summaryrefslogtreecommitdiffstats
path: root/scilab/modules
diff options
context:
space:
mode:
authorSylvestre Ledru <sylvestre.ledru@scilab.org>2010-05-19 10:49:23 +0200
committerSylvestre Ledru <sylvestre.ledru@scilab.org>2010-05-19 10:49:23 +0200
commitb15638d54c98f8232372300c987eba4bb373bddd (patch)
treee789a3871474c9ef7b04d88b7dd0c6012c796225 /scilab/modules
parentbd0792039a4929c292900dc1d567df4c41fd0e8a (diff)
downloadscilab-b15638d54c98f8232372300c987eba4bb373bddd.zip
scilab-b15638d54c98f8232372300c987eba4bb373bddd.tar.gz
Catch the exception in case of error + indentation
Change-Id: I27510e5d35e6319a5d67567e27e4701536a6eaa6
Diffstat (limited to 'scilab/modules')
-rw-r--r--scilab/modules/graphic_export/src/java/org/scilab/modules/graphic_export/FileExporter.java160
-rw-r--r--scilab/modules/gui/src/java/org/scilab/modules/gui/bridge/CallScilabBridge.java5443
2 files changed, 2806 insertions, 2797 deletions
diff --git a/scilab/modules/graphic_export/src/java/org/scilab/modules/graphic_export/FileExporter.java b/scilab/modules/graphic_export/src/java/org/scilab/modules/graphic_export/FileExporter.java
index e6cd8b5..bf57ca1 100644
--- a/scilab/modules/graphic_export/src/java/org/scilab/modules/graphic_export/FileExporter.java
+++ b/scilab/modules/graphic_export/src/java/org/scilab/modules/graphic_export/FileExporter.java
@@ -17,6 +17,7 @@ package org.scilab.modules.graphic_export;
17import java.lang.reflect.Method; 17import java.lang.reflect.Method;
18 18
19import java.io.File; 19import java.io.File;
20import java.io.IOException;
20import org.scilab.modules.renderer.FigureMapper; 21import org.scilab.modules.renderer.FigureMapper;
21import org.scilab.modules.renderer.figureDrawing.DrawableFigureGL; 22import org.scilab.modules.renderer.figureDrawing.DrawableFigureGL;
22 23
@@ -49,93 +50,98 @@ public class FileExporter {
49 * depending on the kind of error 50 * depending on the kind of error
50 */ 51 */
51 public static int fileExport(int figureIndex, String fileName, int fileType, int fileOrientation) { 52 public static int fileExport(int figureIndex, String fileName, int fileType, int fileOrientation) {
52 int saveFileType = -1; 53 int saveFileType = -1;
53 String saveFileName = ""; 54 String saveFileName = "";
54 55
55 DrawableFigureGL exportedFig = FigureMapper.getCorrespondingFigure(figureIndex); 56 DrawableFigureGL exportedFig = FigureMapper.getCorrespondingFigure(figureIndex);
56 57
57 if (exportedFig == null) { 58 if (exportedFig == null) {
58 // figure no longer exists 59 // figure no longer exists
59 return ExportRenderer.IOEXCEPTION_ERROR; 60 return ExportRenderer.IOEXCEPTION_ERROR;
60 }
61
62 //When the graphic-export is too long, we inform the user that the figure is exporting
63 String oldInfoMessage = exportedFig.getInfoMessage();
64 exportedFig.setInfoMessage(exportingMessage);
65 if (fileType == ExportRenderer.PDF_EXPORT || fileType == ExportRenderer.EPS_EXPORT || fileType == ExportRenderer.PS_EXPORT ) {
66
67 /* Under !Windows, make sure that the library for ps export
68 * are already loaded
69 * Note that this code is an ugly workaround to avoid the explicit call
70 * to:
71 * LoadClassPath.loadOnUse(CLASSPATH_PDF_PS_EPS_EXPORT_NAME);
72 * which creates a cyclic dependencies on:
73 * graphic_export => jvm => gui => graphic_export
74 * This code will retrieve on the fly the object and call the method
75 */
76 try {
77 Class jvmLoadClassPathClass = Class.forName("org.scilab.modules.jvm.LoadClassPath");
78 Method loadOnUseMethod = jvmLoadClassPathClass.getDeclaredMethod("loadOnUse", new Class[] { String.class });
79 loadOnUseMethod.invoke(null, CLASSPATH_PDF_PS_EPS_EXPORT_NAME);
80 } catch (java.lang.ClassNotFoundException ex) {
81 System.err.println("Could not find the Scilab class to load the export dependencies: "+ex);
82 } catch (java.lang.NoSuchMethodException ex) {
83 System.err.println("Could not find the Scilab method to load the export dependencies: "+ex);
84 } catch (java.lang.IllegalAccessException ex) {
85 System.err.println("Could not access to the Scilab method to load the export dependencies: "+ex);
86 } catch (java.lang.reflect.InvocationTargetException ex) {
87 System.err.println("Could not invoke the Scilab method to load the export dependencies: "+ex);
88 }
89
90 String ext = "";
91
92 switch (fileType) {
93 case ExportRenderer.PDF_EXPORT:
94 ext = ".pdf";
95 break;
96 case ExportRenderer.EPS_EXPORT:
97 ext = ".eps";
98 break;
99 case ExportRenderer.PS_EXPORT:
100 ext = ".ps";
101 break;
102 default: /* Do not the extension. Probably an error */
103 return ExportRenderer.IOEXCEPTION_ERROR;
104 } 61 }
105 62
106 String name = new File(fileName).getName(); 63 //When the graphic-export is too long, we inform the user that the figure is exporting
107 int dotPosition = name.lastIndexOf("."); 64 String oldInfoMessage = exportedFig.getInfoMessage();
108 if (dotPosition > 0) { 65 exportedFig.setInfoMessage(exportingMessage);
109 name = name.substring(0, dotPosition); 66 if (fileType == ExportRenderer.PDF_EXPORT || fileType == ExportRenderer.EPS_EXPORT || fileType == ExportRenderer.PS_EXPORT ) {
110 saveFileName = fileName.substring(0, fileName.lastIndexOf(".")) + ext; 67
111 } else { 68 /* Under !Windows, make sure that the library for ps export
112 saveFileName = fileName + ext; 69 * are already loaded
70 * Note that this code is an ugly workaround to avoid the explicit call
71 * to:
72 * LoadClassPath.loadOnUse(CLASSPATH_PDF_PS_EPS_EXPORT_NAME);
73 * which creates a cyclic dependencies on:
74 * graphic_export => jvm => gui => graphic_export
75 * This code will retrieve on the fly the object and call the method
76 */
77 try {
78 Class jvmLoadClassPathClass = Class.forName("org.scilab.modules.jvm.LoadClassPath");
79 Method loadOnUseMethod = jvmLoadClassPathClass.getDeclaredMethod("loadOnUse", new Class[] { String.class });
80 loadOnUseMethod.invoke(null, CLASSPATH_PDF_PS_EPS_EXPORT_NAME);
81 } catch (java.lang.ClassNotFoundException ex) {
82 System.err.println("Could not find the Scilab class to load the export dependencies: " + ex);
83 } catch (java.lang.NoSuchMethodException ex) {
84 System.err.println("Could not find the Scilab method to load the export dependencies: " + ex);
85 } catch (java.lang.IllegalAccessException ex) {
86 System.err.println("Could not access to the Scilab method to load the export dependencies: " + ex);
87 } catch (java.lang.reflect.InvocationTargetException ex) {
88 System.err.println("Could not invoke the Scilab method to load the export dependencies: " + ex);
89 }
90
91 String ext = "";
92
93 switch (fileType) {
94 case ExportRenderer.PDF_EXPORT:
95 ext = ".pdf";
96 break;
97 case ExportRenderer.EPS_EXPORT:
98 ext = ".eps";
99 break;
100 case ExportRenderer.PS_EXPORT:
101 ext = ".ps";
102 break;
103 default: /* Do not the extension. Probably an error */
104 return ExportRenderer.IOEXCEPTION_ERROR;
105 }
106
107 String name = new File(fileName).getName();
108 int dotPosition = name.lastIndexOf(".");
109 if (dotPosition > 0) {
110 name = name.substring(0, dotPosition);
111 saveFileName = fileName.substring(0, fileName.lastIndexOf(".")) + ext;
112 } else {
113 saveFileName = fileName + ext;
114 }
115
116 try {
117 /* Temporary SVG file which will be used to convert to PDF */
118 fileName = File.createTempFile(name,"svg").getAbsolutePath();
119 } catch (IOException e) {
120 System.err.println("Could not create temporary file " + e.getLocalizedMessage());
121 }
122
123 saveFileType = fileType;
124 fileType = ExportRenderer.SVG_EXPORT;
113 } 125 }
114
115 /* Temporary SVG file which will be used to convert to PDF */
116 fileName = File.createTempFile(name,"svg").getAbsolutePath();
117 saveFileType = fileType;
118 fileType = ExportRenderer.SVG_EXPORT;
119 }
120 126
121 ExportRenderer export; 127 ExportRenderer export;
122 export = ExportRenderer.createExporter(figureIndex, fileName, fileType, fileOrientation); 128 export = ExportRenderer.createExporter(figureIndex, fileName, fileType, fileOrientation);
123 129
124 // To be sure that their is a GLContext active for export 130 // To be sure that their is a GLContext active for export
125 exportedFig.openGraphicCanvas(); 131 exportedFig.openGraphicCanvas();
126 132
127 exportedFig.getRenderingTarget().addGLEventListener(export); 133 exportedFig.getRenderingTarget().addGLEventListener(export);
128 exportedFig.drawCanvas(); 134 exportedFig.drawCanvas();
129 exportedFig.getRenderingTarget().removeGLEventListener(export); 135 exportedFig.getRenderingTarget().removeGLEventListener(export);
130 136
131 //Put back the old infoMessage 137 //Put back the old infoMessage
132 exportedFig.setInfoMessage(oldInfoMessage); 138 exportedFig.setInfoMessage(oldInfoMessage);
133 139
134 if (saveFileType != -1) { 140 if (saveFileType != -1) {
135 ConvertSVG.SVGTo(fileName, saveFileName, saveFileType); 141 ConvertSVG.SVGTo(fileName, saveFileName, saveFileType);
136 new File(fileName).delete(); 142 new File(fileName).delete();
137 } 143 }
138 144
139 return ExportRenderer.getErrorNumber(); 145 return ExportRenderer.getErrorNumber();
140 } 146 }
141} 147}
diff --git a/scilab/modules/gui/src/java/org/scilab/modules/gui/bridge/CallScilabBridge.java b/scilab/modules/gui/src/java/org/scilab/modules/gui/bridge/CallScilabBridge.java
index de9b833..e6378fc 100644
--- a/scilab/modules/gui/src/java/org/scilab/modules/gui/bridge/CallScilabBridge.java
+++ b/scilab/modules/gui/src/java/org/scilab/modules/gui/bridge/CallScilabBridge.java
@@ -127,2646 +127,2649 @@ import org.scilab.modules.renderer.figureDrawing.DrawableFigureGL;
127 */ 127 */
128public class CallScilabBridge { 128public class CallScilabBridge {
129 129
130 private static final int NB_COLORS = 3; 130 private static final int NB_COLORS = 3;
131 131
132 private static final int POSITION_SIZE = 4; 132 private static final int POSITION_SIZE = 4;
133 133
134 private static final int X_INDEX = 0; 134 private static final int X_INDEX = 0;
135 private static final int Y_INDEX = 1; 135 private static final int Y_INDEX = 1;
136 private static final int WIDTH_INDEX = 2; 136 private static final int WIDTH_INDEX = 2;
137 private static final int HEIGHT_INDEX = 3; 137 private static final int HEIGHT_INDEX = 3;
138 138
139 private static final String NORMALFONT = "normal"; 139 private static final String NORMALFONT = "normal";
140 private static final String OBLIQUEFONT = "oblique"; 140 private static final String OBLIQUEFONT = "oblique";
141 private static final String ITALICFONT = "italic"; 141 private static final String ITALICFONT = "italic";
142 private static final String BOLDFONT = "bold"; 142 private static final String BOLDFONT = "bold";
143 private static final int DEFAULTFONTSIZE = 10; 143 private static final int DEFAULTFONTSIZE = 10;
144 private static final String DEFAULTFONTNAME = "helvetica"; 144 private static final String DEFAULTFONTNAME = "helvetica";
145 145
146 private static final double DEFAULT_RED_BACKGROUND = 0.8 * 255; 146 private static final double DEFAULT_RED_BACKGROUND = 0.8 * 255;
147 private static final double DEFAULT_GREEN_BACKGROUND = 0.8 * 255; 147 private static final double DEFAULT_GREEN_BACKGROUND = 0.8 * 255;
148 private static final double DEFAULT_BLUE_BACKGROUND = 0.8 * 255; 148 private static final double DEFAULT_BLUE_BACKGROUND = 0.8 * 255;
149 149
150 private static final double BUTTON_RED_BACKGROUND = 0.6 * 255; 150 private static final double BUTTON_RED_BACKGROUND = 0.6 * 255;
151 private static final double BUTTON_GREEN_BACKGROUND = 0.6 * 255; 151 private static final double BUTTON_GREEN_BACKGROUND = 0.6 * 255;
152 private static final double BUTTON_BLUE_BACKGROUND = 0.6 * 255; 152 private static final double BUTTON_BLUE_BACKGROUND = 0.6 * 255;
153 153
154 private static final double DEFAULT_RED_FOREGROUND = 0; 154 private static final double DEFAULT_RED_FOREGROUND = 0;
155 private static final double DEFAULT_GREEN_FOREGROUND = 0; 155 private static final double DEFAULT_GREEN_FOREGROUND = 0;
156 private static final double DEFAULT_BLUE_FOREGROUND = 0; 156 private static final double DEFAULT_BLUE_FOREGROUND = 0;
157 157
158 158
159 private static PrintRequestAttributeSet scilabPageFormat = new HashPrintRequestAttributeSet(); 159 private static PrintRequestAttributeSet scilabPageFormat = new HashPrintRequestAttributeSet();
160 private static String tmpPrinterFile = File.createTempFile("scilabfigure","").getAbsolutePath(); 160
161 161 private static final String FIGURE_TITLE = "Graphic window number ";
162 private static final String FIGURE_TITLE = "Graphic window number "; 162
163 163 private static final String SCIDIR = System.getenv("SCI");
164 private static final String SCIDIR = System.getenv("SCI"); 164
165 165 private static final String MENUBARXMLFILE = SCIDIR + "/modules/gui/etc/graphics_menubar.xml";
166 private static final String MENUBARXMLFILE = SCIDIR + "/modules/gui/etc/graphics_menubar.xml"; 166 private static final String TOOLBARXMLFILE = SCIDIR + "/modules/gui/etc/graphics_toolbar.xml";
167 private static final String TOOLBARXMLFILE = SCIDIR + "/modules/gui/etc/graphics_toolbar.xml"; 167
168 168 private static final String CONSOLE = "Console";
169 private static final String CONSOLE = "Console"; 169
170 170 /**
171 /** 171 * Constructor
172 * Constructor 172 */
173 */ 173 protected CallScilabBridge() {
174 protected CallScilabBridge() { 174 throw new UnsupportedOperationException(); /* Prevents calls from subclass */
175 throw new UnsupportedOperationException(); /* Prevents calls from subclass */ 175 }
176 } 176
177 177 /******************/
178 /******************/ 178 /* */
179 /* */ 179 /* CONSOLE BRIDGE */
180 /* CONSOLE BRIDGE */ 180 /* */
181 /* */ 181 /******************/
182 /******************/ 182
183 183 /**
184 /** 184 * Read a line from the Console
185 * Read a line from the Console 185 * @return the line read
186 * @return the line read 186 */
187 */ 187 public static String readLine() {
188 public static String readLine() { 188 return ScilabConsole.getConsole().readLine();
189 return ScilabConsole.getConsole().readLine(); 189 }
190 } 190
191 191 /**
192 /** 192 * Display a line in the Console
193 * Display a line in the Console 193 * @param dataToDisplay the line to display
194 * @param dataToDisplay the line to display 194 */
195 */ 195 public static void display(String dataToDisplay) {
196 public static void display(String dataToDisplay) { 196 ScilabConsole.getConsole().display(dataToDisplay);
197 ScilabConsole.getConsole().display(dataToDisplay); 197 }
198 } 198
199 199 /**
200 /** 200 * Get the status of the Console
201 * Get the status of the Console 201 * @return true if the console is at the prompt
202 * @return true if the console is at the prompt 202 */
203 */ 203 public static boolean isWaitingForInput() {
204 public static boolean isWaitingForInput() { 204 return ScilabConsole.getConsole().isWaitingForInput();
205 return ScilabConsole.getConsole().isWaitingForInput(); 205 }
206 } 206
207 207 /**
208 /** 208 * Update the number of lines and columns that Scilab use to format data to display
209 * Update the number of lines and columns that Scilab use to format data to display 209 */
210 */ 210 public static void scilabLinesUpdate() {
211 public static void scilabLinesUpdate() { 211 ScilabConsole.getConsole().scilabLinesUpdate();
212 ScilabConsole.getConsole().scilabLinesUpdate(); 212 }
213 } 213
214 214 /**
215 /** 215 * Clear the Console
216 * Clear the Console 216 */
217 */ 217 public static void clear() {
218 public static void clear() { 218 ScilabConsole.getConsole().clear();
219 ScilabConsole.getConsole().clear(); 219 }
220 } 220
221 221 /**
222 /** 222 * Clear some lines in the Console
223 * Clear some lines in the Console 223 * @param nbLines the number of lines to clear
224 * @param nbLines the number of lines to clear 224 */
225 */ 225 public static void clear(int nbLines) {
226 public static void clear(int nbLines) { 226 ScilabConsole.getConsole().clear(nbLines);
227 ScilabConsole.getConsole().clear(nbLines); 227 }
228 } 228
229 229 /**
230 /** 230 * Get a char to know if the user wants more data to be displayed
231 * Get a char to know if the user wants more data to be displayed 231 * @return the user answer
232 * @return the user answer 232 */
233 */ 233 public static int getCharWithoutOutput() {
234 public static int getCharWithoutOutput() { 234 return ScilabConsole.getConsole().getAsSimpleConsole().getCharWithoutOutput();
235 return ScilabConsole.getConsole().getAsSimpleConsole().getCharWithoutOutput(); 235 }
236 } 236
237 237 /**
238 /** 238 * Put the prompt on the top left corner
239 * Put the prompt on the top left corner 239 */
240 */ 240 public static void toHome() {
241 public static void toHome() { 241 ScilabConsole.getConsole().toHome();
242 ScilabConsole.getConsole().toHome(); 242 }
243 } 243
244 244 /**
245 /** 245 * Set the contents of the prompt
246 * Set the contents of the prompt 246 * @param prompt the content to set (default is -->)
247 * @param prompt the content to set (default is -->) 247 */
248 */ 248 public static void setPrompt(String prompt) {
249 public static void setPrompt(String prompt) { 249 ScilabConsole.getConsole().setPrompt(prompt);
250 ScilabConsole.getConsole().setPrompt(prompt); 250 }
251 } 251
252 252 /**
253 /** 253 * Clear the commands history
254 * Clear the commands history 254 */
255 */ 255 public static void clearHistory() {
256 public static void clearHistory() { 256 ScilabConsole.getConsole().clearHistory();
257 ScilabConsole.getConsole().clearHistory(); 257 }
258 } 258
259 259 /**************************/
260 /**************************/ 260 /* */
261 /* */ 261 /* OBJECT CREATION BRIDGE */
262 /* OBJECT CREATION BRIDGE */ 262 /* */
263 /* */ 263 /**************************/
264 /**************************/ 264
265 265 /**
266 /** 266 * Create a new Window in Scilab GUIs
267 * Create a new Window in Scilab GUIs 267 * @return the ID of the window in the UIElementMapper
268 * @return the ID of the window in the UIElementMapper 268 */
269 */ 269 public static int newWindow() {
270 public static int newWindow() { 270 Window window = ScilabWindow.createWindow();
271 Window window = ScilabWindow.createWindow(); 271 return UIElementMapper.add(window);
272 return UIElementMapper.add(window); 272 }
273 } 273
274 274 /**
275 /** 275 * Create a new Menubar in Scilab GUIs
276 * Create a new Menubar in Scilab GUIs 276 * @return the ID of the Menubar in the UIElementMapper
277 * @return the ID of the Menubar in the UIElementMapper 277 */
278 */ 278 public static int newMenuBar() {
279 public static int newMenuBar() { 279 MenuBar menuBar = ScilabMenuBar.createMenuBar();
280 MenuBar menuBar = ScilabMenuBar.createMenuBar(); 280 return UIElementMapper.add(menuBar);
281 return UIElementMapper.add(menuBar); 281 }
282 } 282
283 283 /**
284 /** 284 * Create a new Menu in Scilab GUIs
285 * Create a new Menu in Scilab GUIs 285 * @return the ID of the menu in the UIElementMapper
286 * @return the ID of the menu in the UIElementMapper 286 */
287 */ 287 public static int newMenu() {
288 public static int newMenu() { 288 MenuItem menuItem = ScilabMenuItem.createMenuItem();
289 MenuItem menuItem = ScilabMenuItem.createMenuItem(); 289 return UIElementMapper.add(menuItem);
290 return UIElementMapper.add(menuItem); 290 }
291 } 291
292 292 /**
293 /** 293 * Create a new ContextMenu in Scilab GUIs
294 * Create a new ContextMenu in Scilab GUIs 294 * @return the ID of the ContextMenu in the UIElementMapper
295 * @return the ID of the ContextMenu in the UIElementMapper 295 */
296 */ 296 public static int newContextMenu() {
297 public static int newContextMenu() { 297 ContextMenu contextMenu = ScilabContextMenu.createContextMenu();
298 ContextMenu contextMenu = ScilabContextMenu.createContextMenu(); 298 return UIElementMapper.add(contextMenu);
299 return UIElementMapper.add(contextMenu); 299 }
300 } 300
301 301 /**
302 /** 302 * Create a new Color Chooser in Scilab GUIs
303 * Create a new Color Chooser in Scilab GUIs 303 * @return the ID of the Color Chooser in the UIElementMapper
304 * @return the ID of the Color Chooser in the UIElementMapper 304 */
305 */ 305 public static int newColorChooser() {
306 public static int newColorChooser() { 306 ColorChooser colorChooser = ScilabColorChooser.createColorChooser();
307 ColorChooser colorChooser = ScilabColorChooser.createColorChooser(); 307 return UIElementMapper.add(colorChooser);
308 return UIElementMapper.add(colorChooser); 308 }
309 } 309
310 310 /**
311 /** 311 * Create a new Font Chooser in Scilab GUIs
312 * Create a new Font Chooser in Scilab GUIs 312 * @return the ID of the Font Chooser in the UIElementMapper
313 * @return the ID of the Font Chooser in the UIElementMapper 313 */
314 */ 314 public static int newFontChooser() {
315 public static int newFontChooser() { 315 FontChooser fontChooser = ScilabFontChooser.createFontChooser();
316 FontChooser fontChooser = ScilabFontChooser.createFontChooser(); 316 return UIElementMapper.add(fontChooser);
317 return UIElementMapper.add(fontChooser); 317 }
318 } 318
319 319 /**
320 /** 320 * Create a new MessageBox in Scilab GUIs
321 * Create a new MessageBox in Scilab GUIs 321 * @return the ID of the MessageBox in the UIElementMapper
322 * @return the ID of the MessageBox in the UIElementMapper 322 */
323 */ 323 public static int newMessageBox() {
324 public static int newMessageBox() { 324 MessageBox messageBox = ScilabMessageBox.createMessageBox();
325 MessageBox messageBox = ScilabMessageBox.createMessageBox(); 325 return UIElementMapper.add(messageBox);
326 return UIElementMapper.add(messageBox); 326 }
327 } 327
328 328 /**
329 /** 329 * Create a new WaitBar in Scilab GUIs
330 * Create a new WaitBar in Scilab GUIs 330 * @return the ID of the WaitBar in the UIElementMapper
331 * @return the ID of the WaitBar in the UIElementMapper 331 */
332 */ 332 public static int newWaitBar() {
333 public static int newWaitBar() { 333 WaitBar waitBar = ScilabWaitBar.createWaitBar();
334 WaitBar waitBar = ScilabWaitBar.createWaitBar(); 334 return UIElementMapper.add(waitBar);
335 return UIElementMapper.add(waitBar); 335 }
336 } 336
337 337 /**
338 /** 338 * Create a new PushButton in Scilab GUIs
339 * Create a new PushButton in Scilab GUIs 339 * @return the ID of the PushButton in the UIElementMapper
340 * @return the ID of the PushButton in the UIElementMapper 340 */
341 */ 341 public static int newPushButton() {
342 public static int newPushButton() { 342 PushButton pushButton = ScilabPushButton.createPushButton();
343 PushButton pushButton = ScilabPushButton.createPushButton(); 343 int id = UIElementMapper.add(pushButton);
344 int id = UIElementMapper.add(pushButton); 344
345 345 /* Default font */
346 /* Default font */ 346 setWidgetFontName(id, DEFAULTFONTNAME);
347 setWidgetFontName(id, DEFAULTFONTNAME); 347 setWidgetFontWeight(id, NORMALFONT);
348 setWidgetFontWeight(id, NORMALFONT); 348 setWidgetFontSize(id, DEFAULTFONTSIZE);
349 setWidgetFontSize(id, DEFAULTFONTSIZE); 349
350 350 setWidgetRelief(id, ScilabRelief.RAISED);
351 setWidgetRelief(id, ScilabRelief.RAISED); 351
352 352 /* Default colors */
353 /* Default colors */ 353 setWidgetBackgroundColor(id, (int) BUTTON_RED_BACKGROUND, (int) BUTTON_GREEN_BACKGROUND, (int) BUTTON_BLUE_BACKGROUND);
354 setWidgetBackgroundColor(id, (int) BUTTON_RED_BACKGROUND, (int) BUTTON_GREEN_BACKGROUND, (int) BUTTON_BLUE_BACKGROUND); 354 setWidgetForegroundColor(id, (int) DEFAULT_RED_FOREGROUND, (int) DEFAULT_GREEN_FOREGROUND, (int) DEFAULT_BLUE_FOREGROUND);
355 setWidgetForegroundColor(id, (int) DEFAULT_RED_FOREGROUND, (int) DEFAULT_GREEN_FOREGROUND, (int) DEFAULT_BLUE_FOREGROUND); 355 return id;
356 return id; 356 }
357 } 357
358 358 /**
359 /** 359 * Create a new EditBox in Scilab GUIs
360 * Create a new EditBox in Scilab GUIs 360 * @return the ID of the Edit in the UIElementMapper
361 * @return the ID of the Edit in the UIElementMapper 361 */
362 */ 362 public static int newEditBox() {
363 public static int newEditBox() { 363 EditBox editBox = ScilabEditBox.createEditBox();
364 EditBox editBox = ScilabEditBox.createEditBox(); 364 int id = UIElementMapper.add(editBox);
365 int id = UIElementMapper.add(editBox); 365
366 366 /* Default font */
367 /* Default font */ 367 setWidgetFontName(id, DEFAULTFONTNAME);
368 setWidgetFontName(id, DEFAULTFONTNAME); 368 setWidgetFontWeight(id, NORMALFONT);
369 setWidgetFontWeight(id, NORMALFONT); 369 setWidgetFontSize(id, DEFAULTFONTSIZE);
370 setWidgetFontSize(id, DEFAULTFONTSIZE); 370
371 371 setWidgetRelief(id, ScilabRelief.SUNKEN);
372 setWidgetRelief(id, ScilabRelief.SUNKEN); 372
373 373 /* Default colors */
374 /* Default colors */ 374 setWidgetBackgroundColor(id, (int) DEFAULT_RED_BACKGROUND, (int) DEFAULT_GREEN_BACKGROUND, (int) DEFAULT_BLUE_BACKGROUND);
375 setWidgetBackgroundColor(id, (int) DEFAULT_RED_BACKGROUND, (int) DEFAULT_GREEN_BACKGROUND, (int) DEFAULT_BLUE_BACKGROUND); 375 setWidgetForegroundColor(id, (int) DEFAULT_RED_FOREGROUND, (int) DEFAULT_GREEN_FOREGROUND, (int) DEFAULT_BLUE_FOREGROUND);
376 setWidgetForegroundColor(id, (int) DEFAULT_RED_FOREGROUND, (int) DEFAULT_GREEN_FOREGROUND, (int) DEFAULT_BLUE_FOREGROUND); 376 return id;
377 return id; 377 }
378 } 378
379 379 /**
380 /** 380 * Create a new Label in Scilab GUIs
381 * Create a new Label in Scilab GUIs 381 * @return the ID of the Label in the UIElementMapper
382 * @return the ID of the Label in the UIElementMapper 382 */
383 */ 383 public static int newLabel() {
384 public static int newLabel() { 384 Label label = ScilabLabel.createLabel();
385 Label label = ScilabLabel.createLabel(); 385 int id = UIElementMapper.add(label);
386 int id = UIElementMapper.add(label); 386
387 387 /* Default font */
388 /* Default font */ 388 setWidgetFontName(id, DEFAULTFONTNAME);
389 setWidgetFontName(id, DEFAULTFONTNAME); 389 setWidgetFontWeight(id, NORMALFONT);
390 setWidgetFontWeight(id, NORMALFONT); 390 setWidgetFontSize(id, DEFAULTFONTSIZE);
391 setWidgetFontSize(id, DEFAULTFONTSIZE); 391
392 392 setWidgetRelief(id, ScilabRelief.FLAT);
393 setWidgetRelief(id, ScilabRelief.FLAT); 393
394 394 /* Default colors */
395 /* Default colors */ 395 setWidgetBackgroundColor(id, (int) DEFAULT_RED_BACKGROUND, (int) DEFAULT_GREEN_BACKGROUND, (int) DEFAULT_BLUE_BACKGROUND);
396 setWidgetBackgroundColor(id, (int) DEFAULT_RED_BACKGROUND, (int) DEFAULT_GREEN_BACKGROUND, (int) DEFAULT_BLUE_BACKGROUND); 396 setWidgetForegroundColor(id, (int) DEFAULT_RED_FOREGROUND, (int) DEFAULT_GREEN_FOREGROUND, (int) DEFAULT_BLUE_FOREGROUND);
397 setWidgetForegroundColor(id, (int) DEFAULT_RED_FOREGROUND, (int) DEFAULT_GREEN_FOREGROUND, (int) DEFAULT_BLUE_FOREGROUND); 397 return id;
398 return id; 398 }
399 } 399
400 400 /**
401 /** 401 * Create a new CheckBox in Scilab GUIs
402 * Create a new CheckBox in Scilab GUIs 402 * @return the ID of the CheckBox in the UIElementMapper
403 * @return the ID of the CheckBox in the UIElementMapper 403 */
404 */ 404 public static int newCheckBox() {
405 public static int newCheckBox() { 405 CheckBox checkBox = ScilabCheckBox.createCheckBox();
406 CheckBox checkBox = ScilabCheckBox.createCheckBox(); 406 int id = UIElementMapper.add(checkBox);
407 int id = UIElementMapper.add(checkBox); 407
408 408 /* Default font */
409 /* Default font */ 409 setWidgetFontName(id, DEFAULTFONTNAME);
410 setWidgetFontName(id, DEFAULTFONTNAME); 410 setWidgetFontWeight(id, NORMALFONT);
411 setWidgetFontWeight(id, NORMALFONT); 411 setWidgetFontSize(id, DEFAULTFONTSIZE);
412 setWidgetFontSize(id, DEFAULTFONTSIZE); 412
413 413 setWidgetRelief(id, ScilabRelief.FLAT);
414 setWidgetRelief(id, ScilabRelief.FLAT); 414
415 415 /* Default colors */
416 /* Default colors */ 416 setWidgetBackgroundColor(id, (int) DEFAULT_RED_BACKGROUND, (int) DEFAULT_GREEN_BACKGROUND, (int) DEFAULT_BLUE_BACKGROUND);
417 setWidgetBackgroundColor(id, (int) DEFAULT_RED_BACKGROUND, (int) DEFAULT_GREEN_BACKGROUND, (int) DEFAULT_BLUE_BACKGROUND); 417 setWidgetForegroundColor(id, (int) DEFAULT_RED_FOREGROUND, (int) DEFAULT_GREEN_FOREGROUND, (int) DEFAULT_BLUE_FOREGROUND);
418 setWidgetForegroundColor(id, (int) DEFAULT_RED_FOREGROUND, (int) DEFAULT_GREEN_FOREGROUND, (int) DEFAULT_BLUE_FOREGROUND); 418 return id;
419 return id; 419 }
420 } 420
421 421 /**
422 /** 422 * Create a new RadioButton in Scilab GUIs
423 * Create a new RadioButton in Scilab GUIs 423 * @return the ID of the RadioButton in the UIElementMapper
424 * @return the ID of the RadioButton in the UIElementMapper 424 */
425 */ 425 public static int newRadioButton() {
426 public static int newRadioButton() { 426 RadioButton radioButton = ScilabRadioButton.createRadioButton();
427 RadioButton radioButton = ScilabRadioButton.createRadioButton(); 427 int id = UIElementMapper.add(radioButton);
428 int id = UIElementMapper.add(radioButton); 428
429 429 /* Default font */
430 /* Default font */ 430 setWidgetFontName(id, DEFAULTFONTNAME);
431 setWidgetFontName(id, DEFAULTFONTNAME); 431 setWidgetFontWeight(id, NORMALFONT);
432 setWidgetFontWeight(id, NORMALFONT); 432 setWidgetFontSize(id, DEFAULTFONTSIZE);
433 setWidgetFontSize(id, DEFAULTFONTSIZE); 433
434 434 setWidgetRelief(id, ScilabRelief.FLAT);
435 setWidgetRelief(id, ScilabRelief.FLAT); 435
436 436 /* Default colors */
437 /* Default colors */ 437 setWidgetBackgroundColor(id, (int) DEFAULT_RED_BACKGROUND, (int) DEFAULT_GREEN_BACKGROUND, (int) DEFAULT_BLUE_BACKGROUND);
438 setWidgetBackgroundColor(id, (int) DEFAULT_RED_BACKGROUND, (int) DEFAULT_GREEN_BACKGROUND, (int) DEFAULT_BLUE_BACKGROUND); 438 setWidgetForegroundColor(id, (int) DEFAULT_RED_FOREGROUND, (int) DEFAULT_GREEN_FOREGROUND, (int) DEFAULT_BLUE_FOREGROUND);
439 setWidgetForegroundColor(id, (int) DEFAULT_RED_FOREGROUND, (int) DEFAULT_GREEN_FOREGROUND, (int) DEFAULT_BLUE_FOREGROUND); 439 return id;
440 return id; 440 }
441 } 441
442 442 /**
443 /** 443 * Create a new Slider in Scilab GUIs
444 * Create a new Slider in Scilab GUIs 444 * @return the ID of the Slider in the UIElementMapper
445 * @return the ID of the Slider in the UIElementMapper 445 */
446 */ 446 public static int newSlider() {
447 public static int newSlider() { 447 Slider slider = ScilabSlider.createSlider();
448 Slider slider = ScilabSlider.createSlider(); 448 int id = UIElementMapper.add(slider);
449 int id = UIElementMapper.add(slider); 449
450 450 /* Default font */
451 /* Default font */ 451 /* Set a default font because is null when JScrollBar is created */
452 /* Set a default font because is null when JScrollBar is created */ 452 slider.setFont(new Font(DEFAULTFONTNAME, Font.PLAIN, DEFAULTFONTSIZE));
453 slider.setFont(new Font(DEFAULTFONTNAME, Font.PLAIN, DEFAULTFONTSIZE)); 453 setWidgetFontName(id, DEFAULTFONTNAME);
454 setWidgetFontName(id, DEFAULTFONTNAME); 454 setWidgetFontWeight(id, NORMALFONT);
455 setWidgetFontWeight(id, NORMALFONT); 455 setWidgetFontSize(id, DEFAULTFONTSIZE);
456 setWidgetFontSize(id, DEFAULTFONTSIZE); 456
457 457 setWidgetRelief(id, ScilabRelief.FLAT);
458 setWidgetRelief(id, ScilabRelief.FLAT); 458
459 459 /* Default colors */
460 /* Default colors */ 460 setWidgetBackgroundColor(id, (int) DEFAULT_RED_BACKGROUND, (int) DEFAULT_GREEN_BACKGROUND, (int) DEFAULT_BLUE_BACKGROUND);
461 setWidgetBackgroundColor(id, (int) DEFAULT_RED_BACKGROUND, (int) DEFAULT_GREEN_BACKGROUND, (int) DEFAULT_BLUE_BACKGROUND); 461 setWidgetForegroundColor(id, (int) DEFAULT_RED_FOREGROUND, (int) DEFAULT_GREEN_FOREGROUND, (int) DEFAULT_BLUE_FOREGROUND);
462 setWidgetForegroundColor(id, (int) DEFAULT_RED_FOREGROUND, (int) DEFAULT_GREEN_FOREGROUND, (int) DEFAULT_BLUE_FOREGROUND); 462
463 463 slider.setText(""); /* Because Name property is null at creation */
464 slider.setText(""); /* Because Name property is null at creation */ 464 slider.setMinimumValue(0);
465 slider.setMinimumValue(0); 465 slider.setMaximumValue(1);
466 slider.setMaximumValue(1); 466 slider.setUserValue(0);
467 slider.setUserValue(0); 467
468 468 return id;
469 return id; 469 }
470 } 470
471 471 /**
472 /** 472 * Create a new ListBox in Scilab GUIs
473 * Create a new ListBox in Scilab GUIs 473 * @return the ID of the ListBox in the UIElementMapper
474 * @return the ID of the ListBox in the UIElementMapper 474 */
475 */ 475 public static int newListBox() {
476 public static int newListBox() { 476 ListBox listBox = ScilabListBox.createListBox();
477 ListBox listBox = ScilabListBox.createListBox(); 477 int id = UIElementMapper.add(listBox);
478 int id = UIElementMapper.add(listBox); 478
479 479 /* Default font */
480 /* Default font */ 480 setWidgetFontName(id, DEFAULTFONTNAME);
481 setWidgetFontName(id, DEFAULTFONTNAME); 481 setWidgetFontWeight(id, NORMALFONT);
482 setWidgetFontWeight(id, NORMALFONT); 482 setWidgetFontSize(id, DEFAULTFONTSIZE);
483 setWidgetFontSize(id, DEFAULTFONTSIZE); 483
484 484 setWidgetRelief(id, ScilabRelief.FLAT);
485 setWidgetRelief(id, ScilabRelief.FLAT); 485
486 486 /* Default colors */
487 /* Default colors */ 487 setWidgetBackgroundColor(id, (int) DEFAULT_RED_BACKGROUND, (int) DEFAULT_GREEN_BACKGROUND, (int) DEFAULT_BLUE_BACKGROUND);
488 setWidgetBackgroundColor(id, (int) DEFAULT_RED_BACKGROUND, (int) DEFAULT_GREEN_BACKGROUND, (int) DEFAULT_BLUE_BACKGROUND); 488 setWidgetForegroundColor(id, (int) DEFAULT_RED_FOREGROUND, (int) DEFAULT_GREEN_FOREGROUND, (int) DEFAULT_BLUE_FOREGROUND);
489 setWidgetForegroundColor(id, (int) DEFAULT_RED_FOREGROUND, (int) DEFAULT_GREEN_FOREGROUND, (int) DEFAULT_BLUE_FOREGROUND); 489 return id;
490 return id; 490 }
491 } 491
492 492 /**
493 /** 493 * Create a new PopupMenu in Scilab GUIs
494 * Create a new PopupMenu in Scilab GUIs 494 * @return the ID of the PopupMenu in the UIElementMapper
495 * @return the ID of the PopupMenu in the UIElementMapper 495 */
496 */ 496 public static int newPopupMenu() {
497 public static int newPopupMenu() { 497 PopupMenu popupMenu = ScilabPopupMenu.createPopupMenu();
498 PopupMenu popupMenu = ScilabPopupMenu.createPopupMenu(); 498 int id = UIElementMapper.add(popupMenu);
499 int id = UIElementMapper.add(popupMenu); 499
500 500 /* Default font */
501 /* Default font */ 501 setWidgetFontName(id, DEFAULTFONTNAME);
502 setWidgetFontName(id, DEFAULTFONTNAME); 502 setWidgetFontWeight(id, NORMALFONT);
503 setWidgetFontWeight(id, NORMALFONT); 503 setWidgetFontSize(id, DEFAULTFONTSIZE);
504 setWidgetFontSize(id, DEFAULTFONTSIZE); 504
505 505 setWidgetRelief(id, ScilabRelief.FLAT);
506 setWidgetRelief(id, ScilabRelief.FLAT); 506
507 507 /* Default colors */
508 /* Default colors */ 508 setWidgetBackgroundColor(id, (int) DEFAULT_RED_BACKGROUND, (int) DEFAULT_GREEN_BACKGROUND, (int) DEFAULT_BLUE_BACKGROUND);
509 setWidgetBackgroundColor(id, (int) DEFAULT_RED_BACKGROUND, (int) DEFAULT_GREEN_BACKGROUND, (int) DEFAULT_BLUE_BACKGROUND); 509 setWidgetForegroundColor(id, (int) DEFAULT_RED_FOREGROUND, (int) DEFAULT_GREEN_FOREGROUND, (int) DEFAULT_BLUE_FOREGROUND);
510 setWidgetForegroundColor(id, (int) DEFAULT_RED_FOREGROUND, (int) DEFAULT_GREEN_FOREGROUND, (int) DEFAULT_BLUE_FOREGROUND); 510 return id;
511 return id; 511 }
512 } 512
513 513 /**
514 /** 514 * Create a new Frame in Scilab GUIs
515 * Create a new Frame in Scilab GUIs 515 * @return the ID of the Frame in the UIElementMapper
516 * @return the ID of the Frame in the UIElementMapper 516 */
517 */ 517 public static int newFrame() {
518 public static int newFrame() { 518 Frame frame = ScilabFrame.createFrame();
519 Frame frame = ScilabFrame.createFrame(); 519 int id = UIElementMapper.add(frame);
520 int id = UIElementMapper.add(frame); 520
521 521 /* Default font */
522 /* Default font */ 522 setFrameFontName(id, DEFAULTFONTNAME);
523 setFrameFontName(id, DEFAULTFONTNAME); 523 setFrameFontWeight(id, NORMALFONT);
524 setFrameFontWeight(id, NORMALFONT); 524 setFrameFontSize(id, DEFAULTFONTSIZE);
525 setFrameFontSize(id, DEFAULTFONTSIZE); 525
526 526 setFrameRelief(id, ScilabRelief.RIDGE);
527 setFrameRelief(id, ScilabRelief.RIDGE); 527
528 528 /* Default colors */
529 /* Default colors */ 529 setFrameBackgroundColor(id, (int) DEFAULT_RED_BACKGROUND, (int) DEFAULT_GREEN_BACKGROUND, (int) DEFAULT_BLUE_BACKGROUND);
530 setFrameBackgroundColor(id, (int) DEFAULT_RED_BACKGROUND, (int) DEFAULT_GREEN_BACKGROUND, (int) DEFAULT_BLUE_BACKGROUND); 530 setFrameForegroundColor(id, (int) DEFAULT_RED_FOREGROUND, (int) DEFAULT_GREEN_FOREGROUND, (int) DEFAULT_BLUE_FOREGROUND);
531 setFrameForegroundColor(id, (int) DEFAULT_RED_FOREGROUND, (int) DEFAULT_GREEN_FOREGROUND, (int) DEFAULT_BLUE_FOREGROUND); 531
532 532 frame.setText(""); /* Because Name property is null at creation */
533 frame.setText(""); /* Because Name property is null at creation */ 533 return id;
534 return id; 534 }
535 } 535
536 536 /**
537 /** 537 * Create a new ContextMenu in Scilab GUIs
538 * Create a new ContextMenu in Scilab GUIs 538 * and wait for a user answer
539 * and wait for a user answer 539 * @param id the id of the Context Menu
540 * @param id the id of the Context Menu 540 * @return the item of the menu selected
541 * @return the item of the menu selected 541 */
542 */ 542 public static String displayAndWaitContextMenu(int id) {
543 public static String displayAndWaitContextMenu(int id) { 543 return ((ContextMenu) UIElementMapper.getCorrespondingUIElement(id)).getAsSimpleContextMenu().displayAndWait();
544 return ((ContextMenu) UIElementMapper.getCorrespondingUIElement(id)).getAsSimpleContextMenu().displayAndWait(); 544 }
545 } 545
546 546 /**
547 /** 547 * Destroy a Widget
548 * Destroy a Widget 548 * @param id the id of the Widget to destroy
549 * @param id the id of the Widget to destroy 549 */
550 */ 550 public static void destroyWidget(int id) {
551 public static void destroyWidget(int id) { 551 ((Widget) UIElementMapper.getCorrespondingUIElement(id)).destroy();
552 ((Widget) UIElementMapper.getCorrespondingUIElement(id)).destroy(); 552 UIElementMapper.removeMapping(id);
553 UIElementMapper.removeMapping(id); 553 }
554 } 554
555 555 /**
556 /** 556 * Destroy a Frame
557 * Destroy a Frame 557 * @param id the id of the Frame to destroy
558 * @param id the id of the Frame to destroy 558 */
559 */ 559 public static void destroyFrame(int id) {
560 public static void destroyFrame(int id) { 560 ((Frame) UIElementMapper.getCorrespondingUIElement(id)).destroy();
561 ((Frame) UIElementMapper.getCorrespondingUIElement(id)).destroy(); 561 UIElementMapper.removeMapping(id);
562 UIElementMapper.removeMapping(id); 562 }
563 } 563
564 564 /**
565 /** 565 * Create a new window with id figureIndex.
566 * Create a new window with id figureIndex. 566 * The created window contains an empty tab.
567 * The created window contains an empty tab. 567 * @param figureIndex index of the figure to create
568 * @param figureIndex index of the figure to create 568 * @return id of the window
569 * @return id of the window 569 */
570 */ 570 public static int newWindow(int figureIndex) {
571 public static int newWindow(int figureIndex) { 571 Window newWindow = ScilabWindow.createWindow();
572 Window newWindow = ScilabWindow.createWindow(); 572
573 573 newWindow.setTitle(FIGURE_TITLE + figureIndex);
574 newWindow.setTitle(FIGURE_TITLE + figureIndex); 574 /* MENUBAR */
575 /* MENUBAR */ 575 MenuBar menuBar = MenuBarBuilder.buildMenuBar(MENUBARXMLFILE, figureIndex);
576 MenuBar menuBar = MenuBarBuilder.buildMenuBar(MENUBARXMLFILE, figureIndex); 576 /* TOOLBAR */
577 /* TOOLBAR */ 577 ToolBar toolBar = ToolBarBuilder.buildToolBar(TOOLBARXMLFILE, figureIndex);
578 ToolBar toolBar = ToolBarBuilder.buildToolBar(TOOLBARXMLFILE, figureIndex); 578
579 579 TextBox infoBar = ScilabTextBox.createTextBox();
580 TextBox infoBar = ScilabTextBox.createTextBox(); 580
581 581 // create a tab able to display a figure handle
582 // create a tab able to display a figure handle 582 Tab graphicTab = ScilabTab.createTab(FIGURE_TITLE + figureIndex, figureIndex);
583 Tab graphicTab = ScilabTab.createTab(FIGURE_TITLE + figureIndex, figureIndex); 583 /* Destroy the graphic figure when the tab is closed */
584 /* Destroy the graphic figure when the tab is closed */ 584 // // check if figure is already closed
585 // // check if figure is already closed 585 // if (get_figure_handle(fid) <> []) then
586 // if (get_figure_handle(fid) <> []) then 586 // if (get(get_figure_handle(fid), 'event_handler_enable') == 'on') then
587 // if (get(get_figure_handle(fid), 'event_handler_enable') == 'on') then 587 // // execute closing call back
588 // // execute closing call back 588 // execstr(get(get_figure_handle(fid), 'event_handler') + '(fid, -1, -1, -1000)', 'errcatch', 'm');
589 // execstr(get(get_figure_handle(fid), 'event_handler') + '(fid, -1, -1, -1000)', 'errcatch', 'm'); 589 // end
590 // end 590 // // destroy the figure
591 // // destroy the figure 591 // delete(get_figure_handle(fid));
592 // delete(get_figure_handle(fid)); 592 // end
593 // end 593 String closingCommand =
594 String closingCommand = 594 "if (get_figure_handle(" + figureIndex + ") <> []) then"
595 "if (get_figure_handle(" + figureIndex + ") <> []) then" 595 + " if (get(get_figure_handle(" + figureIndex + "), 'event_handler_enable') == 'on') then"
596 + " if (get(get_figure_handle(" + figureIndex + "), 'event_handler_enable') == 'on') then" 596 + " execstr(get(get_figure_handle(" + figureIndex + "), 'event_handler')+'(" + figureIndex + ", -1, -1, -1000)', 'errcatch', 'm');"
597 + " execstr(get(get_figure_handle(" + figureIndex + "), 'event_handler')+'(" + figureIndex + ", -1, -1, -1000)', 'errcatch', 'm');" 597 + " end;"
598 + " end;" 598 + " delete(get_figure_handle(" + figureIndex + "));"
599 + " delete(get_figure_handle(" + figureIndex + "));" 599 + "end;";
600 + "end;"; 600 graphicTab.setCallback(ScilabCloseCallBack.create(figureIndex, closingCommand));
601 graphicTab.setCallback(ScilabCloseCallBack.create(figureIndex, closingCommand)); 601 graphicTab.addMenuBar(menuBar);
602 graphicTab.addMenuBar(menuBar); 602 graphicTab.addToolBar(toolBar);
603 graphicTab.addToolBar(toolBar); 603 graphicTab.addInfoBar(infoBar);
604 graphicTab.addInfoBar(infoBar); 604 newWindow.addTab(graphicTab);
605 newWindow.addTab(graphicTab); 605
606 606 // link the tab and canvas with their figure
607 // link the tab and canvas with their figure 607 DrawableFigureGL associatedFigure = FigureMapper.getCorrespondingFigure(figureIndex);
608 DrawableFigureGL associatedFigure = FigureMapper.getCorrespondingFigure(figureIndex); 608 //associatedFigure.setRendererProperties(new ScilabRendererProperties(graphicTab, graphicCanvas));
609 //associatedFigure.setRendererProperties(new ScilabRendererProperties(graphicTab, graphicCanvas)); 609 associatedFigure.setRendererProperties(new ScilabRendererProperties(graphicTab, null, figureIndex));
610 associatedFigure.setRendererProperties(new ScilabRendererProperties(graphicTab, null, figureIndex)); 610 // don't draw now, figure will show itself when all its parameters will be set
611 // don't draw now, figure will show itself when all its parameters will be set 611
612 612 return 0;
613 return 0; 613 }
614 } 614
615 615 /****************************/
616 /****************************/ 616 /* */
617 /* */ 617 /* OBJECT DIMENSIONS BRIDGE */
618 /* OBJECT DIMENSIONS BRIDGE */ 618 /* */
619 /* */ 619 /****************************/
620 /****************************/ 620
621 621 /**
622 /** 622 * Set the dimensions of an object in Scilab GUIs
623 * Set the dimensions of an object in Scilab GUIs 623 * @param objID the ID of the object in the UIElementMapper
624 * @param objID the ID of the object in the UIElementMapper 624 * @param width the width of the object
625 * @param width the width of the object 625 * @param height the height of the object
626 * @param height the height of the object 626 */
627 */ 627 public static void setDims(int objID, int width, int height) {
628 public static void setDims(int objID, int width, int height) { 628 UIElementMapper.getCorrespondingUIElement(objID).setDims(new Size(width, height));
629 UIElementMapper.getCorrespondingUIElement(objID).setDims(new Size(width, height)); 629 }
630 } 630
631 631 /**********************/
632 /**********************/ 632 /* */
633 /* */ 633 /* OBJECT TEXT BRIDGE */
634 /* OBJECT TEXT BRIDGE */ 634 /* */
635 /* */ 635 /**********************/
636 /**********************/ 636
637 637 /**
638 /** 638 * Set the text of a widget in Scilab GUIs
639 * Set the text of a widget in Scilab GUIs 639 * @param objID the ID of the Widget in the UIElementMapper
640 * @param objID the ID of the Widget in the UIElementMapper 640 * @param text the text to set to the widget
641 * @param text the text to set to the widget 641 */
642 */ 642 public static void setWidgetText(int objID, String text) {
643 public static void setWidgetText(int objID, String text) { 643 ((Widget) UIElementMapper.getCorrespondingUIElement(objID)).setText(text);
644 ((Widget) UIElementMapper.getCorrespondingUIElement(objID)).setText(text); 644 }
645 } 645
646 646 /**
647 /** 647 * Get the text of a widget in Scilab GUIs
648 * Get the text of a widget in Scilab GUIs 648 * @param objID the ID of the Widget in the UIElementMapper
649 * @param objID the ID of the Widget in the UIElementMapper 649 * @return the text of the widget
650 * @return the text of the widget 650 */
651 */ 651 public static String getWidgetText(int objID) {
652 public static String getWidgetText(int objID) { 652 return ((Widget) UIElementMapper.getCorrespondingUIElement(objID)).getText();
653 return ((Widget) UIElementMapper.getCorrespondingUIElement(objID)).getText(); 653 }
654 } 654
655 655 /**
656 /** 656 * Set the text of a Frame in Scilab GUIs
657 * Set the text of a Frame in Scilab GUIs 657 * @param objID the ID of the Widget in the UIElementMapper
658 * @param objID the ID of the Widget in the UIElementMapper 658 * @param text the text to set to the Frame
659 * @param text the text to set to the Frame 659 */
660 */ 660 public static void setFrameText(int objID, String text) {
661 public static void setFrameText(int objID, String text) { 661 ((Frame) UIElementMapper.getCorrespondingUIElement(objID)).setText(text);
662 ((Frame) UIElementMapper.getCorrespondingUIElement(objID)).setText(text); 662 }
663 } 663
664 664 /**
665 /** 665 * Get the text of a Frame in Scilab GUIs
666 * Get the text of a Frame in Scilab GUIs 666 * @param objID the ID of the Frame in the UIElementMapper
667 * @param objID the ID of the Frame in the UIElementMapper 667 * @return the text of the Frame
668 * @return the text of the Frame 668 */
669 */ 669 public static String getFrameText(int objID) {
670 public static String getFrameText(int objID) { 670 return ((Frame) UIElementMapper.getCorrespondingUIElement(objID)).getText();
671 return ((Frame) UIElementMapper.getCorrespondingUIElement(objID)).getText(); 671 }
672 } 672
673 673 /******************/
674 /******************/ 674 /* */
675 /* */ 675 /* PARENT SETTING */
676 /* PARENT SETTING */ 676 /* */
677 /* */ 677 /******************/
678 /******************/ 678
679 679 /**
680 /** 680 * Set a figure as parent for an UIElement
681 * Set a figure as parent for an UIElement 681 * @param figureID the ID of the figure in the FigureMapper
682 * @param figureID the ID of the figure in the FigureMapper 682 * @param objID the ID of the object in the UIElementMapper
683 * @param objID the ID of the object in the UIElementMapper 683 */
684 */ 684 public static void setFigureAsParent(int figureID, int objID) {
685 public static void setFigureAsParent(int figureID, int objID) { 685 Tab parentTab = ((ScilabRendererProperties) FigureMapper.getCorrespondingFigure(figureID).getRendererProperties()).getParentTab();
686 Tab parentTab = ((ScilabRendererProperties) FigureMapper.getCorrespondingFigure(figureID).getRendererProperties()).getParentTab(); 686
687 687 if (!(UIElementMapper.getCorrespondingUIElement(objID) instanceof MenuItem)) {
688 if (!(UIElementMapper.getCorrespondingUIElement(objID) instanceof MenuItem)) { 688 // Add the menu to the tab
689 // Add the menu to the tab 689 parentTab.getMenuBar().add((Menu) UIElementMapper.getCorrespondingUIElement(objID));
690 parentTab.getMenuBar().add((Menu) UIElementMapper.getCorrespondingUIElement(objID)); 690 } else {
691 } else { 691 // obj is a MenuItem that has to be converted to a Menu
692 // obj is a MenuItem that has to be converted to a Menu 692 MenuItem menuItem = (MenuItem) UIElementMapper.getCorrespondingUIElement(objID);
693 MenuItem menuItem = (MenuItem) UIElementMapper.getCorrespondingUIElement(objID); 693
694 694 Menu menuToAdd = ScilabMenu.createMenu();
695 Menu menuToAdd = ScilabMenu.createMenu(); 695 UIElementMapper.removeMapping(objID);
696 UIElementMapper.removeMapping(objID); 696 UIElementMapper.addMapping(objID, menuToAdd);
697 UIElementMapper.addMapping(objID, menuToAdd); 697
698 698 // Copy all properties from MenuItem to Menu
699 // Copy all properties from MenuItem to Menu 699 menuToAdd.setText(menuItem.getText());
700 menuToAdd.setText(menuItem.getText()); 700 menuToAdd.setCallback(menuItem.getCallback());
701 menuToAdd.setCallback(menuItem.getCallback()); 701 menuToAdd.setForeground(menuItem.getForeground());
702 menuToAdd.setForeground(menuItem.getForeground()); 702 menuToAdd.setVisible(menuItem.isVisible());
703 menuToAdd.setVisible(menuItem.isVisible()); 703 menuToAdd.setEnabled(menuItem.isEnabled());
704 menuToAdd.setEnabled(menuItem.isEnabled()); 704 menuToAdd.setChecked(menuItem.isChecked());
705 menuToAdd.setChecked(menuItem.isChecked()); 705 // End of properties copy
706 // End of properties copy 706
707 707 // Add the menu to the tab
708 // Add the menu to the tab 708 parentTab.getMenuBar().add(menuToAdd);
709 parentTab.getMenuBar().add(menuToAdd); 709 }
710 } 710 }
711 } 711
712 712 /**
713 /** 713 * Set a figure as parent for a PushButton
714 * Set a figure as parent for a PushButton 714 * @param figureID the ID of the figure in the FigureMapper
715 * @param figureID the ID of the figure in the FigureMapper 715 * @param objID the ID of the PushButton in the UIElementMapper
716 * @param objID the ID of the PushButton in the UIElementMapper 716 */
717 */ 717 public static void setPushButtonParent(int figureID, int objID) {
718 public static void setPushButtonParent(int figureID, int objID) { 718 Tab parentTab = ((ScilabRendererProperties) FigureMapper.getCorrespondingFigure(figureID).getRendererProperties()).getParentTab();
719 Tab parentTab = ((ScilabRendererProperties) FigureMapper.getCorrespondingFigure(figureID).getRendererProperties()).getParentTab(); 719 PushButton pushButton = (PushButton) UIElementMapper.getCorrespondingUIElement(objID);
720 PushButton pushButton = (PushButton) UIElementMapper.getCorrespondingUIElement(objID); 720 ScilabBridge.addMember(parentTab, pushButton);
721 ScilabBridge.addMember(parentTab, pushButton); 721 }
722 } 722
723 723 /**
724 /** 724 * Remove a PushButton from its parent figure
725 * Remove a PushButton from its parent figure 725 * @param figureID the ID of the figure in the FigureMapper
726 * @param figureID the ID of the figure in the FigureMapper 726 * @param objID the ID of the PushButton in the UIElementMapper
727 * @param objID the ID of the PushButton in the UIElementMapper 727 */
728 */ 728 public static void removePushButtonFromParent(int figureID, int objID) {
729 public static void removePushButtonFromParent(int figureID, int objID) { 729 Tab parentTab = ((ScilabRendererProperties) FigureMapper.getCorrespondingFigure(figureID).getRendererProperties()).getParentTab();
730 Tab parentTab = ((ScilabRendererProperties) FigureMapper.getCorrespondingFigure(figureID).getRendererProperties()).getParentTab(); 730 PushButton pushButton = (PushButton) UIElementMapper.getCorrespondingUIElement(objID);
731 PushButton pushButton = (PushButton) UIElementMapper.getCorrespondingUIElement(objID); 731 ScilabBridge.removeMember(parentTab, pushButton);
732 ScilabBridge.removeMember(parentTab, pushButton); 732 }
733 } 733
734 734 /**
735 /** 735 * Set a figure as parent for a EditBox
736 * Set a figure as parent for a EditBox 736 * @param figureID the ID of the figure in the FigureMapper
737 * @param figureID the ID of the figure in the FigureMapper 737 * @param objID the ID of the PushButton in the UIElementMapper
738 * @param objID the ID of the PushButton in the UIElementMapper 738 */
739 */ 739 public static void setEditBoxParent(int figureID, int objID) {
740 public static void setEditBoxParent(int figureID, int objID) { 740 Tab parentTab = ((ScilabRendererProperties) FigureMapper.getCorrespondingFigure(figureID).getRendererProperties()).getParentTab();
741 Tab parentTab = ((ScilabRendererProperties) FigureMapper.getCorrespondingFigure(figureID).getRendererProperties()).getParentTab(); 741 EditBox editBox = (EditBox) UIElementMapper.getCorrespondingUIElement(objID);
742 EditBox editBox = (EditBox) UIElementMapper.getCorrespondingUIElement(objID); 742 ScilabBridge.addMember(parentTab, editBox);
743 ScilabBridge.addMember(parentTab, editBox); 743 }
744 } 744
745 745 /**
746 /** 746 * Remove an EditBox from its parent figure
747 * Remove an EditBox from its parent figure 747 * @param figureID the ID of the figure in the FigureMapper
748 * @param figureID the ID of the figure in the FigureMapper 748 * @param objID the ID of the PushButton in the UIElementMapper
749 * @param objID the ID of the PushButton in the UIElementMapper 749 */
750 */ 750 public static void removeEditBoxFromParent(int figureID, int objID) {
751 public static void removeEditBoxFromParent(int figureID, int objID) { 751 Tab parentTab = ((ScilabRendererProperties) FigureMapper.getCorrespondingFigure(figureID).getRendererProperties()).getParentTab();
752 Tab parentTab = ((ScilabRendererProperties) FigureMapper.getCorrespondingFigure(figureID).getRendererProperties()).getParentTab(); 752 EditBox editBox = (EditBox) UIElementMapper.getCorrespondingUIElement(objID);
753 EditBox editBox = (EditBox) UIElementMapper.getCorrespondingUIElement(objID); 753 ScilabBridge.removeMember(parentTab, editBox);
754 ScilabBridge.removeMember(parentTab, editBox); 754 }
755 } 755
756 756 /**
757 /** 757 * Set a figure as parent for a Label
758 * Set a figure as parent for a Label 758 * @param figureID the ID of the figure in the FigureMapper
759 * @param figureID the ID of the figure in the FigureMapper 759 * @param objID the ID of the PushButton in the UIElementMapper
760 * @param objID the ID of the PushButton in the UIElementMapper 760 */
761 */ 761 public static void setLabelParent(int figureID, int objID) {
762 public static void setLabelParent(int figureID, int objID) { 762 Tab parentTab = ((ScilabRendererProperties) FigureMapper.getCorrespondingFigure(figureID).getRendererProperties()).getParentTab();
763 Tab parentTab = ((ScilabRendererProperties) FigureMapper.getCorrespondingFigure(figureID).getRendererProperties()).getParentTab(); 763 Label label = (Label) UIElementMapper.getCorrespondingUIElement(objID);
764 Label label = (Label) UIElementMapper.getCorrespondingUIElement(objID); 764 ScilabBridge.addMember(parentTab, label);
765 ScilabBridge.addMember(parentTab, label); 765 }
766 } 766
767 767 /**
768 /** 768 * Remove a Label from its parent figure
769 * Remove a Label from its parent figure 769 * @param figureID the ID of the figure in the FigureMapper
770 * @param figureID the ID of the figure in the FigureMapper 770 * @param objID the ID of the PushButton in the UIElementMapper
771 * @param objID the ID of the PushButton in the UIElementMapper 771 */
772 */ 772 public static void removeLabelFromParent(int figureID, int objID) {
773 public static void removeLabelFromParent(int figureID, int objID) { 773 Tab parentTab = ((ScilabRendererProperties) FigureMapper.getCorrespondingFigure(figureID).getRendererProperties()).getParentTab();
774 Tab parentTab = ((ScilabRendererProperties) FigureMapper.getCorrespondingFigure(figureID).getRendererProperties()).getParentTab(); 774 Label label = (Label) UIElementMapper.getCorrespondingUIElement(objID);
775 Label label = (Label) UIElementMapper.getCorrespondingUIElement(objID); 775 ScilabBridge.removeMember(parentTab, label);
776 ScilabBridge.removeMember(parentTab, label); 776 }
777 } 777
778 778 /**
779 /** 779 * Set a figure as parent for a CheckBox
780 * Set a figure as parent for a CheckBox 780 * @param figureID the ID of the figure in the FigureMapper
781 * @param figureID the ID of the figure in the FigureMapper 781 * @param objID the ID of the PushButton in the UIElementMapper
782 * @param objID the ID of the PushButton in the UIElementMapper 782 */
783 */ 783 public static void setCheckBoxParent(int figureID, int objID) {
784 public static void setCheckBoxParent(int figureID, int objID) { 784 Tab parentTab = ((ScilabRendererProperties) FigureMapper.getCorrespondingFigure(figureID).getRendererProperties()).getParentTab();
785 Tab parentTab = ((ScilabRendererProperties) FigureMapper.getCorrespondingFigure(figureID).getRendererProperties()).getParentTab(); 785 CheckBox checkBox = (CheckBox) UIElementMapper.getCorrespondingUIElement(objID);
786 CheckBox checkBox = (CheckBox) UIElementMapper.getCorrespondingUIElement(objID); 786 ScilabBridge.addMember(parentTab, checkBox);
787 ScilabBridge.addMember(parentTab, checkBox); 787 }
788 } 788
789 789 /**
790 /** 790 * Remove a CheckBox from its parent figure
791 * Remove a CheckBox from its parent figure 791 * @param figureID the ID of the figure in the FigureMapper
792 * @param figureID the ID of the figure in the FigureMapper 792 * @param objID the ID of the PushButton in the UIElementMapper
793 * @param objID the ID of the PushButton in the UIElementMapper 793 */
794 */ 794 public static void removeCheckBoxFromParent(int figureID, int objID) {
795 public static void removeCheckBoxFromParent(int figureID, int objID) { 795 Tab parentTab = ((ScilabRendererProperties) FigureMapper.getCorrespondingFigure(figureID).getRendererProperties()).getParentTab();
796 Tab parentTab = ((ScilabRendererProperties) FigureMapper.getCorrespondingFigure(figureID).getRendererProperties()).getParentTab(); 796 CheckBox checkBox = (CheckBox) UIElementMapper.getCorrespondingUIElement(objID);
797 CheckBox checkBox = (CheckBox) UIElementMapper.getCorrespondingUIElement(objID); 797 ScilabBridge.removeMember(parentTab, checkBox);
798 ScilabBridge.removeMember(parentTab, checkBox); 798 }
799 } 799
800 800 /**
801 /** 801 * Set a figure as parent for a RadioButton
802 * Set a figure as parent for a RadioButton 802 * @param figureID the ID of the figure in the FigureMapper
803 * @param figureID the ID of the figure in the FigureMapper 803 * @param objID the ID of the PushButton in the UIElementMapper
804 * @param objID the ID of the PushButton in the UIElementMapper 804 */
805 */ 805 public static void setRadioButtonParent(int figureID, int objID) {
806 public static void setRadioButtonParent(int figureID, int objID) { 806 Tab parentTab = ((ScilabRendererProperties) FigureMapper.getCorrespondingFigure(figureID).getRendererProperties()).getParentTab();
807 Tab parentTab = ((ScilabRendererProperties) FigureMapper.getCorrespondingFigure(figureID).getRendererProperties()).getParentTab(); 807 RadioButton radioButton = (RadioButton) UIElementMapper.getCorrespondingUIElement(objID);
808 RadioButton radioButton = (RadioButton) UIElementMapper.getCorrespondingUIElement(objID); 808 ScilabBridge.addMember(parentTab, radioButton);
809 ScilabBridge.addMember(parentTab, radioButton); 809 }
810 } 810
811 811 /**
812 /** 812 * Remove a RadioButton from its parent figure
813 * Remove a RadioButton from its parent figure 813 * @param figureID the ID of the figure in the FigureMapper
814 * @param figureID the ID of the figure in the FigureMapper 814 * @param objID the ID of the PushButton in the UIElementMapper
815 * @param objID the ID of the PushButton in the UIElementMapper 815 */
816 */ 816 public static void removeRadioButtonFromParent(int figureID, int objID) {
817 public static void removeRadioButtonFromParent(int figureID, int objID) { 817 Tab parentTab = ((ScilabRendererProperties) FigureMapper.getCorrespondingFigure(figureID).getRendererProperties()).getParentTab();
818 Tab parentTab = ((ScilabRendererProperties) FigureMapper.getCorrespondingFigure(figureID).getRendererProperties()).getParentTab(); 818 RadioButton radioButton = (RadioButton) UIElementMapper.getCorrespondingUIElement(objID);
819 RadioButton radioButton = (RadioButton) UIElementMapper.getCorrespondingUIElement(objID); 819 ScilabBridge.removeMember(parentTab, radioButton);
820 ScilabBridge.removeMember(parentTab, radioButton); 820 }
821 } 821
822 822 /**
823 /** 823 * Set a figure as parent for a Slider
824 * Set a figure as parent for a Slider 824 * @param figureID the ID of the figure in the FigureMapper
825 * @param figureID the ID of the figure in the FigureMapper 825 * @param objID the ID of the PushButton in the UIElementMapper
826 * @param objID the ID of the PushButton in the UIElementMapper 826 */
827 */ 827 public static void setSliderParent(int figureID, int objID) {
828 public static void setSliderParent(int figureID, int objID) { 828 Tab parentTab = ((ScilabRendererProperties) FigureMapper.getCorrespondingFigure(figureID).getRendererProperties()).getParentTab();
829 Tab parentTab = ((ScilabRendererProperties) FigureMapper.getCorrespondingFigure(figureID).getRendererProperties()).getParentTab(); 829 Slider slider = (Slider) UIElementMapper.getCorrespondingUIElement(objID);
830 Slider slider = (Slider) UIElementMapper.getCorrespondingUIElement(objID); 830 ScilabBridge.addMember(parentTab, slider);
831 ScilabBridge.addMember(parentTab, slider); 831 }
832 } 832
833 833 /**
834 /** 834 * Remove a Slider from its parent figure
835 * Remove a Slider from its parent figure 835 * @param figureID the ID of the figure in the FigureMapper
836 * @param figureID the ID of the figure in the FigureMapper 836 * @param objID the ID of the Slider in the UIElementMapper
837 * @param objID the ID of the Slider in the UIElementMapper 837 */
838 */ 838 public static void removeSliderFromParent(int figureID, int objID) {
839 public static void removeSliderFromParent(int figureID, int objID) { 839 Tab parentTab = ((ScilabRendererProperties) FigureMapper.getCorrespondingFigure(figureID).getRendererProperties()).getParentTab();
840 Tab parentTab = ((ScilabRendererProperties) FigureMapper.getCorrespondingFigure(figureID).getRendererProperties()).getParentTab(); 840 Slider slider = (Slider) UIElementMapper.getCorrespondingUIElement(objID);
841 Slider slider = (Slider) UIElementMapper.getCorrespondingUIElement(objID); 841 ScilabBridge.removeMember(parentTab, slider);
842 ScilabBridge.removeMember(parentTab, slider); 842 }
843 } 843
844 844 /**
845 /** 845 * Set a figure as parent for a ListBox
846 * Set a figure as parent for a ListBox 846 * @param figureID the ID of the figure in the FigureMapper
847 * @param figureID the ID of the figure in the FigureMapper 847 * @param objID the ID of the ListBox in the UIElementMapper
848 * @param objID the ID of the ListBox in the UIElementMapper 848 */
849 */ 849 public static void setListBoxParent(int figureID, int objID) {
850 public static void setListBoxParent(int figureID, int objID) { 850 Tab parentTab = ((ScilabRendererProperties) FigureMapper.getCorrespondingFigure(figureID).getRendererProperties()).getParentTab();
851 Tab parentTab = ((ScilabRendererProperties) FigureMapper.getCorrespondingFigure(figureID).getRendererProperties()).getParentTab(); 851 ListBox listBox = (ListBox) UIElementMapper.getCorrespondingUIElement(objID);
852 ListBox listBox = (ListBox) UIElementMapper.getCorrespondingUIElement(objID); 852 ScilabBridge.addMember(parentTab, listBox);
853 ScilabBridge.addMember(parentTab, listBox); 853 }
854 } 854
855 855 /**
856 /** 856 * Remove a ListBox from its parent figure
857 * Remove a ListBox from its parent figure 857 * @param figureID the ID of the figure in the FigureMapper
858 * @param figureID the ID of the figure in the FigureMapper 858 * @param objID the ID of the ListBox in the UIElementMapper
859 * @param objID the ID of the ListBox in the UIElementMapper 859 */
860 */ 860 public static void removeListBoxFromParent(int figureID, int objID) {
861 public static void removeListBoxFromParent(int figureID, int objID) { 861 Tab parentTab = ((ScilabRendererProperties) FigureMapper.getCorrespondingFigure(figureID).getRendererProperties()).getParentTab();
862 Tab parentTab = ((ScilabRendererProperties) FigureMapper.getCorrespondingFigure(figureID).getRendererProperties()).getParentTab(); 862 ListBox listBox = (ListBox) UIElementMapper.getCorrespondingUIElement(objID);
863 ListBox listBox = (ListBox) UIElementMapper.getCorrespondingUIElement(objID); 863 ScilabBridge.removeMember(parentTab, listBox);
864 ScilabBridge.removeMember(parentTab, listBox); 864 }
865 } 865
866 866 /**
867 /** 867 * Set a figure as parent for a PopupMenu
868 * Set a figure as parent for a PopupMenu 868 * @param figureID the ID of the figure in the FigureMapper
869 * @param figureID the ID of the figure in the FigureMapper 869 * @param objID the ID of the PopupMenu in the UIElementMapper
870 * @param objID the ID of the PopupMenu in the UIElementMapper 870 */
871 */ 871 public static void setPopupMenuParent(int figureID, int objID) {
872 public static void setPopupMenuParent(int figureID, int objID) { 872 Tab parentTab = ((ScilabRendererProperties) FigureMapper.getCorrespondingFigure(figureID).getRendererProperties()).getParentTab();
873 Tab parentTab = ((ScilabRendererProperties) FigureMapper.getCorrespondingFigure(figureID).getRendererProperties()).getParentTab(); 873 PopupMenu popupMenu = (PopupMenu) UIElementMapper.getCorrespondingUIElement(objID);
874 PopupMenu popupMenu = (PopupMenu) UIElementMapper.getCorrespondingUIElement(objID); 874 ScilabBridge.addMember(parentTab, popupMenu);
875 ScilabBridge.addMember(parentTab, popupMenu); 875 }
876 } 876
877 877 /**
878 /** 878 * Remove a PopupMenu from its parent figure
879 * Remove a PopupMenu from its parent figure 879 * @param figureID the ID of the figure in the FigureMapper
880 * @param figureID the ID of the figure in the FigureMapper 880 * @param objID the ID of the PopupMenu in the UIElementMapper
881 * @param objID the ID of the PopupMenu in the UIElementMapper 881 */
882 */ 882 public static void removePopupMenuFromParent(int figureID, int objID) {
883 public static void removePopupMenuFromParent(int figureID, int objID) { 883 Tab parentTab = ((ScilabRendererProperties) FigureMapper.getCorrespondingFigure(figureID).getRendererProperties()).getParentTab();
884 Tab parentTab = ((ScilabRendererProperties) FigureMapper.getCorrespondingFigure(figureID).getRendererProperties()).getParentTab(); 884 PopupMenu popupMenu = (PopupMenu) UIElementMapper.getCorrespondingUIElement(objID);
885 PopupMenu popupMenu = (PopupMenu) UIElementMapper.getCorrespondingUIElement(objID); 885 ScilabBridge.removeMember(parentTab, popupMenu);
886 ScilabBridge.removeMember(parentTab, popupMenu); 886 }
887 } 887
888 888 /**
889 /** 889 * Set a figure as parent for a Frame
890 * Set a figure as parent for a Frame 890 * @param figureID the ID of the figure in the FigureMapper
891 * @param figureID the ID of the figure in the FigureMapper 891 * @param objID the ID of the PopupMenu in the UIElementMapper
892 * @param objID the ID of the PopupMenu in the UIElementMapper 892 */
893 */ 893 public static void setFrameParent(int figureID, int objID) {
894 public static void setFrameParent(int figureID, int objID) { 894 Tab parentTab = ((ScilabRendererProperties) FigureMapper.getCorrespondingFigure(figureID).getRendererProperties()).getParentTab();
895 Tab parentTab = ((ScilabRendererProperties) FigureMapper.getCorrespondingFigure(figureID).getRendererProperties()).getParentTab(); 895 Frame frame = (Frame) UIElementMapper.getCorrespondingUIElement(objID);
896 Frame frame = (Frame) UIElementMapper.getCorrespondingUIElement(objID); 896 ScilabBridge.addMember(parentTab, frame);
897 ScilabBridge.addMember(parentTab, frame); 897 }
898 } 898
899 899 /**
900 /** 900 * Remove a Frame from its parent figure
901 * Remove a Frame from its parent figure 901 * @param figureID the ID of the figure in the FigureMapper
902 * @param figureID the ID of the figure in the FigureMapper 902 * @param objID the ID of the PopupMenu in the UIElementMapper
903 * @param objID the ID of the PopupMenu in the UIElementMapper 903 */
904 */ 904 public static void removeFrameFromParent(int figureID, int objID) {
905 public static void removeFrameFromParent(int figureID, int objID) { 905 Tab parentTab = ((ScilabRendererProperties) FigureMapper.getCorrespondingFigure(figureID).getRendererProperties()).getParentTab();
906 Tab parentTab = ((ScilabRendererProperties) FigureMapper.getCorrespondingFigure(figureID).getRendererProperties()).getParentTab(); 906 Frame frame = (Frame) UIElementMapper.getCorrespondingUIElement(objID);
907 Frame frame = (Frame) UIElementMapper.getCorrespondingUIElement(objID); 907 ScilabBridge.removeMember(parentTab, frame);
908 ScilabBridge.removeMember(parentTab, frame); 908 }
909 } 909
910 910 /**
911 /** 911 * Set root Scilab object (the console tab) as the parent of the menu
912 * Set root Scilab object (the console tab) as the parent of the menu 912 * @param objID the id of the menu
913 * @param objID the id of the menu 913 */
914 */ 914 public static void setRootAsParent(int objID) {
915 public static void setRootAsParent(int objID) { 915 if (!(UIElementMapper.getCorrespondingUIElement(objID) instanceof MenuItem)) {
916 if (!(UIElementMapper.getCorrespondingUIElement(objID) instanceof MenuItem)) { 916 // Add the menu to the tab
917 // Add the menu to the tab 917 ScilabConsole.getConsole().getMenuBar().add((Menu) UIElementMapper.getCorrespondingUIElement(objID));
918 ScilabConsole.getConsole().getMenuBar().add((Menu) UIElementMapper.getCorrespondingUIElement(objID)); 918 } else {
919 } else { 919 // obj is a MenuItem that has top be converted to a Menu
920 // obj is a MenuItem that has top be converted to a Menu 920 MenuItem menuItem = (MenuItem) UIElementMapper.getCorrespondingUIElement(objID);
921 MenuItem menuItem = (MenuItem) UIElementMapper.getCorrespondingUIElement(objID); 921
922 922 Menu menuToAdd = ScilabMenu.createMenu();
923 Menu menuToAdd = ScilabMenu.createMenu(); 923 UIElementMapper.removeMapping(objID);
924 UIElementMapper.removeMapping(objID); 924 UIElementMapper.addMapping(objID, menuToAdd);
925 UIElementMapper.addMapping(objID, menuToAdd); 925 // Copy all properties from MenuItem to Menu
926 // Copy all properties from MenuItem to Menu 926 menuToAdd.setText(menuItem.getText());
927 menuToAdd.setText(menuItem.getText()); 927 menuToAdd.setCallback(menuItem.getCallback());
928 menuToAdd.setCallback(menuItem.getCallback()); 928 menuToAdd.setForeground(menuItem.getForeground());
929 menuToAdd.setForeground(menuItem.getForeground()); 929 menuToAdd.setVisible(menuItem.isVisible());
930 menuToAdd.setVisible(menuItem.isVisible()); 930 // End of properties copy
931 // End of properties copy 931
932 932 ScilabConsole.getConsole().getMenuBar().add(menuToAdd);
933 ScilabConsole.getConsole().getMenuBar().add(menuToAdd); 933 }
934 } 934 }
935 } 935
936 936 /**
937 /** 937 * Set an other menu as the parent of the menu
938 * Set an other menu as the parent of the menu 938 * @param menuID the id of the parent menu
939 * @param menuID the id of the parent menu 939 * @param objID the id of the menu
940 * @param objID the id of the menu 940 */
941 */ 941 public static void setMenuAsParent(int menuID, int objID) {
942 public static void setMenuAsParent(int menuID, int objID) { 942
943 943 if (UIElementMapper.getCorrespondingUIElement(menuID) instanceof CheckBoxMenuItem) {
944 if (UIElementMapper.getCorrespondingUIElement(menuID) instanceof CheckBoxMenuItem) { 944 CheckBoxMenuItem parentMenu = (CheckBoxMenuItem) UIElementMapper.getCorrespondingUIElement(menuID);
945 CheckBoxMenuItem parentMenu = (CheckBoxMenuItem) UIElementMapper.getCorrespondingUIElement(menuID); 945
946 946 if (!(UIElementMapper.getCorrespondingUIElement(objID) instanceof MenuItem)) {
947 if (!(UIElementMapper.getCorrespondingUIElement(objID) instanceof MenuItem)) { 947 parentMenu.add((Menu) UIElementMapper.getCorrespondingUIElement(objID));
948 parentMenu.add((Menu) UIElementMapper.getCorrespondingUIElement(objID)); 948 } else if (UIElementMapper.getCorrespondingUIElement(objID) instanceof MenuItem) {
949 } else if (UIElementMapper.getCorrespondingUIElement(objID) instanceof MenuItem) { 949 parentMenu.add((MenuItem) UIElementMapper.getCorrespondingUIElement(objID));
950 parentMenu.add((MenuItem) UIElementMapper.getCorrespondingUIElement(objID)); 950 }
951 } 951 } else if (UIElementMapper.getCorrespondingUIElement(menuID) instanceof MenuItem) {
952 } else if (UIElementMapper.getCorrespondingUIElement(menuID) instanceof MenuItem) { 952 MenuItem parentMenu = (MenuItem) UIElementMapper.getCorrespondingUIElement(menuID);
953 MenuItem parentMenu = (MenuItem) UIElementMapper.getCorrespondingUIElement(menuID); 953
954 954 if (!(UIElementMapper.getCorrespondingUIElement(objID) instanceof MenuItem)) {
955 if (!(UIElementMapper.getCorrespondingUIElement(objID) instanceof MenuItem)) { 955 parentMenu.add((Menu) UIElementMapper.getCorrespondingUIElement(objID));
956 parentMenu.add((Menu) UIElementMapper.getCorrespondingUIElement(objID)); 956 } else if (UIElementMapper.getCorrespondingUIElement(objID) instanceof MenuItem) {
957 } else if (UIElementMapper.getCorrespondingUIElement(objID) instanceof MenuItem) { 957 parentMenu.add((MenuItem) UIElementMapper.getCorrespondingUIElement(objID));
958 parentMenu.add((MenuItem) UIElementMapper.getCorrespondingUIElement(objID)); 958 }
959 } 959 } else if (UIElementMapper.getCorrespondingUIElement(menuID) instanceof ContextMenu) {
960 } else if (UIElementMapper.getCorrespondingUIElement(menuID) instanceof ContextMenu) { 960 ContextMenu parentMenu = (ContextMenu) UIElementMapper.getCorrespondingUIElement(menuID);
961 ContextMenu parentMenu = (ContextMenu) UIElementMapper.getCorrespondingUIElement(menuID); 961
962 962 if (!(UIElementMapper.getCorrespondingUIElement(objID) instanceof MenuItem)) {
963 if (!(UIElementMapper.getCorrespondingUIElement(objID) instanceof MenuItem)) { 963 parentMenu.add((Menu) UIElementMapper.getCorrespondingUIElement(objID));
964 parentMenu.add((Menu) UIElementMapper.getCorrespondingUIElement(objID)); 964 } else if (UIElementMapper.getCorrespondingUIElement(objID) instanceof MenuItem) {
965 } else if (UIElementMapper.getCorrespondingUIElement(objID) instanceof MenuItem) { 965 parentMenu.add((MenuItem) UIElementMapper.getCorrespondingUIElement(objID));
966 parentMenu.add((MenuItem) UIElementMapper.getCorrespondingUIElement(objID)); 966 }
967 } 967 } else if (UIElementMapper.getCorrespondingUIElement(menuID) instanceof Menu) {
968 } else if (UIElementMapper.getCorrespondingUIElement(menuID) instanceof Menu) { 968 Menu parentMenu = (Menu) UIElementMapper.getCorrespondingUIElement(menuID);
969 Menu parentMenu = (Menu) UIElementMapper.getCorrespondingUIElement(menuID); 969
970 970 if (!(UIElementMapper.getCorrespondingUIElement(objID) instanceof MenuItem)) {
971 if (!(UIElementMapper.getCorrespondingUIElement(objID) instanceof MenuItem)) { 971 parentMenu.add((Menu) UIElementMapper.getCorrespondingUIElement(objID));
972 parentMenu.add((Menu) UIElementMapper.getCorrespondingUIElement(objID)); 972 } else if (UIElementMapper.getCorrespondingUIElement(objID) instanceof MenuItem) {
973 } else if (UIElementMapper.getCorrespondingUIElement(objID) instanceof MenuItem) { 973 parentMenu.add((MenuItem) UIElementMapper.getCorrespondingUIElement(objID));
974 parentMenu.add((MenuItem) UIElementMapper.getCorrespondingUIElement(objID)); 974 }
975 } 975 }
976 } 976 }
977 } 977
978 978 /*******************/
979 /*******************/ 979 /* */
980 /* */ 980 /* OBJECT CALLBACK */
981 /* OBJECT CALLBACK */ 981 /* */
982 /* */ 982 /*******************/
983 /*******************/ 983
984 984 /**
985 /** 985 * Set a callback for a Widget
986 * Set a callback for a Widget 986 * @param objID the ID of the object in the UIElementMapper
987 * @param objID the ID of the object in the UIElementMapper 987 * @param callbackString the text of the callback
988 * @param callbackString the text of the callback 988 * @param callbackType the type of the callback
989 * @param callbackType the type of the callback 989 */
990 */ 990 public static void setWidgetCallback(int objID, String callbackString, int callbackType) {
991 public static void setWidgetCallback(int objID, String callbackString, int callbackType) { 991 ((Widget) UIElementMapper.getCorrespondingUIElement(objID))
992 ((Widget) UIElementMapper.getCorrespondingUIElement(objID)) 992 .setCallback(CallBack.createCallback(callbackString, callbackType, objID));
993 .setCallback(CallBack.createCallback(callbackString, callbackType, objID)); 993 }
994 } 994
995 995 /**
996 /** 996 * Set a callback for a Frame
997 * Set a callback for a Frame 997 * @param objID the ID of the object in the UIElementMapper
998 * @param objID the ID of the object in the UIElementMapper 998 * @param callbackString the text of the callback
999 * @param callbackString the text of the callback 999 * @param callbackType the type of the callback
1000 * @param callbackType the type of the callback 1000 */
1001 */ 1001 public static void setFrameCallback(int objID, String callbackString, int callbackType) {
1002 public static void setFrameCallback(int objID, String callbackString, int callbackType) { 1002 ((Frame) UIElementMapper.getCorrespondingUIElement(objID)).setCallback(CallBack.createCallback(callbackString, callbackType, objID));
1003 ((Frame) UIElementMapper.getCorrespondingUIElement(objID)).setCallback(CallBack.createCallback(callbackString, callbackType, objID)); 1003 }
1004 } 1004
1005 1005 /************************/
1006 /************************/ 1006 /* */
1007 /* */ 1007 /* ENABLE/DISABLE MENUS */
1008 /* ENABLE/DISABLE MENUS */ 1008 /* */
1009 /* */ 1009 /************************/
1010 /************************/ 1010
1011 1011 /**
1012 /** 1012 * Disable a menu of a Scilab figure giving its name
1013 * Disable a menu of a Scilab figure giving its name 1013 * @param figureID the id of the figure
1014 * @param figureID the id of the figure 1014 * @param menuName the name of the menu
1015 * @param menuName the name of the menu 1015 * @param status true to set the menu enabled
1016 * @param status true to set the menu enabled 1016 */
1017 */ 1017 public static void setFigureMenuEnabled(int figureID, String menuName, boolean status) {
1018 public static void setFigureMenuEnabled(int figureID, String menuName, boolean status) { 1018 if (FigureMapper.getCorrespondingFigure(figureID) != null) { /** Parent figure must exist */
1019 if (FigureMapper.getCorrespondingFigure(figureID) != null) { /** Parent figure must exist */ 1019 Tab parentTab = ((ScilabRendererProperties) FigureMapper.getCorrespondingFigure(figureID).
1020 Tab parentTab = ((ScilabRendererProperties) FigureMapper.getCorrespondingFigure(figureID). 1020 getRendererProperties()).getParentTab();
1021 getRendererProperties()).getParentTab(); 1021
1022 1022 MenuBar figureMenuBar = parentTab.getMenuBar();
1023 MenuBar figureMenuBar = parentTab.getMenuBar(); 1023
1024 1024 figureMenuBar.getAsSimpleMenuBar().setMenuEnabled(menuName, status);
1025 figureMenuBar.getAsSimpleMenuBar().setMenuEnabled(menuName, status); 1025 }
1026 } 1026 }
1027 } 1027
1028 1028 /**
1029 /** 1029 * Disable a MenuItem of a Scilab figure giving its parent name and position
1030 * Disable a MenuItem of a Scilab figure giving its parent name and position 1030 * @param figureID the id of the figure
1031 * @param figureID the id of the figure 1031 * @param parentMenuName the name of the parent menu
1032 * @param parentMenuName the name of the parent menu 1032 * @param menuItemPosition the name of the parent menu
1033 * @param menuItemPosition the name of the parent menu 1033 * @param status true to set the menu enabled
1034 * @param status true to set the menu enabled 1034 */
1035 */ 1035 public static void setFigureSubMenuEnabled(int figureID, String parentMenuName, int menuItemPosition, boolean status) {
1036 public static void setFigureSubMenuEnabled(int figureID, String parentMenuName, int menuItemPosition, boolean status) { 1036 if (FigureMapper.getCorrespondingFigure(figureID) != null) { /** Parent figure must exist */
1037 if (FigureMapper.getCorrespondingFigure(figureID) != null) { /** Parent figure must exist */ 1037 Tab parentTab = ((ScilabRendererProperties) FigureMapper.getCorrespondingFigure(figureID).
1038 Tab parentTab = ((ScilabRendererProperties) FigureMapper.getCorrespondingFigure(figureID). 1038 getRendererProperties()).getParentTab();
1039 getRendererProperties()).getParentTab(); 1039
1040 1040 MenuBar figureMenuBar = parentTab.getMenuBar();
1041 MenuBar figureMenuBar = parentTab.getMenuBar(); 1041
1042 1042 figureMenuBar.getAsSimpleMenuBar().setSubMenuEnabled(parentMenuName, menuItemPosition, status);
1043 figureMenuBar.getAsSimpleMenuBar().setSubMenuEnabled(parentMenuName, menuItemPosition, status); 1043 }
1044 } 1044 }
1045 } 1045
1046 1046 /**
1047 /** 1047 * Disable a menu of a Scilab root window giving its name
1048 * Disable a menu of a Scilab root window giving its name 1048 * @param menuName the name of the menu
1049 * @param menuName the name of the menu 1049 * @param status true to set the menu enabled
1050 * @param status true to set the menu enabled 1050 */
1051 */ 1051 public static void setRootMenuEnabled(String menuName, boolean status) {
1052 public static void setRootMenuEnabled(String menuName, boolean status) { 1052 if (ScilabConsole.isExistingConsole()) { /** Scilab console must exist */
1053 if (ScilabConsole.isExistingConsole()) { /** Scilab console must exist */ 1053 ScilabConsole.getConsole().getMenuBar().getAsSimpleMenuBar().setMenuEnabled(menuName, status);
1054 ScilabConsole.getConsole().getMenuBar().getAsSimpleMenuBar().setMenuEnabled(menuName, status); 1054 }
1055 } 1055 }
1056 } 1056
1057 1057 /**
1058 /** 1058 * Disable a MenuItem of a Scilab root window giving its parent name and position
1059 * Disable a MenuItem of a Scilab root window giving its parent name and position 1059 * @param parentMenuName the name of the parent menu
1060 * @param parentMenuName the name of the parent menu 1060 * @param menuItemPosition the name of the parent menu
1061 * @param menuItemPosition the name of the parent menu 1061 * @param status true to set the menu enabled
1062 * @param status true to set the menu enabled 1062 */
1063 */ 1063 public static void setRootSubMenuEnabled(String parentMenuName, int menuItemPosition, boolean status) {
1064 public static void setRootSubMenuEnabled(String parentMenuName, int menuItemPosition, boolean status) { 1064 if (ScilabConsole.isExistingConsole()) { /** Scilab console must exist */
1065 if (ScilabConsole.isExistingConsole()) { /** Scilab console must exist */ 1065 ScilabConsole.getConsole().getMenuBar().getAsSimpleMenuBar().setSubMenuEnabled(parentMenuName, menuItemPosition, status);
1066 ScilabConsole.getConsole().getMenuBar().getAsSimpleMenuBar().setSubMenuEnabled(parentMenuName, menuItemPosition, status); 1066 }
1067 } 1067 }
1068 } 1068
1069 1069 /****************/
1070 /****************/ 1070 /* */
1071 /* */ 1071 /* REMOVE MENUS */
1072 /* REMOVE MENUS */ 1072 /* */
1073 /* */ 1073 /****************/
1074 /****************/ 1074
1075 1075 /**
1076 /** 1076 * Delete a menu of a Scilab figure giving its name
1077 * Delete a menu of a Scilab figure giving its name 1077 * @param figureID the id of the figure
1078 * @param figureID the id of the figure 1078 * @param menuName the name of the menu
1079 * @param menuName the name of the menu 1079 */
1080 */ 1080 public static void removeFigureMenu(int figureID, String menuName) {
1081 public static void removeFigureMenu(int figureID, String menuName) { 1081 if (FigureMapper.getCorrespondingFigure(figureID) != null) { /** Parent figure must exist */
1082 if (FigureMapper.getCorrespondingFigure(figureID) != null) { /** Parent figure must exist */ 1082 Tab parentTab = ((ScilabRendererProperties) FigureMapper.getCorrespondingFigure(figureID).
1083 Tab parentTab = ((ScilabRendererProperties) FigureMapper.getCorrespondingFigure(figureID). 1083 getRendererProperties()).getParentTab();
1084 getRendererProperties()).getParentTab(); 1084
1085 1085 MenuBar figureMenuBar = parentTab.getMenuBar();
1086 MenuBar figureMenuBar = parentTab.getMenuBar(); 1086
1087 1087 figureMenuBar.getAsSimpleMenuBar().removeMenu(menuName);
1088 figureMenuBar.getAsSimpleMenuBar().removeMenu(menuName); 1088 }
1089 } 1089 }
1090 } 1090
1091 1091 /**
1092 /** 1092 * Delete a menu of a Scilab root window giving its name
1093 * Delete a menu of a Scilab root window giving its name 1093 * @param menuName the name of the menu
1094 * @param menuName the name of the menu 1094 */
1095 */ 1095 public static void removeRootMenu(String menuName) {
1096 public static void removeRootMenu(String menuName) { 1096 if (ScilabConsole.isExistingConsole()) { /** Scilab Console must exist */
1097 if (ScilabConsole.isExistingConsole()) { /** Scilab Console must exist */ 1097 ScilabConsole.getConsole().getMenuBar().getAsSimpleMenuBar().removeMenu(menuName);
1098 ScilabConsole.getConsole().getMenuBar().getAsSimpleMenuBar().removeMenu(menuName); 1098 }
1099 } 1099 }
1100 } 1100
1101 1101 /***********************/
1102 /***********************/ 1102 /* */
1103 /* */ 1103 /* FILE CHOOSER BRIDGE */
1104 /* FILE CHOOSER BRIDGE */ 1104 /* */
1105 /* */ 1105 /***********************/
1106 /***********************/ 1106
1107 1107
1108 1108
1109 1109 /**
1110 /** 1110 * Create a new Graphic Export File Chooser in Scilab GUIs
1111 * Create a new Graphic Export File Chooser in Scilab GUIs 1111 * @param figureId id of the figure to export
1112 * @param figureId id of the figure to export 1112 * @return the ID of the File Chooser in the UIElementMapper
1113 * @return the ID of the File Chooser in the UIElementMapper 1113 */
1114 */ 1114
1115 1115 public static int newExportFileChooser(int figureId) {
1116 public static int newExportFileChooser(int figureId) { 1116 FileChooser fileChooser = ScilabFileChooser.createExportFileChooser(figureId);
1117 FileChooser fileChooser = ScilabFileChooser.createExportFileChooser(figureId); 1117 return 0;
1118 return 0; 1118 //return UIElementMapper.add(fileChooser);
1119 //return UIElementMapper.add(fileChooser); 1119 }
1120 } 1120
1121 1121
1122 1122
1123 1123 /**********************/
1124 /**********************/ 1124 /* */
1125 /* */ 1125 /* MESSAGE BOX BRIDGE */
1126 /* MESSAGE BOX BRIDGE */ 1126 /* */
1127 /* */ 1127 /**********************/
1128 /**********************/ 1128
1129 1129 /**
1130 /** 1130 * Set the MessageBox title
1131 * Set the MessageBox title 1131 * @param id the id of the messageBox
1132 * @param id the id of the messageBox 1132 * @param title the title of the messageBox
1133 * @param title the title of the messageBox 1133 */
1134 */ 1134 public static void setMessageBoxTitle(int id, String title) {
1135 public static void setMessageBoxTitle(int id, String title) { 1135 ((MessageBox) UIElementMapper.getCorrespondingUIElement(id)).setTitle(title);
1136 ((MessageBox) UIElementMapper.getCorrespondingUIElement(id)).setTitle(title); 1136 }
1137 } 1137
1138 1138 /**
1139 /** 1139 * Set the MessageBox message
1140 * Set the MessageBox message 1140 * @param id the id of the messageBox
1141 * @param id the id of the messageBox 1141 * @param message the message of the messageBox
1142 * @param message the message of the messageBox 1142 */
1143 */ 1143 public static void setMessageBoxMessage(int id, String message) {
1144 public static void setMessageBoxMessage(int id, String message) { 1144 ((MessageBox) UIElementMapper.getCorrespondingUIElement(id)).setMessage(message);
1145 ((MessageBox) UIElementMapper.getCorrespondingUIElement(id)).setMessage(message); 1145 }
1146 } 1146
1147 1147 /**
1148 /** 1148 * Set the MessageBox message (multi-line)
1149 * Set the MessageBox message (multi-line) 1149 * @param id the id of the messageBox
1150 * @param id the id of the messageBox 1150 * @param message the message of the messageBox
1151 * @param message the message of the messageBox 1151 */
1152 */ 1152 public static void setMessageBoxMessage(int id, String[] message) {
1153 public static void setMessageBoxMessage(int id, String[] message) { 1153 ((MessageBox) UIElementMapper.getCorrespondingUIElement(id)).setMessage(message);
1154 ((MessageBox) UIElementMapper.getCorrespondingUIElement(id)).setMessage(message); 1154 }
1155 } 1155
1156 1156 /**
1157 /** 1157 * Display this chooser and wait for user selection
1158 * Display this chooser and wait for user selection 1158 * @param id the id of the messageBox
1159 * @param id the id of the messageBox 1159 */
1160 */ 1160 public static void messageBoxDisplayAndWait(int id) {
1161 public static void messageBoxDisplayAndWait(int id) { 1161 ((MessageBox) UIElementMapper.getCorrespondingUIElement(id)).displayAndWait();
1162 ((MessageBox) UIElementMapper.getCorrespondingUIElement(id)).displayAndWait(); 1162 }
1163 } 1163
1164 1164 /**
1165 /** 1165 * Get the index of the selected button
1166 * Get the index of the selected button 1166 * @param id the id of the messageBox
1167 * @param id the id of the messageBox 1167 * @return the index of the selected button
1168 * @return the index of the selected button 1168 */
1169 */ 1169 public static int getMessageBoxSelectedButton(int id) {
1170 public static int getMessageBoxSelectedButton(int id) { 1170 return ((MessageBox) UIElementMapper.getCorrespondingUIElement(id)).getSelectedButton();
1171 return ((MessageBox) UIElementMapper.getCorrespondingUIElement(id)).getSelectedButton(); 1171 }
1172 } 1172
1173 1173 /**
1174 /** 1174 * Set the indices of the default selected buttons (x_choices)
1175 * Set the indices of the default selected buttons (x_choices) 1175 * @param id the id of the MessageBox
1176 * @param id the id of the MessageBox 1176 * @param indices the indices of the default selected buttons
1177 * @param indices the indices of the default selected buttons 1177 */
1178 */ 1178 public static void setMessageBoxDefaultSelectedButtons(int id, int[] indices) {
1179 public static void setMessageBoxDefaultSelectedButtons(int id, int[] indices) { 1179 ((MessageBox) UIElementMapper.getCorrespondingUIElement(id)).setDefaultSelectedButtons(indices);
1180 ((MessageBox) UIElementMapper.getCorrespondingUIElement(id)).setDefaultSelectedButtons(indices); 1180 }
1181 } 1181
1182 1182 /**
1183 /** 1183 * Get the indices of the user selected buttons (x_choices)
1184 * Get the indices of the user selected buttons (x_choices) 1184 * @param id the id of the MessageBox
1185 * @param id the id of the MessageBox 1185 * @return the indices of the user selected buttons
1186 * @return the indices of the user selected buttons 1186 */
1187 */ 1187 public static int[] getMessageBoxUserSelectedButtons(int id) {
1188 public static int[] getMessageBoxUserSelectedButtons(int id) { 1188 return ((MessageBox) UIElementMapper.getCorrespondingUIElement(id)).getUserSelectedButtons();
1189 return ((MessageBox) UIElementMapper.getCorrespondingUIElement(id)).getUserSelectedButtons(); 1189 }
1190 } 1190
1191 1191 /**
1192 /** 1192 * Set the labels of the buttons in the MessageBox
1193 * Set the labels of the buttons in the MessageBox 1193 * @param id the id of the MessageBox
1194 * @param id the id of the MessageBox 1194 * @param labels the labels of the buttons
1195 * @param labels the labels of the buttons 1195 */
1196 */ 1196 public static void setMessageBoxButtonsLabels(int id, String[] labels) {
1197 public static void setMessageBoxButtonsLabels(int id, String[] labels) { 1197 ((MessageBox) UIElementMapper.getCorrespondingUIElement(id)).setButtonsLabels(labels);
1198 ((MessageBox) UIElementMapper.getCorrespondingUIElement(id)).setButtonsLabels(labels); 1198 }
1199 } 1199
1200 1200 /**
1201 /** 1201 * Set the initial value for the editable part of the MessageBox
1202 * Set the initial value for the editable part of the MessageBox 1202 * @param id the id of the MessageBox
1203 * @param id the id of the MessageBox 1203 * @param value the initial value
1204 * @param value the initial value 1204 */
1205 */ 1205 public static void setMessageBoxInitialValue(int id, String[] value) {
1206 public static void setMessageBoxInitialValue(int id, String[] value) { 1206 ((MessageBox) UIElementMapper.getCorrespondingUIElement(id)).setInitialValue(value);
1207 ((MessageBox) UIElementMapper.getCorrespondingUIElement(id)).setInitialValue(value); 1207 }
1208 } 1208
1209 1209 /**
1210 /** 1210 * Get the value of the editable zone in the MessageBox
1211 * Get the value of the editable zone in the MessageBox 1211 * @param id the id of the MessageBox
1212 * @param id the id of the MessageBox 1212 * @return the value
1213 * @return the value 1213 */
1214 */ 1214 public static String[] getMessageBoxValue(int id) {
1215 public static String[] getMessageBoxValue(int id) { 1215 return ((MessageBox) UIElementMapper.getCorrespondingUIElement(id)).getValue();
1216 return ((MessageBox) UIElementMapper.getCorrespondingUIElement(id)).getValue(); 1216 }
1217 } 1217
1218 1218 /**
1219 /** 1219 * Get the size of the value of the editable zone in the MessageBox
1220 * Get the size of the value of the editable zone in the MessageBox 1220 * @param id the id of the MessageBox
1221 * @param id the id of the MessageBox 1221 * @return the value size
1222 * @return the value size 1222 */
1223 */ 1223 public static int getMessageBoxValueSize(int id) {
1224 public static int getMessageBoxValueSize(int id) { 1224 return ((MessageBox) UIElementMapper.getCorrespondingUIElement(id)).getValueSize();
1225 return ((MessageBox) UIElementMapper.getCorrespondingUIElement(id)).getValueSize(); 1225 }
1226 } 1226
1227 1227 /**
1228 /** 1228 * Set the items of the listbox in the MessageBox
1229 * Set the items of the listbox in the MessageBox 1229 * @param id the id of the MessageBox
1230 * @param id the id of the MessageBox 1230 * @param items the items to set
1231 * @param items the items to set 1231 */
1232 */ 1232 public static void setMessageBoxListBoxItems(int id, String[] items) {
1233 public static void setMessageBoxListBoxItems(int id, String[] items) { 1233 ((MessageBox) UIElementMapper.getCorrespondingUIElement(id)).setListBoxItems(items);
1234 ((MessageBox) UIElementMapper.getCorrespondingUIElement(id)).setListBoxItems(items); 1234 }
1235 } 1235
1236 1236 /**
1237 /** 1237 * Get the index of the selected item in the listbox in the MessageBox
1238 * Get the index of the selected item in the listbox in the MessageBox 1238 * @param id the id of the MessageBox
1239 * @param id the id of the MessageBox 1239 * @return the index
1240 * @return the index 1240 */
1241 */ 1241 public static int getMessageBoxSelectedItem(int id) {
1242 public static int getMessageBoxSelectedItem(int id) { 1242 return ((MessageBox) UIElementMapper.getCorrespondingUIElement(id)).getSelectedItem();
1243 return ((MessageBox) UIElementMapper.getCorrespondingUIElement(id)).getSelectedItem(); 1243 }
1244 } 1244
1245 1245 /**
1246 /** 1246 * Set the name of the lines labels in the editable zone in the MessageBox
1247 * Set the name of the lines labels in the editable zone in the MessageBox 1247 * @param id the id of the MessageBox
1248 * @param id the id of the MessageBox 1248 * @param labels the labels
1249 * @param labels the labels 1249 */
1250 */ 1250 public static void setMessageBoxLineLabels(int id, String[] labels) {
1251 public static void setMessageBoxLineLabels(int id, String[] labels) { 1251 ((MessageBox) UIElementMapper.getCorrespondingUIElement(id)).setLineLabels(labels);
1252 ((MessageBox) UIElementMapper.getCorrespondingUIElement(id)).setLineLabels(labels); 1252 }
1253 } 1253
1254 1254 /**
1255 /** 1255 * Set the name of the columns labels in the editable zone in the MessageBox
1256 * Set the name of the columns labels in the editable zone in the MessageBox 1256 * @param id the id of the MessageBox
1257 * @param id the id of the MessageBox 1257 * @param labels the labels
1258 * @param labels the labels 1258 */
1259 */ 1259 public static void setMessageBoxColumnLabels(int id, String[] labels) {
1260 public static void setMessageBoxColumnLabels(int id, String[] labels) { 1260 ((MessageBox) UIElementMapper.getCorrespondingUIElement(id)).setColumnLabels(labels);
1261 ((MessageBox) UIElementMapper.getCorrespondingUIElement(id)).setColumnLabels(labels); 1261 }
1262 } 1262
1263 1263 /**
1264 /** 1264 * Set the default values of a multi-value editable zone in the MessageBox
1265 * Set the default values of a multi-value editable zone in the MessageBox 1265 * @param id the id of the MessageBox
1266 * @param id the id of the MessageBox 1266 * @param values the values
1267 * @param values the values 1267 */
1268 */ 1268 public static void setMessageBoxDefaultInput(int id, String[] values) {
1269 public static void setMessageBoxDefaultInput(int id, String[] values) { 1269 ((MessageBox) UIElementMapper.getCorrespondingUIElement(id)).setDefaultInput(values);
1270 ((MessageBox) UIElementMapper.getCorrespondingUIElement(id)).setDefaultInput(values); 1270 }
1271 } 1271
1272 1272 /**
1273 /** 1273 * Set a MessageBox modal or not
1274 * Set a MessageBox modal or not 1274 * @param id the id of the MessageBox
1275 * @param id the id of the MessageBox 1275 * @param status true to set the MessageBox modal and false else
1276 * @param status true to set the MessageBox modal and false else 1276 */
1277 */ 1277 public static void setMessageBoxModal(int id, boolean status) {
1278 public static void setMessageBoxModal(int id, boolean status) { 1278 ((MessageBox) UIElementMapper.getCorrespondingUIElement(id)).setModal(status);
1279 ((MessageBox) UIElementMapper.getCorrespondingUIElement(id)).setModal(status); 1279 }
1280 } 1280
1281 1281 /**
1282 /** 1282 * Set the MessageBox icon
1283 * Set the MessageBox icon 1283 * @param id the id of the MessageBox
1284 * @param id the id of the MessageBox 1284 * @param name the name of the icon
1285 * @param name the name of the icon 1285 */
1286 */ 1286 public static void setMessageBoxIcon(int id, String name) {
1287 public static void setMessageBoxIcon(int id, String name) { 1287 ((MessageBox) UIElementMapper.getCorrespondingUIElement(id)).setIcon(name);
1288 ((MessageBox) UIElementMapper.getCorrespondingUIElement(id)).setIcon(name); 1288 }
1289 } 1289
1290 1290 /************************/
1291 /************************/ 1291 /* */
1292 /* */ 1292 /* OBJECT COLORS BRIDGE */
1293 /* OBJECT COLORS BRIDGE */ 1293 /* */
1294 /* */ 1294 /************************/
1295 /************************/ 1295
1296 1296 /**
1297 /** 1297 * Set the background color of a Widget
1298 * Set the background color of a Widget 1298 * @param id the id of the Widget
1299 * @param id the id of the Widget 1299 * @param red the red value for the color
1300 * @param red the red value for the color 1300 * @param green the green value for the color
1301 * @param green the green value for the color 1301 * @param blue the blue value for the color
1302 * @param blue the blue value for the color 1302 */
1303 */ 1303 public static void setWidgetBackgroundColor(int id, int red, int green, int blue) {
1304 public static void setWidgetBackgroundColor(int id, int red, int green, int blue) { 1304 ((Widget) UIElementMapper.getCorrespondingUIElement(id)).setBackground(new Color(red, green, blue));
1305 ((Widget) UIElementMapper.getCorrespondingUIElement(id)).setBackground(new Color(red, green, blue)); 1305 }
1306 } 1306
1307 1307 /**
1308 /** 1308 * Get the background color of a widget
1309 * Get the background color of a widget 1309 * @param id the id of the widget
1310 * @param id the id of the widget 1310 * @return the color [R, G, B]
1311 * @return the color [R, G, B] 1311 */
1312 */ 1312 public static int[] getWidgetBackgroundColor(int id) {
1313 public static int[] getWidgetBackgroundColor(int id) { 1313 Color tmpColor = ((Widget) UIElementMapper.getCorrespondingUIElement(id)).getBackground();
1314 Color tmpColor = ((Widget) UIElementMapper.getCorrespondingUIElement(id)).getBackground(); 1314 int[] color = new int[NB_COLORS];
1315 int[] color = new int[NB_COLORS]; 1315 color[0] = tmpColor.getRed();
1316 color[0] = tmpColor.getRed(); 1316 color[1] = tmpColor.getGreen();
1317 color[1] = tmpColor.getGreen(); 1317 color[2] = tmpColor.getBlue();
1318 color[2] = tmpColor.getBlue(); 1318 return color;
1319 return color; 1319 }
1320 } 1320
1321 1321 /**
1322 /** 1322 * Set the foreground color of a Widget
1323 * Set the foreground color of a Widget 1323 * @param id the id of the Widget
1324 * @param id the id of the Widget 1324 * @param red the red value for the color
1325 * @param red the red value for the color 1325 * @param green the green value for the color
1326 * @param green the green value for the color 1326 * @param blue the blue value for the color
1327 * @param blue the blue value for the color 1327 */
1328 */ 1328 public static void setWidgetForegroundColor(int id, int red, int green, int blue) {
1329 public static void setWidgetForegroundColor(int id, int red, int green, int blue) { 1329 ((Widget) UIElementMapper.getCorrespondingUIElement(id)).setForeground(new Color(red, green, blue));
1330 ((Widget) UIElementMapper.getCorrespondingUIElement(id)).setForeground(new Color(red, green, blue)); 1330 }
1331 } 1331
1332 1332 /**
1333 /** 1333 * Get the foreground color of a Widget
1334 * Get the foreground color of a Widget 1334 * @param id the id of the Widget
1335 * @param id the id of the Widget 1335 * @return the color [R, G, B]
1336 * @return the color [R, G, B] 1336 */
1337 */ 1337 public static int[] getWidgetForegroundColor(int id) {
1338 public static int[] getWidgetForegroundColor(int id) { 1338 Color tmpColor = ((Widget) UIElementMapper.getCorrespondingUIElement(id)).getForeground();
1339 Color tmpColor = ((Widget) UIElementMapper.getCorrespondingUIElement(id)).getForeground(); 1339 int[] color = new int[NB_COLORS];
1340 int[] color = new int[NB_COLORS]; 1340 color[0] = tmpColor.getRed();
1341 color[0] = tmpColor.getRed(); 1341 color[1] = tmpColor.getGreen();
1342 color[1] = tmpColor.getGreen(); 1342 color[2] = tmpColor.getBlue();
1343 color[2] = tmpColor.getBlue(); 1343 return color;
1344 return color; 1344 }
1345 } 1345
1346 1346 /**
1347 /** 1347 * Set the background color of a Frame
1348 * Set the background color of a Frame 1348 * @param id the id of the Frame
1349 * @param id the id of the Frame 1349 * @param red the red value for the color
1350 * @param red the red value for the color 1350 * @param green the green value for the color
1351 * @param green the green value for the color 1351 * @param blue the blue value for the color
1352 * @param blue the blue value for the color 1352 */
1353 */ 1353 public static void setFrameBackgroundColor(int id, int red, int green, int blue) {
1354 public static void setFrameBackgroundColor(int id, int red, int green, int blue) { 1354 ((Frame) UIElementMapper.getCorrespondingUIElement(id)).setBackground(new Color(red, green, blue));
1355 ((Frame) UIElementMapper.getCorrespondingUIElement(id)).setBackground(new Color(red, green, blue)); 1355 }
1356 } 1356
1357 1357 /**
1358 /** 1358 * Get the background color of a Frame
1359 * Get the background color of a Frame 1359 * @param id the id of the Frame
1360 * @param id the id of the Frame 1360 * @return the color [R, G, B]
1361 * @return the color [R, G, B] 1361 */
1362 */ 1362 public static int[] getFrameBackgroundColor(int id) {
1363 public static int[] getFrameBackgroundColor(int id) { 1363 Color tmpColor = ((Frame) UIElementMapper.getCorrespondingUIElement(id)).getBackground();
1364 Color tmpColor = ((Frame) UIElementMapper.getCorrespondingUIElement(id)).getBackground(); 1364 int[] color = new int[NB_COLORS];
1365 int[] color = new int[NB_COLORS]; 1365 color[0] = tmpColor.getRed();
1366 color[0] = tmpColor.getRed(); 1366 color[1] = tmpColor.getGreen();
1367 color[1] = tmpColor.getGreen(); 1367 color[2] = tmpColor.getBlue();
1368 color[2] = tmpColor.getBlue(); 1368 return color;
1369 return color; 1369 }
1370 } 1370
1371 1371 /**
1372 /** 1372 * Set the foreground color of a Frame
1373 * Set the foreground color of a Frame 1373 * @param id the id of the Frame
1374 * @param id the id of the Frame 1374 * @param red the red value for the color
1375 * @param red the red value for the color 1375 * @param green the green value for the color
1376 * @param green the green value for the color 1376 * @param blue the blue value for the color
1377 * @param blue the blue value for the color 1377 */
1378 */ 1378 public static void setFrameForegroundColor(int id, int red, int green, int blue) {
1379 public static void setFrameForegroundColor(int id, int red, int green, int blue) { 1379 ((Frame) UIElementMapper.getCorrespondingUIElement(id)).setForeground(new Color(red, green, blue));
1380 ((Frame) UIElementMapper.getCorrespondingUIElement(id)).setForeground(new Color(red, green, blue)); 1380 }
1381 } 1381
1382 1382 /**
1383 /** 1383 * Get the foreground color of a Frame
1384 * Get the foreground color of a Frame 1384 * @param id the id of the Frame
1385 * @param id the id of the Frame 1385 * @return the color [R, G, B]
1386 * @return the color [R, G, B] 1386 */
1387 */ 1387 public static int[] getFrameForegroundColor(int id) {
1388 public static int[] getFrameForegroundColor(int id) { 1388 Color tmpColor = ((Frame) UIElementMapper.getCorrespondingUIElement(id)).getForeground();
1389 Color tmpColor = ((Frame) UIElementMapper.getCorrespondingUIElement(id)).getForeground(); 1389 int[] color = new int[NB_COLORS];
1390 int[] color = new int[NB_COLORS]; 1390 color[0] = tmpColor.getRed();
1391 color[0] = tmpColor.getRed(); 1391 color[1] = tmpColor.getGreen();
1392 color[1] = tmpColor.getGreen(); 1392 color[2] = tmpColor.getBlue();
1393 color[2] = tmpColor.getBlue(); 1393 return color;
1394 return color; 1394 }
1395 } 1395
1396 1396 /**********************/
1397 /**********************/ 1397 /* */
1398 /* */ 1398 /* OBJECT FONT BRIDGE */
1399 /* OBJECT FONT BRIDGE */ 1399 /* */
1400 /* */ 1400 /**********************/
1401 /**********************/ 1401
1402 1402 /**
1403 /** 1403 * Set the name of a Widget font
1404 * Set the name of a Widget font 1404 * @param id the id of the Widget
1405 * @param id the id of the Widget 1405 * @param name the name of the Widget font
1406 * @param name the name of the Widget font 1406 */
1407 */ 1407 public static void setWidgetFontName(int id, String name) {
1408 public static void setWidgetFontName(int id, String name) { 1408 Font font = ((Widget) UIElementMapper.getCorrespondingUIElement(id)).getFont();
1409 Font font = ((Widget) UIElementMapper.getCorrespondingUIElement(id)).getFont(); 1409 font = new Font(name, font.getStyle(), font.getSize());
1410 font = new Font(name, font.getStyle(), font.getSize()); 1410 ((Widget) UIElementMapper.getCorrespondingUIElement(id)).setFont(font);
1411 ((Widget) UIElementMapper.getCorrespondingUIElement(id)).setFont(font); 1411 }
1412 } 1412
1413 1413 /**
1414 /** 1414 * Get the name of a Widget font
1415 * Get the name of a Widget font 1415 * @param id the id of the Widget
1416 * @param id the id of the Widget 1416 * @return the name of the Widget font
1417 * @return the name of the Widget font 1417 */
1418 */ 1418 public static String getWidgetFontName(int id) {
1419 public static String getWidgetFontName(int id) { 1419 return ((Widget) UIElementMapper.getCorrespondingUIElement(id)).getFont().getName();
1420 return ((Widget) UIElementMapper.getCorrespondingUIElement(id)).getFont().getName(); 1420 }
1421 } 1421
1422 1422 /**
1423 /** 1423 * Set the weight of a Widget font
1424 * Set the weight of a Widget font 1424 * @param id the id of the Widget
1425 * @param id the id of the Widget 1425 * @param weight the weight of the Widget font
1426 * @param weight the weight of the Widget font 1426 */
1427 */ 1427 public static void setWidgetFontWeight(int id, String weight) {
1428 public static void setWidgetFontWeight(int id, String weight) { 1428 Font font = ((Widget) UIElementMapper.getCorrespondingUIElement(id)).getFont();
1429 Font font = ((Widget) UIElementMapper.getCorrespondingUIElement(id)).getFont(); 1429
1430 1430 if (weight.equals(BOLDFONT)) {
1431 if (weight.equals(BOLDFONT)) { 1431 if (font.isItalic()) {
1432 if (font.isItalic()) { 1432 font = new Font(font.getName(), Font.ITALIC + Font.BOLD, font.getSize());
1433 font = new Font(font.getName(), Font.ITALIC + Font.BOLD, font.getSize()); 1433 } else {
1434 } else { 1434 font = new Font(font.getName(), Font.BOLD, font.getSize());
1435 font = new Font(font.getName(), Font.BOLD, font.getSize()); 1435 }
1436 } 1436 } else {
1437 } else { 1437 if (font.isItalic()) {
1438 if (font.isItalic()) { 1438 font = new Font(font.getName(), Font.ITALIC, font.getSize());
1439 font = new Font(font.getName(), Font.ITALIC, font.getSize()); 1439 } else {
1440 } else { 1440 font = new Font(font.getName(), Font.PLAIN, font.getSize());
1441 font = new Font(font.getName(), Font.PLAIN, font.getSize()); 1441 }
1442 } 1442 }
1443 } 1443
1444 1444 ((Widget) UIElementMapper.getCorrespondingUIElement(id)).setFont(font);
1445 ((Widget) UIElementMapper.getCorrespondingUIElement(id)).setFont(font); 1445 }
1446 } 1446
1447 1447 /**
1448 /** 1448 * Set the angle of a Widget font
1449 * Set the angle of a Widget font 1449 * @param id the id of the Widget
1450 * @param id the id of the Widget 1450 * @param angle the angle of the Widget font
1451 * @param angle the angle of the Widget font 1451 */
1452 */ 1452 public static void setWidgetFontAngle(int id, String angle) {
1453 public static void setWidgetFontAngle(int id, String angle) { 1453 Font font = ((Widget) UIElementMapper.getCorrespondingUIElement(id)).getFont();
1454 Font font = ((Widget) UIElementMapper.getCorrespondingUIElement(id)).getFont(); 1454
1455 1455 if (angle.equals(ITALICFONT) || angle.equals(OBLIQUEFONT)) {
1456 if (angle.equals(ITALICFONT) || angle.equals(OBLIQUEFONT)) { 1456 if (font.isBold()) {
1457 if (font.isBold()) { 1457 font = new Font(font.getName(), Font.ITALIC + Font.BOLD, font.getSize());
1458 font = new Font(font.getName(), Font.ITALIC + Font.BOLD, font.getSize()); 1458 } else {
1459 } else { 1459 font = new Font(font.getName(), Font.ITALIC, font.getSize());
1460 font = new Font(font.getName(), Font.ITALIC, font.getSize()); 1460 }
1461 } 1461 } else {
1462 } else { 1462 if (font.isBold()) {
1463 if (font.isBold()) { 1463 font = new Font(font.getName(), Font.BOLD, font.getSize());
1464 font = new Font(font.getName(), Font.BOLD, font.getSize()); 1464 } else {
1465 } else { 1465 font = new Font(font.getName(), Font.PLAIN, font.getSize());
1466 font = new Font(font.getName(), Font.PLAIN, font.getSize()); 1466 }
1467 } 1467 }
1468 } 1468
1469 1469 ((Widget) UIElementMapper.getCorrespondingUIElement(id)).setFont(font);
1470 ((Widget) UIElementMapper.getCorrespondingUIElement(id)).setFont(font); 1470 }
1471 } 1471
1472 1472 /**
1473 /** 1473 * Set the size of a Widget font
1474 * Set the size of a Widget font 1474 * @param id the id of the Widget
1475 * @param id the id of the Widget 1475 * @param size the size of the Widget font
1476 * @param size the size of the Widget font 1476 */
1477 */ 1477 public static void setWidgetFontSize(int id, int size) {
1478 public static void setWidgetFontSize(int id, int size) { 1478 Font font = ((Widget) UIElementMapper.getCorrespondingUIElement(id)).getFont();
1479 Font font = ((Widget) UIElementMapper.getCorrespondingUIElement(id)).getFont(); 1479 font = new Font(font.getName(), font.getStyle(), size);
1480 font = new Font(font.getName(), font.getStyle(), size); 1480 ((Widget) UIElementMapper.getCorrespondingUIElement(id)).setFont(font);
1481 ((Widget) UIElementMapper.getCorrespondingUIElement(id)).setFont(font); 1481 }
1482 } 1482
1483 1483 /**
1484 /** 1484 * Get the size of a Widget font
1485 * Get the size of a Widget font 1485 * @param id the id of the Widget
1486 * @param id the id of the Widget 1486 * @return the size of the Widget font
1487 * @return the size of the Widget font 1487 */
1488 */ 1488 public static int getWidgetFontSize(int id) {
1489 public static int getWidgetFontSize(int id) { 1489 return ((Widget) UIElementMapper.getCorrespondingUIElement(id)).getFont().getSize();
1490 return ((Widget) UIElementMapper.getCorrespondingUIElement(id)).getFont().getSize(); 1490 }
1491 } 1491
1492 1492 /**
1493 /** 1493 * Set the weight of a Frame font
1494 * Set the weight of a Frame font 1494 * @param id the id of the Frame
1495 * @param id the id of the Frame 1495 * @param weight the weight of the Frame font
1496 * @param weight the weight of the Frame font 1496 */
1497 */ 1497 public static void setFrameFontWeight(int id, String weight) {
1498 public static void setFrameFontWeight(int id, String weight) { 1498 Font font = ((Frame) UIElementMapper.getCorrespondingUIElement(id)).getFont();
1499 Font font = ((Frame) UIElementMapper.getCorrespondingUIElement(id)).getFont(); 1499
1500 1500 if (weight.equals(BOLDFONT)) {
1501 if (weight.equals(BOLDFONT)) { 1501 if (font.isItalic()) {
1502 if (font.isItalic()) { 1502 font = new Font(font.getName(), Font.ITALIC + Font.BOLD, font.getSize());
1503 font = new Font(font.getName(), Font.ITALIC + Font.BOLD, font.getSize()); 1503 } else {
1504 } else { 1504 font = new Font(font.getName(), Font.BOLD, font.getSize());
1505 font = new Font(font.getName(), Font.BOLD, font.getSize()); 1505 }
1506 } 1506 } else {
1507 } else { 1507 if (font.isItalic()) {
1508 if (font.isItalic()) { 1508 font = new Font(font.getName(), Font.ITALIC, font.getSize());
1509 font = new Font(font.getName(), Font.ITALIC, font.getSize()); 1509 } else {
1510 } else { 1510 font = new Font(font.getName(), Font.PLAIN, font.getSize());
1511 font = new Font(font.getName(), Font.PLAIN, font.getSize()); 1511 }
1512 } 1512 }
1513 } 1513
1514 1514 ((Frame) UIElementMapper.getCorrespondingUIElement(id)).setFont(font);
1515 ((Frame) UIElementMapper.getCorrespondingUIElement(id)).setFont(font); 1515 }
1516 } 1516
1517 1517 /**
1518 /** 1518 * Set the angle of a Frame font
1519 * Set the angle of a Frame font 1519 * @param id the id of the Frame
1520 * @param id the id of the Frame 1520 * @param angle the angle of the Frame font
1521 * @param angle the angle of the Frame font 1521 */
1522 */ 1522 public static void setFrameFontAngle(int id, String angle) {
1523 public static void setFrameFontAngle(int id, String angle) { 1523 Font font = ((Frame) UIElementMapper.getCorrespondingUIElement(id)).getFont();
1524 Font font = ((Frame) UIElementMapper.getCorrespondingUIElement(id)).getFont(); 1524
1525 1525 if (angle.equals(ITALICFONT) || angle.equals(OBLIQUEFONT)) {
1526 if (angle.equals(ITALICFONT) || angle.equals(OBLIQUEFONT)) { 1526 if (font.isBold()) {
1527 if (font.isBold()) { 1527 font = new Font(font.getName(), Font.ITALIC + Font.BOLD, font.getSize());
1528 font = new Font(font.getName(), Font.ITALIC + Font.BOLD, font.getSize()); 1528 } else {
1529 } else { 1529 font = new Font(font.getName(), Font.ITALIC, font.getSize());
1530 font = new Font(font.getName(), Font.ITALIC, font.getSize()); 1530 }
1531 } 1531 } else {
1532 } else { 1532 if (font.isBold()) {
1533 if (font.isBold()) { 1533 font = new Font(font.getName(), Font.BOLD, font.getSize());
1534 font = new Font(font.getName(), Font.BOLD, font.getSize()); 1534 } else {
1535 } else { 1535 font = new Font(font.getName(), Font.PLAIN, font.getSize());
1536 font = new Font(font.getName(), Font.PLAIN, font.getSize()); 1536 }
1537 } 1537 }
1538 } 1538
1539 1539 ((Frame) UIElementMapper.getCorrespondingUIElement(id)).setFont(font);
1540 ((Frame) UIElementMapper.getCorrespondingUIElement(id)).setFont(font); 1540 }
1541 } 1541
1542 1542 /**
1543 /** 1543 * Set the size of a Frame font
1544 * Set the size of a Frame font 1544 * @param id the id of the Frame
1545 * @param id the id of the Frame 1545 * @param size the size of the Frame font
1546 * @param size the size of the Frame font 1546 */
1547 */ 1547 public static void setFrameFontSize(int id, int size) {
1548 public static void setFrameFontSize(int id, int size) { 1548 Font font = ((Frame) UIElementMapper.getCorrespondingUIElement(id)).getFont();
1549 Font font = ((Frame) UIElementMapper.getCorrespondingUIElement(id)).getFont(); 1549 font = new Font(font.getName(), font.getStyle(), size);
1550 font = new Font(font.getName(), font.getStyle(), size); 1550 ((Frame) UIElementMapper.getCorrespondingUIElement(id)).setFont(font);
1551 ((Frame) UIElementMapper.getCorrespondingUIElement(id)).setFont(font); 1551 }
1552 } 1552
1553 1553 /**
1554 /** 1554 * Get the size of a Frame font
1555 * Get the size of a Frame font 1555 * @param id the id of the Frame
1556 * @param id the id of the Frame 1556 * @return the size of the Frame font
1557 * @return the size of the Frame font 1557 */
1558 */ 1558 public static int getFrameFontSize(int id) {
1559 public static int getFrameFontSize(int id) { 1559 return ((Frame) UIElementMapper.getCorrespondingUIElement(id)).getFont().getSize();
1560 return ((Frame) UIElementMapper.getCorrespondingUIElement(id)).getFont().getSize(); 1560 }
1561 } 1561
1562 1562 /**
1563 /** 1563 * Set the name of a Frame font
1564 * Set the name of a Frame font 1564 * @param id the id of the Frame
1565 * @param id the id of the Frame 1565 * @param name the name of the Frame font
1566 * @param name the name of the Frame font 1566 */
1567 */ 1567 public static void setFrameFontName(int id, String name) {
1568 public static void setFrameFontName(int id, String name) { 1568 Font font = ((Frame) UIElementMapper.getCorrespondingUIElement(id)).getFont();
1569 Font font = ((Frame) UIElementMapper.getCorrespondingUIElement(id)).getFont(); 1569 font = new Font(name, font.getStyle(), font.getSize());
1570 font = new Font(name, font.getStyle(), font.getSize()); 1570 ((Frame) UIElementMapper.getCorrespondingUIElement(id)).setFont(font);
1571 ((Frame) UIElementMapper.getCorrespondingUIElement(id)).setFont(font); 1571 }
1572 } 1572
1573 1573 /**
1574 /** 1574 * Get the name of a Frame font
1575 * Get the name of a Frame font 1575 * @param id the id of the Frame
1576 * @param id the id of the Frame 1576 * @return the name of the Frame font
1577 * @return the name of the Frame font 1577 */
1578 */ 1578 public static String getFrameFontName(int id) {
1579 public static String getFrameFontName(int id) { 1579 return ((Frame) UIElementMapper.getCorrespondingUIElement(id)).getFont().getName();
1580 return ((Frame) UIElementMapper.getCorrespondingUIElement(id)).getFont().getName(); 1580 }
1581 } 1581
1582 1582 /**************************/
1583 /**************************/ 1583 /* */
1584 /* */ 1584 /* OBJECT POSITION BRIDGE */
1585 /* OBJECT POSITION BRIDGE */ 1585 /* */
1586 /* */ 1586 /**************************/
1587 /**************************/ 1587
1588 1588 /**
1589 /** 1589 * Set the position (in Scilab terms) of a Widget
1590 * Set the position (in Scilab terms) of a Widget 1590 * @param id the id of the Widget
1591 * @param id the id of the Widget 1591 * @param x the X-coordinate for the Widget
1592 * @param x the X-coordinate for the Widget 1592 * @param y the Y-coordinate for the Widget
1593 * @param y the Y-coordinate for the Widget 1593 * @param width the width of the Widget
1594 * @param width the width of the Widget 1594 * @param height the height of the Widget
1595 * @param height the height of the Widget 1595 */
1596 */ 1596 public static void setWidgetPosition(int id, int x, int y, int width, int height) {
1597 public static void setWidgetPosition(int id, int x, int y, int width, int height) { 1597 /* Dimensions must be set before position beacause of PositionConverter */
1598 /* Dimensions must be set before position beacause of PositionConverter */ 1598 UIElementMapper.getCorrespondingUIElement(id).setDims(new Size(width, height));
1599 UIElementMapper.getCorrespondingUIElement(id).setDims(new Size(width, height)); 1599 UIElementMapper.getCorrespondingUIElement(id).setPosition(new Position(x, y));
1600 UIElementMapper.getCorrespondingUIElement(id).setPosition(new Position(x, y)); 1600 }
1601 } 1601
1602 1602 /**
1603 /** 1603 * Get the position (in Scilab terms) of a widget
1604 * Get the position (in Scilab terms) of a widget 1604 * @param id the id of the widget
1605 * @param id the id of the widget 1605 * @return the position (X-coordinate, Y-coordinate, width, height) of the button
1606 * @return the position (X-coordinate, Y-coordinate, width, height) of the button 1606 */
1607 */ 1607 public static int[] getWidgetPosition(int id) {
1608 public static int[] getWidgetPosition(int id) { 1608 int[] position = new int[POSITION_SIZE];
1609 int[] position = new int[POSITION_SIZE]; 1609
1610 1610 position[X_INDEX] = ((Widget) UIElementMapper.getCorrespondingUIElement(id)).getPosition().getX();
1611 position[X_INDEX] = ((Widget) UIElementMapper.getCorrespondingUIElement(id)).getPosition().getX(); 1611 position[Y_INDEX] = ((Widget) UIElementMapper.getCorrespondingUIElement(id)).getPosition().getY();
1612 position[Y_INDEX] = ((Widget) UIElementMapper.getCorrespondingUIElement(id)).getPosition().getY(); 1612 position[WIDTH_INDEX] = ((Widget) UIElementMapper.getCorrespondingUIElement(id)).getDims().getWidth();
1613 position[WIDTH_INDEX] = ((Widget) UIElementMapper.getCorrespondingUIElement(id)).getDims().getWidth(); 1613 position[HEIGHT_INDEX] = ((Widget) UIElementMapper.getCorrespondingUIElement(id)).getDims().getHeight();
1614 position[HEIGHT_INDEX] = ((Widget) UIElementMapper.getCorrespondingUIElement(id)).getDims().getHeight(); 1614
1615 1615 return position;
1616 return position; 1616 }
1617 } 1617
1618 1618 /**
1619 /** 1619 * Set the position (in Scilab terms) of a Frame
1620 * Set the position (in Scilab terms) of a Frame 1620 * @param id the id of the Frame
1621 * @param id the id of the Frame 1621 * @param x the X-coordinate for the Frame
1622 * @param x the X-coordinate for the Frame 1622 * @param y the Y-coordinate for the Frame
1623 * @param y the Y-coordinate for the Frame 1623 * @param width the width of the Frame
1624 * @param width the width of the Frame 1624 * @param height the height of the Frame
1625 * @param height the height of the Frame 1625 */
1626 */ 1626 public static void setFramePosition(int id, int x, int y, int width, int height) {
1627 public static void setFramePosition(int id, int x, int y, int width, int height) { 1627 /* Dimensions must be set before position beacause of PositionConverter */
1628 /* Dimensions must be set before position beacause of PositionConverter */ 1628 UIElementMapper.getCorrespondingUIElement(id).setDims(new Size(width, height));
1629 UIElementMapper.getCorrespondingUIElement(id).setDims(new Size(width, height)); 1629 UIElementMapper.getCorrespondingUIElement(id).setPosition(new Position(x, y));
1630 UIElementMapper.getCorrespondingUIElement(id).setPosition(new Position(x, y)); 1630 }
1631 } 1631
1632 1632 /**
1633 /** 1633 * Get the position (in Scilab terms) of a Frame
1634 * Get the position (in Scilab terms) of a Frame 1634 * @param id the id of the Frame
1635 * @param id the id of the Frame 1635 * @return the position (X-coordinate, Y-coordinate, width, height) of the button
1636 * @return the position (X-coordinate, Y-coordinate, width, height) of the button 1636 */
1637 */ 1637 public static int[] getFramePosition(int id) {
1638 public static int[] getFramePosition(int id) { 1638 int[] position = new int[POSITION_SIZE];
1639 int[] position = new int[POSITION_SIZE]; 1639
1640 1640 position[X_INDEX] = ((Frame) UIElementMapper.getCorrespondingUIElement(id)).getPosition().getX();
1641 position[X_INDEX] = ((Frame) UIElementMapper.getCorrespondingUIElement(id)).getPosition().getX(); 1641 position[Y_INDEX] = ((Frame) UIElementMapper.getCorrespondingUIElement(id)).getPosition().getY();
1642 position[Y_INDEX] = ((Frame) UIElementMapper.getCorrespondingUIElement(id)).getPosition().getY(); 1642 position[WIDTH_INDEX] = ((Frame) UIElementMapper.getCorrespondingUIElement(id)).getDims().getWidth();
1643 position[WIDTH_INDEX] = ((Frame) UIElementMapper.getCorrespondingUIElement(id)).getDims().getWidth(); 1643 position[HEIGHT_INDEX] = ((Frame) UIElementMapper.getCorrespondingUIElement(id)).getDims().getHeight();
1644 position[HEIGHT_INDEX] = ((Frame) UIElementMapper.getCorrespondingUIElement(id)).getDims().getHeight(); 1644
1645 1645 return position;
1646 return position; 1646 }
1647 } 1647
1648 1648 /***************************/
1649 /***************************/ 1649 /* */
1650 /* */ 1650 /* OBJECT ALIGNMENT BRIDGE */
1651 /* OBJECT ALIGNMENT BRIDGE */ 1651 /* */
1652 /* */ 1652 /***************************/
1653 /***************************/ 1653
1654 1654 /**
1655 /** 1655 * Set the horizontal alignment for the Widget text
1656 * Set the horizontal alignment for the Widget text 1656 * @param id the id of the Widget
1657 * @param id the id of the Widget 1657 * @param alignment the value for the alignment (See ScilabAlignment.java)
1658 * @param alignment the value for the alignment (See ScilabAlignment.java) 1658 */
1659 */ 1659 public static void setWidgetHorizontalAlignment(int id, String alignment) {
1660 public static void setWidgetHorizontalAlignment(int id, String alignment) { 1660 ((Widget) UIElementMapper.getCorrespondingUIElement(id)).setHorizontalAlignment(alignment);
1661 ((Widget) UIElementMapper.getCorrespondingUIElement(id)).setHorizontalAlignment(alignment); 1661 }
1662 } 1662
1663 1663 /**
1664 /** 1664 * Set the vertical alignment for the Widget text
1665 * Set the vertical alignment for the Widget text 1665 * @param id the id of the Widget
1666 * @param id the id of the Widget 1666 * @param alignment the value for the alignment (See ScilabAlignment.java)
1667 * @param alignment the value for the alignment (See ScilabAlignment.java) 1667 */
1668 */ 1668 public static void setWidgetVerticalAlignment(int id, String alignment) {
1669 public static void setWidgetVerticalAlignment(int id, String alignment) { 1669 ((Widget) UIElementMapper.getCorrespondingUIElement(id)).setVerticalAlignment(alignment);
1670 ((Widget) UIElementMapper.getCorrespondingUIElement(id)).setVerticalAlignment(alignment); 1670 }
1671 } 1671
1672 1672 /**********************/
1673 /**********************/ 1673 /* */
1674 /* */ 1674 /* SLIDER STEP BRIDGE */
1675 /* SLIDER STEP BRIDGE */ 1675 /* */
1676 /* */ 1676 /**********************/
1677 /**********************/ 1677
1678 1678 /**
1679 /** 1679 * Set the minor tick spacing for a Slider
1680 * Set the minor tick spacing for a Slider 1680 * @param id the id of the Slider
1681 * @param id the id of the Slider 1681 * @param space the increment value
1682 * @param space the increment value 1682 */
1683 */ 1683 public static void setSliderMinorTickSpacing(int id, int space) {
1684 public static void setSliderMinorTickSpacing(int id, int space) { 1684 ((Slider) UIElementMapper.getCorrespondingUIElement(id)).setMinorTickSpacing(space);
1685 ((Slider) UIElementMapper.getCorrespondingUIElement(id)).setMinorTickSpacing(space); 1685 }
1686 } 1686
1687 1687 /**
1688 /** 1688 * Set the major tick spacing for a Slider
1689 * Set the major tick spacing for a Slider 1689 * @param id the id of the Slider
1690 * @param id the id of the Slider 1690 * @param space the increment value
1691 * @param space the increment value 1691 */
1692 */ 1692 public static void setSliderMajorTickSpacing(int id, int space) {
1693 public static void setSliderMajorTickSpacing(int id, int space) { 1693 ((Slider) UIElementMapper.getCorrespondingUIElement(id)).setMajorTickSpacing(space);
1694 ((Slider) UIElementMapper.getCorrespondingUIElement(id)).setMajorTickSpacing(space); 1694 }
1695 } 1695
1696 1696 /*************************/
1697 /*************************/ 1697 /* */
1698 /* */ 1698 /* SLIDER MIN/MAX BRIDGE */
1699 /* SLIDER MIN/MAX BRIDGE */ 1699 /* */
1700 /* */ 1700 /*************************/
1701 /*************************/ 1701
1702 1702 /**
1703 /** 1703 * Set the minimum value of a Slider
1704 * Set the minimum value of a Slider 1704 * @param id the id of the Slider
1705 * @param id the id of the Slider 1705 * @param value the minimum value
1706 * @param value the minimum value 1706 */
1707 */ 1707 public static void setSliderMinValue(int id, int value) {
1708 public static void setSliderMinValue(int id, int value) { 1708 ((Slider) UIElementMapper.getCorrespondingUIElement(id)).setMinimumValue(value);
1709 ((Slider) UIElementMapper.getCorrespondingUIElement(id)).setMinimumValue(value); 1709 }
1710 } 1710
1711 1711 /**
1712 /** 1712 * Set the maximum value of a Slider
1713 * Set the maximum value of a Slider 1713 * @param id the id of the Widget
1714 * @param id the id of the Widget 1714 * @param value the maximum value
1715 * @param value the maximum value 1715 */
1716 */ 1716 public static void setSliderMaxValue(int id, int value) {
1717 public static void setSliderMaxValue(int id, int value) { 1717 ((Slider) UIElementMapper.getCorrespondingUIElement(id)).setMaximumValue(value);
1718 ((Slider) UIElementMapper.getCorrespondingUIElement(id)).setMaximumValue(value); 1718 }
1719 } 1719
1720 1720 /*****************************/
1721 /*****************************/ 1721 /* */
1722 /* */ 1722 /* SLIDER ORIENTATION BRIDGE */
1723 /* SLIDER ORIENTATION BRIDGE */ 1723 /* */
1724 /* */ 1724 /*****************************/
1725 /*****************************/ 1725
1726 1726 /**
1727 /** 1727 * Set the slider orientation to vertical
1728 * Set the slider orientation to vertical 1728 * @param id the id of the slider
1729 * @param id the id of the slider 1729 */
1730 */ 1730 public static void setSliderVertical(int id) {
1731 public static void setSliderVertical(int id) { 1731 ((Slider) UIElementMapper.getCorrespondingUIElement(id)).setVertical();
1732 ((Slider) UIElementMapper.getCorrespondingUIElement(id)).setVertical(); 1732 }
1733 } 1733
1734 1734 /**
1735 /** 1735 * Set the slider orientation to horizontal
1736 * Set the slider orientation to horizontal 1736 * @param id the id of the slider
1737 * @param id the id of the slider 1737 */
1738 */ 1738 public static void setSliderHorizontal(int id) {
1739 public static void setSliderHorizontal(int id) { 1739 ((Slider) UIElementMapper.getCorrespondingUIElement(id)).setHorizontal();
1740 ((Slider) UIElementMapper.getCorrespondingUIElement(id)).setHorizontal(); 1740 }
1741 } 1741
1742 1742 /******************/
1743 /******************/ 1743 /* */
1744 /* */ 1744 /* LISTBOX BRIDGE */
1745 /* LISTBOX BRIDGE */ 1745 /* */
1746 /* */ 1746 /******************/
1747 /******************/ 1747
1748 1748 /**
1749 /** 1749 * Set if more than one item can be selected in a ListBox
1750 * Set if more than one item can be selected in a ListBox 1750 * @param id the id of the ListBox
1751 * @param id the id of the ListBox 1751 * @param status true if multiple selection is enabled
1752 * @param status true if multiple selection is enabled 1752 */
1753 */ 1753 public static void setListBoxMultipleSelectionEnabled(int id, boolean status) {
1754 public static void setListBoxMultipleSelectionEnabled(int id, boolean status) { 1754 ((ListBox) UIElementMapper.getCorrespondingUIElement(id)).setMultipleSelectionEnabled(status);
1755 ((ListBox) UIElementMapper.getCorrespondingUIElement(id)).setMultipleSelectionEnabled(status); 1755 }
1756 } 1756
1757 1757 /**
1758 /** 1758 * Get the text of all the list items
1759 * Get the text of all the list items 1759 * @param id the id of the ListBox
1760 * @param id the id of the ListBox 1760 * @return the text items
1761 * @return the text items 1761 * @see org.scilab.modules.gui.listbox.ListBox#getAllItemsText()
1762 * @see org.scilab.modules.gui.listbox.ListBox#getAllItemsText() 1762 */
1763 */ 1763 public static String[] getListBoxAllItemsText(int id) {
1764 public static String[] getListBoxAllItemsText(int id) { 1764 return ((ListBox) UIElementMapper.getCorrespondingUIElement(id)).getAllItemsText();
1765 return ((ListBox) UIElementMapper.getCorrespondingUIElement(id)).getAllItemsText(); 1765 }
1766 } 1766
1767 1767 /**
1768 /** 1768 * Get the number of items in the list
1769 * Get the number of items in the list 1769 * @param id the id of the ListBox
1770 * @param id the id of the ListBox 1770 * @return the number of items
1771 * @return the number of items 1771 * @see org.scilab.modules.gui.listbox.ListBox#getNumberOfItems()
1772 * @see org.scilab.modules.gui.listbox.ListBox#getNumberOfItems() 1772 */
1773 */ 1773 public static int getListBoxNumberOfItems(int id) {
1774 public static int getListBoxNumberOfItems(int id) { 1774 return ((ListBox) UIElementMapper.getCorrespondingUIElement(id)).getNumberOfItems();
1775 return ((ListBox) UIElementMapper.getCorrespondingUIElement(id)).getNumberOfItems(); 1775 }
1776 } 1776
1777 1777 /**
1778 /** 1778 * Set the text of the list items
1779 * Set the text of the list items 1779 * @param id the id of the ListBox
1780 * @param id the id of the ListBox 1780 * @param text the text of the items
1781 * @param text the text of the items 1781 * @see org.scilab.modules.gui.listbox.ListBox#setText(java.lang.String[])
1782 * @see org.scilab.modules.gui.listbox.ListBox#setText(java.lang.String[]) 1782 */
1783 */ 1783 public static void setListBoxText(int id, String[] text) {
1784 public static void setListBoxText(int id, String[] text) { 1784 ((ListBox) UIElementMapper.getCorrespondingUIElement(id)).setText(text);
1785 ((ListBox) UIElementMapper.getCorrespondingUIElement(id)).setText(text); 1785 }
1786 } 1786
1787 1787 /**
1788 /** 1788 * Adjusts the view so that the element given by index is displayed at the top of the ListBox.
1789 * Adjusts the view so that the element given by index is displayed at the top of the ListBox. 1789 * @param id the id of the ListBox
1790 * @param id the id of the ListBox 1790 * @param index the index of the element to be displayed at the top of the ListBox.
1791 * @param index the index of the element to be displayed at the top of the ListBox. 1791 */
1792 */ 1792 public static void setListBoxListBoxTop(int id, int index) {
1793 public static void setListBoxListBoxTop(int id, int index) { 1793 ((ListBox) UIElementMapper.getCorrespondingUIElement(id)).setListBoxTop(index);
1794 ((ListBox) UIElementMapper.getCorrespondingUIElement(id)).setListBoxTop(index); 1794 }
1795 } 1795
1796 1796 /**
1797 /** 1797 * Gets the index of the element displayed at the top of the ListBox
1798 * Gets the index of the element displayed at the top of the ListBox 1798 * @param id the id of the ListBox
1799 * @param id the id of the ListBox 1799 * @return the index of the element displayed at the top of the ListBox
1800 * @return the index of the element displayed at the top of the ListBox 1800 */
1801 */ 1801 public static int getListBoxListBoxTop(int id) {
1802 public static int getListBoxListBoxTop(int id) { 1802 return ((ListBox) UIElementMapper.getCorrespondingUIElement(id)).getListBoxTop();
1803 return ((ListBox) UIElementMapper.getCorrespondingUIElement(id)).getListBoxTop(); 1803 }
1804 } 1804
1805 1805 /********************/
1806 /********************/ 1806 /* */
1807 /* */ 1807 /* POPUPMENU BRIDGE */
1808 /* POPUPMENU BRIDGE */ 1808 /* */
1809 /* */ 1809 /********************/
1810 /********************/ 1810
1811 1811 /**
1812 /** 1812 * Get the text of all the PopupMenu items
1813 * Get the text of all the PopupMenu items 1813 * @param id the id of the PopupMenu
1814 * @param id the id of the PopupMenu 1814 * @return the text items
1815 * @return the text items 1815 * @see org.scilab.modules.gui.popupmenu.PopupMenu#getAllItemsText()
1816 * @see org.scilab.modules.gui.popupmenu.PopupMenu#getAllItemsText() 1816 */
1817 */ 1817 public static String[] getPopupMenuAllItemsText(int id) {
1818 public static String[] getPopupMenuAllItemsText(int id) { 1818 return ((PopupMenu) UIElementMapper.getCorrespondingUIElement(id)).getAllItemsText();
1819 return ((PopupMenu) UIElementMapper.getCorrespondingUIElement(id)).getAllItemsText(); 1819 }
1820 } 1820
1821 1821 /**
1822 /** 1822 * Get the number of items in the PopupMenu
1823 * Get the number of items in the PopupMenu 1823 * @param id the id of the PopupMenu
1824 * @param id the id of the PopupMenu 1824 * @return the number of items
1825 * @return the number of items 1825 * @see org.scilab.modules.gui.popupmenu.PopupMenu#getNumberOfItems()
1826 * @see org.scilab.modules.gui.popupmenu.PopupMenu#getNumberOfItems() 1826 */
1827 */ 1827 public static int getPopupMenuNumberOfItems(int id) {
1828 public static int getPopupMenuNumberOfItems(int id) { 1828 return ((PopupMenu) UIElementMapper.getCorrespondingUIElement(id)).getNumberOfItems();
1829 return ((PopupMenu) UIElementMapper.getCorrespondingUIElement(id)).getNumberOfItems(); 1829 }
1830 } 1830
1831 1831 /**
1832 /** 1832 * Set the text of the PopupMenu items
1833 * Set the text of the PopupMenu items 1833 * @param id the id of the PopupMenu
1834 * @param id the id of the PopupMenu 1834 * @param text the text of the items
1835 * @param text the text of the items 1835 * @see org.scilab.modules.gui.popupmenu.PopupMenu#setText(java.lang.String[])
1836 * @see org.scilab.modules.gui.popupmenu.PopupMenu#setText(java.lang.String[]) 1836 */
1837 */ 1837 public static void setPopupMenuText(int id, String[] text) {
1838 public static void setPopupMenuText(int id, String[] text) { 1838 ((PopupMenu) UIElementMapper.getCorrespondingUIElement(id)).setText(text);
1839 ((PopupMenu) UIElementMapper.getCorrespondingUIElement(id)).setText(text); 1839 }
1840 } 1840
1841 1841 /****************/
1842 /****************/ 1842 /* */
1843 /* */ 1843 /* VALUE BRIDGE */
1844 /* VALUE BRIDGE */ 1844 /* */
1845 /* */ 1845 /****************/
1846 /****************/ 1846
1847 1847 /**
1848 /** 1848 * Set the selected indices of the ListBox
1849 * Set the selected indices of the ListBox 1849 * @param id the id of the ListBox
1850 * @param id the id of the ListBox 1850 * @param indices the indices of the items to be selected
1851 * @param indices the indices of the items to be selected 1851 */
1852 */ 1852 public static void setListBoxSelectedIndices(int id, int[] indices) {
1853 public static void setListBoxSelectedIndices(int id, int[] indices) { 1853 ((ListBox) UIElementMapper.getCorrespondingUIElement(id)).setSelectedIndices(indices);
1854 ((ListBox) UIElementMapper.getCorrespondingUIElement(id)).setSelectedIndices(indices); 1854 }
1855 } 1855
1856 1856 /**
1857 /** 1857 * Get the selected indices of the ListBox
1858 * Get the selected indices of the ListBox 1858 * @param id the id of the ListBox
1859 * @param id the id of the ListBox 1859 * @return the indices of the items selected
1860 * @return the indices of the items selected 1860 */
1861 */ 1861 public static int[] getListBoxSelectedIndices(int id) {
1862 public static int[] getListBoxSelectedIndices(int id) { 1862 return ((ListBox) UIElementMapper.getCorrespondingUIElement(id)).getSelectedIndices();
1863 return ((ListBox) UIElementMapper.getCorrespondingUIElement(id)).getSelectedIndices(); 1863 }
1864 } 1864
1865 1865 /**
1866 /** 1866 * Get the number of items selected in the ListBox
1867 * Get the number of items selected in the ListBox 1867 * @param id the id of the ListBox
1868 * @param id the id of the ListBox 1868 * @return the number of items selected
1869 * @return the number of items selected 1869 */
1870 */ 1870 public static int getListBoxSelectionSize(int id) {
1871 public static int getListBoxSelectionSize(int id) { 1871 return ((ListBox) UIElementMapper.getCorrespondingUIElement(id)).getSelectionSize();
1872 return ((ListBox) UIElementMapper.getCorrespondingUIElement(id)).getSelectionSize(); 1872 }
1873 } 1873
1874 1874 /**
1875 /** 1875 * Set the selected index of the PopupMenu
1876 * Set the selected index of the PopupMenu 1876 * @param id the id of the PopupMenu
1877 * @param id the id of the PopupMenu 1877 * @param index the index of the item to be selected
1878 * @param index the index of the item to be selected 1878 */
1879 */ 1879 public static void setPopupMenuSelectedIndex(int id, int index) {
1880 public static void setPopupMenuSelectedIndex(int id, int index) { 1880 ((PopupMenu) UIElementMapper.getCorrespondingUIElement(id)).setUserSelectedIndex(index);
1881 ((PopupMenu) UIElementMapper.getCorrespondingUIElement(id)).setUserSelectedIndex(index); 1881 }
1882 } 1882
1883 1883 /**
1884 /** 1884 * Get the selected index of the PopupMenu
1885 * Get the selected index of the PopupMenu 1885 * @param id the id of the PopupMenu
1886 * @param id the id of the PopupMenu 1886 * @return the index of the item selected
1887 * @return the index of the item selected 1887 */
1888 */ 1888 public static int getPopupMenuSelectedIndex(int id) {
1889 public static int getPopupMenuSelectedIndex(int id) { 1889 return ((PopupMenu) UIElementMapper.getCorrespondingUIElement(id)).getUserSelectedIndex();
1890 return ((PopupMenu) UIElementMapper.getCorrespondingUIElement(id)).getUserSelectedIndex(); 1890 }
1891 } 1891
1892 1892 /**
1893 /** 1893 * Get the current value of the Slider
1894 * Get the current value of the Slider 1894 * @param id the id of the Slider
1895 * @param id the id of the Slider 1895 * @return the current value of the Slider
1896 * @return the current value of the Slider 1896 */
1897 */ 1897 public static int getSliderValue(int id) {
1898 public static int getSliderValue(int id) { 1898 return ((Slider) UIElementMapper.getCorrespondingUIElement(id)).getValue();
1899 return ((Slider) UIElementMapper.getCorrespondingUIElement(id)).getValue(); 1899 }
1900 } 1900
1901 1901 /**
1902 /** 1902 * Sets the current value of the Slider
1903 * Sets the current value of the Slider 1903 * @param id the id of the Slider
1904 * @param id the id of the Slider 1904 * @param value the new value
1905 * @param value the new value 1905 */
1906 */ 1906 public static void setSliderValue(int id, int value) {
1907 public static void setSliderValue(int id, int value) { 1907 ((Slider) UIElementMapper.getCorrespondingUIElement(id)).setUserValue(value);
1908 ((Slider) UIElementMapper.getCorrespondingUIElement(id)).setUserValue(value); 1908 }
1909 } 1909
1910 1910 /**
1911 /** 1911 * Set if the RadioButton is checked or not
1912 * Set if the RadioButton is checked or not 1912 * @param id the id of the RadioButton
1913 * @param id the id of the RadioButton 1913 * @param status true to set the RadioButton checked
1914 * @param status true to set the RadioButton checked 1914 */
1915 */ 1915 public static void setRadioButtonChecked(int id, boolean status) {
1916 public static void setRadioButtonChecked(int id, boolean status) { 1916 ((RadioButton) UIElementMapper.getCorrespondingUIElement(id)).setChecked(status);
1917 ((RadioButton) UIElementMapper.getCorrespondingUIElement(id)).setChecked(status); 1917 }
1918 } 1918
1919 1919 /**
1920 /** 1920 * Get the status of the RadioButton
1921 * Get the status of the RadioButton 1921 * @param id the id of the RadioButton
1922 * @param id the id of the RadioButton 1922 * @return true if the RadioButton is checked
1923 * @return true if the RadioButton is checked 1923 */
1924 */ 1924 public static boolean isRadioButtonChecked(int id) {
1925 public static boolean isRadioButtonChecked(int id) { 1925 return ((RadioButton) UIElementMapper.getCorrespondingUIElement(id)).isChecked();
1926 return ((RadioButton) UIElementMapper.getCorrespondingUIElement(id)).isChecked(); 1926 }
1927 } 1927
1928 1928 /**
1929 /** 1929 * Set if the CheckBox is checked or not
1930 * Set if the CheckBox is checked or not 1930 * @param id the id of the CheckBox
1931 * @param id the id of the CheckBox 1931 * @param status true to set the CheckBox checked
1932 * @param status true to set the CheckBox checked 1932 */
1933 */ 1933 public static void setCheckBoxChecked(int id, boolean status) {
1934 public static void setCheckBoxChecked(int id, boolean status) { 1934 ((CheckBox) UIElementMapper.getCorrespondingUIElement(id)).setChecked(status);
1935 ((CheckBox) UIElementMapper.getCorrespondingUIElement(id)).setChecked(status); 1935 }
1936 } 1936
1937 1937 /**
1938 /** 1938 * Get the status of the CheckBox
1939 * Get the status of the CheckBox 1939 * @param id the id of the CheckBox
1940 * @param id the id of the CheckBox 1940 * @return true if the CheckBox is checked
1941 * @return true if the CheckBox is checked 1941 */
1942 */ 1942 public static boolean isCheckBoxChecked(int id) {
1943 public static boolean isCheckBoxChecked(int id) { 1943 return ((CheckBox) UIElementMapper.getCorrespondingUIElement(id)).isChecked();
1944 return ((CheckBox) UIElementMapper.getCorrespondingUIElement(id)).isChecked(); 1944 }
1945 } 1945
1946 1946 /*****************/
1947 /*****************/ 1947 /* */
1948 /* */ 1948 /* RELIEF BRIDGE */
1949 /* RELIEF BRIDGE */ 1949 /* */
1950 /* */ 1950 /*****************/
1951 /*****************/ 1951
1952 1952 /**
1953 /** 1953 * Set the Relief of the Widget
1954 * Set the Relief of the Widget 1954 * @param id the id of the Widget
1955 * @param id the id of the Widget 1955 * @param reliefType the type of the relief to set (See ScilabRelief.java)
1956 * @param reliefType the type of the relief to set (See ScilabRelief.java) 1956 */
1957 */ 1957 public static void setWidgetRelief(int id, String reliefType) {
1958 public static void setWidgetRelief(int id, String reliefType) { 1958 ((Widget) UIElementMapper.getCorrespondingUIElement(id)).setRelief(reliefType);
1959 ((Widget) UIElementMapper.getCorrespondingUIElement(id)).setRelief(reliefType); 1959 }
1960 } 1960
1961 1961 /**
1962 /** 1962 * Set the Relief of the Frame
1963 * Set the Relief of the Frame 1963 * @param id the id of the Frame
1964 * @param id the id of the Frame 1964 * @param reliefType the type of the relief to set (See ScilabRelief.java)
1965 * @param reliefType the type of the relief to set (See ScilabRelief.java) 1965 */
1966 */ 1966 public static void setFrameReli