Example usage for java.awt.event MouseAdapter MouseAdapter

List of usage examples for java.awt.event MouseAdapter MouseAdapter

Introduction

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

Prototype

MouseAdapter

Source Link

Usage

From source file:gtu._work.ui.ObnfInsertCreaterUI.java

private void initGUI() {
    try {//from ww  w .  j  a  v a  2 s  . c o m
        JCommonUtil.defaultToolTipDelay();
        BorderLayout thisLayout = new BorderLayout();
        setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
        getContentPane().setLayout(thisLayout);
        {
            jTabbedPane1 = new JTabbedPane();
            getContentPane().add(jTabbedPane1, BorderLayout.CENTER);
            {
                jPanel1 = new JPanel();
                jTabbedPane1.addTab("?schema", null, jPanel1, null);
                {
                    jLabel1 = new JLabel();
                    jPanel1.add(jLabel1);
                    jLabel1.setText("tableName");
                }
                {
                    tableNameText = new JTextField();
                    jPanel1.add(tableNameText);
                    tableNameText.setPreferredSize(new java.awt.Dimension(155, 22));
                }
                {
                    useDomainJarDefineChkBox = new JCheckBox();
                    jPanel1.add(useDomainJarDefineChkBox);
                    useDomainJarDefineChkBox.setText("\u4ee5dominJar\u70ba\u6e96");
                }
                {
                    dominJarFileText = new JTextField();
                    File currentFile = new File(PropertiesUtil.getJarCurrentPath(getClass()),
                            "sris-db-domain-2.5.0-SRIS-SNAPSHOT.jar");
                    if (currentFile.exists()) {
                        dominJarFileText.setText(currentFile.getAbsolutePath());
                    } else {
                        File cUserFile = new File("C:\\Users");
                        if (cUserFile.exists()) {
                            String domainJarPath = "C:/Users/%s/.m2/repository/tw/gov/sris-db-domain/2.5.0-SRIS-SNAPSHOT/sris-db-domain-2.5.0-SRIS-SNAPSHOT.jar";
                            for (File f : cUserFile.listFiles()) {
                                File jf = new File(String.format(domainJarPath, f.getName()));
                                if (jf.exists()) {
                                    dominJarFileText.setText(jf.getAbsolutePath());
                                    break;
                                }
                            }
                        }
                    }
                    jPanel1.add(dominJarFileText);
                    dominJarFileText.setPreferredSize(new java.awt.Dimension(219, 22));
                    JCommonUtil.jTextFieldSetFilePathMouseEvent(dominJarFileText, false);
                }
                {
                    jLabel5 = new JLabel();
                    jPanel1.add(jLabel5);
                    jLabel5.setText("obnfString");
                    jLabel5.setPreferredSize(new java.awt.Dimension(83, 15));
                }
                {
                    jScrollPane2 = new JScrollPane();
                    jPanel1.add(jScrollPane2);
                    jScrollPane2.setPreferredSize(new java.awt.Dimension(544, 76));
                    {
                        obnfArea = new JTextArea();
                        jScrollPane2.setViewportView(obnfArea);
                    }
                }
                {
                    jLabel6 = new JLabel();
                    jPanel1.add(jLabel6);
                    jLabel6.setText("sql");
                    jLabel6.setPreferredSize(new java.awt.Dimension(58, 15));
                }
                {
                    jScrollPane3 = new JScrollPane();
                    jPanel1.add(jScrollPane3);
                    jScrollPane3.setPreferredSize(new java.awt.Dimension(543, 116));
                    {
                        insertSqlArea = new JTextArea();
                        jScrollPane3.setViewportView(insertSqlArea);
                    }
                }
                {
                    executeBtn = new JButton();
                    jPanel1.add(executeBtn);
                    executeBtn.setText("\u8b80\u53d6ObnfString");
                    executeBtn.setPreferredSize(new java.awt.Dimension(146, 29));
                    executeBtn.addActionListener(new ActionListener() {
                        public void actionPerformed(ActionEvent evt) {
                            executeBtnAction();
                        }
                    });
                }
                {
                    processSqlBtn = new JButton();
                    jPanel1.add(processSqlBtn);
                    processSqlBtn.setText("\u7522\u751fSQL");
                    processSqlBtn.setPreferredSize(new java.awt.Dimension(135, 29));
                    processSqlBtn.addActionListener(new ActionListener() {
                        public void actionPerformed(ActionEvent evt) {
                            processSqlBtnAction();
                        }
                    });
                }
            }
            {
                jPanel2 = new JPanel();
                BorderLayout jPanel2Layout = new BorderLayout();
                jPanel2.setLayout(jPanel2Layout);
                jTabbedPane1.addTab("?", null, jPanel2, null);
                {
                    jPanel3 = new JPanel();
                    jPanel2.add(jPanel3, BorderLayout.NORTH);
                    jPanel3.setPreferredSize(new java.awt.Dimension(585, 61));
                    {
                        jLabel4 = new JLabel();
                        jPanel3.add(jLabel4);
                        jLabel4.setText("dbField");
                    }
                    {
                        dbFieldText = new JTextField();
                        jPanel3.add(dbFieldText);
                        dbFieldText.setPreferredSize(new java.awt.Dimension(216, 22));
                    }
                    {
                        jLabel3 = new JLabel();
                        jPanel3.add(jLabel3);
                        jLabel3.setText("value");
                    }
                    {
                        dbValue = new JTextField();
                        jPanel3.add(dbValue);
                        dbValue.setPreferredSize(new java.awt.Dimension(244, 22));
                    }
                    {
                        pkCheckBox = new JCheckBox();
                        jPanel3.add(pkCheckBox);
                        pkCheckBox.setText("\u662fPK");
                    }
                    {
                        addFieldBtn = new JButton();
                        jPanel3.add(addFieldBtn);
                        addFieldBtn.setText("saveOrUpdate");
                        addFieldBtn.setPreferredSize(new java.awt.Dimension(116, 22));
                        addFieldBtn.addActionListener(new ActionListener() {
                            public void actionPerformed(ActionEvent evt) {
                                addFieldBtnAction();
                            }
                        });
                    }
                    {
                        deleteFieldBtn = new JButton();
                        jPanel3.add(deleteFieldBtn);
                        deleteFieldBtn.setText("delete");
                        deleteFieldBtn.setPreferredSize(new java.awt.Dimension(88, 22));
                        deleteFieldBtn.addActionListener(new ActionListener() {
                            public void actionPerformed(ActionEvent evt) {
                                deleteFieldBtnAction();
                            }
                        });
                    }
                }
                {
                    jScrollPane1 = new JScrollPane();
                    jPanel2.add(jScrollPane1, BorderLayout.CENTER);
                    jScrollPane1.setPreferredSize(new java.awt.Dimension(585, 258));
                    {
                        DefaultListModel dbFieldListModel = new DefaultListModel();
                        dbFieldList = new JList();
                        jScrollPane1.setViewportView(dbFieldList);
                        dbFieldList.addMouseListener(new MouseAdapter() {
                            public void mouseClicked(MouseEvent evt) {
                                dbFieldListMousePreformd(evt);
                            }
                        });
                        dbFieldList.setModel(dbFieldListModel);
                        dbFieldList.addKeyListener(new KeyAdapter() {
                            public void keyPressed(KeyEvent evt) {
                                JListUtil.newInstance(dbFieldList).defaultJListKeyPressed(evt);
                            }
                        });
                    }
                }
            }
            {
                jPanel4 = new JPanel();
                GridLayout jPanel4Layout = new GridLayout(1, 1);
                jPanel4Layout.setColumns(1);
                jPanel4Layout.setHgap(5);
                jPanel4Layout.setVgap(5);
                jPanel4.setLayout(jPanel4Layout);
                jTabbedPane1.addTab("?", null, jPanel4, null);
                {
                    manualDefineArea = new JTextArea();
                    jPanel4.add(manualDefineArea);
                    manualDefineArea.setText("");
                    manualDefineArea.setToolTipText("?");
                }
                {
                    manualDefinePkArea = new JTextArea();
                    jPanel4.add(manualDefinePkArea);
                    manualDefinePkArea.setText("");
                    manualDefinePkArea.setToolTipText("PK?");
                }
                {
                    manualDefineDbFieldBtn = new JButton();
                    jPanel4.add(manualDefineDbFieldBtn);
                    manualDefineDbFieldBtn
                            .setText("\u4ee5\u8cbc\u5165\u6b04\u4f4d\u5b9a\u7fa9\u6c7a\u5b9a\u6b04\u4f4d");
                    manualDefineDbFieldBtn.addActionListener(new ActionListener() {
                        public void actionPerformed(ActionEvent evt) {
                            manualDefineDbFieldBtnAction();
                        }
                    });
                }
            }
        }
        pack();
        this.setSize(598, 366);
    } catch (Exception e) {
        //add your error handling code here
        e.printStackTrace();
    }
}

