Search in sources :

Example 6 with Element

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

the class LayoutTplEditor method refreshDiagramModel.

protected void refreshDiagramModel() {
    LayoutTplElement newElement = LayoutTplElementsFactory.INSTANCE.newLayoutTplFromFile(getFile(), _bootstrapStyle, _is62);
    if (newElement == null) {
        /*
			 * create an empty model for diagram in memory, but not write to
			 * source
			 */
        newElement = createEmptyDiagramModel();
    }
    Element model = getModelElement();
    model.clear();
    model.copy(newElement);
}
Also used : LayoutTplElement(com.liferay.ide.layouttpl.core.model.LayoutTplElement) Element(org.eclipse.sapphire.Element) LayoutTplElement(com.liferay.ide.layouttpl.core.model.LayoutTplElement)

Example 7 with Element

use of org.eclipse.sapphire.Element 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)

Example 8 with Element

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

the class WindowStateImageService method compute.

@Override
protected ImageData compute() {
    String strWindowState = null;
    Element element = context(Element.class);
    ImageData imageData = null;
    if (element instanceof CustomWindowState) {
        CustomWindowState customWindowState = (CustomWindowState) element;
        strWindowState = String.valueOf(customWindowState.getWindowState().content());
    } else if (element instanceof WindowState) {
        WindowState windowState = (WindowState) element;
        strWindowState = windowState.getWindowState().content();
    }
    if ("MAXIMIZED".equalsIgnoreCase(strWindowState)) {
        imageData = IMG_MAXIMIZED;
    } else if ("MINIMIZED".equalsIgnoreCase(strWindowState)) {
        imageData = IMG_MINIMIZED;
    }
    if (imageData == null) {
        imageData = IMG_DEFAULT;
    }
    return imageData;
}
Also used : WindowState(com.liferay.ide.portlet.core.model.WindowState) CustomWindowState(com.liferay.ide.portlet.core.model.CustomWindowState) CustomWindowState(com.liferay.ide.portlet.core.model.CustomWindowState) ImageData(org.eclipse.sapphire.ImageData) Element(org.eclipse.sapphire.Element)

Example 9 with Element

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

the class LocaleBundleValidationService method compute.

public Status compute() {
    Element modelElement = context(Element.class);
    if (!modelElement.disposed() && modelElement instanceof SupportedLocales) {
        IProject project = modelElement.adapt(IProject.class);
        Portlet portlet = modelElement.nearest(Portlet.class);
        IWorkspaceRoot wroot = ResourcesPlugin.getWorkspace().getRoot();
        IClasspathEntry[] cpEntries = CoreUtil.getClasspathEntries(project);
        if (cpEntries != null) {
            String locale = modelElement.property(context(ValueProperty.class)).text(false);
            Value<Path> resourceBundle = portlet.getResourceBundle();
            if (locale == null) {
                return Status.createErrorStatus(Resources.localeMustNotEmpty);
            } else {
                String bundleName = resourceBundle.text();
                if ((resourceBundle != null) && (bundleName != null)) {
                    String localeString = PortletUtil.localeString(locale);
                    String ioFileName = PortletUtil.convertJavaToIoFileName(bundleName, RB_FILE_EXTENSION, localeString);
                    for (IClasspathEntry iClasspathEntry : cpEntries) {
                        if (IClasspathEntry.CPE_SOURCE == iClasspathEntry.getEntryKind()) {
                            IPath entryPath = wroot.getFolder(iClasspathEntry.getPath()).getLocation();
                            entryPath = entryPath.append(ioFileName);
                            IFile resourceBundleFile = wroot.getFileForLocation(entryPath);
                            if ((resourceBundleFile != null) && resourceBundleFile.exists()) {
                                return Status.createOkStatus();
                            } else {
                                return Status.createWarningStatus(Resources.bind(StringEscapeUtils.unescapeJava(Resources.noResourceBundle), new Object[] { locale, bundleName, localeString }));
                            }
                        }
                    }
                }
            }
        }
    }
    return Status.createOkStatus();
}
Also used : IPath(org.eclipse.core.runtime.IPath) Path(org.eclipse.sapphire.modeling.Path) Portlet(com.liferay.ide.portlet.core.model.Portlet) IFile(org.eclipse.core.resources.IFile) IPath(org.eclipse.core.runtime.IPath) IClasspathEntry(org.eclipse.jdt.core.IClasspathEntry) Element(org.eclipse.sapphire.Element) SupportedLocales(com.liferay.ide.portlet.core.model.SupportedLocales) IProject(org.eclipse.core.resources.IProject) IWorkspaceRoot(org.eclipse.core.resources.IWorkspaceRoot)

Example 10 with Element

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

the class NameOrQnameValidationService method compute.

@Override
public Status compute() {
    Element element = context(Element.class);
    String elementLabel = element.type().getLabel(false, CapitalizationType.FIRST_WORD_ONLY, false);
    QName iqName = null;
    String name = null;
    String nsURI = null;
    String localPart = null;
    if (element instanceof QName) {
        iqName = (QName) element;
        nsURI = iqName.getNamespaceURI().text(false);
        localPart = iqName.getLocalPart().text(false);
    }
    if (isEmptyOrNull(name) && isEmptyOrNull(nsURI) && isEmptyOrNull(localPart)) {
        return Status.createErrorStatus(Resources.bind(Resources.message, elementLabel));
    } else if (isEmptyOrNull(name) && (isEmptyOrNull(nsURI) || isEmptyOrNull(localPart))) {
        return Status.createErrorStatus(Resources.bind(Resources.invalidQname, elementLabel));
    }
    return Status.createOkStatus();
}
Also used : QName(com.liferay.ide.portlet.core.model.QName) Element(org.eclipse.sapphire.Element)

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