Java Code Examples for com.intellij.openapi.ui.Messages

The following are top voted examples for showing how to use com.intellij.openapi.ui.Messages. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: Dependency-Injection-Graph   File: SetPackageFilter.java   Source Code and License 8 votes vote down vote up
@Override
public void actionPerformed(AnActionEvent anActionEvent) {
    Project project = anActionEvent.getProject();

    if (project != null) {

        String packageName = Messages.showInputDialog(
                Strings.MESSAGE_ASK_PACKAGE_NAME_TO_FILTER,
                Strings.TITLE_ASK_PACKAGE_NAME_TO_FILTER,
                Messages.getQuestionIcon(),
                PropertiesManager.getData(project, PropertyKeys.PACKAGE_NAME),
                new NonEmptyInputValidator());

        if (!TextUtils.isEmpty(packageName)) {
            PropertiesManager.putData(project, PropertyKeys.PACKAGE_NAME, packageName);
        }
    }
}
 
Example 2
Project: educational-plugin   File: CCFromCourseArchive.java   Source Code and License 7 votes vote down vote up
private static void unpackCourseArchive(final Project project) {
  FileChooserDescriptor descriptor =
    new FileChooserDescriptor(true, true, true, true, true, false);

  final VirtualFile virtualFile = FileChooser.chooseFile(descriptor, project, null);
  if (virtualFile == null) {
    return;
  }
  final String basePath = project.getBasePath();
  if (basePath == null) return;

  Course course = StudyProjectGenerator.getCourse(virtualFile.getPath());
  if (course == null) {
    Messages.showErrorDialog("This course is incompatible with current version", "Failed to Unpack Course");
    return;
  }
  generateFromStudentCourse(project, course);
}
 
Example 3
Project: CodeGenerate   File: TemplateEditPane.java   Source Code and License 6 votes vote down vote up
public TemplateEditPane(CodeMakerSettings settings, String template,
                        CodeMakerConfiguration parentPane) {
    CodeTemplate codeTemplate = settings.getCodeTemplate(template);
    if (codeTemplate == null) {
        codeTemplate = CodeTemplate.EMPTY_TEMPLATE;
    }

    templateNameText.setText(codeTemplate.getName());
    classNumberText.setText(String.valueOf(codeTemplate.getClassNumber()));
    classNameText.setText(codeTemplate.getClassNameVm());
    addVmEditor(codeTemplate.getCodeTemplate());
    deleteTemplateButton.addActionListener(e -> {
        int result = Messages.showYesNoDialog("删除模板?", "删除", null);
        if (result == Messages.OK) {
            settings.removeCodeTemplate(template);
            parentPane.refresh(settings);
        }
    });
}
 
Example 4
Project: idea-sourcetrail   File: Ping.java   Source Code and License 6 votes vote down vote up
public static void send()
{
    SourcetrailOptions options = SourcetrailOptions.getInstance();
    try
    {
        String text = "ping>>" + ApplicationNamesInfo.getInstance().getFullProductName() + "<EOM>";
        Socket socket = new Socket(options.getIp(), options.getSourcetrailPort());
        BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(socket.getOutputStream()));
        writer.write(text);
        writer.flush();
        socket.close();
    }
    catch(Exception e)
    {
        String errorMsg =
                "No connection to a Sourcetrail instance\n\n Make sure Sourcetrail is running and the right address is used("
                        + options.getIp() + ":" + options.getSourcetrailPort() + ")";
        Messages.showMessageDialog(errorMsg, "SourcetrailPluginError", Messages.getErrorIcon());
        e.printStackTrace();

    }

}
 
Example 5
Project: idea-php-typo3-plugin   File: NewExtensionFileAction.java   Source Code and License 6 votes vote down vote up
@Override
public void actionPerformed(@NotNull AnActionEvent event) {

    final Project project = getEventProject(event);
    if (project == null) {
        this.setStatus(event, false);
        return;
    }

    PsiDirectory bundleDirContext = ExtensionUtility.getExtensionDirectory(event);
    if (bundleDirContext == null) {
        return;
    }

    String className = Messages.showInputDialog(project, "New class name:", "New File", TYPO3CMSIcons.TYPO3_ICON);
    if (StringUtils.isBlank(className)) {
        return;
    }

    if (!PhpNameUtil.isValidClassName(className)) {
        JOptionPane.showMessageDialog(null, "Invalid class name");
        return;
    }

    write(project, bundleDirContext, className);
}
 
