Example usage for java.awt.event MouseEvent getSource

List of usage examples for java.awt.event MouseEvent getSource

Introduction

In this page you can find the example usage for java.awt.event MouseEvent getSource.

Prototype

public Object getSource() 

Source Link

Document

The object on which the Event initially occurred.

Usage

From source file:com.net2plan.gui.tools.GUINetworkDesign.java

@Override
public void configure(JPanel contentPane) {
    this.currentNetPlan = new NetPlan();

    BidiMap<NetworkLayer, Integer> mapLayer2VisualizationOrder = new DualHashBidiMap<>();
    Map<NetworkLayer, Boolean> layerVisibilityMap = new HashMap<>();
    for (NetworkLayer layer : currentNetPlan.getNetworkLayers()) {
        mapLayer2VisualizationOrder.put(layer, mapLayer2VisualizationOrder.size());
        layerVisibilityMap.put(layer, true);
    }/*from  w  w w . j  a v a2 s .  com*/
    this.vs = new VisualizationState(currentNetPlan, mapLayer2VisualizationOrder, layerVisibilityMap,
            MAXSIZEUNDOLISTPICK);

    topologyPanel = new TopologyPanel(this, JUNGCanvas.class);

    JPanel leftPane = new JPanel(new BorderLayout());
    JPanel logSection = configureLeftBottomPanel();
    if (logSection == null) {
        leftPane.add(topologyPanel, BorderLayout.CENTER);
    } else {
        JSplitPane splitPaneTopology = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
        splitPaneTopology.setTopComponent(topologyPanel);
        splitPaneTopology.setBottomComponent(logSection);
        splitPaneTopology.addPropertyChangeListener(new ProportionalResizeJSplitPaneListener());
        splitPaneTopology.setBorder(new LineBorder(contentPane.getBackground()));
        splitPaneTopology.setOneTouchExpandable(true);
        splitPaneTopology.setDividerSize(7);
        leftPane.add(splitPaneTopology, BorderLayout.CENTER);
    }
    contentPane.add(leftPane, "grow");

    viewEditTopTables = new ViewEditTopologyTablesPane(GUINetworkDesign.this, new BorderLayout());

    reportPane = new ViewReportPane(GUINetworkDesign.this, JSplitPane.VERTICAL_SPLIT);

    setCurrentNetPlanDoNotUpdateVisualization(currentNetPlan);
    Pair<BidiMap<NetworkLayer, Integer>, Map<NetworkLayer, Boolean>> res = VisualizationState
            .generateCanvasDefaultVisualizationLayerInfo(getDesign());
    vs.setCanvasLayerVisibilityAndOrder(getDesign(), res.getFirst(), res.getSecond());

    /* Initialize the undo/redo manager, and set its initial design */
    this.undoRedoManager = new UndoRedoManager(this, MAXSIZEUNDOLISTCHANGES);
    this.undoRedoManager.addNetPlanChange();

    onlineSimulationPane = new OnlineSimulationPane(this);
    executionPane = new OfflineExecutionPanel(this);
    whatIfAnalysisPane = new WhatIfAnalysisPane(this);

    // Closing windows
    WindowUtils.clearFloatingWindows();

    final JTabbedPane tabPane = new JTabbedPane();
    tabPane.add(WindowController.WindowToTab.getTabName(WindowController.WindowToTab.network),
            viewEditTopTables);
    tabPane.add(WindowController.WindowToTab.getTabName(WindowController.WindowToTab.offline), executionPane);
    tabPane.add(WindowController.WindowToTab.getTabName(WindowController.WindowToTab.online),
            onlineSimulationPane);
    tabPane.add(WindowController.WindowToTab.getTabName(WindowController.WindowToTab.whatif),
            whatIfAnalysisPane);
    tabPane.add(WindowController.WindowToTab.getTabName(WindowController.WindowToTab.report), reportPane);

    // Installing customized mouse listener
    MouseListener[] ml = tabPane.getListeners(MouseListener.class);

    for (int i = 0; i < ml.length; i++) {
        tabPane.removeMouseListener(ml[i]);
    }

    // Left click works as usual, right click brings up a pop-up menu.
    tabPane.addMouseListener(new MouseAdapter() {
        public void mousePressed(MouseEvent e) {
            JTabbedPane tabPane = (JTabbedPane) e.getSource();

            int tabIndex = tabPane.getUI().tabForCoordinate(tabPane, e.getX(), e.getY());

            if (tabIndex >= 0 && tabPane.isEnabledAt(tabIndex)) {
                if (tabIndex == tabPane.getSelectedIndex()) {
                    if (tabPane.isRequestFocusEnabled()) {
                        tabPane.requestFocus();

                        tabPane.repaint(tabPane.getUI().getTabBounds(tabPane, tabIndex));
                    }
                } else {
                    tabPane.setSelectedIndex(tabIndex);
                }

                if (!tabPane.isEnabled() || SwingUtilities.isRightMouseButton(e)) {
                    final JPopupMenu popupMenu = new JPopupMenu();

                    final JMenuItem popWindow = new JMenuItem("Pop window out");
                    popWindow.addActionListener(e1 -> {
                        final int selectedIndex = tabPane.getSelectedIndex();
                        final String tabName = tabPane.getTitleAt(selectedIndex);
                        final JComponent selectedComponent = (JComponent) tabPane.getSelectedComponent();

                        // Pops up the selected tab.
                        final WindowController.WindowToTab windowToTab = WindowController.WindowToTab
                                .parseString(tabName);

                        if (windowToTab != null) {
                            switch (windowToTab) {
                            case offline:
                                WindowController.buildOfflineWindow(selectedComponent);
                                WindowController.showOfflineWindow(true);
                                break;
                            case online:
                                WindowController.buildOnlineWindow(selectedComponent);
                                WindowController.showOnlineWindow(true);
                                break;
                            case whatif:
                                WindowController.buildWhatifWindow(selectedComponent);
                                WindowController.showWhatifWindow(true);
                                break;
                            case report:
                                WindowController.buildReportWindow(selectedComponent);
                                WindowController.showReportWindow(true);
                                break;
                            default:
                                return;
                            }
                        }

                        tabPane.setSelectedIndex(0);
                    });

                    // Disabling the pop up button for the network state tab.
                    if (WindowController.WindowToTab.parseString(tabPane
                            .getTitleAt(tabPane.getSelectedIndex())) == WindowController.WindowToTab.network) {
                        popWindow.setEnabled(false);
                    }

                    popupMenu.add(popWindow);

                    popupMenu.show(e.getComponent(), e.getX(), e.getY());
                }
            }
        }
    });

    // Building windows
    WindowController.buildTableControlWindow(tabPane);
    WindowController.showTablesWindow(false);

    addAllKeyCombinationActions();
    updateVisualizationAfterNewTopology();
}

