Search in sources :

Example 81 with IAction

use of org.eclipse.jface.action.IAction in project yamcs-studio by yamcs.

the class CopyWidgetsAction method run.

@Override
public void run() {
    DisplayModel tempModel = new DisplayModel();
    List<AbstractWidgetModel> widgetModels = getSelectedWidgetModels();
    for (AbstractWidgetModel widget : widgetModels) {
        tempModel.addChild(widget, false);
    }
    String xml = XMLUtil.widgetToXMLString(tempModel, false);
    ((OPIEditor) getWorkbenchPart()).getClipboard().setContents(new Object[] { xml }, new Transfer[] { OPIWidgetsTransfer.getInstance() });
    Display.getCurrent().asyncExec(new Runnable() {

        @Override
        public void run() {
            IAction pasteAction = ((ActionRegistry) ((OPIEditor) getWorkbenchPart()).getAdapter(ActionRegistry.class)).getAction(ActionFactory.PASTE.getId());
            if (pasteAction != null) {
                ((PasteWidgetsAction) pasteAction).refreshEnable();
            }
        }
    });
}
Also used : OPIEditor(org.csstudio.opibuilder.editor.OPIEditor) AbstractWidgetModel(org.csstudio.opibuilder.model.AbstractWidgetModel) IAction(org.eclipse.jface.action.IAction) DisplayModel(org.csstudio.opibuilder.model.DisplayModel)

Example 82 with IAction

use of org.eclipse.jface.action.IAction in project liferay-ide by liferay.

the class IDEFormPage method createFormContent.

protected void createFormContent(IManagedForm managedForm) {
    ScrolledForm form = managedForm.getForm();
    FormToolkit toolkit = managedForm.getToolkit();
    toolkit.decorateFormHeading(form.getForm());
    IToolBarManager manager = form.getToolBarManager();
    getFormEditor().contributeToToolbar(manager);
    IFormPart[] parts = managedForm.getParts();
    for (int i = 0; i < parts.length; i++) {
        if (parts[i] instanceof IAdaptable) {
            IAdaptable adapter = (IAdaptable) parts[i];
            IAction[] actions = (IAction[]) adapter.getAdapter(IAction[].class);
            if (actions != null) {
                for (int j = 0; j < actions.length; j++) {
                    form.getToolBarManager().add(actions[j]);
                }
            }
        }
    }
    form.updateToolBar();
}
Also used : IAdaptable(org.eclipse.core.runtime.IAdaptable) FormToolkit(org.eclipse.ui.forms.widgets.FormToolkit) IAction(org.eclipse.jface.action.IAction) IToolBarManager(org.eclipse.jface.action.IToolBarManager) ScrolledForm(org.eclipse.ui.forms.widgets.ScrolledForm) IFormPart(org.eclipse.ui.forms.IFormPart)

Example 83 with IAction

use of org.eclipse.jface.action.IAction in project liferay-ide by liferay.

the class ServiceMethodHyperlinkDetector method detectHyperlinks.

public IHyperlink[] detectHyperlinks(ITextViewer textViewer, IRegion region, boolean canShowMultipleHyperlinks) {
    IHyperlink[] retval = null;
    ITextEditor textEditor = (ITextEditor) getAdapter(ITextEditor.class);
    if (textEditor == null) {
        return retval;
    }
    ITypeRoot input = EditorUtility.getEditorInputJavaElement(textEditor, false);
    IAction openAction = textEditor.getAction("OpenEditor");
    if (_shouldDetectHyperlinks(textEditor, input, openAction, region)) {
        IDocumentProvider documentProvider = textEditor.getDocumentProvider();
        IEditorInput editorInput = textEditor.getEditorInput();
        IDocument document = documentProvider.getDocument(editorInput);
        int offset = region.getOffset();
        IRegion wordRegion = JavaWordFinder.findWord(document, offset);
        if (_isRegionValid(document, wordRegion)) {
            IJavaElement[] elements = new IJavaElement[0];
            long modStamp = documentProvider.getModificationStamp(editorInput);
            if (input.equals(_lastInput) && (modStamp == _lastModStamp) && wordRegion.equals(_lastWordRegion)) {
                elements = _lastElements;
            } else {
                try {
                    elements = ((ICodeAssist) input).codeSelect(wordRegion.getOffset(), wordRegion.getLength());
                    elements = _selectOpenableElements(elements);
                    _lastInput = input;
                    _lastModStamp = modStamp;
                    _lastWordRegion = wordRegion;
                    _lastElements = elements;
                } catch (JavaModelException jme) {
                }
            }
            if (elements.length != 0) {
                List<IHyperlink> links = new ArrayList<>(elements.length);
                for (IJavaElement element : elements) {
                    if (element instanceof IMethod) {
                        _addHyperlinks(links, wordRegion, (SelectionDispatchAction) openAction, (IMethod) element, elements.length > 1, (JavaEditor) textEditor);
                    }
                }
                if (ListUtil.isNotEmpty(links)) {
                    if (canShowMultipleHyperlinks) {
                        retval = links.toArray(new IHyperlink[0]);
                    } else {
                        retval = new IHyperlink[] { links.get(0) };
                    }
                }
            }
        }
    }
    return retval;
}
Also used : IJavaElement(org.eclipse.jdt.core.IJavaElement) JavaModelException(org.eclipse.jdt.core.JavaModelException) ITextEditor(org.eclipse.ui.texteditor.ITextEditor) IAction(org.eclipse.jface.action.IAction) ITypeRoot(org.eclipse.jdt.core.ITypeRoot) ArrayList(java.util.ArrayList) IRegion(org.eclipse.jface.text.IRegion) IDocumentProvider(org.eclipse.ui.texteditor.IDocumentProvider) IHyperlink(org.eclipse.jface.text.hyperlink.IHyperlink) IMethod(org.eclipse.jdt.core.IMethod) IEditorInput(org.eclipse.ui.IEditorInput) IDocument(org.eclipse.jface.text.IDocument)

