Search in sources :

Example 11 with Element

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

the class HierarchyBrowseActionHandler method browse.

@Override
public String browse(Presentation context) {
    Element element = getModelElement();
    Property property = property();
    IProject project = element.adapt(IProject.class);
    try {
        IJavaSearchScope scope = null;
        TypeSelectionExtension extension = null;
        String javaType = _getClassReferenceType(property);
        if (javaType != null) {
            scope = SearchEngine.createHierarchyScope(JavaCore.create(project).findType(javaType));
        } else {
            MessageDialog.openInformation(((SwtPresentation) context).shell(), Msgs.browseImplementation, Msgs.validClassImplProperty);
            return null;
        }
        SelectionDialog dlg = JavaUI.createTypeDialog(((SwtPresentation) context).shell(), null, scope, IJavaElementSearchConstants.CONSIDER_CLASSES, false, StringPool.DOUBLE_ASTERISK, extension);
        String title = property.definition().getLabel(true, CapitalizationType.TITLE_STYLE, false);
        dlg.setTitle(Msgs.select + title);
        if (dlg.open() == SelectionDialog.OK) {
            Object[] results = dlg.getResult();
            assert results != null && results.length == 1;
            if (results[0] instanceof IType) {
                return ((IType) results[0]).getFullyQualifiedName();
            }
        }
    } catch (JavaModelException jme) {
        PortletUIPlugin.logError(jme);
    }
    return null;
}
Also used : JavaModelException(org.eclipse.jdt.core.JavaModelException) IJavaSearchScope(org.eclipse.jdt.core.search.IJavaSearchScope) Element(org.eclipse.sapphire.Element) TypeSelectionExtension(org.eclipse.jdt.ui.dialogs.TypeSelectionExtension) Property(org.eclipse.sapphire.Property) SelectionDialog(org.eclipse.ui.dialogs.SelectionDialog) IProject(org.eclipse.core.resources.IProject) IType(org.eclipse.jdt.core.IType)

Example 12 with Element

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

the class LiferayPortletNameValidationService method compute.

@Override
protected Status compute() {
    Element modelElement = context(Element.class);
    if (!modelElement.disposed()) {
        liferayPortletName = (String) modelElement.property(context(ValueProperty.class)).content();
        IProject project = modelElement.adapt(IProject.class);
        String[] portletNames = new PortletDescriptorHelper(project).getAllPortletNames();
        if (portletNames != null) {
            for (String portletName : portletNames) {
                if (portletName.equals(liferayPortletName)) {
                    return Status.createOkStatus();
                }
            }
        }
    }
    return Status.createErrorStatus(Resources.bind(StringEscapeUtils.unescapeJava(Resources.portletNameInvalid), new Object[] { liferayPortletName }));
}
Also used : PortletDescriptorHelper(com.liferay.ide.portlet.core.dd.PortletDescriptorHelper) Element(org.eclipse.sapphire.Element) IProject(org.eclipse.core.resources.IProject)

Example 13 with Element

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

the class LiferayScriptPossibleValuesService method compute.

@Override
protected void compute(Set<String> values) {
    Element modeElement = context(Element.class);
    List<FileExtensions> exts = modeElement.parent().definition().getAnnotations(FileExtensions.class);
    if ((exts != null) && (exts.size() > 0)) {
        this.type = exts.get(0).expr();
        IProject project = modeElement.adapt(IProject.class);
        if (project != null) {
            IFolder webappRoot = CoreUtil.getDefaultDocrootFolder(project);
            if (webappRoot != null) {
                IPath location = webappRoot.getLocation();
                if (location != null) {
                    if (location.toFile().exists()) {
                        values.addAll(new PropertiesVisitor().visitScriptFiles(webappRoot, type, values));
                    }
                }
            }
        }
    }
}
Also used : IPath(org.eclipse.core.runtime.IPath) Element(org.eclipse.sapphire.Element) FileExtensions(org.eclipse.sapphire.modeling.annotations.FileExtensions) IProject(org.eclipse.core.resources.IProject) IFolder(org.eclipse.core.resources.IFolder)

Example 14 with Element

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

the class PortletStyleValidationService method compute.

@Override
protected Status compute() {
    Element modelElement = context(Element.class);
    if (!modelElement.disposed() && modelElement instanceof PortletStyleElement) {
        Path path = (Path) modelElement.property(context(ValueProperty.class)).content();
        if (path != null) {
            String name = path.lastSegment();
            IProject project = modelElement.adapt(IProject.class);
            boolean fileExisted = new FileCheckVisitor().checkFiles(project, name);
            if (!fileExisted) {
                return Status.createErrorStatus("File " + path.toPortableString() + " is not existed");
            }
        } else {
            return Status.createErrorStatus("Can not set empty value");
        }
    }
    return Status.createOkStatus();
}
Also used : Path(org.eclipse.sapphire.modeling.Path) PortletStyleElement(com.liferay.ide.portlet.core.lfportlet.model.PortletStyleElement) Element(org.eclipse.sapphire.Element) PortletStyleElement(com.liferay.ide.portlet.core.lfportlet.model.PortletStyleElement) ValueProperty(org.eclipse.sapphire.ValueProperty) IProject(org.eclipse.core.resources.IProject)

Example 15 with Element

use of org.eclipse.sapphire.Element 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)

Aggregations

Element (org.eclipse.sapphire.Element)58 IProject (org.eclipse.core.resources.IProject)13 IFile (org.eclipse.core.resources.IFile)12 Property (org.eclipse.sapphire.Property)8 ValueProperty (org.eclipse.sapphire.ValueProperty)8 IPath (org.eclipse.core.runtime.IPath)7 Event (org.eclipse.sapphire.Event)6 PropertyEvent (org.eclipse.sapphire.PropertyEvent)6 FilteredListener (org.eclipse.sapphire.FilteredListener)5 Listener (org.eclipse.sapphire.Listener)5 Path (org.eclipse.sapphire.modeling.Path)5 IType (org.eclipse.jdt.core.IType)4 JavaModelException (org.eclipse.jdt.core.JavaModelException)4 DisposeEvent (org.eclipse.sapphire.DisposeEvent)4 SapphirePart (org.eclipse.sapphire.ui.SapphirePart)4 Task (com.liferay.ide.kaleo.core.model.Task)3 DynamicElement (com.liferay.ide.portal.core.structures.model.DynamicElement)3 ArrayList (java.util.ArrayList)3 IWorkspaceRoot (org.eclipse.core.resources.IWorkspaceRoot)3 IClasspathEntry (org.eclipse.jdt.core.IClasspathEntry)3