Exemple #1
0
  /**
   * And now for a little assembly. Put together the buttons, progress bar and status text field.
   */
  Example1(String name) {
    setBorder(BorderFactory.createTitledBorder(BorderFactory.createLineBorder(Color.black), name));

    progressBar.setMaximum(NUMLOOPS);

    startButton = new JButton("Start");
    startButton.addActionListener(startListener);
    startButton.setEnabled(true);

    interruptButton = new JButton("Cancel");
    interruptButton.addActionListener(interruptListener);
    interruptButton.setEnabled(false);

    JComponent buttonBox = new JPanel();
    buttonBox.add(startButton);
    buttonBox.add(interruptButton);

    setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
    add(buttonBox);
    add(progressBar);
    add(statusField);
    statusField.setAlignmentX(CENTER_ALIGNMENT);

    buttonBox.setBorder(spaceBelow);
    Border pbBorder = progressBar.getBorder();
    progressBar.setBorder(BorderFactory.createCompoundBorder(spaceBelow, pbBorder));
  }
Exemple #2
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;
  }
 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);
 }
Exemple #4
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();
 }
  @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);
 }
  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());
  }
 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();
 }
  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);
  }
  private void addField(OptionField field) {
    // Add label
    JLabel l = new JLabel(field.getDisplayName() + ":");
    GridBagConstraints c = new GridBagConstraints();
    c.gridx = 0;
    c.gridy = currentRow;
    c.insets = new Insets(5, 2, 2, 2);
    c.anchor = GridBagConstraints.NORTHWEST;
    content.add(l, c);

    // Add enable checkbox
    if (field.getEnableToggle() != null) {
      c = new GridBagConstraints();
      c.gridx = 1;
      c.gridy = currentRow;
      c.fill = GridBagConstraints.BOTH;
      c.insets = new Insets(2, 2, 2, 2);
      c.anchor = GridBagConstraints.NORTHWEST;
      content.add(field.getEnableToggle(), c);
    }

    // Add field
    c = new GridBagConstraints();
    c.gridx = 2;
    c.gridy = currentRow;
    c.fill = GridBagConstraints.BOTH;
    c.insets = new Insets(2, 2, 2, 2);
    c.anchor = GridBagConstraints.NORTHWEST;
    content.add(field.getComponent(), c);

    // Add change listener
    field.addChangeListener(
        new ChangeListener() {
          @Override
          public void stateChanged(ChangeEvent e) {
            fireChangeEvent();
          }
        });

    // Update state
    currentRow++;
    pack();
  }
Exemple #11
0
  public void setText(@Nullable final String... text) {
    myText.removeAll();
    if (text == null) return;

    for (int i = 0; i < text.length; i++) {
      final JLabel eachLabel = new JLabel(text[i], JLabel.CENTER);
      final int gap = eachLabel.getIconTextGap();
      eachLabel.setBorder(new EmptyBorder(0, 0, 0, gap));
      eachLabel.setVerticalTextPosition(JLabel.TOP);
      eachLabel.setFont(eachLabel.getFont().deriveFont(Font.BOLD, eachLabel.getFont().getSize()));
      myText.add(eachLabel);
      if (i < text.length - 1) {
        final JLabel eachIcon =
            new JLabel(IconLoader.getIcon("/general/comboArrowRight.png"), JLabel.CENTER);
        eachIcon.setBorder(new EmptyBorder(0, 0, 0, gap));
        myText.add(eachIcon);
      }
    }
  }
Exemple #12
0
 private static void addNewItem(JComponent popup, String name, String icon, Runnable action) {
   JMenuItem item =
       new JMenuItem(
           new AbstractAction(name, EditorUtilities.loadIcon(icon)) {
             public void actionPerformed(ActionEvent e) {
               action.run();
             }
           });
   popup.add(item);
 }
    /** Resets the <code>Popup</code> to an initial state. */
    void reset(Component owner, Component contents, int ownerX, int ownerY) {
      super.reset(owner, contents, ownerX, ownerY);

      JComponent component = (JComponent) getComponent();

      component.setOpaque(contents.isOpaque());
      component.setLocation(ownerX, ownerY);
      component.add(contents, BorderLayout.CENTER);
      contents.invalidate();
      pack();
    }
Exemple #14
0
 public JComponent create(UI ui, Element e) {
   JComponent p;
   try {
     int rows = Integer.parseInt(e.getAttributeValue("rows", "1"));
     int cols = Integer.parseInt(e.getAttributeValue("columns", "1"));
     p = new JPanel(new GridLayout(rows, cols));
     Iterator iter = e.getChildren("cell").iterator();
     while (iter.hasNext()) p.add(ui.create((Element) iter.next()));
   } catch (Exception ex) {
     p = new JLabel(ex.getMessage());
   }
   return p;
 }
