use of com.intellij.openapi.fileEditor.FileEditor in project intellij-community by JetBrains.
the class CCTaskFileActionTest method testAddTaskFile.
public void testAddTaskFile() {
VirtualFile virtualFile = copyFileToTask("nonTaskFile.txt");
myFixture.configureFromExistingVirtualFile(virtualFile);
launchAction(virtualFile, new CCAddAsTaskFile());
TaskFile taskFile = StudyUtils.getTaskFile(getProject(), virtualFile);
assertNotNull(taskFile);
FileEditor fileEditor = FileEditorManager.getInstance(getProject()).getSelectedEditor(virtualFile);
UndoManager.getInstance(getProject()).undo(fileEditor);
assertNull(StudyUtils.getTaskFile(getProject(), virtualFile));
}
use of com.intellij.openapi.fileEditor.FileEditor in project intellij-community by JetBrains.
the class CCDeleteAllAnswerPlaceholdersAction method actionPerformed.
@Override
public void actionPerformed(AnActionEvent e) {
final DataContext context = e.getDataContext();
final VirtualFile file = CommonDataKeys.VIRTUAL_FILE.getData(context);
final Project project = e.getProject();
if (file == null || project == null) {
return;
}
final TaskFile taskFile = StudyUtils.getTaskFile(project, file);
if (taskFile == null) {
return;
}
Editor editor = CommonDataKeys.EDITOR.getData(context);
if (editor == null) {
FileEditorManager instance = FileEditorManager.getInstance(project);
if (!instance.isFileOpen(file)) {
return;
}
FileEditor fileEditor = instance.getSelectedEditor(file);
if (!(fileEditor instanceof TextEditor)) {
return;
}
editor = ((TextEditor) fileEditor).getEditor();
}
List<AnswerPlaceholder> placeholders = new ArrayList<>(taskFile.getAnswerPlaceholders());
final ClearPlaceholders action = new ClearPlaceholders(taskFile, placeholders, editor);
EduUtils.runUndoableAction(project, ACTION_NAME, action, UndoConfirmationPolicy.REQUEST_CONFIRMATION);
}
use of com.intellij.openapi.fileEditor.FileEditor in project intellij-community by JetBrains.
the class JvmSmartStepIntoActionHandler method doStep.
private static void doStep(@NotNull final Project project, @Nullable final SourcePosition position, @NotNull final DebuggerSession session) {
final VirtualFile file = position != null ? position.getFile().getVirtualFile() : null;
final FileEditor fileEditor = file != null ? FileEditorManager.getInstance(project).getSelectedEditor(file) : null;
if (fileEditor instanceof TextEditor) {
for (JvmSmartStepIntoHandler handler : Extensions.getExtensions(JvmSmartStepIntoHandler.EP_NAME)) {
if (handler.isAvailable(position) && handler.doSmartStep(position, session, (TextEditor) fileEditor)) {
return;
}
}
}
doStepInto(session, Registry.is("debugger.single.smart.step.force"), null);
}
use of com.intellij.openapi.fileEditor.FileEditor in project intellij-community by JetBrains.
the class CommandProcessorImpl method finishCommand.
@Override
public void finishCommand(final Project project, final Object command, final Throwable throwable) {
if (myCurrentCommand != command)
return;
final boolean failed;
try {
if (throwable instanceof AbnormalCommandTerminationException) {
final AbnormalCommandTerminationException rollback = (AbnormalCommandTerminationException) throwable;
if (ApplicationManager.getApplication().isUnitTestMode()) {
throw new RuntimeException(rollback);
}
failed = true;
} else if (throwable != null) {
failed = true;
if (throwable instanceof Error) {
throw (Error) throwable;
} else if (throwable instanceof RuntimeException)
throw (RuntimeException) throwable;
CommandLog.LOG.error(throwable);
} else {
failed = false;
}
} finally {
super.finishCommand(project, command, throwable);
}
if (failed) {
if (project != null) {
FileEditor editor = new FocusBasedCurrentEditorProvider().getCurrentEditor();
final UndoManager undoManager = UndoManager.getInstance(project);
if (undoManager.isUndoAvailable(editor)) {
undoManager.undo(editor);
}
}
Messages.showErrorDialog(project, "Cannot perform operation. Too complex, sorry.", "Failed to Perform Operation");
}
}
use of com.intellij.openapi.fileEditor.FileEditor in project intellij-community by JetBrains.
the class ForcedSoftWrapsNotificationProvider method createNotificationPanel.
@Nullable
@Override
public EditorNotificationPanel createNotificationPanel(@NotNull final VirtualFile file, @NotNull final FileEditor fileEditor) {
if (!(fileEditor instanceof TextEditor))
return null;
final Editor editor = ((TextEditor) fileEditor).getEditor();
final Project project = editor.getProject();
if (project == null || !Boolean.TRUE.equals(editor.getUserData(EditorImpl.FORCED_SOFT_WRAPS)) || PropertiesComponent.getInstance().isTrueValue(DISABLED_NOTIFICATION_KEY))
return null;
final EditorNotificationPanel panel = new EditorNotificationPanel();
panel.setText(EditorBundle.message("forced.soft.wrap.message"));
panel.createActionLabel(EditorBundle.message("forced.soft.wrap.hide.message"), () -> {
editor.putUserData(EditorImpl.FORCED_SOFT_WRAPS, null);
EditorNotifications.getInstance(project).updateNotifications(file);
});
panel.createActionLabel(EditorBundle.message("forced.soft.wrap.dont.show.again.message"), () -> {
PropertiesComponent.getInstance().setValue(DISABLED_NOTIFICATION_KEY, "true");
EditorNotifications.getInstance(project).updateAllNotifications();
});
return panel;
}
Aggregations