public static void addActions(JComponent thePanel, IntActionReceiver theTarget) {
    javax.swing.Action goLeft = new SimpleIntAction("Left", 1, theTarget);
    javax.swing.Action goRight = new SimpleIntAction("Right", 0, theTarget);
    javax.swing.Action goDown = new SimpleIntAction("Down", 2, theTarget);
    javax.swing.Action goUp = new SimpleIntAction("Up", 3, theTarget);

    thePanel
        .getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW)
        .put(KeyStroke.getKeyStroke(KeyEvent.VK_LEFT, 0), "goLeft");
    thePanel.getActionMap().put("goLeft", goLeft);
    thePanel
        .getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW)
        .put(KeyStroke.getKeyStroke(KeyEvent.VK_RIGHT, 0), "goRight");
    thePanel.getActionMap().put("goRight", goRight);
    thePanel
        .getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW)
        .put(KeyStroke.getKeyStroke(KeyEvent.VK_DOWN, 0), "goDown");
    thePanel.getActionMap().put("goDown", goDown);
    thePanel
        .getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW)
        .put(KeyStroke.getKeyStroke(KeyEvent.VK_UP, 0), "goUp");
    thePanel.getActionMap().put("goUp", goUp);

    thePanel.add(new JButton(goLeft));
    thePanel.add(new JButton(goRight));
    thePanel.add(new JButton(goUp));
    thePanel.add(new JButton(goDown));
  }
Пример #2
0
  /**
   * Long description in header produces expected line-wrap in footer.
   *
   * <p>Note: the frame is not packed to simulate the appframework context.
   */
  public void interactiveHTMLTextWrapLong() {
    //      Toolkit.getDefaultToolkit().addAWTEventListener(new AWTEventListener() {
    //
    //                    public void eventDispatched(AWTEvent event) {
    //                        if (event.getID() != MouseEvent.MOUSE_MOVED) {
    //                            System.out.println("e:" + event);
    //                        }
    //                    }}, Long.MAX_VALUE);
    JXHeader header = createHeader();
    JXHeader footer = new JXHeader();
    footer.setTitle("Notes:");
    String footerDescription =
        "<html>"
            + " <ul> "
            + " <li> code: in the jdnc-incubator, section kleopatra, package appframework."
            + " <li> technique: back the view by a shared presentation model "
            + " <li> technique: veto selection change until editing is completed "
            + " <li> issue: selection of tab should be vetoable "
            + " <li> issue: empty selection should disable editing pane "
            + " </ul> "
            + " </html>";
    footer.setDescription(footerDescription);

    JComponent panel = new JPanel(new BorderLayout());
    panel.add(header, BorderLayout.NORTH);
    //        panel.add(new JScrollPane(table));
    panel.add(footer, BorderLayout.SOUTH);
    //      JXFrame frame = new JXFrame("html wrapping in SOUTH: long text in NORTH");
    //      frame.add(panel);
    JXFrame frame = wrapInFrame(panel, "html wrapping in SOUTH: long text in NORTH");
    //        addComponentOrientationToggle(frame);
    frame.setSize(800, 600);
    //        show(frame);
    frame.setVisible(true);
  }
  @Override
  public JComponent createOptionsPanel() {
    final JComponent panel = new JPanel(new GridBagLayout());

    final JPanel annotationsPanel =
        SpecialAnnotationsUtil.createSpecialAnnotationsListControl(
            annotationNames, InspectionGadgetsBundle.message("ignore.if.annotated.by"));
    final CheckBox checkBox =
        new CheckBox(
            InspectionGadgetsBundle.message("primitive.fields.ignore.option"),
            this,
            "m_ignorePrimitives");

    final GridBagConstraints constraints = new GridBagConstraints();
    constraints.gridx = 0;
    constraints.gridy = 0;
    constraints.weightx = 1.0;
    constraints.weighty = 1.0;
    constraints.fill = GridBagConstraints.BOTH;
    panel.add(annotationsPanel, constraints);

    constraints.gridy = 1;
    constraints.weighty = 0.0;
    constraints.fill = GridBagConstraints.HORIZONTAL;
    panel.add(checkBox, constraints);

    return panel;
  }
  public void insertDraggableComponent(DraggableComponent component, int index) {
    component.setLayoutOrderList(layoutOrderList);

    component.addListener(draggableComponentListener);
    if (index < 0) {
      layoutOrderList.add(component.getComponent());
      componentBox.add(component.getComponent());
    } else {
      layoutOrderList.add(index, component.getComponent());
      componentBox.add(component.getComponent(), index);
    }

    sortComponentList(!descendingSortOrder);

    draggableComponentList.add(component);
    component.setOuterParentArea(outerParentArea);
    componentBox.revalidate();

    fireAddedEvent(component);
    if (autoSelect
        && layoutOrderList.size() == 1
        && selectedComponent == null
        && component.isEnabled()) doSelectComponent(component);

    updateScrollButtons();
  }
 /**
  * Creates and returns a JXFrame with the specified title, containing two components individually
  * wrapped into a JScrollPane.
  *
  * @param leftComp the left JComponent to wrap
  * @param rightComp the right JComponent to wrap
  * @param title the title to show in the frame
  * @return a configured, packed and located JXFrame
  */
 public JXFrame wrapWithScrollingInFrame(JComponent leftComp, JComponent rightComp, String title) {
   JComponent comp = Box.createHorizontalBox();
   comp.add(new JScrollPane(leftComp));
   comp.add(new JScrollPane(rightComp));
   JXFrame frame = wrapInFrame(comp, title);
   return frame;
 }
