use of org.eclipse.sapphire.Element in project liferay-ide by liferay.
the class ResourceBundleJumpActionHandler method run.
/**
* (non-Javadoc)
*
* @see
* org.eclipse.sapphire.ui.SapphireActionHandler#run(org.eclipse.sapphire.ui.
* SapphireRenderingContext)
*/
@Override
protected Object run(Presentation context) {
Element element = getModelElement();
IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
ValueProperty property = (ValueProperty) property().definition();
IProject project = element.adapt(IProject.class);
Value<Path> value = element.property(property);
String text = value.text(false);
IWorkspace workspace = ResourcesPlugin.getWorkspace();
IWorkspaceRoot wroot = workspace.getRoot();
IClasspathEntry[] cpEntries = CoreUtil.getClasspathEntries(project);
String ioFileName = PortletUtil.convertJavaToIoFileName(text, RB_FILE_EXTENSION);
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()) {
if (window != null) {
IWorkbenchPage page = window.getActivePage();
IEditorDescriptor editorDescriptor = null;
try {
editorDescriptor = IDE.getEditorDescriptor(resourceBundleFile.getName());
} catch (PartInitException pie) {
// No editor was found for this file type.
}
if (editorDescriptor != null) {
try {
IDE.openEditor(page, resourceBundleFile, editorDescriptor.getId(), true);
} catch (PartInitException pie) {
PortletUIPlugin.logError(pie);
}
}
}
}
}
}
return null;
}
use of org.eclipse.sapphire.Element in project liferay-ide by liferay.
the class ResourceBundleJumpActionHandler method computeEnablementState.
/**
* (non-Javadoc)
*
* @see org.eclipse.sapphire.ui.SapphirePropertyEditorActionHandler#
* computeEnablementState()
*/
@Override
protected boolean computeEnablementState() {
Element element = getModelElement();
IProject project = element.adapt(IProject.class);
ValueProperty property = (ValueProperty) property().definition();
String text = element.property(property).text(true);
boolean enabled = super.computeEnablementState();
if (enabled && (text != null)) {
IWorkspace workspace = ResourcesPlugin.getWorkspace();
IWorkspaceRoot wroot = workspace.getRoot();
IClasspathEntry[] cpEntries = CoreUtil.getClasspathEntries(project);
String ioFileName = PortletUtil.convertJavaToIoFileName(text, RB_FILE_EXTENSION);
if (cpEntries != null) {
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 true;
}
}
}
}
}
return false;
}
use of org.eclipse.sapphire.Element in project liferay-ide by liferay.
the class StructuresTests method testDocumentLibraryStructuresRead.
@Test
public void testDocumentLibraryStructuresRead() throws Exception {
final Element element = getElementFromFile(getCurrentProject(), DOCUMENT_LIBRARY_STRUCTURES, Root.TYPE);
setElement(element);
final Root root = element.nearest(Root.class);
assertNotNull(root);
final ElementList<Structure> structures = root.getStructures();
assertNotNull(structures);
assertEquals(8, structures.size());
final Structure structure = structures.get(2);
assertNotNull(structure);
assertEquals("Learning Module Metadata", structure.getName().content(false));
assertEquals("Learning Module Metadata", structure.getDescription().content(false));
final Root structureRoot = structure.getRoot().content(false);
assertNotNull(structureRoot);
assertEquals("[$LOCALE_DEFAULT$]", structureRoot.getAvailableLocales().content(false));
assertEquals("[$LOCALE_DEFAULT$]", structureRoot.getDefaultLocale().content(false));
final ElementList<DynamicElement> dynamicElements = structureRoot.getDynamicElements();
assertNotNull(dynamicElements);
assertEquals(4, dynamicElements.size());
final DynamicElement dynamicElement = dynamicElements.get(1);
assertNotNull(dynamicElement);
assertEquals("string", dynamicElement.getDataType().content(false));
assertEquals("keyword", dynamicElement.getIndexType().content(false));
assertEquals(true, dynamicElement.isMultiple().content(false));
assertEquals("select3212", dynamicElement.getName().content(false));
assertEquals(false, dynamicElement.isReadOnly().content(false));
assertEquals(false, dynamicElement.isRequired().content(false));
assertEquals(true, dynamicElement.isShowLabel().content(false));
assertEquals("select", dynamicElement.getType().content(false));
final DynamicElementMetadata metadata = dynamicElement.getMetadata().content(false);
assertNotNull(metadata);
assertEquals("[$LOCALE_DEFAULT$]", metadata.getLocale().content(false));
final ElementList<Entry> entries = metadata.getEntries();
assertNotNull(entries);
assertEquals(3, entries.size());
final ElementList<DynamicElement> childDynamicElements = dynamicElement.getDynamicElements();
assertNotNull(childDynamicElements);
assertEquals(3, childDynamicElements.size());
final DynamicElement childDynamicElement = childDynamicElements.get(1);
assertNotNull(childDynamicElement);
assertEquals("2_0", childDynamicElement.getName().content(false));
assertEquals("option", childDynamicElement.getType().content(false));
assertEquals("2", childDynamicElement.getValue().content(false));
final DynamicElementMetadata childMetadata = childDynamicElement.getMetadata().content(false);
assertNotNull(childMetadata);
assertEquals("[$LOCALE_DEFAULT$]", childMetadata.getLocale().content(false));
final ElementList<Entry> childEntries = childMetadata.getEntries();
assertNotNull(childEntries);
assertEquals(1, childEntries.size());
final Entry childEntry = childEntries.get(0);
assertNotNull(childEntry);
assertEquals("label", childEntry.getName().content(false));
assertEquals("2.0", childEntry.getValue().content(false));
}
use of org.eclipse.sapphire.Element in project liferay-ide by liferay.
the class ChangeTaskAssignmentsActionHandler method _task.
private Task _task(Presentation context) {
SapphirePart spPart = context.part();
Element element = spPart.getLocalModelElement();
return element.nearest(Task.class);
}
use of org.eclipse.sapphire.Element in project liferay-ide by liferay.
the class NotificationsDiagramNodeEditHandlerFactory method dispose.
@Override
public void dispose() {
super.dispose();
Element element = getElement();
element.detach(_listener, getListPropertyName());
}
Aggregations