001: /*
002: * The Unified Mapping Platform (JUMP) is an extensible, interactive GUI for
003: * visualizing and manipulating spatial features with geometry and attributes.
004: *
005: * Copyright (C) 2003 Vivid Solutions
006: *
007: * This program is free software; you can redistribute it and/or modify it
008: * under the terms of the GNU General Public License as published by the Free
009: * Software Foundation; either version 2 of the License, or (at your option)
010: * any later version.
011: *
012: * This program is distributed in the hope that it will be useful, but WITHOUT
013: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
014: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
015: * more details.
016: *
017: * You should have received a copy of the GNU General Public License along with
018: * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
019: * Place - Suite 330, Boston, MA 02111-1307, USA.
020: *
021: * For more information, contact:
022: *
023: * Vivid Solutions Suite #1A 2328 Government Street Victoria BC V8T 5G5 Canada
024: *
025: * (250)385-6040 www.vividsolutions.com
026: */
027: package com.vividsolutions.jump.workbench.ui.plugin;
028:
029: import com.vividsolutions.jts.util.Assert;
030: import com.vividsolutions.jump.I18N;
031: import com.vividsolutions.jump.workbench.WorkbenchContext;
032: import com.vividsolutions.jump.workbench.model.*;
033: import com.vividsolutions.jump.workbench.plugin.AbstractPlugIn;
034: import com.vividsolutions.jump.workbench.plugin.EnableCheckFactory;
035: import com.vividsolutions.jump.workbench.plugin.MultiEnableCheck;
036: import com.vividsolutions.jump.workbench.plugin.PlugInContext;
037: import com.vividsolutions.jump.workbench.ui.*;
038: import com.vividsolutions.jump.workbench.ui.images.IconLoader;
039: import java.awt.BorderLayout;
040: import javax.swing.ImageIcon;
041: import javax.swing.JInternalFrame;
042: import javax.swing.event.InternalFrameAdapter;
043: import javax.swing.event.InternalFrameEvent;
044:
045: public class ViewAttributesPlugIn extends AbstractPlugIn {
046: public ViewAttributesPlugIn() {
047: }
048:
049: public String getName() {
050: return I18N
051: .get("ui.plugin.ViewAttributesPlugIn.view-edit-attributes");
052: }
053:
054: public boolean execute(final PlugInContext context)
055: throws Exception {
056: reportNothingToUndoYet(context);
057: //Don't add GeometryInfoFrame because the HTML will probably be too
058: // much for the editor pane (too many features). [Jon Aquino]
059: final ViewAttributesFrame frame = new ViewAttributesFrame(
060: context.getSelectedLayer(0), context);
061: context.getWorkbenchFrame().addInternalFrame(frame);
062: return true;
063: }
064:
065: public MultiEnableCheck createEnableCheck(
066: final WorkbenchContext workbenchContext) {
067: EnableCheckFactory checkFactory = new EnableCheckFactory(
068: workbenchContext);
069: return new MultiEnableCheck()
070: .add(checkFactory.createTaskWindowMustBeActiveCheck())
071: .add(
072: checkFactory
073: .createExactlyNLayersMustBeSelectedCheck(1));
074: }
075:
076: public ImageIcon getIcon() {
077: return IconLoader.icon("Row.gif");
078: }
079:
080: public static class ViewAttributesFrame extends JInternalFrame
081: implements LayerManagerProxy, SelectionManagerProxy,
082: LayerNamePanelProxy, TaskFrameProxy, LayerViewPanelProxy {
083: private LayerManager layerManager;
084: private OneLayerAttributeTab attributeTab;
085:
086: public ViewAttributesFrame(Layer layer, PlugInContext context) {
087: this .layerManager = context.getLayerManager();
088: addInternalFrameListener(new InternalFrameAdapter() {
089: public void internalFrameClosed(InternalFrameEvent e) {
090: //Assume that there are no other views on the model [Jon
091: // Aquino]
092: attributeTab.getModel().dispose();
093: }
094: });
095: setResizable(true);
096: setClosable(true);
097: setMaximizable(true);
098: setIconifiable(true);
099: getContentPane().setLayout(new BorderLayout());
100: attributeTab = new OneLayerAttributeTab(context
101: .getWorkbenchContext(), ((TaskFrameProxy) context
102: .getActiveInternalFrame()).getTaskFrame(), this )
103: .setLayer(layer);
104: addInternalFrameListener(new InternalFrameAdapter() {
105: public void internalFrameOpened(InternalFrameEvent e) {
106: attributeTab.getToolBar().updateEnabledState();
107: }
108: });
109: getContentPane().add(attributeTab, BorderLayout.CENTER);
110: setSize(500, 300);
111: updateTitle(attributeTab.getLayer());
112: context.getLayerManager().addLayerListener(
113: new LayerListener() {
114: public void layerChanged(LayerEvent e) {
115: if (attributeTab.getLayer() != null) {
116: updateTitle(attributeTab.getLayer());
117: }
118: }
119:
120: public void categoryChanged(CategoryEvent e) {
121: }
122:
123: public void featuresChanged(FeatureEvent e) {
124: }
125: });
126: Assert
127: .isTrue(
128: !(this instanceof CloneableInternalFrame),
129: I18N
130: .get("ui.plugin.ViewAttributesPlugIn.there-can-be-no-other-views-on-the-InfoModels"));
131: }
132:
133: public LayerViewPanel getLayerViewPanel() {
134: return getTaskFrame().getLayerViewPanel();
135: }
136:
137: public LayerManager getLayerManager() {
138: return layerManager;
139: }
140:
141: private void updateTitle(Layer layer) {
142: String editView;
143: if (layer.isEditable()) {
144: editView = I18N
145: .get("ui.plugin.ViewAttributesPlugIn.edit");
146: } else {
147: editView = I18N
148: .get("ui.plugin.ViewAttributesPlugIn.view");
149: }
150:
151: setTitle(" "
152: + I18N
153: .get("ui.plugin.ViewAttributesPlugIn.attributes")
154: + ": " + layer.getName());
155: }
156:
157: public TaskFrame getTaskFrame() {
158: return attributeTab.getTaskFrame();
159: }
160:
161: public SelectionManager getSelectionManager() {
162: return attributeTab.getPanel().getSelectionManager();
163: }
164:
165: public LayerNamePanel getLayerNamePanel() {
166: return attributeTab;
167: }
168: }
169: }
|