Java 类com.intellij.openapi.project.ProjectBundle 实例源码

项目:intellij-ce-playground    文件:PackageUtil.java   
public static boolean checkSourceRootsConfigured(final Module module, final boolean askUserToSetupSourceRoots) {
  List<VirtualFile> sourceRoots = ModuleRootManager.getInstance(module).getSourceRoots(JavaModuleSourceRootTypes.SOURCES);
  if (sourceRoots.isEmpty()) {
    if (!askUserToSetupSourceRoots) {
      return false;
    }

    Project project = module.getProject();
    Messages.showErrorDialog(project,
                             ProjectBundle.message("module.source.roots.not.configured.error", module.getName()),
                             ProjectBundle.message("module.source.roots.not.configured.title"));

    ProjectSettingsService.getInstance(project).showModuleConfigurationDialog(module.getName(), CommonContentEntriesEditor.NAME);

    sourceRoots = ModuleRootManager.getInstance(module).getSourceRoots(JavaModuleSourceRootTypes.SOURCES);
    if (sourceRoots.isEmpty()) {
      return false;
    }
  }
  return true;
}
项目:intellij-ce-playground    文件:ModuleProjectStructureElement.java   
public void checkModulesNames(ProjectStructureProblemsHolder problemsHolder) {
  final ModifiableModuleModel moduleModel = myContext.getModulesConfigurator().getModuleModel();
  final Module[] all = moduleModel.getModules();
  if (!ArrayUtil.contains(myModule, all)) {
    return;//module has been deleted
  }

  for (Module each : all) {
    if (each != myModule && myContext.getRealName(each).equals(myContext.getRealName(myModule))) {
      problemsHolder.registerProblem(ProjectBundle.message("project.roots.module.duplicate.name.message"), null,
                                     ProjectStructureProblemType.error("duplicate-module-name"), createPlace(),
                                     null);
      break;
    }
  }
}
项目:intellij-ce-playground    文件:ProjectStructureValidator.java   
public static void showDialogAndAddLibraryToDependencies(final Library library, final Project project, boolean allowEmptySelection) {
  for (ProjectStructureValidator validator : EP_NAME.getExtensions()) {
    if (validator.addLibraryToDependencies(library, project, allowEmptySelection)) {
      return;
    }
  }

  final ModuleStructureConfigurable moduleStructureConfigurable = ModuleStructureConfigurable.getInstance(project);
  final List<Module> modules =
    LibraryEditingUtil.getSuitableModules(moduleStructureConfigurable, ((LibraryEx)library).getKind(), library);
  if (modules.isEmpty()) return;
  final ChooseModulesDialog
    dlg = new ChooseModulesDialog(moduleStructureConfigurable.getProject(), modules, ProjectBundle.message("choose.modules.dialog.title"),
                                  ProjectBundle
                                    .message("choose.modules.dialog.description", library.getName()));
  if (dlg.showAndGet()) {
    final List<Module> chosenModules = dlg.getChosenElements();
    for (Module module : chosenModules) {
      moduleStructureConfigurable.addLibraryOrderEntry(module, library);
    }
  }
}
项目:intellij-ce-playground    文件:SdkType.java   
public FileChooserDescriptor getHomeChooserDescriptor() {
  final FileChooserDescriptor descriptor = new FileChooserDescriptor(false, true, false, false, false, false) {
    @Override
    public void validateSelectedFiles(VirtualFile[] files) throws Exception {
      if (files.length != 0){
        final String selectedPath = files[0].getPath();
        boolean valid = isValidSdkHome(selectedPath);
        if (!valid){
          valid = isValidSdkHome(adjustSelectedSdkHome(selectedPath));
          if (!valid) {
            String message = files[0].isDirectory()
                             ? ProjectBundle.message("sdk.configure.home.invalid.error", getPresentableName())
                             : ProjectBundle.message("sdk.configure.home.file.invalid.error", getPresentableName());
            throw new Exception(message);
          }
        }
      }
    }
  };
  descriptor.setTitle(ProjectBundle.message("sdk.configure.home.title", getPresentableName()));
  return descriptor;
}
项目:intellij-ce-playground    文件:SdkConfigurationUtil.java   
private static FileChooserDescriptor createCompositeDescriptor(final SdkType... sdkTypes) {
  return new FileChooserDescriptor(sdkTypes[0].getHomeChooserDescriptor()) {
    @Override
    public void validateSelectedFiles(final VirtualFile[] files) throws Exception {
      if (files.length > 0) {
        for (SdkType type : sdkTypes) {
          if (type.isValidSdkHome(files[0].getPath())) {
            return;
          }
        }
      }
      String key = files.length > 0 && files[0].isDirectory() ? "sdk.configure.home.invalid.error" : "sdk.configure.home.file.invalid.error";
      throw new Exception(ProjectBundle.message(key, sdkTypes[0].getPresentableName()));
    }
  };
}
项目:intellij-ce-playground    文件:JdkListConfigurable.java   
@Override
public AbstractAddGroup createAddAction() {
  return new AbstractAddGroup(ProjectBundle.message("add.new.jdk.text")) {
    @NotNull
    @Override
    public AnAction[] getChildren(@Nullable final AnActionEvent e) {
      DefaultActionGroup group = new DefaultActionGroup(ProjectBundle.message("add.new.jdk.text"), true);
      myJdksTreeModel.createAddActions(group, myTree, new Consumer<Sdk>() {
        @Override
        public void consume(final Sdk projectJdk) {
          addJdkNode(projectJdk, true);
        }
      });
      return group.getChildren(null);
    }
  };
}
项目:intellij-ce-playground    文件:LibraryEditorDialogBase.java   
protected boolean validateAndApply() {
  String newName = myNameField.getText().trim();
  if (newName.length() == 0) {
    newName = null;
  }
  if (shouldCheckName(newName)) {
    final LibraryTable.ModifiableModel tableModifiableModel = getTableModifiableModel();
    if (tableModifiableModel != null && !(tableModifiableModel instanceof ModuleLibraryTable)) {
      if (newName == null) {
        Messages.showErrorDialog(ProjectBundle.message("library.name.not.specified.error", newName), ProjectBundle.message("library.name.not.specified.title"));
        return false;
      }
      if (LibraryEditingUtil.libraryAlreadyExists(tableModifiableModel, newName)) {
        Messages.showErrorDialog(ProjectBundle.message("library.name.already.exists.error", newName), ProjectBundle.message("library.name.already.exists.title"));
        return false;
      }
    }
    myLibraryRootsComponent.renameLibrary(newName);
  }
  myLibraryRootsComponent.applyProperties();
  return true;
}
项目:intellij-ce-playground    文件:ContentRootPanel.java   
private JComponent createHeader() {
  final JPanel panel = new JPanel(new GridBagLayout());
  final JLabel headerLabel = new JLabel(toDisplayPath(getContentEntry().getUrl()));
  headerLabel.setFont(headerLabel.getFont().deriveFont(Font.BOLD));
  headerLabel.setOpaque(false);
  if (getContentEntry().getFile() == null) {
    headerLabel.setForeground(JBColor.RED);
  }
  final IconActionComponent deleteIconComponent = new IconActionComponent(AllIcons.Modules.DeleteContentRoot,
                                                                          AllIcons.Modules.DeleteContentRootRollover,
                                                                          ProjectBundle.message("module.paths.remove.content.tooltip"), new Runnable() {
    @Override
    public void run() {
      myCallback.deleteContentEntry();
    }
  });
  final ResizingWrapper wrapper = new ResizingWrapper(headerLabel);
  panel.add(wrapper, new GridBagConstraints(0, GridBagConstraints.RELATIVE, 1, 1, 1.0, 1.0, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, new Insets(0, 2, 0, 0), 0, 0));
  panel.add(deleteIconComponent, new GridBagConstraints(1, GridBagConstraints.RELATIVE, 1, 1, 0.0, 1.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 2), 0, 0));
  FilePathClipper.install(headerLabel, wrapper);
  return panel;
}
项目:intellij-ce-playground    文件:ExtractArtifactDialog.java   
public ExtractArtifactDialog(ArtifactEditorContext context, LayoutTreeComponent treeComponent, String initialName) {
  super(treeComponent.getLayoutTree(), true);
  myContext = context;
  setTitle(ProjectBundle.message("dialog.title.extract.artifact"));
  for (ArtifactType type : ArtifactType.getAllTypes()) {
    myTypeBox.addItem(type);
  }
  myTypeBox.setSelectedItem(PlainArtifactType.getInstance());
  myTypeBox.setRenderer(new ArtifactTypeCellRenderer(myTypeBox.getRenderer()));
  myNameField.getDocument().addDocumentListener(new DocumentAdapter() {
    @Override
    protected void textChanged(DocumentEvent e) {
      setOKActionEnabled(!StringUtil.isEmptyOrSpaces(getArtifactName()));
    }
  });
  myNameField.setText(initialName);
  init();
}
项目:intellij-ce-playground    文件:ModuleManagerImpl.java   
@NotNull
private Module loadModuleInternal(@NotNull String filePath) throws ModuleWithNameAlreadyExists, IOException {
  filePath = resolveShortWindowsName(filePath);
  final VirtualFile moduleFile = StandardFileSystems.local().findFileByPath(filePath);
  if (moduleFile == null || !moduleFile.exists()) {
    throw new FileNotFoundException(ProjectBundle.message("module.file.does.not.exist.error", filePath));
  }

  String path = moduleFile.getPath();
  ModuleEx module = getModuleByFilePath(path);
  if (module == null) {
    ApplicationManager.getApplication().invokeAndWait(new Runnable() {
      @Override
      public void run() {
        moduleFile.refresh(false, false);
      }
    }, ModalityState.any());
    module = createAndLoadModule(path);
    initModule(module, path, null);
  }
  return module;
}
项目:intellij-ce-playground    文件:ClasspathEditor.java   
private ClasspathFormatPanel(@NotNull ClasspathStorageProvider[] providers) {
  super(new GridBagLayout());

  add(new JLabel(ProjectBundle.message("project.roots.classpath.format.label")),
      new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(10, 6, 6, 0), 0, 0));

  formatIdToDescription.put(ClassPathStorageUtil.DEFAULT_STORAGE, ProjectBundle.message("project.roots.classpath.format.default.descr"));
  for (ClasspathStorageProvider provider : providers) {
    formatIdToDescription.put(provider.getID(), provider.getDescription());
  }

  comboBoxClasspathFormat = new ComboBox(formatIdToDescription.values().toArray());
  updateClasspathFormat();
  add(comboBoxClasspathFormat,
      new GridBagConstraints(1, 0, 1, 1, 1.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(6, 6, 6, 0), 0, 0));
}
项目:intellij-ce-playground    文件:ProjectConfigurable.java   
private void createUIComponents() {
  myLanguageLevelCombo = new LanguageLevelCombo(JavaCoreBundle.message("default.language.level.description")) {
    @Override
    protected LanguageLevel getDefaultLevel() {
      Sdk sdk = myProjectJdkConfigurable.getSelectedProjectJdk();
      if (sdk == null) return null;
      JavaSdkVersion version = JavaSdk.getInstance().getVersion(sdk);
      return version == null ? null : version.getMaxLanguageLevel();
    }
  };
  final JTextField textField = new JTextField();
  final FileChooserDescriptor outputPathsChooserDescriptor = FileChooserDescriptorFactory.createSingleFolderDescriptor();
  InsertPathAction.addTo(textField, outputPathsChooserDescriptor);
  outputPathsChooserDescriptor.setHideIgnored(false);
  BrowseFilesListener listener = new BrowseFilesListener(textField, "", ProjectBundle.message("project.compiler.output"), outputPathsChooserDescriptor);
  myProjectCompilerOutput = new FieldPanel(textField, null, null, listener, EmptyRunnable.getInstance());
  FileChooserFactory.getInstance().installFileCompletion(myProjectCompilerOutput.getTextField(), outputPathsChooserDescriptor, true, null);
}
项目:intellij-ce-playground    文件:LibraryItem.java   
@Override
public String getTooltipText() {
  if (myEntry == null) return null;

  final Library library = myEntry.getLibrary();
  if (library == null) return null;

  final String name = library.getName();
  if (name != null) {
    final List<String> invalidUrls = ((LibraryEx)library).getInvalidRootUrls(OrderRootType.CLASSES);
    if (!invalidUrls.isEmpty()) {
      return ProjectBundle.message("project.roots.tooltip.library.has.broken.paths", name, invalidUrls.size());
    }
  }

  final List<String> descriptions = LibraryPresentationManager.getInstance().getDescriptions(library, myContext);
  if (descriptions.isEmpty()) return null;

  return XmlStringUtil.wrapInHtml(StringUtil.join(descriptions, "<br>"));
}
项目:intellij-ce-playground    文件:AddFrameworkSupportDialog.java   
protected void doOKAction() {
  if (myAddSupportPanel.hasSelectedFrameworks()) {
    if (!myAddSupportPanel.downloadLibraries()) {
      int answer = Messages.showYesNoDialog(myAddSupportPanel.getMainPanel(),
                                            ProjectBundle.message("warning.message.some.required.libraries.wasn.t.downloaded"),
                                            CommonBundle.getWarningTitle(), Messages.getWarningIcon());
      if (answer != Messages.YES) {
        return;
      }
    }

    DumbService.allowStartingDumbModeInside(DumbModePermission.MAY_START_BACKGROUND, new Runnable() {
      @Override
      public void run() {
        new WriteAction() {
          protected void run(@NotNull final Result result) {
            ModifiableRootModel model = ModuleRootManager.getInstance(myModule).getModifiableModel();
            myAddSupportPanel.addSupport(myModule, model);
            model.commit();
          }
        }.execute();
      }
    });
  }
  super.doOKAction();
}
项目:intellij-ce-playground    文件:ExternalAnnotationsManagerImpl.java   
private void setupRootAndAnnotateExternally(@NotNull final OrderEntry entry,
                                            @NotNull final Project project,
                                            @NotNull final PsiModifierListOwner listOwner,
                                            @NotNull final String annotationFQName,
                                            @NotNull final PsiFile fromFile,
                                            @NotNull final String packageName,
                                            @Nullable final PsiNameValuePair[] value) {
  final FileChooserDescriptor descriptor = FileChooserDescriptorFactory.createSingleFolderDescriptor();
  descriptor.setTitle(ProjectBundle.message("external.annotations.root.chooser.title", entry.getPresentableName()));
  descriptor.setDescription(ProjectBundle.message("external.annotations.root.chooser.description"));
  final VirtualFile newRoot = FileChooser.chooseFile(descriptor, project, null);
  if (newRoot == null) {
    notifyAfterAnnotationChanging(listOwner, annotationFQName, false);
    return;
  }
  new WriteCommandAction(project) {
    @Override
    protected void run(@NotNull final Result result) throws Throwable {
      appendChosenAnnotationsRoot(entry, newRoot);
      XmlFile xmlFileInRoot = findXmlFileInRoot(findExternalAnnotationsXmlFiles(listOwner), newRoot);
      if (xmlFileInRoot != null) { //file already exists under appeared content root
        if (!FileModificationService.getInstance().preparePsiElementForWrite(xmlFileInRoot)) {
          notifyAfterAnnotationChanging(listOwner, annotationFQName, false);
          return;
        }
        annotateExternally(listOwner, annotationFQName, xmlFileInRoot, fromFile, value);
      }
      else {
        final XmlFile annotationsXml = createAnnotationsXml(newRoot, packageName);
        if (annotationsXml != null) {
          List<PsiFile> createdFiles = new SmartList<PsiFile>(annotationsXml);
          cacheExternalAnnotations(packageName, fromFile, createdFiles);
        }
        annotateExternally(listOwner, annotationFQName, annotationsXml, fromFile, value);
      }
    }
  }.execute();
}
项目:intellij-ce-playground    文件:JdkChooserPanel.java   
public static Sdk chooseAndSetJDK(final Project project) {
  final Sdk projectJdk = ProjectRootManager.getInstance(project).getProjectSdk();
  final Sdk jdk = showDialog(project, ProjectBundle.message("module.libraries.target.jdk.select.title"), WindowManagerEx.getInstanceEx().getFrame(project), projectJdk);
  if (jdk == null) {
    return null;
  }
  ApplicationManager.getApplication().runWriteAction(new Runnable() {
    public void run() {
      ProjectRootManager.getInstance(project).setProjectSdk(jdk);
    }
  });
  return jdk;
}
项目:intellij-ce-playground    文件:JavaAwareProjectJdkTableImpl.java   
public Sdk getInternalJdk() {
  if (myInternalJdk == null) {
    final String jdkHome = SystemProperties.getJavaHome();
    final String versionName = ProjectBundle.message("sdk.java.name.template", SystemProperties.getJavaVersion());
    myInternalJdk = myJavaSdk.createJdk(versionName, jdkHome);
  }
  return myInternalJdk;
}
项目:intellij-ce-playground    文件:CommonContentEntriesEditor.java   
public AddContentEntryAction() {
  super(ProjectBundle.message("module.paths.add.content.action"),
        ProjectBundle.message("module.paths.add.content.action.description"), AllIcons.Modules.AddContentEntry);
  myDescriptor = new FileChooserDescriptor(false, true, true, false, true, true) {
    @Override
    public void validateSelectedFiles(VirtualFile[] files) throws Exception {
      validateContentEntriesCandidates(files);
    }
  };
  myDescriptor.putUserData(LangDataKeys.MODULE_CONTEXT, getModule());
  myDescriptor.setTitle(ProjectBundle.message("module.paths.add.content.title"));
  myDescriptor.setDescription(ProjectBundle.message("module.paths.add.content.prompt"));
  myDescriptor.putUserData(FileChooserKeys.DELETE_ACTION_AVAILABLE, false);
}
项目:intellij-ce-playground    文件:DefineMacrosDialog.java   
public String getColumnName(int column) {
  switch(column) {
    case MACRO_NAME : return ProjectBundle.message("project.macros.name.column");
    case MACRO_VALUE : return ProjectBundle.message("project.macros.path.column");
  }
  return "";
}
项目:intellij-ce-playground    文件:ProjectJdksEditor.java   
@Override
protected void doOKAction(){
  try{
    myProjectJdk = myConfigurable.getSelectedJdk(); //before dispose
    myConfigurable.apply();
    super.doOKAction();
  }
  catch (ConfigurationException e){
    Messages.showMessageDialog(getContentPane(), e.getMessage(),
                               ProjectBundle.message("sdk.configure.save.settings.error"), Messages.getErrorIcon());
  }
}
项目:intellij-ce-playground    文件:SdkEditor.java   
@Override
public void apply() throws ConfigurationException{
  if(!Comparing.equal(myInitialName, mySdk == null ? "" : mySdk.getName())){
    if(mySdk == null || mySdk.getName().isEmpty()){
      throw new ConfigurationException(ProjectBundle.message("sdk.list.name.required.error"));
    }
  }
  if (mySdk != null){
    myInitialName = mySdk.getName();
    myInitialPath = mySdk.getHomePath();
    final SdkModificator sdkModificator = mySdk.getSdkModificator();
    sdkModificator.setHomePath(getHomeValue().replace(File.separatorChar, '/'));
    for (SdkPathEditor pathEditor : myPathEditors.values()) {
      pathEditor.apply(sdkModificator);
    }
    ApplicationManager.getApplication().runWriteAction(new Runnable() { // fix SCR #29193
      @Override
      public void run() {
        sdkModificator.commitChanges();
      }
    });
    final AdditionalDataConfigurable configurable = getAdditionalDataConfigurable();
    if (configurable != null) {
      configurable.apply();
    }
  }
}
项目:intellij-ce-playground    文件:SdkEditor.java   
private void doSetHomePath(final String homePath, final SdkType sdkType) {
  if (homePath == null){
    return;
  }
  setHomePathValue(homePath.replace('/', File.separatorChar));

  final String newSdkName = suggestSdkName(homePath);
  ((ProjectJdkImpl)mySdk).setName(newSdkName);

  try {
    final Sdk dummySdk = (Sdk)mySdk.clone();
    SdkModificator sdkModificator = dummySdk.getSdkModificator();
    sdkModificator.setHomePath(homePath);
    sdkModificator.removeAllRoots();
    sdkModificator.commitChanges();

    sdkType.setupSdkPaths(dummySdk, mySdkModel);

    clearAllPaths();
    myVersionString = dummySdk.getVersionString();
    if (myVersionString == null) {
      Messages.showMessageDialog(ProjectBundle.message("sdk.java.corrupt.error", homePath),
                               ProjectBundle.message("sdk.java.corrupt.title"), Messages.getErrorIcon());
    }
    sdkModificator = dummySdk.getSdkModificator();
    for (OrderRootType type : myPathEditors.keySet()) {
      SdkPathEditor pathEditor = myPathEditors.get(type);
      pathEditor.setAddBaseDir(dummySdk.getHomeDirectory());
      pathEditor.addPaths(sdkModificator.getRoots(type));
    }
    mySdkModel.getMulticaster().sdkHomeSelected(dummySdk, homePath);
  }
  catch (CloneNotSupportedException e) {
    LOG.error(e); // should not happen in normal program
  }
}
项目:intellij-ce-playground    文件:ModuleOutputElementTypeBase.java   
@NotNull
public List<? extends PackagingElement<?>> chooseAndCreate(@NotNull ArtifactEditorContext context, @NotNull Artifact artifact,
                                                                     @NotNull CompositePackagingElement<?> parent) {
  List<Module> suitableModules = getSuitableModules(context);
  List<Module> selected = context.chooseModules(suitableModules, ProjectBundle.message("dialog.title.packaging.choose.module"));

  final List<PackagingElement<?>> elements = new ArrayList<PackagingElement<?>>();
  final ModulePointerManager pointerManager = ModulePointerManager.getInstance(context.getProject());
  for (Module module : selected) {
    elements.add(createElement(context.getProject(), pointerManager.create(module)));
  }
  return elements;
}
项目:intellij-ce-playground    文件:XsltRunConfiguration.java   
private static synchronized Sdk getDefaultSdk() {
    if (ourDefaultSdk == null) {
        final String jdkHome = SystemProperties.getJavaHome();
        final String versionName = ProjectBundle.message("sdk.java.name.template", SystemProperties.getJavaVersion());
        Sdk sdk = ProjectJdkTable.getInstance().createSdk(versionName, new SimpleJavaSdkType());
        SdkModificator modificator = sdk.getSdkModificator();
        modificator.setHomePath(jdkHome);
        modificator.commitChanges();
        ourDefaultSdk = sdk;
    }

    return ourDefaultSdk;
}
项目:intellij-ce-playground    文件:ModuleProjectStructureElement.java   
@Override
public void check(ProjectStructureProblemsHolder problemsHolder) {
  checkModulesNames(problemsHolder);

  final ModuleRootModel rootModel = myContext.getModulesConfigurator().getRootModel(myModule);
  if (rootModel == null) return; //already disposed
  final OrderEntry[] entries = rootModel.getOrderEntries();
  for (OrderEntry entry : entries) {
    if (!entry.isValid()){
      if (entry instanceof JdkOrderEntry && ((JdkOrderEntry)entry).getJdkName() == null) {
        if (!(entry instanceof InheritedJdkOrderEntry)) {
          problemsHolder.registerProblem(ProjectBundle.message("project.roots.module.jdk.problem.message"), null, ProjectStructureProblemType.error("module-sdk-not-defined"), createPlace(entry),
                                         null);
        }
      }
      else {
        problemsHolder.registerProblem(ProjectBundle.message("project.roots.library.problem.message", StringUtil.escapeXml(entry.getPresentableName())), null,
                                       ProjectStructureProblemType.error("invalid-module-dependency"), createPlace(entry),
                                       null);
      }
    }
    //todo[nik] highlight libraries with invalid paths in ClasspathEditor
    //else if (entry instanceof LibraryOrderEntry) {
    //  final LibraryEx library = (LibraryEx)((LibraryOrderEntry)entry).getLibrary();
    //  if (library != null) {
    //    if (!library.allPathsValid(OrderRootType.CLASSES)) {
    //      problemsHolder.registerError(ProjectBundle.message("project.roots.tooltip.library.misconfigured", entry.getName()));
    //    }
    //    else if (!library.allPathsValid(OrderRootType.SOURCES)) {
    //      problemsHolder.registerWarning(ProjectBundle.message("project.roots.tooltip.library.misconfigured", entry.getName()));
    //    }
    //  }
    //}
  }
}
项目:intellij-ce-playground    文件:LibraryProjectStructureElement.java   
private void reportInvalidRoots(ProjectStructureProblemsHolder problemsHolder, LibraryEx library,
                                final OrderRootType type, String rootName, final ProjectStructureProblemType problemType) {
  final List<String> invalidUrls = library.getInvalidRootUrls(type);
  if (!invalidUrls.isEmpty()) {
    final String description = createInvalidRootsDescription(invalidUrls, rootName, library.getName());
    final PlaceInProjectStructure place = createPlace();
    final String message = ProjectBundle.message("project.roots.error.message.invalid.roots", rootName, invalidUrls.size());
    ProjectStructureProblemDescription.ProblemLevel level = library.getTable().getTableLevel().equals(LibraryTablesRegistrar.PROJECT_LEVEL)
                                                            ? ProjectStructureProblemDescription.ProblemLevel.PROJECT : ProjectStructureProblemDescription.ProblemLevel.GLOBAL;
    problemsHolder.registerProblem(new ProjectStructureProblemDescription(message, description, place,
                                                                          problemType, level,
                                                                          Collections.singletonList(new RemoveInvalidRootsQuickFix(library, type, invalidUrls)),
                                                                          true));
  }
}
项目:intellij-ce-playground    文件:JdkComboBox.java   
public void setSetupButton(final JButton setUpButton,
                              @Nullable final Project project,
                              final ProjectSdksModel jdksModel,
                              final JdkComboBoxItem firstItem,
                              @Nullable final Condition<Sdk> additionalSetup,
                              final boolean moduleJdkSetup) {
  setSetupButton(setUpButton, project, jdksModel, firstItem, additionalSetup,
                 ProjectBundle.message("project.roots.set.up.jdk.title", moduleJdkSetup ? 1 : 2));
}
项目:intellij-ce-playground    文件:LibraryTreeStructure.java   
public LibraryTreeStructure(LibraryRootsComponent parentElement, LibraryRootsComponentDescriptor componentDescriptor) {
  myParentEditor = parentElement;
  myComponentDescriptor = componentDescriptor;
  myRootElementDescriptor = new NodeDescriptor(null, null) {
    @Override
    public boolean update() {
      myName = ProjectBundle.message("library.root.node");
      return false;
    }
    @Override
    public Object getElement() {
      return this;
    }
  };
}
项目:intellij-ce-playground    文件:DefaultLibraryRootsComponentDescriptor.java   
@NotNull
@Override
public FileChooserDescriptor createAttachFilesChooserDescriptor(@Nullable String libraryName) {
  final FileChooserDescriptor descriptor = new FileChooserDescriptor(true, true, true, false, true, true).withFileFilter(LIBRARY_ROOT_CONDITION);
  descriptor.setTitle(StringUtil.isEmpty(libraryName) ? ProjectBundle.message("library.attach.files.action")
                                                      : ProjectBundle.message("library.attach.files.to.library.action", libraryName));
  descriptor.setDescription(ProjectBundle.message("library.java.attach.files.description"));
  return descriptor;
}
项目:intellij-ce-playground    文件:LibraryElementType.java   
@NotNull
public List<? extends LibraryPackagingElement> chooseAndCreate(@NotNull ArtifactEditorContext context, @NotNull Artifact artifact,
                                                                @NotNull CompositePackagingElement<?> parent) {
  final List<Library> selected = context.chooseLibraries(ProjectBundle.message("dialog.title.packaging.choose.library"));
  final List<LibraryPackagingElement> elements = new ArrayList<LibraryPackagingElement>();
  for (Library library : selected) {
    elements.add(new LibraryPackagingElement(library.getTable().getTableLevel(), library.getName(), null));
  }
  return elements;
}
项目:intellij-ce-playground    文件:LayoutTree.java   
@Override
public Pair<Image, Point> createDraggedImage(DnDAction action, Point dragOrigin) {
  final List<PackagingElementNode<?>> nodes = getNodesToDrag();
  if (nodes.size() == 1) {
    return DnDAwareTree.getDragImage(this, getPathFor(nodes.get(0)), dragOrigin);
  }
  return DnDAwareTree.getDragImage(this, ProjectBundle.message("drag.n.drop.text.0.packaging.elements", nodes.size()), dragOrigin);
}
项目:intellij-ce-playground    文件:SourceItemsTree.java   
@Override
public Pair<Image, Point> createDraggedImage(DnDAction action, Point dragOrigin) {
  final DefaultMutableTreeNode[] nodes = getSelectedTreeNodes();
  if (nodes.length == 1) {
    return DnDAwareTree.getDragImage(this, TreeUtil.getPathFromRoot(nodes[0]), dragOrigin);
  }
  return DnDAwareTree.getDragImage(this, ProjectBundle.message("drag.n.drop.text.0.packaging.elements", nodes.length), dragOrigin);
}
项目:intellij-ce-playground    文件:ArtifactEditorImpl.java   
private ActionGroup createAddNonCompositeElementGroup() {
  DefaultActionGroup group = new DefaultActionGroup(ProjectBundle.message("artifacts.add.copy.action"), true);
  group.getTemplatePresentation().setIcon(IconUtil.getAddIcon());
  for (PackagingElementType<?> type : PackagingElementFactory.getInstance().getNonCompositeElementTypes()) {
    group.add(new AddNewPackagingElementAction(type, this));
  }
  return group;
}
项目:intellij-ce-playground    文件:ProjectJdkConfigurable.java   
@NotNull
@Override
public JComponent createComponent() {
  if (myJdkPanel == null) {
    myJdkPanel = new JPanel(new GridBagLayout());
    myCbProjectJdk = new JdkComboBox(myJdksModel);
    myCbProjectJdk.insertItemAt(new JdkComboBox.NoneJdkComboBoxItem(), 0);
    myCbProjectJdk.addActionListener(new ActionListener() {
      @Override
      public void actionPerformed(ActionEvent e) {
        if (myFreeze) return;
        myJdksModel.setProjectSdk(myCbProjectJdk.getSelectedJdk());
        clearCaches();
      }
    });
    myJdkPanel.add(new JLabel(ProjectBundle.message("module.libraries.target.jdk.project.radio")), new GridBagConstraints(0, 0, 3, 1, 0, 0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(0, 0, 4, 0), 0, 0));
    myJdkPanel.add(myCbProjectJdk, new GridBagConstraints(0, 1, 1, 1, 0, 1.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(0, 4, 0, 0), 0, 0));
    final JButton setUpButton = new JButton(ApplicationBundle.message("button.new"));
    myCbProjectJdk.setSetupButton(setUpButton, myProject, myJdksModel, new JdkComboBox.NoneJdkComboBoxItem(), null, false);
    myJdkPanel.add(setUpButton, new GridBagConstraints(1, 1, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 4, 0, 0), 0, 0));
    final JButton editButton = new JButton(ApplicationBundle.message("button.edit"));
    myCbProjectJdk.setEditButton(editButton, myProject, new Computable<Sdk>() {
      @Override
      @Nullable
      public Sdk compute() {
        return myJdksModel.getProjectSdk();
      }
    });

    myJdkPanel.add(editButton, new GridBagConstraints(GridBagConstraints.RELATIVE, 1, 1, 1, 1.0, 0, GridBagConstraints.NORTHWEST,
                                                          GridBagConstraints.NONE, new Insets(0, 4, 0, 0), 0, 0));
  }
  return myJdkPanel;
}
项目:intellij-ce-playground    文件:JavaResourceRootEditHandlerBase.java   
private ResourceRootPropertiesDialog(@NotNull JComponent parentComponent, @NotNull JavaResourceRootProperties properties) {
  super(parentComponent, true);
  myProperties = properties;
  setTitle(ProjectBundle.message("module.paths.edit.properties.title"));
  myRelativeOutputPathField = new JTextField();
  myIsGeneratedCheckBox = new JCheckBox(UIUtil.replaceMnemonicAmpersand("For &generated resources"));
  myMainPanel = FormBuilder.createFormBuilder()
    .addLabeledComponent("Relative output &path:", myRelativeOutputPathField)
    .addComponent(myIsGeneratedCheckBox)
    .getPanel();
  myRelativeOutputPathField.setText(myProperties.getRelativeOutputPath());
  myRelativeOutputPathField.setColumns(25);
  myIsGeneratedCheckBox.setSelected(myProperties.isForGeneratedSources());
  init();
}
项目:intellij-ce-playground    文件:ModulesConfigurator.java   
private boolean doRemoveModules(@NotNull List<ModuleEditor> selectedEditors) {
  if (selectedEditors.isEmpty()) return true;

  String question;
  if (myModuleEditors.size() == selectedEditors.size()) {
    question = ProjectBundle.message("module.remove.last.confirmation", selectedEditors.size());
  }
  else {
    question = ProjectBundle.message("module.remove.confirmation", selectedEditors.get(0).getModule().getName(), selectedEditors.size());
  }
  int result =
    Messages.showYesNoDialog(myProject, question, ProjectBundle.message("module.remove.confirmation.title", selectedEditors.size()), Messages.getQuestionIcon());
  if (result != Messages.YES) {
    return false;
  }
  for (ModuleEditor editor : selectedEditors) {
    myModuleEditors.remove(editor.getModule());

    final Module moduleToRemove = editor.getModule();
    // remove all dependencies on the module which is about to be removed
    List<ModifiableRootModel> modifiableRootModels = new ArrayList<ModifiableRootModel>();
    for (final ModuleEditor moduleEditor : myModuleEditors.values()) {
      final ModifiableRootModel modifiableRootModel = moduleEditor.getModifiableRootModelProxy();
      ContainerUtil.addIfNotNull(modifiableRootModels, modifiableRootModel);
    }

    ModuleDeleteProvider.removeModule(moduleToRemove, null, modifiableRootModels, myModuleModel);
    Disposer.dispose(editor);
  }
  processModuleCountChanged();

  return true;
}
项目:intellij-ce-playground    文件:NewProjectUtil.java   
public static void createNewProject(Project projectToClose, AbstractProjectWizard wizard) {
  final boolean proceed = ProgressManager.getInstance().runProcessWithProgressSynchronously(new Runnable() {
    public void run() {
      ProjectManager.getInstance().getDefaultProject(); //warm up components
    }
  }, ProjectBundle.message("project.new.wizard.progress.title"), true, null);
  if (!proceed) return;
  if (!wizard.showAndGet()) {
    return;
  }

  createFromWizard(wizard, projectToClose);
}
项目:intellij-ce-playground    文件:AddModuleDependencyAction.java   
@Override
protected ClasspathElementChooser<Module> createChooser() {
  final List<Module> chooseItems = getNotAddedModules();
  if (chooseItems.isEmpty()) {
    Messages.showMessageDialog(myClasspathPanel.getComponent(), ProjectBundle.message("message.no.module.dependency.candidates"), getTitle(),
                               Messages.getInformationIcon());
    return null;
  }
  return new ModuleChooser(myClasspathPanel, chooseItems, ProjectBundle.message("classpath.chooser.title.add.module.dependency"),
                           ProjectBundle.message("classpath.chooser.description.add.module.dependency"));
}
项目:intellij-ce-playground    文件:ClasspathPanelImpl.java   
private void initPopupActions() {
  if (myPopupActions == null) {
    int actionIndex = 1;
    final List<AddItemPopupAction<?>> actions = new ArrayList<AddItemPopupAction<?>>();
    final StructureConfigurableContext context = getStructureConfigurableContext();
    actions.add(new AddNewModuleLibraryAction(this, actionIndex++, context));
    actions.add(new AddLibraryDependencyAction(this, actionIndex++, ProjectBundle.message("classpath.add.library.action"), context));
    actions.add(new AddModuleDependencyAction(this, actionIndex, context)
    );

    myPopupActions = actions;
  }
}
项目:intellij-ce-playground    文件:RemoveInvalidElementsDialog.java   
private RemoveInvalidElementsDialog(final String title,
                                    ConfigurationErrorType type,
                                    String invalidElements,
                                    final Project project,
                                    List<ConfigurationErrorDescription> errors) {
  super(project, true);
  setTitle(title);
  myDescriptionLabel.setText(ProjectBundle.message(type.canIgnore() ? "label.text.0.cannot.be.loaded.ignore" : "label.text.0.cannot.be.loaded.remove", invalidElements));
  myContentPanel.setLayout(new VerticalFlowLayout());
  for (ConfigurationErrorDescription error : errors) {
    JCheckBox checkBox = new JCheckBox(error.getElementName() + ".");
    checkBox.setSelected(true);
    myCheckboxes.put(checkBox, error);
    JPanel panel = new JPanel(new GridBagLayout());
    GridBagConstraints constraints = new GridBagConstraints();
    constraints.anchor = GridBagConstraints.NORTHWEST;
    constraints.ipadx = 5;
    panel.add(checkBox, constraints);
    constraints.anchor = GridBagConstraints.NORTHWEST;
    constraints.insets.top = 5;
    panel.add(new JLabel(XmlStringUtil.wrapInHtml(StringUtil.replace(error.getDescription(), "\n", "<br>"))), constraints);
    constraints.weightx = 1;
    panel.add(new JPanel(), constraints);
    myContentPanel.add(panel);
  }
  init();
  setOKButtonText(ProjectBundle.message(type.canIgnore() ? "button.text.ignore.selected" : "button.text.remove.selected"));
  setCancelButtonText(ProjectBundle.message("button.text.keep.all"));
}