Search in sources :

Example 6 with PortletApp

use of com.liferay.ide.portlet.core.model.PortletApp in project liferay-ide by liferay.

the class PortletModePossibleValueService method compute.

// provided by Portlet Specification and Liferay
/**
 * (non-Javadoc)
 *
 * @see org.eclipse.sapphire.modeling.PossibleValuesService#fillPossibleValues(java.
 *      util.SortedSet)
 */
@Override
protected void compute(Set<String> values) {
    PortletApp portletApp = context(PortletApp.class);
    for (int i = 0; i < DEFAULT_MODES.length; i++) {
        values.add(DEFAULT_MODES[i]);
    }
    // Add the ones defined in portlet.xml
    List<CustomPortletMode> customPortletModes = portletApp.getCustomPortletModes();
    for (CustomPortletMode iCustomPortletMode : customPortletModes) {
        String customPortletMode = iCustomPortletMode.getPortletMode().text(false);
        if (customPortletMode != null) {
            values.add(customPortletMode);
        }
    }
}
Also used : CustomPortletMode(com.liferay.ide.portlet.core.model.CustomPortletMode) PortletApp(com.liferay.ide.portlet.core.model.PortletApp)

Example 7 with PortletApp

use of com.liferay.ide.portlet.core.model.PortletApp in project liferay-ide by liferay.

the class CreatePortletAppResourceBundleActionHandler method run.

/**
 * (non-Javadoc)
 *
 * @see
 * org.eclipse.sapphire.ui.SapphireActionHandler#run(org.eclipse.sapphire.ui.
 * SapphireRenderingContext)
 */
@Override
protected Object run(Presentation context) {
    Element element = getModelElement();
    IProject project = element.adapt(IProject.class);
    Property property = property();
    Value<Path> resourceBundle = element.property((ValueProperty) property.definition());
    String resourceBundleText = resourceBundle.text();
    int index = resourceBundleText.lastIndexOf(".");
    if (index == -1) {
        index = resourceBundleText.length();
    }
    String packageName = resourceBundleText.substring(0, index);
    String defaultRBFileName = PortletUtil.convertJavaToIoFileName(resourceBundleText, GenericResourceBundlePathService.RB_FILE_EXTENSION);
    IFolder rbSourecFolder = getResourceBundleFolderLocation(project, defaultRBFileName);
    IPath entryPath = rbSourecFolder.getLocation();
    if (getModelElement() instanceof PortletApp) {
        List<IFile> missingRBFiles = new ArrayList<>();
        StringBuilder rbFileBuffer = new StringBuilder("#Portlet Application Resource Bundle \n");
        IFile rbFile = wroot.getFileForLocation(entryPath.append(defaultRBFileName));
        missingRBFiles.add(rbFile);
        createFiles(context, project, packageName, missingRBFiles, rbFileBuffer);
        setEnabled(false);
        Property modelElement = getModelElement().property(property().definition());
        modelElement.refresh();
    }
    return null;
}
Also used : IPath(org.eclipse.core.runtime.IPath) Path(org.eclipse.sapphire.modeling.Path) IFile(org.eclipse.core.resources.IFile) IPath(org.eclipse.core.runtime.IPath) Element(org.eclipse.sapphire.Element) ArrayList(java.util.ArrayList) IProject(org.eclipse.core.resources.IProject) PortletApp(com.liferay.ide.portlet.core.model.PortletApp) ValueProperty(org.eclipse.sapphire.ValueProperty) Property(org.eclipse.sapphire.Property) IFolder(org.eclipse.core.resources.IFolder)

Example 8 with PortletApp

use of com.liferay.ide.portlet.core.model.PortletApp in project liferay-ide by liferay.

the class WindowStatesPossibleValueService method initPossibleValuesService.

@Override
protected void initPossibleValuesService() {
    super.initPossibleValuesService();
    PortletApp portletApp = context(PortletApp.class);
    Listener listener = new FilteredListener<PropertyContentEvent>() {

        @Override
        protected void handleTypedEvent(PropertyContentEvent event) {
            refreshValues();
        }
    };
    portletApp.attach(listener, PortletApp.PROP_CUSTOM_WINDOW_STATES.name());
    refreshValues();
    portletApp.attach(new FilteredListener<ElementDisposeEvent>() {

        @Override
        protected void handleTypedEvent(ElementDisposeEvent event) {
            portletApp.detach(listener, PortletApp.PROP_CUSTOM_WINDOW_STATES.name());
        }
    });
    this.initialized = true;
}
Also used : FilteredListener(org.eclipse.sapphire.FilteredListener) PropertyContentEvent(org.eclipse.sapphire.PropertyContentEvent) FilteredListener(org.eclipse.sapphire.FilteredListener) Listener(org.eclipse.sapphire.Listener) ElementDisposeEvent(org.eclipse.sapphire.modeling.ElementDisposeEvent) PortletApp(com.liferay.ide.portlet.core.model.PortletApp)

