Révision 2533
| tmp/org.txm.rcp/src/main/java/org/txm/rcp/handlers/results/SetTXMResultPersistentState.java (revision 2533) | ||
|---|---|---|
| 33 | 33 |
import org.eclipse.core.commands.ExecutionException; |
| 34 | 34 |
import org.eclipse.ui.commands.IElementUpdater; |
| 35 | 35 |
import org.eclipse.ui.menus.UIElement; |
| 36 |
import org.txm.core.preferences.TXMPreferences; |
|
| 37 | 36 |
import org.txm.core.results.TXMResult; |
| 38 | 37 |
import org.txm.rcp.handlers.BaseAbstractHandler; |
| 39 | 38 |
import org.txm.rcp.views.corpora.CorporaView; |
| 40 | 39 |
|
| 41 | 40 |
/** |
| 42 |
* Swaps the persistence state of the selected TXM result nodes.
|
|
| 41 |
* Swaps the persistence state of the selected TXM result node. |
|
| 43 | 42 |
* |
| 44 | 43 |
* @author sjacquot |
| 45 | 44 |
* |
| 46 | 45 |
*/ |
| 47 | 46 |
public class SetTXMResultPersistentState extends BaseAbstractHandler implements IElementUpdater {
|
| 48 |
|
|
| 49 |
|
|
| 47 |
|
|
| 48 |
|
|
| 50 | 49 |
@Override |
| 51 | 50 |
public Object execute(ExecutionEvent event) throws ExecutionException {
|
| 52 |
|
|
| 51 |
|
|
| 53 | 52 |
// FIXME: multiple selection |
| 54 |
// FIXME: how to manage the checkbox state?
|
|
| 55 |
// List objects = this.getCorporaViewSelectedObjects(event);
|
|
| 56 |
// if(objects != null) {
|
|
| 57 |
// for (int i = 0; i < objects.size(); i++) {
|
|
| 58 |
// if(objects.get(i) instanceof TXMResult) {
|
|
| 59 |
// ((TXMResult)objects.get(i)).swapPersistableState();
|
|
| 60 |
// }
|
|
| 61 |
// }
|
|
| 62 |
// //CorporaView.refresh();
|
|
| 63 |
// return null;
|
|
| 64 |
// }
|
|
| 65 |
// else {
|
|
| 66 |
// return super.logCanNotExecuteCommand(objects);
|
|
| 67 |
// }
|
|
| 53 |
// FIXME: how to manage the checkbox state? |
|
| 54 |
// List objects = this.getCorporaViewSelectedObjects(event);
|
|
| 55 |
// if(objects != null) {
|
|
| 56 |
// for (int i = 0; i < objects.size(); i++) {
|
|
| 57 |
// if(objects.get(i) instanceof TXMResult) {
|
|
| 58 |
// ((TXMResult)objects.get(i)).swapPersistableState();
|
|
| 59 |
// }
|
|
| 60 |
// }
|
|
| 61 |
// //CorporaView.refresh();
|
|
| 62 |
// return null;
|
|
| 63 |
// }
|
|
| 64 |
// else {
|
|
| 65 |
// return super.logCanNotExecuteCommand(objects);
|
|
| 66 |
// }
|
|
| 68 | 67 |
|
| 69 | 68 |
// FIXME: single selection |
| 70 | 69 |
Object object = this.getCorporaViewSelectedObject(event); |
| 71 |
if(object instanceof TXMResult) {
|
|
| 72 |
TXMResult result = ((TXMResult)object); |
|
| 70 |
if (object instanceof TXMResult) {
|
|
| 71 |
|
|
| 72 |
TXMResult result = ((TXMResult) object); |
|
| 73 | 73 |
result.swapUserPersistableState(); |
| 74 | 74 |
|
| 75 | 75 |
CorporaView.refreshObject(result); |
| 76 |
//CorporaView.refresh(); |
|
| 76 |
|
|
| 77 | 77 |
return null; |
| 78 | 78 |
} |
| 79 |
else {
|
|
| 79 |
else {
|
|
| 80 | 80 |
return super.logCanNotExecuteCommand(object); |
| 81 | 81 |
} |
| 82 |
|
|
| 82 |
|
|
| 83 | 83 |
} |
| 84 |
|
|
| 84 |
|
|
| 85 |
// FIXME: SJ: became useless? |
|
| 85 | 86 |
/** |
| 86 | 87 |
* Display the checked mark in the menu item when the menu is created |
| 87 | 88 |
*/ |
| 88 | 89 |
@Override |
| 89 | 90 |
public void updateElement(UIElement element, Map parameters) {
|
| 90 | 91 |
Object object = CorporaView.getFirstSelectedObject(); |
| 91 |
//element. |
|
| 92 |
if(object != null && object instanceof TXMResult) {
|
|
| 93 |
element.setChecked(((TXMResult)object).isUserPersistable()); |
|
| 92 |
// element.
|
|
| 93 |
if (object != null && object instanceof TXMResult) {
|
|
| 94 |
element.setChecked(((TXMResult) object).isUserPersistable());
|
|
| 94 | 95 |
} |
| 95 | 96 |
} |
| 96 | 97 |
} |
| tmp/org.txm.rcp/src/main/java/org/txm/rcp/views/corpora/CorporaView.java (revision 2533) | ||
|---|---|---|
| 615 | 615 |
@Override |
| 616 | 616 |
public void run() {
|
| 617 | 617 |
|
| 618 |
// FIXME: Debug |
|
| 619 |
// System.err.println("CorporaView.refreshObject(...).new Runnable() {...}.run(): refreshing node " + result);
|
|
| 620 |
// System.err.println("CorporaView.refreshObject(...).new Runnable() {...}.run(): direct parent " + result.getParent());
|
|
| 621 |
// System.err.println("CorporaView.refreshObject(...).new Runnable() {...}.run(): path " + result.getFullPathSimpleName());
|
|
| 622 |
|
|
| 623 | 618 |
CorporaView corporaView = getInstance(); |
| 624 |
corporaView.treeViewer.refresh(); // FIXME: without that the refresh sometimes doesn't work, need to investigate (after some test it may occurs when a hierarchy of more than one result |
|
| 625 |
// is created. Need to refresh all the hierarchy result one by one?) |
|
| 626 | 619 |
|
| 627 |
corporaView.treeViewer.refresh(result);
|
|
| 620 |
corporaView.treeViewer.refresh(); |
|
| 628 | 621 |
|
| 629 | 622 |
try {
|
| 630 | 623 |
CorporaView.expand(result.getParent()); |
| tmp/org.txm.core/src/java/org/txm/core/results/TXMResult.java (revision 2533) | ||
|---|---|---|
| 2758 | 2758 |
/** |
| 2759 | 2759 |
* Sets the user defined persistable state of the result. |
| 2760 | 2760 |
* |
| 2761 |
* When making a result persistent, since a result is always created from its parent(s) and need them to be reconstructed, the state of all the parents in the branch will be set as persistent. |
|
| 2762 |
* When making a result non persistent, its children will not be able to be reconstructed, so they are recursively set as non persistent. |
|
| 2763 |
* Also, since some kind of TXM shortcut commands create some hidden results (e.g. Specificities on Partition that creates an hidden Lexical Table), |
|
| 2764 |
* when making a result non persistent, all its parents that are hidden in the branch are set as non persistent (otherwise they wouldn't be deleted). |
|
| 2765 |
* |
|
| 2766 |
* This method also flushes the result parameter node and so saves the persistence file. |
|
| 2767 |
* |
|
| 2761 | 2768 |
* @param userPersistable the state to set |
| 2762 | 2769 |
*/ |
| 2763 |
public void setUserPersistable(boolean userPersistable) {
|
|
| 2770 |
protected void setUserPersistable(boolean userPersistable, boolean deep) {
|
|
| 2764 | 2771 |
this.userPersistable = userPersistable; |
| 2765 | 2772 |
|
| 2766 | 2773 |
// 1- MANAGE THE PARENTS |
| 2767 |
// force persistable state of the parent if this result is set to persistable
|
|
| 2774 |
// recursively force the persistable state of the parents if this result is set to persistable
|
|
| 2768 | 2775 |
if (userPersistable && this.parent != null && !this.parent.isInternalPersistable()) {
|
| 2769 |
this.parent.setUserPersistable(true); |
|
| 2770 |
} // un persist parent if it is not visible (internal persistable parent is always visible) |
|
| 2771 |
else if (!userPersistable && !parent.isVisible()) {
|
|
| 2772 |
this.parent.setUserPersistable(false); |
|
| 2776 |
this.parent.setUserPersistable(true, false); |
|
| 2773 | 2777 |
} |
| 2774 |
|
|
| 2778 |
// recursively unpersist hidden parents |
|
| 2779 |
else if (!userPersistable && !this.parent.isVisible()) {
|
|
| 2780 |
this.parent.setUserPersistable(false, false); |
|
| 2781 |
} |
|
| 2775 | 2782 |
// 2- MANAGE THE CHILDREN |
| 2776 |
// force non-persistable state of children if this result is set to non-persistable |
|
| 2777 |
if (!userPersistable) {
|
|
| 2778 |
for (TXMResult child : getChildren()) {
|
|
| 2779 |
child.setUserPersistable(userPersistable); |
|
| 2783 |
// recursively force non-persistable state of children if this result is set to non-persistable |
|
| 2784 |
// also transfer this result state to its children marked as "must be synchronized with parent" |
|
| 2785 |
if (deep) {
|
|
| 2786 |
for (TXMResult child : this.getChildren()) {
|
|
| 2787 |
if (!userPersistable || child.mustBeSynchronizedWithParent()) {
|
|
| 2788 |
child.setUserPersistable(userPersistable); |
|
| 2789 |
} |
|
| 2780 | 2790 |
} |
| 2781 | 2791 |
} |
| 2782 | 2792 |
|
| ... | ... | |
| 2794 | 2804 |
} |
| 2795 | 2805 |
|
| 2796 | 2806 |
/** |
| 2807 |
* Sets the user defined persistable state of the result and its children. |
|
| 2808 |
* |
|
| 2809 |
* @param userPersistable |
|
| 2810 |
*/ |
|
| 2811 |
public void setUserPersistable(boolean userPersistable) {
|
|
| 2812 |
this.setUserPersistable(userPersistable, true); |
|
| 2813 |
} |
|
| 2814 |
|
|
| 2815 |
/** |
|
| 2797 | 2816 |
* Swaps the user persistable state. |
| 2798 | 2817 |
* |
| 2799 | 2818 |
* propagate persistence to parent if necessary |
| tmp/org.txm.ca.core/src/org/txm/ca/core/functions/CA.java (revision 2533) | ||
|---|---|---|
| 134 | 134 |
*/ |
| 135 | 135 |
public CA(LexicalTable lexicalTable) {
|
| 136 | 136 |
this(null, lexicalTable); |
| 137 |
|
|
| 138 |
// FIXME: SJ: the CA must not create its own Eigenvalues bar chart. All must be done on the UI-side. |
|
| 139 |
// Eigenvalues eigenvalues = (Eigenvalues) this.getFirstChild(Eigenvalues.class); |
|
| 140 |
// if (eigenvalues == null) {
|
|
| 141 |
// eigenvalues = new Eigenvalues(this); |
|
| 142 |
// } |
|
| 143 | 137 |
} |
| 144 | 138 |
|
| 145 | 139 |
/** |
| ... | ... | |
| 1051 | 1045 |
return (LexicalTable) this.parent; |
| 1052 | 1046 |
} |
| 1053 | 1047 |
|
| 1054 |
// FIXME: SJ: fix to save the eigenvalues when the CA is saved |
|
| 1055 |
// FIXME: SJ: temporary fix to save the Eigenvalues. This method should be removed when the CAEditor will be managed in a better way |
|
| 1056 |
@Override |
|
| 1057 |
public void setUserPersistable(boolean userPersistable) {
|
|
| 1058 |
super.setUserPersistable(userPersistable); // can not call super method, lead to infinite loop
|
|
| 1059 |
|
|
| 1060 |
// deep persistence
|
|
| 1061 |
for (TXMResult child : getChildren()) {
|
|
| 1062 |
child.setUserPersistable(userPersistable);
|
|
| 1063 |
}
|
|
| 1064 |
} |
|
| 1048 |
// // FIXME: SJ: fix to save the eigenvalues when the CA is saved
|
|
| 1049 |
// // FIXME: SJ: temporary fix to save the Eigenvalues. This method should be removed when the CAEditor will be managed in a better way
|
|
| 1050 |
// @Override
|
|
| 1051 |
// public void setUserPersistable(boolean userPersistable) {
|
|
| 1052 |
// super.setUserPersistable(userPersistable); // can not call super method, lead to infinite loop
|
|
| 1053 |
// |
|
| 1054 |
// // deep persistence
|
|
| 1055 |
// for (TXMResult child : getChildren()) {
|
|
| 1056 |
// child.setUserPersistable(userPersistable);
|
|
| 1057 |
// }
|
|
| 1058 |
// }
|
|
| 1065 | 1059 |
|
| 1066 | 1060 |
|
| 1067 | 1061 |
} |
| tmp/org.txm.ca.core/src/org/txm/ca/core/functions/Eigenvalues.java (revision 2533) | ||
|---|---|---|
| 118 | 118 |
} |
| 119 | 119 |
|
| 120 | 120 |
|
| 121 |
// FIXME: SJ: fix to save the eigenvalues when the CA is saved |
|
| 122 |
// FIXME: SJ: temporary fix to save the Eigenvalues. This method should be removed when the CAEditor will be managed in a better way |
|
| 123 |
@Override |
|
| 124 |
public void setUserPersistable(boolean userPersistable) {
|
|
| 125 |
this.userPersistable = userPersistable;
|
|
| 126 |
|
|
| 127 |
// directly save and flush the preference
|
|
| 128 |
try {
|
|
| 129 |
if (this.isUserPersistable()) {
|
|
| 130 |
this.autoSaveParametersFromAnnotations();
|
|
| 131 |
this.saveParameters();
|
|
| 132 |
TXMPreferences.flush(this);
|
|
| 133 |
}
|
|
| 134 |
}
|
|
| 135 |
catch (Exception e) {
|
|
| 136 |
// TODO Auto-generated catch block
|
|
| 137 |
e.printStackTrace();
|
|
| 138 |
}
|
|
| 139 |
} |
|
| 121 |
// // FIXME: SJ: fix to save the eigenvalues when the CA is saved
|
|
| 122 |
// // FIXME: SJ: temporary fix to save the Eigenvalues. This method should be removed when the CAEditor will be managed in a better way
|
|
| 123 |
// @Override
|
|
| 124 |
// public void setUserPersistable(boolean userPersistable) {
|
|
| 125 |
// this.userPersistable = userPersistable;
|
|
| 126 |
// |
|
| 127 |
// // directly save and flush the preference
|
|
| 128 |
// try {
|
|
| 129 |
// if (this.isUserPersistable()) {
|
|
| 130 |
// this.autoSaveParametersFromAnnotations();
|
|
| 131 |
// this.saveParameters();
|
|
| 132 |
// TXMPreferences.flush(this);
|
|
| 133 |
// }
|
|
| 134 |
// }
|
|
| 135 |
// catch (Exception e) {
|
|
| 136 |
// // TODO Auto-generated catch block
|
|
| 137 |
// e.printStackTrace();
|
|
| 138 |
// }
|
|
| 139 |
// }
|
|
| 140 | 140 |
|
| 141 | 141 |
} |
Formats disponibles : Unified diff