From source file:org.openconcerto.erp.core.finance.accounting.element.AnalytiqueSQLElement.java

private void actionModifierAxe(MouseEvent e, final int index) {

    if (index == -1)
        return;/*w  ww  . j  a v  a  2s . com*/

    Component comp = (Component) e.getSource();
    JFrame frame = (JFrame) SwingUtilities.getRoot(comp);

    this.windowChangeNom = new JWindow(frame);
    Container container = this.windowChangeNom.getContentPane();
    container.setLayout(new GridBagLayout());

    final GridBagConstraints c = new DefaultGridBagConstraints();
    c.insets = new Insets(0, 0, 0, 0);
    c.weightx = 1;

    this.editedAxeIndex = index;
    this.text = new JTextField(" " + this.tabAxes.getTitleAt(index) + " ");
    this.text.setEditable(true);
    container.add(this.text, c);
    this.text.setBorder(null);
    // text.setBackground(this.tabAxes.getBackground());
    this.text.addKeyListener(new KeyAdapter() {

        public void keyPressed(KeyEvent event) {

            if (event.getKeyCode() == KeyEvent.VK_ENTER) {
                validAxeText();
            }
        }

    });

    this.windowChangeNom.pack();

    int ecartY = this.tabAxes.getBoundsAt(index).height - this.text.getBounds().height + 2;
    int ecartX = this.tabAxes.getBoundsAt(index).width - this.text.getBounds().width;

    this.windowChangeNom.setLocation(
            comp.getLocationOnScreen().x + this.tabAxes.getBoundsAt(index).getLocation().x + ecartX / 2,
            comp.getLocationOnScreen().y + this.tabAxes.getBoundsAt(index).getLocation().y + ecartY / 2);

    this.windowChangeNom.setVisible(true);
}

