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

The following examples show how to use org.eclipse.jface.action.Action#setEnabled() . 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: SvnPropertiesView.java    From APICloud-Studio with GNU General Public License v3.0 6 votes vote down vote up
/**
 * fill the popup menu for the table
 */
private void fillTableMenu(IMenuManager manager) {
	manager.add(getRefreshAction());

	Action action = getAddPropertyAction();
	try { 		
		if (resource != null)
			action.setEnabled(resource.isManaged());
		else
			action.setEnabled(false);
	} catch (SVNException e) {
		action.setEnabled(false);
	}
	manager.add(action);

	manager.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));
}
 
Example 2
Source File: AbstractInformationControl.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
@Override
protected Control createTitleMenuArea(Composite parent) {
	fViewMenuButtonComposite= (Composite) super.createTitleMenuArea(parent);

	// If there is a header, then the filter text must be created
	// underneath the title and menu area.

	if (hasHeader()) {
		fFilterText= createFilterText(parent);
	}

	// Create show view menu action
	fShowViewMenuAction= new Action("showViewMenu") { //$NON-NLS-1$
		/*
		 * @see org.eclipse.jface.action.Action#run()
		 */
		@Override
		public void run() {
			showDialogMenu();
		}
	};
	fShowViewMenuAction.setEnabled(true);
	fShowViewMenuAction.setActionDefinitionId(IWorkbenchCommandConstants.WINDOW_SHOW_VIEW_MENU);

	return fViewMenuButtonComposite;
}
 
Example 3
Source File: VoiceXMLBrowserInputView.java    From JVoiceXML with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * Updates the drop down menu on the Input View.
 * 
 */
private void updateViewMenu() {
    terminateAction.setEnabled(activeBrowser != null);
    getViewSite().getActionBars().updateActionBars();

    IMenuManager imm = getViewSite().getActionBars().getMenuManager();
    imm.removeAll();

    if (activeBrowsers.size() == 0) {
        Action nothing = new Action("No browsers available.") {
            public void run() {
            }
        };
        nothing.setEnabled(true);
        imm.add(nothing);
    }

    for (int i = 0; i < activeBrowsers.size(); i++) {
        final VoiceXMLBrowserProcess p = activeBrowsers.get(i);
        Action a = new Action(p.getLabel()) {
            public void run() {
                if (activeBrowser == p) {
                    return;
                }
                activeBrowser = p;
                resetView();
                updateUI();
            }
        };
        a.setChecked(p == activeBrowser);
        imm.add(a);
    }
    getViewSite().getActionBars().updateActionBars();
}
 
Example 4
Source File: ReminderView.java    From elexis-3-core with Eclipse Public License 1.0 5 votes vote down vote up
private List<IContributionItem> createActionList(){
	Action labelFilter = new Action("Anzeige filtern") {};
	labelFilter.setEnabled(false);
	
	MenuManager timeFilterSubMenu = new MenuManager("Zeitraum Anzeige");
	FilterTimeAction action30 = new FilterTimeAction(30);
	FilterTimeAction action60 = new FilterTimeAction(60);
	FilterTimeAction action90 = new FilterTimeAction(90);
	action30.setOthers(Arrays.asList(action60, action90));
	action60.setOthers(Arrays.asList(action30, action90));
	action90.setOthers(Arrays.asList(action30, action60));
	timeFilterSubMenu.add(action30);
	timeFilterSubMenu.add(action60);
	timeFilterSubMenu.add(action90);
	
	Action labelResponsibility = new Action("Anzeige erweitern") {};
	labelResponsibility.setEnabled(false);
	
	Action labelSorter = new Action("Anzeige sortieren") {};
	labelSorter.setEnabled(false);
	
	MenuManager typeFilterSubMenu = new MenuManager("Nach Aktionstyp");
	List<IContributionItem> ca =
		ViewMenus.convertActionsToContributionItems((filterActionType));
	for (IContributionItem iContributionItem : ca) {
		typeFilterSubMenu.add(iContributionItem);
	}
	return Arrays.asList(new ActionContributionItem(newReminderAction), null,
		new ActionContributionItem(labelSorter), new ActionContributionItem(sortByDueDate),
		null, new ActionContributionItem(labelFilter), timeFilterSubMenu,
		new ActionContributionItem(showOnlyOwnDueReminderToggleAction), typeFilterSubMenu, null,
		new ActionContributionItem(labelResponsibility),
		new ActionContributionItem(showSelfCreatedReminderAction),
		new ActionContributionItem(showOthersRemindersAction), null);
}
 
