public void example(boolean confirm) { for (int i = 0, c = tabPanel.getWidgetCount(); i < c; i++) { Widget w = tabPanel.getWidget(i); if (w instanceof MetadataGroupPanel) { ((MetadataGroupPanel) w).example(confirm); } } }
/** Puts test values */ void putTestValues(Map<String, String> values) { for (int i = 0, c = tabPanel.getWidgetCount(); i < c; i++) { Widget w = tabPanel.getWidget(i); if (w instanceof MetadataGroupPanel) { ((MetadataGroupPanel) w).putTestValues(values); } } }
/** Delegates to the metadata group panels and updates the internal 'enabled' flag. */ public void enable(boolean enabled) { for (int i = 0, c = tabPanel.getWidgetCount(); i < c; i++) { Widget w = tabPanel.getWidget(i); if (w instanceof MetadataGroupPanel) { ((MetadataGroupPanel) w).enable(enabled); } } this.enabled = enabled; }
private void resetToOriginalOrNewValues( String ontologyUri, OntologyMetadata ontologyMetadata, boolean originalVals, ReviewResult_Old reviewResult_Old, boolean confirm, boolean link) { for (int i = 0, c = tabPanel.getWidgetCount(); i < c; i++) { Widget w = tabPanel.getWidget(i); if (w instanceof MetadataGroupPanel) { ((MetadataGroupPanel) w) .resetToOriginalOrNewValues(ontologyMetadata, originalVals, confirm); } } }
/** * Updates the metadata from the given temporary ontology info object, confirming with the user in * case of any possible overwriting of attributes. */ public void tempOntologyInfoObtained(TempOntologyInfo tempOntologyInfo) { // get the new values from temp file: OntologyMetadata ontologyMetadata = tempOntologyInfo.getOntologyMetadata(); // get current values in the editor: Map<String, String> valuesInEditor = new HashMap<String, String>(); putValues(valuesInEditor, false); // and from the file Map<String, String> tempValues = ontologyMetadata.getOriginalValues(); Set<String> commonKeysWithDiffValues = new HashSet<String>(); // see if there're common attributes with different values in both the editor and the new file for (String tempKey : tempValues.keySet()) { if (valuesInEditor.keySet().contains(tempKey)) { String valueInEditor = valuesInEditor.get(tempKey); String valueInTemp = tempValues.get(tempKey); if (((valueInEditor == null) ^ (valueInTemp == null)) || !valueInEditor.equals(valueInTemp)) { commonKeysWithDiffValues.add(tempKey); } } } if (!commonKeysWithDiffValues.isEmpty()) { // prompt the user for the action to take: String confirmationMsg = "There are different values in the uploaded file for " + commonKeysWithDiffValues.size() + " of the " + "non-empty attributes in the metadata editor. " + "Do you want to replace the existing values in the editor with those from the file?\n" + "\n" + "Select Accept to replace those attributes with values from the file.\n" + "\n" + "Select Cancel to keep the values in the editor.\n" + "\n" + "In either case, missing attributes in the editor will be updated with " + "available values from the file. \n"; // add the attribute names for administrators: if (PortalControl.getInstance().getLoginResult() != null) { LoginResult loginResult = PortalControl.getInstance().getLoginResult(); if (loginResult.isAdministrator()) { confirmationMsg += "\n" + "The attributes are:\n" + commonKeysWithDiffValues; } } if (true) { // this block is just a quick way to open the enclosing DisclosurePanel, if any Widget parent = this.getParent(); while (parent != null) { if (parent instanceof DisclosurePanel) { ((DisclosurePanel) parent).setOpen(true); break; } parent = parent.getParent(); } } if (Window.confirm(confirmationMsg)) { // replace common attributes with values from the file. // Keep tempValues map as it is. See below. } else { // keep values in the editor, so remove the corresponding keys from tempValues: for (String tempKey : commonKeysWithDiffValues) { tempValues.remove(tempKey); } } // use valuesInEditor map to collect the final set of attributes: for (String tempKey : tempValues.keySet()) { valuesInEditor.put(tempKey, tempValues.get(tempKey)); } // and set the final set of attributes: ontologyMetadata.setOriginalValues(valuesInEditor); } for (int i = 0, c = tabPanel.getWidgetCount(); i < c; i++) { Widget w = tabPanel.getWidget(i); if (w instanceof MetadataGroupPanel) { ((MetadataGroupPanel) w).resetToOriginalOrNewValues(ontologyMetadata, true, false); } } }