/** Checks if the program can run under the JDK it was started with. */
  private static boolean checkJdkVersion() {
    if (!"true".equals(System.getProperty("idea.no.jre.check"))) {
      try {
        // try to find a class from tools.jar
        Class.forName("com.sun.jdi.Field");
      } catch (ClassNotFoundException e) {
        showError(
            "Error",
            "'tools.jar' is not in "
                + ApplicationNamesInfo.getInstance().getProductName()
                + " classpath.\n"
                + "Please ensure JAVA_HOME points to JDK rather than JRE.");
        return false;
      }
    }

    if (!"true".equals(System.getProperty("idea.no.jdk.check"))) {
      final String version = System.getProperty("java.version");
      if (!SystemInfo.isJavaVersionAtLeast("1.6")) {
        showError(
            "Java Version Mismatch",
            "The JDK version is "
                + version
                + ".\n"
                + ApplicationNamesInfo.getInstance().getProductName()
                + " requires JDK 1.6 or higher.");
        return false;
      }
    }

    return true;
  }
Beispiel #2
0
 public boolean validate() {
   if (myRbImportModule.isSelected()) {
     final String path = myModulePathFieldPanel.getText().trim();
     if (path.length() == 0) {
       Messages.showErrorDialog(
           IdeBundle.message(
               "error.please.specify.path.to.module.file",
               ApplicationNamesInfo.getInstance().getProductName()),
           IdeBundle.message("title.module.file.path.not.specified"));
       myModulePathFieldPanel.getTextField().requestFocus();
       return false;
     }
     final File file = new File(path);
     if (!file.exists()) {
       Messages.showErrorDialog(
           IdeBundle.message("error.module.file.does.not.exist"),
           IdeBundle.message("title.module.file.does.not.exist"));
       myModulePathFieldPanel.getTextField().requestFocus();
       return false;
     }
     if (!StdFileTypes.IDEA_MODULE.equals(
         FileTypeManager.getInstance().getFileTypeByFileName(file.getName()))) {
       Messages.showErrorDialog(
           IdeBundle.message(
               "error.module.not.iml", path, ApplicationNamesInfo.getInstance().getProductName()),
           IdeBundle.message("title.incorrect.file.type"));
       myModulePathFieldPanel.getTextField().requestFocus();
       return false;
     }
   }
   return true;
 }
 @Override
 public String getHTMLHeader() {
   return "<html><body><h2>Tune "
       + ApplicationNamesInfo.getInstance().getProductName()
       + " to your tasks</h2>"
       + ApplicationNamesInfo.getInstance().getProductName()
       + " has a lot of tools enabled by default. You can set only ones you need or leave them all."
       + "</body></html>";
 }
  private boolean tryToReloadApplication() {
    try {
      final Application app = ApplicationManager.getApplication();

      if (app.isDisposed()) return false;
      final HashSet<Pair<VirtualFile, StateStorage>> causes =
          new HashSet<Pair<VirtualFile, StateStorage>>(myChangedApplicationFiles);
      if (causes.isEmpty()) return true;

      final boolean[] reloadOk = {false};
      final LinkedHashSet<String> components = new LinkedHashSet<String>();

      ApplicationManager.getApplication()
          .runWriteAction(
              new Runnable() {
                @Override
                public void run() {
                  try {
                    reloadOk[0] =
                        ((ApplicationImpl) app).getStateStore().reload(causes, components);
                  } catch (StateStorageException e) {
                    Messages.showWarningDialog(
                        ProjectBundle.message("project.reload.failed", e.getMessage()),
                        ProjectBundle.message("project.reload.failed.title"));
                  } catch (IOException e) {
                    Messages.showWarningDialog(
                        ProjectBundle.message("project.reload.failed", e.getMessage()),
                        ProjectBundle.message("project.reload.failed.title"));
                  }
                }
              });

      if (!reloadOk[0] && !components.isEmpty()) {
        String message = "Application components were changed externally and cannot be reloaded:\n";
        for (String component : components) {
          message += component + "\n";
        }

        final boolean canRestart = ApplicationManager.getApplication().isRestartCapable();
        message += "Would you like to " + (canRestart ? "restart " : "shutdown ");
        message += ApplicationNamesInfo.getInstance().getProductName() + "?";

        if (Messages.showYesNoDialog(
                message, "Application Configuration Reload", Messages.getQuestionIcon())
            == Messages.YES) {
          for (Pair<VirtualFile, StateStorage> cause : causes) {
            StateStorage stateStorage = cause.getSecond();
            if (stateStorage instanceof XmlElementStorage) {
              ((XmlElementStorage) stateStorage).disableSaving();
            }
          }
          ApplicationManagerEx.getApplicationEx().restart(true);
        }
      }

      return reloadOk[0];
    } finally {
      myChangedApplicationFiles.clear();
    }
  }
 /**
  * The constructor
  *
  * @param project the current project
  * @param root the vcs root
  * @param locallyModifiedFiles the collection of locally modified files to use
  */
 protected GitUpdateLocallyModifiedDialog(
     final Project project, final VirtualFile root, List<String> locallyModifiedFiles) {
   super(project, true);
   myLocallyModifiedFiles = locallyModifiedFiles;
   setTitle(GitBundle.getString("update.locally.modified.title"));
   myGitRoot.setText(root.getPresentableUrl());
   myFilesList.setModel(new DefaultListModel());
   setOKButtonText(GitBundle.getString("update.locally.modified.revert"));
   syncListModel();
   myRescanButton.addActionListener(
       new ActionListener() {
         public void actionPerformed(ActionEvent e) {
           myLocallyModifiedFiles.clear();
           try {
             scanFiles(project, root, myLocallyModifiedFiles);
           } catch (VcsException ex) {
             GitUIUtil.showOperationError(project, ex, "Checking for locally modified files");
           }
         }
       });
   myDescriptionLabel.setText(
       GitBundle.message(
           "update.locally.modified.message",
           ApplicationNamesInfo.getInstance().getFullProductName()));
   init();
 }
 /**
  * The constructor
  *
  * @param project the context project
  */
 public GitVcsPanel(@NotNull Project project) {
   myVcs = GitVcs.getInstance(project);
   myAppSettings = GitVcsApplicationSettings.getInstance();
   myProjectSettings = GitVcsSettings.getInstance(project);
   myProject = project;
   mySSHExecutableComboBox.addItem(IDEA_SSH);
   mySSHExecutableComboBox.addItem(NATIVE_SSH);
   mySSHExecutableComboBox.setSelectedItem(
       GitVcsSettings.isDefaultIdeaSsh() ? IDEA_SSH : NATIVE_SSH);
   mySSHExecutableComboBox.setToolTipText(
       GitBundle.message(
           "git.vcs.config.ssh.mode.tooltip",
           ApplicationNamesInfo.getInstance().getFullProductName()));
   myTestButton.addActionListener(
       new ActionListener() {
         public void actionPerformed(ActionEvent e) {
           testConnection();
         }
       });
   myConvertTextFilesComboBox.addItem(CRLF_DO_NOT_CONVERT);
   myConvertTextFilesComboBox.addItem(CRLF_CONVERT_TO_PROJECT);
   myConvertTextFilesComboBox.addItem(CRLF_ASK);
   myConvertTextFilesComboBox.setSelectedItem(CRLF_ASK);
   myGitField.addBrowseFolderListener(
       GitBundle.getString("find.git.title"),
       GitBundle.getString("find.git.description"),
       project,
       new FileChooserDescriptor(true, false, false, false, false, false));
 }
    private JComponent createLogo() {
      NonOpaquePanel panel = new NonOpaquePanel(new BorderLayout());
      ApplicationInfoEx app = ApplicationInfoEx.getInstanceEx();
      JLabel logo = new JLabel(IconLoader.getIcon(app.getWelcomeScreenLogoUrl()));
      logo.setBorder(JBUI.Borders.empty(30, 0, 10, 0));
      logo.setHorizontalAlignment(SwingConstants.CENTER);
      panel.add(logo, BorderLayout.NORTH);
      JLabel appName = new JLabel(ApplicationNamesInfo.getInstance().getFullProductName());
      Font font = getProductFont();
      appName.setForeground(JBColor.foreground());
      appName.setFont(font.deriveFont(JBUI.scale(36f)).deriveFont(Font.PLAIN));
      appName.setHorizontalAlignment(SwingConstants.CENTER);
      String appVersion = "Version " + app.getFullVersion();

      if (app.isEAP() && app.getBuild().getBuildNumber() < Integer.MAX_VALUE) {
        appVersion += " (" + app.getBuild().asString() + ")";
      }

      JLabel version = new JLabel(appVersion);
      version.setFont(getProductFont().deriveFont(JBUI.scale(16f)));
      version.setHorizontalAlignment(SwingConstants.CENTER);
      version.setForeground(Gray._128);

      panel.add(appName);
      panel.add(version, BorderLayout.SOUTH);
      panel.setBorder(JBUI.Borders.emptyBottom(20));
      return panel;
    }
  public WelcomeFrame() {
    JRootPane rootPane = getRootPane();
    final WelcomeScreen screen = createScreen(rootPane);

    final IdeGlassPaneImpl glassPane = new IdeGlassPaneImpl(rootPane);
    setGlassPane(glassPane);
    glassPane.setVisible(false);
    setContentPane(screen.getWelcomePanel());
    setTitle(ApplicationNamesInfo.getInstance().getFullProductName());
    AppUIUtil.updateWindowIcon(this);

    ProjectManager.getInstance()
        .addProjectManagerListener(
            new ProjectManagerAdapter() {
              @Override
              public void projectOpened(Project project) {
                dispose();
              }
            });

    myBalloonLayout = new BalloonLayoutImpl(rootPane.getLayeredPane(), new Insets(8, 8, 8, 8));

    myScreen = screen;
    setupCloseAction();
    new MnemonicHelper().register(this);
    myScreen.setupFrame(this);
  }
 protected JetBrainsTvAction(@NotNull @NonNls final String channel) {
   final String fullProductName = ApplicationNamesInfo.getInstance().getFullProductName();
   getTemplatePresentation().setText(fullProductName + " TV");
   getTemplatePresentation()
       .setDescription(
           UIBundle.message("welcome.screen.jetbrains.tv.action.description", fullProductName));
   myUrl = JETBRAINS_TV_URL + "channel/" + channel;
 }
 @Override
 public String getVersionName() {
   final String fullName = ApplicationNamesInfo.getInstance().getFullProductName();
   if (myEAP && !StringUtil.isEmptyOrSpaces(myCodeName)) {
     return fullName + " (" + myCodeName + ")";
   }
   return fullName;
 }
 ApplicationInfoImpl() {
   String resource = IDEA_PATH + ApplicationNamesInfo.getComponentName() + XML_EXTENSION;
   try {
     Document doc = JDOMUtil.loadDocument(ApplicationInfoImpl.class, resource);
     loadState(doc.getRootElement());
   } catch (Exception e) {
     throw new RuntimeException("Cannot load resource: " + resource, e);
   }
 }
