001: /*
002: * The Unified Mapping Platform (JUMP) is an extensible, interactive GUI
003: * for 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
008: * modify it under the terms of the GNU General Public License
009: * as published by the Free Software Foundation; either version 2
010: * of the License, or (at your option) any later version.
011: *
012: * This program is distributed in the hope that it will be useful,
013: * but WITHOUT ANY WARRANTY; without even the implied warranty of
014: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
015: * GNU General Public License for more details.
016: *
017: * You should have received a copy of the GNU General Public License
018: * along with this program; if not, write to the Free Software
019: * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
020: *
021: * For more information, contact:
022: *
023: * Vivid Solutions
024: * Suite #1A
025: * 2328 Government Street
026: * Victoria BC V8T 5G5
027: * Canada
028: *
029: * (250)385-6040
030: * www.vividsolutions.com
031: */
032:
033: package com.vividsolutions.jump.workbench.ui;
034:
035: import java.awt.BorderLayout;
036: import java.awt.GridBagConstraints;
037: import java.awt.GridBagLayout;
038: import java.awt.Insets;
039:
040: import javax.swing.JCheckBox;
041: import javax.swing.JDesktopPane;
042: import javax.swing.JPanel;
043:
044: import com.vividsolutions.jts.util.Assert;
045: import com.vividsolutions.jump.I18N;
046: import com.vividsolutions.jump.util.Blackboard;
047:
048: /**
049: * Implements an {@link OptionsPanel} for Edit.
050: */
051:
052: public class EditOptionsPanel extends JPanel implements OptionsPanel {
053: private BorderLayout borderLayout1 = new BorderLayout();
054: private JPanel jPanel1 = new JPanel();
055: private GridBagLayout gridBagLayout1 = new GridBagLayout();
056: private JCheckBox preventEditsCheckBox = new JCheckBox();
057: private JPanel jPanel2 = new JPanel();
058: private Blackboard blackboard;
059: private JDesktopPane desktopPane;
060:
061: public EditOptionsPanel(final Blackboard blackboard,
062: JDesktopPane desktopPane) {
063: this .blackboard = blackboard;
064: this .desktopPane = desktopPane;
065: try {
066: jbInit();
067: } catch (Exception e) {
068: Assert.shouldNeverReachHere(e.toString());
069: }
070: }
071:
072: public String validateInput() {
073: return null;
074: }
075:
076: public void okPressed() {
077: blackboard.put(EditTransaction.ROLLING_BACK_INVALID_EDITS_KEY,
078: preventEditsCheckBox.isSelected());
079: }
080:
081: public void init() {
082: preventEditsCheckBox.setSelected(blackboard.get(
083: EditTransaction.ROLLING_BACK_INVALID_EDITS_KEY, false));
084: }
085:
086: private void jbInit() throws Exception {
087: this .setLayout(borderLayout1);
088: jPanel1.setLayout(gridBagLayout1);
089: preventEditsCheckBox
090: .setText(I18N
091: .get("ui.EditOptionsPanel.prevent-edits-resulting-in-invalid-geometries"));
092: this .add(jPanel1, BorderLayout.CENTER);
093: jPanel1.add(preventEditsCheckBox,
094: new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0,
095: GridBagConstraints.WEST,
096: GridBagConstraints.NONE, new Insets(10, 10, 4,
097: 0), 0, 0));
098: jPanel1.add(jPanel2, new GridBagConstraints(100, 100, 1, 1,
099: 1.0, 1.0, GridBagConstraints.CENTER,
100: GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));
101: }
102: }
|