Пример #6
0
  /**
   * Construct the demo
   *
   * @param window
   * @param capture
   * @throws Exception
   */
  public VideoColourSIFT(final JComponent window, final VideoCapture capture) throws Exception {
    final int width = capture.getWidth();
    final int height = capture.getHeight();
    this.capture = capture;
    this.polygonListener = new PolygonDrawingListener();

    GridBagConstraints gbc = new GridBagConstraints();

    final JLabel label =
        new JLabel(
            "<html><body><p>Hold an object in front of the camera, and press space. Select<br/>"
                + "the outline of the object by clicking points on the frozen video<br/>"
                + "image, and press C when you're done. Press space to start the video<br/>"
                + "again, and the object should be tracked.</p></body></html>");
    gbc.gridx = 0;
    gbc.gridy = 0;
    gbc.gridwidth = 2;
    gbc.insets = new Insets(8, 8, 8, 8);
    window.add(label, gbc);

    this.vidPanel = new JPanel(new GridBagLayout());
    this.vidPanel.setBorder(BorderFactory.createTitledBorder("Live Video"));
    this.videoFrame = VideoDisplay.createVideoDisplay(capture, this.vidPanel);
    gbc = new GridBagConstraints();
    gbc.gridy = 1;
    gbc.gridx = 0;
    gbc.gridwidth = 1;
    window.add(this.vidPanel, gbc);

    this.modelPanel = new JPanel(new GridBagLayout());
    this.modelPanel.setBorder(BorderFactory.createTitledBorder("Model"));
    this.modelFrame = new ImageComponent(true, false);
    this.modelFrame.setSize(width, height);
    this.modelFrame.setPreferredSize(new Dimension(width, height));
    this.modelPanel.add(this.modelFrame);
    gbc = new GridBagConstraints();
    gbc.anchor = GridBagConstraints.PAGE_START;
    gbc.gridy = 1;
    gbc.gridx = 1;
    window.add(this.modelPanel, gbc);

    this.matchPanel = new JPanel(new GridBagLayout());
    this.matchPanel.setBorder(BorderFactory.createTitledBorder("Matches"));
    this.matchFrame = new ImageComponent(true, false);
    this.matchFrame.setSize(width * 2, height);
    this.matchFrame.setPreferredSize(new Dimension(width * 2, height));
    this.matchPanel.add(this.matchFrame);
    gbc = new GridBagConstraints();
    gbc.anchor = GridBagConstraints.PAGE_END;
    gbc.gridy = 2;
    gbc.gridx = 0;
    gbc.gridwidth = 2;
    window.add(this.matchPanel, gbc);

    this.videoFrame.getScreen().addMouseListener(this.polygonListener);

    this.videoFrame.addVideoListener(this);
    this.engine = new DoGColourSIFTEngine();
    this.engine.getOptions().setDoubleInitialImage(false);
  }
Пример #7
0
  @Override
  public JComponent createUI(
      DescriptionType inputOrOutput, Map<URI, Object> dataMap, Orientation orientation) {
    // Create the main panel
    JComponent component = new JPanel(new MigLayout("fill"));

    boolean isOptional = false;
    if (inputOrOutput instanceof InputDescriptionType) {
      isOptional =
          ((InputDescriptionType) inputOrOutput).getMinOccurs().equals(new BigInteger("0"));
    }
    // Display the SourceCA into a JTextField
    JTextField jtf = new JTextField();
    jtf.setToolTipText(inputOrOutput.getAbstract().get(0).getValue());
    // "Save" the CA inside the JTextField
    jtf.getDocument().putProperty(DATA_MAP_PROPERTY, dataMap);
    URI uri = URI.create(inputOrOutput.getIdentifier().getValue());
    jtf.getDocument().putProperty(URI_PROPERTY, uri);
    // add the listener for the text changes in the JTextField
    jtf.getDocument()
        .addDocumentListener(
            EventHandler.create(DocumentListener.class, this, "saveDocumentText", "document"));
    if (isOptional) {
      if (dataMap.containsKey(uri)) {
        jtf.setText(dataMap.get(uri).toString());
      }
    }

    GeometryData geometryData = null;
    if (inputOrOutput instanceof InputDescriptionType) {
      geometryData =
          (GeometryData) ((InputDescriptionType) inputOrOutput).getDataDescription().getValue();
    }
    // If the DescriptionType is an output, there is nothing to show, so exit
    if (geometryData == null) {
      return null;
    }

    component.add(jtf, "growx");

    if (orientation.equals(Orientation.VERTICAL)) {
      JPanel buttonPanel = new JPanel(new MigLayout());

      // Create the button Browse
      JButton pasteButton = new JButton(ToolBoxIcon.getIcon(ToolBoxIcon.PASTE));
      // "Save" the sourceCA and the JTextField in the button
      pasteButton.putClientProperty(TEXT_FIELD_PROPERTY, jtf);
      pasteButton.setBorderPainted(false);
      pasteButton.setContentAreaFilled(false);
      pasteButton.setMargin(new Insets(0, 0, 0, 0));
      // Add the listener for the click on the button
      pasteButton.addActionListener(EventHandler.create(ActionListener.class, this, "onPaste", ""));
      buttonPanel.add(pasteButton);

      component.add(buttonPanel, "dock east");
    }

    return component;
  }