Beispiel #12
0
 public FacetDetectionStep(final Icon icon, ModuleType moduleType) {
   super(
       ProjectBundle.message(
           "message.text.stop.searching.for.facets",
           ApplicationNamesInfo.getInstance().getProductName()));
   myIcon = icon;
   myModuleType = moduleType;
   myDetectedFacetsComponent = new DetectedFacetsTreeComponent();
 }
  public void testManifestSections() throws Exception {
    importProject(
        "<groupId>test</groupId>"
            + "<artifactId>project</artifactId>"
            + "<version>1</version>"
            + "<build>"
            + "    <plugins>"
            + "        <plugin>"
            + "            <artifactId>maven-jar-plugin</artifactId>"
            + "            <version>2.4</version>"
            + "            <configuration>"
            + "                <archive>"
            + "                    <manifestSections>"
            + "                        <manifestSection>"
            + "                            <name>org/test/Some.class</name>"
            + "                            <manifestEntries>"
            + "                                <Java-Bean>true</Java-Bean>"
            + "                            </manifestEntries>"
            + "                        </manifestSection>"
            + "                        <manifestSection>"
            + "                            <name>org/test/SomeOther.class</name>"
            + "                            <manifestEntries>"
            + "                                <Java-Bean>true</Java-Bean>"
            + "                            </manifestEntries>"
            + "                        </manifestSection>"
            + "                    </manifestSections>"
            + "                </archive>"
            + "            </configuration>"
            + "        </plugin>"
            + "    </plugins>"
            + "</build>");

    compileModules("project");

    assertUnorderedLinesWithFile(
        getProjectPath() + "/target/MANIFEST.MF",
        "Manifest-Version: 1.0\n"
            + "Build-Jdk: "
            + extractJdkVersion(getModule("project"))
            + "\n"
            + "Built-By: "
            + System.getProperty("user.name")
            + "\n"
            + "Created-By: "
            + ApplicationNamesInfo.getInstance().getFullProductName()
            + "\n"
            + "\n"
            + "Name: org/test/SomeOther.class\n"
            + "Java-Bean: true\n"
            + "\n"
            + "Name: org/test/Some.class\n"
            + "Java-Bean: true");
  }
  private void replaceDuplicates(
      final String includePath,
      final List<IncludeDuplicate<T>> duplicates,
      final Editor editor,
      final Project project) {
    if (duplicates.size() > 0) {
      final String message =
          RefactoringBundle.message(
              "idea.has.found.fragments.that.can.be.replaced.with.include.directive",
              ApplicationNamesInfo.getInstance().getProductName());
      final int exitCode =
          Messages.showYesNoDialog(
              project, message, getRefactoringName(), Messages.getInformationIcon());
      if (exitCode == DialogWrapper.OK_EXIT_CODE) {
        CommandProcessor.getInstance()
            .executeCommand(
                project,
                new Runnable() {
                  public void run() {
                    boolean replaceAll = false;
                    for (IncludeDuplicate<T> pair : duplicates) {
                      if (!replaceAll) {

                        highlightInEditor(project, pair, editor);

                        ReplacePromptDialog promptDialog =
                            new ReplacePromptDialog(
                                false, RefactoringBundle.message("replace.fragment"), project);
                        promptDialog.show();
                        final int promptResult = promptDialog.getExitCode();
                        if (promptResult == FindManager.PromptResult.SKIP) continue;
                        if (promptResult == FindManager.PromptResult.CANCEL) break;

                        if (promptResult == FindManager.PromptResult.OK) {
                          doReplaceRange(includePath, pair.getStart(), pair.getEnd());
                        } else if (promptResult == FindManager.PromptResult.ALL) {
                          doReplaceRange(includePath, pair.getStart(), pair.getEnd());
                          replaceAll = true;
                        } else {
                          LOG.error("Unknown return status");
                        }
                      } else {
                        doReplaceRange(includePath, pair.getStart(), pair.getEnd());
                      }
                    }
                  }
                },
                RefactoringBundle.message("remove.duplicates.command"),
                null);
      }
    }
  }
 public static String getBaseDir() {
   final String lastProjectLocation =
       RecentProjectsManager.getInstance().getLastProjectCreationLocation();
   if (lastProjectLocation != null) {
     return lastProjectLocation.replace('/', File.separatorChar);
   }
   final String userHome = SystemProperties.getUserHome();
   //noinspection HardCodedStringLiteral
   return userHome.replace('/', File.separatorChar)
       + File.separator
       + ApplicationNamesInfo.getInstance().getLowercaseProductName()
       + "Projects";
 }
 private static void setCantReadText(JEditorPane browser, TipAndTrickBean bean) {
   try {
     String plugin = getPoweredByText(bean);
     String product = ApplicationNamesInfo.getInstance().getFullProductName();
     if (!plugin.isEmpty()) {
       product += " and " + plugin + " plugin";
     }
     String message =
         IdeBundle.message("error.unable.to.read.tip.of.the.day", bean.fileName, product);
     browser.read(new StringReader(message), null);
   } catch (IOException ignored) {
   }
 }
