use of com.centurylink.mdw.plugin.project.assembly.ProjectImporter in project mdw-designer by CenturyLinkCloud.
the class MdwWorkbenchWindowAdvisor method postWindowOpen.
public void postWindowOpen() {
IWorkbenchPage activePage = Activator.getActivePage();
// check for updates
// IHandlerService handlerService = (IHandlerService)
// activePage.getWorkbenchWindow().getService(IHandlerService.class);
// try
// {
// Object result =
// handlerService.executeCommand("org.eclipse.equinox.p2.ui.sdk.update", null);
// System.out.println("result: " + result);
// if (result != null)
// System.out.println("result class: " + result.getClass().getName());
// }
// catch (Exception ex)
// {
// ex.printStackTrace();
// }
PluginMessages.log("MDW workbench startup...");
if (activePage != null) {
activePage.hideActionSet("com.centurylink.mdw.plugin.actionset.tools");
activePage.hideActionSet("com.centurylink.mdw.plugin.actionset.dev");
activePage.hideActionSet("com.centurylink.mdw.plugin.actionset.designerClassic");
activePage.hideActionSet("org.eclipse.ui.edit.text.actionSet.navigation");
activePage.hideActionSet("org.eclipse.ui.edit.text.actionSet.annotationNavigation");
activePage.hideActionSet("org.eclipse.ui.externaltools.ExternalToolsSet");
activePage.showActionSet("org.eclipse.search.menu");
// make sure the process explorer view is visible
try {
ProcessExplorerView processExplorerView = (ProcessExplorerView) activePage.showView("mdw.views.designer.processes");
if (mdwHost != null && mdwPort != null) {
final Shell shell = activePage.getActivePart().getSite().getShell();
BusyIndicator.showWhile(shell.getDisplay(), new Runnable() {
public void run() {
try {
discoveryException = null;
projectToImport = getWorkflowProject(mdwHost, mdwPort, mdwContextRoot);
if (projectToImport == null)
throw new DiscoveryException("Unable to discover workflow app at: " + mdwHost + ":" + mdwPort);
} catch (DiscoveryException ex) {
discoveryException = ex;
}
}
});
if (discoveryException != null)
throw discoveryException;
WorkflowProject existing = WorkflowProjectManager.getInstance().getRemoteWorkflowProject(projectToImport.getName());
if (existing != null)
WorkflowProjectManager.getInstance().deleteProject(existing);
ProgressMonitorDialog progMonDlg = new ProgressMonitorDialog(shell);
ProjectInflator projectInflator = new ProjectInflator(projectToImport, null);
projectInflator.inflateRemoteProject(progMonDlg);
ProjectImporter projectImporter = new ProjectImporter(projectToImport);
projectImporter.doImport();
processExplorerView.handleRefresh();
// handle preselected entity
if (preselectType != null && preselectType.trim().length() > 0 && preselectId != null && preselectId.trim().length() > 0) {
if (!preselectType.equals(PRESELECT_PROCESS_INSTANCE))
throw new UnsupportedOperationException("Unsupported preselect type: " + preselectType);
BusyIndicator.showWhile(shell.getDisplay(), new Runnable() {
public void run() {
// open the process instance
IWorkbenchPage page = MdwPlugin.getActivePage();
try {
WorkflowProcess instance = getProcessInstance(new Long(preselectId));
page.openEditor(instance, "mdw.editors.process");
page.showView("org.eclipse.ui.views.PropertySheet");
} catch (PartInitException ex) {
PluginMessages.uiError(ex, "Open Process Instance", projectToImport);
}
}
});
}
}
} catch (Exception ex) {
PluginMessages.uiError(ex, "Initialize Workspace");
}
}
}
use of com.centurylink.mdw.plugin.project.assembly.ProjectImporter in project mdw-designer by CenturyLinkCloud.
the class ImportProjectWizard method performFinish.
@Override
public boolean performFinish() {
if (errorMessage != null) {
MessageDialog.openError(getShell(), "Import Project", errorMessage);
return false;
}
BusyIndicator.showWhile(getShell().getDisplay(), new Runnable() {
public void run() {
List<IProject> existingProjects = new ArrayList<>();
for (WorkflowProject toImport : projectsToImport) {
IProject existing = MdwPlugin.getWorkspaceRoot().getProject(toImport.getName());
if (existing != null && existing.exists())
existingProjects.add(existing);
}
if (!existingProjects.isEmpty()) {
String text = "Please confirm that the following workspace projects should be overwritten:";
ListSelectionDialog lsd = new ListSelectionDialog(getShell(), existingProjects, new ExistingProjectContentProvider(), new ProjectLabelProvider(), text);
lsd.setTitle("Existing Projects");
lsd.setInitialSelections(existingProjects.toArray(new IProject[0]));
lsd.open();
Object[] results = lsd.getResult();
if (results == null) {
cancel = true;
return;
}
for (IProject existing : existingProjects) {
boolean include = false;
for (Object included : results) {
if (existing.getName().equals(((IProject) included).getName()))
include = true;
}
if (include) {
WorkflowProjectManager.getInstance().deleteProject(existing);
} else {
WorkflowProject toRemove = null;
for (WorkflowProject wfp : projectList) {
if (wfp.getName().equals(existing.getName())) {
toRemove = wfp;
break;
}
}
if (toRemove != null)
projectsToImport.remove(toRemove);
}
}
}
}
});
if (cancel)
return false;
if (projectsToImport.isEmpty()) {
MessageDialog.openInformation(getShell(), "Import Projects", "No projects to import.");
return true;
}
try {
getContainer().run(false, false, new IRunnableWithProgress() {
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
monitor.beginTask("Importing MDW project(s)", 100);
monitor.worked(20);
try {
for (WorkflowProject workflowProject : projectsToImport) {
if (workflowProject.isFilePersist()) {
File projectDir = new File(ResourcesPlugin.getWorkspace().getRoot().getLocation().toFile() + "/" + workflowProject.getName());
projectDir.mkdir();
String repositoryUrl = projectsToImport.get(0).getMdwVcsRepository().getRepositoryUrl();
if (repositoryUrl != null && repositoryUrl.length() > 0) {
// avoid
Platform.getBundle("org.eclipse.egit.ui").start();
// Eclipse
// default
// Authenticator
workflowProject.setPersistType(PersistType.Git);
workflowProject.getMdwVcsRepository().setProvider(VcsRepository.PROVIDER_GIT);
monitor.subTask("Cloning Git repository for " + workflowProject.getLabel());
monitor.worked(1);
VcsRepository gitRepo = workflowProject.getMdwVcsRepository();
VersionControlGit vcsGit = new VersionControlGit();
String user = null;
String password = null;
if (MdwPlugin.getSettings().isUseDiscoveredVcsCredentials()) {
user = gitRepo.getUser();
password = gitRepo.getPassword();
}
vcsGit.connect(gitRepo.getRepositoryUrl(), user, password, projectDir);
vcsGit.cloneRepo();
} else {
File assetDir = new File(projectDir + "/" + workflowProject.getMdwVcsRepository().getLocalPath());
assetDir.mkdirs();
}
monitor.worked(40 / projectsToImport.size());
}
ProjectInflator inflator = new ProjectInflator(workflowProject, MdwPlugin.getSettings());
inflator.inflateRemoteProject(getContainer());
}
} catch (Exception ex) {
throw new InvocationTargetException(ex);
}
ProjectImporter projectImporter = new ProjectImporter(projectsToImport);
projectImporter.doImport();
monitor.worked(20);
monitor.done();
}
});
} catch (Exception ex) {
PluginMessages.uiError(ex, "Import Project");
return false;
}
DesignerPerspective.openPerspective(activeWindow);
return true;
}
Aggregations