Search in sources :

Example 36 with EventObject

use of java.util.EventObject in project intellij-community by JetBrains.

the class AbstractValueHint method showHint.

protected boolean showHint(final JComponent component) {
    myInsideShow = true;
    if (myCurrentHint != null) {
        myCurrentHint.hide();
    }
    myCurrentHint = new LightweightHint(component) {

        @Override
        protected boolean canAutoHideOn(TooltipEvent event) {
            InputEvent inputEvent = event.getInputEvent();
            if (inputEvent instanceof MouseEvent) {
                Component comp = inputEvent.getComponent();
                if (comp instanceof EditorComponentImpl) {
                    EditorImpl editor = ((EditorComponentImpl) comp).getEditor();
                    return !isInsideCurrentRange(editor, ((MouseEvent) inputEvent).getPoint());
                }
            }
            return true;
        }
    };
    myCurrentHint.addHintListener(new HintListener() {

        @Override
        public void hintHidden(EventObject event) {
            if (myHideRunnable != null && !myInsideShow) {
                myHideRunnable.run();
            }
            onHintHidden();
        }
    });
    // editor may be disposed before later invokator process this action
    if (myEditor.isDisposed() || myEditor.getComponent().getRootPane() == null) {
        return false;
    }
    Point p = HintManagerImpl.getHintPosition(myCurrentHint, myEditor, myEditor.xyToLogicalPosition(myPoint), HintManager.UNDER);
    HintHint hint = HintManagerImpl.createHintHint(myEditor, p, myCurrentHint, HintManager.UNDER, true);
    hint.setShowImmediately(true);
    HintManagerImpl.getInstanceImpl().showEditorHint(myCurrentHint, myEditor, p, HintManager.HIDE_BY_ANY_KEY | HintManager.HIDE_BY_TEXT_CHANGE | HintManager.HIDE_BY_SCROLLING, 0, false, hint);
    myInsideShow = false;
    return true;
}
Also used : EditorMouseEvent(com.intellij.openapi.editor.event.EditorMouseEvent) TooltipEvent(com.intellij.ide.TooltipEvent) EditorComponentImpl(com.intellij.openapi.editor.impl.EditorComponentImpl) EditorImpl(com.intellij.openapi.editor.impl.EditorImpl) RelativePoint(com.intellij.ui.awt.RelativePoint) EventObject(java.util.EventObject)

Example 37 with EventObject

use of java.util.EventObject in project intellij-community by JetBrains.

the class ShowUIDefaultsAction method actionPerformed.

