[Schmitzm-commits] r298 - in trunk/src: schmitzm/geotools/gui schmitzm/jfree/chart schmitzm/jfree/chart/resource schmitzm/jfree/chart/resource/icons skrueger/geotools/resource/icons skrueger/swing
scm-commit@wald.intevation.org
scm-commit at wald.intevation.org
Tue Aug 11 14:18:01 CEST 2009
Author: alfonx
Date: 2009-08-11 14:18:00 +0200 (Tue, 11 Aug 2009)
New Revision: 298
Added:
trunk/src/schmitzm/jfree/chart/resource/
trunk/src/schmitzm/jfree/chart/resource/icons/
trunk/src/schmitzm/jfree/chart/resource/icons/chartActionZoomToSelected.png
Modified:
trunk/src/schmitzm/geotools/gui/SelectableFeatureTablePane.java
trunk/src/schmitzm/jfree/chart/SelectableChartPanel.java
trunk/src/skrueger/geotools/resource/icons/selection_add.png
trunk/src/skrueger/geotools/resource/icons/selection_clear.png
trunk/src/skrueger/geotools/resource/icons/selection_remove.png
trunk/src/skrueger/geotools/resource/icons/selection_set.png
trunk/src/skrueger/swing/TranslationEditJPanel.java
trunk/src/skrueger/swing/TranslationJTextField.java
Log:
* GP-Feature: Using DesignAtlasChartDialog starts rocking... Now it's possible to change the attributes of existing charts.
Modified: trunk/src/schmitzm/geotools/gui/SelectableFeatureTablePane.java
===================================================================
--- trunk/src/schmitzm/geotools/gui/SelectableFeatureTablePane.java 2009-08-10 22:10:07 UTC (rev 297)
+++ trunk/src/schmitzm/geotools/gui/SelectableFeatureTablePane.java 2009-08-11 12:18:00 UTC (rev 298)
@@ -71,15 +71,20 @@
public static final ImageIcon ICON_SELECTION_INVERT = new ImageIcon(
SelectableFeatureTablePane.class
.getResource("resource/icons/mActionInvertSelection.png"));
+
public static final ImageIcon ICON_SELECTED_TO_TOP = new ImageIcon(
SelectableFeatureTablePane.class
.getResource("resource/icons/mActionSelectedToTop.png"));
+
public static final ImageIcon ICON_UNSELECT = new ImageIcon(
SelectableFeatureTablePane.class
.getResource("resource/icons/mActionUnselectAttributes.png"));
- public static final ImageIcon ICON_ZOMM_TO_SELECTED = new ImageIcon(
+
+ public static final ImageIcon ICON_ZOOM_TO_SELECTED = new ImageIcon(
SelectableFeatureTablePane.class
.getResource("resource/icons/mActionZoomToSelected.png"));
+
+
private final JMapPane externalMapPane;
private JLabel statusLabel;
@@ -324,7 +329,7 @@
if (externalMapPane != null) {
AbstractAction zoomToSelection = new AbstractAction("",
- ICON_ZOMM_TO_SELECTED) {
+ ICON_ZOOM_TO_SELECTED) {
@Override
public void actionPerformed(ActionEvent e) {
Modified: trunk/src/schmitzm/jfree/chart/SelectableChartPanel.java
===================================================================
--- trunk/src/schmitzm/jfree/chart/SelectableChartPanel.java 2009-08-10 22:10:07 UTC (rev 297)
+++ trunk/src/schmitzm/jfree/chart/SelectableChartPanel.java 2009-08-11 12:18:00 UTC (rev 298)
@@ -35,6 +35,8 @@
import java.util.Iterator;
import java.util.Set;
+import javax.swing.ImageIcon;
+
import org.apache.log4j.Logger;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.entity.CategoryItemEntity;
@@ -77,7 +79,12 @@
public class SelectableChartPanel extends org.jfree.chart.ChartPanel {
/** Used for log and debug messages. */
private static Logger LOGGER = LangUtil.createLogger(SelectableChartPanel.class);
+
+ public static final ImageIcon ICON_ZOOM_TO_SELECTED = new ImageIcon(
+ SelectableChartPanel.class
+ .getResource("resource/icons/chartActionZoomToSelected.png"));
+
/**
* Types of window selection on chart panel.
*/
Added: trunk/src/schmitzm/jfree/chart/resource/icons/chartActionZoomToSelected.png
===================================================================
(Binary files differ)
Property changes on: trunk/src/schmitzm/jfree/chart/resource/icons/chartActionZoomToSelected.png
___________________________________________________________________
Name: svn:mime-type
+ image/png
Modified: trunk/src/skrueger/geotools/resource/icons/selection_add.png
===================================================================
(Binary files differ)
Modified: trunk/src/skrueger/geotools/resource/icons/selection_clear.png
===================================================================
(Binary files differ)
Modified: trunk/src/skrueger/geotools/resource/icons/selection_remove.png
===================================================================
(Binary files differ)
Modified: trunk/src/skrueger/geotools/resource/icons/selection_set.png
===================================================================
(Binary files differ)
Modified: trunk/src/skrueger/swing/TranslationEditJPanel.java
===================================================================
--- trunk/src/skrueger/swing/TranslationEditJPanel.java 2009-08-10 22:10:07 UTC (rev 297)
+++ trunk/src/skrueger/swing/TranslationEditJPanel.java 2009-08-11 12:18:00 UTC (rev 298)
@@ -72,8 +72,7 @@
/**
* Remembers all {@link JTextField} that have been created.
*/
- private Set<JTextField> langTextFields = new HashSet<JTextField>();
-
+ private Set<TranslationJTextField> langTextFields = new HashSet<TranslationJTextField>();
private WeakHashMap<ActionListener, ActionListener> actionListeners = new WeakHashMap<ActionListener, ActionListener>();
/**
@@ -107,8 +106,27 @@
.setBorder(BorderFactory.createEmptyBorder(6, 6, 6, 6));
add(questionLable, BorderLayout.NORTH);
}
+
+ /**
+ * Add listeners
+ */
}
+ /**
+ * Creates a {@link JPanel} that asks the user for the translation of a
+ * String in several languages and additionally puts a {@link JLabel} with a
+ * question at the {@link JPanel}'s first row.
+ *
+ * <br/>
+ * This constructor also sets a TitledBorder with the given title.
+ */
+ public TranslationEditJPanel(Translation title, List<String> languages2,
+ String borderTitle) {
+ this(title, languages2);
+
+ setBorder(BorderFactory.createTitledBorder(borderTitle));
+ }
+
private JPanel getTranslationGrid() {
if (translationGrid == null) {
translationGrid = new JPanel(new SpringLayout());
@@ -128,7 +146,7 @@
translationGrid.add(langDesc);
translationGrid.add(langTextField);
- langTextFields.add(langTextField);
+ langTextFields.add(langTextField);
}
// Lay out the panel.
@@ -149,6 +167,15 @@
return trans;
}
+ /**
+ * TODO Is never called?!
+ */
+ public void dispose() {
+ for (TranslationJTextField f: langTextFields) {
+ f.dispose();
+ }
+ }
+
public void addTranslationChangeListener(final ActionListener al) {
final ActionListener actionListener = new ActionListener() {
Modified: trunk/src/skrueger/swing/TranslationJTextField.java
===================================================================
--- trunk/src/skrueger/swing/TranslationJTextField.java 2009-08-10 22:10:07 UTC (rev 297)
+++ trunk/src/skrueger/swing/TranslationJTextField.java 2009-08-11 12:18:00 UTC (rev 298)
@@ -30,6 +30,8 @@
package skrueger.swing;
import java.awt.Color;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
import javax.swing.JTextArea;
import javax.swing.JTextField;
@@ -41,7 +43,9 @@
import skrueger.i8n.Translation;
/**
- * A {@link JTextArea} that signals red when it is not filled by a value.
+ * A {@link JTextArea} that signals red when it is not filled by a value. A
+ * listener is automatically registered with the {@link Translation} to update
+ * on {@link Translation} changes.
*
* @author Stefan Alfons Krüger
*
@@ -52,6 +56,11 @@
int wasValid = 99; // 0 = false, 1 = true, 99 = undefined
private String langCode;
private Translation trans;
+ /**
+ * Listens to changes in the {@link Translation} and update the
+ * {@link JTextField}
+ */
+ private final ActionListener translationChangeActionListener;
/**
* This RED indicates a missing translation
@@ -66,7 +75,7 @@
* @param trans
* @param langCode
*/
- public TranslationJTextField(Translation trans, String langCode) {
+ public TranslationJTextField(final Translation trans, final String langCode) {
super(trans.get(langCode));
this.trans = trans;
this.langCode = langCode;
@@ -102,9 +111,42 @@
checkValid();
}
});
+
+ /**
+ * Add a Listener to the Translation, so the JTextField can update on
+ * Translation changes.
+ */
+ translationChangeActionListener = new ActionListener() {
+
+ @Override
+ public void actionPerformed(ActionEvent e) {
+// LOGGER.debug("ActionListener called ");
+ String newString = trans.get(langCode);
+ if (newString == null)
+ newString = "";
+ if ((newString != null && !newString.equals(getText()))) {
+ LOGGER.debug("Setting text to " + newString
+ + " becuse oldString was " + getText());
+ setText(newString);
+ }
+ }
+
+ };
+
+ LOGGER.debug("registering translationChangeActionListener");
+ trans.addTranslationChangeListener(translationChangeActionListener);
}
/**
+ * TODO Is never called. Should be called!
+ */
+ public void dispose() {
+ boolean b = trans
+ .removeTranslationChangeListener(translationChangeActionListener);
+ LOGGER.debug("removing translationChangeActionListener = " + b);
+ }
+
+ /**
* If the getText().equals("") sets background color to red. The method also
* stored the changed string into the {@link Translation} object.
*/
@@ -120,7 +162,6 @@
wasValid = 0;
}
-
} else {
// valid
if (wasValid != 1) {
@@ -131,7 +172,7 @@
// Directly store the change in the Translation Object
}
-// LOGGER.debug("putting '"+trimmedText+"' into the translation");
+ // LOGGER.debug("putting '"+trimmedText+"' into the translation");
trans.put(langCode, trimmedText);
}
}
More information about the Schmitzm-commits
mailing list