List of usage examples for org.eclipse.jface.preference IPreferenceStore getString
String getString(String name);
From source file:com.iw.plugins.spindle.wizards.NewTapComponentWizardPage.java
License:Mozilla Public License
public void createHTMLResource(IProgressMonitor monitor) throws InterruptedException, CoreException { IPackageFragmentRoot root = fContainerDialogField.getPackageFragmentRoot(); IPackageFragment pack = fPackageDialogField.getPackageFragment(); String componentName = fComponentNameDialog.getTextValue(); IContainer container = (IContainer) pack.getUnderlyingResource(); IFile file1 = container.getFile(new Path(componentName + ".html")); IFile file2 = container.getFile(new Path(componentName + ".htm")); if (file1.exists() || file2.exists()) { return;//from w w w . ja v a2 s . c o m } monitor.beginTask("", 10); if (pack == null) { pack = root.getPackageFragment(""); } if (!pack.exists()) { String packName = pack.getElementName(); pack = root.createPackageFragment(packName, true, null); pack.save(new SubProgressMonitor(monitor, 1), true); } monitor.worked(1); IPreferenceStore pstore = TapestryPlugin.getDefault().getPreferenceStore(); String source = pstore.getString(P_HTML_TO_GENERATE); String comment = MessageUtil.getString("TAPESTRY.xmlComment"); if (source == null) { source = comment + MessageUtil.getString("TAPESTRY.genHTMLSource"); } if (!source.trim().startsWith(comment)) { source = comment + source; } InputStream contents = new ByteArrayInputStream(source.getBytes()); file1.create(contents, false, new SubProgressMonitor(monitor, 1)); monitor.worked(1); monitor.done(); }
From source file:com.ixenit.membersort.handlers.MemberComparator.java
License:Apache License
@Override public int compare(BodyDeclaration o1, BodyDeclaration o2) { IPreferenceStore preferenceStore = Activator.getDefault().getPreferenceStore(); String savedOrder = preferenceStore.getString(PreferenceConstants.P_ORDER); String[] order = OrderConverter.convert(savedOrder); boolean orderByName = preferenceStore.getBoolean(PreferenceConstants.P_ORDER_BY_NAME); Member member1 = _createMember(o1); Member member2 = _createMember(o2); int modifierOrder1 = _computeOrderByModifiers(member1.modifiers, order); int modifierOrder2 = _computeOrderByModifiers(member2.modifiers, order); // If they have the same modifiers then compare them by name if (modifierOrder1 == modifierOrder2) { return orderByName ? member1.name.compareTo(member2.name) : 0; }/*from www. ja v a2s . c o m*/ // Compare them by modifiers return (modifierOrder1 < modifierOrder2) ? -1 : 1; }
From source file:com.joeygibson.eclipse.junitlaunchfixer.Activator.java
License:Open Source License
public void start(BundleContext context) throws Exception { super.start(context); plugin = this; launchManager.addLaunchConfigurationListener(launchConfigurationListener); final IPreferenceStore store = Activator.getDefault().getPreferenceStore(); if (store.getBoolean(PreferenceConstants.P_UPDATE_EXISTING_LAUNCHERS)) { Runnable r = new Runnable() { @Override/*from w ww. jav a2 s .c om*/ public void run() { Shell shell = PlatformUI.getWorkbench().getDisplay().getActiveShell(); ILaunchConfiguration[] launchers = null; try { launchers = launchManager.getLaunchConfigurations(); if (launchers == null || launchers.length == 0) { return; } } catch (CoreException e) { e.printStackTrace(); } List<ILaunchConfiguration> filteredLaunchers = LaunchProcessor .filterNonJUnitLaunchers(launchers); if (filteredLaunchers.size() == 0) { return; } LauncherSelectionDialog dlg = new LauncherSelectionDialog(shell, filteredLaunchers, new ArrayContentProvider(), new LaunchLabelProvider(), "Select launchers to update"); dlg.setHeapSize(store.getString(PreferenceConstants.P_MAX_HEAP)); dlg.setMaxPermSize(store.getString(PreferenceConstants.P_MAX_PERM_SIZE)); dlg.open(); String heapSize = dlg.getHeapSize(); String maxPermSize = dlg.getMaxPermSize(); if (heapSize != null && heapSize.length() > 0 && maxPermSize != null && maxPermSize.length() > 0) { store.setValue(PreferenceConstants.P_MAX_HEAP, heapSize); store.setValue(PreferenceConstants.P_MAX_PERM_SIZE, maxPermSize); Object[] res = dlg.getResult(); if (res != null) { for (Object o : res) { ILaunchConfiguration config = (ILaunchConfiguration) o; LaunchProcessor.processVmArgs(config); } } } } }; PlatformUI.getWorkbench().getDisplay().syncExec(r); store.setValue(PreferenceConstants.P_UPDATE_EXISTING_LAUNCHERS, false); } }
From source file:com.joeygibson.eclipse.junitlaunchfixer.LaunchProcessor.java
License:Open Source License
public static void processVmArgs(ILaunchConfiguration config) { IPreferenceStore store = Activator.getDefault().getPreferenceStore(); String maxHeap = store.getString(PreferenceConstants.P_MAX_HEAP); String maxPermSize = store.getString(PreferenceConstants.P_MAX_PERM_SIZE); String newMaxHeap = "-Xmx" + maxHeap; String newMaxPermSize = "-XX:MaxPermSize=" + maxPermSize; try {/*from www . j a v a 2s . c o m*/ String testKind = config.getAttribute(TEST_KIND_KEY, ""); if (testKind == null || testKind.length() == 0 || !testKind.contains("junit")) { return; } String vmArgs = config.getAttribute(VMARGS_KEY, ""); Matcher matcher = maxHeapPattern.matcher(vmArgs); if (matcher.find()) { vmArgs = matcher.replaceFirst(newMaxHeap); } else { vmArgs += " " + newMaxHeap; } matcher = maxPermSizePattern.matcher(vmArgs); if (matcher.find()) { vmArgs = matcher.replaceFirst(newMaxPermSize); } else { vmArgs += " " + newMaxPermSize; } ILaunchConfigurationWorkingCopy wc = config.getWorkingCopy(); wc.setAttribute(VMARGS_KEY, vmArgs); // Ensure it still shows up in the dropdowns List<String> favorites = new ArrayList<String>(); favorites.add(RUN_GROUP_KEY); favorites.add(DEBUG_GROUP_KEY); wc.setAttribute(FAVORITE_GROUPS_KEY, favorites); wc.doSave(); } catch (CoreException e) { e.printStackTrace(); } }
From source file:com.legstar.eclipse.plugin.cixscom.wizards.AbstractCixsGeneratorWizardPage.java
License:Open Source License
/** * Relative target locations have default values that are built relative * to the project containing the mapping file and preferences taken from a * preference store./*from w w w .java 2 s. c om*/ * This will make sure the default location exists. * * @param store the preference store to use * @param storeKey the preference store key for this target * @return the corresponding default target location */ protected String getDefaultRelativeTargetDir(final IPreferenceStore store, final String storeKey) { IPath projectPath = getMappingFile().getProject().getLocation(); String folder = store.getString(storeKey); String defaultValue = projectPath.append(new Path(folder)).toOSString(); try { CodeGenUtil.checkDirectory(defaultValue, true); getMappingFile().getProject().refreshLocal(IResource.DEPTH_INFINITE, null); } catch (IllegalArgumentException e) { updateStatus(NLS.bind(Messages.invalid_default_location_msg, defaultValue, storeKey)); } catch (CoreException e) { updateStatus(NLS.bind(Messages.location_refresh_failure_msg, defaultValue, storeKey)); } return defaultValue; }
From source file:com.legstar.eclipse.plugin.cixscom.wizards.AbstractCixsGeneratorWizardPage.java
License:Open Source License
/** * Get a location for a target directory. This is the absolute location of * the directory parameter received or a default location if that parameter * is null or invalid.//from w ww .j a v a 2s .c om * * @param dir the candidate target directory * @param store a preference store from which to fetch the default * @param storeKey the preference key to use for default values * @param relative true means the location is relative to the Eclipse * project while false means the location is absolute * @return a unique non ambiguous file location or null if File is null */ protected String getInitTargetDir(final File dir, final IPreferenceStore store, final String storeKey, final boolean relative) { String dirPath = getDisplayPath(dir); if (dirPath == null) { if (relative) { dirPath = getDefaultRelativeTargetDir(store, storeKey); } else { dirPath = store.getString(storeKey); // Don't attempt to create absolute locations } } return dirPath; }
From source file:com.legstar.eclipse.plugin.common.wizards.AbstractWizardPage.java
License:Open Source License
/** * This type of widget is a simple textbox preceded by a label. * The content can be initialized from a preference store. * //from ww w .ja v a 2s. co m * @param container the parent composite * @param store a preference store * @param preferenceName the preference store item * @param labelText the label's text appearing before the textbox * @return the composite */ public static Text createTextField(final Composite container, final IPreferenceStore store, final String preferenceName, final String labelText) { createLabel(container, labelText); Text text = createText(container); if (preferenceName != null) { text.setText(store.getString(preferenceName)); } return text; }
From source file:com.legstar.eclipse.plugin.common.wizards.AbstractWizardRunnable.java
License:Open Source License
/** * @return the preferred ant script sub folder relative to projects. */// w w w.ja v a2 s . c o m public String getPreferenceAntFolder() { IPreferenceStore store = Activator.getDefault().getPreferenceStore(); String antScriptsFolder = store.getString(PreferenceConstants.ANT_SCRIPTS_FOLDER); if (antScriptsFolder == null) { return ""; } else { return antScriptsFolder; } }
From source file:com.legstar.eclipse.plugin.schemagen.wizards.CobolToXsdWizardRunnable.java
License:Open Source License
/** * Create a model ready to be passed to velocity for ant script generation. * /*from w ww . ja va2 s.com*/ * @param mainPage wizard page holding target XSD location and parameters * @param cobolToXsdPage the wizard page holding selected COBOL fragment * @return a valid model * @throws InvocationTargetException if model cannot be built */ protected Cob2XsdModel getModel(final MainWizardPage mainPage, final CobolToXsdWizardPage cobolToXsdPage) throws InvocationTargetException { Cob2XsdModel model = new Cob2XsdModel(); model.setProductLocation( AbstractWizard.getPluginInstallLocation(com.legstar.eclipse.plugin.common.Activator.PLUGIN_ID)); /* Store the content of the text box in a temporary file */ File cobolFile; try { cobolFile = File.createTempFile(TEMP_PATTERN, TEMP_SUFFIX); BufferedWriter writer = new BufferedWriter( new OutputStreamWriter(new FileOutputStream(cobolFile), cobolToXsdPage.getCobolFileEncoding())); writer.write(cobolToXsdPage.getCobolFragment()); writer.close(); } catch (IOException e) { throw new InvocationTargetException(e); } /* Temporary file becomes input to generation process */ model.setCobolSourceFilePath(cobolFile.getPath()); model.setTargetDir(new File(getTargetXsdLocation())); model.setTargetXsdFileName(mainPage.getTargetXSDFileName()); IPreferenceStore store = Activator.getDefault().getPreferenceStore(); /* * ------------------------------------------------------------------- * COBOL source format related options */ model.setCodeFormat(CodeFormat.valueOf(store.getString(PreferenceConstants.DEFAULT_CODE_FORMAT))); model.setStartColumn(store.getInt(PreferenceConstants.DEFAULT_START_COLUMN)); model.setEndColumn(store.getInt(PreferenceConstants.DEFAULT_END_COLUMN)); model.setXsdEncoding(store.getString(PreferenceConstants.DEFAULT_XSD_ENCODING)); model.setTargetNamespace(mainPage.getTargetNamespace()); model.setMapConditionsToFacets(store.getBoolean(PreferenceConstants.DEFAULT_XSD_MAP_CONDITIONS_TO_FACETS)); model.setCustomXsltFileName(store.getString(PreferenceConstants.DEFAULT_XSD_CUSTOM_XSLT_FILE_NAME)); model.setNameConflictPrependParentName( store.getBoolean(PreferenceConstants.DEFAULT_XSD_NAME_CONFLICT_PREPEND_PARENT_NAME)); model.setElementNamesStartWithUppercase( store.getBoolean(PreferenceConstants.DEFAULT_XSD_ELEMENT_NAMES_START_WITH_UPPERCASE)); model.setAddLegStarAnnotations(store.getBoolean(PreferenceConstants.DEFAULT_ADD_LEGSTAR_ANNOTATIONS)); model.setCurrencySign(store.getString(PreferenceConstants.DEFAULT_CURRENCY_SIGN)); model.setCurrencySymbol(store.getString(PreferenceConstants.DEFAULT_CURRENCY_SYMBOL)); model.setDecimalPointIsComma(store.getBoolean(PreferenceConstants.DEFAULT_DECIMAL_POINT_IS_COMMA)); model.setNSymbolDbcs(store.getBoolean(PreferenceConstants.DEFAULT_NSYMBOL_DBCS)); model.setQuoteIsQuote(store.getBoolean(PreferenceConstants.DEFAULT_QUOTE_IS_QUOTE)); return model; }
From source file:com.legstar.eclipse.plugin.schemagen.wizards.MainWizardPage.java
License:Open Source License
/** * The default namespace prefix comes from the LegStar general preferences. * /*from ww w . j a va 2 s.c o m*/ * @return a default prefix terminated with slash */ protected String getDefaultNamespacePrefix() { IPreferenceStore store = getDefaultPreferences(); String str = store.getString(PreferenceConstants.XSD_NAMESPACE_PREFIX); if (str != null && str.length() != 0) { str = setSeparatorChar(str, '/'); return str; } return ""; }