Project

General

Profile

Revision 8315bf09

ID8315bf09007b2be213052e4bee6ce17c8a381391
Parent 353bb041
Child d1dd048b

Added by Patrick Plitzner almost 2 years ago

ref #6774 Add owl export to feature tree editor context menu

View differences:

eu.etaxonomy.taxeditor.store/OSGI-INF/l10n/bundle.properties
203 203
handledmenuitem.label.1 = New Feature Tree
204 204
handledmenuitem.label.2 = Add Child Feature
205 205
handledmenuitem.label.3 = Add Feature
206
handledmenuitem.label.4 = Export Feature Tree
206
handledmenuitem.label.4 = Export as Word file
207 207
handledmenuitem.label.5 = Remove Feature
208 208
handledmenuitem.label.6 = Delete Feature Tree
209 209
handledmenuitem.label.7 = Kind Of Term
......
236 236
command.commandname.11 = Copy Feature
237 237
command.commandname.12 = Paste Feature
238 238
command.commandname.13 = Open Distribution Status Wizard
239

  
240
menu.label.4 = Export
241
handledmenuitem.label.14 = Export as Ontology
242
command.commandname.14 = Export as Ontology
eu.etaxonomy.taxeditor.store/OSGI-INF/l10n/bundle_de.properties
203 203
handledmenuitem.label.1 = Neuer Merkmalsbaum
204 204
handledmenuitem.label.2 = Merkmal als Kind hinzuf?gen
205 205
handledmenuitem.label.3 = Merkmal hinzuf?gen
206
handledmenuitem.label.4 = Merkmalsbaum exportieren
206
handledmenuitem.label.4 = Als Word-Datei exportieren
207 207
handledmenuitem.label.5 = Merkmal entfernen
208 208
handledmenuitem.label.6 = Merkmalsbaum l?schen
209 209
handledmenuitem.label.7 = Kind-Of Term
......
230 230
menu.label.3 = Import
231 231
handledmenuitem.label.10 = Neustarten
232 232
handledmenuitem.label.11 = Nach Updates suchen
233
command.commandname.13 = ?ffne Verbreitungsstatus Wizard
233
command.commandname.13 = ?ffne Verbreitungsstatus Wizard
234

  
235
menu.label.4 = Export
236
handledmenuitem.label.14 = Export als Ontologie
237
command.commandname.14 = Export als Ontologie
eu.etaxonomy.taxeditor.store/fragment.e4xmi
13 13
      <handlers xmi:id="_Bb0TwCFeEeiVXriJfxPIuA" elementId="eu.etaxonomy.taxeditor.featuretree.e4.handler.RemoveFeatureTreeHandlers" contributionURI="bundleclass://eu.etaxonomy.taxeditor.store/eu.etaxonomy.taxeditor.featuretree.e4.handler.RemoveFeatureTreeHandler" command="_3mqzkCFdEeiVXriJfxPIuA"/>
14 14
      <handlers xmi:id="_VSc2UGcqEee0qLTtA2ZpVQ" elementId="eu.etaxonomy.taxeditor.featuretree.e4.handler.FeatureTreeExportHandler" contributionURI="bundleclass://eu.etaxonomy.taxeditor.store/eu.etaxonomy.taxeditor.featuretree.e4.handler.FeatureTreeExportHandler" command="_I_yx4GcqEee0qLTtA2ZpVQ"/>
15 15
      <handlers xmi:id="_3wq0cGceEee0qLTtA2ZpVQ" elementId="eu.etaxonomy.taxeditor.featuretree.e4.handler.AddFeatureHandler" contributionURI="bundleclass://eu.etaxonomy.taxeditor.store/eu.etaxonomy.taxeditor.featuretree.e4.handler.AddFeatureHandler" command="_oftL0GceEee0qLTtA2ZpVQ"/>
16
      <handlers xmi:id="_DcmpgPhnEei8uPv-H2wqnw" elementId="eu.etaxonomy.taxeditor.featuretree.e4.handler.FeatureTreeExportOntologyHandler" contributionURI="bundleclass://eu.etaxonomy.taxeditor.store/eu.etaxonomy.taxeditor.featuretree.e4.handler.FeatureTreeExportOntologyHandler" command="_xyZ4oPhmEei8uPv-H2wqnw"/>
16 17
      <menus xsi:type="menu:PopupMenu" xmi:id="__Jwh4GceEee0qLTtA2ZpVQ" elementId="eu.etaxonomy.taxeditor.store.popupmenu.featureTreeEditor">
17 18
        <children xsi:type="menu:HandledMenuItem" xmi:id="_GuuM0CHXEeiP8eNo0PEm1g" elementId="eu.etaxonomy.taxeditor.store.handledmenuitem.newfeaturetree" label="%handledmenuitem.label.1" iconURI="platform:/plugin/org.eclipse.ui/icons/full/etool16/new_wiz.png" command="_AJtnsCHXEeiP8eNo0PEm1g"/>
