diff options
author | rescobar | 2010-07-20 20:52:40 +0000 |
---|---|---|
committer | rescobar | 2010-07-20 20:52:40 +0000 |
commit | a88b295f5a066c21fce3aefc406d1e922ca44733 (patch) | |
tree | 2df201f4b2513b0ef1c521d0144db43580cb4aac | |
parent | 9dd043fbb2a826276a59d95ae1b0ddc5df14b21c (diff) | |
download | org.eclipse.osee-a88b295f5a066c21fce3aefc406d1e922ca44733.tar.gz org.eclipse.osee-a88b295f5a066c21fce3aefc406d1e922ca44733.tar.xz org.eclipse.osee-a88b295f5a066c21fce3aefc406d1e922ca44733.zip |
Refactored to use Displays class
166 files changed, 9050 insertions, 8894 deletions
diff --git a/plugins/org.eclipse.osee.ats/META-INF/MANIFEST.MF b/plugins/org.eclipse.osee.ats/META-INF/MANIFEST.MF index 3c4c8a68bcc..d544817c248 100644 --- a/plugins/org.eclipse.osee.ats/META-INF/MANIFEST.MF +++ b/plugins/org.eclipse.osee.ats/META-INF/MANIFEST.MF @@ -15,7 +15,6 @@ Require-Bundle: org.eclipse.gef, org.eclipse.core.resources,
org.eclipse.ui.ide,
org.eclipse.ui,
- org.eclipse.core.runtime,
org.eclipse.help,
org.eclipse.osee.framework.ui.plugin,
org.eclipse.osee.framework.plugin.core,
diff --git a/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/editor/SMAActionableItemHeader.java b/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/editor/SMAActionableItemHeader.java index 836fe01baae..af4d9f1a9b3 100644 --- a/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/editor/SMAActionableItemHeader.java +++ b/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/editor/SMAActionableItemHeader.java @@ -22,9 +22,9 @@ import org.eclipse.osee.framework.skynet.core.event.FrameworkTransactionData; import org.eclipse.osee.framework.skynet.core.event.IFrameworkTransactionEventListener; import org.eclipse.osee.framework.skynet.core.event.OseeEventManager; import org.eclipse.osee.framework.skynet.core.event.Sender; -import org.eclipse.osee.framework.ui.plugin.util.Displays; import org.eclipse.osee.framework.ui.skynet.XFormToolkit; import org.eclipse.osee.framework.ui.swt.ALayout; +import org.eclipse.osee.framework.ui.swt.Displays; import org.eclipse.swt.SWT; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.widgets.Composite; diff --git a/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/editor/SMAEditor.java b/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/editor/SMAEditor.java index bee04632538..adddd23234f 100644 --- a/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/editor/SMAEditor.java +++ b/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/editor/SMAEditor.java @@ -64,7 +64,6 @@ import org.eclipse.osee.framework.skynet.core.transaction.SkynetTransaction; import org.eclipse.osee.framework.skynet.core.utility.LoadedArtifacts;
import org.eclipse.osee.framework.ui.plugin.OseeUiActions;
import org.eclipse.osee.framework.ui.plugin.util.AWorkbench;
-import org.eclipse.osee.framework.ui.plugin.util.Displays;
import org.eclipse.osee.framework.ui.plugin.util.Result;
import org.eclipse.osee.framework.ui.skynet.ArtifactImageManager;
import org.eclipse.osee.framework.ui.skynet.AttributesComposite;
@@ -75,6 +74,7 @@ import org.eclipse.osee.framework.ui.skynet.artifact.editor.AbstractArtifactEdit import org.eclipse.osee.framework.ui.skynet.notify.OseeNotificationManager;
import org.eclipse.osee.framework.ui.skynet.render.PresentationType; import org.eclipse.osee.framework.ui.skynet.render.RendererManager; +import org.eclipse.osee.framework.ui.swt.Displays;
import org.eclipse.osee.framework.ui.swt.IDirtiableEditor;
import org.eclipse.osee.framework.ui.swt.ImageManager;
import org.eclipse.swt.SWT;
diff --git a/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/editor/SMAEditorEventManager.java b/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/editor/SMAEditorEventManager.java index 44323a71aac..3acfc2f1c63 100644 --- a/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/editor/SMAEditorEventManager.java +++ b/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/editor/SMAEditorEventManager.java @@ -31,7 +31,7 @@ import org.eclipse.osee.framework.skynet.core.event.Sender; import org.eclipse.osee.framework.skynet.core.event2.ArtifactEvent;
import org.eclipse.osee.framework.skynet.core.event2.artifact.IArtifactEventListener;
import org.eclipse.osee.framework.skynet.core.event2.filter.IEventFilter;
-import org.eclipse.osee.framework.ui.plugin.util.Displays;
+import org.eclipse.osee.framework.ui.swt.Displays; /**
* Common location for event handling for SMAEditors in order to keep number of registrations and processing to a
diff --git a/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/editor/SMAGoalMembersSection.java b/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/editor/SMAGoalMembersSection.java index a0a4288ed38..46152c44614 100644 --- a/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/editor/SMAGoalMembersSection.java +++ b/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/editor/SMAGoalMembersSection.java @@ -32,12 +32,12 @@ import org.eclipse.osee.framework.ui.skynet.XFormToolkit; import org.eclipse.osee.framework.ui.skynet.artifact.editor.ArtifactEditor;
import org.eclipse.osee.framework.ui.skynet.util.ArtifactDragAndDrop;
import org.eclipse.osee.framework.ui.swt.ALayout;
+import org.eclipse.osee.framework.ui.swt.Displays;
import org.eclipse.osee.framework.ui.swt.ImageManager;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Menu;
import org.eclipse.ui.forms.IManagedForm;
@@ -51,159 +51,161 @@ import org.eclipse.ui.forms.widgets.Section; */
public class SMAGoalMembersSection extends SectionPart implements IWorldEditor {
- private final SMAEditor editor;
- private WorldComposite worldComposite;
-
- public SMAGoalMembersSection(SMAEditor editor, Composite parent, XFormToolkit toolkit, int style) {
- super(parent, toolkit, style | Section.TITLE_BAR);
- this.editor = editor;
- }
-
- @Override
- public void initialize(final IManagedForm form) {
- super.initialize(form);
- final FormToolkit toolkit = form.getToolkit();
-
- Section section = getSection();
- section.setText("Members");
-
- section.setLayout(new GridLayout());
- section.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
-
- Composite sectionBody = toolkit.createComposite(section, toolkit.getBorderStyle());
- sectionBody.setLayout(ALayout.getZeroMarginLayout(2, true));
- GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true);
- gd.widthHint = 300;
- sectionBody.setLayoutData(gd);
-
- addDropToAddLabel(toolkit, sectionBody);
- addDropToRemoveLabel(toolkit, sectionBody);
-
- worldComposite =
- new WorldComposite(this, new GoalXViewerFactory((GoalArtifact) editor.getSma()), sectionBody, SWT.BORDER);
- try {
- CustomizeData customizeData = worldComposite.getCustomizeDataCopy();
- ((WorldLabelProvider) worldComposite.getXViewer().getLabelProvider()).setParentGoal((GoalArtifact) editor.getSma());
- worldComposite.load("Members", editor.getSma().getRelatedArtifacts(AtsRelationTypes.Goal_Member),
- customizeData, TableLoadOption.None);
-
- } catch (OseeCoreException ex) {
- OseeLog.log(AtsPlugin.class, OseeLevel.SEVERE, ex);
- }
- gd = new GridData(SWT.FILL, SWT.FILL, true, true);
- gd.horizontalSpan = 2;
- gd.widthHint = 300;
- worldComposite.setLayoutData(gd);
-
- section.setClient(sectionBody);
- toolkit.paintBordersFor(section);
- }
-
- protected void addDropToAddLabel(FormToolkit toolkit, Composite sectionBody) {
- Label dropToAddLabel = new Label(sectionBody, SWT.BORDER);
- dropToAddLabel.setText(" Drop New Members Here");
- dropToAddLabel.setBackgroundImage(ImageManager.getImage(AtsImage.DROP_HERE_TO_ADD_BACKGROUND));
- GridData gd = new GridData(GridData.FILL_BOTH);
- gd.heightHint = 25;
- dropToAddLabel.setLayoutData(gd);
- toolkit.adapt(dropToAddLabel, true, true);
-
- new ArtifactDragAndDrop(dropToAddLabel, editor.getSma(), ArtifactEditor.EDITOR_ID) {
- @Override
- public void performArtifactDrop(Artifact[] dropArtifacts) {
- super.performArtifactDrop(dropArtifacts);
- try {
- List<Artifact> members = new ArrayList<Artifact>();
- members.addAll(((GoalArtifact) editor.getSma()).getMembers());
- for (Artifact art : dropArtifacts) {
- if (!members.contains(art)) {
- members.add(art);
- editor.getSma().addRelation(AtsRelationTypes.Goal_Member, art);
- }
- }
- editor.getSma().setRelationOrder(AtsRelationTypes.Goal_Member, members);
- editor.doSave(null);
- } catch (OseeCoreException ex) {
- OseeLog.log(AtsPlugin.class, OseeLevel.SEVERE_POPUP, ex);
- }
- }
- };
- }
-
- protected void addDropToRemoveLabel(FormToolkit toolkit, Composite sectionBody) {
- Label dropToAddLabel = new Label(sectionBody, SWT.BORDER);
- dropToAddLabel.setText(" Drop Members to Remove");
- dropToAddLabel.setBackgroundImage(ImageManager.getImage(AtsImage.DROP_HERE_TO_REMOVE_BACKGROUND));
- GridData gd = new GridData(GridData.FILL_BOTH);
- gd.heightHint = 25;
- dropToAddLabel.setLayoutData(gd);
- toolkit.adapt(dropToAddLabel, true, true);
-
- new ArtifactDragAndDrop(dropToAddLabel, editor.getSma(), ArtifactEditor.EDITOR_ID) {
- @Override
- public void performArtifactDrop(Artifact[] dropArtifacts) {
- super.performArtifactDrop(dropArtifacts);
- try {
- for (Artifact art : dropArtifacts) {
- editor.getSma().deleteRelation(AtsRelationTypes.Goal_Member, art);
- }
- editor.doSave(null);
- } catch (OseeCoreException ex) {
- OseeLog.log(AtsPlugin.class, OseeLevel.SEVERE_POPUP, ex);
- }
- }
- };
- }
-
- @Override
- public void refresh() {
- super.refresh();
- Display.getDefault().asyncExec(new Runnable() {
- public void run() {
- if (worldComposite != null && !worldComposite.isDisposed()) {
- worldComposite.getXViewer().refresh();
- }
- }
- });
- }
-
- @Override
- public void dispose() {
- if (worldComposite != null && !worldComposite.isDisposed()) {
- worldComposite.dispose();
- }
- super.dispose();
- }
-
- @Override
- public void createToolBarPulldown(Menu menu) {
- }
-
- @Override
- public String getCurrentTitleLabel() {
- return "";
- }
-
- @Override
- public IActionable getIActionable() {
- return null;
- }
-
- @Override
- public IWorldEditorProvider getWorldEditorProvider() {
- return null;
- }
-
- @Override
- public void reSearch() throws OseeCoreException {
- }
-
- @Override
- public void reflow() {
- }
-
- @Override
- public void setTableTitle(String title, boolean warning) {
- }
+ private final SMAEditor editor;
+ private WorldComposite worldComposite;
+
+ public SMAGoalMembersSection(SMAEditor editor, Composite parent, XFormToolkit toolkit, int style) {
+ super(parent, toolkit, style | Section.TITLE_BAR);
+ this.editor = editor;
+ }
+
+ @Override
+ public void initialize(final IManagedForm form) {
+ super.initialize(form);
+ final FormToolkit toolkit = form.getToolkit();
+
+ Section section = getSection();
+ section.setText("Members");
+
+ section.setLayout(new GridLayout());
+ section.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
+
+ Composite sectionBody = toolkit.createComposite(section, toolkit.getBorderStyle());
+ sectionBody.setLayout(ALayout.getZeroMarginLayout(2, true));
+ GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true);
+ gd.widthHint = 300;
+ sectionBody.setLayoutData(gd);
+
+ addDropToAddLabel(toolkit, sectionBody);
+ addDropToRemoveLabel(toolkit, sectionBody);
+
+ worldComposite =
+ new WorldComposite(this, new GoalXViewerFactory((GoalArtifact) editor.getSma()), sectionBody, SWT.BORDER);
+ try {
+ CustomizeData customizeData = worldComposite.getCustomizeDataCopy();
+ ((WorldLabelProvider) worldComposite.getXViewer().getLabelProvider()).setParentGoal((GoalArtifact) editor.getSma());
+ worldComposite.load("Members", editor.getSma().getRelatedArtifacts(AtsRelationTypes.Goal_Member),
+ customizeData, TableLoadOption.None);
+
+ } catch (OseeCoreException ex) {
+ OseeLog.log(AtsPlugin.class, OseeLevel.SEVERE, ex);
+ }
+ gd = new GridData(SWT.FILL, SWT.FILL, true, true);
+ gd.horizontalSpan = 2;
+ gd.widthHint = 300;
+ worldComposite.setLayoutData(gd);
+
+ section.setClient(sectionBody);
+ toolkit.paintBordersFor(section);
+ }
+
+ protected void addDropToAddLabel(FormToolkit toolkit, Composite sectionBody) {
+ Label dropToAddLabel = new Label(sectionBody, SWT.BORDER);
+ dropToAddLabel.setText(" Drop New Members Here");
+ dropToAddLabel.setBackgroundImage(ImageManager.getImage(AtsImage.DROP_HERE_TO_ADD_BACKGROUND));
+ GridData gd = new GridData(GridData.FILL_BOTH);
+ gd.heightHint = 25;
+ dropToAddLabel.setLayoutData(gd);
+ toolkit.adapt(dropToAddLabel, true, true);
+
+ new ArtifactDragAndDrop(dropToAddLabel, editor.getSma(), ArtifactEditor.EDITOR_ID) {
+ @Override
+ public void performArtifactDrop(Artifact[] dropArtifacts) {
+ super.performArtifactDrop(dropArtifacts);
+ try {
+ List<Artifact> members = new ArrayList<Artifact>();
+ members.addAll(((GoalArtifact) editor.getSma()).getMembers());
+ for (Artifact art : dropArtifacts) {
+ if (!members.contains(art)) {
+ members.add(art);
+ editor.getSma().addRelation(AtsRelationTypes.Goal_Member, art);
+ }
+ }
+ editor.getSma().setRelationOrder(AtsRelationTypes.Goal_Member, members);
+ editor.doSave(null);
+ } catch (OseeCoreException ex) {
+ OseeLog.log(AtsPlugin.class, OseeLevel.SEVERE_POPUP, ex);
+ }
+ }
+ };
+ }
+
+ protected void addDropToRemoveLabel(FormToolkit toolkit, Composite sectionBody) {
+ Label dropToAddLabel = new Label(sectionBody, SWT.BORDER);
+ dropToAddLabel.setText(" Drop Members to Remove");
+ dropToAddLabel.setBackgroundImage(ImageManager.getImage(AtsImage.DROP_HERE_TO_REMOVE_BACKGROUND));
+ GridData gd = new GridData(GridData.FILL_BOTH);
+ gd.heightHint = 25;
+ dropToAddLabel.setLayoutData(gd);
+ toolkit.adapt(dropToAddLabel, true, true);
+
+ new ArtifactDragAndDrop(dropToAddLabel, editor.getSma(), ArtifactEditor.EDITOR_ID) {
+ @Override
+ public void performArtifactDrop(Artifact[] dropArtifacts) {
+ super.performArtifactDrop(dropArtifacts);
+ try {
+ for (Artifact art : dropArtifacts) {
+ editor.getSma().deleteRelation(AtsRelationTypes.Goal_Member, art);
+ }
+ editor.doSave(null);
+ } catch (OseeCoreException ex) {
+ OseeLog.log(AtsPlugin.class, OseeLevel.SEVERE_POPUP, ex);
+ }
+ }
+ };
+ }
+
+ @Override
+ public void refresh() {
+ super.refresh();
+ Displays.ensureInDisplayThread(new Runnable() {
+
+ @Override
+ public void run() {
+ if (worldComposite != null && !worldComposite.isDisposed()) {
+ worldComposite.getXViewer().refresh();
+ }
+ }
+ });
+ }
+
+ @Override
+ public void dispose() {
+ if (worldComposite != null && !worldComposite.isDisposed()) {
+ worldComposite.dispose();
+ }
+ super.dispose();
+ }
+
+ @Override
+ public void createToolBarPulldown(Menu menu) {
+ }
+
+ @Override
+ public String getCurrentTitleLabel() {
+ return "";
+ }
+
+ @Override
+ public IActionable getIActionable() {
+ return null;
+ }
+
+ @Override
+ public IWorldEditorProvider getWorldEditorProvider() {
+ return null;
+ }
+
+ @Override
+ public void reSearch() throws OseeCoreException {
+ }
+
+ @Override
+ public void reflow() {
+ }
+
+ @Override
+ public void setTableTitle(String title, boolean warning) {
+ }
}
diff --git a/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/editor/SMARelationsSection.java b/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/editor/SMARelationsSection.java index e2bfee71a79..7443cf66525 100644 --- a/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/editor/SMARelationsSection.java +++ b/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/editor/SMARelationsSection.java @@ -18,7 +18,6 @@ import org.eclipse.osee.ats.artifact.StateMachineArtifact; import org.eclipse.osee.ats.util.AtsRelationTypes;
import org.eclipse.osee.ats.util.AtsUtil;
import org.eclipse.osee.framework.core.enums.CoreRelationTypes;
-import org.eclipse.osee.framework.core.exception.OseeCoreException;
import org.eclipse.osee.framework.core.model.type.RelationType;
import org.eclipse.osee.framework.ui.skynet.artifact.editor.BaseArtifactEditorInput;
import org.eclipse.osee.framework.ui.skynet.artifact.editor.sections.RelationsFormSection;
@@ -33,55 +32,55 @@ import org.eclipse.ui.forms.widgets.Section; */
public class SMARelationsSection extends RelationsFormSection {
- public SMARelationsSection(SMAEditor editor, Composite parent, FormToolkit toolkit, int style) {
- super(editor, parent, toolkit, style | Section.TWISTIE | Section.TITLE_BAR);
- }
+ public SMARelationsSection(SMAEditor editor, Composite parent, FormToolkit toolkit, int style) {
+ super(editor, parent, toolkit, style | Section.TWISTIE | Section.TITLE_BAR);
+ }
- @Override
- public SMAEditor getEditor() {
- return (SMAEditor) super.getEditor();
- }
+ @Override
+ public SMAEditor getEditor() {
+ return (SMAEditor) super.getEditor();
+ }
- @Override
- public BaseArtifactEditorInput getEditorInput() {
- return super.getEditorInput();
- }
+ @Override
+ public BaseArtifactEditorInput getEditorInput() {
+ return super.getEditorInput();
+ }
- @Override
- protected synchronized void createSection(Section section, FormToolkit toolkit) throws OseeCoreException {
- super.createSection(section, toolkit);
- // Don't allow users to see all relations
- if (!AtsUtil.isAtsAdmin()) {
- getRelationComposite().getTreeViewer().addFilter(userRelationsFilter);
- }
- }
+ @Override
+ protected synchronized void createSection(Section section, FormToolkit toolkit) {
+ super.createSection(section, toolkit);
+ // Don't allow users to see all relations
+ if (!AtsUtil.isAtsAdmin()) {
+ getRelationComposite().getTreeViewer().addFilter(userRelationsFilter);
+ }
+ }
- @Override
- protected void handleExpandAndCollapse() {
- ((SMAWorkFlowTab) getEditor().getSelectedPage()).getManagedForm().getForm().layout();
- }
+ @Override
+ protected void handleExpandAndCollapse() {
+ ((SMAWorkFlowTab) getEditor().getSelectedPage()).getManagedForm().getForm().layout();
+ }
- @Override
- protected void addDragAndDrop(Control dropArea) {
- new SMADragAndDrop(dropArea, (StateMachineArtifact) getEditorInput().getArtifact(), SMAEditor.EDITOR_ID);
- }
+ @Override
+ protected void addDragAndDrop(Control dropArea) {
+ new SMADragAndDrop(dropArea, (StateMachineArtifact) getEditorInput().getArtifact(), SMAEditor.EDITOR_ID);
+ }
- private static ViewerFilter userRelationsFilter = new ViewerFilter() {
- @Override
- public boolean select(Viewer viewer, Object parentElement, Object element) {
- if (element instanceof RelationType) {
- return !filteredRelationTypeNames.contains(((RelationType) element).getName());
- }
- return true;
- }
- };
+ private static ViewerFilter userRelationsFilter = new ViewerFilter() {
+ @Override
+ public boolean select(Viewer viewer, Object parentElement, Object element) {
+ if (element instanceof RelationType) {
+ return !filteredRelationTypeNames.contains(((RelationType) element).getName());
+ }
+ return true;
+ }
+ };
- private static List<String> filteredRelationTypeNames =
- Arrays.asList(AtsRelationTypes.ActionToWorkflow_Action.getName(), AtsRelationTypes.SmaToTask_Sma.getName(),
- AtsRelationTypes.TeamActionableItem_ActionableItem.getName(),
- AtsRelationTypes.TeamWorkflowTargetedForVersion_Version.getName(),
- AtsRelationTypes.TeamLead_Lead.getName(), AtsRelationTypes.TeamMember_Member.getName(),
- AtsRelationTypes.TeamWorkflowToReview_Review.getName(), CoreRelationTypes.WorkItem__Child.getName(),
- CoreRelationTypes.Default_Hierarchical__Child.getName(), CoreRelationTypes.Users_Artifact.getName());
+ private static List<String> filteredRelationTypeNames = Arrays.asList(
+ AtsRelationTypes.ActionToWorkflow_Action.getName(), AtsRelationTypes.SmaToTask_Sma.getName(),
+ AtsRelationTypes.TeamActionableItem_ActionableItem.getName(),
+ AtsRelationTypes.TeamWorkflowTargetedForVersion_Version.getName(),
+ AtsRelationTypes.TeamLead_Lead.getName(), AtsRelationTypes.TeamMember_Member.getName(),
+ AtsRelationTypes.TeamWorkflowToReview_Review.getName(), CoreRelationTypes.WorkItem__Child.getName(),
+ CoreRelationTypes.Default_Hierarchical__Child.getName(), CoreRelationTypes.Users_Artifact.getName());
}
diff --git a/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/editor/SMAWorkFlowTab.java b/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/editor/SMAWorkFlowTab.java index 50c9d1b9d8f..406439fa1e2 100644 --- a/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/editor/SMAWorkFlowTab.java +++ b/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/editor/SMAWorkFlowTab.java @@ -58,7 +58,6 @@ import org.eclipse.osee.framework.logging.OseeLevel; import org.eclipse.osee.framework.logging.OseeLog;
import org.eclipse.osee.framework.plugin.core.IActionable;
import org.eclipse.osee.framework.ui.plugin.OseeUiActions;
-import org.eclipse.osee.framework.ui.plugin.util.Displays;
import org.eclipse.osee.framework.ui.plugin.util.Result;
import org.eclipse.osee.framework.ui.skynet.ArtifactImageManager;
import org.eclipse.osee.framework.ui.skynet.XFormToolkit;
@@ -70,6 +69,7 @@ import org.eclipse.osee.framework.ui.skynet.util.OseeDictionary; import org.eclipse.osee.framework.ui.skynet.widgets.IArtifactWidget;
import org.eclipse.osee.framework.ui.skynet.widgets.XDate;
import org.eclipse.osee.framework.ui.swt.ALayout;
+import org.eclipse.osee.framework.ui.swt.Displays;
import org.eclipse.osee.framework.ui.swt.ExceptionComposite;
import org.eclipse.osee.framework.ui.swt.Widgets;
import org.eclipse.swt.SWT;
diff --git a/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/editor/SMAWorkflowMetricsHeader.java b/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/editor/SMAWorkflowMetricsHeader.java index 4de2d7f6161..0ceab7706c1 100644 --- a/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/editor/SMAWorkflowMetricsHeader.java +++ b/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/editor/SMAWorkflowMetricsHeader.java @@ -22,11 +22,11 @@ import org.eclipse.osee.framework.skynet.core.event.FrameworkTransactionData; import org.eclipse.osee.framework.skynet.core.event.IFrameworkTransactionEventListener;
import org.eclipse.osee.framework.skynet.core.event.OseeEventManager;
import org.eclipse.osee.framework.skynet.core.event.Sender;
-import org.eclipse.osee.framework.ui.plugin.util.Displays;
import org.eclipse.osee.framework.ui.plugin.util.Result;
import org.eclipse.osee.framework.ui.skynet.XFormToolkit;
import org.eclipse.osee.framework.ui.skynet.util.FormsUtil;
import org.eclipse.osee.framework.ui.swt.ALayout;
+import org.eclipse.osee.framework.ui.swt.Displays;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.widgets.Composite;
diff --git a/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/editor/widget/ReviewInfoXWidget.java b/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/editor/widget/ReviewInfoXWidget.java index e1885eaf3b4..f201a394924 100644 --- a/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/editor/widget/ReviewInfoXWidget.java +++ b/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/editor/widget/ReviewInfoXWidget.java @@ -40,11 +40,11 @@ import org.eclipse.osee.framework.skynet.core.event.OseeEventManager; import org.eclipse.osee.framework.skynet.core.event.Sender;
import org.eclipse.osee.framework.skynet.core.transaction.SkynetTransaction;
import org.eclipse.osee.framework.ui.plugin.util.AWorkbench;
-import org.eclipse.osee.framework.ui.plugin.util.Displays;
import org.eclipse.osee.framework.ui.plugin.util.Result;
import org.eclipse.osee.framework.ui.skynet.XFormToolkit;
import org.eclipse.osee.framework.ui.skynet.widgets.XLabelValueBase;
import org.eclipse.osee.framework.ui.swt.ALayout;
+import org.eclipse.osee.framework.ui.swt.Displays;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.widgets.Composite;
diff --git a/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/editor/widget/TaskInfoXWidget.java b/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/editor/widget/TaskInfoXWidget.java index 463e1ee9ee4..52e761fba2f 100644 --- a/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/editor/widget/TaskInfoXWidget.java +++ b/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/editor/widget/TaskInfoXWidget.java @@ -26,9 +26,9 @@ import org.eclipse.osee.framework.skynet.core.event.IFrameworkTransactionEventLi import org.eclipse.osee.framework.skynet.core.event.OseeEventManager;
import org.eclipse.osee.framework.skynet.core.event.Sender;
import org.eclipse.osee.framework.skynet.core.transaction.SkynetTransaction;
-import org.eclipse.osee.framework.ui.plugin.util.Displays;
import org.eclipse.osee.framework.ui.plugin.util.Result;
import org.eclipse.osee.framework.ui.skynet.widgets.XLabelValueBase;
+import org.eclipse.osee.framework.ui.swt.Displays;
import org.eclipse.osee.framework.ui.swt.Widgets;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Composite;
diff --git a/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/health/ValidateChangeReports.java b/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/health/ValidateChangeReports.java index 89bbd45a340..4763c00c1ff 100644 --- a/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/health/ValidateChangeReports.java +++ b/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/health/ValidateChangeReports.java @@ -52,13 +52,13 @@ import org.eclipse.osee.framework.skynet.core.change.RelationChange; import org.eclipse.osee.framework.skynet.core.revision.ChangeData;
import org.eclipse.osee.framework.skynet.core.revision.ChangeData.KindType;
import org.eclipse.osee.framework.ui.plugin.PluginUiImage;
-import org.eclipse.osee.framework.ui.plugin.util.Displays;
import org.eclipse.osee.framework.ui.plugin.util.Result;
import org.eclipse.osee.framework.ui.plugin.xnavigate.XNavigateComposite.TableLoadOption; import org.eclipse.osee.framework.ui.plugin.xnavigate.XNavigateItem;
import org.eclipse.osee.framework.ui.plugin.xnavigate.XNavigateItemAction;
import org.eclipse.osee.framework.ui.skynet.compare.CompareHandler;
import org.eclipse.osee.framework.ui.skynet.results.XResultData;
+import org.eclipse.osee.framework.ui.swt.Displays;
import org.eclipse.swt.widgets.Display;
/**
diff --git a/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/hyper/ActionHyperView.java b/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/hyper/ActionHyperView.java index a43cc2e1707..eb7ecee8583 100644 --- a/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/hyper/ActionHyperView.java +++ b/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/hyper/ActionHyperView.java @@ -41,8 +41,8 @@ import org.eclipse.osee.framework.skynet.core.event2.artifact.IArtifactEventList import org.eclipse.osee.framework.skynet.core.event2.filter.IEventFilter;
import org.eclipse.osee.framework.ui.plugin.OseeUiActions;
import org.eclipse.osee.framework.ui.plugin.util.AWorkbench;
-import org.eclipse.osee.framework.ui.plugin.util.Displays;
import org.eclipse.osee.framework.ui.skynet.util.DbConnectionExceptionComposite;
+import org.eclipse.osee.framework.ui.swt.Displays;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Cursor;
import org.eclipse.swt.widgets.Composite;
diff --git a/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/hyper/ActionSkyWalker.java b/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/hyper/ActionSkyWalker.java index b46291abe2e..afbd680e9da 100644 --- a/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/hyper/ActionSkyWalker.java +++ b/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/hyper/ActionSkyWalker.java @@ -35,9 +35,9 @@ import org.eclipse.osee.framework.skynet.core.event2.ArtifactEvent; import org.eclipse.osee.framework.skynet.core.event2.artifact.IArtifactEventListener;
import org.eclipse.osee.framework.skynet.core.event2.filter.IEventFilter;
import org.eclipse.osee.framework.ui.plugin.PluginUiImage;
-import org.eclipse.osee.framework.ui.plugin.util.Displays;
import org.eclipse.osee.framework.ui.skynet.skywalker.SkyWalkerOptions;
import org.eclipse.osee.framework.ui.skynet.skywalker.SkyWalkerView;
+import org.eclipse.osee.framework.ui.swt.Displays;
import org.eclipse.osee.framework.ui.swt.ImageManager;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.ui.IActionBars;
diff --git a/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/hyper/ArtifactHyperView.java b/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/hyper/ArtifactHyperView.java index a9f57c0b011..1a40f8f0bdb 100644 --- a/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/hyper/ArtifactHyperView.java +++ b/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/hyper/ArtifactHyperView.java @@ -42,9 +42,9 @@ import org.eclipse.osee.framework.skynet.core.event2.filter.IEventFilter; import org.eclipse.osee.framework.skynet.core.relation.RelationLink;
import org.eclipse.osee.framework.ui.plugin.OseeUiActions;
import org.eclipse.osee.framework.ui.plugin.util.AWorkbench;
-import org.eclipse.osee.framework.ui.plugin.util.Displays;
import org.eclipse.osee.framework.ui.skynet.util.DbConnectionExceptionComposite;
import org.eclipse.osee.framework.ui.skynet.widgets.dialog.EntryDialog;
+import org.eclipse.osee.framework.ui.swt.Displays;
import org.eclipse.osee.framework.ui.swt.ImageManager;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.ui.IActionBars;
diff --git a/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/navigate/ArtifactImpactToActionSearchItem.java b/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/navigate/ArtifactImpactToActionSearchItem.java index 745d322d02e..2402019efa9 100644 --- a/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/navigate/ArtifactImpactToActionSearchItem.java +++ b/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/navigate/ArtifactImpactToActionSearchItem.java @@ -33,7 +33,6 @@ import org.eclipse.osee.framework.skynet.core.artifact.Artifact; import org.eclipse.osee.framework.skynet.core.artifact.BranchManager;
import org.eclipse.osee.framework.skynet.core.artifact.search.ArtifactQuery;
import org.eclipse.osee.framework.skynet.core.revision.ChangeManager;
-import org.eclipse.osee.framework.ui.plugin.util.Displays;
import org.eclipse.osee.framework.ui.plugin.xnavigate.XNavigateComposite.TableLoadOption;
import org.eclipse.osee.framework.ui.plugin.xnavigate.XNavigateItem;
import org.eclipse.osee.framework.ui.plugin.xnavigate.XNavigateItemAction;
@@ -41,6 +40,7 @@ import org.eclipse.osee.framework.ui.skynet.FrameworkImage; import org.eclipse.osee.framework.ui.skynet.results.XResultData;
import org.eclipse.osee.framework.ui.skynet.widgets.dialog.ArtifactCheckTreeDialog;
import org.eclipse.osee.framework.ui.skynet.widgets.dialog.EntryDialogWithBranchSelect;
+import org.eclipse.osee.framework.ui.swt.Displays;
/**
* @author Donald G. Dunne
diff --git a/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/operation/DuplicateWorkflowBlam.java b/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/operation/DuplicateWorkflowBlam.java index bcfce41da34..5c59810a6f1 100644 --- a/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/operation/DuplicateWorkflowBlam.java +++ b/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/operation/DuplicateWorkflowBlam.java @@ -37,13 +37,13 @@ import org.eclipse.osee.framework.skynet.core.UserManager; import org.eclipse.osee.framework.skynet.core.artifact.Artifact; import org.eclipse.osee.framework.skynet.core.transaction.SkynetTransaction; import org.eclipse.osee.framework.ui.plugin.util.AWorkbench; -import org.eclipse.osee.framework.ui.plugin.util.Displays; import org.eclipse.osee.framework.ui.skynet.blam.AbstractBlam; import org.eclipse.osee.framework.ui.skynet.blam.VariableMap; import org.eclipse.osee.framework.ui.skynet.widgets.XListDropViewer; import org.eclipse.osee.framework.ui.skynet.widgets.XModifiedListener; import org.eclipse.osee.framework.ui.skynet.widgets.XWidget; import org.eclipse.osee.framework.ui.skynet.widgets.workflow.DynamicXWidgetLayout; +import org.eclipse.osee.framework.ui.swt.Displays; import org.eclipse.ui.forms.widgets.FormToolkit; /** diff --git a/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/operation/ImportTasksFromSimpleList.java b/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/operation/ImportTasksFromSimpleList.java index ca51f43d574..39e2fe128be 100644 --- a/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/operation/ImportTasksFromSimpleList.java +++ b/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/operation/ImportTasksFromSimpleList.java @@ -28,13 +28,13 @@ import org.eclipse.osee.framework.skynet.core.User; import org.eclipse.osee.framework.skynet.core.artifact.Artifact; import org.eclipse.osee.framework.skynet.core.transaction.SkynetTransaction; import org.eclipse.osee.framework.ui.plugin.util.AWorkbench; -import org.eclipse.osee.framework.ui.plugin.util.Displays; import org.eclipse.osee.framework.ui.skynet.blam.AbstractBlam; import org.eclipse.osee.framework.ui.skynet.blam.VariableMap; import org.eclipse.osee.framework.ui.skynet.widgets.XListDropViewer; import org.eclipse.osee.framework.ui.skynet.widgets.XModifiedListener; import org.eclipse.osee.framework.ui.skynet.widgets.XWidget; import org.eclipse.osee.framework.ui.skynet.widgets.workflow.DynamicXWidgetLayout; +import org.eclipse.osee.framework.ui.swt.Displays; import org.eclipse.ui.forms.widgets.FormToolkit; /** diff --git a/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/operation/ImportTasksFromSpreadsheet.java b/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/operation/ImportTasksFromSpreadsheet.java index ff762703c3d..cd1f74cf7a5 100644 --- a/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/operation/ImportTasksFromSpreadsheet.java +++ b/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/operation/ImportTasksFromSpreadsheet.java @@ -30,13 +30,13 @@ import org.eclipse.osee.framework.plugin.core.util.Jobs; import org.eclipse.osee.framework.skynet.core.artifact.Artifact;
import org.eclipse.osee.framework.skynet.core.transaction.SkynetTransaction;
import org.eclipse.osee.framework.ui.plugin.util.AWorkbench;
-import org.eclipse.osee.framework.ui.plugin.util.Displays;
import org.eclipse.osee.framework.ui.skynet.blam.AbstractBlam;
import org.eclipse.osee.framework.ui.skynet.blam.VariableMap;
import org.eclipse.osee.framework.ui.skynet.widgets.XListDropViewer;
import org.eclipse.osee.framework.ui.skynet.widgets.XModifiedListener;
import org.eclipse.osee.framework.ui.skynet.widgets.XWidget;
import org.eclipse.osee.framework.ui.skynet.widgets.workflow.DynamicXWidgetLayout;
+import org.eclipse.osee.framework.ui.swt.Displays;
import org.eclipse.ui.forms.widgets.FormToolkit;
/**
diff --git a/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/operation/PurgeUser.java b/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/operation/PurgeUser.java index 13e8581c2af..03d5d41b91b 100644 --- a/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/operation/PurgeUser.java +++ b/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/operation/PurgeUser.java @@ -27,10 +27,10 @@ import org.eclipse.osee.framework.skynet.core.User; import org.eclipse.osee.framework.skynet.core.artifact.Artifact;
import org.eclipse.osee.framework.skynet.core.artifact.search.ArtifactQuery;
import org.eclipse.osee.framework.ui.plugin.util.AWorkbench;
-import org.eclipse.osee.framework.ui.plugin.util.Displays;
import org.eclipse.osee.framework.ui.skynet.blam.AbstractBlam;
import org.eclipse.osee.framework.ui.skynet.blam.VariableMap;
import org.eclipse.osee.framework.ui.skynet.results.XResultData;
+import org.eclipse.osee.framework.ui.swt.Displays;
import org.eclipse.swt.widgets.Display;
/**
diff --git a/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/operation/ReAssignATSObjectsToUser.java b/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/operation/ReAssignATSObjectsToUser.java index 574d4e163ca..1e773b020da 100644 --- a/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/operation/ReAssignATSObjectsToUser.java +++ b/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/operation/ReAssignATSObjectsToUser.java @@ -25,12 +25,12 @@ import org.eclipse.osee.framework.skynet.core.User; import org.eclipse.osee.framework.skynet.core.artifact.Artifact; import org.eclipse.osee.framework.skynet.core.transaction.SkynetTransaction; import org.eclipse.osee.framework.ui.plugin.util.AWorkbench; -import org.eclipse.osee.framework.ui.plugin.util.Displays; import org.eclipse.osee.framework.ui.skynet.blam.AbstractBlam; import org.eclipse.osee.framework.ui.skynet.blam.VariableMap; import org.eclipse.osee.framework.ui.skynet.notify.OseeNotificationManager; import org.eclipse.osee.framework.ui.skynet.util.ArtifactTypeAndDescriptiveLabelProvider; import org.eclipse.osee.framework.ui.skynet.widgets.dialog.ArtifactCheckTreeDialog; +import org.eclipse.osee.framework.ui.swt.Displays; /** * @author Donald G. Dunne diff --git a/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/report/CreateActionArtifactChangeReportJob.java b/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/report/CreateActionArtifactChangeReportJob.java index 88fce97b488..80cbd6052ff 100644 --- a/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/report/CreateActionArtifactChangeReportJob.java +++ b/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/report/CreateActionArtifactChangeReportJob.java @@ -34,11 +34,11 @@ import org.eclipse.osee.framework.skynet.core.attribute.EnumeratedAttribute; import org.eclipse.osee.framework.skynet.core.revision.ChangeData;
import org.eclipse.osee.framework.skynet.core.revision.ChangeData.KindType;
import org.eclipse.osee.framework.ui.plugin.util.AWorkbench;
-import org.eclipse.osee.framework.ui.plugin.util.Displays;
import org.eclipse.osee.framework.ui.plugin.util.Result;
import org.eclipse.osee.framework.ui.skynet.results.XResultData;
import org.eclipse.osee.framework.ui.skynet.results.html.XResultPage.Manipulations;
import org.eclipse.osee.framework.ui.skynet.util.HtmlExportTable;
+import org.eclipse.osee.framework.ui.swt.Displays;
/**
* @author Donald G. Dunne
diff --git a/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/task/TaskEditor.java b/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/task/TaskEditor.java index bc00fbfb547..3cab42ec126 100644 --- a/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/task/TaskEditor.java +++ b/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/task/TaskEditor.java @@ -38,12 +38,12 @@ import org.eclipse.osee.framework.plugin.core.IActionable; import org.eclipse.osee.framework.skynet.core.artifact.Artifact;
import org.eclipse.osee.framework.skynet.core.transaction.SkynetTransaction;
import org.eclipse.osee.framework.ui.plugin.util.AWorkbench;
-import org.eclipse.osee.framework.ui.plugin.util.Displays;
import org.eclipse.osee.framework.ui.plugin.util.Result;
import org.eclipse.osee.framework.ui.plugin.xnavigate.XNavigateComposite.TableLoadOption;
import org.eclipse.osee.framework.ui.skynet.OseeContributionItem;
import org.eclipse.osee.framework.ui.skynet.artifact.editor.AbstractArtifactEditor;
import org.eclipse.osee.framework.ui.swt.CursorManager;
+import org.eclipse.osee.framework.ui.swt.Displays;
import org.eclipse.osee.framework.ui.swt.IDirtiableEditor;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Composite;
diff --git a/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/task/TaskXViewer.java b/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/task/TaskXViewer.java index 79b398f86ce..f6ab994418a 100644 --- a/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/task/TaskXViewer.java +++ b/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/task/TaskXViewer.java @@ -44,10 +44,10 @@ import org.eclipse.osee.framework.skynet.core.event.OseeEventManager; import org.eclipse.osee.framework.skynet.core.event.Sender; import org.eclipse.osee.framework.skynet.core.relation.RelationTypeManager; import org.eclipse.osee.framework.ui.plugin.util.AWorkbench; -import org.eclipse.osee.framework.ui.plugin.util.Displays; import org.eclipse.osee.framework.ui.plugin.util.Result; import org.eclipse.osee.framework.ui.skynet.SkynetGuiPlugin; import org.eclipse.osee.framework.ui.skynet.artifact.ArtifactPromptChange; +import org.eclipse.osee.framework.ui.swt.Displays; import org.eclipse.osee.framework.ui.swt.IDirtiableEditor; import org.eclipse.swt.widgets.TreeColumn; import org.eclipse.swt.widgets.TreeItem; diff --git a/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/util/AtsBranchCommitJob.java b/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/util/AtsBranchCommitJob.java index a26bad93cc7..864af2a8081 100644 --- a/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/util/AtsBranchCommitJob.java +++ b/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/util/AtsBranchCommitJob.java @@ -29,9 +29,9 @@ import org.eclipse.osee.framework.logging.OseeLog; import org.eclipse.osee.framework.skynet.core.artifact.BranchManager;
import org.eclipse.osee.framework.skynet.core.conflict.ConflictManagerExternal;
import org.eclipse.osee.framework.skynet.core.transaction.SkynetTransaction;
-import org.eclipse.osee.framework.ui.plugin.util.Displays;
import org.eclipse.osee.framework.ui.plugin.util.Result;
import org.eclipse.osee.framework.ui.skynet.commandHandlers.branch.commit.CommitHandler;
+import org.eclipse.osee.framework.ui.swt.Displays; import org.eclipse.swt.widgets.Display;
public class AtsBranchCommitJob extends Job {
diff --git a/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/util/AtsUtil.java b/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/util/AtsUtil.java index e66f99d4708..15247122ada 100644 --- a/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/util/AtsUtil.java +++ b/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/util/AtsUtil.java @@ -61,7 +61,6 @@ import org.eclipse.osee.framework.skynet.core.event2.filter.IEventFilter; import org.eclipse.osee.framework.skynet.core.utility.DbUtil;
import org.eclipse.osee.framework.skynet.core.utility.IncrementingNum;
import org.eclipse.osee.framework.ui.plugin.util.AWorkbench;
-import org.eclipse.osee.framework.ui.plugin.util.Displays;
import org.eclipse.osee.framework.ui.plugin.util.Result;
import org.eclipse.osee.framework.ui.plugin.xnavigate.XNavigateComposite.TableLoadOption;
import org.eclipse.osee.framework.ui.skynet.SkynetGuiPlugin;
@@ -70,6 +69,7 @@ import org.eclipse.osee.framework.ui.skynet.ats.OseeEditor; import org.eclipse.osee.framework.ui.skynet.render.PresentationType;
import org.eclipse.osee.framework.ui.skynet.render.RendererManager;
import org.eclipse.osee.framework.ui.swt.ALayout;
+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.SWT;
diff --git a/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/util/OpenInAtsLoopbackCmd.java b/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/util/OpenInAtsLoopbackCmd.java index dcd2dcf1a14..ba7e65ff146 100644 --- a/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/util/OpenInAtsLoopbackCmd.java +++ b/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/util/OpenInAtsLoopbackCmd.java @@ -23,67 +23,69 @@ import org.eclipse.osee.framework.logging.OseeLog; import org.eclipse.osee.framework.skynet.core.artifact.Artifact;
import org.eclipse.osee.framework.skynet.core.httpRequests.BaseArtifactLoopbackCmd;
import org.eclipse.osee.framework.ui.skynet.SkynetGuiPlugin;
-import org.eclipse.swt.widgets.Display;
+import org.eclipse.osee.framework.ui.swt.Displays;
/**
* @author Roberto E. Escobar
*/
public class OpenInAtsLoopbackCmd extends BaseArtifactLoopbackCmd {
- @Override
- public boolean isApplicable(String cmd) {
- return cmd != null && cmd.equalsIgnoreCase("open.ats");
- }
+ @Override
+ public boolean isApplicable(String cmd) {
+ return cmd != null && cmd.equalsIgnoreCase("open.ats");
+ }
- @Override
- public void process(final Artifact artifact, final Map<String, String> parameters, final HttpResponse httpResponse) {
- if (artifact != null) {
- try {
- boolean hasPermissionToRead = false;
- try {
- hasPermissionToRead = AccessControlManager.hasPermission(artifact, PermissionEnum.READ);
- } catch (Exception ex) {
- OseeLog.log(SkynetGuiPlugin.class, Level.SEVERE, ex);
- }
+ @Override
+ public void process(final Artifact artifact, final Map<String, String> parameters, final HttpResponse httpResponse) {
+ if (artifact != null) {
+ try {
+ boolean hasPermissionToRead = false;
+ try {
+ hasPermissionToRead = AccessControlManager.hasPermission(artifact, PermissionEnum.READ);
+ } catch (Exception ex) {
+ OseeLog.log(SkynetGuiPlugin.class, Level.SEVERE, ex);
+ }
- if (!hasPermissionToRead) {
- httpResponse.outputStandardError(HttpURLConnection.HTTP_UNAUTHORIZED, String.format(
- "Access denied - User does not have read access to [%s]", artifact));
- } else {
- final MutableBoolean isDone = new MutableBoolean(false);
- Display.getDefault().asyncExec(new Runnable() {
- public void run() {
- try {
- AtsUtil.openATSAction(artifact, AtsOpenOption.OpenOneOrPopupSelect);
- String html =
- AHTML.simplePage("Action [" + artifact.getName() + "]has been opened in OSEE ATS<br><br>" + "<form><input type=button onClick='window.opener=self;window.close()' value='Close'></form>");
- httpResponse.getPrintStream().println(html);
- } catch (Exception ex) {
- OseeLog.log(SkynetGuiPlugin.class, Level.SEVERE, ex);
- httpResponse.outputStandardError(HttpURLConnection.HTTP_INTERNAL_ERROR, String.format(
- "Unable to open: [%s]", artifact.getName()), ex);
- } finally {
- isDone.setValue(true);
- }
- }
- });
- int count = 1;
- while (!isDone.getValue() && count < 30) {
- try {
- Thread.sleep(350);
- } catch (InterruptedException ex) {
- }
- count++;
- }
- }
- } catch (Exception ex) {
- OseeLog.log(SkynetGuiPlugin.class, Level.SEVERE, ex);
- httpResponse.outputStandardError(HttpURLConnection.HTTP_INTERNAL_ERROR, String.format(
- "Unable to open: [%s]", artifact.getName()), ex);
- }
- } else {
- httpResponse.outputStandardError(HttpURLConnection.HTTP_BAD_REQUEST, "Unable to open null artifact");
- }
- }
+ if (!hasPermissionToRead) {
+ httpResponse.outputStandardError(HttpURLConnection.HTTP_UNAUTHORIZED,
+ String.format("Access denied - User does not have read access to [%s]", artifact));
+ } else {
+ final MutableBoolean isDone = new MutableBoolean(false);
+ Displays.ensureInDisplayThread(new Runnable() {
+
+ @Override
+ public void run() {
+ try {
+ AtsUtil.openATSAction(artifact, AtsOpenOption.OpenOneOrPopupSelect);
+ String html =
+ AHTML.simplePage("Action [" + artifact.getName() + "]has been opened in OSEE ATS<br><br>" + "<form><input type=button onClick='window.opener=self;window.close()' value='Close'></form>");
+ httpResponse.getPrintStream().println(html);
+ } catch (Exception ex) {
+ OseeLog.log(SkynetGuiPlugin.class, Level.SEVERE, ex);
+ httpResponse.outputStandardError(HttpURLConnection.HTTP_INTERNAL_ERROR,
+ String.format("Unable to open: [%s]", artifact.getName()), ex);
+ } finally {
+ isDone.setValue(true);
+ }
+ }
+ });
+ int count = 1;
+ while (!isDone.getValue() && count < 30) {
+ try {
+ Thread.sleep(350);
+ } catch (InterruptedException ex) {
+ }
+ count++;
+ }
+ }
+ } catch (Exception ex) {
+ OseeLog.log(SkynetGuiPlugin.class, Level.SEVERE, ex);
+ httpResponse.outputStandardError(HttpURLConnection.HTTP_INTERNAL_ERROR,
+ String.format("Unable to open: [%s]", artifact.getName()), ex);
+ }
+ } else {
+ httpResponse.outputStandardError(HttpURLConnection.HTTP_BAD_REQUEST, "Unable to open null artifact");
+ }
+ }
}
diff --git a/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/util/widgets/XWorkingBranch.java b/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/util/widgets/XWorkingBranch.java index e42e7d01a78..ac6d0c551ee 100644 --- a/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/util/widgets/XWorkingBranch.java +++ b/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/util/widgets/XWorkingBranch.java @@ -31,13 +31,13 @@ import org.eclipse.osee.framework.skynet.core.event2.ArtifactEvent; import org.eclipse.osee.framework.skynet.core.event2.BranchEvent;
import org.eclipse.osee.framework.skynet.core.event2.artifact.IArtifactEventListener;
import org.eclipse.osee.framework.skynet.core.event2.filter.IEventFilter;
-import org.eclipse.osee.framework.ui.plugin.util.Displays;
import org.eclipse.osee.framework.ui.plugin.util.Result;
import org.eclipse.osee.framework.ui.skynet.ArtifactExplorer;
import org.eclipse.osee.framework.ui.skynet.FrameworkImage;
import org.eclipse.osee.framework.ui.skynet.SkynetGuiPlugin;
import org.eclipse.osee.framework.ui.skynet.widgets.IArtifactWidget;
import org.eclipse.osee.framework.ui.skynet.widgets.XWidget;
+import org.eclipse.osee.framework.ui.swt.Displays;
import org.eclipse.osee.framework.ui.swt.ImageManager;
import org.eclipse.osee.framework.ui.swt.Widgets;
import org.eclipse.swt.SWT;
diff --git a/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/util/widgets/commit/XCommitManager.java b/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/util/widgets/commit/XCommitManager.java index d180dd191fe..2bd0f869dcd 100644 --- a/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/util/widgets/commit/XCommitManager.java +++ b/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/util/widgets/commit/XCommitManager.java @@ -37,12 +37,12 @@ import org.eclipse.osee.framework.skynet.core.event.OseeEventManager; import org.eclipse.osee.framework.skynet.core.event.Sender;
import org.eclipse.osee.framework.skynet.core.event2.BranchEvent;
import org.eclipse.osee.framework.ui.plugin.PluginUiImage;
-import org.eclipse.osee.framework.ui.plugin.util.Displays;
import org.eclipse.osee.framework.ui.plugin.util.Result;
import org.eclipse.osee.framework.ui.skynet.SkynetGuiPlugin;
import org.eclipse.osee.framework.ui.skynet.widgets.IArtifactWidget;
import org.eclipse.osee.framework.ui.skynet.widgets.XWidget;
import org.eclipse.osee.framework.ui.swt.ALayout;
+import org.eclipse.osee.framework.ui.swt.Displays;
import org.eclipse.osee.framework.ui.swt.IDirtiableEditor;
import org.eclipse.osee.framework.ui.swt.ImageManager;
import org.eclipse.osee.framework.ui.swt.Widgets;
diff --git a/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/util/widgets/defect/DefectContentProvider.java b/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/util/widgets/defect/DefectContentProvider.java index 4cc22d1ffdf..8d9503fb84e 100644 --- a/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/util/widgets/defect/DefectContentProvider.java +++ b/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/util/widgets/defect/DefectContentProvider.java @@ -15,7 +15,7 @@ import java.util.Collection; import java.util.HashSet;
import org.eclipse.jface.viewers.ITreeContentProvider;
import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.osee.framework.ui.plugin.util.Displays;
+import org.eclipse.osee.framework.ui.swt.Displays;
public class DefectContentProvider implements ITreeContentProvider {
diff --git a/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/util/widgets/defect/XDefectViewer.java b/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/util/widgets/defect/XDefectViewer.java index e1896c8d0f0..5738edc2eae 100644 --- a/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/util/widgets/defect/XDefectViewer.java +++ b/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/util/widgets/defect/XDefectViewer.java @@ -46,7 +46,6 @@ import org.eclipse.osee.framework.skynet.core.event2.filter.IEventFilter; import org.eclipse.osee.framework.skynet.core.transaction.SkynetTransaction;
import org.eclipse.osee.framework.ui.plugin.PluginUiImage;
import org.eclipse.osee.framework.ui.plugin.util.AWorkbench;
-import org.eclipse.osee.framework.ui.plugin.util.Displays;
import org.eclipse.osee.framework.ui.plugin.util.Result;
import org.eclipse.osee.framework.ui.skynet.FrameworkImage;
import org.eclipse.osee.framework.ui.skynet.SkynetGuiPlugin;
@@ -55,6 +54,7 @@ import org.eclipse.osee.framework.ui.skynet.widgets.XDate; import org.eclipse.osee.framework.ui.skynet.widgets.XWidget;
import org.eclipse.osee.framework.ui.skynet.widgets.dialog.EntryDialog;
import org.eclipse.osee.framework.ui.swt.ALayout;
+import org.eclipse.osee.framework.ui.swt.Displays;
import org.eclipse.osee.framework.ui.swt.IDirtiableEditor;
import org.eclipse.osee.framework.ui.swt.ImageManager;
import org.eclipse.swt.SWT;
diff --git a/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/util/widgets/role/UserRoleContentProvider.java b/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/util/widgets/role/UserRoleContentProvider.java index 4155f172737..0f8620cf934 100644 --- a/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/util/widgets/role/UserRoleContentProvider.java +++ b/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/util/widgets/role/UserRoleContentProvider.java @@ -15,7 +15,7 @@ import java.util.Collection; import java.util.HashSet;
import org.eclipse.jface.viewers.ITreeContentProvider;
import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.osee.framework.ui.plugin.util.Displays;
+import org.eclipse.osee.framework.ui.swt.Displays;
public class UserRoleContentProvider implements ITreeContentProvider {
diff --git a/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/util/widgets/role/XUserRoleViewer.java b/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/util/widgets/role/XUserRoleViewer.java index 2676bbc8b4d..4cec274a3a7 100644 --- a/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/util/widgets/role/XUserRoleViewer.java +++ b/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/util/widgets/role/XUserRoleViewer.java @@ -43,13 +43,13 @@ import org.eclipse.osee.framework.skynet.core.event2.filter.IEventFilter; import org.eclipse.osee.framework.skynet.core.transaction.SkynetTransaction; import org.eclipse.osee.framework.ui.plugin.PluginUiImage; import org.eclipse.osee.framework.ui.plugin.util.AWorkbench; -import org.eclipse.osee.framework.ui.plugin.util.Displays; import org.eclipse.osee.framework.ui.plugin.util.Result; import org.eclipse.osee.framework.ui.skynet.FrameworkImage; import org.eclipse.osee.framework.ui.skynet.SkynetGuiPlugin; import org.eclipse.osee.framework.ui.skynet.widgets.IArtifactWidget; import org.eclipse.osee.framework.ui.skynet.widgets.XWidget; import org.eclipse.osee.framework.ui.swt.ALayout; +import org.eclipse.osee.framework.ui.swt.Displays; import org.eclipse.osee.framework.ui.swt.IDirtiableEditor; import org.eclipse.osee.framework.ui.swt.ImageManager; import org.eclipse.swt.SWT; diff --git a/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/workflow/editor/AtsWorkflowConfigEditor.java b/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/workflow/editor/AtsWorkflowConfigEditor.java index f6ccbe1e54e..83053005175 100644 --- a/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/workflow/editor/AtsWorkflowConfigEditor.java +++ b/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/workflow/editor/AtsWorkflowConfigEditor.java @@ -66,10 +66,10 @@ import org.eclipse.osee.framework.skynet.core.event2.artifact.IArtifactEventList import org.eclipse.osee.framework.skynet.core.event2.filter.IEventFilter;
import org.eclipse.osee.framework.skynet.core.transaction.SkynetTransaction;
import org.eclipse.osee.framework.ui.plugin.util.AWorkbench;
-import org.eclipse.osee.framework.ui.plugin.util.Displays;
import org.eclipse.osee.framework.ui.plugin.util.Result;
import org.eclipse.osee.framework.ui.skynet.widgets.workflow.WorkFlowDefinition;
import org.eclipse.osee.framework.ui.skynet.widgets.workflow.WorkPageDefinition;
+import org.eclipse.osee.framework.ui.swt.Displays;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.ui.IActionBars;
diff --git a/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/workflow/editor/AtsWorkflowConfigEditorPaletteFactory.java b/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/workflow/editor/AtsWorkflowConfigEditorPaletteFactory.java index 313b7830893..363ae016788 100644 --- a/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/workflow/editor/AtsWorkflowConfigEditorPaletteFactory.java +++ b/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/workflow/editor/AtsWorkflowConfigEditorPaletteFactory.java @@ -36,8 +36,8 @@ import org.eclipse.osee.ats.workflow.editor.model.TransitionConnection; import org.eclipse.osee.ats.workflow.editor.model.WorkPageShape;
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.swt.widgets.Display;
/**
* Utility class that can create a GEF Palette.
@@ -47,145 +47,150 @@ import org.eclipse.swt.widgets.Display; */
final class AtsWorkflowConfigEditorPaletteFactory {
- /** Create the "States" drawer. */
- private static PaletteContainer createStatesDrawer() {
- PaletteDrawer componentsDrawer = new PaletteDrawer("States");
-
- CombinedTemplateCreationEntry component =
- new CombinedTemplateCreationEntry("State", "Create a new Workflow State", WorkPageShape.class,
- new SimpleFactory(WorkPageShape.class), ImageManager.getImageDescriptor(FrameworkImage.RECTANGLE_16),
- ImageManager.getImageDescriptor(FrameworkImage.RECTANGLE_24));
- componentsDrawer.add(component);
-
- component =
- new CombinedTemplateCreationEntry("Completed State", "Create a Completed State",
- CompletedWorkPageShape.class, new SimpleFactory(CompletedWorkPageShape.class),
- ImageManager.getImageDescriptor(FrameworkImage.RECTANGLE_16),
- ImageManager.getImageDescriptor(FrameworkImage.RECTANGLE_24));
- componentsDrawer.add(component);
-
- component =
- new CombinedTemplateCreationEntry("Cancelled State", "Create a Cancelled State",
- CancelledWorkPageShape.class, new SimpleFactory(CancelledWorkPageShape.class),
- ImageManager.getImageDescriptor(FrameworkImage.RECTANGLE_16),
- ImageManager.getImageDescriptor(FrameworkImage.RECTANGLE_24));
- componentsDrawer.add(component);
-
- return componentsDrawer;
- }
-
- /** Create the "Transitions" drawer. */
- private static PaletteContainer createTransitionsDrawer() {
- PaletteDrawer componentsDrawer = new PaletteDrawer("Transitions");
-
- ToolEntry tool =
- new ConnectionCreationToolEntry("Default Transition", "Create a Default Transition", new CreationFactory() {
- public Object getNewObject() {
- return null;
- }
-
- public Object getObjectType() {
- return DefaultTransitionConnection.class;
- }
- }, ImageManager.getImageDescriptor(AtsImage.CONECTION_16),
- ImageManager.getImageDescriptor(AtsImage.CONECTION_24));
- componentsDrawer.add(tool);
-
- tool =
- new ConnectionCreationToolEntry("Transition", "Create a Transition", new CreationFactory() {
- public Object getNewObject() {
- return null;
- }
-
- public Object getObjectType() {
- return TransitionConnection.class;
- }
- }, ImageManager.getImageDescriptor(AtsImage.CONECTION_16),
- ImageManager.getImageDescriptor(AtsImage.CONECTION_24));
- componentsDrawer.add(tool);
-
- tool =
- new ConnectionCreationToolEntry("Return Transition", "Create a Return Transition", new CreationFactory() {
- public Object getNewObject() {
- return null;
- }
-
- public Object getObjectType() {
- return ReturnTransitionConnection.class;
- }
- }, ImageManager.getImageDescriptor(AtsImage.CONECTION_16),
- ImageManager.getImageDescriptor(AtsImage.CONECTION_24));
- componentsDrawer.add(tool);
-
- return componentsDrawer;
- }
-
- /**
- * Creates the PaletteRoot and adds all palette elements. Use this factory method to create a new palette for your
- * graphical editor.
- *
- * @return a new PaletteRoot
- */
- static PaletteRoot createPalette(AtsWorkflowConfigEditor editor) {
- PaletteRoot palette = new PaletteRoot();
- palette.add(createToolsGroup(palette, editor));
- palette.add(createStatesDrawer());
- palette.add(createTransitionsDrawer());
- return palette;
- }
-
- /** Create the "Tools" group. */
- private static PaletteContainer createToolsGroup(PaletteRoot palette, AtsWorkflowConfigEditor editor) {
- PaletteToolbar toolbar = new PaletteToolbar("Tools");
-
- // Add a selection tool to the group
- ToolEntry tool = new PanningSelectionToolEntry();
- toolbar.add(tool);
- palette.setDefaultEntry(tool);
-
- // Add a marquee tool to the group
- toolbar.add(new MarqueeToolEntry());
-
- toolbar.add(new ValidateDiagramToolEntry());
-
- final Action action =
- OseeUiActions.createBugAction(AtsPlugin.getInstance(), editor, AtsWorkflowConfigEditor.EDITOR_ID,
- "ATS Workflow Config Editor");
- 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;
- }
-
- /** Utility class. */
- private AtsWorkflowConfigEditorPaletteFactory() {
- // Utility class
- }
+ /** Create the "States" drawer. */
+ private static PaletteContainer createStatesDrawer() {
+ PaletteDrawer componentsDrawer = new PaletteDrawer("States");
+
+ CombinedTemplateCreationEntry component =
+ new CombinedTemplateCreationEntry("State", "Create a new Workflow State", WorkPageShape.class,
+ new SimpleFactory(WorkPageShape.class),
+ ImageManager.getImageDescriptor(FrameworkImage.RECTANGLE_16),
+ ImageManager.getImageDescriptor(FrameworkImage.RECTANGLE_24));
+ componentsDrawer.add(component);
+
+ component =
+ new CombinedTemplateCreationEntry("Completed State", "Create a Completed State",
+ CompletedWorkPageShape.class, new SimpleFactory(CompletedWorkPageShape.class),
+ ImageManager.getImageDescriptor(FrameworkImage.RECTANGLE_16),
+ ImageManager.getImageDescriptor(FrameworkImage.RECTANGLE_24));
+ componentsDrawer.add(component);
+
+ component =
+ new CombinedTemplateCreationEntry("Cancelled State", "Create a Cancelled State",
+ CancelledWorkPageShape.class, new SimpleFactory(CancelledWorkPageShape.class),
+ ImageManager.getImageDescriptor(FrameworkImage.RECTANGLE_16),
+ ImageManager.getImageDescriptor(FrameworkImage.RECTANGLE_24));
+ componentsDrawer.add(component);
+
+ return componentsDrawer;
+ }
+
+ /** Create the "Transitions" drawer. */
+ private static PaletteContainer createTransitionsDrawer() {
+ PaletteDrawer componentsDrawer = new PaletteDrawer("Transitions");
+
+ ToolEntry tool =
+ new ConnectionCreationToolEntry("Default Transition", "Create a Default Transition",
+ new CreationFactory() {
+ public Object getNewObject() {
+ return null;
+ }
+
+ public Object getObjectType() {
+ return DefaultTransitionConnection.class;
+ }
+ }, ImageManager.getImageDescriptor(AtsImage.CONECTION_16),
+ ImageManager.getImageDescriptor(AtsImage.CONECTION_24));
+ componentsDrawer.add(tool);
+
+ tool =
+ new ConnectionCreationToolEntry("Transition", "Create a Transition", new CreationFactory() {
+ public Object getNewObject() {
+ return null;
+ }
+
+ public Object getObjectType() {
+ return TransitionConnection.class;
+ }
+ }, ImageManager.getImageDescriptor(AtsImage.CONECTION_16),
+ ImageManager.getImageDescriptor(AtsImage.CONECTION_24));
+ componentsDrawer.add(tool);
+
+ tool =
+ new ConnectionCreationToolEntry("Return Transition", "Create a Return Transition",
+ new CreationFactory() {
+ public Object getNewObject() {
+ return null;
+ }
+
+ public Object getObjectType() {
+ return ReturnTransitionConnection.class;
+ }
+ }, ImageManager.getImageDescriptor(AtsImage.CONECTION_16),
+ ImageManager.getImageDescriptor(AtsImage.CONECTION_24));
+ componentsDrawer.add(tool);
+
+ return componentsDrawer;
+ }
+
+ /**
+ * Creates the PaletteRoot and adds all palette elements. Use this factory method to create a new palette for your
+ * graphical editor.
+ *
+ * @return a new PaletteRoot
+ */
+ static PaletteRoot createPalette(AtsWorkflowConfigEditor editor) {
+ PaletteRoot palette = new PaletteRoot();
+ palette.add(createToolsGroup(palette, editor));
+ palette.add(createStatesDrawer());
+ palette.add(createTransitionsDrawer());
+ return palette;
+ }
+
+ /** Create the "Tools" group. */
+ private static PaletteContainer createToolsGroup(PaletteRoot palette, AtsWorkflowConfigEditor editor) {
+ PaletteToolbar toolbar = new PaletteToolbar("Tools");
+
+ // Add a selection tool to the group
+ ToolEntry tool = new PanningSelectionToolEntry();
+ toolbar.add(tool);
+ palette.setDefaultEntry(tool);
+
+ // Add a marquee tool to the group
+ toolbar.add(new MarqueeToolEntry());
+
+ toolbar.add(new ValidateDiagramToolEntry());
+
+ final Action action =
+ OseeUiActions.createBugAction(AtsPlugin.getInstance(), editor, AtsWorkflowConfigEditor.EDITOR_ID,
+ "ATS Workflow Config Editor");
+ 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;
+ }
+
+ /** Utility class. */
+ private AtsWorkflowConfigEditorPaletteFactory() {
+ // Utility class
+ }
}
\ No newline at end of file diff --git a/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/workflow/editor/AtsWorkflowConfigRenderer.java b/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/workflow/editor/AtsWorkflowConfigRenderer.java index 8ccfaa761bf..2dbd5ca4d5d 100644 --- a/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/workflow/editor/AtsWorkflowConfigRenderer.java +++ b/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/workflow/editor/AtsWorkflowConfigRenderer.java @@ -20,11 +20,11 @@ import org.eclipse.osee.framework.logging.OseeLevel; import org.eclipse.osee.framework.logging.OseeLog; import org.eclipse.osee.framework.skynet.core.artifact.Artifact; import org.eclipse.osee.framework.ui.plugin.util.AWorkbench; -import org.eclipse.osee.framework.ui.plugin.util.Displays; import org.eclipse.osee.framework.ui.skynet.SkynetGuiPlugin; import org.eclipse.osee.framework.ui.skynet.render.DefaultArtifactRenderer; import org.eclipse.osee.framework.ui.skynet.render.PresentationType; import org.eclipse.osee.framework.ui.skynet.widgets.workflow.WorkFlowDefinition; +import org.eclipse.osee.framework.ui.swt.Displays; import org.eclipse.osee.framework.ui.swt.ImageManager; import org.eclipse.swt.graphics.Image; import org.eclipse.ui.IEditorInput; diff --git a/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/world/AtsXWidgetActionFormPage.java b/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/world/AtsXWidgetActionFormPage.java index 67a6066806c..8805871c649 100644 --- a/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/world/AtsXWidgetActionFormPage.java +++ b/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/world/AtsXWidgetActionFormPage.java @@ -17,7 +17,6 @@ import org.eclipse.osee.ats.internal.AtsPlugin; import org.eclipse.osee.framework.core.exception.OseeCoreException; import org.eclipse.osee.framework.logging.OseeLevel; import org.eclipse.osee.framework.logging.OseeLog; -import org.eclipse.osee.framework.ui.plugin.util.Displays; import org.eclipse.osee.framework.ui.plugin.util.Result; import org.eclipse.osee.framework.ui.skynet.SkynetGuiPlugin; import org.eclipse.osee.framework.ui.skynet.XFormToolkit; @@ -29,6 +28,7 @@ import org.eclipse.osee.framework.ui.skynet.widgets.workflow.DynamicXWidgetLayou import org.eclipse.osee.framework.ui.skynet.widgets.workflow.IDynamicWidgetLayoutListener; import org.eclipse.osee.framework.ui.skynet.widgets.workflow.IXWidgetOptionResolver; import org.eclipse.osee.framework.ui.swt.ALayout; +import org.eclipse.osee.framework.ui.swt.Displays; import org.eclipse.swt.SWT; import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionEvent; diff --git a/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/world/WorldComposite.java b/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/world/WorldComposite.java index 8029d49fcd7..a1256c4dfde 100644 --- a/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/world/WorldComposite.java +++ b/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/world/WorldComposite.java @@ -32,7 +32,6 @@ import org.eclipse.osee.framework.core.exception.OseeCoreException; import org.eclipse.osee.framework.logging.OseeLevel;
import org.eclipse.osee.framework.logging.OseeLog;
import org.eclipse.osee.framework.skynet.core.artifact.Artifact;
-import org.eclipse.osee.framework.ui.plugin.util.Displays;
import org.eclipse.osee.framework.ui.plugin.xnavigate.XNavigateComposite.TableLoadOption;
import org.eclipse.osee.framework.ui.skynet.action.RefreshAction.IRefreshActionHandler;
import org.eclipse.osee.framework.ui.skynet.render.PresentationType; @@ -40,6 +39,7 @@ import org.eclipse.osee.framework.ui.skynet.render.RendererManager; import org.eclipse.osee.framework.ui.skynet.util.DbConnectionExceptionComposite;
import org.eclipse.osee.framework.ui.skynet.widgets.XDate;
import org.eclipse.osee.framework.ui.swt.ALayout;
+import org.eclipse.osee.framework.ui.swt.Displays;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.ScrolledComposite;
import org.eclipse.swt.graphics.Image;
diff --git a/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/world/WorldContentProvider.java b/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/world/WorldContentProvider.java index 089bbcb2664..9387de3164e 100644 --- a/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/world/WorldContentProvider.java +++ b/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/world/WorldContentProvider.java @@ -32,7 +32,7 @@ import org.eclipse.osee.framework.core.exception.OseeCoreException; import org.eclipse.osee.framework.logging.OseeLevel;
import org.eclipse.osee.framework.logging.OseeLog;
import org.eclipse.osee.framework.skynet.core.artifact.Artifact;
-import org.eclipse.osee.framework.ui.plugin.util.Displays;
+import org.eclipse.osee.framework.ui.swt.Displays;
public class WorldContentProvider implements ITreeContentProvider {
diff --git a/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/world/WorldEditor.java b/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/world/WorldEditor.java index b1f2ba6eb47..cf79b47d788 100644 --- a/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/world/WorldEditor.java +++ b/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/world/WorldEditor.java @@ -28,8 +28,8 @@ import org.eclipse.osee.framework.logging.OseeLog; import org.eclipse.osee.framework.plugin.core.IActionable;
import org.eclipse.osee.framework.skynet.core.artifact.Artifact;
import org.eclipse.osee.framework.ui.plugin.util.AWorkbench;
-import org.eclipse.osee.framework.ui.plugin.util.Displays;
import org.eclipse.osee.framework.ui.skynet.OseeContributionItem;
+import org.eclipse.osee.framework.ui.swt.Displays;
import org.eclipse.osee.framework.ui.swt.IDirtiableEditor;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Composite;
diff --git a/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/world/WorldEditorParameterSearchItemProvider.java b/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/world/WorldEditorParameterSearchItemProvider.java index 1a7522e70fe..8b7c7d11a77 100644 --- a/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/world/WorldEditorParameterSearchItemProvider.java +++ b/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/world/WorldEditorParameterSearchItemProvider.java @@ -26,12 +26,12 @@ import org.eclipse.osee.framework.jdk.core.util.Strings; import org.eclipse.osee.framework.logging.OseeLog;
import org.eclipse.osee.framework.skynet.core.artifact.Artifact;
import org.eclipse.osee.framework.ui.plugin.util.AWorkbench;
-import org.eclipse.osee.framework.ui.plugin.util.Displays;
import org.eclipse.osee.framework.ui.plugin.util.Result;
import org.eclipse.osee.framework.ui.plugin.xnavigate.XNavigateComposite.TableLoadOption;
import org.eclipse.osee.framework.ui.skynet.widgets.workflow.DynamicXWidgetLayoutData;
import org.eclipse.osee.framework.ui.skynet.widgets.workflow.IDynamicWidgetLayoutListener;
import org.eclipse.osee.framework.ui.swt.CursorManager;
+import org.eclipse.osee.framework.ui.swt.Displays;
import org.eclipse.swt.SWT;
/**
diff --git a/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/world/WorldViewerEventManager.java b/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/world/WorldViewerEventManager.java index f71b272b2fe..a4b93a771da 100644 --- a/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/world/WorldViewerEventManager.java +++ b/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/world/WorldViewerEventManager.java @@ -29,7 +29,7 @@ import org.eclipse.osee.framework.skynet.core.event2.artifact.EventBasicGuidArti import org.eclipse.osee.framework.skynet.core.event2.artifact.EventModType;
import org.eclipse.osee.framework.skynet.core.event2.artifact.IArtifactEventListener;
import org.eclipse.osee.framework.skynet.core.event2.filter.IEventFilter;
-import org.eclipse.osee.framework.ui.plugin.util.Displays;
+import org.eclipse.osee.framework.ui.swt.Displays; /**
* Common location for event handling for task and world composites in order to keep number of registrations and
diff --git a/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/world/WorldXViewer.java b/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/world/WorldXViewer.java index 23bcfc3e41f..7b5557c999d 100644 --- a/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/world/WorldXViewer.java +++ b/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/world/WorldXViewer.java @@ -73,12 +73,12 @@ import org.eclipse.osee.framework.skynet.core.transaction.SkynetTransaction; import org.eclipse.osee.framework.skynet.core.utility.Artifacts;
import org.eclipse.osee.framework.skynet.core.utility.LoadedArtifacts;
import org.eclipse.osee.framework.ui.plugin.util.AWorkbench;
-import org.eclipse.osee.framework.ui.plugin.util.Displays;
import org.eclipse.osee.framework.ui.plugin.xnavigate.XNavigateComposite.TableLoadOption;
import org.eclipse.osee.framework.ui.skynet.SkynetGuiPlugin;
import org.eclipse.osee.framework.ui.skynet.artifact.ArtifactPromptChange;
import org.eclipse.osee.framework.ui.skynet.results.XResultData;
import org.eclipse.osee.framework.ui.skynet.widgets.xviewer.skynet.column.XViewerAttributeColumn;
+import org.eclipse.osee.framework.ui.swt.Displays;
import org.eclipse.osee.framework.ui.swt.ImageManager;
import org.eclipse.osee.framework.ui.swt.Widgets;
import org.eclipse.swt.events.DisposeEvent;
diff --git a/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/world/WorldXViewerEventManager.java b/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/world/WorldXViewerEventManager.java index 6d1f385ad4b..c52ae8fa754 100644 --- a/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/world/WorldXViewerEventManager.java +++ b/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/world/WorldXViewerEventManager.java @@ -24,7 +24,7 @@ import org.eclipse.osee.framework.skynet.core.event2.artifact.EventBasicGuidArti import org.eclipse.osee.framework.skynet.core.event2.artifact.EventModType;
import org.eclipse.osee.framework.skynet.core.event2.artifact.IArtifactEventListener;
import org.eclipse.osee.framework.skynet.core.event2.filter.IEventFilter;
-import org.eclipse.osee.framework.ui.plugin.util.Displays;
+import org.eclipse.osee.framework.ui.swt.Displays;
/**
* Common location for event handling for task and world composites in order to keep number of registrations and
diff --git a/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/world/WorldXWidgetActionPage.java b/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/world/WorldXWidgetActionPage.java index d6e282a2ede..6af66d42914 100644 --- a/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/world/WorldXWidgetActionPage.java +++ b/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/world/WorldXWidgetActionPage.java @@ -43,13 +43,13 @@ import org.eclipse.osee.framework.plugin.core.util.Jobs; import org.eclipse.osee.framework.skynet.core.artifact.Artifact;
import org.eclipse.osee.framework.ui.plugin.OseeUiActions;
import org.eclipse.osee.framework.ui.plugin.util.AWorkbench;
-import org.eclipse.osee.framework.ui.plugin.util.Displays;
import org.eclipse.osee.framework.ui.plugin.util.Result;
import org.eclipse.osee.framework.ui.skynet.FrameworkImage;
import org.eclipse.osee.framework.ui.skynet.action.CollapseAllAction;
import org.eclipse.osee.framework.ui.skynet.action.ExpandAllAction;
import org.eclipse.osee.framework.ui.skynet.action.RefreshAction;
import org.eclipse.osee.framework.ui.skynet.widgets.workflow.IDynamicWidgetLayoutListener;
+import org.eclipse.osee.framework.ui.swt.Displays;
import org.eclipse.osee.framework.ui.swt.ImageManager;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.KeyEvent;
diff --git a/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/world/search/MultipleHridSearchOperation.java b/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/world/search/MultipleHridSearchOperation.java index b1a3a603375..c7ad923ecd1 100644 --- a/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/world/search/MultipleHridSearchOperation.java +++ b/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/world/search/MultipleHridSearchOperation.java @@ -42,7 +42,6 @@ import org.eclipse.osee.framework.skynet.core.artifact.IATSArtifact; import org.eclipse.osee.framework.skynet.core.artifact.search.ArtifactQuery; import org.eclipse.osee.framework.ui.plugin.util.AWorkbench; import org.eclipse.osee.framework.ui.plugin.util.ArrayTreeContentProvider; -import org.eclipse.osee.framework.ui.plugin.util.Displays; import org.eclipse.osee.framework.ui.plugin.xnavigate.XNavigateComposite.TableLoadOption; import org.eclipse.osee.framework.ui.skynet.ArtifactDecoratorPreferences; import org.eclipse.osee.framework.ui.skynet.ArtifactLabelProvider; @@ -50,6 +49,7 @@ import org.eclipse.osee.framework.ui.skynet.ArtifactViewerSorter; import org.eclipse.osee.framework.ui.skynet.render.PresentationType; import org.eclipse.osee.framework.ui.skynet.render.RendererManager; import org.eclipse.osee.framework.ui.skynet.util.filteredTree.SimpleCheckFilteredTreeDialog; +import org.eclipse.osee.framework.ui.swt.Displays; import org.eclipse.swt.widgets.Display; import org.eclipse.ui.dialogs.ListDialog; diff --git a/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/world/search/MultipleHridSearchUi.java b/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/world/search/MultipleHridSearchUi.java index e46b80d3ee2..0961c0656af 100644 --- a/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/world/search/MultipleHridSearchUi.java +++ b/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/world/search/MultipleHridSearchUi.java @@ -14,12 +14,12 @@ import org.eclipse.jface.dialogs.MessageDialog; import org.eclipse.osee.ats.util.AtsUtil;
import org.eclipse.osee.framework.jdk.core.util.Strings;
import org.eclipse.osee.framework.ui.plugin.util.AWorkbench;
-import org.eclipse.osee.framework.ui.plugin.util.Displays;
import org.eclipse.osee.framework.ui.skynet.ArtifactImageManager;
import org.eclipse.osee.framework.ui.skynet.FrameworkImage;
import org.eclipse.osee.framework.ui.skynet.branch.BranchSelectionDialog;
import org.eclipse.osee.framework.ui.skynet.widgets.dialog.EntryCheckDialog;
import org.eclipse.osee.framework.ui.skynet.widgets.dialog.EntryDialog;
+import org.eclipse.osee.framework.ui.swt.Displays; import org.eclipse.swt.widgets.Display;
/**
diff --git a/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/world/search/WorldUISearchItem.java b/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/world/search/WorldUISearchItem.java index ec7c02380ab..751fb95849d 100644 --- a/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/world/search/WorldUISearchItem.java +++ b/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/world/search/WorldUISearchItem.java @@ -16,7 +16,7 @@ import org.eclipse.osee.framework.core.exception.OseeCoreException; import org.eclipse.osee.framework.logging.OseeLevel; import org.eclipse.osee.framework.logging.OseeLog; import org.eclipse.osee.framework.skynet.core.artifact.Artifact; -import org.eclipse.osee.framework.ui.plugin.util.Displays; +import org.eclipse.osee.framework.ui.swt.Displays; import org.eclipse.osee.framework.ui.swt.KeyedImage; /** diff --git a/plugins/org.eclipse.osee.coverage/src/org/eclipse/osee/coverage/editor/CoverageEditor.java b/plugins/org.eclipse.osee.coverage/src/org/eclipse/osee/coverage/editor/CoverageEditor.java index 720c1ae6d19..f69e5e181d5 100644 --- a/plugins/org.eclipse.osee.coverage/src/org/eclipse/osee/coverage/editor/CoverageEditor.java +++ b/plugins/org.eclipse.osee.coverage/src/org/eclipse/osee/coverage/editor/CoverageEditor.java @@ -38,11 +38,11 @@ import org.eclipse.osee.framework.skynet.core.artifact.Artifact; import org.eclipse.osee.framework.skynet.core.relation.RelationManager; import org.eclipse.osee.framework.ui.plugin.OseeUiActions; import org.eclipse.osee.framework.ui.plugin.util.AWorkbench; -import org.eclipse.osee.framework.ui.plugin.util.Displays; import org.eclipse.osee.framework.ui.skynet.OseeContributionItem; import org.eclipse.osee.framework.ui.skynet.SkynetGuiPlugin; import org.eclipse.osee.framework.ui.skynet.util.ElapsedTime; import org.eclipse.osee.framework.ui.skynet.widgets.XDate; +import org.eclipse.osee.framework.ui.swt.Displays; import org.eclipse.osee.framework.ui.swt.ImageManager; import org.eclipse.ui.IEditorInput; import org.eclipse.ui.IEditorReference; diff --git a/plugins/org.eclipse.osee.coverage/src/org/eclipse/osee/coverage/editor/CoverageEditorImportTab.java b/plugins/org.eclipse.osee.coverage/src/org/eclipse/osee/coverage/editor/CoverageEditorImportTab.java index 129bda86275..066872d5b00 100644 --- a/plugins/org.eclipse.osee.coverage/src/org/eclipse/osee/coverage/editor/CoverageEditorImportTab.java +++ b/plugins/org.eclipse.osee.coverage/src/org/eclipse/osee/coverage/editor/CoverageEditorImportTab.java @@ -34,7 +34,6 @@ import org.eclipse.osee.framework.jdk.core.util.Strings; import org.eclipse.osee.framework.logging.OseeLevel;
import org.eclipse.osee.framework.logging.OseeLog;
import org.eclipse.osee.framework.ui.plugin.util.ArrayTreeContentProvider;
-import org.eclipse.osee.framework.ui.plugin.util.Displays;
import org.eclipse.osee.framework.ui.skynet.FrameworkImage;
import org.eclipse.osee.framework.ui.skynet.SkynetGuiPlugin;
import org.eclipse.osee.framework.ui.skynet.blam.AbstractBlam;
@@ -43,6 +42,7 @@ import org.eclipse.osee.framework.ui.skynet.blam.sections.BlamOutputSection; import org.eclipse.osee.framework.ui.skynet.blam.sections.BlamUsageSection;
import org.eclipse.osee.framework.ui.skynet.widgets.XComboViewer;
import org.eclipse.osee.framework.ui.swt.ALayout;
+import org.eclipse.osee.framework.ui.swt.Displays; import org.eclipse.osee.framework.ui.swt.ImageManager;
import org.eclipse.osee.framework.ui.swt.Widgets;
import org.eclipse.swt.SWT;
diff --git a/plugins/org.eclipse.osee.coverage/src/org/eclipse/osee/coverage/editor/CoverageEditorLoadingTab.java b/plugins/org.eclipse.osee.coverage/src/org/eclipse/osee/coverage/editor/CoverageEditorLoadingTab.java index f09d6400985..57c167ef7ea 100644 --- a/plugins/org.eclipse.osee.coverage/src/org/eclipse/osee/coverage/editor/CoverageEditorLoadingTab.java +++ b/plugins/org.eclipse.osee.coverage/src/org/eclipse/osee/coverage/editor/CoverageEditorLoadingTab.java @@ -11,12 +11,12 @@ package org.eclipse.osee.coverage.editor;
import org.eclipse.osee.coverage.util.CoverageImage;
-import org.eclipse.osee.framework.ui.plugin.util.Displays;
import org.eclipse.osee.framework.ui.skynet.action.RefreshAction;
import org.eclipse.osee.framework.ui.skynet.action.RefreshAction.IRefreshActionHandler;
import org.eclipse.osee.framework.ui.skynet.results.XResultData;
import org.eclipse.osee.framework.ui.skynet.results.html.XResultsComposite;
import org.eclipse.osee.framework.ui.swt.ALayout;
+import org.eclipse.osee.framework.ui.swt.Displays; import org.eclipse.osee.framework.ui.swt.ImageManager;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridData;
diff --git a/plugins/org.eclipse.osee.coverage/src/org/eclipse/osee/coverage/editor/CoverageEditorMergeTab.java b/plugins/org.eclipse.osee.coverage/src/org/eclipse/osee/coverage/editor/CoverageEditorMergeTab.java index 836424a8cac..7b075dea107 100644 --- a/plugins/org.eclipse.osee.coverage/src/org/eclipse/osee/coverage/editor/CoverageEditorMergeTab.java +++ b/plugins/org.eclipse.osee.coverage/src/org/eclipse/osee/coverage/editor/CoverageEditorMergeTab.java @@ -53,7 +53,6 @@ import org.eclipse.osee.framework.logging.OseeLog; import org.eclipse.osee.framework.skynet.core.artifact.Artifact;
import org.eclipse.osee.framework.skynet.core.transaction.SkynetTransaction;
import org.eclipse.osee.framework.ui.plugin.util.AWorkbench;
-import org.eclipse.osee.framework.ui.plugin.util.Displays;
import org.eclipse.osee.framework.ui.plugin.util.Result;
import org.eclipse.osee.framework.ui.skynet.FrameworkImage;
import org.eclipse.osee.framework.ui.skynet.action.CollapseAllAction;
@@ -62,6 +61,7 @@ import org.eclipse.osee.framework.ui.skynet.action.RefreshAction; import org.eclipse.osee.framework.ui.skynet.results.XResultData;
import org.eclipse.osee.framework.ui.skynet.widgets.dialog.CheckBoxDialog;
import org.eclipse.osee.framework.ui.swt.ALayout;
+import org.eclipse.osee.framework.ui.swt.Displays;
import org.eclipse.osee.framework.ui.swt.ImageManager;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.SashForm;
diff --git a/plugins/org.eclipse.osee.coverage/src/org/eclipse/osee/coverage/editor/CoverageEditorOverviewTab.java b/plugins/org.eclipse.osee.coverage/src/org/eclipse/osee/coverage/editor/CoverageEditorOverviewTab.java index 4fdc02fee80..8368c0b3234 100644 --- a/plugins/org.eclipse.osee.coverage/src/org/eclipse/osee/coverage/editor/CoverageEditorOverviewTab.java +++ b/plugins/org.eclipse.osee.coverage/src/org/eclipse/osee/coverage/editor/CoverageEditorOverviewTab.java @@ -23,7 +23,6 @@ import org.eclipse.osee.coverage.model.CoveragePackageBase; import org.eclipse.osee.coverage.model.CoverageUnit;
import org.eclipse.osee.coverage.util.CoverageUtil;
import org.eclipse.osee.framework.jdk.core.util.AHTML;
-import org.eclipse.osee.framework.ui.plugin.util.Displays;
import org.eclipse.osee.framework.ui.skynet.action.RefreshAction;
import org.eclipse.osee.framework.ui.skynet.action.RefreshAction.IRefreshActionHandler;
import org.eclipse.osee.framework.ui.skynet.action.browser.BrowserPrintAction;
@@ -31,6 +30,7 @@ import org.eclipse.osee.framework.ui.skynet.action.browser.IBrowserActionHandler import org.eclipse.osee.framework.ui.skynet.results.XResultData;
import org.eclipse.osee.framework.ui.skynet.results.html.XResultsComposite;
import org.eclipse.osee.framework.ui.swt.ALayout;
+import org.eclipse.osee.framework.ui.swt.Displays; import org.eclipse.osee.framework.ui.swt.ImageManager;
import org.eclipse.swt.SWT;
import org.eclipse.swt.browser.Browser;
diff --git a/plugins/org.eclipse.osee.coverage/src/org/eclipse/osee/coverage/navigate/CoverageNavigateView.java b/plugins/org.eclipse.osee.coverage/src/org/eclipse/osee/coverage/navigate/CoverageNavigateView.java index c0bcc6b3100..7461f89b1c1 100644 --- a/plugins/org.eclipse.osee.coverage/src/org/eclipse/osee/coverage/navigate/CoverageNavigateView.java +++ b/plugins/org.eclipse.osee.coverage/src/org/eclipse/osee/coverage/navigate/CoverageNavigateView.java @@ -32,6 +32,7 @@ import org.eclipse.osee.framework.ui.plugin.xnavigate.XNavigateItem; import org.eclipse.osee.framework.ui.skynet.OseeContributionItem;
import org.eclipse.osee.framework.ui.skynet.util.DbConnectionExceptionComposite;
import org.eclipse.osee.framework.ui.skynet.widgets.XBranchSelectWidget;
+import org.eclipse.osee.framework.ui.swt.Displays;
import org.eclipse.osee.framework.ui.swt.ImageManager;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridData;
@@ -47,146 +48,148 @@ import org.eclipse.ui.part.ViewPart; */
public class CoverageNavigateView extends ViewPart implements IActionable {
- public static final String VIEW_ID = "org.eclipse.osee.coverage.navigate.CoverageNavigateView";
- private XNavigateComposite xNavComp;
- private XBranchSelectWidget xBranchSelectWidget;
-
- public CoverageNavigateView() {
- }
-
- @Override
- public void setFocus() {
- }
-
- @Override
- public void createPartControl(Composite parent) {
- if (!DbConnectionExceptionComposite.dbConnectionIsOk(parent)) {
- return;
- }
-
- OseeContributionItem.addTo(this, false);
-
- Composite comp = new Composite(parent, SWT.None);
- comp.setLayoutData(new GridData(SWT.FILL, SWT.NONE, true, false));
-
- xBranchSelectWidget = new XBranchSelectWidget("");
- xBranchSelectWidget.setDisplayLabel(false);
- if (CoverageUtil.getBranch() != null) {
- xBranchSelectWidget.setSelection(CoverageUtil.getBranch());
- }
- xBranchSelectWidget.createWidgets(comp, 1);
- xBranchSelectWidget.addListener(new Listener() {
- @Override
- public void handleEvent(Event event) {
- try {
- Branch selectedBranch = xBranchSelectWidget.getData();
- if (selectedBranch != null) {
- CoverageUtil.setNavigatorSelectedBranch(selectedBranch);
- }
- } catch (Exception ex) {
- OseeLog.log(getClass(), Level.SEVERE, ex);
- }
- }
-
- });
- CoverageUtil.addBranchChangeListener(new Listener() {
- @Override
- public void handleEvent(Event event) {
- xBranchSelectWidget.setSelection(CoverageUtil.getBranch());
- }
- });
- xNavComp = new XNavigateComposite(new CoverageNavigateViewItems(), comp, SWT.NONE);
-
- createActions();
- xNavComp.refresh();
-
- Label label = new Label(xNavComp, SWT.None);
- String str = getWhoAmI();
- if (CoverageUtil.isAdmin()) {
- str += " - Admin";
- }
- if (!str.equals("")) {
- if (CoverageUtil.isAdmin()) {
- label.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_RED));
- } else {
- label.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_BLUE));
- }
- }
- label.setText(str);
- label.setToolTipText(str);
- GridData gridData = new GridData(GridData.HORIZONTAL_ALIGN_CENTER | GridData.VERTICAL_ALIGN_CENTER);
- gridData.heightHint = 15;
- label.setLayoutData(gridData);
-
- addExtensionPointListenerBecauseOfWorkspaceLoading();
- }
-
- private String getWhoAmI() {
- try {
- String userName = UserManager.getUser().getName();
- return String.format("%s - %s:%s", userName, ClientSessionManager.getDataStoreName(),
- ClientSessionManager.getDataStoreLoginName());
- } catch (Exception ex) {
- OseeLog.log(Activator.class, Level.SEVERE, ex);
- return "Exception: " + ex.getLocalizedMessage();
- }
- }
-
- private void addExtensionPointListenerBecauseOfWorkspaceLoading() {
- IExtensionRegistry extensionRegistry = Platform.getExtensionRegistry();
- extensionRegistry.addListener(new IRegistryEventListener() {
- @Override
- public void added(IExtension[] extensions) {
- refresh();
- }
-
- @Override
- public void added(IExtensionPoint[] extensionPoints) {
- refresh();
- }
-
- @Override
- public void removed(IExtension[] extensions) {
- refresh();
- }
-
- @Override
- public void removed(IExtensionPoint[] extensionPoints) {
- refresh();
- }
- }, "org.eclipse.osee.coverage.CoverageNavigateItem");
- }
-
- protected void createActions() {
- Action refreshAction = new Action("Refresh") {
-
- @Override
- public void run() {
- xNavComp.refresh();
- }
- };
- refreshAction.setImageDescriptor(ImageManager.getImageDescriptor(PluginUiImage.REFRESH));
- refreshAction.setToolTipText("Refresh");
- getViewSite().getActionBars().getMenuManager().add(refreshAction);
-
- OseeUiActions.addBugToViewToolbar(this, this, Activator.getInstance(), VIEW_ID, "Coverage Navigator");
-
- }
-
- public String getActionDescription() {
- IStructuredSelection sel = (IStructuredSelection) xNavComp.getFilteredTree().getViewer().getSelection();
- if (sel.iterator().hasNext()) {
- return String.format("Currently Selected - %s", ((XNavigateItem) sel.iterator().next()).getName());
- }
- return "";
- }
-
- public void refresh() {
- Display.getDefault().asyncExec(new Runnable() {
- public void run() {
- xNavComp.refresh();
- }
- });
- }
+ public static final String VIEW_ID = "org.eclipse.osee.coverage.navigate.CoverageNavigateView";
+ private XNavigateComposite xNavComp;
+ private XBranchSelectWidget xBranchSelectWidget;
+
+ public CoverageNavigateView() {
+ }
+
+ @Override
+ public void setFocus() {
+ }
+
+ @Override
+ public void createPartControl(Composite parent) {
+ if (!DbConnectionExceptionComposite.dbConnectionIsOk(parent)) {
+ return;
+ }
+
+ OseeContributionItem.addTo(this, false);
+
+ Composite comp = new Composite(parent, SWT.None);
+ comp.setLayoutData(new GridData(SWT.FILL, SWT.NONE, true, false));
+
+ xBranchSelectWidget = new XBranchSelectWidget("");
+ xBranchSelectWidget.setDisplayLabel(false);
+ if (CoverageUtil.getBranch() != null) {
+ xBranchSelectWidget.setSelection(CoverageUtil.getBranch());
+ }
+ xBranchSelectWidget.createWidgets(comp, 1);
+ xBranchSelectWidget.addListener(new Listener() {
+ @Override
+ public void handleEvent(Event event) {
+ try {
+ Branch selectedBranch = xBranchSelectWidget.getData();
+ if (selectedBranch != null) {
+ CoverageUtil.setNavigatorSelectedBranch(selectedBranch);
+ }
+ } catch (Exception ex) {
+ OseeLog.log(getClass(), Level.SEVERE, ex);
+ }
+ }
+
+ });
+ CoverageUtil.addBranchChangeListener(new Listener() {
+ @Override
+ public void handleEvent(Event event) {
+ xBranchSelectWidget.setSelection(CoverageUtil.getBranch());
+ }
+ });
+ xNavComp = new XNavigateComposite(new CoverageNavigateViewItems(), comp, SWT.NONE);
+
+ createActions();
+ xNavComp.refresh();
+
+ Label label = new Label(xNavComp, SWT.None);
+ String str = getWhoAmI();
+ if (CoverageUtil.isAdmin()) {
+ str += " - Admin";
+ }
+ if (!str.equals("")) {
+ if (CoverageUtil.isAdmin()) {
+ label.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_RED));
+ } else {
+ label.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_BLUE));
+ }
+ }
+ label.setText(str);
+ label.setToolTipText(str);
+ GridData gridData = new GridData(GridData.HORIZONTAL_ALIGN_CENTER | GridData.VERTICAL_ALIGN_CENTER);
+ gridData.heightHint = 15;
+ label.setLayoutData(gridData);
+
+ addExtensionPointListenerBecauseOfWorkspaceLoading();
+ }
+
+ private String getWhoAmI() {
+ try {
+ String userName = UserManager.getUser().getName();
+ return String.format("%s - %s:%s", userName, ClientSessionManager.getDataStoreName(),
+ ClientSessionManager.getDataStoreLoginName());
+ } catch (Exception ex) {
+ OseeLog.log(Activator.class, Level.SEVERE, ex);
+ return "Exception: " + ex.getLocalizedMessage();
+ }
+ }
+
+ private void addExtensionPointListenerBecauseOfWorkspaceLoading() {
+ IExtensionRegistry extensionRegistry = Platform.getExtensionRegistry();
+ extensionRegistry.addListener(new IRegistryEventListener() {
+ @Override
+ public void added(IExtension[] extensions) {
+ refresh();
+ }
+
+ @Override
+ public void added(IExtensionPoint[] extensionPoints) {
+ refresh();
+ }
+
+ @Override
+ public void removed(IExtension[] extensions) {
+ refresh();
+ }
+
+ @Override
+ public void removed(IExtensionPoint[] extensionPoints) {
+ refresh();
+ }
+ }, "org.eclipse.osee.coverage.CoverageNavigateItem");
+ }
+
+ protected void createActions() {
+ Action refreshAction = new Action("Refresh") {
+
+ @Override
+ public void run() {
+ xNavComp.refresh();
+ }
+ };
+ refreshAction.setImageDescriptor(ImageManager.getImageDescriptor(PluginUiImage.REFRESH));
+ refreshAction.setToolTipText("Refresh");
+ getViewSite().getActionBars().getMenuManager().add(refreshAction);
+
+ OseeUiActions.addBugToViewToolbar(this, this, Activator.getInstance(), VIEW_ID, "Coverage Navigator");
+
+ }
+
+ public String getActionDescription() {
+ IStructuredSelection sel = (IStructuredSelection) xNavComp.getFilteredTree().getViewer().getSelection();
+ if (sel.iterator().hasNext()) {
+ return String.format("Currently Selected - %s", ((XNavigateItem) sel.iterator().next()).getName());
+ }
+ return "";
+ }
+
+ public void refresh() {
+ Displays.ensureInDisplayThread(new Runnable() {
+
+ @Override
+ public void run() {
+ xNavComp.refresh();
+ }
+ });
+ }
}
\ No newline at end of file diff --git a/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/operations/FindTraceUnitFromResource.java b/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/operations/FindTraceUnitFromResource.java index 5555dc3f5c4..e86218dc071 100644 --- a/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/operations/FindTraceUnitFromResource.java +++ b/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/operations/FindTraceUnitFromResource.java @@ -34,103 +34,106 @@ import org.eclipse.osee.framework.skynet.core.artifact.search.ArtifactQuery; import org.eclipse.osee.framework.ui.plugin.util.AWorkbench;
import org.eclipse.osee.framework.ui.skynet.artifact.editor.ArtifactEditor;
import org.eclipse.osee.framework.ui.skynet.artifact.editor.ArtifactEditorInput;
-import org.eclipse.swt.widgets.Display;
+import org.eclipse.osee.framework.ui.swt.Displays;
/**
* @author Roberto E. Escobar
*/
public class FindTraceUnitFromResource {
- private FindTraceUnitFromResource() {
- }
+ private FindTraceUnitFromResource() {
+ }
- private static HashCollection<String, String> toIdentifiers(IResource... resources) {
- HashCollection<String, String> toReturn = new HashCollection<String, String>(false, HashSet.class);
- if (resources != null && resources.length > 0) {
- try {
- Collection<ITraceUnitResourceLocator> locators =
- TraceUnitExtensionManager.getInstance().getAllTraceUnitLocators();
- for (IResource resource : resources) {
- resourceToId(toReturn, resource, locators);
- }
- } catch (Exception ex) {
- OseeLog.log(DefinePlugin.class, Level.SEVERE, ex);
- }
- }
- return toReturn;
- }
+ private static HashCollection<String, String> toIdentifiers(IResource... resources) {
+ HashCollection<String, String> toReturn = new HashCollection<String, String>(false, HashSet.class);
+ if (resources != null && resources.length > 0) {
+ try {
+ Collection<ITraceUnitResourceLocator> locators =
+ TraceUnitExtensionManager.getInstance().getAllTraceUnitLocators();
+ for (IResource resource : resources) {
+ resourceToId(toReturn, resource, locators);
+ }
+ } catch (Exception ex) {
+ OseeLog.log(DefinePlugin.class, Level.SEVERE, ex);
+ }
+ }
+ return toReturn;
+ }
- private static void resourceToId(HashCollection<String, String> idStore, IResource resource, Collection<ITraceUnitResourceLocator> locators) {
- try {
- IFileStore fileStore = EFS.getStore(resource.getLocationURI());
- for (ITraceUnitResourceLocator locator : locators) {
- if (locator.isValidFile(fileStore)) {
- InputStream inputStream = null;
- try {
- inputStream = fileStore.openInputStream(EFS.NONE, new NullProgressMonitor());
- CharBuffer buffer = Lib.inputStreamToCharBuffer(inputStream);
- String identifier = locator.getIdentifier(fileStore, buffer);
- String traceType = locator.getTraceUnitType(identifier, buffer);
- idStore.put(traceType, identifier);
- } catch (Exception ex) {
- OseeLog.log(DefinePlugin.class, Level.SEVERE, ex);
- } finally {
- if (inputStream != null) {
- try {
- inputStream.close();
- } catch (Exception ex) {
- // do nothing
- }
- }
- }
- }
- }
- } catch (Exception ex) {
- OseeLog.log(DefinePlugin.class, Level.SEVERE, ex);
- }
- }
+ private static void resourceToId(HashCollection<String, String> idStore, IResource resource, Collection<ITraceUnitResourceLocator> locators) {
+ try {
+ IFileStore fileStore = EFS.getStore(resource.getLocationURI());
+ for (ITraceUnitResourceLocator locator : locators) {
+ if (locator.isValidFile(fileStore)) {
+ InputStream inputStream = null;
+ try {
+ inputStream = fileStore.openInputStream(EFS.NONE, new NullProgressMonitor());
+ CharBuffer buffer = Lib.inputStreamToCharBuffer(inputStream);
+ String identifier = locator.getIdentifier(fileStore, buffer);
+ String traceType = locator.getTraceUnitType(identifier, buffer);
+ idStore.put(traceType, identifier);
+ } catch (Exception ex) {
+ OseeLog.log(DefinePlugin.class, Level.SEVERE, ex);
+ } finally {
+ if (inputStream != null) {
+ try {
+ inputStream.close();
+ } catch (Exception ex) {
+ // do nothing
+ }
+ }
+ }
+ }
+ }
+ } catch (Exception ex) {
+ OseeLog.log(DefinePlugin.class, Level.SEVERE, ex);
+ }
+ }
- public static void search(Branch branch, IResource... resources) {
- HashCollection<String, String> typeAndIds = toIdentifiers(resources);
- if (!typeAndIds.isEmpty()) {
- Set<Artifact> artifacts = new HashSet<Artifact>();
- for (String artifactTypeName : typeAndIds.keySet()) {
- Collection<String> items = typeAndIds.getValues(artifactTypeName);
- if (items != null) {
- for (String artifactName : items) {
- try {
- artifacts.addAll(ArtifactQuery.getArtifactListFromTypeAndName(artifactTypeName, artifactName, branch));
- } catch (OseeCoreException ex) {
- OseeLog.log(DefinePlugin.class, Level.SEVERE, ex);
- }
- }
- }
- }
+ public static void search(Branch branch, IResource... resources) {
+ HashCollection<String, String> typeAndIds = toIdentifiers(resources);
+ if (!typeAndIds.isEmpty()) {
+ Set<Artifact> artifacts = new HashSet<Artifact>();
+ for (String artifactTypeName : typeAndIds.keySet()) {
+ Collection<String> items = typeAndIds.getValues(artifactTypeName);
+ if (items != null) {
+ for (String artifactName : items) {
+ try {
+ artifacts.addAll(ArtifactQuery.getArtifactListFromTypeAndName(artifactTypeName, artifactName,
+ branch));
+ } catch (OseeCoreException ex) {
+ OseeLog.log(DefinePlugin.class, Level.SEVERE, ex);
+ }
+ }
+ }
+ }
- if (!artifacts.isEmpty()) {
- openArtifacts(artifacts);
- } else {
- AWorkbench.popup("Find Trace Unit from Resource", String.format("Unable to find trace for: %s",
- Arrays.deepToString(resources)));
- }
- } else {
- AWorkbench.popup("Find Trace Unit from Resource", String.format("Unable to find trace handler for: %s",
- Arrays.deepToString(resources)));
- }
- }
+ if (!artifacts.isEmpty()) {
+ openArtifacts(artifacts);
+ } else {
+ AWorkbench.popup("Find Trace Unit from Resource",
+ String.format("Unable to find trace for: %s", Arrays.deepToString(resources)));
+ }
+ } else {
+ AWorkbench.popup("Find Trace Unit from Resource",
+ String.format("Unable to find trace handler for: %s", Arrays.deepToString(resources)));
+ }
+ }
- private static void openArtifacts(final Collection<Artifact> artifacts) {
- Display.getDefault().asyncExec(new Runnable() {
- public void run() {
- try {
- for (Artifact artifact : artifacts) {
- AWorkbench.getActivePage().openEditor(new ArtifactEditorInput(artifact), ArtifactEditor.EDITOR_ID,
- true);
- }
- } catch (Exception ex) {
- OseeLog.log(DefinePlugin.class, Level.SEVERE, ex);
- }
- }
- });
- }
+ private static void openArtifacts(final Collection<Artifact> artifacts) {
+ Displays.ensureInDisplayThread(new Runnable() {
+
+ @Override
+ public void run() {
+ try {
+ for (Artifact artifact : artifacts) {
+ AWorkbench.getActivePage().openEditor(new ArtifactEditorInput(artifact), ArtifactEditor.EDITOR_ID,
+ true);
+ }
+ } catch (Exception ex) {
+ OseeLog.log(DefinePlugin.class, Level.SEVERE, ex);
+ }
+ }
+ });
+ }
}
diff --git a/plugins/org.eclipse.osee.framework.ui.admin/src/org/eclipse/osee/framework/ui/admin/dbtabletab/DbTableTab.java b/plugins/org.eclipse.osee.framework.ui.admin/src/org/eclipse/osee/framework/ui/admin/dbtabletab/DbTableTab.java index feb69192faf..dc8b46b3ecf 100644 --- a/plugins/org.eclipse.osee.framework.ui.admin/src/org/eclipse/osee/framework/ui/admin/dbtabletab/DbTableTab.java +++ b/plugins/org.eclipse.osee.framework.ui.admin/src/org/eclipse/osee/framework/ui/admin/dbtabletab/DbTableTab.java @@ -18,6 +18,7 @@ import org.eclipse.osee.framework.skynet.core.User; import org.eclipse.osee.framework.ui.admin.AdminPlugin; import org.eclipse.osee.framework.ui.admin.AdminView; import org.eclipse.osee.framework.ui.skynet.widgets.XCombo; +import org.eclipse.osee.framework.ui.swt.Displays; import org.eclipse.swt.SWT; import org.eclipse.swt.browser.Browser; import org.eclipse.swt.events.ModifyEvent; @@ -28,163 +29,185 @@ import org.eclipse.swt.graphics.Cursor; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.Listener; import org.eclipse.swt.widgets.TabFolder; import org.eclipse.swt.widgets.TabItem; public class DbTableTab { - protected Browser browser; - public static final String VIEW_ID = "org.eclipse.osee.framework.ui.admin.AdminView"; - public static User person; - public static DbTableViewer dbTableViewer; - private static XCombo filterCombo; - private Label readOnlyLabel, addRecordLabel, publishLabel; - private ArrayList<DbItem> dbItems; - private Cursor handCursor; - private boolean noListener = true; - private Composite parent; - - public DbTableTab(TabFolder tabFolder) { - super(); - - dbItems = new ArrayList<DbItem>(); - dbItems.add(new SiteGssflRpcr()); - dbItems.add(new OseeInfoDbItem()); - handCursor = new Cursor(null, SWT.CURSOR_HAND); - - TabItem dbTab = new TabItem(tabFolder, SWT.NULL); - dbTab.setText("Database"); - - // Filter Composite - int numColumns = 5; - Composite c = new Composite(tabFolder, SWT.NONE); - c.setLayout(new GridLayout(numColumns, false)); - c.setLayoutData(new GridData()); - - c.setLayoutData(new GridData(GridData.FILL_BOTH)); - this.parent = c; - - filterCombo = new XCombo("DB Table", ""); - filterCombo.setDataStrings(getDbTableNames()); - filterCombo.createWidgets(c, 2); - filterCombo.addModifyListener(new ModifyListener() { - - public void modifyText(ModifyEvent e) { - try { - handleTableSelect(); - } catch (OseeDataStoreException ex) { - OseeLog.log(AdminPlugin.class, Level.SEVERE, ex); - } - AdminView.setSaveNeeded(false); - } - }); - - readOnlyLabel = new Label(c, SWT.NONE); - readOnlyLabel.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_RED)); - - addRecordLabel = new Label(c, SWT.NONE); - addRecordLabel.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_BLUE)); - addRecordLabel.addMouseTrackListener(new MouseTrackListener() { - - public void mouseEnter(MouseEvent e) { - if (getSelectedDbItem() != null && getSelectedDbItem().isWriteAccess()) if (addRecordLabel != null) addRecordLabel.setCursor(handCursor); - } - - public void mouseExit(MouseEvent e) { - if (addRecordLabel != null) addRecordLabel.setCursor(null); - }; - - public void mouseHover(MouseEvent e) { - } - }); - - publishLabel = new Label(c, SWT.NONE); - publishLabel.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_BLUE)); - publishLabel.addMouseTrackListener(new MouseTrackListener() { - - public void mouseEnter(MouseEvent e) { - if (getSelectedDbItem() != null && getSelectedDbItem().isWriteAccess()) if (publishLabel != null) publishLabel.setCursor(handCursor); - } - - public void mouseExit(MouseEvent e) { - if (publishLabel != null) publishLabel.setCursor(null); - }; - - public void mouseHover(MouseEvent e) { - } - }); - - updateReadOnly(); - dbTab.setControl(c); - } - - Listener addRecordListener = new Listener() { - public void handleEvent(org.eclipse.swt.widgets.Event event) { - System.out.println("I am adding a row..."); - handleAddRecord(); - }; - }; - - public void handleAddRecord() { - System.out.println("trying to add a record"); - dbTableViewer.addRecord(); - } - - public void updateReadOnly() { - DbItem selItem = getSelectedDbItem(); - if (selItem == null) { - readOnlyLabel.setText(""); - addRecordLabel.setText(" "); - } else if (selItem.isWriteAccess()) { - readOnlyLabel.setText(" WRITE ACCESS"); - addRecordLabel.setText(" Add Record "); - - if (noListener) addRecordLabel.addListener(SWT.MouseUp, addRecordListener); - noListener = false; - } else { - readOnlyLabel.setText(" READ ONLY ACCESS"); - addRecordLabel.setText(" "); - addRecordLabel.removeListener(SWT.MouseUp, addRecordListener); - } - } - - public DbItem getSelectedDbItem() { - for (DbItem d : dbItems) { - if (filterCombo.get().equals(d.getTableName())) return d; - } - return null; - } - - public void handleTableSelect() throws OseeDataStoreException { - if (dbTableViewer != null) dbTableViewer.dispose(); - updateReadOnly(); - if (filterCombo.get().equals("")) return; - - dbTableViewer = new DbTableViewer(parent, 5, this, getSelectedDbItem()); - dbTableViewer.load(); - parent.layout(); - } - - public static void refresh() throws OseeDataStoreException { - if (filterCombo.get().equals("")) return; - if (dbTableViewer != null) { - dbTableViewer.load(); - dbTableViewer.refresh(); - } - } - - public XCombo getFilterCombo() { - return filterCombo; - } - - public String[] getDbTableNames() { - String names[] = new String[dbItems.size()]; - for (int x = 0; x < dbItems.size(); x++) { - names[x] = dbItems.get(x).getTableName(); - } - return names; - } + protected Browser browser; + public static final String VIEW_ID = "org.eclipse.osee.framework.ui.admin.AdminView"; + public static User person; + public static DbTableViewer dbTableViewer; + private static XCombo filterCombo; + private final Label readOnlyLabel, addRecordLabel, publishLabel; + private final ArrayList<DbItem> dbItems; + private final Cursor handCursor; + private boolean noListener = true; + private final Composite parent; + + public DbTableTab(TabFolder tabFolder) { + super(); + + dbItems = new ArrayList<DbItem>(); + dbItems.add(new SiteGssflRpcr()); + dbItems.add(new OseeInfoDbItem()); + handCursor = new Cursor(null, SWT.CURSOR_HAND); + + TabItem dbTab = new TabItem(tabFolder, SWT.NULL); + dbTab.setText("Database"); + + // Filter Composite + int numColumns = 5; + Composite c = new Composite(tabFolder, SWT.NONE); + c.setLayout(new GridLayout(numColumns, false)); + c.setLayoutData(new GridData()); + + c.setLayoutData(new GridData(GridData.FILL_BOTH)); + this.parent = c; + + filterCombo = new XCombo("DB Table", ""); + filterCombo.setDataStrings(getDbTableNames()); + filterCombo.createWidgets(c, 2); + filterCombo.addModifyListener(new ModifyListener() { + + public void modifyText(ModifyEvent e) { + try { + handleTableSelect(); + } catch (OseeDataStoreException ex) { + OseeLog.log(AdminPlugin.class, Level.SEVERE, ex); + } + AdminView.setSaveNeeded(false); + } + }); + + readOnlyLabel = new Label(c, SWT.NONE); + readOnlyLabel.setForeground(Displays.getSystemColor(SWT.COLOR_RED)); + + addRecordLabel = new Label(c, SWT.NONE); + addRecordLabel.setForeground(Displays.getSystemColor(SWT.COLOR_BLUE)); + addRecordLabel.addMouseTrackListener(new MouseTrackListener() { + + public void mouseEnter(MouseEvent e) { + if (getSelectedDbItem() != null && getSelectedDbItem().isWriteAccess()) { + if (addRecordLabel != null) { + addRecordLabel.setCursor(handCursor); + } + } + } + + public void mouseExit(MouseEvent e) { + if (addRecordLabel != null) { + addRecordLabel.setCursor(null); + } + }; + + public void mouseHover(MouseEvent e) { + } + }); + + publishLabel = new Label(c, SWT.NONE); + publishLabel.setForeground(Displays.getSystemColor(SWT.COLOR_BLUE)); + publishLabel.addMouseTrackListener(new MouseTrackListener() { + + @Override + public void mouseEnter(MouseEvent e) { + if (getSelectedDbItem() != null && getSelectedDbItem().isWriteAccess()) { + if (publishLabel != null) { + publishLabel.setCursor(handCursor); + } + } + } + + public void mouseExit(MouseEvent e) { + if (publishLabel != null) { + publishLabel.setCursor(null); + } + }; + + public void mouseHover(MouseEvent e) { + } + }); + + updateReadOnly(); + dbTab.setControl(c); + } + + Listener addRecordListener = new Listener() { + public void handleEvent(org.eclipse.swt.widgets.Event event) { + System.out.println("I am adding a row..."); + handleAddRecord(); + }; + }; + + public void handleAddRecord() { + System.out.println("trying to add a record"); + dbTableViewer.addRecord(); + } + + public void updateReadOnly() { + DbItem selItem = getSelectedDbItem(); + if (selItem == null) { + readOnlyLabel.setText(""); + addRecordLabel.setText(" "); + } else if (selItem.isWriteAccess()) { + readOnlyLabel.setText(" WRITE ACCESS"); + addRecordLabel.setText(" Add Record "); + + if (noListener) { + addRecordLabel.addListener(SWT.MouseUp, addRecordListener); + } + noListener = false; + } else { + readOnlyLabel.setText(" READ ONLY ACCESS"); + addRecordLabel.setText(" "); + addRecordLabel.removeListener(SWT.MouseUp, addRecordListener); + } + } + + public DbItem getSelectedDbItem() { + for (DbItem d : dbItems) { + if (filterCombo.get().equals(d.getTableName())) { + return d; + } + } + return null; + } + + public void handleTableSelect() throws OseeDataStoreException { + if (dbTableViewer != null) { + dbTableViewer.dispose(); + } + updateReadOnly(); + if (filterCombo.get().equals("")) { + return; + } + + dbTableViewer = new DbTableViewer(parent, 5, this, getSelectedDbItem()); + dbTableViewer.load(); + parent.layout(); + } + + public static void refresh() throws OseeDataStoreException { + if (filterCombo.get().equals("")) { + return; + } + if (dbTableViewer != null) { + dbTableViewer.load(); + dbTableViewer.refresh(); + } + } + + public XCombo getFilterCombo() { + return filterCombo; + } + + public String[] getDbTableNames() { + String names[] = new String[dbItems.size()]; + for (int x = 0; x < dbItems.size(); x++) { + names[x] = dbItems.get(x).getTableName(); + } + return names; + } } 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);
+ }
+ }
}
diff --git a/plugins/org.eclipse.osee.framework.ui.data.model.editor/src/org/eclipse/osee/framework/ui/data/model/editor/core/ODMPaletteFactory.java b/plugins/org.eclipse.osee.framework.ui.data.model.editor/src/org/eclipse/osee/framework/ui/data/model/editor/core/ODMPaletteFactory.java index 3d7b40e8134..e377706cf68 100644 --- a/plugins/org.eclipse.osee.framework.ui.data.model.editor/src/org/eclipse/osee/framework/ui/data/model/editor/core/ODMPaletteFactory.java +++ b/plugins/org.eclipse.osee.framework.ui.data.model.editor/src/org/eclipse/osee/framework/ui/data/model/editor/core/ODMPaletteFactory.java @@ -43,160 +43,161 @@ import org.eclipse.osee.framework.ui.swt.ImageManager; */
public class ODMPaletteFactory {
- private final static String DATA_TYPE_TIP_FORMAT = "Add [%s] %s type to %s";
- private final ODMEditor editor;
- private PaletteRoot paletteRoot;
-
- private enum DrawerEnum {
- Artifact_Types,
- Attribute_Types,
- Relation_Types;
-
- public String asLabel() {
- return this.name().replaceAll("_", " ");
- }
- }
-
- private final Map<DrawerEnum, PaletteContainer> containers;
-
- public ODMPaletteFactory(ODMEditor editor) {
- this.containers = new LinkedHashMap<DrawerEnum, PaletteContainer>();
- this.editor = editor;
- }
-
- private void updateDrawers() {
- if (editor.getEditorInput() == null) {
- return;
- }
- DataTypeCache dataTypeCache = editor.getEditorInput().getDataTypeCache();
-
- for (DrawerEnum drawerType : DrawerEnum.values()) {
- PaletteContainer container = containers.get(drawerType);
- if (container == null) {
- container = new PaletteDrawer(drawerType.asLabel());
- containers.put(drawerType, container);
- getPaletteRoot().add(container);
- } else {
- for (Object child : container.getChildren()) {
- container.remove((PaletteEntry) child);
- }
- }
- container.addAll(getToolEntries(drawerType, dataTypeCache));
- }
- }
-
- private List<CombinedTemplateCreationEntry> getToolEntries(DrawerEnum drawerType, DataTypeCache dataTypeCache) {
- List<CombinedTemplateCreationEntry> toReturn = new ArrayList<CombinedTemplateCreationEntry>();
- ImageDescriptor image = null;
- String message = null;
- for (String sourceId : dataTypeCache.getDataTypeSourceIds()) {
- DataTypeSource dataTypeSource = dataTypeCache.getDataTypeSourceById(sourceId);
- switch (drawerType) {
- case Artifact_Types:
- for (ArtifactDataType dataType : dataTypeSource.getArtifactTypeManager().getAllSorted()) {
- image = ImageDescriptor.createFromImage(dataType.getImage());
- message = String.format(DATA_TYPE_TIP_FORMAT, dataType.getName(), "artifact", "the diagram");
- toReturn.add(createDataTypeToolEntry(dataType, image, message));
- }
- break;
- case Attribute_Types:
- image = ImageManager.getImageDescriptor(ODMImage.LOCAL_ATTRIBUTE);
- for (AttributeDataType dataType : dataTypeSource.getAttributeTypeManager().getAllSorted()) {
- message = String.format(DATA_TYPE_TIP_FORMAT, dataType.getName(), "attribute", "an artifact type");
- toReturn.add(createDataTypeToolEntry(dataType, image, message));
- }
- break;
- case Relation_Types:
- image = ImageManager.getImageDescriptor(ODMImage.LOCAL_RELATION);
- for (RelationDataType dataType : dataTypeSource.getRelationTypeManager().getAllSorted()) {
- message = String.format(DATA_TYPE_TIP_FORMAT, dataType.getName(), "relation", "an artifact type");
- toReturn.add(createDataTypeToolEntry(dataType, image, message));
- }
- break;
- default:
- break;
- }
- }
- return toReturn;
- }
-
- private CombinedTemplateCreationEntry createDataTypeToolEntry(final DataType dataType, ImageDescriptor imageDescriptor, String message) {
- CreationFactory factory = new CreationFactory() {
-
- @Override
- public Object getNewObject() {
- return dataType;
- }
-
- @Override
- public Object getObjectType() {
- return null;
- }
-
- };
- return new CombinedTemplateCreationEntry(dataType.getName(), message, factory, factory, imageDescriptor,
- imageDescriptor);
- }
-
- private PaletteContainer createToolsGroup(PaletteRoot palette) {
- PaletteToolbar toolbar = new PaletteToolbar("Tools");
-
- ToolEntry tool = new PanningSelectionToolEntry();
- toolbar.add(tool);
- palette.setDefaultEntry(tool);
-
- toolbar.add(new MarqueeToolEntry());
- toolbar.add(new PaletteSeparator());
-
- ImageDescriptor img = ImageManager.getImageDescriptor(ODMImage.INHERITANCE);
- toolbar.add(new ConnectionCreationToolEntry("Inheritance", "Inherit from an artifact", new SimpleFactory(
- InheritanceLinkModel.class), img, img));
-
- // final Action action =
- // OseeAts.createBugAction(ODMEditorActivator.getInstance(), editor, "OSEE Data Model Editor",
- // ODMEditor.EDITOR_ID);
- // 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;
- }
-
- public void updatePaletteRoot() {
- updateDrawers();
- }
-
- public PaletteRoot getPaletteRoot() {
- if (paletteRoot == null) {
- paletteRoot = new PaletteRoot();
- paletteRoot.add(createToolsGroup(paletteRoot));
- updateDrawers();
- }
- return paletteRoot;
- }
+ private final static String DATA_TYPE_TIP_FORMAT = "Add [%s] %s type to %s";
+ private final ODMEditor editor;
+ private PaletteRoot paletteRoot;
+
+ private enum DrawerEnum {
+ Artifact_Types,
+ Attribute_Types,
+ Relation_Types;
+
+ public String asLabel() {
+ return this.name().replaceAll("_", " ");
+ }
+ }
+
+ private final Map<DrawerEnum, PaletteContainer> containers;
+
+ public ODMPaletteFactory(ODMEditor editor) {
+ this.containers = new LinkedHashMap<DrawerEnum, PaletteContainer>();
+ this.editor = editor;
+ }
+
+ private void updateDrawers() {
+ if (editor.getEditorInput() == null) {
+ return;
+ }
+ DataTypeCache dataTypeCache = editor.getEditorInput().getDataTypeCache();
+
+ for (DrawerEnum drawerType : DrawerEnum.values()) {
+ PaletteContainer container = containers.get(drawerType);
+ if (container == null) {
+ container = new PaletteDrawer(drawerType.asLabel());
+ containers.put(drawerType, container);
+ getPaletteRoot().add(container);
+ } else {
+ for (Object child : container.getChildren()) {
+ container.remove((PaletteEntry) child);
+ }
+ }
+ container.addAll(getToolEntries(drawerType, dataTypeCache));
+ }
+ }
+
+ private List<CombinedTemplateCreationEntry> getToolEntries(DrawerEnum drawerType, DataTypeCache dataTypeCache) {
+ List<CombinedTemplateCreationEntry> toReturn = new ArrayList<CombinedTemplateCreationEntry>();
+ ImageDescriptor image = null;
+ String message = null;
+ for (String sourceId : dataTypeCache.getDataTypeSourceIds()) {
+ DataTypeSource dataTypeSource = dataTypeCache.getDataTypeSourceById(sourceId);
+ switch (drawerType) {
+ case Artifact_Types:
+ for (ArtifactDataType dataType : dataTypeSource.getArtifactTypeManager().getAllSorted()) {
+ image = ImageDescriptor.createFromImage(dataType.getImage());
+ message = String.format(DATA_TYPE_TIP_FORMAT, dataType.getName(), "artifact", "the diagram");
+ toReturn.add(createDataTypeToolEntry(dataType, image, message));
+ }
+ break;
+ case Attribute_Types:
+ image = ImageManager.getImageDescriptor(ODMImage.LOCAL_ATTRIBUTE);
+ for (AttributeDataType dataType : dataTypeSource.getAttributeTypeManager().getAllSorted()) {
+ message = String.format(DATA_TYPE_TIP_FORMAT, dataType.getName(), "attribute", "an artifact type");
+ toReturn.add(createDataTypeToolEntry(dataType, image, message));
+ }
+ break;
+ case Relation_Types:
+ image = ImageManager.getImageDescriptor(ODMImage.LOCAL_RELATION);
+ for (RelationDataType dataType : dataTypeSource.getRelationTypeManager().getAllSorted()) {
+ message = String.format(DATA_TYPE_TIP_FORMAT, dataType.getName(), "relation", "an artifact type");
+ toReturn.add(createDataTypeToolEntry(dataType, image, message));
+ }
+ break;
+ default:
+ break;
+ }
+ }
+ return toReturn;
+ }
+
+ private CombinedTemplateCreationEntry createDataTypeToolEntry(final DataType dataType, ImageDescriptor imageDescriptor, String message) {
+ CreationFactory factory = new CreationFactory() {
+
+ @Override
+ public Object getNewObject() {
+ return dataType;
+ }
+
+ @Override
+ public Object getObjectType() {
+ return null;
+ }
+
+ };
+ return new CombinedTemplateCreationEntry(dataType.getName(), message, factory, factory, imageDescriptor,
+ imageDescriptor);
+ }
+
+ private PaletteContainer createToolsGroup(PaletteRoot palette) {
+ PaletteToolbar toolbar = new PaletteToolbar("Tools");
+
+ ToolEntry tool = new PanningSelectionToolEntry();
+ toolbar.add(tool);
+ palette.setDefaultEntry(tool);
+
+ toolbar.add(new MarqueeToolEntry());
+ toolbar.add(new PaletteSeparator());
+
+ ImageDescriptor img = ImageManager.getImageDescriptor(ODMImage.INHERITANCE);
+ toolbar.add(new ConnectionCreationToolEntry("Inheritance", "Inherit from an artifact", new SimpleFactory(
+ InheritanceLinkModel.class), img, img));
+
+ // final Action action =
+ // OseeAts.createBugAction(ODMEditorActivator.getInstance(), editor, "OSEE Data Model Editor",
+ // ODMEditor.EDITOR_ID);
+ // 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;
+ }
+
+ public void updatePaletteRoot() {
+ updateDrawers();
+ }
+
+ public PaletteRoot getPaletteRoot() {
+ if (paletteRoot == null) {
+ paletteRoot = new PaletteRoot();
+ paletteRoot.add(createToolsGroup(paletteRoot));
+ updateDrawers();
+ }
+ return paletteRoot;
+ }
}
diff --git a/plugins/org.eclipse.osee.framework.ui.data.model.editor/src/org/eclipse/osee/framework/ui/data/model/editor/operation/ODMLoadGraphRunnable.java b/plugins/org.eclipse.osee.framework.ui.data.model.editor/src/org/eclipse/osee/framework/ui/data/model/editor/operation/ODMLoadGraphRunnable.java index 025371b6da8..e82eea0d8f4 100644 --- a/plugins/org.eclipse.osee.framework.ui.data.model.editor/src/org/eclipse/osee/framework/ui/data/model/editor/operation/ODMLoadGraphRunnable.java +++ b/plugins/org.eclipse.osee.framework.ui.data.model.editor/src/org/eclipse/osee/framework/ui/data/model/editor/operation/ODMLoadGraphRunnable.java @@ -23,56 +23,57 @@ import org.eclipse.osee.framework.ui.data.model.editor.model.DataTypeCache; import org.eclipse.osee.framework.ui.data.model.editor.model.DataTypeSource;
import org.eclipse.osee.framework.ui.data.model.editor.model.ODMDiagram;
import org.eclipse.osee.framework.ui.data.model.editor.utility.ODMConstants;
-import org.eclipse.swt.widgets.Display;
+import org.eclipse.osee.framework.ui.swt.Displays;
/**
* @author Roberto E. Escobar
*/
public class ODMLoadGraphRunnable implements IExceptionableRunnable {
- private GraphicalViewer viewer;
- private ODMEditor editor;
- private ODMEditorInput input;
+ private final GraphicalViewer viewer;
+ private final ODMEditor editor;
+ private final ODMEditorInput input;
- public ODMLoadGraphRunnable(GraphicalViewer viewer, ODMEditor editor, ODMEditorInput input) {
- super();
- this.viewer = viewer;
- this.editor = editor;
- this.input = input;
- }
+ public ODMLoadGraphRunnable(GraphicalViewer viewer, ODMEditor editor, ODMEditorInput input) {
+ super();
+ this.viewer = viewer;
+ this.editor = editor;
+ this.input = input;
+ }
- public String getName() {
- return "Loading Osee Data Type Graph";
- }
+ public String getName() {
+ return "Loading Osee Data Type Graph";
+ }
- @Override
- public IStatus run(IProgressMonitor monitor) throws Exception {
- monitor.beginTask(getName(), ODMConstants.TOTAL_STEPS);
- monitor.worked(ODMConstants.SHORT_TASK_STEPS);
- monitor.setTaskName("Initializating cache");
- DataTypeCache dataTypeCache = input.getDataTypeCache();
- dataTypeCache.clear();
- monitor.worked(ODMConstants.SHORT_TASK_STEPS);
+ @Override
+ public IStatus run(IProgressMonitor monitor) throws Exception {
+ monitor.beginTask(getName(), ODMConstants.TOTAL_STEPS);
+ monitor.worked(ODMConstants.SHORT_TASK_STEPS);
+ monitor.setTaskName("Initializating cache");
+ DataTypeCache dataTypeCache = input.getDataTypeCache();
+ dataTypeCache.clear();
+ monitor.worked(ODMConstants.SHORT_TASK_STEPS);
- OseeDataTypeFactory.addTypesFromDataStore(dataTypeCache);
- monitor.worked(ODMConstants.SHORT_TASK_STEPS);
+ OseeDataTypeFactory.addTypesFromDataStore(dataTypeCache);
+ monitor.worked(ODMConstants.SHORT_TASK_STEPS);
- IResource resource = input.getResource();
- if (resource != null) {
- DataTypeSource dataTypeSource = OseeDataTypeFactory.loadFromFile(resource.getFullPath());
- dataTypeCache.addDataTypeSource(dataTypeSource);
- }
- monitor.worked(ODMConstants.SHORT_TASK_STEPS);
+ IResource resource = input.getResource();
+ if (resource != null) {
+ DataTypeSource dataTypeSource = OseeDataTypeFactory.loadFromFile(resource.getFullPath());
+ dataTypeCache.addDataTypeSource(dataTypeSource);
+ }
+ monitor.worked(ODMConstants.SHORT_TASK_STEPS);
- if (editor != null) {
- monitor.setTaskName("Drawing graph");
- Display.getDefault().syncExec(new Runnable() {
- public void run() {
- viewer.setContents(new ODMDiagram(input.getDataTypeCache()));
- editor.updatePalette();
- }
- });
- }
- return Status.OK_STATUS;
- }
+ if (editor != null) {
+ monitor.setTaskName("Drawing graph");
+ Displays.ensureInDisplayThread(new Runnable() {
+ @Override
+ public void run() {
+ viewer.setContents(new ODMDiagram(input.getDataTypeCache()));
+ editor.updatePalette();
+ }
+ });
+ }
+ return Status.OK_STATUS;
+ }
}
diff --git a/plugins/org.eclipse.osee.framework.ui.plugin/src/org/eclipse/osee/framework/ui/plugin/io/StreamToTextArea.java b/plugins/org.eclipse.osee.framework.ui.plugin/src/org/eclipse/osee/framework/ui/plugin/io/StreamToTextArea.java index e9c58b2db65..7f2f72fbc88 100644 --- a/plugins/org.eclipse.osee.framework.ui.plugin/src/org/eclipse/osee/framework/ui/plugin/io/StreamToTextArea.java +++ b/plugins/org.eclipse.osee.framework.ui.plugin/src/org/eclipse/osee/framework/ui/plugin/io/StreamToTextArea.java @@ -15,57 +15,59 @@ import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; +import org.eclipse.osee.framework.ui.swt.Displays; import org.eclipse.osee.framework.ui.swt.FormattedText; import org.eclipse.swt.SWT; import org.eclipse.swt.custom.StyledText; -import org.eclipse.swt.widgets.Display; /** * @author Roberto E. Escobar */ public class StreamToTextArea extends Thread { - private InputStream is; - private String type; - private FormattedText textArea; - private StyledText styledText; - private int swtColor; - private boolean isStopped; + private final InputStream is; + private final String type; + private final FormattedText textArea; + private final StyledText styledText; + private int swtColor; + private boolean isStopped; - public StreamToTextArea(InputStream is, String type, FormattedText textArea) { - this.is = is; - this.type = type; - this.textArea = textArea; - this.styledText = textArea.getStyledText(); - this.isStopped = false; - } + public StreamToTextArea(InputStream is, String type, FormattedText textArea) { + this.is = is; + this.type = type; + this.textArea = textArea; + this.styledText = textArea.getStyledText(); + this.isStopped = false; + } - public void typeColor(int swtColor) { - this.swtColor = swtColor; - } + public void typeColor(int swtColor) { + this.swtColor = swtColor; + } - public void setStopped(boolean value) { - this.isStopped = value; - } + public void setStopped(boolean value) { + this.isStopped = value; + } - public void run() { - try { - BufferedReader br = new BufferedReader(new InputStreamReader(is)); - String line = null; - while (true != isStopped && null != textArea && true != textArea.getStyledText().isDisposed() && null != (line = - br.readLine())) { - final String toDisplay = line; - Display.getDefault().asyncExec(new Runnable() { - public void run() { - if (textArea != null && !textArea.getStyledText().isDisposed()) { - textArea.addText("\t" + type + "> ", SWT.NORMAL, swtColor); - textArea.addText(toDisplay + "\n"); - styledText.setSelection(styledText.getCharCount()); - } - } - }); - } - } catch (IOException ioe) { - ioe.printStackTrace(); - } - } + @Override + public void run() { + try { + BufferedReader br = new BufferedReader(new InputStreamReader(is)); + String line = null; + while (true != isStopped && null != textArea && true != textArea.getStyledText().isDisposed() && null != (line = + br.readLine())) { + final String toDisplay = line; + Displays.ensureInDisplayThread(new Runnable() { + @Override + public void run() { + if (textArea != null && !textArea.getStyledText().isDisposed()) { + textArea.addText("\t" + type + "> ", SWT.NORMAL, swtColor); + textArea.addText(toDisplay + "\n"); + styledText.setSelection(styledText.getCharCount()); + } + } + }); + } + } catch (IOException ioe) { + ioe.printStackTrace(); + } + } } diff --git a/plugins/org.eclipse.osee.framework.ui.plugin/src/org/eclipse/osee/framework/ui/plugin/util/Displays.java b/plugins/org.eclipse.osee.framework.ui.plugin/src/org/eclipse/osee/framework/ui/plugin/util/Displays.java deleted file mode 100644 index e3a52745e73..00000000000 --- a/plugins/org.eclipse.osee.framework.ui.plugin/src/org/eclipse/osee/framework/ui/plugin/util/Displays.java +++ /dev/null @@ -1,42 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2007 Boeing. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Boeing - initial API and implementation - *******************************************************************************/ -package org.eclipse.osee.framework.ui.plugin.util; - -import org.eclipse.swt.widgets.Display; - -/** - * @author Robert A. Fisher - */ -public class Displays { - - public static void ensureInDisplayThread(Runnable runnable) { - ensureInDisplayThread(runnable, false); - } - - public static void ensureInDisplayThread(Runnable runnable, boolean forcePend) { - if (isDisplayThread()) { - // No need to check for force since this will always pend - runnable.run(); - } else { - if (forcePend) { - Display.getDefault().syncExec(runnable); - } else { - Display.getDefault().asyncExec(runnable); - } - } - } - - public static boolean isDisplayThread() { - if (Display.getCurrent() == null) return false; - - return Display.getCurrent().getThread() == Thread.currentThread(); - } -} diff --git a/plugins/org.eclipse.osee.framework.ui.plugin/src/org/eclipse/osee/framework/ui/plugin/util/GetChildrenJob.java b/plugins/org.eclipse.osee.framework.ui.plugin/src/org/eclipse/osee/framework/ui/plugin/util/GetChildrenJob.java index e66c311727b..6864c61dfa1 100644 --- a/plugins/org.eclipse.osee.framework.ui.plugin/src/org/eclipse/osee/framework/ui/plugin/util/GetChildrenJob.java +++ b/plugins/org.eclipse.osee.framework.ui.plugin/src/org/eclipse/osee/framework/ui/plugin/util/GetChildrenJob.java @@ -18,6 +18,7 @@ import org.eclipse.core.runtime.jobs.Job; import org.eclipse.jface.viewers.Viewer; import org.eclipse.osee.framework.logging.OseeLog; import org.eclipse.osee.framework.ui.plugin.internal.OseePluginUiActivator; +import org.eclipse.osee.framework.ui.swt.Displays; import org.eclipse.osee.framework.ui.swt.IContentProviderRunnable; /** diff --git a/plugins/org.eclipse.osee.framework.ui.plugin/src/org/eclipse/osee/framework/ui/plugin/util/JobbedNode.java b/plugins/org.eclipse.osee.framework.ui.plugin/src/org/eclipse/osee/framework/ui/plugin/util/JobbedNode.java index d7c102e441c..db294bd7898 100644 --- a/plugins/org.eclipse.osee.framework.ui.plugin/src/org/eclipse/osee/framework/ui/plugin/util/JobbedNode.java +++ b/plugins/org.eclipse.osee.framework.ui.plugin/src/org/eclipse/osee/framework/ui/plugin/util/JobbedNode.java @@ -13,6 +13,7 @@ package org.eclipse.osee.framework.ui.plugin.util; import org.eclipse.jface.viewers.TreeViewer; import org.eclipse.jface.viewers.Viewer; import org.eclipse.osee.framework.plugin.core.util.Jobs; +import org.eclipse.osee.framework.ui.swt.Displays; import org.eclipse.osee.framework.ui.swt.IContentProviderRunnable; import org.eclipse.osee.framework.ui.swt.ITreeNode; import org.eclipse.osee.framework.ui.swt.TreeNode; diff --git a/plugins/org.eclipse.osee.framework.ui.plugin/src/org/eclipse/osee/framework/ui/plugin/util/OseeConsole.java b/plugins/org.eclipse.osee.framework.ui.plugin/src/org/eclipse/osee/framework/ui/plugin/util/OseeConsole.java index 24d2897baa0..488e0d3e2fa 100644 --- a/plugins/org.eclipse.osee.framework.ui.plugin/src/org/eclipse/osee/framework/ui/plugin/util/OseeConsole.java +++ b/plugins/org.eclipse.osee.framework.ui.plugin/src/org/eclipse/osee/framework/ui/plugin/util/OseeConsole.java @@ -22,9 +22,8 @@ import org.eclipse.osee.framework.jdk.core.util.IConsoleInputListener; import org.eclipse.osee.framework.jdk.core.util.Lib;
import org.eclipse.osee.framework.logging.OseeLog;
import org.eclipse.osee.framework.ui.plugin.internal.OseePluginUiActivator;
+import org.eclipse.osee.framework.ui.swt.Displays;
import org.eclipse.swt.SWT;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.console.ConsolePlugin;
import org.eclipse.ui.console.IConsole;
import org.eclipse.ui.console.IOConsole;
@@ -37,213 +36,214 @@ import org.eclipse.ui.console.IOConsoleOutputStream; * @author Donald G. Dunne
*/
public class OseeConsole {
- private IOConsoleOutputStream streamOut = null;
-
- private IOConsoleOutputStream streamErr = null;
-
- private IOConsoleOutputStream streamPrompt = null;
-
- private final IOConsole console;
-
- private final HandleInput inputHandler;
-
- private final boolean time;
-
- private final Thread thread;
-
- public OseeConsole(String title) {
- this(title, true);
- }
-
- private OseeConsole(String title, boolean time) {
- console = new IOConsole(title, null);
- this.time = time;
- this.inputHandler = new HandleInput();
-
- thread = new Thread(inputHandler);
- thread.setName("Osee console input handler");
- ConsolePlugin.getDefault().getConsoleManager().addConsoles(new IConsole[] {console});
- PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() {
- public void run() {
- streamOut = console.newOutputStream();// newMessageStream();
- streamOut.setColor(Display.getDefault().getSystemColor(SWT.COLOR_BLACK));
- streamOut.setActivateOnWrite(false);
- streamErr = console.newOutputStream();
- streamErr.setColor(Display.getDefault().getSystemColor(SWT.COLOR_RED));
- streamErr.setActivateOnWrite(false);
- streamPrompt = console.newOutputStream();
- streamPrompt.setColor(Display.getDefault().getSystemColor(SWT.COLOR_BLUE));
- streamPrompt.setActivateOnWrite(false);
- }
- });
- thread.start();
- }
-
- public PrintStream getPrintStream() {
- return new PrintStream(streamOut);
- }
-
- public void shutdown() {
- thread.interrupt();
- try {
- thread.join(5000);
- } catch (InterruptedException e) {
- e.printStackTrace();
- } finally {
- ConsolePlugin.getDefault().getConsoleManager().removeConsoles(new IConsole[] {console});
- }
- }
-
- public static final int CONSOLE_ERROR = 0;
-
- public static final int CONSOLE_OUT = 1;
-
- public static final int CONSOLE_PROMPT = 2;
-
- /**
- * Writes string to console without popping console forward
- *
- * @param str
- */
- public void write(String str) {
- write(str, false);
- }
-
- /**
- * Writes string to console without popping console forward
- *
- * @param str
- */
- public void writeError(String str) {
- write(str, CONSOLE_ERROR, true);
- }
-
- /**
- * Writes string to console
- *
- * @param str
- * @param popup bring console window forward
- */
- public void write(String str, boolean popup) {
- write(str, CONSOLE_OUT, popup);
- }
-
- /**
- * Write string to console
- *
- * @param str
- * @param type CONSOLE_ERROR, CONSOLE_OUT, CONSOLE_PROMPT
- */
- public void write(String str, int type) {
- write(str, type, false);
- }
-
- /**
- * Write string to console
- *
- * @param str
- * @param type CONSOLE_ERROR, CONSOLE_OUT, CONSOLE_PROMPT
- * @param popup bring console window forward
- */
- public void write(String str, int type, boolean popup) {
- String time = "";
- if (this.time) {
- Calendar cal = Calendar.getInstance();
- cal.setTime(new Date());
-
- if (cal.get(Calendar.HOUR) == 0) {
- time = "12";
- } else {
- time = "" + cal.get(Calendar.HOUR);
- }
- time = Lib.padLeading(time, '0', 2);
- String minute = "" + cal.get(Calendar.MINUTE);
- minute = Lib.padLeading(minute, '0', 2);
- time += ":" + minute + " => ";
- }
- try {
- sendToStreams(type, time);
- if (str.length() > 100000) {
- int i = 0;
-
- while (i < str.length()) {
- int endIndex = i + 100000;
- endIndex = endIndex > str.length() ? str.length() : endIndex;
- String chunk = str.substring(i, endIndex);
- sendToStreams(type, chunk);
- i = endIndex;
- }
- } else {
- sendToStreams(type, str);
- }
-
- sendToStreams(type, "\n");
- if (popup) {
- popup();
- }
- } catch (IOException ex) {
- ex.printStackTrace();
- }
- }
-
- public void prompt(String str) throws IOException {
- sendToStreams(CONSOLE_PROMPT, str);
- }
-
- private void sendToStreams(int type, String str) throws IOException {
- if (type == CONSOLE_ERROR && streamErr != null) {
- streamErr.write(str);
- }
- if (type == CONSOLE_PROMPT && streamPrompt != null) {
- streamPrompt.write(str);
- }
- if (type == CONSOLE_OUT && streamOut != null) {
- streamOut.write(str);
- }
- }
-
- public void popup() {
- ConsolePlugin.getDefault().getConsoleManager().showConsoleView(console);
- }
-
- public void addInputListener(IConsoleInputListener listener) {
- inputHandler.addListener(listener);
- }
-
- public void removeInputListener(IConsoleInputListener listener) {
- inputHandler.removeListener(listener);
- }
-
- private class HandleInput implements Runnable {
-
- private final CopyOnWriteArrayList<IConsoleInputListener> listeners;
-
- public HandleInput() {
- listeners = new CopyOnWriteArrayList<IConsoleInputListener>();
- }
-
- public void addListener(IConsoleInputListener listener) {
- listeners.add(listener);
- }
-
- public void removeListener(IConsoleInputListener listener) {
- listeners.remove(listener);
- }
-
- public void run() {
- BufferedReader input = new BufferedReader(new InputStreamReader(console.getInputStream()));
- try {
- String line = null;
- while ((line = input.readLine()) != null) {
- for (IConsoleInputListener listener : listeners) {
- listener.lineRead(line);
- }
- }
- } catch (IOException e) {
- e.printStackTrace();
- }
- OseeLog.log(OseePluginUiActivator.class, Level.INFO, "done with the handling of input");
- }
-
- }
+ private IOConsoleOutputStream streamOut = null;
+
+ private IOConsoleOutputStream streamErr = null;
+
+ private IOConsoleOutputStream streamPrompt = null;
+
+ private final IOConsole console;
+
+ private final HandleInput inputHandler;
+
+ private final boolean time;
+
+ private final Thread thread;
+
+ public OseeConsole(String title) {
+ this(title, true);
+ }
+
+ private OseeConsole(String title, boolean time) {
+ console = new IOConsole(title, null);
+ this.time = time;
+ this.inputHandler = new HandleInput();
+
+ thread = new Thread(inputHandler);
+ thread.setName("Osee console input handler");
+ ConsolePlugin.getDefault().getConsoleManager().addConsoles(new IConsole[] {console});
+ Displays.ensureInDisplayThread(new Runnable() {
+ @Override
+ public void run() {
+ streamOut = console.newOutputStream();// newMessageStream();
+ streamOut.setColor(Displays.getSystemColor(SWT.COLOR_BLACK));
+ streamOut.setActivateOnWrite(false);
+ streamErr = console.newOutputStream();
+ streamErr.setColor(Displays.getSystemColor(SWT.COLOR_RED));
+ streamErr.setActivateOnWrite(false);
+ streamPrompt = console.newOutputStream();
+ streamPrompt.setColor(Displays.getSystemColor(SWT.COLOR_BLUE));
+ streamPrompt.setActivateOnWrite(false);
+ }
+ });
+ thread.start();
+ }
+
+ public PrintStream getPrintStream() {
+ return new PrintStream(streamOut);
+ }
+
+ public void shutdown() {
+ thread.interrupt();
+ try {
+ thread.join(5000);
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ } finally {
+ ConsolePlugin.getDefault().getConsoleManager().removeConsoles(new IConsole[] {console});
+ }
+ }
+
+ public static final int CONSOLE_ERROR = 0;
+
+ public static final int CONSOLE_OUT = 1;
+
+ public static final int CONSOLE_PROMPT = 2;
+
+ /**
+ * Writes string to console without popping console forward
+ *
+ * @param str
+ */
+ public void write(String str) {
+ write(str, false);
+ }
+
+ /**
+ * Writes string to console without popping console forward
+ *
+ * @param str
+ */
+ public void writeError(String str) {
+ write(str, CONSOLE_ERROR, true);
+ }
+
+ /**
+ * Writes string to console
+ *
+ * @param str
+ * @param popup bring console window forward
+ */
+ public void write(String str, boolean popup) {
+ write(str, CONSOLE_OUT, popup);
+ }
+
+ /**
+ * Write string to console
+ *
+ * @param str
+ * @param type CONSOLE_ERROR, CONSOLE_OUT, CONSOLE_PROMPT
+ */
+ public void write(String str, int type) {
+ write(str, type, false);
+ }
+
+ /**
+ * Write string to console
+ *
+ * @param str
+ * @param type CONSOLE_ERROR, CONSOLE_OUT, CONSOLE_PROMPT
+ * @param popup bring console window forward
+ */
+ public void write(String str, int type, boolean popup) {
+ String time = "";
+ if (this.time) {
+ Calendar cal = Calendar.getInstance();
+ cal.setTime(new Date());
+
+ if (cal.get(Calendar.HOUR) == 0) {
+ time = "12";
+ } else {
+ time = "" + cal.get(Calendar.HOUR);
+ }
+ time = Lib.padLeading(time, '0', 2);
+ String minute = "" + cal.get(Calendar.MINUTE);
+ minute = Lib.padLeading(minute, '0', 2);
+ time += ":" + minute + " => ";
+ }
+ try {
+ sendToStreams(type, time);
+ if (str.length() > 100000) {
+ int i = 0;
+
+ while (i < str.length()) {
+ int endIndex = i + 100000;
+ endIndex = endIndex > str.length() ? str.length() : endIndex;
+ String chunk = str.substring(i, endIndex);
+ sendToStreams(type, chunk);
+ i = endIndex;
+ }
+ } else {
+ sendToStreams(type, str);
+ }
+
+ sendToStreams(type, "\n");
+ if (popup) {
+ popup();
+ }
+ } catch (IOException ex) {
+ ex.printStackTrace();
+ }
+ }
+
+ public void prompt(String str) throws IOException {
+ sendToStreams(CONSOLE_PROMPT, str);
+ }
+
+ private void sendToStreams(int type, String str) throws IOException {
+ if (type == CONSOLE_ERROR && streamErr != null) {
+ streamErr.write(str);
+ }
+ if (type == CONSOLE_PROMPT && streamPrompt != null) {
+ streamPrompt.write(str);
+ }
+ if (type == CONSOLE_OUT && streamOut != null) {
+ streamOut.write(str);
+ }
+ }
+
+ public void popup() {
+ ConsolePlugin.getDefault().getConsoleManager().showConsoleView(console);
+ }
+
+ public void addInputListener(IConsoleInputListener listener) {
+ inputHandler.addListener(listener);
+ }
+
+ public void removeInputListener(IConsoleInputListener listener) {
+ inputHandler.removeListener(listener);
+ }
+
+ private class HandleInput implements Runnable {
+
+ private final CopyOnWriteArrayList<IConsoleInputListener> listeners;
+
+ public HandleInput() {
+ listeners = new CopyOnWriteArrayList<IConsoleInputListener>();
+ }
+
+ public void addListener(IConsoleInputListener listener) {
+ listeners.add(listener);
+ }
+
+ public void removeListener(IConsoleInputListener listener) {
+ listeners.remove(listener);
+ }
+
+ public void run() {
+ BufferedReader input = new BufferedReader(new InputStreamReader(console.getInputStream()));
+ try {
+ String line = null;
+ while ((line = input.readLine()) != null) {
+ for (IConsoleInputListener listener : listeners) {
+ listener.lineRead(line);
+ }
+ }
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ OseeLog.log(OseePluginUiActivator.class, Level.INFO, "done with the handling of input");
+ }
+
+ }
}
\ No newline at end of file diff --git a/plugins/org.eclipse.osee.framework.ui.plugin/src/org/eclipse/osee/framework/ui/plugin/util/WindowLocal.java b/plugins/org.eclipse.osee.framework.ui.plugin/src/org/eclipse/osee/framework/ui/plugin/util/WindowLocal.java index fb421a558ba..425ff3e8f7e 100644 --- a/plugins/org.eclipse.osee.framework.ui.plugin/src/org/eclipse/osee/framework/ui/plugin/util/WindowLocal.java +++ b/plugins/org.eclipse.osee.framework.ui.plugin/src/org/eclipse/osee/framework/ui/plugin/util/WindowLocal.java @@ -12,6 +12,7 @@ package org.eclipse.osee.framework.ui.plugin.util; import java.util.HashMap; import java.util.Map; +import org.eclipse.osee.framework.ui.swt.Displays; import org.eclipse.ui.PlatformUI; /** diff --git a/plugins/org.eclipse.osee.framework.ui.plugin/src/org/eclipse/osee/framework/ui/plugin/workspace/EarlyStartup.java b/plugins/org.eclipse.osee.framework.ui.plugin/src/org/eclipse/osee/framework/ui/plugin/workspace/EarlyStartup.java index a9a9177832c..c96da9859c5 100644 --- a/plugins/org.eclipse.osee.framework.ui.plugin/src/org/eclipse/osee/framework/ui/plugin/workspace/EarlyStartup.java +++ b/plugins/org.eclipse.osee.framework.ui.plugin/src/org/eclipse/osee/framework/ui/plugin/workspace/EarlyStartup.java @@ -13,7 +13,7 @@ package org.eclipse.osee.framework.ui.plugin.workspace; import org.eclipse.core.runtime.Platform; import org.eclipse.osee.framework.ui.plugin.internal.OseePluginUiActivator; import org.eclipse.osee.framework.ui.plugin.workspace.internal.SafeWorkspaceAccessImpl; -import org.eclipse.swt.widgets.Display; +import org.eclipse.osee.framework.ui.swt.Displays; import org.eclipse.ui.IStartup; import org.osgi.framework.Bundle; @@ -22,20 +22,20 @@ import org.osgi.framework.Bundle; */ public class EarlyStartup implements IStartup { - @Override - public void earlyStartup() { - Display.getDefault().asyncExec(new Runnable() { - @Override - public void run() { - registerWorkspaceAccessService(); - } - }); - } + @Override + public void earlyStartup() { + Displays.ensureInDisplayThread(new Runnable() { + @Override + public void run() { + registerWorkspaceAccessService(); + } + }); + } - private void registerWorkspaceAccessService() { - Bundle bundle = Platform.getBundle(OseePluginUiActivator.PLUGIN_ID); - bundle.getBundleContext().registerService(SafeWorkspaceAccess.class.getName(), new SafeWorkspaceAccessImpl(), - null); - } + private void registerWorkspaceAccessService() { + Bundle bundle = Platform.getBundle(OseePluginUiActivator.PLUGIN_ID); + bundle.getBundleContext().registerService(SafeWorkspaceAccess.class.getName(), new SafeWorkspaceAccessImpl(), + null); + } } diff --git a/plugins/org.eclipse.osee.framework.ui.plugin/src/org/eclipse/osee/framework/ui/plugin/xnavigate/XNavigateComposite.java b/plugins/org.eclipse.osee.framework.ui.plugin/src/org/eclipse/osee/framework/ui/plugin/xnavigate/XNavigateComposite.java index e95170bdde2..60c923b107e 100644 --- a/plugins/org.eclipse.osee.framework.ui.plugin/src/org/eclipse/osee/framework/ui/plugin/xnavigate/XNavigateComposite.java +++ b/plugins/org.eclipse.osee.framework.ui.plugin/src/org/eclipse/osee/framework/ui/plugin/xnavigate/XNavigateComposite.java @@ -19,6 +19,7 @@ import org.eclipse.osee.framework.core.exception.OseeCoreException; import org.eclipse.osee.framework.logging.OseeLevel; import org.eclipse.osee.framework.logging.OseeLog; import org.eclipse.osee.framework.ui.plugin.internal.OseePluginUiActivator; +import org.eclipse.osee.framework.ui.swt.Displays; import org.eclipse.osee.framework.ui.swt.OSEEFilteredTree; import org.eclipse.swt.SWT; import org.eclipse.swt.browser.Browser; @@ -45,217 +46,218 @@ import org.eclipse.ui.dialogs.PatternFilter; */ public class XNavigateComposite extends Composite { - protected Browser browser; - protected OSEEFilteredTree filteredTree; - private static PatternFilter patternFilter = new PatternFilter(); - protected final XNavigateViewItems navigateViewItems; - private List<XNavigateItem> items; - public static enum TableLoadOption { - None, - // Wait for table to be loaded before returning; for test only - ForcePend, - // - ClearLastSearchItem, - // Don't perform UI check, just search - NoUI, - // Don't create fresh copy of search item; for test only - DontCopySearchItem - }; + protected Browser browser; + protected OSEEFilteredTree filteredTree; + private static PatternFilter patternFilter = new PatternFilter(); + protected final XNavigateViewItems navigateViewItems; + private List<XNavigateItem> items; + public static enum TableLoadOption { + None, + // Wait for table to be loaded before returning; for test only + ForcePend, + // + ClearLastSearchItem, + // Don't perform UI check, just search + NoUI, + // Don't create fresh copy of search item; for test only + DontCopySearchItem + }; - /** - * @param parent - * @param style - */ - public XNavigateComposite(XNavigateViewItems navigateViewItems, Composite parent, int style) { - super(parent, style); - this.navigateViewItems = navigateViewItems; + /** + * @param parent + * @param style + */ + public XNavigateComposite(XNavigateViewItems navigateViewItems, Composite parent, int style) { + super(parent, style); + this.navigateViewItems = navigateViewItems; - setLayout(new GridLayout(1, false)); - setLayoutData(new GridData(GridData.FILL_BOTH)); + setLayout(new GridLayout(1, false)); + setLayoutData(new GridData(GridData.FILL_BOTH)); - /* - * Create a grid layout object so the text and treeviewer are layed out the way I want. - */ - GridLayout layout = new GridLayout(); - layout.numColumns = 1; - layout.verticalSpacing = 0; - layout.marginWidth = 0; - layout.marginHeight = 0; - parent.setLayout(layout); - parent.setLayoutData(new GridData(GridData.FILL_BOTH)); - // parent.setBackground(parent.getDisplay().getSystemColor(SWT.COLOR_WHITE)); + /* + * Create a grid layout object so the text and treeviewer are layed out the way I want. + */ + GridLayout layout = new GridLayout(); + layout.numColumns = 1; + layout.verticalSpacing = 0; + layout.marginWidth = 0; + layout.marginHeight = 0; + parent.setLayout(layout); + parent.setLayoutData(new GridData(GridData.FILL_BOTH)); + // parent.setBackground(parent.getDisplay().getSystemColor(SWT.COLOR_WHITE)); - // if (!ConnectionHandler.isConnected()) { - // (new Label(parent, SWT.NONE)).setText("DB Connection Unavailable"); - // return; - // } + // if (!ConnectionHandler.isConnected()) { + // (new Label(parent, SWT.NONE)).setText("DB Connection Unavailable"); + // return; + // } - filteredTree = new OSEEFilteredTree(this, SWT.SINGLE | SWT.BORDER, patternFilter); - filteredTree.getViewer().setContentProvider(new XNavigateContentProvider()); - filteredTree.setInitialText(""); - filteredTree.getViewer().setLabelProvider(new XNavigateLabelProvider()); - GridData gd = new GridData(GridData.FILL_BOTH); - filteredTree.getViewer().getTree().setLayoutData(gd); - filteredTree.getViewer().addDoubleClickListener(new IDoubleClickListener() { - @Override - public void doubleClick(DoubleClickEvent event) { - try { - handleDoubleClick(); - } catch (OseeCoreException ex) { - OseeLog.log(OseePluginUiActivator.class, OseeLevel.SEVERE_POPUP, ex); - } - } - }); - filteredTree.getViewer().getTree().addKeyListener(new KeyListener() { - public void keyPressed(KeyEvent e) { - } + filteredTree = new OSEEFilteredTree(this, SWT.SINGLE | SWT.BORDER, patternFilter); + filteredTree.getViewer().setContentProvider(new XNavigateContentProvider()); + filteredTree.setInitialText(""); + filteredTree.getViewer().setLabelProvider(new XNavigateLabelProvider()); + GridData gd = new GridData(GridData.FILL_BOTH); + filteredTree.getViewer().getTree().setLayoutData(gd); + filteredTree.getViewer().addDoubleClickListener(new IDoubleClickListener() { + @Override + public void doubleClick(DoubleClickEvent event) { + try { + handleDoubleClick(); + } catch (OseeCoreException ex) { + OseeLog.log(OseePluginUiActivator.class, OseeLevel.SEVERE_POPUP, ex); + } + } + }); + filteredTree.getViewer().getTree().addKeyListener(new KeyListener() { + public void keyPressed(KeyEvent e) { + } - public void keyReleased(KeyEvent e) { - if (e.keyCode == SWT.CR || e.keyCode == SWT.KEYPAD_CR) { - try { - handleDoubleClick(); - } catch (OseeCoreException ex) { - OseeLog.log(OseePluginUiActivator.class, OseeLevel.SEVERE_POPUP, ex); - } - } - } - }); - // Disable native tree tooltip - filteredTree.getViewer().getTree().setToolTipText(""); - filteredTree.getViewer().getTree().addListener(SWT.Dispose, tableListener); - filteredTree.getViewer().getTree().addListener(SWT.KeyDown, tableListener); - filteredTree.getViewer().getTree().addListener(SWT.MouseMove, tableListener); - filteredTree.getViewer().getTree().addListener(SWT.MouseHover, tableListener); + public void keyReleased(KeyEvent e) { + if (e.keyCode == SWT.CR || e.keyCode == SWT.KEYPAD_CR) { + try { + handleDoubleClick(); + } catch (OseeCoreException ex) { + OseeLog.log(OseePluginUiActivator.class, OseeLevel.SEVERE_POPUP, ex); + } + } + } + }); + // Disable native tree tooltip + filteredTree.getViewer().getTree().setToolTipText(""); + filteredTree.getViewer().getTree().addListener(SWT.Dispose, tableListener); + filteredTree.getViewer().getTree().addListener(SWT.KeyDown, tableListener); + filteredTree.getViewer().getTree().addListener(SWT.MouseMove, tableListener); + filteredTree.getViewer().getTree().addListener(SWT.MouseHover, tableListener); - } + } - // Implement a "fake" tooltip - final Listener labelListener = new Listener() { - public void handleEvent(Event event) { - Label label = (Label) event.widget; - Shell shell = label.getShell(); - switch (event.type) { - case SWT.MouseDown: - Event e = new Event(); - e.item = (TableItem) label.getData("_TABLEITEM"); - // Assuming table is single select, set the selection as if - // the mouse down event went through to the table - // filteredTree.getViewer().getTree().setSelection(new TableItem[] {(TableItem) e.item}); - filteredTree.getViewer().getTree().notifyListeners(SWT.Selection, e); - shell.dispose(); - filteredTree.getViewer().getTree().setFocus(); - break; - case SWT.MouseExit: - shell.dispose(); - break; - } - } - }; + // Implement a "fake" tooltip + final Listener labelListener = new Listener() { + public void handleEvent(Event event) { + Label label = (Label) event.widget; + Shell shell = label.getShell(); + switch (event.type) { + case SWT.MouseDown: + Event e = new Event(); + e.item = (TableItem) label.getData("_TABLEITEM"); + // Assuming table is single select, set the selection as if + // the mouse down event went through to the table + // filteredTree.getViewer().getTree().setSelection(new TableItem[] {(TableItem) e.item}); + filteredTree.getViewer().getTree().notifyListeners(SWT.Selection, e); + shell.dispose(); + filteredTree.getViewer().getTree().setFocus(); + break; + case SWT.MouseExit: + shell.dispose(); + break; + } + } + }; - Shell tip = null; - Label label = null; + Shell tip = null; + Label label = null; - protected void disposeTooltip() { - if (tip == null) { - return; - } - tip.dispose(); - tip = null; - label = null; - } - Listener tableListener = new Listener() { + protected void disposeTooltip() { + if (tip == null) { + return; + } + tip.dispose(); + tip = null; + label = null; + } + Listener tableListener = new Listener() { - public void handleEvent(Event event) { - switch (event.type) { - case SWT.Dispose: - case SWT.KeyDown: - case SWT.MouseMove: { - if (tip == null) { - break; - } - disposeTooltip(); - break; - } - case SWT.MouseHover: { - TreeItem item = filteredTree.getViewer().getTree().getItem(new Point(event.x, event.y)); - if (item != null && item.getData() instanceof XNavigateItem && ((XNavigateItem) item.getData()).getDescription() != null && !((XNavigateItem) item.getData()).getDescription().equals( - "")) { - if (tip != null && !tip.isDisposed()) { - tip.dispose(); - } - tip = new Shell(Display.getCurrent().getActiveShell(), SWT.ON_TOP | SWT.NO_FOCUS | SWT.TOOL); - tip.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_INFO_BACKGROUND)); - FillLayout layout = new FillLayout(); - layout.marginWidth = 2; - tip.setLayout(layout); - label = new Label(tip, SWT.NONE); - label.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_INFO_FOREGROUND)); - label.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_INFO_BACKGROUND)); - label.setData("_TABLEITEM", item); - label.setText(item.getText() + "\n\n" + ((XNavigateItem) item.getData()).getDescription()); - label.addListener(SWT.MouseExit, labelListener); - label.addListener(SWT.MouseDown, labelListener); - Point size = tip.computeSize(SWT.DEFAULT, SWT.DEFAULT); - Rectangle rect = item.getBounds(0); - Point pt = filteredTree.getViewer().getTree().toDisplay(rect.x, rect.y); - tip.setBounds(pt.x, pt.y + 15, size.x, size.y); - tip.setVisible(true); - } - } - } - } - }; + public void handleEvent(Event event) { + switch (event.type) { + case SWT.Dispose: + case SWT.KeyDown: + case SWT.MouseMove: { + if (tip == null) { + break; + } + disposeTooltip(); + break; + } + case SWT.MouseHover: { + TreeItem item = filteredTree.getViewer().getTree().getItem(new Point(event.x, event.y)); + if (item != null && item.getData() instanceof XNavigateItem && ((XNavigateItem) item.getData()).getDescription() != null && !((XNavigateItem) item.getData()).getDescription().equals( + "")) { + if (tip != null && !tip.isDisposed()) { + tip.dispose(); + } + tip = new Shell(Display.getCurrent().getActiveShell(), SWT.ON_TOP | SWT.NO_FOCUS | SWT.TOOL); + tip.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_INFO_BACKGROUND)); + FillLayout layout = new FillLayout(); + layout.marginWidth = 2; + tip.setLayout(layout); + label = new Label(tip, SWT.NONE); + label.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_INFO_FOREGROUND)); + label.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_INFO_BACKGROUND)); + label.setData("_TABLEITEM", item); + label.setText(item.getText() + "\n\n" + ((XNavigateItem) item.getData()).getDescription()); + label.addListener(SWT.MouseExit, labelListener); + label.addListener(SWT.MouseDown, labelListener); + Point size = tip.computeSize(SWT.DEFAULT, SWT.DEFAULT); + Rectangle rect = item.getBounds(0); + Point pt = filteredTree.getViewer().getTree().toDisplay(rect.x, rect.y); + tip.setBounds(pt.x, pt.y + 15, size.x, size.y); + tip.setVisible(true); + } + } + } + } + }; - protected void handleDoubleClick() throws OseeCoreException { - IStructuredSelection sel = (IStructuredSelection) filteredTree.getViewer().getSelection(); - if (!sel.iterator().hasNext()) { - return; - } - XNavigateItem item = (XNavigateItem) sel.iterator().next(); - handleDoubleClick(item); - } + protected void handleDoubleClick() throws OseeCoreException { + IStructuredSelection sel = (IStructuredSelection) filteredTree.getViewer().getSelection(); + if (!sel.iterator().hasNext()) { + return; + } + XNavigateItem item = (XNavigateItem) sel.iterator().next(); + handleDoubleClick(item); + } - protected void handleDoubleClick(XNavigateItem item, TableLoadOption... tableLoadOptions) throws OseeCoreException { - disposeTooltip(); + protected void handleDoubleClick(XNavigateItem item, TableLoadOption... tableLoadOptions) throws OseeCoreException { + disposeTooltip(); - if (item.getChildren().size() > 0) { - filteredTree.getViewer().setExpandedState(item, true); - } else { - try { - item.run(tableLoadOptions); - } catch (Exception ex) { - OseeLog.log(OseePluginUiActivator.class, OseeLevel.SEVERE_POPUP, ex); - } - } - } + if (item.getChildren().size() > 0) { + filteredTree.getViewer().setExpandedState(item, true); + } else { + try { + item.run(tableLoadOptions); + } catch (Exception ex) { + OseeLog.log(OseePluginUiActivator.class, OseeLevel.SEVERE_POPUP, ex); + } + } + } - public void refresh() { - items = navigateViewItems.getSearchNavigateItems(); - Display.getDefault().asyncExec(new Runnable() { - public void run() { - filteredTree.getViewer().setInput(items); - } - }); - } + public void refresh() { + items = navigateViewItems.getSearchNavigateItems(); + Displays.ensureInDisplayThread(new Runnable() { + @Override + public void run() { + filteredTree.getViewer().setInput(items); + } + }); + } - /** - * @return the listViewer - */ - public FilteredTree getFilteredTree() { - return filteredTree; - } + /** + * @return the listViewer + */ + public FilteredTree getFilteredTree() { + return filteredTree; + } - /** - * @return the patternFilter - */ - public PatternFilter getPatternFilter() { - return patternFilter; - } + /** + * @return the patternFilter + */ + public PatternFilter getPatternFilter() { + return patternFilter; + } - /** - * @return the items - */ - public List<XNavigateItem> getItems() { - return items; - } + /** + * @return the items + */ + public List<XNavigateItem> getItems() { + return items; + } } diff --git a/plugins/org.eclipse.osee.framework.ui.plugin/src/org/eclipse/osee/framework/ui/plugin/xnavigate/XNavigateItemAction.java b/plugins/org.eclipse.osee.framework.ui.plugin/src/org/eclipse/osee/framework/ui/plugin/xnavigate/XNavigateItemAction.java index 7ae43ce8ccb..11854a2a46b 100644 --- a/plugins/org.eclipse.osee.framework.ui.plugin/src/org/eclipse/osee/framework/ui/plugin/xnavigate/XNavigateItemAction.java +++ b/plugins/org.eclipse.osee.framework.ui.plugin/src/org/eclipse/osee/framework/ui/plugin/xnavigate/XNavigateItemAction.java @@ -12,8 +12,8 @@ package org.eclipse.osee.framework.ui.plugin.xnavigate; import org.eclipse.jface.action.Action; import org.eclipse.jface.dialogs.MessageDialog; -import org.eclipse.osee.framework.ui.plugin.util.Displays; import org.eclipse.osee.framework.ui.plugin.xnavigate.XNavigateComposite.TableLoadOption; +import org.eclipse.osee.framework.ui.swt.Displays; import org.eclipse.osee.framework.ui.swt.KeyedImage; import org.eclipse.swt.widgets.Display; diff --git a/plugins/org.eclipse.osee.framework.ui.service.control/src/org/eclipse/osee/framework/ui/service/control/actions/InspectLookUpServerAction.java b/plugins/org.eclipse.osee.framework.ui.service.control/src/org/eclipse/osee/framework/ui/service/control/actions/InspectLookUpServerAction.java index 1720b4c3ec1..c0f9d366fd5 100644 --- a/plugins/org.eclipse.osee.framework.ui.service.control/src/org/eclipse/osee/framework/ui/service/control/actions/InspectLookUpServerAction.java +++ b/plugins/org.eclipse.osee.framework.ui.service.control/src/org/eclipse/osee/framework/ui/service/control/actions/InspectLookUpServerAction.java @@ -17,27 +17,28 @@ import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.StructuredSelection; import org.eclipse.osee.framework.ui.service.control.dialogs.InspectReggieDialogHelper; import org.eclipse.osee.framework.ui.service.control.widgets.ManagerMain; -import org.eclipse.swt.widgets.Display; +import org.eclipse.osee.framework.ui.swt.Displays; /** * @author Roberto E. Escobar */ public class InspectLookUpServerAction implements IDoubleClickListener { - private ManagerMain mainWindow; + private final ManagerMain mainWindow; - public InspectLookUpServerAction(ManagerMain mainWindow) { - super(); - this.mainWindow = mainWindow; - this.mainWindow.getLookupViewer().getViewer().addDoubleClickListener(this); - } + public InspectLookUpServerAction(ManagerMain mainWindow) { + super(); + this.mainWindow = mainWindow; + this.mainWindow.getLookupViewer().getViewer().addDoubleClickListener(this); + } - public void doubleClick(DoubleClickEvent event) { - ISelection sel = event.getSelection(); - if (!sel.isEmpty()) { - Object object = ((StructuredSelection) sel).getFirstElement(); - if (object instanceof ServiceRegistrar) { - Display.getDefault().asyncExec(new InspectReggieDialogHelper(mainWindow, (ServiceRegistrar) object)); - } - } - } + @Override + public void doubleClick(DoubleClickEvent event) { + ISelection sel = event.getSelection(); + if (!sel.isEmpty()) { + Object object = ((StructuredSelection) sel).getFirstElement(); + if (object instanceof ServiceRegistrar) { + Displays.ensureInDisplayThread(new InspectReggieDialogHelper(mainWindow, (ServiceRegistrar) object)); + } + } + } } diff --git a/plugins/org.eclipse.osee.framework.ui.service.control/src/org/eclipse/osee/framework/ui/service/control/actions/OpenLaunchWizard.java b/plugins/org.eclipse.osee.framework.ui.service.control/src/org/eclipse/osee/framework/ui/service/control/actions/OpenLaunchWizard.java index eea7eb0ebe0..3d2d7901162 100644 --- a/plugins/org.eclipse.osee.framework.ui.service.control/src/org/eclipse/osee/framework/ui/service/control/actions/OpenLaunchWizard.java +++ b/plugins/org.eclipse.osee.framework.ui.service.control/src/org/eclipse/osee/framework/ui/service/control/actions/OpenLaunchWizard.java @@ -15,31 +15,31 @@ import org.eclipse.osee.framework.ui.service.control.ServiceControlImage; import org.eclipse.osee.framework.ui.service.control.widgets.ManagerMain;
import org.eclipse.osee.framework.ui.service.control.wizards.launcher.ServiceLaunchWizard;
import org.eclipse.osee.framework.ui.service.control.wizards.launcher.ServiceWizardDialog;
+import org.eclipse.osee.framework.ui.swt.Displays;
import org.eclipse.osee.framework.ui.swt.ImageManager;
-import org.eclipse.swt.widgets.Display;
/**
* @author Roberto E. Escobar
*/
public class OpenLaunchWizard extends Action {
- public OpenLaunchWizard(ManagerMain mainWindow) {
- super();
- setImageDescriptor(ImageManager.getImageDescriptor(ServiceControlImage.ROCKET));
- setText("Launch A Service");
- // setToolTipText("Open the service launching wizard.");
- //TODO: Please remove next two lines upon action 4ZXCH completion.
- this.setToolTipText("Disabled until action 4ZXCH is complete.");
- this.setEnabled(false);
- }
+ public OpenLaunchWizard(ManagerMain mainWindow) {
+ super();
+ setImageDescriptor(ImageManager.getImageDescriptor(ServiceControlImage.ROCKET));
+ setText("Launch A Service");
+ // setToolTipText("Open the service launching wizard.");
+ //TODO: Please remove next two lines upon action 4ZXCH completion.
+ this.setToolTipText("Disabled until action 4ZXCH is complete.");
+ this.setEnabled(false);
+ }
- @Override
- public void run() {
- super.run();
- ServiceLaunchWizard wizard = new ServiceLaunchWizard();
- ServiceWizardDialog dialog = new ServiceWizardDialog(Display.getDefault().getActiveShell(), wizard);
- dialog.setBlockOnOpen(true);
- dialog.open();
- }
+ @Override
+ public void run() {
+ super.run();
+ ServiceLaunchWizard wizard = new ServiceLaunchWizard();
+ ServiceWizardDialog dialog = new ServiceWizardDialog(Displays.getActiveShell(), wizard);
+ dialog.setBlockOnOpen(true);
+ dialog.open();
+ }
}
diff --git a/plugins/org.eclipse.osee.framework.ui.service.control/src/org/eclipse/osee/framework/ui/service/control/dialogs/PopulateInspectReggieDialog.java b/plugins/org.eclipse.osee.framework.ui.service.control/src/org/eclipse/osee/framework/ui/service/control/dialogs/PopulateInspectReggieDialog.java index 01225a87708..a3378aaae3d 100644 --- a/plugins/org.eclipse.osee.framework.ui.service.control/src/org/eclipse/osee/framework/ui/service/control/dialogs/PopulateInspectReggieDialog.java +++ b/plugins/org.eclipse.osee.framework.ui.service.control/src/org/eclipse/osee/framework/ui/service/control/dialogs/PopulateInspectReggieDialog.java @@ -23,7 +23,7 @@ import org.eclipse.jface.dialogs.MessageDialog; import org.eclipse.osee.framework.plugin.core.util.ExportClassLoader;
import org.eclipse.osee.framework.ui.service.control.ControlPlugin;
import org.eclipse.osee.framework.ui.service.control.managers.ServiceTreeBuilder;
-import org.eclipse.swt.widgets.Display;
+import org.eclipse.osee.framework.ui.swt.Displays;
import org.eclipse.ui.PlatformUI;
/**
@@ -31,67 +31,71 @@ import org.eclipse.ui.PlatformUI; */
public class PopulateInspectReggieDialog extends Job {
- private ServiceRegistrar reggie;
- private ServiceTreeBuilder serviceTreeBuilder;
+ private final ServiceRegistrar reggie;
+ private final ServiceTreeBuilder serviceTreeBuilder;
- public PopulateInspectReggieDialog(String title, ServiceTreeBuilder serviceTreeBuilder, ServiceRegistrar reggie) {
- super(title);
- this.serviceTreeBuilder = serviceTreeBuilder;
- this.reggie = reggie;
+ public PopulateInspectReggieDialog(String title, ServiceTreeBuilder serviceTreeBuilder, ServiceRegistrar reggie) {
+ super(title);
+ this.serviceTreeBuilder = serviceTreeBuilder;
+ this.reggie = reggie;
- }
+ }
- public static void scheduleJob(Job job) {
- job.setUser(true);
- job.setPriority(Job.SHORT);
- job.schedule();
- }
+ public static void scheduleJob(Job job) {
+ job.setUser(true);
+ job.setPriority(Job.SHORT);
+ job.schedule();
+ }
- @Override
- protected IStatus run(IProgressMonitor monitor) {
- IStatus status = Status.CANCEL_STATUS;
- ClassLoader loader = this.getThread().getContextClassLoader();
- try {
- this.getThread().setContextClassLoader(ExportClassLoader.getInstance());
- ServiceMatches serviceMatches = reggie.lookup(new ServiceTemplate(null, null, null), Integer.MAX_VALUE);
- final ServiceItem[] serviceItemArray = serviceMatches.items;
- Display.getDefault().asyncExec(new Runnable() {
- public void run() {
- for (ServiceItem item : serviceItemArray) {
- serviceTreeBuilder.serviceAdded(item);
- }
- }
- });
- status = Status.OK_STATUS;
- } catch (RemoteException ex) {
- try {
- displayMessage("Reggie Lookup Error", String.format("Error searching for services in [%s:%s] reggie.\n%s",
- reggie.getLocator().getHost(), reggie.getLocator().getPort(), ControlPlugin.getStackMessages(ex)));
- } catch (RemoteException ex1) {
- displayMessage("Reggie Lookup Error", String.format("Unable to access selected the selected reggie.\n%s",
- ControlPlugin.getStackMessages(ex)));
- }
- } finally {
- this.getThread().setContextClassLoader(loader);
- }
- return status;
- }
+ @Override
+ protected IStatus run(IProgressMonitor monitor) {
+ IStatus status = Status.CANCEL_STATUS;
+ ClassLoader loader = this.getThread().getContextClassLoader();
+ try {
+ this.getThread().setContextClassLoader(ExportClassLoader.getInstance());
+ ServiceMatches serviceMatches = reggie.lookup(new ServiceTemplate(null, null, null), Integer.MAX_VALUE);
+ final ServiceItem[] serviceItemArray = serviceMatches.items;
+ Displays.ensureInDisplayThread(new Runnable() {
+ @Override
+ public void run() {
+ for (ServiceItem item : serviceItemArray) {
+ serviceTreeBuilder.serviceAdded(item);
+ }
+ }
+ });
+ status = Status.OK_STATUS;
+ } catch (RemoteException ex) {
+ try {
+ displayMessage("Reggie Lookup Error", String.format("Error searching for services in [%s:%s] reggie.\n%s",
+ reggie.getLocator().getHost(), reggie.getLocator().getPort(), ControlPlugin.getStackMessages(ex)));
+ } catch (RemoteException ex1) {
+ displayMessage(
+ "Reggie Lookup Error",
+ String.format("Unable to access selected the selected reggie.\n%s",
+ ControlPlugin.getStackMessages(ex)));
+ }
+ } finally {
+ this.getThread().setContextClassLoader(loader);
+ }
+ return status;
+ }
- private void displayMessage(final String title, final String message) {
- displayMessage(title, message, true);
- }
+ private void displayMessage(final String title, final String message) {
+ displayMessage(title, message, true);
+ }
- private void displayMessage(final String title, final String message, final boolean isError) {
- Display.getDefault().syncExec(new Runnable() {
- public void run() {
- if (isError) {
- MessageDialog.openError(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), title, message);
- } else {
- MessageDialog.openInformation(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), title,
- message);
- }
- }
- });
- }
+ private void displayMessage(final String title, final String message, final boolean isError) {
+ Displays.pendInDisplayThread(new Runnable() {
+ @Override
+ public void run() {
+ if (isError) {
+ MessageDialog.openError(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), title, message);
+ } else {
+ MessageDialog.openInformation(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), title,
+ message);
+ }
+ }
+ });
+ }
}
diff --git a/plugins/org.eclipse.osee.framework.ui.service.control/src/org/eclipse/osee/framework/ui/service/control/jobs/TextDisplayHelper.java b/plugins/org.eclipse.osee.framework.ui.service.control/src/org/eclipse/osee/framework/ui/service/control/jobs/TextDisplayHelper.java index 59636198ed5..e310cb40f79 100644 --- a/plugins/org.eclipse.osee.framework.ui.service.control/src/org/eclipse/osee/framework/ui/service/control/jobs/TextDisplayHelper.java +++ b/plugins/org.eclipse.osee.framework.ui.service.control/src/org/eclipse/osee/framework/ui/service/control/jobs/TextDisplayHelper.java @@ -11,9 +11,9 @@ package org.eclipse.osee.framework.ui.service.control.jobs; import org.eclipse.osee.framework.ui.plugin.io.StreamToTextArea; +import org.eclipse.osee.framework.ui.swt.Displays; import org.eclipse.osee.framework.ui.swt.FormattedText; import org.eclipse.swt.SWT; -import org.eclipse.swt.widgets.Display; import org.eclipse.ui.PlatformUI; /** @@ -21,67 +21,68 @@ import org.eclipse.ui.PlatformUI; */ public class TextDisplayHelper { - private FormattedText formattedText; - private StreamToTextArea errorGobbler; - private StreamToTextArea outputGobbler; + private final FormattedText formattedText; + private StreamToTextArea errorGobbler; + private StreamToTextArea outputGobbler; - public TextDisplayHelper(FormattedText formattedText) { - this.formattedText = formattedText; - this.errorGobbler = null; - this.outputGobbler = null; - } + public TextDisplayHelper(FormattedText formattedText) { + this.formattedText = formattedText; + this.errorGobbler = null; + this.outputGobbler = null; + } - public void updateScrollBar() { - PlatformUI.getWorkbench().getDisplay().syncExec(new Runnable() { - public void run() { - formattedText.getStyledText().setSelection(formattedText.getStyledText().getCharCount()); - } - }); - } + public void updateScrollBar() { + PlatformUI.getWorkbench().getDisplay().syncExec(new Runnable() { + public void run() { + formattedText.getStyledText().setSelection(formattedText.getStyledText().getCharCount()); + } + }); + } - public void addText(final String toDisplay, final int format, final int color, final boolean underline) { - PlatformUI.getWorkbench().getDisplay().syncExec(new Runnable() { - public void run() { - formattedText.addText(toDisplay, format, color, underline); - } - }); - } + public void addText(final String toDisplay, final int format, final int color, final boolean underline) { + PlatformUI.getWorkbench().getDisplay().syncExec(new Runnable() { + public void run() { + formattedText.addText(toDisplay, format, color, underline); + } + }); + } - public void clear() { - PlatformUI.getWorkbench().getDisplay().syncExec(new Runnable() { - public void run() { - formattedText.clearTextArea(); - } - }); - } + public void clear() { + PlatformUI.getWorkbench().getDisplay().syncExec(new Runnable() { + public void run() { + formattedText.clearTextArea(); + } + }); + } - public FormattedText getFormattedText() { - return formattedText; - } + public FormattedText getFormattedText() { + return formattedText; + } - public void startProcessHandling(Process process) { - disposeProcessHandling(); - errorGobbler = new StreamToTextArea(process.getErrorStream(), "\t\terr", getFormattedText()); - errorGobbler.setName("ServiceErrorHandler"); - errorGobbler.typeColor(SWT.COLOR_RED); - outputGobbler = new StreamToTextArea(process.getInputStream(), "\t\tout", getFormattedText()); - outputGobbler.setName("ServiceOutputHandler"); - outputGobbler.typeColor(SWT.COLOR_DARK_BLUE); + public void startProcessHandling(Process process) { + disposeProcessHandling(); + errorGobbler = new StreamToTextArea(process.getErrorStream(), "\t\terr", getFormattedText()); + errorGobbler.setName("ServiceErrorHandler"); + errorGobbler.typeColor(SWT.COLOR_RED); + outputGobbler = new StreamToTextArea(process.getInputStream(), "\t\tout", getFormattedText()); + outputGobbler.setName("ServiceOutputHandler"); + outputGobbler.typeColor(SWT.COLOR_DARK_BLUE); - errorGobbler.start(); - outputGobbler.start(); - } + errorGobbler.start(); + outputGobbler.start(); + } - public void disposeProcessHandling() { - Display.getDefault().asyncExec(new Runnable() { - public void run() { - if (errorGobbler != null) { - errorGobbler.setStopped(true); - } - if (outputGobbler != null) { - outputGobbler.setStopped(true); - } - } - }); - } + public void disposeProcessHandling() { + Displays.ensureInDisplayThread(new Runnable() { + @Override + public void run() { + if (errorGobbler != null) { + errorGobbler.setStopped(true); + } + if (outputGobbler != null) { + outputGobbler.setStopped(true); + } + } + }); + } } diff --git a/plugins/org.eclipse.osee.framework.ui.service.control/src/org/eclipse/osee/framework/ui/service/control/jobs/UploadRemoteFileJob.java b/plugins/org.eclipse.osee.framework.ui.service.control/src/org/eclipse/osee/framework/ui/service/control/jobs/UploadRemoteFileJob.java index 105db5a7b32..e5c7947c8fd 100644 --- a/plugins/org.eclipse.osee.framework.ui.service.control/src/org/eclipse/osee/framework/ui/service/control/jobs/UploadRemoteFileJob.java +++ b/plugins/org.eclipse.osee.framework.ui.service.control/src/org/eclipse/osee/framework/ui/service/control/jobs/UploadRemoteFileJob.java @@ -18,7 +18,6 @@ import java.io.InputStream; import java.io.OutputStream; import java.net.URL; import java.util.Map; - import org.eclipse.core.runtime.FileLocator; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IStatus; @@ -29,13 +28,12 @@ import org.eclipse.jface.dialogs.MessageDialog; import org.eclipse.osee.framework.ui.service.control.ControlPlugin; import org.eclipse.osee.framework.ui.service.control.wizards.launcher.ServiceLaunchingInformation; import org.eclipse.osee.framework.ui.service.control.wizards.launcher.pages.UploadPage.LabelEnum; +import org.eclipse.osee.framework.ui.swt.Displays; import org.eclipse.swt.SWT; -import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.ProgressBar; import org.eclipse.swt.widgets.Shell; import org.eclipse.swt.widgets.Text; import org.osgi.framework.Bundle; - import com.jcraft.jsch.ChannelSftp; import com.jcraft.jsch.SftpException; @@ -44,191 +42,200 @@ import com.jcraft.jsch.SftpException; */ public class UploadRemoteFileJob extends Job { - private ServiceLaunchingInformation serviceInfo; - private TextDisplayHelper display; - private ProgressBar progress; - private Map<LabelEnum, Text> dataMap; - private boolean isUploadDirCreationAllowed; - - public UploadRemoteFileJob(String name, ServiceLaunchingInformation serviceInfo, TextDisplayHelper display, ProgressBar progress, Map<LabelEnum, Text> dataMap) { - super(name); - if (serviceInfo == null) throw new IllegalArgumentException("serviceInfo can not be null"); - if (display == null) throw new IllegalArgumentException("display can not be null"); - if (progress == null) throw new IllegalArgumentException("progress can not be null"); - this.serviceInfo = serviceInfo; - this.display = display; - this.progress = progress; - this.dataMap = dataMap; - this.isUploadDirCreationAllowed = false; - progress.setSelection(0); - progress.setMaximum(0); - progress.setMaximum(5); - } - - private void incrementProgress(final int increment) { - Display.getDefault().asyncExec(new Runnable() { - public void run() { - int position = progress.getSelection(); - progress.setSelection(position + increment); - } - }); - } - - private void displayInitMessage(File zipLocation) { - display.clear(); - display.addText("\t\t ----------- Unzip -------------\n\n", SWT.BOLD, SWT.COLOR_BLACK, false); - display.addText("\tFrom Location: ", SWT.BOLD, SWT.COLOR_DARK_BLUE, true); - display.addText(String.format("\t%s\n", zipLocation.getAbsolutePath()), SWT.NORMAL, SWT.COLOR_BLACK, false); - display.addText("\tTo Location: ", SWT.BOLD, SWT.COLOR_DARK_BLUE, true); - display.addText(String.format("\t%s://%s\n", serviceInfo.getSelectedHost(), serviceInfo.getUnzipLocation()), - SWT.NORMAL, SWT.COLOR_BLACK, false); - } - - private ChannelSftp getScpConnection() throws Exception { - display.addText("\n\tStarting SCP...", SWT.NORMAL, SWT.COLOR_BLACK, false); - ChannelSftp sftp = this.serviceInfo.getSSHConnection().getScpConnection(); - incrementProgress(1); - return sftp; - } - - private void createRemotePathOrCdIntoIt(IProgressMonitor monitor, ChannelSftp sftp) throws Exception { - if (monitor.isCanceled() != true) { - try { - sftp.cd(serviceInfo.getUnzipLocation()); - } catch (SftpException ex1) { - this.isUploadDirCreationAllowed = false; - Display.getDefault().syncExec(new Runnable() { - public void run() { - Shell shell = Display.getDefault().getActiveShell(); - isUploadDirCreationAllowed = - MessageDialog.openQuestion(shell, "Scp", - "Unable to find remote path. Would you like to create it?"); - } - }); - - if (isUploadDirCreationAllowed == true) { - try { - sftp.mkdir(serviceInfo.getUnzipLocation()); - } catch (SftpException ex2) { - throw new Exception("Unable to create remote path."); - } - } else { - throw new Exception("Unable to find remote path - user selected not to create it."); - } - - } finally { - incrementProgress(1); - } - } - } - - private void uploadFile(IProgressMonitor monitor, ChannelSftp sftp, File fileToUpload) throws Exception { - if (monitor.isCanceled() != true) { - display.addText(String.format("\n\tUploading [%s]", fileToUpload.getAbsolutePath()), SWT.NORMAL, - SWT.COLOR_BLACK, false); - InputStream input = null; - OutputStream output = null; - try { - input = new FileInputStream(fileToUpload); - output = sftp.put(fileToUpload.getName()); - byte[] buffer = new byte[1024]; - int count = -1; - while ((count = input.read(buffer)) != -1) { - output.write(buffer, 0, count); - } - display.addText(String.format("\n\tTransferred [%s] bytes", fileToUpload.length()), SWT.NORMAL, - SWT.COLOR_BLACK, false); - } catch (SftpException ex1) { - throw new Exception("Error uploading file."); - } finally { - incrementProgress(1); - if (input != null) { - input.close(); - } - if (output != null) { - output.close(); - } - } - } - } - - private void unzipRemoteFiles(IProgressMonitor monitor) throws Exception { - if (monitor.isCanceled() != true) { - String toExec = - String.format("cd %s\nunzip -o %s", serviceInfo.getUnzipLocation(), - serviceInfo.getServiceItem().getZipName()); - - display.addText("\n\tUnzip Cmd: ", SWT.BOLD, SWT.COLOR_DARK_BLUE, true); - display.addText("\t" + toExec.split("\n")[1] + "\n", SWT.NORMAL, SWT.COLOR_BLACK, false); - - String output = this.serviceInfo.getSSHConnection().executeCommandList(toExec.split("\n")); - display.addText("\n\t" + output + "\n", SWT.NORMAL, SWT.COLOR_BLACK, false); - incrementProgress(1); - } - } - - public File getFile(Bundle bundle, String path) throws FileNotFoundException, IOException { - URL url = bundle.getEntry(path); - if (url == null) { - throw new FileNotFoundException("Could not locate the file " + path); - } - try { - url = FileLocator.toFileURL(url); - File file = new File(url.getFile()); - return file; - } catch (Throwable e) { - throw new IOException("Invalid URL format for the URL " + url.toString(), e); - } - } - - @Override - public IStatus run(IProgressMonitor monitor) { - IStatus toReturn = Status.OK_STATUS; - ChannelSftp sftp = null; - try { - Display.getDefault().syncExec(new Runnable() { - public void run() { - serviceInfo.setUnzipLocation(dataMap.get(LabelEnum.Host_Upload_Location).getText()); - } - }); - Bundle bundle = Platform.getBundle(serviceInfo.getServiceItem().getPlugin()); - File zipLocation = getFile(bundle, serviceInfo.getServiceItem().getZipName()); - - displayInitMessage(zipLocation); - - sftp = getScpConnection(); - - createRemotePathOrCdIntoIt(monitor, sftp); - - uploadFile(monitor, sftp, zipLocation); - - unzipRemoteFiles(monitor); - - } catch (Exception ex) { - display.addText(String.format("\n\t%s\n\n", ex.getLocalizedMessage()), SWT.NORMAL, SWT.COLOR_RED, false); - toReturn = new Status(Status.ERROR, ControlPlugin.PLUGIN_PREFERENCE_SCOPE, "Error during upload.", ex); - } finally { - incrementProgress(5); - if (sftp != null) { - sftp.exit(); - sftp.disconnect(); - } - } - - // incrementProgress(1); - // if (true != createDestinationFolder()) { - // incrementProgress(4); - // toReturn = Status.CANCEL_STATUS; - // } else { - - // if (true != toReturn.equals(Status.OK_STATUS)) { - // PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() { - // public void run() { - // MessageDialog.openError(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), "Upload Error", - // "Upload of files to remote host failed."); - // } - // }); - // } - return toReturn; - } + private final ServiceLaunchingInformation serviceInfo; + private final TextDisplayHelper display; + private final ProgressBar progress; + private final Map<LabelEnum, Text> dataMap; + private boolean isUploadDirCreationAllowed; + + public UploadRemoteFileJob(String name, ServiceLaunchingInformation serviceInfo, TextDisplayHelper display, ProgressBar progress, Map<LabelEnum, Text> dataMap) { + super(name); + if (serviceInfo == null) { + throw new IllegalArgumentException("serviceInfo can not be null"); + } + if (display == null) { + throw new IllegalArgumentException("display can not be null"); + } + if (progress == null) { + throw new IllegalArgumentException("progress can not be null"); + } + this.serviceInfo = serviceInfo; + this.display = display; + this.progress = progress; + this.dataMap = dataMap; + this.isUploadDirCreationAllowed = false; + progress.setSelection(0); + progress.setMaximum(0); + progress.setMaximum(5); + } + + private void incrementProgress(final int increment) { + Displays.ensureInDisplayThread(new Runnable() { + @Override + public void run() { + int position = progress.getSelection(); + progress.setSelection(position + increment); + } + }); + } + + private void displayInitMessage(File zipLocation) { + display.clear(); + display.addText("\t\t ----------- Unzip -------------\n\n", SWT.BOLD, SWT.COLOR_BLACK, false); + display.addText("\tFrom Location: ", SWT.BOLD, SWT.COLOR_DARK_BLUE, true); + display.addText(String.format("\t%s\n", zipLocation.getAbsolutePath()), SWT.NORMAL, SWT.COLOR_BLACK, false); + display.addText("\tTo Location: ", SWT.BOLD, SWT.COLOR_DARK_BLUE, true); + display.addText(String.format("\t%s://%s\n", serviceInfo.getSelectedHost(), serviceInfo.getUnzipLocation()), + SWT.NORMAL, SWT.COLOR_BLACK, false); + } + + private ChannelSftp getScpConnection() throws Exception { + display.addText("\n\tStarting SCP...", SWT.NORMAL, SWT.COLOR_BLACK, false); + ChannelSftp sftp = this.serviceInfo.getSSHConnection().getScpConnection(); + incrementProgress(1); + return sftp; + } + + private void createRemotePathOrCdIntoIt(IProgressMonitor monitor, ChannelSftp sftp) throws Exception { + if (monitor.isCanceled() != true) { + try { + sftp.cd(serviceInfo.getUnzipLocation()); + } catch (SftpException ex1) { + this.isUploadDirCreationAllowed = false; + Displays.pendInDisplayThread(new Runnable() { + @Override + public void run() { + Shell shell = Displays.getActiveShell(); + isUploadDirCreationAllowed = + MessageDialog.openQuestion(shell, "Scp", + "Unable to find remote path. Would you like to create it?"); + } + }); + + if (isUploadDirCreationAllowed == true) { + try { + sftp.mkdir(serviceInfo.getUnzipLocation()); + } catch (SftpException ex2) { + throw new Exception("Unable to create remote path."); + } + } else { + throw new Exception("Unable to find remote path - user selected not to create it."); + } + + } finally { + incrementProgress(1); + } + } + } + + private void uploadFile(IProgressMonitor monitor, ChannelSftp sftp, File fileToUpload) throws Exception { + if (monitor.isCanceled() != true) { + display.addText(String.format("\n\tUploading [%s]", fileToUpload.getAbsolutePath()), SWT.NORMAL, + SWT.COLOR_BLACK, false); + InputStream input = null; + OutputStream output = null; + try { + input = new FileInputStream(fileToUpload); + output = sftp.put(fileToUpload.getName()); + byte[] buffer = new byte[1024]; + int count = -1; + while ((count = input.read(buffer)) != -1) { + output.write(buffer, 0, count); + } + display.addText(String.format("\n\tTransferred [%s] bytes", fileToUpload.length()), SWT.NORMAL, + SWT.COLOR_BLACK, false); + } catch (SftpException ex1) { + throw new Exception("Error uploading file."); + } finally { + incrementProgress(1); + if (input != null) { + input.close(); + } + if (output != null) { + output.close(); + } + } + } + } + + private void unzipRemoteFiles(IProgressMonitor monitor) throws Exception { + if (monitor.isCanceled() != true) { + String toExec = + String.format("cd %s\nunzip -o %s", serviceInfo.getUnzipLocation(), + serviceInfo.getServiceItem().getZipName()); + + display.addText("\n\tUnzip Cmd: ", SWT.BOLD, SWT.COLOR_DARK_BLUE, true); + display.addText("\t" + toExec.split("\n")[1] + "\n", SWT.NORMAL, SWT.COLOR_BLACK, false); + + String output = this.serviceInfo.getSSHConnection().executeCommandList(toExec.split("\n")); + display.addText("\n\t" + output + "\n", SWT.NORMAL, SWT.COLOR_BLACK, false); + incrementProgress(1); + } + } + + public File getFile(Bundle bundle, String path) throws FileNotFoundException, IOException { + URL url = bundle.getEntry(path); + if (url == null) { + throw new FileNotFoundException("Could not locate the file " + path); + } + try { + url = FileLocator.toFileURL(url); + File file = new File(url.getFile()); + return file; + } catch (Throwable e) { + throw new IOException("Invalid URL format for the URL " + url.toString(), e); + } + } + + @Override + public IStatus run(IProgressMonitor monitor) { + IStatus toReturn = Status.OK_STATUS; + ChannelSftp sftp = null; + try { + Displays.pendInDisplayThread(new Runnable() { + @Override + public void run() { + serviceInfo.setUnzipLocation(dataMap.get(LabelEnum.Host_Upload_Location).getText()); + } + }); + Bundle bundle = Platform.getBundle(serviceInfo.getServiceItem().getPlugin()); + File zipLocation = getFile(bundle, serviceInfo.getServiceItem().getZipName()); + + displayInitMessage(zipLocation); + + sftp = getScpConnection(); + + createRemotePathOrCdIntoIt(monitor, sftp); + + uploadFile(monitor, sftp, zipLocation); + + unzipRemoteFiles(monitor); + + } catch (Exception ex) { + display.addText(String.format("\n\t%s\n\n", ex.getLocalizedMessage()), SWT.NORMAL, SWT.COLOR_RED, false); + toReturn = new Status(Status.ERROR, ControlPlugin.PLUGIN_PREFERENCE_SCOPE, "Error during upload.", ex); + } finally { + incrementProgress(5); + if (sftp != null) { + sftp.exit(); + sftp.disconnect(); + } + } + + // incrementProgress(1); + // if (true != createDestinationFolder()) { + // incrementProgress(4); + // toReturn = Status.CANCEL_STATUS; + // } else { + + // if (true != toReturn.equals(Status.OK_STATUS)) { + // PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() { + // public void run() { + // MessageDialog.openError(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), "Upload Error", + // "Upload of files to remote host failed."); + // } + // }); + // } + return toReturn; + } } diff --git a/plugins/org.eclipse.osee.framework.ui.service.control/src/org/eclipse/osee/framework/ui/service/control/widgets/LookupViewer.java b/plugins/org.eclipse.osee.framework.ui.service.control/src/org/eclipse/osee/framework/ui/service/control/widgets/LookupViewer.java index 43247b475e8..f07005ddfea 100644 --- a/plugins/org.eclipse.osee.framework.ui.service.control/src/org/eclipse/osee/framework/ui/service/control/widgets/LookupViewer.java +++ b/plugins/org.eclipse.osee.framework.ui.service.control/src/org/eclipse/osee/framework/ui/service/control/widgets/LookupViewer.java @@ -23,13 +23,13 @@ import org.eclipse.jface.viewers.ViewerSorter; import org.eclipse.osee.framework.ui.service.control.ServiceControlImage;
import org.eclipse.osee.framework.ui.service.control.renderer.IRenderer;
import org.eclipse.osee.framework.ui.service.control.renderer.ReggieItemHandler;
+import org.eclipse.osee.framework.ui.swt.Displays;
import org.eclipse.osee.framework.ui.swt.ImageManager;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Table;
import org.eclipse.swt.widgets.TableItem;
@@ -38,106 +38,108 @@ import org.eclipse.swt.widgets.TableItem; */
public class LookupViewer extends Composite {
- private static final Image LOOK_UP_IMAGE = ImageManager.getImage(ServiceControlImage.CONNECTION);//ControlPlugin.getInstance().getImage("connection.gif");
- private static final Image DISCONNECTED_IMAGE = ImageManager.getImage(ServiceControlImage.DISCONNECTED);//ControlPlugin.getInstance().getImage("disconnected.gif");
-
- private StructuredViewer viewer;
- private Map<ServiceID, IRenderer> handlerMap;
-
- public LookupViewer(Composite parent, int style) {
- super(parent, style);
- createControl();
- }
-
- private void createControl() {
- this.setLayout(new GridLayout());
- this.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
-
- viewer = new TableViewer(this, SWT.SINGLE | SWT.READ_ONLY | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);
- viewer.getControl().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
- viewer.setLabelProvider(new ListLabelProvider());
- viewer.setContentProvider(new ArrayContentProvider());
- viewer.setSorter(new ViewerSorter());
- viewer.setInput(new String[0]);
- }
-
- public void refresh() {
- Display.getDefault().asyncExec(new Runnable() {
- public void run() {
- viewer.refresh();
- }
- });
- }
-
- public void setSelection(final String serviceId) {
- Display.getDefault().asyncExec(new Runnable() {
- public void run() {
- Table table = ((TableViewer) viewer).getTable();
- TableItem[] items = table.getItems();
- for (TableItem item : items) {
- Object object = item.getData();
- if (object instanceof ServiceRegistrar) {
- if (((ServiceRegistrar) object).getServiceID().toString().equals(serviceId)) {
- table.setSelection(new TableItem[] {item});
- return;
- }
- }
- }
- }
- });
- }
-
- public StructuredViewer getViewer() {
- return viewer;
- }
-
- public void setInput(Collection<?> input) {
- viewer.setInput(input);
- }
-
- public void setRendererMap(Map<ServiceID, IRenderer> map) {
- this.handlerMap = map;
- }
-
- public IRenderer getRenderer(ServiceID serviceId) {
- if (handlerMap != null) {
- return handlerMap.get(serviceId);
- } else {
- return null;
- }
- }
-
- private class ListLabelProvider extends LabelProvider {
-
- @Override
- public Image getImage(Object element) {
- if (element instanceof ServiceRegistrar) {
- if (ReggieItemHandler.isAllowed((ServiceRegistrar) element)) {
- return LOOK_UP_IMAGE;
- } else {
- return DISCONNECTED_IMAGE;
- }
- }
- return null;
- }
-
- @Override
- public String getText(Object element) {
- if (element instanceof ServiceRegistrar) {
- ServiceRegistrar reggie = (ServiceRegistrar) element;
- try {
- return " Jini Lookup: " + reggie.getLocator().getHost() + " : " + reggie.getLocator().getPort();
- } catch (RemoteException ex) {
- ex.printStackTrace();
- return "Jini Lookup: " + "UNABLE TO LOCATE";
- }
- }
- return "";
- }
- }
-
- @Override
- public void dispose() {
- viewer.getControl().dispose();
- }
+ private static final Image LOOK_UP_IMAGE = ImageManager.getImage(ServiceControlImage.CONNECTION);//ControlPlugin.getInstance().getImage("connection.gif");
+ private static final Image DISCONNECTED_IMAGE = ImageManager.getImage(ServiceControlImage.DISCONNECTED);//ControlPlugin.getInstance().getImage("disconnected.gif");
+
+ private StructuredViewer viewer;
+ private Map<ServiceID, IRenderer> handlerMap;
+
+ public LookupViewer(Composite parent, int style) {
+ super(parent, style);
+ createControl();
+ }
+
+ private void createControl() {
+ this.setLayout(new GridLayout());
+ this.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+
+ viewer = new TableViewer(this, SWT.SINGLE | SWT.READ_ONLY | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);
+ viewer.getControl().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+ viewer.setLabelProvider(new ListLabelProvider());
+ viewer.setContentProvider(new ArrayContentProvider());
+ viewer.setSorter(new ViewerSorter());
+ viewer.setInput(new String[0]);
+ }
+
+ public void refresh() {
+ Displays.ensureInDisplayThread(new Runnable() {
+ @Override
+ public void run() {
+ viewer.refresh();
+ }
+ });
+ }
+
+ public void setSelection(final String serviceId) {
+ Displays.ensureInDisplayThread(new Runnable() {
+ @Override
+ public void run() {
+ Table table = ((TableViewer) viewer).getTable();
+ TableItem[] items = table.getItems();
+ for (TableItem item : items) {
+ Object object = item.getData();
+ if (object instanceof ServiceRegistrar) {
+ if (((ServiceRegistrar) object).getServiceID().toString().equals(serviceId)) {
+ table.setSelection(new TableItem[] {item});
+ return;
+ }
+ }
+ }
+ }
+ });
+ }
+
+ public StructuredViewer getViewer() {
+ return viewer;
+ }
+
+ public void setInput(Collection<?> input) {
+ viewer.setInput(input);
+ }
+
+ public void setRendererMap(Map<ServiceID, IRenderer> map) {
+ this.handlerMap = map;
+ }
+
+ public IRenderer getRenderer(ServiceID serviceId) {
+ if (handlerMap != null) {
+ return handlerMap.get(serviceId);
+ } else {
+ return null;
+ }
+ }
+
+ private class ListLabelProvider extends LabelProvider {
+
+ @Override
+ public Image getImage(Object element) {
+ if (element instanceof ServiceRegistrar) {
+ if (ReggieItemHandler.isAllowed((ServiceRegistrar) element)) {
+ return LOOK_UP_IMAGE;
+ } else {
+ return DISCONNECTED_IMAGE;
+ }
+ }
+ return null;
+ }
+
+ @Override
+ public String getText(Object element) {
+ if (element instanceof ServiceRegistrar) {
+ ServiceRegistrar reggie = (ServiceRegistrar) element;
+ try {
+ return " Jini Lookup: " + reggie.getLocator().getHost() + " : " + reggie.getLocator().getPort();
+ } catch (RemoteException ex) {
+ ex.printStackTrace();
+ return "Jini Lookup: " + "UNABLE TO LOCATE";
+ }
+ }
+ return "";
+ }
+ }
+
+ @Override
+ public void dispose() {
+ viewer.getControl().dispose();
+ }
}
\ No newline at end of file diff --git a/plugins/org.eclipse.osee.framework.ui.service.control/src/org/eclipse/osee/framework/ui/service/control/widgets/ServicesViewer.java b/plugins/org.eclipse.osee.framework.ui.service.control/src/org/eclipse/osee/framework/ui/service/control/widgets/ServicesViewer.java index a13ddb49df8..2cc3bd0a39e 100644 --- a/plugins/org.eclipse.osee.framework.ui.service.control/src/org/eclipse/osee/framework/ui/service/control/widgets/ServicesViewer.java +++ b/plugins/org.eclipse.osee.framework.ui.service.control/src/org/eclipse/osee/framework/ui/service/control/widgets/ServicesViewer.java @@ -30,13 +30,13 @@ import org.eclipse.osee.framework.ui.service.control.data.CategoryParent; import org.eclipse.osee.framework.ui.service.control.data.GroupParent;
import org.eclipse.osee.framework.ui.service.control.data.ServiceNode;
import org.eclipse.osee.framework.ui.service.control.managers.ConnectionManager;
+import org.eclipse.osee.framework.ui.swt.Displays;
import org.eclipse.osee.framework.ui.swt.ImageManager;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.ISharedImages;
import org.eclipse.ui.PlatformUI;
@@ -45,158 +45,159 @@ import org.eclipse.ui.PlatformUI; */
public class ServicesViewer extends Composite {
- private static final Image CONFIG_IMAGE = ImageManager.getImage(ServiceControlImage.CONFIG);
- private static final Image FOLDER_IMAGE =
- PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJ_FOLDER);
- private static final Image GROUP_IMAGE = ImageManager.getImage(ServiceControlImage.GROUP);
- private static final Image CONNECT_FOLDER_IMAGE = ImageManager.getImage(ServiceControlImage.CONNECT_FOLDER);
- private static final Image CONNECTED_IMAGE = ImageManager.getImage(ServiceControlImage.CONNECTED_PLUG);
-
- private StructuredViewer viewer;
- private final Map<Class<?>, Image> serviceIconMap;
-
- public ServicesViewer(Composite parent, int style) {
- super(parent, style);
- create();
- serviceIconMap = new HashMap<Class<?>, Image>();
- }
-
- private void create() {
- this.setLayout(new GridLayout());
- this.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
- createTreeArea(this);
- }
-
- private void createTreeArea(Composite parent) {
- viewer = new TreeViewer(parent, SWT.SINGLE | SWT.READ_ONLY | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);
- viewer.getControl().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
- viewer.setContentProvider(new TreeContentProvider());
- viewer.setLabelProvider(new TreeLabelProvider());
- viewer.setSorter(new ViewerSorter());
- viewer.setInput(new ArrayList<String>());
- viewer.getControl().setBackground(Display.getDefault().getSystemColor(SWT.COLOR_WHITE));
- }
-
- private class TreeLabelProvider extends LabelProvider {
-
- @Override
- public Image getImage(Object obj) {
- Image toReturn = null;
- if (obj instanceof GroupParent) {
- toReturn = GROUP_IMAGE;
- } else if (obj instanceof CategoryParent) {
- toReturn = FOLDER_IMAGE;
- CategoryParent categoryParent = (CategoryParent) obj;
- if (categoryParent.hasChildren()) {
- Object child = categoryParent.getChildren()[0];
- if (child instanceof ServiceNode) {
- ServiceNode serviceNode = (ServiceNode) child;
- if (ConnectionManager.getInstance().isAllowedConnectionType(serviceNode.getServiceItem())) {
- toReturn = CONNECT_FOLDER_IMAGE;
- }
- }
- }
- } else if (obj instanceof ServiceNode) {
- ServiceNode node = (ServiceNode) obj;
- if (node.isConnected()) {
- toReturn = CONNECTED_IMAGE;
- } else {
- toReturn = CONFIG_IMAGE;
- ServiceItem serviceItem = node.getServiceItem();
- for (Class<?> classType : serviceIconMap.keySet()) {
- if (classType.isInstance(serviceItem.service)) {
- Image image = serviceIconMap.get(classType);
- if (image != null) {
- toReturn = image;
- }
- break;
- }
- }
- }
- }
- return toReturn;
- }
-
- @Override
- public String getText(Object obj) {
- return obj.toString();
- }
- }
-
- private class TreeContentProvider implements ITreeContentProvider {
-
- public void dispose() {
- }
-
- public Object[] getChildren(Object parentElement) {
- if (parentElement != null && parentElement instanceof TreeParent) {
- TreeParent parent = (TreeParent) parentElement;
- if (parent.hasChildren()) {
- return parent.getChildren();
- }
- }
- return new Object[0];
- }
-
- public Object[] getElements(Object inputElement) {
- if (inputElement != null && inputElement instanceof Collection<?>) {
- Collection<?> elementArray = (Collection<?>) inputElement;
- return elementArray.toArray();
- }
- return new Object[0];
- }
-
- public Object getParent(Object element) {
- if (element != null && element instanceof TreeObject) {
- TreeObject child = (TreeObject) element;
- return child.getParent();
- }
- return new Object();
- }
-
- public boolean hasChildren(Object element) {
- if (element instanceof TreeParent) {
- TreeParent parent = (TreeParent) element;
- return parent.hasChildren();
- }
- return false;
- }
-
- public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
- }
- }
-
- @Override
- public boolean setFocus() {
- return this.viewer.getControl().setFocus();
- }
-
- public StructuredViewer getViewer() {
- return viewer;
- }
-
- public void setInput(List<TreeParent> input) {
- viewer.setInput(input);
- }
-
- public void refresh() {
- Display.getDefault().asyncExec(new Runnable() {
- public void run() {
- if (viewer != null && !viewer.getControl().isDisposed()) {
- viewer.refresh();
- }
- }
- });
- }
-
- @Override
- public void dispose() {
- viewer.getControl().dispose();
- super.dispose();
- }
-
- public void registerImage(Class<?> serviceType, ImageDescriptor icon) {
- serviceIconMap.put(serviceType, icon.createImage());
- }
+ private static final Image CONFIG_IMAGE = ImageManager.getImage(ServiceControlImage.CONFIG);
+ private static final Image FOLDER_IMAGE = PlatformUI.getWorkbench().getSharedImages().getImage(
+ ISharedImages.IMG_OBJ_FOLDER);
+ private static final Image GROUP_IMAGE = ImageManager.getImage(ServiceControlImage.GROUP);
+ private static final Image CONNECT_FOLDER_IMAGE = ImageManager.getImage(ServiceControlImage.CONNECT_FOLDER);
+ private static final Image CONNECTED_IMAGE = ImageManager.getImage(ServiceControlImage.CONNECTED_PLUG);
+
+ private StructuredViewer viewer;
+ private final Map<Class<?>, Image> serviceIconMap;
+
+ public ServicesViewer(Composite parent, int style) {
+ super(parent, style);
+ create();
+ serviceIconMap = new HashMap<Class<?>, Image>();
+ }
+
+ private void create() {
+ this.setLayout(new GridLayout());
+ this.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+ createTreeArea(this);
+ }
+
+ private void createTreeArea(Composite parent) {
+ viewer = new TreeViewer(parent, SWT.SINGLE | SWT.READ_ONLY | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);
+ viewer.getControl().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+ viewer.setContentProvider(new TreeContentProvider());
+ viewer.setLabelProvider(new TreeLabelProvider());
+ viewer.setSorter(new ViewerSorter());
+ viewer.setInput(new ArrayList<String>());
+ viewer.getControl().setBackground(Displays.getSystemColor(SWT.COLOR_WHITE));
+ }
+
+ private class TreeLabelProvider extends LabelProvider {
+
+ @Override
+ public Image getImage(Object obj) {
+ Image toReturn = null;
+ if (obj instanceof GroupParent) {
+ toReturn = GROUP_IMAGE;
+ } else if (obj instanceof CategoryParent) {
+ toReturn = FOLDER_IMAGE;
+ CategoryParent categoryParent = (CategoryParent) obj;
+ if (categoryParent.hasChildren()) {
+ Object child = categoryParent.getChildren()[0];
+ if (child instanceof ServiceNode) {
+ ServiceNode serviceNode = (ServiceNode) child;
+ if (ConnectionManager.getInstance().isAllowedConnectionType(serviceNode.getServiceItem())) {
+ toReturn = CONNECT_FOLDER_IMAGE;
+ }
+ }
+ }
+ } else if (obj instanceof ServiceNode) {
+ ServiceNode node = (ServiceNode) obj;
+ if (node.isConnected()) {
+ toReturn = CONNECTED_IMAGE;
+ } else {
+ toReturn = CONFIG_IMAGE;
+ ServiceItem serviceItem = node.getServiceItem();
+ for (Class<?> classType : serviceIconMap.keySet()) {
+ if (classType.isInstance(serviceItem.service)) {
+ Image image = serviceIconMap.get(classType);
+ if (image != null) {
+ toReturn = image;
+ }
+ break;
+ }
+ }
+ }
+ }
+ return toReturn;
+ }
+
+ @Override
+ public String getText(Object obj) {
+ return obj.toString();
+ }
+ }
+
+ private class TreeContentProvider implements ITreeContentProvider {
+
+ public void dispose() {
+ }
+
+ public Object[] getChildren(Object parentElement) {
+ if (parentElement != null && parentElement instanceof TreeParent) {
+ TreeParent parent = (TreeParent) parentElement;
+ if (parent.hasChildren()) {
+ return parent.getChildren();
+ }
+ }
+ return new Object[0];
+ }
+
+ public Object[] getElements(Object inputElement) {
+ if (inputElement != null && inputElement instanceof Collection<?>) {
+ Collection<?> elementArray = (Collection<?>) inputElement;
+ return elementArray.toArray();
+ }
+ return new Object[0];
+ }
+
+ public Object getParent(Object element) {
+ if (element != null && element instanceof TreeObject) {
+ TreeObject child = (TreeObject) element;
+ return child.getParent();
+ }
+ return new Object();
+ }
+
+ public boolean hasChildren(Object element) {
+ if (element instanceof TreeParent) {
+ TreeParent parent = (TreeParent) element;
+ return parent.hasChildren();
+ }
+ return false;
+ }
+
+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+ }
+ }
+
+ @Override
+ public boolean setFocus() {
+ return this.viewer.getControl().setFocus();
+ }
+
+ public StructuredViewer getViewer() {
+ return viewer;
+ }
+
+ public void setInput(List<TreeParent> input) {
+ viewer.setInput(input);
+ }
+
+ public void refresh() {
+ Displays.ensureInDisplayThread(new Runnable() {
+ @Override
+ public void run() {
+ if (viewer != null && !viewer.getControl().isDisposed()) {
+ viewer.refresh();
+ }
+ }
+ });
+ }
+
+ @Override
+ public void dispose() {
+ viewer.getControl().dispose();
+ super.dispose();
+ }
+
+ public void registerImage(Class<?> serviceType, ImageDescriptor icon) {
+ serviceIconMap.put(serviceType, icon.createImage());
+ }
}
diff --git a/plugins/org.eclipse.osee.framework.ui.skynet.test/src/org/eclipse/osee/framework/ui/skynet/test/cases/ArtifactPasteOperationTest.java b/plugins/org.eclipse.osee.framework.ui.skynet.test/src/org/eclipse/osee/framework/ui/skynet/test/cases/ArtifactPasteOperationTest.java index 8667aae1daf..82ed90df113 100644 --- a/plugins/org.eclipse.osee.framework.ui.skynet.test/src/org/eclipse/osee/framework/ui/skynet/test/cases/ArtifactPasteOperationTest.java +++ b/plugins/org.eclipse.osee.framework.ui.skynet.test/src/org/eclipse/osee/framework/ui/skynet/test/cases/ArtifactPasteOperationTest.java @@ -14,7 +14,6 @@ import java.util.Arrays; import java.util.Collections;
import java.util.List;
import java.util.Map.Entry;
-import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.osee.framework.core.enums.CoreArtifactTypes;
import org.eclipse.osee.framework.core.enums.CoreRelationTypes;
@@ -46,200 +45,200 @@ import org.junit.Test; */
public class ArtifactPasteOperationTest {
- private static Artifact parent1;
-
- private static Artifact child1;
- private static Artifact child2;
- private static Artifact child3;
- private static Artifact destination;
- private static RelationOrderFactory relationOrderFactory;
-
- @BeforeClass
- public static void setup() throws OseeCoreException {
- List<Artifact> emptyList = Collections.emptyList();
- relationOrderFactory = new RelationOrderFactory();
-
- Branch branch = BranchManager.getCommonBranch();
- parent1 = ArtifactTypeManager.addArtifact(CoreArtifactTypes.Folder, branch, "Parent");
-
- child1 = ArtifactTypeManager.addArtifact(CoreArtifactTypes.Folder, branch, "child_a");
- child1.setRelationOrder(CoreRelationTypes.Default_Hierarchical__Child, emptyList);
-
- child2 = ArtifactTypeManager.addArtifact(CoreArtifactTypes.Folder, branch, "child_b");
- child3 = ArtifactTypeManager.addArtifact(CoreArtifactTypes.Folder, branch, "child_c");
-
- parent1.setRelationOrder(CoreRelationTypes.Default_Hierarchical__Child, emptyList);
- parent1.addChild(child1);
- parent1.addChild(child3);
- parent1.addChild(child2);
-
- destination = ArtifactTypeManager.addArtifact(CoreArtifactTypes.Folder, branch, "Destination");
- destination.setRelationOrder(CoreRelationTypes.Default_Hierarchical__Child, emptyList);
- destination.addChild(parent1);
- }
-
- @AfterClass
- public static void cleanup() throws OseeCoreException {
- delete(child1);
- delete(child2);
- delete(child3);
- delete(parent1);
- delete(destination);
- relationOrderFactory = null;
- }
-
- private static void delete(Artifact artifact) throws OseeCoreException {
- if (artifact != null) {
- artifact.deleteAndPersist();
- }
- }
-
- @Test
- public void testPasteArtifactNoChildren() throws Exception {
- String resolvedName = "Empty Parent First";
- try {
- performPaste(false, true, destination, Arrays.asList(parent1), resolvedName);
- checkPaste(destination, resolvedName, parent1, RelationOrderBaseTypes.USER_DEFINED);
- } finally {
- Artifact toDelete = destination.getChild(resolvedName);
- delete(toDelete);
- }
- }
-
- @Test
- public void testPasteArtifactFolderThenAddChild() throws Exception {
- String resolvedName = "Parent No Children";
- try {
- performPaste(false, true, destination, Arrays.asList(parent1), resolvedName);
- checkPaste(destination, resolvedName, parent1, RelationOrderBaseTypes.USER_DEFINED);
-
- Artifact newArtifact = destination.getChild(resolvedName);
- performPaste(false, true, newArtifact, Arrays.asList(child1), null);
- checkPaste(newArtifact, child1.getName(), child1, RelationOrderBaseTypes.USER_DEFINED);
-
- } finally {
- Artifact toDelete = destination.getChild(resolvedName);
- delete(toDelete);
- }
-
- }
-
- @Test
- public void testPasteArtifactsWithChildren() throws Exception {
- String resolvedName = "Parent With Children";
- try {
- performPaste(true, true, destination, Arrays.asList(parent1), resolvedName);
- checkPaste(destination, resolvedName, parent1, RelationOrderBaseTypes.USER_DEFINED, "child_a", "child_c",
- "child_b");
- } finally {
- Artifact toDelete = destination.getChild(resolvedName);
- delete(toDelete);
- }
- }
-
- private void checkPaste(Artifact destination, String expectedChild, Artifact copiedArtifact, RelationOrderBaseTypes expectedOrderType, String... names) throws OseeCoreException {
- Artifact newArtifact = destination.getChild(expectedChild);
- Assert.assertNotNull(newArtifact);
- Assert.assertTrue(!copiedArtifact.getGuid().equals(newArtifact.getGuid()));
-
- boolean hasChildren = names != null && names.length > 0;
-
- List<Artifact> childArtifacts = newArtifact.getChildren();
-
- Assert.assertEquals(hasChildren, !childArtifacts.isEmpty());
- if (hasChildren) {
- Assert.assertEquals(names.length, childArtifacts.size());
-
- List<Artifact> sourceChildren = parent1.getChildren();
- List<String> guids = Artifacts.toGuids(sourceChildren);
- for (int index = 0; index < names.length; index++) {
- IArtifact childArtifact = childArtifacts.get(index);
- Assert.assertEquals(names[index], childArtifact.getName());
- Assert.assertTrue(!guids.contains(childArtifact.getGuid()));
- }
- } else {
- Assert.assertTrue(childArtifacts.isEmpty());
- }
- checkRelationOrder(newArtifact, expectedOrderType, hasChildren);
- checkRelationOrder(destination, RelationOrderBaseTypes.USER_DEFINED, true);
- }
-
- private void checkRelationOrder(Artifact artifactToCheck, RelationOrderBaseTypes expectedOrderType, boolean hasChildren) throws OseeCoreException {
- RelationOrderData data = relationOrderFactory.createRelationOrderData(artifactToCheck);
- Assert.assertEquals(1, data.size());
-
- List<Artifact> childArtifacts = artifactToCheck.getChildren();
- Assert.assertEquals(hasChildren, !childArtifacts.isEmpty());
- for (Entry<Pair<String, String>, Pair<String, List<String>>> entry : data.entrySet()) {
- String relationType = entry.getKey().getFirst();
- String relationSide = entry.getKey().getSecond();
- String orderGuid = entry.getValue().getFirst();
- List<String> guids = entry.getValue().getSecond();
-
- Assert.assertEquals(CoreRelationTypes.Default_Hierarchical__Child.getName(), relationType);
- Assert.assertEquals(RelationSide.SIDE_B.name(), relationSide);
- Assert.assertEquals(expectedOrderType.getGuid(), orderGuid);
- if (hasChildren && expectedOrderType == RelationOrderBaseTypes.USER_DEFINED) {
- Assert.assertEquals(childArtifacts.size(), guids.size());
- for (int index = 0; index < guids.size(); index++) {
- IArtifact orderedChild = childArtifacts.get(index);
- String guid = guids.get(index);
- Assert.assertEquals(orderedChild.getGuid(), guid);
- }
- } else {
- Assert.assertTrue(guids.isEmpty());
- }
- }
- }
-
- private void performPaste(boolean includeChildren, boolean pasteRelationOrder, Artifact destination, List<Artifact> itemsToCopy, String resolvedName) throws Exception {
- ArtifactPasteConfiguration config = new ArtifactPasteConfiguration();
- config.setIncludeChildrenOfCopiedElements(includeChildren);
- config.setKeepRelationOrderSettings(pasteRelationOrder);
-
- Assert.assertEquals(includeChildren, config.isIncludeChildrenOfCopiedElements());
- Assert.assertEquals(pasteRelationOrder, config.isKeepRelationOrderSettings());
-
- MockArtifactNameConflictHandler handler = new MockArtifactNameConflictHandler();
- handler.setResolveWith(resolvedName);
- handler.setConflictedArtifact(itemsToCopy.get(0));
-
- ArtifactPasteOperation op = new ArtifactPasteOperation(config, destination, itemsToCopy, handler);
- Operations.executeWorkAndCheckStatus(op, new NullProgressMonitor(), -1);
- }
-
- private final static class MockArtifactNameConflictHandler extends ArtifactNameConflictHandler {
-
- private String resolveWith;
- private IArtifact conflictedArtifact;
-
- public MockArtifactNameConflictHandler() {
- resolveWith = null;
- conflictedArtifact = null;
- }
-
- public void setConflictedArtifact(IArtifact conflictedArtifact) {
- this.conflictedArtifact = conflictedArtifact;
- }
-
- public IArtifact getConflictedArtifact() {
- return conflictedArtifact;
- }
-
- public void setResolveWith(String resolveWith) {
- this.resolveWith = resolveWith;
- }
-
- public String getResolveWith() {
- return resolveWith;
- }
-
- @Override
- public String resolve(IArtifact artifact) throws CoreException {
- Assert.assertNotNull(artifact);
- Assert.assertEquals(getConflictedArtifact(), artifact);
- return getResolveWith();
- }
-
- }
+ private static Artifact parent1;
+
+ private static Artifact child1;
+ private static Artifact child2;
+ private static Artifact child3;
+ private static Artifact destination;
+ private static RelationOrderFactory relationOrderFactory;
+
+ @BeforeClass
+ public static void setup() throws OseeCoreException {
+ List<Artifact> emptyList = Collections.emptyList();
+ relationOrderFactory = new RelationOrderFactory();
+
+ Branch branch = BranchManager.getCommonBranch();
+ parent1 = ArtifactTypeManager.addArtifact(CoreArtifactTypes.Folder, branch, "Parent");
+
+ child1 = ArtifactTypeManager.addArtifact(CoreArtifactTypes.Folder, branch, "child_a");
+ child1.setRelationOrder(CoreRelationTypes.Default_Hierarchical__Child, emptyList);
+
+ child2 = ArtifactTypeManager.addArtifact(CoreArtifactTypes.Folder, branch, "child_b");
+ child3 = ArtifactTypeManager.addArtifact(CoreArtifactTypes.Folder, branch, "child_c");
+
+ parent1.setRelationOrder(CoreRelationTypes.Default_Hierarchical__Child, emptyList);
+ parent1.addChild(child1);
+ parent1.addChild(child3);
+ parent1.addChild(child2);
+
+ destination = ArtifactTypeManager.addArtifact(CoreArtifactTypes.Folder, branch, "Destination");
+ destination.setRelationOrder(CoreRelationTypes.Default_Hierarchical__Child, emptyList);
+ destination.addChild(parent1);
+ }
+
+ @AfterClass
+ public static void cleanup() throws OseeCoreException {
+ delete(child1);
+ delete(child2);
+ delete(child3);
+ delete(parent1);
+ delete(destination);
+ relationOrderFactory = null;
+ }
+
+ private static void delete(Artifact artifact) throws OseeCoreException {
+ if (artifact != null) {
+ artifact.deleteAndPersist();
+ }
+ }
+
+ @Test
+ public void testPasteArtifactNoChildren() throws Exception {
+ String resolvedName = "Empty Parent First";
+ try {
+ performPaste(false, true, destination, Arrays.asList(parent1), resolvedName);
+ checkPaste(destination, resolvedName, parent1, RelationOrderBaseTypes.USER_DEFINED);
+ } finally {
+ Artifact toDelete = destination.getChild(resolvedName);
+ delete(toDelete);
+ }
+ }
+
+ @Test
+ public void testPasteArtifactFolderThenAddChild() throws Exception {
+ String resolvedName = "Parent No Children";
+ try {
+ performPaste(false, true, destination, Arrays.asList(parent1), resolvedName);
+ checkPaste(destination, resolvedName, parent1, RelationOrderBaseTypes.USER_DEFINED);
+
+ Artifact newArtifact = destination.getChild(resolvedName);
+ performPaste(false, true, newArtifact, Arrays.asList(child1), null);
+ checkPaste(newArtifact, child1.getName(), child1, RelationOrderBaseTypes.USER_DEFINED);
+
+ } finally {
+ Artifact toDelete = destination.getChild(resolvedName);
+ delete(toDelete);
+ }
+
+ }
+
+ @Test
+ public void testPasteArtifactsWithChildren() throws Exception {
+ String resolvedName = "Parent With Children";
+ try {
+ performPaste(true, true, destination, Arrays.asList(parent1), resolvedName);
+ checkPaste(destination, resolvedName, parent1, RelationOrderBaseTypes.USER_DEFINED, "child_a", "child_c",
+ "child_b");
+ } finally {
+ Artifact toDelete = destination.getChild(resolvedName);
+ delete(toDelete);
+ }
+ }
+
+ private void checkPaste(Artifact destination, String expectedChild, Artifact copiedArtifact, RelationOrderBaseTypes expectedOrderType, String... names) throws OseeCoreException {
+ Artifact newArtifact = destination.getChild(expectedChild);
+ Assert.assertNotNull(newArtifact);
+ Assert.assertTrue(!copiedArtifact.getGuid().equals(newArtifact.getGuid()));
+
+ boolean hasChildren = names != null && names.length > 0;
+
+ List<Artifact> childArtifacts = newArtifact.getChildren();
+
+ Assert.assertEquals(hasChildren, !childArtifacts.isEmpty());
+ if (hasChildren) {
+ Assert.assertEquals(names.length, childArtifacts.size());
+
+ List<Artifact> sourceChildren = parent1.getChildren();
+ List<String> guids = Artifacts.toGuids(sourceChildren);
+ for (int index = 0; index < names.length; index++) {
+ IArtifact childArtifact = childArtifacts.get(index);
+ Assert.assertEquals(names[index], childArtifact.getName());
+ Assert.assertTrue(!guids.contains(childArtifact.getGuid()));
+ }
+ } else {
+ Assert.assertTrue(childArtifacts.isEmpty());
+ }
+ checkRelationOrder(newArtifact, expectedOrderType, hasChildren);
+ checkRelationOrder(destination, RelationOrderBaseTypes.USER_DEFINED, true);
+ }
+
+ private void checkRelationOrder(Artifact artifactToCheck, RelationOrderBaseTypes expectedOrderType, boolean hasChildren) throws OseeCoreException {
+ RelationOrderData data = relationOrderFactory.createRelationOrderData(artifactToCheck);
+ Assert.assertEquals(1, data.size());
+
+ List<Artifact> childArtifacts = artifactToCheck.getChildren();
+ Assert.assertEquals(hasChildren, !childArtifacts.isEmpty());
+ for (Entry<Pair<String, String>, Pair<String, List<String>>> entry : data.entrySet()) {
+ String relationType = entry.getKey().getFirst();
+ String relationSide = entry.getKey().getSecond();
+ String orderGuid = entry.getValue().getFirst();
+ List<String> guids = entry.getValue().getSecond();
+
+ Assert.assertEquals(CoreRelationTypes.Default_Hierarchical__Child.getName(), relationType);
+ Assert.assertEquals(RelationSide.SIDE_B.name(), relationSide);
+ Assert.assertEquals(expectedOrderType.getGuid(), orderGuid);
+ if (hasChildren && expectedOrderType == RelationOrderBaseTypes.USER_DEFINED) {
+ Assert.assertEquals(childArtifacts.size(), guids.size());
+ for (int index = 0; index < guids.size(); index++) {
+ IArtifact orderedChild = childArtifacts.get(index);
+ String guid = guids.get(index);
+ Assert.assertEquals(orderedChild.getGuid(), guid);
+ }
+ } else {
+ Assert.assertTrue(guids.isEmpty());
+ }
+ }
+ }
+
+ private void performPaste(boolean includeChildren, boolean pasteRelationOrder, Artifact destination, List<Artifact> itemsToCopy, String resolvedName) throws Exception {
+ ArtifactPasteConfiguration config = new ArtifactPasteConfiguration();
+ config.setIncludeChildrenOfCopiedElements(includeChildren);
+ config.setKeepRelationOrderSettings(pasteRelationOrder);
+
+ Assert.assertEquals(includeChildren, config.isIncludeChildrenOfCopiedElements());
+ Assert.assertEquals(pasteRelationOrder, config.isKeepRelationOrderSettings());
+
+ MockArtifactNameConflictHandler handler = new MockArtifactNameConflictHandler();
+ handler.setResolveWith(resolvedName);
+ handler.setConflictedArtifact(itemsToCopy.get(0));
+
+ ArtifactPasteOperation op = new ArtifactPasteOperation(config, destination, itemsToCopy, handler);
+ Operations.executeWorkAndCheckStatus(op, new NullProgressMonitor(), -1);
+ }
+
+ private final static class MockArtifactNameConflictHandler extends ArtifactNameConflictHandler {
+
+ private String resolveWith;
+ private IArtifact conflictedArtifact;
+
+ public MockArtifactNameConflictHandler() {
+ resolveWith = null;
+ conflictedArtifact = null;
+ }
+
+ public void setConflictedArtifact(IArtifact conflictedArtifact) {
+ this.conflictedArtifact = conflictedArtifact;
+ }
+
+ public IArtifact getConflictedArtifact() {
+ return conflictedArtifact;
+ }
+
+ public void setResolveWith(String resolveWith) {
+ this.resolveWith = resolveWith;
+ }
+
+ public String getResolveWith() {
+ return resolveWith;
+ }
+
+ @Override
+ public String resolve(IArtifact artifact) {
+ Assert.assertNotNull(artifact);
+ Assert.assertEquals(getConflictedArtifact(), artifact);
+ return getResolveWith();
+ }
+
+ }
}
diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/ArtifactExplorer.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/ArtifactExplorer.java index a7ffc3453b6..e667ba37fc5 100644 --- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/ArtifactExplorer.java +++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/ArtifactExplorer.java @@ -79,7 +79,6 @@ import org.eclipse.osee.framework.skynet.core.transaction.SkynetTransaction; import org.eclipse.osee.framework.skynet.core.utility.LoadedArtifacts;
import org.eclipse.osee.framework.ui.plugin.OseeUiActions;
import org.eclipse.osee.framework.ui.plugin.util.AWorkbench;
-import org.eclipse.osee.framework.ui.plugin.util.Displays;
import org.eclipse.osee.framework.ui.plugin.util.SelectionCountChangeListener;
import org.eclipse.osee.framework.ui.skynet.access.PolicyDialog;
import org.eclipse.osee.framework.ui.skynet.action.OpenAssociatedArtifactFromBranchProvider;
@@ -105,6 +104,7 @@ import org.eclipse.osee.framework.ui.skynet.util.SkynetViews; import org.eclipse.osee.framework.ui.skynet.widgets.XBranchSelectWidget;
import org.eclipse.osee.framework.ui.skynet.widgets.dialog.ArtifactTypeFilteredTreeEntryDialog;
import org.eclipse.osee.framework.ui.skynet.widgets.xHistory.HistoryView;
+import org.eclipse.osee.framework.ui.swt.Displays;
import org.eclipse.osee.framework.ui.swt.ImageManager;
import org.eclipse.osee.framework.ui.swt.MenuItems;
import org.eclipse.osee.framework.ui.swt.TreeViewerUtility;
diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/ArtifactExplorerEventManager.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/ArtifactExplorerEventManager.java index 970fe74f638..63c7fef9d7b 100644 --- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/ArtifactExplorerEventManager.java +++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/ArtifactExplorerEventManager.java @@ -19,7 +19,7 @@ import org.eclipse.osee.framework.skynet.core.event2.artifact.EventBasicGuidArti import org.eclipse.osee.framework.skynet.core.event2.artifact.EventModType;
import org.eclipse.osee.framework.skynet.core.event2.artifact.IArtifactEventListener;
import org.eclipse.osee.framework.skynet.core.event2.filter.IEventFilter;
-import org.eclipse.osee.framework.ui.plugin.util.Displays;
+import org.eclipse.osee.framework.ui.swt.Displays;
/**
* Common location for event handling for ArtifactExplorers in order to keep number of registrations and processing to a
diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/DialogPopupLoggerListener.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/DialogPopupLoggerListener.java index c8da4cfc48f..d341e10e14b 100644 --- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/DialogPopupLoggerListener.java +++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/DialogPopupLoggerListener.java @@ -19,58 +19,58 @@ import org.eclipse.core.runtime.Status; import org.eclipse.jface.dialogs.ErrorDialog;
import org.eclipse.osee.framework.logging.ILoggerListener;
import org.eclipse.osee.framework.logging.OseeLevel;
-import org.eclipse.swt.widgets.Display;
+import org.eclipse.osee.framework.ui.swt.Displays;
/**
* @author Andrew M. Finkbeiner
*/
public class DialogPopupLoggerListener implements ILoggerListener {
- @Override
- public void log(String loggerName, Level level, String message, Throwable th) {
- if (level == OseeLevel.SEVERE_POPUP) {
- String title = "OSEE Error";
- String messageText = message;
- String reasonMessage = "";
- if (th != null) {
- reasonMessage = th.getMessage();
- }
- final IStatus status;
- if (th != null) {
- List<IStatus> exc = new ArrayList<IStatus>();
- exceptionToString(true, loggerName, th, exc);
- status = new MultiStatus(loggerName, Status.ERROR, exc.toArray(new IStatus[exc.size()]), reasonMessage, th);
- } else {
- status = new Status(Status.ERROR, loggerName, -20, reasonMessage, th);
- }
- final String realTitle = title;
- final String realMessageText = messageText;
- Display.getDefault().syncExec(new Runnable() {
- @Override
- public void run() {
- ErrorDialog.openError(Display.getDefault().getActiveShell(), realTitle, realMessageText, status);
- }
- });
- }
- }
+ @Override
+ public void log(String loggerName, Level level, String message, Throwable th) {
+ if (level == OseeLevel.SEVERE_POPUP) {
+ String title = "OSEE Error";
+ String messageText = message;
+ String reasonMessage = "";
+ if (th != null) {
+ reasonMessage = th.getMessage();
+ }
+ final IStatus status;
+ if (th != null) {
+ List<IStatus> exc = new ArrayList<IStatus>();
+ exceptionToString(true, loggerName, th, exc);
+ status = new MultiStatus(loggerName, Status.ERROR, exc.toArray(new IStatus[exc.size()]), reasonMessage, th);
+ } else {
+ status = new Status(Status.ERROR, loggerName, -20, reasonMessage, th);
+ }
+ final String realTitle = title;
+ final String realMessageText = messageText;
+ Displays.pendInDisplayThread(new Runnable() {
+ @Override
+ public void run() {
+ ErrorDialog.openError(Displays.getActiveShell(), realTitle, realMessageText, status);
+ }
+ });
+ }
+ }
- private static void exceptionToString(boolean firstTime, String loggerName, Throwable ex, List<IStatus> exc) {
- if (ex == null) {
- return;
- }
- if (!firstTime) {
- exc.add(new Status(Status.ERROR, loggerName, ex.getMessage()));
- }
- StackTraceElement st[] = ex.getStackTrace();
- for (int i = 0; i < st.length; i++) {
- StackTraceElement ste = st[i];
- exc.add(new Status(Status.ERROR, loggerName, ste.toString()));
- }
- Throwable cause = ex.getCause();
- if (cause != null) {
- exc.add(new Status(Status.ERROR, loggerName, " caused by "));
- exceptionToString(false, loggerName, cause, exc);
- }
- }
+ private static void exceptionToString(boolean firstTime, String loggerName, Throwable ex, List<IStatus> exc) {
+ if (ex == null) {
+ return;
+ }
+ if (!firstTime) {
+ exc.add(new Status(Status.ERROR, loggerName, ex.getMessage()));
+ }
+ StackTraceElement st[] = ex.getStackTrace();
+ for (int i = 0; i < st.length; i++) {
+ StackTraceElement ste = st[i];
+ exc.add(new Status(Status.ERROR, loggerName, ste.toString()));
+ }
+ Throwable cause = ex.getCause();
+ if (cause != null) {
+ exc.add(new Status(Status.ERROR, loggerName, " caused by "));
+ exceptionToString(false, loggerName, cause, exc);
+ }
+ }
}
diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/OseeContributionItem.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/OseeContributionItem.java index c5d2fe4dbb2..63a57e0a462 100644 --- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/OseeContributionItem.java +++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/OseeContributionItem.java @@ -13,8 +13,8 @@ package org.eclipse.osee.framework.ui.skynet; import org.eclipse.jface.action.IStatusLineManager;
import org.eclipse.osee.framework.ui.skynet.ats.IOseeAtsService;
import org.eclipse.osee.framework.ui.skynet.ats.OseeAts;
+import org.eclipse.osee.framework.ui.swt.Displays;
import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.part.IPageSite;
import org.eclipse.ui.part.MultiPageEditorPart;
import org.eclipse.ui.part.ViewPart;
@@ -25,71 +25,72 @@ import org.eclipse.ui.texteditor.StatusLineContributionItem; */
public abstract class OseeContributionItem extends StatusLineContributionItem {
- protected OseeContributionItem(String id) {
- this(id, 4);
- }
-
- protected OseeContributionItem(String id, int width) {
- super(id, true, width);
- }
-
- protected abstract String getEnabledToolTip();
-
- protected abstract String getDisabledToolTip();
-
- protected abstract Image getEnabledImage();
-
- protected abstract Image getDisabledImage();
-
- protected void updateStatus(final boolean isActive) {
- Display.getDefault().asyncExec(new Runnable() {
- public void run() {
- Image image = isActive ? getEnabledImage() : getDisabledImage();
- String toolTip = isActive ? getEnabledToolTip() : getDisabledToolTip();
-
- if (image != null) {
- setImage(image);
- }
- if (toolTip != null) {
- setToolTipText(toolTip);
- }
- }
- });
- }
-
- public static void addTo(IStatusLineManager manager) {
- OseeBuildTypeContributionItem.addTo(manager);
- ResServiceContributionItem.addTo(manager);
- IOseeAtsService atsService = OseeAts.getInstance();
- if (atsService != null && atsService.isAtsAdmin()) {
- AdminContributionItem.addTo(manager);
- }
- SkynetServiceContributionItem.addTo(manager);
- OseeServicesStatusContributionItem.addTo(manager);
- SessionContributionItem.addTo(manager);
- }
-
- public static void addTo(IPageSite pageSite, boolean update) {
- addTo(pageSite.getActionBars().getStatusLineManager());
-
- if (update) {
- pageSite.getActionBars().updateActionBars();
- }
- }
-
- public static void addTo(ViewPart view, boolean update) {
- addTo(view.getViewSite().getActionBars().getStatusLineManager());
-
- if (update) {
- view.getViewSite().getActionBars().updateActionBars();
- }
- }
-
- public static void addTo(MultiPageEditorPart editorPart, boolean update) {
- addTo(editorPart.getEditorSite().getActionBars().getStatusLineManager());
- if (update) {
- editorPart.getEditorSite().getActionBars().updateActionBars();
- }
- }
+ protected OseeContributionItem(String id) {
+ this(id, 4);
+ }
+
+ protected OseeContributionItem(String id, int width) {
+ super(id, true, width);
+ }
+
+ protected abstract String getEnabledToolTip();
+
+ protected abstract String getDisabledToolTip();
+
+ protected abstract Image getEnabledImage();
+
+ protected abstract Image getDisabledImage();
+
+ protected void updateStatus(final boolean isActive) {
+ Displays.ensureInDisplayThread(new Runnable() {
+ @Override
+ public void run() {
+ Image image = isActive ? getEnabledImage() : getDisabledImage();
+ String toolTip = isActive ? getEnabledToolTip() : getDisabledToolTip();
+
+ if (image != null) {
+ setImage(image);
+ }
+ if (toolTip != null) {
+ setToolTipText(toolTip);
+ }
+ }
+ });
+ }
+
+ public static void addTo(IStatusLineManager manager) {
+ OseeBuildTypeContributionItem.addTo(manager);
+ ResServiceContributionItem.addTo(manager);
+ IOseeAtsService atsService = OseeAts.getInstance();
+ if (atsService != null && atsService.isAtsAdmin()) {
+ AdminContributionItem.addTo(manager);
+ }
+ SkynetServiceContributionItem.addTo(manager);
+ OseeServicesStatusContributionItem.addTo(manager);
+ SessionContributionItem.addTo(manager);
+ }
+
+ public static void addTo(IPageSite pageSite, boolean update) {
+ addTo(pageSite.getActionBars().getStatusLineManager());
+
+ if (update) {
+ pageSite.getActionBars().updateActionBars();
+ }
+ }
+
+ public static void addTo(ViewPart view, boolean update) {
+ addTo(view.getViewSite().getActionBars().getStatusLineManager());
+
+ if (update) {
+ view.getViewSite().getActionBars().updateActionBars();
+ }
+ }
+
+ public static void addTo(MultiPageEditorPart editorPart, boolean update) {
+ addTo(editorPart.getEditorSite().getActionBars().getStatusLineManager());
+ if (update) {
+ editorPart.getEditorSite().getActionBars().updateActionBars();
+ }
+ }
}
diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/OseeServicesStatusContributionItem.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/OseeServicesStatusContributionItem.java index e7827932f41..d4383ec2c76 100644 --- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/OseeServicesStatusContributionItem.java +++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/OseeServicesStatusContributionItem.java @@ -15,84 +15,84 @@ import org.eclipse.jface.action.IStatusLineManager; import org.eclipse.osee.framework.logging.IHealthStatus; import org.eclipse.osee.framework.logging.IStatusListener; import org.eclipse.osee.framework.logging.OseeLog; +import org.eclipse.osee.framework.ui.swt.Displays; import org.eclipse.osee.framework.ui.swt.ImageManager; import org.eclipse.osee.framework.ui.swt.OverlayImage; import org.eclipse.swt.graphics.Image; -import org.eclipse.swt.widgets.Display; /** * @author Roberto E. Escobar */ public class OseeServicesStatusContributionItem extends OseeContributionItem implements IStatusListener { - private static final String ID = "osee.service.status"; - private static final Image DISABLED_IMAGE = - new OverlayImage(ImageManager.getImage(FrameworkImage.APPLICATION_SERVER), - ImageManager.getImageDescriptor(FrameworkImage.SLASH_RED_OVERLAY)).createImage(); + private static final String ID = "osee.service.status"; + private static final Image DISABLED_IMAGE = new OverlayImage( + ImageManager.getImage(FrameworkImage.APPLICATION_SERVER), + ImageManager.getImageDescriptor(FrameworkImage.SLASH_RED_OVERLAY)).createImage(); - private static String errorMessage; - private static String okMessage; + private static String errorMessage; + private static String okMessage; - private OseeServicesStatusContributionItem() { - super(ID); - errorMessage = null; - okMessage = null; - updateStatus(true); - OseeLog.register(this); - } + private OseeServicesStatusContributionItem() { + super(ID); + errorMessage = null; + okMessage = null; + updateStatus(true); + OseeLog.register(this); + } - @Override - public void dispose() { - OseeLog.deregister(this); - super.dispose(); - } + @Override + public void dispose() { + OseeLog.deregister(this); + super.dispose(); + } - public static void addTo(IStatusLineManager manager) { - boolean wasFound = false; - for (IContributionItem item : manager.getItems()) { - if (item instanceof OseeServicesStatusContributionItem) { - wasFound = true; - break; - } - } - if (!wasFound) { - manager.add(new OseeServicesStatusContributionItem()); - } - } + public static void addTo(IStatusLineManager manager) { + boolean wasFound = false; + for (IContributionItem item : manager.getItems()) { + if (item instanceof OseeServicesStatusContributionItem) { + wasFound = true; + break; + } + } + if (!wasFound) { + manager.add(new OseeServicesStatusContributionItem()); + } + } - @Override - protected Image getDisabledImage() { - return DISABLED_IMAGE; - } + @Override + protected Image getDisabledImage() { + return DISABLED_IMAGE; + } - @Override - protected String getDisabledToolTip() { - return errorMessage; - } + @Override + protected String getDisabledToolTip() { + return errorMessage; + } - @Override - protected Image getEnabledImage() { - return ImageManager.getImage(FrameworkImage.APPLICATION_SERVER); - } + @Override + protected Image getEnabledImage() { + return ImageManager.getImage(FrameworkImage.APPLICATION_SERVER); + } - @Override - protected String getEnabledToolTip() { - return okMessage; - } + @Override + protected String getEnabledToolTip() { + return okMessage; + } - @Override - public void onStatus(final IHealthStatus status) { - Display.getDefault().asyncExec(new Runnable() { - @Override - public void run() { - if (status.isOk()) { - okMessage = status.getMessage(); - } else { - Throwable error = status.getException(); - errorMessage = error != null ? error.getLocalizedMessage() : "Undefined Error"; - } - updateStatus(status.isOk()); - } - }); + @Override + public void onStatus(final IHealthStatus status) { + Displays.ensureInDisplayThread(new Runnable() { + @Override + public void run() { + if (status.isOk()) { + okMessage = status.getMessage(); + } else { + Throwable error = status.getException(); + errorMessage = error != null ? error.getLocalizedMessage() : "Undefined Error"; + } + updateStatus(status.isOk()); + } + }); - } + } } diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/OseeUiEarlyStartup.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/OseeUiEarlyStartup.java index cebb2ab63dc..3e33da6ef9a 100644 --- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/OseeUiEarlyStartup.java +++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/OseeUiEarlyStartup.java @@ -8,107 +8,108 @@ * Contributors: * Boeing - initial API and implementation *******************************************************************************/ -package org.eclipse.osee.framework.ui.skynet;
-
-import java.util.logging.Level;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.osee.framework.logging.OseeLog;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.ui.IPartListener;
-import org.eclipse.ui.IPerspectiveDescriptor;
-import org.eclipse.ui.IPerspectiveListener;
-import org.eclipse.ui.IStartup;
-import org.eclipse.ui.IWorkbenchPage;
-import org.eclipse.ui.IWorkbenchPart;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.part.ViewPart;
-import org.osgi.framework.Bundle;
-
-/**
- * @author Ryan Schmitt
- */
-public class OseeUiEarlyStartup implements IStartup {
-
- @Override
- public void earlyStartup() {
- if (PlatformUI.isWorkbenchRunning()) {
- Display.getDefault().asyncExec(new Runnable() {
- public void run() {
- PlatformUI.getWorkbench().getActiveWorkbenchWindow().getPartService().addPartListener(
- new IPartListener() {
-
- @Override
- public void partActivated(IWorkbenchPart part) {
- // WorkspaceContributionItem.addToAllViews();
- if (part instanceof ViewPart) {
- WorkspaceContributionItem.addToViewpart((ViewPart) part);
- }
-
- }
-
- @Override
- public void partBroughtToTop(IWorkbenchPart part) {
- // WorkspaceContributionItem.addToAllViews();
- if (part instanceof ViewPart) {
- WorkspaceContributionItem.addToViewpart((ViewPart) part);
- }
-
- }
-
- @Override
- public void partClosed(IWorkbenchPart part) {
- }
-
- @Override
- public void partDeactivated(IWorkbenchPart part) {
- }
-
- @Override
- public void partOpened(IWorkbenchPart part) {
- // WorkspaceContributionItem.addToAllViews();
- if (part instanceof ViewPart) {
- WorkspaceContributionItem.addToViewpart((ViewPart) part);
- }
-
- }
-
- });
- PlatformUI.getWorkbench().getActiveWorkbenchWindow().addPerspectiveListener(new IPerspectiveListener() {
-
- @Override
- public void perspectiveActivated(IWorkbenchPage page, IPerspectiveDescriptor perspective) {
- // WorkspaceContributionItem.addToAllViews();
- if (page instanceof ViewPart) {
- WorkspaceContributionItem.addToViewpart((ViewPart) page);
- }
-
- }
-
- @Override
- public void perspectiveChanged(IWorkbenchPage page, IPerspectiveDescriptor perspective, String changeId) {
- // WorkspaceContributionItem.addToAllViews();
- if (page instanceof ViewPart) {
- WorkspaceContributionItem.addToViewpart((ViewPart) page);
- }
-
- }
-
- });
- }
- });
- startOseeTypes();
- }
- WorkspaceContributionItem.addToAllViews();
- }
-
- private void startOseeTypes() {
- try {
- Bundle bundle = Platform.getBundle("org.eclipse.osee.framework.types.bridge");
- if (bundle.getState() != Bundle.ACTIVE) {
- bundle.start();
- }
- } catch (Exception ex) {
- OseeLog.log(SkynetGuiPlugin.class, Level.SEVERE, ex);
- }
- }
-}
+package org.eclipse.osee.framework.ui.skynet; + +import java.util.logging.Level; +import org.eclipse.core.runtime.Platform; +import org.eclipse.osee.framework.logging.OseeLog; +import org.eclipse.osee.framework.ui.swt.Displays; +import org.eclipse.ui.IPartListener; +import org.eclipse.ui.IPerspectiveDescriptor; +import org.eclipse.ui.IPerspectiveListener; +import org.eclipse.ui.IStartup; +import org.eclipse.ui.IWorkbenchPage; +import org.eclipse.ui.IWorkbenchPart; +import org.eclipse.ui.PlatformUI; +import org.eclipse.ui.part.ViewPart; +import org.osgi.framework.Bundle; + +/** + * @author Ryan Schmitt + */ +public class OseeUiEarlyStartup implements IStartup { + + @Override + public void earlyStartup() { + if (PlatformUI.isWorkbenchRunning()) { + Displays.ensureInDisplayThread(new Runnable() { + @Override + public void run() { + PlatformUI.getWorkbench().getActiveWorkbenchWindow().getPartService().addPartListener( + new IPartListener() { + + @Override + public void partActivated(IWorkbenchPart part) { + // WorkspaceContributionItem.addToAllViews(); + if (part instanceof ViewPart) { + WorkspaceContributionItem.addToViewpart((ViewPart) part); + } + + } + + @Override + public void partBroughtToTop(IWorkbenchPart part) { + // WorkspaceContributionItem.addToAllViews(); + if (part instanceof ViewPart) { + WorkspaceContributionItem.addToViewpart((ViewPart) part); + } + + } + + @Override + public void partClosed(IWorkbenchPart part) { + } + + @Override + public void partDeactivated(IWorkbenchPart part) { + } + + @Override + public void partOpened(IWorkbenchPart part) { + // WorkspaceContributionItem.addToAllViews(); + if (part instanceof ViewPart) { + WorkspaceContributionItem.addToViewpart((ViewPart) part); + } + + } + + }); + PlatformUI.getWorkbench().getActiveWorkbenchWindow().addPerspectiveListener(new IPerspectiveListener() { + + @Override + public void perspectiveActivated(IWorkbenchPage page, IPerspectiveDescriptor perspective) { + // WorkspaceContributionItem.addToAllViews(); + if (page instanceof ViewPart) { + WorkspaceContributionItem.addToViewpart((ViewPart) page); + } + + } + + @Override + public void perspectiveChanged(IWorkbenchPage page, IPerspectiveDescriptor perspective, String changeId) { + // WorkspaceContributionItem.addToAllViews(); + if (page instanceof ViewPart) { + WorkspaceContributionItem.addToViewpart((ViewPart) page); + } + + } + + }); + } + }); + startOseeTypes(); + } + WorkspaceContributionItem.addToAllViews(); + } + + private void startOseeTypes() { + try { + Bundle bundle = Platform.getBundle("org.eclipse.osee.framework.types.bridge"); + if (bundle.getState() != Bundle.ACTIVE) { + bundle.start(); + } + } catch (Exception ex) { + OseeLog.log(SkynetGuiPlugin.class, Level.SEVERE, ex); + } + } +} diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/RelationsComposite.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/RelationsComposite.java index 7b0dbd4cf39..dd0070caf51 100644 --- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/RelationsComposite.java +++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/RelationsComposite.java @@ -47,12 +47,12 @@ import org.eclipse.osee.framework.skynet.core.event.Sender; import org.eclipse.osee.framework.skynet.core.relation.RelationManager;
import org.eclipse.osee.framework.skynet.core.relation.RelationTypeSide;
import org.eclipse.osee.framework.skynet.core.relation.RelationTypeSideSorter;
-import org.eclipse.osee.framework.ui.plugin.util.Displays;
import org.eclipse.osee.framework.ui.skynet.artifact.massEditor.MassArtifactEditor;
import org.eclipse.osee.framework.ui.skynet.relation.explorer.RelationExplorerWindow;
import org.eclipse.osee.framework.ui.skynet.render.PresentationType;
import org.eclipse.osee.framework.ui.skynet.render.RendererManager;
import org.eclipse.osee.framework.ui.skynet.util.SkynetDragAndDrop;
+import org.eclipse.osee.framework.ui.swt.Displays;
import org.eclipse.osee.framework.ui.swt.IDirtiableEditor;
import org.eclipse.swt.SWT;
import org.eclipse.swt.dnd.DND;
diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/ResServiceContributionItem.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/ResServiceContributionItem.java index 9b15f7fc92c..dd1e7419d24 100644 --- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/ResServiceContributionItem.java +++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/ResServiceContributionItem.java @@ -18,7 +18,7 @@ import org.eclipse.osee.framework.skynet.core.event.OseeEventManager; import org.eclipse.osee.framework.skynet.core.event.RemoteEventManager2; import org.eclipse.osee.framework.skynet.core.event.RemoteEventServiceEventType; import org.eclipse.osee.framework.skynet.core.event.Sender; -import org.eclipse.osee.framework.ui.plugin.util.Displays; +import org.eclipse.osee.framework.ui.swt.Displays; import org.eclipse.osee.framework.ui.swt.ImageManager; import org.eclipse.osee.framework.ui.swt.OverlayImage; import org.eclipse.swt.graphics.Image; diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/SessionContributionItem.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/SessionContributionItem.java index 39006907c92..6db8bfe57db 100644 --- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/SessionContributionItem.java +++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/SessionContributionItem.java @@ -25,8 +25,8 @@ import org.eclipse.osee.framework.skynet.core.event.OseeEventManager; import org.eclipse.osee.framework.skynet.core.event.Sender; import org.eclipse.osee.framework.skynet.core.event2.AccessControlEvent; import org.eclipse.osee.framework.skynet.core.utility.LoadedArtifacts; -import org.eclipse.osee.framework.ui.plugin.util.Displays; import org.eclipse.osee.framework.ui.skynet.dialogs.AuthenticationDialog; +import org.eclipse.osee.framework.ui.swt.Displays; import org.eclipse.osee.framework.ui.swt.ImageManager; import org.eclipse.osee.framework.ui.swt.OverlayImage; import org.eclipse.swt.graphics.Image; @@ -76,8 +76,9 @@ public final class SessionContributionItem extends OseeContributionItem implemen // oseeAuthentication.authenticate("", "", "", false); // } if (ClientSessionManager.isSessionValid()) { - Display.getDefault().asyncExec(new Runnable() { - public void run() { + Displays.ensureInDisplayThread(new Runnable() { + @Override + public void run() { try { AccessControlEvent event = new AccessControlEvent(); event.setEventType(AccessControlEventType.UserAuthenticated); diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/SkynetGuiPlugin.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/SkynetGuiPlugin.java index cf2a4d75dc1..0e7e6809f96 100644 --- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/SkynetGuiPlugin.java +++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/SkynetGuiPlugin.java @@ -30,7 +30,7 @@ import org.eclipse.osee.framework.skynet.core.utility.DbUtil; import org.eclipse.osee.framework.ui.plugin.OseeFormActivator;
import org.eclipse.osee.framework.ui.skynet.artifact.ArtifactSaveNotificationHandler;
import org.eclipse.osee.framework.ui.skynet.ats.IOseeAtsService;
-import org.eclipse.swt.widgets.Display;
+import org.eclipse.osee.framework.ui.swt.Displays;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchListener;
import org.eclipse.ui.PlatformUI;
@@ -39,159 +39,161 @@ import org.osgi.service.packageadmin.PackageAdmin; import org.osgi.util.tracker.ServiceTracker;
public class SkynetGuiPlugin extends OseeFormActivator implements IBroadcastEventListener, IOseeDatabaseServiceProvider {
- private static SkynetGuiPlugin pluginInstance; // The shared instance.
- public static final String PLUGIN_ID = "org.eclipse.osee.framework.ui.skynet";
- public static final String CHANGE_REPORT_ATTRIBUTES_PREF =
- "org.eclipse.osee.framework.ui.skynet.changeReportAttributes";
- public static final String ARTIFACT_EXPLORER_ATTRIBUTES_PREF =
- "org.eclipse.osee.framework.ui.skynet.artifactExplorerAttributes";
-
- public static final String ARTIFACT_SEARCH_RESULTS_ATTRIBUTES_PREF =
- "org.eclipse.osee.framework.ui.skynet.artifactSearchResultsAttributes";
- private ServiceTracker packageAdminTracker;
- private ServiceTracker cacheServiceTracker;
- private ServiceTracker databaseServiceTracker;
- private ServiceTracker atsServiceTracker;
-
- public SkynetGuiPlugin() {
- super();
- pluginInstance = this;
- }
-
- @Override
- public void stop(BundleContext context) throws Exception {
- super.stop(context);
- packageAdminTracker.close();
- cacheServiceTracker.close();
- databaseServiceTracker.close();
- atsServiceTracker.close();
- }
-
- @Override
- public void start(BundleContext context) throws Exception {
- super.start(context);
- packageAdminTracker = new ServiceTracker(context, PackageAdmin.class.getName(), null);
- packageAdminTracker.open();
-
- cacheServiceTracker = new ServiceTracker(context, IOseeCachingService.class.getName(), null);
- cacheServiceTracker.open();
-
- databaseServiceTracker = new ServiceTracker(context, IOseeDatabaseService.class.getName(), null);
- databaseServiceTracker.open();
-
- atsServiceTracker = new ServiceTracker(context, IOseeAtsService.class.getName(), null);
- atsServiceTracker.open();
-
- OseeEventManager.addListener(this);
-
- if (PlatformUI.isWorkbenchRunning()) {
-
- OseeLog.registerLoggerListener(new DialogPopupLoggerListener());
-
- IWorkbench workbench = PlatformUI.getWorkbench();
- workbench.addWorkbenchListener(new IWorkbenchListener() {
-
- @Override
- public void postShutdown(IWorkbench workbench) {
- }
-
- @Override
- public boolean preShutdown(IWorkbench workbench, boolean forced) {
- if (!DbUtil.isDbInit()) {
- try {
- UserManager.getUser().saveSettings();
- } catch (Throwable th) {
- th.printStackTrace();
- }
- }
- return true;
- }
- });
-
- PlatformUI.getWorkbench().addWorkbenchListener(new ArtifactSaveNotificationHandler());
- }
- }
-
- public static SkynetGuiPlugin getInstance() {
- return pluginInstance;
- }
-
- @Override
- protected String getPluginName() {
- return PLUGIN_ID;
- }
-
- public PackageAdmin getPackageAdmin() {
- return (PackageAdmin) this.packageAdminTracker.getService();
- }
-
- public IOseeCachingService getOseeCacheService() {
- return (IOseeCachingService) cacheServiceTracker.getService();
- }
-
- public IOseeDatabaseService getOseeDatabaseService() {
- return (IOseeDatabaseService) databaseServiceTracker.getService();
- }
-
- public IOseeAtsService getOseeAtsService() {
- return (IOseeAtsService) atsServiceTracker.getService();
- }
-
- @Override
- public void handleBroadcastEvent(Sender sender, final BroadcastEvent broadcastEvent) {
-
- // Determine whether this is a shutdown event
- // Prevent shutting down users without a valid message
- if (broadcastEvent.getBroadcastEventType() == BroadcastEventType.Force_Shutdown) {
- if (broadcastEvent.getMessage() == null || broadcastEvent.getMessage().length() == 0) {
- return;
- }
- Display.getDefault().asyncExec(new Runnable() {
- public void run() {
- boolean isShutdownRequest = false;
- try {
- isShutdownRequest = broadcastEvent.getUsers().contains(UserManager.getUser());
- } catch (OseeCoreException ex) {
- // do nothing
- }
- if (isShutdownRequest) {
- MessageDialog.openWarning(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),
- "Shutdown Requested", broadcastEvent.getMessage());
- // Shutdown the bench when this event is received
- PlatformUI.getWorkbench().close();
- }
- }
- });
- } else if (broadcastEvent.getBroadcastEventType() == BroadcastEventType.Message) {
- if (broadcastEvent.getMessage() == null || broadcastEvent.getMessage().length() == 0) {
- return;
- }
- Display.getDefault().asyncExec(new Runnable() {
- public void run() {
- MessageDialog.openInformation(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),
- "Remote Message", broadcastEvent.getMessage());
- }
- });
- } else if (broadcastEvent.getBroadcastEventType() == BroadcastEventType.Ping) {
- // Another client ping'd this client for session information; Pong back with
- // original client's session id so it can be identified as the correct pong
- try {
- OseeEventManager.kickBroadcastEvent(this, new BroadcastEvent(BroadcastEventType.Pong, null,
- sender.getOseeSession().toString()));
- } catch (Exception ex) {
- OseeLog.log(SkynetGuiPlugin.class, OseeLevel.SEVERE_POPUP, ex);
- }
- } else if (broadcastEvent.getBroadcastEventType() == BroadcastEventType.Pong) {
- // Got pong from another client; If message == this client's sessionId, then it's
- // the response from this client's ping
- try {
- if (broadcastEvent.getMessage() != null && broadcastEvent.getMessage().equals(
- ClientSessionManager.getSession().toString())) {
- OseeLog.log(SkynetGuiPlugin.class, Level.INFO, "Pong: " + sender.toString());
- }
- } catch (OseeAuthenticationRequiredException ex) {
- OseeLog.log(SkynetGuiPlugin.class, Level.SEVERE, "Pong: " + sender.toString(), ex);
- }
- }
- }
+ private static SkynetGuiPlugin pluginInstance; // The shared instance.
+ public static final String PLUGIN_ID = "org.eclipse.osee.framework.ui.skynet";
+ public static final String CHANGE_REPORT_ATTRIBUTES_PREF =
+ "org.eclipse.osee.framework.ui.skynet.changeReportAttributes";
+ public static final String ARTIFACT_EXPLORER_ATTRIBUTES_PREF =
+ "org.eclipse.osee.framework.ui.skynet.artifactExplorerAttributes";
+
+ public static final String ARTIFACT_SEARCH_RESULTS_ATTRIBUTES_PREF =
+ "org.eclipse.osee.framework.ui.skynet.artifactSearchResultsAttributes";
+ private ServiceTracker packageAdminTracker;
+ private ServiceTracker cacheServiceTracker;
+ private ServiceTracker databaseServiceTracker;
+ private ServiceTracker atsServiceTracker;
+
+ public SkynetGuiPlugin() {
+ super();
+ pluginInstance = this;
+ }
+
+ @Override
+ public void stop(BundleContext context) throws Exception {
+ super.stop(context);
+ packageAdminTracker.close();
+ cacheServiceTracker.close();
+ databaseServiceTracker.close();
+ atsServiceTracker.close();
+ }
+
+ @Override
+ public void start(BundleContext context) throws Exception {
+ super.start(context);
+ packageAdminTracker = new ServiceTracker(context, PackageAdmin.class.getName(), null);
+ packageAdminTracker.open();
+
+ cacheServiceTracker = new ServiceTracker(context, IOseeCachingService.class.getName(), null);
+ cacheServiceTracker.open();
+
+ databaseServiceTracker = new ServiceTracker(context, IOseeDatabaseService.class.getName(), null);
+ databaseServiceTracker.open();
+
+ atsServiceTracker = new ServiceTracker(context, IOseeAtsService.class.getName(), null);
+ atsServiceTracker.open();
+
+ OseeEventManager.addListener(this);
+
+ if (PlatformUI.isWorkbenchRunning()) {
+
+ OseeLog.registerLoggerListener(new DialogPopupLoggerListener());
+
+ IWorkbench workbench = PlatformUI.getWorkbench();
+ workbench.addWorkbenchListener(new IWorkbenchListener() {
+
+ @Override
+ public void postShutdown(IWorkbench workbench) {
+ }
+
+ @Override
+ public boolean preShutdown(IWorkbench workbench, boolean forced) {
+ if (!DbUtil.isDbInit()) {
+ try {
+ UserManager.getUser().saveSettings();
+ } catch (Throwable th) {
+ th.printStackTrace();
+ }
+ }
+ return true;
+ }
+ });
+
+ PlatformUI.getWorkbench().addWorkbenchListener(new ArtifactSaveNotificationHandler());
+ }
+ }
+
+ public static SkynetGuiPlugin getInstance() {
+ return pluginInstance;
+ }
+
+ @Override
+ protected String getPluginName() {
+ return PLUGIN_ID;
+ }
+
+ public PackageAdmin getPackageAdmin() {
+ return (PackageAdmin) this.packageAdminTracker.getService();
+ }
+
+ public IOseeCachingService getOseeCacheService() {
+ return (IOseeCachingService) cacheServiceTracker.getService();
+ }
+
+ public IOseeDatabaseService getOseeDatabaseService() {
+ return (IOseeDatabaseService) databaseServiceTracker.getService();
+ }
+
+ public IOseeAtsService getOseeAtsService() {
+ return (IOseeAtsService) atsServiceTracker.getService();
+ }
+
+ @Override
+ public void handleBroadcastEvent(Sender sender, final BroadcastEvent broadcastEvent) {
+
+ // Determine whether this is a shutdown event
+ // Prevent shutting down users without a valid message
+ if (broadcastEvent.getBroadcastEventType() == BroadcastEventType.Force_Shutdown) {
+ if (broadcastEvent.getMessage() == null || broadcastEvent.getMessage().length() == 0) {
+ return;
+ }
+ Displays.ensureInDisplayThread(new Runnable() {
+ @Override
+ public void run() {
+ boolean isShutdownRequest = false;
+ try {
+ isShutdownRequest = broadcastEvent.getUsers().contains(UserManager.getUser());
+ } catch (OseeCoreException ex) {
+ // do nothing
+ }
+ if (isShutdownRequest) {
+ MessageDialog.openWarning(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),
+ "Shutdown Requested", broadcastEvent.getMessage());
+ // Shutdown the bench when this event is received
+ PlatformUI.getWorkbench().close();
+ }
+ }
+ });
+ } else if (broadcastEvent.getBroadcastEventType() == BroadcastEventType.Message) {
+ if (broadcastEvent.getMessage() == null || broadcastEvent.getMessage().length() == 0) {
+ return;
+ }
+ Displays.ensureInDisplayThread(new Runnable() {
+ @Override
+ public void run() {
+ MessageDialog.openInformation(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),
+ "Remote Message", broadcastEvent.getMessage());
+ }
+ });
+ } else if (broadcastEvent.getBroadcastEventType() == BroadcastEventType.Ping) {
+ // Another client ping'd this client for session information; Pong back with
+ // original client's session id so it can be identified as the correct pong
+ try {
+ OseeEventManager.kickBroadcastEvent(this, new BroadcastEvent(BroadcastEventType.Pong, null,
+ sender.getOseeSession().toString()));
+ } catch (Exception ex) {
+ OseeLog.log(SkynetGuiPlugin.class, OseeLevel.SEVERE_POPUP, ex);
+ }
+ } else if (broadcastEvent.getBroadcastEventType() == BroadcastEventType.Pong) {
+ // Got pong from another client; If message == this client's sessionId, then it's
+ // the response from this client's ping
+ try {
+ if (broadcastEvent.getMessage() != null && broadcastEvent.getMessage().equals(
+ ClientSessionManager.getSession().toString())) {
+ OseeLog.log(SkynetGuiPlugin.class, Level.INFO, "Pong: " + sender.toString());
+ }
+ } catch (OseeAuthenticationRequiredException ex) {
+ OseeLog.log(SkynetGuiPlugin.class, Level.SEVERE, "Pong: " + sender.toString(), ex);
+ }
+ }
+ }
}
\ No newline at end of file diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/SkynetServiceContributionItem.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/SkynetServiceContributionItem.java index 2ed1430fc80..886b2cd6f83 100644 --- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/SkynetServiceContributionItem.java +++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/SkynetServiceContributionItem.java @@ -18,7 +18,7 @@ import org.eclipse.osee.framework.skynet.core.event.OseeEventManager; import org.eclipse.osee.framework.skynet.core.event.RemoteEventManager; import org.eclipse.osee.framework.skynet.core.event.RemoteEventServiceEventType; import org.eclipse.osee.framework.skynet.core.event.Sender; -import org.eclipse.osee.framework.ui.plugin.util.Displays; +import org.eclipse.osee.framework.ui.swt.Displays; import org.eclipse.osee.framework.ui.swt.ImageManager; import org.eclipse.osee.framework.ui.swt.OverlayImage; import org.eclipse.swt.graphics.Image; diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/WorkspaceContributionItem.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/WorkspaceContributionItem.java index 4ec66398422..eda8b623834 100644 --- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/WorkspaceContributionItem.java +++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/WorkspaceContributionItem.java @@ -14,8 +14,8 @@ import java.io.File; import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.action.IContributionItem;
+import org.eclipse.osee.framework.ui.swt.Displays;
import org.eclipse.swt.program.Program;
-import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.IViewPart;
import org.eclipse.ui.IViewReference;
import org.eclipse.ui.PlatformUI;
@@ -23,61 +23,62 @@ import org.eclipse.ui.part.ViewPart; import org.eclipse.ui.texteditor.StatusLineContributionItem;
public class WorkspaceContributionItem extends StatusLineContributionItem {
- public WorkspaceContributionItem() {
- super("org.eclipse.osee.framework.ui.skynet.workspace.status", true, getShortPath().length() + 5);
- setToolTipText(ResourcesPlugin.getWorkspace().getRoot().getLocation().toOSString());
- setText(getShortPath());
- setActionHandler(new Action() {
- @Override
- public void run() {
- Program.launch(ResourcesPlugin.getWorkspace().getRoot().getLocation().toOSString());
- }
- });
- }
+ public WorkspaceContributionItem() {
+ super("org.eclipse.osee.framework.ui.skynet.workspace.status", true, getShortPath().length() + 5);
+ setToolTipText(ResourcesPlugin.getWorkspace().getRoot().getLocation().toOSString());
+ setText(getShortPath());
+ setActionHandler(new Action() {
+ @Override
+ public void run() {
+ Program.launch(ResourcesPlugin.getWorkspace().getRoot().getLocation().toOSString());
+ }
+ });
+ }
- private static String getShortPath() {
- String path = ResourcesPlugin.getWorkspace().getRoot().getLocation().toString();
- String elements[] = path.split("\\/");
- if (elements.length >= 2) {
- return elements[elements.length - 2] + File.separator + elements[elements.length - 1];
- }
- return path;
- }
+ private static String getShortPath() {
+ String path = ResourcesPlugin.getWorkspace().getRoot().getLocation().toString();
+ String elements[] = path.split("\\/");
+ if (elements.length >= 2) {
+ return elements[elements.length - 2] + File.separator + elements[elements.length - 1];
+ }
+ return path;
+ }
- public static void addToAllViews() {
- Display.getDefault().asyncExec(new Runnable() {
- public void run() {
- try {
- if (PlatformUI.getWorkbench() == null || PlatformUI.getWorkbench().getActiveWorkbenchWindow() == null) {
- return;
- }
- for (IViewReference viewDesc : PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getViewReferences()) {
- IViewPart viewPart = viewDesc.getView(false);
- if (viewPart != null) {
- addToViewpart((ViewPart) viewPart);
- }
- }
- } catch (Exception ex) {
- // DO NOTHING
- }
- }
- });
- }
+ public static void addToAllViews() {
+ Displays.ensureInDisplayThread(new Runnable() {
+ @Override
+ public void run() {
+ try {
+ if (PlatformUI.getWorkbench() == null || PlatformUI.getWorkbench().getActiveWorkbenchWindow() == null) {
+ return;
+ }
+ for (IViewReference viewDesc : PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getViewReferences()) {
+ IViewPart viewPart = viewDesc.getView(false);
+ if (viewPart != null) {
+ addToViewpart((ViewPart) viewPart);
+ }
+ }
+ } catch (Exception ex) {
+ // DO NOTHING
+ }
+ }
+ });
+ }
- public static void addToViewpart(ViewPart viewPart) {
- // Attempt to add to PackageExplorerPart
- try {
- if (viewPart != null) {
- for (IContributionItem item : viewPart.getViewSite().getActionBars().getStatusLineManager().getItems()) {
- if (item instanceof WorkspaceContributionItem) {
- return;
- }
- }
- // System.err.println("Adding to " + viewPart);
- viewPart.getViewSite().getActionBars().getStatusLineManager().add(new WorkspaceContributionItem());
- }
- } catch (Exception ex) {
- // do nothing
- }
- }
+ public static void addToViewpart(ViewPart viewPart) {
+ // Attempt to add to PackageExplorerPart
+ try {
+ if (viewPart != null) {
+ for (IContributionItem item : viewPart.getViewSite().getActionBars().getStatusLineManager().getItems()) {
+ if (item instanceof WorkspaceContributionItem) {
+ return;
+ }
+ }
+ // System.err.println("Adding to " + viewPart);
+ viewPart.getViewSite().getActionBars().getStatusLineManager().add(new WorkspaceContributionItem());
+ }
+ } catch (Exception ex) {
+ // do nothing
+ }
+ }
}
diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/artifact/ArtifactNameConflictHandler.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/artifact/ArtifactNameConflictHandler.java index 226a8028d1e..7985b2fa075 100644 --- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/artifact/ArtifactNameConflictHandler.java +++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/artifact/ArtifactNameConflictHandler.java @@ -10,11 +10,11 @@ *******************************************************************************/
package org.eclipse.osee.framework.ui.skynet.artifact;
-import org.eclipse.core.runtime.CoreException;
import org.eclipse.jface.dialogs.InputDialog;
import org.eclipse.jface.window.Window;
import org.eclipse.osee.framework.jdk.core.type.Pair;
import org.eclipse.osee.framework.skynet.core.types.IArtifact;
+import org.eclipse.osee.framework.ui.swt.Displays;
import org.eclipse.swt.widgets.Display;
/**
@@ -22,26 +22,26 @@ import org.eclipse.swt.widgets.Display; */
public class ArtifactNameConflictHandler {
- public String resolve(IArtifact source) throws CoreException {
- final Pair<String, String> beforeAfterNames = new Pair<String, String>("", "");
- if (source instanceof IArtifact) {
- String startingName = source.getName();
- beforeAfterNames.setFirst(startingName);
- beforeAfterNames.setSecond(startingName);
- }
+ public String resolve(IArtifact source) {
+ final Pair<String, String> beforeAfterNames = new Pair<String, String>("", "");
- Display.getDefault().syncExec(new Runnable() {
- public void run() {
- String startingName = beforeAfterNames.getFirst();
- InputDialog dialog =
- new InputDialog(Display.getCurrent().getActiveShell(), "Name Artifact", "Enter artifact name",
- startingName, new NonBlankAndNotSameAsStartingValidator(startingName));
- int result = dialog.open();
- if (result == Window.OK) {
- beforeAfterNames.setSecond(dialog.getValue());
- }
- }
- });
- return beforeAfterNames.getSecond();
- }
+ String startingName = source.getName();
+ beforeAfterNames.setFirst(startingName);
+ beforeAfterNames.setSecond(startingName);
+
+ Displays.pendInDisplayThread(new Runnable() {
+ @Override
+ public void run() {
+ String startingName = beforeAfterNames.getFirst();
+ InputDialog dialog =
+ new InputDialog(Display.getCurrent().getActiveShell(), "Name Artifact", "Enter artifact name",
+ startingName, new NonBlankAndNotSameAsStartingValidator(startingName));
+ int result = dialog.open();
+ if (result == Window.OK) {
+ beforeAfterNames.setSecond(dialog.getValue());
+ }
+ }
+ });
+ return beforeAfterNames.getSecond();
+ }
}
diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/artifact/NonBlankAndNotSameAsStartingValidator.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/artifact/NonBlankAndNotSameAsStartingValidator.java index a3391658f93..dfd89faf970 100644 --- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/artifact/NonBlankAndNotSameAsStartingValidator.java +++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/artifact/NonBlankAndNotSameAsStartingValidator.java @@ -17,19 +17,20 @@ import org.eclipse.osee.framework.jdk.core.util.Strings; * @author Roberto E. Escobar
*/
public final class NonBlankAndNotSameAsStartingValidator implements IInputValidator {
- private final String startingName;
+ private final String startingName;
- public NonBlankAndNotSameAsStartingValidator(String startingName) {
- this.startingName = startingName;
- }
+ public NonBlankAndNotSameAsStartingValidator(String startingName) {
+ this.startingName = startingName;
+ }
- public String isValid(String newText) {
- String errorMessage = null;
- if (!Strings.isValid(newText)) {
- errorMessage = "The new name cannot be blank";
- } else if (Strings.isValid(startingName) && startingName.equals(newText)) {
- errorMessage = "The new name must be different";
- }
- return errorMessage;
- }
+ @Override
+ public String isValid(String newText) {
+ String errorMessage = null;
+ if (!Strings.isValid(newText)) {
+ errorMessage = "The new name cannot be blank";
+ } else if (Strings.isValid(startingName) && startingName.equals(newText)) {
+ errorMessage = "The new name must be different";
+ }
+ return errorMessage;
+ }
}
\ No newline at end of file diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/artifact/OpenArtifactEditorLoopbackCmd.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/artifact/OpenArtifactEditorLoopbackCmd.java index 09c694f6144..53934b4b0b8 100644 --- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/artifact/OpenArtifactEditorLoopbackCmd.java +++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/artifact/OpenArtifactEditorLoopbackCmd.java @@ -25,7 +25,7 @@ import org.eclipse.osee.framework.ui.plugin.util.AWorkbench; import org.eclipse.osee.framework.ui.skynet.SkynetGuiPlugin;
import org.eclipse.osee.framework.ui.skynet.artifact.editor.ArtifactEditor;
import org.eclipse.osee.framework.ui.skynet.artifact.editor.ArtifactEditorInput;
-import org.eclipse.swt.widgets.Display;
+import org.eclipse.osee.framework.ui.swt.Displays;
import org.eclipse.ui.IEditorPart;
/**
@@ -33,68 +33,69 @@ import org.eclipse.ui.IEditorPart; */
public class OpenArtifactEditorLoopbackCmd extends BaseArtifactLoopbackCmd {
- @Override
- public boolean isApplicable(String cmd) {
- return cmd != null && cmd.equalsIgnoreCase("open.artifact");
- }
+ @Override
+ public boolean isApplicable(String cmd) {
+ return cmd != null && cmd.equalsIgnoreCase("open.artifact");
+ }
- @Override
- public void process(final Artifact artifact, final Map<String, String> parameters, final HttpResponse httpResponse) {
- if (artifact != null) {
- try {
- boolean hasPermissionToRead = false;
- try {
- hasPermissionToRead = AccessControlManager.hasPermission(artifact, PermissionEnum.READ);
- } catch (Exception ex) {
- OseeLog.log(SkynetGuiPlugin.class, Level.SEVERE, ex);
- }
+ @Override
+ public void process(final Artifact artifact, final Map<String, String> parameters, final HttpResponse httpResponse) {
+ if (artifact != null) {
+ try {
+ boolean hasPermissionToRead = false;
+ try {
+ hasPermissionToRead = AccessControlManager.hasPermission(artifact, PermissionEnum.READ);
+ } catch (Exception ex) {
+ OseeLog.log(SkynetGuiPlugin.class, Level.SEVERE, ex);
+ }
- if (!hasPermissionToRead) {
- httpResponse.outputStandardError(HttpURLConnection.HTTP_UNAUTHORIZED, String.format(
- "Access denied - User does not have read access to [%s]", artifact));
- } else {
- final MutableBoolean isDone = new MutableBoolean(false);
+ if (!hasPermissionToRead) {
+ httpResponse.outputStandardError(HttpURLConnection.HTTP_UNAUTHORIZED,
+ String.format("Access denied - User does not have read access to [%s]", artifact));
+ } else {
+ final MutableBoolean isDone = new MutableBoolean(false);
- Display.getDefault().asyncExec(new Runnable() {
- public void run() {
- try {
- IEditorPart part =
- AWorkbench.getActivePage().openEditor(new ArtifactEditorInput(artifact),
- ArtifactEditor.EDITOR_ID, true);
- if (part != null) {
- String html =
- AHTML.simplePage(artifact.getName() + " has been opened in OSEE on branch " + artifact.getBranch() + "<br><br>" + "<form><input type=button onClick='window.opener=self;window.close()' value='Close'></form>");
- httpResponse.getPrintStream().println(html);
- } else {
- httpResponse.outputStandardError(HttpURLConnection.HTTP_INTERNAL_ERROR, String.format(
- "Unable to open: [%s]", artifact.getName()));
- }
- } catch (Exception ex) {
- OseeLog.log(SkynetGuiPlugin.class, Level.SEVERE, ex);
- httpResponse.outputStandardError(HttpURLConnection.HTTP_INTERNAL_ERROR, String.format(
- "Unable to open: [%s]", artifact.getName()), ex);
- } finally {
- isDone.setValue(true);
- }
- }
- });
+ Displays.ensureInDisplayThread(new Runnable() {
+ @Override
+ public void run() {
+ try {
+ IEditorPart part =
+ AWorkbench.getActivePage().openEditor(new ArtifactEditorInput(artifact),
+ ArtifactEditor.EDITOR_ID, true);
+ if (part != null) {
+ String html =
+ AHTML.simplePage(artifact.getName() + " has been opened in OSEE on branch " + artifact.getBranch() + "<br><br>" + "<form><input type=button onClick='window.opener=self;window.close()' value='Close'></form>");
+ httpResponse.getPrintStream().println(html);
+ } else {
+ httpResponse.outputStandardError(HttpURLConnection.HTTP_INTERNAL_ERROR,
+ String.format("Unable to open: [%s]", artifact.getName()));
+ }
+ } catch (Exception ex) {
+ OseeLog.log(SkynetGuiPlugin.class, Level.SEVERE, ex);
+ httpResponse.outputStandardError(HttpURLConnection.HTTP_INTERNAL_ERROR,
+ String.format("Unable to open: [%s]", artifact.getName()), ex);
+ } finally {
+ isDone.setValue(true);
+ }
+ }
+ });
- int count = 1;
- while (!isDone.getValue() && count < 30) {
- try {
- Thread.sleep(350);
- } catch (InterruptedException ex) {
- }
- count++;
- }
- }
- } catch (Exception ex) {
- OseeLog.log(SkynetGuiPlugin.class, Level.SEVERE, ex);
- httpResponse.outputStandardError(HttpURLConnection.HTTP_INTERNAL_ERROR, String.format(
- "Unable to open: [%s]", artifact.getName()), ex);
- }
- } else {
- httpResponse.outputStandardError(HttpURLConnection.HTTP_BAD_REQUEST, "Unable to open null artifact");
- }
- }
+ int count = 1;
+ while (!isDone.getValue() && count < 30) {
+ try {
+ Thread.sleep(350);
+ } catch (InterruptedException ex) {
+ }
+ count++;
+ }
+ }
+ } catch (Exception ex) {
+ OseeLog.log(SkynetGuiPlugin.class, Level.SEVERE, ex);
+ httpResponse.outputStandardError(HttpURLConnection.HTTP_INTERNAL_ERROR,
+ String.format("Unable to open: [%s]", artifact.getName()), ex);
+ }
+ } else {
+ httpResponse.outputStandardError(HttpURLConnection.HTTP_BAD_REQUEST, "Unable to open null artifact");
+ }
+ }
}
diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/artifact/annotation/AttributeAnnotationHandler.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/artifact/annotation/AttributeAnnotationHandler.java index 75cfb562ebf..e5bc5b7dc7f 100644 --- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/artifact/annotation/AttributeAnnotationHandler.java +++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/artifact/annotation/AttributeAnnotationHandler.java @@ -26,14 +26,15 @@ import org.eclipse.osee.framework.ui.skynet.SkynetGuiPlugin; */ public class AttributeAnnotationHandler implements IArtifactAnnotation { - public void getAnnotations(Artifact artifact, Set<ArtifactAnnotation> annotations) { - try { - if (artifact.isAttributeTypeValid(CoreAttributeTypes.Annotation)) { - AttributeAnnotationManager mgr = new AttributeAnnotationManager(artifact); - annotations.addAll(mgr.getAnnotations()); - } - } catch (OseeCoreException ex) { - OseeLog.log(SkynetGuiPlugin.class, Level.SEVERE, ex); - } - } + @Override + public void getAnnotations(Artifact artifact, Set<ArtifactAnnotation> annotations) { + try { + if (artifact.isAttributeTypeValid(CoreAttributeTypes.Annotation)) { + AttributeAnnotationManager mgr = new AttributeAnnotationManager(artifact); + annotations.addAll(mgr.getAnnotations()); + } + } catch (OseeCoreException ex) { + OseeLog.log(SkynetGuiPlugin.class, Level.SEVERE, ex); + } + } } diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/artifact/editor/AbstractArtifactEditor.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/artifact/editor/AbstractArtifactEditor.java index 8267ded2000..8d2aecbff14 100644 --- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/artifact/editor/AbstractArtifactEditor.java +++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/artifact/editor/AbstractArtifactEditor.java @@ -30,69 +30,70 @@ import org.eclipse.ui.forms.editor.FormEditor; */ public abstract class AbstractArtifactEditor extends FormEditor implements IDirtiableEditor { - private final static Object[] EMPTY_ARRAY = new Object[0]; - - @Override - protected XFormToolkit createToolkit(Display display) { - // Create a toolkit that shares colors between editors. - // the toolkit will be disposed by the super class (FormEditor) - return new XFormToolkit(SkynetGuiPlugin.getInstance().getSharedFormColors(display)); - } - - @Override - public void doSave(IProgressMonitor monitor) { - } - - @Override - public void doSaveAs() { - } - - @Override - public boolean isSaveAsAllowed() { - return false; - } - - public void onDirtied() { - } - - @Override - public XFormToolkit getToolkit() { - return (XFormToolkit) super.getToolkit(); - } - - public Artifact getArtifactFromEditorInput() { - return (Artifact) getEditorInput().getAdapter(Artifact.class); - } - - @Override - public void init(IEditorSite site, IEditorInput input) throws PartInitException { - super.init(site, input); - ISelectionProvider provider = new ArtifactEditorSelectionProvider(); - Artifact artifact = getArtifactFromEditorInput(); - Object[] selected = artifact != null ? new Object[] {artifact} : EMPTY_ARRAY; - provider.setSelection(new StructuredSelection(selected)); - getSite().setSelectionProvider(provider); - } - - private final class ArtifactEditorSelectionProvider implements ISelectionProvider { - private ISelection selection; - - @Override - public void addSelectionChangedListener(ISelectionChangedListener listener) { - } - - @Override - public ISelection getSelection() { - return selection; - } - - @Override - public void removeSelectionChangedListener(ISelectionChangedListener listener) { - } - - @Override - public void setSelection(ISelection selection) { - this.selection = selection; - } - } + private final static Object[] EMPTY_ARRAY = new Object[0]; + + @Override + protected XFormToolkit createToolkit(Display display) { + // Create a toolkit that shares colors between editors. + // the toolkit will be disposed by the super class (FormEditor) + return new XFormToolkit(SkynetGuiPlugin.getInstance().getSharedFormColors(display)); + } + + @Override + public void doSave(IProgressMonitor monitor) { + } + + @Override + public void doSaveAs() { + } + + @Override + public boolean isSaveAsAllowed() { + return false; + } + + @Override + public void onDirtied() { + } + + @Override + public XFormToolkit getToolkit() { + return (XFormToolkit) super.getToolkit(); + } + + public Artifact getArtifactFromEditorInput() { + return (Artifact) getEditorInput().getAdapter(Artifact.class); + } + + @Override + public void init(IEditorSite site, IEditorInput input) throws PartInitException { + super.init(site, input); + ISelectionProvider provider = new ArtifactEditorSelectionProvider(); + Artifact artifact = getArtifactFromEditorInput(); + Object[] selected = artifact != null ? new Object[] {artifact} : EMPTY_ARRAY; + provider.setSelection(new StructuredSelection(selected)); + getSite().setSelectionProvider(provider); + } + + private final class ArtifactEditorSelectionProvider implements ISelectionProvider { + private ISelection selection; + + @Override + public void addSelectionChangedListener(ISelectionChangedListener listener) { + } + + @Override + public ISelection getSelection() { + return selection; + } + + @Override + public void removeSelectionChangedListener(ISelectionChangedListener listener) { + } + + @Override + public void setSelection(ISelection selection) { + this.selection = selection; + } + } }
\ No newline at end of file diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/artifact/editor/AbstractEventArtifactEditor.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/artifact/editor/AbstractEventArtifactEditor.java index 5af7b269b7a..74958fca310 100644 --- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/artifact/editor/AbstractEventArtifactEditor.java +++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/artifact/editor/AbstractEventArtifactEditor.java @@ -27,9 +27,9 @@ import org.eclipse.osee.framework.skynet.core.event.Sender; import org.eclipse.osee.framework.skynet.core.event2.AccessControlEvent;
import org.eclipse.osee.framework.skynet.core.event2.BranchEvent;
import org.eclipse.osee.framework.skynet.core.utility.LoadedArtifacts;
-import org.eclipse.osee.framework.ui.plugin.util.Displays;
import org.eclipse.osee.framework.ui.skynet.ArtifactImageManager;
import org.eclipse.osee.framework.ui.skynet.SkynetGuiPlugin;
+import org.eclipse.osee.framework.ui.swt.Displays;
import org.eclipse.swt.graphics.Image;
/**
@@ -37,162 +37,166 @@ import org.eclipse.swt.graphics.Image; */
public abstract class AbstractEventArtifactEditor extends AbstractArtifactEditor implements IArtifactEditorEventHandler {
- private final InternalEventHandler internalEventHandler;
-
- public AbstractEventArtifactEditor() {
- super();
- if (OseeEventManager.isOldEvents()) {
- internalEventHandler = new InternalEventHandler();
- OseeEventManager.addListener(internalEventHandler);
- } else {
- internalEventHandler = null;
- ArtifactEditorEventManager.add(this);
- }
- }
-
- @Override
- protected void addPages() {
- }
-
- @Override
- public boolean isDirty() {
- boolean wasDirty = false;
- Artifact artifact = getArtifactFromEditorInput();
- if (artifact != null) {
- if (!artifact.isDeleted()) {
- wasDirty = super.isDirty() || artifact.isDirty();
- }
- }
- return wasDirty;
- }
-
- protected abstract void checkEnabledTooltems();
-
- public abstract void refreshDirtyArtifact();
-
- public abstract void closeEditor();
-
- public abstract void refreshRelations();
-
- public void setMainImage(Image titleImage) {
- super.setTitleImage(titleImage);
- }
-
- @Override
- public void dispose() {
- super.dispose();
- if (OseeEventManager.isOldEvents()) {
- OseeEventManager.removeListener(internalEventHandler);
- }
- }
-
- @Override
- public AbstractEventArtifactEditor getEditor() {
- return this;
- }
-
- /**
- * <REM2> this entire listener can be removed cause handled through ArtifactEditorEventManager
- *
- * @author Donald G. Dunne
- */
- private final class InternalEventHandler implements IArtifactsPurgedEventListener, IBranchEventListener, IAccessControlEventListener, IArtifactsChangeTypeEventListener, IFrameworkTransactionEventListener {
-
- @Override
- public void handleArtifactsChangeTypeEvent(Sender sender, int toArtifactTypeId, final LoadedArtifacts loadedArtifacts) {
- Displays.ensureInDisplayThread(new Runnable() {
- @Override
- public void run() {
- try {
- Artifact localArtifact = getArtifactFromEditorInput();
- if (loadedArtifacts.getLoadedArtifacts().contains(localArtifact)) {
- closeEditor();
- }
- } catch (OseeCoreException ex) {
- OseeLog.log(SkynetGuiPlugin.class, Level.SEVERE, ex);
- }
- }
- });
- }
-
- @Override
- public void handleFrameworkTransactionEvent(Sender sender, final FrameworkTransactionData transData) throws OseeCoreException {
- Displays.ensureInDisplayThread(new Runnable() {
- @Override
- public void run() {
- Artifact localArtifact = getArtifactFromEditorInput();
- if (!transData.isHasEvent(localArtifact)) {
- return;
- }
- if (transData.isDeleted(localArtifact)) {
- closeEditor();
- }
- if (transData.isRelAddedChangedDeleted(localArtifact)) {
- refreshRelations();
- }
- if (transData.isChanged(localArtifact)) {
- refreshDirtyArtifact();
- }
- onDirtied();
- }
- });
- }
-
- @Override
- public void handleArtifactsPurgedEvent(Sender sender, final LoadedArtifacts loadedArtifacts) throws OseeCoreException {
- Displays.ensureInDisplayThread(new Runnable() {
- @Override
- public void run() {
- try {
- if (loadedArtifacts.getLoadedArtifacts().contains(getArtifactFromEditorInput())) {
- closeEditor();
- }
- } catch (OseeCoreException ex) {
- OseeLog.log(SkynetGuiPlugin.class, Level.SEVERE, ex);
- }
- }
- });
- }
-
- @Override
- public void handleBranchEventREM1(Sender sender, final BranchEventType branchModType, final int branchId) {
- Displays.ensureInDisplayThread(new Runnable() {
- @Override
- public void run() {
- if (branchModType == BranchEventType.Committed) {
- if (getArtifactFromEditorInput().getBranch().getId() == branchId) {
- closeEditor();
- }
- }
- }
- });
- }
-
- @Override
- public void handleAccessControlArtifactsEvent(Sender sender, AccessControlEvent accessControlEvent) {
- try {
- if (accessControlEvent.getEventType() == AccessControlEventType.ArtifactsLocked || accessControlEvent.getEventType() == AccessControlEventType.ArtifactsUnlocked) {
- if (accessControlEvent.getArtifacts().contains(getArtifactFromEditorInput())) {
- Displays.ensureInDisplayThread(new Runnable() {
- @Override
- public void run() {
- setTitleImage(ArtifactImageManager.getImage(getArtifactFromEditorInput()));
- }
- });
- }
- }
- } catch (Exception ex) {
- // do nothing
- }
- }
-
- @Override
- public void handleBranchEvent(Sender sender, final BranchEvent branchEvent) {
- // Handled by ArtifactEditorEventManager
- }
-
- @Override
- public void handleLocalBranchToArtifactCacheUpdateEvent(Sender sender) {
- }
- }
+ private final InternalEventHandler internalEventHandler;
+
+ public AbstractEventArtifactEditor() {
+ super();
+ if (OseeEventManager.isOldEvents()) {
+ internalEventHandler = new InternalEventHandler();
+ OseeEventManager.addListener(internalEventHandler);
+ } else {
+ internalEventHandler = null;
+ ArtifactEditorEventManager.add(this);
+ }
+ }
+
+ @Override
+ protected void addPages() {
+ }
+
+ @Override
+ public boolean isDirty() {
+ boolean wasDirty = false;
+ Artifact artifact = getArtifactFromEditorInput();
+ if (artifact != null) {
+ if (!artifact.isDeleted()) {
+ wasDirty = super.isDirty() || artifact.isDirty();
+ }
+ }
+ return wasDirty;
+ }
+
+ protected abstract void checkEnabledTooltems();
+
+ @Override
+ public abstract void refreshDirtyArtifact();
+
+ @Override
+ public abstract void closeEditor();
+
+ @Override
+ public abstract void refreshRelations();
+
+ @Override
+ public void setMainImage(Image titleImage) {
+ super.setTitleImage(titleImage);
+ }
+
+ @Override
+ public void dispose() {
+ super.dispose();
+ if (OseeEventManager.isOldEvents()) {
+ OseeEventManager.removeListener(internalEventHandler);
+ }
+ }
+
+ @Override
+ public AbstractEventArtifactEditor getEditor() {
+ return this;
+ }
+
+ /**
+ * <REM2> this entire listener can be removed cause handled through ArtifactEditorEventManager
+ *
+ * @author Donald G. Dunne
+ */
+ private final class InternalEventHandler implements IArtifactsPurgedEventListener, IBranchEventListener, IAccessControlEventListener, IArtifactsChangeTypeEventListener, IFrameworkTransactionEventListener {
+
+ @Override
+ public void handleArtifactsChangeTypeEvent(Sender sender, int toArtifactTypeId, final LoadedArtifacts loadedArtifacts) {
+ Displays.ensureInDisplayThread(new Runnable() {
+ @Override
+ public void run() {
+ try {
+ Artifact localArtifact = getArtifactFromEditorInput();
+ if (loadedArtifacts.getLoadedArtifacts().contains(localArtifact)) {
+ closeEditor();
+ }
+ } catch (OseeCoreException ex) {
+ OseeLog.log(SkynetGuiPlugin.class, Level.SEVERE, ex);
+ }
+ }
+ });
+ }
+
+ @Override
+ public void handleFrameworkTransactionEvent(Sender sender, final FrameworkTransactionData transData) {
+ Displays.ensureInDisplayThread(new Runnable() {
+ @Override
+ public void run() {
+ Artifact localArtifact = getArtifactFromEditorInput();
+ if (!transData.isHasEvent(localArtifact)) {
+ return;
+ }
+ if (transData.isDeleted(localArtifact)) {
+ closeEditor();
+ }
+ if (transData.isRelAddedChangedDeleted(localArtifact)) {
+ refreshRelations();
+ }
+ if (transData.isChanged(localArtifact)) {
+ refreshDirtyArtifact();
+ }
+ onDirtied();
+ }
+ });
+ }
+
+ @Override
+ public void handleArtifactsPurgedEvent(Sender sender, final LoadedArtifacts loadedArtifacts) {
+ Displays.ensureInDisplayThread(new Runnable() {
+ @Override
+ public void run() {
+ try {
+ if (loadedArtifacts.getLoadedArtifacts().contains(getArtifactFromEditorInput())) {
+ closeEditor();
+ }
+ } catch (OseeCoreException ex) {
+ OseeLog.log(SkynetGuiPlugin.class, Level.SEVERE, ex);
+ }
+ }
+ });
+ }
+
+ @Override
+ public void handleBranchEventREM1(Sender sender, final BranchEventType branchModType, final int branchId) {
+ Displays.ensureInDisplayThread(new Runnable() {
+ @Override
+ public void run() {
+ if (branchModType == BranchEventType.Committed) {
+ if (getArtifactFromEditorInput().getBranch().getId() == branchId) {
+ closeEditor();
+ }
+ }
+ }
+ });
+ }
+
+ @Override
+ public void handleAccessControlArtifactsEvent(Sender sender, AccessControlEvent accessControlEvent) {
+ try {
+ if (accessControlEvent.getEventType() == AccessControlEventType.ArtifactsLocked || accessControlEvent.getEventType() == AccessControlEventType.ArtifactsUnlocked) {
+ if (accessControlEvent.getArtifacts().contains(getArtifactFromEditorInput())) {
+ Displays.ensureInDisplayThread(new Runnable() {
+ @Override
+ public void run() {
+ setTitleImage(ArtifactImageManager.getImage(getArtifactFromEditorInput()));
+ }
+ });
+ }
+ }
+ } catch (Exception ex) {
+ // do nothing
+ }
+ }
+
+ @Override
+ public void handleBranchEvent(Sender sender, final BranchEvent branchEvent) {
+ // Handled by ArtifactEditorEventManager
+ }
+
+ @Override
+ public void handleLocalBranchToArtifactCacheUpdateEvent(Sender sender) {
+ }
+ }
}
diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/artifact/editor/ArtifactEditor.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/artifact/editor/ArtifactEditor.java index 888f6d3bdf7..a543bf2c1b0 100644 --- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/artifact/editor/ArtifactEditor.java +++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/artifact/editor/ArtifactEditor.java @@ -22,14 +22,13 @@ import org.eclipse.osee.framework.plugin.core.IActionable; import org.eclipse.osee.framework.plugin.core.util.Jobs;
import org.eclipse.osee.framework.skynet.core.artifact.Artifact;
import org.eclipse.osee.framework.ui.plugin.util.AWorkbench;
-import org.eclipse.osee.framework.ui.plugin.util.Displays;
import org.eclipse.osee.framework.ui.skynet.OseeContributionItem;
import org.eclipse.osee.framework.ui.skynet.RelationsComposite;
import org.eclipse.osee.framework.ui.skynet.SkynetGuiPlugin;
import org.eclipse.osee.framework.ui.skynet.artifact.editor.pages.ArtifactEditorOutlinePage;
import org.eclipse.osee.framework.ui.skynet.artifact.editor.pages.ArtifactFormPage;
+import org.eclipse.osee.framework.ui.swt.Displays;
import org.eclipse.osee.framework.ui.swt.Widgets;
-import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.PartInitException;
import org.eclipse.ui.progress.UIJob;
import org.eclipse.ui.views.contentoutline.IContentOutlinePage;
@@ -38,215 +37,217 @@ import org.eclipse.ui.views.contentoutline.IContentOutlinePage; * @author Roberto E. Escobar
*/
public class ArtifactEditor extends AbstractEventArtifactEditor {
- public static final String EDITOR_ID = "org.eclipse.osee.framework.ui.skynet.artifact.editor.ArtifactEditor";
-
- private IActionContributor actionBarContributor;
- private ArtifactFormPage formPage;
- private ArtifactEditorOutlinePage outlinePage;
-
- public ArtifactEditor() {
- super();
- }
-
- public IActionContributor getActionBarContributor() {
- if (actionBarContributor == null) {
- actionBarContributor = new ArtifactEditorActionBarContributor(this);
- }
- return actionBarContributor;
- }
-
- @Override
- public BaseArtifactEditorInput getEditorInput() {
- return (BaseArtifactEditorInput) super.getEditorInput();
- }
-
- @Override
- public void onDirtied() {
- Display.getDefault().asyncExec(new Runnable() {
- public void run() {
- firePropertyChange(PROP_DIRTY);
- }
- });
- }
-
- @Override
- public void showBusy(boolean busy) {
- super.showBusy(busy);
- ArtifactFormPage page = getFormPage();
- if (page != null) {
- page.showBusy(busy);
- }
- }
-
- @Override
- public void doSave(IProgressMonitor monitor) {
- try {
- getFormPage().doSave(monitor);
- Artifact artifact = getEditorInput().getArtifact();
- artifact.persist();
- firePropertyChange(PROP_DIRTY);
- } catch (OseeCoreException ex) {
- onDirtied();
- OseeLog.log(SkynetGuiPlugin.class, Level.SEVERE, ex);
- }
- }
-
- @Override
- public void dispose() {
- try {
- // If the artifact is dirty when the editor gets disposed, then it needs to be reverted
- Artifact artifact = getEditorInput().getArtifact();
- if (!artifact.isDeleted() && artifact.isDirty()) {
- try {
- artifact.reloadAttributesAndRelations();
- } catch (OseeCoreException ex) {
- OseeLog.log(SkynetGuiPlugin.class, Level.SEVERE, ex);
- }
- }
- } catch (Exception ex) {
- OseeLog.log(SkynetGuiPlugin.class, Level.SEVERE, ex);
- } finally {
- super.dispose();
- }
- }
-
- @Override
- protected void checkEnabledTooltems() {
- // if (!attributeComposite.isDisposed()) {
- // Display.getDefault().asyncExec(new Runnable() {
- // public void run() {
- // boolean isEditAllowed = artifact.isReadOnly() != true;
- //
- // if (attributeComposite.getToolBar() == null || attributeComposite.getToolBar().isDisposed()) {
- // return;
- // }
- // attributeComposite.getToolBar().getItem(REVEAL_ARTIFACT_INDEX).setEnabled(true);
- // attributeComposite.getToolBar().getItem(EDIT_ARTIFACT_INDEX).setEnabled(isEditAllowed);
- // attributeComposite.getToolBar().update();
- //
- // relationsComposite.getToolBar().getItem(REVEAL_ARTIFACT_INDEX).setEnabled(true);
- // relationsComposite.getToolBar().getItem(EDIT_ARTIFACT_INDEX).setEnabled(isEditAllowed);
- // relationsComposite.getToolBar().update();
- // }
- // });
- // }
- }
-
- @Override
- public void closeEditor() {
- Displays.ensureInDisplayThread(new Runnable() {
- @Override
- public void run() {
- AWorkbench.getActivePage().closeEditor(ArtifactEditor.this, false);
- }
- });
- }
-
- @Override
- public void refreshDirtyArtifact() {
- Jobs.startJob(new RefreshDirtyArtifactJob());
- }
-
- @Override
- public void refreshRelations() {
- Jobs.startJob(new RefreshRelations());
- }
-
- @Override
- protected void addPages() {
- OseeContributionItem.addTo(this, true);
- setPartName(getEditorInput().getName());
- setTitleImage(getEditorInput().getImage());
-
- formPage = new ArtifactFormPage(this, "ArtifactFormPage", null);
- try {
- addPage(formPage);
- } catch (PartInitException ex) {
- OseeLog.log(SkynetGuiPlugin.class, OseeLevel.SEVERE_POPUP, ex);
- }
- }
-
- private ArtifactFormPage getFormPage() {
- return formPage;
- }
-
- @SuppressWarnings("rawtypes")
- @Override
- public Object getAdapter(Class adapter) {
- if (adapter == IActionable.class) {
- return new IActionable() {
- @Override
- public String getActionDescription() {
- return "";
- }
- };
- } else if (adapter == IContentOutlinePage.class) {
- ArtifactEditorOutlinePage page = getOutlinePage();
- page.setInput(this);
- return page;
- } else if (adapter == RelationsComposite.class) {
- return getFormPage().getRelationsComposite();
- }
- return super.getAdapter(adapter);
- }
-
- protected ArtifactEditorOutlinePage getOutlinePage() {
- if (outlinePage == null) {
- outlinePage = new ArtifactEditorOutlinePage();
- }
- return outlinePage;
- }
-
- private final class RefreshRelations extends UIJob {
- public RefreshRelations() {
- super("Refresh Relations");
- }
-
- @Override
- public IStatus runInUIThread(IProgressMonitor monitor) {
- ArtifactFormPage page = getFormPage();
- if (page != null) {
- page.showBusy(true);
- RelationsComposite relationsComposite = page.getRelationsComposite();
- if (relationsComposite != null && !relationsComposite.isDisposed()) {
- relationsComposite.refresh();
- onDirtied();
- }
- page.showBusy(false);
- }
- return Status.OK_STATUS;
- }
- }
-
- private final class RefreshDirtyArtifactJob extends UIJob {
-
- public RefreshDirtyArtifactJob() {
- super("Refresh Dirty Artifact");
- }
-
- @Override
- public IStatus runInUIThread(IProgressMonitor monitor) {
- try {
- setPartName(getEditorInput().getName());
- setTitleImage(getEditorInput().getImage());
- ArtifactEditorOutlinePage outlinePage = getOutlinePage();
- if (outlinePage != null) {
- outlinePage.refresh();
- }
- ArtifactFormPage page = getFormPage();
- if (page != null && Widgets.isAccessible(page.getPartControl())) {
- page.refresh();
- }
- onDirtied();
- } catch (Exception ex) {
- OseeLog.log(SkynetGuiPlugin.class, Level.SEVERE, ex);
- }
- return Status.OK_STATUS;
- }
- }
-
- @Override
- public boolean isDisposed() {
- return formPage == null || formPage.getPartControl() == null || formPage.getPartControl().isDisposed();
- }
+ public static final String EDITOR_ID = "org.eclipse.osee.framework.ui.skynet.artifact.editor.ArtifactEditor";
+
+ private IActionContributor actionBarContributor;
+ private ArtifactFormPage formPage;
+ private ArtifactEditorOutlinePage outlinePage;
+
+ public ArtifactEditor() {
+ super();
+ }
+
+ public IActionContributor getActionBarContributor() {
+ if (actionBarContributor == null) {
+ actionBarContributor = new ArtifactEditorActionBarContributor(this);
+ }
+ return actionBarContributor;
+ }
+
+ @Override
+ public BaseArtifactEditorInput getEditorInput() {
+ return (BaseArtifactEditorInput) super.getEditorInput();
+ }
+
+ @Override
+ public void onDirtied() {
+ Displays.ensureInDisplayThread(new Runnable() {
+ @Override
+ public void run() {
+ firePropertyChange(PROP_DIRTY);
+ }
+ });
+ }
+
+ @Override
+ public void showBusy(boolean busy) {
+ super.showBusy(busy);
+ ArtifactFormPage page = getFormPage();
+ if (page != null) {
+ page.showBusy(busy);
+ }
+ }
+
+ @Override
+ public void doSave(IProgressMonitor monitor) {
+ try {
+ getFormPage().doSave(monitor);
+ Artifact artifact = getEditorInput().getArtifact();
+ artifact.persist();
+ firePropertyChange(PROP_DIRTY);
+ } catch (OseeCoreException ex) {
+ onDirtied();
+ OseeLog.log(SkynetGuiPlugin.class, Level.SEVERE, ex);
+ }
+ }
+
+ @Override
+ public void dispose() {
+ try {
+ // If the artifact is dirty when the editor gets disposed, then it needs to be reverted
+ Artifact artifact = getEditorInput().getArtifact();
+ if (!artifact.isDeleted() && artifact.isDirty()) {
+ try {
+ artifact.reloadAttributesAndRelations();
+ } catch (OseeCoreException ex) {
+ OseeLog.log(SkynetGuiPlugin.class, Level.SEVERE, ex);
+ }
+ }
+ } catch (Exception ex) {
+ OseeLog.log(SkynetGuiPlugin.class, Level.SEVERE, ex);
+ } finally {
+ super.dispose();
+ }
+ }
+
+ @Override
+ protected void checkEnabledTooltems() {
+ // if (!attributeComposite.isDisposed()) {
+ // Displays.ensureInDisplayThread(new Runnable() {
+ // @Override
+ // public void run() {
+ // boolean isEditAllowed = artifact.isReadOnly() != true;
+ //
+ // if (attributeComposite.getToolBar() == null || attributeComposite.getToolBar().isDisposed()) {
+ // return;
+ // }
+ // attributeComposite.getToolBar().getItem(REVEAL_ARTIFACT_INDEX).setEnabled(true);
+ // attributeComposite.getToolBar().getItem(EDIT_ARTIFACT_INDEX).setEnabled(isEditAllowed);
+ // attributeComposite.getToolBar().update();
+ //
+ // relationsComposite.getToolBar().getItem(REVEAL_ARTIFACT_INDEX).setEnabled(true);
+ // relationsComposite.getToolBar().getItem(EDIT_ARTIFACT_INDEX).setEnabled(isEditAllowed);
+ // relationsComposite.getToolBar().update();
+ // }
+ // });
+ // }
+ }
+
+ @Override
+ public void closeEditor() {
+ Displays.ensureInDisplayThread(new Runnable() {
+ @Override
+ public void run() {
+ AWorkbench.getActivePage().closeEditor(ArtifactEditor.this, false);
+ }
+ });
+ }
+
+ @Override
+ public void refreshDirtyArtifact() {
+ Jobs.startJob(new RefreshDirtyArtifactJob());
+ }
+
+ @Override
+ public void refreshRelations() {
+ Jobs.startJob(new RefreshRelations());
+ }
+
+ @Override
+ protected void addPages() {
+ OseeContributionItem.addTo(this, true);
+ setPartName(getEditorInput().getName());
+ setTitleImage(getEditorInput().getImage());
+
+ formPage = new ArtifactFormPage(this, "ArtifactFormPage", null);
+ try {
+ addPage(formPage);
+ } catch (PartInitException ex) {
+ OseeLog.log(SkynetGuiPlugin.class, OseeLevel.SEVERE_POPUP, ex);
+ }
+ }
+
+ private ArtifactFormPage getFormPage() {
+ return formPage;
+ }
+
+ @SuppressWarnings("rawtypes")
+ @Override
+ public Object getAdapter(Class adapter) {
+ if (adapter == IActionable.class) {
+ return new IActionable() {
+ @Override
+ public String getActionDescription() {
+ return "";
+ }
+ };
+ } else if (adapter == IContentOutlinePage.class) {
+ ArtifactEditorOutlinePage page = getOutlinePage();
+ page.setInput(this);
+ return page;
+ } else if (adapter == RelationsComposite.class) {
+ return getFormPage().getRelationsComposite();
+ }
+ return super.getAdapter(adapter);
+ }
+
+ protected ArtifactEditorOutlinePage getOutlinePage() {
+ if (outlinePage == null) {
+ outlinePage = new ArtifactEditorOutlinePage();
+ }
+ return outlinePage;
+ }
+
+ private final class RefreshRelations extends UIJob {
+ public RefreshRelations() {
+ super("Refresh Relations");
+ }
+
+ @Override
+ public IStatus runInUIThread(IProgressMonitor monitor) {
+ ArtifactFormPage page = getFormPage();
+ if (page != null) {
+ page.showBusy(true);
+ RelationsComposite relationsComposite = page.getRelationsComposite();
+ if (relationsComposite != null && !relationsComposite.isDisposed()) {
+ relationsComposite.refresh();
+ onDirtied();
+ }
+ page.showBusy(false);
+ }
+ return Status.OK_STATUS;
+ }
+ }
+
+ private final class RefreshDirtyArtifactJob extends UIJob {
+
+ public RefreshDirtyArtifactJob() {
+ super("Refresh Dirty Artifact");
+ }
+
+ @Override
+ public IStatus runInUIThread(IProgressMonitor monitor) {
+ try {
+ setPartName(getEditorInput().getName());
+ setTitleImage(getEditorInput().getImage());
+ ArtifactEditorOutlinePage outlinePage = getOutlinePage();
+ if (outlinePage != null) {
+ outlinePage.refresh();
+ }
+ ArtifactFormPage page = getFormPage();
+ if (page != null && Widgets.isAccessible(page.getPartControl())) {
+ page.refresh();
+ }
+ onDirtied();
+ } catch (Exception ex) {
+ OseeLog.log(SkynetGuiPlugin.class, Level.SEVERE, ex);
+ }
+ return Status.OK_STATUS;
+ }
+ }
+
+ @Override
+ public boolean isDisposed() {
+ return formPage == null || formPage.getPartControl() == null || formPage.getPartControl().isDisposed();
+ }
}
\ No newline at end of file diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/artifact/editor/ArtifactEditorActionBarContributor.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/artifact/editor/ArtifactEditorActionBarContributor.java index 83dedf40c93..49608fac57a 100644 --- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/artifact/editor/ArtifactEditorActionBarContributor.java +++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/artifact/editor/ArtifactEditorActionBarContributor.java @@ -50,224 +50,230 @@ import org.eclipse.ui.PlatformUI; */
public class ArtifactEditorActionBarContributor implements IActionContributor {
- private final AbstractArtifactEditor editor;
+ private final AbstractArtifactEditor editor;
- public ArtifactEditorActionBarContributor(AbstractArtifactEditor editor) {
- this.editor = editor;
- }
+ public ArtifactEditorActionBarContributor(AbstractArtifactEditor editor) {
+ this.editor = editor;
+ }
- public void contributeToToolBar(IToolBarManager manager) {
- manager.add(createAtsBugAction());
- manager.add(new Separator());
- addOpenWithContributionItem(manager);
- manager.add(new DeleteArtifactAction());
- manager.add(new Separator());
- manager.add(new OpenOutlineAction());
- manager.add(new OpenHistoryAction());
- manager.add(new RevealInExplorerAction());
- manager.add(new RevealBranchAction());
- manager.add(new Separator());
- manager.add(new AccessControlAction());
- manager.add(new Separator());
- manager.add(new CopyArtifactURLAction());
- manager.add(new Separator());
- manager.add(new DirtyReportAction(editor.getArtifactFromEditorInput()));
- }
+ @Override
+ public void contributeToToolBar(IToolBarManager manager) {
+ manager.add(createAtsBugAction());
+ manager.add(new Separator());
+ addOpenWithContributionItem(manager);
+ manager.add(new DeleteArtifactAction());
+ manager.add(new Separator());
+ manager.add(new OpenOutlineAction());
+ manager.add(new OpenHistoryAction());
+ manager.add(new RevealInExplorerAction());
+ manager.add(new RevealBranchAction());
+ manager.add(new Separator());
+ manager.add(new AccessControlAction());
+ manager.add(new Separator());
+ manager.add(new CopyArtifactURLAction());
+ manager.add(new Separator());
+ manager.add(new DirtyReportAction(editor.getArtifactFromEditorInput()));
+ }
- private Artifact getSelectedArtifact() {
- Artifact toReturn = null;
+ private Artifact getSelectedArtifact() {
+ Artifact toReturn = null;
- ISelectionProvider provider = editor.getSite().getSelectionProvider();
- ISelection selection = provider.getSelection();
- if (!selection.isEmpty()) {
- IStructuredSelection structuredSelection = (IStructuredSelection) selection;
- Object selectedObject = structuredSelection.getFirstElement();
- if (selectedObject instanceof Artifact) {
- toReturn = (Artifact) selectedObject;
- }
- }
- return toReturn;
- }
+ ISelectionProvider provider = editor.getSite().getSelectionProvider();
+ ISelection selection = provider.getSelection();
+ if (!selection.isEmpty()) {
+ IStructuredSelection structuredSelection = (IStructuredSelection) selection;
+ Object selectedObject = structuredSelection.getFirstElement();
+ if (selectedObject instanceof Artifact) {
+ toReturn = (Artifact) selectedObject;
+ }
+ }
+ return toReturn;
+ }
- private void addOpenWithContributionItem(IToolBarManager manager) {
- OpenWithContributionItem contributionItem = new OpenWithContributionItem();
- contributionItem.setVisible(true);
- manager.add(contributionItem);
- }
+ private void addOpenWithContributionItem(IToolBarManager manager) {
+ OpenWithContributionItem contributionItem = new OpenWithContributionItem();
+ contributionItem.setVisible(true);
+ manager.add(contributionItem);
+ }
- private final Action createAtsBugAction() {
- IEditorSite site = editor.getEditorSite();
- return OseeUiActions.createBugAction(SkynetGuiPlugin.getInstance(), editor, site.getId(), site.getRegisteredName());
- }
+ private final Action createAtsBugAction() {
+ IEditorSite site = editor.getEditorSite();
+ return OseeUiActions.createBugAction(SkynetGuiPlugin.getInstance(), editor, site.getId(),
+ site.getRegisteredName());
+ }
- private final class RevealBranchAction extends Action {
- public RevealBranchAction() {
- super();
- setImageDescriptor(ImageManager.getImageDescriptor(FrameworkImage.BRANCH));
- setToolTipText("Reveal the branch this artifact is on in the Branch Manager");
- }
+ private final class RevealBranchAction extends Action {
+ public RevealBranchAction() {
+ super();
+ setImageDescriptor(ImageManager.getImageDescriptor(FrameworkImage.BRANCH));
+ setToolTipText("Reveal the branch this artifact is on in the Branch Manager");
+ }
- @Override
- public void run() {
- try {
- BranchView.revealBranch(getSelectedArtifact().getBranch());
- } catch (Exception ex) {
- OseeLog.log(getClass(), OseeLevel.SEVERE_POPUP, ex);
- }
- }
+ @Override
+ public void run() {
+ try {
+ BranchView.revealBranch(getSelectedArtifact().getBranch());
+ } catch (Exception ex) {
+ OseeLog.log(getClass(), OseeLevel.SEVERE_POPUP, ex);
+ }
+ }
- }
+ }
- private final class DeleteArtifactAction extends Action {
+ private final class DeleteArtifactAction extends Action {
- public DeleteArtifactAction() {
- super("&Delete Artifact\tDelete", Action.AS_PUSH_BUTTON);
- setImageDescriptor(ImageManager.getImageDescriptor(FrameworkImage.DELETE));
- }
+ public DeleteArtifactAction() {
+ super("&Delete Artifact\tDelete", Action.AS_PUSH_BUTTON);
+ setImageDescriptor(ImageManager.getImageDescriptor(FrameworkImage.DELETE));
+ }
- @Override
- public void run() {
- try {
- MessageDialog dialog =
- new MessageDialog(Display.getCurrent().getActiveShell(), "Confirm Artifact Deletion", null,
- " Are you sure you want to delete this artifact and all of the default hierarchy children?",
- MessageDialog.QUESTION, new String[] {IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL}, 1);
- if (dialog.open() == Window.OK) {
- getSelectedArtifact().deleteAndPersist();
- }
- } catch (Exception ex) {
- OseeLog.log(SkynetGuiPlugin.class, OseeLevel.SEVERE_POPUP, ex);
- }
- }
- }
+ @Override
+ public void run() {
+ try {
+ MessageDialog dialog =
+ new MessageDialog(
+ Display.getCurrent().getActiveShell(),
+ "Confirm Artifact Deletion",
+ null,
+ " Are you sure you want to delete this artifact and all of the default hierarchy children?",
+ MessageDialog.QUESTION, new String[] {IDialogConstants.YES_LABEL,
+ IDialogConstants.NO_LABEL}, 1);
+ if (dialog.open() == Window.OK) {
+ getSelectedArtifact().deleteAndPersist();
+ }
+ } catch (Exception ex) {
+ OseeLog.log(SkynetGuiPlugin.class, OseeLevel.SEVERE_POPUP, ex);
+ }
+ }
+ }
- private final class OpenHistoryAction extends Action {
+ private final class OpenHistoryAction extends Action {
- public OpenHistoryAction() {
- super();
- setImageDescriptor(ImageManager.getImageDescriptor(FrameworkImage.DB_ICON_BLUE));
- setToolTipText("Show this artifact in the Resource History");
- }
+ public OpenHistoryAction() {
+ super();
+ setImageDescriptor(ImageManager.getImageDescriptor(FrameworkImage.DB_ICON_BLUE));
+ setToolTipText("Show this artifact in the Resource History");
+ }
- @Override
- public void run() {
- try {
- HistoryView.open(getSelectedArtifact());
- } catch (Exception ex) {
- OseeLog.log(getClass(), OseeLevel.SEVERE_POPUP, ex);
- }
- }
- }
+ @Override
+ public void run() {
+ try {
+ HistoryView.open(getSelectedArtifact());
+ } catch (Exception ex) {
+ OseeLog.log(getClass(), OseeLevel.SEVERE_POPUP, ex);
+ }
+ }
+ }
- private final class RevealInExplorerAction extends Action {
- public RevealInExplorerAction() {
- super();
- setImageDescriptor(ImageManager.getImageDescriptor(FrameworkImage.MAGNIFY));
- setToolTipText("Reveal this artifact in the Artifact Explorer");
- }
+ private final class RevealInExplorerAction extends Action {
+ public RevealInExplorerAction() {
+ super();
+ setImageDescriptor(ImageManager.getImageDescriptor(FrameworkImage.MAGNIFY));
+ setToolTipText("Reveal this artifact in the Artifact Explorer");
+ }
- @Override
- public void run() {
- try {
- ArtifactExplorer.revealArtifact(getSelectedArtifact());
- } catch (Exception ex) {
- OseeLog.log(getClass(), OseeLevel.SEVERE_POPUP, ex);
- }
- }
- }
+ @Override
+ public void run() {
+ try {
+ ArtifactExplorer.revealArtifact(getSelectedArtifact());
+ } catch (Exception ex) {
+ OseeLog.log(getClass(), OseeLevel.SEVERE_POPUP, ex);
+ }
+ }
+ }
- private final class AccessControlAction extends Action {
- public AccessControlAction() {
- super();
- setImageDescriptor(ImageManager.getImageDescriptor(FrameworkImage.AUTHENTICATED));
- setToolTipText("&Access Control");
- setText("&Access Control");
- }
+ private final class AccessControlAction extends Action {
+ public AccessControlAction() {
+ super();
+ setImageDescriptor(ImageManager.getImageDescriptor(FrameworkImage.AUTHENTICATED));
+ setToolTipText("&Access Control");
+ setText("&Access Control");
+ }
- @Override
- public void run() {
- try {
- PolicyDialog pd = new PolicyDialog(Display.getCurrent().getActiveShell(), getSelectedArtifact());
- pd.open();
- } catch (Exception ex) {
- OseeLog.log(getClass(), OseeLevel.SEVERE_POPUP, ex);
- }
- }
- }
+ @Override
+ public void run() {
+ try {
+ PolicyDialog pd = new PolicyDialog(Display.getCurrent().getActiveShell(), getSelectedArtifact());
+ pd.open();
+ } catch (Exception ex) {
+ OseeLog.log(getClass(), OseeLevel.SEVERE_POPUP, ex);
+ }
+ }
+ }
- public static final class DirtyReportAction extends Action {
- private final Artifact artifact;
+ public static final class DirtyReportAction extends Action {
+ private final Artifact artifact;
- public DirtyReportAction(Artifact artifact) {
- super();
- this.artifact = artifact;
- setImageDescriptor(ImageManager.getImageDescriptor(FrameworkImage.DIRTY));
- setToolTipText("&Dirty Report");
- setText("&Dirty Report");
- }
+ public DirtyReportAction(Artifact artifact) {
+ super();
+ this.artifact = artifact;
+ setImageDescriptor(ImageManager.getImageDescriptor(FrameworkImage.DIRTY));
+ setToolTipText("&Dirty Report");
+ setText("&Dirty Report");
+ }
- @Override
- public void run() {
- String rString = null;
- for (Attribute<?> attribute : artifact.internalGetAttributes()) {
- if (attribute.isDirty()) {
- rString = "Attribute: " + attribute.getNameValueDescription();
- break;
- }
- }
+ @Override
+ public void run() {
+ String rString = null;
+ for (Attribute<?> attribute : artifact.internalGetAttributes()) {
+ if (attribute.isDirty()) {
+ rString = "Attribute: " + attribute.getNameValueDescription();
+ break;
+ }
+ }
- if (rString == null) {
- rString = RelationManager.reportHasDirtyLinks(artifact);
- }
- AWorkbench.popup("Dirty Report", rString == null || rString.equals("") ? "Not Dirty" : "Dirty -> " + rString);
- }
- }
+ if (rString == null) {
+ rString = RelationManager.reportHasDirtyLinks(artifact);
+ }
+ AWorkbench.popup("Dirty Report", rString == null || rString.equals("") ? "Not Dirty" : "Dirty -> " + rString);
+ }
+ }
- private final class CopyArtifactURLAction extends Action {
- public CopyArtifactURLAction() {
- super();
- setImageDescriptor(ImageManager.getImageDescriptor(FrameworkImage.COPYTOCLIPBOARD));
- setToolTipText("Copy artifact url link to clipboard. NOTE: This is a link pointing to the latest version of the artifact.");
- }
+ private final class CopyArtifactURLAction extends Action {
+ public CopyArtifactURLAction() {
+ super();
+ setImageDescriptor(ImageManager.getImageDescriptor(FrameworkImage.COPYTOCLIPBOARD));
+ setToolTipText("Copy artifact url link to clipboard. NOTE: This is a link pointing to the latest version of the artifact.");
+ }
- @Override
- public void run() {
- if (getSelectedArtifact() != null) {
- Clipboard clipboard = null;
- try {
- URL url = ArtifactURL.getExternalArtifactLink(getSelectedArtifact());
- clipboard = new Clipboard(null);
- clipboard.setContents(new Object[] {url.toString()}, new Transfer[] {TextTransfer.getInstance()});
- } catch (Exception ex) {
- OseeLog.log(SkynetGuiPlugin.class, Level.SEVERE, String.format(
- "Error obtaining url for - guid: [%s] branch:[%s]", getSelectedArtifact().getGuid(),
- getSelectedArtifact().getBranch()), ex);
- } finally {
- if (clipboard != null && !clipboard.isDisposed()) {
- clipboard.dispose();
- clipboard = null;
- }
- }
- }
- }
- }
+ @Override
+ public void run() {
+ if (getSelectedArtifact() != null) {
+ Clipboard clipboard = null;
+ try {
+ URL url = ArtifactURL.getExternalArtifactLink(getSelectedArtifact());
+ clipboard = new Clipboard(null);
+ clipboard.setContents(new Object[] {url.toString()}, new Transfer[] {TextTransfer.getInstance()});
+ } catch (Exception ex) {
+ OseeLog.log(SkynetGuiPlugin.class, Level.SEVERE, String.format(
+ "Error obtaining url for - guid: [%s] branch:[%s]", getSelectedArtifact().getGuid(),
+ getSelectedArtifact().getBranch()), ex);
+ } finally {
+ if (clipboard != null && !clipboard.isDisposed()) {
+ clipboard.dispose();
+ clipboard = null;
+ }
+ }
+ }
+ }
+ }
- private final class OpenOutlineAction extends Action {
- public OpenOutlineAction() {
- super();
- setImageDescriptor(ImageManager.getImageDescriptor(FrameworkImage.OUTLINE));
- setToolTipText("Open Outline");
- }
+ private final class OpenOutlineAction extends Action {
+ public OpenOutlineAction() {
+ super();
+ setImageDescriptor(ImageManager.getImageDescriptor(FrameworkImage.OUTLINE));
+ setToolTipText("Open Outline");
+ }
- @Override
- public void run() {
- try {
- PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().showView(
- "org.eclipse.ui.views.ContentOutline");
- } catch (PartInitException ex) {
- OseeLog.log(SkynetGuiPlugin.class, OseeLevel.SEVERE_POPUP, "Unable to open outline", ex);
- }
- }
- }
+ @Override
+ public void run() {
+ try {
+ PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().showView(
+ "org.eclipse.ui.views.ContentOutline");
+ } catch (PartInitException ex) {
+ OseeLog.log(SkynetGuiPlugin.class, OseeLevel.SEVERE_POPUP, "Unable to open outline", ex);
+ }
+ }
+ }
}
diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/artifact/editor/ArtifactEditorContributor.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/artifact/editor/ArtifactEditorContributor.java index 3bff197ec1d..7d1ec1d890e 100644 --- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/artifact/editor/ArtifactEditorContributor.java +++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/artifact/editor/ArtifactEditorContributor.java @@ -23,79 +23,70 @@ import org.eclipse.ui.IEditorPart; import org.eclipse.ui.part.MultiPageEditorActionBarContributor; import org.eclipse.ui.texteditor.StatusLineContributionItem; -/** - * Manages the installation/deinstallation of global actions for multi-page editors. Responsible for the redirection of - * global actions to the active editor. Multi-page contributor replaces the contributors for the individual editors in - * the multi-page editor. - */ public class ArtifactEditorContributor extends MultiPageEditorActionBarContributor { - private StatusLineContributionItem typeStatusItem; - private ShowInExplorerAction showInExplorerAction; - - /** - * Creates a multi-page contributor. - */ - public ArtifactEditorContributor() { - super(); - - createActions(); - } - - @Override - public void setActiveEditor(IEditorPart part) { - super.setActiveEditor(part); - Artifact artifact = (Artifact) part.getAdapter(Artifact.class); - if (artifact != null) { - typeStatusItem.setText(artifact.getArtifactType().getName()); - typeStatusItem.setImage(ArtifactImageManager.getImage(artifact)); - showInExplorerAction.setArtifact(artifact); - - RelationsComposite composite = (RelationsComposite) part.getAdapter(RelationsComposite.class); - if (composite != null) { - composite.getTreeViewer().addSelectionChangedListener( - new SelectionCountChangeListener(this.getActionBars().getStatusLineManager())); - } - } - } - - @Override - public void setActivePage(IEditorPart part) { - } - - private void createActions() { - typeStatusItem = new StatusLineContributionItem("skynet.artifactType", true, 25); - typeStatusItem.setToolTipText("The type of the artifact being edited."); - - showInExplorerAction = new ShowInExplorerAction(); - } - - @Override - public void contributeToStatusLine(IStatusLineManager statusLineManager) { - statusLineManager.add(typeStatusItem); - OseeContributionItem.addTo(statusLineManager); - } - - @Override - public void contributeToCoolBar(ICoolBarManager coolBarManager) { - coolBarManager.add(showInExplorerAction); - } - - private static class ShowInExplorerAction extends Action { - private Artifact artifact; - - public ShowInExplorerAction() { - setText("Show in Artifact Explorer"); - setToolTipText("Show the Artifact being edited in the Artifact Explorer"); - } - - public void setArtifact(Artifact artifact) { - this.artifact = artifact; - } - - @Override - public void run() { - ArtifactExplorer.revealArtifact(artifact); - } - } + private StatusLineContributionItem typeStatusItem; + private ShowInExplorerAction showInExplorerAction; + + public ArtifactEditorContributor() { + super(); + createActions(); + } + + @Override + public void setActiveEditor(IEditorPart part) { + super.setActiveEditor(part); + Artifact artifact = (Artifact) part.getAdapter(Artifact.class); + if (artifact != null) { + typeStatusItem.setText(artifact.getArtifactType().getName()); + typeStatusItem.setImage(ArtifactImageManager.getImage(artifact)); + showInExplorerAction.setArtifact(artifact); + + RelationsComposite composite = (RelationsComposite) part.getAdapter(RelationsComposite.class); + if (composite != null) { + composite.getTreeViewer().addSelectionChangedListener( + new SelectionCountChangeListener(this.getActionBars().getStatusLineManager())); + } + } + } + + @Override + public void setActivePage(IEditorPart part) { + } + + private void createActions() { + typeStatusItem = new StatusLineContributionItem("skynet.artifactType", true, 25); + typeStatusItem.setToolTipText("The type of the artifact being edited."); + + showInExplorerAction = new ShowInExplorerAction(); + } + + @Override + public void contributeToStatusLine(IStatusLineManager statusLineManager) { + statusLineManager.add(typeStatusItem); + OseeContributionItem.addTo(statusLineManager); + } + + @Override + public void contributeToCoolBar(ICoolBarManager coolBarManager) { + coolBarManager.add(showInExplorerAction); + } + + private static class ShowInExplorerAction extends Action { + private Artifact artifact; + + public ShowInExplorerAction() { + setText("Show in Artifact Explorer"); + setToolTipText("Show the Artifact being edited in the Artifact Explorer"); + } + + public void setArtifact(Artifact artifact) { + this.artifact = artifact; + } + + @Override + public void run() { + ArtifactExplorer.revealArtifact(artifact); + } + } } diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/artifact/editor/ArtifactEditorEventManager.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/artifact/editor/ArtifactEditorEventManager.java index 87828448555..fabece89371 100644 --- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/artifact/editor/ArtifactEditorEventManager.java +++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/artifact/editor/ArtifactEditorEventManager.java @@ -23,8 +23,8 @@ import org.eclipse.osee.framework.skynet.core.event2.artifact.EventBasicGuidArti import org.eclipse.osee.framework.skynet.core.event2.artifact.EventModType;
import org.eclipse.osee.framework.skynet.core.event2.artifact.IArtifactEventListener;
import org.eclipse.osee.framework.skynet.core.event2.filter.IEventFilter;
-import org.eclipse.osee.framework.ui.plugin.util.Displays;
import org.eclipse.osee.framework.ui.skynet.ArtifactImageManager;
+import org.eclipse.osee.framework.ui.swt.Displays;
/**
* Common location for event handling for ArtifactExplorers in order to keep number of registrations and processing to a
diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/artifact/editor/BaseArtifactEditorInput.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/artifact/editor/BaseArtifactEditorInput.java index a28949539b2..e655710d556 100644 --- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/artifact/editor/BaseArtifactEditorInput.java +++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/artifact/editor/BaseArtifactEditorInput.java @@ -22,67 +22,73 @@ import org.eclipse.ui.IPersistableElement; * @author Roberto E. Escobar
*/
public abstract class BaseArtifactEditorInput implements IEditorInput {
- private final Artifact artifact;
+ private final Artifact artifact;
- public BaseArtifactEditorInput(Artifact artifact) {
- this.artifact = artifact;
- }
+ public BaseArtifactEditorInput(Artifact artifact) {
+ this.artifact = artifact;
+ }
- @Override
- public boolean equals(Object obj) {
- boolean equals = false;
- if (obj instanceof BaseArtifactEditorInput) {
- BaseArtifactEditorInput otherEdInput = (BaseArtifactEditorInput) obj;
- equals = artifact == otherEdInput.artifact;
- }
- return equals;
- }
+ @Override
+ public boolean equals(Object obj) {
+ boolean equals = false;
+ if (obj instanceof BaseArtifactEditorInput) {
+ BaseArtifactEditorInput otherEdInput = (BaseArtifactEditorInput) obj;
+ equals = artifact == otherEdInput.artifact;
+ }
+ return equals;
+ }
- public boolean exists() {
- return true;
- }
+ @Override
+ public boolean exists() {
+ return true;
+ }
- public ImageDescriptor getImageDescriptor() {
- return ArtifactImageManager.getImageDescriptor(artifact);
- }
+ @Override
+ public ImageDescriptor getImageDescriptor() {
+ return ArtifactImageManager.getImageDescriptor(artifact);
+ }
- public Image getImage() {
- return ArtifactImageManager.getImage(artifact);
- }
+ public Image getImage() {
+ return ArtifactImageManager.getImage(artifact);
+ }
- public String getName() {
- if (artifact == null) {
- return "No Artifact Input Provided";
- }
- return String.format("%s%s", artifact.getVersionedName(), artifact.isReadOnly() ? " (Read-Only)" : "");
- }
+ @Override
+ public String getName() {
+ if (artifact == null) {
+ return "No Artifact Input Provided";
+ }
+ return String.format("%s%s", artifact.getVersionedName(), artifact.isReadOnly() ? " (Read-Only)" : "");
+ }
- public IPersistableElement getPersistable() {
- return null;
- }
+ @Override
+ public IPersistableElement getPersistable() {
+ return null;
+ }
- public String getToolTipText() {
- return getName();
- }
+ @Override
+ public String getToolTipText() {
+ return getName();
+ }
- @SuppressWarnings("unchecked")
- public Object getAdapter(Class adapter) {
- if (Artifact.class.equals(adapter)) {
- return getArtifact();
- }
- return null;
- }
+ @SuppressWarnings("rawtypes")
+ @Override
+ public Object getAdapter(Class adapter) {
+ if (Artifact.class.equals(adapter)) {
+ return getArtifact();
+ }
+ return null;
+ }
- public Artifact getArtifact() {
- return artifact;
- }
+ public Artifact getArtifact() {
+ return artifact;
+ }
- public boolean isReadOnly() {
- return artifact == null || artifact.isReadOnly();
- }
+ public boolean isReadOnly() {
+ return artifact == null || artifact.isReadOnly();
+ }
- @Override
- public int hashCode() {
- return this.artifact.hashCode();
- }
+ @Override
+ public int hashCode() {
+ return this.artifact.hashCode();
+ }
}
diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/artifact/editor/pages/ArtifactFormPage.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/artifact/editor/pages/ArtifactFormPage.java index 1d99fe24ef3..2e0f30a622e 100644 --- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/artifact/editor/pages/ArtifactFormPage.java +++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/artifact/editor/pages/ArtifactFormPage.java @@ -28,6 +28,7 @@ import org.eclipse.osee.framework.ui.skynet.artifact.editor.sections.DetailsForm import org.eclipse.osee.framework.ui.skynet.artifact.editor.sections.RelationsFormSection;
import org.eclipse.osee.framework.ui.skynet.util.FormsUtil;
import org.eclipse.osee.framework.ui.swt.ALayout;
+import org.eclipse.osee.framework.ui.swt.Displays;
import org.eclipse.osee.framework.ui.swt.ImageManager;
import org.eclipse.osee.framework.ui.swt.Widgets;
import org.eclipse.swt.SWT;
@@ -37,7 +38,6 @@ import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Label;
import org.eclipse.ui.forms.IManagedForm;
import org.eclipse.ui.forms.IMessage;
@@ -53,198 +53,198 @@ import org.eclipse.ui.forms.widgets.Section; public class ArtifactFormPage extends FormPage {
- private enum SectionEnum {
- Attributes,
- Relations,
- Details;
- }
-
- private final Map<SectionEnum, SectionPart> sectionParts;
- private FormText infoText;
-
- public ArtifactFormPage(FormEditor editor, String id, String title) {
- super(editor, id, title);
- this.sectionParts = new LinkedHashMap<SectionEnum, SectionPart>();
- }
-
- @Override
- protected void createFormContent(IManagedForm managedForm) {
- super.createFormContent(managedForm);
- sectionParts.clear();
-
- final ScrolledForm form = managedForm.getForm();
- final FormToolkit toolkit = managedForm.getToolkit();
-
- GridLayout layout = new GridLayout();
- layout.numColumns = 1;
- layout.marginHeight = 10;
- layout.marginWidth = 6;
- layout.horizontalSpacing = 20;
- form.getBody().setLayout(layout);
- form.getBody().setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, true));
-
- updateTitle(form);
- updateImage(form);
- updateArtifactInfoArea(toolkit, form, true);
- addToolBar(toolkit, form, true);
- FormsUtil.addHeadingGradient(toolkit, form, true);
- addMessageDecoration(form);
-
- int sectionStyle = Section.TITLE_BAR | Section.TWISTIE;
-
- sectionParts.put(SectionEnum.Attributes, new AttributesFormSection(getEditor(), form.getBody(), toolkit,
- sectionStyle | Section.EXPANDED));
- sectionParts.put(SectionEnum.Relations, new RelationsFormSection(getEditor(), form.getBody(), toolkit,
- sectionStyle));
- sectionParts.put(SectionEnum.Details, new DetailsFormSection(getEditor(), form.getBody(), toolkit, sectionStyle));
-
- for (SectionPart part : sectionParts.values()) {
- managedForm.addPart(part);
- Section section = part.getSection();
- section.marginWidth = 0;
- section.marginHeight = 2;
- }
- form.layout();
- }
-
- @Override
- public ArtifactEditor getEditor() {
- return (ArtifactEditor) super.getEditor();
- }
-
- private void addMessageDecoration(ScrolledForm form) {
- form.getForm().addMessageHyperlinkListener(new HyperlinkAdapter() {
-
- @Override
- public void linkActivated(HyperlinkEvent e) {
- String title = e.getLabel();
- Object href = e.getHref();
- if (href instanceof IMessage[]) {
- Point noteLocation = ((Control) e.widget).toDisplay(0, 0);
- noteLocation.x += 10;
- noteLocation.y += 10;
-
- MessageSummaryNote note = new MessageSummaryNote(getManagedForm(), title, (IMessage[]) href);
- note.setLocation(noteLocation);
- note.open();
- }
- }
-
- });
- }
-
- private void addToolBar(FormToolkit toolkit, ScrolledForm form, boolean add) {
- IToolBarManager manager = form.getToolBarManager();
- if (add) {
- manager.add(new RefreshAction());
- manager.add(new Separator());
- getEditor().getActionBarContributor().contributeToToolBar(manager);
- manager.update(true);
- } else {
- manager.removeAll();
- }
- form.reflow(true);
- }
-
- private void updateTitle(ScrolledForm form) {
- form.setText(getEditorInput().getName());
- }
-
- private void updateImage(ScrolledForm form) {
- form.setImage(getEditor().getEditorInput().getImage());
- }
-
- private String getArtifactShortInfo() {
- String description;
- try {
- Artifact artifact = getEditor().getEditorInput().getArtifact();
- description =
- String.format("<form><p>%s<b>Branch:</b> %s <b>Type:</b> %s <b>GUID:</b> %s</p></form>",
- !artifact.isDeleted() ? "" : "<b>ARTIFACT DELETED - </b> ", artifact.getBranch().getShortName(),
- artifact.getArtifactTypeName(), artifact.getGuid());
- } catch (Exception ex) {
- description = Lib.exceptionToString(ex);
- }
- return description;
- }
-
- private void updateArtifactInfoArea(FormToolkit toolkit, ScrolledForm form, boolean add) {
- if (add) {
- Composite infoArea = toolkit.createComposite(form.getForm().getBody(), SWT.WRAP);
- infoArea.setLayout(ALayout.getZeroMarginLayout(2, false));
- infoArea.setLayoutData(new GridData(SWT.BEGINNING, SWT.FILL, true, false));
-
- Label label = toolkit.createLabel(infoArea, "", SWT.WRAP);
- Image image;
- try {
- Artifact artifact = getEditor().getEditorInput().getArtifact();
- if (artifact.isDeleted()) {
- image = ImageManager.getImage(FrameworkImage.TRASH);
- } else {
- image = MessageDialog.getImage(MessageDialog.DLG_IMG_MESSAGE_INFO);
- }
- } catch (Exception ex) {
- image = MessageDialog.getImage(MessageDialog.DLG_IMG_MESSAGE_ERROR);
- }
- label.setImage(image);
-
- infoText = toolkit.createFormText(infoArea, false);
- infoText.setText(getArtifactShortInfo(), true, false);
- infoText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_DARK_GRAY));
- infoText.setToolTipText("The human readable id and database id for this artifact");
- } else {
- infoText.setText(getArtifactShortInfo(), true, false);
- }
- }
-
- @Override
- public void dispose() {
- for (SectionPart part : sectionParts.values()) {
- part.dispose();
- }
- super.dispose();
- }
-
- public RelationsComposite getRelationsComposite() {
- SectionPart section = sectionParts.get(SectionEnum.Relations);
- if (section instanceof RelationsFormSection) {
- return ((RelationsFormSection) section).getRelationComposite();
- }
- return null;
- }
-
- public void refresh() {
- final ScrolledForm sForm = getManagedForm().getForm();
- updateTitle(sForm);
- updateImage(sForm);
- updateArtifactInfoArea(getManagedForm().getToolkit(), sForm, false);
- for (SectionPart part : sectionParts.values()) {
- part.refresh();
- }
- sForm.getBody().layout(true);
- sForm.reflow(true);
- getManagedForm().refresh();
- }
-
- @Override
- public void showBusy(boolean busy) {
- super.showBusy(busy);
- if (Widgets.isAccessible(getManagedForm().getForm())) {
- getManagedForm().getForm().getForm().setBusy(busy);
- }
- }
-
- private final class RefreshAction extends Action {
-
- public RefreshAction() {
- super();
- setImageDescriptor(ImageManager.getImageDescriptor(PluginUiImage.REFRESH));
- setToolTipText("Refresh Editor");
- }
-
- @Override
- public void run() {
- refresh();
- }
- }
+ private enum SectionEnum {
+ Attributes,
+ Relations,
+ Details;
+ }
+
+ private final Map<SectionEnum, SectionPart> sectionParts;
+ private FormText infoText;
+
+ public ArtifactFormPage(FormEditor editor, String id, String title) {
+ super(editor, id, title);
+ this.sectionParts = new LinkedHashMap<SectionEnum, SectionPart>();
+ }
+
+ @Override
+ protected void createFormContent(IManagedForm managedForm) {
+ super.createFormContent(managedForm);
+ sectionParts.clear();
+
+ final ScrolledForm form = managedForm.getForm();
+ final FormToolkit toolkit = managedForm.getToolkit();
+
+ GridLayout layout = new GridLayout();
+ layout.numColumns = 1;
+ layout.marginHeight = 10;
+ layout.marginWidth = 6;
+ layout.horizontalSpacing = 20;
+ form.getBody().setLayout(layout);
+ form.getBody().setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, true));
+
+ updateTitle(form);
+ updateImage(form);
+ updateArtifactInfoArea(toolkit, form, true);
+ addToolBar(toolkit, form, true);
+ FormsUtil.addHeadingGradient(toolkit, form, true);
+ addMessageDecoration(form);
+
+ int sectionStyle = Section.TITLE_BAR | Section.TWISTIE;
+
+ sectionParts.put(SectionEnum.Attributes, new AttributesFormSection(getEditor(), form.getBody(), toolkit,
+ sectionStyle | Section.EXPANDED));
+ sectionParts.put(SectionEnum.Relations, new RelationsFormSection(getEditor(), form.getBody(), toolkit,
+ sectionStyle));
+ sectionParts.put(SectionEnum.Details, new DetailsFormSection(getEditor(), form.getBody(), toolkit, sectionStyle));
+
+ for (SectionPart part : sectionParts.values()) {
+ managedForm.addPart(part);
+ Section section = part.getSection();
+ section.marginWidth = 0;
+ section.marginHeight = 2;
+ }
+ form.layout();
+ }
+
+ @Override
+ public ArtifactEditor getEditor() {
+ return (ArtifactEditor) super.getEditor();
+ }
+
+ private void addMessageDecoration(ScrolledForm form) {
+ form.getForm().addMessageHyperlinkListener(new HyperlinkAdapter() {
+
+ @Override
+ public void linkActivated(HyperlinkEvent e) {
+ String title = e.getLabel();
+ Object href = e.getHref();
+ if (href instanceof IMessage[]) {
+ Point noteLocation = ((Control) e.widget).toDisplay(0, 0);
+ noteLocation.x += 10;
+ noteLocation.y += 10;
+
+ MessageSummaryNote note = new MessageSummaryNote(getManagedForm(), title, (IMessage[]) href);
+ note.setLocation(noteLocation);
+ note.open();
+ }
+ }
+
+ });
+ }
+
+ private void addToolBar(FormToolkit toolkit, ScrolledForm form, boolean add) {
+ IToolBarManager manager = form.getToolBarManager();
+ if (add) {
+ manager.add(new RefreshAction());
+ manager.add(new Separator());
+ getEditor().getActionBarContributor().contributeToToolBar(manager);
+ manager.update(true);
+ } else {
+ manager.removeAll();
+ }
+ form.reflow(true);
+ }
+
+ private void updateTitle(ScrolledForm form) {
+ form.setText(getEditorInput().getName());
+ }
+
+ private void updateImage(ScrolledForm form) {
+ form.setImage(getEditor().getEditorInput().getImage());
+ }
+
+ private String getArtifactShortInfo() {
+ String description;
+ try {
+ Artifact artifact = getEditor().getEditorInput().getArtifact();
+ description =
+ String.format("<form><p>%s<b>Branch:</b> %s <b>Type:</b> %s <b>GUID:</b> %s</p></form>",
+ !artifact.isDeleted() ? "" : "<b>ARTIFACT DELETED - </b> ",
+ artifact.getBranch().getShortName(), artifact.getArtifactTypeName(), artifact.getGuid());
+ } catch (Exception ex) {
+ description = Lib.exceptionToString(ex);
+ }
+ return description;
+ }
+
+ private void updateArtifactInfoArea(FormToolkit toolkit, ScrolledForm form, boolean add) {
+ if (add) {
+ Composite infoArea = toolkit.createComposite(form.getForm().getBody(), SWT.WRAP);
+ infoArea.setLayout(ALayout.getZeroMarginLayout(2, false));
+ infoArea.setLayoutData(new GridData(SWT.BEGINNING, SWT.FILL, true, false));
+
+ Label label = toolkit.createLabel(infoArea, "", SWT.WRAP);
+ Image image;
+ try {
+ Artifact artifact = getEditor().getEditorInput().getArtifact();
+ if (artifact.isDeleted()) {
+ image = ImageManager.getImage(FrameworkImage.TRASH);
+ } else {
+ image = MessageDialog.getImage(MessageDialog.DLG_IMG_MESSAGE_INFO);
+ }
+ } catch (Exception ex) {
+ image = MessageDialog.getImage(MessageDialog.DLG_IMG_MESSAGE_ERROR);
+ }
+ label.setImage(image);
+
+ infoText = toolkit.createFormText(infoArea, false);
+ infoText.setText(getArtifactShortInfo(), true, false);
+ infoText.setForeground(Displays.getSystemColor(SWT.COLOR_DARK_GRAY));
+ infoText.setToolTipText("The human readable id and database id for this artifact");
+ } else {
+ infoText.setText(getArtifactShortInfo(), true, false);
+ }
+ }
+
+ @Override
+ public void dispose() {
+ for (SectionPart part : sectionParts.values()) {
+ part.dispose();
+ }
+ super.dispose();
+ }
+
+ public RelationsComposite getRelationsComposite() {
+ SectionPart section = sectionParts.get(SectionEnum.Relations);
+ if (section instanceof RelationsFormSection) {
+ return ((RelationsFormSection) section).getRelationComposite();
+ }
+ return null;
+ }
+
+ public void refresh() {
+ final ScrolledForm sForm = getManagedForm().getForm();
+ updateTitle(sForm);
+ updateImage(sForm);
+ updateArtifactInfoArea(getManagedForm().getToolkit(), sForm, false);
+ for (SectionPart part : sectionParts.values()) {
+ part.refresh();
+ }
+ sForm.getBody().layout(true);
+ sForm.reflow(true);
+ getManagedForm().refresh();
+ }
+
+ @Override
+ public void showBusy(boolean busy) {
+ super.showBusy(busy);
+ if (Widgets.isAccessible(getManagedForm().getForm())) {
+ getManagedForm().getForm().getForm().setBusy(busy);
+ }
+ }
+
+ private final class RefreshAction extends Action {
+
+ public RefreshAction() {
+ super();
+ setImageDescriptor(ImageManager.getImageDescriptor(PluginUiImage.REFRESH));
+ setToolTipText("Refresh Editor");
+ }
+
+ @Override
+ public void run() {
+ refresh();
+ }
+ }
}
diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/artifact/editor/parts/AttributeFormPart.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/artifact/editor/parts/AttributeFormPart.java index ff05fa8acf3..100a7f587aa 100644 --- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/artifact/editor/parts/AttributeFormPart.java +++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/artifact/editor/parts/AttributeFormPart.java @@ -11,15 +11,10 @@ package org.eclipse.osee.framework.ui.skynet.artifact.editor.parts;
import java.util.Arrays;
-import java.util.Collections;
import java.util.List;
import org.eclipse.jface.dialogs.IMessageProvider;
-import org.eclipse.osee.framework.access.AccessControlManager;
import org.eclipse.osee.framework.core.enums.CoreAttributeTypes;
-import org.eclipse.osee.framework.core.enums.PermissionEnum;
-import org.eclipse.osee.framework.core.exception.OseeArgumentException;
import org.eclipse.osee.framework.core.exception.OseeCoreException;
-import org.eclipse.osee.framework.core.model.AccessData;
import org.eclipse.osee.framework.core.model.type.AttributeType;
import org.eclipse.osee.framework.logging.OseeLevel;
import org.eclipse.osee.framework.logging.OseeLog;
@@ -62,224 +57,224 @@ import org.eclipse.ui.forms.widgets.FormToolkit; */
public class AttributeFormPart extends AbstractFormPart {
- private final ArtifactEditor editor;
- private Composite composite;
-
- public AttributeFormPart(ArtifactEditor editor) {
- this.editor = editor;
- }
-
- public void createContents(Composite parent) {
- final FormToolkit toolkit = getManagedForm().getToolkit();
- composite = toolkit.createComposite(parent, SWT.WRAP);
- composite.setLayout(ALayout.getZeroMarginLayout(1, false));
- composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
- composite.setVisible(false);
-
- try {
- Artifact artifact = editor.getEditorInput().getArtifact();
- boolean isEditable = true;//!artifact.isReadOnly();
-
- List<AttributeType> types = Arrays.asList(AttributeTypeUtil.getTypesWithData(artifact));
- boolean willHaveASection = hasWordAttribute(types);
- for (AttributeType attributeType : types) {
- if (AttributeTypeManager.isBaseTypeCompatible(WordAttribute.class, attributeType) || attributeType.equals(CoreAttributeTypes.RELATION_ORDER)) {
- createAttributeTypeControlsInSection(parent, toolkit, attributeType, willHaveASection, false);
- } else {
- createAttributeTypeControls(composite, toolkit, artifact, attributeType, willHaveASection, isEditable,
- false);
- }
- }
- setLabelFonts(composite, FontManager.getDefaultLabelFont());
- layoutControls(composite);
-
- for (XWidget xWidget : XWidgetUtility.findXWidgetsInControl(composite)) {
- xWidget.addXModifiedListener(new XWidgetValidationListener());
- }
- composite.setVisible(true);
-
- } catch (OseeCoreException ex) {
- OseeLog.log(SkynetGuiPlugin.class, OseeLevel.SEVERE_POPUP, "Unable to access attribute types", ex);
- }
-
- }
-
- // private void setPermissions(Composite parent) {
- // for (XWidget widget : XWidgetUtility.findXWidgetsInControl(parent)) {
- // IAttributeXWidgetProvider xWidgetProvider = AttributeXWidgetManager.getAttributeXWidgetProvider(attributeType);
- // List<DynamicXWidgetLayoutData> concreteWidgets = xWidgetProvider.getDynamicXWidgetLayoutData(attributeType);
- // setPermissions(artifact, attributeType, concreteWidgets);
- // }
- // }
-
- private boolean hasWordAttribute(List<AttributeType> types) throws OseeCoreException {
- for (AttributeType attributeType : types) {
- if (AttributeTypeManager.isBaseTypeCompatible(WordAttribute.class, attributeType)) {
- return true;
- }
- }
- return false;
- }
-
- @Override
- public void dispose() {
- Widgets.disposeWidget(composite);
- super.dispose();
- }
-
- private void setLabelFonts(Control parent, Font font) {
- if (parent instanceof Label) {
- Label label = (Label) parent;
- label.setFont(font);
- }
- if (parent instanceof Composite) {
- Composite container = (Composite) parent;
- for (Control child : container.getChildren()) {
- setLabelFonts(child, font);
- }
- container.layout();
- }
- }
-
- private void layoutControls(Control control) {
- if (control instanceof Label || control instanceof Button) {
- control.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING));
- }
-
- if (control instanceof Composite) {
- Composite container = (Composite) control;
- for (Control child : container.getChildren()) {
- layoutControls(child);
- }
- }
- }
-
- private Composite createAttributeTypeControls(Composite parent, FormToolkit toolkit, Artifact artifact, AttributeType attributeType, boolean willHaveASection, boolean isEditable, boolean isExpandable) {
- Composite internalComposite = toolkit.createComposite(parent, SWT.WRAP);
- GridLayout layout = ALayout.getZeroMarginLayout(1, false);
- if (willHaveASection) {
- layout.marginLeft = 18;
- }
- internalComposite.setLayout(layout);
-
- internalComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
-
- try {
- IAttributeXWidgetProvider xWidgetProvider = AttributeXWidgetManager.getAttributeXWidgetProvider(attributeType);
- List<DynamicXWidgetLayoutData> concreteWidgets = xWidgetProvider.getDynamicXWidgetLayoutData(attributeType);
- if (isExpandable) {
- for (DynamicXWidgetLayoutData data : concreteWidgets) {
- data.getXOptionHandler().add(XOption.NO_LABEL);
- }
- }
- WorkPage workPage = new WorkPage(concreteWidgets, new DefaultXWidgetOptionResolver());
- workPage.createBody(getManagedForm(), internalComposite, artifact, null, isEditable);
-
- setPermissions(artifact, attributeType, concreteWidgets);
- } catch (OseeCoreException ex) {
- toolkit.createLabel(parent, String.format("Error creating controls for: [%s]", attributeType.getName()));
- }
- return internalComposite;
- }
-
- private void setPermissions(Artifact artifact, AttributeType attributeType, List<DynamicXWidgetLayoutData> concreteWidgets) throws OseeCoreException, OseeArgumentException {
- for (DynamicXWidgetLayoutData data : concreteWidgets) {
- if (data.getXWidget() != null && data.getXWidget().getControl() != null && !data.getXWidget().getControl().isDisposed()) {
- AccessData accessData = AccessControlManager.getAccessData(Collections.singletonList(artifact));
- data.getXWidget().setEditable(
- !accessData.getAttributeTypeMatches(artifact, attributeType, PermissionEnum.WRITE).isEmpty());
-
- // XWidgetValidateUtility.setStatus(new Status(Status.ERROR, SkynetGuiPlugin.PLUGIN_ID, ""), data.getXWidget());
- // data.getXWidget().setControlCausedMessage("1111", "No premission", 1);
- }
- }
- }
-
- private void createAttributeTypeControlsInSection(Composite parent, FormToolkit toolkit, AttributeType attributeType, boolean willHaveASection, boolean isEditable) {
- int style = ExpandableComposite.COMPACT | ExpandableComposite.TREE_NODE;
-
- Composite internalComposite = toolkit.createComposite(parent, SWT.WRAP);
- internalComposite.setLayout(new GridLayout());
- internalComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false));
-
- ExpandableComposite expandable = toolkit.createExpandableComposite(internalComposite, style);
- expandable.setText(attributeType.getName());
- expandable.setLayout(new GridLayout());
- expandable.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
-
- Artifact artifact = editor.getEditorInput().getArtifact();
-
- Composite composite =
- createAttributeTypeControls(expandable, toolkit, artifact, attributeType, willHaveASection, isEditable, true);
- expandable.setClient(composite);
-
- expandable.addExpansionListener(new IExpansionListener() {
-
- @Override
- public void expansionStateChanged(ExpansionEvent e) {
- getManagedForm().getForm().reflow(true);
- }
-
- @Override
- public void expansionStateChanging(ExpansionEvent e) {
- getManagedForm().getForm().reflow(false);
- }
-
- });
- toolkit.paintBordersFor(expandable);
- }
-
- @Override
- public void commit(boolean onSave) {
- int saveCount = 0;
- List<XWidget> widgets = XWidgetUtility.findXWidgetsInControl(composite);
- for (XWidget xWidget : widgets) {
- if (xWidget.isEditable()) {
- if (xWidget instanceof IArtifactWidget) {
- IArtifactWidget aWidget = (IArtifactWidget) xWidget;
- try {
- if (aWidget.isDirty().isTrue()) {
- aWidget.saveToArtifact();
- xWidget.removeControlCausedMessage("attribute.dirty");
- saveCount++;
- } else {
- saveCount++;
- }
- } catch (OseeCoreException ex) {
- ex.printStackTrace();
- }
- }
- } else {
- saveCount++;
- }
- }
-
- // Ensure all changes saved
- if (saveCount == widgets.size()) {
- super.commit(onSave);
- }
- }
-
- private final class XWidgetValidationListener implements XModifiedListener {
-
- @Override
- public void widgetModified(XWidget xWidget) {
- if (xWidget != null && xWidget instanceof IArtifactWidget) {
- IArtifactWidget aWidget = (IArtifactWidget) xWidget;
- try {
- Result result = aWidget.isDirty();
- if (result.isTrue()) {
- xWidget.setControlCausedMessage("attribute.dirty", "Dirty", IMessageProvider.WARNING);
- if (!isDirty()) {
- markDirty();
- }
- } else {
- xWidget.removeControlCausedMessage("attribute.dirty");
- }
- } catch (Exception ex) {
- xWidget.setControlCausedMessage("attribute.dirty", "Unable to compute isDirty", IMessageProvider.ERROR);
- }
- }
- }
- }
+ private final ArtifactEditor editor;
+ private Composite composite;
+
+ public AttributeFormPart(ArtifactEditor editor) {
+ this.editor = editor;
+ }
+
+ public void createContents(Composite parent) {
+ final FormToolkit toolkit = getManagedForm().getToolkit();
+ composite = toolkit.createComposite(parent, SWT.WRAP);
+ composite.setLayout(ALayout.getZeroMarginLayout(1, false));
+ composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
+ composite.setVisible(false);
+
+ try {
+ Artifact artifact = editor.getEditorInput().getArtifact();
+ boolean isEditable = !artifact.isReadOnly();
+
+ List<AttributeType> types = Arrays.asList(AttributeTypeUtil.getTypesWithData(artifact));
+ boolean willHaveASection = hasWordAttribute(types);
+ for (AttributeType attributeType : types) {
+ if (AttributeTypeManager.isBaseTypeCompatible(WordAttribute.class, attributeType) || attributeType.equals(CoreAttributeTypes.RELATION_ORDER)) {
+ createAttributeTypeControlsInSection(parent, toolkit, attributeType, willHaveASection, false);
+ } else {
+ createAttributeTypeControls(composite, toolkit, artifact, attributeType, willHaveASection, isEditable,
+ false);
+ }
+ }
+ setLabelFonts(composite, FontManager.getDefaultLabelFont());
+ layoutControls(composite);
+
+ for (XWidget xWidget : XWidgetUtility.findXWidgetsInControl(composite)) {
+ xWidget.addXModifiedListener(new XWidgetValidationListener());
+ }
+ composite.setVisible(true);
+
+ } catch (OseeCoreException ex) {
+ OseeLog.log(SkynetGuiPlugin.class, OseeLevel.SEVERE_POPUP, "Unable to access attribute types", ex);
+ }
+
+ }
+
+ private boolean hasWordAttribute(List<AttributeType> types) throws OseeCoreException {
+ for (AttributeType attributeType : types) {
+ if (AttributeTypeManager.isBaseTypeCompatible(WordAttribute.class, attributeType)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ @Override
+ public void dispose() {
+ Widgets.disposeWidget(composite);
+ super.dispose();
+ }
+
+ private void setLabelFonts(Control parent, Font font) {
+ if (parent instanceof Label) {
+ Label label = (Label) parent;
+ label.setFont(font);
+ }
+ if (parent instanceof Composite) {
+ Composite container = (Composite) parent;
+ for (Control child : container.getChildren()) {
+ setLabelFonts(child, font);
+ }
+ container.layout();
+ }
+ }
+
+ private void layoutControls(Control control) {
+ if (control instanceof Label || control instanceof Button) {
+ control.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING));
+ }
+
+ if (control instanceof Composite) {
+ Composite container = (Composite) control;
+ for (Control child : container.getChildren()) {
+ layoutControls(child);
+ }
+ }
+ }
+
+ private Composite createAttributeTypeControls(Composite parent, FormToolkit toolkit, Artifact artifact, AttributeType attributeType, boolean willHaveASection, boolean isEditable, boolean isExpandable) {
+ Composite internalComposite = toolkit.createComposite(parent, SWT.WRAP);
+ GridLayout layout = ALayout.getZeroMarginLayout(1, false);
+ if (willHaveASection) {
+ layout.marginLeft = 18;
+ }
+ internalComposite.setLayout(layout);
+
+ internalComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+
+ try {
+ IAttributeXWidgetProvider xWidgetProvider = AttributeXWidgetManager.getAttributeXWidgetProvider(attributeType);
+ List<DynamicXWidgetLayoutData> concreteWidgets = xWidgetProvider.getDynamicXWidgetLayoutData(attributeType);
+ if (isExpandable) {
+ for (DynamicXWidgetLayoutData data : concreteWidgets) {
+ data.getXOptionHandler().add(XOption.NO_LABEL);
+ }
+ }
+ WorkPage workPage = new WorkPage(concreteWidgets, new DefaultXWidgetOptionResolver());
+ workPage.createBody(getManagedForm(), internalComposite, artifact, null, isEditable);
+
+ } catch (OseeCoreException ex) {
+ toolkit.createLabel(parent, String.format("Error creating controls for: [%s]", attributeType.getName()));
+ }
+ return internalComposite;
+ }
+
+ // private void setPermissions(Artifact artifact, AttributeType attributeType, List<DynamicXWidgetLayoutData> concreteWidgets) throws OseeCoreException, OseeArgumentException {
+ // for (DynamicXWidgetLayoutData data : concreteWidgets) {
+ // if (data.getXWidget() != null && data.getXWidget().getControl() != null && !data.getXWidget().getControl().isDisposed()) {
+ // AccessData accessData = AccessControlManager.getAccessData(Collections.singletonList(artifact));
+ // data.getXWidget().setEditable(
+ // !accessData.getAttributeTypeMatches(artifact, attributeType, PermissionEnum.WRITE).isEmpty());
+ //
+ // XWidgetValidateUtility.setStatus(new Status(Status.ERROR, SkynetGuiPlugin.PLUGIN_ID, ""), data.getXWidget());
+ // // data.getXWidget().setControlCausedMessage("1111", "No premission", 1);
+ // }
+ // }
+ // }
+
+ // private void setPermissions(Composite parent) {
+ // for (XWidget widget : XWidgetUtility.findXWidgetsInControl(parent)) {
+ // IAttributeXWidgetProvider xWidgetProvider = AttributeXWidgetManager.getAttributeXWidgetProvider(attributeType);
+ // List<DynamicXWidgetLayoutData> concreteWidgets = xWidgetProvider.getDynamicXWidgetLayoutData(attributeType);
+ // setPermissions(artifact, attributeType, concreteWidgets);
+ // }
+ // }
+
+ private void createAttributeTypeControlsInSection(Composite parent, FormToolkit toolkit, AttributeType attributeType, boolean willHaveASection, boolean isEditable) {
+ int style = ExpandableComposite.COMPACT | ExpandableComposite.TREE_NODE;
+
+ Composite internalComposite = toolkit.createComposite(parent, SWT.WRAP);
+ internalComposite.setLayout(new GridLayout());
+ internalComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false));
+
+ ExpandableComposite expandable = toolkit.createExpandableComposite(internalComposite, style);
+ expandable.setText(attributeType.getName());
+ expandable.setLayout(new GridLayout());
+ expandable.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
+
+ Artifact artifact = editor.getEditorInput().getArtifact();
+
+ Composite composite =
+ createAttributeTypeControls(expandable, toolkit, artifact, attributeType, willHaveASection, isEditable,
+ true);
+ expandable.setClient(composite);
+
+ expandable.addExpansionListener(new IExpansionListener() {
+
+ @Override
+ public void expansionStateChanged(ExpansionEvent e) {
+ getManagedForm().getForm().reflow(true);
+ }
+
+ @Override
+ public void expansionStateChanging(ExpansionEvent e) {
+ getManagedForm().getForm().reflow(false);
+ }
+
+ });
+ toolkit.paintBordersFor(expandable);
+ }
+
+ @Override
+ public void commit(boolean onSave) {
+ int saveCount = 0;
+ List<XWidget> widgets = XWidgetUtility.findXWidgetsInControl(composite);
+ for (XWidget xWidget : widgets) {
+ if (xWidget.isEditable()) {
+ if (xWidget instanceof IArtifactWidget) {
+ IArtifactWidget aWidget = (IArtifactWidget) xWidget;
+ try {
+ if (aWidget.isDirty().isTrue()) {
+ aWidget.saveToArtifact();
+ xWidget.removeControlCausedMessage("attribute.dirty");
+ saveCount++;
+ } else {
+ saveCount++;
+ }
+ } catch (OseeCoreException ex) {
+ ex.printStackTrace();
+ }
+ }
+ } else {
+ saveCount++;
+ }
+ }
+
+ // Ensure all changes saved
+ if (saveCount == widgets.size()) {
+ super.commit(onSave);
+ }
+ }
+
+ private final class XWidgetValidationListener implements XModifiedListener {
+
+ @Override
+ public void widgetModified(XWidget xWidget) {
+ if (xWidget != null && xWidget instanceof IArtifactWidget) {
+ IArtifactWidget aWidget = (IArtifactWidget) xWidget;
+ try {
+ Result result = aWidget.isDirty();
+ if (result.isTrue()) {
+ xWidget.setControlCausedMessage("attribute.dirty", "Dirty", IMessageProvider.WARNING);
+ if (!isDirty()) {
+ markDirty();
+ }
+ } else {
+ xWidget.removeControlCausedMessage("attribute.dirty");
+ }
+ } catch (Exception ex) {
+ xWidget.setControlCausedMessage("attribute.dirty", "Unable to compute isDirty", IMessageProvider.ERROR);
+ }
+ }
+ }
+ }
}
diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/artifact/editor/parts/MessageSummaryNote.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/artifact/editor/parts/MessageSummaryNote.java index 761e0d356e7..3d4ecb862a1 100644 --- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/artifact/editor/parts/MessageSummaryNote.java +++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/artifact/editor/parts/MessageSummaryNote.java @@ -38,104 +38,112 @@ import org.eclipse.ui.forms.widgets.ScrolledForm; * @author Roberto E. Escobar
*/
public class MessageSummaryNote {
- private Shell shell;
+ private final Shell shell;
- public MessageSummaryNote(IManagedForm managedForm, String title, IMessage[] messages) {
- final ScrolledForm form = managedForm.getForm();
- final FormToolkit toolkit = managedForm.getToolkit();
+ public MessageSummaryNote(IManagedForm managedForm, String title, IMessage[] messages) {
+ final ScrolledForm form = managedForm.getForm();
+ final FormToolkit toolkit = managedForm.getToolkit();
- shell = new Shell(form.getShell(), SWT.ON_TOP | SWT.TOOL);
- shell.setImage(getImage(form.getMessageType()));
- shell.setText(title);
- shell.setLayout(new FillLayout());
+ shell = new Shell(form.getShell(), SWT.ON_TOP | SWT.TOOL);
+ shell.setImage(getImage(form.getMessageType()));
+ shell.setText(title);
+ shell.setLayout(new FillLayout());
- Composite composite = toolkit.createComposite(shell, toolkit.getBorderStyle());
- composite.setLayout(new GridLayout());
+ Composite composite = toolkit.createComposite(shell, toolkit.getBorderStyle());
+ composite.setLayout(new GridLayout());
- FormText text = toolkit.createFormText(composite, true);
- configureFormText(form.getForm(), text);
- text.setText(getMessageSummary(messages), true, false);
+ FormText text = toolkit.createFormText(composite, true);
+ configureFormText(form.getForm(), text);
+ text.setText(getMessageSummary(messages), true, false);
+ text.addFocusListener(new FocusAdapter() {
- text.addFocusListener(new FocusAdapter() {
+ @Override
+ public void focusLost(FocusEvent e) {
+ shell.close();
+ }
+ });
+ shell.setLocation(0, 0);
+ }
- @Override
- public void focusLost(FocusEvent e) {
- shell.close();
- }
- });
- shell.setLocation(0, 0);
- }
+ public void setLocation(Point point) {
+ shell.setLocation(point);
+ }
- public void setLocation(Point point) {
- shell.setLocation(point);
- }
+ public void open() {
+ shell.pack();
+ shell.open();
+ }
- public void open() {
- shell.pack();
- shell.open();
- }
+ private void configureFormText(final Form form, FormText text) {
+ text.addHyperlinkListener(new HyperlinkAdapter() {
+ @Override
+ public void linkActivated(HyperlinkEvent e) {
+ String is = (String) e.getHref();
+ try {
+ int index = Integer.parseInt(is);
+ IMessage[] messages = form.getChildrenMessages();
+ IMessage message = messages[index];
+ Control c = message.getControl();
+ ((FormText) e.widget).getShell().dispose();
+ if (c != null) {
+ c.setFocus();
+ }
+ } catch (NumberFormatException ex) {
+ }
+ }
+ });
+ text.setImage("error", getImage(IMessageProvider.ERROR));
+ text.setImage("warning", getImage(IMessageProvider.WARNING));
+ text.setImage("info", getImage(IMessageProvider.INFORMATION));
+ }
- private void configureFormText(final Form form, FormText text) {
- text.addHyperlinkListener(new HyperlinkAdapter() {
- public void linkActivated(HyperlinkEvent e) {
- String is = (String) e.getHref();
- try {
- int index = Integer.parseInt(is);
- IMessage[] messages = form.getChildrenMessages();
- IMessage message = messages[index];
- Control c = message.getControl();
- ((FormText) e.widget).getShell().dispose();
- if (c != null) {
- c.setFocus();
- }
- } catch (NumberFormatException ex) {
- }
- }
- });
- text.setImage("error", getImage(IMessageProvider.ERROR));
- text.setImage("warning", getImage(IMessageProvider.WARNING));
- text.setImage("info", getImage(IMessageProvider.INFORMATION));
- }
+ private Image getImage(int type) {
+ Image image = null;
+ switch (type) {
+ case IMessageProvider.ERROR:
+ image = PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJS_ERROR_TSK);
+ break;
+ case IMessageProvider.WARNING:
+ image = PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJS_WARN_TSK);
+ break;
+ case IMessageProvider.INFORMATION:
+ image = PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJS_INFO_TSK);
+ break;
+ default:
+ break;
+ }
+ return image;
+ }
- private Image getImage(int type) {
- switch (type) {
- case IMessageProvider.ERROR:
- return PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJS_ERROR_TSK);
- case IMessageProvider.WARNING:
- return PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJS_WARN_TSK);
- case IMessageProvider.INFORMATION:
- return PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJS_INFO_TSK);
- }
- return null;
- }
-
- private String getMessageSummary(IMessage[] messages) {
- StringWriter sw = new StringWriter();
- PrintWriter pw = new PrintWriter(sw);
- pw.println("<form>");
- for (int i = 0; i < messages.length; i++) {
- IMessage message = messages[i];
- pw.print("<li vspace=\"false\" style=\"image\" indent=\"16\" value=\"");
- switch (message.getMessageType()) {
- case IMessageProvider.ERROR:
- pw.print("error");
- break;
- case IMessageProvider.WARNING:
- pw.print("warning");
- break;
- case IMessageProvider.INFORMATION:
- pw.print("info");
- break;
- }
- pw.print("\"> <a href=\"");
- pw.print(i + "");
- pw.print("\">");
- if (message.getPrefix() != null) pw.print(message.getPrefix());
- pw.print(message.getMessage());
- pw.println("</a></li>");
- }
- pw.println("</form>");
- pw.flush();
- return sw.toString();
- }
+ private String getMessageSummary(IMessage[] messages) {
+ StringWriter sw = new StringWriter();
+ PrintWriter pw = new PrintWriter(sw);
+ pw.println("<form>");
+ for (int i = 0; i < messages.length; i++) {
+ IMessage message = messages[i];
+ pw.print("<li vspace=\"false\" style=\"image\" indent=\"16\" value=\"");
+ switch (message.getMessageType()) {
+ case IMessageProvider.ERROR:
+ pw.print("error");
+ break;
+ case IMessageProvider.WARNING:
+ pw.print("warning");
+ break;
+ case IMessageProvider.INFORMATION:
+ pw.print("info");
+ break;
+ }
+ pw.print("\"> <a href=\"");
+ pw.print(i + "");
+ pw.print("\">");
+ if (message.getPrefix() != null) {
+ pw.print(message.getPrefix());
+ }
+ pw.print(message.getMessage());
+ pw.println("</a></li>");
+ }
+ pw.println("</form>");
+ pw.flush();
+ return sw.toString();
+ }
}
diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/artifact/editor/sections/AttributeActionContribution.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/artifact/editor/sections/AttributeActionContribution.java index c6305ef4ee2..0ab54a9b075 100644 --- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/artifact/editor/sections/AttributeActionContribution.java +++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/artifact/editor/sections/AttributeActionContribution.java @@ -28,72 +28,73 @@ import org.eclipse.osee.framework.ui.swt.ImageManager; */ public class AttributeActionContribution implements IActionContributor { - private final AttributeTypeEditPresenter attributeTypeEditor; + private final AttributeTypeEditPresenter attributeTypeEditor; - public AttributeActionContribution(ArtifactEditor editor) { - AttributeTypeEditPresenter.Display view = new AttributeTypeEditDisplay(); - attributeTypeEditor = new AttributeTypeEditPresenter(new Model(editor), view); - } + public AttributeActionContribution(ArtifactEditor editor) { + AttributeTypeEditPresenter.Display view = new AttributeTypeEditDisplay(); + attributeTypeEditor = new AttributeTypeEditPresenter(new Model(editor), view); + } - private static final class Model implements AttributeTypeEditPresenter.Model { - private final ArtifactEditor editor; + private static final class Model implements AttributeTypeEditPresenter.Model { + private final ArtifactEditor editor; - public Model(ArtifactEditor editor) { - this.editor = editor; - } + public Model(ArtifactEditor editor) { + this.editor = editor; + } - @Override - public void doSave() { - editor.doSave(new NullProgressMonitor()); - } + @Override + public void doSave() { + editor.doSave(new NullProgressMonitor()); + } - @Override - public boolean isDirty() { - return editor.isDirty(); - } + @Override + public boolean isDirty() { + return editor.isDirty(); + } - @Override - public Artifact getArtifact() { - return editor.getEditorInput().getArtifact(); - } - } + @Override + public Artifact getArtifact() { + return editor.getEditorInput().getArtifact(); + } + } - public void contributeToToolBar(IToolBarManager manager) { - manager.add(new OpenAddAttributeTypeDialogAction()); - manager.add(new OpenDeleteAttributeTypeDialogAction()); - } + @Override + public void contributeToToolBar(IToolBarManager manager) { + manager.add(new OpenAddAttributeTypeDialogAction()); + manager.add(new OpenDeleteAttributeTypeDialogAction()); + } - private final class OpenAddAttributeTypeDialogAction extends Action { - public OpenAddAttributeTypeDialogAction() { - super(); - setImageDescriptor(ImageManager.getImageDescriptor(FrameworkImage.ADD_GREEN)); - setToolTipText("Opens a dialog to select which attribute type instances to create on the artifact"); - } + private final class OpenAddAttributeTypeDialogAction extends Action { + public OpenAddAttributeTypeDialogAction() { + super(); + setImageDescriptor(ImageManager.getImageDescriptor(FrameworkImage.ADD_GREEN)); + setToolTipText("Opens a dialog to select which attribute type instances to create on the artifact"); + } - @Override - public void run() { - try { - attributeTypeEditor.onAddAttributeType(); - } catch (OseeCoreException ex) { - OseeLog.log(SkynetGuiPlugin.class, OseeLevel.SEVERE_POPUP, ex); - } - } - } + @Override + public void run() { + try { + attributeTypeEditor.onAddAttributeType(); + } catch (OseeCoreException ex) { + OseeLog.log(SkynetGuiPlugin.class, OseeLevel.SEVERE_POPUP, ex); + } + } + } - private final class OpenDeleteAttributeTypeDialogAction extends Action { - public OpenDeleteAttributeTypeDialogAction() { - super(); - setImageDescriptor(ImageManager.getImageDescriptor(FrameworkImage.DELETE)); - setToolTipText("Opens a dialog to select which attribute type instances to remove from the artifact"); - } + private final class OpenDeleteAttributeTypeDialogAction extends Action { + public OpenDeleteAttributeTypeDialogAction() { + super(); + setImageDescriptor(ImageManager.getImageDescriptor(FrameworkImage.DELETE)); + setToolTipText("Opens a dialog to select which attribute type instances to remove from the artifact"); + } - @Override - public void run() { - try { - attributeTypeEditor.onRemoveAttributeType(); - } catch (OseeCoreException ex) { - OseeLog.log(SkynetGuiPlugin.class, OseeLevel.SEVERE_POPUP, ex); - } - } - } + @Override + public void run() { + try { + attributeTypeEditor.onRemoveAttributeType(); + } catch (OseeCoreException ex) { + OseeLog.log(SkynetGuiPlugin.class, OseeLevel.SEVERE_POPUP, ex); + } + } + } }
\ No newline at end of file diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/artifact/editor/sections/AttributeTypeEditDisplay.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/artifact/editor/sections/AttributeTypeEditDisplay.java index 13acf2e0ac0..75563fb3216 100644 --- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/artifact/editor/sections/AttributeTypeEditDisplay.java +++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/artifact/editor/sections/AttributeTypeEditDisplay.java @@ -8,89 +8,90 @@ * Contributors: * Boeing - initial API and implementation *******************************************************************************/ -package org.eclipse.osee.framework.ui.skynet.artifact.editor.sections;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.List;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.viewers.LabelProvider;
-import org.eclipse.jface.window.Window;
-import org.eclipse.osee.framework.core.data.IAttributeType;
-import org.eclipse.osee.framework.ui.plugin.util.ArrayTreeContentProvider;
-import org.eclipse.osee.framework.ui.skynet.FrameworkImage;
-import org.eclipse.osee.framework.ui.skynet.SkynetGuiPlugin;
-import org.eclipse.osee.framework.ui.swt.ImageManager;
-import org.eclipse.osee.framework.ui.swt.KeyedImage;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.dialogs.CheckedTreeSelectionDialog;
-import org.eclipse.ui.dialogs.ISelectionStatusValidator;
-
-public final class AttributeTypeEditDisplay implements AttributeTypeEditPresenter.Display {
-
- public AttributeTypeEditDisplay() {
- super();
- }
-
- public void showInformation(String title, String message) {
- MessageDialog.openInformation(PlatformUI.getWorkbench().getDisplay().getActiveShell(), title, message);
- }
-
- private CheckedTreeSelectionDialog createDialog(String title, String message, KeyedImage keyedImage) {
- CheckedTreeSelectionDialog dialog =
- new CheckedTreeSelectionDialog(PlatformUI.getWorkbench().getDisplay().getActiveShell(),
- new LabelProvider(), new ArrayTreeContentProvider());
- dialog.setTitle(title);
- Image image = ImageManager.getImage(keyedImage);
- dialog.setImage(image);
- dialog.setMessage(message);
- dialog.setValidator(new ISelectionStatusValidator() {
-
- @Override
- public IStatus validate(Object[] selection) {
- if (selection.length == 0) {
- return new Status(IStatus.ERROR, SkynetGuiPlugin.PLUGIN_ID,
- "Select at least one item or click cancel to exit.");
- }
- return Status.OK_STATUS;
- }
- });
- return dialog;
- }
-
- @Override
- public Collection<IAttributeType> getSelections(OperationType operationType, String title, String message, List<? extends IAttributeType> input) {
- Collection<IAttributeType> toReturn = Collections.emptyList();
- CheckedTreeSelectionDialog dialog = createDialog(title, message, getImage(operationType));
- dialog.setInput(input);
- int result = dialog.open();
- if (result == Window.OK) {
- toReturn = new ArrayList<IAttributeType>();
- for (Object object : dialog.getResult()) {
- if (object instanceof IAttributeType) {
- toReturn.add((IAttributeType) object);
- }
- }
- }
- return toReturn;
- }
-
- private KeyedImage getImage(OperationType operationType) {
- KeyedImage toReturn = null;
- switch (operationType) {
- case ADD_ITEM:
- toReturn = FrameworkImage.ADD_GREEN;
- break;
- case REMOVE_ITEM:
- toReturn = FrameworkImage.DELETE;
- break;
- default:
- break;
- }
- return toReturn;
- }
+package org.eclipse.osee.framework.ui.skynet.artifact.editor.sections; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.List; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Status; +import org.eclipse.jface.dialogs.MessageDialog; +import org.eclipse.jface.viewers.LabelProvider; +import org.eclipse.jface.window.Window; +import org.eclipse.osee.framework.core.data.IAttributeType; +import org.eclipse.osee.framework.ui.plugin.util.ArrayTreeContentProvider; +import org.eclipse.osee.framework.ui.skynet.FrameworkImage; +import org.eclipse.osee.framework.ui.skynet.SkynetGuiPlugin; +import org.eclipse.osee.framework.ui.swt.ImageManager; +import org.eclipse.osee.framework.ui.swt.KeyedImage; +import org.eclipse.swt.graphics.Image; +import org.eclipse.ui.PlatformUI; +import org.eclipse.ui.dialogs.CheckedTreeSelectionDialog; +import org.eclipse.ui.dialogs.ISelectionStatusValidator; + +public final class AttributeTypeEditDisplay implements AttributeTypeEditPresenter.Display { + + public AttributeTypeEditDisplay() { + super(); + } + + @Override + public void showInformation(String title, String message) { + MessageDialog.openInformation(PlatformUI.getWorkbench().getDisplay().getActiveShell(), title, message); + } + + private CheckedTreeSelectionDialog createDialog(String title, String message, KeyedImage keyedImage) { + CheckedTreeSelectionDialog dialog = + new CheckedTreeSelectionDialog(PlatformUI.getWorkbench().getDisplay().getActiveShell(), + new LabelProvider(), new ArrayTreeContentProvider()); + dialog.setTitle(title); + Image image = ImageManager.getImage(keyedImage); + dialog.setImage(image); + dialog.setMessage(message); + dialog.setValidator(new ISelectionStatusValidator() { + + @Override + public IStatus validate(Object[] selection) { + if (selection.length == 0) { + return new Status(IStatus.ERROR, SkynetGuiPlugin.PLUGIN_ID, + "Select at least one item or click cancel to exit."); + } + return Status.OK_STATUS; + } + }); + return dialog; + } + + @Override + public Collection<IAttributeType> getSelections(OperationType operationType, String title, String message, List<? extends IAttributeType> input) { + Collection<IAttributeType> toReturn = Collections.emptyList(); + CheckedTreeSelectionDialog dialog = createDialog(title, message, getImage(operationType)); + dialog.setInput(input); + int result = dialog.open(); + if (result == Window.OK) { + toReturn = new ArrayList<IAttributeType>(); + for (Object object : dialog.getResult()) { + if (object instanceof IAttributeType) { + toReturn.add((IAttributeType) object); + } + } + } + return toReturn; + } + + private KeyedImage getImage(OperationType operationType) { + KeyedImage toReturn = null; + switch (operationType) { + case ADD_ITEM: + toReturn = FrameworkImage.ADD_GREEN; + break; + case REMOVE_ITEM: + toReturn = FrameworkImage.DELETE; + break; + default: + break; + } + return toReturn; + } }
\ No newline at end of file diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/artifact/editor/sections/DetailsFormSection.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/artifact/editor/sections/DetailsFormSection.java index 1f9b511f178..69b4ea14815 100644 --- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/artifact/editor/sections/DetailsFormSection.java +++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/artifact/editor/sections/DetailsFormSection.java @@ -30,72 +30,73 @@ import org.eclipse.ui.forms.widgets.Section; */
public class DetailsFormSection extends ArtifactEditorFormSection {
- private FormText formText;
- private boolean sectionCreated = false;
- private Section section;
+ private FormText formText;
+ private boolean sectionCreated = false;
+ private Section section;
- public DetailsFormSection(ArtifactEditor editor, Composite parent, FormToolkit toolkit, int style) {
- super(editor, parent, toolkit, style);
- }
+ public DetailsFormSection(ArtifactEditor editor, Composite parent, FormToolkit toolkit, int style) {
+ super(editor, parent, toolkit, style);
+ }
- @Override
- public void initialize(IManagedForm form) {
- super.initialize(form);
- section = getSection();
- section.setText("Details");
- section.setLayout(new GridLayout());
- section.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
- // Only load when users selects section
- section.addListener(SWT.Activate, new Listener() {
+ @Override
+ public void initialize(IManagedForm form) {
+ super.initialize(form);
+ section = getSection();
+ section.setText("Details");
+ section.setLayout(new GridLayout());
+ section.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
+ // Only load when users selects section
+ section.addListener(SWT.Activate, new Listener() {
- public void handleEvent(Event e) {
- createSection();
- }
- });
+ @Override
+ public void handleEvent(Event e) {
+ createSection();
+ }
+ });
- }
+ }
- private synchronized void createSection() {
- if (!sectionCreated) {
- final FormToolkit toolkit = getManagedForm().getToolkit();
- Composite composite = toolkit.createComposite(getSection(), toolkit.getBorderStyle() | SWT.WRAP);
- composite.setLayout(new GridLayout());
- composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+ private synchronized void createSection() {
+ if (!sectionCreated) {
+ final FormToolkit toolkit = getManagedForm().getToolkit();
+ Composite composite = toolkit.createComposite(getSection(), toolkit.getBorderStyle() | SWT.WRAP);
+ composite.setLayout(new GridLayout());
+ composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
- formText = toolkit.createFormText(composite, false);
- GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true);
- gd.widthHint = 200;
- formText.setLayoutData(gd);
+ formText = toolkit.createFormText(composite, false);
+ GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true);
+ gd.widthHint = 200;
+ formText.setLayoutData(gd);
- getSection().setClient(composite);
- toolkit.paintBordersFor(composite);
- sectionCreated = true;
- }
+ getSection().setClient(composite);
+ toolkit.paintBordersFor(composite);
+ sectionCreated = true;
+ }
- if (Widgets.isAccessible(formText)) {
- try {
- formText.setText(
- Artifacts.getDetailsFormText(Artifacts.getDetailsKeyValues(getEditorInput().getArtifact())), true,
- true);
- } catch (Exception ex) {
- formText.setText(Lib.exceptionToString(ex), false, false);
- }
- getManagedForm().reflow(true);
- }
- }
+ if (Widgets.isAccessible(formText)) {
+ try {
+ formText.setText(
+ Artifacts.getDetailsFormText(Artifacts.getDetailsKeyValues(getEditorInput().getArtifact())), true,
+ true);
+ } catch (Exception ex) {
+ formText.setText(Lib.exceptionToString(ex), false, false);
+ }
+ getManagedForm().reflow(true);
+ }
+ }
- @Override
- public void dispose() {
- if (formText != null && !formText.isDisposed()) {
- formText.dispose();
- }
- super.dispose();
- }
+ @Override
+ public void dispose() {
+ if (formText != null && !formText.isDisposed()) {
+ formText.dispose();
+ }
+ super.dispose();
+ }
- @Override
- public void refresh() {
- super.refresh();
- createSection();
- }
+ @Override
+ public void refresh() {
+ super.refresh();
+ createSection();
+ }
}
diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/artifact/editor/sections/RelationsFormSection.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/artifact/editor/sections/RelationsFormSection.java index 201bd2ff66a..665ede17b94 100644 --- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/artifact/editor/sections/RelationsFormSection.java +++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/artifact/editor/sections/RelationsFormSection.java @@ -10,16 +10,13 @@ *******************************************************************************/
package org.eclipse.osee.framework.ui.skynet.artifact.editor.sections;
-import org.eclipse.osee.framework.core.exception.OseeCoreException;
-import org.eclipse.osee.framework.logging.OseeLevel;
-import org.eclipse.osee.framework.logging.OseeLog;
import org.eclipse.osee.framework.ui.skynet.RelationsComposite;
-import org.eclipse.osee.framework.ui.skynet.SkynetGuiPlugin;
import org.eclipse.osee.framework.ui.skynet.artifact.editor.AbstractArtifactEditor;
import org.eclipse.osee.framework.ui.skynet.artifact.editor.ArtifactEditor;
import org.eclipse.osee.framework.ui.skynet.artifact.editor.pages.ArtifactFormPage;
import org.eclipse.osee.framework.ui.skynet.util.ArtifactDragAndDrop;
import org.eclipse.osee.framework.ui.swt.ALayout;
+import org.eclipse.osee.framework.ui.swt.Displays;
import org.eclipse.osee.framework.ui.swt.Widgets;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.TreeEvent;
@@ -28,7 +25,6 @@ import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Listener;
@@ -41,109 +37,110 @@ import org.eclipse.ui.forms.widgets.Section; */
public class RelationsFormSection extends ArtifactEditorFormSection {
- private RelationsComposite relationComposite;
- private boolean sectionCreated = false;
-
- public RelationsFormSection(AbstractArtifactEditor editor, Composite parent, FormToolkit toolkit, int style) {
- super(editor, parent, toolkit, style);
- }
-
- @Override
- public void initialize(IManagedForm form) {
- super.initialize(form);
- final FormToolkit toolkit = form.getToolkit();
-
- final Section section = getSection();
- section.setText("Relations");
-
- section.setLayout(new GridLayout());
- section.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
- // Only load when users selects section
- section.addListener(SWT.Activate, new Listener() {
-
- public void handleEvent(Event e) {
- try {
- createSection(section, toolkit);
- } catch (OseeCoreException ex) {
- OseeLog.log(SkynetGuiPlugin.class, OseeLevel.SEVERE, ex);
- }
- }
- });
- }
-
- protected synchronized void createSection(Section section, FormToolkit toolkit) throws OseeCoreException {
- if (sectionCreated) return;
- Composite sectionBody = toolkit.createComposite(section, toolkit.getBorderStyle());
- sectionBody.setLayout(ALayout.getZeroMarginLayout());
- sectionBody.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
-
- Label dragDropLabel = new Label(sectionBody, SWT.BORDER);
- dragDropLabel.setText("Click here to drag this \"" + getEditorInput().getArtifact().getArtifactTypeName() + "\"");
- GridData gd = new GridData(GridData.FILL_BOTH);
- gd.heightHint = 25;
- dragDropLabel.setLayoutData(gd);
- addDragAndDrop(dragDropLabel);
- toolkit.adapt(dragDropLabel, true, true);
-
- relationComposite = new RelationsComposite(getEditor(), sectionBody, SWT.NONE, getEditorInput().getArtifact());
- relationComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
-
- section.setClient(sectionBody);
- toolkit.paintBordersFor(section);
-
- relationComposite.getTreeViewer().getTree().addTreeListener(new TreeListener() {
-
- @Override
- public void treeCollapsed(TreeEvent e) {
- redrawPage();
- }
-
- @Override
- public void treeExpanded(TreeEvent e) {
- redrawPage();
- }
-
- private void redrawPage() {
- Display.getDefault().asyncExec(new Runnable() {
- public void run() {
- getSection().getParent().layout();
- getManagedForm().reflow(true);
- }
- });
- }
- });
- sectionCreated = true;
- }
-
- protected void handleExpandAndCollapse() {
- ((ArtifactFormPage) getEditor().getSelectedPage()).refresh();
- }
-
- protected void addDragAndDrop(Control dropArea) {
- new ArtifactDragAndDrop(dropArea, getEditorInput().getArtifact(), ArtifactEditor.EDITOR_ID);
- }
-
- public RelationsComposite getRelationComposite() {
- return relationComposite;
- }
-
- @Override
- public void refresh() {
- super.refresh();
- Display.getDefault().asyncExec(new Runnable() {
- public void run() {
- if (Widgets.isAccessible(relationComposite)) {
- relationComposite.refresh();
- }
- }
- });
- }
-
- @Override
- public void dispose() {
- if (Widgets.isAccessible(relationComposite)) {
- relationComposite.dispose();
- }
- super.dispose();
- }
+ private RelationsComposite relationComposite;
+ private boolean sectionCreated = false;
+
+ public RelationsFormSection(AbstractArtifactEditor editor, Composite parent, FormToolkit toolkit, int style) {
+ super(editor, parent, toolkit, style);
+ }
+
+ @Override
+ public void initialize(IManagedForm form) {
+ super.initialize(form);
+ final FormToolkit toolkit = form.getToolkit();
+
+ final Section section = getSection();
+ section.setText("Relations");
+
+ section.setLayout(new GridLayout());
+ section.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
+ // Only load when users selects section
+ section.addListener(SWT.Activate, new Listener() {
+
+ @Override
+ public void handleEvent(Event e) {
+ createSection(section, toolkit);
+ }
+ });
+ }
+
+ protected synchronized void createSection(Section section, FormToolkit toolkit) {
+ if (sectionCreated) {
+ return;
+ }
+ Composite sectionBody = toolkit.createComposite(section, toolkit.getBorderStyle());
+ sectionBody.setLayout(ALayout.getZeroMarginLayout());
+ sectionBody.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+
+ Label dragDropLabel = new Label(sectionBody, SWT.BORDER);
+ dragDropLabel.setText("Click here to drag this \"" + getEditorInput().getArtifact().getArtifactTypeName() + "\"");
+ GridData gd = new GridData(GridData.FILL_BOTH);
+ gd.heightHint = 25;
+ dragDropLabel.setLayoutData(gd);
+ addDragAndDrop(dragDropLabel);
+ toolkit.adapt(dragDropLabel, true, true);
+
+ relationComposite = new RelationsComposite(getEditor(), sectionBody, SWT.NONE, getEditorInput().getArtifact());
+ relationComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+
+ section.setClient(sectionBody);
+ toolkit.paintBordersFor(section);
+
+ relationComposite.getTreeViewer().getTree().addTreeListener(new TreeListener() {
+
+ @Override
+ public void treeCollapsed(TreeEvent e) {
+ redrawPage();
+ }
+
+ @Override
+ public void treeExpanded(TreeEvent e) {
+ redrawPage();
+ }
+
+ private void redrawPage() {
+ Displays.ensureInDisplayThread(new Runnable() {
+ @Override
+ public void run() {
+ getSection().getParent().layout();
+ getManagedForm().reflow(true);
+ }
+ });
+ }
+ });
+ sectionCreated = true;
+ }
+
+ protected void handleExpandAndCollapse() {
+ ((ArtifactFormPage) getEditor().getSelectedPage()).refresh();
+ }
+
+ protected void addDragAndDrop(Control dropArea) {
+ new ArtifactDragAndDrop(dropArea, getEditorInput().getArtifact(), ArtifactEditor.EDITOR_ID);
+ }
+
+ public RelationsComposite getRelationComposite() {
+ return relationComposite;
+ }
+
+ @Override
+ public void refresh() {
+ super.refresh();
+ Displays.ensureInDisplayThread(new Runnable() {
+ @Override
+ public void run() {
+ if (Widgets.isAccessible(relationComposite)) {
+ relationComposite.refresh();
+ }
+ }
+ });
+ }
+
+ @Override
+ public void dispose() {
+ if (Widgets.isAccessible(relationComposite)) {
+ relationComposite.dispose();
+ }
+ super.dispose();
+ }
}
diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/artifact/massEditor/MassArtifactEditor.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/artifact/massEditor/MassArtifactEditor.java index 916d0d06c95..cd310b4b412 100644 --- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/artifact/massEditor/MassArtifactEditor.java +++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/artifact/massEditor/MassArtifactEditor.java @@ -30,11 +30,11 @@ import org.eclipse.osee.framework.skynet.core.utility.Artifacts; import org.eclipse.osee.framework.ui.plugin.OseeUiActions;
import org.eclipse.osee.framework.ui.plugin.PluginUiImage;
import org.eclipse.osee.framework.ui.plugin.util.AWorkbench;
-import org.eclipse.osee.framework.ui.plugin.util.Displays;
import org.eclipse.osee.framework.ui.plugin.xnavigate.XNavigateComposite.TableLoadOption;
import org.eclipse.osee.framework.ui.skynet.SkynetGuiPlugin;
import org.eclipse.osee.framework.ui.skynet.artifact.editor.AbstractArtifactEditor;
import org.eclipse.osee.framework.ui.swt.ALayout;
+import org.eclipse.osee.framework.ui.swt.Displays;
import org.eclipse.osee.framework.ui.swt.IDirtiableEditor;
import org.eclipse.osee.framework.ui.swt.ImageManager;
import org.eclipse.swt.SWT;
@@ -55,243 +55,245 @@ import org.eclipse.ui.PartInitException; * @author Donald G. Dunne
*/
public class MassArtifactEditor extends AbstractArtifactEditor implements IActionable {
- public static final String EDITOR_ID = "org.eclipse.osee.framework.ui.skynet.massEditor.MassArtifactEditor";
- private int artifactsPageIndex;
- private MassXViewer xViewer;
- private Label branchLabel;
- private ToolBar toolBar;
-
- /**
- * @return the xViewer
- */
- public MassXViewer getXViewer() {
- return xViewer;
- }
-
- @Override
- public void doSave(IProgressMonitor monitor) {
- try {
- Artifacts.persistInTransaction(xViewer.getArtifacts());
- } catch (Exception ex) {
- OseeLog.log(SkynetGuiPlugin.class, OseeLevel.SEVERE_POPUP, ex);
- }
- onDirtied();
- }
-
- public static void editArtifacts(final String name, final Collection<? extends Artifact> artifacts, TableLoadOption... tableLoadOptions) {
- Set<TableLoadOption> options = new HashSet<TableLoadOption>();
- options.addAll(Arrays.asList(tableLoadOptions));
- Displays.ensureInDisplayThread(new Runnable() {
- public void run() {
- boolean accessControlFilteredResults = false;
- try {
- Set<Artifact> accessibleArts = new HashSet<Artifact>();
- for (Artifact artifact : artifacts) {
- if (!AccessControlManager.hasPermission(artifact, PermissionEnum.READ)) {
- OseeLog.log(SkynetGuiPlugin.class, Level.INFO,
- "The user " + UserManager.getUser() + " does not have read access to " + artifact);
- accessControlFilteredResults = true;
- } else {
- accessibleArts.add(artifact);
- }
- }
- if (accessibleArts.isEmpty()) {
- AWorkbench.popup("ERROR", "No Artifacts to edit");
- } else {
- AWorkbench.getActivePage().openEditor(
- new MassArtifactEditorInput(name, accessibleArts, new MassXViewerFactory(accessibleArts)),
- EDITOR_ID);
- }
- if (accessControlFilteredResults) {
- AWorkbench.popup("ERROR", "Some Artifacts not loaded due to access control limitations.");
- }
- } catch (Exception ex) {
- OseeLog.log(SkynetGuiPlugin.class, OseeLevel.SEVERE_POPUP, ex);
- }
- }
- }, options.contains(TableLoadOption.ForcePend));
- }
-
- public static void editArtifact(final Artifact artifact, TableLoadOption... tableLoadOptions) {
- editArtifacts("", Arrays.asList(artifact));
- }
-
- public void createTaskActionBar(Composite parent) {
-
- // Button composite for state transitions, etc
- Composite bComp = new Composite(parent, SWT.NONE);
- // bComp.setBackground(mainSComp.getDisplay().getSystemColor(SWT.COLOR_CYAN));
- bComp.setLayout(ALayout.getZeroMarginLayout(2, false));
- bComp.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
-
- Composite leftComp = new Composite(bComp, SWT.NONE);
- leftComp.setLayout(new GridLayout());
- leftComp.setLayoutData(new GridData(GridData.BEGINNING | GridData.FILL_HORIZONTAL));
-
- branchLabel = new Label(leftComp, SWT.NONE);
- branchLabel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
-
- Composite rightComp = new Composite(bComp, SWT.NONE);
- rightComp.setLayout(new GridLayout());
- rightComp.setLayoutData(new GridData(GridData.END));
-
- toolBar = new ToolBar(rightComp, SWT.FLAT | SWT.RIGHT);
- GridData gd = new GridData(GridData.FILL_HORIZONTAL);
- toolBar.setLayoutData(gd);
- ToolItem item = null;
-
- item = new ToolItem(toolBar, SWT.PUSH);
- item.setImage(ImageManager.getImage(PluginUiImage.REFRESH));
- item.setToolTipText("Refresh");
- item.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- xViewer.refresh();
- }
- });
-
- OseeUiActions.addButtonToEditorToolBar(this, SkynetGuiPlugin.getInstance(), toolBar, EDITOR_ID,
- "Mass Artifact Editor");
- }
-
- public static void editArtifacts(final MassArtifactEditorInput input) {
- Displays.ensureInDisplayThread(new Runnable() {
- @Override
- public void run() {
- IWorkbenchPage page = AWorkbench.getActivePage();
- try {
- page.openEditor(input, EDITOR_ID);
- } catch (PartInitException ex) {
- OseeLog.log(SkynetGuiPlugin.class, OseeLevel.SEVERE_POPUP, ex);
- }
- }
- });
-
- }
-
- @Override
- public boolean isSaveOnCloseNeeded() {
- return isDirty();
- }
-
- @Override
- public void dispose() {
- super.dispose();
-
- for (Artifact taskArt : xViewer.getArtifacts()) {
- try {
- if (taskArt != null && !taskArt.isDeleted() && taskArt.hasDirtyAttributes()) {
- taskArt.reloadAttributesAndRelations();
- }
- } catch (Exception ex) {
- OseeLog.log(SkynetGuiPlugin.class, Level.SEVERE, ex);
- }
- }
- }
-
- public ArrayList<Artifact> getLoadedArtifacts() {
- return xViewer.getLoadedArtifacts();
- }
-
- @Override
- public boolean isDirty() {
- for (Artifact taskArt : xViewer.getArtifacts()) {
- if (!taskArt.isDeleted() && taskArt.hasDirtyAttributes()) {
- return true;
- }
- }
- return false;
- }
-
- @Override
- public String toString() {
- return "MassArtifactEditor";
- }
-
- @Override
- protected void addPages() {
- IEditorInput editorInput = getEditorInput();
- if (!(editorInput instanceof MassArtifactEditorInput)) {
- throw new IllegalArgumentException("Editor Input not TaskEditorInput");
- }
-
- if (((MassArtifactEditorInput) editorInput).getName().equals("")) {
- setPartName("Mass Artifact Editor");
- } else {
- setPartName(((MassArtifactEditorInput) editorInput).getName());
- }
-
- SkynetGuiPlugin.getInstance().setHelp(getContainer(), "mass_artifact_editor",
- "org.eclipse.osee.framework.help.ui");
-
- Composite comp = new Composite(getContainer(), SWT.NONE);
- comp.setLayout(new GridLayout(1, true));
- comp.setLayoutData(new GridData(GridData.FILL_BOTH));
-
- createTaskActionBar(comp);
-
- xViewer = new MassXViewer(comp, SWT.MULTI | SWT.BORDER | SWT.FULL_SELECTION, this);
- xViewer.getTree().setLayoutData(new GridData(GridData.FILL_BOTH));
- xViewer.setContentProvider(new org.eclipse.osee.framework.ui.skynet.artifact.massEditor.MassContentProvider(
- xViewer));
- xViewer.setLabelProvider(new org.eclipse.osee.framework.ui.skynet.artifact.massEditor.MassLabelProvider(xViewer));
- branchLabel.setText("Branch: " + (getBranch() == null ? "No Artifacts Returned" : getBranch().getShortName()));
- artifactsPageIndex = addPage(comp);
- setPageText(artifactsPageIndex, "Artifacts");
-
- new ActionContributionItem(xViewer.getCustomizeAction()).fill(toolBar, -1);
-
- Tree tree = xViewer.getTree();
- GridData gridData = new GridData(GridData.FILL_BOTH | GridData.GRAB_VERTICAL | GridData.GRAB_HORIZONTAL);
- tree.setLayoutData(gridData);
- tree.setHeaderVisible(true);
- tree.setLinesVisible(true);
-
- setActivePage(artifactsPageIndex);
- try {
- xViewer.set(((MassArtifactEditorInput) editorInput).getArtifacts());
- } catch (Exception ex) {
- OseeLog.log(SkynetGuiPlugin.class, OseeLevel.SEVERE_POPUP, ex);
- }
- }
-
- public Branch getBranch() {
- if (((MassArtifactEditorInput) getEditorInput()).getArtifacts().isEmpty()) {
- return null;
- }
- return ((MassArtifactEditorInput) getEditorInput()).getArtifacts().iterator().next().getBranch();
- }
-
- @Override
- public void onDirtied() {
- Displays.ensureInDisplayThread(new Runnable() {
-
- public void run() {
- firePropertyChange(PROP_DIRTY);
- }
- });
- }
-
- public String getCurrentStateName() {
- return "";
- }
-
- public IDirtiableEditor getEditor() {
- return this;
- }
-
- public boolean isArtifactsEditable() {
- return true;
- }
-
- /**
- * @return the artifacts
- */
- public Collection<? extends Artifact> getArtifacts() {
- return xViewer.getArtifacts();
- }
-
- public String getActionDescription() {
- return "";
- }
+ public static final String EDITOR_ID = "org.eclipse.osee.framework.ui.skynet.massEditor.MassArtifactEditor";
+ private int artifactsPageIndex;
+ private MassXViewer xViewer;
+ private Label branchLabel;
+ private ToolBar toolBar;
+
+ /**
+ * @return the xViewer
+ */
+ public MassXViewer getXViewer() {
+ return xViewer;
+ }
+
+ @Override
+ public void doSave(IProgressMonitor monitor) {
+ try {
+ Artifacts.persistInTransaction(xViewer.getArtifacts());
+ } catch (Exception ex) {
+ OseeLog.log(SkynetGuiPlugin.class, OseeLevel.SEVERE_POPUP, ex);
+ }
+ onDirtied();
+ }
+
+ public static void editArtifacts(final String name, final Collection<? extends Artifact> artifacts, TableLoadOption... tableLoadOptions) {
+ Set<TableLoadOption> options = new HashSet<TableLoadOption>();
+ options.addAll(Arrays.asList(tableLoadOptions));
+ Displays.ensureInDisplayThread(new Runnable() {
+ @Override
+ public void run() {
+ boolean accessControlFilteredResults = false;
+ try {
+ Set<Artifact> accessibleArts = new HashSet<Artifact>();
+ for (Artifact artifact : artifacts) {
+ if (!AccessControlManager.hasPermission(artifact, PermissionEnum.READ)) {
+ OseeLog.log(SkynetGuiPlugin.class, Level.INFO,
+ "The user " + UserManager.getUser() + " does not have read access to " + artifact);
+ accessControlFilteredResults = true;
+ } else {
+ accessibleArts.add(artifact);
+ }
+ }
+ if (accessibleArts.isEmpty()) {
+ AWorkbench.popup("ERROR", "No Artifacts to edit");
+ } else {
+ AWorkbench.getActivePage().openEditor(
+ new MassArtifactEditorInput(name, accessibleArts, new MassXViewerFactory(accessibleArts)),
+ EDITOR_ID);
+ }
+ if (accessControlFilteredResults) {
+ AWorkbench.popup("ERROR", "Some Artifacts not loaded due to access control limitations.");
+ }
+ } catch (Exception ex) {
+ OseeLog.log(SkynetGuiPlugin.class, OseeLevel.SEVERE_POPUP, ex);
+ }
+ }
+ }, options.contains(TableLoadOption.ForcePend));
+ }
+
+ public static void editArtifact(final Artifact artifact, TableLoadOption... tableLoadOptions) {
+ editArtifacts("", Arrays.asList(artifact));
+ }
+
+ public void createTaskActionBar(Composite parent) {
+
+ // Button composite for state transitions, etc
+ Composite bComp = new Composite(parent, SWT.NONE);
+ // bComp.setBackground(mainSComp.getDisplay().getSystemColor(SWT.COLOR_CYAN));
+ bComp.setLayout(ALayout.getZeroMarginLayout(2, false));
+ bComp.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+
+ Composite leftComp = new Composite(bComp, SWT.NONE);
+ leftComp.setLayout(new GridLayout());
+ leftComp.setLayoutData(new GridData(GridData.BEGINNING | GridData.FILL_HORIZONTAL));
+
+ branchLabel = new Label(leftComp, SWT.NONE);
+ branchLabel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+
+ Composite rightComp = new Composite(bComp, SWT.NONE);
+ rightComp.setLayout(new GridLayout());
+ rightComp.setLayoutData(new GridData(GridData.END));
+
+ toolBar = new ToolBar(rightComp, SWT.FLAT | SWT.RIGHT);
+ GridData gd = new GridData(GridData.FILL_HORIZONTAL);
+ toolBar.setLayoutData(gd);
+ ToolItem item = null;
+
+ item = new ToolItem(toolBar, SWT.PUSH);
+ item.setImage(ImageManager.getImage(PluginUiImage.REFRESH));
+ item.setToolTipText("Refresh");
+ item.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ xViewer.refresh();
+ }
+ });
+
+ OseeUiActions.addButtonToEditorToolBar(this, SkynetGuiPlugin.getInstance(), toolBar, EDITOR_ID,
+ "Mass Artifact Editor");
+ }
+
+ public static void editArtifacts(final MassArtifactEditorInput input) {
+ Displays.ensureInDisplayThread(new Runnable() {
+ @Override
+ public void run() {
+ IWorkbenchPage page = AWorkbench.getActivePage();
+ try {
+ page.openEditor(input, EDITOR_ID);
+ } catch (PartInitException ex) {
+ OseeLog.log(SkynetGuiPlugin.class, OseeLevel.SEVERE_POPUP, ex);
+ }
+ }
+ });
+
+ }
+
+ @Override
+ public boolean isSaveOnCloseNeeded() {
+ return isDirty();
+ }
+
+ @Override
+ public void dispose() {
+ super.dispose();
+
+ for (Artifact taskArt : xViewer.getArtifacts()) {
+ try {
+ if (taskArt != null && !taskArt.isDeleted() && taskArt.hasDirtyAttributes()) {
+ taskArt.reloadAttributesAndRelations();
+ }
+ } catch (Exception ex) {
+ OseeLog.log(SkynetGuiPlugin.class, Level.SEVERE, ex);
+ }
+ }
+ }
+
+ public ArrayList<Artifact> getLoadedArtifacts() {
+ return xViewer.getLoadedArtifacts();
+ }
+
+ @Override
+ public boolean isDirty() {
+ for (Artifact taskArt : xViewer.getArtifacts()) {
+ if (!taskArt.isDeleted() && taskArt.hasDirtyAttributes()) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ @Override
+ public String toString() {
+ return "MassArtifactEditor";
+ }
+
+ @Override
+ protected void addPages() {
+ IEditorInput editorInput = getEditorInput();
+ if (!(editorInput instanceof MassArtifactEditorInput)) {
+ throw new IllegalArgumentException("Editor Input not TaskEditorInput");
+ }
+
+ if (((MassArtifactEditorInput) editorInput).getName().equals("")) {
+ setPartName("Mass Artifact Editor");
+ } else {
+ setPartName(((MassArtifactEditorInput) editorInput).getName());
+ }
+
+ SkynetGuiPlugin.getInstance().setHelp(getContainer(), "mass_artifact_editor",
+ "org.eclipse.osee.framework.help.ui");
+
+ Composite comp = new Composite(getContainer(), SWT.NONE);
+ comp.setLayout(new GridLayout(1, true));
+ comp.setLayoutData(new GridData(GridData.FILL_BOTH));
+
+ createTaskActionBar(comp);
+
+ xViewer = new MassXViewer(comp, SWT.MULTI | SWT.BORDER | SWT.FULL_SELECTION, this);
+ xViewer.getTree().setLayoutData(new GridData(GridData.FILL_BOTH));
+ xViewer.setContentProvider(new org.eclipse.osee.framework.ui.skynet.artifact.massEditor.MassContentProvider(
+ xViewer));
+ xViewer.setLabelProvider(new org.eclipse.osee.framework.ui.skynet.artifact.massEditor.MassLabelProvider(xViewer));
+ branchLabel.setText("Branch: " + (getBranch() == null ? "No Artifacts Returned" : getBranch().getShortName()));
+ artifactsPageIndex = addPage(comp);
+ setPageText(artifactsPageIndex, "Artifacts");
+
+ new ActionContributionItem(xViewer.getCustomizeAction()).fill(toolBar, -1);
+
+ Tree tree = xViewer.getTree();
+ GridData gridData = new GridData(GridData.FILL_BOTH | GridData.GRAB_VERTICAL | GridData.GRAB_HORIZONTAL);
+ tree.setLayoutData(gridData);
+ tree.setHeaderVisible(true);
+ tree.setLinesVisible(true);
+
+ setActivePage(artifactsPageIndex);
+ try {
+ xViewer.set(((MassArtifactEditorInput) editorInput).getArtifacts());
+ } catch (Exception ex) {
+ OseeLog.log(SkynetGuiPlugin.class, OseeLevel.SEVERE_POPUP, ex);
+ }
+ }
+
+ public Branch getBranch() {
+ if (((MassArtifactEditorInput) getEditorInput()).getArtifacts().isEmpty()) {
+ return null;
+ }
+ return ((MassArtifactEditorInput) getEditorInput()).getArtifacts().iterator().next().getBranch();
+ }
+
+ @Override
+ public void onDirtied() {
+ Displays.ensureInDisplayThread(new Runnable() {
+ @Override
+ public void run() {
+ firePropertyChange(PROP_DIRTY);
+ }
+ });
+ }
+
+ public String getCurrentStateName() {
+ return "";
+ }
+
+ public IDirtiableEditor getEditor() {
+ return this;
+ }
+
+ public boolean isArtifactsEditable() {
+ return true;
+ }
+
+ /**
+ * @return the artifacts
+ */
+ public Collection<? extends Artifact> getArtifacts() {
+ return xViewer.getArtifacts();
+ }
+
+ @Override
+ public String getActionDescription() {
+ return "";
+ }
}
diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/artifact/massEditor/MassArtifactEditorInput.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/artifact/massEditor/MassArtifactEditorInput.java index 508368cc0cb..00a77ed1128 100644 --- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/artifact/massEditor/MassArtifactEditorInput.java +++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/artifact/massEditor/MassArtifactEditorInput.java @@ -22,47 +22,53 @@ import org.eclipse.ui.IPersistableElement; */ public class MassArtifactEditorInput implements IEditorInput { - private final Collection<? extends Artifact> artifacts; - private final String name; - private final SkynetXViewerFactory skynetXViewerFactory; + private final Collection<? extends Artifact> artifacts; + private final String name; + private final SkynetXViewerFactory skynetXViewerFactory; - public SkynetXViewerFactory getXViewerFactory() { - return skynetXViewerFactory; - } + public SkynetXViewerFactory getXViewerFactory() { + return skynetXViewerFactory; + } - public MassArtifactEditorInput(String name, Collection<? extends Artifact> artifacts, SkynetXViewerFactory skynetXViewerFactory) { - this.name = name; - this.artifacts = artifacts; - this.skynetXViewerFactory = skynetXViewerFactory; - } + public MassArtifactEditorInput(String name, Collection<? extends Artifact> artifacts, SkynetXViewerFactory skynetXViewerFactory) { + this.name = name; + this.artifacts = artifacts; + this.skynetXViewerFactory = skynetXViewerFactory; + } - public Collection<? extends Artifact> getArtifacts() { - return artifacts; - } + public Collection<? extends Artifact> getArtifacts() { + return artifacts; + } - public String getName() { - return name; - } + @Override + public String getName() { + return name; + } - public boolean exists() { - return false; - } + @Override + public boolean exists() { + return false; + } - public ImageDescriptor getImageDescriptor() { - return null; - } + @Override + public ImageDescriptor getImageDescriptor() { + return null; + } - public IPersistableElement getPersistable() { - return null; - } + @Override + public IPersistableElement getPersistable() { + return null; + } - public String getToolTipText() { - return ""; - } + @Override + public String getToolTipText() { + return ""; + } - @SuppressWarnings("unchecked") - public Object getAdapter(Class adapter) { - return null; - } + @SuppressWarnings("rawtypes") + @Override + public Object getAdapter(Class adapter) { + return null; + } } diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/artifact/massEditor/MassContentProvider.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/artifact/massEditor/MassContentProvider.java index e2f089a40f1..44a2e9f804e 100644 --- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/artifact/massEditor/MassContentProvider.java +++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/artifact/massEditor/MassContentProvider.java @@ -17,114 +17,144 @@ import org.eclipse.jface.viewers.ITreeContentProvider; import org.eclipse.jface.viewers.Viewer; import org.eclipse.osee.framework.skynet.core.artifact.Artifact; import org.eclipse.osee.framework.skynet.core.event2.artifact.EventBasicGuidArtifact; -import org.eclipse.osee.framework.ui.plugin.util.Displays; +import org.eclipse.osee.framework.ui.swt.Displays; public class MassContentProvider implements ITreeContentProvider { - protected Collection<Artifact> rootSet = new HashSet<Artifact>(); - private final MassXViewer xViewer; - private static Object[] EMPTY_ARRAY = new Object[0]; - - public MassContentProvider(MassXViewer xViewer) { - super(); - this.xViewer = xViewer; - } - - public void add(final Artifact item) { - add(Arrays.asList(item)); - } - - public void add(final Collection<? extends Artifact> items) { - Displays.ensureInDisplayThread(new Runnable() { - public void run() { - if (xViewer.getInput() == null) xViewer.setInput(rootSet); - rootSet.addAll(items); - xViewer.refresh(); - }; - }); - } - - public void set(final Collection<? extends Artifact> arts) { - Displays.ensureInDisplayThread(new Runnable() { - public void run() { - if (xViewer.getInput() == null) xViewer.setInput(rootSet); - clear(); - add(arts); - }; - }); - } - - public void updateAll(final Collection<? extends Object> arts) { - if (arts.isEmpty()) return; - Displays.ensureInDisplayThread(new Runnable() { - public void run() { - if (xViewer.getInput() == null) xViewer.setInput(rootSet); - for (Object art : arts) { - xViewer.update(art, null); - } - }; - }); - } - - public void remove(final EventBasicGuidArtifact art) { - removeAll(Arrays.asList(art)); - } - - public void removeAll(final Collection<? extends EventBasicGuidArtifact> arts) { - Displays.ensureInDisplayThread(new Runnable() { - public void run() { - if (xViewer.getInput() == null) xViewer.setInput(rootSet); - rootSet.removeAll(arts); - xViewer.refresh(); - }; - }); - } - - public void removeAllArts(final Collection<? extends Artifact> arts) { - Displays.ensureInDisplayThread(new Runnable() { - public void run() { - if (xViewer.getInput() == null) xViewer.setInput(rootSet); - rootSet.removeAll(arts); - xViewer.refresh(); - }; - }); - } - - public void clear() { - Displays.ensureInDisplayThread(new Runnable() { - public void run() { - if (xViewer.getInput() == null) xViewer.setInput(rootSet); - rootSet.clear(); - xViewer.refresh(); - }; - }); - } - - @SuppressWarnings("rawtypes") - public Object[] getChildren(Object parentElement) { - if (parentElement instanceof Collection) { - return ((Collection) parentElement).toArray(); - } - return EMPTY_ARRAY; - } - - public Object getParent(Object element) { - return null; - } - - public boolean hasChildren(Object element) { - if (element instanceof Collection) return true; - return false; - } - - public Object[] getElements(Object inputElement) { - if (inputElement instanceof String) return new Object[] {inputElement}; - return getChildren(inputElement); - } - - public void dispose() { - } - - public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { - } + protected Collection<Artifact> rootSet = new HashSet<Artifact>(); + private final MassXViewer xViewer; + private static Object[] EMPTY_ARRAY = new Object[0]; + + public MassContentProvider(MassXViewer xViewer) { + super(); + this.xViewer = xViewer; + } + + public void add(final Artifact item) { + add(Arrays.asList(item)); + } + + public void add(final Collection<? extends Artifact> items) { + Displays.ensureInDisplayThread(new Runnable() { + @Override + public void run() { + if (xViewer.getInput() == null) { + xViewer.setInput(rootSet); + } + rootSet.addAll(items); + xViewer.refresh(); + }; + }); + } + + public void set(final Collection<? extends Artifact> arts) { + Displays.ensureInDisplayThread(new Runnable() { + @Override + public void run() { + if (xViewer.getInput() == null) { + xViewer.setInput(rootSet); + } + clear(); + add(arts); + }; + }); + } + + public void updateAll(final Collection<? extends Object> arts) { + if (arts.isEmpty()) { + return; + } + Displays.ensureInDisplayThread(new Runnable() { + @Override + public void run() { + if (xViewer.getInput() == null) { + xViewer.setInput(rootSet); + } + for (Object art : arts) { + xViewer.update(art, null); + } + }; + }); + } + + public void remove(final EventBasicGuidArtifact art) { + removeAll(Arrays.asList(art)); + } + + public void removeAll(final Collection<? extends EventBasicGuidArtifact> arts) { + Displays.ensureInDisplayThread(new Runnable() { + @Override + public void run() { + if (xViewer.getInput() == null) { + xViewer.setInput(rootSet); + } + rootSet.removeAll(arts); + xViewer.refresh(); + }; + }); + } + + public void removeAllArts(final Collection<? extends Artifact> arts) { + Displays.ensureInDisplayThread(new Runnable() { + @Override + public void run() { + if (xViewer.getInput() == null) { + xViewer.setInput(rootSet); + } + rootSet.removeAll(arts); + xViewer.refresh(); + }; + }); + } + + public void clear() { + Displays.ensureInDisplayThread(new Runnable() { + @Override + public void run() { + if (xViewer.getInput() == null) { + xViewer.setInput(rootSet); + } + rootSet.clear(); + xViewer.refresh(); + }; + }); + } + + @SuppressWarnings("rawtypes") + @Override + public Object[] getChildren(Object parentElement) { + if (parentElement instanceof Collection) { + return ((Collection) parentElement).toArray(); + } + return EMPTY_ARRAY; + } + + @Override + public Object getParent(Object element) { + return null; + } + + @Override + public boolean hasChildren(Object element) { + if (element instanceof Collection) { + return true; + } + return false; + } + + @Override + public Object[] getElements(Object inputElement) { + if (inputElement instanceof String) { + return new Object[] {inputElement}; + } + return getChildren(inputElement); + } + + @Override + public void dispose() { + } + + @Override + public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { + } } diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/artifact/massEditor/MassLabelProvider.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/artifact/massEditor/MassLabelProvider.java index 0c11848726a..c74dc0e0cf9 100644 --- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/artifact/massEditor/MassLabelProvider.java +++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/artifact/massEditor/MassLabelProvider.java @@ -24,88 +24,92 @@ import org.eclipse.swt.graphics.Image; public class MassLabelProvider extends XViewerLabelProvider { - private final MassXViewer xViewer; + private final MassXViewer xViewer; - public MassLabelProvider(MassXViewer xViewer) { - super(xViewer); - this.xViewer = xViewer; - } + public MassLabelProvider(MassXViewer xViewer) { + super(xViewer); + this.xViewer = xViewer; + } - @Override - public Image getColumnImage(Object element, XViewerColumn col, int columnIndex) throws XViewerException { - if (col == null) { - return null; - } - if (columnIndex != 0 && col instanceof XViewerValueColumn) { - return ((XViewerValueColumn) col).getColumnImage(element, col, columnIndex); - } - Artifact artifact = (Artifact) element; - if (artifact == null || artifact.isDeleted()) { - return null; - } - if (columnIndex == 0) { - return ArtifactImageManager.getImage(artifact); - } - return null; - } + @Override + public Image getColumnImage(Object element, XViewerColumn col, int columnIndex) throws XViewerException { + if (col == null) { + return null; + } + if (columnIndex != 0 && col instanceof XViewerValueColumn) { + return ((XViewerValueColumn) col).getColumnImage(element, col, columnIndex); + } + Artifact artifact = (Artifact) element; + if (artifact == null || artifact.isDeleted()) { + return null; + } + if (columnIndex == 0) { + return ArtifactImageManager.getImage(artifact); + } + return null; + } - @Override - public String getColumnText(Object element, XViewerColumn col, int columnIndex) throws XViewerException { - try { - if (col == null) { - return ""; - } - if (col instanceof XViewerValueColumn) { - return ((XViewerValueColumn) col).getColumnText(element, col, columnIndex); - } - if (element instanceof String) { - if (columnIndex == 1) { - return (String) element; - } else { - return ""; - } - } - Artifact artifact = (Artifact) element; - if (artifact == null || artifact.isDeleted()) { - return ""; - } - // Handle case where columns haven't been loaded yet - if (columnIndex > getTreeViewer().getTree().getColumns().length - 1) { - return ""; - } + @Override + public String getColumnText(Object element, XViewerColumn col, int columnIndex) throws XViewerException { + try { + if (col == null) { + return ""; + } + if (col instanceof XViewerValueColumn) { + return ((XViewerValueColumn) col).getColumnText(element, col, columnIndex); + } + if (element instanceof String) { + if (columnIndex == 1) { + return (String) element; + } else { + return ""; + } + } + Artifact artifact = (Artifact) element; + if (artifact == null || artifact.isDeleted()) { + return ""; + } + // Handle case where columns haven't been loaded yet + if (columnIndex > getTreeViewer().getTree().getColumns().length - 1) { + return ""; + } - String colName = col.getName(); - if (!artifact.isAttributeTypeValid(colName)) { - return ""; - } - if (AttributeTypeManager.isBaseTypeCompatible(DateAttribute.class, colName)) { - try { - return new DateAttribute().MMDDYYHHMM.format(artifact.getSoleAttributeValue(colName)); - } catch (OseeCoreException ex) { - return ""; - } - } + String colName = col.getName(); + if (!artifact.isAttributeTypeValid(colName)) { + return ""; + } + if (AttributeTypeManager.isBaseTypeCompatible(DateAttribute.class, colName)) { + try { + return new DateAttribute().MMDDYYHHMM.format(artifact.getSoleAttributeValue(colName)); + } catch (OseeCoreException ex) { + return ""; + } + } - return artifact.getAttributesToString(colName); - } catch (OseeCoreException ex) { - throw new XViewerException(ex); - } - } + return artifact.getAttributesToString(colName); + } catch (OseeCoreException ex) { + throw new XViewerException(ex); + } + } - public boolean isLabelProperty(Object element, String property) { - return false; - } + @Override + public boolean isLabelProperty(Object element, String property) { + return false; + } - public void addListener(ILabelProviderListener listener) { - } + @Override + public void addListener(ILabelProviderListener listener) { + } - public void removeListener(ILabelProviderListener listener) { - } + @Override + public void removeListener(ILabelProviderListener listener) { + } - public MassXViewer getTreeViewer() { - return xViewer; - } + public MassXViewer getTreeViewer() { + return xViewer; + } - public void dispose() { - } + @Override + public void dispose() { + } } diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/artifact/massEditor/MassXViewer.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/artifact/massEditor/MassXViewer.java index 6125f757a1e..66afd029e72 100644 --- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/artifact/massEditor/MassXViewer.java +++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/artifact/massEditor/MassXViewer.java @@ -31,12 +31,12 @@ import org.eclipse.osee.framework.skynet.core.event.OseeEventManager; import org.eclipse.osee.framework.skynet.core.event.Sender;
import org.eclipse.osee.framework.skynet.core.utility.LoadedArtifacts;
import org.eclipse.osee.framework.ui.plugin.util.AWorkbench;
-import org.eclipse.osee.framework.ui.plugin.util.Displays;
import org.eclipse.osee.framework.ui.skynet.SkynetGuiPlugin;
import org.eclipse.osee.framework.ui.skynet.artifact.ArtifactPromptChange;
import org.eclipse.osee.framework.ui.skynet.artifact.ArtifactTransfer;
import org.eclipse.osee.framework.ui.skynet.render.PresentationType;
import org.eclipse.osee.framework.ui.skynet.render.RendererManager;
+import org.eclipse.osee.framework.ui.swt.Displays;
import org.eclipse.osee.framework.ui.swt.IDirtiableEditor;
import org.eclipse.swt.dnd.DND;
import org.eclipse.swt.dnd.DragSource;
@@ -61,271 +61,273 @@ import org.eclipse.swt.widgets.TreeItem; */
public class MassXViewer extends XViewer implements IMassViewerEventHandler, IFrameworkTransactionEventListener, IArtifactsPurgedEventListener, IArtifactsChangeTypeEventListener {
- private String title;
- private final Set<Artifact> artifacts = new HashSet<Artifact>(50);
- private final IDirtiableEditor editor;
- private final List<String> EXTRA_COLUMNS = Arrays.asList(new String[] {"GUID", "HRID", "Artifact Type"});
- private final Composite parent;
-
- public MassXViewer(Composite parent, int style, MassArtifactEditor editor) {
- super(parent, style, ((MassArtifactEditorInput) editor.getEditorInput()).getXViewerFactory());
- this.parent = parent;
- this.editor = editor;
- OseeEventManager.addListener(this);
- MassXViewerEventManager.add(this);
- final MassXViewer fMassXViewer = this;
- parent.addDisposeListener(new DisposeListener() {
-
- @Override
- public void widgetDisposed(DisposeEvent e) {
- MassXViewerEventManager.remove(fMassXViewer);
- }
- });
- }
-
- @Override
- public void handleColumnMultiEdit(TreeColumn treeColumn, Collection<TreeItem> treeItems) {
- String colName = treeColumn.getText();
- Set<Artifact> useArts = new HashSet<Artifact>();
- for (TreeItem item : treeItems) {
- useArts.add((Artifact) item.getData());
- }
- if (ArtifactPromptChange.promptChangeAttribute(colName, colName, useArts, false)) {
- refresh();
- editor.onDirtied();
- }
- }
-
- @Override
- public boolean isColumnMultiEditable(TreeColumn treeColumn, Collection<TreeItem> treeItems) {
- if (EXTRA_COLUMNS.contains(treeColumn.getText())) { - return false; - } - return super.isColumnMultiEditable(treeColumn, treeItems);
- }
-
- @Override
- public boolean isColumnMultiEditEnabled() {
- return true;
- }
-
- @Override
- public boolean handleAltLeftClick(TreeColumn treeColumn, TreeItem treeItem) {
- return handleAltLeftClick(treeColumn, treeItem, false);
- }
-
- public boolean handleAltLeftClick(TreeColumn treeColumn, TreeItem treeItem, boolean persist) {
- super.handleAltLeftClick(treeColumn, treeItem);
- String colName = treeColumn.getText();
- if (EXTRA_COLUMNS.contains(colName)) {
- AWorkbench.popup("ERROR", "Can't change the field " + colName);
- }
- Artifact useArt = ((Artifact) treeItem.getData());
- if (ArtifactPromptChange.promptChangeAttribute(colName, colName, Arrays.asList(useArt), persist)) {
- refresh();
- editor.onDirtied();
- return true;
- }
- return false;
- }
-
- @Override
- protected void createSupportWidgets(Composite parent) {
- super.createSupportWidgets(parent);
- setupDragAndDropSupport();
- }
-
- private void setupDragAndDropSupport() {
-
- // Do not allow drag if artifacts in this table are not on same branch as default branch
- DragSource source = new DragSource(getTree(), DND.DROP_COPY);
- source.setTransfer(new Transfer[] {ArtifactTransfer.getInstance()});
- source.addDragListener(new DragSourceListener() {
-
- public void dragFinished(DragSourceEvent event) {
- refresh();
- }
-
- public void dragSetData(DragSourceEvent event) {
- Collection<Artifact> arts = getSelectedArtifacts();
- if (arts.size() > 0) {
- event.data = new ArtifactData(arts.toArray(new Artifact[arts.size()]), "", MassArtifactEditor.EDITOR_ID);
-
- }
- }
-
- public void dragStart(DragSourceEvent event) {
- event.doit = false;
- Collection<Artifact> arts = getSelectedArtifacts();
- if (arts.size() > 0) {
- event.doit = true;
- }
- }
- });
-
- // Do not allow drop if default branch is not same as artifacts that reside in this table
- DropTarget target = new DropTarget(getTree(), DND.DROP_COPY);
- target.setTransfer(new Transfer[] {FileTransfer.getInstance(), TextTransfer.getInstance(),
- ArtifactTransfer.getInstance()}); - target.addDropListener(new DropTargetAdapter() {
-
- @Override
- public void drop(DropTargetEvent event) {
- performDrop(event);
- }
-
- @Override
- public void dragOver(DropTargetEvent event) {
- // if ((event.data instanceof ArtifactData) && ((ArtifactData)
- // event.data).getArtifacts().length > 0)
- event.detail = DND.DROP_COPY;
- }
-
- @Override
- public void dropAccept(DropTargetEvent event) {
- }
- });
- }
-
- private void performDrop(DropTargetEvent e) {
- try {
- if (e.data instanceof ArtifactData) {
- Artifact[] artsToAdd = ((ArtifactData) e.data).getArtifacts();
- add(Arrays.asList(artsToAdd));
- }
- refresh();
- } catch (Exception ex) {
- OseeLog.log(SkynetGuiPlugin.class, OseeLevel.SEVERE_POPUP, ex);
- }
- }
-
- @Override
- public void handleDoubleClick() {
- if (getSelectedArtifacts().isEmpty()) { - return; - } - RendererManager.openInJob(getSelectedArtifacts(), PresentationType.GENERALIZED_EDIT); - }
-
- public ArrayList<Artifact> getLoadedArtifacts() {
- ArrayList<Artifact> arts = new ArrayList<Artifact>();
- TreeItem items[] = getTree().getItems();
- if (items.length > 0) { - for (TreeItem item : items) { - arts.add((Artifact) item.getData()); - } - } - return arts;
- }
-
- @Override
- public void dispose() {
- OseeEventManager.removeListener(this);
- MassXViewerEventManager.remove(this);
- // Tell the label provider to release its resources
- getLabelProvider().dispose();
- }
-
- public ArrayList<Artifact> getSelectedArtifacts() {
- ArrayList<Artifact> arts = new ArrayList<Artifact>();
- TreeItem items[] = getTree().getSelection();
- if (items.length > 0) { - for (TreeItem item : items) { - arts.add((Artifact) item.getData()); - } - } - return arts;
- }
-
- public String getTitle() {
- return title;
- }
-
- public void add(Collection<? extends Artifact> artifacts) {
- if (xViewerFactory instanceof MassXViewerFactory) {
- ((MassXViewerFactory) xViewerFactory).registerAllAttributeColumnsForArtifacts(artifacts, true, true);
- }
- for (Artifact art : artifacts) {
- this.artifacts.add(art);
- }
- ((MassContentProvider) getContentProvider()).add(artifacts);
- }
-
- public void set(Collection<? extends Artifact> artifacts) {
- if (xViewerFactory instanceof MassXViewerFactory) {
- ((MassXViewerFactory) xViewerFactory).registerAllAttributeColumnsForArtifacts(artifacts, true, true);
- }
- this.artifacts.clear();
- for (Artifact art : artifacts) {
- this.artifacts.add(art);
- }
- ((MassContentProvider) getContentProvider()).set(artifacts);
- }
-
- public Collection<? extends Artifact> getArtifacts() {
- return artifacts;
- }
-
- @Override
- public void handleFrameworkTransactionEvent(Sender sender, final FrameworkTransactionData transData) throws OseeCoreException {
- Displays.ensureInDisplayThread(new Runnable() {
- @Override
- public void run() {
- if (getTree() == null || getTree().isDisposed()) {
- dispose();
- return;
- }
- if (transData.cacheDeletedArtifacts.size() > 0) {
- ((MassContentProvider) getContentProvider()).removeAllArts(transData.cacheDeletedArtifacts);
- }
- if (transData.cacheChangedArtifacts.size() > 0) {
- ((MassContentProvider) getContentProvider()).updateAll(transData.cacheChangedArtifacts);
- }
- refresh(transData.cacheRelationAddedArtifacts);
- refresh(transData.cacheRelationChangedArtifacts);
- refresh(transData.cacheRelationDeletedArtifacts);
- }
- });
- }
-
- @Override
- public void handleArtifactsPurgedEvent(Sender sender, final LoadedArtifacts loadedArtifacts) {
- Displays.ensureInDisplayThread(new Runnable() {
- @Override
- public void run() {
- try {
- if (getTree() != null && !getTree().isDisposed()) {
- remove(loadedArtifacts.getLoadedArtifacts().toArray());
- }
- } catch (OseeCoreException ex) {
- OseeLog.log(SkynetGuiPlugin.class, Level.SEVERE, ex);
- }
- }
- });
- }
-
- @Override
- public void handleArtifactsChangeTypeEvent(Sender sender, int toArtifactTypeId, final LoadedArtifacts loadedArtifacts) {
- Displays.ensureInDisplayThread(new Runnable() {
- @Override
- public void run() {
- try {
- remove(loadedArtifacts.getLoadedArtifacts().toArray());
- } catch (OseeCoreException ex) {
- OseeLog.log(SkynetGuiPlugin.class, Level.SEVERE, ex);
- }
- }
- });
- }
-
- @Override
- public MassXViewer getMassXViewer() {
- return this;
- }
-
- @Override
- public boolean isDisposed() {
- return parent == null || parent.isDisposed();
- }
+ private String title;
+ private final Set<Artifact> artifacts = new HashSet<Artifact>(50);
+ private final IDirtiableEditor editor;
+ private final List<String> EXTRA_COLUMNS = Arrays.asList(new String[] {"GUID", "HRID", "Artifact Type"});
+ private final Composite parent;
+
+ public MassXViewer(Composite parent, int style, MassArtifactEditor editor) {
+ super(parent, style, ((MassArtifactEditorInput) editor.getEditorInput()).getXViewerFactory());
+ this.parent = parent;
+ this.editor = editor;
+ OseeEventManager.addListener(this);
+ MassXViewerEventManager.add(this);
+ final MassXViewer fMassXViewer = this;
+ parent.addDisposeListener(new DisposeListener() {
+
+ @Override
+ public void widgetDisposed(DisposeEvent e) {
+ MassXViewerEventManager.remove(fMassXViewer);
+ }
+ });
+ }
+
+ @Override
+ public void handleColumnMultiEdit(TreeColumn treeColumn, Collection<TreeItem> treeItems) {
+ String colName = treeColumn.getText();
+ Set<Artifact> useArts = new HashSet<Artifact>();
+ for (TreeItem item : treeItems) {
+ useArts.add((Artifact) item.getData());
+ }
+ if (ArtifactPromptChange.promptChangeAttribute(colName, colName, useArts, false)) {
+ refresh();
+ editor.onDirtied();
+ }
+ }
+
+ @Override
+ public boolean isColumnMultiEditable(TreeColumn treeColumn, Collection<TreeItem> treeItems) {
+ if (EXTRA_COLUMNS.contains(treeColumn.getText())) {
+ return false;
+ }
+ return super.isColumnMultiEditable(treeColumn, treeItems);
+ }
+
+ @Override
+ public boolean isColumnMultiEditEnabled() {
+ return true;
+ }
+
+ @Override
+ public boolean handleAltLeftClick(TreeColumn treeColumn, TreeItem treeItem) {
+ return handleAltLeftClick(treeColumn, treeItem, false);
+ }
+
+ public boolean handleAltLeftClick(TreeColumn treeColumn, TreeItem treeItem, boolean persist) {
+ super.handleAltLeftClick(treeColumn, treeItem);
+ String colName = treeColumn.getText();
+ if (EXTRA_COLUMNS.contains(colName)) {
+ AWorkbench.popup("ERROR", "Can't change the field " + colName);
+ }
+ Artifact useArt = ((Artifact) treeItem.getData());
+ if (ArtifactPromptChange.promptChangeAttribute(colName, colName, Arrays.asList(useArt), persist)) {
+ refresh();
+ editor.onDirtied();
+ return true;
+ }
+ return false;
+ }
+
+ @Override
+ protected void createSupportWidgets(Composite parent) {
+ super.createSupportWidgets(parent);
+ setupDragAndDropSupport();
+ }
+
+ private void setupDragAndDropSupport() {
+
+ // Do not allow drag if artifacts in this table are not on same branch as default branch
+ DragSource source = new DragSource(getTree(), DND.DROP_COPY);
+ source.setTransfer(new Transfer[] {ArtifactTransfer.getInstance()});
+ source.addDragListener(new DragSourceListener() {
+ @Override
+ public void dragFinished(DragSourceEvent event) {
+ refresh();
+ }
+
+ @Override
+ public void dragSetData(DragSourceEvent event) {
+ Collection<Artifact> arts = getSelectedArtifacts();
+ if (arts.size() > 0) {
+ event.data = new ArtifactData(arts.toArray(new Artifact[arts.size()]), "", MassArtifactEditor.EDITOR_ID);
+
+ }
+ }
+
+ @Override
+ public void dragStart(DragSourceEvent event) {
+ event.doit = false;
+ Collection<Artifact> arts = getSelectedArtifacts();
+ if (arts.size() > 0) {
+ event.doit = true;
+ }
+ }
+ });
+
+ // Do not allow drop if default branch is not same as artifacts that reside in this table
+ DropTarget target = new DropTarget(getTree(), DND.DROP_COPY);
+ target.setTransfer(new Transfer[] {FileTransfer.getInstance(), TextTransfer.getInstance(),
+ ArtifactTransfer.getInstance()});
+ target.addDropListener(new DropTargetAdapter() {
+
+ @Override
+ public void drop(DropTargetEvent event) {
+ performDrop(event);
+ }
+
+ @Override
+ public void dragOver(DropTargetEvent event) {
+ // if ((event.data instanceof ArtifactData) && ((ArtifactData)
+ // event.data).getArtifacts().length > 0)
+ event.detail = DND.DROP_COPY;
+ }
+
+ @Override
+ public void dropAccept(DropTargetEvent event) {
+ }
+ });
+ }
+
+ private void performDrop(DropTargetEvent e) {
+ try {
+ if (e.data instanceof ArtifactData) {
+ Artifact[] artsToAdd = ((ArtifactData) e.data).getArtifacts();
+ add(Arrays.asList(artsToAdd));
+ }
+ refresh();
+ } catch (Exception ex) {
+ OseeLog.log(SkynetGuiPlugin.class, OseeLevel.SEVERE_POPUP, ex);
+ }
+ }
+
+ @Override
+ public void handleDoubleClick() {
+ if (getSelectedArtifacts().isEmpty()) {
+ return;
+ }
+ RendererManager.openInJob(getSelectedArtifacts(), PresentationType.GENERALIZED_EDIT);
+ }
+
+ public ArrayList<Artifact> getLoadedArtifacts() {
+ ArrayList<Artifact> arts = new ArrayList<Artifact>();
+ TreeItem items[] = getTree().getItems();
+ if (items.length > 0) {
+ for (TreeItem item : items) {
+ arts.add((Artifact) item.getData());
+ }
+ }
+ return arts;
+ }
+
+ @Override
+ public void dispose() {
+ OseeEventManager.removeListener(this);
+ MassXViewerEventManager.remove(this);
+ // Tell the label provider to release its resources
+ getLabelProvider().dispose();
+ }
+
+ public ArrayList<Artifact> getSelectedArtifacts() {
+ ArrayList<Artifact> arts = new ArrayList<Artifact>();
+ TreeItem items[] = getTree().getSelection();
+ if (items.length > 0) {
+ for (TreeItem item : items) {
+ arts.add((Artifact) item.getData());
+ }
+ }
+ return arts;
+ }
+
+ public String getTitle() {
+ return title;
+ }
+
+ public void add(Collection<? extends Artifact> artifacts) {
+ if (xViewerFactory instanceof MassXViewerFactory) {
+ ((MassXViewerFactory) xViewerFactory).registerAllAttributeColumnsForArtifacts(artifacts, true, true);
+ }
+ for (Artifact art : artifacts) {
+ this.artifacts.add(art);
+ }
+ ((MassContentProvider) getContentProvider()).add(artifacts);
+ }
+
+ public void set(Collection<? extends Artifact> artifacts) {
+ if (xViewerFactory instanceof MassXViewerFactory) {
+ ((MassXViewerFactory) xViewerFactory).registerAllAttributeColumnsForArtifacts(artifacts, true, true);
+ }
+ this.artifacts.clear();
+ for (Artifact art : artifacts) {
+ this.artifacts.add(art);
+ }
+ ((MassContentProvider) getContentProvider()).set(artifacts);
+ }
+
+ public Collection<? extends Artifact> getArtifacts() {
+ return artifacts;
+ }
+
+ @Override
+ public void handleFrameworkTransactionEvent(Sender sender, final FrameworkTransactionData transData) {
+ Displays.ensureInDisplayThread(new Runnable() {
+ @Override
+ public void run() {
+ if (getTree() == null || getTree().isDisposed()) {
+ dispose();
+ return;
+ }
+ if (transData.cacheDeletedArtifacts.size() > 0) {
+ ((MassContentProvider) getContentProvider()).removeAllArts(transData.cacheDeletedArtifacts);
+ }
+ if (transData.cacheChangedArtifacts.size() > 0) {
+ ((MassContentProvider) getContentProvider()).updateAll(transData.cacheChangedArtifacts);
+ }
+ refresh(transData.cacheRelationAddedArtifacts);
+ refresh(transData.cacheRelationChangedArtifacts);
+ refresh(transData.cacheRelationDeletedArtifacts);
+ }
+ });
+ }
+
+ @Override
+ public void handleArtifactsPurgedEvent(Sender sender, final LoadedArtifacts loadedArtifacts) {
+ Displays.ensureInDisplayThread(new Runnable() {
+ @Override
+ public void run() {
+ try {
+ if (getTree() != null && !getTree().isDisposed()) {
+ remove(loadedArtifacts.getLoadedArtifacts().toArray());
+ }
+ } catch (OseeCoreException ex) {
+ OseeLog.log(SkynetGuiPlugin.class, Level.SEVERE, ex);
+ }
+ }
+ });
+ }
+
+ @Override
+ public void handleArtifactsChangeTypeEvent(Sender sender, int toArtifactTypeId, final LoadedArtifacts loadedArtifacts) {
+ Displays.ensureInDisplayThread(new Runnable() {
+ @Override
+ public void run() {
+ try {
+ remove(loadedArtifacts.getLoadedArtifacts().toArray());
+ } catch (OseeCoreException ex) {
+ OseeLog.log(SkynetGuiPlugin.class, Level.SEVERE, ex);
+ }
+ }
+ });
+ }
+
+ @Override
+ public MassXViewer getMassXViewer() {
+ return this;
+ }
+
+ @Override
+ public boolean isDisposed() {
+ return parent == null || parent.isDisposed();
+ }
}
diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/artifact/massEditor/MassXViewerEventManager.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/artifact/massEditor/MassXViewerEventManager.java index 027cfbbf2e3..4f8ca13c34b 100644 --- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/artifact/massEditor/MassXViewerEventManager.java +++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/artifact/massEditor/MassXViewerEventManager.java @@ -18,7 +18,7 @@ import org.eclipse.osee.framework.skynet.core.event2.artifact.EventBasicGuidArti import org.eclipse.osee.framework.skynet.core.event2.artifact.EventModType;
import org.eclipse.osee.framework.skynet.core.event2.artifact.IArtifactEventListener;
import org.eclipse.osee.framework.skynet.core.event2.filter.IEventFilter;
-import org.eclipse.osee.framework.ui.plugin.util.Displays;
+import org.eclipse.osee.framework.ui.swt.Displays;
/**
* Common location for event handling for mass editor in order to keep number of registrations and processing to a
diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/blam/BlamEditor.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/blam/BlamEditor.java index 6d2a9bca63a..fae35ce23ad 100644 --- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/blam/BlamEditor.java +++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/blam/BlamEditor.java @@ -20,9 +20,9 @@ import org.eclipse.osee.framework.logging.OseeLevel; import org.eclipse.osee.framework.logging.OseeLog; import org.eclipse.osee.framework.plugin.core.IActionable; import org.eclipse.osee.framework.ui.plugin.util.AWorkbench; -import org.eclipse.osee.framework.ui.plugin.util.Displays; import org.eclipse.osee.framework.ui.skynet.OseeContributionItem; import org.eclipse.osee.framework.ui.skynet.SkynetGuiPlugin; +import org.eclipse.osee.framework.ui.swt.Displays; import org.eclipse.osee.framework.ui.swt.IDirtiableEditor; import org.eclipse.ui.PartInitException; import org.eclipse.ui.forms.editor.FormEditor; diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/blam/operation/ImageCaptureBlam.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/blam/operation/ImageCaptureBlam.java index c38a82365a1..3507f41fc97 100644 --- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/blam/operation/ImageCaptureBlam.java +++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/blam/operation/ImageCaptureBlam.java @@ -13,10 +13,10 @@ package org.eclipse.osee.framework.ui.skynet.blam.operation; import java.util.Arrays;
import java.util.Collection;
import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.osee.framework.ui.plugin.util.Displays;
import org.eclipse.osee.framework.ui.skynet.blam.AbstractBlam;
import org.eclipse.osee.framework.ui.skynet.blam.VariableMap;
import org.eclipse.osee.framework.ui.skynet.widgets.dialog.ImageDialog;
+import org.eclipse.osee.framework.ui.swt.Displays;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.GC;
import org.eclipse.swt.graphics.Image;
@@ -31,60 +31,64 @@ import org.eclipse.swt.widgets.Listener; */
public class ImageCaptureBlam extends AbstractBlam {
- public Point topLeftPoint;
- public Point botRightPoint;
- public boolean listenerAdded = false;
+ public Point topLeftPoint;
+ public Point botRightPoint;
+ public boolean listenerAdded = false;
- @Override
- public String getName() {
- return "Image Capture";
- }
+ @Override
+ public String getName() {
+ return "Image Capture";
+ }
- public void runOperation(VariableMap variableMap, IProgressMonitor monitor) throws Exception {
+ @Override
+ public void runOperation(VariableMap variableMap, IProgressMonitor monitor) throws Exception {
- Displays.ensureInDisplayThread(new Runnable() {
- @Override
- public void run() {
- System.out.println("Starting Image Capture...");
- topLeftPoint = null;
- botRightPoint = null;
- Display.getDefault().addFilter(SWT.MouseUp, displayKeysListener);
- }
- });
- }
- Listener displayKeysListener = new Listener() {
- public void handleEvent(org.eclipse.swt.widgets.Event event) {
- if (event.type == SWT.MouseUp) {
- if (topLeftPoint == null) {
- topLeftPoint = event.display.getCursorLocation();
- print("\nFirst Mouse Event " + topLeftPoint + "\n");
- } else {
- botRightPoint = event.display.getCursorLocation();
- print("Second Mouse Event " + botRightPoint + "\n");
- GC gc = new GC(Display.getCurrent());
- Image image =
- new Image(Display.getCurrent(), botRightPoint.x - topLeftPoint.x, botRightPoint.y - topLeftPoint.y);
- gc.copyArea(image, topLeftPoint.x, topLeftPoint.y);
- gc.dispose();
- Display.getDefault().removeFilter(SWT.MouseUp, displayKeysListener);
- ImageDialog diag = new ImageDialog(image, Display.getCurrent().getActiveShell());
- diag.open();
- }
- }
- }
- };
+ Displays.ensureInDisplayThread(new Runnable() {
+ @Override
+ public void run() {
+ System.out.println("Starting Image Capture...");
+ topLeftPoint = null;
+ botRightPoint = null;
+ Display.getDefault().addFilter(SWT.MouseUp, displayKeysListener);
+ }
+ });
+ }
+ Listener displayKeysListener = new Listener() {
+ @Override
+ public void handleEvent(org.eclipse.swt.widgets.Event event) {
+ if (event.type == SWT.MouseUp) {
+ if (topLeftPoint == null) {
+ topLeftPoint = event.display.getCursorLocation();
+ print("\nFirst Mouse Event " + topLeftPoint + "\n");
+ } else {
+ botRightPoint = event.display.getCursorLocation();
+ print("Second Mouse Event " + botRightPoint + "\n");
+ GC gc = new GC(Display.getCurrent());
+ Image image =
+ new Image(Display.getCurrent(), botRightPoint.x - topLeftPoint.x,
+ botRightPoint.y - topLeftPoint.y);
+ gc.copyArea(image, topLeftPoint.x, topLeftPoint.y);
+ gc.dispose();
+ Display.getDefault().removeFilter(SWT.MouseUp, displayKeysListener);
+ ImageDialog diag = new ImageDialog(image, Display.getCurrent().getActiveShell());
+ diag.open();
+ }
+ }
+ }
+ };
- @Override
- public String getXWidgetsXml() {
- return "<xWidgets></xWidgets>";
- }
+ @Override
+ public String getXWidgetsXml() {
+ return "<xWidgets></xWidgets>";
+ }
- @Override
- public String getDescriptionUsage() {
- return "Mouse Down on top left location, Mouse Up on bottom right. Only works within bounds of workbench window.";
- }
+ @Override
+ public String getDescriptionUsage() {
+ return "Mouse Down on top left location, Mouse Up on bottom right. Only works within bounds of workbench window.";
+ }
- public Collection<String> getCategories() {
- return Arrays.asList("Util");
- }
+ @Override
+ public Collection<String> getCategories() {
+ return Arrays.asList("Util");
+ }
}
\ No newline at end of file diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/blam/operation/PurgeArchivedBranch.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/blam/operation/PurgeArchivedBranch.java index bfc8b9a4983..1b6c0d2d780 100644 --- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/blam/operation/PurgeArchivedBranch.java +++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/blam/operation/PurgeArchivedBranch.java @@ -29,11 +29,11 @@ import org.eclipse.osee.framework.logging.OseeLevel; import org.eclipse.osee.framework.logging.OseeLog;
import org.eclipse.osee.framework.skynet.core.UserManager;
import org.eclipse.osee.framework.skynet.core.artifact.BranchManager;
-import org.eclipse.osee.framework.ui.plugin.util.Displays;
import org.eclipse.osee.framework.ui.skynet.SkynetGuiPlugin;
import org.eclipse.osee.framework.ui.skynet.blam.AbstractBlam;
import org.eclipse.osee.framework.ui.skynet.blam.VariableMap;
import org.eclipse.osee.framework.ui.skynet.results.XResultData;
+import org.eclipse.osee.framework.ui.swt.Displays;
import org.eclipse.swt.widgets.Display;
/**
diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/blam/operation/UpdateArtifactTypeImage.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/blam/operation/UpdateArtifactTypeImage.java index b999f8d4a35..957ee8cace9 100644 --- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/blam/operation/UpdateArtifactTypeImage.java +++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/blam/operation/UpdateArtifactTypeImage.java @@ -23,11 +23,11 @@ import org.eclipse.osee.framework.jdk.core.util.Lib; import org.eclipse.osee.framework.jdk.core.util.Strings;
import org.eclipse.osee.framework.logging.OseeLevel;
import org.eclipse.osee.framework.logging.OseeLog;
-import org.eclipse.osee.framework.ui.plugin.util.Displays;
import org.eclipse.osee.framework.ui.skynet.ArtifactImageManager;
import org.eclipse.osee.framework.ui.skynet.SkynetGuiPlugin;
import org.eclipse.osee.framework.ui.skynet.blam.AbstractBlam;
import org.eclipse.osee.framework.ui.skynet.blam.VariableMap;
+import org.eclipse.osee.framework.ui.swt.Displays;
import org.eclipse.swt.widgets.Display;
/**
@@ -59,7 +59,7 @@ public class UpdateArtifactTypeImage extends AbstractBlam { @Override
public void run() {
try {
- if (MessageDialog.openConfirm(Display.getDefault().getActiveShell(), "Clear Database Image?",
+ if (MessageDialog.openConfirm(Displays.getActiveShell(), "Clear Database Image?",
"No Image File Selected.\n\nSelect \"Ok\" to clear image from database (default image will be used).")) {
ArtifactImageManager.setArtifactTypeImageInDb(artifactSubtypeDescriptor, null);
}
diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/blam/sections/BlamOutputSection.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/blam/sections/BlamOutputSection.java index 657e855fa09..ea50f814f35 100644 --- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/blam/sections/BlamOutputSection.java +++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/blam/sections/BlamOutputSection.java @@ -13,8 +13,8 @@ package org.eclipse.osee.framework.ui.skynet.blam.sections; import java.io.IOException;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.action.ActionContributionItem;
-import org.eclipse.osee.framework.ui.plugin.util.Displays;
import org.eclipse.osee.framework.ui.skynet.blam.AbstractBlam;
+import org.eclipse.osee.framework.ui.swt.Displays;
import org.eclipse.osee.framework.ui.swt.Widgets;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridData;
diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/change/view/ChangeReportPage.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/change/view/ChangeReportPage.java index c06be856b7a..d440dc27572 100644 --- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/change/view/ChangeReportPage.java +++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/change/view/ChangeReportPage.java @@ -40,12 +40,12 @@ import org.eclipse.osee.framework.ui.skynet.change.operations.LoadChangesOperati import org.eclipse.osee.framework.ui.skynet.change.operations.UpdateChangeUiData; import org.eclipse.osee.framework.ui.skynet.change.presenter.ChangeReportInfoPresenter; import org.eclipse.osee.framework.ui.skynet.widgets.xchange.ChangeXViewer; +import org.eclipse.osee.framework.ui.swt.Displays; import org.eclipse.osee.framework.ui.swt.Widgets; import org.eclipse.swt.SWT; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Menu; import org.eclipse.ui.IWorkbenchActionConstants; import org.eclipse.ui.PlatformUI; @@ -61,204 +61,205 @@ import org.eclipse.ui.progress.UIJob; * @author Ryan D. Brooks */ public class ChangeReportPage extends FormPage implements IChangeReportPreferences.Listener { - private static String HELP_CONTEXT_ID = "ChangeView"; - - private ChangeReportTable changeReportTable; - private ChangeReportInfoPresenter infoPresenter; - - public ChangeReportPage(ChangeReportEditor editor) { - super(editor, "change.report", "Change Report"); - } - - @Override - public void showBusy(boolean busy) { - super.showBusy(busy); - if (Widgets.isAccessible(getManagedForm().getForm())) { - getManagedForm().getForm().getForm().setBusy(busy); - } - } - - @Override - protected void createFormContent(IManagedForm managedForm) { - super.createFormContent(managedForm); - - final ScrolledForm form = managedForm.getForm(); - final FormToolkit toolkit = managedForm.getToolkit(); - - GridLayout layout = new GridLayout(); - layout.numColumns = 1; - layout.marginHeight = 10; - layout.marginWidth = 6; - layout.horizontalSpacing = 20; - form.getBody().setLayout(layout); - form.getBody().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); - - updateTitle(form); - updateImage(form); - - managedForm.getMessageManager().setAutoUpdate(false); - - ChangeUiData uiData = getEditorInput().getChangeData(); - this.changeReportTable = new ChangeReportTable(uiData); - this.infoPresenter = new ChangeReportInfoPresenter(new ChangeReportInfo(), uiData); - - int sectionStyle = Section.TITLE_BAR | Section.EXPANDED | Section.TWISTIE; - - managedForm.addPart(new EditorSection(infoPresenter, "Info", form.getBody(), managedForm.getToolkit(), - sectionStyle, false)); - // Can not place table in section or double scroll-bars and maintaining correct table size becomes an issue - changeReportTable.onCreate(getManagedForm(), form.getBody()); - - addToolBar(toolkit, form, true); - form.reflow(true); - - PlatformUI.getWorkbench().getHelpSystem().setHelp(form.getBody(), - "org.eclipse.osee.framework.help.ui." + HELP_CONTEXT_ID); - bindMenu(); - - getEditor().getPreferences().addListener(this); - recomputeChangeReport(uiData.isLoadOnOpenEnabled()); - } - - private void bindMenu() { - final ChangeXViewer xviewer = changeReportTable.getXViewer(); - - MenuManager manager = xviewer.getMenuManager(); - manager.setRemoveAllWhenShown(true); - manager.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS)); - manager.addMenuListener(new ChangeReportMenuListener()); - - Control control = xviewer.getTree(); - Menu menu = manager.createContextMenu(control); - control.setMenu(menu); - - getSite().registerContextMenu("org.eclipse.osee.framework.ui.skynet.widgets.xchange.ChangeView", manager, xviewer); - getSite().setSelectionProvider(xviewer); - } - - private static final class ChangeReportMenuListener implements IMenuListener { - public void menuAboutToShow(IMenuManager manager) { - MenuManager menuManager = (MenuManager) manager; - menuManager.insertBefore(XViewer.MENU_GROUP_PRE, new Separator(IWorkbenchActionConstants.MB_ADDITIONS)); - } - } - - private void updateTitle(ScrolledForm form) { - form.setText(Strings.escapeAmpersands(getEditorInput().getName())); - } - - private void updateImage(ScrolledForm form) { - form.setImage(getEditor().getEditorInput().getImage()); - } - - private void addToolBar(FormToolkit toolkit, ScrolledForm form, boolean add) { - IToolBarManager manager = form.getToolBarManager(); - if (add) { - getEditor().getActionBarContributor().contributeToToolBar(manager); - manager.add(changeReportTable.getXViewer().getCustomizeAction()); - manager.update(true); - } else { - manager.removeAll(); - } - form.reflow(true); - } - - @Override - public ChangeReportEditor getEditor() { - return (ChangeReportEditor) super.getEditor(); - } - - @Override - public ChangeReportEditorInput getEditorInput() { - return (ChangeReportEditorInput) super.getEditorInput(); - } - - public void onLoad() { - Display.getDefault().asyncExec(new Runnable() { - public void run() { - if (changeReportTable != null && infoPresenter != null) { - changeReportTable.onLoading(); - infoPresenter.onLoading(); - } - } - }); - } - - public void refresh() { - final ScrolledForm sForm = getManagedForm().getForm(); - for (IFormPart part : getManagedForm().getParts()) { - part.refresh(); - } - changeReportTable.onUpdate(); - - updateTitle(sForm); - updateImage(sForm); - - sForm.getBody().layout(true); - sForm.reflow(true); - getManagedForm().refresh(); - } - - @Override - public void onDocumentOrderChange(boolean value) { - if (changeReportTable != null) { - changeReportTable.getXViewer().setShowDocumentOrderFilter(value); - changeReportTable.getXViewer().refresh(); - } - } - - public void recomputeChangeReport(boolean isReloadAllowed) { - List<IOperation> ops = new ArrayList<IOperation>(); - ChangeUiData changeData = getEditorInput().getChangeData(); - ops.add(new UpdateChangeUiData(changeData)); - if (isReloadAllowed) { - changeData.reset(); - onLoad(); - ops.add(new LoadChangesOperation(changeData)); - } - ops.add(new LoadAssociatedArtifactOperation(changeData)); - IOperation operation = new CompositeOperation("Load Change Report Data", SkynetGuiPlugin.PLUGIN_ID, ops); - Operations.executeAsJob(operation, true, Job.LONG, new ReloadJobChangeAdapter()); - } - - private final class ReloadJobChangeAdapter extends JobChangeAdapter { - private long startTime = 0; - - @Override - public void scheduled(IJobChangeEvent event) { - super.scheduled(event); - getEditor().getActionBarContributor().getReloadAction().setEnabled(false); - showBusy(true); - } - - @Override - public void aboutToRun(IJobChangeEvent event) { - super.aboutToRun(event); - startTime = System.currentTimeMillis(); - } - - @Override - public void done(IJobChangeEvent event) { - super.done(event); - String message = String.format("Change Report Load completed in [%s]", Lib.getElapseString(startTime)); - OseeLog.log(SkynetGuiPlugin.class, Level.INFO, message); - - Job job = new UIJob("Refresh Change Report") { - - @Override - public IStatus runInUIThread(IProgressMonitor monitor) { - getEditor().refresh(); - getEditor().getActionBarContributor().getReloadAction().setEnabled(true); - getEditor().getActionBarContributor().getOpenAssociatedArtifactAction().updateEnablement(); - getManagedForm().getForm().getBody().layout(true); - getManagedForm().getForm().reflow(true); - getManagedForm().refresh(); - showBusy(false); - return Status.OK_STATUS; - } - }; - Operations.scheduleJob(job, false, Job.SHORT, null); - } - } + private static String HELP_CONTEXT_ID = "ChangeView"; + + private ChangeReportTable changeReportTable; + private ChangeReportInfoPresenter infoPresenter; + + public ChangeReportPage(ChangeReportEditor editor) { + super(editor, "change.report", "Change Report"); + } + + @Override + public void showBusy(boolean busy) { + super.showBusy(busy); + if (Widgets.isAccessible(getManagedForm().getForm())) { + getManagedForm().getForm().getForm().setBusy(busy); + } + } + + @Override + protected void createFormContent(IManagedForm managedForm) { + super.createFormContent(managedForm); + + final ScrolledForm form = managedForm.getForm(); + final FormToolkit toolkit = managedForm.getToolkit(); + + GridLayout layout = new GridLayout(); + layout.numColumns = 1; + layout.marginHeight = 10; + layout.marginWidth = 6; + layout.horizontalSpacing = 20; + form.getBody().setLayout(layout); + form.getBody().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); + + updateTitle(form); + updateImage(form); + + managedForm.getMessageManager().setAutoUpdate(false); + + ChangeUiData uiData = getEditorInput().getChangeData(); + this.changeReportTable = new ChangeReportTable(uiData); + this.infoPresenter = new ChangeReportInfoPresenter(new ChangeReportInfo(), uiData); + + int sectionStyle = Section.TITLE_BAR | Section.EXPANDED | Section.TWISTIE; + + managedForm.addPart(new EditorSection(infoPresenter, "Info", form.getBody(), managedForm.getToolkit(), + sectionStyle, false)); + // Can not place table in section or double scroll-bars and maintaining correct table size becomes an issue + changeReportTable.onCreate(getManagedForm(), form.getBody()); + + addToolBar(toolkit, form, true); + form.reflow(true); + + PlatformUI.getWorkbench().getHelpSystem().setHelp(form.getBody(), + "org.eclipse.osee.framework.help.ui." + HELP_CONTEXT_ID); + bindMenu(); + + getEditor().getPreferences().addListener(this); + recomputeChangeReport(uiData.isLoadOnOpenEnabled()); + } + + private void bindMenu() { + final ChangeXViewer xviewer = changeReportTable.getXViewer(); + + MenuManager manager = xviewer.getMenuManager(); + manager.setRemoveAllWhenShown(true); + manager.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS)); + manager.addMenuListener(new ChangeReportMenuListener()); + + Control control = xviewer.getTree(); + Menu menu = manager.createContextMenu(control); + control.setMenu(menu); + + getSite().registerContextMenu("org.eclipse.osee.framework.ui.skynet.widgets.xchange.ChangeView", manager, xviewer); + getSite().setSelectionProvider(xviewer); + } + + private static final class ChangeReportMenuListener implements IMenuListener { + public void menuAboutToShow(IMenuManager manager) { + MenuManager menuManager = (MenuManager) manager; + menuManager.insertBefore(XViewer.MENU_GROUP_PRE, new Separator(IWorkbenchActionConstants.MB_ADDITIONS)); + } + } + + private void updateTitle(ScrolledForm form) { + form.setText(Strings.escapeAmpersands(getEditorInput().getName())); + } + + private void updateImage(ScrolledForm form) { + form.setImage(getEditor().getEditorInput().getImage()); + } + + private void addToolBar(FormToolkit toolkit, ScrolledForm form, boolean add) { + IToolBarManager manager = form.getToolBarManager(); + if (add) { + getEditor().getActionBarContributor().contributeToToolBar(manager); + manager.add(changeReportTable.getXViewer().getCustomizeAction()); + manager.update(true); + } else { + manager.removeAll(); + } + form.reflow(true); + } + + @Override + public ChangeReportEditor getEditor() { + return (ChangeReportEditor) super.getEditor(); + } + + @Override + public ChangeReportEditorInput getEditorInput() { + return (ChangeReportEditorInput) super.getEditorInput(); + } + + public void onLoad() { + Displays.ensureInDisplayThread(new Runnable() { + @Override + public void run() { + if (changeReportTable != null && infoPresenter != null) { + changeReportTable.onLoading(); + infoPresenter.onLoading(); + } + } + }); + } + + public void refresh() { + final ScrolledForm sForm = getManagedForm().getForm(); + for (IFormPart part : getManagedForm().getParts()) { + part.refresh(); + } + changeReportTable.onUpdate(); + + updateTitle(sForm); + updateImage(sForm); + + sForm.getBody().layout(true); + sForm.reflow(true); + getManagedForm().refresh(); + } + + @Override + public void onDocumentOrderChange(boolean value) { + if (changeReportTable != null) { + changeReportTable.getXViewer().setShowDocumentOrderFilter(value); + changeReportTable.getXViewer().refresh(); + } + } + + public void recomputeChangeReport(boolean isReloadAllowed) { + List<IOperation> ops = new ArrayList<IOperation>(); + ChangeUiData changeData = getEditorInput().getChangeData(); + ops.add(new UpdateChangeUiData(changeData)); + if (isReloadAllowed) { + changeData.reset(); + onLoad(); + ops.add(new LoadChangesOperation(changeData)); + } + ops.add(new LoadAssociatedArtifactOperation(changeData)); + IOperation operation = new CompositeOperation("Load Change Report Data", SkynetGuiPlugin.PLUGIN_ID, ops); + Operations.executeAsJob(operation, true, Job.LONG, new ReloadJobChangeAdapter()); + } + + private final class ReloadJobChangeAdapter extends JobChangeAdapter { + private long startTime = 0; + + @Override + public void scheduled(IJobChangeEvent event) { + super.scheduled(event); + getEditor().getActionBarContributor().getReloadAction().setEnabled(false); + showBusy(true); + } + + @Override + public void aboutToRun(IJobChangeEvent event) { + super.aboutToRun(event); + startTime = System.currentTimeMillis(); + } + + @Override + public void done(IJobChangeEvent event) { + super.done(event); + String message = String.format("Change Report Load completed in [%s]", Lib.getElapseString(startTime)); + OseeLog.log(SkynetGuiPlugin.class, Level.INFO, message); + + Job job = new UIJob("Refresh Change Report") { + + @Override + public IStatus runInUIThread(IProgressMonitor monitor) { + getEditor().refresh(); + getEditor().getActionBarContributor().getReloadAction().setEnabled(true); + getEditor().getActionBarContributor().getOpenAssociatedArtifactAction().updateEnablement(); + getManagedForm().getForm().getBody().layout(true); + getManagedForm().getForm().reflow(true); + getManagedForm().refresh(); + showBusy(false); + return Status.OK_STATUS; + } + }; + Operations.scheduleJob(job, false, Job.SHORT, null); + } + } }
\ No newline at end of file diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/commandHandlers/CompressWordAttributesHandler.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/commandHandlers/CompressWordAttributesHandler.java index 43df1251b26..b365dd2faa2 100644 --- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/commandHandlers/CompressWordAttributesHandler.java +++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/commandHandlers/CompressWordAttributesHandler.java @@ -29,8 +29,8 @@ import org.eclipse.osee.framework.plugin.core.util.Jobs; import org.eclipse.osee.framework.skynet.core.artifact.Artifact;
import org.eclipse.osee.framework.skynet.core.word.WordUtil;
import org.eclipse.osee.framework.ui.plugin.util.AWorkbench;
-import org.eclipse.osee.framework.ui.plugin.util.Displays;
import org.eclipse.osee.framework.ui.skynet.SkynetGuiPlugin;
+import org.eclipse.osee.framework.ui.swt.Displays;
import org.eclipse.ui.PlatformUI;
/**
diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/commandHandlers/branch/PurgeTransactionHandler.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/commandHandlers/branch/PurgeTransactionHandler.java index 37de652dc0b..5206afd2d25 100644 --- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/commandHandlers/branch/PurgeTransactionHandler.java +++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/commandHandlers/branch/PurgeTransactionHandler.java @@ -28,6 +28,7 @@ import org.eclipse.osee.framework.ui.plugin.util.AWorkbench; import org.eclipse.osee.framework.ui.plugin.util.CommandHandler; import org.eclipse.osee.framework.ui.skynet.SkynetGuiPlugin; import org.eclipse.osee.framework.ui.skynet.commandHandlers.Handlers; +import org.eclipse.osee.framework.ui.swt.Displays; import org.eclipse.swt.widgets.Display; /** @@ -35,42 +36,43 @@ import org.eclipse.swt.widgets.Display; */ public class PurgeTransactionHandler extends CommandHandler { - @Override - public Object execute(ExecutionEvent arg0) throws ExecutionException { - IStructuredSelection selection = - (IStructuredSelection) AWorkbench.getActivePage().getActivePart().getSite().getSelectionProvider().getSelection(); + @Override + public Object execute(ExecutionEvent arg0) throws ExecutionException { + IStructuredSelection selection = + (IStructuredSelection) AWorkbench.getActivePage().getActivePart().getSite().getSelectionProvider().getSelection(); - List<TransactionRecord> transactions = Handlers.getTransactionsFromStructuredSelection(selection); - TransactionRecord selectedTransaction = transactions.iterator().next(); + List<TransactionRecord> transactions = Handlers.getTransactionsFromStructuredSelection(selection); + TransactionRecord selectedTransaction = transactions.iterator().next(); - if (MessageDialog.openConfirm(Display.getCurrent().getActiveShell(), "Purge Transaction", - "Are you sure you want to purge the transaction: " + selectedTransaction.getId())) { - BranchManager.purgeTransactions(new JobChangeAdapter() { + if (MessageDialog.openConfirm(Display.getCurrent().getActiveShell(), "Purge Transaction", + "Are you sure you want to purge the transaction: " + selectedTransaction.getId())) { + BranchManager.purgeTransactions(new JobChangeAdapter() { - @Override - public void done(IJobChangeEvent event) { - if (event.getResult().getSeverity() == IStatus.OK) { - Display.getDefault().asyncExec(new Runnable() { - public void run() { - try { - BranchManager.refreshBranches(); - } catch (OseeCoreException ex) { - OseeLog.log(SkynetGuiPlugin.class, OseeLevel.SEVERE_POPUP, ex); - } - } - }); - } - } + @Override + public void done(IJobChangeEvent event) { + if (event.getResult().getSeverity() == IStatus.OK) { + Displays.ensureInDisplayThread(new Runnable() { + @Override + public void run() { + try { + BranchManager.refreshBranches(); + } catch (OseeCoreException ex) { + OseeLog.log(SkynetGuiPlugin.class, OseeLevel.SEVERE_POPUP, ex); + } + } + }); + } + } - }, selectedTransaction.getId()); - } + }, selectedTransaction.getId()); + } - return null; - } + return null; + } - @Override - public boolean isEnabledWithException(IStructuredSelection structuredSelection) throws OseeCoreException { - List<TransactionRecord> transactions = Handlers.getTransactionsFromStructuredSelection(structuredSelection); - return transactions.size() == 1 && AccessControlManager.isOseeAdmin(); - } + @Override + public boolean isEnabledWithException(IStructuredSelection structuredSelection) throws OseeCoreException { + List<TransactionRecord> transactions = Handlers.getTransactionsFromStructuredSelection(structuredSelection); + return transactions.size() == 1 && AccessControlManager.isOseeAdmin(); + } }
\ No newline at end of file diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/commandHandlers/branch/commit/CommitHandler.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/commandHandlers/branch/commit/CommitHandler.java index b5b4eed4f96..c757c8e4549 100644 --- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/commandHandlers/branch/commit/CommitHandler.java +++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/commandHandlers/branch/commit/CommitHandler.java @@ -35,6 +35,7 @@ import org.eclipse.osee.framework.ui.skynet.SkynetGuiPlugin; import org.eclipse.osee.framework.ui.skynet.commandHandlers.Handlers;
import org.eclipse.osee.framework.ui.skynet.widgets.xBranch.BranchViewPresentationPreferences;
import org.eclipse.osee.framework.ui.skynet.widgets.xmerge.MergeView;
+import org.eclipse.osee.framework.ui.swt.Displays;
import org.eclipse.swt.widgets.Display;
/**
@@ -42,156 +43,158 @@ import org.eclipse.swt.widgets.Display; * @author Ryan D. Brooks
*/
public abstract class CommitHandler extends CommandHandler {
- protected final boolean useParentBranch;
-
- public CommitHandler(boolean useParentBranch) {
- this.useParentBranch = useParentBranch;
- }
-
- public static boolean commitBranch(final ConflictManagerExternal conflictManager, boolean archiveSourceBranch) throws OseeCoreException {
- final Branch sourceBranch = conflictManager.getSourceBranch();
- final Branch destinationBranch = conflictManager.getDestinationBranch();
- final TransactionRecord transactionId = sourceBranch.getBaseTransaction();
- boolean branchCommitted = false;
-
- if (!conflictManager.getRemainingConflicts().isEmpty()) {
- String message =
- "Commit stopped due to unresolved conflicts\n\nPossible Resolutions:\n Cancel commit and resolve at a later time\n Launch the Merge Manager to resolve conflicts";
- final String fMessage;
- final String[] choices;
- if (AccessControlManager.isOseeAdmin()) {
- fMessage = message + "\n Force the commit";
- choices = new String[] {"Cancel", "Launch Merge Manager", "Force Commit (Admin Only)"};
- } else {
- fMessage = message;
- choices = new String[] {"Cancel", "Launch Merge Manager"};
- }
-
- final MutableInteger dialogResult = new MutableInteger(0);
- Display.getDefault().syncExec(new Runnable() {
- public void run() {
- MessageDialog dialog =
- new MessageDialog(Display.getCurrent().getActiveShell(), "Unresolved Conflicts", null, fMessage,
- MessageDialog.QUESTION, choices, 0);
- dialogResult.setValue(dialog.open());
- if (dialogResult.getValue() == 1) {
- MergeView.openView(sourceBranch, destinationBranch, transactionId);
- }
- }
- });
-
- if (dialogResult.getValue() == 2) {
- BranchManager.commitBranch(null, conflictManager, archiveSourceBranch, true);
- branchCommitted = true;
- }
- } else {
- final StringBuilder message =
- new StringBuilder(
- "Commit branch\n\n\"" + sourceBranch + "\"\n\n onto destination branch\n\n\"" + destinationBranch + "\"\n");
- int numOriginalConflicts = conflictManager.getOriginalConflicts().size();
- if (numOriginalConflicts > 0) {
- message.append("\nwith " + numOriginalConflicts + " conflicts resolved.\n");
- } else {
- message.append("\n(no conflicts found)\n");
- }
- message.append("\nCommit?");
-
- final MutableInteger dialogResult = new MutableInteger(0);
- Display.getDefault().syncExec(new Runnable() {
- public void run() {
- try {
- if (conflictManager.getOriginalConflicts().isEmpty()) {
- MessageDialog dialog =
- new MessageDialog(Display.getCurrent().getActiveShell(), "Commit Branch", null,
- message.toString(), MessageDialog.QUESTION, new String[] {"Ok", "Cancel"}, 0);
- dialogResult.setValue(dialog.open());
- } else {
- MessageDialog dialog =
- new MessageDialog(Display.getCurrent().getActiveShell(), "Commit Branch", null,
- message.toString(), MessageDialog.QUESTION, new String[] {"Ok",
- "Launch Merge Manager", "Cancel"}, 0);
- dialogResult.setValue(dialog.open());
- if (dialogResult.getValue() == 1) {
- MergeView.openView(sourceBranch, destinationBranch, transactionId);
- }
- }
- } catch (OseeCoreException ex) {
- OseeLog.log(SkynetGuiPlugin.class, OseeLevel.SEVERE_POPUP, ex);
- }
- }
- });
-
- if (dialogResult.getValue() == 0) {
- BranchManager.commitBranch(null, conflictManager, archiveSourceBranch, false);
- branchCommitted = true;
- }
- }
- return branchCommitted;
- }
-
- @Override
- public Object execute(ExecutionEvent event) throws ExecutionException {
- IStructuredSelection selection =
- (IStructuredSelection) AWorkbench.getActivePage().getActivePart().getSite().getSelectionProvider().getSelection();
-
- List<Branch> branches = Handlers.getBranchesFromStructuredSelection(selection);
- Branch sourceBranch = branches.iterator().next();
-
- try {
- Branch destinationBranch = null;
- if (useParentBranch) {
- destinationBranch = sourceBranch.getParentBranch();
- } else {
- destinationBranch =
- BranchManager.getBranch(Integer.parseInt(event.getParameter(BranchViewPresentationPreferences.BRANCH_ID)));
- }
- Jobs.startJob(new CommitJob(sourceBranch, destinationBranch,
- Boolean.parseBoolean(event.getParameter(CommitBranchParameter.ARCHIVE_PARENT_BRANCH))));
- } catch (OseeCoreException ex) {
- OseeLog.log(SkynetGuiPlugin.class, OseeLevel.SEVERE_POPUP, ex);
- }
- return null;
- }
-
- @Override
- public boolean isEnabledWithException(IStructuredSelection structuredSelection) throws OseeCoreException {
- List<Branch> branches = Handlers.getBranchesFromStructuredSelection(structuredSelection);
-
- if (branches.size() == 1) {
- Branch branch = branches.iterator().next();
- return useParentBranchValid(branch) || !useParentBranch && AccessControlManager.isOseeAdmin();
- }
- return false;
- }
-
- protected boolean useParentBranchValid(Branch branch) throws OseeCoreException {
- return branch.hasParentBranch() && useParentBranch && !BranchManager.isChangeManaged(branch) && !branch.getArchiveState().isArchived();
- }
- protected class CommitJob extends Job {
- private final Branch sourceBranch;
- private final Branch destinationBranch;
- private final boolean archiveSourceBranch;
-
- /**
- * @param name
- * @param destinationBranch
- * @param sourceBranch
- */
- public CommitJob(Branch sourceBranch, Branch destinationBranch, boolean archiveSourceBranch) {
- super("Commit Branch");
- this.destinationBranch = destinationBranch;
- this.sourceBranch = sourceBranch;
- this.archiveSourceBranch = archiveSourceBranch;
- }
-
- @Override
- protected IStatus run(IProgressMonitor monitor) {
- try {
- commitBranch(new ConflictManagerExternal(destinationBranch, sourceBranch), archiveSourceBranch);
- } catch (OseeCoreException ex) {
- return new Status(Status.ERROR, SkynetGuiPlugin.PLUGIN_ID, ex.getLocalizedMessage(), ex);
- }
- return Status.OK_STATUS;
- }
- }
+ protected final boolean useParentBranch;
+
+ public CommitHandler(boolean useParentBranch) {
+ this.useParentBranch = useParentBranch;
+ }
+
+ public static boolean commitBranch(final ConflictManagerExternal conflictManager, boolean archiveSourceBranch) throws OseeCoreException {
+ final Branch sourceBranch = conflictManager.getSourceBranch();
+ final Branch destinationBranch = conflictManager.getDestinationBranch();
+ final TransactionRecord transactionId = sourceBranch.getBaseTransaction();
+ boolean branchCommitted = false;
+
+ if (!conflictManager.getRemainingConflicts().isEmpty()) {
+ String message =
+ "Commit stopped due to unresolved conflicts\n\nPossible Resolutions:\n Cancel commit and resolve at a later time\n Launch the Merge Manager to resolve conflicts";
+ final String fMessage;
+ final String[] choices;
+ if (AccessControlManager.isOseeAdmin()) {
+ fMessage = message + "\n Force the commit";
+ choices = new String[] {"Cancel", "Launch Merge Manager", "Force Commit (Admin Only)"};
+ } else {
+ fMessage = message;
+ choices = new String[] {"Cancel", "Launch Merge Manager"};
+ }
+
+ final MutableInteger dialogResult = new MutableInteger(0);
+ Displays.pendInDisplayThread(new Runnable() {
+ @Override
+ public void run() {
+ MessageDialog dialog =
+ new MessageDialog(Display.getCurrent().getActiveShell(), "Unresolved Conflicts", null,
+ fMessage, MessageDialog.QUESTION, choices, 0);
+ dialogResult.setValue(dialog.open());
+ if (dialogResult.getValue() == 1) {
+ MergeView.openView(sourceBranch, destinationBranch, transactionId);
+ }
+ }
+ });
+
+ if (dialogResult.getValue() == 2) {
+ BranchManager.commitBranch(null, conflictManager, archiveSourceBranch, true);
+ branchCommitted = true;
+ }
+ } else {
+ final StringBuilder message =
+ new StringBuilder(
+ "Commit branch\n\n\"" + sourceBranch + "\"\n\n onto destination branch\n\n\"" + destinationBranch + "\"\n");
+ int numOriginalConflicts = conflictManager.getOriginalConflicts().size();
+ if (numOriginalConflicts > 0) {
+ message.append("\nwith " + numOriginalConflicts + " conflicts resolved.\n");
+ } else {
+ message.append("\n(no conflicts found)\n");
+ }
+ message.append("\nCommit?");
+
+ final MutableInteger dialogResult = new MutableInteger(0);
+ Displays.pendInDisplayThread(new Runnable() {
+ @Override
+ public void run() {
+ try {
+ if (conflictManager.getOriginalConflicts().isEmpty()) {
+ MessageDialog dialog =
+ new MessageDialog(Display.getCurrent().getActiveShell(), "Commit Branch", null,
+ message.toString(), MessageDialog.QUESTION, new String[] {"Ok", "Cancel"}, 0);
+ dialogResult.setValue(dialog.open());
+ } else {
+ MessageDialog dialog =
+ new MessageDialog(Display.getCurrent().getActiveShell(), "Commit Branch", null,
+ message.toString(), MessageDialog.QUESTION, new String[] {"Ok",
+ "Launch Merge Manager", "Cancel"}, 0);
+ dialogResult.setValue(dialog.open());
+ if (dialogResult.getValue() == 1) {
+ MergeView.openView(sourceBranch, destinationBranch, transactionId);
+ }
+ }
+ } catch (OseeCoreException ex) {
+ OseeLog.log(SkynetGuiPlugin.class, OseeLevel.SEVERE_POPUP, ex);
+ }
+ }
+ });
+
+ if (dialogResult.getValue() == 0) {
+ BranchManager.commitBranch(null, conflictManager, archiveSourceBranch, false);
+ branchCommitted = true;
+ }
+ }
+ return branchCommitted;
+ }
+
+ @Override
+ public Object execute(ExecutionEvent event) throws ExecutionException {
+ IStructuredSelection selection =
+ (IStructuredSelection) AWorkbench.getActivePage().getActivePart().getSite().getSelectionProvider().getSelection();
+
+ List<Branch> branches = Handlers.getBranchesFromStructuredSelection(selection);
+ Branch sourceBranch = branches.iterator().next();
+
+ try {
+ Branch destinationBranch = null;
+ if (useParentBranch) {
+ destinationBranch = sourceBranch.getParentBranch();
+ } else {
+ destinationBranch =
+ BranchManager.getBranch(Integer.parseInt(event.getParameter(BranchViewPresentationPreferences.BRANCH_ID)));
+ }
+ Jobs.startJob(new CommitJob(sourceBranch, destinationBranch,
+ Boolean.parseBoolean(event.getParameter(CommitBranchParameter.ARCHIVE_PARENT_BRANCH))));
+ } catch (OseeCoreException ex) {
+ OseeLog.log(SkynetGuiPlugin.class, OseeLevel.SEVERE_POPUP, ex);
+ }
+ return null;
+ }
+
+ @Override
+ public boolean isEnabledWithException(IStructuredSelection structuredSelection) throws OseeCoreException {
+ List<Branch> branches = Handlers.getBranchesFromStructuredSelection(structuredSelection);
+
+ if (branches.size() == 1) {
+ Branch branch = branches.iterator().next();
+ return useParentBranchValid(branch) || !useParentBranch && AccessControlManager.isOseeAdmin();
+ }
+ return false;
+ }
+
+ protected boolean useParentBranchValid(Branch branch) throws OseeCoreException {
+ return branch.hasParentBranch() && useParentBranch && !BranchManager.isChangeManaged(branch) && !branch.getArchiveState().isArchived();
+ }
+ protected class CommitJob extends Job {
+ private final Branch sourceBranch;
+ private final Branch destinationBranch;
+ private final boolean archiveSourceBranch;
+
+ /**
+ * @param name
+ * @param destinationBranch
+ * @param sourceBranch
+ */
+ public CommitJob(Branch sourceBranch, Branch destinationBranch, boolean archiveSourceBranch) {
+ super("Commit Branch");
+ this.destinationBranch = destinationBranch;
+ this.sourceBranch = sourceBranch;
+ this.archiveSourceBranch = archiveSourceBranch;
+ }
+
+ @Override
+ protected IStatus run(IProgressMonitor monitor) {
+ try {
+ commitBranch(new ConflictManagerExternal(destinationBranch, sourceBranch), archiveSourceBranch);
+ } catch (OseeCoreException ex) {
+ return new Status(Status.ERROR, SkynetGuiPlugin.PLUGIN_ID, ex.getLocalizedMessage(), ex);
+ }
+ return Status.OK_STATUS;
+ }
+ }
}
\ No newline at end of file diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/dialogs/AuthenticationDialog.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/dialogs/AuthenticationDialog.java index 175a503c557..19d5630c575 100644 --- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/dialogs/AuthenticationDialog.java +++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/dialogs/AuthenticationDialog.java @@ -21,6 +21,7 @@ import org.eclipse.osee.framework.logging.OseeLog; import org.eclipse.osee.framework.skynet.core.UserManager; import org.eclipse.osee.framework.ui.skynet.FrameworkImage; import org.eclipse.osee.framework.ui.skynet.panels.AuthenticationComposite; +import org.eclipse.osee.framework.ui.swt.Displays; import org.eclipse.osee.framework.ui.swt.ImageManager; import org.eclipse.osee.framework.ui.swt.OseeMessageDialog; import org.eclipse.swt.SWT; @@ -29,7 +30,6 @@ import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Shell; import org.eclipse.ui.PlatformUI; @@ -38,209 +38,209 @@ import org.eclipse.ui.PlatformUI; */ public class AuthenticationDialog extends OseeMessageDialog { - private Button okButton; - private Button cancelButton; - protected AuthenticationComposite authenticationComposite; - private boolean selectionOk; - private static final int MAX_RETRIES = 3; - - public AuthenticationDialog(Shell parentShell) { - super(parentShell, "OSEE Authenticate", null, "Enter your user id (email address), password, and domain.", - ImageManager.getImage(FrameworkImage.LOCKED_KEY), new String[] {"Enter", "Cancel"}, 0); - - selectionOk = false; - authenticationComposite = new AuthenticationComposite(parentShell, SWT.NONE, false); - } - - @Override - protected Control createCustomArea(Composite parent) { - authenticationComposite.setParent(parent); - return authenticationComposite; - } - - @Override - protected Control createButtonBar(Composite parent) { - Control c = super.createButtonBar(parent); - okButton = getButton(0); - cancelButton = getButton(1); - - okButton.setEnabled(false); - okButton.addSelectionListener(authenticationComposite.getAuthenticateListener()); - okButton.addSelectionListener(new SelectionAdapter() { - - @Override - public void widgetSelected(SelectionEvent e) { - selectionOk = true; - } - }); - authenticationComposite.getShell().setDefaultButton(okButton); - - cancelButton.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - selectionOk = false; - } - }); - return c; - } - - public boolean isValid() { - return selectionOk; - } - - private void setUserName(String user) { - authenticationComposite.setUserName(user); - } - - private void setPassword(String password) { - authenticationComposite.setPassword(password); - } - - private void setDomain(String domain) { - authenticationComposite.setDomain(domain); - } - - private void setStorageAllowed(boolean isStorageAllowed) { - authenticationComposite.setStorageAllowed(isStorageAllowed); - } - - private void setGuestLogin(boolean isGuestLogin) { - authenticationComposite.setGuestLogin(isGuestLogin); - } - - private void setProtocol(String protocol) { - authenticationComposite.setProtocol(protocol); - } - - private String getUserName() { - return authenticationComposite.getUserName(); - } - - private String getDomain() { - return authenticationComposite.getDomain(); - } - - private String getProtocol() { - return authenticationComposite.getProtocol(); - } - - private boolean isStorageAllowed() { - return authenticationComposite.isStorageAllowed(); - } - - private boolean isGuestLogin() { - return authenticationComposite.isGuestLogin(); - } - - public static void openDialog() { - Display.getDefault().syncExec(new Runnable() { - - private String getErrorMessage(AuthenticationErrorCode status) { - String toReturn = ""; - if (status == null) { - status = AuthenticationErrorCode.Unknown; - } - switch (status) { - case UserNotFound: - toReturn = "User Id not found.\n" + "Enter your user id."; - break; - case InvalidPassword: - toReturn = - "Invalid Password.\n" + "Make sure <CAPS LOCK> is not enabled.\n" + "Enter a valid password."; - break; - case NoResponse: - toReturn = "Please enter a valid user id and password."; - break; - default: - toReturn = "Unknown authentication error"; - break; - } - return toReturn; - } - - public void run() { - String dialogTitle = "Authentication Failed"; - String endMsg = "Shutting down the workbench."; - String user = ""; - String domain = ""; - String message = ""; - String protocol = ""; - boolean isStorageAllowed = false; - boolean isGuestLogin = false; - boolean shutdown = false; - Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(); - - for (int numberOfTries = 0; numberOfTries < MAX_RETRIES; numberOfTries++) { - AuthenticationDialog dialog = new AuthenticationDialog(shell); - if (numberOfTries != 0) { - dialog.setUserName(user); - dialog.setPassword(""); - dialog.setDomain(domain); - dialog.setProtocol(protocol); - dialog.setStorageAllowed(isStorageAllowed); - dialog.setGuestLogin(isGuestLogin); - } - int result = dialog.open(); - - user = dialog.getUserName(); - protocol = dialog.getProtocol(); - domain = dialog.getDomain(); - isStorageAllowed = dialog.isStorageAllowed(); - isGuestLogin = dialog.isGuestLogin(); - - if (result == Window.CANCEL) { - // TODO This was added because ATS requires a user to be logged in - // Non-Authentication is not an option -- - if (numberOfTries > MAX_RETRIES) { - message = "Maximum number of Retries reached.\n" + endMsg; - shutdown = true; - } else { - message = - "Please log in as Guest or with your credentials.\n" + "A Log-in account is required to continue."; - } - - MessageDialog.openError(shell, "Authentication Cancelled", message); - } - // else if (result != Window.OK ) { - // numberOfTries = MAX_RETRIES; - // } - else { - if (dialog.isValid()) { - if (ClientSessionManager.isSessionValid()) { - numberOfTries = MAX_RETRIES; - String userText; - try { - userText = UserManager.getUser().toString(); - } catch (OseeCoreException ex) { - userText = ex.getLocalizedMessage(); - } - MessageDialog.openInformation(shell, "Authenticated", "Logged in as: " + userText); - } else { - if (numberOfTries >= MAX_RETRIES - 1) { - message = "Maximum number of Retries reached.\n" + endMsg; - shutdown = true; - } else { - IHealthStatus status = OseeLog.getStatusByName(ClientSessionManager.getStatusId()); - if (status != null && status.getException() != null) { - Throwable ex = status.getException(); - if (ex instanceof OseeAuthenticationException) { - message = getErrorMessage(((OseeAuthenticationException) ex).getCode()); - } - message = ex.getLocalizedMessage(); - } else { - message = "Authentication error"; - } - } - MessageDialog.openError(shell, dialogTitle, message); - } - } - } - } - - if (shutdown) { - PlatformUI.getWorkbench().close(); - } - } - }); - } + private Button okButton; + private Button cancelButton; + protected AuthenticationComposite authenticationComposite; + private boolean selectionOk; + private static final int MAX_RETRIES = 3; + + public AuthenticationDialog(Shell parentShell) { + super(parentShell, "OSEE Authenticate", null, "Enter your user id (email address), password, and domain.", + ImageManager.getImage(FrameworkImage.LOCKED_KEY), new String[] {"Enter", "Cancel"}, 0); + + selectionOk = false; + authenticationComposite = new AuthenticationComposite(parentShell, SWT.NONE, false); + } + + @Override + protected Control createCustomArea(Composite parent) { + authenticationComposite.setParent(parent); + return authenticationComposite; + } + + @Override + protected Control createButtonBar(Composite parent) { + Control c = super.createButtonBar(parent); + okButton = getButton(0); + cancelButton = getButton(1); + + okButton.setEnabled(false); + okButton.addSelectionListener(authenticationComposite.getAuthenticateListener()); + okButton.addSelectionListener(new SelectionAdapter() { + + @Override + public void widgetSelected(SelectionEvent e) { + selectionOk = true; + } + }); + authenticationComposite.getShell().setDefaultButton(okButton); + + cancelButton.addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + selectionOk = false; + } + }); + return c; + } + + public boolean isValid() { + return selectionOk; + } + + private void setUserName(String user) { + authenticationComposite.setUserName(user); + } + + private void setPassword(String password) { + authenticationComposite.setPassword(password); + } + + private void setDomain(String domain) { + authenticationComposite.setDomain(domain); + } + + private void setStorageAllowed(boolean isStorageAllowed) { + authenticationComposite.setStorageAllowed(isStorageAllowed); + } + + private void setGuestLogin(boolean isGuestLogin) { + authenticationComposite.setGuestLogin(isGuestLogin); + } + + private void setProtocol(String protocol) { + authenticationComposite.setProtocol(protocol); + } + + private String getUserName() { + return authenticationComposite.getUserName(); + } + + private String getDomain() { + return authenticationComposite.getDomain(); + } + + private String getProtocol() { + return authenticationComposite.getProtocol(); + } + + private boolean isStorageAllowed() { + return authenticationComposite.isStorageAllowed(); + } + + private boolean isGuestLogin() { + return authenticationComposite.isGuestLogin(); + } + + public static void openDialog() { + Displays.pendInDisplayThread(new Runnable() { + + private String getErrorMessage(AuthenticationErrorCode status) { + String toReturn = ""; + if (status == null) { + status = AuthenticationErrorCode.Unknown; + } + switch (status) { + case UserNotFound: + toReturn = "User Id not found.\n" + "Enter your user id."; + break; + case InvalidPassword: + toReturn = + "Invalid Password.\n" + "Make sure <CAPS LOCK> is not enabled.\n" + "Enter a valid password."; + break; + case NoResponse: + toReturn = "Please enter a valid user id and password."; + break; + default: + toReturn = "Unknown authentication error"; + break; + } + return toReturn; + } + + public void run() { + String dialogTitle = "Authentication Failed"; + String endMsg = "Shutting down the workbench."; + String user = ""; + String domain = ""; + String message = ""; + String protocol = ""; + boolean isStorageAllowed = false; + boolean isGuestLogin = false; + boolean shutdown = false; + Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(); + + for (int numberOfTries = 0; numberOfTries < MAX_RETRIES; numberOfTries++) { + AuthenticationDialog dialog = new AuthenticationDialog(shell); + if (numberOfTries != 0) { + dialog.setUserName(user); + dialog.setPassword(""); + dialog.setDomain(domain); + dialog.setProtocol(protocol); + dialog.setStorageAllowed(isStorageAllowed); + dialog.setGuestLogin(isGuestLogin); + } + int result = dialog.open(); + + user = dialog.getUserName(); + protocol = dialog.getProtocol(); + domain = dialog.getDomain(); + isStorageAllowed = dialog.isStorageAllowed(); + isGuestLogin = dialog.isGuestLogin(); + + if (result == Window.CANCEL) { + // TODO This was added because ATS requires a user to be logged in + // Non-Authentication is not an option -- + if (numberOfTries > MAX_RETRIES) { + message = "Maximum number of Retries reached.\n" + endMsg; + shutdown = true; + } else { + message = + "Please log in as Guest or with your credentials.\n" + "A Log-in account is required to continue."; + } + + MessageDialog.openError(shell, "Authentication Cancelled", message); + } + // else if (result != Window.OK ) { + // numberOfTries = MAX_RETRIES; + // } + else { + if (dialog.isValid()) { + if (ClientSessionManager.isSessionValid()) { + numberOfTries = MAX_RETRIES; + String userText; + try { + userText = UserManager.getUser().toString(); + } catch (OseeCoreException ex) { + userText = ex.getLocalizedMessage(); + } + MessageDialog.openInformation(shell, "Authenticated", "Logged in as: " + userText); + } else { + if (numberOfTries >= MAX_RETRIES - 1) { + message = "Maximum number of Retries reached.\n" + endMsg; + shutdown = true; + } else { + IHealthStatus status = OseeLog.getStatusByName(ClientSessionManager.getStatusId()); + if (status != null && status.getException() != null) { + Throwable ex = status.getException(); + if (ex instanceof OseeAuthenticationException) { + message = getErrorMessage(((OseeAuthenticationException) ex).getCode()); + } + message = ex.getLocalizedMessage(); + } else { + message = "Authentication error"; + } + } + MessageDialog.openError(shell, dialogTitle, message); + } + } + } + } + + if (shutdown) { + PlatformUI.getWorkbench().close(); + } + } + }); + } } diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/group/GroupExplorer.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/group/GroupExplorer.java index e8f9e7fd3fa..4ae174621dd 100644 --- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/group/GroupExplorer.java +++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/group/GroupExplorer.java @@ -46,7 +46,6 @@ import org.eclipse.osee.framework.skynet.core.transaction.SkynetTransaction; import org.eclipse.osee.framework.ui.plugin.OseeUiActions;
import org.eclipse.osee.framework.ui.plugin.PluginUiImage;
import org.eclipse.osee.framework.ui.plugin.util.AWorkbench;
-import org.eclipse.osee.framework.ui.plugin.util.Displays;
import org.eclipse.osee.framework.ui.skynet.OpenWithMenuListener;
import org.eclipse.osee.framework.ui.skynet.OseeContributionItem;
import org.eclipse.osee.framework.ui.skynet.SkynetGuiPlugin;
@@ -59,6 +58,7 @@ import org.eclipse.osee.framework.ui.skynet.render.RendererManager; import org.eclipse.osee.framework.ui.skynet.util.DbConnectionExceptionComposite;
import org.eclipse.osee.framework.ui.skynet.widgets.XBranchSelectWidget;
import org.eclipse.osee.framework.ui.skynet.widgets.dialog.EntryDialog;
+import org.eclipse.osee.framework.ui.swt.Displays;
import org.eclipse.osee.framework.ui.swt.ImageManager;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.MenuEvent;
diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/handler/ArtifactChangeHandler.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/handler/ArtifactChangeHandler.java index b2d5d968d2d..80429188c2e 100644 --- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/handler/ArtifactChangeHandler.java +++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/handler/ArtifactChangeHandler.java @@ -15,7 +15,7 @@ import org.eclipse.core.runtime.IStatus; import org.eclipse.debug.core.IStatusHandler; import org.eclipse.jface.dialogs.MessageDialog; import org.eclipse.osee.framework.jdk.core.type.MutableInteger; -import org.eclipse.osee.framework.ui.plugin.util.Displays; +import org.eclipse.osee.framework.ui.swt.Displays; import org.eclipse.ui.PlatformUI; /** diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/handler/RemoveTrackChangesHandler.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/handler/RemoveTrackChangesHandler.java index bda7cf46b63..b2fea2b4b79 100644 --- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/handler/RemoveTrackChangesHandler.java +++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/handler/RemoveTrackChangesHandler.java @@ -15,7 +15,7 @@ import org.eclipse.core.runtime.IStatus; import org.eclipse.debug.core.IStatusHandler; import org.eclipse.jface.dialogs.MessageDialog; import org.eclipse.osee.framework.jdk.core.type.MutableInteger; -import org.eclipse.osee.framework.ui.plugin.util.Displays; +import org.eclipse.osee.framework.ui.swt.Displays; import org.eclipse.ui.PlatformUI; /** diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/preferences/ArbitrationServerPage.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/preferences/ArbitrationServerPage.java index eccd6c82c0e..b66c4c686c3 100644 --- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/preferences/ArbitrationServerPage.java +++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/preferences/ArbitrationServerPage.java @@ -21,13 +21,13 @@ import org.eclipse.osee.framework.core.exception.OseeDataStoreException; import org.eclipse.osee.framework.jdk.core.util.Strings;
import org.eclipse.osee.framework.logging.OseeLog;
import org.eclipse.osee.framework.ui.skynet.SkynetGuiPlugin;
+import org.eclipse.osee.framework.ui.swt.Displays;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Group;
import org.eclipse.swt.widgets.Label;
import org.eclipse.ui.IWorkbench;
@@ -38,114 +38,113 @@ import org.eclipse.ui.IWorkbenchPreferencePage; */
public class ArbitrationServerPage extends PreferencePage implements IWorkbenchPreferencePage {
- public ArbitrationServerPage() {
- super();
- }
-
- @Override
- protected Control createContents(Composite parent) {
- Composite content = new Composite(parent, SWT.NONE);
- GridLayout layout = new GridLayout();
- layout.marginHeight = 0;
- layout.marginWidth = 0;
- content.setLayout(layout);
- content.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
-
- Group resourceGroup = new Group(content, SWT.NONE);
- resourceGroup.setLayout(new GridLayout());
- resourceGroup.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
- resourceGroup.setText("OSEE Arbitration");
-
- Composite resourceComposite = new Composite(resourceGroup, SWT.NONE);
- resourceComposite.setLayout(new GridLayout(2, false));
- resourceComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
-
- boolean wasArbitrationOverriden = Strings.isValid(OseeClientProperties.getOseeApplicationServer());
- String defaultArbitrationServer = null;
- if (!wasArbitrationOverriden) {
- try {
- defaultArbitrationServer = HttpUrlBuilderClient.getInstance().getArbitrationServerPrefix();
- } catch (OseeDataStoreException ex) {
- OseeLog.log(SkynetGuiPlugin.class, Level.SEVERE, ex);
- }
- }
-
- String defaultApplicationServer = null;
- try {
- defaultApplicationServer = HttpUrlBuilderClient.getInstance().getApplicationServerPrefix();
- } catch (OseeDataStoreException ex) {
- OseeLog.log(SkynetGuiPlugin.class, Level.SEVERE, ex);
- }
-
- List<Data> entries = new ArrayList<Data>();
-
- if (wasArbitrationOverriden) {
- entries.add(new Data("Arbitration", "Disabled", Display.getDefault().getSystemColor(SWT.COLOR_RED)));
- entries.add(new Data("Application Server: ", defaultApplicationServer != null ? defaultApplicationServer : ""));
- } else {
- entries.add(new Data("Arbitration Server: ", defaultArbitrationServer != null ? defaultArbitrationServer : ""));
- entries.add(new Data("Version To Match: ", OseeCodeVersion.getVersion()));
- entries.add(new Data("Resolved To Server: ", defaultApplicationServer != null ? defaultApplicationServer : ""));
- }
- for (Data entry : entries) {
- Label label1 = new Label(resourceComposite, SWT.NONE);
- label1.setForeground(entry.getLabelColor());
- label1.setText(entry.getLabelText());
-
- Label label2 = new Label(resourceComposite, SWT.NONE);
- label2.setForeground(entry.getDataColor());
- label2.setText(entry.getDataText());
- }
- return content;
- }
-
- public void init(IWorkbench workbench) {
- setPreferenceStore(SkynetGuiPlugin.getInstance().getPreferenceStore());
- setDescription("See default Arbitration Server below.");
- }
-
- private final class Data {
- private final String label;
- private final Color labelColor;
- private final String value;
- private final Color valueColor;
-
- public Data(String label, Color labelColor, String value, Color valueColor) {
- super();
- this.label = label;
- this.labelColor = labelColor;
- this.value = value;
- this.valueColor = valueColor;
- }
-
- public Data(String label, Color labelColor, String value) {
- this(label, labelColor, value, Display.getDefault().getSystemColor(SWT.COLOR_BLACK));
- }
-
- public Data(String label, String value, Color valueColor) {
- this(label, Display.getDefault().getSystemColor(SWT.COLOR_BLUE), value, valueColor);
- }
-
- public Data(String label, String value) {
- this(label, Display.getDefault().getSystemColor(SWT.COLOR_BLUE), value, Display.getDefault().getSystemColor(
- SWT.COLOR_BLACK));
- }
-
- public String getLabelText() {
- return label;
- }
-
- public Color getLabelColor() {
- return labelColor;
- }
-
- public String getDataText() {
- return value;
- }
-
- public Color getDataColor() {
- return valueColor;
- }
-
- }
+ public ArbitrationServerPage() {
+ super();
+ }
+
+ @Override
+ protected Control createContents(Composite parent) {
+ Composite content = new Composite(parent, SWT.NONE);
+ GridLayout layout = new GridLayout();
+ layout.marginHeight = 0;
+ layout.marginWidth = 0;
+ content.setLayout(layout);
+ content.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+
+ Group resourceGroup = new Group(content, SWT.NONE);
+ resourceGroup.setLayout(new GridLayout());
+ resourceGroup.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
+ resourceGroup.setText("OSEE Arbitration");
+
+ Composite resourceComposite = new Composite(resourceGroup, SWT.NONE);
+ resourceComposite.setLayout(new GridLayout(2, false));
+ resourceComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
+
+ boolean wasArbitrationOverriden = Strings.isValid(OseeClientProperties.getOseeApplicationServer());
+ String defaultArbitrationServer = null;
+ if (!wasArbitrationOverriden) {
+ try {
+ defaultArbitrationServer = HttpUrlBuilderClient.getInstance().getArbitrationServerPrefix();
+ } catch (OseeDataStoreException ex) {
+ OseeLog.log(SkynetGuiPlugin.class, Level.SEVERE, ex);
+ }
+ }
+
+ String defaultApplicationServer = null;
+ try {
+ defaultApplicationServer = HttpUrlBuilderClient.getInstance().getApplicationServerPrefix();
+ } catch (OseeDataStoreException ex) {
+ OseeLog.log(SkynetGuiPlugin.class, Level.SEVERE, ex);
+ }
+
+ List<Data> entries = new ArrayList<Data>();
+
+ if (wasArbitrationOverriden) {
+ entries.add(new Data("Arbitration", "Disabled", Displays.getSystemColor(SWT.COLOR_RED)));
+ entries.add(new Data("Application Server: ", defaultApplicationServer != null ? defaultApplicationServer : ""));
+ } else {
+ entries.add(new Data("Arbitration Server: ", defaultArbitrationServer != null ? defaultArbitrationServer : ""));
+ entries.add(new Data("Version To Match: ", OseeCodeVersion.getVersion()));
+ entries.add(new Data("Resolved To Server: ", defaultApplicationServer != null ? defaultApplicationServer : ""));
+ }
+ for (Data entry : entries) {
+ Label label1 = new Label(resourceComposite, SWT.NONE);
+ label1.setForeground(entry.getLabelColor());
+ label1.setText(entry.getLabelText());
+
+ Label label2 = new Label(resourceComposite, SWT.NONE);
+ label2.setForeground(entry.getDataColor());
+ label2.setText(entry.getDataText());
+ }
+ return content;
+ }
+
+ public void init(IWorkbench workbench) {
+ setPreferenceStore(SkynetGuiPlugin.getInstance().getPreferenceStore());
+ setDescription("See default Arbitration Server below.");
+ }
+
+ private final class Data {
+ private final String label;
+ private final Color labelColor;
+ private final String value;
+ private final Color valueColor;
+
+ public Data(String label, Color labelColor, String value, Color valueColor) {
+ super();
+ this.label = label;
+ this.labelColor = labelColor;
+ this.value = value;
+ this.valueColor = valueColor;
+ }
+
+ public Data(String label, Color labelColor, String value) {
+ this(label, labelColor, value, Displays.getSystemColor(SWT.COLOR_BLACK));
+ }
+
+ public Data(String label, String value, Color valueColor) {
+ this(label, Displays.getSystemColor(SWT.COLOR_BLUE), value, valueColor);
+ }
+
+ public Data(String label, String value) {
+ this(label, Displays.getSystemColor(SWT.COLOR_BLUE), value, Displays.getSystemColor(SWT.COLOR_BLACK));
+ }
+
+ public String getLabelText() {
+ return label;
+ }
+
+ public Color getLabelColor() {
+ return labelColor;
+ }
+
+ public String getDataText() {
+ return value;
+ }
+
+ public Color getDataColor() {
+ return valueColor;
+ }
+
+ }
}
diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/preferences/ConfigurationDetails.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/preferences/ConfigurationDetails.java index e734051f96f..4c5763c030a 100644 --- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/preferences/ConfigurationDetails.java +++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/preferences/ConfigurationDetails.java @@ -19,6 +19,7 @@ import org.eclipse.osee.framework.logging.IHealthStatus; import org.eclipse.osee.framework.logging.OseeLog;
import org.eclipse.osee.framework.skynet.core.event.RemoteEventManager;
import org.eclipse.osee.framework.ui.skynet.SkynetGuiPlugin;
+import org.eclipse.osee.framework.ui.swt.Displays;
import org.eclipse.swt.SWT;
import org.eclipse.swt.browser.Browser;
import org.eclipse.swt.layout.FillLayout;
@@ -26,7 +27,6 @@ import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Group;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchPreferencePage;
@@ -35,87 +35,90 @@ import org.eclipse.ui.IWorkbenchPreferencePage; * @author Roberto E. Escobar
*/
public class ConfigurationDetails extends PreferencePage implements IWorkbenchPreferencePage {
- public static final String PAGE_ID = "org.eclipse.osee.framework.ui.skynet.preferences.OseeConfigDetailsPage";
-
- private static final String HTML_HEADER =
- "<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html14/loose.dtd\">\n";
-
- private static final String CSS_SHEET =
- "<style type=\"text/css\"> table.oseeTable { font: 0.7em \"arial\", serif; border-width: 1px 1px 1px 1px; border-spacing: 2px; border-style: solid solid solid solid; border-color: blue blue blue blue; border-collapse: separate; background-color: rgb(255, 250, 250); } " + " table.oseeTable th { border-width: 1px 1px 1px 1px; padding: 4px 4px 4px 4px; border-style: solid solid solid solid; border-color: black black black black; background-color: white; -moz-border-radius: 0px 0px 0px 0px; } " + " table.oseeTable td { border-width: 1px 1px 1px 1px; padding: 4px 4px 4px 4px; border-style: solid solid solid solid; border-color: black black black black; background-color: white; -moz-border-radius: 0px 0px 0px 0px; } </style>\n";
-
- private static final String PAGE_TEMPLATE =
- HTML_HEADER + "<html>\n<head>\n" + CSS_SHEET + "</head>\n<body>\n%s</body>\n</html>";
-
- private Browser browser;
-
- public ConfigurationDetails() {
- super();
- this.browser = null;
- }
-
- public void init(IWorkbench workbench) {
- setPreferenceStore(SkynetGuiPlugin.getInstance().getPreferenceStore());
- setDescription("See below for OSEE configuration details.");
- }
-
- @Override
- protected Control createContents(Composite parent) {
- Composite content = new Composite(parent, SWT.NONE);
- GridLayout layout = new GridLayout();
- layout.marginHeight = 0;
- layout.marginWidth = 0;
- content.setLayout(layout);
- content.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
-
- Group composite = new Group(content, SWT.NONE);
- composite.setLayout(new GridLayout());
- composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
- composite.setText("Connections");
-
- browser = new Browser(composite, SWT.READ_ONLY | SWT.BORDER);
- browser.setLayout(new FillLayout());
- browser.setLayoutData(new GridData(GridData.FILL_BOTH | GridData.GRAB_HORIZONTAL | GridData.GRAB_VERTICAL));
-
- Display.getDefault().asyncExec(new Runnable() {
- public void run() {
- generatePage();
- }
- });
- return content;
- }
-
- private void generatePage() {
- StringBuilder builder = new StringBuilder();
- builder.append("<table class=\"oseeTable\" width=\"100%\">");
- builder.append(AHTML.addHeaderRowMultiColumnTable(new String[] {"Type", "Info", "Status"}));
-
- String buildType = "N/A";
- boolean wasSuccessful = false;
- try {
- buildType = ClientSessionManager.getClientBuildDesignation();
- wasSuccessful = true;
- } catch (OseeCoreException ex) {
- // Do Nothing;
- }
-
- builder.append(AHTML.addRowMultiColumnTable("<b>OSEE Client Version</b>", OseeCodeVersion.getVersion(),
- "<font color=\"green\"><b>Ok</b></font>"));
-
- builder.append(AHTML.addRowMultiColumnTable("<b>OSEE Client Build Type</b>", buildType,
- wasSuccessful ? "<font color=\"green\"><b>Ok</b></font>" : "<font color=\"red\"><b>Unavailable</b></font>"));
-
- for (IHealthStatus status : OseeLog.getStatus()) {
- builder.append(AHTML.addRowMultiColumnTable(
- "<b>" + status.getSourceName() + "</b>",
- status.getMessage().replaceAll("]", "]<br/>"),
- status.isOk() ? "<font color=\"green\"><b>Ok</b></font>" : "<font color=\"red\"><b>Unavailable</b></font>"));
- }
- builder.append(AHTML.addRowMultiColumnTable(
- "<b>Remote Event Service</b>",
- "",
- RemoteEventManager.isConnected() ? "<font color=\"green\"><b>Ok</b></font>" : "<font color=\"red\"><b>Unavailable</b></font>"));
-
- builder.append(AHTML.endMultiColumnTable());
- browser.setText(String.format(PAGE_TEMPLATE, builder.toString()));
- }
+ public static final String PAGE_ID = "org.eclipse.osee.framework.ui.skynet.preferences.OseeConfigDetailsPage";
+
+ private static final String HTML_HEADER =
+ "<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html14/loose.dtd\">\n";
+
+ private static final String CSS_SHEET =
+ "<style type=\"text/css\"> table.oseeTable { font: 0.7em \"arial\", serif; border-width: 1px 1px 1px 1px; border-spacing: 2px; border-style: solid solid solid solid; border-color: blue blue blue blue; border-collapse: separate; background-color: rgb(255, 250, 250); } " + " table.oseeTable th { border-width: 1px 1px 1px 1px; padding: 4px 4px 4px 4px; border-style: solid solid solid solid; border-color: black black black black; background-color: white; -moz-border-radius: 0px 0px 0px 0px; } " + " table.oseeTable td { border-width: 1px 1px 1px 1px; padding: 4px 4px 4px 4px; border-style: solid solid solid solid; border-color: black black black black; background-color: white; -moz-border-radius: 0px 0px 0px 0px; } </style>\n";
+
+ private static final String PAGE_TEMPLATE =
+ HTML_HEADER + "<html>\n<head>\n" + CSS_SHEET + "</head>\n<body>\n%s</body>\n</html>";
+
+ private Browser browser;
+
+ public ConfigurationDetails() {
+ super();
+ this.browser = null;
+ }
+
+ public void init(IWorkbench workbench) {
+ setPreferenceStore(SkynetGuiPlugin.getInstance().getPreferenceStore());
+ setDescription("See below for OSEE configuration details.");
+ }
+
+ @Override
+ protected Control createContents(Composite parent) {
+ Composite content = new Composite(parent, SWT.NONE);
+ GridLayout layout = new GridLayout();
+ layout.marginHeight = 0;
+ layout.marginWidth = 0;
+ content.setLayout(layout);
+ content.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+
+ Group composite = new Group(content, SWT.NONE);
+ composite.setLayout(new GridLayout());
+ composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+ composite.setText("Connections");
+
+ browser = new Browser(composite, SWT.READ_ONLY | SWT.BORDER);
+ browser.setLayout(new FillLayout());
+ browser.setLayoutData(new GridData(GridData.FILL_BOTH | GridData.GRAB_HORIZONTAL | GridData.GRAB_VERTICAL));
+
+ Displays.ensureInDisplayThread(new Runnable() {
+ @Override
+ public void run() {
+ generatePage();
+ }
+ });
+ return content;
+ }
+
+ private void generatePage() {
+ StringBuilder builder = new StringBuilder();
+ builder.append("<table class=\"oseeTable\" width=\"100%\">");
+ builder.append(AHTML.addHeaderRowMultiColumnTable(new String[] {"Type", "Info", "Status"}));
+
+ String buildType = "N/A";
+ boolean wasSuccessful = false;
+ try {
+ buildType = ClientSessionManager.getClientBuildDesignation();
+ wasSuccessful = true;
+ } catch (OseeCoreException ex) {
+ // Do Nothing;
+ }
+
+ builder.append(AHTML.addRowMultiColumnTable("<b>OSEE Client Version</b>", OseeCodeVersion.getVersion(),
+ "<font color=\"green\"><b>Ok</b></font>"));
+
+ builder.append(AHTML.addRowMultiColumnTable(
+ "<b>OSEE Client Build Type</b>",
+ buildType,
+ wasSuccessful ? "<font color=\"green\"><b>Ok</b></font>" : "<font color=\"red\"><b>Unavailable</b></font>"));
+
+ for (IHealthStatus status : OseeLog.getStatus()) {
+ builder.append(AHTML.addRowMultiColumnTable(
+ "<b>" + status.getSourceName() + "</b>",
+ status.getMessage().replaceAll("]", "]<br/>"),
+ status.isOk() ? "<font color=\"green\"><b>Ok</b></font>" : "<font color=\"red\"><b>Unavailable</b></font>"));
+ }
+ builder.append(AHTML.addRowMultiColumnTable(
+ "<b>Remote Event Service</b>",
+ "",
+ RemoteEventManager.isConnected() ? "<font color=\"green\"><b>Ok</b></font>" : "<font color=\"red\"><b>Unavailable</b></font>"));
+
+ builder.append(AHTML.endMultiColumnTable());
+ browser.setText(String.format(PAGE_TEMPLATE, builder.toString()));
+ }
}
diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/preferences/DataSourceDetails.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/preferences/DataSourceDetails.java index 4b858c0f2ef..fc43af94139 100644 --- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/preferences/DataSourceDetails.java +++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/preferences/DataSourceDetails.java @@ -20,6 +20,7 @@ import org.eclipse.osee.framework.database.core.OseeInfo; import org.eclipse.osee.framework.jdk.core.util.AHTML;
import org.eclipse.osee.framework.jdk.core.util.Lib;
import org.eclipse.osee.framework.ui.skynet.SkynetGuiPlugin;
+import org.eclipse.osee.framework.ui.swt.Displays;
import org.eclipse.swt.SWT;
import org.eclipse.swt.browser.Browser;
import org.eclipse.swt.layout.FillLayout;
@@ -27,7 +28,6 @@ import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Group;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchPreferencePage;
@@ -36,101 +36,102 @@ import org.eclipse.ui.IWorkbenchPreferencePage; * @author Roberto E. Escobar
*/
public class DataSourceDetails extends PreferencePage implements IWorkbenchPreferencePage {
- private static final String HTML_HEADER =
- "<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html14/loose.dtd\">\n";
+ private static final String HTML_HEADER =
+ "<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html14/loose.dtd\">\n";
- private static final String CSS_SHEET =
- "<style type=\"text/css\"> table.oseeTable { font: 0.7em \"arial\", serif; border-width: 1px 1px 1px 1px; border-spacing: 2px; border-style: solid solid solid solid; border-color: blue blue blue blue; border-collapse: separate; background-color: rgb(255, 250, 250); } " + " table.oseeTable th { border-width: 1px 1px 1px 1px; padding: 4px 4px 4px 4px; border-style: solid solid solid solid; border-color: black black black black; background-color: white; -moz-border-radius: 0px 0px 0px 0px; } " + " table.oseeTable td { border-width: 1px 1px 1px 1px; padding: 4px 4px 4px 4px; border-style: solid solid solid solid; border-color: black black black black; background-color: white; -moz-border-radius: 0px 0px 0px 0px; } </style>\n";
+ private static final String CSS_SHEET =
+ "<style type=\"text/css\"> table.oseeTable { font: 0.7em \"arial\", serif; border-width: 1px 1px 1px 1px; border-spacing: 2px; border-style: solid solid solid solid; border-color: blue blue blue blue; border-collapse: separate; background-color: rgb(255, 250, 250); } " + " table.oseeTable th { border-width: 1px 1px 1px 1px; padding: 4px 4px 4px 4px; border-style: solid solid solid solid; border-color: black black black black; background-color: white; -moz-border-radius: 0px 0px 0px 0px; } " + " table.oseeTable td { border-width: 1px 1px 1px 1px; padding: 4px 4px 4px 4px; border-style: solid solid solid solid; border-color: black black black black; background-color: white; -moz-border-radius: 0px 0px 0px 0px; } </style>\n";
- private static final String PAGE_TEMPLATE =
- HTML_HEADER + "<html>\n<head>\n" + CSS_SHEET + "</head>\n<body>\n%s</body>\n</html>";
+ private static final String PAGE_TEMPLATE =
+ HTML_HEADER + "<html>\n<head>\n" + CSS_SHEET + "</head>\n<body>\n%s</body>\n</html>";
- private Browser browser;
+ private Browser browser;
- public DataSourceDetails() {
- super();
- this.browser = null;
- }
+ public DataSourceDetails() {
+ super();
+ this.browser = null;
+ }
- public void init(IWorkbench workbench) {
- setPreferenceStore(SkynetGuiPlugin.getInstance().getPreferenceStore());
- setDescription("See below for OSEE Data Source Details.");
- }
+ public void init(IWorkbench workbench) {
+ setPreferenceStore(SkynetGuiPlugin.getInstance().getPreferenceStore());
+ setDescription("See below for OSEE Data Source Details.");
+ }
- @Override
- protected Control createContents(Composite parent) {
- Composite content = new Composite(parent, SWT.NONE);
- GridLayout layout = new GridLayout();
- layout.marginHeight = 0;
- layout.marginWidth = 0;
- content.setLayout(layout);
- content.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+ @Override
+ protected Control createContents(Composite parent) {
+ Composite content = new Composite(parent, SWT.NONE);
+ GridLayout layout = new GridLayout();
+ layout.marginHeight = 0;
+ layout.marginWidth = 0;
+ content.setLayout(layout);
+ content.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
- Group composite = new Group(content, SWT.NONE);
- composite.setLayout(new GridLayout());
- composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
- composite.setText("Data Source(s)");
+ Group composite = new Group(content, SWT.NONE);
+ composite.setLayout(new GridLayout());
+ composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+ composite.setText("Data Source(s)");
- browser = new Browser(composite, SWT.READ_ONLY | SWT.BORDER);
- browser.setLayout(new FillLayout());
- browser.setLayoutData(new GridData(GridData.FILL_BOTH | GridData.GRAB_HORIZONTAL | GridData.GRAB_VERTICAL));
+ browser = new Browser(composite, SWT.READ_ONLY | SWT.BORDER);
+ browser.setLayout(new FillLayout());
+ browser.setLayoutData(new GridData(GridData.FILL_BOTH | GridData.GRAB_HORIZONTAL | GridData.GRAB_VERTICAL));
- Display.getDefault().asyncExec(new Runnable() {
- public void run() {
- generatePage();
- }
- });
- return content;
- }
+ Displays.ensureInDisplayThread(new Runnable() {
+ @Override
+ public void run() {
+ generatePage();
+ }
+ });
+ return content;
+ }
- private void generatePage() {
- StringBuilder builder = new StringBuilder();
- builder.append(getDatabaseSourceInfo());
- builder.append("<br/>");
- builder.append(getDatabaseImportSource());
- browser.setText(String.format(PAGE_TEMPLATE, builder.toString()));
- }
+ private void generatePage() {
+ StringBuilder builder = new StringBuilder();
+ builder.append(getDatabaseSourceInfo());
+ builder.append("<br/>");
+ builder.append(getDatabaseImportSource());
+ browser.setText(String.format(PAGE_TEMPLATE, builder.toString()));
+ }
- private String getDatabaseSourceInfo() {
- StringBuilder builder = new StringBuilder();
- builder.append("<table class=\"oseeTable\" width=\"100%\">");
- builder.append(AHTML.addHeaderRowMultiColumnTable(new String[] {"Data Source"}));
- try {
- builder.append(AHTML.addRowMultiColumnTable(String.format(
- "<b>Name:</b> %s<br/><b>Schema:</b> %s<br/><b>Driver:</b> %s<br/><b>Is Production:</b> %s<br/><b>ID:</b> %s<br/>",
- ClientSessionManager.getDataStoreName(), ClientSessionManager.getDataStoreLoginName(),
- ClientSessionManager.getDataStoreDriver(), ClientSessionManager.isProductionDataStore(),
- OseeInfo.getDatabaseGuid())));
- } catch (Exception ex) {
- builder.append(Lib.exceptionToString(ex));
- } finally {
- builder.append(AHTML.endMultiColumnTable());
- }
- return builder.toString();
- }
+ private String getDatabaseSourceInfo() {
+ StringBuilder builder = new StringBuilder();
+ builder.append("<table class=\"oseeTable\" width=\"100%\">");
+ builder.append(AHTML.addHeaderRowMultiColumnTable(new String[] {"Data Source"}));
+ try {
+ builder.append(AHTML.addRowMultiColumnTable(String.format(
+ "<b>Name:</b> %s<br/><b>Schema:</b> %s<br/><b>Driver:</b> %s<br/><b>Is Production:</b> %s<br/><b>ID:</b> %s<br/>",
+ ClientSessionManager.getDataStoreName(), ClientSessionManager.getDataStoreLoginName(),
+ ClientSessionManager.getDataStoreDriver(), ClientSessionManager.isProductionDataStore(),
+ OseeInfo.getDatabaseGuid())));
+ } catch (Exception ex) {
+ builder.append(Lib.exceptionToString(ex));
+ } finally {
+ builder.append(AHTML.endMultiColumnTable());
+ }
+ return builder.toString();
+ }
- private String getDatabaseImportSource() {
- DateFormat dateFormat = SimpleDateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.MEDIUM);
- StringBuilder builder = new StringBuilder();
- builder.append("<table class=\"oseeTable\" width=\"100%\">");
- builder.append(AHTML.addHeaderRowMultiColumnTable(new String[] {"Source Id", "Exported On", "Imported On"}));
- IOseeStatement chStmt = null;
- try {
- chStmt = ConnectionHandler.getStatement();
- chStmt.runPreparedQuery("select * from osee_import_source");
- while (chStmt.next()) {
- builder.append(AHTML.addRowMultiColumnTable(chStmt.getString("db_source_guid"),
- dateFormat.format(chStmt.getTimestamp("source_export_date")),
- dateFormat.format(chStmt.getTimestamp("date_imported"))));
- }
- } catch (Exception ex) {
- builder.append(AHTML.addRowSpanMultiColumnTable(Lib.exceptionToString(ex), 3));
- } finally {
- builder.append(AHTML.endMultiColumnTable());
- if (chStmt != null) {
- chStmt.close();
- }
- }
- return builder.toString().replaceAll("\n", "<br/>");
- }
+ private String getDatabaseImportSource() {
+ DateFormat dateFormat = SimpleDateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.MEDIUM);
+ StringBuilder builder = new StringBuilder();
+ builder.append("<table class=\"oseeTable\" width=\"100%\">");
+ builder.append(AHTML.addHeaderRowMultiColumnTable(new String[] {"Source Id", "Exported On", "Imported On"}));
+ IOseeStatement chStmt = null;
+ try {
+ chStmt = ConnectionHandler.getStatement();
+ chStmt.runPreparedQuery("select * from osee_import_source");
+ while (chStmt.next()) {
+ builder.append(AHTML.addRowMultiColumnTable(chStmt.getString("db_source_guid"),
+ dateFormat.format(chStmt.getTimestamp("source_export_date")),
+ dateFormat.format(chStmt.getTimestamp("date_imported"))));
+ }
+ } catch (Exception ex) {
+ builder.append(AHTML.addRowSpanMultiColumnTable(Lib.exceptionToString(ex), 3));
+ } finally {
+ builder.append(AHTML.endMultiColumnTable());
+ if (chStmt != null) {
+ chStmt.close();
+ }
+ }
+ return builder.toString().replaceAll("\n", "<br/>");
+ }
}
diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/render/ArtifactGuis.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/render/ArtifactGuis.java index 5fc1150e5f8..b37dac73f3d 100644 --- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/render/ArtifactGuis.java +++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/render/ArtifactGuis.java @@ -24,7 +24,7 @@ import org.eclipse.osee.framework.jdk.core.type.MutableBoolean; import org.eclipse.osee.framework.skynet.core.artifact.Artifact; import org.eclipse.osee.framework.skynet.core.artifact.Attribute; import org.eclipse.osee.framework.skynet.core.artifact.BranchManager; -import org.eclipse.osee.framework.ui.plugin.util.Displays; +import org.eclipse.osee.framework.ui.swt.Displays; import org.eclipse.swt.widgets.Display; public final class ArtifactGuis { diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/render/DefaultArtifactRenderer.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/render/DefaultArtifactRenderer.java index 62f41b23d27..f9ebb1b532a 100644 --- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/render/DefaultArtifactRenderer.java +++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/render/DefaultArtifactRenderer.java @@ -27,7 +27,6 @@ import org.eclipse.osee.framework.skynet.core.linking.OseeLinkBuilder; import org.eclipse.osee.framework.skynet.core.relation.RelationManager;
import org.eclipse.osee.framework.skynet.core.relation.order.RelationOrderData;
import org.eclipse.osee.framework.ui.plugin.util.AWorkbench; -import org.eclipse.osee.framework.ui.plugin.util.Displays; import org.eclipse.osee.framework.ui.skynet.ArtifactImageManager;
import org.eclipse.osee.framework.ui.skynet.SkynetGuiPlugin;
import org.eclipse.osee.framework.ui.skynet.artifact.editor.ArtifactEditor;
@@ -38,6 +37,7 @@ import org.eclipse.osee.framework.ui.skynet.render.compare.IComparator; import org.eclipse.osee.framework.ui.skynet.render.word.AttributeElement;
import org.eclipse.osee.framework.ui.skynet.render.word.Producer;
import org.eclipse.osee.framework.ui.skynet.render.word.WordMLProducer;
+import org.eclipse.osee.framework.ui.swt.Displays;
import org.eclipse.swt.graphics.Image;
/**
diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/render/WordTemplateRenderer.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/render/WordTemplateRenderer.java index 31952ce3d35..58278f11d3f 100644 --- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/render/WordTemplateRenderer.java +++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/render/WordTemplateRenderer.java @@ -32,7 +32,6 @@ import org.eclipse.osee.framework.skynet.core.linking.LinkType; import org.eclipse.osee.framework.skynet.core.linking.OseeLinkBuilder;
import org.eclipse.osee.framework.skynet.core.linking.WordMlLinkHandler;
import org.eclipse.osee.framework.skynet.core.word.WordUtil;
-import org.eclipse.osee.framework.ui.plugin.util.Displays;
import org.eclipse.osee.framework.ui.skynet.blam.VariableMap;
import org.eclipse.osee.framework.ui.skynet.render.compare.IComparator;
import org.eclipse.osee.framework.ui.skynet.render.compare.WordTemplateCompare;
@@ -42,6 +41,7 @@ import org.eclipse.osee.framework.ui.skynet.render.word.WordMLProducer; import org.eclipse.osee.framework.ui.skynet.render.word.WordTemplateProcessor;
import org.eclipse.osee.framework.ui.skynet.templates.TemplateManager;
import org.eclipse.osee.framework.ui.skynet.util.WordUiUtil;
+import org.eclipse.osee.framework.ui.swt.Displays;
import org.w3c.dom.Element;
/**
diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/render/word/WordTemplateProcessor.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/render/word/WordTemplateProcessor.java index fe6137a97dd..51bf89dc181 100644 --- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/render/word/WordTemplateProcessor.java +++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/render/word/WordTemplateProcessor.java @@ -47,7 +47,6 @@ import org.eclipse.osee.framework.skynet.core.attribute.AttributeTypeManager; import org.eclipse.osee.framework.skynet.core.linking.LinkType;
import org.eclipse.osee.framework.skynet.core.transaction.SkynetTransaction;
import org.eclipse.osee.framework.skynet.core.word.WordUtil;
-import org.eclipse.osee.framework.ui.plugin.util.Displays;
import org.eclipse.osee.framework.ui.skynet.blam.VariableMap;
import org.eclipse.osee.framework.ui.skynet.render.IRenderer;
import org.eclipse.osee.framework.ui.skynet.render.ITemplateRenderer;
@@ -56,6 +55,7 @@ import org.eclipse.osee.framework.ui.skynet.render.RendererManager; import org.eclipse.osee.framework.ui.skynet.render.RenderingUtil;
import org.eclipse.osee.framework.ui.skynet.render.WordTemplateRenderer;
import org.eclipse.osee.framework.ui.skynet.util.WordUiUtil;
+import org.eclipse.osee.framework.ui.swt.Displays;
/**
* @author Robert A. Fisher
diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/results/ResultsEditor.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/results/ResultsEditor.java index 47ede737f1a..e1c79be3c60 100644 --- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/results/ResultsEditor.java +++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/results/ResultsEditor.java @@ -22,13 +22,13 @@ import org.eclipse.osee.framework.logging.OseeLog; import org.eclipse.osee.framework.plugin.core.IActionable; import org.eclipse.osee.framework.ui.plugin.OseeUiActions; import org.eclipse.osee.framework.ui.plugin.util.AWorkbench; -import org.eclipse.osee.framework.ui.plugin.util.Displays; import org.eclipse.osee.framework.ui.skynet.OseeContributionItem; import org.eclipse.osee.framework.ui.skynet.SkynetGuiPlugin; import org.eclipse.osee.framework.ui.skynet.artifact.editor.AbstractArtifactEditor; import org.eclipse.osee.framework.ui.skynet.results.html.ResultsEditorHtmlTab; import org.eclipse.osee.framework.ui.skynet.results.html.XResultPage; import org.eclipse.osee.framework.ui.swt.ALayout; +import org.eclipse.osee.framework.ui.swt.Displays; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.ToolBar; import org.eclipse.ui.IEditorInput; diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/results/XResultData.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/results/XResultData.java index 54564939b5b..404bb3b4ab1 100644 --- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/results/XResultData.java +++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/results/XResultData.java @@ -27,12 +27,12 @@ import org.eclipse.osee.framework.logging.SevereLoggingMonitor; import org.eclipse.osee.framework.skynet.core.UserManager;
import org.eclipse.osee.framework.skynet.core.artifact.Artifact;
import org.eclipse.osee.framework.skynet.core.artifact.BranchManager;
-import org.eclipse.osee.framework.ui.plugin.util.Displays;
import org.eclipse.osee.framework.ui.skynet.SkynetGuiPlugin;
import org.eclipse.osee.framework.ui.skynet.results.html.XResultBrowserHyperCmd;
import org.eclipse.osee.framework.ui.skynet.results.html.XResultPage;
import org.eclipse.osee.framework.ui.skynet.results.html.XResultPage.Manipulations;
import org.eclipse.osee.framework.ui.skynet.widgets.XDate;
+import org.eclipse.osee.framework.ui.swt.Displays;
/**
* Used to log Info, Warning and Errors to multiple locations (logger, stderr/out and XResultView). Upon completion, a
diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/search/MaxMatchCountConfirmer.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/search/MaxMatchCountConfirmer.java index 648c91fe14c..9bc5add5763 100644 --- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/search/MaxMatchCountConfirmer.java +++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/search/MaxMatchCountConfirmer.java @@ -13,7 +13,7 @@ package org.eclipse.osee.framework.ui.skynet.search; import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.osee.framework.jdk.core.type.MutableBoolean;
import org.eclipse.osee.framework.skynet.core.artifact.ISearchConfirmer;
-import org.eclipse.osee.framework.ui.plugin.util.Displays;
+import org.eclipse.osee.framework.ui.swt.Displays;
import org.eclipse.swt.widgets.Display;
/**
diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/search/page/ArtifactSearchPage.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/search/page/ArtifactSearchPage.java index e3797953ae2..bdd7ec125bb 100644 --- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/search/page/ArtifactSearchPage.java +++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/search/page/ArtifactSearchPage.java @@ -51,7 +51,6 @@ import org.eclipse.osee.framework.skynet.core.event2.artifact.EventModType; import org.eclipse.osee.framework.skynet.core.event2.artifact.IArtifactEventListener;
import org.eclipse.osee.framework.skynet.core.event2.filter.IEventFilter;
import org.eclipse.osee.framework.skynet.core.utility.LoadedArtifacts;
-import org.eclipse.osee.framework.ui.plugin.util.Displays;
import org.eclipse.osee.framework.ui.skynet.ArtifactDecorator;
import org.eclipse.osee.framework.ui.skynet.ArtifactDoubleClick;
import org.eclipse.osee.framework.ui.skynet.OseeContributionItem;
@@ -59,6 +58,7 @@ import org.eclipse.osee.framework.ui.skynet.SkynetGuiPlugin; import org.eclipse.osee.framework.ui.skynet.listener.IRebuildMenuListener;
import org.eclipse.osee.framework.ui.skynet.search.AbstractArtifactSearchResult;
import org.eclipse.osee.framework.ui.skynet.util.SkynetDragAndDrop;
+import org.eclipse.osee.framework.ui.swt.Displays;
import org.eclipse.search.ui.IContextMenuConstants;
import org.eclipse.search.ui.ISearchResultViewPart;
import org.eclipse.search.ui.text.Match;
diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/search/page/DecoratingArtifactSearchLabelProvider.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/search/page/DecoratingArtifactSearchLabelProvider.java index 571bf79042c..248e4493ea7 100644 --- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/search/page/DecoratingArtifactSearchLabelProvider.java +++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/search/page/DecoratingArtifactSearchLabelProvider.java @@ -19,10 +19,10 @@ import org.eclipse.jface.viewers.DecoratingStyledCellLabelProvider; import org.eclipse.jface.viewers.ILabelProvider;
import org.eclipse.jface.viewers.StyledString;
import org.eclipse.jface.viewers.StyledString.Styler;
-import org.eclipse.jface.viewers.ViewerColumn; +import org.eclipse.jface.viewers.ViewerColumn;
+import org.eclipse.osee.framework.ui.swt.Displays;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.StyleRange;
-import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.IWorkbenchPreferenceConstants;
import org.eclipse.ui.PlatformUI;
@@ -31,70 +31,76 @@ import org.eclipse.ui.PlatformUI; */
public class DecoratingArtifactSearchLabelProvider extends DecoratingStyledCellLabelProvider implements IPropertyChangeListener, ILabelProvider {
- private static final String HIGHLIGHT_BG_COLOR_NAME = "org.eclipse.jdt.ui.ColoredLabels.match_highlight"; //$NON-NLS-1$
-
- public static final Styler HIGHLIGHT_STYLE = StyledString.createColorRegistryStyler(null, HIGHLIGHT_BG_COLOR_NAME);
-
- public DecoratingArtifactSearchLabelProvider(ArtifactSearchLabelProvider provider) {
- super(provider, PlatformUI.getWorkbench().getDecoratorManager().getLabelDecorator(), null);
- }
-
- public void initialize(ColumnViewer viewer, ViewerColumn column) {
- PlatformUI.getPreferenceStore().addPropertyChangeListener(this);
- JFaceResources.getColorRegistry().addListener(this);
-
- setOwnerDrawEnabled(showColoredLabels());
-
- super.initialize(viewer, column);
- }
-
- public void dispose() {
- super.dispose();
- PlatformUI.getPreferenceStore().removePropertyChangeListener(this);
- JFaceResources.getColorRegistry().removeListener(this);
- }
-
- private void refresh() {
- ColumnViewer viewer = getViewer();
-
- if (viewer == null) {
- return;
- }
- boolean showColoredLabels = showColoredLabels();
- if (showColoredLabels != isOwnerDrawEnabled()) {
- setOwnerDrawEnabled(showColoredLabels);
- viewer.refresh();
- } else if (showColoredLabels) {
- viewer.refresh();
- }
- }
-
- protected StyleRange prepareStyleRange(StyleRange styleRange, boolean applyColors) {
- if (!applyColors && styleRange.background != null) {
- styleRange = super.prepareStyleRange(styleRange, applyColors);
- styleRange.borderStyle = SWT.BORDER_DOT;
- return styleRange;
- }
- return super.prepareStyleRange(styleRange, applyColors);
- }
-
- public static boolean showColoredLabels() {
- return PlatformUI.getPreferenceStore().getBoolean(IWorkbenchPreferenceConstants.USE_COLORED_LABELS);
- }
-
- public void propertyChange(PropertyChangeEvent event) {
- String property = event.getProperty();
- if (property.equals(JFacePreferences.QUALIFIER_COLOR) || property.equals(JFacePreferences.COUNTER_COLOR) || property.equals(JFacePreferences.DECORATIONS_COLOR) || property.equals(HIGHLIGHT_BG_COLOR_NAME) || property.equals(IWorkbenchPreferenceConstants.USE_COLORED_LABELS)) {
- Display.getDefault().asyncExec(new Runnable() {
- public void run() {
- refresh();
- }
- });
- }
- }
-
- public String getText(Object element) {
- return getStyledText(element).getString();
- }
+ private static final String HIGHLIGHT_BG_COLOR_NAME = "org.eclipse.jdt.ui.ColoredLabels.match_highlight"; //$NON-NLS-1$
+
+ public static final Styler HIGHLIGHT_STYLE = StyledString.createColorRegistryStyler(null, HIGHLIGHT_BG_COLOR_NAME);
+
+ public DecoratingArtifactSearchLabelProvider(ArtifactSearchLabelProvider provider) {
+ super(provider, PlatformUI.getWorkbench().getDecoratorManager().getLabelDecorator(), null);
+ }
+
+ @Override
+ public void initialize(ColumnViewer viewer, ViewerColumn column) {
+ PlatformUI.getPreferenceStore().addPropertyChangeListener(this);
+ JFaceResources.getColorRegistry().addListener(this);
+
+ setOwnerDrawEnabled(showColoredLabels());
+
+ super.initialize(viewer, column);
+ }
+
+ @Override
+ public void dispose() {
+ super.dispose();
+ PlatformUI.getPreferenceStore().removePropertyChangeListener(this);
+ JFaceResources.getColorRegistry().removeListener(this);
+ }
+
+ private void refresh() {
+ ColumnViewer viewer = getViewer();
+
+ if (viewer == null) {
+ return;
+ }
+ boolean showColoredLabels = showColoredLabels();
+ if (showColoredLabels != isOwnerDrawEnabled()) {
+ setOwnerDrawEnabled(showColoredLabels);
+ viewer.refresh();
+ } else if (showColoredLabels) {
+ viewer.refresh();
+ }
+ }
+
+ @Override
+ protected StyleRange prepareStyleRange(StyleRange styleRange, boolean applyColors) {
+ if (!applyColors && styleRange.background != null) {
+ styleRange = super.prepareStyleRange(styleRange, applyColors);
+ styleRange.borderStyle = SWT.BORDER_DOT;
+ return styleRange;
+ }
+ return super.prepareStyleRange(styleRange, applyColors);
+ }
+
+ public static boolean showColoredLabels() {
+ return PlatformUI.getPreferenceStore().getBoolean(IWorkbenchPreferenceConstants.USE_COLORED_LABELS);
+ }
+
+ @Override
+ public void propertyChange(PropertyChangeEvent event) {
+ String property = event.getProperty();
+ if (property.equals(JFacePreferences.QUALIFIER_COLOR) || property.equals(JFacePreferences.COUNTER_COLOR) || property.equals(JFacePreferences.DECORATIONS_COLOR) || property.equals(HIGHLIGHT_BG_COLOR_NAME) || property.equals(IWorkbenchPreferenceConstants.USE_COLORED_LABELS)) {
+ Displays.ensureInDisplayThread(new Runnable() {
+ @Override
+ public void run() {
+ refresh();
+ }
+ });
+ }
+ }
+
+ @Override
+ public String getText(Object element) {
+ return getStyledText(element).getString();
+ }
}
\ No newline at end of file diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/util/SkynetViews.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/util/SkynetViews.java index ff23104868b..b5b6739aba7 100644 --- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/util/SkynetViews.java +++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/util/SkynetViews.java @@ -16,7 +16,7 @@ import org.eclipse.osee.framework.database.core.OseeInfo; import org.eclipse.osee.framework.jdk.core.util.Strings;
import org.eclipse.osee.framework.logging.OseeLog;
import org.eclipse.osee.framework.ui.skynet.SkynetGuiPlugin;
-import org.eclipse.swt.widgets.Display;
+import org.eclipse.osee.framework.ui.swt.Displays;
import org.eclipse.ui.IMemento;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchPage;
@@ -28,53 +28,54 @@ import org.eclipse.ui.PlatformUI; */
public class SkynetViews {
- private static final String MEMENTO_SOURCE_GUID = "sourceDbGuid";
+ private static final String MEMENTO_SOURCE_GUID = "sourceDbGuid";
- public static boolean isSourceValid(IMemento memento) {
- boolean result = false;
- if (memento != null) {
- String dbId = memento.getString(MEMENTO_SOURCE_GUID);
- if (Strings.isValid(dbId)) {
- String currentDbId = null;
- try {
- currentDbId = OseeInfo.getDatabaseGuid();
- } catch (OseeDataStoreException ex) {
- OseeLog.log(SkynetGuiPlugin.class, Level.WARNING, "Unable to set memento source db guid");
- }
- if (dbId.equals(currentDbId)) {
- result = true;
- }
- }
- }
- return result;
- }
+ public static boolean isSourceValid(IMemento memento) {
+ boolean result = false;
+ if (memento != null) {
+ String dbId = memento.getString(MEMENTO_SOURCE_GUID);
+ if (Strings.isValid(dbId)) {
+ String currentDbId = null;
+ try {
+ currentDbId = OseeInfo.getDatabaseGuid();
+ } catch (OseeDataStoreException ex) {
+ OseeLog.log(SkynetGuiPlugin.class, Level.WARNING, "Unable to set memento source db guid");
+ }
+ if (dbId.equals(currentDbId)) {
+ result = true;
+ }
+ }
+ }
+ return result;
+ }
- public static void addDatabaseSourceId(IMemento memento) {
- if (memento != null) {
- try {
- memento.putString(MEMENTO_SOURCE_GUID, OseeInfo.getDatabaseGuid());
- } catch (OseeDataStoreException ex) {
- OseeLog.log(SkynetGuiPlugin.class, Level.WARNING, "Unable to set memento source db guid");
- }
- }
- }
+ public static void addDatabaseSourceId(IMemento memento) {
+ if (memento != null) {
+ try {
+ memento.putString(MEMENTO_SOURCE_GUID, OseeInfo.getDatabaseGuid());
+ } catch (OseeDataStoreException ex) {
+ OseeLog.log(SkynetGuiPlugin.class, Level.WARNING, "Unable to set memento source db guid");
+ }
+ }
+ }
- public static void closeView(final String viewId, final String secondaryId) {
- if (Strings.isValid(viewId)) {
- Display.getDefault().asyncExec(new Runnable() {
- public void run() {
- IWorkbench workbench = PlatformUI.getWorkbench();
- if (workbench != null) {
- IWorkbenchWindow workbenchWindow = workbench.getActiveWorkbenchWindow();
- if (workbenchWindow != null) {
- IWorkbenchPage workbenchPage = workbenchWindow.getActivePage();
- if (workbenchPage != null) {
- workbenchPage.hideView(workbenchPage.findViewReference(viewId, secondaryId));
- }
- }
- }
- }
- });
- }
- }
+ public static void closeView(final String viewId, final String secondaryId) {
+ if (Strings.isValid(viewId)) {
+ Displays.ensureInDisplayThread(new Runnable() {
+ @Override
+ public void run() {
+ IWorkbench workbench = PlatformUI.getWorkbench();
+ if (workbench != null) {
+ IWorkbenchWindow workbenchWindow = workbench.getActiveWorkbenchWindow();
+ if (workbenchWindow != null) {
+ IWorkbenchPage workbenchPage = workbenchWindow.getActivePage();
+ if (workbenchPage != null) {
+ workbenchPage.hideView(workbenchPage.findViewReference(viewId, secondaryId));
+ }
+ }
+ }
+ }
+ });
+ }
+ }
}
\ No newline at end of file diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/util/WordUiUtil.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/util/WordUiUtil.java index 09f1a89e7ec..12f1541cd79 100644 --- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/util/WordUiUtil.java +++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/util/WordUiUtil.java @@ -17,9 +17,9 @@ import org.eclipse.osee.framework.jdk.core.util.AHTML; import org.eclipse.osee.framework.logging.OseeLevel;
import org.eclipse.osee.framework.logging.OseeLog;
import org.eclipse.osee.framework.skynet.core.artifact.Artifact;
-import org.eclipse.osee.framework.ui.plugin.util.Displays;
import org.eclipse.osee.framework.ui.skynet.SkynetGuiPlugin;
import org.eclipse.osee.framework.ui.skynet.results.XResultData;
+import org.eclipse.osee.framework.ui.swt.Displays;
import org.eclipse.swt.widgets.Display;
/**
diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/XFlatDam.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/XFlatDam.java index e3c2ddfd33f..d93e71db3bf 100644 --- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/XFlatDam.java +++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/XFlatDam.java @@ -36,249 +36,249 @@ import org.eclipse.osee.framework.skynet.core.attribute.FloatingPointAttribute; import org.eclipse.osee.framework.skynet.core.attribute.IntegerAttribute;
import org.eclipse.osee.framework.ui.plugin.util.Result;
import org.eclipse.osee.framework.ui.skynet.SkynetGuiPlugin;
+import org.eclipse.osee.framework.ui.swt.Displays;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.progress.UIJob;
public class XFlatDam extends XFlatWidget<String> implements IArtifactWidget {
- private Artifact artifact;
- private String attributeTypeName;
- private final Map<String, XWidget> xWidgets;
- private final XModifiedListener xModifiedListener;
+ private Artifact artifact;
+ private String attributeTypeName;
+ private final Map<String, XWidget> xWidgets;
+ private final XModifiedListener xModifiedListener;
- public XFlatDam(String displayLabel) {
- super(displayLabel);
- this.xWidgets = new LinkedHashMap<String, XWidget>();
- this.artifact = null;
- this.xModifiedListener = new XModifiedListener() {
- public void widgetModified(XWidget widget) {
- notifyXModifiedListeners();
- };
- };
- }
+ public XFlatDam(String displayLabel) {
+ super(displayLabel);
+ this.xWidgets = new LinkedHashMap<String, XWidget>();
+ this.artifact = null;
+ this.xModifiedListener = new XModifiedListener() {
+ public void widgetModified(XWidget widget) {
+ notifyXModifiedListeners();
+ };
+ };
+ }
- public void setArtifact(Artifact artifact, String attributeTypeName) throws OseeCoreException {
- this.artifact = artifact;
- this.attributeTypeName = attributeTypeName;
- AttributeType attributeType = AttributeTypeManager.getType(attributeTypeName);
+ public void setArtifact(Artifact artifact, String attributeTypeName) throws OseeCoreException {
+ this.artifact = artifact;
+ this.attributeTypeName = attributeTypeName;
+ AttributeType attributeType = AttributeTypeManager.getType(attributeTypeName);
- int minOccurrence = attributeType.getMinOccurrences();
- int maxOccurrence = attributeType.getMaxOccurrences();
+ int minOccurrence = attributeType.getMinOccurrences();
+ int maxOccurrence = attributeType.getMaxOccurrences();
- if (minOccurrence == 0) {
- minOccurrence = 1;
- }
- setPageRange(minOccurrence, maxOccurrence);
- }
+ if (minOccurrence == 0) {
+ minOccurrence = 1;
+ }
+ setPageRange(minOccurrence, maxOccurrence);
+ }
- @Override
- protected void createControls(Composite parent, int horizontalSpan) {
- super.createControls(parent, horizontalSpan);
- final Collection<String> values = new ArrayList<String>();
- try {
- values.addAll(getStored());
- for (int index = 0; index < values.size(); index++) {
- addPage("");
- }
- } catch (Exception ex) {
- OseeLog.log(SkynetGuiPlugin.class, OseeLevel.SEVERE_POPUP, ex);
- }
- Job job = new UIJob("Update Flat XText") {
+ @Override
+ protected void createControls(Composite parent, int horizontalSpan) {
+ super.createControls(parent, horizontalSpan);
+ final Collection<String> values = new ArrayList<String>();
+ try {
+ values.addAll(getStored());
+ for (int index = 0; index < values.size(); index++) {
+ addPage("");
+ }
+ } catch (Exception ex) {
+ OseeLog.log(SkynetGuiPlugin.class, OseeLevel.SEVERE_POPUP, ex);
+ }
+ Job job = new UIJob("Update Flat XText") {
- @Override
- public IStatus runInUIThread(IProgressMonitor monitor) {
- setNotificationsAllowed(false);
- Iterator<String> dataIterator = values.iterator();
- Iterator<XWidget> widgetIterator = xWidgets.values().iterator();
- while (dataIterator.hasNext() && widgetIterator.hasNext()) {
- XWidget widget = widgetIterator.next();
- if (widget instanceof XText) {
- ((XText) widget).set(dataIterator.next());
- } else if (widget instanceof XDate) {
- ((XDate) widget).setDate(toDate(dataIterator.next()));
- }
- }
- values.clear();
- setNotificationsAllowed(true);
- return Status.OK_STATUS;
- }
- };
- Jobs.startJob(job);
- }
+ @Override
+ public IStatus runInUIThread(IProgressMonitor monitor) {
+ setNotificationsAllowed(false);
+ Iterator<String> dataIterator = values.iterator();
+ Iterator<XWidget> widgetIterator = xWidgets.values().iterator();
+ while (dataIterator.hasNext() && widgetIterator.hasNext()) {
+ XWidget widget = widgetIterator.next();
+ if (widget instanceof XText) {
+ ((XText) widget).set(dataIterator.next());
+ } else if (widget instanceof XDate) {
+ ((XDate) widget).setDate(toDate(dataIterator.next()));
+ }
+ }
+ values.clear();
+ setNotificationsAllowed(true);
+ return Status.OK_STATUS;
+ }
+ };
+ Jobs.startJob(job);
+ }
- public List<String> getInput() {
- List<String> data = new ArrayList<String>();
- for (XWidget widget : xWidgets.values()) {
- if (widget instanceof XText) {
- data.add(((XText) widget).get());
- } else if (widget instanceof XDate) {
- Date date = ((XDate) widget).getDate();
- if (date != null) {
- data.add(String.valueOf(date.getTime()));
- }
- }
- }
- return data;
- }
+ public List<String> getInput() {
+ List<String> data = new ArrayList<String>();
+ for (XWidget widget : xWidgets.values()) {
+ if (widget instanceof XText) {
+ data.add(((XText) widget).get());
+ } else if (widget instanceof XDate) {
+ Date date = ((XDate) widget).getDate();
+ if (date != null) {
+ data.add(String.valueOf(date.getTime()));
+ }
+ }
+ }
+ return data;
+ }
- public Collection<String> getStored() throws OseeCoreException {
- return artifact.getAttributesToStringList(attributeTypeName);
- }
+ public Collection<String> getStored() throws OseeCoreException {
+ return artifact.getAttributesToStringList(attributeTypeName);
+ }
- @Override
- public Result isDirty() throws OseeCoreException {
- try {
- Collection<String> enteredValues = new ArrayList<String>();//getSelected();
- Collection<String> storedValues = getStored();
- if (!Collections.isEqual(enteredValues, storedValues)) {
- return new Result(true, attributeTypeName + " is dirty");
- }
- } catch (NumberFormatException ex) {
- // do nothing
- }
- return Result.FalseResult;
- }
+ @Override
+ public Result isDirty() throws OseeCoreException {
+ try {
+ Collection<String> enteredValues = new ArrayList<String>();//getSelected();
+ Collection<String> storedValues = getStored();
+ if (!Collections.isEqual(enteredValues, storedValues)) {
+ return new Result(true, attributeTypeName + " is dirty");
+ }
+ } catch (NumberFormatException ex) {
+ // do nothing
+ }
+ return Result.FalseResult;
+ }
- @Override
- public void revert() throws OseeCoreException {
- setArtifact(artifact, attributeTypeName);
- }
+ @Override
+ public void revert() throws OseeCoreException {
+ setArtifact(artifact, attributeTypeName);
+ }
- @Override
- public void saveToArtifact() throws OseeCoreException {
- artifact.setAttributeValues(attributeTypeName, getInput());
- }
+ @Override
+ public void saveToArtifact() throws OseeCoreException {
+ artifact.setAttributeValues(attributeTypeName, getInput());
+ }
- @Override
- protected void createPage(final String id, Composite parent, String initialInput) {
- if (!xWidgets.containsKey(id)) {
- try {
- XWidget xWidget = getWidget(attributeTypeName, parent, initialInput);
- xWidget.setEditable(isEditable());
- xWidgets.put(id, xWidget);
+ @Override
+ protected void createPage(final String id, Composite parent, String initialInput) {
+ if (!xWidgets.containsKey(id)) {
+ try {
+ XWidget xWidget = getWidget(attributeTypeName, parent, initialInput);
+ xWidget.setEditable(isEditable());
+ xWidgets.put(id, xWidget);
- xWidget.addXModifiedListener(xModifiedListener);
- parent.layout();
- } catch (OseeCoreException ex) {
- OseeLog.log(SkynetGuiPlugin.class, OseeLevel.SEVERE_POPUP, ex);
- }
- }
- }
+ xWidget.addXModifiedListener(xModifiedListener);
+ parent.layout();
+ } catch (OseeCoreException ex) {
+ OseeLog.log(SkynetGuiPlugin.class, OseeLevel.SEVERE_POPUP, ex);
+ }
+ }
+ }
- @Override
- protected void onRemovePage(String id) {
- xWidgets.remove(id);
- }
+ @Override
+ protected void onRemovePage(String id) {
+ xWidgets.remove(id);
+ }
- @Override
- public IStatus isValid() {
- for (XWidget widget : xWidgets.values()) {
- IStatus status = widget.isValid();
- if (!status.isOK()) {
- return status;
- }
- }
- return Status.OK_STATUS;
- }
+ @Override
+ public IStatus isValid() {
+ for (XWidget widget : xWidgets.values()) {
+ IStatus status = widget.isValid();
+ if (!status.isOK()) {
+ return status;
+ }
+ }
+ return Status.OK_STATUS;
+ }
- @Override
- public void validate() {
- for (String id : getPageIds()) {
- if (Strings.isValid(id)) {
- XWidget widget = xWidgets.get(id);
- widget.validate();
- }
- }
- }
+ @Override
+ public void validate() {
+ for (String id : getPageIds()) {
+ if (Strings.isValid(id)) {
+ XWidget widget = xWidgets.get(id);
+ widget.validate();
+ }
+ }
+ }
- private Date toDate(String value) {
- try {
- return new Date(Long.parseLong(value));
- } catch (Exception ex) {
- OseeLog.log(SkynetGuiPlugin.class, OseeLevel.SEVERE_POPUP, ex);
- }
- return new Date();
- }
+ private Date toDate(String value) {
+ try {
+ return new Date(Long.parseLong(value));
+ } catch (Exception ex) {
+ OseeLog.log(SkynetGuiPlugin.class, OseeLevel.SEVERE_POPUP, ex);
+ }
+ return new Date();
+ }
- private XWidget getWidget(String attributeType, Composite parent, String initialInput) throws OseeCoreException {
- XWidget xWidget = null;
+ private XWidget getWidget(String attributeType, Composite parent, String initialInput) throws OseeCoreException {
+ XWidget xWidget = null;
- if (AttributeTypeManager.isBaseTypeCompatible(IntegerAttribute.class, attributeType)) {
- XInteger xInteger = new XInteger("");
- xInteger.setFillHorizontally(true);
- xInteger.createWidgets(getManagedForm(), parent, 2);
- if (Strings.isValid(initialInput)) {
- xInteger.setText(initialInput);
- }
- xWidget = xInteger;
- } else if (AttributeTypeManager.isBaseTypeCompatible(DateAttribute.class, attributeType)) {
- XDate xDate = new XDate("");
- xDate.setFillHorizontally(true);
- xDate.createWidgets(getManagedForm(), parent, 2);
- if (Strings.isValid(initialInput)) {
- xDate.setDate(toDate(initialInput));
- }
- xWidget = xDate;
- } else if (AttributeTypeManager.isBaseTypeCompatible(FloatingPointAttribute.class, attributeType)) {
- XFloat xFloat = new XFloat("");
- xFloat.setFillHorizontally(true);
- xFloat.createWidgets(getManagedForm(), parent, 2);
- if (Strings.isValid(initialInput)) {
- xFloat.setText(initialInput);
- }
- xWidget = xFloat;
- } else if (AttributeTypeManager.isBaseTypeCompatible(BinaryBackedAttribute.class, attributeType)) {
- XLabel xLabel = new XLabel("");
- xLabel.setFillHorizontally(true);
- xLabel.createWidgets(getManagedForm(), parent, 2);
- if (Strings.isValid(initialInput)) {
- xLabel.setLabel(initialInput);
- }
- xWidget = xLabel;
- }
+ if (AttributeTypeManager.isBaseTypeCompatible(IntegerAttribute.class, attributeType)) {
+ XInteger xInteger = new XInteger("");
+ xInteger.setFillHorizontally(true);
+ xInteger.createWidgets(getManagedForm(), parent, 2);
+ if (Strings.isValid(initialInput)) {
+ xInteger.setText(initialInput);
+ }
+ xWidget = xInteger;
+ } else if (AttributeTypeManager.isBaseTypeCompatible(DateAttribute.class, attributeType)) {
+ XDate xDate = new XDate("");
+ xDate.setFillHorizontally(true);
+ xDate.createWidgets(getManagedForm(), parent, 2);
+ if (Strings.isValid(initialInput)) {
+ xDate.setDate(toDate(initialInput));
+ }
+ xWidget = xDate;
+ } else if (AttributeTypeManager.isBaseTypeCompatible(FloatingPointAttribute.class, attributeType)) {
+ XFloat xFloat = new XFloat("");
+ xFloat.setFillHorizontally(true);
+ xFloat.createWidgets(getManagedForm(), parent, 2);
+ if (Strings.isValid(initialInput)) {
+ xFloat.setText(initialInput);
+ }
+ xWidget = xFloat;
+ } else if (AttributeTypeManager.isBaseTypeCompatible(BinaryBackedAttribute.class, attributeType)) {
+ XLabel xLabel = new XLabel("");
+ xLabel.setFillHorizontally(true);
+ xLabel.createWidgets(getManagedForm(), parent, 2);
+ if (Strings.isValid(initialInput)) {
+ xLabel.setLabel(initialInput);
+ }
+ xWidget = xLabel;
+ }
- if (xWidget == null) {
- XText xTextWidget = new XTextInternalWidget("");
- if (Strings.isValid(initialInput)) {
- xTextWidget.setText(initialInput);
- }
- xTextWidget.addXTextSpellModifyDictionary(new SkynetSpellModifyDictionary());
- xTextWidget.setFillHorizontally(false);
- xTextWidget.setFillVertically(false);
- xTextWidget.createWidgets(getManagedForm(), parent, 2);
- xWidget = xTextWidget;
- }
- return xWidget;
- }
+ if (xWidget == null) {
+ XText xTextWidget = new XTextInternalWidget("");
+ if (Strings.isValid(initialInput)) {
+ xTextWidget.setText(initialInput);
+ }
+ xTextWidget.addXTextSpellModifyDictionary(new SkynetSpellModifyDictionary());
+ xTextWidget.setFillHorizontally(false);
+ xTextWidget.setFillVertically(false);
+ xTextWidget.createWidgets(getManagedForm(), parent, 2);
+ xWidget = xTextWidget;
+ }
+ return xWidget;
+ }
- private final class XTextInternalWidget extends XText {
+ private final class XTextInternalWidget extends XText {
- public XTextInternalWidget(String label) {
- super(label);
- }
+ public XTextInternalWidget(String label) {
+ super(label);
+ }
- @Override
- protected int getTextStyle() {
- int styleBase = SWT.NONE;
- if (isEditable()) {
- styleBase |= SWT.READ_ONLY;
- }
- return styleBase | (fillVertically ? SWT.WRAP | SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL : SWT.SINGLE);
- }
+ @Override
+ protected int getTextStyle() {
+ int styleBase = SWT.NONE;
+ if (isEditable()) {
+ styleBase |= SWT.READ_ONLY;
+ }
+ return styleBase | (fillVertically ? SWT.WRAP | SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL : SWT.SINGLE);
+ }
- @Override
- public void createControls(Composite parent, int horizontalSpan, boolean fillText) {
- super.createControls(parent, horizontalSpan, fillText);
- GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true);
- gd.widthHint = 200;
- sText.setLayoutData(gd);
- sText.setWordWrap(true);
- sText.setEditable(isEditable());
- if (!isEditable()) {
- sText.setBackground(Display.getDefault().getSystemColor(SWT.COLOR_WIDGET_LIGHT_SHADOW));
- }
- }
- }
+ @Override
+ public void createControls(Composite parent, int horizontalSpan, boolean fillText) {
+ super.createControls(parent, horizontalSpan, fillText);
+ GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true);
+ gd.widthHint = 200;
+ sText.setLayoutData(gd);
+ sText.setWordWrap(true);
+ sText.setEditable(isEditable());
+ if (!isEditable()) {
+ sText.setBackground(Displays.getSystemColor(SWT.COLOR_WIDGET_LIGHT_SHADOW));
+ }
+ }
+ }
}
diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/XFlatWidget.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/XFlatWidget.java index 92348975fa6..6cd410d1046 100644 --- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/XFlatWidget.java +++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/XFlatWidget.java @@ -29,6 +29,7 @@ import org.eclipse.osee.framework.ui.plugin.util.AWorkbench; import org.eclipse.osee.framework.ui.skynet.FrameworkImage;
import org.eclipse.osee.framework.ui.skynet.SkynetGuiPlugin;
import org.eclipse.osee.framework.ui.swt.ALayout;
+import org.eclipse.osee.framework.ui.swt.Displays;
import org.eclipse.osee.framework.ui.swt.ImageManager;
import org.eclipse.osee.framework.ui.swt.Widgets;
import org.eclipse.swt.SWT;
@@ -41,7 +42,6 @@ import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.ToolBar;
import org.eclipse.ui.ISharedImages;
@@ -49,353 +49,355 @@ import org.eclipse.ui.PlatformUI; public abstract class XFlatWidget<T> extends XLabel {
- private FlatControl flatControl;
- private StyledText currentPageLabel;
- private Composite container;
- private Label messageLabel;
- private Label messageIcon;
- private int minPage;
- private int maxPage;
-
- public XFlatWidget(String displayLabel, String xmlRoot) {
- super(displayLabel, xmlRoot);
- setToolTip("Navigate pages by clicking forward and backward buttons.");
- minPage = 0;
- maxPage = 0;
- }
-
- @Override
- public void dispose() {
- flatControl.dispose();
- super.dispose();
- }
-
- public Collection<String> getPageIds() {
- return flatControl.pageIds;
- }
-
- public XFlatWidget(String displayLabel) {
- this(displayLabel, "");
- }
-
- protected void setPageRange(int minPage, int maxPage) throws OseeArgumentException {
- if (minPage < 0) {
- throw new OseeArgumentException("Min Number of Pages must be greater than 0");
- }
- if (maxPage < 1) {
- throw new OseeArgumentException("Max Number of Pages must be at least 1");
- }
-
- if (maxPage < minPage) {
- throw new OseeArgumentException(
- String.format("Invalid required number of pages [%s] < [%s]", maxPage, minPage));
- }
- this.minPage = minPage;
- this.maxPage = maxPage;
- }
-
- @Override
- public Control getControl() {
- return flatControl.flatComposite;
- }
-
- @Override
- public void setToolTip(String toolTip) {
- if (Strings.isValid(toolTip)) {
- super.setToolTip(toolTip);
- }
- }
-
- @Override
- public void refresh() {
- updateCurrentPageLabel();
- flatControl.refresh();
- }
-
- @Override
- protected void createControls(final Composite parent, int horizontalSpan) {
- container = new Composite(parent, SWT.NONE);
- GridLayout layout = new GridLayout(isDisplayLabel() ? 2 : 1, false);
- layout.marginHeight = 0;
- layout.marginWidth = 0;
- layout.marginRight = 0;
- container.setLayout(layout);
- container.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
-
- if (isDisplayLabel() && Strings.isValid(getLabel())) {
- labelWidget = new Label(container, SWT.NONE);
- labelWidget.setText(String.format("%s:", getLabel()));
- labelWidget.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING));
- if (getToolTip() != null) {
- labelWidget.setToolTipText(getToolTip());
- }
- }
-
- Composite composite = new Composite(container, SWT.NONE);
- GridLayout layout1 = new GridLayout(1, false);
- layout1.marginHeight = 0;
- layout1.marginWidth = 0;
- layout1.verticalSpacing = 0;
- layout1.horizontalSpacing = 0;
- composite.setLayout(layout1);
- composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
-
- createToolBar(composite);
- flatControl = new FlatControl();
- flatControl.createControl(composite);
- createMessageArea(composite);
-
- addToolTip(container, getToolTip());
- refresh();
- }
-
- private void createMessageArea(Composite parent) {
- Composite messageArea = new Composite(parent, SWT.BORDER);
- GridLayout layout = new GridLayout(2, false);
- layout.marginHeight = 0;
- layout.marginWidth = 0;
- layout.marginLeft = 5;
- layout.horizontalSpacing = 0;
- layout.verticalSpacing = 0;
- layout.marginBottom = 5;
-
- messageArea.setLayout(layout);
- messageArea.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
- messageArea.setBackground(Display.getDefault().getSystemColor(SWT.COLOR_INFO_BACKGROUND));
-
- messageIcon = new Label(messageArea, SWT.NONE);
- messageIcon.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false));
-
- messageLabel = new Label(messageArea, SWT.NONE);
- messageLabel.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, false));
- }
-
- private void createToolBar(Composite parent) {
- Composite composite = new Composite(parent, SWT.BORDER);
- GridLayout layout = new GridLayout(3, false);
- layout.marginHeight = 0;
- layout.marginLeft = 5;
- layout.marginWidth = 2;
- composite.setLayout(layout);
- composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
-
- currentPageLabel = new StyledText(composite, SWT.READ_ONLY | SWT.SINGLE | SWT.WRAP);
- currentPageLabel.setAlignment(SWT.RIGHT);
- currentPageLabel.setFont(JFaceResources.getBannerFont());
- GridData gd = new GridData(SWT.FILL, SWT.FILL, true, false);
- gd.minimumWidth = 10;
- currentPageLabel.setLayoutData(gd);
- currentPageLabel.setText("0 Items");
-
- Composite filler = new Composite(composite, SWT.NONE);
- GridLayout layout1 = new GridLayout(1, false);
- filler.setLayout(layout1);
- filler.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
-
- ToolBar toolbar = new ToolBar(composite, SWT.FLAT | SWT.HORIZONTAL);
- toolbar.setLayoutData(new GridData(SWT.NONE, SWT.NONE, false, false));
- ToolBarManager manager = new ToolBarManager(toolbar);
- manager.add(new Separator());
- manager.add(new AddPage());
- manager.update(true);
- }
-
- private void addToolTip(Control control, String toolTipText) {
- if (Strings.isValid(toolTipText)) {
- control.setToolTipText(toolTipText);
- if (control instanceof Composite) {
- for (Control child : ((Composite) control).getChildren()) {
- child.setToolTipText(toolTipText);
- }
- }
- }
- }
-
- private void updateCurrentPageLabel() {
- Display.getDefault().asyncExec(new Runnable() {
- public void run() {
- if (Widgets.isAccessible(currentPageLabel)) {
- int totalPages = flatControl.getTotalPages();
- currentPageLabel.setText(String.format("%s Items", totalPages));
- }
- }
- });
- }
-
- public void addPage(T value) {
- flatControl.addPage(value);
- }
-
- private void setMessage(final int severity, final String message) {
- Display.getDefault().asyncExec(new Runnable() {
- public void run() {
- if (Widgets.isAccessible(messageLabel)) {
- Composite parent = messageLabel.getParent();
-
- String text = message;
- boolean isVisible = Strings.isValid(text);
-
- String imageName = null;
- switch (severity) {
- case IStatus.INFO:
- imageName = ISharedImages.IMG_OBJS_INFO_TSK;
- break;
- case IStatus.ERROR:
- imageName = ISharedImages.IMG_OBJS_ERROR_TSK;
- break;
- case IStatus.WARNING:
- imageName = ISharedImages.IMG_OBJS_WARN_TSK;
- break;
- default:
- imageName = null;
- break;
- }
- Image image =
- Strings.isValid(imageName) ? PlatformUI.getWorkbench().getSharedImages().getImage(imageName) : null;
- messageIcon.setImage(image);
- messageLabel.setText(isVisible ? " " + text : text);
-
- messageIcon.setVisible(isVisible);
- messageLabel.setVisible(isVisible);
- parent.setVisible(isVisible);
- parent.layout();
- }
- }
- });
- }
-
- protected abstract void createPage(String id, Composite parent, T value);
-
- protected abstract void onRemovePage(String id);
-
- private final class AddPage extends Action {
- public AddPage() {
- super();
- setImageDescriptor(ImageManager.getImageDescriptor(FrameworkImage.ADD_GREEN));
- setToolTipText("Adds a page");
- }
-
- @Override
- public void run() {
- flatControl.addPage((T) null);
- }
- }
-
- private final class RemovePage extends Action {
- public RemovePage() {
- super();
- setImageDescriptor(ImageManager.getImageDescriptor(FrameworkImage.REMOVE));
- setToolTipText("Removes a page");
- }
-
- @Override
- public void run() {
- AWorkbench.popup("Not implemented yet");
- flatControl.removePage("here");
- }
- }
-
- private final class FlatControl {
- private final List<String> pageIds;
- private Composite flatComposite;
- private final Map<String, Composite> pages = new HashMap<String, Composite>();
-
- public FlatControl() {
- this.pageIds = new ArrayList<String>();
- }
-
- private void createControl(Composite parent) {
- pageIds.clear();
- flatComposite = new Composite(parent, SWT.BORDER);
- flatComposite.setLayout(ALayout.getZeroMarginLayout());
- GridData gd = new GridData(SWT.FILL, SWT.FILL, true, false);
- gd.minimumWidth = 60;
- flatComposite.setLayoutData(gd);
- flatComposite.layout();
- }
-
- public void dispose() {
- pageIds.clear();
- Widgets.disposeWidget(flatComposite);
- }
-
- public void refresh() {
- flatComposite.layout();
- flatComposite.getParent().layout();
- }
-
- private int getTotalPages() {
- return Widgets.isAccessible(flatComposite) ? pages.size() : 0;
- }
-
- private void addPage(T value) {
- int numberOfPages = getTotalPages();
- IStatus status = validate(numberOfPages + 1);
- if (status.isOK()) {
- setMessage(IStatus.OK, "");
- final String pageId = GUID.create();
- if (pageIds.add(pageId)) {
- Composite composite = new Composite(flatComposite, SWT.WRAP | SWT.BORDER);
- composite.setLayout(new GridLayout(3, false));
- composite.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false));
-
- createPage(pageId, composite, value);
-
- Button button = new Button(composite, SWT.FLAT);
- button.setImage(ImageManager.getImage(FrameworkImage.DELETE));
- button.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- removePage(pageId);
- }
- });
-
- pages.put(pageId, composite);
- notifyXModifiedListeners();
- } else {
- setMessage(IStatus.WARNING, "Add page error");
- }
- } else {
- setMessage(IStatus.ERROR, status.getMessage());
- }
- }
-
- private void removePage(String pageId) {
- int numberOfPages = getTotalPages();
- IStatus status = validate(numberOfPages - 1);
- if (status.isOK()) {
- setMessage(IStatus.OK, "");
-
- pageIds.remove(pageId);
- if (pageId != null) {
- onRemovePage(pageId);
- Control control = pages.remove(pageId);
- Widgets.disposeWidget(control);
- notifyXModifiedListeners();
- } else {
- setMessage(IStatus.WARNING, "Remove page error");
- }
- } else {
- setMessage(IStatus.ERROR, status.getMessage());
- }
- }
-
- private IStatus validate(int numberOfPages) {
- IStatus status = null;
- if (minPage <= numberOfPages && maxPage >= numberOfPages) {
- status = Status.OK_STATUS;
- } else {
- List<String> message = new ArrayList<String>();
- if (numberOfPages < minPage) {
- message.add(String.format("Must have at least [%s] page%s", minPage, minPage == 1 ? "" : "s"));
- }
- if (numberOfPages > maxPage) {
- message.add(String.format("Can't add more than [%s] page%s", maxPage, maxPage == 1 ? "" : "s"));
- }
- status = new Status(IStatus.ERROR, SkynetGuiPlugin.PLUGIN_ID, Collections.toString(" &", message));
- }
- return status;
- }
- }
+ private FlatControl flatControl;
+ private StyledText currentPageLabel;
+ private Composite container;
+ private Label messageLabel;
+ private Label messageIcon;
+ private int minPage;
+ private int maxPage;
+
+ public XFlatWidget(String displayLabel, String xmlRoot) {
+ super(displayLabel, xmlRoot);
+ setToolTip("Navigate pages by clicking forward and backward buttons.");
+ minPage = 0;
+ maxPage = 0;
+ }
+
+ @Override
+ public void dispose() {
+ flatControl.dispose();
+ super.dispose();
+ }
+
+ public Collection<String> getPageIds() {
+ return flatControl.pageIds;
+ }
+
+ public XFlatWidget(String displayLabel) {
+ this(displayLabel, "");
+ }
+
+ protected void setPageRange(int minPage, int maxPage) throws OseeArgumentException {
+ if (minPage < 0) {
+ throw new OseeArgumentException("Min Number of Pages must be greater than 0");
+ }
+ if (maxPage < 1) {
+ throw new OseeArgumentException("Max Number of Pages must be at least 1");
+ }
+
+ if (maxPage < minPage) {
+ throw new OseeArgumentException(
+ String.format("Invalid required number of pages [%s] < [%s]", maxPage, minPage));
+ }
+ this.minPage = minPage;
+ this.maxPage = maxPage;
+ }
+
+ @Override
+ public Control getControl() {
+ return flatControl.flatComposite;
+ }
+
+ @Override
+ public void setToolTip(String toolTip) {
+ if (Strings.isValid(toolTip)) {
+ super.setToolTip(toolTip);
+ }
+ }
+
+ @Override
+ public void refresh() {
+ updateCurrentPageLabel();
+ flatControl.refresh();
+ }
+
+ @Override
+ protected void createControls(final Composite parent, int horizontalSpan) {
+ container = new Composite(parent, SWT.NONE);
+ GridLayout layout = new GridLayout(isDisplayLabel() ? 2 : 1, false);
+ layout.marginHeight = 0;
+ layout.marginWidth = 0;
+ layout.marginRight = 0;
+ container.setLayout(layout);
+ container.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
+
+ if (isDisplayLabel() && Strings.isValid(getLabel())) {
+ labelWidget = new Label(container, SWT.NONE);
+ labelWidget.setText(String.format("%s:", getLabel()));
+ labelWidget.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING));
+ if (getToolTip() != null) {
+ labelWidget.setToolTipText(getToolTip());
+ }
+ }
+
+ Composite composite = new Composite(container, SWT.NONE);
+ GridLayout layout1 = new GridLayout(1, false);
+ layout1.marginHeight = 0;
+ layout1.marginWidth = 0;
+ layout1.verticalSpacing = 0;
+ layout1.horizontalSpacing = 0;
+ composite.setLayout(layout1);
+ composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
+
+ createToolBar(composite);
+ flatControl = new FlatControl();
+ flatControl.createControl(composite);
+ createMessageArea(composite);
+
+ addToolTip(container, getToolTip());
+ refresh();
+ }
+
+ private void createMessageArea(Composite parent) {
+ Composite messageArea = new Composite(parent, SWT.BORDER);
+ GridLayout layout = new GridLayout(2, false);
+ layout.marginHeight = 0;
+ layout.marginWidth = 0;
+ layout.marginLeft = 5;
+ layout.horizontalSpacing = 0;
+ layout.verticalSpacing = 0;
+ layout.marginBottom = 5;
+
+ messageArea.setLayout(layout);
+ messageArea.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+ messageArea.setBackground(Displays.getSystemColor(SWT.COLOR_INFO_BACKGROUND));
+
+ messageIcon = new Label(messageArea, SWT.NONE);
+ messageIcon.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false));
+
+ messageLabel = new Label(messageArea, SWT.NONE);
+ messageLabel.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, false));
+ }
+
+ private void createToolBar(Composite parent) {
+ Composite composite = new Composite(parent, SWT.BORDER);
+ GridLayout layout = new GridLayout(3, false);
+ layout.marginHeight = 0;
+ layout.marginLeft = 5;
+ layout.marginWidth = 2;
+ composite.setLayout(layout);
+ composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
+
+ currentPageLabel = new StyledText(composite, SWT.READ_ONLY | SWT.SINGLE | SWT.WRAP);
+ currentPageLabel.setAlignment(SWT.RIGHT);
+ currentPageLabel.setFont(JFaceResources.getBannerFont());
+ GridData gd = new GridData(SWT.FILL, SWT.FILL, true, false);
+ gd.minimumWidth = 10;
+ currentPageLabel.setLayoutData(gd);
+ currentPageLabel.setText("0 Items");
+
+ Composite filler = new Composite(composite, SWT.NONE);
+ GridLayout layout1 = new GridLayout(1, false);
+ filler.setLayout(layout1);
+ filler.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
+
+ ToolBar toolbar = new ToolBar(composite, SWT.FLAT | SWT.HORIZONTAL);
+ toolbar.setLayoutData(new GridData(SWT.NONE, SWT.NONE, false, false));
+ ToolBarManager manager = new ToolBarManager(toolbar);
+ manager.add(new Separator());
+ manager.add(new AddPage());
+ manager.update(true);
+ }
+
+ private void addToolTip(Control control, String toolTipText) {
+ if (Strings.isValid(toolTipText)) {
+ control.setToolTipText(toolTipText);
+ if (control instanceof Composite) {
+ for (Control child : ((Composite) control).getChildren()) {
+ child.setToolTipText(toolTipText);
+ }
+ }
+ }
+ }
+
+ private void updateCurrentPageLabel() {
+ Displays.ensureInDisplayThread(new Runnable() {
+ @Override
+ public void run() {
+ if (Widgets.isAccessible(currentPageLabel)) {
+ int totalPages = flatControl.getTotalPages();
+ currentPageLabel.setText(String.format("%s Items", totalPages));
+ }
+ }
+ });
+ }
+
+ public void addPage(T value) {
+ flatControl.addPage(value);
+ }
+
+ private void setMessage(final int severity, final String message) {
+ Displays.ensureInDisplayThread(new Runnable() {
+ @Override
+ public void run() {
+ if (Widgets.isAccessible(messageLabel)) {
+ Composite parent = messageLabel.getParent();
+
+ String text = message;
+ boolean isVisible = Strings.isValid(text);
+
+ String imageName = null;
+ switch (severity) {
+ case IStatus.INFO:
+ imageName = ISharedImages.IMG_OBJS_INFO_TSK;
+ break;
+ case IStatus.ERROR:
+ imageName = ISharedImages.IMG_OBJS_ERROR_TSK;
+ break;
+ case IStatus.WARNING:
+ imageName = ISharedImages.IMG_OBJS_WARN_TSK;
+ break;
+ default:
+ imageName = null;
+ break;
+ }
+ Image image =
+ Strings.isValid(imageName) ? PlatformUI.getWorkbench().getSharedImages().getImage(imageName) : null;
+ messageIcon.setImage(image);
+ messageLabel.setText(isVisible ? " " + text : text);
+
+ messageIcon.setVisible(isVisible);
+ messageLabel.setVisible(isVisible);
+ parent.setVisible(isVisible);
+ parent.layout();
+ }
+ }
+ });
+ }
+
+ protected abstract void createPage(String id, Composite parent, T value);
+
+ protected abstract void onRemovePage(String id);
+
+ private final class AddPage extends Action {
+ public AddPage() {
+ super();
+ setImageDescriptor(ImageManager.getImageDescriptor(FrameworkImage.ADD_GREEN));
+ setToolTipText("Adds a page");
+ }
+
+ @Override
+ public void run() {
+ flatControl.addPage((T) null);
+ }
+ }
+
+ private final class RemovePage extends Action {
+ public RemovePage() {
+ super();
+ setImageDescriptor(ImageManager.getImageDescriptor(FrameworkImage.REMOVE));
+ setToolTipText("Removes a page");
+ }
+
+ @Override
+ public void run() {
+ AWorkbench.popup("Not implemented yet");
+ flatControl.removePage("here");
+ }
+ }
+
+ private final class FlatControl {
+ private final List<String> pageIds;
+ private Composite flatComposite;
+ private final Map<String, Composite> pages = new HashMap<String, Composite>();
+
+ public FlatControl() {
+ this.pageIds = new ArrayList<String>();
+ }
+
+ private void createControl(Composite parent) {
+ pageIds.clear();
+ flatComposite = new Composite(parent, SWT.BORDER);
+ flatComposite.setLayout(ALayout.getZeroMarginLayout());
+ GridData gd = new GridData(SWT.FILL, SWT.FILL, true, false);
+ gd.minimumWidth = 60;
+ flatComposite.setLayoutData(gd);
+ flatComposite.layout();
+ }
+
+ public void dispose() {
+ pageIds.clear();
+ Widgets.disposeWidget(flatComposite);
+ }
+
+ public void refresh() {
+ flatComposite.layout();
+ flatComposite.getParent().layout();
+ }
+
+ private int getTotalPages() {
+ return Widgets.isAccessible(flatComposite) ? pages.size() : 0;
+ }
+
+ private void addPage(T value) {
+ int numberOfPages = getTotalPages();
+ IStatus status = validate(numberOfPages + 1);
+ if (status.isOK()) {
+ setMessage(IStatus.OK, "");
+ final String pageId = GUID.create();
+ if (pageIds.add(pageId)) {
+ Composite composite = new Composite(flatComposite, SWT.WRAP | SWT.BORDER);
+ composite.setLayout(new GridLayout(3, false));
+ composite.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false));
+
+ createPage(pageId, composite, value);
+
+ Button button = new Button(composite, SWT.FLAT);
+ button.setImage(ImageManager.getImage(FrameworkImage.DELETE));
+ button.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ removePage(pageId);
+ }
+ });
+
+ pages.put(pageId, composite);
+ notifyXModifiedListeners();
+ } else {
+ setMessage(IStatus.WARNING, "Add page error");
+ }
+ } else {
+ setMessage(IStatus.ERROR, status.getMessage());
+ }
+ }
+
+ private void removePage(String pageId) {
+ int numberOfPages = getTotalPages();
+ IStatus status = validate(numberOfPages - 1);
+ if (status.isOK()) {
+ setMessage(IStatus.OK, "");
+
+ pageIds.remove(pageId);
+ if (pageId != null) {
+ onRemovePage(pageId);
+ Control control = pages.remove(pageId);
+ Widgets.disposeWidget(control);
+ notifyXModifiedListeners();
+ } else {
+ setMessage(IStatus.WARNING, "Remove page error");
+ }
+ } else {
+ setMessage(IStatus.ERROR, status.getMessage());
+ }
+ }
+
+ private IStatus validate(int numberOfPages) {
+ IStatus status = null;
+ if (minPage <= numberOfPages && maxPage >= numberOfPages) {
+ status = Status.OK_STATUS;
+ } else {
+ List<String> message = new ArrayList<String>();
+ if (numberOfPages < minPage) {
+ message.add(String.format("Must have at least [%s] page%s", minPage, minPage == 1 ? "" : "s"));
+ }
+ if (numberOfPages > maxPage) {
+ message.add(String.format("Can't add more than [%s] page%s", maxPage, maxPage == 1 ? "" : "s"));
+ }
+ status = new Status(IStatus.ERROR, SkynetGuiPlugin.PLUGIN_ID, Collections.toString(" &", message));
+ }
+ return status;
+ }
+ }
}
diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/XListViewer.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/XListViewer.java index bdb05d3ef0f..87731ea6982 100644 --- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/XListViewer.java +++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/XListViewer.java @@ -165,7 +165,7 @@ public class XListViewer extends XWidget { if (isDisplayLabel() && verticalLabel) {
composite = new Composite(parent, SWT.NONE);
- // composite.setBackground(Display.getDefault().getSystemColor(SWT.COLOR_CYAN));
+ // composite.setBackground(Displays.getSystemColor(SWT.COLOR_CYAN));
composite.setLayout(new GridLayout(1, false));
GridData gd = new GridData(GridData.FILL_BOTH);
gd.horizontalSpan = 2;
diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/XSelectFromDialog.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/XSelectFromDialog.java index 67f840bcca3..b8f4e3f3ef3 100644 --- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/XSelectFromDialog.java +++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/XSelectFromDialog.java @@ -24,6 +24,7 @@ import org.eclipse.osee.framework.logging.OseeLog; import org.eclipse.osee.framework.ui.skynet.SkynetGuiPlugin;
import org.eclipse.osee.framework.ui.skynet.util.filteredTree.MinMaxOSEECheckedFilteredTreeDialog;
import org.eclipse.osee.framework.ui.swt.ALayout;
+import org.eclipse.osee.framework.ui.swt.Displays;
import org.eclipse.osee.framework.ui.swt.Widgets;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
@@ -40,175 +41,175 @@ import org.eclipse.swt.widgets.Label; */
public abstract class XSelectFromDialog<T> extends XText {
- private final List<T> selected;
- private final List<T> input;
- private int minSelectionRequired, maxSelectionRequired = 1;
- private Button selectionButton;
-
- public XSelectFromDialog(String displayLabel, String xmlRoot) {
- super(displayLabel, xmlRoot);
- this.selected = new ArrayList<T>();
- this.input = new ArrayList<T>();
- setToolTip("Click the button on the left to change the current selection.");
- }
-
- public XSelectFromDialog(String displayLabel) {
- this(displayLabel, "");
- }
-
- public void setRequiredSelection(int minSelectionRequired, int maxSelectionRequired) throws OseeArgumentException {
- if (minSelectionRequired < 0) {
- throw new OseeArgumentException("Min Number of Selection must be greater than or equal to 0");
- }
- if (maxSelectionRequired < 1) {
- throw new OseeArgumentException("Max Number of Selection must be at least 1");
- }
-
- if (maxSelectionRequired < minSelectionRequired) {
- throw new OseeArgumentException(String.format("Invalid required number of selections [%s] < [%s]",
- maxSelectionRequired, minSelectionRequired));
- }
- this.minSelectionRequired = minSelectionRequired;
- this.maxSelectionRequired = maxSelectionRequired;
- }
-
- @Override
- protected int getTextStyle() {
- return SWT.READ_ONLY | SWT.BORDER | SWT.MULTI | SWT.WRAP | SWT.H_SCROLL | SWT.V_SCROLL;
- }
-
- @Override
- public void setToolTip(String toolTip) {
- if (Strings.isValid(toolTip)) {
- super.setToolTip(toolTip);
- }
- }
-
- @Override
- public Object getData() {
- return getSelected();
- }
-
- @Override
- public void setEditable(boolean editable) {
- super.setEditable(editable);
- if (Widgets.isAccessible(selectionButton)) {
- selectionButton.setEnabled(editable);
- }
- }
-
- @Override
- public void createControls(final Composite parent, int horizontalSpan, boolean fillText) {
- Composite composite = new Composite(parent, SWT.NONE);
- composite.setLayout(ALayout.getZeroMarginLayout(3, false));
- composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, true));
-
- Label label = getLabelWidget();
- if (label != null) {
- label.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING));
- }
- setVerticalLabel(true);
- super.createControls(composite, horizontalSpan, fillText);
-
- getStyledText().setEditable(false);
- getStyledText().setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING));
-
- selectionButton = new Button(composite, SWT.PUSH);
- selectionButton.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING));
- selectionButton.setText("Set...");
- selectionButton.setEnabled(isEditable());
- selectionButton.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- if (openSelectionDialog()) {
- notifyXModifiedListeners();
- }
- }
- });
- addToolTip(composite, getToolTip());
- getStyledText().setBackground(Display.getDefault().getSystemColor(SWT.COLOR_WIDGET_LIGHT_SHADOW));
- refresh();
- }
-
- private void addToolTip(Control control, String toolTipText) {
- if (Strings.isValid(toolTipText)) {
- control.setToolTipText(toolTipText);
- if (control instanceof Composite) {
- for (Control child : ((Composite) control).getChildren()) {
- child.setToolTipText(toolTipText);
- }
- }
- }
- }
-
- public void setSelectableItems(Collection<T> input) {
- this.input.clear();
- this.input.addAll(input);
- }
-
- public List<T> getSelectableItems() {
- return new ArrayList<T>(input);
- }
-
- public void setSelected(Collection<T> input) {
- this.selected.clear();
- this.selected.addAll(input);
- setText(Collections.toString("\n", selected));
- }
-
- public List<T> getSelected() {
- return new ArrayList<T>(selected);
- }
-
- public abstract MinMaxOSEECheckedFilteredTreeDialog createDialog();
-
- @SuppressWarnings("unchecked")
- protected boolean openSelectionDialog() {
- boolean selectedChanged = false;
- if (getSelectableItems().isEmpty()) {
- MessageDialog.openInformation(Display.getCurrent().getActiveShell(), getLabel(),
- "Could not find items available to select from.");
- } else {
- try {
- MinMaxOSEECheckedFilteredTreeDialog dialog = createDialog();
- Set<T> choices = new HashSet<T>(selected);
- choices.addAll(input);
- dialog.setInput(choices);
- dialog.setInitialSelections(getSelected());
-
- int result = dialog.open();
- if (result == 0) {
- List<T> dialogSelections = new ArrayList<T>();
- for (Object obj : dialog.getResult()) {
- dialogSelections.add((T) obj);
- }
-
- // boolean wasDifference = !Collections.setComplement(selected, dialogSelections).isEmpty();
- // wasDifference &= !Collections.setComplement(dialogSelections, selected).isEmpty();
- // if (wasDifference) {
- setSelected(dialogSelections);
- selectedChanged = true;
- // }
- }
- } catch (Exception ex) {
- OseeLog.log(SkynetGuiPlugin.class, OseeLevel.SEVERE_POPUP, ex);
- }
- }
- return selectedChanged;
- }
-
- /**
- * @return the minSelectionRequired
- */
- public int getMinSelectionRequired() {
- return minSelectionRequired;
- }
-
- /**
- * @return the maxSelectionRequired
- */
- public int getMaxSelectionRequired() {
- return maxSelectionRequired;
- }
+ private final List<T> selected;
+ private final List<T> input;
+ private int minSelectionRequired, maxSelectionRequired = 1;
+ private Button selectionButton;
+
+ public XSelectFromDialog(String displayLabel, String xmlRoot) {
+ super(displayLabel, xmlRoot);
+ this.selected = new ArrayList<T>();
+ this.input = new ArrayList<T>();
+ setToolTip("Click the button on the left to change the current selection.");
+ }
+
+ public XSelectFromDialog(String displayLabel) {
+ this(displayLabel, "");
+ }
+
+ public void setRequiredSelection(int minSelectionRequired, int maxSelectionRequired) throws OseeArgumentException {
+ if (minSelectionRequired < 0) {
+ throw new OseeArgumentException("Min Number of Selection must be greater than or equal to 0");
+ }
+ if (maxSelectionRequired < 1) {
+ throw new OseeArgumentException("Max Number of Selection must be at least 1");
+ }
+
+ if (maxSelectionRequired < minSelectionRequired) {
+ throw new OseeArgumentException(String.format("Invalid required number of selections [%s] < [%s]",
+ maxSelectionRequired, minSelectionRequired));
+ }
+ this.minSelectionRequired = minSelectionRequired;
+ this.maxSelectionRequired = maxSelectionRequired;
+ }
+
+ @Override
+ protected int getTextStyle() {
+ return SWT.READ_ONLY | SWT.BORDER | SWT.MULTI | SWT.WRAP | SWT.H_SCROLL | SWT.V_SCROLL;
+ }
+
+ @Override
+ public void setToolTip(String toolTip) {
+ if (Strings.isValid(toolTip)) {
+ super.setToolTip(toolTip);
+ }
+ }
+
+ @Override
+ public Object getData() {
+ return getSelected();
+ }
+
+ @Override
+ public void setEditable(boolean editable) {
+ super.setEditable(editable);
+ if (Widgets.isAccessible(selectionButton)) {
+ selectionButton.setEnabled(editable);
+ }
+ }
+
+ @Override
+ public void createControls(final Composite parent, int horizontalSpan, boolean fillText) {
+ Composite composite = new Composite(parent, SWT.NONE);
+ composite.setLayout(ALayout.getZeroMarginLayout(3, false));
+ composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, true));
+
+ Label label = getLabelWidget();
+ if (label != null) {
+ label.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING));
+ }
+ setVerticalLabel(true);
+ super.createControls(composite, horizontalSpan, fillText);
+
+ getStyledText().setEditable(false);
+ getStyledText().setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING));
+
+ selectionButton = new Button(composite, SWT.PUSH);
+ selectionButton.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING));
+ selectionButton.setText("Set...");
+ selectionButton.setEnabled(isEditable());
+ selectionButton.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ if (openSelectionDialog()) {
+ notifyXModifiedListeners();
+ }
+ }
+ });
+ addToolTip(composite, getToolTip());
+ getStyledText().setBackground(Displays.getSystemColor(SWT.COLOR_WIDGET_LIGHT_SHADOW));
+ refresh();
+ }
+
+ private void addToolTip(Control control, String toolTipText) {
+ if (Strings.isValid(toolTipText)) {
+ control.setToolTipText(toolTipText);
+ if (control instanceof Composite) {
+ for (Control child : ((Composite) control).getChildren()) {
+ child.setToolTipText(toolTipText);
+ }
+ }
+ }
+ }
+
+ public void setSelectableItems(Collection<T> input) {
+ this.input.clear();
+ this.input.addAll(input);
+ }
+
+ public List<T> getSelectableItems() {
+ return new ArrayList<T>(input);
+ }
+
+ public void setSelected(Collection<T> input) {
+ this.selected.clear();
+ this.selected.addAll(input);
+ setText(Collections.toString("\n", selected));
+ }
+
+ public List<T> getSelected() {
+ return new ArrayList<T>(selected);
+ }
+
+ public abstract MinMaxOSEECheckedFilteredTreeDialog createDialog();
+
+ @SuppressWarnings("unchecked")
+ protected boolean openSelectionDialog() {
+ boolean selectedChanged = false;
+ if (getSelectableItems().isEmpty()) {
+ MessageDialog.openInformation(Display.getCurrent().getActiveShell(), getLabel(),
+ "Could not find items available to select from.");
+ } else {
+ try {
+ MinMaxOSEECheckedFilteredTreeDialog dialog = createDialog();
+ Set<T> choices = new HashSet<T>(selected);
+ choices.addAll(input);
+ dialog.setInput(choices);
+ dialog.setInitialSelections(getSelected());
+
+ int result = dialog.open();
+ if (result == 0) {
+ List<T> dialogSelections = new ArrayList<T>();
+ for (Object obj : dialog.getResult()) {
+ dialogSelections.add((T) obj);
+ }
+
+ // boolean wasDifference = !Collections.setComplement(selected, dialogSelections).isEmpty();
+ // wasDifference &= !Collections.setComplement(dialogSelections, selected).isEmpty();
+ // if (wasDifference) {
+ setSelected(dialogSelections);
+ selectedChanged = true;
+ // }
+ }
+ } catch (Exception ex) {
+ OseeLog.log(SkynetGuiPlugin.class, OseeLevel.SEVERE_POPUP, ex);
+ }
+ }
+ return selectedChanged;
+ }
+
+ /**
+ * @return the minSelectionRequired
+ */
+ public int getMinSelectionRequired() {
+ return minSelectionRequired;
+ }
+
+ /**
+ * @return the maxSelectionRequired
+ */
+ public int getMaxSelectionRequired() {
+ return maxSelectionRequired;
+ }
}
diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/XStackedDam.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/XStackedDam.java index 5181ead6c24..de6a7cdb5f2 100644 --- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/XStackedDam.java +++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/XStackedDam.java @@ -36,247 +36,247 @@ import org.eclipse.osee.framework.skynet.core.attribute.FloatingPointAttribute; import org.eclipse.osee.framework.skynet.core.attribute.IntegerAttribute;
import org.eclipse.osee.framework.ui.plugin.util.Result;
import org.eclipse.osee.framework.ui.skynet.SkynetGuiPlugin;
+import org.eclipse.osee.framework.ui.swt.Displays;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.progress.UIJob;
public class XStackedDam extends XStackedWidget<String> implements IArtifactWidget {
- private Artifact artifact;
- private String attributeTypeName;
- private final Map<String, XWidget> xWidgets;
- private final XModifiedListener xModifiedListener;
+ private Artifact artifact;
+ private String attributeTypeName;
+ private final Map<String, XWidget> xWidgets;
+ private final XModifiedListener xModifiedListener;
- public XStackedDam(String displayLabel) {
- super(displayLabel);
- this.xWidgets = new LinkedHashMap<String, XWidget>();
- this.artifact = null;
- this.xModifiedListener = new XModifiedListener() {
- public void widgetModified(XWidget widget) {
- notifyXModifiedListeners();
- };
- };
- }
+ public XStackedDam(String displayLabel) {
+ super(displayLabel);
+ this.xWidgets = new LinkedHashMap<String, XWidget>();
+ this.artifact = null;
+ this.xModifiedListener = new XModifiedListener() {
+ public void widgetModified(XWidget widget) {
+ notifyXModifiedListeners();
+ };
+ };
+ }
- public void setArtifact(Artifact artifact, String attributeTypeName) throws OseeCoreException {
- this.artifact = artifact;
- this.attributeTypeName = attributeTypeName;
- AttributeType attributeType = AttributeTypeManager.getType(attributeTypeName);
+ public void setArtifact(Artifact artifact, String attributeTypeName) throws OseeCoreException {
+ this.artifact = artifact;
+ this.attributeTypeName = attributeTypeName;
+ AttributeType attributeType = AttributeTypeManager.getType(attributeTypeName);
- int minOccurrence = attributeType.getMinOccurrences();
- int maxOccurrence = attributeType.getMaxOccurrences();
+ int minOccurrence = attributeType.getMinOccurrences();
+ int maxOccurrence = attributeType.getMaxOccurrences();
- if (minOccurrence == 0) {
- minOccurrence = 1;
- }
- setPageRange(minOccurrence, maxOccurrence);
- }
+ if (minOccurrence == 0) {
+ minOccurrence = 1;
+ }
+ setPageRange(minOccurrence, maxOccurrence);
+ }
- @Override
- protected void createControls(Composite parent, int horizontalSpan) {
- super.createControls(parent, horizontalSpan);
- final Collection<String> values = new ArrayList<String>();
- try {
- values.addAll(getStored());
- for (int index = 0; index < values.size(); index++) {
- addPage("");
- }
- } catch (Exception ex) {
- OseeLog.log(SkynetGuiPlugin.class, OseeLevel.SEVERE_POPUP, ex);
- }
- Job job = new UIJob("Update Stacked XText") {
+ @Override
+ protected void createControls(Composite parent, int horizontalSpan) {
+ super.createControls(parent, horizontalSpan);
+ final Collection<String> values = new ArrayList<String>();
+ try {
+ values.addAll(getStored());
+ for (int index = 0; index < values.size(); index++) {
+ addPage("");
+ }
+ } catch (Exception ex) {
+ OseeLog.log(SkynetGuiPlugin.class, OseeLevel.SEVERE_POPUP, ex);
+ }
+ Job job = new UIJob("Update Stacked XText") {
- @Override
- public IStatus runInUIThread(IProgressMonitor monitor) {
- setNotificationsAllowed(false);
- Iterator<String> dataIterator = values.iterator();
- Iterator<XWidget> widgetIterator = xWidgets.values().iterator();
- while (dataIterator.hasNext() && widgetIterator.hasNext()) {
- XWidget widget = widgetIterator.next();
- if (widget instanceof XText) {
- ((XText) widget).set(dataIterator.next());
- } else if (widget instanceof XDate) {
- ((XDate) widget).setDate(toDate(dataIterator.next()));
- }
- }
- values.clear();
- setNotificationsAllowed(true);
- return Status.OK_STATUS;
- }
- };
- Jobs.startJob(job);
- }
+ @Override
+ public IStatus runInUIThread(IProgressMonitor monitor) {
+ setNotificationsAllowed(false);
+ Iterator<String> dataIterator = values.iterator();
+ Iterator<XWidget> widgetIterator = xWidgets.values().iterator();
+ while (dataIterator.hasNext() && widgetIterator.hasNext()) {
+ XWidget widget = widgetIterator.next();
+ if (widget instanceof XText) {
+ ((XText) widget).set(dataIterator.next());
+ } else if (widget instanceof XDate) {
+ ((XDate) widget).setDate(toDate(dataIterator.next()));
+ }
+ }
+ values.clear();
+ setNotificationsAllowed(true);
+ return Status.OK_STATUS;
+ }
+ };
+ Jobs.startJob(job);
+ }
- public List<String> getInput() {
- List<String> data = new ArrayList<String>();
- for (XWidget widget : xWidgets.values()) {
- if (widget instanceof XText) {
- data.add(((XText) widget).get());
- } else if (widget instanceof XDate) {
- Date date = ((XDate) widget).getDate();
- if (date != null) {
- data.add(String.valueOf(date.getTime()));
- }
- }
- }
- return data;
- }
+ public List<String> getInput() {
+ List<String> data = new ArrayList<String>();
+ for (XWidget widget : xWidgets.values()) {
+ if (widget instanceof XText) {
+ data.add(((XText) widget).get());
+ } else if (widget instanceof XDate) {
+ Date date = ((XDate) widget).getDate();
+ if (date != null) {
+ data.add(String.valueOf(date.getTime()));
+ }
+ }
+ }
+ return data;
+ }
- public Collection<String> getStored() throws OseeCoreException {
- return artifact.getAttributesToStringList(attributeTypeName);
- }
+ public Collection<String> getStored() throws OseeCoreException {
+ return artifact.getAttributesToStringList(attributeTypeName);
+ }
- @Override
- public Result isDirty() throws OseeCoreException {
- try {
- Collection<String> enteredValues = new ArrayList<String>();//getSelected();
- Collection<String> storedValues = getStored();
- if (!Collections.isEqual(enteredValues, storedValues)) {
- return new Result(true, attributeTypeName + " is dirty");
- }
- } catch (NumberFormatException ex) {
- // do nothing
- }
- return Result.FalseResult;
- }
+ @Override
+ public Result isDirty() throws OseeCoreException {
+ try {
+ Collection<String> enteredValues = new ArrayList<String>();//getSelected();
+ Collection<String> storedValues = getStored();
+ if (!Collections.isEqual(enteredValues, storedValues)) {
+ return new Result(true, attributeTypeName + " is dirty");
+ }
+ } catch (NumberFormatException ex) {
+ // do nothing
+ }
+ return Result.FalseResult;
+ }
- @Override
- public void revert() throws OseeCoreException {
- setArtifact(artifact, attributeTypeName);
- }
+ @Override
+ public void revert() throws OseeCoreException {
+ setArtifact(artifact, attributeTypeName);
+ }
- @Override
- public void saveToArtifact() throws OseeCoreException {
- artifact.setAttributeValues(attributeTypeName, getInput());
- }
+ @Override
+ public void saveToArtifact() throws OseeCoreException {
+ artifact.setAttributeValues(attributeTypeName, getInput());
+ }
- @Override
- protected void createPage(String id, Composite parent, String initialInput) {
- if (!xWidgets.containsKey(id)) {
- try {
- XWidget xWidget = getWidget(attributeTypeName, parent, initialInput);
- xWidget.setEditable(isEditable());
- xWidgets.put(id, xWidget);
+ @Override
+ protected void createPage(String id, Composite parent, String initialInput) {
+ if (!xWidgets.containsKey(id)) {
+ try {
+ XWidget xWidget = getWidget(attributeTypeName, parent, initialInput);
+ xWidget.setEditable(isEditable());
+ xWidgets.put(id, xWidget);
- xWidget.addXModifiedListener(xModifiedListener);
- parent.layout();
- } catch (OseeCoreException ex) {
- OseeLog.log(SkynetGuiPlugin.class, OseeLevel.SEVERE_POPUP, ex);
- }
- }
- }
+ xWidget.addXModifiedListener(xModifiedListener);
+ parent.layout();
+ } catch (OseeCoreException ex) {
+ OseeLog.log(SkynetGuiPlugin.class, OseeLevel.SEVERE_POPUP, ex);
+ }
+ }
+ }
- @Override
- protected void onRemovePage(String id) {
- xWidgets.remove(id);
- }
+ @Override
+ protected void onRemovePage(String id) {
+ xWidgets.remove(id);
+ }
- @Override
- public IStatus isValid() {
- for (XWidget widget : xWidgets.values()) {
- IStatus status = widget.isValid();
- if (!status.isOK()) {
- return status;
- }
- }
- return Status.OK_STATUS;
- }
+ @Override
+ public IStatus isValid() {
+ for (XWidget widget : xWidgets.values()) {
+ IStatus status = widget.isValid();
+ if (!status.isOK()) {
+ return status;
+ }
+ }
+ return Status.OK_STATUS;
+ }
- @Override
- public void validate() {
- String id = getCurrentPageId();
- if (Strings.isValid(id)) {
- XWidget widget = xWidgets.get(id);
- widget.validate();
- }
- }
+ @Override
+ public void validate() {
+ String id = getCurrentPageId();
+ if (Strings.isValid(id)) {
+ XWidget widget = xWidgets.get(id);
+ widget.validate();
+ }
+ }
- private Date toDate(String value) {
- try {
- return new Date(Long.parseLong(value));
- } catch (Exception ex) {
- OseeLog.log(SkynetGuiPlugin.class, OseeLevel.SEVERE_POPUP, ex);
- }
- return new Date();
- }
+ private Date toDate(String value) {
+ try {
+ return new Date(Long.parseLong(value));
+ } catch (Exception ex) {
+ OseeLog.log(SkynetGuiPlugin.class, OseeLevel.SEVERE_POPUP, ex);
+ }
+ return new Date();
+ }
- private XWidget getWidget(String attributeType, Composite parent, String initialInput) throws OseeCoreException {
- XWidget xWidget = null;
- if (AttributeTypeManager.isBaseTypeCompatible(IntegerAttribute.class, attributeType)) {
- XInteger xInteger = new XInteger("");
- xInteger.setFillHorizontally(true);
- xInteger.createWidgets(getManagedForm(), parent, 2);
- if (Strings.isValid(initialInput)) {
- xInteger.setText(initialInput);
- }
- xWidget = xInteger;
- } else if (AttributeTypeManager.isBaseTypeCompatible(DateAttribute.class, attributeType)) {
- XDate xDate = new XDate("");
- xDate.setFillHorizontally(true);
- xDate.createWidgets(getManagedForm(), parent, 2);
- if (Strings.isValid(initialInput)) {
- xDate.setDate(toDate(initialInput));
- }
- xWidget = xDate;
- } else if (AttributeTypeManager.isBaseTypeCompatible(FloatingPointAttribute.class, attributeType)) {
- XFloat xFloat = new XFloat("");
- xFloat.setFillHorizontally(true);
- xFloat.createWidgets(getManagedForm(), parent, 2);
- if (Strings.isValid(initialInput)) {
- xFloat.setText(initialInput);
- }
- xWidget = xFloat;
- } else if (AttributeTypeManager.isBaseTypeCompatible(BinaryBackedAttribute.class, attributeType)) {
- XLabel xLabel = new XLabel("");
- xLabel.setFillHorizontally(true);
- xLabel.createWidgets(getManagedForm(), parent, 2);
- if (Strings.isValid(initialInput)) {
- xLabel.setLabel(initialInput);
- }
- xWidget = xLabel;
- }
+ private XWidget getWidget(String attributeType, Composite parent, String initialInput) throws OseeCoreException {
+ XWidget xWidget = null;
+ if (AttributeTypeManager.isBaseTypeCompatible(IntegerAttribute.class, attributeType)) {
+ XInteger xInteger = new XInteger("");
+ xInteger.setFillHorizontally(true);
+ xInteger.createWidgets(getManagedForm(), parent, 2);
+ if (Strings.isValid(initialInput)) {
+ xInteger.setText(initialInput);
+ }
+ xWidget = xInteger;
+ } else if (AttributeTypeManager.isBaseTypeCompatible(DateAttribute.class, attributeType)) {
+ XDate xDate = new XDate("");
+ xDate.setFillHorizontally(true);
+ xDate.createWidgets(getManagedForm(), parent, 2);
+ if (Strings.isValid(initialInput)) {
+ xDate.setDate(toDate(initialInput));
+ }
+ xWidget = xDate;
+ } else if (AttributeTypeManager.isBaseTypeCompatible(FloatingPointAttribute.class, attributeType)) {
+ XFloat xFloat = new XFloat("");
+ xFloat.setFillHorizontally(true);
+ xFloat.createWidgets(getManagedForm(), parent, 2);
+ if (Strings.isValid(initialInput)) {
+ xFloat.setText(initialInput);
+ }
+ xWidget = xFloat;
+ } else if (AttributeTypeManager.isBaseTypeCompatible(BinaryBackedAttribute.class, attributeType)) {
+ XLabel xLabel = new XLabel("");
+ xLabel.setFillHorizontally(true);
+ xLabel.createWidgets(getManagedForm(), parent, 2);
+ if (Strings.isValid(initialInput)) {
+ xLabel.setLabel(initialInput);
+ }
+ xWidget = xLabel;
+ }
- if (xWidget == null) {
- XText xTextWidget = new XTextInternalWidget("");
- if (Strings.isValid(initialInput)) {
- xTextWidget.setText(initialInput);
- }
- xTextWidget.addXTextSpellModifyDictionary(new SkynetSpellModifyDictionary());
- xTextWidget.setFillHorizontally(false);
- xTextWidget.setFillVertically(true);
- xTextWidget.createWidgets(getManagedForm(), parent, 2);
- xWidget = xTextWidget;
- }
- return xWidget;
- }
- private final class XTextInternalWidget extends XText {
+ if (xWidget == null) {
+ XText xTextWidget = new XTextInternalWidget("");
+ if (Strings.isValid(initialInput)) {
+ xTextWidget.setText(initialInput);
+ }
+ xTextWidget.addXTextSpellModifyDictionary(new SkynetSpellModifyDictionary());
+ xTextWidget.setFillHorizontally(false);
+ xTextWidget.setFillVertically(true);
+ xTextWidget.createWidgets(getManagedForm(), parent, 2);
+ xWidget = xTextWidget;
+ }
+ return xWidget;
+ }
+ private final class XTextInternalWidget extends XText {
- public XTextInternalWidget(String label) {
- super(label);
- }
+ public XTextInternalWidget(String label) {
+ super(label);
+ }
- @Override
- protected int getTextStyle() {
- int styleBase = SWT.NONE;
- if (isEditable()) {
- styleBase |= SWT.READ_ONLY;
- }
- return styleBase | (fillVertically ? SWT.WRAP | SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL : SWT.SINGLE);
- }
+ @Override
+ protected int getTextStyle() {
+ int styleBase = SWT.NONE;
+ if (isEditable()) {
+ styleBase |= SWT.READ_ONLY;
+ }
+ return styleBase | (fillVertically ? SWT.WRAP | SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL : SWT.SINGLE);
+ }
- @Override
- public void createControls(Composite parent, int horizontalSpan, boolean fillText) {
- super.createControls(parent, horizontalSpan, fillText);
- GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true);
- gd.widthHint = 200;
- gd.heightHint = 200;
- sText.setLayoutData(gd);
- sText.setWordWrap(true);
- sText.setEditable(isEditable());
- if (!isEditable()) {
- sText.setBackground(Display.getDefault().getSystemColor(SWT.COLOR_WIDGET_LIGHT_SHADOW));
- }
- }
- }
+ @Override
+ public void createControls(Composite parent, int horizontalSpan, boolean fillText) {
+ super.createControls(parent, horizontalSpan, fillText);
+ GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true);
+ gd.widthHint = 200;
+ gd.heightHint = 200;
+ sText.setLayoutData(gd);
+ sText.setWordWrap(true);
+ sText.setEditable(isEditable());
+ if (!isEditable()) {
+ sText.setBackground(Displays.getSystemColor(SWT.COLOR_WIDGET_LIGHT_SHADOW));
+ }
+ }
+ }
}
diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/XStackedWidget.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/XStackedWidget.java index 4cf449345cd..be66506a5b0 100644 --- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/XStackedWidget.java +++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/XStackedWidget.java @@ -25,6 +25,7 @@ import org.eclipse.osee.framework.jdk.core.util.Strings; import org.eclipse.osee.framework.ui.skynet.FrameworkImage;
import org.eclipse.osee.framework.ui.skynet.SkynetGuiPlugin;
import org.eclipse.osee.framework.ui.swt.ALayout;
+import org.eclipse.osee.framework.ui.swt.Displays;
import org.eclipse.osee.framework.ui.swt.ImageManager;
import org.eclipse.osee.framework.ui.swt.StackedViewer;
import org.eclipse.osee.framework.ui.swt.Widgets;
@@ -43,445 +44,446 @@ import org.eclipse.ui.PlatformUI; public abstract class XStackedWidget<T> extends XLabel {
- private StackedControl stackedControl;
- private StyledText currentPageLabel;
- private Composite container;
- private Label messageLabel;
- private Label messageIcon;
- private int minPage;
- private int maxPage;
-
- public XStackedWidget(String displayLabel, String xmlRoot) {
- super(displayLabel, xmlRoot);
- setToolTip("Navigate pages by clicking forward and backward buttons.");
- minPage = 0;
- maxPage = 0;
- }
-
- @Override
- public void dispose() {
- stackedControl.dispose();
- super.dispose();
- }
-
- public XStackedWidget(String displayLabel) {
- this(displayLabel, "");
- }
-
- protected void setPageRange(int minPage, int maxPage) throws OseeArgumentException {
- if (minPage < 0) {
- throw new OseeArgumentException("Min Number of Pages must be greater than 0");
- }
- if (maxPage < 1) {
- throw new OseeArgumentException("Max Number of Pages must be at least 1");
- }
-
- if (maxPage < minPage) {
- throw new OseeArgumentException(
- String.format("Invalid required number of pages [%s] < [%s]", maxPage, minPage)); - }
- this.minPage = minPage;
- this.maxPage = maxPage;
- }
-
- @Override
- public Control getControl() {
- if (stackedControl == null) { - return null; - } - return stackedControl.stackedViewer;
- }
-
- @Override
- public void setToolTip(String toolTip) {
- if (Strings.isValid(toolTip)) {
- super.setToolTip(toolTip);
- }
- }
-
- @Override
- public void refresh() {
- updateCurrentPageLabel();
- stackedControl.refresh();
- }
-
- @Override
- protected void createControls(final Composite parent, int horizontalSpan) {
- container = new Composite(parent, SWT.NONE);
- GridLayout layout = new GridLayout(isDisplayLabel() ? 2 : 1, false);
- layout.marginHeight = 0;
- layout.marginWidth = 0;
- layout.marginRight = 0;
- container.setLayout(layout);
- container.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
-
- if (isDisplayLabel() && Strings.isValid(getLabel())) {
- labelWidget = new Label(container, SWT.NONE);
- labelWidget.setText(String.format("%s:", getLabel()));
- labelWidget.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING));
- if (getToolTip() != null) {
- labelWidget.setToolTipText(getToolTip());
- }
- }
-
- Composite composite = new Composite(container, SWT.NONE);
- GridLayout layout1 = new GridLayout(1, false);
- layout1.marginHeight = 0;
- layout1.marginWidth = 0;
- layout1.verticalSpacing = 0;
- layout1.horizontalSpacing = 0;
- composite.setLayout(layout1);
- composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
-
- createToolBar(composite);
- stackedControl = new StackedControl();
- stackedControl.createControl(composite);
- createMessageArea(composite);
-
- addToolTip(container, getToolTip());
- stackedControl.next();
- refresh();
- }
-
- private void createMessageArea(Composite parent) {
- Composite messageArea = new Composite(parent, SWT.BORDER);
- GridLayout layout = new GridLayout(2, false);
- layout.marginHeight = 0;
- layout.marginWidth = 0;
- layout.marginLeft = 5;
- layout.horizontalSpacing = 0;
- layout.verticalSpacing = 0;
- layout.marginBottom = 5;
-
- messageArea.setLayout(layout);
- messageArea.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
- messageArea.setBackground(Display.getDefault().getSystemColor(SWT.COLOR_INFO_BACKGROUND));
-
- messageIcon = new Label(messageArea, SWT.NONE);
- messageIcon.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false));
-
- messageLabel = new Label(messageArea, SWT.NONE);
- messageLabel.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, false));
- }
-
- private void createToolBar(Composite parent) {
- Composite composite = new Composite(parent, SWT.BORDER);
- GridLayout layout = new GridLayout(3, false);
- layout.marginHeight = 0;
- layout.marginLeft = 5;
- layout.marginWidth = 2;
- composite.setLayout(layout);
- composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
- composite.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WIDGET_LIGHT_SHADOW));
-
- currentPageLabel = new StyledText(composite, SWT.READ_ONLY | SWT.SINGLE | SWT.WRAP);
- currentPageLabel.setAlignment(SWT.RIGHT);
- currentPageLabel.setFont(JFaceResources.getBannerFont());
- GridData gd = new GridData(SWT.FILL, SWT.FILL, true, false);
- gd.minimumWidth = 10;
- currentPageLabel.setLayoutData(gd);
- currentPageLabel.setText("0 of 0");
-
- Composite filler = new Composite(composite, SWT.NONE);
- GridLayout layout1 = new GridLayout(1, false);
- filler.setLayout(layout1);
- filler.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
-
- ToolBar toolbar = new ToolBar(composite, SWT.FLAT | SWT.HORIZONTAL);
- toolbar.setLayoutData(new GridData(SWT.NONE, SWT.NONE, false, false));
- ToolBarManager manager = new ToolBarManager(toolbar);
- manager.add(new Separator());
- manager.add(new Back());
- manager.add(new Forward());
- manager.add(new Separator());
- manager.add(new AddPage());
- manager.add(new RemovePage());
- manager.update(true);
- }
-
- private void addToolTip(Control control, String toolTipText) {
- if (Strings.isValid(toolTipText)) {
- control.setToolTipText(toolTipText);
- if (control instanceof Composite) {
- for (Control child : ((Composite) control).getChildren()) {
- child.setToolTipText(toolTipText);
- }
- }
- }
- }
-
- private void updateCurrentPageLabel() {
- Display.getDefault().asyncExec(new Runnable() {
- public void run() {
- if (Widgets.isAccessible(currentPageLabel)) {
- int totalPages = stackedControl.getTotalPages();
- int currentPage = stackedControl.getCurrentPageIndex() + 1;
- if (currentPage > totalPages) {
- currentPage = totalPages;
- }
- currentPageLabel.setText(String.format("Page %s of %s - Page Id (%s)", currentPage, totalPages,
- stackedControl.getCurrentPageId())); - }
- }
- });
- }
-
- public void addPage(T value) {
- stackedControl.addPage(value);
- }
-
- protected String getCurrentPageId() {
- return stackedControl.getCurrentPageId();
- }
-
- private void setMessage(final int severity, final String message) {
- Display.getDefault().asyncExec(new Runnable() {
- public void run() {
- if (Widgets.isAccessible(messageLabel)) {
- Composite parent = messageLabel.getParent();
-
- String text = message;
- boolean isVisible = Strings.isValid(text);
-
- String imageName = null;
- switch (severity) {
- case IStatus.INFO:
- imageName = ISharedImages.IMG_OBJS_INFO_TSK;
- break;
- case IStatus.ERROR:
- imageName = ISharedImages.IMG_OBJS_ERROR_TSK;
- break;
- case IStatus.WARNING:
- imageName = ISharedImages.IMG_OBJS_WARN_TSK;
- break;
- default:
- imageName = null;
- break;
- }
- Image image =
- Strings.isValid(imageName) ? PlatformUI.getWorkbench().getSharedImages().getImage(imageName) : null; - messageIcon.setImage(image);
- messageLabel.setText(isVisible ? " " + text : text);
-
- messageIcon.setVisible(isVisible);
- messageLabel.setVisible(isVisible);
- parent.setVisible(isVisible);
- parent.layout();
- }
- }
- });
- }
-
- protected abstract void createPage(String id, Composite parent, T value);
-
- protected abstract void onRemovePage(String id);
-
- private final class Back extends Action {
- public Back() {
- super();
- setImageDescriptor(ImageManager.getImageDescriptor(FrameworkImage.NAV_BACKWARD));
- setToolTipText("Back to previous page");
- }
-
- @Override
- public void run() {
- stackedControl.previous();
- }
- }
-
- private final class Forward extends Action {
- public Forward() {
- super();
- setImageDescriptor(ImageManager.getImageDescriptor(FrameworkImage.NAV_FORWARD));
- setToolTipText("Forward to next page");
- }
-
- @Override
- public void run() {
- stackedControl.next();
- }
- }
-
- private final class AddPage extends Action {
- public AddPage() {
- super();
- setImageDescriptor(ImageManager.getImageDescriptor(FrameworkImage.ADD_GREEN));
- setToolTipText("Adds a page");
- }
-
- @Override
- public void run() {
- stackedControl.addPage((T) null);
- }
- }
-
- private final class RemovePage extends Action {
- public RemovePage() {
- super();
- setImageDescriptor(ImageManager.getImageDescriptor(FrameworkImage.X_RED));
- setToolTipText("Removes a page");
- }
-
- @Override
- public void run() {
- stackedControl.removePage();
- }
- }
-
- private final class StackedControl {
- private StackedViewer stackedViewer;
- private int currentPage;
- private final List<String> pageIds;
-
- public StackedControl() {
- this.stackedViewer = null;
- this.currentPage = -1;
- this.pageIds = new ArrayList<String>();
- }
-
- private void createControl(Composite parent) {
- pageIds.clear();
- stackedViewer = new StackedViewer(parent, SWT.BORDER);
- stackedViewer.setLayout(ALayout.getZeroMarginLayout());
- GridData gd = new GridData(SWT.FILL, SWT.FILL, false, false);
- gd.minimumHeight = 60;
- gd.minimumWidth = 60;
- stackedViewer.setLayoutData(gd);
- stackedViewer.setCurrentControl(StackedViewer.DEFAULT_CONTROL);
- stackedViewer.layout();
- }
-
- public void dispose() {
- pageIds.clear();
- Widgets.disposeWidget(stackedViewer);
- }
-
- public void refresh() {
- stackedViewer.getStackComposite().layout();
- stackedViewer.getStackComposite().getParent().layout();
- }
-
- private int getTotalPages() {
- return Widgets.isAccessible(stackedViewer) ? stackedViewer.getControlCount() : 0;
- }
-
- private int getCurrentPageIndex() {
- return currentPage;
- }
-
- private String getCurrentPageId() {
- String toReturn = null;
- int index = getCurrentPageIndex();
- if (index >= 0 && index < pageIds.size()) {
- toReturn = pageIds.get(index);
- }
- return toReturn;
- }
-
- private void next() {
- int next = getCurrentPageIndex();
- if (next + 1 < getTotalPages()) {
- next++;
- } else {
- next = 0;
- }
- setCurrentPage(next);
- }
-
- private void previous() {
- int previous = getCurrentPageIndex();
- if (previous - 1 >= 0) {
- previous--;
- } else {
- previous = getTotalPages() - 1;
- }
- setCurrentPage(previous);
- }
-
- public void setCurrentPage(int index) {
- String pageId = null;
- setMessage(IStatus.OK, "");
- if (index >= 0 && index < pageIds.size()) {
- pageId = pageIds.get(index);
- if (pageId == null) {
- setMessage(IStatus.ERROR, String.format("Page [%s] not found.", index));
- }
- } else {
- setMessage(IStatus.ERROR, String.format("Page [%s] out of bounds.", index));
- }
-
- if (pageId == null) {
- index = 0;
- pageId = StackedViewer.DEFAULT_CONTROL;
- }
- this.currentPage = index;
- stackedViewer.setCurrentControl(pageId);
- updateCurrentPageLabel();
- }
-
- private void addPage(T value) {
- int numberOfPages = getTotalPages();
- IStatus status = validate(numberOfPages + 1);
- if (status.isOK()) {
- setMessage(IStatus.OK, "");
- String id = GUID.create();
- if (pageIds.add(id)) {
- Composite composite = new Composite(stackedViewer.getStackComposite(), SWT.WRAP);
- composite.setLayout(new GridLayout());
- composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, true));
-
- createPage(id, composite, value);
- stackedViewer.addControl(id, composite);
- setCurrentPage(numberOfPages);
- notifyXModifiedListeners();
- } else {
- setMessage(IStatus.WARNING, - String.format("Add page error - page at index [%s] already exists", getCurrentPageIndex())); - }
- } else {
- setMessage(IStatus.ERROR, status.getMessage());
- }
- }
-
- private void removePage() {
- int numberOfPages = getTotalPages();
- IStatus status = validate(numberOfPages - 1);
- if (status.isOK()) {
- setMessage(IStatus.OK, "");
- System.out.println("Delete Page");
-
- String pageId = pageIds.remove(getCurrentPageIndex());
- if (pageId != null) {
- onRemovePage(pageId);
- Control control = stackedViewer.removeControl(pageId);
- Widgets.disposeWidget(control);
- previous();
- notifyXModifiedListeners();
- } else {
- setMessage(IStatus.WARNING, - String.format("Remove page error - page at index [%s] does not exist", getCurrentPageIndex())); - }
- } else {
- setMessage(IStatus.ERROR, status.getMessage());
- }
- }
-
- private IStatus validate(int numberOfPages) {
- IStatus status = null;
- if (minPage <= numberOfPages && maxPage >= numberOfPages) {
- status = Status.OK_STATUS;
- } else {
- List<String> message = new ArrayList<String>();
- if (numberOfPages < minPage) {
- message.add(String.format("Must have at least [%s] page%s", minPage, minPage == 1 ? "" : "s"));
- }
- if (numberOfPages > maxPage) {
- message.add(String.format("Can't add more than [%s] page%s", maxPage, maxPage == 1 ? "" : "s"));
- }
- status = new Status(IStatus.ERROR, SkynetGuiPlugin.PLUGIN_ID, Collections.toString(" &", message));
- }
- return status;
- }
- }
+ private StackedControl stackedControl;
+ private StyledText currentPageLabel;
+ private Composite container;
+ private Label messageLabel;
+ private Label messageIcon;
+ private int minPage;
+ private int maxPage;
+
+ public XStackedWidget(String displayLabel, String xmlRoot) {
+ super(displayLabel, xmlRoot);
+ setToolTip("Navigate pages by clicking forward and backward buttons.");
+ minPage = 0;
+ maxPage = 0;
+ }
+
+ @Override
+ public void dispose() {
+ stackedControl.dispose();
+ super.dispose();
+ }
+
+ public XStackedWidget(String displayLabel) {
+ this(displayLabel, "");
+ }
+
+ protected void setPageRange(int minPage, int maxPage) throws OseeArgumentException {
+ if (minPage < 0) {
+ throw new OseeArgumentException("Min Number of Pages must be greater than 0");
+ }
+ if (maxPage < 1) {
+ throw new OseeArgumentException("Max Number of Pages must be at least 1");
+ }
+
+ if (maxPage < minPage) {
+ throw new OseeArgumentException(
+ String.format("Invalid required number of pages [%s] < [%s]", maxPage, minPage));
+ }
+ this.minPage = minPage;
+ this.maxPage = maxPage;
+ }
+
+ @Override
+ public Control getControl() {
+ if (stackedControl == null) {
+ return null;
+ }
+ return stackedControl.stackedViewer;
+ }
+
+ @Override
+ public void setToolTip(String toolTip) {
+ if (Strings.isValid(toolTip)) {
+ super.setToolTip(toolTip);
+ }
+ }
+
+ @Override
+ public void refresh() {
+ updateCurrentPageLabel();
+ stackedControl.refresh();
+ }
+
+ @Override
+ protected void createControls(final Composite parent, int horizontalSpan) {
+ container = new Composite(parent, SWT.NONE);
+ GridLayout layout = new GridLayout(isDisplayLabel() ? 2 : 1, false);
+ layout.marginHeight = 0;
+ layout.marginWidth = 0;
+ layout.marginRight = 0;
+ container.setLayout(layout);
+ container.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
+
+ if (isDisplayLabel() && Strings.isValid(getLabel())) {
+ labelWidget = new Label(container, SWT.NONE);
+ labelWidget.setText(String.format("%s:", getLabel()));
+ labelWidget.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING));
+ if (getToolTip() != null) {
+ labelWidget.setToolTipText(getToolTip());
+ }
+ }
+
+ Composite composite = new Composite(container, SWT.NONE);
+ GridLayout layout1 = new GridLayout(1, false);
+ layout1.marginHeight = 0;
+ layout1.marginWidth = 0;
+ layout1.verticalSpacing = 0;
+ layout1.horizontalSpacing = 0;
+ composite.setLayout(layout1);
+ composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
+
+ createToolBar(composite);
+ stackedControl = new StackedControl();
+ stackedControl.createControl(composite);
+ createMessageArea(composite);
+
+ addToolTip(container, getToolTip());
+ stackedControl.next();
+ refresh();
+ }
+
+ private void createMessageArea(Composite parent) {
+ Composite messageArea = new Composite(parent, SWT.BORDER);
+ GridLayout layout = new GridLayout(2, false);
+ layout.marginHeight = 0;
+ layout.marginWidth = 0;
+ layout.marginLeft = 5;
+ layout.horizontalSpacing = 0;
+ layout.verticalSpacing = 0;
+ layout.marginBottom = 5;
+
+ messageArea.setLayout(layout);
+ messageArea.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+ messageArea.setBackground(Displays.getSystemColor(SWT.COLOR_INFO_BACKGROUND));
+
+ messageIcon = new Label(messageArea, SWT.NONE);
+ messageIcon.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false));
+
+ messageLabel = new Label(messageArea, SWT.NONE);
+ messageLabel.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, false));
+ }
+
+ private void createToolBar(Composite parent) {
+ Composite composite = new Composite(parent, SWT.BORDER);
+ GridLayout layout = new GridLayout(3, false);
+ layout.marginHeight = 0;
+ layout.marginLeft = 5;
+ layout.marginWidth = 2;
+ composite.setLayout(layout);
+ composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
+ composite.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WIDGET_LIGHT_SHADOW));
+
+ currentPageLabel = new StyledText(composite, SWT.READ_ONLY | SWT.SINGLE | SWT.WRAP);
+ currentPageLabel.setAlignment(SWT.RIGHT);
+ currentPageLabel.setFont(JFaceResources.getBannerFont());
+ GridData gd = new GridData(SWT.FILL, SWT.FILL, true, false);
+ gd.minimumWidth = 10;
+ currentPageLabel.setLayoutData(gd);
+ currentPageLabel.setText("0 of 0");
+
+ Composite filler = new Composite(composite, SWT.NONE);
+ GridLayout layout1 = new GridLayout(1, false);
+ filler.setLayout(layout1);
+ filler.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
+
+ ToolBar toolbar = new ToolBar(composite, SWT.FLAT | SWT.HORIZONTAL);
+ toolbar.setLayoutData(new GridData(SWT.NONE, SWT.NONE, false, false));
+ ToolBarManager manager = new ToolBarManager(toolbar);
+ manager.add(new Separator());
+ manager.add(new Back());
+ manager.add(new Forward());
+ manager.add(new Separator());
+ manager.add(new AddPage());
+ manager.add(new RemovePage());
+ manager.update(true);
+ }
+
+ private void addToolTip(Control control, String toolTipText) {
+ if (Strings.isValid(toolTipText)) {
+ control.setToolTipText(toolTipText);
+ if (control instanceof Composite) {
+ for (Control child : ((Composite) control).getChildren()) {
+ child.setToolTipText(toolTipText);
+ }
+ }
+ }
+ }
+
+ private void updateCurrentPageLabel() {
+ Displays.ensureInDisplayThread(new Runnable() {
+ @Override
+ public void run() {
+ if (Widgets.isAccessible(currentPageLabel)) {
+ int totalPages = stackedControl.getTotalPages();
+ int currentPage = stackedControl.getCurrentPageIndex() + 1;
+ if (currentPage > totalPages) {
+ currentPage = totalPages;
+ }
+ currentPageLabel.setText(String.format("Page %s of %s - Page Id (%s)", currentPage, totalPages,
+ stackedControl.getCurrentPageId()));
+ }
+ }
+ });
+ }
+
+ public void addPage(T value) {
+ stackedControl.addPage(value);
+ }
+
+ protected String getCurrentPageId() {
+ return stackedControl.getCurrentPageId();
+ }
+
+ private void setMessage(final int severity, final String message) {
+ Displays.ensureInDisplayThread(new Runnable() {
+ @Override
+ public void run() {
+ if (Widgets.isAccessible(messageLabel)) {
+ Composite parent = messageLabel.getParent();
+
+ String text = message;
+ boolean isVisible = Strings.isValid(text);
+
+ String imageName = null;
+ switch (severity) {
+ case IStatus.INFO:
+ imageName = ISharedImages.IMG_OBJS_INFO_TSK;
+ break;
+ case IStatus.ERROR:
+ imageName = ISharedImages.IMG_OBJS_ERROR_TSK;
+ break;
+ case IStatus.WARNING:
+ imageName = ISharedImages.IMG_OBJS_WARN_TSK;
+ break;
+ default:
+ break;
+ }
+ Image image =
+ Strings.isValid(imageName) ? PlatformUI.getWorkbench().getSharedImages().getImage(imageName) : null;
+ messageIcon.setImage(image);
+ messageLabel.setText(isVisible ? " " + text : text);
+
+ messageIcon.setVisible(isVisible);
+ messageLabel.setVisible(isVisible);
+ parent.setVisible(isVisible);
+ parent.layout();
+ }
+ }
+ });
+ }
+
+ protected abstract void createPage(String id, Composite parent, T value);
+
+ protected abstract void onRemovePage(String id);
+
+ private final class Back extends Action {
+ public Back() {
+ super();
+ setImageDescriptor(ImageManager.getImageDescriptor(FrameworkImage.NAV_BACKWARD));
+ setToolTipText("Back to previous page");
+ }
+
+ @Override
+ public void run() {
+ stackedControl.previous();
+ }
+ }
+
+ private final class Forward extends Action {
+ public Forward() {
+ super();
+ setImageDescriptor(ImageManager.getImageDescriptor(FrameworkImage.NAV_FORWARD));
+ setToolTipText("Forward to next page");
+ }
+
+ @Override
+ public void run() {
+ stackedControl.next();
+ }
+ }
+
+ private final class AddPage extends Action {
+ public AddPage() {
+ super();
+ setImageDescriptor(ImageManager.getImageDescriptor(FrameworkImage.ADD_GREEN));
+ setToolTipText("Adds a page");
+ }
+
+ @Override
+ public void run() {
+ stackedControl.addPage((T) null);
+ }
+ }
+
+ private final class RemovePage extends Action {
+ public RemovePage() {
+ super();
+ setImageDescriptor(ImageManager.getImageDescriptor(FrameworkImage.X_RED));
+ setToolTipText("Removes a page");
+ }
+
+ @Override
+ public void run() {
+ stackedControl.removePage();
+ }
+ }
+
+ private final class StackedControl {
+ private StackedViewer stackedViewer;
+ private int currentPage;
+ private final List<String> pageIds;
+
+ public StackedControl() {
+ this.stackedViewer = null;
+ this.currentPage = -1;
+ this.pageIds = new ArrayList<String>();
+ }
+
+ private void createControl(Composite parent) {
+ pageIds.clear();
+ stackedViewer = new StackedViewer(parent, SWT.BORDER);
+ stackedViewer.setLayout(ALayout.getZeroMarginLayout());
+ GridData gd = new GridData(SWT.FILL, SWT.FILL, false, false);
+ gd.minimumHeight = 60;
+ gd.minimumWidth = 60;
+ stackedViewer.setLayoutData(gd);
+ stackedViewer.setCurrentControl(StackedViewer.DEFAULT_CONTROL);
+ stackedViewer.layout();
+ }
+
+ public void dispose() {
+ pageIds.clear();
+ Widgets.disposeWidget(stackedViewer);
+ }
+
+ public void refresh() {
+ stackedViewer.getStackComposite().layout();
+ stackedViewer.getStackComposite().getParent().layout();
+ }
+
+ private int getTotalPages() {
+ return Widgets.isAccessible(stackedViewer) ? stackedViewer.getControlCount() : 0;
+ }
+
+ private int getCurrentPageIndex() {
+ return currentPage;
+ }
+
+ private String getCurrentPageId() {
+ String toReturn = null;
+ int index = getCurrentPageIndex();
+ if (index >= 0 && index < pageIds.size()) {
+ toReturn = pageIds.get(index);
+ }
+ return toReturn;
+ }
+
+ private void next() {
+ int next = getCurrentPageIndex();
+ if (next + 1 < getTotalPages()) {
+ next++;
+ } else {
+ next = 0;
+ }
+ setCurrentPage(next);
+ }
+
+ private void previous() {
+ int previous = getCurrentPageIndex();
+ if (previous - 1 >= 0) {
+ previous--;
+ } else {
+ previous = getTotalPages() - 1;
+ }
+ setCurrentPage(previous);
+ }
+
+ public void setCurrentPage(int index) {
+ String pageId = null;
+ setMessage(IStatus.OK, "");
+ if (index >= 0 && index < pageIds.size()) {
+ pageId = pageIds.get(index);
+ if (pageId == null) {
+ setMessage(IStatus.ERROR, String.format("Page [%s] not found.", index));
+ }
+ } else {
+ setMessage(IStatus.ERROR, String.format("Page [%s] out of bounds.", index));
+ }
+
+ if (pageId == null) {
+ index = 0;
+ pageId = StackedViewer.DEFAULT_CONTROL;
+ }
+ this.currentPage = index;
+ stackedViewer.setCurrentControl(pageId);
+ updateCurrentPageLabel();
+ }
+
+ private void addPage(T value) {
+ int numberOfPages = getTotalPages();
+ IStatus status = validate(numberOfPages + 1);
+ if (status.isOK()) {
+ setMessage(IStatus.OK, "");
+ String id = GUID.create();
+ if (pageIds.add(id)) {
+ Composite composite = new Composite(stackedViewer.getStackComposite(), SWT.WRAP);
+ composite.setLayout(new GridLayout());
+ composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, true));
+
+ createPage(id, composite, value);
+ stackedViewer.addControl(id, composite);
+ setCurrentPage(numberOfPages);
+ notifyXModifiedListeners();
+ } else {
+ setMessage(IStatus.WARNING,
+ String.format("Add page error - page at index [%s] already exists", getCurrentPageIndex()));
+ }
+ } else {
+ setMessage(IStatus.ERROR, status.getMessage());
+ }
+ }
+
+ private void removePage() {
+ int numberOfPages = getTotalPages();
+ IStatus status = validate(numberOfPages - 1);
+ if (status.isOK()) {
+ setMessage(IStatus.OK, "");
+ System.out.println("Delete Page");
+
+ String pageId = pageIds.remove(getCurrentPageIndex());
+ if (pageId != null) {
+ onRemovePage(pageId);
+ Control control = stackedViewer.removeControl(pageId);
+ Widgets.disposeWidget(control);
+ previous();
+ notifyXModifiedListeners();
+ } else {
+ setMessage(IStatus.WARNING,
+ String.format("Remove page error - page at index [%s] does not exist", getCurrentPageIndex()));
+ }
+ } else {
+ setMessage(IStatus.ERROR, status.getMessage());
+ }
+ }
+
+ private IStatus validate(int numberOfPages) {
+ IStatus status = null;
+ if (minPage <= numberOfPages && maxPage >= numberOfPages) {
+ status = Status.OK_STATUS;
+ } else {
+ List<String> message = new ArrayList<String>();
+ if (numberOfPages < minPage) {
+ message.add(String.format("Must have at least [%s] page%s", minPage, minPage == 1 ? "" : "s"));
+ }
+ if (numberOfPages > maxPage) {
+ message.add(String.format("Can't add more than [%s] page%s", maxPage, maxPage == 1 ? "" : "s"));
+ }
+ status = new Status(IStatus.ERROR, SkynetGuiPlugin.PLUGIN_ID, Collections.toString(" &", message));
+ }
+ return status;
+ }
+ }
}
diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/workflow/DynamicXWidgetLayout.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/workflow/DynamicXWidgetLayout.java index 86099c0f0c4..0a9626d4db3 100644 --- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/workflow/DynamicXWidgetLayout.java +++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/workflow/DynamicXWidgetLayout.java @@ -35,6 +35,7 @@ import org.eclipse.osee.framework.ui.skynet.widgets.XOption; import org.eclipse.osee.framework.ui.skynet.widgets.XText; import org.eclipse.osee.framework.ui.skynet.widgets.XWidget; import org.eclipse.osee.framework.ui.swt.ALayout; +import org.eclipse.osee.framework.ui.swt.Displays; import org.eclipse.swt.SWT; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; @@ -53,406 +54,406 @@ import org.xml.sax.SAXException; */ public class DynamicXWidgetLayout { - private final Set<DynamicXWidgetLayoutData> datas = new LinkedHashSet<DynamicXWidgetLayoutData>(); - private final Map<String, DynamicXWidgetLayoutData> nameToLayoutData = - new HashMap<String, DynamicXWidgetLayoutData>(); - private final ArrayList<ArrayList<String>> orRequired = new ArrayList<ArrayList<String>>(); - private final ArrayList<ArrayList<String>> xorRequired = new ArrayList<ArrayList<String>>(); - public static String OR_REQUIRED = "OrRequired"; - public static String XOR_REQUIRED = "XOrRequired"; - public static String XWIDGET = "XWidget"; - public static String XWIDGETS_LIST = "xWidgets"; - private final IDynamicWidgetLayoutListener dynamicWidgetLayoutListener; - private final IXWidgetOptionResolver optionResolver; - private final List<XWidget> xWidgets = new ArrayList<XWidget>(); - - public DynamicXWidgetLayout() { - this(null, new DefaultXWidgetOptionResolver()); - } - - public DynamicXWidgetLayout(IDynamicWidgetLayoutListener dynamicWidgetLayoutListener, IXWidgetOptionResolver optionResolver) { - this.dynamicWidgetLayoutListener = dynamicWidgetLayoutListener; - this.optionResolver = optionResolver; - } - - private Composite createComposite(Composite parent, FormToolkit toolkit) { - return toolkit != null ? toolkit.createComposite(parent, SWT.WRAP) : new Composite(parent, SWT.NONE); - } - - public void createBody(IManagedForm managedForm, Composite parent, Artifact artifact, XModifiedListener xModListener, boolean isEditable) throws OseeCoreException { - Composite attrComp = null; - - final FormToolkit toolkit = managedForm != null ? managedForm.getToolkit() : null; - - attrComp = createComposite(parent, toolkit); - - GridLayout layout = new GridLayout(1, false); - layout.marginWidth = 2; - layout.marginHeight = 2; - attrComp.setLayout(layout); - attrComp.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - - if (toolkit != null) { - toolkit.adapt(attrComp); - } - - boolean inChildComposite = false, inGroupComposite = false; - Composite childComp = null; - Group groupComp = null; - // Create Attributes - for (DynamicXWidgetLayoutData xWidgetLayoutData : getLayoutDatas()) { - Composite useComp = attrComp; - - if (xWidgetLayoutData.getBeginGroupComposite() > 0) { - groupComp = new Group(attrComp, SWT.None); - if (Strings.isValid(xWidgetLayoutData.getName())) { - groupComp.setText(xWidgetLayoutData.getName()); - } - groupComp.setLayout(ALayout.getZeroMarginLayout(xWidgetLayoutData.getBeginGroupComposite(), false)); - groupComp.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - if (toolkit != null) { - toolkit.adapt(groupComp); - } - inGroupComposite = true; - // No XWidget associated, so go to next one - continue; - } - if (xWidgetLayoutData.getBeginComposite() > 0) { - childComp = createComposite((inGroupComposite ? groupComp : attrComp), toolkit); - childComp.setLayout(ALayout.getZeroMarginLayout(xWidgetLayoutData.getBeginComposite(), false)); - childComp.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - if (toolkit != null) { - toolkit.adapt(childComp); - } - inChildComposite = true; - } - if (inGroupComposite) { - useComp = groupComp; - if (xWidgetLayoutData.isEndGroupComposite()) { - inGroupComposite = false; - // No XWidget associated, so go to next one - continue; - } - } - if (inChildComposite) { - useComp = childComp; - if (xWidgetLayoutData.isEndComposite()) { - inChildComposite = false; - } - } else if (xWidgetLayoutData.getXOptionHandler().contains(XOption.HORIZONTAL_LABEL)) { - useComp = createComposite(attrComp, toolkit); - useComp.setLayout(ALayout.getZeroMarginLayout(2, false)); - useComp.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - if (toolkit != null) { - toolkit.adapt(useComp); - } - } - - XWidget xWidget = xWidgetLayoutData.getXWidget(); - xWidgets.add(xWidget); - - if (Strings.isValid(xWidgetLayoutData.getName())) { - xWidget.setLabel(xWidgetLayoutData.getName().replaceFirst("^.*?\\.", "")); - } - - if (Strings.isValid(xWidgetLayoutData.getToolTip())) { - xWidget.setToolTip(xWidgetLayoutData.getToolTip()); - } - - xWidget.setRequiredEntry(xWidgetLayoutData.isRequired()); - xWidget.setEditable(xWidgetLayoutData.getXOptionHandler().contains(XOption.EDITABLE) && isEditable); - - if (dynamicWidgetLayoutListener != null) { - dynamicWidgetLayoutListener.widgetCreating(xWidget, toolkit, artifact, this, xModListener, isEditable); - } - - if (artifact != null && xWidget instanceof IArtifactWidget) { - try { - ((IArtifactWidget) xWidget).setArtifact(artifact, xWidgetLayoutData.getStorageName()); - } catch (Exception ex) { - OseeLog.log(SkynetGuiPlugin.class, OseeLevel.SEVERE_POPUP, ex); - } - } - - if (xWidget instanceof XText) { - XText xText = (XText) xWidget; - if (xWidgetLayoutData.getXOptionHandler().contains(XOption.FILL_HORIZONTALLY)) { - xText.setFillHorizontally(true); - } - if (xWidgetLayoutData.getXOptionHandler().contains(XOption.FILL_VERTICALLY)) { - xText.setFillVertically(true); - } - } - - xWidget.createWidgets(managedForm, useComp, 2); - - if (xWidget instanceof XText) { - XText xText = (XText) xWidget; - if (xWidgetLayoutData.getXOptionHandler().contains(XOption.FILL_HORIZONTALLY) && xWidgetLayoutData.getXOptionHandler().contains( - XOption.FILL_VERTICALLY)) { - GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true); - gd.minimumWidth = 60; - gd.minimumHeight = 60; - useComp.setLayoutData(gd); - - gd = new GridData(SWT.FILL, SWT.FILL, true, true); - gd.minimumWidth = 60; - gd.minimumHeight = 60; - xText.getStyledText().setLayoutData(gd); - } else if (xWidgetLayoutData.getXOptionHandler().contains(XOption.FILL_HORIZONTALLY)) { - GridData gd = new GridData(SWT.FILL, SWT.FILL, true, false); - gd.minimumWidth = 60; - useComp.setLayoutData(gd); - - gd = new GridData(SWT.FILL, SWT.FILL, true, false); - gd.minimumWidth = 60; - xText.getStyledText().setLayoutData(gd); - } else if (xWidgetLayoutData.getXOptionHandler().contains(XOption.FILL_VERTICALLY)) { - GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true); - gd.minimumHeight = 60; - useComp.setLayoutData(gd); - - gd = new GridData(SWT.FILL, SWT.FILL, true, true); - gd.minimumHeight = 60; - xText.getStyledText().setLayoutData(gd); - } - - if (xWidgetLayoutData.isHeightSet()) { - xText.setHeight(xWidgetLayoutData.getHeight()); - } - } - useComp.layout(); - - if (xModListener != null) { - xWidget.addXModifiedListener(xModListener); - } - - xWidget.addXModifiedListener(refreshRequiredModListener); - - if (dynamicWidgetLayoutListener != null) { - dynamicWidgetLayoutListener.widgetCreated(xWidget, toolkit, artifact, this, xModListener, isEditable); - dynamicWidgetLayoutListener.createXWidgetLayoutData(xWidgetLayoutData, xWidget, toolkit, artifact, - xModListener, isEditable); - } - } - - Display.getDefault().asyncExec(new Runnable() { - - public void run() { - try { - for (DynamicXWidgetLayoutData xWidgetLayoutData : getLayoutDatas()) { - xWidgetLayoutData.getXWidget().validate(); - } - refreshOrAndXOrRequiredFlags(); - } catch (OseeCoreException ex) { - OseeLog.log(SkynetGuiPlugin.class, OseeLevel.SEVERE_POPUP, ex); - } - } - }); - } - private final XModifiedListener refreshRequiredModListener = new XModifiedListener() { - public void widgetModified(XWidget widget) { - try { - refreshOrAndXOrRequiredFlags(); - } catch (OseeCoreException ex) { - OseeLog.log(SkynetGuiPlugin.class, OseeLevel.SEVERE_POPUP, ex); - } - } - }; - - /** - * Required flags are set per XWidget and the labels change from Red to Black when the widget has been edited - * successfully. When a page is made up of two or more widgets that need to work together, these required flags need - * to be set/unset whenever a widget from the group gets modified. - * - * @throws OseeArgumentException - */ - private void refreshOrAndXOrRequiredFlags() throws OseeArgumentException { - // Handle orRequired - for (ArrayList<String> orReq : orRequired) { - // If group is complete, change all to black, else all red - boolean isComplete = isOrGroupFromAttrNameComplete(orReq.iterator().next()); - for (String aName : orReq) { - DynamicXWidgetLayoutData layoutData = getLayoutData(aName); - Label label = layoutData.getXWidget().getLabelWidget(); - if (label != null && !label.isDisposed()) { - label.setForeground(isComplete ? null : Display.getCurrent().getSystemColor(SWT.COLOR_RED)); - } - } - } - // Handle xorRequired - for (ArrayList<String> xorReq : xorRequired) { - // If group is complete, change all to black, else all red - boolean isComplete = isXOrGroupFromAttrNameComplete(xorReq.iterator().next()); - for (String aName : xorReq) { - DynamicXWidgetLayoutData layoutData = getLayoutData(aName); - Label label = layoutData.getXWidget().getLabelWidget(); - if (label != null && !label.isDisposed()) { - label.setForeground(isComplete ? null : Display.getCurrent().getSystemColor(SWT.COLOR_RED)); - } - } - } - } - - public IStatus isPageComplete() { - try { - for (DynamicXWidgetLayoutData data : datas) { - IStatus valid = data.getXWidget().isValid(); - if (!valid.isOK()) { - // Check to see if widget is part of a completed OR or XOR group - if (!isOrGroupFromAttrNameComplete(data.getStorageName()) && !isXOrGroupFromAttrNameComplete(data.getStorageName())) { - return valid; - } - } - } - } catch (OseeCoreException ex) { - OseeLog.log(SkynetGuiPlugin.class, OseeLevel.SEVERE_POPUP, ex); - } - return Status.OK_STATUS; - } - - public Set<DynamicXWidgetLayoutData> getLayoutDatas() { - return datas; - } - - public void setLayoutDatas(List<DynamicXWidgetLayoutData> datas) { - this.datas.clear(); - for (DynamicXWidgetLayoutData data : datas) { - data.setDynamicXWidgetLayout(this); - this.datas.add(data); - } - } - - public void addWorkLayoutDatas(List<DynamicXWidgetLayoutData> datas) { - this.datas.addAll(datas); - } - - public void addWorkLayoutData(DynamicXWidgetLayoutData data) { - this.datas.add(data); - } - - public DynamicXWidgetLayoutData getLayoutData(String attrName) { - for (DynamicXWidgetLayoutData layoutData : datas) { - if (layoutData.getStorageName().equals(attrName)) { - return layoutData; - } - } - return null; - } - - public boolean isOrRequired(String attrName) { - return getOrRequiredGroup(attrName).size() > 0; - } - - public boolean isXOrRequired(String attrName) { - return getXOrRequiredGroup(attrName).size() > 0; - } - - public ArrayList<String> getOrRequiredGroup(String attrName) { - return getRequiredGroup(orRequired, attrName); - } - - public ArrayList<String> getXOrRequiredGroup(String attrName) { - return getRequiredGroup(xorRequired, attrName); - } - - private ArrayList<String> getRequiredGroup(ArrayList<ArrayList<String>> requiredList, String attrName) { - for (ArrayList<String> list : requiredList) { - for (String aName : list) { - if (aName.equals(attrName)) { - return list; - } - } - } - return new ArrayList<String>(); - } - - /** - * @param name - * @return true if ANY item in group is entered - * @throws OseeArgumentException - */ - public boolean isOrGroupFromAttrNameComplete(String name) throws OseeArgumentException { - for (String aName : getOrRequiredGroup(name)) { - DynamicXWidgetLayoutData layoutData = getLayoutData(aName); - if (layoutData.getXWidget() != null && layoutData.getXWidget().isValid().isOK()) { - return true; - } - } - return false; - } - - /** - * @param attrName - * @return true if only ONE item in group is entered - * @throws OseeArgumentException - */ - public boolean isXOrGroupFromAttrNameComplete(String attrName) throws OseeArgumentException { - boolean oneFound = false; - for (String aName : getXOrRequiredGroup(attrName)) { - DynamicXWidgetLayoutData layoutData = getLayoutData(aName); - if (layoutData.getXWidget() != null && layoutData.getXWidget().isValid().isOK()) { - // If already found one, return false - if (oneFound) { - return false; - } else { - oneFound = true; - } - } - } - return oneFound; - } - - protected void processOrRequired(String instr) { - ArrayList<String> names = new ArrayList<String>(); - for (String attr : instr.split(";")) { - if (!attr.contains("[ \\s]*")) { - names.add(attr); - } - } - orRequired.add(names); - } - - protected void processXOrRequired(String instr) { - ArrayList<String> names = new ArrayList<String>(); - for (String attr : instr.split(";")) { - if (!attr.contains("[ \\s]*")) { - names.add(attr); - } - } - xorRequired.add(names); - } - - protected void processlayoutDatas(String xWidgetXml) throws IOException, ParserConfigurationException, SAXException { - Document document = Jaxp.readXmlDocument(xWidgetXml); - Element rootElement = document.getDocumentElement(); - - List<DynamicXWidgetLayoutData> attrs = XWidgetParser.extractlayoutDatas(this, rootElement); - for (DynamicXWidgetLayoutData attr : attrs) { - nameToLayoutData.put(attr.getName(), attr); - datas.add(attr); - } - } - - protected void processLayoutDatas(Element element) throws IOException, ParserConfigurationException, SAXException { - List<DynamicXWidgetLayoutData> layoutDatas = XWidgetParser.extractlayoutDatas(this, element); - for (DynamicXWidgetLayoutData layoutData : layoutDatas) { - nameToLayoutData.put(layoutData.getName(), layoutData); - datas.add(layoutData); - } - } - - /** - * @return the optionResolver - */ - public IXWidgetOptionResolver getOptionResolver() { - return optionResolver; - } - - /** - * @return the xWidgets - */ - public List<XWidget> getXWidgets() { - return xWidgets; - } + private final Set<DynamicXWidgetLayoutData> datas = new LinkedHashSet<DynamicXWidgetLayoutData>(); + private final Map<String, DynamicXWidgetLayoutData> nameToLayoutData = + new HashMap<String, DynamicXWidgetLayoutData>(); + private final ArrayList<ArrayList<String>> orRequired = new ArrayList<ArrayList<String>>(); + private final ArrayList<ArrayList<String>> xorRequired = new ArrayList<ArrayList<String>>(); + public static String OR_REQUIRED = "OrRequired"; + public static String XOR_REQUIRED = "XOrRequired"; + public static String XWIDGET = "XWidget"; + public static String XWIDGETS_LIST = "xWidgets"; + private final IDynamicWidgetLayoutListener dynamicWidgetLayoutListener; + private final IXWidgetOptionResolver optionResolver; + private final List<XWidget> xWidgets = new ArrayList<XWidget>(); + + public DynamicXWidgetLayout() { + this(null, new DefaultXWidgetOptionResolver()); + } + + public DynamicXWidgetLayout(IDynamicWidgetLayoutListener dynamicWidgetLayoutListener, IXWidgetOptionResolver optionResolver) { + this.dynamicWidgetLayoutListener = dynamicWidgetLayoutListener; + this.optionResolver = optionResolver; + } + + private Composite createComposite(Composite parent, FormToolkit toolkit) { + return toolkit != null ? toolkit.createComposite(parent, SWT.WRAP) : new Composite(parent, SWT.NONE); + } + + public void createBody(IManagedForm managedForm, Composite parent, Artifact artifact, XModifiedListener xModListener, boolean isEditable) throws OseeCoreException { + Composite attrComp = null; + + final FormToolkit toolkit = managedForm != null ? managedForm.getToolkit() : null; + + attrComp = createComposite(parent, toolkit); + + GridLayout layout = new GridLayout(1, false); + layout.marginWidth = 2; + layout.marginHeight = 2; + attrComp.setLayout(layout); + attrComp.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); + + if (toolkit != null) { + toolkit.adapt(attrComp); + } + + boolean inChildComposite = false, inGroupComposite = false; + Composite childComp = null; + Group groupComp = null; + // Create Attributes + for (DynamicXWidgetLayoutData xWidgetLayoutData : getLayoutDatas()) { + Composite useComp = attrComp; + + if (xWidgetLayoutData.getBeginGroupComposite() > 0) { + groupComp = new Group(attrComp, SWT.None); + if (Strings.isValid(xWidgetLayoutData.getName())) { + groupComp.setText(xWidgetLayoutData.getName()); + } + groupComp.setLayout(ALayout.getZeroMarginLayout(xWidgetLayoutData.getBeginGroupComposite(), false)); + groupComp.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); + if (toolkit != null) { + toolkit.adapt(groupComp); + } + inGroupComposite = true; + // No XWidget associated, so go to next one + continue; + } + if (xWidgetLayoutData.getBeginComposite() > 0) { + childComp = createComposite((inGroupComposite ? groupComp : attrComp), toolkit); + childComp.setLayout(ALayout.getZeroMarginLayout(xWidgetLayoutData.getBeginComposite(), false)); + childComp.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); + if (toolkit != null) { + toolkit.adapt(childComp); + } + inChildComposite = true; + } + if (inGroupComposite) { + useComp = groupComp; + if (xWidgetLayoutData.isEndGroupComposite()) { + inGroupComposite = false; + // No XWidget associated, so go to next one + continue; + } + } + if (inChildComposite) { + useComp = childComp; + if (xWidgetLayoutData.isEndComposite()) { + inChildComposite = false; + } + } else if (xWidgetLayoutData.getXOptionHandler().contains(XOption.HORIZONTAL_LABEL)) { + useComp = createComposite(attrComp, toolkit); + useComp.setLayout(ALayout.getZeroMarginLayout(2, false)); + useComp.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); + if (toolkit != null) { + toolkit.adapt(useComp); + } + } + + XWidget xWidget = xWidgetLayoutData.getXWidget(); + xWidgets.add(xWidget); + + if (Strings.isValid(xWidgetLayoutData.getName())) { + xWidget.setLabel(xWidgetLayoutData.getName().replaceFirst("^.*?\\.", "")); + } + + if (Strings.isValid(xWidgetLayoutData.getToolTip())) { + xWidget.setToolTip(xWidgetLayoutData.getToolTip()); + } + + xWidget.setRequiredEntry(xWidgetLayoutData.isRequired()); + xWidget.setEditable(xWidgetLayoutData.getXOptionHandler().contains(XOption.EDITABLE) && isEditable); + + if (dynamicWidgetLayoutListener != null) { + dynamicWidgetLayoutListener.widgetCreating(xWidget, toolkit, artifact, this, xModListener, isEditable); + } + + if (artifact != null && xWidget instanceof IArtifactWidget) { + try { + ((IArtifactWidget) xWidget).setArtifact(artifact, xWidgetLayoutData.getStorageName()); + } catch (Exception ex) { + OseeLog.log(SkynetGuiPlugin.class, OseeLevel.SEVERE_POPUP, ex); + } + } + + if (xWidget instanceof XText) { + XText xText = (XText) xWidget; + if (xWidgetLayoutData.getXOptionHandler().contains(XOption.FILL_HORIZONTALLY)) { + xText.setFillHorizontally(true); + } + if (xWidgetLayoutData.getXOptionHandler().contains(XOption.FILL_VERTICALLY)) { + xText.setFillVertically(true); + } + } + + xWidget.createWidgets(managedForm, useComp, 2); + + if (xWidget instanceof XText) { + XText xText = (XText) xWidget; + if (xWidgetLayoutData.getXOptionHandler().contains(XOption.FILL_HORIZONTALLY) && xWidgetLayoutData.getXOptionHandler().contains( + XOption.FILL_VERTICALLY)) { + GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true); + gd.minimumWidth = 60; + gd.minimumHeight = 60; + useComp.setLayoutData(gd); + + gd = new GridData(SWT.FILL, SWT.FILL, true, true); + gd.minimumWidth = 60; + gd.minimumHeight = 60; + xText.getStyledText().setLayoutData(gd); + } else if (xWidgetLayoutData.getXOptionHandler().contains(XOption.FILL_HORIZONTALLY)) { + GridData gd = new GridData(SWT.FILL, SWT.FILL, true, false); + gd.minimumWidth = 60; + useComp.setLayoutData(gd); + + gd = new GridData(SWT.FILL, SWT.FILL, true, false); + gd.minimumWidth = 60; + xText.getStyledText().setLayoutData(gd); + } else if (xWidgetLayoutData.getXOptionHandler().contains(XOption.FILL_VERTICALLY)) { + GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true); + gd.minimumHeight = 60; + useComp.setLayoutData(gd); + + gd = new GridData(SWT.FILL, SWT.FILL, true, true); + gd.minimumHeight = 60; + xText.getStyledText().setLayoutData(gd); + } + + if (xWidgetLayoutData.isHeightSet()) { + xText.setHeight(xWidgetLayoutData.getHeight()); + } + } + useComp.layout(); + + if (xModListener != null) { + xWidget.addXModifiedListener(xModListener); + } + + xWidget.addXModifiedListener(refreshRequiredModListener); + + if (dynamicWidgetLayoutListener != null) { + dynamicWidgetLayoutListener.widgetCreated(xWidget, toolkit, artifact, this, xModListener, isEditable); + dynamicWidgetLayoutListener.createXWidgetLayoutData(xWidgetLayoutData, xWidget, toolkit, artifact, + xModListener, isEditable); + } + } + + Displays.ensureInDisplayThread(new Runnable() { + @Override + public void run() { + try { + for (DynamicXWidgetLayoutData xWidgetLayoutData : getLayoutDatas()) { + xWidgetLayoutData.getXWidget().validate(); + } + refreshOrAndXOrRequiredFlags(); + } catch (OseeCoreException ex) { + OseeLog.log(SkynetGuiPlugin.class, OseeLevel.SEVERE_POPUP, ex); + } + } + }); + } + private final XModifiedListener refreshRequiredModListener = new XModifiedListener() { + public void widgetModified(XWidget widget) { + try { + refreshOrAndXOrRequiredFlags(); + } catch (OseeCoreException ex) { + OseeLog.log(SkynetGuiPlugin.class, OseeLevel.SEVERE_POPUP, ex); + } + } + }; + + /** + * Required flags are set per XWidget and the labels change from Red to Black when the widget has been edited + * successfully. When a page is made up of two or more widgets that need to work together, these required flags need + * to be set/unset whenever a widget from the group gets modified. + * + * @throws OseeArgumentException + */ + private void refreshOrAndXOrRequiredFlags() throws OseeArgumentException { + // Handle orRequired + for (ArrayList<String> orReq : orRequired) { + // If group is complete, change all to black, else all red + boolean isComplete = isOrGroupFromAttrNameComplete(orReq.iterator().next()); + for (String aName : orReq) { + DynamicXWidgetLayoutData layoutData = getLayoutData(aName); + Label label = layoutData.getXWidget().getLabelWidget(); + if (label != null && !label.isDisposed()) { + label.setForeground(isComplete ? null : Display.getCurrent().getSystemColor(SWT.COLOR_RED)); + } + } + } + // Handle xorRequired + for (ArrayList<String> xorReq : xorRequired) { + // If group is complete, change all to black, else all red + boolean isComplete = isXOrGroupFromAttrNameComplete(xorReq.iterator().next()); + for (String aName : xorReq) { + DynamicXWidgetLayoutData layoutData = getLayoutData(aName); + Label label = layoutData.getXWidget().getLabelWidget(); + if (label != null && !label.isDisposed()) { + label.setForeground(isComplete ? null : Display.getCurrent().getSystemColor(SWT.COLOR_RED)); + } + } + } + } + + public IStatus isPageComplete() { + try { + for (DynamicXWidgetLayoutData data : datas) { + IStatus valid = data.getXWidget().isValid(); + if (!valid.isOK()) { + // Check to see if widget is part of a completed OR or XOR group + if (!isOrGroupFromAttrNameComplete(data.getStorageName()) && !isXOrGroupFromAttrNameComplete(data.getStorageName())) { + return valid; + } + } + } + } catch (OseeCoreException ex) { + OseeLog.log(SkynetGuiPlugin.class, OseeLevel.SEVERE_POPUP, ex); + } + return Status.OK_STATUS; + } + + public Set<DynamicXWidgetLayoutData> getLayoutDatas() { + return datas; + } + + public void setLayoutDatas(List<DynamicXWidgetLayoutData> datas) { + this.datas.clear(); + for (DynamicXWidgetLayoutData data : datas) { + data.setDynamicXWidgetLayout(this); + this.datas.add(data); + } + } + + public void addWorkLayoutDatas(List<DynamicXWidgetLayoutData> datas) { + this.datas.addAll(datas); + } + + public void addWorkLayoutData(DynamicXWidgetLayoutData data) { + this.datas.add(data); + } + + public DynamicXWidgetLayoutData getLayoutData(String attrName) { + for (DynamicXWidgetLayoutData layoutData : datas) { + if (layoutData.getStorageName().equals(attrName)) { + return layoutData; + } + } + return null; + } + + public boolean isOrRequired(String attrName) { + return getOrRequiredGroup(attrName).size() > 0; + } + + public boolean isXOrRequired(String attrName) { + return getXOrRequiredGroup(attrName).size() > 0; + } + + public ArrayList<String> getOrRequiredGroup(String attrName) { + return getRequiredGroup(orRequired, attrName); + } + + public ArrayList<String> getXOrRequiredGroup(String attrName) { + return getRequiredGroup(xorRequired, attrName); + } + + private ArrayList<String> getRequiredGroup(ArrayList<ArrayList<String>> requiredList, String attrName) { + for (ArrayList<String> list : requiredList) { + for (String aName : list) { + if (aName.equals(attrName)) { + return list; + } + } + } + return new ArrayList<String>(); + } + + /** + * @param name + * @return true if ANY item in group is entered + * @throws OseeArgumentException + */ + public boolean isOrGroupFromAttrNameComplete(String name) throws OseeArgumentException { + for (String aName : getOrRequiredGroup(name)) { + DynamicXWidgetLayoutData layoutData = getLayoutData(aName); + if (layoutData.getXWidget() != null && layoutData.getXWidget().isValid().isOK()) { + return true; + } + } + return false; + } + + /** + * @param attrName + * @return true if only ONE item in group is entered + * @throws OseeArgumentException + */ + public boolean isXOrGroupFromAttrNameComplete(String attrName) throws OseeArgumentException { + boolean oneFound = false; + for (String aName : getXOrRequiredGroup(attrName)) { + DynamicXWidgetLayoutData layoutData = getLayoutData(aName); + if (layoutData.getXWidget() != null && layoutData.getXWidget().isValid().isOK()) { + // If already found one, return false + if (oneFound) { + return false; + } else { + oneFound = true; + } + } + } + return oneFound; + } + + protected void processOrRequired(String instr) { + ArrayList<String> names = new ArrayList<String>(); + for (String attr : instr.split(";")) { + if (!attr.contains("[ \\s]*")) { + names.add(attr); + } + } + orRequired.add(names); + } + + protected void processXOrRequired(String instr) { + ArrayList<String> names = new ArrayList<String>(); + for (String attr : instr.split(";")) { + if (!attr.contains("[ \\s]*")) { + names.add(attr); + } + } + xorRequired.add(names); + } + + protected void processlayoutDatas(String xWidgetXml) throws IOException, ParserConfigurationException, SAXException { + Document document = Jaxp.readXmlDocument(xWidgetXml); + Element rootElement = document.getDocumentElement(); + + List<DynamicXWidgetLayoutData> attrs = XWidgetParser.extractlayoutDatas(this, rootElement); + for (DynamicXWidgetLayoutData attr : attrs) { + nameToLayoutData.put(attr.getName(), attr); + datas.add(attr); + } + } + + protected void processLayoutDatas(Element element) throws IOException, ParserConfigurationException, SAXException { + List<DynamicXWidgetLayoutData> layoutDatas = XWidgetParser.extractlayoutDatas(this, element); + for (DynamicXWidgetLayoutData layoutData : layoutDatas) { + nameToLayoutData.put(layoutData.getName(), layoutData); + datas.add(layoutData); + } + } + + /** + * @return the optionResolver + */ + public IXWidgetOptionResolver getOptionResolver() { + return optionResolver; + } + + /** + * @return the xWidgets + */ + public List<XWidget> getXWidgets() { + return xWidgets; + } } diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/xBranch/BranchView.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/xBranch/BranchView.java index bd16ef71ef8..d6238328ab5 100644 --- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/xBranch/BranchView.java +++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/xBranch/BranchView.java @@ -37,9 +37,9 @@ import org.eclipse.osee.framework.skynet.core.event2.ITransactionEventListener; import org.eclipse.osee.framework.skynet.core.event2.TransactionEvent;
import org.eclipse.osee.framework.skynet.core.event2.TransactionEventType;
import org.eclipse.osee.framework.ui.plugin.util.AWorkbench;
-import org.eclipse.osee.framework.ui.plugin.util.Displays;
import org.eclipse.osee.framework.ui.skynet.OseeContributionItem;
import org.eclipse.osee.framework.ui.skynet.SkynetGuiPlugin;
+import org.eclipse.osee.framework.ui.swt.Displays;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/xBranch/XBranchWidget.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/xBranch/XBranchWidget.java index 1662fcff212..93b9ad69634 100644 --- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/xBranch/XBranchWidget.java +++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/xBranch/XBranchWidget.java @@ -31,10 +31,10 @@ import org.eclipse.osee.framework.plugin.core.util.Jobs; import org.eclipse.osee.framework.skynet.core.artifact.BranchManager;
import org.eclipse.osee.framework.ui.plugin.OseeUiActions;
import org.eclipse.osee.framework.ui.plugin.PluginUiImage;
-import org.eclipse.osee.framework.ui.plugin.util.Displays;
import org.eclipse.osee.framework.ui.skynet.SkynetGuiPlugin;
import org.eclipse.osee.framework.ui.skynet.widgets.XWidget;
import org.eclipse.osee.framework.ui.swt.ALayout;
+import org.eclipse.osee.framework.ui.swt.Displays;
import org.eclipse.osee.framework.ui.swt.ImageManager;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/xHistory/HistoryView.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/xHistory/HistoryView.java index da71f379918..3719a5e0adc 100644 --- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/xHistory/HistoryView.java +++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/xHistory/HistoryView.java @@ -40,7 +40,6 @@ import org.eclipse.osee.framework.skynet.core.event.IBranchEventListener; import org.eclipse.osee.framework.skynet.core.event.Sender;
import org.eclipse.osee.framework.skynet.core.event2.BranchEvent;
import org.eclipse.osee.framework.ui.plugin.util.AWorkbench;
-import org.eclipse.osee.framework.ui.plugin.util.Displays;
import org.eclipse.osee.framework.ui.skynet.FrameworkImage;
import org.eclipse.osee.framework.ui.skynet.OpenWithMenuListener;
import org.eclipse.osee.framework.ui.skynet.OseeContributionItem;
@@ -49,6 +48,7 @@ import org.eclipse.osee.framework.ui.skynet.change.ChangeUiUtil; import org.eclipse.osee.framework.ui.skynet.listener.IRebuildMenuListener;
import org.eclipse.osee.framework.ui.skynet.menu.ArtifactDiffMenu;
import org.eclipse.osee.framework.ui.skynet.util.SkynetViews;
+import org.eclipse.osee.framework.ui.swt.Displays;
import org.eclipse.osee.framework.ui.swt.ImageManager;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.MenuEvent;
diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/xHistory/XHistoryWidget.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/xHistory/XHistoryWidget.java index 31fea354733..46d500459ab 100644 --- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/xHistory/XHistoryWidget.java +++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/xHistory/XHistoryWidget.java @@ -33,11 +33,11 @@ import org.eclipse.osee.framework.skynet.core.change.Change; import org.eclipse.osee.framework.skynet.core.revision.ChangeManager;
import org.eclipse.osee.framework.ui.plugin.OseeUiActions;
import org.eclipse.osee.framework.ui.plugin.PluginUiImage;
-import org.eclipse.osee.framework.ui.plugin.util.Displays;
import org.eclipse.osee.framework.ui.skynet.SkynetGuiPlugin;
import org.eclipse.osee.framework.ui.skynet.util.SkynetDragAndDrop;
import org.eclipse.osee.framework.ui.skynet.widgets.XWidget;
import org.eclipse.osee.framework.ui.swt.ALayout;
+import org.eclipse.osee.framework.ui.swt.Displays;
import org.eclipse.osee.framework.ui.swt.ImageManager;
import org.eclipse.swt.SWT;
import org.eclipse.swt.dnd.DND;
diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/xmerge/MergeView.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/xmerge/MergeView.java index 8002e2bf328..18359c963a9 100644 --- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/xmerge/MergeView.java +++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/xmerge/MergeView.java @@ -58,7 +58,6 @@ import org.eclipse.osee.framework.skynet.core.transaction.TransactionManager; import org.eclipse.osee.framework.ui.plugin.util.AWorkbench;
import org.eclipse.osee.framework.ui.plugin.util.AbstractSelectionEnabledHandler;
import org.eclipse.osee.framework.ui.plugin.util.Commands;
-import org.eclipse.osee.framework.ui.plugin.util.Displays;
import org.eclipse.osee.framework.ui.skynet.ArtifactExplorer;
import org.eclipse.osee.framework.ui.skynet.FrameworkImage;
import org.eclipse.osee.framework.ui.skynet.OseeContributionItem;
@@ -68,6 +67,7 @@ import org.eclipse.osee.framework.ui.skynet.render.RendererManager; import org.eclipse.osee.framework.ui.skynet.revert.RevertWizard;
import org.eclipse.osee.framework.ui.skynet.util.SkynetViews;
import org.eclipse.osee.framework.ui.skynet.widgets.xHistory.HistoryView;
+import org.eclipse.osee.framework.ui.swt.Displays;
import org.eclipse.osee.framework.ui.swt.ImageManager;
import org.eclipse.osee.framework.ui.swt.NonmodalWizardDialog;
import org.eclipse.swt.layout.GridData;
@@ -813,7 +813,7 @@ public class MergeView extends ViewPart implements IActionable, IBranchEventList "Source Artifact Changed", showConflicts);
if (artifact.equals(conflict.getSourceArtifact()) && sender.isLocal()) {
new MessageDialog(
- Display.getDefault().getActiveShell().getShell(),
+ Displays.getActiveShell().getShell(),
"Modifying Source artifact while merging",
null,
"Typically changes done while merging should be done on the merge branch. You should not normally merge on the source branch.",
@@ -934,7 +934,7 @@ public class MergeView extends ViewPart implements IActionable, IBranchEventList "Source Artifact Changed", showConflicts);
if (artifact.equals(conflict.getSourceArtifact()) && sender.isLocal()) {
new MessageDialog(
- Display.getDefault().getActiveShell().getShell(),
+ Displays.getActiveShell().getShell(),
"Modifying Source artifact while merging",
null,
"Typically changes done while merging should be done on the merge branch. You should not normally merge on the source branch.",
diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/xmerge/MergeXViewer.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/xmerge/MergeXViewer.java index 1811ea5beea..ba4a8f042d1 100644 --- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/xmerge/MergeXViewer.java +++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/xmerge/MergeXViewer.java @@ -34,12 +34,12 @@ import org.eclipse.osee.framework.skynet.core.event.MergeBranchEventType; import org.eclipse.osee.framework.skynet.core.event.OseeEventManager;
import org.eclipse.osee.framework.skynet.core.event2.BranchEvent;
import org.eclipse.osee.framework.ui.plugin.util.AWorkbench;
-import org.eclipse.osee.framework.ui.plugin.util.Displays;
import org.eclipse.osee.framework.ui.skynet.ArtifactImageManager;
import org.eclipse.osee.framework.ui.skynet.SkynetGuiPlugin;
import org.eclipse.osee.framework.ui.skynet.compare.AttributeCompareItem;
import org.eclipse.osee.framework.ui.skynet.compare.CompareHandler;
import org.eclipse.osee.framework.ui.skynet.mergeWizard.ConflictResolutionWizard;
+import org.eclipse.osee.framework.ui.swt.Displays;
import org.eclipse.osee.framework.ui.swt.Widgets;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/xmerge/MergeXWidget.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/xmerge/MergeXWidget.java index 81348a194f0..4540cb63ed5 100644 --- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/xmerge/MergeXWidget.java +++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/xmerge/MergeXWidget.java @@ -50,7 +50,6 @@ import org.eclipse.osee.framework.skynet.core.types.IArtifact; import org.eclipse.osee.framework.ui.plugin.OseeUiActions;
import org.eclipse.osee.framework.ui.plugin.PluginUiImage;
import org.eclipse.osee.framework.ui.plugin.util.AWorkbench;
-import org.eclipse.osee.framework.ui.plugin.util.Displays;
import org.eclipse.osee.framework.ui.plugin.util.ListSelectionDialogNoSave;
import org.eclipse.osee.framework.ui.skynet.ArtifactImageManager;
import org.eclipse.osee.framework.ui.skynet.FrameworkImage;
@@ -61,6 +60,7 @@ import org.eclipse.osee.framework.ui.skynet.render.PresentationType; import org.eclipse.osee.framework.ui.skynet.render.RendererManager; import org.eclipse.osee.framework.ui.skynet.widgets.XWidget;
import org.eclipse.osee.framework.ui.swt.ALayout;
+import org.eclipse.osee.framework.ui.swt.Displays;
import org.eclipse.osee.framework.ui.swt.IDirtiableEditor;
import org.eclipse.osee.framework.ui.swt.ImageManager;
import org.eclipse.swt.SWT;
diff --git a/plugins/org.eclipse.osee.framework.ui.swt/src/org/eclipse/osee/framework/ui/swt/Displays.java b/plugins/org.eclipse.osee.framework.ui.swt/src/org/eclipse/osee/framework/ui/swt/Displays.java new file mode 100644 index 00000000000..ae0d6ae6097 --- /dev/null +++ b/plugins/org.eclipse.osee.framework.ui.swt/src/org/eclipse/osee/framework/ui/swt/Displays.java @@ -0,0 +1,66 @@ +/******************************************************************************* + * Copyright (c) 2004, 2007 Boeing. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Boeing - initial API and implementation + *******************************************************************************/ +package org.eclipse.osee.framework.ui.swt; + +import org.eclipse.swt.graphics.Color; +import org.eclipse.swt.widgets.Display; +import org.eclipse.swt.widgets.Shell; + +/** + * @author Robert A. Fisher + */ +public final class Displays { + + private Displays() { + } + + public static void ensureInDisplayThread(Runnable runnable) { + ensureInDisplayThread(runnable, false); + } + + public static void pendInDisplayThread(Runnable runnable) { + ensureInDisplayThread(runnable, true); + } + + public static void ensureInDisplayThread(Runnable runnable, boolean forcePend) { + if (isDisplayThread()) { + // No need to check for force since this will always pend + runnable.run(); + } else { + if (forcePend) { + Display.getDefault().syncExec(runnable); + } else { + Display.getDefault().asyncExec(runnable); + } + } + } + + public static boolean isDisplayThread() { + boolean isDisplayTh = false; + Display currentDisplay = Display.getCurrent(); + if (currentDisplay != null) { + isDisplayTh = currentDisplay.getThread() == Thread.currentThread(); + } + return isDisplayTh; + } + + public static Shell getActiveShell() { + return Displays.getActiveShell(); + } + + public static Color getSystemColor(int colorId) { + return Displays.getSystemColor(colorId); + } + + public static Color getColor(int red, int green, int blue) { + return new Color(Display.getDefault(), red, green, blue); + } +} diff --git a/plugins/org.eclipse.osee.framework.ui.swt/src/org/eclipse/osee/framework/ui/swt/FormattedText.java b/plugins/org.eclipse.osee.framework.ui.swt/src/org/eclipse/osee/framework/ui/swt/FormattedText.java index 4858dd074ba..09642a886fe 100644 --- a/plugins/org.eclipse.osee.framework.ui.swt/src/org/eclipse/osee/framework/ui/swt/FormattedText.java +++ b/plugins/org.eclipse.osee.framework.ui.swt/src/org/eclipse/osee/framework/ui/swt/FormattedText.java @@ -18,100 +18,100 @@ import org.eclipse.swt.custom.StyledText; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Display; /** * @author Roberto E. Escobar */ public class FormattedText extends Composite { - private List<StyleRange> styleArray; - private StyledText textArea; - private int height; - private int width; - private boolean editable; - - public FormattedText(Composite parent, int style) { - this(parent, style, 300, 300, false); - } - - public FormattedText(Composite parent, int style, boolean editable) { - this(parent, style, 300, 300, editable); - } - - public FormattedText(Composite parent, int style, int height, int width) { - this(parent, style, height, width, false); - } - - public FormattedText(Composite parent, int style, int height, int width, boolean editable) { - super(parent, style); - this.editable = editable; - this.height = height; - this.width = width; - this.styleArray = new ArrayList<StyleRange>(); - createTextArea(); - } - - private void createTextArea() { - this.setLayout(new GridLayout()); - this.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); - - textArea = new StyledText(this, SWT.MULTI | SWT.WRAP | SWT.V_SCROLL | SWT.H_SCROLL | SWT.BORDER); - GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true); - gd.heightHint = height; - gd.widthHint = width; - textArea.setLayoutData(gd); - textArea.setEditable(editable); - textArea.setBackground(Display.getDefault().getSystemColor(SWT.COLOR_WHITE)); - textArea.setBackground(Display.getDefault().getSystemColor(SWT.COLOR_GRAY)); - textArea.setText(""); - } - - public String[] getCmdList() { - return textArea.getText().split("\n"); - } - - public void setTextAreaBackground(final int swtColor) { - textArea.setBackground(Display.getDefault().getSystemColor(swtColor)); - } - - public StyledText getStyledText() { - return textArea; - } - - public void clearTextArea() { - textArea.setText(""); - styleArray.clear(); - } - - public void addText(String textToAdd) { - addText(textToAdd, SWT.NORMAL, SWT.COLOR_BLACK); - } - - public void addText(String textToAdd, int swtFontStyle, int swtColor) { - addText(textToAdd, swtFontStyle, swtColor, false); - } - - public void addText(String textToAdd, int swtFontStyle, int swtColor, boolean underline) { - if (textToAdd != null) { - String temp = textArea.getText(); - int startIndex = temp.length(); - temp += textToAdd; - textArea.setText(temp); - StyleRange tempStyle = new StyleRange(); - styleArray.add(tempStyle); - tempStyle.fontStyle = swtFontStyle; - tempStyle.start = startIndex; - tempStyle.length = textToAdd.length(); - tempStyle.underline = underline; - tempStyle.foreground = Display.getDefault().getSystemColor(swtColor); - textArea.setStyleRanges(styleArray.toArray(new StyleRange[styleArray.size()])); - textArea.redraw(); - } - } - - public void dispose() { - super.dispose(); - textArea.dispose(); - } + private final List<StyleRange> styleArray; + private StyledText textArea; + private final int height; + private final int width; + private final boolean editable; + + public FormattedText(Composite parent, int style) { + this(parent, style, 300, 300, false); + } + + public FormattedText(Composite parent, int style, boolean editable) { + this(parent, style, 300, 300, editable); + } + + public FormattedText(Composite parent, int style, int height, int width) { + this(parent, style, height, width, false); + } + + public FormattedText(Composite parent, int style, int height, int width, boolean editable) { + super(parent, style); + this.editable = editable; + this.height = height; + this.width = width; + this.styleArray = new ArrayList<StyleRange>(); + createTextArea(); + } + + private void createTextArea() { + this.setLayout(new GridLayout()); + this.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); + + textArea = new StyledText(this, SWT.MULTI | SWT.WRAP | SWT.V_SCROLL | SWT.H_SCROLL | SWT.BORDER); + GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true); + gd.heightHint = height; + gd.widthHint = width; + textArea.setLayoutData(gd); + textArea.setEditable(editable); + textArea.setBackground(Displays.getSystemColor(SWT.COLOR_WHITE)); + textArea.setBackground(Displays.getSystemColor(SWT.COLOR_GRAY)); + textArea.setText(""); + } + + public String[] getCmdList() { + return textArea.getText().split("\n"); + } + + public void setTextAreaBackground(final int swtColor) { + textArea.setBackground(Displays.getSystemColor(swtColor)); + } + + public StyledText getStyledText() { + return textArea; + } + + public void clearTextArea() { + textArea.setText(""); + styleArray.clear(); + } + + public void addText(String textToAdd) { + addText(textToAdd, SWT.NORMAL, SWT.COLOR_BLACK); + } + + public void addText(String textToAdd, int swtFontStyle, int swtColor) { + addText(textToAdd, swtFontStyle, swtColor, false); + } + + public void addText(String textToAdd, int swtFontStyle, int swtColor, boolean underline) { + if (textToAdd != null) { + String temp = textArea.getText(); + int startIndex = temp.length(); + temp += textToAdd; + textArea.setText(temp); + StyleRange tempStyle = new StyleRange(); + styleArray.add(tempStyle); + tempStyle.fontStyle = swtFontStyle; + tempStyle.start = startIndex; + tempStyle.length = textToAdd.length(); + tempStyle.underline = underline; + tempStyle.foreground = Displays.getSystemColor(swtColor); + textArea.setStyleRanges(styleArray.toArray(new StyleRange[styleArray.size()])); + textArea.redraw(); + } + } + + @Override + public void dispose() { + super.dispose(); + textArea.dispose(); + } } diff --git a/plugins/org.eclipse.osee.framework.ui.swt/src/org/eclipse/osee/framework/ui/swt/StackedViewer.java b/plugins/org.eclipse.osee.framework.ui.swt/src/org/eclipse/osee/framework/ui/swt/StackedViewer.java index 6c2be1a8e82..ec2692866a8 100644 --- a/plugins/org.eclipse.osee.framework.ui.swt/src/org/eclipse/osee/framework/ui/swt/StackedViewer.java +++ b/plugins/org.eclipse.osee.framework.ui.swt/src/org/eclipse/osee/framework/ui/swt/StackedViewer.java @@ -18,7 +18,6 @@ import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Label; /** @@ -26,80 +25,80 @@ import org.eclipse.swt.widgets.Label; */ public class StackedViewer extends Composite { - public static final String DEFAULT_CONTROL = "DEFAULT_CONTROL"; - private StackLayout stackLayout; - private Composite stackComposite; - private Map<String, Control> compositeMap; - - public StackedViewer(Composite parent, int style) { - super(parent, style); - compositeMap = new HashMap<String, Control>(); - create(); - } - - private void create() { - this.setLayout(new GridLayout()); - this.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); - - stackComposite = new Composite(this, SWT.NONE); - stackLayout = new StackLayout(); - stackLayout.marginHeight = 0; - stackLayout.marginWidth = 0; - stackComposite.setLayout(stackLayout); - stackComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); - - compositeMap.clear(); - compositeMap.put(DEFAULT_CONTROL, createDefault(stackComposite)); - - setCurrentControl(DEFAULT_CONTROL); - } - - public Control addControl(String key, Control control) { - return compositeMap.put(key, control); - } - - public Control removeControl(String key) { - return compositeMap.remove(key); - } - - public int getControlCount() { - return compositeMap.size() - 1; - } - - private Composite createDefault(Composite parent) { - Composite composite = new Composite(parent, SWT.NONE); - composite.setLayout(new GridLayout()); - composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); - composite.setBackground(Display.getDefault().getSystemColor(SWT.COLOR_INFO_BACKGROUND)); - - Label label = new Label(composite, SWT.NONE); - label.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); - label.setText("DEFAULT LAYER"); - label.setBackground(Display.getDefault().getSystemColor(SWT.COLOR_INFO_BACKGROUND)); - - return composite; - } - - public Composite getStackComposite() { - return stackComposite; - } - - public void setCurrentControl(String key) { - Control control = compositeMap.get(key); - if (control == null) { - control = compositeMap.get(DEFAULT_CONTROL); - } - stackLayout.topControl = control; - stackComposite.layout(); - } - - @Override - public void dispose() { - for (Control control : compositeMap.values()) { - Widgets.disposeWidget(control); - } - compositeMap.clear(); - Widgets.disposeWidget(stackComposite); - super.dispose(); - } + public static final String DEFAULT_CONTROL = "DEFAULT_CONTROL"; + private StackLayout stackLayout; + private Composite stackComposite; + private final Map<String, Control> compositeMap; + + public StackedViewer(Composite parent, int style) { + super(parent, style); + compositeMap = new HashMap<String, Control>(); + create(); + } + + private void create() { + this.setLayout(new GridLayout()); + this.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); + + stackComposite = new Composite(this, SWT.NONE); + stackLayout = new StackLayout(); + stackLayout.marginHeight = 0; + stackLayout.marginWidth = 0; + stackComposite.setLayout(stackLayout); + stackComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); + + compositeMap.clear(); + compositeMap.put(DEFAULT_CONTROL, createDefault(stackComposite)); + + setCurrentControl(DEFAULT_CONTROL); + } + + public Control addControl(String key, Control control) { + return compositeMap.put(key, control); + } + + public Control removeControl(String key) { + return compositeMap.remove(key); + } + + public int getControlCount() { + return compositeMap.size() - 1; + } + + private Composite createDefault(Composite parent) { + Composite composite = new Composite(parent, SWT.NONE); + composite.setLayout(new GridLayout()); + composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); + composite.setBackground(Displays.getSystemColor(SWT.COLOR_INFO_BACKGROUND)); + + Label label = new Label(composite, SWT.NONE); + label.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); + label.setText("DEFAULT LAYER"); + label.setBackground(Displays.getSystemColor(SWT.COLOR_INFO_BACKGROUND)); + + return composite; + } + + public Composite getStackComposite() { + return stackComposite; + } + + public void setCurrentControl(String key) { + Control control = compositeMap.get(key); + if (control == null) { + control = compositeMap.get(DEFAULT_CONTROL); + } + stackLayout.topControl = control; + stackComposite.layout(); + } + + @Override + public void dispose() { + for (Control control : compositeMap.values()) { + Widgets.disposeWidget(control); + } + compositeMap.clear(); + Widgets.disposeWidget(stackComposite); + super.dispose(); + } } diff --git a/plugins/org.eclipse.osee.framework.ui.swt/src/org/eclipse/osee/framework/ui/swt/hex/BasicHexTable.java b/plugins/org.eclipse.osee.framework.ui.swt/src/org/eclipse/osee/framework/ui/swt/hex/BasicHexTable.java index 4f6fdab03bf..68d69547f81 100644 --- a/plugins/org.eclipse.osee.framework.ui.swt/src/org/eclipse/osee/framework/ui/swt/hex/BasicHexTable.java +++ b/plugins/org.eclipse.osee.framework.ui.swt/src/org/eclipse/osee/framework/ui/swt/hex/BasicHexTable.java @@ -16,6 +16,7 @@ import org.eclipse.jface.viewers.ColumnViewerToolTipSupport; import org.eclipse.jface.viewers.TableViewer; import org.eclipse.jface.viewers.TableViewerColumn; import org.eclipse.jface.window.ToolTip; +import org.eclipse.osee.framework.ui.swt.Displays; import org.eclipse.swt.SWT; import org.eclipse.swt.layout.FillLayout; import org.eclipse.swt.widgets.Composite; @@ -27,85 +28,84 @@ import org.eclipse.swt.widgets.Shell; */ public class BasicHexTable extends HexTable { - /** - * @param shell - * @param array - * @param bytesPerRow - */ - public BasicHexTable(Composite parent, byte[] array, int bytesPerRow) { - super(parent, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL, array, bytesPerRow); - } + /** + * @param shell + * @param array + * @param bytesPerRow + */ + public BasicHexTable(Composite parent, byte[] array, int bytesPerRow) { + super(parent, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL, array, bytesPerRow); + } - @Override - protected void createAndConfigureColumns(TableViewer v, TableColumnLayout layout, int bytesPerRow) { - ColumnViewerToolTipSupport.enableFor(v, ToolTip.NO_RECREATE); - TableViewerColumn column = new TableViewerColumn(v, SWT.RIGHT); + @Override + protected void createAndConfigureColumns(TableViewer v, TableColumnLayout layout, int bytesPerRow) { + ColumnViewerToolTipSupport.enableFor(v, ToolTip.NO_RECREATE); + TableViewerColumn column = new TableViewerColumn(v, SWT.RIGHT); - column.setLabelProvider(new OffsetColumnLabelProvider()); - column.getColumn().setText("Offset"); - column.getColumn().setResizable(false); - column.getColumn().setMoveable(false); - layout.setColumnData(column.getColumn(), new ColumnPixelData(50)); - for (int i = 0; i < bytesPerRow; i++) { - TableViewerColumn c = new TableViewerColumn(v, SWT.LEFT); - c.setLabelProvider(createByteColumnLabelProvider(i)); - c.getColumn().setText(Integer.toHexString(i)); - c.getColumn().setResizable(false); - c.getColumn().setMoveable(false); - c.setEditingSupport(createHexEditingSupport(i)); - layout.setColumnData(c.getColumn(), new ColumnPixelData(26)); - } + column.setLabelProvider(new OffsetColumnLabelProvider()); + column.getColumn().setText("Offset"); + column.getColumn().setResizable(false); + column.getColumn().setMoveable(false); + layout.setColumnData(column.getColumn(), new ColumnPixelData(50)); + for (int i = 0; i < bytesPerRow; i++) { + TableViewerColumn c = new TableViewerColumn(v, SWT.LEFT); + c.setLabelProvider(createByteColumnLabelProvider(i)); + c.getColumn().setText(Integer.toHexString(i)); + c.getColumn().setResizable(false); + c.getColumn().setMoveable(false); + c.setEditingSupport(createHexEditingSupport(i)); + layout.setColumnData(c.getColumn(), new ColumnPixelData(26)); + } - TableViewerColumn divider = new TableViewerColumn(v, SWT.LEFT); - divider.getColumn().setResizable(false); - divider.setLabelProvider(new DividerLabel()); - layout.setColumnData(divider.getColumn(), new ColumnPixelData(1)); - for (int i = 0; i < bytesPerRow; i++) { - TableViewerColumn c = new TableViewerColumn(v, SWT.LEFT); + TableViewerColumn divider = new TableViewerColumn(v, SWT.LEFT); + divider.getColumn().setResizable(false); + divider.setLabelProvider(new DividerLabel()); + layout.setColumnData(divider.getColumn(), new ColumnPixelData(1)); + for (int i = 0; i < bytesPerRow; i++) { + TableViewerColumn c = new TableViewerColumn(v, SWT.LEFT); - c.setLabelProvider(new AsciiColumnLabelProvider(i)); - c.getColumn().setResizable(false); - c.getColumn().setMoveable(false); - layout.setColumnData(c.getColumn(), new ColumnPixelData(20)); - } - } + c.setLabelProvider(new AsciiColumnLabelProvider(i)); + c.getColumn().setResizable(false); + c.getColumn().setMoveable(false); + layout.setColumnData(c.getColumn(), new ColumnPixelData(20)); + } + } - /** - * @param args - */ - public static void main(String[] args) { - Display display = new Display(); - Shell shell = new Shell(display); - shell.setSize(500, 400); - shell.setLayout(new FillLayout()); - byte[] array = new byte[702]; - for (int i = 0; i < array.length; i++) { - array[i] = (byte) i; - } - int index = 50; - String str = "this is a test"; - array[48] = 3; - array[49] = 3; - for (byte b : str.getBytes()) { - array[index] = b; - index++; - } - array[index] = 3; - array[index + 1] = 3; - BasicHexTable t = new BasicHexTable(shell, array, 16); - shell.open(); - IHexTblHighlighter yellowHL = t.createHighlighter(30, 3, Display.getDefault().getSystemColor(SWT.COLOR_YELLOW)); - IHexTblHighlighter blueHL = - t.createHighlighter(50, str.length(), Display.getDefault().getSystemColor(SWT.COLOR_BLUE)); - yellowHL.highlight(); - blueHL.highlight(); - while (!shell.isDisposed()) { - if (!display.readAndDispatch()) { - display.sleep(); - } - } + /** + * @param args + */ + public static void main(String[] args) { + Display display = new Display(); + Shell shell = new Shell(display); + shell.setSize(500, 400); + shell.setLayout(new FillLayout()); + byte[] array = new byte[702]; + for (int i = 0; i < array.length; i++) { + array[i] = (byte) i; + } + int index = 50; + String str = "this is a test"; + array[48] = 3; + array[49] = 3; + for (byte b : str.getBytes()) { + array[index] = b; + index++; + } + array[index] = 3; + array[index + 1] = 3; + BasicHexTable t = new BasicHexTable(shell, array, 16); + shell.open(); + IHexTblHighlighter yellowHL = t.createHighlighter(30, 3, Displays.getSystemColor(SWT.COLOR_YELLOW)); + IHexTblHighlighter blueHL = t.createHighlighter(50, str.length(), Displays.getSystemColor(SWT.COLOR_BLUE)); + yellowHL.highlight(); + blueHL.highlight(); + while (!shell.isDisposed()) { + if (!display.readAndDispatch()) { + display.sleep(); + } + } - display.dispose(); + display.dispose(); - } + } } diff --git a/plugins/org.eclipse.osee.framework.ui.swt/src/org/eclipse/osee/framework/ui/swt/hex/DividerLabel.java b/plugins/org.eclipse.osee.framework.ui.swt/src/org/eclipse/osee/framework/ui/swt/hex/DividerLabel.java index ec39b03cf77..b58acc1edae 100644 --- a/plugins/org.eclipse.osee.framework.ui.swt/src/org/eclipse/osee/framework/ui/swt/hex/DividerLabel.java +++ b/plugins/org.eclipse.osee.framework.ui.swt/src/org/eclipse/osee/framework/ui/swt/hex/DividerLabel.java @@ -8,46 +8,50 @@ * Contributors: * Boeing - initial API and implementation *******************************************************************************/ -package org.eclipse.osee.framework.ui.swt.hex;
-
+package org.eclipse.osee.framework.ui.swt.hex; + import org.eclipse.jface.viewers.ColumnLabelProvider; +import org.eclipse.osee.framework.ui.swt.Displays; import org.eclipse.swt.SWT; import org.eclipse.swt.graphics.Color; import org.eclipse.swt.graphics.Point; -import org.eclipse.swt.widgets.Display; -
-public class DividerLabel extends ColumnLabelProvider {
-
- public DividerLabel() {
- super();
- }
-
- public String getToolTipText(Object element) {
-
- return null;
- }
-
- public Point getToolTipShift(Object object) {
- return new Point(12, 12);
- }
-
- public int getToolTipDisplayDelayTime(Object object) {
- return 125;
- }
-
- public int getToolTipTimeDisplayed(Object object) {
- return 5000;
- }
-
- @Override
- public Color getBackground(Object element) {
- return Display.getDefault().getSystemColor(SWT.COLOR_BLACK);
- }
-
- @Override
- public String getText(Object element) {
-
- return null;
- }
-
+ +public class DividerLabel extends ColumnLabelProvider { + + public DividerLabel() { + super(); + } + + @Override + public String getToolTipText(Object element) { + + return null; + } + + @Override + public Point getToolTipShift(Object object) { + return new Point(12, 12); + } + + @Override + public int getToolTipDisplayDelayTime(Object object) { + return 125; + } + + @Override + public int getToolTipTimeDisplayed(Object object) { + return 5000; + } + + @Override + public Color getBackground(Object element) { + return Displays.getSystemColor(SWT.COLOR_BLACK); + } + + @Override + public String getText(Object element) { + + return null; + } + }
\ No newline at end of file diff --git a/plugins/org.eclipse.osee.framework.ui.swt/src/org/eclipse/osee/framework/ui/swt/hex/HexEditingSupport.java b/plugins/org.eclipse.osee.framework.ui.swt/src/org/eclipse/osee/framework/ui/swt/hex/HexEditingSupport.java index bfb82841e9f..a17977bf35e 100644 --- a/plugins/org.eclipse.osee.framework.ui.swt/src/org/eclipse/osee/framework/ui/swt/hex/HexEditingSupport.java +++ b/plugins/org.eclipse.osee.framework.ui.swt/src/org/eclipse/osee/framework/ui/swt/hex/HexEditingSupport.java @@ -15,64 +15,64 @@ import org.eclipse.jface.viewers.CellEditor; import org.eclipse.jface.viewers.EditingSupport; import org.eclipse.jface.viewers.TableViewer; import org.eclipse.jface.viewers.TextCellEditor; +import org.eclipse.osee.framework.ui.swt.Displays; import org.eclipse.swt.SWT; import org.eclipse.swt.graphics.Font; import org.eclipse.swt.graphics.Rectangle; -import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Text; public class HexEditingSupport extends EditingSupport { - private final TextCellEditor textEditor; - private final int column; - private final TableViewer viewer; + private final TextCellEditor textEditor; + private final int column; + private final TableViewer viewer; - public HexEditingSupport(Font font, TableViewer viewer, int column) { - super(viewer); - this.viewer = viewer; - textEditor = new CustomTextCellEditor(viewer.getTable(), SWT.SINGLE); - ((Text) textEditor.getControl()).setTextLimit(2); - textEditor.getControl().setFont(font); - this.column = column; + public HexEditingSupport(Font font, TableViewer viewer, int column) { + super(viewer); + this.viewer = viewer; + textEditor = new CustomTextCellEditor(viewer.getTable(), SWT.SINGLE); + ((Text) textEditor.getControl()).setTextLimit(2); + textEditor.getControl().setFont(font); + this.column = column; - } + } - @Override - protected boolean canEdit(Object element) { - return ((HexTableRow) element).length > column; - } + @Override + protected boolean canEdit(Object element) { + return ((HexTableRow) element).length > column; + } - @Override - protected CellEditor getCellEditor(Object element) { - HexTableRow row = (HexTableRow) element; - int index = row.offset / row.length; - Rectangle rect = viewer.getTable().getItem(index).getBounds(column); - rect.width = 20; - textEditor.getControl().setBounds(rect); - return textEditor; - } + @Override + protected CellEditor getCellEditor(Object element) { + HexTableRow row = (HexTableRow) element; + int index = row.offset / row.length; + Rectangle rect = viewer.getTable().getItem(index).getBounds(column); + rect.width = 20; + textEditor.getControl().setBounds(rect); + return textEditor; + } - @Override - protected Object getValue(Object element) { - HexTableRow row = (HexTableRow) element; - return String.format("%02X", row.array[row.offset + column] & 0xFF); - } + @Override + protected Object getValue(Object element) { + HexTableRow row = (HexTableRow) element; + return String.format("%02X", row.array[row.offset + column] & 0xFF); + } - @Override - protected void setValue(Object element, Object value) { - HexTableRow row = (HexTableRow) element; - String strValue = value.toString(); - int val; - try { - val = Integer.parseInt(strValue, 16); - if (val >= 0 && val <= 255) { - row.array[row.offset + column] = (byte) val; - getViewer().update(row, null); - } else { - throw new NumberFormatException("value out of range. Must be between 00 and FF"); - } - } catch (NumberFormatException e) { - MessageDialog.openError(Display.getDefault().getActiveShell(), "Numeric Entry Error", e.getMessage()); - } - } + @Override + protected void setValue(Object element, Object value) { + HexTableRow row = (HexTableRow) element; + String strValue = value.toString(); + int val; + try { + val = Integer.parseInt(strValue, 16); + if (val >= 0 && val <= 255) { + row.array[row.offset + column] = (byte) val; + getViewer().update(row, null); + } else { + throw new NumberFormatException("value out of range. Must be between 00 and FF"); + } + } catch (NumberFormatException e) { + MessageDialog.openError(Displays.getActiveShell(), "Numeric Entry Error", e.getMessage()); + } + } }
\ No newline at end of file diff --git a/plugins/org.eclipse.osee.framework.ui.swt/src/org/eclipse/osee/framework/ui/swt/hex/OffsetColumnLabelProvider.java b/plugins/org.eclipse.osee.framework.ui.swt/src/org/eclipse/osee/framework/ui/swt/hex/OffsetColumnLabelProvider.java index b7628a2d52f..05662f8e6fd 100644 --- a/plugins/org.eclipse.osee.framework.ui.swt/src/org/eclipse/osee/framework/ui/swt/hex/OffsetColumnLabelProvider.java +++ b/plugins/org.eclipse.osee.framework.ui.swt/src/org/eclipse/osee/framework/ui/swt/hex/OffsetColumnLabelProvider.java @@ -11,41 +11,41 @@ package org.eclipse.osee.framework.ui.swt.hex; import org.eclipse.jface.viewers.ColumnLabelProvider; +import org.eclipse.osee.framework.ui.swt.Displays; import org.eclipse.osee.framework.ui.swt.FontManager; import org.eclipse.swt.SWT; import org.eclipse.swt.graphics.Color; import org.eclipse.swt.graphics.Font; -import org.eclipse.swt.widgets.Display; public class OffsetColumnLabelProvider extends ColumnLabelProvider { - public OffsetColumnLabelProvider() { - super(); - } - - @Override - public String getText(Object element) { - return Integer.toString(((HexTableRow) element).getOffset()); - } - - @Override - public Color getBackground(Object element) { - return Display.getDefault().getSystemColor(SWT.COLOR_YELLOW); - } - - @Override - public Color getForeground(Object element) { - return Display.getDefault().getSystemColor(SWT.COLOR_BLACK); - } - - @Override - public Font getFont(Object element) { - return FontManager.getCourierNew8(); - } - - @Override - public void dispose() { - super.dispose(); - } + public OffsetColumnLabelProvider() { + super(); + } + + @Override + public String getText(Object element) { + return Integer.toString(((HexTableRow) element).getOffset()); + } + + @Override + public Color getBackground(Object element) { + return Displays.getSystemColor(SWT.COLOR_YELLOW); + } + + @Override + public Color getForeground(Object element) { + return Displays.getSystemColor(SWT.COLOR_BLACK); + } + + @Override + public Font getFont(Object element) { + return FontManager.getCourierNew8(); + } + + @Override + public void dispose() { + super.dispose(); + } }
\ No newline at end of file diff --git a/plugins/org.eclipse.osee.framework.ui.workspacebundleloader/META-INF/MANIFEST.MF b/plugins/org.eclipse.osee.framework.ui.workspacebundleloader/META-INF/MANIFEST.MF index 7a655424fec..13641a062de 100644 --- a/plugins/org.eclipse.osee.framework.ui.workspacebundleloader/META-INF/MANIFEST.MF +++ b/plugins/org.eclipse.osee.framework.ui.workspacebundleloader/META-INF/MANIFEST.MF @@ -14,6 +14,7 @@ Import-Package: org.eclipse.core.resources, org.eclipse.osee.framework.logging, org.eclipse.osee.framework.plugin.core.util, org.eclipse.osee.framework.ui.plugin.workspace, + org.eclipse.osee.framework.ui.swt, org.eclipse.swt.widgets, org.eclipse.ui, org.osgi.framework, diff --git a/plugins/org.eclipse.osee.framework.ui.workspacebundleloader/src/org/eclipse/osee/framework/ui/workspacebundleloader/EarlyStartup.java b/plugins/org.eclipse.osee.framework.ui.workspacebundleloader/src/org/eclipse/osee/framework/ui/workspacebundleloader/EarlyStartup.java index de9a429873d..9879687c802 100644 --- a/plugins/org.eclipse.osee.framework.ui.workspacebundleloader/src/org/eclipse/osee/framework/ui/workspacebundleloader/EarlyStartup.java +++ b/plugins/org.eclipse.osee.framework.ui.workspacebundleloader/src/org/eclipse/osee/framework/ui/workspacebundleloader/EarlyStartup.java @@ -13,8 +13,8 @@ package org.eclipse.osee.framework.ui.workspacebundleloader; import java.util.logging.Level; import org.eclipse.core.runtime.Platform; import org.eclipse.osee.framework.logging.OseeLog; +import org.eclipse.osee.framework.ui.swt.Displays; import org.eclipse.osee.framework.ui.workspacebundleloader.internal.Activator; -import org.eclipse.swt.widgets.Display; import org.eclipse.ui.IStartup; import org.osgi.framework.Bundle; import org.osgi.framework.BundleException; @@ -24,23 +24,23 @@ import org.osgi.framework.BundleException; */ public class EarlyStartup implements IStartup { - private SafeWorkspaceTracker workspaceTracker; + private SafeWorkspaceTracker workspaceTracker; - @Override - public void earlyStartup() { - Display.getDefault().asyncExec(new Runnable() { - @Override - public void run() { - try { - Bundle bundle = Platform.getBundle("org.eclipse.osee.framework.ui.workspacebundleloader"); - bundle.start(); - workspaceTracker = new SafeWorkspaceTracker(bundle.getBundleContext()); - workspaceTracker.open(true); - } catch (BundleException ex) { - OseeLog.log(Activator.class, Level.SEVERE, ex); - } - } - }); + @Override + public void earlyStartup() { + Displays.ensureInDisplayThread(new Runnable() { + @Override + public void run() { + try { + Bundle bundle = Platform.getBundle("org.eclipse.osee.framework.ui.workspacebundleloader"); + bundle.start(); + workspaceTracker = new SafeWorkspaceTracker(bundle.getBundleContext()); + workspaceTracker.open(true); + } catch (BundleException ex) { + OseeLog.log(Activator.class, Level.SEVERE, ex); + } + } + }); - } + } } diff --git a/plugins/org.eclipse.osee.framework.ui.workspacebundleloader/src/org/eclipse/osee/framework/ui/workspacebundleloader/FileChangeDetector.java b/plugins/org.eclipse.osee.framework.ui.workspacebundleloader/src/org/eclipse/osee/framework/ui/workspacebundleloader/FileChangeDetector.java index ad88a273116..3267ea5f934 100644 --- a/plugins/org.eclipse.osee.framework.ui.workspacebundleloader/src/org/eclipse/osee/framework/ui/workspacebundleloader/FileChangeDetector.java +++ b/plugins/org.eclipse.osee.framework.ui.workspacebundleloader/src/org/eclipse/osee/framework/ui/workspacebundleloader/FileChangeDetector.java @@ -8,83 +8,74 @@ * Contributors: * Boeing - initial API and implementation *******************************************************************************/ -package org.eclipse.osee.framework.ui.workspacebundleloader;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.URL;
-import java.security.NoSuchAlgorithmException;
-import java.util.Arrays;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.logging.Level;
-
-import org.eclipse.osee.framework.jdk.core.util.ChecksumUtil;
-import org.eclipse.osee.framework.logging.OseeLog;
-
-/**
- * @author Andrew M. Finkbeiner
- *
- */
-public class FileChangeDetector {
-
- private ConcurrentHashMap<URL, byte[]> bundleNameToMd5Map;
-
- public FileChangeDetector(){
- bundleNameToMd5Map = new ConcurrentHashMap<URL, byte[]>();
- }
-
- public boolean isChanged(URL url) {
- byte[] digest = getMd5Checksum(url);
- if (bundleNameToMd5Map.containsKey(url)) {
- // check for bundle binary equality
- if (!Arrays.equals(bundleNameToMd5Map.get(url), digest)) {
- bundleNameToMd5Map.put(url, digest);
- return true;
- } else {
- return false;
- }
- } else {
- bundleNameToMd5Map.put(url, digest);
- return true;
- }
- }
-
- private byte[] getMd5Checksum(URL url) {
- InputStream in = null;
- byte[] digest = new byte[0];
- try {
- in = url.openStream();
- digest = ChecksumUtil.createChecksum(url.openStream(), "MD5");
- } catch (IOException ex) {
- OseeLog.log(FileChangeDetector.class, Level.SEVERE, ex);
- } catch (NoSuchAlgorithmException ex) {
- OseeLog.log(FileChangeDetector.class, Level.SEVERE, ex);
- } finally {
- if (in != null) {
- try {
- in.close();
- } catch (IOException ex) {
- OseeLog.log(FileChangeDetector.class, Level.SEVERE, ex);
- }
- }
- }
- return digest;
- }
-
- /**
- * @param url
- * @return
- */
- public boolean remove(URL url) {
- bundleNameToMd5Map.remove(url);
- return true;
- }
-
- /**
- *
- */
- public void clear() {
- bundleNameToMd5Map.clear();
- }
-
-}
+package org.eclipse.osee.framework.ui.workspacebundleloader; + +import java.io.IOException; +import java.io.InputStream; +import java.net.URL; +import java.security.NoSuchAlgorithmException; +import java.util.Arrays; +import java.util.concurrent.ConcurrentHashMap; +import java.util.logging.Level; +import org.eclipse.osee.framework.jdk.core.util.ChecksumUtil; +import org.eclipse.osee.framework.logging.OseeLog; + +/** + * @author Andrew M. Finkbeiner + */ +public class FileChangeDetector { + + private final ConcurrentHashMap<URL, byte[]> bundleNameToMd5Map; + + public FileChangeDetector() { + bundleNameToMd5Map = new ConcurrentHashMap<URL, byte[]>(); + } + + public boolean isChanged(URL url) { + byte[] digest = getMd5Checksum(url); + if (bundleNameToMd5Map.containsKey(url)) { + // check for bundle binary equality + if (!Arrays.equals(bundleNameToMd5Map.get(url), digest)) { + bundleNameToMd5Map.put(url, digest); + return true; + } else { + return false; + } + } else { + bundleNameToMd5Map.put(url, digest); + return true; + } + } + + private byte[] getMd5Checksum(URL url) { + InputStream in = null; + byte[] digest = new byte[0]; + try { + in = url.openStream(); + digest = ChecksumUtil.createChecksum(url.openStream(), "MD5"); + } catch (IOException ex) { + OseeLog.log(FileChangeDetector.class, Level.SEVERE, ex); + } catch (NoSuchAlgorithmException ex) { + OseeLog.log(FileChangeDetector.class, Level.SEVERE, ex); + } finally { + if (in != null) { + try { + in.close(); + } catch (IOException ex) { + OseeLog.log(FileChangeDetector.class, Level.SEVERE, ex); + } + } + } + return digest; + } + + public boolean remove(URL url) { + bundleNameToMd5Map.remove(url); + return true; + } + + public void clear() { + bundleNameToMd5Map.clear(); + } + +} diff --git a/plugins/org.eclipse.osee.framework.ui.workspacebundleloader/src/org/eclipse/osee/framework/ui/workspacebundleloader/JarCollectionNature.java b/plugins/org.eclipse.osee.framework.ui.workspacebundleloader/src/org/eclipse/osee/framework/ui/workspacebundleloader/JarCollectionNature.java index 75103491487..357ad000964 100644 --- a/plugins/org.eclipse.osee.framework.ui.workspacebundleloader/src/org/eclipse/osee/framework/ui/workspacebundleloader/JarCollectionNature.java +++ b/plugins/org.eclipse.osee.framework.ui.workspacebundleloader/src/org/eclipse/osee/framework/ui/workspacebundleloader/JarCollectionNature.java @@ -8,8 +8,8 @@ * Contributors: * Boeing - initial API and implementation *******************************************************************************/ -package org.eclipse.osee.framework.ui.workspacebundleloader;
-
+package org.eclipse.osee.framework.ui.workspacebundleloader; + import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; @@ -21,10 +21,9 @@ import java.util.ArrayList; import java.util.Collection; import java.util.LinkedList; import java.util.jar.Attributes; -import java.util.jar.Manifest; import java.util.jar.Attributes.Name; +import java.util.jar.Manifest; import java.util.logging.Level; - import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IProjectNature; import org.eclipse.core.resources.IWorkspace; @@ -34,150 +33,147 @@ import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.Path; import org.eclipse.osee.framework.logging.OseeLog; -
-/**
- * @author Robert A. Fisher
- */
-public class JarCollectionNature implements IProjectNature {
-
- private final Name BUNDLE_PATH_ATTRIBUTE; - private boolean isClosing;
-
- protected IProject project;
-
- /**
- * @param BUNDLE_PATH_ATTRIBUTE the name of the attribute in the MANIFEST.MF to look at when looking for the path to
- * the jars being provided.
- */
- public JarCollectionNature(String BUNDLE_PATH_ATTRIBUTE) {
- super();
- this.BUNDLE_PATH_ATTRIBUTE = new Name(BUNDLE_PATH_ATTRIBUTE); - this.isClosing = false;
- } - -
- /** - * @return the isClosing - */ - public boolean isClosing() { - return isClosing; - } - - - /** - * @param isClosing the isClosing to set - */ - public void setClosing(boolean isClosing) { - this.isClosing = isClosing; - } - - - @Override
- public void configure() throws CoreException {
- }
-
- @Override
- public void deconfigure() throws CoreException {
- }
-
- @Override
- public IProject getProject() {
- return project;
- }
-
- @Override
- public void setProject(IProject project) {
- this.project = project;
- }
-
- public Collection<URL> getBundles() { - Collection<URL> urls = new ArrayList<URL>();
- - if( isClosing ) { - return urls; - }
- - IPath[] paths = getProjectRelativeBundlePaths();
- for (IPath path : paths) {
- IPath pluginsPath = project.getLocation().append(path);
- File pluginDir = pluginsPath.toFile();
- File[] jars = pluginDir.listFiles(new FilenameFilter() {
- @Override
- public boolean accept(File dir, String name) {
- return name.endsWith(".jar");
- }
- });
-
- if (jars != null) {
- for (File jar : jars) {
- try {
- urls.add(jar.toURI().toURL());
- } catch (MalformedURLException ex) {
- OseeLog.log(JarCollectionNature.class, Level.SEVERE, ex);
- }
- }
- }
- }
- return urls;
- }
-
- public IPath[] getProjectRelativeBundlePaths() {
- Manifest manifest = getManifestFile();
- Path[] paths;
- Attributes mainAttributes = manifest.getMainAttributes();
- String pathString;
- if (mainAttributes.containsKey(BUNDLE_PATH_ATTRIBUTE)) {
- pathString = mainAttributes.getValue(BUNDLE_PATH_ATTRIBUTE);
- String[] tempPaths = pathString.split(",");
- paths = new Path[tempPaths.length];
- for (int i = 0; i < paths.length; i++) {
- paths[i] = new Path(tempPaths[i].trim());
- }
- } else {
- paths = new Path[1];
- paths[0] = new Path("plugins");
- }
- return paths;
- }
-
- /**
- * @param manifestFile
- * @return
- * @throws IOException
- * @throws FileNotFoundException
- */
- private Manifest getManifestFile() {
- try {
- File manifestFile = project.getLocation().append("META-INF").append("MANIFEST.MF").toFile();
- if (manifestFile.exists()) {
- return new Manifest(new FileInputStream(manifestFile));
- } else {
- return null;
- }
- } catch (Exception ex) {
- ex.printStackTrace();
- return null;
- }
- }
-
- @SuppressWarnings("unchecked")
- protected static <T extends JarCollectionNature> Collection<T> getWorkspaceProjects(String natureId, Class<T> clazz) throws CoreException {
- IWorkspace workspace = ResourcesPlugin.getWorkspace();
- IWorkspaceRoot workspaceRoot = workspace.getRoot();
- IProject[] projects = workspaceRoot.getProjects();
-
- Collection<T> natures = new LinkedList<T>();
-
- for (IProject project : projects) {
- if (project.isOpen()) {
- IProjectNature nature = project.getNature(natureId);
- if (nature != null) {
- JarCollectionNature jarNature = (JarCollectionNature) nature;
- natures.add((T) jarNature);
- }
- }
- }
-
- return natures;
- }
+ +/** + * @author Robert A. Fisher + */ +public class JarCollectionNature implements IProjectNature { + + private final Name BUNDLE_PATH_ATTRIBUTE; + private boolean isClosing; + + protected IProject project; + + /** + * @param BUNDLE_PATH_ATTRIBUTE the name of the attribute in the MANIFEST.MF to look at when looking for the path to + * the jars being provided. + */ + public JarCollectionNature(String BUNDLE_PATH_ATTRIBUTE) { + super(); + this.BUNDLE_PATH_ATTRIBUTE = new Name(BUNDLE_PATH_ATTRIBUTE); + this.isClosing = false; + } + + /** + * @return the isClosing + */ + public boolean isClosing() { + return isClosing; + } + + /** + * @param isClosing the isClosing to set + */ + public void setClosing(boolean isClosing) { + this.isClosing = isClosing; + } + + @Override + public void configure() { + } + + @Override + public void deconfigure() { + } + + @Override + public IProject getProject() { + return project; + } + + @Override + public void setProject(IProject project) { + this.project = project; + } + + public Collection<URL> getBundles() { + Collection<URL> urls = new ArrayList<URL>(); + + if (isClosing) { + return urls; + } + + IPath[] paths = getProjectRelativeBundlePaths(); + for (IPath path : paths) { + IPath pluginsPath = project.getLocation().append(path); + File pluginDir = pluginsPath.toFile(); + File[] jars = pluginDir.listFiles(new FilenameFilter() { + @Override + public boolean accept(File dir, String name) { + return name.endsWith(".jar"); + } + }); + + if (jars != null) { + for (File jar : jars) { + try { + urls.add(jar.toURI().toURL()); + } catch (MalformedURLException ex) { + OseeLog.log(JarCollectionNature.class, Level.SEVERE, ex); + } + } + } + } + return urls; + } + + public IPath[] getProjectRelativeBundlePaths() { + Manifest manifest = getManifestFile(); + Path[] paths; + Attributes mainAttributes = manifest.getMainAttributes(); + String pathString; + if (mainAttributes.containsKey(BUNDLE_PATH_ATTRIBUTE)) { + pathString = mainAttributes.getValue(BUNDLE_PATH_ATTRIBUTE); + String[] tempPaths = pathString.split(","); + paths = new Path[tempPaths.length]; + for (int i = 0; i < paths.length; i++) { + paths[i] = new Path(tempPaths[i].trim()); + } + } else { + paths = new Path[1]; + paths[0] = new Path("plugins"); + } + return paths; + } + + /** + * @param manifestFile + * @return + * @throws IOException + * @throws FileNotFoundException + */ + private Manifest getManifestFile() { + try { + File manifestFile = project.getLocation().append("META-INF").append("MANIFEST.MF").toFile(); + if (manifestFile.exists()) { + return new Manifest(new FileInputStream(manifestFile)); + } else { + return null; + } + } catch (Exception ex) { + ex.printStackTrace(); + return null; + } + } + + @SuppressWarnings("unchecked") + protected static <T extends JarCollectionNature> Collection<T> getWorkspaceProjects(String natureId, Class<T> clazz) throws CoreException { + IWorkspace workspace = ResourcesPlugin.getWorkspace(); + IWorkspaceRoot workspaceRoot = workspace.getRoot(); + IProject[] projects = workspaceRoot.getProjects(); + + Collection<T> natures = new LinkedList<T>(); + + for (IProject project : projects) { + if (project.isOpen()) { + IProjectNature nature = project.getNature(natureId); + if (nature != null) { + JarCollectionNature jarNature = (JarCollectionNature) nature; + natures.add((T) jarNature); + } + } + } + + return natures; + } }
\ No newline at end of file diff --git a/plugins/org.eclipse.osee.framework.ui.workspacebundleloader/src/org/eclipse/osee/framework/ui/workspacebundleloader/SafeWorkspaceTracker.java b/plugins/org.eclipse.osee.framework.ui.workspacebundleloader/src/org/eclipse/osee/framework/ui/workspacebundleloader/SafeWorkspaceTracker.java index bf62898f2bc..9ac15b99548 100644 --- a/plugins/org.eclipse.osee.framework.ui.workspacebundleloader/src/org/eclipse/osee/framework/ui/workspacebundleloader/SafeWorkspaceTracker.java +++ b/plugins/org.eclipse.osee.framework.ui.workspacebundleloader/src/org/eclipse/osee/framework/ui/workspacebundleloader/SafeWorkspaceTracker.java @@ -17,7 +17,6 @@ import java.util.Iterator; import java.util.LinkedList; import java.util.Map; import java.util.logging.Level; - import org.eclipse.core.resources.IWorkspace; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IProgressMonitor; @@ -36,17 +35,16 @@ import org.osgi.util.tracker.ServiceTracker; /** * @author Andrew M. Finkbeiner */ -public class SafeWorkspaceTracker extends ServiceTracker implements - IJarChangeListener<WorkspaceStarterNature>, WorkspaceLoader { +public class SafeWorkspaceTracker extends ServiceTracker implements IJarChangeListener<WorkspaceStarterNature>, WorkspaceLoader { private final Map<String, Bundle> installedBundles; private final Map<String, Bundle> runningBundles; private final Collection<Bundle> stoppedBundles; - private JarChangeResourceListener workspaceListener; + private JarChangeResourceListener<WorkspaceStarterNature> workspaceListener; private SafeWorkspaceAccess service; - private ServiceTracker packageAdminTracker; + private final ServiceTracker packageAdminTracker; - private FileChangeDetector detector = new FileChangeDetector(); + private final FileChangeDetector detector = new FileChangeDetector(); /** * @param context @@ -56,8 +54,7 @@ public class SafeWorkspaceTracker extends ServiceTracker implements public SafeWorkspaceTracker(BundleContext context) { super(context, SafeWorkspaceAccess.class.getName(), null); - packageAdminTracker = new ServiceTracker(context, PackageAdmin.class - .getName(), null); + packageAdminTracker = new ServiceTracker(context, PackageAdmin.class.getName(), null); packageAdminTracker.open(true); this.installedBundles = new HashMap<String, Bundle>(); @@ -75,8 +72,7 @@ public class SafeWorkspaceTracker extends ServiceTracker implements } void setupWorkspaceBundleLoadingAfterBenchStartup() { - Jobs.runInJob(new PrecompileStartup("Loading Precompiled Libraries", - Activator.BUNDLE_ID), false); + Jobs.runInJob(new PrecompileStartup("Loading Precompiled Libraries", Activator.BUNDLE_ID), false); } private class PrecompileStartup extends AbstractOperation { @@ -91,14 +87,13 @@ public class SafeWorkspaceTracker extends ServiceTracker implements @Override protected void doWork(IProgressMonitor monitor) throws Exception { IWorkspace workspace = service.getWorkspace(); - workspaceListener = new JarChangeResourceListener<WorkspaceStarterNature>( - WorkspaceStarterNature.NATURE_ID, SafeWorkspaceTracker.this); + workspaceListener = + new JarChangeResourceListener<WorkspaceStarterNature>(WorkspaceStarterNature.NATURE_ID, + SafeWorkspaceTracker.this); try { installWorkspacePlugins(); } catch (CoreException ex) { OseeLog.log(Activator.class, Level.SEVERE, ex); - } catch (BundleException ex) { - OseeLog.log(Activator.class, Level.SEVERE, ex); } workspace.addResourceChangeListener(workspaceListener); } @@ -154,9 +149,7 @@ public class SafeWorkspaceTracker extends ServiceTracker implements * @throws BundleException * @throws BundleException */ - private void installWorkspacePlugins() throws CoreException, - BundleException { - + private void installWorkspacePlugins() throws CoreException { loadBundles(); } @@ -191,8 +184,7 @@ public class SafeWorkspaceTracker extends ServiceTracker implements // Check to see if this is the first we've seen this if (runningBundles.containsKey(urlString)) { Bundle bundle = runningBundles.get(urlString); - System.out.println("\tUpdating plugin " - + bundle.getSymbolicName()); + System.out.println("\tUpdating plugin " + bundle.getSymbolicName()); bundle.update(); } else { @@ -215,8 +207,7 @@ public class SafeWorkspaceTracker extends ServiceTracker implements String urlString = url.toString(); if (runningBundles.containsKey(urlString)) { Bundle bundle = runningBundles.get(urlString); - System.out.println("\tStopping plugin " - + bundle.getSymbolicName()); + System.out.println("\tStopping plugin " + bundle.getSymbolicName()); bundle.stop(); runningBundles.remove(urlString); @@ -229,7 +220,7 @@ public class SafeWorkspaceTracker extends ServiceTracker implements /** * @throws BundleException */ - private void transitionInstalledPlugins() throws BundleException { + private void transitionInstalledPlugins() { Iterator<String> iter = installedBundles.keySet().iterator(); while (iter.hasNext()) { String urlString = iter.next(); @@ -249,8 +240,7 @@ public class SafeWorkspaceTracker extends ServiceTracker implements * */ private void refreshPackages() { - PackageAdmin packageAdmin = (PackageAdmin) packageAdminTracker - .getService(); + PackageAdmin packageAdmin = (PackageAdmin) packageAdminTracker.getService(); packageAdmin.refreshPackages(null); // try { // Thread.sleep(10000); @@ -261,7 +251,7 @@ public class SafeWorkspaceTracker extends ServiceTracker implements /** * @throws BundleException */ - private void transitionStoppedBundles() throws BundleException { + private void transitionStoppedBundles() { Iterator<Bundle> iter = stoppedBundles.iterator(); while (iter.hasNext()) { Bundle bundle = iter.next(); @@ -278,11 +268,8 @@ public class SafeWorkspaceTracker extends ServiceTracker implements @Override public void handlePostChange() { - try { - transitionInstalledPlugins(); - transitionStoppedBundles(); - } catch (BundleException ex) { - } + transitionInstalledPlugins(); + transitionStoppedBundles(); } @Override @@ -300,15 +287,12 @@ public class SafeWorkspaceTracker extends ServiceTracker implements handleBundleRemoved(url); } - try { - transitionStoppedBundles(); - } catch (BundleException ex) { - } + transitionStoppedBundles(); } - public void loadBundles() throws CoreException, BundleException { - for (WorkspaceStarterNature starterNature : WorkspaceStarterNature - .getWorkspaceProjects()) { + @Override + public void loadBundles() throws CoreException { + for (WorkspaceStarterNature starterNature : WorkspaceStarterNature.getWorkspaceProjects()) { for (URL url : starterNature.getBundles()) { try { handleBundleAdded(url); @@ -321,6 +305,7 @@ public class SafeWorkspaceTracker extends ServiceTracker implements transitionInstalledPlugins(); } + @Override public void unloadBundles() { cleanupHandledBundles(); } diff --git a/plugins/org.eclipse.osee.framework.ui.workspacebundleloader/src/org/eclipse/osee/framework/ui/workspacebundleloader/internal/Activator.java b/plugins/org.eclipse.osee.framework.ui.workspacebundleloader/src/org/eclipse/osee/framework/ui/workspacebundleloader/internal/Activator.java index 215d8521b75..6c528c39635 100644 --- a/plugins/org.eclipse.osee.framework.ui.workspacebundleloader/src/org/eclipse/osee/framework/ui/workspacebundleloader/internal/Activator.java +++ b/plugins/org.eclipse.osee.framework.ui.workspacebundleloader/src/org/eclipse/osee/framework/ui/workspacebundleloader/internal/Activator.java @@ -18,12 +18,14 @@ import org.osgi.framework.BundleContext; */
public class Activator implements BundleActivator {
- public static final String BUNDLE_ID = "org.eclipse.osee.framework.ui.workspacebundleloader";
+ public static final String BUNDLE_ID = "org.eclipse.osee.framework.ui.workspacebundleloader";
-public void start(BundleContext context) throws Exception {
- }
+ @Override
+ public void start(BundleContext context) throws Exception {
+ }
- public void stop(BundleContext context) throws Exception {
- }
+ @Override
+ public void stop(BundleContext context) throws Exception {
+ }
}
|