Search in sources :

Example 1 with Element

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

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

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

the class CustomJspValidationService method _getPortalDir.

private IPath _getPortalDir() {
    if (_portalDir == null) {
        try {
            Element element = context().find(Element.class);
            IFile file = element.nearest(Hook.class).adapt(IFile.class);
            IProject project = file.getProject();
            ILiferayProject liferayProject = LiferayCore.create(project);
            if (liferayProject != null) {
                ILiferayPortal portal = liferayProject.adapt(ILiferayPortal.class);
                if (portal != null) {
                    _portalDir = portal.getAppServerPortalDir();
                }
            }
        } catch (Exception e) {
            HookCore.logError(e);
        }
    }
    return _portalDir;
}
Also used : Hook(com.liferay.ide.hook.core.model.Hook) IFile(org.eclipse.core.resources.IFile) ILiferayProject(com.liferay.ide.core.ILiferayProject) Element(org.eclipse.sapphire.Element) ILiferayPortal(com.liferay.ide.core.ILiferayPortal) IProject(org.eclipse.core.resources.IProject)

Example 4 with Element

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

the class CustomJspsBindingImpl method resource.

@Override
@SuppressWarnings("unchecked")
protected Resource resource(Object obj) {
    Element element = property().element();
    Resource resource = element.resource();
    return new CustomJspResource(resource, (ObjectValue<String>) obj);
}
Also used : Element(org.eclipse.sapphire.Element) IResource(org.eclipse.core.resources.IResource) Resource(org.eclipse.sapphire.Resource)

Example 5 with Element

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

the class CustomJspsEnablementService method initEnablementService.

@Override
protected void initEnablementService() {
    Listener listener = new FilteredListener<PropertyEvent>() {

        protected void handleTypedEvent(PropertyEvent event) {
            refresh();
        }
    };
    ElementHandle<Element> element = _hook().property(Hook.PROP_CUSTOM_JSP_DIR);
    element.attach(listener, CustomJspDir.PROP_VALUE.name());
}
Also used : FilteredListener(org.eclipse.sapphire.FilteredListener) FilteredListener(org.eclipse.sapphire.FilteredListener) Listener(org.eclipse.sapphire.Listener) Element(org.eclipse.sapphire.Element) PropertyEvent(org.eclipse.sapphire.PropertyEvent)

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