List of usage examples for org.eclipse.jface.preference IPreferenceStore setValue
void setValue(String name, boolean value);
From source file:com.android.ddmuilib.NativeHeapPanel.java
License:Apache License
private void createLibraryTopHalf(Composite base) { final int minPanelWidth = 60; final IPreferenceStore prefs = DdmUiPreferences.getStore(); // create a composite that'll contain 2 tables horizontally final Composite top = new Composite(base, SWT.NONE); mLibraryModeTopControl = top;/* w w w. j a v a2s . c om*/ top.setLayout(new FormLayout()); top.setLayoutData(new GridData(GridData.FILL_BOTH)); // first table: library mLibraryTable = new Table(top, SWT.MULTI | SWT.FULL_SELECTION); mLibraryTable.setLayoutData(new GridData(GridData.FILL_BOTH)); mLibraryTable.setHeaderVisible(true); mLibraryTable.setLinesVisible(true); TableHelper.createTableColumn(mLibraryTable, "Library", SWT.LEFT, "abcdefghijklmnopqrstuvwxyz", //$NON-NLS-2$ PREFS_LIB_LIBRARY, prefs); TableHelper.createTableColumn(mLibraryTable, "Size", SWT.RIGHT, "9,999,999", PREFS_LIB_SIZE, prefs); //$NON-NLS-2$ TableHelper.createTableColumn(mLibraryTable, "Count", SWT.RIGHT, "9,999", PREFS_LIB_COUNT, prefs); //$NON-NLS-2$ mLibraryTable.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { fillLibraryAllocationTable(); } }); final Sash sash = new Sash(top, SWT.VERTICAL); // 2nd table: allocation per library mLibraryAllocationTable = new Table(top, SWT.MULTI | SWT.FULL_SELECTION); mLibraryAllocationTable.setLayoutData(new GridData(GridData.FILL_BOTH)); mLibraryAllocationTable.setHeaderVisible(true); mLibraryAllocationTable.setLinesVisible(true); TableHelper.createTableColumn(mLibraryAllocationTable, "Total", SWT.RIGHT, "9,999,999", //$NON-NLS-2$ PREFS_LIBALLOC_TOTAL, prefs); TableHelper.createTableColumn(mLibraryAllocationTable, "Count", SWT.RIGHT, "9,999", PREFS_LIBALLOC_COUNT, //$NON-NLS-2$ prefs); TableHelper.createTableColumn(mLibraryAllocationTable, "Size", SWT.RIGHT, "999,999", PREFS_LIBALLOC_SIZE, //$NON-NLS-2$ prefs); TableHelper.createTableColumn(mLibraryAllocationTable, "Method", SWT.LEFT, "abcdefghijklmnopqrst", //$NON-NLS-2$ PREFS_LIBALLOC_METHOD, prefs); mLibraryAllocationTable.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { // get the index of the selection in the library table int index1 = mLibraryTable.getSelectionIndex(); // get the index in the library allocation table int index2 = mLibraryAllocationTable.getSelectionIndex(); // get the MallocInfo object if (index1 != -1 && index2 != -1) { LibraryAllocations liballoc = mLibraryAllocations.get(index1); NativeAllocationInfo info = liballoc.getAllocation(index2); fillDetailTable(info); } } }); // form layout data FormData data = new FormData(); data.top = new FormAttachment(0, 0); data.bottom = new FormAttachment(100, 0); data.left = new FormAttachment(0, 0); data.right = new FormAttachment(sash, 0); mLibraryTable.setLayoutData(data); final FormData sashData = new FormData(); if (prefs != null && prefs.contains(PREFS_LIBRARY_SASH)) { sashData.left = new FormAttachment(0, prefs.getInt(PREFS_LIBRARY_SASH)); } else { sashData.left = new FormAttachment(50, 0); } sashData.bottom = new FormAttachment(100, 0); sashData.top = new FormAttachment(0, 0); // 50% across sash.setLayoutData(sashData); data = new FormData(); data.top = new FormAttachment(0, 0); data.bottom = new FormAttachment(100, 0); data.left = new FormAttachment(sash, 0); data.right = new FormAttachment(100, 0); mLibraryAllocationTable.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 = top.getClientArea(); int right = panelRect.width - sashRect.width - minPanelWidth; e.x = Math.max(Math.min(e.x, right), minPanelWidth); if (e.x != sashRect.x) { sashData.left = new FormAttachment(0, e.x); prefs.setValue(PREFS_LIBRARY_SASH, e.y); top.layout(); } } }); }
From source file:com.android.ddmuilib.TableHelper.java
License:Apache License
/** * Create a TableColumn 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. jav a2s . c om * @param style The column style * @param sample_text A sample text to figure out column width if preference * value is missing * @param pref_name The preference entry name for column width * @param prefs The preference store * @return The TableColumn object that was created */ public static TableColumn createTableColumn(Table parent, String header, int style, String sample_text, final String pref_name, final IPreferenceStore prefs) { // create the column TableColumn col = new TableColumn(parent, style); // 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)); } // set the header col.setText(header); // if there is a pref store and a pref entry name, then we setup a // listener to catch column resize to put store the new width value. 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 = ((TableColumn) e.widget).getWidth(); // store in pref store prefs.setValue(pref_name, w); } }); } return col; }
From source file:com.android.ddmuilib.TableHelper.java
License:Apache 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/*w w w .j av a 2 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 pref_name The preference entry name for column width * @param prefs The preference store */ public static void createTreeColumn(Tree parent, String header, int style, String sample_text, final String pref_name, final IPreferenceStore prefs) { // create the column TreeColumn col = new TreeColumn(parent, style); // 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)); } // set the header col.setText(header); // if there is a pref store and a pref entry name, then we setup a // listener to catch column resize to put store the new width value. 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); } }); } }
From source file:com.android.ddmuilib.TableHelper.java
License:Apache 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 www .j a v a2s . c o m*/ * @param style The column style * @param width the width of the column if the preference value is missing * @param pref_name The preference entry name for column width * @param prefs The preference store */ public static void createTreeColumn(Tree parent, String header, int style, int width, final String pref_name, final IPreferenceStore prefs) { // create the column TreeColumn col = new TreeColumn(parent, style); // 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.setWidth(width); // init the prefs store with the current value if (prefs != null) { prefs.setValue(pref_name, width); } } else { col.setWidth(prefs.getInt(pref_name)); } // set the header col.setText(header); // if there is a pref store and a pref entry name, then we setup a // listener to catch column resize to put store the new width value. 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); } }); } }
From source file:com.android.ddmuilib.ThreadPanel.java
License:Apache License
/** * Create our control(s).// w w w.j a v a 2 s. c om */ @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.installer.InstallSdkDialog.java
License:Open Source License
private void createShowMeButton(Composite composite) { GridData gd;/*from w w w .j av a 2 s . c o m*/ mShowMeButton = new Button(composite, SWT.CHECK); gd = new GridData(); gd.horizontalSpan = 3; mShowMeButton.setLayoutData(gd); mShowMeButton.setText("Show me again"); boolean showMe = InstallerActivator.getDefault().getPreferenceStore() .getBoolean(InstallerActivator.SHOW_ME_AGAIN); mShowMeButton.setSelection(showMe); mShowMeButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { IPreferenceStore prefs = InstallerActivator.getDefault().getPreferenceStore(); prefs.setValue(InstallerActivator.SHOW_ME_AGAIN, mShowMeButton.getSelection()); } }); }
From source file:com.android.ide.eclipse.adt.internal.editors.layout.refactoring.ExtractIncludeRefactoringTest.java
License:Open Source License
public void testExtract7() throws Exception { // Just like testExtract6, except we turn on auto-formatting IPreferenceStore store = AdtPlugin.getDefault().getPreferenceStore(); AdtPrefs.init(store);//from w w w . jav a2 s . co m AdtPrefs prefs = AdtPrefs.getPrefs(); prefs.initializeStoreWithDefaults(store); store.setValue(AdtPrefs.PREFS_FORMAT_GUI_XML, true); prefs.loadValues(null); assertTrue(AdtPrefs.getPrefs().getFormatGuiXml()); testExtract6(); }
From source file:com.android.ide.eclipse.adt.internal.editors.layout.refactoring.RefactoringTest.java
License:Open Source License
@Override protected void setUp() throws Exception { // Ensure that the defaults are initialized so for example formatting options are // initialized properly IPreferenceStore store = AdtPlugin.getDefault().getPreferenceStore(); AdtPrefs.init(store);//from w ww .ja va 2s . c o m AdtPrefs prefs = AdtPrefs.getPrefs(); prefs.initializeStoreWithDefaults(store); store.setValue(AdtPrefs.PREFS_FORMAT_GUI_XML, autoFormat()); prefs.loadValues(null); super.setUp(); }
From source file:com.android.ide.eclipse.adt.internal.lint.GlobalLintConfiguration.java
License:Open Source License
/** * Sets the custom severities for the given issues, in bulk. * * @param severities a map from detector to severity to use from now on * @return true if something changed from the current settings *///from w w w .j a v a 2s . c o m private boolean setSeverities(Map<Issue, Severity> severities) { mSeverities = severities; String value = ""; if (severities.size() > 0) { List<Issue> sortedKeys = new ArrayList<Issue>(severities.keySet()); Collections.sort(sortedKeys); StringBuilder sb = new StringBuilder(severities.size() * 20); for (Issue issue : sortedKeys) { Severity severity = severities.get(issue); if (severity != issue.getDefaultSeverity()) { if (sb.length() > 0) { sb.append(','); } sb.append(issue.getId()); sb.append('='); sb.append(severity.name()); } } value = sb.toString(); } IPreferenceStore store = getStore(); String previous = store.getString(AdtPrefs.PREFS_LINT_SEVERITIES); boolean changed = !value.equals(previous); if (changed) { if (value.length() == 0) { store.setToDefault(AdtPrefs.PREFS_LINT_SEVERITIES); } else { store.setValue(AdtPrefs.PREFS_LINT_SEVERITIES, value); } } return changed; }
From source file:com.android.ide.eclipse.adt.internal.lint.LintEclipseContext.java
License:Open Source License
/** * Sets the custom severity for the given detector to the given new severity * * @param severities a map from detector to severity to use from now on *///www .j a v a 2 s.c o m public void setSeverities(Map<Issue, Severity> severities) { mSeverities = null; IPreferenceStore store = AdtPlugin.getDefault().getPreferenceStore(); if (severities.size() == 0) { store.setToDefault(AdtPrefs.PREFS_LINT_SEVERITIES); return; } List<Issue> sortedKeys = new ArrayList<Issue>(severities.keySet()); Collections.sort(sortedKeys); StringBuilder sb = new StringBuilder(severities.size() * 20); for (Issue issue : sortedKeys) { Severity severity = severities.get(issue); if (severity != issue.getDefaultSeverity()) { if (sb.length() > 0) { sb.append(','); } sb.append(issue.getId()); sb.append('='); sb.append(severity.name()); } } if (sb.length() > 0) { store.setValue(AdtPrefs.PREFS_LINT_SEVERITIES, sb.toString()); } else { store.setToDefault(AdtPrefs.PREFS_LINT_SEVERITIES); } }