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:eu.europa.ec.markt.dss.applet.view.validationpolicy.EditView.java

private void registerMouseListener(final JTree tree) {

    MouseListener mouseAdapter = new MouseAdapter() {
        public void mousePressed(MouseEvent mouseEvent) {
            if (mouseEvent.getButton() == MouseEvent.BUTTON3) {
                final int selectedRow = tree.getRowForLocation(mouseEvent.getX(), mouseEvent.getY());
                final TreePath selectedPath = tree.getPathForLocation(mouseEvent.getX(), mouseEvent.getY());
                if (selectedRow != -1) {
                    final XmlDomAdapterNode clickedItem = (XmlDomAdapterNode) selectedPath
                            .getLastPathComponent();
                    final boolean isLeaf = tree.getModel().isLeaf(selectedPath.getLastPathComponent());
                    // Do nothing on root element
                    if (selectedPath.getPathCount() > 1) {
                        // find the allowed actions, to know if a popup menu should be displayed and the content of the popup menu + action handlers
                        if (clickedItem.node instanceof Element) {
                            nodeActionAdd(mouseEvent, selectedRow, selectedPath, clickedItem, tree);
                        } else if (isLeaf) {
                            valueLeafActionEdit(mouseEvent, selectedPath, clickedItem, tree);
                        }//from w  w w. java2  s  .c  o m
                    }
                }
            }
        }
    };
    tree.addMouseListener(mouseAdapter);
}

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

public MirthTable(String prefix, Set<String> defaultVisibleColumns) {
    super();/*  w ww .j a  va  2  s  .c  o m*/

    this.prefix = prefix;
    this.defaultVisibleColumns = defaultVisibleColumns;

    userPreferences = Preferences.userNodeForPackage(Mirth.class);
    columnOrderMap = new HashMap<String, Integer>();
    if (StringUtils.isNotEmpty(prefix)) {
        try {
            userPreferences = Preferences.userNodeForPackage(Mirth.class);
            String columns = userPreferences.get(prefix + "ColumnOrderMap", "");

            if (StringUtils.isNotEmpty(columns)) {
                columnOrderMap = (Map<String, Integer>) ObjectXMLSerializer.getInstance().deserialize(columns,
                        Map.class);
            }
        } catch (Exception e) {
        }

        sortKeys = new ArrayList<SortKey>();
        try {
            String sortOrder = userPreferences.get(prefix + "SortOrder", "");

            if (StringUtils.isNotEmpty(sortOrder)) {
                sortKeys = ObjectXMLSerializer.getInstance().deserialize(sortOrder, List.class);
            }
        } catch (Exception e) {
        }
    }

    setDragEnabled(true);
    addKeyListener(new KeyListener() {

        public void keyPressed(KeyEvent e) {
            boolean isAccelerated = (((e.getModifiers()
                    & Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()) > 0)
                    || ((e.getModifiers() & InputEvent.CTRL_MASK) > 0));
            if ((e.getKeyCode() == KeyEvent.VK_S) && isAccelerated) {
                PlatformUI.MIRTH_FRAME.doContextSensitiveSave();
            }
        }

        public void keyReleased(KeyEvent e) {
        }

        public void keyTyped(KeyEvent e) {
        }
    });

    /*
     * Swingx 1.0 has this set to true by default, which doesn't allow dragging and dropping
     * into tables. Swingx 0.8 had this set to false. Tables that want it set to true can
     * override it.
     */
    putClientProperty("terminateEditOnFocusLost", Boolean.FALSE);

    getTableHeader().addMouseListener(new MouseAdapter() {
        public void mouseReleased(MouseEvent e) {
            saveColumnOrder();
        }
    });

    final JButton columnControlButton = new JButton(new ColumnControlButton(this).getIcon());

    columnControlButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            JPopupMenu columnMenu = getColumnMenu();
            Dimension buttonSize = columnControlButton.getSize();
            int xPos = columnControlButton.getComponentOrientation().isLeftToRight()
                    ? buttonSize.width - columnMenu.getPreferredSize().width
                    : 0;
            columnMenu.show(columnControlButton, xPos, columnControlButton.getHeight());
        }
    });

    setColumnControl(columnControlButton);
}

