Search in sources :

Example 6 with NewLiferayPluginProjectOp

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

the class UseDefaultLocationValidationService method compute.

@Override
protected Status compute() {
    Status retval = Status.createOkStatus();
    NewLiferayPluginProjectOp op = _op();
    NewLiferayProjectProvider<NewLiferayPluginProjectOp> provider = op.getProjectProvider().content();
    if ((op.getProjectName().content() != null) && "ant".equals(provider.getShortName()) && !op.getUseDefaultLocation().content() && !NewLiferayPluginProjectOpMethods.canUseCustomLocation(op)) {
        retval = Status.createErrorStatus("The specified SDK version is not allowed to use custom location.");
    }
    return retval;
}
Also used : Status(org.eclipse.sapphire.modeling.Status) NewLiferayPluginProjectOp(com.liferay.ide.project.core.model.NewLiferayPluginProjectOp)

Example 7 with NewLiferayPluginProjectOp

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

the class ProfileIdPossibleValuesService method _fillPossibleValues.

private void _fillPossibleValues() {
    NewLiferayPluginProjectOp op = _op();
    Set<String> possibleProfileIds = NewLiferayPluginProjectOpMethods.getPossibleProfileIds(op, true);
    _possibleValues.clear();
    _possibleValues.addAll(possibleProfileIds);
}
Also used : NewLiferayPluginProjectOp(com.liferay.ide.project.core.model.NewLiferayPluginProjectOp)

Example 8 with NewLiferayPluginProjectOp

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

the class ProjectNameValidationService 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);
        }
    }
    String currentProjectName = op.getProjectName().content();
    if (currentProjectName != null) {
        IStatus nameStatus = CoreUtil.getWorkspace().validateName(currentProjectName, IResource.PROJECT);
        if (!nameStatus.isOK()) {
            retval = StatusBridge.create(nameStatus);
        } else if (_isInvalidProjectName(op)) {
            Boolean projectImported = op.getImportProjectStatus().content();
            if (projectImported == false) {
                retval = Status.createErrorStatus("A project with that name already exists.");
            }
        } else if (_isAntProject(op) && _isSuffixOnly(currentProjectName)) {
            retval = Status.createErrorStatus("A project name cannot only be a type suffix.");
        } else if (!_hasValidDisplayName(currentProjectName)) {
            retval = Status.createErrorStatus("The project name is invalid.");
        } else if (_isMavenProject(op) && !_isValidMavenProjectName(currentProjectName)) {
            retval = Status.createErrorStatus("The project name is invalid for a maven project");
        } else {
            Path currentProjectLocation = op.getLocation().content(true);
            if ((currentProjectName != null) && (currentProjectLocation != null)) {
                String currentPath = currentProjectLocation.toOSString();
                IPath osPath = org.eclipse.core.runtime.Path.fromOSString(currentPath);
                IStatus projectStatus = provider.validateProjectLocation(currentProjectName, osPath);
                if (!projectStatus.isOK()) {
                    retval = StatusBridge.create(projectStatus);
                }
            }
        }
    }
    op.getSdkLocation().refresh();
    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 9 with NewLiferayPluginProjectOp

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

the class ProjectNameValidationService method initValidationService.

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

        @Override
        protected void handleTypedEvent(PropertyContentEvent event) {
            PropertyDef def = event.property().definition();
            if (!def.equals(NewLiferayPluginProjectOp.PROP_DISPLAY_NAME) && !def.equals(NewLiferayPluginProjectOp.PROP_FINAL_PROJECT_NAME) && !def.equals(NewLiferayPluginProjectOp.PROP_PORTLET_NAME) && !def.equals(NewLiferayPluginProjectOp.PROP_PROJECT_NAMES) && !def.equals(NewLiferayPluginProjectOp.PROP_PROJECT_NAME)) {
                try {
                    refresh();
                } catch (Exception e) {
                    ProjectCore.logError(e);
                }
            }
        }
    };
    NewLiferayPluginProjectOp op = _op();
    op.attach(_listener, "*");
}
Also used : PropertyContentEvent(org.eclipse.sapphire.PropertyContentEvent) PropertyDef(org.eclipse.sapphire.PropertyDef) NewLiferayPluginProjectOp(com.liferay.ide.project.core.model.NewLiferayPluginProjectOp) CoreException(org.eclipse.core.runtime.CoreException)

Example 10 with NewLiferayPluginProjectOp

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

the class SelectActiveProfilesActionHandler method run.

@Override
protected Object run(Presentation context) {
    if (context instanceof SwtPresentation) {
        final SwtPresentation swt = (SwtPresentation) context;
        final NewLiferayPluginProjectOp op = getModelElement().nearest(NewLiferayPluginProjectOp.class);
        final String previousActiveProfilesValue = op.getActiveProfilesValue().content();
        // we need to rebuild the 'selected' list from what is specified in the
        // 'activeProfiles' property
        op.getSelectedProfiles().clear();
        final String activeProfiles = op.getActiveProfilesValue().content();
        if (!CoreUtil.isNullOrEmpty(activeProfiles)) {
            final String[] profileIds = activeProfiles.split(",");
            if (ListUtil.isNotEmpty(profileIds)) {
                for (String profileId : profileIds) {
                    if (!CoreUtil.isNullOrEmpty(profileId)) {
                        boolean foundExistingProfile = false;
                        for (Profile profile : op.getSelectedProfiles()) {
                            if (profileId.equals(profile.getId().content())) {
                                foundExistingProfile = true;
                                break;
                            }
                        }
                        if (!foundExistingProfile) {
                            Profile newlySelectedProfile = op.getSelectedProfiles().insert();
                            newlySelectedProfile.setId(profileId);
                        }
                    }
                }
            }
        }
        final CustomSapphireDialog dialog = new CustomSapphireDialog(swt.shell(), op, DefinitionLoader.sdef(NewLiferayPluginProjectWizard.class).dialog("SelectActiveProfiles"));
        dialog.setBlockOnOpen(true);
        final int result = dialog.open();
        if (result == SapphireDialog.CANCEL) {
            // restore previous value
            op.setActiveProfilesValue(previousActiveProfilesValue);
        } else {
            final ElementList<Profile> selectedProfiles = op.getSelectedProfiles();
            NewLiferayPluginProjectOpMethods.updateActiveProfilesValue(op, selectedProfiles);
        }
    }
    return null;
}
Also used : SwtPresentation(org.eclipse.sapphire.ui.forms.swt.SwtPresentation) NewLiferayPluginProjectOp(com.liferay.ide.project.core.model.NewLiferayPluginProjectOp) Profile(com.liferay.ide.project.core.model.Profile)

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