mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
cleanup renamed classes
This commit is contained in:
@@ -35,25 +35,25 @@
|
||||
</project-components>
|
||||
|
||||
<actions>
|
||||
<action id="CheckAction" class="com.jetbrains.python.edu.actions.CheckAction" text="check"
|
||||
<action id="CheckAction" class="com.jetbrains.python.edu.actions.StudyCheckAction" text="check"
|
||||
description="Runs tests for current tasks" icon="/icons/icon.jpg">
|
||||
</action>
|
||||
<action id="PrevWindowAction" class="com.jetbrains.python.edu.actions.PrevWindowAction" text="PrevWindowAction" description="prev">
|
||||
<action id="PrevWindowAction" class="com.jetbrains.python.edu.actions.StudyPrevWindowAction" text="PrevWindowAction" description="prev">
|
||||
<add-to-group group-id="MainToolBar" anchor="last"/>
|
||||
</action>
|
||||
|
||||
<action id="NextWindow" class="com.jetbrains.python.edu.actions.NextWindowAction" text="NextWindowAction" description="next">
|
||||
<action id="NextWindow" class="com.jetbrains.python.edu.actions.StudyNextWindowAction" text="NextWindowAction" description="next">
|
||||
<add-to-group group-id="MainToolBar" anchor="last"/>
|
||||
</action>
|
||||
<action id="NextTaskAction" class="com.jetbrains.python.edu.actions.NextTaskAction" text="NextTaskAction" description="Next Task"/>
|
||||
<action id="PreviousTaskAction" class="com.jetbrains.python.edu.actions.PreviousTaskAction" text="PreviousTaskAction"
|
||||
<action id="NextTaskAction" class="com.jetbrains.python.edu.actions.StudyNextStudyTaskAction" text="NextTaskAction" description="Next Task"/>
|
||||
<action id="PreviousTaskAction" class="com.jetbrains.python.edu.actions.StudyPreviousStudyTaskAction" text="PreviousTaskAction"
|
||||
description="Previous Task"/>
|
||||
<action id="RefreshTaskAction" class="com.jetbrains.python.edu.actions.RefreshTaskAction" text="RefreshTaskAction"
|
||||
<action id="RefreshTaskAction" class="com.jetbrains.python.edu.actions.StudyRefreshTaskAction" text="RefreshTaskAction"
|
||||
description="Refresh current task"/>
|
||||
<action id="WatchInputAction" class="com.jetbrains.python.edu.actions.WatchInputAction" text="WatchInputAction"
|
||||
<action id="WatchInputAction" class="com.jetbrains.python.edu.actions.StudyEditInputAction" text="WatchInputAction"
|
||||
description="watch input"/>
|
||||
<action id="StudyRunAction" class="com.jetbrains.python.edu.actions.StudyRunAction" text="StudyRunAction" description="run your code"/>
|
||||
<action id="ShowHintAction" class="com.jetbrains.python.edu.actions.ShowHintAction" text="Show hint"
|
||||
<action id="ShowHintAction" class="com.jetbrains.python.edu.actions.StudyShowHintAction" text="Show hint"
|
||||
description="show hint">
|
||||
<add-to-group group-id="MainToolBar" anchor="last"/>
|
||||
</action>
|
||||
|
||||
@@ -19,9 +19,9 @@ import com.intellij.openapi.wm.ToolWindow;
|
||||
import com.intellij.openapi.wm.ToolWindowAnchor;
|
||||
import com.intellij.openapi.wm.ToolWindowManager;
|
||||
import com.intellij.util.xmlb.XmlSerializer;
|
||||
import com.jetbrains.python.edu.actions.NextWindowAction;
|
||||
import com.jetbrains.python.edu.actions.PrevWindowAction;
|
||||
import com.jetbrains.python.edu.actions.ShowHintAction;
|
||||
import com.jetbrains.python.edu.actions.StudyNextWindowAction;
|
||||
import com.jetbrains.python.edu.actions.StudyPrevWindowAction;
|
||||
import com.jetbrains.python.edu.actions.StudyShowHintAction;
|
||||
import com.jetbrains.python.edu.course.Course;
|
||||
import com.jetbrains.python.edu.course.Lesson;
|
||||
import com.jetbrains.python.edu.course.Task;
|
||||
@@ -129,10 +129,10 @@ public class StudyTaskManager implements ProjectComponent, PersistentStateCompon
|
||||
StudyUtils.updateStudyToolWindow(myProject);
|
||||
studyToolWindow.show(null);
|
||||
}
|
||||
addShortcut(NextWindowAction.SHORTCUT, NextWindowAction.ACTION_ID);
|
||||
addShortcut(PrevWindowAction.SHORTCUT, PrevWindowAction.ACTION_ID);
|
||||
addShortcut(ShowHintAction.SHORTCUT, ShowHintAction.ACTION_ID);
|
||||
addShortcut(NextWindowAction.SHORTCUT2, NextWindowAction.ACTION_ID);
|
||||
addShortcut(StudyNextWindowAction.SHORTCUT, StudyNextWindowAction.ACTION_ID);
|
||||
addShortcut(StudyPrevWindowAction.SHORTCUT, StudyPrevWindowAction.ACTION_ID);
|
||||
addShortcut(StudyShowHintAction.SHORTCUT, StudyShowHintAction.ACTION_ID);
|
||||
addShortcut(StudyNextWindowAction.SHORTCUT2, StudyNextWindowAction.ACTION_ID);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -23,10 +23,6 @@ import org.jetbrains.annotations.NotNull;
|
||||
import java.io.*;
|
||||
import java.util.Collection;
|
||||
|
||||
/**
|
||||
* author: liana
|
||||
* data: 7/15/14.
|
||||
*/
|
||||
public class StudyUtils {
|
||||
private static final Logger LOG = Logger.getInstance(StudyUtils.class.getName());
|
||||
public static void closeSilently(Closeable stream) {
|
||||
@@ -53,6 +49,7 @@ public class StudyUtils {
|
||||
return index >= 0 && index < size;
|
||||
}
|
||||
|
||||
@SuppressWarnings("IOResourceOpenedButNotSafelyClosed")
|
||||
public static String getFileText(String parentDir, String fileName, boolean wrapHTML) {
|
||||
|
||||
File inputFile = parentDir !=null ? new File(parentDir, fileName) : new File(fileName);
|
||||
@@ -118,16 +115,17 @@ public class StudyUtils {
|
||||
return Integer.parseInt(fullName.substring(logicalName.length())) - 1;
|
||||
}
|
||||
|
||||
@SuppressWarnings("IOResourceOpenedButNotSafelyClosed")
|
||||
public static VirtualFile flushWindows(Document document, TaskFile taskFile, VirtualFile file) {
|
||||
VirtualFile taskDir = file.getParent();
|
||||
VirtualFile file_windows = null;
|
||||
VirtualFile fileWindows = null;
|
||||
if (taskDir != null) {
|
||||
String name = file.getNameWithoutExtension() + "_windows";
|
||||
PrintWriter printWriter = null;
|
||||
try {
|
||||
|
||||
file_windows = taskDir.createChildData(taskFile, name);
|
||||
printWriter = new PrintWriter(new FileOutputStream(file_windows.getPath()));
|
||||
fileWindows = taskDir.createChildData(taskFile, name);
|
||||
printWriter = new PrintWriter(new FileOutputStream(fileWindows.getPath()));
|
||||
for (TaskWindow taskWindow : taskFile.getTaskWindows()) {
|
||||
if (!taskWindow.isValid(document)) {
|
||||
continue;
|
||||
@@ -138,13 +136,13 @@ public class StudyUtils {
|
||||
}
|
||||
}
|
||||
catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
LOG.error(e);
|
||||
}
|
||||
finally {
|
||||
closeSilently(printWriter);
|
||||
StudyUtils.synchronize();
|
||||
synchronize();
|
||||
}
|
||||
}
|
||||
return file_windows;
|
||||
return fileWindows;
|
||||
}
|
||||
}
|
||||
|
||||
+11
-8
@@ -35,9 +35,10 @@ import java.awt.*;
|
||||
import java.io.*;
|
||||
import java.util.Map;
|
||||
|
||||
public class CheckAction extends DumbAwareAction {
|
||||
public class StudyCheckAction extends DumbAwareAction {
|
||||
|
||||
private static final Logger LOG = Logger.getInstance(CheckAction.class.getName());
|
||||
private static final Logger LOG = Logger.getInstance(StudyCheckAction.class.getName());
|
||||
public static final String PYTHONPATH = "PYTHONPATH";
|
||||
|
||||
static class StudyTestRunner {
|
||||
public static final String TEST_OK = "#study_plugin test OK";
|
||||
@@ -58,7 +59,7 @@ public class CheckAction extends DumbAwareAction {
|
||||
final Map<String, String> env = commandLine.getEnvironment();
|
||||
final VirtualFile courseDir = project.getBaseDir();
|
||||
if (courseDir != null)
|
||||
env.put("PYTHONPATH", courseDir.getPath());
|
||||
env.put(PYTHONPATH, courseDir.getPath());
|
||||
if (sdk != null) {
|
||||
String pythonPath = sdk.getHomePath();
|
||||
if (pythonPath != null) {
|
||||
@@ -103,9 +104,6 @@ public class CheckAction extends DumbAwareAction {
|
||||
CommandProcessor.getInstance().runUndoTransparentAction(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
//CommandProcessor.getInstance().executeCommand(project, new Runnable() {
|
||||
// @Override
|
||||
// public void run() {
|
||||
final Editor selectedEditor = StudyEditor.getSelectedEditor(project);
|
||||
if (selectedEditor != null) {
|
||||
final FileDocumentManager fileDocumentManager = FileDocumentManager.getInstance();
|
||||
@@ -114,7 +112,7 @@ public class CheckAction extends DumbAwareAction {
|
||||
StudyTaskManager taskManager = StudyTaskManager.getInstance(project);
|
||||
final TaskFile selectedTaskFile = taskManager.getTaskFile(openedFile);
|
||||
if (selectedTaskFile != null) {
|
||||
StudyUtils.flushWindows(selectedEditor.getDocument(), selectedTaskFile, openedFile);
|
||||
VirtualFile windowsDescription = StudyUtils.flushWindows(selectedEditor.getDocument(), selectedTaskFile, openedFile);
|
||||
FileDocumentManager.getInstance().saveAllDocuments();
|
||||
final VirtualFile taskDir = openedFile.getParent();
|
||||
Task currentTask = selectedTaskFile.getTask();
|
||||
@@ -156,6 +154,12 @@ public class CheckAction extends DumbAwareAction {
|
||||
catch (IOException e) {
|
||||
LOG.error(e);
|
||||
}
|
||||
try {
|
||||
windowsDescription.delete(this);
|
||||
}
|
||||
catch (IOException e) {
|
||||
LOG.error("failed to delete windows description", e);
|
||||
}
|
||||
selectedTaskFile.drawAllWindows(selectedEditor);
|
||||
createTestResultPopUp(failedMessage, JBColor.RED, project);
|
||||
}
|
||||
@@ -165,7 +169,6 @@ public class CheckAction extends DumbAwareAction {
|
||||
|
||||
}
|
||||
});
|
||||
//}, null, null);
|
||||
}
|
||||
});
|
||||
}
|
||||
+7
-7
@@ -25,7 +25,7 @@ import com.jetbrains.python.edu.course.Task;
|
||||
import com.jetbrains.python.edu.course.TaskFile;
|
||||
import com.jetbrains.python.edu.course.UserTest;
|
||||
import com.jetbrains.python.edu.editor.StudyEditor;
|
||||
import com.jetbrains.python.edu.ui.TestContentPanel;
|
||||
import com.jetbrains.python.edu.ui.StudyTestContentPanel;
|
||||
import icons.StudyIcons;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@@ -38,12 +38,12 @@ import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class WatchInputAction extends DumbAwareAction {
|
||||
public class StudyEditInputAction extends DumbAwareAction {
|
||||
|
||||
public static final String TEST_TAB_NAME = "test";
|
||||
public static final String USER_TEST_INPUT = "input";
|
||||
public static final String USER_TEST_OUTPUT = "output";
|
||||
private static final Logger LOG = Logger.getInstance(WatchInputAction.class.getName());
|
||||
private static final Logger LOG = Logger.getInstance(StudyEditInputAction.class.getName());
|
||||
private JBEditorTabs tabbedPane;
|
||||
private Map<TabInfo, UserTest> myEditableTabs = new HashMap<TabInfo, UserTest>();
|
||||
|
||||
@@ -68,7 +68,7 @@ public class WatchInputAction extends DumbAwareAction {
|
||||
assert testsDir != null;
|
||||
UserTest userTest = createUserTest(testsDir, currentTask);
|
||||
userTest.setEditable(true);
|
||||
TestContentPanel testContentPanel = new TestContentPanel(userTest);
|
||||
StudyTestContentPanel testContentPanel = new StudyTestContentPanel(userTest);
|
||||
TabInfo testTab = addTestTab(tabbedPane.getTabCount(), testContentPanel, currentTask, true);
|
||||
myEditableTabs.put(testTab, userTest);
|
||||
tabbedPane.addTabSilently(testTab, tabCount - 1);
|
||||
@@ -81,7 +81,7 @@ public class WatchInputAction extends DumbAwareAction {
|
||||
for (UserTest userTest : userTests) {
|
||||
String inputFileText = StudyUtils.getFileText(null, userTest.getInput(), false);
|
||||
String outputFileText = StudyUtils.getFileText(null, userTest.getOutput(), false);
|
||||
TestContentPanel myContentPanel = new TestContentPanel(userTest);
|
||||
StudyTestContentPanel myContentPanel = new StudyTestContentPanel(userTest);
|
||||
myContentPanel.addInputContent(inputFileText);
|
||||
myContentPanel.addOutputContent(outputFileText);
|
||||
TabInfo testTab = addTestTab(i, myContentPanel, currentTask, userTest.isEditable());
|
||||
@@ -137,12 +137,12 @@ public class WatchInputAction extends DumbAwareAction {
|
||||
return userTest;
|
||||
}
|
||||
|
||||
private TabInfo addTestTab(int nameIndex, final TestContentPanel contentPanel, @NotNull final Task currentTask, boolean toBeClosable) {
|
||||
private TabInfo addTestTab(int nameIndex, final StudyTestContentPanel contentPanel, @NotNull final Task currentTask, boolean toBeClosable) {
|
||||
TabInfo testTab = toBeClosable ? createClosableTab(contentPanel, currentTask) : new TabInfo(contentPanel);
|
||||
return testTab.setText(TEST_TAB_NAME + String.valueOf(nameIndex));
|
||||
}
|
||||
|
||||
private TabInfo createClosableTab(TestContentPanel contentPanel, Task currentTask) {
|
||||
private TabInfo createClosableTab(StudyTestContentPanel contentPanel, Task currentTask) {
|
||||
TabInfo closableTab = new TabInfo(contentPanel);
|
||||
final DefaultActionGroup tabActions = new DefaultActionGroup();
|
||||
tabActions.add(new CloseTab(closableTab, currentTask));
|
||||
+1
-1
@@ -5,7 +5,7 @@ import com.jetbrains.python.edu.course.Task;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
public class NextTaskAction extends TaskNavigationAction {
|
||||
public class StudyNextStudyTaskAction extends StudyTaskNavigationAction {
|
||||
|
||||
@Override
|
||||
protected JButton getButton(StudyEditor selectedStudyEditor) {
|
||||
+2
-2
@@ -17,12 +17,12 @@ import icons.StudyIcons;
|
||||
/**
|
||||
* move caret to next task window
|
||||
*/
|
||||
public class NextWindowAction extends DumbAwareAction {
|
||||
public class StudyNextWindowAction extends DumbAwareAction {
|
||||
public static final String ACTION_ID = "NextWindow";
|
||||
public static final String SHORTCUT = "ctrl pressed PERIOD";
|
||||
public static final String SHORTCUT2 = "ctrl pressed ENTER";
|
||||
|
||||
public NextWindowAction() {
|
||||
public StudyNextWindowAction() {
|
||||
super("NextWindowAction", "Select next window", StudyIcons.Next);
|
||||
}
|
||||
|
||||
+2
-2
@@ -18,11 +18,11 @@ import icons.StudyIcons;
|
||||
* author: liana
|
||||
* data: 6/30/14.
|
||||
*/
|
||||
public class PrevWindowAction extends DumbAwareAction {
|
||||
public class StudyPrevWindowAction extends DumbAwareAction {
|
||||
public static final String ACTION_ID = "PrevWindowAction";
|
||||
public static final String SHORTCUT = "ctrl pressed COMMA";
|
||||
|
||||
public PrevWindowAction() {
|
||||
public StudyPrevWindowAction() {
|
||||
super("PrevWindowAction", "Select previous window", StudyIcons.Prev);
|
||||
}
|
||||
|
||||
+1
-1
@@ -6,7 +6,7 @@ import com.jetbrains.python.edu.course.Task;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
public class PreviousTaskAction extends TaskNavigationAction {
|
||||
public class StudyPreviousStudyTaskAction extends StudyTaskNavigationAction {
|
||||
|
||||
@Override
|
||||
protected JButton getButton(StudyEditor selectedStudyEditor) {
|
||||
+2
-2
@@ -23,8 +23,8 @@ import com.jetbrains.python.edu.editor.StudyEditor;
|
||||
|
||||
import java.io.*;
|
||||
|
||||
public class RefreshTaskAction extends DumbAwareAction {
|
||||
private static final Logger LOG = Logger.getInstance(RefreshTaskAction.class.getName());
|
||||
public class StudyRefreshTaskAction extends DumbAwareAction {
|
||||
private static final Logger LOG = Logger.getInstance(StudyRefreshTaskAction.class.getName());
|
||||
|
||||
public void refresh(final Project project) {
|
||||
ApplicationManager.getApplication().invokeLater(new Runnable() {
|
||||
+2
-2
@@ -24,11 +24,11 @@ import icons.StudyIcons;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
public class ShowHintAction extends DumbAwareAction {
|
||||
public class StudyShowHintAction extends DumbAwareAction {
|
||||
public static final String ACTION_ID = "ShowHintAction";
|
||||
public static final String SHORTCUT = "ctrl pressed 7";
|
||||
|
||||
public ShowHintAction() {
|
||||
public StudyShowHintAction() {
|
||||
super("Show hint", "Show hint", StudyIcons.ShowHint);
|
||||
}
|
||||
|
||||
+1
-1
@@ -25,7 +25,7 @@ import java.util.Map;
|
||||
* author: liana
|
||||
* data: 7/21/14.
|
||||
*/
|
||||
abstract public class TaskNavigationAction extends DumbAwareAction {
|
||||
abstract public class StudyTaskNavigationAction extends DumbAwareAction {
|
||||
public void navigateTask(Project project) {
|
||||
Editor selectedEditor = StudyEditor.getSelectedEditor(project);
|
||||
FileDocumentManager fileDocumentManager = FileDocumentManager.getInstance();
|
||||
@@ -121,38 +121,39 @@ public class StudyEditor implements FileEditor {
|
||||
watchInputButton.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
WatchInputAction watchInputAction = (WatchInputAction)ActionManager.getInstance().getAction("WatchInputAction");
|
||||
watchInputAction.showInput(project);
|
||||
StudyEditInputAction studyEditInputAction = (StudyEditInputAction)ActionManager.getInstance().getAction("WatchInputAction");
|
||||
studyEditInputAction.showInput(project);
|
||||
}
|
||||
});
|
||||
}
|
||||
myCheckButton.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
CheckAction checkAction = (CheckAction)ActionManager.getInstance().getAction("CheckAction");
|
||||
checkAction.check(project);
|
||||
StudyCheckAction studyCheckAction = (StudyCheckAction)ActionManager.getInstance().getAction("CheckAction");
|
||||
studyCheckAction.check(project);
|
||||
}
|
||||
});
|
||||
|
||||
myNextTaskButton.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
NextTaskAction nextTaskAction = (NextTaskAction)ActionManager.getInstance().getAction("NextTaskAction");
|
||||
nextTaskAction.navigateTask(project);
|
||||
StudyNextStudyTaskAction studyNextTaskAction = (StudyNextStudyTaskAction)ActionManager.getInstance().getAction("NextTaskAction");
|
||||
studyNextTaskAction.navigateTask(project);
|
||||
}
|
||||
});
|
||||
myPrevTaskButton.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
PreviousTaskAction prevTaskAction = (PreviousTaskAction)ActionManager.getInstance().getAction("PreviousTaskAction");
|
||||
StudyPreviousStudyTaskAction
|
||||
prevTaskAction = (StudyPreviousStudyTaskAction)ActionManager.getInstance().getAction("PreviousTaskAction");
|
||||
prevTaskAction.navigateTask(project);
|
||||
}
|
||||
});
|
||||
myRefreshButton.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
RefreshTaskAction refreshTaskAction = (RefreshTaskAction)ActionManager.getInstance().getAction("RefreshTaskAction");
|
||||
refreshTaskAction.refresh(project);
|
||||
StudyRefreshTaskAction studyRefreshTaskAction = (StudyRefreshTaskAction)ActionManager.getInstance().getAction("RefreshTaskAction");
|
||||
studyRefreshTaskAction.refresh(project);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
+2
-2
@@ -10,12 +10,12 @@ import javax.swing.event.DocumentEvent;
|
||||
import javax.swing.text.BadLocationException;
|
||||
import java.awt.*;
|
||||
|
||||
public class TestContentPanel extends JPanel {
|
||||
public class StudyTestContentPanel extends JPanel {
|
||||
public static final Dimension PREFERRED_SIZE = new Dimension(300, 200);
|
||||
private static final Font HEADER_FONT = new Font("Arial", Font.BOLD, 16);
|
||||
private final JTextArea myInputArea = new JTextArea();
|
||||
private final JTextArea myOutputArea = new JTextArea();
|
||||
public TestContentPanel(UserTest userTest) {
|
||||
public StudyTestContentPanel(UserTest userTest) {
|
||||
this.setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
|
||||
initContentLabel("input", myInputArea);
|
||||
myInputArea.getDocument().addDocumentListener(new BufferUpdater(userTest.getInputBuffer()));
|
||||
Reference in New Issue
Block a user