Author: adietish
Date: 2010-11-04 14:56:09 -0400 (Thu, 04 Nov 2010)
New Revision: 26267
Added:
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/views/CloudViewElementUtils.java
Modified:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/ChangeLog
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/CVMessages.properties
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/utils/UIUtils.java
Log:
[JBIDE-7499] added dialog to start several instances at once
Modified: trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/ChangeLog
===================================================================
--- trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/ChangeLog 2010-11-04 17:55:56
UTC (rev 26266)
+++ trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/ChangeLog 2010-11-04 18:56:09
UTC (rev 26267)
@@ -1,7 +1,12 @@
2010-11-04 André Dietisheim <adietish(a)redhat.com>
+ * src/org/jboss/tools/deltacloud/ui/commands/AbstractInstanceHandler.java:
+ [JBIDE-7499] extracted base handler for instances
+ * src/org/jboss/tools/deltacloud/ui/commands/StartInstanceHandler.java:
+ [JBIDE-7499] added dialog to start several instances at once
* src/org/jboss/tools/deltacloud/ui/views/CVMessages.properties:
[JBIDE-7496] added texts for dialog to stop several instances at once
+ [JBIDE-7499] added texts for dialog to start several instances at once
* src/org/jboss/tools/deltacloud/ui/commands/StopInstanceHandler.java
(StopInstanceDialog):
[JBIDE-7496] added dialog to stop several instances at once
* src/org/jboss/tools/deltacloud/ui/views/ImageView.java (.modifyText):
Added:
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
(rev 0)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/commands/AbstractInstanceHandler.java 2010-11-04
18:56:09 UTC (rev 26267)
@@ -0,0 +1,50 @@
+/*******************************************************************************
+ * 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 org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.IHandler;
+import org.eclipse.jface.viewers.ISelection;
+import org.jboss.tools.deltacloud.core.DeltaCloud;
+import org.jboss.tools.deltacloud.core.DeltaCloudInstance;
+import org.jboss.tools.deltacloud.ui.views.CVInstanceElement;
+import org.jboss.tools.deltacloud.ui.views.CloudViewElementUtils;
+import org.jboss.tools.deltacloud.ui.views.PerformInstanceActionThread;
+import org.jboss.tools.internal.deltacloud.ui.utils.UIUtils;
+
+/**
+ * A base handler that instance related handler may extend
+ *
+ * @author Andre Dietisheim
+ */
+public abstract class AbstractInstanceHandler extends AbstractHandler implements IHandler
{
+
+ protected void executeInstanceAction(CVInstanceElement cvInstance, String actionId,
String expectedState,
+ String title, String message) {
+ if (cvInstance != null) {
+ DeltaCloudInstance instance = (DeltaCloudInstance) cvInstance.getElement();
+ DeltaCloud cloud = CloudViewElementUtils.getCloud(cvInstance);
+ PerformInstanceActionThread t = new PerformInstanceActionThread(
+ cloud,
+ instance,
+ actionId,
+ title,
+ message,
+ expectedState);
+ t.setUser(true);
+ t.schedule();
+ }
+ }
+
+ protected boolean isSingleInstanceSelected(ISelection selection) {
+ return UIUtils.isSingleSelection(selection, CVInstanceElement.class);
+ }
+}
Property changes on:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/commands/AbstractInstanceHandler.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
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 2010-11-04
17:55:56 UTC (rev 26266)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/commands/StartInstanceHandler.java 2010-11-04
18:56:09 UTC (rev 26267)
@@ -10,11 +10,13 @@
******************************************************************************/
package org.jboss.tools.deltacloud.ui.commands;
-import org.eclipse.core.commands.AbstractHandler;
+import java.util.List;
+
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.core.commands.IHandler;
import org.eclipse.core.runtime.Status;
+import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.ui.handlers.HandlerUtil;
@@ -30,22 +32,46 @@
/**
* @author Andre Dietisheim
*/
-public class StartInstanceHandler extends AbstractHandler implements IHandler {
+public class StartInstanceHandler extends AbstractInstanceHandler implements IHandler {
private final static String STARTING_INSTANCE_TITLE =
"StartingInstance.title"; //$NON-NLS-1$
private final static String STARTING_INSTANCE_MSG = "StartingInstance.msg";
//$NON-NLS-1$
+ private final static String START_INSTANCES_DIALOG_TITLE =
"StartInstancesDialog.title"; //$NON-NLS-1$
+ private final static String START_INSTANCES_DIALOG_MSG =
"StartInstancesDialog.msg"; //$NON-NLS-1$
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
ISelection selection = HandlerUtil.getCurrentSelection(event);
if (selection instanceof IStructuredSelection) {
- CVInstanceElement cvinstance = UIUtils.getFirstElement(selection,
CVInstanceElement.class);
- startInstance(cvinstance);
+ if (isSingleInstanceSelected(selection)) {
+ CVInstanceElement cvinstance = UIUtils.getFirstElement(selection,
CVInstanceElement.class);
+ startInstance(cvinstance);
+ } else {
+ startWithDialog((IStructuredSelection) selection);
+ }
}
return Status.OK_STATUS;
}
+ @SuppressWarnings("unchecked")
+ private void startWithDialog(IStructuredSelection selection) {
+ CVInstanceElementsSelectionDialog dialog = new CVInstanceElementsSelectionDialog(
+ UIUtils.getActiveShell()
+ , (List<CVInstanceElement>) selection.toList()
+ , CVMessages.getString(START_INSTANCES_DIALOG_TITLE)
+ , CVMessages.getString(START_INSTANCES_DIALOG_MSG));
+ if (Dialog.OK == dialog.open()) {
+ startInstances(dialog.getResult());
+ }
+ }
+
+ private void startInstances(Object[] cvInstances) {
+ for (int i = 0; i < cvInstances.length; i++) {
+ startInstance((CVInstanceElement) cvInstances[i]);
+ }
+ }
+
private void startInstance(CVInstanceElement cvInstance) {
if (cvInstance != null) {
DeltaCloudInstance instance = (DeltaCloudInstance) cvInstance.getElement();
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
17:55:56 UTC (rev 26266)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/commands/StopInstanceHandler.java 2010-11-04
18:56:09 UTC (rev 26267)
@@ -12,7 +12,6 @@
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;
@@ -21,49 +20,36 @@
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.ui.handlers.HandlerUtil;
-import org.jboss.tools.deltacloud.core.DeltaCloud;
import org.jboss.tools.deltacloud.core.DeltaCloudInstance;
-import org.jboss.tools.deltacloud.ui.views.CVCloudElement;
import org.jboss.tools.deltacloud.ui.views.CVInstanceElement;
import org.jboss.tools.deltacloud.ui.views.CVMessages;
-import org.jboss.tools.deltacloud.ui.views.CloudViewElement;
-import org.jboss.tools.deltacloud.ui.views.PerformInstanceActionThread;
import org.jboss.tools.internal.deltacloud.ui.utils.UIUtils;
/**
* @author Andre Dietisheim
*/
-public class StopInstanceHandler extends AbstractHandler implements IHandler {
+public class StopInstanceHandler extends AbstractInstanceHandler implements IHandler {
private final static String STOPPING_INSTANCE_TITLE =
"StoppingInstance.title"; //$NON-NLS-1$
private final static String STOPPING_INSTANCE_MSG = "StoppingInstance.msg";
//$NON-NLS-1$
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$
-
-
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
ISelection selection = HandlerUtil.getCurrentSelection(event);
if (selection instanceof IStructuredSelection) {
- IStructuredSelection structuredSelection = (IStructuredSelection) selection;
- if (isSingleInstance(structuredSelection)) {
+ if (isSingleInstanceSelected(selection)) {
CVInstanceElement cvInstance = UIUtils.getFirstElement(selection,
CVInstanceElement.class);
stopInstance(cvInstance);
} else {
- stopWithDialog(structuredSelection);
+ stopWithDialog((IStructuredSelection) selection);
}
}
return Status.OK_STATUS;
}
- private boolean isSingleInstance(IStructuredSelection selection) {
- List<?> selectedItems = selection.toList();
- return selectedItems.size() == 1
- && selectedItems.get(0) instanceof CVInstanceElement;
- }
-
@SuppressWarnings("unchecked")
private void stopWithDialog(IStructuredSelection selection) {
CVInstanceElementsSelectionDialog dialog = new CVInstanceElementsSelectionDialog(
@@ -85,27 +71,12 @@
private void stopInstance(CVInstanceElement cvInstance) {
if (cvInstance != null) {
DeltaCloudInstance instance = (DeltaCloudInstance) cvInstance.getElement();
- DeltaCloud cloud = getCloud(cvInstance);
- executeInstanceAction(instance, cloud);
+ executeInstanceAction(
+ cvInstance
+ , DeltaCloudInstance.STOP
+ , DeltaCloudInstance.STOPPED
+ , CVMessages.getString(STOPPING_INSTANCE_TITLE)
+ , CVMessages.getFormattedString(STOPPING_INSTANCE_MSG, new String[] {
instance.getName() }));
}
}
-
- private DeltaCloud getCloud(CloudViewElement element) {
- while (!(element instanceof CVCloudElement)) {
- element = (CloudViewElement) element.getParent();
- }
- CVCloudElement cvcloud = (CVCloudElement) element;
- DeltaCloud cloud = (DeltaCloud) cvcloud.getElement();
- return cloud;
- }
-
- private void executeInstanceAction(DeltaCloudInstance instance, DeltaCloud cloud) {
- PerformInstanceActionThread t = new PerformInstanceActionThread(cloud, instance,
- DeltaCloudInstance.STOP,
- CVMessages.getString(STOPPING_INSTANCE_TITLE),
- CVMessages.getFormattedString(STOPPING_INSTANCE_MSG, new String[] {
instance.getName() }),
- DeltaCloudInstance.STOPPED);
- t.setUser(true);
- t.schedule();
- }
}
Modified:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/CVMessages.properties
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/CVMessages.properties 2010-11-04
17:55:56 UTC (rev 26266)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/CVMessages.properties 2010-11-04
18:56:09 UTC (rev 26267)
@@ -47,10 +47,12 @@
StartingInstance.title=Starting Instance
StartingInstance.msg=Starting Instance: {0}
+StartInstancesDialog.title=Start Instances
+StartInstancesDialog.msg=Please choose the instances that shall be started by checking
them:
StoppingInstance.title=Stopping Instance
StoppingInstance.msg=Stopping Instance: {0}
StopInstancesDialog.title=Stop Instances
-StopInstancesDialog.msg=Please choose the instance that shall be stopped by checking
them:
+StopInstancesDialog.msg=Please choose the instances that shall be stopped by checking
them:
RebootingInstance.title=Rebooting Instance
RebootingInstance.msg=Rebooting Instance: {0}
DestroyingInstance.title=Destroying Instance
Added:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/CloudViewElementUtils.java
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/CloudViewElementUtils.java
(rev 0)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/CloudViewElementUtils.java 2010-11-04
18:56:09 UTC (rev 26267)
@@ -0,0 +1,26 @@
+/*******************************************************************************
+ * 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.views;
+
+import org.jboss.tools.deltacloud.core.DeltaCloud;
+
+public class CloudViewElementUtils {
+
+ public static DeltaCloud getCloud(CloudViewElement element) {
+ while (!(element instanceof CVCloudElement)) {
+ element = (CloudViewElement) element.getParent();
+ }
+ CVCloudElement cvcloud = (CVCloudElement) element;
+ DeltaCloud cloud = (DeltaCloud) cvcloud.getElement();
+ return cloud;
+ }
+
+}
Property changes on:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/CloudViewElementUtils.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 2010-11-04
17:55:56 UTC (rev 26266)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/utils/UIUtils.java 2010-11-04
18:56:09 UTC (rev 26267)
@@ -40,11 +40,9 @@
/**
* @author Andre Dietisheim
*/
-public class UIUtils
-{
-
- private UIUtils()
- {
+public class UIUtils {
+
+ private UIUtils() {
}
/**
@@ -54,8 +52,7 @@
*
* @see IWorkbenchWindow#getSelectionService()
*/
- public static ISelection getWorkbenchWindowSelection()
- {
+ public static ISelection getWorkbenchWindowSelection() {
return getActiveWorkbenchWindow().getSelectionService().getSelection();
}
@@ -64,15 +61,11 @@
*
* @return the structured selection
*/
- public static IStructuredSelection getStructuredSelection()
- {
+ public static IStructuredSelection getStructuredSelection() {
ISelection selection = getWorkbenchWindowSelection();
- if ( selection instanceof IStructuredSelection )
- {
- return ( IStructuredSelection ) selection;
- }
- else
- {
+ if (selection instanceof IStructuredSelection) {
+ return (IStructuredSelection) selection;
+ } else {
return null;
}
}
@@ -80,42 +73,56 @@
/**
* Gets the first element.
*
- * @param selection the selection
- * @param expectedClass the expected class
+ * @param selection
+ * the selection
+ * @param expectedClass
+ * the expected class
*
* @return the first element
*/
@SuppressWarnings("unchecked")
- public static <T> T getFirstElement( final ISelection selection, final
Class<T> expectedClass )
- {
- if ( selection == null )
- {
+ public static <T> T getFirstElement(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 && expectedClass.isAssignableFrom(
firstElement.getClass() ) )
- {
- return ( T ) firstElement;
- }
- else
- {
+ } else {
+ Assert.isTrue(selection instanceof IStructuredSelection);
+ Object firstElement = ((IStructuredSelection) selection).getFirstElement();
+ if (firstElement != null &&
expectedClass.isAssignableFrom(firstElement.getClass())) {
+ return (T) firstElement;
+ } else {
return null;
}
}
}
/**
+ * 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
+ && getFirstElement(selection, expectedClass) != null;
+ }
+
+ /**
* Gets the active page.
*
* @return the active page
*/
- public static IWorkbenchPage getActivePage()
- {
+ public static IWorkbenchPage getActivePage() {
IWorkbenchPage workbenchPage = getActiveWorkbenchWindow().getActivePage();
- Assert.isNotNull( workbenchPage );
+ Assert.isNotNull(workbenchPage);
return workbenchPage;
}
@@ -124,10 +131,9 @@
*
* @return the active editor
*/
- public static IEditorPart getActiveEditor()
- {
+ public static IEditorPart getActiveEditor() {
IEditorPart editor = getActivePage().getActiveEditor();
- Assert.isNotNull( editor );
+ Assert.isNotNull(editor);
return editor;
}
@@ -136,17 +142,15 @@
*
* @return the active workbench window
*/
- public static IWorkbenchWindow getActiveWorkbenchWindow()
- {
+ public static IWorkbenchWindow getActiveWorkbenchWindow() {
IWorkbenchWindow workbenchWindow = getWorkbench().getActiveWorkbenchWindow();
- Assert.isNotNull( workbenchWindow );
+ Assert.isNotNull(workbenchWindow);
return workbenchWindow;
}
- public static Shell getActiveShell()
- {
+ public static Shell getActiveShell() {
Shell shell = getActiveWorkbenchWindow().getShell();
- Assert.isTrue( shell != null && !shell.isDisposed() );
+ Assert.isTrue(shell != null && !shell.isDisposed());
return shell;
}
@@ -155,93 +159,96 @@
*
* @return the workbench
*/
- public static IWorkbench getWorkbench()
- {
+ public static IWorkbench getWorkbench() {
IWorkbench workbench = PlatformUI.getWorkbench();
- Assert.isNotNull( workbench );
+ 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
+ * @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 );
+ 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 );
+ 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.
+ * 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
+ * @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() );
+ 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()
+ 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 )
+ public void widgetDisposed(DisposeEvent e)
{
- menuService.releaseContributions( ( ContributionManager ) contributionManager );
+ menuService.releaseContributions((ContributionManager) contributionManager);
}
- } );
+ });
}
/**
* Creates context menu to a given control.
*
- * @param control the control
+ * @param control
+ * the control
*
* @return the i menu manager
*/
- public static IMenuManager createContextMenu( final Control control )
- {
- Assert.isTrue( control != null && !control.isDisposed() );
+ public static IMenuManager createContextMenu(final Control control) {
+ Assert.isTrue(control != null && !control.isDisposed());
MenuManager menuManager = new MenuManager();
- menuManager.add( new GroupMarker( IWorkbenchActionConstants.MB_ADDITIONS ) );
+ menuManager.add(new GroupMarker(IWorkbenchActionConstants.MB_ADDITIONS));
- Menu menu = menuManager.createContextMenu( control );
- control.setMenu( menu );
+ 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
+ * @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 );
+ 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 );
+ IDialogSettings section = dialogSettings.getSection(identifier);
+ if (section == null) {
+ section = dialogSettings.addNewSection(identifier);
}
return section;
}
@@ -249,18 +256,18 @@
/**
* Returns the page for a given editor.
*
- * @param editor the editor
- * @return
+ * @param editor
+ * the editor
+ * @return
*
* @return the page
*
* @see IWorkbenchPage
*/
- public static IWorkbenchPage getPage( EditorPart editor )
- {
- Assert.isNotNull( editor );
+ public static IWorkbenchPage getPage(EditorPart editor) {
+ Assert.isNotNull(editor);
IWorkbenchPartSite site = editor.getSite();
- Assert.isNotNull( site );
+ Assert.isNotNull(site);
return site.getPage();
}