Beispiel #17
0
 /**
  * @return the prompthooks.py extension used for capturing prompts from Mercurial and requesting
  *     IDEA's user about authentication.
  */
 @NotNull
 public File getPromptHooksExtensionFile() {
   if (myPromptHooksExtensionFile == null) {
     // check that hooks are available
     myPromptHooksExtensionFile = HgUtil.getTemporaryPythonFile("prompthooks");
     if (myPromptHooksExtensionFile == null || !myPromptHooksExtensionFile.exists()) {
       LOG.error(
           "prompthooks.py Mercurial extension is not found. Please reinstall "
               + ApplicationNamesInfo.getInstance().getProductName());
     }
   }
   return myPromptHooksExtensionFile;
 }
  protected void setup(
      final AnAction action,
      JPanel root,
      final JLabel name,
      final JLabel description,
      JLabel icon) {
    name.setText(action.getTemplatePresentation().getText());
    name.setUI(DarculaWelcomeScreenLabelUI.createUI(name));
    name.setForeground(UIUtil.getPanelBackground());
    description.setUI(DarculaWelcomeScreenLabelUI.createUI(description));
    // icon.setIcon(action.getTemplatePresentation().getIcon());
    final String text = action.getTemplatePresentation().getDescription();
    final String html =
        XmlStringUtil.wrapInHtml(
            MessageFormat.format(text, ApplicationNamesInfo.getInstance().getFullProductName()));
    root.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
    description.setText(html);
    description.setForeground(Gray._200);
    description.setEnabled(false);
    root.addMouseListener(
        new MouseAdapter() {
          @Override
          public void mouseEntered(MouseEvent e) {
            description.setEnabled(true);
            name.setForeground(new Color(0xE09600));
          }

          @Override
          public void mouseExited(MouseEvent e) {
            description.setEnabled(false);
            name.setForeground(UIUtil.getPanelBackground());
          }

          @Override
          public void mouseClicked(MouseEvent e) {
            final ActionManager actionManager = ActionManager.getInstance();
            AnActionEvent evt =
                new AnActionEvent(
                    null,
                    DataManager.getInstance().getDataContext(e.getComponent()),
                    ActionPlaces.WELCOME_SCREEN,
                    action.getTemplatePresentation(),
                    actionManager,
                    0);
            action.beforeActionPerformedUpdate(evt);
            if (evt.getPresentation().isEnabled()) {
              action.actionPerformed(evt);
            }
          }
        });
  }
  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);
    }
  }
  private static boolean showConfirmation() {
    final boolean hasUnsafeBgTasks = ProgressManager.getInstance().hasUnsafeProgressIndicator();

    DialogWrapper.DoNotAskOption option =
        new DialogWrapper.DoNotAskOption() {
          @Override
          public boolean isToBeShown() {
            return GeneralSettings.getInstance().isConfirmExit();
          }

          @Override
          public void setToBeShown(boolean value, int exitCode) {
            GeneralSettings.getInstance().setConfirmExit(value);
          }

          @Override
          public boolean canBeHidden() {
            return !hasUnsafeBgTasks;
          }

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

          @Override
          public String getDoNotShowMessage() {
            return "Do not ask me again";
          }
        };

    if (hasUnsafeBgTasks || option.isToBeShown()) {
      String message =
          ApplicationBundle.message(
              hasUnsafeBgTasks ? "exit.confirm.prompt.tasks" : "exit.confirm.prompt",
              ApplicationNamesInfo.getInstance().getFullProductName());

      if (DialogWrapper.OK_EXIT_CODE
          != Messages.showYesNoDialog(
              message,
              ApplicationBundle.message("exit.confirm.title"),
              ApplicationBundle.message("command.exit"),
              "Cancel",
              Messages.getQuestionIcon(),
              option)) {
        return false;
      }
    }
    return true;
  }
  public void testDefaultEntries() throws Exception {
    importProject(
        "<groupId>test</groupId>"
            + "<artifactId>project</artifactId>"
            + "<version>1</version>"
            + "<dependencies>"
            + "  <dependency>"
            + "    <groupId>test</groupId>"
            + "    <artifactId>other-project</artifactId>"
            + "    <version>1</version>"
            + "  </dependency>"
            + "</dependencies>"
            + "<build>"
            + "    <plugins>"
            + "        <plugin>"
            + "            <artifactId>maven-jar-plugin</artifactId>"
            + "            <version>2.4</version>"
            + "            <configuration>"
            + "                <archive>"
            + "                    <manifest>"
            + "                        <addDefaultImplementationEntries>true</addDefaultImplementationEntries>"
            + "                        <addDefaultSpecificationEntries>true</addDefaultSpecificationEntries>"
            + "                    </manifest>"
            + "                </archive>"
            + "            </configuration>"
            + "        </plugin>"
            + "    </plugins>"
            + "</build>");

    compileModules("project");

    assertUnorderedLinesWithFile(
        getProjectPath() + "/target/MANIFEST.MF",
        "Manifest-Version: 1.0\n"
            + "Implementation-Version: 1\n"
            + "Implementation-Vendor-Id: test\n"
            + "Build-Jdk: "
            + extractJdkVersion(getModule("project"))
            + "\n"
            + "Built-By: "
            + System.getProperty("user.name")
            + "\n"
            + "Created-By: "
            + ApplicationNamesInfo.getInstance().getFullProductName()
            + "\n"
            + "Specification-Version: 1");
  }
  private void applyTo(ArrayRenderer renderer, boolean showBigRangeWarning)
      throws ConfigurationException {
    int newStartIndex = getInt(myStartIndex);
    int newEndIndex = getInt(myEndIndex);
    int newLimit = getInt(myEntriesLimit);

    if (newStartIndex < 0) {
      throw new ConfigurationException(
          DebuggerBundle.message("error.array.renderer.configurable.start.index.less.than.zero"));
    }

    if (newEndIndex < newStartIndex) {
      throw new ConfigurationException(
          DebuggerBundle.message("error.array.renderer.configurable.end.index.less.than.start"));
    }

    if (newStartIndex >= 0 && newEndIndex >= 0) {
      if (newStartIndex > newEndIndex) {
        int currentStartIndex = renderer.START_INDEX;
        int currentEndIndex = renderer.END_INDEX;
        newEndIndex = newStartIndex + (currentEndIndex - currentStartIndex);
      }

      if (newLimit <= 0) {
        newLimit = 1;
      }

      if (showBigRangeWarning && (newEndIndex - newStartIndex > 10000)) {
        final int answer =
            Messages.showOkCancelDialog(
                myPanel.getRootPane(),
                DebuggerBundle.message(
                    "warning.range.too.big", ApplicationNamesInfo.getInstance().getProductName()),
                DebuggerBundle.message("title.range.too.big"),
                Messages.getWarningIcon());
        if (answer != Messages.OK) {
          return;
        }
      }
    }

    renderer.START_INDEX = newStartIndex;
    renderer.END_INDEX = newEndIndex;
    renderer.ENTRIES_LIMIT = newLimit;
  }
  public void testBasic() throws Exception {
    importProject(
        "<groupId>test</groupId>" + "<artifactId>project</artifactId>" + "<version>1</version>");

    compileModules("project");

    assertUnorderedLinesWithFile(
        getProjectPath() + "/target/MANIFEST.MF",
        "Manifest-Version: 1.0\n"
            + "Build-Jdk: "
            + extractJdkVersion(getModule("project"))
            + "\n"
            + "Built-By: "
            + System.getProperty("user.name")
            + "\n"
            + "Created-By: "
            + ApplicationNamesInfo.getInstance().getFullProductName());
  }
  public static void handleComponentError(
      Throwable t, @Nullable String componentClassName, @Nullable ComponentConfig config) {
    if (t instanceof StartupAbortedException) {
      throw (StartupAbortedException) t;
    }

    PluginId pluginId = null;
    if (config != null) {
      pluginId = config.getPluginId();
    }
    if (pluginId == null || CORE_PLUGIN_ID.equals(pluginId.getIdString())) {
      if (componentClassName != null) {
        pluginId = getPluginByClassName(componentClassName);
      }
    }
    if (pluginId == null || CORE_PLUGIN_ID.equals(pluginId.getIdString())) {
      if (t instanceof PicoPluginExtensionInitializationException) {
        pluginId = ((PicoPluginExtensionInitializationException) t).getPluginId();
      }
    }

    if (pluginId != null && !CORE_PLUGIN_ID.equals(pluginId.getIdString())) {
      getLogger().warn(t);

      disablePlugin(pluginId.getIdString());

      StringWriter message = new StringWriter();
      message
          .append("Plugin '")
          .append(pluginId.getIdString())
          .append("' failed to initialize and will be disabled. ");
      message
          .append(" Please restart ")
          .append(ApplicationNamesInfo.getInstance().getFullProductName())
          .append('.');
      message.append("\n\n");
      t.printStackTrace(new PrintWriter(message));
      Main.showMessage("Plugin Error", message.toString(), false);

      throw new StartupAbortedException(t).exitCode(Main.PLUGIN_ERROR).logError(false);
    } else {
      throw new StartupAbortedException("Fatal error initializing '" + componentClassName + "'", t);
    }
  }
  public void testClasspathEntry() throws Exception {
    importProject(
        "<groupId>test</groupId>"
            + "<artifactId>project</artifactId>"
            + "<version>1</version>"
            + "<dependencies>"
            + "  <dependency>"
            + "    <groupId>test</groupId>"
            + "    <artifactId>other-project</artifactId>"
            + "    <version>1</version>"
            + "  </dependency>"
            + "</dependencies>"
            + "<build>"
            + "    <plugins>"
            + "        <plugin>"
            + "            <artifactId>maven-jar-plugin</artifactId>"
            + "            <version>2.4</version>"
            + "            <configuration>"
            + "                <archive>"
            + "                    <manifest>"
            + "                        <addClasspath>true</addClasspath>"
            + "                        <classpathPrefix>lib</classpathPrefix>"
            + "                    </manifest>"
            + "                </archive>"
            + "            </configuration>"
            + "        </plugin>"
            + "    </plugins>"
            + "</build>");

    compileModules("project");

    assertUnorderedLinesWithFile(
        getProjectPath() + "/target/MANIFEST.MF",
        "Manifest-Version: 1.0\n"
            + "Class-Path: lib/other-project-1.jar\n"
            + "Build-Jdk: "
            + extractJdkVersion(getModule("project"))
            + "\n"
            + "Built-By: "
            + System.getProperty("user.name")
            + "\n"
            + "Created-By: "
            + ApplicationNamesInfo.getInstance().getFullProductName());
  }
 private static Pair<SVNRevision, SVNURL> createRemoteFolder(
     final SvnVcs17 vcs, final SVNURL parent, final String folderName) throws SVNException {
   SVNURL url = parent.appendPath(folderName, false);
   final String urlText = url.toString();
   final ProgressIndicator indicator = ProgressManager.getInstance().getProgressIndicator();
   if (indicator != null) {
     indicator.checkCanceled();
     indicator.setText(SvnBundle.message("share.directory.create.dir.progress.text", urlText));
   }
   final SVNCommitInfo info =
       vcs.createCommitClient()
           .doMkDir(
               new SVNURL[] {url},
               SvnBundle.message(
                   "share.directory.commit.message",
                   folderName,
                   ApplicationNamesInfo.getInstance().getFullProductName()));
   return new Pair<SVNRevision, SVNURL>(SVNRevision.create(info.getNewRevision()), url);
 }
 @Override
 protected void handleInitComponentError(
     final Throwable ex, final boolean fatal, final String componentClassName) {
   if (PluginManager.isPluginClass(componentClassName)) {
     LOG.error(ex);
     PluginId pluginId = PluginManager.getPluginByClassName(componentClassName);
     @NonNls
     final String errorMessage =
         "Plugin "
             + pluginId.getIdString()
             + " failed to initialize and will be disabled:\n"
             + ex.getMessage()
             + "\nPlease restart "
             + ApplicationNamesInfo.getInstance().getFullProductName()
             + ".";
     PluginManager.disablePlugin(pluginId.getIdString());
     if (!myHeadlessMode) {
       JOptionPane.showMessageDialog(null, errorMessage);
     } else {
       //noinspection UseOfSystemOutOrSystemErr
       System.out.println(errorMessage);
       System.exit(1);
     }
     return; // do not call super
   }
   if (fatal) {
     LOG.error(ex);
     @NonNls
     final String errorMessage =
         "Fatal error initializing class "
             + componentClassName
             + ":\n"
             + ex.toString()
             + "\nComplete error stacktrace was written to idea.log";
     if (!myHeadlessMode) {
       JOptionPane.showMessageDialog(null, errorMessage);
     } else {
       //noinspection UseOfSystemOutOrSystemErr
       System.out.println(errorMessage);
     }
   }
   super.handleInitComponentError(ex, fatal, componentClassName);
 }
