arcgissamples\editing\EditingPanel.java
/* Copyright 2010 ESRI * * All rights reserved under the copyright laws of the United States * and applicable international laws, treaties, and conventions. * * You may freely redistribute and use this sample code, with or * without modification, provided you include the original copyright * notice and use restrictions. * * See the use restrictions. * */ package arcgissamples.editing; import java.awt.Color; import java.awt.Dimension; import java.awt.Font; import java.awt.GridBagConstraints; import java.awt.GridBagLayout; import java.awt.Insets; import javax.swing.BorderFactory; import javax.swing.JButton; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.border.TitledBorder; import com.esri.arcgis.beans.toolbar.ToolbarBean; /* This class represents a panel that contains 5 JButtons for initiating editing operations and 2 * Toolbar Controls that contain the editing tools. The JButtons delegate their event handling * to the EditingPanelActionListener class. */ public class EditingPanel extends JPanel { public EditingPanel() { super(); initialize(); setPreferredSize(new Dimension(200,200)); } public void registerActionListener(EditingPanelActionListener listener) { getBtnCreate().addActionListener(listener); getBtnFinish().addActionListener(listener); getBtnModify().addActionListener(listener); getBtnReshape().addActionListener(listener); getBtnStart().addActionListener(listener); } private void initialize() { GridBagConstraints gridBagConstraints11 = new GridBagConstraints(); gridBagConstraints11.gridx = 0; gridBagConstraints11.insets = new Insets(10, 5, 5, 5); gridBagConstraints11.weighty = 1.0D; gridBagConstraints11.fill = GridBagConstraints.HORIZONTAL; gridBagConstraints11.anchor = GridBagConstraints.NORTHWEST; gridBagConstraints11.gridwidth = 2; gridBagConstraints11.gridy = 5; setLblMessage(new JLabel()); getLblMessage().setText(""); getLblMessage().setBackground(new Color(238, 238, 238)); GridBagConstraints gridBagConstraints6 = new GridBagConstraints(); gridBagConstraints6.gridx = 1; gridBagConstraints6.fill = GridBagConstraints.HORIZONTAL; gridBagConstraints6.gridy = 1; GridBagConstraints gridBagConstraints5 = new GridBagConstraints(); gridBagConstraints5.gridx = 1; gridBagConstraints5.fill = GridBagConstraints.HORIZONTAL; gridBagConstraints5.weightx = 1.0D; gridBagConstraints5.gridy = 0; GridBagConstraints gridBagConstraints4 = new GridBagConstraints(); gridBagConstraints4.gridx = 0; gridBagConstraints4.anchor = GridBagConstraints.NORTHWEST; gridBagConstraints4.insets = new Insets(5, 5, 5, 5); gridBagConstraints4.weighty = 0.0D; gridBagConstraints4.fill = GridBagConstraints.HORIZONTAL; gridBagConstraints4.gridy = 4; GridBagConstraints gridBagConstraints3 = new GridBagConstraints(); gridBagConstraints3.gridx = 0; gridBagConstraints3.anchor = GridBagConstraints.NORTHWEST; gridBagConstraints3.insets = new Insets(5, 5, 5, 5); gridBagConstraints3.fill = GridBagConstraints.HORIZONTAL; gridBagConstraints3.weighty = 0.0D; gridBagConstraints3.gridy = 3; GridBagConstraints gridBagConstraints2 = new GridBagConstraints(); gridBagConstraints2.gridx = 0; gridBagConstraints2.anchor = GridBagConstraints.NORTHWEST; gridBagConstraints2.insets = new Insets(5, 5, 5, 5); gridBagConstraints2.gridy = 2; GridBagConstraints gridBagConstraints1 = new GridBagConstraints(); gridBagConstraints1.gridx = 0; gridBagConstraints1.anchor = GridBagConstraints.NORTHWEST; gridBagConstraints1.insets = new Insets(5, 5, 5, 5); gridBagConstraints1.fill = GridBagConstraints.HORIZONTAL; gridBagConstraints1.gridy = 1; GridBagConstraints gridBagConstraints = new GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.anchor = GridBagConstraints.NORTHWEST; gridBagConstraints.insets = new Insets(5, 5, 5, 5); gridBagConstraints.fill = GridBagConstraints.HORIZONTAL; gridBagConstraints.gridy = 0; this.setSize(325, 219); this.setLayout(new GridBagLayout()); this.setBorder(BorderFactory.createTitledBorder(null, "Editing Panel", TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, new Font("Dialog", Font.BOLD, 12), new Color(51, 51, 51))); this.add(getBtnCreate(), gridBagConstraints); this.add(getBtnModify(), gridBagConstraints1); this.add(getBtnReshape(), gridBagConstraints2); this.add(getBtnStart(), gridBagConstraints3); this.add(getBtnFinish(), gridBagConstraints4); this.add(getLblMessage(), gridBagConstraints11); this.add(getToolbarEditing(), gridBagConstraints5); this.add(getToolbarUndoRedo(), gridBagConstraints6); } /** * This method initializes btnCreate * * @return javax.swing.JButton */ public JButton getBtnCreate() { if (btnCreate == null) { try { btnCreate = new JButton(); btnCreate.setText("Create"); btnCreate.setEnabled(false); } catch (java.lang.Throwable e) { e.printStackTrace(); } } return btnCreate; } /** * This method initializes btnModify * * @return javax.swing.JButton */ public JButton getBtnModify() { if (btnModify == null) { try { btnModify = new JButton(); btnModify.setText("Modify"); btnModify.setEnabled(false); } catch (java.lang.Throwable e) { e.printStackTrace(); } } return btnModify; } /** * This method initializes btnReshape * * @return javax.swing.JButton */ public JButton getBtnReshape() { if (btnReshape == null) { try { btnReshape = new JButton(); btnReshape.setText("Reshape"); btnReshape.setEnabled(false); } catch (java.lang.Throwable e) { e.printStackTrace(); } } return btnReshape; } /** * This method initializes btnStart * * @return javax.swing.JButton */ public JButton getBtnStart() { if (btnStart == null) { try { btnStart = new JButton(); btnStart.setText("Start"); } catch (java.lang.Throwable e) { e.printStackTrace(); } } return btnStart; } /** * This method initializes btnFinish * * @return javax.swing.JButton */ public JButton getBtnFinish() { if (btnFinish == null) { try { btnFinish = new JButton(); btnFinish.setText("Finish"); btnFinish.setVisible(false); } catch (java.lang.Throwable e) { e.printStackTrace(); } } return btnFinish; } /** * This method initializes toolbarEditing1 * * @return com.esri.arcgis.beans.TOC.ToolbarBean */ public ToolbarBean getToolbarEditing() { if (toolbarEditing == null) { try { toolbarEditing = new ToolbarBean(); } catch (java.lang.Throwable e) { e.printStackTrace(); } } return toolbarEditing; } /** * This method initializes toolbarEditing2 * * @return com.esri.arcgis.beans.TOC.ToolbarBean */ public ToolbarBean getToolbarUndoRedo() { if (toolbarUndoRedo == null) { try { toolbarUndoRedo = new ToolbarBean(); } catch (java.lang.Throwable e) { e.printStackTrace(); } } return toolbarUndoRedo; } public void setLblMessage(JLabel lblMessage) { this.lblMessage = lblMessage; } public JLabel getLblMessage() { return lblMessage; } private static final long serialVersionUID = 1L; private JButton btnCreate = null; private JButton btnModify = null; private JButton btnReshape = null; private JButton btnStart = null; private JButton btnFinish = null; private ToolbarBean toolbarEditing = null; private ToolbarBean toolbarUndoRedo = null; private JLabel lblMessage = null; } // @jve:decl-index=0:visual-constraint="10,10"