Révision 528
tmp/org.txm.core/src/java/org/txm/core/preferences/TXMPreferences.java (revision 528) | ||
---|---|---|
893 | 893 |
try { |
894 | 894 |
System.err.println("TXMPreferences.flush(): Local preferences for object " + result.getUUID() + " saved to file."); |
895 | 895 |
// FIXME: useless? |
896 |
//scope.getNode(getId(result)).sync();
|
|
896 |
//scope.getNode(result.getUUID()).sync();
|
|
897 | 897 |
scope.getNode(result.getUUID()).flush(); |
898 | 898 |
} |
899 | 899 |
catch(BackingStoreException e) { |
... | ... | |
1046 | 1046 |
} |
1047 | 1047 |
|
1048 | 1048 |
/** |
1049 |
* Stores the specified parameters pairs of key / value in a local node dedicated to the specified result. The node qualifier is generated by the <code>Object.toString()</code> method.
|
|
1049 |
* Stores the specified parameters pairs of key/value in a local node dedicated to the specified result. The node qualifier is generated by the <code>TXMResult.getUUID</code> method.
|
|
1050 | 1050 |
* @param result |
1051 | 1051 |
* @param key |
1052 | 1052 |
* @param value |
... | ... | |
1071 | 1071 |
else if (Boolean.class.isInstance(value)) { |
1072 | 1072 |
putLocalBoolean(result, key, (Boolean) value); |
1073 | 1073 |
} |
1074 |
// FIXME: to do |
|
1074 | 1075 |
// else if (Serializable.class.isInstance(value)) { |
1075 | 1076 |
// putLocalSerializable(result, key, (Serializable) value); |
1076 |
// } else {
|
|
1077 |
// //FIXME: Debug
|
|
1078 |
// System.err.println("TXMPreferences.putLocal(): error, can't find a put method that matches the value type: " + value.getClass() + "="+value+".");
|
|
1079 |
// }
|
|
1077 |
else { |
|
1078 |
//FIXME: Debug |
|
1079 |
System.err.println("TXMPreferences.putLocal(): error, can't find a put method that matches the value type: " + value.getClass() + "=" + value + ".");
|
|
1080 |
} |
|
1080 | 1081 |
} |
1081 | 1082 |
|
1082 | 1083 |
private static void putLocalSerializable(TXMResult result, String key, Serializable value) { |
... | ... | |
1084 | 1085 |
scope.getNode(result.getUUID()).putByteArray(key, b); |
1085 | 1086 |
} |
1086 | 1087 |
|
1088 |
/** |
|
1089 |
* Clones nodes. Creates a local node for the destination result and copy it all the source result parameters. |
|
1090 |
* @param srcResult |
|
1091 |
* @param dstResult |
|
1092 |
*/ |
|
1093 |
public static void cloneNode(TXMResult srcResult, TXMResult dstResult) { |
|
1094 |
IEclipsePreferences preferences = scope.getNode(srcResult.getUUID()); |
|
1095 |
if(preferences != null) { |
|
1096 |
try { |
|
1097 |
String[] keys = preferences.keys(); |
|
1098 |
for(int i = 0; i < keys.length; i++) { |
|
1099 |
putLocal(dstResult, keys[i], preferences.get(keys[i], "")); |
|
1100 |
} |
|
1101 |
} |
|
1102 |
catch(BackingStoreException e) { |
|
1103 |
// TODO Auto-generated catch block |
|
1104 |
e.printStackTrace(); |
|
1105 |
} |
|
1106 |
} |
|
1107 |
} |
|
1108 |
|
|
1087 | 1109 |
//FIXME: this code is dedicated to dynamically retrieve the static field PREFERENCES_NODE of the runtime subclass and use it super class to avoid to pass it to all methods. |
1088 | 1110 |
// eg. to use ProgressionPreferences.getBoolean("test") instead of TXMPreferences.getBoolean(ProgressionPreferences.PREFERENCES_NODE, "test") |
1089 | 1111 |
// but it doesn"t work, need to continue the tests... |
tmp/org.txm.core/src/java/org/txm/core/preferences/___CorpusScope.java (revision 528) | ||
---|---|---|
1 |
/** |
|
2 |
* |
|
3 |
*/ |
|
4 |
package org.txm.core.preferences; |
|
5 |
|
|
6 |
import java.io.File; |
|
7 |
import java.util.HashMap; |
|
8 |
|
|
9 |
import org.eclipse.core.internal.preferences.AbstractScope; |
|
10 |
import org.eclipse.core.resources.ResourcesPlugin; |
|
11 |
import org.eclipse.core.runtime.IPath; |
|
12 |
import org.eclipse.core.runtime.Path; |
|
13 |
import org.eclipse.core.runtime.preferences.ConfigurationScope; |
|
14 |
import org.osgi.service.prefs.BackingStoreException; |
|
15 |
import org.osgi.service.prefs.Preferences; |
|
16 |
|
|
17 |
/** |
|
18 |
* Tests to save the results and corpus parameters in the binary corpus path. |
|
19 |
* Temporary, in future we'll need to use ProjectScope + IProject + Eclipse Workspace. |
|
20 |
* @author sjacquot |
|
21 |
* |
|
22 |
*/ |
|
23 |
//FIXME: Temporary, in future we'll need to use ProjectScope + IProject + Eclipse Workspace. |
|
24 |
public class ___CorpusScope extends AbstractScope { |
|
25 |
|
|
26 |
/** |
|
27 |
* Project scopes. |
|
28 |
*/ |
|
29 |
public static HashMap<String, ___CorpusScope> projectScopes = new HashMap<String, ___CorpusScope>(); |
|
30 |
|
|
31 |
/** |
|
32 |
* Scope name. |
|
33 |
*/ |
|
34 |
protected String name; |
|
35 |
|
|
36 |
/** |
|
37 |
* Location. |
|
38 |
*/ |
|
39 |
protected IPath location; |
|
40 |
|
|
41 |
/** |
|
42 |
* |
|
43 |
* @param name |
|
44 |
* @param location |
|
45 |
*/ |
|
46 |
public ___CorpusScope(String name, File location) { |
|
47 |
super(); |
|
48 |
this.name = name; |
|
49 |
this.location = new Path(location.getAbsolutePath() + "/"); |
|
50 |
} |
|
51 |
|
|
52 |
/* (non-Javadoc) |
|
53 |
* @see org.eclipse.core.internal.preferences.AbstractScope#getName() |
|
54 |
*/ |
|
55 |
@Override |
|
56 |
public String getName() { |
|
57 |
return this.name; |
|
58 |
} |
|
59 |
|
|
60 |
/* (non-Javadoc) |
|
61 |
* @see org.eclipse.core.internal.preferences.AbstractScope#getLocation() |
|
62 |
*/ |
|
63 |
@Override |
|
64 |
public IPath getLocation() { |
|
65 |
return this.location; |
|
66 |
} |
|
67 |
|
|
68 |
|
|
69 |
/** |
|
70 |
* |
|
71 |
* @param scope |
|
72 |
*/ |
|
73 |
@SuppressWarnings("restriction") |
|
74 |
public static void addScope(___CorpusScope scope) { |
|
75 |
|
|
76 |
projectScopes.put(scope.getName(), scope); |
|
77 |
|
|
78 |
Preferences prefs = scope.getNode("import"); |
|
79 |
prefs.put("test", "value"); |
|
80 |
System.err.println("CorpusScope.addScope(): " + prefs.absolutePath()); |
|
81 |
System.err.println("CorpusScope.addScope(): test = " + prefs.get("test", "default value")); |
|
82 |
try { |
|
83 |
//prefs.sync(); |
|
84 |
prefs.flush(); |
|
85 |
} |
|
86 |
catch(BackingStoreException e) { |
|
87 |
// TODO Auto-generated catch block |
|
88 |
e.printStackTrace(); |
|
89 |
} |
|
90 |
|
|
91 |
System.err.println("CorpusScope.addScope(): default scope location: " + ConfigurationScope.INSTANCE.getLocation()); |
|
92 |
System.err.println("CorpusScope.addScope(): workspace location: " + ResourcesPlugin.getWorkspace().getRoot().getLocation().toString()); |
|
93 |
System.out.println("CorpusScope.addScope(): add scope " + scope.getName() + " - " + scope.getLocation()); |
|
94 |
} |
|
95 |
|
|
96 |
/** |
|
97 |
* |
|
98 |
* @param scope |
|
99 |
*/ |
|
100 |
public static void removeScope(String name) { |
|
101 |
projectScopes.remove(name); |
|
102 |
} |
|
103 |
|
|
104 |
/** |
|
105 |
* |
|
106 |
* @param name |
|
107 |
* @return |
|
108 |
*/ |
|
109 |
public static ___CorpusScope getScope(String name) { |
|
110 |
return projectScopes.get(name); |
|
111 |
} |
|
112 |
|
|
113 |
} |
|
0 | 114 |
tmp/org.txm.core/src/java/org/txm/core/results/TXMResult.java (revision 528) | ||
---|---|---|
20 | 20 |
|
21 | 21 |
/** |
22 | 22 |
* Root class of all TXM results. |
23 |
* This class contains methods to get some different version of the name of the result and some additional computing information. |
|
23 |
* This class contains methods to get some different versions of the name of the result and some additional computing information.
|
|
24 | 24 |
* It also contains methods to manage a tree hierarchy of result nodes. |
25 | 25 |
* |
26 | 26 |
* @author mdecorde |
... | ... | |
47 | 47 |
*/ |
48 | 48 |
protected boolean dirty = true; |
49 | 49 |
|
50 |
public boolean isDirty() { return dirty;} |
|
51 |
|
|
52 | 50 |
/** |
53 |
* Mark the result has dirty so editors or others will know to recompute the TXMResult |
|
54 |
*/ |
|
55 |
public void setDirty() { |
|
56 |
dirty = true; |
|
57 |
} |
|
58 |
|
|
59 |
/** |
|
60 | 51 |
* The result Parent. should not be null except for roots TXMResult |
61 | 52 |
*/ |
62 | 53 |
protected TXMResult parent; |
... | ... | |
78 | 69 |
*/ |
79 | 70 |
protected String preferencesNodeQualifier; |
80 | 71 |
|
72 |
|
|
81 | 73 |
/** |
74 |
* If set, allows the command to notify its progress. |
|
75 |
*/ |
|
76 |
protected IProgressMonitor monitor; |
|
77 |
/** |
|
78 |
* |
|
79 |
*/ |
|
80 |
private Semaphore progressSemaphore = new Semaphore(1); |
|
81 |
|
|
82 |
/** |
|
83 |
* This variable ensure the TXMResult class constructor has been called |
|
84 |
*/ |
|
85 |
private boolean constructorCalled; |
|
86 |
|
|
87 |
|
|
88 |
/** |
|
82 | 89 |
* Creates a new TXMResult, child of the specified parent. |
83 | 90 |
* @param parent |
84 | 91 |
*/ |
... | ... | |
86 | 93 |
this(parent, null); |
87 | 94 |
} |
88 | 95 |
|
89 |
public boolean hasResults() { |
|
90 |
return children.size() > 0; |
|
91 |
} |
|
92 | 96 |
|
93 | 97 |
/** |
94 |
* |
|
98 |
* Creates a new TXMResult, child of the specified parent.
|
|
95 | 99 |
* @param parent |
96 |
* @return true this object is connected to the parent |
|
97 |
*/ |
|
98 |
public boolean isUsingParent(TXMResult parent) { |
|
99 |
if (this == parent) return true; |
|
100 |
else if (this.parent == null) return false; |
|
101 |
else return this.parent.isUsingParent(parent); |
|
102 |
} |
|
103 |
|
|
104 |
/** |
|
105 |
* |
|
106 |
* @param parent |
|
107 | 100 |
* @param parameters |
108 | 101 |
*/ |
109 | 102 |
public TXMResult(TXMResult parent, TXMParameters parameters) { |
110 | 103 |
|
111 | 104 |
// FIXME: discuss about this method and validate it. Also discuss about a getInternalName() method that should also return an unique ID. |
112 | 105 |
this.parent = parent; |
113 |
this.uniqueID = this.getClass().getName() + '@' + ID_TIME_FORMAT.format(new Date(System.currentTimeMillis())) + "_" + UUID.randomUUID();
|
|
106 |
this.createUUID();
|
|
114 | 107 |
|
115 | 108 |
this.weight = 0; |
116 | 109 |
this.visible = true; |
... | ... | |
126 | 119 |
//System.out.println("TXMResult.TXMResult(): default preferences node qualifier = " + this.preferencesNodeQualifier + ", class = " + getClass()); |
127 | 120 |
} |
128 | 121 |
|
122 |
|
|
129 | 123 |
/** |
124 |
* Creates and stores an UUID dedicated to persistence for this result. |
|
125 |
*/ |
|
126 |
protected void createUUID() { |
|
127 |
this.uniqueID = this.getClass().getName() + '@' + ID_TIME_FORMAT.format(new Date(System.currentTimeMillis())) + "_" + UUID.randomUUID(); |
|
128 |
} |
|
129 |
|
|
130 |
|
|
131 |
public boolean hasResults() { |
|
132 |
return children.size() > 0; |
|
133 |
} |
|
134 |
|
|
135 |
/** |
|
136 |
* Gets the dirty states. |
|
137 |
* @return |
|
138 |
*/ |
|
139 |
public boolean isDirty() { |
|
140 |
return dirty; |
|
141 |
} |
|
142 |
|
|
143 |
/** |
|
144 |
* Marks the result as dirty so editors or others will know the TXMResult needs to be recomputed. |
|
145 |
*/ |
|
146 |
public void setDirty() { |
|
147 |
dirty = true; |
|
148 |
} |
|
149 |
|
|
150 |
|
|
151 |
|
|
152 |
|
|
153 |
/** |
|
154 |
* |
|
155 |
* @param parent |
|
156 |
* @return true this object is connected to the parent |
|
157 |
*/ |
|
158 |
public boolean isUsingParent(TXMResult parent) { |
|
159 |
if (this == parent) return true; |
|
160 |
else if (this.parent == null) return false; |
|
161 |
else return this.parent.isUsingParent(parent); |
|
162 |
} |
|
163 |
|
|
164 |
/** |
|
130 | 165 |
* Gets the preferences node qualifier of the result command. |
131 | 166 |
* @return |
132 | 167 |
*/ |
133 | 168 |
public String getPreferencesNodeQualifier() { |
134 |
return preferencesNodeQualifier; |
|
169 |
return this.preferencesNodeQualifier;
|
|
135 | 170 |
} |
136 | 171 |
|
137 | 172 |
public String[] getParametersKeys() throws BackingStoreException { |
... | ... | |
571 | 606 |
TXMResult clone = null; |
572 | 607 |
try { |
573 | 608 |
clone = (TXMResult) super.clone(); |
609 |
clone.createUUID(); |
|
574 | 610 |
this.parent.addResult(clone); |
611 |
TXMPreferences.cloneNode(this, clone); |
|
575 | 612 |
} |
576 | 613 |
catch(Exception e) { |
577 | 614 |
} |
... | ... | |
608 | 645 |
* |
609 | 646 |
* @return true if parameters are all OK |
610 | 647 |
*/ |
611 |
public abstract boolean validateParameters() throws Exception;
|
|
648 |
public abstract boolean canCompute() throws Exception;
|
|
612 | 649 |
|
613 | 650 |
public String getSimpleDetails() { |
614 | 651 |
String mess = this.getDetails(); |
... | ... | |
617 | 654 |
return this.toString(); |
618 | 655 |
} |
619 | 656 |
|
620 |
/** |
|
621 |
* if set, allows the command to notify its progress |
|
622 |
*/ |
|
623 |
protected IProgressMonitor monitor; |
|
624 |
|
|
625 |
Semaphore progressSemaphore = new Semaphore(1); |
|
626 |
/** |
|
627 |
* This variable ensure the TXMResult class constructor has been called |
|
628 |
*/ |
|
629 |
private boolean constructorCalled; |
|
630 |
|
|
631 | 657 |
public void acquireSemaphore() { |
632 | 658 |
try { |
633 | 659 |
this.progressSemaphore.acquire(); |
... | ... | |
638 | 664 |
|
639 | 665 |
/** |
640 | 666 |
* Computes the result according to specified command parameters. |
667 |
* @param update TODO |
|
668 |
* @param parameters |
|
641 | 669 |
* |
642 |
* @param parameters |
|
643 | 670 |
* @return |
644 | 671 |
*/ |
645 |
public boolean compute() throws Exception { |
|
646 |
return this.compute(null); |
|
672 |
public boolean compute(boolean update) throws Exception {
|
|
673 |
return this.compute(false, null);
|
|
647 | 674 |
} |
648 | 675 |
|
649 | 676 |
/** |
650 |
* Computes the result according to stored command parameters. |
|
677 |
* Computes the result. |
|
678 |
* @param update TODO |
|
679 |
* @param watcher |
|
651 | 680 |
* |
652 |
* @param watcher |
|
653 | 681 |
* @return |
654 | 682 |
* @throws Exception |
655 | 683 |
* @throws InvalidCqpIdException |
... | ... | |
657 | 685 |
* @throws CqiClientException |
658 | 686 |
* @throws IOException |
659 | 687 |
*/ |
660 |
public boolean compute(IProgressMonitor monitor) throws Exception { |
|
661 |
return hasBeenConstructorCalled() && setCurrentMonitor(monitor) && validateParameters() && _compute() && saveParameters(); |
|
688 |
public boolean compute(boolean update, IProgressMonitor monitor) throws Exception { |
|
689 |
|
|
690 |
this.monitor = monitor; |
|
691 |
|
|
692 |
// FIXME: Debug |
|
693 |
System.err.println("TXMResult.compute(): computing result of type " + this.getClass() + "..."); |
|
694 |
|
|
695 |
|
|
696 |
if(!hasBeenConstructorCalled()) { |
|
697 |
return false; |
|
698 |
} |
|
699 |
|
|
700 |
if(!canCompute()) { |
|
701 |
return false; |
|
702 |
} |
|
703 |
|
|
704 |
if(!_compute(update)) { |
|
705 |
return false; |
|
706 |
} |
|
707 |
|
|
708 |
if(!saveParameters()) { |
|
709 |
return false; |
|
710 |
} |
|
711 |
|
|
712 |
this.dirty = false; |
|
713 |
|
|
714 |
|
|
715 |
// FIXME: Debug |
|
716 |
System.err.println("TXMResult.compute(): computing done."); |
|
717 |
|
|
718 |
|
|
719 |
return true; |
|
662 | 720 |
} |
663 | 721 |
|
664 |
private boolean hasBeenConstructorCalled() { |
|
665 |
// TODO Auto-generated method stub |
|
666 |
return constructorCalled; |
|
667 |
} |
|
722 |
|
|
668 | 723 |
|
669 |
public abstract boolean _compute() throws Exception; |
|
724 |
/** |
|
725 |
* |
|
726 |
* @param update TODO |
|
727 |
* @return |
|
728 |
* @throws Exception |
|
729 |
*/ |
|
730 |
protected abstract boolean _compute(boolean update) throws Exception; |
|
670 | 731 |
|
671 | 732 |
// //removed for now, waiting to see if used |
672 | 733 |
// /** |
... | ... | |
675 | 736 |
// * @param parameters |
676 | 737 |
// * @return |
677 | 738 |
// */ |
678 |
// public boolean compute(IProgressMonitor watcher, TXMParameters parameters) throws Exception {
|
|
739 |
// public boolean compute(IProgressMonitor monitor, TXMParameters parameters) throws Exception {
|
|
679 | 740 |
// this.parameters = parameters; |
680 |
// return this.compute(watcher);
|
|
741 |
// return this.compute(monitor);
|
|
681 | 742 |
// } |
682 | 743 |
|
683 | 744 |
/** |
684 | 745 |
* |
746 |
* @return |
|
747 |
*/ |
|
748 |
private boolean hasBeenConstructorCalled() { |
|
749 |
// TODO Auto-generated method stub |
|
750 |
return constructorCalled; |
|
751 |
} |
|
752 |
|
|
753 |
// /** |
|
754 |
// * Copy the parameters from the local preference node if exists. Also fills the non existent parameters with the command default preferences. |
|
755 |
// * @return |
|
756 |
// */ |
|
757 |
// public abstract boolean loadParameters(); |
|
758 |
|
|
759 |
/** |
|
760 |
* |
|
685 | 761 |
* @return the array of extensions to show in the FileDialog SWT widget |
686 | 762 |
*/ |
687 | 763 |
@Deprecated |
... | ... | |
701 | 777 |
return false; |
702 | 778 |
} |
703 | 779 |
|
704 |
/** |
|
705 |
* |
|
706 |
* @return the parent Object that contains this result |
|
707 |
*/ |
|
708 |
@Deprecated |
|
709 |
// FIXME: to remove when TXMResult2 will be fully implemented |
|
710 |
//public abstract HasResults getHasResultsParent(); |
|
711 |
|
|
712 | 780 |
public boolean tryAcquireSemaphore() { |
713 | 781 |
return this.progressSemaphore.tryAcquire(); |
714 | 782 |
} |
tmp/org.txm.core/src/java/org/txm/objects/Workspace.java (revision 528) | ||
---|---|---|
362 | 362 |
} |
363 | 363 |
|
364 | 364 |
@Override |
365 |
public boolean validateParameters() {
|
|
365 |
public boolean canCompute() {
|
|
366 | 366 |
// TODO Auto-generated method stub |
367 | 367 |
return false; |
368 | 368 |
} |
369 | 369 |
|
370 | 370 |
@Override |
371 |
public boolean _compute() throws Exception {
|
|
371 |
protected boolean _compute(boolean update) throws Exception {
|
|
372 | 372 |
// TODO Auto-generated method stub |
373 | 373 |
return false; |
374 | 374 |
} |
tmp/org.txm.core/src/java/org/txm/objects/TxmObject.java (revision 528) | ||
---|---|---|
266 | 266 |
} |
267 | 267 |
|
268 | 268 |
@Override |
269 |
public boolean validateParameters() {
|
|
269 |
public boolean canCompute() {
|
|
270 | 270 |
// TODO Auto-generated method stub |
271 | 271 |
return false; |
272 | 272 |
} |
273 | 273 |
|
274 | 274 |
@Override |
275 |
public boolean _compute() throws Exception {
|
|
275 |
protected boolean _compute(boolean update) throws Exception {
|
|
276 | 276 |
// TODO Auto-generated method stub |
277 | 277 |
return false; |
278 | 278 |
} |
tmp/org.txm.core/src/java/org/txm/functions/CommandsAPI.java (revision 528) | ||
---|---|---|
96 | 96 |
System.out.println("Computing "+command.cmd+"..."); |
97 | 97 |
result = command.clazz.newInstance(); |
98 | 98 |
result.setParameters(parameters); |
99 |
if (result.validateParameters())
|
|
100 |
result.compute(); |
|
99 |
if (result.canCompute())
|
|
100 |
result.compute(false);
|
|
101 | 101 |
//FIXME: debug |
102 | 102 |
System.out.println(result); |
103 | 103 |
} else { |
tmp/org.txm.core/build.properties (revision 528) | ||
---|---|---|
33 | 33 |
lib/sqlite-jdbc-3.8.11.2.jar,\ |
34 | 34 |
lib/postgresql-9.4.1207.jre6.jar,\ |
35 | 35 |
lib/jodconverter-core-3.1-beta.jar,\ |
36 |
log4j.properties,\ |
|
37 |
bin/org/txm/functions/mesures/ |
|
36 |
log4j.properties |
|
38 | 37 |
output.. = bin/ |
39 | 38 |
source.. = src/java/,\ |
40 | 39 |
res/ |
41 |
bin.excludes = META-INF/TSTMANIFEST.MF,\ |
|
42 |
bin/org/knallgrau/,\ |
|
43 |
bin/org/kohsuke/,\ |
|
44 |
bin/org/txm/functions/,\ |
|
45 |
bin/org/txm/images/,\ |
|
46 |
bin/org/txm/searchengine/,\ |
|
47 |
bin/org/txm/xml/,\ |
|
48 |
bin/org/txm/css/,\ |
|
49 |
bin/org/txm/annotation/,\ |
|
50 |
bin/org/txm/js/,\ |
|
51 |
bin/org/txm/metadatas/,\ |
|
52 |
bin/org/txm/objects/,\ |
|
53 |
bin/org/txm/package.html,\ |
|
54 |
bin/org/txm/sql/,\ |
|
55 |
bin/org/txm/stat/,\ |
|
56 |
bin/org/txm/tests/,\ |
|
57 |
bin/org/txm/ts/,\ |
|
58 |
bin/org/txm/utils/ |
|
40 |
bin.excludes = META-INF/TSTMANIFEST.MF |
tmp/org.txm.core/META-INF/MANIFEST.MF (revision 528) | ||
---|---|---|
9 | 9 |
org.eclipse.core.runtime;bundle-version="3.10.0";visibility:=reexport, |
10 | 10 |
org.eclipse.osgi.util;bundle-version="3.2.0";visibility:=reexport, |
11 | 11 |
org.eclipse.core.net;visibility:=reexport, |
12 |
org.eclipse.osgi;visibility:=reexport |
|
12 |
org.eclipse.osgi;visibility:=reexport, |
|
13 |
org.eclipse.core.resources |
|
13 | 14 |
Bundle-RequiredExecutionEnvironment: JavaSE-1.6 |
14 | 15 |
Export-Package: EDU.oswego.cs.dl.util.concurrent, |
15 | 16 |
EDU.oswego.cs.dl.util.concurrent.misc, |
tmp/org.txm.core/.classpath (revision 528) | ||
---|---|---|
22 | 22 |
<classpathentry exported="true" kind="lib" path="lib/juniversalchardet-1.0.3.jar"/> |
23 | 23 |
<classpathentry exported="true" kind="lib" path="lib/textcat-1.0.1.jar"/> |
24 | 24 |
<classpathentry exported="true" kind="lib" path="lib/json-20090211.jar"/> |
25 |
<classpathentry exported="true" kind="lib" path="lib/juh-3.2.1.jar" sourcepath="src/java"/> |
|
26 |
<classpathentry exported="true" kind="lib" path="lib/jurt-3.2.1.jar"/> |
|
27 | 25 |
<classpathentry exported="true" kind="lib" path="lib/ridl-3.2.1.jar"/> |
28 | 26 |
<classpathentry exported="true" kind="lib" path="lib/unoil-3.2.1.jar"/> |
29 | 27 |
<classpathentry exported="true" kind="lib" path="lib/jtidy-r938.jar"/> |
tmp/org.txm.index.rcp/src/org/txm/index/rcp/editors/IndexEditor.java (revision 528) | ||
---|---|---|
261 | 261 |
|
262 | 262 |
index.setParameters(query, properties, Fmin, Fmax, Tmax, nLines); |
263 | 263 |
|
264 |
if (index.validateParameters() && index.isDirty()) {
|
|
264 |
if (index.canCompute() && index.isDirty()) {
|
|
265 | 265 |
|
266 | 266 |
title = NLS.bind(IndexUIMessages.IndexEditor_2, new Object[]{ |
267 | 267 |
query.getQueryString(), properties, index.getCorpus().getName()}); |
... | ... | |
272 | 272 |
System.out.println(title); |
273 | 273 |
Log.info("Start computing Index..."); |
274 | 274 |
|
275 |
index.compute(this); |
|
275 |
index.compute(false, this);
|
|
276 | 276 |
} else { |
277 | 277 |
return Status.CANCEL_STATUS; |
278 | 278 |
} |
... | ... | |
380 | 380 |
paramArea.setLayout(new FormLayout()); |
381 | 381 |
|
382 | 382 |
// info&navigation panel |
383 |
final Composite infosArea = this.topToolBar.installGroup("Infos", "Informations and Navigation", null); |
|
383 |
final Composite infosArea = this.topToolBar.installGroup("Infos", "Informations and Navigation", null, true);
|
|
384 | 384 |
|
385 | 385 |
Composite resultArea = this.getDisplayArea(); |
386 | 386 |
|
tmp/org.txm.chartsengine.rcp/src/org/txm/chartsengine/rcp/SWTChartsComponentsProvider.java (revision 528) | ||
---|---|---|
40 | 40 |
import org.txm.chartsengine.core.ChartCreator; |
41 | 41 |
import org.txm.chartsengine.core.ChartsEngine; |
42 | 42 |
import org.txm.chartsengine.core.preferences.ChartsEnginePreferences; |
43 |
import org.txm.chartsengine.core.results.ChartResult; |
|
43 | 44 |
import org.txm.chartsengine.rcp.editors.ChartEditorInput; |
44 | 45 |
import org.txm.chartsengine.rcp.editors.ChartEditorPart; |
45 | 46 |
import org.txm.chartsengine.rcp.events.EventCallBack; |
... | ... | |
51 | 52 |
import org.txm.chartsengine.rcp.swt.ChartEditorToolBar; |
52 | 53 |
import org.txm.core.results.TXMResult; |
53 | 54 |
import org.txm.rcp.editors.SplitedGenericMultiPageEditor; |
54 |
import org.txm.rcp.editors.TXMEditorPart; |
|
55 | 55 |
import org.txm.rcp.preferences.TXMPreferencePage; |
56 | 56 |
import org.txm.utils.logger.Log; |
57 | 57 |
|
... | ... | |
68 | 68 |
|
69 | 69 |
// FIXME: should be done in an activator? |
70 | 70 |
static { |
71 |
// Initializes the SWT Charts Components provider according to the current charts engine and its output format |
|
72 |
SWTChartsComponentsProvider.createSWTChartsComponentsProviders(); |
|
73 |
SWTChartsComponentsProvider.setCurrrentComponentsProvider(ChartsEngine.getCurrent()); |
|
71 |
// Initializes the SWT Charts Components provider according to the current charts engine and its output format
|
|
72 |
SWTChartsComponentsProvider.createSWTChartsComponentsProviders();
|
|
73 |
SWTChartsComponentsProvider.setCurrrentComponentsProvider(ChartsEngine.getCurrent());
|
|
74 | 74 |
} |
75 | 75 |
|
76 | 76 |
|
... | ... | |
105 | 105 |
*/ |
106 | 106 |
protected Properties keyboardBindingProperties; |
107 | 107 |
|
108 |
|
|
109 | 108 |
|
110 | 109 |
/** |
111 | 110 |
* Installed SWT charts components providers. |
... | ... | |
149 | 148 |
// } |
150 | 149 |
} |
151 | 150 |
|
152 |
|
|
151 |
/** |
|
152 |
* |
|
153 |
* @param chartsEngine |
|
154 |
*/ |
|
153 | 155 |
public SWTChartsComponentsProvider(ChartsEngine chartsEngine) { |
154 | 156 |
this(chartsEngine, new ___MouseBindingProperties(), new ___KeyboardBindingProperties()); |
155 | 157 |
} |
156 | 158 |
|
157 | 159 |
|
160 |
/** |
|
161 |
* |
|
162 |
*/ |
|
158 | 163 |
public SWTChartsComponentsProvider() { |
159 | 164 |
this(null); |
160 | 165 |
} |
161 | 166 |
|
162 | 167 |
|
163 |
|
|
164 | 168 |
/** |
165 |
* Creates and return a SWT EditorPart filled with a new chart for the specified result and chart type. |
|
166 |
* @param editorInputName |
|
169 |
* Creates a <code>ChartEditorInput</code> for the specified chart result. |
|
167 | 170 |
* @param result |
168 |
* @param preferencesNode |
|
169 |
* @param chartType |
|
170 |
* @return |
|
171 |
* @return a <code>ChartEditorInput</code> |
|
171 | 172 |
*/ |
172 |
public ChartEditorPart createChartEditor(TXMResult result, String chartType) { |
|
173 |
ChartEditorInput chartEditorInput = new ChartEditorInput(this, result, chartType, null); |
|
174 |
|
|
175 |
//FIXME: need to try to do the chart creation in openEditor() with computeChart() (tested without success... need to check again) |
|
176 |
// create the chart from the charts engine chart creator extension |
|
177 |
this.createChart(chartEditorInput, result, chartType); |
|
178 |
|
|
179 |
ChartEditorPart editor = new ChartEditorPart(this, chartEditorInput); |
|
180 |
return editor; |
|
173 |
public ChartEditorInput createChartEditorInput(ChartResult result) { |
|
174 |
return new ChartEditorInput(this, result); |
|
181 | 175 |
} |
182 |
|
|
183 | 176 |
|
184 | 177 |
/** |
185 |
* Creates and return a SWT EditorPart filled with a new chart for the specified result. |
|
186 |
* @param editorInputName |
|
187 |
* @param result |
|
188 |
* @param preferencesNode |
|
189 |
* @return |
|
190 |
*/ |
|
191 |
public ChartEditorPart createChartEditor(TXMResult result) { |
|
192 |
return this.createChartEditor(result, null); |
|
193 |
} |
|
194 |
|
|
195 |
// /** |
|
196 |
// * Creates and return a SWT EditorPart filled with a new chart for the specified result. |
|
197 |
// * @param result |
|
198 |
// * @param preferencesNode |
|
199 |
// * @param chartType |
|
200 |
// * @return |
|
201 |
// */ |
|
202 |
// public ChartEditorPart createChartEditor(TXMResult result, String preferencesNode, String chartType) { |
|
203 |
// return this.createChartEditor(this.getChartsEngine().getChartCreator(result.getClass(), chartType).getFileNamePrefix(), result, preferencesNode, chartType); |
|
204 |
// } |
|
205 |
|
|
206 |
/** |
|
207 |
* Creates a new chart for the specified result data and saves it in the specified editor input. |
|
208 |
* A chart editor created with the editor input will be filled with chart. |
|
178 |
* Creates a new chart container for the specified <code>ChartResult</code> save it in the specified <code>ChartEditorInput</code>. |
|
209 | 179 |
* |
210 |
* @param chartEditorInput |
|
211 |
* @param result |
|
212 |
* @param preferencesNode |
|
213 |
*/ |
|
214 |
public void createChart(ChartEditorInput chartEditorInput, TXMResult result) { |
|
215 |
this.createChart(chartEditorInput, result, chartEditorInput.getChartType()); |
|
216 |
} |
|
217 |
|
|
218 |
/** |
|
219 |
* Creates a new chart for the specified result data and chart type and save it in the specified editor input. |
|
220 |
* |
|
221 | 180 |
* @param chartsEngine |
222 | 181 |
* @param chartEditorInput |
223 | 182 |
* @param result |
... | ... | |
225 | 184 |
* @param chartType |
226 | 185 |
* @return |
227 | 186 |
*/ |
228 |
protected abstract boolean createChart(ChartsEngine chartsEngine, ChartEditorInput chartEditorInput, TXMResult result, String chartType);
|
|
187 |
protected abstract boolean createChartContainer(ChartsEngine chartsEngine, ChartEditorInput chartEditorInput);
|
|
229 | 188 |
|
230 | 189 |
/** |
231 |
* Creates a new chart for the specified result data and chart type and save it in the specified editor input.
|
|
190 |
* Creates a new chart container for the specified <code>ChartResult</code> save it in the specified <code>ChartEditorInput</code>.
|
|
232 | 191 |
* |
233 | 192 |
* @param chartEditorInput |
234 | 193 |
* @param result |
... | ... | |
236 | 195 |
* @param chartType |
237 | 196 |
* @return |
238 | 197 |
*/ |
239 |
protected boolean createChart(ChartEditorInput chartEditorInput, TXMResult result, String chartType) {
|
|
240 |
return this.createChart(this.getChartsEngine(), chartEditorInput, result, chartType);
|
|
198 |
public boolean createChartContainer(ChartEditorInput chartEditorInput) {
|
|
199 |
return this.createChartContainer(this.getChartsEngine(), chartEditorInput);
|
|
241 | 200 |
} |
242 | 201 |
|
243 | 202 |
|
... | ... | |
249 | 208 |
* @param chartType |
250 | 209 |
* @return <code>True</code>, if a chart creator has been found and the chart has been updated, otherwise <code>false</code> |
251 | 210 |
*/ |
252 |
public boolean updateChart(ChartEditorPart editor, String chartType) { |
|
253 |
ChartCreator chartCreator = this.chartsEngine.getChartCreator(editor.getResultData().getClass(), chartType); |
|
254 |
if(chartCreator != null) { |
|
255 |
chartCreator.updateChart(editor.getChart(), editor.getResultData()); |
|
256 |
return true; |
|
211 |
public boolean updateChart(ChartEditorPart editor) { |
|
212 |
try { |
|
213 |
return editor.getResultData().compute(true); |
|
257 | 214 |
} |
215 |
catch(Exception e) { |
|
216 |
// TODO Auto-generated catch block |
|
217 |
e.printStackTrace(); |
|
218 |
} |
|
258 | 219 |
return false; |
259 | 220 |
} |
260 |
|
|
261 |
|
|
262 |
/** |
|
263 |
* Updates the specified chart stored in the editor and according to the stored TXM result. |
|
264 |
* @param editor |
|
265 |
* @param command |
|
266 |
* @param params |
|
267 |
* @return <code>True</code>, if a chart creator has been found and the chart has been updated, otherwise <code>false</code> |
|
268 |
*/ |
|
269 |
public boolean updateChart(ChartEditorPart editor) { |
|
270 |
return this.updateChart(editor, editor.getChartType()); |
|
271 |
} |
|
272 |
|
|
273 | 221 |
|
274 | 222 |
|
275 | 223 |
/** |
... | ... | |
631 | 579 |
return this.openEditor(chartEditorInput, chartEditorInput.getResult().getClass().getName()); |
632 | 580 |
} |
633 | 581 |
|
634 |
/** |
|
635 |
* Opens the specified <code>ChartEditorPart</code> in the active page and registers the event listeners and context menus according to the type of the chart editor part. |
|
636 |
* The chart type is the editor input result data class name. |
|
637 |
* @param chartEditorInput |
|
638 |
* @param editorPartId |
|
639 |
* @return |
|
640 |
*/ |
|
641 |
public ChartEditorPart openEditor(ChartEditorInput chartEditorInput, String editorPartId) { |
|
642 |
return this.openEditor(chartEditorInput, editorPartId, null); |
|
643 |
} |
|
644 | 582 |
|
645 |
|
|
646 | 583 |
/** |
647 | 584 |
* Opens the <code>ChartEditorPart</code> specified by its id and ChartEditorInput in the active page and registers the event listeners and context menus according to the <code>EventCallBack</code> installed extensions. |
648 | 585 |
* @param chartEditorInput |
... | ... | |
651 | 588 |
* @return |
652 | 589 |
*/ |
653 | 590 |
// FIXME: this method have some trouble when calling through a progress dialog |
654 |
public ChartEditorPart openEditor(ChartEditorInput chartEditorInput, String editorPartId, String chartType) {
|
|
591 |
public ChartEditorPart openEditor(ChartEditorInput chartEditorInput, String editorPartId) { |
|
655 | 592 |
|
656 | 593 |
ChartEditorPart openedChartEditorPart = null; |
657 | 594 |
|
... | ... | |
666 | 603 |
Log.info("SWTChartsComponentsProvider.openEditor(): opening editor with id " + editorPartId); |
667 | 604 |
|
668 | 605 |
// if the editor is already open or the charts engine can create the specified chart type |
669 |
if(isAlreadyOpened || this.chartsEngine.canCreateChart(chartEditorInput.getResult().getClass(), chartType)) {
|
|
606 |
if(isAlreadyOpened || this.chartsEngine.canCreateChart(chartEditorInput.getResult().getClass(), chartEditorInput.getChartType())) {
|
|
670 | 607 |
|
671 | 608 |
//Log.info(this.name + " - Opening editor for result data type " + chartEditorInput.getResultData().getClass() + " and editor id " + editorPartId); |
672 | 609 |
|
... | ... | |
714 | 651 |
for(int i = 0; i < ChartsEngine.getChartsEngines().size() && !canCreate; i++) { |
715 | 652 |
if(ChartsEngine.getChartsEngines().get(i) != this.chartsEngine) { |
716 | 653 |
ChartsEngine chartsEngine = ChartsEngine.getChartsEngines().get(i); |
717 |
canCreate = chartsEngine.canCreateChart(chartEditorInput.getResult().getClass(), chartType);
|
|
654 |
canCreate = chartsEngine.canCreateChart(chartEditorInput.getResult().getClass(), chartEditorInput.getChartType());
|
|
718 | 655 |
// get a provider that can manage the charts engine |
719 | 656 |
if(canCreate) { |
720 | 657 |
SWTChartsComponentsProvider provider = SWTChartsComponentsProvider.getComponentsProvider(chartsEngine); |
... | ... | |
722 | 659 |
provider.setChartsEngine(chartsEngine); |
723 | 660 |
chartEditorInput.setSWTChartsComponentsProvider(provider); |
724 | 661 |
Log.warning(provider.toString()); |
725 |
return provider.openEditor(chartEditorInput, editorPartId, chartType);
|
|
662 |
return provider.openEditor(chartEditorInput, editorPartId); |
|
726 | 663 |
} |
727 | 664 |
} |
728 | 665 |
} |
... | ... | |
742 | 679 |
* @param params |
743 | 680 |
* @return |
744 | 681 |
*/ |
745 |
public ChartEditorPart openEditor(TXMResult result, String chartType) {
|
|
746 |
return this.openEditor(this.createChartEditor(result, chartType), chartType);
|
|
682 |
public ChartEditorPart openEditor(ChartResult result) {
|
|
683 |
return this.openEditor(this.createChartEditorInput(result), result.getClass().getName());
|
|
747 | 684 |
} |
748 | 685 |
|
749 |
/** |
|
750 |
* |
|
751 |
* @param editorInputName |
|
752 |
* @param result |
|
753 |
* @param params |
|
754 |
* @return |
|
755 |
*/ |
|
756 |
public ChartEditorPart openEditor(TXMResult result) { |
|
757 |
return this.openEditor(result, null); |
|
758 |
} |
|
759 | 686 |
|
760 |
|
|
761 | 687 |
/** |
762 |
* Opens the specified <code>ChartEditorPart</code> in the active page and registers the event listeners and context menus according to the type of the chart editor part. |
|
763 |
* The ID of the editor is the editor input result data class name. |
|
764 |
* @param editorPart |
|
765 |
* @return |
|
766 |
*/ |
|
767 |
public ChartEditorPart openEditor(ChartEditorPart editorPart) { |
|
768 |
return this.openEditor(editorPart, null); |
|
769 |
} |
|
770 |
|
|
771 |
/** |
|
772 |
* Opens the specified <code>ChartEditorPart</code> in the active page and registers the event listeners and context menus according to the type of the chart editor part. |
|
773 |
* The ID of the editor is the editor input result data class name. |
|
774 |
* @param chartEditorInput |
|
775 |
* @return |
|
776 |
*/ |
|
777 |
public ChartEditorPart openEditor(ChartEditorPart editorPart, String chartType) { |
|
778 |
return this.openEditor(editorPart, editorPart.getEditorInput().getResult().getClass().getName(), chartType); |
|
779 |
} |
|
780 |
|
|
781 |
|
|
782 |
/** |
|
783 |
* Opens the specified <code>ChartEditorPart</code> in the active page and registers the event listeners and context menus according to the type of the chart editor part. |
|
784 |
* @param editorPart |
|
785 |
* @param editorId |
|
786 |
* @return |
|
787 |
*/ |
|
788 |
public ChartEditorPart openEditor(ChartEditorPart editorPart, String editorId, String chartType) { |
|
789 |
return this.openEditor(editorPart.getEditorInput(), editorId, chartType); |
|
790 |
} |
|
791 |
|
|
792 |
|
|
793 |
|
|
794 |
/** |
|
795 | 688 |
* Initializes the default context menus. |
796 | 689 |
* @param composite |
797 | 690 |
*/ |
tmp/org.txm.chartsengine.rcp/src/org/txm/chartsengine/rcp/editors/ChartEditorInput.java (revision 528) | ||
---|---|---|
4 | 4 |
import org.eclipse.ui.IPersistableElement; |
5 | 5 |
import org.txm.chartsengine.core.ChartsEngine; |
6 | 6 |
import org.txm.chartsengine.core.preferences.ChartsEnginePreferences; |
7 |
import org.txm.chartsengine.core.results.ChartResult; |
|
7 | 8 |
import org.txm.chartsengine.rcp.SWTChartsComponentsProvider; |
8 | 9 |
import org.txm.core.preferences.TXMPreferences; |
9 | 10 |
import org.txm.core.results.TXMResult; |
... | ... | |
20 | 21 |
@Deprecated |
21 | 22 |
protected String name; |
22 | 23 |
|
23 |
/** |
|
24 |
* Chart type. |
|
25 |
*/ |
|
26 |
protected String chartType; |
|
27 | 24 |
|
28 | 25 |
/** |
29 | 26 |
* SWT chart components provider used to create the chart editor. |
... | ... | |
38 | 35 |
protected Object chartContainer; |
39 | 36 |
|
40 | 37 |
|
38 |
//protected Object chart; |
|
39 |
|
|
41 | 40 |
/** |
42 | 41 |
* Creates a chart editor input linked to the current SWT charts components provider. |
43 | 42 |
* @param result |
... | ... | |
60 | 59 |
/** |
61 | 60 |
* Creates a chart editor input linked to the specified SWT charts components provider. |
62 | 61 |
* @param swtComponentsProvider |
63 |
* @param result |
|
64 |
* @param preferencesNodeQualifier |
|
65 |
* @param chartType |
|
66 |
*/ |
|
67 |
public ChartEditorInput(SWTChartsComponentsProvider swtComponentsProvider, TXMResult result, String chartType) { |
|
68 |
this(swtComponentsProvider, result, chartType, null); |
|
69 |
} |
|
70 |
|
|
71 |
/** |
|
72 |
* Creates a chart editor input linked to the specified SWT charts components provider. |
|
73 |
* @param swtComponentsProvider |
|
74 | 62 |
* @param name |
75 | 63 |
* @param result |
76 | 64 |
* @param preferencesNodeQualifier |
77 | 65 |
* @param chartType |
78 | 66 |
* @param chartContainer |
79 | 67 |
*/ |
80 |
public ChartEditorInput(SWTChartsComponentsProvider swtComponentsProvider, TXMResult result, String chartType, Object chartContainer) {
|
|
68 |
public ChartEditorInput(SWTChartsComponentsProvider swtComponentsProvider, TXMResult result, Object chartContainer) { |
|
81 | 69 |
super(result); |
82 | 70 |
this.swtChartsComponentsProvider = swtComponentsProvider; |
83 |
this.chartType = chartType; |
|
84 | 71 |
this.chartContainer = chartContainer; |
85 | 72 |
} |
86 | 73 |
|
... | ... | |
177 | 164 |
this.chartContainer = chartContainer; |
178 | 165 |
} |
179 | 166 |
|
167 |
// public void setChart(Object chart) { |
|
168 |
// this.chart = chart; |
|
169 |
// } |
|
180 | 170 |
|
171 |
|
|
172 |
|
|
181 | 173 |
/** |
182 | 174 |
* Set the <code>SWTChartsComponentsProvider</code> to link to this editor input and to use for reading the chart object. |
183 | 175 |
* @param swtChartsComponentsProvider the swtChartsComponentsProvider to set |
... | ... | |
193 | 185 |
* @return the chartType or <code>null</code> if there only one chart type needed for the linked <code>TXMResult</code>. |
194 | 186 |
*/ |
195 | 187 |
public String getChartType() { |
196 |
return chartType;
|
|
188 |
return this.getResult().getChartType();
|
|
197 | 189 |
} |
198 | 190 |
|
191 |
@Override |
|
192 |
public ChartResult getResult() { |
|
193 |
return (ChartResult) this.result; |
|
194 |
} |
|
199 | 195 |
|
200 |
|
|
201 | 196 |
/** |
202 | 197 |
* Sets and updates the local preferences node qualifier from the result data. |
203 | 198 |
* Synchronizes the local preferences node with the result data type, chart type, etc. |
... | ... | |
207 | 202 |
//FIXME: to call when implemented in parent class |
208 | 203 |
//super.syncLocalPreferencesNode(); |
209 | 204 |
// FIXME: persistence test |
210 |
if(this.chartType != null) {
|
|
211 |
TXMPreferences.putLocalString(this.result, ChartsEnginePreferences.CHART_TYPE, this.chartType);
|
|
205 |
if(this.getResult().getChartType() != null) {
|
|
206 |
TXMPreferences.putLocal(this.result, ChartsEnginePreferences.CHART_TYPE, this.getResult().getChartType());
|
|
212 | 207 |
} |
213 | 208 |
|
214 |
TXMPreferences.putLocalString(this.result, ChartsEnginePreferences.RESULT_DATA_TYPE, this.result.getClass().getName());
|
|
209 |
TXMPreferences.putLocal(this.result, ChartsEnginePreferences.RESULT_DATA_TYPE, this.result.getClass().getName()); |
|
215 | 210 |
} |
216 | 211 |
|
217 | 212 |
|
... | ... | |
225 | 220 |
} |
226 | 221 |
return false; |
227 | 222 |
} |
223 |
|
|
224 |
/** |
|
225 |
* Gets the chart object. According to the used charts engine, it can be a file, an UI component, etc. |
|
226 |
* @return |
|
227 |
*/ |
|
228 |
public Object getChart() { |
|
229 |
try { |
|
230 |
return ((ChartResult) this.result).getChart(); |
|
231 |
} |
|
232 |
catch(Exception e) { |
|
233 |
} |
|
234 |
return null; |
|
235 |
} |
|
228 | 236 |
|
229 | 237 |
} |
tmp/org.txm.chartsengine.rcp/src/org/txm/chartsengine/rcp/editors/ChartEditorPart.java (revision 528) | ||
---|---|---|
4 | 4 |
import java.io.File; |
5 | 5 |
import java.util.ArrayList; |
6 | 6 |
|
7 |
import javax.swing.JComponent; |
|
8 |
|
|
7 | 9 |
import org.eclipse.core.runtime.CoreException; |
8 | 10 |
import org.eclipse.core.runtime.IConfigurationElement; |
9 | 11 |
import org.eclipse.core.runtime.IProgressMonitor; |
... | ... | |
15 | 17 |
import org.eclipse.swt.layout.GridData; |
16 | 18 |
import org.eclipse.swt.widgets.Composite; |
17 | 19 |
import org.eclipse.swt.widgets.Group; |
20 |
import org.eclipse.ui.IEditorInput; |
|
21 |
import org.eclipse.ui.IEditorSite; |
|
18 | 22 |
import org.eclipse.ui.IPartListener; |
19 | 23 |
import org.eclipse.ui.IWorkbenchPart; |
24 |
import org.eclipse.ui.PartInitException; |
|
20 | 25 |
import org.eclipse.ui.PlatformUI; |
21 |
import org.eclipse.ui.contexts.IContextService; |
|
22 | 26 |
import org.eclipse.ui.part.EditorPart; |
23 | 27 |
import org.eclipse.ui.part.MultiPageEditorPart; |
24 | 28 |
import org.txm.chartsengine.core.ChartsEngine; |
29 |
import org.txm.chartsengine.core.results.ChartResult; |
|
25 | 30 |
import org.txm.chartsengine.rcp.SWTChartsComponentsProvider; |
26 | 31 |
import org.txm.chartsengine.rcp.events.EventCallBack; |
27 | 32 |
import org.txm.chartsengine.rcp.events.EventCallBackHandler; |
28 | 33 |
import org.txm.chartsengine.rcp.swt.AdvancedChartEditorToolBar; |
29 | 34 |
import org.txm.chartsengine.rcp.swt.ChartComposite; |
30 | 35 |
import org.txm.chartsengine.rcp.swt.ChartEditorToolBar; |
31 |
import org.txm.core.results.TXMResult; |
|
32 | 36 |
import org.txm.rcp.editors.TXMEditorPart; |
33 | 37 |
import org.txm.rcp.editors.TXMEditorToolBar; |
34 | 38 |
import org.txm.rcp.utils.JobHandler; |
... | ... | |
95 | 99 |
} |
96 | 100 |
|
97 | 101 |
|
98 |
|
|
102 |
|
|
99 | 103 |
/** |
100 | 104 |
* |
101 | 105 |
* @param swtComponentsProvider |
102 |
* @param titleImage |
|
103 |
* @param result |
|
104 |
* @param chartContainer |
|
105 |
*/ |
|
106 |
public ChartEditorPart(SWTChartsComponentsProvider swtComponentsProvider, TXMResult result, String chartType, Object chartContainer) { |
|
107 |
this(swtComponentsProvider, new ChartEditorInput(swtComponentsProvider, result, chartType, chartContainer)); |
|
108 |
} |
|
109 |
|
|
110 |
|
|
111 |
/** |
|
112 |
* |
|
113 |
* @param swtComponentsProvider |
|
114 | 106 |
* @param chartEditorInput |
115 | 107 |
*/ |
116 |
public ChartEditorPart(SWTChartsComponentsProvider swtComponentsProvider, ChartEditorInput chartEditorInput) {
|
|
108 |
protected ChartEditorPart(SWTChartsComponentsProvider swtComponentsProvider, ChartEditorInput chartEditorInput) {
|
|
117 | 109 |
this.setInput(chartEditorInput); |
118 | 110 |
this.setPartName(chartEditorInput.getName()); |
119 | 111 |
|
120 | 112 |
this.wasAlreadyOpened = false; |
121 | 113 |
} |
122 | 114 |
|
123 |
|
|
115 |
/** |
|
116 |
* |
|
117 |
* @param chartEditorInput |
|
118 |
*/ |
|
124 | 119 |
public ChartEditorPart(ChartEditorInput chartEditorInput) { |
125 | 120 |
this(SWTChartsComponentsProvider.getCurrent(), chartEditorInput); |
126 | 121 |
} |
127 | 122 |
|
128 | 123 |
|
124 |
@Override |
|
125 |
public void init(IEditorSite site, IEditorInput input) throws PartInitException { |
|
126 |
|
|
127 |
|
|
128 |
super.init(site, input); |
|
129 |
} |
|
129 | 130 |
|
130 | 131 |
@Override |
131 | 132 |
public void createPartControl(Composite parent) { |
... | ... | |
145 | 146 |
|
146 | 147 |
// Toolbar |
147 | 148 |
this.chartToolBar = new ChartEditorToolBar(this.getTopToolBarContainer(), SWT.FLAT | SWT.RIGHT, this); |
149 |
//this.chartToolBar = new ChartEditorToolBar(this.topToolBar, SWT.FLAT | SWT.RIGHT, this); |
|
148 | 150 |
//this.chartToolBar.setBackground(parent.getDisplay().getSystemColor(SWT.COLOR_RED)); |
149 | 151 |
|
150 | 152 |
|
... | ... | |
223 | 225 |
|
224 | 226 |
// Advanced tool bar |
225 | 227 |
//this.advancedToolBarComposite = new Composite(parent, SWT.NONE); |
226 |
Group group = this.topToolBar.installGroup("Rendering parameters", "Show/Hide rendering parameters", "platform:/plugin/org.txm.chartsengine.rcp/icons/show_rendering_parameters.png"); |
|
228 |
Group group = this.topToolBar.installGroup("Rendering parameters", "Show/Hide rendering parameters", "platform:/plugin/org.txm.chartsengine.rcp/icons/show_rendering_parameters.png", false);
|
|
227 | 229 |
this.advancedChartToolBar = new AdvancedChartEditorToolBar(group, SWT.FLAT, this); |
228 | 230 |
// this.advancedToolBar.setBackground(parent.getDisplay().getSystemColor(SWT.COLOR_WHITE)); |
229 | 231 |
// this.advancedToolBarComposite.pack(true); |
232 |
|
|
233 |
// Remove parent composites |
|
234 |
this.displayArea.dispose(); |
|
235 |
this.bottomToolBar.dispose(); |
|
230 | 236 |
|
231 | 237 |
// Chart composite |
232 |
ChartComposite chartComposite = this.getSWTChartsComponentsProvider().createComposite(this, parent);
|
|
238 |
this.chartComposite = this.getSWTChartsComponentsProvider().createComposite(this, parent);
|
|
233 | 239 |
GridData gd = new GridData(GridData.FILL_BOTH); |
234 | 240 |
// gd.grabExcessVerticalSpace = true; |
235 | 241 |
// gd.grabExcessHorizontalSpace = true; |
236 |
// gd.horizontalSpan = 2; // 2 for match the command parameters toolbar AND the chart toolbar
|
|
237 |
chartComposite.setLayoutData(gd); |
|
242 |
//gd.horizontalSpan = 2; // 2 for match the command parameters toolbar AND the chart toolbar
|
|
243 |
this.chartComposite.setLayoutData(gd);
|
|
238 | 244 |
|
245 |
|
|
246 |
// Re-add the bottom toolbar |
|
247 |
this.bottomToolBar = new TXMEditorToolBar(parent, SWT.FLAT, "bottom", this); |
|
248 |
|
|
239 | 249 |
// FIXME: open dialog box message if the composite doesn't contain any chart (typically when the charts engine doesn't contain chart creator for the specified result data type) |
240 | 250 |
// if(composite.getChart() == null) { |
241 | 251 |
// MessageDialog.openWarning(parent.getShell(), "Warning", "Current charts engine can not create chart for " + this.getResultData().getClass().getSimpleName() + " result type. You can set another charts engine in the preferences."); |
... | ... | |
246 | 256 |
//parent.setBackground(parent.getDisplay().getSystemColor(SWT.COLOR_WHITE)); |
247 | 257 |
|
248 | 258 |
|
259 |
this.computeChart(false); |
|
249 | 260 |
|
250 |
// initialize the default shared context menus as Export, etc. |
|
251 |
SWTChartsComponentsProvider.initDefaultContextMenus(chartComposite); |
|
252 |
|
|
253 | 261 |
|
254 |
// registers user entries event call back extensions |
|
255 |
this.registerEventCallBackExtensions(); |
|
256 | 262 |
|
257 |
//FIXME: test to contribute to menu only in some context |
|
258 |
// create chart editor part context |
|
259 |
// IContextService contextService = (IContextService)getSite().getService(IContextService.class); |
|
260 |
// contextService.activateContext(ChartEditorPart.class.getName()); |
|
261 |
// // create chart composite context |
|
262 |
// contextService.activateContext(this.chartComposite.getClass().getName()); |
|
263 |
|
|
264 |
//FIXME: description test |
|
265 |
//this.setContentDescription("details"); |
|
266 |
//this.setContentDescription(this.getResultData().getDetails()); |
|
267 |
|
|
268 | 263 |
} |
269 | 264 |
|
270 | 265 |
|
... | ... | |
422 | 417 |
*/ |
423 | 418 |
public void computeChart(String jobName, final boolean update, boolean setUser, final boolean resetView, final boolean clearChartItemsSelection) { |
424 | 419 |
|
420 |
|
|
425 | 421 |
JobHandler job = new JobHandler(jobName) { |
426 | 422 |
|
427 | 423 |
@Override |
... | ... | |
430 | 426 |
this.runInit(monitor); |
431 | 427 |
|
432 | 428 |
try { |
433 |
// creating/updating |
|
434 |
monitor.beginTask("Computing", IProgressMonitor.UNKNOWN); |
|
429 |
|
|
430 |
// computing result |
|
431 |
monitor.beginTask("Computing", 100); |
|
432 |
|
|
433 |
// FIXME: temporary solution, should call super.computeResult() ? |
|
434 |
if(getResultData().isDirty()) { |
|
435 |
getResultData().compute(update, monitor); |
|
436 |
} |
|
437 |
|
|
435 | 438 |
|
436 |
if(update) { |
|
437 |
updateChart(); |
|
439 |
// creating/updating chart |
|
440 |
monitor.subTask("computing chart"); |
|
441 |
|
|
442 |
getResultData().computeChart(update); |
|
443 |
|
|
444 |
if(!update) { |
|
445 |
createChartContainer(); |
|
438 | 446 |
} |
439 |
else { |
|
440 |
createChart(); |
|
441 |
} |
|
442 | 447 |
|
448 |
// FIXME: long process test |
|
449 |
// for(long i = 0; i < 9000000000L; i++) { |
|
450 |
// ; |
|
451 |
// } |
|
452 |
|
|
453 |
monitor.worked(25); |
|
454 |
|
|
443 | 455 |
// cancel |
444 | 456 |
if(monitor.isCanceled()) { |
445 | 457 |
close(true); |
... | ... | |
447 | 459 |
} |
448 | 460 |
|
449 | 461 |
// loading |
450 |
monitor.setTaskName("Loading");
|
|
462 |
monitor.subTask("loading chart");
|
|
451 | 463 |
loadChart(resetView, clearChartItemsSelection); |
452 | 464 |
|
465 |
if(!update) { |
|
466 |
// Initialize Swing/AWT events delegation. |
|
467 |
this.syncExec(new Runnable() { |
|
468 |
@Override |
|
469 |
public void run() { |
|
470 |
// initialize the default shared context menus as Export, etc. |
|
471 |
SWTChartsComponentsProvider.initDefaultContextMenus(chartComposite); |
|
472 |
|
|
473 |
|
|
474 |
// registers user entries event call back extensions |
|
475 |
registerEventCallBackExtensions(); |
|
476 |
|
|
477 |
//FIXME: test to contribute to menu only in some context |
|
478 |
// create chart editor part context |
|
479 |
// IContextService contextService = (IContextService)getSite().getService(IContextService.class); |
|
480 |
// contextService.activateContext(ChartEditorPart.class.getName()); |
|
481 |
// // create chart composite context |
|
482 |
// contextService.activateContext(this.chartComposite.getClass().getName()); |
|
483 |
|
|
484 |
//FIXME: description test |
|
485 |
//this.setContentDescription("details"); |
|
486 |
//this.setContentDescription(this.getResultData().getDetails()); |
|
487 |
|
|
488 |
initializeAWTDelegationListeners(); |
|
489 |
} |
|
490 |
}); |
|
491 |
} |
|
492 |
|
|
493 |
|
|
453 | 494 |
// FIXME: refresh the tree node |
454 | 495 |
// getSite().getShell().getDisplay().syncExec(new Runnable() { |
455 | 496 |
// @Override |
... | ... | |
464 | 505 |
} |
465 | 506 |
// for user direct canceling |
466 | 507 |
catch(ThreadDeath td) { |
508 |
// FIXME should clean() and/or set the result as dirty? |
|
467 | 509 |
close(true); |
468 | 510 |
return Status.CANCEL_STATUS; |
469 | 511 |
} |
... | ... | |
482 | 524 |
|
483 | 525 |
|
484 | 526 |
|
527 |
/** |
|
528 |
* Initialize Swing/AWT events delegation. |
|
529 |
* @param swingComponent |
|
530 |
*/ |
|
531 |
protected void initializeAWTDelegationListeners() { |
|
532 |
this.getChartComposite().getChartComponent().setChartEditor(this); |
|
533 |
SWTChartsComponentsProvider.initializeAWTDelegationListeners(this, (JComponent) this.getEditorInput().getChartContainer()); |
|
534 |
} |
|
485 | 535 |
|
486 | 536 |
/** |
487 | 537 |
* Convenience method the get the casted linked editor input. |
... | ... | |
570 | 620 |
|
571 | 621 |
|
572 | 622 |
|
573 |
/** |
|
574 |
* Updates the specified chart stored in the editor and according to the stored TXM result. |
|
575 |
* @return <code>True</code>, if a chart creator has been found and the chart has been updated, otherwise <code>false</code> |
|
576 |
*/ |
|
577 |
public boolean updateChart() { |
|
578 |
return this.getSWTChartsComponentsProvider().updateChart(this); |
|
623 |
public void createChartContainer() { |
|
624 |
this.getSWTChartsComponentsProvider().createChartContainer(this.getEditorInput()); |
|
579 | 625 |
} |
580 | 626 |
|
581 | 627 |
/** |
582 |
* Creates a new chart for the specified result data and save it in the current editor input. |
|
583 |
* @param result |
|
584 |
* @param preferencesNode |
|
585 |
*/ |
|
586 |
public void createChart(TXMResult result) { |
|
587 |
this.getSWTChartsComponentsProvider().createChart(this.getEditorInput(), result); |
|
588 |
} |
|
589 |
|
|
590 |
/** |
|
591 |
* Creates a new chart for current stored result and save it in the current editor input. |
|
592 |
*/ |
|
593 |
public void createChart() { |
|
594 |
this.createChart(this.getResultData()); |
|
595 |
} |
|
596 |
|
|
597 |
/** |
|
598 | 628 |
* Disposes the editor. |
599 | 629 |
* Implementations using a Composite to embed AWT/Swing components should manually call this.composite.dispose() in the redefined method. |
600 | 630 |
*/ |
... | ... | |
627 | 657 |
* @return |
628 | 658 |
*/ |
629 | 659 |
public String getChartType() { |
630 |
return this.getEditorInput().getChartType();
|
|
660 |
return this.getResultData().getChartType();
|
|
631 | 661 |
} |
632 | 662 |
|
633 | 663 |
/** |
... | ... | |
635 | 665 |
* @return |
636 | 666 |
*/ |
637 | 667 |
public Object getChart() { |
638 |
return this.chartComposite.getChart();
|
|
668 |
return this.getResultData().getChart();
|
|
639 | 669 |
} |
640 | 670 |
|
671 |
@Override |
|
672 |
public ChartResult getResultData() { |
|
673 |
return (ChartResult) this.getEditorInput().getResult(); |
|
674 |
} |
|
675 |
|
|
676 |
|
|
641 | 677 |
/** |
642 | 678 |
* Returns the chart components provider associated with the editor (through its <code>ChartEditorInput</code>). |
643 | 679 |
* @return |
... | ... | |
835 | 871 |
/** |
836 | 872 |
* @param composite the composite to set |
837 | 873 |
*/ |
838 |
public void setComposite(ChartComposite composite) { |
|
839 |
this.chartComposite = composite; |
|
840 |
} |
|
874 |
// public void setComposite(ChartComposite composite) {
|
|
875 |
// this.chartComposite = composite;
|
|
876 |
// }
|
|
841 | 877 |
|
842 | 878 |
|
843 | 879 |
|
... | ... | |
860 | 896 |
} |
861 | 897 |
|
862 | 898 |
|
899 |
/** |
|
900 |
* Opens an editor for the specified result. |
|
901 |
* @param result |
|
902 |
* @return |
|
903 |
*/ |
|
904 |
public static ChartEditorPart openEditor(ChartResult result) { |
|
905 |
return SWTChartsComponentsProvider.getCurrent().openEditor(result); |
|
906 |
} |
|
907 |
|
|
863 | 908 |
|
864 | 909 |
/** |
865 | 910 |
* Checks whatever the chart composite has the focus or not. |
... | ... | |
880 | 925 |
protected void initializeFields() { |
881 | 926 |
// TODO Auto-generated method stub |
882 | 927 |
} |
928 |
|
|
929 |
|
|
930 |
|
|
931 |
/** |
|
932 |
* @return the chartComposite |
|
933 |
*/ |
|
934 |
public ChartComposite getChartComposite() { |
|
935 |
return chartComposite; |
|
936 |
} |
|
883 | 937 |
} |
tmp/org.txm.chartsengine.rcp/src/org/txm/chartsengine/rcp/swt/ChartEditorToolBar.java (revision 528) | ||
---|---|---|
11 | 11 |
* @author sjacquot |
12 | 12 |
* |
13 | 13 |
*/ |
14 |
// FIXME: became useless, can directly use TXMEditorToolBar |
|
14 | 15 |
public class ChartEditorToolBar extends TXMEditorToolBar { |
15 | 16 |
|
16 | 17 |
|
tmp/org.txm.chartsengine.rcp/src/org/txm/chartsengine/rcp/swt/AdvancedChartEditorToolBar.java (revision 528) | ||
---|---|---|
2 | 2 |
|
3 | 3 |
import java.awt.Font; |
4 | 4 |
import java.awt.GraphicsEnvironment; |
5 |
import java.util.ArrayList; |
|
5 | 6 |
|
7 |
import org.eclipse.core.runtime.IConfigurationElement; |
|
8 |
import org.eclipse.core.runtime.Platform; |
|
9 |
import org.eclipse.jface.preference.ComboFieldEditor; |
|
6 | 10 |
import org.eclipse.swt.SWT; |
7 | 11 |
import org.eclipse.swt.events.SelectionEvent; |
8 | 12 |
import org.eclipse.swt.events.SelectionListener; |
... | ... | |
10 | 14 |
import org.eclipse.swt.widgets.Composite; |
11 | 15 |
import org.eclipse.swt.widgets.ToolBar; |
12 | 16 |
import org.eclipse.swt.widgets.ToolItem; |
17 |
import org.txm.chartsengine.core.ChartCreator; |
|
13 | 18 |
import org.txm.chartsengine.core.ChartsEngine; |
14 | 19 |
import org.txm.chartsengine.core.preferences.ChartsEnginePreferences; |
15 | 20 |
import org.txm.chartsengine.rcp.editors.ChartEditorPart; |
... | ... | |
166 | 171 |
fontSizeCombo.select(currentFontSizeIndex); |
167 | 172 |
|
168 | 173 |
|
174 |
// Chart types from installed chart creators |
|
169 | 175 |
|
176 |
// if(contributions.length > 1) { |
|
177 |
final Combo chartTypeCombo = new Combo(this, SWT.READ_ONLY); |
|
178 |
ArrayList<ChartCreator> chartCreators = this.chartEditorPart.getSWTChartsComponentsProvider().getChartsEngine().getChartCreators(this.chartEditorPart.getResultData()); |
|
179 |
String chartTypes[] = new String[chartCreators.size()]; |
|
180 |
int currentChartTypeIndex = 0; |
|
181 |
for(int i = 0; i < chartCreators.size(); i++) { |
|
182 |
chartTypes[i] = chartCreators.get(i).getChartType(); |
|
183 |
if(chartTypes[i] == null) { |
|
184 |
chartTypes[i] = this.chartEditorPart.getResultData().getClass().getName(); |
|
185 |
} |
|
186 |
if(this.getEditorPart().getChartType() != null && this.getEditorPart().getChartType().equals(chartTypes[i])) { |
|
187 |
currentChartTypeIndex = i; |
|
188 |
} |
|
189 |
|
|
190 |
} |
Formats disponibles : Unified diff