Search in sources :

Example 1 with NewLiferayProfile

use of com.liferay.ide.project.core.model.NewLiferayProfile 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 2 with NewLiferayProfile

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

the class LiferayVersionDefaultValueService method initDefaultValueService.

@Override
protected void initDefaultValueService() {
    super.initDefaultValueService();
    PropertyDef def = context().find(PropertyDef.class);
    Property property = context(Element.class).property(def);
    PossibleValuesService possibleValuesService = property.service(PossibleValuesService.class);
    possibleValuesService.attach(new Listener() {

        @Override
        public void handle(Event event) {
            _possibleValues = possibleValuesService.values();
            refresh();
        }
    });
    NewLiferayProfile profile = context(NewLiferayProfile.class);
    profile.property(NewLiferayProfile.PROP_RUNTIME_NAME).attach(new FilteredListener<PropertyContentEvent>() {

        @Override
        protected void handleTypedEvent(PropertyContentEvent event) {
            _possibleValues = possibleValuesService.values();
            _runtimeVersion = null;
            refresh();
        }
    });
    _possibleValues = possibleValuesService.values();
}
Also used : PossibleValuesService(org.eclipse.sapphire.PossibleValuesService) PropertyContentEvent(org.eclipse.sapphire.PropertyContentEvent) FilteredListener(org.eclipse.sapphire.FilteredListener) Listener(org.eclipse.sapphire.Listener) PropertyDef(org.eclipse.sapphire.PropertyDef) Element(org.eclipse.sapphire.Element) NewLiferayProfile(com.liferay.ide.project.core.model.NewLiferayProfile) PropertyContentEvent(org.eclipse.sapphire.PropertyContentEvent) Event(org.eclipse.sapphire.Event) Property(org.eclipse.sapphire.Property)

Example 3 with NewLiferayProfile

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

the class NewLiferayProfileIdDefaultValueService method compute.

@Override
protected String compute() {
    NewLiferayProfile profile = _newLiferayProfile();
    String defaultRuntimeName = profile.getRuntimeName().content();
    /*
		 * First try to use this as a runtimeName, but need to check it against existing possible values.
		 * If no existing profiles with this name exist, use it, if not, append a (1)
		 */
    String data = defaultRuntimeName;
    if (data.equals("<None>")) {
        return StringPool.EMPTY;
    }
    data = data.replaceAll(StringPool.SPACE, StringPool.DASH);
    NewLiferayPluginProjectOp op = profile.nearest(NewLiferayPluginProjectOp.class);
    Set<String> possibleValues = NewLiferayPluginProjectOpMethods.getPossibleProfileIds(op, false);
    while (possibleValues.contains(data)) {
        try {
            data = _nextSuffix(data);
        } catch (Exception e) {
        }
    }
    return data;
}
Also used : NewLiferayProfile(com.liferay.ide.project.core.model.NewLiferayProfile) NewLiferayPluginProjectOp(com.liferay.ide.project.core.model.NewLiferayPluginProjectOp)

Example 4 with NewLiferayProfile

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

the class NewLiferayProfileIdValidationService method compute.

@Override
protected Status compute() {
    Status retval = Status.createOkStatus();
    NewLiferayProfile newLiferayProfile = _profile();
    String profileId = newLiferayProfile.getId().content(true);
    if ((profileId == null) || profileId.isEmpty()) {
        retval = Status.createErrorStatus("Profile id can not be empty.");
    } else if (profileId.contains(StringPool.SPACE)) {
        retval = Status.createErrorStatus("No spaces are allowed in profile id.");
    }
    if (ListUtil.isEmpty(_existingValues)) {
        return retval;
    }
    for (String val : _existingValues) {
        if ((val != null) && val.equals(profileId)) {
            return Status.createErrorStatus("Profile already exists.");
        }
    }
    return retval;
}
Also used : Status(org.eclipse.sapphire.modeling.Status) NewLiferayProfile(com.liferay.ide.project.core.model.NewLiferayProfile)

Example 5 with NewLiferayProfile

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

the class NewLiferayProfileRuntimeValidationService method compute.

@Override
protected Status compute() {
    Status retval = Status.createOkStatus();
    NewLiferayPluginProjectOp op = context(NewLiferayPluginProjectOp.class);
    NewLiferayProjectProvider<NewLiferayPluginProjectOp> provider = op.getProjectProvider().content(true);
    if ("maven".equals(provider.getShortName())) {
        NewLiferayProfile newLiferayProfile = context(NewLiferayProfile.class);
        String runtimeName = newLiferayProfile.getRuntimeName().content(true);
        IRuntime runtime = ServerUtil.getRuntime(runtimeName);
        if (runtime == null) {
            retval = Status.createErrorStatus("Liferay runtime must be configured.");
        }
    }
    return retval;
}
Also used : Status(org.eclipse.sapphire.modeling.Status) NewLiferayProfile(com.liferay.ide.project.core.model.NewLiferayProfile) NewLiferayPluginProjectOp(com.liferay.ide.project.core.model.NewLiferayPluginProjectOp) IRuntime(org.eclipse.wst.server.core.IRuntime)

Aggregations

NewLiferayProfile (com.liferay.ide.project.core.model.NewLiferayProfile)12 NewLiferayPluginProjectOp (com.liferay.ide.project.core.model.NewLiferayPluginProjectOp)4 IFile (org.eclipse.core.resources.IFile)3 Properties (java.util.Properties)2 IProject (org.eclipse.core.resources.IProject)2 CoreException (org.eclipse.core.runtime.CoreException)2 FilteredListener (org.eclipse.sapphire.FilteredListener)2 Listener (org.eclipse.sapphire.Listener)2 PossibleValuesService (org.eclipse.sapphire.PossibleValuesService)2 PropertyContentEvent (org.eclipse.sapphire.PropertyContentEvent)2 Status (org.eclipse.sapphire.modeling.Status)2 SapphireDialog (org.eclipse.sapphire.ui.forms.swt.SapphireDialog)2 IDOMModel (org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel)2 IWebProject (com.liferay.ide.core.IWebProject)1 IPortletFramework (com.liferay.ide.project.core.IPortletFramework)1 PluginType (com.liferay.ide.project.core.model.PluginType)1 ProjectName (com.liferay.ide.project.core.model.ProjectName)1 NewLiferayPluginProjectWizard (com.liferay.ide.project.ui.wizard.NewLiferayPluginProjectWizard)1 File (java.io.File)1 IOException (java.io.IOException)1