Search in sources :

Example 6 with Property

use of org.eclipse.sapphire.Property 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 7 with Property

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

the class TransitionTargetListener method handleTypedEvent.

@Override
protected void handleTypedEvent(PropertyContentEvent event) {
    Property property = event.property();
    Transition transition = property.nearest(Transition.class);
    if (transition != null) {
        ReferenceValue<String, Node> targe = transition.getTarget();
        Value<String> transitionName = transition.getName();
        if ((targe.content() != null) && (transitionName.content(false) == null)) {
            String targetName = targe.content();
            String defaultName = targetName;
            Set<String> existingNames = new HashSet<>();
            CanTransition camtransition = transition.nearest(CanTransition.class);
            for (Transition t : camtransition.getTransitions()) {
                Value<String> tName = t.getName();
                if (tName.content() != null) {
                    existingNames.add(tName.content());
                }
            }
            int count = 1;
            while (existingNames.contains(defaultName)) {
                defaultName = targetName + "_" + count++;
            }
            transition.setName(defaultName);
        }
    }
}
Also used : Node(com.liferay.ide.kaleo.core.model.Node) CanTransition(com.liferay.ide.kaleo.core.model.CanTransition) Transition(com.liferay.ide.kaleo.core.model.Transition) CanTransition(com.liferay.ide.kaleo.core.model.CanTransition) Property(org.eclipse.sapphire.Property) HashSet(java.util.HashSet)

Example 8 with Property

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

the class LeastVersionRuntimeValidationService method compute.

@Override
protected Status compute() {
    Property property = context(Element.class).property(context(Property.class).definition());
    Value<?> value = (Value<?>) property;
    String runtimeName = value.content().toString();
    IRuntime runtime = ServerUtil.getRuntime(runtimeName);
    if (runtime == null) {
        return Status.createErrorStatus("Liferay runtime must be configured.");
    }
    ILiferayRuntime liferayRuntime = ServerUtil.getLiferayRuntime(runtime);
    Version runtimeVersion = new Version(liferayRuntime.getPortalVersion());
    if (CoreUtil.compareVersions(runtimeVersion, ILiferayConstants.V620) < 0) {
        return Status.createErrorStatus("Liferay runtime must be greater than 6.2.0.");
    } else {
        return StatusBridge.create(runtime.validate(new NullProgressMonitor()));
    }
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) Version(org.osgi.framework.Version) Element(org.eclipse.sapphire.Element) ILiferayRuntime(com.liferay.ide.server.core.ILiferayRuntime) Value(org.eclipse.sapphire.Value) Property(org.eclipse.sapphire.Property) IRuntime(org.eclipse.wst.server.core.IRuntime)

Example 9 with Property

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

the class LiferayVersionDefaultValueService method initDefaultValueService.

@Override
protected void initDefaultValueService() {
    super.initDefaultValueService();
    PropertyDef def = context().find(PropertyDef.class);
    Property property = context(Element.class).property(def);
    PossibleValuesService possibleValuesService = property.service(PossibleValuesService.class);
    possibleValuesService.attach(new Listener() {

        @Override
        public void handle(Event event) {
            _possibleValues = possibleValuesService.values();
            refresh();
        }
    });
    NewLiferayProfile profile = context(NewLiferayProfile.class);
    profile.property(NewLiferayProfile.PROP_RUNTIME_NAME).attach(new FilteredListener<PropertyContentEvent>() {

        @Override
        protected void handleTypedEvent(PropertyContentEvent event) {
            _possibleValues = possibleValuesService.values();
            _runtimeVersion = null;
            refresh();
        }
    });
    _possibleValues = possibleValuesService.values();
}
Also used : PossibleValuesService(org.eclipse.sapphire.PossibleValuesService) PropertyContentEvent(org.eclipse.sapphire.PropertyContentEvent) FilteredListener(org.eclipse.sapphire.FilteredListener) Listener(org.eclipse.sapphire.Listener) PropertyDef(org.eclipse.sapphire.PropertyDef) Element(org.eclipse.sapphire.Element) NewLiferayProfile(com.liferay.ide.project.core.model.NewLiferayProfile) PropertyContentEvent(org.eclipse.sapphire.PropertyContentEvent) Event(org.eclipse.sapphire.Event) Property(org.eclipse.sapphire.Property)

Example 10 with Property

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

the class HierarchyJavaTypeBrowseActionHandler method browse.

