use of org.eclipse.sapphire.modeling.Path 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.modeling.Path in project liferay-ide by liferay.
the class LiferayPortletXmlTest method testIconRelativePathService.
@Test
public void testIconRelativePathService() throws Exception {
if (shouldSkipBundleTests())
return;
NewLiferayPluginProjectOp newProjectOp = NewLiferayPluginProjectOp.TYPE.instantiate();
newProjectOp.setProjectName("test-path");
newProjectOp.setPluginType(PluginType.portlet);
newProjectOp.setIncludeSampleCode(true);
newProjectOp.setPortletFramework("mvc");
newProjectOp.setPortletName("testPortlet");
final IProject testProject = createAntProject(newProjectOp);
LiferayPortletXml liferayPortletApp = op(testProject);
for (LiferayPortlet liferayPortlet : liferayPortletApp.getPortlets()) {
final RelativePathService pathService = liferayPortlet.getIcon().service(RelativePathService.class);
List<Path> iconPaths = pathService.roots();
assertEquals(true, iconPaths.size() > 0);
}
}
use of org.eclipse.sapphire.modeling.Path in project liferay-ide by liferay.
the class GenericResourceBundlePathService method convertToRelative.
@Override
public Path convertToRelative(Path path) {
Path localPath = super.convertToRelative(path);
String bundle = localPath.toPortableString();
if ((bundle == null) || (bundle.indexOf("/") == -1)) {
return localPath;
}
String correctBundle = bundle.replace("/", ".");
Path newPath = Path.fromPortableString(correctBundle);
return newPath.removeFileExtension();
}
use of org.eclipse.sapphire.modeling.Path in project liferay-ide by liferay.
the class SDKImportLocationValidationService method compute.
@Override
protected Status compute() {
Status retval = Status.createOkStatus();
SDKProjectsImportOp op = _op();
Path currentProjectLocation = op.getSdkLocation().content(true);
if ((currentProjectLocation != null) && !currentProjectLocation.isEmpty()) {
String currentPath = currentProjectLocation.toOSString();
retval = StatusBridge.create(ProjectImportUtil.validateSDKPath(currentPath));
}
return retval;
}
use of org.eclipse.sapphire.modeling.Path in project liferay-ide by liferay.
the class SDKImportValidationService method compute.
@Override
protected Status compute() {
Status retval = Status.createOkStatus();
ParentSDKProjectImportOp op = _op();
try {
SDK sdk = SDKUtil.getWorkspaceSDK();
if (sdk != null) {
return StatusBridge.create(ProjectCore.createErrorStatus(" This workspace already has another sdk."));
}
Path currentProjectLocation = op.getSdkLocation().content(true);
if ((currentProjectLocation != null) && !currentProjectLocation.isEmpty()) {
sdk = SDKUtil.createSDKFromLocation(PathBridge.create(currentProjectLocation));
if (sdk != null) {
IStatus sdkStatus = sdk.validate(true);
if (!sdkStatus.isOK()) {
retval = StatusBridge.create(ProjectCore.createWarningStatus(sdkStatus.getChildren()[0].getMessage()));
}
} else {
retval = StatusBridge.create(ProjectCore.createErrorStatus("This parent sdk project path is invalid."));
}
}
} catch (CoreException ce) {
}
return retval;
}
Aggregations