use of com.twinsoft.convertigo.eclipse.dialogs.ArchiveExportOptionDialog 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.dialogs.ArchiveExportOptionDialog 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