@Override
public void actionPerformed(AnActionEvent e) {
    final UIDefaults defaults = UIManager.getDefaults();
    Enumeration keys = defaults.keys();
    final Object[][] data = new Object[defaults.size()][2];
    int i = 0;
    while (keys.hasMoreElements()) {
        Object key = keys.nextElement();
        data[i][0] = key;
        data[i][1] = defaults.get(key);
        i++;
    }
    Arrays.sort(data, (o1, o2) -> StringUtil.naturalCompare(o1[0].toString(), o2[0].toString()));
    final Project project = getEventProject(e);
    new DialogWrapper(project) {

        {
            setTitle("Edit LaF Defaults");
            setModal(false);
            init();
        }

        public JBTable myTable;

        @Nullable
        @Override
        public JComponent getPreferredFocusedComponent() {
            return myTable;
        }

        @Nullable
        @Override
        protected String getDimensionServiceKey() {
            return project == null ? null : "UI.Defaults.Dialog";
        }

        @Override
        protected JComponent createCenterPanel() {
            final JBTable table = new JBTable(new DefaultTableModel(data, new Object[] { "Name", "Value" }) {

                @Override
                public boolean isCellEditable(int row, int column) {
                    return column == 1 && getValueAt(row, column) instanceof Color;
                }
            }) {

                @Override
                public boolean editCellAt(int row, int column, EventObject e) {
                    if (isCellEditable(row, column) && e instanceof MouseEvent) {
                        final Object color = getValueAt(row, column);
                        final Color newColor = ColorPicker.showDialog(this, "Choose Color", (Color) color, true, null, true);
                        if (newColor != null) {
                            final ColorUIResource colorUIResource = new ColorUIResource(newColor);
                            final Object key = getValueAt(row, 0);
                            UIManager.put(key, colorUIResource);
                            setValueAt(colorUIResource, row, column);
                        }
                    }
                    return false;
                }
            };
            table.setDefaultRenderer(Object.class, new DefaultTableCellRenderer() {

                @Override
                public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
                    final JPanel panel = new JPanel(new BorderLayout());
                    final JLabel label = new JLabel(value == null ? "" : value.toString());
                    panel.add(label, BorderLayout.CENTER);
                    if (value instanceof Color) {
                        final Color c = (Color) value;
                        label.setText(String.format("[r=%d,g=%d,b=%d] hex=0x%s", c.getRed(), c.getGreen(), c.getBlue(), ColorUtil.toHex(c)));
                        label.setForeground(ColorUtil.isDark(c) ? Color.white : Color.black);
                        panel.setBackground(c);
                        return panel;
                    } else if (value instanceof Icon) {
                        try {
                            final Icon icon = new IconWrap((Icon) value);
                            if (icon.getIconHeight() <= 20) {
                                label.setIcon(icon);
                            }
                            label.setText(String.format("(%dx%d) %s)", icon.getIconWidth(), icon.getIconHeight(), label.getText()));
                        } catch (Throwable e1) {
                        //
                        }
                        return panel;
                    } else if (value instanceof Border) {
                        try {
                            final Insets i = ((Border) value).getBorderInsets(null);
                            label.setText(String.format("[%d, %d, %d, %d] %s", i.top, i.left, i.bottom, i.right, label.getText()));
                            return panel;
                        } catch (Exception ignore) {
                        }
                    }
                    return super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
                }
            });
            final JBScrollPane pane = new JBScrollPane(table);
            new TableSpeedSearch(table, (o, cell) -> cell.column == 1 ? null : String.valueOf(o));
            table.setShowGrid(false);
            final JPanel panel = new JPanel(new BorderLayout());
            panel.add(pane, BorderLayout.CENTER);
            myTable = table;
            TableUtil.ensureSelectionExists(myTable);
            return panel;
        }
    }.show();
}
Also used : EmptyIcon(com.intellij.util.ui.EmptyIcon) Arrays(java.util.Arrays) DefaultTableModel(javax.swing.table.DefaultTableModel) Enumeration(java.util.Enumeration) StringUtil(com.intellij.openapi.util.text.StringUtil) AnAction(com.intellij.openapi.actionSystem.AnAction) ColorUIResource(javax.swing.plaf.ColorUIResource) MouseEvent(java.awt.event.MouseEvent) JBScrollPane(com.intellij.ui.components.JBScrollPane) Border(javax.swing.border.Border) EventObject(java.util.EventObject) java.awt(java.awt) JBTable(com.intellij.ui.table.JBTable) Nullable(org.jetbrains.annotations.Nullable) DefaultTableCellRenderer(javax.swing.table.DefaultTableCellRenderer) PairFunction(com.intellij.util.PairFunction) DialogWrapper(com.intellij.openapi.ui.DialogWrapper) AnActionEvent(com.intellij.openapi.actionSystem.AnActionEvent) Project(com.intellij.openapi.project.Project) DumbAware(com.intellij.openapi.project.DumbAware) Comparator(java.util.Comparator) javax.swing(javax.swing) DefaultTableModel(javax.swing.table.DefaultTableModel) JBTable(com.intellij.ui.table.JBTable) DefaultTableCellRenderer(javax.swing.table.DefaultTableCellRenderer) Enumeration(java.util.Enumeration) MouseEvent(java.awt.event.MouseEvent) ColorUIResource(javax.swing.plaf.ColorUIResource) DialogWrapper(com.intellij.openapi.ui.DialogWrapper) EventObject(java.util.EventObject) Project(com.intellij.openapi.project.Project) EventObject(java.util.EventObject) EmptyIcon(com.intellij.util.ui.EmptyIcon) Border(javax.swing.border.Border) Nullable(org.jetbrains.annotations.Nullable) JBScrollPane(com.intellij.ui.components.JBScrollPane)