Пример #8
0
  /**
   * Constructor.
   *
   * @param profile SAMP profile
   * @param trackMessages if true, the GUI will contain a visual representation of messages sent and
   *     received
   * @param autoSec number of seconds between automatic hub connection attempts; &lt;=0 means no
   *     automatic connections
   */
  public HubMonitor(ClientProfile profile, boolean trackMessages, int autoSec) {
    super(new BorderLayout());

    // Set up a new GuiHubConnector and GUI decorations.
    connector_ =
        trackMessages ? new MessageTrackerHubConnector(profile) : new GuiHubConnector(profile);

    // Declare the default subscriptions.  This is required so that
    // the hub knows the client is subscribed to those hub.event
    // MTypes which inform about client registration, hub shutdown etc.
    connector_.declareSubscriptions(connector_.computeSubscriptions());

    // Declare metadata about this application.
    Metadata meta = new Metadata();
    meta.setName("HubMonitor");
    meta.setDescriptionText("GUI hub monitor utility");
    try {
      meta.setIconUrl(
          UtilServer.getInstance()
              .exportResource("/org/astrogrid/samp/images/" + "eye.gif")
              .toString());
    } catch (IOException e) {
      logger_.warning("Can't set icon");
    }
    meta.put("author", "Mark Taylor");
    connector_.declareMetadata(meta);

    // Create and place a component which maintains a display of
    // currently registered clients.  A more modest GUI could just use
    // connector.getClientListModel() as a model for a JList component.
    add(connector_.createMonitorPanel(), BorderLayout.CENTER);

    // Prepare a container for other widgets at the bottom of the window.
    JPanel infoBox = new JPanel(new BorderLayout());
    add(infoBox, BorderLayout.SOUTH);

    // Create and place components which allow the user to
    // view and control registration/unregistration explicitly.
    JComponent connectBox = new JPanel(new BorderLayout());
    connectBox.add(new JButton(connector_.createToggleRegisterAction()), BorderLayout.CENTER);
    connectBox.add(connector_.createConnectionIndicator(), BorderLayout.EAST);
    infoBox.add(connectBox, BorderLayout.EAST);

    // Create and place components which provide a compact display
    // of the connector's status.
    JComponent statusBox = Box.createHorizontalBox();
    statusBox.add(connector_.createClientBox(false, 24));
    if (connector_ instanceof MessageTrackerHubConnector) {
      statusBox.add(((MessageTrackerHubConnector) connector_).createMessageBox(24));
    }
    infoBox.add(statusBox, BorderLayout.CENTER);

    // Attempt registration, and arrange that if/when unregistered we look
    // for a hub to register with on a regular basis.
    connector_.setActive(true);
    connector_.setAutoconnect(autoSec);
  }
Пример #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);
    }
  }
Пример #10
0
 private void initDataLine2(JComponent panel) {
   GridBagConstraints c = gridLine();
   panel.add(new JLabel(Messages.uiGet("RegistryBoard.CategoryLabel")), c); // $NON-NLS-1$
   categoryF = new DataField();
   panel.add(categoryF, c);
   panel.add(new JLabel(Messages.uiGet("RegistryBoard.CourseLabel")), c); // $NON-NLS-1$
   courseF = new DataField();
   panel.add(courseF, c);
 }
 private JComponent build() {
   JComponent comp = Box.createVerticalBox();
   comp.add(new JScrollPane(list));
   comp.add(valueField, BorderLayout.SOUTH);
   comp.add(activityBox);
   comp.add(new JXTitledSeparator("below: edited bindings"));
   comp.add(uncommittedBox);
   return comp;
 }
