/** @see Editor#addEditorForm() */
  @Override
  public void addEditorForm() {
    if (initiallyNull) {
      model = new JTextField();
    } else {
      model = new JTextField(item.model);
      model.setEnabled(false);
    }

    model.setPreferredSize(fieldSize);

    addField(TABLE_BUS_MODEL, model);

    try {
      MaskFormatter formatter = new MaskFormatter("####");
      formatter.setPlaceholderCharacter('Y');
      year = new JFormattedTextField(formatter);
      if (!initiallyNull) {
        ((JFormattedTextField) year).setText(item.year);
        year.setEnabled(false);
      }

      year.setPreferredSize(fieldSize);
      addField(TABLE_BUS_YEAR, year);
    } catch (ParseException e) {
    }
  }
 /** Synchronize content and header sizes. */
 private void setMaxWidth(JComponent content, JComponent header) {
   int c_width = content.getPreferredSize().width;
   int h_width = header.getPreferredSize().width;
   if (c_width > h_width) {
     header.setPreferredSize(new Dimension(c_width, header.getPreferredSize().height));
   } else {
     content.setPreferredSize(new Dimension(h_width, content.getPreferredSize().height));
   }
 }
  /** initialisation of the title bar */
  public void init() {
    installDecoration();
    installBorders();
    installResizers();

    addWindowListener(
        new WindowAdapter() {

          public void windowActivated(WindowEvent e) {
            getRootPane().setBorder(activeBorder);
            repaint();
          }

          public void windowDeactivated(WindowEvent e) {
            getRootPane().setBorder(inactiveBorder);
            repaint();
          }
        });

    title.setPreferredSize(new Dimension(10, titleHeight));

    getContentPane().add(title, BorderLayout.NORTH);

    //    ResizeListener listener = new ResizeListener();
    //    addMouseMotionListener(listener); //2005/10/06
    //    addMouseListener(listener);
  }
 public static JComponent constrainHeight(JComponent component) {
   int preferredWidth = component.getPreferredSize().width;
   component.setPreferredSize(new Dimension(preferredWidth, s_maxButtonHeight));
   component.setMaximumSize(new Dimension(2048, s_maxButtonHeight));
   component.setMinimumSize(new Dimension(preferredWidth, s_maxButtonHeight));
   return component;
 }
Example #5
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();
  }
 public JComponent createComponent() {
   myTabbedPane = new TabbedPaneWrapper(myParent);
   createConfigurableTabs();
   final JComponent component = myTabbedPane.getComponent();
   component.setPreferredSize(new Dimension(500, 400));
   return component;
 }
Example #7
0
 public void setZoomLevel(double zoom) {
   this.zoom = zoom;
   // change the size of the panel and the text
   view.setPreferredSize(
       new Dimension((int) (100 * this.zoom), (int) (items * ITEM_HEIGHT * this.zoom)));
   this.setPopupSize(
       (int) (100 * this.zoom), (int) (Math.min(items * ITEM_HEIGHT + 10, 100) * this.zoom));
 }
 @Override
 public void setPreferredSize(final Dimension DIM) {
   super.setPreferredSize(DIM);
   calcInnerBounds();
   init(getInnerBounds().width, getInnerBounds().height);
   invalidate();
   repaint();
 }
Example #9
0
  /**
   * Constructs an SQLPanel using a given annotation for the 'ref' part of the URL (the part after
   * the '#' character).
   *
   * @param refString the string used for annotating
   * @param refArea true to use a multi-line text area for the ref field, false for a one-line field
   */
  public SQLPanel(String refString, boolean refArea) {
    super(new BorderLayout());
    stack = new LabelledComponentStack();
    add(stack, BorderLayout.NORTH);
    Font inputFont = stack.getInputFont();

    /* Protocol input field. */
    protoField = new JComboBox();
    protoField.addItem("");
    protoField.addItem("mysql");
    protoField.addItem("postgresql");
    protoField.setEditable(true);
    protoField.setFont(inputFont);
    stack.addLine("Protocol", "jdbc:", protoField);

    /* Host input field. */
    hostField = new JComboBox();
    hostField.addItem("");
    hostField.addItem("localhost");
    hostField.setEditable(true);
    hostField.setFont(inputFont);
    stack.addLine("Host", "://", hostField);

    /* Database field. */
    dbField = new JTextField(12);
    stack.addLine("Database name", "/", dbField);

    /* Reference field in the one-line case. */
    if (!refArea) {
      refField = new JTextField(32);
      stack.addLine(refString, "#", refField);
    }

    /* Username input field. */
    userField = new JTextField(12);
    userField.setText(System.getProperty("user.name"));
    stack.addLine("User name", null, userField);

    /* Password input field. */
    passField = new JPasswordField(12);
    stack.addLine("Password", null, passField);

    /* Reference field in the multi-line case. */
    if (refArea) {
      JComponent refHolder = new JPanel(new BorderLayout());
      Box labelBox = Box.createVerticalBox();
      labelBox.add(new JLabel(refString + ": # "));
      labelBox.add(Box.createVerticalGlue());
      refHolder.add(labelBox, BorderLayout.WEST);
      refField = new JTextArea();
      refField.setFont(Font.decode("Monospaced"));
      refHolder.add(Box.createVerticalStrut(5), BorderLayout.NORTH);
      refHolder.add(new JScrollPane(refField), BorderLayout.CENTER);
      refHolder.setPreferredSize(new Dimension(400, 100));
      add(refHolder, BorderLayout.CENTER);
    }
  }
