Search in sources :

Example 11 with NewLiferayPluginProjectOp

use of com.liferay.ide.project.core.model.NewLiferayPluginProjectOp in project liferay-ide by liferay.

the class NewLiferayProfileActionHandler method run.

@Override
protected Object run(Presentation context) {
    if (context instanceof SwtPresentation) {
        final SwtPresentation swt = (SwtPresentation) context;
        final NewLiferayPluginProjectOp op = _op(context);
        final NewLiferayProfile newLiferayProfile = op.getNewLiferayProfiles().insert();
        final SapphireDialog dialog = new SapphireDialog(swt.shell(), newLiferayProfile, DefinitionLoader.sdef(NewLiferayPluginProjectWizard.class).dialog("NewLiferayProfile"));
        dialog.setBlockOnOpen(true);
        final int result = dialog.open();
        if (result == SapphireDialog.OK) {
            addToActiveProfiles(op, newLiferayProfile);
        } else {
            op.getNewLiferayProfiles().remove(newLiferayProfile);
        }
    }
    return null;
}
Also used : NewLiferayProfile(com.liferay.ide.project.core.model.NewLiferayProfile) SwtPresentation(org.eclipse.sapphire.ui.forms.swt.SwtPresentation) NewLiferayPluginProjectOp(com.liferay.ide.project.core.model.NewLiferayPluginProjectOp) SapphireDialog(org.eclipse.sapphire.ui.forms.swt.SapphireDialog)

Example 12 with NewLiferayPluginProjectOp

use of com.liferay.ide.project.core.model.NewLiferayPluginProjectOp in project liferay-ide by liferay.

the class LiferayVersionPossibleValuesService method compute.

@Override
protected void compute(Set<String> values) {
    if (_versions != null) {
        values.addAll(_versions);
    } else if (_versionsJob == null) {
        _versionsJob = new Job("Determining possible Liferay versions.") {

            @Override
            protected IStatus run(IProgressMonitor monitor) {
                NewLiferayPluginProjectOp op = _op();
                if (!op.disposed()) {
                    ILiferayProjectProvider projectProvider = op.getProjectProvider().content();
                    try {
                        _versions = projectProvider.getData("liferayVersions", String.class, _groupId, _artifactId);
                    } catch (Exception e) {
                        ProjectCore.logError("Could not determine possible versions.", e);
                    }
                    refresh();
                }
                return Status.OK_STATUS;
            }
        };
        _versionsJob.schedule();
    }
}
Also used : IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) ILiferayProjectProvider(com.liferay.ide.core.ILiferayProjectProvider) NewLiferayPluginProjectOp(com.liferay.ide.project.core.model.NewLiferayPluginProjectOp) Job(org.eclipse.core.runtime.jobs.Job)

Example 13 with NewLiferayPluginProjectOp

use of com.liferay.ide.project.core.model.NewLiferayPluginProjectOp in project liferay-ide by liferay.

the class LocationListener method handleTypedEvent.

@Override
protected void handleTypedEvent(ValuePropertyContentEvent event) {
    NewLiferayPluginProjectOp op = op(event);
    boolean useDefaultLocation = op.getUseDefaultLocation().content(true);
    if (useDefaultLocation) {
        return;
    }
    String afterValue = event.after();
    String beforeValue = event.before();
    if ((beforeValue == null) && (afterValue != null)) {
        NewLiferayPluginProjectOpMethods.updateLocation(op, new Path(afterValue));
    }
}
Also used : Path(org.eclipse.sapphire.modeling.Path) NewLiferayPluginProjectOp(com.liferay.ide.project.core.model.NewLiferayPluginProjectOp)

Example 14 with NewLiferayPluginProjectOp

use of com.liferay.ide.project.core.model.NewLiferayPluginProjectOp in project liferay-ide by liferay.

the class LocationValidationService method compute.