Exemple #15
0
 private JComponent createLayerPanel() {
   JComponent panel = new JPanel();
   panel.add(new JCheckBox("JCheckBox"));
   panel.add(new JRadioButton("JRadioButton"));
   panel.add(new JTextField(15));
   JButton button = new JButton("Have a nice day");
   button.setMnemonic('H');
   button.addActionListener(
       new ActionListener() {
         public void actionPerformed(ActionEvent e) {
           logger.info("LockableLayerDemo.actionPerformed");
         }
       });
   panel.add(button);
   panel.add(new JTextField(15));
   panel.add(new JCheckBox("JCheckBox"));
   panel.add(new JRadioButton("JRadioButton"));
   panel.add(new JTextField(15));
   panel.add(new JCheckBox("JCheckBox"));
   panel.add(new JRadioButton("JRadioButton"));
   panel.setBorder(BorderFactory.createEtchedBorder());
   return panel;
 }
  @Override
  protected JComponent createChangePanel() {
    final JComponent primaryPanel = new JPanel(new BorderLayout());
    JComponent propertyPanel = new JPanel(new BorderLayout());
    JComponent nameAndRandomizePanel = new JPanel(new BorderLayout());
    JComponent propertySetterPanel = createPropertyPanel();
    JComponent centerPanel = createCenterPanel();
    if (canRandomize) {
      shouldRandomizeCheckBox = new JCheckBox();
      shouldRandomizeCheckBox.addActionListener(
          new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
              shouldRandomize = shouldRandomizeCheckBox.isSelected();
            }
          });
      nameAndRandomizePanel.add(shouldRandomizeCheckBox, BorderLayout.LINE_START);
      final MouseListener unrandomizer =
          new MouseAdapter() {
            @Override
            public void mousePressed(MouseEvent e) {
              if (e.getComponent().contains(e.getPoint())
                  && !shouldRandomizeCheckBox.contains(e.getPoint())) {
                shouldRandomizeCheckBox.setSelected(false);
                shouldRandomize = false;
              } else {
                System.out.println(e.getPoint() + "Is out of bounds");
              }
            }
          };
      ContainerListener mouseListenerAdder =
          new ContainerAdapter() {
            @Override
            public void componentAdded(ContainerEvent e) {
              addListeners(e.getChild());
            }

            public void addListeners(Component c) {
              c.addMouseListener(unrandomizer);
              if (c instanceof Container) {
                ((Container) c).addContainerListener(this);
                for (Component child : ((Container) c).getComponents()) {
                  addListeners(child);
                }
              }
            }
          };
      primaryPanel.addMouseListener(unrandomizer);
      primaryPanel.addContainerListener(mouseListenerAdder);
    }
    if (centerPanel != null) primaryPanel.add(centerPanel, BorderLayout.CENTER);
    nameAndRandomizePanel.add(new JLabel(name), BorderLayout.CENTER);
    propertyPanel.add(nameAndRandomizePanel, BorderLayout.LINE_START);
    propertyPanel.add(propertySetterPanel, BorderLayout.LINE_END);
    primaryPanel.add(propertyPanel, BorderLayout.PAGE_START);
    return primaryPanel;
  }
  /**
   * Constructs a popup using the specified settings.
   *
   * @param content The component that represents the popup content.
   * @param hideOnClick If <code>true</code> then the popup will hide when any area outside of it is
   *     clicked (rather like a popup menu). If <code>false</code> the popup will not hide when any
   *     area outside of it is clicked.
   * @param timerDelay The number of milliseconds after which the the popup will automatically hide
   *     itself. If a value of zero is specified, then the popup will remain displayed indefinitely.
   * @param isModal If <code>true</code>, mouse listener events that occur outside the component
   *     area are forwarded to the appropriate component in the content pane i.e other components
   *     may be interacted with whilst the popup is displayed. If <code>false</code> then the popup
   *     behaves rather like a modal dialog, so that no other components can receive mouse events
   *     until the component has closed.
   */
  public PopupComponent(JComponent content, boolean hideOnClick, int timerDelay, boolean isModal) {
    glassPane = new JPanel(null);

    glassPane.setLayout(null);

    glassPane.add(content);

    glassPane.setOpaque(false);

    listeners = new ArrayList<PopupComponentListener>();

    setupListeners();

    setContent(content);

    this.HIDE_ON_CLICK = hideOnClick;

    this.POPUP_IS_MODAL = isModal;

    // Check to see if a timer delay has been
    // specified.  If so, set up the timer.
    if (timerDelay > 0) {
      HIDE_ON_TIMER = true;

      HIDE_TIMER_DELAY = timerDelay;

      timer =
          new Timer(
              HIDE_TIMER_DELAY,
              new ActionListener() {
                public void actionPerformed(ActionEvent e) {
                  // Hide the popup if the mouse is outside
                  // the content
                  if (mouseOverGlassPane == true) {
                    hidePopup();

                    timer.stop();
                  } else {
                    timer.stop();

                    timer.start();
                  }
                }
              });
    }
  }
  /**
   * Sets current tool windows pane (panel where all tool windows are located). If <code>
   * toolWindowsPane</code> is <code>null</code> then the method just removes the current tool
   * windows pane.
   */
  final void setToolWindowsPane(@Nullable final ToolWindowsPane toolWindowsPane) {
    final JComponent contentPane = (JComponent) getContentPane();
    if (myToolWindowsPane != null) {
      contentPane.remove(myToolWindowsPane);
    }

    hideWelcomeScreen(contentPane);

    myToolWindowsPane = toolWindowsPane;
    if (myToolWindowsPane != null) {
      contentPane.add(myToolWindowsPane, BorderLayout.CENTER);
    } else if (!myApplication.isDisposeInProgress()) {
      showWelcomeScreen();
    }

    contentPane.revalidate();
  }
  /**
   * Creates preview for the device(video) in the video container.
   *
   * @param device the device
   * @param videoContainer the container
   * @throws IOException a problem accessing the device.
   * @throws MediaException a problem getting preview.
   */
  private static void createPreview(MediaDevice device, final JComponent videoContainer)
      throws IOException, MediaException {
    videoContainer.removeAll();

    videoContainer.revalidate();
    videoContainer.repaint();

    if (device == null) return;

    Component c =
        (Component)
            GuiActivator.getMediaService()
                .getVideoPreviewComponent(
                    device, videoContainer.getSize().width, videoContainer.getSize().height);

    videoContainer.add(c);
  }
  /**
   * Sets the content that the popup displays
   *
   * @param content A JComponent that represents the content to be displayed.
   */
  public void setContent(JComponent content) {
    if (content == null) {
      throw new NullPointerException("Popup content must not be null");
    }

    // Remove the previous popup content
    if (this.content != null) {
      glassPane.remove(this.content);
    }

    // Set this content to the new content
    this.content = content;

    // Set the size of the content
    this.content.setSize(this.content.getPreferredSize());

    // Put the content into the glass pane
    glassPane.add(this.content);
  }