Beispiel #28
0
    public UpdateInfoPanel() {
      ApplicationInfo appInfo = ApplicationInfo.getInstance();
      myBuildNumber.setText(appInfo.getBuild().asString() + ")");
      final String version = appInfo.getFullVersion();

      myVersionNumber.setText(version);
      myNewBuildNumber.setText(myLatestBuild.getNumber().asString() + ")");
      myNewVersionNumber.setText(myLatestBuild.getVersion());
      myUpdateMessageLabel.setBackground(UIUtil.getLabelBackground());
      myScrollPane.setBackground(UIUtil.getLabelBackground());
      myScrollPane.setBorder(BorderFactory.createEmptyBorder(10, 0, 0, 0));
      if (myLatestBuild.getMessage() != null) {
        StringBuilder builder = new StringBuilder();
        builder
            .append("<html><head>")
            .append(UIUtil.getCssFontDeclaration(UIUtil.getLabelFont()))
            .append("</head><body>")
            .append(StringUtil.formatLinks(myLatestBuild.getMessage()))
            .append("</body></html>");
        myUpdateMessageLabel.setText(builder.toString());
        myUpdateMessageLabel.addHyperlinkListener(BrowserHyperlinkListener.INSTANCE);
      } else {
        myUpdateMessageLabel.setVisible(false);
      }

      PatchInfo patch = myLatestBuild.findPatchForCurrentBuild();
      if (patch == null) {
        myPatchAvailableLabel.setVisible(false);
        myPatchSizeLabel.setVisible(false);
      } else {
        myPatchSizeLabel.setText(patch.getSize() + "MB");
      }

      if (SystemInfo.isMac) {
        myManualCheckLabel.setText(
            "<html><br>To check for new updates manually, use the <b>"
                + ApplicationNamesInfo.getInstance().getProductName()
                + " | Check for Updates</b> command.</html>");
      }

      LabelTextReplacingUtil.replaceText(myPanel);
    }
  public void testManifestEntries() throws Exception {
    importProject(
        "<groupId>test</groupId>"
            + "<artifactId>project</artifactId>"
            + "<version>1</version>"
            + "<build>"
            + "    <plugins>"
            + "        <plugin>"
            + "            <artifactId>maven-jar-plugin</artifactId>"
            + "            <version>2.4</version>"
            + "            <configuration>"
            + "                <archive>"
            + "                    <manifestEntries>"
            + "                        <Dependencies>some.package</Dependencies>"
            + "                        <otherEntry>other entry value </otherEntry>"
            + "                    </manifestEntries>"
            + "                </archive>"
            + "            </configuration>"
            + "        </plugin>"
            + "    </plugins>"
            + "</build>");

    compileModules("project");

    assertUnorderedLinesWithFile(
        getProjectPath() + "/target/MANIFEST.MF",
        "Manifest-Version: 1.0\n"
            + "otherEntry: other entry value\n"
            + "Dependencies: some.package\n"
            + "Build-Jdk: "
            + extractJdkVersion(getModule("project"))
            + "\n"
            + "Built-By: "
            + System.getProperty("user.name")
            + "\n"
            + "Created-By: "
            + ApplicationNamesInfo.getInstance().getFullProductName());
  }
  private static boolean ensureCouldCloseIfUnableToSave(@NotNull final Project project) {
    final ProjectImpl.UnableToSaveProjectNotification[] notifications =
        NotificationsManager.getNotificationsManager()
            .getNotificationsOfType(ProjectImpl.UnableToSaveProjectNotification.class, project);
    if (notifications.length == 0) return true;

    final String fileNames = StringUtil.join(notifications[0].getFileNames(), "\n");

    final String msg =
        String.format(
            "%s was unable to save some project files,\nare you sure you want to close this project anyway?",
            ApplicationNamesInfo.getInstance().getProductName());
    return Messages.showDialog(
            project,
            msg,
            "Unsaved Project",
            "Read-only files:\n\n" + fileNames,
            new String[] {"Yes", "No"},
            0,
            1,
            Messages.getWarningIcon())
        == 0;
  }