Example #1
0
  /** Creates a new view. */
  public NetView() {
    initComponents();

    scrollPane.setLayout(new PlacardScrollPaneLayout());
    scrollPane.setBorder(new EmptyBorder(0, 0, 0, 0));

    setEditor(new DefaultDrawingEditor());
    undo = new UndoRedoManager();
    view.setDrawing(createDrawing());
    view.getDrawing().addUndoableEditListener(undo);
    initActions();
    undo.addPropertyChangeListener(
        new PropertyChangeListener() {

          @Override
          public void propertyChange(PropertyChangeEvent evt) {
            setHasUnsavedChanges(undo.hasSignificantEdits());
          }
        });

    ResourceBundleUtil labels = ResourceBundleUtil.getBundle("org.jhotdraw.draw.Labels");

    JPanel placardPanel = new JPanel(new BorderLayout());
    javax.swing.AbstractButton pButton;
    pButton = ButtonFactory.createZoomButton(view);
    pButton.putClientProperty("Quaqua.Button.style", "placard");
    pButton.putClientProperty("Quaqua.Component.visualMargin", new Insets(0, 0, 0, 0));
    pButton.setFont(UIManager.getFont("SmallSystemFont"));
    placardPanel.add(pButton, BorderLayout.WEST);
    toggleGridButton = pButton = ButtonFactory.createToggleGridButton(view);
    pButton.putClientProperty("Quaqua.Button.style", "placard");
    pButton.putClientProperty("Quaqua.Component.visualMargin", new Insets(0, 0, 0, 0));
    pButton.setFont(UIManager.getFont("SmallSystemFont"));
    labels.configureToolBarButton(pButton, "view.toggleGrid.placard");
    placardPanel.add(pButton, BorderLayout.EAST);
    scrollPane.add(placardPanel, JScrollPane.LOWER_LEFT_CORNER);

    toggleGridButton.setSelected(preferences.getBoolean("view.gridVisible", false));
    view.setScaleFactor(preferences.getDouble("view.scaleFactor", 1d));

    view.addPropertyChangeListener(
        new PropertyChangeListener() {

          @Override
          public void propertyChange(PropertyChangeEvent evt) {
            String name = evt.getPropertyName();
            if ("scaleFactor".equals(name)) {
              preferences.putDouble("view.scaleFactor", (Double) evt.getNewValue());
              firePropertyChange("scaleFactor", evt.getOldValue(), evt.getNewValue());
            }
          }
        });
  }
  /** Called when the panel becomes active. */
  public void panelActivate() {
    parent.lockNextButton();
    parent.lockPrevButton();
    if (idata.installSuccess) {
      // We set the information
      centerPanel.add(
          new JLabel(
              parent.langpack.getString("FinishPanel.success"),
              parent.icons.getImageIcon("information"),
              JLabel.TRAILING));
      centerPanel.add(Box.createVerticalStrut(20));

      if (idata.info.getWriteUninstaller()) {
        // We prepare a message for the uninstaller feature
        String path = translatePath("$INSTALL_PATH") + File.separator + "Uninstaller";

        centerPanel.add(
            new JLabel(
                parent.langpack.getString("FinishPanel.uninst.info"),
                parent.icons.getImageIcon("information"),
                JLabel.TRAILING));
        centerPanel.add(new JLabel(path, parent.icons.getImageIcon("empty"), JLabel.TRAILING));
      }

      // We add the autoButton
      centerPanel.add(Box.createVerticalStrut(20));
      autoButton =
          ButtonFactory.createButton(
              parent.langpack.getString("FinishPanel.auto"),
              parent.icons.getImageIcon("edit"),
              idata.buttonsHColor);
      autoButton.setToolTipText(parent.langpack.getString("FinishPanel.auto.tip"));
      autoButton.addActionListener(this);
      centerPanel.add(autoButton);
    } else
      centerPanel.add(
          new JLabel(
              parent.langpack.getString("FinishPanel.fail"),
              parent.icons.getImageIcon("information"),
              JLabel.TRAILING));
  }