Example 6
Project: watchMe   File: SlackSettings.java   Source Code and License 6 votes vote down vote up
public void actionPerformed(AnActionEvent e) {
    this.project = e.getData(CommonDataKeys.PROJECT);

    String description = this.showInputDialog(SlackChannel.getIdDescription(), null);

    if (!isValidField(description)) {
        errorMessage();
        return;
    }

    String token = this.showInputDialog(SlackChannel.getTokenDescription(), null);

    if (!isValidField(token)) {
        errorMessage();
        return;
    }

    String channel = this.showInputDialog(SlackChannel.getChanneNameDescription(), "");

    SlackStorage.getInstance().registerChannel(new SlackChannel(token, description, channel));
    Messages.showMessageDialog(this.project, "Settings Saved.", "Information", Messages.getInformationIcon());
}
 
Example 7
Project: watchMe   File: SlackSettings.java   Source Code and License 6 votes vote down vote up
@Override
public void actionPerformed(AnActionEvent e) {
    final Project project = e.getData(CommonDataKeys.PROJECT);

    List<String> channelsId = SlackStorage.getInstance().getChannelsId();

    if (channelsId.size() > 0) {
        String channelToRemove = Messages.showEditableChooseDialog(
                "Select the channel to remove",
                SlackChannel.getSettingsDescription(),
                SlackStorage.getSlackIcon(),
                channelsId.toArray(new String[channelsId.size()]),
                channelsId.get(0),
                null
        );

        if (channelsId.contains(channelToRemove)) {
            SlackStorage.getInstance().removeChannelByDescription(channelToRemove);
            Messages.showMessageDialog(project, "Channel \"" + channelToRemove + "\" removed.", "Information", Messages.getInformationIcon());
        }
    }
}
 
Example 8
Project: AndroidSourceViewer   File: CleanAction.java   Source Code and License 6 votes vote down vote up
@Override
public void actionPerformed(AnActionEvent e) {
    cacheFile = new File(Constant.CACHE_PATH);
    if (!cacheFile.exists()) {
        cacheFile.mkdirs();
    }
    long size = FileUtils.sizeOfDirectory(cacheFile);
    DialogBuilder builder = new DialogBuilder();
    builder.setTitle(Constant.TITLE);
    builder.resizable(false);
    builder.setCenterPanel(new JLabel(String.format("Currently occupy storage %.2fM, "
            + "Clean Cache immediately?", size/1024.0/1024.0),
            Messages.getInformationIcon(), SwingConstants.CENTER));
    builder.addOkAction().setText("Clean Now");
    builder.addCancelAction().setText("Cancel");
    builder.setButtonsAlignment(SwingConstants.RIGHT);
    if (builder.show() == 0) {
        clean();
    }
}
 
Example 9
Project: hybris-integration-intellij-idea-plugin   File: DirectoriesScannerErrorsProcessor.java   Source Code and License 6 votes vote down vote up
@Override
public boolean shouldContinue(final List<File> t) {
    if (!t.isEmpty()) {
        ApplicationManager.getApplication().invokeLater(new Runnable() {

            @Override
            public void run() {
                Messages.showErrorDialog(
                    HybrisI18NBundleUtils.message("hybris.project.import.scan.failed", t),
                    HybrisI18NBundleUtils.message("hybris.project.error")
                );
            }
        });
    }

    return false;
}
 
Example 10
Project: hybris-integration-intellij-idea-plugin   File: ProjectRefreshAction.java   Source Code and License 6 votes vote down vote up
@Override
public void actionPerformed(AnActionEvent anActionEvent) {
    final Project project = getEventProject(anActionEvent);

    if (project == null) {
        return;
    }
    removeOldProjectData(project);

    try {
        collectStatistics();
        final AddModuleWizard wizard = getWizard(project);
        final ProjectBuilder projectBuilder = wizard.getProjectBuilder();

        if (projectBuilder instanceof AbstractHybrisProjectImportBuilder) {
            ((AbstractHybrisProjectImportBuilder) projectBuilder).setRefresh(true);
        }
        projectBuilder.commit(project, null, ModulesProvider.EMPTY_MODULES_PROVIDER);
    } catch (ConfigurationException e) {
        Messages.showErrorDialog(
            anActionEvent.getProject(),
            e.getMessage(),
            HybrisI18NBundleUtils.message("hybris.project.import.error.unable.to.proceed")
        );
    }
}
 
Example 11
Project: educational-plugin   File: StudyProjectGenerator.java   Source Code and License 6 votes vote down vote up
public void generateProject(@NotNull final Project project, @NotNull final VirtualFile baseDir) {
  final Course course = getCourse(project);
  if (course == null) {
    LOG.warn("Course is null");
    Messages.showWarningDialog("Some problems occurred while creating the course", "Error in Course Creation");
    return;
  }
  else if (course.isAdaptive() && !StudyUtils.isCourseValid(course)) {
    Messages.showWarningDialog("There is no recommended tasks for this adaptive course", "Error in Course Creation");
    return;
  }
  StudyTaskManager.getInstance(project).setCourse(course);
  ApplicationManager.getApplication().runWriteAction(() -> {
    StudyGenerator.createCourse(course, baseDir);
    StudyUtils.registerStudyToolWindow(course, project);
    StudyUtils.openFirstTask(course, project);
    EduUsagesCollector.projectTypeCreated(course.isAdaptive() ? EduNames.ADAPTIVE : EduNames.STUDY);
  });
}
 
