public JComponent createComponent() {
   myTabbedPane = new TabbedPaneWrapper(myParent);
   createConfigurableTabs();
   final JComponent component = myTabbedPane.getComponent();
   component.setPreferredSize(new Dimension(500, 400));
   return component;
 }
Пример #2
0
  /**
   * Generate a user interface from the given xml document (derived from the given path). The xml
   * can be a thredds query capability, any verion of a thredds catalog or an IDV menus xml file.
   *
   * @param doc the xml document
   * @param xmlRoot The root of the xml document to create a display for.
   * @param path The url path we got the xml from.
   */
  protected void makeUi(Document doc, Element xmlRoot, String path) {
    this.document = doc;
    setHaveData(false);
    if (xmlRoot == null) {
      return;
    }
    setSelected(path);
    XmlHandler handler = null;
    String tagName = XmlUtil.getLocalName(xmlRoot);

    if (tagName.equals(WmsUtil.TAG_WMS1) || tagName.equals(WmsUtil.TAG_WMS2)) {
      handler = new WmsHandler(this, xmlRoot, path);
    } else if (tagName.equals(TAG_ERROR)) {
      final String error = XmlUtil.getAttribute(xmlRoot, "label", "Error");
      LogUtil.userErrorMessage("Error: " + error);
      return;
    } else if (tagName.equals(CatalogUtil.TAG_CATALOG)) {
      handler = new ThreddsHandler(this, xmlRoot, path);
    } else if (tagName.equals("menus")) {
      handler = new MenuHandler(this, xmlRoot, path);
    } else {
      throw new IllegalArgumentException(
          "Unknown xml:"
              + ((xmlContents.length() > 100) ? xmlContents.substring(0, 100) : xmlContents)
              + " ...");
    }

    JComponent contents = handler.getContents();
    contents.setPreferredSize(new Dimension(200, 250));
    addToContents(contents);
    addToHistory(handler);
    updateStatus();
  }
 private RelativePoint relativePointWithDominantRectangle(
     final JLayeredPane layeredPane, final Rectangle bounds) {
   Dimension preferredSize = getComponent().getPreferredSize();
   if (myDimensionServiceKey != null) {
     final Dimension dimension =
         DimensionService.getInstance().getSize(myDimensionServiceKey, myProject);
     if (dimension != null) {
       preferredSize = dimension;
     }
   }
   final Point leftTopCorner = new Point(bounds.x + bounds.width, bounds.y);
   final Point leftTopCornerScreen = (Point) leftTopCorner.clone();
   SwingUtilities.convertPointToScreen(leftTopCornerScreen, layeredPane);
   final RelativePoint relativePoint;
   if (!ScreenUtil.isOutsideOnTheRightOFScreen(
       new Rectangle(
           leftTopCornerScreen.x,
           leftTopCornerScreen.y,
           preferredSize.width,
           preferredSize.height))) {
     relativePoint = new RelativePoint(layeredPane, leftTopCorner);
   } else {
     if (bounds.x > preferredSize.width) {
       relativePoint =
           new RelativePoint(layeredPane, new Point(bounds.x - preferredSize.width, bounds.y));
     } else {
       setDimensionServiceKey(null); // going to cut width
       Rectangle screen =
           ScreenUtil.getScreenRectangle(leftTopCornerScreen.x, leftTopCornerScreen.y);
       final int spaceOnTheLeft = bounds.x;
       final int spaceOnTheRight = (screen.x + screen.width) - leftTopCornerScreen.x;
       if (spaceOnTheLeft > spaceOnTheRight) {
         relativePoint = new RelativePoint(layeredPane, new Point(0, bounds.y));
         myComponent.setPreferredSize(
             new Dimension(spaceOnTheLeft, Math.max(preferredSize.height, 200)));
       } else {
         relativePoint = new RelativePoint(layeredPane, leftTopCorner);
         myComponent.setPreferredSize(
             new Dimension(spaceOnTheRight, Math.max(preferredSize.height, 200)));
       }
     }
   }
   return relativePoint;
 }
