Example usage for java.awt.event MouseEvent consume

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

Introduction

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

Prototype

public void consume() 

Source Link

Document

Consumes this event so that it will not be processed in the default manner by the source which originated it.

Usage

From source file:TransferableScribblePane.java

/**
 * This method is called for mouse motion events. We don't have to detect
 * gestures that initiate a drag in this method. That is the job of the
 * DragGestureRecognizer we created in the constructor: it will notify the
 * DragGestureListener defined below.// w ww  .  j a v a2s.com
 */
public void processMouseMotionEvent(MouseEvent e) {
    if (e.getID() == MouseEvent.MOUSE_DRAGGED && // If we're dragging
            currentLine != null) { // and a line exists
        currentLine.addSegment(e.getX(), e.getY()); // Add a line segment
        e.consume(); // Eat the event
        repaint(); // Redisplay all lines
    }
    super.processMouseMotionEvent(e); // Invoke any listeners
}

From source file:edu.ku.brc.ui.dnd.SimpleGlassPane.java

@Override
protected void processMouseEvent(MouseEvent e) {
    if (hideOnClick && e.getClickCount() == 1) {
        hideOnClick = false;//from   www  . jav  a  2s  . c o  m
        SwingUtilities.invokeLater(new Runnable() {
            @Override
            public void run() {
                SimpleGlassPane.this.setVisible(false);
            }
        });
    } else if (!dblClickProgBar || !getProgressBarRect().contains(e.getPoint())) {
        e.consume();
    }
    super.processMouseEvent(e);
}

From source file:net.sf.mzmine.chartbasics.gui.swing.ChartGestureMouseAdapter.java

@Override
public void mouseClicked(MouseEvent e) {
    if (gestureHandlers == null || gestureHandlers.isEmpty()
            || !(listensFor(Event.CLICK) || listensFor(Event.DOUBLE_CLICK)))
        return;/*  w  w  w. j  a  va 2  s.c o  m*/

    if (e.getComponent() instanceof ChartPanel) {
        ChartPanel chartPanel = (ChartPanel) e.getComponent();
        ChartEntity entity = findChartEntity(chartPanel, e);
        ChartGesture.Entity gestureEntity = ChartGesture.getGestureEntity(entity);
        Button button = Button.getButton(e.getButton());

        if (!e.isConsumed()) {
            // double clicked
            if (e.getClickCount() == 2) {
                // reset click count to handle double clicks quickly
                e.consume();
                // handle event
                handleEvent(new ChartGestureEvent(chartPanel, e, entity,
                        new ChartGesture(gestureEntity, Event.DOUBLE_CLICK, button)));
            } else if (e.getClickCount() == 1) {
                // handle event
                handleEvent(new ChartGestureEvent(chartPanel, e, entity,
                        new ChartGesture(gestureEntity, Event.CLICK, button)));
            }
        }
    }
}

From source file:com.diversityarrays.kdxplore.curate.fieldview.FieldLayoutViewPanel.java

