Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarco Stornelli2019-04-13 07:20:09 -0400
committerJeff Johnston2019-04-24 22:32:28 -0400
commitfc2543362190076be37843e4f7f556e2f25fe538 (patch)
tree0a8fd635d99f30d7c0fd2ab4cb1dd50bdf2aecba
parent98ab473c5f19bde83877199c88651f7acba86e9f (diff)
downloadorg.eclipse.cdt-fc2543362190076be37843e4f7f556e2f25fe538.tar.gz
org.eclipse.cdt-fc2543362190076be37843e4f7f556e2f25fe538.tar.xz
org.eclipse.cdt-fc2543362190076be37843e4f7f556e2f25fe538.zip
Bug 546395 - Added "copy qualified name" feature
Change-Id: I66b544cf7d9b05fcf1e9d5641cfd5d6060fa802c Signed-off-by: Marco Stornelli <marco.stornelli@gmail.com>
-rw-r--r--core/org.eclipse.cdt.ui/META-INF/MANIFEST.MF2
-rw-r--r--core/org.eclipse.cdt.ui/icons/dlcl16/cpyqual_menu.pngbin0 -> 433 bytes
-rw-r--r--core/org.eclipse.cdt.ui/icons/elcl16/cpyqual_menu.pngbin0 -> 543 bytes
-rw-r--r--core/org.eclipse.cdt.ui/plugin.properties7
-rw-r--r--core/org.eclipse.cdt.ui/plugin.xml19
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CPluginImages.java2
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/ICHelpContextIds.java1
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/ActionMessages.java6
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/ActionMessages.properties7
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/CopyQualifiedNameAction.java179
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/ICEditorActionDefinitionIds.java6
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/CdtActionConstants.java7
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/GenerateActionGroup.java18
13 files changed, 246 insertions, 8 deletions
diff --git a/core/org.eclipse.cdt.ui/META-INF/MANIFEST.MF b/core/org.eclipse.cdt.ui/META-INF/MANIFEST.MF
index 30b6fc52ed..689e852e66 100644
--- a/core/org.eclipse.cdt.ui/META-INF/MANIFEST.MF
+++ b/core/org.eclipse.cdt.ui/META-INF/MANIFEST.MF
@@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
Bundle-SymbolicName: org.eclipse.cdt.ui; singleton:=true
-Bundle-Version: 6.4.200.qualifier
+Bundle-Version: 6.5.0.qualifier
Bundle-Activator: org.eclipse.cdt.ui.CUIPlugin
Bundle-Vendor: %providerName
Bundle-Localization: plugin
diff --git a/core/org.eclipse.cdt.ui/icons/dlcl16/cpyqual_menu.png b/core/org.eclipse.cdt.ui/icons/dlcl16/cpyqual_menu.png
new file mode 100644
index 0000000000..f11e70bb4b
--- /dev/null
+++ b/core/org.eclipse.cdt.ui/icons/dlcl16/cpyqual_menu.png
Binary files differ
diff --git a/core/org.eclipse.cdt.ui/icons/elcl16/cpyqual_menu.png b/core/org.eclipse.cdt.ui/icons/elcl16/cpyqual_menu.png
new file mode 100644
index 0000000000..7cb025686d
--- /dev/null
+++ b/core/org.eclipse.cdt.ui/icons/elcl16/cpyqual_menu.png
Binary files differ
diff --git a/core/org.eclipse.cdt.ui/plugin.properties b/core/org.eclipse.cdt.ui/plugin.properties
index 457ea7d805..1ca78dfdc6 100644
--- a/core/org.eclipse.cdt.ui/plugin.properties
+++ b/core/org.eclipse.cdt.ui/plugin.properties
@@ -82,6 +82,9 @@ asmEditor.description=Editor for Assembly Source Files
category.source.name=C/C++ Source
category.source.description= C/C++ Source Actions
+ActionDefinition.copyQualifiedName.name= Copy Qualified Name
+ActionDefinition.copyQualifiedName.description= Copy a fully qualified name to the system clipboard
+
ActionDefinition.sourceQuickMenu.name= Show Source Quick Menu
ActionDefinition.sourceQuickMenu.description= Shows the source quick menu
@@ -681,4 +684,6 @@ semanticHighlightingExtensionPoint = Semantic Highlighting Extension Point
UserSettingEntries.name = CDT User Setting Entries
-toolchains.preferences.name = Core Build Toolchains \ No newline at end of file
+toolchains.preferences.name = Core Build Toolchains
+
+CopyQualifiedName.label= Cop&y Qualified Name \ No newline at end of file
diff --git a/core/org.eclipse.cdt.ui/plugin.xml b/core/org.eclipse.cdt.ui/plugin.xml
index 6246ea0e62..802941373b 100644
--- a/core/org.eclipse.cdt.ui/plugin.xml
+++ b/core/org.eclipse.cdt.ui/plugin.xml
@@ -1961,6 +1961,14 @@
</action>
<!-- Edit group -->
<action
+ definitionId="org.eclipse.cdt.ui.edit.text.c.copy.qualified.name"
+ label="%CopyQualifiedName.label"
+ retarget="true"
+ menubarPath="org.eclipse.jdt.ui.source.menu/editGroup"
+ icon="$nl$/icons/elcl16/cpyqual_menu.png"
+ id="org.eclipse.cdt.ui.actions.CopyQualifiedName">
+ </action>
+ <action
definitionId="org.eclipse.cdt.ui.edit.text.c.format"
label="%FormatAction.label"
retarget="true"
@@ -2398,6 +2406,11 @@
contextId="org.eclipse.cdt.ui.cEditorScope"
commandId="org.eclipse.cdt.ui.edit.text.c.toggle.comment"/>
<key
+ sequence="M1+Q"
+ schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"
+ contextId="org.eclipse.cdt.ui.cEditorScope"
+ commandId="org.eclipse.cdt.ui.edit.text.c.copy.qualified.name"/>
+ <key
sequence="M1+7"
schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"
contextId="org.eclipse.cdt.ui.cEditorScope"
@@ -2957,6 +2970,12 @@
id="org.eclipse.cdt.ui.category.source">
</category>
<command
+ name="%ActionDefinition.copyQualifiedName.name"
+ description="%ActionDefinition.copyQualifiedName.description"
+ categoryId="org.eclipse.cdt.ui.category.source"
+ id="org.eclipse.cdt.ui.edit.text.c.copy.qualified.name">
+ </command>
+ <command
name="%ActionDefinition.format.name"
description="%ActionDefinition.format.description"
categoryId="org.eclipse.cdt.ui.category.source"
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CPluginImages.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CPluginImages.java
index b62561b2f9..a69660fcbd 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CPluginImages.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CPluginImages.java
@@ -574,6 +574,8 @@ public class CPluginImages {
public static final ImageDescriptor DESC_ELCL_NAVIGATE_FORWARD = createUnManaged(T_ELCL, "forward_nav.gif"); //$NON-NLS-1$
public static final ImageDescriptor DESC_ELCL_OPEN_DECLARATION = createUnManaged(T_ELCL, "goto_input.gif"); //$NON-NLS-1$
+ public static final ImageDescriptor DESC_DLCL_COPY_QUALIFIED_NAME = createUnManaged(T_DLCL, "cpyqual_menu.png"); //$NON-NLS-1$
+ public static final ImageDescriptor DESC_ELCL_COPY_QUALIFIED_NAME = createUnManaged(T_ELCL, "cpyqual_menu.png"); //$NON-NLS-1$
// incorrectly defined descriptors
/** @deprecated as of CDT 8.0. */
@Deprecated
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/ICHelpContextIds.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/ICHelpContextIds.java
index f5014ea764..3a5e0dffa4 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/ICHelpContextIds.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/ICHelpContextIds.java
@@ -51,6 +51,7 @@ public interface ICHelpContextIds {
public static final String TOGGLE_MARK_OCCURRENCES_ACTION = PREFIX + "toggle_mark_occurrences_action_context"; //$NON-NLS-1$
public static final String FORMAT_ALL = PREFIX + "format_all_action"; //$NON-NLS-1$
public static final String GOTO_MATCHING_BRACKET_ACTION = PREFIX + "goto_matching_bracket_action"; //$NON-NLS-1$
+ public static final String COPY_QUALIFIED_NAME_ACTION = PREFIX + "copy_qualified_name_action_context"; //$NON-NLS-1$
// Preference/property pages
public static final String C_PREF_PAGE = PREFIX + "c_pref"; //$NON-NLS-1$
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/ActionMessages.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/ActionMessages.java
index 276f39a1df..862faf8219 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/ActionMessages.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/ActionMessages.java
@@ -105,6 +105,12 @@ public class ActionMessages extends NLS {
public static String ExpandAllAction_label;
public static String ExpandAllAction_tooltip;
public static String ExpandAllAction_description;
+ public static String CopyQualifiedNameAction_ToolTipText;
+ public static String CopyQualifiedNameAction_InfoDialogTitel;
+ public static String CopyQualifiedNameAction_ErrorDescription;
+ public static String CopyQualifiedNameAction_ActionName;
+ public static String CopyQualifiedNameAction_ErrorTitle;
+ public static String CopyQualifiedNameAction_NoElementToQualify;
static {
// Initialize resource bundle.
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/ActionMessages.properties b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/ActionMessages.properties
index aba32e9c22..baeddfc01b 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/ActionMessages.properties
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/ActionMessages.properties
@@ -127,3 +127,10 @@ CollapseAllAction_description=Collapse All
ExpandAllAction_label=Expand All
ExpandAllAction_tooltip=Expand All
ExpandAllAction_description=Expand All
+
+CopyQualifiedNameAction_ToolTipText=Copy to fully qualified name to the system Clipboard
+CopyQualifiedNameAction_InfoDialogTitel=Copy Qualified Name
+CopyQualifiedNameAction_ErrorDescription=There was a problem when accessing the system clipboard. Retry?
+CopyQualifiedNameAction_ActionName=Cop&y Qualified Name
+CopyQualifiedNameAction_ErrorTitle=Problem Copying to Clipboard
+CopyQualifiedNameAction_NoElementToQualify=No Element to qualify found in selection.
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/CopyQualifiedNameAction.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/CopyQualifiedNameAction.java
new file mode 100644
index 0000000000..1e6444cc1a
--- /dev/null
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/CopyQualifiedNameAction.java
@@ -0,0 +1,179 @@
+/*******************************************************************************
+ * Copyright (c) 2019 Marco Stornelli
+ *
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
+ * https://www.eclipse.org/legal/epl-2.0/
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.actions;
+
+import org.eclipse.cdt.core.browser.IQualifiedTypeName;
+import org.eclipse.cdt.core.dom.ast.ASTVisitor;
+import org.eclipse.cdt.core.dom.ast.DOMException;
+import org.eclipse.cdt.core.dom.ast.IASTName;
+import org.eclipse.cdt.core.dom.ast.IASTNode;
+import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
+import org.eclipse.cdt.core.dom.ast.IBinding;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPBinding;
+import org.eclipse.cdt.core.model.ITranslationUnit;
+import org.eclipse.cdt.internal.ui.CPluginImages;
+import org.eclipse.cdt.internal.ui.ICHelpContextIds;
+import org.eclipse.cdt.internal.ui.editor.CEditorMessages;
+import org.eclipse.cdt.ui.CDTUITools;
+import org.eclipse.cdt.ui.CUIPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.text.ITextSelection;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.ISelectionProvider;
+import org.eclipse.swt.SWTError;
+import org.eclipse.swt.dnd.Clipboard;
+import org.eclipse.swt.dnd.DND;
+import org.eclipse.swt.dnd.TextTransfer;
+import org.eclipse.swt.dnd.Transfer;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.texteditor.ITextEditor;
+import org.eclipse.ui.texteditor.TextEditorAction;
+
+public class CopyQualifiedNameAction extends TextEditorAction {
+
+ private ITextEditor fEditor;
+
+ private static class NameVisitor extends ASTVisitor {
+ private String qualifiedName;
+
+ public NameVisitor() {
+ shouldVisitNames = true;
+ qualifiedName = null;
+ }
+
+ @Override
+ public int visit(IASTName name) {
+ IBinding b = name.resolveBinding();
+ if (b instanceof ICPPBinding) {
+ try {
+ qualifiedName = String.join(IQualifiedTypeName.QUALIFIER, ((ICPPBinding) b).getQualifiedName());
+ } catch (DOMException e) {
+ CUIPlugin.log(e);
+ }
+ }
+ return PROCESS_ABORT;
+ }
+
+ public String getQualifiedName() {
+ return qualifiedName;
+ }
+ }
+
+ public CopyQualifiedNameAction(ITextEditor editor) {
+ super(CEditorMessages.getBundleForConstructedKeys(), "CopyQualifiedName.", editor); //$NON-NLS-1$
+ fEditor = editor;
+ setText(ActionMessages.CopyQualifiedNameAction_ActionName);
+ setToolTipText(ActionMessages.CopyQualifiedNameAction_ToolTipText);
+ setDisabledImageDescriptor(CPluginImages.DESC_DLCL_COPY_QUALIFIED_NAME);
+ setImageDescriptor(CPluginImages.DESC_ELCL_COPY_QUALIFIED_NAME);
+ PlatformUI.getWorkbench().getHelpSystem().setHelp(this, ICHelpContextIds.COPY_QUALIFIED_NAME_ACTION);
+ }
+
+ private boolean isValidSelection(ITextSelection selection) {
+ if (selection == null || selection.isEmpty() || selection.getLength() <= 0)
+ return false;
+ final int offset = selection.getOffset();
+ final int length = selection.getLength();
+ ITranslationUnit translationUnit = (ITranslationUnit) CDTUITools
+ .getEditorInputCElement(fEditor.getEditorInput());
+ String qualName = null;
+ try {
+ IASTTranslationUnit ast = translationUnit.getAST(null, 0);
+ if (ast != null) {
+ IASTNode enclosingNode = ast.getNodeSelector(null).findEnclosingNode(offset, length);
+ NameVisitor n = new NameVisitor();
+ enclosingNode.accept(n);
+ qualName = n.getQualifiedName();
+ }
+ } catch (CoreException e) {
+ return false;
+ }
+ return qualName != null;
+ }
+
+ @Override
+ public void update() {
+ super.update();
+ if (isEnabled()) {
+ setEnabled(isValidSelection(getCurrentSelection()));
+ }
+ }
+
+ /**
+ * Returns the editor's selection, or <code>null</code> if no selection can be obtained or the
+ * editor is <code>null</code>.
+ *
+ * @return the selection of the action's editor, or <code>null</code>
+ */
+ protected ITextSelection getCurrentSelection() {
+ if (fEditor != null) {
+ ISelectionProvider provider = fEditor.getSelectionProvider();
+ if (provider != null) {
+ ISelection selection = provider.getSelection();
+ if (selection instanceof ITextSelection)
+ return (ITextSelection) selection;
+ }
+ }
+ return null;
+ }
+
+ @Override
+ public void run() {
+ ITextSelection textSelection = getCurrentSelection();
+
+ if (textSelection == null || !isValidSelection(textSelection)) {
+ return;
+ }
+
+ final int offset = textSelection.getOffset();
+ final int length = textSelection.getLength();
+ ITranslationUnit translationUnit = (ITranslationUnit) CDTUITools
+ .getEditorInputCElement(fEditor.getEditorInput());
+ String qualName = null;
+ try {
+ IASTTranslationUnit ast = translationUnit.getAST(null, 0);
+ if (ast != null) {
+ IASTNode enclosingNode = ast.getNodeSelector(null).findEnclosingNode(offset, length);
+ NameVisitor n = new NameVisitor();
+ enclosingNode.accept(n);
+ qualName = n.getQualifiedName();
+ }
+ } catch (CoreException e) {
+ CUIPlugin.log(e);
+ }
+
+ final Shell shell = fEditor.getEditorSite().getShell();
+
+ if (qualName == null) {
+ MessageDialog.openInformation(shell, ActionMessages.CopyQualifiedNameAction_InfoDialogTitel,
+ ActionMessages.CopyQualifiedNameAction_NoElementToQualify);
+ return;
+ }
+
+ Clipboard clipboard = new Clipboard(shell.getDisplay());
+ try {
+ clipboard.setContents(new String[] { qualName }, new Transfer[] { TextTransfer.getInstance() });
+ } catch (SWTError e) {
+ if (e.code != DND.ERROR_CANNOT_SET_CLIPBOARD) {
+ throw e;
+ }
+ if (MessageDialog.openQuestion(shell, ActionMessages.CopyQualifiedNameAction_ErrorTitle,
+ ActionMessages.CopyQualifiedNameAction_ErrorDescription)) {
+ clipboard.setContents(new String[] { qualName }, new Transfer[] { TextTransfer.getInstance() });
+ }
+ } finally {
+ clipboard.dispose();
+ }
+ }
+
+}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/ICEditorActionDefinitionIds.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/ICEditorActionDefinitionIds.java
index 7a46b6df4e..81d8b31c12 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/ICEditorActionDefinitionIds.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/ICEditorActionDefinitionIds.java
@@ -315,4 +315,10 @@ public interface ICEditorActionDefinitionIds extends ITextEditorActionDefinition
* (value <code>"org.eclipse.cdt.ui.edit.text.c.select.last"</code>).
*/
public static final String SELECT_LAST = "org.eclipse.cdt.ui.edit.text.c.select.last"; //$NON-NLS-1$
+
+ /**
+ * Action definition ID of the edit -> copy qualified name
+ * (value <code>"org.eclipse.cdt.ui.edit.text.c.copy.qualified.name"</code>).
+ */
+ public static final String COPY_QUALIFIED_NAME = "org.eclipse.cdt.ui.edit.text.c.copy.qualified.name"; //$NON-NLS-1$
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/CdtActionConstants.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/CdtActionConstants.java
index e9aa791452..6a3dfbfcbf 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/CdtActionConstants.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/CdtActionConstants.java
@@ -494,4 +494,11 @@ public class CdtActionConstants {
* <code>"org.eclipse.cdt.ui.actions.ExceptionOccurrences"</code>).
*/
public static final String FIND_EXCEPTION_OCCURRENCES = "org.eclipse.cdt.ui.actions.ExceptionOccurrences"; //$NON-NLS-1$
+
+ /**
+ * Source menu: name of standard action to copy fully qualified names (value
+ * <code>"org.eclipse.cdt.ui.actions.CopyQualifiedName"</code>).
+ * @since 6.5
+ */
+ public static final String COPY_QUALIFIED_NAME = "org.eclipse.cdt.ui.actions.CopyQualifiedName"; //$NON-NLS-1$
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/GenerateActionGroup.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/GenerateActionGroup.java
index 9039ada687..933b70e474 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/GenerateActionGroup.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/GenerateActionGroup.java
@@ -23,6 +23,7 @@ import org.eclipse.cdt.core.model.ISourceReference;
import org.eclipse.cdt.internal.ui.IContextMenuConstants;
import org.eclipse.cdt.internal.ui.actions.ActionMessages;
import org.eclipse.cdt.internal.ui.actions.CDTQuickMenuCreator;
+import org.eclipse.cdt.internal.ui.actions.CopyQualifiedNameAction;
import org.eclipse.cdt.internal.ui.editor.AddIncludeAction;
import org.eclipse.cdt.internal.ui.editor.CEditor;
import org.eclipse.cdt.internal.ui.editor.ICEditorActionDefinitionIds;
@@ -134,7 +135,7 @@ public class GenerateActionGroup extends ActionGroup implements ISelectionChange
// private SortMembersAction fSortMembers;
private SortLinesAction fSortLines;
private FormatAllAction fFormatAll;
- // private CopyQualifiedNameAction fCopyQualifiedNameAction;
+ private CopyQualifiedNameAction fCopyQualifiedNameAction;
//
private static final String QUICK_MENU_ID = "org.eclipse.cdt.ui.edit.text.c.source.quickMenu"; //$NON-NLS-1$
@@ -172,10 +173,10 @@ public class GenerateActionGroup extends ActionGroup implements ISelectionChange
fSortLines.setActionDefinitionId(ICEditorActionDefinitionIds.SORT_LINES);
editor.setAction("SortLines", fSortLines); //$NON-NLS-1$
- // IAction pastAction= editor.getAction(ITextEditorActionConstants.PASTE);//IWorkbenchActionDefinitionIds.PASTE);
- // fCopyQualifiedNameAction= new CopyQualifiedNameAction(editor, null, pastAction);
- // fCopyQualifiedNameAction.setActionDefinitionId(CopyQualifiedNameAction.JAVA_EDITOR_ACTION_DEFINITIONS_ID);
- // editor.setAction("CopyQualifiedName", fCopyQualifiedNameAction); //$NON-NLS-1$
+ fCopyQualifiedNameAction = new CopyQualifiedNameAction(editor);
+ fCopyQualifiedNameAction.setActionDefinitionId(ICEditorActionDefinitionIds.COPY_QUALIFIED_NAME);
+ editor.setAction("CopyQualifiedName", fCopyQualifiedNameAction); //$NON-NLS-1$
+ editor.markAsSelectionDependentAction("CopyQualifiedName", true); //$NON-NLS-1$
//
// fOverrideMethods= new OverrideMethodsAction(editor);
// fOverrideMethods.setActionDefinitionId(ICEditorActionDefinitionIds.OVERRIDE_METHODS);
@@ -307,6 +308,8 @@ public class GenerateActionGroup extends ActionGroup implements ISelectionChange
//
fFormatAll = new FormatAllAction(site);
fFormatAll.setActionDefinitionId(ICEditorActionDefinitionIds.FORMAT);
+ // fCopyQualifiedNameAction = new CopyQualifiedNameAction(site);
+ // fCopyQualifiedNameAction.setActionDefinitionId(ICEditorActionDefinitionIds.COPY_QUALIFIED_NAME);
//
// fCleanUp= new CleanUpAction(site);
// fCleanUp.setActionDefinitionId(ICEditorActionDefinitionIds.CLEAN_UP);
@@ -346,6 +349,7 @@ public class GenerateActionGroup extends ActionGroup implements ISelectionChange
// registerSelectionListener(fSelectionProvider, fSortMembers);
registerSelectionListener(fSelectionProvider, fAddTaskAction);
// registerSelectionListener(fSelectionProvider, fCleanUp);
+ // registerSelectionListener(fSelectionProvider, fCopyQualifiedNameAction);
selectionChanged(new SelectionChangedEvent(fSelectionProvider, selection));
registerSelectionListener(fSelectionProvider, this);
@@ -430,6 +434,7 @@ public class GenerateActionGroup extends ActionGroup implements ISelectionChange
added += addEditorAction(source, ITextEditorActionConstants.SHIFT_LEFT);
added += addEditorAction(source, "Indent"); //$NON-NLS-1$
added += addEditorAction(source, "Format"); //$NON-NLS-1$
+ added += addAction(source, fCopyQualifiedNameAction);
source.add(new Separator(GROUP_ORGANIZE));
added += addAction(source, fAddInclude);
added += addAction(source, fOrganizeIncludes);
@@ -456,6 +461,7 @@ public class GenerateActionGroup extends ActionGroup implements ISelectionChange
// added+= addAction(source, fAddCppDocStub);
source.add(new Separator(GROUP_EDIT));
added += addAction(source, fFormatAll);
+ added += addAction(source, fCopyQualifiedNameAction);
source.add(new Separator(GROUP_ORGANIZE));
added += addAction(source, fAddInclude);
added += addAction(source, fOrganizeIncludes);
@@ -515,7 +521,7 @@ public class GenerateActionGroup extends ActionGroup implements ISelectionChange
actionBar.setGlobalActionHandler(IDEActionFactory.ADD_TASK.getId(), fAddTaskAction);
actionBar.setGlobalActionHandler(CdtActionConstants.FORMAT, fFormatAll);
} else {
- // actionBar.setGlobalActionHandler(CopyQualifiedNameAction.ACTION_HANDLER_ID, fCopyQualifiedNameAction);
+ actionBar.setGlobalActionHandler(CdtActionConstants.COPY_QUALIFIED_NAME, fCopyQualifiedNameAction);
}
}

Back to the top