Search in sources :

Example 1 with ValueProperty

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

the class CreateSrcFileActionHandler method _getSrcFile.

private IFile _getSrcFile() {
    IFile retval = null;
    ValueProperty valueProperty = ValueProperty.class.cast(property().definition());
    Value<Path> value = getModelElement().property(valueProperty);
    if ((value != null) && !CoreUtil.isNullOrEmpty(value.text())) {
        IPath defaultSrcFolderPath = _getDefaultSrcFolderPath();
        if (defaultSrcFolderPath != null) {
            IPath filePath = defaultSrcFolderPath.append(value.text());
            IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
            retval = root.getFile(filePath);
        }
    }
    return retval;
}
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) IWorkspaceRoot(org.eclipse.core.resources.IWorkspaceRoot) ValueProperty(org.eclipse.sapphire.ValueProperty)

Example 2 with ValueProperty

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

the class CreateSrcFileActionHandler method run.

@Override
public Object run(Presentation context) {
    IFile file = _getSrcFile();
    try {
        if (!file.exists()) {
            InputStream defaultContentStream = new ByteArrayInputStream(StringPool.EMPTY.getBytes());
            file.create(defaultContentStream, true, null);
            try {
                file.refreshLocal(IResource.DEPTH_INFINITE, null);
            } catch (Exception e) {
                HookUI.logError(e);
            }
            ValueProperty valueProperty = ValueProperty.class.cast(property().definition());
            // do this so that the downstream properties can update their
            // enablement/validation/etc.
            Value<Object> value = getModelElement().property(valueProperty);
            Object content = value.content();
            value.clear();
            value.write(content);
            refreshEnablementState();
        }
    } catch (Exception e) {
        HookUI.logError("Unable to create src file: " + file.getName(), e);
    }
    return null;
}
Also used : IFile(org.eclipse.core.resources.IFile) ByteArrayInputStream(java.io.ByteArrayInputStream) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) ValueProperty(org.eclipse.sapphire.ValueProperty)

Example 3 with ValueProperty

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

the class CreateDirectoryActionHandler method init.

@Override
public void init(SapphireAction action, ActionHandlerDef def) {
    super.init(action, def);
    Element element = getModelElement();
    ValueProperty property = (ValueProperty) property().definition();
    Listener listener = new FilteredListener<PropertyEvent>() {

        @Override
        public void handleTypedEvent(PropertyEvent event) {
            refreshEnablementState();
        }
    };
    element.attach(listener, property.name());
    attach(new Listener() {

        @Override
        public void handle(Event event) {
            if (event instanceof DisposeEvent) {
                element.detach(listener, property.name());
            }
        }
    });
}
Also used : FilteredListener(org.eclipse.sapphire.FilteredListener) FilteredListener(org.eclipse.sapphire.FilteredListener) Listener(org.eclipse.sapphire.Listener) Element(org.eclipse.sapphire.Element) Event(org.eclipse.sapphire.Event) DisposeEvent(org.eclipse.sapphire.DisposeEvent) PropertyEvent(org.eclipse.sapphire.PropertyEvent) PropertyEvent(org.eclipse.sapphire.PropertyEvent) DisposeEvent(org.eclipse.sapphire.DisposeEvent) ValueProperty(org.eclipse.sapphire.ValueProperty)

Example 4 with ValueProperty

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

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

ValueProperty (org.eclipse.sapphire.ValueProperty)11 Element (org.eclipse.sapphire.Element)7 IFile (org.eclipse.core.resources.IFile)5 IProject (org.eclipse.core.resources.IProject)4 IPath (org.eclipse.core.runtime.IPath)4 IWorkspaceRoot (org.eclipse.core.resources.IWorkspaceRoot)3 Property (org.eclipse.sapphire.Property)3 Path (org.eclipse.sapphire.modeling.Path)3 ArrayList (java.util.ArrayList)2 IWorkspace (org.eclipse.core.resources.IWorkspace)2 IClasspathEntry (org.eclipse.jdt.core.IClasspathEntry)2 PortletApp (com.liferay.ide.portlet.core.model.PortletApp)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 InputStream (java.io.InputStream)1 IFolder (org.eclipse.core.resources.IFolder)1 DocumentEvent (org.eclipse.jface.text.DocumentEvent)1 IDocument (org.eclipse.jface.text.IDocument)1 IDocumentListener (org.eclipse.jface.text.IDocumentListener)1 DisposeEvent (org.eclipse.sapphire.DisposeEvent)1 Event (org.eclipse.sapphire.Event)1