private void initWizard(final String title) {
    setTitle(title);
    myCurrentStep = 0;
    myPreviousButton = new JButton(IdeBundle.message("button.wizard.previous"));
    myNextButton = new JButton(IdeBundle.message("button.wizard.next"));
    myCancelButton = new JButton(CommonBundle.getCancelButtonText());
    myHelpButton = new JButton(CommonBundle.getHelpButtonText());
    myContentPanel = new JPanel(new CardLayout());

    myIcon = new TallImageComponent(null);

    JRootPane rootPane = getRootPane();
    if (rootPane != null) { // it will be null in headless mode, i.e. tests
      rootPane.registerKeyboardAction(
          new ActionListener() {
            public void actionPerformed(final ActionEvent e) {
              helpAction();
            }
          },
          KeyStroke.getKeyStroke(KeyEvent.VK_F1, 0),
          JComponent.WHEN_IN_FOCUSED_WINDOW);

      rootPane.registerKeyboardAction(
          new ActionListener() {
            public void actionPerformed(final ActionEvent e) {
              helpAction();
            }
          },
          KeyStroke.getKeyStroke(KeyEvent.VK_HELP, 0),
          JComponent.WHEN_IN_FOCUSED_WINDOW);
    }
  }
 public static void copyDir(
     @NotNull File fromDir, @NotNull File toDir, @Nullable final FileFilter filter)
     throws IOException {
   ensureExists(toDir);
   if (isAncestor(fromDir, toDir, true)) {
     LOG.error(fromDir.getAbsolutePath() + " is ancestor of " + toDir + ". Can't copy to itself.");
     return;
   }
   File[] files = fromDir.listFiles();
   if (files == null)
     throw new IOException(
         CommonBundle.message("exception.directory.is.invalid", fromDir.getPath()));
   if (!fromDir.canRead())
     throw new IOException(
         CommonBundle.message("exception.directory.is.not.readable", fromDir.getPath()));
   for (File file : files) {
     if (filter != null && !filter.accept(file)) {
       continue;
     }
     if (file.isDirectory()) {
       copyDir(file, new File(toDir, file.getName()), filter);
     } else {
       copy(file, new File(toDir, file.getName()));
     }
   }
 }
Exemplo n.º 3
0
  public boolean execute(boolean drop, boolean isInsideStartFinishGroup) {
    if (!myUndoableGroup.isUndoable()) {
      reportCannotUndo(
          CommonBundle.message("cannot.undo.error.contains.nonundoable.changes.message"),
          myUndoableGroup.getAffectedDocuments());
      return false;
    }

    Set<DocumentReference> clashing = getStackHolder().collectClashingActions(myUndoableGroup);
    if (!clashing.isEmpty()) {
      reportCannotUndo(
          CommonBundle.message("cannot.undo.error.other.affected.files.changed.message"), clashing);
      return false;
    }

    if (!isInsideStartFinishGroup && myUndoableGroup.shouldAskConfirmation(isRedo())) {
      if (!askUser()) return false;
    } else {
      if (restore(getBeforeState())) {
        setBeforeState(new EditorAndState(myEditor, myEditor.getState(FileEditorStateLevel.UNDO)));
        return true;
      }
    }

    Collection<VirtualFile> readOnlyFiles = collectReadOnlyAffectedFiles();
    if (!readOnlyFiles.isEmpty()) {
      final Project project = myManager.getProject();
      final VirtualFile[] files = VfsUtil.toVirtualFileArray(readOnlyFiles);

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

      final ReadonlyStatusHandler.OperationStatus operationStatus =
          ReadonlyStatusHandler.getInstance(project).ensureFilesWritable(files);
      if (operationStatus.hasReadonlyFiles()) {
        return false;
      }
    }

    Collection<Document> readOnlyDocuments = collectReadOnlyDocuments();
    if (!readOnlyDocuments.isEmpty()) {
      for (Document document : readOnlyDocuments) {
        document.fireReadOnlyModificationAttempt();
      }
      return false;
    }

    getStackHolder().removeFromStacks(myUndoableGroup);
    if (!drop) {
      getReverseStackHolder().addToStacks(myUndoableGroup);
    }

    performAction();

    restore(getAfterState());

    return true;
  }