Пример #4
0
 /**
  * Remove the currently display gui and insert the given one.
  *
  * @param comp The new gui.
  */
 private void addToContents(JComponent comp) {
   handlerHolder.removeAll();
   comp.setPreferredSize(new Dimension(200, 300));
   handlerHolder.add(comp, BorderLayout.CENTER);
   if (myContents != null) {
     myContents.invalidate();
     myContents.validate();
     myContents.repaint();
   }
 }
 public static Window setSize(JComponent content, final Dimension size) {
   final Window popupWindow = SwingUtilities.windowForComponent(content);
   final Point location = popupWindow.getLocation();
   popupWindow.setLocation(location.x, location.y);
   Insets insets = content.getInsets();
   if (insets != null) {
     size.width += insets.left + insets.right;
     size.height += insets.top + insets.bottom;
   }
   content.setPreferredSize(size);
   popupWindow.pack();
   return popupWindow;
 }
Пример #6
0
  /**
   * Create preview component.
   *
   * @param type type
   * @param comboBox the options.
   * @param prefSize the preferred size
   * @return the component.
   */
  private static Component createPreview(int type, final JComboBox comboBox, Dimension prefSize) {
    JComponent preview = null;

    if (type == DeviceConfigurationComboBoxModel.AUDIO) {
      Object selectedItem = comboBox.getSelectedItem();

      if (selectedItem instanceof AudioSystem) {
        AudioSystem audioSystem = (AudioSystem) selectedItem;

        if (!NoneAudioSystem.LOCATOR_PROTOCOL.equalsIgnoreCase(audioSystem.getLocatorProtocol())) {
          preview = new TransparentPanel(new GridBagLayout());
          createAudioSystemControls(audioSystem, preview);
        }
      }
    } else if (type == DeviceConfigurationComboBoxModel.VIDEO) {
      JLabel noPreview =
          new JLabel(
              NeomediaActivator.getResources().getI18NString("impl.media.configform.NO_PREVIEW"));

      noPreview.setHorizontalAlignment(SwingConstants.CENTER);
      noPreview.setVerticalAlignment(SwingConstants.CENTER);

      preview = createVideoContainer(noPreview);
      preview.setPreferredSize(prefSize);

      Object selectedItem = comboBox.getSelectedItem();
      CaptureDeviceInfo device = null;
      if (selectedItem instanceof DeviceConfigurationComboBoxModel.CaptureDevice)
        device = ((DeviceConfigurationComboBoxModel.CaptureDevice) selectedItem).info;

      Exception exception;
      try {
        createVideoPreview(device, preview);
        exception = null;
      } catch (IOException ex) {
        exception = ex;
      } catch (MediaException ex) {
        exception = ex;
      }
      if (exception != null) {
        logger.error("Failed to create preview for device " + device, exception);
        device = null;
      }
    }

    return preview;
  }
  protected JComponent createCenterPanel() {
    myList.setCellRenderer(new CvsListCellRenderer());

    myCenterPanelLayout.setHgap(6);

    myCenterPanel.add(createActionsPanel(), BorderLayout.NORTH);
    JComponent listPanel = createListPanel();

    myCenterPanel.add(listPanel, BorderLayout.CENTER);
    myCenterPanel.add(createCvsConfigurationPanel(), BorderLayout.EAST);
    myCenterPanel.add(new JSeparator(JSeparator.HORIZONTAL), BorderLayout.SOUTH);

    myList.setModel(myModel);

    addSelectionListener();

    int minWidth = myList.getFontMetrics(myList.getFont()).stringWidth(SAMPLE_CVSROOT) + 40;
    Dimension minSize = new Dimension(minWidth, myList.getMaximumSize().height);
    listPanel.setMinimumSize(minSize);
    listPanel.setPreferredSize(minSize);
    return myCenterPanel;
  }