Exemple #21
0
 private JComponent createToolPanel() {
   JComponent box = Box.createVerticalBox();
   JCheckBox button = new JCheckBox(disablingItem.getText());
   button.setModel(disablingItem.getModel());
   box.add(Box.createGlue());
   box.add(button);
   box.add(Box.createGlue());
   JRadioButton blur = new JRadioButton(blurItem.getText());
   blur.setModel(blurItem.getModel());
   box.add(blur);
   JRadioButton emboss = new JRadioButton(embossItem.getText());
   emboss.setModel(embossItem.getModel());
   box.add(emboss);
   JRadioButton translucent = new JRadioButton(busyPainterItem.getText());
   translucent.setModel(busyPainterItem.getModel());
   box.add(translucent);
   box.add(Box.createGlue());
   return box;
 }
  private void addSeparator(String label) {
    JPanel p = new JPanel(new GridBagLayout());
    GridBagConstraints c;

    if (label != null) {
      // left border
      c = new GridBagConstraints();
      c.gridy = 0;
      c.ipadx = 15; // half the desired width
      p.add(new JSeparator(), c);

      // label
      c = new GridBagConstraints();
      c.gridy = 0;
      c.insets = new Insets(0, 4, 0, 4);
      p.add(new JLabel(label), c);
    }

    // right border
    c = new GridBagConstraints();
    c.gridy = 0;
    c.fill = GridBagConstraints.HORIZONTAL;
    c.weightx = 1;
    p.add(new JSeparator(), c);

    // add to window
    c = new GridBagConstraints();
    c.gridx = 0;
    c.gridy = currentRow++;
    c.gridwidth = 3;
    c.fill = GridBagConstraints.HORIZONTAL;
    if (label == null) {
      // simple separator between predicate name and options; don't use
      // pronounced section break
      c.insets = new Insets(3, 0, 3, 0);
    } else {
      c.insets = new Insets(10, 0, 0, 0);
    }
    content.add(p, c);
  }
