private void jbInit() throws Exception {
   this.setSize(new Dimension(560, 293));
   setTitle("Please select a contact to send");
   _scrollPaneContactList.setBounds(15, 10, 530, 237);
   _listContactList.setOpaque(false);
   _listContactList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
   _listContactList.setCellRenderer(new ContactListRenderer());
   _listContactList.addListSelectionListener(
       new ListSelectionListener() {
         public void valueChanged(ListSelectionEvent listSelectionEvent) {
           _listContactList_valueChanged(listSelectionEvent);
         }
       });
   _listContactList.setVisibleRowCount(JLIST_VISIBLE_ROW_COUNT);
   _scrollPaneContactList.addScrollUpButtonActionListener(
       new ActionListener() {
         public void actionPerformed(ActionEvent actionEvent) {
           _scrollPaneContactList_scrollUp(actionEvent);
         }
       });
   _scrollPaneContactList.addScrollDownButtonActionListener(
       new ActionListener() {
         public void actionPerformed(ActionEvent actionEvent) {
           _scrollPaneContactList_scrollDown(actionEvent);
         }
       });
   _scrollPaneContactList.addToViewport(_listContactList);
   _panelContent.add(_scrollPaneContactList, null);
 }
Пример #2
0
  public TeamPanel(int teamSize, GameDTO game, List<Participant> players) {
    super();
    setOpaque(false);

    list = new JList();
    list.setVisibleRowCount(teamSize);
    list.setOpaque(false);
    list.setCellRenderer(new ChampSelectCellRenderer());
    list.setFixedCellHeight(90);
    list.setFixedCellWidth(130);
    updateGame(game, players);

    JScrollPane scroll = new JScrollPane(list);
    //		scroll.setMinimumSize(new Dimension(160, scroll.getPreferredSize().height));

    add(scroll, BorderLayout.CENTER);
  }
  private void init() {
    JScrollPane _scroll =
        new JScrollPane(
            _previewList = new JList(new TopTermListModel()),
            JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
            JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    _scroll.setBorder(null);

    _previewList.setOpaque(false);
    _previewList.setCellRenderer(new TopTermListCellRenderer());
    _previewList.setVisibleRowCount(1);
    _previewList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    _previewList.setLayoutOrientation(JList.HORIZONTAL_WRAP);
    _scroll.setViewportView(_previewList);

    RemoveableListManager removeableListManager = new RemoveableListManager(_previewList);

    add(_previewList, BorderLayout.CENTER);
  }
Пример #4
0
  /** Refreshes the game list panel */
  public void refreshPlayerList() {
    DefaultListModel model = new DefaultListModel();

    List players = this.graphicLobby.lobbyClient.getPlayers();

    if (players != null)
      for (Iterator iterator = players.iterator(); iterator.hasNext(); )
        model.addElement((String) iterator.next());

    JList list = new JList(model);
    list.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION);
    list.setLayoutOrientation(JList.VERTICAL);
    list.setVisibleRowCount(-1);
    list.setFont(new Font("Comic Sans MS", Font.BOLD, 15));
    list.setForeground(Color.black);
    list.setOpaque(false);

    list.repaint();
    list.revalidate();

    super.setViewportView(list);
  }
