List of usage examples for org.eclipse.jface.preference IPreferenceStore getString
String getString(String name);
From source file:com.aptana.ide.editors.preferences.ProblemsPreferencePage.java
License:Open Source License
/** * Creates the page's UI content./* w w w.j av a2 s. co m*/ * * @param parent * @return Control */ protected Control createContents(Composite parent) { // define common container to Problems Filter and list of available validators Composite composite = new Composite(parent, SWT.NULL); GridLayout layout = new GridLayout(1, true); layout.marginHeight = 0; layout.marginWidth = 0; composite.setLayout(layout); composite.setLayoutData(new GridData(GridData.FILL_BOTH)); createValidatorPreferenceControls(composite); // create controls for filtering errors // define container & its gridding Group errorFilter = new Group(composite, SWT.NONE); GridLayout gridLayout = new GridLayout(); gridLayout.numColumns = 1; errorFilter.setLayout(gridLayout); errorFilter.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, true)); errorFilter.setText(CodeAssistMessages.ProblemsPreferencePage_ProblemViewFilters); _tableEditor = new TableEditor(errorFilter, SWT.NULL, true); _tableEditor.setDescription(CodeAssistMessages.ProblemsPreferencePage_ProblemsDescription); GridData data = new GridData(GridData.FILL_BOTH); data.heightHint = 150; _tableEditor.setLayoutData(data); IPreferenceStore store = doGetPreferenceStore(); String editors = store.getString(doGetPreferenceString()); ErrorDescriptor[] descriptors = ErrorDescriptor.deserializeErrorDescriptors(editors); List<Object> items = new ArrayList<Object>(Arrays.asList(descriptors)); _tableEditor.setLabelProvider(new TableLabelProvider()); _tableEditor.addAddItemListener(this); new TableColumn(_tableEditor.getTable(), SWT.LEFT); _tableEditor.setItems(items); workbench.getHelpSystem().setHelp(parent, IWorkbenchHelpContextIds.FILE_EDITORS_PREFERENCE_PAGE); applyDialogFont(_tableEditor); return composite; }
From source file:com.aptana.ide.editors.unified.colorizer.ColorizerReader.java
License:Open Source License
/** * Imports a colorization and saves it to preference and global registry. * // w ww . jav a2s . com * @param file - * imported colorization * @param mimeType */ public void importColorization(File file, String mimeType) { InputStream stream = null; try { String id = ids.get(mimeType); if (id != null) { IPreferenceStore store = UnifiedEditorsPlugin.getDefault().getPreferenceStore(); String content = store.getString(id); stream = file.toURL().openStream(); this.loadXML(stream); if (mimeType != null) { store.setValue(id, content); } } } catch (Exception e1) { IdeLog.logError(UnifiedEditorsPlugin.getDefault(), Messages.ColorizerReader_ERROR_IMPORTING); } finally { try { if (stream != null) { stream.close(); } } catch (IOException e) { } } }
From source file:com.aptana.ide.editors.unified.colorizer.ColorizerReader.java
License:Open Source License
/** * Loads a colorization from the preference store * /*from w w w . ja va 2 s . c o m*/ * @param id * @param register * @return - language colorizer */ public LanguageColorizer loadColorization(String id, boolean register) { registerColorizer = register; colorizer = null; mimeType = null; try { IPreferenceStore store = UnifiedEditorsPlugin.getDefault().getPreferenceStore(); String content = store.getString(id); InputStream stream = null; if (content.length() > 0) { stream = new ByteArrayInputStream(content.getBytes()); this.loadXML(stream); if (mimeType != null) { setPreferenceId(mimeType, id); store.setValue(id, content); } } } catch (Exception e) { colorizer = null; } return colorizer; }
From source file:com.aptana.ide.editors.unified.colorizer.ColorizerReader.java
License:Open Source License
/** * Loads a colorization file into the language registry * /*from w w w . j ava 2s . co m*/ * @param url * @param id * @param useDefault * @return - language colorizer */ public LanguageColorizer loadColorizationFromURL(URL url, String id, boolean useDefault) { InputStream stream = null; colorizer = null; mimeType = null; try { IPreferenceStore store = UnifiedEditorsPlugin.getDefault().getPreferenceStore(); String content = store.getString(id); if (content.length() > 0 && !useDefault) { stream = new ByteArrayInputStream(content.getBytes()); } else { stream = url.openStream(); } this.loadXML(stream); if (mimeType != null) { setPreferenceId(mimeType, id); urls.put(mimeType, url); store.setValue(id, content); } } catch (Exception e) { IdeLog.logError(UnifiedEditorsPlugin.getDefault(), StringUtils.format(Messages.ColorizerReader_ERROR_LOADING, id)); } finally { try { if (stream != null) { stream.close(); } } catch (IOException e) { } } return colorizer; }
From source file:com.aptana.ide.editors.unified.contentassist.CompletionProposalPopup.java
License:Open Source License
/** * Creates the proposal selector.//from ww w . j a v a2 s . c o m */ private void createProposalSelector() { Control control = fContentAssistSubjectControlAdapter.getControl(); if (Helper.okToUse(fProposalShell)) { // Custom code to force colors again in case theme changed... // Not sure why we don't set background for all WS here if (!"carbon".equals(SWT.getPlatform())) //$NON-NLS-1$ { fProposalShell.setBackground(getForegroundColor(control)); } Color c = getBackgroundColor(control); fProposalTable.setBackground(c); c = getForegroundColor(control); fProposalTable.setForeground(c); return; } fProposalShell = new Shell(control.getShell(), SWT.ON_TOP | SWT.RESIZE); fProposalTable = new Table(fProposalShell, SWT.H_SCROLL | SWT.V_SCROLL | SWT.VIRTUAL); Listener listener = new Listener() { public void handleEvent(Event event) { handleSetData(event); } }; fProposalTable.addListener(SWT.SetData, listener); final IPreferenceStore store = UnifiedEditorsPlugin.getDefault().getPreferenceStore(); _insertOnTab = store.getBoolean(IPreferenceConstants.INSERT_ON_TAB); String agents = store.getString(IPreferenceConstants.USER_AGENT_PREFERENCE); if (agents != null && !agents.equals(StringUtils.EMPTY)) { fUserAgents = agents.split(",").length; //$NON-NLS-1$ } else { fUserAgents = 0; } TableColumn initialInfo = new TableColumn(fProposalTable, SWT.LEFT); initialInfo.setWidth(16); for (int i = 0; i < fUserAgents; i++) { TableColumn tc = new TableColumn(fProposalTable, SWT.LEFT); tc.setWidth(17); } TableColumn locationInfo = new TableColumn(fProposalTable, SWT.LEFT); locationInfo.setWidth(16); fProposalTable.setLocation(0, 0); if (fAdditionalInfoController != null) { fAdditionalInfoController.setSizeConstraints(40, 10, true, false); } GridLayout layout = new GridLayout(); layout.marginWidth = 0; layout.marginHeight = 0; fProposalShell.setLayout(layout); GridData data = new GridData(GridData.FILL_BOTH); Point size = fContentAssistant.restoreCompletionProposalPopupSize(); if (size != null) { fProposalTable.setLayoutData(data); fProposalShell.setSize(size); } else { data.heightHint = fProposalTable.getItemHeight() * CompletionProposalPopup.PROPOSAL_ITEM_HEIGHT; data.widthHint = 300; fProposalTable.setLayoutData(data); fProposalShell.pack(); } fProposalShell.addControlListener(new ControlListener() { public void controlMoved(ControlEvent e) { } public void controlResized(ControlEvent e) { if (fAdditionalInfoController != null) { // reset the cached resize constraints fAdditionalInfoController.setSizeConstraints(40, 10, true, false); } fSize = fProposalShell.getSize(); } }); if (!"carbon".equals(SWT.getPlatform())) //$NON-NLS-1$ { fProposalShell.setBackground(getForegroundColor(control)); } Color c = getBackgroundColor(control); fProposalTable.setBackground(c); c = getForegroundColor(control); fProposalTable.setForeground(c); fProposalTable.addSelectionListener(new SelectionListener() { public void widgetSelected(SelectionEvent e) { } public void widgetDefaultSelected(SelectionEvent e) { selectProposalWithMask(e.stateMask); // This disposal on windows it because of focus issue when a select is manually select and the next time // the popup is show it has focus and so editor typing focus is lost if (Platform.OS_WIN32.equals(Platform.getOS())) { disposePopup(); } } }); fPopupCloser.install(fContentAssistant, fProposalTable); final IPropertyChangeListener propListener = new IPropertyChangeListener() { public void propertyChange(PropertyChangeEvent event) { if (event.getProperty().equals(IPreferenceConstants.USER_AGENT_PREFERENCE)) { if (Helper.okToUse(fProposalShell)) { fProposalShell.dispose(); } else { // shell already disposed so remove this listener if (store != null) { store.removePropertyChangeListener(this); } } } } }; store.addPropertyChangeListener(propListener); fProposalShell.addDisposeListener(new DisposeListener() { public void widgetDisposed(DisposeEvent e) { if (store != null && propListener != null) { store.removePropertyChangeListener(propListener); } unregister(); // but don't dispose the shell, since we're being called from its // disposal event! } }); fProposalTable.setHeaderVisible(false); }
From source file:com.aptana.ide.editors.unified.contentassist.UnifiedContentAssistProcessor.java
License:Open Source License
/** * Returns the string array of user agents * @return String[]//from ww w . ja v a2 s . com */ public static String[] getUserAgents() { if (PluginUtils.isPluginLoaded(UnifiedEditorsPlugin.getDefault())) { IPreferenceStore prefs = UnifiedEditorsPlugin.getDefault().getPreferenceStore(); String agents = prefs.getString(IPreferenceConstants.USER_AGENT_PREFERENCE); return agents.split(","); //$NON-NLS-1$ } else { return new String[] { Messages.UnifiedContentAssistProcessor_IE, Messages.UnifiedContentAssistProcessor_Mozilla }; } }
From source file:com.aptana.ide.editors.unified.errors.UnifiedErrorManager.java
License:Open Source License
/** * //from w w w .jav a 2s . c o m */ private void loadErrorDescriptors() { IPreferenceStore store = getPreferenceStore(); if (store != null) { String editors = store.getString(IPreferenceConstants.IGNORE_PROBLEMS); _errorDescriptors = ErrorDescriptor.deserializeErrorDescriptors(editors); } }
From source file:com.aptana.ide.editors.unified.errors.UnifiedErrorManager.java
License:Open Source License
/** * Retrieve registered validators, and apply selections made via preference settings *//*w ww .j ava2 s.c o m*/ private void initializeValidators() { ValidatorRef[] registeredValidators = ValidatorManager.getInstance().getValidators(mimeType); IPreferenceStore preferenceStore = getPreferenceStore(); if (preferenceStore != null) { String property = preferenceStore.getString(IPreferenceConstants.VALIDATORS_LIST); if (property != null && property.length() > 0) { String[] preferredValidators = property.split(","); //$NON-NLS-1$ ArrayList newValidators = new ArrayList(); for (int i = 0; i < preferredValidators.length; i++) { for (int j = 0; j < registeredValidators.length; j++) { if (preferredValidators[i].equals(registeredValidators[j].getName())) { newValidators.add(registeredValidators[j]); continue; } } } validators = (ValidatorRef[]) newValidators.toArray(new ValidatorRef[0]); } else { // Default is to use all the registered validators validators = registeredValidators; } } else { // Why should preference store be null ? IdeLog.logInfo(UnifiedEditorsPlugin.getDefault(), Messages.UnifiedErrorManager_PreferenceRetrievalError); validators = registeredValidators; } }
From source file:com.aptana.ide.editors.unified.UnifiedAutoIndentStrategy.java
License:Open Source License
/** * isAutoInsertEnabled/*from w w w. j a va2 s .c om*/ * * @return boolean */ protected boolean isAutoInsertEnabled() { IPreferenceStore store = getPreferenceStore(); String abi = com.aptana.ide.editors.preferences.IPreferenceConstants.AUTO_BRACKET_INSERTION; return (store == null || store.getString(abi).equals("NONE") == false); //$NON-NLS-1$ // if (store != null && store.getString(abi).equals("NONE")) // { // return false; // } // else // { // return true; // } }
From source file:com.aptana.ide.intro.IntroStartup.java
License:Open Source License
/** * Show the My Aptana start page.//from w w w . ja va2 s . c om */ protected void showMyAptana() { IPreferenceStore store = IntroPlugin.getDefault().getPreferenceStore(); boolean shownPreviously = store.getBoolean(IPreferenceConstants.SHOWN_PREVIOUSLY) || "true".equals(System.getProperty(IGNORE)); //$NON-NLS-1$ if (!shownPreviously) { store.setValue(IPreferenceConstants.SHOWN_PREVIOUSLY, true); showStartupPage(); return; } String showStartPage = store.getString(IPreferenceConstants.SHOW_STARTPAGE_ON_STARTUP); boolean portalPreviouslyOpened = PortalPlugin.getDefault().getPreferenceStore().getBoolean( com.aptana.ide.server.portal.preferences.IPreferenceConstants.MY_APTANA_PREVIOUSLY_OPENED); if (showStartPage.equals(IPreferenceConstants.ALWAYS_SHOW) || portalPreviouslyOpened) { showStartupPage(); return; } if (showStartPage.equals(IPreferenceConstants.NEVER_SHOW)) { return; } // this has a side effect of updating the feature change list store boolean changed = FeatureChangeManager.getManager().areFeaturesChanged(); if (changed) { IdeLog.logInfo(IntroPlugin.getDefault(), "Features Changed"); //$NON-NLS-1$ List<FeatureChange> changeList = FeatureChangeManager.getManager().getFeatureChangeList(); if (changeList != null && changeList.size() > 0) { showStartupPage(); } } else { IdeLog.logInfo(IntroPlugin.getDefault(), "Unchanged feature store"); //$NON-NLS-1$ } }