Пример #8
0
  /**
   * Create preview component.
   *
   * @param comboBox the options.
   * @return the component.
   */
  private static Component createPreview(final JComboBox comboBox) {
    final JComponent preview;

    JLabel noPreview =
        new JLabel(GuiActivator.getResources().getI18NString("impl.media.configform.NO_PREVIEW"));
    noPreview.setHorizontalAlignment(SwingConstants.CENTER);
    noPreview.setVerticalAlignment(SwingConstants.CENTER);

    preview = createVideoContainer(noPreview);

    preview.setPreferredSize(new Dimension(WIDTH, 280));
    preview.setMaximumSize(new Dimension(WIDTH, 280));

    final ActionListener comboBoxListener =
        new ActionListener() {
          public void actionPerformed(ActionEvent event) {
            MediaDevice device = (MediaDevice) comboBox.getSelectedItem();

            if ((device != null) && device.equals(videoDeviceInPreview)) return;

            Exception exception;
            try {
              createPreview(device, preview);
              exception = null;
            } catch (IOException ex) {
              exception = ex;
            } catch (MediaException ex) {
              exception = ex;
            }
            if (exception != null) {
              logger.error("Failed to create preview for device " + device, exception);

              device = null;
            }

            videoDeviceInPreview = device;
          }
        };
    comboBox.addActionListener(comboBoxListener);

    /*
     * We have to initialize the controls to reflect the configuration
     * at the time of creating this instance. Additionally, because the
     * video preview will stop when it and its associated controls
     * become unnecessary, we have to restart it when the mentioned
     * controls become necessary again. We'll address the two goals
     * described by pretending there's a selection in the video combo
     * box when the combo box in question becomes displayable.
     */
    comboBox.addHierarchyListener(
        new HierarchyListener() {
          public void hierarchyChanged(HierarchyEvent event) {
            if (((event.getChangeFlags() & HierarchyEvent.DISPLAYABILITY_CHANGED) != 0)
                && comboBox.isDisplayable()) {
              // let current changes end their execution
              // and after that trigger action on combobox
              SwingUtilities.invokeLater(
                  new Runnable() {
                    public void run() {
                      comboBoxListener.actionPerformed(null);
                    }
                  });
            } else {
              if (!comboBox.isDisplayable()) videoDeviceInPreview = null;
            }
          }
        });

    return preview;
  }
  @Nullable
  private Point createToolTipImage(@NotNull KeyType key) {
    UIUtil.putClientProperty(myComponent, EXPANDED_RENDERER, true);
    Pair<Component, Rectangle> rendererAndBounds = getCellRendererAndBounds(key);
    UIUtil.putClientProperty(myComponent, EXPANDED_RENDERER, null);
    if (rendererAndBounds == null) return null;

    JComponent renderer = ObjectUtils.tryCast(rendererAndBounds.first, JComponent.class);
    if (renderer == null) return null;
    if (renderer.getClientProperty(DISABLE_EXPANDABLE_HANDLER) != null) return null;

    if (UIUtil.getClientProperty((JComponent) rendererAndBounds.getFirst(), USE_RENDERER_BOUNDS)
        == Boolean.TRUE) {
      rendererAndBounds.getSecond().translate(renderer.getX(), renderer.getY());
      rendererAndBounds.getSecond().setSize(renderer.getSize());
    }

    myKeyItemBounds = rendererAndBounds.second;

    Rectangle cellBounds = myKeyItemBounds;
    Rectangle visibleRect = getVisibleRect(key);

    if (cellBounds.y < visibleRect.y) return null;

    int cellMaxY = cellBounds.y + cellBounds.height;
    int visMaxY = visibleRect.y + visibleRect.height;
    if (cellMaxY > visMaxY) return null;

    int cellMaxX = cellBounds.x + cellBounds.width;
    int visMaxX = visibleRect.x + visibleRect.width;

    Point location = new Point(visMaxX, cellBounds.y);
    SwingUtilities.convertPointToScreen(location, myComponent);

    Rectangle screen =
        !Registry.is("ide.expansion.hints.on.all.screens")
            ? ScreenUtil.getScreenRectangle(location)
            : ScreenUtil.getAllScreensRectangle();

    int borderWidth = isPaintBorder() ? 1 : 0;
    int width = Math.min(screen.width + screen.x - location.x - borderWidth, cellMaxX - visMaxX);
    int height = cellBounds.height;

    if (width <= 0 || height <= 0) return null;

    Dimension size = getImageSize(width, height);
    myImage = UIUtil.createImage(size.width, size.height, BufferedImage.TYPE_INT_RGB);

    Graphics2D g = myImage.createGraphics();
    g.setClip(null);
    doFillBackground(height, width, g);
    g.translate(cellBounds.x - visMaxX, 0);
    doPaintTooltipImage(renderer, cellBounds, g, key);

    CustomLineBorder border = null;
    if (borderWidth > 0) {
      border = new CustomLineBorder(getBorderColor(), borderWidth, 0, borderWidth, borderWidth);
      location.y -= borderWidth;
      size.width += borderWidth;
      size.height += borderWidth + borderWidth;
    }

    g.dispose();
    myRendererPane.remove(renderer);

    myTipComponent.setBorder(border);
    myTipComponent.setPreferredSize(size);
    return location;
  }
