use of org.eclipse.sapphire.modeling.Status in project liferay-ide by liferay.
the class NewModuleFragmentFilesOpMethods method execute.
public static final Status execute(NewModuleFragmentFilesOp op, ProgressMonitor pm) {
IProgressMonitor monitor = ProgressMonitorBridge.create(pm);
monitor.beginTask("Copy files (this process may take several minutes)", 100);
String projectName = op.getProjectName().content();
IProject project = CoreUtil.getProject(projectName);
Status retval = null;
try {
String hostBundleName = op.getHostOsgiBundle().content();
IPath projectCoreLocation = ProjectCore.getDefault().getStateLocation();
IPath tempJarDir = LiferayCore.GLOBAL_USER_DIR.append(hostBundleName);
if (FileUtil.notExists(tempJarDir)) {
IRuntime runtime = ServerUtil.getRuntime(op.getLiferayRuntimeName().content());
String hostOsgiJar = hostBundleName + ".jar";
ServerUtil.getModuleFileFrom70Server(runtime, hostOsgiJar, projectCoreLocation);
IPath tempJarFile = projectCoreLocation.append(hostOsgiJar);
try {
ZipUtil.unzip(tempJarFile.toFile(), tempJarDir.toFile());
} catch (IOException ioe) {
throw new CoreException(ProjectCore.createErrorStatus(ioe));
}
}
ElementList<OverrideFilePath> files = op.getOverrideFiles();
for (OverrideFilePath file : files) {
File fragmentFile = tempJarDir.append(file.getValue().content()).toFile();
if (FileUtil.exists(fragmentFile)) {
File folder = null;
if (fragmentFile.getName().equals("portlet.properties")) {
IPath path = project.getLocation().append("src/main/java");
folder = path.toFile();
FileUtil.copyFileToDir(fragmentFile, "portlet-ext.properties", folder);
} else if (fragmentFile.getName().contains("default.xml")) {
String parent = fragmentFile.getPath();
parent = parent.replaceAll("\\\\", "/");
String metaInfResources = "resource-actions";
parent = parent.substring(parent.indexOf(metaInfResources) + metaInfResources.length());
IPath resources = project.getLocation().append("src/main/resources/resource-actions");
folder = resources.toFile();
folder.mkdirs();
FileUtil.copyFileToDir(fragmentFile, "default-ext.xml", folder);
try {
File ext = new File(project.getLocation().append("src/main/resources") + "/portlet-ext.properties");
ext.createNewFile();
String extFileContent = "resource.actions.configs=resource-actions/default.xml," + "resource-actions/default-ext.xml";
FileUtil.writeFile(ext, extFileContent, null);
} catch (Exception e) {
throw new CoreException(ProjectCore.createErrorStatus(e));
}
} else {
String parent = fragmentFile.getParentFile().getPath();
parent = parent.replaceAll("\\\\", "/");
String metaInfResources = "META-INF/resources";
parent = parent.substring(parent.indexOf(metaInfResources) + metaInfResources.length());
IPath resources = project.getLocation().append("src/main/resources/META-INF/resources");
folder = resources.toFile();
folder.mkdirs();
if (!parent.equals("resources") && !parent.equals("")) {
folder = resources.append(parent).toFile();
folder.mkdirs();
}
FileUtil.copyFileToDir(fragmentFile, folder);
}
}
}
project.refreshLocal(IResource.DEPTH_INFINITE, null);
retval = Status.createOkStatus();
} catch (Exception e) {
String msg = "Error copy files.";
ProjectCore.logError(msg, e);
return Status.createErrorStatus(msg + " Please see Eclipse error log for more details.", e);
}
return retval;
}
use of org.eclipse.sapphire.modeling.Status in project liferay-ide by liferay.
the class NewModuleFragmentOpMethods method execute.
public static final Status execute(NewModuleFragmentOp op, ProgressMonitor pm) {
IProgressMonitor monitor = ProgressMonitorBridge.create(pm);
monitor.beginTask("Creating Liferay module fragment project (this process may take several minutes)", 100);
Status retval = null;
try {
NewLiferayProjectProvider<BaseModuleOp> projectProvider = op.getProjectProvider().content(true);
IStatus status = projectProvider.createNewProject(op, monitor);
retval = StatusBridge.create(status);
if (retval.ok()) {
_updateBuildPrefs(op);
}
} catch (Exception e) {
String msg = "Error creating Liferay module fragment project.";
ProjectCore.logError(msg, e);
return Status.createErrorStatus(msg + " Please see Eclipse error log for more details.", e);
}
return retval;
}
use of org.eclipse.sapphire.modeling.Status in project liferay-ide by liferay.
the class ImportLiferayModuleProjectOpMethods method execute.
public static final Status execute(ImportLiferayModuleProjectOp op, ProgressMonitor pm) {
IProgressMonitor monitor = ProgressMonitorBridge.create(pm);
monitor.beginTask("Importing Module project...", 100);
Path path = op.getLocation().content();
String location = path.toOSString();
ILiferayProjectImporter importer = LiferayCore.getImporter(op.getBuildType().content());
Status retval = Status.createOkStatus();
try {
importer.importProjects(location, monitor);
} catch (CoreException ce) {
retval = Status.createErrorStatus(ce);
}
return retval;
}
use of org.eclipse.sapphire.modeling.Status in project liferay-ide by liferay.
the class ImportModuleProjectLocationValidationService method compute.
@Override
protected Status compute() {
ImportLiferayModuleProjectOp op = _op();
Path path = op.getLocation().content();
if ((path == null) || path.isEmpty()) {
return Status.createOkStatus();
}
String location = path.toOSString();
Status retval = StatusBridge.create(ProjectImportUtil.validatePath(location));
if (!retval.ok()) {
return retval;
}
if (LiferayWorkspaceUtil.isValidWorkspaceLocation(location)) {
return Status.createErrorStatus("Can't import Liferay Workspace, please use Import Liferay Workspace Project wizard.");
}
retval = StatusBridge.create(ImportLiferayModuleProjectOpMethods.getBuildType(location));
if (retval.severity() == Status.Severity.ERROR) {
return retval;
}
String projectName = path.lastSegment();
if (FileUtil.exists(CoreUtil.getProject(projectName))) {
return Status.createErrorStatus("A project with that name already exists.");
}
return retval;
}
use of org.eclipse.sapphire.modeling.Status in project liferay-ide by liferay.
the class JavaPackageNameValidationService method compute.
@Override
protected Status compute() {
Status retval = Status.createOkStatus();
NewLiferayComponentOp op = _op();
String projectName = op.getProjectName().text(false);
if (projectName != null) {
IJavaProject javaproject = JavaCore.create(CoreUtil.getProject(op.getProjectName().text(false)));
if (CoreUtil.getSourceFolders(javaproject).size() == 0) {
retval = Status.createErrorStatus("Unable to find any source folders.");
return retval;
}
}
JavaPackageName packageName = op.getPackageName().content(true);
if (packageName != null) {
IStatus status = JavaConventions.validatePackageName(packageName.toString(), CompilerOptions.VERSION_1_7, CompilerOptions.VERSION_1_7);
int packageNameStatus = status.getSeverity();
if (packageNameStatus == IStatus.ERROR) {
retval = Status.createErrorStatus("Invalid package name");
}
}
return retval;
}
Aggregations