From source file:com.tascape.qa.th.android.driver.App.java

/**
 * The method starts a GUI to let an user inspect element tree and take screenshot when the user is interacting
 * with the app-under-test manually. Please make sure to set timeout long enough for manual interaction.
 *
 * @param timeoutMinutes timeout in minutes to fail the manual steps
 *
 * @throws Exception if case of error/*w w  w .ja v  a  2  s.  com*/
 */
public void interactManually(int timeoutMinutes) throws Exception {
    LOG.info("Start manual UI interaction");
    long end = System.currentTimeMillis() + timeoutMinutes * 60000L;

    AtomicBoolean visible = new AtomicBoolean(true);
    AtomicBoolean pass = new AtomicBoolean(false);
    String tName = Thread.currentThread().getName() + "m";
    SwingUtilities.invokeLater(() -> {
        JDialog jd = new JDialog((JFrame) null, "Manual Device UI Interaction - " + device.getProductDetail());
        jd.setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE);

        JPanel jpContent = new JPanel(new BorderLayout());
        jd.setContentPane(jpContent);
        jpContent.setPreferredSize(new Dimension(1088, 828));
        jpContent.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));

        JPanel jpInfo = new JPanel();
        jpContent.add(jpInfo, BorderLayout.PAGE_START);
        jpInfo.setLayout(new BorderLayout());
        {
            JButton jb = new JButton("PASS");
            jb.setForeground(Color.green.darker());
            jb.setFont(jb.getFont().deriveFont(Font.BOLD));
            jpInfo.add(jb, BorderLayout.LINE_START);
            jb.addActionListener(event -> {
                pass.set(true);
                jd.dispose();
                visible.set(false);
            });
        }
        {
            JButton jb = new JButton("FAIL");
            jb.setForeground(Color.red);
            jb.setFont(jb.getFont().deriveFont(Font.BOLD));
            jpInfo.add(jb, BorderLayout.LINE_END);
            jb.addActionListener(event -> {
                pass.set(false);
                jd.dispose();
                visible.set(false);
            });
        }

        JLabel jlTimeout = new JLabel("xxx seconds left", SwingConstants.CENTER);
        jpInfo.add(jlTimeout, BorderLayout.CENTER);
        jpInfo.add(jlTimeout, BorderLayout.CENTER);
        new SwingWorker<Long, Long>() {
            @Override
            protected Long doInBackground() throws Exception {
                while (System.currentTimeMillis() < end) {
                    Thread.sleep(1000);
                    long left = (end - System.currentTimeMillis()) / 1000;
                    this.publish(left);
                }
                return 0L;
            }

            @Override
            protected void process(List<Long> chunks) {
                Long l = chunks.get(chunks.size() - 1);
                jlTimeout.setText(l + " seconds left");
                if (l < 850) {
                    jlTimeout.setForeground(Color.red);
                }
            }
        }.execute();

        JPanel jpResponse = new JPanel(new BorderLayout());
        JPanel jpProgress = new JPanel(new BorderLayout());
        jpResponse.add(jpProgress, BorderLayout.PAGE_START);

        JTextArea jtaJson = new JTextArea();
        jtaJson.setEditable(false);
        jtaJson.setTabSize(4);
        Font font = jtaJson.getFont();
        jtaJson.setFont(new Font("Courier New", font.getStyle(), font.getSize()));

        JTree jtView = new JTree();

        JTabbedPane jtp = new JTabbedPane();
        jtp.add("tree", new JScrollPane(jtView));
        jtp.add("json", new JScrollPane(jtaJson));

        jpResponse.add(jtp, BorderLayout.CENTER);

        JPanel jpScreen = new JPanel();
        jpScreen.setMinimumSize(new Dimension(200, 200));
        jpScreen.setLayout(new BoxLayout(jpScreen, BoxLayout.PAGE_AXIS));
        JScrollPane jsp1 = new JScrollPane(jpScreen);
        jpResponse.add(jsp1, BorderLayout.LINE_START);

        JPanel jpJs = new JPanel(new BorderLayout());
        JTextArea jtaJs = new JTextArea();
        jpJs.add(new JScrollPane(jtaJs), BorderLayout.CENTER);

        JSplitPane jSplitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, jpResponse, jpJs);
        jSplitPane.setResizeWeight(0.88);
        jpContent.add(jSplitPane, BorderLayout.CENTER);

        JPanel jpLog = new JPanel();
        jpLog.setBorder(BorderFactory.createEmptyBorder(5, 0, 0, 0));
        jpLog.setLayout(new BoxLayout(jpLog, BoxLayout.LINE_AXIS));

        JCheckBox jcbTap = new JCheckBox("Enable Click", null, false);
        jpLog.add(jcbTap);
        jpLog.add(Box.createHorizontalStrut(8));

        JButton jbLogUi = new JButton("Log Screen");
        jpResponse.add(jpLog, BorderLayout.PAGE_END);
        {
            jpLog.add(jbLogUi);
            jbLogUi.addActionListener((ActionEvent event) -> {
                jtaJson.setText("waiting for screenshot...");
                Thread t = new Thread(tName) {
                    @Override
                    public void run() {
                        LOG.debug("\n\n");
                        try {
                            WindowHierarchy wh = device.loadWindowHierarchy();
                            jtView.setModel(getModel(wh));

                            jtaJson.setText("");
                            jtaJson.append(wh.root.toJson().toString(2));
                            jtaJson.append("\n");

                            File png = device.takeDeviceScreenshot();
                            BufferedImage image = ImageIO.read(png);

                            int w = device.getDisplayWidth();
                            int h = device.getDisplayHeight();

                            BufferedImage resizedImg = new BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB);
                            Graphics2D g2 = resizedImg.createGraphics();
                            g2.setRenderingHint(RenderingHints.KEY_INTERPOLATION,
                                    RenderingHints.VALUE_INTERPOLATION_BILINEAR);
                            g2.drawImage(image, 0, 0, w, h, null);
                            g2.dispose();

                            JLabel jLabel = new JLabel(new ImageIcon(resizedImg));
                            jpScreen.removeAll();
                            jsp1.setPreferredSize(new Dimension(w + 30, h));
                            jpScreen.add(jLabel);

                            jLabel.addMouseListener(new MouseAdapter() {
                                @Override
                                public void mouseClicked(MouseEvent e) {
                                    LOG.debug("clicked at {},{}", e.getPoint().getX(), e.getPoint().getY());
                                    if (jcbTap.isSelected()) {
                                        device.click(e.getPoint().x, e.getPoint().y);
                                        device.waitForIdle();
                                        jbLogUi.doClick();
                                    }
                                }
                            });
                        } catch (Exception ex) {
                            LOG.error("Cannot log screen", ex);
                            jtaJson.append("Cannot log screen");
                        }
                        jtaJson.append("\n\n\n");
                        LOG.debug("\n\n");

                        jd.setSize(jd.getBounds().width + 1, jd.getBounds().height + 1);
                        jd.setSize(jd.getBounds().width - 1, jd.getBounds().height - 1);
                    }
                };
                t.start();
            });
        }
        jpLog.add(Box.createHorizontalStrut(38));
        {
            JButton jbLogMsg = new JButton("Log Message");
            jpLog.add(jbLogMsg);
            JTextField jtMsg = new JTextField(10);
            jpLog.add(jtMsg);
            jtMsg.addFocusListener(new FocusListener() {
                @Override
                public void focusLost(final FocusEvent pE) {
                }

                @Override
                public void focusGained(final FocusEvent pE) {
                    jtMsg.selectAll();
                }
            });
            jtMsg.addKeyListener(new KeyAdapter() {
                @Override
                public void keyPressed(java.awt.event.KeyEvent e) {
                    if (e.getKeyCode() == java.awt.event.KeyEvent.VK_ENTER) {
                        jbLogMsg.doClick();
                    }
                }
            });
            jbLogMsg.addActionListener(event -> {
                Thread t = new Thread(tName) {
                    @Override
                    public void run() {
                        String msg = jtMsg.getText();
                        if (StringUtils.isNotBlank(msg)) {
                            LOG.info("{}", msg);
                            jtMsg.selectAll();
                        }
                    }
                };
                t.start();
                try {
                    t.join();
                } catch (InterruptedException ex) {
                    LOG.error("Cannot take screenshot", ex);
                }
                jtMsg.requestFocus();
            });
        }
        jpLog.add(Box.createHorizontalStrut(38));
        {
            JButton jbClear = new JButton("Clear");
            jpLog.add(jbClear);
            jbClear.addActionListener(event -> {
                jtaJson.setText("");
            });
        }

        JPanel jpAction = new JPanel();
        jpContent.add(jpAction, BorderLayout.PAGE_END);
        jpAction.setLayout(new BoxLayout(jpAction, BoxLayout.LINE_AXIS));
        jpJs.add(jpAction, BorderLayout.PAGE_END);

        jd.pack();
        jd.setVisible(true);
        jd.setLocationRelativeTo(null);

        jbLogUi.doClick();
    });

    while (visible.get()) {
        if (System.currentTimeMillis() > end) {
            LOG.error("Manual UI interaction timeout");
            break;
        }
        Thread.sleep(500);
    }

    if (pass.get()) {
        LOG.info("Manual UI Interaction returns PASS");
    } else {
        Assert.fail("Manual UI Interaction returns FAIL");
    }
}