From source file:org.openmicroscopy.shoola.env.ui.ActivityComponent.java

/** 
 * Invokes when the activity end. /*from  w  w  w  .j a v a 2s  . c  om*/
 * 
 * @param result The result of the activity.
 */
public void endActivity(Object result) {
    this.result = result;
    boolean busy = status.isBusy();
    reset();
    if (result instanceof Map) {
        Map<String, Object> m = convertResult((Map<String, Object>) result);
        int size = m.size();
        this.result = m;
        remove(resultPane);
        Color c = getBackground();
        if (size == 0) {
            JToolBar row = new JToolBar();
            row.setOpaque(false);
            row.setFloatable(false);
            row.setBorder(null);
            row.setBackground(c);
            JButton button;
            if (errorObject != null) {
                button = createButton(ActivityResultRow.ERROR_TEXT, ERROR, this);
                button.addMouseListener(new MouseAdapter() {

                    public void mouseReleased(MouseEvent e) {
                        showMenu((JComponent) e.getSource(), ERROR, e.getX(), e.getY());
                    }
                });
                row.add(button);
            }
            if (infoObject != null) {
                button = createButton(ActivityResultRow.INFO_TEXT, INFO, this);
                button.addMouseListener(new MouseAdapter() {

                    public void mouseReleased(MouseEvent e) {
                        showMenu((JComponent) e.getSource(), INFO, e.getX(), e.getY());
                    }
                });
                row.add(button);
            }
            add(row, paneIndex);
        } else {
            Entry<String, Object> entry;
            Iterator<Entry<String, Object>> i = m.entrySet().iterator();
            ActivityResultRow row = null;
            JPanel content = new JPanel();
            content.setLayout(new BoxLayout(content, BoxLayout.Y_AXIS));

            content.setBackground(c);
            int index = 0;
            int max = 2;
            JButton moreButton = null;
            while (i.hasNext()) {
                entry = (Entry<String, Object>) i.next();
                this.result = entry.getValue();
                row = new ActivityResultRow((String) entry.getKey(), entry.getValue(), this);
                row.setBackground(c);
                row.addPropertyChangeListener(listener);
                resultButtons.add(row);
                if (index < max)
                    content.add(row);
                else {
                    if (moreButton == null) {
                        moreButton = createButton("" + (m.size() - max) + " more", ALL_RESULT, this);
                        content.add(moreButton);
                    }
                }
                index++;
            }

            if (m.size() == 1)
                add(row, paneIndex);
            else
                add(content, paneIndex);
            resultPane = content;
        }

        repaint();
    }

    firePropertyChange(UNREGISTER_ACTIVITY_PROPERTY, null, this);
    notifyActivityEnd();
    //Post an event to 
    //if (busy) {
    EventBus bus = registry.getEventBus();
    bus.post(new ActivityProcessEvent(this, busy));
    //}
}

From source file:org.openmicroscopy.shoola.agents.util.ui.ScriptingDialog.java

