Skip to content

Commit 792ad6c

Browse files
committed
split FeatureInfoPlugIn into FeatureInfoPlugin (multiple frames allowed) and UniqueFeatureInfoFrame (single frame)
1 parent b36fbb5 commit 792ad6c

File tree

3 files changed

+77
-4
lines changed

3 files changed

+77
-4
lines changed

Diff for: scripts/default-plugins.xml

+6
Original file line numberDiff line numberDiff line change
@@ -1595,6 +1595,12 @@
15951595

15961596

15971597
<!-- ================ LayerView Popup Menu =============================== -->
1598+
<plug-in>
1599+
com.vividsolutions.jump.workbench.ui.plugin.UniqueFeatureInfoPlugIn
1600+
<menus>
1601+
<layerview-popup install="true" />
1602+
</menus>
1603+
</plug-in>
15981604
<plug-in>
15991605
com.vividsolutions.jump.workbench.ui.plugin.FeatureInfoPlugIn
16001606
<menus>

Diff for: src/com/vividsolutions/jump/workbench/ui/plugin/FeatureInfoPlugIn.java

+1-4
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@
3333

3434
package com.vividsolutions.jump.workbench.ui.plugin;
3535

36-
import java.awt.event.KeyEvent;
3736
import java.util.Iterator;
3837

3938
import javax.swing.ImageIcon;
@@ -55,11 +54,9 @@ public class FeatureInfoPlugIn extends AbstractPlugIn {
5554
private static EnableCheck checker = null;
5655

5756
public FeatureInfoPlugIn() {
58-
this.setShortcutKeys(KeyEvent.VK_I);
59-
this.setShortcutModifiers(KeyEvent.ALT_MASK);
6057
}
6158

62-
public static final ImageIcon ICON = IconLoader.icon("information_16x16.png");
59+
public static final ImageIcon ICON = IconLoader.icon("information_multi_20x20.png");
6360

6461
public static EnableCheck createEnableCheck(
6562
WorkbenchContext workbenchContext) {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
package com.vividsolutions.jump.workbench.ui.plugin;
2+
3+
import com.vividsolutions.jump.util.Blackboard;
4+
import com.vividsolutions.jump.workbench.WorkbenchContext;
5+
import com.vividsolutions.jump.workbench.model.Layer;
6+
import com.vividsolutions.jump.workbench.plugin.*;
7+
import com.vividsolutions.jump.workbench.ui.*;
8+
import com.vividsolutions.jump.workbench.ui.images.IconLoader;
9+
import org.openjump.core.ui.plugin.view.ViewOptionsPlugIn;
10+
11+
import javax.swing.*;
12+
import java.awt.event.KeyEvent;
13+
import java.util.Iterator;
14+
15+
public class UniqueFeatureInfoPlugIn extends AbstractPlugIn {
16+
17+
private static EnableCheck checker = null;
18+
19+
public UniqueFeatureInfoPlugIn() {
20+
this.setShortcutKeys(KeyEvent.VK_I);
21+
this.setShortcutModifiers(KeyEvent.ALT_MASK);
22+
}
23+
24+
public static final ImageIcon ICON = IconLoader.icon("information_16x16.png");
25+
26+
public static EnableCheck createEnableCheck(
27+
WorkbenchContext workbenchContext) {
28+
if (checker == null) {
29+
EnableCheckFactory checkFactory = EnableCheckFactory.getInstance(workbenchContext);
30+
checker = new MultiEnableCheck()
31+
.add(checkFactory.createWindowWithSelectionManagerMustBeActiveCheck())
32+
.add(checkFactory.createWindowWithLayerManagerMustBeActiveCheck())
33+
.add(
34+
checkFactory
35+
.createWindowWithAssociatedTaskFrameMustBeActiveCheck())
36+
.add(checkFactory.createAtLeastNItemsMustBeSelectedCheck(1));
37+
}
38+
return checker;
39+
}
40+
41+
public void initialize(PlugInContext context) throws Exception {
42+
super.initialize(context);
43+
}
44+
45+
public boolean execute(PlugInContext context) throws Exception {
46+
reportNothingToUndoYet(context);
47+
// Deactivate synchronization
48+
//Don't pass in TaskFrame as LayerManagerProxy, because the TaskFrame may
49+
//be closed and thus the LayerManagerProxy may return null. [Jon Aquino]
50+
TaskFrame taskFrame = ((TaskFrameProxy) context.getActiveInternalFrame()).getTaskFrame();
51+
InfoFrame infoFrame = taskFrame.getInfoFrame();
52+
SelectionManager selectionManager =
53+
((SelectionManagerProxy) context.getActiveInternalFrame()).getSelectionManager();
54+
infoFrame.getModel().clear();
55+
56+
// TODO should be nice to extend FeatureInfoPlugIn to non-layer layerables
57+
for (Iterator<Layer> i = context.getLayerManager().iterator(Layer.class); i.hasNext(); ) {
58+
Layer layer = i.next();
59+
60+
if (selectionManager.getFeaturesWithSelectedItems(layer).isEmpty()) {
61+
continue;
62+
}
63+
//infoFrame.getModel().remove(layer);
64+
infoFrame.getModel().add(layer, selectionManager.getFeaturesWithSelectedItems(layer));
65+
}
66+
infoFrame.surface();
67+
68+
return true;
69+
}
70+
}

0 commit comments

Comments
 (0)