Example 12
Project: educational-plugin   File: CCGetCourseFromStepic.java   Source Code and License 6 votes vote down vote up
@Override
public void actionPerformed(@NotNull AnActionEvent e) {
  final IdeView view = e.getData(LangDataKeys.IDE_VIEW);
  final Project project = e.getData(CommonDataKeys.PROJECT);
  if (view == null || project == null) {
    return;
  }
  final String courseId = Messages.showInputDialog("Please, enter course id", "Get Course From Stepik", null);
  if (StringUtil.isNotEmpty(courseId)) {
    ProgressManager.getInstance().run(new Task.Modal(project, "Creating Course", true) {
      @Override
      public void run(@NotNull final ProgressIndicator indicator) {
        createCourse(project, courseId);
      }
    });
  }
}
 
Example 13
Project: educational-plugin   File: CCCreateCourseArchive.java   Source Code and License 6 votes vote down vote up
private static void packCourse(@NotNull final VirtualFile baseDir, String locationDir, String zipName, boolean showMessage) {
  try {
    final File zipFile = new File(locationDir, zipName + ".zip");
    ZipOutputStream zos = new ZipOutputStream(new BufferedOutputStream(new FileOutputStream(zipFile)));
    VirtualFile[] courseFiles = baseDir.getChildren();
    for (VirtualFile file : courseFiles) {
      ZipUtil.addFileOrDirRecursively(zos, null, new File(file.getPath()), file.getName(), null, null);
    }
    zos.close();
    if (showMessage) {
      ApplicationManager.getApplication().invokeLater(
        () -> Messages.showInfoMessage("Course archive was saved to " + zipFile.getPath(),
                                       "Course Archive Was Created Successfully"));

    }
  }
  catch (IOException e1) {
    LOG.error(e1);
  }
}
 
Example 14
Project: educational-plugin   File: CCCreateCourseArchive.java   Source Code and License 6 votes vote down vote up
@SuppressWarnings("IOResourceOpenedButNotSafelyClosed")
private static void generateJson(VirtualFile parentDir, Course course) {
  final Gson gson = new GsonBuilder().setPrettyPrinting().excludeFieldsWithoutExposeAnnotation().
    registerTypeAdapter(Task.class, new StudySerializationUtils.Json.TaskAdapter()).create();
  final String json = gson.toJson(course);
  final File courseJson = new File(parentDir.getPath(), EduNames.COURSE_META_FILE);
  OutputStreamWriter outputStreamWriter = null;
  try {
    outputStreamWriter = new OutputStreamWriter(new FileOutputStream(courseJson), "UTF-8");
    outputStreamWriter.write(json);
  }
  catch (Exception e) {
    Messages.showErrorDialog(e.getMessage(), "Failed to Generate Json");
    LOG.info(e);
  }
  finally {
    try {
      if (outputStreamWriter != null) {
        outputStreamWriter.close();
      }
    }
    catch (IOException e1) {
      //close silently
    }
  }
}
 
Example 15
Project: Gradle-External-Library-Helper   File: SearchAction.java   Source Code and License 6 votes vote down vote up
private void doSearch(String keyword, AnActionEvent actionEvent) {
    getRepositories(keyword)
            .thenAcceptAsync(mavenSearchResponse -> {
                        SwingUtilities.invokeLater(() -> {
                            if (!mavenSearchResponse.getBody().getNumFound().equals("0")) {
                                SelectFromListDialog dialog = initSelectFromListDialog(actionEvent.getProject(), Strings.TITLE_SELECT_REPOSITORY, ArrayHelper.docListToStringArray(mavenSearchResponse.getBody().getDocList()), toStringAspect);
                                boolean isOk = dialog.showAndGet();
                                if (isOk) {
                                    gradleManager.addDependency(String.valueOf(dialog.getSelection()[0]), actionEvent);
                                }
                            } else if (mavenSearchResponse.getSpellcheck().getSuggestion().size() > 0) {
                                Messages.showInfoMessage(Strings.MESSAGE_SUGGESTIONS + String.join(",", ArrayHelper.objectListToStringArray(mavenSearchResponse.getSpellcheck().getSuggestion())), Strings.TITLE_NOT_FOUND);
                            } else {
                                Messages.showInfoMessage("", Strings.TITLE_NOT_FOUND);
                            }
                        });
                    }
            ).exceptionally(throwable -> {
        SwingUtilities.invokeLater(() -> {
            Messages.showInfoMessage(throwable.getMessage(), Strings.ERROR_TITLE_MAVEN_SEARCH);
        });

        return null;
    });
}
 
