Search in sources :

Example 36 with ProjectExplorerView

use of com.twinsoft.convertigo.eclipse.views.projectexplorer.ProjectExplorerView in project convertigo by convertigo.

the class NewProjectWizard method updateProjectTreeView.

private void updateProjectTreeView() {
    ConvertigoPlugin.getDisplay().asyncExec(() -> {
        // refresh the project explorer treeview
        ProjectExplorerView view = (ProjectExplorerView) ConvertigoPlugin.getDefault().getProjectExplorerView();
        try {
            if (projectName != null) {
                view.importProjectTreeObject(projectName);
            }
        } catch (CoreException e) {
            ConvertigoPlugin.logException(e, "An error occured while refreshing the tree view");
        }
        view.viewer.refresh();
    });
}
Also used : ProjectExplorerView(com.twinsoft.convertigo.eclipse.views.projectexplorer.ProjectExplorerView) CoreException(org.eclipse.core.runtime.CoreException)

Example 37 with ProjectExplorerView

use of com.twinsoft.convertigo.eclipse.views.projectexplorer.ProjectExplorerView in project convertigo by convertigo.

the class OperationImportParametersFromVariablesAction method run.

public void run() {
    Display display = Display.getDefault();
    Cursor waitCursor = new Cursor(display, SWT.CURSOR_WAIT);
    Shell shell = getParentShell();
    shell.setCursor(waitCursor);
    try {
        ProjectExplorerView explorerView = getProjectExplorerView();
        if (explorerView != null) {
            TreeObject treeObject = explorerView.getFirstSelectedTreeObject();
            Object databaseObject = treeObject.getObject();
            if ((databaseObject != null) && (databaseObject instanceof UrlMappingOperation)) {
                UrlMappingOperation operation = (UrlMappingOperation) databaseObject;
                String targetRequestable = operation.getTargetRequestable();
                if (!targetRequestable.isEmpty()) {
                    StringTokenizer st = new StringTokenizer(targetRequestable, ".");
                    int count = st.countTokens();
                    String projectName = st.nextToken();
                    String sequenceName = count == 2 ? st.nextToken() : "";
                    String connectorName = count == 3 ? st.nextToken() : "";
                    String transactionName = count == 3 ? st.nextToken() : "";
                    Project project = Engine.theApp.databaseObjectsManager.getProjectByName(projectName);
                    RequestableObject requestableObject = null;
                    if (sequenceName.isEmpty()) {
                        requestableObject = project.getConnectorByName(connectorName).getTransactionByName(transactionName);
                    } else {
                        requestableObject = project.getSequenceByName(sequenceName);
                    }
                    if (requestableObject != null && requestableObject instanceof IVariableContainer) {
                        IVariableContainer variableContainer = (IVariableContainer) requestableObject;
                        for (Variable variable : variableContainer.getVariables()) {
                            String variableName = variable.getName();
                            Object variableValue = variable.getValueOrNull();
                            UrlMappingParameter parameter = null;
                            try {
                                parameter = operation.getParameterByName(variableName);
                            } catch (Exception e) {
                            }
                            if (parameter == null) {
                                if (operation instanceof PostOperation || operation instanceof PutOperation)
                                    parameter = new FormParameter();
                                else
                                    parameter = new QueryParameter();
                                parameter.setName(variableName);
                                parameter.setComment(variable.getComment());
                                parameter.setArray(false);
                                parameter.setExposed(((RequestableVariable) variable).isWsdl());
                                parameter.setMultiValued(variable.isMultiValued());
                                parameter.setRequired(variable.isRequired());
                                parameter.setValueOrNull(!variable.isMultiValued() ? variableValue : null);
                                parameter.setMappedVariableName(variableName);
                                parameter.bNew = true;
                                parameter.hasChanged = true;
                                operation.add(parameter);
                                operation.hasChanged = true;
                            }
                        }
                        if (operation.hasChanged) {
                            explorerView.reloadTreeObject(treeObject);
                            StructuredSelection structuredSelection = new StructuredSelection(treeObject);
                            ConvertigoPlugin.getDefault().getPropertiesView().selectionChanged((IWorkbenchPart) explorerView, structuredSelection);
                        }
                    }
                } else {
                    throw new ConvertigoException("Operation has no target requestable : please select one first.");
                }
            }
        }
    } catch (Throwable e) {
        ConvertigoPlugin.logException(e, "Unable to import variables as new parameters in operation!");
    } finally {
        shell.setCursor(null);
        waitCursor.dispose();
    }
}
Also used : QueryParameter(com.twinsoft.convertigo.beans.rest.QueryParameter) ProjectExplorerView(com.twinsoft.convertigo.eclipse.views.projectexplorer.ProjectExplorerView) UrlMappingOperation(com.twinsoft.convertigo.beans.core.UrlMappingOperation) Variable(com.twinsoft.convertigo.beans.core.Variable) RequestableVariable(com.twinsoft.convertigo.beans.variables.RequestableVariable) RequestableObject(com.twinsoft.convertigo.beans.core.RequestableObject) UrlMappingParameter(com.twinsoft.convertigo.beans.core.UrlMappingParameter) PutOperation(com.twinsoft.convertigo.beans.rest.PutOperation) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) Cursor(org.eclipse.swt.graphics.Cursor) FormParameter(com.twinsoft.convertigo.beans.rest.FormParameter) ConvertigoException(com.twinsoft.convertigo.engine.ConvertigoException) PostOperation(com.twinsoft.convertigo.beans.rest.PostOperation) Project(com.twinsoft.convertigo.beans.core.Project) ConvertigoException(com.twinsoft.convertigo.engine.ConvertigoException) Shell(org.eclipse.swt.widgets.Shell) StringTokenizer(java.util.StringTokenizer) IVariableContainer(com.twinsoft.convertigo.beans.core.IVariableContainer) TreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.TreeObject) TreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.TreeObject) RequestableObject(com.twinsoft.convertigo.beans.core.RequestableObject) Display(org.eclipse.swt.widgets.Display)

