summaryrefslogtreecommitdiffstats
path: root/scilab/modules
diff options
context:
space:
mode:
authorSylvestre Ledru <sylvestre.ledru@scilab.org>2010-05-07 18:27:26 +0200
committerClément DAVID <clement.david@scilab.org>2010-05-19 10:10:14 +0200
commit6acaa9709be7728a9296a8f4e0df1437c7e69d36 (patch)
tree18ccd4c2158348c1a37d8f8555d81cccb1a31910 /scilab/modules
parent39bdba1e1e00ccfbe1015a0074a527ca1805eda9 (diff)
downloadscilab-6acaa9709be7728a9296a8f4e0df1437c7e69d36.zip
scilab-6acaa9709be7728a9296a8f4e0df1437c7e69d36.tar.gz
* bug 6893 fixed - Some files +~JF****.tmp where created outside of the Scilab
temporary directory. * bug 6933 fixed - Some temporary files (dict_*.tmp) were created when using search engine of the help browser. Change-Id: I36dd84ae1b24e90e5c3e10301639c3da6599b53a
Diffstat (limited to 'scilab/modules')
-rw-r--r--scilab/modules/helptools/src/java/org/scilab/modules/helptools/BuildDocObject.java2
-rw-r--r--scilab/modules/helptools/src/java/org/scilab/modules/helptools/CopyConvert.java1
-rw-r--r--scilab/modules/jvm/src/java/org/scilab/modules/jvm/Scilab.java415
3 files changed, 213 insertions, 205 deletions
diff --git a/scilab/modules/helptools/src/java/org/scilab/modules/helptools/BuildDocObject.java b/scilab/modules/helptools/src/java/org/scilab/modules/helptools/BuildDocObject.java
index 03affe3..3aa2ce4 100644
--- a/scilab/modules/helptools/src/java/org/scilab/modules/helptools/BuildDocObject.java
+++ b/scilab/modules/helptools/src/java/org/scilab/modules/helptools/BuildDocObject.java
@@ -22,6 +22,8 @@ import org.xml.sax.SAXException;
22 22
23import com.icl.saxon.StyleSheet; /* saxon */ 23import com.icl.saxon.StyleSheet; /* saxon */
24 24
25import org.scilab.modules.jvm.utils.ScilabConstants;
26
25/** 27/**
26 * This classes intends to wrap Saxon features in a easy-to-use class. 28 * This classes intends to wrap Saxon features in a easy-to-use class.
27 */ 29 */
diff --git a/scilab/modules/helptools/src/java/org/scilab/modules/helptools/CopyConvert.java b/scilab/modules/helptools/src/java/org/scilab/modules/helptools/CopyConvert.java
index eb657b5..bef5763 100644
--- a/scilab/modules/helptools/src/java/org/scilab/modules/helptools/CopyConvert.java
+++ b/scilab/modules/helptools/src/java/org/scilab/modules/helptools/CopyConvert.java
@@ -53,6 +53,7 @@ import net.sourceforge.jeuclid.MutableLayoutContext;
53import net.sourceforge.jeuclid.context.LayoutContextImpl; 53import net.sourceforge.jeuclid.context.LayoutContextImpl;
54import net.sourceforge.jeuclid.converter.Converter; 54import net.sourceforge.jeuclid.converter.Converter;
55 55
56import org.scilab.modules.jvm.utils.ScilabConstants;
56import org.scilab.forge.jlatexmath.TeXConstants; 57import org.scilab.forge.jlatexmath.TeXConstants;
57import org.scilab.forge.jlatexmath.TeXFormula; 58import org.scilab.forge.jlatexmath.TeXFormula;
58import org.scilab.forge.jlatexmath.ParseException; 59import org.scilab.forge.jlatexmath.ParseException;
diff --git a/scilab/modules/jvm/src/java/org/scilab/modules/jvm/Scilab.java b/scilab/modules/jvm/src/java/org/scilab/modules/jvm/Scilab.java
index a2328ca..ea440f4 100644
--- a/scilab/modules/jvm/src/java/org/scilab/modules/jvm/Scilab.java
+++ b/scilab/modules/jvm/src/java/org/scilab/modules/jvm/Scilab.java
@@ -32,6 +32,7 @@ import org.scilab.modules.gui.utils.ConfigManager;
32import org.scilab.modules.gui.utils.LookAndFeelManager; 32import org.scilab.modules.gui.utils.LookAndFeelManager;
33import org.scilab.modules.gui.utils.MenuBarBuilder; 33import org.scilab.modules.gui.utils.MenuBarBuilder;
34import org.scilab.modules.gui.utils.ToolBarBuilder; 34import org.scilab.modules.gui.utils.ToolBarBuilder;
35import org.scilab.modules.jvm.utils.ScilabConstants;
35import org.scilab.modules.localization.Messages; 36import org.scilab.modules.localization.Messages;
36 37
37import org.flexdock.docking.DockingConstants; 38import org.flexdock.docking.DockingConstants;
@@ -46,213 +47,217 @@ import org.flexdock.docking.DockingConstants;
46 */ 47 */
47public class Scilab { 48public class Scilab {
48 49
49 private static final String CLASS_NOT_FOUND = "Could not find class: "; 50 private static final String CLASS_NOT_FOUND = "Could not find class: ";
50 51
51 private static final String SEE_DEFAULT_PATHS = "See SCI/etc/classpath.xml for default paths."; 52 private static final String SEE_DEFAULT_PATHS = "See SCI/etc/classpath.xml for default paths.";
52 53
53 /** Index of windows vista version */ 54 /** Index of windows vista version */
54 private static final double VISTA_VERSION = 6.0; 55 private static final double VISTA_VERSION = 6.0;
55 56
56 private static final String ENABLE_JAVA2D_OPENGL_PIPELINE = "sun.java2d.opengl"; 57 private static final String ENABLE_JAVA2D_OPENGL_PIPELINE = "sun.java2d.opengl";
57 private static final String ENABLE = "true"; 58 private static final String ENABLE = "true";
58 private static final String DISABLE = "false"; 59 private static final String DISABLE = "false";
59 private static final String DISABLE_DDRAW = "sun.java2d.noddraw"; 60 private static final String DISABLE_DDRAW = "sun.java2d.noddraw";
60 private static final String OSNAME = "os.name"; 61 private static final String OSNAME = "os.name";
61 private static final String MACOS = "mac"; 62 private static final String MACOS = "mac";
62 63
63 private static String SCIDIR; 64 private static String SCIDIR;
64 65
65 private static String MENUBARXMLFILE; 66 private static String MENUBARXMLFILE;
66 67
67 private static String TOOLBARXMLFILE; 68 private static String TOOLBARXMLFILE;
68 69
69 private Window mainView; 70 private Window mainView;
70 71
71 /** 72 /**
72 * Constructor Scilab Class. 73 * Constructor Scilab Class.
73 * @param mode Mode Scilab -NW -NWNI -STD -API 74 * @param mode Mode Scilab -NW -NWNI -STD -API
74 */ 75 */
75 public Scilab(int mode) { 76 public Scilab(int mode) {
76 77 /**
77 /** 78 * Set Java temporary directory
78 * Set Scilab directory. Note that it is done in the constructor 79 */
79 * and not as directly when setting the member because we had some 80 System.setProperty("java.io.tmpdir",ScilabConstants.TMPDIR.getAbsolutePath());
80 * race condition. See bug #4419 81
81 */ 82 /*
82 try { 83 * Set Scilab directory. Note that it is done in the constructor
83 SCIDIR = System.getenv("SCI"); 84 * and not as directly when setting the member because we had some
84 } catch (Exception e) { 85 * race condition. See bug #4419
85 System.err.println("Cannot retrieve the variable SCI. Please report on http://bugzilla.scilab.org/"); 86 */
86 System.err.println(e.getLocalizedMessage()); 87 try {
87 System.exit(-1); 88 SCIDIR = System.getenv("SCI");
88 } 89 } catch (Exception e) {
89 90 System.err.println("Cannot retrieve the variable SCI. Please report on http://bugzilla.scilab.org/");
90 MENUBARXMLFILE = SCIDIR + "/modules/gui/etc/main_menubar.xml"; 91 System.err.println(e.getLocalizedMessage());
91 TOOLBARXMLFILE = SCIDIR + "/modules/gui/etc/main_toolbar.xml"; 92 System.exit(-1);
92 93 }
93 /** 94
94 * Set options for JOGL 95 MENUBARXMLFILE = SCIDIR + "/modules/gui/etc/main_menubar.xml";
95 * they must be set before creating GUI 96 TOOLBARXMLFILE = SCIDIR + "/modules/gui/etc/main_toolbar.xml";
96 */ 97
97 setJOGLFlags(); 98 /*
98 99 * Set options for JOGL
99 /* 100 * they must be set before creating GUI
100 * if not API mode 101 */
101 * bug 3673 by default in API mode we dont modify look n feel 102 setJOGLFlags();
102 * If SCI_JAVA_ENABLE_HEADLESS is set, do not set the look and feel. 103
103 * (needed when building the documentation under *ux) 104 /*
104 */ 105 * if not API mode
105 if (mode != 1 && System.getenv("SCI_JAVA_ENABLE_HEADLESS") == null) { 106 * bug 3673 by default in API mode we dont modify look n feel
106 /* http://java.sun.com/docs/books/tutorial/uiswing/lookandfeel/plaf.html */ 107 * If SCI_JAVA_ENABLE_HEADLESS is set, do not set the look and feel.
107 try { 108 * (needed when building the documentation under *ux)
108 109 */
109 String scilabLookAndFeel = "javax.swing.plaf.metal.MetalLookAndFeel"; 110 if (mode != 1 && System.getenv("SCI_JAVA_ENABLE_HEADLESS") == null) {
110 111 /* http://java.sun.com/docs/books/tutorial/uiswing/lookandfeel/plaf.html */
111 if (isWindowsPlateform()) { 112 try {
112 scilabLookAndFeel = "com.sun.java.swing.plaf.windows.WindowsLookAndFeel"; 113
113 } else if (System.getProperty(OSNAME).toLowerCase().indexOf(MACOS) != -1) { 114 String scilabLookAndFeel = "javax.swing.plaf.metal.MetalLookAndFeel";
115
116 if (isWindowsPlateform()) {
117 scilabLookAndFeel = "com.sun.java.swing.plaf.windows.WindowsLookAndFeel";
118 } else if (System.getProperty(OSNAME).toLowerCase().indexOf(MACOS) != -1) {
114 /** OPTION ADDED TO ALLOW DOCKING UNDER MACOSX */ 119 /** OPTION ADDED TO ALLOW DOCKING UNDER MACOSX */
115 System.setProperty(DockingConstants.HEAVYWEIGHT_DOCKABLES, ENABLE); 120 System.setProperty(DockingConstants.HEAVYWEIGHT_DOCKABLES, ENABLE);
116 scilabLookAndFeel = "apple.laf.AquaLookAndFeel"; 121 scilabLookAndFeel = "apple.laf.AquaLookAndFeel";
117 } else { 122 } else {
118 scilabLookAndFeel = "com.sun.java.swing.plaf.gtk.GTKLookAndFeel"; 123 scilabLookAndFeel = "com.sun.java.swing.plaf.gtk.GTKLookAndFeel";
119 } 124 }
120 125
121 /* Init the LookAndFeelManager all the time since we can 126 /* Init the LookAndFeelManager all the time since we can
122 * create windows in the NW mode */ 127 * create windows in the NW mode */
123 128
124 LookAndFeelManager lookAndFeel = new LookAndFeelManager(); 129 LookAndFeelManager lookAndFeel = new LookAndFeelManager();
125 130
126 if (lookAndFeel.isSupportedLookAndFeel(scilabLookAndFeel)) { 131 if (lookAndFeel.isSupportedLookAndFeel(scilabLookAndFeel)) {
127 lookAndFeel.setLookAndFeel(scilabLookAndFeel); 132 lookAndFeel.setLookAndFeel(scilabLookAndFeel);
128 } else { 133 } else {
129 lookAndFeel.setSystemLookAndFeel(); 134 lookAndFeel.setSystemLookAndFeel();
130 } 135 }
131 136
132 } catch (java.lang.NoClassDefFoundError exception) { 137 } catch (java.lang.NoClassDefFoundError exception) {
133 System.err.println("Could not initialize graphics Environment"); 138 System.err.println("Could not initialize graphics Environment");
134 System.err.println("Scilab Graphical option may not be working correctly."); 139 System.err.println("Scilab Graphical option may not be working correctly.");
135 System.err.println("An error occurred: " + exception.getLocalizedMessage()); 140 System.err.println("An error occurred: " + exception.getLocalizedMessage());
136 } 141 }
137 } 142 }
138 143
139 if (mode == 2) { /* Mode GUI */ 144 if (mode == 2) { /* Mode GUI */
140 145
141 // Create a user config file if not already exists 146 // Create a user config file if not already exists
142 ConfigManager.createUserCopy(); 147 ConfigManager.createUserCopy();
143 148
144 try { 149 try {
145 mainView = ScilabWindow.createWindow(); 150 mainView = ScilabWindow.createWindow();
146 } catch (NoClassDefFoundError exception) { 151 } catch (NoClassDefFoundError exception) {
147 System.err.println("Cannot create Scilab Window.\n" 152 System.err.println("Cannot create Scilab Window.\n"
148 + "Check if the thirdparties are available (Flexdock, JOGL...).\n" + SEE_DEFAULT_PATHS); 153 + "Check if the thirdparties are available (Flexdock, JOGL...).\n" + SEE_DEFAULT_PATHS);
149 System.err.println(CLASS_NOT_FOUND + exception.getLocalizedMessage()); 154 System.err.println(CLASS_NOT_FOUND + exception.getLocalizedMessage());
150 System.exit(-1); 155 System.exit(-1);
151 } catch (java.awt.HeadlessException exception) { 156 } catch (java.awt.HeadlessException exception) {
152 System.err.println("Error during the initialization of the window: " + exception.getLocalizedMessage()); 157 System.err.println("Error during the initialization of the window: " + exception.getLocalizedMessage());
153 System.exit(-1); 158 System.exit(-1);
154 } 159 }
155 160
156 mainView.setPosition(ConfigManager.getMainWindowPosition()); 161 mainView.setPosition(ConfigManager.getMainWindowPosition());
157 mainView.setDims(ConfigManager.getMainWindowSize()); 162 mainView.setDims(ConfigManager.getMainWindowSize());
158 163
159 /************/ 164 /************/
160 /* MENU BAR */ 165 /* MENU BAR */
161 /************/ 166 /************/
162 MenuBar menuBar = MenuBarBuilder.buildMenuBar(MENUBARXMLFILE); 167 MenuBar menuBar = MenuBarBuilder.buildMenuBar(MENUBARXMLFILE);
163 168
164 /************/ 169 /************/
165 /* TOOL BAR */ 170 /* TOOL BAR */
166 /************/ 171 /************/
167 ToolBar toolBar = ToolBarBuilder.buildToolBar(TOOLBARXMLFILE); 172 ToolBar toolBar = ToolBarBuilder.buildToolBar(TOOLBARXMLFILE);
168 173
169 /* Create the console */ 174 /* Create the console */
170 Tab consoleTab = null; 175 Tab consoleTab = null;
171 try { 176 try {
172 /* CONSOLE */ 177 /* CONSOLE */
173 /* Create a tab to put console into */ 178 /* Create a tab to put console into */
174 consoleTab = ScilabTab.createTab(Messages.gettext("Scilab Console")); 179 consoleTab = ScilabTab.createTab(Messages.gettext("Scilab Console"));
175 /* Exit Scilab when the console is closed */ 180 /* Exit Scilab when the console is closed */
176 consoleTab.setCallback(CallBack.createCallback("exit();", CallBack.SCILAB_INSTRUCTION)); 181 consoleTab.setCallback(CallBack.createCallback("exit();", CallBack.SCILAB_INSTRUCTION));
177 182
178 ScilabConsole.createConsole(); 183 ScilabConsole.createConsole();
179 } catch (NoClassDefFoundError exception) { 184 } catch (NoClassDefFoundError exception) {
180 System.err.println("Cannot create Scilab Console.\nCheck if the thirdparties are available (JoGL/JRosetta...).\n" 185 System.err.println("Cannot create Scilab Console.\nCheck if the thirdparties are available (JoGL/JRosetta...).\n"
181 + SEE_DEFAULT_PATHS); 186 + SEE_DEFAULT_PATHS);
182 System.err.println(CLASS_NOT_FOUND + exception.getLocalizedMessage()); 187 System.err.println(CLASS_NOT_FOUND + exception.getLocalizedMessage());
183 System.exit(-1); 188 System.exit(-1);
184 } 189 }
185 190
186 TextBox infoBar = ScilabTextBox.createTextBox(); 191 TextBox infoBar = ScilabTextBox.createTextBox();
187 192
188 /** Adding content into container */ 193 /** Adding content into container */
189 toolBar.setVisible(false); // Enabled in scilab.start 194 toolBar.setVisible(false); // Enabled in scilab.start
190 ScilabConsole.getConsole().addToolBar(toolBar); 195 ScilabConsole.getConsole().addToolBar(toolBar);
191 ScilabConsole.getConsole().addMenuBar(menuBar); 196 ScilabConsole.getConsole().addMenuBar(menuBar);
192 ScilabConsole.getConsole().addInfoBar(infoBar); 197 ScilabConsole.getConsole().addInfoBar(infoBar);
193 ScilabConsole.getConsole().setMaxOutputSize(ConfigManager.getMaxOutputSize()); 198 ScilabConsole.getConsole().setMaxOutputSize(ConfigManager.getMaxOutputSize());
194 consoleTab.addMember(ScilabConsole.getConsole()); 199 consoleTab.addMember(ScilabConsole.getConsole());
195 mainView.addTab(consoleTab); 200 mainView.addTab(consoleTab);
196 mainView.draw(); 201 mainView.draw();
197 } 202 }
198 203
199 } 204 }
200 205
201 /** 206 /**
202 * Sets the prompt displayed in Scilab console 207 * Sets the prompt displayed in Scilab console
203 * @param prompt the prompt to be displayed as a String 208 * @param prompt the prompt to be displayed as a String
204 */ 209 */
205 public void setPrompt(String prompt) { 210 public void setPrompt(String prompt) {
206 ScilabConsole.getConsole().setPrompt(prompt); 211 ScilabConsole.getConsole().setPrompt(prompt);
207 } 212 }
208 213
209 /** 214 /**
210 * Set the command line flags to the JVM 215 * Set the command line flags to the JVM
211 */ 216 */
212 public static void setJOGLFlags() { 217 public static void setJOGLFlags() {
213 218
214 // Must give popUpMenu heavy weight 219 // Must give popUpMenu heavy weight
215 // in case we enable GLCanvas 220 // in case we enable GLCanvas
216 JPopupMenu.setDefaultLightWeightPopupEnabled(false); 221 JPopupMenu.setDefaultLightWeightPopupEnabled(false);
217 // Uneash OpenGL power 222 // Uneash OpenGL power
218 // Not yet 223 // Not yet
219 //System.setProperty(ENABLE_JAVA2D_OPENGL_PIPELINE, ENABLE_WITH_DEBUG); 224 //System.setProperty(ENABLE_JAVA2D_OPENGL_PIPELINE, ENABLE_WITH_DEBUG);
220 System.setProperty(ENABLE_JAVA2D_OPENGL_PIPELINE, DISABLE); 225 System.setProperty(ENABLE_JAVA2D_OPENGL_PIPELINE, DISABLE);
221 226
222 if (isWindowsPlateform()) { 227 if (isWindowsPlateform()) {
223 if (findWindowsVersion() >= VISTA_VERSION) { 228 if (findWindowsVersion() >= VISTA_VERSION) {
224 // don't enable OpenGL because of aero 229 // don't enable OpenGL because of aero
225 System.setProperty(ENABLE_JAVA2D_OPENGL_PIPELINE, DISABLE); 230 System.setProperty(ENABLE_JAVA2D_OPENGL_PIPELINE, DISABLE);
226 } 231 }
227 // desactivate direct3d and direct draw under windows 232 // desactivate direct3d and direct draw under windows
228 System.setProperty(DISABLE_DDRAW, ENABLE); 233 System.setProperty(DISABLE_DDRAW, ENABLE);
229 } 234 }
230 235
231 } 236 }
232 237
233 /** 238 /**
234 * @return true if the os is windows, false otherwise 239 * @return true if the os is windows, false otherwise
235 */ 240 */
236 public static boolean isWindowsPlateform() { 241 public static boolean isWindowsPlateform() {
237 // get os name 242 // get os name
238 return System.getProperty(OSNAME).toLowerCase().contains("windows"); 243 return System.getProperty(OSNAME).toLowerCase().contains("windows");
239 } 244 }
240 245
241 /** 246 /**
242 * Find the verion of windows used on the computer if one 247 * Find the verion of windows used on the computer if one
243 * @return negative value if the OS is not windows, the version of windows otherwise 248 * @return negative value if the OS is not windows, the version of windows otherwise
244 */ 249 */
245 public static double findWindowsVersion() { 250 public static double findWindowsVersion() {
246 // default valu enot windows 251 // default valu enot windows
247 double windowsVersion = -1.0; 252 double windowsVersion = -1.0;
248 253
249 if (isWindowsPlateform()) { 254 if (isWindowsPlateform()) {
250 // windows plateform 255 // windows plateform
251 return Double.valueOf(System.getProperty("os.version")); 256 return Double.valueOf(System.getProperty("os.version"));
252 } 257 }
253 258
254 return windowsVersion; 259 return windowsVersion;
255 } 260 }
256 261
257} 262}
258/*--------------------------------------------------------------------------*/ 263/*--------------------------------------------------------------------------*/