Java Code Examples for org.eclipse.jface.action.IAction#AS_DROP_DOWN_MENU

The following examples show how to use org.eclipse.jface.action.IAction#AS_DROP_DOWN_MENU . 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: ShowHistoryAction.java    From n4js with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Create an instance.
 */
public ShowHistoryAction(TestResultsView view) {
	super("Show History", IAction.AS_DROP_DOWN_MENU);
	this.view = view;
	setToolTipText("Show list of recent test sessions.");
	setImageDescriptor(TesterUiActivator.getImageDescriptor(TesterUiActivator.ICON_HISTORY));
	setMenuCreator(new HistoryMenuCreator());
}
 
Example 2
Source File: DocumentationMenuAction.java    From statecharts with Eclipse Public License 1.0 5 votes vote down vote up
public DocumentationMenuAction() {
	super("Toggle Documentation", IAction.AS_DROP_DOWN_MENU);
	setId(ID);
	setMenuCreator(this);
	setImageDescriptor(StatechartImages.MENU.imageDescriptor());
	actions = new ArrayList<Action>();
	createActions();
}
 
Example 3
Source File: ClasspathModifierDropDownAction.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Create a drop down action using the same descriptors as the provided action, but it's on
 * tool tip text. The action will automatically be put in the list of actions that are
 * managed by this drop down menu.
 */
public ClasspathModifierDropDownAction() {
    super(null, null, BuildpathModifierAction.DROP_DOWN_ACTION, IAction.AS_DROP_DOWN_MENU);

    fActions= new ArrayList<BuildpathModifierAction>();
    fFirstValidAction= null;

    setText(""); //$NON-NLS-1$
    setToolTipText(""); //$NON-NLS-1$
}
 
Example 4
Source File: PlayAction.java    From ice with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * <p>
 * The constructor
 * </p>
 * 
 * @param parent
 *            <p>
 *            The PlayableViewPart to whom the object of this class belongs.
 *            </p>
 */
public PlayAction(PlayableViewPart parent) {

	// Call this class' super constructor for a drop-down menu and declare
	// this class as the menu creator
	super(null, IAction.AS_DROP_DOWN_MENU);
	setMenuCreator(this);

	// Store the calling class in the local field
	viewer = parent;

	// Set the text of the "hover" display
	this.setText("Play");

	// Set the button image
	Bundle bundle = FrameworkUtil.getBundle(getClass());
	Path imagePath = new Path(
			"icons" + System.getProperty("file.separator") + "play.gif");
	URL imageURL = FileLocator.find(bundle, imagePath, null);
	ImageDescriptor imageDescriptor = ImageDescriptor
			.createFromURL(imageURL);
	this.setImageDescriptor(imageDescriptor);

	// Create the drop-down selections for 12, 24, and 30 fps and a
	// selection to access the custom frame rate dialog
	FrameRateChangeAction fps12 = new FrameRateChangeAction(12, this,
			"12fps");
	rateActions.add(fps12);
	FrameRateChangeAction fps24 = new FrameRateChangeAction(24, this,
			"24fps");
	rateActions.add(fps24);
	FrameRateChangeAction fps30 = new FrameRateChangeAction(30, this,
			"30fps");
	rateActions.add(fps30);
	FrameRateChangeAction fpsCustom = new FrameRateChangeAction(this,
			"Custom...");
	rateActions.add(fpsCustom);

	return;
}
 
Example 5
Source File: LaborOrderPulldownMenuCreator.java    From elexis-3-core with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Returns action to the pulldown button
 * 
 * @return
 */
public IAction getAction(){
	int buttonStyle = IAction.AS_DROP_DOWN_MENU;
	if (actions.size() == 1) {
		buttonStyle = IAction.AS_PUSH_BUTTON;
	}
	IAction dropDownAction = new Action("Dropdown", buttonStyle) {
		@Override
		public void run(){
			getSelected().run();
		}
	};
	dropDownAction.setMenuCreator(this);
	return dropDownAction;
}
 
Example 6
Source File: SearchConnectorsAction.java    From olca-app with Mozilla Public License 2.0 5 votes vote down vote up
public SearchConnectorsAction(int type) {
	super(type == PROVIDER
			? M.SearchProvidersFor
			: M.SearchRecipientsFor,
			IAction.AS_DROP_DOWN_MENU);
	if (type == PROVIDER)
		setId(ActionIds.SEARCH_PROVIDERS);
	else if (type == RECIPIENTS)
		setId(ActionIds.SEARCH_RECIPIENTS);
	this.type = type;
	setMenuCreator(new MenuCreator());
}
 