/** Initializes the components. */
private void initComponents() {
    sorter = new ViewerSorter();
    cancelButton = new JButton("Cancel");
    cancelButton.setToolTipText("Close the dialog.");
    cancelButton.setActionCommand("" + CANCEL);
    cancelButton.addActionListener(this);
    applyButton = new JButton("Run Script");
    applyButton.setToolTipText("Run the selected script.");
    applyButton.setActionCommand("" + APPLY);
    applyButton.addActionListener(this);
    IconManager icons = IconManager.getInstance();
    menuButton = new JButton(icons.getIcon(IconManager.FILTER_MENU));
    menuButton.setText("Script");
    menuButton.setHorizontalTextPosition(JButton.LEFT);
    menuButton.addMouseListener(new MouseAdapter() {

        public void mouseReleased(MouseEvent e) {
            Object src = e.getSource();
            if (src instanceof Component) {
                Point p = e.getPoint();
                createOptionMenu().show((Component) src, p.x, p.y);
            }//from   ww  w  .  j a v  a  2  s .  com
        }
    });
    components = new LinkedHashMap<String, ScriptComponent>();
    componentsAll = new LinkedHashMap<String, ScriptComponent>();
    Map<String, ParamData> types = script.getInputs();
    if (types == null)
        return;
    List<ScriptComponent> results = new ArrayList<ScriptComponent>();
    Entry<String, ParamData> entry;
    ParamData param;
    JComponent comp;
    ScriptComponent c;
    String name;
    Class<?> type;
    Object defValue;
    Iterator<Entry<String, ParamData>> i = types.entrySet().iterator();
    List<Object> values;
    Number n;
    String details = "";
    String text = "";
    String grouping;
    String parent;
    Map<String, List<ScriptComponent>> childrenMap = new HashMap<String, List<ScriptComponent>>();
    List<ScriptComponent> l;
    int length;
    boolean columnsSet;
    while (i.hasNext()) {
        text = "";
        columnsSet = false;
        comp = null;
        entry = i.next();
        param = entry.getValue();
        name = entry.getKey();
        type = param.getPrototype();
        values = param.getValues();
        defValue = param.getDefaultValue();
        if (CollectionUtils.isNotEmpty(values)) {
            comp = createValuesBox(values, defValue);
        }
        if (Long.class.equals(type) || Integer.class.equals(type) || Float.class.equals(type)
                || Double.class.equals(type)) {
            if (comp == null) {
                if (script.isIdentifier(name)) {
                    comp = new NumericalTextField();
                    ((NumericalTextField) comp).setNumberType(type);
                    ((NumericalTextField) comp).setNegativeAccepted(false);
                    if (CollectionUtils.isNotEmpty(refObjects)) {
                        //support of image type
                        DataObject object = refObjects.get(0);
                        if (script.isSupportedType(object, name)) {
                            defValue = object.getId();
                        }
                    }
                } else {
                    comp = new NumericalTextField();
                    ((NumericalTextField) comp).setNumberType(type);
                    n = param.getMinValue();
                    if (n != null) {
                        if (Long.class.equals(type)) {
                            text += "Min: " + n.longValue() + " ";
                            ((NumericalTextField) comp).setMinimum(n.longValue());
                        } else if (Integer.class.equals(type)) {
                            text += "Min: " + n.intValue() + " ";
                            ((NumericalTextField) comp).setMinimum(n.intValue());
                        } else if (Double.class.equals(type)) {
                            text += "Min: " + n.doubleValue() + " ";
                            ((NumericalTextField) comp).setMinimum(n.doubleValue());
                        } else if (Float.class.equals(type)) {
                            text += "Min: " + n.floatValue() + " ";
                            ((NumericalTextField) comp).setMinimum(n.floatValue());
                        }
                    } else {
                        ((NumericalTextField) comp).setNegativeAccepted(true);
                    }
                    n = param.getMaxValue();
                    if (n != null) {
                        if (Long.class.equals(type)) {
                            text += "Max: " + n.longValue() + " ";
                            ((NumericalTextField) comp).setMaximum(n.longValue());
                        } else if (Integer.class.equals(type)) {
                            text += "Max: " + n.intValue() + " ";
                            ((NumericalTextField) comp).setMaximum(n.intValue());
                        } else if (Double.class.equals(type)) {
                            text += "Max: " + n.doubleValue() + " ";
                            ((NumericalTextField) comp).setMaximum(n.doubleValue());
                        } else if (Float.class.equals(type)) {
                            text += "Max: " + n.floatValue() + " ";
                            ((NumericalTextField) comp).setMaximum(n.floatValue());
                        }
                    }
                }
                if (defValue != null)
                    ((NumericalTextField) comp).setText("" + defValue);
            }
        } else if (String.class.equals(type)) {
            if (comp == null) {
                comp = new JTextField();
                if (defValue != null) {
                    length = defValue.toString().length();
                    String s = defValue.toString().trim();
                    ((JTextField) comp).setColumns(length);
                    ((JTextField) comp).setText(s);
                    columnsSet = s.length() > 0;
                }
            }
        } else if (Boolean.class.equals(type)) {
            if (comp == null) {
                comp = new JCheckBox();
                if (defValue != null)
                    ((JCheckBox) comp).setSelected((Boolean) defValue);
            }
        } else if (Map.class.equals(type)) {
            if (comp == null)
                comp = new ComplexParamPane(param.getKeyType(), param.getValueType());
            else
                comp = new ComplexParamPane(param.getKeyType(), (JComboBox) comp);
        } else if (List.class.equals(type)) {
            if (script.isIdentifier(name)) {
                identifier = new IdentifierParamPane(Long.class);
                identifier.setValues(refObjects);
                identifier.addDocumentListener(this);
                comp = identifier;
            } else {
                if (comp == null)
                    comp = new ComplexParamPane(param.getKeyType());
                else
                    comp = new ComplexParamPane((JComboBox) comp);
            }
        }
        if (comp != null) {
            if (comp instanceof JTextField) {
                if (!columnsSet)
                    ((JTextField) comp).setColumns(ScriptComponent.COLUMNS);
                ((JTextField) comp).getDocument().addDocumentListener(this);
            }
            if (comp instanceof ComplexParamPane)
                comp.addPropertyChangeListener(this);
            comp.setToolTipText(param.getDescription());
            c = new ScriptComponent(comp, name);
            if (text.trim().length() > 0)
                c.setUnit(text);
            if (!(comp instanceof JComboBox || comp instanceof JCheckBox))
                c.setRequired(!param.isOptional());
            if (details != null && details.trim().length() > 0)
                c.setInfo(details);
            if (comp instanceof JComboBox && script.isDataType(name)) {
                dataTypes = (JComboBox) comp;
                dataTypes.addActionListener(new ActionListener() {

                    public void actionPerformed(ActionEvent e) {
                        handleDataTypeChanges();
                    }
                });
            }
            grouping = param.getGrouping();
            parent = param.getParent();
            c.setParentIndex(parent);
            if (parent.length() > 0) {
                l = childrenMap.get(parent);
                if (l == null) {
                    l = new ArrayList<ScriptComponent>();
                    childrenMap.put(parent, l);
                }
                l.add(c);
            }

            if (grouping.length() > 0) {
                c.setGrouping(grouping);
                c.setNameLabel(grouping);
            } else {
                c.setNameLabel(name);
            }
            if (c.hasChildren() || parent.length() == 0) {
                results.add(c);
            }
            componentsAll.put(c.getParameterName(), c);
        }
    }
    ScriptComponent key;
    Iterator<ScriptComponent> k = results.iterator();
    while (k.hasNext()) {
        key = k.next();
        grouping = key.getGrouping();
        l = childrenMap.get(grouping);
        childrenMap.remove(grouping);
        if (l != null)
            key.setChildren(sorter.sort(l));
    }
    if (childrenMap != null && childrenMap.size() > 0) {
        Iterator<String> j = childrenMap.keySet().iterator();
        ScriptComponent sc;
        while (j.hasNext()) {
            parent = j.next();
            sc = new ScriptComponent();
            sc.setGrouping(parent);
            sc.setNameLabel(parent);
            sc.setChildren(sorter.sort(childrenMap.get(parent)));
            results.add(sc);
        }
    }
    List<ScriptComponent> sortedKeys = sorter.sort(results);
    k = sortedKeys.iterator();

    while (k.hasNext()) {
        key = k.next();
        components.put(key.getParameterName(), key);
    }
    setSelectedDataType();
    if (identifier != null)
        identifier.addPropertyChangeListener(this);
    canRunScript();
}

