ui designer MorphAction: avoid invokeLater

This commit is contained in:
peter
2016-04-06 11:07:27 +02:00
parent a36e02062d
commit 1a23fc52c9
2 changed files with 10 additions and 16 deletions
@@ -45,7 +45,6 @@ import com.intellij.util.IncorrectOperationException;
import com.intellij.util.Processor;
import org.jetbrains.annotations.NotNull;
import javax.swing.*;
import java.util.ArrayList;
import java.util.List;
@@ -64,20 +63,14 @@ public class MorphAction extends AbstractGuiEditorAction {
protected void actionPerformed(final GuiEditor editor, final List<RadComponent> selection, final AnActionEvent e) {
Processor<ComponentItem> processor = new Processor<ComponentItem>() {
public boolean process(final ComponentItem selectedValue) {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
Runnable runnable = new Runnable() {
public void run() {
for(RadComponent c: selection) {
if (!morphComponent(editor, c, selectedValue)) break;
}
editor.refreshAndSave(true);
}
};
CommandProcessor.getInstance().executeCommand(editor.getProject(), runnable, UIDesignerBundle.message("morph.component.command"), null);
editor.getGlassLayer().requestFocus();
Runnable runnable = () -> {
for(RadComponent c: selection) {
if (!morphComponent(editor, c, selectedValue)) break;
}
});
editor.refreshAndSave(true);
};
CommandProcessor.getInstance().executeCommand(editor.getProject(), runnable, UIDesignerBundle.message("morph.component.command"), null);
editor.getGlassLayer().requestFocus();
return true;
}
};
@@ -41,6 +41,7 @@ class PaletteListPopupStep implements ListPopupStep<ComponentItem>, SpeedSearchF
private final Processor<ComponentItem> myRunnable;
private final String myTitle;
private final Project myProject;
private Runnable myFinalRunnable;
PaletteListPopupStep(GuiEditor editor, ComponentItem initialSelection, final Processor<ComponentItem> runnable, final String title) {
myInitialSelection = initialSelection;
@@ -93,12 +94,12 @@ class PaletteListPopupStep implements ListPopupStep<ComponentItem>, SpeedSearchF
}
public PopupStep onChosen(final ComponentItem selectedValue, final boolean finalChoice) {
myRunnable.process(selectedValue);
myFinalRunnable = () -> myRunnable.process(selectedValue);
return PopupStep.FINAL_CHOICE;
}
public Runnable getFinalRunnable() {
return null;
return myFinalRunnable;
}
public boolean hasSubstep(final ComponentItem selectedValue) {