Example usage for javax.swing JPopupMenu insert

List of usage examples for javax.swing JPopupMenu insert

Introduction

In this page you can find the example usage for javax.swing JPopupMenu insert.

Prototype

public void insert(Component component, int index) 

Source Link

Document

Inserts the specified component into the menu at a given position.

Usage

From source file:com.mirth.connect.client.ui.components.MirthIconTextField.java

public MirthIconTextField(ImageIcon icon) {
    setIcon(icon);/*from   w  ww  .  j av a2 s .  c o m*/

    addMouseListener(new MouseAdapter() {
        @Override
        public void mouseClicked(MouseEvent evt) {
            if (isIconActive(evt) && iconPopupMenuComponent != null) {
                JPopupMenu iconPopupMenu = new JPopupMenu();
                iconPopupMenu.insert(iconPopupMenuComponent, 0);
                iconPopupMenu.show(evt.getComponent(), evt.getX(), evt.getY());
            }
        }
    });

    addMouseMotionListener(new MouseMotionAdapter() {
        @Override
        public void mouseMoved(MouseEvent evt) {
            int cursorType = getCursor().getType();

            if (isIconActive(evt)) {
                if (StringUtils.isNotBlank(alternateToolTipText)) {
                    MirthIconTextField.super.setToolTipText(alternateToolTipText);
                }

                if (iconPopupMenuComponent != null) {
                    if (cursorType != Cursor.HAND_CURSOR) {
                        setCursor(new Cursor(Cursor.HAND_CURSOR));
                    }
                } else {
                    if (cursorType != Cursor.DEFAULT_CURSOR) {
                        setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
                    }
                }
            } else {
                if (StringUtils.isNotBlank(alternateToolTipText)) {
                    MirthIconTextField.super.setToolTipText(originalToolTipText);
                }

                if (cursorType != Cursor.TEXT_CURSOR) {
                    setCursor(new Cursor(Cursor.TEXT_CURSOR));
                }
            }
        }
    });
}

From source file:net.sourceforge.processdash.ev.ui.chart.EVHiddenOrShownSeriesXYChartPanel.java

private void reloadSeriesMenus() {
    JPopupMenu menu = getPopupMenu();
    while (menu.getComponent(0) instanceof ShowChartLineMenuItem)
        menu.remove(0);/* ww  w.  j  a v  a  2s  .c  o m*/
    XYDataset data = filteredData.getSourceDataset();
    for (int i = data.getSeriesCount(); i-- > 0;)
        menu.insert(new ShowChartLineMenuItem(filteredData, i), 0);
}

From source file:com.eviware.soapui.impl.wsdl.panels.teststeps.WsdlTestRequestDesktopPanel.java

protected SoapMessageXmlEditor buildRequestEditor() {
    SoapMessageXmlEditor editor = super.buildRequestEditor();

    XmlOutlineEditor outlineEditor = editor.getOutlineEditor();
    if (outlineEditor != null) {
        JPopupMenu popupMenu = new JPopupMenu();
        popupMenu.add(new TransferFromPropertyAction(getRequest(), outlineEditor));

        outlineEditor.getOutlineTable().setComponentPopupMenu(popupMenu);

        XmlSourceEditor sourceEditor = editor.getSourceEditor();
        if (sourceEditor != null) {
            JPopupMenu editorPopup = sourceEditor.getEditorPopup();
            editorPopup.insert(new TransferFromPropertyFromSource(getRequest(), sourceEditor, outlineEditor),
                    0);/*from ww w.  j a v  a2  s.  c  o  m*/
        }
    }

    return editor;
}

From source file:com.eviware.soapui.impl.wsdl.panels.teststeps.WsdlTestRequestDesktopPanel.java

protected SoapMessageXmlEditor buildResponseEditor() {
    SoapMessageXmlEditor editor = super.buildResponseEditor();

    XmlOutlineEditor outlineEditor = editor.getOutlineEditor();
    if (outlineEditor != null) {
        JPopupMenu popupMenu = new JPopupMenu();
        popupMenu.add(new AddXPathContentAssertionAction(getRequest(), outlineEditor));
        popupMenu.add(new TransferToPropertyAction(getRequest(), outlineEditor));

        outlineEditor.getOutlineTable().setComponentPopupMenu(popupMenu);

        XmlSourceEditor sourceEditor = editor.getSourceEditor();
        if (sourceEditor != null) {
            JPopupMenu editorPopup = sourceEditor.getEditorPopup();
            editorPopup.insert(
                    new AddXPathContentAssertionFromSource(getRequest(), sourceEditor, outlineEditor), 0);
            editorPopup.insert(new TransferToPropertyFromSource(getRequest(), sourceEditor, outlineEditor), 0);
        }//from w  ww.ja va 2s .co  m
    }

    return editor;
}

From source file:org.jax.bham.test.HaplotypeAssociationTestGraphPanel.java