@SuppressWarnings("unchecked")
public FieldLayoutViewPanel(@SuppressWarnings("rawtypes") MutableComboBoxModel comboBoxModel,
        JCheckBox alwaysOnTopOption, CurationData cd, CurationTableModel ctm, SelectedValueStore svs,
        PlotCellChoicesPanel pccp, JPopupMenu popuMenu, Font fontForResizeControls, Action curationHelpAction,
        MessagePrinter mp, Closure<String> selectionClosure, CurationContext curationContext,
        CurationMenuProvider curationMenuProvider,

        FieldLayoutTableModel fieldLayoutTableModel, CellSelectableTable fieldLayoutTable,
        FieldViewSelectionModel fvsm,/*from  ww  w . j a v  a 2 s .c om*/

        JButton undockButton) {
    super(new BorderLayout());

    this.traitInstanceCombo.setModel(comboBoxModel);
    this.curationData = cd;
    this.messagePrinter = mp;
    this.selectionClosure = selectionClosure;
    this.curationTableModel = ctm;

    this.fieldLayoutTableModel = fieldLayoutTableModel;
    this.fieldLayoutTable = fieldLayoutTable;
    this.fieldViewSelectionModel = fvsm;

    traitInstanceCombo.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            Object item = comboBoxModel.getSelectedItem();
            if (item instanceof TraitInstance) {
                TraitInstance ti = (TraitInstance) item;
                plotCellRenderer.setActiveInstance(ti);
            }
        }
    });

    rhtm = new RowHeaderTableModel(true, fieldLayoutTable, rowRemovable) {
        public String getRowLabel(int rowIndex) {
            int yCoord = FieldLayoutUtil.convertRowIndexToYCoord(rowIndex, trial,
                    fieldLayoutTableModel.getFieldLayout());
            return String.valueOf(yCoord);
        }
    };
    rowHeaderTable = new RowHeaderTable(SwingConstants.CENTER, false, fieldLayoutTable, rowRemovable, rhtm,
            RowHeaderTable.createDefaultColumnModel("X/Y")) {
        public String getMarkerIndexName(int viewRow) {
            return "MIN-" + viewRow; //$NON-NLS-1$
        }
    };
    rhtTableRowResizer = new TableRowResizer(rowHeaderTable, true);

    curationData.addCurationDataChangeListener(plotActivationListener);

    curationTableModel.addTableModelListener(new TableModelListener() {
        @Override
        public void tableChanged(TableModelEvent e) {
            fieldLayoutTable.repaint();
        }
    });
    plotCellRenderer = new PlotCellRenderer(plotAttributeProvider, curationTableModel);

    TraitInstanceCellRenderer tiCellRenderer = new TraitInstanceCellRenderer(
            curationData.getTraitColorProvider(), instanceNameProvider);
    traitInstanceCombo.setRenderer(tiCellRenderer);
    traitInstanceCombo.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            updateActiveTraitInstance();
        }
    });
    traitInstanceCombo.getModel().addListDataListener(new ListDataListener() {
        @Override
        public void intervalRemoved(ListDataEvent e) {
            updateActiveTraitInstance();
        }

        @Override
        public void intervalAdded(ListDataEvent e) {
            updateActiveTraitInstance();
        }

        @Override
        public void contentsChanged(ListDataEvent e) {
            updateActiveTraitInstance();
        }
    });

    this.trial = curationData.getTrial();
    this.plotCellChoicesPanel = pccp;

    for (TraitInstance t : curationData.getTraitInstances()) {
        String id = InstanceIdentifierUtil.getInstanceIdentifier(t);
        traitById.put(id, t);
    }

    //      fieldViewSelectionModel = new FieldViewSelectionModel(
    //            fieldLayoutTable, 
    //            fieldLayoutTableModel, 
    //            svs);
    fieldLayoutTable.setSelectionModel(fieldViewSelectionModel);

    plotCellRenderer.setCurationData(curationData);
    plotCellRenderer.setSelectionModel(fieldViewSelectionModel);

    plotCellChoicesPanel.addPlotCellChoicesListener(plotCellChoicesListener);

    fieldLayoutTableModel.setTrial(trial);

    // IMPORTANT: DO NOT SORT THE FIELD LAYOUT TABLE
    fieldLayoutTable.setAutoCreateRowSorter(false);
    JScrollPane fieldTableScrollPane = new JScrollPane(fieldLayoutTable);

    if (undockButton != null) {
        fieldTableScrollPane.setCorner(JScrollPane.UPPER_RIGHT_CORNER, undockButton);
    }
    fieldTableScrollPane.setRowHeaderView(rowHeaderTable);
    ChangeListener scrollBarChangeListener = new ChangeListener() {
        @Override
        public void stateChanged(ChangeEvent e) {
            fireRefreshRequired();
        }
    };
    fieldTableScrollPane.getVerticalScrollBar().getModel().addChangeListener(scrollBarChangeListener);
    fieldTableScrollPane.getHorizontalScrollBar().getModel().addChangeListener(scrollBarChangeListener);

    fieldLayoutTable.setRowHeaderTable(rowHeaderTable);

    //      fieldLayoutTable.setComponentPopupMenu(popuMenu);

    initFieldLayoutTable();

    Map<Integer, Plot> plotById = new HashMap<>();
    FieldLayout<Integer> plotIdLayout = FieldLayoutUtil.createPlotIdLayout(trial.getTrialLayout(),
            trial.getPlotIdentSummary(), curationData.getPlots(), plotById);

    KdxploreFieldLayout<Plot> kdxFieldLayout = new KdxploreFieldLayout<Plot>(Plot.class, plotIdLayout.imageId,
            plotIdLayout.xsize, plotIdLayout.ysize);
    kdxFieldLayout.warning = plotIdLayout.warning;

    for (int y = 0; y < plotIdLayout.ysize; ++y) {
        for (int x = 0; x < plotIdLayout.xsize; ++x) {
            Integer id = plotIdLayout.cells[y][x];
            if (id != null) {
                Plot plot = plotById.get(id);
                kdxFieldLayout.store_xy(plot, x, y);
            }
        }
    }
    fieldLayoutTableModel.setFieldLayout(kdxFieldLayout);

    if (kdxFieldLayout.warning != null && !kdxFieldLayout.warning.isEmpty()) {
        warningMessage.setText(kdxFieldLayout.warning);
    } else {
        warningMessage.setText(""); //$NON-NLS-1$
    }

    changeVisitOrderAction.putValue(Action.SMALL_ICON, KDClientUtils.getIcon(kdxFieldLayout.imageId));

    List<Component> components = new ArrayList<>();
    components.add(alwaysOnTopOption);

    Collections.addAll(components, new JButton(changeVisitOrderAction), new JButton(curationHelpAction),
            traitInstanceCombo);
    Box resizeControls = KDClientUtils.createResizeControls(fieldLayoutTable, fontForResizeControls,
            components.toArray(new Component[components.size()]));
    resizeCombo = KDClientUtils.findResizeCombo(resizeControls);

    if (RunMode.getRunMode().isDeveloper()) {
        new FieldLayoutViewPanel.DebugSettings(resizeControls, messagePrinter);
    }

    JPanel fieldPanel = new JPanel(new BorderLayout());

    //      if (useSeparator) {
    //         SeparatorPanel separator = GuiUtil.createLabelSeparator("Field Layout:", resizeControls);
    //         fieldPanel.add(separator, BorderLayout.NORTH);
    //         fieldPanel.add(fieldTableScrollPane, BorderLayout.CENTER);
    //      }
    //      else {
    fieldPanel.add(resizeControls, BorderLayout.NORTH);
    fieldPanel.add(fieldTableScrollPane, BorderLayout.CENTER);
    //      }

    //      splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT,
    //            plotCellChoicesPanel,
    //            fieldPanel);
    //      splitPane.setResizeWeight(0.0);
    //      splitPane.setOneTouchExpandable(true);

    add(warningMessage, BorderLayout.NORTH);
    add(fieldPanel, BorderLayout.CENTER);
    //      splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT,
    //            plotCellChoicesPanel,
    //            fieldPanel);
    //      splitPane.setResizeWeight(0.0);
    //      splitPane.setOneTouchExpandable(true);
    //      
    //      add(warningMessage, BorderLayout.NORTH);
    //      add(splitPane, BorderLayout.CENTER);

    fieldLayoutTable.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseClicked(MouseEvent me) {
            if (SwingUtilities.isRightMouseButton(me) && 1 == me.getClickCount()) {
                me.consume();

                List<Plot> plots = getSelectedPlots();

                List<TraitInstance> checkedInstances = new ArrayList<>();
                for (int index = traitInstanceCombo.getItemCount(); --index >= 1;) {
                    Object item = traitInstanceCombo.getItemAt(index);
                    if (item instanceof TraitInstance) {
                        checkedInstances.add((TraitInstance) item);
                    }
                }

                TraitInstance ti = fieldViewSelectionModel.getActiveTraitInstance(true);
                List<PlotOrSpecimen> plotSpecimens = new ArrayList<>();
                plotSpecimens.addAll(plots);
                curationMenuProvider.showFieldViewToolMenu(me, plotSpecimens, ti, checkedInstances);
            }
        }
    });
}