Example 16
Project: CodeGen   File: PsiUtil.java   Source Code and License 6 votes vote down vote up
public static PsiDirectory createDirectory(Project project, String title, String description) {
    final FileChooserDescriptor descriptor = FileChooserDescriptorFactory.createSingleFolderDescriptor();
    descriptor.setTitle(title);
    descriptor.setShowFileSystemRoots(false);
    descriptor.setDescription(description);
    descriptor.setHideIgnored(true);
    descriptor.setRoots(project.getBaseDir());
    descriptor.setForcedToUseIdeaFileChooser(true);
    VirtualFile file = FileChooser.chooseFile(descriptor, project, project.getBaseDir());
    if(Objects.isNull(file)){
        Messages.showInfoMessage("Cancel " + title, "Error");
        return null;
    }

    PsiDirectory psiDirectory = PsiDirectoryFactory.getInstance(project).createDirectory(file);
    if(PsiDirectoryFactory.getInstance(project).isPackage(psiDirectory)){
        return psiDirectory;
    }else {
        Messages.showInfoMessage("请选择正确的 package 路径。", "Error");
        return createDirectory(project, title, description);
    }
}
 
Example 17
Project: Dependency-Injection-Graph   File: SmaliAnalyzer.java   Source Code and License 6 votes vote down vote up
public boolean run() {
    String filter = arguments.getFilter();
    if (filter == null) {
        System.err.println("Please check your filter!");
        return false;
    }

    String replacement = Matcher.quoteReplacement(File.separator);
    String searchString = Pattern.quote(".");
    filterAsPath = filter.replaceAll(searchString, replacement);
    File projectFolder = getProjectFolder();
    if (projectFolder.exists()) {
        traverseSmaliCode(projectFolder);
        return true;
    } else if (isInstantRunEnabled()) {
        System.err.println("Enabled Instant Run feature detected. We cannot decompile it. Please, disable Instant Run and rebuild your app.");
        Messages.showInfoMessage(Strings.ERROR_INSTANT_RUN_ENABLED, Strings.TITLE_ERROR_INSTANT_RUN_ENABLED);
    } else {
        System.err.println("Smali folder cannot be absent!");
    }
    return false;
}
 
Example 18
Project: KotlinMvp   File: AndroidMvpAction.java   Source Code and License 6 votes vote down vote up
@Override
public void actionPerformed(AnActionEvent e) {
    project = e.getProject();
    selectGroup = DataKeys.VIRTUAL_FILE.getData(e.getDataContext());
    String className = Messages.showInputDialog(project, "请输入类名称", "NewMvpGroup", Messages.getQuestionIcon());
    if (className == null || className.equals("")) {
        System.out.print("没有输入类名");
        return;
    }
    if (className.equals("base") || className.equals("BASE") || className.equals("Base")) {
        createMvpBase();
    } else {
        createClassMvp(className);
    }
    project.getBaseDir().refresh(false, true);
}
 
Example 19
Project: intellij-ce-playground   File: ChangeBoundFieldTypeFix.java   Source Code and License 6 votes vote down vote up
public void invoke(@NotNull Project project, Editor editor, PsiFile file) throws IncorrectOperationException {
  CommandProcessor.getInstance().executeCommand(myField.getProject(), new Runnable() {
    public void run() {
      try {
        final PsiManager manager = myField.getManager();
        myField.getTypeElement().replace(JavaPsiFacade.getInstance(manager.getProject()).getElementFactory().createTypeElement(myTypeToSet));
      }
      catch (final IncorrectOperationException e) {
        ApplicationManager.getApplication().invokeLater(new Runnable(){
          public void run() {
            Messages.showErrorDialog(myField.getProject(),
                                     QuickFixBundle.message("cannot.change.field.exception", myField.getName(), e.getLocalizedMessage()),
                                     CommonBundle.getErrorTitle());
          }
        });
      }
    }
  }, getText(), null);
}
 
Example 20
Project: intellij-ce-playground   File: PydevConsoleRunner.java   Source Code and License 6 votes vote down vote up
@Override
public void setSelected(AnActionEvent e, boolean state) {
  mySelected = state;

  if (mySelected) {
    try {
      mySession = connectToDebugger();
    }
    catch (Exception e1) {
      LOG.error(e1);
      Messages.showErrorDialog("Can't connect to debugger", "Error Connecting Debugger");
    }
  }
  else {
    //TODO: disable debugging
  }
}
 
