Beispiel #1
0
  public void setScaleFactor(double scaleFactor) {
    this.scaleFactor = scaleFactor;
    chart.setSize(chart.getPreferredSize());
    memoryRuler.setSize((int) memoryRuler.getPreferredSize().getWidth(), getViewport().getHeight());
    pauseRuler.setSize((int) pauseRuler.getPreferredSize().getWidth(), getViewport().getHeight());
    timestampRuler.setSize(
        (int) (getViewport().getWidth() * getScaleFactor()),
        (int) timestampRuler.getPreferredSize().getHeight());

    horizontalScrollBar.setBlockIncrement((int) (scaleFactor * 5000));

    repaint();
  }
Beispiel #2
0
  private void setUpDisplayPanel() {
    JScrollPane mainScroll;
    JPanel mainPanel = new JPanel(new BorderLayout());
    displayPanel = new JPanel(new BorderLayout());
    hostsHolder = new JPanel();

    hostsHolder.setLayout(new BoxLayout(hostsHolder, BoxLayout.Y_AXIS));
    mainPanel.add(hostsHolder, BorderLayout.NORTH);
    displayPanel.add(mainScroll = new JScrollPane(mainPanel));

    JScrollBar bar = mainScroll.getVerticalScrollBar();
    mainScroll.setBorder(null);
    bar.setBlockIncrement(40);
    bar.setUnitIncrement(40);
  }
  private JScrollBar createScrollBar(int row) {
    JScrollBar scrollBar = new JScrollBar();
    scrollBar.setMinimum(0);
    scrollBar.setVisibleAmount(1);
    scrollBar.setBlockIncrement(1);
    scrollBar.setOrientation(JScrollBar.HORIZONTAL);

    GridBagConstraints scrollBarContraints = new GridBagConstraints();
    scrollBarContraints.fill = GridBagConstraints.HORIZONTAL;
    scrollBarContraints.weightx = 1.0;
    scrollBarContraints.gridx = 1;
    scrollBarContraints.gridy = row;
    super.add(scrollBar, scrollBarContraints);

    return scrollBar;
  }