Example 84 with IAction

use of org.eclipse.jface.action.IAction in project liferay-ide by liferay.

the class FindBreakingChangesPage method createTableView.

public void createTableView(Composite container) {
    GridData gridData = new GridData(GridData.FILL_BOTH);
    gridData.minimumWidth = 200;
    gridData.minimumHeight = 200;
    Composite tableComposite = new Composite(container, SWT.NONE);
    _problemsViewer = new TableViewer(tableComposite, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION | SWT.BORDER | SWT.VIRTUAL);
    _problemsViewer.getTable().setLayoutData(gridData);
    _createColumns(_problemsViewer);
    final Table table = _problemsViewer.getTable();
    table.setHeaderVisible(true);
    _problemsViewer.setContentProvider(ArrayContentProvider.getInstance());
    _problemsViewer.setComparer(null);
    _comparator = new MigratorComparator();
    _problemsViewer.setComparator(_comparator);
    MenuManager menuMgr = new MenuManager();
    IAction markDoneAction = new MarkDoneAction(_problemsViewer);
    IAction markUndoneAction = new MarkUndoneAction(_problemsViewer);
    IAction ignoreAction = new IgnoreAction(_problemsViewer);
    IAction ignoreAlways = new IgnoreAlwaysAction(_problemsViewer);
    IAction autoCorrectAction = new AutoCorrectAction(_problemsViewer);
    menuMgr.add(markDoneAction);
    menuMgr.add(markUndoneAction);
    menuMgr.add(ignoreAction);
    menuMgr.add(autoCorrectAction);
    menuMgr.add(ignoreAlways);
    Menu menu = menuMgr.createContextMenu(table);
    table.setMenu(menu);
    _problemsViewer.addDoubleClickListener(this);
}
Also used : MigratorComparator(com.liferay.ide.project.ui.migration.MigratorComparator) Table(org.eclipse.swt.widgets.Table) MarkDoneAction(com.liferay.ide.project.ui.migration.MarkDoneAction) Composite(org.eclipse.swt.widgets.Composite) IAction(org.eclipse.jface.action.IAction) AutoCorrectAction(com.liferay.ide.project.ui.migration.AutoCorrectAction) MarkUndoneAction(com.liferay.ide.project.ui.migration.MarkUndoneAction) GridData(org.eclipse.swt.layout.GridData) MenuManager(org.eclipse.jface.action.MenuManager) IgnoreAlwaysAction(com.liferay.ide.project.ui.migration.IgnoreAlwaysAction) Menu(org.eclipse.swt.widgets.Menu) TableViewer(org.eclipse.jface.viewers.TableViewer) IgnoreAction(com.liferay.ide.project.ui.migration.IgnoreAction)

Example 85 with IAction

use of org.eclipse.jface.action.IAction in project liferay-ide by liferay.

the class UpgradeView method createPartControl.