Exemple #23
0
  /**
   * Creates preview for the (video) device in the video container.
   *
   * @param device the device
   * @param videoContainer the video container
   * @throws IOException a problem accessing the device
   * @throws MediaException a problem getting preview
   */
  private static void createVideoPreview(CaptureDeviceInfo device, JComponent videoContainer)
      throws IOException, MediaException {
    videoContainer.removeAll();

    videoContainer.revalidate();
    videoContainer.repaint();

    if (device == null) return;

    for (MediaDevice mediaDevice : mediaService.getDevices(MediaType.VIDEO, MediaUseCase.ANY)) {
      if (((MediaDeviceImpl) mediaDevice).getCaptureDeviceInfo().equals(device)) {
        Dimension videoContainerSize = videoContainer.getPreferredSize();
        Component preview =
            (Component)
                mediaService.getVideoPreviewComponent(
                    mediaDevice, videoContainerSize.width, videoContainerSize.height);

        if (preview != null) videoContainer.add(preview);
        break;
      }
    }
  }
  public void addComponent(JComponent parent, JComponent child, Tag childTag, String constraint) {

    if ("left".equals(constraint)) {
      checkConstraint(parent, BorderLayout.WEST);
      parent.add(child, BorderLayout.WEST);
    } else if ("center".equals(constraint)) {
      checkConstraint(parent, BorderLayout.CENTER);
      parent.add(child, BorderLayout.CENTER);
    } else if ("right".equals(constraint)) {
      checkConstraint(parent, BorderLayout.EAST);
      parent.add(child, BorderLayout.EAST);
    } else if ("bottom".equals(constraint)) {
      checkConstraint(parent, BorderLayout.SOUTH);
      parent.add(child, BorderLayout.SOUTH);
    } else if ("top".equals(constraint)) {
      checkConstraint(parent, BorderLayout.NORTH);
      parent.add(child, BorderLayout.NORTH);
    } else {
      checkConstraint(parent, BorderLayout.CENTER);
      parent.add(child);
    }
  }
  /**
   * Shows the hint in the layered pane. Coordinates <code>x</code> and <code>y</code> are in <code>
   * parentComponent</code> coordinate system. Note that the component appears on 250 layer.
   */
  @Override
  public void show(
      @NotNull final JComponent parentComponent,
      final int x,
      final int y,
      final JComponent focusBackComponent,
      @NotNull final HintHint hintHint) {
    myParentComponent = parentComponent;
    myHintHint = hintHint;

    myFocusBackComponent = focusBackComponent;

    LOG.assertTrue(myParentComponent.isShowing());
    myEscListener = new MyEscListener();
    myComponent.registerKeyboardAction(
        myEscListener,
        KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0),
        JComponent.WHEN_IN_FOCUSED_WINDOW);
    myComponent.registerKeyboardAction(
        myEscListener, KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), JComponent.WHEN_FOCUSED);
    final JLayeredPane layeredPane = parentComponent.getRootPane().getLayeredPane();

    myComponent.validate();

    if (!myForceShowAsPopup
        && (myForceLightweightPopup
            || fitsLayeredPane(
                layeredPane,
                myComponent,
                new RelativePoint(parentComponent, new Point(x, y)),
                hintHint))) {
      beforeShow();
      final Dimension preferredSize = myComponent.getPreferredSize();

      if (hintHint.isAwtTooltip()) {
        IdeTooltip tooltip =
            new IdeTooltip(
                hintHint.getOriginalComponent(),
                hintHint.getOriginalPoint(),
                myComponent,
                hintHint,
                myComponent) {
              @Override
              protected boolean canAutohideOn(TooltipEvent event) {
                if (event.getInputEvent() instanceof MouseEvent) {
                  return !(hintHint.isContentActive() && event.isIsEventInsideBalloon());
                } else if (event.getAction() != null) {
                  return false;
                } else {
                  return true;
                }
              }

              @Override
              protected void onHidden() {
                fireHintHidden();
                TooltipController.getInstance().resetCurrent();
              }

              @Override
              public boolean canBeDismissedOnTimeout() {
                return false;
              }
            }.setToCenterIfSmall(hintHint.isMayCenterTooltip())
                .setPreferredPosition(hintHint.getPreferredPosition())
                .setHighlighterType(hintHint.isHighlighterType())
                .setTextForeground(hintHint.getTextForeground())
                .setTextBackground(hintHint.getTextBackground())
                .setBorderColor(hintHint.getBorderColor())
                .setBorderInsets(hintHint.getBorderInsets())
                .setFont(hintHint.getTextFont())
                .setCalloutShift(hintHint.getCalloutShift())
                .setPositionChangeShift(
                    hintHint.getPositionChangeX(), hintHint.getPositionChangeY())
                .setExplicitClose(hintHint.isExplicitClose())
                .setHint(true);
        myComponent.validate();
        myCurrentIdeTooltip =
            IdeTooltipManager.getInstance()
                .show(tooltip, hintHint.isShowImmediately(), hintHint.isAnimationEnabled());
      } else {
        final Point layeredPanePoint =
            SwingUtilities.convertPoint(parentComponent, x, y, layeredPane);
        myComponent.setBounds(
            layeredPanePoint.x, layeredPanePoint.y, preferredSize.width, preferredSize.height);
        layeredPane.add(myComponent, JLayeredPane.POPUP_LAYER);

        myComponent.validate();
        myComponent.repaint();
      }
    } else {
      myIsRealPopup = true;
      Point actualPoint = new Point(x, y);
      JComponent actualComponent = new OpaquePanel(new BorderLayout());
      actualComponent.add(myComponent, BorderLayout.CENTER);
      if (isAwtTooltip()) {
        fixActualPoint(actualPoint);

        int inset = BalloonImpl.getNormalInset();
        actualComponent.setBorder(new LineBorder(hintHint.getTextBackground(), inset));
        actualComponent.setBackground(hintHint.getTextBackground());
        actualComponent.validate();
      }

      myPopup =
          JBPopupFactory.getInstance()
              .createComponentPopupBuilder(actualComponent, myFocusRequestor)
              .setRequestFocus(myFocusRequestor != null)
              .setFocusable(myFocusRequestor != null)
              .setResizable(myResizable)
              .setMovable(myTitle != null)
              .setTitle(myTitle)
              .setModalContext(false)
              .setShowShadow(isRealPopup() && !isForceHideShadow())
              .setCancelKeyEnabled(false)
              .setCancelOnClickOutside(myCancelOnClickOutside)
              .setCancelCallback(
                  new Computable<Boolean>() {
                    @Override
                    public Boolean compute() {
                      onPopupCancel();
                      return true;
                    }
                  })
              .setCancelOnOtherWindowOpen(myCancelOnOtherWindowOpen)
              .createPopup();

      beforeShow();
      myPopup.show(new RelativePoint(myParentComponent, new Point(actualPoint.x, actualPoint.y)));
    }
  }
  protected JComponent createCenterPanel() {
    JPanel panel = new MyPanel();

    myUiUpdater = new MergingUpdateQueue("FileChooserUpdater", 200, false, panel);
    Disposer.register(myDisposable, myUiUpdater);
    new UiNotifyConnector(panel, myUiUpdater);

    panel.setBorder(JBUI.Borders.empty());

    createTree();

    final DefaultActionGroup group = createActionGroup();
    ActionToolbar toolBar =
        ActionManager.getInstance().createActionToolbar(ActionPlaces.UNKNOWN, group, true);
    toolBar.setTargetComponent(panel);

    final JPanel toolbarPanel = new JPanel(new BorderLayout());
    toolbarPanel.add(toolBar.getComponent(), BorderLayout.CENTER);

    myTextFieldAction =
        new TextFieldAction() {
          public void linkSelected(final LinkLabel aSource, final Object aLinkData) {
            toggleShowTextField();
          }
        };
    toolbarPanel.add(myTextFieldAction, BorderLayout.EAST);

    myPathTextFieldWrapper = new JPanel(new BorderLayout());
    myPathTextFieldWrapper.setBorder(JBUI.Borders.emptyBottom(2));
    myPathTextField =
        new FileTextFieldImpl.Vfs(
            FileChooserFactoryImpl.getMacroMap(),
            getDisposable(),
            new LocalFsFinder.FileChooserFilter(myChooserDescriptor, myFileSystemTree)) {
          protected void onTextChanged(final String newValue) {
            myUiUpdater.cancelAllUpdates();
            updateTreeFromPath(newValue);
          }
        };
    Disposer.register(myDisposable, myPathTextField);
    myPathTextFieldWrapper.add(myPathTextField.getField(), BorderLayout.CENTER);
    if (getRecentFiles().length > 0) {
      myPathTextFieldWrapper.add(createHistoryButton(), BorderLayout.EAST);
    }

    myNorthPanel = new JPanel(new BorderLayout());
    myNorthPanel.add(toolbarPanel, BorderLayout.NORTH);

    updateTextFieldShowing();

    panel.add(myNorthPanel, BorderLayout.NORTH);

    registerMouseListener(group);

    JScrollPane scrollPane = ScrollPaneFactory.createScrollPane(myFileSystemTree.getTree());
    // scrollPane.setBorder(BorderFactory.createLineBorder(new Color(148, 154, 156)));
    panel.add(scrollPane, BorderLayout.CENTER);
    panel.setPreferredSize(JBUI.size(400));

    panel.add(
        new JLabel(
            "<html><center><small><font color=gray>Drag and drop a file into the space above to quickly locate it in the tree.</font></small></center></html>",
            SwingConstants.CENTER),
        BorderLayout.SOUTH);

    ApplicationManager.getApplication()
        .getMessageBus()
        .connect(getDisposable())
        .subscribe(
            ApplicationActivationListener.TOPIC,
            new ApplicationActivationListener.Adapter() {
              @Override
              public void applicationActivated(IdeFrame ideFrame) {
                ((SaveAndSyncHandlerImpl) SaveAndSyncHandler.getInstance())
                    .maybeRefresh(ModalityState.current());
              }
            });

    return panel;
  }
