use of org.eclipse.sapphire.Element in project liferay-ide by liferay.
the class HierarchyBrowseActionHandler 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;
String javaType = _getClassReferenceType(property);
if (javaType != null) {
scope = SearchEngine.createHierarchyScope(JavaCore.create(project).findType(javaType));
} else {
MessageDialog.openInformation(((SwtPresentation) context).shell(), Msgs.browseImplementation, Msgs.validClassImplProperty);
return null;
}
SelectionDialog dlg = JavaUI.createTypeDialog(((SwtPresentation) context).shell(), null, scope, IJavaElementSearchConstants.CONSIDER_CLASSES, 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) {
PortletUIPlugin.logError(jme);
}
return null;
}
use of org.eclipse.sapphire.Element in project liferay-ide by liferay.
the class LiferayPortletNameValidationService method compute.
@Override
protected Status compute() {
Element modelElement = context(Element.class);
if (!modelElement.disposed()) {
liferayPortletName = (String) modelElement.property(context(ValueProperty.class)).content();
IProject project = modelElement.adapt(IProject.class);
String[] portletNames = new PortletDescriptorHelper(project).getAllPortletNames();
if (portletNames != null) {
for (String portletName : portletNames) {
if (portletName.equals(liferayPortletName)) {
return Status.createOkStatus();
}
}
}
}
return Status.createErrorStatus(Resources.bind(StringEscapeUtils.unescapeJava(Resources.portletNameInvalid), new Object[] { liferayPortletName }));
}
use of org.eclipse.sapphire.Element in project liferay-ide by liferay.
the class LiferayScriptPossibleValuesService method compute.
@Override
protected void compute(Set<String> values) {
Element modeElement = context(Element.class);
List<FileExtensions> exts = modeElement.parent().definition().getAnnotations(FileExtensions.class);
if ((exts != null) && (exts.size() > 0)) {
this.type = exts.get(0).expr();
IProject project = modeElement.adapt(IProject.class);
if (project != null) {
IFolder webappRoot = CoreUtil.getDefaultDocrootFolder(project);
if (webappRoot != null) {
IPath location = webappRoot.getLocation();
if (location != null) {
if (location.toFile().exists()) {
values.addAll(new PropertiesVisitor().visitScriptFiles(webappRoot, type, values));
}
}
}
}
}
}
use of org.eclipse.sapphire.Element in project liferay-ide by liferay.
the class PortletStyleValidationService method compute.
@Override
protected Status compute() {
Element modelElement = context(Element.class);
if (!modelElement.disposed() && modelElement instanceof PortletStyleElement) {
Path path = (Path) modelElement.property(context(ValueProperty.class)).content();
if (path != null) {
String name = path.lastSegment();
IProject project = modelElement.adapt(IProject.class);
boolean fileExisted = new FileCheckVisitor().checkFiles(project, name);
if (!fileExisted) {
return Status.createErrorStatus("File " + path.toPortableString() + " is not existed");
}
} else {
return Status.createErrorStatus("Can not set empty value");
}
}
return Status.createOkStatus();
}
use of org.eclipse.sapphire.Element in project liferay-ide by liferay.
the class OpenPortletResourceAction method selectAndRevealItem.
/**
* @param editor
* TODO: need to work on to fix to reveal the selected node
*/
protected void selectAndRevealItem(IEditorPart editorPart) {
if (this.editorPart instanceof SapphireEditor) {
SapphireEditorForXml editor = (SapphireEditorForXml) editorPart;
PortletNode portletNavigatorNode = (PortletNode) selectedNode;
Element selectedModelElement = portletNavigatorNode.getModel();
if (selectedModelElement != null) {
MasterDetailsEditorPage mdepDetailsEditorPage = (MasterDetailsEditorPage) editor.getActivePageInstance();
if (mdepDetailsEditorPage != null) {
MasterDetailsContentOutline contentOutline = mdepDetailsEditorPage.outline();
MasterDetailsContentNodePart rootNode = contentOutline.getRoot();
if (rootNode != null) {
MasterDetailsContentNodeList nodes = rootNode.nodes();
MasterDetailsContentNodePart portletAppNode = nodes.visible().get(0);
MasterDetailsContentNodePart portletsNode = portletAppNode.findNode(_PORTLETS_NODE_LABEL);
if (portletsNode != null) {
if (selectedModelElement instanceof Portlet) {
Portlet selectedPortlet = (Portlet) selectedModelElement;
for (MasterDetailsContentNodePart childNode : portletsNode.nodes().visible()) {
String selectedPortletName = selectedPortlet.getPortletName().content();
if (childNode.getModelElement() instanceof Portlet) {
Portlet mpContentNodePortlet = (Portlet) childNode.getModelElement();
String mpContentNodePortletName = mpContentNodePortlet.getPortletName().content();
if (selectedPortletName.equals(mpContentNodePortletName)) {
childNode.select();
childNode.setExpanded(true);
break;
}
}
}
}
}
}
}
}
}
}
Aggregations