Example 7
Source File: SwitchRepositoryMenuCreator.java    From ADT_Frontend with MIT License 4 votes vote down vote up
@Override
public Menu getMenu(Control ctrl) {
	//dispose menu if already created
	if (this.menu != null) {
		this.menu.dispose();
		this.menu = null;
	}
	//create new menu for the control
	this.menu = new Menu(ctrl);
	//Create the first level menu with the available project in the workspace
	//-----------------------------------------------------------------------
	//get the list of accessible projects - existing and open projects
	IProject[] projects = AdtCoreProjectServiceFactory.createCoreProjectService().getAvailableAdtCoreProjects();
	for (IProject project : projects) {
		//we will show the project in the menu only if it is logged on
		if (this.stagingUtil.isLoggedOn(project)) {
			//check if abapgit is supported by the project
			if (!this.stagingUtil.isAbapGitSupported(project)) {
				//do not show projects which does not support abapgit
				continue;
			}
			//create a drop down menu item for the project
			this.menuItem = new Action(project.getName(), IAction.AS_DROP_DOWN_MENU) {
			};
			//add the sub menu creator for the project, which will create the menu
			//with the list of available repositories
			this.menuItem.setMenuCreator(new RespositoryListMenuCreator(project));
			this.item = new ActionContributionItem(this.menuItem);
			this.item.fill(this.menu, -1);
		}
	}
	//if no logged on and supported systems are available, add a dummy menu contribution
	if (this.menu.getItemCount() == 0) {
		this.menuItem = new Action(Messages.AbapGitStaging_switch_repository_no_supported_systems_xmg) {
		};
		//disable the menu
		this.menuItem.setEnabled(false);
		this.item = new ActionContributionItem(this.menuItem);
		this.item.fill(this.menu, -1);
	}
	return this.menu;
}
 
Example 8
Source File: AggregateEditorComposite.java    From birt with Eclipse Public License 1.0 4 votes vote down vote up
public AggregationAction( boolean enabled )
{
	super( "", IAction.AS_DROP_DOWN_MENU ); //$NON-NLS-1$
	setImageDescriptor( ImageDescriptor.createFromURL( UIHelper.getURL( ChartUIConstants.IMAGE_SIGMA ) ) );
	setEnabled( enabled );
}
 
Example 9
Source File: TabbedPropertyTitle.java    From birt with Eclipse Public License 1.0 4 votes vote down vote up
private void handleWidgetSelection( Event e, ToolItem item )
{

	boolean selection = item.getSelection( );

	int style = item.getStyle( );
	IAction action = (IAction) actionMap.get( item );

	if ( ( style & ( SWT.TOGGLE | SWT.CHECK ) ) != 0 )
	{
		if ( action.getStyle( ) == IAction.AS_CHECK_BOX )
		{
			action.setChecked( selection );
		}
	}
	else if ( ( style & SWT.RADIO ) != 0 )
	{
		if ( action.getStyle( ) == IAction.AS_RADIO_BUTTON )
		{
			action.setChecked( selection );
		}
	}
	else if ( ( style & SWT.DROP_DOWN ) != 0 )
	{
		if ( e.detail == 4 )
		{ // on drop-down button
			if ( action.getStyle( ) == IAction.AS_DROP_DOWN_MENU )
			{
				IMenuCreator mc = action.getMenuCreator( );
				ToolItem ti = (ToolItem) item;
				if ( mc != null )
				{
					Menu m = mc.getMenu( ti.getParent( ) );
					if ( m != null )
					{
						Point point = ti.getParent( )
								.toDisplay( new Point( e.x, e.y ) );
						m.setLocation( point.x, point.y ); // waiting
						m.setVisible( true );
						return; // we don't fire the action
					}
				}
			}
		}
	}

	action.runWithEvent( e );
}
 
Example 10
Source File: ActionTree.java    From ice with Eclipse Public License 1.0 4 votes vote down vote up
/**
 * ActionTree constructor for <b>parent</b> tree nodes that will get a menu.
 * These nodes should have child ActionTrees added via the function
 * 
 * @param text
 *            The text displayed by the Action's IContributionItem. This
 *            will be seen on the MenuItem or ToolItem.
 */
public ActionTree(String text) {
	// Set the text.
	this.text = text;

	// Define a new JFace Action that will open a Menu for this node. The
	// Menu will show items for the children of this node.
	action = new Action(this.text, IAction.AS_DROP_DOWN_MENU) {
		@Override
		public void run() {
			// This method only appears to be run when the action
			// corresponds to a ToolItem.
			// TODO Have the menu appear in the correct location below the
			// button.

			// ToolItem toolItem = null;
			// Menu menu = null;
			// TODO How do we get the Action's ToolItem?
			// TODO How do we get the Action's Menu?
			// getMenuCreator().getMenu(Control parent);
			//
			// Rectangle r = toolItem.getBounds();
			// Point p = new Point(r.x, r.y + r.height);
			// p = toolItem.getParent().toDisplay(p.x, p.y);
			// menu.setLocation(p.x, p.y);
			// menu.setVisible(true);
		}
	};
	action.setEnabled(false);

	// Initialize the list of children.
	children = new ArrayList<ActionTree>();

	// Initialize and set the IMenuCreator that will build the menu.
	menuCreator = new MenuCreator();
	action.setMenuCreator(menuCreator);

	// Default to being enabled as soon as possible.
	enabled = true;

	return;
}
 
Example 11
Source File: ChangeBackgroundColorAction.java    From ermasterr with Apache License 2.0 3 votes vote down vote up
public ChangeBackgroundColorAction(final IWorkbenchPart part, final ERDiagram diagram) {
    super(part, IAction.AS_DROP_DOWN_MENU);

    setId(ID);

    setText(ResourceString.getResourceString("action.title.change.background.color"));
    setToolTipText(ResourceString.getResourceString("action.title.change.background.color"));

    final int[] defaultColor = diagram.getDefaultColor();

    rgb = new RGB(defaultColor[0], defaultColor[1], defaultColor[2]);
    setColorToImage();
}