Пример #10
0
 protected void resizeHook(JComponent component) {
   component.setPreferredSize(new Dimension(400, 400));
 }
Пример #11
0
  public MyDeviceChooser(
      boolean multipleSelection,
      @NotNull final Action okAction,
      @NotNull AndroidFacet facet,
      @NotNull IAndroidTarget projectTarget,
      @Nullable Condition<IDevice> filter) {

    myFacet = facet;
    myFilter = filter;
    myMinSdkVersion = AndroidModuleInfo.get(facet).getRuntimeMinSdkVersion();
    myProjectTarget = projectTarget;
    if (new IsWatchFeatureRequiredCompat(facet).get()) {
      myRequiredHardwareFeatures = EnumSet.of(IDevice.HardwareFeature.WATCH);
    } else {
      myRequiredHardwareFeatures = EnumSet.noneOf(IDevice.HardwareFeature.class);
    }

    myDeviceTable = new JBTable();
    myPanel = ScrollPaneFactory.createScrollPane(myDeviceTable);
    myPanel.setPreferredSize(new Dimension(450, 220));

    myDeviceTable.setModel(new MyDeviceTableModel(EMPTY_DEVICE_ARRAY));
    myDeviceTable.setSelectionMode(
        multipleSelection
            ? ListSelectionModel.MULTIPLE_INTERVAL_SELECTION
            : ListSelectionModel.SINGLE_SELECTION);
    myDeviceTable
        .getSelectionModel()
        .addListSelectionListener(
            new ListSelectionListener() {
              @Override
              public void valueChanged(ListSelectionEvent e) {
                if (myProcessSelectionFlag) {
                  hadUserInteraction = true;
                  fireSelectedDevicesChanged();
                }
              }
            });
    new DoubleClickListener() {
      @Override
      protected boolean onDoubleClick(MouseEvent e) {
        if (myDeviceTable.isEnabled() && okAction.isEnabled()) {
          okAction.actionPerformed(null);
          return true;
        }
        return false;
      }
    }.installOn(myDeviceTable);

    myDeviceTable.setDefaultRenderer(LaunchCompatibility.class, new LaunchCompatibilityRenderer());
    myDeviceTable.setDefaultRenderer(
        IDevice.class, new DeviceRenderer.DeviceNameRenderer(facet.getAvdManagerSilently()));
    myDeviceTable.addKeyListener(
        new KeyAdapter() {
          @Override
          public void keyPressed(KeyEvent e) {
            if (e.getKeyCode() == KeyEvent.VK_ENTER && okAction.isEnabled()) {
              okAction.actionPerformed(null);
            }
          }
        });

    setColumnWidth(
        myDeviceTable, DEVICE_NAME_COLUMN_INDEX, "Samsung Galaxy Nexus Android 4.1 (API 17)");
    setColumnWidth(myDeviceTable, SERIAL_COLUMN_INDEX, "0000-0000-00000");
    setColumnWidth(myDeviceTable, DEVICE_STATE_COLUMN_INDEX, "offline");
    setColumnWidth(myDeviceTable, COMPATIBILITY_COLUMN_INDEX, "yes");

    // Do not recreate columns on every model update - this should help maintain the column sizes
    // set above
    myDeviceTable.setAutoCreateColumnsFromModel(false);

    // Allow sorting by columns (in lexicographic order)
    myDeviceTable.setAutoCreateRowSorter(true);

    myRefreshingAlarm = new Alarm(Alarm.ThreadToUse.POOLED_THREAD, this);
    myBridge = AndroidSdkUtils.getDebugBridge(myFacet.getModule().getProject());
  }
