From 6b7f927b6837d6f7547b8ac79badc93796a82909 Mon Sep 17 00:00:00 2001
From: Martin Oberhuber < martin.oberhuber@windriver.com>
Date: Thu, 24 Jul 2008 13:27:08 +0000
Subject: [PATCH] [186769] Add comments about how to add RSE preference page
actions
---
.../org.eclipse.rse.ui/HelpContexts.xml | 1 +
.../rse/internal/ui/SystemResources.java | 1 +
.../SystemShowPreferencesPageAction.java | 79 +++---
.../rse/internal/ui/view/SystemViewPart.java | 236 +++++++++---------
rse/plugins/org.eclipse.rse.ui/plugin.xml | 5 +-
5 files changed, 165 insertions(+), 157 deletions(-)
diff --git a/rse/plugins/org.eclipse.rse.ui/HelpContexts.xml b/rse/plugins/org.eclipse.rse.ui/HelpContexts.xml
index 1467d225873..1a2a874a511 100644
--- a/rse/plugins/org.eclipse.rse.ui/HelpContexts.xml
+++ b/rse/plugins/org.eclipse.rse.ui/HelpContexts.xml
@@ -112,6 +112,7 @@ Select the configuration to be used for this subsystem and then edit the propert
* @deprecated this will be moved to use the command/handler extension point.
- * @see SystemCascadingPreferencesAction
*/
-public class SystemShowPreferencesPageAction extends SystemBaseAction implements IViewActionDelegate
+public class SystemShowPreferencesPageAction extends SystemBaseAction implements IViewActionDelegate
{
-
- private PreferenceManager preferenceManager;
+
+ private PreferenceManager preferenceManager;
private String[] preferencePageIDs;
private String preferencePageCategory;
-
+
/**
* Constructor.
* We are instantiated inside {@link RSEUIPlugin#getShowPreferencePageActions()}
@@ -56,7 +55,7 @@ public class SystemShowPreferencesPageAction extends SystemBaseAction implements
{
super("temp label", null); //$NON-NLS-1$
}
-
+
/**
* Set ID of the preference root page to show.
* @param preferencePageID The ID of the preference page root to show. All child nodes will also be shown.
@@ -71,25 +70,25 @@ public class SystemShowPreferencesPageAction extends SystemBaseAction implements
*/
public void setPreferencePageID(String[] preferencePageIDs)
{
- allowOnMultipleSelection(false);
+ allowOnMultipleSelection(false);
setSelectionSensitive(false);
this.preferencePageIDs = preferencePageIDs;
}
/**
* Set the category of the pages to be shown. This only needs to be called
* for non-root pages. Note that the ID to give here is not of the immediate
- * parent, but that of the root parent. It tells us which root subtree to
+ * parent, but that of the root parent. It tells us which root subtree to
* search for the given page(s).
*/
public void setPreferencePageCategory(String preferencePageCategory)
{
this.preferencePageCategory = preferencePageCategory;
}
-
+
/**
* @see IViewActionDelegate#init(IViewPart)
*/
- public void init(IViewPart view)
+ public void init(IViewPart view)
{
setShell(view.getSite().getShell());
}
@@ -99,7 +98,7 @@ public class SystemShowPreferencesPageAction extends SystemBaseAction implements
/**
* @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
*/
- public void run(IAction action)
+ public void run(IAction action)
{
run();
}
@@ -107,15 +106,15 @@ public class SystemShowPreferencesPageAction extends SystemBaseAction implements
/**
* @see org.eclipse.ui.IActionDelegate#selectionChanged(org.eclipse.jface.action.IAction, org.eclipse.jface.viewers.ISelection)
*/
- public void selectionChanged(IAction action, ISelection selection)
+ public void selectionChanged(IAction action, ISelection selection)
{
}
-
+
/**
* This is the method called when the user selects this action.
* @see org.eclipse.jface.action.Action#run()
*/
- public void run()
+ public void run()
{
// Bring up the preferences page
/*
@@ -125,25 +124,25 @@ public class SystemShowPreferencesPageAction extends SystemBaseAction implements
dialog.open();
*/
PreferenceManager pm = getPreferenceManager();
-
- if (pm != null)
+
+ if (pm != null)
{
shell = RSEUIPlugin.getTheSystemRegistryUI().getShell();
PreferenceDialog d = new WorkbenchPreferenceDialog(shell, pm);
d.create();
// TODO - hack to make this work in 3.1
String id = PlatformUI.PLUGIN_ID + ".preference_dialog_context"; //$NON-NLS-1$
-
+
PlatformUI.getWorkbench().getHelpSystem().setHelp(d.getShell(), id);
- d.open();
- }
- }
+ d.open();
+ }
+ }
/*
* Get the preference manager.
*/
- public PreferenceManager getPreferenceManager()
+ public PreferenceManager getPreferenceManager()
{
- if (preferenceManager == null)
+ if (preferenceManager == null)
{
preferenceManager = new PreferenceManager('/');
@@ -151,16 +150,16 @@ public class SystemShowPreferencesPageAction extends SystemBaseAction implements
//PreferencePageRegistryReader registryReader = new PreferencePageRegistryReader(PlatformUI.getWorkbench());
//List pageContributions = registryReader.getPreferenceContributions(Platform.getExtensionRegistry());
-
+
PreferenceManager workbenchMgr = PlatformUI.getWorkbench().getPreferenceManager();
-
+
List pageContributions = workbenchMgr.getElements(PreferenceManager.POST_ORDER);
-
-
+
+
//Add the contributions to the manager
Iterator iter = pageContributions.iterator();
- while (iter.hasNext())
+ while (iter.hasNext())
{
IPreferenceNode prefNode = (IPreferenceNode) iter.next();
//System.out.println("prefNode.getId() == "+prefNode.getId());
@@ -176,16 +175,16 @@ public class SystemShowPreferencesPageAction extends SystemBaseAction implements
//System.out.println("Made it here");
prefNode = searchForSubPage(prefNode, prefNodeID);
if (prefNode != null)
- match = true;
+ match = true;
}
if (match)
preferenceManager.addToRoot(prefNode);
}
-
+
}
return preferenceManager;
}
-
+
private IPreferenceNode searchForSubPage(IPreferenceNode parent, String prefNodeID)
{
IPreferenceNode match = null;
@@ -196,18 +195,18 @@ public class SystemShowPreferencesPageAction extends SystemBaseAction implements
{
if (testForMatch(subNodes[idx].getId()))
match = subNodes[idx];
- else
+ else
match = searchForSubPage(subNodes[idx], prefNodeID);
}
-
+
return match;
}
-
+
private boolean testForMatch(String prefNodeID)
{
boolean match = false;
for (int idx=0; !match && (idx
* The parent's default implementation will ignore the memento and initialize
- * the view in a fresh state. Subclasses may override the implementation to
+ * the view in a fresh state. Subclasses may override the implementation to
* perform any state restoration as needed.
*/
public void init(IViewSite site, IMemento memento) throws PartInitException
@@ -918,7 +922,7 @@ public class SystemViewPart
{
AbstractUIPlugin plugin = (AbstractUIPlugin) Platform.getPlugin(PlatformUI.PLUGIN_ID);
URL installURL = plugin.getDescriptor().getInstallURL();
-
+
URL url = new URL(installURL, iconPath + relativePath);
ImageDescriptor descriptor = ImageDescriptor.createFromURL(url);
return descriptor;
@@ -963,7 +967,7 @@ public class SystemViewPart
// restoring expansion state and hence will abandon it.
memento.putString(TAG_SHOWFILTERPOOLS, SystemPreferencesManager.getShowFilterPools() ? "t" : "f"); //$NON-NLS-1$ //$NON-NLS-2$
- //memento.putString(TAG_SHOWFILTERSTRINGS, SystemPreferencesManager.getPreferencesManager().getShowFilterStrings() ? "t" : "f");
+ //memento.putString(TAG_SHOWFILTERSTRINGS, SystemPreferencesManager.getPreferencesManager().getShowFilterStrings() ? "t" : "f");
String inputMemento = memento.getString("factoryID"); // see IWorkbenchWindow ... this is only clue I can figure out! //$NON-NLS-1$
if (inputMemento != null)
@@ -1080,7 +1084,7 @@ public class SystemViewPart
//System.out.println("SYSTEMVIEWPART: restoreState");
if (!SystemPreferencesManager.getPreferencesManager().getRememberState())
return;
-
+
// restore the show filter pools and show filter strings settings as they were when this was saved
boolean showFilterPools = false;
boolean showFilterStrings = false;
@@ -1089,22 +1093,22 @@ public class SystemViewPart
showFilterPools = savedValue.equals("t");
else
showFilterPools = SystemPreferencesManager.getPreferencesManager().getShowFilterPools();
-
+
savedValue = memento.getString(TAG_SHOWFILTERSTRINGS); // historical
if (savedValue != null)
showFilterStrings = savedValue.equals("t");
//else
//showFilterStrings = SystemPreferencesManager.getPreferencesManager().getShowFilterStrings();
-
+
IMemento childMem = null;
-
+
// restore expand-to hashtable state
- childMem= memento.getChild(TAG_EXPANDED_TO);
- if (childMem != null)
+ childMem= memento.getChild(TAG_EXPANDED_TO);
+ if (childMem != null)
{
IMemento[] elementMem= childMem.getChildren(TAG_ELEMENT);
Hashtable ht = new Hashtable();
- for (int i= 0; i < elementMem.length; i++)
+ for (int i= 0; i < elementMem.length; i++)
{
String key = elementMem[i].getString(TAG_PATH);
String value = elementMem[i].getString(TAG_FILTER);
@@ -1114,16 +1118,16 @@ public class SystemViewPart
if (ht.size() > 0)
systemView.setExpandToFilterTable(ht);
}
-
+
// restore expansion state
childMem= memento.getChild(TAG_EXPANDED);
- if (childMem != null)
+ if (childMem != null)
{
ArrayList elements= new ArrayList();
Vector remoteElements = new Vector();
IMemento[] elementMem= childMem.getChildren(TAG_ELEMENT);
// walk through list of expanded nodes, breaking into 2 lists: non-remote and remote
- for (int i= 0; i < elementMem.length; i++)
+ for (int i= 0; i < elementMem.length; i++)
{
Object element= getObjectFromMemento(showFilterPools, showFilterStrings, elementMem[i].getString(TAG_PATH));
if (element != null)
@@ -1154,15 +1158,15 @@ public class SystemViewPart
}
}
}
-
+
// restoreSelection
childMem= memento.getChild(TAG_SELECTION);
- if (childMem != null)
+ if (childMem != null)
{
ArrayList list= new ArrayList();
Vector remoteElements = new Vector();
IMemento[] elementMem= childMem.getChildren(TAG_ELEMENT);
- for (int i= 0; i < elementMem.length; i++)
+ for (int i= 0; i < elementMem.length; i++)
{
Object element= getObjectFromMemento(showFilterPools, showFilterStrings, elementMem[i].getString(TAG_PATH));
if (element != null)
@@ -1182,7 +1186,7 @@ public class SystemViewPart
v.addElement(ro.name);
}
SystemResourceChangeEvent event = new SystemResourceChangeEvent(v,ISystemResourceChangeEvents.EVENT_SELECT_REMOTE,null);
- systemView.systemResourceChanged(event);
+ systemView.systemResourceChanged(event);
}
}
Tree tree= systemView.getTree();
@@ -1190,7 +1194,7 @@ public class SystemViewPart
ScrollBar bar= tree.getVerticalBar();
if (bar != null)
{
- try
+ try
{
String posStr= memento.getString(TAG_VERTICAL_POSITION);
if (posStr != null)
@@ -1199,15 +1203,15 @@ public class SystemViewPart
position= new Integer(posStr).intValue();
bar.setSelection(position);
}
- } catch (NumberFormatException e)
+ } catch (NumberFormatException e)
{
}
}
//restore vertical position
bar= tree.getHorizontalBar();
- if (bar != null)
+ if (bar != null)
{
- try
+ try
{
String posStr= memento.getString(TAG_HORIZONTAL_POSITION);
if (posStr != null)
@@ -1216,7 +1220,7 @@ public class SystemViewPart
position= new Integer(posStr).intValue();
bar.setSelection(position);
}
- } catch (NumberFormatException e)
+ } catch (NumberFormatException e)
{
}
}
@@ -1255,22 +1259,22 @@ public class SystemViewPart
// 1. connections
// 2. subsystems
// 3. filter pools (optional)
- // 4. filters
+ // 4. filters
// 5. filter strings (optional)
// 6. remote objects
// 1. connections
// 2. subsystems
- // 3. filters
+ // 3. filters
// 4. filter strings (optional)
// 5. remote objects
// 1. connections
// 2. subsystems
// 3. filter pools (optional)
- // 4. filters
+ // 4. filters
// 5. remote objects
// 1. connections
// 2. subsystems
- // 3. filters
+ // 3. filters
// 4. remote objects
int index = 0;
@@ -1340,7 +1344,7 @@ public class SystemViewPart
if (refs[refidx].getFullName().equals(poolName))
fpRef = refs[refidx];
}
-
+
// TODO: handle nested filters. in this case they are separated by ';'. See SystemFilterReferenceAdapter's getMementoHandle()
if (fpRef != null)
{
@@ -1452,7 +1456,7 @@ public class SystemViewPart
{
lastToken = token.toString();
v.addElement(lastToken);
- //System.out.println("...token: " + token);
+ //System.out.println("...token: " + token);
token.setLength(0);
idx += delimLen - 1;
}
@@ -1477,36 +1481,36 @@ public class SystemViewPart
_restoredObject = restoredObject;
_children = children;
}
-
+
public void run()
{
Vector matches = new Vector();
systemView.findAllRemoteItemReferences(_restoredObject, _restoredObject, matches);
if (matches.size() > 0){
TreeItem item = (TreeItem)matches.get(0);
- systemView.createTreeItems(item, _children);
+ systemView.createTreeItems(item, _children);
item.setExpanded(true);
}
}
}
-
-
+
+
protected class RestoreRemoteObjects extends Job
{
private Vector _remoteObjectsToRestore;
private List _cacheSubSystemList;
private Vector _remoteObjectsToSelect;
-
+
public RestoreRemoteObjects(Vector remoteObjects, List cacheSubSystemList, Vector remoteObjectsToSelect)
- {
+ {
super("Restore Remote Objects"); //$NON-NLS-1$
_remoteObjectsToRestore = remoteObjects;
_cacheSubSystemList = cacheSubSystemList;
_remoteObjectsToSelect = remoteObjectsToSelect;
}
- protected IStatus run(IProgressMonitor monitor)
+ protected IStatus run(IProgressMonitor monitor)
{
IStatus status = doRestore(monitor);
if (status.isOK()){
@@ -1514,42 +1518,42 @@ public class SystemViewPart
}
return status;
}
-
+
protected IStatus doSelect(IProgressMonitor monitor)
- {
+ {
Vector v = new Vector();
for (int i = 0; i < _remoteObjectsToSelect.size(); i++){
-
+
Object object = _remoteObjectsToSelect.get(i);
if (object instanceof RemoteObject)
{
- RemoteObject robject = (RemoteObject)object;
+ RemoteObject robject = (RemoteObject)object;
v.addElement(robject.name);
}
}
SystemResourceChangeEvent event = new SystemResourceChangeEvent(v, ISystemResourceChangeEvents.EVENT_SELECT_REMOTE, null);
systemView.systemResourceChanged(event);
-
+
return Status.OK_STATUS;
}
-
-
+
+
protected IStatus doRestore(IProgressMonitor monitor)
{
for (int i = 0; i < _remoteObjectsToRestore.size(); i++){
-
+
if (monitor.isCanceled()){
return Status.CANCEL_STATUS;
}
-
+
Object object = _remoteObjectsToRestore.get(i);
if (object instanceof RemoteObject)
{
RemoteObject robject = (RemoteObject)object;
-
+
ISubSystem ss = robject.subsystem;
- // yantzi: artemis 6.0: notify subsystems that this is a restore from memento so they
+ // yantzi: artemis 6.0: notify subsystems that this is a restore from memento so they
// can optionally use the cache if desired
if (ss != null && ss.supportsCaching())
{
@@ -1559,37 +1563,37 @@ public class SystemViewPart
if (!ss.isOffline()){
String path = robject.name;
ISystemFilterReference fref = robject.fRef;
-
+
try
{
Object actualObject = ss.getObjectWithAbsoluteName(path, monitor);
-
+
if (actualObject instanceof IAdaptable)
{
// get the adapter
ISystemViewElementAdapter adapter = (ISystemViewElementAdapter)((IAdaptable)actualObject).getAdapter(ISystemViewElementAdapter.class);
-
+
// get the context
ContextObject contextObject = new ContextObject(actualObject, ss, fref);
-
- // get the children
+
+ // get the children
Object[] children = adapter.getChildren(contextObject, monitor);
-
+
ShowRestoredRemoteObject showRunnable = new ShowRestoredRemoteObject(actualObject, children);
Display.getDefault().asyncExec(showRunnable);
}
-
+
}
catch (Exception e)
{
// unexpected
}
-
+
// yantzi: artemis 6.0: reset restore from memento flag
if (ss != null && ss.supportsCaching())
{
ss.getCacheManager().setRestoreFromMemento(false);
- }
+ }
}
}
else if (object instanceof ISystemFilterReference)
@@ -1610,16 +1614,16 @@ public class SystemViewPart
{
// get the adapter
ISystemViewElementAdapter adapter = (ISystemViewElementAdapter)((IAdaptable)object).getAdapter(ISystemViewElementAdapter.class);
-
+
// get the context
ContextObject contextObject = new ContextObject(fref, ss, fref);
-
- // get the children
+
+ // get the children
Object[] children = adapter.getChildren(contextObject, monitor);
-
+
ShowRestoredRemoteObject showRunnable = new ShowRestoredRemoteObject(fref, children);
Display.getDefault().asyncExec(showRunnable);
- }
+ }
}
}
}
@@ -1632,11 +1636,11 @@ public class SystemViewPart
((ISubSystem) _cacheSubSystemList.get(i)).getCacheManager().setRestoreFromMemento(false);
}
}
-
+
return Status.OK_STATUS;
- }
+ }
}
-
+
protected class RemoteObject
{
public String name;
@@ -1656,14 +1660,14 @@ public class SystemViewPart
{
return "Remote object: " + name; //$NON-NLS-1$
}
-
+
public boolean equals(RemoteObject compared)
{
if (name.equals(compared.name) &&
subsystem == compared.subsystem &&
fRef == compared.fRef)
return true;
-
+
return false;
}
}
@@ -1696,10 +1700,10 @@ public class SystemViewPart
{
super("Restore RSE Tree"); //$NON-NLS-1$
_memento = memento;
-
+
}
- public IStatus runInUIThread(IProgressMonitor monitor)
+ public IStatus runInUIThread(IProgressMonitor monitor)
{
IMemento memento = _memento;
//System.out.println("SYSTEMVIEWPART: restoreState");
@@ -1747,12 +1751,12 @@ public class SystemViewPart
if (childMem != null)
{
ArrayList elements = new ArrayList();
-
+
IMemento[] elementMem = childMem.getChildren(TAG_ELEMENT);
// yantzi: artemis6.0, keep track subsystems which have their memento flag set in order
// to restore system view from cache (if the subsystem supports this)
-
+
ISubSystem cacheSubSystem;
boolean restoreFromCache = RSEUIPlugin.getDefault().getPreferenceStore().getBoolean(ISystemPreferencesConstants.RESTORE_STATE_FROM_CACHE);
@@ -1771,7 +1775,7 @@ public class SystemViewPart
remoteElementsToRestore.add(element); // filters trigger asynchronous queries, so best to expand this with remote items
if (restoreFromCache)
- {
+ {
// yantzi: artemis 6.0, see comment above
cacheSubSystem = ((ISystemFilterReference)element).getSubSystem();
if (cacheSubSystem.supportsCaching() && cacheSubSystem.getCacheManager() != null)
@@ -1793,12 +1797,12 @@ public class SystemViewPart
// restoreSelection
childMem = memento.getChild(TAG_SELECTION);
-
+
Vector remoteElementsToSelect = new Vector();
if (childMem != null)
{
ArrayList list = new ArrayList();
-
+
IMemento[] elementMem = childMem.getChildren(TAG_ELEMENT);
for (int i = 0; i < elementMem.length; i++)
{
@@ -1814,13 +1818,13 @@ public class SystemViewPart
systemView.setSelection(new StructuredSelection(list));
}
}
-
+
if (remoteElementsToRestore.size() > 0)
{
RestoreRemoteObjects restoreRemoteJob = new RestoreRemoteObjects(remoteElementsToRestore, cacheSubSystemList, remoteElementsToSelect);
- restoreRemoteJob.schedule();
- }
-
+ restoreRemoteJob.schedule();
+ }
+
Tree tree = systemView.getTree();
//restore vertical position
ScrollBar bar = tree.getVerticalBar();
@@ -1858,8 +1862,8 @@ public class SystemViewPart
{
}
}
-
-
+
+
String linkWithEditor = memento.getString(TAG_LINKWITHEDITOR);
if (linkWithEditor != null)
{
@@ -1873,11 +1877,11 @@ public class SystemViewPart
_isLinkingEnabled = false;
}
-
-
+
+
return Status.OK_STATUS;
}
-
+
}
// THE FOLLOWING ARE TO ENABLE PERSISTENCE OF NON-PRIMARY REMOTE SYSTEM EXPLORER VIEWS OPENED UP BY THE
@@ -1941,7 +1945,7 @@ public class SystemViewPart
*
public void saveState(IMemento memento)
{
-
+
}*/
/**
@@ -1982,7 +1986,7 @@ public class SystemViewPart
}
/**
- * Called by our plugin's startup method to register our adaptable object types
+ * Called by our plugin's startup method to register our adaptable object types
* with the platform. We prefer to do it here to isolate/encapsulate all factory
* logic in this one place.
*/
@@ -1993,7 +1997,7 @@ public class SystemViewPart
manager.registerAdapters(this, input.getClass());
}
/**
- * Called by our plugin's startup method to register our adaptable object types
+ * Called by our plugin's startup method to register our adaptable object types
* with the platform. We prefer to do it here to isolate/encapsulate all factory
* logic in this one place.
*/
diff --git a/rse/plugins/org.eclipse.rse.ui/plugin.xml b/rse/plugins/org.eclipse.rse.ui/plugin.xml
index 37217b67770..f2a9ad9c3a8 100644
--- a/rse/plugins/org.eclipse.rse.ui/plugin.xml
+++ b/rse/plugins/org.eclipse.rse.ui/plugin.xml
@@ -266,7 +266,10 @@ Anna Dushistova (MontaVista) - [234274][api] Launch Shell / Terminal commands m
-
+
+
+