Search in sources :

Example 6 with ProjectUrlParser

use of com.twinsoft.convertigo.engine.util.ProjectUrlParser in project convertigo by convertigo.

the class ImportWizardPage method createControl.

/* (non-Javadoc)
	 * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
	 */
public void createControl(Composite parent) {
    Composite page = new Composite(parent, SWT.NONE);
    page.setLayout(new GridLayout(2, false));
    GridData gd = new GridData(SWT.FILL, SWT.FILL, true, false);
    gd.horizontalSpan = 2;
    Composite fileSelectionArea = new Composite(page, SWT.NONE);
    fileSelectionArea.setLayoutData(gd);
    editor = new ProjectFileFieldEditor("fileSelect", "Select File: ", fileSelectionArea);
    editor.getTextControl(fileSelectionArea).addModifyListener(new ModifyListener() {

        public void modifyText(ModifyEvent e) {
            IPath path = new Path(ImportWizardPage.this.editor.getStringValue());
            filePath = path.toString();
            updateStatus();
        }
    });
    gd = new GridData(SWT.FILL, SWT.FILL, true, false);
    gd.horizontalSpan = 2;
    new Label(page, SWT.HORIZONTAL | SWT.SEPARATOR).setLayoutData(gd);
    gd = new GridData(SWT.FILL, SWT.FILL, true, false);
    gd.horizontalSpan = 2;
    Label label = new Label(page, SWT.NONE);
    label.setLayoutData(gd);
    label.setText("Project can also be imported by a \"Project remote URL\":");
    gd = new GridData(SWT.FILL, SWT.FILL, true, false);
    gd.horizontalSpan = 2;
    projectReferenceComposite = new ProjectReferenceComposite(page, SWT.NONE, new ProjectUrlParser(""), () -> updateStatus());
    projectReferenceComposite.setLayoutData(gd);
    updateStatus();
    setControl(page);
}
Also used : IPath(org.eclipse.core.runtime.IPath) Path(org.eclipse.core.runtime.Path) ProjectReferenceComposite(com.twinsoft.convertigo.eclipse.swt.ProjectReferenceComposite) ProjectUrlParser(com.twinsoft.convertigo.engine.util.ProjectUrlParser) GridLayout(org.eclipse.swt.layout.GridLayout) ModifyEvent(org.eclipse.swt.events.ModifyEvent) ProjectReferenceComposite(com.twinsoft.convertigo.eclipse.swt.ProjectReferenceComposite) Composite(org.eclipse.swt.widgets.Composite) ModifyListener(org.eclipse.swt.events.ModifyListener) IPath(org.eclipse.core.runtime.IPath) GridData(org.eclipse.swt.layout.GridData) Label(org.eclipse.swt.widgets.Label)

Example 7 with ProjectUrlParser

use of com.twinsoft.convertigo.engine.util.ProjectUrlParser in project convertigo by convertigo.

the class ProjectSchemaReference method setProjectName.

public void setProjectName(String projectName) {
    this.projectName = projectName;
    parser = new ProjectUrlParser(projectName);
}
Also used : ProjectUrlParser(com.twinsoft.convertigo.engine.util.ProjectUrlParser)

Example 8 with ProjectUrlParser

