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

The following examples show how to use org.eclipse.jface.action.Action#setChecked() . 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: ModulaQuickOutlineDialog.java    From xds-ide with Eclipse Public License 1.0 6 votes vote down vote up
@Override
protected void fillDialogMenu(IMenuManager dialogMenu) {
    Action actSortAlph = new Action (Messages.XdsQuickOutlineDialog_SortAlphabetically, IAction.AS_CHECK_BOX) {
        public void run() {
            reSort(this.isChecked());
        }
    }; 
    
    actSortAlph.setImageDescriptor(ImageDescriptor.createFromImage(ImageUtils.getImage(ImageUtils.SORT_ALPHA)));
    actSortAlph.setChecked(sortAlph);
    dialogMenu.add(actSortAlph);
    
    Action actFilters = new Action (Messages.XdsQuickOutlineDialog_Filters, IAction.AS_PUSH_BUTTON) {
        public void run() {
            filtersDialog();
        }
    }; 
    actFilters.setImageDescriptor(ImageDescriptor.createFromImage(ImageUtils.getImage(ImageUtils.FILTERS_ICON)));
    dialogMenu.add(actFilters);
    
    dialogMenu.add(new Separator("XdsMenuEnd")); //$NON-NLS-1$
    super.fillDialogMenu(dialogMenu);
}
 
Example 2
Source File: MemoryUsageView2.java    From tracecompass with Eclipse Public License 2.0 6 votes vote down vote up
private Action getFilterAction() {
    Action action = new Action(Messages.MemoryView_FilterAction_Text, IAction.AS_CHECK_BOX) {
        // memory view is filtered by default.
        private boolean isFiltered = true;

        @Override
        public void run() {
            isFiltered ^= true;
            setToolTipText(isFiltered ? Messages.MemoryView_FilterAction_FilteredTooltipText : Messages.MemoryView_FilterAction_UnfilteredTooltipText);
            TmfViewer tree = getLeftChildViewer();
            if (tree instanceof MemoryUsageTreeViewer2) {
                MemoryUsageTreeViewer2 memoryUsageTreeViewer = (MemoryUsageTreeViewer2) tree;
                memoryUsageTreeViewer.setFiltered(isFiltered);
            }
        }
    };
    action.setToolTipText(Messages.MemoryView_FilterAction_FilteredTooltipText);
    action.setImageDescriptor(AbstractUIPlugin.imageDescriptorFromPlugin("org.eclipse.tracecompass.tmf.ui", "icons/elcl16/filter_items.gif")); //$NON-NLS-1$ //$NON-NLS-2$
    // filtered by default, to not change the default behavior
    action.setChecked(true);
    return action;
}
 
Example 3
Source File: MemoryUsageView.java    From tracecompass with Eclipse Public License 2.0 6 votes vote down vote up
private Action getFilterAction() {
    Action action = new Action(Messages.MemoryView_FilterAction_Text, IAction.AS_CHECK_BOX) {
        // memory view is filtered by default.
        private boolean isFiltered = true;

        @Override
        public void run() {
            isFiltered ^= true;
            setToolTipText(isFiltered ? Messages.MemoryView_FilterAction_FilteredTooltipText : Messages.MemoryView_FilterAction_UnfilteredTooltipText);
            TmfViewer tree = getLeftChildViewer();
            if (tree instanceof MemoryUsageTreeViewer) {
                MemoryUsageTreeViewer memoryUsageTreeViewer = (MemoryUsageTreeViewer) tree;
                memoryUsageTreeViewer.setFiltered(isFiltered);
            }
        }
    };
    action.setToolTipText(Messages.MemoryView_FilterAction_FilteredTooltipText);
    action.setImageDescriptor(AbstractUIPlugin.imageDescriptorFromPlugin("org.eclipse.tracecompass.tmf.ui", "icons/elcl16/filter_items.gif")); //$NON-NLS-1$ //$NON-NLS-2$
    // filtered by default, to not change the default behavior
    action.setChecked(true);
    return action;
}
 
Example 4
Source File: DotGraphView.java    From gef with Eclipse Public License 2.0 5 votes vote down vote up
private boolean toggle(Action action, boolean input) {
	action.setChecked(!action.isChecked());
	IToolBarManager mgr = getViewSite().getActionBars().getToolBarManager();
	for (IContributionItem item : mgr.getItems()) {
		if (item instanceof ActionContributionItem
				&& ((ActionContributionItem) item).getAction() == action) {
			action.setChecked(!action.isChecked());
			return !input;
		}
	}
	return input;
}
 
