ISecurePreferences root = org.eclipse.equinox.security.storage.SecurePreferencesFactory.getDefault(); if (root == null) return null; ISecurePreferences node = root.node("/your.class.path.or.something.else"); // get the node for your application e.g. this.getClass().getCanonicalName() node = node.node( "some name"); // get custom node from the tree node.get( "key" ); // load node.put("key","value", true / false (encrypt) ); // store (no save operation) node.remove("key"); // remove node.flush(); // save
private void saveProxyAuth(IProxyData data) { ISecurePreferences node= getNode(); if (node == null) return; try { if (data.getUserId() != null) node.put(INFO_PROXY_USER, data.getUserId(), true /* store encrypted */); else node.remove(INFO_PROXY_USER); if (data.getPassword() != null) node.put(INFO_PROXY_PASS, data.getPassword(), true /* store encrypted */); else node.remove(INFO_PROXY_PASS); } catch (StorageException e) { Activator.logError(e.getMessage(), e); return; } // optional: save it right away in case something crashes later try { node.flush(); } catch (IOException e) { Activator.logError(e.getMessage(), e); return; } }
public void run() { if (selectedNode == null) return; StructuredSelection selection = (StructuredSelection) tableViewer.getSelection(); Object selected = selection.getFirstElement(); if (!(selected instanceof TableValuesElement)) return; TableValuesElement node = (TableValuesElement) selected; String key = node.getKey(); // "Are you sure?" dialog MessageBox dialog = new MessageBox(shell, SWT.ICON_WARNING | SWT.YES | SWT.NO); dialog.setText(SecUIMessages.removeValueTitle); String msg = NLS.bind(SecUIMessages.removeValueMsg, key); dialog.setMessage(msg); if (dialog.open() != SWT.YES) return; selectedNode.remove(key); parentView.modified(); tableViewer.refresh(); } };
public void run() { if (selectedNode == null) return; StructuredSelection selection = (StructuredSelection) tableViewer.getSelection(); Object selected = selection.getFirstElement(); if (!(selected instanceof TableValuesElement)) return; TableValuesElement node = (TableValuesElement) selected; String key = node.getKey(); // "Are you sure?" dialog MessageBox dialog = new MessageBox(shell, SWT.ICON_WARNING | SWT.YES | SWT.NO); dialog.setText(SecUIMessages.removeValueTitle); String msg = NLS.bind(SecUIMessages.removeValueMsg, key); dialog.setMessage(msg); if (dialog.open() != SWT.YES) return; selectedNode.remove(key); parentView.modified(); tableViewer.refresh(); } };