use of com.twinsoft.convertigo.engine.util.ProjectUrlParser 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();
}
Also used : TreeObjectEvent(com.twinsoft.convertigo.eclipse.views.projectexplorer.TreeObjectEvent) IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) CoreException(org.eclipse.core.runtime.CoreException) Step(com.twinsoft.convertigo.beans.core.Step) JScriptEditorInput(com.twinsoft.convertigo.eclipse.editors.jscript.JScriptEditorInput) NamespaceUriValidator(com.twinsoft.convertigo.eclipse.property_editors.validators.NamespaceUriValidator) IPath(org.eclipse.core.runtime.IPath) PartInitException(org.eclipse.ui.PartInitException) Map(java.util.Map) IViewPart(org.eclipse.ui.IViewPart) ConnectorEditor(com.twinsoft.convertigo.eclipse.editors.connector.ConnectorEditor) Cursor(org.eclipse.swt.graphics.Cursor) RequestableStep(com.twinsoft.convertigo.beans.core.RequestableStep) GenericUtils(com.twinsoft.convertigo.engine.util.GenericUtils) IEditorInput(org.eclipse.ui.IEditorInput) PlatformUI(org.eclipse.ui.PlatformUI) Set(java.util.Set) Display(org.eclipse.swt.widgets.Display) StepWithExpressions(com.twinsoft.convertigo.beans.core.StepWithExpressions) IResourceChangeEvent(org.eclipse.core.resources.IResourceChangeEvent) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) ConvertigoPlugin(com.twinsoft.convertigo.eclipse.ConvertigoPlugin) List(java.util.List) Reference(com.twinsoft.convertigo.beans.core.Reference) Sequence(com.twinsoft.convertigo.beans.core.Sequence) Transaction(com.twinsoft.convertigo.beans.core.Transaction) Path(org.eclipse.core.runtime.Path) SWT(org.eclipse.swt.SWT) IResourceChangeListener(org.eclipse.core.resources.IResourceChangeListener) SequenceEditorInput(com.twinsoft.convertigo.eclipse.editors.sequence.SequenceEditorInput) EngineException(com.twinsoft.convertigo.engine.EngineException) SequenceEditor(com.twinsoft.convertigo.eclipse.editors.sequence.SequenceEditor) SourcePickerView(com.twinsoft.convertigo.eclipse.views.sourcepicker.SourcePickerView) CouchDbConnector(com.twinsoft.convertigo.beans.connectors.CouchDbConnector) IFolder(org.eclipse.core.resources.IFolder) ResourcesPlugin(org.eclipse.core.resources.ResourcesPlugin) TraceFileEditorInput(com.twinsoft.convertigo.eclipse.editors.text.TraceFileEditorInput) EngineEvent(com.twinsoft.convertigo.engine.EngineEvent) HashMap(java.util.HashMap) ProjectUrlParser(com.twinsoft.convertigo.engine.util.ProjectUrlParser) ConvertigoException(com.twinsoft.convertigo.engine.ConvertigoException) JsonIndex(com.twinsoft.convertigo.beans.couchdb.JsonIndex) ArrayList(java.util.ArrayList) MobileBuilder(com.twinsoft.convertigo.engine.mobile.MobileBuilder) SequenceStep(com.twinsoft.convertigo.beans.steps.SequenceStep) Connector(com.twinsoft.convertigo.beans.core.Connector) IProject(org.eclipse.core.resources.IProject) IResourceDelta(org.eclipse.core.resources.IResourceDelta) CustomDialog(com.twinsoft.convertigo.eclipse.dialogs.CustomDialog) IFile(org.eclipse.core.resources.IFile) DatabaseObject(com.twinsoft.convertigo.beans.core.DatabaseObject) ICellEditorValidator(org.eclipse.jface.viewers.ICellEditorValidator) FileEditorInput(org.eclipse.ui.part.FileEditorInput) ProjectSchemaReference(com.twinsoft.convertigo.beans.references.ProjectSchemaReference) Shell(org.eclipse.swt.widgets.Shell) Iterator(java.util.Iterator) Viewer(org.eclipse.jface.viewers.Viewer) Job(org.eclipse.core.runtime.jobs.Job) Engine(com.twinsoft.convertigo.engine.Engine) IResourceDeltaVisitor(org.eclipse.core.resources.IResourceDeltaVisitor) CouchDbManager(com.twinsoft.convertigo.engine.providers.couchdb.CouchDbManager) Project(com.twinsoft.convertigo.beans.core.Project) ProjectExplorerView(com.twinsoft.convertigo.eclipse.views.projectexplorer.ProjectExplorerView) IResource(org.eclipse.core.resources.IResource) MessageBox(org.eclipse.swt.widgets.MessageBox) IEditorReference(org.eclipse.ui.IEditorReference) ButtonSpec(com.twinsoft.convertigo.eclipse.dialogs.ButtonSpec) TransactionStep(com.twinsoft.convertigo.beans.steps.TransactionStep) ConnectorEditorInput(com.twinsoft.convertigo.eclipse.editors.connector.ConnectorEditorInput) ProjectUrlParser(com.twinsoft.convertigo.engine.util.ProjectUrlParser) Set(java.util.Set) ProjectExplorerView(com.twinsoft.convertigo.eclipse.views.projectexplorer.ProjectExplorerView) ProjectSchemaReference(com.twinsoft.convertigo.beans.references.ProjectSchemaReference) Reference(com.twinsoft.convertigo.beans.core.Reference) ProjectSchemaReference(com.twinsoft.convertigo.beans.references.ProjectSchemaReference) IEditorReference(org.eclipse.ui.IEditorReference) CoreException(org.eclipse.core.runtime.CoreException) PartInitException(org.eclipse.ui.PartInitException) EngineException(com.twinsoft.convertigo.engine.EngineException) ConvertigoException(com.twinsoft.convertigo.engine.ConvertigoException) IProject(org.eclipse.core.resources.IProject) Project(com.twinsoft.convertigo.beans.core.Project) CustomDialog(com.twinsoft.convertigo.eclipse.dialogs.CustomDialog) Iterator(java.util.Iterator) EngineEvent(com.twinsoft.convertigo.engine.EngineEvent) List(java.util.List) ArrayList(java.util.ArrayList) Map(java.util.Map) HashMap(java.util.HashMap) ButtonSpec(com.twinsoft.convertigo.eclipse.dialogs.ButtonSpec)

