List of usage examples for org.eclipse.jface.preference IPreferenceStore getString
String getString(String name);
From source file:com.palantir.typescript.services.language.LanguageService.java
License:Apache License
private void updateCompilationSettings() { IPreferenceStore preferenceStore = TypeScriptPlugin.getDefault().getPreferenceStore(); CompilationSettings compilationSettings = new CompilationSettings( preferenceStore.getBoolean(IPreferenceConstants.COMPILER_NO_LIB), LanguageVersion.valueOf(preferenceStore.getString(IPreferenceConstants.COMPILER_CODE_GEN_TARGET)), ModuleGenTarget.valueOf(preferenceStore.getString(IPreferenceConstants.COMPILER_MODULE_GEN_TARGET)), preferenceStore.getBoolean(IPreferenceConstants.COMPILER_MAP_SOURCE_FILES), preferenceStore.getBoolean(IPreferenceConstants.COMPILER_REMOVE_COMMENTS)); Request request = new Request(SERVICE, "setCompilationSettings", compilationSettings); this.bridge.call(request, Void.class); }
From source file:com.palantir.typescript.TypeScriptBuilder.java
License:Apache License
private void ensureOutputFolderExists(IProgressMonitor monitor) throws CoreException { IPreferenceStore projectPreferenceStore = new ProjectPreferenceStore(this.getProject()); // ensure the output directory exists if it was specified String outputFolderName = projectPreferenceStore.getString(IPreferenceConstants.COMPILER_OUT_DIR); if (!Strings.isNullOrEmpty(outputFolderName)) { IFolder outputFolder = this.getProject().getFolder(outputFolderName); if (!outputFolder.exists()) { EclipseResources.createParentDirs(outputFolder, monitor); // mark the folder as derived so built resources don't show up in file searches outputFolder.setDerived(true, monitor); }/* ww w . j ava2 s . c o m*/ } }
From source file:com.palantir.typescript.TypeScriptBuilder.java
License:Apache License
private boolean isOutputFileSpecified() { IPreferenceStore projectPreferenceStore = new ProjectPreferenceStore(this.getProject()); return !Strings.isNullOrEmpty(projectPreferenceStore.getString(IPreferenceConstants.COMPILER_OUT_FILE)); }
From source file:com.peergreen.eclipse.osgi.PeergreenLaunchConfiguration.java
License:Apache License
@Override public String[] getClasspath(ILaunchConfiguration launchConfiguration) throws CoreException { String[] configurationClasspath = super.getClasspath(launchConfiguration); List<String> classpath = new ArrayList<>(); // Find the plugin model final IPluginModelBase peergreenPlugin = PluginRegistry.findModel(PLUGIN_ID); if (peergreenPlugin == null) { throw new CoreException(new Status(IStatus.ERROR, PLUGIN_ID, String.format("Unable to find the '%s' plugin", PLUGIN_ID))); }/* www . j a v a2 s . c o m*/ String installLocation = peergreenPlugin.getInstallLocation(); File installLocationPath = new File(installLocation); // Jar file ? if (installLocationPath.isFile()) { classpath.add(installLocation); } else { // add unpack directory classpath.add(installLocationPath.getPath()); // directory. In development mode, adds target/classes classpath.add(new File(installLocationPath, "target" + File.separator + "classes").getPath()); } // Get server path from the preference store IPreferenceStore preferenceStore = Activator.getDefault().getPreferenceStore(); String serverPath = preferenceStore.getString(SERVER_PATH); classpath.add(serverPath); // adds existing classpath from super methode classpath.addAll(Arrays.asList(configurationClasspath)); // transform list into array return classpath.toArray(new String[classpath.size()]); }
From source file:com.peergreen.eclipse.osgi.preferences.PeergreenPreferencePage.java
License:Apache License
@Override public void init(IWorkbench workbench) { // Initialize the values Activator activator = Activator.getDefault(); if (activator != null) { IPreferenceStore preferenceStore = activator.getPreferenceStore(); if (preferenceStore != null) { setPreferenceStore(preferenceStore); String xmlContent = preferenceStore.getString(SERVER_XML_CONTENT); try { this.serversConfiguration = new ServersConfigurationReader() .parse(new StringReader(xmlContent)); } catch (ParsingException e) { throw new IllegalStateException("Cannot parse XML file", e); }//from w w w . j ava 2 s.c o m } } }
From source file:com.peergreen.eclipse.osgi.preferences.PreferenceInitializer.java
License:Apache License
@Override public void initializeDefaultPreferences() { IPreferenceStore store = Activator.getDefault().getPreferenceStore(); Enumeration<String> serversPath = Activator.getDefault().getBundle().getEntryPaths(SERVERS_PATH); if (serversPath == null || !serversPath.hasMoreElements()) { throw new IllegalStateException( String.format("Unable to find any peergreen server in '%s' plugin", PLUGIN_ID)); }/* w w w . j a v a 2 s . co m*/ URL serverURL = null; String defaultServerPath = null; // Now, add entry for each server while (serversPath.hasMoreElements()) { String serverPath = serversPath.nextElement(); try { URL url = Activator.getDefault().getBundle().getEntry(serverPath); if (url == null) { throw new IllegalStateException( String.format("Unable to find the peergreen server in '%s' plugin", PLUGIN_ID)); } serverURL = FileLocator.toFileURL(FileLocator.resolve(url)); defaultServerPath = serverURL.getPath(); } catch (IOException e) { throw new IllegalStateException( String.format("Unable to find the peergreen server in '%s' plugin", PLUGIN_ID), e); } store.setDefault(SERVER_PATH, defaultServerPath); } // validate the current value String path = store.getString(SERVER_PATH); if (path != null && !path.equals(defaultServerPath)) { File localFile = new File(path); // file removed so revert to the default value if (!localFile.exists()) { store.setValue(SERVER_PATH, defaultServerPath); } } // XM file ? String xmlContent = store.getString(SERVER_XML_CONTENT); if (xmlContent == null || "".equals(xmlContent)) { // initialize default xml try (JarFile jarFile = new JarFile(defaultServerPath)) { // Check if manifest is OK Manifest manifest = jarFile.getManifest(); String serverName = manifest.getMainAttributes().getValue("Peergreen-Server-Name"); String version = manifest.getMainAttributes().getValue(Name.IMPLEMENTATION_VERSION); // no name if (serverName == null) { throw new IllegalStateException(String.format( "Selected file %s is a JAR file but not a valid Peergreen Server", defaultServerPath)); } // no version if (version == null) { throw new IllegalStateException(String .format("Unable to find the version of the Peergreen Server %s", defaultServerPath)); } xmlContent = "<peergreen-server><entry name='".concat(serverName).concat("' version='") .concat(version).concat("' isDefault='true' localPath='").concat(defaultServerPath) .concat("' /></peergreen-server>>"); store.setDefault(SERVER_XML_CONTENT, xmlContent); } catch (IOException e) { throw new IllegalStateException(String.format("Unable to open the jar file %s", defaultServerPath)); } } /*String defaultServerPath = null; URL serverURL = null; try { URL url = Activator.getDefault().getBundle().getEntry(ENTRY); if (url == null) { throw new IllegalStateException(String.format("Unable to find the peergreen server in '%s' plugin", PLUGIN_ID)); } serverURL = FileLocator.toFileURL(FileLocator.resolve(url)); defaultServerPath = serverURL.getPath(); } catch (IOException e) { throw new IllegalStateException(String.format("Unable to find the peergreen server in '%s' plugin", PLUGIN_ID), e); } store.setDefault(SERVER_PATH, defaultServerPath); // validate the current value String path = store.getString(SERVER_PATH); if (path != null && !path.equals(defaultServerPath)) { File localFile = new File(path); // file removed so revert to the default value if (!localFile.exists()) { store.setValue(SERVER_PATH, defaultServerPath); } } // XM file ? String xmlContent = store.getString(SERVER_XML_CONTENT); if (xmlContent == null || "".equals(xmlContent)) { // initialize default xml xmlContent = "<peergreen-server><entry name='Peergreen Server Light' version='1.0.0-M0' isDefault='true' localPath='".concat(defaultServerPath).concat("' /></peergreen-server>>"); store.setDefault(SERVER_XML_CONTENT, xmlContent); }*/ }
From source file:com.phonegap.runtime.SimulatorLaunchConfigurationDelegate.java
License:Open Source License
/** * @see org.eclipse.debug.core.model.ILaunchConfigurationDelegate#launch(org.eclipse.debug.core.ILaunchConfiguration, * java.lang.String, org.eclipse.debug.core.ILaunch, org.eclipse.core.runtime.IProgressMonitor) *//*from w w w. j a v a2s .c om*/ public void launch(ILaunchConfiguration configuration, String mode, ILaunch launch, IProgressMonitor monitor) throws CoreException { String projectName = configuration.getAttribute("PROJECT", ""); //$NON-NLS-1$ String applicationFile = configuration.getAttribute("APPLICATION", ""); //$NON-NLS-1$ String commandArgs = configuration.getAttribute("COMMANDLINE", ""); //$NON-NLS-1$ String sdk = configuration.getAttribute("PHONEGAPSDK", ""); //$NON-NLS-1$ if (projectName.length() == 0 || applicationFile.length() == 0) { monitor.setCanceled(true); return; } IProject _project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName); IFile file = _project.getFile(applicationFile); String sdkLocation = null; if (!sdk.equals("")) //$NON-NLS-1$ { IPreferenceStore store = PhoneGapPlugin.getDefault().getPreferenceStore(); String names = store.getString(PhoneGapPlugin.RUNTIME_NAMES_PREFERENCE); String locations = store.getString(PhoneGapPlugin.RUNTIME_LOCATIONS_PREFERENCE); String[] sdkPrefNames = names.split(PhoneGapPlugin.PREFERENCE_DELIMITER); String[] sdkPrefLocations = locations.split(PhoneGapPlugin.PREFERENCE_DELIMITER); for (int i = 0; i < sdkPrefNames.length; i++) { if (sdk.equals(sdkPrefNames[i])) { if (i < sdkPrefLocations.length) { sdkLocation = sdkPrefLocations[i]; break; } } } } if (sdkLocation == null) { sdkLocation = PhoneGapPlugin.getDefaultPhoneGapSDKLocation(); } // if (sdkLocation == null) // { // // Fail back to default // sdkLocation = store.getString(PhoneGapPlugin.RUNTIME_LOCATION_DEFAULT_PREFERENCE); // } // if (sdkLocation == null || sdkLocation.length() == 0) // { // sdkLocation = PhoneGapPlugin.getDefaultSDKLocation(); // } /* If you can't find an sdkLocaiton then don't run */ if (sdkLocation == null || sdkLocation.length() == 0) { Job job = new UIJob("No PhoneGap SDK Found Message") { @Override public IStatus runInUIThread(IProgressMonitor monitor) { //CoreUIUtils.logAndDialogError(CoreUIUtils.getActiveShell(), PhoneGapPlugin.getDefault(), "No PhoneGap SDK Found", "To launch your PhoneGap application, you must set your default PhoneGap SDK."); return Status.OK_STATUS; } }; job.setPriority(Job.INTERACTIVE); job.schedule(); return; } IPath sdkPath = new Path(sdkLocation); String applicationContent = file.getLocation().makeAbsolute().toOSString(); Map<String, String> attrs = new HashMap<String, String>(); Process process = null; String executable = null; if (org.eclipse.debug.core.ILaunchManager.DEBUG_MODE.equals(mode)) { SimulatorLauncher launcher = new SimulatorLauncher(sdkPath, applicationContent, commandArgs); attrs.put(IProcess.ATTR_CMDLINE, launcher.getCommand()); executable = launcher.getExecutable(); process = launcher.execute(); } else if (org.eclipse.debug.core.ILaunchManager.RUN_MODE.equals(mode)) { SimulatorLauncher launcher = new SimulatorLauncher(sdkPath, applicationContent, commandArgs); attrs.put(IProcess.ATTR_CMDLINE, launcher.getCommand()); executable = launcher.getExecutable(); process = launcher.execute(); } if (process == null) { UIJob errorJob = new UIJob("Error launching simulator.") { public IStatus runInUIThread(IProgressMonitor monitor) { MessageDialog.openError(Display.getDefault().getActiveShell(), "Error launching simulator.", "Check PhoneGap SDK location"); PreferenceDialog dialog = PreferencesUtil.createPreferenceDialogOn( this.getDisplay().getActiveShell(), "com.phonegap.preferences.SDKPreferencePage", //$NON-NLS-1$ new String[] { "com.phonegap.preferences.SDKPreferencePage" }, null); //$NON-NLS-1$ dialog.open(); return Status.OK_STATUS; } }; errorJob.schedule(); monitor.setCanceled(true); return; } if (org.eclipse.debug.core.ILaunchManager.DEBUG_MODE.equals(mode)) { //c:\bin\phone-gap-sdk\adl c:\bin\phone-gap-sdk\application.xml c:\bin\phone-gap-sdk\bin-debug DebugPlugin.newProcess(launch, process, executable, attrs); } /* if (org.eclipse.debug.core.ILaunchManager.RUN_MODE == mode) { attrs.put(IProcess.ATTR_PROCESS_TYPE, "com.aptana.ide.apollo.AdlProcess"); //$NON-NLS-1$ DebugPlugin.newProcess(launch, process, executable, attrs); } else if (org.eclipse.debug.core.ILaunchManager.DEBUG_MODE == mode) { JSDebugTarget debugTarget = null; DebugConnection controller = FDBDebugConnection.createConnection(debugHost); IProcess debugProcess = new JSDebugProcess(launch, process, false, executable, attrs); try { debugTarget = new JSDebugTarget(launch, "AIR Debugger", debugProcess, null, null, controller, true); } catch(CoreException e) { if ( debugTarget != null ) { debugTarget.terminate(); } else { try { controller.dispose(); } catch (IOException ignore) { } } if (debugProcess != null) { debugProcess.terminate(); } throw e; } } */ }
From source file:com.puppetlabs.geppetto.pp.dsl.ui.linking.PPUISearchPathProvider.java
License:Open Source License
@Override public PPSearchPath get(Resource r) { String handle = allContainers.getContainerHandle(r.getURI()); // get project IProject project = workspace.getRoot().getProject(handle); // get project specific preference and use them if they are enabled IPreferenceStore store = preferenceStoreAccess.getContextPreferenceStore(project); String pathString = store.getString(PPPreferenceConstants.PUPPET_PROJECT_PATH); String environment = store.getString(PPPreferenceConstants.PUPPET_ENVIRONMENT); // if no path at all specified, the PPSearchPath enforces a default of "*" PPSearchPath searchPath = PPSearchPath.fromString(pathString, null); // if environment is still empty if (environment != null) environment = environment.trim(); if (environment == null || environment.length() == 0) environment = "production"; // System.err.printf("Project %s uses env=%s and path=%s\n", project.getName(), environment, pathString); // return a resolved search path return searchPath.evaluate(environment); }
From source file:com.python.pydev.analysis.system_info_builder.SynchSystemModulesManagerTest.java
License:Open Source License
public void testSaveUserChoicesAfterSelection() throws Exception { setupEnv(false);/* w ww. j av a2s.c om*/ IPreferenceStore preferences = createPreferenceStore(); SynchSystemModulesManager synchManager = new SynchSystemModulesManager(); final DataAndImageTreeNode root = new DataAndImageTreeNode(null, null, null); Map<IInterpreterManager, Map<String, IInterpreterInfo>> managerToNameToInfo = PydevPlugin .getInterpreterManagerToInterpreterNameToInfo(); synchManager.updateStructures(null, root, new ManagerInfoToUpdate(managerToNameToInfo), new SynchSystemModulesManager.CreateInterpreterInfoCallback() { @Override public IInterpreterInfo createInterpreterInfo(IInterpreterManager manager, String executable, IProgressMonitor monitor) { Collection<String> pythonpath = new ArrayList<String>(); pythonpath.add(libDir.toString()); pythonpath.add(libDir2.toString()); pythonpath.add(libDir3.toString()); pythonpath.add(libZipFile.toString()); final InterpreterInfo info = new InterpreterInfo("2.6", TestDependent.PYTHON_EXE, pythonpath); return info; } }); assertTrue(root.hasChildren()); List<TreeNode> selectedElements = new ArrayList<TreeNode>(); TreeNode interpreterNode = (TreeNode) root.getChildren().get(0); selectedElements.add(interpreterNode); List<TreeNode> children = interpreterNode.getChildren(); for (TreeNode<PythonpathChange> treeNode : children) { if (treeNode.getData().path.equals(libDir2.toString())) { selectedElements.add(treeNode); } } synchManager.saveUnselected(root, selectedElements, preferences); //Check that we ignored libDir3 and libZipFile String key = SynchSystemModulesManager .createKeyForInfo((IInterpreterInfo) ((TreeNode) root.getChildren().get(0)).getData()); String entry = preferences.getString(key); List<String> entries = StringUtils.split(entry, "|||"); assertEquals(2, entries.size()); HashSet<String> entriesSet = new HashSet<String>(entries); assertEquals(new HashSet(entries), new HashSet(Arrays.asList(libDir3.toString(), libZipFile.toString()))); //Check that only libDir2 is initially selected. List<TreeNode> initialSelection = synchManager .createInitialSelectionForDialogConsideringPreviouslyIgnored(root, preferences); assertEquals(2, initialSelection.size()); TreeNode treeNode = initialSelection.get(0); TreeNode treeNode1 = initialSelection.get(1); TreeNode interpreterInfoNode; TreeNode pythonpathNode; if (treeNode.getData() instanceof IInterpreterInfo) { interpreterNode = treeNode; pythonpathNode = treeNode1; } else { interpreterNode = treeNode1; pythonpathNode = treeNode; } assertEquals(((PythonpathChange) pythonpathNode.getData()).path, libDir2.toString()); }
From source file:com.python.pydev.analysis.system_info_builder.SyncSystemModulesManagerTest.java
License:Open Source License
public void testSaveUserChoicesAfterSelection() throws Exception { setupEnv(false);//from w w w. ja v a 2 s .c om IPreferenceStore preferences = createPreferenceStore(); SynchSystemModulesManager synchManager = new SynchSystemModulesManager(); final DataAndImageTreeNode root = new DataAndImageTreeNode(null, null, null); Map<IInterpreterManager, Map<String, IInterpreterInfo>> managerToNameToInfo = PydevPlugin .getInterpreterManagerToInterpreterNameToInfo(); synchManager.updateStructures(null, root, new ManagerInfoToUpdate(managerToNameToInfo), new SynchSystemModulesManager.CreateInterpreterInfoCallback() { @Override public IInterpreterInfo createInterpreterInfo(IInterpreterManager manager, String executable, IProgressMonitor monitor) { Collection<String> pythonpath = new ArrayList<>(); pythonpath.add(libDir.toString()); pythonpath.add(libDir2.toString()); pythonpath.add(libDir3.toString()); pythonpath.add(libZipFile.toString()); final InterpreterInfo info = new InterpreterInfo("2.6", TestDependent.PYTHON_EXE, pythonpath); return info; } }); assertTrue(root.hasChildren()); List<TreeNode> selectedElements = new ArrayList<>(); TreeNode interpreterNode = (TreeNode) root.getChildren().get(0); selectedElements.add(interpreterNode); List<TreeNode> children = interpreterNode.getChildren(); for (TreeNode<PythonpathChange> treeNode : children) { if (treeNode.getData().path.equals(libDir2.toString())) { selectedElements.add(treeNode); } } synchManager.saveUnselected(root, selectedElements, preferences); //Check that we ignored libDir3 and libZipFile String key = SynchSystemModulesManager .createKeyForInfo((IInterpreterInfo) ((TreeNode) root.getChildren().get(0)).getData()); String entry = preferences.getString(key); List<String> entries = StringUtils.split(entry, "|||"); assertEquals(2, entries.size()); HashSet<String> entriesSet = new HashSet<>(entries); assertEquals(new HashSet(entries), new HashSet(Arrays.asList(libDir3.toString(), libZipFile.toString()))); //Check that only libDir2 is initially selected. List<TreeNode> initialSelection = synchManager .createInitialSelectionForDialogConsideringPreviouslyIgnored(root, preferences); assertEquals(2, initialSelection.size()); TreeNode treeNode = initialSelection.get(0); TreeNode treeNode1 = initialSelection.get(1); TreeNode interpreterInfoNode; TreeNode pythonpathNode; if (treeNode.getData() instanceof IInterpreterInfo) { interpreterNode = treeNode; pythonpathNode = treeNode1; } else { interpreterNode = treeNode1; pythonpathNode = treeNode; } assertEquals(((PythonpathChange) pythonpathNode.getData()).path, libDir2.toString()); }