use of com.twinsoft.convertigo.engine.util.ProjectUrlParser in project convertigo by convertigo.
the class ImportWizard method performFinish.
/* (non-Javadoc)
* @see org.eclipse.jface.wizard.Wizard#performFinish()
*/
public boolean performFinish() {
ProjectExplorerView explorerView = ConvertigoPlugin.getDefault().getProjectExplorerView();
ProjectUrlParser parser = fileChooserPage.getParser();
String filePath = fileChooserPage.getFilePath();
if (parser.isValid()) {
ConvertigoPlugin.infoMessageBox("Loading " + parser.getProjectName() + " in a background job.");
Job.create("Import project " + parser.getProjectName(), (mon) -> {
try {
Project project = Engine.theApp.referencedProjectManager.importProject(parser, true);
if (project != null) {
TreeObject tree = explorerView.getProjectRootObject(project.getName());
if (tree != null) {
explorerView.reloadProject(tree);
}
explorerView.refreshProjects();
}
} catch (Exception e) {
Engine.logStudio.debug("Loading from remote URL failed", e);
}
}).schedule();
}
try {
if (explorerView != null) {
if (filePath != null) {
explorerView.importProject(filePath, getTargetProjectName());
}
}
} catch (Exception e) {
ConvertigoPlugin.logException(e, "Unable to import project !");
}
return true;
}
use of com.twinsoft.convertigo.engine.util.ProjectUrlParser in project convertigo by convertigo.
the class NewProjectWizard method setInitializationData.
@Override
public void setInitializationData(IConfigurationElement config, String propertyName, Object data) throws CoreException {
String value = config.getValue();
try {
wizardId = config.getAttribute("id");
JSONObject json = new JSONObject(value);
String url = json.getString("url");
projectUrlParser = new ProjectUrlParser(url);
projectName = projectUrlParser.getProjectName();
doPage1 = json.has("doPage1") && json.getBoolean("doPage1");
doPage2 = json.has("doPage2") && json.getBoolean("doPage2");
doPage4 = json.has("doPage4") && json.getBoolean("doPage4");
doPage5 = json.has("doPage5") && json.getBoolean("doPage5");
doPage6 = json.has("doPage6") && json.getBoolean("doPage6");
doPage7 = json.has("doPage7") && json.getBoolean("doPage7");
doPage8 = json.has("doPage8") && json.getBoolean("doPage8");
doPage9 = json.has("doPage9") && json.getBoolean("doPage9");
doPage10 = json.has("doPage10") && json.getBoolean("doPage10");
doPage11 = json.has("doPage11") && json.getBoolean("doPage11");
doPageSummarySampleProject = json.has("doPageSummarySampleProject") && json.getBoolean("doPageSummarySampleProject");
doConfigureSQLConnectorPage = json.has("doConfigureSQLConnectorPage") && json.getBoolean("doConfigureSQLConnectorPage");
doConfigureSAPConnectorPage = json.has("doConfigureSAPConnectorPage") && json.getBoolean("doConfigureSAPConnectorPage");
} catch (JSONException e) {
}
}
use of com.twinsoft.convertigo.engine.util.ProjectUrlParser in project convertigo by convertigo.
the class ReferencedProjectManager method check.
private boolean check(Map<String, ProjectUrlParser> refs) {
List<String> loaded = new LinkedList<>();
for (Entry<String, ProjectUrlParser> entry : refs.entrySet()) {
String projectName = entry.getKey();
try {
ProjectUrlParser parser = entry.getValue();
Project project = Engine.theApp.databaseObjectsManager.getOriginalProjectByName(parser.getProjectName(), false);
Project nProject = importProject(parser);
if (nProject != null && nProject != project) {
loaded.add(projectName);
}
} catch (Exception e) {
Engine.logEngine.warn("(ReferencedProjectManager) Failed to load '" + projectName + "'", e);
}
}
if (!loaded.isEmpty()) {
check(loaded);
return true;
}
return false;
}
use of com.twinsoft.convertigo.engine.util.ProjectUrlParser in project convertigo by convertigo.
the class ImportURL method getServiceResult.
protected void getServiceResult(HttpServletRequest request, Document document) throws Exception {
String error = null;
try {
String url = request.getParameter("url");
ProjectUrlParser parser = new ProjectUrlParser(url);
if (parser.isValid()) {
Project project;
if ((project = Engine.theApp.referencedProjectManager.importProject(parser, true)) == null) {
error = "No project loaded with: " + url;
} else {
String projectName = project.getName();
Project.executeAutoStartSequences(projectName);
}
} else {
error = "The format is invalid";
}
} catch (Exception e) {
error = "Failed to import project from URL, " + e.getClass().getSimpleName() + ": " + e.getMessage();
Engine.logAdmin.warn(error, e);
}
Element root = document.getDocumentElement();
Element elt;
if (error == null) {
elt = document.createElement("success");
elt.setTextContent("true");
} else {
elt = document.createElement("error");
elt.setTextContent(error);
}
root.appendChild(elt);
}
use of com.twinsoft.convertigo.engine.util.ProjectUrlParser in project convertigo by convertigo.
the class ImportWizardPage method updateStatus.
private void updateStatus() {
String message = null;
ProjectUrlParser parser = getParser();
if (parser != null) {
if (StringUtils.isEmpty(parser.getProjectUrl())) {
if (filePath.equals("")) {
message = "Please select a file";
} else if (!Engine.isProjectFile(filePath) && !filePath.endsWith(".car") && !filePath.endsWith(".zip")) {
message = "Please select a compatible file extension";
} else if (!new File(filePath).exists()) {
message = "Please select an existing compatible file";
} else {
try {
String projectName = DatabaseObjectsManager.getProjectName(new File(filePath));
if (StringUtils.isNotBlank(projectName)) {
setMessage("Current project to import is '" + projectName + "'.");
}
} catch (Exception e) {
}
}
}
}
setErrorMessage(message);
setPageComplete(message == null);
}
Aggregations