Example usage for java.awt.event MouseEvent isConsumed

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

Introduction

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

Prototype

public boolean isConsumed() 

Source Link

Document

Returns whether or not this event has been consumed.

Usage

From source file:com.sec.ose.osi.ui.frm.tray.JTrayIconApp.java

private void initTray() {
    Image image = new ImageIcon(WindowUtil.class.getResource("icon.png")).getImage();

    mTrayIcon = new TrayIcon(image, mTrayTitle, createPopupMenu(BEFORE_LOGIN_STATE));
    mTrayIcon.setImageAutoSize(true);//from   w w  w.j  a va  2  s .  co m
    mTrayIcon.addMouseListener(new java.awt.event.MouseAdapter() {

        public void mousePressed(java.awt.event.MouseEvent e) {
            log.debug("mousePressed()");
            int state = 0;
            currentFrame = UISharedData.getInstance().getCurrentFrame();

            if (currentFrame == null)
                return;
            if (currentFrame.getClass().equals(JFrmLogin.class)) {
                state = BEFORE_LOGIN_STATE;
            } else {
                state = AFTER_LOGIN_STATE;
            }

            if (SwingUtilities.isRightMouseButton(e)) {
                mTrayIcon.setPopupMenu(createPopupMenu(state));
            }

            if (e.getClickCount() >= DOUBLE_CLICK && !e.isConsumed()) {
                currentFrame.setVisible(true);
            }
        }
    });

    try {
        mSystemTray.add(mTrayIcon);
    } catch (AWTException e1) {
        log.warn(e1.getMessage());
    }
}

From source file:com.projity.pm.graphic.spreadsheet.SpreadSheet.java

