This commit is contained in:
Alexander Lobas
2012-11-27 11:44:59 +04:00
parent 34519b959a
commit 7f89a3ec9e
3 changed files with 28 additions and 16 deletions
@@ -965,6 +965,11 @@ public final class GuiEditor extends JPanel implements DataProvider, ModuleProvi
return null;
}
public boolean isUndoRedoInProgress() {
UndoManager undoManager = UndoManager.getInstance(getProject());
return undoManager.isUndoInProgress() || undoManager.isRedoInProgress();
}
private boolean isActiveEditor() {
return UIDesignerToolWindowManager.getInstance(getProject()).getActiveFormEditor() == this;
}
@@ -240,25 +240,28 @@ public final class InplaceEditingLayer extends JComponent{
* Finishes current inplace editing
*/
private void finishInplaceEditing(){
if(myInplaceComponent == null || myInsideChange){ // nothing to finish
if (myInplaceComponent == null || myInsideChange) { // nothing to finish
return;
}
myInsideChange = true;
try{
// 1. Apply new value to the component
LOG.assertTrue(myInplaceEditor != null);
CommandProcessor.getInstance().executeCommand(
myInplaceComponent.getProject(),
new Runnable() {
public void run() {
try {
final Object value = myInplaceEditor.getValue();
myInplaceProperty.setValue(myInplaceComponent, value);
} catch (Exception ignored){}
myEditor.refreshAndSave(true);
}
}, UIDesignerBundle.message("command.set.property.value"), null);
if (!myEditor.isUndoRedoInProgress()) {
CommandProcessor.getInstance().executeCommand(
myInplaceComponent.getProject(),
new Runnable() {
public void run() {
try {
final Object value = myInplaceEditor.getValue();
myInplaceProperty.setValue(myInplaceComponent, value);
}
catch (Exception ignored) {
}
myEditor.refreshAndSave(true);
}
}, UIDesignerBundle.message("command.set.property.value"), null);
}
// 2. Remove editor from the layer
if (myInplaceEditorComponent != null) { // reenterability guard
@@ -654,14 +654,18 @@ public final class PropertyInspectorTable extends Table implements DataProvider{
public void editingStopped(final ChangeEvent ignored){
LOG.assertTrue(isEditing());
LOG.assertTrue(editingRow!=-1);
if (myStoppingEditing) return;
if (myStoppingEditing) {
return;
}
myStoppingEditing = true;
final Property property=myProperties.get(editingRow);
final PropertyEditor editor=property.getEditor();
editor.removePropertyEditorListener(myPropertyEditorListener);
try {
final Object value = editor.getValue();
setValueAt(value, editingRow, editingColumn);
if (myEditor != null && !myEditor.isUndoRedoInProgress()) {
final Object value = editor.getValue();
setValueAt(value, editingRow, editingColumn);
}
}
catch (final Exception exc) {
showInvalidInput(exc);