@Override
public void createPartControl(Composite parent) {
    ScrolledComposite scrolledComposite = new ScrolledComposite(parent, SWT.DOUBLE_BUFFERED | SWT.H_SCROLL | SWT.V_SCROLL);
    scrolledComposite.setExpandHorizontal(true);
    scrolledComposite.setExpandVertical(true);
    Composite container = SWTUtil.createComposite(scrolledComposite, 1, 0, GridData.FILL_BOTH);
    GridLayout gridLayout = new GridLayout(1, false);
    gridLayout.marginWidth = 0;
    gridLayout.marginTop = 0;
    gridLayout.marginHeight = 0;
    container.setLayout(gridLayout);
    Composite composite = new Composite(container, SWT.NONE);
    composite.setLayout(new GridLayout(1, true));
    GridData grData = new GridData(GridData.FILL_BOTH);
    grData.grabExcessVerticalSpace = true;
    grData.grabExcessHorizontalSpace = true;
    composite.setLayoutData(grData);
    final GearControl gear = new GearControl(composite, SWT.NONE);
    GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
    gridData.grabExcessHorizontalSpace = true;
    gridData.widthHint = 400;
    gridData.heightHint = 150;
    gear.setLayoutData(gridData);
    gear.setBackground(parent.getBackground());
    StackLayout stackLayout = new StackLayout();
    _pagesSwitchControler = new Composite(composite, SWT.BORDER);
    _pagesSwitchControler.setLayout(stackLayout);
    GridData containerData = new GridData(GridData.FILL_BOTH);
    containerData.grabExcessHorizontalSpace = true;
    containerData.grabExcessVerticalSpace = true;
    containerData.grabExcessHorizontalSpace = true;
    _pagesSwitchControler.setLayoutData(containerData);
    int pageIndex = 0;
    Page welcomePage = new WelcomePage(_pagesSwitchControler, SWT.NONE, _dataModel);
    welcomePage.setIndex(pageIndex++);
    welcomePage.setTitle("Welcome");
    welcomePage.setBackPage(false);
    welcomePage.addPageNavigateListener(gear);
    Page initConfigureProjectPage = new InitConfigureProjectPage(_pagesSwitchControler, SWT.NONE, _dataModel);
    initConfigureProjectPage.setIndex(pageIndex++);
    initConfigureProjectPage.setTitle("Select project(s) to upgrade");
    initConfigureProjectPage.addPageNavigateListener(gear);
    initConfigureProjectPage.addPageValidationListener(gear);
    initConfigureProjectPage.setNextPage(false);
    Page upgradePomPage = new UpgradePomPage(_pagesSwitchControler, SWT.NONE, _dataModel);
    upgradePomPage.setIndex(pageIndex++);
    upgradePomPage.setTitle("Upgrade POM Files");
    upgradePomPage.addPageValidationListener(gear);
    Page findBreakingChangesPage = new FindBreakingChangesPage(_pagesSwitchControler, SWT.NONE, _dataModel);
    findBreakingChangesPage.setIndex(pageIndex++);
    findBreakingChangesPage.setTitle("Find Breaking Changes");
    Page descriptorsPage = new DescriptorsPage(_pagesSwitchControler, SWT.NONE, _dataModel);
    descriptorsPage.setIndex(pageIndex++);
    descriptorsPage.setTitle("Update Descriptor Files");
    descriptorsPage.addPageValidationListener(gear);
    Page buildServicePage = new BuildServicePage(_pagesSwitchControler, SWT.NONE, _dataModel);
    buildServicePage.setIndex(pageIndex++);
    buildServicePage.setTitle("Build Services");
    Page layoutTemplatePage = new LayoutTemplatePage(_pagesSwitchControler, SWT.NONE, _dataModel);
    layoutTemplatePage.setIndex(pageIndex++);
    layoutTemplatePage.setTitle("Layout Templates");
    layoutTemplatePage.addPageValidationListener(gear);
    Page customJspPage = new CustomJspPage(_pagesSwitchControler, SWT.NONE, _dataModel);
    customJspPage.setIndex(pageIndex++);
    customJspPage.setTitle("Custom Jsp");
    customJspPage.addPageValidationListener(gear);
    // Page extAndThemePage = new ExtAndThemePage( pagesSwitchControler, SWT.NONE,
    // dataModel );
    // extAndThemePage.setIndex( 7 );
    // extAndThemePage.setTitle( "Ext and Theme" );
    Page buildPage = new BuildPage(_pagesSwitchControler, SWT.NONE, _dataModel);
    buildPage.setIndex(pageIndex++);
    buildPage.setTitle("Build");
    Page summaryPage = new SummaryPage(_pagesSwitchControler, SWT.NONE, _dataModel);
    summaryPage.setIndex(pageIndex++);
    summaryPage.setTitle("Summary");
    summaryPage.setNextPage(false);
    summaryPage.addPageNavigateListener(gear);
    _staticPageList.clear();
    _staticPageList.add(welcomePage);
    _staticPageList.add(initConfigureProjectPage);
    _staticPageList.add(upgradePomPage);
    _staticPageList.add(findBreakingChangesPage);
    _staticPageList.add(descriptorsPage);
    _staticPageList.add(buildServicePage);
    _staticPageList.add(layoutTemplatePage);
    _staticPageList.add(customJspPage);
    // staticPageList.add( extAndThemePage );
    _staticPageList.add(buildPage);
    _staticPageList.add(summaryPage);
    resetPages();
    final NavigatorControl navigator = new NavigatorControl(composite, SWT.NONE);
    navigator.addPageNavigateListener(gear);
    navigator.addPageActionListener(gear);
    navigator.setBackground(parent.getBackground());
    _staticPageList.stream().forEach(navigator::addPageActionListener);
    gear.addSelectionChangedListener(navigator);
    gear.addSelectionChangedListener(this);
    gear.addSelectionChangedListener(initConfigureProjectPage);
    gear.addSelectionChangedListener(descriptorsPage);
    gear.addSelectionChangedListener(upgradePomPage);
    gear.addSelectionChangedListener(layoutTemplatePage);
    gear.addSelectionChangedListener(summaryPage);
    GridData navData = new GridData(GridData.FILL_HORIZONTAL);
    navData.grabExcessHorizontalSpace = true;
    navigator.setLayoutData(navData);
    scrolledComposite.setContent(container);
    // scrolledComposite.setMinSize(container.computeSize(SWT.DEFAULT, 670));
    setSelectPage(0);
    parent.addDisposeListener(new DisposeListener() {

        @Override
        public void widgetDisposed(DisposeEvent e) {
            int pageNum = getPageNumber();
            for (int i = 0; i < pageNum; i++) {
                Page page = UpgradeView.getPage(i);
                String pageId = page.getPageId();
                PageAction pageAction = page.getSelectedAction();
                if (pageAction != null) {
                    UpgradeSettingsUtil.storeProperty(pageId, pageAction.getPageActionName());
                }
            }
        }
    });
    IActionBars actionBars = getViewSite().getActionBars();
    final IToolBarManager mgr = actionBars.getToolBarManager();
    final IAction restart = new Action("Restart Upgrade", ImageDescriptor.createFromURL(bundle.getEntry("icons/e16/restart.gif"))) {

        @Override
        public void run() {
            _restartUpgradeTool();
        }
    };
    final IAction showAllPages = new Action("Show All Pages", ImageDescriptor.createFromURL(bundle.getEntry("icons/e16/showall.gif"))) {

        @Override
        public void run() {
            StringBuilder desriptors = new StringBuilder("If you fail to import projects, you can skip step 2 by ");
            desriptors.append("doing the following steps:\n");
            desriptors.append("   1.upgrade SDK 6.2 to SDK 7.0 manually\n");
            desriptors.append("      or use blade cli to create a Liferay workspace for your SDK\n");
            desriptors.append("   2.import projects you want to upgrade into Eclipse workspace\n");
            desriptors.append("   3.click \"yes\" to show all the steps");
            Boolean openNewLiferayProjectWizard = MessageDialog.openQuestion(UIUtil.getActiveShell(), "Show All Pages", desriptors.toString());
            if (openNewLiferayProjectWizard) {
                showAllPages();
            }
        }
    };
    mgr.add(restart);
    mgr.add(showAllPages);
}
Also used : DisposeListener(org.eclipse.swt.events.DisposeListener) IAction(org.eclipse.jface.action.IAction) Action(org.eclipse.jface.action.Action) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) DisposeEvent(org.eclipse.swt.events.DisposeEvent) GridLayout(org.eclipse.swt.layout.GridLayout) StackLayout(org.eclipse.swt.custom.StackLayout) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) IActionBars(org.eclipse.ui.IActionBars) Composite(org.eclipse.swt.widgets.Composite) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) IAction(org.eclipse.jface.action.IAction) IToolBarManager(org.eclipse.jface.action.IToolBarManager) GridData(org.eclipse.swt.layout.GridData)