Example 21
Project: intellij-ce-playground   File: InstallPluginAction.java   Source Code and License 6 votes vote down vote up
private boolean userConfirm(IdeaPluginDescriptor[] selection) {
  String message;
  if (selection.length == 1) {
    if (selection[0] instanceof IdeaPluginDescriptorImpl) {
      message = IdeBundle.message("prompt.update.plugin", selection[0].getName());
    }
    else {
      message = IdeBundle.message("prompt.download.and.install.plugin", selection[0].getName());
    }
  }
  else {
    message = IdeBundle.message("prompt.install.several.plugins", selection.length);
  }

  return Messages.showYesNoDialog(myHost.getMainPanel(), message, IdeBundle.message("action.download.and.install.plugin"), Messages.getQuestionIcon()) == Messages.YES;
}
 
Example 22
Project: intellij-ce-playground   File: AndroidImportProjectAction.java   Source Code and License 6 votes vote down vote up
private static void importAdtProject(@NotNull VirtualFile file) {
  AdtImportProvider adtImportProvider = new AdtImportProvider(true);
  AddModuleWizard wizard = new AddModuleWizard(null, ProjectImportProvider.getDefaultPath(file), adtImportProvider);
  if (wizard.showAndGet()) {
    try {
      doCreate(wizard);
    }
    catch (final IOException e) {
      invokeLaterIfNeeded(new Runnable() {
        @Override
        public void run() {
          Messages.showErrorDialog(e.getMessage(), "Project Initialization Failed");
        }
      });
    }
  }
}
 
Example 23
Project: PackageTemplates   File: CreateDirectoryAction.java   Source Code and License 6 votes vote down vote up
private boolean onAsk(PsiDirectory psiDuplicate) {
    int dialogAnswerCode = Messages.showYesNoDialog(project,
            String.format(Localizer.get("warning.ArgDirectoryAlreadyExists"), psiDuplicate.getName()),
            Localizer.get("title.WriteConflict"),
            Localizer.get("action.Overwrite"),
            Localizer.get("action.UseExisting"),
            Messages.getQuestionIcon(),
            new NeverShowAskCheckBox()
    );
    if (dialogAnswerCode == Messages.OK) {
        if (!onOverwrite(psiDuplicate)) {
            return false;
        }
    } else {
        if (!onUseExisting(psiDuplicate)) {
            return false;
        }
    }
    return true;
}
 
Example 24
Project: intellij-ce-playground   File: ConfigureAvdOptionsStep.java   Source Code and License 6 votes vote down vote up
@Override
public boolean commitStep() {
  if (!myState.containsKey(DISPLAY_USE_EXTERNAL_SD_KEY) || !myState.get(DISPLAY_USE_EXTERNAL_SD_KEY)) {
    Storage orig = myState.get(SD_CARD_STORAGE_KEY);
    Storage current = myState.get(DISPLAY_SD_SIZE_KEY);
    if (orig != null && !orig.equals(current)) {
      int result = Messages.showYesNoDialog((Project)null, "Changing the size of the built-in SD card will erase " +
                                                           "the current contents of the card. Continue?",
                                            "Confirm Data Wipe", AllIcons.General.QuestionDialog);
      if (result != Messages.YES) {
        return false;
      }
    }
  }
  File displayFile = myState.get(DISPLAY_SKIN_FILE_KEY);
  boolean hasFrame = myState.getNotNull(DEVICE_FRAME_KEY, false);
  myState.put(CUSTOM_SKIN_FILE_KEY,  hasFrame ? displayFile : NO_SKIN);
  myState.put(BACKUP_SKIN_FILE_KEY, hasFrame ? null : displayFile);

  return super.commitStep();
}
 
Example 25
Project: intellij-ce-playground   File: TextFieldWithLaunchBrowserButton.java   Source Code and License 6 votes vote down vote up
public TextFieldWithLaunchBrowserButton(String url) {
  myUrl = url;
  addActionListener(new ActionListener() {
    @Override
    public void actionPerformed(ActionEvent e) {
      try {
        if (Desktop.isDesktopSupported() && Desktop.getDesktop().isSupported(Desktop.Action.BROWSE)) {
          Desktop.getDesktop().browse(URI.create(myUrl));
        } else {
          Messages.showErrorDialog("Please visit \n" + myUrl + "\n to retrieve this value", "Could Not Open Web Browser");
        }
      }
      catch (IOException error) {
        LOG.error(error);
      }
    }
  });
}
 
