diff --git a/.classpath b/.classpath index e3c5b1bf15263a98db881ffda852ed6999dd0810..5809bd113511e3ad39d66415ea92d201aaa220a3 100644 --- a/.classpath +++ b/.classpath @@ -1,8 +1,9 @@ <?xml version="1.0" encoding="UTF-8"?> <classpath> <classpathentry kind="src" output="target/classes" path="src/main/java"/> - <classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources"/> - <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> + <classpathentry excluding="**" including="**/*.java" kind="src" output="target/classes" path="src/main/resources"/> + <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/> + <classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER"/> <classpathentry kind="con" path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER"/> <classpathentry kind="output" path="target/classes"/> </classpath> diff --git a/.project b/.project index 4b5bdf7e68a4335d160ed4eafb1ee54c3275929c..953fe65f42a30373cf348c5356f62d735c9bac48 100644 --- a/.project +++ b/.project @@ -27,8 +27,14 @@ <arguments> </arguments> </buildCommand> + <buildCommand> + <name>org.eclipse.m2e.core.maven2Builder</name> + <arguments> + </arguments> + </buildCommand> </buildSpec> <natures> + <nature>org.eclipse.m2e.core.maven2Nature</nature> <nature>org.maven.ide.eclipse.maven2Nature</nature> <nature>org.devzuz.q.maven.jdt.core.mavenNature</nature> <nature>org.eclipse.jdt.core.javanature</nature> diff --git a/Bensikin.launch b/Bensikin.launch index 73864ebf367a918abd64a835e963ee851a92057f..f26615446b0a7da1d628e9d2b7e08237b2bcaafc 100644 --- a/Bensikin.launch +++ b/Bensikin.launch @@ -11,10 +11,10 @@ <listEntry value="org.eclipse.debug.ui.launchGroup.debug"/> <listEntry value="org.eclipse.debug.ui.launchGroup.run"/> </listAttribute> -<stringAttribute key="org.eclipse.jdt.launching.CLASSPATH_PROVIDER" value="org.maven.ide.eclipse.launchconfig.classpathProvider"/> +<stringAttribute key="org.eclipse.jdt.launching.CLASSPATH_PROVIDER" value="org.eclipse.m2e.launchconfig.classpathProvider"/> <stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="fr.soleil.bensikin.Bensikin"/> -<stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS" value="d:\BensikinMySql snapmanager snapmanager expert"/> +<stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS" value="snap snap expert"/> <stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="bensikinArchivingGUI"/> -<stringAttribute key="org.eclipse.jdt.launching.SOURCE_PATH_PROVIDER" value="org.maven.ide.eclipse.launchconfig.sourcepathProvider"/> -<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-DTANGO_HOST=RAMEAU.synchrotron-soleil.fr:20000"/> +<stringAttribute key="org.eclipse.jdt.launching.SOURCE_PATH_PROVIDER" value="org.eclipse.m2e.launchconfig.sourcepathProvider"/> +<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-DTANGO_HOST=calypso:20001 -Dfr.soleil.archiving.directory=D:\Archiving\Bensikin -DSNAP_RAC=false -DSNAP_HOST=SAIPH -DSNAP_NAME=TEST11"/> </launchConfiguration> diff --git a/pom.xml b/pom.xml index 7ce85b317e6c202eeec9559bae3270eb84940f9b..b96c8a0a89d284f32a9105dd16f29823094e56ac 100644 --- a/pom.xml +++ b/pom.xml @@ -9,7 +9,7 @@ </parent> <groupId>fr.soleil.gui</groupId> <artifactId>bensikinArchivingGUI</artifactId> - <version>1.6.20-SNAPSHOT</version> + <version>1.6.21</version> <name>Bensikin</name> <developers> <developer> diff --git a/src/main/java/fr/soleil/bensikin/actions/listeners/SnapshotCompareTableHeaderListener.java b/src/main/java/fr/soleil/bensikin/actions/listeners/SnapshotCompareTableHeaderListener.java index e6c83efa662e33184b12ea0fa9c2ec5a9b9fa489..ed91442eda8c3f4d36ce30cc71ff8d689f6fea14 100644 --- a/src/main/java/fr/soleil/bensikin/actions/listeners/SnapshotCompareTableHeaderListener.java +++ b/src/main/java/fr/soleil/bensikin/actions/listeners/SnapshotCompareTableHeaderListener.java @@ -20,31 +20,33 @@ import fr.soleil.bensikin.models.SnapshotCompareTableModel; * @author CLAISSE */ public class SnapshotCompareTableHeaderListener extends MouseAdapter { - private SnapshotCompareTableModel model; - - /** - * Does nothing - */ - public SnapshotCompareTableHeaderListener(SnapshotCompareTableModel _model) { - this.model = _model; + private final SnapshotCompareTableModel model; + + /** + * Does nothing + */ + public SnapshotCompareTableHeaderListener(SnapshotCompareTableModel _model) { + this.model = _model; + } + + /* + * (non-Javadoc) + * + * @see java.awt.event.MouseListener#mousePressed(java.awt.event.MouseEvent) + */ + @Override + public void mousePressed(MouseEvent event) { + int clickCount = event.getClickCount(); + if (clickCount == 1) { + return; + // so that the use can resize columns } - /* - * (non-Javadoc) - * - * @see java.awt.event.MouseListener#mousePressed(java.awt.event.MouseEvent) - */ - public void mousePressed(MouseEvent event) { - int clickCount = event.getClickCount(); - if (clickCount == 1) { - return; - // so that the use can resize columns - } - - Point point = event.getPoint(); - JTableHeader header = (JTableHeader) event.getSource(); - int clickedColunIndex = header.columnAtPoint(point); - - this.model.sort(clickedColunIndex); - } + Point point = event.getPoint(); + JTableHeader header = (JTableHeader) event.getSource(); + int clickedColunIndex = header.columnAtPoint(point); + + // this.model.sort(clickedColunIndex); + + } } diff --git a/src/main/java/fr/soleil/bensikin/actions/listeners/SnapshotDetailTableHeaderListener.java b/src/main/java/fr/soleil/bensikin/actions/listeners/SnapshotDetailTableHeaderListener.java index 7745c9df80e343adcedb334064c2aea325d0df41..e93d54741060ea7d7a2f04f2234e3fa8b1478043 100644 --- a/src/main/java/fr/soleil/bensikin/actions/listeners/SnapshotDetailTableHeaderListener.java +++ b/src/main/java/fr/soleil/bensikin/actions/listeners/SnapshotDetailTableHeaderListener.java @@ -20,31 +20,33 @@ import fr.soleil.bensikin.models.SnapshotDetailTableModel; * @author CLAISSE */ public class SnapshotDetailTableHeaderListener extends MouseAdapter { - private SnapshotDetailTableModel model; - - /** - * Does nothing - */ - public SnapshotDetailTableHeaderListener(SnapshotDetailTableModel _model) { - this.model = _model; + private final SnapshotDetailTableModel model; + + /** + * Does nothing + */ + public SnapshotDetailTableHeaderListener(SnapshotDetailTableModel _model) { + this.model = _model; + } + + /* + * (non-Javadoc) + * + * @see java.awt.event.MouseListener#mousePressed(java.awt.event.MouseEvent) + */ + @Override + public void mousePressed(MouseEvent event) { + int clickCount = event.getClickCount(); + if (clickCount == 1) { + return; + // so that the use can resize columns } - /* - * (non-Javadoc) - * - * @see java.awt.event.MouseListener#mousePressed(java.awt.event.MouseEvent) - */ - public void mousePressed(MouseEvent event) { - int clickCount = event.getClickCount(); - if (clickCount == 1) { - return; - // so that the use can resize columns - } - - Point point = event.getPoint(); - JTableHeader header = (JTableHeader) event.getSource(); - int clickedColunIndex = header.columnAtPoint(point); - - this.model.sort(clickedColunIndex); - } + Point point = event.getPoint(); + JTableHeader header = (JTableHeader) event.getSource(); + int clickedColunIndex = header.columnAtPoint(point); + + // this.model.sort(clickedColunIndex); + + } } diff --git a/src/main/java/fr/soleil/bensikin/components/snapshot/detail/SnapshotDetailTable.java b/src/main/java/fr/soleil/bensikin/components/snapshot/detail/SnapshotDetailTable.java index a8991276bd65f60575ba28f72c0072c9e3d9c16e..d8f4fe85812880a4a6d2ab6a6fddef25488e9d7e 100644 --- a/src/main/java/fr/soleil/bensikin/components/snapshot/detail/SnapshotDetailTable.java +++ b/src/main/java/fr/soleil/bensikin/components/snapshot/detail/SnapshotDetailTable.java @@ -55,8 +55,11 @@ package fr.soleil.bensikin.components.snapshot.detail; import java.util.HashMap; +import javax.swing.DefaultRowSorter; import javax.swing.JCheckBox; import javax.swing.JTable; +import javax.swing.RowSorter; +import javax.swing.SortOrder; import javax.swing.table.JTableHeader; import javax.swing.table.TableModel; @@ -72,6 +75,7 @@ import fr.soleil.bensikin.components.renderers.SnapshotDetailRenderer; import fr.soleil.bensikin.components.renderers.SortedTableHeaderRenderer; import fr.soleil.bensikin.data.snapshot.Snapshot; import fr.soleil.bensikin.data.snapshot.SnapshotAttributeValue; +import fr.soleil.bensikin.data.snapshot.SnapshotAttributeValue.SnapshotValueComparator; import fr.soleil.bensikin.data.snapshot.SnapshotAttributeWriteValue; import fr.soleil.bensikin.models.SnapshotDetailTableModel; import fr.soleil.bensikin.models.SnapshotDetailTableModel.SnapshotColumns; @@ -95,6 +99,12 @@ public class SnapshotDetailTable extends JXTable { private boolean showCanSet; private boolean showAbsValues; + /** + * The comparator used with columns having a {@link SnapshotAttributeValue} + * object to handle + */ + private final SnapshotValueComparator comparator; + /** * Builds its model from the given snapshot, makes the 1st column the same * color as the header, and adds a cell renderer and editor to itself. @@ -104,21 +114,22 @@ public class SnapshotDetailTable extends JXTable { */ public SnapshotDetailTable(Snapshot snapshot) { super(); - setSortable(false);// for the JXTable not to interact with the sort + // setSortable(false);// for the JXTable not to interact with the sort // mechanism already in place + comparator = new SnapshotValueComparator(); this.snapshot = snapshot; initialize(); } protected void initialize() { - //gives each column its identifier + // gives each column its identifier setColumnFactory(new ColumnFactory() { private final SnapshotColumns[] columns = SnapshotColumns.values(); @Override public void configureTableColumn(TableModel model, TableColumnExt columnExt) { super.configureTableColumn(model, columnExt); - //follow the enum order! + // follow the enum order! columnExt.setIdentifier(columns[columnExt.getModelIndex()]); } }); @@ -127,12 +138,26 @@ public class SnapshotDetailTable extends JXTable { initializeRenderer(); initializeEditor(); initializeTableColumns(); + initializeSortModel(); this.setRowHeight(this.getRowHeight() + 2); this.addMouseListener(new SnapshotDetailTableListener()); // Do not allow column reordering because it has a bad impact on data // sorting - getTableHeader().setReorderingAllowed(false); + // getTableHeader().setReorderingAllowed(false); + } + + protected void initializeSortModel() { + setSortOrder(SnapshotColumns.NAME.ordinal(), SortOrder.ASCENDING); + RowSorter<?> rowSorter = getRowSorter(); + if (rowSorter instanceof DefaultRowSorter) { + for (int i = 0; i < getModel().getColumnCount(); ++i) { + String columnName = getModel().getColumnName(i); + if ((i != SnapshotColumns.NAME.ordinal()) && (i != SnapshotColumns.CAN_SET.ordinal())) { + ((DefaultRowSorter<?, ?>) rowSorter).setComparator(i, comparator); + } + } + } } protected void initializeTableColumns() { @@ -176,7 +201,8 @@ public class SnapshotDetailTable extends JXTable { /** * Allow to show or hide checkbox column. * - * @param showCanSet true to show the column, false to hide it + * @param showCanSet + * true to show the column, false to hide it */ public void setShowCanSet(boolean showCanSet) { this.showCanSet = showCanSet; @@ -195,7 +221,8 @@ public class SnapshotDetailTable extends JXTable { /** * Allow to show or hide absolute columns. * - * @param showAbsValues true to show the columns, false to hide it + * @param showAbsValues + * true to show the columns, false to hide it */ public void setShowAbsValues(boolean showAbsValues) { this.showAbsValues = showAbsValues; @@ -283,8 +310,8 @@ public class SnapshotDetailTable extends JXTable { * * @return */ - //TODO refactor to use columns id - //TODO this is specific to the print table! + // TODO refactor to use columns id + // TODO this is specific to the print table! public String toUserFriendlyString() { StringBuffer buffer = new StringBuffer(); int rowCount = getRowCount(); @@ -341,7 +368,7 @@ public class SnapshotDetailTable extends JXTable { int columnCount = 0; for (int col = 0; col < getColumnCount(); col++) { if (columnMap.get(col)) { - //only add separator before an item + // only add separator before an item if (columnCount > 0) { buffer.append(Options.getInstance().getSnapshotOptions().getCSVSeparator()); } diff --git a/src/main/java/fr/soleil/bensikin/containers/sub/dialogs/options/OptionsSaveOptionsTab.java b/src/main/java/fr/soleil/bensikin/containers/sub/dialogs/options/OptionsSaveOptionsTab.java index bd4fa9eab8a544acb135b85d8f8db81a8c60b983..5beaa67c7d93d0bf6797598fe612dd18e5232d91 100644 --- a/src/main/java/fr/soleil/bensikin/containers/sub/dialogs/options/OptionsSaveOptionsTab.java +++ b/src/main/java/fr/soleil/bensikin/containers/sub/dialogs/options/OptionsSaveOptionsTab.java @@ -35,13 +35,20 @@ import java.awt.GridBagConstraints; import java.awt.GridBagLayout; import java.awt.GridLayout; import java.awt.Insets; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; import javax.swing.Box; +import javax.swing.BoxLayout; import javax.swing.ButtonGroup; +import javax.swing.JCheckBox; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JRadioButton; +import javax.swing.border.EtchedBorder; +import javax.swing.border.TitledBorder; +import fr.soleil.archiving.gui.tools.GUIUtilities; import fr.soleil.bensikin.options.sub.SaveOptions; import fr.soleil.bensikin.tools.Messages; @@ -53,160 +60,258 @@ import fr.soleil.bensikin.tools.Messages; */ public class OptionsSaveOptionsTab extends JPanel { - private static final long serialVersionUID = -9212162249698224136L; + private static final long serialVersionUID = -9212162249698224136L; - private static OptionsSaveOptionsTab instance = null; + private static OptionsSaveOptionsTab instance = null; - private JRadioButton yesButton; - private JRadioButton noButton; - private JLabel label; - private ButtonGroup buttonGroup; + private JRadioButton saveHistoryYes; + private JRadioButton saveHistoryNo; + private JLabel label; + private ButtonGroup buttonHistoryGroup; - // private Dimension dim = new Dimension(300 , 300); - private JPanel myPanel; + private Box loadPropertiesBox; + // private JCheckBox contextOpenedCheckBox; + private JCheckBox contextSelectedCheckBox; + private JCheckBox snapshotsOpenedCheckBox; + private JCheckBox snapshotsSelectedCheckBox; - /** - * Instantiates itself if necessary, returns the instance. - * - * @return The instance - */ - public static OptionsSaveOptionsTab getInstance() { - if (instance == null) { - instance = new OptionsSaveOptionsTab(); - } + // private Dimension dim = new Dimension(300 , 300); + private JPanel myPanel; - return instance; + /** + * Instantiates itself if necessary, returns the instance. + * + * @return The instance + */ + public static OptionsSaveOptionsTab getInstance() { + if (instance == null) { + instance = new OptionsSaveOptionsTab(); } - /** - * Builds the tab. - */ - private OptionsSaveOptionsTab() { - this.initComponents(); - this.initLayout(); - this.addComponents(); - } + return instance; + } - /** - * Inits the tab's layout. - */ - private void initLayout() { - setLayout(new GridLayout()); - } + /** + * Builds the tab. + */ + private OptionsSaveOptionsTab() { + this.initComponents(); + this.initLayout(); + this.addComponents(); + } - /** - * Adds the initialized components to the tab. - */ - private void addComponents() { - myPanel = new JPanel(new GridBagLayout()); - - Insets gapInsets = new Insets(0, 0, 40, 0); - - JPanel buttonPanel = new JPanel(new GridBagLayout()); - - GridBagConstraints yesConstraints = new GridBagConstraints(); - yesConstraints.fill = GridBagConstraints.HORIZONTAL; - yesConstraints.gridx = 0; - yesConstraints.gridy = 0; - yesConstraints.weightx = 1; - yesConstraints.weighty = 0; - yesConstraints.insets = gapInsets; - buttonPanel.add(yesButton, yesConstraints); - GridBagConstraints noConstraints = new GridBagConstraints(); - noConstraints.fill = GridBagConstraints.HORIZONTAL; - noConstraints.gridx = 0; - noConstraints.gridy = 1; - noConstraints.weightx = 1; - noConstraints.weighty = 0; - buttonPanel.add(noButton, noConstraints); - - GridBagConstraints labelConstraints = new GridBagConstraints(); - labelConstraints.fill = GridBagConstraints.HORIZONTAL; - labelConstraints.gridx = 0; - labelConstraints.gridy = 0; - labelConstraints.weightx = 0.3; - labelConstraints.weighty = 0; - labelConstraints.insets = new Insets(10, 0, 0, 40); - labelConstraints.anchor = GridBagConstraints.EAST; - myPanel.add(label, labelConstraints); - GridBagConstraints buttonPanelConstraints = new GridBagConstraints(); - buttonPanelConstraints.fill = GridBagConstraints.HORIZONTAL; - buttonPanelConstraints.gridx = 1; - buttonPanelConstraints.gridy = 0; - buttonPanelConstraints.weightx = 0.7; - buttonPanelConstraints.weighty = 0; - buttonPanelConstraints.insets = new Insets(10, 0, 0, 0); - buttonPanelConstraints.anchor = GridBagConstraints.WEST; - myPanel.add(buttonPanel, buttonPanelConstraints); - - GridBagConstraints glueConstraints = new GridBagConstraints(); - glueConstraints.fill = GridBagConstraints.BOTH; - glueConstraints.gridx = 0; - glueConstraints.gridy = 1; - glueConstraints.weightx = 1; - glueConstraints.weighty = 1; - glueConstraints.gridwidth = GridBagConstraints.REMAINDER; - glueConstraints.gridheight = GridBagConstraints.REMAINDER; - myPanel.add(Box.createGlue(), glueConstraints); - - this.add(myPanel); - } + /** + * Inits the tab's layout. + */ + private void initLayout() { + setLayout(new GridLayout()); + } - /** - * Inits the tab's components. - */ - private void initComponents() { - buttonGroup = new ButtonGroup(); + /** + * Adds the initialized components to the tab. + */ + private void addComponents() { + myPanel = new JPanel(new GridBagLayout()); - String msgSaveHistoryOnShutdown = Messages - .getMessage("DIALOGS_OPTIONS_SAVE_SAVEONSHUTDOWN"); - String msgYes = Messages - .getMessage("DIALOGS_OPTIONS_SAVE_SAVEONSHUTDOWN_YES"); - String msgNo = Messages - .getMessage("DIALOGS_OPTIONS_SAVE_SAVEONSHUTDOWN_NO"); + Insets gapInsets = new Insets(0, 0, 40, 0); - label = new JLabel(msgSaveHistoryOnShutdown, JLabel.RIGHT); + JPanel buttonPanel = new JPanel(new GridBagLayout()); - yesButton = new JRadioButton(msgYes, true); - noButton = new JRadioButton(msgNo, true); + GridBagConstraints yesConstraints = new GridBagConstraints(); + yesConstraints.fill = GridBagConstraints.HORIZONTAL; + yesConstraints.gridx = 0; + yesConstraints.gridy = 0; + yesConstraints.weightx = 1; + yesConstraints.weighty = 0; + yesConstraints.insets = gapInsets; + buttonPanel.add(saveHistoryYes, yesConstraints); + GridBagConstraints noConstraints = new GridBagConstraints(); + noConstraints.fill = GridBagConstraints.HORIZONTAL; + noConstraints.gridx = 0; + noConstraints.gridy = 1; + noConstraints.weightx = 1; + noConstraints.weighty = 0; + buttonPanel.add(saveHistoryNo, noConstraints); - yesButton.setActionCommand(String.valueOf(SaveOptions.HISTORY_YES)); - noButton.setActionCommand(String.valueOf(SaveOptions.HISTORY_NO)); + GridBagConstraints labelConstraints = new GridBagConstraints(); + labelConstraints.fill = GridBagConstraints.HORIZONTAL; + labelConstraints.gridx = 0; + labelConstraints.gridy = 0; + labelConstraints.weightx = 0.3; + labelConstraints.weighty = 0; + labelConstraints.insets = new Insets(10, 0, 0, 40); + labelConstraints.anchor = GridBagConstraints.EAST; + myPanel.add(label, labelConstraints); + GridBagConstraints buttonPanelConstraints = new GridBagConstraints(); + buttonPanelConstraints.fill = GridBagConstraints.HORIZONTAL; + buttonPanelConstraints.gridx = 1; + buttonPanelConstraints.gridy = 0; + buttonPanelConstraints.weightx = 0.7; + buttonPanelConstraints.weighty = 0; + buttonPanelConstraints.insets = new Insets(10, 0, 0, 0); + buttonPanelConstraints.anchor = GridBagConstraints.WEST; + myPanel.add(buttonPanel, buttonPanelConstraints); - buttonGroup.add(yesButton); - buttonGroup.add(noButton); + GridBagConstraints saveContextConstraints = new GridBagConstraints(); + saveContextConstraints.fill = GridBagConstraints.HORIZONTAL; + saveContextConstraints.gridx = 0; + saveContextConstraints.gridy = 1; + saveContextConstraints.gridwidth = GridBagConstraints.REMAINDER; + saveContextConstraints.weightx = 1; + saveContextConstraints.weighty = 0; + saveContextConstraints.insets = new Insets(10, 0, 0, 0); + myPanel.add(loadPropertiesBox, saveContextConstraints); - } + GridBagConstraints glueConstraints = new GridBagConstraints(); + glueConstraints.fill = GridBagConstraints.BOTH; + glueConstraints.gridx = 0; + glueConstraints.gridy = 2; + glueConstraints.weightx = 1; + glueConstraints.weighty = 1; + glueConstraints.gridwidth = GridBagConstraints.REMAINDER; + glueConstraints.gridheight = GridBagConstraints.REMAINDER; + myPanel.add(Box.createGlue(), glueConstraints); + + this.add(myPanel); + } + + /** + * Inits the tab's components. + */ + private void initComponents() { + + initHistoryComponents(); + + initLoadEntitiesComponents(); + } + + private void initHistoryComponents() { + buttonHistoryGroup = new ButtonGroup(); + + String msgSaveHistoryOnShutdown = Messages.getMessage("DIALOGS_OPTIONS_SAVE_SAVEONSHUTDOWN"); + String msgYes = Messages.getMessage("DIALOGS_OPTIONS_SAVE_SAVEONSHUTDOWN_YES"); + String msgNo = Messages.getMessage("DIALOGS_OPTIONS_SAVE_SAVEONSHUTDOWN_NO"); + + label = new JLabel(msgSaveHistoryOnShutdown, JLabel.RIGHT); + + saveHistoryYes = new JRadioButton(msgYes, true); + saveHistoryYes.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + loadPropertiesBox.setVisible(true); + } + }); - /** - * @return The buttonGroup attribute, containing the Save Yes and Save No - * JRadioButtons - */ - public ButtonGroup getButtonGroup() { - return buttonGroup; + saveHistoryNo = new JRadioButton(msgNo, true); + saveHistoryNo.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + loadPropertiesBox.setVisible(false); + } + }); + + saveHistoryYes.setActionCommand(String.valueOf(SaveOptions.HISTORY_YES)); + saveHistoryNo.setActionCommand(String.valueOf(SaveOptions.HISTORY_NO)); + + buttonHistoryGroup.add(saveHistoryYes); + buttonHistoryGroup.add(saveHistoryNo); + } + + private void initLoadEntitiesComponents() { + + // String msg = + // Messages.getMessage("DIALOGS_OPTIONS_SAVE_OPENED_CONTEXT"); + // contextOpenedCheckBox = new JCheckBox(msg, true); + // contextOpenedCheckBox.setActionCommand(String.valueOf(SaveOptions.CONTEXT_OPENED)); + String msg = Messages.getMessage("DIALOGS_OPTIONS_SAVE_SELECTED_CONTEXT"); + contextSelectedCheckBox = new JCheckBox(msg, false); + contextSelectedCheckBox.setActionCommand(String.valueOf(SaveOptions.CONTEXT_SELECTED)); + msg = Messages.getMessage("DIALOGS_OPTIONS_SAVE_OPENED_SNAPSHOT"); + snapshotsOpenedCheckBox = new JCheckBox(msg, false); + snapshotsOpenedCheckBox.setActionCommand(String.valueOf(SaveOptions.SNAPSHOT_OPENED)); + msg = Messages.getMessage("DIALOGS_OPTIONS_SAVE_SELECTED_SNAPSHOT"); + snapshotsSelectedCheckBox = new JCheckBox(msg, false); + snapshotsSelectedCheckBox.setActionCommand(String.valueOf(SaveOptions.SNAPSHOT_SELECTED)); + + loadPropertiesBox = new Box(BoxLayout.Y_AXIS); + // loadPropertiesBox.add(contextOpenedCheckBox); + // loadPropertiesBox.add(Box.createVerticalStrut(5)); + loadPropertiesBox.add(contextSelectedCheckBox); + loadPropertiesBox.add(Box.createVerticalStrut(5)); + loadPropertiesBox.add(snapshotsOpenedCheckBox); + loadPropertiesBox.add(Box.createVerticalStrut(5)); + loadPropertiesBox.add(snapshotsSelectedCheckBox); + + msg = Messages.getMessage("DIALOGS_OPTIONS_SAVE_LOAD_ENTITIES"); + TitledBorder tb = new TitledBorder(new EtchedBorder(EtchedBorder.LOWERED), msg, + TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.TOP, GUIUtilities.getOptionsTitleFont()); + loadPropertiesBox.setBorder(tb); + } + + /** + * @return The buttonGroup attribute, containing the Save Yes and Save No + * JRadioButtons + */ + public ButtonGroup getButtonHistoryGroup() { + return buttonHistoryGroup; + } + + /** + * @return a table of boolean with the 4 load properties boolean values + */ + public boolean[] getLoadPropertiesValues() { + boolean[] result = new boolean[4]; + // result[SaveOptions.CONTEXT_OPENED] = + // contextOpenedCheckBox.isSelected(); + result[SaveOptions.CONTEXT_OPENED] = true; + result[SaveOptions.CONTEXT_SELECTED] = contextSelectedCheckBox.isSelected(); + result[SaveOptions.SNAPSHOT_OPENED] = snapshotsOpenedCheckBox.isSelected(); + result[SaveOptions.SNAPSHOT_SELECTED] = snapshotsSelectedCheckBox.isSelected(); + return result; + } + + /** + * Select load properties check box + * + * @param properties + * a set of boolean that indicate if the checkbox related is + * selected or not + */ + public void setLoadPropertiesCheckBox(boolean[] properties) { + if (properties != null && properties.length == 4) { + // contextOpenedCheckBox.setSelected(properties[SaveOptions.CONTEXT_OPENED]); + contextSelectedCheckBox.setSelected(properties[SaveOptions.CONTEXT_SELECTED]); + snapshotsOpenedCheckBox.setSelected(properties[SaveOptions.SNAPSHOT_OPENED]); + snapshotsSelectedCheckBox.setSelected(properties[SaveOptions.SNAPSHOT_SELECTED]); } + } + + /** + * Selects a save JRadioButton, depending on the hasSave parameter value + * + * @param hasSave + * Has to be either HISTORY_YES or HISTORY_NO, otherwise a + * IllegalArgumentException is thrown + * @throws IllegalArgumentException + */ + public void selectHasSaveButton(int hasSave) throws IllegalArgumentException { + switch (hasSave) { + case SaveOptions.HISTORY_YES: + saveHistoryYes.setSelected(true); + if (loadPropertiesBox != null) { + loadPropertiesBox.setVisible(true); + } + break; + + case SaveOptions.HISTORY_NO: + saveHistoryNo.setSelected(true); + if (loadPropertiesBox != null) { + loadPropertiesBox.setVisible(false); + } + break; - /** - * Selects a save JRadioButton, depending on the hasSave parameter value - * - * @param hasSave - * Has to be either HISTORY_YES or HISTORY_NO, otherwise a - * IllegalArgumentException is thrown - * @throws IllegalArgumentException - */ - public void selectHasSaveButton(int hasSave) - throws IllegalArgumentException { - switch (hasSave) { - case SaveOptions.HISTORY_YES: - yesButton.setSelected(true); - break; - - case SaveOptions.HISTORY_NO: - noButton.setSelected(true); - break; - - default: - throw new IllegalArgumentException(); - } + default: + throw new IllegalArgumentException(); } + } } diff --git a/src/main/java/fr/soleil/bensikin/containers/sub/dialogs/options/OptionsSnapshotTab.java b/src/main/java/fr/soleil/bensikin/containers/sub/dialogs/options/OptionsSnapshotTab.java index 08331b5192effa97b14bd3d1bd054869fca9391a..d517ef57543386e0187e7948178098bb9af96842 100644 --- a/src/main/java/fr/soleil/bensikin/containers/sub/dialogs/options/OptionsSnapshotTab.java +++ b/src/main/java/fr/soleil/bensikin/containers/sub/dialogs/options/OptionsSnapshotTab.java @@ -76,7 +76,6 @@ public class OptionsSnapshotTab extends JPanel { // --- private Box autoCommentBox; - private JRadioButton autoSnapshotCommentYes; private JRadioButton autoSnapshotCommentNo; private JTextField defaultSnapshotComment; @@ -242,10 +241,20 @@ public class OptionsSnapshotTab extends JPanel { * Inits the tab's components. */ private void initComponents() { + + initSnapshotAutoComment(); + + initTimeFilterPanel(); + + initCSVPanel(); + + initShowPanel(); + } + + private void initSnapshotAutoComment() { buttonGroup = new ButtonGroup(); String msg = Messages.getMessage("DIALOGS_OPTIONS_SNAPSHOT_HAS_AUTO_SNAPSHOT_COMMENT_YES"); - msg = Messages.getMessage("DIALOGS_OPTIONS_SNAPSHOT_HAS_AUTO_SNAPSHOT_COMMENT_YES"); autoSnapshotCommentYes = new JRadioButton(msg, true); autoSnapshotCommentYes.setActionCommand(String.valueOf(SnapshotOptions.SNAPSHOT_AUTO_COMMENT_YES)); msg = Messages.getMessage("DIALOGS_OPTIONS_SNAPSHOT_HAS_AUTO_SNAPSHOT_COMMENT_NO"); @@ -274,12 +283,6 @@ public class OptionsSnapshotTab extends JPanel { TitledBorder tb = new TitledBorder(new EtchedBorder(EtchedBorder.LOWERED), msg, TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.TOP, GUIUtilities.getOptionsTitleFont()); autoCommentBox.setBorder(tb); - - initTimeFilterPanel(); - - initCSVPanel(); - - initShowPanel(); } private void initCSVPanel() { diff --git a/src/main/java/fr/soleil/bensikin/data/snapshot/SnapshotAttributeValue.java b/src/main/java/fr/soleil/bensikin/data/snapshot/SnapshotAttributeValue.java index 91a0192f54696f89b611f4c1695f38aff7a8999a..51a277a04d52fa47f11f943395b977706d1f578a 100644 --- a/src/main/java/fr/soleil/bensikin/data/snapshot/SnapshotAttributeValue.java +++ b/src/main/java/fr/soleil/bensikin/data/snapshot/SnapshotAttributeValue.java @@ -71,6 +71,7 @@ // -====================================================================== package fr.soleil.bensikin.data.snapshot; +import java.util.Comparator; import java.util.Locale; import java.util.StringTokenizer; @@ -85,7 +86,7 @@ import fr.soleil.snapArchivingApi.SnapshotingTools.Tools.StringFormater; * All snapshot attributes values, be it read write or delta, extend this class * that implements basic cast operations, value tests, and String * representation. - * + * * @author CLAISSE */ public class SnapshotAttributeValue { @@ -315,9 +316,9 @@ public class SnapshotAttributeValue { * dimY = y.length; for ( int j = 0 ; j < dimX ; j++ ) { ret += ( "" * + imageValue[ i ][ j ] ); if ( j < dimY - 1 ) { ret += * Y_SEPARATOR; } - * + * * } - * + * * if ( i < dimX - 1 ) { ret += X_SEPARATOR; } } } */ break; @@ -329,7 +330,7 @@ public class SnapshotAttributeValue { /** * Returns a XML representation of the value. - * + * * @return a XML representation of the value */ @Override @@ -476,7 +477,7 @@ public class SnapshotAttributeValue { /** * Sets the value attribute, and depending on the data format, the * scalarValue, imageValue, or spectrumValue. - * + * * @param _value * The raw value */ @@ -677,7 +678,7 @@ public class SnapshotAttributeValue { /** * Builds a SnapshotAttributeValue given its format, type, and value. - * + * * @param _dataFormat * The data format ( scalar, spectrum, or image ) * @param _dataType @@ -711,7 +712,7 @@ public class SnapshotAttributeValue { /** * Tests whether a value is coherent with the data type - * + * * @param value * The value to test * @return True if it is, false otherwise @@ -754,7 +755,7 @@ public class SnapshotAttributeValue { /** * Casts a value content to its Tango type. - * + * * @param value * The value content * @param _data_type @@ -951,7 +952,7 @@ public class SnapshotAttributeValue { /** * Sets the display format in case of scalar value - * + * * @param format * the display format */ @@ -974,4 +975,66 @@ public class SnapshotAttributeValue { return ret; } + public static class SnapshotValueComparator implements Comparator<SnapshotAttributeValue> { + + @Override + public int compare(SnapshotAttributeValue obj1, SnapshotAttributeValue obj2) { + + Object obj1_value = obj1.getValue(); + Object obj2_value = obj2.getValue(); + + // String valueType1 = (obj1_value != null) ? + // obj1_value.getClass().getSimpleName() : "NULL"; + // String valueType2 = (obj2_value != null) ? + // obj2_value.getClass().getSimpleName() : "NULL"; + // + // System.out.println("Obj1 value : " + valueType1 + + // ", Obj2 value : " + valueType2); + + // Order : Number > String > Boolean > Array > Others + + if (obj1_value != null && obj1_value.getClass().isArray()) { + if (obj2_value == null) { + return 1; + } else if (obj2_value != null && obj2_value.getClass().isArray()) { + return 0; + } else { + return -1; + } + } + + if (obj1_value instanceof Boolean) { + if (obj2_value instanceof Boolean) { + return ((Boolean) obj1_value).compareTo((Boolean) obj2_value); + } else if (obj2_value instanceof Number || obj2_value instanceof String) { + return -1; + } else { + return 1; + } + } + + if (obj1_value instanceof String) { + if (obj2_value instanceof Number) { + return -1; + } else if (obj2_value instanceof String) { + return ((String) obj1_value).compareTo(((String) obj2_value)); + } else { + return 1; + } + } + + if (obj1_value instanceof Number) { + if (obj2_value instanceof Number) { + Double valueDouble = ((Number) obj1_value).doubleValue(); + Double o_valueDouble = ((Number) obj2_value).doubleValue(); + return valueDouble.compareTo(o_valueDouble); + } else { + return 1; + } + } + + return -1; + } + } + } diff --git a/src/main/java/fr/soleil/bensikin/history/History.java b/src/main/java/fr/soleil/bensikin/history/History.java index 0851148f41e0d0e8b3bc8ca9a252a9a154aba306..242d9cacd7135d1760323684f64c8e5de0609ca7 100644 --- a/src/main/java/fr/soleil/bensikin/history/History.java +++ b/src/main/java/fr/soleil/bensikin/history/History.java @@ -67,6 +67,7 @@ import fr.soleil.bensikin.history.snapshot.SelectedSnapshotRef; import fr.soleil.bensikin.history.snapshot.SnapshotHistory; import fr.soleil.bensikin.models.ContextListTableModel; import fr.soleil.bensikin.models.SnapshotListTableModel; +import fr.soleil.bensikin.options.sub.SaveOptions; import fr.soleil.bensikin.xml.XMLLine; import fr.soleil.snapArchivingApi.SnapManagerApi.ISnapManager; import fr.soleil.snapArchivingApi.SnapshotingTools.Tools.Condition; @@ -368,29 +369,80 @@ public class History { return selectedSnapshots; } + public void setLoadProperties(boolean[] properties) throws SnapshotingException, Exception { + if (properties[SaveOptions.CONTEXT_OPENED]) { + setOpenedContexts(); + } + if (properties[SaveOptions.CONTEXT_SELECTED]) { + setSelectedContexts(); + } + if (properties[SaveOptions.SNAPSHOT_OPENED]) { + setOpenedSnapshots(); + } + if (properties[SaveOptions.SNAPSHOT_SELECTED]) { + setSelectedSnapshots(); + } + } + /** - * Applies the opened/selected state of snapshots/contexts contained in this - * History to the static references in Context/Snapshot. + * Applies the opened state of contexts contained in this History to the + * static references in Context. * * @throws SnapshotingException * @throws Exception */ - public void setOpenedAndSelectedEntities() throws SnapshotingException, Exception { + public void setOpenedContexts() throws SnapshotingException, Exception { + Hashtable<String, Context> openedContexts = this.loadOpenedContextsFromHistory(); - Context.setOpenedContexts(openedContexts); - - // Context selectedContext = this.loadSelectedContext(); - // if (selectedContext != null) { - // Context.setSelectedContext(selectedContext); - // } - // - // Hashtable<String, Snapshot> openedSnapshots = this - // .loadOpenedSnapshotsFromHistory(); - // Snapshot.setOpenedSnapshots(openedSnapshots); - // - // Hashtable<String, Snapshot> selectedSnapshots = this - // .loadSelectedSnapshotsFromHistory(); - // Snapshot.setSelectedSnapshots(selectedSnapshots); + if (openedContexts != null) { + Context.setOpenedContexts(openedContexts); + } + } + + /** + * Applies the selected state of contexts contained in this History to the + * static references in Context. + * + * @throws SnapshotingException + * @throws Exception + */ + public void setSelectedContexts() throws SnapshotingException, Exception { + + Context selectedContext = this.loadSelectedContext(); + if (selectedContext != null) { + Context.setSelectedContext(selectedContext); + } + + } + + /** + * Applies the opened/selected state of snapshots contained in this History + * to the static references in Snapshot. + * + * @throws SnapshotingException + * @throws Exception + */ + public void setOpenedSnapshots() throws SnapshotingException, Exception { + + Hashtable<String, Snapshot> openedSnapshots = this.loadOpenedSnapshotsFromHistory(); + if (openedSnapshots != null) { + Snapshot.setOpenedSnapshots(openedSnapshots); + } + } + + /** + * Applies the opened/selected state of snapshots contained in this History + * to the static references in Snapshot. + * + * @throws SnapshotingException + * @throws Exception + */ + public void setSelectedSnapshots() throws SnapshotingException, Exception { + + Hashtable<String, Snapshot> selectedSnapshots = this.loadSelectedSnapshotsFromHistory(); + if (selectedSnapshots != null) { + Snapshot.setSelectedSnapshots(selectedSnapshots); + } } /** diff --git a/src/main/java/fr/soleil/bensikin/lifecycle/DefaultLifeCycleManager.java b/src/main/java/fr/soleil/bensikin/lifecycle/DefaultLifeCycleManager.java index 06e3c8c708a145609368add57a019b404da39ae0..5fe7af57be3cbfe11d155c0075240cc8122503a1 100644 --- a/src/main/java/fr/soleil/bensikin/lifecycle/DefaultLifeCycleManager.java +++ b/src/main/java/fr/soleil/bensikin/lifecycle/DefaultLifeCycleManager.java @@ -93,7 +93,8 @@ public class DefaultLifeCycleManager implements LifeCycleManager { private String historyPath; private String favoritesPath; - boolean hasHistorySave = true; + private boolean hasHistorySave = true; + private boolean[] loadProperties = null; public DefaultLifeCycleManager() { } @@ -261,7 +262,7 @@ public class DefaultLifeCycleManager implements LifeCycleManager { splash.setMessage("applying history"); History.setHistory(history); splash.progress(14); - history.setOpenedAndSelectedEntities(); + history.setLoadProperties(loadProperties); splash.progress(15); splash.setMessage("history fully loaded"); @@ -428,4 +429,14 @@ public class DefaultLifeCycleManager implements LifeCycleManager { return hasHistorySave; } + @Override + public boolean[] getLoadProperties() { + return loadProperties; + } + + @Override + public void setLoadProperties(boolean[] loadProperties) { + this.loadProperties = loadProperties; + } + } diff --git a/src/main/java/fr/soleil/bensikin/lifecycle/LifeCycleManager.java b/src/main/java/fr/soleil/bensikin/lifecycle/LifeCycleManager.java index 2765447bfd35a863f923f74fe530352807d10506..879c96b8f18c58c013682d505f542123511f8db2 100644 --- a/src/main/java/fr/soleil/bensikin/lifecycle/LifeCycleManager.java +++ b/src/main/java/fr/soleil/bensikin/lifecycle/LifeCycleManager.java @@ -34,13 +34,15 @@ import java.util.Hashtable; import fr.soleil.util.component.Splash; /** - * An important interface that controls the application's startup/shutdown cycle. + * An important interface that controls the application's startup/shutdown + * cycle. * * @author CLAISSE */ public interface LifeCycleManager { /** - * Called before the GUI graphics containers are instantiated. Can be used to load : + * Called before the GUI graphics containers are instantiated. Can be used + * to load : * <UL> * <LI>the application's state from the history file * <LI>the application's options @@ -52,40 +54,44 @@ public interface LifeCycleManager { * <LI>etc.. * </UL> * - * @param startParameters Can contain parameters if necessary + * @param startParameters + * Can contain parameters if necessary */ public void applicationWillStart(Hashtable startParameters, Splash splash); /** - * Called just after the GUI graphics containers are instantiated. Must be used for operations - * that need the containers to already exist: + * Called just after the GUI graphics containers are instantiated. Must be + * used for operations that need the containers to already exist: * <UL> * <LI>pushing the pre loaded history and options to the display components * <LI>setting the window size * <LI>etc.. * <UL> * - * @param startParameters Can contain parameters if necessary + * @param startParameters + * Can contain parameters if necessary */ public void applicationStarted(Hashtable startParameters); /** - * Called when the application detects a shutdown request, be it through the close icon or - * through the menu's Exit option. Can be used to: + * Called when the application detects a shutdown request, be it through the + * close icon or through the menu's Exit option. Can be used to: * <UL> * <LI>save everything that has to be saved * <LI>close resources * </UL> * And finally, that's where the application's shutdown must be done. * - * @param endParameters Can contain parameters if necessary + * @param endParameters + * Can contain parameters if necessary */ public void applicationClosed(Hashtable endParameters); /** * Sets whether the application must save/load history * - * @param b Whether the application must save/load history + * @param b + * Whether the application must save/load history */ public void setHasHistorySave(boolean b); @@ -96,4 +102,20 @@ public interface LifeCycleManager { */ public boolean hasHistorySave(); + /** + * Sets whether the application must save/load current context/snapshots + * + * @param b + * Whether the application must save/load current + * context/snapshots + */ + public void setLoadProperties(boolean[] loadProperties); + + /** + * Gets whether the application must save/load current context/snapshots + * + * @return Whether the application must save/load current context/snapshots + */ + public boolean[] getLoadProperties(); + } diff --git a/src/main/java/fr/soleil/bensikin/models/SnapshotCompareTableModel.java b/src/main/java/fr/soleil/bensikin/models/SnapshotCompareTableModel.java index abb238a6b9e70dc73399427be1b23fee98219ecb..a7c7338d240b988f25719e52de9ffffb94fc8b7a 100644 --- a/src/main/java/fr/soleil/bensikin/models/SnapshotCompareTableModel.java +++ b/src/main/java/fr/soleil/bensikin/models/SnapshotCompareTableModel.java @@ -84,7 +84,7 @@ public class SnapshotCompareTableModel extends SortedTableModel { private static final long serialVersionUID = -8810932900385131562L; - private Map<Integer, String> colNamesMap; + private final Map<Integer, String> colNamesMap; private boolean filter; /** @@ -109,7 +109,7 @@ public class SnapshotCompareTableModel extends SortedTableModel { */ protected static String[] snapNames; - private Snapshot snapshot1, snapshot2; + private final Snapshot snapshot1, snapshot2; public boolean isFilter() { return filter; @@ -477,7 +477,7 @@ public class SnapshotCompareTableModel extends SortedTableModel { this.rows = SnapshotComparison.build(snapshot1, snapshot2, Options.getInstance().getSnapshotOptions() .isShowDiff()); fireTableStructureChanged(); - sort(0); + // sort(0); } public void initRows() { @@ -501,17 +501,17 @@ public class SnapshotCompareTableModel extends SortedTableModel { * @param clickedColumnIndex * The index of the column to sort the lines by */ - @Override - public void sort(int clickedColumnIndex) { - int snapshotType = getSnapshotType(clickedColumnIndex); - int columnType = getColumnType(clickedColumnIndex); - if (snapshotType == SnapshotComparison.SNAPSHOT_TYPE_ATTR_NAME) { - snapshotType = SnapshotComparison.SNAPSHOT_TYPE_1; - columnType = SnapshotComparison.COLUMN_ATTR_NAME_TYPE; - } - sortByColumn(snapshotType, columnType); - sortedColumn = clickedColumnIndex; - } + // @Override + // public void sort(int clickedColumnIndex) { + // int snapshotType = getSnapshotType(clickedColumnIndex); + // int columnType = getColumnType(clickedColumnIndex); + // if (snapshotType == SnapshotComparison.SNAPSHOT_TYPE_ATTR_NAME) { + // snapshotType = SnapshotComparison.SNAPSHOT_TYPE_1; + // columnType = SnapshotComparison.COLUMN_ATTR_NAME_TYPE; + // } + // sortByColumn(snapshotType, columnType); + // sortedColumn = clickedColumnIndex; + // } /** * Sorts the table's lines relative to the specified field. If the the table diff --git a/src/main/java/fr/soleil/bensikin/models/SnapshotDetailTableModel.java b/src/main/java/fr/soleil/bensikin/models/SnapshotDetailTableModel.java index 517c08aa53a80746e2a76ceee3df5a25691604a2..20c9de3905ed55bee6cf33771c5e32e76d446f0e 100644 --- a/src/main/java/fr/soleil/bensikin/models/SnapshotDetailTableModel.java +++ b/src/main/java/fr/soleil/bensikin/models/SnapshotDetailTableModel.java @@ -110,12 +110,12 @@ import fr.soleil.data.service.AbstractKey; * list of snapshots. Its rows are SnapshotAttribute objects. A static reference * Hashtable allows for keeping track of precedently created instances (using as * reference the Snapshot the rows of which the table is displaying). - * + * * @author CLAISSE */ public class SnapshotDetailTableModel extends SortedTableModel { - //this is the columns list. Order matters. + // this is the columns list. Order matters. public static enum SnapshotColumns { NAME, WRITE, READ, DELTA, CAN_SET, WRITE_ABS, READ_ABS, DELTA_ABS } @@ -123,6 +123,7 @@ public class SnapshotDetailTableModel extends SortedTableModel { private static final long serialVersionUID = -4689031046562249463L; private SnapshotAttribute[] rows; private SnapshotAttribute[] rowsFilter; + private static String[] columnsNames; private boolean filter; @@ -130,7 +131,7 @@ public class SnapshotDetailTableModel extends SortedTableModel { private static HashMap<Snapshot, SnapshotDetailTableModel> snapshotDetailTableModelHashtable = null; - private HashMap<SnapshotAttributeValue, AbstractKey> cometeKeys = new HashMap<SnapshotAttributeValue, AbstractKey>(); + private final HashMap<SnapshotAttributeValue, AbstractKey> cometeKeys = new HashMap<SnapshotAttributeValue, AbstractKey>(); public List<Integer> getAttributesNumRowList() { return attributesNumRowList; @@ -150,7 +151,7 @@ public class SnapshotDetailTableModel extends SortedTableModel { /** * Creates a statically referenced instance of model for the given Snapshot. - * + * * @param snapshot * The model of which we're displaying the details * @return The instance found for the specified Snapshot reference, or a new @@ -192,8 +193,9 @@ public class SnapshotDetailTableModel extends SortedTableModel { } /** - * Builds itself with the list of attributes contained in <code>snapshot</code>. - * + * Builds itself with the list of attributes contained in + * <code>snapshot</code>. + * * @param snapshot * The Snapshot containing the attributes to display */ @@ -212,7 +214,7 @@ public class SnapshotDetailTableModel extends SortedTableModel { /** * Builds the matched list of attributes contained in snapshot. - * + * * @param snapshot * The Snapshot containing the attributes to display */ @@ -434,55 +436,55 @@ public class SnapshotDetailTableModel extends SortedTableModel { /** * Sorts the table's lines relative to the specified column. If the the * table is already sorted relative to this column, reverses the sort. - * + * * @param clickedColumnIndex * The index of the column to sort the lines by */ - @Override - public void sort(int clickedColumnIndex) { - switch (clickedColumnIndex) { - case 0: - sortByColumn(SnapshotAttributeComparator.COMPARE_NAME); - sortedColumn = clickedColumnIndex; - break; - - case 1: - sortByColumn(SnapshotAttributeComparator.COMPARE_WRITE_VALUE); - sortedColumn = clickedColumnIndex; - break; - - case 2: - sortByColumn(SnapshotAttributeComparator.COMPARE_READ_VALUE); - sortedColumn = clickedColumnIndex; - break; - - case 3: - sortByColumn(SnapshotAttributeComparator.COMPARE_DELTA_VALUE); - sortedColumn = clickedColumnIndex; - break; - - case 5: - sortByColumn(SnapshotAttributeComparator.COMPARE_WRITE_ABS_VALUE); - sortedColumn = clickedColumnIndex; - break; - - case 6: - sortByColumn(SnapshotAttributeComparator.COMPARE_READ_ABS_VALUE); - sortedColumn = clickedColumnIndex; - break; - - case 7: - sortByColumn(SnapshotAttributeComparator.COMPARE_DELTA_ABS_VALUE); - sortedColumn = clickedColumnIndex; - break; - - } - } + // @Override + // public void sort(int clickedColumnIndex) { + // switch (clickedColumnIndex) { + // case 0: + // sortByColumn(SnapshotAttributeComparator.COMPARE_NAME); + // sortedColumn = clickedColumnIndex; + // break; + // + // case 1: + // sortByColumn(SnapshotAttributeComparator.COMPARE_WRITE_VALUE); + // sortedColumn = clickedColumnIndex; + // break; + // + // case 2: + // sortByColumn(SnapshotAttributeComparator.COMPARE_READ_VALUE); + // sortedColumn = clickedColumnIndex; + // break; + // + // case 3: + // sortByColumn(SnapshotAttributeComparator.COMPARE_DELTA_VALUE); + // sortedColumn = clickedColumnIndex; + // break; + // + // case 5: + // sortByColumn(SnapshotAttributeComparator.COMPARE_WRITE_ABS_VALUE); + // sortedColumn = clickedColumnIndex; + // break; + // + // case 6: + // sortByColumn(SnapshotAttributeComparator.COMPARE_READ_ABS_VALUE); + // sortedColumn = clickedColumnIndex; + // break; + // + // case 7: + // sortByColumn(SnapshotAttributeComparator.COMPARE_DELTA_ABS_VALUE); + // sortedColumn = clickedColumnIndex; + // break; + // + // } + // } /** * Sorts the table's lines relative to the specified field. If the the table * is already sorted relative to this column, reverses the sort. - * + * * @param compareCase * The type of field to sort the lines by */ diff --git a/src/main/java/fr/soleil/bensikin/models/SortedTableModel.java b/src/main/java/fr/soleil/bensikin/models/SortedTableModel.java index 3e585b7f0e7f8b6efcf4e71319f52aa9f8139a78..e7461376444e51d331924ed0c6bc6e5ca5ed6fd0 100644 --- a/src/main/java/fr/soleil/bensikin/models/SortedTableModel.java +++ b/src/main/java/fr/soleil/bensikin/models/SortedTableModel.java @@ -5,22 +5,22 @@ import javax.swing.table.AbstractTableModel; import fr.soleil.bensikin.components.BensikinComparator; public abstract class SortedTableModel extends AbstractTableModel { - protected int idSort; - protected int sortedColumn; + protected int idSort; + protected int sortedColumn; - public SortedTableModel() { - super(); - idSort = BensikinComparator.NO_SORT; - sortedColumn = -1; - } + public SortedTableModel() { + super(); + idSort = BensikinComparator.NO_SORT; + sortedColumn = -1; + } - public abstract void sort(int clickedColumnIndex); + // public abstract void sort(int clickedColumnIndex); - public int getSortedColumn() { - return sortedColumn; - } + public int getSortedColumn() { + return sortedColumn; + } - public int getIdSort() { - return idSort; - } + public int getIdSort() { + return idSort; + } } diff --git a/src/main/java/fr/soleil/bensikin/options/sub/SaveOptions.java b/src/main/java/fr/soleil/bensikin/options/sub/SaveOptions.java index 4e7844bb25b444c1118b922095f1f7596f047232..986d4905a529c9281ddbf7f232f6a720d4337799 100644 --- a/src/main/java/fr/soleil/bensikin/options/sub/SaveOptions.java +++ b/src/main/java/fr/soleil/bensikin/options/sub/SaveOptions.java @@ -40,72 +40,141 @@ import fr.soleil.bensikin.options.ReadWriteOptionBook; * * @author CLAISSE */ -public class SaveOptions extends ReadWriteOptionBook implements - PushPullOptionBook { - /** - * The history saving property name - */ - public static final String HISTORY = "HISTORY"; - - /** - * The code for the history saving property value of "Do save history" - */ - public static final int HISTORY_YES = 1; - - /** - * The code for the history saving property value of "Don't save history" - */ - public static final int HISTORY_NO = 0; - - /** - * The XML tag name used in saving/loading - */ - public static final String XML_TAG = "save"; - - /** - * Default constructor - */ - public SaveOptions() { - super(XML_TAG); +public class SaveOptions extends ReadWriteOptionBook implements PushPullOptionBook { + /** + * The history saving property name + */ + public static final String HISTORY = "HISTORY"; + + /** + * The code for the history saving property value of "Do save history" + */ + public static final int HISTORY_YES = 1; + + /** + * The code for the history saving property value of "Don't save history" + */ + public static final int HISTORY_NO = 0; + + /** + * The XML tag name used in saving/loading + */ + public static final String XML_TAG = "save"; + + /** + * The load properties names + */ + public static final String CONTEXT_OPENED_NAME = "CONTEXT_OPENED"; + public static final String CONTEXT_SELECTED_NAME = "CONTEXT_SELECTED"; + public static final String SNAPSHOT_OPENED_NAME = "SNAPSHOT_OPENED"; + public static final String SNAPSHOT_SELECTED_NAME = "SNAPSHOT_SELECTED"; + + /** + * Code for history properties to be load at application launch + */ + public static final int CONTEXT_OPENED = 0; + public static final int CONTEXT_SELECTED = 1; + public static final int SNAPSHOT_OPENED = 2; + public static final int SNAPSHOT_SELECTED = 3; + + public static final int LOAD_ENTITY_YES = 1; + public static final int LOAD_ENTITY_NO = 0; + + /** + * Default constructor + */ + public SaveOptions() { + super(XML_TAG); + } + + /* + * (non-Javadoc) + * + * @see bensikin.bensikin.options.PushPullOptionBook#fillFromOptionsDialog() + */ + @Override + public void fillFromOptionsDialog() { + OptionsSaveOptionsTab saveTab = OptionsSaveOptionsTab.getInstance(); + ButtonModel selectedModel = saveTab.getButtonHistoryGroup().getSelection(); + String selectedActionCommand = selectedModel.getActionCommand(); + + this.content.put(HISTORY, selectedActionCommand); + + boolean[] loadConfiguration = saveTab.getLoadPropertiesValues(); + + this.content.put(CONTEXT_OPENED_NAME, (loadConfiguration[CONTEXT_OPENED]) ? Integer.toString(LOAD_ENTITY_YES) + : Integer.toString(LOAD_ENTITY_NO)); + this.content.put( + CONTEXT_SELECTED_NAME, + (loadConfiguration[CONTEXT_SELECTED]) ? Integer.toString(LOAD_ENTITY_YES) : Integer + .toString(LOAD_ENTITY_NO)); + this.content.put(SNAPSHOT_OPENED_NAME, (loadConfiguration[SNAPSHOT_OPENED]) ? Integer.toString(LOAD_ENTITY_YES) + : Integer.toString(LOAD_ENTITY_NO)); + this.content.put( + SNAPSHOT_SELECTED_NAME, + (loadConfiguration[SNAPSHOT_SELECTED]) ? Integer.toString(LOAD_ENTITY_YES) : Integer + .toString(LOAD_ENTITY_NO)); + } + + /* + * (non-Javadoc) + * + * @see bensikin.bensikin.options.PushPullOptionBook#push() + */ + @Override + public void push() { + LifeCycleManager lifeCycleManager = LifeCycleManagerFactory.getCurrentImpl(); + + // History save option + String val_s = this.content.get(HISTORY); + if (val_s != null) { + int val = Integer.parseInt(val_s); + + switch (val) { + case HISTORY_YES: + lifeCycleManager.setHasHistorySave(true); + break; + + case HISTORY_NO: + lifeCycleManager.setHasHistorySave(false); + break; + } + + OptionsSaveOptionsTab saveTab = OptionsSaveOptionsTab.getInstance(); + saveTab.selectHasSaveButton(val); } - /* - * (non-Javadoc) - * - * @see bensikin.bensikin.options.PushPullOptionBook#fillFromOptionsDialog() - */ - public void fillFromOptionsDialog() { - OptionsSaveOptionsTab saveTab = OptionsSaveOptionsTab.getInstance(); - ButtonModel selectedModel = saveTab.getButtonGroup().getSelection(); - String selectedActionCommand = selectedModel.getActionCommand(); - - this.content.put(HISTORY, selectedActionCommand); + // load properties + if (lifeCycleManager.hasHistorySave()) { + boolean[] loadProperties = new boolean[4]; + + loadProperties[CONTEXT_OPENED] = getLoadPropertyFromContent(CONTEXT_OPENED_NAME); + loadProperties[CONTEXT_SELECTED] = getLoadPropertyFromContent(CONTEXT_SELECTED_NAME); + loadProperties[SNAPSHOT_OPENED] = getLoadPropertyFromContent(SNAPSHOT_OPENED_NAME); + loadProperties[SNAPSHOT_SELECTED] = getLoadPropertyFromContent(SNAPSHOT_SELECTED_NAME); + + lifeCycleManager.setLoadProperties(loadProperties); + + OptionsSaveOptionsTab saveTab = OptionsSaveOptionsTab.getInstance(); + saveTab.setLoadPropertiesCheckBox(loadProperties); } + } - /* - * (non-Javadoc) - * - * @see bensikin.bensikin.options.PushPullOptionBook#push() - */ - public void push() { - String val_s = (String) this.content.get(HISTORY); - if (val_s != null) { - int val = Integer.parseInt(val_s); - LifeCycleManager lifeCycleManager = LifeCycleManagerFactory - .getCurrentImpl(); - - switch (val) { - case HISTORY_YES: - lifeCycleManager.setHasHistorySave(true); - break; - - case HISTORY_NO: - lifeCycleManager.setHasHistorySave(false); - break; - } - - OptionsSaveOptionsTab saveTab = OptionsSaveOptionsTab.getInstance(); - saveTab.selectHasSaveButton(val); - } + /** + * Search within the content to find the load property related to the donate + * key + * + * @param key + * the String to use for content search + * @return the boolean property + */ + private boolean getLoadPropertyFromContent(String key) { + boolean result = false; + String val_s = this.content.get(key); + if (val_s != null) { + int val = Integer.parseInt(val_s); + result = (val == LOAD_ENTITY_YES); } + return result; + } } diff --git a/src/main/java/fr/soleil/bensikin/options/sub/SnapshotOptions.java b/src/main/java/fr/soleil/bensikin/options/sub/SnapshotOptions.java index 7d595472964e32800a6d525c2fcd0e281f06f135..d4be0922b2c976f8bb31216f695925cc4a609eda 100644 --- a/src/main/java/fr/soleil/bensikin/options/sub/SnapshotOptions.java +++ b/src/main/java/fr/soleil/bensikin/options/sub/SnapshotOptions.java @@ -77,6 +77,7 @@ public class SnapshotOptions extends ReadWriteOptionBook implements PushPullOpti * Don't auto-comment new snapshots */ public static final int SNAPSHOT_AUTO_COMMENT_NO = 0; + /** * The snapshot auto-comment value property name (unused if auto-commenting * is disabled) diff --git a/src/main/resources/fr/soleil/bensikin/resources/messages/resources_en_US.properties b/src/main/resources/fr/soleil/bensikin/resources/messages/resources_en_US.properties index b3138b8119976d971554a63f1c9a66a98c1b035a..1414ac8e211aa1ee19de944940f4844cca9ce5c7 100644 --- a/src/main/resources/fr/soleil/bensikin/resources/messages/resources_en_US.properties +++ b/src/main/resources/fr/soleil/bensikin/resources/messages/resources_en_US.properties @@ -265,6 +265,11 @@ DIALOGS_OPTIONS_SAVE_SAVEONSHUTDOWN = Save history on shutdown: DIALOGS_OPTIONS_SAVE_SAVEONSHUTDOWN_YES = Yes DIALOGS_OPTIONS_SAVE_SAVEONSHUTDOWN_NO = No +DIALOGS_OPTIONS_SAVE_LOAD_ENTITIES = History Load Properties +DIALOGS_OPTIONS_SAVE_SELECTED_CONTEXT = Last Selected Context +DIALOGS_OPTIONS_SAVE_OPENED_SNAPSHOT = Opened Snapshots +DIALOGS_OPTIONS_SAVE_SELECTED_SNAPSHOT = Last Selected Snapshot + #-------------------Options Dialog save tab END--------------- #-------------------Options Dialog wordlist START---------------