From source file:TransferableScribblePane.java

/**
 * This method is called on mouse button events. It begins a new line or tries
 * to select an existing line./*from   w  w  w.j a v a2 s . co  m*/
 */
public void processMouseEvent(MouseEvent e) {
    if (e.getButton() == MouseEvent.BUTTON1) { // Left mouse button
        if (e.getID() == MouseEvent.MOUSE_PRESSED) { // Pressed down
            if (e.isShiftDown()) { // with Shift key
                // If the shift key is down, try to select a line
                int x = e.getX();
                int y = e.getY();

                // Loop through the lines checking to see if we hit one
                PolyLine selection = null;
                int numlines = lines.size();
                for (int i = 0; i < numlines; i++) {
                    PolyLine line = (PolyLine) lines.get(i);
                    if (line.intersects(x - 2, y - 2, 4, 4)) {
                        selection = line;
                        e.consume();
                        break;
                    }
                }
                // If we found an intersecting line, save it and repaint
                if (selection != selectedLine) { // If selection changed
                    selectedLine = selection; // remember which is selected
                    repaint(); // will make selection dashed
                }
            } else if (!e.isControlDown()) { // no shift key or ctrl key
                // Start a new line on mouse down without shift or ctrl
                currentLine = new PolyLine(e.getX(), e.getY());
                lines.add(currentLine);
                e.consume();
            }
        } else if (e.getID() == MouseEvent.MOUSE_RELEASED) {// Left Button Up
            // End the line on mouse up
            if (currentLine != null) {
                currentLine = null;
                e.consume();
            }
        }
    }

    // The superclass method dispatches to registered event listeners
    super.processMouseEvent(e);
}

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