From source file:cl.almejo.vsim.gui.SimWindow.java

public SimWindow(Circuit circuit) {
    _circuit = circuit;//from  w ww.  j a  v  a2  s.  com
    _circuit.addCircuitEventListener(this);
    _canvas = new CircuitCanvas(_circuit);

    setBounds(100, 100, 800, 800);

    _displaysPane = new JTabbedPane();

    CanvasScrollPane scrollPane = new CanvasScrollPane(_canvas);
    CenterCanvasButton panel = new CenterCanvasButton();
    panel.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseClicked(MouseEvent e) {
            SimWindow.this.getCanvas().center();
        }
    });
    scrollPane.addCorner(panel);

    JSplitPane rightSplitpane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, scrollPane, _displaysPane);
    rightSplitpane.setOneTouchExpandable(true);
    rightSplitpane.setDividerLocation(600);

    JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT,
            new JSplitPane(JSplitPane.VERTICAL_SPLIT, getToolsPane(), new JPanel()), rightSplitpane);

    getContentPane().add(splitPane, BorderLayout.CENTER);

    JPanel statusBar = getStatusBar();
    statusBar.add(new ZoomChanger(_canvas));
    getContentPane().add(statusBar, BorderLayout.SOUTH);

    setVisible(true);

    setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
    addComponentListener(this);
    addWindowListener(this);
    _canvas.addMouseListener(this);
    _canvas.setZoom(1.0);
    _canvas.addMouseMotionListener(this);
    _canvas.resizeViewport();

    addMenu();
    addMainToolbar();
    updateActionStates();
    updateTitle();
}

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

private void buildMenu() {
    JXTaskPane editPane = new JXTaskPane();
    editPane.setTitle("Bearbeiten");
    JXButton filter3k = new JXButton(new ImageIcon(DSWorkbenchTagFrame.class.getResource("/res/ui/3k.png")));
    filter3k.setToolTipText("Whlt alle Drfer mit weniger als 3000 Punkten");
    filter3k.addMouseListener(new MouseAdapter() {

        @Override/*w  w  w  . jav a  2  s .  c o  m*/
        public void mouseReleased(MouseEvent e) {
            filterByPoints(3000);
        }
    });

    editPane.getContentPane().add(filter3k);

    JXButton filter5k = new JXButton(new ImageIcon(DSWorkbenchTagFrame.class.getResource("/res/ui/5k.png")));

    filter5k.setToolTipText("Whlt alle Drfer mit weniger als 5000 Punkten");
    filter5k.addMouseListener(new MouseAdapter() {

        @Override
        public void mouseReleased(MouseEvent e) {
            filterByPoints(5000);
        }
    });

    editPane.getContentPane().add(filter5k);
    JXButton filter7k = new JXButton(new ImageIcon(DSWorkbenchTagFrame.class.getResource("/res/ui/7k.png")));

    filter7k.setToolTipText("Whlt alle Drfer mit weniger als 7000 Punkten");
    filter7k.addMouseListener(new MouseAdapter() {

        @Override
        public void mouseReleased(MouseEvent e) {
            filterByPoints(7000);
        }
    });

    editPane.getContentPane().add(filter7k);

    JXButton filter9k = new JXButton(new ImageIcon(DSWorkbenchTagFrame.class.getResource("/res/ui/9k.png")));

    filter9k.setToolTipText("Whlt alle Drfer mit weniger als 9000 Punkten");
    filter9k.addMouseListener(new MouseAdapter() {

        @Override
        public void mouseReleased(MouseEvent e) {
            filterByPoints(9000);
        }
    });

    editPane.getContentPane().add(filter9k);

    jApplyCustomFilter.addMouseListener(new MouseAdapter() {

        @Override
        public void mouseReleased(MouseEvent e) {
            try {
                filterByPoints(UIHelper.parseIntFromField(jCustomPointsField, 1500));
            } catch (NumberFormatException nfe) {
                jCustomPointsField.setText(null);
            }
        }
    });

    editPane.getContentPane().add(jCustomPointsPanel);

    JXTaskPane transferPane = new JXTaskPane();
    transferPane.setTitle("bertragen");
    JXButton toHtml = new JXButton(
            new ImageIcon(DSWorkbenchTagFrame.class.getResource("/res/ui/att_HTML.png")));

    toHtml.setToolTipText("Gewhlte Drfer als HTML Datei exportieren");
    toHtml.addMouseListener(new MouseAdapter() {

        @Override
        public void mouseReleased(MouseEvent e) {
            exportAsHTML();
        }
    });
    transferPane.getContentPane().add(toHtml);

    JXTaskPane miscPane = new JXTaskPane();
    miscPane.setTitle("Sonstiges");
    JXButton structure = new JXButton(
            new ImageIcon(DSWorkbenchTagFrame.class.getResource("/res/ui/branch.png")));

    structure.setToolTipText("Wechsel zwischen Baumstruktur und Liste");
    structure.addMouseListener(new MouseAdapter() {

        @Override
        public void mouseReleased(MouseEvent e) {
            switchViewType();
        }
    });
    miscPane.getContentPane().add(structure);
    JXButton region = new JXButton(
            new ImageIcon(DSWorkbenchTagFrame.class.getResource("/res/ui/region_select.png")));

    region.setToolTipText("Auswahl aller Drfer innerhalb bestimmter Koordinaten");
    region.addMouseListener(new MouseAdapter() {

        @Override
        public void mouseReleased(MouseEvent e) {
            showRegionSelection();
        }
    });
    miscPane.getContentPane().add(region);

    JXButton substract = new JXButton(
            new ImageIcon(DSWorkbenchTagFrame.class.getResource("/res/ui/branch_remove.png")));

    substract.setToolTipText(
            "Abziehen aller Drfer aus der Zwischenablage von der Liste der ausgewhlten Drfer");
    substract.addMouseListener(new MouseAdapter() {

        @Override
        public void mouseReleased(MouseEvent e) {
            substractVillagesFromClipboard();
        }
    });
    miscPane.getContentPane().add(substract);

    centerPanel.setupTaskPane(editPane, transferPane, miscPane);
}

