Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/org.eclipse.osee.coverage/src/org/eclipse/osee/coverage/action/ConfigureCoverageMethodsAction.java')
-rw-r--r--plugins/org.eclipse.osee.coverage/src/org/eclipse/osee/coverage/action/ConfigureCoverageMethodsAction.java214
1 files changed, 107 insertions, 107 deletions
diff --git a/plugins/org.eclipse.osee.coverage/src/org/eclipse/osee/coverage/action/ConfigureCoverageMethodsAction.java b/plugins/org.eclipse.osee.coverage/src/org/eclipse/osee/coverage/action/ConfigureCoverageMethodsAction.java
index dedb60c51a4..18fcce3b35a 100644
--- a/plugins/org.eclipse.osee.coverage/src/org/eclipse/osee/coverage/action/ConfigureCoverageMethodsAction.java
+++ b/plugins/org.eclipse.osee.coverage/src/org/eclipse/osee/coverage/action/ConfigureCoverageMethodsAction.java
@@ -8,8 +8,8 @@
* Contributors:
* Boeing - initial API and implementation
*******************************************************************************/
-package org.eclipse.osee.coverage.action;
-
+package org.eclipse.osee.coverage.action;
+
import java.util.HashSet;
import java.util.Set;
import org.eclipse.jface.action.Action;
@@ -35,108 +35,108 @@ 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.osee.framework.ui.swt.KeyedImage;
-
-/**
- * @author Donald G. Dunne
- */
-public class ConfigureCoverageMethodsAction extends Action {
-
- public static KeyedImage OSEE_IMAGE = FrameworkImage.GEAR;
-
- public ConfigureCoverageMethodsAction() {
- super("Configure Coverage Methods");
- }
-
- @Override
- public ImageDescriptor getImageDescriptor() {
- return ImageManager.getImageDescriptor(OSEE_IMAGE);
- }
-
- @Override
- public void run() {
- try {
- if (!CoverageUtil.getBranchFromUser(false)) {
- return;
- }
- CoveragePackageArtifactListDialog dialog =
- new CoveragePackageArtifactListDialog("Open Coverage Package", "Select Coverage Package");
- dialog.setInput(OseeCoveragePackageStore.getCoveragePackageArtifacts(CoverageUtil.getBranch()));
- if (dialog.open() == 0) {
- Artifact coveragePackageArtifact = (Artifact) dialog.getResult()[0];
- OseeCoveragePackageStore packageStore = new OseeCoveragePackageStore(coveragePackageArtifact);
- CoverageOptionManagerStore optionsStore = new CoverageOptionManagerStore(packageStore);
- Result isSaveable = optionsStore.isSaveable();
- if (isSaveable.isFalse()) {
- isSaveable.popup();
- return;
- }
- String coverageOptions = null;
- StoreLocation storeLocation = optionsStore.getStoreLocation();
- if (storeLocation == StoreLocation.None) {
- MessageDialog localGlobalDialog =
- new MessageDialog(Displays.getActiveShell(), "Question", null,
- "No Custom Coverage Methods Configured, Configure Now?", MessageDialog.WARNING,
- new String[] {"Save local to Coverage Pacakge", "Save globally for Branch", "Cancel"}, 0);
-
- int result = localGlobalDialog.open();
- if (result == 0) {
- storeLocation = StoreLocation.Local;
- } else if (result == 1) {
- storeLocation = StoreLocation.Global;
- } else {
- return;
- }
- coverageOptions = CoverageOptionManagerDefault.instance().toXml();
- } else {
- coverageOptions = optionsStore.getCoverageOptions();
- }
-
- // Recheck save after option has been chosen
- optionsStore = new CoverageOptionManagerStore(packageStore);
- isSaveable = optionsStore.isSaveable();
- if (isSaveable.isFalse()) {
- isSaveable.popup();
- return;
- }
-
- boolean successOrCancel = false;
- // Keep allowing user to enter options until valid
- while (!successOrCancel) {
- EntryDialog entryDiag = new EntryDialog(getText(), "Edit Configure Options");
- entryDiag.setFillVertically(true);
- entryDiag.setEntry(coverageOptions);
- if (entryDiag.open() == 0) {
- coverageOptions = entryDiag.getEntry();
- try {
- CoverageOptionManager manager = new CoverageOptionManager(coverageOptions);
- if (manager.get().isEmpty()) {
- throw new OseeArgumentException("No options specified");
- }
- if (manager.get(CoverageOptionManager.Not_Covered.getName()) == null) {
- throw new OseeArgumentException("Can't remove Not_Covered item");
- }
- Set<String> names = new HashSet<String>();
- for (CoverageOption option : manager.get()) {
- if (names.contains(option.getName())) {
- throw new OseeArgumentException(String.format("Multiple options with same name [%s]",
- option.getName()));
- } else {
- names.add(option.getName());
- }
- }
- optionsStore.store(coverageOptions, storeLocation);
- successOrCancel = true;
- } catch (Exception ex) {
- OseeLog.log(Activator.class, OseeLevel.SEVERE_POPUP,
- "Invalid coverage options\n\n" + ex.getLocalizedMessage(), ex);
- }
- } else {
- successOrCancel = true;
- }
- }
- }
- } catch (OseeCoreException ex) {
- OseeLog.log(Activator.class, OseeLevel.SEVERE_POPUP, ex);
- }
- }
-}
+
+/**
+ * @author Donald G. Dunne
+ */
+public class ConfigureCoverageMethodsAction extends Action {
+
+ public static KeyedImage OSEE_IMAGE = FrameworkImage.GEAR;
+
+ public ConfigureCoverageMethodsAction() {
+ super("Configure Coverage Methods");
+ }
+
+ @Override
+ public ImageDescriptor getImageDescriptor() {
+ return ImageManager.getImageDescriptor(OSEE_IMAGE);
+ }
+
+ @Override
+ public void run() {
+ try {
+ if (!CoverageUtil.getBranchFromUser(false)) {
+ return;
+ }
+ CoveragePackageArtifactListDialog dialog =
+ new CoveragePackageArtifactListDialog("Open Coverage Package", "Select Coverage Package");
+ dialog.setInput(OseeCoveragePackageStore.getCoveragePackageArtifacts(CoverageUtil.getBranch()));
+ if (dialog.open() == 0) {
+ Artifact coveragePackageArtifact = (Artifact) dialog.getResult()[0];
+ OseeCoveragePackageStore packageStore = new OseeCoveragePackageStore(coveragePackageArtifact);
+ CoverageOptionManagerStore optionsStore = new CoverageOptionManagerStore(packageStore);
+ Result isSaveable = optionsStore.isSaveable();
+ if (isSaveable.isFalse()) {
+ isSaveable.popup();
+ return;
+ }
+ String coverageOptions = null;
+ StoreLocation storeLocation = optionsStore.getStoreLocation();
+ if (storeLocation == StoreLocation.None) {
+ MessageDialog localGlobalDialog =
+ new MessageDialog(Displays.getActiveShell(), "Question", null,
+ "No Custom Coverage Methods Configured, Configure Now?", MessageDialog.WARNING,
+ new String[] {"Save local to Coverage Pacakge", "Save globally for Branch", "Cancel"}, 0);
+
+ int result = localGlobalDialog.open();
+ if (result == 0) {
+ storeLocation = StoreLocation.Local;
+ } else if (result == 1) {
+ storeLocation = StoreLocation.Global;
+ } else {
+ return;
+ }
+ coverageOptions = CoverageOptionManagerDefault.instance().toXml();
+ } else {
+ coverageOptions = optionsStore.getCoverageOptions();
+ }
+
+ // Recheck save after option has been chosen
+ optionsStore = new CoverageOptionManagerStore(packageStore);
+ isSaveable = optionsStore.isSaveable();
+ if (isSaveable.isFalse()) {
+ isSaveable.popup();
+ return;
+ }
+
+ boolean successOrCancel = false;
+ // Keep allowing user to enter options until valid
+ while (!successOrCancel) {
+ EntryDialog entryDiag = new EntryDialog(getText(), "Edit Configure Options");
+ entryDiag.setFillVertically(true);
+ entryDiag.setEntry(coverageOptions);
+ if (entryDiag.open() == 0) {
+ coverageOptions = entryDiag.getEntry();
+ try {
+ CoverageOptionManager manager = new CoverageOptionManager(coverageOptions);
+ if (manager.get().isEmpty()) {
+ throw new OseeArgumentException("No options specified");
+ }
+ if (manager.get(CoverageOptionManager.Not_Covered.getName()) == null) {
+ throw new OseeArgumentException("Can't remove Not_Covered item");
+ }
+ Set<String> names = new HashSet<String>();
+ for (CoverageOption option : manager.get()) {
+ if (names.contains(option.getName())) {
+ throw new OseeArgumentException(String.format("Multiple options with same name [%s]",
+ option.getName()));
+ } else {
+ names.add(option.getName());
+ }
+ }
+ optionsStore.store(coverageOptions, storeLocation);
+ successOrCancel = true;
+ } catch (Exception ex) {
+ OseeLog.log(Activator.class, OseeLevel.SEVERE_POPUP,
+ "Invalid coverage options\n\n" + ex.getLocalizedMessage(), ex);
+ }
+ } else {
+ successOrCancel = true;
+ }
+ }
+ }
+ } catch (OseeCoreException ex) {
+ OseeLog.log(Activator.class, OseeLevel.SEVERE_POPUP, ex);
+ }
+ }
+}

Back to the top