Search in sources :

Example 1 with Property

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

the class PortalPropertiesFileListener method handleTypedEvent.

@Override
protected void handleTypedEvent(PropertyContentEvent event) {
    Property prop = event.property();
    if (Hook.PROP_PORTAL_PROPERTIES_FILE.equals(prop.definition())) {
        Hook hook = prop.element().nearest(Hook.class);
        PortalPropertiesFile ppf = hook.getPortalPropertiesFile().content(false);
        if (ppf != null) {
            Value<Path> value = ppf.getValue();
            if (value != null) {
                Path path = value.content(false);
                if (path == null) {
                    ppf.initialize();
                }
            }
        }
    }
}
Also used : Path(org.eclipse.sapphire.modeling.Path) Hook(com.liferay.ide.hook.core.model.Hook) PortalPropertiesFile(com.liferay.ide.hook.core.model.PortalPropertiesFile) Property(org.eclipse.sapphire.Property)

Example 2 with Property

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

the class ServiceTypeImplBrowseActionHandler 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;
        if ("type".equals(_kind)) {
            scope = SearchEngine.createJavaSearchScope(new IJavaProject[] { JavaCore.create(project) });
            extension = new TypeSelectionExtension() {

                @Override
                public ITypeInfoFilterExtension getFilterExtension() {
                    return new ITypeInfoFilterExtension() {

                        public boolean select(ITypeInfoRequestor typeInfoRequestor) {
                            if (typeInfoRequestor.getPackageName().startsWith("com.liferay") && typeInfoRequestor.getTypeName().endsWith("Service")) {
                                return true;
                            }
                            return false;
                        }
                    };
                }
            };
        } else if ("impl".equals(_kind)) {
            String serviceType = _getServiceType(element);
            if (serviceType != null) {
                String wrapperType = serviceType + "Wrapper";
                scope = SearchEngine.createHierarchyScope(JavaCore.create(project).findType(wrapperType));
            } else {
                Shell shell = ((SwtPresentation) context).shell();
                MessageDialog.openInformation(shell, Msgs.serviceImplBrowse, Msgs.validServiceTypeProperty);
                return null;
            }
        }
        Shell shell = ((SwtPresentation) context).shell();
        SelectionDialog dlg = JavaUI.createTypeDialog(shell, null, scope, _browseDialogStyle, 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) {
        HookUI.logError(jme);
    }
    return null;
}
Also used : JavaModelException(org.eclipse.jdt.core.JavaModelException) Element(org.eclipse.sapphire.Element) ITypeInfoFilterExtension(org.eclipse.jdt.ui.dialogs.ITypeInfoFilterExtension) TypeSelectionExtension(org.eclipse.jdt.ui.dialogs.TypeSelectionExtension) SelectionDialog(org.eclipse.ui.dialogs.SelectionDialog) IProject(org.eclipse.core.resources.IProject) IType(org.eclipse.jdt.core.IType) Shell(org.eclipse.swt.widgets.Shell) IJavaProject(org.eclipse.jdt.core.IJavaProject) IJavaSearchScope(org.eclipse.jdt.core.search.IJavaSearchScope) SwtPresentation(org.eclipse.sapphire.ui.forms.swt.SwtPresentation) Property(org.eclipse.sapphire.Property) ITypeInfoRequestor(org.eclipse.jdt.ui.dialogs.ITypeInfoRequestor)

Example 3 with Property

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

the class CustomJspValidationService method compute.

@Override
public Status compute() {
    Value<?> value = (Value<?>) context(Element.class).property(context(Property.class).definition());
    ValueProperty property = value.definition();
    String label = property.getLabel(true, CapitalizationType.NO_CAPS, false);
    if (_isValueEmpty(value)) {
        String msg = NLS.bind(Msgs.nonEmptyValueRequired, label);
        return Status.createErrorStatus(msg);
    } else if (!_isValidPortalJsp(value) && !_isValidProjectJsp(value)) {
        String msg = NLS.bind(Msgs.customJspInvalidPath, label);
        return Status.createErrorStatus(msg);
    }
    return Status.createOkStatus();
}
Also used : Value(org.eclipse.sapphire.Value) ValueProperty(org.eclipse.sapphire.ValueProperty) Property(org.eclipse.sapphire.Property) ValueProperty(org.eclipse.sapphire.ValueProperty)

Example 4 with Property

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

the class CustomJspDirListener method handleTypedEvent.

@Override
protected void handleTypedEvent(PropertyContentEvent event) {
    Property prop = event.property();
    Hook hook = prop.element().nearest(Hook.class);
    if (hook != null) {
        if (CustomJspDir.PROP_VALUE.equals(prop.definition())) {
            // IDE-1132, Listen the change of Property CustomJspDir, and refresh the
            // Property CustomJsps.
            hook.property(Hook.PROP_CUSTOM_JSPS).refresh();
        } else if (Hook.PROP_CUSTOM_JSP_DIR.equals(prop.definition())) {
            // IDE-1251 listen for changes to custom_jsp_dir and if it is empty initialize
            // initial content @InitialValue
            CustomJspDir customJspDir = hook.getCustomJspDir().content(false);
            if (customJspDir != null) {
                Value<Path> value = customJspDir.getValue();
                if (value != null) {
                    Path path = value.content(false);
                    if (path == null) {
                        customJspDir.initialize();
                    }
                }
            }
        }
    }
}
Also used : Path(org.eclipse.sapphire.modeling.Path) Hook(com.liferay.ide.hook.core.model.Hook) Value(org.eclipse.sapphire.Value) CustomJspDir(com.liferay.ide.hook.core.model.CustomJspDir) Property(org.eclipse.sapphire.Property)

Example 5 with Property

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

the class AbstractResourceBundleActionHandler method computeEnablementState.

/**
 * (non-Javadoc)
 *
 * @see org.eclipse.sapphire.ui.SapphirePropertyEditorActionHandler#
 * computeEnablementState()
 */
@Override
protected boolean computeEnablementState() {
    boolean enabled = super.computeEnablementState();
    if (enabled) {
        Element element = getModelElement();
        Property property = property();
        IProject project = element.adapt(IProject.class);
        String rbFile = element.property((ValueProperty) property.definition()).text();
        if (rbFile != null) {
            String ioFileName = PortletUtil.convertJavaToIoFileName(rbFile, GenericResourceBundlePathService.RB_FILE_EXTENSION);
            enabled = !getFileFromClasspath(project, ioFileName);
        } else {
            enabled = false;
        }
    }
    return enabled;
}
Also used : Element(org.eclipse.sapphire.Element) ValueProperty(org.eclipse.sapphire.ValueProperty) Property(org.eclipse.sapphire.Property) IProject(org.eclipse.core.resources.IProject) ValueProperty(org.eclipse.sapphire.ValueProperty)

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