From source file:com.mac.tarchan.desktop.event.EventQuery.java

/**
 * ?????//from  w  w w.ja v  a2s .c  om
 * 
 * @param mouseClicked ?
 * @return ??
 * @see MouseListener#mouseClicked(java.awt.event.MouseEvent)
 */
public EventQuery dblclick(final MouseListener mouseClicked) {
    log.debug("dblclick=" + list);
    for (Component child : list) {
        child.addMouseListener(new MouseAdapter() {
            @Override
            public void mouseClicked(MouseEvent e) {
                if (e.getClickCount() == 2)
                    mouseClicked.mouseClicked(e);
            }
        });
    }
    return this;
}

From source file:com.sshtools.sshterm.SshTermSessionPanel.java

/**
 *
 *
 * @param application//from   www  .  j a v  a  2s . c o  m
 *
 * @throws SshToolsApplicationException
 */
public void init(SshToolsApplication application) throws SshToolsApplicationException {
    super.init(application);

    //  Additional connection tabs
    additionalTabs = new SshToolsConnectionTab[] { new SshTermTerminalTab() };

    //  Printing page format
    try {
        if (System.getSecurityManager() != null) {
            AccessController.checkPermission(new RuntimePermission("queuePrintJob"));
        }

        try {
            PrinterJob job = PrinterJob.getPrinterJob();

            if (job == null) {
                throw new IOException("Could not get print page format.");
            }

            pageFormat = job.defaultPage();

            if (PreferencesStore.preferenceExists(PREF_PAGE_FORMAT_ORIENTATION)) {
                pageFormat.setOrientation(
                        PreferencesStore.getInt(PREF_PAGE_FORMAT_ORIENTATION, PageFormat.LANDSCAPE));

                Paper paper = new Paper();
                paper.setImageableArea(PreferencesStore.getDouble(PREF_PAGE_FORMAT_IMAGEABLE_X, 0),
                        PreferencesStore.getDouble(PREF_PAGE_FORMAT_IMAGEABLE_Y, 0),
                        PreferencesStore.getDouble(PREF_PAGE_FORMAT_IMAGEABLE_W, 0),
                        PreferencesStore.getDouble(PREF_PAGE_FORMAT_IMAGEABLE_H, 0));
                paper.setSize(PreferencesStore.getDouble(PREF_PAGE_FORMAT_SIZE_W, 0),
                        PreferencesStore.getDouble(PREF_PAGE_FORMAT_SIZE_H, 0));
                pageFormat.setPaper(paper);
            }
        } catch (Exception e) {
            showExceptionMessage("Error", e.getMessage());
        }
    } catch (AccessControlException ace) {
        ace.printStackTrace();
    }

    enableEvents(VDU_EVENTS);

    // Set up the actions
    initActions();

    // Create the status bar
    statusBar = new StatusBar();

    dataListener = new DataNotificationListener(statusBar);

    // Create our terminal emulation object
    try {
        emulation = createEmulation();
    } catch (IOException ioe) {
        throw new SshToolsApplicationException(ioe);
    }

    emulation.addTerminalListener(this);

    // Set a scrollbar for the terminal - doesn't seem to be as simple as this
    scrollBar = new JScrollBar(JScrollBar.VERTICAL);
    emulation.setBufferSize(1000);

    // Create our swing terminal and add it to the main frame
    terminal = new TerminalPanel(emulation) {

        public void processEvent(AWTEvent evt) {
            /** We can't add a MouseWheelListener because it was not available in 1.3, so direct processing of events is necessary */
            if (evt instanceof MouseEvent && evt.getID() == 507) {
                try {
                    Method m = evt.getClass().getMethod("getWheelRotation", new Class[] {});
                    SshTermSessionPanel.this.scrollBar.setValue(SshTermSessionPanel.this.scrollBar.getValue()
                            + (SshTermSessionPanel.this.scrollBar.getUnitIncrement()
                                    * ((Integer) m.invoke(evt, new Object[] {})).intValue()
                                    * PreferencesStore.getInt(PREF_MOUSE_WHEEL_INCREMENT, 1)));

                } catch (Throwable t) {
                }
            } else {
                super.processEvent(evt);
            }
        }

        public void copyNotify() {
            copyAction.actionPerformed(null);
        }

    };
    terminal.requestFocus();
    terminal.setScrollbar(scrollBar);
    terminal.addMouseMotionListener(this);

    //terminal.addMouseWheelListener(this);
    // Center panel with terminal and scrollbar
    JPanel center = new JPanel(new BorderLayout());
    center.setBackground(Color.red);
    center.add(terminal, BorderLayout.CENTER);
    center.add(scrollBar, BorderLayout.EAST);

    // Show the context menu on mouse button 3 (right click)
    terminal.addMouseListener(new MouseAdapter() {
        public void mouseClicked(MouseEvent evt) {
            if ((evt.getModifiers() & MouseEvent.BUTTON3_MASK) > 0) {
                getContextMenu().setLabel(getApplication().getApplicationName());
                getContextMenu().show(terminal, evt.getX(), evt.getY());
            } else if ((evt.getModifiers() & MouseEvent.BUTTON2_MASK) > 0) {
                pasteAction.actionPerformed(null);
            }
        }
    });

    //
    //        JPanel top = new JPanel(new BorderLayout());
    //        top.add(getJMenuBar(), BorderLayout.NORTH);
    //        top.add(north, BorderLayout.SOUTH);
    setLayout(new BorderLayout());
    add(center, BorderLayout.CENTER);

    //        add(top, BorderLayout.NORTH);
    // Make sure that the swing terminal has focus
    terminal.requestFocus();
}

From source file:com.raddle.tools.MergeMain.java