Exemplo n.º 4
0
 public MyDeleteAction(Condition<Object[]> availableCondition) {
   super(
       CommonBundle.message("button.delete"),
       CommonBundle.message("button.delete"),
       PlatformIcons.DELETE_ICON);
   registerCustomShortcutSet(CommonShortcuts.getDelete(), myTree);
   myCondition = availableCondition;
 }
Exemplo n.º 5
0
  /** Sets current LAF. The method doesn't update component hierarchy. */
  @Override
  public void setCurrentLookAndFeel(UIManager.LookAndFeelInfo lookAndFeelInfo) {
    if (findLaf(lookAndFeelInfo.getClassName()) == null) {
      LOG.error("unknown LookAndFeel : " + lookAndFeelInfo);
      return;
    }
    // Set L&F
    if (IdeaLookAndFeelInfo.CLASS_NAME.equals(
        lookAndFeelInfo.getClassName())) { // that is IDEA default LAF
      IdeaLaf laf = new IdeaLaf();
      MetalLookAndFeel.setCurrentTheme(new IdeaBlueMetalTheme());
      try {
        UIManager.setLookAndFeel(laf);
      } catch (Exception e) {
        Messages.showMessageDialog(
            IdeBundle.message(
                "error.cannot.set.look.and.feel", lookAndFeelInfo.getName(), e.getMessage()),
            CommonBundle.getErrorTitle(),
            Messages.getErrorIcon());
        return;
      }
    } else if (DarculaLookAndFeelInfo.CLASS_NAME.equals(lookAndFeelInfo.getClassName())) {
      DarculaLaf laf = new DarculaLaf();
      try {
        UIManager.setLookAndFeel(laf);
        JBColor.setDark(true);
        IconLoader.setUseDarkIcons(true);
      } catch (Exception e) {
        Messages.showMessageDialog(
            IdeBundle.message(
                "error.cannot.set.look.and.feel", lookAndFeelInfo.getName(), e.getMessage()),
            CommonBundle.getErrorTitle(),
            Messages.getErrorIcon());
        return;
      }
    } else { // non default LAF
      try {
        LookAndFeel laf =
            ((LookAndFeel) Class.forName(lookAndFeelInfo.getClassName()).newInstance());
        if (laf instanceof MetalLookAndFeel) {
          MetalLookAndFeel.setCurrentTheme(new DefaultMetalTheme());
        }
        UIManager.setLookAndFeel(laf);
      } catch (Exception e) {
        Messages.showMessageDialog(
            IdeBundle.message(
                "error.cannot.set.look.and.feel", lookAndFeelInfo.getName(), e.getMessage()),
            CommonBundle.getErrorTitle(),
            Messages.getErrorIcon());
        return;
      }
    }
    myCurrentLaf =
        ObjectUtils.chooseNotNull(findLaf(lookAndFeelInfo.getClassName()), lookAndFeelInfo);

    checkLookAndFeel(lookAndFeelInfo, false);
  }
 @NotNull
 @Override
 public ListPopup createConfirmation(String title, final Runnable onYes, int defaultOptionIndex) {
   return createConfirmation(
       title,
       CommonBundle.getYesButtonText(),
       CommonBundle.getNoButtonText(),
       onYes,
       defaultOptionIndex);
 }
 private static boolean askWhetherShouldSearchForParameterInOverridingMethods(
     final PsiElement psiElement, final PsiParameter parameter) {
   return Messages.showOkCancelDialog(
           psiElement.getProject(),
           FindBundle.message(
               "find.parameter.usages.in.overriding.methods.prompt", parameter.getName()),
           FindBundle.message("find.parameter.usages.in.overriding.methods.title"),
           CommonBundle.getYesButtonText(),
           CommonBundle.getNoButtonText(),
           Messages.getQuestionIcon())
       == 0;
 }
 public ConfirmationDialog(
     Project project,
     final String message,
     String title,
     final Icon icon,
     final VcsShowConfirmationOption option,
     @Nullable String okActionName,
     @Nullable String cancelActionName) {
   super(project, message, title, icon);
   myOption = option;
   myOkActionName = okActionName != null ? okActionName : CommonBundle.getYesButtonText();
   myCancelActionName =
       cancelActionName != null ? cancelActionName : CommonBundle.getNoButtonText();
   init();
 }
  public void removeCoverageSuite(final CoverageSuite suite) {
    final String fileName = suite.getCoverageDataFileName();

    boolean deleteTraces = suite.isTracingEnabled();
    if (!FileUtil.isAncestor(PathManager.getSystemPath(), fileName, false)) {
      String message = "Would you like to delete file \'" + fileName + "\' ";
      if (deleteTraces) {
        message +=
            "and traces directory \'"
                + FileUtil.getNameWithoutExtension(new File(fileName))
                + "\' ";
      }
      message += "on disk?";
      if (Messages.showYesNoDialog(
              myProject, message, CommonBundle.getWarningTitle(), Messages.getWarningIcon())
          == Messages.YES) {
        deleteCachedCoverage(fileName, deleteTraces);
      }
    } else {
      deleteCachedCoverage(fileName, deleteTraces);
    }

    myCoverageSuites.remove(suite);
    if (myCurrentSuitesBundle != null && myCurrentSuitesBundle.contains(suite)) {
      CoverageSuite[] suites = myCurrentSuitesBundle.getSuites();
      suites = ArrayUtil.remove(suites, suite);
      chooseSuitesBundle(suites.length > 0 ? new CoverageSuitesBundle(suites) : null);
    }
  }
  public static void copyAsFiles(
      PsiElement[] elements, @Nullable PsiDirectory defaultTargetDirectory, Project project) {
    PsiDirectory targetDirectory = null;
    String newName = null;
    boolean openInEditor = true;

    if (ApplicationManager.getApplication().isUnitTestMode()) {
      targetDirectory = defaultTargetDirectory;
    } else {
      CopyFilesOrDirectoriesDialog dialog =
          new CopyFilesOrDirectoriesDialog(elements, defaultTargetDirectory, project, false);
      if (dialog.showAndGet()) {
        newName = elements.length == 1 ? dialog.getNewName() : null;
        targetDirectory = dialog.getTargetDirectory();
        openInEditor = dialog.openInEditor();
      }
    }

    if (targetDirectory != null) {
      try {
        for (PsiElement element : elements) {
          PsiFileSystemItem psiElement = (PsiFileSystemItem) element;
          if (psiElement.isDirectory()) {
            MoveFilesOrDirectoriesUtil.checkIfMoveIntoSelf(psiElement, targetDirectory);
          }
        }
      } catch (IncorrectOperationException e) {
        CommonRefactoringUtil.showErrorHint(
            project, null, e.getMessage(), CommonBundle.getErrorTitle(), null);
        return;
      }

      copyImpl(elements, newName, targetDirectory, false, openInEditor);
    }
  }
  private static void showUnsupportedNotification(
      @NotNull final Project project, @NotNull final VirtualFile file) {
    new Notification(
            MavenUtil.MAVEN_NOTIFICATION_GROUP,
            "Unsupported action",
            "<html>You have to <a href='#'>enable</a> <b>"
                + CommonBundle.settingsActionPath()
                + " | Maven | Importing | \"Use Maven3 to import project\"</b> option to use Show Effective POM action</html>",
            NotificationType.ERROR,
            new NotificationListener.Adapter() {
              @Override
              protected void hyperlinkActivated(
                  @NotNull Notification notification, @NotNull HyperlinkEvent e) {
                MavenServerManager.getInstance().setUseMaven2(false);
                notification.expire();

                new Notification(
                        MavenUtil.MAVEN_NOTIFICATION_GROUP,
                        "Option enabled",
                        "Option \"Use Maven3 to import project\" has been enabled",
                        NotificationType.INFORMATION)
                    .notify(project);

                actionPerformed(project, file);
              }
            })
        .notify(project);
  }
  @Override
  public void invoke(@NotNull Project project, Editor editor, PsiFile file)
      throws IncorrectOperationException {
    if (!(file instanceof GroovyFile)) return;

    VirtualFile vfile = file.getVirtualFile();
    if (vfile == null) return;

    final Module module = ModuleUtilCore.findModuleForFile(vfile, project);
    if (module == null) return;

    final String packageName = ((GroovyFile) file).getPackageName();
    PsiDirectory directory =
        PackageUtil.findOrCreateDirectoryForPackage(module, packageName, null, true);
    if (directory == null) return;

    String error = RefactoringMessageUtil.checkCanCreateFile(directory, file.getName());
    if (error != null) {
      Messages.showMessageDialog(
          project, error, CommonBundle.getErrorTitle(), Messages.getErrorIcon());
      return;
    }
    new MoveFilesOrDirectoriesProcessor(
            project, new PsiElement[] {file}, directory, false, false, false, null, null)
        .run();
  }
 public RerunAction(JComponent comp) {
   super(
       CommonBundle.message("action.rerun"),
       AnalysisScopeBundle.message("action.rerun.dependency"),
       AllIcons.Actions.RefreshUsages);
   registerCustomShortcutSet(CommonShortcuts.getRerun(), comp);
 }
  @Override
  public void actionPerformed(AnActionEvent e) {
    DataContext dataContext = e.getDataContext();
    final Project project = CommonDataKeys.PROJECT.getData(dataContext);
    if (project == null) return;
    PsiDocumentManager.getInstance(project).commitAllDocuments();
    Editor editor = CommonDataKeys.EDITOR.getData(dataContext);

    UsageTarget[] usageTargets = UsageView.USAGE_TARGETS_KEY.getData(dataContext);
    if (usageTargets != null) {
      FileEditor fileEditor = PlatformDataKeys.FILE_EDITOR.getData(dataContext);
      if (fileEditor != null) {
        usageTargets[0].findUsagesInEditor(fileEditor);
      }
    } else if (editor == null) {
      Messages.showMessageDialog(
          project,
          FindBundle.message("find.no.usages.at.cursor.error"),
          CommonBundle.getErrorTitle(),
          Messages.getErrorIcon());
    } else {
      HintManager.getInstance()
          .showErrorHint(editor, FindBundle.message("find.no.usages.at.cursor.error"));
    }
  }