Example 26
Project: intellij-ce-playground   File: RenameProjectAction.java   Source Code and License 6 votes vote down vote up
@Override
public void actionPerformed(AnActionEvent e) {
  final DataContext dataContext = e.getDataContext();
  final Project project = CommonDataKeys.PROJECT.getData(dataContext);
  LOG.assertTrue(project instanceof ProjectEx);
  Module module;
  Module[] modules = ModuleManager.getInstance(project).getModules();
  if (modules.length == 1 && project.getName().equals(modules[0].getName())) {
    module = modules[0];
  }
  else {
    module = null;
  }
  Messages.showInputDialog(project, RefactoringBundle.message("enter.new.project.name"), RefactoringBundle.message("rename.project"),
                           Messages.getQuestionIcon(),
                           project.getName(),
                           new RenameProjectHandler.MyInputValidator((ProjectEx)project, module));
}
 
Example 27
Project: intellij-ce-playground   File: DeleteHandler.java   Source Code and License 6 votes vote down vote up
private static boolean clearReadOnlyFlag(final VirtualFile virtualFile, final Project project) {
  final boolean[] success = new boolean[1];
  CommandProcessor.getInstance().executeCommand(project, new Runnable() {
    @Override
    public void run() {
      Runnable action = new Runnable() {
        @Override
        public void run() {
          try {
            ReadOnlyAttributeUtil.setReadOnlyAttribute(virtualFile, false);
            success[0] = true;
          }
          catch (IOException e1) {
            Messages.showMessageDialog(project, e1.getMessage(), CommonBundle.getErrorTitle(), Messages.getErrorIcon());
          }
        }
      };
      ApplicationManager.getApplication().runWriteAction(action);
    }
  }, "", null);
  return success[0];
}
 
Example 28
Project: intellij-ce-playground   File: GroupBrowser.java   Source Code and License 6 votes vote down vote up
@Nullable
@Override
protected String showDialog() {
  TestClassFilter filter;
  Module module = editor.getModuleSelector().getModule();
  if (module == null) {
    filter = new TestClassFilter(GlobalSearchScope.projectScope(getProject()), getProject(), false);
  }
  else {
    filter = new TestClassFilter(GlobalSearchScope.moduleScope(module), getProject(), false);
  }
  PsiClass[] classes = TestNGUtil.getAllTestClasses(filter, true);
  if(classes == null || classes.length == 0) {
    Messages.showMessageDialog(getField(), "No tests found in project", "Cannot Browse Groups", Messages.getInformationIcon());
    return null;
  } else {
    return GroupList.showDialog(classes, getField());
  }
}
 
Example 29
Project: intellij-ce-playground   File: SvnUpdateEnvironment.java   Source Code and License 6 votes vote down vote up
private boolean checkAncestry(final File sourceFile, final SVNURL targetUrl, final SVNRevision targetRevision) throws SvnBindException {
  final Info sourceSvnInfo = myVcs.getInfo(sourceFile);
  final Info targetSvnInfo = myVcs.getInfo(targetUrl, targetRevision);

  if (sourceSvnInfo == null || targetSvnInfo == null) {
    // cannot check
    return true;
  }

  final SVNURL copyFromTarget = targetSvnInfo.getCopyFromURL();
  final SVNURL copyFromSource = sourceSvnInfo.getCopyFromURL();

  if ((copyFromSource != null) || (copyFromTarget != null)) {
    if (sourceSvnInfo.getURL().equals(copyFromTarget) || targetUrl.equals(copyFromSource)) {
      return true;
    }
  }

  final int result = Messages.showYesNoDialog(myVcs.getProject(), SvnBundle.message("switch.target.not.copy.current"),
                                              SvnBundle.message("switch.target.problem.title"), Messages.getWarningIcon());
  return (Messages.YES == result);
}
 
Example 30
Project: intellij-ce-playground   File: MavenProjectImporter.java   Source Code and License 6 votes vote down vote up
private boolean deleteObsoleteModules() {
  final List<Module> obsoleteModules = collectObsoleteModules();
  if (obsoleteModules.isEmpty()) return false;

  setMavenizedModules(obsoleteModules, false);

  final int[] result = new int[1];
  MavenUtil.invokeAndWait(myProject, myModelsProvider.getModalityStateForQuestionDialogs(), new Runnable() {
    public void run() {
      result[0] = Messages.showYesNoDialog(myProject,
                                           ProjectBundle.message("maven.import.message.delete.obsolete", formatModules(obsoleteModules)),
                                           ProjectBundle.message("maven.project.import.title"),
                                           Messages.getQuestionIcon());
    }
  });

  if (result[0] == Messages.NO) return false;// NO

  for (Module each : obsoleteModules) {
    if (!each.isDisposed()) {
      myModuleModel.disposeModule(each);
    }
  }

  return true;
}
 