public void setModel(SpreadSheetModel spreadSheetModel, SpreadSheetColumnModel spreadSheetColumnModel) {
    makeCustomTableHeader(spreadSheetColumnModel);
    TableModel oldModel = getModel();
    setModel(spreadSheetModel);/*w  ww .  ja va 2  s  . c om*/

    if (spreadSheetColumnModel != null) {
        //System.out.println("creating new ColModel");
        setColumnModel(spreadSheetColumnModel);

        selection = new SpreadSheetSelectionModel(this);
        selection.setRowSelection(new SpreadSheetListSelectionModel(selection, true));
        selection.setColumnSelection(new SpreadSheetListSelectionModel(selection, false));
        setSelectionModel(selection.getRowSelection());
        createDefaultColumnsFromModel(spreadSheetModel.getFieldArray()); //Consume memory
        getColumnModel().setSelectionModel(selection.getColumnSelection());
    }

    registerEditors(); //Consume memory
    initRowHeader(spreadSheetModel);
    initModel();
    initListeners();

    GraphicConfiguration config = GraphicConfiguration.getInstance();
    //fix for substance
    setTableHeader(createDefaultTableHeader());
    JTableHeader header = getTableHeader();
    header.setPreferredSize(
            new Dimension((int) header.getPreferredSize().getWidth(), config.getColumnHeaderHeight()));
    header.addMouseListener(new HeaderMouseListener(this));

    addMouseListener(new MouseAdapter() {
        //         Cursor oldCursor = null;
        //         public void mouseEntered(MouseEvent e) {
        //            Point p = e.getPoint();
        //            int col = columnAtPoint(p);
        //            Field field = ((SpreadSheetModel) getModel()).getFieldInNonTranslatedColumn(col + 1);
        //            System.out.println("mouse entered field " + field);
        //            if (field != null && field.isHyperlink()) {
        //               oldCursor = getCursor();
        //               setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
        //               System.out.println("setting new cursor to " + Cursor.getPredefinedCursor(Cursor.HAND_CURSOR) + " old is " + oldCursor);
        //            } else 
        //               super.mouseEntered(e);
        //
        //         }
        //
        //         public void mouseExited(MouseEvent e) {
        //            Point p = e.getPoint();
        //            int col = columnAtPoint(p);
        //            Field field = ((SpreadSheetModel) getModel()).getFieldInNonTranslatedColumn(col + 1);
        //            System.out.println("mouse exited field " + field);
        //            if (field != null && field.isHyperlink()) {
        //               setCursor(oldCursor);
        //               System.out.println("setting old cursor to " + oldCursor);
        //               e.consume();
        //            } else 
        //               super.mouseEntered(e);
        //         }

        public void mousePressed(MouseEvent e) { // changed to mousePressed instead of mouseClicked() for snappier handling 17/5/04 hk
            Point p = e.getPoint();
            int row = rowAtPoint(p);
            int col = columnAtPoint(p);
            SpreadSheetPopupMenu popup = getPopup();
            if (SwingUtilities.isLeftMouseButton(e)) {
                SpreadSheetColumnModel columnModel = (SpreadSheetColumnModel) getColumnModel();
                Field field = ((SpreadSheetModel) getModel()).getFieldInNonTranslatedColumn(col + 1);
                SpreadSheetModel model = (SpreadSheetModel) getModel();
                if (field.isNameField()) {
                    // if (col == columnModel.getNameIndex()) {
                    GraphicNode node = model.getNode(row);
                    if (isOnIcon(e)) {
                        if (model.getCellProperties(node).isCompositeIcon()) {
                            finishCurrentOperations();
                            selection.getRowSelection().clearSelection();
                            boolean change = true;
                            if (!node.isFetched()) // for subprojects
                                change = node.fetch();
                            if (change)
                                model.changeCollapsedState(row);
                            e.consume(); // prevent dbl click treatment below

                            // because editor may have already been
                            // installed we
                            // have to update its collapsed state
                            // updateNameCellEditor(node);

                            // editCellAt(row,model.findGraphicNodeRow(node));
                        }
                    }
                } else if (field != null && field.isHyperlink()) {
                    Hyperlink link = (Hyperlink) model.getValueAt(row, col + 1);
                    if (link != null) {
                        BrowserControl.displayURL(link.getAddress());
                        e.consume(); // prevent dbl click treatment below
                    }

                }
                if (!e.isConsumed()) {
                    if (e.getClickCount() == 2) // if above code didn't treat and is dbl click
                        doDoubleClick(row, col);
                    else
                        doClick(row, col);
                }

            } else if (popup != null && SwingUtilities.isRightMouseButton(e)) { // e.isPopupTrigger() can be used too
                //               selection.getRowSelection().clearSelection();
                //               selection.getRowSelection().addSelectionInterval(row, row);
                popup.setRow(row);
                popup.setCol(col);
                popup.show(SpreadSheet.this, e.getX(), e.getY());
            }
        }
    });

    if (oldModel != spreadSheetModel && oldModel instanceof CommonSpreadSheetModel)
        ((CommonSpreadSheetModel) getModel()).getCache().removeNodeModelListener(this);
    spreadSheetModel.getCache().addNodeModelListener(this);

    //      getColumnModel().addColumnModelListener(new TableColumnModelListener(){
    //         public void columnAdded(TableColumnModelEvent e) {
    //            // TODO Auto-generated method stub
    //            
    //         }
    //         public void columnMarginChanged(ChangeEvent e) {
    //            // TODO Auto-generated method stub
    //            
    //         }
    //         public void columnMoved(TableColumnModelEvent e) {
    //            // TODO Auto-generated method stub
    //            
    //         }
    //         public void columnRemoved(TableColumnModelEvent e) {
    //            // TODO Auto-generated method stub
    //            
    //         }
    //         public void columnSelectionChanged(ListSelectionEvent e) {
    //            System.out.println(((e.getValueIsAdjusting())?"lse=":"LSE=")+e.getFirstIndex()+", "+e.getLastIndex());
    //            SpreadSheet.this.revalidate();
    //            //SpreadSheet.this.paintImmediately(0, 0, getWidth(), GraphicConfiguration.getInstance().getColumnHeaderHeight());
    //         }
    //      });

}

From source file:org.kalypso.mt.input.MTMouseInput.java

public void fakeMousePress(final Vector3D position) {
    m_fakeMousePressed = true;/*from www. j av a 2 s. co  m*/

    final IWidget[] widgets = m_mgr.getWidgets();
    if (ArrayUtils.isNotEmpty(widgets)) {
        final Point p = new Point((int) position.x, (int) position.y);
        m_fakeMousePressPos = p;

        final MouseEvent event = MouseEvents.toMouseEvent(p);
        for (final IWidget widget : widgets) {
            widget.mousePressed(event);
            if (event.isConsumed())
                break;
        }
    } else {
        // System.out.println( "No widget selected" );
    }
}