From source file:ru.codemine.pos.ui.windows.document.startbalances.StartBalancesListWindow.java

@Override
public void setupActionListeners() {
    setNewActionListener(newSb);/*from w  w  w  . j a v  a2  s  .  com*/
    setEditActionListener(editSb);
    setDeleteActionListener(deleteSb);
    setProcessActionListener(processSb);
    setUnprocessActionListener(unprocessSb);
    setRefreshActionListener(refreshSbList);

    storeChooseBox.addActionListener(changeStoreSb);

    table.addMouseListener(new MouseAdapter() {
        @Override
        public void mousePressed(MouseEvent e) {
            Point p = e.getPoint();
            int row = table.rowAtPoint(p);
            if (e.getClickCount() == 2 && e.getButton() == MouseEvent.BUTTON1) {
                menuItemEdit.doClick();
            }
        }
    });

    actionListenersInit = true;
}

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

private void initGUI() {
    try {/*from  w  ww.  j  av  a  2s. c o m*/
        {
        }
        BorderLayout thisLayout = new BorderLayout();
        getContentPane().setLayout(thisLayout);
        this.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
        {
            jTabbedPane1 = new JTabbedPane();
            getContentPane().add(jTabbedPane1, BorderLayout.CENTER);
            {
                jPanel1 = new JPanel();
                BorderLayout jPanel1Layout = new BorderLayout();
                jPanel1.setLayout(jPanel1Layout);
                jTabbedPane1.addTab("source", null, jPanel1, null);
                {
                    jScrollPane1 = new JScrollPane();
                    jPanel1.add(jScrollPane1, BorderLayout.CENTER);
                    {
                        replaceArea = new JTextArea();
                        jScrollPane1.setViewportView(replaceArea);
                        replaceArea.addMouseListener(new MouseAdapter() {
                            public void mouseClicked(MouseEvent evt) {
                                JPopupMenuUtil.newInstance(replaceArea).applyEvent(evt)
                                        .addJMenuItem("load from file", true, new ActionListener() {

                                            Thread newThread;

                                            public void actionPerformed(ActionEvent arg0) {
                                                if (newThread != null
                                                        && newThread.getState() != Thread.State.TERMINATED) {
                                                    JCommonUtil._jOptionPane_showMessageDialog_error(
                                                            "file is loading!");
                                                    return;
                                                }

                                                final File file = JCommonUtil._jFileChooser_selectFileOnly();
                                                if (file == null) {
                                                    JCommonUtil._jOptionPane_showMessageDialog_error(
                                                            "file is not correct!");
                                                    return;
                                                }
                                                String defaultCharset = Charset.defaultCharset().displayName();
                                                String chst = (String) JCommonUtil._jOptionPane_showInputDialog(
                                                        "input your charset!", defaultCharset);
                                                final Charset charset2 = Charset.forName(
                                                        StringUtils.defaultIfEmpty(chst, defaultCharset));

                                                newThread = new Thread(Thread.currentThread().getThreadGroup(),
                                                        new Runnable() {
                                                            public void run() {
                                                                try {
                                                                    loadFromFileSb = new StringBuilder();
                                                                    BufferedReader reader = new BufferedReader(
                                                                            new InputStreamReader(
                                                                                    new FileInputStream(file),
                                                                                    charset2));
                                                                    for (String line = null; (line = reader
                                                                            .readLine()) != null;) {
                                                                        loadFromFileSb.append(line + "\n");
                                                                    }
                                                                    reader.close();
                                                                    replaceArea
                                                                            .setText(loadFromFileSb.toString());
                                                                    JCommonUtil
                                                                            ._jOptionPane_showMessageDialog_info(
                                                                                    "load completed!");
                                                                } catch (Exception e) {
                                                                    JCommonUtil.handleException(e);
                                                                }
                                                            }
                                                        }, "" + System.currentTimeMillis());
                                                newThread.setDaemon(true);
                                                newThread.start();
                                            }
                                        }).show();
                            }
                        });
                    }
                }
            }
            {
                jPanel2 = new JPanel();
                BorderLayout jPanel2Layout = new BorderLayout();
                jPanel2.setLayout(jPanel2Layout);
                jTabbedPane1.addTab("param", null, jPanel2, null);
                {
                    exeucte = new JButton();
                    jPanel2.add(exeucte, BorderLayout.SOUTH);
                    exeucte.setText("exeucte");
                    exeucte.setPreferredSize(new java.awt.Dimension(491, 125));
                    exeucte.addActionListener(new ActionListener() {
                        public void actionPerformed(ActionEvent evt) {
                            exeucteActionPerformed(evt);
                        }
                    });
                }
                {
                    jPanel3 = new JPanel();
                    GroupLayout jPanel3Layout = new GroupLayout((JComponent) jPanel3);
                    jPanel3.setLayout(jPanel3Layout);
                    jPanel2.add(jPanel3, BorderLayout.CENTER);
                    {
                        repFromText = new JTextField();
                    }
                    {
                        repToText = new JTextField();
                    }
                    jPanel3Layout.setHorizontalGroup(jPanel3Layout.createSequentialGroup()
                            .addContainerGap(25, 25)
                            .addGroup(jPanel3Layout.createParallelGroup()
                                    .addGroup(jPanel3Layout.createSequentialGroup().addComponent(repFromText,
                                            GroupLayout.PREFERRED_SIZE, 446, GroupLayout.PREFERRED_SIZE))
                                    .addGroup(jPanel3Layout.createSequentialGroup().addComponent(repToText,
                                            GroupLayout.PREFERRED_SIZE, 446, GroupLayout.PREFERRED_SIZE)))
                            .addContainerGap(20, Short.MAX_VALUE));
                    jPanel3Layout.setVerticalGroup(jPanel3Layout.createSequentialGroup().addContainerGap()
                            .addComponent(repFromText, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE,
                                    GroupLayout.PREFERRED_SIZE)
                            .addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED)
                            .addComponent(repToText, GroupLayout.PREFERRED_SIZE, 24, GroupLayout.PREFERRED_SIZE)
                            .addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE));
                }
                {
                    addToTemplate = new JButton();
                    jPanel2.add(addToTemplate, BorderLayout.NORTH);
                    addToTemplate.setText("add to template");
                    addToTemplate.addActionListener(new ActionListener() {
                        public void actionPerformed(ActionEvent evt) {
                            prop.put(repFromText.getText(), repToText.getText());
                            reloadTemplateList();
                        }
                    });
                }
            }
            {
                jPanel4 = new JPanel();
                BorderLayout jPanel4Layout = new BorderLayout();
                jPanel4.setLayout(jPanel4Layout);
                jTabbedPane1.addTab("result", null, jPanel4, null);
                {
                    jScrollPane2 = new JScrollPane();
                    jPanel4.add(jScrollPane2, BorderLayout.CENTER);
                    jScrollPane2.setPreferredSize(new java.awt.Dimension(491, 283));
                    {
                        DefaultTableModel resultAreaModel = JTableUtil.createModel(true, "match", "count");
                        resultArea = new JTable();
                        jScrollPane2.setViewportView(resultArea);
                        JTableUtil.defaultSetting(resultArea);
                        resultArea.setModel(resultAreaModel);
                    }
                }
            }
            {
                jPanel5 = new JPanel();
                BorderLayout jPanel5Layout = new BorderLayout();
                jPanel5.setLayout(jPanel5Layout);
                jTabbedPane1.addTab("template", null, jPanel5, null);
                {
                    jScrollPane3 = new JScrollPane();
                    jPanel5.add(jScrollPane3, BorderLayout.CENTER);
                    {
                        templateList = new JList();
                        jScrollPane3.setViewportView(templateList);
                        reloadTemplateList();
                    }
                    templateList.addMouseListener(new MouseAdapter() {
                        public void mouseClicked(MouseEvent evt) {
                            if (templateList.getLeadSelectionIndex() == -1) {
                                return;
                            }
                            Entry<Object, Object> entry = (Entry<Object, Object>) JListUtil
                                    .getLeadSelectionObject(templateList);
                            repFromText.setText((String) entry.getKey());
                            repToText.setText((String) entry.getValue());
                        }
                    });
                    templateList.addKeyListener(new KeyAdapter() {
                        public void keyPressed(KeyEvent evt) {
                            JListUtil.newInstance(templateList).defaultJListKeyPressed(evt);
                        }
                    });
                }
            }
            {
                jPanel6 = new JPanel();
                FlowLayout jPanel6Layout = new FlowLayout();
                jPanel6.setLayout(jPanel6Layout);
                jTabbedPane1.addTab("result1", null, jPanel6, null);
                {
                    resultBtn1 = new JButton();
                    jPanel6.add(resultBtn1);
                    resultBtn1.setText("to String[]");
                    resultBtn1.setPreferredSize(new java.awt.Dimension(105, 32));
                    resultBtn1.addActionListener(new ActionListener() {
                        public void actionPerformed(ActionEvent evt) {
                            JTableUtil tableUtil = JTableUtil.newInstance(resultArea);
                            int[] rowPoss = tableUtil.getSelectedRows();
                            DefaultTableModel model = tableUtil.getModel();
                            List<Object> valueList = new ArrayList<Object>();
                            for (int ii = 0; ii < rowPoss.length; ii++) {
                                valueList.add(model.getValueAt(rowPoss[ii], 0));
                            }
                            String reult = valueList.toString().replaceAll("[\\s]", "")
                                    .replaceAll("[\\,]", "\",\"").replaceAll("[\\[\\]]", "\"");
                            ClipboardUtil.getInstance().setContents(reult);
                        }
                    });
                }
                {
                    resultBtn2 = new JButton();
                    jPanel6.add(resultBtn2);
                    resultBtn2.setText("TODO");
                    resultBtn2.setPreferredSize(new java.awt.Dimension(105, 32));
                    resultBtn2.addActionListener(new ActionListener() {
                        public void actionPerformed(ActionEvent evt) {
                            System.out.println("resultBtn1.actionPerformed, event=" + evt);
                            // TODO add your code for
                            // resultBtn1.actionPerformed
                            JCommonUtil._jOptionPane_showMessageDialog_info("TODO");
                        }
                    });
                }
            }
        }
        this.setSize(512, 350);
        JCommonUtil.setFont(repToText, repFromText, replaceArea, templateList);
        {
            panel = new JPanel();
            jTabbedPane1.addTab("eBao", null, panel, null);
            panel.setLayout(new BorderLayout(0, 0));
            {
                scrollPane = new JScrollPane();
                panel.add(scrollPane, BorderLayout.CENTER);
                {
                    ebaoTable = new JTable();
                    scrollPane.setViewportView(ebaoTable);
                    // TODO
                    DefaultTableModel ebaoModel = JTableUtil.createModel(true, "match", "label");
                    JTableUtil.defaultSetting(ebaoTable);
                    ebaoTable.setModel(ebaoModel);
                }
            }
            {
                exactEbaoSearchChk = new JCheckBox("");
                panel.add(exactEbaoSearchChk, BorderLayout.NORTH);
            }
        }

        JCommonUtil.frameCloseDo(this, new WindowAdapter() {
            public void windowClosing(WindowEvent paramWindowEvent) {
                if (StringUtils.isNotBlank(repFromText.getText())) {
                    prop.put(repFromText.getText(), repToText.getText());
                }
                try {
                    prop.store(new FileOutputStream(propFile), "regexText");
                } catch (Exception e) {
                    JCommonUtil.handleException("properties store error!", e);
                }
                setVisible(false);
                dispose();
            }
        });
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:de.mprengemann.intellij.plugin.androidicons.settings.PluginSettings.java