Example 31
Project: intellij-ce-playground   File: AvdComboBox.java   Source Code and License 6 votes vote down vote up
public AvdComboBox(@Nullable Project project, boolean addEmptyElement, boolean showNotLaunchedOnly) {
  myProject = project;
  myAddEmptyElement = addEmptyElement;
  myShowNotLaunchedOnly = showNotLaunchedOnly;

  addActionListener(new ActionListener() {
    @Override
    public void actionPerformed(ActionEvent e) {
      final AndroidPlatform platform = findAndroidPlatform();
      AvdComboBox avdComboBox = AvdComboBox.this;
      if (platform == null) {
        Messages.showErrorDialog(avdComboBox, "Cannot find any configured Android SDK");
        return;
      }
      RunAndroidAvdManagerAction action = new RunAndroidAvdManagerAction();
      action.openAvdManager(myProject);
      AvdInfo selected = action.getSelected();
      if (selected != null) {
        getComboBox().setSelectedItem(new IdDisplay(selected.getName(), ""));
      }
    }
  });

  setMinimumSize(new Dimension(100, getMinimumSize().height));
}
 
Example 32
Project: intellij-ce-playground   File: DvcsCommitAdditionalComponent.java   Source Code and License 6 votes vote down vote up
private void loadMessagesInModalTask(@NotNull Project project) {
  try {
    myMessagesForRoots =
      ProgressManager.getInstance().runProcessWithProgressSynchronously(new ThrowableComputable<Map<VirtualFile,String>, VcsException>() {
        @Override
        public Map<VirtualFile, String> compute() throws VcsException {
          return getLastCommitMessages();
        }
      }, "Reading commit message...", false, project);
  }
  catch (VcsException e) {
    Messages.showErrorDialog(getComponent(), "Couldn't load commit message of the commit to amend.\n" + e.getMessage(),
                             "Commit Message not Loaded");
    log.info(e);
  }
}
 
Example 33
Project: intellij-ce-playground   File: ImportModuleFromImlFileAction.java   Source Code and License 6 votes vote down vote up
@Override
public void actionPerformed(AnActionEvent e) {
  final VirtualFile[] files = e.getData(CommonDataKeys.VIRTUAL_FILE_ARRAY);
  final Project project = getEventProject(e);
  if (files == null || project == null) return;

  try {
    final ModifiableModuleModel model = ModuleManager.getInstance(project).getModifiableModel();
    for (VirtualFile file : files) {
      model.loadModule(file.getPath());
    }

    AccessToken token = WriteAction.start();
    try {
      model.commit();
    }
    finally {
      token.finish();
    }
  }
  catch (Exception ex) {
    LOG.info(ex);
    Messages.showErrorDialog(project, "Cannot import module: " + ex.getMessage(), CommonBundle.getErrorTitle());
  }
}
 
Example 34
Project: intellij-ce-playground   File: PluginModuleBuildConfEditor.java   Source Code and License 6 votes vote down vote up
public void apply() throws ConfigurationException {
  if (myUseUserManifest.isSelected() && myManifest.getText() != null && !new File(myManifest.getText()).exists()){
    throw new ConfigurationException(DevKitBundle.message("error.file.not.found.message", myManifest.getText()));
  }
  final File plugin = new File(myBuildProperties.getPluginXmlPath());
  final String newPluginPath = myPluginXML.getText() + File.separator + META_INF + File.separator + PLUGIN_XML;
  if (plugin.exists() && !plugin.getPath().equals(newPluginPath) && 
      Messages.showYesNoDialog(myModule.getProject(), DevKitBundle.message("deployment.view.delete", plugin.getPath()),
                               DevKitBundle.message("deployment.cleanup", META_INF), null) == Messages.YES) {

    CommandProcessor.getInstance().executeCommand(myModule.getProject(),
                                                  new Runnable() {
                                                    public void run() {
                                                      FileUtil.delete(plugin.getParentFile());
                                                    }
                                                  },
                                                  DevKitBundle.message("deployment.cleanup", META_INF),
                                                  null);
  }
  myBuildProperties.setPluginXmlPathAndCreateDescriptorIfDoesntExist(newPluginPath);
  myBuildProperties.setManifestPath(myManifest.getText());
  myBuildProperties.setUseUserManifest(myUseUserManifest.isSelected());
}
 
Example 35
Project: intellij-ce-playground   File: PluginManagerConfigurable.java   Source Code and License 6 votes vote down vote up
@Override
public void apply() throws ConfigurationException {
  final String applyMessage = myPluginManagerMain.apply();
  if (applyMessage != null) {
    throw new ConfigurationException(applyMessage);
  }

  if (myPluginManagerMain.isRequireShutdown()) {
    if (showRestartDialog() == Messages.YES) {
      ApplicationManagerEx.getApplicationEx().restart(true);
    }
    else {
      myPluginManagerMain.ignoreChanges();
    }
  }
}
 