public void setModel(SpreadSheetModel spreadSheetModel, SpreadSheetColumnModel spreadSheetColumnModel) {
    makeCustomTableHeader(spreadSheetColumnModel);
    TableModel oldModel = getModel();
    setModel(spreadSheetModel);//from  w w w. j  av a  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:edu.uci.ics.jung.visualization.control.LabelEditingGraphMousePlugin.java

/**
 * For primary modifiers (default, MouseButton1):
 * pick a single Vertex or Edge that/*w  ww.  ja  va 2s.com*/
  * is under the mouse pointer. If no Vertex or edge is under
  * the pointer, unselect all picked Vertices and edges, and
  * set up to draw a rectangle for multiple selection
  * of contained Vertices.
  * For additional selection (default Shift+MouseButton1):
  * Add to the selection, a single Vertex or Edge that is
  * under the mouse pointer. If a previously picked Vertex
  * or Edge is under the pointer, it is un-picked.
  * If no vertex or Edge is under the pointer, set up
  * to draw a multiple selection rectangle (as above)
  * but do not unpick previously picked elements.
 * 
 * @param e the event
 */
@SuppressWarnings("unchecked")
public void mouseClicked(MouseEvent e) {
    if (e.getModifiers() == modifiers && e.getClickCount() == 2) {
        VisualizationViewer<V, E> vv = (VisualizationViewer) e.getSource();
        GraphElementAccessor<V, E> pickSupport = vv.getPickSupport();
        if (pickSupport != null) {
            Transformer<V, String> vs = vv.getRenderContext().getVertexLabelTransformer();
            if (vs instanceof MapTransformer) {
                Map<V, String> map = ((MapTransformer) vs).getMap();
                Layout<V, E> layout = vv.getGraphLayout();
                // p is the screen point for the mouse event
                Point2D p = e.getPoint();

                V vertex = pickSupport.getVertex(layout, p.getX(), p.getY());
                if (vertex != null) {
                    String newLabel = vs.transform(vertex);
                    newLabel = JOptionPane.showInputDialog("New Vertex Label for " + vertex);
                    if (newLabel != null) {
                        map.put(vertex, newLabel);
                        vv.repaint();
                    }
                    return;
                }
            }
            Transformer<E, String> es = vv.getRenderContext().getEdgeLabelTransformer();
            if (es instanceof MapTransformer) {
                Map<E, String> map = ((MapTransformer) es).getMap();
                Layout<V, E> layout = vv.getGraphLayout();
                // p is the screen point for the mouse event
                Point2D p = e.getPoint();
                // take away the view transform
                Point2D ip = vv.getRenderContext().getMultiLayerTransformer().inverseTransform(Layer.VIEW, p);
                E edge = pickSupport.getEdge(layout, ip.getX(), ip.getY());
                if (edge != null) {
                    String newLabel = JOptionPane.showInputDialog("New Edge Label for " + edge);
                    if (newLabel != null) {
                        map.put(edge, newLabel);
                        vv.repaint();
                    }
                    return;
                }
            }
        }
        e.consume();
    }
}

From source file:com.diversityarrays.kdxplore.curate.TrialDataEditor.java

public TrialDataEditor(CurationData cd, WindowOpener<JFrame> windowOpener, MessageLogger messageLogger,
        KdxploreDatabase kdxdb, IntFunction<Trait> traitProvider, SampleType[] sampleTypes) throws IOException {
    super(new BorderLayout());

    this.traitProvider = traitProvider;
    this.windowOpener = windowOpener;

    this.curationData = cd;
    this.curationData.setChangeManager(changeManager);
    this.curationData.setKDSmartDatabase(kdxdb.getKDXploreKSmartDatabase());

    inactiveTagFilterIcon = KDClientUtils.getIcon(ImageId.TAG_FILTER_24);
    activeTagFilterIcon = KDClientUtils.getIcon(ImageId.TAG_FILTER_ACTIVE_24);

    inactivePlotOrSpecimenFilterIcon = KDClientUtils.getIcon(ImageId.FILTER_PLOT_SPEC_INACTIVE);
    activePlotFilterIcon = KDClientUtils.getIcon(ImageId.FILTER_PLOT_ACTIVE);
    activeSpecimenFilterIcon = KDClientUtils.getIcon(ImageId.FILTER_SPEC_ACTIVE);

    updatePlotSpecimenIcon();//from   w  w  w.  j  av  a2s .  c  o  m

    TraitColorProvider traitColourProvider = new TraitColorProvider(false);
    this.curationData.setTraitColorProvider(traitColourProvider);

    curationData.addCurationDataChangeListener(new CurationDataChangeListener() {
        @Override
        public void plotActivationChanged(Object source, boolean activated, List<Plot> plots) {
            updateRowFilter();
            if (toolController != null) {
                toolController.plotActivationsChanged(activated, plots);
            }
        }

        @Override
        public void editedSamplesChanged(Object source, List<CurationCellId> curationCellIds) {
            if (toolController != null) {
                toolController.editedSamplesChanged();
            }
        }
    });

    this.selectedValueStore = new SelectedValueStore(curationData.getTrial().getTrialName());

    this.messageLogger = messageLogger;

    smallFont = KDClientUtils.makeSmallFont(this);

    // undockViewAction.putValue(Action.SHORT_DESCRIPTION, "Click to undock
    // this view");

    KDClientUtils.initAction(ImageId.HELP_24, curationHelpAction, Msg.TOOLTIP_HELP_DATA_CURATION(), false);

    KDClientUtils.initAction(ImageId.SAVE_24, saveChangesAction, Msg.TOOLTIP_SAVE_CHANGES(), true);
    KDClientUtils.initAction(ImageId.EXPORT_24, exportCuratedData, Msg.TOOLTIP_EXPORT(), true);

    KDClientUtils.initAction(ImageId.UNDO_24, undoAction, Msg.TOOLTIP_UNDO(), true);
    KDClientUtils.initAction(ImageId.REDO_24, redoAction, Msg.TOOLTIP_REDO(), true);

    KDClientUtils.initAction(ImageId.FIELD_VIEW_24, showFieldViewAction, Msg.TOOLTIP_FIELD_VIEW(), false);

    KDClientUtils.initAction(ImageId.GET_TRIALINFO_24, importCuratedData, Msg.TOOLTIP_IMPORT_DATA(), true);

    Function<TraitInstance, List<KdxSample>> sampleProvider = new Function<TraitInstance, List<KdxSample>>() {
        @Override
        public List<KdxSample> apply(TraitInstance ti) {
            return curationData.getSampleMeasurements(ti);
        }
    };
    tivrByTi = VisToolUtil.buildTraitInstanceValueRetrieverMap(curationData.getTrial(),
            curationData.getTraitInstances(), sampleProvider);

    // = = = = = = = =

    boolean readOnly = false;
    // FIXME work out if the Trial can be edited or not
    curationTableModel = new CurationTableModel(curationData, readOnly);
    // See FIXME comment in CurationTableModel.isReadOnly()

    curationTableSelectionModel = new CurationTableSelectionModelImpl(selectedValueStore, curationTableModel);

    curationTableSelectionModel.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);

    curationTable = new CurationTable("CurationTable-" + (++UNIQUE_CURATION_TABLE_ID), //$NON-NLS-1$
            curationTableModel, curationTableSelectionModel);
    curationTable.setCellSelectionEnabled(true);
    curationTable.setAutoCreateRowSorter(true);

    // = = = = = = = =
    this.sampleSourcesTablePanel = new SampleSourcesTablePanel(curationData, curationTableModel, handler);

    @SuppressWarnings("unchecked")
    TableRowSorter<CurationTableModel> rowSorter = (TableRowSorter<CurationTableModel>) curationTable
            .getRowSorter();
    rowSorter.setSortsOnUpdates(true);
    rowSorter.addRowSorterListener(rowSorterListener);

    curationCellRenderer = new CurationTableCellRenderer(curationTableModel, colorProviderFactory,
            curationTableSelectionModel);

    curationTable.setDefaultRenderer(Object.class, curationCellRenderer);
    curationTable.setDefaultRenderer(Integer.class, curationCellRenderer);
    curationTable.setDefaultRenderer(String.class, curationCellRenderer);
    curationTable.setDefaultRenderer(CurationCellValue.class, curationCellRenderer);
    curationTable.setDefaultRenderer(Double.class, curationCellRenderer);
    curationTable.setDefaultRenderer(TraitValue.class, curationCellRenderer);

    // If either the rows selected change or the columns selected change
    // then we
    // need to inform the visualisation tools.
    curationTable.getSelectionModel().addListSelectionListener(curationTableCellSelectionListener);
    curationTable.getColumnModel().addColumnModelListener(curationTableCellSelectionListener);

    fieldLayoutView = new InterceptFieldLayoutView();

    this.curationCellEditor = new CurationCellEditorImpl(curationTableModel, fieldLayoutView, curationData,
            refreshFieldLayoutView, kdxdb, traitProvider, sampleTypes);

    SuppressionInfoProvider suppressionInfoProvider = new SuppressionInfoProvider(curationData,
            curationTableModel, curationTable);

    suppressionHandler = new SuppressionHandler(curationContext, curationData, curationCellEditor,
            suppressionInfoProvider);

    loadVisualisationTools();

    curationMenuProvider = new CurationMenuProvider(curationContext, curationData, messages, visualisationTools,
            suppressionHandler);

    curationMenuProvider.setSuppressionInfoProvider(suppressionInfoProvider);

    fieldLayoutView.addTraitInstanceSelectionListener(new ItemListener() {
        @Override
        public void itemStateChanged(ItemEvent e) {
            if (ItemEvent.SELECTED == e.getStateChange()) {
                TraitInstance traitInstance = fieldLayoutView.getActiveTraitInstance(true);
                if (traitInstance == null) {
                    curationCellEditor.setCurationCellValue(null);
                } else {
                    // startEdit(HowStarted.FIELD_VIEW_CHANGED_ACTIVE_TRAIT_INSTANCE);
                }
                fieldLayoutView.updateSamplesSelectedInTable();
            }
        }
    });

    // = = = = = = =

    curationData.addUnsavedChangesListener(new UnsavedChangesListener() {
        @Override
        public void unsavedChangesExist(Object source, int nChanges) {
            int unsavedCount = curationData.getUnsavedChangesCount();
            saveChangesAction.setEnabled(unsavedCount > 0);

            if (unsavedCount > 0) {
                statusInfoLine.setMessage("Unsaved changes: " + unsavedCount);
            } else {
                statusInfoLine.setMessage("No Unsaved changes");
            }
        }
    });

    // curationData.addEditedSampleChangeListener(new ChangeListener() {
    // @Override
    // public void stateChanged(ChangeEvent e) {
    // handleEditedSampleChanges();
    // }
    // });
    saveChangesAction.setEnabled(false);
    changeManager.addChangeListener(new ChangeListener() {
        @Override
        public void stateChanged(ChangeEvent e) {
            updateUndoRedoActions();
        }
    });
    undoAction.setEnabled(false);
    redoAction.setEnabled(false);

    // = = = = = = = =

    // TODO provide one of these for each relevant device type
    DeviceType deviceTypeForSamples = null;

    StatsData statsData = curationData.getStatsData(deviceTypeForSamples);

    TIStatsTableModel statsTableModel = new TIStatsTableModel2(curationData, statsData, deviceTypeForSamples);

    traitColourProvider.generateColorMap(statsData.getTraitInstancesWithData());

    Set<Integer> instanceNumbers = statsData.getInstanceNumbers();
    String nonHtmlLabel;
    if (instanceNumbers.size() > 1) {
        tAndIpanelLabel = "<HTML><i>Plot Info</i> &amp; Trait Instances";
        nonHtmlLabel = "Plot Info & Trait Instances";
    } else {
        tAndIpanelLabel = "<HTML><i>Plot Info</i> &amp; Traits";
        nonHtmlLabel = "Plot Info & Traits";
    }

    traitsAndInstancesPanel = new TraitsAndInstancesPanel2(curationContext, smallFont, statsTableModel,
            instanceNumbers.size() > 1, statsData.getInvalidRuleCount(), nonHtmlLabel, curationMenuProvider,
            outlierConsumer);

    traitsAndInstancesPanel.addTraitInstanceStatsItemListener(new ItemListener() {
        boolean busy;

        @Override
        public void itemStateChanged(ItemEvent e) {
            // NOTE: we want to process both SELECTED and DESELECTED
            // variants
            if (busy) {
                Shared.Log.d(TAG, "***** LOOPED in traitsAndInstancesPanel.ItemListener"); //$NON-NLS-1$
            } else {
                Shared.Log.d(TAG, "traitsAndInstancesPanel.ItemListener BEGIN"); //$NON-NLS-1$
                busy = true;
                try {
                    updateViewedTraitInstances(e); // !!!!!
                } finally {
                    busy = false;
                    Shared.Log.d(TAG, "traitsAndInstancesPanel.ItemListener END\n"); //$NON-NLS-1$
                }
            }
        }
    });

    // = = = = = = = =

    plotCellChoicesPanel = new PlotCellChoicesPanel(curationContext, curationData, deviceTypeForSamples,
            tAndIpanelLabel, curationMenuProvider, colorProviderFactory);

    // plotCellChoicesPanel.setData(
    // curationData.getPlotAttributes(),
    // traitsAndInstancesPanel.getTraitInstancesWithData());

    plotCellChoicesPanel.addPlotCellChoicesListener(new PlotCellChoicesListener() {
        @Override
        public void traitInstanceChoicesChanged(Object source, boolean choiceAdded, TraitInstance[] choice,
                Map<Integer, Set<TraitInstance>> traitInstancesByTraitId) {
            traitsAndInstancesPanel.changeTraitInstanceChoice(choiceAdded, choice);
        }

        @Override
        public void plotAttributeChoicesChanged(Object source, List<ValueRetriever<?>> vrList) {
            curationTableModel.setSelectedPlotAttributes(vrList);
        }
    });

    // = = = = = = = =

    statsAndSamplesSplit = createStatsAndSamplesTable(traitsAndInstancesPanel.getComponent());

    mainTabbedPane.addTab(TAB_SAMPLES, samplesTableIcon, statsAndSamplesSplit, Msg.TOOLTIP_SAMPLES_TABLE());

    // = = = = = = = =

    checkForInvalidTraits();

    leftSplit = new JSplitPane(JSplitPane.VERTICAL_SPLIT, createCurationCellEditorComponent(),
            plotCellChoicesPanel);
    leftSplit.setResizeWeight(0.5);
    // traitToDoTaskPaneContainer);

    // rightSplit = new JSplitPane(JSplitPane.VERTICAL_SPLIT,
    // traitsAndInstancesPanel, fieldViewAndPlots);
    // rightSplit.setResizeWeight(0.5);
    // rightSplit.setOneTouchExpandable(true);

    leftAndRightSplit = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, leftSplit, mainTabbedPane);
    leftAndRightSplit.setOneTouchExpandable(true);

    mainVerticalSplit = new JSplitPane(JSplitPane.VERTICAL_SPLIT, messages, leftAndRightSplit);
    mainVerticalSplit.setOneTouchExpandable(true);
    mainVerticalSplit.setResizeWeight(0.0);

    add(statusInfoLine, BorderLayout.NORTH);
    add(mainVerticalSplit, BorderLayout.CENTER);

    fieldLayoutView.addCellSelectionListener(fieldViewCellSelectionListener);

    curationTable.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseClicked(MouseEvent me) {
            if (SwingUtilities.isRightMouseButton(me) && 1 == me.getClickCount()) {
                me.consume();
                displayPopupMenu(me);
            }

        }
    });
}

