diff options
author | Morgan E. Cook | 2017-01-12 00:00:19 +0000 |
---|---|---|
committer | Morgan Cook | 2017-02-14 19:29:22 +0000 |
commit | aa721b5bc36fd4e107e36345aaba9885a251d9b3 (patch) | |
tree | da27c144c6e710a31e7e5abe25b2c442ac63fd9c | |
parent | bcd9d85f976da2cf11e59d36e614fcc642312926 (diff) | |
download | org.eclipse.osee-aa721b5bc36fd4e107e36345aaba9885a251d9b3.tar.gz org.eclipse.osee-aa721b5bc36fd4e107e36345aaba9885a251d9b3.tar.xz org.eclipse.osee-aa721b5bc36fd4e107e36345aaba9885a251d9b3.zip |
refinement: Remove Word Diff sleep and add user notification for large diffs
Change-Id: I269f4eb72926faf64943360c3d23d9c86337aac6
Signed-off-by: Morgan E. Cook <Morgan.e.cook@boeing.com>
2 files changed, 63 insertions, 16 deletions
diff --git a/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/blam/operation/PublishWithSpecifiedTemplate.java b/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/blam/operation/PublishWithSpecifiedTemplate.java index 32b0039940b..10738115bd5 100644 --- a/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/blam/operation/PublishWithSpecifiedTemplate.java +++ b/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/blam/operation/PublishWithSpecifiedTemplate.java @@ -18,10 +18,12 @@ import java.util.Arrays; import java.util.Collection; import java.util.Collections; import java.util.List; +import java.util.concurrent.atomic.AtomicReference; import java.util.regex.Matcher; import java.util.regex.Pattern; import javax.ws.rs.core.MediaType; import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.jface.dialogs.MessageDialog; import org.eclipse.osee.framework.core.data.BranchId; import org.eclipse.osee.framework.jdk.core.type.OseeArgumentException; import org.eclipse.osee.framework.jdk.core.type.OseeCoreException; @@ -51,6 +53,7 @@ import org.eclipse.swt.events.ModifyEvent; import org.eclipse.swt.events.ModifyListener; import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.widgets.Display; import org.eclipse.ui.forms.widgets.FormToolkit; import org.json.JSONArray; import org.json.JSONException; @@ -168,9 +171,38 @@ public class PublishWithSpecifiedTemplate extends AbstractBlam { WordTemplateRenderer.FIRST_TIME, true}; - renderer.publish(master, slave, artifacts, options); + Boolean isDiff = (Boolean) variableMap.getValue(PUBLISH_AS_DIFF); + int toProcessSize = 0; + for (Artifact art : artifacts) { + toProcessSize += art.getDescendants().size(); + } - transaction.execute(); + final int totalSize = toProcessSize; + final AtomicReference<Boolean> result = new AtomicReference<>(); + final int maxArtsForQuickDiff = 900; + + Display.getDefault().syncExec(new Runnable() { + @Override + public void run() { + double secPerArt = 2; + double minutes = (totalSize * secPerArt) / 60; + + if (isDiff && totalSize > maxArtsForQuickDiff && !MessageDialog.openConfirm( + Display.getDefault().getActiveShell(), "Continue with Word Diff", + "You have chosen to do a word diff on " + totalSize + " Artifacts.\n\n" + // + "This could be a very long running task (approximately " + minutes + "min) and consume large resources.\n\nAre you sure?")) { + result.set(false); + } else { + result.set(true); + } + } + }); + + if (result.get()) { + renderer.publish(master, slave, artifacts, options); + transaction.execute(); + monitor.done(); + } } private List<Artifact> getArtifactsFromOrcsQuery() { diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/util/VbaWordDiffGenerator.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/util/VbaWordDiffGenerator.java index 88dd1673b80..06c68d18cd2 100644 --- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/util/VbaWordDiffGenerator.java +++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/util/VbaWordDiffGenerator.java @@ -75,6 +75,7 @@ public class VbaWordDiffGenerator implements IVbaDiffGenerator { private final boolean detectFormatChanges; private final boolean executeVbScript; private final boolean skipErrors; + private Long timeoutMs; public VbaWordDiffGenerator(boolean merge, boolean show, boolean detectFormatChanges, boolean executeVbScript, boolean skipErrors, boolean diffFieldCode) { this.merge = merge; @@ -83,6 +84,18 @@ public class VbaWordDiffGenerator implements IVbaDiffGenerator { this.executeVbScript = executeVbScript; this.skipErrors = skipErrors; this.diffFieldCode = diffFieldCode; + + timeoutMs = Long.MAX_VALUE; + String timeout = null; + try { + timeout = OseeInfo.getValue("osee.vba.word.diff.timeout"); + if (Strings.isValid(timeout)) { + timeoutMs = Long.parseLong(timeout); + } + } catch (Exception ex) { + OseeLog.log(Activator.class, Level.INFO, + String.format("Timeout lookup failed in %s, set to default %s", this.getClass().getSimpleName(), timeout)); + } } @Override @@ -145,8 +158,22 @@ public class VbaWordDiffGenerator implements IVbaDiffGenerator { } //Unfortunately Word seems to need a little extra time to close, otherwise Word 2007 will crash periodically if too many files are being compared. - String propertyWordDiffSleepMs = System.getProperty(OSEE_WORD_DIFF_SLEEP_MS, "250");// Quarter second is the default sleep value - appendable.append("WScript.sleep(" + propertyWordDiffSleepMs + ")\n"); + String propertyWordDiffSleepMs = null; + try { + propertyWordDiffSleepMs = OseeInfo.getValue(OSEE_WORD_DIFF_SLEEP_MS); + } catch (Exception ex) { + OseeLog.log(Activator.class, Level.INFO, + String.format("Word Diff Sleep lookup failed in %s, set to default %s", this.getClass().getSimpleName(), + propertyWordDiffSleepMs)); + } + + if (!Strings.isValid(propertyWordDiffSleepMs)) { + propertyWordDiffSleepMs = "250"; // Quarter second is the default sleep value + } + + if (!propertyWordDiffSleepMs.equals("0")) { + appendable.append("WScript.sleep(" + propertyWordDiffSleepMs + ")\n"); + } appendable.append(" ver1 = \""); appendable.append(entry.getKey()); @@ -225,18 +252,6 @@ public class VbaWordDiffGenerator implements IVbaDiffGenerator { errorCatcher.start(); outputCatcher.start(); - Long timeoutMs = Long.MAX_VALUE; - String timeout = null; - try { - timeout = OseeInfo.getValue("osee.vba.word.diff.timeout"); - } catch (Exception ex) { - OseeLog.log(Activator.class, Level.INFO, String.format("Timeout lookup failed in %s, set to default %s", - this.getClass().getSimpleName(), timeout)); - } - if (Strings.isValid(timeout)) { - timeoutMs = Long.parseLong(timeout); - } - if (!process.waitFor(timeoutMs, TimeUnit.MILLISECONDS)) { throw new OperationTimedoutException("The View Word Change Report Timed-out"); } |