Search in sources :

Example 71 with MouseListener

use of java.awt.event.MouseListener in project intellij-community by JetBrains.

the class DiffPanelImpl method onContentChangedIn.

public void onContentChangedIn(EditorSource source) {
    myDiffUpdater.contentRemoved(source);
    final EditorEx editor = source.getEditor();
    if (myIsHorizontal && source.getSide() == FragmentSide.SIDE1 && editor != null) {
        editor.setVerticalScrollbarOrientation(EditorEx.VERTICAL_SCROLLBAR_LEFT);
    }
    DiffSideView viewSide = getSideView(source.getSide());
    viewSide.setEditorSource(getProject(), source);
    Disposer.dispose(myScrollSupport);
    if (editor == null) {
        if (!myDisposed) {
            rediff();
        }
        return;
    }
    final MouseListener mouseListener = PopupHandler.installUnknownPopupHandler(editor.getContentComponent(), new MergeActionGroup(this, source.getSide()), ActionManager.getInstance());
    myDiffUpdater.contentAdded(source);
    editor.getSettings().setLineNumbersShown(true);
    editor.getSettings().setFoldingOutlineShown(false);
    editor.getFoldingModel().setFoldingEnabled(false);
    ((EditorMarkupModel) editor.getMarkupModel()).setErrorStripeVisible(true);
    Editor editor1 = getEditor(FragmentSide.SIDE1);
    Editor editor2 = getEditor(FragmentSide.SIDE2);
    if (editor1 != null && editor2 != null && myIsSyncScroll) {
        myScrollSupport.install(new EditingSides[] { this });
    }
    final VisibleAreaListener visibleAreaListener = mySplitter.getVisibleAreaListener();
    final ScrollingModel scrollingModel = editor.getScrollingModel();
    if (visibleAreaListener != null) {
        scrollingModel.addVisibleAreaListener(visibleAreaListener);
        scrollingModel.addVisibleAreaListener(myVisibleAreaListener);
    }
    myFontSizeSynchronizer.synchronize(editor);
    source.addDisposable(new Disposable() {

        public void dispose() {
            myFontSizeSynchronizer.stopSynchronize(editor);
        }
    });
    source.addDisposable(new Disposable() {

        public void dispose() {
            if (visibleAreaListener != null) {
                scrollingModel.removeVisibleAreaListener(visibleAreaListener);
                scrollingModel.removeVisibleAreaListener(myVisibleAreaListener);
            }
            editor.getContentComponent().removeMouseListener(mouseListener);
        }
    });
}
Also used : Disposable(com.intellij.openapi.Disposable) EditorEx(com.intellij.openapi.editor.ex.EditorEx) MouseListener(java.awt.event.MouseListener) ScrollingModel(com.intellij.openapi.editor.ScrollingModel) VisibleAreaListener(com.intellij.openapi.editor.event.VisibleAreaListener) Editor(com.intellij.openapi.editor.Editor) EditorMarkupModel(com.intellij.openapi.editor.ex.EditorMarkupModel) MergeActionGroup(com.intellij.openapi.diff.actions.MergeActionGroup)

Example 72 with MouseListener

use of java.awt.event.MouseListener in project intellij-community by JetBrains.

the class InsertPathAction method addTo.

public static void addTo(JTextComponent textField, FileChooserDescriptor descriptor) {
    if (ApplicationManager.getApplication() != null) {
        //NPE fixed when another class loader works
        removeFrom(textField);
        if (textField.getClientProperty(INSERT_PATH_ACTION) != null)
            return;
        DefaultActionGroup actionGroup = new DefaultActionGroup();
        InsertPathAction action = descriptor != null ? new InsertPathAction(textField, descriptor) : new InsertPathAction(textField);
        actionGroup.add(action);
        MouseListener popupHandler = PopupHandler.installUnknownPopupHandler(textField, actionGroup, ActionManager.getInstance());
        action.savePopupHandler(popupHandler);
        textField.putClientProperty(INSERT_PATH_ACTION, action);
    }
}
Also used : MouseListener(java.awt.event.MouseListener)

Example 73 with MouseListener

use of java.awt.event.MouseListener in project azure-tools-for-java by Microsoft.

