10 |
10 |
|
11 |
11 |
import javax.inject.Named;
|
12 |
12 |
|
13 |
|
import org.eclipse.core.runtime.IProgressMonitor;
|
14 |
|
import org.eclipse.core.runtime.IStatus;
|
15 |
|
import org.eclipse.core.runtime.Status;
|
16 |
|
import org.eclipse.core.runtime.jobs.Job;
|
17 |
13 |
import org.eclipse.e4.core.di.annotations.CanExecute;
|
18 |
14 |
import org.eclipse.e4.core.di.annotations.Execute;
|
19 |
|
import org.eclipse.e4.ui.model.application.ui.basic.MPart;
|
|
15 |
import org.eclipse.e4.ui.model.application.MApplication;
|
20 |
16 |
import org.eclipse.e4.ui.model.application.ui.menu.MHandledMenuItem;
|
21 |
17 |
import org.eclipse.e4.ui.services.IServiceConstants;
|
|
18 |
import org.eclipse.e4.ui.workbench.modeling.EModelService;
|
22 |
19 |
import org.eclipse.e4.ui.workbench.modeling.EPartService;
|
23 |
|
import org.eclipse.e4.ui.workbench.modeling.EPartService.PartState;
|
24 |
|
import org.eclipse.swt.widgets.Display;
|
25 |
20 |
|
26 |
21 |
import eu.etaxonomy.cdm.model.common.CdmBase;
|
27 |
22 |
import eu.etaxonomy.cdm.model.common.Group;
|
28 |
23 |
import eu.etaxonomy.taxeditor.editor.EditorUtil;
|
29 |
24 |
import eu.etaxonomy.taxeditor.editor.group.authority.CdmAuthorityEditor;
|
30 |
25 |
import eu.etaxonomy.taxeditor.editor.group.authority.CdmAuthorityEditorInput;
|
31 |
|
import eu.etaxonomy.taxeditor.editor.group.authority.e4.CdmAuthorityEditorE4;
|
32 |
26 |
import eu.etaxonomy.taxeditor.editor.l10n.Messages;
|
33 |
|
import eu.etaxonomy.taxeditor.model.MessagingUtils;
|
34 |
27 |
|
35 |
28 |
/**
|
36 |
29 |
* Handler which opens an instance of the {@link CdmAuthorityEditor} for a2
|
... | ... | |
47 |
40 |
|
48 |
41 |
@Execute
|
49 |
42 |
public void execute(@Named(IServiceConstants.ACTIVE_SELECTION) CdmBase selection,
|
50 |
|
EPartService partService) {
|
51 |
|
Job job = new Job(OPENING_CDM_AUTHORITIES) {
|
52 |
|
@Override
|
53 |
|
protected IStatus run(IProgressMonitor monitor) {
|
54 |
|
monitor.beginTask(OPENING_CDM_AUTHORITIES, 1);//selection.size());
|
55 |
|
|
56 |
|
if (selection instanceof Group) {
|
57 |
|
Display.getDefault().asyncExec(new Runnable() {
|
58 |
|
@Override
|
59 |
|
public void run() {
|
60 |
|
try {
|
61 |
|
MPart part = partService.createPart("eu.etaxonomy.taxeditor.editor.group.authority.e4.CdmAuthorityEditorE4");
|
62 |
|
part = partService.showPart(part, PartState.ACTIVATE);
|
63 |
|
CdmAuthorityEditorE4 editor = (CdmAuthorityEditorE4) part.getObject();
|
64 |
|
editor.init(CdmAuthorityEditorInput.NewInstance(((Group) selection).getUuid()));
|
65 |
|
} catch (Exception e) {
|
66 |
|
MessagingUtils.warningDialog(
|
67 |
|
Messages.EditCdmAuthoritiesHandler_COULD_NOT_OPEN_AUTHORITIES,
|
68 |
|
EditorUtil.class, e.getMessage());
|
69 |
|
}
|
70 |
|
}
|
71 |
|
|
72 |
|
});
|
73 |
|
monitor.worked(1);
|
74 |
|
}
|
75 |
|
monitor.done();
|
76 |
|
return Status.OK_STATUS;
|
77 |
|
}
|
78 |
|
};
|
79 |
|
job.setPriority(Job.SHORT);
|
80 |
|
job.schedule();
|
|
43 |
EPartService partService, EModelService modelService, MApplication application) {
|
|
44 |
try {
|
|
45 |
EditorUtil.openRightsEditor(CdmAuthorityEditorInput.NewInstance(((Group) selection).getUuid()), modelService, partService, application);
|
|
46 |
} catch (Exception e) {
|
|
47 |
// TODO Auto-generated catch block
|
|
48 |
e.printStackTrace();
|
|
49 |
}
|
|
50 |
// Job job = new Job(OPENING_CDM_AUTHORITIES) {
|
|
51 |
// @Override
|
|
52 |
// protected IStatus run(IProgressMonitor monitor) {
|
|
53 |
// monitor.beginTask(OPENING_CDM_AUTHORITIES, 1);//selection.size());
|
|
54 |
//
|
|
55 |
// if (selection instanceof Group) {
|
|
56 |
// Display.getDefault().asyncExec(new Runnable() {
|
|
57 |
// @Override
|
|
58 |
// public void run() {
|
|
59 |
// try {
|
|
60 |
//// MPart part = partService.createPart("eu.etaxonomy.taxeditor.editor.group.authority.e4.CdmAuthorityEditorE4");
|
|
61 |
//// part = partService.showPart(part, PartState.ACTIVATE);
|
|
62 |
//// CdmAuthorityEditorE4 editor = (CdmAuthorityEditorE4) part.getObject();
|
|
63 |
//// editor.init(CdmAuthorityEditorInput.NewInstance(((Group) selection).getUuid()));
|
|
64 |
//
|
|
65 |
// } catch (Exception e) {
|
|
66 |
// MessagingUtils.warningDialog(
|
|
67 |
// Messages.EditCdmAuthoritiesHandler_COULD_NOT_OPEN_AUTHORITIES,
|
|
68 |
// EditorUtil.class, e.getMessage());
|
|
69 |
// }
|
|
70 |
// }
|
|
71 |
//
|
|
72 |
// });
|
|
73 |
// monitor.worked(1);
|
|
74 |
// }
|
|
75 |
// monitor.done();
|
|
76 |
// return Status.OK_STATUS;
|
|
77 |
// }
|
|
78 |
// };
|
|
79 |
// job.setPriority(Job.SHORT);
|
|
80 |
// job.schedule();
|
81 |
81 |
}
|
82 |
82 |
|
83 |
83 |
@CanExecute
|
fix #7011: open the cdm authorities editor in editor area and fix that it is grayed