use of com.twinsoft.convertigo.beans.core.Reference in project convertigo by convertigo.
the class ProjectExplorerView method loadedProjectsHaveReferences.
private boolean loadedProjectsHaveReferences() {
ViewContentProvider provider = (ViewContentProvider) viewer.getContentProvider();
if (provider != null) {
Object[] objects = provider.getChildren(provider.getTreeRoot());
for (int i = 0; i < objects.length; i++) {
TreeObject treeObject = (TreeObject) objects[i];
if (treeObject instanceof ProjectTreeObject) {
// Check for references on projects
ProjectTreeObject projectTreeObject = (ProjectTreeObject) treeObject;
List<Reference> references = ((Project) projectTreeObject.getObject()).getReferenceList();
if (references.size() > 0) {
for (Reference reference : references) {
if (reference instanceof ProjectSchemaReference) {
return true;
}
}
}
// Check for sequences (potential call steps)
List<Sequence> sequences = ((Project) projectTreeObject.getObject()).getSequencesList();
if (sequences.size() > 0) {
return true;
}
}
}
}
return false;
}
use of com.twinsoft.convertigo.beans.core.Reference in project convertigo by convertigo.
the class List method getServiceResult.
protected void getServiceResult(HttpServletRequest request, Document document) throws Exception {
Element root = document.getDocumentElement();
Element projectsListElement = document.createElement("projects");
root.appendChild(projectsListElement);
boolean isStudio = Engine.isStudioMode();
for (String projectName : Engine.theApp.databaseObjectsManager.getAllProjectNamesList()) {
try {
if (isStudio && projectName.startsWith("mobilebuilder_tpl_")) {
continue;
}
Project project = Engine.theApp.databaseObjectsManager.getOriginalProjectByName(projectName);
if (project == null) {
continue;
}
String deployDate = "n/a";
File file = new File(Engine.projectDir(projectName) + ".car");
if (file.exists())
deployDate = DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.SHORT, request.getLocale()).format(new Date(file.lastModified()));
String comment = project.getComment();
if (comment.length() > 100)
comment = comment.substring(0, 100) + "...";
String version = project.getVersion();
DateFormat df = DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.SHORT, request.getLocale());
String exported = project.getInfoForProperty("exported", df, request.getLocale());
Element projectElement = document.createElement("project");
projectElement.setAttribute("name", projectName);
projectElement.setAttribute("comment", comment);
projectElement.setAttribute("version", version);
projectElement.setAttribute("exported", exported);
projectElement.setAttribute("exportedTs", "" + project.getExportTime());
projectElement.setAttribute("deployDate", deployDate);
projectElement.setAttribute("deployDateTs", "" + file.lastModified());
if (Engine.theApp.databaseObjectsManager.symbolsProjectCheckUndefined(projectName)) {
projectElement.setAttribute("undefined_symbols", "true");
}
for (Reference ref : project.getReferenceList()) {
if (ref instanceof ProjectSchemaReference) {
ProjectSchemaReference prjRef = (ProjectSchemaReference) ref;
if (prjRef.getParser().isValid() && Engine.theApp.databaseObjectsManager.getOriginalProjectByName(prjRef.getParser().getProjectName(), true) == null) {
projectElement.setAttribute("missingDependencies", "true");
break;
}
}
}
projectsListElement.appendChild(projectElement);
} catch (EngineException e) {
String message = "Unable to get project information ('" + projectName + "')";
Engine.logAdmin.error(message, e);
}
}
}
use of com.twinsoft.convertigo.beans.core.Reference in project convertigo by convertigo.
the class ProjectTreeObject method checkMissingProjects.
public void checkMissingProjects(final boolean doReload) {
synchronized (this) {
if (isCheckMissingProjects) {
return;
}
isCheckMissingProjects = true;
}
final Project project = getObject();
Job.create("Check missing project for " + project.getName(), (monitor) -> {
try {
final Set<String> missingProjects = project.getMissingProjects().keySet();
final Set<String> missingProjectReferences = project.getMissingProjectReferences().keySet();
if (!missingProjects.isEmpty() || !missingProjectReferences.isEmpty()) {
List<String> allProjects = Engine.theApp.databaseObjectsManager.getAllProjectNamesList(false);
for (Iterator<String> i = missingProjects.iterator(); i.hasNext(); ) {
String targetProjectName = i.next();
if (allProjects.contains(targetProjectName)) {
Display.getDefault().syncExec(() -> {
try {
ProjectExplorerView pev = getProjectExplorerView();
TreeObject obj = pev.getProjectRootObject(targetProjectName);
if (obj != null && obj instanceof UnloadedProjectTreeObject) {
pev.loadProject(((UnloadedProjectTreeObject) obj));
i.remove();
}
} catch (Exception e) {
Engine.logStudio.warn("Failed to open \"" + targetProjectName + "\"", e);
}
});
}
}
Map<String, ProjectUrlParser> refToImport = new HashMap<>();
for (Reference ref : project.getReferenceList()) {
if (ref instanceof ProjectSchemaReference) {
ProjectSchemaReference prjRef = (ProjectSchemaReference) ref;
if (missingProjects.contains(prjRef.getParser().getProjectName()) && prjRef.getParser().isValid()) {
refToImport.put(prjRef.getParser().getProjectName(), prjRef.getParser());
}
}
}
if (!refToImport.isEmpty()) {
Engine.execute(() -> {
boolean loaded = false;
for (ProjectUrlParser parser : refToImport.values()) {
try {
loaded |= Engine.theApp.referencedProjectManager.importProject(parser) != null;
} catch (Exception e) {
Engine.logStudio.warn("Failed to load '" + parser.getProjectName() + "'", e);
}
}
if (loaded) {
Engine.theApp.fireMigrationFinished(new EngineEvent(""));
}
});
return;
}
String message = "For \"" + project.getName() + "\" project :\n";
for (String targetProjectName : missingProjects) {
message += " > The project \"" + targetProjectName + "\" is missing\n";
}
for (String targetProjectName : missingProjectReferences) {
message += " > The reference to project \"" + targetProjectName + "\" is missing\n";
}
message += "\nPlease create missing reference(s) and import missing project(s), or correct your project.";
if (!missingProjectReferences.isEmpty()) {
final String msg = message;
final String warn = message;
Display.getDefault().syncExec(() -> {
CustomDialog customDialog = new CustomDialog(null, "Project references", msg + "\n\nDo you want to automatically add reference objects ?", 670, 250, new ButtonSpec("Always", true), new ButtonSpec("Never", false));
String autoCreate = ConvertigoPlugin.getProperty(ConvertigoPlugin.PREFERENCE_AUTO_CREATE_PROJECT_REFERENCE);
int response = autoCreate.isEmpty() ? customDialog.open() : (autoCreate.equalsIgnoreCase("true") ? 0 : 1);
ConvertigoPlugin.setProperty(ConvertigoPlugin.PREFERENCE_AUTO_CREATE_PROJECT_REFERENCE, response == 0 ? "true" : "false");
if (response == 0) {
for (String targetProjectName : missingProjectReferences) {
try {
ProjectSchemaReference reference = new ProjectSchemaReference();
String projectName = targetProjectName;
reference.setName(targetProjectName + "_reference");
projectName = ProjectUrlParser.getUrl(projectName);
reference.setProjectName(projectName);
reference.hasChanged = true;
project.add(reference);
} catch (Exception e) {
ConvertigoPlugin.logException(e, "failed to add a reference to '" + targetProjectName + "'");
}
}
try {
if (doReload || autoCreate.isEmpty()) {
ProjectExplorerView pev = getProjectExplorerView();
pev.reloadTreeObject(ProjectTreeObject.this);
}
} catch (Exception e) {
e.printStackTrace();
}
hasBeenModified(true);
} else {
Engine.logBeans.warn(warn);
}
});
} else if (!missingProjects.isEmpty()) {
ConvertigoPlugin.warningMessageBox(message);
}
}
} finally {
isCheckMissingProjects = false;
}
}).schedule();
}
use of com.twinsoft.convertigo.beans.core.Reference in project convertigo by convertigo.
the class ProjectSchemaWizardPage method initialize.
private void initialize() {
if (parentObject instanceof Project) {
Project project = (Project) parentObject;
List<String> projectList = new ArrayList<String>();
projectList.add(project.getName());
List<Reference> references = project.getReferenceList();
for (Reference reference : references) {
if (reference instanceof ProjectSchemaReference) {
projectList.add(((ProjectSchemaReference) reference).getParser().getProjectName());
}
}
for (String name : Engine.theApp.databaseObjectsManager.getAllProjectNamesList()) {
if (!projectList.contains(name)) {
TreeItem branch = new TreeItem(tree, SWT.NONE);
branch.setText(name);
}
}
tree.setVisible(true);
} else
tree.setVisible(false);
}
use of com.twinsoft.convertigo.beans.core.Reference in project convertigo by convertigo.
the class ReferencedProjectManager method getReferenceFromProject.
public ProjectSchemaReference getReferenceFromProject(Project project, String projectName) throws EngineException {
ProjectSchemaReference prjRef = null;
for (Reference ref : project.getReferenceList()) {
if (ref instanceof ProjectSchemaReference) {
prjRef = (ProjectSchemaReference) ref;
if (projectName.equals(prjRef.getParser().getProjectName())) {
break;
} else {
prjRef = null;
}
}
}
if (prjRef == null) {
prjRef = new ProjectSchemaReference();
if (projectName.startsWith("mobilebuilder_tpl_")) {
prjRef.setProjectName(projectName + "=https://github.com/convertigo/c8oprj-mobilebuilder-tpl/archive/" + projectName + ".zip");
} else {
prjRef.setProjectName(projectName);
}
project.add(prjRef);
project.changed();
project.hasChanged = true;
}
return prjRef;
}
Aggregations