private void initAndroidIconsSettings() {
    FileChooserDescriptor workingDirectoryChooserDescriptor = FileChooserDescriptorFactory
            .createSingleFolderDescriptor();
    if (persistedAndroidIconsFile != null) {
        VirtualFile loadedFile = VirtualFileManager.getInstance().findFileByUrl(persistedAndroidIconsFile);
        if (loadedFile != null) {
            androidIconsAssetHome.setText(loadedFile.getCanonicalPath());
            selectedAndroidIconsFile = loadedFile;
        }/*  www  .ja v a 2s.  c  o m*/
    }
    String title = "Select res directory";
    workingDirectoryChooserDescriptor.setTitle(title);
    androidIconsAssetHome.addBrowseFolderListener(title, null, null, workingDirectoryChooserDescriptor);
    androidIconsAssetHome
            .addBrowseFolderListener(new TextBrowseFolderListener(workingDirectoryChooserDescriptor) {
                @Override
                @SuppressWarnings("deprecation") // Otherwise not compatible to AndroidStudio
                protected void onFileChoosen(@NotNull VirtualFile chosenFile) {
                    super.onFileChoosen(chosenFile);
                    selectionPerformed = true;
                    selectedAndroidIconsFile = chosenFile;
                    scanForAndroidIconsAssets();
                }
            });
    androidIconsOpenBrowser.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseClicked(MouseEvent e) {
            super.mouseClicked(e);
            BrowserUtil.browse(ANDROID_ICONS_URL);
        }
    });
    scanForAndroidIconsAssets();
}

