use of com.intellij.ide.IdeView in project intellij-community by JetBrains.
the class CCTaskMoveHandlerDelegate method canMove.
@Override
public boolean canMove(DataContext dataContext) {
if (CommonDataKeys.PSI_FILE.getData(dataContext) != null) {
return false;
}
IdeView view = LangDataKeys.IDE_VIEW.getData(dataContext);
if (view == null) {
return false;
}
PsiDirectory sourceDirectory = DirectoryChooserUtil.getOrChooseDirectory(view);
return isTaskDir(sourceDirectory);
}
use of com.intellij.ide.IdeView in project intellij-community by JetBrains.
the class CCPushLesson method update.
@Override
public void update(@NotNull AnActionEvent e) {
e.getPresentation().setEnabledAndVisible(false);
final IdeView view = e.getData(LangDataKeys.IDE_VIEW);
final Project project = e.getData(CommonDataKeys.PROJECT);
if (view == null || project == null) {
return;
}
final Course course = StudyTaskManager.getInstance(project).getCourse();
if (course == null) {
return;
}
if (!course.getCourseMode().equals(CCUtils.COURSE_MODE))
return;
PsiDirectory lessonDir = DirectoryChooserUtil.getOrChooseDirectory(view);
if (lessonDir == null || !lessonDir.getName().contains("lesson")) {
return;
}
final Lesson lesson = course.getLesson(lessonDir.getName());
if (lesson != null && course.getId() > 0) {
e.getPresentation().setEnabledAndVisible(true);
if (lesson.getId() <= 0) {
e.getPresentation().setText("Upload Lesson to Stepik");
}
}
}
use of com.intellij.ide.IdeView in project intellij-community by JetBrains.
the class CCPushTask method update.
@Override
public void update(@NotNull AnActionEvent e) {
e.getPresentation().setEnabledAndVisible(false);
final IdeView view = e.getData(LangDataKeys.IDE_VIEW);
final Project project = e.getData(CommonDataKeys.PROJECT);
if (view == null || project == null) {
return;
}
final Course course = StudyTaskManager.getInstance(project).getCourse();
if (course == null) {
return;
}
if (!course.getCourseMode().equals(CCUtils.COURSE_MODE))
return;
PsiDirectory taskDir = DirectoryChooserUtil.getOrChooseDirectory(view);
if (taskDir == null || !taskDir.getName().contains(EduNames.TASK)) {
return;
}
final PsiDirectory lessonDir = taskDir.getParentDirectory();
if (lessonDir == null)
return;
final Lesson lesson = course.getLesson(lessonDir.getName());
if (lesson != null && lesson.getId() > 0 && course.getId() > 0) {
e.getPresentation().setEnabledAndVisible(true);
final com.jetbrains.edu.learning.courseFormat.Task task = lesson.getTask(taskDir.getName());
if (task.getStepId() <= 0) {
e.getPresentation().setText("Upload Task to Stepik");
}
}
}
use of com.intellij.ide.IdeView in project intellij-community by JetBrains.
the class CreatePackageAction method actionPerformed.
@Override
public void actionPerformed(AnActionEvent e) {
final IdeView view = e.getData(LangDataKeys.IDE_VIEW);
if (view == null) {
return;
}
final Project project = e.getData(CommonDataKeys.PROJECT);
final PsiDirectory directory = DirectoryChooserUtil.getOrChooseDirectory(view);
if (directory == null)
return;
final CreateDirectoryOrPackageHandler validator = new CreateDirectoryOrPackageHandler(project, directory, false, ".") {
@Override
protected void createDirectories(String subDirName) {
super.createDirectories(subDirName);
PsiFileSystemItem element = getCreatedElement();
if (element instanceof PsiDirectory) {
createInitPyInHierarchy((PsiDirectory) element, directory);
}
}
};
Messages.showInputDialog(project, IdeBundle.message("prompt.enter.new.package.name"), IdeBundle.message("title.new.package"), Messages.getQuestionIcon(), "", validator);
final PsiFileSystemItem result = validator.getCreatedElement();
if (result != null) {
view.selectElement(result);
}
}
use of com.intellij.ide.IdeView in project intellij-community by JetBrains.
the class CreateSnapShotAction method actionPerformed.
public void actionPerformed(AnActionEvent e) {
final Project project = e.getData(CommonDataKeys.PROJECT);
final IdeView view = e.getData(LangDataKeys.IDE_VIEW);
if (project == null || view == null) {
return;
}
final PsiDirectory dir = view.getOrChooseDirectory();
if (dir == null)
return;
final SnapShotClient client = new SnapShotClient();
List<RunnerAndConfigurationSettings> appConfigurations = new ArrayList<>();
RunnerAndConfigurationSettings snapshotConfiguration = null;
boolean connected = false;
ApplicationConfigurationType cfgType = ApplicationConfigurationType.getInstance();
List<RunnerAndConfigurationSettings> racsi = RunManager.getInstance(project).getConfigurationSettingsList(cfgType);
for (RunnerAndConfigurationSettings config : racsi) {
if (config.getConfiguration() instanceof ApplicationConfiguration) {
ApplicationConfiguration appConfig = (ApplicationConfiguration) config.getConfiguration();
appConfigurations.add(config);
if (appConfig.ENABLE_SWING_INSPECTOR) {
SnapShooterConfigurationSettings settings = SnapShooterConfigurationSettings.get(appConfig);
snapshotConfiguration = config;
if (settings.getLastPort() > 0) {
try {
client.connect(settings.getLastPort());
connected = true;
} catch (IOException ex) {
connected = false;
}
}
}
if (connected)
break;
}
}
if (snapshotConfiguration == null) {
snapshotConfiguration = promptForSnapshotConfiguration(project, appConfigurations);
if (snapshotConfiguration == null)
return;
}
if (!connected) {
int rc = Messages.showYesNoDialog(project, UIDesignerBundle.message("snapshot.run.prompt"), UIDesignerBundle.message("snapshot.title"), Messages.getQuestionIcon());
if (rc == Messages.NO)
return;
final ApplicationConfiguration appConfig = (ApplicationConfiguration) snapshotConfiguration.getConfiguration();
final SnapShooterConfigurationSettings settings = SnapShooterConfigurationSettings.get(appConfig);
settings.setNotifyRunnable(() -> SwingUtilities.invokeLater(() -> {
Messages.showMessageDialog(project, UIDesignerBundle.message("snapshot.prepare.notice"), UIDesignerBundle.message("snapshot.title"), Messages.getInformationIcon());
try {
client.connect(settings.getLastPort());
} catch (IOException ex) {
Messages.showMessageDialog(project, UIDesignerBundle.message("snapshot.connection.error"), UIDesignerBundle.message("snapshot.title"), Messages.getErrorIcon());
return;
}
runSnapShooterSession(client, project, dir, view);
}));
try {
ExecutionEnvironmentBuilder.create(DefaultRunExecutor.getRunExecutorInstance(), snapshotConfiguration).buildAndExecute();
} catch (ExecutionException ex) {
Messages.showMessageDialog(project, UIDesignerBundle.message("snapshot.run.error", ex.getMessage()), UIDesignerBundle.message("snapshot.title"), Messages.getErrorIcon());
}
} else {
runSnapShooterSession(client, project, dir, view);
}
}
Aggregations