From 72f70bc8eba5ade21c03a694dadb63f869c54c51 Mon Sep 17 00:00:00 2001 From: Calixte DENIZET Date: Mon, 17 Mar 2014 13:41:28 +0100 Subject: [PATCH] SciNotes: make a little cleanup Change-Id: Id38fed6c0659309532bd72d8671c8411183c0fa1 --- .../modules/scinotes/etc/scinotesConfiguration.xml | 218 +------------------- .../java/org/scilab/modules/scinotes/SciNotes.java | 20 +- .../scinotes/actions/SuppressCommentsAction.java | 77 ------- .../scinotes/utils/ConfigSciNotesManager.java | 136 +----------- 4 files changed, 3 insertions(+), 448 deletions(-) delete mode 100644 scilab/modules/scinotes/src/java/org/scilab/modules/scinotes/actions/SuppressCommentsAction.java diff --git a/scilab/modules/scinotes/etc/scinotesConfiguration.xml b/scilab/modules/scinotes/etc/scinotesConfiguration.xml index 9e2fe4e..4ab8126 100644 --- a/scilab/modules/scinotes/etc/scinotesConfiguration.xml +++ b/scilab/modules/scinotes/etc/scinotesConfiguration.xml @@ -12,233 +12,18 @@ * --> - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -254,6 +39,5 @@ - diff --git a/scilab/modules/scinotes/src/java/org/scilab/modules/scinotes/SciNotes.java b/scilab/modules/scinotes/src/java/org/scilab/modules/scinotes/SciNotes.java index 8963ee6..b311e5d 100644 --- a/scilab/modules/scinotes/src/java/org/scilab/modules/scinotes/SciNotes.java +++ b/scilab/modules/scinotes/src/java/org/scilab/modules/scinotes/SciNotes.java @@ -692,6 +692,7 @@ public class SciNotes extends SwingScilabDockablePanel { if (getTabPane().getTabCount() != 1 || getTextPane(0).getName() != null) { openFile(null, 0, null); } + setWindowIcon("accessories-text-editor"); WindowsConfigurationManager.restorationFinished(this); @@ -1939,25 +1940,6 @@ public class SciNotes extends SwingScilabDockablePanel { } /** - * Auto-indent mode management - * - * @param b - * true to activate auto-indent mode - */ - public static void setSuppressComments(boolean b) { - for (SciNotes ed : scinotesList) { - int n = ed.getTabPane().getTabCount(); - for (int i = 0; i < n; i++) { - ScilabEditorPane sep = ed.getTextPane(i); - sep.suppressCommentsInExecutingCode(b); - if (sep.getOtherPaneInSplit() != null) { - sep.getOtherPaneInSplit().suppressCommentsInExecutingCode(b); - } - } - } - } - - /** * Horizontal Wrap mode management * * @param b diff --git a/scilab/modules/scinotes/src/java/org/scilab/modules/scinotes/actions/SuppressCommentsAction.java b/scilab/modules/scinotes/src/java/org/scilab/modules/scinotes/actions/SuppressCommentsAction.java deleted file mode 100644 index 833a047..0000000 --- a/scilab/modules/scinotes/src/java/org/scilab/modules/scinotes/actions/SuppressCommentsAction.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab - * Copyright (C) 2011 - 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.1-en.txt - * - */ - -package org.scilab.modules.scinotes.actions; - -import java.beans.PropertyChangeEvent; -import java.beans.PropertyChangeListener; - -import javax.swing.JCheckBoxMenuItem; -import javax.swing.KeyStroke; -import javax.swing.SwingUtilities; - -import org.scilab.modules.gui.checkboxmenuitem.CheckBoxMenuItem; -import org.scilab.modules.scinotes.SciNotes; -import org.scilab.modules.scinotes.utils.ConfigSciNotesManager; - -/** - * SuppressCommentsAction Class - * @author Calixte DENIZET - * - */ -public final class SuppressCommentsAction extends DefaultCheckAction { - - /** - * serialVersionUID - */ - private static final long serialVersionUID = -1L; - - /** - * Constructor - * @param name the name of the action - * @param editor SciNotes - */ - public SuppressCommentsAction(String name, SciNotes editor) { - super(name, editor); - } - - /** - * doAction - */ - public void doAction() { - SwingUtilities.invokeLater(new Runnable() { - public void run() { - SciNotes.setSuppressComments(SuppressCommentsAction.this.getState()); - ConfigSciNotesManager.saveSuppressComments(SuppressCommentsAction.this.getState()); - } - }); - } - - /** - * createCheckBoxMenu - * @param label label of the menu - * @param editor SciNotes - * @param key KeyStroke - * @return CheckBoxMenuItem - */ - public static CheckBoxMenuItem createMenu(String label, SciNotes editor, KeyStroke key) { - final CheckBoxMenuItem sca = createCheckBoxMenu(label, null, new SuppressCommentsAction(label, editor), key); - sca.setChecked(ConfigSciNotesManager.getSuppressComments()); - ((JCheckBoxMenuItem) sca.getAsSimpleCheckBoxMenuItem()).addPropertyChangeListener(new PropertyChangeListener() { - public void propertyChange(PropertyChangeEvent e) { - sca.setChecked(ConfigSciNotesManager.getSuppressComments()); - } - }); - - return sca; - } -} diff --git a/scilab/modules/scinotes/src/java/org/scilab/modules/scinotes/utils/ConfigSciNotesManager.java b/scilab/modules/scinotes/src/java/org/scilab/modules/scinotes/utils/ConfigSciNotesManager.java index ca35b31..4aa293d 100644 --- a/scilab/modules/scinotes/src/java/org/scilab/modules/scinotes/utils/ConfigSciNotesManager.java +++ b/scilab/modules/scinotes/src/java/org/scilab/modules/scinotes/utils/ConfigSciNotesManager.java @@ -84,7 +84,6 @@ public final class ConfigSciNotesManager { private static final int MARGIN = 20; - private static final String HORIZONTALWRAP = "HorizontalWrapAllowed"; private static final String ERROR_READ = "Could not load file: "; private static final String ERROR_WRITE = "Could not save file: "; private static final String VALUE = "value"; @@ -110,8 +109,7 @@ public final class ConfigSciNotesManager { private static final String HELPONTYPING = "HelpOnTyping"; private static final String LINENUMBERING = "LineNumbering"; private static final String EDITOR = "SciNotes"; - private static final String SUPPRESSCOMMENTS = "SuppressComments"; - + private static final String FOREGROUNDCOLOR = "ForegroundColor"; private static final String BACKGROUNDCOLOR = "BackgroundColor"; private static final String ALTERNCOLORS = "AlternColors"; @@ -360,138 +358,6 @@ public final class ConfigSciNotesManager { } /** - * Get the background Color - * @return the background Color - */ - public static Color getSciNotesBackgroundColor() { - /* Load file */ - readDocument(); - - Element root = document.getDocumentElement(); - - NodeList profiles = root.getElementsByTagName(EDITOR); - Element scinotesProfile = (Element) profiles.item(0); - - NodeList allElements = scinotesProfile.getElementsByTagName(BACKGROUNDCOLOR); - Element scinotesBackground = (Element) allElements.item(0); - - /*direct create a Color with "#FF00FF" string from the xml */ - return Color.decode(scinotesBackground.getAttribute(VALUE)); - } - - /** - * Get the foreground Color - * @return the foreground Color - */ - public static Color getSciNotesForegroundColor() { - /* Load file */ - readDocument(); - - Element root = document.getDocumentElement(); - - NodeList profiles = root.getElementsByTagName(EDITOR); - Element scinotesProfile = (Element) profiles.item(0); - - NodeList allElements = scinotesProfile.getElementsByTagName(FOREGROUNDCOLOR); - Element scinotesForeground = (Element) allElements.item(0); - - /*direct create a Color with "#FF00FF" string from the xml */ - return Color.decode(scinotesForeground.getAttribute(VALUE)); - } - - /** - * Save SciNotes BackgroundColor - * @param color the new Color - */ - public static void saveSciNotesBackground(Color color) { - - /* Load file */ - readDocument(); - - Element root = document.getDocumentElement(); - - NodeList profiles = root.getElementsByTagName(EDITOR); - Element scinotesProfile = (Element) profiles.item(0); - - NodeList allSizeElements = scinotesProfile.getElementsByTagName(BACKGROUNDCOLOR); - Element scinotesBackground = (Element) allSizeElements.item(0); - - String rgb = Integer.toHexString(color.getRGB()); - scinotesBackground.setAttribute(VALUE, COLORPREFIX + rgb.substring(2, rgb.length())); - - /* Save changes */ - writeDocument(); - } - - /** - * Save SciNotes foregroundColor - * @param color the new Color - */ - public static void saveSciNotesForeground(Color color) { - readDocument(); - - Element root = document.getDocumentElement(); - - NodeList profiles = root.getElementsByTagName(EDITOR); - Element scinotesProfile = (Element) profiles.item(0); - - NodeList allSizeElements = scinotesProfile.getElementsByTagName(FOREGROUNDCOLOR); - Element scinotesForeground = (Element) allSizeElements.item(0); - - String rgb = Integer.toHexString(color.getRGB()); - scinotesForeground.setAttribute(VALUE, COLORPREFIX + rgb.substring(2, rgb.length())); - - /* Save changes */ - writeDocument(); - } - - /** - * Save SciNotes autoIndent or not - * @param activated if autoIndent should be used or not - */ - public static void saveSuppressComments(boolean activated) { - /* Load file */ - readDocument(); - - Element root = document.getDocumentElement(); - - NodeList profiles = root.getElementsByTagName(PROFILE); - Element scinotesProfile = (Element) profiles.item(0); - - NodeList allSizeElements = scinotesProfile.getElementsByTagName(SUPPRESSCOMMENTS); - Element suppressComments = (Element) allSizeElements.item(0); - if (suppressComments == null) { - Element sup = document.createElement(SUPPRESSCOMMENTS); - sup.setAttribute(VALUE, new Boolean(activated).toString()); - scinotesProfile.appendChild((Node) sup); - } else { - suppressComments.setAttribute(VALUE, new Boolean(activated).toString()); - } - /* Save changes */ - writeDocument(); - } - - /** - * @return a boolean if autoIndent should be used or not - */ - public static boolean getSuppressComments() { - /* Load file */ - readDocument(); - - Element root = document.getDocumentElement(); - NodeList profiles = root.getElementsByTagName(PROFILE); - Element scinotesProfile = (Element) profiles.item(0); - NodeList allSizeElements = scinotesProfile.getElementsByTagName(SUPPRESSCOMMENTS); - Element suppressComments = (Element) allSizeElements.item(0); - - if (suppressComments == null) { - return true; - } else { - return new Boolean(suppressComments.getAttribute(VALUE)); - } - } - - /** * Get all the recent opened files * @return an array of uri */ -- 1.7.9.5