Example #10
0
 /**
  * Sets the size and preferred size of the canvas.
  *
  * @param w The width of the image.
  * @param h The height of the image.
  */
 private void makeComponentsSize(int w, int h) {
   if (canvas == null) return;
   Insets i = canvas.getInsets();
   int width = w + i.right + i.left;
   int height = h + i.top + i.bottom;
   Dimension d = new Dimension(width, height);
   canvas.setPreferredSize(d);
   canvas.setSize(d);
 }
Example #11
0
 public static void sizeIt(JComponent c, int width, int height) {
   if (height < 0) {
     height = c.getPreferredSize().height;
   }
   Dimension myDimension = new Dimension(width, height);
   c.setMaximumSize(myDimension);
   c.setMinimumSize(myDimension);
   c.setPreferredSize(myDimension);
 }
Example #12
0
 public void setPreferredSize(Dimension d) {
   if (c instanceof RootPaneContainer) {
     ((RootPaneContainer) c).getRootPane().setPreferredSize(d);
   } else if (jc != null) {
     jc.setPreferredSize(d);
   } else {
     throw new IllegalStateException();
   }
 }
 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;
 }
 private void put(JComponent... components) {
   JPanel panel = new JPanel();
   panel.setLayout(new FlowLayout(FlowLayout.LEFT));
   Dimension componentDimension = null;
   if (components.length == 2) {
     componentDimension = bigComponentDimension;
   } else {
     componentDimension = smallComponentDimension;
   }
   for (JComponent c : components) {
     if (c instanceof JLabel) {
       c.setPreferredSize(labelDimension);
     } else {
       c.setPreferredSize(componentDimension);
     }
     panel.add(c);
   }
   this.add(panel);
 }
 /**
  * Remove the currently display gui and insert the given one.
  *
  * @param comp The new gui.
  */
 private void addToContents(JComponent comp) {
   treePanel.removeAll();
   comp.setPreferredSize(new Dimension(200, 300));
   treePanel.add(comp, BorderLayout.CENTER);
   if (contents != null) {
     contents.invalidate();
     contents.validate();
     contents.repaint();
   }
 }
Example #16
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 EditSemester_Gui(String s) {

    super(new GridLayout(2, 1));
    frame.setIconImage(
        Toolkit.getDefaultToolkit().getImage(getClass().getResource("/images/icon.png")));
    Dimension d1 = new Dimension(400, 800);
    Dimension d2 = new Dimension(900, 800);
    Dimension d3 = new Dimension(200, 800);
    Dimension d4 = new Dimension(1500, 800);

    tabbedPane1 = new MainPanel1_EditSemester_Gui(s);
    tabbedPane2 = new MainPanel2_EditSemester_Gui(s);
    tabbedPane3 = new MainPanel3_EditSemester_Gui(s);

    pnlAll = new JPanel();
    pnlAll.setPreferredSize(d4);
    pnlAll.setLayout(new BoxLayout(pnlAll, BoxLayout.X_AXIS));

    pnlTreeContainer = new JPanel();
    pnlTreeContainer.setPreferredSize(d3);
    pnlTreeContainer.add(tabbedPane3);

    pnlSettings = new JPanel();
    pnlSettings.setPreferredSize(d1);
    pnlSettings.add(tabbedPane1);

    pnlSemester = new JPanel();
    pnlSemester.setPreferredSize(d2);
    pnlSemester.add(tabbedPane2);

    // Add the tabbed pane to this panel.
    initTabComponent(0);
    initTabComponent2(0);
    initTabComponent3(0);

    pnlAll.add(pnlTreeContainer);
    pnlAll.add(pnlSemester);
    pnlAll.add(pnlSettings);

    add(pnlAll);
  }
