File tree Expand file tree Collapse file tree 9 files changed +139
-0
lines changed
com.vogella.plugin.markers
src/com/vogella/plugin/markers/handlers Expand file tree Collapse file tree 9 files changed +139
-0
lines changed Original file line number Diff line number Diff line change 1+ <?xml version =" 1.0" encoding =" UTF-8" ?>
2+ <classpath >
3+ <classpathentry kind =" con" path =" org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8" />
4+ <classpathentry kind =" con" path =" org.eclipse.pde.core.requiredPlugins" />
5+ <classpathentry kind =" src" path =" src" />
6+ <classpathentry kind =" output" path =" bin" />
7+ </classpath >
Original file line number Diff line number Diff line change 1+ <?xml version =" 1.0" encoding =" UTF-8" ?>
2+ <projectDescription >
3+ <name >com.vogella.plugin.markers</name >
4+ <comment ></comment >
5+ <projects >
6+ </projects >
7+ <buildSpec >
8+ <buildCommand >
9+ <name >org.eclipse.jdt.core.javabuilder</name >
10+ <arguments >
11+ </arguments >
12+ </buildCommand >
13+ <buildCommand >
14+ <name >org.eclipse.pde.ManifestBuilder</name >
15+ <arguments >
16+ </arguments >
17+ </buildCommand >
18+ <buildCommand >
19+ <name >org.eclipse.pde.SchemaBuilder</name >
20+ <arguments >
21+ </arguments >
22+ </buildCommand >
23+ </buildSpec >
24+ <natures >
25+ <nature >org.eclipse.pde.PluginNature</nature >
26+ <nature >org.eclipse.jdt.core.javanature</nature >
27+ </natures >
28+ </projectDescription >
Original file line number Diff line number Diff line change 1+ eclipse.preferences.version =1
2+ org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode =enabled
3+ org.eclipse.jdt.core.compiler.codegen.targetPlatform =1.8
4+ org.eclipse.jdt.core.compiler.compliance =1.8
5+ org.eclipse.jdt.core.compiler.problem.assertIdentifier =error
6+ org.eclipse.jdt.core.compiler.problem.enumIdentifier =error
7+ org.eclipse.jdt.core.compiler.source =1.8
Original file line number Diff line number Diff line change 1+ Manifest-Version : 1.0
2+ Bundle-ManifestVersion : 2
3+ Bundle-Name : Markers
4+ Bundle-SymbolicName : com.vogella.plugin.markers;singleton:=true
5+ Bundle-Version : 1.0.0.qualifier
6+ Bundle-Vendor : VOGELLA
7+ Require-Bundle : org.eclipse.jface,
8+ org.eclipse.e4.ui.services,
9+ org.eclipse.e4.core.di.annotations,
10+ org.eclipse.core.resources,
11+ org.eclipse.core.runtime;bundle-version="3.12.0",
12+ org.eclipse.e4.core.services
13+ Bundle-RequiredExecutionEnvironment : JavaSE-1.8
Original file line number Diff line number Diff line change 1+ source.. = src/
2+ output.. = bin/
3+ bin.includes = plugin.xml,\
4+ META-INF/,\
5+ .,\
6+ icons/,\
7+ fragment.e4xmi
Original file line number Diff line number Diff line change 1+ <?xml version =" 1.0" encoding =" ASCII" ?>
2+ <fragment : ModelFragments xmi : version =" 2.0" xmlns : xmi =" http://www.omg.org/XMI" xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance" xmlns : commands =" http://www.eclipse.org/ui/2010/UIModel/application/commands" xmlns : fragment =" http://www.eclipse.org/ui/2010/UIModel/fragment" xmlns : menu =" http://www.eclipse.org/ui/2010/UIModel/application/ui/menu" xmi : id =" _BxaXACerEeWxCPrV0pAZQQ" >
3+ <fragments xsi : type =" fragment:StringModelFragment" xmi : id =" _QqSikIrOEeW7h_qdP9N9fw" featurename =" commands" parentElementId =" xpath:/" >
4+ <elements xsi : type =" commands:Command" xmi : id =" _UCYfwIrOEeW7h_qdP9N9fw" elementId =" test.handler.helloWorldCommand" commandName =" Add Task Marker" />
5+ </fragments >
6+ <fragments xsi : type =" fragment:StringModelFragment" xmi : id =" _fW12kIrOEeW7h_qdP9N9fw" featurename =" handlers" parentElementId =" xpath:/" >
7+ <elements xsi : type =" commands:Handler" xmi : id =" _k2L0IIrOEeW7h_qdP9N9fw" elementId =" org.eclipse.pde.ui.templates.handler.0" contributionURI =" bundleclass://com.vogella.plugin.markers/com.vogella.plugin.markers.handlers.AddMarkerHandler" command =" _UCYfwIrOEeW7h_qdP9N9fw" />
8+ </fragments >
9+ <fragments xsi : type =" fragment:StringModelFragment" xmi : id =" _pVgfIIrOEeW7h_qdP9N9fw" featurename =" menuContributions" parentElementId =" xpath:/" >
10+ <elements xsi : type =" menu:MenuContribution" xmi : id =" _tSwX0IrOEeW7h_qdP9N9fw" elementId =" org.eclipse.pde.ui.templates.menucontribution.0" positionInParent =" after=additions" parentId =" org.eclipse.ui.main.menu" >
11+ <children xsi : type =" menu:Menu" xmi : id =" _wg9ZMIrOEeW7h_qdP9N9fw" elementId =" org.eclipse.pde.ui.templates.menu.e4handlers" label =" E4 Handlers" >
12+ <children xsi : type =" menu:HandledMenuItem" xmi : id =" _2LM_MIrOEeW7h_qdP9N9fw" elementId =" org.eclipse.pde.ui.templates.handledmenuitem." label =" " iconURI =" platform:/plugin/com.vogella.plugin.markers/icons/Sample.png" command =" _UCYfwIrOEeW7h_qdP9N9fw" />
13+ </children >
14+ </elements >
15+ <elements xsi : type =" menu:MenuContribution" xmi : id =" _BducUIrPEeW7h_qdP9N9fw" elementId =" org.eclipse.pde.ui.templates.menucontribution.1" positionInParent =" after=additions" parentId =" popup" >
16+ <children xsi : type =" menu:Menu" xmi : id =" _Dtii0IrPEeW7h_qdP9N9fw" elementId =" org.eclipse.pde.ui.templates.menu.e4handlers" label =" E4 Handlers" iconURI =" platform:/plugin/com.vogella.plugin.markers/icons/Sample.png" >
17+ <children xsi : type =" menu:HandledMenuItem" xmi : id =" _Dtii0YrPEeW7h_qdP9N9fw" elementId =" org.eclipse.pde.ui.templates.handledmenuitem." label =" " iconURI =" platform:/plugin/com.vogella.plugin.markers/icons/Sample.png" command =" _UCYfwIrOEeW7h_qdP9N9fw" />
18+ </children >
19+ </elements >
20+ </fragments >
21+ </fragment : ModelFragments >
Original file line number Diff line number Diff line change 1+ <?xml version =" 1.0" encoding =" UTF-8" ?>
2+ <?eclipse version =" 3.4" ?>
3+ <plugin >
4+
5+ <extension
6+ id =" com.vogella.plugin.markers.fragment"
7+ point =" org.eclipse.e4.workbench.model" >
8+ <fragment
9+ apply =" initial"
10+ uri =" fragment.e4xmi" >
11+ </fragment >
12+ </extension >
13+
14+ </plugin >
Original file line number Diff line number Diff line change 1+ package com .vogella .plugin .markers .handlers ;
2+
3+ import javax .inject .Named ;
4+
5+ import org .eclipse .core .resources .IMarker ;
6+ import org .eclipse .core .resources .IResource ;
7+ import org .eclipse .e4 .core .di .annotations .Execute ;
8+ import org .eclipse .e4 .core .services .adapter .Adapter ;
9+ import org .eclipse .e4 .ui .services .IServiceConstants ;
10+ import org .eclipse .jface .viewers .IStructuredSelection ;
11+
12+
13+ public class AddMarkerHandler {
14+
15+ @ Execute
16+ public void execute (@ Named (IServiceConstants .ACTIVE_SELECTION ) IStructuredSelection selection , Adapter adapter ) {
17+
18+ if (selection == null || selection .isEmpty ()) {
19+ return ;
20+ }
21+
22+ Object firstElement = selection .getFirstElement ();
23+ IResource resource = adapter .adapt (firstElement , IResource .class );
24+
25+ if (resource != null ) {
26+ writeMarkers (resource );
27+ }
28+
29+ }
30+
31+ private void writeMarkers (IResource resource ) {
32+ try {
33+ IMarker marker = resource .createMarker (IMarker .TASK );
34+ marker .setAttribute (IMarker .MESSAGE , "This is a task" );
35+ marker .setAttribute (IMarker .PRIORITY , IMarker .PRIORITY_HIGH );
36+ } catch (Exception e ) {
37+ e .printStackTrace ();
38+ }
39+ }
40+
41+
42+ }
You can’t perform that action at this time.
0 commit comments