|
| 1 | +/** |
| 2 | + * The contents of this file are subject to the license and copyright |
| 3 | + * detailed in the LICENSE file at the root of the source |
| 4 | + * tree and available online at |
| 5 | + * |
| 6 | + * https://github.com/keeps/roda |
| 7 | + */ |
| 8 | + |
| 9 | +package org.roda.wui.client.planning; |
| 10 | + |
| 11 | +import org.roda.core.data.v2.ip.IndexedAIP; |
| 12 | + |
| 13 | +import com.google.gwt.core.client.GWT; |
| 14 | +import com.google.gwt.uibinder.client.UiBinder; |
| 15 | +import com.google.gwt.uibinder.client.UiField; |
| 16 | +import com.google.gwt.user.client.ui.Composite; |
| 17 | +import com.google.gwt.user.client.ui.Label; |
| 18 | +import com.google.gwt.user.client.ui.Widget; |
| 19 | + |
| 20 | +import config.i18n.client.ClientMessages; |
| 21 | + |
| 22 | +/** |
| 23 | + * @author Luis Faria |
| 24 | + * |
| 25 | + */ |
| 26 | +public class DetailsPanel extends Composite { |
| 27 | + |
| 28 | + private static final ClientMessages messages = GWT.create(ClientMessages.class); |
| 29 | + private static MyUiBinder uiBinder = GWT.create(MyUiBinder.class); |
| 30 | + @UiField |
| 31 | + Label aipID; |
| 32 | + @UiField |
| 33 | + Label aipType; |
| 34 | + @UiField |
| 35 | + Label aipState; |
| 36 | + @UiField |
| 37 | + Label aipCreatedOn; |
| 38 | + @UiField |
| 39 | + Label aipCreatedBy; |
| 40 | + |
| 41 | + @UiField |
| 42 | + Label modifiedOn; |
| 43 | + |
| 44 | + @UiField |
| 45 | + Label modifiedBy; |
| 46 | + |
| 47 | + /* |
| 48 | + * FlowPanel Permissions; |
| 49 | + * |
| 50 | + * @UiField |
| 51 | + * |
| 52 | + * Label riskNotesKey, riskNotesValue; |
| 53 | + * |
| 54 | + * @UiField Label riskPreMitigationKey; |
| 55 | + * |
| 56 | + * @UiField Label riskPreMitigationProbability; |
| 57 | + * |
| 58 | + * @UiField Label riskPreMitigationImpact; |
| 59 | + * |
| 60 | + * @UiField HTML riskPreMitigationSeverity; |
| 61 | + * |
| 62 | + * @UiField Label riskPreMitigationNotesKey, riskPreMitigationNotesValue; |
| 63 | + * |
| 64 | + * @UiField Label riskPosMitigationKey; |
| 65 | + * |
| 66 | + * @UiField Label riskPosMitigationProbabilityKey; |
| 67 | + * |
| 68 | + * @UiField Label riskPosMitigationProbability; |
| 69 | + * |
| 70 | + * @UiField Label riskPosMitigationImpactKey; |
| 71 | + * |
| 72 | + * @UiField Label riskPosMitigationImpact; |
| 73 | + * |
| 74 | + * @UiField Label riskPosMitigationSeverityKey; |
| 75 | + * |
| 76 | + * @UiField HTML riskPosMitigationSeverity; |
| 77 | + * |
| 78 | + * @UiField Label riskPosMitigationNotesKey, riskPosMitigationNotesValue; |
| 79 | + * |
| 80 | + * @UiField Label riskMitigationKey; |
| 81 | + * |
| 82 | + * @UiField Label riskMitigationStrategyKey, riskMitigationStrategyValue; |
| 83 | + * |
| 84 | + * @UiField Label riskMitigationOwnerTypeKey, riskMitigationOwnerTypeValue; |
| 85 | + * |
| 86 | + * @UiField Label riskMitigationOwnerKey, riskMitigationOwnerValue; |
| 87 | + * |
| 88 | + * @UiField Label riskMitigationRelatedEventIdentifierTypeKey, |
| 89 | + * riskMitigationRelatedEventIdentifierTypeValue; |
| 90 | + * |
| 91 | + * @UiField Label riskMitigationRelatedEventIdentifierValueKey, |
| 92 | + * riskMitigationRelatedEventIdentifierValueValue; |
| 93 | + * |
| 94 | + * @UiField(provided = true) SearchWrapper searchWrapper; |
| 95 | + */ |
| 96 | + public DetailsPanel(IndexedAIP aip) { |
| 97 | + initWidget(uiBinder.createAndBindUi(this)); |
| 98 | + init(aip); |
| 99 | + } |
| 100 | + |
| 101 | + public void init(IndexedAIP aip) { |
| 102 | + GWT.log("DetailsPanel init"); |
| 103 | + aipID.setText(aip.getId()); |
| 104 | + aipType.setText(aip.getType()); |
| 105 | + |
| 106 | + aipState.setText(aip.getState().name()); |
| 107 | + aipCreatedOn.setText(String.valueOf(aip.getCreatedOn())); |
| 108 | + aipCreatedBy.setText(aip.getCreatedBy()); |
| 109 | + |
| 110 | + modifiedOn.setText(String.valueOf(aip.getUpdatedOn())); |
| 111 | + modifiedBy.setText(aip.getUpdatedBy()); |
| 112 | + |
| 113 | + /* |
| 114 | + * riskIdentifiedOn.setText(Humanize.formatDate(risk.getIdentifiedOn())); |
| 115 | + * riskIdentifiedBy.setText(risk.getIdentifiedBy()); |
| 116 | + * riskNotesValue.setText(risk.getNotes()); |
| 117 | + * riskNotesKey.setVisible(StringUtils.isNotBlank(risk.getNotes())); |
| 118 | + * |
| 119 | + * for (String category : risk.getCategories()) { Label categoryLabel = new |
| 120 | + * Label(category); categoryLabel.addStyleName("value"); |
| 121 | + * riskCategories.add(categoryLabel); } |
| 122 | + * |
| 123 | + * final int preSeverity = risk.getPreMitigationSeverity(); final int |
| 124 | + * posSeverity = risk.getPostMitigationSeverity(); |
| 125 | + * |
| 126 | + * Services services = new Services("Retrieve risk mitigation terms", "get"); |
| 127 | + * services.riskResource(s -> s.retrieveRiskMitigationTerms(risk.getUUID())) |
| 128 | + * .whenComplete((riskMitigationTerms, throwable) -> { if (throwable == null) { |
| 129 | + * int severityLowLimit = riskMitigationTerms.getSeverityLowLimit(); int |
| 130 | + * severityHighLimit = riskMitigationTerms.getSeverityHighLimit(); |
| 131 | + * |
| 132 | + * riskPreMitigationProbability.setText( |
| 133 | + * messages.riskMitigationProbability(riskMitigationTerms. |
| 134 | + * getPreMitigationProbability().replace(' ', '_'))); riskPreMitigationImpact |
| 135 | + * .setText(messages.riskMitigationImpact(riskMitigationTerms. |
| 136 | + * getPreMitigationImpact().replace(' ', '_'))); |
| 137 | + * |
| 138 | + * riskPreMitigationSeverity |
| 139 | + * .setHTML(HtmlSnippetUtils.getSeverityDefinition(preSeverity, |
| 140 | + * severityLowLimit, severityHighLimit)); |
| 141 | + * |
| 142 | + * riskPosMitigationProbability.setText( |
| 143 | + * messages.riskMitigationProbability(riskMitigationTerms. |
| 144 | + * getPosMitigationProbability().replace(' ', '_'))); riskPosMitigationImpact |
| 145 | + * .setText(messages.riskMitigationImpact(riskMitigationTerms. |
| 146 | + * getPosMitigationImpact().replace(' ', '_'))); |
| 147 | + * |
| 148 | + * riskPosMitigationKey.setVisible(true); |
| 149 | + * riskPosMitigationProbabilityKey.setVisible(true); |
| 150 | + * riskPosMitigationProbability.setVisible(true); |
| 151 | + * riskPosMitigationImpactKey.setVisible(true); |
| 152 | + * riskPosMitigationImpact.setVisible(true); |
| 153 | + * riskPosMitigationSeverityKey.setVisible(true); |
| 154 | + * riskPosMitigationSeverity.setVisible(true); riskPosMitigationSeverity |
| 155 | + * .setHTML(HtmlSnippetUtils.getSeverityDefinition(posSeverity, |
| 156 | + * severityLowLimit, severityHighLimit)); } }); |
| 157 | + * |
| 158 | + * riskPreMitigationNotesValue.setText(risk.getPreMitigationNotes()); |
| 159 | + * riskPreMitigationNotesKey.setVisible(StringUtils.isNotBlank(risk. |
| 160 | + * getPreMitigationNotes())); |
| 161 | + * |
| 162 | + * riskPosMitigationNotesValue.setText(risk.getPostMitigationNotes()); |
| 163 | + * riskPosMitigationNotesKey.setVisible(StringUtils.isNotBlank(risk. |
| 164 | + * getPostMitigationNotes())); |
| 165 | + * |
| 166 | + * int mitigationCounter = 0; |
| 167 | + * |
| 168 | + * if (StringUtils.isNotBlank(risk.getMitigationStrategy())) { |
| 169 | + * mitigationCounter++; riskMitigationStrategyKey.setVisible(true); |
| 170 | + * riskMitigationStrategyValue.setText(risk.getMitigationStrategy()); } else { |
| 171 | + * riskMitigationStrategyKey.setVisible(false); } |
| 172 | + * |
| 173 | + * if (StringUtils.isNotBlank(risk.getMitigationOwnerType())) { |
| 174 | + * mitigationCounter++; riskMitigationOwnerTypeKey.setVisible(true); |
| 175 | + * riskMitigationOwnerTypeValue.setText(risk.getMitigationOwnerType()); } else { |
| 176 | + * riskMitigationOwnerTypeKey.setVisible(false); } |
| 177 | + * |
| 178 | + * if (StringUtils.isNotBlank(risk.getMitigationOwner())) { mitigationCounter++; |
| 179 | + * riskMitigationOwnerKey.setVisible(true); |
| 180 | + * riskMitigationOwnerValue.setText(risk.getMitigationOwner()); } else { |
| 181 | + * riskMitigationOwnerKey.setVisible(false); } |
| 182 | + * |
| 183 | + * if (StringUtils.isNotBlank(risk.getMitigationRelatedEventIdentifierType())) { |
| 184 | + * mitigationCounter++; |
| 185 | + * riskMitigationRelatedEventIdentifierTypeKey.setVisible(true); |
| 186 | + * riskMitigationRelatedEventIdentifierTypeValue.setText(risk. |
| 187 | + * getMitigationRelatedEventIdentifierType()); } else { |
| 188 | + * riskMitigationRelatedEventIdentifierTypeKey.setVisible(false); } |
| 189 | + * |
| 190 | + * if (StringUtils.isNotBlank(risk.getMitigationRelatedEventIdentifierValue())) |
| 191 | + * { mitigationCounter++; |
| 192 | + * riskMitigationRelatedEventIdentifierValueKey.setVisible(true); |
| 193 | + * riskMitigationRelatedEventIdentifierValueValue.setText(risk. |
| 194 | + * getMitigationRelatedEventIdentifierValue()); } else { |
| 195 | + * riskMitigationRelatedEventIdentifierValueKey.setVisible(false); } |
| 196 | + * |
| 197 | + * riskMitigationKey.setVisible(mitigationCounter != 0); |
| 198 | + * |
| 199 | + * // FIXME it must be visible later |
| 200 | + * riskMitigationOwnerTypeKey.setVisible(false); |
| 201 | + * riskMitigationOwnerTypeValue.setVisible(false); |
| 202 | + * riskMitigationRelatedEventIdentifierTypeKey.setVisible(false); |
| 203 | + * riskMitigationRelatedEventIdentifierTypeValue.setVisible(false); |
| 204 | + * riskMitigationRelatedEventIdentifierValueKey.setVisible(false); |
| 205 | + * riskMitigationRelatedEventIdentifierValueValue.setVisible(false); |
| 206 | + */} |
| 207 | + |
| 208 | + public void clear() { |
| 209 | + aipID.setText(""); |
| 210 | + aipType.setText(""); |
| 211 | + aipState.setText(""); |
| 212 | + aipCreatedOn.setText(""); |
| 213 | + aipCreatedBy.setText(""); |
| 214 | + modifiedOn.setText(""); |
| 215 | + modifiedBy.setText(""); |
| 216 | + /* |
| 217 | + * riskNotesKey.setVisible(false); riskNotesValue.setText(""); |
| 218 | + * |
| 219 | + * riskPreMitigationProbability.setText(""); |
| 220 | + * riskPreMitigationImpact.setText(""); riskPreMitigationSeverity.setText(""); |
| 221 | + * riskPreMitigationNotesKey.setVisible(false); |
| 222 | + * riskPreMitigationNotesValue.setText(""); |
| 223 | + * |
| 224 | + * riskPosMitigationKey.setVisible(false); |
| 225 | + * riskPosMitigationProbabilityKey.setVisible(false); |
| 226 | + * riskPosMitigationProbability.setText(""); |
| 227 | + * riskPosMitigationImpactKey.setVisible(false); |
| 228 | + * riskPosMitigationImpact.setText(""); |
| 229 | + * riskPosMitigationSeverityKey.setVisible(false); |
| 230 | + * riskPosMitigationSeverity.setText(""); |
| 231 | + * riskPosMitigationNotesKey.setVisible(false); |
| 232 | + * riskPosMitigationNotesValue.setText(""); |
| 233 | + * |
| 234 | + * riskMitigationKey.setVisible(false); |
| 235 | + * riskMitigationStrategyKey.setVisible(false); |
| 236 | + * riskMitigationStrategyValue.setText(""); |
| 237 | + * riskMitigationOwnerTypeKey.setVisible(false); |
| 238 | + * riskMitigationOwnerTypeValue.setText(""); |
| 239 | + * riskMitigationOwnerKey.setVisible(false); |
| 240 | + * riskMitigationOwnerValue.setText(""); |
| 241 | + * riskMitigationRelatedEventIdentifierTypeKey.setVisible(false); |
| 242 | + * riskMitigationRelatedEventIdentifierTypeValue.setText(""); |
| 243 | + * riskMitigationRelatedEventIdentifierValueKey.setVisible(false); |
| 244 | + * riskMitigationRelatedEventIdentifierValueValue.setText(""); |
| 245 | + */} |
| 246 | + |
| 247 | + interface MyUiBinder extends UiBinder<Widget, DetailsPanel> { |
| 248 | + Widget createAndBindUi(DetailsPanel detailsPanel); |
| 249 | + } |
| 250 | +} |
0 commit comments