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;
}
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);
}
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;
}
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, "*");
}
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;
}
Aggregations