Java Code Examples for org.eclipse.jface.action.Action#setId()

The following examples show how to use org.eclipse.jface.action.Action#setId() . 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: PluginConfigManage.java    From translationstudio8 with GNU General Public License v2.0 6 votes vote down vote up
public void addPluginMenu(final PluginConfigBean bean) {
	for (int i = 0; i < parentManager.getItems().length; i++) {
		if ("net.heartsome.cat.ts.ui.menu.plugin".equals(parentManager.getItems()[i].getId())) {
			MenuManager pluginMenu = (MenuManager) parentManager.getItems()[i];
			// 开始添加新的菜单
			Action action = new Action() {
				@Override
				public void run() {
					executePlugin(bean);
				}
			};
			action.setText(bean.getName());
			action.setId(bean.getId());
			if (!"".equals(bean.getShortcutKey())) {
				action.setText(bean.getName() + "\t" + bean.getShortcutKey());
			}

			pluginMenu.add(action);
			pluginMenu.update();
		}
	}
}
 
Example 2
Source File: AbstractSliceSystem.java    From dawnsci with Eclipse Public License 1.0 6 votes vote down vote up
private IAction createSliceToolAction(IConfigurationElement e, final ISlicingTool slicingTool) {
	
	String toolTip = e.getAttribute("tooltip");
	if (toolTip==null) toolTip = slicingTool.getToolId();

	final Action action = new Action(toolTip, IAction.AS_CHECK_BOX) {
       	public void run() {
       		militarize(slicingTool);
       	}
       };
       
   	final String   icon  = e.getAttribute("icon");
   	if (icon!=null) {
    	final String   id    = e.getContributor().getName();
    	final Bundle   bundle= Platform.getBundle(id);
    	final URL      entry = bundle.getEntry(icon);
    	final ImageDescriptor des = ImageDescriptor.createFromURL(entry);
    	action.setImageDescriptor(des);
   	}

	action.setId(slicingTool.getToolId());	
    return action;	
}
 
Example 3
Source File: PluginConfigManage.java    From tmxeditor8 with GNU General Public License v2.0 6 votes vote down vote up
public void addPluginMenu(final PluginConfigBean bean) {
	for (int i = 0; i < parentManager.getItems().length; i++) {
		if ("net.heartsome.cat.ts.ui.menu.plugin".equals(parentManager.getItems()[i].getId())) {
			MenuManager pluginMenu = (MenuManager) parentManager.getItems()[i];
			// 开始添加新的菜单
			Action action = new Action() {
				@Override
				public void run() {
					executePlugin(bean);
				}
			};
			action.setText(bean.getName());
			action.setId(bean.getId());
			if (!"".equals(bean.getShortcutKey())) {
				action.setText(bean.getName() + "\t" + bean.getShortcutKey());
			}

			pluginMenu.add(action);
			pluginMenu.update();
		}
	}
}
 
Example 4
Source File: GamaCommand.java    From gama with GNU General Public License v3.0 5 votes vote down vote up
public Action toAction() {
	final Action result = new Action(text) {

		@Override
		public void runWithEvent(final Event e) {
			selector.widgetSelected(new SelectionEvent(e));
		}
	};

	result.setImageDescriptor(GamaIcons.create(image).descriptor());
	result.setToolTipText(tooltip);
	result.setId(image);
	return result;

}
 
Example 5
Source File: GamaCommand.java    From gama with GNU General Public License v3.0 5 votes vote down vote up
public Action toCheckAction() {
	final Action result = new Action(text, Action.AS_CHECK_BOX) {

		@Override
		public void runWithEvent(final Event e) {
			selector.widgetSelected(new SelectionEvent(e));
		}
	};

	result.setImageDescriptor(GamaIcons.create(image).descriptor());
	result.setToolTipText(tooltip);
	result.setId(image);
	return result;

}
 
Example 6
Source File: AbstractSearchIndexResultPage.java    From Pydev with Eclipse Public License 1.0 5 votes vote down vote up
@Override
protected void fillToolbar(IToolBarManager tbm) {
    super.fillToolbar(tbm);
    for (Action a : fGroupByActions) {
        String id = IContextMenuConstants.GROUP_PROPERTIES + "." + a.hashCode();
        a.setId(id);
        tbm.add(a);
    }
}