Example 5
Source File: TmfChartView.java    From tracecompass with Eclipse Public License 2.0 5 votes vote down vote up
private IAction createClampAction() {
    Action action = new Action(Messages.TmfChartView_LockYAxis, IAction.AS_PUSH_BUTTON) {
        @Override
        public void run() {
            LockRangeDialog rangeDialog = new LockRangeDialog(getSite().getShell(), getChartViewer());
            rangeDialog.open();
        }
    };
    action.setChecked(false);
    return action;
}
 
Example 6
Source File: TmfChartView.java    From tracecompass with Eclipse Public License 2.0 5 votes vote down vote up
private IAction createClampAction() {
    Action action = new Action(Messages.TmfChartView_LockYAxis, IAction.AS_PUSH_BUTTON) {
        @Override
        public void run() {
            LockRangeDialog rangeDialog = new LockRangeDialog(getSite().getShell(), getChartViewer());
            rangeDialog.open();
        }
    };
    action.setChecked(false);
    return action;
}
 
Example 7
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 8
Source File: SvnWizardCommitPage.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
private Action[] getCustomOptions() {
  	List customOptions = new ArrayList();
  	if (resourceSelectionTree.showIncludeUnversionedButton()) {
      	includeUnversionedAction = new Action(Policy.bind("CommitDialog.includeUnversioned"), SWT.TOGGLE) {
  			public void run() {
  				includeUnversioned = !includeUnversioned;
  				if (includeUnversionedButton.isVisible()) {
  					includeUnversionedButton.setSelection(includeUnversioned);
  				}
  				toggleIncludeUnversioned();
  			}   		    		
      	};  
  		includeUnversionedAction.setChecked(includeUnversioned);
  		customOptions.add(includeUnversionedAction);
  	}
  	keepLocksAction = new Action(Policy.bind("CommitDialog.keepLocks"), SWT.TOGGLE) {
	public void run() {
		keepLocks = !keepLocks;
		if (keepLocksButton.isVisible()) {
			keepLocksButton.setSelection(keepLocks);
		}
	}   		
};
customOptions.add(keepLocksAction);
Action[] customOptionArray = new Action[customOptions.size()];
customOptions.toArray(customOptionArray);
  	return customOptionArray;
  }
 
Example 9
Source File: SearchScopeActionGroup.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
private void ensureExactlyOneCheckedAction(Action[] result) {
	int checked = getCheckedActionCount(result);
	if (checked != 1) {
		if (checked > 1) {
			for (int i = 0; i < result.length; i++) {
				Action action = result[i];
				action.setChecked(false);
			}
		}
		fSearchScopeWorkspaceAction.setChecked(true);
	}
}
 
Example 10
Source File: SearchScopeActionGroup.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
private void addAction(List<Action> actions, Action action) {
	if (action == fSelectedAction) {
		action.setChecked(true);
	} else {
		action.setChecked(false);
	}

	actions.add(action);
}
 
Example 11
Source File: ICEScrolledPropertiesBlock.java    From ice with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * <p>
 * This operation creates actions in the toolbar for the block.
 * </p>
 * 
 * @param managedForm
 *            <p>
 *            The parent Form
 *            </p>
 */
@Override
protected void createToolBarActions(IManagedForm managedForm) {
	final ScrolledForm form = managedForm.getForm();
	Action haction = new Action("Horizontal Orientation",
			IAction.AS_RADIO_BUTTON) {
		@Override
		public void run() {
			sashForm.setOrientation(SWT.HORIZONTAL);
			form.reflow(true);
		}
	};
	haction.setChecked(true);
	haction.setToolTipText("Set Details to the Right of Masters");
	Action vaction = new Action("Vertical Orientation",
			IAction.AS_RADIO_BUTTON) {
		@Override
		public void run() {
			sashForm.setOrientation(SWT.VERTICAL);
			form.reflow(true);
		}
	};
	vaction.setChecked(false);
	vaction.setToolTipText("Set Details Below Masters");
	form.getToolBarManager().add(haction);
	form.getToolBarManager().add(vaction);
}
 
Example 12
Source File: HeaderPageWithSash.java    From uima-uimaj with Apache License 2.0 5 votes vote down vote up
/**
 * Creates the tool bar actions.
 *
 * @param managedForm the managed form
 */
