Author: adietish
Date: 2010-11-04 13:02:52 -0400 (Thu, 04 Nov 2010)
New Revision: 26264
Added:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/commands/CVInstanceElementsSelectionDialog.java
Modified:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/commands/StopInstanceHandler.java
Log:
[JBIDE-7499] extracted CVInstanceElementDialog to its own class to allow reuse for
starting instances
Added:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/commands/CVInstanceElementsSelectionDialog.java
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/commands/CVInstanceElementsSelectionDialog.java
(rev 0)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/commands/CVInstanceElementsSelectionDialog.java 2010-11-04
17:02:52 UTC (rev 26264)
@@ -0,0 +1,63 @@
+/*******************************************************************************
+ * 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.deltacloud.ui.commands;
+
+import java.util.Collection;
+
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.jface.viewers.IStructuredContentProvider;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.dialogs.ListSelectionDialog;
+import org.jboss.tools.deltacloud.ui.views.CVInstanceElement;
+
+/**
+ * A dialog that allows the user to select CVInstanceElements
+ *
+ * @see CVInstanceElement
+ */
+public class CVInstanceElementsSelectionDialog extends ListSelectionDialog {
+
+ private static class DeltaCloudInstanceProvider implements IStructuredContentProvider {
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public Object[] getElements(Object cvInstanceElements) {
+ Assert.isTrue(cvInstanceElements instanceof Collection);
+ Collection<CVInstanceElement> instances = (Collection<CVInstanceElement>)
cvInstanceElements;
+ return instances.toArray(new CVInstanceElement[instances.size()]);
+ }
+
+ @Override
+ public void dispose() {
+ }
+
+ @Override
+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+ }
+ }
+
+ private static class CloudElementNameProvider extends LabelProvider {
+ public String getText(Object element) {
+ return ((CVInstanceElement) element).getName();
+ }
+ };
+
+ public CVInstanceElementsSelectionDialog(Shell parentShell, Collection<?>
cloudViewElements, String title, String message) {
+ super(parentShell
+ , cloudViewElements
+ , new DeltaCloudInstanceProvider()
+ , new CloudElementNameProvider()
+ , message);
+ setTitle(title);
+ }
+}
\ No newline at end of file
Property changes on:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/commands/CVInstanceElementsSelectionDialog.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
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 2010-11-04
16:54:57 UTC (rev 26263)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/commands/StopInstanceHandler.java 2010-11-04
17:02:52 UTC (rev 26264)
@@ -10,23 +10,16 @@
******************************************************************************/
package org.jboss.tools.deltacloud.ui.commands;
-import java.util.Collection;
import java.util.List;
import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.core.commands.IHandler;
-import org.eclipse.core.runtime.Assert;
import org.eclipse.core.runtime.Status;
import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.IStructuredContentProvider;
import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.LabelProvider;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.dialogs.ListSelectionDialog;
import org.eclipse.ui.handlers.HandlerUtil;
import org.jboss.tools.deltacloud.core.DeltaCloud;
import org.jboss.tools.deltacloud.core.DeltaCloudInstance;
@@ -47,42 +40,8 @@
private final static String STOP_INSTANCES_DIALOG_TITLE =
"StopInstancesDialog.title"; //$NON-NLS-1$
private final static String STOP_INSTANCES_DIALOG_MSG =
"StopInstancesDialog.msg"; //$NON-NLS-1$
- public static class StopInstanceDialog extends ListSelectionDialog {
- private static class DeltaCloudInstanceProvider implements IStructuredContentProvider
{
- @SuppressWarnings("unchecked")
- @Override
- public Object[] getElements(Object cvInstanceElements) {
- Assert.isTrue(cvInstanceElements instanceof Collection);
- Collection<CVInstanceElement> instances = (Collection<CVInstanceElement>)
cvInstanceElements;
- return instances.toArray(new CVInstanceElement[instances.size()]);
- }
-
- @Override
- public void dispose() {
- }
-
- @Override
- public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
- }
- }
-
- private static class CloudElementNameProvider extends LabelProvider {
- public String getText(Object element) {
- return ((CVInstanceElement) element).getName();
- }
- };
-
- public StopInstanceDialog(Shell parentShell, Collection<?> cloudViewElements) {
- super(parentShell
- , cloudViewElements
- , new DeltaCloudInstanceProvider()
- , new CloudElementNameProvider(),
CVMessages.getString(STOP_INSTANCES_DIALOG_TITLE));
- setTitle(CVMessages.getString(STOP_INSTANCES_DIALOG_MSG));
- }
- }
-
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
ISelection selection = HandlerUtil.getCurrentSelection(event);
@@ -107,9 +66,11 @@
@SuppressWarnings("unchecked")
private void stopWithDialog(IStructuredSelection selection) {
- StopInstanceDialog dialog = new StopInstanceDialog(
+ CVInstanceElementsSelectionDialog dialog = new CVInstanceElementsSelectionDialog(
UIUtils.getActiveShell()
- , (List<CVInstanceElement>) selection.toList());
+ , (List<CVInstanceElement>) selection.toList()
+ , CVMessages.getString(STOP_INSTANCES_DIALOG_TITLE)
+ , CVMessages.getString(STOP_INSTANCES_DIALOG_MSG));
if (Dialog.OK == dialog.open()) {
stopInstances(dialog.getResult());
}