Search in sources :

Example 1 with MasterDetailsContentNodePart

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

the class OpenPortletResourceAction method selectAndRevealItem.

/**
 * @param editor
 *            TODO: need to work on to fix to reveal the selected node
 */
protected void selectAndRevealItem(IEditorPart editorPart) {
    if (this.editorPart instanceof SapphireEditor) {
        SapphireEditorForXml editor = (SapphireEditorForXml) editorPart;
        PortletNode portletNavigatorNode = (PortletNode) selectedNode;
        Element selectedModelElement = portletNavigatorNode.getModel();
        if (selectedModelElement != null) {
            MasterDetailsEditorPage mdepDetailsEditorPage = (MasterDetailsEditorPage) editor.getActivePageInstance();
            if (mdepDetailsEditorPage != null) {
                MasterDetailsContentOutline contentOutline = mdepDetailsEditorPage.outline();
                MasterDetailsContentNodePart rootNode = contentOutline.getRoot();
                if (rootNode != null) {
                    MasterDetailsContentNodeList nodes = rootNode.nodes();
                    MasterDetailsContentNodePart portletAppNode = nodes.visible().get(0);
                    MasterDetailsContentNodePart portletsNode = portletAppNode.findNode(_PORTLETS_NODE_LABEL);
                    if (portletsNode != null) {
                        if (selectedModelElement instanceof Portlet) {
                            Portlet selectedPortlet = (Portlet) selectedModelElement;
                            for (MasterDetailsContentNodePart childNode : portletsNode.nodes().visible()) {
                                String selectedPortletName = selectedPortlet.getPortletName().content();
                                if (childNode.getModelElement() instanceof Portlet) {
                                    Portlet mpContentNodePortlet = (Portlet) childNode.getModelElement();
                                    String mpContentNodePortletName = mpContentNodePortlet.getPortletName().content();
                                    if (selectedPortletName.equals(mpContentNodePortletName)) {
                                        childNode.select();
                                        childNode.setExpanded(true);
                                        break;
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
Also used : MasterDetailsContentNodeList(org.eclipse.sapphire.ui.forms.MasterDetailsContentNodeList) MasterDetailsContentNodePart(org.eclipse.sapphire.ui.forms.MasterDetailsContentNodePart) Portlet(com.liferay.ide.portlet.core.model.Portlet) SapphireEditorForXml(org.eclipse.sapphire.ui.swt.xml.editor.SapphireEditorForXml) MasterDetailsEditorPage(org.eclipse.sapphire.ui.forms.swt.MasterDetailsEditorPage) SapphireEditor(org.eclipse.sapphire.ui.SapphireEditor) Element(org.eclipse.sapphire.Element) MasterDetailsContentOutline(org.eclipse.sapphire.ui.forms.MasterDetailsContentOutline) PortletNode(com.liferay.ide.portlet.ui.navigator.PortletNode)

Example 2 with MasterDetailsContentNodePart

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

the class CreatePortletActionHandler method run.

/**
 * (non-Javadoc)
 *
 * @see
 * SapphireActionHandler#run(org.eclipse.sapphire.ui.
 * SapphireRenderingContext)
 */
@Override
protected Object run(Presentation context) {
    PortletApp rootModel = (PortletApp) context.part().getModelElement();
    Portlet portlet = rootModel.getPortlets().insert();
    // Open the dialog to capture the mandatory properties
    SapphireDialog dialog = new SapphireDialog(((SwtPresentation) context).shell(), portlet, DefinitionLoader.sdef(PortletXmlEditor.class).dialog());
    if ((dialog != null) && (Dialog.OK == dialog.open())) {
        // Select the node
        MasterDetailsEditorPagePart page = getPart().nearest(MasterDetailsEditorPagePart.class);
        MasterDetailsContentNodePart root = page.outline().getRoot();
        MasterDetailsContentNodePart node = root.findNode(portlet);
        if (node != null) {
            node.select();
        }
        try {
            rootModel.resource().save();
        } catch (ResourceStoreException rse) {
        // Log it in PorletUI Plugin
        }
        return portlet;
    } else {
        rootModel.getPortlets().remove(portlet);
        portlet = null;
        try {
            rootModel.resource().save();
        } catch (ResourceStoreException rse) {
        // Log it in PorletUI Plugin
        }
        return null;
    }
}
Also used : ResourceStoreException(org.eclipse.sapphire.modeling.ResourceStoreException) Portlet(com.liferay.ide.portlet.core.model.Portlet) MasterDetailsContentNodePart(org.eclipse.sapphire.ui.forms.MasterDetailsContentNodePart) MasterDetailsEditorPagePart(org.eclipse.sapphire.ui.forms.MasterDetailsEditorPagePart) SapphireDialog(org.eclipse.sapphire.ui.forms.swt.SapphireDialog) PortletApp(com.liferay.ide.portlet.core.model.PortletApp)

Example 3 with MasterDetailsContentNodePart

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

the class DefinePortletEventHandler method run.

/**
 * (non-Javadoc)
 *
 * @see
 * SapphireActionHandler#run(org.eclipse.sapphire.ui.
 * SapphireRenderingContext)
 */
@Override
protected Object run(Presentation context) {
    PortletApp rootModel = (PortletApp) context.part().getModelElement();
    EventDefinition eventDefintion = rootModel.getEventDefinitions().insert();
    // Select the node
    MasterDetailsEditorPagePart page = getPart().nearest(MasterDetailsEditorPagePart.class);
    MasterDetailsContentNodePart root = page.outline().getRoot();
    MasterDetailsContentNodePart node = root.findNode(eventDefintion);
    if (node != null) {
        node.select();
    }
    return eventDefintion;
}
Also used : MasterDetailsContentNodePart(org.eclipse.sapphire.ui.forms.MasterDetailsContentNodePart) MasterDetailsEditorPagePart(org.eclipse.sapphire.ui.forms.MasterDetailsEditorPagePart) EventDefinition(com.liferay.ide.portlet.core.model.EventDefinition) PortletApp(com.liferay.ide.portlet.core.model.PortletApp)

Aggregations

MasterDetailsContentNodePart (org.eclipse.sapphire.ui.forms.MasterDetailsContentNodePart)3 Portlet (com.liferay.ide.portlet.core.model.Portlet)2 PortletApp (com.liferay.ide.portlet.core.model.PortletApp)2 MasterDetailsEditorPagePart (org.eclipse.sapphire.ui.forms.MasterDetailsEditorPagePart)2 EventDefinition (com.liferay.ide.portlet.core.model.EventDefinition)1 PortletNode (com.liferay.ide.portlet.ui.navigator.PortletNode)1 Element (org.eclipse.sapphire.Element)1 ResourceStoreException (org.eclipse.sapphire.modeling.ResourceStoreException)1 SapphireEditor (org.eclipse.sapphire.ui.SapphireEditor)1 MasterDetailsContentNodeList (org.eclipse.sapphire.ui.forms.MasterDetailsContentNodeList)1 MasterDetailsContentOutline (org.eclipse.sapphire.ui.forms.MasterDetailsContentOutline)1 MasterDetailsEditorPage (org.eclipse.sapphire.ui.forms.swt.MasterDetailsEditorPage)1 SapphireDialog (org.eclipse.sapphire.ui.forms.swt.SapphireDialog)1 SapphireEditorForXml (org.eclipse.sapphire.ui.swt.xml.editor.SapphireEditorForXml)1