public static List<String> translateIncludePaths(IProject project, List<String> sumIncludes) { // first check if cygpath translation is needed at all boolean translationNeeded = false; if (Platform.getOS().equals(Platform.OS_WIN32)) { for (Iterator<String> i = sumIncludes.iterator(); i.hasNext(); ) { String include = i.next(); if (include.startsWith("/")) { // $NON-NLS-1$ translationNeeded = true; break; } } } if (!translationNeeded) { return sumIncludes; } List<String> translatedIncludePaths = new ArrayList<String>(); for (Iterator<String> i = sumIncludes.iterator(); i.hasNext(); ) { String includePath = i.next(); String translatedPath = Cygwin.cygwinToWindowsPath(includePath); translatedIncludePaths.add(translatedPath); } return translatedIncludePaths; }
private void internalSetAuthCredentials( ICredentials credentials, URI link, String realm, boolean persist) throws CredentialsException { /* Store Credentials in In-Memory Store */ if (!persist) { fInMemoryStore.put(toCacheKey(link, realm), credentials); } /* Store Credentials in secure Storage */ else { ISecurePreferences securePreferences = getSecurePreferences(); /* Check if Bundle is Stopped */ if (securePreferences == null) return; /* Store in Equinox Security Storage */ ISecurePreferences allFeedsPreferences = securePreferences.node(SECURE_FEED_NODE); ISecurePreferences feedPreferences = allFeedsPreferences.node(EncodingUtils.encodeSlashes(link.toString())); ISecurePreferences realmPreference = feedPreferences.node(EncodingUtils.encodeSlashes(realm != null ? realm : REALM)); IPreferenceScope globalScope = Owl.getPreferenceService().getGlobalScope(); /* OS Password is only supported on Windows and Mac */ boolean useOSPassword = globalScope.getBoolean(DefaultPreferences.USE_OS_PASSWORD); if (!Platform.OS_WIN32.equals(Platform.getOS()) && !Platform.OS_MACOSX.equals(Platform.getOS())) useOSPassword = false; boolean encryptPW = useOSPassword || globalScope.getBoolean(DefaultPreferences.USE_MASTER_PASSWORD); try { if (credentials.getUsername() != null) realmPreference.put(USERNAME, credentials.getUsername(), encryptPW); if (credentials.getPassword() != null) realmPreference.put(PASSWORD, credentials.getPassword(), encryptPW); if (credentials.getDomain() != null) realmPreference.put(DOMAIN, credentials.getDomain(), encryptPW); realmPreference.flush(); // Flush to disk early } catch (StorageException e) { throw new CredentialsException(Activator.getDefault().createErrorStatus(e.getMessage(), e)); } catch (IOException e) { throw new CredentialsException(Activator.getDefault().createErrorStatus(e.getMessage(), e)); } } /* Uncache */ removeUnprotected(link, realm); }
public static String replaceMultilines(String result) { if (result == null) { return null; } String finalResult; if (Platform.getOS().equals(Platform.OS_WIN32)) { finalResult = result.replaceAll("\r", "").trim(); // $NON-NLS-1$ //$NON-NLS-2$ } else if (Platform.getOS().equals(Platform.OS_MACOSX)) { finalResult = result.replaceAll("\r", "\n").trim(); // $NON-NLS-1$ //$NON-NLS-2$ } else { finalResult = result; } return finalResult; }
private ISecurePreferences getSecurePreferences() { if (!InternalOwl.IS_ECLIPSE) { IPreferenceScope prefs = Owl.getPreferenceService().getGlobalScope(); boolean useOSPasswordProvider = prefs.getBoolean(DefaultPreferences.USE_OS_PASSWORD); /* Disable OS Password if Master Password shall be used */ if (prefs.getBoolean(DefaultPreferences.USE_MASTER_PASSWORD)) useOSPasswordProvider = false; /* Try storing credentials in profile folder */ try { Activator activator = Activator.getDefault(); /* Check if Bundle is Stopped */ if (activator == null) return null; IPath stateLocation = activator.getStateLocation(); stateLocation = stateLocation.append(SECURE_STORAGE_FILE); URL location = stateLocation.toFile().toURL(); Map<String, String> options = null; /* Use OS dependent password provider if available */ if (useOSPasswordProvider) { if (Platform.OS_WIN32.equals(Platform.getOS())) { options = new HashMap<String, String>(); options.put(IProviderHints.REQUIRED_MODULE_ID, WIN_PW_PROVIDER_ID); } else if (Platform.OS_MACOSX.equals(Platform.getOS())) { options = new HashMap<String, String>(); options.put(IProviderHints.REQUIRED_MODULE_ID, MACOS_PW_PROVIDER_ID); } } /* Use RSSOwl password provider */ else { options = new HashMap<String, String>(); options.put(IProviderHints.REQUIRED_MODULE_ID, RSSOWL_PW_PROVIDER_ID); } return SecurePreferencesFactory.open(location, options); } catch (MalformedURLException e) { Activator.safeLogError(e.getMessage(), e); } catch (IllegalStateException e1) { Activator.safeLogError(e1.getMessage(), e1); } catch (IOException e2) { Activator.safeLogError(e2.getMessage(), e2); } } /* Fallback to default location */ return SecurePreferencesFactory.getDefault(); }
public static boolean isExecutable(IPath path) { if (path == null) { return false; } File file = path.toFile(); if (file == null || !file.exists() || file.isDirectory()) { return false; } // OK, file exists try { Method m = File.class.getMethod("canExecute"); // $NON-NLS-1$ if (m != null) { return (Boolean) m.invoke(file); } } catch (Exception e) { } // File.canExecute() doesn't exist; do our best to determine if file is executable... if (Platform.OS_WIN32.equals(Platform.getOS())) { return true; } IFileStore fileStore = EFS.getLocalFileSystem().getStore(path); return fileStore.fetchInfo().getAttribute(EFS.ATTRIBUTE_EXECUTABLE); }
public void testInterfaceWithInvalidCharacter() { if (Platform.getOS().contains("win")) { doNewCMETest("Components::Interface", INVALID_CHAR_ERROR, "*"); } else { doNewCMETest("Components::Interface", INVALID_UNIX_CHAR_ERROR, "/"); } }
public void testClassWithInvalidCharacter() { if (Platform.getOS().contains("win")) { doNewCMETest("Classes::Class", INVALID_CHAR_ERROR, "*"); } else { doNewCMETest("Classes::Class", INVALID_UNIX_CHAR_ERROR, "/"); } }
public int runDirectorToInstall( String message, File installFolder, String sourceRepo, String iuToInstall) { String[] command = new String[] { // "-application", "org.eclipse.equinox.p2.director", // "-repository", sourceRepo, "-installIU", iuToInstall, // "-destination", installFolder.getAbsolutePath(), // "-bundlepool", installFolder.getAbsolutePath(), // "-roaming", "-profile", "PlatformProfile", "-profileProperties", "org.eclipse.update.install.features=true", // "-p2.os", Platform.getOS(), "-p2.ws", Platform.getWS(), "-p2.arch", Platform.getOSArch() }; return runEclipse(message, command); }
public void testSingleQuoted2() throws Exception { if (Platform.getOS().equals(Constants.OS_WIN32)) { execute1Arg("'1'", "'1'", "'1'"); // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ } else { execute1Arg("'1'", "1", "1"); // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ } }
public void testSingleQuoted1() throws Exception { if (Platform.getOS().equals(Constants.OS_WIN32)) { execute("'1 2'", new String[] {"'1", "2'"}); // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ } else { execute("'1 2'", new String[] {"1 2"}, "\"1 2\""); // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ } }
public void testDoubleQuoted4() throws Exception { if (Platform.getOS().equals(Constants.OS_WIN32)) { execute1Arg("\"\"\"\"", "\"", "\\\""); // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ } else { execute1Arg("\"\"\"\"", "", "\"\""); // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ } }
public void testEscape() throws Exception { if (Platform.getOS().equals(Constants.OS_WIN32)) { execute1Arg("\\1"); // $NON-NLS-1$ } else { execute1Arg("\\1", "1", "1"); // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ } }
public void run(IAction action) { final TransformToGenModelWizard wiz = new TransformToGenModelWizard(); wiz.setWindowTitle(action.getText()); wiz.init(PlatformUI.getWorkbench(), sselection); WizardDialog wd = new WizardDialog(getShell(), wiz); wd.create(); Rectangle mb = getShell().getMonitor().getClientArea(); Point dpi = getShell().getDisplay().getDPI(); if (Platform.OS_MACOSX.equals(Platform.getOS())) { dpi = new Point(110, 110); // OSX DPI is always 72; 110 is a common value for modern LCD screens } int width = dpi.x * WIZARD_WIDTH_INCH; int height = dpi.y * WIZARD_HEIGHT_INCH; int x = mb.x + (mb.width - width) / 2; if (x < mb.x) { x = mb.x; } int y = mb.y + (mb.height - height) / 2; if (y < mb.y) { y = mb.y; } wd.getShell().setLocation(x, y); wd.getShell().setSize(width, height); wd.open(); }
public Object getSourceElement(IStackFrame stackFrame) { if (stackFrame instanceof ScriptStackFrame) { ScriptStackFrame sf = (ScriptStackFrame) stackFrame; URI uri = sf.getFileName(); String pathname = uri.getPath(); if (Platform.getOS().equals(Platform.OS_WIN32)) { pathname = pathname.substring(1); } File file = new File(pathname); IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); IContainer container = root.getContainerForLocation(new Path(file.getParent())); if (container != null) { IResource resource = container.findMember(file.getName()); if (resource instanceof IFile) { return (IFile) resource; } } else { return file; } } return null; }
/** * Execute the zipalign for a certain apk * * @param apk */ public static void zipAlign(File apk) { // String zipAlign = SdkUtils.getSdkToolsPath(); String zipAlign = AndroidUtils.getSDKPathByPreference() + IPath.SEPARATOR + IAndroidConstants.FD_TOOLS; try { File tempFile = File.createTempFile("_tozipalign", ".apk"); FileUtil.copyFile(apk, tempFile); if (!zipAlign.endsWith(File.separator)) { zipAlign += File.separator; } zipAlign += Platform.getOS().equals(Platform.OS_WIN32) ? "zipalign.exe" : "zipalign"; String[] command = new String[] { zipAlign, "-f", "-v", "4", tempFile.getAbsolutePath(), apk.getAbsolutePath() }; StringBuilder commandLine = new StringBuilder(); for (String commandPart : command) { commandLine.append(commandPart); commandLine.append(" "); } AndmoreLogger.info(PackageFile.class, "Zipaligning package: " + commandLine.toString()); Runtime.getRuntime().exec(command); } catch (IOException e) { AndmoreLogger.error(PackageFile.class, "Error while zipaligning package", e); } catch (Exception e) { AndmoreLogger.error( PackageFile.class, "Zipalign application cannot be executed - insuficient permissions", e); } }
/** * Returns a new working directory (in temporary space). Ensures the directory exists. Any * directory levels that had to be created are marked for deletion on exit. * * @return working directory * @exception IOException * @since 2.0 */ public static synchronized File createWorkingDirectory() throws IOException { if (dirRoot == null) { dirRoot = System.getProperty("java.io.tmpdir"); // $NON-NLS-1$ // in Linux, returns '/tmp', we must add '/' if (!dirRoot.endsWith(File.separator)) dirRoot += File.separator; // on Unix/Linux, the temp dir is shared by many users, so we need to ensure // that the top working directory is different for each user if (!Platform.getOS().equals("win32")) { // $NON-NLS-1$ String home = System.getProperty("user.home"); // $NON-NLS-1$ home = Integer.toString(home.hashCode()); dirRoot += home + File.separator; } dirRoot += "eclipse" + File.separator + ".update" + File.separator + Long.toString(tmpseed) + File.separator; // $NON-NLS-1$ //$NON-NLS-2$ } String tmpName = dirRoot + Long.toString(++tmpseed) + File.separator; File tmpDir = new File(tmpName); verifyPath(tmpDir, false); if (!tmpDir.exists()) throw new FileNotFoundException(tmpName); return tmpDir; }
/* * (non-Javadoc) * * @see org.eclipse.swt.widgets.Widget#dispose() */ @Override public void dispose() { if (androidInput != null) { androidInput.dispose(); } if (currentSkinImage != null) { currentSkinImage.dispose(); } Layout layout = getLayout(); if (layout instanceof AndroidSkinLayout) { ((AndroidSkinLayout) layout).dispose(); } skin = null; currentKey = null; keyListener = null; mainDisplayMouseListener = null; mainDisplayMouseMoveListener = null; if (!Platform.getOS().equals(Platform.OS_MACOSX)) { long hnd = androidInstance.getWindowHandle(); if (hnd > 0) { NativeUIUtils.showWindow(hnd); NativeUIUtils.restoreWindow(hnd); } // Force update on redrawing androidInstance.setWindowHandle(0); } super.dispose(); }
@Override public Path getCommandPath(Path command) { if (command.isAbsolute()) { return command; } if (Platform.getOS().equals(Platform.OS_WIN32)) { if (!command.toString().endsWith(".exe")) { // $NON-NLS-1$ command = Paths.get(command.toString() + ".exe"); // $NON-NLS-1$ } } if (path != null) { for (Path p : path) { Path c = p.resolve(command); if (Files.isExecutable(c)) { return c; } } } // Look for it in the path environment var IEnvironmentVariable myPath = getVariable("PATH"); // $NON-NLS-1$ String path = myPath != null ? myPath.getValue() : System.getenv("PATH"); // $NON-NLS-1$ for (String entry : path.split(File.pathSeparator)) { Path entryPath = Paths.get(entry); Path cmdPath = entryPath.resolve(command); if (Files.isExecutable(cmdPath)) { return cmdPath; } } return null; }
/** * Start vim and embed it in the Window with the <code>wid</code> (platform-dependent!) given. * * @param workingDir * @param wid The id of the window to embed vim into */ public void start(String workingDir, long wid) { // gather Strings (nice names for readbility) String gvim = VimPlugin.getDefault().getPreferenceStore().getString(PreferenceConstants.P_GVIM); String netbeans = getNetbeansString(ID); String dontfork = "-f"; // foreground -- dont fork // Platform specific code String socketid = "--socketid"; // use --windowid, under win32 if (Platform.getOS().equals(Platform.OS_WIN32)) { socketid = "--windowid"; } String stringwid = String.valueOf(wid); String[] addopts = getUserArgs(); // build args-array (dynamic size due to addopts.split) String[] args = new String[9 + addopts.length]; args[0] = gvim; args[1] = "--servername"; args[2] = String.valueOf(ID); args[3] = netbeans; args[4] = dontfork; args[5] = socketid; args[6] = stringwid; args[7] = "--cmd"; args[8] = "let g:vimplugin_running = 1"; // copy addopts to args System.arraycopy(addopts, 0, args, 9, addopts.length); start(workingDir, true, false, args); }
private static RSetup loadSetup( final String id, final Map<String, String> filter, final IConfigurationElement[] configurationElements) { try { for (int i = 0; i < configurationElements.length; i++) { final IConfigurationElement element = configurationElements[i]; if (element.getName().equals(SETUP_ELEMENT_NAME) && id.equals(element.getAttribute(ID_ATTRIBUTE_NAME))) { final RSetup setup = new RSetup(id); if (filter != null && filter.containsKey("$os$")) { // $NON-NLS-1$ setup.setOS(filter.get("$os$"), filter.get("$arch$")); // $NON-NLS-1$ //$NON-NLS-2$ } else { setup.setOS(Platform.getOS(), Platform.getOSArch()); } setup.setName(element.getAttribute(NAME_ATTRIBUTE_NAME)); loadSetupBase(id, filter, configurationElements, setup); if (setup.getRHome() == null) { log( IStatus.WARNING, "Incomplete R setup: Missing R home for setup '" + id + "', the setup is ignored.", element); return null; } loadSetupLibraries(id, filter, configurationElements, setup); return setup; } } } catch (final Exception e) { LOGGER.log( new Status(IStatus.ERROR, PLUGIN_ID, "Error in R setup: Failed to load setup.", e)); } return null; }
private void hideMenuCheck() { try { URL pluginUrl = Platform.getBundle(GrassUiPlugin.PLUGIN_ID).getResource("/"); String pluginPath = FileLocator.toFileURL(pluginUrl).getPath(); File pluginFile = new File(pluginPath); File installFolder = pluginFile.getParentFile().getParentFile().getParentFile(); File grassFolderFile = new File(installFolder, "grass"); if (Platform.getOS().equals(Platform.OS_WIN32)) { if (!grassFolderFile.exists() || !grassFolderFile.isDirectory()) { IWorkbenchWindow[] wwindows = PlatformUI.getWorkbench().getWorkbenchWindows(); String actionSetID = "eu.hydrologis.jgrass.ui.grassactionset"; for (IWorkbenchWindow iWorkbenchWindow : wwindows) { IWorkbenchPage activePage = iWorkbenchWindow.getActivePage(); if (activePage != null) { activePage.hideActionSet(actionSetID); MenuManager mbManager = ((ApplicationWindow) iWorkbenchWindow).getMenuBarManager(); for (int i = 0; i < mbManager.getItems().length; i++) { IContributionItem item = mbManager.getItems()[i]; if (item.getId().equals(actionSetID)) { item.setVisible(false); } } } } } } } catch (IOException e) { e.printStackTrace(); } }
static { if (Platform.OS_MACOSX.equals(Platform.getOS())) { MODIFIER_NO_SNAPPING = SWT.CTRL; } else { MODIFIER_NO_SNAPPING = SWT.ALT; } }
public void testCopyFromNonReadableDirectory() throws Exception { // We can use source.setReadable(false) when we decide to use java 1.6 if (!Platform.OS_WIN32.equals(Platform.getOS())) { URL resourceURL = Platform.getBundle(BUNDLE_ID).getEntry(RESOURCE_DIR); File resourceFolder = ResourceUtil.resourcePathToFile(resourceURL); File source = new File(resourceFolder, TEST_DIR); File dest = new File(tempDir, "tempdir"); try { Runtime.getRuntime() .exec(new String[] {"chmod", "333", source.getAbsolutePath()}) .waitFor(); //$NON-NLS-1$ IOUtil.copyDirectory(source, dest); assertDirectory(source, dest); fail("Expected directories to not match"); } catch (AssertionError ae) { // expected } finally { FileUtil.deleteRecursively(dest); Runtime.getRuntime() .exec(new String[] {"chmod", "755", source.getAbsolutePath()}) .waitFor(); //$NON-NLS-1$ } } }
protected List<String> get_X86_REGS() { List<String> list = new LinkedList<String>( Arrays.asList( "eax", "ecx", "edx", "ebx", "esp", "ebp", "esi", "edi", "eip", "eflags", "cs", "ss", "ds", "es", "fs", "gs", "st0", "st1", "st2", "st3", "st4", "st5", "st6", "st7", "fctrl", "fstat", "ftag", "fiseg", "fioff", "foseg", "fooff", "fop", "xmm0", "xmm1", "xmm2", "xmm3", "xmm4", "xmm5", "xmm6", "xmm7", "mxcsr", "orig_eax", "mm0", "mm1", "mm2", "mm3", "mm4", "mm5", "mm6", "mm7")); // On Windows, gdb doesn't report "orig_eax" as a register. Apparently it does on Linux if (Platform.getOS().equals(Platform.OS_WIN32)) { list.remove("orig_eax"); } return list; }
/** * Tests a JDT source feature bundle container contains the appropriate bundles * * @throws Exception */ public void testSourceFeatureBundleContainer() throws Exception { // extract the feature IPath location = extractModifiedFeatures(); ITargetDefinition definition = getNewTarget(); ITargetLocation container = getTargetService() .newFeatureLocation(location.toOSString(), "org.eclipse.jdt.source", null); container.resolve(definition, null); TargetBundle[] bundles = container.getBundles(); List expected = new ArrayList(); expected.add("org.eclipse.jdt.source"); expected.add("org.eclipse.jdt.launching.source"); // There are two versions of junit available, each with source expected.add("org.junit.source"); expected.add("org.junit.source"); if (Platform.getOS().equals(Platform.OS_MACOSX)) { expected.add("org.eclipse.jdt.launching.macosx.source"); } assertEquals("Wrong number of bundles", expected.size(), bundles.length); for (int i = 0; i < bundles.length; i++) { if (bundles[i].getBundleInfo().getSymbolicName().equals("org.eclipse.jdt.doc.isv")) { assertFalse("Should not be a source bundle", bundles[i].isSourceBundle()); } else { assertTrue(expected.remove(bundles[i].getBundleInfo().getSymbolicName())); assertTrue("Should be a source bundle", bundles[i].isSourceBundle()); } } assertTrue("Wrong bundles in JDT feature", expected.isEmpty()); }
/** * Test sample project with a virtual folder that points to configure scripts. Tests Bug 434275 - * Autotools configuration in subfolder not found * * @throws Exception */ @Test public void testAutotoolsVirtualFolder() throws Exception { Path p = new Path("zip/project2.zip"); IWorkspaceRoot root = ProjectTools.getWorkspaceRoot(); IPath rootPath = root.getLocation(); IPath configPath = rootPath.append("config"); File configDir = configPath.toFile(); configDir.deleteOnExit(); assertTrue(configDir.mkdir()); ProjectTools.createLinkedFolder( testProject, "src", URIUtil.append(root.getLocationURI(), "config")); ProjectTools.addSourceContainerWithImport(testProject, "src", p); assertTrue(testProject.hasNature(AutotoolsNewProjectNature.AUTOTOOLS_NATURE_ID)); assertTrue(exists("src/ChangeLog")); ProjectTools.setConfigDir(testProject, "src"); ProjectTools.markExecutable(testProject, "src/autogen.sh"); assertFalse(exists("src/configure")); assertFalse(exists("src/Makefile.in")); assertFalse(exists("src/sample/Makefile.in")); assertFalse(exists("src/aclocal.m4")); assertTrue(ProjectTools.build()); assertTrue(exists("src/configure")); assertTrue(exists("src/Makefile.in")); assertTrue(exists("src/sample/Makefile.in")); assertTrue(exists("src/aclocal.m4")); assertTrue(exists("config.status")); assertTrue(exists("Makefile")); String extension = Platform.getOS().equals(Platform.OS_WIN32) ? ".exe" : ""; assertTrue(exists("sample/a.out" + extension)); assertTrue(exists("sample/Makefile")); }
/** * Reads and returns the VM arguments specified in the running platform's .ini file, or am empty * string if none. * * @return VM arguments specified in the running platform's .ini file */ public static String getIniVMArgs() { File installDirectory = new File(Platform.getInstallLocation().getURL().getFile()); if (Platform.getOS().equals(Platform.OS_MACOSX)) installDirectory = new File(installDirectory, "Eclipse.app/Contents/MacOS"); // $NON-NLS-1$ File eclipseIniFile = new File(installDirectory, "eclipse.ini"); // $NON-NLS-1$ BufferedReader in = null; StringBuffer result = new StringBuffer(); if (eclipseIniFile.exists()) { try { in = new BufferedReader(new FileReader(eclipseIniFile)); String str; boolean vmargs = false; while ((str = in.readLine()) != null) { if (vmargs) { if (result.length() > 0) result.append(" "); // $NON-NLS-1$ result.append(str); } // start concat'ng if we have vmargs if (vmargs == false && str.equals("-vmargs")) // $NON-NLS-1$ vmargs = true; } } catch (IOException e) { MDECore.log(e); } finally { if (in != null) try { in.close(); } catch (IOException e) { MDECore.log(e); } } } return result.toString(); }
public Section create(Composite parent, FormToolkit toolkit) { boolean twistie = (style & Section.TWISTIE) != 0; boolean expanded = !twistie || (style & Section.EXPANDED) != 0; final Section section = toolkit.createSection(parent, style | Section.NO_TITLE_FOCUS_BOX); section.setText(composite.getName()); GridDataFactory.fillDefaults().grab(true, expanded).applyTo(section); Composite c = toolkit.createComposite(section); GridLayoutFactory.fillDefaults().extendedMargins(0, 0, 0, 5).applyTo(c); composite.createControl(c); Composite forToolbar = new Composite(section, SWT.NONE); FillLayout fl = new FillLayout(); forToolbar.setLayout(fl); if (Platform.getOS().equals(Platform.OS_LINUX)) { fl.marginHeight = -2; } if (Platform.getOS().equals(Platform.OS_MACOSX)) { fl.marginHeight = -2; } composite.createToolBar(forToolbar); section.setClient(c); section.setTextClient(forToolbar); if (twistie) { composite.setVisible(expanded); composite .observeVisible() .addChangeListener( new IChangeListener() { public void handleChange(ChangeEvent event) { GridDataFactory.fillDefaults() .grab(true, composite.getVisible()) .applyTo(section); section.setExpanded(composite.getVisible()); } }); section.addExpansionListener( new ExpansionAdapter() { public void expansionStateChanged(ExpansionEvent e) { composite.setVisible(section.isExpanded()); } }); } return section; }
public static void explore(String name) { File file = new File(name); String command = null; if (file.isFile()) { command = getExploreFileCommand(); } else { command = getExploreCommand(); } if (command != null) { if (Platform.getOS().equals(Platform.OS_WIN32)) { name = name.replace('/', '\\'); } try { if (Platform.OS_LINUX.equals(Platform.getOS()) || Platform.OS_MACOSX.equals(Platform.getOS())) { int len = exploreFolderCommandArray.length; String name2 = file.isFile() ? new Path(name).removeLastSegments(1).toString() : name; exploreFolderCommandArray[len - 1] = name2; Runtime.getRuntime().exec(exploreFolderCommandArray); } else if (Platform.getOS().equals(Platform.OS_WIN32)) { if (file.isDirectory()) { int len = exploreFolderCommandArray.length; exploreFolderCommandArray[len - 1] = "\"" + name + "\""; // $NON-NLS-1$ //$NON-NLS-2$ Runtime.getRuntime().exec(exploreFolderCommandArray); } else { int len = exploreFileCommandArray.length; exploreFileCommandArray[len - 1] = "\"" + name + "\""; // $NON-NLS-1$ //$NON-NLS-2$ Runtime.getRuntime().exec(exploreFileCommandArray); } } else { command = command.replace(ExploreUtils.PATH, name); if (JBossServerUIPlugin.getDefault().isDebugging()) { IStatus status = new Status( IStatus.WARNING, JBossServerUIPlugin.PLUGIN_ID, "command=" + command, null); //$NON-NLS-1$ JBossServerUIPlugin.getDefault().getLog().log(status); } Runtime.getRuntime().exec(command); } } catch (IOException e) { JBossServerUIPlugin.log(e.getMessage(), e); } } }
static { // It appears this call is no longer necessary on Windows as the SWT Mozilla in Eclipse 3.5+ is // performing similar // initialization tasks, and calling it was causing a crash when initializing the profile if (!Platform.OS_WIN32.equals(Platform.getOS())) { FirefoxExtensionsSupport.init(); } }