コード例 #1
0
 /** Returns the coordinates of the top left corner of the value at the given index. */
 public Point getCoordinates(int index) {
   JScrollBar bar = scrollPane.getVerticalScrollBar();
   Rectangle r = segmentTable.getCellRect(index, 1, true);
   segmentTable.scrollRectToVisible(r);
   setTopLevelLocation();
   return new Point(
       (int) (r.getX() + topLevelLocation.getX()), (int) (r.getY() + topLevelLocation.getY()));
 }
コード例 #2
0
  public void createFileChooserDemo() {
    theImage = new JLabel("");
    jpgIcon = createImageIcon("filechooser/jpgIcon.jpg", "jpg image");
    gifIcon = createImageIcon("filechooser/gifIcon.gif", "gif image");

    JPanel demoPanel = getDemoPanel();
    demoPanel.setLayout(new BoxLayout(demoPanel, BoxLayout.Y_AXIS));

    JPanel innerPanel = new JPanel();
    innerPanel.setLayout(new BoxLayout(innerPanel, BoxLayout.X_AXIS));

    demoPanel.add(Box.createRigidArea(VGAP20));
    demoPanel.add(innerPanel);
    demoPanel.add(Box.createRigidArea(VGAP20));

    innerPanel.add(Box.createRigidArea(HGAP20));

    // Create a panel to hold buttons
    JPanel buttonPanel =
        new JPanel() {
          public Dimension getMaximumSize() {
            return new Dimension(getPreferredSize().width, super.getMaximumSize().height);
          }
        };
    buttonPanel.setLayout(new BoxLayout(buttonPanel, BoxLayout.Y_AXIS));

    buttonPanel.add(Box.createRigidArea(VGAP15));
    buttonPanel.add(createPlainFileChooserButton());
    buttonPanel.add(Box.createRigidArea(VGAP15));
    buttonPanel.add(createPreviewFileChooserButton());
    buttonPanel.add(Box.createRigidArea(VGAP15));
    buttonPanel.add(createCustomFileChooserButton());
    buttonPanel.add(Box.createVerticalGlue());

    // Create a panel to hold the image
    JPanel imagePanel = new JPanel();
    imagePanel.setLayout(new BorderLayout());
    imagePanel.setBorder(new BevelBorder(BevelBorder.LOWERED));
    JScrollPane scroller = new JScrollPane(theImage);
    scroller.getVerticalScrollBar().setUnitIncrement(10);
    scroller.getHorizontalScrollBar().setUnitIncrement(10);
    imagePanel.add(scroller, BorderLayout.CENTER);

    // add buttons and image panels to inner panel
    innerPanel.add(buttonPanel);
    innerPanel.add(Box.createRigidArea(HGAP30));
    innerPanel.add(imagePanel);
    innerPanel.add(Box.createRigidArea(HGAP20));
  }
コード例 #3
0
ファイル: ControlPanel.java プロジェクト: johnperry/Geneva2
 /** Class constructor; creates a user interface and loads it with values from the props file. */
 public ControlPanel() {
   super();
   setLayout(new BorderLayout());
   Configuration config = Configuration.getInstance();
   config.setControlPanel(this);
   props = config.getProperties();
   profiles = new Profiles();
   profileLoader = new ProfileLoader();
   profileSaver = new ProfileSaver();
   profileDeleter = new ProfileDeleter();
   selectorPanel = new SelectorPanel();
   jsp = new JScrollPane();
   jsp.setViewportView(selectorPanel);
   this.add(jsp, BorderLayout.CENTER);
   footerPanel = new FooterPanel();
   this.add(footerPanel, BorderLayout.SOUTH);
   jsp.getVerticalScrollBar().setUnitIncrement(25);
   jsp.getVerticalScrollBar().setBlockIncrement(25);
 }
