# HG changeset patch # User Alexander Simon # Date 1408955979 -14400 # Mon Aug 25 12:39:39 2014 +0400 # Node ID f0bcbf5dc2694a4d6f6b6c4b3040229da1bf7870 # Parent 14a4f64d0f15d103af61b4d711f25c21ae333fa5 fixing Bug 246668 - There is no setup local host - move host info setup in server record initialization diff --git a/cnd.discovery/src/org/netbeans/modules/cnd/discovery/services/UserOptionsProviderImpl.java b/cnd.discovery/src/org/netbeans/modules/cnd/discovery/services/UserOptionsProviderImpl.java --- a/cnd.discovery/src/org/netbeans/modules/cnd/discovery/services/UserOptionsProviderImpl.java +++ b/cnd.discovery/src/org/netbeans/modules/cnd/discovery/services/UserOptionsProviderImpl.java @@ -71,6 +71,7 @@ import org.netbeans.modules.nativeexecution.api.ExecutionEnvironment; import org.netbeans.modules.nativeexecution.api.ExecutionEnvironmentFactory; import org.netbeans.modules.nativeexecution.api.util.ConnectionManager; +import org.netbeans.modules.nativeexecution.api.util.HostInfoUtils; import org.netbeans.modules.nativeexecution.api.util.ProcessUtils; import org.netbeans.modules.nativeexecution.api.util.ProcessUtils.ExitStatus; import org.netbeans.modules.remote.spi.FileSystemProvider; @@ -227,7 +228,7 @@ synchronized(pkgConfigs){ pkg = pkgConfigs.get(hostKey); if (pkg == null) { - if (ConnectionManager.getInstance().isConnectedTo(env)) { + if (ConnectionManager.getInstance().isConnectedTo(env) && HostInfoUtils.isHostInfoAvailable(env)) { pkg = PkgConfigManager.getDefault().getPkgConfig(env); pkgConfigs.put(hostKey, pkg); } diff --git a/cnd.modeldiscovery/src/org/netbeans/modules/cnd/modeldiscovery/provider/PkgConfigImpl.java b/cnd.modeldiscovery/src/org/netbeans/modules/cnd/modeldiscovery/provider/PkgConfigImpl.java --- a/cnd.modeldiscovery/src/org/netbeans/modules/cnd/modeldiscovery/provider/PkgConfigImpl.java +++ b/cnd.modeldiscovery/src/org/netbeans/modules/cnd/modeldiscovery/provider/PkgConfigImpl.java @@ -65,15 +65,12 @@ import org.netbeans.modules.nativeexecution.api.ExecutionEnvironment; import org.netbeans.modules.nativeexecution.api.ExecutionEnvironmentFactory; import org.netbeans.modules.nativeexecution.api.HostInfo; -import org.netbeans.modules.nativeexecution.api.util.ConnectionManager.CancellationException; import org.netbeans.modules.nativeexecution.api.util.HostInfoUtils; import org.netbeans.modules.nativeexecution.api.util.Path; import org.netbeans.modules.nativeexecution.api.util.ProcessUtils; import org.netbeans.modules.nativeexecution.api.util.ProcessUtils.ExitStatus; -import org.netbeans.modules.remote.spi.FileSystemCacheProvider; import org.netbeans.modules.remote.spi.FileSystemProvider; import org.openide.filesystems.FileObject; -import org.openide.util.Exceptions; /** * @@ -87,33 +84,32 @@ private Map> seachBase; private String drivePrefix; private final ExecutionEnvironment env; + private HostInfo.OSFamily OS = HostInfo.OSFamily.LINUX; + private HostInfo.Bitness BITNESS = HostInfo.Bitness._32; public PkgConfigImpl(ExecutionEnvironment env) { this.env = env; + HostInfo hostInfo = getHostInfo(env); + if (hostInfo != null) { + OS = hostInfo.getOSFamily(); + BITNESS = hostInfo.getOS().getBitness(); + } initPackages(); } - private boolean isWindows() { + private HostInfo getHostInfo(ExecutionEnvironment env) { try { - return HostInfoUtils.getHostInfo(env).getOSFamily()== HostInfo.OSFamily.WINDOWS; - } catch (Exception ex) { + return HostInfoUtils.getHostInfo(env); + } catch (Throwable ex) { ex.printStackTrace(System.err); - return false; + return null; } } - private boolean isLinux() { - try { - return HostInfoUtils.getHostInfo(env).getOSFamily()== HostInfo.OSFamily.LINUX; - } catch (Exception ex) { - ex.printStackTrace(System.err); - return false; - } - } - + private List envPaths(String folder, String... foders){ List res = new ArrayList(); String pkg_config; - if (isWindows()) { + if (OS == HostInfo.OSFamily.WINDOWS) { pkg_config = "pkg-config.exe"; // NOI18N } else { pkg_config = "pkg-config"; // NOI18N @@ -131,7 +127,7 @@ private void addPaths(List res, String additionalPaths) { if (additionalPaths != null && additionalPaths.length() > 0) { StringTokenizer st; - if (isWindows()){ + if (OS == HostInfo.OSFamily.WINDOWS){ st = new StringTokenizer(additionalPaths, ";"); // NOI18N } else { st = new StringTokenizer(additionalPaths, ":"); // NOI18N @@ -143,7 +139,7 @@ } private void initPackages() { - if (isWindows()){ + if (OS == HostInfo.OSFamily.WINDOWS){ // at first find pkg-config.exe in paths String baseDirectory = getPkgConfihPath(); if (baseDirectory == null) { @@ -175,18 +171,8 @@ initPackages(envPaths(baseDirectory), true); // NOI18N } else { //initPackages("/net/elif/export1/sside/as204739/pkgconfig/"); // NOI18N - if (isLinux()) { - HostInfo hostinfo = null; - try { - if (HostInfoUtils.isHostInfoAvailable(env)) { - hostinfo = HostInfoUtils.getHostInfo(env); - } - } catch (IOException ex) { - Exceptions.printStackTrace(ex); - } catch (CancellationException ex) { - Exceptions.printStackTrace(ex); - } - if (hostinfo != null && hostinfo.getOS().getBitness() == HostInfo.Bitness._64) { + if (OS == HostInfo.OSFamily.LINUX) { + if (BITNESS == HostInfo.Bitness._64) { initPackages(envPaths("/usr/lib64/pkgconfig", "/usr/share/pkgconfig"), false); // NOI18N } else { initPackages(envPaths("/usr/lib/pkgconfig", "/usr/share/pkgconfig"), false); // NOI18N @@ -393,7 +379,7 @@ Map> res = new HashMap>(); for (Map.Entry> entry : map.entrySet()) { Pair pair = new Pair(entry.getKey(), entry.getValue()); - if (isWindows()){ + if (OS == HostInfo.OSFamily.WINDOWS){ if (entry.getKey().length() < 2 || entry.getKey().charAt(1) != ':') { if (TRACE) { System.err.println("ignore relative path "+entry.getKey()); diff --git a/cnd.remote/src/org/netbeans/modules/cnd/remote/server/RemoteServerList.java b/cnd.remote/src/org/netbeans/modules/cnd/remote/server/RemoteServerList.java --- a/cnd.remote/src/org/netbeans/modules/cnd/remote/server/RemoteServerList.java +++ b/cnd.remote/src/org/netbeans/modules/cnd/remote/server/RemoteServerList.java @@ -43,6 +43,7 @@ import java.beans.PropertyChangeListener; import java.beans.PropertyChangeSupport; +import java.io.IOException; import java.io.PrintWriter; import java.util.ArrayList; import java.util.Collection; @@ -69,9 +70,11 @@ import org.netbeans.modules.nativeexecution.api.util.ConnectionListener; import org.netbeans.modules.nativeexecution.api.util.ConnectionManager; import org.netbeans.modules.nativeexecution.api.util.FileInfoProvider; +import org.netbeans.modules.nativeexecution.api.util.HostInfoUtils; import org.netbeans.modules.nativeexecution.api.util.PasswordManager; import org.netbeans.modules.nativeexecution.api.util.ProcessUtils; import org.openide.util.ChangeSupport; +import org.openide.util.Exceptions; import org.openide.util.Lookup; import org.openide.util.NbPreferences; import org.openide.util.RequestProcessor; @@ -103,9 +106,25 @@ // Creates the "localhost" record and any remote records cached in remote.preferences // "localhost" record - RemoteServerRecord localRecord = new RemoteServerRecord(ExecutionEnvironmentFactory.getLocal(), null, RemoteSyncFactory.getDefault(), false); - localRecord.setState(RemoteServerRecord.State.ONLINE); + + final ExecutionEnvironment localEnv = ExecutionEnvironmentFactory.getLocal(); + final RemoteServerRecord localRecord = new RemoteServerRecord(localEnv, null, RemoteSyncFactory.getDefault(), false); items.add(localRecord); + localRecord.setState(HostInfoUtils.isHostInfoAvailable(localEnv) ? RemoteServerRecord.State.ONLINE : RemoteServerRecord.State.OFFLINE); + if (!HostInfoUtils.isHostInfoAvailable(localEnv)) { + RP.post(new Runnable() { + @Override + public void run() { + try { + HostInfoUtils.getHostInfo(localEnv); + localRecord.checkHostInfo(); + localRecord.setState(HostInfoUtils.isHostInfoAvailable(localEnv) ? RemoteServerRecord.State.ONLINE : RemoteServerRecord.State.OFFLINE); + } catch (Throwable ex) { + ex.printStackTrace(System.err); + } + } + }); + } // now remote records cached in remote.preferences String slist = getPreferences().get(REMOTE_SERVERS, null); diff --git a/cnd.remote/src/org/netbeans/modules/cnd/remote/server/RemoteServerRecord.java b/cnd.remote/src/org/netbeans/modules/cnd/remote/server/RemoteServerRecord.java --- a/cnd.remote/src/org/netbeans/modules/cnd/remote/server/RemoteServerRecord.java +++ b/cnd.remote/src/org/netbeans/modules/cnd/remote/server/RemoteServerRecord.java @@ -66,6 +66,7 @@ import org.netbeans.modules.nativeexecution.api.util.HostInfoUtils; import org.netbeans.modules.nativeexecution.api.util.PasswordManager; import org.openide.awt.StatusDisplayer; +import org.openide.util.Exceptions; import org.openide.util.Lookup; import org.openide.util.NbBundle; @@ -177,50 +178,76 @@ */ public synchronized void init(PropertyChangeSupport pcs) { assert !SwingUtilities.isEventDispatchThread() : "RemoteServer initialization must be done out of EDT"; // NOI18N - try { - ConnectionManager.getInstance().connectTo(executionEnvironment); - } catch (IOException ex) { - StatusDisplayer.getDefault().setStatusText(NbBundle.getMessage(RemoteServerRecord.class, "ERR_ConnectingToHost", executionEnvironment, ex.getLocalizedMessage())); - reason = ex.getMessage(); - setState(State.OFFLINE); - return; - } catch (CancellationException ex) { - setState(State.CANCELLED); - return; - } - Object ostate = state; - setState(State.INITIALIZING); - RemoteServerSetup rss = new RemoteServerSetup(getExecutionEnvironment()); - if (!Boolean.getBoolean("cnd.remote.skip.setup")) { - if (rss.needsSetupOrUpdate()) { - rss.setup(); + final ExecutionEnvironment env = getExecutionEnvironment(); + if (env.isLocal()) { + Object ostate = state; + try { + HostInfoUtils.getHostInfo(env); + } catch (IOException ex) { + StatusDisplayer.getDefault().setStatusText(NbBundle.getMessage(RemoteServerRecord.class, "ERR_ConnectingToHost", executionEnvironment, ex.getLocalizedMessage())); + reason = ex.getMessage(); + setState(State.OFFLINE); + return; + } catch (CancellationException ex) { + setState(State.CANCELLED); + return; } - } -// if (ostate == State.UNINITIALIZED) { -// checkX11Forwarding(); -// } - boolean initPathMap = false; - - synchronized (stateLock) { - if (rss.isCancelled()) { - setState(State.CANCELLED); - } else if (rss.isFailed()) { - reason = rss.getReason(); - setState(State.OFFLINE); - } else { - initPathMap = true; - setState(State.ONLINE); - if (rss.hasProblems()) { - problems = rss.getReason(); + synchronized (stateLock) { + if (HostInfoUtils.isHostInfoAvailable(env)) { + setState(State.ONLINE); + } else { + setState(State.OFFLINE); } } + if (pcs != null) { + pcs.firePropertyChange(RemoteServerRecord.PROP_STATE_CHANGED, ostate, state); + } + } else { + try { + ConnectionManager.getInstance().connectTo(executionEnvironment); + } catch (IOException ex) { + StatusDisplayer.getDefault().setStatusText(NbBundle.getMessage(RemoteServerRecord.class, "ERR_ConnectingToHost", executionEnvironment, ex.getLocalizedMessage())); + reason = ex.getMessage(); + setState(State.OFFLINE); + return; + } catch (CancellationException ex) { + setState(State.CANCELLED); + return; + } + Object ostate = state; + setState(State.INITIALIZING); + RemoteServerSetup rss = new RemoteServerSetup(env); + if (!Boolean.getBoolean("cnd.remote.skip.setup")) { + if (rss.needsSetupOrUpdate()) { + rss.setup(); + } + } + // if (ostate == State.UNINITIALIZED) { + // checkX11Forwarding(); + // } + boolean initPathMap = false; + + synchronized (stateLock) { + if (rss.isCancelled()) { + setState(State.CANCELLED); + } else if (rss.isFailed()) { + reason = rss.getReason(); + setState(State.OFFLINE); + } else { + initPathMap = true; + setState(State.ONLINE); + if (rss.hasProblems()) { + problems = rss.getReason(); + } + } + } + if (initPathMap) { + RemotePathMap.getPathMap(env).initIfNeeded(); + } + if (pcs != null) { + pcs.firePropertyChange(RemoteServerRecord.PROP_STATE_CHANGED, ostate, state); + } } - if (initPathMap) { - RemotePathMap.getPathMap(getExecutionEnvironment()).initIfNeeded(); - } - if (pcs != null) { - pcs.firePropertyChange(RemoteServerRecord.PROP_STATE_CHANGED, ostate, state); - } } @Override diff --git a/dlight.nativeexecution/src/org/netbeans/modules/nativeexecution/support/hostinfo/impl/UnixHostInfoProvider.java b/dlight.nativeexecution/src/org/netbeans/modules/nativeexecution/support/hostinfo/impl/UnixHostInfoProvider.java --- a/dlight.nativeexecution/src/org/netbeans/modules/nativeexecution/support/hostinfo/impl/UnixHostInfoProvider.java +++ b/dlight.nativeexecution/src/org/netbeans/modules/nativeexecution/support/hostinfo/impl/UnixHostInfoProvider.java @@ -272,7 +272,6 @@ nbstart = NbStartUtility.getInstance().getPath(execEnv, hostInfo); } catch (IOException ex) { log.log(Level.WARNING, "Failed to get remote path of NbStartUtility", ex); // NOI18N - Exceptions.printStackTrace(ex); } String envPath = hostInfo.getEnvironmentFile(); diff --git a/dlight.terminal/src/org/netbeans/modules/dlight/terminal/action/TerminalSupportImpl.java b/dlight.terminal/src/org/netbeans/modules/dlight/terminal/action/TerminalSupportImpl.java --- a/dlight.terminal/src/org/netbeans/modules/dlight/terminal/action/TerminalSupportImpl.java +++ b/dlight.terminal/src/org/netbeans/modules/dlight/terminal/action/TerminalSupportImpl.java @@ -150,27 +150,29 @@ final HostInfo hostInfo; try { hostInfo = HostInfoUtils.getHostInfo(env); - boolean isSupported = PtySupport.isSupportedFor(env); - if (!isSupported) { - if (!silentMode) { - String message; + } catch (Throwable ex) { + ex.printStackTrace(System.err); + if (!silentMode) { + String message = NbBundle.getMessage(TerminalSupportImpl.class, "LocalTerminalNotSupported.error"); // NOI18N + NotifyDescriptor nd = new NotifyDescriptor.Message(message, NotifyDescriptor.INFORMATION_MESSAGE); + DialogDisplayer.getDefault().notify(nd); + } + return; + } + boolean isSupported = PtySupport.isSupportedFor(env); + if (!isSupported) { + if (!silentMode) { + String message; - if (hostInfo.getOSFamily() == HostInfo.OSFamily.WINDOWS) { - message = NbBundle.getMessage(TerminalSupportImpl.class, "LocalTerminalNotSupported.error.nocygwin"); // NOI18N - } else { - message = NbBundle.getMessage(TerminalSupportImpl.class, "LocalTerminalNotSupported.error"); // NOI18N - } + if (hostInfo.getOSFamily() == HostInfo.OSFamily.WINDOWS) { + message = NbBundle.getMessage(TerminalSupportImpl.class, "LocalTerminalNotSupported.error.nocygwin"); // NOI18N + } else { + message = NbBundle.getMessage(TerminalSupportImpl.class, "LocalTerminalNotSupported.error"); // NOI18N + } - NotifyDescriptor nd = new NotifyDescriptor.Message(message, NotifyDescriptor.INFORMATION_MESSAGE); - DialogDisplayer.getDefault().notify(nd); - } - return; + NotifyDescriptor nd = new NotifyDescriptor.Message(message, NotifyDescriptor.INFORMATION_MESSAGE); + DialogDisplayer.getDefault().notify(nd); } - } catch (IOException ex) { - Exceptions.printStackTrace(ex); - return; - } catch (CancellationException ex) { - Exceptions.printStackTrace(ex); return; }