Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adjusting package structure #122

Merged
merged 1 commit into from
Jan 14, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,25 +1,24 @@
package com.shuzijun.leetcode.plugin.actions;
package com.shuzijun.leetcode.plugin.actions.editor;

import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.actionSystem.PlatformDataKeys;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.openapi.wm.WindowManager;
import com.shuzijun.leetcode.plugin.actions.AbstractAction;
import com.shuzijun.leetcode.plugin.manager.ViewManager;
import com.shuzijun.leetcode.plugin.model.Config;
import com.shuzijun.leetcode.plugin.model.LeetcodeEditor;
import com.shuzijun.leetcode.plugin.model.Question;
import com.shuzijun.leetcode.plugin.setting.ProjectConfig;
import com.shuzijun.leetcode.plugin.timer.TimerBarWidget;
import com.shuzijun.leetcode.plugin.utils.MessageUtils;
import com.shuzijun.leetcode.plugin.utils.PropertiesUtils;

/**
* @author shuzijun
*/
public abstract class AbstractTimeAction extends AbstractAsynAction {
abstract class AbstractEditAction extends AbstractAction {

@Override
public void perform(AnActionEvent anActionEvent, Config config) {
public void actionPerformed(AnActionEvent anActionEvent, Config config) {
VirtualFile vf = anActionEvent.getData(PlatformDataKeys.VIRTUAL_FILE);
LeetcodeEditor leetcodeEditor = ProjectConfig.getInstance(anActionEvent.getProject()).getEditor(vf.getPath());
if (leetcodeEditor == null) {
Expand All @@ -30,13 +29,10 @@ public void perform(AnActionEvent anActionEvent, Config config) {
MessageUtils.getInstance(anActionEvent.getProject()).showInfoMsg("info", PropertiesUtils.getInfo("tree.null"));
return;
}
TimerBarWidget timerBarWidget = (TimerBarWidget) WindowManager.getInstance().getStatusBar(anActionEvent.getProject()).getWidget(TimerBarWidget.ID);
if (timerBarWidget != null) {
perform(anActionEvent, config, timerBarWidget, question);
} else {
//For possible reasons, the IDE version is not supported
}

actionPerformed(anActionEvent, config, question);

}

public abstract void perform(AnActionEvent anActionEvent, Config config, TimerBarWidget timerBarWidget, Question question);
public abstract void actionPerformed(AnActionEvent anActionEvent, Config config, Question question);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package com.shuzijun.leetcode.plugin.actions.editor;

import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.application.ApplicationManager;
import com.shuzijun.leetcode.plugin.model.Config;
import com.shuzijun.leetcode.plugin.model.Question;

/**
* @author shuzijun
*/
public abstract class AbstractEditAsynAction extends AbstractEditAction {

@Override
public void actionPerformed(AnActionEvent anActionEvent, Config config, Question question) {
ApplicationManager.getApplication().executeOnPooledThread(new Runnable() {
@Override
public void run() {
perform(anActionEvent, config, question);
}
});
}

public abstract void perform(AnActionEvent anActionEvent, Config config, Question question);
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.shuzijun.leetcode.plugin.actions;
package com.shuzijun.leetcode.plugin.actions.editor;

import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.actionSystem.DefaultActionGroup;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,40 +1,19 @@
package com.shuzijun.leetcode.plugin.actions.editor;

import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.actionSystem.CommonDataKeys;
import com.intellij.openapi.actionSystem.PlatformDataKeys;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.vfs.VirtualFile;
import com.shuzijun.leetcode.plugin.actions.AbstractAction;
import com.shuzijun.leetcode.plugin.manager.CodeManager;
import com.shuzijun.leetcode.plugin.manager.ViewManager;
import com.shuzijun.leetcode.plugin.model.Config;
import com.shuzijun.leetcode.plugin.model.LeetcodeEditor;
import com.shuzijun.leetcode.plugin.model.Question;
import com.shuzijun.leetcode.plugin.setting.ProjectConfig;
import com.shuzijun.leetcode.plugin.utils.MessageUtils;
import com.shuzijun.leetcode.plugin.utils.PropertiesUtils;

/**
* @author shuzijun
*/
public class OpenContentAction extends AbstractAction {
public class OpenContentAction extends AbstractEditAction {

@Override
public void actionPerformed(AnActionEvent anActionEvent, Config config) {
final Editor editor = anActionEvent.getData(CommonDataKeys.EDITOR);
VirtualFile vf = anActionEvent.getData(PlatformDataKeys.VIRTUAL_FILE);
LeetcodeEditor leetcodeEditor = ProjectConfig.getInstance(anActionEvent.getProject()).getEditor(vf.getPath());
if (leetcodeEditor == null) {
return;
}
Question question = ViewManager.getQuestionById(leetcodeEditor.getQuestionId(), anActionEvent.getProject());
if (question == null) {
MessageUtils.getInstance(anActionEvent.getProject()).showInfoMsg("info", PropertiesUtils.getInfo("tree.null"));
return;
}
public void actionPerformed(AnActionEvent anActionEvent, Config config, Question question) {
Project project = anActionEvent.getProject();
ApplicationManager.getApplication().invokeLater(new Runnable() {
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,34 +2,17 @@

import com.intellij.ide.BrowserUtil;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.actionSystem.PlatformDataKeys;
import com.intellij.openapi.vfs.VirtualFile;
import com.shuzijun.leetcode.plugin.actions.AbstractAction;
import com.shuzijun.leetcode.plugin.manager.ViewManager;
import com.shuzijun.leetcode.plugin.model.Config;
import com.shuzijun.leetcode.plugin.model.LeetcodeEditor;
import com.shuzijun.leetcode.plugin.model.Question;
import com.shuzijun.leetcode.plugin.setting.ProjectConfig;
import com.shuzijun.leetcode.plugin.utils.MessageUtils;
import com.shuzijun.leetcode.plugin.utils.PropertiesUtils;
import com.shuzijun.leetcode.plugin.utils.URLUtils;

/**
* @author zzdcon
*/
public class OpenInWebAction extends AbstractAction {
public class OpenInWebAction extends AbstractEditAction {

@Override
public void actionPerformed(AnActionEvent anActionEvent, Config config) {
VirtualFile vf = anActionEvent.getData(PlatformDataKeys.VIRTUAL_FILE);
LeetcodeEditor leetcodeEditor = ProjectConfig.getInstance(anActionEvent.getProject()).getEditor(vf.getPath());
if (leetcodeEditor == null) {
return;
}
Question question = ViewManager.getQuestionById(leetcodeEditor.getQuestionId(), anActionEvent.getProject());
if (question == null) {
MessageUtils.getInstance(anActionEvent.getProject()).showInfoMsg("info", PropertiesUtils.getInfo("tree.null"));
return;
}
public void actionPerformed(AnActionEvent anActionEvent, Config config, Question question) {
BrowserUtil.browse(URLUtils.getLeetcodeProblems() + question.getTitleSlug());
}
}
Original file line number Diff line number Diff line change
@@ -1,17 +1,23 @@
package com.shuzijun.leetcode.plugin.actions.editor;

import com.intellij.openapi.actionSystem.AnActionEvent;
import com.shuzijun.leetcode.plugin.actions.AbstractTimeAction;
import com.intellij.openapi.wm.WindowManager;
import com.shuzijun.leetcode.plugin.model.Config;
import com.shuzijun.leetcode.plugin.model.Question;
import com.shuzijun.leetcode.plugin.timer.TimerBarWidget;

/**
* @author shuzijun
*/
public class ResetTimeAction extends AbstractTimeAction {
public class ResetTimeAction extends AbstractEditAsynAction {

@Override
public void perform(AnActionEvent anActionEvent, Config config, TimerBarWidget timerBarWidget, Question question) {
timerBarWidget.reset();
public void perform(AnActionEvent anActionEvent, Config config, Question question) {
TimerBarWidget timerBarWidget = (TimerBarWidget) WindowManager.getInstance().getStatusBar(anActionEvent.getProject()).getWidget(TimerBarWidget.ID);
if (timerBarWidget != null) {
timerBarWidget.reset();
} else {
//For possible reasons, the IDE version is not supported
}
}
}
Original file line number Diff line number Diff line change
@@ -1,34 +1,17 @@
package com.shuzijun.leetcode.plugin.actions.editor;

import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.actionSystem.PlatformDataKeys;
import com.intellij.openapi.vfs.VirtualFile;
import com.shuzijun.leetcode.plugin.actions.AbstractAsynAction;
import com.shuzijun.leetcode.plugin.manager.CodeManager;
import com.shuzijun.leetcode.plugin.manager.ViewManager;
import com.shuzijun.leetcode.plugin.model.Config;
import com.shuzijun.leetcode.plugin.model.LeetcodeEditor;
import com.shuzijun.leetcode.plugin.model.Question;
import com.shuzijun.leetcode.plugin.setting.ProjectConfig;
import com.shuzijun.leetcode.plugin.utils.MessageUtils;
import com.shuzijun.leetcode.plugin.utils.PropertiesUtils;

/**
* @author shuzijun
*/
public class RunCodeAction extends AbstractAsynAction {
public class RunCodeAction extends AbstractEditAsynAction {

@Override
public void perform(AnActionEvent anActionEvent, Config config) {
VirtualFile vf = anActionEvent.getData(PlatformDataKeys.VIRTUAL_FILE);
LeetcodeEditor leetcodeEditor = ProjectConfig.getInstance(anActionEvent.getProject()).getEditor(vf.getPath());
if (leetcodeEditor == null) {
return;
}
Question question = ViewManager.getQuestionById(leetcodeEditor.getQuestionId(), anActionEvent.getProject());
if (question == null) {
MessageUtils.getInstance(anActionEvent.getProject()).showInfoMsg("info", PropertiesUtils.getInfo("tree.null"));
return;
}
CodeManager.RuncodeCode(question,anActionEvent.getProject());
public void perform(AnActionEvent anActionEvent, Config config, Question question) {
CodeManager.RuncodeCode(question, anActionEvent.getProject());
}
}
Original file line number Diff line number Diff line change
@@ -1,17 +1,23 @@
package com.shuzijun.leetcode.plugin.actions.editor;

import com.intellij.openapi.actionSystem.AnActionEvent;
import com.shuzijun.leetcode.plugin.actions.AbstractTimeAction;
import com.intellij.openapi.wm.WindowManager;
import com.shuzijun.leetcode.plugin.model.Config;
import com.shuzijun.leetcode.plugin.model.Question;
import com.shuzijun.leetcode.plugin.timer.TimerBarWidget;

/**
* @author shuzijun
*/
public class StartTimeAction extends AbstractTimeAction {
public class StartTimeAction extends AbstractEditAsynAction {

@Override
public void perform(AnActionEvent anActionEvent, Config config, TimerBarWidget timerBarWidget, Question question) {
timerBarWidget.startTimer(question.getTitle());
public void perform(AnActionEvent anActionEvent, Config config, Question question) {
TimerBarWidget timerBarWidget = (TimerBarWidget) WindowManager.getInstance().getStatusBar(anActionEvent.getProject()).getWidget(TimerBarWidget.ID);
if (timerBarWidget != null) {
timerBarWidget.startTimer(question.getTitle());
} else {
//For possible reasons, the IDE version is not supported
}
}
}
Loading