mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
cleanup
This commit is contained in:
@@ -24,7 +24,7 @@ import com.intellij.openapi.actionSystem.ex.ActionManagerEx;
|
||||
import com.intellij.openapi.actionSystem.ex.AnActionListener;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.application.PathManager;
|
||||
import com.intellij.openapi.components.ExportableApplicationComponent;
|
||||
import com.intellij.openapi.components.ExportableComponent;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.keymap.KeymapUtil;
|
||||
import com.intellij.openapi.project.Project;
|
||||
@@ -70,7 +70,7 @@ import java.util.Set;
|
||||
/**
|
||||
* @author max
|
||||
*/
|
||||
public class ActionMacroManager implements ExportableApplicationComponent, NamedJDOMExternalizable {
|
||||
public class ActionMacroManager implements ExportableComponent, NamedJDOMExternalizable, Disposable {
|
||||
private static final Logger LOG = Logger.getInstance("#com.intellij.ide.actionMacro.ActionMacroManager");
|
||||
|
||||
private static final String TYPING_SAMPLE = "WWWWWWWWWWWWWWWWWWWW";
|
||||
@@ -95,6 +95,7 @@ public class ActionMacroManager implements ExportableApplicationComponent, Named
|
||||
public ActionMacroManager(ActionManagerEx actionManagerEx) {
|
||||
myActionManager = actionManagerEx;
|
||||
myActionManager.addAnActionListener(new AnActionListener() {
|
||||
@Override
|
||||
public void beforeActionPerformed(AnAction action, DataContext dataContext, final AnActionEvent event) {
|
||||
String id = myActionManager.getId(action);
|
||||
if (id == null) return;
|
||||
@@ -113,9 +114,11 @@ public class ActionMacroManager implements ExportableApplicationComponent, Named
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void beforeEditorTyping(char c, DataContext dataContext) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterActionPerformed(final AnAction action, final DataContext dataContext, final AnActionEvent event) {
|
||||
}
|
||||
});
|
||||
@@ -124,6 +127,7 @@ public class ActionMacroManager implements ExportableApplicationComponent, Named
|
||||
IdeEventQueue.getInstance().addPostprocessor(myKeyProcessor, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readExternal(Element element) throws InvalidDataException {
|
||||
myMacros = new ArrayList<ActionMacro>();
|
||||
final List macros = element.getChildren(ELEMENT_MACRO);
|
||||
@@ -137,20 +141,24 @@ public class ActionMacroManager implements ExportableApplicationComponent, Named
|
||||
registerActions();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getExternalFileName() {
|
||||
return "macros";
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public File[] getExportFiles() {
|
||||
return new File[]{PathManager.getOptionsFile(this)};
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public String getPresentableName() {
|
||||
return IdeBundle.message("title.macros");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeExternal(Element element) throws WriteExternalException {
|
||||
for (ActionMacro macro : myMacros) {
|
||||
Element macroElement = new Element(ELEMENT_MACRO);
|
||||
@@ -163,14 +171,6 @@ public class ActionMacroManager implements ExportableApplicationComponent, Named
|
||||
return ApplicationManager.getApplication().getComponent(ActionMacroManager.class);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public String getComponentName() {
|
||||
return "ActionMacroManager";
|
||||
}
|
||||
|
||||
public void initComponent() {
|
||||
}
|
||||
|
||||
public void startRecording(String macroName) {
|
||||
LOG.assertTrue(!myIsRecording);
|
||||
myIsRecording = true;
|
||||
@@ -397,6 +397,7 @@ public class ActionMacroManager implements ExportableApplicationComponent, Named
|
||||
|
||||
final PlaybackRunner runner = new PlaybackRunner(script.toString(), new PlaybackRunner.StatusCallback.Edt() {
|
||||
|
||||
@Override
|
||||
public void messageEdt(PlaybackContext context, String text, Type type) {
|
||||
if (type == Type.message || type == Type.error) {
|
||||
StatusBar statusBar = frame.getStatusBar();
|
||||
@@ -414,12 +415,14 @@ public class ActionMacroManager implements ExportableApplicationComponent, Named
|
||||
|
||||
runner.run()
|
||||
.doWhenDone(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
StatusBar statusBar = frame.getStatusBar();
|
||||
statusBar.setInfo("Script execution finished");
|
||||
}
|
||||
})
|
||||
.doWhenProcessed(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
myIsPlaying = false;
|
||||
}
|
||||
@@ -430,7 +433,8 @@ public class ActionMacroManager implements ExportableApplicationComponent, Named
|
||||
return myIsRecording;
|
||||
}
|
||||
|
||||
public void disposeComponent() {
|
||||
@Override
|
||||
public void dispose() {
|
||||
IdeEventQueue.getInstance().removePostprocessor(myKeyProcessor);
|
||||
}
|
||||
|
||||
@@ -525,6 +529,7 @@ public class ActionMacroManager implements ExportableApplicationComponent, Named
|
||||
getTemplatePresentation().setText(macro.getName(), false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed(AnActionEvent e) {
|
||||
IdeEventQueue.getInstance().doWhenReady(new Runnable() {
|
||||
@Override
|
||||
@@ -534,6 +539,7 @@ public class ActionMacroManager implements ExportableApplicationComponent, Named
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(AnActionEvent e) {
|
||||
super.update(e);
|
||||
e.getPresentation().setEnabled(!getInstance().isPlaying());
|
||||
@@ -542,6 +548,7 @@ public class ActionMacroManager implements ExportableApplicationComponent, Named
|
||||
|
||||
private class MyKeyPostpocessor implements IdeEventQueue.EventDispatcher {
|
||||
|
||||
@Override
|
||||
public boolean dispatch(AWTEvent e) {
|
||||
if (isRecording() && e instanceof KeyEvent) {
|
||||
postProcessKeyEvent((KeyEvent)e);
|
||||
|
||||
Reference in New Issue
Block a user