From source file:com.openbravo.pos.admin.RolesViewTree.java

private void createTree() {

    //Create the jtree            
    root = new DefaultMutableTreeNode();
    uTree = new CheckboxTree(root);
    root.setUserObject("All Permissions");
    uTree.getCheckingModel().setCheckingMode(TreeCheckingModel.CheckingMode.PROPAGATE_PRESERVING_CHECK);
    uTree.clearSelection();/*from  w  w  w .  ja  v  a  2  s. c o  m*/

    DefaultCheckboxTreeCellRenderer renderer = (DefaultCheckboxTreeCellRenderer) uTree.getCellRenderer();
    renderer.setLeafIcon(null);
    renderer.setClosedIcon(null);
    renderer.setOpenIcon(null);

    // set up listeners
    MouseListener ml = new MouseAdapter() {
        public void mousePressed(MouseEvent e) {
            int selRow = uTree.getRowForLocation(e.getX(), e.getY());
            TreePath selPath = uTree.getPathForLocation(e.getX(), e.getY());

            if (selPath != null) {
                DefaultMutableTreeNode node = (DefaultMutableTreeNode) selPath.getLastPathComponent();
                // If using Right to left Language change the way the check tree works    
                if (!uTree.getComponentOrientation().isLeftToRight()) {
                    if (uTree.isPathChecked(new TreePath(node.getPath()))) {
                        uTree.removeCheckingPath(new TreePath(node.getPath()));
                    } else {
                        uTree.addCheckingPath(new TreePath(node.getPath()));
                    }
                }
                jPermissionDesc.setText(descriptionMap.get(node));
            }
        }
    };
    uTree.addMouseListener(ml);

    // when this listener is fired changes state to dirty 
    uTree.addTreeCheckingListener(new TreeCheckingListener() {
        public void valueChanged(TreeCheckingEvent e) {
            passedDirty.setDirty(true);
        }
    });

    try {
        // Get list of all the permisions in the database
        // and the list of sections
        dbPermissions = (List) m_dlAdmin.getAlldbPermissions();
        branches = m_dlAdmin.getSectionsList();
    } catch (BasicException ex) {
        Logger.getLogger(RolesViewTree.class.getName()).log(Level.SEVERE, null, ex);
    }

    // Create the main branches in the tree
    for (Object branch : branches) {
        section = ((StringUtils.substring(branch.toString(), 0, 2)).equals("##"))
                ? AppLocal.getIntString(StringUtils.right(branch.toString(), branch.toString().length() - 2))
                : branch.toString();
        root.add(new DefaultMutableTreeNode(section));
    }

    classMap = new HashMap();
    descriptionMap = new HashMap();
    nodePaths = new HashMap();
    // Replace displayname, Section and Description 
    // from the database with the correct details from the permissions locale        
    for (DBPermissionsInfo Perm : dbPermissions) {
        Perm.setDisplayName(((StringUtils.substring(Perm.getDisplayName(), 0, 2)).equals("##"))
                ? AppLocal.getIntString(
                        StringUtils.right(Perm.getDisplayName(), Perm.getDisplayName().length() - 2))
                : Perm.getDisplayName());
        Perm.setSection(((StringUtils.substring(Perm.getSection(), 0, 2)).equals("##"))
                ? AppLocal.getIntString(StringUtils.right(Perm.getSection(), Perm.getSection().length() - 2))
                : Perm.getSection());
        Perm.setDescription(((StringUtils.substring(Perm.getDescription(), 0, 2)).equals("##"))
                ? AppLocal.getIntString(
                        StringUtils.right(Perm.getDescription(), Perm.getDescription().length() - 2))
                : Perm.getDescription());
    }
    //put the list into order by display name
    sort();
    // Create the leaf nodes & fill in hashmap's
    for (DBPermissionsInfo Perm : dbPermissions) {
        DefaultMutableTreeNode newNode = new DefaultMutableTreeNode(Perm.getDisplayName(), false);
        if (searchNode(Perm.getSection(), root) != null) {
            searchNode(Perm.getSection(), root).add(newNode);
            classMap.put("[All Permissions, " + Perm.getSection() + ", " + newNode + "]", Perm.getClassName());
            descriptionMap.put(newNode, Perm.getDescription());
            nodePaths.put(Perm.getClassName(), newNode);
        }
    }
    root = sortTree(root);
    jScrollPane1.setViewportView(uTree);
    uTree.expandAll();
}

