List of usage examples for org.eclipse.jface.preference IPreferenceStore contains
boolean contains(String name);
From source file:com.android.ddmuilib.ThreadPanel.java
License:Apache License
/** * Create our control(s).//w w w. j av a2 s .c o m */ @Override protected Control createControl(Composite parent) { mDisplay = parent.getDisplay(); final IPreferenceStore store = DdmUiPreferences.getStore(); mBase = new Composite(parent, SWT.NONE); mBase.setLayout(new StackLayout()); // UI for thread not enabled mNotEnabled = new Label(mBase, SWT.CENTER | SWT.WRAP); mNotEnabled.setText("Thread updates not enabled for selected client\n" + "(use toolbar button to enable)"); // UI for not client selected mNotSelected = new Label(mBase, SWT.CENTER | SWT.WRAP); mNotSelected.setText("no client is selected"); // base composite for selected client with enabled thread update. mThreadBase = new Composite(mBase, SWT.NONE); mThreadBase.setLayout(new FormLayout()); // table above the sash mThreadTable = new Table(mThreadBase, SWT.MULTI | SWT.FULL_SELECTION); mThreadTable.setHeaderVisible(true); mThreadTable.setLinesVisible(true); TableHelper.createTableColumn(mThreadTable, "ID", SWT.RIGHT, "888", //$NON-NLS-2$ PREFS_THREAD_COL_ID, store); TableHelper.createTableColumn(mThreadTable, "Tid", SWT.RIGHT, "88888", //$NON-NLS-2$ PREFS_THREAD_COL_TID, store); TableHelper.createTableColumn(mThreadTable, "Status", SWT.LEFT, "timed-wait", //$NON-NLS-2$ PREFS_THREAD_COL_STATUS, store); TableHelper.createTableColumn(mThreadTable, "utime", SWT.RIGHT, "utime", //$NON-NLS-2$ PREFS_THREAD_COL_UTIME, store); TableHelper.createTableColumn(mThreadTable, "stime", SWT.RIGHT, "utime", //$NON-NLS-2$ PREFS_THREAD_COL_STIME, store); TableHelper.createTableColumn(mThreadTable, "Name", SWT.LEFT, "android.class.ReallyLongClassName.MethodName", //$NON-NLS-1$ PREFS_THREAD_COL_NAME, store); mThreadViewer = new TableViewer(mThreadTable); mThreadViewer.setContentProvider(new ThreadContentProvider()); mThreadViewer.setLabelProvider(new ThreadLabelProvider()); mThreadViewer.addSelectionChangedListener(new ISelectionChangedListener() { @Override public void selectionChanged(SelectionChangedEvent event) { requestThreadStackTrace(getThreadSelection(event.getSelection())); } }); mThreadViewer.addDoubleClickListener(new IDoubleClickListener() { @Override public void doubleClick(DoubleClickEvent event) { requestThreadStackTrace(getThreadSelection(event.getSelection())); } }); // the separating sash final Sash sash = new Sash(mThreadBase, SWT.HORIZONTAL); Color darkGray = parent.getDisplay().getSystemColor(SWT.COLOR_DARK_GRAY); sash.setBackground(darkGray); // the UI below the sash mStackTraceBase = new Composite(mThreadBase, SWT.NONE); mStackTraceBase.setLayout(new GridLayout(2, false)); mRefreshStackTraceButton = new Button(mStackTraceBase, SWT.PUSH); mRefreshStackTraceButton.setText("Refresh"); mRefreshStackTraceButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { requestThreadStackTrace(getThreadSelection(null)); } }); mStackTraceTimeLabel = new Label(mStackTraceBase, SWT.NONE); mStackTraceTimeLabel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); mStackTracePanel = new StackTracePanel(); mStackTraceTable = mStackTracePanel.createPanel(mStackTraceBase, PREFS_STACK_COLUMN, store); GridData gd; mStackTraceTable.setLayoutData(gd = new GridData(GridData.FILL_BOTH)); gd.horizontalSpan = 2; // now setup the sash. // form layout data FormData data = new FormData(); data.top = new FormAttachment(0, 0); data.bottom = new FormAttachment(sash, 0); data.left = new FormAttachment(0, 0); data.right = new FormAttachment(100, 0); mThreadTable.setLayoutData(data); final FormData sashData = new FormData(); if (store != null && store.contains(PREFS_THREAD_SASH)) { sashData.top = new FormAttachment(0, store.getInt(PREFS_THREAD_SASH)); } else { sashData.top = new FormAttachment(50, 0); // 50% across } sashData.left = new FormAttachment(0, 0); sashData.right = new FormAttachment(100, 0); sash.setLayoutData(sashData); data = new FormData(); data.top = new FormAttachment(sash, 0); data.bottom = new FormAttachment(100, 0); data.left = new FormAttachment(0, 0); data.right = new FormAttachment(100, 0); mStackTraceBase.setLayoutData(data); // allow resizes, but cap at minPanelWidth sash.addListener(SWT.Selection, new Listener() { @Override public void handleEvent(Event e) { Rectangle sashRect = sash.getBounds(); Rectangle panelRect = mThreadBase.getClientArea(); int bottom = panelRect.height - sashRect.height - 100; e.y = Math.max(Math.min(e.y, bottom), 100); if (e.y != sashRect.y) { sashData.top = new FormAttachment(0, e.y); store.setValue(PREFS_THREAD_SASH, e.y); mThreadBase.layout(); } } }); ((StackLayout) mBase.getLayout()).topControl = mNotSelected; return mBase; }
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// www . j ava 2 s. c om * @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.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/*from w ww.j a v a 2s .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.preferences.CommonEditorPreferencePage.java
License:Open Source License
/** * Create the Content Assist group and options if there are any for this language/editor. * /*from ww w. ja v a2 s . com*/ * @param parent */ protected Composite createContentAssistOptions(Composite parent) { IPreferenceStore s = getChainedEditorPreferenceStore(); Label label = new Label(parent, SWT.NONE); label.setText(Messages.CommonEditorPreferencePage_OnTypingCharacters); label.setLayoutData(GridDataFactory.fillDefaults().span(2, 1).create()); if (s.contains( com.aptana.editor.common.contentassist.IPreferenceConstants.COMPLETION_PROPOSAL_ACTIVATION_CHARACTERS)) { addField(new StringFieldEditor( com.aptana.editor.common.contentassist.IPreferenceConstants.COMPLETION_PROPOSAL_ACTIVATION_CHARACTERS, Messages.CommonEditorPreferencePage_DisplayProposals, parent)); } if (s.contains( com.aptana.editor.common.contentassist.IPreferenceConstants.CONTEXT_INFORMATION_ACTIVATION_CHARACTERS)) { addField(new StringFieldEditor( com.aptana.editor.common.contentassist.IPreferenceConstants.CONTEXT_INFORMATION_ACTIVATION_CHARACTERS, Messages.CommonEditorPreferencePage_DisplayContextualInfo, parent)); } if (s.contains(com.aptana.editor.common.contentassist.IPreferenceConstants.PROPOSAL_TRIGGER_CHARACTERS)) { addField(new StringFieldEditor( com.aptana.editor.common.contentassist.IPreferenceConstants.PROPOSAL_TRIGGER_CHARACTERS, Messages.CommonEditorPreferencePage_InsertProposal, parent)); } return parent; }
From source file:com.aptana.ide.debug.internal.ui.actions.ShowConstantsActionDelegate.java
License:Open Source License
/** * getPreferenceValue//from www.j av a 2 s . co m * * @param part * @return boolean */ protected boolean getPreferenceValue(IViewPart part) { String baseKey = getPreferenceKey(); String viewKey = part.getSite().getId(); String compositeKey = viewKey + "." + baseKey; //$NON-NLS-1$ IPreferenceStore store = getPreferenceStore(); boolean value = false; if (store.contains(compositeKey)) { value = store.getBoolean(compositeKey); } else { value = store.getBoolean(baseKey); } return value; }
From source file:com.aptana.ide.debug.internal.ui.preferences.JSDebugPreferencePage.java
License:Open Source License
private void setInitialValues() { suspendOnFirstLine.setSelection(store.getBoolean(IJSDebugPreferenceNames.SUSPEND_ON_FIRST_LINE)); suspendOnExceptions.setSelection(store.getBoolean(IJSDebugPreferenceNames.SUSPEND_ON_EXCEPTIONS)); suspendOnErrors.setSelection(store.getBoolean(IJSDebugPreferenceNames.SUSPEND_ON_ERRORS)); suspendOnDebuggerKeyword/*from w ww . ja v a2 s . co m*/ .setSelection(store.getBoolean(IJSDebugPreferenceNames.SUSPEND_ON_DEBUGGER_KEYWORD)); IPreferenceStore uiStore = DebugUiPlugin.getDefault().getPreferenceStore(); if (!uiStore.contains(IDebugUIConstants.PREF_CONFIRM_EXIT_DEBUGGER)) { confirmExitDebugger.setSelection(true); // for compatibility with existing workspace/preferences } else { confirmExitDebugger.setSelection(uiStore.getBoolean(IDebugUIConstants.PREF_CONFIRM_EXIT_DEBUGGER)); } }
From source file:com.aptana.ide.debug.internal.ui.preferences.JSDebugPreferencePage.java
License:Open Source License
private void setDefaultValues() { suspendOnFirstLine.setSelection(store.getDefaultBoolean(IJSDebugPreferenceNames.SUSPEND_ON_FIRST_LINE)); suspendOnExceptions.setSelection(store.getDefaultBoolean(IJSDebugPreferenceNames.SUSPEND_ON_EXCEPTIONS)); suspendOnErrors.setSelection(store.getDefaultBoolean(IJSDebugPreferenceNames.SUSPEND_ON_ERRORS)); suspendOnDebuggerKeyword//from w ww . ja va 2 s .co m .setSelection(store.getDefaultBoolean(IJSDebugPreferenceNames.SUSPEND_ON_DEBUGGER_KEYWORD)); IPreferenceStore uiStore = DebugUiPlugin.getDefault().getPreferenceStore(); if (uiStore.contains(IDebugUIConstants.PREF_CONFIRM_EXIT_DEBUGGER)) { confirmExitDebugger .setSelection(uiStore.getDefaultBoolean(IDebugUIConstants.PREF_CONFIRM_EXIT_DEBUGGER)); } else { confirmExitDebugger.setSelection(true); } }
From source file:com.aptana.ide.debug.internal.ui.WorkbenchCloseListener.java
License:Open Source License
/** * @see org.eclipse.swt.widgets.Listener#handleEvent(org.eclipse.swt.widgets.Event) */// w w w . j av a 2 s .c om public void handleEvent(Event event) { if (event.widget instanceof Shell && PlatformUI.getWorkbench().getWorkbenchWindowCount() == 1 && PlatformUI.getWorkbench().getWorkbenchWindows()[0].getShell() == event.widget) { // last workbench window is about to close if ("true".equals(System.getProperty(JSDebugOptionsManager.DEBUGGER_ACTIVE))) { //$NON-NLS-1$ IPreferenceStore store = DebugUiPlugin.getDefault().getPreferenceStore(); if (store.contains(IDebugUIConstants.PREF_CONFIRM_EXIT_DEBUGGER)) { if (store.getBoolean(IDebugUIConstants.PREF_CONFIRM_EXIT_DEBUGGER) == false) { return; } } event.doit = false; MessageDialogWithToggle dlg = MessageDialogWithToggle.openOkCancelConfirm((Shell) event.widget, Messages.WorkbenchCloseListener_ConfirmDebuggerExit, Messages.WorkbenchCloseListener_AptanaDebuggerIsActive_DoYouWantToExit, Messages.WorkbenchCloseListener_AlwaysExitDebuggerWithoutPrompt, false, null, null); int returnValue = dlg.getReturnCode(); if (returnValue != IDialogConstants.OK_ID) { // SWT hack - discard close event event.type = SWT.None; return; } if (dlg.getToggleState()) { store.setValue(IDebugUIConstants.PREF_CONFIRM_EXIT_DEBUGGER, false); DebugUiPlugin.getDefault().savePluginPreferences(); } } } }
From source file:com.aptana.ide.installer.wizard.InstallerWizardDialog.java
License:Open Source License
/** * @see org.eclipse.jface.wizard.WizardDialog#createButtonsForButtonBar(org.eclipse.swt.widgets.Composite) *///from w w w .j a v a 2 s. co m protected void createButtonsForButtonBar(Composite parent) { // adds the "Do not show again" checkbox GridLayout layout = (GridLayout) parent.getLayout(); // makes necessary adjustment to the layout // 1. increment the number of columns in the button bar layout.numColumns++; layout.numColumns++; // For Manage Plugins... button // 2. makes the columns unequal widths layout.makeColumnsEqualWidth = false; // adjusts the layout data GridData gridData = (GridData) parent.getLayoutData(); gridData.grabExcessHorizontalSpace = true; gridData.horizontalAlignment = GridData.FILL; Composite button = new Composite(parent, SWT.NONE); button.setLayout(new GridLayout()); gridData = new GridData(SWT.FILL, SWT.FILL, true, true); // calculates the minimum width the composite should have GC gc = new GC(button); gridData.widthHint = gc.stringExtent(Messages.InstallerWizardDialog_DoNotShowNote).x + 10; gc.dispose(); button.setLayoutData(gridData); fDoNotShowButton = new Button(button, SWT.CHECK); fDoNotShowButton.setText(Messages.InstallerWizardDialog_DoNotShowLabel); fDoNotShowButton.setFont(JFaceResources.getDialogFont()); boolean donotshow; IPreferenceStore prefs = Activator.getDefault().getPreferenceStore(); if (prefs.contains(IPreferenceConstants.WIZARD_DO_NOT_SHOW_AGAIN)) { donotshow = prefs.getBoolean(IPreferenceConstants.WIZARD_DO_NOT_SHOW_AGAIN); } else { donotshow = prefs.getBoolean(IPreferenceConstants.WIZARD_DO_NOT_SHOW_AGAIN_DEFAULT); } fDoNotShowButton.setSelection(donotshow); fDoNotShowButton.setLayoutData(new GridData(SWT.BEGINNING, SWT.FILL, true, true)); fDoNotShowButton.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { saveStates(); updateDoNotShowLayout(); } }); Button managePluginsButton = new Button(parent, SWT.PUSH); managePluginsButton.setText(Messages.InstallerWizardDialog_Manage_Plugins); managePluginsButton.addSelectionListener(new SelectionListener() { public void widgetDefaultSelected(SelectionEvent e) { widgetSelected(e); } public void widgetSelected(SelectionEvent e) { try { close(); CoreUIUtils.showView("com.aptana.ide.ui.ViewPlugins"); //$NON-NLS-1$ } catch (PartInitException e1) { // Do nothing, view didn't open } } }); super.createButtonsForButtonBar(parent); // changes the "Finish" text to "Install" and disables it by default getFinishButton().setText(INSTALL_LABEL); // changes the "Cancel" text to "Close" getButton(IDialogConstants.CANCEL_ID).setText(CLOSE_LABEL); }
From source file:com.aptana.js.debug.ui.internal.preferences.JSDebugPreferencePage.java
License:Open Source License
private void setInitialValues() { suspendOnFirstLine/*from w w w. j a va 2 s. c om*/ .setSelection(getPreferenceStore().getBoolean(IJSDebugPreferenceNames.SUSPEND_ON_FIRST_LINE)); suspendOnExceptions .setSelection(getPreferenceStore().getBoolean(IJSDebugPreferenceNames.SUSPEND_ON_EXCEPTIONS)); suspendOnErrors.setSelection(getPreferenceStore().getBoolean(IJSDebugPreferenceNames.SUSPEND_ON_ERRORS)); suspendOnDebuggerKeyword .setSelection(getPreferenceStore().getBoolean(IJSDebugPreferenceNames.SUSPEND_ON_DEBUGGER_KEYWORD)); IPreferenceStore uiStore = JSDebugUIPlugin.getDefault().getPreferenceStore(); if (!uiStore.contains(IJSDebugUIConstants.PREF_CONFIRM_EXIT_DEBUGGER)) { confirmExitDebugger.setSelection(true); // for compatibility with // existing // workspace/preferences } else { confirmExitDebugger.setSelection(uiStore.getBoolean(IJSDebugUIConstants.PREF_CONFIRM_EXIT_DEBUGGER)); } }