the class VMWizardModel method configStepList.

public void configStepList(JList jList, int step) {
    jList.setListData(getStepTitleList());
    jList.setSelectedIndex(step);
    jList.setBorder(new EmptyBorder(10, 0, 10, 0));
    jList.setCellRenderer(new DefaultListCellRenderer() {

        @Override
        public Component getListCellRendererComponent(JList jList, Object o, int i, boolean b, boolean b1) {
            return super.getListCellRendererComponent(jList, "  " + o.toString(), i, b, b1);
        }
    });
    for (MouseListener mouseListener : jList.getMouseListeners()) {
        jList.removeMouseListener(mouseListener);
    }
    for (MouseMotionListener mouseMotionListener : jList.getMouseMotionListeners()) {
        jList.removeMouseMotionListener(mouseMotionListener);
    }
    jList.setBackground(JBColor.background());
}
Also used : MouseListener(java.awt.event.MouseListener) EmptyBorder(javax.swing.border.EmptyBorder) MouseMotionListener(java.awt.event.MouseMotionListener)

Example 74 with MouseListener

use of java.awt.event.MouseListener in project JMRI by JMRI.

the class SystemConsole method createFrame.

/**
     * Layout the console frame
     */
private void createFrame() {
    // Use a JmriJFrame to ensure that we fit on the screen
    frame = new JmriJFrame(Bundle.getMessage("TitleConsole"));
    pref = jmri.InstanceManager.getDefault(jmri.UserPreferencesManager.class);
    // Add Help menu (Windows menu automaitically added)
    // NOI18N
    frame.addHelpMenu("package.apps.SystemConsole", true);
    // Grab a reference to the system clipboard
    final Clipboard clipboard = frame.getToolkit().getSystemClipboard();
    // Setup the scroll pane
    JScrollPane scroll = new JScrollPane(console);
    frame.add(scroll, BorderLayout.CENTER);
    // Add button to allow copy to clipboard
    JPanel p = new JPanel();
    JButton copy = new JButton(Bundle.getMessage("ButtonCopyClip"));
    copy.addActionListener((ActionEvent event) -> {
        StringSelection text = new StringSelection(console.getText());
        clipboard.setContents(text, text);
    });
    p.add(copy);
    // Add button to allow console window to be closed
    JButton close = new JButton(Bundle.getMessage("ButtonClose"));
    close.addActionListener((ActionEvent event) -> {
        frame.setVisible(false);
        frame.dispose();
    });
    p.add(close);
    JButton stackTrace = new JButton(Bundle.getMessage("ButtonStackTrace"));
    stackTrace.addActionListener((ActionEvent event) -> {
        performStackTrace();
    });
    p.add(stackTrace);
    // Add checkbox to enable/disable auto-scrolling
    // Use the inverted SimplePreferenceState to default as enabled
    p.add(autoScroll = new JCheckBox(Bundle.getMessage("CheckBoxAutoScroll"), !pref.getSimplePreferenceState(alwaysScrollCheck)));
    autoScroll.addActionListener((ActionEvent event) -> {
        doAutoScroll(console, autoScroll.isSelected());
        pref.setSimplePreferenceState(alwaysScrollCheck, !autoScroll.isSelected());
    });
    // Add checkbox to enable/disable always on top
    p.add(alwaysOnTop = new JCheckBox(Bundle.getMessage("CheckBoxOnTop"), pref.getSimplePreferenceState(alwaysOnTopCheck)));
    alwaysOnTop.setVisible(true);
    alwaysOnTop.setToolTipText(Bundle.getMessage("ToolTipOnTop"));
    alwaysOnTop.addActionListener((ActionEvent event) -> {
        frame.setAlwaysOnTop(alwaysOnTop.isSelected());
        pref.setSimplePreferenceState(alwaysOnTopCheck, alwaysOnTop.isSelected());
    });
    frame.setAlwaysOnTop(alwaysOnTop.isSelected());
    // Define the pop-up menu
    copySelection = new JMenuItem(Bundle.getMessage("MenuItemCopy"));
    copySelection.addActionListener((ActionEvent event) -> {
        StringSelection text = new StringSelection(console.getSelectedText());
        clipboard.setContents(text, text);
    });
    popup.add(copySelection);
    JMenuItem menuItem = new JMenuItem(Bundle.getMessage("ButtonCopyClip"));
    menuItem.addActionListener((ActionEvent event) -> {
        StringSelection text = new StringSelection(console.getText());
        clipboard.setContents(text, text);
    });
    popup.add(menuItem);
    popup.add(new JSeparator());
    JRadioButtonMenuItem rbMenuItem;
    // Define the colour scheme sub-menu
    schemeMenu = new JMenu(rbc.getString("ConsoleSchemeMenu"));
    schemeGroup = new ButtonGroup();
    for (final Scheme s : schemes) {
        rbMenuItem = new JRadioButtonMenuItem(s.description);
        rbMenuItem.addActionListener((ActionEvent event) -> {
            setScheme(schemes.indexOf(s));
        });
        rbMenuItem.setSelected(getScheme() == schemes.indexOf(s));
        schemeMenu.add(rbMenuItem);
        schemeGroup.add(rbMenuItem);
    }
    popup.add(schemeMenu);
    // Define the wrap style sub-menu
    wrapMenu = new JMenu(rbc.getString("ConsoleWrapStyleMenu"));
    wrapGroup = new ButtonGroup();
    rbMenuItem = new JRadioButtonMenuItem(rbc.getString("ConsoleWrapStyleNone"));
    rbMenuItem.addActionListener((ActionEvent event) -> {
        setWrapStyle(WRAP_STYLE_NONE);
    });
    rbMenuItem.setSelected(getWrapStyle() == WRAP_STYLE_NONE);
    wrapMenu.add(rbMenuItem);
    wrapGroup.add(rbMenuItem);
    rbMenuItem = new JRadioButtonMenuItem(rbc.getString("ConsoleWrapStyleLine"));
    rbMenuItem.addActionListener((ActionEvent event) -> {
        setWrapStyle(WRAP_STYLE_LINE);
    });
    rbMenuItem.setSelected(getWrapStyle() == WRAP_STYLE_LINE);
    wrapMenu.add(rbMenuItem);
    wrapGroup.add(rbMenuItem);
    rbMenuItem = new JRadioButtonMenuItem(rbc.getString("ConsoleWrapStyleWord"));
    rbMenuItem.addActionListener((ActionEvent event) -> {
        setWrapStyle(WRAP_STYLE_WORD);
    });
    rbMenuItem.setSelected(getWrapStyle() == WRAP_STYLE_WORD);
    wrapMenu.add(rbMenuItem);
    wrapGroup.add(rbMenuItem);
    popup.add(wrapMenu);
    // Bind pop-up to objects
    MouseListener popupListener = new PopupListener();
    console.addMouseListener(popupListener);
    frame.addMouseListener(popupListener);
    // Add document listener to scroll to end when modified if required
    console.getDocument().addDocumentListener(new DocumentListener() {

        // References to the JTextArea and JCheckBox
        // of this instantiation
        JTextArea ta = console;

        JCheckBox chk = autoScroll;

        @Override
        public void insertUpdate(DocumentEvent e) {
            doAutoScroll(ta, chk.isSelected());
        }

        @Override
        public void removeUpdate(DocumentEvent e) {
            doAutoScroll(ta, chk.isSelected());
        }

        @Override
        public void changedUpdate(DocumentEvent e) {
            doAutoScroll(ta, chk.isSelected());
        }
    });
    // Add the button panel to the frame & then arrange everything
    frame.add(p, BorderLayout.SOUTH);
    frame.pack();
}
Also used : JScrollPane(javax.swing.JScrollPane) JPanel(javax.swing.JPanel) DocumentListener(javax.swing.event.DocumentListener) JTextArea(javax.swing.JTextArea) ActionEvent(java.awt.event.ActionEvent) JButton(javax.swing.JButton) JRadioButtonMenuItem(javax.swing.JRadioButtonMenuItem) DocumentEvent(javax.swing.event.DocumentEvent) UserPreferencesManager(jmri.UserPreferencesManager) JSeparator(javax.swing.JSeparator) StringSelection(java.awt.datatransfer.StringSelection) JCheckBox(javax.swing.JCheckBox) MouseListener(java.awt.event.MouseListener) JmriJFrame(jmri.util.JmriJFrame) ButtonGroup(javax.swing.ButtonGroup) Clipboard(java.awt.datatransfer.Clipboard) JMenuItem(javax.swing.JMenuItem) JMenu(javax.swing.JMenu)

