Author: ulhume
Date: 2008-09-11 00:26:39 +0200 (Thu, 11 Sep 2008)
New Revision: 1837
Removed:
software_suite_v2/software/development_tools/tuxdroid-gadget-tester/trunk/tuxdroid-gadget-tester/sources/com/kysoh/tuxdroid/gadget/framework/tester/JHtmlBrowser.java
Modified:
software_suite_v2/software/development_tools/tuxdroid-gadget-tester/trunk/tuxdroid-gadget-tester/sources/com/kysoh/tuxdroid/gadget/framework/tester/GadgetPanel.java
software_suite_v2/software/development_tools/tuxdroid-gadget-tester/trunk/tuxdroid-gadget-tester/sources/com/kysoh/tuxdroid/gadget/framework/tester/GadgetPropertiesEditorModel.java
Log:
* Make use of the new colorized console
* New property editor
* New HTML browser
Modified:
software_suite_v2/software/development_tools/tuxdroid-gadget-tester/trunk/tuxdroid-gadget-tester/sources/com/kysoh/tuxdroid/gadget/framework/tester/GadgetPanel.java
===================================================================
---
software_suite_v2/software/development_tools/tuxdroid-gadget-tester/trunk/tuxdroid-gadget-tester/sources/com/kysoh/tuxdroid/gadget/framework/tester/GadgetPanel.java
2008-09-10 07:12:13 UTC (rev 1836)
+++
software_suite_v2/software/development_tools/tuxdroid-gadget-tester/trunk/tuxdroid-gadget-tester/sources/com/kysoh/tuxdroid/gadget/framework/tester/GadgetPanel.java
2008-09-10 22:26:39 UTC (rev 1837)
@@ -36,16 +36,21 @@
import javax.swing.AbstractAction;
import javax.swing.Action;
import javax.swing.JPanel;
+import javax.swing.JScrollPane;
import javax.swing.JSplitPane;
import javax.swing.JTree;
import javax.swing.event.TreeModelEvent;
import javax.swing.event.TreeModelListener;
+import javax.swing.text.Style;
+import javax.swing.text.StyleConstants;
import javax.swing.tree.TreeModel;
import javax.swing.tree.TreePath;
import net.karmaLab.swing.JConsole;
+import net.karmaLab.swing.configuration.SimpleDialog;
import net.karmaLab.swing.htmlBrowser.JHtmlBrowser;
-import net.karmaLab.swing.propertiesEditor.JPropertiesEditor;
+import net.karmaLab.swing.propertiesEditor.JPropertiesPanel;
+import net.karmaLab.tools.HtmlColors;
import net.karmaLab.tools.Strings;
import net.karmaLab.traces.Traces;
@@ -100,7 +105,15 @@
return;
}
URL url = helpFile.toURI().toURL();
- new JHtmlBrowser(url).show();
+
+ JHtmlBrowser htmlBrowser = new JHtmlBrowser();
+
htmlBrowser.loadStylesheet(getClass().getResourceAsStream("styles.css"));
+
htmlBrowser.setBackgroundImage(getClass().getResource("bg.png"));
+ htmlBrowser.browse(url);
+ htmlBrowser.setPreferredSize(new Dimension(640,
480));
+ SimpleDialog dialog = new SimpleDialog(null,
htmlBrowser);
+ dialog.setTitle("About this gadget...");
+ dialog.execute();
} catch (MalformedURLException e1) {
e1.printStackTrace();
}
@@ -274,12 +287,12 @@
private final class GadgetObserver implements GadgetListener {
@Override
public void errors(GadgetInstance instance, String message) {
- console.println("[" +
instance.getGadget().getDescription().getName() + " # " + instance.getId() + "]
Error > " + message);
+ console.println("[" +
instance.getGadget().getDescription().getName() + " # " + instance.getId() + "]
Error > " + message, "error");
}
/** [EMAIL PROTECTED] */
public void notification(GadgetInstance instance, String name,
Object... parameters) {
- console.println("[" +
instance.getGadget().getDescription().getName() + " # " + instance.getId() + "]
'" + name + "' notification > " + Strings.implode(parameters, ' '));
+ console.println("[" +
instance.getGadget().getDescription().getName() + " # " + instance.getId() + "]
'" + name + "' notification > " + Strings.implode(parameters, ' '),
"notification");
}
@Override
@@ -305,7 +318,7 @@
@Override
public void trace(GadgetInstance instance, String message) {
- console.println("[" +
instance.getGadget().getDescription().getName() + " # " + instance.getId() + "]
Trace > " + message);
+ console.println("[" +
instance.getGadget().getDescription().getName() + " # " + instance.getId() + "]
Trace > " + message, "trace");
}
}
@@ -319,7 +332,7 @@
private final JConsole console = new JConsole();
/** Current gadget id. */
final Gadget gadget;
- private final JPropertiesEditor gadgetParametersEditor;
+ private final JPropertiesPanel gadgetParametersEditor;
private final GadgetsContainer container;
private final GadgetPropertiesEditorModel propertiesEditorModel;
@@ -345,11 +358,11 @@
actionsTree.addMouseListener(new ActionTreeMouseObserver());
gadget.addListener(new GadgetObserver());
setLayout(new BorderLayout());
- gadgetParametersEditor = new JPropertiesEditor();
+ gadgetParametersEditor = new JPropertiesPanel();
gadgetParametersEditor.setShowInvisibleProperties(true);
propertiesEditorModel = new GadgetPropertiesEditorModel(gadget);
gadgetParametersEditor.setModel(propertiesEditorModel);
- JSplitPane actionSplitPane = new
JSplitPane(JSplitPane.VERTICAL_SPLIT, gadgetParametersEditor, actionsTree);
+ JSplitPane actionSplitPane = new
JSplitPane(JSplitPane.VERTICAL_SPLIT, new JScrollPane(gadgetParametersEditor),
actionsTree);
JSplitPane splitPane = new
JSplitPane(JSplitPane.HORIZONTAL_SPLIT, console, actionSplitPane);
actionSplitPane.setPreferredSize(new Dimension(150, 0));
actionSplitPane.setSize(new Dimension(150, 0));
@@ -359,6 +372,21 @@
actionSplitPane.setResizeWeight(0.5);
splitPane.setResizeWeight(0.7);
add(splitPane);
+ Style style = console.newStyle("header");
+ StyleConstants.setForeground(style,
HtmlColors.fromHtml("#F9CF36"));
+ StyleConstants.setUnderline(style, true);
+ style = console.newStyle("property_name");
+ StyleConstants.setBold(style, true);
+ StyleConstants.setForeground(style,
HtmlColors.fromHtml("#B5F552"));
+ style = console.newStyle("property_value");
+ StyleConstants.setForeground(style,
HtmlColors.fromHtml("#B5F552"));
+ style = console.newStyle("error");
+ StyleConstants.setForeground(style,
HtmlColors.fromHtml("#7A7070"));
+ StyleConstants.setLeftIndent(style, 10);
+ style = console.newStyle("trace");
+ StyleConstants.setForeground(style,
HtmlColors.fromHtml("#FA9774"));
+ style = console.newStyle("notification");
+ StyleConstants.setForeground(style,
HtmlColors.fromHtml("#A2A2D9"));
console.println("New gadget added");
exploreGadget();
revalidate();
@@ -368,19 +396,22 @@
* Retreive gadget informations.
*/
private void exploreGadget() {
- console.println("\n\n***************** Exploring gadget");
+ console.println();
+ console.println();
+ console.println("Exploring gadget...");
+ console.println();
// Get remote description
- console.println("Description");
- console.println("------------------------------------");
+ console.println("Description", "header");
showDescription(gadget);
// Get remote notifications
- console.println("\nNotifications");
- console.println("------------------------------------");
+ console.println();
+ console.println("Notifications", "header");
showTokens(gadget.getNotifications());
// Get remote notifications
- console.println("\nControls");
- console.println("------------------------------------");
+ console.println();
+ console.println("Controls", "header");
showTokens(gadget.getCommands());
+ console.println();
}
/**
@@ -391,10 +422,15 @@
*/
private void showTokens(Vector<GadgetToken> vector) {
for (GadgetToken token : vector) {
- console.println(" " + token.getName() + " : " +
token.getDescription());
+ showToken(token.getName(), token.getDescription());
}
}
+ private void showToken(String name, String value) {
+ console.print(" " + name + " : ", "property_name");
+ console.println(" " + value + " : ", "property_value");
+ }
+
/**
* Format gadget description.
*
@@ -403,14 +439,14 @@
*/
private void showDescription(Gadget gadget) {
GadgetDescription description = gadget.getDescription();
- console.println(" Name : " +
description.getTranslatedName());
- console.println(" Version : " + description.getVersion());
- console.println(" Author : " + description.getAuthor());
- console.println(" Description : " +
description.getDescription());
- console.println(" UUID : " + description.getUuid());
- console.println(" WorkingPath : " +
gadget.getInterpreter().getWorkingPath());
- console.println(" iconFile : " + description.getIconFile());
- console.println(" HelpFile : " + gadget.getHelpFile());
+ showToken("Name", description.getTranslatedName());
+ showToken("Version", description.getVersion());
+ showToken("Author", description.getAuthor());
+ showToken("Description", description.getDescription());
+ showToken("UUID", "" + description.getUuid());
+ showToken("WorkingPath", "" +
gadget.getInterpreter().getWorkingPath());
+ showToken("iconFile", description.getIconFile());
+ showToken("HelpFile", "" + gadget.getHelpFile());
}
public Gadget getGadget() {
Modified:
software_suite_v2/software/development_tools/tuxdroid-gadget-tester/trunk/tuxdroid-gadget-tester/sources/com/kysoh/tuxdroid/gadget/framework/tester/GadgetPropertiesEditorModel.java
===================================================================
---
software_suite_v2/software/development_tools/tuxdroid-gadget-tester/trunk/tuxdroid-gadget-tester/sources/com/kysoh/tuxdroid/gadget/framework/tester/GadgetPropertiesEditorModel.java
2008-09-10 07:12:13 UTC (rev 1836)
+++
software_suite_v2/software/development_tools/tuxdroid-gadget-tester/trunk/tuxdroid-gadget-tester/sources/com/kysoh/tuxdroid/gadget/framework/tester/GadgetPropertiesEditorModel.java
2008-09-10 22:26:39 UTC (rev 1837)
@@ -63,7 +63,7 @@
@Override
public String getDescription() {
- return parameter.getTranslatedName();
+ return parameter.getDescription();
}
@Override
@@ -73,7 +73,7 @@
@Override
public String getName() {
- return parameter.getDescription();
+ return parameter.getName();
}
@Override
Deleted:
software_suite_v2/software/development_tools/tuxdroid-gadget-tester/trunk/tuxdroid-gadget-tester/sources/com/kysoh/tuxdroid/gadget/framework/tester/JHtmlBrowser.java
===================================================================
---
software_suite_v2/software/development_tools/tuxdroid-gadget-tester/trunk/tuxdroid-gadget-tester/sources/com/kysoh/tuxdroid/gadget/framework/tester/JHtmlBrowser.java
2008-09-10 07:12:13 UTC (rev 1836)
+++
software_suite_v2/software/development_tools/tuxdroid-gadget-tester/trunk/tuxdroid-gadget-tester/sources/com/kysoh/tuxdroid/gadget/framework/tester/JHtmlBrowser.java
2008-09-10 22:26:39 UTC (rev 1837)
@@ -1,125 +0,0 @@
-/* This file is part of "TuxDroid Gadget Tester".
- * Copyright 2008, kysoh
- * Author : Yoran Brault
- * eMail : [EMAIL PROTECTED] (remove _bad_ before sending an email)
- * Site : http://www.kysoh.com/
- *
- * "TuxDroid Gadget Tester" is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * "TuxDroid Gadget Tester" is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with "TuxDroid Gadget Tester"; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-package com.kysoh.tuxdroid.gadget.framework.tester;
-
-import java.awt.BorderLayout;
-import java.awt.Color;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.net.URL;
-import java.util.Enumeration;
-
-import javax.swing.JEditorPane;
-import javax.swing.JFrame;
-import javax.swing.JPanel;
-import javax.swing.JScrollPane;
-import javax.swing.event.HyperlinkEvent;
-import javax.swing.event.HyperlinkListener;
-import javax.swing.text.Style;
-import javax.swing.text.html.HTMLEditorKit;
-import javax.swing.text.html.StyleSheet;
-
-public class JHtmlBrowser extends JPanel implements HyperlinkListener {
- private final JEditorPane htmlPane;
-
- public JHtmlBrowser(URL url) {
- htmlPane = new JEditorPane();
-
- // Définition du style par défaut
- HTMLEditorKit editor = (HTMLEditorKit) htmlPane
- .getEditorKitForContentType("text/html");
- StyleSheet styles = editor.getStyleSheet();
- InputStream stylesStream =
getClass().getResourceAsStream("styles.css");
- InputStreamReader reader = new InputStreamReader(stylesStream);
- try {
- styles.loadRules(reader, null);
- } catch (IOException e) {
- e.printStackTrace();
- }
-
- // Petit hack entre amis, cet abruti est incapable de trouver
la bonne
- // référence à l'image sinon...
- URL stylesURL = getClass().getResource("bg.png");
- styles.addRule("body { background-image: url('" + stylesURL +
"');}");
-
- // Ajout de la feuille de style à l'éditeur
- editor.setStyleSheet(styles);
- htmlPane.setEditorKit(editor);
-
- // Juste pour savoir ce qui se passe
-// Enumeration<?> rules = styles.getStyleNames();
-// while (rules.hasMoreElements()) {
-// String name = (String) rules.nextElement();
-// Style rule = styles.getStyle(name);
-// System.out.println(rule.toString());
-// }
-
- // Peaufinage
- htmlPane.setEditable(false);
- htmlPane.addHyperlinkListener(this);
- htmlPane.setBorder(null);
-
- // Ajout du scroller
- JScrollPane scrollPane = new JScrollPane(htmlPane);
- scrollPane.setBorder(null);
-
- // Load de l'URL (c'est plus joli avant affichage)
- if (url != null) {
- browse(url);
- }
-
- // Ajout du composant
- setLayout(new BorderLayout());
- add(scrollPane, BorderLayout.CENTER);
- }
-
- public JHtmlBrowser() {
- this(null);
- }
-
- public void show() {
- int width = 640;
- int height = 480;
- setBounds(width / 8, height / 8, width, height);
- JFrame frame = new JFrame("Gadget Help File");
- frame.getContentPane().add(this, BorderLayout.CENTER);
- frame.setSize(width, height);
- frame.setVisible(true);
- }
-
- public void browse(URL url) {
- try {
- htmlPane.setPage(url);
- htmlPane.setContentType("text/html; charset=utf-8");
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
-
- public void hyperlinkUpdate(HyperlinkEvent event) {
- if (event.getEventType() == HyperlinkEvent.EventType.ACTIVATED)
{
- browse(event.getURL());
- }
- }
-}
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Tux-droid-svn mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tux-droid-svn