List of usage examples for org.eclipse.jface.preference IPreferenceStore setValue
void setValue(String name, boolean value);
From source file:com.amalto.workbench.preferences.SSLPreferences.java
License:Open Source License
@Override public boolean performOk() { IPreferenceStore store = getPreferenceStore(); String algorithm = sslAlgorithmCombo.getText(); String keypath = keyPath.getText(); String keypass = keyPassword.getText(); String keytype = keyType.getText(); String trustpath = trustPath.getText(); String trustpass = trustPassword.getText(); String trusttype = trustType.getText(); try {/*from w w w . j a v a2 s. c o m*/ SSLContextProvider.buildContext(algorithm, keypath, keypass, keytype, trustpath, trustpass, trusttype); store.setValue(PreferenceConstants.SSL_Algorithm, algorithm); store.setValue(PreferenceConstants.VERIFY_HOSTNAME, verificationType[1].getSelection()); store.setValue(PreferenceConstants.KEYSTORE_FILE, keypath); store.setValue(PreferenceConstants.KEYSTORE_PASSWORD, encryptPasswd(keypass)); store.setValue(PreferenceConstants.KEYSTORE_TYPE, keytype); store.setValue(PreferenceConstants.TRUSTSTORE_FILE, trustpath); store.setValue(PreferenceConstants.TRUSTSTORE_PASSWORD, encryptPasswd(trustpass)); store.setValue(PreferenceConstants.TRUSTSTORE_TYPE, trusttype); setErrorMessage(null); return super.performOk(); } catch (Exception e) { setErrorMessage(e.getMessage()); log.error(e.getMessage(), e); return false; } }
From source file:com.amazonaws.eclipse.core.mobileanalytics.context.ClientContextConfig.java
License:Apache License
private static String _getOrGenerateClientId() { IPreferenceStore store = AwsToolkitCore.getDefault().getPreferenceStore(); String clientId = store.getString(MOBILE_ANALYTICS_CLIENT_ID_PREF_STORE_KEY); if (clientId != null && !clientId.isEmpty()) { return clientId; }/*from w ww. java 2 s . c o m*/ // Generate a GUID as the client id and persist it in the preference store String newClientId = UUID.randomUUID().toString(); store.setValue(MOBILE_ANALYTICS_CLIENT_ID_PREF_STORE_KEY, newClientId); return newClientId; }
From source file:com.amazonaws.eclipse.core.preferences.PreferenceInitializer.java
License:Apache License
/** * Imports the AWS account preferences from the Amazon EC2 Eclipse plugin * and stores them in the AWS Toolkit Core's preference store. This is * necessary for backwards compatibility, so that users who already * installed and configured the Amazon EC2 Eclipse plugin don't lose their * AWS account information once the AWS Toolkit Core plugin is installed. *///from w w w . j a v a 2s . c o m private void importEc2AccountPreferences() { IPreferenceStore awsToolkitPreferenceStore = getAwsToolkitCorePreferenceStore(); /* * If the EC2 plugin preferences have already been imported, we don't * want to overwrite anything, so just bail out. */ if (awsToolkitPreferenceStore.getBoolean(PreferenceConstants.P_EC2_PREFERENCES_IMPORTED)) { return; } IPreferenceStore ec2PluginPreferenceStore = getEc2PluginPreferenceStore(); for (String preferenceToImport : preferencesToImport) { String value = ec2PluginPreferenceStore.getString(preferenceToImport); awsToolkitPreferenceStore.setValue(preferenceToImport, value); } /* * Record that we imported the pre-existing EC2 plugin preferences so * that we know not to re-import them next time. */ awsToolkitPreferenceStore.setValue(PreferenceConstants.P_EC2_PREFERENCES_IMPORTED, true); }
From source file:com.amazonaws.eclipse.core.preferences.PreferenceInitializerTest.java
License:Apache License
/** * If the EC2 plugin preferences have already been imported, we expect them * to not be imported again./*from www.j a va 2 s . c o m*/ */ @Test public void testOnlyImportOnce() { MockPreferenceInitializer preferenceInitializer = new MockPreferenceInitializer(); IPreferenceStore preferenceStore = preferenceInitializer.getAwsToolkitCorePreferenceStore(); preferenceStore.setValue(PreferenceConstants.P_EC2_PREFERENCES_IMPORTED, true); assertEquals("", preferenceStore.getString(PreferenceConstants.P_ACCESS_KEY)); preferenceInitializer.initializeDefaultPreferences(); assertEquals("", preferenceStore.getString(PreferenceConstants.P_ACCESS_KEY)); }
From source file:com.amazonaws.eclipse.lambda.project.wizard.NewLambdaJavaFunctionProjectWizard.java
License:Open Source License
private static void savePreferences(NewLambdaJavaFunctionProjectWizardDataModel dataModel, IPreferenceStore prefStore) { prefStore.setValue(LambdaPlugin.PREF_K_SHOW_README_AFTER_CREATE_NEW_PROJECT, dataModel.isShowReadmeFile()); }
From source file:com.android.ddms.DebugPortProvider.java
License:Apache License
/** * Sets new [device, app, port] values.//ww w .ja v a 2s. com * The values are also sync'ed in the preference store. * @param map The map containing the new values. */ public void setPortList(Map<String, Map<String, Integer>> map) { // update the member map. mMap.clear(); mMap.putAll(map); // create the value to store in the preference store. // see format definition in getPortList StringBuilder sb = new StringBuilder(); Set<String> deviceKeys = map.keySet(); for (String deviceKey : deviceKeys) { Map<String, Integer> deviceMap = map.get(deviceKey); if (deviceMap != null) { Set<String> appKeys = deviceMap.keySet(); for (String appKey : appKeys) { Integer port = deviceMap.get(appKey); if (port != null) { sb.append(appKey).append(':').append(port.intValue()).append(':').append(deviceKey) .append('|'); } } } } String value = sb.toString(); // get the prefs store. IPreferenceStore store = PrefsDialog.getStore(); // and give it the new value. store.setValue(PREFS_STATIC_PORT_LIST, value); }
From source file:com.android.ddmuilib.AllocationPanel.java
License:Apache License
/** * Create our control(s)./* w w w. j av a 2 s. co m*/ */ @Override protected Control createControl(Composite parent) { final IPreferenceStore store = DdmUiPreferences.getStore(); Display display = parent.getDisplay(); // get some images mSortUpImg = ImageLoader.getDdmUiLibLoader().loadImage("sort_up.png", display); mSortDownImg = ImageLoader.getDdmUiLibLoader().loadImage("sort_down.png", display); // base composite for selected client with enabled thread update. mAllocationBase = new Composite(parent, SWT.NONE); mAllocationBase.setLayout(new FormLayout()); // table above the sash Composite topParent = new Composite(mAllocationBase, SWT.NONE); topParent.setLayout(new GridLayout(6, false)); mEnableButton = new Button(topParent, SWT.PUSH); mEnableButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { Client current = getCurrentClient(); AllocationTrackingStatus status = current.getClientData().getAllocationStatus(); if (status == AllocationTrackingStatus.ON) { current.enableAllocationTracker(false); } else { current.enableAllocationTracker(true); } current.requestAllocationStatus(); } }); mRequestButton = new Button(topParent, SWT.PUSH); mRequestButton.setText("Get Allocations"); mRequestButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { getCurrentClient().requestAllocationDetails(); } }); setUpButtons(false /* enabled */, AllocationTrackingStatus.OFF); GridData gridData; Composite spacer = new Composite(topParent, SWT.NONE); spacer.setLayoutData(gridData = new GridData(GridData.FILL_HORIZONTAL)); new Label(topParent, SWT.NONE).setText("Filter:"); final Text filterText = new Text(topParent, SWT.BORDER); filterText.setLayoutData(gridData = new GridData(GridData.FILL_HORIZONTAL)); gridData.widthHint = 200; filterText.addModifyListener(new ModifyListener() { @Override public void modifyText(ModifyEvent arg0) { mFilterText = filterText.getText().trim(); mAllocationViewer.refresh(); } }); mTraceFilterCheck = new Button(topParent, SWT.CHECK); mTraceFilterCheck.setText("Inc. trace"); mTraceFilterCheck.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent arg0) { mAllocationViewer.refresh(); } }); mAllocationTable = new Table(topParent, SWT.MULTI | SWT.FULL_SELECTION); mAllocationTable.setLayoutData(gridData = new GridData(GridData.FILL_BOTH)); gridData.horizontalSpan = 6; mAllocationTable.setHeaderVisible(true); mAllocationTable.setLinesVisible(true); final TableColumn numberCol = TableHelper.createTableColumn(mAllocationTable, "Alloc Order", SWT.RIGHT, "Alloc Order", //$NON-NLS-1$ PREFS_ALLOC_COL_NUMBER, store); numberCol.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent arg0) { setSortColumn(numberCol, SortMode.NUMBER); } }); final TableColumn sizeCol = TableHelper.createTableColumn(mAllocationTable, "Allocation Size", SWT.RIGHT, "888", //$NON-NLS-1$ PREFS_ALLOC_COL_SIZE, store); sizeCol.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent arg0) { setSortColumn(sizeCol, SortMode.SIZE); } }); final TableColumn classCol = TableHelper.createTableColumn(mAllocationTable, "Allocated Class", SWT.LEFT, "Allocated Class", //$NON-NLS-1$ PREFS_ALLOC_COL_CLASS, store); classCol.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent arg0) { setSortColumn(classCol, SortMode.CLASS); } }); final TableColumn threadCol = TableHelper.createTableColumn(mAllocationTable, "Thread Id", SWT.LEFT, "999", //$NON-NLS-2$ PREFS_ALLOC_COL_THREAD, store); threadCol.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent arg0) { setSortColumn(threadCol, SortMode.THREAD); } }); final TableColumn inClassCol = TableHelper.createTableColumn(mAllocationTable, "Allocated in", SWT.LEFT, "utime", //$NON-NLS-1$ PREFS_ALLOC_COL_TRACE_CLASS, store); inClassCol.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent arg0) { setSortColumn(inClassCol, SortMode.IN_CLASS); } }); final TableColumn inMethodCol = TableHelper.createTableColumn(mAllocationTable, "Allocated in", SWT.LEFT, "utime", //$NON-NLS-1$ PREFS_ALLOC_COL_TRACE_METHOD, store); inMethodCol.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent arg0) { setSortColumn(inMethodCol, SortMode.IN_METHOD); } }); // init the default sort colum switch (mSorter.getSortMode()) { case SIZE: mSortColumn = sizeCol; break; case CLASS: mSortColumn = classCol; break; case THREAD: mSortColumn = threadCol; break; case IN_CLASS: mSortColumn = inClassCol; break; case IN_METHOD: mSortColumn = inMethodCol; break; } mSortColumn.setImage(mSorter.isDescending() ? mSortDownImg : mSortUpImg); mAllocationViewer = new TableViewer(mAllocationTable); mAllocationViewer.setContentProvider(new AllocationContentProvider()); mAllocationViewer.setLabelProvider(new AllocationLabelProvider()); mAllocationViewer.addSelectionChangedListener(new ISelectionChangedListener() { @Override public void selectionChanged(SelectionChangedEvent event) { AllocationInfo selectedAlloc = getAllocationSelection(event.getSelection()); updateAllocationStackTrace(selectedAlloc); } }); // the separating sash final Sash sash = new Sash(mAllocationBase, SWT.HORIZONTAL); Color darkGray = parent.getDisplay().getSystemColor(SWT.COLOR_DARK_GRAY); sash.setBackground(darkGray); // the UI below the sash mStackTracePanel = new StackTracePanel(); mStackTraceTable = mStackTracePanel.createPanel(mAllocationBase, PREFS_STACK_COLUMN, store); // 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); topParent.setLayoutData(data); final FormData sashData = new FormData(); if (store != null && store.contains(PREFS_ALLOC_SASH)) { sashData.top = new FormAttachment(0, store.getInt(PREFS_ALLOC_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); mStackTraceTable.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 = mAllocationBase.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_ALLOC_SASH, e.y); mAllocationBase.layout(); } } }); return mAllocationBase; }
From source file:com.android.ddmuilib.log.event.EventDisplayOptions.java
License:Apache License
private void createLeftPanel(Composite leftPanel) { final IPreferenceStore store = DdmUiPreferences.getStore(); GridLayout gl;/*from ww w . j a va 2 s . co m*/ leftPanel.setLayoutData(new GridData(GridData.FILL_VERTICAL)); leftPanel.setLayout(gl = new GridLayout(1, false)); gl.verticalSpacing = 1; mEventDisplayList = new List(leftPanel, SWT.BORDER | SWT.SINGLE | SWT.V_SCROLL | SWT.FULL_SELECTION); mEventDisplayList.setLayoutData(new GridData(GridData.FILL_BOTH)); mEventDisplayList.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { handleEventDisplaySelection(); } }); Composite bottomControls = new Composite(leftPanel, SWT.NONE); bottomControls.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); bottomControls.setLayout(gl = new GridLayout(5, false)); gl.marginHeight = gl.marginWidth = 0; gl.verticalSpacing = 0; gl.horizontalSpacing = 0; ImageLoader loader = ImageLoader.getDdmUiLibLoader(); mEventDisplayNewButton = new Button(bottomControls, SWT.PUSH | SWT.FLAT); mEventDisplayNewButton.setImage(loader.loadImage("add.png", //$NON-NLS-1$ leftPanel.getDisplay())); mEventDisplayNewButton.setToolTipText("Adds a new event display"); mEventDisplayNewButton.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_CENTER)); mEventDisplayNewButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { createNewEventDisplay(); } }); mEventDisplayDeleteButton = new Button(bottomControls, SWT.PUSH | SWT.FLAT); mEventDisplayDeleteButton.setImage(loader.loadImage("delete.png", //$NON-NLS-1$ leftPanel.getDisplay())); mEventDisplayDeleteButton.setToolTipText("Deletes the selected event display"); mEventDisplayDeleteButton.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_CENTER)); mEventDisplayDeleteButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { deleteEventDisplay(); } }); mEventDisplayUpButton = new Button(bottomControls, SWT.PUSH | SWT.FLAT); mEventDisplayUpButton.setImage(loader.loadImage("up.png", //$NON-NLS-1$ leftPanel.getDisplay())); mEventDisplayUpButton.setToolTipText("Moves the selected event display up"); mEventDisplayUpButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { // get current selection. int selection = mEventDisplayList.getSelectionIndex(); if (selection > 0) { // update the list of EventDisplay. EventDisplay display = mDisplayList.remove(selection); mDisplayList.add(selection - 1, display); // update the list widget mEventDisplayList.remove(selection); mEventDisplayList.add(display.getName(), selection - 1); // update the selection and reset the ui. mEventDisplayList.select(selection - 1); handleEventDisplaySelection(); mEventDisplayList.showSelection(); setModified(); } } }); mEventDisplayDownButton = new Button(bottomControls, SWT.PUSH | SWT.FLAT); mEventDisplayDownButton.setImage(loader.loadImage("down.png", //$NON-NLS-1$ leftPanel.getDisplay())); mEventDisplayDownButton.setToolTipText("Moves the selected event display down"); mEventDisplayDownButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { // get current selection. int selection = mEventDisplayList.getSelectionIndex(); if (selection != -1 && selection < mEventDisplayList.getItemCount() - 1) { // update the list of EventDisplay. EventDisplay display = mDisplayList.remove(selection); mDisplayList.add(selection + 1, display); // update the list widget mEventDisplayList.remove(selection); mEventDisplayList.add(display.getName(), selection + 1); // update the selection and reset the ui. mEventDisplayList.select(selection + 1); handleEventDisplaySelection(); mEventDisplayList.showSelection(); setModified(); } } }); Group sizeGroup = new Group(leftPanel, SWT.NONE); sizeGroup.setText("Display Size:"); sizeGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); sizeGroup.setLayout(new GridLayout(2, false)); Label l = new Label(sizeGroup, SWT.NONE); l.setText("Width:"); mDisplayWidthText = new Text(sizeGroup, SWT.LEFT | SWT.SINGLE | SWT.BORDER); mDisplayWidthText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); mDisplayWidthText.setText(Integer.toString(store.getInt(EventLogPanel.PREFS_DISPLAY_WIDTH))); mDisplayWidthText.addModifyListener(new ModifyListener() { @Override public void modifyText(ModifyEvent e) { String text = mDisplayWidthText.getText().trim(); try { store.setValue(EventLogPanel.PREFS_DISPLAY_WIDTH, Integer.parseInt(text)); setModified(); } catch (NumberFormatException nfe) { // do something? } } }); l = new Label(sizeGroup, SWT.NONE); l.setText("Height:"); mDisplayHeightText = new Text(sizeGroup, SWT.LEFT | SWT.SINGLE | SWT.BORDER); mDisplayHeightText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); mDisplayHeightText.setText(Integer.toString(store.getInt(EventLogPanel.PREFS_DISPLAY_HEIGHT))); mDisplayHeightText.addModifyListener(new ModifyListener() { @Override public void modifyText(ModifyEvent e) { String text = mDisplayHeightText.getText().trim(); try { store.setValue(EventLogPanel.PREFS_DISPLAY_HEIGHT, Integer.parseInt(text)); setModified(); } catch (NumberFormatException nfe) { // do something? } } }); }
From source file:com.android.ddmuilib.log.event.EventLogPanel.java
License:Apache License
/** * Saves the {@link EventDisplay}s into the {@link DdmUiPreferences} store. */// www .j a v a 2 s .c om private void saveEventDisplays() { IPreferenceStore store = DdmUiPreferences.getStore(); boolean first = true; StringBuilder sb = new StringBuilder(); for (EventDisplay eventDisplay : mEventDisplays) { String storage = eventDisplay.getStorageString(); if (storage != null) { if (first == false) { sb.append(EVENT_DISPLAY_STORAGE_SEPARATOR); } else { first = false; } sb.append(storage); } } store.setValue(PREFS_EVENT_DISPLAY, sb.toString()); }
From source file:com.android.ddmuilib.NativeHeapPanel.java
License:Apache License
/** * Create the Table display. This includes a "detail" Table in the bottom * half and 2 modes in the top half: allocation Table and * library+allocations Tables./*w w w . j a va2s. co m*/ * * @param base the top parent to create the display into */ private void createTableDisplay(Composite base) { final int minPanelWidth = 60; final IPreferenceStore prefs = DdmUiPreferences.getStore(); // top level composite for mode 1 & 2 mTableModeControl = new Composite(base, SWT.NONE); GridLayout gl = new GridLayout(1, false); gl.marginLeft = gl.marginRight = gl.marginTop = gl.marginBottom = 0; mTableModeControl.setLayout(gl); mTableModeControl.setLayoutData(new GridData(GridData.FILL_BOTH)); mTotalMemoryLabel = new Label(mTableModeControl, SWT.NONE); mTotalMemoryLabel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); mTotalMemoryLabel.setText("Total Memory: 0 Bytes"); // the top half of these modes is dynamic final Composite sash_composite = new Composite(mTableModeControl, SWT.NONE); sash_composite.setLayout(new FormLayout()); sash_composite.setLayoutData(new GridData(GridData.FILL_BOTH)); // create the stacked composite mAllocationStackComposite = new Composite(sash_composite, SWT.NONE); mAllocationStackLayout = new StackLayout(); mAllocationStackComposite.setLayout(mAllocationStackLayout); mAllocationStackComposite.setLayoutData(new GridData(GridData.FILL_BOTH)); // create the top half for mode 1 createAllocationTopHalf(mAllocationStackComposite); // create the top half for mode 2 createLibraryTopHalf(mAllocationStackComposite); final Sash sash = new Sash(sash_composite, SWT.HORIZONTAL); // bottom half of these modes is the same: detail table createDetailTable(sash_composite); // init value for stack mAllocationStackLayout.topControl = mAllocationModeTop; // form layout data FormData data = new FormData(); data.top = new FormAttachment(mTotalMemoryLabel, 0); data.bottom = new FormAttachment(sash, 0); data.left = new FormAttachment(0, 0); data.right = new FormAttachment(100, 0); mAllocationStackComposite.setLayoutData(data); final FormData sashData = new FormData(); if (prefs != null && prefs.contains(PREFS_ALLOCATION_SASH)) { sashData.top = new FormAttachment(0, prefs.getInt(PREFS_ALLOCATION_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); mDetailTable.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 = sash_composite.getClientArea(); int bottom = panelRect.height - sashRect.height - minPanelWidth; e.y = Math.max(Math.min(e.y, bottom), minPanelWidth); if (e.y != sashRect.y) { sashData.top = new FormAttachment(0, e.y); prefs.setValue(PREFS_ALLOCATION_SASH, e.y); sash_composite.layout(); } } }); }