updatedIfSet = resource.getResourceInterfaces();
}
} else {
- boolean result = false;
Resource resourceInSelection = resourceManagerRef
.getCurrentResourceInSelection();
if (null != resourceInSelection) {
// Null Check
- result = resourceManagerRef.isPropertyValueInvalid(
- resourceInSelection, properties,
- Constants.RESOURCE_URI);
+ boolean result = resourceManagerRef
+ .isPropertyValueInvalid(resourceInSelection,
+ properties, Constants.RESOURCE_URI);
if (result) {
MessageDialog.openError(parent.getShell(),
"Invalid Resource URI.",
return;
}
+ result = resourceManagerRef.isPropertyValueInvalid(
+ resourceInSelection, properties,
+ Constants.RESOURCE_TYPE);
+ if (result) {
+ MessageDialog.openError(parent.getShell(),
+ "Invalid Resource Type.",
+ Constants.INVALID_RESOURCE_TYPE_MESSAGE);
+ return;
+ }
+
boolean update = false;
boolean uriChange = false;
+ boolean typeChange = false;
boolean nameChange = false;
boolean interfaceChange = false;
update = true;
nameChange = true;
}
+
if (resourceManagerRef.isPropValueChanged(
resourceInSelection, properties,
Constants.RESOURCE_URI)) {
return;
}
- if (resourceManagerRef
- .isResourceStarted(resourceInSelection)) {
- update = MessageDialog.openQuestion(
- parent.getShell(), "Save Details",
- "Resource will be restarted to take the changes."
- + " Do you want to continue?");
- if (!update) {
- return;
- }
- }
-
update = true;
uriChange = true;
}
+
+ if (resourceManagerRef.isPropValueChanged(
+ resourceInSelection, properties,
+ Constants.RESOURCE_TYPE)) {
+ update = true;
+ typeChange = true;
+ }
// Checking whether any changes made in resource
// interfaces by
// comparing the current interface set and updated
// interface set.
- if (null != updatedIfSet) {
- Set<String> curIfSet = resourceInSelection
- .getResourceInterfaces();
+ Set<String> curIfSet = resourceInSelection
+ .getResourceInterfaces();
+ if (null != curIfSet && null != updatedIfSet) {
if (curIfSet.size() != updatedIfSet.size()) {
update = true;
interfaceChange = true;
}
}
if (update) {
+ if (uriChange || typeChange || interfaceChange) {
+ if (resourceManagerRef
+ .isResourceStarted(resourceInSelection)) {
+ update = MessageDialog.openQuestion(
+ parent.getShell(),
+ "Save Details",
+ "Resource will be restarted to take the changes."
+ + " Do you want to continue?");
+ if (!update) {
+ return;
+ }
+ }
+ }
try {
- if (uriChange || nameChange)
+ if (uriChange || nameChange || typeChange)
result = Activator
.getDefault()
.getResourceManager()
resourceManagerRef
.getCurrentResourceInSelection(),
properties, uriChange,
- nameChange);
+ nameChange, typeChange);
if (interfaceChange)
result = Activator
.getDefault()
} catch (SimulatorException ex) {
result = false;
}
- if (result) {
- MessageDialog.openInformation(
- parent.getShell(), "Operation status",
- "Resource properties updated.");
- } else {
+ if (!result) {
MessageDialog.openInformation(
parent.getShell(), "Operation status",
"Failed to update the resource properties.");
resourceSelectionChangedListener);
}
- class PropertycontentProvider implements IStructuredContentProvider {
+ private static class PropertycontentProvider implements
+ IStructuredContentProvider {
@Override
public void dispose() {
if (!getEnableEdit()) {
return null;
}
- // Disabling edit for resource type
String propName = ((MetaProperty) element).getPropName();
- if (null != propName && propName.equals(Constants.RESOURCE_TYPE)) {
- return null;
- }
-
CellEditor editor = new TextCellEditor(viewer.getTable());
if (null != propName && propName.equals(Constants.INTERFACE_TYPES)) {
editor.setStyle(SWT.READ_ONLY);
// Update the local copy of the current resource
// interfaces to keep the state for save operation.
updatedIfSet.clear();
- String newPropValue = "";
+ StringBuilder newPropValue = new StringBuilder();
for (Map.Entry<String, String> entry : curResInterfaces
.entrySet()) {
- if (!newPropValue.isEmpty()) {
- newPropValue += ", ";
+ if (!newPropValue.toString().isEmpty()) {
+ newPropValue.append(", ");
}
String value = ifTypes.get(entry.getKey());
- newPropValue += value;
+ newPropValue.append(value);
updatedIfSet.add(value);
}
// Update the model
MetaProperty prop = (MetaProperty) element;
- prop.setPropValue(newPropValue);
+ prop.setPropValue(newPropValue.toString());
// Update the viewer in a separate UI thread.
Display.getDefault().asyncExec(new Runnable() {
@Override