Search in sources :

Example 1 with SapphirePart

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

the class ChangeTaskAssignmentsActionHandler method _task.

private Task _task(Presentation context) {
    SapphirePart spPart = context.part();
    Element element = spPart.getLocalModelElement();
    return element.nearest(Task.class);
}
Also used : Element(org.eclipse.sapphire.Element) SapphirePart(org.eclipse.sapphire.ui.SapphirePart)

Example 2 with SapphirePart

use of org.eclipse.sapphire.ui.SapphirePart 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 3 with SapphirePart

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

the class TemplateOpenActionHandler method notification.

protected Notification notification(Presentation context) {
    ISapphirePart part = context.part();
    if (part instanceof DetailSectionPart) {
        DetailSectionPart pageBook = part.nearest(DetailSectionPart.class);
        FormPart currentPage = pageBook.getCurrentPage();
        Element element = currentPage.getLocalModelElement();
        return element.nearest(Notification.class);
    }
    SapphirePart spPart = context.part();
    Element element = spPart.getLocalModelElement();
    return element.nearest(Notification.class);
}
Also used : FormPart(org.eclipse.sapphire.ui.forms.FormPart) Element(org.eclipse.sapphire.Element) ISapphirePart(org.eclipse.sapphire.ui.ISapphirePart) DetailSectionPart(org.eclipse.sapphire.ui.forms.DetailSectionPart) SapphirePart(org.eclipse.sapphire.ui.SapphirePart) ISapphirePart(org.eclipse.sapphire.ui.ISapphirePart)

Example 4 with SapphirePart

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

the class ShowDiagramPartActionHandler method run.

@Override
protected Object run(Presentation context) {
    SapphireDiagramEditorPagePart diagramPart = context.part().nearest(SapphireDiagramEditorPagePart.class);
    if (diagramPart != null) {
        LabelProvider labelProvider = new LabelProvider() {

            @Override
            public Image getImage(Object element) {
                if (element instanceof DiagramNodePart) {
                    DiagramNodePart diagramNodePart = (DiagramNodePart) element;
                    Element modelElement = diagramNodePart.getLocalModelElement();
                    return diagramPart.getSwtResourceCache().image(modelElement.type().image());
                } else if (element instanceof DiagramConnectionPart) {
                    return diagramPart.getSwtResourceCache().image(Transition.TYPE.image());
                } else {
                    return diagramPart.getSwtResourceCache().image(WorkflowNode.TYPE.image());
                }
            }

            @Override
            public String getText(Object element) {
                if (element instanceof DiagramNodePart) {
                    return ((DiagramNodePart) element).getId();
                } else if (element instanceof DiagramConnectionPart) {
                    return ((DiagramConnectionPart) element).getLabel();
                } else {
                    if (element != null) {
                        return element.toString();
                    }
                    return "";
                }
            }
        };
        ElementListSelectionDialog dialog = new ElementListSelectionDialog(((SwtPresentation) context).shell(), labelProvider);
        List<SapphirePart> parts = new ArrayList<>();
        parts.addAll(diagramPart.getNodes());
        parts.addAll(diagramPart.getConnections());
        dialog.setElements(parts.toArray());
        dialog.setMultipleSelection(false);
        dialog.setHelpAvailable(false);
        dialog.setTitle("Find Part");
        dialog.setMessage("Select part:");
        dialog.open();
        Object[] result = dialog.getResult();
        if ((result != null) && (result.length == 1)) {
            // select node in diagram
            ISapphirePart part = (ISapphirePart) result[0];
            if (part instanceof DiagramConnectionPart || part instanceof DiagramNodePart) {
                /*
					 * diagramPart.setSelections( ReadOnlyListFactory.create(
					 * part ) );
					 */
                SapphireDiagramEditor diagramEditor = diagramPart.adapt(SapphireDiagramEditor.class);
                GraphicalViewer viewer = diagramEditor.getGraphicalViewer();
                GraphicalEditPart editpart = diagramEditor.getGraphicalEditPart(part);
                if (editpart != null) {
                    // Force a layout first.
                    viewer.flush();
                    viewer.select(editpart);
                    viewer.reveal(editpart);
                }
            }
        }
    }
    return null;
}
Also used : GraphicalViewer(org.eclipse.gef.GraphicalViewer) Element(org.eclipse.sapphire.Element) ArrayList(java.util.ArrayList) SapphireDiagramEditor(org.eclipse.sapphire.ui.swt.gef.SapphireDiagramEditor) ISapphirePart(org.eclipse.sapphire.ui.ISapphirePart) SapphirePart(org.eclipse.sapphire.ui.SapphirePart) ISapphirePart(org.eclipse.sapphire.ui.ISapphirePart) SapphireDiagramEditorPagePart(org.eclipse.sapphire.ui.diagram.editor.SapphireDiagramEditorPagePart) ElementListSelectionDialog(org.eclipse.ui.dialogs.ElementListSelectionDialog) DiagramConnectionPart(org.eclipse.sapphire.ui.diagram.DiagramConnectionPart) LabelProvider(org.eclipse.jface.viewers.LabelProvider) GraphicalEditPart(org.eclipse.gef.GraphicalEditPart) DiagramNodePart(org.eclipse.sapphire.ui.diagram.editor.DiagramNodePart)

Aggregations

Element (org.eclipse.sapphire.Element)4 SapphirePart (org.eclipse.sapphire.ui.SapphirePart)4 ISapphirePart (org.eclipse.sapphire.ui.ISapphirePart)2 ArrayList (java.util.ArrayList)1 GraphicalEditPart (org.eclipse.gef.GraphicalEditPart)1 GraphicalViewer (org.eclipse.gef.GraphicalViewer)1 LabelProvider (org.eclipse.jface.viewers.LabelProvider)1 DiagramConnectionPart (org.eclipse.sapphire.ui.diagram.DiagramConnectionPart)1 DiagramNodePart (org.eclipse.sapphire.ui.diagram.editor.DiagramNodePart)1 SapphireDiagramEditorPagePart (org.eclipse.sapphire.ui.diagram.editor.SapphireDiagramEditorPagePart)1 DetailSectionPart (org.eclipse.sapphire.ui.forms.DetailSectionPart)1 FormPart (org.eclipse.sapphire.ui.forms.FormPart)1 SapphireDiagramEditor (org.eclipse.sapphire.ui.swt.gef.SapphireDiagramEditor)1 IEditorSite (org.eclipse.ui.IEditorSite)1 IWorkbenchPartSite (org.eclipse.ui.IWorkbenchPartSite)1 ElementListSelectionDialog (org.eclipse.ui.dialogs.ElementListSelectionDialog)1 ITextEditor (org.eclipse.ui.texteditor.ITextEditor)1