Revision: 6194
http://sourceforge.net/p/jump-pilot/code/6194
Author: michaudm
Date: 2019-09-21 07:08:28 +0000 (Sat, 21 Sep 2019)
Log Message:
-----------
Improve SetAtribute extension : add ComboBox capability
Modified Paths:
--------------
plug-ins/SetAttributesPlugin/trunk/src/org/openjump/ext/setattributes/SetAttributesButtonActionListener.java
plug-ins/SetAttributesPlugin/trunk/src/org/openjump/ext/setattributes/SetAttributesExtension.java
plug-ins/SetAttributesPlugin/trunk/src/org/openjump/ext/setattributes/SetAttributesToolbox.java
plug-ins/SetAttributesPlugin/trunk/src/org/openjump/ext/setattributes/SetOfAttributes.java
Added Paths:
-----------
plug-ins/SetAttributesPlugin/trunk/doc/
plug-ins/SetAttributesPlugin/trunk/doc/OpenJUMP-JeuxAttributs.odt
plug-ins/SetAttributesPlugin/trunk/doc/OpenJUMP-JeuxAttributs.pdf
plug-ins/SetAttributesPlugin/trunk/src/org/openjump/ext/setattributes/ListOfSetOfAttributes.java
plug-ins/SetAttributesPlugin/trunk/src/org/openjump/ext/setattributes/SetAttributesComboItemListener.java
Added: plug-ins/SetAttributesPlugin/trunk/doc/OpenJUMP-JeuxAttributs.odt
===================================================================
(Binary files differ)
Index: plug-ins/SetAttributesPlugin/trunk/doc/OpenJUMP-JeuxAttributs.odt
===================================================================
--- plug-ins/SetAttributesPlugin/trunk/doc/OpenJUMP-JeuxAttributs.odt
2019-08-10 10:09:24 UTC (rev 6193)
+++ plug-ins/SetAttributesPlugin/trunk/doc/OpenJUMP-JeuxAttributs.odt
2019-09-21 07:08:28 UTC (rev 6194)
Property changes on:
plug-ins/SetAttributesPlugin/trunk/doc/OpenJUMP-JeuxAttributs.odt
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+application/octet-stream
\ No newline at end of property
Added: plug-ins/SetAttributesPlugin/trunk/doc/OpenJUMP-JeuxAttributs.pdf
===================================================================
(Binary files differ)
Index: plug-ins/SetAttributesPlugin/trunk/doc/OpenJUMP-JeuxAttributs.pdf
===================================================================
--- plug-ins/SetAttributesPlugin/trunk/doc/OpenJUMP-JeuxAttributs.pdf
2019-08-10 10:09:24 UTC (rev 6193)
+++ plug-ins/SetAttributesPlugin/trunk/doc/OpenJUMP-JeuxAttributs.pdf
2019-09-21 07:08:28 UTC (rev 6194)
Property changes on:
plug-ins/SetAttributesPlugin/trunk/doc/OpenJUMP-JeuxAttributs.pdf
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+application/octet-stream
\ No newline at end of property
Added:
plug-ins/SetAttributesPlugin/trunk/src/org/openjump/ext/setattributes/ListOfSetOfAttributes.java
===================================================================
---
plug-ins/SetAttributesPlugin/trunk/src/org/openjump/ext/setattributes/ListOfSetOfAttributes.java
(rev 0)
+++
plug-ins/SetAttributesPlugin/trunk/src/org/openjump/ext/setattributes/ListOfSetOfAttributes.java
2019-09-21 07:08:28 UTC (rev 6194)
@@ -0,0 +1,63 @@
+package org.openjump.ext.setattributes;
+
+import javax.swing.*;
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlRootElement;
+import java.awt.*;
+import java.io.File;
+import java.util.*;
+import java.util.List;
+
+/**
+ * Contains a list of SetOfAttributes.
+ * Useful to build ComboBoxes containing sevral buttons
+ */
+@XmlRootElement(name="combo")
+public class ListOfSetOfAttributes {
+
+ @XmlAttribute
+ String text = "";
+
+ @XmlElement(name="button")
+ List<SetOfAttributes> listOfSets = new ArrayList<>();
+
+ public JComboBox<SetOfAttributes> createCombo(File dir) {
+ JComboBox<SetOfAttributes> comboBox = new JComboBox<>();
+ Vector<SetOfAttributes> vector = new Vector<>(listOfSets);
+ comboBox.setModel(new DefaultComboBoxModel<>(vector));
+ comboBox.setRenderer(new IconRenderer(dir));
+ return comboBox;
+ }
+
+ class IconRenderer extends DefaultListCellRenderer {
+
+ private Map<String, ImageIcon> iconMap = new HashMap<>();
+ private Color background = new Color(0, 100, 255, 15);
+ private Color defaultBackground = (Color)
UIManager.get("List.background");
+
+
+ public IconRenderer(File dir) {
+ for (SetOfAttributes setOfAttributes : listOfSets) {
+ ImageIcon icon = new
ImageIcon(dir.getPath()+"/"+setOfAttributes.icon);
+ if (icon.getImageLoadStatus() == MediaTracker.COMPLETE) {
+ iconMap.put(setOfAttributes.text, icon);
+ }
+ }
+ }
+
+ @Override
+ public Component getListCellRendererComponent(JList<?> list, Object
value, int index,
+ boolean isSelected,
boolean cellHasFocus) {
+ super.getListCellRendererComponent(list, value, index, isSelected,
cellHasFocus);
+ SetOfAttributes set = (SetOfAttributes) value;
+ this.setText(set.text);
+ this.setIcon(iconMap.get(set.text));
+ if (!isSelected) {
+ this.setBackground(index % 2 == 0 ? background :
defaultBackground);
+ }
+ return this;
+ }
+ }
+
+}
Modified:
plug-ins/SetAttributesPlugin/trunk/src/org/openjump/ext/setattributes/SetAttributesButtonActionListener.java
===================================================================
---
plug-ins/SetAttributesPlugin/trunk/src/org/openjump/ext/setattributes/SetAttributesButtonActionListener.java
2019-08-10 10:09:24 UTC (rev 6193)
+++
plug-ins/SetAttributesPlugin/trunk/src/org/openjump/ext/setattributes/SetAttributesButtonActionListener.java
2019-09-21 07:08:28 UTC (rev 6194)
@@ -40,117 +40,6 @@
@Override
public void actionPerformed(ActionEvent e) {
- SelectionManager selectionManager =
pluginContext.getLayerViewPanel().getSelectionManager();
-
pluginContext.getLayerManager().getUndoableEditReceiver().startReceiving();
- try {
- int editableLayers = 0;
- int editableFeatures = 0;
- Pattern layerPattern = null;
- // If layer is not null
- if (setOfAttributes.getLayer() != null) {
- try {
- // create a pattern to read this specific layer name
- layerPattern =
Pattern.compile(Pattern.quote(setOfAttributes.getLayer()));
- // then try to interpret * as glob
- if (setOfAttributes.getLayer().contains("*")) {
- layerPattern =
Pattern.compile(setOfAttributes.getLayer().replaceAll("\\*", ".*"));
- }
- // and finally, try to read layer name as a regex if it
starts and ends with a /
- if (setOfAttributes.getLayer().startsWith("/") &&
setOfAttributes.getLayer().endsWith("/")) {
- layerPattern =
Pattern.compile(setOfAttributes.getLayer().substring(1,
setOfAttributes.getLayer().length() - 1));
- }
- } catch (PatternSyntaxException pse) {
- pse.printStackTrace();
- }
- }
- final Map<Layer, Map<Feature, Feature>> mapSource = new
HashMap<Layer, Map<Feature, Feature>>();
- final Map<Layer, Map<Feature, Feature>> mapTarget = new
HashMap<Layer, Map<Feature, Feature>>();
- for (Layer lyr : selectionManager.getLayersWithSelectedItems()) {
- if (!lyr.isEditable()) continue;
- if (layerPattern != null &&
!layerPattern.matcher(lyr.getName()).matches()) continue;
- editableLayers++;
- Map<Feature, Feature> srcLayerMap = new HashMap<Feature,
Feature>();
- Map<Feature, Feature> tgtLayerMap = new HashMap<Feature,
Feature>();
- Collection<Feature> features =
selectionManager.getFeaturesWithSelectedItems(lyr);
- editableFeatures += features.size();
- for (Feature feature : features) {
- srcLayerMap.put(feature, feature.clone(false));
- }
-
tgtLayerMap.putAll(setOfAttributes.setAttributes(selectionManager.getFeaturesWithSelectedItems(lyr),
lyr.getName()));
- mapSource.put(lyr, srcLayerMap);
- mapTarget.put(lyr, tgtLayerMap);
- }
- if (unselect) {
- for (Layer lyr :
selectionManager.getLayersWithSelectedItems()) {
- selectionManager.unselectItems(lyr);
- }
- }
- if (editableLayers == 0 && setOfAttributes.getLayer() == null) {
-
pluginContext.getWorkbenchFrame().warnUser(I18N_.getText("set_attributes",
- "SetAttributesPlugIn.no-feature-found"));
- } else if (editableLayers == 0) {
-
pluginContext.getWorkbenchFrame().warnUser(I18N_.getMessage("set_attributes",
- "SetAttributesPlugIn.no-feature-found-in-layer",
- new Object[]{setOfAttributes.getLayer()}));
- } else if (editableFeatures == 0 && setOfAttributes.getLayer() ==
null) {
-
pluginContext.getWorkbenchFrame().warnUser(I18N_.getText("set_attributes",
- "SetAttributesPlugIn.no-feature-found"));
- } else if (editableFeatures == 0) {
-
pluginContext.getWorkbenchFrame().warnUser(I18N_.getMessage("set_attributes",
- "SetAttributesPlugIn.no-feature-found-in-layer",
- new Object[]{setOfAttributes.getLayer()}));
- } else {
- UndoableCommand command =
- new
UndoableCommand(I18N.get(SetAttributesPlugIn.class.getName())) {
- public void execute() {
- for (Layer lyr : mapTarget.keySet()) {
- Map<Feature,Feature> mapTgt =
mapTarget.get(lyr);
- Map<Feature,Feature> mapSrc =
mapSource.get(lyr);
- for (Feature feature : mapTgt.keySet()) {
- Feature newFeature =
mapTgt.get(feature);
- FeatureSchema schema =
feature.getSchema();
- for (SetAttribute setAtt :
setOfAttributes.attributes) {
- String name = setAtt.getName();
- if (schema.hasAttribute(name)) {
- feature.setAttribute(name,
newFeature.getAttribute(name));
- }
- }
- }
-
pluginContext.getLayerManager().fireFeaturesAttChanged(mapTgt.keySet(),
FeatureEventType.ATTRIBUTES_MODIFIED, lyr, mapSrc.values());
-
//pluginContext.getLayerManager().fireFeaturesChanged(map.keySet(),
FeatureEventType.ATTRIBUTES_MODIFIED, lyr);
- }
- pluginContext.getLayerViewPanel().repaint();
- }
-
- public void unexecute() {
- for (Layer lyr : mapSource.keySet()) {
- Map<Feature, Feature> mapSrc =
mapSource.get(lyr);
- Map<Feature, Feature> mapTgt =
mapTarget.get(lyr);
- for (Feature feature : mapSrc.keySet()) {
- Feature newFeature =
mapSrc.get(feature);
- FeatureSchema schema =
feature.getSchema();
- for (SetAttribute setAtt :
setOfAttributes.attributes) {
- String name = setAtt.getName();
- if (schema.hasAttribute(name)) {
- feature.setAttribute(name,
newFeature.getAttribute(name));
- }
- }
-
pluginContext.getLayerManager().fireFeaturesAttChanged(mapSrc.keySet(),
FeatureEventType.ATTRIBUTES_MODIFIED, lyr, mapTgt.values());
-
//pluginContext.getLayerManager().fireFeaturesChanged(mapSrc.keySet(),
FeatureEventType.ATTRIBUTES_MODIFIED, lyr);
- }
- }
- pluginContext.getLayerViewPanel().repaint();
- }
- };
-
- command.execute();
-
pluginContext.getLayerManager().getUndoableEditReceiver().receive(command.toUndoableEdit());
- }
- } catch (Exception exc) {
- LOG.warn(null, exc);
- pluginContext.getWorkbenchFrame().warnUser(exc.getMessage());
- } finally {
-
pluginContext.getLayerManager().getUndoableEditReceiver().stopReceiving();
- }
+ setOfAttributes.setAttributes(pluginContext, unselect);
}
}
Added:
plug-ins/SetAttributesPlugin/trunk/src/org/openjump/ext/setattributes/SetAttributesComboItemListener.java
===================================================================
---
plug-ins/SetAttributesPlugin/trunk/src/org/openjump/ext/setattributes/SetAttributesComboItemListener.java
(rev 0)
+++
plug-ins/SetAttributesPlugin/trunk/src/org/openjump/ext/setattributes/SetAttributesComboItemListener.java
2019-09-21 07:08:28 UTC (rev 6194)
@@ -0,0 +1,29 @@
+package org.openjump.ext.setattributes;
+
+import com.vividsolutions.jump.workbench.plugin.PlugInContext;
+
+import javax.swing.*;
+import java.awt.event.ItemEvent;
+import java.awt.event.ItemListener;
+
+public class SetAttributesComboItemListener implements ItemListener {
+
+ final PlugInContext pluginContext;
+ final boolean unselect;
+
+ SetAttributesComboItemListener(final PlugInContext pluginContext,
+ final boolean unselect) {
+ this.pluginContext = pluginContext;
+ this.unselect = unselect;
+ }
+
+ public void itemStateChanged(ItemEvent itemEvent) {
+ int state = itemEvent.getStateChange();
+ if (state == ItemEvent.SELECTED) {
+ SetOfAttributes setOfAttributes =
(SetOfAttributes)itemEvent.getItem();
+ setOfAttributes.setAttributes(pluginContext, unselect);
+ }
+ ((JComboBox)itemEvent.getSource()).setPopupVisible(false);
+
+ }
+}
Modified:
plug-ins/SetAttributesPlugin/trunk/src/org/openjump/ext/setattributes/SetAttributesExtension.java
===================================================================
---
plug-ins/SetAttributesPlugin/trunk/src/org/openjump/ext/setattributes/SetAttributesExtension.java
2019-08-10 10:09:24 UTC (rev 6193)
+++
plug-ins/SetAttributesPlugin/trunk/src/org/openjump/ext/setattributes/SetAttributesExtension.java
2019-09-21 07:08:28 UTC (rev 6194)
@@ -8,6 +8,9 @@
* buttons to "fill" a set of consistent attribute values for selected
* features
*/
+// 0.8.0 [2019-09-15] add combo boxes capabilities
+// 0.7.1 [2015- - ]
+// 0.7.0 [2015-06-13]
public class SetAttributesExtension extends Extension {
public String getName() {
@@ -15,7 +18,7 @@
}
public String getVersion() {
- return "0.7.0 (2015-06-13)";
+ return "0.8.0 (2019-09-16)";
}
public void configure(PlugInContext context) throws Exception {
Modified:
plug-ins/SetAttributesPlugin/trunk/src/org/openjump/ext/setattributes/SetAttributesToolbox.java
===================================================================
---
plug-ins/SetAttributesPlugin/trunk/src/org/openjump/ext/setattributes/SetAttributesToolbox.java
2019-08-10 10:09:24 UTC (rev 6193)
+++
plug-ins/SetAttributesPlugin/trunk/src/org/openjump/ext/setattributes/SetAttributesToolbox.java
2019-09-21 07:08:28 UTC (rev 6194)
@@ -50,6 +50,9 @@
@XmlAttribute (required=false)
boolean unselect;
+ @XmlElement (name="combo")
+ List<ListOfSetOfAttributes> comboboxes;
+
@XmlElement (name="button")
List<SetOfAttributes> buttons;
@@ -64,34 +67,47 @@
constraints.gridy = 0;
constraints.insets = new Insets(1,1,1,1);
final PlugInContext pluginContext = context.createPlugInContext();
- for (final SetOfAttributes setOfAttributes : buttons) {
- ImageIcon icon = new
ImageIcon(dir.getPath()+"/"+setOfAttributes.icon);
- final JButton button;
- if (icon.getImageLoadStatus() == MediaTracker.COMPLETE) {
- button = new JButton(icon);
- } else {
- button = new JButton(setOfAttributes.text);
- if (setOfAttributes.getBackgroundColor()!=null) {
- button.setBackground(setOfAttributes.getBackgroundColor());
- //button.setContentAreaFilled(false);
- button.setOpaque(true);
+ if (comboboxes != null) {
+ for (final ListOfSetOfAttributes listOfSetOfAttributes :
comboboxes) {
+ final JComboBox<SetOfAttributes> combo =
listOfSetOfAttributes.createCombo(dir);
+ constraints.gridx = 0;
+ dialog.getContentPane().add(new
JLabel(listOfSetOfAttributes.text), constraints);
+ constraints.gridx = 1;
+ combo.addItemListener(new
SetAttributesComboItemListener(pluginContext, unselect));
+ dialog.getContentPane().add(combo, constraints);
+ constraints.gridy += 1;
+ }
+ }
+ if (buttons != null) {
+ for (final SetOfAttributes setOfAttributes : buttons) {
+ ImageIcon icon = new ImageIcon(dir.getPath() + "/" +
setOfAttributes.icon);
+ final JButton button;
+ if (icon.getImageLoadStatus() == MediaTracker.COMPLETE) {
+ button = new JButton(icon);
+ } else {
+ button = new JButton(setOfAttributes.text);
+ if (setOfAttributes.getBackgroundColor() != null) {
+
button.setBackground(setOfAttributes.getBackgroundColor());
+ //button.setContentAreaFilled(false);
+ button.setOpaque(true);
+ }
}
- }
- if (setOfAttributes.getAttributes() == null ||
setOfAttributes.getAttributes().size()==0) {
- button.setEnabled(false);
- }
- button.setMargin(new Insets(0, 0, 0, 0));
- button.setPreferredSize(new Dimension(iconWidth, iconHeight));
- button.setToolTipText(setOfAttributes.getTooltip());
+ if (setOfAttributes.getAttributes() == null ||
setOfAttributes.getAttributes().size() == 0) {
+ button.setEnabled(false);
+ }
+ button.setMargin(new Insets(0, 0, 0, 0));
+ button.setPreferredSize(new Dimension(iconWidth, iconHeight));
+ button.setToolTipText(setOfAttributes.getTooltip());
- button.addActionListener(new
SetAttributesButtonActionListener(pluginContext, setOfAttributes, unselect));
+ button.addActionListener(new
SetAttributesButtonActionListener(pluginContext, setOfAttributes, unselect));
- button.addMouseListener(new
SetAttributesButtonMouseListener(setOfAttributes, button));
- dialog.getContentPane().add(button, constraints);
- constraints.gridx += 1;
- if (constraints.gridx >= maxCol) {
- constraints.gridx = 0;
- constraints.gridy += 1;
+ button.addMouseListener(new
SetAttributesButtonMouseListener(setOfAttributes, button));
+ dialog.getContentPane().add(button, constraints);
+ constraints.gridx += 1;
+ if (constraints.gridx >= maxCol) {
+ constraints.gridx = 0;
+ constraints.gridy += 1;
+ }
}
}
return dialog;
Modified:
plug-ins/SetAttributesPlugin/trunk/src/org/openjump/ext/setattributes/SetOfAttributes.java
===================================================================
---
plug-ins/SetAttributesPlugin/trunk/src/org/openjump/ext/setattributes/SetOfAttributes.java
2019-08-10 10:09:24 UTC (rev 6193)
+++
plug-ins/SetAttributesPlugin/trunk/src/org/openjump/ext/setattributes/SetOfAttributes.java
2019-09-21 07:08:28 UTC (rev 6194)
@@ -5,6 +5,11 @@
import com.vividsolutions.jump.feature.Feature;
import com.vividsolutions.jump.feature.FeatureSchema;
import com.vividsolutions.jump.util.FlexibleDateParser;
+import com.vividsolutions.jump.workbench.model.FeatureEventType;
+import com.vividsolutions.jump.workbench.model.Layer;
+import com.vividsolutions.jump.workbench.model.UndoableCommand;
+import com.vividsolutions.jump.workbench.plugin.PlugInContext;
+import com.vividsolutions.jump.workbench.ui.SelectionManager;
import org.apache.log4j.Logger;
import javax.swing.*;
@@ -17,9 +22,11 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import java.util.regex.Pattern;
+import java.util.regex.PatternSyntaxException;
/**
- * Contains information or an attribute set.
+ * Contains information of an attribute set.
*/
@XmlRootElement (name="button")
public class SetOfAttributes {
@@ -120,9 +127,11 @@
if (!checkDimension(feature)) {
continue;
}
- //Feature newFeature = map.get(feature);
AttributeType type = schema.getAttributeType(name);
- if (type == AttributeType.STRING) {
+ if (value == null) {
+ newFeature.setAttribute(name, null);
+ }
+ else if (type == AttributeType.STRING) {
newFeature.setAttribute(name, value);
}
else if (type == AttributeType.INTEGER) {
@@ -154,6 +163,121 @@
return map;
}
+ public void setAttributes(final PlugInContext pluginContext, final boolean
unselect) {
+ SelectionManager selectionManager =
pluginContext.getLayerViewPanel().getSelectionManager();
+
pluginContext.getLayerManager().getUndoableEditReceiver().startReceiving();
+ try {
+ int editableLayers = 0;
+ int editableFeatures = 0;
+ Pattern layerPattern = null;
+ // If layer is not null
+ if (getLayer() != null) {
+ try {
+ // create a pattern to read this specific layer name
+ layerPattern = Pattern.compile(Pattern.quote(getLayer()));
+ // then try to interpret * as glob
+ if (getLayer().contains("*")) {
+ layerPattern =
Pattern.compile(getLayer().replaceAll("\\*", ".*"));
+ }
+ // and finally, try to read layer name as a regex if it
starts and ends with a /
+ if (getLayer().startsWith("/") &&
getLayer().endsWith("/")) {
+ layerPattern = Pattern.compile(getLayer().substring(1,
getLayer().length() - 1));
+ }
+ } catch (PatternSyntaxException pse) {
+ pse.printStackTrace();
+ }
+ }
+ final Map<Layer, Map<Feature, Feature>> mapSource = new
HashMap<Layer, Map<Feature, Feature>>();
+ final Map<Layer, Map<Feature, Feature>> mapTarget = new
HashMap<Layer, Map<Feature, Feature>>();
+ for (Layer lyr : selectionManager.getLayersWithSelectedItems()) {
+ if (!lyr.isEditable()) continue;
+ if (layerPattern != null &&
!layerPattern.matcher(lyr.getName()).matches()) continue;
+ editableLayers++;
+ Map<Feature, Feature> srcLayerMap = new HashMap<Feature,
Feature>();
+ Map<Feature, Feature> tgtLayerMap = new HashMap<Feature,
Feature>();
+ Collection<Feature> features =
selectionManager.getFeaturesWithSelectedItems(lyr);
+ editableFeatures += features.size();
+ for (Feature feature : features) {
+ srcLayerMap.put(feature, feature.clone(false));
+ }
+
tgtLayerMap.putAll(setAttributes(selectionManager.getFeaturesWithSelectedItems(lyr),
lyr.getName()));
+ mapSource.put(lyr, srcLayerMap);
+ mapTarget.put(lyr, tgtLayerMap);
+ }
+ if (unselect) {
+ for (Layer lyr :
selectionManager.getLayersWithSelectedItems()) {
+ selectionManager.unselectItems(lyr);
+ }
+ }
+ if (editableLayers == 0 && getLayer() == null) {
+
pluginContext.getWorkbenchFrame().warnUser(I18N_.getText("set_attributes",
+ "SetAttributesPlugIn.no-feature-found"));
+ } else if (editableLayers == 0) {
+
pluginContext.getWorkbenchFrame().warnUser(I18N_.getMessage("set_attributes",
+ "SetAttributesPlugIn.no-feature-found-in-layer",
+ new Object[]{getLayer()}));
+ } else if (editableFeatures == 0 && getLayer() == null) {
+
pluginContext.getWorkbenchFrame().warnUser(I18N_.getText("set_attributes",
+ "SetAttributesPlugIn.no-feature-found"));
+ } else if (editableFeatures == 0) {
+
pluginContext.getWorkbenchFrame().warnUser(I18N_.getMessage("set_attributes",
+ "SetAttributesPlugIn.no-feature-found-in-layer",
+ new Object[]{getLayer()}));
+ } else {
+ UndoableCommand command =
+ new
UndoableCommand(I18N.get(SetAttributesPlugIn.class.getName())) {
+ public void execute() {
+ for (Layer lyr : mapTarget.keySet()) {
+ Map<Feature,Feature> mapTgt =
mapTarget.get(lyr);
+ Map<Feature,Feature> mapSrc =
mapSource.get(lyr);
+ for (Feature feature : mapTgt.keySet()) {
+ Feature newFeature =
mapTgt.get(feature);
+ FeatureSchema schema =
feature.getSchema();
+ for (SetAttribute setAtt : attributes)
{
+ String name = setAtt.getName();
+ if (schema.hasAttribute(name)) {
+ feature.setAttribute(name,
newFeature.getAttribute(name));
+ }
+ }
+ }
+
pluginContext.getLayerManager().fireFeaturesAttChanged(mapTgt.keySet(),
FeatureEventType.ATTRIBUTES_MODIFIED, lyr, mapSrc.values());
+
//pluginContext.getLayerManager().fireFeaturesChanged(map.keySet(),
FeatureEventType.ATTRIBUTES_MODIFIED, lyr);
+ }
+ pluginContext.getLayerViewPanel().repaint();
+ }
+
+ public void unexecute() {
+ for (Layer lyr : mapSource.keySet()) {
+ Map<Feature, Feature> mapSrc =
mapSource.get(lyr);
+ Map<Feature, Feature> mapTgt =
mapTarget.get(lyr);
+ for (Feature feature : mapSrc.keySet()) {
+ Feature newFeature =
mapSrc.get(feature);
+ FeatureSchema schema =
feature.getSchema();
+ for (SetAttribute setAtt : attributes)
{
+ String name = setAtt.getName();
+ if (schema.hasAttribute(name)) {
+ feature.setAttribute(name,
newFeature.getAttribute(name));
+ }
+ }
+
pluginContext.getLayerManager().fireFeaturesAttChanged(mapSrc.keySet(),
FeatureEventType.ATTRIBUTES_MODIFIED, lyr, mapTgt.values());
+
//pluginContext.getLayerManager().fireFeaturesChanged(mapSrc.keySet(),
FeatureEventType.ATTRIBUTES_MODIFIED, lyr);
+ }
+ }
+ pluginContext.getLayerViewPanel().repaint();
+ }
+ };
+
+ command.execute();
+
pluginContext.getLayerManager().getUndoableEditReceiver().receive(command.toUndoableEdit());
+ }
+ } catch (Exception exc) {
+ LOG.warn(null, exc);
+ pluginContext.getWorkbenchFrame().warnUser(exc.getMessage());
+ } finally {
+
pluginContext.getLayerManager().getUndoableEditReceiver().stopReceiving();
+ }
+ }
+
boolean checkDimension(Feature feature) {
if (dimension > -1) {
return feature.getGeometry().getDimension() == dimension;
_______________________________________________
Jump-pilot-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jump-pilot-devel