private void initGUI() {
    try {//from  w  w w.  ja va  2s .  c om
        {
            this.setBounds(0, 0, 1050, 600);
            getContentPane().setLayout(null);
            this.setTitle("\u5c5e\u6027\u6587\u4ef6\u6bd4\u8f83");
            {
                sourceTxt = new JTextField();
                getContentPane().add(sourceTxt);
                sourceTxt.setBounds(12, 12, 373, 22);
            }
            {
                sourceBtn = new JButton();
                getContentPane().add(sourceBtn);
                sourceBtn.setText("\u6253\u5f00");
                sourceBtn.setBounds(406, 12, 74, 22);
                sourceBtn.addActionListener(new ActionListener() {

                    @Override
                    public void actionPerformed(ActionEvent evt) {
                        JFileChooser fileChooser = new JFileChooser(); // 
                        fileChooser.addChoosableFileFilter(
                                new FileNameExtensionFilter("", "properties"));
                        File curFile = new File(sourceTxt.getText());
                        if (curFile.exists()) {
                            fileChooser.setCurrentDirectory(curFile.getParentFile());
                        }
                        int result = fileChooser.showOpenDialog(MergeMain.this);
                        if (result == JFileChooser.APPROVE_OPTION) {
                            File selected = fileChooser.getSelectedFile();
                            source = new PropertyHolder(selected, "utf-8");
                            sourceTxt.setText(selected.getAbsolutePath());
                            properties.setProperty("left.file", selected.getAbsolutePath());
                            savePropMergeFile();
                            compare();
                        }
                    }
                });
            }
            {
                targetTxt = new JTextField();
                getContentPane().add(targetTxt);
                targetTxt.setBounds(496, 12, 419, 22);
            }
            {
                targetBtn = new JButton();
                getContentPane().add(targetBtn);
                targetBtn.setText("\u6253\u5f00");
                targetBtn.setBounds(935, 12, 81, 22);
                targetBtn.setSize(74, 22);
                targetBtn.addActionListener(new ActionListener() {

                    @Override
                    public void actionPerformed(ActionEvent evt) {
                        JFileChooser fileChooser = new JFileChooser(); // 
                        fileChooser.addChoosableFileFilter(
                                new FileNameExtensionFilter("", "properties"));
                        File curFile = new File(targetTxt.getText());
                        if (curFile.exists()) {
                            fileChooser.setCurrentDirectory(curFile.getParentFile());
                        }
                        int result = fileChooser.showOpenDialog(MergeMain.this);
                        if (result == JFileChooser.APPROVE_OPTION) {
                            File selected = fileChooser.getSelectedFile();
                            target = new PropertyHolder(selected, "utf-8");
                            targetTxt.setText(selected.getAbsolutePath());
                            properties.setProperty("right.file", selected.getAbsolutePath());
                            savePropMergeFile();
                            compare();
                        }
                    }
                });
            }
            {
                jScrollPane1 = new JScrollPane();
                getContentPane().add(jScrollPane1);
                jScrollPane1.setBounds(12, 127, 373, 413);
                {
                    ListModel sourceListModel = new DefaultComboBoxModel(new String[] {});
                    sourceList = new JList();
                    jScrollPane1.setViewportView(sourceList);
                    sourceList.setAutoscrolls(true);
                    sourceList.setModel(sourceListModel);
                    sourceList.addKeyListener(new KeyAdapter() {
                        @Override
                        public void keyPressed(KeyEvent evt) {
                            if (evt.getKeyCode() == KeyEvent.VK_DELETE) {
                                PropertyLine v = (PropertyLine) sourceList.getSelectedValue();
                                if (v != null) {
                                    int ret = JOptionPane.showConfirmDialog(MergeMain.this,
                                            "?" + v.getKey() + "?");
                                    if (ret == JOptionPane.YES_OPTION) {
                                        v.setState(LineState.deleted);
                                        compare();
                                        sourceList.setSelectedValue(v, true);
                                    }
                                }
                            }
                        }
                    });
                    sourceList.addMouseListener(new MouseAdapter() {
                        @Override
                        public void mouseClicked(MouseEvent evt) {
                            if (evt.getClickCount() == 2) {
                                Object v = sourceList.getSelectedValue();
                                updatePropertyLine((PropertyLine) v);
                                sourceList.setSelectedValue(v, true);
                            }
                        }
                    });
                    sourceList.addListSelectionListener(new ListSelectionListener() {

                        @Override
                        public void valueChanged(ListSelectionEvent evt) {
                            if (sourceList.getSelectedValue() != null) {
                                PropertyLine pl = (PropertyLine) sourceList.getSelectedValue();
                                if (target != null) {
                                    PropertyLine p = target.getLine(pl.getKey());
                                    if (p != null) {
                                        TextDiffResult rt = TextdiffUtil.getDifferResult(p.toString(),
                                                pl.toString());
                                        diffResultPane.setText("" + rt.getTargetHtml() + "<br/>?"
                                                + rt.getSrcHtml());
                                        selectLine(targetList, p);
                                        return;
                                    }
                                }
                                TextDiffResult rt = TextdiffUtil.getDifferResult("", pl.toString());
                                diffResultPane.setText(
                                        "" + rt.getTargetHtml() + "<br/>?" + rt.getSrcHtml());

                            }
                        }
                    });
                }
            }
            {
                jScrollPane2 = new JScrollPane();
                getContentPane().add(jScrollPane2);
                jScrollPane2.setBounds(496, 127, 419, 413);
                {
                    ListModel targetListModel = new DefaultComboBoxModel(new String[] {});
                    targetList = new JList();
                    jScrollPane2.setViewportView(targetList);
                    targetList.setAutoscrolls(true);
                    targetList.setModel(targetListModel);
                    targetList.addKeyListener(new KeyAdapter() {
                        @Override
                        public void keyPressed(KeyEvent evt) {
                            if (evt.getKeyCode() == KeyEvent.VK_DELETE) {
                                PropertyLine v = (PropertyLine) targetList.getSelectedValue();
                                if (v != null) {
                                    int ret = JOptionPane.showConfirmDialog(MergeMain.this,
                                            "?" + v.getKey() + "?");
                                    if (ret == JOptionPane.YES_OPTION) {
                                        v.setState(LineState.deleted);
                                        compare();
                                        targetList.setSelectedValue(v, true);
                                    }
                                }
                            }
                        }
                    });
                    targetList.addMouseListener(new MouseAdapter() {
                        @Override
                        public void mouseClicked(MouseEvent evt) {
                            if (evt.getClickCount() == 2) {
                                Object v = targetList.getSelectedValue();
                                updatePropertyLine((PropertyLine) v);
                                targetList.setSelectedValue(v, true);
                            }
                        }
                    });
                    targetList.addListSelectionListener(new ListSelectionListener() {

                        @Override
                        public void valueChanged(ListSelectionEvent evt) {
                            if (targetList.getSelectedValue() != null) {
                                PropertyLine pl = (PropertyLine) targetList.getSelectedValue();
                                if (source != null) {
                                    PropertyLine s = source.getLine(pl.getKey());
                                    if (s != null) {
                                        TextDiffResult rt = TextdiffUtil.getDifferResult(pl.toString(),
                                                s.toString());
                                        diffResultPane.setText("" + rt.getTargetHtml() + "<br/>?"
                                                + rt.getSrcHtml());
                                        selectLine(sourceList, s);
                                        return;
                                    }
                                }
                                TextDiffResult rt = TextdiffUtil.getDifferResult(pl.toString(), "");
                                diffResultPane.setText(
                                        "" + rt.getTargetHtml() + "<br/>?" + rt.getSrcHtml());
                            }
                        }
                    });
                }
            }
            {
                sourceSaveBtn = new JButton();
                getContentPane().add(sourceSaveBtn);
                sourceSaveBtn.setText("\u4fdd\u5b58");
                sourceSaveBtn.setBounds(406, 45, 74, 22);
                sourceSaveBtn.addActionListener(new ActionListener() {

                    @Override
                    public void actionPerformed(ActionEvent evt) {
                        int result = JOptionPane.showConfirmDialog(MergeMain.this,
                                "???\n"
                                        + source.getPropertyFile().getAbsolutePath());
                        if (result == JOptionPane.YES_OPTION) {
                            source.saveFile();
                            JOptionPane.showMessageDialog(MergeMain.this, "??");
                            clearState(source);
                            compare();
                        }
                    }
                });
            }
            {
                targetSaveBtn = new JButton();
                getContentPane().add(targetSaveBtn);
                targetSaveBtn.setText("\u4fdd\u5b58");
                targetSaveBtn.setBounds(935, 45, 81, 22);
                targetSaveBtn.setSize(74, 22);
                targetSaveBtn.addActionListener(new ActionListener() {

                    @Override
                    public void actionPerformed(ActionEvent evt) {
                        int result = JOptionPane.showConfirmDialog(MergeMain.this,
                                "????\n"
                                        + target.getPropertyFile().getAbsolutePath());
                        if (result == JOptionPane.YES_OPTION) {
                            target.saveFile();
                            JOptionPane.showMessageDialog(MergeMain.this, "??");
                            clearState(target);
                            compare();
                        }
                    }
                });
            }
            {
                toTargetBtn = new JButton();
                getContentPane().add(toTargetBtn);
                toTargetBtn.setText("->");
                toTargetBtn.setBounds(406, 221, 74, 22);
                toTargetBtn.addActionListener(new ActionListener() {

                    @Override
                    public void actionPerformed(ActionEvent evt) {
                        Object[] oo = sourceList.getSelectedValues();
                        for (Object selected : oo) {
                            PropertyLine s = (PropertyLine) selected;
                            if (s != null && target != null) {
                                PropertyLine t = target.getLine(s.getKey());
                                if (t == null) {
                                    PropertyLine n = s.clone();
                                    n.setState(LineState.added);
                                    target.addPropertyLineAtSuitedPosition(n);
                                } else if (!t.getValue().equals(s.getValue())) {
                                    t.setState(LineState.updated);
                                    t.setValue(s.getValue());
                                } else if (t.getState() == LineState.deleted) {
                                    if (t.getValue().equals(t.getOriginalValue())) {
                                        t.setState(LineState.original);
                                    } else {
                                        t.setState(LineState.updated);
                                    }
                                }
                                compare();
                            }
                        }
                    }
                });
            }
            {
                toSourceBtn = new JButton();
                getContentPane().add(toSourceBtn);
                toSourceBtn.setText("<-");
                toSourceBtn.setBounds(406, 255, 74, 22);
                toSourceBtn.addActionListener(new ActionListener() {

                    @Override
                    public void actionPerformed(ActionEvent evt) {
                        Object[] oo = targetList.getSelectedValues();
                        for (Object selected : oo) {
                            PropertyLine t = (PropertyLine) selected;
                            if (t != null && source != null) {
                                PropertyLine s = source.getLine(t.getKey());
                                if (s == null) {
                                    PropertyLine n = t.clone();
                                    n.setState(LineState.added);
                                    source.addPropertyLineAtSuitedPosition(n);
                                } else if (!s.getValue().equals(t.getValue())) {
                                    s.setState(LineState.updated);
                                    s.setValue(t.getValue());
                                } else if (s.getState() == LineState.deleted) {
                                    if (s.getValue().equals(s.getOriginalValue())) {
                                        s.setState(LineState.original);
                                    } else {
                                        s.setState(LineState.updated);
                                    }
                                }
                                compare();
                            }
                        }
                    }
                });
            }
            {
                jScrollPane3 = new JScrollPane();
                getContentPane().add(jScrollPane3);
                jScrollPane3.setBounds(12, 73, 903, 42);
                {
                    diffResultPane = new JTextPane();
                    jScrollPane3.setViewportView(diffResultPane);
                    diffResultPane.setBounds(12, 439, 903, 63);
                    diffResultPane.setContentType("text/html");
                    diffResultPane.setPreferredSize(new java.awt.Dimension(901, 42));
                }
            }
            {
                compareBtn = new JButton();
                getContentPane().add(compareBtn);
                compareBtn.setText("\u6bd4\u8f83");
                compareBtn.setBounds(406, 139, 74, 22);
                compareBtn.addActionListener(new ActionListener() {

                    @Override
                    public void actionPerformed(ActionEvent evt) {
                        compare();
                    }
                });
            }
            {
                sourceReloadBtn = new JButton();
                getContentPane().add(sourceReloadBtn);
                sourceReloadBtn.setText("\u91cd\u65b0\u8f7d\u5165");
                sourceReloadBtn.setBounds(12, 40, 64, 29);
                sourceReloadBtn.setSize(90, 22);
                sourceReloadBtn.addActionListener(new ActionListener() {
                    @Override
                    public void actionPerformed(ActionEvent evt) {
                        if (sourceTxt.getText().length() > 0) {
                            File curFile = new File(sourceTxt.getText().trim());
                            if (curFile.exists()) {
                                source = new PropertyHolder(curFile, "utf-8");
                                sourceTxt.setText(curFile.getAbsolutePath());
                                properties.setProperty("left.file", curFile.getAbsolutePath());
                                savePropMergeFile();
                                compare();
                            } else {
                                JOptionPane.showMessageDialog(MergeMain.this,
                                        "" + curFile.getAbsolutePath() + "?");
                            }
                        }
                    }
                });
            }
            {
                targetReloadBtn = new JButton();
                getContentPane().add(targetReloadBtn);
                targetReloadBtn.setText("\u91cd\u65b0\u8f7d\u5165");
                targetReloadBtn.setBounds(839, 45, 90, 22);
                targetReloadBtn.addActionListener(new ActionListener() {
                    @Override
                    public void actionPerformed(ActionEvent evt) {
                        if (targetTxt.getText().length() > 0) {
                            File curFile = new File(targetTxt.getText().trim());
                            if (curFile.exists()) {
                                target = new PropertyHolder(curFile, "utf-8");
                                targetTxt.setText(curFile.getAbsolutePath());
                                properties.setProperty("right.file", curFile.getAbsolutePath());
                                savePropMergeFile();
                                compare();
                            } else {
                                JOptionPane.showMessageDialog(MergeMain.this,
                                        "" + curFile.getAbsolutePath() + "?");
                            }
                        }
                    }
                });
            }
            {
                helpBtn = new JButton();
                getContentPane().add(helpBtn);
                helpBtn.setText("\u5e2e\u52a9");
                helpBtn.setBounds(405, 338, 38, 29);
                helpBtn.setSize(74, 22);
                helpBtn.addActionListener(new ActionListener() {
                    @Override
                    public void actionPerformed(ActionEvent evt) {
                        StringBuilder sb = new StringBuilder();
                        sb.append("?").append("\n");
                        sb.append("del").append("\n");
                        sb.append("??").append("\n");
                        sb.append(": /.prop-merge/prop-merge.properties").append("\n");
                        JOptionPane.showMessageDialog(MergeMain.this, sb.toString());
                    }
                });
            }
            {
                sourceEditBtn = new JButton();
                getContentPane().add(sourceEditBtn);
                sourceEditBtn.setText("\u7f16\u8f91\u6587\u4ef6");
                sourceEditBtn.setBounds(108, 40, 90, 22);
                sourceEditBtn.addActionListener(new ActionListener() {
                    @Override
                    public void actionPerformed(ActionEvent evt) {
                        if (sourceTxt.getText().length() > 0) {
                            File curFile = new File(sourceTxt.getText());
                            editFile(curFile);
                        }
                    }
                });
            }
            {
                targetEditBtn = new JButton();
                getContentPane().add(targetEditBtn);
                targetEditBtn.setText("\u7f16\u8f91\u6587\u4ef6");
                targetEditBtn.setBounds(743, 45, 90, 22);
                targetEditBtn.addActionListener(new ActionListener() {
                    @Override
                    public void actionPerformed(ActionEvent evt) {
                        if (targetTxt.getText().length() > 0) {
                            File curFile = new File(targetTxt.getText());
                            editFile(curFile);
                        }
                    }
                });
            }
        }
        pack();
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:edu.ku.brc.specify.tasks.RecordSetTask.java

/**
 * Adds the Context PopupMenu for the RecordSet.
 * @param roc the RolloverCommand btn to add the pop to
 *///from w ww. j  a va  2 s. co  m
public void addPopMenu(final RolloverCommand roc, final boolean isOKDelete, final boolean isOKModify) {
    if (roc.getLabelText() != null) {
        final JPopupMenu popupMenu = new JPopupMenu();

        if (isOKModify) {
            JMenuItem renameMenuItem = new JMenuItem(UIRegistry.getResourceString("Rename"));
            renameMenuItem.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent actionEvent) {
                    roc.startEditting(RecordSetTask.this);
                }
            });
            popupMenu.add(renameMenuItem);
        }

        if (isOKDelete) {
            JMenuItem delMenuItem = new JMenuItem(UIRegistry.getResourceString("Delete"));
            delMenuItem.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent actionEvent) {
                    CommandDispatcher.dispatch(new CommandAction(RECORD_SET, DELETE_CMD_ACT, roc));
                }
            });
            popupMenu.add(delMenuItem);
        }

        JMenuItem viewMenuItem = new JMenuItem(UIRegistry.getResourceString("View"));
        viewMenuItem.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent actionEvent) {
                CommandAction cmdAction = new CommandAction("Express_Search", "ViewRecordSet", roc);
                cmdAction.setProperty("canModify", isOKDelete);
                CommandDispatcher.dispatch(cmdAction);
            }
        });
        popupMenu.add(viewMenuItem);

        MouseListener mouseListener = new MouseAdapter() {
            private boolean showIfPopupTrigger(MouseEvent mouseEvent) {
                if (roc.isEnabled() && mouseEvent.isPopupTrigger() && popupMenu.getComponentCount() > 0) {
                    popupMenu.show(mouseEvent.getComponent(), mouseEvent.getX(), mouseEvent.getY());
                    return true;
                }
                return false;
            }

            @Override
            public void mousePressed(MouseEvent mouseEvent) {
                if (roc.isEnabled()) {
                    showIfPopupTrigger(mouseEvent);
                }
            }

            @Override
            public void mouseReleased(MouseEvent mouseEvent) {
                if (roc.isEnabled()) {
                    showIfPopupTrigger(mouseEvent);
                }
            }
        };
        roc.addMouseListener(mouseListener);
    }
}

