Revision 1c12d52c
Added by Patrick Plitzner almost 6 years ago
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/model/AbstractUtility.java | ||
---|---|---|
55 | 55 |
import org.eclipse.ui.PlatformUI; |
56 | 56 |
import org.eclipse.ui.ide.undo.WorkspaceUndoUtil; |
57 | 57 |
import org.eclipse.ui.progress.IProgressConstants; |
58 |
import org.eclipse.ui.progress.IProgressService; |
|
59 |
import org.eclipse.ui.progress.IWorkbenchSiteProgressService; |
|
60 | 58 |
|
61 | 59 |
import eu.etaxonomy.cdm.api.application.CdmApplicationState; |
62 | 60 |
import eu.etaxonomy.cdm.api.service.IProgressMonitorService; |
... | ... | |
474 | 472 |
newMonitor.worked(steps); |
475 | 473 |
} |
476 | 474 |
|
477 |
public static IProgressService getProgressService() { |
|
478 |
IWorkbench workbench = PlatformUI.getWorkbench(); |
|
479 |
return workbench.getProgressService(); |
|
480 |
} |
|
481 |
|
|
482 |
public static IWorkbenchSiteProgressService getProgressService2() { |
|
483 |
return (IWorkbenchSiteProgressService) getService(IWorkbenchSiteProgressService.class); |
|
484 |
} |
|
485 |
|
|
486 | 475 |
public static String getPluginId() { |
487 | 476 |
return "eu.taxeditor"; |
488 | 477 |
} |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/newWizard/AbstractNewEntityWizard.java | ||
---|---|---|
9 | 9 |
|
10 | 10 |
package eu.etaxonomy.taxeditor.newWizard; |
11 | 11 |
|
12 |
import org.eclipse.e4.ui.workbench.IWorkbench; |
|
12 | 13 |
import org.eclipse.jface.viewers.IStructuredSelection; |
13 | 14 |
import org.eclipse.jface.wizard.Wizard; |
14 | 15 |
import org.eclipse.swt.widgets.Display; |
15 |
import org.eclipse.ui.INewWizard; |
|
16 |
import org.eclipse.ui.ISelectionService; |
|
17 |
import org.eclipse.ui.IWorkbench; |
|
18 | 16 |
|
19 | 17 |
import eu.etaxonomy.cdm.api.conversation.ConversationHolder; |
20 | 18 |
import eu.etaxonomy.cdm.api.conversation.IConversationEnabled; |
21 | 19 |
import eu.etaxonomy.cdm.persistence.hibernate.CdmDataChangeMap; |
22 |
import eu.etaxonomy.taxeditor.model.AbstractUtility; |
|
23 | 20 |
import eu.etaxonomy.taxeditor.store.CdmStore; |
24 | 21 |
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory; |
25 | 22 |
|
26 | 23 |
/** |
27 |
* <p>Abstract AbstractNewEntityWizard class.</p> |
|
28 | 24 |
* |
29 | 25 |
* @author n.hoffmann |
30 | 26 |
* @created Jun 1, 2010 |
31 | 27 |
* @version 1.0 |
32 | 28 |
*/ |
33 | 29 |
public abstract class AbstractNewEntityWizard<T> extends Wizard implements |
34 |
INewWizard, IConversationEnabled {
|
|
30 |
IConversationEnabled { |
|
35 | 31 |
|
36 | 32 |
private ConversationHolder conversation; |
37 | 33 |
|
... | ... | |
39 | 35 |
|
40 | 36 |
private T entity; |
41 | 37 |
|
42 |
private IWorkbench workbench; |
|
43 |
|
|
44 | 38 |
private IStructuredSelection selection; |
45 | 39 |
|
46 |
/** |
|
47 |
* <p>Constructor for AbstractNewEntityWizard.</p> |
|
48 |
* |
|
49 |
* @param <T> a T object. |
|
50 |
*/ |
|
51 | 40 |
public AbstractNewEntityWizard(){ |
52 | 41 |
setWindowTitle(String.format("New %s", getEntityName())); |
53 | 42 |
} |
... | ... | |
59 | 48 |
*/ |
60 | 49 |
protected abstract String getEntityName(); |
61 | 50 |
|
62 |
/* (non-Javadoc) |
|
63 |
* @see org.eclipse.jface.wizard.Wizard#performFinish() |
|
64 |
*/ |
|
65 | 51 |
/** {@inheritDoc} */ |
66 | 52 |
@Override |
67 | 53 |
public boolean performFinish() { |
... | ... | |
72 | 58 |
return true; |
73 | 59 |
} |
74 | 60 |
|
75 |
/** |
|
76 |
* <p>Getter for the field <code>entity</code>.</p> |
|
77 |
* |
|
78 |
* @return a T object. |
|
79 |
*/ |
|
80 | 61 |
public T getEntity() { |
81 | 62 |
return entity; |
82 | 63 |
} |
83 | 64 |
|
84 |
/** |
|
85 |
* <p>Setter for the field <code>entity</code>.</p> |
|
86 |
* |
|
87 |
* @param entity a T object. |
|
88 |
*/ |
|
89 | 65 |
public void setEntity(T entity){ |
90 | 66 |
this.entity = entity; |
91 | 67 |
} |
... | ... | |
95 | 71 |
*/ |
96 | 72 |
protected abstract void saveEntity(); |
97 | 73 |
|
98 |
/* (non-Javadoc) |
|
99 |
* @see org.eclipse.ui.IWorkbenchWizard#init(org.eclipse.ui.IWorkbench, org.eclipse.jface.viewers.IStructuredSelection) |
|
100 |
*/ |
|
101 | 74 |
/** {@inheritDoc} */ |
102 |
@Override |
|
103 | 75 |
public void init(IWorkbench workbench, IStructuredSelection selection) { |
104 |
this.workbench = workbench != null ? workbench : AbstractUtility.getWorkbench(); |
|
105 |
|
|
106 |
if(selection == null){ |
|
107 |
ISelectionService service = this.workbench.getActiveWorkbenchWindow().getSelectionService(); |
|
108 |
if(service.getSelection() instanceof IStructuredSelection){ |
|
109 |
selection = (IStructuredSelection) service.getSelection(); |
|
110 |
} |
|
111 |
} |
|
112 |
this.selection = selection; |
|
113 |
|
|
114 |
formFactory = new CdmFormFactory(Display.getCurrent(), null); |
|
115 |
conversation = CdmStore.createConversation(); |
|
76 |
formFactory = new CdmFormFactory(Display.getCurrent(), null); |
|
77 |
conversation = CdmStore.createConversation(); |
|
78 |
this.selection = selection; |
|
116 | 79 |
entity = createNewEntity(); |
117 | 80 |
|
118 | 81 |
} |
119 | 82 |
|
120 |
/** |
|
121 |
* <p>createNewEntity</p> |
|
122 |
* |
|
123 |
* @return a T object. |
|
124 |
*/ |
|
125 | 83 |
protected abstract T createNewEntity(); |
126 | 84 |
|
127 |
/** |
|
128 |
* <p>getConversationHolder</p> |
|
129 |
* |
|
130 |
* @return a {@link eu.etaxonomy.cdm.api.conversation.ConversationHolder} object. |
|
131 |
*/ |
|
132 | 85 |
@Override |
133 | 86 |
public ConversationHolder getConversationHolder() { |
134 | 87 |
return conversation; |
... | ... | |
138 | 91 |
@Override |
139 | 92 |
public void update(CdmDataChangeMap changeEvents) {} |
140 | 93 |
|
141 |
/** |
|
142 |
* @return the workbench |
|
143 |
*/ |
|
144 |
public IWorkbench getWorkbench() { |
|
145 |
return workbench; |
|
146 |
} |
|
147 |
|
|
148 |
/** |
|
149 |
* @return the selection |
|
150 |
*/ |
|
151 | 94 |
public IStructuredSelection getSelection() { |
152 | 95 |
return selection; |
153 | 96 |
} |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/classification/AbstractEditWizard.java | ||
---|---|---|
21 | 21 |
import eu.etaxonomy.cdm.api.conversation.ConversationHolder; |
22 | 22 |
import eu.etaxonomy.cdm.api.conversation.IConversationEnabled; |
23 | 23 |
import eu.etaxonomy.cdm.persistence.hibernate.CdmDataChangeMap; |
24 |
import eu.etaxonomy.taxeditor.model.AbstractUtility; |
|
25 | 24 |
import eu.etaxonomy.taxeditor.store.CdmStore; |
26 | 25 |
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory; |
27 | 26 |
/** |
... | ... | |
38 | 37 |
|
39 | 38 |
private T entity; |
40 | 39 |
|
41 |
private IWorkbench workbench; |
|
42 |
|
|
43 | 40 |
@Inject |
44 | 41 |
private IEclipseContext context; |
45 | 42 |
|
... | ... | |
102 | 99 |
/** {@inheritDoc} */ |
103 | 100 |
@Override |
104 | 101 |
public void init(IWorkbench workbench, IStructuredSelection selection) { |
105 |
this.workbench = workbench != null ? workbench : AbstractUtility.getWorkbench(); |
|
106 |
|
|
107 |
|
|
108 | 102 |
formFactory = new CdmFormFactory(context.get(Shell.class).getDisplay()); |
109 | 103 |
conversation = CdmStore.createConversation(); |
110 |
|
|
111 |
|
|
112 | 104 |
} |
113 | 105 |
|
114 | 106 |
|
... | ... | |
127 | 119 |
@Override |
128 | 120 |
public void update(CdmDataChangeMap changeEvents) {} |
129 | 121 |
|
130 |
/** |
|
131 |
* @return the workbench |
|
132 |
*/ |
|
133 |
public IWorkbench getWorkbench() { |
|
134 |
return workbench; |
|
135 |
} |
|
136 |
|
|
137 |
|
|
138 |
|
|
139 | 122 |
} |
Also available in: Unified diff
ref #6913 Remove workbench and selection handling from edit/new wizards