@Override
public String browse(Presentation context) {
    Element element = getModelElement();
    Property property = property();
    IProject project = element.adapt(IProject.class);
    try {
        JavaTypeConstraintService typeService = property.service(JavaTypeConstraintService.class);
        EnumSet<JavaTypeKind> kinds = EnumSet.noneOf(JavaTypeKind.class);
        kinds.addAll(typeService.kinds());
        int browseDialogStyle = IJavaElementSearchConstants.CONSIDER_ALL_TYPES;
        int count = kinds.size();
        if (count == 1) {
            JavaTypeKind kind = kinds.iterator().next();
            switch(kind) {
                case CLASS:
                    browseDialogStyle = IJavaElementSearchConstants.CONSIDER_CLASSES;
                    break;
                case ABSTRACT_CLASS:
                    browseDialogStyle = IJavaElementSearchConstants.CONSIDER_CLASSES;
                    break;
                case INTERFACE:
                    browseDialogStyle = IJavaElementSearchConstants.CONSIDER_INTERFACES;
                    break;
                case ANNOTATION:
                    browseDialogStyle = IJavaElementSearchConstants.CONSIDER_ANNOTATION_TYPES;
                    break;
                case ENUM:
                    browseDialogStyle = IJavaElementSearchConstants.CONSIDER_ENUMS;
                    break;
                default:
                    throw new IllegalStateException();
            }
        } else if (count == 2) {
            if (kinds.contains(JavaTypeKind.CLASS) || kinds.contains(JavaTypeKind.ABSTRACT_CLASS)) {
                if (kinds.contains(JavaTypeKind.INTERFACE)) {
                    browseDialogStyle = IJavaElementSearchConstants.CONSIDER_CLASSES_AND_INTERFACES;
                } else if (kinds.contains(JavaTypeKind.ENUM)) {
                    browseDialogStyle = IJavaElementSearchConstants.CONSIDER_CLASSES_AND_ENUMS;
                }
            }
        }
        IJavaSearchScope scope = null;
        IType type = JavaCore.create(project).findType(_typeName);
        if (type != null) {
            scope = SearchEngine.createHierarchyScope(type);
        }
        SwtPresentation swt = (SwtPresentation) context;
        SelectionDialog dlg = JavaUI.createTypeDialog(swt.shell(), null, scope, browseDialogStyle, false, _filter, null);
        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) {
        HookUI.logError(jme);
    }
    return null;
}
Also used : JavaTypeKind(org.eclipse.sapphire.java.JavaTypeKind) JavaModelException(org.eclipse.jdt.core.JavaModelException) Element(org.eclipse.sapphire.Element) SelectionDialog(org.eclipse.ui.dialogs.SelectionDialog) IProject(org.eclipse.core.resources.IProject) IType(org.eclipse.jdt.core.IType) JavaTypeConstraintService(org.eclipse.sapphire.java.JavaTypeConstraintService) IJavaSearchScope(org.eclipse.jdt.core.search.IJavaSearchScope) SwtPresentation(org.eclipse.sapphire.ui.forms.swt.SwtPresentation) Property(org.eclipse.sapphire.Property)

Aggregations

Property (org.eclipse.sapphire.Property)16 Element (org.eclipse.sapphire.Element)10 IProject (org.eclipse.core.resources.IProject)5 ValueProperty (org.eclipse.sapphire.ValueProperty)4 IType (org.eclipse.jdt.core.IType)3 JavaModelException (org.eclipse.jdt.core.JavaModelException)3 IJavaSearchScope (org.eclipse.jdt.core.search.IJavaSearchScope)3 FilteredListener (org.eclipse.sapphire.FilteredListener)3 Listener (org.eclipse.sapphire.Listener)3 Value (org.eclipse.sapphire.Value)3 Path (org.eclipse.sapphire.modeling.Path)3 Hook (com.liferay.ide.hook.core.model.Hook)2 Transition (com.liferay.ide.kaleo.core.model.Transition)2 ArrayList (java.util.ArrayList)2 TypeSelectionExtension (org.eclipse.jdt.ui.dialogs.TypeSelectionExtension)2 Event (org.eclipse.sapphire.Event)2 PossibleValuesService (org.eclipse.sapphire.PossibleValuesService)2 PropertyContentEvent (org.eclipse.sapphire.PropertyContentEvent)2 PropertyDef (org.eclipse.sapphire.PropertyDef)2 JavaTypeKind (org.eclipse.sapphire.java.JavaTypeKind)2