From source file:com.mirth.connect.client.ui.editors.filter.FilterPane.java

/**
 * This method is called from within the constructor to initialize the form.
 *//*  w  w  w. j  av  a2  s. co m*/
public void initComponents() {

    // the available panels (cards)
    rulePanel = new BasePanel();
    blankPanel = new BasePanel();

    scriptTextArea = new MirthRTextScrollPane(null, true, SyntaxConstants.SYNTAX_STYLE_JAVASCRIPT, false);
    scriptTextArea.setBackground(new Color(204, 204, 204));
    scriptTextArea.setBorder(BorderFactory.createEtchedBorder());
    scriptTextArea.getTextArea().setEditable(false);
    scriptTextArea.getTextArea().setDropTarget(null);

    generatedScriptPanel = new JPanel();
    generatedScriptPanel.setBackground(Color.white);
    generatedScriptPanel.setLayout(new CardLayout());
    generatedScriptPanel.add(scriptTextArea, "");

    tabbedPane = new JTabbedPane();
    tabbedPane.addTab("Rule", rulePanel);

    tabbedPane.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseClicked(MouseEvent e) {
            switchTab = (lastSelectedIndex == 0 && tabbedPane.getSelectedIndex() == 1) ? true : false;
            updateCodePanel(null);
        }
    });

    for (FilterRulePlugin filterRulePlugin : LoadedExtensions.getInstance().getFilterRulePlugins().values()) {
        filterRulePlugin.initialize(this);
    }

    // establish the cards to use in the Transformer
    rulePanel.addCard(blankPanel, BLANK_TYPE);
    for (FilterRulePlugin plugin : LoadedExtensions.getInstance().getFilterRulePlugins().values()) {
        rulePanel.addCard(plugin.getPanel(), plugin.getPluginPointName());
    }

    filterTablePane = new JScrollPane();

    viewTasks = new JXTaskPane();
    viewTasks.setTitle("Mirth Views");
    viewTasks.setFocusable(false);

    filterPopupMenu = new JPopupMenu();

    viewTasks.add(initActionCallback("accept", "Return back to channel.",
            ActionFactory.createBoundAction("accept", "Back to Channel", "B"),
            new ImageIcon(Frame.class.getResource("images/resultset_previous.png"))));
    parent.setNonFocusable(viewTasks);
    viewTasks.setVisible(false);
    parent.taskPaneContainer.add(viewTasks, parent.taskPaneContainer.getComponentCount() - 1);

    filterTasks = new JXTaskPane();
    filterTasks.setTitle("Filter Tasks");
    filterTasks.setFocusable(false);

    // add new rule task
    filterTasks.add(initActionCallback("addNewRule", "Add a new filter rule.",
            ActionFactory.createBoundAction("addNewRule", "Add New Rule", "N"),
            new ImageIcon(Frame.class.getResource("images/add.png"))));
    JMenuItem addNewRule = new JMenuItem("Add New Rule");
    addNewRule.setIcon(new ImageIcon(Frame.class.getResource("images/add.png")));
    addNewRule.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            addNewRule();
        }
    });
    filterPopupMenu.add(addNewRule);

    // delete rule task
    filterTasks.add(initActionCallback("deleteRule", "Delete the currently selected filter rule.",
            ActionFactory.createBoundAction("deleteRule", "Delete Rule", "X"),
            new ImageIcon(Frame.class.getResource("images/delete.png"))));
    JMenuItem deleteRule = new JMenuItem("Delete Rule");
    deleteRule.setIcon(new ImageIcon(Frame.class.getResource("images/delete.png")));
    deleteRule.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            deleteRule();
        }
    });
    filterPopupMenu.add(deleteRule);

    filterTasks.add(initActionCallback("doImport", "Import a filter from an XML file.",
            ActionFactory.createBoundAction("doImport", "Import Filter", "I"),
            new ImageIcon(Frame.class.getResource("images/report_go.png"))));
    JMenuItem importFilter = new JMenuItem("Import Filter");
    importFilter.setIcon(new ImageIcon(Frame.class.getResource("images/report_go.png")));
    importFilter.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            doImport();
        }
    });
    filterPopupMenu.add(importFilter);

    filterTasks.add(initActionCallback("doExport", "Export the filter to an XML file.",
            ActionFactory.createBoundAction("doExport", "Export Filter", "E"),
            new ImageIcon(Frame.class.getResource("images/report_disk.png"))));
    JMenuItem exportFilter = new JMenuItem("Export Filter");
    exportFilter.setIcon(new ImageIcon(Frame.class.getResource("images/report_disk.png")));
    exportFilter.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            doExport();
        }
    });
    filterPopupMenu.add(exportFilter);

    filterTasks.add(initActionCallback("doValidate", "Validate the currently viewed script.",
            ActionFactory.createBoundAction("doValidate", "Validate Script", "V"),
            new ImageIcon(Frame.class.getResource("images/accept.png"))));
    JMenuItem validateStep = new JMenuItem("Validate Script");
    validateStep.setIcon(new ImageIcon(Frame.class.getResource("images/accept.png")));
    validateStep.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            doValidate();
        }
    });
    filterPopupMenu.add(validateStep);

    // move rule up task
    filterTasks.add(initActionCallback("moveRuleUp", "Move the currently selected rule up.",
            ActionFactory.createBoundAction("moveRuleUp", "Move Rule Up", "P"),
            new ImageIcon(Frame.class.getResource("images/arrow_up.png"))));
    JMenuItem moveRuleUp = new JMenuItem("Move Rule Up");
    moveRuleUp.setIcon(new ImageIcon(Frame.class.getResource("images/arrow_up.png")));
    moveRuleUp.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            moveRuleUp();
        }
    });
    filterPopupMenu.add(moveRuleUp);

    // move rule down task
    filterTasks.add(initActionCallback("moveRuleDown", "Move the currently selected rule down.",
            ActionFactory.createBoundAction("moveRuleDown", "Move Rule Down", "D"),
            new ImageIcon(Frame.class.getResource("images/arrow_down.png"))));
    JMenuItem moveRuleDown = new JMenuItem("Move Rule Down");
    moveRuleDown.setIcon(new ImageIcon(Frame.class.getResource("images/arrow_down.png")));
    moveRuleDown.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            moveRuleDown();
        }
    });
    filterPopupMenu.add(moveRuleDown);

    // add the tasks to the taskpane, and the taskpane to the mirth client
    parent.setNonFocusable(filterTasks);
    filterTasks.setVisible(false);
    parent.taskPaneContainer.add(filterTasks, parent.taskPaneContainer.getComponentCount() - 1);

    makeFilterTable();

    // BGN LAYOUT
    filterTablePane.setBorder(BorderFactory.createEmptyBorder());
    rulePanel.setBorder(BorderFactory.createEmptyBorder());

    hSplitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, filterTablePane, tabbedPane);
    hSplitPane.setContinuousLayout(true);
    hSplitPane.setOneTouchExpandable(true);
    vSplitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, hSplitPane, refPanel);
    vSplitPane.setContinuousLayout(true);
    vSplitPane.setOneTouchExpandable(true);

    this.setLayout(new BorderLayout());
    this.add(vSplitPane, BorderLayout.CENTER);
    this.setBorder(BorderFactory.createEmptyBorder());
    vSplitPane.setBorder(BorderFactory.createEmptyBorder());
    hSplitPane.setBorder(BorderFactory.createEmptyBorder());
    resizePanes();
    // END LAYOUT

}

