Révision 2427
tmp/org.txm.rcp/src/main/java/org/txm/rcp/adapters/TXMResultAdapter.java (revision 2427) | ||
---|---|---|
24 | 24 |
* |
25 | 25 |
*/ |
26 | 26 |
public abstract class TXMResultAdapter extends WorkbenchAdapter { |
27 |
|
|
27 |
|
|
28 | 28 |
/** |
29 |
* Default constructor.
|
|
29 |
* Default constructor. |
|
30 | 30 |
*/ |
31 | 31 |
public TXMResultAdapter() { |
32 | 32 |
// TODO Auto-generated constructor stub |
33 | 33 |
} |
34 |
|
|
34 |
|
|
35 | 35 |
@Override |
36 | 36 |
public Object[] getChildren(Object result) { |
37 | 37 |
if (!(result instanceof TXMResult)) { |
... | ... | |
39 | 39 |
} |
40 | 40 |
return ((TXMResult) result).getChildren(!TBXPreferences.getInstance().getBoolean(TBXPreferences.SHOW_ALL_RESULT_NODES)).toArray(); |
41 | 41 |
} |
42 |
|
|
42 |
|
|
43 | 43 |
@Override |
44 | 44 |
public String getLabel(Object result) { |
45 | 45 |
if (!(result instanceof TXMResult)) { |
46 | 46 |
return result.toString(); |
47 | 47 |
} |
48 | 48 |
String label = ((TXMResult) result).getCurrentName(); |
49 |
|
|
49 |
|
|
50 | 50 |
// FIXME: SJ: doesn't work if a result has more than one editor opened |
51 | 51 |
IEditorPart editor = SWTEditorsUtils.getEditor((TXMResult) result); |
52 |
if(editor != null && editor.isDirty()) {
|
|
52 |
if (editor != null && editor.isDirty()) {
|
|
53 | 53 |
label += " *"; //$NON-NLS-1$ |
54 | 54 |
} |
55 | 55 |
|
56 | 56 |
return label; |
57 | 57 |
} |
58 |
|
|
58 |
|
|
59 | 59 |
@Override |
60 | 60 |
public Object getParent(Object result) { |
61 | 61 |
if (result instanceof TXMResult) { |
62 | 62 |
return ((TXMResult) result).getParent(); |
63 |
} else { |
|
63 |
} |
|
64 |
else { |
|
64 | 65 |
return null; |
65 | 66 |
} |
66 | 67 |
} |
67 |
|
|
68 |
|
|
68 | 69 |
@Override |
69 | 70 |
public FontData getFont(Object element) { |
70 | 71 |
|
71 | 72 |
FontData fontData = null; |
72 | 73 |
|
73 |
if(element instanceof TXMResult) {
|
|
74 |
|
|
74 |
if (element instanceof TXMResult) {
|
|
75 |
|
|
75 | 76 |
fontData = Display.getCurrent().getSystemFont().getFontData()[0]; |
76 | 77 |
|
77 | 78 |
// highlight the node label of the current active editor |
78 |
if(element == BaseAbstractHandler.getActiveEditorResult(null)) {
|
|
79 |
if (element == BaseAbstractHandler.getActiveEditorResult(null)) {
|
|
79 | 80 |
fontData.setStyle(SWT.BOLD); |
80 | 81 |
} |
81 | 82 |
|
82 | 83 |
// display non-persisted result with italic font if the autosave result preference is disabled |
83 |
if(!TBXPreferences.getInstance().getBoolean(TBXPreferences.AUTO_PERSISTENCE_ENABLED) && !((TXMResult)element).isUserPersistable() && !((TXMResult)element).isInternalPersistable()) {
|
|
84 |
if (!TBXPreferences.getInstance().getBoolean(TBXPreferences.AUTO_PERSISTENCE_ENABLED) && !((TXMResult) element).isUserPersistable() && !((TXMResult) element).isInternalPersistable()) {
|
|
84 | 85 |
fontData.setStyle(fontData.getStyle() | SWT.ITALIC); |
85 | 86 |
} |
86 |
|
|
87 |
|
|
87 | 88 |
} |
88 | 89 |
|
89 | 90 |
return fontData; |
90 | 91 |
} |
91 |
|
|
92 |
|
|
92 | 93 |
@Override |
93 |
public RGB getForeground(Object element) {
|
|
94 |
public RGB getForeground(Object element) {
|
|
94 | 95 |
// debug/advanced mode |
95 |
if(TBXPreferences.getInstance().getBoolean(TBXPreferences.EXPERT_USER) && element instanceof TXMResult && !((TXMResult)element).hasBeenComputedOnce()) {
|
|
96 |
// highlight results that has not yet been computed
|
|
96 |
if (TBXPreferences.getInstance().getBoolean(TBXPreferences.EXPERT_USER) && element instanceof TXMResult && !((TXMResult) element).hasBeenComputedOnce()) {
|
|
97 |
// set as gray results that has not yet been computed
|
|
97 | 98 |
Display display = Display.getCurrent(); |
98 |
Color color = display.getSystemColor(SWT.COLOR_DARK_GRAY);
|
|
99 |
return color.getRGB();
|
|
99 |
Color color = display.getSystemColor(SWT.COLOR_DARK_GRAY);
|
|
100 |
return color.getRGB();
|
|
100 | 101 |
} |
101 | 102 |
// FIXME: DEbug |
102 |
// else if(element instanceof TXMResult && ((TXMResult)element).isDirty()) {
|
|
103 |
// Display display = Display.getCurrent();
|
|
104 |
// Color color = display.getSystemColor(SWT.COLOR_YELLOW);
|
|
105 |
// return color.getRGB();
|
|
106 |
// }
|
|
107 |
|
|
103 |
// else if(element instanceof TXMResult && ((TXMResult)element).isDirty()) {
|
|
104 |
// Display display = Display.getCurrent();
|
|
105 |
// Color color = display.getSystemColor(SWT.COLOR_YELLOW);
|
|
106 |
// return color.getRGB();
|
|
107 |
// }
|
|
108 |
|
|
108 | 109 |
return null; |
109 |
}
|
|
110 |
|
|
110 |
}
|
|
111 |
|
|
111 | 112 |
@Override |
112 |
public RGB getBackground(Object element) {
|
|
113 |
public RGB getBackground(Object element) {
|
|
113 | 114 |
|
114 | 115 |
// debug/advanced mode |
115 |
if(TBXPreferences.getInstance().getBoolean(TBXPreferences.EXPERT_USER) && element instanceof TXMResult && !((TXMResult)element).isVisible()) {
|
|
116 |
// highlight results that are not visible
|
|
116 |
if (TBXPreferences.getInstance().getBoolean(TBXPreferences.EXPERT_USER) && element instanceof TXMResult && !((TXMResult) element).isVisible()) {
|
|
117 |
// add a gray background to results that are not visible
|
|
117 | 118 |
Display display = Display.getCurrent(); |
118 |
//Color color = display.getSystemColor(SWT.COLOR_GRAY);
|
|
119 |
// Color color = display.getSystemColor(SWT.COLOR_GRAY);
|
|
119 | 120 |
Color color = new Color(display, 240, 240, 240); |
120 |
return color.getRGB();
|
|
121 |
return color.getRGB();
|
|
121 | 122 |
} |
122 |
|
|
123 | 123 |
|
124 |
|
|
124 | 125 |
// FIXME: SJ: tests |
125 |
// if(element instanceof TXMResult && ((TXMResult)element).isUserPersistable()) {
|
|
126 |
// Display display = Display.getCurrent();
|
|
127 |
// Color color = display.getSystemColor(SWT.COLOR_WIDGET_BACKGROUND);
|
|
128 |
// |
|
129 |
// // FIXME: random color tests
|
|
130 |
//// Random rnd = new Random();
|
|
131 |
//// int r = rnd.nextInt(128) + 128; // 128 ... 255
|
|
132 |
//// int g = rnd.nextInt(128) + 128; // 128 ... 255
|
|
133 |
//// int b = rnd.nextInt(128) + 128; // 128 ... 255
|
|
134 |
//// Color blue = new Color(display, r, g, b);
|
|
135 |
//
|
|
136 |
// return color.getRGB();
|
|
137 |
// }
|
|
126 |
// if(element instanceof TXMResult && ((TXMResult)element).isUserPersistable()) {
|
|
127 |
// Display display = Display.getCurrent();
|
|
128 |
// Color color = display.getSystemColor(SWT.COLOR_WIDGET_BACKGROUND);
|
|
129 |
//
|
|
130 |
// // FIXME: random color tests
|
|
131 |
//// Random rnd = new Random();
|
|
132 |
//// int r = rnd.nextInt(128) + 128; // 128 ... 255
|
|
133 |
//// int g = rnd.nextInt(128) + 128; // 128 ... 255
|
|
134 |
//// int b = rnd.nextInt(128) + 128; // 128 ... 255
|
|
135 |
//// Color blue = new Color(display, r, g, b);
|
|
136 |
//
|
|
137 |
// return color.getRGB();
|
|
138 |
// }
|
|
138 | 139 |
return null; |
139 |
}
|
|
140 |
|
|
140 |
}
|
|
141 |
|
|
141 | 142 |
} |
Formats disponibles : Unified diff