JBoss Tools SVN: r29016 - trunk/bpel/plugins/org.eclipse.bpel.ui/src/org/eclipse/bpel/ui/properties.
by jbosstools-commits@lists.jboss.org
Author: bbrodt
Date: 2011-02-04 13:36:04 -0500 (Fri, 04 Feb 2011)
New Revision: 29016
Modified:
trunk/bpel/plugins/org.eclipse.bpel.ui/src/org/eclipse/bpel/ui/properties/LiteralAssignCategory.java
Log:
avoid NPE in Assign property page
Modified: trunk/bpel/plugins/org.eclipse.bpel.ui/src/org/eclipse/bpel/ui/properties/LiteralAssignCategory.java
===================================================================
--- trunk/bpel/plugins/org.eclipse.bpel.ui/src/org/eclipse/bpel/ui/properties/LiteralAssignCategory.java 2011-02-04 18:32:19 UTC (rev 29015)
+++ trunk/bpel/plugins/org.eclipse.bpel.ui/src/org/eclipse/bpel/ui/properties/LiteralAssignCategory.java 2011-02-04 18:36:04 UTC (rev 29016)
@@ -1,146 +1,149 @@
-/*******************************************************************************
- * 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.bpel.ui.properties;
-
-import org.eclipse.bpel.common.ui.flatui.FlatFormAttachment;
-import org.eclipse.bpel.common.ui.flatui.FlatFormData;
-import org.eclipse.bpel.model.From;
-import org.eclipse.bpel.model.resource.BPELResource;
-import org.eclipse.bpel.model.util.BPELUtils;
-import org.eclipse.bpel.ui.IBPELUIConstants;
-import org.eclipse.bpel.ui.Messages;
-import org.eclipse.bpel.ui.adapters.IVirtualCopyRuleSide;
-import org.eclipse.bpel.ui.util.BPELUtil;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Text;
-
-
-/**
- * An AssignCategory where the user can type in a literal value (note: NOT an expression).
- *
- * TODO: his could be an XML editor one day ...
- */
-
-public class LiteralAssignCategory extends AssignCategoryBase {
-
- Text fLiteralText;
-
- protected LiteralAssignCategory (BPELPropertySection ownerSection ) {
- super(ownerSection);
- }
-
- /**
- * @see org.eclipse.bpel.ui.properties.IAssignCategory#getName()
- */
-
- @Override
- public String getName() {
- return Messages.LiteralAssignCategory_Fixed_Value_1;
- }
-
- @Override
- protected String getLabelFlatFormatString() {
- return IBPELUIConstants.FORMAT_CMD_EDIT;
- }
-
- @Override
- protected void createClient2(Composite parent) {
- FlatFormData data;
-
-
- fLiteralText = fWidgetFactory.createText(parent, EMPTY_STRING, SWT.V_SCROLL | SWT.MULTI);
- data = new FlatFormData();
- data.left = new FlatFormAttachment(0, 0);
- data.right = new FlatFormAttachment(100, 0);
- //data.top = new FlatFormAttachment(typeComposite, IDetailsAreaConstants.VSPACE);
- data.top = new FlatFormAttachment(0,0);
- data.bottom = new FlatFormAttachment(100, 0);
- fLiteralText.setLayoutData(data);
-
- fChangeHelper.startListeningTo(fLiteralText);
- }
-
-
- /**
- * @see org.eclipse.bpel.ui.properties.IAssignCategory#isCategoryForModel(org.eclipse.emf.ecore.EObject)
- */
-
- @Override
- public boolean isCategoryForModel (EObject aModel) {
- From from = BPELUtil.adapt(aModel, From.class);
- return (from != null && from.getLiteral() != null);
- }
-
- @Override
- protected void load (IVirtualCopyRuleSide aModel) {
-
- From from = BPELUtil.adapt(aModel.getCopyRuleSide(), From.class);
-
- fChangeHelper.startNonUserChange();
- String fromString = EMPTY_STRING;
- if (from != null) {
- fromString = from.getLiteral();
- }
- if (fromString == null) {
- fromString = EMPTY_STRING;
- }
-
- fLiteralText.setText(fromString);
- fChangeHelper.finishNonUserChange();
- }
-
-
- @Override
- protected void store (IVirtualCopyRuleSide aModel) {
-
- From from = BPELUtil.adapt(aModel.getCopyRuleSide(), From.class);
-
- String expr = fLiteralText.getText();
-
- from.setLiteral(expr);
-
- if (expr == null) {
- from.setUnsafeLiteral(Boolean.FALSE);
- } else {
- // test if the unsafe literal can be converted into an element and serialized safely
- if (BPELUtils.convertStringToNode(from, expr, (BPELResource)getBPELEditor().getResource()) != null) {
- from.setUnsafeLiteral(Boolean.TRUE);
- } else {
- from.setUnsafeLiteral(Boolean.FALSE);
- MessageDialog.openWarning(fLiteralText.getShell(),
- Messages.LiteralAssignCategory_Warning_1,
- Messages.LiteralAssignCategory_Literal_not_XML_2);
- }
- }
-
- }
-
- /**
- * @see org.eclipse.bpel.ui.properties.BPELPropertySection#getUserContext()
- */
- @Override
- public Object getUserContext() {
- return null;
- }
-
- /**
- * @see org.eclipse.bpel.ui.properties.BPELPropertySection#restoreUserContext(java.lang.Object)
- */
-
- @Override
- public void restoreUserContext(Object userContext) {
- fLiteralText.setFocus();
- }
-
-}
+/*******************************************************************************
+ * 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.bpel.ui.properties;
+
+import org.eclipse.bpel.common.ui.flatui.FlatFormAttachment;
+import org.eclipse.bpel.common.ui.flatui.FlatFormData;
+import org.eclipse.bpel.model.From;
+import org.eclipse.bpel.model.resource.BPELResource;
+import org.eclipse.bpel.model.util.BPELUtils;
+import org.eclipse.bpel.ui.IBPELUIConstants;
+import org.eclipse.bpel.ui.Messages;
+import org.eclipse.bpel.ui.adapters.IVirtualCopyRuleSide;
+import org.eclipse.bpel.ui.util.BPELUtil;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Text;
+
+
+/**
+ * An AssignCategory where the user can type in a literal value (note: NOT an expression).
+ *
+ * TODO: his could be an XML editor one day ...
+ */
+
+public class LiteralAssignCategory extends AssignCategoryBase {
+
+ Text fLiteralText;
+
+ protected LiteralAssignCategory (BPELPropertySection ownerSection ) {
+ super(ownerSection);
+ }
+
+ /**
+ * @see org.eclipse.bpel.ui.properties.IAssignCategory#getName()
+ */
+
+ @Override
+ public String getName() {
+ return Messages.LiteralAssignCategory_Fixed_Value_1;
+ }
+
+ @Override
+ protected String getLabelFlatFormatString() {
+ return IBPELUIConstants.FORMAT_CMD_EDIT;
+ }
+
+ @Override
+ protected void createClient2(Composite parent) {
+ FlatFormData data;
+
+
+ fLiteralText = fWidgetFactory.createText(parent, EMPTY_STRING, SWT.V_SCROLL | SWT.MULTI);
+ data = new FlatFormData();
+ data.left = new FlatFormAttachment(0, 0);
+ data.right = new FlatFormAttachment(100, 0);
+ //data.top = new FlatFormAttachment(typeComposite, IDetailsAreaConstants.VSPACE);
+ data.top = new FlatFormAttachment(0,0);
+ data.bottom = new FlatFormAttachment(100, 0);
+ fLiteralText.setLayoutData(data);
+
+ fChangeHelper.startListeningTo(fLiteralText);
+ }
+
+
+ /**
+ * @see org.eclipse.bpel.ui.properties.IAssignCategory#isCategoryForModel(org.eclipse.emf.ecore.EObject)
+ */
+
+ @Override
+ public boolean isCategoryForModel (EObject aModel) {
+ From from = BPELUtil.adapt(aModel, From.class);
+ return (from != null && from.getLiteral() != null);
+ }
+
+ @Override
+ protected void load (IVirtualCopyRuleSide aModel) {
+
+ From from = BPELUtil.adapt(aModel.getCopyRuleSide(), From.class);
+
+ fChangeHelper.startNonUserChange();
+ try {
+ String fromString = EMPTY_STRING;
+ if (from != null) {
+ fromString = from.getLiteral();
+ }
+ if (fromString == null) {
+ fromString = EMPTY_STRING;
+ }
+
+ fLiteralText.setText(fromString);
+ } finally {
+ fChangeHelper.finishNonUserChange();
+ }
+ }
+
+
+ @Override
+ protected void store (IVirtualCopyRuleSide aModel) {
+
+ From from = BPELUtil.adapt(aModel.getCopyRuleSide(), From.class);
+
+ String expr = fLiteralText.getText();
+
+ from.setLiteral(expr);
+
+ if (expr == null) {
+ from.setUnsafeLiteral(Boolean.FALSE);
+ } else {
+ // test if the unsafe literal can be converted into an element and serialized safely
+ if (BPELUtils.convertStringToNode(from, expr, (BPELResource)getBPELEditor().getResource()) != null) {
+ from.setUnsafeLiteral(Boolean.TRUE);
+ } else {
+ from.setUnsafeLiteral(Boolean.FALSE);
+ MessageDialog.openWarning(fLiteralText.getShell(),
+ Messages.LiteralAssignCategory_Warning_1,
+ Messages.LiteralAssignCategory_Literal_not_XML_2);
+ }
+ }
+
+ }
+
+ /**
+ * @see org.eclipse.bpel.ui.properties.BPELPropertySection#getUserContext()
+ */
+ @Override
+ public Object getUserContext() {
+ return null;
+ }
+
+ /**
+ * @see org.eclipse.bpel.ui.properties.BPELPropertySection#restoreUserContext(java.lang.Object)
+ */
+
+ @Override
+ public void restoreUserContext(Object userContext) {
+ fLiteralText.setFocus();
+ }
+
+}
13 years, 11 months
JBoss Tools SVN: r29015 - in trunk/bpel/plugins/org.eclipse.bpel.model/src/org/eclipse/bpel/model: resource and 1 other directories.
by jbosstools-commits@lists.jboss.org
Author: bbrodt
Date: 2011-02-04 13:32:19 -0500 (Fri, 04 Feb 2011)
New Revision: 29015
Modified:
trunk/bpel/plugins/org.eclipse.bpel.model/src/org/eclipse/bpel/model/extensions/BPELActivityDeserializer.java
trunk/bpel/plugins/org.eclipse.bpel.model/src/org/eclipse/bpel/model/resource/BPELReader.java
trunk/bpel/plugins/org.eclipse.bpel.model/src/org/eclipse/bpel/model/util/ReconciliationBPELReader.java
trunk/bpel/plugins/org.eclipse.bpel.model/src/org/eclipse/bpel/model/util/ReconciliationHelper.java
Log:
https://issues.jboss.org/browse/JBIDE-8132
Patch copied from eclipse.org/bpel code line.
See also https://bugs.eclipse.org/bugs/show_bug.cgi?id=332926 and https://bugs.eclipse.org/bugs/show_bug.cgi?id=334424
Modified: trunk/bpel/plugins/org.eclipse.bpel.model/src/org/eclipse/bpel/model/extensions/BPELActivityDeserializer.java
===================================================================
--- trunk/bpel/plugins/org.eclipse.bpel.model/src/org/eclipse/bpel/model/extensions/BPELActivityDeserializer.java 2011-02-04 17:33:33 UTC (rev 29014)
+++ trunk/bpel/plugins/org.eclipse.bpel.model/src/org/eclipse/bpel/model/extensions/BPELActivityDeserializer.java 2011-02-04 18:32:19 UTC (rev 29015)
@@ -31,6 +31,9 @@
/**
* This method deserializes elements into instances of classes
* which implement the Activity interface.
+ * https://bugs.eclipse.org/bugs/show_bug.cgi?id=334424
+ * https://issues.jboss.org/browse/JBIDE-8132
+ * Client needs to use the activity if not null
*/
- public Activity unmarshall(QName elementType, Node node, Process process, Map nsMap, ExtensionRegistry extReg, URI uri, BPELReader bpelReader);
+ public Activity unmarshall(QName elementType, Node node, Activity activity, Process process, Map nsMap, ExtensionRegistry extReg, URI uri, BPELReader bpelReader);
}
Modified: trunk/bpel/plugins/org.eclipse.bpel.model/src/org/eclipse/bpel/model/resource/BPELReader.java
===================================================================
--- trunk/bpel/plugins/org.eclipse.bpel.model/src/org/eclipse/bpel/model/resource/BPELReader.java 2011-02-04 17:33:33 UTC (rev 29014)
+++ trunk/bpel/plugins/org.eclipse.bpel.model/src/org/eclipse/bpel/model/resource/BPELReader.java 2011-02-04 18:32:19 UTC (rev 29015)
@@ -2352,48 +2352,50 @@
/**
* Converts an XML extensionactivity element to a BPEL ExtensionActivity object.
*/
- protected Activity xml2ExtensionActivity(Element extensionActivityElement) {
- // Do not call setStandardAttributes here because extensionActivityElement
- // doesn't have them.
+ protected Activity xml2ExtensionActivity(Element extensionActivityElement) {
+ // Do not call setStandardAttributes here because extensionActivityElement
+ // doesn't have them.
+ Activity extensionActivity = BPELFactory.eINSTANCE.createExtensionActivity();
+
+ // Find the child element.
+ List<Element> nodeList = getChildElements(extensionActivityElement);
+
+ if (nodeList.size() == 1) {
+ Element child = nodeList.get(0);
+ // We found a child element. Look up a deserializer for this
+ // activity and call it.
+ String localName = child.getLocalName();
+ String namespace = child.getNamespaceURI();
+ QName qname = new QName(namespace, localName);
+ BPELActivityDeserializer deserializer = extensionRegistry.getActivityDeserializer(qname);
+ if (deserializer != null) {
+ // Deserialize the DOM element and return the new Activity
+ Map<String,String> nsMap = getAllNamespacesForElement(child);
+ // https://bugs.eclipse.org/bugs/show_bug.cgi?id=334424
+ // https://issues.jboss.org/browse/JBIDE-8132
+ extensionActivity = deserializer.unmarshall(qname,child,extensionActivity,process,nsMap,extensionRegistry, getResource().getURI(), this);
+ // Now let's do the standard attributes and elements
+ setStandardAttributes(child, extensionActivity);
+ setStandardElements(child, extensionActivity);
+
+ // Don't do extensibility because extensionActivity is not extensible.
+ // If individual extensionActivity subclasses are actually extensible, they
+ // have to do this themselves in their deserializer.
+
+ // The created Activity that extends from ExtensioActivity should get the
+ // whole <extensionActivity>-DOM-Fragment, this is done here.
+ extensionActivity.setElement(extensionActivityElement);
+ return extensionActivity;
+ }
+ }
+ // Fallback is to create a new extensionActivity.
+ // Bugzilla 324115
+ setStandardAttributes(extensionActivityElement, extensionActivity);
+ setStandardElements(extensionActivityElement, extensionActivity);
+ extensionActivity.setElement(extensionActivityElement);
+ return extensionActivity;
+ }
- // Find the child element.
- List<Element> nodeList = getChildElements(extensionActivityElement);
-
- if (nodeList.size() == 1) {
- Element child = nodeList.get(0);
- // We found a child element. Look up a deserializer for this
- // activity and call it.
- String localName = child.getLocalName();
- String namespace = child.getNamespaceURI();
- QName qname = new QName(namespace, localName);
- BPELActivityDeserializer deserializer = extensionRegistry.getActivityDeserializer(qname);
- if (deserializer != null) {
- // Deserialize the DOM element and return the new Activity
- Map<String,String> nsMap = getAllNamespacesForElement(child);
- Activity activity = deserializer.unmarshall(qname,child,process,nsMap,extensionRegistry,getResource().getURI(), this);
- // Now let's do the standard attributes and elements
- setStandardAttributes(child, activity);
- setStandardElements(child, activity);
-
- // Don't do extensibility because extensionActivity is not extensible.
- // If individual extensionActivity subclasses are actually extensible, they
- // have to do this themselves in their deserializer.
-
- // The created Activity that extends from ExtensioActivity should get the
- // whole <extensionActivity>-DOM-Fragment, this is done here.
- activity.setElement(extensionActivityElement);
- return activity;
- }
- }
- // Fallback is to create a new extensionActivity.
- // https://jira.jboss.org/browse/JBIDE-6917
- Activity activity = BPELFactory.eINSTANCE.createExtensionActivity();
- setStandardAttributes(extensionActivityElement, activity);
- setStandardElements(extensionActivityElement, activity);
- activity.setElement(extensionActivityElement);
- return activity;
- }
-
/**
* Converts an XML wait element to a BPEL Wait object.
Modified: trunk/bpel/plugins/org.eclipse.bpel.model/src/org/eclipse/bpel/model/util/ReconciliationBPELReader.java
===================================================================
--- trunk/bpel/plugins/org.eclipse.bpel.model/src/org/eclipse/bpel/model/util/ReconciliationBPELReader.java 2011-02-04 17:33:33 UTC (rev 29014)
+++ trunk/bpel/plugins/org.eclipse.bpel.model/src/org/eclipse/bpel/model/util/ReconciliationBPELReader.java 2011-02-04 18:32:19 UTC (rev 29015)
@@ -1757,11 +1757,13 @@
} else if (localName.equals("rethrow")) {
activity = xml2Rethrow(activity, activityElement);
} else if (localName.equals("extensionActivity")) {
- // extensionActivity is a special case. It does not have any
- // standard
- // attributes or elements, nor is it an extensible element.
- // Return immediately.
- activity = xml2ExtensionActivity(activityElement);
+ // extensionActivity is a special case. It does not have any
+ // standard attributes or elements, nor is it an extensible
+ // element. Return immediately.
+ // https://bugs.eclipse.org/bugs/show_bug.cgi?id=334424
+ // https://issues.jboss.org/browse/JBIDE-8132
+ // Need to pass the activity in to the deserializer
+ activity = xml2ExtensionActivity(activity,activityElement);
return activity;
} else if (localName.equals("opaqueActivity")) {
activity = xml2OpaqueActivity(activity, activityElement);
@@ -2689,9 +2691,10 @@
/**
* Converts an XML extensionactivity element to a BPEL ExtensionActivity
- * object.
+ * object.
*/
- protected Activity xml2ExtensionActivity(Element extensionActivityElement) {
+ protected Activity xml2ExtensionActivity(Activity extensionActivity,
+ Element extensionActivityElement) {
// Do not call setStandardAttributes here because
// extensionActivityElement
// doesn't have them.
@@ -2710,27 +2713,29 @@
.getActivityDeserializer(qname);
if (deserializer != null) {
// Deserialize the DOM element and return the new Activity
- Map<String, String> nsMap = getAllNamespacesForElement(child);
- Activity activity = deserializer.unmarshall(qname, child,
- process, nsMap, extensionRegistry, getResource()
+ Map<String, String> nsMap = getAllNamespacesForElement(child);
+ // https://bugs.eclipse.org/bugs/show_bug.cgi?id=334424
+ // https://issues.jboss.org/browse/JBIDE-8132
+ // pass the activity that was already created to the serializer
+ extensionActivity = deserializer.unmarshall(qname, child,
+ extensionActivity, process, nsMap, extensionRegistry, getResource()
.getURI(), this);
- // Now let's do the standard attributes and elements
- setStandardAttributes(child, activity);
- setStandardElements(child, activity);
-
- // Don't do extensibility because extensionActivity is not
- // extensible.
- // If individual extensionActivity subclasses are actually
- // extensible, they
- // have to do this themselves in their deserializer.
-
- // The created Activity that extends from ExtensioActivity
- // should get the
- // whole <extensionActivity>-DOM-Fragment, this is done here.
- activity.setElement(extensionActivityElement);
-
- return activity;
+ setStandardAttributes(child, extensionActivity);
+ setStandardElements(child, extensionActivity);
+
+ // Don't do extensibility because extensionActivity is not
+ // extensible.
+ // If individual extensionActivity subclasses are actually
+ // extensible, they
+ // have to do this themselves in their deserializer.
+
+ // The created Activity that extends from ExtensioActivity
+ // should get the
+ // whole <extensionActivity>-DOM-Fragment, this is done here.
+ extensionActivity.setElement(extensionActivityElement);
+
+ return extensionActivity;
}
}
// Fallback is to create a new extensionActivity.
Modified: trunk/bpel/plugins/org.eclipse.bpel.model/src/org/eclipse/bpel/model/util/ReconciliationHelper.java
===================================================================
--- trunk/bpel/plugins/org.eclipse.bpel.model/src/org/eclipse/bpel/model/util/ReconciliationHelper.java 2011-02-04 17:33:33 UTC (rev 29014)
+++ trunk/bpel/plugins/org.eclipse.bpel.model/src/org/eclipse/bpel/model/util/ReconciliationHelper.java 2011-02-04 18:32:19 UTC (rev 29015)
@@ -215,6 +215,10 @@
// https://issues.jboss.org/browse/JBIDE-8048
// this was left out inadevertently
reader.xml2CompensationHandler((CompensationHandler)element, changedElement);
+ } else if (element instanceof ExtensibleElement){
+ // https://bugs.eclipse.org/bugs/show_bug.cgi?id=334424
+ // https://issues.jboss.org/browse/JBIDE-8132
+ reader.xml2ExtensibleElement((ExtensibleElement)element, changedElement);
} else {
System.err.println("Cannot reconcile: " + element.getClass());
// throw new NotImplementedException(element.getClass().toString());
13 years, 11 months
JBoss Tools SVN: r29014 - in trunk/deltacloud/plugins: org.jboss.tools.deltacloud.integration/src/org/jboss/tools/deltacloud/integration/wizard and 9 other directories.
by jbosstools-commits@lists.jboss.org
Author: adietish
Date: 2011-02-04 12:33:33 -0500 (Fri, 04 Feb 2011)
New Revision: 29014
Added:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/utils/LayoutUtils.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/utils/WorkbenchUtils.java
Removed:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/utils/ContentProposalFactory.java
Modified:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.integration/src/org/jboss/tools/deltacloud/integration/rse/util/RSEUtils.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.integration/src/org/jboss/tools/deltacloud/integration/rse/util/ShowInRemoteSystemExplorerHandler.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.integration/src/org/jboss/tools/deltacloud/integration/wizard/CreateRSEFromInstanceJob.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.integration/src/org/jboss/tools/deltacloud/integration/wizard/RSEandASWizardPage.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/ChangeLog
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/IDeltaCloudPreferenceConstants.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/adapter/DeltaCloudInstanceAdapterFactory.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/commands/AbstractInstanceHandler.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/commands/CreateInstanceFromAnyImageHandler.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/commands/CreateInstanceFromSpecificImageHandler.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/commands/DeleteCloudHandler.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/commands/DeltaCloudInstanceDialog.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/commands/DeltaCloudInstancePropertyTester.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/commands/DeltaCloudPropertyTester.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/commands/DestroyInstanceHandler.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/commands/EditConnectionHandler.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/commands/FilterImagesHandler.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/commands/FilterInstancesHandler.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/commands/ManageKeysHandler.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/commands/RebootInstanceHandler.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/commands/RefreshCloudHandler.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/commands/StartInstanceHandler.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/commands/StopInstanceHandler.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/DeltaCloudView.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/cnf/CloudViewActionProvider.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/cnf/CloudViewActionUtil.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloudelements/AbstractCloudElementTableView.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/utils/UIUtils.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/CloudConnectionPage.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/ManageKeysPage.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/NewInstancePage.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/NewInstanceWizard.java
Log:
[JBIDE-8295] added confirmatino dialog when stopping instances
Modified: trunk/deltacloud/plugins/org.jboss.tools.deltacloud.integration/src/org/jboss/tools/deltacloud/integration/rse/util/RSEUtils.java
===================================================================
--- trunk/deltacloud/plugins/org.jboss.tools.deltacloud.integration/src/org/jboss/tools/deltacloud/integration/rse/util/RSEUtils.java 2011-02-04 16:44:52 UTC (rev 29013)
+++ trunk/deltacloud/plugins/org.jboss.tools.deltacloud.integration/src/org/jboss/tools/deltacloud/integration/rse/util/RSEUtils.java 2011-02-04 17:33:33 UTC (rev 29014)
@@ -36,7 +36,7 @@
import org.jboss.tools.deltacloud.integration.DeltaCloudIntegrationPlugin;
import org.jboss.tools.deltacloud.integration.Messages;
import org.jboss.tools.deltacloud.integration.wizard.CreateServerFromRSEJob;
-import org.jboss.tools.internal.deltacloud.ui.utils.UIUtils;
+import org.jboss.tools.internal.deltacloud.ui.utils.WorkbenchUtils;
/**
* @author André Dietisheim
@@ -182,14 +182,14 @@
@Override
public void run() {
try {
- UIUtils.showView(VIEW_REMOTESYSEXPLORER_ID);
+ WorkbenchUtils.showView(VIEW_REMOTESYSEXPLORER_ID);
} catch (PartInitException e) {
// I have no idea wtf is wrong here
// but my dev environment will not let me use common classes
// IStatus status = StatusFactory.getInstance(IStatus.ERROR,
// DeltaCloudIntegrationPlugin.PLUGIN_ID, e.getMessage(), e);
Status status = new Status(IStatus.ERROR, DeltaCloudIntegrationPlugin.PLUGIN_ID, e.getMessage(), e);
- ErrorDialog.openError(UIUtils.getActiveShell(),
+ ErrorDialog.openError(WorkbenchUtils.getActiveShell(),
Messages.ERROR,
Messages.COULD_NOT_LAUNCH_RSE_EXPLORER,
status);
Modified: trunk/deltacloud/plugins/org.jboss.tools.deltacloud.integration/src/org/jboss/tools/deltacloud/integration/rse/util/ShowInRemoteSystemExplorerHandler.java
===================================================================
--- trunk/deltacloud/plugins/org.jboss.tools.deltacloud.integration/src/org/jboss/tools/deltacloud/integration/rse/util/ShowInRemoteSystemExplorerHandler.java 2011-02-04 16:44:52 UTC (rev 29013)
+++ trunk/deltacloud/plugins/org.jboss.tools.deltacloud.integration/src/org/jboss/tools/deltacloud/integration/rse/util/ShowInRemoteSystemExplorerHandler.java 2011-02-04 17:33:33 UTC (rev 29014)
@@ -24,7 +24,7 @@
import org.jboss.tools.deltacloud.core.DeltaCloudInstance;
import org.jboss.tools.deltacloud.integration.DeltaCloudIntegrationPlugin;
import org.jboss.tools.deltacloud.integration.Messages;
-import org.jboss.tools.internal.deltacloud.ui.utils.UIUtils;
+import org.jboss.tools.internal.deltacloud.ui.utils.WorkbenchUtils;
/**
* @author Andre Dietisheim
@@ -35,7 +35,7 @@
public Object execute(ExecutionEvent event) throws ExecutionException {
ISelection selection = HandlerUtil.getCurrentSelection(event);
if (selection instanceof IStructuredSelection) {
- DeltaCloudInstance instance = UIUtils.getFirstAdaptedElement(selection, DeltaCloudInstance.class);
+ DeltaCloudInstance instance = WorkbenchUtils.getFirstAdaptedElement(selection, DeltaCloudInstance.class);
try {
String connectionName = RSEUtils.createConnectionName(instance);
IHost host = RSEUtils.createHost(connectionName,
Modified: trunk/deltacloud/plugins/org.jboss.tools.deltacloud.integration/src/org/jboss/tools/deltacloud/integration/wizard/CreateRSEFromInstanceJob.java
===================================================================
--- trunk/deltacloud/plugins/org.jboss.tools.deltacloud.integration/src/org/jboss/tools/deltacloud/integration/wizard/CreateRSEFromInstanceJob.java 2011-02-04 16:44:52 UTC (rev 29013)
+++ trunk/deltacloud/plugins/org.jboss.tools.deltacloud.integration/src/org/jboss/tools/deltacloud/integration/wizard/CreateRSEFromInstanceJob.java 2011-02-04 17:33:33 UTC (rev 29014)
@@ -19,8 +19,6 @@
import org.eclipse.core.runtime.preferences.InstanceScope;
import org.eclipse.osgi.util.NLS;
import org.eclipse.rse.core.model.IHost;
-import org.eclipse.rse.core.subsystems.IConnectorService;
-import org.eclipse.rse.services.clientserver.messages.SystemMessageException;
import org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFileSubSystem;
import org.eclipse.swt.widgets.Display;
import org.jboss.tools.deltacloud.core.DeltaCloudInstance;
Modified: trunk/deltacloud/plugins/org.jboss.tools.deltacloud.integration/src/org/jboss/tools/deltacloud/integration/wizard/RSEandASWizardPage.java
===================================================================
--- trunk/deltacloud/plugins/org.jboss.tools.deltacloud.integration/src/org/jboss/tools/deltacloud/integration/wizard/RSEandASWizardPage.java 2011-02-04 16:44:52 UTC (rev 29013)
+++ trunk/deltacloud/plugins/org.jboss.tools.deltacloud.integration/src/org/jboss/tools/deltacloud/integration/wizard/RSEandASWizardPage.java 2011-02-04 17:33:33 UTC (rev 29014)
@@ -38,6 +38,7 @@
import org.jboss.tools.deltacloud.core.DeltaCloudInstance;
import org.jboss.tools.deltacloud.integration.DeltaCloudIntegrationPlugin;
import org.jboss.tools.deltacloud.ui.wizard.INewInstanceWizardPage;
+import org.jboss.tools.internal.deltacloud.ui.utils.LayoutUtils;
import org.jboss.tools.internal.deltacloud.ui.utils.UIUtils;
import org.osgi.service.prefs.BackingStoreException;
@@ -86,37 +87,37 @@
c2.setLayout(new FormLayout());
createRSE = new Button(c2, SWT.CHECK);
createRSE.setText("Create RSE Connection");
- createRSE.setLayoutData(UIUtils.createFormData(0, 5, null, 0, 0, 5, 100, -5));
+ createRSE.setLayoutData(LayoutUtils.createFormData(0, 5, null, 0, 0, 5, 100, -5));
createServer = new Button(c2, SWT.CHECK);
createServer.setText("Create Server Adapter");
- createServer.setLayoutData(UIUtils.createFormData(createRSE, 5, null, 0, 0, 5, 100, -5));
+ createServer.setLayoutData(LayoutUtils.createFormData(createRSE, 5, null, 0, 0, 5, 100, -5));
Group g = new Group(c2, SWT.SHADOW_IN);
serverDetailsGroup = g;
g.setLayout(new FormLayout());
- g.setLayoutData(UIUtils.createFormData(createServer, 5, null, 0, 0, 5, 100, -5));
+ g.setLayoutData(LayoutUtils.createFormData(createServer, 5, null, 0, 0, 5, 100, -5));
g.setText("Server Details");
final int INDENTATION = 40;
autoScanCheck = new Button(g, SWT.RADIO);
autoScanCheck.setText("Determine server details from this remote file:");
- autoScanCheck.setLayoutData(UIUtils.createFormData(0, 5, null, 0, 0, 5, null, 0));
+ autoScanCheck.setLayoutData(LayoutUtils.createFormData(0, 5, null, 0, 0, 5, null, 0));
autoScanCheck.setSelection(true);
remoteDetailsLoc = new Text(g, SWT.BORDER);
- remoteDetailsLoc.setLayoutData(UIUtils.createFormData(autoScanCheck, 5, null, 0, 0, INDENTATION, 100, -5));
+ remoteDetailsLoc.setLayoutData(LayoutUtils.createFormData(autoScanCheck, 5, null, 0, 0, INDENTATION, 100, -5));
remoteDetailsLoc.setText("./.jboss");
this.remoteDetailsLocDeco = UIUtils.createErrorDecoration(REMOTE_DETAILS_LOC_ERROR, remoteDetailsLoc);
autoLocalRuntimeLabel = new Label(g, SWT.NONE);
autoLocalRuntimeLabel.setText("Local Runtime: ");
- autoLocalRuntimeLabel.setLayoutData(UIUtils.createFormData(remoteDetailsLoc, 7, null, 0, 0, INDENTATION, null,
+ autoLocalRuntimeLabel.setLayoutData(LayoutUtils.createFormData(remoteDetailsLoc, 7, null, 0, 0, INDENTATION, null,
0));
autoAddLocalRuntimeButton = new Button(g, SWT.DEFAULT);
autoAddLocalRuntimeButton.setText("Configure Runtimes...");
- autoAddLocalRuntimeButton.setLayoutData(UIUtils.createFormData(remoteDetailsLoc, 7, null, 0, null, 0, 100, -5));
+ autoAddLocalRuntimeButton.setLayoutData(LayoutUtils.createFormData(remoteDetailsLoc, 7, null, 0, null, 0, 100, -5));
autoAddLocalRuntimeButton.addSelectionListener(new SelectionListener() {
public void widgetSelected(SelectionEvent e) {
configureRuntimesPressed();
@@ -126,37 +127,37 @@
}
});
autoLocalRuntimeCombo = new Combo(g, SWT.READ_ONLY);
- autoLocalRuntimeCombo.setLayoutData(UIUtils.createFormData(remoteDetailsLoc, 5, null, 0, autoLocalRuntimeLabel,
+ autoLocalRuntimeCombo.setLayoutData(LayoutUtils.createFormData(remoteDetailsLoc, 5, null, 0, autoLocalRuntimeLabel,
10, autoAddLocalRuntimeButton, -5));
this.autoLocalRuntimeDeco = UIUtils.createErrorDecoration(SELECT_RUNTIME_ERROR, autoLocalRuntimeCombo);
hardCodeServerDetails = new Button(g, SWT.RADIO);
hardCodeServerDetails.setText("Set remote server details manually");
- hardCodeServerDetails.setLayoutData(UIUtils.createFormData(autoLocalRuntimeCombo, 5, null, 0, 0, 10, null, 0));
+ hardCodeServerDetails.setLayoutData(LayoutUtils.createFormData(autoLocalRuntimeCombo, 5, null, 0, 0, 10, null, 0));
serverHome = new Label(g, SWT.NONE);
serverHome.setText("JBoss Server Home: ");
- serverHome.setLayoutData(UIUtils.createFormData(hardCodeServerDetails, 7, null, 0, 0, INDENTATION, null, 0));
+ serverHome.setLayoutData(LayoutUtils.createFormData(hardCodeServerDetails, 7, null, 0, 0, INDENTATION, null, 0));
serverHomeText = new Text(g, SWT.BORDER);
- serverHomeText.setLayoutData(UIUtils.createFormData(hardCodeServerDetails, 5, null, 0, serverHome, 10, 100, -5));
+ serverHomeText.setLayoutData(LayoutUtils.createFormData(hardCodeServerDetails, 5, null, 0, serverHome, 10, 100, -5));
serverHomeText.setText("/etc/jboss/jboss-as");
this.serverHomeDeco = UIUtils.createErrorDecoration(SERVER_HOME_ERROR, serverHomeText);
serverConfig = new Label(g, SWT.NONE);
serverConfig.setText("Configuration: ");
- serverConfig.setLayoutData(UIUtils.createFormData(serverHomeText, 7, null, 0, 0, INDENTATION, null, 0));
+ serverConfig.setLayoutData(LayoutUtils.createFormData(serverHomeText, 7, null, 0, 0, INDENTATION, null, 0));
serverConfigText = new Text(g, SWT.BORDER);
- serverConfigText.setLayoutData(UIUtils.createFormData(serverHomeText, 5, null, 0, serverHome, 10, 100, -5));
+ serverConfigText.setLayoutData(LayoutUtils.createFormData(serverHomeText, 5, null, 0, serverHome, 10, 100, -5));
serverConfigText.setText("default");
this.serverConfigDeco = UIUtils.createErrorDecoration(SERVER_CONFIG_ERROR, serverConfigText);
localRuntimeLabel = new Label(g, SWT.NONE);
localRuntimeLabel.setText("Local Runtime: ");
- localRuntimeLabel.setLayoutData(UIUtils.createFormData(serverConfigText, 7, null, 0, 0, INDENTATION, null, 0));
+ localRuntimeLabel.setLayoutData(LayoutUtils.createFormData(serverConfigText, 7, null, 0, 0, INDENTATION, null, 0));
addLocalRuntimeButton = new Button(g, SWT.DEFAULT);
addLocalRuntimeButton.setText("Configure Runtimes...");
- addLocalRuntimeButton.setLayoutData(UIUtils.createFormData(serverConfigText, 7, null, 0, null, 0, 100, -5));
+ addLocalRuntimeButton.setLayoutData(LayoutUtils.createFormData(serverConfigText, 7, null, 0, null, 0, 100, -5));
addLocalRuntimeButton.addSelectionListener(new SelectionListener() {
public void widgetSelected(SelectionEvent e) {
configureRuntimesPressed();
@@ -166,24 +167,24 @@
}
});
localRuntimeCombo = new Combo(g, SWT.READ_ONLY);
- localRuntimeCombo.setLayoutData(UIUtils.createFormData(serverConfigText, 5, null, 0, serverHome, 10,
+ localRuntimeCombo.setLayoutData(LayoutUtils.createFormData(serverConfigText, 5, null, 0, serverHome, 10,
addLocalRuntimeButton, -5));
this.localRuntimeDeco = UIUtils.createErrorDecoration(SELECT_RUNTIME_ERROR, localRuntimeCombo);
deployOnlyRadio = new Button(g, SWT.RADIO);
deployOnlyRadio.setText("Use a deploy-only server adapter");
- deployOnlyRadio.setLayoutData(UIUtils.createFormData(localRuntimeCombo, 5, null, 0, 0, 5, null, 0));
+ deployOnlyRadio.setLayoutData(LayoutUtils.createFormData(localRuntimeCombo, 5, null, 0, 0, 5, null, 0));
deployFolder = new Label(g, SWT.NONE);
deployFolder.setText("Deploy Folder: ");
- deployFolder.setLayoutData(UIUtils.createFormData(deployOnlyRadio, 7, null, 0, 0, INDENTATION, null, 0));
+ deployFolder.setLayoutData(LayoutUtils.createFormData(deployOnlyRadio, 7, null, 0, 0, INDENTATION, null, 0));
deployFolderText = new Text(g, SWT.BORDER);
deployFolderText.setText("/path/to/deploy");
- deployFolderText.setLayoutData(UIUtils.createFormData(deployOnlyRadio, 5, null, 0, deployFolder, 10, 100, -5));
+ deployFolderText.setLayoutData(LayoutUtils.createFormData(deployOnlyRadio, 5, null, 0, deployFolder, 10, 100, -5));
this.deployFolderDeco = UIUtils.createErrorDecoration(DEPLOY_FOLDER_NOT_EMPTY, deployFolderText);
Label dummyLabel = new Label(g, SWT.NONE);
- dummyLabel.setLayoutData(UIUtils.createFormData(deployOnlyRadio, 5, null, 0, deployFolderText, 10, 100, -5));
+ dummyLabel.setLayoutData(LayoutUtils.createFormData(deployOnlyRadio, 5, null, 0, deployFolderText, 10, 100, -5));
IEclipsePreferences prefs = new InstanceScope().getNode(DeltaCloudIntegrationPlugin.PLUGIN_ID);
boolean initRSE, initServer;
Modified: trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/ChangeLog
===================================================================
--- trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/ChangeLog 2011-02-04 16:44:52 UTC (rev 29013)
+++ trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/ChangeLog 2011-02-04 17:33:33 UTC (rev 29014)
@@ -1,3 +1,15 @@
+2011-02-04 André Dietisheim <André Dietisheim@adietisheim-thinkpad>
+
+ * src/org/jboss/tools/deltacloud/ui/commands/StopInstanceHandler.java
+ (stopInstances):
+ (stopInstances):
+ [JBIDE-8295] added confirmatino dialog when stopping instances
+ * src/org/jboss/tools/internal/deltacloud/ui/wizards/ImageFilterPage.java
+ (validate):
+ (validate):
+ (createControl):
+ [JBIDE-8332] added field decorations to FilterImage- and FilterInstance-dialogs
+
2011-02-03 André Dietisheim <André Dietisheim@adietisheim-thinkpad>
* src/org/jboss/tools/deltacloud/ui/views/cloudelements/InstanceView.java (propertyChange):
Modified: trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/IDeltaCloudPreferenceConstants.java
===================================================================
--- trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/IDeltaCloudPreferenceConstants.java 2011-02-04 16:44:52 UTC (rev 29013)
+++ trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/IDeltaCloudPreferenceConstants.java 2011-02-04 17:33:33 UTC (rev 29014)
@@ -13,6 +13,7 @@
public interface IDeltaCloudPreferenceConstants {
public final static String DONT_CONFIRM_CREATE_INSTANCE = "dont_confirm_create_instance"; //$NON-NLS-1$
+ public final static String DONT_CONFIRM_STOP_INSTANCE = "dont_confirm_stop_instance"; //$NON-NLS-1$
public final static String AUTO_CONNECT_INSTANCE = "auto_connect_instance"; //$NON-NLS-1$
public final static String LAST_EC2_KEYNAME = "last_ec2_keyname"; //$NON-NLS-1$
public final static String DEFAULT_KEY_DIR = "default_key_directory"; //$NON-NLS-1$
Modified: trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/adapter/DeltaCloudInstanceAdapterFactory.java
===================================================================
--- trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/adapter/DeltaCloudInstanceAdapterFactory.java 2011-02-04 16:44:52 UTC (rev 29013)
+++ trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/adapter/DeltaCloudInstanceAdapterFactory.java 2011-02-04 17:33:33 UTC (rev 29014)
@@ -13,7 +13,7 @@
import org.eclipse.core.runtime.IAdapterFactory;
import org.jboss.tools.deltacloud.core.DeltaCloud;
import org.jboss.tools.deltacloud.core.DeltaCloudInstance;
-import org.jboss.tools.internal.deltacloud.ui.utils.UIUtils;
+import org.jboss.tools.internal.deltacloud.ui.utils.WorkbenchUtils;
public class DeltaCloudInstanceAdapterFactory implements IAdapterFactory {
@@ -28,7 +28,7 @@
if (adaptableObject instanceof DeltaCloudInstance) {
return ((DeltaCloudInstance) adaptableObject).getDeltaCloud();
} else {
- return UIUtils.adapt(adaptableObject, DeltaCloud.class);
+ return WorkbenchUtils.adapt(adaptableObject, DeltaCloud.class);
}
}
Modified: trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/commands/AbstractInstanceHandler.java
===================================================================
--- trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/commands/AbstractInstanceHandler.java 2011-02-04 16:44:52 UTC (rev 29013)
+++ trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/commands/AbstractInstanceHandler.java 2011-02-04 17:33:33 UTC (rev 29014)
@@ -18,7 +18,7 @@
import org.jboss.tools.deltacloud.core.client.utils.StringUtils;
import org.jboss.tools.deltacloud.core.client.utils.StringUtils.IElementFormatter;
import org.jboss.tools.deltacloud.core.job.InstanceActionJob;
-import org.jboss.tools.internal.deltacloud.ui.utils.UIUtils;
+import org.jboss.tools.internal.deltacloud.ui.utils.WorkbenchUtils;
/**
* A base handler that instance related handler may extend
@@ -36,7 +36,7 @@
}
protected boolean isSingleInstanceSelected(ISelection selection) {
- return UIUtils.isSingleSelection(selection, DeltaCloudInstance.class);
+ return WorkbenchUtils.isSingleSelection(selection, DeltaCloudInstance.class);
}
@SuppressWarnings("unchecked")
Modified: trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/commands/CreateInstanceFromAnyImageHandler.java
===================================================================
--- trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/commands/CreateInstanceFromAnyImageHandler.java 2011-02-04 16:44:52 UTC (rev 29013)
+++ trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/commands/CreateInstanceFromAnyImageHandler.java 2011-02-04 17:33:33 UTC (rev 29014)
@@ -21,7 +21,7 @@
import org.eclipse.jface.wizard.WizardDialog;
import org.eclipse.ui.handlers.HandlerUtil;
import org.jboss.tools.deltacloud.core.DeltaCloud;
-import org.jboss.tools.internal.deltacloud.ui.utils.UIUtils;
+import org.jboss.tools.internal.deltacloud.ui.utils.WorkbenchUtils;
import org.jboss.tools.internal.deltacloud.ui.wizards.NewInstanceWizard;
/**
@@ -34,9 +34,9 @@
public Object execute(ExecutionEvent event) throws ExecutionException {
ISelection selection = HandlerUtil.getCurrentSelection(event);
if (selection instanceof IStructuredSelection) {
- DeltaCloud cloud = UIUtils.getFirstAdaptedElement(selection, DeltaCloud.class);
+ DeltaCloud cloud = WorkbenchUtils.getFirstAdaptedElement(selection, DeltaCloud.class);
IWizard wizard = new NewInstanceWizard(cloud);
- WizardDialog dialog = new WizardDialog(UIUtils.getActiveWorkbenchWindow().getShell(),
+ WizardDialog dialog = new WizardDialog(WorkbenchUtils.getActiveWorkbenchWindow().getShell(),
wizard);
dialog.create();
dialog.open();
Modified: trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/commands/CreateInstanceFromSpecificImageHandler.java
===================================================================
--- trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/commands/CreateInstanceFromSpecificImageHandler.java 2011-02-04 16:44:52 UTC (rev 29013)
+++ trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/commands/CreateInstanceFromSpecificImageHandler.java 2011-02-04 17:33:33 UTC (rev 29014)
@@ -23,7 +23,7 @@
import org.eclipse.ui.handlers.HandlerUtil;
import org.jboss.tools.deltacloud.core.DeltaCloud;
import org.jboss.tools.deltacloud.core.DeltaCloudImage;
-import org.jboss.tools.internal.deltacloud.ui.utils.UIUtils;
+import org.jboss.tools.internal.deltacloud.ui.utils.WorkbenchUtils;
import org.jboss.tools.internal.deltacloud.ui.wizards.NewInstanceWizard;
/**
@@ -35,7 +35,7 @@
public Object execute(ExecutionEvent event) throws ExecutionException {
ISelection selection = HandlerUtil.getCurrentSelection(event);
if (selection instanceof IStructuredSelection) {
- DeltaCloudImage deltaCloudImage = UIUtils.getFirstAdaptedElement(selection, DeltaCloudImage.class);
+ DeltaCloudImage deltaCloudImage = WorkbenchUtils.getFirstAdaptedElement(selection, DeltaCloudImage.class);
createInstance(deltaCloudImage, HandlerUtil.getActiveShell(event));
}
Modified: trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/commands/DeleteCloudHandler.java
===================================================================
--- trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/commands/DeleteCloudHandler.java 2011-02-04 16:44:52 UTC (rev 29013)
+++ trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/commands/DeleteCloudHandler.java 2011-02-04 17:33:33 UTC (rev 29014)
@@ -38,7 +38,7 @@
import org.jboss.tools.deltacloud.core.DeltaCloudManager;
import org.jboss.tools.deltacloud.ui.ErrorUtils;
import org.jboss.tools.deltacloud.ui.views.CVMessages;
-import org.jboss.tools.internal.deltacloud.ui.utils.UIUtils;
+import org.jboss.tools.internal.deltacloud.ui.utils.WorkbenchUtils;
/**
* @author Andre Dietisheim
@@ -138,7 +138,7 @@
DeltaCloud deltaCloud = null;
if (selectedElements.size() > 0) {
Object object = selectedElements.get(0);
- deltaCloud = UIUtils.adapt(object, DeltaCloud.class);
+ deltaCloud = WorkbenchUtils.adapt(object, DeltaCloud.class);
}
return deltaCloud;
}
@@ -146,7 +146,7 @@
private Collection<DeltaCloud> getSelectedClouds(List<?> selectedElements) {
Set<DeltaCloud> selectedClouds = new HashSet<DeltaCloud>();
for (Object element : selectedElements) {
- DeltaCloud deltaCloud = UIUtils.adapt(element, DeltaCloud.class);
+ DeltaCloud deltaCloud = WorkbenchUtils.adapt(element, DeltaCloud.class);
if (deltaCloud != null) {
selectedClouds.add(deltaCloud);
}
Modified: trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/commands/DeltaCloudInstanceDialog.java
===================================================================
--- trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/commands/DeltaCloudInstanceDialog.java 2011-02-04 16:44:52 UTC (rev 29013)
+++ trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/commands/DeltaCloudInstanceDialog.java 2011-02-04 17:33:33 UTC (rev 29014)
@@ -18,7 +18,7 @@
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.dialogs.ListSelectionDialog;
import org.jboss.tools.deltacloud.core.DeltaCloudInstance;
-import org.jboss.tools.internal.deltacloud.ui.utils.UIUtils;
+import org.jboss.tools.internal.deltacloud.ui.utils.WorkbenchUtils;
/**
* A dialog that allows the user to select CVInstanceElements
@@ -29,7 +29,7 @@
private static class DeltaCloudInstanceNameProvider extends LabelProvider {
public String getText(Object element) {
- DeltaCloudInstance instance = UIUtils.adapt(element, DeltaCloudInstance.class);
+ DeltaCloudInstance instance = WorkbenchUtils.adapt(element, DeltaCloudInstance.class);
if (instance != null) {
return instance.getName();
} else {
Modified: trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/commands/DeltaCloudInstancePropertyTester.java
===================================================================
--- trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/commands/DeltaCloudInstancePropertyTester.java 2011-02-04 16:44:52 UTC (rev 29013)
+++ trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/commands/DeltaCloudInstancePropertyTester.java 2011-02-04 17:33:33 UTC (rev 29014)
@@ -13,7 +13,7 @@
import org.eclipse.core.expressions.PropertyTester;
import org.eclipse.core.runtime.Assert;
import org.jboss.tools.deltacloud.core.DeltaCloudInstance;
-import org.jboss.tools.internal.deltacloud.ui.utils.UIUtils;
+import org.jboss.tools.internal.deltacloud.ui.utils.WorkbenchUtils;
/**
* A property tester for the command framework that answers if the given
@@ -31,7 +31,7 @@
@Override
public boolean test(Object receiver, String property, Object[] args, Object expectedValue) {
- DeltaCloudInstance instance = UIUtils.adapt(receiver, DeltaCloudInstance.class);
+ DeltaCloudInstance instance = WorkbenchUtils.adapt(receiver, DeltaCloudInstance.class);
if (instance == null) {
return false;
}
Modified: trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/commands/DeltaCloudPropertyTester.java
===================================================================
--- trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/commands/DeltaCloudPropertyTester.java 2011-02-04 16:44:52 UTC (rev 29013)
+++ trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/commands/DeltaCloudPropertyTester.java 2011-02-04 17:33:33 UTC (rev 29014)
@@ -15,7 +15,7 @@
import org.jboss.tools.deltacloud.core.DeltaCloud;
import org.jboss.tools.deltacloud.core.DeltaCloudException;
import org.jboss.tools.deltacloud.core.DeltaCloudImage;
-import org.jboss.tools.internal.deltacloud.ui.utils.UIUtils;
+import org.jboss.tools.internal.deltacloud.ui.utils.WorkbenchUtils;
/**
* A property tester for the command framework that answers if the given
@@ -30,7 +30,7 @@
@Override
public boolean test(Object receiver, String property, Object[] args, Object expectedValue) {
- DeltaCloud cloud = UIUtils.adapt(receiver, DeltaCloud.class);
+ DeltaCloud cloud = WorkbenchUtils.adapt(receiver, DeltaCloud.class);
if (cloud == null) {
return false;
}
Modified: trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/commands/DestroyInstanceHandler.java
===================================================================
--- trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/commands/DestroyInstanceHandler.java 2011-02-04 16:44:52 UTC (rev 29013)
+++ trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/commands/DestroyInstanceHandler.java 2011-02-04 17:33:33 UTC (rev 29014)
@@ -26,7 +26,7 @@
import org.jboss.tools.deltacloud.core.job.DestroyCloudInstanceJob;
import org.jboss.tools.deltacloud.ui.Activator;
import org.jboss.tools.deltacloud.ui.views.CVMessages;
-import org.jboss.tools.internal.deltacloud.ui.utils.UIUtils;
+import org.jboss.tools.internal.deltacloud.ui.utils.WorkbenchUtils;
/**
* @author Andre Dietisheim
@@ -41,7 +41,7 @@
try {
if (selection instanceof IStructuredSelection) {
if (isSingleInstanceSelected(selection)) {
- DeltaCloudInstance cvInstance = UIUtils.getFirstAdaptedElement(selection, DeltaCloudInstance.class);
+ DeltaCloudInstance cvInstance = WorkbenchUtils.getFirstAdaptedElement(selection, DeltaCloudInstance.class);
destroyInstance(cvInstance);
} else {
destroyWithDialog((IStructuredSelection) selection);
@@ -59,10 +59,10 @@
@SuppressWarnings("unchecked")
private void destroyWithDialog(IStructuredSelection selection) {
List<DeltaCloudInstance> deltaCloudInstances =
- UIUtils.adapt((List<DeltaCloudInstance>) selection.toList(),DeltaCloudInstance.class);
+ WorkbenchUtils.adapt((List<DeltaCloudInstance>) selection.toList(),DeltaCloudInstance.class);
List<DeltaCloudInstance> destroyableInstances = getDestroyableInstances(deltaCloudInstances);
DeltaCloudInstanceDialog dialog = new DeltaCloudInstanceDialog(
- UIUtils.getActiveShell()
+ WorkbenchUtils.getActiveShell()
, destroyableInstances
, CVMessages.getString(DESTROY_INSTANCE_TITLE)
, CVMessages.getString(DESTROY_INSTANCE_MSG));
Modified: trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/commands/EditConnectionHandler.java
===================================================================
--- trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/commands/EditConnectionHandler.java 2011-02-04 16:44:52 UTC (rev 29013)
+++ trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/commands/EditConnectionHandler.java 2011-02-04 17:33:33 UTC (rev 29014)
@@ -21,7 +21,7 @@
import org.eclipse.jface.wizard.WizardDialog;
import org.eclipse.ui.handlers.HandlerUtil;
import org.jboss.tools.deltacloud.core.DeltaCloud;
-import org.jboss.tools.internal.deltacloud.ui.utils.UIUtils;
+import org.jboss.tools.internal.deltacloud.ui.utils.WorkbenchUtils;
import org.jboss.tools.internal.deltacloud.ui.wizards.EditCloudConnectionWizard;
/**
@@ -33,10 +33,10 @@
public Object execute(ExecutionEvent event) throws ExecutionException {
ISelection selection = HandlerUtil.getCurrentSelection(event);
if (selection instanceof IStructuredSelection) {
- DeltaCloud cloud = UIUtils.getFirstAdaptedElement(selection, DeltaCloud.class);
+ DeltaCloud cloud = WorkbenchUtils.getFirstAdaptedElement(selection, DeltaCloud.class);
if (cloud != null) {
IWizard wizard = new EditCloudConnectionWizard(cloud);
- WizardDialog dialog = new WizardDialog(UIUtils.getActiveWorkbenchWindow().getShell(), wizard);
+ WizardDialog dialog = new WizardDialog(WorkbenchUtils.getActiveWorkbenchWindow().getShell(), wizard);
dialog.create();
dialog.open();
}
Modified: trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/commands/FilterImagesHandler.java
===================================================================
--- trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/commands/FilterImagesHandler.java 2011-02-04 16:44:52 UTC (rev 29013)
+++ trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/commands/FilterImagesHandler.java 2011-02-04 17:33:33 UTC (rev 29014)
@@ -21,8 +21,8 @@
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.handlers.HandlerUtil;
import org.jboss.tools.deltacloud.core.DeltaCloud;
-import org.jboss.tools.internal.deltacloud.ui.utils.UIUtils;
import org.jboss.tools.internal.deltacloud.ui.utils.WizardUtils;
+import org.jboss.tools.internal.deltacloud.ui.utils.WorkbenchUtils;
import org.jboss.tools.internal.deltacloud.ui.wizards.ImageFilterWizard;
/**
@@ -34,7 +34,7 @@
public Object execute(ExecutionEvent event) throws ExecutionException {
ISelection selection = HandlerUtil.getCurrentSelection(event);
if (selection instanceof IStructuredSelection) {
- DeltaCloud cloud = UIUtils.getFirstAdaptedElement(selection, DeltaCloud.class);
+ DeltaCloud cloud = WorkbenchUtils.getFirstAdaptedElement(selection, DeltaCloud.class);
createImagesFilter(cloud, HandlerUtil.getActiveShell(event));
}
Modified: trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/commands/FilterInstancesHandler.java
===================================================================
--- trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/commands/FilterInstancesHandler.java 2011-02-04 16:44:52 UTC (rev 29013)
+++ trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/commands/FilterInstancesHandler.java 2011-02-04 17:33:33 UTC (rev 29014)
@@ -21,8 +21,8 @@
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.handlers.HandlerUtil;
import org.jboss.tools.deltacloud.core.DeltaCloud;
-import org.jboss.tools.internal.deltacloud.ui.utils.UIUtils;
import org.jboss.tools.internal.deltacloud.ui.utils.WizardUtils;
+import org.jboss.tools.internal.deltacloud.ui.utils.WorkbenchUtils;
import org.jboss.tools.internal.deltacloud.ui.wizards.InstanceFilterWizard;
/**
@@ -34,7 +34,7 @@
public Object execute(ExecutionEvent event) throws ExecutionException {
ISelection selection = HandlerUtil.getCurrentSelection(event);
if (selection instanceof IStructuredSelection) {
- DeltaCloud deltaCloud = UIUtils.getFirstAdaptedElement(selection, DeltaCloud.class);
+ DeltaCloud deltaCloud = WorkbenchUtils.getFirstAdaptedElement(selection, DeltaCloud.class);
createInstancesFilter(deltaCloud, HandlerUtil.getActiveShell(event));
}
Modified: trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/commands/ManageKeysHandler.java
===================================================================
--- trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/commands/ManageKeysHandler.java 2011-02-04 16:44:52 UTC (rev 29013)
+++ trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/commands/ManageKeysHandler.java 2011-02-04 17:33:33 UTC (rev 29014)
@@ -21,8 +21,8 @@
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.handlers.HandlerUtil;
import org.jboss.tools.deltacloud.core.DeltaCloud;
-import org.jboss.tools.internal.deltacloud.ui.utils.UIUtils;
import org.jboss.tools.internal.deltacloud.ui.utils.WizardUtils;
+import org.jboss.tools.internal.deltacloud.ui.utils.WorkbenchUtils;
import org.jboss.tools.internal.deltacloud.ui.wizards.ManageKeysWizard;
/**
@@ -34,7 +34,7 @@
public Object execute(ExecutionEvent event) throws ExecutionException {
ISelection selection = HandlerUtil.getCurrentSelection(event);
if (selection instanceof IStructuredSelection) {
- DeltaCloud cloud = UIUtils.getFirstAdaptedElement(selection, DeltaCloud.class);
+ DeltaCloud cloud = WorkbenchUtils.getFirstAdaptedElement(selection, DeltaCloud.class);
createImagesFilter(cloud, HandlerUtil.getActiveShell(event));
}
Modified: trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/commands/RebootInstanceHandler.java
===================================================================
--- trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/commands/RebootInstanceHandler.java 2011-02-04 16:44:52 UTC (rev 29013)
+++ trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/commands/RebootInstanceHandler.java 2011-02-04 17:33:33 UTC (rev 29014)
@@ -25,7 +25,7 @@
import org.jboss.tools.deltacloud.core.DeltaCloudInstance;
import org.jboss.tools.deltacloud.ui.Activator;
import org.jboss.tools.deltacloud.ui.views.CVMessages;
-import org.jboss.tools.internal.deltacloud.ui.utils.UIUtils;
+import org.jboss.tools.internal.deltacloud.ui.utils.WorkbenchUtils;
/**
* @author Andre Dietisheim
@@ -44,7 +44,7 @@
try {
if (selection instanceof IStructuredSelection) {
if (isSingleInstanceSelected(selection)) {
- DeltaCloudInstance cvInstance = UIUtils.getFirstAdaptedElement(selection, DeltaCloudInstance.class);
+ DeltaCloudInstance cvInstance = WorkbenchUtils.getFirstAdaptedElement(selection, DeltaCloudInstance.class);
rebootInstance(cvInstance);
} else {
rebootWithDialog((IStructuredSelection) selection);
@@ -60,10 +60,10 @@
@SuppressWarnings("unchecked")
private void rebootWithDialog(IStructuredSelection selection) {
- List<DeltaCloudInstance> deltaCloudInstances = UIUtils.adapt((List<DeltaCloudInstance>) selection.toList(), DeltaCloudInstance.class);
+ List<DeltaCloudInstance> deltaCloudInstances = WorkbenchUtils.adapt((List<DeltaCloudInstance>) selection.toList(), DeltaCloudInstance.class);
List<DeltaCloudInstance> rebootableInstances = getRebootableInstances(deltaCloudInstances);
DeltaCloudInstanceDialog dialog = new DeltaCloudInstanceDialog(
- UIUtils.getActiveShell()
+ WorkbenchUtils.getActiveShell()
, rebootableInstances
, CVMessages.getString(REBOOT_INSTANCE_TITLE)
, CVMessages.getString(REBOOT_INSTANCE_MSG));
Modified: trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/commands/RefreshCloudHandler.java
===================================================================
--- trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/commands/RefreshCloudHandler.java 2011-02-04 16:44:52 UTC (rev 29013)
+++ trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/commands/RefreshCloudHandler.java 2011-02-04 17:33:33 UTC (rev 29014)
@@ -28,7 +28,7 @@
import org.jboss.tools.deltacloud.core.DeltaCloudMultiException;
import org.jboss.tools.deltacloud.core.job.AbstractCloudJob;
import org.jboss.tools.deltacloud.ui.ErrorUtils;
-import org.jboss.tools.internal.deltacloud.ui.utils.UIUtils;
+import org.jboss.tools.internal.deltacloud.ui.utils.WorkbenchUtils;
/**
* @author Andre Dietisheim
@@ -43,7 +43,7 @@
refresh(clouds);
} else {
// no item selected: try active part
- refresh(UIUtils.adapt(HandlerUtil.getActivePart(event), DeltaCloud.class));
+ refresh(WorkbenchUtils.adapt(HandlerUtil.getActivePart(event), DeltaCloud.class));
}
return Status.OK_STATUS;
}
@@ -53,7 +53,7 @@
return Collections.emptyList();
}
- return UIUtils.adapt(((IStructuredSelection) selection).toList(), DeltaCloud.class);
+ return WorkbenchUtils.adapt(((IStructuredSelection) selection).toList(), DeltaCloud.class);
}
private void refresh(Collection<DeltaCloud> clouds) {
Modified: trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/commands/StartInstanceHandler.java
===================================================================
--- trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/commands/StartInstanceHandler.java 2011-02-04 16:44:52 UTC (rev 29013)
+++ trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/commands/StartInstanceHandler.java 2011-02-04 17:33:33 UTC (rev 29014)
@@ -26,7 +26,7 @@
import org.jboss.tools.deltacloud.core.DeltaCloudInstance;
import org.jboss.tools.deltacloud.ui.Activator;
import org.jboss.tools.deltacloud.ui.views.CVMessages;
-import org.jboss.tools.internal.deltacloud.ui.utils.UIUtils;
+import org.jboss.tools.internal.deltacloud.ui.utils.WorkbenchUtils;
/**
* @author Andre Dietisheim
@@ -44,7 +44,7 @@
try {
if (selection instanceof IStructuredSelection) {
if (isSingleInstanceSelected(selection)) {
- DeltaCloudInstance cvinstance = UIUtils.getFirstAdaptedElement(selection, DeltaCloudInstance.class);
+ DeltaCloudInstance cvinstance = WorkbenchUtils.getFirstAdaptedElement(selection, DeltaCloudInstance.class);
startInstance(cvinstance);
} else {
startWithDialog((IStructuredSelection) selection);
@@ -61,10 +61,10 @@
@SuppressWarnings("unchecked")
private void startWithDialog(IStructuredSelection selection) {
- List<DeltaCloudInstance> deltaCloudInstances = UIUtils.adapt((List<DeltaCloudInstance>) selection.toList(), DeltaCloudInstance.class);
+ List<DeltaCloudInstance> deltaCloudInstances = WorkbenchUtils.adapt((List<DeltaCloudInstance>) selection.toList(), DeltaCloudInstance.class);
List<DeltaCloudInstance> stoppedInstances = getStoppedInstances(deltaCloudInstances);
DeltaCloudInstanceDialog dialog = new DeltaCloudInstanceDialog(
- UIUtils.getActiveShell()
+ WorkbenchUtils.getActiveShell()
, stoppedInstances
, CVMessages.getString(START_INSTANCES_DIALOG_TITLE)
, CVMessages.getString(START_INSTANCES_DIALOG_MSG));
Modified: trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/commands/StopInstanceHandler.java
===================================================================
--- trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/commands/StopInstanceHandler.java 2011-02-04 16:44:52 UTC (rev 29013)
+++ trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/commands/StopInstanceHandler.java 2011-02-04 17:33:33 UTC (rev 29014)
@@ -24,8 +24,10 @@
import org.jboss.tools.common.log.StatusFactory;
import org.jboss.tools.deltacloud.core.DeltaCloudInstance;
import org.jboss.tools.deltacloud.ui.Activator;
+import org.jboss.tools.deltacloud.ui.IDeltaCloudPreferenceConstants;
import org.jboss.tools.deltacloud.ui.views.CVMessages;
import org.jboss.tools.internal.deltacloud.ui.utils.UIUtils;
+import org.jboss.tools.internal.deltacloud.ui.utils.WorkbenchUtils;
/**
* @author Andre Dietisheim
@@ -43,7 +45,8 @@
try {
if (selection instanceof IStructuredSelection) {
if (isSingleInstanceSelected(selection)) {
- DeltaCloudInstance instance = UIUtils.getFirstAdaptedElement(selection, DeltaCloudInstance.class);
+ DeltaCloudInstance instance = WorkbenchUtils.getFirstAdaptedElement(selection,
+ DeltaCloudInstance.class);
stopInstance(instance);
} else {
stopWithDialog((IStructuredSelection) selection);
@@ -59,11 +62,12 @@
@SuppressWarnings("unchecked")
private void stopWithDialog(IStructuredSelection selection) {
- List<DeltaCloudInstance> deltaCloudInstances = UIUtils.adapt((List<DeltaCloudInstance>) selection.toList(),
+ List<DeltaCloudInstance> deltaCloudInstances = WorkbenchUtils.adapt(
+ (List<DeltaCloudInstance>) selection.toList(),
DeltaCloudInstance.class);
List<DeltaCloudInstance> stoppableInstances = getStoppableInstances(deltaCloudInstances);
DeltaCloudInstanceDialog dialog = new DeltaCloudInstanceDialog(
- UIUtils.getActiveShell()
+ WorkbenchUtils.getActiveShell()
, stoppableInstances
, CVMessages.getString(STOP_INSTANCES_DIALOG_TITLE)
, CVMessages.getString(STOP_INSTANCES_DIALOG_MSG));
@@ -84,19 +88,41 @@
}
private void stopInstances(Object[] deltaCloudInstances) {
- for (int i = 0; i < deltaCloudInstances.length; i++) {
- stopInstance((DeltaCloudInstance) deltaCloudInstances[i]);
+ if (askUserToConfirm()) {
+ for (int i = 0; i < deltaCloudInstances.length; i++) {
+ stopInstance((DeltaCloudInstance) deltaCloudInstances[i]);
+ }
}
}
private void stopInstance(DeltaCloudInstance instance) {
if (instance != null) {
+ if (askUserToConfirm()) {
+ doStopInstance(instance);
+ }
+ }
+ }
+
+ private void doStopInstance(DeltaCloudInstance instance) {
+ if (instance != null) {
executeInstanceAction(
- instance
- , DeltaCloudInstance.Action.STOP
- , DeltaCloudInstance.State.STOPPED
- , CVMessages.getString(STOPPING_INSTANCE_TITLE)
- , CVMessages.getFormattedString(STOPPING_INSTANCE_MSG, new String[] { instance.getName() }));
+ instance
+ , DeltaCloudInstance.Action.STOP
+ , DeltaCloudInstance.State.STOPPED
+ , CVMessages.getString(STOPPING_INSTANCE_TITLE)
+ , CVMessages.getFormattedString(STOPPING_INSTANCE_MSG, new String[] { instance.getName() }));
}
}
+
+ private boolean askUserToConfirm() {
+ return UIUtils
+ .openConfirmationDialog(
+ "Confirm instance stop",
+ "You are about to stop a running system(s), that might be in production. Are you sure that you want to stop the given instance(s)?",
+ "Don't warn me again",
+ IDeltaCloudPreferenceConstants.DONT_CONFIRM_CREATE_INSTANCE,
+ Activator.PLUGIN_ID,
+ WorkbenchUtils.getActiveShell());
+ }
+
}
Modified: trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/DeltaCloudView.java
===================================================================
--- trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/DeltaCloudView.java 2011-02-04 16:44:52 UTC (rev 29013)
+++ trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/DeltaCloudView.java 2011-02-04 17:33:33 UTC (rev 29014)
@@ -25,7 +25,7 @@
import org.jboss.tools.deltacloud.ui.SWTImagesFactory;
import org.jboss.tools.deltacloud.ui.views.CVMessages;
import org.jboss.tools.deltacloud.ui.views.cloud.property.CVPropertySheetPage;
-import org.jboss.tools.internal.deltacloud.ui.utils.UIUtils;
+import org.jboss.tools.internal.deltacloud.ui.utils.WorkbenchUtils;
public class DeltaCloudView extends ViewPart implements ITabbedPropertySheetPageContributor {
@@ -63,8 +63,8 @@
}
private void hookContextMenu(Control control) {
- IMenuManager contextMenu = UIUtils.createContextMenu(control);
- UIUtils.registerContributionManager(UIUtils.getContextMenuId(ID), contextMenu, control);
+ IMenuManager contextMenu = WorkbenchUtils.createContextMenu(control);
+ WorkbenchUtils.registerContributionManager(WorkbenchUtils.getContextMenuId(ID), contextMenu, control);
}
private void contributeToActionBars() {
Modified: trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/cnf/CloudViewActionProvider.java
===================================================================
--- trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/cnf/CloudViewActionProvider.java 2011-02-04 16:44:52 UTC (rev 29013)
+++ trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/cnf/CloudViewActionProvider.java 2011-02-04 17:33:33 UTC (rev 29014)
@@ -1,7 +1,5 @@
package org.jboss.tools.deltacloud.ui.views.cloud.cnf;
-import java.io.ObjectInputStream.GetField;
-
import org.eclipse.jface.action.Action;
import org.eclipse.jface.action.GroupMarker;
import org.eclipse.jface.action.IMenuManager;
@@ -24,7 +22,7 @@
import org.jboss.tools.deltacloud.core.DeltaCloud;
import org.jboss.tools.deltacloud.core.DeltaCloudInstance;
import org.jboss.tools.deltacloud.ui.SWTImagesFactory;
-import org.jboss.tools.internal.deltacloud.ui.utils.UIUtils;
+import org.jboss.tools.internal.deltacloud.ui.utils.WorkbenchUtils;
import org.jboss.tools.internal.deltacloud.ui.wizards.EditCloudConnectionWizard;
import org.jboss.tools.internal.deltacloud.ui.wizards.ImageFilterWizard;
import org.jboss.tools.internal.deltacloud.ui.wizards.InstanceFilterWizard;
@@ -146,7 +144,7 @@
editConnectionAction = new Action() {
public void run() {
- DeltaCloud cloud = UIUtils.getFirstAdaptedElement(getSelection(), DeltaCloud.class);
+ DeltaCloud cloud = WorkbenchUtils.getFirstAdaptedElement(getSelection(), DeltaCloud.class);
if (cloud != null) {
IWizard wizard = new EditCloudConnectionWizard(cloud);
WizardDialog dialog = new WizardDialog(shell, wizard);
@@ -219,7 +217,7 @@
filterImageAction = new Action() {
public void run() {
- DeltaCloud cloud = UIUtils.getFirstAdaptedElement(getSelection(), DeltaCloud.class);
+ DeltaCloud cloud = WorkbenchUtils.getFirstAdaptedElement(getSelection(), DeltaCloud.class);
if( cloud != null ) {
IWizard wizard = new ImageFilterWizard(cloud);
WizardDialog dialog = new WizardDialog(shell, wizard);
@@ -233,7 +231,7 @@
filterInstanceAction = new Action() {
public void run() {
- DeltaCloud cloud = UIUtils.getFirstAdaptedElement(getSelection(), DeltaCloud.class);
+ DeltaCloud cloud = WorkbenchUtils.getFirstAdaptedElement(getSelection(), DeltaCloud.class);
if( cloud != null ) {
IWizard wizard = new InstanceFilterWizard(cloud);
WizardDialog dialog = new WizardDialog(shell, wizard);
Modified: trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/cnf/CloudViewActionUtil.java
===================================================================
--- trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/cnf/CloudViewActionUtil.java 2011-02-04 16:44:52 UTC (rev 29013)
+++ trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloud/cnf/CloudViewActionUtil.java 2011-02-04 17:33:33 UTC (rev 29014)
@@ -26,7 +26,7 @@
import org.jboss.tools.deltacloud.ui.commands.DeleteCloudHandler.DeleteCloudsDialog;
import org.jboss.tools.deltacloud.ui.commands.DeltaCloudInstanceDialog;
import org.jboss.tools.deltacloud.ui.views.CVMessages;
-import org.jboss.tools.internal.deltacloud.ui.utils.UIUtils;
+import org.jboss.tools.internal.deltacloud.ui.utils.WorkbenchUtils;
import org.jboss.tools.internal.deltacloud.ui.wizards.NewInstanceWizard;
public class CloudViewActionUtil {
@@ -87,7 +87,7 @@
if(instances.length > 1 ) {
List<DeltaCloudInstance> list = Arrays.asList(instances);
DeltaCloudInstanceDialog dialog = new DeltaCloudInstanceDialog(
- UIUtils.getActiveShell(), list,
+ WorkbenchUtils.getActiveShell(), list,
dialogTitle, dialogMsg);
dialog.setInitialElementSelections(list);
if (Dialog.OK == dialog.open()) {
@@ -151,15 +151,15 @@
public static List<DeltaCloudInstance> getCloudInstances(ISelection selection) {
if( selection instanceof IStructuredSelection ) {
IStructuredSelection s2 = (IStructuredSelection)selection;
- List<DeltaCloudInstance> instances = UIUtils.adapt(s2.toList(),DeltaCloudInstance.class);
+ List<DeltaCloudInstance> instances = WorkbenchUtils.adapt(s2.toList(),DeltaCloudInstance.class);
return instances;
}
- return Collections.EMPTY_LIST;
+ return Collections.emptyList();
}
public static void showCreateInstanceWizard(Shell shell, ISelection selection) {
- DeltaCloudImage deltaCloudImage = UIUtils.getFirstAdaptedElement(selection, DeltaCloudImage.class);
- DeltaCloud deltaCloud = UIUtils.getFirstAdaptedElement(selection, DeltaCloud.class);
+ DeltaCloudImage deltaCloudImage = WorkbenchUtils.getFirstAdaptedElement(selection, DeltaCloudImage.class);
+ DeltaCloud deltaCloud = WorkbenchUtils.getFirstAdaptedElement(selection, DeltaCloud.class);
IWizard wizard = new NewInstanceWizard(deltaCloud, deltaCloudImage);
WizardDialog dialog = new WizardDialog(shell, wizard);
dialog.create();
@@ -197,7 +197,7 @@
List<?> selectedElements = ((IStructuredSelection) selection).toList();
Set<DeltaCloud> selectedClouds = new HashSet<DeltaCloud>();
for (Object element : selectedElements) {
- DeltaCloud deltaCloud = UIUtils.adapt(element, DeltaCloud.class);
+ DeltaCloud deltaCloud = WorkbenchUtils.adapt(element, DeltaCloud.class);
if (deltaCloud != null) {
selectedClouds.add(deltaCloud);
}
Modified: trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloudelements/AbstractCloudElementTableView.java
===================================================================
--- trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloudelements/AbstractCloudElementTableView.java 2011-02-04 16:44:52 UTC (rev 29013)
+++ trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloudelements/AbstractCloudElementTableView.java 2011-02-04 17:33:33 UTC (rev 29014)
@@ -56,7 +56,7 @@
import org.jboss.tools.deltacloud.ui.views.Columns;
import org.jboss.tools.deltacloud.ui.views.Columns.Column;
import org.jboss.tools.internal.deltacloud.ui.preferences.StringPreferenceValue;
-import org.jboss.tools.internal.deltacloud.ui.utils.UIUtils;
+import org.jboss.tools.internal.deltacloud.ui.utils.WorkbenchUtils;
/**
* A common superclass for viewers that operate on IDeltaCloudElements
@@ -118,7 +118,7 @@
public void selectionChanged(IWorkbenchPart part, ISelection selection) {
// we want to listen to selection changes in the deltacloud view
// only
- DeltaCloud cloud = UIUtils.getFirstAdaptedElement(selection, DeltaCloud.class);
+ DeltaCloud cloud = WorkbenchUtils.getFirstAdaptedElement(selection, DeltaCloud.class);
if (isNewCloud(cloud)) {
int index = getCloudIndex(cloud, getClouds());
currentCloudSelector.select(index);
@@ -339,8 +339,8 @@
}
private void hookContextMenu(Control control) {
- IMenuManager contextMenu = UIUtils.createContextMenu(control);
- UIUtils.registerContributionManager(UIUtils.getContextMenuId(getViewID()), contextMenu, control);
+ IMenuManager contextMenu = WorkbenchUtils.createContextMenu(control);
+ WorkbenchUtils.registerContributionManager(WorkbenchUtils.getContextMenuId(getViewID()), contextMenu, control);
}
protected abstract String getViewID();
Deleted: trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/utils/ContentProposalFactory.java
===================================================================
--- trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/utils/ContentProposalFactory.java 2011-02-04 16:44:52 UTC (rev 29013)
+++ trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/utils/ContentProposalFactory.java 2011-02-04 17:33:33 UTC (rev 29014)
@@ -1,73 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010 Red Hat, Inc.
- * Distributed under license by Red Hat, Inc. All rights reserved.
- * This program is 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:
- * Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
-package org.jboss.tools.internal.deltacloud.ui.utils;
-
-import org.eclipse.jface.bindings.keys.KeyStroke;
-import org.eclipse.jface.fieldassist.ContentProposalAdapter;
-import org.eclipse.jface.fieldassist.ControlDecoration;
-import org.eclipse.jface.fieldassist.FieldDecorationRegistry;
-import org.eclipse.jface.fieldassist.SimpleContentProposalProvider;
-import org.eclipse.jface.fieldassist.TextContentAdapter;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.FocusAdapter;
-import org.eclipse.swt.events.FocusEvent;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Text;
-import org.jboss.tools.deltacloud.ui.Activator;
-import org.jboss.tools.internal.deltacloud.ui.preferences.StringsPreferenceValue;
-
-/**
- * @author André Dietisheim
- */
-public class ContentProposalFactory {
-
- public static ContentProposalAdapter addPreferencesProposalAdapter(final Text text, String preferencesKey) {
- final ControlDecoration decoration = createContenAssistDecoration(text);
-
- final StringsPreferenceValue preferencesValues =
- new StringsPreferenceValue(',', preferencesKey, Activator.PLUGIN_ID);
- SimpleContentProposalProvider proposalProvider = new SimpleContentProposalProvider(preferencesValues.get());
- proposalProvider.setFiltering(true);
- text.addFocusListener(new FocusAdapter() {
-
- @Override
- public void focusGained(FocusEvent e) {
- decoration.show();
- }
-
- @Override
- public void focusLost(FocusEvent e) {
- decoration.hide();
-
- preferencesValues.add(text.getText());
- preferencesValues.store();
- }
-
- });
- KeyStroke keyStroke = KeyStroke.getInstance(SWT.CONTROL, ' ');
- ContentProposalAdapter proposalAdapter =
- new ContentProposalAdapter(text, new TextContentAdapter(), proposalProvider, keyStroke, null);
- proposalAdapter.setProposalAcceptanceStyle(ContentProposalAdapter.PROPOSAL_REPLACE);
- return proposalAdapter;
- }
-
- private static ControlDecoration createContenAssistDecoration(Control control) {
- ControlDecoration decoration = new ControlDecoration(control, SWT.RIGHT | SWT.TOP);
- Image errorImage = FieldDecorationRegistry.getDefault()
- .getFieldDecoration(FieldDecorationRegistry.DEC_CONTENT_PROPOSAL).getImage();
- decoration.setImage(errorImage);
- decoration.setDescriptionText("History available");
- decoration.setShowHover(true);
- decoration.hide();
- return decoration;
- }
-}
Added: trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/utils/LayoutUtils.java
===================================================================
--- trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/utils/LayoutUtils.java (rev 0)
+++ trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/utils/LayoutUtils.java 2011-02-04 17:33:33 UTC (rev 29014)
@@ -0,0 +1,55 @@
+/*******************************************************************************
+ * Copyright (c) 2010 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is 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:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.internal.deltacloud.ui.utils;
+
+import org.eclipse.swt.layout.FormAttachment;
+import org.eclipse.swt.layout.FormData;
+import org.eclipse.swt.widgets.Control;
+
+/**
+ * @author Rob Stryker
+ */
+public class LayoutUtils {
+
+ /**
+ * This method has been stolen from AS-Tools' UIUtil class and is useful for
+ * creating FormData objects
+ */
+ public static FormData createFormData(
+ Object topStart, int topOffset,
+ Object bottomStart, int bottomOffset,
+ Object leftStart, int leftOffset,
+ Object rightStart, int rightOffset) {
+
+ FormData data = new FormData();
+
+ if (topStart != null) {
+ data.top = topStart instanceof Control ? new FormAttachment((Control) topStart, topOffset) :
+ new FormAttachment(((Integer) topStart).intValue(), topOffset);
+ }
+
+ if (bottomStart != null) {
+ data.bottom = bottomStart instanceof Control ? new FormAttachment((Control) bottomStart, bottomOffset) :
+ new FormAttachment(((Integer) bottomStart).intValue(), bottomOffset);
+ }
+
+ if (leftStart != null) {
+ data.left = leftStart instanceof Control ? new FormAttachment((Control) leftStart, leftOffset) :
+ new FormAttachment(((Integer) leftStart).intValue(), leftOffset);
+ }
+
+ if (rightStart != null) {
+ data.right = rightStart instanceof Control ? new FormAttachment((Control) rightStart, rightOffset) :
+ new FormAttachment(((Integer) rightStart).intValue(), rightOffset);
+ }
+ return data;
+ }
+}
Property changes on: trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/utils/LayoutUtils.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/utils/UIUtils.java
===================================================================
--- trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/utils/UIUtils.java 2011-02-04 16:44:52 UTC (rev 29013)
+++ trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/utils/UIUtils.java 2011-02-04 17:33:33 UTC (rev 29014)
@@ -10,375 +10,77 @@
******************************************************************************/
package org.jboss.tools.internal.deltacloud.ui.utils;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.jface.action.ContributionManager;
-import org.eclipse.jface.action.GroupMarker;
-import org.eclipse.jface.action.IContributionManager;
-import org.eclipse.jface.action.IMenuManager;
-import org.eclipse.jface.action.MenuManager;
-import org.eclipse.jface.dialogs.IDialogSettings;
+import org.eclipse.core.runtime.preferences.InstanceScope;
+import org.eclipse.jface.bindings.keys.KeyStroke;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.dialogs.MessageDialogWithToggle;
+import org.eclipse.jface.fieldassist.ContentProposalAdapter;
import org.eclipse.jface.fieldassist.ControlDecoration;
import org.eclipse.jface.fieldassist.FieldDecorationRegistry;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.jface.resource.JFaceResources;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.fieldassist.SimpleContentProposalProvider;
+import org.eclipse.jface.fieldassist.TextContentAdapter;
import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.DisposeEvent;
-import org.eclipse.swt.events.DisposeListener;
+import org.eclipse.swt.events.FocusAdapter;
+import org.eclipse.swt.events.FocusEvent;
import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.layout.FormAttachment;
-import org.eclipse.swt.layout.FormData;
import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Menu;
import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.IWorkbench;
-import org.eclipse.ui.IWorkbenchActionConstants;
-import org.eclipse.ui.IWorkbenchPage;
-import org.eclipse.ui.IWorkbenchPartSite;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.PartInitException;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.menus.IMenuService;
-import org.eclipse.ui.part.EditorPart;
-import org.eclipse.ui.plugin.AbstractUIPlugin;
+import org.eclipse.swt.widgets.Text;
+import org.jboss.tools.deltacloud.ui.Activator;
+import org.jboss.tools.deltacloud.ui.IDeltaCloudPreferenceConstants;
+import org.jboss.tools.internal.deltacloud.ui.preferences.StringsPreferenceValue;
+import org.osgi.service.prefs.Preferences;
/**
* @author Andre Dietisheim
*/
public class UIUtils {
- private static final String CONTEXT_MENU_PREFIX = "popup:";
- private static final String VIEW_MENU_PREFIX = "menu:";
-
- private UIUtils() {
- }
+ public static ContentProposalAdapter addPreferencesProposalAdapter(final Text text, String preferencesKey) {
+ final ControlDecoration decoration = createContenAssistDecoration(text);
- /**
- * Returns the selection of the active workbench window.
- *
- * @return the selection
- *
- * @see IWorkbenchWindow#getSelectionService()
- */
- public static ISelection getWorkbenchWindowSelection() {
- return getActiveWorkbenchWindow().getSelectionService().getSelection();
- }
+ final StringsPreferenceValue preferencesValues =
+ new StringsPreferenceValue(',', preferencesKey, Activator.PLUGIN_ID);
+ SimpleContentProposalProvider proposalProvider = new SimpleContentProposalProvider(preferencesValues.get());
+ proposalProvider.setFiltering(true);
+ text.addFocusListener(new FocusAdapter() {
- /**
- * Gets the structured selection.
- *
- * @return the structured selection
- */
- public static IStructuredSelection getStructuredSelection() {
- ISelection selection = getWorkbenchWindowSelection();
- if (selection instanceof IStructuredSelection) {
- return (IStructuredSelection) selection;
- } else {
- return null;
- }
- }
-
- /**
- * Gets the first element of a given selection in the given type. Returns
- * <code>null</null> if selection is selection is empty or adaption of the first element in
- * the given selection fails. Adaption is tried by casting and by adapting it.
- *
- * @param selection
- * the selection
- * @param expectedClass
- * the expected class
- *
- * @return the first element
- */
- public static <T> T getFirstAdaptedElement(final ISelection selection, final Class<T> expectedClass) {
- if (selection == null) {
- return null;
- } else {
- Assert.isTrue(selection instanceof IStructuredSelection);
- Object firstElement = ((IStructuredSelection) selection).getFirstElement();
- if (firstElement == null) {
- return null;
+ @Override
+ public void focusGained(FocusEvent e) {
+ decoration.show();
}
- return adapt(firstElement, expectedClass);
- }
- }
- /**
- * Returns <code>true</code> if the given selection holds exactly 1 element
- * of the given type.
- *
- * @param selection
- * the selection to check
- * @param expectedClass
- * the expected class
- * @return <code>true</code>, if the given selection holds a single element
- * of the given type.
- */
- public static <T> boolean isSingleSelection(final ISelection selection, final Class<T> expectedClass) {
- if (!(selection instanceof IStructuredSelection)) {
- return false;
- }
-
- return ((IStructuredSelection) selection).toList().size() == 1
- && getFirstAdaptedElement(selection, expectedClass) != null;
- }
-
- public static <T> List<T> adapt(Collection<?> objects, Class<T> expectedClass) {
- List<T> adaptedObjects = new ArrayList<T>();
- for (Object object : objects) {
- T adaptedObject = adapt(object, expectedClass);
- if (adaptedObject != null) {
- adaptedObjects.add(adaptedObject);
+ @Override
+ public void focusLost(FocusEvent e) {
+ decoration.hide();
+
+ preferencesValues.add(text.getText());
+ preferencesValues.store();
}
- }
- return adaptedObjects;
- }
-
- /**
- * Adapts the given object to the given type. Returns <code>null</code> if
- * the given adaption is not possible. Adaption is tried by casting and by adapting it.
- *
- * @param <T>
- * @param object
- * @param expectedClass
- * @return
- */
- @SuppressWarnings("unchecked")
- public static <T> T adapt(Object object, Class<T> expectedClass) {
- if (object == null) {
- return null;
- }
-
- Object adaptedObject = null;
- if (expectedClass.isAssignableFrom(object.getClass())) {
- adaptedObject = object;
- } else if (object instanceof IAdaptable) {
- adaptedObject = ((IAdaptable) object).getAdapter(expectedClass);
- }
-
- if (adaptedObject != null) {
- return (T) adaptedObject;
- } else {
- return (T) Platform.getAdapterManager().loadAdapter(object, expectedClass.getName());
- }
- }
- /**
- * Gets the active page.
- *
- * @return the active page
- */
- public static IWorkbenchPage getActivePage() {
- IWorkbenchPage workbenchPage = getActiveWorkbenchWindow().getActivePage();
- Assert.isNotNull(workbenchPage);
- return workbenchPage;
- }
-
- /**
- * Returns the editor that's currently active (focused).
- *
- * @return the active editor
- */
- public static IEditorPart getActiveEditor() {
- IEditorPart editor = getActivePage().getActiveEditor();
- Assert.isNotNull(editor);
- return editor;
- }
-
- /**
- * Gets the active workbench window.
- *
- * @return the active workbench window
- */
- public static IWorkbenchWindow getActiveWorkbenchWindow() {
- IWorkbenchWindow workbenchWindow = getWorkbench().getActiveWorkbenchWindow();
- Assert.isNotNull(workbenchWindow);
- return workbenchWindow;
- }
-
- public static Shell getActiveShell() {
- Shell shell = getActiveWorkbenchWindow().getShell();
- Assert.isTrue(shell != null && !shell.isDisposed());
- return shell;
- }
-
- /**
- * Gets the workbench.
- *
- * @return the workbench
- */
- public static IWorkbench getWorkbench() {
- IWorkbench workbench = PlatformUI.getWorkbench();
- Assert.isNotNull(workbench);
- return workbench;
- }
-
- /**
- * Replaces an image with the given key by the given image descriptor.
- *
- * @param imageKey
- * the image key
- * @param imageDescriptor
- * the image descriptor
- */
- public static void replaceInJfaceImageRegistry(final String imageKey, final ImageDescriptor imageDescriptor) {
- Assert.isNotNull(imageKey);
- Assert.isNotNull(imageDescriptor);
-
- JFaceResources.getImageRegistry().remove(imageKey);
- JFaceResources.getImageRegistry().put(imageKey, imageDescriptor);
- }
-
- /**
- * Register the given ContributionManager with the given id. The
- * contribution manager gets unregistered on control disposal.
- *
- * @param id
- * the id
- * @param contributionManager
- * the contribution manager
- * @param control
- * the control
- *
- * @see ContributionManager
- * @see IMenuService
- * @see DisposeListener
- */
- public static void registerContributionManager(final String id, final IContributionManager contributionManager,
- final Control control) {
- Assert.isNotNull(id);
- Assert.isNotNull(contributionManager);
- Assert.isTrue(control != null && !control.isDisposed());
-
- final IMenuService menuService = (IMenuService) PlatformUI.getWorkbench().getService(IMenuService.class);
- menuService.populateContributionManager((ContributionManager) contributionManager, id);
- contributionManager.update(true);
- control.addDisposeListener(new DisposeListener()
- {
- public void widgetDisposed(DisposeEvent e)
- {
- menuService.releaseContributions((ContributionManager) contributionManager);
- }
});
+ KeyStroke keyStroke = KeyStroke.getInstance(SWT.CONTROL, ' ');
+ ContentProposalAdapter proposalAdapter =
+ new ContentProposalAdapter(text, new TextContentAdapter(), proposalProvider, keyStroke, null);
+ proposalAdapter.setProposalAcceptanceStyle(ContentProposalAdapter.PROPOSAL_REPLACE);
+ return proposalAdapter;
}
-
- public static String getContextMenuId(String viewId) {
- return new StringBuffer(CONTEXT_MENU_PREFIX).append(viewId).toString();
- }
-
- public static String getViewMenuId(String viewId) {
- return new StringBuffer(VIEW_MENU_PREFIX).append(viewId).toString();
- }
- /**
- * Creates context menu to a given control.
- *
- * @param control
- * the control
- *
- * @return the i menu manager
- */
- public static IMenuManager createContextMenu(final Control control) {
- Assert.isTrue(control != null && !control.isDisposed());
-
- MenuManager menuManager = new MenuManager();
- menuManager.add(new GroupMarker(IWorkbenchActionConstants.MB_ADDITIONS));
-
- Menu menu = menuManager.createContextMenu(control);
- control.setMenu(menu);
- return menuManager;
+ private static ControlDecoration createContenAssistDecoration(Control control) {
+ ControlDecoration decoration = new ControlDecoration(control, SWT.RIGHT | SWT.TOP);
+ Image errorImage = FieldDecorationRegistry.getDefault()
+ .getFieldDecoration(FieldDecorationRegistry.DEC_CONTENT_PROPOSAL).getImage();
+ decoration.setImage(errorImage);
+ decoration.setDescriptionText("History available");
+ decoration.setShowHover(true);
+ decoration.hide();
+ return decoration;
}
-
- /**
- * Gets the dialog settings for the given identifer and plugin.
- *
- * @param identifier
- * the identifier
- * @param plugin
- * the plugin
- *
- * @return the dialog settings
- */
- public static IDialogSettings getDialogSettings(final String identifier, final AbstractUIPlugin plugin) {
- Assert.isNotNull(plugin);
- IDialogSettings dialogSettings = plugin.getDialogSettings();
- IDialogSettings section = dialogSettings.getSection(identifier);
- if (section == null) {
- section = dialogSettings.addNewSection(identifier);
- }
- return section;
- }
-
- /**
- * Returns the page for a given editor.
- *
- * @param editor
- * the editor
- * @return
- *
- * @return the page
- *
- * @see IWorkbenchPage
- */
- public static IWorkbenchPage getPage(EditorPart editor) {
- Assert.isNotNull(editor);
- IWorkbenchPartSite site = editor.getSite();
- Assert.isNotNull(site);
- return site.getPage();
- }
-
- public static void showView(String viewId) throws PartInitException {
- Assert.isLegal(viewId != null && viewId.length() > 0);
- getActivePage().showView(viewId);
- }
-
- /**
- * This method has been stolen from AS-Tools' UIUtil class
- * and is useful for creating FormData objects
- */
- public static FormData createFormData(
- Object topStart, int topOffset,
- Object bottomStart, int bottomOffset,
- Object leftStart, int leftOffset,
- Object rightStart, int rightOffset) {
-
- FormData data = new FormData();
-
- if( topStart != null ) {
- data.top = topStart instanceof Control ? new FormAttachment((Control)topStart, topOffset) :
- new FormAttachment(((Integer)topStart).intValue(), topOffset);
- }
-
- if( bottomStart != null ) {
- data.bottom = bottomStart instanceof Control ? new FormAttachment((Control)bottomStart, bottomOffset) :
- new FormAttachment(((Integer)bottomStart).intValue(), bottomOffset);
- }
-
- if( leftStart != null ) {
- data.left = leftStart instanceof Control ? new FormAttachment((Control)leftStart, leftOffset) :
- new FormAttachment(((Integer)leftStart).intValue(), leftOffset);
- }
-
- if( rightStart != null ) {
- data.right = rightStart instanceof Control ? new FormAttachment((Control)rightStart, rightOffset) :
- new FormAttachment(((Integer)rightStart).intValue(), rightOffset);
- }
- return data;
- }
-
public static ControlDecoration createErrorDecoration(String errorText, Control control) {
return createDecoration(errorText, FieldDecorationRegistry.DEC_ERROR, control);
}
-
+
public static ControlDecoration createDecoration(String text, String imageKey, Control control) {
ControlDecoration decoration = new ControlDecoration(control, SWT.LEFT | SWT.TOP);
Image errorImage = FieldDecorationRegistry.getDefault()
@@ -390,4 +92,42 @@
return decoration;
}
+ /**
+ * Opens a confirmation dialog that offers a checkbox that allows the user
+ * to turn further aksing off. The checkbox state is stored to the preferences
+ *
+ * @param title
+ * dialog title
+ * @param message
+ * dialog message
+ * @param dontShowAgainMessage
+ * message for further asking ("dont show this dialog again")
+ * @param preferencesKey
+ * the preferences key to store state of further asking
+ * @param pluginId
+ * the plugin id to use when storing the preferences
+ * @param shell
+ * the shell to use
+ * @return true, if successful
+ */
+ public static boolean openConfirmationDialog(String title, String message, String dontShowAgainMessage,
+ String preferencesKey, String pluginId, Shell shell) {
+ boolean confirmed = true;
+ Preferences prefs = new InstanceScope().getNode(pluginId);
+ boolean dontShowDialog =
+ prefs.getBoolean(preferencesKey, false);
+ if (!dontShowDialog) {
+ MessageDialogWithToggle dialog =
+ MessageDialogWithToggle.openOkCancelConfirm(shell, title, message, dontShowAgainMessage,
+ false, null, null);
+ confirmed = dialog.getReturnCode() == Dialog.OK;
+ boolean toggleState = dialog.getToggleState();
+ // If warning turned off by user, set the preference for future
+ // usage
+ if (toggleState) {
+ prefs.putBoolean(IDeltaCloudPreferenceConstants.DONT_CONFIRM_CREATE_INSTANCE, true);
+ }
+ }
+ return confirmed;
+ }
}
Added: trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/utils/WorkbenchUtils.java
===================================================================
--- trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/utils/WorkbenchUtils.java (rev 0)
+++ trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/utils/WorkbenchUtils.java 2011-02-04 17:33:33 UTC (rev 29014)
@@ -0,0 +1,337 @@
+/*******************************************************************************
+ * Copyright (c) 2010 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is 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:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.internal.deltacloud.ui.utils;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.jface.action.ContributionManager;
+import org.eclipse.jface.action.GroupMarker;
+import org.eclipse.jface.action.IContributionManager;
+import org.eclipse.jface.action.IMenuManager;
+import org.eclipse.jface.action.MenuManager;
+import org.eclipse.jface.dialogs.IDialogSettings;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.resource.JFaceResources;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.swt.events.DisposeEvent;
+import org.eclipse.swt.events.DisposeListener;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Menu;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.IWorkbenchActionConstants;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.IWorkbenchPartSite;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.menus.IMenuService;
+import org.eclipse.ui.part.EditorPart;
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+
+/**
+ * @author Andre Dietisheim
+ */
+public class WorkbenchUtils {
+
+ private static final String CONTEXT_MENU_PREFIX = "popup:";
+ private static final String VIEW_MENU_PREFIX = "menu:";
+
+ private WorkbenchUtils() {
+ }
+
+ /**
+ * Returns the selection of the active workbench window.
+ *
+ * @return the selection
+ *
+ * @see IWorkbenchWindow#getSelectionService()
+ */
+ public static ISelection getWorkbenchWindowSelection() {
+ return getActiveWorkbenchWindow().getSelectionService().getSelection();
+ }
+
+ /**
+ * Gets the structured selection.
+ *
+ * @return the structured selection
+ */
+ public static IStructuredSelection getStructuredSelection() {
+ ISelection selection = getWorkbenchWindowSelection();
+ if (selection instanceof IStructuredSelection) {
+ return (IStructuredSelection) selection;
+ } else {
+ return null;
+ }
+ }
+
+ /**
+ * Gets the first element of a given selection in the given type. Returns
+ * <code>null</null> if selection is selection is empty or adaption of the first element in
+ * the given selection fails. Adaption is tried by casting and by adapting it.
+ *
+ * @param selection
+ * the selection
+ * @param expectedClass
+ * the expected class
+ *
+ * @return the first element
+ */
+ public static <T> T getFirstAdaptedElement(final ISelection selection, final Class<T> expectedClass) {
+ if (selection == null) {
+ return null;
+ } else {
+ Assert.isTrue(selection instanceof IStructuredSelection);
+ Object firstElement = ((IStructuredSelection) selection).getFirstElement();
+ if (firstElement == null) {
+ return null;
+ }
+ return adapt(firstElement, expectedClass);
+ }
+ }
+
+ /**
+ * Returns <code>true</code> if the given selection holds exactly 1 element
+ * of the given type.
+ *
+ * @param selection
+ * the selection to check
+ * @param expectedClass
+ * the expected class
+ * @return <code>true</code>, if the given selection holds a single element
+ * of the given type.
+ */
+ public static <T> boolean isSingleSelection(final ISelection selection, final Class<T> expectedClass) {
+ if (!(selection instanceof IStructuredSelection)) {
+ return false;
+ }
+
+ return ((IStructuredSelection) selection).toList().size() == 1
+ && getFirstAdaptedElement(selection, expectedClass) != null;
+ }
+
+ public static <T> List<T> adapt(Collection<?> objects, Class<T> expectedClass) {
+ List<T> adaptedObjects = new ArrayList<T>();
+ for (Object object : objects) {
+ T adaptedObject = adapt(object, expectedClass);
+ if (adaptedObject != null) {
+ adaptedObjects.add(adaptedObject);
+ }
+ }
+ return adaptedObjects;
+ }
+
+ /**
+ * Adapts the given object to the given type. Returns <code>null</code> if
+ * the given adaption is not possible. Adaption is tried by casting and by
+ * adapting it.
+ *
+ * @param <T>
+ * @param object
+ * @param expectedClass
+ * @return
+ */
+ @SuppressWarnings("unchecked")
+ public static <T> T adapt(Object object, Class<T> expectedClass) {
+ if (object == null) {
+ return null;
+ }
+
+ Object adaptedObject = null;
+ if (expectedClass.isAssignableFrom(object.getClass())) {
+ adaptedObject = object;
+ } else if (object instanceof IAdaptable) {
+ adaptedObject = ((IAdaptable) object).getAdapter(expectedClass);
+ }
+
+ if (adaptedObject != null) {
+ return (T) adaptedObject;
+ } else {
+ return (T) Platform.getAdapterManager().loadAdapter(object, expectedClass.getName());
+ }
+ }
+
+ /**
+ * Gets the active page.
+ *
+ * @return the active page
+ */
+ public static IWorkbenchPage getActivePage() {
+ IWorkbenchPage workbenchPage = getActiveWorkbenchWindow().getActivePage();
+ Assert.isNotNull(workbenchPage);
+ return workbenchPage;
+ }
+
+ /**
+ * Returns the editor that's currently active (focused).
+ *
+ * @return the active editor
+ */
+ public static IEditorPart getActiveEditor() {
+ IEditorPart editor = getActivePage().getActiveEditor();
+ Assert.isNotNull(editor);
+ return editor;
+ }
+
+ /**
+ * Gets the active workbench window.
+ *
+ * @return the active workbench window
+ */
+ public static IWorkbenchWindow getActiveWorkbenchWindow() {
+ IWorkbenchWindow workbenchWindow = getWorkbench().getActiveWorkbenchWindow();
+ Assert.isNotNull(workbenchWindow);
+ return workbenchWindow;
+ }
+
+ public static Shell getActiveShell() {
+ Shell shell = getActiveWorkbenchWindow().getShell();
+ Assert.isTrue(shell != null && !shell.isDisposed());
+ return shell;
+ }
+
+ /**
+ * Gets the workbench.
+ *
+ * @return the workbench
+ */
+ public static IWorkbench getWorkbench() {
+ IWorkbench workbench = PlatformUI.getWorkbench();
+ Assert.isNotNull(workbench);
+ return workbench;
+ }
+
+ /**
+ * Replaces an image with the given key by the given image descriptor.
+ *
+ * @param imageKey
+ * the image key
+ * @param imageDescriptor
+ * the image descriptor
+ */
+ public static void replaceInJfaceImageRegistry(final String imageKey, final ImageDescriptor imageDescriptor) {
+ Assert.isNotNull(imageKey);
+ Assert.isNotNull(imageDescriptor);
+
+ JFaceResources.getImageRegistry().remove(imageKey);
+ JFaceResources.getImageRegistry().put(imageKey, imageDescriptor);
+ }
+
+ /**
+ * Register the given ContributionManager with the given id. The
+ * contribution manager gets unregistered on control disposal.
+ *
+ * @param id
+ * the id
+ * @param contributionManager
+ * the contribution manager
+ * @param control
+ * the control
+ *
+ * @see ContributionManager
+ * @see IMenuService
+ * @see DisposeListener
+ */
+ public static void registerContributionManager(final String id, final IContributionManager contributionManager,
+ final Control control) {
+ Assert.isNotNull(id);
+ Assert.isNotNull(contributionManager);
+ Assert.isTrue(control != null && !control.isDisposed());
+
+ final IMenuService menuService = (IMenuService) PlatformUI.getWorkbench().getService(IMenuService.class);
+ menuService.populateContributionManager((ContributionManager) contributionManager, id);
+ contributionManager.update(true);
+ control.addDisposeListener(new DisposeListener()
+ {
+ public void widgetDisposed(DisposeEvent e)
+ {
+ menuService.releaseContributions((ContributionManager) contributionManager);
+ }
+ });
+ }
+
+ public static String getContextMenuId(String viewId) {
+ return new StringBuffer(CONTEXT_MENU_PREFIX).append(viewId).toString();
+ }
+
+ public static String getViewMenuId(String viewId) {
+ return new StringBuffer(VIEW_MENU_PREFIX).append(viewId).toString();
+ }
+
+ /**
+ * Creates context menu to a given control.
+ *
+ * @param control
+ * the control
+ *
+ * @return the i menu manager
+ */
+ public static IMenuManager createContextMenu(final Control control) {
+ Assert.isTrue(control != null && !control.isDisposed());
+
+ MenuManager menuManager = new MenuManager();
+ menuManager.add(new GroupMarker(IWorkbenchActionConstants.MB_ADDITIONS));
+
+ Menu menu = menuManager.createContextMenu(control);
+ control.setMenu(menu);
+ return menuManager;
+ }
+
+ /**
+ * Gets the dialog settings for the given identifer and plugin.
+ *
+ * @param identifier
+ * the identifier
+ * @param plugin
+ * the plugin
+ *
+ * @return the dialog settings
+ */
+ public static IDialogSettings getDialogSettings(final String identifier, final AbstractUIPlugin plugin) {
+ Assert.isNotNull(plugin);
+ IDialogSettings dialogSettings = plugin.getDialogSettings();
+ IDialogSettings section = dialogSettings.getSection(identifier);
+ if (section == null) {
+ section = dialogSettings.addNewSection(identifier);
+ }
+ return section;
+ }
+
+ /**
+ * Returns the page for a given editor.
+ *
+ * @param editor
+ * the editor
+ * @return
+ *
+ * @return the page
+ *
+ * @see IWorkbenchPage
+ */
+ public static IWorkbenchPage getPage(EditorPart editor) {
+ Assert.isNotNull(editor);
+ IWorkbenchPartSite site = editor.getSite();
+ Assert.isNotNull(site);
+ return site.getPage();
+ }
+
+ public static void showView(String viewId) throws PartInitException {
+ Assert.isLegal(viewId != null && viewId.length() > 0);
+ getActivePage().showView(viewId);
+ }
+}
Property changes on: trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/utils/WorkbenchUtils.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/CloudConnectionPage.java
===================================================================
--- trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/CloudConnectionPage.java 2011-02-04 16:44:52 UTC (rev 29013)
+++ trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/CloudConnectionPage.java 2011-02-04 17:33:33 UTC (rev 29014)
@@ -66,7 +66,7 @@
import org.jboss.tools.internal.deltacloud.ui.common.swt.JFaceUtils;
import org.jboss.tools.internal.deltacloud.ui.preferences.IPreferenceKeys;
import org.jboss.tools.internal.deltacloud.ui.preferences.StringPreferenceValue;
-import org.jboss.tools.internal.deltacloud.ui.utils.ContentProposalFactory;
+import org.jboss.tools.internal.deltacloud.ui.utils.UIUtils;
/**
* @author Jeff Jonhston
@@ -335,7 +335,7 @@
Label nameLabel = new Label(container, SWT.NULL);
nameLabel.setText(WizardMessages.getString(NAME_LABEL));
Text nameText = new Text(container, SWT.BORDER | SWT.SINGLE);
- ContentProposalFactory.addPreferencesProposalAdapter(nameText, NAME_PROPOSAL_KEY);
+ UIUtils.addPreferencesProposalAdapter(nameText, NAME_PROPOSAL_KEY);
bindName(dbc, nameText);
// url
@@ -343,7 +343,7 @@
urlLabel.setText(WizardMessages.getString(URL_LABEL));
Point p1 = urlLabel.computeSize(SWT.DEFAULT, SWT.DEFAULT);
Text urlText = new Text(container, SWT.BORDER | SWT.SINGLE);
- ContentProposalFactory.addPreferencesProposalAdapter(urlText, URL_PROPOSAL_KEY);
+ UIUtils.addPreferencesProposalAdapter(urlText, URL_PROPOSAL_KEY);
dbc.bindValue(
WidgetProperties.text(SWT.Modify).observe(urlText),
BeanProperties.value(
@@ -368,7 +368,7 @@
Label usernameLabel = new Label(container, SWT.NULL);
usernameLabel.setText(WizardMessages.getString(USERNAME_LABEL));
Text usernameText = new Text(container, SWT.BORDER | SWT.SINGLE);
- ContentProposalFactory.addPreferencesProposalAdapter(usernameText, USERNAME_PROPOSAL_KEY);
+ UIUtils.addPreferencesProposalAdapter(usernameText, USERNAME_PROPOSAL_KEY);
IObservableValue usernameObservable = WidgetProperties.text(SWT.Modify).observe(usernameText);
dbc.bindValue(
usernameObservable,
Modified: trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/ManageKeysPage.java
===================================================================
--- trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/ManageKeysPage.java 2011-02-04 16:44:52 UTC (rev 29013)
+++ trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/ManageKeysPage.java 2011-02-04 17:33:33 UTC (rev 29014)
@@ -60,7 +60,7 @@
import org.jboss.tools.deltacloud.ui.ErrorUtils;
import org.jboss.tools.deltacloud.ui.SWTImagesFactory;
import org.jboss.tools.internal.deltacloud.ui.common.databinding.validator.ObjectNotNullToBoolean;
-import org.jboss.tools.internal.deltacloud.ui.utils.UIUtils;
+import org.jboss.tools.internal.deltacloud.ui.utils.LayoutUtils;
import org.jboss.tools.internal.deltacloud.ui.utils.WizardUtils;
/**
@@ -304,22 +304,22 @@
composite.setFont(parent.getFont());
composite.setLayout(new FormLayout());
Label titleBarSeparator = new Label(composite, SWT.HORIZONTAL | SWT.SEPARATOR);
- titleBarSeparator.setLayoutData(UIUtils.createFormData(0,0,null,0,0,0,100,0));
+ titleBarSeparator.setLayoutData(LayoutUtils.createFormData(0,0,null,0,0,0,100,0));
setTitle(WizardMessages.getString(CREATE_KEY_TITLE));
Label nameLabel = new Label(composite, SWT.NONE);
nameLabel.setText("Key ID: ");
- nameLabel.setLayoutData(UIUtils.createFormData(0,7,null,0,0,5,null,0));
+ nameLabel.setLayoutData(LayoutUtils.createFormData(0,7,null,0,0,5,null,0));
nameText = new Text(composite, SWT.BORDER);
- nameText.setLayoutData(UIUtils.createFormData(0,5,null,0,nameLabel, 5, 100, -5));
+ nameText.setLayoutData(LayoutUtils.createFormData(0,5,null,0,nameLabel, 5, 100, -5));
persist = new Button(composite, SWT.CHECK);
persist.setText("Save key in folder: ");
- persist.setLayoutData(UIUtils.createFormData(nameText, 8, null, 0, 0,5,null,0));
+ persist.setLayoutData(LayoutUtils.createFormData(nameText, 8, null, 0, 0,5,null,0));
Button browse = new Button(composite, SWT.DEFAULT);
browse.setText("Browse...");
- browse.setLayoutData(UIUtils.createFormData(nameText, 5, null, 0, null, 0, 100, -5));
+ browse.setLayoutData(LayoutUtils.createFormData(nameText, 5, null, 0, null, 0, 100, -5));
browse.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
DirectoryDialog dialog = new DirectoryDialog(getShell(), SWT.NONE);
@@ -331,7 +331,7 @@
});
pemText = new Text(composite, SWT.BORDER);
- pemText.setLayoutData(UIUtils.createFormData(nameText,5,null,0,persist, 5, browse, -5));
+ pemText.setLayoutData(LayoutUtils.createFormData(nameText,5,null,0,persist, 5, browse, -5));
init();
Modified: trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/NewInstancePage.java
===================================================================
--- trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/NewInstancePage.java 2011-02-04 16:44:52 UTC (rev 29013)
+++ trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/NewInstancePage.java 2011-02-04 17:33:33 UTC (rev 29014)
@@ -72,7 +72,7 @@
import org.jboss.tools.internal.deltacloud.ui.common.databinding.validator.MandatoryStringValidator;
import org.jboss.tools.internal.deltacloud.ui.common.databinding.validator.SelectedComboItemValidator;
import org.jboss.tools.internal.deltacloud.ui.utils.DataBindingUtils;
-import org.jboss.tools.internal.deltacloud.ui.utils.ContentProposalFactory;
+import org.jboss.tools.internal.deltacloud.ui.utils.UIUtils;
/**
* @author Jeff Jonston
@@ -180,14 +180,14 @@
nameLabel.setText(WizardMessages.getString(NAME_LABEL));
GridDataFactory.fillDefaults().align(SWT.LEFT, SWT.CENTER).applyTo(nameLabel);
this.nameText = new Text(container, SWT.BORDER | SWT.SINGLE);
- ContentProposalFactory.addPreferencesProposalAdapter(nameText, NAME_PROPOSAL_KEY);
+ UIUtils.addPreferencesProposalAdapter(nameText, NAME_PROPOSAL_KEY);
GridDataFactory.fillDefaults().span(2, 1).grab(true, false).applyTo(nameText);
Label imageLabel = new Label(container, SWT.NULL);
imageLabel.setText(WizardMessages.getString(IMAGE_LABEL));
GridDataFactory.fillDefaults().align(SWT.LEFT, SWT.CENTER).applyTo(imageLabel);
this.imageText = new Text(container, SWT.BORDER | SWT.SINGLE);
- ContentProposalFactory.addPreferencesProposalAdapter(imageText, IMAGE_PROPOSAL_KEY);
+ UIUtils.addPreferencesProposalAdapter(imageText, IMAGE_PROPOSAL_KEY);
GridDataFactory.fillDefaults().grab(true, false).align(SWT.FILL, SWT.CENTER).applyTo(imageText);
Button findImageButton = new Button(container, SWT.NULL);
findImageButton.setText(WizardMessages.getString(FIND_BUTTON_LABEL));
@@ -212,7 +212,7 @@
keyLabel.setText(WizardMessages.getString(KEY_LABEL));
GridDataFactory.fillDefaults().align(SWT.LEFT, SWT.CENTER).applyTo(keyLabel);
keyText = new Text(container, SWT.BORDER | SWT.SINGLE);
- ContentProposalFactory.addPreferencesProposalAdapter(keyText, KEY_PROPOSAL_KEY);
+ UIUtils.addPreferencesProposalAdapter(keyText, KEY_PROPOSAL_KEY);
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).applyTo(keyText);
Button keyManageButton = new Button(container, SWT.NULL);
keyManageButton.setText(WizardMessages.getString(MANAGE_BUTTON_LABEL));
Modified: trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/NewInstanceWizard.java
===================================================================
--- trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/NewInstanceWizard.java 2011-02-04 16:44:52 UTC (rev 29013)
+++ trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/NewInstanceWizard.java 2011-02-04 17:33:33 UTC (rev 29014)
@@ -11,9 +11,6 @@
package org.jboss.tools.internal.deltacloud.ui.wizards;
import org.eclipse.core.runtime.Assert;
-import org.eclipse.core.runtime.preferences.InstanceScope;
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.jface.dialogs.MessageDialogWithToggle;
import org.jboss.tools.common.jobs.ChainedJob;
import org.jboss.tools.deltacloud.core.DeltaCloud;
import org.jboss.tools.deltacloud.core.DeltaCloudException;
@@ -25,7 +22,7 @@
import org.jboss.tools.deltacloud.ui.ErrorUtils;
import org.jboss.tools.deltacloud.ui.IDeltaCloudPreferenceConstants;
import org.jboss.tools.deltacloud.ui.wizard.INewInstanceWizardPage;
-import org.osgi.service.prefs.Preferences;
+import org.jboss.tools.internal.deltacloud.ui.utils.UIUtils;
/**
* @author Jeff Johnston
@@ -101,7 +98,11 @@
boolean result = false;
Exception e = null;
try {
- if (isProceed()) {
+ if (UIUtils.openConfirmationDialog(
+ WizardMessages.getString(CONFIRM_CREATE_TITLE), WizardMessages.getString(CONFIRM_CREATE_MSG),
+ WizardMessages.getString(DONT_SHOW_THIS_AGAIN_MSG),
+ IDeltaCloudPreferenceConstants.DONT_CONFIRM_CREATE_INSTANCE, Activator.PLUGIN_ID, getShell())) {
+
instance = cloud.createInstance(name, imageId, realmId, profileId, keyId, memory, storage);
if (instance != null) {
result = true;
@@ -142,27 +143,4 @@
}
first.schedule();
}
-
- private boolean isProceed() {
- boolean proceed = true;
- Preferences prefs = new InstanceScope().getNode(Activator.PLUGIN_ID);
- boolean dontShowDialog =
- prefs.getBoolean(IDeltaCloudPreferenceConstants.DONT_CONFIRM_CREATE_INSTANCE, false);
- if (!dontShowDialog) {
- MessageDialogWithToggle dialog =
- MessageDialogWithToggle.openOkCancelConfirm(getShell(),
- WizardMessages.getString(CONFIRM_CREATE_TITLE),
- WizardMessages.getString(CONFIRM_CREATE_MSG),
- WizardMessages.getString(DONT_SHOW_THIS_AGAIN_MSG),
- false, null, null);
- proceed = dialog.getReturnCode() == Dialog.OK;
- boolean toggleState = dialog.getToggleState();
- // If warning turned off by user, set the preference for future
- // usage
- if (toggleState) {
- prefs.putBoolean(IDeltaCloudPreferenceConstants.DONT_CONFIRM_CREATE_INSTANCE, true);
- }
- }
- return proceed;
- }
-}
+}
\ No newline at end of file
13 years, 11 months
JBoss Tools SVN: r29013 - trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards.
by jbosstools-commits@lists.jboss.org
Author: adietish
Date: 2011-02-04 11:44:52 -0500 (Fri, 04 Feb 2011)
New Revision: 29013
Added:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/AbstractFilterPage.java
Modified:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/ImageFilterPage.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/InstanceFilterPage.java
Log:
[JBIDE-8332] added field decorations to FilterImage- and FilterInstance-dialogs
Added: trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/AbstractFilterPage.java
===================================================================
--- trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/AbstractFilterPage.java (rev 0)
+++ trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/AbstractFilterPage.java 2011-02-04 16:44:52 UTC (rev 29013)
@@ -0,0 +1,119 @@
+/*******************************************************************************
+ * Copyright (c) 2010 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is 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:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.internal.deltacloud.ui.wizards;
+
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.jface.fieldassist.ControlDecoration;
+import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Text;
+import org.jboss.tools.deltacloud.core.DeltaCloud;
+import org.jboss.tools.deltacloud.core.ICloudElementFilter;
+import org.jboss.tools.deltacloud.core.IFieldMatcher;
+import org.jboss.tools.deltacloud.ui.SWTImagesFactory;
+
+/**
+ * @author Jeff Johnston
+ * @author André Dietisheim
+ */
+public abstract class AbstractFilterPage extends WizardPage {
+
+ protected final static String EMPTY_RULE = "ErrorFilterEmptyRule.msg"; //$NON-NLS-1$
+ protected final static String INVALID_SEMICOLON = "ErrorFilterSemicolon.msg"; //$NON-NLS-1$
+
+ protected final static String DEFAULT_LABEL = "DefaultButton.label"; //$NON-NLS-1$
+
+ private DeltaCloud cloud;
+
+ public AbstractFilterPage(String name, String title, String description, DeltaCloud cloud) {
+ super(name);
+ this.cloud = cloud;
+ setTitle(title);
+ setDescription(description);
+ setImageDescriptor(SWTImagesFactory.DESC_DELTA_LARGE);
+ setPageComplete(false);
+ }
+
+ private ModifyListener textListener = new ModifyListener() {
+
+ @Override
+ public void modifyText(ModifyEvent e) {
+ validate();
+ }
+ };
+
+ private SelectionAdapter buttonListener = new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ Button b = (Button) e.widget;
+ Text text = getTextWidget(b);
+ if (text != null) {
+ text.setText(ICloudElementFilter.ALL_MATCHER_EXPRESSION);
+ }
+ }
+ };
+
+
+ protected abstract Text getTextWidget(Button button);
+
+ protected abstract void validate();
+
+ protected String validate(Text text, ControlDecoration decoration, String formError) {
+ String error = null;
+ if (text.getText().length() == 0) {
+ error = WizardMessages.getString(EMPTY_RULE);
+ } else if (text.getText().contains(ICloudElementFilter.EXPRESSION_DELIMITER)) {
+ error = WizardMessages.getString(INVALID_SEMICOLON);
+ }
+ if (error != null) {
+ decoration.setDescriptionText(error);
+ decoration.show();
+ setPageComplete(false);
+ setErrorMessage(error);
+ return error;
+ } else {
+ return formError;
+ }
+ }
+
+ protected Label createRuleLabel(String text, Composite container) {
+ Label label = new Label(container, SWT.NULL);
+ label.setText(text);
+ return label;
+ }
+
+ protected Button createDefaultRuleButton(final Composite container) {
+ Button button = new Button(container, SWT.NULL);
+ button.setText(WizardMessages.getString(DEFAULT_LABEL));
+ button.addSelectionListener(buttonListener);
+ return button;
+ }
+
+ protected Text createRuleText(IFieldMatcher rule, final Composite container) {
+ Assert.isNotNull(rule, "Rule may not be null");
+
+ Text text = new Text(container, SWT.BORDER | SWT.SINGLE);
+ text.setText(rule.toString());
+ text.addModifyListener(textListener);
+ return text;
+ }
+
+ protected DeltaCloud getDeltaCloud() {
+ return cloud;
+ }
+}
Property changes on: trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/AbstractFilterPage.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/ImageFilterPage.java
===================================================================
--- trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/ImageFilterPage.java 2011-02-04 16:35:57 UTC (rev 29012)
+++ trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/ImageFilterPage.java 2011-02-04 16:44:52 UTC (rev 29013)
@@ -10,14 +10,8 @@
******************************************************************************/
package org.jboss.tools.internal.deltacloud.ui.wizards;
-import org.eclipse.core.runtime.Assert;
import org.eclipse.jface.fieldassist.ControlDecoration;
-import org.eclipse.jface.wizard.WizardPage;
import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.ModifyEvent;
-import org.eclipse.swt.events.ModifyListener;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.layout.FormAttachment;
import org.eclipse.swt.layout.FormData;
@@ -27,30 +21,23 @@
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Text;
import org.jboss.tools.deltacloud.core.DeltaCloud;
-import org.jboss.tools.deltacloud.core.ICloudElementFilter;
-import org.jboss.tools.deltacloud.core.IFieldMatcher;
import org.jboss.tools.deltacloud.core.IImageFilter;
-import org.jboss.tools.deltacloud.ui.SWTImagesFactory;
import org.jboss.tools.internal.deltacloud.ui.utils.UIUtils;
/**
* @author Jeff Johnston
*/
-public class ImageFilterPage extends WizardPage {
+public class ImageFilterPage extends AbstractFilterPage {
private final static String NAME = "ImageFilter.name"; //$NON-NLS-1$
private final static String TITLE = "ImageFilter.title"; //$NON-NLS-1$
private final static String DESC = "ImageFilter.desc"; //$NON-NLS-1$
private final static String FILTER_LABEL = "ImageFilter.label"; //$NON-NLS-1$
- private final static String EMPTY_RULE = "ErrorFilterEmptyRule.msg"; //$NON-NLS-1$
- private final static String INVALID_SEMICOLON = "ErrorFilterSemicolon.msg"; //$NON-NLS-1$
private final static String NAME_LABEL = "Name.label"; //$NON-NLS-1$
private final static String ID_LABEL = "Id.label"; //$NON-NLS-1$
private final static String ARCH_LABEL = "Arch.label"; //$NON-NLS-1$
private final static String DESC_LABEL = "Desc.label"; //$NON-NLS-1$
- private final static String DEFAULT_LABEL = "DefaultButton.label"; //$NON-NLS-1$
- private DeltaCloud cloud;
private Text nameText;
private ControlDecoration nameDecoration;
private Button defaultName;
@@ -65,11 +52,7 @@
private Button defaultDesc;
public ImageFilterPage(DeltaCloud cloud) {
- super(WizardMessages.getString(NAME));
- this.cloud = cloud;
- setDescription(WizardMessages.getString(DESC));
- setTitle(WizardMessages.getString(TITLE));
- setImageDescriptor(SWTImagesFactory.DESC_DELTA_LARGE);
+ super(WizardMessages.getString(NAME), WizardMessages.getString(TITLE), WizardMessages.getString(DESC), cloud);
setPageComplete(false);
}
@@ -89,44 +72,23 @@
return descText.getText();
}
- private ModifyListener textListener = new ModifyListener() {
-
- @Override
- public void modifyText(ModifyEvent e) {
- validate();
+ @Override
+ protected Text getTextWidget(Button button) {
+ Text text = null;
+ if (button == defaultName) {
+ text = nameText;
+ } else if (button == defaultId) {
+ text = idText;
+ } else if (button == defaultArch) {
+ text = archText;
+ } else if (button == defaultDesc) {
+ text = descText;
}
- };
+ return text;
+ }
- private SelectionAdapter buttonListener = new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- Button b = (Button) e.widget;
- Text text = getTextWidget(b);
- if (text != null) {
- text.setText(ICloudElementFilter.ALL_MATCHER_EXPRESSION);
- }
- }
-
- private Text getTextWidget(Button button) {
- Text text = null;
- if (button == defaultName) {
- text = nameText;
- }
- else if (button == defaultId) {
- text = idText;
- }
- else if (button == defaultArch) {
- text = archText;
- }
- else if (button == defaultDesc) {
- text = descText;
- }
- return text;
- }
-
- };
-
- private void validate() {
+ @Override
+ protected void validate() {
nameDecoration.hide();
idDecoration.hide();
archDecoration.hide();
@@ -139,24 +101,6 @@
setPageComplete(error == null);
setErrorMessage(error);
}
-
- private String validate(Text text, ControlDecoration decoration, String formError) {
- String error = null;
- if (text.getText().length() == 0) {
- error = WizardMessages.getString(EMPTY_RULE);
- } else if (text.getText().contains(ICloudElementFilter.EXPRESSION_DELIMITER)) {
- error = WizardMessages.getString(INVALID_SEMICOLON);
- }
- if (error != null) {
- decoration.setDescriptionText(error);
- decoration.show();
- setPageComplete(false);
- setErrorMessage(error);
- return error;
- } else {
- return formError;
- }
- }
@Override
public void createControl(Composite parent) {
@@ -166,7 +110,7 @@
layout.marginWidth = 5;
container.setLayout(layout);
- IImageFilter filter = cloud.getImageFilter();
+ IImageFilter filter = getDeltaCloud().getImageFilter();
Label label = new Label(container, SWT.NULL);
label.setText(WizardMessages.getString(FILTER_LABEL));
@@ -268,27 +212,4 @@
setControl(container);
setPageComplete(true);
}
-
- private Label createRuleLabel(String text, Composite container) {
- Label label = new Label(container, SWT.NULL);
- label.setText(text);
- return label;
- }
-
- private Button createDefaultRuleButton(final Composite container) {
- Button button = new Button(container, SWT.NULL);
- button.setText(WizardMessages.getString(DEFAULT_LABEL));
- button.addSelectionListener(buttonListener);
- return button;
- }
-
- private Text createRuleText(IFieldMatcher rule, final Composite container) {
- Assert.isNotNull(rule, "Rule may not be null");
-
- Text text = new Text(container, SWT.BORDER | SWT.SINGLE);
- text.setText(rule.toString());
- text.addModifyListener(textListener);
- return text;
- }
-
}
Modified: trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/InstanceFilterPage.java
===================================================================
--- trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/InstanceFilterPage.java 2011-02-04 16:35:57 UTC (rev 29012)
+++ trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/InstanceFilterPage.java 2011-02-04 16:44:52 UTC (rev 29013)
@@ -10,36 +10,27 @@
******************************************************************************/
package org.jboss.tools.internal.deltacloud.ui.wizards;
-import org.eclipse.core.runtime.Assert;
+import org.eclipse.jface.fieldassist.ControlDecoration;
import org.eclipse.jface.layout.GridDataFactory;
import org.eclipse.jface.layout.GridLayoutFactory;
-import org.eclipse.jface.wizard.WizardPage;
import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.ModifyEvent;
-import org.eclipse.swt.events.ModifyListener;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Text;
import org.jboss.tools.deltacloud.core.DeltaCloud;
-import org.jboss.tools.deltacloud.core.ICloudElementFilter;
-import org.jboss.tools.deltacloud.core.IFieldMatcher;
import org.jboss.tools.deltacloud.core.IInstanceFilter;
-import org.jboss.tools.deltacloud.ui.SWTImagesFactory;
+import org.jboss.tools.internal.deltacloud.ui.utils.UIUtils;
/**
* @author Jeff Johnston
*/
-public class InstanceFilterPage extends WizardPage {
+public class InstanceFilterPage extends AbstractFilterPage {
private final static String NAME = "InstanceFilter.name"; //$NON-NLS-1$
private final static String TITLE = "InstanceFilter.title"; //$NON-NLS-1$
private final static String DESC = "InstanceFilter.desc"; //$NON-NLS-1$
private final static String FILTER_LABEL = "InstanceFilter.label"; //$NON-NLS-1$
- private final static String EMPTY_RULE = "ErrorFilterEmptyRule.msg"; //$NON-NLS-1$
- private final static String INVALID_SEMICOLON = "ErrorFilterSemicolon.msg"; //$NON-NLS-1$
private final static String NAME_LABEL = "Name.label"; //$NON-NLS-1$
private final static String ID_LABEL = "Id.label"; //$NON-NLS-1$
private final static String ALIAS_LABEL = "Alias.label"; //$NON-NLS-1$
@@ -48,34 +39,34 @@
private final static String KEYNAME_LABEL = "Key.label"; //$NON-NLS-1$
private final static String REALM_LABEL = "Realm.label"; //$NON-NLS-1$
private final static String PROFILE_LABEL = "Profile.label"; //$NON-NLS-1$
- private final static String DEFAULT_LABEL = "DefaultButton.label"; //$NON-NLS-1$
- private DeltaCloud cloud;
private Text nameText;
- private Text idText;
- private Text aliasText;
- private Text imageIdText;
- private Text ownerIdText;
- private Text keyIdText;
- private Text realmText;
- private Text profileText;
-
+ private ControlDecoration nameDecoration;
private Button defaultName;
+ private Text idText;
+ private ControlDecoration idDecoration;
private Button defaultId;
+ private Text aliasText;
+ private ControlDecoration aliasDecoration;
private Button defaultAlias;
+ private Text imageIdText;
+ private ControlDecoration imageDecoration;
private Button defaultImageId;
+ private Text ownerIdText;
private Button defaultOwnerId;
+ private ControlDecoration ownerDecoration;
+ private Text keyIdText;
+ private ControlDecoration keyIdDecoration;
private Button defaultKeyId;
+ private Text realmText;
+ private ControlDecoration realmDecoration;
private Button defaultRealm;
+ private Text profileText;
+ private ControlDecoration profileDecoration;
private Button defaultProfile;
public InstanceFilterPage(DeltaCloud cloud) {
- super(WizardMessages.getString(NAME));
- this.cloud = cloud;
- setDescription(WizardMessages.getString(DESC));
- setTitle(WizardMessages.getString(TITLE));
- setImageDescriptor(SWTImagesFactory.DESC_DELTA_LARGE);
- setPageComplete(false);
+ super(WizardMessages.getString(NAME), WizardMessages.getString(TITLE), WizardMessages.getString(DESC), cloud);
}
public String getNameRule() {
@@ -110,102 +101,70 @@
return profileText.getText();
}
- private ModifyListener Listener = new ModifyListener() {
-
- @Override
- public void modifyText(ModifyEvent e) {
- // TODO Auto-generated method stub
- validate();
+ @Override
+ protected Text getTextWidget(Button button) {
+ Text text = null;
+ if (button == defaultName) {
+ text = nameText;
+ } else if (button == defaultId) {
+ text = idText;
+ } else if (button == defaultAlias) {
+ text = aliasText;
+ } else if (button == defaultImageId) {
+ text = imageIdText;
+ } else if (button == defaultOwnerId) {
+ text = ownerIdText;
+ } else if (button == defaultKeyId) {
+ text = keyIdText;
+ } else if (button == defaultRealm) {
+ text = realmText;
+ } else if (button == defaultProfile) {
+ text = profileText;
}
- };
+ return text;
+ }
- private SelectionAdapter buttonListener = new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- Button b = (Button) e.widget;
- Text text = getTextWidget(b);
- if (text != null) {
- text.setText(ICloudElementFilter.ALL_MATCHER_EXPRESSION);
- }
- }
-
- private Text getTextWidget(Button button) {
- Text text = null;
- if (button == defaultName) {
- text = nameText;
- }
- else if (button == defaultId) {
- text = idText;
- }
- else if (button == defaultAlias) {
- text = aliasText;
- }
- else if (button == defaultImageId) {
- text = imageIdText;
- }
- else if (button == defaultOwnerId) {
- text = ownerIdText;
- }
- else if (button == defaultKeyId) {
- text = keyIdText;
- }
- else if (button == defaultRealm) {
- text = realmText;
- }
- else if (button == defaultProfile) {
- text = profileText;
- }
- return text;
- }
- };
-
- private void validate() {
- boolean complete = true;
- boolean error = false;
-
- if (nameText.getText().length() == 0 ||
- idText.getText().length() == 0 ||
- aliasText.getText().length() == 0 ||
- imageIdText.getText().length() == 0 ||
- ownerIdText.getText().length() == 0 ||
- keyIdText.getText().length() == 0 ||
- realmText.getText().length() == 0 ||
- profileText.getText().length() == 0) {
-
- setErrorMessage(WizardMessages.getString(EMPTY_RULE));
- error = true;
- } else if (nameText.getText().contains(";") ||
- idText.getText().contains(";") ||
- aliasText.getText().contains(";") ||
- imageIdText.getText().contains(";") ||
- ownerIdText.getText().contains(";") ||
- keyIdText.getText().contains(";") ||
- realmText.getText().contains(";") ||
- profileText.getText().contains(";")) {
- setErrorMessage(WizardMessages.getString(INVALID_SEMICOLON));
- error = true;
- }
-
- if (!error)
- setErrorMessage(null);
- setPageComplete(complete && !error);
+ @Override
+ protected void validate() {
+ nameDecoration.hide();
+ idDecoration.hide();
+ aliasDecoration.hide();
+ imageDecoration.hide();
+ ownerDecoration.hide();
+ keyIdDecoration.hide();
+ realmDecoration.hide();
+ profileDecoration.hide();
+
+ String error = null;
+ error = validate(nameText, nameDecoration, error);
+ error = validate(idText, idDecoration, error);
+ error = validate(aliasText, aliasDecoration, error);
+ error = validate(imageIdText, imageDecoration, error);
+ error = validate(ownerIdText, ownerDecoration, error);
+ error = validate(keyIdText, keyIdDecoration, error);
+ error = validate(realmText, realmDecoration, error);
+ error = validate(profileText, profileDecoration, error);
+ setPageComplete(error == null);
+ setErrorMessage(error);
}
@Override
public void createControl(Composite parent) {
final Composite container = new Composite(parent, SWT.NULL);
GridLayoutFactory.fillDefaults().numColumns(3).spacing(8, 4).applyTo(container);
-
+
Label label = new Label(container, SWT.NULL);
label.setText(WizardMessages.getString(FILTER_LABEL));
- GridDataFactory.fillDefaults().span(3, 1).align(SWT.LEFT, SWT.CENTER).indent(0, 14).hint(SWT.DEFAULT, 30).applyTo(label);
-
- IInstanceFilter filter = cloud.getInstanceFilter();
+ GridDataFactory.fillDefaults().span(3, 1).align(SWT.LEFT, SWT.CENTER).indent(0, 14).hint(SWT.DEFAULT, 30)
+ .applyTo(label);
+ IInstanceFilter filter = getDeltaCloud().getInstanceFilter();
+
Label nameLabel = createRuleLabel(WizardMessages.getString(NAME_LABEL), container);
GridDataFactory.fillDefaults().align(SWT.LEFT, SWT.CENTER).applyTo(nameLabel);
this.nameText = createRuleText(filter.getNameRule(), container);
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).applyTo(nameText);
+ this.nameDecoration = UIUtils.createErrorDecoration("", nameText);
this.defaultName = createDefaultRuleButton(container);
GridDataFactory.fillDefaults().align(SWT.RIGHT, SWT.CENTER).applyTo(defaultName);
@@ -213,6 +172,7 @@
GridDataFactory.fillDefaults().align(SWT.LEFT, SWT.CENTER).applyTo(aliasLabel);
this.aliasText = createRuleText(filter.getAliasRule(), container);
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).applyTo(aliasText);
+ this.aliasDecoration = UIUtils.createErrorDecoration("", aliasText);
this.defaultAlias = createDefaultRuleButton(container);
GridDataFactory.fillDefaults().align(SWT.RIGHT, SWT.CENTER).applyTo(defaultAlias);
@@ -220,6 +180,7 @@
GridDataFactory.fillDefaults().align(SWT.LEFT, SWT.CENTER).applyTo(idLabel);
this.idText = createRuleText(filter.getIdRule(), container);
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).applyTo(idText);
+ this.idDecoration = UIUtils.createErrorDecoration("", idText);
this.defaultId = createDefaultRuleButton(container);
GridDataFactory.fillDefaults().align(SWT.RIGHT, SWT.CENTER).applyTo(defaultId);
@@ -227,6 +188,7 @@
GridDataFactory.fillDefaults().align(SWT.LEFT, SWT.CENTER).applyTo(imageIdLabel);
this.imageIdText = createRuleText(filter.getImageIdRule(), container);
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).applyTo(imageIdText);
+ this.imageDecoration = UIUtils.createErrorDecoration("", imageIdText);
this.defaultImageId = createDefaultRuleButton(container);
GridDataFactory.fillDefaults().align(SWT.RIGHT, SWT.CENTER).applyTo(defaultImageId);
@@ -234,6 +196,7 @@
GridDataFactory.fillDefaults().align(SWT.LEFT, SWT.CENTER).applyTo(ownerIdLabel);
this.ownerIdText = createRuleText(filter.getOwnerIdRule(), container);
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).applyTo(ownerIdText);
+ this.ownerDecoration = UIUtils.createErrorDecoration("", ownerIdText);
this.defaultOwnerId = createDefaultRuleButton(container);
GridDataFactory.fillDefaults().align(SWT.RIGHT, SWT.CENTER).applyTo(defaultOwnerId);
@@ -241,6 +204,7 @@
GridDataFactory.fillDefaults().align(SWT.LEFT, SWT.CENTER).applyTo(keyNameLabel);
this.keyIdText = createRuleText(filter.getKeyNameRule(), container);
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).applyTo(keyIdText);
+ this.keyIdDecoration = UIUtils.createErrorDecoration("", keyIdText);
this.defaultKeyId = createDefaultRuleButton(container);
GridDataFactory.fillDefaults().align(SWT.RIGHT, SWT.CENTER).applyTo(defaultKeyId);
@@ -248,12 +212,14 @@
GridDataFactory.fillDefaults().align(SWT.LEFT, SWT.CENTER).applyTo(realmLabel);
this.realmText = createRuleText(filter.getRealmRule(), container);
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).applyTo(realmText);
+ this.realmDecoration = UIUtils.createErrorDecoration("", realmText);
this.defaultRealm = createDefaultRuleButton(container);
GridDataFactory.fillDefaults().align(SWT.RIGHT, SWT.CENTER).applyTo(defaultRealm);
Label profileLabel = createRuleLabel(WizardMessages.getString(PROFILE_LABEL), container);
GridDataFactory.fillDefaults().align(SWT.LEFT, SWT.CENTER).applyTo(profileLabel);
this.profileText = createRuleText(filter.getProfileRule(), container);
+ this.profileDecoration = UIUtils.createErrorDecoration("", profileText);
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).applyTo(profileText);
this.defaultProfile = createDefaultRuleButton(container);
GridDataFactory.fillDefaults().align(SWT.RIGHT, SWT.CENTER).applyTo(defaultProfile);
@@ -261,26 +227,4 @@
setControl(container);
setPageComplete(true);
}
-
- private Label createRuleLabel(String text, Composite container) {
- Label label = new Label(container, SWT.NULL);
- label.setText(text);
- return label;
- }
-
- private Button createDefaultRuleButton(final Composite container) {
- Button button = new Button(container, SWT.NULL);
- button.setText(WizardMessages.getString(DEFAULT_LABEL));
- button.addSelectionListener(buttonListener);
- return button;
- }
-
- private Text createRuleText(IFieldMatcher rule, final Composite container) {
- Assert.isNotNull(rule, "Rule may not be null");
-
- Text text = new Text(container, SWT.BORDER | SWT.SINGLE);
- text.setText(rule.toString());
- text.addModifyListener(Listener);
- return text;
- }
}
13 years, 11 months
JBoss Tools SVN: r29012 - trunk/cdi/tests/org.jboss.tools.cdi.ui.test/src/org/jboss/tools/cdi/ui/test/marker.
by jbosstools-commits@lists.jboss.org
Author: dazarov
Date: 2011-02-04 11:35:57 -0500 (Fri, 04 Feb 2011)
New Revision: 29012
Modified:
trunk/cdi/tests/org.jboss.tools.cdi.ui.test/src/org/jboss/tools/cdi/ui/test/marker/CDIMarkerResolutionTest.java
Log:
https://issues.jboss.org/browse/JBIDE-7635
Modified: trunk/cdi/tests/org.jboss.tools.cdi.ui.test/src/org/jboss/tools/cdi/ui/test/marker/CDIMarkerResolutionTest.java
===================================================================
--- trunk/cdi/tests/org.jboss.tools.cdi.ui.test/src/org/jboss/tools/cdi/ui/test/marker/CDIMarkerResolutionTest.java 2011-02-04 16:32:36 UTC (rev 29011)
+++ trunk/cdi/tests/org.jboss.tools.cdi.ui.test/src/org/jboss/tools/cdi/ui/test/marker/CDIMarkerResolutionTest.java 2011-02-04 16:35:57 UTC (rev 29012)
@@ -21,9 +21,12 @@
import org.eclipse.core.resources.IncrementalProjectBuilder;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.jdt.core.ICompilationUnit;
+import org.eclipse.ltk.core.refactoring.Change;
import org.eclipse.ltk.core.refactoring.CompositeChange;
import org.eclipse.ltk.core.refactoring.RefactoringStatus;
import org.eclipse.ltk.core.refactoring.RefactoringStatusEntry;
+import org.eclipse.ltk.core.refactoring.TextFileChange;
import org.eclipse.ltk.core.refactoring.participants.RefactoringProcessor;
import org.eclipse.ui.IMarkerResolution;
import org.eclipse.ui.ide.IDE;
@@ -39,6 +42,7 @@
import org.jboss.tools.cdi.ui.marker.SelectBeanMarkerResolution;
import org.jboss.tools.cdi.ui.marker.TestableResolutionWithRefactoringProcessor;
import org.jboss.tools.cdi.ui.marker.TestableResolutionWithSelectionWizard;
+import org.jboss.tools.common.EclipseUtil;
import org.jboss.tools.common.util.FileUtil;
import org.jboss.tools.test.util.JobUtils;
@@ -70,6 +74,9 @@
if (attribute != null){
int messageId = attribute.intValue();
if(messageId == id){
+ String text = (String)marker.getAttribute(IMarker.MESSAGE,"none");
+ System.out.println("Before quick fix: "+text);
+
IMarkerResolution[] resolutions = IDE.getMarkerHelpRegistry()
.getResolutions(marker);
for (int j = 0; j < resolutions.length; j++) {
@@ -99,7 +106,20 @@
CompositeChange rootChange = (CompositeChange)processor.createChange(new NullProgressMonitor());
- rootChange.perform(new NullProgressMonitor());
+ for(Change change : rootChange.getChildren()){
+ if(change instanceof TextFileChange){
+ IFile cFile = ((TextFileChange)change).getFile();
+ ICompilationUnit cUnit = EclipseUtil.getCompilationUnit(cFile);
+ ICompilationUnit compilationUnit = cUnit.getWorkingCopy(new NullProgressMonitor());
+
+ compilationUnit.applyTextEdit(((TextFileChange)change).getEdit(), new NullProgressMonitor());
+
+ compilationUnit.commitWorkingCopy(false, new NullProgressMonitor());
+ compilationUnit.discardWorkingCopy();
+ }
+ }
+
+ //rootChange.perform(new NullProgressMonitor());
}else if(resolution instanceof TestableResolutionWithSelectionWizard){
((TestableResolutionWithSelectionWizard)resolution).selectFirstElementAndRun(marker);
}else{
@@ -112,8 +132,10 @@
System.out.println("Before: "+markers.length+" after: "+newMarkers.length);
+
+
for(IMarker m : newMarkers){
- String text = (String)m.getAttribute(IMarker.TEXT,"none");
+ text = (String)m.getAttribute(IMarker.MESSAGE,"none");
System.out.println("After quick fix: "+text);
}
13 years, 11 months
JBoss Tools SVN: r29011 - trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck.
by jbosstools-commits@lists.jboss.org
Author: scabanovich
Date: 2011-02-04 11:32:36 -0500 (Fri, 04 Feb 2011)
New Revision: 29011
Modified:
trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/InjectionPointTest.java
Log:
JBIDE-8325
https://issues.jboss.org/browse/JBIDE-8325
Modified: trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/InjectionPointTest.java
===================================================================
--- trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/InjectionPointTest.java 2011-02-04 16:32:06 UTC (rev 29010)
+++ trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/InjectionPointTest.java 2011-02-04 16:32:36 UTC (rev 29011)
@@ -68,7 +68,7 @@
}
public void testGetInjections() {
- List<IInjectionPoint> ps = cdiProject.getInjections("org.jboss.jsr299.tck.tests.lookup.injection.Fox");
+ Set<IInjectionPoint> ps = cdiProject.getInjections("org.jboss.jsr299.tck.tests.lookup.injection.Fox");
assertTrue(!ps.isEmpty());
ps = cdiProject.getInjections("org.jboss.jsr299.tck.tests.context.dependent.Tarantula");
13 years, 11 months
JBoss Tools SVN: r29010 - in trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi: internal/core/impl and 1 other directory.
by jbosstools-commits@lists.jboss.org
Author: scabanovich
Date: 2011-02-04 11:32:06 -0500 (Fri, 04 Feb 2011)
New Revision: 29010
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/IBeanManager.java
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/CDIProject.java
Log:
JBIDE-8325
https://issues.jboss.org/browse/JBIDE-8325
Modified: trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/IBeanManager.java
===================================================================
--- trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/IBeanManager.java 2011-02-04 16:22:10 UTC (rev 29009)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/IBeanManager.java 2011-02-04 16:32:06 UTC (rev 29010)
@@ -460,5 +460,11 @@
*/
List<INodeReference> getInterceptorClasses(String fullQualifiedTypeName);
- List<IInjectionPoint> getInjections(String fullyQualifiedTypeName);
+ /**
+ * Returns set of injection points with declared type exactly equal to fullyQualifiedTypeName.
+ *
+ * @param fullyQualifiedTypeName
+ * @return
+ */
+ Set<IInjectionPoint> getInjections(String fullyQualifiedTypeName);
}
\ No newline at end of file
Modified: trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/CDIProject.java
===================================================================
--- trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/CDIProject.java 2011-02-04 16:22:10 UTC (rev 29009)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/CDIProject.java 2011-02-04 16:32:06 UTC (rev 29010)
@@ -93,6 +93,8 @@
private Set<IDecorator> decorators = new HashSet<IDecorator>();
private Set<IInterceptor> interceptors = new HashSet<IInterceptor>();
+ private Map<String, Set<IInjectionPoint>> injectionPointsByType = new HashMap<String, Set<IInjectionPoint>>();
+
BeansXMLData beansXMLData = new BeansXMLData();
public CDIProject() {}
@@ -1156,6 +1158,8 @@
for (IBean bean: beans) {
addBean(bean);
}
+
+ buildInjectionPoinsByType();
// System.out.println("Project=" + getNature().getProject());
// System.out.println("Qualifiers=" + qualifiers.size());
@@ -1213,6 +1217,26 @@
}
}
+ void buildInjectionPoinsByType() {
+ injectionPointsByType.clear();
+
+ for (IBean b: allBeans) {
+ Set<IInjectionPoint> ps = b.getInjectionPoints();
+ for (IInjectionPoint p: ps) {
+ IParametedType t = p.getType();
+ if(t == null || t.getType() == null) continue;
+ String n = t.getType().getFullyQualifiedName();
+ Set<IInjectionPoint> s = injectionPointsByType.get(n);
+ if(s == null) {
+ s = new HashSet<IInjectionPoint>();
+ injectionPointsByType.put(n, s);
+ }
+ s.add(p);
+ }
+ }
+
+ }
+
void rebuildXML() {
beansXMLData.clean();
Set<BeansXMLDefinition> beanXMLs = n.getDefinitions().getBeansXMLDefinitions();
@@ -1324,31 +1348,9 @@
return getBeans(attemptToResolveAmbiguousDependency, beanType, qualifiers.toArray(new IType[0]));
}
- public List<IInjectionPoint> getInjections(String fullyQualifiedTypeName) {
- List<IInjectionPoint> result = new ArrayList<IInjectionPoint>();
-
- IType type = null;
- try {
- type = EclipseJavaUtil.findType(EclipseUtil.getJavaProject(getNature().getProject()), fullyQualifiedTypeName);
- } catch (JavaModelException e) {
- CDICorePlugin.getDefault().logError(e);
- }
- if(type == null) {
- return result;
- }
- IParametedType pType = getNature().getTypeFactory().newParametedType(type);
- Set<IParametedType> types = ((ParametedType)pType).getAllTypes();
- IBean[] beans = getBeans();
- for (IBean b: beans) {
- Set<IInjectionPoint> ps = b.getInjectionPoints();
- for (IInjectionPoint p: ps) {
- IParametedType t = p.getType();
- if(containsType(types, t)) {
- result.add(p);
- }
- }
- }
-
+ public Set<IInjectionPoint> getInjections(String fullyQualifiedTypeName) {
+ Set<IInjectionPoint> result = injectionPointsByType.get(fullyQualifiedTypeName);
+ if(result == null) result = Collections.emptySet();
return result;
}
13 years, 11 months
JBoss Tools SVN: r29009 - trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards.
by jbosstools-commits@lists.jboss.org
Author: adietish
Date: 2011-02-04 11:22:10 -0500 (Fri, 04 Feb 2011)
New Revision: 29009
Modified:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/ImageFilterPage.java
Log:
[JBIDE-8332] added field decorations to FilterImage- and FilterInstance-dialogs
Modified: trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/ImageFilterPage.java
===================================================================
--- trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/ImageFilterPage.java 2011-02-04 15:22:48 UTC (rev 29008)
+++ trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/ImageFilterPage.java 2011-02-04 16:22:10 UTC (rev 29009)
@@ -10,6 +10,8 @@
******************************************************************************/
package org.jboss.tools.internal.deltacloud.ui.wizards;
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.jface.fieldassist.ControlDecoration;
import org.eclipse.jface.wizard.WizardPage;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.ModifyEvent;
@@ -26,7 +28,10 @@
import org.eclipse.swt.widgets.Text;
import org.jboss.tools.deltacloud.core.DeltaCloud;
import org.jboss.tools.deltacloud.core.ICloudElementFilter;
+import org.jboss.tools.deltacloud.core.IFieldMatcher;
+import org.jboss.tools.deltacloud.core.IImageFilter;
import org.jboss.tools.deltacloud.ui.SWTImagesFactory;
+import org.jboss.tools.internal.deltacloud.ui.utils.UIUtils;
/**
* @author Jeff Johnston
@@ -47,13 +52,16 @@
private DeltaCloud cloud;
private Text nameText;
+ private ControlDecoration nameDecoration;
+ private Button defaultName;
private Text idText;
+ private ControlDecoration idDecoration;
+ private Button defaultId;
private Text archText;
+ private ControlDecoration archDecoration;
+ private Button defaultArch;
private Text descText;
-
- private Button defaultName;
- private Button defaultId;
- private Button defaultArch;
+ private ControlDecoration descDecoration;
private Button defaultDesc;
public ImageFilterPage(DeltaCloud cloud) {
@@ -81,16 +89,15 @@
return descText.getText();
}
- private ModifyListener Listener = new ModifyListener() {
+ private ModifyListener textListener = new ModifyListener() {
@Override
public void modifyText(ModifyEvent e) {
- // TODO Auto-generated method stub
validate();
}
};
- private SelectionAdapter ButtonListener = new SelectionAdapter() {
+ private SelectionAdapter buttonListener = new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
Button b = (Button) e.widget;
@@ -120,27 +127,35 @@
};
private void validate() {
- boolean complete = true;
- boolean error = false;
-
- if (nameText.getText().length() == 0 ||
- idText.getText().length() == 0 ||
- archText.getText().length() == 0 ||
- descText.getText().length() == 0) {
-
- setErrorMessage(WizardMessages.getString(EMPTY_RULE));
- error = true;
- } else if (nameText.getText().contains(";") ||
- idText.getText().contains(";") ||
- archText.getText().contains(";") ||
- descText.getText().contains(";")) {
- setErrorMessage(WizardMessages.getString(INVALID_SEMICOLON));
- error = true;
+ nameDecoration.hide();
+ idDecoration.hide();
+ archDecoration.hide();
+ descDecoration.hide();
+ String error = null;
+ error = validate(nameText, nameDecoration, error);
+ error = validate(idText, idDecoration, error);
+ error = validate(archText, archDecoration, error);
+ error = validate(descText, descDecoration, error);
+ setPageComplete(error == null);
+ setErrorMessage(error);
+ }
+
+ private String validate(Text text, ControlDecoration decoration, String formError) {
+ String error = null;
+ if (text.getText().length() == 0) {
+ error = WizardMessages.getString(EMPTY_RULE);
+ } else if (text.getText().contains(ICloudElementFilter.EXPRESSION_DELIMITER)) {
+ error = WizardMessages.getString(INVALID_SEMICOLON);
}
-
- if (!error)
- setErrorMessage(null);
- setPageComplete(complete && !error);
+ if (error != null) {
+ decoration.setDescriptionText(error);
+ decoration.show();
+ setPageComplete(false);
+ setErrorMessage(error);
+ return error;
+ } else {
+ return formError;
+ }
}
@Override
@@ -151,53 +166,31 @@
layout.marginWidth = 5;
container.setLayout(layout);
+ IImageFilter filter = cloud.getImageFilter();
+
Label label = new Label(container, SWT.NULL);
label.setText(WizardMessages.getString(FILTER_LABEL));
- Label nameLabel = new Label(container, SWT.NULL);
- nameLabel.setText(WizardMessages.getString(NAME_LABEL));
+ Label nameLabel = createRuleLabel(WizardMessages.getString(NAME_LABEL), container);
+ this.nameText = createRuleText(filter.getNameRule(), container);
+ this.nameDecoration = UIUtils.createErrorDecoration("", nameText);
+ this.defaultName = createDefaultRuleButton(container);
- nameText = new Text(container, SWT.BORDER | SWT.SINGLE);
- nameText.setText(cloud.getImageFilter().getNameRule().toString());
- nameText.addModifyListener(Listener);
+ Label idLabel = createRuleLabel(WizardMessages.getString(ID_LABEL), container);
+ this.idText = createRuleText(filter.getIdRule(), container);
+ this.idDecoration = UIUtils.createErrorDecoration("", idText);
+ this.defaultId = createDefaultRuleButton(container);
- defaultName = new Button(container, SWT.NULL);
- defaultName.setText(WizardMessages.getString(DEFAULT_LABEL));
- defaultName.addSelectionListener(ButtonListener);
+ Label archLabel = createRuleLabel(WizardMessages.getString(ARCH_LABEL), container);
+ this.archText = createRuleText(filter.getArchRule(), container);
+ this.archDecoration = UIUtils.createErrorDecoration(WizardMessages.getString(""), archText);
+ this.defaultArch = createDefaultRuleButton(container);
- Label idLabel = new Label(container, SWT.NULL);
- idLabel.setText(WizardMessages.getString(ID_LABEL));
+ Label descLabel = createRuleLabel(WizardMessages.getString(DESC_LABEL), container);
+ this.descText = createRuleText(filter.getDescRule(), container);
+ this.descDecoration = UIUtils.createErrorDecoration("", descText);
+ this.defaultDesc = createDefaultRuleButton(container);
- idText = new Text(container, SWT.BORDER | SWT.SINGLE);
- idText.setText(cloud.getImageFilter().getIdRule().toString());
- idText.addModifyListener(Listener);
-
- defaultId = new Button(container, SWT.NULL);
- defaultId.setText(WizardMessages.getString(DEFAULT_LABEL));
- defaultId.addSelectionListener(ButtonListener);
-
- Label archLabel = new Label(container, SWT.NULL);
- archLabel.setText(WizardMessages.getString(ARCH_LABEL));
-
- archText = new Text(container, SWT.BORDER | SWT.SINGLE);
- archText.setText(cloud.getImageFilter().getArchRule().toString());
- archText.addModifyListener(Listener);
-
- defaultArch = new Button(container, SWT.NULL);
- defaultArch.setText(WizardMessages.getString(DEFAULT_LABEL));
- defaultArch.addSelectionListener(ButtonListener);
-
- Label descLabel = new Label(container, SWT.NULL);
- descLabel.setText(WizardMessages.getString(DESC_LABEL));
-
- descText = new Text(container, SWT.BORDER | SWT.SINGLE);
- descText.setText(cloud.getImageFilter().getDescRule().toString());
- descText.addModifyListener(Listener);
-
- defaultDesc = new Button(container, SWT.NULL);
- defaultDesc.setText(WizardMessages.getString(DEFAULT_LABEL));
- defaultDesc.addSelectionListener(ButtonListener);
-
Point p1 = label.computeSize(SWT.DEFAULT, SWT.DEFAULT);
Point p2 = nameText.computeSize(SWT.DEFAULT, SWT.DEFAULT);
Point p3 = defaultName.computeSize(SWT.DEFAULT, SWT.DEFAULT);
@@ -276,4 +269,26 @@
setPageComplete(true);
}
+ private Label createRuleLabel(String text, Composite container) {
+ Label label = new Label(container, SWT.NULL);
+ label.setText(text);
+ return label;
+ }
+
+ private Button createDefaultRuleButton(final Composite container) {
+ Button button = new Button(container, SWT.NULL);
+ button.setText(WizardMessages.getString(DEFAULT_LABEL));
+ button.addSelectionListener(buttonListener);
+ return button;
+ }
+
+ private Text createRuleText(IFieldMatcher rule, final Composite container) {
+ Assert.isNotNull(rule, "Rule may not be null");
+
+ Text text = new Text(container, SWT.BORDER | SWT.SINGLE);
+ text.setText(rule.toString());
+ text.addModifyListener(textListener);
+ return text;
+ }
+
}
13 years, 11 months
JBoss Tools SVN: r29008 - trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck.
by jbosstools-commits@lists.jboss.org
Author: scabanovich
Date: 2011-02-04 10:22:48 -0500 (Fri, 04 Feb 2011)
New Revision: 29008
Modified:
trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/InjectionPointTest.java
Log:
JBIDE-8325
https://issues.jboss.org/browse/JBIDE-8325
Modified: trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/InjectionPointTest.java
===================================================================
--- trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/InjectionPointTest.java 2011-02-04 15:21:37 UTC (rev 29007)
+++ trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/InjectionPointTest.java 2011-02-04 15:22:48 UTC (rev 29008)
@@ -10,6 +10,7 @@
******************************************************************************/
package org.jboss.tools.cdi.core.test.tck;
+import java.util.List;
import java.util.Set;
import org.eclipse.jdt.core.ITypeParameter;
@@ -66,4 +67,12 @@
assertEquals(1, injections.size());
}
+ public void testGetInjections() {
+ List<IInjectionPoint> ps = cdiProject.getInjections("org.jboss.jsr299.tck.tests.lookup.injection.Fox");
+ assertTrue(!ps.isEmpty());
+
+ ps = cdiProject.getInjections("org.jboss.jsr299.tck.tests.context.dependent.Tarantula");
+ assertTrue(!ps.isEmpty());
+ }
+
}
\ No newline at end of file
13 years, 11 months
JBoss Tools SVN: r29007 - in trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi: internal/core/impl and 1 other directory.
by jbosstools-commits@lists.jboss.org
Author: scabanovich
Date: 2011-02-04 10:21:37 -0500 (Fri, 04 Feb 2011)
New Revision: 29007
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/IBeanManager.java
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/CDIProject.java
Log:
JBIDE-8325
https://issues.jboss.org/browse/JBIDE-8325
Modified: trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/IBeanManager.java
===================================================================
--- trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/IBeanManager.java 2011-02-04 15:00:24 UTC (rev 29006)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/IBeanManager.java 2011-02-04 15:21:37 UTC (rev 29007)
@@ -459,4 +459,6 @@
* <interceptors> of beans.xml by its full qualified type name.
*/
List<INodeReference> getInterceptorClasses(String fullQualifiedTypeName);
+
+ List<IInjectionPoint> getInjections(String fullyQualifiedTypeName);
}
\ No newline at end of file
Modified: trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/CDIProject.java
===================================================================
--- trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/CDIProject.java 2011-02-04 15:00:24 UTC (rev 29006)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/CDIProject.java 2011-02-04 15:21:37 UTC (rev 29007)
@@ -1324,6 +1324,34 @@
return getBeans(attemptToResolveAmbiguousDependency, beanType, qualifiers.toArray(new IType[0]));
}
+ public List<IInjectionPoint> getInjections(String fullyQualifiedTypeName) {
+ List<IInjectionPoint> result = new ArrayList<IInjectionPoint>();
+
+ IType type = null;
+ try {
+ type = EclipseJavaUtil.findType(EclipseUtil.getJavaProject(getNature().getProject()), fullyQualifiedTypeName);
+ } catch (JavaModelException e) {
+ CDICorePlugin.getDefault().logError(e);
+ }
+ if(type == null) {
+ return result;
+ }
+ IParametedType pType = getNature().getTypeFactory().newParametedType(type);
+ Set<IParametedType> types = ((ParametedType)pType).getAllTypes();
+ IBean[] beans = getBeans();
+ for (IBean b: beans) {
+ Set<IInjectionPoint> ps = b.getInjectionPoints();
+ for (IInjectionPoint p: ps) {
+ IParametedType t = p.getType();
+ if(containsType(types, t)) {
+ result.add(p);
+ }
+ }
+ }
+
+ return result;
+ }
+
/**
* For usage in TCK tests which contain many versions of beans.xml in packages.
* @param path
13 years, 11 months