Search in sources :

Example 56 with Element

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

the class TransitionPossibleValuesService method compute.

@Override
protected void compute(Set<String> values) {
    /*
		 * if we are a task return states and tasks, if we are a state, find
		 * tasks.
		 */
    Element modelElement = context(Element.class);
    WorkflowDefinition workflow = modelElement.nearest(WorkflowDefinition.class);
    if (workflow == null) {
        workflow = modelElement.adapt(WorkflowDefinition.class);
    }
    if (workflow != null) {
        addNodeNames(values, workflow.getTasks());
        addNodeNames(values, workflow.getStates());
        addNodeNames(values, workflow.getConditions());
        addNodeNames(values, workflow.getForks());
        addNodeNames(values, workflow.getJoins());
        Value<Version> schemaVersion = workflow.getSchemaVersion();
        Version version = schemaVersion.content();
        if (version.compareTo(new Version("6.2")) >= 0) {
            addNodeNames(values, workflow.getJoinXors());
        }
    }
}
Also used : Version(org.eclipse.sapphire.Version) Element(org.eclipse.sapphire.Element) WorkflowDefinition(com.liferay.ide.kaleo.core.model.WorkflowDefinition)

Example 57 with Element

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

the class StructuresTests method testDDMStructureBasicDocumentRead.

@Test
public void testDDMStructureBasicDocumentRead() throws Exception {
    final Element element = getElementFromFile(getCurrentProject(), DDM_STRUCTURE_BASIC_DOCUMENT, Root.TYPE);
    setElement(element);
    final Root root = element.nearest(Root.class);
    assertNotNull(root);
    assertEquals("en_US", root.getAvailableLocales().content());
    assertEquals("en_US", root.getDefaultLocale().content());
    final ElementList<DynamicElement> dynamicElements = root.getDynamicElements();
    assertEquals(154, dynamicElements.size());
    final DynamicElement dynamicElement = dynamicElements.get(1);
    assertNotNull(dynamicElement);
    assertEquals("string", dynamicElement.getDataType().content(false));
    assertEquals("ClimateForcast_COMMAND_LINE", dynamicElement.getName().content(false));
    assertEquals("text", dynamicElement.getType().content(false));
    final DynamicElementMetadata metaData = dynamicElement.getMetadata().content(false);
    assertNotNull(metaData);
    assertEquals("en_US", metaData.getLocale().content(false));
    final ElementList<Entry> entries = metaData.getEntries();
    assertNotNull(entries);
    assertEquals(4, entries.size());
    final Entry entry = entries.get(2);
    assertNotNull(entry);
    assertEquals("required", entry.getName().content(false));
    assertEquals("false", entry.getValue().content(false));
}
Also used : Entry(com.liferay.ide.portal.core.structures.model.Entry) Root(com.liferay.ide.portal.core.structures.model.Root) DynamicElementMetadata(com.liferay.ide.portal.core.structures.model.DynamicElementMetadata) DynamicElement(com.liferay.ide.portal.core.structures.model.DynamicElement) DynamicElement(com.liferay.ide.portal.core.structures.model.DynamicElement) Element(org.eclipse.sapphire.Element) Test(org.junit.Test)

Example 58 with Element

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

the class StructuresTests method getElementFromFile.

protected Element getElementFromFile(IProject project, IPath filePath, ElementType type) throws Exception {
    final String filePathValue = filePath.toOSString();
    final IFile file = createFile(project, filePathValue, this.getClass().getResourceAsStream(filePathValue));
    assertEquals(file.getFullPath().lastSegment(), filePath.lastSegment());
    final InputStream contents = file.getContents();
    final Element element = type.instantiate(new RootXmlResource(new XmlResourceStore(contents)));
    contents.close();
    return element;
}
Also used : IFile(org.eclipse.core.resources.IFile) InputStream(java.io.InputStream) DynamicElement(com.liferay.ide.portal.core.structures.model.DynamicElement) Element(org.eclipse.sapphire.Element) XmlResourceStore(org.eclipse.sapphire.modeling.xml.XmlResourceStore) RootXmlResource(org.eclipse.sapphire.modeling.xml.RootXmlResource)

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