From source file:pt.lsts.neptus.util.logdownload.LogsDownloaderWorkerUtil.java

/**
 * Creates a {@link MouseListener} to open the selected log folder in MRA.
 * // w w  w  . j a va  2s. c  o  m
 * @param worker
 * @param logFolderList
 * @return
 */
static MouseAdapter createOpenLogInMRAMouseListener(LogsDownloaderWorker worker,
        LogFolderInfoList logFolderList) {
    return new MouseAdapter() {
        @Override
        public void mouseClicked(MouseEvent e) {
            if (e.getButton() == MouseEvent.BUTTON3) {
                // Test if log can be opened in MRA, and open it

                final String baseFxPath = worker.getDirBaseToStoreFiles() + "/" + worker.getLogLabel() + "/"
                        + logFolderList.getSelectedValue() + "/";
                File logFolder = new File(baseFxPath);
                LogValidity isLogOkForOpening = LogUtils.isValidLSFSource(logFolder);

                JPopupMenu popup = new JPopupMenu();
                JMenuItem jm = popup.add(I18n.text("Open this log in MRA"));
                if (isLogOkForOpening == LogValidity.VALID) {
                    File log = LogUtils.getValidLogFileFromLogFolder(logFolder);
                    jm.addActionListener(new ActionListener() {
                        @Override
                        public void actionPerformed(ActionEvent e) {
                            Thread t = new Thread(
                                    LogsDownloaderWorker.class.getSimpleName() + " :: MRA Openner") {
                                public void run() {
                                    JFrame mra = new NeptusMRA();
                                    mra.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);

                                    ((NeptusMRA) mra).getMraFilesHandler().openLog(log);
                                };
                            };
                            t.setDaemon(true);
                            t.start();
                        }
                    });
                } else {
                    jm.setEnabled(false);
                }

                popup.show((Component) e.getSource(), e.getX(), e.getY());
            }
        }
    };
}

