From tchemit@users.nuiton.org Tue Jul 31 17:18:20 2012 From: tchemit@users.nuiton.org To: jaxx-commits@list.nuiton.org Subject: [Jaxx-commits] r2460 - trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config Date: Tue, 31 Jul 2012 17:18:20 +0200 Message-ID: <20120731151820.DC4CD162DF@nuiton.codelutin.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="===============2462596418627349134==" --===============2462596418627349134== Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Author: tchemit Date: 2012-07-31 17:18:20 +0200 (Tue, 31 Jul 2012) New Revision: 2460 Url: http://nuiton.org/repositories/revision/jaxx/2460 Log: fixes #2217: Improve ConfigCategoryUI Added: trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/ConfigCa= tegoryUIHandler.java Modified: trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/ConfigCa= llBackUI.jaxx trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/ConfigCa= tegoryUI.jaxx Modified: trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/C= onfigCallBackUI.jaxx =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/ConfigC= allBackUI.jaxx 2012-07-31 13:57:54 UTC (rev 2459) +++ trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/ConfigC= allBackUI.jaxx 2012-07-31 15:18:20 UTC (rev 2460) @@ -24,10 +24,6 @@ --> =20 - - =20 @@ -97,14 +56,12 @@ javaBean=3D'getContextValue(CategoryModel.class)'/> =20 + onTableChanged=3D'handler.updateDescriptionText()'/> =20 + onValueChanged=3D'if (!event.getValueIsAdjusting()) {h= andler.updateDescriptionText(); }'/> =20 - - Added: trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/Conf= igCategoryUIHandler.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/ConfigC= ategoryUIHandler.java (rev 0) +++ trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/ConfigC= ategoryUIHandler.java 2012-07-31 15:18:20 UTC (rev 2460) @@ -0,0 +1,112 @@ +package jaxx.runtime.swing.editor.config; +/* + * #%L + * JAXX :: Widgets + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2008 - 2012 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=20 + * published by the Free Software Foundation, either version 3 of the=20 + * License, or (at your option) any later version. + *=20 + * 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. + *=20 + * You should have received a copy of the GNU General Lesser Public=20 + * License along with this program. If not, see + * . + * #L% + */ + +import jaxx.runtime.SwingUtil; +import jaxx.runtime.swing.editor.config.model.ConfigTableModel; +import jaxx.runtime.swing.editor.config.model.OptionModel; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +import javax.swing.JTable; +import javax.swing.JTextArea; +import javax.swing.ListSelectionModel; +import java.awt.Font; + +import static org.nuiton.i18n.I18n._; +import static org.nuiton.i18n.I18n.n_; + +/** + * Handler of {@link ConfigCategoryUI}. + * + * @author tchemit + * @since 2.5.4 + */ +public class ConfigCategoryUIHandler { + + /** Logger. */ + private static final Log log =3D + LogFactory.getLog(ConfigCategoryUIHandler.class); + + private final ConfigCategoryUI ui; + + public ConfigCategoryUIHandler(ConfigCategoryUI ui) { + this.ui =3D ui; + } + + public void init() { + + JTable table =3D ui.getTable(); + + // prepare table + SwingUtil.setI18nTableHeaderRenderer( + table, + n_("config.key"), + n_("config.key.tip"), + n_("config.value"), + n_("config.value.tip"), + n_("config.defaultValue"), + n_("config.defaultValue.tip")); + + ConfigTableRenderer renderer =3D new ConfigTableRenderer(); + SwingUtil.setTableColumnRenderer(table, 0, renderer); + SwingUtil.setTableColumnRenderer(table, 1, renderer); + SwingUtil.setTableColumnRenderer(table, 2, renderer); + Font f =3D table.getFont().deriveFont(Font.ITALIC | Font.BOLD); + int width =3D SwingUtil.computeTableColumnWidth(table, f, 0, "___*"); + SwingUtil.fixTableColumnWidth(table, 0, width); + SwingUtil.setTableColumnEditor(table, 1, new ConfigTableEditor((Conf= igTableModel) table.getModel())); + } + + public void updateDescriptionText() { + OptionModel option; + JTable table =3D ui.getTable(); + JTextArea description =3D ui.getDescription(); + ListSelectionModel selectionModel =3D ui.getSelectionModel(); + + if (selectionModel.isSelectionEmpty()) { + option =3D null; + } else { + int row =3D selectionModel.getAnchorSelectionIndex(); + ConfigTableModel m =3D (ConfigTableModel) table.getModel(); + option =3D m.getEntry(row); + if (log.isDebugEnabled()) { + log.debug(row + " : " + option); + } + } + StringBuilder buffer =3D new StringBuilder(); + if (option =3D=3D null) { + buffer.append(_("config.no.option.selected")); + } else { + buffer.append(_("config.option.label", option.getKey(), _(option= .getDescription()))).append('\n'); + if (option.isModified()) { + buffer.append(_("config.option.modified", option.getOriginal= Value(), option.getValue())).append('\n'); + } + if (option.isFinal()) { + buffer.append(_("config.option.final")).append('\n'); + } + } + description.setText(buffer.toString()); + } +} Property changes on: trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/edit= or/config/ConfigCategoryUIHandler.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native --===============2462596418627349134==--