Exemplo n.º 15
0
  private void chooseDirectoryAndMove(Project project, PsiFile myFile) {
    try {
      PsiDirectory directory =
          MoveClassesOrPackagesUtil.chooseDestinationPackage(project, myTargetPackage, null);

      if (directory == null) {
        return;
      }
      String error = RefactoringMessageUtil.checkCanCreateFile(directory, myFile.getName());
      if (error != null) {
        Messages.showMessageDialog(
            project, error, CommonBundle.getErrorTitle(), Messages.getErrorIcon());
        return;
      }
      new MoveClassesOrPackagesProcessor(
              project,
              new PsiElement[] {((PsiJavaFile) myFile).getClasses()[0]},
              new SingleSourceRootMoveDestination(
                  PackageWrapper.create(JavaDirectoryService.getInstance().getPackage(directory)),
                  directory),
              false,
              false,
              null)
          .run();
    } catch (IncorrectOperationException e) {
      LOG.error(e);
    }
  }
Exemplo n.º 16
0
  private void checkForEmptyAndDuplicatedNames(
      MyNode rootNode,
      String prefix,
      String title,
      Class<? extends NamedConfigurable> configurableClass,
      boolean recursively)
      throws ConfigurationException {
    final Set<String> names = new HashSet<String>();
    for (int i = 0; i < rootNode.getChildCount(); i++) {
      final MyNode node = (MyNode) rootNode.getChildAt(i);
      final NamedConfigurable scopeConfigurable = node.getConfigurable();

      if (configurableClass.isInstance(scopeConfigurable)) {
        final String name = scopeConfigurable.getDisplayName();
        if (name.trim().length() == 0) {
          selectNodeInTree(node);
          throw new ConfigurationException("Name should contain non-space characters");
        }
        if (names.contains(name)) {
          final NamedConfigurable selectedConfigurable = getSelectedConfigurable();
          if (selectedConfigurable == null
              || !Comparing.strEqual(selectedConfigurable.getDisplayName(), name)) {
            selectNodeInTree(node);
          }
          throw new ConfigurationException(
              CommonBundle.message("smth.already.exist.error.message", prefix, name), title);
        }
        names.add(name);
      }

      if (recursively) {
        checkForEmptyAndDuplicatedNames(node, prefix, title, configurableClass, true);
      }
    }
  }
 private void removeSelected() {
   CheckedTreeNode node = getSelectedToolNode();
   if (node != null) {
     int result =
         Messages.showYesNoDialog(
             this,
             ToolsBundle.message("tools.delete.confirmation"),
             CommonBundle.getWarningTitle(),
             Messages.getWarningIcon());
     if (result != 0) {
       return;
     }
     myIsModified = true;
     if (node.getUserObject() instanceof Tool) {
       Tool tool = (Tool) node.getUserObject();
       CheckedTreeNode parentNode = (CheckedTreeNode) node.getParent();
       ((ToolsGroup) parentNode.getUserObject()).removeElement(tool);
       removeNodeFromParent(node);
       if (parentNode.getChildCount() == 0) {
         removeNodeFromParent(parentNode);
       }
     } else if (node.getUserObject() instanceof ToolsGroup) {
       removeNodeFromParent(node);
     }
     update();
     myTree.requestFocus();
   }
 }
 static void chooseAmbiguousTargetAndPerform(
     @NotNull final Project project,
     final Editor editor,
     @NotNull PsiElementProcessor<PsiElement> processor) {
   if (editor == null) {
     Messages.showMessageDialog(
         project,
         FindBundle.message("find.no.usages.at.cursor.error"),
         CommonBundle.getErrorTitle(),
         Messages.getErrorIcon());
   } else {
     int offset = editor.getCaretModel().getOffset();
     boolean chosen =
         GotoDeclarationAction.chooseAmbiguousTarget(
             editor,
             offset,
             processor,
             FindBundle.message("find.usages.ambiguous.title", "crap"),
             null);
     if (!chosen) {
       ApplicationManager.getApplication()
           .invokeLater(
               new Runnable() {
                 @Override
                 public void run() {
                   if (editor.isDisposed() || !editor.getComponent().isShowing()) return;
                   HintManager.getInstance()
                       .showErrorHint(
                           editor, FindBundle.message("find.no.usages.at.cursor.error"));
                 }
               },
               project.getDisposed());
     }
   }
 }