Example 38 with ProjectExplorerView

use of com.twinsoft.convertigo.eclipse.views.projectexplorer.ProjectExplorerView in project convertigo by convertigo.

the class ProjectContinuousIntegrationGradle method run.

public void run() {
    Display display = Display.getDefault();
    Cursor waitCursor = new Cursor(display, SWT.CURSOR_WAIT);
    Shell shell = getParentShell();
    shell.setCursor(waitCursor);
    try {
        ProjectExplorerView explorerView = getProjectExplorerView();
        if (explorerView != null) {
            TreeObject treeObject = explorerView.getFirstSelectedTreeObject();
            if (treeObject != null && treeObject instanceof ProjectTreeObject) {
                ProjectTreeObject projectTreeObject = (ProjectTreeObject) treeObject;
                Project project = projectTreeObject.getObject();
                dest = project.getDirFile();
                suffix = "." + new SimpleDateFormat("yy-MM-dd_HH-mm-ss").format(new Date()) + ".bak";
                int code = ConvertigoPlugin.questionMessageBox(shell, "This will put configuration files in your project.\nIf files already exist, your version will be renamed as a '" + suffix + "' file.");
                if (code == SWT.NO) {
                    return;
                }
                String id = action.getId();
                Matcher matcher = Pattern.compile(".*\\.(.*)").matcher(id);
                if (!matcher.matches()) {
                    return;
                }
                String type = matcher.group(1);
                IProject iproject = projectTreeObject.getIProject();
                Job.create("Update CI resources of " + projectTreeObject.getName(), (monitor) -> {
                    try {
                        backupFiles.clear();
                        downloadFiles(BASE_URL + type + ".json");
                        iproject.refreshLocal(1, monitor);
                        if (!backupFiles.isEmpty()) {
                            ConvertigoPlugin.infoMessageBox("Backup done in " + backupFiles);
                        }
                    } catch (Exception e) {
                        Engine.logStudio.error("failed to update gradle resources", e);
                    }
                }).schedule();
            }
        }
    } finally {
        shell.setCursor(null);
        waitCursor.dispose();
    }
}
Also used : Date(java.util.Date) SimpleDateFormat(java.text.SimpleDateFormat) TreeSet(java.util.TreeSet) Matcher(java.util.regex.Matcher) IProject(org.eclipse.core.resources.IProject) CloseableHttpResponse(org.apache.http.client.methods.CloseableHttpResponse) Cursor(org.eclipse.swt.graphics.Cursor) Shell(org.eclipse.swt.widgets.Shell) Job(org.eclipse.core.runtime.jobs.Job) Engine(com.twinsoft.convertigo.engine.Engine) FileOutputStream(java.io.FileOutputStream) Set(java.util.Set) JSONObject(org.codehaus.jettison.json.JSONObject) IOException(java.io.IOException) FileUtils(org.apache.commons.io.FileUtils) JSONArray(org.codehaus.jettison.json.JSONArray) Display(org.eclipse.swt.widgets.Display) TreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.TreeObject) File(java.io.File) StandardCharsets(java.nio.charset.StandardCharsets) Project(com.twinsoft.convertigo.beans.core.Project) ProjectExplorerView(com.twinsoft.convertigo.eclipse.views.projectexplorer.ProjectExplorerView) IOUtils(org.apache.commons.io.IOUtils) ConvertigoPlugin(com.twinsoft.convertigo.eclipse.ConvertigoPlugin) ProjectTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.ProjectTreeObject) HttpGet(org.apache.http.client.methods.HttpGet) SWT(org.eclipse.swt.SWT) Pattern(java.util.regex.Pattern) EngineException(com.twinsoft.convertigo.engine.EngineException) InputStream(java.io.InputStream) ProjectExplorerView(com.twinsoft.convertigo.eclipse.views.projectexplorer.ProjectExplorerView) Matcher(java.util.regex.Matcher) Cursor(org.eclipse.swt.graphics.Cursor) Date(java.util.Date) IProject(org.eclipse.core.resources.IProject) IOException(java.io.IOException) EngineException(com.twinsoft.convertigo.engine.EngineException) IProject(org.eclipse.core.resources.IProject) Project(com.twinsoft.convertigo.beans.core.Project) Shell(org.eclipse.swt.widgets.Shell) TreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.TreeObject) ProjectTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.ProjectTreeObject) ProjectTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.ProjectTreeObject) SimpleDateFormat(java.text.SimpleDateFormat) Display(org.eclipse.swt.widgets.Display)