Пример #12
0
 private void initDataLine3(JComponent panel) {
   GridBagConstraints c = gridLine();
   panel.add(new JLabel(Messages.uiGet("RegistryBoard.StatusLabel")), c); // $NON-NLS-1$
   statusF = new StatusField();
   panel.add(statusF, c);
   panel.add(new JLabel(Messages.uiGet("RegistryBoard.TimeLabel")), c); // $NON-NLS-1$
   resultTimeF = new DataField();
   panel.add(resultTimeF, c);
 }
 public AppSubscriptionsPanel(
     final ClientDavConnection connection,
     final ClientApplication clientApplication,
     final DavApplication dav) {
   super(new BorderLayout());
   _jSplitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);
   ApplicationSubscriptionInfo subscriptionInfo;
   try {
     subscriptionInfo = connection.getSubscriptionInfo(dav, clientApplication);
   } catch (IOException e) {
     subscriptionInfo = null;
     e.printStackTrace();
     JOptionPane.showMessageDialog(
         this, "Konnte die Anmeldungen nicht auflisten. " + e.getMessage());
   }
   final TitledBorder sendBorder =
       BorderFactory.createTitledBorder(BorderFactory.createEmptyBorder(), "Sende-Anmeldungen");
   final TitledBorder receiveBorder =
       BorderFactory.createTitledBorder(BorderFactory.createEmptyBorder(), "Empfangs-Anmeldungen");
   final TitledBorder labelBorder = BorderFactory.createTitledBorder("Details");
   final JComponent paneSend = new JPanel(new BorderLayout());
   _senderList =
       new JList(
           new MyListModel(
               subscriptionInfo == null
                   ? Collections.emptyList()
                   : subscriptionInfo.getSenderSubscriptions()));
   paneSend.add(new JScrollPane(_senderList), BorderLayout.CENTER);
   final JComponent paneReceive = new JPanel(new BorderLayout());
   _receiverList =
       new JList(
           new MyListModel(
               subscriptionInfo == null
                   ? Collections.emptyList()
                   : subscriptionInfo.getReceiverSubscriptions()));
   paneReceive.add(new JScrollPane(_receiverList), BorderLayout.CENTER);
   paneSend.setBorder(sendBorder);
   paneReceive.setBorder(receiveBorder);
   _jSplitPane.setLeftComponent(paneSend);
   _jSplitPane.setRightComponent(paneReceive);
   _jSplitPane.setResizeWeight(0.5);
   _senderList.addMouseListener(new MyMouseListener(_senderList));
   _receiverList.addMouseListener(new MyMouseListener(_receiverList));
   _senderList.setFocusable(false);
   _receiverList.setFocusable(false);
   this.add(_jSplitPane, BorderLayout.CENTER);
   _label = new JEditorPane("text/html", "");
   _label.putClientProperty(JEditorPane.HONOR_DISPLAY_PROPERTIES, Boolean.TRUE);
   _label.setFont(_label.getFont().deriveFont(Font.PLAIN));
   _label.setBorder(labelBorder);
   _label.setEditable(false);
   final JScrollPane pane = new JScrollPane(_label);
   pane.setBorder(BorderFactory.createEmptyBorder());
   pane.setPreferredSize(new Dimension(400, 160));
   this.add(pane, BorderLayout.SOUTH);
 }
Пример #14
0
  private static void processSideBars(Map sideBars, JComponent ec) {
    JScrollPane scroller = (JScrollPane) ec.getComponent(0);

    // Remove all existing sidebars
    ec.removeAll();

    // Add the scroller and the new sidebars
    ec.add(scroller);
    scroller.setRowHeader(null);
    scroller.setColumnHeaderView(null);
    //        final MouseDispatcher mouse = new MouseDispatcher((JTextComponent)
    // ec.getClientProperty(JTextComponent.class));
    for (Iterator entries = sideBars.entrySet().iterator(); entries.hasNext(); ) {
      Map.Entry entry = (Map.Entry) entries.next();
      SideBarPosition position = (SideBarPosition) entry.getKey();
      JComponent sideBar = (JComponent) entry.getValue();

      //            if (position.getPosition() == SideBarPosition.WEST) {
      //                JPanel p = new JPanel(new BorderLayout()) {
      //
      //                    @Override
      //                    public void addNotify() {
      //                        super.addNotify();
      //                        infiltrateContainer(this, mouse, true);
      //                    }
      //
      //                    @Override
      //                    public void removeNotify() {
      //                        infiltrateContainer(this, mouse, false);
      //                        super.removeNotify();
      //                    }
      //
      //                };
      //                p.add(sideBar, BorderLayout.CENTER);
      //                sideBar = p;
      //            }

      if (position.isScrollable()) {
        if (position.getPosition() == SideBarPosition.WEST) {
          scroller.setRowHeaderView(sideBar);
        } else {
          if (position.getPosition() == SideBarPosition.NORTH) {
            scroller.setColumnHeaderView(sideBar);
          } else {
            throw new IllegalArgumentException(
                "Unsupported side bar position, scrollable = true, position="
                    + position.getBorderLayoutPosition()); // NOI18N
          }
        }
      } else {
        ec.add(sideBar, position.getBorderLayoutPosition());
      }
    }
  }