Beispiel #4
0
  public ModelChartImpl() {
    super();
    this.model = new GCModel(true);
    this.chart = new Chart();
    this.chart.setPreferredSize(new Dimension(0, 0));
    setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_NEVER);

    // set scrolling speed
    horizontalScrollBar = getHorizontalScrollBar();
    horizontalScrollBar.setUnitIncrement(50);
    horizontalScrollBar.setBlockIncrement(500);

    // order of the renderers determines what is painted first and last
    // we start with what's painted last
    GridBagConstraints gridBagConstraints = new GridBagConstraints();
    gridBagConstraints.fill = GridBagConstraints.BOTH;
    gridBagConstraints.weightx = 2;
    gridBagConstraints.weighty = 2;
    gridBagConstraints.gridx = 1;
    gridBagConstraints.gridy = 1;

    initialMarkLevelRenderer = new InitialMarkLevelRenderer(this);
    chart.add(initialMarkLevelRenderer, gridBagConstraints);
    usedHeapRenderer = new UsedHeapRenderer(this);
    chart.add(usedHeapRenderer, gridBagConstraints);
    gcTimesRenderer = new GCTimesRenderer(this);
    chart.add(gcTimesRenderer, gridBagConstraints);
    fullGCLineRenderer = new FullGCLineRenderer(this);
    chart.add(fullGCLineRenderer, gridBagConstraints);
    gcRectanglesRenderer = new GCRectanglesRenderer(this);
    chart.add(gcRectanglesRenderer, gridBagConstraints);
    incLineRenderer = new IncLineRenderer(this);
    chart.add(incLineRenderer, gridBagConstraints);
    concurrentGcLineRenderer = new ConcurrentGcBegionEndRenderer(this);
    chart.add(concurrentGcLineRenderer, gridBagConstraints);
    totalTenuredRenderer = new TotalTenuredRenderer(this);
    chart.add(totalTenuredRenderer, gridBagConstraints);
    totalYoungRenderer = new TotalYoungRenderer(this);
    chart.add(totalYoungRenderer, gridBagConstraints);
    totalHeapRenderer = new TotalHeapRenderer(this);
    chart.add(totalHeapRenderer, gridBagConstraints);

    setViewportView(chart);
    // This would make scrolling slower, but eliminates flickering...
    // getViewport().setScrollMode(JViewport.BACKINGSTORE_SCROLL_MODE);

    JPanel rowHeaderPanel = new JPanel();
    GridBagLayout layout = new GridBagLayout();
    rowHeaderPanel.setLayout(layout);
    GridBagConstraints constraints = new GridBagConstraints();
    constraints.fill = GridBagConstraints.VERTICAL;
    constraints.weightx = 2;
    constraints.weighty = 1;
    constraints.gridheight = 2;
    constraints.gridx = 0;
    constraints.gridy = 1;
    this.memoryRuler = new Ruler(true, 0, model.getFootprint(), "K");
    this.pauseRuler = new Ruler(true, 0, model.getPause().getMax(), "s");
    layout.setConstraints(memoryRuler, constraints);
    rowHeaderPanel.add(memoryRuler);
    constraints.gridx = 1;
    layout.setConstraints(pauseRuler, constraints);
    rowHeaderPanel.add(pauseRuler);
    setRowHeaderView(rowHeaderPanel);
    setCorner(JScrollPane.UPPER_LEFT_CORNER, new JPanel());
    setCorner(JScrollPane.LOWER_LEFT_CORNER, new JPanel());

    DateFormat dateFormatter = new TimeFormat();
    this.timestampRuler = new Ruler(false, 0, model.getRunningTime(), "", dateFormatter);
    setColumnHeaderView(timestampRuler);

    getViewport()
        .addComponentListener(
            new ComponentListener() {
              public void componentResized(ComponentEvent e) {
                chart.setSize(chart.getPreferredSize());
                memoryRuler.setSize(
                    (int) memoryRuler.getPreferredSize().getWidth(), e.getComponent().getHeight());
                pauseRuler.setSize(
                    (int) pauseRuler.getPreferredSize().getWidth(), e.getComponent().getHeight());
                timestampRuler.setSize(
                    (int) chart.getPreferredSize().getWidth(),
                    (int) timestampRuler.getPreferredSize().getHeight());
              }

              public void componentMoved(ComponentEvent e) {}

              public void componentShown(ComponentEvent e) {}

              public void componentHidden(ComponentEvent e) {}
            });
    // timestamp menu
    final JPopupMenu popupMenu = new JPopupMenu();
    timeOffsetPanel = new TimeOffsetPanel(popupMenu);
    popupMenu.add(timeOffsetPanel);
    final JPopupMenu timestampRulerPopup = popupMenu;
    Action setOffsetAction =
        new AbstractAction() {
          public void actionPerformed(ActionEvent e) {
            if (timeOffsetPanel.isOffsetSet())
              timestampRuler.setOffset(timeOffsetPanel.getDate().getTime() / 1000);
            else timestampRuler.setOffset(0);
            timestampRuler.revalidate();
            timestampRuler.repaint();
          }
        };
    timeOffsetPanel.setOkAction(setOffsetAction);
    this.timestampRuler.addMouseListener(
        new MouseAdapter() {
          public void mousePressed(MouseEvent e) {
            maybePopup(e);
          }

          public void mouseReleased(MouseEvent e) {
            maybePopup(e);
          }

          public void maybePopup(MouseEvent e) {
            if (e.isPopupTrigger()) {
              if (timestampRuler.getOffset() != 0) {
                timeOffsetPanel.setDate(new Date((long) timestampRuler.getOffset() * 1000));
                timeOffsetPanel.setOffsetSet(true);
              } else {
                long suggestedStartDate = model.getLastModified();
                if (model.hasDateStamp()) {
                  suggestedStartDate = (long) (model.getFirstDateStamp().getTime());
                } else if (model.hasCorrectTimestamp()) {
                  suggestedStartDate -= (long) (model.getRunningTime() * 1000.0d);
                }
                timeOffsetPanel.setDate(new Date(suggestedStartDate));
                timeOffsetPanel.setOffsetSet(false);
              }
              timestampRulerPopup.show(e.getComponent(), e.getX(), e.getY());
              timeOffsetPanel.requestFocus();
            }
          }
        });
  }
