Java Code Examples for org.eclipse.swt.widgets.Control#removeMouseListener()

The following examples show how to use org.eclipse.swt.widgets.Control#removeMouseListener() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ClipboardCopy.java    From BiglyBT with GNU General Public License v2.0 5 votes vote down vote up
public static void
removeCopyToClipMenu(
Control		control )
{
 MouseAdapter ml = (MouseAdapter)control.getData( MOUSE_LISTENER_KEY );
 
 if ( ml != null ){
 
  control.removeMouseListener( ml );
 }
}
 
Example 2
Source File: TmfBaseProvider.java    From tracecompass with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * Method to deregister the provider from chart viewer.
 */
protected void deregister() {
    IPlotArea plotArea = getChart().getPlotArea();
    if (plotArea == null) {
        return;
    }
    Control control = plotArea.getControl();
    if (!control.isDisposed()) {
        if (this instanceof MouseListener) {
            control.removeMouseListener((MouseListener) this);
        }
        if (this instanceof MouseMoveListener) {
            control.removeMouseMoveListener((MouseMoveListener) this);
        }
        if (this instanceof MouseWheelListener) {
            control.removeMouseWheelListener((MouseWheelListener) this);
        }
        if (this instanceof MouseTrackListener) {
            control.removeMouseTrackListener((MouseTrackListener) this);
        }
        if (this instanceof ICustomPaintListener) {
            plotArea.removeCustomPaintListener((ICustomPaintListener) this);
        } else if (this instanceof PaintListener) {
            control.removePaintListener((PaintListener) this);
        }

        TmfAbstractToolTipHandler tooltipHandler = getTooltipHandler();
        if(tooltipHandler != null) {
            tooltipHandler.deactivateHoverHelp(control);
        }
    }
}
 
Example 3
Source File: BaseMouseProvider.java    From tracecompass with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * Method to deregister the provider from chart viewer.
 */
protected void deregister() {
    IPlotArea plotArea = getChart().getPlotArea();
    if (plotArea == null) {
        return;
    }
    Control control = plotArea.getControl();
    if (!control.isDisposed()) {
        if (this instanceof MouseListener) {
            control.removeMouseListener((MouseListener) this);
        }
        if (this instanceof MouseMoveListener) {
            control.removeMouseMoveListener((MouseMoveListener) this);
        }
        if (this instanceof MouseWheelListener) {
            control.removeMouseWheelListener((MouseWheelListener) this);
        }
        if (this instanceof MouseTrackListener) {
            control.removeMouseTrackListener((MouseTrackListener) this);
        }
        if (this instanceof ICustomPaintListener) {
            plotArea.removeCustomPaintListener((ICustomPaintListener) this);
        } else if (this instanceof PaintListener) {
            control.removePaintListener((PaintListener) this);
        }
        TmfAbstractToolTipHandler tooltipHandler = getTooltipHandler();
        if(tooltipHandler != null) {
            tooltipHandler.deactivateHoverHelp(control);
        }
    }
}
 
Example 4
Source File: ContentAssistant.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Uninstalls this closer from the viewer's text widget.
 */
protected void uninstall()
{
	Control shell = fShell;
	fShell = null;
	if (Helper.okToUse(shell))
	{
		shell.removeControlListener(this);
	}

	Control control = fControl;
	fControl = null;
	if (Helper.okToUse(control))
	{

		control.removeMouseListener(this);
		control.removeFocusListener(this);

		/*
		 * 1GGYYWK: ITPJUI:ALL - Dismissing editor with code assist up causes lots of Internal Errors
		 */
		control.removeDisposeListener(this);
	}

	if (fViewer != null)
	{
		fViewer.removeViewportListener(this);
	}
}
 
Example 5
Source File: CppStyleConsoleViewer.java    From CppStyle with MIT License 5 votes vote down vote up
@Override
protected void handleDispose() {
	Control control = getTextWidget();

	if (control != null) {
		control.removeMouseListener(this);
	}

	this.getDocument().removeDocumentListener(documentListener);
	super.handleDispose();
}
 
Example 6
Source File: ClipboardCopy.java    From BiglyBT with GNU General Public License v2.0 4 votes vote down vote up
public static void
 addCopyToClipMenu(
final Control				control,
final copyToClipProvider	provider )
 {
  MouseAdapter ml = (MouseAdapter)control.getData( MOUSE_LISTENER_KEY );
  
  if ( ml != null ){
  
	  control.removeMouseListener( ml );
  }
  
  ml =
	  new MouseAdapter()
	  {
		  @Override
		  public void
		  mouseDown(
			 MouseEvent e )
		  {
			  if ( control.isDisposed()){

				  return;
			  }

			  final String	text = provider.getText();

			  if ( control.getMenu() != null || text == null || text.length() == 0 ){

				  return;
			  }

			  if (!(e.button == 3 || (e.button == 1 && e.stateMask == SWT.CONTROL))){

				  return;
			  }

			  final Menu menu = new Menu(control.getShell(),SWT.POP_UP);

			  MenuItem   item = new MenuItem( menu,SWT.NONE );

			  item.setData( MENU_ITEM_KEY, "" );

			  String	msg_text_id;

			  if ( provider instanceof copyToClipProvider2 ){

				  msg_text_id = ((copyToClipProvider2)provider).getMenuResource();

			  }else{

				  msg_text_id = "label.copy.to.clipboard";
			  }

			  item.setText( MessageText.getString( msg_text_id ));

			  item.addSelectionListener(
					  new SelectionAdapter()
					  {
						  @Override
						  public void
						  widgetSelected(
								  SelectionEvent arg0)
						  {
							  new Clipboard(control.getDisplay()).setContents(new Object[] {text}, new Transfer[] {TextTransfer.getInstance()});
						  }
					  });

			  control.setMenu( menu );

			  menu.addMenuListener(
					  new MenuAdapter()
					  {
						  @Override
						  public void
						  menuHidden(
								  MenuEvent arg0 )
						  {
							  if ( control.getMenu() == menu ){

								  control.setMenu( null );
							  }
						  }
					  });

			  menu.setVisible( true );
		  }
	  };
  
  control.setData( MOUSE_LISTENER_KEY, ml );
  
  control.addMouseListener( ml );
 }