Example usage for org.eclipse.jface.action IAction AS_CHECK_BOX

List of usage examples for org.eclipse.jface.action IAction AS_CHECK_BOX

Introduction

In this page you can find the example usage for org.eclipse.jface.action IAction AS_CHECK_BOX.

Prototype

int AS_CHECK_BOX

To view the source code for org.eclipse.jface.action IAction AS_CHECK_BOX.

Click Source Link

Document

Action style constant (value 2) indicating action is a check box (or a toggle button).

Usage

From source file:ar.com.tadp.xml.rinzo.core.outline.actions.ShowFullNameAction.java

License:Open Source License

public int getStyle() {
    return IAction.AS_CHECK_BOX;
}

From source file:ar.com.tadp.xml.rinzo.core.views.XPathView.java

License:Open Source License

public void createPartControl(Composite parent) {
    parent.setLayout(new GridLayout(1, false));
    parent.setLayoutData(new GridData(GridData.FILL_BOTH));

    Composite expresionComposite = new Composite(parent, SWT.NONE);
    expresionComposite.setLayout(new GridLayout(3, false));
    expresionComposite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    Composite expresionContainer = new Composite(expresionComposite, SWT.NONE);
    expresionContainer.setLayout(new GridLayout(3, false));
    expresionContainer.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

    Label label = new Label(expresionContainer, SWT.NONE);
    label.setText("Expression:");
    this.expressionsCombo = new Combo(expresionContainer, SWT.DROP_DOWN | SWT.SINGLE | SWT.LEAD);
    this.expressionsCombo.setLayout(new GridLayout(1, false));
    this.expressionsCombo.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    this.expressionsCombo.setFocus();
    this.expressionsCombo.setVisibleItemCount(8);
    this.expressionsCombo.setToolTipText("Enter XPath for Source XML");
    this.autoEvaluationListener = new AutoEvaluationKeyListener();
    this.enterEvaluationListener = new EnterEvaluationKeyListener();
    this.expressionsCombo.addKeyListener(this.enterEvaluationListener);
    this.selectionListener = new SelectionListenerImplementation();

    this.evaluateButton = new Button(expresionComposite, SWT.PUSH);
    this.evaluateButton.setText("evaluate");
    this.evaluateButton.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent e) {
            super.widgetSelected(e);
            evaluateExpression();/*from  ww  w . j  a  v  a  2s .  c o m*/
        }
    });

    Composite resultComposite = new Composite(parent, SWT.NONE);
    resultComposite.setLayout(new FillLayout());
    resultComposite.setLayoutData(new GridData(GridData.FILL_BOTH));
    this.resultViewer = new SourceViewer(resultComposite, null, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL);
    this.resultViewer.setInput(this);
    this.resultViewer.configure(new XMLEditorConfiguration());
    this.resultViewer.setDocument(new Document(""));

    this.clearAllAction = new Action("Clear All") {
        public void run() {
            resultViewer.getDocument().set("");
            resultViewer.refresh();
            expressionsCombo.removeAll();
        }
    };
    this.clearAllAction
            .setImageDescriptor(ImageDescriptor.createFromImage(PluginImages.get(PluginImages.IMG_CLEAR)));

    this.autoEvaluateAction = new Action("Auto Evaluate XPath", IAction.AS_CHECK_BOX) {
        public void run() {
            setAutoEvaluation(!autoEvaluation);
        }
    };
    this.autoEvaluateAction.setImageDescriptor(
            ImageDescriptor.createFromImage(PluginImages.get(PluginImages.IMG_XPATH_AUTO_EVALUATE)));
    this.setAutoEvaluation(
            XMLEditorPlugin.getDefault().getPreferenceStore().getBoolean(XPATH_VIEW_AUTO_EVALUATION));
    this.autoEvaluateAction.setChecked(this.autoEvaluation);

    IToolBarManager toolbarManager = getViewSite().getActionBars().getToolBarManager();
    toolbarManager.add(this.autoEvaluateAction);
    toolbarManager.add(this.clearAllAction);
}

From source file:at.bestsolution.eclipse.properties.PropertyContentOutlinePage.java

License:Open Source License

