org.eclipse.swt.events.MouseTrackAdapter Java Examples

The following examples show how to use org.eclipse.swt.events.MouseTrackAdapter. 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: LabelEditManager.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Creates the cell editor on the given composite. The cell editor is
 * created by instantiating the cell editor type passed into this
 * DirectEditManager's constuctor.
 * 
 * @param composite
 *            the composite to create the cell editor on
 * @return the newly created cell editor
 */
protected CellEditor createCellEditorOn( Composite composite )
{
	int style = this.applyBidiStyle( SWT.MULTI | SWT.WRAP ); // bidi_hcg

	LabelCellEditor editor = new LabelCellEditor( composite, style );
		//new LabelCellEditor( composite, SWT.MULTI | SWT.WRAP );
	final Control c = editor.getControl( );
	c.addMouseTrackListener( new MouseTrackAdapter( )
	{

		public void mouseEnter( MouseEvent e )
		{
			c.setCursor( SharedCursors.IBEAM );
		}

	} );
	return editor;
}
 
Example #2
Source File: TmfAbstractToolTipHandler.java    From tracecompass with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * Callback for the mouse-over tooltip to deactivate hoverhelp
 *
 * @param control
 *            The control object to use
 * @since 5.0
 */
public void deactivateHoverHelp(final Control control) {
    MouseTrackAdapter adapter = fMouseTrackAdapter;
    if (adapter != null) {
        control.removeMouseTrackListener(adapter);
        fMouseTrackAdapter = null;
    }
}
 
Example #3
Source File: CodeSmellPackageExplorer.java    From JDeodorant with MIT License 5 votes vote down vote up
private void hookTooltips(PackageMapDiagram diagram) {
	// Create an information provider for our table viewer
	IInformationProvider informationProvider = new PackageMapDiagramInformationProvider(diagram);
	List<ICustomInformationControlCreator> informationControlCreators = new ArrayList<ICustomInformationControlCreator>();
	if(CODE_SMELL_TYPE != null) {
		if(CODE_SMELL_TYPE.equals(CodeSmellType.FEATURE_ENVY))
			informationControlCreators.add(new FeatureEnviedMethodInformationControlCreator());
		else if(CODE_SMELL_TYPE.equals(CodeSmellType.GOD_CLASS))
			informationControlCreators.add(new GodClassInformationControlCreator());
	}
	Control control =figureCanvas;
	final InformationControlManager informationControlManager = new InformationControlManager(informationProvider, informationControlCreators, false);
	informationControlManager.install(control);

	// MouseListener to show the information when the user hovers a table item
	control.addMouseTrackListener(new MouseTrackAdapter() {
		@Override
		public void mouseHover(MouseEvent event) {
			informationControlManager.showInformation();
		}
	});

	// DisposeListener to uninstall the information control manager

	DisposeListener listener = new DisposeListener(){
		public void widgetDisposed(DisposeEvent e) {
			informationControlManager.dispose();
		}
	};
	control.addDisposeListener(listener);
	// Install tooltips
	//Tooltips.install(diagram.getControl(), informationProvider, informationControlCreators, false);
}
 
Example #4
Source File: ProjectFileDialog.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Add Tooltip for root TreeItem.
 */
protected void addToolTip( )
{
	final Tree tree = getTreeViewer( ).getTree( );
	tree.addMouseTrackListener( new MouseTrackAdapter( ) {

		public void mouseHover( MouseEvent event )
		{
			Widget widget = event.widget;
			if ( widget == tree )
			{
				Point pt = new Point( event.x, event.y );
				TreeItem item = tree.getItem( pt );

				if ( item == null )
				{
					tree.setToolTipText( null );
				}
				else
				{
					if ( getTreeViewer( ).getLabelProvider( ) instanceof FileLabelProvider )
					{
						tree.setToolTipText( ( (FileLabelProvider) getTreeViewer( ).getLabelProvider( ) ).getToolTip( item.getData( ) ) );
					}
					else
					{
						tree.setToolTipText( null );
					}
				}
			}
		}
	} );
	refreshRoot( );
}
 
Example #5
Source File: ResourceFileFolderSelectionDialog.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Add Tooltip for root TreeItem.
 */