From source file:net.technicpack.launcher.ui.InstallerFrame.java

private void addGlassPane() {
    glassPane = new JPanel() {
        @Override//from  w  ww.j  a  va2 s .  c  om
        public void paintComponent(Graphics g) {
            super.paintComponent(g);
            g.setColor(LauncherFrame.COLOR_CENTRAL_BACK);
            g.fillRect(0, 0, getWidth(), getHeight());
        }
    };
    glassPane.addMouseListener(new MouseListener() {
        @Override
        public void mouseClicked(MouseEvent e) {
            e.consume();
        }

        @Override
        public void mousePressed(MouseEvent e) {
            e.consume();
        }

        @Override
        public void mouseReleased(MouseEvent e) {
            e.consume();
        }

        @Override
        public void mouseEntered(MouseEvent e) {
            e.consume();
        }

        @Override
        public void mouseExited(MouseEvent e) {
            e.consume();
        }
    });
    glassPane.setOpaque(false);
    glassPane.setLayout(new GridBagLayout());

    JLabel spinner = new JLabel(resources.getIcon("loader.gif"));
    glassPane.add(spinner);
    setGlassPane(glassPane);
}

From source file:org.kalypso.kalypsomodel1d2d.ui.map.channeledit.DrawBanklineWidget.java

@Override
public void mousePressed(final MouseEvent event) {
    if (event.getButton() != MouseEvent.BUTTON1)
        return;//from   w  w  w . j  a va2 s . co  m

    event.consume();

    final IMapPanel mapPanel = getMapPanel();
    if (mapPanel == null)
        return;

    final Point p = event.getPoint();

    m_currentPos = MapUtilities.transform(mapPanel, p);

    /* If we have a node, take this position, else take the current one */
    // final GM_Point currentPos = MapUtilities.transform( mapPanel, p );

    if (!m_edit) {
        try {
            final GM_Curve curve = (GM_Curve) m_lineBuilder.addPoint(m_currentPos);
            if (curve != null)
                finishLine(curve);
        } catch (final Exception e) {
            e.printStackTrace();
            reinit();
        }
    }
}