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;
}
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();
}
}
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));
}
}
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;
}
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);
}
Aggregations