LinkEditorDialog(final DrawableList list, final LinkShape shape, int x, int y) { super((javax.swing.JFrame) null, true); this.originalShape = shape; this.shape = (LinkShape) shape.clone(); this.list = list; setResizable(false); setDefaultCloseOperation(javax.swing.WindowConstants.DO_NOTHING_ON_CLOSE); addWindowListener( new java.awt.event.WindowAdapter() { @Override public void windowClosing(java.awt.event.WindowEvent e) { saveShape(); } }); org.nlogo.swing.Utils.addEscKeyAction( this, new javax.swing.AbstractAction() { public void actionPerformed(java.awt.event.ActionEvent e) { if (!originalShape.toString().equals(getCurrentShape().toString()) && 0 != javax.swing.JOptionPane.showConfirmDialog( LinkEditorDialog.this, "You may lose changes made to this shape. Do you want to cancel anyway?", "Confirm Cancel", javax.swing.JOptionPane.YES_NO_OPTION)) { return; } dispose(); } }); java.awt.GridBagLayout gb = new java.awt.GridBagLayout(); java.awt.GridBagConstraints c = new java.awt.GridBagConstraints(); setLayout(gb); javax.swing.JLabel label = new javax.swing.JLabel("name: "); c.anchor = java.awt.GridBagConstraints.WEST; add(label, c); c.gridwidth = java.awt.GridBagConstraints.REMAINDER; name.setText(shape.getName()); add(name, c); c.gridwidth = 1; label = new javax.swing.JLabel("direction indicator: "); add(label, c); c.gridwidth = java.awt.GridBagConstraints.REMAINDER; javax.swing.JButton diButton = new javax.swing.JButton("Edit"); add(diButton, c); diButton.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent e) { new EditorDialog( LinkEditorDialog.this, (org.nlogo.shape.VectorShape) shape.getDirectionIndicator(), getLocation().x, getLocation().y, false); } }); c.gridwidth = 1; label = new javax.swing.JLabel("curviness: "); add(label, c); c.gridwidth = java.awt.GridBagConstraints.REMAINDER; curviness.setText(Double.toString(shape.curviness())); add(curviness, c); for (int i = 0; i < dashes.length; i++) { dashes[i] = new javax.swing.JComboBox(org.nlogo.shape.LinkLine.dashChoices); dashes[i].setRenderer(new DashCellRenderer()); dashes[i].setSelectedItem(shape.getDashes(i)); } c.gridwidth = 1; add(new javax.swing.JLabel("left line"), c); c.gridwidth = java.awt.GridBagConstraints.REMAINDER; add(dashes[2], c); c.gridwidth = 1; add(new javax.swing.JLabel("middle line"), c); c.gridwidth = java.awt.GridBagConstraints.REMAINDER; add(dashes[1], c); c.gridwidth = 1; add(new javax.swing.JLabel("right line"), c); c.gridwidth = java.awt.GridBagConstraints.REMAINDER; add(dashes[0], c); javax.swing.JButton cancel = new javax.swing.JButton(I18N.guiJ().get("common.buttons.cancel")); cancel.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent e) { dispose(); } }); javax.swing.JButton done = new javax.swing.JButton(I18N.guiJ().get("common.buttons.ok")); done.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent e) { saveShape(); setVisible(false); dispose(); } }); javax.swing.JPanel buttonPanel = new org.nlogo.swing.ButtonPanel(new javax.swing.JButton[] {done, cancel}); c.anchor = java.awt.GridBagConstraints.EAST; add(buttonPanel, c); setLocation(x + 10, y + 10); setTitle("Link Shape"); name.setEnabled(!ShapeList.isDefaultShapeName(shape.getName())); list.update(); pack(); getRootPane().setDefaultButton(done); // when name is not enabled focus goes to the curviness // field instead ev 2/18/08 if (ShapeList.isDefaultShapeName(shape.getName())) { curviness.requestFocus(); } else { name.requestFocus(); } setVisible(true); }