Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSamantha Chan2005-08-31 20:34:14 +0000
committerSamantha Chan2005-08-31 20:34:14 +0000
commit4b43180f4c45f52e7158c9908b0bd3653cdb9c9e (patch)
treeed958e1530f1653974b1685e8b89cef2abd4f197
parent6578f29b3b5daa58641b1e6291882728c4a7279a (diff)
downloadeclipse.platform.debug-4b43180f4c45f52e7158c9908b0bd3653cdb9c9e.tar.gz
eclipse.platform.debug-4b43180f4c45f52e7158c9908b0bd3653cdb9c9e.tar.xz
eclipse.platform.debug-4b43180f4c45f52e7158c9908b0bd3653cdb9c9e.zip
Allow user to define policy set
-rw-r--r--org.eclipse.debug.ui/schema/viewUpdatePolicy.exsd4
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/DebugUIMessages.java26
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/DebugUIMessages.properties22
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/updatePolicy/AbstractDebugViewExtension.java13
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/updatePolicy/DebugModel.java46
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/updatePolicy/IDebugViewExtension.java2
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/updatePolicy/IUpdatePolicyManager.java41
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/updatePolicy/IUpdatePolicySet.java29
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/updatePolicy/IUpdatePolicySetListener.java33
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/updatePolicy/PolicySetDialog.java567
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/updatePolicy/UpdatePolicyMgr.java132
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/updatePolicy/UpdatePolicySet.java107
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/variables/VariablesView.java14
13 files changed, 1003 insertions, 33 deletions
diff --git a/org.eclipse.debug.ui/schema/viewUpdatePolicy.exsd b/org.eclipse.debug.ui/schema/viewUpdatePolicy.exsd
index d357aba8c..141de7941 100644
--- a/org.eclipse.debug.ui/schema/viewUpdatePolicy.exsd
+++ b/org.eclipse.debug.ui/schema/viewUpdatePolicy.exsd
@@ -55,10 +55,10 @@
</documentation>
</annotation>
</attribute>
- <attribute name="modelId" type="string" use="required">
+ <attribute name="modelId" type="string">
<annotation>
<documentation>
- The model identifier of the debug element being displayed by the view.
+ The model identifier of the debug element being displayed by the view. If unspecified, the policy set can be applied to all models.
</documentation>
</annotation>
</attribute>
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/DebugUIMessages.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/DebugUIMessages.java
index 70b08400c..95dbfc86b 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/DebugUIMessages.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/DebugUIMessages.java
@@ -212,12 +212,32 @@ public class DebugUIMessages extends NLS {
public static String SetUpdatePolicyAction_1;
public static String SetUpdatePolicyAction_3;
public static String SetUpdatePolicyAction_6;
-
-
+ public static String PolicySetDialog_1;
+ public static String PolicySetDialog_2;
+ public static String PolicySetDialog_3;
+ public static String PolicySetDialog_4;
+ public static String PolicySetDialog_6;
+ public static String PolicySetDialog_7;
+ public static String PolicySetDialog_9;
+ public static String PolicySetDialog_10;
+ public static String PolicySetDialog_11;
+ public static String PolicySetDialog_12;
+ public static String PolicySetDialog_14;
+ public static String PolicySetDialog_15;
+ public static String PolicySetDialog_16;
+ public static String PolicySetDialog_17;
+ public static String PolicySetDialog_0;
+ public static String PolicySetDialog_25;
+ public static String PolicySetDialog_26;
+ public static String UpdatePolicyMgr_0;
+ public static String UpdatePolicyMgr_1;
+ public static String UpdatePolicyMgr_2;
+ public static String UpdatePolicyMgr_3;
+ public static String UpdatePolicyMgr_4;
+
static {
// load message values from bundle file
NLS.initializeMessages(BUNDLE_NAME, DebugUIMessages.class);
}
-
} \ No newline at end of file
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/DebugUIMessages.properties b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/DebugUIMessages.properties
index dcab1fced..dfe195b81 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/DebugUIMessages.properties
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/DebugUIMessages.properties
@@ -205,3 +205,25 @@ TableRenderingPreferencePage_2=Number of Lines per Page:
TableRenderingPreferencePage_3=Page size cannot be less than 1.
TableRenderingPreferencePage_4=Page size is invalid.
TableRenderingPrefAction_0=Table Renderings
+PolicySetDialog_1=Manage Policy Sets
+PolicySetDialog_2=Details
+PolicySetDialog_3=Identifier:
+PolicySetDialog_4=Name:
+PolicySetDialog_6=Descriptions:
+PolicySetDialog_7=Policies:
+PolicySetDialog_9=Apply
+PolicySetDialog_10=Policy Sets
+PolicySetDialog_11=New...
+PolicySetDialog_12=Remove
+PolicySetDialog_14=Failed to add policy set.
+PolicySetDialog_15=An exception has occurred adding policy set.
+PolicySetDialog_16=Failed to remove policy set.
+PolicySetDialog_17=An exception has occurred removing policy set.
+PolicySetDialog_0=New Policy Set
+PolicySetDialog_25=Policy Set Changed
+PolicySetDialog_26=Unsaved information found in this policy set, save it?
+UpdatePolicyMgr_0=Unable to add policy set because another policy set with the same id already exists.
+UpdatePolicyMgr_1=Policy set does not have a valid id.
+UpdatePolicyMgr_2=Policy set does not have a valid name.
+UpdatePolicyMgr_3=Policy set does not have a valid description.
+UpdatePolicyMgr_4=Policy set cannot be removed.
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/updatePolicy/AbstractDebugViewExtension.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/updatePolicy/AbstractDebugViewExtension.java
index d74d08709..7a7b85671 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/updatePolicy/AbstractDebugViewExtension.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/updatePolicy/AbstractDebugViewExtension.java
@@ -31,6 +31,7 @@ import org.eclipse.core.runtime.Platform;
import org.eclipse.debug.core.model.IDebugElement;
import org.eclipse.debug.internal.ui.DebugUIPlugin;
import org.eclipse.debug.ui.AbstractDebugView;
+import org.eclipse.jface.action.Action;
import org.eclipse.jface.action.IMenuManager;
import org.eclipse.jface.action.MenuManager;
import org.eclipse.jface.action.Separator;
@@ -45,8 +46,6 @@ import org.eclipse.ui.XMLMemento;
public abstract class AbstractDebugViewExtension extends AbstractDebugView implements IDebugViewExtension {
- public static final String PROPERTY_UPDATE_POLICY="org.eclipse.debug.ui.updatePolicy"; //$NON-NLS-1$
-
private static final DebugModel[] EMPTY = new DebugModel[0];
private static final IUpdatePolicy[] EMPTY_POLICY = new IUpdatePolicy[0];
@@ -289,6 +288,7 @@ public abstract class AbstractDebugViewExtension extends AbstractDebugView imple
DebugModel[] models = getActiveModels();
+ // TODO: move actions to plugin.xml... these strings move to plugin.properties
menu.add(new Separator("UpdatePolicy")); //$NON-NLS-1$
IMenuManager updatePolicyMenu = new MenuManager("Update Policy", "updatePolicy"); //$NON-NLS-2$
for (int i=0; i<models.length; i++)
@@ -309,6 +309,13 @@ public abstract class AbstractDebugViewExtension extends AbstractDebugView imple
}
}
menu.add(updatePolicyMenu);
+ menu.add(new Action("Manage Policy Set..."){
+
+ public void run() {
+
+ PolicySetDialog dialog = new PolicySetDialog(DebugUIPlugin.getActiveWorkbenchWindow().getShell());
+ dialog.open();
+ }});
}
public void saveModels(IMemento memento) {
@@ -435,7 +442,7 @@ public abstract class AbstractDebugViewExtension extends AbstractDebugView imple
String oldId = fActivePolicySetId;
fActivePolicySetId = policySetId;
Object[] listeners = fListeners.getListeners();
- PropertyChangeEvent evt = new PropertyChangeEvent(this, PROPERTY_UPDATE_POLICY, oldId, fActivePolicySetId);
+ PropertyChangeEvent evt = new PropertyChangeEvent(this, IDebugViewExtension.PROPERTY_UPDATE_POLICY, oldId, fActivePolicySetId);
for (int i=0; i<listeners.length; i++)
{
if (listeners[i] instanceof IPropertyChangeListener)
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/updatePolicy/DebugModel.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/updatePolicy/DebugModel.java
index 342e0c01b..6b4a141f7 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/updatePolicy/DebugModel.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/updatePolicy/DebugModel.java
@@ -25,7 +25,7 @@ import org.eclipse.jface.util.PropertyChangeEvent;
import org.eclipse.ui.IMemento;
import org.eclipse.ui.IPersistableElement;
-public class DebugModel extends PlatformObject implements IPersistableElement{
+public class DebugModel extends PlatformObject implements IPersistableElement, IUpdatePolicySetListener{
private static final IUpdatePolicyHandler[] EMPTY = new IUpdatePolicyHandler[0];
public static final String ATTR_MODEL_ID = "modelId"; //$NON-NLS-1$
@@ -46,7 +46,6 @@ public class DebugModel extends PlatformObject implements IPersistableElement{
public DebugModel(IMemento memento, IDebugViewExtension view)
{
fView = view;
- addListeners();
String modelId = memento.getString(DebugModel.ATTR_MODEL_ID);
fModelIdentifier = modelId;
@@ -58,22 +57,21 @@ public class DebugModel extends PlatformObject implements IPersistableElement{
fActivePolicySet = set;
// do not activate handlers unless the model is activated
}
+ addListeners();
}
public DebugModel(String modelIdentifier, IDebugViewExtension view)
{
fModelIdentifier = modelIdentifier;
fView = view;
-
addListeners();
}
private void addListeners() {
fListener = new IPropertyChangeListener() {
public void propertyChange(PropertyChangeEvent event) {
- if (fIsActive) {
- if (event.getProperty().equals(
- AbstractDebugViewExtension.PROPERTY_UPDATE_POLICY)) {
+ if (fIsActive && fActivePolicySet != null) {
+ if (event.getProperty().equals(IDebugViewExtension.PROPERTY_UPDATE_POLICY)) {
Object obj = event.getNewValue();
if (obj instanceof String) {
String newId = (String) obj;
@@ -143,7 +141,7 @@ public class DebugModel extends PlatformObject implements IPersistableElement{
set = fActivePolicySet;
loadHandlers(set);
}
-
+ DebugUITools.getUpdatePolicyManager().addPolicySetListener(this);
if (debugContext != null)
{
if (debugContext.getModelIdentifier().equals(getModelIdentifier()))
@@ -164,11 +162,13 @@ public class DebugModel extends PlatformObject implements IPersistableElement{
{
fIsActive = false;
unloadHandlers();
+ DebugUITools.getUpdatePolicyManager().removePolicySetListener(this);
}
public void dispose()
{
removeListeners();
+ DebugUITools.getUpdatePolicyManager().removePolicySetListener(this);
unloadHandlers();
fPolicyHandlers = null;
}
@@ -254,4 +254,36 @@ public class DebugModel extends PlatformObject implements IPersistableElement{
{
return fDebugContext;
}
+
+ public void policySetAdded(IUpdatePolicySet set) {
+ // do not handle policy set added
+ // not activating the policy set unless user has set it
+
+ }
+
+ public void policySetRemoved(IUpdatePolicySet set) {
+ // if the current policy set is removed, pick primary policy set
+ if (fActivePolicySet != null && fActivePolicySet == set)
+ {
+ unloadHandlers();
+ IUpdatePolicySet newSet = DebugUITools.getUpdatePolicyManager().getPrimaryPolicySet(fView.getSite().getId(), getModelIdentifier());
+
+ if (newSet == null)
+ {
+ DebugUIPlugin.logErrorMessage("Cannot find primary policy set: " + fView.getSite().getId() + " " + getModelIdentifier()); //$NON-NLS-1$//$NON-NLS-2$
+ return;
+ }
+ loadHandlers(newSet);
+ }
+ }
+
+ public void policySetChanged(IUpdatePolicySet set) {
+ // if the current policy set is changed, reload policy set
+ if (fActivePolicySet != null && fActivePolicySet == set)
+ {
+ unloadHandlers();
+ loadHandlers(set);
+ }
+
+ }
}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/updatePolicy/IDebugViewExtension.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/updatePolicy/IDebugViewExtension.java
index d8a30d661..dc34b1c73 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/updatePolicy/IDebugViewExtension.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/updatePolicy/IDebugViewExtension.java
@@ -23,6 +23,8 @@ import org.eclipse.jface.util.IPropertyChangeListener;
// to allow memory renderings to implemen this interface
public interface IDebugViewExtension extends IDebugView{
+ public static final String PROPERTY_UPDATE_POLICY="org.eclipse.debug.ui.updatePolicy"; //$NON-NLS-1$
+
/**
* Called when the view needs to be refreshed. The sepcified element and its children
* would be updated.
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/updatePolicy/IUpdatePolicyManager.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/updatePolicy/IUpdatePolicyManager.java
index 4d3666a8c..58b732e4f 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/updatePolicy/IUpdatePolicyManager.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/updatePolicy/IUpdatePolicyManager.java
@@ -12,6 +12,8 @@
package org.eclipse.debug.internal.ui.views.updatePolicy;
+import org.eclipse.debug.core.DebugException;
+
public interface IUpdatePolicyManager {
/**
@@ -22,6 +24,11 @@ public interface IUpdatePolicyManager {
IUpdatePolicySet[] getPolicySets(String viewId, String modelId);
/**
+ * @return all policy sets
+ */
+ IUpdatePolicySet[] getAllPolicySets();
+
+ /**
* @param viewId
* @param modelId
* @return the primary policy set applicable to the given view id and model id
@@ -40,4 +47,38 @@ public interface IUpdatePolicyManager {
* @return the policy with the given policy id
*/
IUpdatePolicy getPolicy(String policyId);
+
+ /**
+ * @return all update policies
+ */
+ IUpdatePolicy[] getAllPolicies();
+
+ /**
+ * @param policySet
+ * @throws DebugException if error has occurred adding the policy set
+ */
+ public void addPolicySet(IUpdatePolicySet policySet) throws DebugException;
+
+ /**
+ * @param policySet
+ * @throws DebugException if error has occurred removing the policy set
+ */
+ public void removePolicySet(IUpdatePolicySet policySet) throws DebugException;
+
+ /**
+ * Notify UpdatePolicyManager that the policy set has changed.
+ * This will cause the policy set manager to fire a change event
+ * @param policySet the policy set changed
+ */
+ public void policySetChanged(IUpdatePolicySet policySet);
+
+ /**
+ * @param listener listener to be notfied when user-defined policy set are added/removed from the manager
+ */
+ public void addPolicySetListener(IUpdatePolicySetListener listener);
+
+ /**
+ * @param listener listener to remove
+ */
+ public void removePolicySetListener(IUpdatePolicySetListener listener);
}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/updatePolicy/IUpdatePolicySet.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/updatePolicy/IUpdatePolicySet.java
index 7415c5f02..2c53bbd39 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/updatePolicy/IUpdatePolicySet.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/updatePolicy/IUpdatePolicySet.java
@@ -33,14 +33,31 @@ public interface IUpdatePolicySet {
public String[] getPolicies();
/**
+ * @param ids set new policies in the policy set
+ *
+ */
+ public void setPolicies(String[] ids);
+
+ /**
* @return name of the policy set
*/
public String getName();
/**
+ * Sets the name of this policy set
+ * @param name
+ */
+ public void setName(String name);
+
+ /**
* @return description of the policy set
*/
public String getDescription();
+
+ /**
+ * Sets the description of this policy set
+ */
+ public void setDescription(String description);
/**
* @return if the policy is hidden
@@ -56,5 +73,17 @@ public interface IUpdatePolicySet {
* @return the id of this policy set
*/
public String getId();
+
+ /**
+ * @return if the policy set is editable. A policy set is editable
+ * if it is added by an user.
+ */
+ public boolean canEdit();
+
+ /**
+ * @return if the policy set is removable. A policy set is removable
+ * if it is added by an user.
+ */
+ public boolean canRemove();
}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/updatePolicy/IUpdatePolicySetListener.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/updatePolicy/IUpdatePolicySetListener.java
new file mode 100644
index 000000000..cc08e15a7
--- /dev/null
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/updatePolicy/IUpdatePolicySetListener.java
@@ -0,0 +1,33 @@
+/*******************************************************************************
+ * Copyright (c) 2005 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.debug.internal.ui.views.updatePolicy;
+
+public interface IUpdatePolicySetListener {
+
+ /**
+ * Policy set added to the manager.
+ * @param set
+ */
+ public void policySetAdded(IUpdatePolicySet set);
+
+ /**
+ * Policy set removed from the manager.
+ * @param set
+ */
+ public void policySetRemoved(IUpdatePolicySet set);
+
+ /**
+ * Policy set changed
+ * @param set
+ */
+ public void policySetChanged(IUpdatePolicySet set);
+}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/updatePolicy/PolicySetDialog.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/updatePolicy/PolicySetDialog.java
new file mode 100644
index 000000000..82e713920
--- /dev/null
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/updatePolicy/PolicySetDialog.java
@@ -0,0 +1,567 @@
+/*******************************************************************************
+ * Copyright (c) 2005 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.debug.internal.ui.views.updatePolicy;
+
+import java.util.ArrayList;
+
+import org.eclipse.debug.core.DebugException;
+import org.eclipse.debug.internal.ui.DebugUIMessages;
+import org.eclipse.debug.internal.ui.DebugUIPlugin;
+import org.eclipse.debug.ui.DebugUITools;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.text.Document;
+import org.eclipse.jface.text.TextViewer;
+import org.eclipse.jface.viewers.CheckStateChangedEvent;
+import org.eclipse.jface.viewers.CheckboxTableViewer;
+import org.eclipse.jface.viewers.ICheckStateListener;
+import org.eclipse.jface.viewers.ILabelProvider;
+import org.eclipse.jface.viewers.ILabelProviderListener;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.IStructuredContentProvider;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.ListViewer;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.SashForm;
+import org.eclipse.swt.events.KeyAdapter;
+import org.eclipse.swt.events.KeyEvent;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Group;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.ui.dialogs.SelectionDialog;
+
+// TODO: Dialog needs F1 help
+public class PolicySetDialog extends SelectionDialog implements IUpdatePolicySetListener{
+
+ private ListViewer fPolicySetViewer;
+ private Button fNewButton;
+ private Text fNameText;
+ private TextViewer fDescriptionViewer;
+ private CheckboxTableViewer fPoliciesViewer;
+ private Text fIdText;
+ private boolean fPrompt = false;
+ private IUpdatePolicySet fSelectedPolicySet;
+
+ private class PolicySetContentProvider implements IStructuredContentProvider
+ {
+ public Object[] getElements(Object inputElement) {
+ if (inputElement instanceof IUpdatePolicyManager)
+ {
+ IUpdatePolicyManager mgr = (IUpdatePolicyManager)inputElement;
+ IUpdatePolicySet[] sets = mgr.getAllPolicySets();
+ ArrayList retList = new ArrayList();
+
+ for (int i=0; i<sets.length; i++)
+ {
+ if (sets[i].canEdit() || sets[i].canRemove())
+ retList.add(sets[i]);
+ }
+ return retList.toArray();
+ }
+ else if (inputElement instanceof IUpdatePolicySet)
+ {
+ return DebugUITools.getUpdatePolicyManager().getAllPolicies();
+ }
+ return new Object[0];
+ }
+
+ public void dispose() {
+ }
+
+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+ }
+ }
+
+ private class PolicySetLabelProvider implements ILabelProvider
+ {
+
+ public Image getImage(Object element) {
+ return null;
+ }
+
+ public String getText(Object element) {
+ if (element instanceof IUpdatePolicySet)
+ {
+ IUpdatePolicySet set = (IUpdatePolicySet)element;
+ return set.getName();
+ }
+ else if (element instanceof IUpdatePolicy)
+ {
+ IUpdatePolicy policy = (IUpdatePolicy)element;
+ StringBuffer buf = new StringBuffer(policy.getName());
+ buf.append(" - "); //$NON-NLS-1$
+ buf.append(policy.getDescription());
+ return buf.toString();
+ }
+ return null;
+ }
+
+ public void addListener(ILabelProviderListener listener) {
+
+ }
+
+ public void dispose() {
+
+ }
+
+ public boolean isLabelProperty(Object element, String property) {
+ return false;
+ }
+
+ public void removeListener(ILabelProviderListener listener) {
+
+ }
+ }
+
+ protected PolicySetDialog(Shell shell) {
+ super(shell);
+ super.setShellStyle(super.getShellStyle()|SWT.RESIZE);
+ super.setTitle(DebugUIMessages.PolicySetDialog_1);
+ }
+
+ protected Control createDialogArea(Composite parent) {
+
+ SashForm composite = new SashForm(parent, SWT.HORIZONTAL);
+ GridData comositeSpec= new GridData(GridData.FILL_BOTH);
+ comositeSpec.grabExcessVerticalSpace= true;
+ comositeSpec.grabExcessHorizontalSpace= true;
+ comositeSpec.verticalAlignment= GridData.FILL;
+ comositeSpec.widthHint = 600;
+ comositeSpec.heightHint = 500;
+ composite.setLayoutData(comositeSpec);
+
+ createPolicySetPane(composite);
+ createPolicyPane(composite);
+ composite.setWeights(new int[] {30, 70});
+
+ // set initial selection
+ setInitialSelection();
+
+ return composite;
+ }
+
+ private void setInitialSelection() {
+ Object elm = fPolicySetViewer.getElementAt(0);
+ if (elm != null)
+ {
+ fPolicySetViewer.setSelection(new StructuredSelection(elm));
+ }
+ else
+ {
+ fPolicySetViewer.setSelection(StructuredSelection.EMPTY);
+ }
+ }
+
+ private void createPolicyPane(Composite composite) {
+ Group group = new Group(composite, SWT.NONE);
+ GridLayout layout = new GridLayout();
+ layout.numColumns = 2;
+ layout.makeColumnsEqualWidth = false;
+ group.setLayout(layout);
+ group.setText(DebugUIMessages.PolicySetDialog_2);
+ GridData groupData = new GridData(GridData.FILL_BOTH);
+ groupData.horizontalSpan = 2;
+ group.setLayoutData(groupData);
+
+ Label idLabel = new Label(group, SWT.NONE);
+ idLabel.setText(DebugUIMessages.PolicySetDialog_3);
+ GridData idLabelData = new GridData();
+ idLabelData.horizontalAlignment = GridData.HORIZONTAL_ALIGN_BEGINNING;
+ idLabelData.horizontalSpan = 1;
+ idLabel.setLayoutData(idLabelData);
+
+ fIdText = new Text(group, SWT.BORDER);
+ fIdText.setEditable(false);
+ GridData idTextData = new GridData(GridData.FILL_HORIZONTAL);
+ idTextData.horizontalSpan = 1;
+ idTextData.grabExcessHorizontalSpace = true;
+ fIdText.setLayoutData(idTextData);
+
+ Label nameLabel = new Label(group, SWT.NONE);
+ nameLabel.setText(DebugUIMessages.PolicySetDialog_4);
+ GridData nameLabelData = new GridData();
+ nameLabelData.horizontalAlignment = GridData.HORIZONTAL_ALIGN_BEGINNING;
+ nameLabelData.horizontalSpan = 1;
+ nameLabel.setLayoutData(nameLabelData);
+
+ fNameText = new Text(group, SWT.BORDER);
+ fNameText.setText(""); //$NON-NLS-1$
+ GridData nameTextData = new GridData(GridData.FILL_HORIZONTAL);
+ nameTextData.horizontalSpan = 1;
+ nameTextData.grabExcessHorizontalSpace = true;
+ fNameText.setLayoutData(nameTextData);
+
+ fNameText.addKeyListener(new KeyAdapter() {
+ public void keyPressed(KeyEvent e) {
+ fPrompt = true;
+ super.keyPressed(e);
+ }
+ });
+
+ Label descriptionLabel = new Label(group, SWT.NONE);
+ descriptionLabel.setText(DebugUIMessages.PolicySetDialog_6);
+ GridData descriptionLabelData = new GridData(GridData.FILL_HORIZONTAL);
+ descriptionLabelData.horizontalAlignment = GridData.HORIZONTAL_ALIGN_BEGINNING;
+ descriptionLabelData.horizontalSpan = 2;
+ descriptionLabel.setLayoutData(descriptionLabelData);
+
+ fDescriptionViewer = new TextViewer(group, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL);
+ fDescriptionViewer.setDocument(new Document());
+ GridData descriptionTextData = new GridData(GridData.FILL_HORIZONTAL);
+ descriptionTextData.horizontalSpan = 2;
+ descriptionTextData.grabExcessHorizontalSpace = true;
+ descriptionTextData.heightHint = 50;
+ fDescriptionViewer.getControl().setLayoutData(descriptionTextData);
+ fDescriptionViewer.getTextWidget().addKeyListener(new KeyAdapter() {
+ public void keyPressed(KeyEvent e) {
+ fPrompt = true;
+ super.keyPressed(e);
+ }});
+
+ Label policyLabel = new Label(group, SWT.NONE);
+ policyLabel.setText(DebugUIMessages.PolicySetDialog_7);
+ GridData policyLabelData = new GridData();
+ policyLabelData.horizontalAlignment = GridData.HORIZONTAL_ALIGN_BEGINNING;
+ policyLabelData.horizontalSpan = 2;
+ policyLabel.setLayoutData(policyLabelData);
+
+ fPoliciesViewer = CheckboxTableViewer.newCheckList(group, SWT.FILL | SWT.BORDER);
+ GridData policiesData = new GridData(GridData.FILL_BOTH);
+ policiesData.heightHint = 80;
+ policiesData.horizontalSpan = 2;
+ fPoliciesViewer.getControl().setLayoutData(policiesData);
+ fPoliciesViewer.addCheckStateListener(new ICheckStateListener() {
+
+ public void checkStateChanged(CheckStateChangedEvent event) {
+ fPrompt = true;
+ }});
+
+ // TODO: reuse content provider and label provider
+ fPoliciesViewer.setContentProvider(new PolicySetContentProvider());
+ fPoliciesViewer.setLabelProvider(new PolicySetLabelProvider());
+
+ Label filler = new Label(group, SWT.NONE);
+ filler.setText(""); //$NON-NLS-1$
+ GridData fillerData = new GridData();
+ fillerData.horizontalSpan = 1;
+ filler.setLayoutData(fillerData);
+
+ Button fApplyButton = new Button(group, SWT.NONE);
+ fApplyButton.setText(DebugUIMessages.PolicySetDialog_9);
+ GridData applyButtonData = new GridData(GridData.HORIZONTAL_ALIGN_END);
+ applyButtonData.horizontalSpan = 1;
+ fApplyButton.setLayoutData(applyButtonData);
+ fApplyButton.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ performApply();
+ super.widgetSelected(e);
+ }
+ });
+
+ setEditable(true);
+ }
+
+ private void createPolicySetPane(Composite parent)
+ {
+ Composite composite = new Composite(parent, SWT.NONE);
+ GridLayout compositeLayout = new GridLayout();
+ compositeLayout.numColumns = 2;
+ compositeLayout.makeColumnsEqualWidth = false;
+ composite.setLayout(compositeLayout);
+
+ GridData comositeSpec= new GridData(GridData.FILL_BOTH);
+ comositeSpec.grabExcessVerticalSpace= true;
+ comositeSpec.grabExcessHorizontalSpace= true;
+ comositeSpec.verticalAlignment= GridData.FILL;
+ comositeSpec.widthHint = 400;
+ composite.setLayoutData(comositeSpec);
+
+ Label label = new Label(composite, SWT.NONE);
+ GridData labelData = new GridData();
+ labelData.horizontalSpan = 2;
+ label.setText(DebugUIMessages.PolicySetDialog_10);
+ label.setLayoutData(labelData);
+
+ fPolicySetViewer = new ListViewer(composite, SWT.FILL | SWT.BORDER);
+ GridData listLayout = new GridData(GridData.FILL_BOTH);
+ listLayout.horizontalSpan = 2;
+ listLayout.heightHint =140;
+ listLayout.widthHint =140;
+ fPolicySetViewer.getControl().setLayoutData(listLayout);
+ fPolicySetViewer.setContentProvider(new PolicySetContentProvider());
+ fPolicySetViewer.setLabelProvider(new PolicySetLabelProvider());
+ fPolicySetViewer.setInput(DebugUITools.getUpdatePolicyManager());
+ fPolicySetViewer.addSelectionChangedListener(new ISelectionChangedListener() {
+
+ public void selectionChanged(SelectionChangedEvent event) {
+ ISelection selection = fPolicySetViewer.getSelection();
+ if (selection != null && selection instanceof IStructuredSelection)
+ {
+ IStructuredSelection strucSel = (IStructuredSelection)selection;
+ Object elm = strucSel.getFirstElement();
+ if (elm == fSelectedPolicySet)
+ return;
+
+ if (fPrompt)
+ {
+ promtAndSave();
+ }
+
+ if (elm instanceof IUpdatePolicySet)
+ {
+ fSelectedPolicySet = (IUpdatePolicySet)elm;
+ populateDetailedFields((IUpdatePolicySet)elm);
+ }
+ else
+ {
+ fSelectedPolicySet = null;
+ populateDetailedFields(null);
+ }
+ }
+
+ }});
+
+ fNewButton = new Button(composite, SWT.NONE);
+ fNewButton.setText(DebugUIMessages.PolicySetDialog_11);
+ GridData newButtonData = new GridData(GridData.FILL_HORIZONTAL);
+ newButtonData.horizontalSpan = 1;
+ fNewButton.setLayoutData(newButtonData);
+ fNewButton.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ createNewPolicySet();
+ super.widgetSelected(e);
+ }});
+
+ Button removeButton = new Button(composite, SWT.NONE);
+ removeButton.setText(DebugUIMessages.PolicySetDialog_12);
+ GridData removeButtonData = new GridData(GridData.FILL_HORIZONTAL);
+ removeButtonData.horizontalSpan = 1;
+ removeButton.setLayoutData(removeButtonData);
+ removeButton.addSelectionListener(new SelectionAdapter() {
+
+ public void widgetSelected(SelectionEvent e) {
+ ISelection selection = fPolicySetViewer.getSelection();
+ if (selection != null && selection instanceof IStructuredSelection)
+ {
+ Object obj = ((IStructuredSelection)selection).getFirstElement();
+ if (obj != null && obj instanceof IUpdatePolicySet)
+ {
+ removePolicySet((IUpdatePolicySet)obj);
+ }
+ }
+ super.widgetSelected(e);
+ }});
+ }
+
+
+ private void performApply() {
+ // TODO: selection in policy set viewer incorrect after perform apply is called.
+ Object input = fSelectedPolicySet;
+ if (input != null && input instanceof UpdatePolicySet)
+ {
+ // TODO: Look at storing references to IUpdatePolicy in a policy set
+ // instead of storing the ids of the policies
+ // It will simplify this code.
+ UpdatePolicySet set = (UpdatePolicySet)input;
+ String id = fIdText.getText();
+ String name = fNameText.getText();
+ String description = fDescriptionViewer.getTextWidget().getText();
+ Object[] objs = fPoliciesViewer.getCheckedElements();
+ IUpdatePolicy[] policies = new IUpdatePolicy[objs.length];
+ System.arraycopy(objs, 0, policies, 0, objs.length);
+
+ String[] policyIds = new String[policies.length];
+ for (int i=0; i<policyIds.length; i++)
+ policyIds[i] = policies[i].getId();
+ set.init(id, name, description,policyIds);
+
+ IUpdatePolicySet existing = DebugUITools.getUpdatePolicyManager().getPolicySet(id);
+ if (existing != null)
+ {
+ existing.setName(name);
+ existing.setDescription(description);
+ existing.setPolicies(policyIds);
+ DebugUITools.getUpdatePolicyManager().policySetChanged(existing);
+ }
+ }
+ }
+
+ private void setEditable(boolean editable)
+ {
+ fNameText.setEditable(editable);
+ fDescriptionViewer.setEditable(editable);
+ fPoliciesViewer.getControl().setEnabled(editable);
+ }
+
+ private void createNewPolicySet()
+ {
+
+ // find policy set id
+ String[] identifiers = getUniqueIdAndName();
+ String id = identifiers[0];
+
+ // find policy set name
+ String name = identifiers[1];
+
+ // create temp update policy set
+ UpdatePolicySet set = new UpdatePolicySet();
+ set.init(id, name, "", new String[0]); //$NON-NLS-1$
+ fPoliciesViewer.setInput(set);
+ fPoliciesViewer.setAllChecked(false);
+
+ try {
+ DebugUITools.getUpdatePolicyManager().addPolicySet(set);
+ } catch (DebugException e) {
+ DebugUIPlugin.errorDialog(getParentShell(), DebugUIMessages.PolicySetDialog_14, DebugUIMessages.PolicySetDialog_15, e);
+ }
+ }
+
+ private void removePolicySet(IUpdatePolicySet set)
+ {
+ if (set != null)
+ {
+ try {
+ DebugUITools.getUpdatePolicyManager().removePolicySet(set);
+ } catch (DebugException e) {
+ DebugUIPlugin.errorDialog(getParentShell(), DebugUIMessages.PolicySetDialog_16, DebugUIMessages.PolicySetDialog_17, e);
+ }
+ }
+ }
+
+ private void populateDetailedFields(IUpdatePolicySet set)
+ {
+ if (set == null)
+ {
+ // clear fields
+ fIdText.setText(""); //$NON-NLS-1$
+ fNameText.setText(""); //$NON-NLS-1$
+ fDescriptionViewer.getTextWidget().setText(""); //$NON-NLS-1$
+ fPoliciesViewer.setInput(set);
+ }
+ else
+ {
+ fIdText.setText(set.getId());
+ fNameText.setText(set.getName());
+ fDescriptionViewer.getTextWidget().setText(set.getDescription());
+ fPoliciesViewer.setInput(set);
+
+ String[] ids = set.getPolicies();
+ ArrayList policies = new ArrayList();
+ for (int i=0; i<ids.length; i++)
+ {
+ IUpdatePolicy policy = DebugUITools.getUpdatePolicyManager().getPolicy(ids[i]);
+ policies.add(policy);
+ }
+
+ fPoliciesViewer.setCheckedElements(policies.toArray());
+ }
+ }
+
+ private String[] getUniqueIdAndName() {
+ IUpdatePolicySet[] policySets = DebugUITools.getUpdatePolicyManager().getAllPolicySets();
+ int cnt = 1;
+ String prefix = "org.eclipse.debug.ui.user.policySet."; //$NON-NLS-1$
+ String id = prefix + cnt;
+
+ String namePrefix = DebugUIMessages.PolicySetDialog_0;
+ String name = namePrefix + " (" + cnt + ")"; //$NON-NLS-1$ //$NON-NLS-2$
+
+ boolean foundId = false;
+ while (!foundId)
+ {
+ boolean unique = true;
+ for (int i=0; i<policySets.length; i++)
+ {
+ if (policySets[i].getId().equals(id))
+ {
+ unique = false;
+ break;
+ }
+ }
+
+ if (!unique)
+ {
+ foundId = false;
+ cnt ++;
+ id = prefix + cnt;
+ name = namePrefix + " (" + cnt; //$NON-NLS-1$
+ name += ")"; //$NON-NLS-1$
+ }
+ else
+ foundId = true;
+ }
+ return new String[]{id, name};
+ }
+
+ public boolean close() {
+ DebugUITools.getUpdatePolicyManager().removePolicySetListener(this);
+ return super.close();
+ }
+
+ public int open() {
+ DebugUITools.getUpdatePolicyManager().addPolicySetListener(this);
+ return super.open();
+ }
+
+ public void policySetAdded(IUpdatePolicySet set) {
+ fPolicySetViewer.refresh();
+ fPolicySetViewer.setSelection(new StructuredSelection(set));
+ }
+
+ public void policySetRemoved(IUpdatePolicySet set) {
+ fPolicySetViewer.refresh();
+ setInitialSelection();
+ }
+
+ public void policySetChanged(IUpdatePolicySet set) {
+ fPolicySetViewer.refresh();
+ }
+
+ private void promtAndSave() {
+ boolean save = MessageDialog.openQuestion(DebugUIPlugin.getShell(), DebugUIMessages.PolicySetDialog_25, DebugUIMessages.PolicySetDialog_26);
+
+ if (save)
+ {
+ performApply();
+ }
+ fPrompt = false;
+ }
+
+ protected void cancelPressed() {
+
+ if (fPrompt)
+ {
+ promtAndSave();
+ }
+ super.cancelPressed();
+ }
+
+ protected void okPressed() {
+ // save info
+ if (fPrompt)
+ performApply();
+ super.okPressed();
+ }
+
+}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/updatePolicy/UpdatePolicyMgr.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/updatePolicy/UpdatePolicyMgr.java
index 7f918d8ed..8f887073e 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/updatePolicy/UpdatePolicyMgr.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/updatePolicy/UpdatePolicyMgr.java
@@ -20,19 +20,64 @@ import java.util.List;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.core.runtime.IExtensionPoint;
+import org.eclipse.core.runtime.ISafeRunnable;
+import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Platform;
+import org.eclipse.debug.core.DebugException;
+import org.eclipse.debug.internal.ui.DebugUIMessages;
import org.eclipse.debug.internal.ui.DebugUIPlugin;
+import org.eclipse.jface.util.ListenerList;
+// TODO: Need to add code to persist user-defined policy sets
public class UpdatePolicyMgr implements IUpdatePolicyManager {
private static final IUpdatePolicySet[] EMPTY = new IUpdatePolicySet[0];
private static final String ELEMENT_POLICY_SET = "policySet"; //$NON-NLS-1$
private static final String ELEMENT_POLICY = "policy"; //$NON-NLS-1$
+ private static final int ADDED = 0;
+ private static final int REMOVED = 1;
+ private static final int CHANGED = 2;
+
private static IUpdatePolicyManager fgDefault;
private List fPolicySets = new ArrayList();
private Hashtable fPolicies = new Hashtable();
+ private ListenerList fListeners = new ListenerList();
+
+ class NotifyListenersRunnable implements ISafeRunnable
+ {
+ private IUpdatePolicySetListener fListener;
+ private int fEvent;
+ private IUpdatePolicySet fSet;
+
+ NotifyListenersRunnable(IUpdatePolicySetListener listener, int event, IUpdatePolicySet policySet)
+ {
+ fEvent = event;
+ fListener = listener;
+ fSet = policySet;
+ }
+
+ public void handleException(Throwable exception) {
+ DebugUIPlugin.log(exception);
+ }
+
+ public void run() throws Exception {
+ switch (fEvent) {
+ case ADDED:
+ fListener.policySetAdded(fSet);
+ break;
+ case REMOVED:
+ fListener.policySetRemoved(fSet);
+ break;
+ case CHANGED:
+ fListener.policySetChanged(fSet);
+ break;
+ default:
+ break;
+ }
+ }
+ }
public static IUpdatePolicyManager getDefault()
{
@@ -130,4 +175,91 @@ public class UpdatePolicyMgr implements IUpdatePolicyManager {
return null;
}
+ public void addPolicySet(IUpdatePolicySet policySet) throws DebugException{
+
+ validatePolicySet(policySet);
+
+ Iterator iter = fPolicySets.iterator();
+
+ while (iter.hasNext())
+ {
+ IUpdatePolicySet existingSet = (IUpdatePolicySet)iter.next();
+ if (existingSet.getId().equals(policySet.getId()))
+ {
+ IStatus status = DebugUIPlugin.newErrorStatus(DebugUIMessages.UpdatePolicyMgr_0, null);
+ throw new DebugException(status);
+ }
+ }
+
+ fPolicySets.add(policySet);
+ notifyListeners(policySet, ADDED);
+ }
+
+ private void validatePolicySet(IUpdatePolicySet policySet)throws DebugException
+ {
+ if (policySet.getId() == null)
+ {
+ IStatus status = DebugUIPlugin.newErrorStatus(DebugUIMessages.UpdatePolicyMgr_1, null);
+ throw new DebugException(status);
+ }
+
+ if (!policySet.isHidden())
+ {
+ if (policySet.getName() == null)
+ {
+ IStatus status = DebugUIPlugin.newErrorStatus(DebugUIMessages.UpdatePolicyMgr_2, null);
+ throw new DebugException(status);
+ }
+
+ if (policySet.getDescription() == null)
+ {
+ IStatus status = DebugUIPlugin.newErrorStatus(DebugUIMessages.UpdatePolicyMgr_3, null);
+ throw new DebugException(status);
+ }
+ }
+ }
+
+ public void removePolicySet(IUpdatePolicySet policySet) throws DebugException{
+ if (!policySet.canRemove())
+ {
+ IStatus status = DebugUIPlugin.newErrorStatus(DebugUIMessages.UpdatePolicyMgr_4, null);
+ throw new DebugException(status);
+ }
+
+ fPolicySets.remove(policySet);
+ notifyListeners(policySet, REMOVED);
+ }
+
+ public IUpdatePolicySet[] getAllPolicySets() {
+ return (IUpdatePolicySet[])fPolicySets.toArray(new IUpdatePolicySet[fPolicySets.size()]);
+ }
+
+ public void addPolicySetListener(IUpdatePolicySetListener listener) {
+ fListeners.add(listener);
+ }
+
+ public void removePolicySetListener(IUpdatePolicySetListener listener) {
+ fListeners.remove(listener);
+ }
+
+ public void policySetChanged(IUpdatePolicySet policySet) {
+ notifyListeners(policySet, CHANGED);
+ }
+
+ private void notifyListeners(IUpdatePolicySet set, int event)
+ {
+ Object[] listeners = fListeners.getListeners();
+ for (int i=0; i<listeners.length; i++)
+ {
+ if (listeners[i] instanceof IUpdatePolicySetListener)
+ {
+ NotifyListenersRunnable runnable = new NotifyListenersRunnable((IUpdatePolicySetListener)listeners[i], event, set);
+ Platform.run(runnable);
+ }
+ }
+ }
+
+ public IUpdatePolicy[] getAllPolicies() {
+ return (IUpdatePolicy[])fPolicies.values().toArray(new IUpdatePolicy[fPolicies.values().size()]);
+ }
}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/updatePolicy/UpdatePolicySet.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/updatePolicy/UpdatePolicySet.java
index 26b7d9f50..ac438fb71 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/updatePolicy/UpdatePolicySet.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/updatePolicy/UpdatePolicySet.java
@@ -36,19 +36,51 @@ public class UpdatePolicySet implements IUpdatePolicySet{
private IConfigurationElement fConfigurationElement;
private Set fUpdatePolicies;
+ private String fName;
+ private String fDescription;
+ private String fId;
public UpdatePolicySet(IConfigurationElement elm)
{
fConfigurationElement = elm;
}
+ public UpdatePolicySet()
+ {
+ }
+
+ public void init(String id, String name, String description, String[] policies)
+ {
+ fId = id;
+ fName = name;
+ fDescription = description;
+ fUpdatePolicies = new HashSet();
+ for (int i=0; i<policies.length; i++)
+ {
+ fUpdatePolicies.add(policies[i]);
+ }
+ }
+
+ public void setPolicies(String[] policies)
+ {
+ fUpdatePolicies.clear();
+ for (int i=0; i<policies.length; i++)
+ {
+ fUpdatePolicies.add(policies[i]);
+ }
+ }
+
/**
* Validates this contribution.
*
* @exception CoreException if invalid
*/
void validate() throws CoreException {
- verifyPresent(ATTR_MODELID);
+
+ // no need to validate if fConfigurationElement is null
+ if (fConfigurationElement == null)
+ return;
+
verifyPresent(ATTR_ID);
verifyElmPresent(ELMT_POLICY_ID);
@@ -86,6 +118,9 @@ public class UpdatePolicySet implements IUpdatePolicySet{
*/
public String getViewId()
{
+ if (fConfigurationElement == null)
+ return null;
+
return fConfigurationElement.getAttribute(ATTR_VIEWID);
}
@@ -94,6 +129,9 @@ public class UpdatePolicySet implements IUpdatePolicySet{
*/
public String getModelId()
{
+ if (fConfigurationElement == null)
+ return null;
+
return fConfigurationElement.getAttribute(ATTR_MODELID);
}
@@ -107,6 +145,9 @@ public class UpdatePolicySet implements IUpdatePolicySet{
private void initPolicies()
{
+ if (fConfigurationElement == null)
+ return;
+
IConfigurationElement[] configElmts = fConfigurationElement.getChildren(ELMT_POLICY_ID);
fUpdatePolicies = new HashSet();
@@ -123,28 +164,43 @@ public class UpdatePolicySet implements IUpdatePolicySet{
*/
public boolean isApplicable(String viewId, String modelId)
{
- if (getViewId() != null)
+ String setViewId = getViewId();
+ String setModelId = getModelId();
+
+ boolean applicable = true;
+
+ if (setViewId != null)
{
- if (viewId.equals(getViewId()) && modelId.equals(getModelId()))
- return true;
+ if (!setViewId.equals(viewId))
+ applicable = false;
}
- else
+
+ if (setModelId != null)
{
- if (modelId.equals(getModelId()))
- return true;
+ if (!setModelId.equals(modelId))
+ applicable = false;
}
- return false;
+
+ return applicable;
}
public String getName() {
- return fConfigurationElement.getAttribute(ATTR_NAME);
+ if (fName == null && fConfigurationElement != null)
+ fName = fConfigurationElement.getAttribute(ATTR_NAME);
+ return fName;
}
public String getDescription() {
- return fConfigurationElement.getAttribute(ATTR_DESCRIPTION);
+ if (fDescription == null && fConfigurationElement != null)
+ fDescription = fConfigurationElement.getAttribute(ATTR_NAME);
+ return fDescription;
}
public boolean isHidden() {
+
+ if (fConfigurationElement == null)
+ return false;
+
Boolean hidden = new Boolean("false"); //$NON-NLS-1$
if (fConfigurationElement.getAttribute(ATTR_HIDDEN) != null)
{
@@ -155,6 +211,10 @@ public class UpdatePolicySet implements IUpdatePolicySet{
}
public boolean isPrimary() {
+
+ if (fConfigurationElement == null)
+ return false;
+
Boolean hidden = new Boolean("false"); //$NON-NLS-1$
if (fConfigurationElement.getAttribute(ATTR_PRIMARY) != null)
{
@@ -165,7 +225,32 @@ public class UpdatePolicySet implements IUpdatePolicySet{
}
public String getId() {
- return fConfigurationElement.getAttribute(ATTR_ID);
+ if (fId == null && fConfigurationElement != null)
+ fId = fConfigurationElement.getAttribute(ATTR_ID);
+ return fId;
+ }
+
+ public boolean canEdit() {
+ // policy set created by extension point cannot be modified
+ return isUserDefined();
+ }
+
+ public boolean canRemove() {
+ // policy set created by extension point cannot be removed
+ return isUserDefined();
+ }
+
+ public void setName(String name) {
+ fName = name;
+ }
+
+ public void setDescription(String description) {
+ fDescription = description;
+ }
+
+ public boolean isUserDefined()
+ {
+ return fConfigurationElement == null;
}
}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/variables/VariablesView.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/variables/VariablesView.java
index d6a969e99..e43dc9362 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/variables/VariablesView.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/variables/VariablesView.java
@@ -34,7 +34,6 @@ import org.eclipse.debug.core.model.IThread;
import org.eclipse.debug.core.model.IValue;
import org.eclipse.debug.core.model.IVariable;
import org.eclipse.debug.internal.ui.DebugPluginImages;
-import org.eclipse.debug.internal.ui.DebugUIMessages;
import org.eclipse.debug.internal.ui.DebugUIPlugin;
import org.eclipse.debug.internal.ui.DelegatingModelPresentation;
import org.eclipse.debug.internal.ui.IDebugHelpContextIds;
@@ -220,6 +219,7 @@ public class VariablesView extends AbstractDebugViewExtension implements
}
boolean load = false;
+
if (oldContext == null && newContext != null)
{
@@ -228,20 +228,20 @@ public class VariablesView extends AbstractDebugViewExtension implements
else if (oldContext != null && newContext == null)
{
load = true;
+ deactivateModel(oldContext.getModelIdentifier());
}
else if (oldContext != null && newContext != null && !oldContext.equals(newContext))
{
load = true;
+
+ // unload old ones
+ if (!oldContext.getModelIdentifier().equals(newContext.getModelIdentifier()))
+ deactivateModel(oldContext.getModelIdentifier());
}
if (load)
{
- // unload old ones
- if (oldContext != null)
- deactivateModel(oldContext.getModelIdentifier());
- else
- deactivateModel(null);
-
+
// load new ones
if (newContext != null)
{

Back to the top