Esempio n. 1
0
  private void initComponents() {
    {
      DefaultTableColumnModel model = new DefaultTableColumnModel();
      TableColumn column = new TableColumn(0);
      column.setResizable(true);
      model.addColumn(column);

      column = new TableColumn(1, 120, new ButtonCellRenderer(), null);
      column.setMaxWidth(120);
      column.setResizable(false);
      model.addColumn(column);

      companionsTable.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS);
      companionsTable.getTableHeader().setResizingAllowed(false);
      companionsTable.setAutoCreateColumnsFromModel(false);
      companionsTable.setColumnModel(model);
    }
    companionsTable.setIntercellSpacing(new Dimension(0, 0));
    companionsTable.setFocusable(false);
    companionsTable.setRowHeight(23);
    companionsTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    setLeftComponent(new JScrollPane(companionsTable));
    JPanel rightPane = new JPanel(new BorderLayout());
    infoPane.setOpaque(false);
    infoPane.setEditable(false);
    infoPane.setFocusable(true);
    infoPane.setContentType("text/html"); // $NON-NLS-1$
    rightPane.add(new JScrollPane(infoPane), BorderLayout.CENTER);
    JPanel buttonPane = new JPanel(new FlowLayout());
    buttonPane.add(loadButton);
    rightPane.add(buttonPane, BorderLayout.SOUTH);
    setRightComponent(rightPane);
  }
  private void updateList(final List<WCInfo> infoList) {
    myPanel.removeAll();
    final Insets nullIndent = new Insets(1, 3, 1, 0);
    final GridBagConstraints gb =
        new GridBagConstraints(
            0,
            0,
            1,
            1,
            0,
            0,
            GridBagConstraints.NORTHWEST,
            GridBagConstraints.NONE,
            new Insets(2, 2, 0, 0),
            0,
            0);
    gb.insets.left = 4;
    myPanel.add(myRefreshLabel, gb);
    gb.insets.left = 1;

    final LocalFileSystem lfs = LocalFileSystem.getInstance();
    final Insets topIndent = new Insets(10, 3, 0, 0);
    for (final WCInfo wcInfo : infoList) {
      final VirtualFile vf = lfs.refreshAndFindFileByIoFile(new File(wcInfo.getPath()));
      final VirtualFile root = (vf == null) ? wcInfo.getVcsRoot() : vf;

      final JEditorPane editorPane = new JEditorPane(UIUtil.HTML_MIME, "");
      editorPane.setEditable(false);
      editorPane.setFocusable(true);
      editorPane.setBackground(UIUtil.getPanelBackground());
      editorPane.addHyperlinkListener(
          new HyperlinkListener() {
            @Override
            public void hyperlinkUpdate(HyperlinkEvent e) {
              if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
                if (CONFIGURE_BRANCHES.equals(e.getDescription())) {
                  if (!checkRoot(root, wcInfo.getPath(), " invoke Configure Branches")) return;
                  BranchConfigurationDialog.configureBranches(myProject, root, true);
                } else if (FIX_DEPTH.equals(e.getDescription())) {
                  final int result =
                      Messages.showOkCancelDialog(
                          myVcs.getProject(),
                          "You are going to checkout into '"
                              + wcInfo.getPath()
                              + "' with 'infinity' depth.\n"
                              + "This will update your working copy to HEAD revision as well.",
                          "Set working copy infinity depth",
                          Messages.getWarningIcon());
                  if (result == 0) {
                    // update of view will be triggered by roots changed event
                    SvnCheckoutProvider.checkout(
                        myVcs.getProject(),
                        new File(wcInfo.getPath()),
                        wcInfo.getRootUrl(),
                        SVNRevision.HEAD,
                        SVNDepth.INFINITY,
                        false,
                        null,
                        wcInfo.getFormat());
                  }
                } else if (CHANGE_FORMAT.equals(e.getDescription())) {
                  changeFormat(wcInfo);
                } else if (MERGE_FROM.equals(e.getDescription())) {
                  if (!checkRoot(root, wcInfo.getPath(), " invoke Merge From")) return;
                  mergeFrom(wcInfo, root, editorPane);
                }
              }
            }

            private boolean checkRoot(
                VirtualFile root, final String path, final String actionName) {
              if (root == null) {
                Messages.showWarningDialog(
                    myProject, "Invalid working copy root: " + path, "Can not " + actionName);
                return false;
              }
              return true;
            }
          });
      editorPane.setBorder(null);
      editorPane.setText(formatWc(wcInfo));

      final JPanel copyPanel = new JPanel(new GridBagLayout());

      final GridBagConstraints gb1 =
          new GridBagConstraints(
              0,
              0,
              1,
              1,
              0,
              0,
              GridBagConstraints.NORTHWEST,
              GridBagConstraints.NONE,
              nullIndent,
              0,
              0);
      gb1.insets.top = 1;
      gb1.gridwidth = 3;

      gb.insets = topIndent;
      gb.fill = GridBagConstraints.HORIZONTAL;
      ++gb.gridy;

      final JPanel contForCopy = new JPanel(new BorderLayout());
      contForCopy.add(copyPanel, BorderLayout.WEST);
      myPanel.add(contForCopy, gb);

      copyPanel.add(editorPane, gb1);
      gb1.insets = nullIndent;
    }

    myPanel.revalidate();
    myPanel.repaint();
  }