Beispiel #5
0
  HtmlPanel(final Map<String, Action> actions, HtmlPage page) throws IOException {
    super(new BorderLayout());

    this.actions = actions;
    textPane = new JTextPane();
    find = new JTextField();
    matches = new JLabel();
    this.page = null;

    final Dimension d = matches.getPreferredSize();
    matches.setPreferredSize(new Dimension(100, d.height));

    textPane.setEditable(false);
    textPane.setFocusable(false);
    textPane.addHyperlinkListener(
        new HyperlinkListener() {

          public final void hyperlinkUpdate(HyperlinkEvent ev) {
            if (ev.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
              final JEditorPane pane = (JEditorPane) ev.getSource();
              if (ev instanceof HTMLFrameHyperlinkEvent) {
                final HTMLFrameHyperlinkEvent evt = (HTMLFrameHyperlinkEvent) ev;
                final HTMLDocument doc = (HTMLDocument) pane.getDocument();
                doc.processHTMLFrameHyperlinkEvent(evt);
              } else if (Desktop.isDesktopSupported())
                try {
                  Desktop.getDesktop().browse(ev.getURL().toURI());
                } catch (final Exception e) {
                  e.printStackTrace();
                }
            }
          }
        });

    final HTMLEditorKit kit =
        new HTMLEditorKit() {
          private static final long serialVersionUID = 1L;

          @Override
          public final Document createDefaultDocument() {
            final HTMLDocument doc = (HTMLDocument) super.createDefaultDocument();
            // Load synchronously.
            doc.setAsynchronousLoadPriority(-1);
            return doc;
          }
        };

    final StyleSheet styleSheet = kit.getStyleSheet();
    final InputStream is = getClass().getResourceAsStream("/doogal.css");
    try {
      styleSheet.loadRules(newBufferedReader(is), null);
    } finally {
      is.close();
    }

    textPane.setEditorKit(kit);

    final Document doc = kit.createDefaultDocument();
    textPane.setDocument(doc);
    textPane.addMouseListener(
        new MouseAdapter() {

          private final void showPopup(MouseEvent e) {
            if (e.isPopupTrigger()) {
              final JPopupMenu menu = newPopupMenu(TableType.DOCUMENT, actions);
              if (null != menu) menu.show(e.getComponent(), e.getX(), e.getY());
            }
          }

          @Override
          public final void mousePressed(MouseEvent e) {
            showPopup(e);
          }

          @Override
          public final void mouseReleased(MouseEvent e) {
            showPopup(e);
          }
        });
    find.setColumns(16);
    find.setFont(new Font("Dialog", Font.PLAIN, TINY_FONT));
    find.setMargin(new Insets(2, 2, 2, 2));
    find.addActionListener(
        new ActionListener() {
          public final void actionPerformed(ActionEvent ev) {
            find(find.getText());
          }
        });

    final JLabel label = new JLabel("Quick Find: ");
    label.setLabelFor(find);

    final JButton clear = new JButton("Clear");
    clear.setMargin(new Insets(1, 5, 0, 5));
    clear.setFont(new Font("Dialog", Font.PLAIN, TINY_FONT));
    clear.addActionListener(
        new ActionListener() {
          public final void actionPerformed(ActionEvent e) {
            find.setText("");
            find("");
          }
        });

    final JPanel findPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT));
    findPanel.add(label);
    findPanel.add(find);
    findPanel.add(clear);
    findPanel.add(matches);

    scrollPane =
        new JScrollPane(
            textPane,
            ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED,
            ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
    scrollPane.setFocusable(false);
    final JScrollBar scrollBar = scrollPane.getVerticalScrollBar();
    scrollBar.setBlockIncrement(scrollBar.getBlockIncrement() * 20);
    scrollBar.setUnitIncrement(scrollBar.getUnitIncrement() * 20);

    add(scrollPane, BorderLayout.CENTER);
    add(findPanel, BorderLayout.SOUTH);

    setPage(page);
  }
  public CopiesPanel(final Project project) {
    myProject = project;
    myConnection = myProject.getMessageBus().connect(myProject);
    myVcs = SvnVcs.getInstance(myProject);
    myCurrentInfoList = null;

    final Runnable focus =
        new Runnable() {
          @Override
          public void run() {
            IdeFocusManager.getInstance(myProject).requestFocus(myRefreshLabel, true);
          }
        };
    final Runnable refreshView =
        new Runnable() {
          @Override
          public void run() {
            final List<WCInfo> infoList = myVcs.getWcInfosWithErrors();
            final boolean hasErrors = !myVcs.getSvnFileUrlMapping().getErrorRoots().isEmpty();
            final List<WorkingCopyFormat> supportedFormats = getSupportedFormats();
            Runnable runnable =
                new Runnable() {
                  @Override
                  public void run() {
                    if (myCurrentInfoList != null) {
                      final List<OverrideEqualsWrapper<WCInfo>> newList =
                          ObjectsConvertor.convert(
                              infoList,
                              new Convertor<WCInfo, OverrideEqualsWrapper<WCInfo>>() {
                                @Override
                                public OverrideEqualsWrapper<WCInfo> convert(WCInfo o) {
                                  return new OverrideEqualsWrapper<WCInfo>(
                                      InfoEqualityPolicy.getInstance(), o);
                                }
                              },
                              ObjectsConvertor.NOT_NULL);

                      if (Comparing.haveEqualElements(newList, myCurrentInfoList)) {
                        myRefreshLabel.setEnabled(true);
                        return;
                      }
                      myCurrentInfoList = newList;
                    }
                    Collections.sort(infoList, WCComparator.getInstance());
                    updateList(infoList, supportedFormats);
                    myRefreshLabel.setEnabled(true);
                    showErrorNotification(hasErrors);
                    SwingUtilities.invokeLater(focus);
                  }
                };
            ApplicationManager.getApplication().invokeLater(runnable, ModalityState.NON_MODAL);
          }
        };
    final Consumer<Boolean> refreshOnPooled =
        new Consumer<Boolean>() {
          @Override
          public void consume(Boolean somethingNew) {
            if (Boolean.TRUE.equals(somethingNew)) {
              if (ApplicationManager.getApplication().isUnitTestMode()) {
                refreshView.run();
              } else {
                ApplicationManager.getApplication().executeOnPooledThread(refreshView);
              }
            } else {
              ApplicationManager.getApplication()
                  .invokeLater(
                      new Runnable() {
                        @Override
                        public void run() {
                          myRefreshLabel.setEnabled(true);
                        }
                      },
                      ModalityState.NON_MODAL);
            }
          }
        };
    myConnection.subscribe(SvnVcs.ROOTS_RELOADED, refreshOnPooled);

    final JPanel holderPanel = new JPanel(new BorderLayout());
    FontMetrics fm = holderPanel.getFontMetrics(holderPanel.getFont());
    myTextHeight = (int) (fm.getHeight() * 1.3);
    myPanel = new JPanel(new GridBagLayout());
    final JPanel panel = new JPanel(new BorderLayout());
    panel.add(myPanel, BorderLayout.NORTH);
    holderPanel.add(panel, BorderLayout.WEST);
    myRefreshLabel =
        new MyLinkLabel(
            myTextHeight,
            "Refresh",
            new LinkListener() {
              @Override
              public void linkSelected(LinkLabel aSource, Object aLinkData) {
                if (myRefreshLabel.isEnabled()) {
                  myVcs.invokeRefreshSvnRoots();
                  myRefreshLabel.setEnabled(false);
                }
              }
            });
    final JScrollPane pane = ScrollPaneFactory.createScrollPane(holderPanel);
    myHolder = pane;
    final JScrollBar vBar = pane.getVerticalScrollBar();
    vBar.setBlockIncrement(vBar.getBlockIncrement() * 5);
    vBar.setUnitIncrement(vBar.getUnitIncrement() * 5);
    myHolder.setBorder(null);
    setFocusableForLinks(myRefreshLabel);
    refreshOnPooled.consume(true);
    initView();
  }