use of org.eclipse.sapphire.Element in project liferay-ide by liferay.
the class CreateDirectoryActionHandler method run.
@Override
protected Object run(Presentation context) {
try {
Element element = getModelElement();
IProject project = element.adapt(IProject.class);
CustomJspDir customJspDir = (CustomJspDir) element;
Path customJspDirValue = customJspDir.getValue().content(false);
if (customJspDirValue == null) {
customJspDirValue = customJspDir.getValue().content(true);
customJspDir.setValue(customJspDirValue);
}
customJspDir.setValue(customJspDirValue);
RelativePathService service = property().service(RelativePathService.class);
Path absolutePath = service.convertToAbsolute(customJspDirValue);
if (FileUtil.notExists(absolutePath)) {
IWebProject webproject = LiferayCore.create(IWebProject.class, project);
if ((webproject != null) && (webproject.getDefaultDocrootFolder() != null)) {
IFolder defaultDocroot = webproject.getDefaultDocrootFolder();
IFolder customJspFolder = defaultDocroot.getFolder(new org.eclipse.core.runtime.Path(customJspDirValue.toPortableString()));
CoreUtil.makeFolders(customJspFolder);
// force a refresh of validation
customJspDir.setValue((Path) null);
customJspDir.setValue(customJspDirValue);
refreshEnablementState();
}
}
} catch (Exception e) {
HookUI.logError(e);
}
return null;
}
use of org.eclipse.sapphire.Element in project liferay-ide by liferay.
the class HierarchyJavaTypeBrowseActionHandler method browse.
@Override
public String browse(Presentation context) {
Element element = getModelElement();
Property property = property();
IProject project = element.adapt(IProject.class);
try {
JavaTypeConstraintService typeService = property.service(JavaTypeConstraintService.class);
EnumSet<JavaTypeKind> kinds = EnumSet.noneOf(JavaTypeKind.class);
kinds.addAll(typeService.kinds());
int browseDialogStyle = IJavaElementSearchConstants.CONSIDER_ALL_TYPES;
int count = kinds.size();
if (count == 1) {
JavaTypeKind kind = kinds.iterator().next();
switch(kind) {
case CLASS:
browseDialogStyle = IJavaElementSearchConstants.CONSIDER_CLASSES;
break;
case ABSTRACT_CLASS:
browseDialogStyle = IJavaElementSearchConstants.CONSIDER_CLASSES;
break;
case INTERFACE:
browseDialogStyle = IJavaElementSearchConstants.CONSIDER_INTERFACES;
break;
case ANNOTATION:
browseDialogStyle = IJavaElementSearchConstants.CONSIDER_ANNOTATION_TYPES;
break;
case ENUM:
browseDialogStyle = IJavaElementSearchConstants.CONSIDER_ENUMS;
break;
default:
throw new IllegalStateException();
}
} else if (count == 2) {
if (kinds.contains(JavaTypeKind.CLASS) || kinds.contains(JavaTypeKind.ABSTRACT_CLASS)) {
if (kinds.contains(JavaTypeKind.INTERFACE)) {
browseDialogStyle = IJavaElementSearchConstants.CONSIDER_CLASSES_AND_INTERFACES;
} else if (kinds.contains(JavaTypeKind.ENUM)) {
browseDialogStyle = IJavaElementSearchConstants.CONSIDER_CLASSES_AND_ENUMS;
}
}
}
IJavaSearchScope scope = null;
IType type = JavaCore.create(project).findType(_typeName);
if (type != null) {
scope = SearchEngine.createHierarchyScope(type);
}
SwtPresentation swt = (SwtPresentation) context;
SelectionDialog dlg = JavaUI.createTypeDialog(swt.shell(), null, scope, browseDialogStyle, false, _filter, null);
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;
}
use of org.eclipse.sapphire.Element in project liferay-ide by liferay.
the class PortalFilterNamesPossibleValuesService method compute.
@Override
protected void compute(Set<String> values) {
if (_servletFilterNames == null) {
Element element = context().find(Element.class);
IFile hookFile = element.adapt(IFile.class);
if (hookFile != null) {
try {
ILiferayProject liferayProject = LiferayCore.create(hookFile.getProject());
if (liferayProject != null) {
ILiferayPortal portal = liferayProject.adapt(ILiferayPortal.class);
if (portal != null) {
IPath appServerPortalDir = portal.getAppServerPortalDir();
if (appServerPortalDir != null) {
_servletFilterNames = ServerUtil.getServletFilterNames(appServerPortalDir);
}
}
}
} catch (Exception e) {
}
}
}
if (_servletFilterNames != null) {
Collections.addAll(values, _servletFilterNames);
}
}
use of org.eclipse.sapphire.Element in project liferay-ide by liferay.
the class PortletColumnsListener method handleTypedEvent.
@Override
protected void handleTypedEvent(PropertyContentEvent event) {
Property property = event.property();
Element element = property.element();
LayoutTplElement layouttpl = element.nearest(LayoutTplElement.class);
updateColumns(layouttpl, 1);
}
use of org.eclipse.sapphire.Element in project liferay-ide by liferay.
the class PortletModeImageService method compute.
@Override
protected ImageData compute() {
String portletMode = null;
Element element = context(Element.class);
ImageData imageData = null;
if (element instanceof CustomPortletMode) {
CustomPortletMode iCustomPortletMode = (CustomPortletMode) element;
portletMode = String.valueOf(iCustomPortletMode.getPortletMode().content());
} else if (element instanceof PortletMode) {
PortletMode iPortletMode = (PortletMode) element;
portletMode = iPortletMode.getPortletMode().content();
}
if (portletMode != null) {
if ("VIEW".equalsIgnoreCase(portletMode)) {
imageData = IMG_VIEW;
} else if ("EDIT".equalsIgnoreCase(portletMode)) {
imageData = IMG_EDIT;
} else if ("HELP".equalsIgnoreCase(portletMode)) {
imageData = IMG_HELP;
}
}
if (imageData == null) {
imageData = IMG_DEFAULT;
}
return imageData;
}
Aggregations