18 19
        <children xsi:type="menu:MenuSeparator" xmi:id="_eIB1kCHXEeiP8eNo0PEm1g" elementId="eu.etaxonomy.taxeditor.store.menuseparator.5"/>
......
22 23
        <children xsi:type="menu:HandledMenuItem" xmi:id="_G_IOENj3EeidDMMI9xTsbQ" elementId="eu.etaxonomy.taxeditor.store.handledmenuitem.paste" label="%handledmenuitem.label.12" iconURI="platform:/plugin/eu.etaxonomy.taxeditor.store/icons/paste_edit.png" command="_xDk5kNjyEeidDMMI9xTsbQ"/>
23 24
        <children xsi:type="menu:HandledMenuItem" xmi:id="_QXkWYNjyEeidDMMI9xTsbQ" elementId="eu.etaxonomy.taxeditor.store.handledmenuitem.copy" label="%handledmenuitem.label.13" iconURI="platform:/plugin/eu.etaxonomy.taxeditor.store/icons/copy_edit.png" command="_cMyQ4NjyEeidDMMI9xTsbQ"/>
24 25
        <children xsi:type="menu:MenuSeparator" xmi:id="_So5f0NjyEeidDMMI9xTsbQ" elementId="eu.etaxonomy.taxeditor.store.menuseparator.7"/>
25
        <children xsi:type="menu:HandledMenuItem" xmi:id="_7vaEcGcqEee0qLTtA2ZpVQ" elementId="eu.etaxonomy.taxeditor.store.handledmenuitem.exportFeatureTree" label="%handledmenuitem.label.4" iconURI="platform:/plugin/eu.etaxonomy.taxeditor.store/icons/export.gif" command="_I_yx4GcqEee0qLTtA2ZpVQ">
26
          <visibleWhen xsi:type="ui:CoreExpression" xmi:id="_-91IQGcqEee0qLTtA2ZpVQ" coreExpressionId="isShowExperimentalFeatures"/>
26
        <children xsi:type="menu:Menu" xmi:id="_jPawUPhmEei8uPv-H2wqnw" elementId="eu.etaxonomy.taxeditor.store.menu.export" label="%menu.label.4">
27
          <children xsi:type="menu:HandledMenuItem" xmi:id="_7vaEcGcqEee0qLTtA2ZpVQ" elementId="eu.etaxonomy.taxeditor.store.handledmenuitem.exportFeatureTreeOwl" label="%handledmenuitem.label.14" iconURI="platform:/plugin/eu.etaxonomy.taxeditor.store/icons/export.gif" command="_xyZ4oPhmEei8uPv-H2wqnw">
28
            <visibleWhen xsi:type="ui:CoreExpression" xmi:id="_-91IQGcqEee0qLTtA2ZpVQ" coreExpressionId="isShowExperimentalFeatures"/>
29
          </children>
30
          <children xsi:type="menu:HandledMenuItem" xmi:id="_qcmvwPhmEei8uPv-H2wqnw" elementId="eu.etaxonomy.taxeditor.store.handledmenuitem.exportFeatureTree" label="%handledmenuitem.label.4" iconURI="platform:/plugin/eu.etaxonomy.taxeditor.store/icons/export.gif" command="_I_yx4GcqEee0qLTtA2ZpVQ">
31
            <visibleWhen xsi:type="ui:CoreExpression" xmi:id="_qcmvwfhmEei8uPv-H2wqnw" coreExpressionId="isShowExperimentalFeatures"/>
32
          </children>
27 33
        </children>
28 34
        <children xsi:type="menu:MenuSeparator" xmi:id="_TFRL0CFgEeiVXriJfxPIuA" elementId="eu.etaxonomy.taxeditor.store.menuseparator.0"/>
29 35
        <children xsi:type="menu:HandledMenuItem" xmi:id="_Beb6QGcfEee0qLTtA2ZpVQ" elementId="eu.etaxonomy.taxeditor.store.handledmenuitem.removeFeature" label="%handledmenuitem.label.5" iconURI="platform:/plugin/eu.etaxonomy.taxeditor.store/icons/delete.gif" command="_fNBtQGcjEee0qLTtA2ZpVQ"/>
......
140 146
    <elements xsi:type="commands:Command" xmi:id="_cMyQ4NjyEeidDMMI9xTsbQ" elementId="eu.etaxonomy.taxeditor.store.command.featureTree.copyFeature" commandName="%command.commandname.11"/>
141 147
    <elements xsi:type="commands:Command" xmi:id="_xDk5kNjyEeidDMMI9xTsbQ" elementId="eu.etaxonomy.taxeditor.store.command.featureTree.pasteFeature" commandName="%command.commandname.12"/>
142 148
    <elements xsi:type="commands:Command" xmi:id="_Za5DYO5vEeizn7bmbAeBkw" elementId="eu.etaxonomy.taxeditor.store.open.OpenDistributionStatusWizardHandler" commandName="%command.commandname.13"/>