From source file:com.samebug.clients.idea.ui.component.WriteTip.java

public WriteTip(final Actions actions) {
    tipTitle = new TipTitle();
    tipDescription = new DescriptionLabel(SamebugBundle.message("samebug.tip.write.tip.description"));
    tipBody = new TipBody();
    lengthCounter = new LengthCounter();
    sourceTitle = new SourceTitle();
    sourceDescription = new DescriptionLabel(SamebugBundle.message("samebug.tip.write.source.description"));
    sourceLink = new SourceLink();
    errorPanel = new ErrorPanel();
    cancel = new CancelButton();
    submit = new SubmitButton();
    this.actions = actions;

    setLayout(new BoxLayout(this, BoxLayout.PAGE_AXIS));
    setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));

    add(new TransparentPanel() {
        {//from  w w w. j av  a  2s .  com
            add(tipTitle);
        }
    });
    add(new TransparentPanel() {
        {
            setBorder(BorderFactory.createEmptyBorder(10, 0, 10, 0));
            add(tipDescription);
        }
    });
    add(new JScrollPane(tipBody));
    add(new TransparentPanel() {
        {
            setLayout(new FlowLayout(FlowLayout.RIGHT));
            add(lengthCounter);
        }
    });
    add(new TransparentPanel() {
        {
            add(sourceTitle);
        }
    });
    add(new TransparentPanel() {
        {
            setBorder(BorderFactory.createEmptyBorder(10, 0, 10, 0));
            add(sourceDescription);
        }
    });
    add(new TransparentPanel() {
        {
            add(sourceLink);
        }
    });
    add(new TransparentPanel() {
        {
            setBorder(BorderFactory.createEmptyBorder(10, 0, 10, 0));
            add(errorPanel);
        }
    });
    add(new TransparentPanel() {
        {
            setLayout(new FlowLayout(FlowLayout.RIGHT, 20, 0));
            add(cancel);
            add(submit);
        }
    });

    PromptSupport.setPrompt(SamebugBundle.message("samebug.tip.write.tip.placeholder"), tipBody);
    PromptSupport.setPrompt(SamebugBundle.message("samebug.tip.write.source.placeholder"), sourceLink);
    updateSubmitButton(true);

    ((AbstractDocument) tipBody.getDocument()).setDocumentFilter(new TipConstraints());
    tipBody.getDocument().addDocumentListener(new TipEditorListener());

    submit.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseClicked(MouseEvent e) {
            if (submit.isEnabled()) {
                final String tip = tipBody.getText();
                final String rawSourceUrl = sourceLink.getText();
                beginPostTip();
                actions.onClickSubmitTip(tip, rawSourceUrl);
            }
        }
    });
}

