Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrescobar2010-07-20 20:52:40 +0000
committerrescobar2010-07-20 20:52:40 +0000
commita88b295f5a066c21fce3aefc406d1e922ca44733 (patch)
tree2df201f4b2513b0ef1c521d0144db43580cb4aac /plugins/org.eclipse.osee.framework.ui.branch.graph/src
parent9dd043fbb2a826276a59d95ae1b0ddc5df14b21c (diff)
downloadorg.eclipse.osee-a88b295f5a066c21fce3aefc406d1e922ca44733.tar.gz
org.eclipse.osee-a88b295f5a066c21fce3aefc406d1e922ca44733.tar.xz
org.eclipse.osee-a88b295f5a066c21fce3aefc406d1e922ca44733.zip
Refactored to use Displays class
Diffstat (limited to 'plugins/org.eclipse.osee.framework.ui.branch.graph/src')
-rw-r--r--plugins/org.eclipse.osee.framework.ui.branch.graph/src/org/eclipse/osee/framework/ui/branch/graph/core/BranchGraphPaletteProvider.java171
-rw-r--r--plugins/org.eclipse.osee.framework.ui.branch.graph/src/org/eclipse/osee/framework/ui/branch/graph/operation/LoadGraphOperation.java194
2 files changed, 184 insertions, 181 deletions
diff --git a/plugins/org.eclipse.osee.framework.ui.branch.graph/src/org/eclipse/osee/framework/ui/branch/graph/core/BranchGraphPaletteProvider.java b/plugins/org.eclipse.osee.framework.ui.branch.graph/src/org/eclipse/osee/framework/ui/branch/graph/core/BranchGraphPaletteProvider.java
index 8dcba9e5203..61b945c1609 100644
--- a/plugins/org.eclipse.osee.framework.ui.branch.graph/src/org/eclipse/osee/framework/ui/branch/graph/core/BranchGraphPaletteProvider.java
+++ b/plugins/org.eclipse.osee.framework.ui.branch.graph/src/org/eclipse/osee/framework/ui/branch/graph/core/BranchGraphPaletteProvider.java
@@ -24,97 +24,98 @@ import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.osee.framework.ui.branch.graph.BranchGraphActivator;
import org.eclipse.osee.framework.ui.plugin.OseeUiActions;
import org.eclipse.osee.framework.ui.skynet.FrameworkImage;
+import org.eclipse.osee.framework.ui.swt.Displays;
import org.eclipse.osee.framework.ui.swt.ImageManager;
import org.eclipse.osee.framework.ui.swt.KeyedImage;
-import org.eclipse.swt.widgets.Display;
/**
* @author Roberto E. Escobar
*/
public class BranchGraphPaletteProvider {
- private static final String[] drawerNames = new String[] {"Filters"};
- private PaletteRoot paletteRoot;
- private final BranchGraphEditor editor;
-
- public BranchGraphPaletteProvider(BranchGraphEditor editor) {
- this.paletteRoot = null;
- this.editor = editor;
- }
-
- public PaletteRoot getPaletteRoot() {
- if (paletteRoot == null) {
- paletteRoot = new PaletteRoot();
- paletteRoot.add(createToolsGroup(paletteRoot));
- // addDrawers(paletteRoot);
- }
- return paletteRoot;
- }
-
- private void addDrawers(PaletteRoot paletteRoot) {
- for (String drawerName : drawerNames) {
- PaletteContainer container = new PaletteDrawer(drawerName);
-
- String name = "one";
- String description = "example";
- Class<?> clazz = Object.class;
-
- container.add(createComponent(name, description, clazz, FrameworkImage.RECTANGLE_16,
- FrameworkImage.RECTANGLE_24));
- paletteRoot.add(container);
- }
- }
-
- private ToolEntry createComponent(String label, String description, Class<?> clazz, KeyedImage smallImage, KeyedImage largeImage) {
- ToolEntry toolEntry =
- new ToolEntry(label, description, ImageManager.getImageDescriptor(smallImage),
- ImageManager.getImageDescriptor(largeImage)) {
-
- };
- return toolEntry;
- }
-
- private PaletteContainer createToolsGroup(PaletteRoot palette) {
- PaletteToolbar toolbar = new PaletteToolbar("Tools");
-
- ToolEntry tool = new PanningSelectionToolEntry();
- toolbar.add(tool);
- palette.setDefaultEntry(tool);
-
- toolbar.add(new MarqueeToolEntry());
-
- final Action action =
- OseeUiActions.createBugAction(BranchGraphActivator.getInstance(), editor, BranchGraphEditor.EDITOR_ID,
- "Branch Graph");
- final ImageDescriptor img = action.getImageDescriptor();
-
- toolbar.add(new ToolEntry("", action.getText(), img, img, null) {
-
- @Override
- public Tool createTool() {
- return new AbstractTool() {
-
- @Override
- protected String getCommandName() {
- return action.getText();
- }
-
- @Override
- public void activate() {
- super.activate();
- Display.getDefault().asyncExec(new Runnable() {
- public void run() {
- deactivate();
- action.run();
- }
- });
-
- }
- };
- }
-
- });
-
- return toolbar;
- }
+ private static final String[] drawerNames = new String[] {"Filters"};
+ private PaletteRoot paletteRoot;
+ private final BranchGraphEditor editor;
+
+ public BranchGraphPaletteProvider(BranchGraphEditor editor) {
+ this.paletteRoot = null;
+ this.editor = editor;
+ }
+
+ public PaletteRoot getPaletteRoot() {
+ if (paletteRoot == null) {
+ paletteRoot = new PaletteRoot();
+ paletteRoot.add(createToolsGroup(paletteRoot));
+ // addDrawers(paletteRoot);
+ }
+ return paletteRoot;
+ }
+
+ private void addDrawers(PaletteRoot paletteRoot) {
+ for (String drawerName : drawerNames) {
+ PaletteContainer container = new PaletteDrawer(drawerName);
+
+ String name = "one";
+ String description = "example";
+ Class<?> clazz = Object.class;
+
+ container.add(createComponent(name, description, clazz, FrameworkImage.RECTANGLE_16,
+ FrameworkImage.RECTANGLE_24));
+ paletteRoot.add(container);
+ }
+ }
+
+ private ToolEntry createComponent(String label, String description, Class<?> clazz, KeyedImage smallImage, KeyedImage largeImage) {
+ ToolEntry toolEntry =
+ new ToolEntry(label, description, ImageManager.getImageDescriptor(smallImage),
+ ImageManager.getImageDescriptor(largeImage)) {
+
+ };
+ return toolEntry;
+ }
+
+ private PaletteContainer createToolsGroup(PaletteRoot palette) {
+ PaletteToolbar toolbar = new PaletteToolbar("Tools");
+
+ ToolEntry tool = new PanningSelectionToolEntry();
+ toolbar.add(tool);
+ palette.setDefaultEntry(tool);
+
+ toolbar.add(new MarqueeToolEntry());
+
+ final Action action =
+ OseeUiActions.createBugAction(BranchGraphActivator.getInstance(), editor, BranchGraphEditor.EDITOR_ID,
+ "Branch Graph");
+ final ImageDescriptor img = action.getImageDescriptor();
+
+ toolbar.add(new ToolEntry("", action.getText(), img, img, null) {
+
+ @Override
+ public Tool createTool() {
+ return new AbstractTool() {
+
+ @Override
+ protected String getCommandName() {
+ return action.getText();
+ }
+
+ @Override
+ public void activate() {
+ super.activate();
+ Displays.ensureInDisplayThread(new Runnable() {
+ @Override
+ public void run() {
+ deactivate();
+ action.run();
+ }
+ });
+
+ }
+ };
+ }
+
+ });
+
+ return toolbar;
+ }
}
diff --git a/plugins/org.eclipse.osee.framework.ui.branch.graph/src/org/eclipse/osee/framework/ui/branch/graph/operation/LoadGraphOperation.java b/plugins/org.eclipse.osee.framework.ui.branch.graph/src/org/eclipse/osee/framework/ui/branch/graph/operation/LoadGraphOperation.java
index 765d476080f..25120e5cf23 100644
--- a/plugins/org.eclipse.osee.framework.ui.branch.graph/src/org/eclipse/osee/framework/ui/branch/graph/operation/LoadGraphOperation.java
+++ b/plugins/org.eclipse.osee.framework.ui.branch.graph/src/org/eclipse/osee/framework/ui/branch/graph/operation/LoadGraphOperation.java
@@ -25,7 +25,7 @@ import org.eclipse.osee.framework.ui.branch.graph.core.BranchGraphEditorInput;
import org.eclipse.osee.framework.ui.branch.graph.model.GraphCache;
import org.eclipse.osee.framework.ui.branch.graph.model.GraphLoader;
import org.eclipse.osee.framework.ui.plugin.util.AWorkbench;
-import org.eclipse.swt.widgets.Display;
+import org.eclipse.osee.framework.ui.swt.Displays;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.IWorkbenchWindow;
@@ -35,99 +35,101 @@ import org.eclipse.ui.IWorkbenchWindow;
*/
public class LoadGraphOperation implements IExceptionableRunnable {
- private Branch resource;
- private GraphicalViewer viewer;
- private BranchGraphEditor editor;
- private GraphCache graph;
-
- private static final int TOTAL_STEPS = Integer.MAX_VALUE;
- private static final int SHORT_TASK_STEPS = TOTAL_STEPS / 50;
- private static final int VERY_LONG_TASK = TOTAL_STEPS / 2;
- private static final int TASK_STEPS = (TOTAL_STEPS - SHORT_TASK_STEPS * 3 - VERY_LONG_TASK) / 2;
-
- protected LoadGraphOperation(IWorkbenchPart part, GraphicalViewer viewer, BranchGraphEditor editor) {
- super();
- this.viewer = viewer;
- this.editor = editor;
- }
-
- public LoadGraphOperation(IWorkbenchPart part, GraphicalViewer viewer, BranchGraphEditor editor, Branch resource) {
- this(part, viewer, editor);
- this.resource = resource;
- }
-
- public String getName() {
- return "Loading graph information";
- }
-
- @Override
- public IStatus run(IProgressMonitor monitor) throws Exception {
- boolean error = false;
- monitor.beginTask(getName(), TOTAL_STEPS);
- monitor.worked(SHORT_TASK_STEPS);
- try {
- TransactionRecord transaction = TransactionManager.getHeadTransaction(resource);
- if (editor != null) {
- ((BranchGraphEditorInput) editor.getEditorInput()).setTransactionId(transaction);
- }
- Branch path = transaction.getBranch();
-
- monitor.setTaskName("Initializating cache");
-
- monitor.worked(SHORT_TASK_STEPS);
-
- if (editor != null) {
- if (error == true || monitor.isCanceled()) {
- Display.getDefault().syncExec(new Runnable() {
- public void run() {
- IWorkbenchWindow window = editor.getEditorSite().getWorkbenchWindow();
- IWorkbenchPage page = window.getActivePage();
- page.activate(editor);
- page.closeEditor(editor, false);
- }
- });
- } else {
- updateView(monitor, path, transaction);
- }
- }
- } catch (Exception ex) {
- AWorkbench.popup("Error Calculating Revision Graph Information", Lib.exceptionToString(ex));
- } finally {
- monitor.done();
- }
- return Status.OK_STATUS;
- }
-
- private void updateView(IProgressMonitor monitor, Branch branch, TransactionRecord revision) throws OseeCoreException {
- monitor.setTaskName("Finding root node");
- int unitWork = TASK_STEPS / (int) (revision.getId());
- if (unitWork < 1) {
- unitWork = 1;
- }
- monitor.setTaskName("Calculating graph");
- graph = new GraphCache(branch);
- GraphLoader.load(graph, new InternalTaskProgressListener(monitor, unitWork));
- monitor.setTaskName("Drawing graph");
-
- Display.getDefault().syncExec(new Runnable() {
- public void run() {
- viewer.setContents(graph);
- editor.setOutlineContent(graph);
- }
- });
- }
- private final class InternalTaskProgressListener implements IProgressListener {
-
- private IProgressMonitor monitor;
- private int unitWork;
-
- public InternalTaskProgressListener(IProgressMonitor monitor, int unitWork) {
- this.monitor = monitor;
- this.unitWork = unitWork;
- }
-
- public void worked() {
- monitor.worked(unitWork);
- }
- }
+ private Branch resource;
+ private final GraphicalViewer viewer;
+ private final BranchGraphEditor editor;
+ private GraphCache graph;
+
+ private static final int TOTAL_STEPS = Integer.MAX_VALUE;
+ private static final int SHORT_TASK_STEPS = TOTAL_STEPS / 50;
+ private static final int VERY_LONG_TASK = TOTAL_STEPS / 2;
+ private static final int TASK_STEPS = (TOTAL_STEPS - SHORT_TASK_STEPS * 3 - VERY_LONG_TASK) / 2;
+
+ protected LoadGraphOperation(IWorkbenchPart part, GraphicalViewer viewer, BranchGraphEditor editor) {
+ super();
+ this.viewer = viewer;
+ this.editor = editor;
+ }
+
+ public LoadGraphOperation(IWorkbenchPart part, GraphicalViewer viewer, BranchGraphEditor editor, Branch resource) {
+ this(part, viewer, editor);
+ this.resource = resource;
+ }
+
+ public String getName() {
+ return "Loading graph information";
+ }
+
+ @Override
+ public IStatus run(IProgressMonitor monitor) throws Exception {
+ boolean error = false;
+ monitor.beginTask(getName(), TOTAL_STEPS);
+ monitor.worked(SHORT_TASK_STEPS);
+ try {
+ TransactionRecord transaction = TransactionManager.getHeadTransaction(resource);
+ if (editor != null) {
+ ((BranchGraphEditorInput) editor.getEditorInput()).setTransactionId(transaction);
+ }
+ Branch path = transaction.getBranch();
+
+ monitor.setTaskName("Initializating cache");
+
+ monitor.worked(SHORT_TASK_STEPS);
+
+ if (editor != null) {
+ if (error == true || monitor.isCanceled()) {
+ Displays.pendInDisplayThread(new Runnable() {
+ @Override
+ public void run() {
+ IWorkbenchWindow window = editor.getEditorSite().getWorkbenchWindow();
+ IWorkbenchPage page = window.getActivePage();
+ page.activate(editor);
+ page.closeEditor(editor, false);
+ }
+ });
+ } else {
+ updateView(monitor, path, transaction);
+ }
+ }
+ } catch (Exception ex) {
+ AWorkbench.popup("Error Calculating Revision Graph Information", Lib.exceptionToString(ex));
+ } finally {
+ monitor.done();
+ }
+ return Status.OK_STATUS;
+ }
+
+ private void updateView(IProgressMonitor monitor, Branch branch, TransactionRecord revision) throws OseeCoreException {
+ monitor.setTaskName("Finding root node");
+ int unitWork = TASK_STEPS / (revision.getId());
+ if (unitWork < 1) {
+ unitWork = 1;
+ }
+ monitor.setTaskName("Calculating graph");
+ graph = new GraphCache(branch);
+ GraphLoader.load(graph, new InternalTaskProgressListener(monitor, unitWork));
+ monitor.setTaskName("Drawing graph");
+
+ Displays.pendInDisplayThread(new Runnable() {
+ @Override
+ public void run() {
+ viewer.setContents(graph);
+ editor.setOutlineContent(graph);
+ }
+ });
+ }
+ private final class InternalTaskProgressListener implements IProgressListener {
+
+ private final IProgressMonitor monitor;
+ private final int unitWork;
+
+ public InternalTaskProgressListener(IProgressMonitor monitor, int unitWork) {
+ this.monitor = monitor;
+ this.unitWork = unitWork;
+ }
+
+ public void worked() {
+ monitor.worked(unitWork);
+ }
+ }
}

Back to the top