Example 38 with EventObject

use of java.util.EventObject in project intellij-community by JetBrains.

the class FileColorSettingsTable method editCellAt.

@Override
public boolean editCellAt(int row, int column, EventObject e) {
    if (e == null || (e instanceof MouseEvent && ((MouseEvent) e).getClickCount() == 1))
        return false;
    final Object at = getModel().getValueAt(row, column);
    if (!(at instanceof FileColorConfiguration))
        return false;
    final FileColorConfigurationEditDialog dialog = new FileColorConfigurationEditDialog(myManager, ((FileColorConfiguration) at));
    dialog.getScopeComboBox().setEnabled(false);
    dialog.show();
    return false;
}
Also used : MouseEvent(java.awt.event.MouseEvent) EventObject(java.util.EventObject)

Example 39 with EventObject

use of java.util.EventObject in project JMRI by JMRI.

the class HelpUtil method makeHelpMenu.

public static JMenu makeHelpMenu(String ref, boolean direct) {
    if (!initOK()) {
        log.warn("help initialization not completed");
        // initialization failed
        return null;
    }
    JMenu helpMenu = new JMenu(Bundle.getMessage("HELP"));
    JMenuItem item = makeHelpMenuItem(ref);
    if (item == null) {
        log.error("Can't make help menu item for " + ref);
        return null;
    }
    helpMenu.add(item);
    if (direct) {
        item = new JMenuItem(Bundle.getMessage("MenuItemHelp"));
        globalHelpBroker.enableHelpOnButton(item, "index", null);
        helpMenu.add(item);
        // add standard items
        JMenuItem license = new JMenuItem(Bundle.getMessage("MenuItemLicense"));
        helpMenu.add(license);
        license.addActionListener(new apps.LicenseAction());
        JMenuItem directories = new JMenuItem(Bundle.getMessage("MenuItemLocations"));
        helpMenu.add(directories);
        directories.addActionListener(new jmri.jmrit.XmlFileLocationAction());
        JMenuItem updates = new JMenuItem(Bundle.getMessage("MenuItemCheckUpdates"));
        helpMenu.add(updates);
        updates.addActionListener(new apps.CheckForUpdateAction());
        JMenuItem context = new JMenuItem(Bundle.getMessage("MenuItemContext"));
        helpMenu.add(context);
        context.addActionListener(new apps.ReportContextAction());
        JMenuItem console = new JMenuItem(Bundle.getMessage("MenuItemConsole"));
        helpMenu.add(console);
        console.addActionListener(new apps.SystemConsoleAction());
        helpMenu.add(new jmri.jmrit.mailreport.ReportAction());
        // Put about dialog in Apple's prefered area on Mac OS X
        if (SystemType.isMacOSX()) {
            try {
                Application.getApplication().setAboutHandler((EventObject eo) -> {
                    new AboutDialog(null, true).setVisible(true);
                });
            } catch (java.lang.RuntimeException re) {
                log.error("Unable to put About handler in default location", re);
            }
        }
        // Include About in Help menu if not on Mac OS X or not using Aqua Look and Feel
        if (!SystemType.isMacOSX() || !UIManager.getLookAndFeel().isNativeLookAndFeel()) {
            helpMenu.addSeparator();
            JMenuItem about = new JMenuItem(Bundle.getMessage("MenuItemAbout") + " " + jmri.Application.getApplicationName());
            helpMenu.add(about);
            about.addActionListener(new AboutAction());
        }
    }
    return helpMenu;
}
Also used : AboutDialog(jmri.swing.AboutDialog) AboutAction(apps.AboutAction) EventObject(java.util.EventObject) JMenuItem(javax.swing.JMenuItem) JMenu(javax.swing.JMenu)

Example 40 with EventObject

use of java.util.EventObject in project cayenne by apache.

the class ProjectController method removeFromHistory.