Пример #15
0
 public static void addMenuItems(JComponent popup) {
   addNewItem(
       popup,
       "Class",
       "images/class.png",
       () -> SourceFileCreator.instance().create(ClassType.Class));
   addNewItem(
       popup,
       "Enum",
       "images/enum.png",
       () -> SourceFileCreator.instance().create(ClassType.Enum));
   popup.add(new JPopupMenu.Separator());
   addNewItem(
       popup,
       "Interface",
       "images/interface.png",
       () -> SourceFileCreator.instance().create(ClassType.Interface));
   addNewItem(
       popup,
       "Structure",
       "images/structure.png",
       () -> SourceFileCreator.instance().create(ClassType.Structure));
   addNewItem(
       popup,
       "Annotation",
       "images/annotation.png",
       () -> SourceFileCreator.instance().create(ClassType.Annotation));
   popup.add(new JPopupMenu.Separator());
   addNewItem(
       popup,
       "Program",
       "images/program.png",
       () -> SourceFileCreator.instance().create(ClassType.Program));
   addNewItem(
       popup,
       "Template",
       "images/template.png",
       () -> SourceFileCreator.instance().create(ClassType.Template));
   popup.add(new JPopupMenu.Separator());
   addNewItem(
       popup,
       "Enhancement",
       "images/Enhancement.png",
       () -> SourceFileCreator.instance().create(ClassType.Enhancement));
   popup.add(new JPopupMenu.Separator());
   addNewItem(
       popup,
       "Namespace",
       "images/folder.png",
       () -> SourceFileCreator.instance().createNamespace());
   addCustomTypes();
 }
Пример #16
0
    public void update() {
      // remove all buttons
      container.removeAll();

      // number of indicators
      int count =
          IndicatorPanel.this.chartFrame.getSplitPanel().getIndicatorsPanel().getIndicatorsCount();

      ToolboxButton button;

      // Settings
      container.add(
          button =
              new ToolboxButton(
                  indicatorSettings(IndicatorPanel.this.chartFrame, IndicatorPanel.this)));
      button.setText("");
      button.setToolTipText("Settings");

      if (count > 1) {
        // Move Up
        container.add(
            button =
                new ToolboxButton(moveUp(IndicatorPanel.this.chartFrame, IndicatorPanel.this)));
        button.setText("");
        button.setToolTipText("Move Up");

        // Move Down
        container.add(
            button =
                new ToolboxButton(moveDown(IndicatorPanel.this.chartFrame, IndicatorPanel.this)));
        button.setText("");
        button.setToolTipText("Move Down");
      }

      // Toggle Maximize/Minimize
      container.add(
          button =
              new ToolboxButton(
                  isMaximized() ? minimize(IndicatorPanel.this) : maximize(IndicatorPanel.this)));
      button.setText("");
      button.setToolTipText(isMaximized() ? "Minimize" : "Maximize");

      // Remove
      container.add(
          button =
              new ToolboxButton(removeAction(IndicatorPanel.this.chartFrame, IndicatorPanel.this)));
      button.setText("");
      button.setToolTipText("Remove");

      revalidate();
      repaint();
    }
  @Override
  public JComponent createForm() {

    JComponent component = super.createForm();

    annotationComboBox.setRenderer(
        new DefaultListCellRenderer() {
          @Override
          public Component getListCellRendererComponent(
              JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
            super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
            if (value != null) {
              Annotation annotation = (Annotation) value;
              this.setText(annotation.getBrief());
            } else {
              this.setText("-- select annotation --");
            }
            return this;
          }
        });

    component.setLayout(new FormLayout("right:p, 4dlu, left:p", "p, 4dlu, p, 4dlu, p, 4dlu, p"));

    CellConstraints cc = new CellConstraints();

    component.add(getLabel("annotationLabel"), cc.xy(1, 1));
    component.add(annotationComboBox, cc.xy(3, 1));
    component.add(getLabel("patternLabel"), cc.xy(1, 3));
    component.add(patternField, cc.xy(3, 3));
    component.add(getLabel("ciLabel"), cc.xy(1, 5));
    component.add(caseInsensitive, cc.xy(3, 5));
    component.add(getLabel("remove"), cc.xy(1, 7));
    component.add(removeMatched, cc.xy(3, 7));

    patternField.setEnabled(false);
    caseInsensitive.setSelected(true);
    caseInsensitive.setEnabled(false);

    // action listener will fill out a suggested pattern for selected annotation types
    annotationComboBox.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            Object obj = annotationComboBox.getSelectedItem();
            if (obj == null) {
              patternField.setEnabled(false);
              caseInsensitive.setEnabled(false);
              setEnabled(false);
            } else {
              patternField.setEnabled(true);
              caseInsensitive.setEnabled(true);
              patternField.setText(getDefault(obj.getClass()));
              patternField.setCaretPosition(0);
              setEnabled(true);
            }
          }
        });

    return component;
  }
 public ParticleContainer(Editor editor) {
   parent = editor.getContentComponent();
   parent.add(this);
   this.setBounds(parent.getBounds());
   setVisible(true);
   parent.addComponentListener(this);
 }