public PropertyContentOutlinePage(PropertiesFileEditor editor) {
    final IEditorInput input = editor.getEditorInput();
    final IDocumentProvider provider = editor.getDocumentProvider();
    this.editor = editor;
    document = provider.getDocument(input);
    document.addDocumentListener(new IDocumentListener() {

        public void documentChanged(DocumentEvent event) {
            try {
                setProperties(getPairs(event.fDocument));
            } catch (UnsupportedEncodingException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();/*from   w  ww .  j  av a  2  s .c  o  m*/
            } catch (IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }

        public void documentAboutToBeChanged(DocumentEvent event) {
        }
    });
    try {
        properties = getPairs(document);
    } catch (UnsupportedEncodingException e1) {
        // TODO Auto-generated catch block
        e1.printStackTrace();
    } catch (IOException e1) {
        // TODO Auto-generated catch block
        e1.printStackTrace();
    }

    sortAction = new Action("", IAction.AS_CHECK_BOX) {
        @Override
        public void run() {
            preferences.putBoolean(PREF_SORTED, isChecked());
            try {
                preferences.flush();
            } catch (BackingStoreException e) {
                e.printStackTrace();
            }
        }
    };
    sortAction.setImageDescriptor(
            Activator.getDefault().getImageRegistry().getDescriptor(Activator.ALPHASORT_ICON));
    sortAction.setChecked(isSorted());

    hierarchicalAction = new Action("", IAction.AS_CHECK_BOX) {
        @Override
        public void run() {
            preferences.putBoolean(PREF_HIERARCHICAL, isChecked());
            try {
                preferences.flush();
            } catch (BackingStoreException e) {
                e.printStackTrace();
            }
        }
    };
    hierarchicalAction.setImageDescriptor(
            Activator.getDefault().getImageRegistry().getDescriptor(Activator.HIERACHICAL_ICON));
    hierarchicalAction.setChecked(isHierarchical());

    preferences.addPreferenceChangeListener(new IPreferenceChangeListener() {

        public void preferenceChange(PreferenceChangeEvent event) {
            if (event.getKey().equals(PREF_SORTED)) {
                boolean val = isSorted();
                setSorted(val);
                sortAction.setChecked(val);
            } else if (event.getKey().equals(PREF_HIERARCHICAL)) {
                boolean val = isHierarchical();
                setHierarchical(val);
                hierarchicalAction.setChecked(val);
            }
        }
    });
}

From source file:at.bestsolution.efxclipse.tooling.jdt.ui.internal.editors.outline.PropertyContentOutlinePage.java

License:Open Source License

public PropertyContentOutlinePage(PropertiesFileEditor editor) {
    final IEditorInput input = editor.getEditorInput();
    final IDocumentProvider provider = editor.getDocumentProvider();
    this.editor = editor;
    document = provider.getDocument(input);
    document.addDocumentListener(new IDocumentListener() {

        public void documentChanged(DocumentEvent event) {
            try {
                setProperties(getPairs(event.fDocument));
            } catch (UnsupportedEncodingException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();// w w w  .  j av a  2 s .com
            } catch (IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }

        public void documentAboutToBeChanged(DocumentEvent event) {
        }
    });
    try {
        properties = getPairs(document);
    } catch (UnsupportedEncodingException e1) {
        // TODO Auto-generated catch block
        e1.printStackTrace();
    } catch (IOException e1) {
        // TODO Auto-generated catch block
        e1.printStackTrace();
    }

    sortAction = new Action("", IAction.AS_CHECK_BOX) {
        @Override
        public void run() {
            preferences.putBoolean(PREF_SORTED, isChecked());
            try {
                preferences.flush();
            } catch (BackingStoreException e) {
                e.printStackTrace();
            }
        }
    };
    sortAction.setImageDescriptor(
            JavaFXUIPlugin.getDefault().getImageRegistry().getDescriptor(JavaFXUIPlugin.ALPHASORT_ICON));
    sortAction.setChecked(isSorted());

    hierarchicalAction = new Action("", IAction.AS_CHECK_BOX) {
        @Override
        public void run() {
            preferences.putBoolean(PREF_HIERARCHICAL, isChecked());
            try {
                preferences.flush();
            } catch (BackingStoreException e) {
                e.printStackTrace();
            }
        }
    };
    hierarchicalAction.setImageDescriptor(
            JavaFXUIPlugin.getDefault().getImageRegistry().getDescriptor(JavaFXUIPlugin.HIERACHICAL_ICON));
    hierarchicalAction.setChecked(isHierarchical());

    preferences.addPreferenceChangeListener(new IPreferenceChangeListener() {

        public void preferenceChange(PreferenceChangeEvent event) {
            if (event.getKey().equals(PREF_SORTED)) {
                boolean val = isSorted();
                setSorted(val);
                sortAction.setChecked(val);
            } else if (event.getKey().equals(PREF_HIERARCHICAL)) {
                boolean val = isHierarchical();
                setHierarchical(val);
                hierarchicalAction.setChecked(val);
            }
        }
    });
}

From source file:at.bestsolution.efxclipse.tooling.ui.preview.LivePreviewPart.java

License:Open Source License

@Override
public void createPartControl(final Composite parent) {
    final Composite container = new Composite(parent, SWT.NONE);
    container.setLayout(new GridLayout(3, false));

    folder = new CTabFolder(container, SWT.BOTTOM | SWT.BORDER);
    folder.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, true, 3, 1));

    parent.getDisplay().asyncExec(new Runnable() {

        @Override//from w  w w. ja v  a  2  s .c  o  m
        public void run() {

            {
                CTabItem item = new CTabItem(folder, SWT.NONE);

                item.setText("Preview");
                item.setImage(JFaceResources.getImage(IMAGE_PREVIEW));

                swtFXContainer = new FXCanvas(folder, SWT.NONE);
                swtFXContainer.setEnabled(false);

                item.setControl(swtFXContainer);

                rootPane_new = new BorderPane();
                Scene scene = new Scene((Parent) rootPane_new, 1000, 1000);
                currentScene = scene;
                swtFXContainer.setScene(scene);
            }

            {
                logItem = new CTabItem(folder, SWT.NONE);
                logItem.setText("Error log");
                logItem.setImage(JFaceResources.getImage(IMAGE_OK));

                logStatement = new Text(folder, SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL);
                logStatement.setEditable(false);
                logItem.setControl(logStatement);

                Menu m = new Menu(logStatement);
                logStatement.setMenu(m);
                MenuItem clearItem = new MenuItem(m, SWT.PUSH);
                clearItem.setText("Clear Log");
                clearItem.addSelectionListener(new SelectionAdapter() {
                    @Override
                    public void widgetSelected(SelectionEvent e) {
                        logStatement.setText("");
                    }
                });
            }

            {
                CTabItem fxmlContent = new CTabItem(folder, SWT.NONE);
                fxmlContent.setText("FXML-Source");
                fxmlContent.setImage(JFaceResources.getImage(IMAGE_FXML_CONTENT));

                final AnnotationModel model = new AnnotationModel();
                VerticalRuler verticalRuler = new VerticalRuler(VERTICAL_RULER_WIDTH, new AnnotationAccess());
                int styles = SWT.V_SCROLL | SWT.H_SCROLL | SWT.MULTI | SWT.BORDER | SWT.FULL_SELECTION;
                SourceViewer sourceViewer = new SourceViewer(folder, verticalRuler, styles);
                sourceViewer.configure(new XMLConfiguration(new ColorManager()));
                sourceViewer.setEditable(false);
                sourceViewer.getTextWidget().setFont(JFaceResources.getTextFont());

                document = new Document();
                IDocumentPartitioner partitioner = new FastPartitioner(new XMLPartitionScanner(),
                        new String[] { XMLPartitionScanner.XML_TAG, XMLPartitionScanner.XML_COMMENT });
                partitioner.connect(document);
                document.setDocumentPartitioner(partitioner);
                sourceViewer.setDocument(document);
                verticalRuler.setModel(model);
                fxmlContent.setControl(sourceViewer.getControl());
            }

            folder.setSelection(0);

            statusLabelIcon = new Label(container, SWT.NONE);
            statusLabelIcon.setImage(JFaceResources.getImage(IMAGE_STATUS_NOPREVIEW));

            statusLabelText = new Label(container, SWT.NONE);
            statusLabelText.setText(NO_PREVIEW_TEXT);
            statusLabelText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

            Composite scaleControl = new Composite(container, SWT.NONE);
            scaleControl.setLayoutData(new GridData(GridData.END, GridData.CENTER, false, false));
            scaleControl.setLayout(new GridLayout(2, false));

            Label l = new Label(scaleControl, SWT.NONE);
            l.setText("Zoom");

            scale = new Spinner(scaleControl, SWT.BORDER);
            scale.setMinimum(10);
            scale.setMaximum(500);
            scale.setIncrement(10);
            scale.setSelection(100);
            scale.addSelectionListener(new SelectionAdapter() {
                @Override
                public void widgetSelected(SelectionEvent e) {
                    rootPane_new.setScaleX(scale.getSelection() / 100.0);
                    rootPane_new.setScaleY(scale.getSelection() / 100.0);
                    if (currentFile != null) {
                        scaleMap.put(currentFile, scale.getSelection());
                    }
                }
            });

            parent.layout(true, true);

            if (currentData != null) {
                refreshContent(currentData);
            }
        }
    });

    parent.layout(true, true);

    Action loadController = new Action("", IAction.AS_CHECK_BOX) {
        @Override
        public void run() {
            preference.putBoolean(PREF_LOAD_CONTROLLER, !preference.getBoolean(PREF_LOAD_CONTROLLER, false));
            try {
                preference.flush();
                synchronizer.refreshPreview();
            } catch (BackingStoreException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }
    };
    loadController.setChecked(preference.getBoolean(PREF_LOAD_CONTROLLER, false));
    loadController.setImageDescriptor(JFaceResources.getImageRegistry().getDescriptor(IMAGE_LOAD_CONTROLLER));
    loadController.setToolTipText("Load the controller");

    Action refresh = new Action("", JFaceResources.getImageRegistry().getDescriptor(IMAGE_REFRESH)) {
        @Override
        public void run() {
            synchronizer.refreshPreview();
        }
    };
    refresh.setToolTipText("Force a refresh");

    getViewSite().getActionBars().getToolBarManager().add(refresh);
    getViewSite().getActionBars().getToolBarManager().add(loadController);
}

From source file:bndtools.views.ImportsExportsView.java

License:Open Source License

void fillActionBars() {
    IAction toggleShowSelfImports = new Action("showSelfImports", IAction.AS_CHECK_BOX) {
        @Override/*w w  w .  ja  va 2 s. c om*/
        public void runWithEvent(Event event) {
            if (isChecked()) {
                viewer.removeFilter(hideSelfImportsFilter);
            } else {
                viewer.addFilter(hideSelfImportsFilter);
            }
        }
    };
    toggleShowSelfImports.setChecked(false);
    toggleShowSelfImports.setImageDescriptor(
            AbstractUIPlugin.imageDescriptorFromPlugin(Plugin.PLUGIN_ID, "/icons/package_folder_impexp.gif"));
    toggleShowSelfImports.setToolTipText("Show self-imported packages");

    IToolBarManager toolBarManager = getViewSite().getActionBars().getToolBarManager();
    toolBarManager.add(toggleShowSelfImports);
}

From source file:bndtools.views.resolution.ResolutionView.java

License:Open Source License

void fillActionBars() {
    IAction toggleShowSelfImports = new Action("showSelfImports", IAction.AS_CHECK_BOX) {
        @Override//www.j a  v a2s. c  om
        public void runWithEvent(Event event) {
            if (isChecked()) {
                reqsViewer.removeFilter(hideSelfImportsFilter);
            } else {
                reqsViewer.addFilter(hideSelfImportsFilter);
            }
        }
    };
    toggleShowSelfImports.setChecked(false);
    toggleShowSelfImports.setImageDescriptor(
            AbstractUIPlugin.imageDescriptorFromPlugin(Plugin.PLUGIN_ID, "/icons/package_folder_impexp.gif"));
    toggleShowSelfImports.setToolTipText(
            "Show resolved requirements.\n\nInclude requirements that are resolved within the set of selected bundles.");

    IAction toggleLockInput = new Action("lockInput", IAction.AS_CHECK_BOX) {
        @Override
        public void runWithEvent(Event event) {
            inputLocked = isChecked();
            if (!inputLocked) {
                executeAnalysis();
            }
        }
    };
    toggleLockInput.setChecked(false);
    toggleLockInput.setImageDescriptor(Icons.desc("lock"));
    toggleLockInput.setToolTipText("Lock to current selection");

    IToolBarManager toolBarManager = getViewSite().getActionBars().getToolBarManager();
    toolBarManager.add(toggleShowSelfImports);
    toolBarManager.add(toggleLockInput);
}

From source file:ca.uwaterloo.gp.fmp.presentation.ConstraintsView.java

License:Open Source License

protected void addLinkButton() {
    toggleLinkingAction = new Action("Link with Editor", IAction.AS_CHECK_BOX) {
        public void run() {
            linked = !linked;/*from   w w w  .j  a  v a2s .  c  o  m*/
        }
    };
    toggleLinkingAction.setChecked(linked);
    toggleLinkingAction.setToolTipText("Link with Editor");
    toggleLinkingAction.setImageDescriptor(getImageDescriptor("elcl16/synced.gif"));
    IActionBars bars = getViewSite().getActionBars();
    bars.getToolBarManager().add(toggleLinkingAction);
}

From source file:ca.uwaterloo.gp.fmp.presentation.PropertiesView.java

License:Open Source License

public void createPartControl(Composite parent) {
    treeViewer = new TreeViewer(parent, SWT.H_SCROLL | SWT.V_SCROLL | SWT.PUSH);

    treeViewer.addFilter(new ViewerFilter() {
        public boolean select(Viewer viewer, Object parentElement, Object element) {
            // hide everyting that is not defined in the metamodel                   
            if (filter && RoleQuery.INSTANCE.getPropertyRole((Node) element) == RoleQuery.NONE)
                return false;
            // hide configurations
            if (!filter) {
                if (element instanceof Feature
                        && RoleQuery.INSTANCE.getNodeType((Node) element) == RoleQuery.ROOT_FEATURE)
                    return false;
            }//from   w w w  . j a  v  a  2 s  . co m
            if (parentElement instanceof Clonable) {
                int state = ((Clonable) parentElement).getState().getValue();
                int min = ((Clonable) parentElement).getMin();
                if (min == 0 && (state == ConfigState.UNDECIDED || state == ConfigState.MACHINE_ELIMINATED
                        || state == ConfigState.USER_ELIMINATED))
                    return false;
            }
            return true;
        }
    });
    toggleAnnotations = new Action("Toggle Annotations", IAction.AS_CHECK_BOX) {
        public void run() {
            filter = !filter;
            treeViewer.refresh();
        }
    };
    toggleAnnotations.setToolTipText("Shows/hides unused annotations");
    toggleAnnotations.setImageDescriptor(ExtendedImageRegistry.getInstance()
            .getImageDescriptor(fmpEditPlugin.INSTANCE.getImage("full/ShowAnnotationsAction")));

    toggleLinkingAction = new Action("Link with Editor", IAction.AS_CHECK_BOX) {
        public void run() {
            selectionListenerActive = !selectionListenerActive;
        }
    };
    toggleLinkingAction.setChecked(selectionListenerActive);
    toggleLinkingAction.setToolTipText("Link with Editor");
    toggleLinkingAction.setImageDescriptor(
            AbstractUIPlugin.imageDescriptorFromPlugin("org.eclipse.ui", "icons/full/elcl16/synced.gif"));
    getViewSite().getActionBars().getToolBarManager().add(toggleLinkingAction);

    getViewSite().getActionBars().getToolBarManager().add(toggleAnnotations);

    // add drag support
    treeViewer.addDragSupport(dndOperations, transfers, new ViewerDragAdapter(treeViewer));

    getSite().getPage().addPartListener(this);
    getSite().getPage().addSelectionListener(this);

    IEditorPart activeEditor = getSite().getPage().getActiveEditor();
    if (activeEditor instanceof FmpEditor) {
        registerWithEditor((FmpEditor) activeEditor);
        setInputFromEditorSelection(editor.getSelection());
    }
}

From source file:cc.warlock.rcp.actions.StreamShowAction.java

License:Open Source License

public StreamShowAction(String title, String id, String secondaryId) {
    super(title, IAction.AS_CHECK_BOX);
    this.id = id;
    this.secondaryId = secondaryId;
    setChecked(findView() != null);/*w ww .  jav a2 s. co  m*/
    setDescription("Custom output window: " + title);
    setImageDescriptor(WarlockSharedImages.getImageDescriptor(WarlockSharedImages.IMG_WINDOW));
}