protected void createToolBarActions(IManagedForm managedForm) {
  final ScrolledForm form = managedForm.getForm();

  haction = new Action("hor", IAction.AS_RADIO_BUTTON) { //$NON-NLS-1$
    @Override
    public void run() {
      sashForm.setOrientation(SWT.HORIZONTAL);
      form.reflow(true);
    }
  };
  haction.setChecked(true);
  haction.setToolTipText("Horizontal Orientation");
  TAEConfiguratorPlugin instance = TAEConfiguratorPlugin.getDefault();
  haction.setImageDescriptor(instance
          .getImageDescriptor(TAEConfiguratorPlugin.IMAGE_TH_HORIZONTAL));
  haction.setDisabledImageDescriptor(instance
          .getImageDescriptor(TAEConfiguratorPlugin.IMAGE_TH_HORIZONTAL));

  vaction = new Action("ver", IAction.AS_RADIO_BUTTON) { //$NON-NLS-1$
    @Override
    public void run() {
      sashForm.setOrientation(SWT.VERTICAL);
      form.reflow(true);
    }
  };
  vaction.setChecked(false);
  vaction.setToolTipText("Vertical Orientation");
  vaction.setImageDescriptor(instance
          .getImageDescriptor(TAEConfiguratorPlugin.IMAGE_TH_VERTICAL));
  vaction.setDisabledImageDescriptor(instance
          .getImageDescriptor(TAEConfiguratorPlugin.IMAGE_TH_VERTICAL));
  form.getToolBarManager().add(haction);
  form.getToolBarManager().add(vaction);
  form.updateToolBar();
  maybeInitialize(managedForm);
}
 
Example 13
Source File: SVNHistoryPage.java    From APICloud-Studio with GNU General Public License v3.0 4 votes vote down vote up
private void contributeActions() {
  toggleShowComments = new Action(Policy.bind("HistoryView.showComments"), //$NON-NLS-1$
      SVNUIPlugin.getPlugin().getImageDescriptor(ISVNUIConstants.IMG_COMMENTS)) {
    public void run() {
      showComments = isChecked();
      setViewerVisibility();
      store.setValue(ISVNUIConstants.PREF_SHOW_COMMENTS, showComments);
    }
  };
  toggleShowComments.setChecked(showComments);
  // PlatformUI.getWorkbench().getHelpSystem().setHelp(toggleTextAction,
  // IHelpContextIds.SHOW_COMMENT_IN_HISTORY_ACTION);

  // Toggle wrap comments action
  toggleWrapCommentsAction = new Action(Policy.bind("HistoryView.wrapComments")) { //$NON-NLS-1$
    public void run() {
      wrapCommentsText = isChecked();
      setViewerVisibility();
      store.setValue(ISVNUIConstants.PREF_WRAP_COMMENTS, wrapCommentsText);
    }
  };
  toggleWrapCommentsAction.setChecked(wrapCommentsText);
  // PlatformUI.getWorkbench().getHelpSystem().setHelp(toggleTextWrapAction,
  // IHelpContextIds.SHOW_TAGS_IN_HISTORY_ACTION);

  // Toggle path visible action
  toggleShowAffectedPathsAction = new Action(Policy.bind("HistoryView.showAffectedPaths"), //$NON-NLS-1$
      SVNUIPlugin.getPlugin().getImageDescriptor(ISVNUIConstants.IMG_AFFECTED_PATHS_FLAT_MODE)) {
    public void run() {
      showAffectedPaths = isChecked();
      setViewerVisibility();
      store.setValue(ISVNUIConstants.PREF_SHOW_PATHS, showAffectedPaths);
    }
  };
  toggleShowAffectedPathsAction.setChecked(showAffectedPaths);
  // PlatformUI.getWorkbench().getHelpSystem().setHelp(toggleListAction,
  // IHelpContextIds.SHOW_TAGS_IN_HISTORY_ACTION);

  // Toggle stop on copy action
  toggleStopOnCopyAction = new Action(Policy.bind("HistoryView.stopOnCopy")) { //$NON-NLS-1$
    public void run() {
      refresh();
      SVNUIPlugin.getPlugin().getPreferenceStore().setValue(ISVNUIConstants.PREF_STOP_ON_COPY,
          toggleStopOnCopyAction.isChecked());
    }
  };
  toggleStopOnCopyAction.setChecked(store.getBoolean(ISVNUIConstants.PREF_STOP_ON_COPY));
  
  // Toggle include merged revisions action
  toggleIncludeMergedRevisionsAction = new Action(Policy.bind("HistoryView.includeMergedRevisions")) { //$NON-NLS-1$
    public void run() {
      store.setValue(ISVNUIConstants.PREF_INCLUDE_MERGED_REVISIONS, toggleIncludeMergedRevisionsAction.isChecked());
  	refreshTable();
  	refresh();
    }
  };
  toggleIncludeMergedRevisionsAction.setChecked(store.getBoolean(ISVNUIConstants.PREF_INCLUDE_MERGED_REVISIONS));    
  
  IHistoryPageSite parentSite = getHistoryPageSite();
  IPageSite pageSite = parentSite.getWorkbenchPageSite();
  IActionBars actionBars = pageSite.getActionBars();

  // Contribute toggle text visible to the toolbar drop-down
  IMenuManager actionBarsMenu = actionBars.getMenuManager();
  actionBarsMenu.add(getGetNextAction());
  actionBarsMenu.add(getGetAllAction());
  actionBarsMenu.add(toggleStopOnCopyAction);
  actionBarsMenu.add(toggleIncludeMergedRevisionsAction);
  actionBarsMenu.add(new Separator());
  actionBarsMenu.add(toggleWrapCommentsAction);
  actionBarsMenu.add(new Separator());
  actionBarsMenu.add(toggleShowComments);
  actionBarsMenu.add(toggleShowAffectedPathsAction);
  actionBarsMenu.add(new Separator());
  for (int i = 0; i < toggleAffectedPathsModeActions.length; i++) {
    actionBarsMenu.add(toggleAffectedPathsModeActions[i]);
  }
  actionBarsMenu.add(new Separator());
  for (int i = 0; i < toggleAffectedPathsLayoutActions.length; i++) {
    actionBarsMenu.add(toggleAffectedPathsLayoutActions[i]);
  }
  
  // Create the local tool bar
  IToolBarManager tbm = actionBars.getToolBarManager();
  // tbm.add(getRefreshAction());
  tbm.add(new Separator());
  tbm.add(getSearchAction());
  tbm.add(getClearSearchAction());
  tbm.add(new Separator());
  tbm.add(toggleShowComments);
  tbm.add(toggleShowAffectedPathsAction);
  tbm.add(new Separator());
  tbm.add(getGetNextAction());
  tbm.add(getGetAllAction());
  // tbm.add(getLinkWithEditorAction());
  tbm.update(false);
  
  actionBars.updateActionBars();  
}
 
