Révision 2974

tmp/org.txm.edition.rcp/src/org/txm/edition/rcp/editors/EditionLink.java (revision 2974)
4 4

  
5 5
import org.eclipse.swt.browser.Browser;
6 6
import org.eclipse.swt.browser.BrowserFunction;
7
import org.txm.core.results.TXMResult;
7 8
import org.txm.edition.rcp.handlers.BackToText;
8 9
import org.txm.edition.rcp.messages.EditionUIMessages;
10
import org.txm.rcp.editors.TXMEditor;
11

  
9 12
/**
10 13
 * Browser Javascript method to open a TXM edition given 1 to 4 parameters : corpusid, editionid, textid, wordid
14
 * 
11 15
 * @author mdecorde
12 16
 *
13 17
 */
14 18
public class EditionLink extends BrowserFunction {
15

  
19
	
16 20
	String data = ""; //$NON-NLS-1$
21
	
17 22
	Browser browser;
18
	SynopticEditionEditor synopticEditionEditor;
19

  
20
	EditionLink (SynopticEditionEditor synopticEditionEditor, Browser browser) {
21
		super (browser, "txmedition"); //$NON-NLS-1$
23
	
24
	TXMEditor<? extends TXMResult> synopticEditionEditor;
25
	
26
	EditionLink(TXMEditor<? extends TXMResult> synopticEditionEditor, Browser browser) {
27
		super(browser, "txmedition"); //$NON-NLS-1$
22 28
		this.browser = browser;
23 29
		this.synopticEditionEditor = synopticEditionEditor;
24 30
	}
25

  
26
	public Object function (Object[] arguments) { // corpus id, edition id, text id, word id
27
		HashMap<String, String> params = new HashMap<String, String>();
28

  
31
	
32
	@Override
33
	public Object function(Object[] arguments) { // corpus id, edition id, text id, word id
34
		HashMap<String, String> params = new HashMap<>();
35
		
29 36
		String id = BackToText.class.getName();
30

  
37
		
31 38
		if (arguments.length == 4) {
32
			params.put(id+".corpusid", arguments[0].toString()); //$NON-NLS-1$
33
			params.put(id+".editionid", arguments[1].toString()); //$NON-NLS-1$
34
			params.put(id+".textid", arguments[2].toString()); //$NON-NLS-1$
35
			params.put(id+".wordid", arguments[3].toString()); //$NON-NLS-1$
36
		} else if (arguments.length == 3) {
37
			params.put(id+".corpusid", arguments[0].toString()); //$NON-NLS-1$
38
			params.put(id+".editionid", arguments[1].toString()); //$NON-NLS-1$
39
			params.put(id+".textid", arguments[2].toString()); //$NON-NLS-1$
40
			params.put(id+".wordid", null); //$NON-NLS-1$
41
		} else if (arguments.length == 2) {
42
			params.put(id+".corpusid", arguments[0].toString()); //$NON-NLS-1$
43
			params.put(id+".editionid", arguments[1].toString()); //$NON-NLS-1$
44
			params.put(id+".textid", null); //$NON-NLS-1$
45
			params.put(id+".wordid", null); //$NON-NLS-1$
46
		} else if (arguments.length == 1) {
47
			params.put(id+".corpusid", arguments[0].toString()); //$NON-NLS-1$
48
			params.put(id+".editionid", null); //$NON-NLS-1$
49
			params.put(id+".textid", null); //$NON-NLS-1$
50
			params.put(id+".wordid", null); //$NON-NLS-1$
51
		} else {
39
			params.put(id + ".corpusid", arguments[0].toString()); //$NON-NLS-1$
40
			params.put(id + ".editionid", arguments[1].toString()); //$NON-NLS-1$
41
			params.put(id + ".textid", arguments[2].toString()); //$NON-NLS-1$
42
			params.put(id + ".wordid", arguments[3].toString()); //$NON-NLS-1$
43
		}
44
		else if (arguments.length == 3) {
45
			params.put(id + ".corpusid", arguments[0].toString()); //$NON-NLS-1$
46
			params.put(id + ".editionid", arguments[1].toString()); //$NON-NLS-1$
47
			params.put(id + ".textid", arguments[2].toString()); //$NON-NLS-1$
48
			params.put(id + ".wordid", null); //$NON-NLS-1$
49
		}
50
		else if (arguments.length == 2) {
51
			params.put(id + ".corpusid", arguments[0].toString()); //$NON-NLS-1$
52
			params.put(id + ".editionid", arguments[1].toString()); //$NON-NLS-1$
53
			params.put(id + ".textid", null); //$NON-NLS-1$
54
			params.put(id + ".wordid", null); //$NON-NLS-1$
55
		}
56
		else if (arguments.length == 1) {
57
			params.put(id + ".corpusid", arguments[0].toString()); //$NON-NLS-1$
58
			params.put(id + ".editionid", null); //$NON-NLS-1$
59
			params.put(id + ".textid", null); //$NON-NLS-1$
60
			params.put(id + ".wordid", null); //$NON-NLS-1$
61
		}
62
		else {
52 63
			System.out.println(EditionUIMessages.errorColonTxmeditioncorpusidEditionidTextidWordidCalledWithNoArguments);
53 64
			return null;
54 65
		}
55

  
66
		
56 67
		return SynopticEditionEditor.callTXMCommand(id, params);
57 68
	}
58
}
69
}
tmp/org.txm.edition.rcp/src/org/txm/edition/rcp/editors/CommandLink.java (revision 2974)
2 2

  
3 3
import org.eclipse.swt.browser.Browser;
4 4
import org.eclipse.swt.browser.BrowserFunction;
5
import org.txm.core.results.TXMResult;
5 6
import org.txm.edition.rcp.messages.EditionUIMessages;
7
import org.txm.rcp.editors.TXMEditor;
6 8

  
7 9
public class CommandLink extends BrowserFunction {
8 10
	
9 11
	String data = EditionUIMessages.CommandLink_empty;
12
	
10 13
	Browser browser;
11
	SynopticEditionEditor synopticEditionEditor;
12 14
	
13
	CommandLink (SynopticEditionEditor synopticEditionEditor, Browser browser) {
14
		super (browser, "txmcommand"); //$NON-NLS-1$
15
	TXMEditor<? extends TXMResult> editor;
16
	
17
	CommandLink(TXMEditor<? extends TXMResult> editor, Browser browser) {
18
		super(browser, "txmcommand"); //$NON-NLS-1$
15 19
		this.browser = browser;
16
		this.synopticEditionEditor = synopticEditionEditor;
20
		this.editor = editor;
17 21
	}
18 22
	
19
	public Object function (Object[] arguments) {
20
		if (synopticEditionEditor != null) {
21
			try { //TODO add option (or another browser command) to not force activated editor
22
				synopticEditionEditor.getSite().getPage().activate(synopticEditionEditor);
23
			} catch (Exception e) {
23
	@Override
24
	public Object function(Object[] arguments) {
25
		if (editor != null) {
26
			try { // TODO add option (or another browser command) to not force activated editor
27
				editor.getSite().getPage().activate(editor);
28
			}
29
			catch (Exception e) {
24 30
				System.out.println(e);
25 31
			}
26 32
		}
27 33
		return SynopticEditionEditor.callTXMCommand(arguments);
28 34
	}
29
}
35
}
tmp/org.txm.properties.rcp/src/org/txm/properties/rcp/editors/DocumentationTab.java (revision 2974)
1
package org.txm.properties.rcp.editors;
2

  
3
import java.io.File;
4
import java.net.MalformedURLException;
5

  
6
import org.eclipse.swt.SWT;
7
import org.eclipse.swt.browser.Browser;
8
import org.eclipse.swt.layout.GridData;
9
import org.eclipse.swt.widgets.Label;
10
import org.eclipse.swt.widgets.TabFolder;
11
import org.eclipse.swt.widgets.TabItem;
12
import org.txm.core.results.TXMResult;
13
import org.txm.objects.Project;
14
import org.txm.properties.rcp.Messages;
15
import org.txm.rcp.swt.GLComposite;
16
import org.txm.utils.logger.Log;
17

  
18
/**
19
 * Page displayed if Properties parent is a Corpus
20
 * 
21
 * @author mdecorde
22
 *
23
 */
24
public class DocumentationTab extends PropertiesTab {
25
	
26
	TXMResult result;
27
	
28
	protected Browser browser;
29
	
30
	public DocumentationTab(TabFolder folder, PropertiesPagedEditor editor) {
31
		super(folder, editor);
32
		
33
		this.result = editor.getResult().getParent();
34
		tab.setText("Documentation");
35
		
36
		buildContent(parent);
37
	}
38
	
39
	protected void buildContent(GLComposite parent) {
40
		this.browser = new Browser(parent, SWT.NONE);
41
		this.browser.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, true));
42
	}
43
	
44
	@Override
45
	public void updateResultFromEditor(boolean update) throws Exception {
46
		
47
	}
48
	
49
	@Override
50
	public void updateEditorFromResult() {
51
		TXMResult r = this.editor.getResult().getParent();
52
		Project p = r.getFirstParent(Project.class);
53
		File file = new File(p.getProjectDirectory(), "doc/index.html");
54
		if (file != null && file.exists()) {
55
			try {
56
				this.browser.setUrl(file.toURI().toURL().toString());
57
			}
58
			catch (MalformedURLException e) {
59
				// TODO Auto-generated catch block
60
				e.printStackTrace();
61
			}
62
		}
63
		else {
64
			Log.severe("Information HTML file doesn't exist."); //$NON-NLS-1$
65
		}
66
	}
67
	
68
	public TabItem getTab() {
69
		return tab;
70
	}
71
}
0 72

  
tmp/org.txm.properties.rcp/src/org/txm/properties/rcp/editors/PropertiesPagedEditor.java (revision 2974)
1 1
package org.txm.properties.rcp.editors;
2 2

  
3
import java.io.File;
3 4
import java.util.ArrayList;
4 5

  
5 6
import org.eclipse.swt.SWT;
......
17 18
import org.txm.searchengine.cqp.corpus.CQPCorpus;
18 19
import org.txm.core.results.Parameter;
19 20
import org.txm.core.results.TXMResult;
21
import org.txm.objects.Project;
20 22

  
21 23
public class PropertiesPagedEditor extends TXMEditor<Properties> {
22

  
24
	
23 25
	private TabFolder tabFolder;
24
	protected ArrayList<PropertiesTab> tabs = new ArrayList<PropertiesTab>();
25

  
26
	
27
	protected ArrayList<PropertiesTab> tabs = new ArrayList<>();
28
	
26 29
	/**
27 30
	 * The maximum number of word property values to display.
28 31
	 */
......
41 44
		
42 45
		
43 46
		GLComposite parent = getResultArea();
44
		tabFolder = new TabFolder (parent, SWT.BORDER);
47
		tabFolder = new TabFolder(parent, SWT.BORDER);
45 48
		tabFolder.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, true));
46 49
		
47 50
		tabs.add(new PropertiesGeneralTab(tabFolder, this));
48 51
		PropertiesTXMResultTab resultTab = new PropertiesTXMResultTab(tabFolder, this);
49 52
		tabs.add(resultTab);
53
		
54
		Project p = this.getResult().getFirstParent(Project.class);
55
		File file = new File(p.getProjectDirectory(), "doc/index.html");
56
		if (file.exists()) {
57
			DocumentationTab docTab = new DocumentationTab(tabFolder, this);
58
			tabs.add(docTab);
59
		}
50 60
		tabs.add(new PropertiesParametersTab(tabFolder, this));
51 61
		
52 62
		tabFolder.setSelection(resultTab.getTab());
53 63
	}
54

  
64
	
55 65
	@Override
56 66
	public void updateResultFromEditor() {
57 67
		for (PropertiesTab tab : tabs) {
58 68
			tab.updateEditorFromResult();
59 69
		}
60 70
	}
61

  
71
	
62 72
	@Override
63 73
	public void updateEditorFromResult(boolean update) throws Exception {
64 74
		for (PropertiesTab tab : tabs) {
65 75
			tab.updateEditorFromResult();
66 76
		}
67 77
	}
68

  
69

  
78
	
79
	
70 80
}

Formats disponibles : Unified diff