use of bndtools.release.ui.WorkspaceReleaseDialog in project bndtools by bndtools.
the class WorkspaceAnalyserJob method run.
@Override
protected IStatus run(IProgressMonitor monitor) {
IProgressMonitor mon = monitor;
if (mon == null) {
mon = new NullProgressMonitor();
}
try {
Collection<Project> projects = Activator.getWorkspace().getAllProjects();
mon.beginTask(Messages.workspaceReleaseJob, projects.size() * 2);
List<Project> orderedProjects = getBuildOrder(mon, Activator.getWorkspace());
if (mon.isCanceled()) {
return Status.CANCEL_STATUS;
}
final List<ProjectDiff> projectDiffs = new ArrayList<ProjectDiff>();
mon.setTaskName(Messages.processingProjects);
for (Project project : orderedProjects) {
IProject eProject = ReleaseUtils.getProject(project);
if (!isIncluded(eProject)) {
mon.worked(1);
continue;
}
if ("".equals(project.getProperty(Constants.RELEASEREPO, null))) {
mon.worked(1);
continue;
}
if (eProject == null || !eProject.isOpen() || !eProject.isAccessible()) {
mon.worked(1);
continue;
}
List<Baseline> jarDiffs = null;
try (ProjectBuilder pb = project.getBuilder(null)) {
for (Builder b : pb.getSubBuilders()) {
mon.subTask(String.format(Messages.processingProject, b.getBsn()));
Baseline jarDiff = DiffHelper.createBaseline(b);
if (jarDiff != null) {
if (jarDiffs == null) {
jarDiffs = new ArrayList<Baseline>();
}
jarDiffs.add(jarDiff);
}
}
}
if (jarDiffs != null && jarDiffs.size() > 0) {
projectDiffs.add(new ProjectDiff(project, jarDiffs));
}
if (mon.isCanceled()) {
return Status.CANCEL_STATUS;
}
mon.worked(1);
}
if (projectDiffs.size() == 0) {
Runnable runnable = new Runnable() {
@Override
public void run() {
MessageDialog.openInformation(shell, Messages.releaseWorkspaceBundles, Messages.noBundlesRequireRelease);
}
};
if (Display.getCurrent() == null) {
Display.getDefault().syncExec(runnable);
} else {
runnable.run();
}
return Status.OK_STATUS;
}
ReleaseHelper.initializeProjectDiffs(projectDiffs);
Runnable runnable = new Runnable() {
@Override
public void run() {
WorkspaceReleaseDialog dialog = new WorkspaceReleaseDialog(shell, projectDiffs, false);
int ret = dialog.open();
if (ret == Window.OK) {
boolean runJob = false;
for (ProjectDiff diff : projectDiffs) {
if (diff.isRelease()) {
runJob = true;
break;
}
}
if (!runJob) {
return;
}
WorkspaceReleaseJob releaseJob = new WorkspaceReleaseJob(projectDiffs, dialog.getReleaseOption(), dialog.isShowMessage());
releaseJob.setRule(ResourcesPlugin.getWorkspace().getRoot());
releaseJob.schedule();
}
}
};
if (Display.getCurrent() == null) {
Display.getDefault().asyncExec(runnable);
} else {
runnable.run();
}
} catch (Exception e) {
return new Status(IStatus.ERROR, Activator.PLUGIN_ID, e.getMessage(), e);
}
return Status.OK_STATUS;
}
use of bndtools.release.ui.WorkspaceReleaseDialog in project bndtools by bndtools.
the class ReleaseDialogJob method run.
@Override
protected IStatus run(IProgressMonitor monitor) {
try {
monitor.beginTask(Messages.cleaningProject, 100);
monitor.setTaskName(Messages.releasing);
monitor.worked(33);
monitor.subTask(Messages.checkingExported);
final List<Baseline> diffs = new ArrayList<Baseline>();
try (ProjectBuilder pb = project.getBuilder(null)) {
for (Builder builder : pb.getSubBuilders()) {
if (subBundles != null) {
if (!subBundles.contains(builder.getPropertiesFile())) {
continue;
}
}
Baseline diff = DiffHelper.createBaseline(builder);
if (diff != null) {
diffs.add(diff);
}
}
}
if (diffs.size() == 0) {
// TODO: message
return Status.OK_STATUS;
}
monitor.worked(33);
Runnable runnable = new Runnable() {
@Override
public void run() {
List<ProjectDiff> projectDiffs = new ArrayList<ProjectDiff>();
projectDiffs.add(new ProjectDiff(project, diffs));
ReleaseHelper.initializeProjectDiffs(projectDiffs);
WorkspaceReleaseDialog dialog = new WorkspaceReleaseDialog(shell, projectDiffs, true);
if (dialog.open() == Window.OK) {
boolean runJob = false;
for (ProjectDiff diff : projectDiffs) {
if (diff.isRelease()) {
runJob = true;
break;
}
}
if (!runJob) {
return;
}
WorkspaceReleaseJob releaseJob = new WorkspaceReleaseJob(projectDiffs, dialog.getReleaseOption(), dialog.isShowMessage());
releaseJob.setRule(ResourcesPlugin.getWorkspace().getRoot());
releaseJob.schedule();
}
}
};
if (Display.getCurrent() == null) {
Display.getDefault().asyncExec(runnable);
} else {
runnable.run();
}
monitor.worked(33);
return Status.OK_STATUS;
} catch (Exception e) {
return new Status(IStatus.ERROR, Activator.PLUGIN_ID, "Error : " + e.getMessage(), e);
} finally {
monitor.done();
}
}
Aggregations