diff options
author | ddunne | 2008-10-31 21:16:32 +0000 |
---|---|---|
committer | ddunne | 2008-10-31 21:16:32 +0000 |
commit | 31a2211bac2a6081fe553c1f66585bb20f9bb862 (patch) | |
tree | 83455e07a6ff144bc40fde2b274dc1866c5b6f37 /org.eclipse.osee.framework.ui.skynet | |
parent | 453389d855027e2f8490921668686221023e7261 (diff) | |
download | org.eclipse.osee-31a2211bac2a6081fe553c1f66585bb20f9bb862.tar.gz org.eclipse.osee-31a2211bac2a6081fe553c1f66585bb20f9bb862.tar.xz org.eclipse.osee-31a2211bac2a6081fe553c1f66585bb20f9bb862.zip |
"Team Workflow" - TTL2L - "Branch selection dialog doesn't sort by favorites"
Diffstat (limited to 'org.eclipse.osee.framework.ui.skynet')
13 files changed, 491 insertions, 427 deletions
diff --git a/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/ArtifactExplorer.java b/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/ArtifactExplorer.java index b94536cd19d..ee61f1105fa 100644 --- a/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/ArtifactExplorer.java +++ b/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/ArtifactExplorer.java @@ -82,6 +82,7 @@ import org.eclipse.osee.framework.ui.skynet.artifact.editor.ArtifactEditor; import org.eclipse.osee.framework.ui.skynet.artifact.massEditor.MassArtifactEditor;
import org.eclipse.osee.framework.ui.skynet.ats.IActionable;
import org.eclipse.osee.framework.ui.skynet.ats.OseeAts;
+import org.eclipse.osee.framework.ui.skynet.branch.BranchSelectionDialog;
import org.eclipse.osee.framework.ui.skynet.history.RevisionHistoryView;
import org.eclipse.osee.framework.ui.skynet.menu.ArtifactPreviewMenu;
import org.eclipse.osee.framework.ui.skynet.menu.ArtifactTreeViewerGlobalMenuHelper;
@@ -91,7 +92,6 @@ import org.eclipse.osee.framework.ui.skynet.menu.IGlobalMenuHelper; import org.eclipse.osee.framework.ui.skynet.render.RendererManager;
import org.eclipse.osee.framework.ui.skynet.skywalker.SkyWalkerView;
import org.eclipse.osee.framework.ui.skynet.util.ArtifactClipboard;
-import org.eclipse.osee.framework.ui.skynet.util.BranchSelectionDialog;
import org.eclipse.osee.framework.ui.skynet.util.DbConnectionExceptionComposite;
import org.eclipse.osee.framework.ui.skynet.util.HierarchicalReportDialog;
import org.eclipse.osee.framework.ui.skynet.util.HtmlReportJob;
@@ -438,7 +438,7 @@ public class ArtifactExplorer extends ViewPart implements IAccessControlEventLis Action setDefaultBranch = new Action("Set Default Branch", Action.AS_PUSH_BUTTON) {
@Override
public void run() {
- BranchSelectionDialog branchSelection = new BranchSelectionDialog("Set Default Branch");
+ BranchSelectionDialog branchSelection = new BranchSelectionDialog("Set Default Branch", false);
int result = branchSelection.open();
if (result == Window.OK) {
BranchManager.setDefaultBranch(branchSelection.getSelection());
diff --git a/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/Import/ArtifactImportPage.java b/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/Import/ArtifactImportPage.java index 00a0ddaf31f..4d858b3a3bc 100644 --- a/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/Import/ArtifactImportPage.java +++ b/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/Import/ArtifactImportPage.java @@ -28,6 +28,7 @@ import org.eclipse.osee.framework.skynet.core.artifact.BranchManager; import org.eclipse.osee.framework.skynet.core.attribute.TypeValidityManager; import org.eclipse.osee.framework.ui.plugin.util.DirectoryOrFileSelector; import org.eclipse.osee.framework.ui.skynet.SkynetGuiPlugin; +import org.eclipse.osee.framework.ui.skynet.branch.BranchSelectComposite; import org.eclipse.swt.SWT; import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionEvent; @@ -39,6 +40,7 @@ import org.eclipse.swt.widgets.Event; import org.eclipse.swt.widgets.Group; import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.List; +import org.eclipse.swt.widgets.Listener; import org.eclipse.swt.widgets.Text; import org.eclipse.ui.dialogs.WizardDataTransferPage; @@ -53,7 +55,7 @@ public class ArtifactImportPage extends WizardDataTransferPage { public static final String PAGE_NAME = "osee.define.wizardPage.artifactImportPage"; private final Artifact destinationArtifact; private List typeList; - private List branchList; + private BranchSelectComposite branchSelectComposite; private Button chkReuseArtifacts; private Button radImportUnderDhRoot; @@ -192,11 +194,11 @@ public class ArtifactImportPage extends WizardDataTransferPage { radImportUnderSelection.setToolTipText("All the top level artifacts that are imported " + "will become children of the selected artifact."); radImportUnderSelection.addListener(SWT.Selection, this); radImportUnderSelection.addSelectionListener(new SelectionAdapter() { + @Override public void widgetSelected(SelectionEvent e) { if (radImportUnderSelection.getSelection()) { Branch branch = destinationArtifact.getBranch(); - branchList.setSelection(new String[] {branch.getBranchName()}); - branchList.showSelection(); + branchSelectComposite.setSelected(branch); populateTypeList(branch); } } @@ -222,6 +224,7 @@ public class ArtifactImportPage extends WizardDataTransferPage { /* * @see WizardPage#becomesVisible */ + @Override public void setVisible(boolean visible) { super.setVisible(visible); // policy: wizards are not allowed to come up with an error message @@ -235,6 +238,7 @@ public class ArtifactImportPage extends WizardDataTransferPage { return directoryFileSelector.validate(this); } + @Override protected void createOptionsGroup(Composite parent) { Group composite = new Group(parent, SWT.NONE); composite.setText("Options"); @@ -249,13 +253,10 @@ public class ArtifactImportPage extends WizardDataTransferPage { label.setText("Artifact Type:"); label.setLayoutData(new GridData(SWT.BEGINNING, SWT.BEGINNING, false, false)); - branchList = new List(composite, SWT.BORDER | SWT.V_SCROLL); - GridData gridData = new GridData(GridData.FILL_BOTH); - gridData.heightHint = 300; - branchList.setLayoutData(gridData); + branchSelectComposite = new BranchSelectComposite(composite, SWT.BORDER, false); typeList = new List(composite, SWT.BORDER | SWT.V_SCROLL); - gridData = new GridData(GridData.FILL_BOTH); + GridData gridData = new GridData(GridData.FILL_BOTH); gridData.heightHint = 300; typeList.setLayoutData(gridData); @@ -266,34 +267,23 @@ public class ArtifactImportPage extends WizardDataTransferPage { defaultBranch = destinationArtifact.getBranch(); } - try { - int defaultBranchIndex = 0; - for (Branch branch : BranchManager.getNormalBranches()) { - branchList.add(branch.getBranchName()); - branchList.setData(branch.getBranchName(), branch); - if (branch.equals(defaultBranch)) { - branchList.select(defaultBranchIndex); - } else { - defaultBranchIndex++; - } - } - } catch (OseeCoreException ex) { - OseeLog.log(SkynetGuiPlugin.class, Level.SEVERE, ex); - } - populateTypeList(defaultBranch); // Start out with an item selected typeList.setSelection(0); - branchList.addSelectionListener(new SelectionAdapter() { - public void widgetSelected(SelectionEvent event) { - String itemName = branchList.getItem(branchList.getSelectionIndex()); - populateTypeList((Branch) branchList.getData(itemName)); + branchSelectComposite.addListener(new Listener() { + /* (non-Javadoc) + * @see org.eclipse.swt.widgets.Listener#handleEvent(org.eclipse.swt.widgets.Event) + */ + @Override + public void handleEvent(Event event) { + populateTypeList(branchSelectComposite.getSelectedBranch()); } }); } private void populateTypeList(Branch branch) { + if (branch == null) return; try { String[] selection = typeList.getSelection(); typeList.removeAll(); @@ -390,8 +380,7 @@ public class ArtifactImportPage extends WizardDataTransferPage { if (chkReuseArtifacts.getSelection()) { return destinationArtifact.getBranch(); } else { - String itemName = branchList.getItem(branchList.getSelectionIndex()); - return (Branch) branchList.getData(itemName); + return branchSelectComposite.getSelectedBranch(); } } @@ -428,7 +417,7 @@ public class ArtifactImportPage extends WizardDataTransferPage { super.updateWidgetEnablements(); if (built) { - branchList.setEnabled(!radImportUnderSelection.getSelection()); + branchSelectComposite.setEnabled(!radImportUnderSelection.getSelection()); txtImportUnderFolderName.setEnabled(false);// TODO future development radImportUnderSelection.setEnabled(destinationArtifact != null); diff --git a/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/Import/ImportMetaPage.java b/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/Import/ImportMetaPage.java index e1dd25b15d0..ad3af9bdd4e 100644 --- a/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/Import/ImportMetaPage.java +++ b/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/Import/ImportMetaPage.java @@ -11,23 +11,18 @@ package org.eclipse.osee.framework.ui.skynet.Import; import java.io.File; -import java.util.logging.Level; import org.eclipse.core.resources.IResource; import org.eclipse.core.runtime.IAdaptable; import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.osee.framework.db.connection.exception.OseeCoreException; -import org.eclipse.osee.framework.logging.OseeLog; import org.eclipse.osee.framework.skynet.core.artifact.Branch; -import org.eclipse.osee.framework.skynet.core.artifact.BranchManager; import org.eclipse.osee.framework.ui.plugin.util.DirectoryOrFileSelector; -import org.eclipse.osee.framework.ui.skynet.SkynetGuiPlugin; +import org.eclipse.osee.framework.ui.skynet.branch.BranchSelectComposite; 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.Event; import org.eclipse.swt.widgets.Group; -import org.eclipse.swt.widgets.List; import org.eclipse.ui.dialogs.WizardDataTransferPage; /** @@ -38,7 +33,7 @@ public class ImportMetaPage extends WizardDataTransferPage { public static final String PAGE_NAME = "osee.define.wizardPage.importMetaPage"; private DirectoryOrFileSelector directoryFileSelector; - private List branchList; + private BranchSelectComposite branchSelectComposite; private IResource currentResourceSelection; @@ -104,30 +99,9 @@ public class ImportMetaPage extends WizardDataTransferPage { composite.setText("Destination Branch"); GridLayout gd = new GridLayout(); composite.setLayout(gd); - composite.setLayoutData(new GridData(GridData.FILL_BOTH)); - - branchList = new List(composite, SWT.BORDER | SWT.V_SCROLL); - GridData gridData = new GridData(GridData.FILL_BOTH); - gridData.heightHint = 300; - branchList.setLayoutData(gridData); - - try { - Branch defaultBranch = BranchManager.getDefaultBranch(); - - int defaultBranchIndex = 0; - for (Branch branch : BranchManager.getNormalBranches()) { - branchList.add(branch.getBranchName()); - branchList.setData(branch.getBranchName(), branch); - if (branch.equals(defaultBranch)) { - branchList.select(defaultBranchIndex); - } else { - defaultBranchIndex++; - } - } - } catch (OseeCoreException ex) { - branchList.add(ex.getLocalizedMessage()); - OseeLog.log(SkynetGuiPlugin.class, Level.SEVERE, ex); - } + composite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); + + branchSelectComposite = new BranchSelectComposite(composite, SWT.BORDER, false); setPageComplete(determinePageCompletion()); } @@ -135,6 +109,7 @@ public class ImportMetaPage extends WizardDataTransferPage { /* * @see WizardPage#becomesVisible */ + @Override public void setVisible(boolean visible) { super.setVisible(visible); // policy: wizards are not allowed to come up with an error message @@ -153,8 +128,7 @@ public class ImportMetaPage extends WizardDataTransferPage { } public Branch getSelectedBranch() { - String itemName = branchList.getItem(branchList.getSelectionIndex()); - return (Branch) branchList.getData(itemName); + return branchSelectComposite.getSelectedBranch(); } /* diff --git a/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/SkynetDefaultBranchContributionItem.java b/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/SkynetDefaultBranchContributionItem.java index 3f2a1a938b4..f090d73039b 100644 --- a/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/SkynetDefaultBranchContributionItem.java +++ b/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/SkynetDefaultBranchContributionItem.java @@ -21,7 +21,7 @@ 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.branch.BranchLabelProvider; -import org.eclipse.osee.framework.ui.skynet.util.BranchSelectionDialog; +import org.eclipse.osee.framework.ui.skynet.branch.BranchSelectionDialog; import org.eclipse.swt.graphics.Image; import org.eclipse.ui.part.MultiPageEditorPart; import org.eclipse.ui.part.ViewPart; @@ -47,7 +47,7 @@ public class SkynetDefaultBranchContributionItem extends SkynetContributionItem */ @Override public void run() { - BranchSelectionDialog branchSelection = new BranchSelectionDialog("Set Default Branch"); + BranchSelectionDialog branchSelection = new BranchSelectionDialog("Set Default Branch", false); int result = branchSelection.open(); if (result == Window.OK) { BranchManager.setDefaultBranch(branchSelection.getSelection()); diff --git a/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/branch/BranchListComposite.java b/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/branch/BranchListComposite.java index b7743868785..601192ae735 100644 --- a/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/branch/BranchListComposite.java +++ b/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/branch/BranchListComposite.java @@ -5,6 +5,7 @@ */
package org.eclipse.osee.framework.ui.skynet.branch;
+import java.util.Collection;
import java.util.logging.Level;
import org.eclipse.jface.viewers.ITableLabelProvider;
import org.eclipse.jface.viewers.StructuredSelection;
@@ -54,8 +55,14 @@ public class BranchListComposite implements IBranchEventListener { private Text filterText;
private BranchNameFilter nameFilter;
private FavoritesSorter sorter;
+ private final Collection<Branch> branches;
public BranchListComposite(Composite parent) {
+ this(null, parent);
+ }
+
+ public BranchListComposite(Collection<Branch> branches, Composite parent) {
+ this.branches = branches;
try {
if (!DbConnectionExceptionComposite.dbConnectionIsOk(parent)) return;
@@ -210,7 +217,6 @@ public class BranchListComposite implements IBranchEventListener { public Branch getWorkingBranch() throws OseeCoreException {
return branch;
}
-
}
public void refresh() {
@@ -222,7 +228,11 @@ public class BranchListComposite implements IBranchEventListener { public void forcePopulateView() throws OseeCoreException {
if (branchTable != null && !branchTable.getTree().isDisposed()) {
BranchManager.refreshBranches();
- branchTable.setInput(BranchManager.getInstance());
+ if (branches == null) {
+ branchTable.setInput(BranchManager.getInstance());
+ } else {
+ branchTable.setInput(branches);
+ }
}
}
diff --git a/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/branch/BranchSelectComposite.java b/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/branch/BranchSelectComposite.java new file mode 100644 index 00000000000..f373d714372 --- /dev/null +++ b/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/branch/BranchSelectComposite.java @@ -0,0 +1,143 @@ +/*******************************************************************************
+ * 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.skynet.branch;
+
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Set;
+import org.eclipse.osee.framework.skynet.core.artifact.Branch;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Listener;
+import org.eclipse.swt.widgets.Text;
+
+/**
+ * @author Roberto E. Escobar
+ */
+public class BranchSelectComposite extends Composite implements Listener {
+ protected static final int SIZING_TEXT_FIELD_WIDTH = 250;
+
+ private Button branchSelectButton;
+ private Text branchSelectTextWidget;
+ private Branch selectedBranch;
+ private Branch defaultSelectedBranch;
+ private final Set<Listener> listeners;
+ private final boolean allowOnlyWorkingBranches;
+
+ public BranchSelectComposite(Composite parent, int style, boolean allowOnlyWorkingBranches) {
+ super(parent, style);
+ this.allowOnlyWorkingBranches = allowOnlyWorkingBranches;
+ this.listeners = Collections.synchronizedSet(new HashSet<Listener>());
+ createControl(this);
+ }
+
+ public static BranchSelectComposite createWorkingBranchSelectComposite(Composite parent, int style) {
+ return new BranchSelectComposite(parent, style, true);
+ }
+
+ public static BranchSelectComposite createBranchSelectComposite(Composite parent, int style) {
+ return new BranchSelectComposite(parent, style, false);
+ }
+
+ private void createControl(Composite parent) {
+ parent.setLayout(new GridLayout(2, false));
+ parent.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+
+ branchSelectTextWidget = new Text(parent, SWT.BORDER | SWT.READ_ONLY);
+ GridData data = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.GRAB_HORIZONTAL);
+ data.widthHint = SIZING_TEXT_FIELD_WIDTH;
+ branchSelectTextWidget.setLayoutData(data);
+ setSelected(defaultSelectedBranch);
+
+ branchSelectButton = new Button(parent, SWT.PUSH);
+ branchSelectButton.setText("Select Branch...");
+ branchSelectButton.addListener(SWT.Selection, this);
+ branchSelectButton.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL));
+ }
+
+ public Branch getSelectedBranch() {
+ return selectedBranch;
+ }
+
+ private boolean areOnlyWorkingBranchesAllowed() {
+ return allowOnlyWorkingBranches;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.swt.widgets.Listener#handleEvent(org.eclipse.swt.widgets.Event)
+ */
+ public void handleEvent(Event event) {
+ if (event.widget == branchSelectButton) {
+ if (areOnlyWorkingBranchesAllowed() != false) {
+ setSelected(BranchSelectionDialog.getWorkingBranchFromUser());
+ } else {
+ setSelected(BranchSelectionDialog.getBranchFromUser());
+ }
+ }
+ notifyListener(event);
+ }
+
+ public void setSelected(Branch branch) {
+ selectedBranch = branch;
+ String name = "";
+ if (selectedBranch != null) {
+ name = selectedBranch.getBranchName();
+ }
+ branchSelectTextWidget.setText(name);
+
+ }
+
+ private void notifyListener(Event event) {
+ synchronized (listeners) {
+ for (Listener listener : listeners) {
+ listener.handleEvent(event);
+ }
+ }
+ }
+
+ public void addListener(Listener listener) {
+ synchronized (listeners) {
+ listeners.add(listener);
+ }
+ }
+
+ public void removeListener(Listener listener) {
+ synchronized (listeners) {
+ listeners.remove(listener);
+ }
+ }
+
+ /**
+ * @return the defaultSelectedBranch
+ */
+ public Branch getDefaultSelectedBranch() {
+ return defaultSelectedBranch;
+ }
+
+ /**
+ * @param defaultSelectedBranch the defaultSelectedBranch to set
+ */
+ public void setDefaultSelectedBranch(Branch defaultSelectedBranch) {
+ this.defaultSelectedBranch = defaultSelectedBranch;
+ }
+
+ /**
+ * @return the branchSelectLabel
+ */
+ public Text getBranchSelectText() {
+ return branchSelectTextWidget;
+ }
+}
diff --git a/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/util/BranchSelectionDialog.java b/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/branch/BranchSelectionDialog.java index 296beaffc18..1365f45e0a7 100644 --- a/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/util/BranchSelectionDialog.java +++ b/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/branch/BranchSelectionDialog.java @@ -8,23 +8,26 @@ * Contributors: * Boeing - initial API and implementation *******************************************************************************/ -package org.eclipse.osee.framework.ui.skynet.util; +package org.eclipse.osee.framework.ui.skynet.branch; -import java.util.Collection; +import java.util.List; +import java.util.logging.Level; import org.eclipse.jface.dialogs.MessageDialog; -import org.eclipse.jface.viewers.ILabelProvider; -import org.eclipse.jface.viewers.ILabelProviderListener; import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jface.viewers.ITreeContentProvider; -import org.eclipse.jface.viewers.Viewer; +import org.eclipse.jface.window.Window; +import org.eclipse.osee.framework.core.enums.BranchType; +import org.eclipse.osee.framework.db.connection.exception.OseeCoreException; +import org.eclipse.osee.framework.logging.OseeLog; import org.eclipse.osee.framework.skynet.core.artifact.Branch; +import org.eclipse.osee.framework.skynet.core.artifact.BranchControlled; +import org.eclipse.osee.framework.skynet.core.artifact.BranchManager; +import org.eclipse.osee.framework.skynet.core.artifact.BranchState; import org.eclipse.osee.framework.ui.plugin.util.AWorkbench; import org.eclipse.osee.framework.ui.plugin.util.JobbedNode; -import org.eclipse.osee.framework.ui.skynet.branch.BranchListComposite; +import org.eclipse.osee.framework.ui.skynet.SkynetGuiPlugin; import org.eclipse.swt.SWT; import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.events.SelectionListener; -import org.eclipse.swt.graphics.Image; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Control; @@ -39,10 +42,12 @@ public class BranchSelectionDialog extends MessageDialog { Branch selected = null; BranchListComposite branchListComposite; + private final boolean allowOnlyWorkingBranches; - public BranchSelectionDialog(String title) { + public BranchSelectionDialog(String title, boolean allowOnlyWorkingBranches) { super(Display.getCurrent().getActiveShell(), title, null, null, MessageDialog.NONE, new String[] {"Ok", "Cancel"}, 0); + this.allowOnlyWorkingBranches = allowOnlyWorkingBranches; setShellStyle(getShellStyle() | SWT.RESIZE); } @@ -52,9 +57,20 @@ public class BranchSelectionDialog extends MessageDialog { @Override protected Control createDialogArea(Composite container) { - branchListComposite = new BranchListComposite(container); + List<Branch> branches = null; + try { + if (allowOnlyWorkingBranches) { + branches = + BranchManager.getBranches(BranchState.ACTIVE, BranchControlled.CHANGE_MANAGED, BranchType.STANDARD); + } else { + branches = BranchManager.getNormalBranches(); + } + } catch (OseeCoreException ex) { + OseeLog.log(SkynetGuiPlugin.class, Level.SEVERE, ex); + } + branchListComposite = new BranchListComposite(branches, container); branchListComposite.setPresentation(true); - GridData gd = new GridData(); + GridData gd = new GridData(GridData.FILL_BOTH); gd.heightHint = 500; gd.widthHint = 400; branchListComposite.getBranchTable().getTree().setLayoutData(gd); @@ -109,77 +125,21 @@ public class BranchSelectionDialog extends MessageDialog { super.okPressed(); } - public class BranchLabelProvider implements ILabelProvider { - - public Image getImage(Object arg0) { - return null; - } - - public String getText(Object arg0) { - Branch type = (Branch) arg0; - return type.getBranchName(); - } - - public void addListener(ILabelProviderListener arg0) { + private static Branch createDialog(boolean allowOnlyWorkingBranches) { + Branch toReturn = null; + BranchSelectionDialog branchSelection = new BranchSelectionDialog("Select Branch", allowOnlyWorkingBranches); + int result = branchSelection.open(); + if (result == Window.OK) { + toReturn = branchSelection.getSelection(); } - - public void dispose() { - } - - public boolean isLabelProperty(Object arg0, String arg1) { - return false; - } - - public void removeListener(ILabelProviderListener arg0) { - } - + return toReturn; } - public void setSelected(Branch selected) { - this.selected = selected; + public static Branch getBranchFromUser() { + return createDialog(false); } - private class BranchContentProvider implements ITreeContentProvider { - - /* (non-Javadoc) - * @see org.eclipse.jface.viewers.ITreeContentProvider#getChildren(java.lang.Object) - */ - public Object[] getChildren(Object parentElement) { - return null; - } - - /* (non-Javadoc) - * @see org.eclipse.jface.viewers.ITreeContentProvider#getParent(java.lang.Object) - */ - public Object getParent(Object element) { - return null; - } - - /* (non-Javadoc) - * @see org.eclipse.jface.viewers.ITreeContentProvider#hasChildren(java.lang.Object) - */ - public boolean hasChildren(Object element) { - return false; - } - - /* (non-Javadoc) - * @see org.eclipse.jface.viewers.IStructuredContentProvider#getElements(java.lang.Object) - */ - public Object[] getElements(Object inputElement) { - return ((Collection<?>) inputElement).toArray(); - } - - /* (non-Javadoc) - * @see org.eclipse.jface.viewers.IContentProvider#dispose() - */ - public void dispose() { - } - - /* (non-Javadoc) - * @see org.eclipse.jface.viewers.IContentProvider#inputChanged(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object) - */ - public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { - } - + public static Branch getWorkingBranchFromUser() { + return createDialog(true); } } diff --git a/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/dialogs/BranchSelectionDialog.java b/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/dialogs/BranchSelectionDialog.java deleted file mode 100644 index c29e86f67d6..00000000000 --- a/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/dialogs/BranchSelectionDialog.java +++ /dev/null @@ -1,111 +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.skynet.dialogs; - -import java.util.List; -import java.util.logging.Level; -import java.util.logging.Logger; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Status; -import org.eclipse.jface.window.Window; -import org.eclipse.osee.framework.plugin.core.config.ConfigUtil; -import org.eclipse.osee.framework.skynet.core.artifact.Branch; -import org.eclipse.osee.framework.skynet.core.artifact.BranchManager; -import org.eclipse.osee.framework.ui.skynet.SkynetGuiPlugin; -import org.eclipse.swt.SWT; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.ui.PlatformUI; -import org.eclipse.ui.dialogs.ElementTreeSelectionDialog; -import org.eclipse.ui.dialogs.ISelectionStatusValidator; - -/** - * @author Roberto E. Escobar - */ -public class BranchSelectionDialog extends ElementTreeSelectionDialog { - private static Logger logger = ConfigUtil.getConfigFactory().getLogger(BranchSelectionDialog.class); - private static final String TITLE_MESSAGE = "Select a %sBranch"; - private static final String BRANCH_ERROR_MESSAGE = "Must select a %sbranch."; - - private boolean allowOnlyWorkingBranches; - - private BranchSelectionDialog(Shell parent, boolean allowOnlyWorkingBranches) { - super(parent, new SimpleBranchLabelProvider(), new SimpleBranchContentProvider()); - this.allowOnlyWorkingBranches = allowOnlyWorkingBranches; - initialize(); - setShellStyle(getShellStyle() | SWT.RESIZE); - setTitle(getTitleAndMessage()); - setMessage(getTitleAndMessage()); - setAllowMultiple(false); - setValidator(new ISelectionStatusValidator() { - - public IStatus validate(Object[] selection) { - String message = ""; - int status = Status.ERROR; - if (selection.length == 0) { - message = "Must make selection."; - } else { - Branch branch = (Branch) selection[0]; - if (areOnlyWorkingBranchesAllowed() && !branch.hasParentBranch()) { - message = getBranchErrorMessage(); - } else { - status = OK; - message = String.format("Selected: [%s]", branch.getBranchName()); - } - } - return new Status(status, SkynetGuiPlugin.PLUGIN_ID, message); - } - }); - } - - private boolean areOnlyWorkingBranchesAllowed() { - return allowOnlyWorkingBranches; - } - - private String getTitleAndMessage() { - return String.format(TITLE_MESSAGE, areOnlyWorkingBranchesAllowed() ? "Working " : ""); - } - - private String getBranchErrorMessage() { - return String.format(BRANCH_ERROR_MESSAGE, areOnlyWorkingBranchesAllowed() ? "working " : ""); - } - - private void initialize() { - try { - List<Branch> branchList = BranchManager.getTopLevelBranches(); - setInput(branchList); - } catch (Exception ex) { - logger.log(Level.SEVERE, "Unable to get root branches.", ex); - } - } - - public Branch getSelection() { - return (Branch) getResult()[0]; - } - - private static Branch createDialog(boolean allowOnlyWorkingBranches) { - Branch toReturn = null; - BranchSelectionDialog branchSelection = - new BranchSelectionDialog(PlatformUI.getWorkbench().getDisplay().getActiveShell(), allowOnlyWorkingBranches); - int result = branchSelection.open(); - if (result == Window.OK) { - toReturn = branchSelection.getSelection(); - } - return toReturn; - } - - public static Branch getBranchFromUser() { - return createDialog(false); - } - - public static Branch getWorkingBranchFromUser() { - return createDialog(true); - } -} diff --git a/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/dialogs/SimpleBranchContentProvider.java b/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/dialogs/SimpleBranchContentProvider.java deleted file mode 100644 index 6ac07e7d64d..00000000000 --- a/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/dialogs/SimpleBranchContentProvider.java +++ /dev/null @@ -1,102 +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.skynet.dialogs;
-
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.logging.Level;
-import org.eclipse.jface.viewers.ITreeContentProvider;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.osee.framework.db.connection.exception.OseeCoreException;
-import org.eclipse.osee.framework.logging.OseeLog;
-import org.eclipse.osee.framework.skynet.core.artifact.Branch;
-import org.eclipse.osee.framework.ui.skynet.SkynetGuiPlugin;
-
-/**
- * @author Roberto E. Escobar
- */
-public final class SimpleBranchContentProvider implements ITreeContentProvider {
- private static final Object[] EMPTY_ARRAY = new Object[0];
-
- @SuppressWarnings("unchecked")
- public Object[] getChildren(Object parentElement) {
- if (parentElement instanceof Collection) {
- Iterator<Object> iter = ((Collection<Object>) parentElement).iterator();
- while (iter.hasNext()) {
- Object object = iter.next();
-
- if (object instanceof Branch && ((Branch) object).isMergeBranch()) {
- iter.remove();
- }
- }
- return ((Collection) parentElement).toArray();
- }
- if (parentElement instanceof Branch) {
- try {
- Collection<Branch> branches = ((Branch) parentElement).getChildBranches();
- List<Branch> sortedBranches = new LinkedList<Branch>(branches);
- Collections.sort(sortedBranches, new Comparator<Branch>() {
- public int compare(Branch branch1, Branch branch2) {
- String name1 = branch1.getBranchName();
- String name2 = branch2.getBranchName();
- try {
- name1 = name1.replace(branch1.getAssociatedArtifact().getHumanReadableId() + " - ", "");
- } catch (Exception ex) {
- }
- try {
- name2 = name2.replace(branch2.getAssociatedArtifact().getHumanReadableId() + " - ", "");
- } catch (Exception ex) {
- }
- return name1.compareTo(name2);
- }
- });
- return sortedBranches.toArray(new Branch[sortedBranches.size()]);
- } catch (OseeCoreException ex) {
- OseeLog.log(SkynetGuiPlugin.class, Level.SEVERE, ex);
- }
- }
- return EMPTY_ARRAY;
- }
-
- public Object getParent(Object element) {
- return null;
- }
-
- public boolean hasChildren(Object element) {
- if (element instanceof Collection) return true;
- if (element instanceof Branch) {
- try {
- Collection<Branch> branches = ((Branch) element).getChildBranches();
- return branches.size() > 0;
- } catch (OseeCoreException ex) {
- OseeLog.log(SkynetGuiPlugin.class, Level.SEVERE, ex);
- }
- }
- 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) {
- }
-
-}
diff --git a/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/dialogs/SimpleBranchLabelProvider.java b/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/dialogs/SimpleBranchLabelProvider.java deleted file mode 100644 index 399f48f59ab..00000000000 --- a/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/dialogs/SimpleBranchLabelProvider.java +++ /dev/null @@ -1,47 +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.skynet.dialogs;
-
-import org.eclipse.jface.viewers.LabelProvider;
-import org.eclipse.osee.framework.skynet.core.artifact.Branch;
-import org.eclipse.osee.framework.ui.skynet.SkynetGuiPlugin;
-import org.eclipse.swt.graphics.Image;
-
-/**
- * @author Roberto E. Escobar
- */
-public final class SimpleBranchLabelProvider extends LabelProvider {
- private static final Image PARENT_BRANCH_IMAGE = SkynetGuiPlugin.getInstance().getImage("branch.gif");
- private static final Image CHILD_BRANCH_IMAGE = SkynetGuiPlugin.getInstance().getImage("change_managed_branch.gif");
-
- public Image getImage(Object arg0) {
- Image toReturn = null;
- if (arg0 instanceof Branch) {
- Branch branch = ((Branch) arg0);
- if (branch != null) {
- toReturn = branch.hasParentBranch() ? CHILD_BRANCH_IMAGE : PARENT_BRANCH_IMAGE;
- }
- }
- return toReturn;
- }
-
- public String getText(Object arg0) {
- String toReturn = "";
- if (arg0 instanceof Branch) {
- Branch branch = ((Branch) arg0);
- if (branch != null) {
- toReturn = branch.getBranchName();
- }
- }
- return toReturn;
- }
-}
diff --git a/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/panels/BranchSelectComposite.java b/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/panels/BranchSelectSimpleComposite.java index b7f50d0dba0..16c6d301e29 100644 --- a/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/panels/BranchSelectComposite.java +++ b/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/panels/BranchSelectSimpleComposite.java @@ -17,14 +17,12 @@ import java.util.HashSet; import java.util.List;
import java.util.Set;
import java.util.logging.Level;
-import java.util.logging.Logger;
import org.eclipse.osee.framework.jdk.core.util.Strings;
import org.eclipse.osee.framework.logging.OseeLog;
-import org.eclipse.osee.framework.plugin.core.config.ConfigUtil;
import org.eclipse.osee.framework.skynet.core.artifact.Branch;
import org.eclipse.osee.framework.skynet.core.artifact.BranchManager;
import org.eclipse.osee.framework.ui.skynet.SkynetGuiPlugin;
-import org.eclipse.osee.framework.ui.skynet.dialogs.BranchSelectionDialog;
+import org.eclipse.osee.framework.ui.skynet.branch.BranchSelectionDialog;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.FocusAdapter;
import org.eclipse.swt.events.FocusEvent;
@@ -43,18 +41,17 @@ import org.eclipse.swt.widgets.Listener; /**
* @author Roberto E. Escobar
*/
-public class BranchSelectComposite extends Composite implements Listener {
- private static Logger logger = ConfigUtil.getConfigFactory().getLogger(BranchSelectComposite.class);
+public class BranchSelectSimpleComposite extends Composite implements Listener {
protected static final int SIZING_TEXT_FIELD_WIDTH = 250;
private Button branchSelectButton;
private Combo branchSelectCombo;
private boolean entryChanged;
private Branch currentBranch;
- private Set<Listener> listeners;
- private boolean allowOnlyWorkingBranches;
+ private final Set<Listener> listeners;
+ private final boolean allowOnlyWorkingBranches;
- private BranchSelectComposite(Composite parent, int style, boolean allowOnlyWorkingBranches) {
+ private BranchSelectSimpleComposite(Composite parent, int style, boolean allowOnlyWorkingBranches) {
super(parent, style);
this.allowOnlyWorkingBranches = allowOnlyWorkingBranches;
this.entryChanged = false;
@@ -63,12 +60,12 @@ public class BranchSelectComposite extends Composite implements Listener { createControl(this);
}
- public static BranchSelectComposite createWorkingBranchSelectComposite(Composite parent, int style) {
- return new BranchSelectComposite(parent, style, true);
+ public static BranchSelectSimpleComposite createWorkingBranchSelectComposite(Composite parent, int style) {
+ return new BranchSelectSimpleComposite(parent, style, true);
}
- public static BranchSelectComposite createBranchSelectComposite(Composite parent, int style) {
- return new BranchSelectComposite(parent, style, false);
+ public static BranchSelectSimpleComposite createBranchSelectComposite(Composite parent, int style) {
+ return new BranchSelectSimpleComposite(parent, style, false);
}
private void createControl(Composite parent) {
@@ -81,12 +78,14 @@ public class BranchSelectComposite extends Composite implements Listener { branchSelectCombo.setLayoutData(data);
branchSelectCombo.setFont(parent.getFont());
branchSelectCombo.addSelectionListener(new SelectionAdapter() {
+ @Override
public void widgetSelected(SelectionEvent e) {
updateFromSourceField();
}
});
branchSelectCombo.addKeyListener(new KeyAdapter() {
+ @Override
public void keyPressed(KeyEvent e) {
// If there has been a key pressed then mark as dirty
entryChanged = true;
@@ -94,6 +93,7 @@ public class BranchSelectComposite extends Composite implements Listener { });
branchSelectCombo.addFocusListener(new FocusAdapter() {
+ @Override
public void focusLost(FocusEvent e) {
// Clear the flag to prevent constant update
if (entryChanged) {
@@ -201,8 +201,8 @@ public class BranchSelectComposite extends Composite implements Listener { }
}
} catch (Exception ex) {
- logger.log(Level.SEVERE, String.format("Unable to add invalid branch id [%s] to selection list.",
- toStore));
+ OseeLog.log(SkynetGuiPlugin.class, Level.SEVERE, String.format(
+ "Unable to add invalid branch id [%s] to selection list.", toStore));
}
}
}
diff --git a/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/XBranchSelectComboWidget.java b/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/XBranchSelectComboWidget.java new file mode 100644 index 00000000000..70b85e2d140 --- /dev/null +++ b/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/XBranchSelectComboWidget.java @@ -0,0 +1,241 @@ +/*******************************************************************************
+ * 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.skynet.widgets;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.logging.Level;
+import org.eclipse.osee.framework.db.connection.exception.OseeCoreException;
+import org.eclipse.osee.framework.jdk.core.util.Strings;
+import org.eclipse.osee.framework.logging.OseeLog;
+import org.eclipse.osee.framework.skynet.core.artifact.Branch;
+import org.eclipse.osee.framework.skynet.core.artifact.BranchManager;
+import org.eclipse.osee.framework.ui.plugin.util.Result;
+import org.eclipse.osee.framework.ui.skynet.SkynetGuiPlugin;
+import org.eclipse.osee.framework.ui.skynet.panels.BranchSelectSimpleComposite;
+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.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;
+
+/**
+ * @author Roberto E. Escobar
+ */
+public class XBranchSelectComboWidget extends XWidget implements Listener {
+ public static final String WIDGET_ID = XBranchSelectWidget.class.getSimpleName();
+
+ private BranchSelectSimpleComposite selectComposite;
+ private Composite composite;
+ private int defaultBranch;
+
+ private final List<Listener> listeners = new ArrayList<Listener>();
+
+ public XBranchSelectComboWidget(String label) {
+ super(label);
+ this.defaultBranch = -1;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.osee.framework.ui.skynet.widgets.XWidget#createWidgets(org.eclipse.swt.widgets.Composite, int)
+ */
+ @Override
+ public void createWidgets(Composite parent, int horizontalSpan) {
+ composite = null;
+
+ if (!verticalLabel && (horizontalSpan < 2)) {
+ horizontalSpan = 2;
+ } else if (verticalLabel) {
+ horizontalSpan = 1;
+ }
+
+ if (displayLabel && verticalLabel) {
+ composite = new Composite(parent, SWT.NONE);
+ GridLayout gL = new GridLayout();
+ gL.marginWidth = 0;
+ gL.marginHeight = 0;
+ composite.setLayout(gL);
+ composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+ } else {
+ composite = parent;
+ }
+
+ // Create List Widgets
+ if (displayLabel) {
+ labelWidget = new Label(composite, SWT.NONE);
+ labelWidget.setText(label + ":");
+ }
+ selectComposite = BranchSelectSimpleComposite.createBranchSelectComposite(composite, SWT.NONE);
+ if (defaultBranch != -1) {
+ selectComposite.restoreWidgetValues(null, Integer.toString(defaultBranch));
+ }
+ selectComposite.addListener(this);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.osee.framework.ui.skynet.widgets.XWidget#dispose()
+ */
+ @Override
+ public void dispose() {
+ if (selectComposite != null) {
+ selectComposite.removeListener(this);
+ selectComposite.dispose();
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.osee.framework.ui.skynet.widgets.XWidget#getControl()
+ */
+ @Override
+ public Control getControl() {
+ return composite;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.osee.framework.ui.skynet.widgets.XWidget#getData()
+ */
+ @Override
+ public Branch getData() {
+ return selectComposite.getSelectedBranch();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.osee.framework.ui.skynet.widgets.XWidget#getReportData()
+ */
+ @Override
+ public String getReportData() {
+ Branch branch = selectComposite.getSelectedBranch();
+ return branch != null ? branch.getBranchName() : "";
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.osee.framework.ui.skynet.widgets.XWidget#getXmlData()
+ */
+ @Override
+ public String getXmlData() {
+ System.out.println("Get XML Data Called: ");
+ return "";
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.osee.framework.ui.skynet.widgets.XWidget#isValid()
+ */
+ @Override
+ public Result isValid() {
+ if (selectComposite.getSelectedBranch() == null) return new Result("Must select a Branch");
+ return Result.TrueResult;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.osee.framework.ui.skynet.widgets.XWidget#refresh()
+ */
+ @Override
+ public void refresh() {
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.osee.framework.ui.skynet.widgets.XWidget#setFocus()
+ */
+ @Override
+ public void setFocus() {
+ selectComposite.setFocus();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.osee.framework.ui.skynet.widgets.XWidget#setXmlData(java.lang.String)
+ */
+ @Override
+ public void setXmlData(String str) {
+ System.out.println("Set XML Data Called: " + str);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.osee.framework.ui.skynet.widgets.XWidget#toHTML(java.lang.String)
+ */
+ @Override
+ public String toHTML(String labelFont) {
+ System.out.println("Set to Html Called: " + labelFont);
+ return "";
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.osee.framework.ui.skynet.widgets.XWidget#setDisplayLabel(java.lang.String)
+ */
+ @Override
+ public void setDisplayLabel(final String displayLabel) {
+ Display.getCurrent().asyncExec(new Runnable() {
+ public void run() {
+ XBranchSelectComboWidget.super.setDisplayLabel(displayLabel);
+ getLabelWidget().setText(displayLabel);
+ }
+ });
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.osee.framework.ui.skynet.widgets.XWidget#setToolTip(java.lang.String)
+ */
+ @Override
+ public void setToolTip(final String toolTip) {
+ Display.getCurrent().asyncExec(new Runnable() {
+ public void run() {
+ if (Strings.isValid(toolTip) != false) {
+ XBranchSelectComboWidget.super.setToolTip(toolTip);
+ if (selectComposite != null && selectComposite.isDisposed() != true) {
+ selectComposite.setToolTipText(toolTip);
+ for (Control control : selectComposite.getChildren()) {
+ control.setToolTipText(toolTip);
+ }
+ }
+ }
+ }
+ });
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.swt.widgets.Listener#handleEvent(org.eclipse.swt.widgets.Event)
+ */
+ @Override
+ public void handleEvent(Event event) {
+ super.setLabelError();
+ notifyListeners(event);
+ }
+
+ public void setDefaultBranch(String branchName) {
+ if (Strings.isValid(branchName) != false) {
+ try {
+ Branch branch = BranchManager.getBranch(branchName);
+ defaultBranch = branch.getBranchId();
+ } catch (OseeCoreException ex) {
+ OseeLog.log(SkynetGuiPlugin.class, Level.SEVERE, "Unable to set default branch.", ex);
+ }
+ }
+ }
+
+ public void addListener(Listener listener) {
+ listeners.add(listener);
+ }
+
+ public void removeListener(Listener listener) {
+ listeners.remove(listener);
+ }
+
+ private void notifyListeners(Event event) {
+ for (Listener listener : listeners) {
+ listener.handleEvent(event);
+ }
+ }
+
+}
diff --git a/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/XBranchSelectWidget.java b/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/XBranchSelectWidget.java index 67b82c3c9d5..ccad24f963c 100644 --- a/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/XBranchSelectWidget.java +++ b/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/XBranchSelectWidget.java @@ -21,7 +21,7 @@ import org.eclipse.osee.framework.skynet.core.artifact.Branch; import org.eclipse.osee.framework.skynet.core.artifact.BranchManager;
import org.eclipse.osee.framework.ui.plugin.util.Result;
import org.eclipse.osee.framework.ui.skynet.SkynetGuiPlugin;
-import org.eclipse.osee.framework.ui.skynet.panels.BranchSelectComposite;
+import org.eclipse.osee.framework.ui.skynet.branch.BranchSelectComposite;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
@@ -34,6 +34,7 @@ import org.eclipse.swt.widgets.Listener; /**
* @author Roberto E. Escobar
+ * @author Donald G. Dunne
*/
public class XBranchSelectWidget extends XWidget implements Listener {
public static final String WIDGET_ID = XBranchSelectWidget.class.getSimpleName();
@@ -42,7 +43,7 @@ public class XBranchSelectWidget extends XWidget implements Listener { private Composite composite;
private int defaultBranch;
- private List<Listener> listeners = new ArrayList<Listener>();
+ private final List<Listener> listeners = new ArrayList<Listener>();
public XBranchSelectWidget(String label) {
super(label);
@@ -79,8 +80,12 @@ public class XBranchSelectWidget extends XWidget implements Listener { labelWidget.setText(label + ":");
}
selectComposite = BranchSelectComposite.createBranchSelectComposite(composite, SWT.NONE);
- if (defaultBranch != -1) {
- selectComposite.restoreWidgetValues(null, Integer.toString(defaultBranch));
+ try {
+ if (defaultBranch != -1) {
+ selectComposite.setDefaultSelectedBranch(BranchManager.getBranch(defaultBranch));
+ }
+ } catch (OseeCoreException ex) {
+ // do nothing
}
selectComposite.addListener(this);
}
@@ -101,7 +106,7 @@ public class XBranchSelectWidget extends XWidget implements Listener { */
@Override
public Control getControl() {
- return composite;
+ return selectComposite.getBranchSelectText();
}
/* (non-Javadoc)
@@ -135,7 +140,9 @@ public class XBranchSelectWidget extends XWidget implements Listener { */
@Override
public Result isValid() {
- if (selectComposite.getSelectedBranch() == null) return new Result("Must select a Branch");
+ if (selectComposite.getSelectedBranch() == null) {
+ return new Result("Must select a Branch");
+ }
return Result.TrueResult;
}
|