Exemple #27
0
 public AttributesPanel() {
   this.setLayout(new BorderLayout());
   super.add(box, BorderLayout.CENTER);
 }
  private void recreateEditorsPanel() {
    myValuesPanel.removeAll();
    myValuesPanel.setLayout(new CardLayout());

    if (!myProject.isOpen()) return;
    JPanel valuesPanelComponent = new MyJPanel(new GridBagLayout());
    myValuesPanel.add(
        new JBScrollPane(valuesPanelComponent) {
          @Override
          public void updateUI() {
            super.updateUI();
            getViewport().setBackground(UIUtil.getPanelBackground());
          }
        },
        VALUES);
    myValuesPanel.add(myNoPropertySelectedPanel, NO_PROPERTY_SELECTED);

    List<PropertiesFile> propertiesFiles = myResourceBundle.getPropertiesFiles();

    GridBagConstraints gc =
        new GridBagConstraints(
            0,
            0,
            0,
            0,
            0,
            0,
            GridBagConstraints.NORTHWEST,
            GridBagConstraints.BOTH,
            new Insets(5, 5, 5, 5),
            0,
            0);
    releaseAllEditors();
    myTitledPanels.clear();
    int y = 0;
    Editor previousEditor = null;
    Editor firstEditor = null;
    for (final PropertiesFile propertiesFile : propertiesFiles) {
      final Editor editor = createEditor();
      final Editor oldEditor = myEditors.put(propertiesFile, editor);
      if (firstEditor == null) {
        firstEditor = editor;
      }
      if (previousEditor != null) {
        editor.putUserData(
            ChooseSubsequentPropertyValueEditorAction.PREV_EDITOR_KEY, previousEditor);
        previousEditor.putUserData(
            ChooseSubsequentPropertyValueEditorAction.NEXT_EDITOR_KEY, editor);
      }
      previousEditor = editor;
      if (oldEditor != null) {
        EditorFactory.getInstance().releaseEditor(oldEditor);
      }
      ((EditorEx) editor)
          .addFocusListener(
              new FocusChangeListener() {
                @Override
                public void focusGained(final Editor editor) {
                  mySelectedEditor = editor;
                }

                @Override
                public void focusLost(final Editor eventEditor) {
                  writeEditorPropertyValue(editor, propertiesFile, null);
                }
              });
      gc.gridx = 0;
      gc.gridy = y++;
      gc.gridheight = 1;
      gc.gridwidth = GridBagConstraints.REMAINDER;
      gc.weightx = 1;
      gc.weighty = 1;
      gc.anchor = GridBagConstraints.CENTER;

      Locale locale = propertiesFile.getLocale();
      List<String> names = new ArrayList<String>();
      if (!Comparing.strEqual(locale.getDisplayLanguage(), null)) {
        names.add(locale.getDisplayLanguage());
      }
      if (!Comparing.strEqual(locale.getDisplayCountry(), null)) {
        names.add(locale.getDisplayCountry());
      }
      if (!Comparing.strEqual(locale.getDisplayVariant(), null)) {
        names.add(locale.getDisplayVariant());
      }

      String title = propertiesFile.getName();
      if (!names.isEmpty()) {
        title += " (" + StringUtil.join(names, "/") + ")";
      }
      JComponent comp =
          new JPanel(new BorderLayout()) {
            @Override
            public Dimension getPreferredSize() {
              Insets insets = getBorder().getBorderInsets(this);
              return new Dimension(100, editor.getLineHeight() * 4 + insets.top + insets.bottom);
            }
          };
      comp.add(editor.getComponent(), BorderLayout.CENTER);
      comp.setBorder(IdeBorderFactory.createTitledBorder(title, true));
      myTitledPanels.put(propertiesFile, (JPanel) comp);

      valuesPanelComponent.add(comp, gc);
    }
    if (previousEditor != null) {
      previousEditor.putUserData(
          ChooseSubsequentPropertyValueEditorAction.NEXT_EDITOR_KEY, firstEditor);
      firstEditor.putUserData(
          ChooseSubsequentPropertyValueEditorAction.PREV_EDITOR_KEY, previousEditor);
    }

    gc.gridx = 0;
    gc.gridy = y;
    gc.gridheight = GridBagConstraints.REMAINDER;
    gc.gridwidth = GridBagConstraints.REMAINDER;
    gc.weightx = 10;
    gc.weighty = 1;

    valuesPanelComponent.add(new JPanel(), gc);
    selectionChanged();
    myValuesPanel.repaint();
    UIUtil.invokeAndWaitIfNeeded(
        new Runnable() {
          @Override
          public void run() {
            updateEditorsFromProperties();
          }
        });
  }
