Java Code Examples for org.eclipse.jface.action.IAction#setChecked()
The following examples show how to use
org.eclipse.jface.action.IAction#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: Zoom.java From tracecompass with Eclipse Public License 2.0 | 6 votes |
/** * Set action check state of a view action for a given action ID. * * @param id The action ID * @param checked true to check the action, false to uncheck the action */ protected void setActionChecked(String id, boolean checked) { if (getView() != null) { IActionBars bar = getView().getViewSite().getActionBars(); if (bar == null) { return; } IToolBarManager barManager = bar.getToolBarManager(); if (barManager == null) { return; } IContributionItem nextPage = barManager.find(id); if (nextPage instanceof ActionContributionItem) { IAction action = ((ActionContributionItem) nextPage).getAction(); if (action != null) { action.setChecked(checked); } } } }
Example 2
Source File: TmfEventsTable.java From tracecompass with Eclipse Public License 2.0 | 6 votes |
private IAction createAutoFitAction(TableColumn column) { final IAction autoFitAction = new Action(Messages.TmfEventsTable_AutoFit, IAction.AS_CHECK_BOX) { @Override public void run() { boolean isChecked = isChecked(); int index = (int) column.getData(Key.INDEX); if (isChecked) { fPacking = true; column.pack(); fPacking = false; column.setData(Key.WIDTH, SWT.DEFAULT); fColumnSize[index] = SWT.DEFAULT; } else { fColumnSize[index] = column.getWidth(); column.setData(Key.WIDTH, fColumnSize[index]); } } }; autoFitAction.setChecked(Objects.equals(column.getData(Key.WIDTH), SWT.DEFAULT)); return autoFitAction; }
Example 3
Source File: ControlFlowView.java From tracecompass with Eclipse Public License 2.0 | 6 votes |
private IAction createHierarchicalAction() { IAction action = new Action(Messages.ControlFlowView_hierarchicalViewLabel, IAction.AS_RADIO_BUTTON) { @Override public void run() { ITmfTrace parentTrace = getTrace(); synchronized (fFlatTraces) { fFlatTraces.remove(parentTrace); List<@NonNull TimeGraphEntry> entryList = getEntryList(parentTrace); if (entryList != null) { for (TimeGraphEntry traceEntry : entryList) { Collection<TimeGraphEntry> controlFlowEntries = fEntries.row(getProvider(traceEntry)).values(); controlFlowEntries.forEach(e -> e.setParent(null)); addEntriesToHierarchicalTree(controlFlowEntries, traceEntry); } } } refresh(); } }; action.setChecked(true); action.setToolTipText(Messages.ControlFlowView_hierarchicalViewToolTip); return action; }
Example 4
Source File: ThemeContribution.java From tm4e with Eclipse Public License 1.0 | 5 votes |
@Override protected IContributionItem[] getContributionItems() { List<IContributionItem> items = new ArrayList<IContributionItem>(); if (handlerService != null) { IEditorPart editorPart = getActivePart(handlerService.getCurrentState()); if (editorPart != null) { IThemeManager manager = TMUIPlugin.getThemeManager(); boolean dark = manager.isDarkEclipseTheme(); ITheme[] themes = manager.getThemes(); TMPresentationReconciler presentationReconciler = TMPresentationReconciler.getTMPresentationReconciler(editorPart); if (themes != null && presentationReconciler != null) { String scopeName = presentationReconciler.getGrammar().getScopeName(); ITheme selectedTheme = manager.getThemeForScope(scopeName, dark); for (ITheme theme : themes) { IAction action = createAction(scopeName, theme, dark); if (theme.equals(selectedTheme)) { action.setChecked(true); } IContributionItem item = new ActionContributionItem(action); items.add(item); } } } } return items.toArray(new IContributionItem[items.size()]); }
Example 5
Source File: PartialBuildAction.java From texlipse with Eclipse Public License 1.0 | 5 votes |
/** * */ public void setActiveEditor(IAction action, IEditorPart targetEditor) { editor = targetEditor; action.setEnabled(editor instanceof TexEditor); if (action.isEnabled()) { IProject project = ((TexEditor) editor).getProject(); if (project == null) { action.setEnabled(false); return; } //System.out.println("partial-build-running-from"); action.setChecked(TexlipseProperties.getProjectProperty(project, TexlipseProperties.PARTIAL_BUILD_PROPERTY) != null); run(action); } }
Example 6
Source File: RenameInformationPopup.java From typescript.java with MIT License | 5 votes |
private void addMoveMenuItem(IMenuManager manager, final int snapPosition, String text) { IAction action= new Action(text, IAction.AS_RADIO_BUTTON) { @Override public void run() { fSnapPosition= snapPosition; fSnapPositionChanged= true; getDialogSettings().put(SNAP_POSITION_KEY, fSnapPosition); updatePopupLocation(true); activateEditor(); } }; action.setChecked(fSnapPosition == snapPosition); manager.add(action); }
Example 7
Source File: TmfEventsTable.java From tracecompass with Eclipse Public License 2.0 | 5 votes |
private IAction createShowColumnAction(final TableColumn column) { final IAction columnMenuAction = new Action(column.getText(), IAction.AS_CHECK_BOX) { @Override public void run() { boolean isChecked = isChecked(); int index = (int) column.getData(Key.INDEX); if (isChecked) { int width = (int) column.getData(Key.WIDTH); column.setResizable(true); if (width <= 0) { fPacking = true; column.pack(); fPacking = false; column.setData(Key.WIDTH, SWT.DEFAULT); fColumnSize[index] = SWT.DEFAULT; } else { column.setWidth(width); } } else { column.setResizable(false); column.setWidth(0); } fColumnResizable[index] = isChecked; fTable.refresh(); } }; columnMenuAction.setChecked(column.getResizable()); return columnMenuAction; }
Example 8
Source File: ControlFlowView.java From tracecompass with Eclipse Public License 2.0 | 5 votes |
private IAction createFlatAction() { IAction action = new Action(Messages.ControlFlowView_flatViewLabel, IAction.AS_RADIO_BUTTON) { @Override public void run() { applyFlatPresentation(); refresh(); } }; action.setChecked(true); action.setToolTipText(Messages.ControlFlowView_flatViewToolTip); return action; }
Example 9
Source File: RenameInformationPopup.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
private void addMoveMenuItem(IMenuManager manager, final int snapPosition, String text) { IAction action= new Action(text, IAction.AS_RADIO_BUTTON) { @Override public void run() { fSnapPosition= snapPosition; fSnapPositionChanged= true; getDialogSettings().put(SNAP_POSITION_KEY, fSnapPosition); updatePopupLocation(true); activateEditor(); } }; action.setChecked(fSnapPosition == snapPosition); manager.add(action); }
Example 10
Source File: GraphicalView.java From eclipsegraphviz with Eclipse Public License 1.0 | 5 votes |
private void updateAutoSyncToggleButtonState() { IToolBarManager toolBarManager = getViewSite().getActionBars().getToolBarManager(); ActionContributionItem autoSyncToggleContribution = (ActionContributionItem) toolBarManager .find("com.abstratt.imageviewer.autoUpdate"); if (autoSyncToggleContribution != null) { IAction action = autoSyncToggleContribution.getAction(); action.setChecked(isAutoSync()); } }
Example 11
Source File: AbstractSliceSystem.java From dawnsci with Eclipse Public License 1.0 | 5 votes |
/** * Disarms the current tool (if different) and arms this tool. * * @param tool */ @Override public void militarize(ISlicingTool slicingTool) { saveSliceSettings(); if (activeTool!=null && slicingTool!=activeTool) { activeTool.demilitarize(); } // If we don't support advanced slicing (averaging etc.) then disable if (advanced!=null) advanced.setEnabled(slicingTool.isAdvancedSupported()); if (!slicingTool.isAdvancedSupported()) { DimsDataList list = getDimsDataList(); for (DimsData dd : list.iterable()) { if (dd.getPlotAxis().isAdvanced()) { dd.setSliceRange(null); dd.setPlotAxis(AxisType.SLICE); } } } slicingTool.militarize(false); activeTool = slicingTool; // check the correct actions for (Enum<?> key : plotTypeActions.keySet()) { final IAction action = plotTypeActions.get(key); action.setChecked(key==sliceType); } }
Example 12
Source File: AbstractShowReferencesActionDelegate.java From Pydev with Eclipse Public License 1.0 | 5 votes |
@Override public void init(IAction action) { fAction = action; action.setChecked(isShowReference()); PyVariablesPreferences.addPropertyChangeListener(this); run(fAction); }
Example 13
Source File: TexWordWrapAction.java From texlipse with Eclipse Public License 1.0 | 4 votes |
public void init(IAction action) { action.setChecked(!off); }
Example 14
Source File: TabbedPropertyTitle.java From birt with Eclipse Public License 1.0 | 4 votes |
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 ); }