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
October 2010
- 3 participants
- 24 discussions
r2105 - trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor
by tchemit@users.nuiton.org 05 Oct '10
by tchemit@users.nuiton.org 05 Oct '10
05 Oct '10
Author: tchemit
Date: 2010-10-05 10:04:30 +0200 (Tue, 05 Oct 2010)
New Revision: 2105
Url: http://nuiton.org/repositories/revision/jaxx/2105
Log:
remove unecessary parentheses
Modified:
trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/NumberEditorHandler.java
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 2010-10-05 08:03:11 UTC (rev 2104)
+++ trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/NumberEditorHandler.java 2010-10-05 08:04:30 UTC (rev 2105)
@@ -242,7 +242,7 @@
try {
Float f = Float.parseFloat(s);
- if (!editor.isUseSign() && (s.startsWith("-"))) {
+ if (!editor.isUseSign() && s.startsWith("-")) {
if (log.isDebugEnabled()) {
log.debug("will skip since can not allow sign on this editor but was " + f);
}
@@ -447,7 +447,7 @@
strValue = newValue + "";
if (editor.isUseFloat()) {
Float n = Float.parseFloat(strValue);
- if (((float) n.intValue()) == n) {
+ if ((float) n.intValue() == n) {
strValue = n.intValue() + "";
}
}
1
0
05 Oct '10
Author: tchemit
Date: 2010-10-05 10:03:11 +0200 (Tue, 05 Oct 2010)
New Revision: 2104
Url: http://nuiton.org/repositories/revision/jaxx/2104
Log:
Evolution #913: Remove deprecated EntityComboBoxHandler
Removed:
trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/EntityComboBox.jaxx
trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/EntityComboBoxHandler.java
Deleted: trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/EntityComboBox.jaxx
===================================================================
--- trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/EntityComboBox.jaxx 2010-10-04 18:12:49 UTC (rev 2103)
+++ trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/EntityComboBox.jaxx 2010-10-05 08:03:11 UTC (rev 2104)
@@ -1,139 +0,0 @@
-<!--
- #%L
- JAXX :: Widgets
-
- $Id$
- $HeadURL$
- %%
- Copyright (C) 2008 - 2010 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>.
- #L%
-
- @deprecated since 2.2, use now {@link BeanComboBox}
- -->
-
-<Table fill='both' insets='0' genericType='O'
- onFocusGained='combobox.requestFocus()'
- onFocusLost='hidePopup()'>
-
- <!-- auto complete property -->
- <Boolean id='autoComplete' javaBean='false'/>
-
- <!-- show reset property -->
- <Boolean id='showReset' javaBean='false'/>
-
- <!-- show decorator property -->
- <Boolean id='showDecorator' javaBean='true'/>
-
- <!-- editable combo property -->
- <Boolean id='editable' javaBean='true'/>
-
- <!-- bean property linked state -->
- <String id='property' javaBean='""'/>
-
- <!-- bean property -->
- <Object id='bean' javaBean='null'/>
-
- <!-- selectedItem property -->
- <Object id='selectedItem' javaBean='null'/>
-
- <!-- sort index property -->
- <Integer id='index' javaBean='0'/>
-
- <!-- datas of the combo-box -->
- <java.util.List id='data' genericType='O' javaBean='null'/>
-
- <!-- model of sorted property -->
- <ButtonGroup id='indexes' useToolTipText='true'
- onStateChanged='setIndex((Integer)indexes.getSelectedValue())'/>
-
- <!-- ui handler -->
- <EntityComboBoxHandler id='handler' genericType='O' constructorParams='this'/>
-
- <String id='selectedToolTipText' javaBean='null'/>
-
- <String id='notSelectedToolTipText' javaBean='null'/>
-
- <String id='popupTitleText' javaBean='null'/>
-
- <String id='i18nPrefix' javaBean='"beancombobox.common."'/>
-
- <!-- popup to change sorted property-->
- <JPopupMenu id='popup'
- border='{new TitledBorder(_("beancombobox.popup.title"))}'
- onPopupMenuWillBecomeInvisible='getChangeDecorator().setSelected(false)'
- onPopupMenuCanceled='getChangeDecorator().setSelected(false)'>
- <JLabel id='popupLabel'/>
- <JSeparator/>
- </JPopupMenu>
-
- <script><![CDATA[
-import static org.nuiton.i18n.I18n.n_;
-import jaxx.runtime.decorator.JXPathDecorator;
-
-public static final String DEFAULT_POPUP_LABEL = n_("bean.popup.label");
-
-public static final String DEFAULT_SELECTED_TOOLTIP = n_("bean.sort.on");
-
-public static final String DEFAULT_NOT_SELECTED_TOOLTIP = n_("bean.sort.off");
-
-public void init(JXPathDecorator<O> decorator, java.util.List<O> data) {
- handler.init(decorator, data);
-}
-
-protected void hidePopup() {
- if (popup.isVisible()) {
- popup.setVisible(false);
- }
-}
-]]>
- </script>
- <row>
- <cell anchor='west'>
- <!-- le boutton pour reinitialiser la valeur sélectionnée -->
- <JToolBar floatable='false' borderPainted='false' visible='{isShowReset()}'>
- <JButton actionIcon='combobox-reset'
- toolTipText='beancombobox.action.reset.tip'
- focusable='false'
- focusPainted='false'
- enabled='{isEditable() && isEnabled()}'
- onActionPerformed='setSelectedItem(null)'/>
- </JToolBar>
-
- </cell>
- <cell weightx='1'>
- <!-- la liste déroulante -->
- <JComboBox id='combobox'
- selectedItem='{getSelectedItem()}'
- enabled='{isEnabled()}'
- editable='{isEditable()}'
- focusable='{isEnabled() && isEditable()}'
- onFocusGained='hidePopup()'
- onItemStateChanged='setSelectedItem(combobox.getSelectedItem())'/>
- </cell>
- <cell anchor='east' fill='both' insets='0'>
- <!-- le boutton pour changer le tri -->
- <JToolBar floatable='false' borderPainted='false' visible='{isShowDecorator()}'>
- <JToggleButton id='changeDecorator'
- actionIcon='combobox-sort'
- toolTipText='beancombobox.action.sort.tip'
- focusable='false'
- focusPainted='false'
- onActionPerformed='getHandler().togglePopup()'/>
- </JToolBar>
- </cell>
- </row>
-</Table>
Deleted: trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/EntityComboBoxHandler.java
===================================================================
--- trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/EntityComboBoxHandler.java 2010-10-04 18:12:49 UTC (rev 2103)
+++ trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/EntityComboBoxHandler.java 2010-10-05 08:03:11 UTC (rev 2104)
@@ -1,483 +0,0 @@
-/*
- * #%L
- * JAXX :: Widgets
- *
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2008 - 2010 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>.
- * #L%
- */
-
-package jaxx.runtime.swing;
-
-import java.awt.Component;
-import jaxx.runtime.SwingUtil;
-import jaxx.runtime.swing.editor.bean.BeanComboBoxHandler;
-import org.apache.commons.beanutils.PropertyUtils;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import static org.nuiton.i18n.I18n._;
-import static org.nuiton.i18n.I18n.n_;
-
-import org.jdesktop.swingx.autocomplete.AutoCompleteDecorator;
-import org.jdesktop.swingx.autocomplete.ObjectToStringConverter;
-
-import javax.swing.JPopupMenu;
-import javax.swing.JRadioButtonMenuItem;
-import javax.swing.JToggleButton;
-import javax.swing.SwingUtilities;
-import javax.swing.text.Document;
-import javax.swing.text.JTextComponent;
-import java.awt.Dimension;
-import java.awt.event.FocusEvent;
-import java.awt.event.FocusListener;
-import java.beans.Introspector;
-import java.beans.PropertyChangeEvent;
-import java.beans.PropertyChangeListener;
-import java.beans.PropertyDescriptor;
-import java.lang.reflect.Method;
-import java.util.List;
-import javax.swing.JComboBox;
-import jaxx.runtime.decorator.Decorator;
-import jaxx.runtime.decorator.JXPathDecorator;
-import jaxx.runtime.decorator.MultiJXPathDecorator;
-import jaxx.runtime.swing.renderer.DecoratorListCellRenderer;
-import jaxx.runtime.decorator.DecoratorUtils;
-import org.jdesktop.swingx.autocomplete.AutoCompletePropertyChangeListener;
-
-/**
- * Le handler d'un {@link EntityComboBox}.
- * <p/>
- * Note: ce handler n'est pas staeless et n'est donc pas partageable entre plusieurs ui.
- *
- * @param <O> le type des objet contenus dans le modèle du composant.
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @see EntityComboBox
- * @deprecated since 2.2, use now {@link BeanComboBoxHandler}.
- */
-@Deprecated
-public class EntityComboBoxHandler<O> implements PropertyChangeListener {
-
- public static final Log log = LogFactory.getLog(EntityComboBoxHandler.class);
- public static final String SELECTED_ITEM_PROPERTY = "selectedItem";
- public static final String INDEX_PROPERTY = "index";
- public static final String AUTO_COMPLETE_PROPERTY = "autoComplete";
- public static final String DATA_PROPERTY = "data";
- /** ui if the handler */
- protected EntityComboBox<O> ui;
- /** the mutator method on the property of boxed bean in the ui */
- protected Method mutator;
- /** the original document of the combbo box editor (keep it to make possible undecorate) */
- protected Document originalDocument;
- /** the convertor used to auto-complete */
- protected ObjectToStringConverter convertor;
- /** the decorator of data */
- protected MultiJXPathDecorator<O> decorator;
- protected boolean init;
-
- public EntityComboBoxHandler(EntityComboBox<O> ui) {
- this.ui = ui;
- }
- protected final FocusListener EDITOR_TEXT_COMP0NENT_FOCUSLISTENER = new FocusListener() {
-
- @Override
- public void focusGained(FocusEvent e) {
- if (log.isDebugEnabled()) {
- log.debug("close popup from " + e);
- }
- ui.getPopup().setVisible(false);
- }
-
- @Override
- public void focusLost(FocusEvent e) {
- }
- };
-
- /**
- * Initialise le handler de l'ui
- *
- * @param decorator le decorateur a utiliser
- * @param data la liste des données a gérer
- */
- public void init(JXPathDecorator<O> decorator, List<O> data) {
-
- if (init) {
- throw new IllegalStateException("can not init the handler twice");
- }
- init = true;
- if (decorator == null) {
- throw new NullPointerException("can not have a null decorator as parameter");
- }
-
- JAXXButtonGroup indexes = ui.getIndexes();
-
- MultiJXPathDecorator<O> d;
- if (decorator instanceof MultiJXPathDecorator<?>) {
- // should clone decorator ?
- d = (MultiJXPathDecorator<O>) decorator;
- } else {
- d = DecoratorUtils.newMultiJXPathDecorator(decorator.getInternalClass(), decorator.getInitialExpression(), " - ");
- }
- this.decorator = d;
-
- // init combobox renderer base on given decorator
- ui.getCombobox().setRenderer(new DecoratorListCellRenderer(d));
-
- convertor = newDecoratedObjectToStringConverter(d);
-
- // keep a trace of original document (to make possible reverse autom-complete)
- JTextComponent editorComponent = (JTextComponent) ui.getCombobox().getEditor().getEditorComponent();
- originalDocument = editorComponent.getDocument();
-
- // build popup
- preparePopup(d);
-
- ui.autoComplete = true;
-
- ui.addPropertyChangeListener(this);
-
- // set datas
- ui.setData(data);
-
- // select sort button
- indexes.setSelectedButton(ui.getIndex());
- }
-
- /** Toggle the popup visible state. */
- public void togglePopup() {
- boolean newValue = !ui.getPopup().isVisible();
-
- if (log.isTraceEnabled()) {
- log.trace(newValue);
- }
-
- if (!newValue) {
- if (ui.getPopup() != null) {
- ui.getPopup().setVisible(false);
- }
- return;
- }
- SwingUtilities.invokeLater(new Runnable() {
-
- @Override
- public void run() {
- ui.getPopup().pack();
- Dimension dim = ui.getPopup().getPreferredSize();
- JToggleButton invoker = ui.getChangeDecorator();
- ui.getPopup().show(invoker, (int) (invoker.getPreferredSize().getWidth() - dim.getWidth()), invoker.getHeight());
- }
- });
- }
-
- /**
- * Modifie l'état autoComplete de l'ui.
- *
- * @param oldValue l'ancienne valeur
- * @param newValue la nouvelle valeur
- */
- protected void setAutoComplete(Boolean oldValue, Boolean newValue) {
- oldValue = oldValue != null && oldValue;
- newValue = newValue != null && newValue;
- if (oldValue == newValue) {
- return;
- }
- if (log.isDebugEnabled()) {
- log.debug("autocomplete state : <" + oldValue + " to " + newValue + ">");
- }
- if (!newValue) {
- JTextComponent editorComponent = (JTextComponent) ui.getCombobox().getEditor().getEditorComponent();
- editorComponent.removeFocusListener(EDITOR_TEXT_COMP0NENT_FOCUSLISTENER);
- undecorate(ui.getCombobox(), originalDocument);
- } else {
- decorate(ui.getCombobox(), convertor);
- JTextComponent editorComponent = (JTextComponent) ui.getCombobox().getEditor().getEditorComponent();
- editorComponent.addFocusListener(EDITOR_TEXT_COMP0NENT_FOCUSLISTENER);
- }
- }
-
- /**
- * Modifie l'index du décorateur
- *
- * @param oldValue l'ancienne valeur
- * @param newValue la nouvelle valeur
- */
- @SuppressWarnings({"unchecked"})
- protected void setIndex(Integer oldValue, Integer newValue) {
- if (newValue.equals(oldValue)) {
- return;
- }
- if (log.isDebugEnabled()) {
- log.debug("check state : <" + oldValue + " to " + newValue + ">");
- }
-
- // change decorator context
- decorator.setContextIndex(newValue);
-
- // keep selected item
- Object previousSelectedItem = ui.getSelectedItem();
- Boolean wasAutoComplete = ui.isAutoComplete();
-
- if (wasAutoComplete) {
- ui.setAutoComplete(false);
- }
-
- // remove autocomplete
- if (previousSelectedItem != null) {
- ui.getCombobox().setSelectedItem(null);
- ui.selectedItem = null;
- }
-
-
- try {
- // Sort data with the decorator jxpath tokens.
- DecoratorUtils.sort(decorator, ui.getData(), newValue);
- } catch (Exception e) {
- log.warn(e.getMessage(), e);
- //System.out.println("newValue :: "+decorator+" : "+newValue);
- //System.out.println("datas :: "+ui.getData());
- }
-
- // reload the model
- SwingUtil.fillComboBox(ui.getCombobox(), ui.getData(), null);
-
- if (wasAutoComplete) {
- ui.setAutoComplete(true);
- }
-
- if (previousSelectedItem != null) {
- ui.setSelectedItem(previousSelectedItem);
- }
-
- ui.getCombobox().requestFocus();
- }
-
- /**
- * Modifie la valeur sélectionnée dans la liste déroulante.
- *
- * @param oldValue l'ancienne valeur
- * @param newValue la nouvelle valeur
- */
- protected void setSelectedItem(Object oldValue, Object newValue) {
- if (ui.getBean() == null) {
- return;
- }
-
- if (newValue == null) {
- if (ui.getCombobox().getSelectedItem() == null) {
- return;
- }
- ui.getCombobox().setSelectedItem(null);
-
- if (ui.isAutoComplete()) {
- ui.setAutoComplete(false);
- ui.setAutoComplete(true);
- }
-
- if (oldValue == null) {
- return;
- }
- }
- if (log.isDebugEnabled()) {
- log.debug(ui.getProperty() + " on " + ui.getBean().getClass() + " :: " + oldValue + " to " + newValue);
- }
-
- try {
- Method mut = getMutator();
- if (mut != null) {
- mut.invoke(ui.getBean(), newValue);
- }
- } catch (Exception e) {
- throw new RuntimeException(e);
- }
- }
-
- /** @return le document de l'éditeur avant complétion. */
- public Document getOriginalDocument() {
- return originalDocument;
- }
-
- public MultiJXPathDecorator<O> getDecorator() {
- return decorator;
- }
-
- /**
- * Creation de l'ui pour modifier le décorateur.
- *
- * @param decorator le decorateur a utiliser
- */
- protected void preparePopup(MultiJXPathDecorator<?> decorator) {
- String selectedTip = ui.getSelectedToolTipText();
- if (selectedTip == null) {
- // use default selected tip text
- selectedTip = EntityComboBox.DEFAULT_SELECTED_TOOLTIP;
- }
- String notSelectedTip = ui.getNotSelectedToolTipText();
- if (notSelectedTip == null) {
- // use default selected tip text
- notSelectedTip = EntityComboBox.DEFAULT_NOT_SELECTED_TOOLTIP;
- }
- JPopupMenu popup = ui.getPopup();
-
- //Container container = ui.getIndexesContainer();
- for (int i = 0, max = decorator.getNbContext(); i < max; i++) {
- String property = ui.getI18nPrefix() + decorator.getProperty(i);
- String propertyI18n = _(property);
- JRadioButtonMenuItem button = new JRadioButtonMenuItem(propertyI18n);
- button.putClientProperty(JAXXButtonGroup.BUTTON8GROUP_CLIENT_PROPERTY, ui.getIndexes());
- button.putClientProperty(JAXXButtonGroup.VALUE_CLIENT_PROPERTY, i);
- popup.add(button);
- if (selectedTip != null) {
- button.putClientProperty(JAXXButtonGroup.SELECTED_TIP_CLIENT_PROPERTY, _(selectedTip, propertyI18n));
- }
- if (notSelectedTip != null) {
- button.putClientProperty(JAXXButtonGroup.NOT_SELECTED_TIP_CLIENT_PROPERTY, _(notSelectedTip, propertyI18n));
- }
- button.setSelected(false);
- ui.getIndexes().add(button);
- }
- String title = ui.getPopupTitleText();
- if (title == null) {
- // use default popup title
- title = EntityComboBox.DEFAULT_POPUP_LABEL;
-
- Class<?> internalClass = decorator.getInternalClass();
- String beanI18nKey;
- if (internalClass == null) {
- beanI18nKey = n_("bean.unknown.type");
- } else {
- beanI18nKey = ui.getI18nPrefix() + Introspector.decapitalize(internalClass.getSimpleName());
- }
- String beanI18n = _(beanI18nKey);
- title = _(title, beanI18n);
- } else {
- title = _(title);
- }
- ui.getPopupLabel().setText(title);
- ui.getPopup().setLabel(title);
- ui.getPopup().invalidate();
- }
-
- public Class<?> getTargetClass() {
- Method m = getMutator();
- return m == null ? null : m.getParameterTypes()[0];
- }
-
- /** @return le mutateur a utiliser pour modifier le bean associé. */
- protected Method getMutator() {
- if (mutator == null) {
- Object bean = ui.getBean();
- if (bean == null) {
- throw new NullPointerException("could not find bean in " + ui);
- }
- String property = ui.getProperty();
- if (property == null) {
- throw new NullPointerException("could not find property in " + ui);
- }
-
- try {
- PropertyDescriptor descriptor = PropertyUtils.getPropertyDescriptor(bean, property);
- if (descriptor != null) {
- mutator = descriptor.getWriteMethod();
- }
- } catch (Exception e) {
- throw new RuntimeException(e);
- }
- }
- return mutator;
- }
-
- /**
- * Encapsule un {@link Decorator} dans un {@link ObjectToStringConverter}.
- *
- * @param decorator le decorateur a encapsuler.
- * @return le converter encapsule dans un {@link ObjectToStringConverter}
- */
- public static ObjectToStringConverter newDecoratedObjectToStringConverter(final Decorator<?> decorator) {
-
- return new ObjectToStringConverter() {
-
- @Override
- public String getPreferredStringForItem(Object item) {
- return item instanceof String ? (String) item : item == null ? "" : decorator.toString(item);
- }
- };
- }
-
- /**
- * Ajout l'auto-complétion sur une liste déroulante, en utilisant le
- * converteur donné pour afficher les données.
- *
- * @param combo la combo à décorer
- * @param convertor le converter utilisé pour afficher les données.
- */
- public static void decorate(JComboBox combo, ObjectToStringConverter convertor) {
-
- AutoCompleteDecorator.decorate(combo, convertor);
- }
-
- /**
- * Désactive l'aut-complétion sur une liste déroulante, en y repositionnant
- * le modèle du document d'édition d'avant auto-complétion.
- *
- * @param combo la liste déroulante à décorer
- * @param originalDocument le document original de l'édtieur de la
- * liste déroulante.
- */
- public static void undecorate(JComboBox combo, Document originalDocument) {
-
- // has not to be editable
- combo.setEditable(false);
-
- // configure the text component=editor component
- Component c = combo.getEditor().getEditorComponent();
- JTextComponent editorComponent = (JTextComponent) c;
- editorComponent.setDocument(originalDocument);
- editorComponent.setText(null);
- //remove old property change listener
- for (PropertyChangeListener l : c.getPropertyChangeListeners("editor")) {
- if (l instanceof AutoCompletePropertyChangeListener) {
- c.removePropertyChangeListener("editor", l);
- }
- }
- }
-
- @Override
- public void propertyChange(PropertyChangeEvent evt) {
- String propertyName = evt.getPropertyName();
-
- if (SELECTED_ITEM_PROPERTY.equals(propertyName)) {
- setSelectedItem(evt.getOldValue(), evt.getNewValue());
- return;
- }
-
- if (INDEX_PROPERTY.equals(propertyName)) {
- setIndex((Integer) evt.getOldValue(), (Integer) evt.getNewValue());
- return;
- }
- if (AUTO_COMPLETE_PROPERTY.equals(propertyName)) {
- setAutoComplete((Boolean) evt.getOldValue(), (Boolean) evt.getNewValue());
- return;
- }
- if (DATA_PROPERTY.equals(propertyName)) {
- // list has changed, force reload of index
- setIndex(-1, ui.getIndex());
- }
-
- }
-}
1
0
r2103 - trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing
by sletellier@users.nuiton.org 04 Oct '10
by sletellier@users.nuiton.org 04 Oct '10
04 Oct '10
Author: sletellier
Date: 2010-10-04 20:12:49 +0200 (Mon, 04 Oct 2010)
New Revision: 2103
Url: http://nuiton.org/repositories/revision/jaxx/2103
Log:
Creating handler for ListSelectionUI
Added:
trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/ListSelectorHandler.java
Modified:
trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/ListSelectorUI.jaxx
Added: trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/ListSelectorHandler.java
===================================================================
--- trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/ListSelectorHandler.java (rev 0)
+++ trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/ListSelectorHandler.java 2010-10-04 18:12:49 UTC (rev 2103)
@@ -0,0 +1,179 @@
+/*
+ * #%L
+ * JAXX :: Widgets
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2008 - 2010 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>.
+ * #L%
+ */
+package jaxx.runtime.swing;
+
+import jaxx.runtime.SwingUtil;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import javax.swing.*;
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+
+/**
+ * @author sletellier <letellier(a)codelutin.com>
+ * @since 2.2.3
+ */
+public class ListSelectorHandler <B> {
+
+ public static final Log log = LogFactory.getLog(ListSelectorHandler.class);
+
+ protected ListSelectorUI<B> listSelector;
+
+ public ListSelectorHandler(final ListSelectorUI<B> listSelector) {
+ this.listSelector = listSelector;
+ }
+
+ protected JComboBox getCombo() {
+ return listSelector.getCombo();
+ }
+
+ protected JList getList() {
+ return listSelector.getList();
+ }
+
+ /**
+ * @return the datas from the combo box.
+ */
+ public java.util.List<B> getComboDatas() {
+ java.util.List<B> datas = new java.util.ArrayList<B>();
+ ComboBoxModel comboModel = getCombo().getModel();
+ for (int i = 0, j = comboModel.getSize(); i < j; i++) {
+ B g = (B) comboModel.getElementAt(i);
+ datas.add(g);
+ }
+ return datas;
+ }
+
+ /**
+ * @return the data for the list.
+ */
+ public java.util.List<B> getListDatas() {
+ java.util.List<B> datas = new java.util.ArrayList<B>();
+ ListModel listModel = getList().getModel();
+ for (int i = 0, j = listModel.getSize(); i < j; i++) {
+ B g = (B) listModel.getElementAt(i);
+ datas.add(g);
+ }
+ return datas;
+ }
+
+ /**
+ * Initialize the component.
+ *
+ * @param toCombo datas to set in combo
+ * @param toList datas to set in list
+ */
+ public void init(java.util.List<B> toCombo, java.util.List<B> toList) {
+ setComboDatas(toCombo);
+ setListDatas(toList);
+ // after init, always unmodified editor
+ // TODO should avoid to fire a changed ?
+ listSelector.setModified(false);
+
+ HidorButton hidor = listSelector.getHidor();
+ hidor.addPropertyChangeListener("targetVisible", new PropertyChangeListener() {
+
+ @Override
+ public void propertyChange(PropertyChangeEvent evt) {
+ if (log.isDebugEnabled()) {
+ log.debug("target visible changed <" + evt.getOldValue() + ":" + evt.getNewValue() + ">");
+ }
+ if (!listSelector.isShowHidor() || !listSelector.isEnabled()) {
+ return;
+ }
+ SwingUtilities.invokeLater(new Runnable() {
+
+ @Override
+ public void run() {
+ log.info("invalidate " + listSelector.getParent().getName());
+ listSelector.listPane.invalidate();
+ }
+ });
+ }
+ });
+ }
+
+ /**
+ * Transfert the {@code b} data from combo box to list.
+ *
+ * @param b the data to transfert
+ */
+ protected void transfertToList(B b) {
+ ((DefaultListModel) getList().getModel()).addElement(b);
+ ((DefaultComboBoxModel) getCombo().getModel()).removeElement(b);
+ listSelector.setModified(true);
+ }
+
+ /**
+ * Transfert the {@code b} data from list to combo box.
+ *
+ * @param bs the data to transfert
+ */
+ protected void transfertToCombo(B[] bs) {
+ for (B b : bs) {
+ ((DefaultListModel) getList().getModel()).removeElement(b);
+ ((DefaultComboBoxModel) getCombo().getModel()).addElement(b);
+ }
+ listSelector.setModified(true);
+ }
+
+ /**
+ * @param enabled databinding
+ * @return {@code true} if add button should be enabled
+ */
+ protected boolean updateAddEnabled(boolean enabled) {
+ return enabled && getCombo().getModel().getSize() > 0;
+ }
+
+ /**
+ * @param enabled databinding
+ * @return {@code true} if remove button should be enabled
+ */
+ protected boolean updateRemoveEnabled(boolean enabled) {
+ return enabled && getList().getModel().getSize() > 0;
+ }
+
+ /**
+ * Set the data in combo box model.
+ *
+ * @param toCombo datas to set in combo box model
+ */
+ protected void setComboDatas(java.util.List<B> toCombo) {
+ SwingUtil.fillComboBox(getCombo(), toCombo, null);
+ //Note : there is a case when combo was selected, then come here with an empty
+ // combo model : no propertyChanged is fired, so add button stays enabled...
+ listSelector.processDataBinding("add.enabled");
+ }
+
+ /**
+ * Set the data in the list model.
+ *
+ * @param toList datas to set in list model
+ */
+ protected void setListDatas(java.util.List<B> toList) {
+ SwingUtil.fillList(getList(), toList, null);
+ }
+}
Modified: trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/ListSelectorUI.jaxx
===================================================================
--- trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/ListSelectorUI.jaxx 2010-10-03 15:50:46 UTC (rev 2102)
+++ trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/ListSelectorUI.jaxx 2010-10-04 18:12:49 UTC (rev 2103)
@@ -35,57 +35,27 @@
<ListCellRenderer id='renderer' javaBean='null'/>
- <import>
-java.beans.PropertyChangeListener
-java.beans.PropertyChangeEvent
- </import>
+ <!-- ui handler -->
+ <ListSelectorHandler id='handler' genericType='B' constructorParams='this'/>
<script><![CDATA[
-hidor.addPropertyChangeListener("targetVisible", new PropertyChangeListener() {
- @Override
- public void propertyChange(PropertyChangeEvent evt) {
- if (log.isDebugEnabled()) {
- log.debug("target visible changed <" + evt.getOldValue() + ":" + evt.getNewValue() + ">");
- }
- if (!showHidor || !isEnabled()) {
- return;
- }
- SwingUtilities.invokeLater(new Runnable() {
+public void setHandler(ListSelectorHandler handler) {
+ this.handler = handler;
+}
- @Override
- public void run() {
- log.info("invalidate " + getParent().getName());
- listPane.invalidate();
- }
- });
- }
-});
-
/**
* @return the datas from the combo box.
*/
public java.util.List<B> getComboDatas() {
- java.util.List<B> datas = new java.util.ArrayList<B>();
- ComboBoxModel comboModel = combo.getModel();
- for (int i = 0, j = comboModel.getSize(); i < j; i++) {
- B g = (B) comboModel.getElementAt(i);
- datas.add(g);
- }
- return datas;
+ return handler.getComboDatas();
}
/**
* @return the data for the list.
*/
public java.util.List<B> getListDatas() {
- java.util.List<B> datas = new java.util.ArrayList<B>();
- ListModel listModel = list.getModel();
- for (int i = 0, j = listModel.getSize(); i < j; i++) {
- B g = (B) listModel.getElementAt(i);
- datas.add(g);
- }
- return datas;
+ return handler.getListDatas();
}
/**
@@ -95,74 +65,8 @@
* @param toList datas to set in list
*/
public void init(java.util.List<B> toCombo, java.util.List<B> toList) {
- setComboDatas(toCombo);
- setListDatas(toList);
- // after init, always unmodified editor
- // TODO should avoid to fire a changed ?
- setModified(false);
+ handler.init(toCombo, toList);
}
-
-/**
- * Transfert the {@code b} data from combo box to list.
- *
- * @param b the data to transfert
- */
-protected void transfertToList(B b) {
- ((DefaultListModel) list.getModel()).addElement(b);
- ((DefaultComboBoxModel) combo.getModel()).removeElement(b);
- setModified(true);
-}
-
-/**
- * Transfert the {@code b} data from list to combo box.
- *
- * @param bs the data to transfert
- */
-protected void transfertToCombo(B[] bs) {
- for (B b : bs) {
- ((DefaultListModel) list.getModel()).removeElement(b);
- ((DefaultComboBoxModel) combo.getModel()).addElement(b);
- }
- setModified(true);
-}
-
-/**
- * @param enabled databinding
- * @return {@code true} if add button should be enabled
- */
-protected boolean updateAddEnabled(boolean enabled) {
- return enabled && combo.getModel().getSize() > 0;
-}
-
-/**
- * @param enabled databinding
- * @return {@code true} if remove button should be enabled
- */
-protected boolean updateRemoveEnabled(boolean enabled) {
- return enabled && list.getModel().getSize() > 0;
-}
-
-/**
- * Set the data in combo box model.
- *
- * @param toCombo datas to set in combo box model
- */
-protected void setComboDatas(java.util.List<B> toCombo) {
- SwingUtil.fillComboBox(combo, toCombo, null);
- //Note : there is a case when combo was selected, then come here with an empty
- // combo model : no propertyChanged is fired, so add button stays enabled...
- processDataBinding("add.enabled");
-}
-
-/**
- * Set the data in the list model.
- *
- * @param toList datas to set in list model
- */
-protected void setListDatas(java.util.List<B> toList) {
- SwingUtil.fillList(list, toList, null);
-}
-
]]>
</script>
@@ -176,7 +80,7 @@
enabled='{isEnabled()}'
model='{new DefaultListModel()}'
font-size='11'
- onMouseClicked='if (event.getClickCount()==2) { transfertToCombo((B[]) list.getSelectedValues()); }'
+ onMouseClicked='if (event.getClickCount()==2) { handler.transfertToCombo((B[]) list.getSelectedValues()); }'
cellRenderer='{getRenderer()}'/>
</JPanel>
@@ -194,14 +98,14 @@
<JButton id="add"
toolTipText='{getAddToListTip()}'
actionIcon='add'
- enabled='{updateAddEnabled(combo.isEnabled() && combo.getSelectedIndex() > -1)}'
- onActionPerformed='transfertToList((B) combo.getSelectedItem());'/>
+ enabled='{handler.updateAddEnabled(combo.isEnabled() && combo.getSelectedIndex() > -1)}'
+ onActionPerformed='handler.transfertToList((B) combo.getSelectedItem());'/>
<JButton id="remove"
toolTipText='{getAddToComboTip()}'
actionIcon='remove'
- enabled='{updateRemoveEnabled(list.isEnabled() && list.getSelectedIndex() > -1)}'
- onActionPerformed='transfertToCombo((B[]) list.getSelectedValues())'/>
+ enabled='{handler.updateRemoveEnabled(list.isEnabled() && list.getSelectedIndex() > -1)}'
+ onActionPerformed='handler.transfertToCombo((B[]) list.getSelectedValues())'/>
<HidorButton id="hidor"
target='{list}'
1
0
Author: tchemit
Date: 2010-10-03 17:50:46 +0200 (Sun, 03 Oct 2010)
New Revision: 2102
Url: http://nuiton.org/repositories/revision/jaxx/2102
Log:
Update mavenpom4redmineAndCentral to 2.3.
Modified:
trunk/pom.xml
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2010-09-30 08:06:27 UTC (rev 2101)
+++ trunk/pom.xml 2010-10-03 15:50:46 UTC (rev 2102)
@@ -33,8 +33,8 @@
<parent>
<groupId>org.nuiton</groupId>
- <artifactId>mavenpom4redmine</artifactId>
- <version>2.2.6</version>
+ <artifactId>mavenpom4redmineAndCentral</artifactId>
+ <version>2.3</version>
</parent>
<artifactId>jaxx</artifactId>
@@ -443,14 +443,6 @@
<javahelp.version>2.0.02</javahelp.version>
<jnlp.version>1.0-alpha-2-cl_20100511</jnlp.version>
- <!-- release config -->
-
- <!-- activate this profile while doing release:prepare -->
- <arguments>-DperformRelease -Pcentral-safe</arguments>
-
- <!-- activate this profile while doing release:perform -->
- <releaseProfiles>central-safe</releaseProfiles>
-
</properties>
<build>
1
0