Exemple #29
0
  @Override
  protected void zmenaVyberu(final Set<Alela> aAlelyx) {
    jmenaVybranychAlel = Alela.alelyToNames(aAlelyx);
    final Genotyp genotyp = new Genotyp(aAlelyx, bag.getGenom());
    final Sklivec sklivec = bag.getSklivec(genotyp);
    jskelneikony.removeAll();
    // BoundingRect br = Imagant.sjednoceni(sklivec.imaganti);
    {
      jskelneikony.add(Box.createVerticalStrut(20));
      final JButton jLabel = new JButton();
      jLabel.setAlignmentX(CENTER_ALIGNMENT);
      // jLabel.setText("všechna skla přes sebe");
      final Imagant imagant = Sklo.prekresliNaSebe(sklivec.imaganti);
      if (imagant != null) {
        jLabel.setIcon(new ImageIcon(imagant.getImage()));
      }
      jskelneikony.add(jLabel);
    }
    jskelneikony.add(Box.createVerticalStrut(50));

    final Iterator<SkloAplikant> iterator = bag.getSada().getSkloAplikanti().iterator();

    for (final Imagant imagant : sklivec.imaganti) {
      final SkloAplikant skloAplikant = iterator.next();
      final Box panel = Box.createHorizontalBox();
      final TitledBorder border = BorderFactory.createTitledBorder(skloAplikant.sklo.getName());
      border.setTitleJustification(TitledBorder.CENTER);
      panel.setBorder(border);
      final JLabel jLabel = new JLabel();
      // jLabel.setText("sklo");
      if (imagant != null) {
        jLabel.setIcon(new ImageIcon(imagant.getImage()));
      }
      jLabel.setAlignmentX(CENTER_ALIGNMENT);

      panel.add(Box.createHorizontalGlue());
      panel.add(jLabel);
      panel.add(Box.createHorizontalGlue());

      panel.setMinimumSize(new Dimension(150, 100));
      panel.setPreferredSize(new Dimension(150, 100));

      // JLabel jJmenoSady = new JLabel(skloAplikant.sklo.getName());
      // jJmenoSady.setAlignmentX(JComponent.CENTER_ALIGNMENT);
      // jskelneikony.add(jJmenoSady);
      jskelneikony.add(panel);
      jskelneikony.add(Box.createVerticalStrut(10));
    }
    jskelneikony.add(Box.createVerticalGlue());

    final JCheckBox jZobrazovaniVseho = new JCheckBox("Zobrazit vše");
    jZobrazovaniVseho.setSelected(zobrazovatVse);
    jskelneikony.add(jZobrazovaniVseho);

    jZobrazovaniVseho.addItemListener(
        e -> {
          zobrazovatVse = jZobrazovaniVseho.isSelected();
          resetBag(bag);
        });

    // a teď vyrendrovat vše přes sebe

    System.out.println(genotyp);
    jskelneikony.revalidate();
    // pack();
  }
