List of usage examples for org.eclipse.jface.preference IPreferenceStore getInt
int getInt(String name);
From source file:com.android.ide.eclipse.adt.internal.ui.ResourceExplorerView.java
License:Open Source License
/** * Create a TreeColumn with the specified parameters. If a * <code>PreferenceStore</code> object and a preference entry name String * object are provided then the column will listen to change in its width * and update the preference store accordingly. * * @param parent The Table parent object * @param header The header string//from w w w . j a v a2 s . co m * @param style The column style * @param sample_text A sample text to figure out column width if preference * value is missing * @param fixedSize a fixed size. If != -1 the column is non resizable * @param pref_name The preference entry name for column width * @param prefs The preference store */ public void createTreeColumn(Tree parent, String header, int style, String sample_text, int fixedSize, final String pref_name, final IPreferenceStore prefs) { // create the column TreeColumn col = new TreeColumn(parent, style); if (fixedSize != -1) { col.setWidth(fixedSize); col.setResizable(false); } else { // if there is no pref store or the entry is missing, we use the sample // text and pack the column. // Otherwise we just read the width from the prefs and apply it. if (prefs == null || prefs.contains(pref_name) == false) { col.setText(sample_text); col.pack(); // init the prefs store with the current value if (prefs != null) { prefs.setValue(pref_name, col.getWidth()); } } else { col.setWidth(prefs.getInt(pref_name)); } // if there is a pref store and a pref entry name, then we setup a // listener to catch column resize to put the new width value into the store. if (prefs != null && pref_name != null) { col.addControlListener(new ControlListener() { @Override public void controlMoved(ControlEvent e) { } @Override public void controlResized(ControlEvent e) { // get the new width int w = ((TreeColumn) e.widget).getWidth(); // store in pref store prefs.setValue(pref_name, w); } }); } } // set the header col.setText(header); }
From source file:com.android.ide.eclipse.ddms.DdmsPlugin.java
License:Apache License
@Override public void start(BundleContext context) throws Exception { super.start(context); final Display display = getDisplay(); // get the eclipse store final IPreferenceStore eclipseStore = getPreferenceStore(); AndroidDebugBridge.addDeviceChangeListener(this); DdmUiPreferences.setStore(eclipseStore); //DdmUiPreferences.displayCharts(); // set the consoles. mDdmsConsole = new MessageConsole("DDMS", null); //$NON-NLS-1$ ConsolePlugin.getDefault().getConsoleManager().addConsoles(new IConsole[] { mDdmsConsole }); final MessageConsoleStream consoleStream = mDdmsConsole.newMessageStream(); final MessageConsoleStream errorConsoleStream = mDdmsConsole.newMessageStream(); mRed = new Color(display, 0xFF, 0x00, 0x00); // because this can be run, in some cases, by a non UI thread, and because // changing the console properties update the UI, we need to make this change // in the UI thread. display.asyncExec(new Runnable() { @Override/*ww w .j a v a 2 s .com*/ public void run() { errorConsoleStream.setColor(mRed); } }); // set up the ddms log to use the ddms console. Log.setLogOutput(new ILogOutput() { @Override public void printLog(LogLevel logLevel, String tag, String message) { if (logLevel.getPriority() >= LogLevel.ERROR.getPriority()) { printToStream(errorConsoleStream, tag, message); showConsoleView(mDdmsConsole); } else { printToStream(consoleStream, tag, message); } } @Override public void printAndPromptLog(final LogLevel logLevel, final String tag, final String message) { printLog(logLevel, tag, message); // dialog box only run in UI thread.. display.asyncExec(new Runnable() { @Override public void run() { Shell shell = display.getActiveShell(); if (logLevel == LogLevel.ERROR) { MessageDialog.openError(shell, tag, message); } else { MessageDialog.openWarning(shell, tag, message); } } }); } }); // set up the ddms console to use this objects DdmConsole.setConsole(new IDdmConsole() { @Override public void printErrorToConsole(String message) { printToStream(errorConsoleStream, null, message); showConsoleView(mDdmsConsole); } @Override public void printErrorToConsole(String[] messages) { for (String m : messages) { printToStream(errorConsoleStream, null, m); } showConsoleView(mDdmsConsole); } @Override public void printToConsole(String message) { printToStream(consoleStream, null, message); } @Override public void printToConsole(String[] messages) { for (String m : messages) { printToStream(consoleStream, null, m); } } }); // set the listener for the preference change eclipseStore.addPropertyChangeListener(new IPropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent event) { // get the name of the property that changed. String property = event.getProperty(); if (PreferenceInitializer.ATTR_DEBUG_PORT_BASE.equals(property)) { DdmPreferences .setDebugPortBase(eclipseStore.getInt(PreferenceInitializer.ATTR_DEBUG_PORT_BASE)); } else if (PreferenceInitializer.ATTR_SELECTED_DEBUG_PORT.equals(property)) { DdmPreferences.setSelectedDebugPort( eclipseStore.getInt(PreferenceInitializer.ATTR_SELECTED_DEBUG_PORT)); } else if (PreferenceInitializer.ATTR_THREAD_INTERVAL.equals(property)) { DdmUiPreferences.setThreadRefreshInterval( eclipseStore.getInt(PreferenceInitializer.ATTR_THREAD_INTERVAL)); } else if (PreferenceInitializer.ATTR_LOG_LEVEL.equals(property)) { DdmPreferences.setLogLevel(eclipseStore.getString(PreferenceInitializer.ATTR_LOG_LEVEL)); } else if (PreferenceInitializer.ATTR_TIME_OUT.equals(property)) { DdmPreferences.setTimeOut(eclipseStore.getInt(PreferenceInitializer.ATTR_TIME_OUT)); } else if (PreferenceInitializer.ATTR_USE_ADBHOST.equals(property)) { DdmPreferences.setUseAdbHost(eclipseStore.getBoolean(PreferenceInitializer.ATTR_USE_ADBHOST)); } else if (PreferenceInitializer.ATTR_ADBHOST_VALUE.equals(property)) { DdmPreferences .setAdbHostValue(eclipseStore.getString(PreferenceInitializer.ATTR_ADBHOST_VALUE)); } } }); // do some last initializations // set the preferences. PreferenceInitializer.setupPreferences(); // this class is set as the main source revealer and will look at all the implementations // of the extension point. see #reveal(String, String, int) StackTracePanel.setSourceRevealer(this); /* * Load the extension point implementations. * The first step is to load the IConfigurationElement representing the implementations. * The 2nd step is to use these objects to instantiate the implementation classes. * * Because the 2nd step will trigger loading the plug-ins providing the implementations, * and those plug-ins could access DDMS classes (like ADT), this 2nd step should be done * in a Job to ensure that DDMS is loaded, so that the other plug-ins can load. * * Both steps could be done in the 2nd step but some of DDMS UI rely on knowing if there * is an implementation or not (DeviceView), so we do the first steps in start() and, in * some case, record it. * */ // get the IConfigurationElement for the debuggerConnector right away. final IConfigurationElement[] dcce = findConfigElements("com.android.ide.eclipse.ddms.debuggerConnector"); //$NON-NLS-1$ mHasDebuggerConnectors = dcce.length > 0; // get the other configElements and instantiante them in a Job. new Job(Messages.DdmsPlugin_DDMS_Post_Create_Init) { @Override protected IStatus run(IProgressMonitor monitor) { try { // init the lib AndroidDebugBridge.init(true /* debugger support */); // get the available adb locators IConfigurationElement[] elements = findConfigElements( "com.android.ide.eclipse.ddms.toolsLocator"); //$NON-NLS-1$ IToolsLocator[] locators = instantiateToolsLocators(elements); for (IToolsLocator locator : locators) { try { String adbLocation = locator.getAdbLocation(); String traceviewLocation = locator.getTraceViewLocation(); String hprofConvLocation = locator.getHprofConvLocation(); if (adbLocation != null && traceviewLocation != null && hprofConvLocation != null) { // checks if the location is valid. if (setToolsLocation(adbLocation, hprofConvLocation, traceviewLocation)) { AndroidDebugBridge.createBridge(sAdbLocation, true /* forceNewBridge */); // no need to look at the other locators. break; } } } catch (Throwable t) { // ignore, we'll just not use this implementation. } } // get the available debugger connectors mDebuggerConnectors = instantiateDebuggerConnectors(dcce); // get the available Traceview Launchers. elements = findConfigElements("com.android.ide.eclipse.ddms.traceviewLauncher"); //$NON-NLS-1$ mTraceviewLaunchers = instantiateTraceviewLauncher(elements); return Status.OK_STATUS; } catch (CoreException e) { return e.getStatus(); } } }.schedule(); }
From source file:com.android.ide.eclipse.ddms.preferences.PreferenceInitializer.java
License:Apache License
/** * Initializes the preferences of ddmlib and ddmuilib with values from the eclipse store. *//*from www.ja va 2 s . c om*/ public synchronized static void setupPreferences() { IPreferenceStore store = DdmsPlugin.getDefault().getPreferenceStore(); DdmPreferences.setDebugPortBase(store.getInt(ATTR_DEBUG_PORT_BASE)); DdmPreferences.setSelectedDebugPort(store.getInt(ATTR_SELECTED_DEBUG_PORT)); DdmPreferences.setLogLevel(store.getString(ATTR_LOG_LEVEL)); DdmPreferences.setInitialThreadUpdate(store.getBoolean(ATTR_DEFAULT_THREAD_UPDATE)); DdmPreferences.setInitialHeapUpdate(store.getBoolean(ATTR_DEFAULT_HEAP_UPDATE)); DdmPreferences.setProfilerBufferSizeMb(store.getInt(ATTR_PROFILER_BUFSIZE_MB)); DdmUiPreferences.setThreadRefreshInterval(store.getInt(ATTR_THREAD_INTERVAL)); DdmPreferences.setTimeOut(store.getInt(ATTR_TIME_OUT)); DdmPreferences.setUseAdbHost(store.getBoolean(ATTR_USE_ADBHOST)); DdmPreferences.setAdbHostValue(store.getString(ATTR_ADBHOST_VALUE)); }
From source file:com.android.ide.eclipse.editors.resources.explorer.ResourceExplorerView.java
License:Open Source License
/** * Create a TreeColumn with the specified parameters. If a * <code>PreferenceStore</code> object and a preference entry name String * object are provided then the column will listen to change in its width * and update the preference store accordingly. * * @param parent The Table parent object * @param header The header string/* ww w .j a va 2 s. c o m*/ * @param style The column style * @param sample_text A sample text to figure out column width if preference * value is missing * @param fixedSize a fixed size. If != -1 the column is non resizable * @param pref_name The preference entry name for column width * @param prefs The preference store */ public void createTreeColumn(Tree parent, String header, int style, String sample_text, int fixedSize, final String pref_name, final IPreferenceStore prefs) { // create the column TreeColumn col = new TreeColumn(parent, style); if (fixedSize != -1) { col.setWidth(fixedSize); col.setResizable(false); } else { // if there is no pref store or the entry is missing, we use the sample // text and pack the column. // Otherwise we just read the width from the prefs and apply it. if (prefs == null || prefs.contains(pref_name) == false) { col.setText(sample_text); col.pack(); // init the prefs store with the current value if (prefs != null) { prefs.setValue(pref_name, col.getWidth()); } } else { col.setWidth(prefs.getInt(pref_name)); } // if there is a pref store and a pref entry name, then we setup a // listener to catch column resize to put the new width value into the store. if (prefs != null && pref_name != null) { col.addControlListener(new ControlListener() { public void controlMoved(ControlEvent e) { } public void controlResized(ControlEvent e) { // get the new width int w = ((TreeColumn) e.widget).getWidth(); // store in pref store prefs.setValue(pref_name, w); } }); } } // set the header col.setText(header); }
From source file:com.aptana.editor.common.AbstractThemeableEditor.java
License:Open Source License
@Override protected void handlePreferenceStoreChanged(PropertyChangeEvent event) { super.handlePreferenceStoreChanged(event); if (this.fThemeableEditorColorsExtension == null) { return;/*from w ww . j av a2 s. com*/ } this.fThemeableEditorColorsExtension.handlePreferenceStoreChanged(event); // Add case when the global editor settings have changed String property = event.getProperty(); if (property.equals(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_LINE_NUMBER_RULER)) { ((CommonLineNumberChangeRulerColumn) fLineNumberRulerColumn).showLineNumbers(isLineNumberVisible()); } else if (property.equals(IPreferenceConstants.EDITOR_PEER_CHARACTER_CLOSE)) { fPeerCharacterCloser .setAutoInsertEnabled(Boolean.parseBoolean(StringUtil.getStringValue(event.getNewValue()))); } else if (property.equals(IPreferenceConstants.EDITOR_WRAP_SELECTION)) { fPeerCharacterCloser .setAutoWrapEnabled(Boolean.parseBoolean(StringUtil.getStringValue(event.getNewValue()))); } else if (property.equals(IPreferenceConstants.EDITOR_ENABLE_FOLDING)) { SourceViewerConfiguration config = getSourceViewerConfiguration(); if (config instanceof CommonSourceViewerConfiguration) { ((CommonSourceViewerConfiguration) config).forceReconcile(); } } else if (IPreferenceConstants.USE_GLOBAL_DEFAULTS.equals(property)) { // Update the tab settings when we modify the use global defaults preference IPreferenceStore store = getPreferenceStore(); if (store != null) { getSourceViewer().getTextWidget() .setTabs(store.getInt(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_TAB_WIDTH)); } if (isTabsToSpacesConversionEnabled()) { installTabsToSpacesConverter(); } else { uninstallTabsToSpacesConverter(); } return; } }
From source file:com.aptana.formatter.FormatterUtils.java
License:Open Source License
/** * Returns the editor's tab width as set in the given editor's-specific preferences. In case a value is not found, * or the preferences are null, the workspace settings for the editor's tab-width will be returned. * //from w w w. j av a 2 s.c om * @param preferenceStore * The editor's preferences store; Null, in case a workspace setting is needed. * @return The editor's tab-width * @deprecated Use EditorUtil.getSpaceIndentSize(preferencesQualifier) */ public static int getEditorTabWidth(IPreferenceStore preferenceStore) { IPreferenceStore prefs = getChainedPreferences(preferenceStore, EditorsPlugin.getDefault().getPreferenceStore()); return prefs.getInt(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_TAB_WIDTH); }
From source file:com.aptana.ide.core.ui.InitialStartup.java
License:Open Source License
/** * Run whenever the web perspective is activated * /* ww w.j a v a 2 s . c o m*/ * @param page * @param listener */ private static void onWebPerspectiveActivated(IWorkbenchPage page) { IPreferenceStore prefs = CoreUIPlugin.getDefault().getPreferenceStore(); int lastWorkspace = prefs.getInt(IPreferenceConstants.WEB_PERSPECTIVE_LAST_VERSION); if (WebPerspectiveFactory.VERSION > lastWorkspace) { prefs.setValue(IPreferenceConstants.WEB_PERSPECTIVE_LAST_VERSION, WebPerspectiveFactory.VERSION); prefs.setValue(IPreferenceConstants.WEB_PERSPECTIVE_RESET_PERSPECTIVE, false); WebPerspectiveFactory.resetPerspective(page); } }
From source file:com.aptana.ide.core.ui.PreferenceUtils.java
License:Open Source License
private static boolean actuallyRestore(IPreferenceStore store, String key, TableColumn[] columns) { boolean found = false; for (int a = 0; a < columns.length; a++) { int int1 = store.getInt(getColumnKey(key, a)); if (int1 != 0) { found = true;//from www . java2 s .c om columns[a].setWidth(int1); } } return found; }
From source file:com.aptana.ide.core.ui.PreferenceUtils.java
License:Open Source License
/** * restoring columns width settings from preference store * /*from w ww . j a va2s .com*/ * @param store * @param key * @param tree */ public static void restoreSettingsFromPreferenceStore(IPreferenceStore store, String key, final Tree tree) { TreeColumn[] columns = tree.getColumns(); boolean found = false; for (int a = 0; a < columns.length; a++) { int int1 = store.getInt(getColumnKey(key, a)); if (int1 != 0) { columns[a].setWidth(int1); found = true; } } if (tree.getLayout() instanceof TableLayout && found) { final TableLayout ll = (TableLayout) tree.getLayout(); tree.setLayout(null); tree.addControlListener(new ControlListener() { int inc = 0; public void controlMoved(ControlEvent e) { } public void controlResized(ControlEvent e) { if (inc == 1) { tree.setLayout(ll); } inc++; } }); } }
From source file:com.aptana.ide.editor.css.formatting.CSSCodeFormatterOptions.java
License:Open Source License
private void initFromPreferences() { IPreferenceStore preferenceStore = CSSPlugin.getDefault().getPreferenceStore(); formatterTabChar = preferenceStore.getString(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR); tabSize = preferenceStore.getInt(DefaultCodeFormatterConstants.FORMATTER_TAB_SIZE); formatterBracePositionForBlock = parseOption(preferenceStore, DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK); newlinesBetweenSelectors = preferenceStore.getBoolean(NEWLINES_BETWEEN_SELECTORS); String string = preferenceStore.getString(DefaultCodeFormatterConstants.NO_FORMATTING); if (string.length() > 0) { doFormatting = false;//from w w w .ja va2 s . c o m } }