/** Opens a new window with a drawing view. */
  protected void open(DrawingView newDrawingView) {
    getVersionControlStrategy().assertCompatibleVersion();
    setUndoManager(new UndoManager());
    fIconkit = new Iconkit(this);
    getContentPane().setLayout(new BorderLayout());

    // status line must be created before a tool is set
    fStatusLine = createStatusLine();
    getContentPane().add(fStatusLine, BorderLayout.SOUTH);

    // create dummy tool until the default tool is activated during toolDone()
    setTool(new NullTool(this), "");
    setView(newDrawingView);
    JComponent contents = createContents(view());
    contents.setAlignmentX(LEFT_ALIGNMENT);

    JToolBar tools = createToolPalette();
    createTools(tools);

    JPanel activePanel = new JPanel();
    activePanel.setAlignmentX(LEFT_ALIGNMENT);
    activePanel.setAlignmentY(TOP_ALIGNMENT);
    activePanel.setLayout(new BorderLayout());
    activePanel.add(tools, BorderLayout.NORTH);
    activePanel.add(contents, BorderLayout.CENTER);

    getContentPane().add(activePanel, BorderLayout.CENTER);

    JMenuBar mb = new JMenuBar();
    createMenus(mb);
    setJMenuBar(mb);

    Dimension d = defaultSize();
    if (d.width > mb.getPreferredSize().width) {
      setSize(d.width, d.height);
    } else {
      setSize(mb.getPreferredSize().width, d.height);
    }
    addListeners();
    setVisible(true);
    fStorageFormatManager = createStorageFormatManager();

    toolDone();
  }
Example #2
0
  public SwingUpdaterUI(String oldBuildDesc, String newBuildDesc, InstallOperation operation) {
    myOperation = operation;

    myProcessTitle = new JLabel(" ");
    myProcessProgress = new JProgressBar(0, 100);
    myProcessStatus = new JLabel(" ");

    myCancelButton = new JButton(CANCEL_BUTTON_TITLE);

    myConsole = new JTextArea();
    myConsole.setLineWrap(true);
    myConsole.setWrapStyleWord(true);
    myConsole.setCaretPosition(myConsole.getText().length());
    myConsole.setTabSize(1);
    myConsolePane = new JPanel(new BorderLayout());
    myConsolePane.add(new JScrollPane(myConsole));
    myConsolePane.setBorder(BUTTONS_BORDER);
    myConsolePane.setVisible(false);

    myCancelButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            doCancel();
          }
        });

    myFrame = new JFrame();
    myFrame.setTitle(TITLE);

    myFrame.setLayout(new BorderLayout());
    myFrame.getRootPane().setBorder(FRAME_BORDER);
    myFrame.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);

    myFrame.addWindowListener(
        new WindowAdapter() {
          @Override
          public void windowClosing(WindowEvent e) {
            doCancel();
          }
        });

    JPanel processPanel = new JPanel();
    processPanel.setLayout(new BoxLayout(processPanel, BoxLayout.Y_AXIS));
    processPanel.add(myProcessTitle);
    processPanel.add(myProcessProgress);
    processPanel.add(myProcessStatus);

    processPanel.add(myConsolePane);
    for (Component each : processPanel.getComponents()) {
      ((JComponent) each).setAlignmentX(Component.LEFT_ALIGNMENT);
    }

    JPanel buttonsPanel = new JPanel();
    buttonsPanel.setBorder(BUTTONS_BORDER);
    buttonsPanel.setLayout(new BoxLayout(buttonsPanel, BoxLayout.X_AXIS));
    buttonsPanel.add(Box.createHorizontalGlue());
    buttonsPanel.add(myCancelButton);

    myProcessTitle.setText("<html>Updating " + oldBuildDesc + " to " + newBuildDesc + "...");

    myFrame.add(processPanel, BorderLayout.CENTER);
    myFrame.add(buttonsPanel, BorderLayout.SOUTH);

    myFrame.setMinimumSize(new Dimension(500, 50));
    myFrame.pack();
    myFrame.setLocationRelativeTo(null);

    myFrame.setVisible(true);

    myQueue.add(
        new UpdateRequest() {
          @Override
          public void perform() {
            doPerform();
          }
        });

    startRequestDispatching();
  }
 private void setComponentSize(JComponent component, int w, int h) {
   component.setMinimumSize(new Dimension(w, h));
   component.setMaximumSize(new Dimension(w, h));
   component.setPreferredSize(new Dimension(w, h));
   component.setAlignmentX(Component.LEFT_ALIGNMENT);
 }
 private void addLeftToPanel(JPanel p, JComponent c) {
   c.setAlignmentX(Component.LEFT_ALIGNMENT);
   p.add(c);
 }
 protected void align(JComponent c) {
   c.setAlignmentX(JComponent.LEFT_ALIGNMENT);
   c.setAlignmentY(JComponent.TOP_ALIGNMENT);
 }