From source file:de.tor.tribes.ui.views.DSWorkbenchSelectionFrame.java

private void firePerformRegionSelectionEvent(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_firePerformRegionSelectionEvent
    if (evt.getSource() == jPerformSelection) {
        Point start = new Point((Integer) jStartX.getValue(), (Integer) jStartY.getValue());
        Point end = new Point((Integer) jEndX.getValue(), (Integer) jEndY.getValue());
        Rectangle mapDim = ServerSettings.getSingleton().getMapDimension();

        if (start.x < mapDim.getMinX() || start.x > mapDim.getMaxX() || start.y < mapDim.getMinY()
                || start.y > mapDim.getMaxY() || end.x < mapDim.getMinX() || end.x > mapDim.getMaxX()
                || end.y < mapDim.getMinY() || end.y > mapDim.getMaxY()) {
            showError("Ungltiger Start- oder Endpunkt");
        } else if ((Math.abs(end.x - start.x) * (end.y - start.y)) > 30000) {
            showError("<html>Die angegebene Auswahl k&ouml;nnte mehr als 10.000 D&ouml;rfer umfassen.<br/>"
                    + "Die Auswahl k&ouml;nnte so sehr lange dauern. Bitte verkleinere den gew&auml;hlten Bereich.");
        } else {/*from w  w w  .j av a2  s.  c  om*/
            List<Village> selection = DataHolder.getSingleton().getVillagesInRegion(start, end);
            addVillages(selection);
        }
    }

    jRegionSelectDialog.setVisible(false);
}

From source file:net.sf.firemox.DeckBuilder.java

public void mouseClicked(MouseEvent e) {
    if (e.getSource() == leftList && e.getClickCount() == 2) {
        refreshAddComponent(true);/*from  ww  w . j  av  a  2  s. c om*/
    } else if (e.getSource() == removeButton && rightList.getSelectedRow() != -1) {
        removeCardFromDeck();
    } else if (e.getSource() == cardNameTxt) {
        cardNameTxt.selectAll();
    }
}

From source file:net.sf.jasperreports.swing.JRViewerPanel.java

void hyperlinkClicked(MouseEvent evt) {
    JPanel link = (JPanel) evt.getSource();
    JRPrintHyperlink element = linksMap.get(link);
    hyperlinkClicked(element);
}

From source file:ome.formats.importer.gui.GuiImporter.java

/**
 * Check if the history table is enabled, disabling the history tab 
 * if it is not.//from ww  w .j a  va 2s .com
 */
void checkHistoryEnable() {
    tPane.addMouseListener(new MouseAdapter() {

        public void mouseClicked(MouseEvent e) {

            JTabbedPane pane = (JTabbedPane) e.getSource();

            boolean userDisabled = config.getUserDisableHistory() | config.getStaticDisableHistory();

            if (pane.indexAtLocation(e.getX(), e.getY()) == historyTabIndex
                    && getHistoryTable().db.historyEnabled == false) {
                if (HistoryDB.alertOnce == false && !userDisabled) {
                    JOptionPane.showMessageDialog(null,
                            "For some reason we are not able to connect to the remote\n"
                                    + "history service (this most likely means the server does\n"
                                    + "not have this feature installed). In the meantime, you will\n"
                                    + "still be able to use the importer, however the history tab's\n"
                                    + "functionality will not be enabled.",
                            "Warning", JOptionPane.ERROR_MESSAGE);
                    HistoryDB.alertOnce = true;
                }
            }
        }
    });
}