Exemplo n.º 19
0
  private boolean checkLookAndFeel(final UIManager.LookAndFeelInfo lafInfo, final boolean confirm) {
    String message = null;

    if (lafInfo.getName().contains("GTK")
        && SystemInfo.isXWindow
        && !SystemInfo.isJavaVersionAtLeast("1.6.0_12")) {
      message = IdeBundle.message("warning.problem.laf.1");
    }

    if (message != null) {
      if (confirm) {
        final String[] options = {
          IdeBundle.message("confirm.set.look.and.feel"), CommonBundle.getCancelButtonText()
        };
        final int result =
            Messages.showOkCancelDialog(
                message,
                CommonBundle.getWarningTitle(),
                options[0],
                options[1],
                Messages.getWarningIcon());
        if (result == Messages.OK) {
          myLastWarning = message;
          return true;
        }
        return false;
      }

      if (!message.equals(myLastWarning)) {
        Notifications.Bus.notify(
            new Notification(
                Notifications.SYSTEM_MESSAGES_GROUP_ID,
                "L&F Manager",
                message,
                NotificationType.WARNING,
                NotificationListener.URL_OPENING_LISTENER));
        myLastWarning = message;
      }
    }

    return true;
  }
    @NotNull
    public String getReadonlyFilesMessage() {
      if (hasReadonlyFiles()) {
        StringBuilder buf = new StringBuilder();
        if (myReadonlyFiles.length > 1) {
          for (VirtualFile file : myReadonlyFiles) {
            buf.append('\n');
            buf.append(file.getPresentableUrl());
          }

          return CommonBundle.message(
              "failed.to.make.the.following.files.writable.error.message", buf.toString());
        } else {
          return CommonBundle.message(
              "failed.to.make.file.writeable.error.message",
              myReadonlyFiles[0].getPresentableUrl());
        }
      }
      throw new RuntimeException("No readonly files");
    }
  private void init(
      final Project project,
      final ConfigurableGroup[] groups,
      @Nullable final Configurable preselected) {
    myProject = project;
    myGroups = groups;
    myPreselected = preselected;

    setTitle(CommonBundle.settingsTitle());

    init();
  }
  @Override
  protected void doOKAction() {
    final LibraryCompositionSettings librarySettings = myComponent.getLibraryCompositionSettings();
    if (librarySettings != null) {
      final ModifiableRootModel modifiableModel =
          myModifiableModelsProvider.getModuleModifiableModel(myModule);
      if (!askAndRemoveDuplicatedLibraryEntry(
          modifiableModel, librarySettings.getLibraryDescription())) {
        if (myConfigurable.isOnlyLibraryAdded()) {
          myModifiableModelsProvider.disposeModuleModifiableModel(modifiableModel);
          return;
        }
        return;
      }

      // Fix
      new WriteAction() {
        @Override
        protected void run(final Result result) {
          myModifiableModelsProvider.commitModuleModifiableModel(modifiableModel);
        }
      }.execute();

      final boolean downloaded = librarySettings.downloadFiles(getRootPane());
      if (!downloaded) {
        int answer =
            Messages.showYesNoDialog(
                getRootPane(),
                ProjectBundle.message("warning.message.some.required.libraries.wasn.t.downloaded"),
                CommonBundle.getWarningTitle(),
                Messages.getWarningIcon());
        if (answer != 0) {
          return;
        }
      }
    }

    new WriteAction() {
      @Override
      protected void run(final Result result) {
        final ModifiableRootModel rootModel =
            myModifiableModelsProvider.getModuleModifiableModel(myModule);
        if (librarySettings != null) {
          librarySettings.addLibraries(
              rootModel, new ArrayList<Library>(), myModel.getLibrariesContainer());
        }
        myConfigurable.addSupport(myModule, rootModel, myModifiableModelsProvider);
        myModifiableModelsProvider.commitModuleModifiableModel(rootModel);
      }
    }.execute();
    super.doOKAction();
  }
 @Override
 protected JComponent createSouthPanel() {
   JComponent southPanel = super.createSouthPanel();
   myDoNotAskMeCheckBox = new JCheckBox(CommonBundle.message("dialog.options.do.not.show"));
   myDoNotAskMeCheckBox.addActionListener(
       new ActionListener() {
         @Override
         public void actionPerformed(ActionEvent e) {
           updateState();
         }
       });
   return DialogWrapper.addDoNotShowCheckBox(southPanel, myDoNotAskMeCheckBox);
 }
