Search in sources :

Example 51 with Element

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

the class AddDefaultColumnsAction method run.

@Override
protected Object run(Presentation context) {
    Element element = context.part().getLocalModelElement();
    if (element instanceof Entity) {
        String entityName = ((Entity) element).getName().content();
        if (CoreUtil.isNullOrEmpty(entityName)) {
            String title = "Add Liferay Default Columns";
            String message = "The entity name must be specified.";
            MessageDialog.openInformation(UIUtil.getActiveShell(), title, message);
        } else {
            IFile serviceXML = element.adapt(IFile.class);
            new ServiceBuilderDescriptorHelper(serviceXML.getProject()).addDefaultColumns(entityName);
        }
    }
    return null;
}
Also used : Entity(com.liferay.ide.service.core.model.Entity) IFile(org.eclipse.core.resources.IFile) Element(org.eclipse.sapphire.Element) ServiceBuilderDescriptorHelper(com.liferay.ide.service.core.operation.ServiceBuilderDescriptorHelper)

Example 52 with Element

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

the class AddDefaultEntityAction method run.

@Override
protected Object run(Presentation context) {
    Element localModelElement = context.part().getLocalModelElement();
    IFile serviceXML = localModelElement.adapt(IFile.class);
    new ServiceBuilderDescriptorHelper(serviceXML.getProject()).addDefaultEntity();
    return null;
}
Also used : IFile(org.eclipse.core.resources.IFile) Element(org.eclipse.sapphire.Element) ServiceBuilderDescriptorHelper(com.liferay.ide.service.core.operation.ServiceBuilderDescriptorHelper)

Example 53 with Element

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

the class BuildWSDDActionHandler method run.

@Override
protected Object run(Presentation context) {
    Element modelElement = context.part().getModelElement();
    IFile file = modelElement.adapt(IFile.class);
    if (FileUtil.exists(file) && ServiceUIUtil.shouldCreateServiceBuilderJob(file)) {
        new BuildWSDDJob(file.getProject()).schedule();
    }
    return null;
}
Also used : IFile(org.eclipse.core.resources.IFile) Element(org.eclipse.sapphire.Element) BuildWSDDJob(com.liferay.ide.service.core.job.BuildWSDDJob)

Example 54 with Element

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

the class RelationshipResource method _persistRelationship.

private void _persistRelationship() {
    Element element = parent().element();
    ServiceBuilder serviceBuilder = element.nearest(ServiceBuilder.class);
    String fromName = _relationshipObject.getFromName();
    String toName = _relationshipObject.getToName();
    Entity fromEntity = EntityRelationshipService.findEntity(fromName, serviceBuilder);
    Entity toEntity = EntityRelationshipService.findEntity(toName, serviceBuilder);
    if ((fromEntity != null) && (toEntity != null)) {
        Column primaryKeyColumn = null;
        for (Column column : toEntity.getColumns()) {
            if (column.isPrimary().content()) {
                primaryKeyColumn = column;
                break;
            }
        }
        if (primaryKeyColumn != null) {
            Column column = fromEntity.getColumns().insert();
            column.setName(primaryKeyColumn.getName().content());
            column.setType("long");
        }
    }
}
Also used : Entity(com.liferay.ide.service.core.model.Entity) Column(com.liferay.ide.service.core.model.Column) Element(org.eclipse.sapphire.Element) ServiceBuilder(com.liferay.ide.service.core.model.ServiceBuilder)

Example 55 with Element

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

the class NodeNameListener method handleTypedEvent.

@Override
protected void handleTypedEvent(PropertyContentEvent event) {
    Property property = event.property();
    Element element = property.element();
    WorkflowDefinition workflow = element.adapt(WorkflowDefinition.class);
    Map<String, String> eventInfo = new HashMap<>();
    event.fillTracingInfo(eventInfo);
    String oldName = eventInfo.get("before");
    if (oldName == null) {
        oldName = _lastNodeNames.get(property);
    }
    String newName = eventInfo.get("after");
    List<Transition> allTransitions = new ArrayList<>();
    if (workflow != null) {
        ElementList<Condition> allConditions = workflow.getConditions();
        ElementList<Fork> allForks = workflow.getForks();
        ElementList<Join> allJoins = workflow.getJoins();
        ElementList<State> allStates = workflow.getStates();
        ElementList<Task> allTasks = workflow.getTasks();
        for (Condition condition : allConditions) {
            ElementList<Transition> conditionTransitions = condition.getTransitions();
            for (Transition transition : conditionTransitions) {
                allTransitions.add(transition);
            }
        }
        for (Fork fork : allForks) {
            ElementList<Transition> forkTransitions = fork.getTransitions();
            for (Transition transition : forkTransitions) {
                allTransitions.add(transition);
            }
        }
        for (Join join : allJoins) {
            ElementList<Transition> joinTransitions = join.getTransitions();
            for (Transition transition : joinTransitions) {
                allTransitions.add(transition);
            }
        }
        for (State state : allStates) {
            ElementList<Transition> stateTransitions = state.getTransitions();
            for (Transition transition : stateTransitions) {
                allTransitions.add(transition);
            }
        }
        for (Task task : allTasks) {
            ElementList<Transition> taskTransitions = task.getTransitions();
            for (Transition transition : taskTransitions) {
                allTransitions.add(transition);
            }
        }
    }
    for (Transition transition : allTransitions) {
        String targetName = transition.getTarget().toString();
        if (targetName.equals(oldName)) {
            if (newName != null) {
                transition.setTarget(newName);
                if (_lastNodeNames.containsKey(property)) {
                    _lastNodeNames.remove(property);
                }
            } else {
                _lastNodeNames.put(property, oldName);
            }
        }
    }
}
Also used : Condition(com.liferay.ide.kaleo.core.model.Condition) Task(com.liferay.ide.kaleo.core.model.Task) Fork(com.liferay.ide.kaleo.core.model.Fork) HashMap(java.util.HashMap) Element(org.eclipse.sapphire.Element) ArrayList(java.util.ArrayList) WorkflowDefinition(com.liferay.ide.kaleo.core.model.WorkflowDefinition) Join(com.liferay.ide.kaleo.core.model.Join) State(com.liferay.ide.kaleo.core.model.State) Transition(com.liferay.ide.kaleo.core.model.Transition) Property(org.eclipse.sapphire.Property)

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