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();
});
}
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();
}
}
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();
}
}
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();
}
}
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();
}
}
Aggregations