Example 39 with ProjectExplorerView

use of com.twinsoft.convertigo.eclipse.views.projectexplorer.ProjectExplorerView in project convertigo by convertigo.

the class ProjectDeployAction method run.

public void run() {
    Display display = Display.getDefault();
    Cursor waitCursor = new Cursor(display, SWT.CURSOR_WAIT);
    Shell shell = getParentShell();
    shell.setCursor(waitCursor);
    try {
        ProjectExplorerView explorerView = getProjectExplorerView();
        if (explorerView != null) {
            ProjectTreeObject projectTreeObject = (ProjectTreeObject) explorerView.getFirstSelectedTreeObject();
            Project project = projectTreeObject.getObject();
            if (projectTreeObject.hasChanged() && !projectTreeObject.save(true)) {
                return;
            }
            ArchiveExportOptionDialog dlg = new ArchiveExportOptionDialog(shell, project, true);
            if (dlg.open() != Window.OK) {
                return;
            }
            if (!dlg.getVersion().equals(project.getVersion())) {
                project.setVersion(dlg.getVersion());
                project.hasChanged = true;
                projectTreeObject.save(false);
            }
            explorerView.refreshTreeObject(projectTreeObject);
            ProjectDeployDialog projectDeployDialog = new ProjectDeployDialog(shell, project, dlg.getArchiveExportOptions());
            projectDeployDialog.open();
        }
    } catch (Throwable e) {
        ConvertigoPlugin.logException(e, "Unable to deploy the project!");
    } finally {
        shell.setCursor(null);
        waitCursor.dispose();
    }
}
Also used : Project(com.twinsoft.convertigo.beans.core.Project) Shell(org.eclipse.swt.widgets.Shell) ProjectExplorerView(com.twinsoft.convertigo.eclipse.views.projectexplorer.ProjectExplorerView) ArchiveExportOptionDialog(com.twinsoft.convertigo.eclipse.dialogs.ArchiveExportOptionDialog) ProjectTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.ProjectTreeObject) Cursor(org.eclipse.swt.graphics.Cursor) ProjectDeployDialog(com.twinsoft.convertigo.eclipse.dialogs.ProjectDeployDialog) Display(org.eclipse.swt.widgets.Display)

Example 40 with ProjectExplorerView

use of com.twinsoft.convertigo.eclipse.views.projectexplorer.ProjectExplorerView in project convertigo by convertigo.

the class ProjectExportAction method run.

