Jaxx-commits
Threads by month
- ----- 2026 -----
- June
- May
- April
- March
- February
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2008 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2007 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2006 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2005 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2004 -----
- December
- November
- October
- September
- August
December 2009
- 2 participants
- 44 discussions
Author: tchemit
Date: 2009-12-22 18:34:34 +0100 (Tue, 22 Dec 2009)
New Revision: 1694
Added:
trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/model/ConfigUIModelBuilder.java
trunk/jaxx-widgets/src/test/
trunk/jaxx-widgets/src/test/java/
trunk/jaxx-widgets/src/test/java/jaxx/
trunk/jaxx-widgets/src/test/java/jaxx/runtime/
trunk/jaxx-widgets/src/test/java/jaxx/runtime/swing/
trunk/jaxx-widgets/src/test/java/jaxx/runtime/swing/editor/
trunk/jaxx-widgets/src/test/java/jaxx/runtime/swing/editor/config/
trunk/jaxx-widgets/src/test/java/jaxx/runtime/swing/editor/config/model/
trunk/jaxx-widgets/src/test/java/jaxx/runtime/swing/editor/config/model/ConfigUIModelBuilderTest.java
trunk/jaxx-widgets/src/test/java/jaxx/runtime/swing/editor/config/model/MyConfig.java
trunk/jaxx-widgets/src/test/resources/
trunk/jaxx-widgets/src/test/resources/log4j.properties
Modified:
trunk/jaxx-widgets/pom.xml
trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/FontSizor.jaxx
trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/ConfigCategoryUI.jaxx
trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/ConfigTableEditor.java
trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/ConfigUI.jaxx
trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/ConfigUIBuilder.java
trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/model/CategoryModel.java
trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/model/ConfigUIModel.java
trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/model/OptionModel.java
trunk/jaxx-widgets/src/main/resources/i18n/jaxx-widgets-en_GB.properties
trunk/jaxx-widgets/src/main/resources/i18n/jaxx-widgets-fr_FR.properties
Log:
add ConfigModelBuilder api + reload ui and application call back in ConfigUI + fix FontSizor issues
Modified: trunk/jaxx-widgets/pom.xml
===================================================================
--- trunk/jaxx-widgets/pom.xml 2009-12-22 07:45:46 UTC (rev 1693)
+++ trunk/jaxx-widgets/pom.xml 2009-12-22 17:34:34 UTC (rev 1694)
@@ -41,6 +41,11 @@
<artifactId>commons-io</artifactId>
</dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ </dependency>
+
</dependencies>
<!-- ************************************************************* -->
Modified: trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/FontSizor.jaxx
===================================================================
--- trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/FontSizor.jaxx 2009-12-22 07:45:46 UTC (rev 1693)
+++ trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/FontSizor.jaxx 2009-12-22 17:34:34 UTC (rev 1694)
@@ -39,7 +39,9 @@
public static final String BINDING_DEFAULT_FONT_SIZE_CALL_BACK = "defaultFontSize.callBack";
public void init() {
- setFontSize(defaultFontSize);
+ if (fontSize == null) {
+ setFontSize(defaultFontSize);
+ }
}
boolean updateDefaultSizeEnabled(Float fontSize, Float defaultFontSize, boolean enabled) {
@@ -69,7 +71,7 @@
setFontSize(defaultFontSize);
}
});
- applyDataBinding(BINDING_DEFAULT_FONT_SIZE_CALL_BACK);
+ //applyDataBinding(BINDING_DEFAULT_FONT_SIZE_CALL_BACK);
}
]]>
</script>
Modified: trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/ConfigCategoryUI.jaxx
===================================================================
--- trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/ConfigCategoryUI.jaxx 2009-12-22 07:45:46 UTC (rev 1693)
+++ trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/ConfigCategoryUI.jaxx 2009-12-22 17:34:34 UTC (rev 1694)
@@ -24,7 +24,7 @@
<JPanel layout='{new BorderLayout()}'>
<style source='ConfigCategoryUI.css'/>
-
+
<script><![CDATA[
import jaxx.runtime.swing.editor.config.model.*;
import jaxx.runtime.swing.editor.ColumnSelector;
@@ -82,6 +82,9 @@
]]>
</script>
+ <!-- le modele de l'ui -->
+ <ConfigUIModel id='model' initializer='getContextValue(ConfigUIModel.class)'/>
+
<CategoryModel id='categoryModel' javaBean='getContextValue(CategoryModel.class)'/>
<ConfigTableModel id='tableModel' constructorParams='categoryModel'
@@ -112,8 +115,10 @@
<!-- actions of the category -->
<JPanel layout='{new GridLayout(1,0)}' constraints='BorderLayout.SOUTH'>
- <JButton id='reset' onActionPerformed='getContextValue(ConfigUIModel.class).reset()'/>
- <JButton id='save' onActionPerformed='getContextValue(ConfigUIModel.class).saveModified()'/>
+ <JButton id='reset' onActionPerformed='model.reset()'/>
+ <JButton id='save' onActionPerformed='model.saveModified()'/>
+ <!--<JButton id='reset' onActionPerformed='getContextValue(ConfigUIModel.class).reset()'/>-->
+ <!--<JButton id='save' onActionPerformed='getContextValue(ConfigUIModel.class).saveModified()'/>-->
</JPanel>
</JPanel>
</JPanel>
Modified: trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/ConfigTableEditor.java
===================================================================
--- trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/ConfigTableEditor.java 2009-12-22 07:45:46 UTC (rev 1693)
+++ trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/ConfigTableEditor.java 2009-12-22 17:34:34 UTC (rev 1694)
@@ -20,6 +20,7 @@
package jaxx.runtime.swing.editor.config;
import jaxx.runtime.swing.editor.config.model.ConfigTableModel;
+
import javax.swing.DefaultCellEditor;
import javax.swing.JTable;
import javax.swing.event.CellEditorListener;
@@ -27,9 +28,11 @@
import java.awt.Component;
import java.util.EventObject;
import java.util.Locale;
+
import jaxx.runtime.swing.editor.ClassCellEditor;
import jaxx.runtime.swing.editor.EnumEditor;
import jaxx.runtime.swing.editor.LocaleEditor;
+import jaxx.runtime.swing.editor.config.model.OptionModel;
/**
* L'éditeur des valeurs des propriétés d'une configuration
@@ -47,7 +50,7 @@
@Override
public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) {
- delegate = findDelegate(table, model.getEntry(row).getType());
+ delegate = findDelegate(table, model.getEntry(row));
return delegate.getTableCellEditorComponent(table, value, isSelected, row, column);
}
@@ -92,9 +95,11 @@
}
}
- protected TableCellEditor findDelegate(JTable table, Class<?> type) {
+ protected TableCellEditor findDelegate(JTable table, OptionModel option) {
+ Class<?> type = option.getType();
TableCellEditor editor = table.getDefaultEditor(type);
TableCellEditor defaultEditor = table.getDefaultEditor(Object.class);
+ //TODO always Search from option.getEditor() and store editor as cache
if (editor == defaultEditor) {
// find not a specialized editor for the type
if (type.isEnum()) {
Modified: trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/ConfigUI.jaxx
===================================================================
--- trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/ConfigUI.jaxx 2009-12-22 07:45:46 UTC (rev 1693)
+++ trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/ConfigUI.jaxx 2009-12-22 17:34:34 UTC (rev 1694)
@@ -59,7 +59,7 @@
</script>
<!-- le modele de l'ui -->
- <ConfigUIModel id='model' javaBean='getContextValue(ConfigUIModel.class)'/>
+ <ConfigUIModel id='model' initializer='getContextValue(ConfigUIModel.class)'/>
<!-- les differentes categories de la configuration -->
<JTabbedPane id='categories' constraints='BorderLayout.CENTER'
Modified: trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/ConfigUIBuilder.java
===================================================================
--- trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/ConfigUIBuilder.java 2009-12-22 07:45:46 UTC (rev 1693)
+++ trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/ConfigUIBuilder.java 2009-12-22 17:34:34 UTC (rev 1694)
@@ -20,24 +20,9 @@
*/
package jaxx.runtime.swing.editor.config;
-import java.awt.Frame;
-import java.awt.Window;
-import java.awt.event.ActionEvent;
-import java.awt.event.WindowAdapter;
-import java.awt.event.WindowEvent;
-import java.util.List;
-import javax.swing.AbstractAction;
-import javax.swing.Action;
-import javax.swing.JButton;
-import javax.swing.JComponent;
-import javax.swing.JDialog;
-import javax.swing.JOptionPane;
-import javax.swing.JRootPane;
-import javax.swing.KeyStroke;
import jaxx.runtime.JAXXContext;
+import jaxx.runtime.SwingUtil;
import jaxx.runtime.context.JAXXInitialContext;
-import jaxx.runtime.SwingUtil;
-
import jaxx.runtime.swing.editor.config.model.CategoryModel;
import jaxx.runtime.swing.editor.config.model.ConfigUIModel;
import jaxx.runtime.swing.editor.config.model.OptionModel;
@@ -45,8 +30,18 @@
import org.apache.commons.logging.LogFactory;
import static org.nuiton.i18n.I18n._;
+import javax.swing.*;
+import java.awt.*;
+import java.awt.event.ActionEvent;
+import java.awt.event.WindowAdapter;
+import java.awt.event.WindowEvent;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
/**
* La classe pour construire l'ui
+ *
* @author chemit
*/
public class ConfigUIBuilder {
@@ -56,12 +51,12 @@
/**
* Construire l'ui de configuration (sous forme de panel)
*
- * @param parentContext le context applicatif
- * @param model le modele de l'ui de configuration
+ * @param parentContext le context applicatif
+ * @param model le modele de l'ui de configuration
* @param defaultCategory la categorie a selectionner
* @return l'ui instanciate
*/
- public static ConfigUI newConfigUI(jaxx.runtime.JAXXContext parentContext, final ConfigUIModel model, String defaultCategory) {
+ public static ConfigUI newConfigUI(JAXXContext parentContext, final ConfigUIModel model, String defaultCategory) {
JAXXContext tx = new JAXXInitialContext().add(parentContext).add(model);
final ConfigUI ui = new ConfigUI(tx);
@@ -78,28 +73,119 @@
return;
}
+ boolean needReloadUI = false;
+ boolean needReloadApplication = false;
+
+ StringBuilder reloadUIBuffer = new StringBuilder();
+
+ StringBuilder reloadApplicationBuffer = new StringBuilder();
+
if (model.isSaved() && !model.isStandalone()) {
+
+
StringBuilder buffer = new StringBuilder();
+
// on doit verifier si des options sauvees necessite
// un redemarrage de l'application
for (CategoryModel cat : model) {
List<OptionModel> savedOptions = cat.getSavedOptions();
+ List<OptionModel> needReloadUIOptions = new ArrayList<OptionModel>();
+ List<OptionModel> needReloadApplicationOptions = new ArrayList<OptionModel>();
if (!savedOptions.isEmpty()) {
+ Iterator<OptionModel> itr = savedOptions.iterator();
buffer.append("\n").append(_("config.category.saved", _(cat.getCategory()))).append("\n");
- for (OptionModel option : savedOptions) {
+ while (itr.hasNext()) {
+ OptionModel option = itr.next();
buffer.append("\n- ").append(option.getKey());
+ if (option.isNeedReloadApplication()) {
+ needReloadApplication = true;
+ needReloadApplicationOptions.add(option);
+ continue;
+ }
+ if (option.isNeedReloadUI()) {
+ needReloadUI = true;
+ needReloadUIOptions.add(option);
+ continue;
+ }
+ itr.remove();
+
}
+ if (!savedOptions.isEmpty()) {
+
+ if (!needReloadApplicationOptions.isEmpty()) {
+ reloadApplicationBuffer.append("\n");
+ reloadApplicationBuffer.append(_("config.category.needReloadApplication", _(cat.getCategory())));
+ reloadApplicationBuffer.append("\n");
+ // second pass to obtain needReloadUI
+ for (OptionModel option : needReloadApplicationOptions) {
+ reloadApplicationBuffer.append("\n- ").append(option.getKey());
+ }
+ }
+
+ if (!needReloadUIOptions.isEmpty()) {
+ reloadUIBuffer.append("\n");
+ reloadUIBuffer.append(_("config.category.needReloadUI", _(cat.getCategory())));
+ reloadUIBuffer.append("\n");
+ // second pass to obtain needReloadUI
+ for (OptionModel option : needReloadUIOptions) {
+ reloadUIBuffer.append("\n- ").append(option.getKey());
+ }
+ }
+ }
+
}
+ }
+ if (log.isInfoEnabled()) {
+ log.info("save options :\n" + buffer.toString());
}
-// askUser(ui,
-// _("config.title.will.reload.application"), buffer.toString(),
-// JOptionPane.INFORMATION_MESSAGE,
-// new Object[]{
-// _("config.choice.ok")},
-// 0);
+
+ if (needReloadApplication) {
+
+ // reloading application implies reloading ui
+ needReloadUI = false;
+
+ askUser(ui,
+ _("config.title.will.reload.application"),
+ _("config.model.needReloadApplication") +
+ reloadApplicationBuffer.toString(),
+ JOptionPane.INFORMATION_MESSAGE,
+ new Object[]{_("config.choice.ok")},
+ 0);
+ }
+
+ if (needReloadUI) {
+ askUser(ui,
+ _("config.title.will.reload.ui"),
+ _("config.model.needReloadUI") +
+ reloadUIBuffer.toString(),
+ JOptionPane.INFORMATION_MESSAGE,
+ new Object[]{_("config.choice.ok")},
+ 0);
+ }
}
+
+ // close the configu ui
ui.getParentContainer(Window.class).dispose();
+
+ if (needReloadApplication) {
+
+ Runnable callback = model.getReloadApplicationCallback();
+ if (callback == null) {
+ throw new IllegalStateException("No reloadApplicationCallback found in model");
+ }
+
+ SwingUtilities.invokeLater(callback);
+ } else if (needReloadUI) {
+
+ Runnable callback = model.getReloadUICallback();
+ if (callback == null) {
+ throw new IllegalStateException("No reloadUICallback found in model");
+ }
+ SwingUtilities.invokeLater(callback);
+ }
+
+
}
};
String tip = quitButton.getToolTipText();
@@ -127,9 +213,9 @@
/**
* Affiche l'ui de configuration dans un boite de dialogue.
- *
- * @param configUI l'ui de configuration
- * @param ui l'ui parent de la boite de dialogue a afficher (peut etre nulle)
+ *
+ * @param configUI l'ui de configuration
+ * @param ui l'ui parent de la boite de dialogue a afficher (peut etre nulle)
* @param undecorated un drapeau pour savoir si on affiche les decorations de fenetre
*/
public static void showConfigUI(final ConfigUI configUI, Frame ui, boolean undecorated) {
@@ -149,9 +235,6 @@
public void windowClosing(WindowEvent e) {
ActionEvent myEvent = new ActionEvent(e.getSource(), 1, "quit");
configUI.getQuit().getAction().actionPerformed(myEvent);
-// if (canQuitCategory(configUI)) {
-// e.getWindow().dispose();
-// }
}
});
f.setUndecorated(undecorated);
@@ -185,8 +268,8 @@
buffer.toString(),
JOptionPane.ERROR_MESSAGE,
new Object[]{
- _("config.choice.continue"),
- _("config.choice.cancel")},
+ _("config.choice.continue"),
+ _("config.choice.cancel")},
0);
switch (reponse) {
@@ -216,9 +299,9 @@
_("config.title.need.confirm"), buffer.toString(),
JOptionPane.WARNING_MESSAGE,
new Object[]{
- _("config.choice.save"),
- _("config.choice.doNotSave"),
- _("config.choice.cancel")},
+ _("config.choice.save"),
+ _("config.choice.doNotSave"),
+ _("config.choice.cancel")},
0);
switch (reponse) {
@@ -242,7 +325,17 @@
public static int askUser(ConfigUI parent, String title, String message, int typeMessage, Object[] options, int defaultOption) {
- int response = JOptionPane.showOptionDialog(parent, message, title, JOptionPane.DEFAULT_OPTION, typeMessage, null, options, options[defaultOption]);
+ int response = JOptionPane.showOptionDialog(
+ parent,
+ message,
+ title,
+ JOptionPane.DEFAULT_OPTION,
+ typeMessage,
+ null,
+ options,
+ options[defaultOption]
+ );
+
return response;
}
}
Modified: trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/model/CategoryModel.java
===================================================================
--- trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/model/CategoryModel.java 2009-12-22 07:45:46 UTC (rev 1693)
+++ trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/model/CategoryModel.java 2009-12-22 17:34:34 UTC (rev 1694)
@@ -49,6 +49,18 @@
/** suport of modification */
protected PropertyChangeSupport pcs = new PropertyChangeSupport(this);
+ protected CategoryModel(String category, String categoryLabel) {
+ super();
+ this.category = category;
+ this.categoryLabel = categoryLabel;
+ this.entries = new ArrayList<OptionModel>();
+ }
+
+ protected void addOption(OptionModel option) {
+ entries.add(option);
+ }
+
+ @Deprecated
public CategoryModel(String category, String categoryLabel, OptionModel[] entries) {
super();
this.category = category;
Modified: trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/model/ConfigUIModel.java
===================================================================
--- trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/model/ConfigUIModel.java 2009-12-22 07:45:46 UTC (rev 1693)
+++ trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/model/ConfigUIModel.java 2009-12-22 17:34:34 UTC (rev 1694)
@@ -20,37 +20,41 @@
*/
package jaxx.runtime.swing.editor.config.model;
-import java.beans.PropertyChangeListener;
-import java.beans.PropertyChangeSupport;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map;
+import org.apache.commons.beanutils.PropertyUtils;
+import static org.nuiton.i18n.I18n._;
import org.nuiton.util.ApplicationConfig;
import org.nuiton.util.ApplicationConfig.OptionDef;
-import static org.nuiton.i18n.I18n._;
+import java.beans.PropertyChangeListener;
+import java.beans.PropertyChangeSupport;
+import java.util.*;
+
/**
* Le modele de l'ui des preferences.
+ * <p/>
+ * Ce modele contient les catégories des options.
*
- * Ce modele contient les catégories des options.
- *
* @author chemit
*/
public class ConfigUIModel implements Iterable<CategoryModel> {
public static final String CATEGORY_MODEL_PROPERTY_NAME = "categoryModel";
- /** le dictionnaire des options disponibles par categorie */
+ /**
+ * le dictionnaire des options disponibles par categorie
+ */
protected final Map<String, CategoryModel> categories;
- /** La configuration de l'application */
+ /**
+ * La configuration de l'application
+ */
protected final ApplicationConfig config;
- /** la cateogrie en cours d'utilisation */
+ /**
+ * la cateogrie en cours d'utilisation
+ */
protected CategoryModel categoryModel;
/**
* un drapeau pour savoir si la configuration a été modifiée au moins une
* fois.
- *
+ * <p/>
* On utilise ce drapeau lors de la sortie pour verifier s'il faut ou non
* redemarer l'application (si non en mode standalone)
*/
@@ -58,12 +62,23 @@
/**
* un drapeau pour savoir si l'ui de configuration a été lancée en mode
* standalone ou pas.
- *
+ * <p/>
* Si pas lancée en mode standalone, et si la confi a été sauvé on vérifie
* s'il ne faut pas relancer l'application.
*/
protected boolean standalone;
- /** suport of modification */
+ /**
+ * call back when reload ui is necessary
+ */
+ protected Runnable reloadUICallback;
+ /**
+ * call back when reload application is necessary
+ */
+ protected Runnable reloadApplicationCallback;
+
+ /**
+ * suport of modification
+ */
protected final PropertyChangeSupport pcs = new PropertyChangeSupport(this);
public ConfigUIModel(ApplicationConfig config) {
@@ -74,10 +89,12 @@
/**
* Ajoute une categorie dans le modele.
*
- * @param category l'id de la categorie (la clef de traduction du nom de la categorie)
+ * @param category l'id de la categorie (la clef de traduction du nom de la categorie)
* @param categoryLabel la clef de traduction de la description de la categorie
- * @param keys les options de la categorie
+ * @param keys les options de la categorie
+ * @deprecated since 2.0.0 prefer use the {@link #addCategory(CategoryModel)}
*/
+ @Deprecated
public void addCategory(String category, String categoryLabel, OptionDef... keys) {
if (categories.containsKey(category)) {
throw new IllegalArgumentException(_("config.error.category.already.exists", category));
@@ -94,8 +111,20 @@
}
/**
+ * Ajoute une categorie dans le modele.
+ *
+ * @param category la categorie a ajouter au modèle.
+ */
+ public void addCategory(CategoryModel category) {
+ if (categories.containsKey(category.getCategory())) {
+ throw new IllegalArgumentException(_("config.error.category.already.exists", category.getCategory()));
+ }
+ categories.put(category.getCategory(), category);
+ }
+
+ /**
* Change la categorie en cours d'édition.
- *
+ *
* @param category l'id de la categorie courante
*/
public void setCategory(String category) {
@@ -139,25 +168,53 @@
this.standalone = standalone;
}
+ public Runnable getReloadApplicationCallback() {
+ return reloadApplicationCallback;
+ }
+
+ public Runnable getReloadUICallback() {
+ return reloadUICallback;
+ }
+
public void saveModified() {
// compute transients keys (to never be saved)
List<String> transients = new ArrayList<String>();
- for (OptionModel option : categoryModel) {
- if (option.isModified()) {
- Object value = option.getValue();
- //TODO TC-20090245 : should try to seek for a mutator, since
- // mutator could have extra code to be done when modify an option
- config.setOption(option.getKey(), value == null ? null : value.toString());
- // l'option a été sauvegardée, on la marque
- option.setSaved(true);
- // this is the new original value
- option.initValue(value);
+ //TODO TC-20091222 : will be in ApplicationConfig, for the moment catch in your config it...
+// config.setAdjusting(true);
+ config.setOption("adjusting", "true");
+
+ try {
+ for (OptionModel option : categoryModel) {
+ if (option.isModified()) {
+ Object value = option.getValue();
+ //TODO TC-20090245 : should try to seek for a mutator, since
+ if (option.getPropertyName() != null) {
+ // this is a javaBean option
+ try {
+ PropertyUtils.setProperty(config, option.getPropertyName(), value);
+ } catch (Exception e) {
+ throw new RuntimeException("could not set property [" + option.getPropertyName() + "] with value = " + value, e);
+ }
+ } else {
+ // mutator could have extra code to be done when modify an option
+ config.setOption(option.getKey(), value == null ? null : value.toString());
+ }
+ // l'option a été sauvegardée, on la marque
+ option.setSaved(true);
+ // this is the new original value
+ option.initValue(value);
+ }
+ if (option.isTransient()) {
+ transients.add(option.getKey());
+ }
}
- if (option.isTransient()) {
- transients.add(option.getKey());
- }
+ } finally {
+ //TODO TC-20091222 : will be in ApplicationConfig, for the moment catch in your config it...
+// config.setAdjusting(false);
+ config.setOption("adjusting", "false");
}
+
setSaved(true);
// save config
config.saveForUser(transients.toArray(new String[transients.size()]));
@@ -223,4 +280,16 @@
public synchronized PropertyChangeListener[] getPropertyChangeListeners() {
return pcs.getPropertyChangeListeners();
}
+
+ protected void setReloadApplicationCallback(Runnable reloadApplicationCallback) {
+ this.reloadApplicationCallback = reloadApplicationCallback;
+ }
+
+ protected void setReloadUICallback(Runnable reloadUICallback) {
+ this.reloadUICallback = reloadUICallback;
+ }
+
+ protected ApplicationConfig getConfig() {
+ return config;
+ }
}
Added: trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/model/ConfigUIModelBuilder.java
===================================================================
--- trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/model/ConfigUIModelBuilder.java (rev 0)
+++ trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/model/ConfigUIModelBuilder.java 2009-12-22 17:34:34 UTC (rev 1694)
@@ -0,0 +1,305 @@
+package jaxx.runtime.swing.editor.config.model;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.nuiton.util.ApplicationConfig;
+
+import javax.swing.table.TableCellEditor;
+
+/**
+ * A builder of {@link jaxx.runtime.swing.editor.config.model.ConfigUIModel}
+ * Created: 22 déc. 2009
+ *
+ * @author Tony Chemit <chemit(a)codelutin.com> Copyright Code Lutin
+ * @version $Revision$
+ * <p/>
+ * Mise a jour: $Date$ par :
+ * $Author: tchemit $
+ * @since 2.0.0
+ */
+public class ConfigUIModelBuilder {
+ /**
+ * Logger
+ */
+ private static final Log log = LogFactory.getLog(ConfigUIModelBuilder.class);
+
+ /**
+ * current model used
+ */
+ ConfigUIModel model;
+ /**
+ * current category used
+ */
+ CategoryModel category;
+ /**
+ * current option used
+ */
+ OptionModel option;
+
+ /**
+ * Create a new model and set it as current model.
+ *
+ * @param config the configuration used in model
+ * @throws IllegalStateException if there is already a current model
+ * @throws NullPointerException if config is {@code null}
+ */
+ public void createModel(ApplicationConfig config) throws IllegalStateException, NullPointerException {
+ checkNoCurrent(model, "model");
+ checkNotNull(config, "createModel", "config");
+ model = new ConfigUIModel(config);
+ if (log.isDebugEnabled()) {
+ log.debug("model created : " + model);
+ }
+ }
+
+ /**
+ * Set the {@code reloadApplicationCallback} of the current model.
+ *
+ * @param callback the call back to set
+ * @throws IllegalStateException if there is not a current model
+ * @throws NullPointerException if any of parameter is {@code null}
+ * @see jaxx.runtime.swing.editor.config.model.ConfigUIModel#setReloadApplicationCallback(Runnable)
+ */
+ public void setReloadApplicationCallback(Runnable callback) throws IllegalStateException, NullPointerException {
+ checkCurrent(model, "model");
+ checkNotNull(callback, "setReloadApplicationCallback", "callback");
+ model.setReloadApplicationCallback(callback);
+ }
+
+ /**
+ * Set the {@code reloadUICallback} of the current model.
+ *
+ * @param callback the call back to set
+ * @throws IllegalStateException if there is not a current model
+ * @throws NullPointerException if any of parameter is {@code null}
+ * @see jaxx.runtime.swing.editor.config.model.ConfigUIModel#setReloadUICallback(Runnable)
+ */
+ public void setReloadUICallback(Runnable callback) {
+ checkCurrent(model, "model");
+ checkNotNull(callback, "setReloadUICallback", "callback");
+ model.setReloadUICallback(callback);
+ }
+
+ /**
+ * Add a new category, and set it as current.
+ * <p/>
+ * <b>Note:</b> As side effets, if a previous category, then store it to the model.
+ *
+ * @param categoryName the name of the new category (can not to be {@code null})
+ * @param categoryLabel the label of the new category (can not to be {@code null})
+ * @throws IllegalStateException if there is not a current model, nor category
+ * @throws NullPointerException if any of parameter is {@code null}
+ */
+ public void addCategory(String categoryName, String categoryLabel) throws IllegalStateException, NullPointerException {
+ checkCurrent(model, "model");
+ checkNotNull(categoryName, "addCategory", "categoryName");
+ checkNotNull(categoryLabel, "addCategory", "categoryLabel");
+ flushCategory();
+ category = new CategoryModel(categoryName, categoryLabel);
+ if (log.isDebugEnabled()) {
+ log.debug("category created : " + category);
+ }
+ }
+
+ /**
+ * Add a new option, and set it as current.
+ * <p/>
+ * <b>Note:</b> As side effets, if a previous option, then store it to the model.
+ *
+ * @param def the def ot the new option
+ * @throws IllegalStateException if there is not a current model, nor category
+ * @throws NullPointerException if any of parameter is {@code null}
+ */
+ public void addOption(ApplicationConfig.OptionDef def) throws IllegalStateException, NullPointerException {
+ checkCurrent(model, "model");
+ checkCurrent(category, "category");
+ checkNotNull(def, "addOption", "def");
+ flushOption();
+ Object value = model.getConfig().getOption(def);
+ option = new OptionModel(def, value);
+ if (log.isDebugEnabled()) {
+ log.debug("option created : " + option);
+ }
+ }
+
+ /**
+ * Add a new option with a propertyName, and set it as current.
+ * <p/>
+ * <b>Note:</b> As side effets, if a previous option, then store it to the model.
+ * <p/>
+ * <b>Note:</b> This method is a short-cut for
+ * {@link #addOption(org.nuiton.util.ApplicationConfig.OptionDef)} then
+ * {@link #setOptionPropertyName(String)}.
+ *
+ * @param def the def ot the new option
+ * @param propertyName the propertyName to set on the option
+ * @throws IllegalStateException if there is not a current model, nor category
+ * @throws NullPointerException if any of parameter is {@code null}
+ */
+ public void addOption(ApplicationConfig.OptionDef def, String propertyName) throws IllegalStateException, NullPointerException {
+ addOption(def);
+ checkNotNull(propertyName, "setOptionPropertyName", "propertyName");
+ option.setPropertyName(propertyName);
+ }
+
+ /**
+ * Set the propertyName on the current option.
+ *
+ * @param propertyName the propertyName to set in the current option.
+ * @throws IllegalStateException if there is not a current option set.
+ * @throws NullPointerException if any of parameter is {@code null}
+ * @see jaxx.runtime.swing.editor.config.model.OptionModel#setPropertyName(String)
+ */
+ public void setOptionPropertyName(String propertyName) throws IllegalStateException, NullPointerException {
+ checkCurrent(option, "option");
+ checkNotNull(propertyName, "setOptionPropertyName", "propertyName");
+ option.setPropertyName(propertyName);
+ }
+
+ /**
+ * Set the editor on the current option.
+ *
+ * @param editor the editor to set in the current option.
+ * @throws IllegalStateException if there is not a current option set.
+ * @throws NullPointerException if any of parameter is {@code null}
+ * @see jaxx.runtime.swing.editor.config.model.OptionModel#setEditor(javax.swing.table.TableCellEditor)
+ */
+ public void setOptionEditor(TableCellEditor editor) throws IllegalStateException, NullPointerException {
+ checkCurrent(option, "option");
+ checkNotNull(editor, "setOptionEditor", "editor");
+ option.setEditor(editor);
+ }
+
+ /**
+ * Set the needReloadUI flag on the current option.
+ *
+ * @param needReload new value to set
+ * @throws IllegalStateException if there is not a current option set.
+ * @see jaxx.runtime.swing.editor.config.model.OptionModel#setNeedReloadUI(boolean)
+ */
+ public void setOptionNeedReloadUI(boolean needReload) throws IllegalStateException {
+ checkCurrent(option, "option");
+ option.setNeedReloadUI(needReload);
+ }
+
+ /**
+ * Set the needReloadApplication flag on the current option.
+ *
+ * @param needReload new value to set
+ * @throws IllegalStateException if there is not a current option set.
+ * @see jaxx.runtime.swing.editor.config.model.OptionModel#setNeedReloadUI(boolean)
+ */
+ public void setOptionNeedReloadApplication(boolean needReload) throws IllegalStateException {
+ checkCurrent(option, "option");
+ option.setNeedReloadApplication(needReload);
+ }
+
+ /**
+ * Flush the model and return it.
+ * <p/>
+ * <b>Note:</b> As a side effect, nothing is available in the builder after this operation.
+ * To reuse the builder on a model, use the dedicated setter.
+ *
+ * @return the final model
+ * @throws IllegalStateException if there is not a current model set.
+ */
+ public ConfigUIModel flushModel() throws IllegalStateException {
+ checkCurrent(model, "model");
+ flushCategory();
+ ConfigUIModel result = model;
+ model = null;
+ return result;
+ }
+
+ /**
+ * Set the given model as current model.
+ * <p/>
+ * <b>Note:</b> As side effets, il will clean current category and option.
+ *
+ * @param model the model to use
+ * @throws IllegalStateException if there is already a current model
+ */
+ public void setModel(ConfigUIModel model) throws IllegalStateException {
+ checkNoCurrent(model, "model");
+ this.model = model;
+ if (log.isDebugEnabled()) {
+ log.debug("new current model : " + this.model);
+ }
+ category = null;
+ option = null;
+ }
+
+ /**
+ * Set the given category as current category.
+ * <p/>
+ * <b>Note:</b> As side effets, il will clean current option.
+ *
+ * @param categoryModel the category to use
+ * @throws IllegalStateException if there is not a current model or a current category
+ */
+ public void setCategory(CategoryModel categoryModel) throws IllegalStateException {
+ checkCurrent(model, "model");
+ checkNoCurrent(category, "category");
+ category = categoryModel;
+ if (log.isDebugEnabled()) {
+ log.debug("new current category : " + this.category);
+ }
+ option = null;
+ }
+
+ /**
+ * Sets the given option as current option.
+ *
+ * @param optionModel the option to use
+ * @throws IllegalStateException if there is not a current model, nor category, or a current option
+ */
+ public void setOption(OptionModel optionModel) throws IllegalStateException {
+ checkCurrent(model, "model");
+ checkCurrent(category, "category");
+ checkNoCurrent(option, "option");
+ option = optionModel;
+ if (log.isDebugEnabled()) {
+ log.debug("new current option : " + this.option);
+ }
+ }
+
+ protected CategoryModel flushCategory() {
+ CategoryModel result = category;
+ if (category != null) {
+ flushOption();
+ // add the previous category to the model
+ model.addCategory(category);
+ category = null;
+ }
+ return result;
+ }
+
+ protected OptionModel flushOption() {
+ OptionModel result = option;
+ if (option != null) {
+ // add the previous option to the category
+ category.addOption(option);
+ option = null;
+ }
+ return result;
+ }
+
+ protected void checkCurrent(Object o, String type) {
+ if (o == null) {
+ throw new IllegalStateException("no current " + type + "!");
+ }
+ }
+
+ protected void checkNoCurrent(Object o, String type) {
+ if (o != null) {
+ throw new IllegalStateException("there is already a current " + type + "!");
+ }
+ }
+
+ protected void checkNotNull(Object o, String method, String parameter) {
+ if (o == null) {
+ throw new NullPointerException("method " + method + " does not support null parameter " + parameter + "!");
+ }
+ }
+
+}
Property changes on: trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/model/ConfigUIModelBuilder.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL
Modified: trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/model/OptionModel.java
===================================================================
--- trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/model/OptionModel.java 2009-12-22 07:45:46 UTC (rev 1693)
+++ trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/model/OptionModel.java 2009-12-22 17:34:34 UTC (rev 1694)
@@ -22,6 +22,8 @@
import org.nuiton.util.ApplicationConfig.OptionDef;
+import javax.swing.table.TableCellEditor;
+
/**
* le modele d'une option de la configuration a editer.
*
@@ -29,16 +31,42 @@
*/
public class OptionModel implements OptionDef {
- /** la definition de l'option ( venant de la config) */
+ /**
+ * la definition de l'option ( venant de la config)
+ */
protected final OptionDef def;
- /** un drapeau pour savoir si l'option est valide (n'est pas utilisé actuellement) */
+ /**
+ * un drapeau pour savoir si l'option est valide (n'est pas utilisé actuellement)
+ */
protected boolean valid = true;
- /** un drapeau pour savoir si l'option a été sauvée */
+ /**
+ * un drapeau pour savoir si l'option a été sauvée
+ */
protected boolean saved = false;
- /** la valeur non modifié de l'option */
+ /**
+ * un drapeau pour savoir si le changement de l'option nécessite un redémarrage de l'ui.
+ */
+ protected boolean needReloadUI = false;
+ /**
+ * un drapeau pour savoir si le changement de l'option nécessite un redémarrage de l'application.
+ */
+ protected boolean needReloadApplication = false;
+ /**
+ * la valeur non modifié de l'option
+ */
protected Object originalValue;
- /** la valeur actuelle de l'option (peut être la valeur orignal si non modifée)*/
+ /**
+ * la valeur actuelle de l'option (peut être la valeur orignal si non modifée)
+ */
protected Object value;
+ /**
+ * le nom de la propriété javaBean (peut etre null, si option sans support javaBean)
+ */
+ protected String propertyName;
+ /**
+ * l'editeur utilise pour modifier graphiquement l'option
+ */
+ protected TableCellEditor editor;
protected OptionModel(OptionDef def, Object value) {
this.def = def;
@@ -75,6 +103,14 @@
return def.isFinal();
}
+ public boolean isNeedReloadUI() {
+ return needReloadUI;
+ }
+
+ public boolean isNeedReloadApplication() {
+ return needReloadApplication;
+ }
+
public Object getOriginalValue() {
return originalValue;
}
@@ -106,9 +142,33 @@
public void setSaved(boolean saved) {
this.saved = saved;
}
-
+
public void initValue(Object originalValue) {
this.originalValue = originalValue;
this.value = originalValue;
}
+
+ public String getPropertyName() {
+ return propertyName;
+ }
+
+ public TableCellEditor getEditor() {
+ return editor;
+ }
+
+ protected void setEditor(TableCellEditor editor) {
+ this.editor = editor;
+ }
+
+ protected void setNeedReloadUI(boolean needReloadUI) {
+ this.needReloadUI = needReloadUI;
+ }
+
+ protected void setNeedReloadApplication(boolean needReloadApplication) {
+ this.needReloadApplication = needReloadApplication;
+ }
+
+ protected void setPropertyName(String propertyName) {
+ this.propertyName = propertyName;
+ }
}
Modified: trunk/jaxx-widgets/src/main/resources/i18n/jaxx-widgets-en_GB.properties
===================================================================
--- trunk/jaxx-widgets/src/main/resources/i18n/jaxx-widgets-en_GB.properties 2009-12-22 07:45:46 UTC (rev 1693)
+++ trunk/jaxx-widgets/src/main/resources/i18n/jaxx-widgets-en_GB.properties 2009-12-22 17:34:34 UTC (rev 1694)
@@ -9,6 +9,8 @@
config.action.reset.tip=Cancel the modifications for the category
config.action.save=Save
config.action.save.tip=Save the modifications for the category
+config.category.needReloadApplication=
+config.category.needReloadUI=
config.category.saved=The category '%1$s' was modified \:
config.choice.cancel=Cancel
config.choice.continue=Continue
@@ -24,6 +26,8 @@
config.key.tip=Key of the option
config.message.quit.invalid.category=The category '%1$s' is not valid\!
config.message.quit.valid.and.modified.category=The category '%1$s' has some modified options \:
+config.model.needReloadApplication=
+config.model.needReloadUI=
config.modified=Option was modified (previous value \: %1$s)
config.no.option.selected=< No selected option >
config.option.final=This option can not be modified
@@ -32,6 +36,7 @@
config.title=Preferences
config.title.need.confirm=A confirmation is required
config.title.will.reload.application=The application need to be restarted
+config.title.will.reload.ui=The graphical interface must be relauched
config.unmodifiable=Can not be modified
config.unvalid=Option is not valid \! (previous value \: %1$s, required type \: %2$s)
config.value=Value
@@ -46,9 +51,9 @@
errorUI.action.close=Close
errorUI.message=An error wad detected...
errorUI.title=Error...
-fontsize.action.default.tip=
-fontsize.action.down.tip=
-fontsize.action.up.tip=
+fontsize.action.default.tip=Restore default font size
+fontsize.action.down.tip=Decrease font size
+fontsize.action.up.tip=Increase font size
hidor.hideTip=Hide
hidor.showTip=Show
i18neditor.empty.locales=< No locale to select >
@@ -74,5 +79,4 @@
numbereditor.clearAll=C
numbereditor.clearOne=CE
numbereditor.toggleSign=+/-
-size\ \:\ =
timeeditor.H=H
Modified: trunk/jaxx-widgets/src/main/resources/i18n/jaxx-widgets-fr_FR.properties
===================================================================
--- trunk/jaxx-widgets/src/main/resources/i18n/jaxx-widgets-fr_FR.properties 2009-12-22 07:45:46 UTC (rev 1693)
+++ trunk/jaxx-widgets/src/main/resources/i18n/jaxx-widgets-fr_FR.properties 2009-12-22 17:34:34 UTC (rev 1694)
@@ -9,6 +9,8 @@
config.action.reset.tip=Annuler les modifications de cette cat\u00E9gorie
config.action.save=Enregistrer
config.action.save.tip=Sauver les modifications de cette cat\u00E9gorie
+config.category.needReloadApplication=Cat\u00E9gorie '%1$s' \:
+config.category.needReloadUI=Cat\u00E9gorie '%1$s' \:
config.category.saved=La cat\u00E9gorie '%1$s' a \u00E9t\u00E9 modifi\u00E9e \:
config.choice.cancel=Annuler
config.choice.continue=Continuer
@@ -24,6 +26,8 @@
config.key.tip=Clef de l'option
config.message.quit.invalid.category=La cat\u00E9gorie '%1$s' n'est pas valide\!
config.message.quit.valid.and.modified.category=La cat\u00E9gorie '%1$s' poss\u00E8dent des options modifi\u00E9es \:
+config.model.needReloadApplication=Des options ont \u00E9t\u00E9 modifi\u00E9s qui n\u00E9cessitent le red\u00E9marrage de l'application.\n
+config.model.needReloadUI=Des options ont \u00E9t\u00E9 modifi\u00E9s qui n\u00E9cessitent le red\u00E9marrage de l'interface graphique.\n
config.modified=Option modifi\u00E9e (valeur originale \: %1$s)
config.no.option.selected=< Pas d'option s\u00E9lectionn\u00E9e >
config.option.final=Option non modifiable
@@ -32,6 +36,7 @@
config.title=Pr\u00E9f\u00E9rences
config.title.need.confirm=Une confirmation de votre part est requise...
config.title.will.reload.application=L'application doit \u00EAtre red\u00E9marrer...
+config.title.will.reload.ui=L'interface graphique doit \u00EAtre relancer...
config.unmodifiable=Ne peut pas \u00EAtre modifi\u00E9
config.unvalid=Option non valide (valeur originale \: %1$s, type requis \: %2$s)
config.value=Valeur
@@ -46,9 +51,9 @@
errorUI.action.close=Fermer
errorUI.message=Une erreur est survenue \!
errorUI.title=Erreur...
-fontsize.action.default.tip=
-fontsize.action.down.tip=
-fontsize.action.up.tip=
+fontsize.action.default.tip=Retour sur la taille par d\u00E9faut
+fontsize.action.down.tip=Diminuer la taille de la police
+fontsize.action.up.tip=Augmenter la taille de la police
hidor.hideTip=Cacher
hidor.showTip=Voir
i18neditor.empty.locales=< Aucune locale \u00E0 s\u00E9lectionner >
@@ -74,5 +79,4 @@
numbereditor.clearAll=C
numbereditor.clearOne=CE
numbereditor.toggleSign=+/-
-size\ \:\ =
timeeditor.H=H
Added: trunk/jaxx-widgets/src/test/java/jaxx/runtime/swing/editor/config/model/ConfigUIModelBuilderTest.java
===================================================================
--- trunk/jaxx-widgets/src/test/java/jaxx/runtime/swing/editor/config/model/ConfigUIModelBuilderTest.java (rev 0)
+++ trunk/jaxx-widgets/src/test/java/jaxx/runtime/swing/editor/config/model/ConfigUIModelBuilderTest.java 2009-12-22 17:34:34 UTC (rev 1694)
@@ -0,0 +1,343 @@
+package jaxx.runtime.swing.editor.config.model;
+
+import jaxx.runtime.swing.editor.MyDefaultCellEditor;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import javax.swing.table.TableCellEditor;
+
+/**
+ * Created: 22 déc. 2009
+ *
+ * @author Tony Chemit <chemit(a)codelutin.com> Copyright Code Lutin
+ * @version $Revision$
+ * <p/>
+ * Mise a jour: $Date$ par :
+ * $Author: tchemit $
+ * @since 2.0.0
+ */
+public class ConfigUIModelBuilderTest {
+
+ ConfigUIModelBuilder builder;
+
+ static MyConfig config;
+
+ @BeforeClass
+ public static void beforeeClass() {
+ config = new MyConfig();
+ }
+
+
+ @Before
+ public void setup() {
+ builder = new ConfigUIModelBuilder();
+ }
+
+ @Test(expected = NullPointerException.class)
+ public void testCreateModelLimitCase0() throws Exception {
+ builder.createModel(null);
+ }
+
+ @Test(expected = IllegalStateException.class)
+ public void testFlushModelLimitCase0() throws Exception {
+ builder.flushModel();
+ }
+
+ @Test
+ public void testCreateModel() throws Exception {
+ builder.createModel(config);
+ ConfigUIModel configModel = builder.flushModel();
+ Assert.assertNotNull(configModel);
+ Assert.assertNotNull(configModel.getConfig());
+
+ }
+
+ @Test(expected = IllegalStateException.class)
+ public void testSetReloadApplicationCallbackLimitCase0() throws Exception {
+ builder.setReloadApplicationCallback(null);
+ }
+
+ @Test(expected = NullPointerException.class)
+ public void testSetReloadApplicationCallbackLimitCase1() throws Exception {
+ builder.createModel(config);
+ builder.setReloadApplicationCallback(null);
+ }
+
+ @Test
+ public void testSetReloadApplicationCallback() throws Exception {
+ builder.createModel(config);
+ Runnable callback = new Runnable() {
+
+ @Override
+ public void run() {
+ }
+ };
+ builder.setReloadApplicationCallback(callback);
+ ConfigUIModel configModel = builder.flushModel();
+ Assert.assertNotNull(configModel);
+ Assert.assertNotNull(configModel.getConfig());
+ Assert.assertEquals(callback, configModel.getReloadApplicationCallback());
+ }
+
+ @Test(expected = IllegalStateException.class)
+ public void testSetReloadUICallbackLimitCase0() throws Exception {
+ builder.setReloadUICallback(null);
+ }
+
+ @Test(expected = NullPointerException.class)
+ public void testSetReloadUICallbackLimitCase1() throws Exception {
+ builder.createModel(config);
+ builder.setReloadUICallback(null);
+ }
+
+ @Test
+ public void testSetReloadUICallback() throws Exception {
+ builder.createModel(config);
+ Runnable callback = new Runnable() {
+
+ @Override
+ public void run() {
+ }
+ };
+ builder.setReloadUICallback(callback);
+ ConfigUIModel configModel = builder.flushModel();
+ Assert.assertNotNull(configModel);
+ Assert.assertNotNull(configModel.getConfig());
+ Assert.assertEquals(callback, configModel.getReloadUICallback());
+ }
+
+ @Test(expected = IllegalStateException.class)
+ public void testAddCategoryLimitCase0() throws Exception {
+ builder.addCategory(null, null);
+ }
+
+ @Test(expected = NullPointerException.class)
+ public void testAddCategoryLimitCase1() throws Exception {
+ builder.createModel(config);
+ builder.addCategory(null, null);
+ }
+
+ @Test(expected = NullPointerException.class)
+ public void testAddCategoryLimitCase2() throws Exception {
+ builder.createModel(config);
+ builder.addCategory("", null);
+ }
+
+ @Test
+ public void testAddCategory() throws Exception {
+ builder.createModel(config);
+ builder.addCategory("cat0", "cat0 label");
+ CategoryModel categoryModel = builder.flushCategory();
+ Assert.assertNotNull(categoryModel);
+ Assert.assertEquals("cat0", categoryModel.category);
+ Assert.assertEquals("cat0 label", categoryModel.categoryLabel);
+ Assert.assertEquals(0, categoryModel.entries.size());
+
+ }
+
+ @Test(expected = IllegalStateException.class)
+ public void testAddOptionLimitCase0() throws Exception {
+ builder.addOption(null);
+ }
+
+ @Test(expected = IllegalStateException.class)
+ public void testAddOptionLimitCase1() throws Exception {
+ builder.createModel(config);
+ builder.addOption(null);
+ }
+
+ @Test(expected = NullPointerException.class)
+ public void testAddOptionLimitCase2() throws Exception {
+ builder.createModel(config);
+ builder.addCategory("cat0", "cat0 label");
+ builder.addOption(null);
+ }
+
+ @Test
+ public void testAddOption() throws Exception {
+ builder.createModel(config);
+ builder.addCategory("cat0", "cat0 label");
+ builder.addOption(MyConfig.Option.LOCALE);
+ OptionModel optionModel = builder.flushOption();
+ Assert.assertNotNull(optionModel);
+ Assert.assertEquals(MyConfig.Option.LOCALE, optionModel.def);
+
+ CategoryModel categoryModel = builder.flushCategory();
+ Assert.assertNotNull(categoryModel);
+ Assert.assertEquals("cat0", categoryModel.category);
+ Assert.assertEquals("cat0 label", categoryModel.categoryLabel);
+ Assert.assertEquals(1, categoryModel.entries.size());
+ }
+
+ @Test(expected = IllegalStateException.class)
+ public void testSetOptionPropertyNameLimitCase0() throws Exception {
+ builder.setOptionPropertyName(null);
+ }
+
+ @Test(expected = IllegalStateException.class)
+ public void testSetOptionPropertyNameLimitCase1() throws Exception {
+ builder.createModel(config);
+ builder.setOptionPropertyName(null);
+ }
+
+ @Test(expected = IllegalStateException.class)
+ public void testSetOptionPropertyNameLimitCase2() throws Exception {
+ builder.createModel(config);
+ builder.addCategory("cat0", "cat0 label");
+ builder.setOptionPropertyName(null);
+ }
+
+
+ @Test(expected = NullPointerException.class)
+ public void testSetOptionPropertyNameLimitCase3() throws Exception {
+ builder.createModel(config);
+ builder.addCategory("cat0", "cat0 label");
+ builder.addOption(MyConfig.Option.LOCALE);
+ builder.setOptionPropertyName(null);
+ }
+
+ @Test
+ public void testSetOptionPropertyName() throws Exception {
+ builder.createModel(config);
+ builder.addCategory("cat0", "cat0 label");
+ builder.addOption(MyConfig.Option.LOCALE);
+ builder.setOptionPropertyName(MyConfig.PROPERTY_LOCALE);
+ OptionModel optionModel = builder.flushOption();
+ Assert.assertNotNull(optionModel);
+ Assert.assertEquals(MyConfig.Option.LOCALE, optionModel.def);
+ Assert.assertEquals(MyConfig.PROPERTY_LOCALE, optionModel.propertyName);
+ Assert.assertEquals(false, optionModel.needReloadUI);
+ Assert.assertNull(optionModel.editor);
+ }
+
+ @Test(expected = IllegalStateException.class)
+ public void testSetOptionEditorLimitCase0() throws Exception {
+ builder.setOptionEditor(null);
+ }
+
+ @Test(expected = IllegalStateException.class)
+ public void testSetOptionEditorLimitCase1() throws Exception {
+ builder.createModel(config);
+ builder.setOptionEditor(null);
+ }
+
+ @Test(expected = IllegalStateException.class)
+ public void testSetOptionEditorLimitCase2() throws Exception {
+ builder.createModel(config);
+ builder.addCategory("cat0", "cat0 label");
+ builder.setOptionEditor(null);
+ }
+
+
+ @Test(expected = NullPointerException.class)
+ public void testSetOptionEditorLimitCase3() throws Exception {
+ builder.createModel(config);
+ builder.addCategory("cat0", "cat0 label");
+ builder.addOption(MyConfig.Option.LOCALE);
+ builder.setOptionEditor(null);
+ }
+
+ @Test
+ public void testSetOptionEditor() throws Exception {
+ builder.createModel(config);
+ builder.addCategory("cat0", "cat0 label");
+ builder.addOption(MyConfig.Option.LOCALE);
+ TableCellEditor cellEditor = MyDefaultCellEditor.newBooleanEditor();
+ builder.setOptionEditor(cellEditor);
+ OptionModel optionModel = builder.flushOption();
+ Assert.assertNotNull(optionModel);
+ Assert.assertEquals(MyConfig.Option.LOCALE, optionModel.def);
+ Assert.assertNull(optionModel.propertyName);
+ Assert.assertEquals(false, optionModel.needReloadUI);
+ Assert.assertEquals(cellEditor, optionModel.editor);
+ }
+
+ @Test(expected = IllegalStateException.class)
+ public void testSetOptionNeedReloadUILimitCase0() throws Exception {
+ builder.setOptionNeedReloadUI(false);
+ }
+
+ @Test(expected = IllegalStateException.class)
+ public void testSetOptionNeedReloadUILimitCase1() throws Exception {
+ builder.createModel(config);
+ builder.setOptionNeedReloadUI(true);
+ }
+
+ @Test(expected = IllegalStateException.class)
+ public void testSetOptionNeedReloadUILimitCase2() throws Exception {
+ builder.createModel(config);
+ builder.addCategory("cat0", "cat0 label");
+ builder.setOptionNeedReloadUI(false);
+ }
+
+ @Test
+ public void testSetOptionNeedReloadUI() throws Exception {
+ builder.createModel(config);
+ builder.addCategory("cat0", "cat0 label");
+ builder.addOption(MyConfig.Option.LOCALE);
+ builder.setOptionNeedReloadUI(true);
+ OptionModel optionModel = builder.flushOption();
+ Assert.assertNotNull(optionModel);
+ Assert.assertEquals(MyConfig.Option.LOCALE, optionModel.def);
+ Assert.assertEquals(true, optionModel.needReloadUI);
+ Assert.assertNull(optionModel.propertyName);
+ Assert.assertNull(optionModel.editor);
+ }
+
+ @Test(expected = IllegalStateException.class)
+ public void testSetOptionNeedReloadApplicationLimitCase0() throws Exception {
+ builder.setOptionNeedReloadApplication(false);
+ }
+
+ @Test(expected = IllegalStateException.class)
+ public void testSetOptionNeedReloadApplicationLimitCase1() throws Exception {
+ builder.createModel(config);
+ builder.setOptionNeedReloadApplication(true);
+ }
+
+ @Test(expected = IllegalStateException.class)
+ public void testSetOptionNeedReloadApplicationLimitCase2() throws Exception {
+ builder.createModel(config);
+ builder.addCategory("cat0", "cat0 label");
+ builder.setOptionNeedReloadApplication(false);
+ }
+
+ @Test
+ public void testSetOptionNeedReloadApplication() throws Exception {
+ builder.createModel(config);
+ builder.addCategory("cat0", "cat0 label");
+ builder.addOption(MyConfig.Option.LOCALE);
+ builder.setOptionNeedReloadApplication(true);
+ OptionModel optionModel = builder.flushOption();
+ Assert.assertNotNull(optionModel);
+ Assert.assertEquals(MyConfig.Option.LOCALE, optionModel.def);
+ Assert.assertEquals(true, optionModel.needReloadApplication);
+ Assert.assertNull(optionModel.propertyName);
+ Assert.assertNull(optionModel.editor);
+ }
+
+
+ @Test
+ public void testFlushModel() throws Exception {
+ builder.createModel(config);
+ ConfigUIModel configModel = builder.flushModel();
+ Assert.assertNotNull(configModel);
+ Assert.assertNull(builder.model);
+ }
+
+ @Test
+ public void testSetModel() throws Exception {
+
+ }
+
+ @Test
+ public void testSetCategory() throws Exception {
+ }
+
+ @Test
+ public void testSetOption() throws Exception {
+ }
+
+}
Property changes on: trunk/jaxx-widgets/src/test/java/jaxx/runtime/swing/editor/config/model/ConfigUIModelBuilderTest.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL
Copied: trunk/jaxx-widgets/src/test/java/jaxx/runtime/swing/editor/config/model/MyConfig.java (from rev 1693, trunk/jaxx-demo/src/main/java/jaxx/demo/DemoConfig.java)
===================================================================
--- trunk/jaxx-widgets/src/test/java/jaxx/runtime/swing/editor/config/model/MyConfig.java (rev 0)
+++ trunk/jaxx-widgets/src/test/java/jaxx/runtime/swing/editor/config/model/MyConfig.java 2009-12-22 17:34:34 UTC (rev 1694)
@@ -0,0 +1,208 @@
+/*
+ * *##%
+ * JAXX Demo
+ * Copyright (C) 2008 - 2009 CodeLutin
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program 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 Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * ##%*
+ */
+package jaxx.runtime.swing.editor.config.model;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import static org.nuiton.i18n.I18n._;
+
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+import java.util.Date;
+import java.util.Locale;
+
+/**
+ * @author chemit
+ * @since 2.0.0
+ */
+public class MyConfig extends org.nuiton.util.ApplicationConfig {
+
+ /**
+ * to use log facility, just put in your code: log.info(\"...\");
+ */
+ static private Log log = LogFactory.getLog(MyConfig.class);
+
+ public static final String PROPERTY_FULLSCREEN = "fullscreen";
+ public static final String PROPERTY_LOCALE = "locale";
+ public static final String PROPERTY_FONT_SIZE = "fontSize";
+ public static final String PROPERTY_ADJUSTING = "adjusting";
+
+ /**
+ * un drapeau pour bloquer la sauvegarde lors de la modification en masse des options
+ * via les setter.
+ */
+ protected boolean adjusting;
+ protected final PropertyChangeListener saveAction = new PropertyChangeListener() {
+
+ @Override
+ public void propertyChange(PropertyChangeEvent evt) {
+ if (adjusting) {
+ if (log.isDebugEnabled()) {
+ log.debug("skip save while adjusting");
+ }
+ return;
+ }
+ if (log.isDebugEnabled()) {
+ log.debug("Saving configuration at " + new Date());
+ }
+ saveForUser();
+ }
+ };
+
+ @Override
+ public void saveForUser(String... excludeKeys) {
+ // never save anything :)
+ }
+
+ public MyConfig() {
+
+ setConfigFileName(Option.CONFIG_FILE.defaultValue);
+
+ // chargement de la configuration interne
+
+ for (Option o : Option.values()) {
+ setDefaultOption(o.key, o.defaultValue);
+ }
+
+ adjusting = true;
+ addPropertyChangeListener(PROPERTY_FULLSCREEN, saveAction);
+ addPropertyChangeListener(PROPERTY_FONT_SIZE, saveAction);
+ addPropertyChangeListener(PROPERTY_LOCALE, saveAction);
+ adjusting = false;
+ }
+
+ @Override
+ public void setOption(String key, String value) {
+ if (key.equals(PROPERTY_ADJUSTING)) {
+ setAdjusting(Boolean.valueOf(value));
+ return;
+ }
+ super.setOption(key, value);
+ }
+
+
+ public boolean isFullScreen() {
+ Boolean result = getOptionAsBoolean(Option.FULL_SCREEN.key);
+ return result != null && result;
+ }
+
+ public Locale getLocale() {
+ Locale result = getOption(Locale.class, Option.LOCALE.key);
+ return result;
+ }
+
+ public Float getFontSize() {
+ Float result = getOption(Float.class, Option.FONT_SIZE.key);
+ return result;
+ }
+
+ public void setFullscreen(boolean fullscreen) {
+ Object oldValue = null;
+ setOption(Option.FULL_SCREEN.key, fullscreen + "");
+// saveForUser();
+ firePropertyChange(PROPERTY_FULLSCREEN, oldValue, fullscreen);
+ }
+
+ public void setLocale(Locale newLocale) {
+ setOption(Option.LOCALE.key, newLocale.toString());
+// saveForUser();
+ firePropertyChange(PROPERTY_LOCALE, null, newLocale);
+ }
+
+ public void setFontSize(Float newFontSize) {
+ Float oldValue = getFontSize();
+ if (log.isDebugEnabled()) {
+ log.debug("changing font-size to " + newFontSize);
+ }
+ setOption(Option.FONT_SIZE.key, newFontSize.toString());
+// saveForUser();
+ firePropertyChange(PROPERTY_FONT_SIZE, oldValue, newFontSize);
+ }
+
+ public boolean isAdjusting() {
+ return adjusting;
+ }
+
+ public void setAdjusting(boolean adjusting) {
+ if (log.isDebugEnabled()) {
+ log.debug("changing adjusting to " + adjusting);
+ }
+ boolean oldValue = this.adjusting;
+ this.adjusting = adjusting;
+ firePropertyChange(PROPERTY_ADJUSTING, oldValue, adjusting);
+ }
+
+ //////////////////////////////////////////////////
+ // Toutes les options disponibles
+ //////////////////////////////////////////////////
+ public static enum Option implements OptionDef {
+
+ CONFIG_FILE(CONFIG_FILE_NAME, _("jaxxdemo.config.configFileName.description"), "jaxxdemo", String.class, true, true),
+ FULL_SCREEN("ui.fullscreen", _("jaxxdemo.config.ui.fullscreen"), "false", Boolean.class, false, false),
+ LOCALE("ui." + PROPERTY_LOCALE, _("jaxxdemo.config.ui." + PROPERTY_LOCALE), Locale.FRANCE.toString(), Locale.class, false, false),
+ FONT_SIZE("ui." + PROPERTY_FONT_SIZE, _("jaxxdemo.config.ui." + PROPERTY_FONT_SIZE), "10f", Float.class, false, false);
+ public final String key;
+ public final String description;
+ public final String defaultValue;
+ public final Class<?> type;
+ public final boolean _transient;
+ public final boolean _final;
+
+ private Option(String key, String description, String defaultValue, Class<?> type, boolean _transient, boolean _final) {
+ this.key = key;
+ this.description = description;
+ this.defaultValue = defaultValue;
+ this.type = type;
+ this._final = _final;
+ this._transient = _transient;
+ }
+
+ @Override
+ public boolean isFinal() {
+ return _final;
+ }
+
+ @Override
+ public boolean isTransient() {
+ return _transient;
+ }
+
+ @Override
+ public String getDefaultValue() {
+ return defaultValue;
+ }
+
+ @Override
+ public String getDescription() {
+ return description;
+ }
+
+ @Override
+ public String getKey() {
+ return key;
+ }
+
+ @Override
+ public Class<?> getType() {
+ return type;
+ }
+ }
+}
\ No newline at end of file
Added: trunk/jaxx-widgets/src/test/resources/log4j.properties
===================================================================
--- trunk/jaxx-widgets/src/test/resources/log4j.properties (rev 0)
+++ trunk/jaxx-widgets/src/test/resources/log4j.properties 2009-12-22 17:34:34 UTC (rev 1694)
@@ -0,0 +1,10 @@
+# Global logging configuration
+log4j.rootLogger=ERROR, stdout
+# Console output...
+log4j.appender.stdout=org.apache.log4j.ConsoleAppender
+log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
+log4j.appender.stdout.layout.ConversionPattern=%5p [%t] (%F:%L) %M - %m%n
+
+log4j.logger.jaxx.swing=INFO
+#log4j.logger.jaxx.runtime.swing.editor.config.model.ConfigUIModelBuilder=DEBUG
+log4j.logger.org.nuiton=WARN
1
0
r1693 - in trunk: jaxx-demo/src/main/java/jaxx/demo jaxx-demo/src/main/java/jaxx/demo/feature/databinding jaxx-demo/src/main/java/jaxx/demo/feature/validation jaxx-demo/src/main/resources/i18n jaxx-widgets/src/main/java/jaxx/runtime/swing
by tchemit@users.nuiton.org 22 Dec '09
by tchemit@users.nuiton.org 22 Dec '09
22 Dec '09
Author: tchemit
Date: 2009-12-22 08:45:46 +0100 (Tue, 22 Dec 2009)
New Revision: 1693
Modified:
trunk/jaxx-demo/src/main/java/jaxx/demo/DemoConfig.java
trunk/jaxx-demo/src/main/java/jaxx/demo/DemoPanel.jaxx
trunk/jaxx-demo/src/main/java/jaxx/demo/DemoSources.jaxx
trunk/jaxx-demo/src/main/java/jaxx/demo/DemoSourcesHandler.java
trunk/jaxx-demo/src/main/java/jaxx/demo/DemoUI.css
trunk/jaxx-demo/src/main/java/jaxx/demo/DemoUIHandler.java
trunk/jaxx-demo/src/main/java/jaxx/demo/feature/databinding/BindingExtremeDemo.jaxx
trunk/jaxx-demo/src/main/java/jaxx/demo/feature/validation/ValidationListDemo.jaxx
trunk/jaxx-demo/src/main/java/jaxx/demo/feature/validation/ValidationTableDemo.jaxx
trunk/jaxx-demo/src/main/resources/i18n/jaxx-demo-en_GB.properties
trunk/jaxx-demo/src/main/resources/i18n/jaxx-demo-fr_FR.properties
trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/FontSizor.jaxx
Log:
improve FontSizor with callback + demo
Modified: trunk/jaxx-demo/src/main/java/jaxx/demo/DemoConfig.java
===================================================================
--- trunk/jaxx-demo/src/main/java/jaxx/demo/DemoConfig.java 2009-12-21 20:11:57 UTC (rev 1692)
+++ trunk/jaxx-demo/src/main/java/jaxx/demo/DemoConfig.java 2009-12-22 07:45:46 UTC (rev 1693)
@@ -36,15 +36,17 @@
/**
* La configuration de l'application.
+ * <p/>
+ * Il s'agit de l'objet partagé par toutes les démos.
*
- * Il s'agit de l'objet partagé par toutes les démos.
- *
* @author chemit
* @since 1.7.2
*/
public class DemoConfig extends org.nuiton.util.ApplicationConfig {
- /** to use log facility, just put in your code: log.info(\"...\"); */
+ /**
+ * to use log facility, just put in your code: log.info(\"...\");
+ */
static private Log log = LogFactory.getLog(DemoConfig.class);
/**
* le fichier de configuration de l'application avec les informations sur
@@ -116,6 +118,11 @@
return result;
}
+ public Float getFontSize() {
+ Float result = getOption(Float.class, Option.FONT_SIZE.key);
+ return result;
+ }
+
public void setFullscreen(boolean fullscreen) {
Object oldValue = null;
setOption(Option.FULL_SCREEN.key, fullscreen + "");
@@ -129,6 +136,13 @@
firePropertyChange("locale", null, newLocale);
}
+ public void setFontSize(Float newFontSize) {
+ Float oldValue = getFontSize();
+ setOption(Option.FONT_SIZE.key, newFontSize.toString());
+ saveForUser();
+ firePropertyChange("fontSize", oldValue, newFontSize);
+ }
+
/**
* Save configuration, in user home directory using the
* {@link #getConfigFileName}. Default, env and commande line note saved
@@ -137,8 +151,9 @@
// shoudl we never save any conf ?
super.saveForUser();
}
+
public static final String[] DEFAULT_JAXX_PCS = {
- "fullScreen", "locale"
+ "fullScreen", "locale", "fontSize"
};
public void removeJaxxPropertyChangeListener() {
@@ -166,6 +181,7 @@
CONFIG_FILE(CONFIG_FILE_NAME, _("jaxxdemo.config.configFileName.description"), "jaxxdemo", String.class, true, true),
FULL_SCREEN("ui.fullscreen", _("jaxxdemo.config.ui.fullscreen"), "false", Boolean.class, false, false),
LOCALE("ui.locale", _("jaxxdemo.config.ui.locale"), Locale.FRANCE.toString(), Locale.class, false, false),
+ FONT_SIZE("ui.fontSize", _("jaxxdemo.config.ui.fontSize"), "10f", Float.class, false, false),
DEMO_PATH("ui.demo.path", _("jaxxdemo.config.ui.demo.path"), "$root/jaxxdemo.tree.component.jaxx/jaxxdemo.tree.component.jaxx.tree.navigation/" + FullNavigationTreeDemo.class.getSimpleName(), String.class, false, false);
public final String key;
public final String description;
Modified: trunk/jaxx-demo/src/main/java/jaxx/demo/DemoPanel.jaxx
===================================================================
--- trunk/jaxx-demo/src/main/java/jaxx/demo/DemoPanel.jaxx 2009-12-21 20:11:57 UTC (rev 1692)
+++ trunk/jaxx-demo/src/main/java/jaxx/demo/DemoPanel.jaxx 2009-12-22 07:45:46 UTC (rev 1693)
@@ -66,9 +66,10 @@
<JPanel id='demoPanel'/>
</tab>
- <tab id='tabDemoSources' tabComponent='{sourceTabs.getSourcesHeader()}'>
+ <tab id='tabDemoSources' title='Sources'>
<DemoSources id='sourceTabs'
sources='{java.util.Arrays.asList(getSources())}'
- incomingClass='{getClass()}'/>
+ incomingClass='{getClass()}'
+ constructorParams='this'/>
</tab>
</JTabbedPane>
\ No newline at end of file
Modified: trunk/jaxx-demo/src/main/java/jaxx/demo/DemoSources.jaxx
===================================================================
--- trunk/jaxx-demo/src/main/java/jaxx/demo/DemoSources.jaxx 2009-12-21 20:11:57 UTC (rev 1692)
+++ trunk/jaxx-demo/src/main/java/jaxx/demo/DemoSources.jaxx 2009-12-22 07:45:46 UTC (rev 1693)
@@ -25,17 +25,32 @@
import jaxx.runtime.swing.FontSizor;
public void init() {
+ //fontSizor.setDefaultFontSize(getConfig().getFontSize());
fontSizor.init();
+ fontSizor.setCallBack(new Runnable() {
+
+ @Override
+ public void run() {
+ log.info("update font size : " + fontSizor.getFontSize());
+ getConfig().setFontSize(fontSizor.getFontSize());
+ }
+ });
handler.init(this);
}
+
+public DemoConfig getConfig() {
+ return getContextValue(DemoConfig.class);
+}
+
+public void updateSource(ItemEvent event) {
+ setCurrentSource((String) sourceTabs.getSelectedItem());
+ editor.setText(handler.getSourceContent(this, getCurrentSource()));
+ editor.setSyntaxEditingStyle(handler.getSourceEditingStyle(this, getCurrentSource()));
+ editor.setCaretPosition(0);
+}
]]>
</script>
- <JPanel id="sourcesHeader" opaque='false'>
- <JLabel text='Sources' opaque='false'/>
- <FontSizor id='fontSizor' opaque='false' showFontSize='true' defaultFontSize='10f' fontSize='10f'/>
- </JPanel>
-
<DemoSourcesHandler id='handler'/>
<Class id='incomingClass' javaBean='null'/>
@@ -44,21 +59,35 @@
<java.util.List id='sources' genericType='String' javaBean='null'/>
- <JTabbedPane id='sourceTabs'
- constraints='BorderLayout.CENTER'
- tabPlacement='{JTabbedPane.BOTTOM}'
- onStateChanged='handler.updateSource(this)'/>
+ <JToolBar id='editorPaneHeader'
+ floatable='false'
+ borderPainted='false'
+ opaque='false'
+ constraints='BorderLayout.SOUTH'>
- <RSyntaxTextArea id='editor'
- constraints='BorderLayout.SOUTH'
- font-size='{fontSizor.getFontSize()}'
- text='{handler.getSourceContent(DemoSources.this, getCurrentSource())}'
- syntaxEditingStyle='{handler.getSourceEditingStyle(DemoSources.this, getCurrentSource())}'
- minimumSize="{jaxx.runtime.SwingUtil.newMinDimension()}"
- textAntiAliasHint='{RenderingHints.KEY_ANTIALIASING.toString()}'
- editable="false"
- wrapStyleWord="false"
- columns="80"
- lineWrap="true"/>
+ <JComboBox id='sourceTabs'
+ model='{new DefaultComboBoxModel()}'
+ onItemStateChanged='if(event.getStateChange() == ItemEvent.SELECTED) { updateSource(event); }'/>
+ <javax.swing.Box.Filler
+ constructorParams='SwingUtil.newMinDimension(), SwingUtil.newMinDimension(), SwingUtil.newMaxXDimension()'/>
+ <FontSizor id='fontSizor' opaque='false' showFontSize='true' defaultFontSize='{getConfig().getFontSize()}'/>
+ <!--defaultFontSize='{getConfig().getFontSize()}' fontSize='{getConfig().getFontSize()}'/>-->
+ </JToolBar>
+ <JScrollPane id='editorPane' columnHeaderView='{editorPaneHeader}' constraints='BorderLayout.CENTER'>
+ <RSyntaxTextArea id='editor'
+ font-size='{getConfig().getFontSize()}'
+ minimumSize="{jaxx.runtime.SwingUtil.newMinDimension()}"
+ textAntiAliasHint='{RenderingHints.KEY_ANTIALIASING.toString()}'
+ editable="false"
+ wrapStyleWord="false"
+ columns="80"
+ lineWrap="true"/>
+ <!--font-size='{updateSize(getFontSizor().getFontSize())}'-->
+ <!-- TC-20091221 : can not use binding since we want to do something after assigment... -->
+ <!--text='{handler.getSourceContent(DemoSources.this, getCurrentSource())}'-->
+ <!--syntaxEditingStyle='{handler.getSourceEditingStyle(DemoSources.this, getCurrentSource())}'-->
+ </JScrollPane>
+
+
</JPanel>
\ No newline at end of file
Modified: trunk/jaxx-demo/src/main/java/jaxx/demo/DemoSourcesHandler.java
===================================================================
--- trunk/jaxx-demo/src/main/java/jaxx/demo/DemoSourcesHandler.java 2009-12-21 20:11:57 UTC (rev 1692)
+++ trunk/jaxx-demo/src/main/java/jaxx/demo/DemoSourcesHandler.java 2009-12-22 07:45:46 UTC (rev 1693)
@@ -1,12 +1,12 @@
package jaxx.demo;
+import jaxx.runtime.SwingUtil;
import org.apache.commons.io.IOUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.fife.ui.rsyntaxtextarea.RSyntaxTextArea;
-import javax.swing.*;
-import java.awt.*;
+import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;
@@ -27,9 +27,9 @@
*/
private static final Log log = LogFactory.getLog(DemoSourcesHandler.class);
- protected Map<String, String> sourcesCache;
+ protected static Map<String, String> sourcesCache;
- public Map<String, String> getSourcesCache() {
+ public static Map<String, String> getSourcesCache() {
if (sourcesCache == null) {
sourcesCache = new TreeMap<String, String>();
}
@@ -44,9 +44,10 @@
if (result == null) {
try {
if (log.isDebugEnabled()) {
- log.debug(name + " from " + getClass());
+ log.debug(name + " from " + ui.getIncomingClass());
}
- result = IOUtils.toString(ui.getIncomingClass().getResourceAsStream(name));
+ String path = name.substring(ui.getIncomingClass().getPackage().getName().length() + 1);
+ result = IOUtils.toString(ui.getIncomingClass().getResourceAsStream(path));
if (log.isDebugEnabled()) {
log.debug("source [" + name + "], loaded content =\n" + result);
}
@@ -64,6 +65,7 @@
if (source == null) {
return "";
}
+ ui.getEditor().setFractionalFontMetricsEnabled(true);
String s = null;
if (source.matches(".*\\.jaxx") || source.matches(".*\\.xml")) {
s = RSyntaxTextArea.SYNTAX_STYLE_XML;
@@ -72,8 +74,8 @@
} else if (source.matches(".*\\.css")) {
s = RSyntaxTextArea.SYNTAX_STYLE_CSS;
}
- if (log.isInfoEnabled()) {
- log.info("source [" + source + "] style = " + s);
+ if (log.isDebugEnabled()) {
+ log.debug("source [" + source + "] style = " + s);
}
return s;
}
@@ -83,42 +85,22 @@
if (sources == null) {
return;
}
- for (String source : sources) {
- if (log.isInfoEnabled()) {
- log.info("adding tab for resource " + source);
+ List<String> toFill = new ArrayList<String>();
+ String prefix = ui.getIncomingClass() == null ? "" : (ui.getIncomingClass().getPackage().getName() + ".");
+ for (String source : sources) {
+ String path = prefix + source;
+ if (log.isDebugEnabled()) {
+ log.debug("adding resource " + path);
}
- JScrollPane pane = new JScrollPane(
- JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
- JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
- pane.setBorder(null);
- // ajout de l'onglet
- ui.sourceTabs.addTab(source, pane);
- int index = ui.sourceTabs.indexOfComponent(pane);
- JLabel l = new JLabel(source);
- l.setFont(l.getFont().deriveFont((float) 10));
- ui.sourceTabs.setTabComponentAt(index, l);
+ toFill.add(path);
}
- }
-
- public void updateSource(DemoSources ui) {
- JTabbedPane sourceTabs = ui.getSourceTabs();
- int index = sourceTabs.getSelectedIndex();
- String sourceName = sourceTabs.getTitleAt(index);
-
- if (log.isInfoEnabled()) {
- log.info("new current Source : " + sourceName);
+ SwingUtil.fillComboBox(ui.getSourceTabs(), toFill, null);
+ if (!toFill.isEmpty()) {
+ ui.getSourceTabs().setSelectedIndex(0);
}
- // attach editor to correct selected tab and reset it
- JScrollPane pane = (JScrollPane) sourceTabs.getComponentAt(index);
- pane.getViewport().add(ui.getEditor());
- ui.getEditor().setText("");
- ui.getEditor().setCaretPosition(0);
- ui.getEditor().setTextAntiAliasHint(RenderingHints.KEY_ANTIALIASING.toString());
-
- // change the current source to release the editor
- ui.setCurrentSource(sourceName);
-
+ toFill.clear();
+ ui.getEditor().discardAllEdits();
}
}
Modified: trunk/jaxx-demo/src/main/java/jaxx/demo/DemoUI.css
===================================================================
--- trunk/jaxx-demo/src/main/java/jaxx/demo/DemoUI.css 2009-12-21 20:11:57 UTC (rev 1692)
+++ trunk/jaxx-demo/src/main/java/jaxx/demo/DemoUI.css 2009-12-22 07:45:46 UTC (rev 1693)
@@ -49,7 +49,7 @@
toolTipText:"jaxxdemo.action.configuration.tip";
actionIcon:"config";
mnemonic:C;
- enabled:false;
+ /*enabled:false;*/
_help:{"ui.main.menu.file.configuration"};
}
Modified: trunk/jaxx-demo/src/main/java/jaxx/demo/DemoUIHandler.java
===================================================================
--- trunk/jaxx-demo/src/main/java/jaxx/demo/DemoUIHandler.java 2009-12-21 20:11:57 UTC (rev 1692)
+++ trunk/jaxx-demo/src/main/java/jaxx/demo/DemoUIHandler.java 2009-12-22 07:45:46 UTC (rev 1693)
@@ -254,6 +254,7 @@
n_("jaxxdemo.config.category.other"),
n_("jaxxdemo.config.category.other.description"),
DemoConfig.Option.FULL_SCREEN,
+ DemoConfig.Option.FONT_SIZE,
DemoConfig.Option.LOCALE);
ConfigUI configUI = ConfigUIBuilder.newConfigUI(context, model, "jaxxdemo.config.category.directories");
Modified: trunk/jaxx-demo/src/main/java/jaxx/demo/feature/databinding/BindingExtremeDemo.jaxx
===================================================================
--- trunk/jaxx-demo/src/main/java/jaxx/demo/feature/databinding/BindingExtremeDemo.jaxx 2009-12-21 20:11:57 UTC (rev 1692)
+++ trunk/jaxx-demo/src/main/java/jaxx/demo/feature/databinding/BindingExtremeDemo.jaxx 2009-12-22 07:45:46 UTC (rev 1693)
@@ -227,7 +227,7 @@
</cell>
</row>
- <row>
+ <row weighty="1">
<cell columns="3">
<JPanel layout="{new BorderLayout()}">
<JTextArea id="bindingsLabel" editable='false' text='{$bindings.size() + " bindings."}'/>
Modified: trunk/jaxx-demo/src/main/java/jaxx/demo/feature/validation/ValidationListDemo.jaxx
===================================================================
--- trunk/jaxx-demo/src/main/java/jaxx/demo/feature/validation/ValidationListDemo.jaxx 2009-12-21 20:11:57 UTC (rev 1692)
+++ trunk/jaxx-demo/src/main/java/jaxx/demo/feature/validation/ValidationListDemo.jaxx 2009-12-22 07:45:46 UTC (rev 1693)
@@ -24,12 +24,17 @@
<script><![CDATA[
import static org.nuiton.i18n.I18n.n_;
import jaxx.runtime.validator.swing.SwingValidatorMessageListRenderer;
+import jaxx.runtime.validator.swing.SwingValidatorMessageListModel;
void $afterCompleteSetup() {
}
+
@Override
protected String[] getSources() {
- return new String[]{ getDefaultSource(), "Validation.css", "Model.java", "Identity.java" };
+ return new String[]{ getDefaultSource(), "Validation.css",
+ "Identity.java", "Identity-error-validation.xml", "Identity-info-validation.xml", "Identity-warning-validation.xml",
+ "Model.java", "Model-error-validation.xml", "Model-info-validation.xml", "Model-warning-validation.xml"
+ };
}
]]>
</script>
@@ -41,8 +46,8 @@
<!-- errors model -->
<!-- Not existing :) -->
<!--jaxx.runtime.validator.gwt.GWTValidatorMessageListModel id='errors'-->
- <jaxx.runtime.validator.swing.SwingValidatorMessageListModel id='errors'
- onContentsChanged='ok.setEnabled(errors.isEmpty())'/>
+ <SwingValidatorMessageListModel id='errors'
+ onContentsChanged='ok.setEnabled(errors.isEmpty())'/>
<!-- validators -->
<BeanValidator id='validator' bean='model1' uiClass="jaxx.runtime.validator.swing.ui.ImageValidationUI">
Modified: trunk/jaxx-demo/src/main/java/jaxx/demo/feature/validation/ValidationTableDemo.jaxx
===================================================================
--- trunk/jaxx-demo/src/main/java/jaxx/demo/feature/validation/ValidationTableDemo.jaxx 2009-12-21 20:11:57 UTC (rev 1692)
+++ trunk/jaxx-demo/src/main/java/jaxx/demo/feature/validation/ValidationTableDemo.jaxx 2009-12-22 07:45:46 UTC (rev 1693)
@@ -21,16 +21,33 @@
<jaxx.demo.DemoPanel>
<style source="Validation.css"/>
- <!-- models -->
+ <script><![CDATA[
+import static org.nuiton.i18n.I18n.n_;
+import jaxx.runtime.validator.swing.SwingValidatorUtil;
+import jaxx.runtime.validator.swing.SwingValidatorMessageTableRenderer;
+import jaxx.runtime.validator.swing.SwingValidatorMessageTableModel;
+
+void $afterCompleteSetup() {
+ SwingValidatorUtil.installUI(errorTable, new SwingValidatorMessageTableRenderer());
+}
+
+@Override
+protected String[] getSources() {
+ return new String[]{ getDefaultSource(), "Validation.css",
+ "Identity.java", "Identity-error-validation.xml", "Identity-info-validation.xml", "Identity-warning-validation.xml",
+ "Model.java", "Model-error-validation.xml", "Model-info-validation.xml", "Model-warning-validation.xml"
+ };
+}
+]]></script>
+
+ <!-- models -->
<Model id='model1'/>
<Model id='model2'/>
<Identity id='identity'/>
<!-- errors model -->
- <!-- Not existing :) -->
- <!--jaxx.runtime.validator.gwt.GWTValidatorMessageTableModel id='errors2'/-->
- <jaxx.runtime.validator.swing.SwingValidatorMessageTableModel id='errors2'
- onTableChanged='ok.setEnabled(errors2.getRowCount()==0)'/>
+ <SwingValidatorMessageTableModel id='errors2'
+ onTableChanged='ok.setEnabled(errors2.getRowCount()==0)'/>
<!-- validators -->
<BeanValidator id='validator' bean='model1' uiClass="jaxx.runtime.validator.swing.ui.ImageValidationUI">
@@ -47,22 +64,7 @@
uiClass="jaxx.runtime.validator.swing.ui.TranslucentValidationUI">
<field name="email" component="email2"/>
</BeanValidator>
-
- <script><![CDATA[
-import static org.nuiton.i18n.I18n.n_;
-import jaxx.runtime.validator.swing.SwingValidatorUtil;
-import jaxx.runtime.validator.swing.SwingValidatorMessageTableRenderer;
-
-void $afterCompleteSetup() {
- SwingValidatorUtil.installUI(errorTable, new SwingValidatorMessageTableRenderer());
-}
-
-@Override
-protected String[] getSources() {
- return new String[]{ getDefaultSource(), "Validation.css", "Model.java", "Identity.java" };
-}
-]]></script>
-
+
<Table fill='both' id='demoPanel'>
<row>
<cell weightx='1' weighty='1' insets='6, 3, 0, 0'>
@@ -77,7 +79,7 @@
<JTextField id='text' text='{model1.getText()}'
onKeyReleased='model1.setText(text.getText())'
_validatorLabel='{n_("form.text")}'
- />
+ />
</cell>
</row>
<row>
@@ -88,7 +90,7 @@
<JTextField id='text2' text='{model1.getText2()}'
onKeyReleased='model1.setText2(text2.getText())'
_validatorLabel='{n_("form.text2")}'
- />
+ />
</cell>
</row>
@@ -97,7 +99,7 @@
<JLabel text='Ratio:'/>
</cell>
<cell>
- <JSlider id='ratio' minimum='0' maximum='100'
+ <JSlider id='ratio' minimum='0' maximum='100'
value='{model1.getRatio()}'
_validatorLabel='{n_("form.ratio")}'
onStateChanged='model1.setRatio(ratio.getValue())'/>
@@ -170,7 +172,7 @@
<JLabel text='Ratio:'/>
</cell>
<cell>
- <JSlider id='_ratio' minimum='0' maximum='100'
+ <JSlider id='_ratio' minimum='0' maximum='100'
value='{model2.getRatio()}'
_validatorLabel='{n_("form2.ratio")}'
onStateChanged='model2.setRatio(_ratio.getValue())'/>
Modified: trunk/jaxx-demo/src/main/resources/i18n/jaxx-demo-en_GB.properties
===================================================================
--- trunk/jaxx-demo/src/main/resources/i18n/jaxx-demo-en_GB.properties 2009-12-21 20:11:57 UTC (rev 1692)
+++ trunk/jaxx-demo/src/main/resources/i18n/jaxx-demo-en_GB.properties 2009-12-22 07:45:46 UTC (rev 1693)
@@ -166,6 +166,7 @@
jaxxdemo.config.category.other.description=Others preferences
jaxxdemo.config.configFileName.description=Configuration file name
jaxxdemo.config.ui.demo.path=
+jaxxdemo.config.ui.fontSize=
jaxxdemo.config.ui.fullscreen=To change the screen mode (true for full screen)
jaxxdemo.config.ui.locale=Locale of the application
jaxxdemo.i18neditor.configuration=Configuration
Modified: trunk/jaxx-demo/src/main/resources/i18n/jaxx-demo-fr_FR.properties
===================================================================
--- trunk/jaxx-demo/src/main/resources/i18n/jaxx-demo-fr_FR.properties 2009-12-21 20:11:57 UTC (rev 1692)
+++ trunk/jaxx-demo/src/main/resources/i18n/jaxx-demo-fr_FR.properties 2009-12-22 07:45:46 UTC (rev 1693)
@@ -166,6 +166,7 @@
jaxxdemo.config.category.other.description=Autres options
jaxxdemo.config.configFileName.description=Le nom du fichier de configuration
jaxxdemo.config.ui.demo.path=
+jaxxdemo.config.ui.fontSize=
jaxxdemo.config.ui.fullscreen=Pour afficher l'aplication en mode pleine \u00E9cran
jaxxdemo.config.ui.locale=Langue utilis\u00E9e par l'application (fr_FR, en_GB ou es_ES)
jaxxdemo.i18neditor.configuration=Configuration
Modified: trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/FontSizor.jaxx
===================================================================
--- trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/FontSizor.jaxx 2009-12-21 20:11:57 UTC (rev 1692)
+++ trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/FontSizor.jaxx 2009-12-22 07:45:46 UTC (rev 1693)
@@ -34,6 +34,10 @@
<Boolean id='showFontSize' javaBean='false'/>
<script><![CDATA[
+
+public static final String BINDING_FONT_SIZE_CALL_BACK = "fontSize.callBack";
+public static final String BINDING_DEFAULT_FONT_SIZE_CALL_BACK = "defaultFontSize.callBack";
+
public void init() {
setFontSize(defaultFontSize);
}
@@ -44,6 +48,29 @@
}
return !fontSize.equals(defaultFontSize) && enabled;
}
+
+public void setCallBack(final Runnable action) {
+ removeDataBinding(BINDING_FONT_SIZE_CALL_BACK);
+ registerDataBinding(new SimpleJAXXObjectBinding(this, BINDING_FONT_SIZE_CALL_BACK, true ,"fontSize") {
+
+ @Override
+ public void processDataBinding() {
+ action.run();
+ }
+ });
+ applyDataBinding(BINDING_FONT_SIZE_CALL_BACK);
+}
+
+void $afterCompleteSetup() {
+ registerDataBinding(new SimpleJAXXObjectBinding(this, BINDING_DEFAULT_FONT_SIZE_CALL_BACK, true ,"defaultFontSize") {
+
+ @Override
+ public void processDataBinding() {
+ setFontSize(defaultFontSize);
+ }
+ });
+ applyDataBinding(BINDING_DEFAULT_FONT_SIZE_CALL_BACK);
+}
]]>
</script>
<JToolBar floatable='false'
@@ -76,7 +103,7 @@
onActionPerformed='setFontSize(fontSize + 1)'/>
<JLabel visible='{isShowFontSize()}'
- text='{"" + getFontSize()}'/>
+ text='{SwingUtil.getStringValue(getFontSize())}'/>
</JToolBar>
</JPanel>
1
0
r1692 - in trunk/jaxx-demo/src/main: java/jaxx/demo java/jaxx/demo/component/jaxx/editor java/jaxx/demo/feature/databinding java/jaxx/demo/fun resources/i18n
by tchemit@users.nuiton.org 21 Dec '09
by tchemit@users.nuiton.org 21 Dec '09
21 Dec '09
Author: tchemit
Date: 2009-12-21 21:11:57 +0100 (Mon, 21 Dec 2009)
New Revision: 1692
Added:
trunk/jaxx-demo/src/main/java/jaxx/demo/DemoSources.jaxx
trunk/jaxx-demo/src/main/java/jaxx/demo/DemoSourcesHandler.java
trunk/jaxx-demo/src/main/java/jaxx/demo/feature/databinding/BindingExtremeDemo.jaxx
trunk/jaxx-demo/src/main/java/jaxx/demo/feature/databinding/DefaultDemoUIModel.java
trunk/jaxx-demo/src/main/java/jaxx/demo/feature/databinding/DemoUIModel.java
Modified:
trunk/jaxx-demo/src/main/java/jaxx/demo/DemoPanel.jaxx
trunk/jaxx-demo/src/main/java/jaxx/demo/DemoTreeHelper.java
trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/editor/NumberEditorDemo.jaxx
trunk/jaxx-demo/src/main/java/jaxx/demo/fun/Calculator.css
trunk/jaxx-demo/src/main/resources/i18n/jaxx-demo-en_GB.properties
trunk/jaxx-demo/src/main/resources/i18n/jaxx-demo-fr_FR.properties
Log:
add FontSizor widget + ExtremeDatabinding demo + use FontSizor on sources
Modified: trunk/jaxx-demo/src/main/java/jaxx/demo/DemoPanel.jaxx
===================================================================
--- trunk/jaxx-demo/src/main/java/jaxx/demo/DemoPanel.jaxx 2009-12-21 20:11:01 UTC (rev 1691)
+++ trunk/jaxx-demo/src/main/java/jaxx/demo/DemoPanel.jaxx 2009-12-21 20:11:57 UTC (rev 1692)
@@ -22,8 +22,6 @@
<JTabbedPane id='top'>
<script><![CDATA[
-import org.apache.commons.io.IOUtils;
-import org.fife.ui.rsyntaxtextarea.RSyntaxTextArea;
protected String[] getSources() {
if (getClass() == DemoPanel.class) {
@@ -48,20 +46,6 @@
return getLabel() + " Demo";
}
-public String loadSource(String filename) {
- try {
- if (log.isDebugEnabled()) {
- log.debug(filename + " from " + getClass());
- }
- String result = IOUtils.toString(getClass().getResourceAsStream(filename));
-
- return result;
- } catch (Exception e) {
- log.error("could not load file " + filename, e);
- return "could not load file " + filename;
- }
-}
-
private void $afterCompleteSetup() {
SwingUtilities.invokeLater(new Runnable() {
@@ -71,48 +55,20 @@
top.remove(sourceTabs);
return;
}
- for (String extra : getSources()) {
- JScrollPane pane = new JScrollPane(
- JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
- JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
- pane.setBorder(null);
- //pane.setMinimumSize(jaxx.runtime.SwingUtil.newMinDimension());
- // creation du contenu du fichier
- RSyntaxTextArea content = new RSyntaxTextArea();
- if (extra.matches(".*\\.jaxx") || extra.matches(".*\\.xml")){
- content.setSyntaxEditingStyle(RSyntaxTextArea.SYNTAX_STYLE_XML);
- } else if (extra.matches(".*\\.java")){
- content.setSyntaxEditingStyle(RSyntaxTextArea.SYNTAX_STYLE_JAVA);
- } else if (extra.matches(".*\\.css")){
- content.setSyntaxEditingStyle(RSyntaxTextArea.SYNTAX_STYLE_CSS);
- }
- content.setFont(content.getFont().deriveFont((float) 11));
- content.setMinimumSize(jaxx.runtime.SwingUtil.newMinDimension());
- content.setEditable(false);
- content.setWrapStyleWord(false);
- content.setText(loadSource(extra));
- content.setColumns(80);
- content.setLineWrap(true);
- pane.getViewport().add(content);
- content.setCaretPosition(0);
- // ajout de l'onglet
- sourceTabs.addTab(extra, pane);
- int index = sourceTabs.indexOfComponent(pane);
- JLabel l = new JLabel(extra);
- l.setFont(l.getFont().deriveFont((float) 10));
- sourceTabs.setTabComponentAt(index,l);
- }
+ sourceTabs.init();
}
});
}
]]>
</script>
- <tab title='{getDemoTabTitle()}'>
+ <tab id='tabDemoPanel' title='{getDemoTabTitle()}'>
<JPanel id='demoPanel'/>
</tab>
- <tab title='Sources'>
- <JTabbedPane id='sourceTabs' tabPlacement='{JTabbedPane.BOTTOM}'/>
+ <tab id='tabDemoSources' tabComponent='{sourceTabs.getSourcesHeader()}'>
+ <DemoSources id='sourceTabs'
+ sources='{java.util.Arrays.asList(getSources())}'
+ incomingClass='{getClass()}'/>
</tab>
-</JTabbedPane>
+</JTabbedPane>
\ No newline at end of file
Copied: trunk/jaxx-demo/src/main/java/jaxx/demo/DemoSources.jaxx (from rev 1686, trunk/jaxx-demo/src/main/java/jaxx/demo/DemoPanel.jaxx)
===================================================================
--- trunk/jaxx-demo/src/main/java/jaxx/demo/DemoSources.jaxx (rev 0)
+++ trunk/jaxx-demo/src/main/java/jaxx/demo/DemoSources.jaxx 2009-12-21 20:11:57 UTC (rev 1692)
@@ -0,0 +1,64 @@
+<!--
+ *##%
+ JAXX Demo
+ Copyright (C) 2008 - 2009 CodeLutin
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation, either version 3 of the
+ License, or (at your option) any later version.
+
+ This program 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 Lesser Public License for more details.
+
+ You should have received a copy of the GNU General Lesser Public
+ License along with this program. If not, see
+ <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ ##%*
+-->
+<JPanel layout='{new BorderLayout()}'>
+
+ <script><![CDATA[
+import org.fife.ui.rsyntaxtextarea.RSyntaxTextArea;
+import jaxx.runtime.swing.FontSizor;
+
+public void init() {
+ fontSizor.init();
+ handler.init(this);
+}
+ ]]>
+ </script>
+
+ <JPanel id="sourcesHeader" opaque='false'>
+ <JLabel text='Sources' opaque='false'/>
+ <FontSizor id='fontSizor' opaque='false' showFontSize='true' defaultFontSize='10f' fontSize='10f'/>
+ </JPanel>
+
+ <DemoSourcesHandler id='handler'/>
+
+ <Class id='incomingClass' javaBean='null'/>
+
+ <String id='currentSource' javaBean='null'/>
+
+ <java.util.List id='sources' genericType='String' javaBean='null'/>
+
+ <JTabbedPane id='sourceTabs'
+ constraints='BorderLayout.CENTER'
+ tabPlacement='{JTabbedPane.BOTTOM}'
+ onStateChanged='handler.updateSource(this)'/>
+
+ <RSyntaxTextArea id='editor'
+ constraints='BorderLayout.SOUTH'
+ font-size='{fontSizor.getFontSize()}'
+ text='{handler.getSourceContent(DemoSources.this, getCurrentSource())}'
+ syntaxEditingStyle='{handler.getSourceEditingStyle(DemoSources.this, getCurrentSource())}'
+ minimumSize="{jaxx.runtime.SwingUtil.newMinDimension()}"
+ textAntiAliasHint='{RenderingHints.KEY_ANTIALIASING.toString()}'
+ editable="false"
+ wrapStyleWord="false"
+ columns="80"
+ lineWrap="true"/>
+
+</JPanel>
\ No newline at end of file
Added: trunk/jaxx-demo/src/main/java/jaxx/demo/DemoSourcesHandler.java
===================================================================
--- trunk/jaxx-demo/src/main/java/jaxx/demo/DemoSourcesHandler.java (rev 0)
+++ trunk/jaxx-demo/src/main/java/jaxx/demo/DemoSourcesHandler.java 2009-12-21 20:11:57 UTC (rev 1692)
@@ -0,0 +1,124 @@
+package jaxx.demo;
+
+import org.apache.commons.io.IOUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.fife.ui.rsyntaxtextarea.RSyntaxTextArea;
+
+import javax.swing.*;
+import java.awt.*;
+import java.util.List;
+import java.util.Map;
+import java.util.TreeMap;
+
+/**
+ * Created: 21 déc. 2009
+ *
+ * @author Tony Chemit <chemit(a)codelutin.com> Copyright Code Lutin
+ * @version $Revision$
+ * <p/>
+ * Mise a jour: $Date$ par :
+ * $Author: tchemit $
+ */
+public class DemoSourcesHandler {
+
+ /**
+ * Logger
+ */
+ private static final Log log = LogFactory.getLog(DemoSourcesHandler.class);
+
+ protected Map<String, String> sourcesCache;
+
+ public Map<String, String> getSourcesCache() {
+ if (sourcesCache == null) {
+ sourcesCache = new TreeMap<String, String>();
+ }
+ return sourcesCache;
+ }
+
+ public String getSourceContent(DemoSources ui, String name) {
+ if (name == null) {
+ return "";
+ }
+ String result = getSourcesCache().get(name);
+ if (result == null) {
+ try {
+ if (log.isDebugEnabled()) {
+ log.debug(name + " from " + getClass());
+ }
+ result = IOUtils.toString(ui.getIncomingClass().getResourceAsStream(name));
+ if (log.isDebugEnabled()) {
+ log.debug("source [" + name + "], loaded content =\n" + result);
+ }
+ } catch (Exception e) {
+ log.error("could not load file " + name, e);
+ result = "could not load file " + name;
+ }
+ getSourcesCache().put(name, result);
+ }
+ return result;
+ }
+
+ public String getSourceEditingStyle(DemoSources ui, String source) {
+
+ if (source == null) {
+ return "";
+ }
+ String s = null;
+ if (source.matches(".*\\.jaxx") || source.matches(".*\\.xml")) {
+ s = RSyntaxTextArea.SYNTAX_STYLE_XML;
+ } else if (source.matches(".*\\.java")) {
+ s = RSyntaxTextArea.SYNTAX_STYLE_JAVA;
+ } else if (source.matches(".*\\.css")) {
+ s = RSyntaxTextArea.SYNTAX_STYLE_CSS;
+ }
+ if (log.isInfoEnabled()) {
+ log.info("source [" + source + "] style = " + s);
+ }
+ return s;
+ }
+
+ public void init(DemoSources ui) {
+ List<String> sources = ui.getSources();
+ if (sources == null) {
+ return;
+ }
+ for (String source : sources) {
+
+ if (log.isInfoEnabled()) {
+ log.info("adding tab for resource " + source);
+ }
+ JScrollPane pane = new JScrollPane(
+ JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
+ JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
+ pane.setBorder(null);
+ // ajout de l'onglet
+ ui.sourceTabs.addTab(source, pane);
+ int index = ui.sourceTabs.indexOfComponent(pane);
+ JLabel l = new JLabel(source);
+ l.setFont(l.getFont().deriveFont((float) 10));
+ ui.sourceTabs.setTabComponentAt(index, l);
+ }
+ }
+
+ public void updateSource(DemoSources ui) {
+ JTabbedPane sourceTabs = ui.getSourceTabs();
+ int index = sourceTabs.getSelectedIndex();
+ String sourceName = sourceTabs.getTitleAt(index);
+
+ if (log.isInfoEnabled()) {
+ log.info("new current Source : " + sourceName);
+ }
+ // attach editor to correct selected tab and reset it
+ JScrollPane pane = (JScrollPane) sourceTabs.getComponentAt(index);
+ pane.getViewport().add(ui.getEditor());
+ ui.getEditor().setText("");
+ ui.getEditor().setCaretPosition(0);
+ ui.getEditor().setTextAntiAliasHint(RenderingHints.KEY_ANTIALIASING.toString());
+
+ // change the current source to release the editor
+ ui.setCurrentSource(sourceName);
+
+ }
+
+}
Property changes on: trunk/jaxx-demo/src/main/java/jaxx/demo/DemoSourcesHandler.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL
Modified: trunk/jaxx-demo/src/main/java/jaxx/demo/DemoTreeHelper.java
===================================================================
--- trunk/jaxx-demo/src/main/java/jaxx/demo/DemoTreeHelper.java 2009-12-21 20:11:01 UTC (rev 1691)
+++ trunk/jaxx-demo/src/main/java/jaxx/demo/DemoTreeHelper.java 2009-12-21 20:11:57 UTC (rev 1692)
@@ -29,6 +29,7 @@
import jaxx.demo.component.jaxx.navigation.item.ItemTreeNavigationDemo;
import jaxx.demo.component.swing.*;
import jaxx.demo.feature.databinding.BeanDataBindingDemo;
+import jaxx.demo.feature.databinding.BindingExtremeDemo;
import jaxx.demo.feature.validation.ValidationListDemo;
import jaxx.demo.feature.validation.ValidationTableDemo;
import jaxx.demo.fun.CalculatorDemo;
@@ -116,6 +117,7 @@
goUp().
addText(n_("jaxxdemo.tree.feature")).
addText(n_("jaxxdemo.tree.features.databinding")).
+ addDemo(BindingExtremeDemo.class).
addDemo(BeanDataBindingDemo.class).
goUp().
addText(n_("jaxxdemo.tree.features.validation")).
Modified: trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/editor/NumberEditorDemo.jaxx
===================================================================
--- trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/editor/NumberEditorDemo.jaxx 2009-12-21 20:11:01 UTC (rev 1691)
+++ trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/editor/NumberEditorDemo.jaxx 2009-12-21 20:11:57 UTC (rev 1692)
@@ -86,97 +86,4 @@
</row>
</Table>
</jaxx.demo.DemoPanel>
- <!--row>
- <cell>
- <NumberEditor id='positifIntegerEditor'
- property='positifInteger'
- constructorParams='this'
- bean='{demoModel}'
- autoPopup='false'
- showPopupButton='true'
- showReset='true'/>
- </cell>
- <cell>
- <NumberEditor id='positifIntegerEditor2'
- property='positifInteger'
- constructorParams='this'
- bean='{demoModel}'
- autoPopup='true'
- showPopupButton='true'
- showReset='true'/>
- </cell>
- </row>
- <row>
- <cell>
- <JLabel text='{_("numbereditor.normal.int", demoModel.getNormalInteger())}'/>
- </cell>
- <cell>
- <NumberEditor id='normalIntegerEditor'
- property='normalInteger'
- constructorParams='this'
- bean='{demoModel}'
- autoPopup='false'
- showPopupButton='true'
- showReset='true'
- useSign='true'/>
- </cell>
- <cell>
- <NumberEditor id='normalIntegerEditor2'
- property='normalInteger'
- constructorParams='this'
- bean='{demoModel}'
- autoPopup='true'
- showPopupButton='true'
- showReset='true'
- useSign='true'/>
- </cell>
- </row>
- <row>
- <cell>
- <JLabel text='{_("numbereditor.positive.float", demoModel.getPositifFloat())}'/>
- </cell>
- <cell>
- <NumberEditor id='positifFloatEditor'
- property='positifFloat'
- constructorParams='this'
- bean='{demoModel}'
- autoPopup='false'
- showPopupButton='true'
- showReset='true'/>
- </cell>
- <cell>
- <NumberEditor id='positifFloatEditor2'
- property='positifFloat'
- constructorParams='this'
- bean='{demoModel}'
- autoPopup='true'
- showPopupButton='true'
- showReset='true'/>
- </cell>
- </row>
- <row>
- <cell>
- <JLabel text='{_("numbereditor.normal.float", demoModel.getNormalFloat())}'/>
- </cell>
- <cell>
- <NumberEditor id='normalFloatEditor'
- property='normalFloat'
- constructorParams='this'
- bean='{demoModel}'
- autoPopup='false'
- showPopupButton='true'
- showReset='true'
- useSign='true'/>
- </cell>
- <cell>
- <NumberEditor id='normalFloatEditor2'
- property='normalFloat'
- constructorParams='this'
- bean='{demoModel}'
- autoPopup='true'
- showPopupButton='true'
- showReset='true'
- useSign='true'/>
- </cell>
- </row-->
Added: trunk/jaxx-demo/src/main/java/jaxx/demo/feature/databinding/BindingExtremeDemo.jaxx
===================================================================
--- trunk/jaxx-demo/src/main/java/jaxx/demo/feature/databinding/BindingExtremeDemo.jaxx (rev 0)
+++ trunk/jaxx-demo/src/main/java/jaxx/demo/feature/databinding/BindingExtremeDemo.jaxx 2009-12-21 20:11:57 UTC (rev 1692)
@@ -0,0 +1,243 @@
+<!--
+ *##%
+ JAXX Demo
+ Copyright (C) 2008 - 2009 CodeLutin
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation, either version 3 of the
+ License, or (at your option) any later version.
+
+ This program 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 Lesser Public License for more details.
+
+ You should have received a copy of the GNU General Lesser Public
+ License along with this program. If not, see
+ <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ ##%*
+-->
+
+<jaxx.demo.DemoPanel id='mainFrame' implements='DemoUIModel'>
+
+ <style>
+ JTextArea { editable:false; }
+
+ JCheckBox { enabled:false; }
+
+ .nobinding { background:{Color.GRAY}; }
+ </style>
+
+ <script><![CDATA[
+public JToggleButton getT3() { return t0; }
+
+private void $afterCompleteSetup() {
+ for (Object o : $objectMap.values()) {
+ if (o instanceof JCheckBox) {
+ JCheckBox c = (JCheckBox) o;
+ c.setBackground($bindings.containsKey(c.getName() + ".selected") ? Color.WHITE : Color.RED);
+ }
+ }
+ SwingUtilities.invokeLater(new Runnable() {
+
+ @Override
+ public void run() {
+ DefaultListModel m = (DefaultListModel) bindings.getModel();
+ for (JAXXBinding b : getDataBindings()) {
+ m.addElement(b.getId());
+ }
+ }
+ });
+}
+@Override
+protected String[] getSources() {
+ return new String[]{ getDefaultSource(), "DemoUIModel.java", "DefaultDemoUIModel.java" };
+}
+ ]]>
+ </script>
+
+ <Boolean id='f0' javaBean='Boolean.FALSE'/>
+ <Boolean id='f1' javaBean='Boolean.FALSE'/>
+ <java.io.File id='file' javaBean='new java.io.File(".")'/>
+
+ <DefaultDemoUIModel id='model0' initializer='new DefaultDemoUIModel()'/>
+
+ <DemoUIModel id='model1' javaBean='new DefaultDemoUIModel()'/>
+
+
+ <Table id='demoPanel' fill="both" constraints='BorderLayout.NORTH'>
+ <row>
+ <cell columns="3">
+ <JPanel layout="{new GridLayout(1,0)}">
+ <JCheckBox id='cf0' selected='{isF0()}' text='isF0()'/>
+ <JCheckBox id='cf1' selected='{isF1()}' text='isF1()'/>
+ <JCheckBox id='cf0O1' selected='{isF0() || isF1()}' text='isF0() || isF1()'/>
+ <JCheckBox id='cf0A1' selected='{isF0() && isF1()}' text='isF0() && isF1()'/>
+ </JPanel>
+ </cell>
+ </row>
+ <row>
+ <cell columns="3">
+ <JPanel layout="{new GridLayout(1,0)}">
+ <JCheckBox id='ct0' selected='{t0.isSelected()}' text='t0.isSelected()'/>
+ <JCheckBox id='ct1' selected='{t1.isSelected()}' text='t1.isSelected()'/>
+ <JCheckBox id='ct0O1' selected='{t0.isSelected() || t1.isSelected()}'
+ text='t0.isSelected() || t1.isSelected()'/>
+ <JCheckBox id='ct0A1' selected='{t0.isSelected() && t1.isSelected()}'
+ text='t0.isSelected() && t1.isSelected()'/>
+ </JPanel>
+ </cell>
+ </row>
+ <row>
+ <cell columns="3">
+ <JPanel layout="{new GridLayout(1,0)}">
+ <JCheckBox id='cgett0' selected='{getT0().isSelected()}' text='getT0().isSelected()'/>
+ <JCheckBox id='cgett1' selected='{getT1().isSelected()}' text='getT1().isSelected()'/>
+ <JCheckBox id='cgett0O1' selected='{getT0().isSelected() || getT1().isSelected()}'
+ text='getT0().isSelected() || getT1().isSelected()'/>
+ <JCheckBox id='cgett0A1' selected='{getT0().isSelected() && getT1().isSelected()}'
+ text='getT0().isSelected() && getT1().isSelected()'/>
+ </JPanel>
+ </cell>
+ </row>
+ <row>
+ <cell columns="3">
+ <JPanel layout="{new GridLayout(1,0)}">
+ <JTextArea id='cfile' border='{new TitledBorder("file.getAbsolutePath()")}'
+ text='{file.getAbsolutePath()}' visible='{!$bindings.containsKey("cfile.text")}'
+ styleClass="nobinding"/>
+ <JTextArea id='cgetfile' border='{new TitledBorder("getFile().getAbsolutePath()")}'
+ text='{getFile().getAbsolutePath()}'
+ visible='{$bindings.containsKey("cgetfile.text")}'/>
+ </JPanel>
+ </cell>
+ </row>
+ <row weightx='1'>
+ <cell>
+ <JToggleButton id='t0' text='f0' onActionPerformed='setF0(!f0)'/>
+ </cell>
+ <cell>
+ <JToggleButton id='t1' text='f1' onActionPerformed='setF1(!f1)' javaBean='new JToggleButton()'/>
+ </cell>
+ <cell>
+ <JButton text="file..."
+ onActionPerformed='setFile(org.nuiton.util.FileUtil.getFile(this, new String[0]))'/>
+ </cell>
+ </row>
+
+ <row>
+ <cell columns="3">
+ <JPanel layout="{new GridLayout(1,0)}">
+ <JCheckBox id='cmt0' selected='{model0.isF0()}' text='model0.isF0()'/>
+ <JCheckBox id='cmt1' selected='{model0.isF1()}' text='model0.isF1()'/>
+ <JCheckBox id='cmt0O1' selected='{model0.isF0() || model0.isF1()}'
+ text='model0.isF0() || model0.isF1()'/>
+ <JCheckBox id='cmt0A1' selected='{model0.isF0() && model0.isF1()}'
+ text='model0.isF0() && model0.isF1()'/>
+ </JPanel>
+ </cell>
+ </row>
+ <row>
+ <cell columns="3">
+ <JPanel layout="{new GridLayout(1,0)}">
+ <JCheckBox id='cmgett0' selected='{getModel0().isF0()}' text='getModel0().isF0()'/>
+ <JCheckBox id='cmgett1' selected='{getModel0().isF1()}' text='getModel0().isF1()'/>
+ <JCheckBox id='cmgett0O1' selected='{getModel0().isF0() || getModel0().isF1()}'
+ text='getModel0().isF0() || getModel0().isF1()'/>
+ <JCheckBox id='cmgett0A1' selected='{getModel0().isF0() && getModel0().isF1()}'
+ text='getModel0().isF0() && getModel0().isF1()'/>
+ </JPanel>
+ </cell>
+ </row>
+ <row>
+ <cell columns="3">
+ <JPanel layout="{new GridLayout(1,0)}">
+ <JTextArea id='cMfile' border='{new TitledBorder("model0.getFile().getAbsolutePath()")}'
+ text='{model0.getFile().getAbsolutePath()}'
+ visible='{$bindings.containsKey("cMfile.text")}'/>
+ <JTextArea id='cMgetfile' border='{new TitledBorder("getModel0().getFile().getAbsolutePath()")}'
+ text='{getModel0().getFile().getAbsolutePath()}'
+ visible='{$bindings.containsKey("cMgetfile.text")}'/>
+ </JPanel>
+ </cell>
+ </row>
+ <row>
+ <cell>
+ <JToggleButton id='Mt0' text='model0.f0' onActionPerformed='model0.setF0(!model0.isF0())'/>
+ </cell>
+ <cell>
+ <JToggleButton id='Mt1' text='model0.f1' onActionPerformed='model0.setF1(!model0.isF1())'
+ javaBean='new JToggleButton()'/>
+ </cell>
+ <cell>
+ <JButton text="model0.file..."
+ onActionPerformed='model0.setFile(org.nuiton.util.FileUtil.getFile(this,new String[0]))'/>
+ </cell>
+ </row>
+
+ <row>
+ <cell columns="3">
+ <JPanel layout="{new GridLayout(1,0)}">
+ <JCheckBox id='cit0' selected='{((DemoUIModel)model1).isF0()}' text='model1.isF0()'/>
+ <JCheckBox id='cit1' selected='{((DemoUIModel)model1).isF1()}' text='model1.isF1()'/>
+ <JCheckBox id='cit0O1' selected='{((DemoUIModel)model1).isF0() || ((DemoUIModel)model1).isF1()}'
+ text='model1.isF0() || model1.isF1()'/>
+ <JCheckBox id='cit0A1'
+ selected='{((DemoUIModel)model1).isF0() && ((DemoUIModel)model1).isF1()}'
+ text='model1.isF0() && model1.isF1()'/>
+ </JPanel>
+ </cell>
+ </row>
+ <row>
+ <cell columns="3">
+ <JPanel layout="{new GridLayout(1,0)}">
+ <JCheckBox id='cigett0' selected='{getModel1().isF0()}' text='getModel1().isF0()'/>
+ <JCheckBox id='cigett1' selected='{getModel1().isF1()}' text='getModel1().isF1()'/>
+ <JCheckBox id='cigett0O1' selected='{getModel1().isF0() || getModel1().isF1()}'
+ text='getModel1().isF0() || getModel1().isF1()'/>
+ <JCheckBox id='cigett0A1' selected='{getModel1().isF0() && getModel1().isF1()}'
+ text='getModel1().isF0() && getModel1().isF1()'/>
+ </JPanel>
+ </cell>
+ </row>
+ <row>
+ <cell columns="3">
+ <JPanel layout="{new GridLayout(1,0)}">
+ <JTextArea id='cIfile' border='{new TitledBorder("model1.getFile().getAbsolutePath()")}'
+ text='{model1.getFile().getAbsolutePath()}'
+ visible='{$bindings.containsKey("cIfile.text")}'/>
+ <JTextArea id='cIgetfile' border='{new TitledBorder("getModel1().getFile().getAbsolutePath()")}'
+ text='{getModel1().getFile().getAbsolutePath()}'
+ visible='{$bindings.containsKey("cIgetfile.text")}'/>
+ </JPanel>
+ </cell>
+ </row>
+ <row>
+ <cell>
+ <JToggleButton id='It0' text='model1.f0' onActionPerformed='model1.setF0(!model1.isF0())'/>
+ </cell>
+ <cell>
+ <JToggleButton id='It1' text='model1.f1' onActionPerformed='model1.setF1(!model1.isF1())'
+ javaBean='new JToggleButton()'/>
+ </cell>
+ <cell>
+ <JButton text="model1.file..."
+ onActionPerformed='model1.setFile(org.nuiton.util.FileUtil.getFile(this,new String[0]))'/>
+ </cell>
+ </row>
+
+ <row>
+ <cell columns="3">
+ <JPanel layout="{new BorderLayout()}">
+ <JTextArea id="bindingsLabel" editable='false' text='{$bindings.size() + " bindings."}'/>
+ <JScrollPane constraints='BorderLayout.CENTER' columnHeaderView='{bindingsLabel}'>
+ <JList id="bindings" model='{new DefaultListModel()}' font-size='10'/>
+ </JScrollPane>
+ </JPanel>
+ </cell>
+ </row>
+ </Table>
+
+
+</jaxx.demo.DemoPanel>
Added: trunk/jaxx-demo/src/main/java/jaxx/demo/feature/databinding/DefaultDemoUIModel.java
===================================================================
--- trunk/jaxx-demo/src/main/java/jaxx/demo/feature/databinding/DefaultDemoUIModel.java (rev 0)
+++ trunk/jaxx-demo/src/main/java/jaxx/demo/feature/databinding/DefaultDemoUIModel.java 2009-12-21 20:11:57 UTC (rev 1692)
@@ -0,0 +1,137 @@
+package jaxx.demo.feature.databinding;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import java.beans.PropertyChangeListener;
+import java.beans.PropertyChangeSupport;
+
+/**
+ * Created: 3 déc. 2009
+ *
+ * @author Tony Chemit <chemit(a)codelutin.com> Copyright Code Lutin
+ * @version $Revision$
+ * <p/>
+ * Mise a jour: $Date$ par :
+ * $Author: tchemit $
+ */
+public class DefaultDemoUIModel implements DemoUIModel {
+
+
+ protected java.io.File file;
+ protected java.io.File file1;
+ protected java.lang.Boolean f1 = false;
+ protected java.lang.Boolean f0 = false;
+
+ protected javax.swing.JToggleButton t1;
+ protected javax.swing.JToggleButton t0;
+
+ public static final String PROPERTY_T1 = "t1";
+ public static final String PROPERTY_F1 = "f1";
+ public static final String PROPERTY_F0 = "f0";
+ public static final String PROPERTY_FILE = "file";
+
+ protected final PropertyChangeSupport pcs = new PropertyChangeSupport(this);
+
+ protected static final Log log = LogFactory.getLog(DefaultDemoUIModel.class);
+
+ /*---------------------------------------------------------------------------------*/
+ /*-- public acessor methods -------------------------------------------------------*/
+ /*---------------------------------------------------------------------------------*/
+
+ public java.lang.Boolean getF0() {
+ return f0;
+ }
+
+ public java.lang.Boolean getF1() {
+ return f1;
+ }
+
+ @Override
+ public java.io.File getFile() {
+ return file;
+ }
+
+ public java.io.File getFile1() {
+ return file1;
+ }
+
+ @Override
+ public javax.swing.JToggleButton getT0() {
+ return t0;
+ }
+
+ @Override
+ public javax.swing.JToggleButton getT1() {
+ return t1;
+ }
+
+ @Override
+ public java.lang.Boolean isF0() {
+ return f0 != null && f0;
+ }
+
+ @Override
+ public java.lang.Boolean isF1() {
+ return f1 != null && f1;
+ }
+
+ /*---------------------------------------------------------------------------------*/
+ /*-- public mutator methods -------------------------------------------------------*/
+ /*---------------------------------------------------------------------------------*/
+
+ @Override
+ public void setF0(java.lang.Boolean newValue) {
+ java.lang.Boolean oldValue = this.f0;
+ this.f0 = newValue;
+ firePropertyChange(PROPERTY_F0, oldValue, newValue);
+ }
+
+ @Override
+ public void setF1(java.lang.Boolean newValue) {
+ java.lang.Boolean oldValue = this.f1;
+ this.f1 = newValue;
+ firePropertyChange(PROPERTY_F1, oldValue, newValue);
+ }
+
+ @Override
+ public void setFile(java.io.File newValue) {
+ java.io.File oldValue = this.file;
+ this.file = newValue;
+ firePropertyChange(PROPERTY_FILE, oldValue, newValue);
+ }
+
+
+ public void setT1(javax.swing.JToggleButton newValue) {
+ javax.swing.JToggleButton oldValue = this.t1;
+ this.t1 = newValue;
+ firePropertyChange(PROPERTY_T1, oldValue, newValue);
+ }
+
+ @Override
+ public void firePropertyChange(String name, Object oldValue, Object newValue) {
+ pcs.firePropertyChange(name, oldValue, newValue);
+ }
+
+ @Override
+ public void addPropertyChangeListener(PropertyChangeListener listener) {
+ pcs.addPropertyChangeListener(listener);
+ }
+
+ @Override
+ public void addPropertyChangeListener(String property, PropertyChangeListener listener) {
+ pcs.addPropertyChangeListener(property, listener);
+ }
+
+ @Override
+ public void removePropertyChangeListener(PropertyChangeListener listener) {
+ pcs.removePropertyChangeListener(listener);
+ }
+
+ @Override
+ public void removePropertyChangeListener(String property, PropertyChangeListener listener) {
+ pcs.removePropertyChangeListener(property, listener);
+ }
+
+
+}
Property changes on: trunk/jaxx-demo/src/main/java/jaxx/demo/feature/databinding/DefaultDemoUIModel.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL
Added: trunk/jaxx-demo/src/main/java/jaxx/demo/feature/databinding/DemoUIModel.java
===================================================================
--- trunk/jaxx-demo/src/main/java/jaxx/demo/feature/databinding/DemoUIModel.java (rev 0)
+++ trunk/jaxx-demo/src/main/java/jaxx/demo/feature/databinding/DemoUIModel.java 2009-12-21 20:11:57 UTC (rev 1692)
@@ -0,0 +1,74 @@
+package jaxx.demo.feature.databinding;
+
+import javax.swing.*;
+import java.io.File;
+
+/**
+ * Created: 2 déc. 2009
+ *
+ * @author Tony Chemit <chemit(a)codelutin.com> Copyright Code Lutin
+ * @version $Revision$
+ * <p/>
+ * Mise a jour: $Date$ par :
+ * $Author: tchemit $
+ */
+public interface DemoUIModel {
+
+ Boolean isF0();
+
+ Boolean isF1();
+
+ void setF0(Boolean b);
+
+ void setF1(Boolean b);
+
+ JToggleButton getT0();
+
+ JToggleButton getT1();
+
+ File getFile();
+
+ void setFile(File newValue);
+
+ /**
+ * All <code>JAXXObject</code> implements are capable of broadcasting <code>PropertyChangeEvent</code>, and
+ * furthermore (for technical reasons) must allow code in outside packages, specifically the JAXX runtime,
+ * to trigger these events.
+ *
+ * @param name the name of the property which changed
+ * @param oldValue the old value of the property
+ * @param newValue the new value of the property
+ */
+ void firePropertyChange(String name, Object oldValue, Object newValue);
+
+ /**
+ * Register a general {@link java.beans.PropertyChangeListener}.
+ *
+ * @param listener the listener to register
+ */
+ void addPropertyChangeListener(java.beans.PropertyChangeListener listener);
+
+ /**
+ * Register a {@link java.beans.PropertyChangeListener}. for the given {@code propertyName}.
+ *
+ * @param property the property name to listen
+ * @param listener the listener to register
+ */
+ void addPropertyChangeListener(String property, java.beans.PropertyChangeListener listener);
+
+ /**
+ * Unregister a general {@link java.beans.PropertyChangeListener}.
+ *
+ * @param listener the listener to unregister
+ */
+ void removePropertyChangeListener(java.beans.PropertyChangeListener listener);
+
+ /**
+ * Unregister a {@link java.beans.PropertyChangeListener}. for the given {@code propertyName}.
+ *
+ * @param property the property name to listen
+ * @param listener the listener to unregister
+ */
+ void removePropertyChangeListener(String property, java.beans.PropertyChangeListener listener);
+
+}
Property changes on: trunk/jaxx-demo/src/main/java/jaxx/demo/feature/databinding/DemoUIModel.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL
Modified: trunk/jaxx-demo/src/main/java/jaxx/demo/fun/Calculator.css
===================================================================
--- trunk/jaxx-demo/src/main/java/jaxx/demo/fun/Calculator.css 2009-12-21 20:11:01 UTC (rev 1691)
+++ trunk/jaxx-demo/src/main/java/jaxx/demo/fun/Calculator.css 2009-12-21 20:11:57 UTC (rev 1692)
@@ -39,8 +39,12 @@
foreground: red;
}
-JButton:mouseover {
+/*JButton:mouseover {
font-weight: bold;
+}*/
+
+JButton.operator:mouseover {
+ font-weight: bold;
}
JButton.operator:mouseover {
Modified: trunk/jaxx-demo/src/main/resources/i18n/jaxx-demo-en_GB.properties
===================================================================
--- trunk/jaxx-demo/src/main/resources/i18n/jaxx-demo-en_GB.properties 2009-12-21 20:11:01 UTC (rev 1691)
+++ trunk/jaxx-demo/src/main/resources/i18n/jaxx-demo-en_GB.properties 2009-12-21 20:11:57 UTC (rev 1692)
@@ -112,13 +112,32 @@
edit2=Edit 2
edit3=Edit 3
editor.getSelectedLocale()=
+f0=
+f1=
+file...=
form.ratio=Ratio
form.text=Text
form.text2=Text 2
form2.ratio=Form 2 Ratio
form2.text=Form 2 Text
form2.text2=Form 2 Text 2
+getModel0().isF0()=
+getModel0().isF0()\ &&\ getModel0().isF1()=
+getModel0().isF0()\ ||\ getModel0().isF1()=
+getModel0().isF1()=
+getModel1().isF0()=
+getModel1().isF0()\ &&\ getModel1().isF1()=
+getModel1().isF0()\ ||\ getModel1().isF1()=
+getModel1().isF1()=
+getT0().isSelected()=
+getT0().isSelected()\ &&\ getT1().isSelected()=
+getT0().isSelected()\ ||\ getT1().isSelected()=
+getT1().isSelected()=
i18neditor.popup.title=
+isF0()=
+isF0()\ &&\ isF1()=
+isF0()\ ||\ isF1()=
+isF1()=
jaxxdemo.about.message=<h3>JAXX Demo</h3><hr/>For more informations, viste the <a href\="http\://maven-site.nuiton.org/jaxx/jaxx-demo">website of the project</a>.
jaxxdemo.action.about=About...
jaxxdemo.action.about.tip=About JAXXDemo...
@@ -194,6 +213,20 @@
jaxxdemo.tree.fun=Fun
jaxxdemo.warning.nimbus.landf=Could not init nymbus look and feel, you need at leasr version 1.6u10 of java.
jaxxdemo.warning.no.ui=No ui environnement detected
+model0.f0=
+model0.f1=
+model0.file...=
+model0.isF0()=
+model0.isF0()\ &&\ model0.isF1()=
+model0.isF0()\ ||\ model0.isF1()=
+model0.isF1()=
+model1.f0=
+model1.f1=
+model1.file...=
+model1.isF0()=
+model1.isF0()\ &&\ model1.isF1()=
+model1.isF0()\ ||\ model1.isF1()=
+model1.isF1()=
movies=Movies
numbereditor.normal.float=Signed float
numbereditor.normal.int=Signed integer
@@ -204,6 +237,10 @@
numbereditor.without.auto.popup=Without auto popup
show/hide\ label1=
show/hide\ label2=
+t0.isSelected()=
+t0.isSelected()\ &&\ t1.isSelected()=
+t0.isSelected()\ ||\ t1.isSelected()=
+t1.isSelected()=
test=
valid=
x=
Modified: trunk/jaxx-demo/src/main/resources/i18n/jaxx-demo-fr_FR.properties
===================================================================
--- trunk/jaxx-demo/src/main/resources/i18n/jaxx-demo-fr_FR.properties 2009-12-21 20:11:01 UTC (rev 1691)
+++ trunk/jaxx-demo/src/main/resources/i18n/jaxx-demo-fr_FR.properties 2009-12-21 20:11:57 UTC (rev 1692)
@@ -112,13 +112,32 @@
edit2=Editer 2
edit3=Editer 3
editor.getSelectedLocale()=
+f0=
+f1=
+file...=
form.ratio=Form \: ratio
form.text=Form \: text
form.text2=Form \: text2
form2.ratio=Form2 \: ratio
form2.text=Form2 \: text
form2.text2=Form2 \: text2
+getModel0().isF0()=
+getModel0().isF0()\ &&\ getModel0().isF1()=
+getModel0().isF0()\ ||\ getModel0().isF1()=
+getModel0().isF1()=
+getModel1().isF0()=
+getModel1().isF0()\ &&\ getModel1().isF1()=
+getModel1().isF0()\ ||\ getModel1().isF1()=
+getModel1().isF1()=
+getT0().isSelected()=
+getT0().isSelected()\ &&\ getT1().isSelected()=
+getT0().isSelected()\ ||\ getT1().isSelected()=
+getT1().isSelected()=
i18neditor.popup.title=
+isF0()=
+isF0()\ &&\ isF1()=
+isF0()\ ||\ isF1()=
+isF1()=
jaxxdemo.about.message=<h3>JAXX Demo</h3><hr/>Pour plus d'informations, vous pouvez visiter le <a href\="http\://maven-site.nuiton.org/jaxx/jaxx-demo">site du projet</a>.
jaxxdemo.action.about=A propos
jaxxdemo.action.about.tip=A propos de JAXX Demo...
@@ -194,6 +213,20 @@
jaxxdemo.tree.fun=Fun
jaxxdemo.warning.nimbus.landf=Le look and Feel Nimbus n'a pas \u00E9t\u00E9 trouv\u00E9, il faut au moins la version 1.6u10 de java.
jaxxdemo.warning.no.ui=Aucun environnement graphique d\u00E9tect\u00E9
+model0.f0=
+model0.f1=
+model0.file...=
+model0.isF0()=
+model0.isF0()\ &&\ model0.isF1()=
+model0.isF0()\ ||\ model0.isF1()=
+model0.isF1()=
+model1.f0=
+model1.f1=
+model1.file...=
+model1.isF0()=
+model1.isF0()\ &&\ model1.isF1()=
+model1.isF0()\ ||\ model1.isF1()=
+model1.isF1()=
movies=Films
numbereditor.normal.float=D\u00E9cimal primitif \: [%1$s]
numbereditor.normal.int=Entier primitif \: [%1$s]
@@ -204,6 +237,10 @@
numbereditor.without.auto.popup=Sans popup auto
show/hide\ label1=
show/hide\ label2=
+t0.isSelected()=
+t0.isSelected()\ &&\ t1.isSelected()=
+t0.isSelected()\ ||\ t1.isSelected()=
+t1.isSelected()=
test=
valid=valide
x=x
1
0
r1691 - in trunk/jaxx-widgets/src/main: java/jaxx/runtime/swing resources/i18n resources/icons
by tchemit@users.nuiton.org 21 Dec '09
by tchemit@users.nuiton.org 21 Dec '09
21 Dec '09
Author: tchemit
Date: 2009-12-21 21:11:01 +0100 (Mon, 21 Dec 2009)
New Revision: 1691
Added:
trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/FontSizor.jaxx
trunk/jaxx-widgets/src/main/resources/icons/action-font-size-down.png
trunk/jaxx-widgets/src/main/resources/icons/action-font-size-up.png
trunk/jaxx-widgets/src/main/resources/icons/action-font-size.png
Modified:
trunk/jaxx-widgets/src/main/resources/i18n/jaxx-widgets-en_GB.properties
trunk/jaxx-widgets/src/main/resources/i18n/jaxx-widgets-fr_FR.properties
Log:
add FontSizor widget + ExtremeDatabinding demo + use FontSizor on sources
Added: trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/FontSizor.jaxx
===================================================================
--- trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/FontSizor.jaxx (rev 0)
+++ trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/FontSizor.jaxx 2009-12-21 20:11:01 UTC (rev 1691)
@@ -0,0 +1,82 @@
+<!--
+
+/**
+ * *##% jaxx-runtime-swing-widget
+ * Copyright (C) 2008 - 2009 CodeLutin
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program 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 Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*
+ */
+
+-->
+
+<JPanel layout='{new BorderLayout()}'>
+
+ <!-- default size of font -->
+ <Float id='defaultFontSize' javaBean='12f'/>
+
+ <!-- size of font -->
+ <Float id='fontSize' javaBean='null'/>
+
+ <Boolean id='showDefaultFontSize' javaBean='true'/>
+
+ <Boolean id='showFontSize' javaBean='false'/>
+
+ <script><![CDATA[
+public void init() {
+ setFontSize(defaultFontSize);
+}
+
+boolean updateDefaultSizeEnabled(Float fontSize, Float defaultFontSize, boolean enabled) {
+ if (fontSize==null || defaultFontSize==null) {
+ return false;
+ }
+ return !fontSize.equals(defaultFontSize) && enabled;
+}
+ ]]>
+ </script>
+ <JToolBar floatable='false'
+ borderPainted='false'
+ opaque='{isOpaque()}'
+ constraints='BorderLayout.CENTER'>
+
+ <JButton id='downSize'
+ actionIcon='font-size-down'
+ toolTipText='fontsize.action.down.tip'
+ focusable='false'
+ focusPainted='false'
+ enabled='{isEnabled()}'
+ onActionPerformed='setFontSize(fontSize - 1)'/>
+
+ <JButton id='defaultSize'
+ actionIcon='font-size'
+ toolTipText='fontsize.action.default.tip'
+ focusable='false'
+ focusPainted='false'
+ visible='{isShowDefaultFontSize()}'
+ enabled='{updateDefaultSizeEnabled(getFontSize(), getDefaultFontSize(), isEnabled())}'
+ onActionPerformed='setFontSize(defaultFontSize)'/>
+ <JButton id='upSize'
+ actionIcon='font-size-up'
+ toolTipText='fontsize.action.up.tip'
+ focusable='false'
+ focusPainted='false'
+ enabled='{isEnabled()}'
+ onActionPerformed='setFontSize(fontSize + 1)'/>
+
+ <JLabel visible='{isShowFontSize()}'
+ text='{"" + getFontSize()}'/>
+ </JToolBar>
+
+</JPanel>
Modified: trunk/jaxx-widgets/src/main/resources/i18n/jaxx-widgets-en_GB.properties
===================================================================
--- trunk/jaxx-widgets/src/main/resources/i18n/jaxx-widgets-en_GB.properties 2009-12-21 20:09:52 UTC (rev 1690)
+++ trunk/jaxx-widgets/src/main/resources/i18n/jaxx-widgets-en_GB.properties 2009-12-21 20:11:01 UTC (rev 1691)
@@ -46,6 +46,9 @@
errorUI.action.close=Close
errorUI.message=An error wad detected...
errorUI.title=Error...
+fontsize.action.default.tip=
+fontsize.action.down.tip=
+fontsize.action.up.tip=
hidor.hideTip=Hide
hidor.showTip=Show
i18neditor.empty.locales=< No locale to select >
@@ -71,4 +74,5 @@
numbereditor.clearAll=C
numbereditor.clearOne=CE
numbereditor.toggleSign=+/-
+size\ \:\ =
timeeditor.H=H
Modified: trunk/jaxx-widgets/src/main/resources/i18n/jaxx-widgets-fr_FR.properties
===================================================================
--- trunk/jaxx-widgets/src/main/resources/i18n/jaxx-widgets-fr_FR.properties 2009-12-21 20:09:52 UTC (rev 1690)
+++ trunk/jaxx-widgets/src/main/resources/i18n/jaxx-widgets-fr_FR.properties 2009-12-21 20:11:01 UTC (rev 1691)
@@ -46,6 +46,9 @@
errorUI.action.close=Fermer
errorUI.message=Une erreur est survenue \!
errorUI.title=Erreur...
+fontsize.action.default.tip=
+fontsize.action.down.tip=
+fontsize.action.up.tip=
hidor.hideTip=Cacher
hidor.showTip=Voir
i18neditor.empty.locales=< Aucune locale \u00E0 s\u00E9lectionner >
@@ -71,4 +74,5 @@
numbereditor.clearAll=C
numbereditor.clearOne=CE
numbereditor.toggleSign=+/-
+size\ \:\ =
timeeditor.H=H
Added: trunk/jaxx-widgets/src/main/resources/icons/action-font-size-down.png
===================================================================
(Binary files differ)
Property changes on: trunk/jaxx-widgets/src/main/resources/icons/action-font-size-down.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: trunk/jaxx-widgets/src/main/resources/icons/action-font-size-up.png
===================================================================
(Binary files differ)
Property changes on: trunk/jaxx-widgets/src/main/resources/icons/action-font-size-up.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: trunk/jaxx-widgets/src/main/resources/icons/action-font-size.png
===================================================================
(Binary files differ)
Property changes on: trunk/jaxx-widgets/src/main/resources/icons/action-font-size.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
1
0
Author: tchemit
Date: 2009-12-21 21:09:52 +0100 (Mon, 21 Dec 2009)
New Revision: 1690
Modified:
trunk/pom.xml
Log:
bump rsyntaxtextarea to 1.4.0
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2009-12-21 20:09:23 UTC (rev 1689)
+++ trunk/pom.xml 2009-12-21 20:09:52 UTC (rev 1690)
@@ -234,7 +234,7 @@
<dependency>
<groupId>org.nuiton.thirdparty</groupId>
<artifactId>rsyntaxtextarea</artifactId>
- <version>1.3.3</version>
+ <version>1.4.0</version>
</dependency>
<!-- swinglabs dependencies -->
1
0
r1689 - trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing
by tchemit@users.nuiton.org 21 Dec '09
by tchemit@users.nuiton.org 21 Dec '09
21 Dec '09
Author: tchemit
Date: 2009-12-21 21:09:23 +0100 (Mon, 21 Dec 2009)
New Revision: 1689
Modified:
trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JTabbedPaneHandler.java
trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/TabHandler.java
Log:
add tabComponent support for TabInfo
Modified: trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JTabbedPaneHandler.java
===================================================================
--- trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JTabbedPaneHandler.java 2009-12-21 20:09:08 UTC (rev 1688)
+++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JTabbedPaneHandler.java 2009-12-21 20:09:23 UTC (rev 1689)
@@ -133,6 +133,11 @@
appendAdditionCode(getId() + ".setDisabledIconAt(" + tabIndex + ", " + disabledIcon + ");");
}
+ String tabComponent= tabInfo.getTabComponentStr();
+ if (tabComponent != null) {
+ appendAdditionCode(getId() + ".setTabComponentAt(" + tabIndex + ", " + tabComponent + ");");
+ }
+
tabInfo = USED;
}
}
Modified: trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/TabHandler.java
===================================================================
--- trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/TabHandler.java 2009-12-21 20:09:08 UTC (rev 1688)
+++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/TabHandler.java 2009-12-21 20:09:23 UTC (rev 1689)
@@ -128,6 +128,9 @@
Color background = (Color) TypeManager.convertFromString(value, Color.class);
tabInfo.setBackground(background);
compiledTabInfo.appendInitializationCode(id + ".setBackground(" + TypeManager.getJavaCode(background) + ");");
+ } else if (name.equals("tabComponent")) {
+ tabInfo.setTabComponentStr(TypeManager.getJavaCode(value));
+ compiledTabInfo.appendInitializationCode(id + ".setTabComponent(" + TypeManager.getJavaCode(value) + ");");
} else {
compiler.reportError("The <tab> tag does not support the attribute '" + name + "'");
}
1
0
21 Dec '09
Author: tchemit
Date: 2009-12-21 21:09:08 +0100 (Mon, 21 Dec 2009)
New Revision: 1688
Modified:
trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/TabInfo.java
trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/TabInfoPropertyChangeListener.java
Log:
add tabComponent support for TabInfo
Modified: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/TabInfo.java
===================================================================
--- trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/TabInfo.java 2009-12-21 13:02:20 UTC (rev 1687)
+++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/TabInfo.java 2009-12-21 20:09:08 UTC (rev 1688)
@@ -20,7 +20,7 @@
*/
package jaxx.runtime.swing;
-import javax.swing.Icon;
+import javax.swing.*;
import javax.swing.event.SwingPropertyChangeSupport;
import java.awt.Color;
import java.beans.PropertyChangeListener;
@@ -29,6 +29,8 @@
public class TabInfo {
public static String BACKGROUND_PROPERTY = "background";
+ public static String TAB_COMPONENT_PROPERTY = "tabComponent";
+ public static String TAB_COMPONENT_STR_PROPERTY = "tabComponentStr";
public static String DISABLED_ICON_PROPERTY = "disabledIcon";
public static String DISPLAYED_MNEMONIC_INDEX_PROPERTY = "displayedMnemonicIndex";
public static String ENABLED_PROPERTY = "enabled";
@@ -47,6 +49,8 @@
private int mnemonic = -1;
private String title;
private String toolTipText;
+ private JComponent tabComponent;
+ private String tabComponentStr;
private PropertyChangeSupport propertyChangeSupport;
public TabInfo() {
@@ -150,6 +154,27 @@
firePropertyChange(TOOL_TIP_TEXT_PROPERTY, oldValue, toolTipText);
}
+ public JComponent getTabComponent() {
+ return tabComponent;
+ }
+
+ public void setTabComponent(JComponent tabComponent) {
+ JComponent oldValue = this.tabComponent;
+ this.tabComponent = tabComponent;
+ firePropertyChange(TAB_COMPONENT_PROPERTY, oldValue, tabComponent);
+ }
+
+
+ public String getTabComponentStr() {
+ return tabComponentStr;
+ }
+
+ public void setTabComponentStr(String tabComponentStr) {
+ String oldValue = this.tabComponentStr;
+ this.tabComponentStr = tabComponentStr;
+ firePropertyChange(TAB_COMPONENT_STR_PROPERTY, oldValue, tabComponent);
+ }
+
private PropertyChangeSupport getPropertyChangeSupport() {
if (propertyChangeSupport == null) {
propertyChangeSupport = new SwingPropertyChangeSupport(this);
Modified: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/TabInfoPropertyChangeListener.java
===================================================================
--- trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/TabInfoPropertyChangeListener.java 2009-12-21 13:02:20 UTC (rev 1687)
+++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/TabInfoPropertyChangeListener.java 2009-12-21 20:09:08 UTC (rev 1688)
@@ -22,7 +22,7 @@
import javax.swing.Icon;
import javax.swing.JTabbedPane;
-import java.awt.Color;
+import java.awt.*;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
@@ -55,6 +55,8 @@
tabs.setIconAt(tabIndex, (Icon) e.getNewValue());
} else if (name.equals(TabInfo.DISABLED_ICON_PROPERTY)) {
tabs.setDisabledIconAt(tabIndex, (Icon) e.getNewValue());
+ }else if (name.equals(TabInfo.TAB_COMPONENT_PROPERTY)) {
+ tabs.setTabComponentAt(tabIndex, (Component) e.getNewValue());
}
}
}
1
0
r1687 - in trunk/maven-jaxx-plugin/src: main/java/org/nuiton/jaxx/plugin site site/rst
by tchemit@users.nuiton.org 21 Dec '09
by tchemit@users.nuiton.org 21 Dec '09
21 Dec '09
Author: tchemit
Date: 2009-12-21 14:02:20 +0100 (Mon, 21 Dec 2009)
New Revision: 1687
Added:
trunk/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/AbstractGenerateHelpMojo.java
trunk/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/GenerateHelpSearchMojo.java
Modified:
trunk/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/AbstractJaxxMojo.java
trunk/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/GenerateHelpMojo.java
trunk/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/GenerateMojo.java
trunk/maven-jaxx-plugin/src/site/rst/index.rst
trunk/maven-jaxx-plugin/src/site/site.xml
Log:
Evolution #172: G?\195?\169n?\195?\169rer les index de l'aide dans un goal sp?\195?\169cific
Copied: trunk/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/AbstractGenerateHelpMojo.java (from rev 1686, trunk/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/GenerateHelpMojo.java)
===================================================================
--- trunk/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/AbstractGenerateHelpMojo.java (rev 0)
+++ trunk/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/AbstractGenerateHelpMojo.java 2009-12-21 13:02:20 UTC (rev 1687)
@@ -0,0 +1,211 @@
+/* *##%
+ * JAXX Maven plugin
+ * Copyright (C) 2008 - 2009 CodeLutin
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program 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 Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * ##%*/
+package org.nuiton.jaxx.plugin;
+
+import org.apache.maven.plugin.MojoFailureException;
+import org.nuiton.i18n.I18n;
+import org.nuiton.plugin.VelocityTemplateGenerator;
+import org.nuiton.util.SortedProperties;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.InputStreamReader;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Locale;
+import java.util.Properties;
+
+/**
+ * Abstract Mojo to generate help stuff.
+ *
+ * @author chemit
+ * @since 2.0.0
+ */
+public abstract class AbstractGenerateHelpMojo extends AbstractJaxxMojo {
+
+ protected static final String AUTOREMOVE_LINE = "REMOVE THS LINE TO DISABLE AUTO-REGENERATE THE FILE";
+ /**
+ * The directory where to create or update help files.
+ *
+ * @parameter expression="${jaxx.outHelp}" default-value="${project.basedir}/src/main/help"
+ * @required
+ * @since 1.3
+ */
+ protected File outHelp;
+ /**
+ * The locales to generate for help, separeted by comma.
+ * <p/>
+ * The first locale given is the default locale.
+ *
+ * @parameter expression="${jaxx.locales}"
+ * @required
+ * @since 2.0.0
+ */
+ protected String locales;
+ /**
+ * The name of the helpset to generate.
+ *
+ * @parameter expression="${jaxx.helpsetName}" default-value="${project.artifactId}"
+ * @required
+ * @since 1.3
+ */
+ protected String helpsetName;
+ /**
+ * Flag to generate the search index.
+ *
+ * @parameter expression="${jaxx.generateSearch}" default-value="true"
+ * @required
+ * @since 1.3
+ */
+ protected boolean generateSearch;
+ /**
+ * The help ids discovered in {@link #helpIdsStore} files.
+ */
+ protected static Properties helpIds;
+ /**
+ * Default locale (the first locale in {@link #localesToTreate}.
+ */
+ protected Locale defaultLocale;
+ /**
+ * Locales to treate
+ */
+ protected Locale[] localesToTreate;
+
+ /**
+ * Do the action for the given locale.
+ *
+ * @param locale the locale to treate
+ * @param isDefaultLocale {@code true} if given locale is de the default locale
+ * @param localizedTarget where are stored help files for the given locale
+ * @param localePath the locale path to use (is {@code default} if given locale is default).
+ * @throws Exception if any pb
+ */
+ protected abstract void doActionForLocale(Locale locale, boolean isDefaultLocale, File localizedTarget, String localePath) throws Exception;
+
+ /**
+ * Call back after doing all stuff for all locales declared
+ */
+ protected abstract void postDoAction();
+
+ @Override
+ public boolean init() throws Exception {
+
+ File idsStore = getHelpIdsStore();
+
+ if (!idsStore.exists()) {
+ getLog().info("no helpIdStore to react at " + idsStore);
+ return false;
+ }
+
+ if (locales == null || locales.trim().isEmpty()) {
+ throw new MojoFailureException("You must set the 'locales' property properly (was " + locales + ").");
+ }
+
+ // check there is a outHelp
+ if (outHelp == null) {
+ throw new MojoFailureException("You must set the 'outHelp' property.");
+ }
+
+ List<Locale> tmp = new ArrayList<Locale>();
+ for (String loc : locales.split(",")) {
+ Locale l = I18n.newLocale(loc);
+ tmp.add(l);
+ }
+
+ if (tmp.isEmpty()) {
+ throw new MojoFailureException("you must set the 'locales' property.");
+ }
+
+ localesToTreate = tmp.toArray(new Locale[tmp.size()]);
+ defaultLocale = localesToTreate[0];
+
+ createDirectoryIfNecessary(getTargetDirectory());
+
+ // load ids from idsStore file (only once by session)
+
+ if (helpIds == null) {
+ helpIds = new SortedProperties();
+
+ BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(idsStore), getEncoding()));
+ String id;
+ while ((id = reader.readLine()) != null) {
+ id = id.trim();
+ String path = id.replaceAll("\\.", File.separator) + ".html";
+ helpIds.put(id, path);
+ }
+
+ if (helpIds.isEmpty()) {
+
+ // no ids detected
+ getLog().warn("No helpIds detected, will skip.");
+ return false;
+ }
+ }
+ return true;
+ }
+
+ @Override
+ public final void doAction() throws Exception {
+
+ for (Locale locale : localesToTreate) {
+
+ boolean isDefaultLocale = locale == defaultLocale;
+
+ String language = locale.getLanguage();
+
+ String localePath = (isDefaultLocale ? "default" : language);
+
+ File localizedTarget = new File(outHelp, localePath);
+
+ createDirectoryIfNecessary(localizedTarget);
+
+ doActionForLocale(locale, isDefaultLocale, localizedTarget, localePath);
+
+ }
+
+ postDoAction();
+ }
+
+ @Override
+ public File getTargetDirectory() {
+ return outHelp;
+ }
+
+ @Override
+ public void setTargetDirectory(File targetDirectory) {
+ this.outHelp = targetDirectory;
+ }
+
+ protected void doGen(File template, File f, Properties env) throws Exception {
+ VelocityTemplateGenerator gen = prepareGenerator(template);
+ gen.generate(env, f);
+ }
+
+ protected VelocityTemplateGenerator prepareGenerator(File template) throws Exception {
+ URL templateURL = getTemplate(template);
+
+ if (verbose) {
+ getLog().info("using template " + templateURL);
+ }
+ VelocityTemplateGenerator gen = new VelocityTemplateGenerator(project, templateURL);
+ return gen;
+ }
+}
\ No newline at end of file
Property changes on: trunk/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/AbstractGenerateHelpMojo.java
___________________________________________________________________
Added: svn:mergeinfo
+
Modified: trunk/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/AbstractJaxxMojo.java
===================================================================
--- trunk/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/AbstractJaxxMojo.java 2009-12-20 19:57:10 UTC (rev 1686)
+++ trunk/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/AbstractJaxxMojo.java 2009-12-21 13:02:20 UTC (rev 1687)
@@ -18,9 +18,13 @@
* ##%*/
package org.nuiton.jaxx.plugin;
+import org.apache.maven.model.Resource;
import org.apache.maven.project.MavenProject;
import java.io.File;
+import java.io.IOException;
+import java.util.List;
+
import org.nuiton.plugin.AbstractPlugin;
/**
@@ -109,4 +113,68 @@
public void setEncoding(String encoding) {
this.encoding = encoding;
}
+
+ /**
+ * TODO-TC20091221 Should move this to AbstractPlugin
+ * Create the directory if necessary.
+ *
+ * @param dir the directory to create if not already existing
+ * @throws IOException if could not create the directory
+ */
+ protected void createDirectoryIfNecessary(File dir) throws IOException {
+ if (!dir.exists()) {
+ if (verbose) {
+ getLog().info("mkdir " + dir);
+ }
+ boolean b = dir.mkdirs();
+ if (!b) {
+ throw new IOException("could not create directory "+dir);
+ }
+ }
+ }
+
+ //TODO-TC20091221 move this api to PluginHelper
+ public static boolean addResourceDir(File dir, MavenProject project, String... includes) {
+ List<?> resources = project.getResources();
+ boolean added = addResourceDir(dir, project, resources, includes);
+ return added;
+ }
+
+ //TODO-TC20091221 move this api to PluginHelper
+ public static boolean addTestResourceDir(File newresourceDir, MavenProject project, String... includes) {
+ List<?> resources = project.getTestResources();
+ boolean added = addResourceDir(newresourceDir, project, resources, includes);
+ return added;
+ }
+
+ //TODO-TC20091221 move this api to PluginHelper
+ public static boolean addResourceDir(File dir, MavenProject project, List<?> resources, String... includes) {
+ String newresourceDir = dir.getAbsolutePath();
+ boolean shouldAdd = true;
+ for (Object o : resources) {
+ Resource r = (Resource) o;
+ if (!r.getDirectory().equals(newresourceDir)) {
+ continue;
+ }
+
+ for (String i : includes) {
+ if (!r.getIncludes().contains(i)) {
+ r.addInclude(i);
+ }
+ }
+ shouldAdd = false;
+ break;
+ }
+ if (shouldAdd) {
+ Resource r = new Resource();
+ r.setDirectory(newresourceDir);
+ for (String i : includes) {
+ if (!r.getIncludes().contains(i)) {
+ r.addInclude(i);
+ }
+ }
+ project.addResource(r);
+ }
+ return shouldAdd;
+ }
}
Modified: trunk/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/GenerateHelpMojo.java
===================================================================
--- trunk/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/GenerateHelpMojo.java 2009-12-20 19:57:10 UTC (rev 1686)
+++ trunk/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/GenerateHelpMojo.java 2009-12-21 13:02:20 UTC (rev 1687)
@@ -18,185 +18,89 @@
* ##%*/
package org.nuiton.jaxx.plugin;
-import com.sun.java.help.search.Indexer;
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.lang.reflect.InvocationTargetException;
-import org.apache.maven.plugin.MojoFailureException;
+import org.nuiton.plugin.VelocityTemplateGenerator;
+import org.nuiton.util.FileUtil;
+import org.nuiton.util.SortedProperties;
import java.io.File;
-import java.io.FileInputStream;
-import java.io.InputStreamReader;
-import java.io.PrintStream;
-import java.lang.reflect.Method;
-import java.net.URL;
-import java.util.ArrayList;
import java.util.Enumeration;
-import java.util.List;
import java.util.Locale;
import java.util.Properties;
-import org.codehaus.plexus.util.DirectoryScanner;
-import org.codehaus.plexus.util.FileUtils;
-import org.codehaus.plexus.util.StringUtils;
-import org.nuiton.i18n.I18n;
-import org.nuiton.plugin.VelocityTemplateGenerator;
-import org.nuiton.util.FileUtil;
-import org.nuiton.util.SortedProperties;
/**
* Mojo to generate javax help stuff for your project.
- *
+ * <p/>
* HelpIds should have been discovered by the JaxxMojo.
*
* @author chemit
* @goal generate-help
* @phase process-sources
- *
* @requiresProject
* @requiresDependencyResolution compile
* @since 1.3
*/
-public class GenerateHelpMojo extends AbstractJaxxMojo {
+public class GenerateHelpMojo extends AbstractGenerateHelpMojo {
- private static final String AUTOREMOVE_LINE = "REMOVE THS LINE TO DISABLE AUTO-REGENERATE THE FILE";
+
/**
- * The directory where to generate help files.
- *
- * @parameter expression="${jaxx.outHelp}" default-value="${project.basedir}/src/main/help"
- * @required
- *
- * @since 1.3
- */
- protected File outHelp;
- /**
- * The locales to generate for help, seprated by comma.
- *
- * The first locale given is the default locale.
- *
- * @parameter expression="${jaxx.locales}"
- * @required
- *
- * @since 2.0.0
- */
- protected String locales;
- /**
- * The name of the helpset to generate.
- *
- * @parameter expression="${jaxx.helpsetName}" default-value="${project.artifactId}"
- * @required
- *
- * @since 1.3
- */
- protected String helpsetName;
- /**
* The template used to generate helpset file.
- *
+ * <p/>
* Must be an existing file or a ressource in class-path
- *
+ *
* @parameter expression="${jaxx.helpsetTemplate}" default-value="/defaultHelpSet.hs.vm"
* @required
- *
* @since 1.3
*/
protected File helpsetTemplate;
/**
* The template used to generate helpset map file.
- *
+ * <p/>
* Must be an existing file or a ressource in class-path
- *
+ *
* @parameter expression="${jaxx.mapTemplate}" default-value="/defaultMap.jhm.vm"
* @required
- *
* @since 1.3
*/
protected File mapTemplate;
/**
* The template used to generate helpset index file.
- *
+ * <p/>
* Must be an existing file or a ressource in class-path
- *
+ *
* @parameter expression="${jaxx.indexTemplate}" default-value="/defaultIndex.xml.vm"
* @required
- *
* @since 1.3
*/
protected File indexTemplate;
/**
* The template used to generate helpset toc file.
- *
+ * <p/>
* Must be an existing file or a ressource in class-path
- *
+ *
* @parameter expression="${jaxx.tocTemplate}" default-value="/defaultToc.xml.vm"
* @required
- *
* @since 1.3
*/
protected File tocTemplate;
/**
* The template used to generate helpset content file.
- *
+ * <p/>
* Must be an existing file or a ressource in class-path
*
* @parameter expression="${jaxx.contentTemplate}" default-value="/defaultContent.html.vm"
* @required
- *
* @since 1.3
*/
protected File contentTemplate;
- /**
- * Flag to generate the search index.
- *
- * @parameter expression="${jaxx.generateSearch}" default-value="true"
- * @required
- *
- * @since 1.3
- */
- protected boolean generateSearch;
- /**
- * The help ids discovered in {@link #helpIdsStore} files.
- */
- private Properties helpIds;
- /**
- * Default locale (the first locale in {@link #localesToTreate}.
- */
- private Locale defaultLocale;
- /**
- * Locales to treate
- */
- private Locale[] localesToTreate;
+ protected String mapFileName;
+ protected String indexFileName;
+ protected String tocFileName;
+ protected int touchedFiles;
+
@Override
public boolean init() throws Exception {
- File idsStore = getHelpIdsStore();
-
- if (!idsStore.exists()) {
- getLog().info("no helpIdStore to react at " + idsStore);
- return false;
- }
-
- if (locales == null || locales.trim().isEmpty()) {
- throw new MojoFailureException("You must set the 'locales' property properly (was " + locales + ").");
- }
-
- // check there is a outHelp
- if (outHelp == null) {
- throw new MojoFailureException("You must set the 'target' property.");
- }
-
- List<Locale> tmp = new ArrayList<Locale>();
- for (String loc : locales.split(",")) {
- Locale l = I18n.newLocale(loc);
- tmp.add(l);
- }
-
- if (tmp.isEmpty()) {
- throw new MojoFailureException("you must set the 'locales' property.");
- }
-
- localesToTreate = tmp.toArray(new Locale[tmp.size()]);
- defaultLocale = localesToTreate[0];
-
// check ressources
checkResource(helpsetTemplate);
checkResource(mapTemplate);
@@ -204,147 +108,90 @@
checkResource(tocTemplate);
checkResource(contentTemplate);
- if (!getTargetDirectory().exists()) {
- getLog().info("mkdir " + getTargetDirectory());
- getTargetDirectory().mkdirs();
- }
+ mapFileName = helpsetName + "Map.jhm";
+ indexFileName = helpsetName + "Index.xml";
+ tocFileName = helpsetName + "TOC.xml";
+ touchedFiles=0;
+ return super.init();
+ }
- // load ids from idsStore file
+ protected void postDoAction() {
+ getLog().info(touchedFiles + " file(s) treated.");
+ }
- helpIds = new SortedProperties();
+ protected void doActionForLocale(Locale locale, boolean isDefaultLocale, File localizedTarget, String localePath) throws Exception {
- BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(idsStore), getEncoding()));
- String id = null;
- while ((id = reader.readLine()) != null) {
- id = id.trim();
- String path = id.replaceAll("\\.", File.separator) + ".html";
- helpIds.put(id, path);
- }
+ String language = locale.getLanguage();
- if (helpIds.isEmpty()) {
-
- // no ids detected
- getLog().warn("No helpIds detected, will skip.");
- return false;
+ getLog().info("Generate help for language " + language);
+ if (isVerbose()) {
+ getLog().info(" Localized target : " + localizedTarget);
}
- return true;
- }
- @Override
- public void doAction() throws Exception {
+ Properties env = new Properties();
- int touchedFiles = 0;
+ env.put("helpSetName", helpsetName);
+ env.put("locale", language);
+ env.put("localePath", localePath);
+ env.put("separator", " ");
+ env.put("autoremoveLine", AUTOREMOVE_LINE);
- String mapFileName = helpsetName + "Map.jhm";
- String indexFileName = helpsetName + "Index.xml";
- String tocFileName = helpsetName + "TOC.xml";
+ String localeSuffix = isDefaultLocale ? "" : "_" + language;
+ String helpsetFileName = helpsetName + localeSuffix + ".hs";
- for (Locale locale : localesToTreate) {
+ env.put("helpSetFileName", helpsetFileName);
- boolean isDefaultLocale = locale == defaultLocale;
+ env.put("mapFileName", mapFileName);
+ env.put("indexFileName", indexFileName);
+ env.put("tocFileName", tocFileName);
+ env.put("generateSearch", generateSearch);
- String language = locale.getLanguage();
+ // ---------------------------------------------------------------
+ // --- main helpset file -----------------------------------------
+ // ---------------------------------------------------------------
- String localePath = (isDefaultLocale ? "default" : language);
+ File file = new File(outHelp, helpsetFileName);
- File localizedTarget = new File(outHelp, localePath);
+ boolean doCreate = generateHelpsetFile(file, env);
- if (!localizedTarget.exists()) {
- localizedTarget.mkdirs();
- }
- getLog().info("Generate help for language " + language);
- if (isVerbose()) {
- getLog().info(" Localized target : " + localizedTarget);
- }
-
- Properties env = new Properties();
-
- env.put("helpSetName", helpsetName);
- env.put("locale", language);
- env.put("localePath", localePath);
- env.put("separator", " ");
- env.put("autoremoveLine", AUTOREMOVE_LINE);
-
- String localeSuffix = isDefaultLocale ? "" : "_" + language;
- String helpsetFileName = helpsetName + localeSuffix + ".hs";
-
- env.put("helpSetFileName", helpsetFileName);
-
- env.put("mapFileName", mapFileName);
- env.put("indexFileName", indexFileName);
- env.put("tocFileName", tocFileName);
- env.put("generateSearch", generateSearch);
-
- // ---------------------------------------------------------------
- // --- main helpset file -----------------------------------------
- // ---------------------------------------------------------------
-
- File file = new File(outHelp, helpsetFileName);
-
- boolean doCreate = generateHelpsetFile(file, env);
-
- if (doCreate) {
- touchedFiles++;
- }
-
- // ---------------------------------------------------------------
- // --- helpset map file ------------------------------------------
- // ---------------------------------------------------------------
-
- file = new File(localizedTarget, mapFileName);
-
- generateMapFile(file, env);
+ if (doCreate) {
touchedFiles++;
+ }
- // ---------------------------------------------------------------
- // --- helpset index file ----------------------------------------
- // ---------------------------------------------------------------
+ // ---------------------------------------------------------------
+ // --- helpset map file ------------------------------------------
+ // ---------------------------------------------------------------
- file = new File(localizedTarget, indexFileName);
+ file = new File(localizedTarget, mapFileName);
- generateIndexFile(file, env);
- touchedFiles++;
+ generateMapFile(file, env);
+ touchedFiles++;
- // ---------------------------------------------------------------
- // --- helpset toc file ------------------------------------------
- // ---------------------------------------------------------------
+ // ---------------------------------------------------------------
+ // --- helpset index file ----------------------------------------
+ // ---------------------------------------------------------------
- file = new File(localizedTarget, tocFileName);
+ file = new File(localizedTarget, indexFileName);
- generateTocFile(file, env);
- touchedFiles++;
+ generateIndexFile(file, env);
+ touchedFiles++;
- // ---------------------------------------------------------------
- // --- helpset content files -------------------------------------
- // ---------------------------------------------------------------
+ // ---------------------------------------------------------------
+ // --- helpset toc file ------------------------------------------
+ // ---------------------------------------------------------------
- touchedFiles += generateContentFiles(localizedTarget, env, localePath);
+ file = new File(localizedTarget, tocFileName);
- // ---------------------------------------------------------------
- // --- generate search index -------------------------------------
- // ---------------------------------------------------------------
-
- if (generateSearch) {
+ generateTocFile(file, env);
+ touchedFiles++;
- generateSearchIndex(localizedTarget, locale);
- }
+ // ---------------------------------------------------------------
+ // --- helpset content files -------------------------------------
+ // ---------------------------------------------------------------
-
- }
-
- getLog().info(touchedFiles + " file(s) treated.");
+ touchedFiles += generateContentFiles(localizedTarget, env, localePath);
}
- @Override
- public File getTargetDirectory() {
- return outHelp;
- }
-
- @Override
- public void setTargetDirectory(File targetDirectory) {
- this.outHelp = targetDirectory;
- }
-
protected int generateContentFiles(File localizedTarget, Properties env, String localePath) throws Exception {
int touchedFiles = 0;
@@ -367,7 +214,7 @@
continue;
}
}
- f.getParentFile().mkdirs();
+ createDirectoryIfNecessary(f.getParentFile());
if (verbose) {
if (exist) {
getLog().info("regenerate content file " + f);
@@ -412,7 +259,7 @@
boolean create;
- Properties mergedHelpIds = null;
+ Properties mergedHelpIds;
if (file.exists()) {
// get back the exisiting data and merge it with incoming ones
@@ -503,35 +350,6 @@
return rootItem;
}
- protected void generateSearchIndex(File localizedTarget, Locale locale) throws IllegalArgumentException, IOException, InvocationTargetException, SecurityException, IllegalAccessException, NoSuchMethodException {
-
- Method m = Indexer.class.getDeclaredMethod("main", String[].class);
- File indexDir = new File(localizedTarget, "JavaHelpSearch");
- // remove old index
- FileUtils.deleteDirectory(indexDir);
- //copy resources to a tmp dir (without any VCS infos)
- File tmpDir = new File(project.getBasedir(), "target" + File.separator + "jaxx-tmp" + File.separator + "indexer-" + locale + "-" + System.nanoTime());
- getLog().info("copy files to " + tmpDir + " for indexing them");
- FileUtils.copyDirectory(localizedTarget, tmpDir, "**/*", StringUtils.join(DirectoryScanner.DEFAULTEXCLUDES, ","));
- List<String> params = new ArrayList<String>();
- params.add("-verbose");
- params.add("-db");
- params.add(indexDir.getAbsolutePath());
- params.add("-logfile");
- File logFile = new File(project.getBasedir(), "target" + File.separator + "generated-sources" + File.separator + "jaxx" + File.separator + "indexer-" + locale + ".log");
- params.add(logFile.getAbsolutePath());
- params.add(tmpDir.getAbsolutePath());
- PrintStream out = System.out;
- PrintStream err = System.err;
- try {
- m.invoke(null, (Object) params.toArray(new String[params.size()]));
- } finally {
- System.setOut(out);
- System.setErr(err);
- }
- getLog().info("Search Index generated");
- }
-
protected NodeItem generateTocFile(File file, Properties env) throws Exception {
NodeItem rootItem = null;
@@ -572,18 +390,4 @@
return rootItem;
}
- protected void doGen(File template, File f, Properties env) throws Exception {
- VelocityTemplateGenerator gen = prepareGenerator(template);
- gen.generate(env, f);
- }
-
- protected VelocityTemplateGenerator prepareGenerator(File template) throws Exception {
- URL templateURL = getTemplate(template);
-
- if (verbose) {
- getLog().info("using template " + templateURL);
- }
- VelocityTemplateGenerator gen = new VelocityTemplateGenerator(project, templateURL);
- return gen;
- }
}
Copied: trunk/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/GenerateHelpSearchMojo.java (from rev 1686, trunk/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/GenerateHelpMojo.java)
===================================================================
--- trunk/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/GenerateHelpSearchMojo.java (rev 0)
+++ trunk/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/GenerateHelpSearchMojo.java 2009-12-21 13:02:20 UTC (rev 1687)
@@ -0,0 +1,128 @@
+/* *##%
+ * JAXX Maven plugin
+ * Copyright (C) 2008 - 2009 CodeLutin
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program 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 Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * ##%*/
+package org.nuiton.jaxx.plugin;
+
+import com.sun.java.help.search.Indexer;
+import org.codehaus.plexus.util.DirectoryScanner;
+import org.codehaus.plexus.util.FileUtils;
+import org.codehaus.plexus.util.StringUtils;
+
+import java.io.File;
+import java.io.PrintStream;
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Locale;
+
+/**
+ * Mojo to generate javax search index help stuff for your project.
+ * <p/>
+ * The current files should be generated always in a generated directory and not in
+ * your src directories (this is mainly binary files not to be stored in scm system)...
+ *
+ * @author chemit
+ * @goal generate-help-search
+ * @phase process-sources
+ * @requiresProject
+ * @requiresDependencyResolution compile
+ * @since 2.0.0
+ */
+public class GenerateHelpSearchMojo extends AbstractGenerateHelpMojo {
+
+ protected File targetRoot;
+ protected String timestamp;
+
+ @Override
+ public boolean init() throws Exception {
+ if (!generateSearch) {
+ getLog().info("Do not generate search.");
+ return false;
+ }
+ targetRoot = getFileFromBasedir("target", "generated-sources", "help");
+ createDirectoryIfNecessary(targetRoot);
+
+ timestamp = "-" + System.currentTimeMillis();
+ return super.init();
+ }
+
+ @Override
+ protected void doActionForLocale(Locale locale, boolean isDefaultLocale, File localizedTarget, String localePath) throws Exception {
+
+ String language = locale.getLanguage();
+
+ File target = new File(targetRoot, localePath + File.separator + "JavaHelpSearch");
+
+ createDirectoryIfNecessary(localizedTarget);
+ createDirectoryIfNecessary(target);
+
+ getLog().info("Generate help search index for language " + language);
+ if (isVerbose()) {
+ getLog().info(" Localized source : " + localizedTarget);
+ getLog().info(" Localized target : " + target);
+ }
+
+ // ---------------------------------------------------------------
+ // --- generate search index -------------------------------------
+ // ---------------------------------------------------------------
+
+ generateSearchIndex(localizedTarget, target, locale);
+ }
+
+ @Override
+ protected void postDoAction() {
+
+ // add resources to the project
+ addResourceDir(targetRoot, getProject(), "**/*");
+ }
+
+ protected void generateSearchIndex(File source, File target, Locale locale) throws Exception {
+
+ Method m = Indexer.class.getDeclaredMethod("main", String[].class);
+
+ // remove old index
+ FileUtils.deleteDirectory(target);
+
+ //copy resources to a tmp dir (without any VCS infos)
+ File tmpDir = getFileFromBasedir("target", "jaxx-tmp", "indexer-" + locale + timestamp);
+ getLog().info("copy files to " + tmpDir + " for indexing them");
+ FileUtils.copyDirectory(source, tmpDir, "**/*", StringUtils.join(DirectoryScanner.DEFAULTEXCLUDES, ","));
+
+ // prepare arguments of Indexer.main calling
+ List<String> params = new ArrayList<String>();
+ params.add("-verbose");
+ params.add("-db");
+ params.add(target.getAbsolutePath());
+ params.add("-logfile");
+ File logFile = getFileFromBasedir("target", "generated-sources", "jaxx", "indexer-" + locale + ".log");
+ params.add(logFile.getAbsolutePath());
+ params.add(tmpDir.getAbsolutePath());
+ PrintStream out = System.out;
+ PrintStream err = System.err;
+
+ // invoke Indexer.main
+ try {
+ m.invoke(null, (Object) params.toArray(new String[params.size()]));
+ } finally {
+ System.setOut(out);
+ System.setErr(err);
+ }
+ getLog().info("Search Index generated for " + locale);
+ }
+
+}
\ No newline at end of file
Modified: trunk/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/GenerateMojo.java
===================================================================
--- trunk/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/GenerateMojo.java 2009-12-20 19:57:10 UTC (rev 1686)
+++ trunk/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/GenerateMojo.java 2009-12-21 13:02:20 UTC (rev 1687)
@@ -367,9 +367,7 @@
BeanInfoUtil.addJaxxBeanInfoPath(beanInfoSearchPath);
}
- if (!getTargetDirectory().exists()) {
- getTargetDirectory().mkdirs();
- }
+ createDirectoryIfNecessary(getTargetDirectory());
// compute extra imports (can not use java classes since some of
// imports can not be still compiled)
@@ -567,9 +565,7 @@
}
File idsStore = getHelpIdsStore();
- if (!idsStore.getParentFile().exists()) {
- idsStore.getParentFile().mkdirs();
- }
+ createDirectoryIfNecessary(idsStore.getParentFile());
StringBuilder buffer = new StringBuilder();
Modified: trunk/maven-jaxx-plugin/src/site/rst/index.rst
===================================================================
--- trunk/maven-jaxx-plugin/src/site/rst/index.rst 2009-12-20 19:57:10 UTC (rev 1686)
+++ trunk/maven-jaxx-plugin/src/site/rst/index.rst 2009-12-21 13:02:20 UTC (rev 1687)
@@ -9,8 +9,10 @@
The plugin permits to generate java files from jaxx files via the `generate`_ goal.
-You can also generate the java help system via the `generate-help`_ goal.
+You can also generate the java help system via the `generate-help`_ goal and generate search index via
+the `generate-help-search`_ goal.
+
Default layout
--------------
@@ -20,7 +22,8 @@
* the jaxx files should be under *src/main/java*
* the generated java files should be under *target/generated-sources/java*
* the java help files should be under *src/main/help*
-
+ * the generated help search index should be under *target/generated-sources/help*
+
.. _generate: generate-mojo.html
-
.. _generate-help: generate-help-mojo.html
+.. _generate-help-search: generate-help-search-mojo.html
Modified: trunk/maven-jaxx-plugin/src/site/site.xml
===================================================================
--- trunk/maven-jaxx-plugin/src/site/site.xml 2009-12-20 19:57:10 UTC (rev 1686)
+++ trunk/maven-jaxx-plugin/src/site/site.xml 2009-12-21 13:02:20 UTC (rev 1687)
@@ -20,6 +20,7 @@
<item name="Détail goals" href="plugin-info.html">
<item name="generate" href="generate-mojo.html"/>
<item name="generate-help" href="generate-help-mojo.html"/>
+ <item name="generate-help-search" href="generate-help-search-mojo.html"/>
<item name="help" href="help-mojo.html"/>
</item>
</menu>
1
0
r1686 - trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor
by tchemit@users.nuiton.org 20 Dec '09
by tchemit@users.nuiton.org 20 Dec '09
20 Dec '09
Author: tchemit
Date: 2009-12-20 20:57:10 +0100 (Sun, 20 Dec 2009)
New Revision: 1686
Modified:
trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/NumberEditorHandler.java
Log:
- fix Anomalie #152: NumberEditor avec un Double ou BigDecimal
Modified: trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/NumberEditorHandler.java
===================================================================
--- trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/NumberEditorHandler.java 2009-12-18 13:34:23 UTC (rev 1685)
+++ trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/NumberEditorHandler.java 2009-12-20 19:57:10 UTC (rev 1686)
@@ -288,16 +288,16 @@
return f;
}
if (modelType == Double.class) {
- return f.doubleValue();
+ return f;
}
if (modelType == Long.class) {
return f.longValue();
}
if (modelType == BigInteger.class) {
- return BigInteger.valueOf(f.longValue());
+ return new BigInteger(f.longValue() + "");
}
if (modelType == BigDecimal.class) {
- return BigDecimal.valueOf(f.doubleValue());
+ return new BigDecimal(f + "");
}
if (editor.isUseFloat()) {
// use default float value
1
0
Author: tchemit
Date: 2009-12-18 14:34:23 +0100 (Fri, 18 Dec 2009)
New Revision: 1685
Modified:
trunk/pom.xml
Log:
use mavenpom 1.1.3
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2009-12-14 11:44:49 UTC (rev 1684)
+++ trunk/pom.xml 2009-12-18 13:34:23 UTC (rev 1685)
@@ -10,7 +10,7 @@
<parent>
<groupId>org.nuiton</groupId>
<artifactId>mavenpom</artifactId>
- <version>1.1.1</version>
+ <version>1.1.3</version>
</parent>
<artifactId>jaxx</artifactId>
1
0