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