Search in sources :

Example 41 with Path

use of org.eclipse.sapphire.modeling.Path in project liferay-ide by liferay.

the class CustomJspPage method _runConvertAction.

private void _runConvertAction() {
    CustomProjectSelectionDialog dialog = new CustomProjectSelectionDialog(UIUtil.getActiveShell());
    dialog.setProjects(_getHookProjects());
    URL imageUrl = bundle.getEntry("/icons/e16/hook.png");
    Image hookImage = ImageDescriptor.createFromURL(imageUrl).createImage();
    dialog.setImage(hookImage);
    dialog.setTitle("Custom JSP Hook Project");
    dialog.setMessage("Select Custom JSP Hook Project");
    List<IProject> hookProjects = new ArrayList<>();
    if (dialog.open() == Window.OK) {
        final Object[] selectedProjects = dialog.getResult();
        if (selectedProjects != null) {
            for (Object project : selectedProjects) {
                if (project instanceof IJavaProject) {
                    IJavaProject p = (IJavaProject) project;
                    hookProjects.add(p.getProject());
                }
            }
        }
    }
    int size = hookProjects.size();
    if (size < 1) {
        return;
    }
    String[] sourcePaths = new String[size];
    String[] projectNames = new String[size];
    for (int i = 0; i < size; i++) {
        IProject hookProject = hookProjects.get(i);
        sourcePaths[i] = hookProject.getLocation().toOSString();
        projectNames[i] = hookProject.getName();
    }
    CustomJspConverter converter = new CustomJspConverter();
    IRuntime liferay70Runtime = _getLiferay70Runtime();
    if (liferay70Runtime == null) {
        MessageDialog.openError(Display.getDefault().getActiveShell(), "Convert Error", "Couldn't find Liferay 7.x Runtime.");
        return;
    }
    String liferay62ServerLocation = _getLiferay62ServerLocation();
    if (liferay62ServerLocation == null) {
        MessageDialog.openError(Display.getDefault().getActiveShell(), "Convert Error", "Couldn't find Liferay 6.2 Runtime.");
        return;
    }
    converter.setLiferay70Runtime(liferay70Runtime);
    converter.setLiferay62ServerLocation(liferay62ServerLocation);
    converter.setUi(this);
    Value<Path> convertedProjectLocation = dataModel.getConvertedProjectLocation();
    String targetPath = convertedProjectLocation.content().toPortableString();
    boolean liferayWorkapce = false;
    if (targetPath.equals(_defaultLocation) && _hasLiferayWorkspace) {
        liferayWorkapce = true;
    }
    converter.doExecute(sourcePaths, projectNames, targetPath, liferayWorkapce);
}
Also used : IPath(org.eclipse.core.runtime.IPath) Path(org.eclipse.sapphire.modeling.Path) ArrayList(java.util.ArrayList) StyledString(org.eclipse.jface.viewers.StyledString) Image(org.eclipse.swt.graphics.Image) CustomProjectSelectionDialog(com.liferay.ide.project.ui.dialog.CustomProjectSelectionDialog) URL(java.net.URL) IProject(org.eclipse.core.resources.IProject) IRuntime(org.eclipse.wst.server.core.IRuntime) IJavaProject(org.eclipse.jdt.core.IJavaProject)

Example 42 with Path

use of org.eclipse.sapphire.modeling.Path in project liferay-ide by liferay.

the class ImportSDKProjectsCheckboxCustomPart method updateValidation.

@Override
protected void updateValidation() {
    retval = Status.createOkStatus();
    Value<Path> sdkLocationPath = _op().getSdkLocation();
    Path sdkLocation = sdkLocationPath.content();
    if (sdkLocation != null) {
        IStatus status = ProjectImportUtil.validateSDKPath(sdkLocation.toPortableString());
        if (status.isOK()) {
            final int projectsCount = checkBoxViewer.getTable().getItemCount();
            final int selectedProjectsCount = checkBoxViewer.getCheckedElements().length;
            if (projectsCount == 0) {
                retval = Status.createErrorStatus("No available projects can be imported.");
            }
            if ((projectsCount > 0) && (selectedProjectsCount == 0)) {
                retval = Status.createErrorStatus("At least one project must be specified.");
            }
        }
    } else {
        retval = Status.createErrorStatus("SDK path cannot be empty");
    }
    refreshValidation();
}
Also used : Path(org.eclipse.sapphire.modeling.Path) IStatus(org.eclipse.core.runtime.IStatus)

