[Pixelle-commit] SF.net SVN: pixelle:[176] trunk/pixelle/src/com/mebigfatguy/pixelle
Brought to you by:
dbrosius
|
From: <dbr...@us...> - 2008-11-14 05:50:39
|
Revision: 176
http://pixelle.svn.sourceforge.net/pixelle/?rev=176&view=rev
Author: dbrosius
Date: 2008-11-14 05:50:34 +0000 (Fri, 14 Nov 2008)
Log Message:
-----------
make current selection less kludgy
Modified Paths:
--------------
trunk/pixelle/src/com/mebigfatguy/pixelle/AlgorithmArchiver.java
trunk/pixelle/src/com/mebigfatguy/pixelle/dialogs/PixelleExpressionDialog.java
Modified: trunk/pixelle/src/com/mebigfatguy/pixelle/AlgorithmArchiver.java
===================================================================
--- trunk/pixelle/src/com/mebigfatguy/pixelle/AlgorithmArchiver.java 2008-11-14 05:39:04 UTC (rev 175)
+++ trunk/pixelle/src/com/mebigfatguy/pixelle/AlgorithmArchiver.java 2008-11-14 05:50:34 UTC (rev 176)
@@ -51,6 +51,7 @@
private static final String SYSTEM_ALGO_XML_PATH = "/com/mebigfatguy/pixelle/resources/algorithms.xml";
private static final String SYSTEM_ALGO_XSD_PATH = "/com/mebigfatguy/pixelle/resources/algorithms.xsd";
public static final String GROUP = "group";
+ public static final String CURRENT = "current_";
public static final String ALGORITHM = "algorithm";
public static final String COMPONENT = "component";
public static final String NAME = "name";
@@ -85,13 +86,15 @@
private void populateMenuAlgorithms(JPopupMenu menu, Map<String, Map<String, Map<PixelleComponent, String>>> algorithms, ActionListener l) {
for (final Map.Entry<String, Map<String, Map<PixelleComponent, String>>> entry : algorithms.entrySet()) {
String groupName = entry.getKey();
- JMenu group = new JMenu(groupName);
- menu.add(group);
- for (final String algos : entry.getValue().keySet()) {
- JMenuItem algoItem = new JMenuItem(algos);
- algoItem.putClientProperty(NAME, groupName);
- algoItem.addActionListener(l);
- group.add(algoItem);
+ if (!CURRENT.equals(groupName)) {
+ JMenu group = new JMenu(groupName);
+ menu.add(group);
+ for (final String algos : entry.getValue().keySet()) {
+ JMenuItem algoItem = new JMenuItem(algos);
+ algoItem.putClientProperty(NAME, groupName);
+ algoItem.addActionListener(l);
+ group.add(algoItem);
+ }
}
}
}
@@ -132,6 +135,14 @@
group.put(algorithmName, new HashMap<PixelleComponent, String>(algorithm));
}
+ public void setCurrent(Map<PixelleComponent, String> algorithm) {
+ addAlgorithm(AlgorithmArchiver.CURRENT, AlgorithmArchiver.CURRENT, algorithm);
+ }
+
+ public Map<PixelleComponent, String> getCurrent() {
+ return getAlgorithm(AlgorithmArchiver.CURRENT, AlgorithmArchiver.CURRENT);
+ }
+
public void removeAlgorithm(String group, String name) {
}
Modified: trunk/pixelle/src/com/mebigfatguy/pixelle/dialogs/PixelleExpressionDialog.java
===================================================================
--- trunk/pixelle/src/com/mebigfatguy/pixelle/dialogs/PixelleExpressionDialog.java 2008-11-14 05:39:04 UTC (rev 175)
+++ trunk/pixelle/src/com/mebigfatguy/pixelle/dialogs/PixelleExpressionDialog.java 2008-11-14 05:50:34 UTC (rev 176)
@@ -21,8 +21,6 @@
import java.awt.BorderLayout;
import java.awt.Container;
import java.awt.GridLayout;
-import java.awt.Menu;
-import java.awt.MenuItem;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseAdapter;
@@ -42,7 +40,6 @@
import javax.swing.JPanel;
import javax.swing.JPopupMenu;
import javax.swing.JTextField;
-import javax.swing.MenuElement;
import com.mebigfatguy.pixelle.AlgorithmArchiver;
import com.mebigfatguy.pixelle.PixelleBundle;
@@ -55,7 +52,6 @@
private static final long serialVersionUID = -420573137466431577L;
private static final int NUM_LABELS = 5;
- private static final String CURRENT = "current_";
private final JLabel lhs[] =
{
@@ -154,7 +150,7 @@
}
});
try {
- Map<PixelleComponent, String> algorithms = AlgorithmArchiver.getArchiver().getAlgorithm(CURRENT, CURRENT);
+ Map<PixelleComponent, String> algorithms = AlgorithmArchiver.getArchiver().getCurrent();
if (algorithms != null) {
editor[0].setText(algorithms.get(PixelleComponent.RED));
editor[1].setText(algorithms.get(PixelleComponent.GREEN));
@@ -248,7 +244,7 @@
public void actionPerformed(ActionEvent ae) {
Map<PixelleComponent, String> algorithm = getAlgorithms();
AlgorithmArchiver archiver = AlgorithmArchiver.getArchiver();
- archiver.addAlgorithm(CURRENT, CURRENT, algorithm);
+ archiver.setCurrent(algorithm);
archiver.save();
clickedOK = true;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|