summaryrefslogtreecommitdiff
path: root/src/de/lmu/ifi/dbs/elki/gui/multistep/panels
diff options
context:
space:
mode:
Diffstat (limited to 'src/de/lmu/ifi/dbs/elki/gui/multistep/panels')
-rw-r--r--src/de/lmu/ifi/dbs/elki/gui/multistep/panels/AlgorithmTabPanel.java43
-rw-r--r--src/de/lmu/ifi/dbs/elki/gui/multistep/panels/EvaluationTabPanel.java43
-rw-r--r--src/de/lmu/ifi/dbs/elki/gui/multistep/panels/InputTabPanel.java35
-rw-r--r--src/de/lmu/ifi/dbs/elki/gui/multistep/panels/LoggingTabPanel.java35
-rw-r--r--src/de/lmu/ifi/dbs/elki/gui/multistep/panels/OutputTabPanel.java35
-rw-r--r--src/de/lmu/ifi/dbs/elki/gui/multistep/panels/ParameterTabPanel.java83
-rw-r--r--src/de/lmu/ifi/dbs/elki/gui/multistep/panels/SavedSettingsTabPanel.java238
7 files changed, 372 insertions, 140 deletions
diff --git a/src/de/lmu/ifi/dbs/elki/gui/multistep/panels/AlgorithmTabPanel.java b/src/de/lmu/ifi/dbs/elki/gui/multistep/panels/AlgorithmTabPanel.java
index 3dde0889..4f294468 100644
--- a/src/de/lmu/ifi/dbs/elki/gui/multistep/panels/AlgorithmTabPanel.java
+++ b/src/de/lmu/ifi/dbs/elki/gui/multistep/panels/AlgorithmTabPanel.java
@@ -1,26 +1,27 @@
package de.lmu.ifi.dbs.elki.gui.multistep.panels;
+
/*
-This file is part of ELKI:
-Environment for Developing KDD-Applications Supported by Index-Structures
-
-Copyright (C) 2011
-Ludwig-Maximilians-Universität München
-Lehr- und Forschungseinheit für Datenbanksysteme
-ELKI Development Team
-
-This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU Affero 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 Affero General Public License for more details.
-
-You should have received a copy of the GNU Affero General Public License
-along with this program. If not, see <http://www.gnu.org/licenses/>.
-*/
+ This file is part of ELKI:
+ Environment for Developing KDD-Applications Supported by Index-Structures
+
+ Copyright (C) 2011
+ Ludwig-Maximilians-Universität München
+ Lehr- und Forschungseinheit für Datenbanksysteme
+ ELKI Development Team
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Affero 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 Affero General Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
import java.lang.ref.WeakReference;
diff --git a/src/de/lmu/ifi/dbs/elki/gui/multistep/panels/EvaluationTabPanel.java b/src/de/lmu/ifi/dbs/elki/gui/multistep/panels/EvaluationTabPanel.java
index 0f7a6776..4f6d0879 100644
--- a/src/de/lmu/ifi/dbs/elki/gui/multistep/panels/EvaluationTabPanel.java
+++ b/src/de/lmu/ifi/dbs/elki/gui/multistep/panels/EvaluationTabPanel.java
@@ -1,26 +1,27 @@
package de.lmu.ifi.dbs.elki.gui.multistep.panels;
+
/*
-This file is part of ELKI:
-Environment for Developing KDD-Applications Supported by Index-Structures
-
-Copyright (C) 2011
-Ludwig-Maximilians-Universität München
-Lehr- und Forschungseinheit für Datenbanksysteme
-ELKI Development Team
-
-This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU Affero 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 Affero General Public License for more details.
-
-You should have received a copy of the GNU Affero General Public License
-along with this program. If not, see <http://www.gnu.org/licenses/>.
-*/
+ This file is part of ELKI:
+ Environment for Developing KDD-Applications Supported by Index-Structures
+
+ Copyright (C) 2011
+ Ludwig-Maximilians-Universität München
+ Lehr- und Forschungseinheit für Datenbanksysteme
+ ELKI Development Team
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Affero 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 Affero General Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
import java.lang.ref.WeakReference;
diff --git a/src/de/lmu/ifi/dbs/elki/gui/multistep/panels/InputTabPanel.java b/src/de/lmu/ifi/dbs/elki/gui/multistep/panels/InputTabPanel.java
index 86d7a013..833d5ba8 100644
--- a/src/de/lmu/ifi/dbs/elki/gui/multistep/panels/InputTabPanel.java
+++ b/src/de/lmu/ifi/dbs/elki/gui/multistep/panels/InputTabPanel.java
@@ -1,26 +1,27 @@
package de.lmu.ifi.dbs.elki.gui.multistep.panels;
+
/*
-This file is part of ELKI:
-Environment for Developing KDD-Applications Supported by Index-Structures
+ This file is part of ELKI:
+ Environment for Developing KDD-Applications Supported by Index-Structures
-Copyright (C) 2011
-Ludwig-Maximilians-Universität München
-Lehr- und Forschungseinheit für Datenbanksysteme
-ELKI Development Team
+ Copyright (C) 2011
+ Ludwig-Maximilians-Universität München
+ Lehr- und Forschungseinheit für Datenbanksysteme
+ ELKI Development Team
-This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU Affero 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 free software: you can redistribute it and/or modify
+ it under the terms of the GNU Affero 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 Affero General Public License for more details.
+ 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 Affero General Public License for more details.
-You should have received a copy of the GNU Affero General Public License
-along with this program. If not, see <http://www.gnu.org/licenses/>.
-*/
+ You should have received a copy of the GNU Affero General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
import de.lmu.ifi.dbs.elki.utilities.exceptions.AbortException;
import de.lmu.ifi.dbs.elki.utilities.optionhandling.parameterization.Parameterization;
diff --git a/src/de/lmu/ifi/dbs/elki/gui/multistep/panels/LoggingTabPanel.java b/src/de/lmu/ifi/dbs/elki/gui/multistep/panels/LoggingTabPanel.java
index 1ab722f0..143887fc 100644
--- a/src/de/lmu/ifi/dbs/elki/gui/multistep/panels/LoggingTabPanel.java
+++ b/src/de/lmu/ifi/dbs/elki/gui/multistep/panels/LoggingTabPanel.java
@@ -1,26 +1,27 @@
package de.lmu.ifi.dbs.elki.gui.multistep.panels;
+
/*
-This file is part of ELKI:
-Environment for Developing KDD-Applications Supported by Index-Structures
+ This file is part of ELKI:
+ Environment for Developing KDD-Applications Supported by Index-Structures
-Copyright (C) 2011
-Ludwig-Maximilians-Universität München
-Lehr- und Forschungseinheit für Datenbanksysteme
-ELKI Development Team
+ Copyright (C) 2011
+ Ludwig-Maximilians-Universität München
+ Lehr- und Forschungseinheit für Datenbanksysteme
+ ELKI Development Team
-This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU Affero 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 free software: you can redistribute it and/or modify
+ it under the terms of the GNU Affero 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 Affero General Public License for more details.
+ 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 Affero General Public License for more details.
-You should have received a copy of the GNU Affero General Public License
-along with this program. If not, see <http://www.gnu.org/licenses/>.
-*/
+ You should have received a copy of the GNU Affero General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
import de.lmu.ifi.dbs.elki.logging.LoggingConfiguration;
import de.lmu.ifi.dbs.elki.logging.LoggingUtil;
diff --git a/src/de/lmu/ifi/dbs/elki/gui/multistep/panels/OutputTabPanel.java b/src/de/lmu/ifi/dbs/elki/gui/multistep/panels/OutputTabPanel.java
index 7e599a62..acbde125 100644
--- a/src/de/lmu/ifi/dbs/elki/gui/multistep/panels/OutputTabPanel.java
+++ b/src/de/lmu/ifi/dbs/elki/gui/multistep/panels/OutputTabPanel.java
@@ -1,26 +1,27 @@
package de.lmu.ifi.dbs.elki.gui.multistep.panels;
+
/*
-This file is part of ELKI:
-Environment for Developing KDD-Applications Supported by Index-Structures
+ This file is part of ELKI:
+ Environment for Developing KDD-Applications Supported by Index-Structures
-Copyright (C) 2011
-Ludwig-Maximilians-Universität München
-Lehr- und Forschungseinheit für Datenbanksysteme
-ELKI Development Team
+ Copyright (C) 2011
+ Ludwig-Maximilians-Universität München
+ Lehr- und Forschungseinheit für Datenbanksysteme
+ ELKI Development Team
-This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU Affero 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 free software: you can redistribute it and/or modify
+ it under the terms of the GNU Affero 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 Affero General Public License for more details.
+ 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 Affero General Public License for more details.
-You should have received a copy of the GNU Affero General Public License
-along with this program. If not, see <http://www.gnu.org/licenses/>.
-*/
+ You should have received a copy of the GNU Affero General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
import java.lang.ref.WeakReference;
diff --git a/src/de/lmu/ifi/dbs/elki/gui/multistep/panels/ParameterTabPanel.java b/src/de/lmu/ifi/dbs/elki/gui/multistep/panels/ParameterTabPanel.java
index 175b9100..1bfe0000 100644
--- a/src/de/lmu/ifi/dbs/elki/gui/multistep/panels/ParameterTabPanel.java
+++ b/src/de/lmu/ifi/dbs/elki/gui/multistep/panels/ParameterTabPanel.java
@@ -1,34 +1,33 @@
package de.lmu.ifi.dbs.elki.gui.multistep.panels;
-/*
-This file is part of ELKI:
-Environment for Developing KDD-Applications Supported by Index-Structures
-
-Copyright (C) 2011
-Ludwig-Maximilians-Universität München
-Lehr- und Forschungseinheit für Datenbanksysteme
-ELKI Development Team
-
-This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU Affero 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 Affero General Public License for more details.
-
-You should have received a copy of the GNU Affero General Public License
-along with this program. If not, see <http://www.gnu.org/licenses/>.
-*/
+/*
+ This file is part of ELKI:
+ Environment for Developing KDD-Applications Supported by Index-Structures
+
+ Copyright (C) 2011
+ Ludwig-Maximilians-Universität München
+ Lehr- und Forschungseinheit für Datenbanksysteme
+ ELKI Development Team
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Affero 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 Affero General Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
-import java.util.BitSet;
-import java.util.List;
import javax.swing.BoxLayout;
import javax.swing.JButton;
@@ -39,13 +38,11 @@ import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import de.lmu.ifi.dbs.elki.gui.configurator.ConfiguratorPanel;
-import de.lmu.ifi.dbs.elki.gui.util.DynamicParameters;
import de.lmu.ifi.dbs.elki.logging.Logging;
import de.lmu.ifi.dbs.elki.utilities.FormatUtil;
import de.lmu.ifi.dbs.elki.utilities.designpattern.Observable;
import de.lmu.ifi.dbs.elki.utilities.designpattern.Observer;
import de.lmu.ifi.dbs.elki.utilities.designpattern.Observers;
-import de.lmu.ifi.dbs.elki.utilities.optionhandling.OptionID;
import de.lmu.ifi.dbs.elki.utilities.optionhandling.ParameterException;
import de.lmu.ifi.dbs.elki.utilities.optionhandling.UnspecifiedParameterException;
import de.lmu.ifi.dbs.elki.utilities.optionhandling.parameterization.ListParameterization;
@@ -131,7 +128,7 @@ public abstract class ParameterTabPanel extends JPanel implements Observable<Par
runButton.setMnemonic(KeyEvent.VK_R);
runButton.addActionListener(new ActionListener() {
@Override
- public void actionPerformed(@SuppressWarnings("unused") ActionEvent e) {
+ public void actionPerformed(ActionEvent e) {
Thread r = new Thread() {
@Override
public void run() {
@@ -183,6 +180,9 @@ public abstract class ParameterTabPanel extends JPanel implements Observable<Par
ListParameterization config = new ListParameterization();
parameterTable.appendParameters(config);
setParameters(config);
+ if(config.getErrors().size() > 0) {
+ reportErrors(config);
+ }
config.clearErrors();
parameterTable.setEnabled(true);
}
@@ -192,14 +192,9 @@ public abstract class ParameterTabPanel extends JPanel implements Observable<Par
*
* @param config Parameterization
*/
- public void setParameters(ListParameterization config) {
+ public void setParameters(Parameterization config) {
TrackParameters track = new TrackParameters(config);
configureStep(track);
- //config.logUnusedParameters();
- if(config.getErrors().size() > 0) {
- reportErrors(config);
- }
- List<Pair<OptionID, Object>> remainingParameters = config.getRemainingParameters();
// update parameter table
{
@@ -210,21 +205,6 @@ public abstract class ParameterTabPanel extends JPanel implements Observable<Par
parameterTable.addParameter(pair.first, pair.getSecond(), track);
}
//parameters.updateFromTrackParameters(track);
- // Add remaining parameters
- if(remainingParameters != null && !remainingParameters.isEmpty()) {
- DynamicParameters.RemainingOptions remo = new DynamicParameters.RemainingOptions();
- try {
- remo.setValue("FIXME"); //FormatUtil.format(remainingParameters, " "));
- }
- catch(ParameterException e) {
- logger.exception(e);
- }
- BitSet bits = new BitSet();
- bits.set(DynamicParameters.BIT_INVALID);
- bits.set(DynamicParameters.BIT_SYNTAX_ERROR);
- //parameters.addParameter(remo, remo.getValue(), bits, 0);
- parameterTable.addParameter(null, remo, track);
- }
parameterTable.revalidate();
parameterTable.setEnabled(true);
@@ -234,6 +214,15 @@ public abstract class ParameterTabPanel extends JPanel implements Observable<Par
updateStatus();
observers.notifyObservers(this);
}
+
+ /**
+ * Collect parameters
+ *
+ * @param params Parameter list to add to
+ */
+ public void appendParameters(ListParameterization params) {
+ parameterTable.appendParameters(params);
+ }
/**
* Report errors in a single error log record.
diff --git a/src/de/lmu/ifi/dbs/elki/gui/multistep/panels/SavedSettingsTabPanel.java b/src/de/lmu/ifi/dbs/elki/gui/multistep/panels/SavedSettingsTabPanel.java
new file mode 100644
index 00000000..147943eb
--- /dev/null
+++ b/src/de/lmu/ifi/dbs/elki/gui/multistep/panels/SavedSettingsTabPanel.java
@@ -0,0 +1,238 @@
+package de.lmu.ifi.dbs.elki.gui.multistep.panels;
+/*
+ This file is part of ELKI:
+ Environment for Developing KDD-Applications Supported by Index-Structures
+
+ Copyright (C) 2011
+ Ludwig-Maximilians-Universität München
+ Lehr- und Forschungseinheit für Datenbanksysteme
+ ELKI Development Team
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Affero 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 Affero General Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+import java.awt.GridBagConstraints;
+import java.awt.GridBagLayout;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.awt.event.KeyEvent;
+import java.io.IOException;
+import java.util.ArrayList;
+
+import javax.swing.AbstractListModel;
+import javax.swing.BoxLayout;
+import javax.swing.ComboBoxModel;
+import javax.swing.JButton;
+import javax.swing.JComboBox;
+import javax.swing.JPanel;
+
+import de.lmu.ifi.dbs.elki.gui.multistep.MultiStepGUI;
+import de.lmu.ifi.dbs.elki.gui.util.SavedSettingsFile;
+import de.lmu.ifi.dbs.elki.logging.Logging;
+import de.lmu.ifi.dbs.elki.utilities.optionhandling.parameterization.SerializedParameterization;
+
+/**
+ * Tab panel to manage saved settings.
+ *
+ * @author Erich Schubert
+ */
+public class SavedSettingsTabPanel extends JPanel {
+ /**
+ * Serial version
+ */
+ private static final long serialVersionUID = 1L;
+
+ /**
+ * Logger
+ */
+ protected static final Logging logger = Logging.getLogger(SavedSettingsTabPanel.class);
+
+ /**
+ * The settings file to display.
+ */
+ SavedSettingsFile store;
+
+ /**
+ * Settings combo box.
+ */
+ SettingsComboboxModel savedSettingsModel;
+
+ /**
+ * The combo box to use
+ */
+ JComboBox savedCombo;
+
+ /**
+ * The UI to set parameters on.
+ *
+ * TODO: Use an Interface instead?
+ */
+ private MultiStepGUI gui;
+
+ /**
+ * Constructor.
+ *
+ * @param store2 Settings store.
+ * @param gui2 UI to use
+ */
+ public SavedSettingsTabPanel(SavedSettingsFile store2, MultiStepGUI gui2) {
+ super();
+ this.store = store2;
+ this.gui = gui2;
+ this.setLayout(new GridBagLayout());
+ // Dropdown for saved settings
+ {
+ savedSettingsModel = new SettingsComboboxModel(store);
+ savedCombo = new JComboBox(savedSettingsModel);
+ savedCombo.setEditable(true);
+ savedCombo.setSelectedItem("[Saved Settings]");
+ GridBagConstraints constraints = new GridBagConstraints();
+ constraints.fill = GridBagConstraints.HORIZONTAL;
+ constraints.gridx = 0;
+ constraints.gridy = 0;
+ constraints.weightx = 1.0;
+ constraints.weighty = 0.01;
+ add(savedCombo, constraints);
+ }
+ // Button panel
+ {
+ JPanel buttonPanel = new JPanel();
+ buttonPanel.setLayout(new BoxLayout(buttonPanel, BoxLayout.X_AXIS));
+
+ // button to load settings
+ JButton loadButton = new JButton("Load");
+ loadButton.setMnemonic(KeyEvent.VK_L);
+ loadButton.addActionListener(new ActionListener() {
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ String key = savedSettingsModel.getSelectedItem();
+ ArrayList<String> settings = store.get(key);
+ SerializedParameterization config = new SerializedParameterization(settings);
+ gui.setParameters(config);
+ config.logUnusedParameters();
+ config.clearErrors();
+ }
+ });
+ buttonPanel.add(loadButton);
+ // button to save settings
+ JButton saveButton = new JButton("Save");
+ saveButton.setMnemonic(KeyEvent.VK_S);
+ saveButton.addActionListener(new ActionListener() {
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ String key = savedSettingsModel.getSelectedItem();
+ store.put(key, gui.serializeParameters());
+ try {
+ store.save();
+ }
+ catch(IOException e1) {
+ logger.exception(e1);
+ }
+ savedSettingsModel.update();
+ }
+ });
+ buttonPanel.add(saveButton);
+ // button to remove saved settings
+ JButton removeButton = new JButton("Remove");
+ removeButton.setMnemonic(KeyEvent.VK_E);
+ removeButton.addActionListener(new ActionListener() {
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ String key = savedSettingsModel.getSelectedItem();
+ store.remove(key);
+ try {
+ store.save();
+ }
+ catch(IOException e1) {
+ logger.exception(e1);
+ }
+ savedCombo.setSelectedItem("[Saved Settings]");
+ savedSettingsModel.update();
+ }
+ });
+ buttonPanel.add(removeButton);
+
+ GridBagConstraints constraints = new GridBagConstraints();
+ constraints.fill = GridBagConstraints.HORIZONTAL;
+ constraints.gridx = 0;
+ constraints.gridy = 1;
+ constraints.weightx = 1.0;
+ constraints.weighty = 0.01;
+ add(buttonPanel, constraints);
+ }
+ }
+
+ /**
+ * Class to interface between the saved settings list and a JComboBox
+ *
+ * @author Erich Schubert
+ *
+ * @apiviz.composedOf de.lmu.ifi.dbs.elki.gui.util.SavedSettingsFile
+ */
+ class SettingsComboboxModel extends AbstractListModel implements ComboBoxModel {
+ /**
+ * Serial version
+ */
+ private static final long serialVersionUID = 1L;
+
+ /**
+ * Settings storage
+ */
+ protected SavedSettingsFile store;
+
+ /**
+ * Selected entry
+ */
+ protected String selected = null;
+
+ /**
+ * Constructor
+ *
+ * @param store Store to access
+ */
+ public SettingsComboboxModel(SavedSettingsFile store) {
+ super();
+ this.store = store;
+ }
+
+ @Override
+ public String getSelectedItem() {
+ return selected;
+ }
+
+ @Override
+ public void setSelectedItem(Object anItem) {
+ if(anItem instanceof String) {
+ selected = (String) anItem;
+ }
+ }
+
+ @Override
+ public Object getElementAt(int index) {
+ return store.getElementAt(index).first;
+ }
+
+ @Override
+ public int getSize() {
+ return store.size();
+ }
+
+ /**
+ * Force an update
+ */
+ public void update() {
+ fireContentsChanged(this, 0, getSize() + 1);
+ }
+ }
+} \ No newline at end of file