Example 5
Source File: FlameChartView.java    From tracecompass with Eclipse Public License 2.0 4 votes vote down vote up
private Action getConfigureSymbolsAction() {
    if (fConfigureSymbolsAction != null) {
        return fConfigureSymbolsAction;
    }

    Action configureSymbolsAction = new Action(Messages.CallStackView_ConfigureSymbolProvidersText) {
        @Override
        public void run() {
            SymbolProviderConfigDialog dialog = new SymbolProviderConfigDialog(getSite().getShell(), getProviderPages());
            if (dialog.open() == IDialogConstants.OK_ID) {
                List<TimeGraphEntry> traceEntries = getEntryList(getTrace());
                if (traceEntries != null) {
                    for (TraceEntry traceEntry : Iterables.filter(traceEntries, TraceEntry.class)) {
                        ITimeGraphDataProvider<? extends TimeGraphEntryModel> provider = traceEntry.getProvider();
                        if (provider instanceof CallStackDataProvider) {
                            ((CallStackDataProvider) provider).resetFunctionNames(new NullProgressMonitor());
                        }

                        // reset full and zoomed events here
                        Iterable<TimeGraphEntry> flatten = Utils.flatten(traceEntry);
                        flatten.forEach(e -> e.setSampling(null));

                        // recompute full events
                        long start = traceEntry.getStartTime();
                        long end = traceEntry.getEndTime();
                        final long resolution = Long.max(1, (end - start) / getDisplayWidth());
                        zoomEntries(flatten, start, end, resolution, new NullProgressMonitor());
                    }
                    // zoomed events will be retriggered by refreshing
                    refresh();
                }
                synchingToTime(getTimeGraphViewer().getSelectionBegin());
            }
        }
    };

    configureSymbolsAction.setToolTipText(Messages.CallStackView_ConfigureSymbolProvidersTooltip);
    configureSymbolsAction.setImageDescriptor(Objects.requireNonNull(Activator.getDefault()).getImageDescripterFromPath(IMPORT_BINARY_ICON_PATH));

    /*
     * The updateConfigureSymbolsAction() method (called by refresh()) will set the
     * action to true if applicable after the symbol provider has been properly
     * loaded.
     */
    configureSymbolsAction.setEnabled(false);

    fConfigureSymbolsAction = configureSymbolsAction;
    return configureSymbolsAction;
}
 
Example 6
Source File: TerminologyViewPart.java    From translationstudio8 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * 创建视图工具栏的按钮。
 */
private void createAction() {
	firstAction = new Action() {
		@Override
		public void run() {
			if (rowIndex < 0) {
				return;
			}
			if (tempEditor == null || rowIndex < 0) {
				return;
			}
			TransUnitBean transUnit = tempEditor.getRowTransUnitBean(rowIndex);
			Hashtable<String, String> tuProp = transUnit.getTuProps();
			if (tuProp != null) {
				String translate = tuProp.get("translate");
				if (translate != null && translate.equalsIgnoreCase("no")) {
					MessageDialog.openInformation(getSite().getShell(),
							Messages.getString("view.TerminologyViewPart.msgTitle"),
							Messages.getString("view.TerminologyViewPart.msg1"));
					return;
				}
			}

			String tarTerm = "";
			GridItem[] items = gridTable.getSelection();
			if (items.length <= 0) {
				return;
			} else {
				tarTerm = items[0].getText(2);
			}

			try {
				tempEditor.insertCell(rowIndex, tempEditor.getTgtColumnIndex(), tarTerm);
				// tempEditor.setFocus(); // 焦点给回编辑器
			} catch (ExecutionException e) {
				if (Constant.RUNNING_MODE == Constant.MODE_DEBUG) {
					e.printStackTrace();
				}
				MessageDialog.openInformation(parent.getShell(),
						Messages.getString("view.TerminologyViewPart.msgTitle"),
						Messages.getString("view.TerminologyViewPart.msg2") + e.getMessage());
			}
		}
	};
	firstAction.setText(Messages.getString("view.TerminologyViewPart.menu.inserttermtarget"));
	firstAction.setImageDescriptor(Activator.getIconDescriptor(ImageConstants.ACCPTE_TERM));
	firstAction.setToolTipText(Messages.getString("view.TerminologyViewPart.firstAction"));
	firstAction.setEnabled(false);
	//getViewSite().getActionBars().getToolBarManager().add(firstAction);
}
 
Example 7
Source File: TerminologyViewPart.java    From tmxeditor8 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * 创建视图工具栏的按钮。
 */
private void createAction() {
	firstAction = new Action() {
		@Override
		public void run() {
			if (rowIndex < 0) {
				return;
			}
			if (tempEditor == null || rowIndex < 0) {
				return;
			}
			TransUnitBean transUnit = tempEditor.getRowTransUnitBean(rowIndex);
			Hashtable<String, String> tuProp = transUnit.getTuProps();
			if (tuProp != null) {
				String translate = tuProp.get("translate");
				if (translate != null && translate.equalsIgnoreCase("no")) {
					MessageDialog.openInformation(getSite().getShell(),
							Messages.getString("view.TerminologyViewPart.msgTitle"),
							Messages.getString("view.TerminologyViewPart.msg1"));
					return;
				}
			}

			String tarTerm = "";
			GridItem[] items = gridTable.getSelection();
			if (items.length <= 0) {
				return;
			} else {
				tarTerm = items[0].getText(2);
			}

			try {
				tempEditor.insertCell(rowIndex, tempEditor.getTgtColumnIndex(), tarTerm);
				// tempEditor.setFocus(); // 焦点给回编辑器
			} catch (ExecutionException e) {
				if (Constant.RUNNING_MODE == Constant.MODE_DEBUG) {
					e.printStackTrace();
				}
				MessageDialog.openInformation(parent.getShell(),
						Messages.getString("view.TerminologyViewPart.msgTitle"),
						Messages.getString("view.TerminologyViewPart.msg2") + e.getMessage());
			}
		}
	};
	firstAction.setImageDescriptor(Activator.getIconDescriptor(ImageConstants.ACCPTE_TERM));
	firstAction.setToolTipText(Messages.getString("view.TerminologyViewPart.firstAction"));
	firstAction.setEnabled(false);
	getViewSite().getActionBars().getToolBarManager().add(firstAction);
}
 
Example 8
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;
}