From source file:org.kalypso.mt.input.MTMouseInput.java

public void fakeMouseMove(final Vector3D position) {
    final MouseEvent event = MouseEvents.toMouseEvent(new Point((int) position.x, (int) position.y));

    final IWidget[] widgets = m_mgr.getWidgets();
    for (final IWidget widget : widgets) {
        if (m_fakeDrag)
            widget.mouseDragged(event);//ww w .  j ava 2s .c  o  m
        else
            widget.mouseMoved(event);

        if (event.isConsumed())
            break;
    }
}

From source file:org.kalypso.mt.input.MTMouseInput.java

public void fakeMouseRelease(final Vector3D position) {
    setFakeDrag(false);/*from   www.j a  v a 2 s.c o m*/

    if (!m_fakeMousePressed)
        return;

    final Point point = new Point((int) position.x, (int) position.y);
    final MouseEvent event = MouseEvents.toMouseEvent(point);

    final IWidget[] widgets = m_mgr.getWidgets();
    for (final IWidget widget : widgets) {
        widget.mouseReleased(event);
        if (m_fakeMousePressPos != null) {
            final double dist = m_fakeMousePressPos.distance(point);
            if (dist < MT_FAKE_MOUSE_CLICK_DISTANCE) {
                widget.mouseClicked(event);
            }
        }

        if (event.isConsumed())
            break;
    }

}

From source file:org.kalypso.ogc.gml.widgets.WidgetManager.java

@Override
public void mouseClicked(final MouseEvent e) {
    final IWidget[] widgets = getWidgets();
    for (final IWidget widget : widgets) {
        widget.mouseClicked(e);/*  w  w  w. j  a  va2 s  .c o m*/

        if (e.isConsumed())
            return;
    }
}

From source file:org.kalypso.ogc.gml.widgets.WidgetManager.java

@Override
public void mouseMoved(final MouseEvent e) {
    final IWidget[] widgets = getWidgets();
    for (final IWidget widget : widgets) {
        widget.mouseMoved(e);/*from  ww w .j  av  a 2s .  co m*/

        if (e.isConsumed())
            return;
    }

    m_mapPanel.fireMouseMouveEvent(e.getX(), e.getY());
}

From source file:org.kalypso.ogc.gml.widgets.WidgetManager.java

@Override
public void mouseDragged(final MouseEvent e) {
    final IWidget[] widgets = getWidgets();
    for (final IWidget widget : widgets) {
        widget.mouseDragged(e);//from  w w  w. j a va  2  s . co m

        if (e.isConsumed())
            return;
    }
}

From source file:org.kalypso.ogc.gml.widgets.WidgetManager.java

@Override
public void mouseEntered(final MouseEvent e) {
    final IWidget[] widgets = getWidgets();

    for (final IWidget widget : widgets) {
        // so, if the mouse enter event happens already somewhere inside the map panel frame - it's actually a finger tap
        // event/*from   ww w.  ja va  2 s .  c o  m*/
        // if( isInsideMapFrame( e.getPoint() ) )
        // {
        // FIXME: leftPressed does not exist any more
        // if( widget != null )
        // widget.leftPressed( e.getPoint() );
        // }
        // else
        widget.mouseEntered(e);

        if (e.isConsumed())
            return;
    }
}

From source file:org.kalypso.ogc.gml.widgets.WidgetManager.java

@Override
public void mouseExited(final MouseEvent e) {
    final IWidget[] widgets = getWidgets();

    for (final IWidget widget : widgets) {
        // so, if the mouse enter event happens already somewhere inside the map panel frame - it's actually a finger tap
        // event//from w w w.  j a  va2 s.c  o  m
        // if( isInsideMapFrame( e.getPoint() ) )
        // {
        // FIXME: leftReleased does not exist any more
        // if( widget != null )
        // widget.leftReleased( e.getPoint() );
        // }
        // else
        widget.mouseExited(e);

        if (e.isConsumed())
            return;
    }
}