Revision 5403b045
Added by Patrick Plitzner over 7 years ago
eu.etaxonomy.taxeditor.editor/plugin.xml | ||
---|---|---|
1498 | 1498 |
id="eu.etaxonomy.taxeditor.editor.taxonParameterType" |
1499 | 1499 |
type="eu.etaxonomy.cdm.model.taxon.TaxonBase"> |
1500 | 1500 |
</commandParameterType> |
1501 |
<command |
|
1502 |
defaultHandler="eu.etaxonomy.taxeditor.editor.view.derivate.handler.CreateFieldUnitHandler" |
|
1503 |
id="eu.etaxonomy.taxeditor.editor.derivate.createFieldUnit" |
|
1504 |
name="%command.name.43"> |
|
1505 |
</command> |
|
1506 | 1501 |
<command |
1507 | 1502 |
defaultHandler="eu.etaxonomy.taxeditor.editor.view.derivate.handler.DeleteDerivateHandler" |
1508 | 1503 |
id="eu.etaxonomy.taxeditor.editor.derivate.deepDelete" |
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/derivate/handler/CreateFieldUnitHandler.java | ||
---|---|---|
1 |
package eu.etaxonomy.taxeditor.editor.view.derivate.handler; |
|
2 |
|
|
3 |
import org.eclipse.core.commands.AbstractHandler; |
|
4 |
import org.eclipse.core.commands.ExecutionEvent; |
|
5 |
import org.eclipse.core.commands.ExecutionException; |
|
6 |
|
|
7 |
import eu.etaxonomy.cdm.api.service.IOccurrenceService; |
|
8 |
import eu.etaxonomy.cdm.model.common.CdmBase; |
|
9 |
import eu.etaxonomy.cdm.model.occurrence.FieldUnit; |
|
10 |
import eu.etaxonomy.taxeditor.editor.view.derivate.DerivateView; |
|
11 |
import eu.etaxonomy.taxeditor.model.AbstractUtility; |
|
12 |
import eu.etaxonomy.taxeditor.model.MessagingUtils; |
|
13 |
import eu.etaxonomy.taxeditor.store.CdmStore; |
|
14 |
|
|
15 |
public class CreateFieldUnitHandler extends AbstractHandler { |
|
16 |
|
|
17 |
@Override |
|
18 |
public Object execute(ExecutionEvent event) throws ExecutionException { |
|
19 |
if(AbstractUtility.getActivePart() instanceof DerivateView){ |
|
20 |
DerivateView derivateView = (DerivateView)AbstractUtility.getActivePart(); |
|
21 |
if(derivateView.isDirty()){ |
|
22 |
MessagingUtils.warningDialog(DerivateView.VIEW_HAS_UNSAVED_CHANGES, this, DerivateView.YOU_NEED_TO_SAVE_BEFORE_PERFORMING_THIS_ACTION); |
|
23 |
return null; |
|
24 |
} |
|
25 |
FieldUnit fieldUnit = FieldUnit.NewInstance(); |
|
26 |
fieldUnit = CdmBase.deproxy(CdmStore.getService(IOccurrenceService.class).save(fieldUnit), FieldUnit.class); |
|
27 |
derivateView.getConversationHolder().commit(); |
|
28 |
derivateView.addFieldUnit(fieldUnit); |
|
29 |
derivateView.refreshTree(); |
|
30 |
} |
|
31 |
return null; |
|
32 |
} |
|
33 |
|
|
34 |
} |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/handler/CreateFieldUnitHandler.java | ||
---|---|---|
1 |
package eu.etaxonomy.taxeditor.handler; |
|
2 |
|
|
3 |
import org.eclipse.core.commands.AbstractHandler; |
|
4 |
import org.eclipse.core.commands.ExecutionEvent; |
|
5 |
import org.eclipse.core.commands.ExecutionException; |
|
6 |
import org.eclipse.jface.viewers.ISelection; |
|
7 |
import org.eclipse.jface.viewers.IStructuredSelection; |
|
8 |
import org.eclipse.ui.handlers.HandlerUtil; |
|
9 |
|
|
10 |
public class CreateFieldUnitHandler extends AbstractHandler { |
|
11 |
|
|
12 |
@Override |
|
13 |
public Object execute(ExecutionEvent event) throws ExecutionException { |
|
14 |
ISelection currentSelection = HandlerUtil.getCurrentSelection(event); |
|
15 |
if(currentSelection instanceof IStructuredSelection){ |
|
16 |
System.out.println(currentSelection); |
|
17 |
} |
|
18 |
return null; |
|
19 |
} |
|
20 |
|
|
21 |
} |
Also available in: Unified diff
Remove unused class