Aggregations

IAction (org.eclipse.jface.action.IAction)387 Action (org.eclipse.jface.action.Action)147 ImageDescriptor (org.eclipse.jface.resource.ImageDescriptor)79 IWorkbenchAction (org.eclipse.ui.actions.ActionFactory.IWorkbenchAction)57 Separator (org.eclipse.jface.action.Separator)55 WebLaunchAction (com.centurylink.mdw.plugin.actions.WebLaunchActions.WebLaunchAction)50 MenuManager (org.eclipse.jface.action.MenuManager)39 IMenuManager (org.eclipse.jface.action.IMenuManager)37 ArrayList (java.util.ArrayList)36 ActionContributionItem (org.eclipse.jface.action.ActionContributionItem)35 IContributionItem (org.eclipse.jface.action.IContributionItem)31 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)26 WorkflowElement (com.centurylink.mdw.plugin.designer.model.WorkflowElement)22 WorkflowProject (com.centurylink.mdw.plugin.project.model.WorkflowProject)18 ActionRegistry (org.eclipse.gef.ui.actions.ActionRegistry)16 IToolBarManager (org.eclipse.jface.action.IToolBarManager)16 IEditorPart (org.eclipse.ui.IEditorPart)15 Point (org.eclipse.swt.graphics.Point)14 Iterator (java.util.Iterator)13 Menu (org.eclipse.swt.widgets.Menu)13