From source file:org.zaproxy.zap.extension.multiFuzz.impl.http.HttpFuzzerContentPanel.java

public JXTreeTable getFuzzResultTable() {
    if (fuzzResultTable == null) {
        resetFuzzResultTable();/*  w w  w  . j av  a2s.c o m*/
        fuzzResultTable = new JXTreeTable(getResultsModel());
        fuzzResultTable.setName("HttpFuzzResultTable");
        fuzzResultTable.setDoubleBuffered(true);
        fuzzResultTable.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_INTERVAL_SELECTION);
        fuzzResultTable.setFont(new java.awt.Font("Default", java.awt.Font.PLAIN, 12));
        fuzzResultTable.setDefaultRenderer(Pair.class, new IconTableCellRenderer());

        int[] widths = { 10, 25, 550, 30, 85, 55, 40, 70 };
        for (int i = 0, count = widths.length; i < count; i++) {
            TableColumn column = fuzzResultTable.getColumnModel().getColumn(i);
            column.setPreferredWidth(widths[i]);
        }
        fuzzResultTable.addMouseListener(new java.awt.event.MouseAdapter() {
            @Override
            public void mousePressed(java.awt.event.MouseEvent e) {
                showPopupMenuIfTriggered(e);
            }

            @Override
            public void mouseReleased(java.awt.event.MouseEvent e) {
                showPopupMenuIfTriggered(e);
            }

            private void showPopupMenuIfTriggered(java.awt.event.MouseEvent e) {
                if (e.isPopupTrigger() && SwingUtilities.isRightMouseButton(e)) {
                    // Select list item on right click
                    JTable table = (JTable) e.getSource();
                    int row = table.rowAtPoint(e.getPoint());

                    if (!table.isRowSelected(row)) {
                        table.changeSelection(row, 0, false, false);
                    }
                    View.getSingleton().getPopupMenu().show(e.getComponent(), e.getX(), e.getY());
                }
            }

        });

        fuzzResultTable.getSelectionModel()
                .addListSelectionListener(new javax.swing.event.ListSelectionListener() {

                    @Override
                    public void valueChanged(javax.swing.event.ListSelectionEvent e) {
                        if (!e.getValueIsAdjusting()) {
                            if (fuzzResultTable.getSelectedRowCount() == 0) {
                                return;
                            }
                            final int row = fuzzResultTable.getSelectedRow();
                            if (getEntry(row) instanceof HttpFuzzRequestRecord) {
                                final HistoryReference historyReference = ((HttpFuzzRequestRecord) getEntry(
                                        row)).getHistory();
                                try {
                                    displayMessage(historyReference.getHttpMessage());
                                } catch (HttpMalformedHeaderException | SQLException ex) {
                                    logger.error(ex.getMessage(), ex);
                                }
                            }
                        }
                    }
                });
        fuzzResultTable.getTableHeader().addMouseListener(new MouseListener() {
            int sortedOn = -1;

            @Override
            public void mouseReleased(MouseEvent arg0) {
            }

            @Override
            public void mousePressed(MouseEvent arg0) {
            }

            @Override
            public void mouseExited(MouseEvent arg0) {
            }

            @Override
            public void mouseEntered(MouseEvent arg0) {
            }

            @Override
            public void mouseClicked(MouseEvent e) {
                int index = fuzzResultTable.columnAtPoint(e.getPoint());
                List<HttpFuzzRecord> list = getResultsModel().getEntries();
                if (list.size() == 0) {
                    return;
                }
                HttpFuzzRecordComparator comp = new HttpFuzzRecordComparator();
                comp.setFeature(index);
                if (index == sortedOn) {
                    Collections.sort(list, comp);
                    Collections.reverse(list);
                    sortedOn = -1;
                } else {
                    Collections.sort(list, comp);
                    sortedOn = index;
                }
                fuzzResultTable.updateUI();
            }
        });
        fuzzResultTable.setRootVisible(false);
        fuzzResultTable.setVisible(true);
    }
    return fuzzResultTable;
}