(1) Runnable for backend long run processes and Progress Handle management
Runnable allRunnable = new Runnable() {
WorkspaceMgr mgr = null;
Workspace ws = PerforceConfig.getDefault().getDefaultWorkspace();
ProgressHandle handle = null;
public void run() {
try {
handle = ProgressHandleFactory.createHandle(NbBundle.getMessage(PerforceAnnotator.class, "CTL_PopupMenuItem_ViewAllChangelist"));
mgr = new WorkspaceMgr(ws);
handle.start();
showAllChangelist(changes);
SwingUtilities.invokeLater(new Runnable() {
public void run() {
ChangelistView comp = ChangelistView.findInstance();
VersioningOutputManager.getInstance().addComponent(NbBundle.getMessage(PerforceAnnotator.class, "CTL_PopupMenuItem_ViewAllChangelist"), comp);
comp.setContext(ctx, changes);
comp.setDisplayName(NbBundle.getMessage(PerforceAnnotator.class, "CTL_PopupMenuItem_ViewAllChangelist"));
//comp.open();
comp.requestActive();
}
});
} catch (WorkspaceException ex) {
Exceptions.printStackTrace(ex);
} finally {
handle.finish();
}
}
};
(2) UI current thread context
if (cmd.equals(NbBundle.getMessage(PerforceAnnotator.class, "CTL_PopupMenuItem_ViewAllChangelist"))) {
RequestProcessor.getDefault().post(allRunnable);
}
(3) So, current thread, spawn thread for progress bar and backend process, back to UI population
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment