Révision 1467
tmp/org.txm.rcp/src/main/java/org/txm/rcp/testers/ToolboxTester.java (revision 1467) | ||
---|---|---|
23 | 23 |
public static final String PROPERTY_SEARCH_ENGINE_READY = "SearchEngineReady"; //$NON-NLS-1$ |
24 | 24 |
public static final String PROPERTY_COMPUTABLE = "computable"; //$NON-NLS-1$ |
25 | 25 |
public static final String PROPERTY_PERSISTABLE = "persistable"; //$NON-NLS-1$ |
26 |
public static final String PROPERTY_LOCK = "lock"; //$NON-NLS-1$ |
|
26 | 27 |
|
27 | 28 |
public ToolboxTester() { |
28 | 29 |
// TODO Auto-generated constructor stub |
... | ... | |
55 | 56 |
} |
56 | 57 |
return false; |
57 | 58 |
// System.out.println("TEST: receiver="+receiver+" property="+property+" args="+args+" expectedValue="+expectedValue); //$NON-NLS-1$ //$NON-NLS-2$ |
59 |
} else if (PROPERTY_LOCK.equals(property)) { |
|
60 |
if (receiver == null) return false; |
|
61 |
Class c = receiver.getClass(); |
|
62 |
if (!(receiver instanceof List)) return false; |
|
63 |
|
|
64 |
List list = (List) receiver; |
|
65 |
if (list.size() == 0) return false; |
|
66 |
receiver = list.get(0); |
|
67 |
|
|
68 |
if (receiver instanceof TXMResult) { |
|
69 |
return !((TXMResult)receiver).isLocked(); |
|
70 |
//return true; |
|
71 |
} |
|
72 |
return false; |
|
73 |
// System.out.println("TEST: receiver="+receiver+" property="+property+" args="+args+" expectedValue="+expectedValue); //$NON-NLS-1$ //$NON-NLS-2$ |
|
58 | 74 |
} |
59 | 75 |
|
60 | 76 |
return false; |
tmp/org.txm.rcp/src/main/java/org/txm/rcp/views/corpora/CorporaView.java (revision 1467) | ||
---|---|---|
398 | 398 |
|
399 | 399 |
final int IMAGE_MARGIN = 2; |
400 | 400 |
final Image icon = IImageKeys.getImage("icons/decorators/bullet_green.png"); |
401 |
final Image icon_lock = IImageKeys.getImage("icons/decorators/lock.png"); |
|
401 | 402 |
// final Image icon = AbstractUIPlugin.imageDescriptorFromPlugin("org.eclipse.gef","platform:/plugin/org.eclipse.gef/org/eclipse/gef/internal/icons/pinned.gif").createImage(); |
402 | 403 |
// final Image icon = AbstractUIPlugin.imageDescriptorFromPlugin("org.eclipse.team.svn.help","platform:/plugin/org.eclipse.team.svn.help/images/lock.gif").createImage(); |
403 | 404 |
|
... | ... | |
412 | 413 |
// } |
413 | 414 |
// } |
414 | 415 |
// }); |
415 |
// treeViewer.getTree().addListener(SWT.PaintItem, new Listener() { |
|
416 |
// public void handleEvent(Event event) { |
|
417 |
// if(event.item.getData() instanceof TXMResult && ((TXMResult)event.item.getData()).isUserPersistable()) { |
|
418 |
// TreeItem item = (TreeItem)event.item; |
|
419 |
// Image trailingImage = (Image)item.getImage(); |
|
420 |
// if (trailingImage != null) { |
|
421 |
// //int x = event.x + event.width + IMAGE_MARGIN; |
|
422 |
// int x = event.x + event.width; |
|
423 |
// //int x = event.x - 20; |
|
424 |
// //int x = event.x - 5; |
|
425 |
// int itemHeight = treeViewer.getTree().getItemHeight(); |
|
426 |
// int imageHeight = trailingImage.getBounds().height; |
|
427 |
// int y = event.y + (itemHeight - imageHeight) / 2; |
|
428 |
// //int y = event.y + 5; |
|
429 |
// |
|
430 |
// event.gc.drawImage(icon, x, y); |
|
431 |
// //event.gc.drawImage(PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_ETOOL_SAVE_EDIT_DISABLED), x, y); |
|
432 |
// } |
|
433 |
// } |
|
434 |
// } |
|
435 |
// }); |
|
416 |
treeViewer.getTree().addListener(SWT.PaintItem, new Listener() { |
|
417 |
public void handleEvent(Event event) { |
|
418 |
if (event.item.getData() instanceof TXMResult && ((TXMResult)event.item.getData()).isLocked()) { |
|
419 |
TreeItem item = (TreeItem)event.item; |
|
420 |
Image trailingImage = (Image)item.getImage(); |
|
421 |
if (trailingImage != null) { |
|
422 |
int x = 3 + event.x + event.width; |
|
423 |
int itemHeight = treeViewer.getTree().getItemHeight(); |
|
424 |
int imageHeight = trailingImage.getBounds().height; |
|
425 |
int y = 2+event.y + (itemHeight - imageHeight) / 2; |
|
426 |
|
|
427 |
event.gc.drawImage(icon_lock, x, y); |
|
428 |
} |
|
429 |
} |
|
430 |
} |
|
431 |
}); |
|
436 | 432 |
|
437 |
|
|
438 | 433 |
MenuManager menuManager = new MenuManager(); |
439 | 434 |
Menu menu = menuManager.createContextMenu(treeViewer.getTree()); |
440 | 435 |
|
tmp/org.txm.rcp/src/main/java/org/txm/rcp/handlers/results/SetTXMResultLockState.java (revision 1467) | ||
---|---|---|
1 |
// Copyright © 2010-2013 ENS de Lyon. |
|
2 |
// Copyright © 2007-2010 ENS de Lyon, CNRS, INRP, University of |
|
3 |
// Lyon 2, University of Franche-Comté, University of Nice |
|
4 |
// Sophia Antipolis, University of Paris 3. |
|
5 |
// |
|
6 |
// The TXM platform is free software: you can redistribute it |
|
7 |
// and/or modify it under the terms of the GNU General Public |
|
8 |
// License as published by the Free Software Foundation, |
|
9 |
// either version 2 of the License, or (at your option) any |
|
10 |
// later version. |
|
11 |
// |
|
12 |
// The TXM platform is distributed in the hope that it will be |
|
13 |
// useful, but WITHOUT ANY WARRANTY; without even the implied |
|
14 |
// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR |
|
15 |
// PURPOSE. See the GNU General Public License for more |
|
16 |
// details. |
|
17 |
// |
|
18 |
// You should have received a copy of the GNU General |
|
19 |
// Public License along with the TXM platform. If not, see |
|
20 |
// http://www.gnu.org/licenses. |
|
21 |
// |
|
22 |
// |
|
23 |
// |
|
24 |
// $LastChangedDate:$ |
|
25 |
// $LastChangedRevision:$ |
|
26 |
// $LastChangedBy:$ |
|
27 |
// |
|
28 |
package org.txm.rcp.handlers.results; |
|
29 |
|
|
30 |
import java.util.Map; |
|
31 |
|
|
32 |
import org.eclipse.core.commands.ExecutionEvent; |
|
33 |
import org.eclipse.core.commands.ExecutionException; |
|
34 |
import org.eclipse.ui.commands.IElementUpdater; |
|
35 |
import org.eclipse.ui.menus.UIElement; |
|
36 |
import org.txm.core.preferences.TXMPreferences; |
|
37 |
import org.txm.core.results.TXMResult; |
|
38 |
import org.txm.rcp.handlers.BaseAbstractHandler; |
|
39 |
import org.txm.rcp.views.corpora.CorporaView; |
|
40 |
|
|
41 |
/** |
|
42 |
* Swaps the persistence state of the selected TXM result nodes. |
|
43 |
* |
|
44 |
* @author sjacquot |
|
45 |
* |
|
46 |
*/ |
|
47 |
public class SetTXMResultLockState extends BaseAbstractHandler implements IElementUpdater { |
|
48 |
|
|
49 |
|
|
50 |
@Override |
|
51 |
public Object execute(ExecutionEvent event) throws ExecutionException { |
|
52 |
|
|
53 |
Object object = this.getCorporaViewSelectedObject(event); |
|
54 |
if(object instanceof TXMResult) { |
|
55 |
TXMResult result = ((TXMResult)object); |
|
56 |
result.setLocked(!result.isLocked()); |
|
57 |
|
|
58 |
CorporaView.refreshObject(result); |
|
59 |
return null; |
|
60 |
} |
|
61 |
else { |
|
62 |
return super.logCanNotExecuteCommand(object); |
|
63 |
} |
|
64 |
} |
|
65 |
|
|
66 |
/** |
|
67 |
* Display the checked mark in the menu item when the menu is created |
|
68 |
*/ |
|
69 |
@Override |
|
70 |
public void updateElement(UIElement element, Map parameters) { |
|
71 |
Object object = CorporaView.getFirstSelectedObject(); |
|
72 |
//element. |
|
73 |
if(object != null && object instanceof TXMResult) { |
|
74 |
element.setChecked(((TXMResult)object).isLocked()); |
|
75 |
} |
|
76 |
} |
|
77 |
} |
|
0 | 78 |
tmp/org.txm.rcp/src/main/java/org/txm/rcp/adapters/TXMResultAdapter.java (revision 1467) | ||
---|---|---|
25 | 25 |
*/ |
26 | 26 |
public abstract class TXMResultAdapter extends WorkbenchAdapter { |
27 | 27 |
|
28 |
|
|
29 | 28 |
/** |
30 | 29 |
* Default constructor. |
31 | 30 |
*/ |
tmp/org.txm.rcp/src/main/java/org/txm/rcp/editors/TXMEditor.java (revision 1467) | ||
---|---|---|
430 | 430 |
this.topToolBar.unInstallGroup(COMPUTING_PARAMETERS_GROUP_ID); |
431 | 431 |
} |
432 | 432 |
|
433 |
if (getResult().isLocked()) { |
|
434 |
this.firstLineComposite.setEnabled(false); |
|
435 |
System.out.println("LOCKED!!!"); |
|
436 |
} |
|
433 | 437 |
|
434 | 438 |
// disable the compute button, it will be re-enable or not later when the UI will check if the editor is dirty or not |
435 | 439 |
ToolItem computeButton = this.topToolBar.getItemByContributionId(TOP_TOOLBAR_COMPUTE_BUTTON_ID); |
... | ... | |
611 | 615 |
|
612 | 616 |
// enable/disable the compute button according to dirty state of the editor |
613 | 617 |
if (this.computeButton != null && !this.computeButton.isDisposed()) { |
614 |
this.computeButton.setEnabled(dirty); |
|
618 |
this.computeButton.setEnabled(dirty && !getResult().isLocked());
|
|
615 | 619 |
} |
616 | 620 |
|
617 | 621 |
firePropertyChange(IEditorPart.PROP_DIRTY); |
tmp/org.txm.rcp/plugin.xml (revision 1467) | ||
---|---|---|
2001 | 2001 |
</visibleWhen> |
2002 | 2002 |
</command> |
2003 | 2003 |
<command |
2004 |
commandId="org.txm.rcp.handlers.results.SetTXMResultLockState" |
|
2005 |
mode="FORCE_TEXT" |
|
2006 |
style="toggle"> |
|
2007 |
<visibleWhen |
|
2008 |
checkEnabled="false"> |
|
2009 |
<and> |
|
2010 |
<reference |
|
2011 |
definitionId="OneTXMResultSelected"> |
|
2012 |
</reference> |
|
2013 |
</and> |
|
2014 |
</visibleWhen> |
|
2015 |
</command> |
|
2016 |
<command |
|
2004 | 2017 |
commandId="org.txm.rcp.commands.function.RenameResult" |
2005 | 2018 |
label="%command.label.26" |
2006 | 2019 |
style="push"> |
... | ... | |
2614 | 2627 |
id="org.txm.rcp.handlers.results.SetTXMResultPersistentState" |
2615 | 2628 |
name="%command.name.33"> |
2616 | 2629 |
</command> |
2630 |
<command |
|
2631 |
categoryId="org.txm.rcp.categories.results" |
|
2632 |
defaultHandler="org.txm.rcp.handlers.results.SetTXMResultLockState" |
|
2633 |
id="org.txm.rcp.handlers.results.SetTXMResultLockState" |
|
2634 |
name="Lock"> |
|
2635 |
</command> |
|
2617 | 2636 |
<command |
2618 | 2637 |
defaultHandler="org.txm.rcp.handlers.results.CloneTXMResult" |
2619 | 2638 |
id="org.txm.rcp.handlers.results.CloneTXMResult" |
... | ... | |
3073 | 3092 |
schemeId="org.txm.rcp.scheme" |
3074 | 3093 |
sequence="M1+S"> |
3075 | 3094 |
</key> |
3095 |
<key |
|
3096 |
commandId="org.txm.rcp.handlers.results.SetTXMResultLockState" |
|
3097 |
contextId="org.txm.rcp.views.corpora.CorporaView" |
|
3098 |
schemeId="org.txm.rcp.scheme" |
|
3099 |
sequence="M1+L"> |
|
3100 |
</key> |
|
3076 | 3101 |
</extension> |
3077 | 3102 |
<!-- <extension |
3078 | 3103 |
point="org.eclipse.e4.ui.css.swt.theme"> |
tmp/org.txm.core/src/java/org/txm/core/preferences/TXMPreferences.java (revision 1467) | ||
---|---|---|
169 | 169 |
*/ |
170 | 170 |
public static final String N_LINES_PER_PAGE = "n_lines_per_page"; //$NON-NLS-1$ |
171 | 171 |
|
172 |
public static final String LOCK = "locked_result"; |
|
173 |
|
|
172 | 174 |
/** |
173 | 175 |
* Preferences node qualifier of the instance. |
174 | 176 |
*/ |
... | ... | |
187 | 189 |
|
188 | 190 |
Preferences preferences = this.getDefaultPreferencesNode(); |
189 | 191 |
preferences.putBoolean(TBXPreferences.VISIBLE, true); |
192 |
preferences.putBoolean(TBXPreferences.LOCK, false); |
|
190 | 193 |
} |
191 | 194 |
|
192 | 195 |
/** |
tmp/org.txm.core/src/java/org/txm/core/results/TXMResult.java (revision 1467) | ||
---|---|---|
97 | 97 |
/** |
98 | 98 |
* if frozen, the result is not updated when computed |
99 | 99 |
*/ |
100 |
protected boolean frozen = false; |
|
100 |
@Parameter(key=TXMPreferences.LOCK, type=Parameter.INTERNAL) |
|
101 |
protected boolean locked = false; |
|
101 | 102 |
|
102 | 103 |
/** |
103 | 104 |
* if a method changed the internal data without **recomputing** the result, the result must be marked "altered" |
... | ... | |
333 | 334 |
/** |
334 | 335 |
* Freezes the result -> cannot be recomputed. |
335 | 336 |
*/ |
336 |
public void freeze() {
|
|
337 |
this.frozen = true;
|
|
337 |
public void lock() {
|
|
338 |
this.locked = true;
|
|
338 | 339 |
} |
339 | 340 |
|
340 | 341 |
/** |
341 | 342 |
* Unfreezes the result -> can be recomputed. |
342 | 343 |
*/ |
343 |
public void unfreeze() {
|
|
344 |
this.frozen = false;
|
|
344 |
public void unLock() {
|
|
345 |
this.locked = false;
|
|
345 | 346 |
} |
346 | 347 |
|
347 | 348 |
/** |
348 | 349 |
* Freezes/unfreezes the result. |
349 | 350 |
*/ |
350 |
public void setFrozen(boolean frozen) {
|
|
351 |
this.frozen = frozen;
|
|
351 |
public void setLocked(boolean state) {
|
|
352 |
this.locked = state;
|
|
352 | 353 |
} |
353 | 354 |
|
354 | 355 |
/** |
355 | 356 |
* @return true if the resutl is frozen |
356 | 357 |
*/ |
357 |
public boolean isFrozen() {
|
|
358 |
return this.frozen;
|
|
358 |
public boolean isLocked() {
|
|
359 |
return this.locked;
|
|
359 | 360 |
} |
360 | 361 |
|
361 | 362 |
/** |
... | ... | |
2024 | 2025 |
// no changes to do |
2025 | 2026 |
// FIXME: SJ: we need to do do some actions even if the object is frozen, eg. updating parameters, saving parameters, etc. |
2026 | 2027 |
// FIXME MD: nope the parameters must not move and will be saved in the current state |
2027 |
if (hasBeenComputedOnce && frozen) {
|
|
2028 |
if (hasBeenComputedOnce && locked) {
|
|
2028 | 2029 |
return true; |
2029 | 2030 |
} |
2030 | 2031 |
|
Formats disponibles : Unified diff