diff options
author | megumi.telles | 2017-05-18 18:58:51 +0000 |
---|---|---|
committer | Morgan E. Cook | 2017-06-26 16:33:35 +0000 |
commit | 3bfbcd16f649ebd186622912597e484077ac5958 (patch) | |
tree | 71ee78453f17c169aeb29b43532da78bf8654a58 | |
parent | 1ba22a2fd5443612483f525dc815d297406c69e7 (diff) | |
download | org.eclipse.osee-3bfbcd16f649ebd186622912597e484077ac5958.tar.gz org.eclipse.osee-3bfbcd16f649ebd186622912597e484077ac5958.tar.xz org.eclipse.osee-3bfbcd16f649ebd186622912597e484077ac5958.zip |
feature[ats_ATS402720]: Allow branch view to set on editors
-- Change Report
-- Artifact Explorer
-- Publish With Specified Template
Signed-off-by: Morgan E. Cook <morgan.e.cook@boeing.com>
Change-Id: I943a6783782e2585a907861d107cddda2dfd942c
22 files changed, 666 insertions, 55 deletions
diff --git a/plugins/org.eclipse.osee.define.report.api/src/org/eclipse/osee/define/report/api/WordTemplateContentData.java b/plugins/org.eclipse.osee.define.report.api/src/org/eclipse/osee/define/report/api/WordTemplateContentData.java index ddb32bc3d73..9621e9ab6d3 100644 --- a/plugins/org.eclipse.osee.define.report.api/src/org/eclipse/osee/define/report/api/WordTemplateContentData.java +++ b/plugins/org.eclipse.osee.define.report.api/src/org/eclipse/osee/define/report/api/WordTemplateContentData.java @@ -28,6 +28,7 @@ public class WordTemplateContentData { private TransactionId txId; private String sessionId; private String oseeLink; + private ArtifactId viewId; public Long getArtId() { return artId; @@ -92,4 +93,12 @@ public class WordTemplateContentData { public void setOseeLink(String oseeLink) { this.oseeLink = oseeLink; } + + public ArtifactId getViewId() { + return viewId; + } + + public void setViewId(ArtifactId viewId) { + this.viewId = viewId; + } } diff --git a/plugins/org.eclipse.osee.define.report/src/org/eclipse/osee/define/report/WordUpdateEndpointImpl.java b/plugins/org.eclipse.osee.define.report/src/org/eclipse/osee/define/report/WordUpdateEndpointImpl.java index faaac4e77fb..d45f2b214bd 100644 --- a/plugins/org.eclipse.osee.define.report/src/org/eclipse/osee/define/report/WordUpdateEndpointImpl.java +++ b/plugins/org.eclipse.osee.define.report/src/org/eclipse/osee/define/report/WordUpdateEndpointImpl.java @@ -59,7 +59,7 @@ public final class WordUpdateEndpointImpl implements WordUpdateEndpoint { @Override public Pair<String, Set<String>> renderWordTemplateContent(WordTemplateContentData data) throws OseeCoreException { - WordTemplateContentRendererHandler wordRendererHandler = new WordTemplateContentRendererHandler(orcsApi); + WordTemplateContentRendererHandler wordRendererHandler = new WordTemplateContentRendererHandler(orcsApi, logger); return wordRendererHandler.renderWordML(data); } } diff --git a/plugins/org.eclipse.osee.define.report/src/org/eclipse/osee/define/report/internal/wordupdate/WordMLApplicabilityHandler.java b/plugins/org.eclipse.osee.define.report/src/org/eclipse/osee/define/report/internal/wordupdate/WordMLApplicabilityHandler.java index ef9c8010b0d..d6c76e1b3b6 100644 --- a/plugins/org.eclipse.osee.define.report/src/org/eclipse/osee/define/report/internal/wordupdate/WordMLApplicabilityHandler.java +++ b/plugins/org.eclipse.osee.define.report/src/org/eclipse/osee/define/report/internal/wordupdate/WordMLApplicabilityHandler.java @@ -26,7 +26,9 @@ import org.antlr.runtime.ANTLRStringStream; import org.antlr.runtime.CommonTokenStream; import org.antlr.runtime.RecognitionException; import org.codehaus.jackson.map.ObjectMapper; +import org.eclipse.osee.framework.core.data.ArtifactId; import org.eclipse.osee.framework.core.data.BranchId; +import org.eclipse.osee.framework.core.data.BranchViewData; import org.eclipse.osee.framework.core.data.FeatureDefinitionData; import org.eclipse.osee.framework.core.enums.CoreArtifactTypes; import org.eclipse.osee.framework.core.enums.CoreAttributeTypes; @@ -36,15 +38,18 @@ import org.eclipse.osee.framework.core.grammar.ApplicabilityGrammarLexer; import org.eclipse.osee.framework.core.grammar.ApplicabilityGrammarParser; import org.eclipse.osee.framework.core.util.WordCoreUtil; import org.eclipse.osee.framework.jdk.core.type.OseeCoreException; +import org.eclipse.osee.logger.Log; import org.eclipse.osee.orcs.OrcsApi; import org.eclipse.osee.orcs.data.ArtifactReadable; public class WordMLApplicabilityHandler { - public static String previewValidApplicabilityContent(OrcsApi orcsApi, String content, BranchId branch) throws OseeCoreException { + public static String previewValidApplicabilityContent(OrcsApi orcsApi, Log logger, String content, BranchId branch, ArtifactId viewId) throws OseeCoreException { Map<String, List<String>> featureValuesAllowed = new TreeMap<>(String.CASE_INSENSITIVE_ORDER); + BranchId branchToUse = getBranchToUse(orcsApi, branch, viewId); + featureValuesAllowed = - orcsApi.getQueryFactory().applicabilityQuery().getBranchViewFeatureValues(branch, branch.getViewId()); + orcsApi.getQueryFactory().applicabilityQuery().getBranchViewFeatureValues(branchToUse, viewId); String toReturn = content; @@ -52,7 +57,15 @@ public class WordMLApplicabilityHandler { CoreArtifactTypes.FeatureDefinition).getResults().getExactlyOne(); String featureDefJson = featureDefArt.getSoleAttributeAsString(CoreAttributeTypes.GeneralStringData); - Collection<String> configurationsAllowed = featureValuesAllowed.get("Config"); + Collection<String> configurations = featureValuesAllowed.get("Config"); + // Only care about the configuration that is included (all others assumed to be excluded) + String includedConfiguration = ""; + for (String config : configurations) { + if (!config.toLowerCase().contains("excluded")) { + includedConfiguration = config; + } + } + Stack<ApplicabilityBlock> applicabilityBlocks = new Stack<>(); Matcher matcher = WordCoreUtil.FULL_PATTERN.matcher(toReturn); @@ -86,7 +99,7 @@ public class WordMLApplicabilityHandler { matcher.group(endBracketGroup) != null ? WordCoreUtil.textOnly(matcher.group(endBracketGroup)) : null; String toInsert = evaluateApplicabilityBlock(applicabilityBlock, optionalEndBracket, toReturn, - featureDefJson, featureValuesAllowed, configurationsAllowed); + featureDefJson, featureValuesAllowed, includedConfiguration); String toReplace = toReturn.substring(applicabilityBlock.getStartInsertIndex(), applicabilityBlock.getEndInsertIndex()); @@ -100,13 +113,39 @@ public class WordMLApplicabilityHandler { toReturn = removeEmptyLists(toReturn); if (applicBlockCount != 0) { - throw new OseeCoreException("An applicability block of text is missing an End Feature/Configuration tag"); + logger.error("An applicability block of text is missing an End Feature/Configuration tag"); } return toReturn; } - private static String evaluateApplicabilityBlock(ApplicabilityBlock applicabilityBlock, String optionalEndBracket, String fullWordML, String featureDefJson, Map<String, List<String>> featureValuesAllowed, Collection<String> configurationsAllowed) { + private static BranchId getBranchToUse(OrcsApi orcsApi, BranchId branch, ArtifactId viewId) { + BranchId branchView = findBranchView(orcsApi, viewId); + return branchView == null ? branch : branchView; + + } + + private static BranchId findBranchView(OrcsApi orcsApi, ArtifactId viewId) { + BranchId branchToUse = null; + boolean foundBranchView = false; + List<BranchViewData> views = orcsApi.getQueryFactory().applicabilityQuery().getViews(); + for (BranchViewData viewData : views) { + List<ArtifactId> branchViews = viewData.getBranchViews(); + for (ArtifactId id : branchViews) { + if (viewId.equals(id)) { + branchToUse = viewData.getBranch(); + foundBranchView = true; + break; + } + } + if (foundBranchView) { + break; + } + } + return branchToUse; + } + + private static String evaluateApplicabilityBlock(ApplicabilityBlock applicabilityBlock, String optionalEndBracket, String fullWordML, String featureDefJson, Map<String, List<String>> featureValuesAllowed, String configurations) { //Remove Logical Messages that were mistaken for optional end brackets if (optionalEndBracket != null && optionalEndBracket.contains(".")) { int originalEnd = applicabilityBlock.getEndInsertIndex(); @@ -124,8 +163,8 @@ public class WordMLApplicabilityHandler { Map<String, String> binDataMap = new TreeMap<>(String.CASE_INSENSITIVE_ORDER); saveBinData(applicabilityBlock.getFullText(), binDataMap); - String toInsert = evaluateApplicabilityExpression(applicabilityBlock, featureDefJson, configurationsAllowed, - featureValuesAllowed); + String toInsert = + evaluateApplicabilityExpression(applicabilityBlock, featureDefJson, configurations, featureValuesAllowed); toInsert = insertMissingbinData(toInsert, binDataMap); return toInsert; @@ -210,7 +249,7 @@ public class WordMLApplicabilityHandler { return applic; } - private static String evaluateApplicabilityExpression(ApplicabilityBlock applic, String featureDefJson, Collection<String> configurationsAllowed, Map<String, List<String>> featureValuesAllowed) { + private static String evaluateApplicabilityExpression(ApplicabilityBlock applic, String featureDefJson, String configuration, Map<String, List<String>> featureValuesAllowed) { String applicabilityExpression = applic.getApplicabilityExpression(); String toInsert = ""; try { @@ -227,7 +266,7 @@ public class WordMLApplicabilityHandler { toInsert = getValidFeatureContent(fullText, applic.isInTable(), parser.getIdValuesMap(), parser.getOperators(), featureDefJson, featureValuesAllowed); } else if (applic.getType().equals(ApplicabilityType.Configuration)) { - toInsert = getValidConfigurationContent(fullText, parser.getIdValuesMap(), configurationsAllowed); + toInsert = getValidConfigurationContent(fullText, parser.getIdValuesMap(), configuration); } } catch (RecognitionException ex) { @@ -238,7 +277,7 @@ public class WordMLApplicabilityHandler { return toInsert; } - public static String getValidConfigurationContent(String fullText, HashMap<String, List<String>> id_value_map, Collection<String> configurationsAllowed) { + public static String getValidConfigurationContent(String fullText, HashMap<String, List<String>> id_value_map, String configuration) { Matcher match = WordCoreUtil.ELSE_PATTERN.matcher(fullText); String beginningText = fullText; String elseText = ""; @@ -254,18 +293,11 @@ public class WordMLApplicabilityHandler { String toReturn = ""; // Note: this assumes only OR's are put in between configurations - for (String id : id_value_map.keySet()) { - boolean isIncluded = true; - List<String> values = id_value_map.get(id); - for (String val : values) { - if (val.equalsIgnoreCase("excluded")) { - isIncluded = false; - } - } - - if (containsIgnoreCase(configurationsAllowed, id) == isIncluded) { + List<String> values = id_value_map.get(configuration.toUpperCase()); + if (values != null) { + String value = values.get(0); + if (!value.toLowerCase().equals("excluded")) { toReturn = beginningText; - break; } } diff --git a/plugins/org.eclipse.osee.define.report/src/org/eclipse/osee/define/report/internal/wordupdate/WordTemplateContentRendererHandler.java b/plugins/org.eclipse.osee.define.report/src/org/eclipse/osee/define/report/internal/wordupdate/WordTemplateContentRendererHandler.java index 7eb90a1ba8f..ec54553b539 100644 --- a/plugins/org.eclipse.osee.define.report/src/org/eclipse/osee/define/report/internal/wordupdate/WordTemplateContentRendererHandler.java +++ b/plugins/org.eclipse.osee.define.report/src/org/eclipse/osee/define/report/internal/wordupdate/WordTemplateContentRendererHandler.java @@ -20,6 +20,7 @@ import org.eclipse.osee.framework.core.enums.CoreAttributeTypes; import org.eclipse.osee.framework.core.enums.DeletionFlag; import org.eclipse.osee.framework.jdk.core.type.OseeCoreException; import org.eclipse.osee.framework.jdk.core.type.Pair; +import org.eclipse.osee.logger.Log; import org.eclipse.osee.orcs.OrcsApi; import org.eclipse.osee.orcs.data.ArtifactReadable; @@ -36,10 +37,13 @@ public class WordTemplateContentRendererHandler { "<w:highlight w:val=\"light-gray\"></w:highlight><w:shd w:color=\"auto\" w:fill=\"BFBFBF\" w:val=\"clear\"></w:shd>"; public static final String EMPTY_PARAGRAPHS = "<w:r wsp:rsidRPr=\"\\d+\"><w:t></w:t></w:r>"; public static final String EXTRA_SPACES = "<w:r><w:t> </w:t></w:r>"; - private final OrcsApi orcsApi; - public WordTemplateContentRendererHandler(OrcsApi orcsApi) { + private OrcsApi orcsApi; + private Log logger; + + public WordTemplateContentRendererHandler(OrcsApi orcsApi, Log logger) { this.orcsApi = orcsApi; + this.logger = logger; } public Pair<String, Set<String>> renderWordML(WordTemplateContentData wtcData) throws OseeCoreException { @@ -97,11 +101,13 @@ public class WordTemplateContentRendererHandler { } } - if (!wtcData.getIsEdit() && wtcData.getBranch().getViewId().notEqual(ArtifactId.SENTINEL)) { + if (!wtcData.getIsEdit() && (wtcData.getBranch().getViewId().notEqual( + ArtifactId.SENTINEL) || isWtcViewIdValid(wtcData))) { data = data.replaceAll(PL_STYLE_WITH_RETURN, ""); data = data.replaceAll(PL_STYLE, ""); data = data.replaceAll(PL_HIGHLIGHT, ""); - data = WordMLApplicabilityHandler.previewValidApplicabilityContent(orcsApi, data, wtcData.getBranch()); + data = WordMLApplicabilityHandler.previewValidApplicabilityContent(orcsApi, logger, data, + wtcData.getBranch(), wtcData.getViewId()); data = data.replaceAll(EMPTY_PARAGRAPHS, ""); } @@ -117,4 +123,8 @@ public class WordTemplateContentRendererHandler { return null; } + + private boolean isWtcViewIdValid(WordTemplateContentData wtcData) { + return (wtcData.getViewId() != null && wtcData.getViewId().notEqual(ArtifactId.SENTINEL)); + } } 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 eee7a1019f2..d1ab6b20381 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,12 +18,15 @@ import java.util.Arrays; import java.util.Collection; import java.util.Collections; import java.util.List; +import java.util.Map; +import java.util.Map.Entry; 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.ArtifactId; 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; @@ -35,6 +38,7 @@ import org.eclipse.osee.framework.skynet.core.transaction.SkynetTransaction; import org.eclipse.osee.framework.skynet.core.transaction.TransactionManager; 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.branch.ViewApplicabilityUtil; import org.eclipse.osee.framework.ui.skynet.internal.ServiceUtil; import org.eclipse.osee.framework.ui.skynet.render.IRenderer; import org.eclipse.osee.framework.ui.skynet.render.ITemplateRenderer; @@ -66,10 +70,12 @@ import org.json.JSONObject; public class PublishWithSpecifiedTemplate extends AbstractBlam { private List<Artifact> templates; private BranchId branch; + private Map<Long, String> branchViews; private XBranchSelectWidget branchWidget; private XCombo slaveWidget; private XDslEditorWidget orcsQueryWidget; + private XCombo branchViewWidget; private XListDropViewer artifactsWidget; private final String USE_ARTIFACT_NAMES = "Use Artifact Names"; private final String USE_PARAGRAPH_NUMBERS = "Use Paragraph Numbers"; @@ -82,6 +88,7 @@ public class PublishWithSpecifiedTemplate extends AbstractBlam { private final String WAS_BRANCH = "WAS Branch"; private final String INCLUDE_ARTIFACT_UUIDS = "Include Artifact UUIDs"; private final String ORCS_QUERY = "Orcs Query"; + private final String VIEW = "Branch View (For IS Artifacts)"; @Override public String getName() { @@ -135,6 +142,14 @@ public class PublishWithSpecifiedTemplate extends AbstractBlam { throw new OseeArgumentException("Cannot determine IS branch."); } + Object view = variableMap.getValue(VIEW); + ArtifactId viewId = ArtifactId.SENTINEL; + for (Entry<Long, String> entry : branchViews.entrySet()) { + if (entry.getValue().equals(view)) { + viewId = ArtifactId.valueOf(entry.getKey()); + } + } + WordTemplateRenderer renderer = new WordTemplateRenderer(); SkynetTransaction transaction = TransactionManager.createTransaction(branch, "BLAM: Publish with specified template"); @@ -169,7 +184,9 @@ public class PublishWithSpecifiedTemplate extends AbstractBlam { ITemplateRenderer.USE_TEMPLATE_ONCE, true, WordTemplateRenderer.FIRST_TIME, - true}; + true, + "ViewId", + viewId}; Boolean isDiff = (Boolean) variableMap.getValue(PUBLISH_AS_DIFF); int toProcessSize = 0; @@ -299,6 +316,10 @@ public class PublishWithSpecifiedTemplate extends AbstractBlam { ")\" displayName=\"%s\" horizontalLabel=\"true\"/><XWidget xwidgetType=\"XLabel\" displayName=\" \" />", SLAVE_TEMPLATE)); builder.append(String.format("<XWidget xwidgetType=\"XListDropViewer\" displayName=\"%s\" />", IS_ARTIFACTS)); + + builder.append("<XWidget xwidgetType=\"XLabel\" displayName=\" \" /><XWidget xwidgetType=\"XCombo("); + builder.append(String.format(")\" displayName=\"%s\" horizontalLabel=\"true\"/>", VIEW)); + builder.append( String.format("<XWidget xwidgetType=\"XDslEditorWidget\" displayName=\"%s\" defaultValue=\"", ORCS_QUERY)); builder.append("orcs"); @@ -348,7 +369,7 @@ public class PublishWithSpecifiedTemplate extends AbstractBlam { public void modifyText(ModifyEvent e) { // only enable slave template selection if Master is for SRS or Engineering Worksheets (EWS) String masterTemplate = masterCombo.get(); - if (masterTemplate.contains("srsMaster") || // + if (masterTemplate.contains("srsMaster") || // masterTemplate.contains("ewsMaster")) { slaveWidget.setEnabled(true); orcsQueryWidget.setEditable(false); @@ -368,9 +389,35 @@ public class PublishWithSpecifiedTemplate extends AbstractBlam { } else if (xWidget.getLabel().equals(IS_ARTIFACTS)) { artifactsWidget = (XListDropViewer) xWidget; artifactsWidget.setEditable(true); + + artifactsWidget.addXModifiedListener(new XModifiedListener() { + + @Override + public void widgetModified(XWidget widget) { + if (branchViewWidget != null) { + branchViewWidget.setEditable(true); + List<Artifact> artifacts = artifactsWidget.getArtifacts(); + if (artifacts != null && !artifacts.isEmpty()) { + Artifact art = artifacts.iterator().next(); + BranchId isArtBranch = art.getBranch(); + if (isArtBranch != null) { + if (ViewApplicabilityUtil.isBranchOfProductLine(isArtBranch)) { + branchViews = + ViewApplicabilityUtil.getBranchViews(ViewApplicabilityUtil.getParentBranch(isArtBranch)); + branchViewWidget.setDataStrings(branchViews.values()); + } + } + } + } + } + }); + } else if (xWidget.getLabel().equals(ORCS_QUERY)) { orcsQueryWidget = (XDslEditorWidget) xWidget; orcsQueryWidget.setEditable(true); + } else if (xWidget.getLabel().equals(VIEW)) { + branchViewWidget = (XCombo) xWidget; + branchViewWidget.setEditable(false); } } diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/branch/ViewApplicabilityUtil.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/branch/ViewApplicabilityUtil.java index 89dd5acd45c..d74f2d1ca1b 100644 --- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/branch/ViewApplicabilityUtil.java +++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/branch/ViewApplicabilityUtil.java @@ -10,20 +10,28 @@ *******************************************************************************/ package org.eclipse.osee.framework.ui.skynet.branch; +import java.util.ArrayList; import java.util.Collection; +import java.util.HashMap; import java.util.List; +import java.util.Map; import java.util.logging.Level; import org.eclipse.jface.window.Window; import org.eclipse.osee.framework.core.data.ApplicabilityId; import org.eclipse.osee.framework.core.data.ApplicabilityToken; -import org.eclipse.osee.framework.core.data.BranchId; +import org.eclipse.osee.framework.core.data.ArtifactId; import org.eclipse.osee.framework.core.data.ArtifactToken; +import org.eclipse.osee.framework.core.data.BranchId; +import org.eclipse.osee.framework.core.data.BranchViewData; +import org.eclipse.osee.framework.core.enums.CoreArtifactTypes; import org.eclipse.osee.framework.core.enums.PermissionEnum; +import org.eclipse.osee.framework.core.exception.ArtifactDoesNotExist; import org.eclipse.osee.framework.core.model.access.PermissionStatus; import org.eclipse.osee.framework.jdk.core.type.OseeCoreException; import org.eclipse.osee.framework.logging.OseeLog; import org.eclipse.osee.framework.skynet.core.AccessPolicy; 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.ui.skynet.internal.Activator; import org.eclipse.osee.framework.ui.skynet.internal.ServiceUtil; @@ -82,4 +90,59 @@ public class ViewApplicabilityUtil { } return true; } + + //########################## + // Support for branch views + //########################## + + public static ApplicabilityEndpoint getApplicabilityEndpoint(BranchId branch) { + if (branch != null) { + ApplicabilityEndpoint applEndpoint = ServiceUtil.getOseeClient().getApplicabilityEndpoint(branch); + return applEndpoint; + } + return null; + } + + public static List<BranchViewData> getBranchViewData(BranchId branch) { + ApplicabilityEndpoint applEndpoint = getApplicabilityEndpoint(branch); + List<BranchViewData> views = new ArrayList<>(); + if (applEndpoint != null) { + views.addAll(applEndpoint.getViews()); + } + return views; + } + + public static Map<Long, String> getBranchViews(BranchId branch) { + Map<Long, String> viewsToBranchData = new HashMap<Long, String>(); + for (BranchViewData view : ViewApplicabilityUtil.getBranchViewData(branch)) { + for (ArtifactId art : view.getBranchViews()) { + try { + Artifact artifact = ArtifactQuery.getArtifactFromId(art, branch); + viewsToBranchData.put(art.getId(), artifact.getName()); + } catch (ArtifactDoesNotExist e) { + // Do Nothing + } + + } + } + return viewsToBranchData; + } + + public static boolean isBranchOfProductLine(BranchId branch) { + int count = ArtifactQuery.createQueryBuilder(branch).andIsOfType(CoreArtifactTypes.FeatureDefinition).getCount(); + return count > 0; + + } + + public static BranchId getParentBranch(BranchId branch) { + if (branch != null) { + BranchId parentBranch = BranchManager.getParentBranch(branch); + if (ViewApplicabilityUtil.isBranchOfProductLine(parentBranch)) { + return parentBranch; + } + return branch; + } + return null; + } + } diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/change/view/ChangeReportEditor.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/change/view/ChangeReportEditor.java index 3d8af2f11ef..0a287c616b0 100644 --- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/change/view/ChangeReportEditor.java +++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/change/view/ChangeReportEditor.java @@ -13,6 +13,7 @@ package org.eclipse.osee.framework.ui.skynet.change.view; import java.util.List; import java.util.logging.Level; import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.osee.framework.core.data.ArtifactId; import org.eclipse.osee.framework.core.data.BranchId; import org.eclipse.osee.framework.core.data.TransactionId; import org.eclipse.osee.framework.jdk.core.type.OseeCoreException; @@ -46,6 +47,7 @@ public class ChangeReportEditor extends FormEditor implements IChangeReportView private BranchTransactionActionBarContributor branchTransactionActionBarContributor; private final EventRelay eventRelay; private BranchTransactionPage branchTransactionPage; + private ArtifactId viewId; public ChangeReportEditor() { eventRelay = new EventRelay(); @@ -146,6 +148,14 @@ public class ChangeReportEditor extends FormEditor implements IChangeReportView } } + public ArtifactId getViewId() { + return viewId; + } + + public void setViewId(ArtifactId viewId) { + this.viewId = viewId; + } + private final class EventRelay implements IBranchEventListener, ITransactionEventListener { @Override 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 bfa2dac08b3..94628459e25 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 @@ -61,6 +61,7 @@ public class ChangeReportPage extends FormPage { private ChangeReportTable changeReportTable; private ChangeReportInfoPresenter infoPresenter; + private ChangeReportPageViewApplicability viewApplicability; public ChangeReportPage(ChangeReportEditor editor) { super(editor, "change.report", "Change Report"); @@ -97,11 +98,13 @@ public class ChangeReportPage extends FormPage { ChangeUiData uiData = getEditorInput().getChangeData(); changeReportTable = new ChangeReportTable(uiData); infoPresenter = new ChangeReportInfoPresenter(new ChangeReportInfo(), uiData); + viewApplicability = new ChangeReportPageViewApplicability(getEditor(), toolkit, form); int sectionStyle = ExpandableComposite.TITLE_BAR | ExpandableComposite.EXPANDED | ExpandableComposite.TWISTIE; managedForm.addPart( new EditorSection(infoPresenter, "Info", form.getBody(), managedForm.getToolkit(), sectionStyle, false)); + viewApplicability.create(); // Can not place table in section or double scroll-bars and maintaining correct table size becomes an issue changeReportTable.onCreate(getManagedForm(), form.getBody()); diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/change/view/ChangeReportPageViewApplicability.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/change/view/ChangeReportPageViewApplicability.java new file mode 100644 index 00000000000..f8c281b6b9b --- /dev/null +++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/change/view/ChangeReportPageViewApplicability.java @@ -0,0 +1,128 @@ +/******************************************************************************* + * Copyright (c) 2017 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.change.view; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.Map; +import org.eclipse.jface.window.Window; +import org.eclipse.osee.framework.core.data.ArtifactId; +import org.eclipse.osee.framework.core.data.BranchId; +import org.eclipse.osee.framework.jdk.core.util.Conditions; +import org.eclipse.osee.framework.ui.skynet.branch.ViewApplicabilityUtil; +import org.eclipse.osee.framework.ui.skynet.change.ChangeReportEditorInput; +import org.eclipse.osee.framework.ui.skynet.widgets.dialog.ViewBranchViewFilterTreeDialog; +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; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.widgets.Button; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.ui.forms.widgets.FormText; +import org.eclipse.ui.forms.widgets.FormToolkit; +import org.eclipse.ui.forms.widgets.ScrolledForm; + +/** + * @author Megumi Telles + */ +public class ChangeReportPageViewApplicability { + + private final FormToolkit toolkit; + private final ScrolledForm form; + private FormText text; + private Button button; + private SelectionAdapter changeableAdapter; + private final ChangeReportEditor editor; + + public ChangeReportPageViewApplicability(ChangeReportEditor editor, FormToolkit toolkit, ScrolledForm form) { + this.toolkit = toolkit; + this.form = form; + this.editor = editor; + } + + public void create() { + Composite applicabilityComp = toolkit.createComposite(form.getForm().getBody(), SWT.WRAP); + applicabilityComp.setLayout(ALayout.getZeroMarginLayout(2, false)); + applicabilityComp.setLayoutData(new GridData(SWT.BEGINNING, SWT.FILL, true, false)); + + text = toolkit.createFormText(applicabilityComp, false); + text.setText(getArtifactViewApplicabiltyText(), true, false); + text.setForeground(Displays.getSystemColor(SWT.COLOR_DARK_GRAY)); + + button = toolkit.createButton(applicabilityComp, "", SWT.PUSH); + button.setText("Set View"); + setButtonChangeable(); + } + + public void refresh() { + text.setText(getArtifactViewApplicabiltyText(), true, false); + editor.refresh(); + } + + private void setButtonChangeable() { + button.addSelectionListener(getChangeableAdapter()); + } + + private SelectionAdapter getChangeableAdapter() { + if (changeableAdapter == null) { + changeableAdapter = new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + super.widgetSelected(e); + changeView(); + refresh(); + } + }; + } + return changeableAdapter; + } + + private String getArtifactViewApplicabiltyText() { + Map<Long, String> branchViews = + ViewApplicabilityUtil.getBranchViews(ViewApplicabilityUtil.getParentBranch(getBranch())); + String result = branchViews.get(editor.getViewId()); + return String.format("<form><p><b>Branch View:</b> %s</p></form>", result == null ? "Not Set" : result); + } + + private BranchId getBranch() { + Conditions.assertNotNull(editor, "Change Editor"); + ChangeReportEditorInput editorInput = editor.getEditorInput(); + if (editorInput != null) { + BranchId branch = editorInput.getBranch(); + if (branch == null) { + button.setEnabled(false); + } + return branch; + } + return null; + } + + private boolean changeView() { + Map<Long, String> branchViews = + ViewApplicabilityUtil.getBranchViews(ViewApplicabilityUtil.getParentBranch(getBranch())); + ViewBranchViewFilterTreeDialog dialog = + new ViewBranchViewFilterTreeDialog("Select Branch View", "Select Branch View", branchViews); + Collection<String> values = new ArrayList<>(); + values.add("<Clear View Selection>"); + values.addAll(branchViews.values()); + dialog.setInput(values); + dialog.setMultiSelect(false); + int result = dialog.open(); + if (result == Window.OK) { + editor.setViewId(ArtifactId.valueOf(dialog.getSelection())); + return true; + } + return false; + } + +} diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/commandHandlers/Handlers.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/commandHandlers/Handlers.java index fdb6221eac3..53fb732086a 100644 --- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/commandHandlers/Handlers.java +++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/commandHandlers/Handlers.java @@ -15,12 +15,21 @@ import java.util.LinkedList; import java.util.List; import org.eclipse.core.runtime.IAdaptable; import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.osee.framework.core.data.ArtifactId; import org.eclipse.osee.framework.core.data.IOseeBranch; import org.eclipse.osee.framework.core.data.TransactionToken; import org.eclipse.osee.framework.skynet.core.artifact.Artifact; import org.eclipse.osee.framework.skynet.core.change.Change; import org.eclipse.osee.framework.skynet.core.conflict.Conflict; +import org.eclipse.osee.framework.ui.plugin.util.AWorkbench; +import org.eclipse.osee.framework.ui.skynet.change.view.ChangeReportEditor; +import org.eclipse.osee.framework.ui.skynet.explorer.ArtifactExplorer; import org.eclipse.search.ui.text.Match; +import org.eclipse.ui.IEditorPart; +import org.eclipse.ui.IWorkbench; +import org.eclipse.ui.IWorkbenchPage; +import org.eclipse.ui.IWorkbenchPart; +import org.eclipse.ui.PlatformUI; /** * This is a utility class for OSEE handlers @@ -89,4 +98,28 @@ public class Handlers { } return objects; } + + public static ArtifactId getViewId() { + IWorkbench workbench = PlatformUI.getWorkbench(); + if (!workbench.isStarting() && !workbench.isClosing()) { + IWorkbenchPage page = AWorkbench.getActivePage(); + if (page != null) { + IWorkbenchPart activePart = page.getActivePart(); + if (activePart instanceof ArtifactExplorer) { + ArtifactId viewId = ((ArtifactExplorer) activePart).getViewId(); + return viewId == null ? ArtifactId.SENTINEL : viewId; + } + if (activePart instanceof ChangeReportEditor) { + ArtifactId viewId = ((ChangeReportEditor) activePart).getViewId(); + return viewId == null ? ArtifactId.SENTINEL : viewId; + } + IEditorPart activeEditor = page.getActiveEditor(); + if (activeEditor instanceof ChangeReportEditor) { + ArtifactId viewId = ((ChangeReportEditor) activeEditor).getViewId(); + return viewId == null ? ArtifactId.SENTINEL : viewId; + } + } + } + return ArtifactId.SENTINEL; + } }
\ No newline at end of file diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/commandHandlers/change/SingleNativeDiffHandler.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/commandHandlers/change/SingleNativeDiffHandler.java index 6f6f4106998..b366b17f2b4 100644 --- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/commandHandlers/change/SingleNativeDiffHandler.java +++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/commandHandlers/change/SingleNativeDiffHandler.java @@ -4,7 +4,7 @@ * 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 *******************************************************************************/ @@ -23,6 +23,7 @@ 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.util.CommandHandler; import org.eclipse.osee.framework.ui.skynet.commandHandlers.Handlers; +import org.eclipse.osee.framework.ui.skynet.render.IRenderer; import org.eclipse.osee.framework.ui.skynet.render.RendererManager; import org.eclipse.osee.framework.ui.skynet.render.RenderingUtil; @@ -46,7 +47,7 @@ public class SingleNativeDiffHandler extends CommandHandler { public Object executeWithException(ExecutionEvent event, IStructuredSelection selection) throws OseeCoreException { Collection<ArtifactDelta> artifactDeltas = ChangeManager.getCompareArtifacts(changes); String pathPrefix = RenderingUtil.getAssociatedArtifactName(changes); - RendererManager.diffInJob(artifactDeltas, pathPrefix); + RendererManager.diffInJob(artifactDeltas, pathPrefix, IRenderer.VIEW_ID, Handlers.getViewId()); return 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/change/ViewWordChangeReportHandler.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/commandHandlers/change/ViewWordChangeReportHandler.java index a768bac0a8f..2bc185dbb6b 100644 --- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/commandHandlers/change/ViewWordChangeReportHandler.java +++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/commandHandlers/change/ViewWordChangeReportHandler.java @@ -54,6 +54,7 @@ public class ViewWordChangeReportHandler extends CommandHandler { if (ArtifactGuis.checkDeletedOnParent(artifacts)) { String pathPrefix = RenderingUtil.getAssociatedArtifactName(localChanges); IRenderer preferredRenderer = new WordTemplateRenderer(); + preferredRenderer.setOption(IRenderer.VIEW_ID, Handlers.getViewId()); RendererManager.diffInJobWithPreferedRenderer(artifactDeltas, pathPrefix, preferredRenderer); } } diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/commandHandlers/renderer/handlers/GeneralPurposeRendererHandler.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/commandHandlers/renderer/handlers/GeneralPurposeRendererHandler.java index c89c78a186e..cf8fc4ff908 100644 --- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/commandHandlers/renderer/handlers/GeneralPurposeRendererHandler.java +++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/commandHandlers/renderer/handlers/GeneralPurposeRendererHandler.java @@ -13,7 +13,9 @@ package org.eclipse.osee.framework.ui.skynet.commandHandlers.renderer.handlers; import java.util.ArrayList; import org.eclipse.core.commands.ExecutionEvent; import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.osee.framework.core.data.ArtifactId; import org.eclipse.osee.framework.core.enums.PresentationType; +import org.eclipse.osee.framework.ui.skynet.commandHandlers.Handlers; import org.eclipse.osee.framework.ui.skynet.render.IRenderer; import org.eclipse.osee.framework.ui.skynet.render.ITemplateRenderer; import org.eclipse.osee.framework.ui.skynet.render.RendererManager; @@ -27,10 +29,11 @@ import org.eclipse.osee.framework.ui.skynet.render.RendererManager; public class GeneralPurposeRendererHandler extends AbstractEditorHandler { @Override public Object executeWithException(ExecutionEvent event, IStructuredSelection selection) { - ArrayList<Object> options = new ArrayList<>(4); + ArrayList<Object> options = new ArrayList<>(6); String presentationTypeStr = event.getParameter(PresentationType.class.getSimpleName()); String template = event.getParameter(ITemplateRenderer.TEMPLATE_OPTION); String openOption = event.getParameter(IRenderer.OPEN_OPTION); + ArtifactId viewId = Handlers.getViewId(); PresentationType presentationType = PresentationType.valueOf(presentationTypeStr); if (template != null) { @@ -41,6 +44,10 @@ public class GeneralPurposeRendererHandler extends AbstractEditorHandler { options.add(IRenderer.OPEN_OPTION); options.add(openOption); } + if (!viewId.equals(ArtifactId.SENTINEL)) { + options.add(IRenderer.VIEW_ID); + options.add(viewId); + } RendererManager.openInJob(artifacts, presentationType, options.toArray()); return null; diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/explorer/ArtifactExplorer.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/explorer/ArtifactExplorer.java index a6129bae41c..3aeabec282b 100644 --- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/explorer/ArtifactExplorer.java +++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/explorer/ArtifactExplorer.java @@ -29,6 +29,7 @@ import org.eclipse.jface.viewers.SelectionChangedEvent; import org.eclipse.jface.viewers.StructuredSelection; import org.eclipse.jface.viewers.TreeViewer; import org.eclipse.osee.framework.access.AccessControlManager; +import org.eclipse.osee.framework.core.data.ArtifactId; import org.eclipse.osee.framework.core.data.BranchId; import org.eclipse.osee.framework.core.data.IOseeBranch; import org.eclipse.osee.framework.core.operation.IOperation; @@ -114,6 +115,9 @@ public class ArtifactExplorer extends GenericViewPart implements IArtifactExplor public ArtifactExplorerMenu artifactExplorerMenu; private ArtifactExplorerToolbar artifactExplorerToolbar; + private ArtifactExplorerViewApplicability view; + private ArtifactId viewId; + public static void explore(Collection<Artifact> artifacts) { explore(artifacts, AWorkbench.getActivePage()); } @@ -166,6 +170,7 @@ public class ArtifactExplorer extends GenericViewPart implements IArtifactExplor branch = selectedBranch; dragAndDropWorker.updateBranch(branch); explore(OseeSystemArtifacts.getDefaultHierarchyRootArtifact(branch)); + refreshView(); } } catch (Exception ex) { setErrorString("Error loading branch (see error log for details): " + ex.getLocalizedMessage()); @@ -175,6 +180,9 @@ public class ArtifactExplorer extends GenericViewPart implements IArtifactExplor }); + view = new ArtifactExplorerViewApplicability(parent, this); + view.create(); + stackComposite = new Composite(parent, SWT.NONE); stackLayout = new StackLayout(); stackComposite.setLayout(stackLayout); @@ -417,6 +425,14 @@ public class ArtifactExplorer extends GenericViewPart implements IArtifactExplor if (branch != null && branchSelect != null && !branch.equals(branchSelect.getData())) { branchSelect.setSelection(branch); refreshBranchWarning(); + refreshView(); + } + } + + private void refreshView() { + setViewId(branch.getViewId()); + if (view != null) { + view.refresh(); } } @@ -524,4 +540,12 @@ public class ArtifactExplorer extends GenericViewPart implements IArtifactExplor return stackComposite; } + public ArtifactId getViewId() { + return viewId; + } + + public void setViewId(ArtifactId viewId) { + this.viewId = viewId; + } + } diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/explorer/ArtifactExplorerViewApplicability.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/explorer/ArtifactExplorerViewApplicability.java new file mode 100644 index 00000000000..978dac92500 --- /dev/null +++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/explorer/ArtifactExplorerViewApplicability.java @@ -0,0 +1,136 @@ +/******************************************************************************* + * Copyright (c) 2017 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.explorer; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.Map; +import org.eclipse.jface.window.Window; +import org.eclipse.osee.framework.core.data.ArtifactId; +import org.eclipse.osee.framework.core.data.BranchId; +import org.eclipse.osee.framework.core.exception.ArtifactDoesNotExist; +import org.eclipse.osee.framework.ui.skynet.branch.ViewApplicabilityUtil; +import org.eclipse.osee.framework.ui.skynet.widgets.dialog.ViewBranchViewFilterTreeDialog; +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; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.widgets.Button; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.ui.forms.widgets.FormText; + +/** + * @author Megumi Telles + */ +public class ArtifactExplorerViewApplicability { + + private final Composite parent; + private FormText text; + private Button button; + private SelectionAdapter changeableAdapter; + private final ArtifactExplorer explorer; + + public ArtifactExplorerViewApplicability(Composite parent, ArtifactExplorer explorer) { + this.parent = parent; + this.explorer = explorer; + } + + public void create() { + Composite applicabilityComp = new Composite(parent, SWT.WRAP); + applicabilityComp.setLayout(ALayout.getZeroMarginLayout(2, false)); + applicabilityComp.setLayoutData(new GridData(SWT.BEGINNING, SWT.FILL, true, false)); + + button = new Button(applicabilityComp, SWT.PUSH); + button.setText("Set View"); + setButtonChangeable(); + + text = new FormText(applicabilityComp, SWT.WRAP); + GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true); + gd.widthHint = 200; + text.setLayoutData(gd); + text.setText(getArtifactViewApplicabiltyText(), true, false); + text.setForeground(Displays.getSystemColor(SWT.COLOR_DARK_GRAY)); + + } + + public void refresh() { + text.setText(getArtifactViewApplicabiltyText(), true, false); + } + + private void setButtonChangeable() { + button.addSelectionListener(getChangeableAdapter()); + + } + + private SelectionAdapter getChangeableAdapter() { + if (changeableAdapter == null) { + changeableAdapter = new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + super.widgetSelected(e); + changeView(); + refresh(); + } + }; + } + return changeableAdapter; + } + + private String getArtifactViewApplicabiltyText() { + Map<Long, String> branchViews; + String result = null; + try { + if (explorer != null) { + BranchId branch = explorer.getBranch(); + if (branch != null) { + if (!ViewApplicabilityUtil.isBranchOfProductLine(branch)) { + button.setEnabled(false); + } else { + ArtifactId viewId = branch.getViewId(); + if (viewId != null && !viewId.equals(ArtifactId.SENTINEL)) { + button.setEnabled(false); + } else { + button.setEnabled(true); + viewId = explorer.getViewId(); + } + branchViews = + ViewApplicabilityUtil.getBranchViews(ViewApplicabilityUtil.getParentBranch(explorer.getBranch())); + result = branchViews.get(viewId); + } + } + } + } catch (ArtifactDoesNotExist ex) { + // do nothing + } + return String.format("<form><p>%s</p></form>", result == null ? "Not Set" : result); + } + + private boolean changeView() { + Map<Long, String> branchViews = + ViewApplicabilityUtil.getBranchViews(ViewApplicabilityUtil.getParentBranch(explorer.getBranch())); + ViewBranchViewFilterTreeDialog dialog = + new ViewBranchViewFilterTreeDialog("Select Branch View", "Select Branch View", branchViews); + Collection<String> values = new ArrayList<>(); + values.add("<Clear View Selection>"); + values.addAll(branchViews.values()); + dialog.setInput(values); + dialog.setMultiSelect(false); + int result = dialog.open(); + if (result == Window.OK) { + explorer.setViewId(ArtifactId.valueOf(dialog.getSelection())); + return true; + } + return false; + } + +} diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/render/IRenderer.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/render/IRenderer.java index eecce4126e7..b23f38a62b5 100644 --- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/render/IRenderer.java +++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/render/IRenderer.java @@ -48,6 +48,7 @@ public interface IRenderer { public static final String OPEN_OPTION = "open.option"; public static final String EXECUTE_VB_SCRIPT = "execute.vb.script"; public static final String OVERRIDE_DATA_RIGHTS_OPTION = "overrideDataRights"; + public static final String VIEW_ID = "ViewId"; public static enum DataRightsClassification { governmentPurposeRights("Government Purpose Rights"), diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/render/RendererManager.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/render/RendererManager.java index 311bb5d8636..f06e392a99e 100644 --- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/render/RendererManager.java +++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/render/RendererManager.java @@ -55,8 +55,8 @@ public final class RendererManager { /** * @return Returns the intersection of renderers applicable for all of the artifacts */ - public static List<IRenderer> getCommonRenderers(Collection<Artifact> artifacts, PresentationType presentationType) throws OseeCoreException { - List<IRenderer> commonRenders = getApplicableRenderers(presentationType, artifacts.iterator().next()); + public static List<IRenderer> getCommonRenderers(Collection<Artifact> artifacts, PresentationType presentationType, Object... data) throws OseeCoreException { + List<IRenderer> commonRenders = getApplicableRenderers(presentationType, artifacts.iterator().next(), data); for (Artifact artifact : artifacts) { List<IRenderer> applicableRenders = getApplicableRenderers(presentationType, artifact); @@ -114,6 +114,7 @@ public final class RendererManager { int bestRating = IRenderer.NO_MATCH; ensurePopulated(); for (IRenderer renderer : renderers) { + renderer.setOptions(options); int rating = renderer.getApplicabilityRating(presentationType, artifact, options); if (rating > bestRating) { bestRendererPrototype = renderer; @@ -137,9 +138,9 @@ public final class RendererManager { artifact.getAttributeTypes()); } - private static List<IRenderer> getApplicableRenderers(PresentationType presentationType, Artifact artifact) throws OseeCoreException { + private static List<IRenderer> getApplicableRenderers(PresentationType presentationType, Artifact artifact, Object... data) throws OseeCoreException { ArrayList<IRenderer> applicableRenderers = new ArrayList<>(); - IRenderer bestRenderer = getBestRenderer(presentationType, artifact); + IRenderer bestRenderer = getBestRenderer(presentationType, artifact, data); int rendererMinimumRanking = bestRenderer.minimumRanking(); int minimumRank = Math.max(rendererMinimumRanking, IRenderer.BASE_MATCH); 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 728867657aa..081f4e0a0b1 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 @@ -18,7 +18,6 @@ import static org.eclipse.osee.framework.core.enums.PresentationType.GENERALIZED import static org.eclipse.osee.framework.core.enums.PresentationType.GENERAL_REQUESTED; import static org.eclipse.osee.framework.core.enums.PresentationType.PREVIEW; import static org.eclipse.osee.framework.core.enums.PresentationType.SPECIALIZED_EDIT; - import java.io.ByteArrayOutputStream; import java.io.File; import java.io.InputStream; @@ -28,14 +27,13 @@ import java.util.LinkedList; import java.util.List; import java.util.Set; import java.util.logging.Level; - import javax.xml.stream.XMLOutputFactory; import javax.xml.stream.XMLStreamException; import javax.xml.stream.XMLStreamWriter; - import org.eclipse.jface.resource.ImageDescriptor; import org.eclipse.osee.define.report.api.WordTemplateContentData; import org.eclipse.osee.framework.core.client.ClientSessionManager; +import org.eclipse.osee.framework.core.data.ArtifactId; import org.eclipse.osee.framework.core.data.AttributeTypeToken; import org.eclipse.osee.framework.core.data.BranchId; import org.eclipse.osee.framework.core.data.TransactionId; @@ -186,6 +184,8 @@ public class WordTemplateRenderer extends WordRenderer implements ITemplateRende wtcData.setTxId(txId); wtcData.setSessionId(ClientSessionManager.getSessionId()); wtcData.setOseeLink(oseeLink); + ArtifactId view = (ArtifactId) getOption(IRenderer.VIEW_ID); + wtcData.setViewId(view == null ? ArtifactId.SENTINEL : view); Pair<String, Set<String>> content = null; try { @@ -346,4 +346,5 @@ public class WordTemplateRenderer extends WordRenderer implements ITemplateRende commands.add(new MenuCmdDef(CommandGroup.PREVIEW, PREVIEW, "MS Word Preview with children", imageDescriptor, TEMPLATE_OPTION, PREVIEW_WITH_RECURSE_VALUE)); } + } diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/render/compare/AbstractWordCompare.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/render/compare/AbstractWordCompare.java index 8bfc4ef3858..1ad89579c4c 100644 --- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/render/compare/AbstractWordCompare.java +++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/render/compare/AbstractWordCompare.java @@ -20,8 +20,8 @@ import java.util.regex.Pattern; import org.eclipse.core.resources.IFile; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.NullProgressMonitor; -import org.eclipse.osee.framework.core.data.BranchId; import org.eclipse.osee.framework.core.data.AttributeTypeId; +import org.eclipse.osee.framework.core.data.BranchId; import org.eclipse.osee.framework.core.data.IOseeBranch; import org.eclipse.osee.framework.core.enums.CoreAttributeTypes; import org.eclipse.osee.framework.core.enums.PresentationType; 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 8f8f34818e5..ce5fb31968b 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,6 +47,7 @@ import org.eclipse.osee.define.report.api.PageOrientation; import org.eclipse.osee.define.report.api.ReportConstants; import org.eclipse.osee.framework.core.data.ApplicabilityId; import org.eclipse.osee.framework.core.data.ApplicabilityToken; +import org.eclipse.osee.framework.core.data.ArtifactId; import org.eclipse.osee.framework.core.data.AttributeTypeId; import org.eclipse.osee.framework.core.data.AttributeTypeToken; import org.eclipse.osee.framework.core.data.BranchId; @@ -308,7 +309,8 @@ public class WordTemplateProcessor { // for single edit override outlining options outlining = false; } - processArtifactSet(templateOptions, artifacts, wordMl, outlineType, presentationType); + processArtifactSet(templateOptions, artifacts, wordMl, outlineType, presentationType, + (ArtifactId) renderer.getOption(IRenderer.VIEW_ID)); } else if (elementType.equals(NESTED_TEMPLATE)) { parseNestedTemplateOptions(templateOptions, folder, wordMl, presentationType); } else { @@ -511,8 +513,10 @@ public class WordTemplateProcessor { return startParagraphNumber; } - private void processArtifactSet(String templateOptions, List<Artifact> artifacts, WordMLProducer wordMl, String outlineType, PresentationType presentationType) throws OseeCoreException { + private void processArtifactSet(String templateOptions, List<Artifact> artifacts, WordMLProducer wordMl, String outlineType, PresentationType presentationType, ArtifactId viewId) throws OseeCoreException { nonTemplateArtifacts.clear(); + renderer.setOption(IRenderer.VIEW_ID, viewId == null ? ArtifactId.SENTINEL : viewId); + if (Strings.isValid(outlineNumber)) { wordMl.setNextParagraphNumberTo(outlineNumber); } @@ -607,6 +611,7 @@ public class WordTemplateProcessor { // Check for option that may have been set from Publish with Diff BLAM to recurse if (recurseChildren && !renderer.getBooleanOption(RECURSE_ON_LOAD) || renderer.getBooleanOption( RECURSE_ON_LOAD) && !renderer.getBooleanOption("Orig Publish As Diff")) { + for (Artifact childArtifact : artifact.getChildren()) { processObjectArtifact(childArtifact, wordMl, outlineType, presentationType, data); } diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/dialog/ViewBranchViewFilterTreeDialog.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/dialog/ViewBranchViewFilterTreeDialog.java new file mode 100644 index 00000000000..252cd23ba22 --- /dev/null +++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/dialog/ViewBranchViewFilterTreeDialog.java @@ -0,0 +1,95 @@ +/******************************************************************************* + * Copyright (c) 2017 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.dialog; + +import java.util.Map; +import java.util.Map.Entry; +import org.eclipse.jface.viewers.ISelectionChangedListener; +import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.jface.viewers.SelectionChangedEvent; +import org.eclipse.osee.framework.core.util.Result; +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.StringLabelProvider; +import org.eclipse.osee.framework.ui.skynet.internal.Activator; +import org.eclipse.osee.framework.ui.skynet.util.StringNameComparator; +import org.eclipse.osee.framework.ui.skynet.widgets.XCheckBox; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; + +/** + * @author Megumi Telles + */ +public class ViewBranchViewFilterTreeDialog extends FilteredTreeDialog { + private Long selection; + XCheckBox showAll = new XCheckBox("Show All Branch Views"); + private final Map<Long, String> branchViews; + + public ViewBranchViewFilterTreeDialog(String title, String message, Map<Long, String> branchViews) { + super(title, message, new ArrayTreeContentProvider(), new StringLabelProvider()); + this.branchViews = branchViews; + } + + @Override + protected Control createDialogArea(Composite container) { + Control comp = super.createDialogArea(container); + try { + getTreeViewer().getViewer().setComparator(new StringNameComparator()); + getTreeViewer().getViewer().addPostSelectionChangedListener(new ISelectionChangedListener() { + @Override + public void selectionChanged(SelectionChangedEvent event) { + IStructuredSelection sel = (IStructuredSelection) getTreeViewer().getViewer().getSelection(); + if (sel.isEmpty()) { + selection = null; + } else { + Object selElement = sel.getFirstElement(); + for (Entry<Long, String> entry : branchViews.entrySet()) { + if (entry.getValue().equals(selElement)) { + selection = entry.getKey(); + break; + } + } + if (selection == null) { + selection = -1L; + } + } + updateStatusLabel(); + } + }); + GridData gd = new GridData(GridData.FILL_BOTH); + gd.heightHint = 500; + getTreeViewer().getViewer().getTree().setLayoutData(gd); + } catch (Exception ex) { + OseeLog.log(Activator.class, OseeLevel.SEVERE_POPUP, ex); + } + + return comp; + } + + @Override + protected Result isComplete() { + try { + if (selection == null) { + return new Result("A View Applicability must be selected."); + } + } catch (Exception ex) { + OseeLog.log(Activator.class, OseeLevel.SEVERE_POPUP, ex); + } + return Result.TrueResult; + } + + public Long getSelection() { + return selection; + } + +} diff --git a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/search/ApplicabilityQueryImpl.java b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/search/ApplicabilityQueryImpl.java index 4c55e778739..2bd8ce04b1b 100644 --- a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/search/ApplicabilityQueryImpl.java +++ b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/search/ApplicabilityQueryImpl.java @@ -112,18 +112,22 @@ public class ApplicabilityQueryImpl implements ApplicabilityQuery { List<ApplicabilityToken> result = getViewApplicabilityTokens(viewId, branch); for (ApplicabilityToken app : result) { - if (!app.getName().equals("Base")) { - String[] nameValue = app.getName().split("="); - String name = nameValue[0].trim(); - String value = nameValue[1].trim(); - - if (toReturn.containsKey(name)) { - List<String> list = new ArrayList<>(); - list.addAll(toReturn.get(name)); - list.add(value); - toReturn.put(name, list); - } else { - toReturn.put(name, Arrays.asList(value)); + if (!app.getName().equalsIgnoreCase("Base")) { + String[] values = app.getName().split("="); + + // This will not return Excluded Configurations + if (values.length <= 2) { + String name = values[0].trim(); + String value = values[1].trim(); + + if (toReturn.containsKey(name)) { + List<String> list = new ArrayList<>(); + list.addAll(toReturn.get(name)); + list.add(value); + toReturn.put(name, list); + } else { + toReturn.put(name, Arrays.asList(value)); + } } } } |