Пример #19
0
  private void makeGridPanel(Component[] components) {
    final Insets insets = new Insets(5, 5, 5, 5);
    final GridBagConstraints gbc = new GridBagConstraints();

    gbc.weightx = 1.0;
    gbc.weighty = 1.0;
    gbc.insets = insets;
    gbc.ipadx = 0;
    gbc.ipady = 0;
    gbc.anchor = GridBagConstraints.EAST;
    gbc.fill = GridBagConstraints.HORIZONTAL;

    int i = 0;
    int j = 0;

    for (Component component : components) {
      gbc.gridx = i;
      gbc.gridy = j;
      gbc.gridwidth = 1;
      gbc.gridheight = 1;

      centerPanel.add(component, gbc);

      i++;

      // 2 components per row
      if ((i % 2) == 0) {
        j++;
        i = 0;
      }
    }
  }
Пример #20
0
 /**
  * Add a strut, or rigid spacing, to a UI component
  *
  * @param b the component to add the strut to, should be either a Box or a Container using a
  *     BoxLayout.
  * @param layout the desired layout orientation of the strut. One of {@link
  *     javax.swing.BoxLayout#X_AXIS}, {@link javax.swing.BoxLayout#Y_AXIS}, {@link
  *     javax.swing.BoxLayout#LINE_AXIS}, or {@link javax.swing.BoxLayout#PAGE_AXIS}.
  * @param size the length, in pixels, of the strut
  */
 public static void addStrut(JComponent b, int layout, int size) {
   if (size < 1) return;
   b.add(
       getAxis(b, layout) == BoxLayout.X_AXIS
           ? Box.createHorizontalStrut(size)
           : Box.createVerticalStrut(size));
 }
Пример #21
0
  /**
   * Creates a plugin hosts given its class name. Use PluginHostManager.HOST_* constants.
   *
   * @param pluginHostClass Class name of plugin host to create.
   * @param props Properties map.
   * @throws PluginException on plugin error.
   */
  public void setPluginHost(String pluginHostClass, Map props) throws PluginException {
    boolean firstTime = (current_ == null);
    PluginHost previous = current_;

    try {
      current_ = (PluginHost) Class.forName(pluginHostClass).newInstance();
    } catch (InstantiationException e) {
      throw new PluginException(e);
    } catch (IllegalAccessException e) {
      throw new PluginException(e);
    } catch (ClassNotFoundException e) {
      throw new PluginException(e);
    }

    if (firstTime) {
      try {
        current_.initialize(props);
      } catch (ServiceException se) {
        throw new PluginException(se);
      }
    } else {
      try {
        transferAssets(previous, current_);
      } catch (ServiceException e1) {
        throw new PluginException(e1);
      }
      recepticle_.remove(previous.getView());
    }

    recepticle_.add(current_.getView());
  }
Пример #22
0
 protected void initButtons(JComponent panel) {
   mergeRunnerB = new JButton(GecoIcon.createIcon(GecoIcon.MergeRunner));
   mergeRunnerB.setToolTipText(Messages.uiGet("RegistryBoard.MergeEcardTooltip")); // $NON-NLS-1$
   mergeRunnerB.setEnabled(false);
   mergeRunnerB.addActionListener(
       new ActionListener() {
         public void actionPerformed(ActionEvent e) {
           RunnerRaceData mergedData =
               control()
                   .mergeRunnerWithData(
                       getSelectedRunner(), wizard().getECardData(), wizard().getSourceRunner());
           wizard().closeAfterMerge(mergedData);
         }
       });
   overwriteWarningL = new JLabel(GecoIcon.createIcon(GecoIcon.Overwrite));
   overwriteWarningL.setToolTipText(
       Messages.uiGet("RegistryBoard.OverwriteWarning")); // $NON-NLS-1$
   overwriteWarningL.setVisible(false);
   mergeRunnerB.setAlignmentX(MergeWizard.CENTER_ALIGNMENT);
   overwriteWarningL.setAlignmentX(MergeWizard.CENTER_ALIGNMENT);
   Box buttons = Box.createVerticalBox();
   buttons.add(mergeRunnerB);
   buttons.add(overwriteWarningL);
   panel.add(buttons, buttonsCol(3));
 }
  public AbstractInplaceIntroducer(
      Project project,
      Editor editor,
      @Nullable E expr,
      @Nullable V localVariable,
      E[] occurrences,
      String title,
      final FileType languageFileType) {
    super(null, editor, project, title, occurrences, expr);
    myLocalVariable = localVariable;
    if (localVariable != null) {
      final PsiElement nameIdentifier = localVariable.getNameIdentifier();
      if (nameIdentifier != null) {
        myLocalMarker = createMarker(nameIdentifier);
      }
    } else {
      myLocalMarker = null;
    }
    myExprText = getExpressionText(expr);
    myLocalName = localVariable != null ? localVariable.getName() : null;

    myPreview = createPreviewComponent(project, languageFileType);
    myPreviewComponent = new JPanel(new BorderLayout());
    myPreviewComponent.add(myPreview.getComponent(), BorderLayout.CENTER);
    myPreviewComponent.setBorder(new EmptyBorder(2, 2, 6, 2));

    myWholePanel = new JPanel(new GridBagLayout());
    myWholePanel.setBorder(null);

    showDialogAdvertisement(getActionName());
  }