@Override
public void run() {
    Display display = Display.getDefault();
    Cursor waitCursor = new Cursor(display, SWT.CURSOR_WAIT);
    Shell shell = getParentShell();
    shell.setCursor(waitCursor);
    try {
        ProjectExplorerView explorerView = getProjectExplorerView();
        if (explorerView != null) {
            ProjectTreeObject projectTreeObject = (ProjectTreeObject) explorerView.getFirstSelectedTreeObject();
            Project project = (Project) projectTreeObject.getObject();
            String projectName = project.getName();
            if (projectTreeObject.hasChanged() && !projectTreeObject.save(true)) {
                return;
            }
            ArchiveExportOptionDialog dlg = new ArchiveExportOptionDialog(shell, project, false);
            if (dlg.open() != Window.OK) {
                return;
            }
            if (!dlg.getVersion().equals(project.getVersion())) {
                project.setVersion(dlg.getVersion());
                project.hasChanged = true;
                projectTreeObject.save(false);
            }
            explorerView.refreshTreeObject(projectTreeObject);
            String projectArchive = projectName + ".car";
            FileDialog fileDialog = new FileDialog(shell, SWT.PRIMARY_MODAL | SWT.SAVE);
            fileDialog.setText("Export a project");
            fileDialog.setFilterExtensions(new String[] { "*.car", "*.zip" });
            fileDialog.setFilterNames(new String[] { "Convertigo archives", "Convertigo archives as zip" });
            fileDialog.setFilterPath(Engine.PROJECTS_PATH);
            fileDialog.setFileName(projectArchive);
            String filePath = fileDialog.open();
            if (filePath != null) {
                File file = new File(filePath);
                if (file.exists()) {
                    if (ConvertigoPlugin.questionMessageBox(shell, "File already exists. Do you want to overwrite?") == SWT.YES) {
                        if (!file.delete()) {
                            ConvertigoPlugin.warningMessageBox("Error when deleting the file " + file.getName() + "! Please verify access rights!");
                            return;
                        }
                    } else {
                        return;
                    }
                }
                if (Pattern.matches(".+(\\.zip|\\.car)", file.getName())) {
                    CarUtils.makeArchive(file, project, dlg.getArchiveExportOptions());
                } else {
                    Toolkit.getDefaultToolkit().beep();
                    ConvertigoPlugin.logWarning("Wrong file extension!");
                }
            }
            projectTreeObject.getIProject().refreshLocal(IResource.DEPTH_ONE, null);
            explorerView.setFocus();
            explorerView.setSelectedTreeObject(projectTreeObject);
        }
    } catch (Throwable e) {
        ConvertigoPlugin.logException(e, "Unable to export the project!");
    } finally {
        shell.setCursor(null);
        waitCursor.dispose();
    }
}
Also used : Project(com.twinsoft.convertigo.beans.core.Project) Shell(org.eclipse.swt.widgets.Shell) ProjectExplorerView(com.twinsoft.convertigo.eclipse.views.projectexplorer.ProjectExplorerView) ArchiveExportOptionDialog(com.twinsoft.convertigo.eclipse.dialogs.ArchiveExportOptionDialog) ProjectTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.ProjectTreeObject) Cursor(org.eclipse.swt.graphics.Cursor) FileDialog(org.eclipse.swt.widgets.FileDialog) File(java.io.File) Display(org.eclipse.swt.widgets.Display)

Aggregations

ProjectExplorerView (com.twinsoft.convertigo.eclipse.views.projectexplorer.ProjectExplorerView)175 Cursor (org.eclipse.swt.graphics.Cursor)144 Display (org.eclipse.swt.widgets.Display)144 Shell (org.eclipse.swt.widgets.Shell)144 TreeObject (com.twinsoft.convertigo.eclipse.views.projectexplorer.model.TreeObject)113 DatabaseObjectTreeObject (com.twinsoft.convertigo.eclipse.views.projectexplorer.model.DatabaseObjectTreeObject)73 DatabaseObject (com.twinsoft.convertigo.beans.core.DatabaseObject)49 TreeParent (com.twinsoft.convertigo.eclipse.views.projectexplorer.TreeParent)38 Sequence (com.twinsoft.convertigo.beans.core.Sequence)35 EngineException (com.twinsoft.convertigo.engine.EngineException)26 Project (com.twinsoft.convertigo.beans.core.Project)24 Step (com.twinsoft.convertigo.beans.core.Step)22 TreeObjectEvent (com.twinsoft.convertigo.eclipse.views.projectexplorer.TreeObjectEvent)22 ProjectTreeObject (com.twinsoft.convertigo.eclipse.views.projectexplorer.model.ProjectTreeObject)22 StepTreeObject (com.twinsoft.convertigo.eclipse.views.projectexplorer.model.StepTreeObject)21 StepWithExpressions (com.twinsoft.convertigo.beans.core.StepWithExpressions)19 CompositeEvent (com.twinsoft.convertigo.eclipse.editors.CompositeEvent)19 StepEvent (com.twinsoft.convertigo.beans.core.StepEvent)15 Transaction (com.twinsoft.convertigo.beans.core.Transaction)14 File (java.io.File)14