Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 96897 Details for
Bug 227428
Move secure storage view into the preference page
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
Patch
patch secure storage View Move.txt (text/plain), 33.84 KB, created by
Oleg Besedin
on 2008-04-21 13:45:20 EDT
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Oleg Besedin
Created:
2008-04-21 13:45:20 EDT
Size:
33.84 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.equinox.security.ui >Index: src/org/eclipse/equinox/internal/security/ui/storage/view/ValuesView.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.equinox/security/bundles/org.eclipse.equinox.security.ui/src/org/eclipse/equinox/internal/security/ui/storage/view/ValuesView.java,v >retrieving revision 1.5 >diff -u -r1.5 ValuesView.java >--- src/org/eclipse/equinox/internal/security/ui/storage/view/ValuesView.java 14 Apr 2008 21:10:12 -0000 1.5 >+++ src/org/eclipse/equinox/internal/security/ui/storage/view/ValuesView.java 21 Apr 2008 17:43:01 -0000 >@@ -35,7 +35,7 @@ > */ > private final static String ENCRYPTED_SUBSTITUTE = "**********"; //$NON-NLS-1$ > >- protected SecurePreferencesView parentView; >+ protected ISecurePreferencesSelection parentView; > protected TableViewer tableViewer; > > protected ISecurePreferences selectedNode = null; >@@ -146,7 +146,7 @@ > // using default implementation for now > } > >- public ValuesView(Table table, final SecurePreferencesView parentView, Shell shell) { >+ public ValuesView(Table table, final ISecurePreferencesSelection parentView, Shell shell) { > this.parentView = parentView; > this.shell = shell; > >@@ -166,8 +166,10 @@ > tableViewer.setLabelProvider(new TableLabelProvider()); > tableViewer.setSorter(new TableNameSorter()); > >- makeActions(); >- hookContextMenu(); >+ if (Activator.getDefault().debugStorageContents()) { >+ makeActions(); >+ hookContextMenu(); >+ } > } > > private void hookContextMenu() { >@@ -200,7 +202,6 @@ > }); > Menu menu = menuMgr.createContextMenu(tableViewer.getControl()); > tableViewer.getControl().setMenu(menu); >- parentView.getSite().registerContextMenu(menuMgr, tableViewer); > > // fill context menu > menuMgr.add(addValueAction); >Index: src/org/eclipse/equinox/internal/security/ui/storage/view/NodesView.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.equinox/security/bundles/org.eclipse.equinox.security.ui/src/org/eclipse/equinox/internal/security/ui/storage/view/NodesView.java,v >retrieving revision 1.3 >diff -u -r1.3 NodesView.java >--- src/org/eclipse/equinox/internal/security/ui/storage/view/NodesView.java 14 Apr 2008 21:10:12 -0000 1.3 >+++ src/org/eclipse/equinox/internal/security/ui/storage/view/NodesView.java 21 Apr 2008 17:43:01 -0000 >@@ -10,6 +10,7 @@ > *******************************************************************************/ > package org.eclipse.equinox.internal.security.ui.storage.view; > >+import org.eclipse.equinox.internal.security.ui.Activator; > import org.eclipse.equinox.internal.security.ui.nls.SecUIMessages; > import org.eclipse.equinox.internal.security.ui.storage.IStorageConst; > import org.eclipse.equinox.security.storage.ISecurePreferences; >@@ -34,7 +35,7 @@ > */ > final private static String defaultPrefs = "default"; //$NON-NLS-1$ > >- protected SecurePreferencesView parentView; >+ protected ISecurePreferencesSelection parentView; > protected TreeViewer nodeTreeViewer; > > protected ViewContentProvider contentProvider; >@@ -108,7 +109,7 @@ > } > } > >- public NodesView(Tree nodeTree, final SecurePreferencesView parentView) { >+ public NodesView(Tree nodeTree, final ISecurePreferencesSelection parentView) { > this.parentView = parentView; > > nodeTreeViewer = new TreeViewer(nodeTree); >@@ -129,8 +130,10 @@ > } > }); > >- makeActions(); >- hookContextMenu(); >+ if (Activator.getDefault().debugStorageContents()) { >+ makeActions(); >+ hookContextMenu(); >+ } > } > > private void hookContextMenu() { >@@ -155,7 +158,6 @@ > }); > Menu menu = menuMgr.createContextMenu(nodeTreeViewer.getControl()); > nodeTreeViewer.getControl().setMenu(menu); >- parentView.getSite().registerContextMenu(menuMgr, nodeTreeViewer); > > // fill context menu > menuMgr.add(refreshNodesAction); >Index: src/org/eclipse/equinox/internal/security/ui/storage/view/SecurePreferencesView.java >=================================================================== >RCS file: src/org/eclipse/equinox/internal/security/ui/storage/view/SecurePreferencesView.java >diff -N src/org/eclipse/equinox/internal/security/ui/storage/view/SecurePreferencesView.java >--- src/org/eclipse/equinox/internal/security/ui/storage/view/SecurePreferencesView.java 14 Apr 2008 21:10:12 -0000 1.4 >+++ /dev/null 1 Jan 1970 00:00:00 -0000 >@@ -1,165 +0,0 @@ >-/******************************************************************************* >- * Copyright (c) 2008 IBM Corporation and others. >- * All rights reserved. This program and the accompanying materials >- * are made available under the terms of the Eclipse Public License v1.0 >- * which accompanies this distribution, and is available at >- * http://www.eclipse.org/legal/epl-v10.html >- * >- * Contributors: >- * IBM Corporation - initial API and implementation >- *******************************************************************************/ >-package org.eclipse.equinox.internal.security.ui.storage.view; >- >-import java.io.*; >-import org.eclipse.core.runtime.IStatus; >-import org.eclipse.equinox.internal.security.storage.friends.IDeleteListener; >-import org.eclipse.equinox.internal.security.storage.friends.InternalExchangeUtils; >-import org.eclipse.equinox.internal.security.ui.Activator; >-import org.eclipse.equinox.internal.security.ui.nls.SecUIMessages; >-import org.eclipse.equinox.internal.security.ui.storage.IStorageConst; >-import org.eclipse.equinox.security.storage.*; >-import org.eclipse.jface.action.*; >-import org.eclipse.jface.resource.ImageDescriptor; >-import org.eclipse.swt.SWT; >-import org.eclipse.swt.custom.SashForm; >-import org.eclipse.swt.layout.GridData; >-import org.eclipse.swt.layout.GridLayout; >-import org.eclipse.swt.widgets.*; >-import org.eclipse.ui.IActionBars; >-import org.eclipse.ui.part.ViewPart; >- >-public class SecurePreferencesView extends ViewPart implements IDeleteListener { >- >- protected NodesView nodesView = null; >- protected ValuesView valuesView = null; >- >- protected Action saveAction; >- protected Action exportAction; >- private Shell shell; >- >- public void setSelection(ISecurePreferences selectedNode) { >- valuesView.setInput(selectedNode); >- } >- >- public SecurePreferencesView() { >- // nothing to do >- } >- >- public void createPartControl(Composite parent) { >- shell = parent.getShell(); >- >- SashForm sashForm = new SashForm(parent, SWT.HORIZONTAL); >- sashForm.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, true)); >- >- Tree nodeTree = new Tree(sashForm, SWT.SINGLE | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER); >- GridData gridData = new GridData(GridData.FILL, GridData.FILL, true, true); >- gridData.verticalSpan = 2; >- nodeTree.setLayoutData(gridData); >- >- Composite rightPane = new Composite(sashForm, SWT.NONE); >- rightPane.setLayout(new GridLayout()); >- >- new Label(rightPane, SWT.NONE).setText(SecUIMessages.keysTable); >- >- Table tableOfValues = new Table(rightPane, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER); >- tableOfValues.setLinesVisible(true); >- tableOfValues.setHeaderVisible(true); >- tableOfValues.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, true)); >- >- nodesView = new NodesView(nodeTree, this); >- valuesView = new ValuesView(tableOfValues, this, shell); >- >- makeActions(); >- >- // add pull down menu >- IActionBars bars = getViewSite().getActionBars(); >- IMenuManager manager = bars.getMenuManager(); >- manager.add(saveAction); >- manager.add(new Separator()); >- manager.add(exportAction); >- >- InternalExchangeUtils.addDeleteListener(this); >- } >- >- /** >- * Passing the focus request to the viewer's control. >- */ >- public void setFocus() { >- nodesView.setFocus(); >- } >- >- private void makeActions() { >- saveAction = new Action() { >- public void run() { >- ISecurePreferences root = SecurePreferencesFactory.getDefault(); >- try { >- root.flush(); >- } catch (IOException e) { >- Activator.log(IStatus.ERROR, e.getMessage(), null, e); >- } >- } >- }; >- saveAction.setText(SecUIMessages.saveCommand); >- saveAction.setToolTipText(SecUIMessages.saveCommandTip); >- saveAction.setImageDescriptor(ImageDescriptor.createFromFile(SecurePreferencesView.class, "/icons/storage/save.gif")); //$NON-NLS-1$ >- >- exportAction = new Action() { >- public void run() { >- export(); >- } >- }; >- exportAction.setText(SecUIMessages.exportCommand); >- exportAction.setToolTipText(SecUIMessages.exportCommandTip); >- exportAction.setImageDescriptor(ImageDescriptor.createFromFile(SecurePreferencesView.class, "/icons/storage/export_secure.gif")); //$NON-NLS-1$ >- } >- >- protected void export() { >- ISecurePreferences root = SecurePreferencesFactory.getDefault(); >- if (root == null) >- return; >- ExportDialog dialog = new ExportDialog(shell); >- dialog.open(); >- String fileName = dialog.getFileName(); >- if (fileName == null) >- return; >- File outputFile = new File(fileName); >- >- PrintStream output; >- try { >- output = new PrintStream(new FileOutputStream(outputFile)); >- } catch (FileNotFoundException e) { >- Activator.log(IStatus.ERROR, e.getMessage(), null, e); >- return; >- } >- export(root, output); >- output.flush(); >- output.close(); >- } >- >- protected void export(ISecurePreferences node, PrintStream stream) { >- if (IStorageConst.PROVIDER_NODE.equals(node.absolutePath())) >- return; // skip internal node >- String[] keys = node.keys(); >- if (keys.length > 0) { >- String header = '[' + node.absolutePath() + ']'; >- stream.println(header); >- for (int i = 0; i < keys.length; i++) { >- try { >- String data = keys[i] + " := " + node.get(keys[i], ""); //$NON-NLS-1$ //$NON-NLS-2$ >- stream.println(data); >- } catch (StorageException e) { >- Activator.log(IStatus.ERROR, SecUIMessages.failedDecrypt, null, e); >- } >- } >- } >- String[] children = node.childrenNames(); >- for (int i = 0; i < children.length; i++) { >- export(node.node(children[i]), stream); >- } >- } >- >- public void onDeleted() { >- if (nodesView != null) >- nodesView.postDeleted(); >- } >-} >Index: src/org/eclipse/equinox/internal/security/ui/Activator.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.equinox/security/bundles/org.eclipse.equinox.security.ui/src/org/eclipse/equinox/internal/security/ui/Activator.java,v >retrieving revision 1.4 >diff -u -r1.4 Activator.java >--- src/org/eclipse/equinox/internal/security/ui/Activator.java 2 Apr 2008 19:57:33 -0000 1.4 >+++ src/org/eclipse/equinox/internal/security/ui/Activator.java 21 Apr 2008 17:43:01 -0000 >@@ -18,6 +18,7 @@ > import org.eclipse.equinox.internal.provisional.security.ui.AuthorizationManager; > import org.eclipse.jface.resource.ImageDescriptor; > import org.eclipse.osgi.internal.provisional.service.security.AuthorizationEngine; >+import org.eclipse.osgi.service.debug.DebugOptions; > import org.eclipse.osgi.service.resolver.PlatformAdmin; > import org.eclipse.osgi.service.security.TrustEngine; > import org.eclipse.osgi.util.NLS; >@@ -43,6 +44,7 @@ > private static ServiceTracker authzEngineTracker; > private static ServiceTracker authzManagerTracker; > private static ServiceTracker platformAdminTracker; >+ private static ServiceTracker debugTracker; > > // The shared plug-in instance > private static Activator plugin; >@@ -51,6 +53,10 @@ > private static BundleContext bundleContext; > private ServiceRegistration defaultAuthzManagerReg; > >+ // debug tracing >+ private static final String OPTION_DEBUG = "org.eclipse.equinox.security.ui/debug"; //$NON-NLS-1$; >+ private static final String OPTION_DEBUG_STORAGE = OPTION_DEBUG + "/storage"; //$NON-NLS-1$; >+ > public Activator() { > super(); > } >@@ -109,6 +115,10 @@ > platformAdminTracker.close(); > platformAdminTracker = null; > } >+ if (debugTracker != null) { >+ debugTracker.close(); >+ debugTracker = null; >+ } > } > > public static TrustEngine[] getTrustEngines() { >@@ -204,4 +214,20 @@ > plugin.getLog().log(new Status(severity, getSymbolicName(), IStatus.OK, NLS.bind(key, args), throwable)); > } > >+ public DebugOptions getDebugOptions() { >+ if (debugTracker == null) { >+ debugTracker = new ServiceTracker(bundleContext, DebugOptions.class.getName(), null); >+ debugTracker.open(); >+ } >+ return (DebugOptions) debugTracker.getService(); >+ } >+ >+ public boolean debugStorageContents() { >+ DebugOptions debugOptions = getDebugOptions(); >+ if (debugOptions == null) >+ return false; >+ return debugOptions.getBooleanOption(OPTION_DEBUG, false) && // >+ debugOptions.getBooleanOption(OPTION_DEBUG_STORAGE, false); >+ } >+ > } >Index: plugin.xml >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.equinox/security/bundles/org.eclipse.equinox.security.ui/plugin.xml,v >retrieving revision 1.6 >diff -u -r1.6 plugin.xml >--- plugin.xml 20 Mar 2008 22:42:29 -0000 1.6 >+++ plugin.xml 21 Apr 2008 17:43:01 -0000 >@@ -73,18 +73,6 @@ > </provider> > </extension> > >- <!-- The view of the default secure storage --> >- <extension >- point="org.eclipse.ui.views"> >- <view >- name="%storageView" >- icon="icons/storage/secure_storage.gif" >- category="org.eclipse.ui" >- class="org.eclipse.equinox.internal.security.ui.storage.view.SecurePreferencesView" >- id="org.eclipse.equinox.security.views.storage"> >- </view> >- </extension> >- > <!-- Dependency injection to couple UI and core modules --> > <extension > point="org.eclipse.equinox.security.internalUI"> >Index: plugin.properties >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.equinox/security/bundles/org.eclipse.equinox.security.ui/plugin.properties,v >retrieving revision 1.5 >diff -u -r1.5 plugin.properties >--- plugin.properties 20 Mar 2008 22:42:29 -0000 1.5 >+++ plugin.properties 21 Apr 2008 17:43:01 -0000 >@@ -18,4 +18,3 @@ > certificateFile = Certificate File > certificateFileDescription = Import certificates into the platform. > storage = Secure Storage >-storageView = Secure Storage >Index: src/org/eclipse/equinox/internal/security/ui/nls/SecUIMessages.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.equinox/security/bundles/org.eclipse.equinox.security.ui/src/org/eclipse/equinox/internal/security/ui/nls/SecUIMessages.java,v >retrieving revision 1.13 >diff -u -r1.13 SecUIMessages.java >--- src/org/eclipse/equinox/internal/security/ui/nls/SecUIMessages.java 18 Apr 2008 18:14:44 -0000 1.13 >+++ src/org/eclipse/equinox/internal/security/ui/nls/SecUIMessages.java 21 Apr 2008 17:43:01 -0000 >@@ -61,6 +61,10 @@ > public static String postDeleteMsg; > public static String tabPassword; > public static String tabAdvanced; >+ public static String tabContents; >+ public static String saveButton; >+ public static String exportButton; >+ public static String locationButton; > > // secure storage view > public static String generalTitle; >@@ -87,10 +91,6 @@ > public static String decryptValueCommandTmp; > public static String failedDecrypt; > public static String failedEncrypt; >- public static String saveCommand; >- public static String saveCommandTip; >- public static String exportCommand; >- public static String exportCommandTip; > > // new node dialog > public static String newNodeTitle; >Index: src/org/eclipse/equinox/internal/security/ui/nls/messages.properties >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.equinox/security/bundles/org.eclipse.equinox.security.ui/src/org/eclipse/equinox/internal/security/ui/nls/messages.properties,v >retrieving revision 1.15 >diff -u -r1.15 messages.properties >--- src/org/eclipse/equinox/internal/security/ui/nls/messages.properties 18 Apr 2008 18:59:50 -0000 1.15 >+++ src/org/eclipse/equinox/internal/security/ui/nls/messages.properties 21 Apr 2008 17:43:01 -0000 >@@ -55,10 +55,14 @@ > postDeleteMsg = Storage deleted. It is highly recommended to restart this session. > tabPassword = Password > tabAdvanced = Advanced >+tabContents = Contents >+saveButton = &Save... >+exportButton = &Export... >+locationButton = S&torage location: > > ## Secure storage view > generalTitle = Secure Storage >-rootNodeName = Root >+rootNodeName = Default Secure Storage > keysTable = Values associated with the selected node: > keysColumn = ID > valuesColumn = Value >@@ -81,10 +85,6 @@ > decryptValueCommandTmp = Decrypt selected value > failedDecrypt = Unable to decrypt the specified value. See log for details. > failedEncrypt = Unable to encrypt the specified value. See log for details. >-saveCommand = &Save >-saveCommandTip = Save default preferences >-exportCommand = &Export >-exportCommandTip = Export secure storage in a clear text form > > ## new node dialog > newNodeTitle = Secure Preferences >Index: META-INF/MANIFEST.MF >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.equinox/security/bundles/org.eclipse.equinox.security.ui/META-INF/MANIFEST.MF,v >retrieving revision 1.8 >diff -u -r1.8 MANIFEST.MF >--- META-INF/MANIFEST.MF 18 Apr 2008 18:14:44 -0000 1.8 >+++ META-INF/MANIFEST.MF 21 Apr 2008 17:43:01 -0000 >@@ -13,11 +13,12 @@ > org.eclipse.jface.action, > org.eclipse.osgi.internal.provisional.service.security;version="[1.0.0,2.0.0)", > org.eclipse.osgi.internal.service.security, >- org.eclipse.osgi.service.resolver;version="1.2.0", >- org.eclipse.osgi.service.security;version="1.0.0", >- org.eclipse.osgi.util;version="1.1.0", >+ org.eclipse.osgi.service.debug;version="[1.0.0,2.0.0)", >+ org.eclipse.osgi.service.resolver;version="[1.2.0,2.0.0)", >+ org.eclipse.osgi.service.security;version="[1.0.0,2.0.0)", >+ org.eclipse.osgi.util;version="[1.1.0,2.0.0)", > org.osgi.framework, >- org.osgi.util.tracker;version="1.3.3" >+ org.osgi.util.tracker;version="[1.3.3,2.0.0)" > Require-Bundle: org.eclipse.equinox.security;bundle-version="[1.0.0,2.0.0)", > org.eclipse.equinox.preferences;bundle-version="[3.2.200,4.0.0)", > org.eclipse.ui;bundle-version="[3.4.0,4.0.0)" >Index: src/org/eclipse/equinox/internal/security/ui/storage/TabAdvanced.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.equinox/security/bundles/org.eclipse.equinox.security.ui/src/org/eclipse/equinox/internal/security/ui/storage/TabAdvanced.java,v >retrieving revision 1.3 >diff -u -r1.3 TabAdvanced.java >--- src/org/eclipse/equinox/internal/security/ui/storage/TabAdvanced.java 14 Apr 2008 21:10:13 -0000 1.3 >+++ src/org/eclipse/equinox/internal/security/ui/storage/TabAdvanced.java 21 Apr 2008 17:43:01 -0000 >@@ -10,7 +10,6 @@ > *******************************************************************************/ > package org.eclipse.equinox.internal.security.ui.storage; > >-import java.net.URL; > import java.util.Iterator; > import java.util.Map; > import org.eclipse.core.runtime.preferences.ConfigurationScope; >@@ -18,15 +17,10 @@ > import org.eclipse.equinox.internal.security.storage.friends.IStorageConstants; > import org.eclipse.equinox.internal.security.storage.friends.InternalExchangeUtils; > import org.eclipse.equinox.internal.security.ui.nls.SecUIMessages; >-import org.eclipse.equinox.security.storage.ISecurePreferences; >-import org.eclipse.equinox.security.storage.SecurePreferencesFactory; > import org.eclipse.jface.layout.GridLayoutFactory; > import org.eclipse.jface.layout.LayoutConstants; > import org.eclipse.swt.SWT; >-import org.eclipse.swt.events.SelectionEvent; >-import org.eclipse.swt.events.SelectionListener; > import org.eclipse.swt.layout.GridData; >-import org.eclipse.swt.layout.GridLayout; > import org.eclipse.swt.widgets.*; > import org.osgi.service.prefs.BackingStoreException; > >@@ -39,10 +33,8 @@ > > private IEclipsePreferences eclipseNode = null; > private String defaultCipherAlgorithm; >- private Shell shell; > > public TabAdvanced(TabFolder folder, int index, final Shell shell) { >- this.shell = shell; > > TabItem tab = new TabItem(folder, SWT.NONE, index); > tab.setText(SecUIMessages.tabAdvanced); >@@ -71,54 +63,9 @@ > position++; > } > >- // Default preferences group >- Group defaultPrefsGroup = new Group(page, SWT.NONE); >- defaultPrefsGroup.setText(SecUIMessages.defaultGroup); >- defaultPrefsGroup.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, false)); >- defaultPrefsGroup.setLayout(new GridLayout()); >- >- Button buttonDetele = new Button(defaultPrefsGroup, SWT.NONE); >- buttonDetele.setText(SecUIMessages.deleteButton); >- buttonDetele.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, false, false)); >- buttonDetele.addSelectionListener(new SelectionListener() { >- >- public void widgetDefaultSelected(SelectionEvent e) { >- widgetSelected(e); >- } >- >- public void widgetSelected(SelectionEvent e) { >- deteleDefaultStorage(); >- } >- }); >- > GridLayoutFactory.fillDefaults().margins(LayoutConstants.getMargins()).numColumns(1).generateLayout(page); > } > >- protected void deteleDefaultStorage() { >- URL location = InternalExchangeUtils.defaultStorageLocation(); >- if (location == null) >- return; >- MessageBox messageBox = new MessageBox(shell, SWT.YES | SWT.NO); >- messageBox.setText(location.getFile().toString()); >- messageBox.setMessage(SecUIMessages.confirmDeleteMsg); >- if (messageBox.open() != SWT.YES) >- return; >- >- // clear the data structure itself in case somebody holds on to it >- ISecurePreferences defaultStorage = SecurePreferencesFactory.getDefault(); >- defaultStorage.clear(); >- defaultStorage.removeNode(); >- >- // clear it from the list of open storages, delete the file >- InternalExchangeUtils.defaultStorageDelete(); >- >- // suggest restart in case somebody holds on to the deleted storage >- MessageBox postDeletionBox = new MessageBox(shell, SWT.OK); >- postDeletionBox.setText(SecUIMessages.postDeleteTitle); >- postDeletionBox.setMessage(SecUIMessages.postDeleteMsg); >- postDeletionBox.open(); >- } >- > public void performDefaults() { > for (int i = 0; i < cipherSelector.getItemCount(); i++) { > String item = cipherSelector.getItem(i); >Index: src/org/eclipse/equinox/internal/security/ui/storage/StoragePreferencePage.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.equinox/security/bundles/org.eclipse.equinox.security.ui/src/org/eclipse/equinox/internal/security/ui/storage/StoragePreferencePage.java,v >retrieving revision 1.5 >diff -u -r1.5 StoragePreferencePage.java >--- src/org/eclipse/equinox/internal/security/ui/storage/StoragePreferencePage.java 11 Apr 2008 15:43:09 -0000 1.5 >+++ src/org/eclipse/equinox/internal/security/ui/storage/StoragePreferencePage.java 21 Apr 2008 17:43:01 -0000 >@@ -10,6 +10,7 @@ > *******************************************************************************/ > package org.eclipse.equinox.internal.security.ui.storage; > >+import org.eclipse.jface.dialogs.IDialogConstants; > import org.eclipse.jface.preference.PreferencePage; > import org.eclipse.swt.SWT; > import org.eclipse.swt.layout.GridData; >@@ -21,6 +22,7 @@ > public class StoragePreferencePage extends PreferencePage implements IWorkbenchPreferencePage { > > protected TabPassword passwordTab; >+ protected TabContents contentsTab; > protected TabAdvanced advancedTab; > > public StoragePreferencePage() { >@@ -37,7 +39,8 @@ > > TabFolder folder = new TabFolder(parent, SWT.TOP); > passwordTab = new TabPassword(folder, 0, getShell()); >- advancedTab = new TabAdvanced(folder, 1, getShell()); >+ contentsTab = new TabContents(folder, 1, getShell(), convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH)); >+ advancedTab = new TabAdvanced(folder, 2, getShell()); > folder.setSelection(0); > folder.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); > return folder; >Index: .options >=================================================================== >RCS file: .options >diff -N .options >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ .options 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,5 @@ >+# Debugging options for the org.eclipse.equinox.security.ui plugin >+ >+# Turn on general debugging for the org.eclipse.equinox.common plugin. >+org.eclipse.equinox.security.ui/debug=false >+org.eclipse.equinox.security.ui/debug/storage=false >Index: src/org/eclipse/equinox/internal/security/ui/storage/TabContents.java >=================================================================== >RCS file: src/org/eclipse/equinox/internal/security/ui/storage/TabContents.java >diff -N src/org/eclipse/equinox/internal/security/ui/storage/TabContents.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/equinox/internal/security/ui/storage/TabContents.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,207 @@ >+/******************************************************************************* >+ * Copyright (c) 2008 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.equinox.internal.security.ui.storage; >+ >+import java.io.*; >+import java.net.URL; >+import org.eclipse.core.runtime.IStatus; >+import org.eclipse.equinox.internal.security.storage.friends.IDeleteListener; >+import org.eclipse.equinox.internal.security.storage.friends.InternalExchangeUtils; >+import org.eclipse.equinox.internal.security.ui.Activator; >+import org.eclipse.equinox.internal.security.ui.nls.SecUIMessages; >+import org.eclipse.equinox.internal.security.ui.storage.view.*; >+import org.eclipse.equinox.security.storage.*; >+import org.eclipse.jface.dialogs.Dialog; >+import org.eclipse.jface.layout.GridLayoutFactory; >+import org.eclipse.jface.layout.LayoutConstants; >+import org.eclipse.swt.SWT; >+import org.eclipse.swt.custom.SashForm; >+import org.eclipse.swt.events.SelectionAdapter; >+import org.eclipse.swt.events.SelectionEvent; >+import org.eclipse.swt.graphics.Point; >+import org.eclipse.swt.layout.GridData; >+import org.eclipse.swt.layout.GridLayout; >+import org.eclipse.swt.widgets.*; >+ >+public class TabContents implements ISecurePreferencesSelection, IDeleteListener { >+ >+ private Shell shell; >+ protected NodesView nodesView = null; >+ protected ValuesView valuesView = null; >+ >+ public void setSelection(ISecurePreferences selectedNode) { >+ valuesView.setInput(selectedNode); >+ } >+ >+ public TabContents(TabFolder folder, int index, final Shell shell, int minButtonWidth) { >+ this.shell = shell; >+ >+ TabItem tab = new TabItem(folder, SWT.NONE, index); >+ tab.setText(SecUIMessages.tabContents); >+ Composite page = new Composite(folder, SWT.NONE); >+ tab.setControl(page); >+ >+ SashForm sashForm = new SashForm(page, SWT.HORIZONTAL); >+ sashForm.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, true)); >+ >+ Tree nodeTree = new Tree(sashForm, SWT.SINGLE | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER); >+ GridData gridData = new GridData(GridData.FILL, GridData.FILL, true, true); >+ gridData.verticalSpan = 2; >+ nodeTree.setLayoutData(gridData); >+ >+ Composite rightPane = new Composite(sashForm, SWT.NONE); >+ rightPane.setLayout(new GridLayout()); >+ >+ new Label(rightPane, SWT.NONE).setText(SecUIMessages.keysTable); >+ >+ Table tableOfValues = new Table(rightPane, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER); >+ tableOfValues.setLinesVisible(true); >+ tableOfValues.setHeaderVisible(true); >+ tableOfValues.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, true)); >+ >+ Composite buttonBar = new Composite(rightPane, SWT.NONE); >+ GridLayout buttonBarLayout = new GridLayout(); >+ buttonBarLayout.marginRight = 0; >+ buttonBar.setLayout(buttonBarLayout); >+ buttonBar.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END)); >+ >+ Button buttonSave = new Button(buttonBar, SWT.CENTER); >+ buttonSave.setText(SecUIMessages.saveButton); >+ setButtonSize(buttonSave, minButtonWidth); >+ buttonSave.addSelectionListener(new SelectionAdapter() { >+ >+ public void widgetSelected(SelectionEvent e) { >+ ISecurePreferences root = SecurePreferencesFactory.getDefault(); >+ try { >+ root.flush(); >+ } catch (IOException exception) { >+ Activator.log(IStatus.ERROR, exception.getMessage(), null, exception); >+ } >+ } >+ }); >+ >+ Button buttonExport = new Button(buttonBar, SWT.CENTER); >+ buttonExport.setText(SecUIMessages.exportButton); >+ setButtonSize(buttonExport, minButtonWidth); >+ buttonExport.addSelectionListener(new SelectionAdapter() { >+ public void widgetSelected(SelectionEvent e) { >+ export(); >+ } >+ }); >+ >+ Button buttonDelete = new Button(buttonBar, SWT.CENTER); >+ buttonDelete.setText(SecUIMessages.deleteButton); >+ setButtonSize(buttonDelete, minButtonWidth); >+ buttonDelete.addSelectionListener(new SelectionAdapter() { >+ public void widgetSelected(SelectionEvent e) { >+ deteleDefaultStorage(); >+ } >+ }); >+ >+ URL location = InternalExchangeUtils.defaultStorageLocation(); >+ if (location != null) { >+ new Label(page, SWT.NONE).setText(SecUIMessages.locationButton); >+ new Text(page, SWT.READ_ONLY).setText(location.getFile().toString()); >+ } >+ >+ sashForm.setWeights(new int[] {30, 70}); >+ >+ nodesView = new NodesView(nodeTree, this); >+ valuesView = new ValuesView(tableOfValues, this, shell); >+ >+ GridLayoutFactory.fillDefaults().margins(LayoutConstants.getMargins()).numColumns(1).generateLayout(page); >+ InternalExchangeUtils.addDeleteListener(this); >+ } >+ >+ public void onDeleted() { >+ if (nodesView != null) >+ nodesView.postDeleted(); >+ } >+ >+ protected void export() { >+ ISecurePreferences root = SecurePreferencesFactory.getDefault(); >+ if (root == null) >+ return; >+ ExportDialog dialog = new ExportDialog(shell); >+ dialog.open(); >+ String fileName = dialog.getFileName(); >+ if (fileName == null) >+ return; >+ File outputFile = new File(fileName); >+ >+ PrintStream output; >+ try { >+ output = new PrintStream(new FileOutputStream(outputFile)); >+ } catch (FileNotFoundException e) { >+ Activator.log(IStatus.ERROR, e.getMessage(), null, e); >+ return; >+ } >+ export(root, output); >+ output.flush(); >+ output.close(); >+ } >+ >+ protected void export(ISecurePreferences node, PrintStream stream) { >+ if (IStorageConst.PROVIDER_NODE.equals(node.absolutePath())) >+ return; // skip internal node >+ String[] keys = node.keys(); >+ if (keys.length > 0) { >+ String header = '[' + node.absolutePath() + ']'; >+ stream.println(header); >+ for (int i = 0; i < keys.length; i++) { >+ try { >+ String data = keys[i] + " := " + node.get(keys[i], ""); //$NON-NLS-1$ //$NON-NLS-2$ >+ stream.println(data); >+ } catch (StorageException e) { >+ Activator.log(IStatus.ERROR, SecUIMessages.failedDecrypt, null, e); >+ } >+ } >+ } >+ String[] children = node.childrenNames(); >+ for (int i = 0; i < children.length; i++) { >+ export(node.node(children[i]), stream); >+ } >+ } >+ >+ protected void setButtonSize(Button button, int minButtonWidth) { >+ Dialog.applyDialogFont(button); >+ GridData data = new GridData(); >+ Point minButtonSize = button.computeSize(SWT.DEFAULT, SWT.DEFAULT, true); >+ data.widthHint = Math.max(minButtonWidth, minButtonSize.x); >+ button.setLayoutData(data); >+ } >+ >+ protected void deteleDefaultStorage() { >+ URL location = InternalExchangeUtils.defaultStorageLocation(); >+ if (location == null) >+ return; >+ MessageBox messageBox = new MessageBox(shell, SWT.YES | SWT.NO); >+ messageBox.setText(location.getFile().toString()); >+ messageBox.setMessage(SecUIMessages.confirmDeleteMsg); >+ if (messageBox.open() != SWT.YES) >+ return; >+ >+ // clear the data structure itself in case somebody holds on to it >+ ISecurePreferences defaultStorage = SecurePreferencesFactory.getDefault(); >+ defaultStorage.clear(); >+ defaultStorage.removeNode(); >+ >+ // clear it from the list of open storages, delete the file >+ InternalExchangeUtils.defaultStorageDelete(); >+ >+ // suggest restart in case somebody holds on to the deleted storage >+ MessageBox postDeletionBox = new MessageBox(shell, SWT.OK); >+ postDeletionBox.setText(SecUIMessages.postDeleteTitle); >+ postDeletionBox.setMessage(SecUIMessages.postDeleteMsg); >+ postDeletionBox.open(); >+ } >+ >+} >Index: src/org/eclipse/equinox/internal/security/ui/storage/view/ISecurePreferencesSelection.java >=================================================================== >RCS file: src/org/eclipse/equinox/internal/security/ui/storage/view/ISecurePreferencesSelection.java >diff -N src/org/eclipse/equinox/internal/security/ui/storage/view/ISecurePreferencesSelection.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/equinox/internal/security/ui/storage/view/ISecurePreferencesSelection.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,18 @@ >+/******************************************************************************* >+ * Copyright (c) 2008 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.equinox.internal.security.ui.storage.view; >+ >+import org.eclipse.equinox.security.storage.ISecurePreferences; >+ >+public interface ISecurePreferencesSelection { >+ public void setSelection(ISecurePreferences selectedNode); >+ >+}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 227428
:
96869
| 96897