org.eclipse.swt.events.MenuDetectEvent Java Examples

The following examples show how to use org.eclipse.swt.events.MenuDetectEvent. 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: AssistField.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Initialize quick fix menu for content assist.
 */
protected void initQuickFixMenu( )
{
	if ( hasQuickFix( ) )
	{
		controlDecoration.addMenuDetectListener( new MenuDetectListener( ) {

			public void menuDetected( MenuDetectEvent event )
			{
				// no quick fix if we aren't in error state.
				if ( isValid( ) )
				{
					return;
				}
				if ( quickFixMenu == null )
				{
					quickFixMenu = FieldAssistHelper.getInstance( )
							.createQuickFixMenu( AssistField.this );
				}
				quickFixMenu.setLocation( event.x, event.y );
				quickFixMenu.setVisible( true );
			}
		} );
	}
}
 
Example #2
Source File: ImportWizardPageColumns.java    From arx with Apache License 2.0 6 votes vote down vote up
/**
 * Creates a new editor for the given {@link TableViewer}.
 * 
 * @param viewer The TableViewer this editor is implemented for
 * @param columns The columns
 */
public DatatypeContextMenu(final TableViewer viewer, List<ImportWizardModelColumn> columns) {

    this.update(columns);
    this.viewer = viewer;
    viewer.getTable().addMenuDetectListener(new MenuDetectListener() {
        @Override
        public void menuDetected(MenuDetectEvent e) {
            // Check selection
           int index = table.getSelectionIndex();
           if (index == -1) {
             return; 
           }
           
           // Create and show context menu
           getMenu(viewer, (ImportWizardModelColumn) table.getItem(index).getData()).setVisible(true);      
        }
    });
}
 
Example #3
Source File: BreadcrumbViewer.java    From gwt-eclipse-plugin with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * A context menu has been requested for the selected breadcrumb item.
 * 
 * @param event the event issued the menu detection
 */
void fireMenuDetect(MenuDetectEvent event) {
  Object[] listeners = fMenuListeners.getListeners();
  for (int i = 0; i < listeners.length; i++) {
    ((MenuDetectListener) listeners[i]).menuDetected(event);
  }
}
 
Example #4
Source File: SWTLayeredDisplayMultiListener.java    From gama with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void menuDetected(final MenuDetectEvent e) {
	if (!ok.get()) { return; }
	// DEBUG.LOG("Menu detected on " + view.getPartName());
	final Point p = control.toControl(e.x, e.y);
	delegate.menuDetected(p.x, p.y);
}
 
Example #5
Source File: BreadcrumbViewer.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * A context menu has been requested for the selected breadcrumb item.
 *
 * @param event the event issued the menu detection
 */
void fireMenuDetect(MenuDetectEvent event) {
	Object[] listeners= fMenuListeners.getListeners();
	for (int i= 0; i < listeners.length; i++) {
		((MenuDetectListener)listeners[i]).menuDetected(event);
	}
}
 
Example #6
Source File: BreadcrumbViewer.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * A context menu has been requested for the selected breadcrumb item.
 * 
 * @param event
 *            the event issued the menu detection
 */
void fireMenuDetect( MenuDetectEvent event )
{
	Object[] listeners = fMenuListeners.getListeners( );
	for ( int i = 0; i < listeners.length; i++ )
	{
		( (MenuDetectListener) listeners[i] ).menuDetected( event );
	}
}
 
Example #7
Source File: TimeGraphControl.java    From tracecompass with Eclipse Public License 2.0 4 votes vote down vote up
@Override
public void menuDetected(MenuDetectEvent e) {
    if (null == fTimeProvider) {
        return;
    }
    /*
     * This flag indicates if menu was prevented from being shown below and
     * therefore must be made visible on callback from mouseUp().
     */
    boolean pendingEventCallback = fPendingMenuDetectEvent != null;
    Point p = toControl(e.x, e.y);
    if (e.detail == SWT.MENU_MOUSE && isOverTimeSpace(p.x, p.y)) {
        if (fPendingMenuDetectEvent == null) {
            /*
             * Feature in Linux. The MenuDetectEvent is received before mouseDown. Store the
             * event and trigger it later just before handling mouseUp. This allows for the
             * method to detect if mouse is used to drag zoom.
             */
            fPendingMenuDetectEvent = e;
            /*
             * Prevent the platform to show the menu when returning. The menu will be shown
             * (see below) when this method is called again during mouseUp().
             */
            e.doit = false;
            return;
        }
        fPendingMenuDetectEvent = null;
        if (fDragState != DRAG_ZOOM || !isInDragZoomMargin()) {
            /*
             * Don't show the menu on mouseUp() if a drag zoom is in progress with a drag
             * range outside of the drag zoom margin, or if any other drag operation, or
             * none, is in progress.
             */
            e.doit = false;
            return;
        }
    } else {
        if (fDragState != DRAG_NONE) {
            /*
             * Don't show the menu on keyboard menu or mouse menu outside of the time space
             * if any drag operation is in progress.
             */
            e.doit = false;
            return;
        }
    }
    int idx = getItemIndexAtY(p.y);
    if (idx >= 0 && idx < fItemData.fExpandedItems.length) {
        Item item = fItemData.fExpandedItems[idx];
        ITimeGraphEntry entry = item.fEntry;

        /* Send menu event for the time graph entry */
        e.doit = true;
        e.data = entry;
        fireMenuEventOnTimeGraphEntry(e);
        Menu menu = getMenu();
        if (pendingEventCallback && e.doit && (menu != null)) {
            menu.setVisible(true);
        }

        /* Send menu event for time event */
        if (entry.hasTimeEvents()) {
            ITimeEvent event = Utils.findEvent(entry, getTimeAtX(p.x), 2);
            if (event != null) {
                e.doit = true;
                e.data = event;
                fireMenuEventOnTimeEvent(e);
                menu = getMenu();
                if (pendingEventCallback && e.doit && (menu != null)) {
                    menu.setVisible(true);
                }
            }
        }
    }
}
 
Example #8
Source File: TimeGraphControl.java    From tracecompass with Eclipse Public License 2.0 2 votes vote down vote up
/**
 * Menu event callback on {@link ITimeGraphEntry}s
 *
 * @param event
 *            The MenuDetectEvent, with field {@link TypedEvent#data} set to the
 *            selected {@link ITimeGraphEntry}
 */
private void fireMenuEventOnTimeGraphEntry(MenuDetectEvent event) {
    for (MenuDetectListener listener : fTimeGraphEntryMenuListeners) {
        listener.menuDetected(event);
    }
}
 
Example #9
Source File: TimeGraphControl.java    From tracecompass with Eclipse Public License 2.0 2 votes vote down vote up
/**
 * Menu event callback on {@link ITimeEvent}s
 *
 * @param event
 *            The MenuDetectEvent, with field {@link TypedEvent#data} set to the
 *            selected {@link ITimeEvent}
 */
private void fireMenuEventOnTimeEvent(MenuDetectEvent event) {
    for (MenuDetectListener listener : fTimeEventMenuListeners) {
        listener.menuDetected(event);
    }
}