This is an automated email from the git hooks/post-receive script. New commit to branch develop in repository observe. See https://gitlab.nuiton.org/codelutin/observe.git commit 37d9dc98c353e6ac03a4d11f2fe22c694210baf6 Author: Tony CHEMIT <chemit@codelutin.com> Date: Sun Sep 4 19:29:35 2016 +0200 Improve show technical informations (make text selectable) --- .../ui/content/ref/ContentReferenceUIHandler.java | 109 +++++++++++++-------- .../ui/content/ref/ContentReferenceUIModel.java | 47 ++++----- 2 files changed, 90 insertions(+), 66 deletions(-) diff --git a/application-swing/src/main/java/fr/ird/observe/application/swing/ui/content/ref/ContentReferenceUIHandler.java b/application-swing/src/main/java/fr/ird/observe/application/swing/ui/content/ref/ContentReferenceUIHandler.java index 632f1fc..4e630d6 100644 --- a/application-swing/src/main/java/fr/ird/observe/application/swing/ui/content/ref/ContentReferenceUIHandler.java +++ b/application-swing/src/main/java/fr/ird/observe/application/swing/ui/content/ref/ContentReferenceUIHandler.java @@ -22,11 +22,18 @@ package fr.ird.observe.application.swing.ui.content.ref; import fr.ird.observe.application.swing.ObserveSwingApplicationContext; +import fr.ird.observe.application.swing.db.DataContext; +import fr.ird.observe.application.swing.db.ObserveSwingDataSource; import fr.ird.observe.application.swing.decoration.DecoratorService; import fr.ird.observe.application.swing.decoration.ObserveI18nDecoratorHelper; import fr.ird.observe.application.swing.decoration.decorators.ReferentialReferenceDecorator; -import fr.ird.observe.application.swing.db.DataContext; -import fr.ird.observe.application.swing.db.ObserveSwingDataSource; +import fr.ird.observe.application.swing.ui.UIHelper; +import fr.ird.observe.application.swing.ui.content.ContentMode; +import fr.ird.observe.application.swing.ui.content.ContentUIHandler; +import fr.ird.observe.application.swing.ui.tree.ObserveTreeHelper; +import fr.ird.observe.application.swing.ui.usage.UsagesUI; +import fr.ird.observe.application.swing.ui.util.SpringUtilities; +import fr.ird.observe.application.swing.validation.ValidationContext; import fr.ird.observe.services.dto.Form; import fr.ird.observe.services.dto.IdDto; import fr.ird.observe.services.dto.ReferenceMap; @@ -41,13 +48,6 @@ import fr.ird.observe.services.dto.referential.VesselSizeCategoryDto; import fr.ird.observe.services.dto.result.SaveResultDto; import fr.ird.observe.services.service.DataNotFoundException; import fr.ird.observe.services.service.ReferentialService; -import fr.ird.observe.application.swing.ui.UIHelper; -import fr.ird.observe.application.swing.ui.content.ContentMode; -import fr.ird.observe.application.swing.ui.content.ContentUIHandler; -import fr.ird.observe.application.swing.ui.tree.ObserveTreeHelper; -import fr.ird.observe.application.swing.ui.usage.UsagesUI; -import fr.ird.observe.application.swing.ui.util.SpringUtilities; -import fr.ird.observe.application.swing.validation.ValidationContext; import jaxx.runtime.JAXXContext; import jaxx.runtime.swing.CardLayout2Ext; import jaxx.runtime.swing.editor.bean.BeanListHeader; @@ -69,6 +69,7 @@ import javax.swing.JPanel; import javax.swing.JPopupMenu; import javax.swing.JScrollPane; import javax.swing.JTable; +import javax.swing.JTextField; import javax.swing.JToolBar; import javax.swing.RowSorter; import javax.swing.SortOrder; @@ -79,6 +80,8 @@ import javax.swing.table.DefaultTableCellRenderer; import java.awt.Container; import java.awt.Dimension; import java.awt.Font; +import java.awt.event.FocusEvent; +import java.awt.event.FocusListener; import java.beans.Introspector; import java.util.ArrayList; import java.util.Collection; @@ -136,9 +139,9 @@ public class ContentReferenceUIHandler<E extends ReferentialDto> extends Content }; } - public static <E extends IdDto> void showUsagesForDelete(JAXXContext tx, - E entity, - ReferenceMap usages) { + private static <E extends IdDto> void showUsagesForDelete(JAXXContext tx, + E entity, + ReferenceMap usages) { DecoratorService service = ObserveSwingApplicationContext.get().getDecoratorService(); Decorator<?> decorator = service.getDecoratorByType(entity.getClass()); @@ -159,9 +162,9 @@ public class ContentReferenceUIHandler<E extends ReferentialDto> extends Content 0); } - public static <E extends IdDto> boolean showUsagesForDesactivated(JAXXContext tx, - E entity, - ReferenceMap usages) { + private static <E extends IdDto> boolean showUsagesForDesactivated(JAXXContext tx, + E entity, + ReferenceMap usages) { DecoratorService service = ObserveSwingApplicationContext.get().getDecoratorService(); Decorator<?> decorator = service.getDecoratorByType(entity.getClass()); @@ -246,7 +249,7 @@ public class ContentReferenceUIHandler<E extends ReferentialDto> extends Content * * @param button le boutton qui a declanche l'action */ - public void showUniqueKeys(JButton button) { + void showUniqueKeys(JButton button) { Class<E> beanType = getBeanType(); Set<ReferentialReference<E>> entities = getDataSource().getReferentialReferences(beanType); @@ -314,11 +317,9 @@ public class ContentReferenceUIHandler<E extends ReferentialDto> extends Content getUi().decorateUniqueKeyTable(table, new DefaultTableCellRenderer(), pane); pane.setViewportView(table); - pane.setVerticalScrollBarPolicy( - JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED); + pane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED); - String title = t("observe.title.unique.key", - t(ObserveI18nDecoratorHelper.getTypeI18nKey(beanType))); + String title = t("observe.title.unique.key", t(ObserveI18nDecoratorHelper.getTypeI18nKey(beanType))); pane.setBorder(new TitledBorder(title)); @@ -332,7 +333,7 @@ public class ContentReferenceUIHandler<E extends ReferentialDto> extends Content popup.show(button, x, y); } - public void showUsages() { + void showUsages() { E bean; @@ -376,32 +377,62 @@ public class ContentReferenceUIHandler<E extends ReferentialDto> extends Content * * @param button le boutton qui a declanche l'action */ - public void showTechnicalInformations(JButton button) { + void showTechnicalInformations(JButton button) { ReferentialDto bean = getModel().isEditing() ? getBean() : getModel().getSelectedBean(); JPanel content = new JPanel(new SpringLayout()); - content.add(new JLabel(t("observe.common.topiaId"))); - content.add(new JLabel(bean.getId())); + FocusListener l = new FocusListener() { + @Override + public void focusGained(FocusEvent e) { + JTextField source = (JTextField) e.getSource(); + source.setSelectionStart(0); + source.setSelectionEnd(source.getText().length()); + } - content.add(new JLabel(t("observe.common.topiaCreateDate"))); + @Override + public void focusLost(FocusEvent e) { - content.add(new JLabel(dateFormat.format(bean.getCreateDate()))); + } + }; - content.add(new JLabel(t("observe.common.lastUpdateDate"))); + { + content.add(new JLabel(t("observe.common.topiaId"))); + JTextField comp = new JTextField(bean.getId()); + comp.setEditable(false); + comp.addFocusListener(l); + content.add(comp); + } + { + content.add(new JLabel(t("observe.common.topiaCreateDate"))); + JTextField comp = new JTextField(dateFormat.format(bean.getCreateDate())); + comp.setEditable(false); + comp.addFocusListener(l); + content.add(comp); + } - content.add(new JLabel(dateFormat.format(bean.getLastUpdateDate()))); + { + content.add(new JLabel(t("observe.common.lastUpdateDate"))); + JTextField comp = new JTextField(dateFormat.format(bean.getLastUpdateDate())); + comp.setEditable(false); + comp.addFocusListener(l); + content.add(comp); + } - content.add(new JLabel(t("observe.common.topiaVersion"))); - content.add(new JLabel(String.valueOf(bean.getVersion()))); + { + content.add(new JLabel(t("observe.common.topiaVersion"))); + JTextField comp = new JTextField(String.valueOf(bean.getVersion())); + comp.setEditable(false); + comp.addFocusListener(l); + content.add(comp); + } SpringUtilities.makeCompactGrid(content, 4, 2, 5, 5, 5, 5); Decorator<E> decorator = getDecoratorService().getDecoratorByType(getBeanType()); - String title = t("observe.title.technical.informations", - "\n" + decorator.toString(bean)); + String title = t("observe.title.technical.informations", "\n" + decorator.toString(bean)); content.setBorder(new TitledBorder(title)); @@ -578,7 +609,7 @@ public class ContentReferenceUIHandler<E extends ReferentialDto> extends Content // return super.closeUI(); // } - public final void createUI() { + void createUI() { ContentReferenceUI<E> ui = getUi(); @@ -595,7 +626,7 @@ public class ContentReferenceUIHandler<E extends ReferentialDto> extends Content ui.startEdit(null); } - public void modifyUI() { + void modifyUI() { ContentReferenceUIModel<E> model = getModel(); if (model.getMode() != ContentMode.READ) { @@ -640,7 +671,7 @@ public class ContentReferenceUIHandler<E extends ReferentialDto> extends Content } } - public void backToList() { + void backToList() { ContentReferenceUIModel<E> model = getModel(); if (!model.isModified() || checkEdit(getUi())) { getUi().stopEdit(); @@ -806,23 +837,23 @@ public class ContentReferenceUIHandler<E extends ReferentialDto> extends Content return incomingReferences; } - public boolean canSeeI18nTable(E bean) { + boolean canSeeI18nTable(E bean) { return bean instanceof I18nReferentialDto || bean instanceof VesselSizeCategoryDto; } - public String updateView(boolean editing) { + String updateView(boolean editing) { if (log.isDebugEnabled()) { log.debug("Editing has changed : " + editing); } return editing ? ContentReferenceUI.DETAIL_VIEW : ContentReferenceUI.LIST_VIEW; } - protected void copyIntoBean(E source, E target) { + private void copyIntoBean(E source, E target) { Binder<E, E> binder = BinderFactory.newBinder(getBeanType()); binder.copy(source, target); } - protected ReferentialService getReferentialService() { + private ReferentialService getReferentialService() { return ObserveSwingApplicationContext.get().getMainDataSourceServicesProvider().newReferentialService(); } diff --git a/application-swing/src/main/java/fr/ird/observe/application/swing/ui/content/ref/ContentReferenceUIModel.java b/application-swing/src/main/java/fr/ird/observe/application/swing/ui/content/ref/ContentReferenceUIModel.java index e455b69..b564b9d 100644 --- a/application-swing/src/main/java/fr/ird/observe/application/swing/ui/content/ref/ContentReferenceUIModel.java +++ b/application-swing/src/main/java/fr/ird/observe/application/swing/ui/content/ref/ContentReferenceUIModel.java @@ -21,12 +21,10 @@ */ package fr.ird.observe.application.swing.ui.content.ref; +import fr.ird.observe.application.swing.ui.content.ContentUIModel; import fr.ird.observe.services.dto.referential.I18nReferentialDto; import fr.ird.observe.services.dto.referential.LengthWeightParameterDto; import fr.ird.observe.services.dto.referential.ReferentialDto; -import fr.ird.observe.application.swing.ui.content.ContentUIModel; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; import java.util.ArrayList; import java.util.Arrays; @@ -40,24 +38,22 @@ import java.util.List; */ public abstract class ContentReferenceUIModel<E extends ReferentialDto> extends ContentUIModel<E> { - public static final String PROPERTY_EMPTY = "empty"; + private static final String PROPERTY_SELECTED_BEAN = "selectedBean"; - public static final String PROPERTY_SELECTED_BEAN = "selectedBean"; + protected static final String SUFFIX_TEXT = ".text"; - public static final String SUFFIX_TEXT = ".text"; + protected static final String SUFFIX_MODEL = ".model"; - public static final String SUFFIX_MODEL = ".model"; + private static final String SUFFIX_SELECTED_INDEX = ".selectedIndex"; - public static final String SUFFIX_SELECTED_INDEX = ".selectedIndex"; + protected static final String SUFFIX_SELECTED_ITEM = ".selectedItem"; - public static final String SUFFIX_SELECTED_ITEM = ".selectedItem"; + protected static final String SUFFIX_SELECTED = ".selected"; - public static final String SUFFIX_SELECTED = ".selected"; - - public static final String SUFFIX_DATE = ".date"; + private static final String SUFFIX_DATE = ".date"; /** liste des bindings present sur tous les ecrans du referentiel */ - protected final static String[] DEFAULT_DATABINDING = { + private final static String[] DEFAULT_DATABINDING = { ReferentialDto.PROPERTY_CODE + SUFFIX_TEXT, ReferentialDto.PROPERTY_URI + SUFFIX_TEXT, ReferentialDto.PROPERTY_STATUS + SUFFIX_SELECTED_INDEX, @@ -65,7 +61,7 @@ public abstract class ContentReferenceUIModel<E extends ReferentialDto> extends }; /** liste des proprietes presents sur les entites parametrageLengthWeightAble */ - protected final static String[] DEFAULT_LENGTH_WEIGHT_PARAMETER_ABLE_DATABINDING = { + private final static String[] DEFAULT_LENGTH_WEIGHT_PARAMETER_ABLE_DATABINDING = { LengthWeightParameterDto.PROPERTY_START_DATE + SUFFIX_DATE, LengthWeightParameterDto.PROPERTY_END_DATE + SUFFIX_DATE, LengthWeightParameterDto.PROPERTY_SPECIES + SUFFIX_SELECTED_ITEM, @@ -79,7 +75,7 @@ public abstract class ContentReferenceUIModel<E extends ReferentialDto> extends }; /** liste des bindings presents sur les entites i18n */ - protected final static String[] DEFAULT_I18N_DATABINDING = { + private final static String[] DEFAULT_I18N_DATABINDING = { I18nReferentialDto.PROPERTY_LABEL1 + SUFFIX_TEXT, I18nReferentialDto.PROPERTY_LABEL2 + SUFFIX_TEXT, I18nReferentialDto.PROPERTY_LABEL3 + SUFFIX_TEXT, @@ -91,7 +87,7 @@ public abstract class ContentReferenceUIModel<E extends ReferentialDto> extends }; /** liste des proprietes present sur tous les ecrans du referentiel */ - protected final static String[] DEFAULT_PROPERTIES = { + final static String[] DEFAULT_PROPERTIES = { ReferentialDto.PROPERTY_CODE, ReferentialDto.PROPERTY_URI, ReferentialDto.PROPERTY_STATUS, @@ -99,7 +95,7 @@ public abstract class ContentReferenceUIModel<E extends ReferentialDto> extends }; /** liste des proprietes presents sur les entites taillePoidsAble */ - protected final static String[] DEFAULT_PARAMETRAGE_TAILLE_POIDS_ABLE_PROPERTIES = { + private final static String[] DEFAULT_PARAMETRAGE_TAILLE_POIDS_ABLE_PROPERTIES = { LengthWeightParameterDto.PROPERTY_START_DATE, LengthWeightParameterDto.PROPERTY_END_DATE, LengthWeightParameterDto.PROPERTY_OCEAN, @@ -113,7 +109,7 @@ public abstract class ContentReferenceUIModel<E extends ReferentialDto> extends }; /** liste des proprietes presents sur les entites i18n */ - protected final static String[] DEFAULT_I18N_PROPERTIES = { + private final static String[] DEFAULT_I18N_PROPERTIES = { I18nReferentialDto.PROPERTY_LABEL1, I18nReferentialDto.PROPERTY_LABEL2, I18nReferentialDto.PROPERTY_LABEL3, @@ -126,19 +122,16 @@ public abstract class ContentReferenceUIModel<E extends ReferentialDto> extends private static final long serialVersionUID = 1L; - /** Logger. */ - private static final Log log = LogFactory.getLog(ContentReferenceUIModel.class); - /** la liste des propriétés du bean a charger */ - protected final String[] properties; + private final String[] properties; /** la liste des propriétés faisant partie de la clef metier */ - protected final String[] naturalIds; + private final String[] naturalIds; /** la liste des bindings à activer lors de l'ouverture de l'ui */ - protected final String[] dataBinding; + private final String[] dataBinding; - protected E selectedBean; + private E selectedBean; protected ContentReferenceUIModel(Class<E> beanType) { @@ -200,7 +193,7 @@ public abstract class ContentReferenceUIModel<E extends ReferentialDto> extends * celles communes * @return la liste des toutes les proprietes utilises sur l'entite edite dans l'ui */ - protected final List<String> buildProperties(boolean usedefault, String[] properties) { + private final List<String> buildProperties(boolean usedefault, String[] properties) { List<String> result = new ArrayList<>(); result.addAll(Arrays.asList(DEFAULT_PROPERTIES)); @@ -232,7 +225,7 @@ public abstract class ContentReferenceUIModel<E extends ReferentialDto> extends * ceux communs * @return la liste de tous les databindings utilises sur l'entite edite dans l'ui */ - protected final List<String> buildDataBindings(boolean usedefault, String[] dataBinding) { + private final List<String> buildDataBindings(boolean usedefault, String[] dataBinding) { List<String> result = new ArrayList<>(); result.addAll(Arrays.asList(DEFAULT_DATABINDING)); -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@codelutin.com>.