Example 36
Project: intellij-ce-playground   File: HTMLExportUtil.java   Source Code and License 6 votes vote down vote up
public static void writeFile(final String folder, @NonNls final String fileName, CharSequence buf, final Project project) {
  try {
    HTMLExporter.writeFileImpl(folder, fileName, buf);
  }
  catch (IOException e) {
    Runnable showError = new Runnable() {
      @Override
      public void run() {
        final String fullPath = folder + File.separator + fileName;
        Messages.showMessageDialog(
          project,
          InspectionsBundle.message("inspection.export.error.writing.to", fullPath),
          InspectionsBundle.message("inspection.export.results.error.title"),
          Messages.getErrorIcon()
        );
      }
    };
    ApplicationManager.getApplication().invokeLater(showError, ModalityState.NON_MODAL);
    throw new ProcessCanceledException();
  }
}
 
Example 37
Project: intellij-ce-playground   File: FontOptions.java   Source Code and License 6 votes vote down vote up
public static void showReadOnlyMessage(JComponent parent, final boolean sharedScheme) {
  if (!sharedScheme) {
    Messages.showMessageDialog(
      parent,
      ApplicationBundle.message("error.readonly.scheme.cannot.be.modified"),
      ApplicationBundle.message("title.cannot.modify.readonly.scheme"),
      Messages.getInformationIcon()
    );
  }
  else {
    Messages.showMessageDialog(
      parent,
      ApplicationBundle.message("error.shared.scheme.cannot.be.modified"),
      ApplicationBundle.message("title.cannot.modify.readonly.scheme"),
      Messages.getInformationIcon()
    );
  }
}
 
Example 38
Project: intellij-ce-playground   File: BreakpointsDialog.java   Source Code and License 6 votes vote down vote up
@Override
public void actionPerformed(AnActionEvent e) {
  String groupName = myGroup;
  if (myNewGroup) {
    groupName = Messages.showInputDialog("New group name", "New Group", AllIcons.Nodes.NewFolder);
    if (groupName == null) {
      return;
    }
  }
  for (BreakpointItem item : myTreeController.getSelectedBreakpoints(true)) {
    Object breakpoint = item.getBreakpoint();
    if (breakpoint instanceof XBreakpointBase) {
      ((XBreakpointBase)breakpoint).setGroup(groupName);
    }
  }
  myTreeController.rebuildTree(myBreakpointItems);
}
 
Example 39
Project: intellij-ce-playground   File: ProjectImporterCheckoutListener.java   Source Code and License 6 votes vote down vote up
@Override
public boolean processCheckedOutDirectory(Project project, File directory) {
  final File[] files = directory.listFiles();
  if (files != null) {
    final LocalFileSystem localFileSystem = LocalFileSystem.getInstance();
    for (File file : files) {
      if (file.isDirectory()) continue;
      final VirtualFile virtualFile = localFileSystem.findFileByIoFile(file);
      if (virtualFile != null) {
        final ProjectOpenProcessor openProcessor = ProjectOpenProcessor.getImportProvider(virtualFile);
        if (openProcessor != null) {
          int rc = Messages
            .showYesNoDialog(project, VcsBundle.message("checkout.open.project.prompt", ProjectCheckoutListener.getProductNameWithArticle(), file.getPath()),
                             VcsBundle.message("checkout.title"), Messages.getQuestionIcon());
          if (rc == Messages.YES) {
            openProcessor.doOpenProject(virtualFile, project, false);
          }
          return true;
        }
      }
    }
  }
  return false;
}
 
Example 40
Project: intellij-ce-playground   File: CustomizableActionsPanel.java   Source Code and License 6 votes vote down vote up
private void editToolbarIcon(String actionId, DefaultMutableTreeNode node) {
  final AnAction anAction = ActionManager.getInstance().getAction(actionId);
  if (isToolbarAction(node) && anAction.getTemplatePresentation().getIcon() == null) {
    final int exitCode = Messages.showOkCancelDialog(IdeBundle.message("error.adding.action.without.icon.to.toolbar"),
                                                     IdeBundle.message("title.unable.to.add.action.without.icon.to.toolbar"),
                                                     Messages.getInformationIcon());
    if (exitCode == Messages.OK) {
      mySelectedSchema.addIconCustomization(actionId, null);
      anAction.getTemplatePresentation().setIcon(AllIcons.Toolbar.Unknown);
      anAction.getTemplatePresentation().setDisabledIcon(IconLoader.getDisabledIcon(AllIcons.Toolbar.Unknown));
      anAction.setDefaultIcon(false);
      node.setUserObject(Pair.create(actionId, AllIcons.Toolbar.Unknown));
      myActionsTree.repaint();
      CustomActionsSchema.setCustomizationSchemaForCurrentProjects();
    }
  }
}