Example 75 with MouseListener

use of java.awt.event.MouseListener in project jabref by JabRef.

the class BasicAction method initRawPanel.

// Panel with text import functionality
private void initRawPanel() {
    rawPanel.setLayout(new BorderLayout());
    // Textarea
    textPane.setEditable(false);
    document = textPane.getStyledDocument();
    addStylesToDocument();
    try {
        document.insertString(0, "", document.getStyle("regular"));
    } catch (BadLocationException ex) {
        LOGGER.warn("Problem setting style", ex);
    }
    OverlayPanel testPanel = new OverlayPanel(textPane, Localization.lang("paste text here"));
    testPanel.setPreferredSize(new Dimension(450, 255));
    testPanel.setMaximumSize(new Dimension(450, Integer.MAX_VALUE));
    // Setup fields (required to be done before setting up popup menu)
    fieldList = new JList<>(getAllFields());
    fieldList.setCellRenderer(new SimpleCellRenderer(fieldList.getFont()));
    ListSelectionModel listSelectionModel = fieldList.getSelectionModel();
    listSelectionModel.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    listSelectionModel.addListSelectionListener(new FieldListSelectionHandler());
    fieldList.addMouseListener(new FieldListMouseListener());
    // After the call to getAllFields
    initPopupMenuAndToolbar();
    //Add listener to components that can bring up popup menus.
    MouseListener popupListener = new PopupListener(inputMenu);
    textPane.addMouseListener(popupListener);
    testPanel.addMouseListener(popupListener);
    JPanel leftPanel = new JPanel(new BorderLayout());
    leftPanel.add(toolBar, BorderLayout.NORTH);
    leftPanel.add(testPanel, BorderLayout.CENTER);
    JPanel inputPanel = setUpFieldListPanel();
    // parse with FreeCite button
    parseWithFreeCiteButton.addActionListener(event -> {
        if (parseWithFreeCiteAndAddEntries()) {
            okPressed = false;
            dispose();
        }
    });
    rawPanel.add(leftPanel, BorderLayout.CENTER);
    rawPanel.add(inputPanel, BorderLayout.EAST);
    JLabel desc = new JLabel("<html><h3>" + Localization.lang("Plain text import") + "</h3><p>" + Localization.lang("This is a simple copy and paste dialog. First load or paste some text into " + "the text input area.<br>After that, you can mark text and assign it to a BibTeX field.") + "</p></html>");
    desc.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    rawPanel.add(desc, BorderLayout.SOUTH);
}
Also used : JPanel(javax.swing.JPanel) ListSelectionModel(javax.swing.ListSelectionModel) JLabel(javax.swing.JLabel) Dimension(java.awt.Dimension) OverlayPanel(org.jabref.gui.util.component.OverlayPanel) MouseListener(java.awt.event.MouseListener) BorderLayout(java.awt.BorderLayout) BadLocationException(javax.swing.text.BadLocationException)

Aggregations

MouseListener (java.awt.event.MouseListener)104 MouseEvent (java.awt.event.MouseEvent)67 Dimension (java.awt.Dimension)21 JLabel (javax.swing.JLabel)20 MouseAdapter (java.awt.event.MouseAdapter)19 JPanel (javax.swing.JPanel)16 Component (java.awt.Component)14 JComponent (javax.swing.JComponent)14 ActionEvent (java.awt.event.ActionEvent)13 ActionListener (java.awt.event.ActionListener)11 MouseMotionListener (java.awt.event.MouseMotionListener)11 JButton (javax.swing.JButton)11 JScrollPane (javax.swing.JScrollPane)11 Insets (java.awt.Insets)8 BorderLayout (java.awt.BorderLayout)7 Color (java.awt.Color)7 Point (java.awt.Point)7 File (java.io.File)7 ImageIcon (javax.swing.ImageIcon)6 JCheckBox (javax.swing.JCheckBox)6