Author: adietish
Date: 2012-01-30 04:29:32 -0500 (Mon, 30 Jan 2012)
New Revision: 38263
Added:
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/commands/
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/commands/CopyPropertyCommandHandler.java
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
09:02:53 UTC (rev 38262)
+++ trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/plugin.xml 2012-01-30
09:29:32 UTC (rev 38263)
@@ -274,8 +274,8 @@
<extension
point="org.eclipse.ui.commands">
<command
- id="org.jboss.tools.openshift.express.internal.ui.CopyCommand"
- name="New Bookmarks Folder">
+
id="org.jboss.tools.openshift.express.internal.ui.commands.CopyPropertyCommand"
+ name="Copy property command">
</command>
</extension>
<extension
@@ -283,11 +283,18 @@
<menuContribution
locationURI="popup:org.jboss.tools.openshift.express.internal.ui.wizard.ApplicationDetailsDialog">
<command
-
commandId="org.jboss.tools.openshift.express.internal.ui.CopyCommand"
+
commandId="org.jboss.tools.openshift.express.internal.ui.commands.CopyPropertyCommand"
icon="icons/copy_edit_co.gif"
label="Copy"
style="push">
</command>
</menuContribution>
- </extension>
+ </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/commands/CopyPropertyCommandHandler.java
===================================================================
---
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/commands/CopyPropertyCommandHandler.java
(rev 0)
+++
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/commands/CopyPropertyCommandHandler.java 2012-01-30
09:29:32 UTC (rev 38263)
@@ -0,0 +1,52 @@
+/*******************************************************************************
+ * 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.commands;
+
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.swt.dnd.Clipboard;
+import org.eclipse.swt.dnd.TextTransfer;
+import org.eclipse.swt.dnd.Transfer;
+import org.eclipse.ui.handlers.HandlerUtil;
+import org.jboss.tools.openshift.express.internal.ui.propertytable.IProperty;
+
+/**
+ * @author Andre Dietisheim
+ */
+public class CopyPropertyCommandHandler extends AbstractHandler {
+
+ @Override
+ public Object execute(ExecutionEvent event) throws ExecutionException {
+ ISelection selection = HandlerUtil.getCurrentSelectionChecked(event);
+ if (selection instanceof StructuredSelection) {
+ Object selectedElement = ((IStructuredSelection) selection).getFirstElement();
+ if (selectedElement instanceof IProperty) {
+ IProperty selectedProperty = (IProperty) selectedElement;
+ copyToClipboard(selectedProperty, event);
+ }
+
+ }
+ return null;
+ }
+
+ private void copyToClipboard(IProperty selectedProperty, ExecutionEvent event) {
+ TextTransfer textTransfer = TextTransfer.getInstance();
+ Clipboard clipboard = new Clipboard(HandlerUtil.getActiveShell(event).getDisplay());
+ clipboard.setContents(
+ new Object[] { selectedProperty.getValue() },
+ new Transfer[] { textTransfer });
+ }
+
+}
Property changes on:
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/commands/CopyPropertyCommandHandler.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
09:02:53 UTC (rev 38262)
+++
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ApplicationDetailsDialog.java 2012-01-30
09:29:32 UTC (rev 38263)
@@ -41,7 +41,8 @@
*/
public class ApplicationDetailsDialog extends TitleAreaDialog {
- private static final String CONTEXT_MENU =
"popup:org.jboss.tools.openshift.express.internal.ui.wizard.ApplicationDetailsDialog";
+ 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) {
@@ -68,8 +69,7 @@
GridLayoutFactory.fillDefaults().margins(10, 10).applyTo(dialogArea);
TreeViewer viewer = createApplicationDetailsTable(dialogArea);
fillApplicationDetailsTable(viewer);
- IMenuManager contextMenu = UIUtils.createContextMenu(viewer.getControl());
- UIUtils.registerContributionManager(CONTEXT_MENU, contextMenu, viewer.getControl());
+ createContextMenu(viewer);
Label buttonsSeparator = new Label(parent, SWT.HORIZONTAL | SWT.SEPARATOR);
GridDataFactory.fillDefaults()
@@ -78,6 +78,11 @@
return dialogArea;
}
+ private void createContextMenu(TreeViewer viewer) {
+ IMenuManager contextMenu = UIUtils.createContextMenu(viewer.getControl());
+ UIUtils.registerContributionManager(CONTEXT_MENU_ID, contextMenu,
viewer.getControl());
+ }
+
private void fillApplicationDetailsTable(final TreeViewer viewer) {
viewer.setInput(application);
viewer.expandToLevel(2);