Révision 998

tmp/org.txm.rcp/src/main/java/org/txm/rcp/views/debug/TXMResultDebugView.java (revision 998)
105 105
		buffer.append("UUID: " + this.currentResult.getUUID() + "\n"); //$NON-NLS-1$ //$NON-NLS-2$
106 106
		buffer.append("Simple name: " + this.currentResult.getSimpleName() + "\n"); //$NON-NLS-1$ //$NON-NLS-2$
107 107
		buffer.append("User name: " + this.currentResult.getUserName() + "\n"); //$NON-NLS-1$ //$NON-NLS-2$
108
		buffer.append("Lazy name: " + this.currentResult.getLazyName() + "\n"); //$NON-NLS-1$ //$NON-NLS-2$
108 109
		buffer.append("Name: " + this.currentResult.getName() + "\n"); //$NON-NLS-1$ //$NON-NLS-2$
109 110
		buffer.append("Valid filename: " + this.currentResult.getValidFileName() + "\n"); //$NON-NLS-1$ //$NON-NLS-2$
110 111
		buffer.append("Empty name: " + this.currentResult.getEmptyName() + "\n"); //$NON-NLS-1$ //$NON-NLS-2$
tmp/org.txm.rcp/src/main/java/org/txm/rcp/adapters/TXMResultAdapter.java (revision 998)
31 31
	@Override