Example 9 with ProjectUrlParser

use of com.twinsoft.convertigo.engine.util.ProjectUrlParser in project convertigo by convertigo.

the class ReferencedProjectManager method check.

private boolean check(List<String> names) {
    boolean loaded = false;
    Map<String, ProjectUrlParser> refs = new HashMap<>();
    for (String name : names) {
        try {
            Project project = Engine.theApp.databaseObjectsManager.getOriginalProjectByName(name, true);
            if (project != null) {
                loaded |= check(project, refs);
            }
        } catch (Exception e) {
            Engine.logEngine.error("Failed to load " + name, e);
        }
    }
    return loaded;
}
Also used : ProjectUrlParser(com.twinsoft.convertigo.engine.util.ProjectUrlParser) Project(com.twinsoft.convertigo.beans.core.Project) HashMap(java.util.HashMap)

Example 10 with ProjectUrlParser

use of com.twinsoft.convertigo.engine.util.ProjectUrlParser in project convertigo by convertigo.

the class ReferencedProjectManager method check.

private boolean check(Project project, Map<String, ProjectUrlParser> refs) {
    project.getReferenceList().forEach(r -> {
        if (r instanceof ProjectSchemaReference) {
            ProjectSchemaReference ref = (ProjectSchemaReference) r;
            String url = ref.getProjectName();
            ProjectUrlParser parser = new ProjectUrlParser(url);
            if (parser.isValid()) {
                refs.put(parser.getProjectName(), parser);
            }
        }
    });
    return check(refs);
}
Also used : ProjectUrlParser(com.twinsoft.convertigo.engine.util.ProjectUrlParser) ProjectSchemaReference(com.twinsoft.convertigo.beans.references.ProjectSchemaReference)

Aggregations

ProjectUrlParser (com.twinsoft.convertigo.engine.util.ProjectUrlParser)10 Project (com.twinsoft.convertigo.beans.core.Project)5 ProjectSchemaReference (com.twinsoft.convertigo.beans.references.ProjectSchemaReference)2 ConvertigoPlugin (com.twinsoft.convertigo.eclipse.ConvertigoPlugin)2 ProjectExplorerView (com.twinsoft.convertigo.eclipse.views.projectexplorer.ProjectExplorerView)2 Engine (com.twinsoft.convertigo.engine.Engine)2 EngineException (com.twinsoft.convertigo.engine.EngineException)2 File (java.io.File)2 HashMap (java.util.HashMap)2 IPath (org.eclipse.core.runtime.IPath)2 Path (org.eclipse.core.runtime.Path)2 CouchDbConnector (com.twinsoft.convertigo.beans.connectors.CouchDbConnector)1 Connector (com.twinsoft.convertigo.beans.core.Connector)1 DatabaseObject (com.twinsoft.convertigo.beans.core.DatabaseObject)1 Reference (com.twinsoft.convertigo.beans.core.Reference)1 RequestableStep (com.twinsoft.convertigo.beans.core.RequestableStep)1 Sequence (com.twinsoft.convertigo.beans.core.Sequence)1 Step (com.twinsoft.convertigo.beans.core.Step)1 StepWithExpressions (com.twinsoft.convertigo.beans.core.StepWithExpressions)1 Transaction (com.twinsoft.convertigo.beans.core.Transaction)1