Пример #24
0
  /**
   * Short description in header produces unexpected line wraps in footer.
   *
   * <p>Note: the frame is not packed to simulate the appframework context.
   */
  public void interactiveHTMLTextWrapShort() {
    JXHeader header = new JXHeader();
    header.setTitle("AlbumManager");
    String headerShort =
        "An adaption from JGoodies Binding Tutorial in the context"
            + " of BeansBinding/AppFramework. ";
    header.setDescription(headerShort);
    header.setIcon(XTestUtils.loadDefaultIcon());
    JXHeader footer = new JXHeader();
    footer.setTitle("Notes:");
    String footerDescription =
        "<html>"
            + " <ul> "
            + " <li> code: in the jdnc-incubator, section kleopatra, package appframework."
            + " <li> technique: back the view by a shared presentation model "
            + " <li> technique: veto selection change until editing is completed "
            + " <li> issue: selection of tab should be vetoable "
            + " <li> issue: empty selection should disable editing pane "
            + " </ul> "
            + " </html>";
    footer.setDescription(footerDescription);

    JComponent panel = new JPanel(new BorderLayout());
    panel.add(header, BorderLayout.NORTH);
    panel.add(footer, BorderLayout.SOUTH);
    JXFrame frame = new JXFrame("html wrapping in SOUTh: short text in NORTH");
    frame.add(panel);
    frame.setSize(800, 400);
    frame.setVisible(true);
  }
 public UpdateOrStatusOptionsDialog(Project project, Map<Configurable, AbstractVcs> confs) {
   super(project);
   setTitle(getRealTitle());
   myProject = project;
   if (confs.size() == 1) {
     myMainPanel = new JPanel(new BorderLayout());
     final Configurable configurable = confs.keySet().iterator().next();
     addComponent(confs.get(configurable), configurable, BorderLayout.CENTER);
     myMainPanel.add(Box.createVerticalStrut(10), BorderLayout.SOUTH);
   } else {
     myMainPanel = new JBTabbedPane();
     final ArrayList<AbstractVcs> vcses = new ArrayList<>(confs.values());
     Collections.sort(
         vcses,
         new Comparator<AbstractVcs>() {
           public int compare(final AbstractVcs o1, final AbstractVcs o2) {
             return o1.getDisplayName().compareTo(o2.getDisplayName());
           }
         });
     Map<AbstractVcs, Configurable> vcsToConfigurable = revertMap(confs);
     for (AbstractVcs vcs : vcses) {
       addComponent(vcs, vcsToConfigurable.get(vcs), vcs.getDisplayName());
     }
   }
   init();
 }
Пример #26
0
 /**
  * Start layout determining. If it is needed, a dummy component will be created as first row. This
  * will be done, if the IzPack guiprefs modifier with the key "layoutAnchor" has the value "SOUTH"
  * or "SOUTHWEST". The earlier used value "BOTTOM" and the declaration via the IzPack variable
  * <code>IzPanel.LayoutType</code> are also supported.
  */
 private void startGridBagLayout() {
   if (layoutStarted) {
     return;
   }
   layoutStarted = true;
   if (izPanelLayout == null || !(izPanelLayout instanceof GridBagLayout)) {
     izPanelLayout = new GridBagLayout();
   }
   GridBagConstraints dgbc = new GridBagConstraints();
   dgbc.insets = new Insets(0, 0, getYGap(LABEL_GAP), 0);
   dgbc.anchor = GridBagConstraints.WEST;
   defaultConstraints = dgbc;
   parent.setLayout(izPanelLayout);
   switch (getAnchor()) {
     case SOUTH:
     case SOUTH_WEST:
       // Make a header to push the rest to the bottom.
       IzPanel.Filler dummy = new IzPanel.Filler();
       GridBagConstraints gbConstraint = (GridBagConstraints) getNextYConstraints();
       gbConstraint.weighty = 1.0;
       gbConstraint.fill = GridBagConstraints.BOTH;
       gbConstraint.anchor = GridBagConstraints.WEST;
       parent.add(dummy, gbConstraint);
       break;
     default:
       break;
   }
   // TODO: impl for layout type CENTER, ...
 }