コード例 #4
0
  public void installComponents(JFileChooser fc) {
    fc.setLayout(new BorderLayout(10, 10));
    fc.setAlignmentX(JComponent.CENTER_ALIGNMENT);

    JPanel interior =
        new JPanel() {
          public Insets getInsets() {
            return insets;
          }
        };
    align(interior);
    interior.setLayout(new BoxLayout(interior, BoxLayout.PAGE_AXIS));

    fc.add(interior, BorderLayout.CENTER);

    // PENDING(jeff) - I18N
    JLabel l = new JLabel(pathLabelText);
    l.setDisplayedMnemonic(pathLabelMnemonic);
    align(l);
    interior.add(l);

    File currentDirectory = fc.getCurrentDirectory();
    String curDirName = null;
    if (currentDirectory != null) {
      curDirName = currentDirectory.getPath();
    }
    pathField =
        new JTextField(curDirName) {
          public Dimension getMaximumSize() {
            Dimension d = super.getMaximumSize();
            d.height = getPreferredSize().height;
            return d;
          }
        };
    l.setLabelFor(pathField);
    align(pathField);

    // Change to folder on return
    pathField.addActionListener(getUpdateAction());
    interior.add(pathField);

    interior.add(Box.createRigidArea(vstrut10));

    // CENTER: left, right accessory
    JPanel centerPanel = new JPanel();
    centerPanel.setLayout(new BoxLayout(centerPanel, BoxLayout.LINE_AXIS));
    align(centerPanel);

    // left panel - Filter & folderList
    JPanel leftPanel = new JPanel();
    leftPanel.setLayout(new BoxLayout(leftPanel, BoxLayout.PAGE_AXIS));
    align(leftPanel);

    // add the filter PENDING(jeff) - I18N
    l = new JLabel(filterLabelText);
    l.setDisplayedMnemonic(filterLabelMnemonic);
    align(l);
    leftPanel.add(l);

    filterComboBox =
        new JComboBox() {
          public Dimension getMaximumSize() {
            Dimension d = super.getMaximumSize();
            d.height = getPreferredSize().height;
            return d;
          }
        };
    l.setLabelFor(filterComboBox);
    filterComboBoxModel = createFilterComboBoxModel();
    filterComboBox.setModel(filterComboBoxModel);
    filterComboBox.setRenderer(createFilterComboBoxRenderer());
    fc.addPropertyChangeListener(filterComboBoxModel);
    align(filterComboBox);
    leftPanel.add(filterComboBox);

    // leftPanel.add(Box.createRigidArea(vstrut10));

    // Add the Folder List PENDING(jeff) - I18N
    l = new JLabel(foldersLabelText);
    l.setDisplayedMnemonic(foldersLabelMnemonic);
    align(l);
    leftPanel.add(l);
    JScrollPane sp = createDirectoryList();
    sp.getVerticalScrollBar().setFocusable(false);
    sp.getHorizontalScrollBar().setFocusable(false);
    l.setLabelFor(sp.getViewport().getView());
    leftPanel.add(sp);

    // create files list
    JPanel rightPanel = new JPanel();
    align(rightPanel);
    rightPanel.setLayout(new BoxLayout(rightPanel, BoxLayout.PAGE_AXIS));

    l = new JLabel(filesLabelText);
    l.setDisplayedMnemonic(filesLabelMnemonic);
    align(l);
    rightPanel.add(l);
    sp = createFilesList();
    l.setLabelFor(sp);
    rightPanel.add(sp);

    centerPanel.add(leftPanel);
    centerPanel.add(Box.createRigidArea(hstrut10));
    centerPanel.add(rightPanel);

    JComponent accessoryPanel = getAccessoryPanel();
    JComponent accessory = fc.getAccessory();
    if (accessoryPanel != null) {
      if (accessory == null) {
        accessoryPanel.setPreferredSize(ZERO_ACC_SIZE);
        accessoryPanel.setMaximumSize(ZERO_ACC_SIZE);
      } else {
        getAccessoryPanel().add(accessory, BorderLayout.CENTER);
        accessoryPanel.setPreferredSize(PREF_ACC_SIZE);
        accessoryPanel.setMaximumSize(MAX_SIZE);
      }
      align(accessoryPanel);
      centerPanel.add(accessoryPanel);
    }
    interior.add(centerPanel);
    interior.add(Box.createRigidArea(vstrut10));

    // add the filename field PENDING(jeff) - I18N
    l = new JLabel(enterFileNameLabelText);
    l.setDisplayedMnemonic(enterFileNameLabelMnemonic);
    align(l);
    interior.add(l);

    filenameTextField =
        new JTextField() {
          public Dimension getMaximumSize() {
            Dimension d = super.getMaximumSize();
            d.height = getPreferredSize().height;
            return d;
          }
        };
    l.setLabelFor(filenameTextField);
    filenameTextField.addActionListener(getApproveSelectionAction());
    align(filenameTextField);
    filenameTextField.setAlignmentX(JComponent.LEFT_ALIGNMENT);
    interior.add(filenameTextField);

    bottomPanel = getBottomPanel();
    bottomPanel.add(new JSeparator(), BorderLayout.NORTH);

    // Add buttons
    JPanel buttonPanel = new JPanel();
    align(buttonPanel);
    buttonPanel.setLayout(new BoxLayout(buttonPanel, BoxLayout.LINE_AXIS));
    buttonPanel.add(Box.createGlue());

    approveButton =
        new JButton(getApproveButtonText(fc)) {
          public Dimension getMaximumSize() {
            return new Dimension(MAX_SIZE.width, this.getPreferredSize().height);
          }
        };
    approveButton.setMnemonic(getApproveButtonMnemonic(fc));
    approveButton.setToolTipText(getApproveButtonToolTipText(fc));
    align(approveButton);
    approveButton.setMargin(buttonMargin);
    approveButton.addActionListener(getApproveSelectionAction());
    buttonPanel.add(approveButton);
    buttonPanel.add(Box.createGlue());

    JButton updateButton =
        new JButton(updateButtonText) {
          public Dimension getMaximumSize() {
            return new Dimension(MAX_SIZE.width, this.getPreferredSize().height);
          }
        };
    updateButton.setMnemonic(updateButtonMnemonic);
    updateButton.setToolTipText(updateButtonToolTipText);
    align(updateButton);
    updateButton.setMargin(buttonMargin);
    updateButton.addActionListener(getUpdateAction());
    buttonPanel.add(updateButton);
    buttonPanel.add(Box.createGlue());

    JButton cancelButton =
        new JButton(cancelButtonText) {
          public Dimension getMaximumSize() {
            return new Dimension(MAX_SIZE.width, this.getPreferredSize().height);
          }
        };
    cancelButton.setMnemonic(cancelButtonMnemonic);
    cancelButton.setToolTipText(cancelButtonToolTipText);
    align(cancelButton);
    cancelButton.setMargin(buttonMargin);
    cancelButton.addActionListener(getCancelSelectionAction());
    buttonPanel.add(cancelButton);
    buttonPanel.add(Box.createGlue());

    JButton helpButton =
        new JButton(helpButtonText) {
          public Dimension getMaximumSize() {
            return new Dimension(MAX_SIZE.width, this.getPreferredSize().height);
          }
        };
    helpButton.setMnemonic(helpButtonMnemonic);
    helpButton.setToolTipText(helpButtonToolTipText);
    align(helpButton);
    helpButton.setMargin(buttonMargin);
    helpButton.setEnabled(false);
    buttonPanel.add(helpButton);
    buttonPanel.add(Box.createGlue());

    bottomPanel.add(buttonPanel, BorderLayout.SOUTH);
    if (fc.getControlButtonsAreShown()) {
      fc.add(bottomPanel, BorderLayout.SOUTH);
    }
  }
