private boolean _stopEditing(boolean silence) {
if (currentEditor != null) {
stoppingEditing = true;
WidgetAdapter adapter = currentEditor.getAdapter();
IEditor iEditor = currentEditor.getEditor();
try {
iEditor.validateValue();
Object newValue = iEditor.getValue();
Object oldValue = iEditor.getOldValue();
if (isValueChanged(oldValue, newValue)) {
IUndoableOperation operation = new SetWidgetValueOperation(adapter, oldValue, newValue);
IOperationHistory operationHistory = PlatformUI.getWorkbench().getOperationSupport().getOperationHistory();
operation.addContext(adapter.getUndoContext());
operationHistory.execute(operation, null, null);
adapter.setDirty(true);
CompositeAdapter container = (CompositeAdapter) adapter.getParentAdapter();
if (container != null)
container.adjustLayout(adapter.getWidget());
if (adapter.isSelected()) {
designer.publishSelection();
}
}
iEditor.removeChangeListener(this);
iEditor.getComponent().removeFocusListener(this);
iEditor.getComponent().transferFocus();
glassPlane.remove(iEditor.getComponent());
glassPlane.validate();
designer.repaint();
currentEditor = null;
return true;
} catch (Exception e) {
if (silence) {
iEditor.removeChangeListener(this);
iEditor.getComponent().removeFocusListener(this);
glassPlane.remove(iEditor.getComponent());
glassPlane.validate();
currentEditor = null;
} else {
final String message = e.getMessage();
final Shell shell = JavaUtil.getEclipseShell();
shell.getDisplay().syncExec(new Runnable() {
public void run() {
MessageDialog.openError(shell, Messages.GLASS_TARGET_VALIDATION_ERROR, message);
}
});
iEditor.getComponent().requestFocus();
}
return false;
} finally {
stoppingEditing = false;
}