Exemplo n.º 24
0
 @Nullable
 public static AndroidSdkData parse(@NotNull String path, @NotNull final Component component) {
   MessageBuildingSdkLog log = new MessageBuildingSdkLog();
   AndroidSdkData sdkData = parse(path, log);
   if (sdkData == null) {
     String message = log.getErrorMessage();
     if (message.length() > 0) {
       message = "Android SDK is parsed incorrectly. Parsing log:\n" + message;
       Messages.showInfoMessage(component, message, CommonBundle.getErrorTitle());
     }
   }
   return sdkData;
 }
  public static void openTipInBrowser(@Nullable TipAndTrickBean tip, JEditorPane browser) {
    if (tip == null) return;
    try {
      PluginDescriptor pluginDescriptor = tip.getPluginDescriptor();
      ClassLoader tipLoader =
          pluginDescriptor == null
              ? TipUIUtil.class.getClassLoader()
              : ObjectUtils.notNull(
                  pluginDescriptor.getPluginClassLoader(), TipUIUtil.class.getClassLoader());

      URL url = ResourceUtil.getResource(tipLoader, "/tips/", tip.fileName);

      if (url == null) {
        setCantReadText(browser, tip);
        return;
      }

      StringBuffer text = new StringBuffer(ResourceUtil.loadText(url));
      updateShortcuts(text);
      updateImages(text, tipLoader);
      String replaced =
          text.toString()
              .replace("&productName;", ApplicationNamesInfo.getInstance().getFullProductName());
      String major = ApplicationInfo.getInstance().getMajorVersion();
      replaced = replaced.replace("&majorVersion;", major);
      String minor = ApplicationInfo.getInstance().getMinorVersion();
      replaced = replaced.replace("&minorVersion;", minor);
      replaced =
          replaced.replace("&majorMinorVersion;", major + ("0".equals(minor) ? "" : ("." + minor)));
      replaced = replaced.replace("&settingsPath;", CommonBundle.settingsActionPath());
      replaced =
          replaced.replaceFirst(
              "<link rel=\"stylesheet\".*tips\\.css\">", ""); // don't reload the styles
      if (browser.getUI() == null) {
        browser.updateUI();
        boolean succeed = browser.getUI() != null;
        String message =
            "reinit JEditorPane.ui: "
                + (succeed ? "OK" : "FAIL")
                + ", laf="
                + LafManager.getInstance().getCurrentLookAndFeel();
        if (succeed) LOG.warn(message);
        else LOG.error(message);
      }
      adjustFontSize(((HTMLEditorKit) browser.getEditorKit()).getStyleSheet());
      browser.read(new StringReader(replaced), url);
    } catch (IOException e) {
      setCantReadText(browser, tip);
    }
  }
  @Override
  protected void doOKAction() {
    final String resourceName = getResourceName();
    final String fileName = getFileName();
    final List<String> dirNames = getDirNames();
    final Module module = getModule();

    if (resourceName.length() == 0) {
      Messages.showErrorDialog(
          myPanel, "Resource name is not specified", CommonBundle.getErrorTitle());
    } else if (!AndroidResourceUtil.isCorrectAndroidResourceName(resourceName)) {
      Messages.showErrorDialog(
          myPanel, resourceName + " is not correct resource name", CommonBundle.getErrorTitle());
    } else if (fileName.length() == 0) {
      Messages.showErrorDialog(myPanel, "File name is not specified", CommonBundle.getErrorTitle());
    } else if (dirNames.size() == 0) {
      Messages.showErrorDialog(
          myPanel, "Directories are not selected", CommonBundle.getErrorTitle());
    } else if (module == null) {
      Messages.showErrorDialog(myPanel, "Module is not specified", CommonBundle.getErrorTitle());
    } else {
      super.doOKAction();
    }
  }