From source file:org.eurocarbdb.application.glycoworkbench.plugin.PeakAnnotationCalibrationPanel.java

protected void finalSettings() {
    super.finalSettings();

    theChartPanel.addMouseMotionListener(new MouseMotionAdapter() {
        public void mouseDragged(MouseEvent e) {
            onMouseDragged(e);/*from   w w w.  j  a v a  2 s.  co m*/
        }
    });

    theChartPanel.addMouseListener(new MouseAdapter() {
        public void mousePressed(MouseEvent e) {
            onMousePressed(e);
        }

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

        public void mouseClicked(MouseEvent e) {
            onMouseClicked(e);
        }
    });
}

From source file:ec.ui.view.StabilityView.java

public StabilityView() {
    super();//from   w ww  .java  2  s  .  com
    setLayout(new BorderLayout());

    this.graphs_ = new LinkedHashMap<>();

    meanRenderer = new XYLineAndShapeRenderer(true, false);
    meanRenderer.setAutoPopulateSeriesPaint(false);
    meanRenderer.setBasePaint(themeSupport.getLineColor(KnownColor.RED));

    pointsRenderer = new XYLineAndShapeRenderer(false, true);
    pointsRenderer.setAutoPopulateSeriesPaint(false);
    pointsRenderer.setAutoPopulateSeriesShape(false);
    pointsRenderer.setBaseShape(new Ellipse2D.Double(-2, -2, 4, 4));
    pointsRenderer.setBasePaint(themeSupport.getLineColor(KnownColor.BLUE));
    pointsRenderer.setBaseShapesFilled(false);

    smoothRenderer = new XYLineAndShapeRenderer(true, false);
    smoothRenderer.setAutoPopulateSeriesPaint(false);
    smoothRenderer.setBasePaint(themeSupport.getLineColor(KnownColor.GREEN));

    mainChart = createChart();
    detailChart = createChart();

    panel = new JChartPanel(null);

    errorPanel = new JPanel(new BorderLayout());
    errorLabel = new JLabel();
    errorLabel.setHorizontalAlignment(SwingConstants.CENTER);
    errorLabel.setFont(errorLabel.getFont().deriveFont(errorLabel.getFont().getSize2D() * 3 / 2));
    errorPanel.add(errorLabel, BorderLayout.CENTER);

    panel.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseClicked(MouseEvent e) {
            indexSelected = -1;
            if (e.getButton() == MouseEvent.BUTTON1 && e.getClickCount() == 2) {
                double x = panel.getChartX(e.getX());
                Graphs g = null;
                for (Bornes b : graphs_.keySet()) {
                    indexSelected++;
                    if (x >= b.min_ && x <= b.max_) {
                        g = graphs_.get(b);
                        break;
                    }
                }
                if (g == null) {
                    return;
                }

                showDetail(g);
            } else if (e.getButton() == MouseEvent.BUTTON3) {
                showMain();
                indexSelected = -1;
            }
        }
    });

    StandardXYToolTipGenerator generator = new StandardXYToolTipGenerator() {
        final DecimalFormat format = new DecimalFormat("0.0000");

        @Override
        public String generateToolTip(XYDataset dataset, int series, int item) {
            try {
                StabilityViewItem i = items.get(indexSelected == -1 ? series : indexSelected);
                int cpt = 0;
                for (Map.Entry<TsDomain, Double> e : i.data.entrySet()) {
                    if (cpt == item) {
                        TsDomain dom = e.getKey();
                        return "(" + dom.getStart().toString() + ", " + dom.getEnd().toString() + ") : "
                                + format.format(e.getValue());
                    }
                    cpt++;
                }
            } catch (IndexOutOfBoundsException e) {
            }
            return null;
        }
    };
    pointsRenderer.setBaseToolTipGenerator(generator);
    cards = new JPanel(new CardLayout());

    cards.add(MAIN_PANEL, panel);

    cards.add(ERROR_PANEL, errorPanel);

    add(cards, BorderLayout.CENTER);

    onColorSchemeChange();
}

