Révision 1877
| tmp/org.txm.core/src/java/org/txm/core/preferences/TXMPreferences.java (revision 1877) | ||
|---|---|---|
| 607 | 607 |
*/ |
| 608 | 608 |
public static String getString(String key, TXMResult result, String nodePath, String defaultValue) {
|
| 609 | 609 |
|
| 610 |
// if(result instanceof Project) {
|
|
| 611 |
// //TXMPreferences.dump(); |
|
| 612 |
// return preferencesService.getRootNode().node(result.getParametersNodePath()).get(key, defaultValue); |
|
| 613 |
// } |
|
| 614 |
|
|
| 615 |
|
|
| 616 |
// if(result != null && result.getProject() != null && result.getProject().getPreferencesScope().getNode(result.getUUID()) != null) {
|
|
| 617 |
// return result.getProject().getPreferencesScope().getNode(result.getUUID()).get(key, defaultValue); |
|
| 618 |
// } |
|
| 619 |
|
|
| 620 | 610 |
nodePath = findNodePath(nodePath, result, key); |
| 621 | 611 |
|
| 622 | 612 |
//System.out.println("--- TXMPreferences.getString() node path = " + nodePath);
|
| ... | ... | |
| 639 | 629 |
*/ |
| 640 | 630 |
public static Date getDate(String key, TXMResult result, String nodePath, Date defaultValue) {
|
| 641 | 631 |
|
| 642 |
// if(result instanceof Project) {
|
|
| 643 |
// //TXMPreferences.dump(); |
|
| 644 |
// return preferencesService.getRootNode().node(result.getParametersNodePath()).get(key, defaultValue); |
|
| 645 |
// } |
|
| 646 |
|
|
| 647 |
|
|
| 648 |
// if(result != null && result.getProject() != null && result.getProject().getPreferencesScope().getNode(result.getUUID()) != null) {
|
|
| 649 |
// return result.getProject().getPreferencesScope().getNode(result.getUUID()).get(key, defaultValue); |
|
| 650 |
// } |
|
| 651 |
|
|
| 652 | 632 |
nodePath = findNodePath(nodePath, result, key); |
| 653 | 633 |
|
| 654 | 634 |
//System.out.println("--- TXMPreferences.getString() node path = " + nodePath);
|
| ... | ... | |
| 1080 | 1060 |
* @return <code>true</code> if the node exists, otherwise <code>false</code> |
| 1081 | 1061 |
*/ |
| 1082 | 1062 |
public static boolean resultScopeNodeExists(TXMResult result) {
|
| 1063 |
// FIXME: SJ: this code seems to create the node but it shouldn't |
|
| 1083 | 1064 |
return preferencesRootNode.node(result.getParametersNodePath()) != null; |
| 1065 |
// Try this one instead |
|
| 1066 |
// try {
|
|
| 1067 |
// return preferencesRootNode.nodeExists(result.getParametersNodePath()); |
|
| 1068 |
// } |
|
| 1069 |
// catch (BackingStoreException e) {
|
|
| 1070 |
// // TODO Auto-generated catch block |
|
| 1071 |
// e.printStackTrace(); |
|
| 1072 |
// } |
|
| 1073 |
// return false; |
|
| 1084 | 1074 |
} |
| 1085 | 1075 |
|
| 1086 | 1076 |
/** |
| ... | ... | |
| 1092 | 1082 |
*/ |
| 1093 | 1083 |
public static boolean keyExists(String nodePath, String key) {
|
| 1094 | 1084 |
|
| 1095 |
if(preferencesRootNode.node(nodePath) != null) {
|
|
| 1096 |
try {
|
|
| 1097 |
return Arrays.asList(preferencesRootNode.node(nodePath).keys()).contains(key); |
|
| 1085 |
if (!nodePath.startsWith("/instance")) {
|
|
| 1086 |
nodePath = "/instance/" + nodePath; |
|
| 1087 |
} |
|
| 1088 |
|
|
| 1089 |
|
|
| 1090 |
try {
|
|
| 1091 |
if(preferencesRootNode.nodeExists(nodePath)) {
|
|
| 1092 |
try {
|
|
| 1093 |
return Arrays.asList(preferencesRootNode.node(nodePath).keys()).contains(key); |
|
| 1094 |
} |
|
| 1095 |
catch(BackingStoreException e) {
|
|
| 1096 |
e.printStackTrace(); |
|
| 1097 |
} |
|
| 1098 | 1098 |
} |
| 1099 |
catch(BackingStoreException e) {
|
|
| 1100 |
e.printStackTrace(); |
|
| 1101 |
} |
|
| 1102 | 1099 |
} |
| 1100 |
catch (BackingStoreException e) {
|
|
| 1101 |
// TODO Auto-generated catch block |
|
| 1102 |
e.printStackTrace(); |
|
| 1103 |
} |
|
| 1103 | 1104 |
return false; |
| 1104 | 1105 |
} |
| 1105 | 1106 |
|
| ... | ... | |
| 1124 | 1125 |
* @param key |
| 1125 | 1126 |
*/ |
| 1126 | 1127 |
public static void setEmpty(String nodePath, String key) {
|
| 1128 |
if (!nodePath.startsWith("/instance")) {
|
|
| 1129 |
nodePath = "/instance/" + nodePath; |
|
| 1130 |
} |
|
| 1127 | 1131 |
preferencesRootNode.node(nodePath).put(key, ""); |
| 1128 | 1132 |
} |
| 1129 | 1133 |
|
Formats disponibles : Unified diff