private void updateClickPosition(int x, int y) {
    this.lastClickedIntervalIndex = this.getMaximalIntervalIndex(x, y);

    // remove the old menu items
    JPopupMenu popupMenu = this.chartPanel.getPopupMenu();
    for (int i = 0; i < this.lastMenuItems.size(); i++) {
        popupMenu.remove(0);//  w w  w. j  a  va2  s  .c om
    }

    // now replace the old menus with some new ones
    this.lastMenuItems = this.createContextMenuItems();
    for (int i = 0; i < this.lastMenuItems.size(); i++) {
        popupMenu.insert(this.lastMenuItems.get(i), i);
    }
}

From source file:dbseer.gui.panel.DBSeerSelectableChartPanel.java

public DBSeerSelectableChartPanel(JFreeChart chart, DBSeerDataSet dataset, String chartName,
        double[] timestamp) {
    super(chart);
    this.setBorder(emptyBorder);
    this.setMouseWheelEnabled(true);
    this.addChartMouseListener(this);
    this.dataset = dataset;
    this.chart = chart;
    this.chartName = chartName;
    this.timestamp = timestamp;
    this.isTransactionSampleChart = false;
    this.maxTransactionSeries = this.dataset.getNumTransactionTypes();
    for (String name : DBSeerGUI.transactionSampleCharts) {
        if (name.equals(this.chartName)) {
            this.isTransactionSampleChart = true;
            break;
        }//from w  ww . j av a2s . c om
    }

    if (this.isTransactionSampleChart) {
        JPopupMenu popupMenu = this.getPopupMenu();
        showQueryAction = new ShowQueryAction();
        showQueryAction.setDataset(this.dataset);
        showQueryAction.setTimestamp(this.timestamp);
        if (this.chartName.equals("CombinedAvgLatency")) {
            showQueryAction.setShowAll(true);
        }
        showQueriesMenuItem = new JMenuItem(showQueryAction);
        showQueriesMenuItem.setEnabled(false);
        popupMenu.insert(showQueriesMenuItem, 0);
    }
}

From source file:org.rdv.viz.chart.ChartViz.java

/**
 * Create the chart and setup it's UI.//from   w  w  w.java 2 s. co  m
 */
private void initChart() {
    XYToolTipGenerator toolTipGenerator;

    if (xyMode) {
        dataCollection = new XYTimeSeriesCollection();

        NumberAxis domainAxis = new NumberAxis();
        domainAxis.setAutoRangeIncludesZero(false);
        domainAxis.addChangeListener(new AxisChangeListener() {
            public void axisChanged(AxisChangeEvent ace) {
                boundsChanged();
            }
        });
        this.domainAxis = domainAxis;

        toolTipGenerator = new StandardXYToolTipGenerator("{0}: {1} , {2}", new DecimalFormat(),
                new DecimalFormat());
    } else {
        dataCollection = new TimeSeriesCollection();

        domainAxis = new FixedAutoAdjustRangeDateAxis();
        domainAxis.setLabel("Time");
        domainAxis.setAutoRange(false);

        toolTipGenerator = new StandardXYToolTipGenerator("{0}: {1} , {2}",
                new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS"), new DecimalFormat());
    }

    rangeAxis = new NumberAxis();
    rangeAxis.setAutoRangeIncludesZero(false);
    rangeAxis.addChangeListener(new AxisChangeListener() {
        public void axisChanged(AxisChangeEvent ace) {
            boundsChanged();
        }
    });

    FastXYItemRenderer renderer = new FastXYItemRenderer(StandardXYItemRenderer.LINES, toolTipGenerator);
    renderer.setBaseCreateEntities(false);
    renderer.setBaseStroke(new BasicStroke(0.5f));
    if (xyMode) {
        renderer.setCursorVisible(true);
    }

    xyPlot = new XYPlot(dataCollection, domainAxis, rangeAxis, renderer);

    chart = new JFreeChart(xyPlot);
    chart.setAntiAlias(false);

    seriesLegend = chart.getLegend();
    chart.removeLegend();

    chartPanel = new ChartPanel(chart, true);
    chartPanel.setInitialDelay(0);

    // get the chart panel standard popup menu
    JPopupMenu popupMenu = chartPanel.getPopupMenu();

    // create a popup menu item to copy an image to the clipboard
    final JMenuItem copyChartMenuItem = new JMenuItem("Copy");
    copyChartMenuItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            copyChart();
        }
    });
    popupMenu.insert(copyChartMenuItem, 2);

    popupMenu.insert(new JPopupMenu.Separator(), 3);

    popupMenu.add(new JPopupMenu.Separator());

    showLegendMenuItem = new JCheckBoxMenuItem("Show Legend", true);
    showLegendMenuItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent ae) {
            setShowLegend(showLegendMenuItem.isSelected());
        }
    });
    popupMenu.add(showLegendMenuItem);

    if (xyMode) {
        popupMenu.add(new JPopupMenu.Separator());

        JMenuItem addLocalSeriesMenuItem = new JMenuItem("Add local series...");
        addLocalSeriesMenuItem.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent ae) {
                addLocalSeries();
            }
        });

        popupMenu.add(addLocalSeriesMenuItem);
    }

    chartPanelPanel = new JPanel();
    chartPanelPanel.setLayout(new BorderLayout());
    chartPanelPanel.add(chartPanel, BorderLayout.CENTER);
}