Author: adietish
Date: 2012-01-30 08:10:08 -0500 (Mon, 30 Jan 2012)
New Revision: 38266
Added:
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/propertytable/CopyPropertyAction.java
Removed:
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/commands/
Modified:
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/plugin.xml
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ApplicationDetailsDialog.java
Log:
[JBIDE-10724] adding copy command to context menu
Modified: trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/plugin.xml
===================================================================
--- trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/plugin.xml 2012-01-30
11:35:27 UTC (rev 38265)
+++ trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/plugin.xml 2012-01-30
13:10:08 UTC (rev 38266)
@@ -270,31 +270,5 @@
id="org.jboss.tools.openshift.express.ui.server.fragment"
typeIds="org.jboss.tools.openshift.express.openshift.server.type">
</fragment>
- </extension>
- <extension
- point="org.eclipse.ui.commands">
- <command
-
id="org.jboss.tools.openshift.express.internal.ui.commands.CopyPropertyCommand"
- name="Copy property command">
- </command>
</extension>
- <extension
- point="org.eclipse.ui.menus">
- <menuContribution
-
locationURI="popup:org.jboss.tools.openshift.express.internal.ui.wizard.ApplicationDetailsDialog">
- <command
-
commandId="org.jboss.tools.openshift.express.internal.ui.commands.CopyPropertyCommand"
- icon="icons/copy_edit_co.gif"
- label="Copy"
- style="push">
- </command>
- </menuContribution>
- </extension>
- <extension
- point="org.eclipse.ui.handlers">
- <handler
-
class="org.jboss.tools.openshift.express.internal.ui.commands.CopyPropertyCommandHandler"
-
commandId="org.jboss.tools.openshift.express.internal.ui.commands.CopyPropertyCommand">
- </handler>
- </extension>
</plugin>
Added:
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/propertytable/CopyPropertyAction.java
===================================================================
---
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/propertytable/CopyPropertyAction.java
(rev 0)
+++
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/propertytable/CopyPropertyAction.java 2012-01-30
13:10:08 UTC (rev 38266)
@@ -0,0 +1,59 @@
+/*******************************************************************************
+ * Copyright (c) 2011 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.openshift.express.internal.ui.propertytable;
+
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.ISelectionProvider;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.swt.dnd.Clipboard;
+import org.eclipse.swt.dnd.TextTransfer;
+import org.eclipse.swt.dnd.Transfer;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.ISharedImages;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.actions.ActionFactory;
+import org.eclipse.ui.actions.SelectionProviderAction;
+
+/**
+ * @author Andre Dietisheim
+ */
+public class CopyPropertyAction extends SelectionProviderAction {
+
+ private ISelectionProvider selectionProvider;
+
+ public CopyPropertyAction(ISelectionProvider provider) {
+ super(provider, ActionFactory.COPY.getId());
+ initAction();
+ this.selectionProvider = provider;
+ }
+
+ protected void initAction() {
+ ISharedImages sharedImages = PlatformUI.getWorkbench().getSharedImages();
+ setImageDescriptor(sharedImages.getImageDescriptor(ISharedImages.IMG_TOOL_COPY));
+ setDisabledImageDescriptor(sharedImages.getImageDescriptor(ISharedImages.IMG_TOOL_COPY_DISABLED));
+ setActionDefinitionId(ActionFactory.COPY.getCommandId());
+ }
+
+ @Override
+ public void run() {
+ ISelection selection = selectionProvider.getSelection();
+ if (selection instanceof IStructuredSelection) {
+ IStructuredSelection structuredSelection = (IStructuredSelection) selection;
+ if (structuredSelection.getFirstElement() instanceof IProperty) {
+ IProperty property = (IProperty) structuredSelection.getFirstElement();
+ Clipboard clipboard = new Clipboard(Display.getDefault());
+ clipboard.setContents(
+ new Object[] { property.getValue() },
+ new Transfer[] { TextTransfer.getInstance() });
+ }
+ }
+ }
+}
\ No newline at end of file
Property changes on:
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/propertytable/CopyPropertyAction.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Modified:
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ApplicationDetailsDialog.java
===================================================================
---
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ApplicationDetailsDialog.java 2012-01-30
11:35:27 UTC (rev 38265)
+++
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ApplicationDetailsDialog.java 2012-01-30
13:10:08 UTC (rev 38266)
@@ -29,6 +29,7 @@
import org.eclipse.swt.widgets.Tree;
import org.eclipse.swt.widgets.TreeColumn;
import org.jboss.tools.openshift.express.internal.ui.OpenShiftImages;
+import org.jboss.tools.openshift.express.internal.ui.propertytable.CopyPropertyAction;
import
org.jboss.tools.openshift.express.internal.ui.propertytable.PropertyNameCellLabelProvider;
import
org.jboss.tools.openshift.express.internal.ui.propertytable.PropertyValueCellLabelProvider;
import org.jboss.tools.openshift.express.internal.ui.utils.UIUtils;
@@ -41,8 +42,6 @@
*/
public class ApplicationDetailsDialog extends TitleAreaDialog {
- private static final String CONTEXT_MENU_ID =
"popup:org.jboss.tools.openshift.express.internal.ui.wizard.ApplicationDetailsDialog";
-
private IApplication application;
public ApplicationDetailsDialog(IApplication application, Shell parentShell) {
@@ -70,7 +69,7 @@
TreeViewer viewer = createApplicationDetailsTable(dialogArea);
fillApplicationDetailsTable(viewer);
createContextMenu(viewer);
-
+
Label buttonsSeparator = new Label(parent, SWT.HORIZONTAL | SWT.SEPARATOR);
GridDataFactory.fillDefaults()
.align(SWT.FILL, SWT.TOP).grab(true, false).applyTo(buttonsSeparator);
@@ -80,7 +79,7 @@
private void createContextMenu(TreeViewer viewer) {
IMenuManager contextMenu = UIUtils.createContextMenu(viewer.getControl());
- UIUtils.registerContributionManager(CONTEXT_MENU_ID, contextMenu,
viewer.getControl());
+ contextMenu.add(new CopyPropertyAction(viewer));
}
private void fillApplicationDetailsTable(final TreeViewer viewer) {
@@ -128,4 +127,6 @@
protected void createButtonsForButtonBar(Composite parent) {
createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, true);
}
+
+
}