Search in sources :

Example 11 with IWorkbenchPartSite

use of org.eclipse.ui.IWorkbenchPartSite in project liferay-ide by liferay.

the class EditorSiteAdapterService method convert.

@Override
public <A> A convert(Object object, Class<A> adapterType) {
    A retval = null;
    if (IEditorSite.class.equals(adapterType)) {
        SapphirePart sapphirePart = context(SapphirePart.class);
        Element localElement = sapphirePart.getLocalModelElement();
        ITextEditor editor = localElement.adapt(ITextEditor.class);
        IWorkbenchPartSite editorSite = editor.getSite();
        if (editorSite instanceof IEditorSite) {
            retval = adapterType.cast(editorSite);
        }
    }
    return retval;
}
Also used : IWorkbenchPartSite(org.eclipse.ui.IWorkbenchPartSite) ITextEditor(org.eclipse.ui.texteditor.ITextEditor) Element(org.eclipse.sapphire.Element) SapphirePart(org.eclipse.sapphire.ui.SapphirePart) IEditorSite(org.eclipse.ui.IEditorSite)

Example 12 with IWorkbenchPartSite

use of org.eclipse.ui.IWorkbenchPartSite in project liferay-ide by liferay.

the class IDEFormEditor method _validateEdit.

private void _validateEdit(IEditorInput input) {
    InputContext context = fInputContextManager.getContext(input);
    if (!context.validateEdit()) {
        IWorkbenchPartSite site = getSite();
        Shell shell = site.getShell();
        shell.getDisplay().asyncExec(new Runnable() {

            public void run() {
                doRevert(context.getInput());
                context.setValidated(false);
            }
        });
    }
}
Also used : IWorkbenchPartSite(org.eclipse.ui.IWorkbenchPartSite) Shell(org.eclipse.swt.widgets.Shell) InputContext(com.liferay.ide.ui.editor.InputContext)

Example 13 with IWorkbenchPartSite

use of org.eclipse.ui.IWorkbenchPartSite in project webtools.sourceediting by eclipse.

the class ConfigurationPointCalculator method getConfigurationPoints.

public String[] getConfigurationPoints() {
    List points = new ArrayList(2);
    IWorkbenchPartSite site = null;
    if (fPart != null) {
        site = fPart.getSite();
        if (site != null) {
            String id = site.getId();
            if (id != null && id.length() > 0 && !id.equals(fRootClass.getName()))
                points.add(id);
        }
        if (site instanceof MultiPageEditorSite) {
            String multipageID = ((MultiPageEditorSite) site).getMultiPageEditor().getSite().getId();
            if (!points.contains(multipageID))
                points.add(multipageID);
            // $NON-NLS-1$
            String sourcePageID = ((MultiPageEditorSite) site).getMultiPageEditor().getSite().getId() + ".source";
            if (!points.contains(sourcePageID))
                points.add(sourcePageID);
        }
        if (site instanceof MultiPageEditorSite) {
            String multipageClassName = ((MultiPageEditorSite) site).getMultiPageEditor().getClass().getName();
            if (!points.contains(multipageClassName))
                points.add(multipageClassName);
        }
        Class editorClass = fPart.getClass();
        while (editorClass != null && fRootClass != null && !editorClass.equals(fRootClass)) {
            if (!points.contains(editorClass.getName()))
                points.add(editorClass.getName());
            editorClass = editorClass.getSuperclass();
        }
    }
    if (fContentType != null) {
        IContentType contentType = Platform.getContentTypeManager().getContentType(fContentType);
        while (contentType != null && !contentType.getId().equals(IContentTypeManager.CT_TEXT)) {
            if (!points.contains(contentType.getId()))
                points.add(contentType.getId());
            contentType = contentType.getBaseType();
        }
    }
    if (fRootClass != null && !points.contains(fRootClass.getName()))
        points.add(fRootClass.getName());
    return (String[]) points.toArray(new String[0]);
}
Also used : IWorkbenchPartSite(org.eclipse.ui.IWorkbenchPartSite) ArrayList(java.util.ArrayList) List(java.util.List) ArrayList(java.util.ArrayList) IContentType(org.eclipse.core.runtime.content.IContentType) MultiPageEditorSite(org.eclipse.ui.part.MultiPageEditorSite)

Example 14 with IWorkbenchPartSite

use of org.eclipse.ui.IWorkbenchPartSite in project webtools.sourceediting by eclipse.

the class XSDMultiPageEditorContributor method setActivePage.

/*
   * (non-JavaDoc) Method declared in
   * AbstractMultiPageEditorActionBarContributor.
   */