From source file:com.intuit.tank.proxy.ProxyApp.java

private JPanel getTransactionTable() {
    JPanel frame = new JPanel(new BorderLayout());
    model = new TransactionTableModel();
    final JTable table = new TransactionTable(model);
    final TableRowSorter<TableModel> sorter = new TableRowSorter<TableModel>(model);
    table.setRowSorter(sorter);/*from  w  w w.  ja v a  2s.co m*/
    final JPopupMenu pm = new JPopupMenu();
    JMenuItem item = new JMenuItem("Delete Selected");
    item.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            int[] selectedRows = table.getSelectedRows();
            if (selectedRows.length != 0) {
                int response = JOptionPane.showConfirmDialog(ProxyApp.this,
                        "Are you sure you want to delete " + selectedRows.length + " Transactions?",
                        "Confirm Delete", JOptionPane.YES_NO_OPTION);
                if (response == JOptionPane.YES_OPTION) {
                    int[] correctedRows = new int[selectedRows.length];
                    for (int i = selectedRows.length; --i >= 0;) {
                        int row = selectedRows[i];
                        int index = (Integer) table.getValueAt(row, 0) - 1;
                        correctedRows[i] = index;
                    }
                    Arrays.sort(correctedRows);
                    for (int i = correctedRows.length; --i >= 0;) {
                        int row = correctedRows[i];
                        Transaction transaction = model.getTransactionForIndex(row);
                        if (transaction != null) {
                            model.removeTransaction(transaction, row);
                            isDirty = true;
                            saveAction.setEnabled(isDirty && !stopAction.isEnabled());
                        }
                    }
                }
            }
        }
    });
    pm.add(item);
    table.add(pm);

    table.addMouseListener(new MouseAdapter() {
        boolean pressed = false;

        public void mouseClicked(MouseEvent e) {
            if (e.getClickCount() == 2) {
                Point p = e.getPoint();
                int row = table.rowAtPoint(p);
                int index = (Integer) table.getValueAt(row, 0) - 1;
                Transaction transaction = model.getTransactionForIndex(index);
                if (transaction != null) {
                    detailsTF.setText(transaction.toString());
                    detailsTF.setCaretPosition(0);
                    detailsDialog.setVisible(true);
                }
            }
        }

        /**
         * @{inheritDoc
         */
        @Override
        public void mousePressed(MouseEvent e) {
            if (e.isPopupTrigger()) {
                pressed = true;
                int[] selectedRows = table.getSelectedRows();
                if (selectedRows.length != 0) {
                    pm.show(e.getComponent(), e.getX(), e.getY());
                }
            }
        }

        /**
         * @{inheritDoc
         */
        @Override
        public void mouseReleased(MouseEvent e) {
            if (!pressed && e.isPopupTrigger()) {
                int[] selectedRows = table.getSelectedRows();
                if (selectedRows.length != 0) {
                    pm.show(e.getComponent(), e.getX(), e.getY());
                }
            }
        }

    });

    JScrollPane pane = new JScrollPane(table);
    frame.add(pane, BorderLayout.CENTER);
    JPanel panel = new JPanel(new BorderLayout());
    JLabel label = new JLabel("Filter: ");
    panel.add(label, BorderLayout.WEST);
    final JLabel countLabel = new JLabel(" Count: 0 ");
    panel.add(countLabel, BorderLayout.EAST);
    final JTextField filterText = new JTextField("");
    filterText.addKeyListener(new KeyAdapter() {
        public void keyTyped(KeyEvent e) {
            String text = filterText.getText();
            if (text.length() == 0) {
                sorter.setRowFilter(null);
            } else {
                try {
                    sorter.setRowFilter(RowFilter.regexFilter(text));
                    countLabel.setText(" Count: " + sorter.getViewRowCount() + " ");
                } catch (PatternSyntaxException pse) {
                    System.err.println("Bad regex pattern");
                }
            }
        }
    });
    panel.add(filterText, BorderLayout.CENTER);

    frame.add(panel, BorderLayout.NORTH);
    return frame;
}