Пример #27
0
  /**
   * Adds the supplied collection of beans at the supplied index in the list of collections. If the
   * index is not supplied then the primary collection is set (i.e. index 0). Also adds the beans to
   * the supplied JComponent container (if not null)
   *
   * @param beanInstances a <code>Vector</code> value
   * @param container a <code>JComponent</code> value
   */
  public static void setBeanInstances(
      Vector<Object> beanInstances, JComponent container, Integer... tab) {
    removeAllBeansFromContainer(container, tab);

    if (container != null) {
      for (int i = 0; i < beanInstances.size(); i++) {
        Object bean = ((BeanInstance) beanInstances.elementAt(i)).getBean();
        if (Beans.isInstanceOf(bean, JComponent.class)) {
          container.add((JComponent) bean);
        }
      }
      container.revalidate();
      container.repaint();
    }

    int index = 0;
    if (tab.length > 0) {
      index = tab[0].intValue();
    }

    if (index < TABBED_COMPONENTS.size()) {
      TABBED_COMPONENTS.set(index, beanInstances);
    }

    // COMPONENTS = beanInstances;
  }
  @Override
  protected void createMenu(final JComponent menu) {
    menu.add(
        new JMenuItem(
            CActionProxy.proxy(
                new CCreateProjectAction(
                    getParent(),
                    database,
                    new CNodeSelectionUpdater(getProjectTree(), findNode())))));

    final List<IProjectFolderMenuPlugin> plugins = new ArrayList<IProjectFolderMenuPlugin>();

    for (final IPlugin<IPluginInterface> plugin : PluginInterface.instance().getPluginRegistry()) {
      if (plugin instanceof IProjectFolderMenuPlugin) {
        plugins.add((IProjectFolderMenuPlugin) plugin);
      }
    }

    if (!plugins.isEmpty()) {
      menu.add(new JSeparator());

      for (final IProjectFolderMenuPlugin plugin : plugins) {
        try {
          final List<JComponent> menuItems = plugin.extendProjectFolderMenu(getPluginDatabase());

          if (menuItems != null) {
            for (final JComponent menuItem : menuItems) {
              menu.add(menuItem);
            }
          }
        } catch (final Exception exception) {
          CUtilityFunctions.logException(exception);

          final String innerMessage = "E00089: " + "Plugin caused an unexpected exception";
          final String innerDescription =
              CUtilityFunctions.createDescription(
                  String.format("The plugin %s caused an unexpected exception.", plugin.getName()),
                  new String[] {"The plugin contains a bug."},
                  new String[] {
                    "The plugin probably behaves erroneously from this point on but it remains active"
                  });

          CNaviErrorDialog.show(getParent(), innerMessage, innerDescription, exception);
        }
      }
    }
  }
Пример #29
0
  @Inject
  public AllocatableEditUI(RaplaContext context) throws RaplaException {
    super(context);
    classificationField = new ClassificationField<Allocatable>(context);
    permissionField = new PermissionListField(context, getString("permissions"));

    permissionField.setPermissionLevels(
        Permission.DENIED,
        Permission.READ_NO_ALLOCATION,
        Permission.READ,
        Permission.ALLOCATE,
        Permission.ALLOCATE_CONFLICTS,
        Permission.EDIT,
        Permission.ADMIN);
    final JComponent permissionPanel = permissionField.getComponent();
    editPanel.setLayout(new BorderLayout());
    editPanel.add(classificationField.getComponent(), BorderLayout.CENTER);
    holdBackConflictsField = new BooleanField(context, getString("holdbackconflicts"));
    holdBackConflictPanel = new JPanel();
    holdBackConflictPanel.setLayout(new BorderLayout());
    holdBackConflictPanel.add(
        new JLabel(holdBackConflictsField.getFieldName() + ": "), BorderLayout.WEST);
    holdBackConflictPanel.add(holdBackConflictsField.getComponent(), BorderLayout.CENTER);

    classificationField.addChangeListener(
        new ChangeListener() {

          @Override
          public void stateChanged(ChangeEvent e) {
            final boolean mainTabSelected = classificationField.isMainTabSelected();
            permissionPanel.setVisible(!mainTabSelected);
            if (!mainTabSelected && !editPanel.isAncestorOf(permissionPanel)) {
              editPanel.remove(holdBackConflictPanel);
              editPanel.add(permissionPanel, BorderLayout.SOUTH);
              editPanel.repaint();
            }

            if (mainTabSelected && (!editPanel.isAncestorOf(holdBackConflictPanel))) {
              editPanel.remove(permissionPanel);
              editPanel.add(holdBackConflictPanel, BorderLayout.SOUTH);
              editPanel.repaint();
            }
            AllocatableEditUI.this.stateChanged(e);
          }
        });
    editPanel.setPreferredSize(new Dimension(800, 600));
  }
  public OWLAnonymousIndividualAnnotationValueEditor(OWLEditorKit owlEditorKit) {
    editorKit = owlEditorKit;

    OWLAnonymousIndividualPropertyAssertionsFrame frame =
        new OWLAnonymousIndividualPropertyAssertionsFrame(owlEditorKit);

    frameList = new OWLFrameList<>(owlEditorKit, frame);

    mainComponent = new JPanel(new BorderLayout(7, 7));
    JScrollPane sp = new JScrollPane(frameList);
    JPanel scrollPaneHolder = new JPanel(new BorderLayout());
    scrollPaneHolder.add(sp);
    scrollPaneHolder.setBorder(BorderFactory.createEmptyBorder(0, 25, 0, 0));
    mainComponent.add(scrollPaneHolder);
    annotationValueLabel = new JLabel();
    mainComponent.add(annotationValueLabel, BorderLayout.NORTH);
  }