Example usage for javax.swing JTable removeMouseListener

List of usage examples for javax.swing JTable removeMouseListener

Introduction

In this page you can find the example usage for javax.swing JTable removeMouseListener.

Prototype

public synchronized void removeMouseListener(MouseListener l) 

Source Link

Document

Removes the specified mouse listener so that it no longer receives mouse events from this component.

Usage

From source file:org.nuclos.client.ui.collect.CollectController.java

/**
 * alternative entry point: view search result (in Results tab)
 * @precondition this.isSearchPanelAvailable()
 *
 * @deprecated Move to ResultController.
 *///from   w  ww.  j a  v a  2s  .  c  om
public final void runViewResults(final ICollectableListOfValues clctlovSource) throws CommonBusinessException {
    // remove mouse listener for double click in table:
    final JTable tbl = this.getResultTable();
    tbl.removeMouseListener(this.getMouseListenerForTableDoubleClick());

    // add alternative mouse listener for foreign key lookup:
    foreignKeyMouseListenerForTableDoubleClick = new MouseAdapter() {
        @Override
        public void mouseClicked(MouseEvent ev) {
            if (SwingUtilities.isLeftMouseButton(ev) && ev.getClickCount() == 2) {
                try {
                    final Collectable clctSelected = CollectController.this.getCompleteSelectedCollectable();
                    // TODO assert clctSelected != null ?
                    if (clctSelected != null) {
                        clctlovSource.acceptLookedUpCollectable(clctSelected);

                        // remove the mouse listener after it has done its job:
                        // tbl.removeMouseListener(this);

                        // TODO may whatever mouselistener was installed should be removed from the table in "close()"

                        // Note that Controller.close() is called implicitly here:
                        getTab().dispose();
                    }
                } catch (Exception ex) {
                    Errors.getInstance().showExceptionDialog(getTab(), ex);
                }
            }
        }
    };

    tbl.addMouseListener(foreignKeyMouseListenerForTableDoubleClick);
    if (!this.isSearchPanelAvailable()) {
        throw new IllegalStateException("this.isSearchPanelAvailable()");
    }
    this.setCollectableSearchConditionInSearchPanel(clctlovSource.getCollectableSearchCondition());
    this.selectTab();
    getResultController().getSearchResultStrategy().cmdSearch();
    this.getCollectPanel().setTabbedPaneEnabledAt(CollectState.OUTERSTATE_DETAILS, false);
    this.getCollectPanel().setTabbedPaneEnabledAt(CollectState.OUTERSTATE_SEARCH, false);
}