コード例 #5
0
 private void newWordAction() {
   if ((wordListModel.size() == 0) || !wordListModel.get(0).equals(WORD_FIRSTLINE_TEXT))
     wordListModel.add(0, WORD_FIRSTLINE_TEXT);
   wordList.setSelectedIndex(0);
   wPane.getVerticalScrollBar().setValue(0);
 }
コード例 #6
0
  public CopiesPanel(final Project project) {
    myProject = project;
    myConnection = myProject.getMessageBus().connect(myProject);
    myVcs = SvnVcs.getInstance(myProject);
    myCurrentInfoList = null;

    final Runnable focus =
        new Runnable() {
          @Override
          public void run() {
            IdeFocusManager.getInstance(myProject).requestFocus(myRefreshLabel, true);
          }
        };
    final Runnable refreshView =
        new Runnable() {
          @Override
          public void run() {
            final List<WCInfo> infoList = myVcs.getWcInfosWithErrors();
            final boolean hasErrors = !myVcs.getSvnFileUrlMapping().getErrorRoots().isEmpty();
            final List<WorkingCopyFormat> supportedFormats = getSupportedFormats();
            Runnable runnable =
                new Runnable() {
                  @Override
                  public void run() {
                    if (myCurrentInfoList != null) {
                      final List<OverrideEqualsWrapper<WCInfo>> newList =
                          ObjectsConvertor.convert(
                              infoList,
                              new Convertor<WCInfo, OverrideEqualsWrapper<WCInfo>>() {
                                @Override
                                public OverrideEqualsWrapper<WCInfo> convert(WCInfo o) {
                                  return new OverrideEqualsWrapper<WCInfo>(
                                      InfoEqualityPolicy.getInstance(), o);
                                }
                              },
                              ObjectsConvertor.NOT_NULL);

                      if (Comparing.haveEqualElements(newList, myCurrentInfoList)) {
                        myRefreshLabel.setEnabled(true);
                        return;
                      }
                      myCurrentInfoList = newList;
                    }
                    Collections.sort(infoList, WCComparator.getInstance());
                    updateList(infoList, supportedFormats);
                    myRefreshLabel.setEnabled(true);
                    showErrorNotification(hasErrors);
                    SwingUtilities.invokeLater(focus);
                  }
                };
            ApplicationManager.getApplication().invokeLater(runnable, ModalityState.NON_MODAL);
          }
        };
    final Consumer<Boolean> refreshOnPooled =
        new Consumer<Boolean>() {
          @Override
          public void consume(Boolean somethingNew) {
            if (Boolean.TRUE.equals(somethingNew)) {
              if (ApplicationManager.getApplication().isUnitTestMode()) {
                refreshView.run();
              } else {
                ApplicationManager.getApplication().executeOnPooledThread(refreshView);
              }
            } else {
              ApplicationManager.getApplication()
                  .invokeLater(
                      new Runnable() {
                        @Override
                        public void run() {
                          myRefreshLabel.setEnabled(true);
                        }
                      },
                      ModalityState.NON_MODAL);
            }
          }
        };
    myConnection.subscribe(SvnVcs.ROOTS_RELOADED, refreshOnPooled);

    final JPanel holderPanel = new JPanel(new BorderLayout());
    FontMetrics fm = holderPanel.getFontMetrics(holderPanel.getFont());
    myTextHeight = (int) (fm.getHeight() * 1.3);
    myPanel = new JPanel(new GridBagLayout());
    final JPanel panel = new JPanel(new BorderLayout());
    panel.add(myPanel, BorderLayout.NORTH);
    holderPanel.add(panel, BorderLayout.WEST);
    myRefreshLabel =
        new MyLinkLabel(
            myTextHeight,
            "Refresh",
            new LinkListener() {
              @Override
              public void linkSelected(LinkLabel aSource, Object aLinkData) {
                if (myRefreshLabel.isEnabled()) {
                  myVcs.invokeRefreshSvnRoots();
                  myRefreshLabel.setEnabled(false);
                }
              }
            });
    final JScrollPane pane = ScrollPaneFactory.createScrollPane(holderPanel);
    myHolder = pane;
    final JScrollBar vBar = pane.getVerticalScrollBar();
    vBar.setBlockIncrement(vBar.getBlockIncrement() * 5);
    vBar.setUnitIncrement(vBar.getUnitIncrement() * 5);
    myHolder.setBorder(null);
    setFocusableForLinks(myRefreshLabel);
    refreshOnPooled.consume(true);
    initView();
  }