Пример #12
0
  public void createGUI() {
    typeSelection = new JComboBox(MappingTypes.values());
    fieldSelection = new JComboBox(columnsToBeMappedTo);
    literalEntry = new RoundedJTextField(10);
    literalEntry.setText("-");

    // set the appearance for ach of the fields!
    UIHelper.renderComponent(typeSelection, UIHelper.VER_10_PLAIN, UIHelper.GREY_COLOR, false);
    UIHelper.setJComboBoxAsHeavyweight(typeSelection);
    UIHelper.renderComponent(fieldSelection, UIHelper.VER_10_PLAIN, UIHelper.GREY_COLOR, false);
    UIHelper.setJComboBoxAsHeavyweight(fieldSelection);
    UIHelper.renderComponent(literalEntry, UIHelper.VER_10_PLAIN, UIHelper.GREY_COLOR, false);

    typeSelection.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent ae) {
            if (typeSelection.getSelectedIndex() == -1) {
              typeSelection.setSelectedIndex(0);
            }
            showHideFields();
          }
        });

    fieldSelection.setPreferredSize(new Dimension(130, 25));

    fieldDrop = createTableBrowseDropdown(fieldSelection);

    fieldDrop.setPreferredSize(new Dimension(160, 25));

    changeableContentContainer = new JPanel();
    changeableContentContainer.setLayout(
        new BoxLayout(changeableContentContainer, BoxLayout.LINE_AXIS));
    changeableContentContainer.setPreferredSize(new Dimension(160, 25));

    add(typeSelection);
    add(changeableContentContainer);

    if (preExistingMapping != null) {
      typeSelection.setSelectedItem(preExistingMapping.getType());

      // check if columns available contains the item it is to be set to.
      if (preExistingMapping.getType() == MappingTypes.LITERAL) {
        literalEntry.setText(preExistingMapping.getMapping());
      } else {
        if (checkFieldExists(preExistingMapping.getMapping())) {
          fieldSelection.setSelectedItem(preExistingMapping.getMapping());
        }
      }
    }

    showHideFields();

    ImageIcon imageToUse = (lastInList) ? addButtonIcon : removeButtonIcon;

    addRemoveMappingChoice = new JLabel(imageToUse);
    addRemoveMappingChoice.addMouseListener(
        new MouseAdapter() {

          @Override
          public void mouseExited(MouseEvent mouseEvent) {
            if (addRemoveMappingChoice.isEnabled()) {
              addRemoveMappingChoice.setIcon(lastInList ? addButtonIcon : removeButtonIcon);
            }
          }

          @Override
          public void mouseEntered(MouseEvent mouseEvent) {
            if (addRemoveMappingChoice.isEnabled()) {
              addRemoveMappingChoice.setIcon(lastInList ? addButtonIconOver : removeButtonIconOver);
            }
          }

          public void mousePressed(MouseEvent mouseEvent) {

            if (addRemoveMappingChoice.isEnabled()) {
              if (lastInList) {
                // tell the parent to add a new mapping
                addRemoveMappingChoice.setIcon(addButtonIcon);
                firePropertyChange("addNewMapping", "1", "2");
              } else {
                // tell the parent to remove this mapping!
                firePropertyChange("removeThisMapping", "1", getCurrentInstance());
              }
            }
          }
        });

    add(addRemoveMappingChoice);
  }
  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);
    }
  }
 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);
 }
Пример #15
0
 @Override
 public void setPreferredSize(Dimension preferredSize) {
   super.setPreferredSize(preferredSize);
   myBaseDocControl.setPreferredSize(preferredSize);
 }
Пример #16
0
 protected void resizeHook(JComponent content) {
   int height = (int) (DIALOG_WIDTH * 1.1);
   content.setPreferredSize(new Dimension(DIALOG_WIDTH, height));
 }
  private void updateViewerForSelection() {
    if (myAllContents.isEmpty()) return;
    String fullString = getSelectedText();

    if (myViewer != null) {
      EditorFactory.getInstance().releaseEditor(myViewer);
    }

    if (myUseIdeaEditor) {
      myViewer = createIdeaEditor(fullString);
      JComponent component = myViewer.getComponent();
      component.setPreferredSize(JBUI.size(300, 500));
      mySplitter.setSecondComponent(component);
    } else {
      final JTextArea textArea = new JTextArea(fullString);
      textArea.setRows(3);
      textArea.setWrapStyleWord(true);
      textArea.setLineWrap(true);
      textArea.setSelectionStart(0);
      textArea.setSelectionEnd(textArea.getText().length());
      textArea.setEditable(false);
      mySplitter.setSecondComponent(ScrollPaneFactory.createScrollPane(textArea));
    }
    mySplitter.revalidate();
  }