public void setActivePage(IEditorPart part) {
    if (activeEditorPart == part)
        return;
    activeEditorPart = part;
    IActionBars actionBars = getActionBars();
    boolean isSource = false;
    if (activeEditorPart != null && activeEditorPart instanceof ITextEditor) {
        isSource = true;
        zoomInRetargetAction.setEnabled(false);
        zoomOutRetargetAction.setEnabled(false);
        captureScreenAction.setEnabled(false);
        activateSourcePage(activeEditorPart, true);
    } else {
        activateSourcePage(xsdEditor, false);
        if (part instanceof InternalXSDMultiPageEditor) {
            xsdEditor = (InternalXSDMultiPageEditor) part;
        }
        if (xsdEditor != null) {
            // cs: here's we ensure the UNDO and REDO actions are available when
            // the design view is active
            IWorkbenchPartSite site = xsdEditor.getSite();
            if (site instanceof IEditorSite) {
                ITextEditor textEditor = xsdEditor.getTextEditor();
                IActionBars siteActionBars = ((IEditorSite) site).getActionBars();
                siteActionBars.setGlobalActionHandler(ITextEditorActionConstants.UNDO, getAction(textEditor, ITextEditorActionConstants.UNDO));
                siteActionBars.setGlobalActionHandler(ITextEditorActionConstants.REDO, getAction(textEditor, ITextEditorActionConstants.REDO));
                siteActionBars.updateActionBars();
            }
            Object adapter = xsdEditor.getAdapter(ActionRegistry.class);
            if (adapter instanceof ActionRegistry) {
                ActionRegistry registry = (ActionRegistry) adapter;
                actionBars.setGlobalActionHandler(ActionFactory.DELETE.getId(), registry.getAction(DeleteAction.ID));
                actionBars.setGlobalActionHandler(GEFActionConstants.ZOOM_IN, registry.getAction(GEFActionConstants.ZOOM_IN));
                actionBars.setGlobalActionHandler(GEFActionConstants.ZOOM_OUT, registry.getAction(GEFActionConstants.ZOOM_OUT));
                actionBars.setGlobalActionHandler(ActionFactory.PRINT.getId(), registry.getAction(ActionFactory.PRINT.getId()));
                actionBars.setGlobalActionHandler(ActionFactory.SELECT_ALL.getId(), registry.getAction(ActionFactory.SELECT_ALL.getId()));
                zoomInRetargetAction.setEnabled(true);
                zoomOutRetargetAction.setEnabled(true);
                captureScreenAction.setEnabled(true);
            }
        }
    }
    if (actionBars != null) {
        // update menu bar and tool bar
        actionBars.updateActionBars();
    }
    if (zoomComboContributionItem != null) {
        zoomComboContributionItem.setVisible(!isSource);
        zoomComboContributionItem.update();
        // Bug 254772 - parent contribution manager should not be null.  We added this item already.
        // Force the ToolBarManager to update/redraw the items
        zoomComboContributionItem.getParent().update(true);
    }
}
Also used : IWorkbenchPartSite(org.eclipse.ui.IWorkbenchPartSite) ITextEditor(org.eclipse.ui.texteditor.ITextEditor) ActionRegistry(org.eclipse.gef.ui.actions.ActionRegistry) IActionBars(org.eclipse.ui.IActionBars) IEditorSite(org.eclipse.ui.IEditorSite)

Example 15 with IWorkbenchPartSite

use of org.eclipse.ui.IWorkbenchPartSite in project webtools.sourceediting by eclipse.

the class XSDSearchReferencesGroupActionDelegate method fillMenu.

protected void fillMenu(Menu menu) {
    try {
        if (fSelection == null) {
            return;
        }
        if (workbenchPart != null) {
            IWorkbenchPartSite site = workbenchPart.getSite();
            if (site == null)
                return;
            IEditorPart editor = site.getPage().getActiveEditor();
            if (editor != null) {
                ReferencesSearchGroup referencesGroup = new ReferencesSearchGroup(editor);
                XSDSearchGroupSubMenu subMenu = new XSDSearchGroupSubMenu(referencesGroup);
                subMenu.fill(menu, -1);
            }
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}
Also used : IWorkbenchPartSite(org.eclipse.ui.IWorkbenchPartSite) IEditorPart(org.eclipse.ui.IEditorPart)

Aggregations

IWorkbenchPartSite (org.eclipse.ui.IWorkbenchPartSite)73 IWorkbenchPart (org.eclipse.ui.IWorkbenchPart)13 ISelection (org.eclipse.jface.viewers.ISelection)12 IEditorPart (org.eclipse.ui.IEditorPart)12 ArrayList (java.util.ArrayList)10 MenuManager (org.eclipse.jface.action.MenuManager)9 ISelectionProvider (org.eclipse.jface.viewers.ISelectionProvider)9 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)9 Composite (org.eclipse.swt.widgets.Composite)9 Display (org.eclipse.swt.widgets.Display)9 Shell (org.eclipse.swt.widgets.Shell)9 IWorkbenchWindow (org.eclipse.ui.IWorkbenchWindow)9 Menu (org.eclipse.swt.widgets.Menu)7 IEditorSite (org.eclipse.ui.IEditorSite)7 IWorkbenchPage (org.eclipse.ui.IWorkbenchPage)7 SWT (org.eclipse.swt.SWT)6 PartInitException (org.eclipse.ui.PartInitException)6 List (java.util.List)5 IToolBarManager (org.eclipse.jface.action.IToolBarManager)4 Separator (org.eclipse.jface.action.Separator)4