Example 43 with Path

use of org.eclipse.sapphire.modeling.Path in project liferay-ide by liferay.

the class ProjectLocationValidationService method compute.

@Override
protected Status compute() {
    Status retval = Status.createOkStatus();
    int countPossibleWorkspaceSDKProjects = SDKUtil.countPossibleWorkspaceSDKProjects();
    if (countPossibleWorkspaceSDKProjects > 1) {
        return StatusBridge.create(ProjectCore.createErrorStatus("This workspace has more than one SDK."));
    }
    Value<Path> sdkLocation = _op().getSdkLocation();
    final Path location = sdkLocation.content(true);
    if ((location == null) || location.isEmpty()) {
        return StatusBridge.create(ProjectCore.createErrorStatus("Liferay Plugins SDK or Maven location is empty."));
    }
    IStatus buildType = ImportLiferayModuleProjectOpMethods.getBuildType(location.removeFileExtension().toPortableString());
    SDK sdk = SDKUtil.createSDKFromLocation(PathBridge.create(location));
    if (sdk != null) {
        String version = sdk.getVersion();
        if (version != null) {
            Version sdkVersion = new Version(version);
            int result = sdkVersion.compareTo(new Version("6.1.0"));
            if (result < 0) {
                return StatusBridge.create(ProjectCore.createErrorStatus("This tool doesn't support 6.0.x."));
            }
        }
    } else if (!buildType.getMessage().equals("maven")) {
        return StatusBridge.create(ProjectCore.createErrorStatus("Plugins SDK or Maven location is not valid."));
    }
    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) Version(org.osgi.framework.Version) SDK(com.liferay.ide.sdk.core.SDK)

Example 44 with Path

use of org.eclipse.sapphire.modeling.Path in project liferay-ide by liferay.

the class ImportLiferayWorkspaceWizard method performPostFinish.

@Override
protected void performPostFinish() {
    super.performPostFinish();
    final ImportLiferayWorkspaceOp op = element().nearest(ImportLiferayWorkspaceOp.class);
    Path projectPath = op.getWorkspaceLocation().content();
    final IProject newProject = CoreUtil.getProject(projectPath.lastSegment());
    try {
        addToWorkingSets(newProject);
    } catch (Exception ex) {
        ProjectUI.logError("Unable to add project to working set", ex);
    }
    openLiferayPerspective(newProject);
    ProjectExplorerLayoutUtil.setNested(true);
}
Also used : ImportLiferayWorkspaceOp(com.liferay.ide.project.core.workspace.ImportLiferayWorkspaceOp) Path(org.eclipse.sapphire.modeling.Path) IProject(org.eclipse.core.resources.IProject) CoreException(org.eclipse.core.runtime.CoreException)

Example 45 with Path

use of org.eclipse.sapphire.modeling.Path in project liferay-ide by liferay.

the class BackupLocationValidationService method compute.

@Override
protected Status compute() {
    Status retval = Status.createOkStatus();
    Value<Path> backupLocation = _op().getBackupLocation();
    Path location = backupLocation.content();
    if (location != null) {
        if (!location.isAbsolute()) {
            return Status.createErrorStatus("\"" + location.toPortableString() + "\" is not an absolute path.");
        }
        if (location.toFile().isFile()) {
            return Status.createErrorStatus("\"" + location.toPortableString() + "\" is not a folder.");
        }
    }
    return retval;
}
Also used : Status(org.eclipse.sapphire.modeling.Status) Path(org.eclipse.sapphire.modeling.Path)

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