diff options
author | Alena Laskavaia | 2010-04-21 01:40:15 +0000 |
---|---|---|
committer | Alena Laskavaia | 2010-04-21 01:40:15 +0000 |
commit | 56c7ec129c598246bb54eb73e19b3ab9b3747c7e (patch) | |
tree | 156fcb056ab829966046c6e406b60339a37e7bb6 | |
parent | a7b0ef2fef8ce9e96aae946cb5e6ac46eceb644f (diff) | |
download | org.eclipse.cdt-56c7ec129c598246bb54eb73e19b3ab9b3747c7e.tar.gz org.eclipse.cdt-56c7ec129c598246bb54eb73e19b3ab9b3747c7e.tar.xz org.eclipse.cdt-56c7ec129c598246bb54eb73e19b3ab9b3747c7e.zip |
- command contribution implemented properly
8 files changed, 114 insertions, 21 deletions
diff --git a/codan/org.eclipse.cdt.codan.ui.cxx/META-INF/MANIFEST.MF b/codan/org.eclipse.cdt.codan.ui.cxx/META-INF/MANIFEST.MF index a8a4137c5b6..1badca951ad 100644 --- a/codan/org.eclipse.cdt.codan.ui.cxx/META-INF/MANIFEST.MF +++ b/codan/org.eclipse.cdt.codan.ui.cxx/META-INF/MANIFEST.MF @@ -1,16 +1,18 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 -Bundle-Name: Codan Analysis UI for C/C++ +Bundle-Name: %Bundle-Name Bundle-SymbolicName: org.eclipse.cdt.codan.ui.cxx;singleton:=true Bundle-Version: 1.0.0.qualifier Bundle-Activator: org.eclipse.cdt.codan.internal.ui.cxx.Activator -Bundle-Vendor: Eclipse CDT +Bundle-Vendor: %Bundle-Vendor Require-Bundle: org.eclipse.ui, org.eclipse.core.runtime, org.eclipse.cdt.codan.core;bundle-version="1.0.0", org.eclipse.cdt.codan.core.cxx;bundle-version="1.0.0", org.eclipse.ui.editors, org.eclipse.cdt.core, - org.eclipse.cdt.ui + org.eclipse.cdt.ui, + org.eclipse.core.resources, + org.eclipse.cdt.codan.ui;bundle-version="1.0.0" Bundle-RequiredExecutionEnvironment: J2SE-1.5 Bundle-ActivationPolicy: lazy diff --git a/codan/org.eclipse.cdt.codan.ui.cxx/OSGI-INF/l10n/bundle.properties b/codan/org.eclipse.cdt.codan.ui.cxx/OSGI-INF/l10n/bundle.properties new file mode 100644 index 00000000000..a209d46e405 --- /dev/null +++ b/codan/org.eclipse.cdt.codan.ui.cxx/OSGI-INF/l10n/bundle.properties @@ -0,0 +1,4 @@ +#Properties file for org.eclipse.cdt.codan.ui.cxx +command.name = Run C/C++ Code Analysis +Bundle-Vendor = Eclipse CDT +Bundle-Name = Codan Analysis UI for C/C++
\ No newline at end of file diff --git a/codan/org.eclipse.cdt.codan.ui.cxx/build.properties b/codan/org.eclipse.cdt.codan.ui.cxx/build.properties index e9863e281ea..bbeeaf15779 100644 --- a/codan/org.eclipse.cdt.codan.ui.cxx/build.properties +++ b/codan/org.eclipse.cdt.codan.ui.cxx/build.properties @@ -2,4 +2,5 @@ source.. = src/ output.. = bin/ bin.includes = META-INF/,\ .,\ - plugin.xml + plugin.xml,\ + OSGI-INF/l10n/bundle.properties diff --git a/codan/org.eclipse.cdt.codan.ui.cxx/plugin.xml b/codan/org.eclipse.cdt.codan.ui.cxx/plugin.xml index ed16e308094..0a1b18e23cf 100644 --- a/codan/org.eclipse.cdt.codan.ui.cxx/plugin.xml +++ b/codan/org.eclipse.cdt.codan.ui.cxx/plugin.xml @@ -7,5 +7,37 @@ <startup class="org.eclipse.cdt.codan.internal.ui.cxx.Startup"></startup> </extension> + + <extension + point="org.eclipse.ui.menus"> + <menuContribution + locationURI="popup:org.eclipse.ui.popup.any?after=additions"> + <command + commandId="org.eclipse.cdt.codan.commands.runCodanCommand" + id="org.eclipse.cdt.codan.ui.cxx.menus.runCodanCxxCommand" + label="%command.name" + mnemonic="C"> + <visibleWhen checkEnabled="false"> + <iterate ifEmpty="false"> + <adapt type="org.eclipse.core.resources.IResource"> + <test property="org.eclipse.core.resources.projectNature" value="org.eclipse.cdt.core.cnature"/> + </adapt> + </iterate> + </visibleWhen> + </command> + </menuContribution> + <!-- <menuContribution + locationURI="toolbar:org.eclipse.ui.main.toolbar?after=additions"> + <toolbar + id="org.eclipse.cdt.codan.ui.cxx.toolbars.sampleToolbar"> + <command + commandId="org.eclipse.cdt.codan.ui.cxx.commands.runCodanCxxCommand" + icon="icons/sample.gif" + id="org.eclipse.cdt.codan.ui.cxx.toolbars.sampleCommand" + tooltip="%command.name"> + </command> + </toolbar> + </menuContribution> --> + </extension> </plugin> diff --git a/codan/org.eclipse.cdt.codan.ui/META-INF/MANIFEST.MF b/codan/org.eclipse.cdt.codan.ui/META-INF/MANIFEST.MF index 9254788c1bf..fec1699b2bf 100644 --- a/codan/org.eclipse.cdt.codan.ui/META-INF/MANIFEST.MF +++ b/codan/org.eclipse.cdt.codan.ui/META-INF/MANIFEST.MF @@ -13,4 +13,8 @@ Require-Bundle: org.eclipse.ui, org.eclipse.cdt.codan.core;bundle-version="1.0.0" Bundle-RequiredExecutionEnvironment: J2SE-1.5 Bundle-ActivationPolicy: lazy +Export-Package: org.eclipse.cdt.codan.internal.ui;x-friends:="org.eclipse.cdt.codan.ui.cxx", + org.eclipse.cdt.codan.internal.ui.actions;x-friends:="org.eclipse.cdt.codan.ui.cxx", + org.eclipse.cdt.codan.internal.ui.dialogs;x-friends:="org.eclipse.cdt.codan.ui.cxx", + org.eclipse.cdt.codan.internal.ui.preferences;x-friends:="org.eclipse.cdt.codan.ui.cxx" diff --git a/codan/org.eclipse.cdt.codan.ui/OSGI-INF/l10n/bundle.properties b/codan/org.eclipse.cdt.codan.ui/OSGI-INF/l10n/bundle.properties index b5bdcbf784d..59c86df0fe5 100644 --- a/codan/org.eclipse.cdt.codan.ui/OSGI-INF/l10n/bundle.properties +++ b/codan/org.eclipse.cdt.codan.ui/OSGI-INF/l10n/bundle.properties @@ -4,4 +4,6 @@ Bundle-Name = Code Analysis UI CodeAnalysisAction.label = Run Code Analysis CodeAnalysisProperties.name = Code Analysis CodeAnalysisPreferences.name = Code Analysis -CodeAnalysisPreferencesBuild.name = Launching
\ No newline at end of file +CodeAnalysisPreferencesBuild.name = Launching +category.name = Code Analysis +command.name = Run Code Analysis
\ No newline at end of file diff --git a/codan/org.eclipse.cdt.codan.ui/plugin.xml b/codan/org.eclipse.cdt.codan.ui/plugin.xml index 1989ca09d16..88e3dcb665f 100644 --- a/codan/org.eclipse.cdt.codan.ui/plugin.xml +++ b/codan/org.eclipse.cdt.codan.ui/plugin.xml @@ -3,23 +3,14 @@ <plugin> - <extension - point="org.eclipse.ui.popupMenus"> - <objectContribution - adaptable="true" - objectClass="org.eclipse.core.resources.IProject" - nameFilter="*" - id="org.eclipse.cdt.codan.ui.runaction"> - <action - label="%CodeAnalysisAction.label" - class="org.eclipse.cdt.codan.internal.ui.actions.RunCodeAnalysis" - menubarPath="additions" - enablesFor="+" - id="org.eclipse.cdt.codan.ui.actions.RunCodeAnalysis"> - </action> - </objectContribution> + <extension + point="org.eclipse.ui.commands"> + <category + id="org.eclipse.cdt.codan.ui.commands.category" + name="%category.name"> + </category> + </extension> - <extension point="org.eclipse.ui.preferencePages"> <page @@ -63,4 +54,30 @@ </initializer> </extension> + <extension + point="org.eclipse.ui.commands"> + <command + categoryId="org.eclipse.cdt.codan.ui.commands.category" + id="org.eclipse.cdt.codan.commands.runCodanCommand" + name="%command.name"> + </command> + </extension> + <extension + point="org.eclipse.ui.handlers"> + <handler + class="org.eclipse.cdt.codan.ui.handlers.RunCodanCommand" + commandId="org.eclipse.cdt.codan.commands.runCodanCommand"> + </handler> + </extension> + <!-- + <extension + point="org.eclipse.ui.bindings"> + <key + commandId="org.eclipse.cdt.codan.commands.runCodanCommand" + contextId="org.eclipse.ui.contexts.window" + schemeId="org.eclipse.ui.defaultAcceleratorConfiguration" + sequence="M1+F9"> + </key> + </extension> + --> </plugin> diff --git a/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/ui/handlers/RunCodanCommand.java b/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/ui/handlers/RunCodanCommand.java new file mode 100644 index 00000000000..b5f81ff6894 --- /dev/null +++ b/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/ui/handlers/RunCodanCommand.java @@ -0,0 +1,31 @@ +package org.eclipse.cdt.codan.ui.handlers; + +import org.eclipse.cdt.codan.internal.ui.actions.RunCodeAnalysis; +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.ui.handlers.HandlerUtil; + +/** + * Command to run code analysis AbstractHandler, an IHandler base class. + * @see org.eclipse.core.commands.IHandler + * @see org.eclipse.core.commands.AbstractHandler + */ +public class RunCodanCommand extends AbstractHandler { + + public RunCodanCommand() { + } + + /** + * the command has been executed, so extract extract the needed information + * from the application context. + */ + public Object execute(ExecutionEvent event) throws ExecutionException { + ISelection currentSelection = HandlerUtil.getCurrentSelection(event); + RunCodeAnalysis action = new RunCodeAnalysis(); + action.selectionChanged(null, currentSelection); + action.run(null); + return null; + } +} |