Example 14
Source File: SelectorPanel.java    From elexis-3-core with Eclipse Public License 1.0 4 votes vote down vote up
public SelectorPanel(Composite parent, IAction... actions){
	super(parent, SWT.NONE);
	setBackground(parent.getBackground());
	/*
	 * RowLayout layout = new RowLayout(SWT.HORIZONTAL); layout.fill = true; layout.pack = true;
	 */
	FormLayout layout = new FormLayout();
	layout.marginLeft = 0;
	layout.marginRight = 0;
	setLayout(layout);
	tActions = new ToolBarManager(SWT.FLAT | SWT.HORIZONTAL | SWT.WRAP);
	
	aClr = new Action(Messages.SelectorPanel_clearFields) {
		{
			setImageDescriptor(Images.IMG_CLEAR.getImageDescriptor());
		}
		
		@Override
		public void run(){
			clearValues();
		}
	};
	tActions.add(aClr);
	
	autoSearchActivatedAction =
		new Action(Messages.SelectorPanel_automaticSearch, Action.AS_CHECK_BOX) {
			{
				setImageDescriptor(Images.IMG_REFRESH.getImageDescriptor());
			}
			
			@Override
			public void run(){
				autoSearchActivated = !autoSearchActivated;
				if (autoSearchActivated)
					contentsChanged(null);
				super.run();
			}
		};
	autoSearchActivatedAction.setToolTipText(Messages.SelectorPanel_activateAutomaticSearch);
	autoSearchActivatedAction.setChecked(autoSearchActivated);
	tActions.add(autoSearchActivatedAction);
	
	performSearchAction = new Action(Messages.SelectorPanel_performSearch) {
		{
			setImageDescriptor(Images.IMG_NEXT.getImageDescriptor());
		}
		
		@Override
		public void run(){
			boolean oldState = autoSearchActivated;
			autoSearchActivated = true;
			contentsChanged(null);
			autoSearchActivated = oldState;
			super.run();
		}
	};
	performSearchAction.setToolTipText(Messages.SelectorPanel_performSearchTooltip);
	tActions.add(performSearchAction);
	
	for (IAction ac : actions) {
		if (ac != null) {
			tActions.add(ac);
		} else {
			tActions.add(new Separator());
		}
	}
	tb = tActions.createControl(this);
	FormData fdActions = new FormData();
	fdActions.top = new FormAttachment(0, 0);
	fdActions.right = new FormAttachment(100, 0);
	tb.setLayoutData(fdActions);
	cFields = new Composite(this, SWT.NONE);
	FormData fd = new FormData();
	fd.left = new FormAttachment(0, 0);
	fd.top = new FormAttachment(0, 0);
	fd.right = new FormAttachment(100, 0);
	cFields.setLayoutData(fd);
	cFields.setLayout(new FillLayout());
	if (parent.getData("TEST_COMP_NAME") != null) {
		for (int idx = 0; idx < tb.getItemCount(); idx++)
		{
			tb.getItem(idx).setData("TEST_COMP_NAME",
				parent.getData("TEST_COMP_NAME") + "_" + idx + "_tbi");
		}
	}
	pack();
}