32 32
	public String getLabel(Object result) {
33 33
		if (result instanceof TXMResult) {
34
			return ((TXMResult) result).getUserOrSimpleName();
34
			return ((TXMResult) result).getCurrentName();
35 35
		}
36 36
		else {
37 37
			return result.toString();
tmp/org.txm.rcp/src/main/java/org/txm/rcp/commands/function/RenameResult.java (revision 998)
26 26
			final TXMResult r = (TXMResult)first;
27 27
			
28 28
			final IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindow(event);
29
			TextDialog dialog = new TextDialog(window.getShell(), "Rename " + r, "Enter the new name to show in the Corpus view", r.getUserOrSimpleName());
29
			TextDialog dialog = new TextDialog(window.getShell(), "Rename " + r, "Enter the new name to show in the Corpus view", r.getCurrentName());
30 30
			if (dialog.open() == TextDialog.OK) {
31 31
				String newName = dialog.getText();
32 32
				if (newName.length() > 0) {
tmp/org.txm.core/src/java/org/txm/core/preferences/TXMPreferences.java (revision 998)
85 85
	public final static String RESULT_UUID = "result_uuid"; //$NON-NLS-1$
86 86
	public final static String PARENT_UUID = "parent_uuid"; //$NON-NLS-1$
87 87
	public final static String BUNDLE_ID = "bundle_id"; //$NON-NLS-1$
88
	public final static String NAME = "name"; //$NON-NLS-1$
89

  
88
	public final static String USER_NAME = "user_name"; //$NON-NLS-1$
89
	public final static String LAZY_NAME = "lazy_name"; //$NON-NLS-1$
90
	
90 91
	// to shared strings in some command preferences
91 92
	/**
92 93
	 * Queries.
tmp/org.txm.core/src/java/org/txm/core/results/TXMResult.java (revision 998)
102 102
	protected boolean visible;
103 103

  
104 104
	/**
105
	 * The user name. To rename a result but also to store the simple name for unserialization and lazy loading.
105
	 * The user name (to rename a result).
106 106
	 */
107 107
	protected String userName;
108
	
109
	
110
	/**
111
	 *  To store the simple name for unserialization and lazy loading.
112
	 */
113
	protected String lazyName;
114
	
108 115

  
109 116
	/**
110 117
	 * The command preferences node qualifier.
......
205 212
		}
206 213

  
207 214
		// retrieving user name
208
		if (!this.getStringParameterValue(TXMPreferences.NAME).isEmpty()) {
209
			this.userName = this.getStringParameterValue(TXMPreferences.NAME);
215
		if (!this.getStringParameterValue(TXMPreferences.USER_NAME).isEmpty()) {
216
			this.userName = this.getStringParameterValue(TXMPreferences.USER_NAME);
210 217
		}
211 218

  
219
		// retrieving lazy name
220
		if (!this.getStringParameterValue(TXMPreferences.LAZY_NAME).isEmpty()) {
221
			this.lazyName = this.getStringParameterValue(TXMPreferences.LAZY_NAME);
222
		}
223

  
224
		
212 225
		// loads parameters from local result node, current command preferences or default command preferences
213 226
		try {
214 227
			this.autoLoadParametersFromAnnotations(); // auto fill from Parameter annotations
......
723 736

  
724 737
		// internal data to save for unserialization
725 738
		this.saveParameter("class", this.getClass().getName()); //$NON-NLS-1$
726
		// store the user name if exists it otherwise the simple name (to display something at reloading otherwise the simple name can leads to error because the result is not computed until it will be reopen)
727
		this.saveParameter(TXMPreferences.NAME, this.getUserOrSimpleName());
739
		// store the user name if exists, otherwise the simple name as lazy name (to display something at reloading otherwise the simple name can leads to error because the result is not computed until it will be reopen)
740
		if(this.userName != null)	{
741
			this.saveParameter(TXMPreferences.USER_NAME, this.userName);	
742
		}
743
		this.saveParameter(TXMPreferences.LAZY_NAME, this.getSimpleName());	
728 744
		
745
		
729 746
		this.saveParameter(TXMPreferences.RESULT_UUID, this.uniqueID);
730 747
		this.saveParameter(TXMPreferences.BUNDLE_ID, this.preferencesNodeQualifier);
731 748
		if(this.parent != null)	{
......
1341 1358
	public abstract String getDetails();
1342 1359

  
1343 1360
	/**
1344
	 * Gets the user name if exists otherwise the simple name.
1345
	 * @return the user name if exists otherwise the simple name
1361
	 * Gets the user name if exists otherwise, the lazy name if exists, otherwise the simple name.
1362
	 * @return the user name if exists otherwise, the lazy name if exists, otherwise the simple name
1346 1363
	 */
1347
	public String getUserOrSimpleName() {
1364
	public String getCurrentName() {
1348 1365
		if(this.userName != null)	{
1349 1366
			return this.userName;
1350 1367
		}
1368
		else if(this.lazyName != null) {
1369
			return this.lazyName;
1370
		}
1351 1371
		else {
1352 1372
			return this.getSimpleName();	
1353 1373
		}
......
1611 1631

  
1612 1632
		}
1613 1633

  
1634
		// clear the lazy name, no more needed since the object has been computed and getSimpleName() can now work
1635
		this.lazyName = null;
1636
		
1614 1637
		// store last used parameters
1615 1638
		if(updateLastParameters)	{
1616 1639
			this.updateLastParameters();
......
1829 1852
	public void setPersistable(boolean persistable) {
1830 1853
		this.persistable = persistable;
1831 1854
	}
1855

  
1856
	/**
1857
	 * @return the lazyName
1858
	 */
1859
	public String getLazyName() {
1860
		return lazyName;
1861
	}
1832 1862
}
tmp/org.txm.core/src/java/org/txm/Toolbox.java (revision 998)
285 285
					Log.finest("Toolbox.initialize(): bundle_id = " + TXMPreferences.getString(TXMPreferences.BUNDLE_ID, nodeQualifier));
286 286
					Bundle bundle = Platform.getBundle(TXMPreferences.getString(TXMPreferences.BUNDLE_ID, nodeQualifier));
287 287
					if (bundle == null) {
288
						System.out.println("Warning: can not restore object with bundle name "+TXMPreferences.getString(TXMPreferences.BUNDLE_ID, nodeQualifier));
288
						Log.finest("Warning: can not restore object with bundle name " + TXMPreferences.getString(TXMPreferences.BUNDLE_ID, nodeQualifier));
289 289
						continue;
290 290
					}
291
					String className = TXMPreferences.getString("class", nodeQualifier);
291
					String className = TXMPreferences.getString("class", nodeQualifier); //$NON-NLS-1$
292 292
					Class<?> cl = bundle.loadClass(className);
293 293
					Constructor<?> cons = cl.getConstructor(String.class);
294 294
					cons.newInstance(nodeQualifier);

Formats disponibles : Unified diff