protected void addToolTip( )
{
	final Tree tree = getTreeViewer( ).getTree( );
	tree.addMouseTrackListener( new MouseTrackAdapter( ) {

		public void mouseHover( MouseEvent event )
		{
			Widget widget = event.widget;
			if ( widget == tree )
			{
				Point pt = new Point( event.x, event.y );
				TreeItem item = tree.getItem( pt );

				if ( item == null )
				{
					tree.setToolTipText( null );
				}
				else
				{
					if ( getTreeViewer( ).getLabelProvider( ) instanceof ResourceFileLabelProvider )
					{
						tree.setToolTipText( ( (ResourceFileLabelProvider) getTreeViewer( ).getLabelProvider( ) ).getToolTip( item.getData( ) ) );
					}
					else
					{
						tree.setToolTipText( null );
					}
				}
			}
		}
	} );
	refreshRoot( );
}
 
Example #6
Source File: AnnotationExpansionControl.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 4 votes vote down vote up
/**
	 * Creates a new control.
	 *
	 * @param parent parent shell
	 * @param shellStyle additional style flags
	 * @param access the annotation access
	 */
	public AnnotationExpansionControl(Shell parent, int shellStyle, IAnnotationAccess access) {
		fPaintListener= new MyPaintListener();
		fMouseTrackListener= new MyMouseTrackListener();
		fMouseListener= new MyMouseListener();
		fMenuDetectListener= new MyMenuDetectListener();
		fDisposeListener= new MyDisposeListener();
		fViewportListener= new IViewportListener() {

			public void viewportChanged(int verticalOffset) {
				dispose();
			}

		};
		fLayouter= new LinearLayouter();

		if (access instanceof IAnnotationAccessExtension)
			fAnnotationAccessExtension= (IAnnotationAccessExtension) access;

		fShell= new Shell(parent, shellStyle | SWT.NO_FOCUS | SWT.ON_TOP);
		Display display= fShell.getDisplay();
		fShell.setBackground(display.getSystemColor(SWT.COLOR_BLACK));
		fComposite= new Composite(fShell, SWT.NO_FOCUS | SWT.NO_REDRAW_RESIZE | SWT.NO_TRIM);
//		fComposite= new Composite(fShell, SWT.NO_FOCUS | SWT.NO_REDRAW_RESIZE | SWT.NO_TRIM | SWT.V_SCROLL);

		GridLayout layout= new GridLayout(1, true);
		layout.marginHeight= 0;
		layout.marginWidth= 0;
		fShell.setLayout(layout);

		GridData data= new GridData(GridData.FILL_BOTH);
		data.heightHint= fLayouter.getAnnotationSize() + 2 * fLayouter.getBorderWidth() + 4;
		fComposite.setLayoutData(data);
		fComposite.addMouseTrackListener(new MouseTrackAdapter() {

			@Override
			public void mouseExit(MouseEvent e) {
				if (fComposite == null)
						return;
				Control[] children= fComposite.getChildren();
				Rectangle bounds= null;
				for (int i= 0; i < children.length; i++) {
					if (bounds == null)
						bounds= children[i].getBounds();
					else
						bounds.add(children[i].getBounds());
					if (bounds.contains(e.x, e.y))
						return;
				}

				// if none of the children contains the event, we leave the popup
				dispose();
			}

		});

//		fComposite.getVerticalBar().addListener(SWT.Selection, new Listener() {
//
//			public void handleEvent(Event event) {
//				Rectangle bounds= fShell.getBounds();
//				int x= bounds.x - fLayouter.getAnnotationSize() - fLayouter.getBorderWidth();
//				int y= bounds.y;
//				fShell.setBounds(x, y, bounds.width, bounds.height);
//			}
//
//		});

		Cursor handCursor= getHandCursor(display);
		fShell.setCursor(handCursor);
		fComposite.setCursor(handCursor);

		setInfoSystemColor();
	}
 
Example #7
Source File: LibraryExplorerTreeViewPage.java    From birt with Eclipse Public License 1.0 4 votes vote down vote up
/**
 * Initializes the data view page.
 */