@Override
protected Status compute() {
    Status retval = Status.createOkStatus();
    NewLiferayPluginProjectOp op = _op();
    NewLiferayProjectProvider<NewLiferayPluginProjectOp> provider = op.getProjectProvider().content();
    if (provider.getShortName().equals("ant")) {
        SDK sdk = null;
        try {
            sdk = SDKUtil.getWorkspaceSDK();
            if (sdk != null) {
                IStatus sdkStatus = sdk.validate();
                if (!sdkStatus.isOK()) {
                    retval = Status.createErrorStatus(sdkStatus.getChildren()[0].getMessage());
                }
            }
        } catch (CoreException ce) {
            retval = Status.createErrorStatus(ce);
        }
    }
    Path currentProjectLocation = op.getLocation().content(true);
    String currentProjectName = op.getProjectName().content();
    /*
		 * Location won't be validated if the UseDefaultLocation has an error.
		 * Get the validation of the property might not work as excepted,
		 * let's use call the validation service manually.
		 */
    Value<Boolean> useDefalutLocationValue = op.getUseDefaultLocation();
    Status status = useDefalutLocationValue.service(UseDefaultLocationValidationService.class).validation();
    if (!useDefalutLocationValue.content(true) && status.ok() && (currentProjectName != null)) {
        /*
			 * IDE-1150, instead of using annotation "@Required",use this service to
			 * validate the custom project location must be specified, let the wizard
			 * display the error of project name when project name and location are both
			 * null.
			 */
        if (currentProjectLocation == null) {
            return Status.createErrorStatus("Location must be specified.");
        }
        String currentPath = currentProjectLocation.toOSString();
        if (!org.eclipse.core.runtime.Path.EMPTY.isValidPath(currentPath)) {
            return Status.createErrorStatus("\"" + currentPath + "\" is not a valid path.");
        }
        IPath osPath = org.eclipse.core.runtime.Path.fromOSString(currentPath);
        if (!osPath.toFile().isAbsolute()) {
            return Status.createErrorStatus("\"" + currentPath + "\" is not an absolute path.");
        }
        if (FileUtil.notExists(osPath) && !_canCreate(osPath.toFile())) {
            retval = Status.createErrorStatus("Cannot create project content at \"" + currentPath + "\"");
        }
        IStatus locationStatus = provider.validateProjectLocation(currentProjectName, osPath);
        if (!locationStatus.isOK()) {
            retval = Status.createErrorStatus(locationStatus.getMessage());
        }
    }
    return retval;
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) Status(org.eclipse.sapphire.modeling.Status) IPath(org.eclipse.core.runtime.IPath) Path(org.eclipse.sapphire.modeling.Path) IStatus(org.eclipse.core.runtime.IStatus) CoreException(org.eclipse.core.runtime.CoreException) IPath(org.eclipse.core.runtime.IPath) NewLiferayPluginProjectOp(com.liferay.ide.project.core.model.NewLiferayPluginProjectOp) SDK(com.liferay.ide.sdk.core.SDK)

Example 15 with NewLiferayPluginProjectOp

use of com.liferay.ide.project.core.model.NewLiferayPluginProjectOp in project liferay-ide by liferay.

the class LocationValidationService method initValidationService.

@Override
protected void initValidationService() {
    _listener = new FilteredListener<PropertyContentEvent>() {

        @Override
        protected void handleTypedEvent(PropertyContentEvent event) {
            refresh();
        }
    };
    NewLiferayPluginProjectOp op = _op();
    op.getProjectName().attach(_listener);
    op.getProjectProvider().attach(_listener);
}
Also used : PropertyContentEvent(org.eclipse.sapphire.PropertyContentEvent) NewLiferayPluginProjectOp(com.liferay.ide.project.core.model.NewLiferayPluginProjectOp)

Aggregations

NewLiferayPluginProjectOp (com.liferay.ide.project.core.model.NewLiferayPluginProjectOp)122 Test (org.junit.Test)61 IProject (org.eclipse.core.resources.IProject)48 IWebProject (com.liferay.ide.core.IWebProject)18 IFile (org.eclipse.core.resources.IFile)18 IPath (org.eclipse.core.runtime.IPath)14 IFolder (org.eclipse.core.resources.IFolder)13 SDK (com.liferay.ide.sdk.core.SDK)12 Status (org.eclipse.sapphire.modeling.Status)10 PropertyContentEvent (org.eclipse.sapphire.PropertyContentEvent)9 Path (org.eclipse.sapphire.modeling.Path)8 CoreException (org.eclipse.core.runtime.CoreException)7 IPortletFramework (com.liferay.ide.project.core.IPortletFramework)6 HashSet (java.util.HashSet)5 PossibleValuesService (org.eclipse.sapphire.PossibleValuesService)5 ValidationService (org.eclipse.sapphire.services.ValidationService)5 IVirtualComponent (org.eclipse.wst.common.componentcore.resources.IVirtualComponent)5 NewLiferayProfile (com.liferay.ide.project.core.model.NewLiferayProfile)4 IStatus (org.eclipse.core.runtime.IStatus)4 LayoutTplDescriptorHelper (com.liferay.ide.layouttpl.core.operation.LayoutTplDescriptorHelper)3