Search in sources :

Example 11 with Path

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;
}
Also used : IPath(org.eclipse.core.runtime.IPath) Path(org.eclipse.sapphire.modeling.Path) IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) IFile(org.eclipse.core.resources.IFile) IPath(org.eclipse.core.runtime.IPath) IClasspathEntry(org.eclipse.jdt.core.IClasspathEntry) Element(org.eclipse.sapphire.Element) IEditorDescriptor(org.eclipse.ui.IEditorDescriptor) ValueProperty(org.eclipse.sapphire.ValueProperty) IProject(org.eclipse.core.resources.IProject) IWorkspaceRoot(org.eclipse.core.resources.IWorkspaceRoot) IWorkspace(org.eclipse.core.resources.IWorkspace) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) PartInitException(org.eclipse.ui.PartInitException)

Example 12 with Path

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);
    }
}
Also used : Path(org.eclipse.sapphire.modeling.Path) LiferayPortletXml(com.liferay.ide.portlet.core.lfportlet.model.LiferayPortletXml) RelativePathService(org.eclipse.sapphire.services.RelativePathService) NewLiferayPluginProjectOp(com.liferay.ide.project.core.model.NewLiferayPluginProjectOp) LiferayPortlet(com.liferay.ide.portlet.core.lfportlet.model.LiferayPortlet) IProject(org.eclipse.core.resources.IProject) Test(org.junit.Test)

Example 13 with Path

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();
}
Also used : IPath(org.eclipse.core.runtime.IPath) Path(org.eclipse.sapphire.modeling.Path)

Example 14 with Path

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;
}
Also used : Status(org.eclipse.sapphire.modeling.Status) Path(org.eclipse.sapphire.modeling.Path) SDKProjectsImportOp(com.liferay.ide.project.core.model.SDKProjectsImportOp)

Example 15 with Path

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;
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) Status(org.eclipse.sapphire.modeling.Status) Path(org.eclipse.sapphire.modeling.Path) IStatus(org.eclipse.core.runtime.IStatus) CoreException(org.eclipse.core.runtime.CoreException) ParentSDKProjectImportOp(com.liferay.ide.project.core.model.ParentSDKProjectImportOp) SDK(com.liferay.ide.sdk.core.SDK)

Aggregations

Path (org.eclipse.sapphire.modeling.Path)71 IPath (org.eclipse.core.runtime.IPath)37 IStatus (org.eclipse.core.runtime.IStatus)18 Status (org.eclipse.sapphire.modeling.Status)18 IProject (org.eclipse.core.resources.IProject)17 SDK (com.liferay.ide.sdk.core.SDK)16 CoreException (org.eclipse.core.runtime.CoreException)16 IFile (org.eclipse.core.resources.IFile)12 File (java.io.File)9 NewLiferayPluginProjectOp (com.liferay.ide.project.core.model.NewLiferayPluginProjectOp)8 ArrayList (java.util.ArrayList)8 IFolder (org.eclipse.core.resources.IFolder)8 Hook (com.liferay.ide.hook.core.model.Hook)6 Element (org.eclipse.sapphire.Element)6 CustomJspDir (com.liferay.ide.hook.core.model.CustomJspDir)5 IWebProject (com.liferay.ide.core.IWebProject)4 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)4 IWorkspaceRoot (org.eclipse.core.resources.IWorkspaceRoot)3 ValueProperty (org.eclipse.sapphire.ValueProperty)3 ILiferayPortal (com.liferay.ide.core.ILiferayPortal)2