Пример #5
0
    @SuppressWarnings("unchecked") // we must be compatible with 1.6
    public VersionManagementPanel(final VisualCanvas canvas) {

      super(canvas);

      setLayout(new GridLayout());

      // TODO @Christian Poliwoda what does manual testing mean?
      // numbers tested manually
      Dimension prefScrollPaneDim = new Dimension(100, 30);
      Dimension visibleRectDim = canvas.getVisibleRect().getSize();

      final VersionController controller =
          canvas.getProjectController().getProject().getProjectFile();

      final int numVersions = controller.getNumberOfVersions() - 1;

      versionData = new Object[numVersions];

      ArrayList<RevCommit> versions = new ArrayList<RevCommit>();

      try {
        versions = controller.getVersions();
      } catch (IOException ex) {
        Logger.getLogger(VersionManagementPanel.class.getName()).log(Level.SEVERE, null, ex);
      }

      int maxTextwidth = 0;
      String longestText = null;

      // the history with timestamp and a short commit message
      for (int i = 1; i < versions.size(); i++) {
        String text =
            // + Message.generateHTMLSpace(3)
            new Date(versions.get(i).getCommitTime() * 1000L)
                + ": "
                + versions.get(i).getShortMessage();

        // truncate texts that are too long
        int maxTextLength = 100;
        String dots = "...";

        int textLength = text.length() - dots.length();

        if (textLength > maxTextLength) {
          text = text.substring(0, maxTextLength) + dots;
        }

        versionData[versions.size() - i - 1] = new Version(text, i);

        if (text.length() > maxTextwidth) {
          maxTextwidth = text.length();
          longestText = text;
        }
      }

      resultModel = new DefaultListModel();

      // first init to show all if search not started yet
      for (int i = 0; i < versionData.length; i++) {
        resultModel.addElement(versionData[i]);
      }

      versionList = new JList(resultModel);

      // set the width of version managment window
      // dependent on largest git short message length
      double maxFontWidth =
          versionList
              .getFontMetrics(versionList.getFont())
              .getStringBounds(longestText, versionList.getGraphics())
              .getWidth();

      if (maxFontWidth <= visibleRectDim.width) {

        prefScrollPaneDim.width = (int) maxFontWidth;
      } else {

        if (visibleRectDim.width < 400) {
          prefScrollPaneDim.width = visibleRectDim.width;
        } else {
          prefScrollPaneDim.width = 400;
        }
      }

      versionList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);

      versionList.setOpaque(false);

      versionList.setBackground(VSwingUtil.TRANSPARENT_COLOR);
      versionList.setBorder(new EmptyBorder(3, 3, 3, 3));

      Box upperTopBox = Box.createVerticalBox();

      // press the commits to top with VerticalGlue
      // contains search area at top and
      // search results at the botton
      Box upperOuterBox = Box.createVerticalBox();

      JButton searchButton = new JButton("search");
      searchButton.addActionListener(
          new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent ae) {
              searchAndAddToResultList();
            }
          });

      searchField = new JTextArea();

      // search area box
      Box upperBox1 = Box.createHorizontalBox();

      upperBox1.add(searchField);
      upperBox1.add(searchButton);

      Dimension fieldDim = new Dimension(Short.MAX_VALUE, searchField.getPreferredSize().height);
      searchField.setMaximumSize(fieldDim);

      searchField.addKeyListener(
          new KeyAdapter() {
            String tmp = "";

            @Override
            public void keyReleased(KeyEvent ke) {

              searchAndAddToResultList();
            }
          });

      //            upperOuterBox.add(upperBox1);
      upperTopBox.add(upperBox1);
      upperTopBox.add(upperOuterBox);

      // result area box
      Box upperBox2 = Box.createHorizontalBox();

      upperBox2.add(Box.createHorizontalGlue());
      upperBox2.add(versionList);
      upperBox2.add(Box.createHorizontalGlue());

      upperOuterBox.add(upperBox2);
      upperOuterBox.add(Box.createVerticalGlue());

      // added for optical reasons to force correct scrollbar position
      Box upperInnerBorderPane = Box.createHorizontalBox();
      upperInnerBorderPane.add(upperOuterBox);
      upperInnerBorderPane.setBorder(new EmptyBorder(5, 15, 5, 15));
      upperInnerBorderPane.setBackground(VSwingUtil.TRANSPARENT_COLOR);

      VScrollPane upperScrollPane = new VScrollPane(upperInnerBorderPane);
      upperScrollPane.setHorizontalScrollBarPolicy(VScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
      upperScrollPane.setVerticalScrollBarPolicy(VScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
      upperScrollPane.setMinimumSize(prefScrollPaneDim);

      JSplitPane splitPane = new VSplitPane(JSplitPane.VERTICAL_SPLIT);
      splitPane.setEnabled(true); // true = transparent
      splitPane.setBackground(VSwingUtil.TRANSPARENT_COLOR);
      splitPane.setBorder(new EmptyBorder(5, 5, 5, 5));
      splitPane.setDividerLocation(0.5);

      upperTopBox.add(upperScrollPane);
      splitPane.add(upperTopBox); // add in the upper part

      htmlCommit.setBackground(VSwingUtil.TRANSPARENT_COLOR);
      htmlCommit.setContentType("text/html");
      htmlCommit.setOpaque(false);
      htmlCommit.setEditable(false);
      htmlCommit.setBorder(new EmptyBorder(0, 15, 0, 15));

      Box lowerBox = Box.createVerticalBox();
      lowerBox.setAlignmentX(Component.LEFT_ALIGNMENT);
      lowerBox.add(htmlCommit);
      lowerBox.add(Box.createVerticalGlue());

      VScrollPane lowerScrollPane = new VScrollPane(lowerBox);

      lowerScrollPane.setHorizontalScrollBarPolicy(VScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
      lowerScrollPane.setVerticalScrollBarPolicy(VScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
      lowerScrollPane.setMinimumSize(new Dimension(0, 0));

      // add in the lower part
      splitPane.setBottomComponent(lowerScrollPane);

      add(splitPane);

      versionList.addMouseListener(
          new MouseAdapter() {
            @Override
            public void mouseClicked(MouseEvent e) {

              // show commit message in lower part if clicked on a row
              // in upper part
              if (e.getClickCount() == 1) {

                final VersionController controller =
                    canvas.getProjectController().getProject().getProjectFile();

                final int numVersions = controller.getNumberOfVersions() - 1;

                ArrayList<RevCommit> versions = new ArrayList<RevCommit>();

                try {
                  versions = controller.getVersions();
                } catch (IOException ex) {
                  Logger.getLogger(VersionManagementPanel.class.getName())
                      .log(Level.SEVERE, null, ex);
                }

                int versionIndex = ((Version) versionList.getSelectedValue()).getVersion();

                htmlCommit.setText(
                    "<html>"
                        + "<pre> <font color=white><br>"
                        + "<b>SHA-1:</b> "
                        + versions.get(versionIndex).getName()
                        + "<br><br>"
                        + "<b>Message:</b><br><br>"
                        + versions.get(versionIndex).getFullMessage()
                        + "</pre></p>"
                        + "</html>");
                htmlCommit.setCaretPosition(0);
              }

              if (e.getClickCount() == 2 && SwingUtilities.isLeftMouseButton(e)) {

                if (((Version) versionList.getSelectedValue()).getVersion() < 2) {
                  VDialog.showMessageDialog(
                      canvas,
                      "Cannot Load Version",
                      "The first version in a project contains no"
                          + " sessions and cannot be loaded!");
                  return;
                }

                //                        if (VDialog.showConfirmDialog(canvas,
                //                                "Checkout Version:",
                //                                "<html><div align=Center>"
                //                                + "<p>Do you want to checkout the selected"
                //                                + " version?<p>"
                //                                + "<p><b>Unsaved changes will be lost!</b></p>"
                //                                + "</div></html>",
                //                                VDialog.DialogType.YES_NO) != VDialog.YES) {
                //                            return;
                //                        }

                int answer =
                    VDialog.showConfirmDialog(
                        canvas,
                        "Checkout Version:",
                        "<html><div align=Center>"
                            + "<p>Checking out selected version.<p><br>"
                            + "<p>Do you want to save the current session?</p><br>"
                            + "<p><b>Unsaved changes will be lost!</b></p>"
                            + "</div></html>",
                        new String[] {"Save", "Discard", "Cancel"});

                if (answer == 0) {
                  try {
                    canvas.getProjectController().saveProject(false);
                  } catch (IOException ex) {
                    Logger.getLogger(VersionManagement.class.getName()).log(Level.SEVERE, null, ex);

                    VDialog.showMessageDialog(
                        canvas,
                        "Cannot save Project:",
                        "<html><div align=Center>" + "Project cannot be saved!" + "</div></html>");
                  }
                } else if (answer == 1) {
                  // nothing to do
                } else if (answer == 2) {
                  return;
                }

                try {

                  int versionIndex = ((Version) versionList.getSelectedValue()).getVersion();

                  canvas.setActive(false);

                  String currentSessionName = canvas.getProjectController().getCurrentSession();

                  canvas.getProjectController().close(currentSessionName);

                  controller.checkoutVersion(versionIndex);

                  if (dialog != null) {
                    dialog.close();
                    dialog = null;
                  }

                  if (canvas
                      .getProjectController()
                      .getProject()
                      .getSessionFileByEntryName(currentSessionName)
                      .exists()) {
                    canvas.getProjectController().open(currentSessionName, false, true);
                  } else {
                    //                                VDialog.showMessageDialog(canvas,
                    //                                        "Cannot load \""
                    //                                        + currentSessionName
                    //                                        +"\":", "<html><div align=Center>"
                    //                                        + "<p>The Session "
                    //                                        + Message.EMPHASIZE_BEGIN
                    //                                        + currentSessionName
                    //                                         +  Message.EMPHASIZE_END
                    //                                        + " does not exist in the current"
                    //                                        + " version."
                    //                                        + "<p>The <b>Main</b>-Session will"
                    //                                        + "be loaded instead</div></html>");
                    canvas.getProjectController().open("Main", false, true);
                  }

                } catch (IOException ex) {
                  Logger.getLogger(VersionManagementPanel.class.getName())
                      .log(Level.SEVERE, null, ex);
                }
              }
            }
          });

      //            setMinimumSize(visibleRectDim);
      setMaximumSize(visibleRectDim);

      int width = getPreferredSize().width;
      setPreferredSize(new Dimension(width, (int) (visibleRectDim.height * 0.5)));
    } // end constructure
  public PerformanceVectorViewer(
      final PerformanceVector performanceVector, final IOContainer container) {
    setLayout(new BorderLayout());

    // all criteria
    final CardLayout cardLayout = new CardLayout();
    final JPanel mainPanel = new JPanel(cardLayout);
    add(mainPanel, BorderLayout.CENTER);
    List<String> criteriaNameList = new LinkedList<>();
    for (int i = 0; i < performanceVector.getSize(); i++) {
      PerformanceCriterion criterion = performanceVector.getCriterion(i);
      criteriaNameList.add(criterion.getName());
      JPanel component =
          ResultDisplayTools.createVisualizationComponent(
              criterion, container, "Performance Criterion", false);
      JScrollPane criterionPane = new ExtendedJScrollPane(component);
      criterionPane.setBorder(null);
      criterionPane.setBackground(Colors.WHITE);
      mainPanel.add(criterionPane, criterion.getName());
    }
    if (criteriaNameList.isEmpty()) {
      remove(mainPanel);
      add(new ResourceLabel("result_view.no_criterions"));
      return;
    }
    String[] criteriaNames = new String[criteriaNameList.size()];
    criteriaNameList.toArray(criteriaNames);

    // selection list
    final JList<String> criteriaList =
        new JList<String>(criteriaNames) {

          private static final long serialVersionUID = 3031125186920370793L;

          @Override
          public Dimension getPreferredSize() {
            Dimension dim = super.getPreferredSize();
            dim.width = Math.max(150, dim.width);
            return dim;
          }
        };
    criteriaList.setCellRenderer(new CriterionListCellRenderer());
    criteriaList.setOpaque(false);

    criteriaList.setBorder(BorderFactory.createTitledBorder("Criterion"));
    criteriaList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);

    criteriaList.addListSelectionListener(
        new ListSelectionListener() {

          @Override
          public void valueChanged(ListSelectionEvent e) {
            String selected = criteriaList.getSelectedValue();
            cardLayout.show(mainPanel, selected);
          }
        });

    JScrollPane listScrollPane = new ExtendedJScrollPane(criteriaList);
    listScrollPane.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 2));
    add(listScrollPane, BorderLayout.WEST);

    // select first criterion
    criteriaList.setSelectedIndices(new int[] {0});
  }