Exemple #30
0
  /**
   * Creates the UI controls which are to control the details of a specific <tt>AudioSystem</tt>.
   *
   * @param audioSystem the <tt>AudioSystem</tt> for which the UI controls to control its details
   *     are to be created
   * @param container the <tt>JComponent</tt> into which the UI controls which are to control the
   *     details of the specified <tt>audioSystem</tt> are to be added
   */
  public static void createAudioSystemControls(AudioSystem audioSystem, JComponent container) {
    GridBagConstraints constraints = new GridBagConstraints();

    constraints.anchor = GridBagConstraints.NORTHWEST;
    constraints.fill = GridBagConstraints.HORIZONTAL;
    constraints.weighty = 0;

    int audioSystemFeatures = audioSystem.getFeatures();
    boolean featureNotifyAndPlaybackDevices =
        ((audioSystemFeatures & AudioSystem.FEATURE_NOTIFY_AND_PLAYBACK_DEVICES) != 0);

    constraints.gridx = 0;
    constraints.insets = new Insets(3, 0, 3, 3);
    constraints.weightx = 0;

    constraints.gridy = 0;
    container.add(
        new JLabel(getLabelText(DeviceConfigurationComboBoxModel.AUDIO_CAPTURE)), constraints);
    if (featureNotifyAndPlaybackDevices) {
      constraints.gridy = 2;
      container.add(
          new JLabel(getLabelText(DeviceConfigurationComboBoxModel.AUDIO_PLAYBACK)), constraints);
      constraints.gridy = 3;
      container.add(
          new JLabel(getLabelText(DeviceConfigurationComboBoxModel.AUDIO_NOTIFY)), constraints);
    }

    constraints.gridx = 1;
    constraints.insets = new Insets(3, 3, 3, 0);
    constraints.weightx = 1;

    JComboBox captureCombo = null;

    if (featureNotifyAndPlaybackDevices) {
      captureCombo = new JComboBox();
      captureCombo.setEditable(false);
      captureCombo.setModel(
          new DeviceConfigurationComboBoxModel(
              captureCombo,
              mediaService.getDeviceConfiguration(),
              DeviceConfigurationComboBoxModel.AUDIO_CAPTURE));
      constraints.gridy = 0;
      container.add(captureCombo, constraints);
    }

    int anchor = constraints.anchor;
    SoundLevelIndicator capturePreview =
        new SoundLevelIndicator(
            SimpleAudioLevelListener.MIN_LEVEL, SimpleAudioLevelListener.MAX_LEVEL);

    constraints.anchor = GridBagConstraints.CENTER;
    constraints.gridy = (captureCombo == null) ? 0 : 1;
    container.add(capturePreview, constraints);
    constraints.anchor = anchor;

    constraints.gridy = GridBagConstraints.RELATIVE;

    if (featureNotifyAndPlaybackDevices) {
      JComboBox playbackCombo = new JComboBox();

      playbackCombo.setEditable(false);
      playbackCombo.setModel(
          new DeviceConfigurationComboBoxModel(
              captureCombo,
              mediaService.getDeviceConfiguration(),
              DeviceConfigurationComboBoxModel.AUDIO_PLAYBACK));
      container.add(playbackCombo, constraints);

      JComboBox notifyCombo = new JComboBox();

      notifyCombo.setEditable(false);
      notifyCombo.setModel(
          new DeviceConfigurationComboBoxModel(
              captureCombo,
              mediaService.getDeviceConfiguration(),
              DeviceConfigurationComboBoxModel.AUDIO_NOTIFY));
      container.add(notifyCombo, constraints);
    }

    if ((AudioSystem.FEATURE_ECHO_CANCELLATION & audioSystemFeatures) != 0) {
      final SIPCommCheckBox echoCancelCheckBox =
          new SIPCommCheckBox(
              NeomediaActivator.getResources().getI18NString("impl.media.configform.ECHOCANCEL"));

      /*
       * First set the selected one, then add the listener in order to
       * avoid saving the value when using the default one and only
       * showing to user without modification.
       */
      echoCancelCheckBox.setSelected(mediaService.getDeviceConfiguration().isEchoCancel());
      echoCancelCheckBox.addItemListener(
          new ItemListener() {
            public void itemStateChanged(ItemEvent e) {
              mediaService.getDeviceConfiguration().setEchoCancel(echoCancelCheckBox.isSelected());
            }
          });
      container.add(echoCancelCheckBox, constraints);
    }

    if ((AudioSystem.FEATURE_DENOISE & audioSystemFeatures) != 0) {
      final SIPCommCheckBox denoiseCheckBox =
          new SIPCommCheckBox(
              NeomediaActivator.getResources().getI18NString("impl.media.configform.DENOISE"));

      /*
       * First set the selected one, then add the listener in order to
       * avoid saving the value when using the default one and only
       * showing to user without modification.
       */
      denoiseCheckBox.setSelected(mediaService.getDeviceConfiguration().isDenoise());
      denoiseCheckBox.addItemListener(
          new ItemListener() {
            public void itemStateChanged(ItemEvent e) {
              mediaService.getDeviceConfiguration().setDenoise(denoiseCheckBox.isSelected());
            }
          });
      container.add(denoiseCheckBox, constraints);
    }

    createAudioPreview(audioSystem, captureCombo, capturePreview);
  }