private void removeFromHistory(EventObject e) {
    int count = controllerStateHistory.size();
    List<ControllerState> removeList = new ArrayList<>();
    for (int i = 0; i < count; i++) {
        ControllerState cs = controllerStateHistory.get(i);
        if (cs == null || cs.event == null) {
            continue;
        }
        EventObject csEvent = cs.event;
        if (e instanceof EntityEvent && csEvent instanceof EntityDisplayEvent) {
            if (((EntityEvent) e).getEntity() == ((EntityDisplayEvent) csEvent).getEntity()) {
                removeList.add(cs);
            }
        } else if (e instanceof EmbeddableEvent && csEvent instanceof EmbeddableDisplayEvent) {
            if (((EmbeddableEvent) e).getEmbeddable() == ((EmbeddableDisplayEvent) csEvent).getEmbeddable()) {
                removeList.add(cs);
            }
        } else if (e instanceof ProcedureEvent && csEvent instanceof ProcedureDisplayEvent) {
            if (((ProcedureEvent) e).getProcedure() == ((ProcedureDisplayEvent) csEvent).getProcedure()) {
                removeList.add(cs);
            }
        } else if (e instanceof QueryEvent && csEvent instanceof QueryDisplayEvent) {
            if (((QueryEvent) e).getQuery() == ((QueryDisplayEvent) csEvent).getQuery()) {
                removeList.add(cs);
            }
        } else if (e instanceof DataMapEvent && csEvent instanceof DataMapDisplayEvent) {
            if (((DataMapEvent) e).getDataMap() == ((DataMapDisplayEvent) csEvent).getDataMap()) {
                removeList.add(cs);
            }
        } else if (e instanceof DataNodeEvent && csEvent instanceof DataNodeDisplayEvent) {
            if (((DataNodeEvent) e).getDataNode() == ((DataNodeDisplayEvent) csEvent).getDataNode()) {
                removeList.add(cs);
            }
        } else if (e instanceof DomainEvent && csEvent instanceof DomainDisplayEvent) {
            if (((DomainEvent) e).getDomain() == ((DomainDisplayEvent) csEvent).getDomain()) {
                removeList.add(cs);
            }
        }
    }
    for (ControllerState o : removeList) {
        controllerStateHistory.remove(o);
    }
}
Also used : EmbeddableEvent(org.apache.cayenne.map.event.EmbeddableEvent) DomainEvent(org.apache.cayenne.configuration.event.DomainEvent) ProcedureEvent(org.apache.cayenne.configuration.event.ProcedureEvent) ArrayList(java.util.ArrayList) QueryEvent(org.apache.cayenne.configuration.event.QueryEvent) EventObject(java.util.EventObject) DataMapEvent(org.apache.cayenne.configuration.event.DataMapEvent) DataNodeEvent(org.apache.cayenne.configuration.event.DataNodeEvent) EntityEvent(org.apache.cayenne.map.event.EntityEvent)

Aggregations

EventObject (java.util.EventObject)111 EventFactory (org.apache.camel.spi.EventFactory)25 EventNotifier (org.apache.camel.spi.EventNotifier)25 ManagementStrategy (org.apache.camel.spi.ManagementStrategy)25 AlertHandler (edu.cmu.cs.hcii.cogtool.util.AlertHandler)21 EventNotifierSupport (org.apache.camel.support.EventNotifierSupport)15 DefaultCamelContext (org.apache.camel.impl.DefaultCamelContext)10 Frame (edu.cmu.cs.hcii.cogtool.model.Frame)9 Hashtable (java.util.Hashtable)8 AsynchClientTask (cbit.vcell.client.task.AsynchClientTask)7 ProgressDialogListener (org.vcell.util.ProgressDialogListener)7 Test (org.junit.Test)6 MouseEvent (java.awt.event.MouseEvent)4 File (java.io.File)4 ExchangeCompletedEvent (org.apache.camel.management.event.ExchangeCompletedEvent)4 ClientConfig (com.hazelcast.client.config.ClientConfig)3 Design (edu.cmu.cs.hcii.cogtool.model.Design)3 TaskGroup (edu.cmu.cs.hcii.cogtool.model.TaskGroup)3 DesignEditorFrame (edu.cmu.cs.hcii.cogtool.uimodel.DesignEditorFrame)3 PreferencesHandler (jmri.plaf.macosx.PreferencesHandler)3