15 |
15 |
import org.eclipse.swt.widgets.Group;
|
16 |
16 |
import org.eclipse.swt.widgets.ToolItem;
|
17 |
17 |
import org.eclipse.ui.IEditorInput;
|
|
18 |
import org.eclipse.ui.IEditorPart;
|
18 |
19 |
import org.eclipse.ui.IEditorSite;
|
|
20 |
import org.eclipse.ui.IWorkbenchPage;
|
19 |
21 |
import org.eclipse.ui.IWorkbenchPart;
|
|
22 |
import org.eclipse.ui.IWorkbenchWindow;
|
20 |
23 |
import org.eclipse.ui.PartInitException;
|
21 |
24 |
import org.eclipse.ui.part.EditorPart;
|
|
25 |
import org.txm.chartsengine.rcp.editors.ChartEditorInput;
|
|
26 |
import org.txm.chartsengine.rcp.editors.ChartEditorPart;
|
|
27 |
import org.txm.cooccurrence.rcp.editors.CooccurrencesEditor;
|
22 |
28 |
import org.txm.core.results.ITXMResult;
|
23 |
29 |
import org.txm.rcp.IImageKeys;
|
|
30 |
import org.txm.rcp.Messages;
|
|
31 |
import org.txm.rcp.StatusLine;
|
|
32 |
import org.txm.rcp.TXMWindows;
|
24 |
33 |
import org.txm.rcp.views.corpora.CorporaView;
|
25 |
34 |
|
26 |
35 |
/**
|
... | ... | |
29 |
38 |
* @author sjacquot
|
30 |
39 |
*
|
31 |
40 |
*/
|
32 |
|
public class TXMEditorPart extends EditorPart {
|
|
41 |
public abstract class TXMEditorPart extends EditorPart {
|
33 |
42 |
|
34 |
43 |
|
35 |
44 |
|
... | ... | |
87 |
96 |
this.setVisible(this.commandParametersComposite, (this.getEditorInput().getResult() == null));
|
88 |
97 |
|
89 |
98 |
this.commandParametersGroup.pack();
|
90 |
|
|
91 |
99 |
}
|
92 |
100 |
|
93 |
101 |
|
... | ... | |
152 |
160 |
return group;
|
153 |
161 |
}
|
154 |
162 |
|
|
163 |
|
|
164 |
|
155 |
165 |
/**
|
156 |
166 |
* Sets the visibility state of the specified composite.
|
157 |
167 |
* The mechanism is based on GridData.exclude to hide the composite therefore the composite must have a GridData as layout data.
|
... | ... | |
238 |
248 |
}
|
239 |
249 |
|
240 |
250 |
/**
|
241 |
|
* Returns the result object associated with the editor.
|
|
251 |
* Returns the result object associated with the editor through its editor input.
|
242 |
252 |
* @return
|
243 |
253 |
*/
|
244 |
254 |
public ITXMResult getResultData() {
|
... | ... | |
246 |
256 |
}
|
247 |
257 |
|
248 |
258 |
|
|
259 |
/**
|
|
260 |
* Computes and creates or updates the result (from the linked editor input data).
|
|
261 |
* @param update set if it's an update on an existing result or a creation of a new result
|
|
262 |
*/
|
|
263 |
public abstract void computeResult(boolean update);
|
249 |
264 |
|
|
265 |
|
250 |
266 |
/**
|
251 |
267 |
* Synchronizes the editor with the result and refreshes the corpus view.
|
252 |
268 |
*/
|
... | ... | |
268 |
284 |
}
|
269 |
285 |
}
|
270 |
286 |
|
|
287 |
/**
|
|
288 |
* Deletes the linked TXM result.
|
|
289 |
* @return
|
|
290 |
*/
|
|
291 |
public boolean deleteResult() {
|
|
292 |
try {
|
|
293 |
return this.getEditorInput().deleteResult();
|
|
294 |
}
|
|
295 |
catch(Exception e) {
|
|
296 |
return false;
|
|
297 |
}
|
|
298 |
}
|
|
299 |
|
|
300 |
/**
|
|
301 |
* Closes the editor from the UI thread and deletes or not the linked result.
|
|
302 |
*/
|
|
303 |
public void close(final boolean deleteResult) {
|
|
304 |
final EditorPart self = this;
|
|
305 |
getSite().getShell().getDisplay().syncExec(new Runnable() {
|
|
306 |
@Override
|
|
307 |
public void run() {
|
|
308 |
getSite().getPage().closeEditor(self, false);
|
|
309 |
if(deleteResult) {
|
|
310 |
deleteResult();
|
|
311 |
}
|
|
312 |
}
|
|
313 |
});
|
|
314 |
}
|
|
315 |
|
|
316 |
/**
|
|
317 |
* Closes the editor from the UI thread.
|
|
318 |
*/
|
|
319 |
public void close() {
|
|
320 |
close(false);
|
|
321 |
}
|
|
322 |
|
|
323 |
/**
|
|
324 |
*
|
|
325 |
* @param editorInput
|
|
326 |
* @param editorPartId
|
|
327 |
* @param activate
|
|
328 |
* @param matchFlags
|
|
329 |
* @return
|
|
330 |
*/
|
|
331 |
public static TXMEditorPart openEditor(TXMResultEditorInput editorInput, String editorPartId, boolean activate, int matchFlags) {
|
|
332 |
TXMEditorPart editor = null;
|
|
333 |
try {
|
|
334 |
IWorkbenchWindow window =TXMWindows.getActiveWindow();
|
|
335 |
IWorkbenchPage page = window.getActivePage();
|
|
336 |
editor = (CooccurrencesEditor) page.openEditor(editorInput, editorPartId, activate, matchFlags);
|
|
337 |
}
|
|
338 |
catch (Exception e) {
|
|
339 |
org.txm.rcp.utils.Logger.printStackTrace(e);
|
|
340 |
}
|
|
341 |
return editor;
|
|
342 |
}
|
|
343 |
|
|
344 |
/**
|
|
345 |
*
|
|
346 |
* @param editorInput
|
|
347 |
* @param editorPartId
|
|
348 |
* @return
|
|
349 |
*/
|
|
350 |
public static TXMEditorPart openEditor(TXMResultEditorInput editorInput, String editorPartId) {
|
|
351 |
return openEditor(editorInput, editorPartId, true, IWorkbenchPage.MATCH_INPUT | IWorkbenchPage.MATCH_ID);
|
|
352 |
}
|
|
353 |
|
|
354 |
|
271 |
355 |
}
|