Example 9 with PortletApp

use of com.liferay.ide.portlet.core.model.PortletApp in project liferay-ide by liferay.

the class QNamesPossibleValuesService method compute.

/**
 * (non-Javadoc)
 *
 * @see org.eclipse.sapphire.modeling.PossibleValuesService#fillPossibleValues(java.
 *      util.SortedSet)
 */
@Override
protected void compute(Set<String> values) {
    Element Element = context(Element.class);
    // values.add( param( "0" ) );
    PortletApp portletApp = context(Element.class).nearest(PortletApp.class);
    if (Element instanceof EventDefinitionRef) {
        ElementList<EventDefinition> eventDefs = portletApp.getEventDefinitions();
        for (EventDefinition eventDefinition : eventDefs) {
            if ((eventDefinition.getNamespaceURI().content() != null) && (eventDefinition.getLocalPart().content() != null)) {
                values.add(getQName(eventDefinition.getNamespaceURI().content(false), eventDefinition.getLocalPart().content()));
            }
        }
    } else if (Element instanceof SupportedPublicRenderParameter) {
        ElementList<PublicRenderParameter> publicRenderParameters = portletApp.getPublicRenderParameters();
        for (PublicRenderParameter publicRenderParam : publicRenderParameters) {
            if ((publicRenderParam.getNamespaceURI().content() != null) && (publicRenderParam.getLocalPart().content() != null)) {
                values.add(getQName(publicRenderParam.getNamespaceURI().content(false), publicRenderParam.getLocalPart().content()));
            }
        }
    }
}
Also used : EventDefinitionRef(com.liferay.ide.portlet.core.model.EventDefinitionRef) Element(org.eclipse.sapphire.Element) ElementList(org.eclipse.sapphire.ElementList) EventDefinition(com.liferay.ide.portlet.core.model.EventDefinition) SupportedPublicRenderParameter(com.liferay.ide.portlet.core.model.SupportedPublicRenderParameter) SupportedPublicRenderParameter(com.liferay.ide.portlet.core.model.SupportedPublicRenderParameter) PublicRenderParameter(com.liferay.ide.portlet.core.model.PublicRenderParameter) PortletApp(com.liferay.ide.portlet.core.model.PortletApp)

Aggregations

PortletApp (com.liferay.ide.portlet.core.model.PortletApp)9 EventDefinition (com.liferay.ide.portlet.core.model.EventDefinition)2 Portlet (com.liferay.ide.portlet.core.model.Portlet)2 PublicRenderParameter (com.liferay.ide.portlet.core.model.PublicRenderParameter)2 Element (org.eclipse.sapphire.Element)2 MasterDetailsContentNodePart (org.eclipse.sapphire.ui.forms.MasterDetailsContentNodePart)2 MasterDetailsEditorPagePart (org.eclipse.sapphire.ui.forms.MasterDetailsEditorPagePart)2 CustomPortletMode (com.liferay.ide.portlet.core.model.CustomPortletMode)1 CustomWindowState (com.liferay.ide.portlet.core.model.CustomWindowState)1 EventDefinitionRef (com.liferay.ide.portlet.core.model.EventDefinitionRef)1 Param (com.liferay.ide.portlet.core.model.Param)1 PortletInfo (com.liferay.ide.portlet.core.model.PortletInfo)1 SecurityRoleRef (com.liferay.ide.portlet.core.model.SecurityRoleRef)1 SupportedPublicRenderParameter (com.liferay.ide.portlet.core.model.SupportedPublicRenderParameter)1 Supports (com.liferay.ide.portlet.core.model.Supports)1 ArrayList (java.util.ArrayList)1 TreeSet (java.util.TreeSet)1 IFile (org.eclipse.core.resources.IFile)1 IFolder (org.eclipse.core.resources.IFolder)1 IProject (org.eclipse.core.resources.IProject)1