Révision 376

tmp/org.txm.rcp/src/main/java/org/txm/rcp/editors/TXMResultEditorInput.java (revision 376)
1 1
package org.txm.rcp.editors;
2 2

  
3
import java.util.HashMap;
4
import java.util.Properties;
5

  
3 6
import org.eclipse.jface.resource.ImageDescriptor;
4 7
import org.eclipse.ui.IEditorInput;
5 8
import org.eclipse.ui.IPersistableElement;
......
27 30
	
28 31
	
29 32
	
33
	//FIXME: parameters tests
34
	protected Properties params;
35
	protected ITXMResult source;
36
	
37
	
30 38
	/**
31 39
	 * Creates an editor input with no linked TXM result.
32 40
	 */
......
42 50
	public TXMResultEditorInput(ITXMResult result) {
43 51
		this.result = result;
44 52
		this.alwaysRecreateEditor = false;
53
		
45 54
	}
46 55

  
47

  
56
	//FIXME: parameters tests
57
	public TXMResultEditorInput(ITXMResult source, HashMap<String, Object> parameters) {
58
		this.source = source;
59
		this.params = params;
60
	}
61
	
48 62
	/**
49 63
	 * Gets the TXM result associated with the editor input.
50 64
	 * @return the linked result
......
92 106
		return "";
93 107
	}
94 108

  
109
	/**
110
	 * Deletes the linked TXM result.
111
	 * @return
112
	 */
113
	public boolean deleteResult()	{
114
		try {
115
			return this.result.delete();
116
		}
117
		catch(Exception e) {
118
			return false;
119
		}
120
	}
121

  
122
	
95 123
	@Override
96 124
	public boolean exists() {
97 125
		// TODO Auto-generated method stub
......
127 155
		return false;
128 156
	}
129 157

  
158

  
159
	/**
160
	 * @return the params
161
	 */
162
	public Properties getParams() {
163
		return params;
164
	}
165

  
166

  
167
	/**
168
	 * @return the source
169
	 */
170
	public ITXMResult getSource() {
171
		return source;
172
	}
173

  
130 174
	
131 175
}
tmp/org.txm.rcp/src/main/java/org/txm/rcp/editors/TXMEditorPart.java (revision 376)
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
}

Formats disponibles : Unified diff