Example #18
0
 public static JComponent setSize(JComponent comp, int height, int width) {
   Dimension size = comp.getMaximumSize();
   if (height != 0) {
     size.height = height;
   } else if (width != 0) {
     size.width = width;
   }
   comp.setMinimumSize(size);
   comp.setMaximumSize(size);
   comp.setPreferredSize(size);
   return comp;
 }
 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;
 }
Example #20
0
  public Scene(String title) {
    _canvas = createCanvas();
    _canvas.addMouseListener(
        new MouseAdapter() {
          public void mousePressed(MouseEvent e) {
            maybeShowPopup(e);
          }

          public void mouseReleased(MouseEvent e) {
            maybeShowPopup(e);
          }
        });
    _component = createComponent(_canvas);
    _component.setPreferredSize(new Dimension(OPTIMAL_FRAME_SIZE, OPTIMAL_FRAME_SIZE));
    _title = title;
  }
Example #21
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;
  }
  /* (non-Javadoc)
   * @see org.springframework.richclient.dialog.ApplicationDialog#createDialogContentPane()
   */
  protected JComponent createDialogContentPane() {
    final TextAreaPane messagePane = new TextAreaPane();
    final Icon icon = UIManager.getIcon(ERRORICON);
    messagePane.setDefaultIcon(icon);

    final StringBuffer messageBuffer = new StringBuffer();
    messageBuffer.append(message);

    if (exception != null) {
      if (!message.equals("")) {
        messageBuffer.append("\n\n");
      }
      messageBuffer.append(exception.getLocalizedMessage());
    }

    messagePane.setMessage(new Message(messageBuffer.toString(), Severity.ERROR));
    final JComponent paneConrol = messagePane.getControl();
    paneConrol.setPreferredSize(new Dimension(400, 100));
    return messagePane.getControl();
  }
Example #23
0
  protected JComponent buildGridPanel() {
    grid = ComponentUtils.getStandardTable();
    grid.setColumnControlVisible(false);
    source = new BasicEventList();
    final EventList<MatcherEditor> editors = new BasicEventList<MatcherEditor>();
    editors.add(
        new TextComponentMatcherEditor(
            inputField,
            GlazedLists.textFilterator(
                new String[] {"documento", "sucursal.nombre", "clave", "nombre"})));
    final MatcherEditor editor = new CompositeMatcherEditor(editors);
    final FilterList filterList = new FilterList(source, new ThreadedMatcherEditor(editor));
    SortedList sorted = new SortedList(filterList, null);
    final EventTableModel tm = new EventTableModel(sorted, getTableFormat());
    selectionModel = new EventSelectionModel(sorted);

    grid.setModel(tm);
    TableComparatorChooser.install(grid, sorted, TableComparatorChooser.MULTIPLE_COLUMN_MOUSE);
    grid.setSelectionModel(selectionModel);

    final Action select =
        new AbstractAction() {
          public void actionPerformed(ActionEvent e) {
            doSelect();
          }
        };
    ComponentUtils.addEnterAction(grid, select);
    grid.addMouseListener(
        new MouseAdapter() {
          @Override
          public void mouseClicked(MouseEvent e) {
            if (e.getClickCount() == 2) doSelect();
          }
        });
    grid.packAll();

    JComponent c = ComponentUtils.createTablePanel(grid);
    c.setPreferredSize(new Dimension(750, 400));
    return c;
  }
  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;
  }
Example #25
0
 @Override
 protected void setPreferedDimension(JComponent gridComponent) {
   gridComponent.setPreferredSize(new Dimension(650, 400));
 }
Example #26
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);
  }
 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);
 }
 protected void resizeHook(JComponent content) {
   int height = (int) (DIALOG_WIDTH * 1.1);
   content.setPreferredSize(new Dimension(DIALOG_WIDTH, height));
 }
Example #29
0
 @Override
 public void setPreferredSize(Dimension preferredSize) {
   super.setPreferredSize(preferredSize);
   myBaseDocControl.setPreferredSize(preferredSize);
 }
  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();
  }