From source file:com.wwidesigner.gui.StudyView.java

@Override
protected void initializeComponents() {
    // create file tree
    tree = new JTree() {
        @Override/*ww w.j  a v  a  2  s .  c  o m*/
        public String getToolTipText(MouseEvent e) {
            String tip = null;
            TreePath path = tree.getPathForLocation(e.getX(), e.getY());
            if (path != null) {
                if (path.getPathCount() == 3) // it is a leaf
                {
                    DefaultMutableTreeNode node = (DefaultMutableTreeNode) path.getLastPathComponent();
                    if (node instanceof TreeNodeWithToolTips) {
                        tip = ((TreeNodeWithToolTips) node).getToolTip();
                    }
                }
            }
            return tip == null ? getToolTipText() : tip;
        }
    };
    // Show tooltips for the Study view, and let them persist for 8 seconds.
    ToolTipManager.sharedInstance().registerComponent(tree);
    ToolTipManager.sharedInstance().setDismissDelay(8000);
    // If a Study view node doesn't fit in the pane, expand it when hovering
    // over it.
    ExpandedTipUtils.install(tree);
    tree.setRootVisible(false);
    tree.getSelectionModel().setSelectionMode(TreeSelectionModel.DISCONTIGUOUS_TREE_SELECTION);
    tree.addMouseListener(new MouseAdapter() {
        public void mousePressed(MouseEvent e) {
            TreePath path = tree.getPathForLocation(e.getX(), e.getY());
            if (path != null) {
                if (path.getPathCount() == 3) // it is a leaf
                {
                    DefaultMutableTreeNode node = (DefaultMutableTreeNode) path.getLastPathComponent();
                    DefaultMutableTreeNode parentNode = (DefaultMutableTreeNode) node.getParent();
                    String category = (String) parentNode.getUserObject();
                    study.setCategorySelection(category, (String) node.getUserObject());
                    if (StudyModel.INSTRUMENT_CATEGORY_ID.equals(category)
                            || StudyModel.TUNING_CATEGORY_ID.equals(category)) {
                        try {
                            study.validHoleCount();
                        } catch (Exception ex) {
                            showException(ex);
                        }
                    }
                }
                updateView();
            }
        }
    });
    JScrollPane scrollPane = new JScrollPane(tree);
    scrollPane.setPreferredSize(new Dimension(225, 100));
    add(scrollPane);

    Preferences myPreferences = getApplication().getPreferences();
    String modelName = myPreferences.get(OptimizationPreferences.STUDY_MODEL_OPT,
            OptimizationPreferences.NAF_STUDY_NAME);
    setStudyModel(modelName);
    study.setPreferences(myPreferences);

    getApplication().getEventManager().subscribe(WIDesigner.FILE_OPENED_EVENT_ID, this);
    getApplication().getEventManager().subscribe(WIDesigner.FILE_CLOSED_EVENT_ID, this);
    getApplication().getEventManager().subscribe(WIDesigner.FILE_SAVED_EVENT_ID, this);
    getApplication().getEventManager().subscribe(WIDesigner.WINDOW_RENAMED_EVENT_ID, this);
}