149
    <elements xsi:type="commands:Command" xmi:id="_xyZ4oPhmEei8uPv-H2wqnw" elementId="eu.etaxonomy.taxeditor.store.command.featureTree.exportTreeOntology" commandName="%command.commandname.14"/>
143 150
  </fragments>
144 151
  <fragments xsi:type="fragment:StringModelFragment" xmi:id="_swGH0GhvEee3K4uKJljEYg" featurename="handlers" parentElementId="xpath:/">
145 152
    <elements xsi:type="commands:Handler" xmi:id="_rVEdIGcjEee0qLTtA2ZpVQ" elementId="eu.etaxonomy.taxeditor.featuretree.e4.handler.RemoveFeatureHandler" contributionURI="bundleclass://eu.etaxonomy.taxeditor.store/eu.etaxonomy.taxeditor.featuretree.e4.handler.RemoveFeatureHandler" command="_fNBtQGcjEee0qLTtA2ZpVQ"/>
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/featuretree/e4/handler/FeatureTreeExportOntologyHandler.java
1
/**
2
* Copyright (C) 2017 EDIT
3
* European Distributed Institute of Taxonomy
4
* http://www.e-taxonomy.eu
5
*
6
* The contents of this file are subject to the Mozilla Public License Version 1.1
7
* See LICENSE.TXT at the top of this package for the full license terms.
8
*/
9
package eu.etaxonomy.taxeditor.featuretree.e4.handler;
10

  
11
import java.io.File;
12

  
13
import javax.inject.Named;
14

  
15
import org.eclipse.core.runtime.jobs.Job;
16
import org.eclipse.e4.core.di.annotations.CanExecute;
17
import org.eclipse.e4.core.di.annotations.Execute;
18
import org.eclipse.e4.core.di.annotations.Optional;
19
import org.eclipse.e4.ui.model.application.ui.basic.MPart;
20
import org.eclipse.e4.ui.model.application.ui.menu.MHandledMenuItem;
21
import org.eclipse.e4.ui.services.IServiceConstants;
22
import org.eclipse.jface.viewers.IStructuredSelection;
23
import org.eclipse.swt.widgets.DirectoryDialog;
24
import org.eclipse.swt.widgets.Shell;
25
import org.eclipse.ui.progress.IProgressConstants;
26

  
27
import eu.etaxonomy.cdm.io.descriptive.owl.out.OwlExportConfigurator;
28
import eu.etaxonomy.cdm.model.description.FeatureTree;
29
import eu.etaxonomy.taxeditor.featuretree.e4.IFeatureTreeEditor;
30
import eu.etaxonomy.taxeditor.preference.IPreferenceKeys;
31
import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
32
import eu.etaxonomy.taxeditor.store.CdmStore;
33
import eu.etaxonomy.taxeditor.store.StoreUtil;
34

  
35
/**
36
 * @author pplitzner
37
 * @since Jul 12, 2017
38
 *
39
 */
40
public class FeatureTreeExportOntologyHandler {
41

  
42
    @Execute
43
    public void execute(@Named(IServiceConstants.ACTIVE_SHELL) Shell shell,
44
            @Named(IServiceConstants.ACTIVE_SELECTION)IStructuredSelection selection,
45
            @Named(IServiceConstants.ACTIVE_PART)MPart thisPart){
46
        IFeatureTreeEditor editor = (IFeatureTreeEditor) thisPart.getObject();
47

  
48
        if(StoreUtil.checkDirty(editor)){
49
            return;
50
        }
51

  
52
        FeatureTree selectedFeatureTree = (FeatureTree) selection.getFirstElement();
53
        DirectoryDialog dialog = new DirectoryDialog(shell);
54
        String directoryString = dialog.open();
55
        if(directoryString!=null){
56
            // create job
57
            Job job = CdmStore.getExportManager().createIOServiceJob(OwlExportConfigurator.NewInstance(null, null, selectedFeatureTree), new File(directoryString+"/"+selectedFeatureTree.getTitleCache()+".owl"));
58
            // configure the job
59
            job.setProperty(IProgressConstants.KEEP_PROPERTY, true);
60
            job.setUser(true);
61
            // schedule job
62
            job.schedule();
63
        }
64
    }
65

  
66
    @CanExecute
67
    public boolean canExecute(
68
            @Optional@Named(IServiceConstants.ACTIVE_SELECTION)IStructuredSelection selection,
69
            MHandledMenuItem menuItem) {
70
        boolean canExecute = false;
71
        canExecute = PreferencesUtil.getBooleanValue(IPreferenceKeys.SHOW_EXPERIMENTAL_FEATURES)
72
                && selection!=null
73
                && selection.size()==1
74
                && selection.getFirstElement() instanceof FeatureTree;
75
        menuItem.setVisible(canExecute);
76
        return canExecute;
77
    }
78

  
79
}

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)