List of usage examples for org.eclipse.jface.preference IPreferenceStore getBoolean
boolean getBoolean(String name);
From source file:de.akra.idocit.ui.components.DocumentationEditor.java
License:Apache License
/** * {@inheritDoc}/*w w w. j av a 2 s. c o m*/ */ @Override public void init(IEditorSite site, IEditorInput input) throws PartInitException { setSite(site); setInput(input); if (IDocItActivator.isInitializedAtStartup()) { setupConfigChangeListener(); List<Addressee> addressees = ServiceManager.getInstance().getPersistenceService() .loadConfiguredAddressees(); List<ThematicRole> thematicRoles = ServiceManager.getInstance().getPersistenceService() .loadThematicRoles(); EditArtifactDocumentationCompositeSelection selection = new EditArtifactDocumentationCompositeSelection(); selection.setSelectedSignatureElement(SignatureElement.EMPTY_SIGNATURE_ELEMENT); selection.setInterfaceArtifact(InterfaceArtifact.NOT_SUPPORTED_ARTIFACT); selection.setAddresseeList(addressees); selection.setThematicRoleList(thematicRoles); if (input instanceof FileEditorInput) { // Get the interface as file ... IFile interfaceIFile = ((FileEditorInput) input).getFile(); File interfaceFile = interfaceIFile.getLocation().toFile(); // Store the original default editor for the opened file. IPreferenceStore store = PlatformUI.getPreferenceStore(); boolean dontUseIdocItAsDefaultEditor = store .getBoolean(PreferenceStoreConstants.DEFAULT_EDITOR_PREFERENCE); if (dontUseIdocItAsDefaultEditor) { final IEditorDescriptor originalEditor = IDE.getDefaultEditor(interfaceIFile); // Changes due to Issue #123 if (originalEditor != null) { // if there is a default editor, then revert it store.setValue(PreferenceStoreConstants.ORIGINAL_EDITOR_ID, originalEditor.getId()); } // End changes due to Issue #123 } setSelection(null); if (interfaceFile.exists()) { // ... and load it. try { logger.log(Level.INFO, "Start parsing"); InterfaceArtifact interfaceArtifact = ServiceManager.getInstance().getPersistenceService() .loadInterface(interfaceIFile); selection.setInterfaceArtifact(interfaceArtifact); selection.setArtifactFile(interfaceIFile); logger.log(Level.INFO, "End parsing"); logger.log(Level.INFO, "InterfaceArtifact.size=" + interfaceArtifact.size()); logger.log(Level.INFO, "Start copy"); initialInterfaceArtifact = (InterfaceArtifact) interfaceArtifact .copy(SignatureElement.EMPTY_SIGNATURE_ELEMENT); logger.log(Level.INFO, "End copy"); setPartName(interfaceIFile.getName() + " - " + DialogConstants.DIALOG_TITLE); if (!interfaceFile.canWrite()) { MessageDialog.openInformation(site.getShell(), DialogConstants.DIALOG_TITLE, "The file is not writable, changes can not be saved."); } } catch (Exception ex) { String msg = "Could not parse '" + interfaceIFile.getFullPath() + "'."; logger.log(Level.SEVERE, msg, ex); MessageBoxUtils.openErrorBox(site.getShell(), msg + "\n\nError:\n" + ex.toString(), ex); } } else { String msg = "File is no longer available: " + interfaceFile.getAbsolutePath(); logger.log(Level.WARNING, msg); MessageBoxUtils.openErrorBox(site.getShell(), msg); } } else { logger.log(Level.SEVERE, "Not an instance of FileEditorInput."); } logger.log(Level.INFO, "Start setSelection"); setSelection(selection); logger.log(Level.INFO, "End setSelection"); } }
From source file:de.akra.idocit.ui.components.DocumentationEditor.java
License:Apache License
/** * {@inheritDoc}/*from w w w . j a v a 2 s . c o m*/ */ @Override public void dispose() { super.dispose(); if (initializationFont != null) { initializationFont.dispose(); } IPreferenceStore store = PlatformUI.getPreferenceStore(); boolean dontUseIdocItAsDefaultEditor = store.getBoolean(PreferenceStoreConstants.DEFAULT_EDITOR_PREFERENCE); if (dontUseIdocItAsDefaultEditor) { final String originalEditorId = store.getString(PreferenceStoreConstants.ORIGINAL_EDITOR_ID); final EditArtifactDocumentationCompositeSelection selection = getSelection(); if (selection != null && selection.getArtifactFile() != null && originalEditorId != null) { IDE.setDefaultEditor(selection.getArtifactFile(), originalEditorId); } } IDocItActivator.removeConfigurationListener(listener); ServiceManager.getInstance().getPersistenceService() .removeAddresseChangeListener(adresseeConfigChangeListener); ServiceManager.getInstance().getPersistenceService() .removeThematicRoleChangeListener(thematicRoleConfigChangeListener); ServiceManager.getInstance().getPersistenceService() .removeThematicGridChangeListener(thematicGridConfigChangeListener); }
From source file:de.anbos.eclipse.easyshell.plugin.legacy.PrefsV1_5.java
License:Open Source License
/** * Loads the preference store and sets the data to controls. * * @return store loaded./*from w w w . ja va 2 s . c om*/ */ public static boolean loadStore(IPreferenceStore store, OS os, CommandDataList cmdDataList, MenuDataList menuDataList) { /* DebugStr=debugYes DebugStr1=debugNo DebugStr2=debugNo IdStr1=cmdWinPower IdStr2=cmdWinCyg QuotesStr=quotesAuto QuotesStr1=quotesNo QuotesStr2=quotesNo TokenizerStr=EasyShellTokenizerNo TokenizerStr1=EasyShellTokenizerYes TokenizerStr2=EasyShellTokenizerYes eclipse.preferences.version=1 listPreference1=1 listPreference2=2 targetCopyPathPreference={2}{5} copy targetEnabled=true targetEnabled1=true targetEnabled2=true targetExplorePreference=explorer.exe /select, {2} my targetExplorePreference2=explorer.exe /select, ${easyshell\:resource_loc} targetPreference=cmd.exe /C start "{4}" /D {1} cmd.exe /K test targetPreference1=cmd.exe /C start "${easyshell\:project_name}" /D ${easyshell\:container_loc} powershell.exe targetPreference2=cmd.exe /C start "${easyshell\:project_name}" /D ${easyshell\:container_loc} "C\:\\Cygwin\\bin\\bash.exe" targetRunPreference=cmd.exe /C start "{4}" /D {1} {3} hello targetRunPreference1=cmd.exe /C start "${easyshell\:project_name}" /D ${easyshell\:container_loc} powershell.exe -command ./''${easyshell\:resource_name}'' targetRunPreference2=cmd.exe /C start "${easyshell\:project_name}" /D ${easyshell\:container_loc} "C\:\\Cygwin\\bin\\bash.exe" -c ./''${easyshell\:resource_name}'' */ // get proper command (detect) Command cmdProper = getProperCommand(); // duplicate cache List<String> openCmdList = new ArrayList<String>(); List<String> runCmdList = new ArrayList<String>(); List<String> exploreCmdList = new ArrayList<String>(); List<String> copyPathList = new ArrayList<String>(); // iterate over the instances for (int instanceId = 0; instanceId < 3; instanceId++) { // set defaults first initializeDefaults(store, cmdProper, instanceId); // get the properties now if (store.getBoolean(PreferenceEntry.preferenceTargetEnabled.getString(instanceId))) { final String postfix = " (" + Version.v1_5.getName() + ")"; String IdStr = store.getString(PreferenceEntry.preferenceListString.getString(instanceId)); Command command = Command.valueOf(IdStr); int position = menuDataList.size(); // open String openCmd = store.getString(PreferenceEntry.preferenceTargetOpen.getString(instanceId)); if (!openCmdList.contains(openCmd)) { openCmdList.add(openCmd); CommandData cmdDataOpen = new CommandData(null, PresetType.presetUser, os, command.getConsole(), ResourceType.resourceTypeFileOrDirectory, false, null, Category.categoryOpen, CommandType.commandTypeExecute, PrefsV1_4.migrateCommandVariables(openCmd)); cmdDataList.add(cmdDataOpen); MenuData menuDataOpen = new MenuData(cmdDataOpen.getId(), true, MenuNameType.menuNameTypeOpenHere, null, cmdDataOpen.getId()); menuDataOpen.setPosition(position++); menuDataOpen.setNamePattern(menuDataOpen.getNamePattern() + postfix); menuDataOpen.setNameType(MenuNameType.menuNameTypeUser); menuDataList.add(menuDataOpen); } // run String runCmd = store.getString(PreferenceEntry.preferenceTargetRun.getString(instanceId)); if (!runCmdList.contains(runCmd)) { runCmdList.add(runCmd); CommandData cmdDataRun = new CommandData(null, PresetType.presetUser, os, command.getConsole(), ResourceType.resourceTypeFileOrDirectory, false, null, Category.categoryRun, CommandType.commandTypeExecute, PrefsV1_4.migrateCommandVariables(runCmd)); cmdDataList.add(cmdDataRun); MenuData menuDataRun = new MenuData(cmdDataRun.getId(), true, MenuNameType.menuNameTypeRunWith, null, cmdDataRun.getId()); menuDataRun.setPosition(position++); menuDataRun.setNamePattern(menuDataRun.getNamePattern() + postfix); menuDataRun.setNameType(MenuNameType.menuNameTypeUser); menuDataList.add(menuDataRun); } // explore String exploreCmd = store.getString(PreferenceEntry.preferenceTargetExplore.getString(instanceId)); if (!exploreCmdList.contains(exploreCmd)) { exploreCmdList.add(exploreCmd); CommandData cmdDataExplore = new CommandData(null, PresetType.presetUser, os, command.getExplorer(), ResourceType.resourceTypeFileOrDirectory, false, null, Category.categoryExplore, CommandType.commandTypeExecute, PrefsV1_4.migrateCommandVariables(exploreCmd)); cmdDataList.add(cmdDataExplore); MenuData menuDataExplore = new MenuData(cmdDataExplore.getId(), true, MenuNameType.menuNameTypeShowIn, null, cmdDataExplore.getId()); menuDataExplore.setPosition(position++); menuDataExplore.setNamePattern(menuDataExplore.getNamePattern() + postfix); menuDataExplore.setNameType(MenuNameType.menuNameTypeUser); menuDataList.add(menuDataExplore); } // copy to clipboard String copyPathCmd = store .getString(PreferenceEntry.preferenceTargetCopyPath.getString(instanceId)); if (!copyPathList.contains(copyPathCmd)) { copyPathList.add(copyPathCmd); CommandData cmdDataCopyPath = new CommandData(null, PresetType.presetUser, os, "Full Path", ResourceType.resourceTypeFileOrDirectory, false, null, Category.categoryClipboard, CommandType.commandTypeClipboard, PrefsV1_4.migrateCommandVariables(copyPathCmd)); cmdDataList.add(cmdDataCopyPath); MenuData menuDataCopyPath = new MenuData(cmdDataCopyPath.getId(), true, MenuNameType.menuNameTypeCopyToClipboard, null, cmdDataCopyPath.getId()); menuDataCopyPath.setPosition(position++); menuDataCopyPath.setNamePattern(menuDataCopyPath.getNamePattern() + postfix); menuDataCopyPath.setNameType(MenuNameType.menuNameTypeUser); menuDataList.add(menuDataCopyPath); } /* String QuotesStr = store.getString(PreferenceEntry.preferenceQuotes.getString(instanceId)); Quotes quotes = Quotes.valueOf(QuotesStr); String DebugStr = store.getString(PreferenceEntry.preferenceDebug.getString(instanceId)); Debug debug = Debug.valueOf(DebugStr); String TokenizerStr = store.getString(PreferenceEntry.preferenceTokenizer.getString(instanceId)); Tokenizer tokenizer = Tokenizer.valueOf(TokenizerStr); */ } } return true; }
From source file:de.anbos.eclipse.easyshell.plugin.preferences.Initializer.java
License:Open Source License
private void migrate(IPreferenceStore store) { if (!store.getBoolean(Constants.PREF_MIGRATED)) { int migrateState = -1; // -1 = old store not found, 0 (Yes) = migrated, 1 (No) = no migration wanted by user, 2 (Cancel) = try to migrate again for (int i = Version.values().length - 2; i > 0; i--) { Version version = Version.values()[i]; String versionName = version.getName(); if (version.toString().startsWith("v1_")) { migrateState = migrate_from_v1(store, version, migrateState); } else { migrateState = migrate_from_v2(store, version, migrateState); }//from www.j av a 2s. com // if no old store for this version found continue, else break if (migrateState != -1) { switch (migrateState) { case 0: Utils.showToolTipWarning(null, Activator.getResourceString("easyshell.plugin.name"), MessageFormat.format( Activator.getResourceString("easyshell.message.warning.migrated.yes"), versionName)); break; case 1: Utils.showToolTipWarning(null, Activator.getResourceString("easyshell.plugin.name"), MessageFormat.format( Activator.getResourceString("easyshell.message.warning.migrated.no"), versionName)); break; case 2: Utils.showToolTipWarning(null, Activator.getResourceString("easyshell.plugin.name"), MessageFormat.format( Activator.getResourceString("easyshell.message.warning.migrated.cancel"), versionName)); break; } break; } } // we have first startup without old store if (migrateState == -1) { Utils.showToolTipWarning(null, Activator.getResourceString("easyshell.plugin.name"), Activator.getResourceString("easyshell.message.warning.migrated.default")); } // do not set migration flag if user canceled and want to do it later if (migrateState != 2) { store.setValue(Constants.PREF_MIGRATED, true); } } }
From source file:de.bmw.yamaica.ide.ui.internal.dialogs.ProjectWizard.java
License:Mozilla Public License
public static void addYamaicaSpecificProjectSettings(IProject project, IProgressMonitor monitor) { try {/*w ww . java2 s. c o m*/ IProjectDescription projectDescription = project.getDescription(); String xtextNature = "org.eclipse.xtext.ui.shared.xtextNature"; String[] natureIds = projectDescription.getNatureIds(); ArrayList<String> newNatureIds = new ArrayList<String>(natureIds.length + 2); for (String natureId : natureIds) { newNatureIds.add(natureId); } if (!projectDescription.hasNature(YamaicaNature.NATURE_ID)) { newNatureIds.add(YamaicaNature.NATURE_ID); } if (!projectDescription.hasNature(xtextNature)) { newNatureIds.add(xtextNature); ICommand command = projectDescription.newCommand(); command.setBuilderName("org.eclipse.xtext.ui.shared.xtextBuilder"); projectDescription.setBuildSpec(new ICommand[] { command }); } projectDescription.setNatureIds(newNatureIds.toArray(new String[newNatureIds.size()])); project.setDescription(projectDescription, monitor); IPreferenceStore baseStore = de.bmw.yamaica.common.ui.Preferences.getPreferenceStore(); IPreferenceStore store = Activator.getDefault().getPreferenceStore(); YamaicaXmlModel model = YamaicaXmlModel.acquireInstance(project, project); IResourcePropertyStore resourcePropertyStore = model.getResourcePropertyStore(project); String importFolderPathAsString = resourcePropertyStore .getProperty(IResourcePropertyStore.IMPORT_FOLDER); String targetFolderPathAsString = resourcePropertyStore .getProperty(IResourcePropertyStore.TARGET_FOLDER); if (null == importFolderPathAsString) { importFolderPathAsString = baseStore.getString(de.bmw.yamaica.common.ui.Preferences.IMPORT_FOLDER); resourcePropertyStore.setProperty(IResourcePropertyStore.IMPORT_FOLDER, importFolderPathAsString); } if (null == targetFolderPathAsString) { targetFolderPathAsString = baseStore.getString(de.bmw.yamaica.common.ui.Preferences.TARGET_FOLDER); resourcePropertyStore.setProperty(IResourcePropertyStore.TARGET_FOLDER, targetFolderPathAsString); } IWorkspace workspace = ResourcesPlugin.getWorkspace(); IFolder importFolder = project.getFolder(new Path(importFolderPathAsString)); IFolder targetFolder = project.getFolder(new Path(targetFolderPathAsString)); if (!importFolder.exists()) { new ContainerCreator(workspace, importFolder.getFullPath()).createContainer(monitor); } if (!targetFolder.exists()) { new ContainerCreator(workspace, targetFolder.getFullPath()).createContainer(monitor); } model.save(); if (store.getBoolean(Preferences.CREATE_YAMAICA_EDITOR_LINK)) { IWorkspaceRoot root = workspace.getRoot(); IPath projectPath = project.getFullPath(); IPath yamaicaXmlFilePath = projectPath .append(store.getString(Preferences.YAMAICA_EDITOR_LINK_NAME)); IFile projectFile = root.getFile(yamaicaXmlFilePath); IFile projectSettingsFile = YamaicaXmlModel.getSettingsFile(project); URI projectSettingsFileUri = projectSettingsFile.getPathVariableManager() .convertToRelative(projectSettingsFile.getLocationURI(), false, "PROJECT_LOC"); if (!projectFile.exists()) { projectFile.createLink(projectSettingsFileUri, IResource.ALLOW_MISSING_LOCAL, monitor); } } YamaicaXmlModel.releaseInstance(project, project); } catch (CoreException e) { e.printStackTrace(); } }
From source file:de.byteholder.geoclipse.map.TileImageCache.java
License:Open Source License
/** * @return OS path for the tile cache or <code>null</code> when offline cache is not used or * otherwise/*from w w w . j a va 2 s . c o m*/ */ public static String getTileCacheOSPath() { final IPreferenceStore prefStore = Activator.getDefault().getPreferenceStore(); if (prefStore.getBoolean(IMappingPreferences.OFFLINE_CACHE_USE_OFFLINE)) { return _osTileCachePath; } return null; }
From source file:de.byteholder.geoclipse.map.TileImageCache.java
License:Open Source License
private static void setTileCachePath() { // get status if the tile is offline cache is activated final IPreferenceStore prefStore = Activator.getDefault().getPreferenceStore(); _useOffLineCache = prefStore.getBoolean(IMappingPreferences.OFFLINE_CACHE_USE_OFFLINE); if (_useOffLineCache) { /*//ww w. j a v a 2s .com * check and create tile cache path */ String workingDirectory; final boolean useDefaultLocation = prefStore .getBoolean(IMappingPreferences.OFFLINE_CACHE_USE_DEFAULT_LOCATION); if (useDefaultLocation) { workingDirectory = Platform.getInstanceLocation().getURL().getPath(); } else { workingDirectory = prefStore.getString(IMappingPreferences.OFFLINE_CACHE_PATH); } if (new File(workingDirectory).exists() == false) { System.err.println("working directory is not available: " + workingDirectory); //$NON-NLS-1$ _useOffLineCache = false; return; } final IPath tileCachePath = new Path(workingDirectory).append(TILE_OFFLINE_CACHE_OS_PATH); if (tileCachePath.toFile().exists() == false) { tileCachePath.toFile().mkdirs(); } _osTileCachePath = tileCachePath.toOSString(); } }
From source file:de.byteholder.geoclipse.preferences.PrefPageCache.java
License:Open Source License
@Override public boolean performOk() { stopOfflineInfoJob();// ww w . j a va2 s . c o m if (validateData() == false) { return false; } final IPreferenceStore prefStore = Activator.getDefault().getPreferenceStore(); boolean isModified = false; // check if the cache settings have changed if (prefStore.getBoolean(IMappingPreferences.OFFLINE_CACHE_USE_OFFLINE) != fUseOffLineCache .getBooleanValue()) { isModified = true; } if (prefStore.getBoolean(IMappingPreferences.OFFLINE_CACHE_USE_DEFAULT_LOCATION) != fUseDefaultLocation .getBooleanValue()) { isModified = true; } if (prefStore.getString(IMappingPreferences.OFFLINE_CACHE_PATH) .equals(fCachePathEditor.getStringValue()) == false) { isModified = true; } fUseOffLineCache.store(); fUseDefaultLocation.store(); fCachePathEditor.store(); if (isModified) { if (MessageDialog.openQuestion(Display.getDefault().getActiveShell(), Messages.pref_cache_message_box_title, Messages.pref_cache_message_box_text)) { Display.getCurrent().asyncExec(new Runnable() { public void run() { PlatformUI.getWorkbench().restart(); } }); } } return super.performOk(); }
From source file:de.cdhq.eclipse.wordwrap.plugin.ActivateOnFileOpenHandler.java
License:Open Source License
/** * Handles the opening of an editor and tries to enable wrapping if auto word wrap is enabled. * /*from www .j a va2 s . c om*/ * @param partRef * Reference to the workbench part that is opened (usually an IEditorPart) * @author Florian Weling <flo@cdhq.de> */ public static void handleFileOpenEvent(IWorkbenchPartReference partRef) { // get preference store of this plugin IPreferenceStore preferenceStore = Activator.getDefault().getPreferenceStore(); IWorkbenchPart part = partRef.getPart(true); if (part instanceof IEditorPart) { /* * Some of the possible editor types and their input: * * - Text editor: * part = org.eclipse.ui.editors.text.TextEditor * editorInput = org.eclipse.ui.part.FileEditorInput(/ProjectName/Example.txt) * editorInput = org.eclipse.ui.internal.editors.text.NonExistingFileEditorInput * * - Java editor (JDT): * part = org.eclipse.jdt.internal.ui.javaeditor.CompilationUnitEditor * editorInput = org.eclipse.ui.part.FileEditorInput(/ProjectName/src/Example.java) * * - XML editor (WTP): * part = org.eclipse.wst.xml.ui.internal.tabletree.XMLMultiPageEditorPart * editorInput = org.eclipse.ui.part.FileEditorInput(/ProjectName/Example.xml) * */ IEditorPart editorPart = (IEditorPart) part; // immediately activate word wrap when it is enabled for all files if (preferenceStore.getBoolean("de.cdhq.eclipse.wordwrap.autoenable.forall")) { WordWrapUtils.setWordWrap(editorPart, true); return; } // check if auto word wrap is enabled for file extensions if (!preferenceStore.getBoolean("de.cdhq.eclipse.wordwrap.autoenable.forextensions")) { return; } // get file name of editor's input IEditorInput input = editorPart.getEditorInput(); IFile file = ResourceUtil.getFile(input); // file can be null if an empty file is created if (file != null) { String fileExtension = file.getFileExtension(); // stop if file extension is empty (i.e. null) if (fileExtension == null) { return; } // get extensions from preference store String[] extensions = ExtensionListFieldEditor .parseString(preferenceStore.getString("de.cdhq.eclipse.wordwrap.autoenable.extensions")); // check if extension is covered by extensioned selected in preferences for (String ext : extensions) { if (ext.equals(fileExtension)) { // extension found: activate wrapping WordWrapUtils.setWordWrap(editorPart, true); // no further action necessary return; } } } } }