protected void initPage( )
{
	createContextMenus( );

	// !remove sorter to keep same order with outline view
	// treeViewer.setSorter( new ViewerSorter( ) {
	//
	// public int category( Object element )
	// {
	// if ( element instanceof LibraryHandle )
	// {
	// return 1;
	// }
	// return super.category( element );
	// }
	//
	// } );

	final Tree tree = getTreeViewer( ).getTree( );

	tree.addMouseTrackListener( new MouseTrackAdapter( ) {

		public void mouseHover( MouseEvent event )
		{
			Widget widget = event.widget;
			if ( widget == tree )
			{
				Point pt = new Point( event.x, event.y );
				TreeItem item = tree.getItem( pt );

				try
				{
					tree.setToolTipText( getTooltip( item ) );
				}
				catch ( IOException e )
				{
					// Does nothing
				}
			}
		}
	} );
}
 
Example #8
Source File: ExpressionBuilder.java    From birt with Eclipse Public License 1.0 4 votes vote down vote up
private void initTable( TableViewer tableViewer, boolean leafOnly )
{
	final Table table = tableViewer.getTable( );

	GridData gd = new GridData( GridData.FILL_BOTH );
	gd.heightHint = 150;
	table.setLayoutData( gd );
	table.setToolTipText( null );

	final TableColumn column = new TableColumn( table, SWT.NONE );
	column.setWidth( 200 );
	table.getShell( ).addControlListener( new ControlAdapter( ) {

		public void controlResized( ControlEvent e )
		{
			Display.getCurrent( ).asyncExec( new Runnable( ) {

				public void run( )
				{
					if ( column != null && !column.isDisposed( ) )
					{
						column.setWidth( table.getSize( ).x > 204 ? table.getSize( ).x - 4
								: 200 );
					}
				}
			} );

		}

	} );

	table.addMouseTrackListener( new MouseTrackAdapter( ) {

		public void mouseHover( MouseEvent event )
		{
			Widget widget = event.widget;
			if ( widget == table )
			{
				Point pt = new Point( event.x, event.y );
				TableItem item = table.getItem( pt );
				if ( item == null )
				{

					table.setToolTipText( null );
				}
				else
				{
					table.setToolTipText( provider.getTooltipText( item.getData( ) ) );
				}
			}
		}
	} );

	tableViewer.setLabelProvider( new ExpressionLabelProvider( ) );
	tableViewer.setContentProvider( new TableContentProvider( tableViewer, leafOnly ) );
	tableViewer.addSelectionChangedListener( selectionListener );
	tableViewer.addDoubleClickListener( doubleClickListener );
}
 
Example #9
Source File: ReadOnlyStyledText.java    From nebula with Eclipse Public License 2.0 3 votes vote down vote up
/**
 * Constructs a new instance of this class given its parent and a style
 * value describing its behavior and appearance.
 * <p>
 * The style value is either one of the style constants defined in class
 * <code>SWT</code> which is applicable to instances of this class, or must
 * be built by <em>bitwise OR</em>'ing together (that is, using the
 * <code>int</code> "|" operator) two or more of those <code>SWT</code>
 * style constants. The class description lists the style constants that are
 * applicable to the class. Style bits are also inherited from superclasses.
 * </p>
 *
 * @param parent a widget which will be the parent of the new instance
 *            (cannot be null)
 * @param style the style of widget to construct
 *
 * @exception IllegalArgumentException
 *                <ul>
 *                <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
 *                </ul>
 * @exception SWTException
 *                <ul>
 *                <li>ERROR_THREAD_INVALID_ACCESS - if not called from the
 *                thread that created the parent</li>
 *                </ul>
 *
 * @see SWT#FULL_SELECTION
 * @see SWT#MULTI
 * @see SWT#SINGLE
 * @see #getStyle
 * @see StyledText
 */
public ReadOnlyStyledText(final Composite parent, final int style) {
	super(parent, style | SWT.WRAP | SWT.READ_ONLY);
	addMouseTrackListener(new MouseTrackAdapter() {
		@Override
		public void mouseEnter(final MouseEvent e) {
			setCursor(getDisplay().getSystemCursor(SWT.CURSOR_ARROW));
		}
	});
	setCaret(null);
	addListener(SWT.Selection, e -> {
		setSelection(0, 0);
	});
}