Skip to content

Commit

Permalink
teiiddes-2415: Fixes parameter deletion issue, parsing issue (caused …
Browse files Browse the repository at this point in the history
…by XML conversion from a JSON object without a root), and the duplicate row of parameters after editing the dafault value.
  • Loading branch information
tejones committed Jan 6, 2015
1 parent e2c45d3 commit bfc4b0c
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -303,14 +303,14 @@ void handleAddProperty() {

if (this.wsProfileDetailsWizardPage!=null){
for( Object key : this.parameterMap.keySet() ) {
Parameter para = (Parameter)this.parameterMap.get((String)key);
Parameter para = (Parameter)this.parameterMap.get(key);
wsProfileDetailsWizardPage.getProfileProperties().put(para.getPropertyKey(), para.getPropertyValue());
}
wsProfileDetailsWizardPage.setParameterMap(this.parameterMap);
wsProfileDetailsWizardPage.urlPreviewText.setText(wsProfileDetailsWizardPage.updateUrlPreview().toString());
}else{
for( Object key : this.parameterMap.keySet() ) {
Parameter para = (Parameter)this.parameterMap.get((String)key);
Parameter para = (Parameter)this.parameterMap.get(key);
propertyPage.getExtraProperties().put(para.getPropertyKey(), para.getPropertyValue());
}
propertyPage.setParameterMap(this.parameterMap);
Expand All @@ -330,9 +330,13 @@ void handleRemoveProperty() {
this.propertiesViewer.refresh();

if (this.wsProfileDetailsWizardPage!=null){
wsProfileDetailsWizardPage.setParameterMap(this.parameterMap);
wsProfileDetailsWizardPage.getProfileProperties().remove(selectedProperty.getName());
wsProfileDetailsWizardPage.urlPreviewText.setText(wsProfileDetailsWizardPage.updateUrlPreview().toString());
}else{
propertyPage.urlPreviewText.setText(wsProfileDetailsWizardPage.updateUrlPreview().toString());
propertyPage.setParameterMap(this.parameterMap);
propertyPage.getExtraProperties().remove(Parameter.PREFIX+selectedProperty.getName());
propertyPage.urlPreviewText.setText(propertyPage.updateUrlPreview().toString());
}
}

Expand Down Expand Up @@ -434,15 +438,15 @@ protected void setValue(Object element, Object value) {
if( newType != null && newType.length() > 0 && !newType.equalsIgnoreCase(oldType)) {
((Parameter)element).setType(Parameter.Type.fromValue(newType));
parameterMap.put(key,element);
propertiesViewer.refresh();
propertiesViewer.refresh(element);
}
} else if( columnID == 2 ) {
String oldDefaultValue = ((Parameter)element).getDefaultValue();
String newDefaultValue = (String)value;
if( newDefaultValue != null && newDefaultValue.length() > 0 && !newDefaultValue.equalsIgnoreCase(oldDefaultValue)) {
((Parameter)element).setDefaultValue(newDefaultValue);
parameterMap.put(key,element);
propertiesViewer.refresh();
propertiesViewer.refresh(element);
}
}
}
Expand Down Expand Up @@ -639,7 +643,10 @@ void handleTypeChanged(Object type) {
private void updateState() {
// check to see if new name is valid
String msg = validateName();


// check to see if new default value is valid
String defaultValueMsg = StringUtilities.isEmpty(this.defaultValue) ? UTIL.getString("AddParameterDialog_emptyDefaultValue") : UTIL.getString("AddParameterDialog_message"); //$NON-NLS-1$

// update UI controls
if (StringUtilities.isEmpty(msg)) {
if (!this.btnOk.isEnabled()) {
Expand All @@ -651,7 +658,7 @@ private void updateState() {
}

this.imageLabel.setImage(getInfoImage());
msg = UTIL.getString("AddParameterDialog_message"); //$NON-NLS-1$
// msg = UTIL.getString("AddParameterDialog_message"); //$NON-NLS-1$
} else {
// value is not valid
if (this.btnOk.isEnabled()) {
Expand All @@ -661,7 +668,11 @@ private void updateState() {
this.imageLabel.setImage(getErrorImage());
}

this.messageLabel.setText(msg);
if (!StringUtilities.isEmpty(msg)) {
this.messageLabel.setText(msg);
}else{
this.messageLabel.setText(defaultValueMsg);
}
this.messageLabel.pack();
}

Expand Down Expand Up @@ -712,10 +723,10 @@ private boolean isValidChar(char c) {
* @param proposedValue the proposed value
* @return an error message or <code>null</code> if value is valid
*/
public String validateValue( String proposedValue ) {
public String validateDefaultValue( String proposedValue ) {
// must have a value
if (StringUtilities.isEmpty(proposedValue)) {
return UTIL.getString("AddParameterDialog_emptyParameterValue"); //$NON-NLS-1$
return UTIL.getString("AddParameterDialog_emptyDefaultValue"); //$NON-NLS-1$
}

// valid
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,7 @@ public void widgetDefaultSelected(SelectionEvent e) {
* @return the extraProperties
*/
public Properties getExtraProperties() {
this.extraProperties = new Properties();
for( String key : this.getParameterMap().keySet() ) {
Parameter para = this.getParameterMap().get(key);
this.extraProperties.put(para.getPropertyKey(), para.getPropertyValue());
Expand All @@ -288,7 +289,7 @@ public Properties getExtraProperties() {
public void setExtraProperties(Properties extraProperties) {
for( String key : this.getParameterMap().keySet() ) {
Parameter para = this.getParameterMap().get(key);
this.extraProperties.put(para.getPropertyKey(), para.getPropertyValue());
extraProperties.put(para.getPropertyKey(), para.getPropertyValue());
}
this.extraProperties = extraProperties;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,7 @@ AddParameterDialog_customParameterAlreadyExists = Parameter "{0}" already exists
AddParameterDialog_emptyParameterName=Name of parameter cannot be empty
AddParameterDialog_invalidParameterName=Name must contain only letters and/or numbers
AddParameterDialog_emptyParameterValue=Parameter cannot be empty
AddParameterDialog_emptyDefaultValue = Default value cannot be empty

ExtraPropertiesPanel_groupTitle=Miscellaneous Properties
ExtraPropertiesPanel_name=Name
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -868,8 +868,8 @@ TeiidMetadataImportSourcePage.viewFileNameMustBeSpecified=View model name cannot
TeiidMetadataImportSourcePage.illegalFileName=Invalid model name. {0}
TeiidMetadataImportSourcePage.fileAlreadyExistsMessage=View model file already exits
TeiidMetadataImportSourcePage.newViewProcedureName=New View Procedure Name:
TeiidMetadataImportSourcePage.viewProcedureNameInvalid=View procedure name invalid. {0}
TeiidMetadataImportSourcePage.viewProcedureAlreadyExists=View procedure name {0} already exists in target view model.
TeiidMetadataImportSourcePage.viewProcedureNameInvalid=View procedure name invalid.
TeiidMetadataImportSourcePage.viewProcedureAlreadyExists=View procedure name already exists in target view model.
TeiidMetadataImportSourcePage.viewProcedureNameNullOrEmpty=View procedure name is null or empty

TeiidMetadataImportSourcePage.noDataFilesSelected=No Data Files Selected For Import
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -326,14 +326,14 @@ private void createFolderContentsListGroup(Composite parent) {
selectedFileText.setEditable(false);

Button showFileContentsButton = new Button(folderContentsGroup, SWT.PUSH);
showFileContentsButton.setText("Show Contents");
showFileContentsButton.setText("Show Contents"); //$NON-NLS-1$
showFileContentsButton.addSelectionListener(new SelectionListener() {

@Override
public void widgetSelected(SelectionEvent e) {
if( modelsDefinitionSection.getXmlFileInfo() != null ) {
FileUiUtils.INSTANCE.showFileContents(getShell(), modelsDefinitionSection.getXmlFileInfo().getDataFile(),
"Response Document", modelsDefinitionSection.getXmlFileInfo().getDataFile().getName());
"Response Document", modelsDefinitionSection.getXmlFileInfo().getDataFile().getName()); //$NON-NLS-1$
}
}

Expand Down Expand Up @@ -693,9 +693,9 @@ private File getXmlFileFromRestUrl(IConnectionProfile profile) {
MessageDialog.openError(this.getShell(), getString("ioErrorTitle"), //$NON-NLS-1$
getString("ioErrorMessage") + ex.getMessage()); //$NON-NLS-1$
} catch (Exception ex) {
if( ex instanceof JSONException && ex.getMessage().contains("A JSONObject text must begin with") ) {
if( ex instanceof JSONException && ex.getMessage().contains("A JSONObject text must begin with") ) { //$NON-NLS-1$

String message = getString("invalidRESTResponseTypeMessage", responseType);
String message = getString("invalidRESTResponseTypeMessage", responseType); //$NON-NLS-1$
MessageDialog.openError(this.getShell(),
getString("invalidRESTConnectionProfileTitle"), //$NON-NLS-1$
message); //$NON-NLS-1$
Expand Down Expand Up @@ -734,7 +734,7 @@ private File convertJsonToXml(File jsonFile, String name) throws IOException, Ex

jsonFile = File.createTempFile(
CoreStringUtil.createFileName(jsonFile.getName()), DOT_XML_LOWER);
String xml = XML.toString(jsonObject);
String xml = XML.toString(jsonObject, "result"); //$NON-NLS-1$
FileUtils.write(xml.getBytes(), jsonFile);
return jsonFile;

Expand Down

0 comments on commit bfc4b0c

Please sign in to comment.