* Bug #11810 fixed - In BrowseVar, contents of "visibility" column are left
aligned.
+* Bug #11834 fixed - In SciNotes there was not a menu to set font or colors.
+
* Bug #11840 fixed - In Xcos, dialogs could not be closed on escape.
package org.scilab.modules.commons;
import java.awt.Font;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
import org.w3c.dom.Document;
return instance;
}
+ public static void openPreferences(String path) {
+ try {
+ Class prefs = ClassLoader.getSystemClassLoader().loadClass("org.scilab.modules.preferences.ScilabPreferences");
+ Method open = prefs.getDeclaredMethod("openPreferences", String.class);
+ open.invoke(null, path);
+ } catch (ClassNotFoundException e) {
+ // Nothing displayed (always occurs in MN mode)
+ } catch (Exception e) {
+ System.err.println(e);
+ }
+ }
+
public void configurationChanged(XConfigurationEvent e) {
boolean all = e.getModifiedPaths().contains("ALL");
if (all || e.getModifiedPaths().contains(ENV_PATH)) {
Document doc = XConfiguration.getXConfigurationDocument();
Language language = XConfiguration.get(Language.class, doc, LANG_PATH)[0];
WindowsDefaultLanguage.setdefaultlanguage(language.lang);
- }
+ }
if (all || e.getModifiedPaths().contains(FONT_PATH)) {
desktopFont = null;
<entry type="java" action="CopySelectionInNewTabAction" name="scinotes-selection-new-tab"/>
<entry type="java" action="SplitAction" name="scinotes-split"/>
<entry type="java" action="HelpOnKeywordInPopupAction" name="scinotes-help-keyword-popup"/>
+ <entry type="java" action="SetFontAction" name="scinotes-set-font"/>
+ <entry type="java" action="SetColorsAction" name="scinotes-set-colors"/>
</scinotes>
<console>
<entry type="java" action="org.scilab.modules.console.SelectAllAction" name="console-select-all"/>
<action key="" description="_(Close all but this)" name="scinotes-close-all-but"/>
<action key="" description="_(Convert quote to double quote)" name="scinotes-double-quote"/>
<action key="" description="_(Line numbering)" name="scinotes-line-numbering"/>
+ <action key="" description="_(Set the SciNotes font)" name="scinotes-set-font"/>
+ <action key="" description="_(Set the SciNotes colors)" name="scinotes-set-colors"/>
</action-folder>
<action-folder name="Xcos" xconf-uid="xcos">
<!-- File -->
<?xml version="1.0" encoding="utf-8"?>
-<interface version="0.07" path="1/" width="800" height="550">
+<interface version="0.08" path="1/" width="800" height="550">
<general/>
<web/>
<preference/>
* Open the preferences window
*/
public static void openPreferences() {
+ openPreferences(null);
+ }
+
+ /**
+ * Open the preferences window
+ */
+ public static void openPreferences(final String initialPath) {
SwingUtilities.invokeLater(new Runnable() {
- public void run() {
- XConfigManager.openPreferences();
- }
- });
+ public void run() {
+ XConfigManager.openPreferences(initialPath);
+ }
+ });
}
/**
static {
factory = ScilabTransformerFactory.newInstance();
factory.setURIResolver(new URIResolver() {
- public Source resolve(String href, String base) throws TransformerException {
- if (href.startsWith("$SCI")) {
- href = href.replace("$SCI", SCI);
- base = null;
- }
-
- try {
- File baseDir = null;
- if (base != null && !base.isEmpty()) {
- baseDir = new File(new URI(base)).getParentFile();
- }
- File f;
- if (baseDir != null) {
- f = new File(baseDir, href);
- } else {
- f = new File(href);
+ public Source resolve(String href, String base) throws TransformerException {
+ if (href.startsWith("$SCI")) {
+ href = href.replace("$SCI", SCI);
+ base = null;
}
- if (f.exists() && f.canRead()) {
- return new StreamSource(f);
+ try {
+ File baseDir = null;
+ if (base != null && !base.isEmpty()) {
+ baseDir = new File(new URI(base)).getParentFile();
+ }
+ File f;
+ if (baseDir != null) {
+ f = new File(baseDir, href);
+ } else {
+ f = new File(href);
+ }
+
+ if (f.exists() && f.canRead()) {
+ return new StreamSource(f);
+ }
+ } catch (Exception e) {
+ System.out.println(e);
}
- } catch (Exception e) {
- System.out.println(e);
- }
- throw new TransformerException("Cannot find the file " + href + "::" + base);
- }
- });
+ throw new TransformerException("Cannot find the file " + href + "::" + base);
+ }
+ });
}
/**
List<File> list = new ArrayList<File>();
File modulesDir = new File(SCI + "/modules/");
File[] modules = modulesDir.listFiles(new FileFilter() {
- public boolean accept(File f) {
- return f.isDirectory();
- }
- });
+ public boolean accept(File f) {
+ return f.isDirectory();
+ }
+ });
for (File module : modules) {
File etc = new File(module, "/etc/");
buffer.append("<xsl:import href=\"").append(SCI).append("/modules/preferences/src/xslt/XConfiguration.xsl").append("\"/>\n");
FilenameFilter filter = new FilenameFilter() {
- public boolean accept(File dir, String name) {
- return name.endsWith(".xsl") && name.startsWith("XConfiguration");
- }
- };
+ public boolean accept(File dir, String name) {
+ return name.endsWith(".xsl") && name.startsWith("XConfiguration");
+ }
+ };
// Include standard Scilab xsl files
for (File etc : etcs) {
// Include toolboxes xsl files
List<ScilabPreferences.ToolboxInfos> infos = ScilabPreferences.getToolboxesInfos();
filter = new FilenameFilter() {
- public boolean accept(File dir, String name) {
- return name.endsWith(".xsl");
- }
- };
+ public boolean accept(File dir, String name) {
+ return name.endsWith(".xsl");
+ }
+ };
for (ScilabPreferences.ToolboxInfos i : infos) {
File etc = new File(i.getPrefFile()).getParentFile();
File[] xsls = etc.listFiles(filter);
}
/**
+ * Get the real path from an abstract path: scinotes/header will be converted into 8/2
+ * @param name abstract path
+ * @return real path
+ */
+ public static String getPath(String name) {
+ String[] ids = name.split("/");
+ Element element = document.getDocumentElement();
+ String path = "";
+ for (int i = 0; i < ids.length; i++) {
+ int index = 1;
+ NodeList childNodes = element.getChildNodes();
+ Node node = null;
+ int len = childNodes.getLength();
+ int j = 0;
+ for (; j < len; j++) {
+ node = childNodes.item(j);
+ String nodeName = node.getNodeName();
+ if (nodeName.equalsIgnoreCase(ids[i])) {
+ path += index + "/";
+ element = (Element) node;
+ break;
+ }
+ if (!node.getNodeName().equals("#text") && !node.getNodeName().equals("#comment")) {
+ index++;
+ }
+ }
+
+ if (j == len) {
+ System.err.println("Invalid path: " + name);
+ return "1/";
+ }
+ }
+ return path;
+ }
+
+ /**
* Interpret action.
* @param action : to be interpreted.
* @param source : component source of the action (only class is needed).
Element element = getElementByContext(context);
String value = getAttribute(action, "value");
String attribute = getAttribute(action, "set");
+ if (attribute.equals("path") && context.equals("/") && !Character.isDigit(value.charAt(0))) {
+ value = getPath(value);
+ }
if (element != null) {
element.setAttribute(attribute, value);
XConfiguration.addModifiedPath(getNodePath(element));
return NAV;
}
- String response = attr.getNodeValue();
- if (response.startsWith("_(") && response.endsWith(")")) {
- response = Messages.gettext(response.substring(2, response.length() - 1));
- }
+ String response = attr.getNodeValue();
+ if (response.startsWith("_(") && response.endsWith(")")) {
+ response = Messages.gettext(response.substring(2, response.length() - 1));
+ }
return response;
}
/** Display dialog and wait for events.
*
*/
- public static void displayAndWait() {
+ public static void displayAndWait(String initialPath) {
XConfigManager.active = true;
XWizardManager.active = false;
// Set up DOM Side
readUserDocuments();
+ if (initialPath != null && !initialPath.equals("")) {
+ String path = getPath(initialPath);
+ document.getDocumentElement().setAttribute("path", path);
+ }
updated = false;
// Plug in resize
//dialog.setResizable(false);
dialog.addComponentListener(new ComponentAdapter() {
- public void componentResized(ComponentEvent e) {
- Element element = document.getDocumentElement();
- Dimension dimension = dialog.getSize();
- int height = XConfigManager.getInt(element, "height", 0);
- int width = XConfigManager.getInt(element, "width", 0);
- if (Math.abs(((double) height) - dimension.getHeight()) > 0.1 || Math.abs(((double) width) - dimension.getWidth()) > 0.1 ) {
- element.setAttribute("height", Integer.toString((int) dimension.getHeight()));
- element.setAttribute("width", Integer.toString((int) dimension.getWidth()));
+ public void componentResized(ComponentEvent e) {
+ Element element = document.getDocumentElement();
+ Dimension dimension = dialog.getSize();
+ int height = XConfigManager.getInt(element, "height", 0);
+ int width = XConfigManager.getInt(element, "width", 0);
+ if (Math.abs(((double) height) - dimension.getHeight()) > 0.1 || Math.abs(((double) width) - dimension.getWidth()) > 0.1 ) {
+ element.setAttribute("height", Integer.toString((int) dimension.getHeight()));
+ element.setAttribute("width", Integer.toString((int) dimension.getWidth()));
+ }
}
- }
- });
+ });
dialog.addWindowListener(new WindowAdapter() {
- @Override
- public void windowClosing(WindowEvent e) {
- cancel();
- }
- });
+ @Override
+ public void windowClosing(WindowEvent e) {
+ cancel();
+ }
+ });
ScilabSwingUtilities.closeOnEscape(dialog);
// Set up correspondence
/**
* Opens a dialog to setup preferences.
*/
- public static void openPreferences() {
- XConfigManager.displayAndWait();
+ public static void openPreferences(String initialPath) {
+ XConfigManager.displayAndWait(initialPath);
}
/** Secondary dialog for help.*/
Element tbxs = (Element) toolboxes.item(0);
document.getDocumentElement().removeChild(tbxs);
}
+ correspondance = null;
updated = false;
- refreshDisplay();
}
/** Interpret action.
</Checkbox>\r
<Panel gridx="2" gridy="1" weightx="1"/>\r
<Link gridx="3" gridy="1" weightx="0" listener="MouseListener" text="_(Set syntax Colors)" enable="{@keywords-colorization}">\r
- <mouseClicked set="path" value="3/" context="/" enable="{@keywords-colorization}"/>\r
+ <mouseClicked set="path" value="scinotes/header" context="/" enable="{@keywords-colorization}"/>\r
</Link>\r
<Checkbox checked="{@highlight-brackets}" selected-value="true" unselected-value="false" listener="ActionListener" text="_(Highlight corresponding brackets)" gridx="1" gridy="2" fill="none" weightx="0" anchor="west">\r
<actionPerformed choose="highlight-brackets">\r
<menuitem action="scinotes-encoding" label="Current file encoding"/>
<menuitem action="scinotes-eof" label="Line Endings"/>
<separator/>
+ <menu label="Preferences">
+ <menuitem action="scinotes-set-font" label="Set font"/>
+ <menuitem action="scinotes-set-colors" label="Set colors"/>
+ </menu>
+ <separator/>
<menu label="Auto-completion on">
<menuitem action="scinotes-autocomplete-openers" label="(, [, ..."/>
<menuitem action="scinotes-autocomplete-keyword" label="if, function, ..."/>
--- /dev/null
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2012 - Scilab Enterprises - Calixte DENIZET
+ *
+ * This file must be used under the terms of the CeCILL.
+ * This source file is licensed as described in the file COPYING, which
+ * you should have received as part of this distribution. The terms
+ * are also available at
+ * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+ *
+ */
+
+package org.scilab.modules.scinotes.actions;
+
+import javax.swing.KeyStroke;
+
+import org.scilab.modules.commons.ScilabGeneralPrefs;
+import org.scilab.modules.gui.menuitem.MenuItem;
+import org.scilab.modules.scinotes.SciNotes;
+
+/**
+ * SetColorsAction Class
+ * @author Calixte DENIZET
+ */
+public class SetColorsAction extends DefaultAction {
+
+ /**
+ * Constructor
+ * @param name the name of the action
+ * @param editor SciNotes
+ */
+ public SetColorsAction(String name, SciNotes editor) {
+ super(name, editor);
+ }
+
+ /**
+ * doAction
+ */
+ @Override
+ public void doAction() {
+ ScilabGeneralPrefs.openPreferences("colors/");
+ }
+
+ /**
+ * createMenu
+ * @param label label of the menu
+ * @param editor SciNotes
+ * @param key Keystroke
+ * @return MenuItem
+ */
+ public static MenuItem createMenu(String label, final SciNotes editor, KeyStroke key) {
+ return createMenu(label, null, new SetColorsAction(label, editor), key);
+ }
+}
--- /dev/null
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2012 - Scilab Enterprises - Calixte DENIZET
+ *
+ * This file must be used under the terms of the CeCILL.
+ * This source file is licensed as described in the file COPYING, which
+ * you should have received as part of this distribution. The terms
+ * are also available at
+ * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+ *
+ */
+
+package org.scilab.modules.scinotes.actions;
+
+import javax.swing.KeyStroke;
+
+import org.scilab.modules.commons.ScilabGeneralPrefs;
+import org.scilab.modules.gui.menuitem.MenuItem;
+import org.scilab.modules.scinotes.SciNotes;
+
+/**
+ * SetFontAction Class
+ * @author Calixte DENIZET
+ */
+public class SetFontAction extends DefaultAction {
+
+ /**
+ * Constructor
+ * @param name the name of the action
+ * @param editor SciNotes
+ */
+ public SetFontAction(String name, SciNotes editor) {
+ super(name, editor);
+ }
+
+ /**
+ * doAction
+ */
+ @Override
+ public void doAction() {
+ ScilabGeneralPrefs.openPreferences("fonts/");
+ }
+
+ /**
+ * createMenu
+ * @param label label of the menu
+ * @param editor SciNotes
+ * @param key Keystroke
+ * @return MenuItem
+ */
+ public static MenuItem createMenu(String label, final SciNotes editor, KeyStroke key) {
+ return createMenu(label, null, new SetFontAction(label, editor), key);
+ }
+}