Exemplo n.º 27
0
 public void onWizardFinished() throws CommitStepException {
   if (isFrameworksMode()) {
     boolean ok = myFrameworksPanel.downloadLibraries();
     if (!ok) {
       int answer =
           Messages.showYesNoDialog(
               getComponent(),
               ProjectBundle.message("warning.message.some.required.libraries.wasn.t.downloaded"),
               CommonBundle.getWarningTitle(),
               Messages.getWarningIcon());
       if (answer != Messages.YES) {
         throw new CommitStepException(null);
       }
     }
   }
 }
  public ContentChooser(
      Project project, String title, boolean useIdeaEditor, boolean allowMultipleSelections) {
    super(project, true);
    myProject = project;
    myUseIdeaEditor = useIdeaEditor;
    myAllowMultipleSelections = allowMultipleSelections;
    myUpdateAlarm = new Alarm(getDisposable());
    mySplitter = new JBSplitter(true, 0.3f);
    mySplitter.setSplitterProportionKey(getDimensionServiceKey() + ".splitter");
    myList = new JBList(new CollectionListModel<Item>());
    myList.setExpandableItemsEnabled(false);

    setOKButtonText(CommonBundle.getOkButtonText());
    setTitle(title);

    init();
  }
Exemplo n.º 29
0
  @Override
  protected void updateImpl(PresentationData data) {
    PsiFile value = getValue();
    data.setPresentableText(value.getName());
    data.setIcon(value.getIcon(Iconable.ICON_FLAG_READ_STATUS));

    VirtualFile file = getVirtualFile();
    if (file != null && file.is(VFileProperty.SYMLINK)) {
      String target = file.getCanonicalPath();
      if (target == null) {
        data.setAttributesKey(CodeInsightColors.WRONG_REFERENCES_ATTRIBUTES);
        data.setTooltip(CommonBundle.message("vfs.broken.link"));
      } else {
        data.setTooltip(FileUtil.toSystemDependentName(target));
      }
    }
  }
  private static boolean userApprovesStopForSameTypeConfigurations(
      Project project, String configName, int instancesCount) {
    RunManagerImpl runManager = RunManagerImpl.getInstanceImpl(project);
    final RunManagerConfig config = runManager.getConfig();
    if (!config.isRestartRequiresConfirmation()) return true;

    DialogWrapper.DoNotAskOption option =
        new DialogWrapper.DoNotAskOption() {
          @Override
          public boolean isToBeShown() {
            return config.isRestartRequiresConfirmation();
          }

          @Override
          public void setToBeShown(boolean value, int exitCode) {
            config.setRestartRequiresConfirmation(value);
          }

          @Override
          public boolean canBeHidden() {
            return true;
          }

          @Override
          public boolean shouldSaveOptionsOnCancel() {
            return false;
          }

          @NotNull
          @Override
          public String getDoNotShowMessage() {
            return CommonBundle.message("dialog.options.do.not.show");
          }
        };
    return Messages.showOkCancelDialog(
            project,
            ExecutionBundle.message(
                "rerun.singleton.confirmation.message", configName, instancesCount),
            ExecutionBundle.message("process.is.running.dialog.title", configName),
            ExecutionBundle.message("rerun.confirmation.button.text"),
            CommonBundle.message("button.cancel"),
            Messages.getQuestionIcon(),
            option)
        == Messages.OK;
  }