com.intellij.openapi.project.ProjectBundle Java Examples

The following examples show how to use com.intellij.openapi.project.ProjectBundle. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SdkConfigurationUtil.java    From consulo with Apache License 2.0 6 votes vote down vote up
private static FileChooserDescriptor createCompositeDescriptor(final SdkType... sdkTypes) {
  FileChooserDescriptor descriptor0 = sdkTypes[0].getHomeChooserDescriptor();
  FileChooserDescriptor descriptor =
    new FileChooserDescriptor(descriptor0.isChooseFiles(), descriptor0.isChooseFolders(), descriptor0.isChooseJars(),
                              descriptor0.isChooseJarsAsFiles(), descriptor0.isChooseJarContents(), descriptor0.isChooseMultiple()) {

      @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 message = files.length > 0 && files[0].isDirectory()
                         ? ProjectBundle.message("sdk.configure.home.invalid.error", sdkTypes[0].getPresentableName())
                         : ProjectBundle.message("sdk.configure.home.file.invalid.error", sdkTypes[0].getPresentableName());
        throw new Exception(message);
      }
    };
  descriptor.setTitle(descriptor0.getTitle());
  return descriptor;
}
 
Example #2
Source File: ModuleLibraryOrderEntryImpl.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Nonnull
@Override
public String getPresentableName() {
  final String name = myLibrary.getName();
  if (name != null) {
    return name;
  }
  else {
    if (myLibrary instanceof LibraryEx && ((LibraryEx)myLibrary).isDisposed()) {
      return "<unknown>";
    }

    final String[] urls = myLibrary.getUrls(BinariesOrderRootType.getInstance());
    if (urls.length > 0) {
      String url = urls[0];
      return PathUtil.toPresentableUrl(url);
    }
    else {
      return ProjectBundle.message("library.empty.library.item");
    }
  }
}
 
Example #3
Source File: ModuleStructureConfigurable.java    From consulo with Apache License 2.0 6 votes vote down vote up
public void addLibraryOrderEntry(final Module module, final Library library) {
  Component parent = TargetAWT.to(WindowManager.getInstance().suggestParentWindow(module.getProject()));

  final ModuleEditor moduleEditor = myContext.myModulesConfigurator.getModuleEditor(module);
  LOG.assertTrue(moduleEditor != null, "Current module editor was not initialized");
  final ModifiableRootModel modelProxy = moduleEditor.getModifiableRootModelProxy();
  final OrderEntry[] entries = modelProxy.getOrderEntries();
  for (OrderEntry entry : entries) {
    if (entry instanceof LibraryOrderEntry && Comparing.strEqual(entry.getPresentableName(), library.getName())) {
      if (Messages.showYesNoDialog(parent,
                                   ProjectBundle.message("project.roots.replace.library.entry.message", entry.getPresentableName()),
                                   ProjectBundle.message("project.roots.replace.library.entry.title"),
                                   Messages.getInformationIcon()) == Messages.YES) {
        modelProxy.removeOrderEntry(entry);
        break;
      }
    }
  }
  modelProxy.addLibraryEntry(library);
  myContext.getDaemonAnalyzer().queueUpdate(new ModuleProjectStructureElement(myContext, module));
  myTree.repaint();
}
 
Example #4
Source File: ModuleStructureConfigurable.java    From consulo with Apache License 2.0 6 votes vote down vote up
@RequiredUIAccess
@Override
public void update(final AnActionEvent e) {
  super.update(e);
  final Presentation presentation = e.getPresentation();
  String text = ProjectBundle.message("project.roots.plain.mode.action.text.disabled");
  if (myPlainMode){
    text = ProjectBundle.message("project.roots.plain.mode.action.text.enabled");
  }
  presentation.setText(text);
  presentation.setDescription(text);

  if (myContext.myModulesConfigurator != null) {
    presentation.setVisible(myContext.myModulesConfigurator.getModuleModel().hasModuleGroups());
  }
}
 
Example #5
Source File: SdkType.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Nonnull
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;
}
 
Example #6
Source File: ModuleStructureConfigurable.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Override
protected AbstractAddGroup createAddAction() {
  return new AbstractAddGroup(ProjectBundle.message("add.new.header.text")) {
    @Override
    @Nonnull
    public AnAction[] getChildren(@Nullable final AnActionEvent e) {

      ArrayList<AnAction> result = new ArrayList<AnAction>();

      AnAction addModuleAction = new AddModuleAction(false);
      addModuleAction.getTemplatePresentation().setText("New Module");
      result.add(addModuleAction);

      AnAction importModuleAction = new AddModuleAction(true);
      importModuleAction.getTemplatePresentation().setText("Import Module");
      importModuleAction.getTemplatePresentation().setIcon(AllIcons.ToolbarDecorator.Import);
      result.add(importModuleAction);

      return result.toArray(new AnAction[result.size()]);
    }
  };
}
 
Example #7
Source File: SdkListConfigurable.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Override
public AbstractAddGroup createAddAction() {
  return new AbstractAddGroup(ProjectBundle.message("add.action.name")) {
    @Nonnull
    @Override
    public AnAction[] getChildren(@Nullable final AnActionEvent e) {
      DefaultActionGroup group = new DefaultActionGroup(ProjectBundle.message("add.action.name"), true);
      mySdksModel.createAddActions(group, myTree, new Consumer<Sdk>() {
        @Override
        public void consume(final Sdk sdk) {
          addSdkNode(sdk, true);
        }
      }, ADD_SDK_FILTER);
      return group.getChildren(null);
    }
  };
}
 
Example #8
Source File: ModuleManagerImpl.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Override
public void renameModule(@Nonnull Module module, @Nonnull String newName) throws ModuleWithNameAlreadyExistsException {
  final Module oldModule = getModuleByNewName(newName);
  myNewNameToModule.remove(myModuleToNewName.get(module));
  if (module.getName().equals(newName)) { // if renaming to itself, forget it altogether
    myModuleToNewName.remove(module);
    myNewNameToModule.remove(newName);
  }
  else {
    myModuleToNewName.put(module, newName);
    myNewNameToModule.put(newName, module);
  }

  if (oldModule != null) {
    throw new ModuleWithNameAlreadyExistsException(ProjectBundle.message("module.already.exists.error", newName), newName);
  }
}
 
Example #9
Source File: ModuleProjectStructureElement.java    From consulo with Apache License 2.0 6 votes vote down vote up
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;
    }
  }
}
 
Example #10
Source File: SingleSdkEditor.java    From consulo with Apache License 2.0 6 votes vote down vote up
public SingleSdkEditor(final Sdk sdk, Component parent, SdksConfigurable configurable) {
  super(parent, true);
  myConfigurable = configurable;
  SwingUtilities.invokeLater(new Runnable(){
    @Override
    public void run() {
      myConfigurable.selectNodeInTree(sdk != null ? sdk.getName() : null);
    }
  });
  setTitle(ProjectBundle.message("sdk.configure.title"));
  Disposer.register(myDisposable, new Disposable() {
    @Override
    public void dispose() {
      if (myConfigurable != null) {
        myConfigurable.disposeUIResources();
        myConfigurable = null;
      }
    }
  });
  init();
}
 
Example #11
Source File: LibraryTreeStructure.java    From consulo with Apache License 2.0 6 votes vote down vote up
public LibraryTreeStructure(LibraryRootsComponent parentElement, LibraryRootsComponentDescriptor componentDescriptor) {
  myParentEditor = parentElement;
  myComponentDescriptor = componentDescriptor;
  myRootElementDescriptor = new NodeDescriptor(null, null) {
    @RequiredUIAccess
    @Override
    public boolean update() {
      myName = ProjectBundle.message("library.root.node");
      return false;
    }
    @Override
    public Object getElement() {
      return this;
    }
  };
}
 
Example #12
Source File: DefaultSdksModel.java    From consulo with Apache License 2.0 6 votes vote down vote up
@RequiredUIAccess
private void setupSdk(Sdk newSdk, Consumer<Sdk> callback) {
  UIAccess uiAccess = UIAccess.current();

  new Task.ConditionalModal(null, "Setuping SDK...", false, PerformInBackgroundOption.DEAF) {
    @Override
    public void run(@Nonnull ProgressIndicator indicator) {
      SdkType sdkType = (SdkType)newSdk.getSdkType();
      sdkType.setupSdkPaths(newSdk);

      uiAccess.give(() -> {
        if (newSdk.getVersionString() == null) {
          String home = newSdk.getHomePath();
          Messages.showMessageDialog(ProjectBundle.message("sdk.java.corrupt.error", home), ProjectBundle.message("sdk.java.corrupt.title"), Messages.getErrorIcon());
        }

        doAdd(newSdk, callback);
      });
    }
  }.queue();
}
 
Example #13
Source File: BaseSdkEditor.java    From consulo with Apache License 2.0 5 votes vote down vote up
private void doSetHomePath(final String homePath, final SdkType sdkType) {
  if (homePath == null) {
    return;
  }
  setHomePathValue(homePath.replace('/', File.separatorChar));

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

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

    sdkType.setupSdkPaths(dummySdk);

    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()) {
      myPathEditors.get(type).addPaths(sdkModificator.getRoots(type));
    }
    mySdkModel.getMulticaster().sdkHomeSelected(dummySdk, homePath);
  }
  catch (CloneNotSupportedException e) {
    BaseSdkEditor.LOGGER.error(e); // should not happen in normal program
  }
}
 
Example #14
Source File: ModuleProjectStructureElement.java    From consulo with Apache License 2.0 5 votes vote down vote up
@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 ModuleExtensionWithSdkOrderEntry && ((ModuleExtensionWithSdkOrderEntry)entry).getSdkName() == null) {
        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()));
    //    }
    //  }
    //}
  }
}
 
Example #15
Source File: SdksConfigurable.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
@Nullable
protected ArrayList<AnAction> createActions(final boolean fromPopup) {
  final ArrayList<AnAction> actions = new ArrayList<AnAction>();
  DefaultActionGroup group = new DefaultActionGroup(ProjectBundle.message("add.action.name"), true);
  group.getTemplatePresentation().setIcon(IconUtil.getAddIcon());
  mySdksModel.createAddActions(group, myTree, projectJdk -> {
    addNode(new MyNode(new SdkConfigurable(((SdkImpl)projectJdk), mySdksModel, TREE_UPDATER, myHistory, myProject), false), myRoot);
    selectNodeInTree(findNodeByObject(myRoot, projectJdk));
  }, SdkListConfigurable.ADD_SDK_FILTER);
  actions.add(new MyActionGroupWrapper(group));
  actions.add(new MyDeleteAction(forAll(Conditions.alwaysTrue())));
  return actions;
}
 
Example #16
Source File: VfsDirectoryBasedStorage.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Nonnull
public static VirtualFile createDir(@Nonnull File ioDir, @Nonnull Object requestor) {
  //noinspection ResultOfMethodCallIgnored
  ioDir.mkdirs();
  String parentFile = ioDir.getParent();
  VirtualFile parentVirtualFile = parentFile == null ? null : LocalFileSystem.getInstance().refreshAndFindFileByPath(parentFile.replace(File.separatorChar, '/'));
  if (parentVirtualFile == null) {
    throw new StateStorageException(ProjectBundle.message("project.configuration.save.file.not.found", parentFile));
  }
  return getFile(ioDir.getName(), parentVirtualFile, requestor);
}
 
Example #17
Source File: DefineMacrosDialog.java    From consulo with Apache License 2.0 5 votes vote down vote up
public DefineMacrosDialog(String[] macroNames) {
  super(true);
  myMacroTable = new String[macroNames.length][2];

  for (int idx = 0; idx < macroNames.length; idx++) {
    final String macroName = macroNames[idx];
    myMacroTable[idx] = new String[]{macroName, ""};
    myIndex.put(macroName, idx);
  }
  setCancelButtonText(ProjectBundle.message("project.macros.cancel.button"));
  init();
}
 
Example #18
Source File: GeneralProjectSettingsElement.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public void check(ProjectStructureProblemsHolder problemsHolder) {
  final Graph<Chunk<ModuleRootModel>> graph = ModuleCompilerUtil.toChunkGraph(myContext.getModulesConfigurator().createGraphGenerator());
  final Collection<Chunk<ModuleRootModel>> chunks = graph.getNodes();
  List<String> cycles = new ArrayList<String>();
  for (Chunk<ModuleRootModel> chunk : chunks) {
    final Set<ModuleRootModel> modules = chunk.getNodes();
    List<String> names = new ArrayList<String>();
    for (ModuleRootModel model : modules) {
      names.add(model.getModule().getName());
    }
    if (modules.size() > 1) {
      cycles.add(StringUtil.join(names, ", "));
    }
  }
  if (!cycles.isEmpty()) {
    final Project project = myContext.getProject();
    final PlaceInProjectStructureBase place = new PlaceInProjectStructureBase(project, ProjectStructureConfigurable.getInstance(project).createModulesPlace(), this);
    final String message;
    final String description;
    if (cycles.size() > 1) {
      message = "Circular dependencies";
      @NonNls final String br = "<br>&nbsp;&nbsp;&nbsp;&nbsp;";
      StringBuilder cyclesString = new StringBuilder();
      for (int i = 0; i < cycles.size(); i++) {
        cyclesString.append(br).append(i + 1).append(". ").append(cycles.get(i));
      }
      description = ProjectBundle.message("module.circular.dependency.warning.description", cyclesString);
    }
    else {
      message = ProjectBundle.message("module.circular.dependency.warning.short", cycles.get(0));
      description = null;
    }
    problemsHolder.registerProblem(new ProjectStructureProblemDescription(message, description, place,
                                                                          ProjectStructureProblemType.warning("module-circular-dependency"),
                                                                          Collections.<ConfigurationErrorQuickFix>emptyList()));
  }
}
 
Example #19
Source File: ModuleOutputElementTypeBase.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
@Nonnull
public List<? extends PackagingElement<?>> chooseAndCreate(@Nonnull ArtifactEditorContext context,
                                                           @Nonnull Artifact artifact,
                                                           @Nonnull 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<?>>();
  for (Module module : selected) {
    elements.add(createElement(context.getProject(), ModuleUtilCore.createPointer(module)));
  }
  return elements;
}
 
Example #20
Source File: DefineMacrosDialog.java    From consulo with Apache License 2.0 5 votes vote down vote up
protected JComponent createCenterPanel() {
  JPanel panel = new JPanel(new BorderLayout());
  Table table = new Table(new MyTableModel());
  JLabel label = new JLabel(ProjectBundle.message("project.macros.prompt"));
  label.setBorder(IdeBorderFactory.createEmptyBorder(6, 6, 6, 6));
  panel.add(label, BorderLayout.NORTH);
  panel.add(ScrollPaneFactory.createScrollPane(table), BorderLayout.CENTER);
  return panel;
}
 
Example #21
Source File: DefineMacrosDialog.java    From consulo with Apache License 2.0 5 votes vote down vote up
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 "";
}
 
Example #22
Source File: ProjectMacrosUtil.java    From consulo with Apache License 2.0 5 votes vote down vote up
public static boolean showMacrosConfigurationDialog(Project project, final Collection<String> undefinedMacros) {
  final String text = ProjectBundle.message("project.load.undefined.path.variables.message");
  final Application application = ApplicationManager.getApplication();
  if (application.isHeadlessEnvironment() || application.isUnitTestMode()) {
    throw new RuntimeException(text + ": " + StringUtil.join(undefinedMacros, ", "));
  }
  final UndefinedMacrosConfigurable configurable =
    new UndefinedMacrosConfigurable(text, undefinedMacros);
  final SingleConfigurableEditor editor = new SingleConfigurableEditor(project, configurable);
  editor.show();
  return editor.isOK();
}
 
Example #23
Source File: ContentRootPanel.java    From consulo with Apache License 2.0 5 votes vote down vote up
private JComponent createFolderChangeOptionsComponent(final ContentFolder folder, @Nonnull ContentFolderTypeProvider editor) {
  return new IconActionComponent(AllIcons.Modules.ContentFolderOptions, AllIcons.Modules.ContentFolderOptions, ProjectBundle.message("module.paths.properties.tooltip"),
                                 new Runnable() {
                                   @Override
                                   public void run() {
                                     myCallback.showChangeOptionsDialog(getContentEntry(), folder);
                                   }
                                 });
}
 
Example #24
Source File: OrderEntryAppearanceServiceImpl.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Nonnull
@Override
public CellAppearanceEx forSdk(@Nullable final Sdk jdk, final boolean isInComboBox, final boolean selected, final boolean showVersion) {
  if (jdk == null) {
    return SimpleTextCellAppearance.invalid(ProjectBundle.message("unknown.sdk"), AllIcons.Toolbar.Unknown);
  }

  String name = jdk.getName();
  CompositeAppearance appearance = new CompositeAppearance();
  SdkType sdkType = (SdkType)jdk.getSdkType();
  appearance.setIcon(SdkUtil.getIcon(jdk));
  SimpleTextAttributes attributes = getTextAttributes(sdkType.sdkHasValidPath(jdk), selected);
  CompositeAppearance.DequeEnd ending = appearance.getEnding();
  ending.addText(name, attributes);

  if (showVersion) {
    String versionString = jdk.getVersionString();
    if (versionString != null && !versionString.equals(name)) {
      SimpleTextAttributes textAttributes = isInComboBox && !selected ? SimpleTextAttributes.SYNTHETIC_ATTRIBUTES :
                                            SystemInfo.isMac && selected ? new SimpleTextAttributes(SimpleTextAttributes.STYLE_PLAIN, 
                                                                                                    Color.WHITE): SimpleTextAttributes.GRAY_ATTRIBUTES;
      ending.addComment(versionString, textAttributes);
    }
  }

  return ending.getAppearance();
}
 
Example #25
Source File: DocumentationOrderRootTypeUIFactory.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
protected void addToolbarButtons(ToolbarDecorator toolbarDecorator) {
  AnActionButton specifyUrlButton = new AnActionButton(ProjectBundle.message("sdk.paths.specify.url.button"), IconUtil.getAddLinkIcon()) {
    @RequiredUIAccess
    @Override
    public void actionPerformed(@Nonnull AnActionEvent e) {
      onSpecifyUrlButtonClicked();
    }
  };
  specifyUrlButton.setShortcut(CustomShortcutSet.fromString("alt S"));
  specifyUrlButton.addCustomUpdater(e -> myEnabled);
  toolbarDecorator.addExtraAction(specifyUrlButton);
}
 
Example #26
Source File: BaseSdkEditor.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public void apply() throws ConfigurationException {
  if (!Comparing.equal(myInitialName, mySdk.getName())) {
    if (mySdk.getName().isEmpty()) {
      throw new ConfigurationException(ProjectBundle.message("sdk.list.name.required.error"));
    }
  }
  myInitialName = mySdk.getName();
  myInitialPath = mySdk.getHomePath();
  final SdkModificator sdkModificator = mySdk.getSdkModificator();
  SdkType sdkType = (SdkType)mySdk.getSdkType();
  // we can change home path only when user can add sdk via interface
  if(sdkType.supportsUserAdd()) {
    sdkModificator.setHomePath(getHomeValue().replace(File.separatorChar, '/'));
  }
  for (SdkPathEditor pathEditor : myPathEditors.values()) {
    pathEditor.apply(sdkModificator);
  }
  ApplicationManager.getApplication().runWriteAction(new Runnable() {
    @Override
    public void run() {
      sdkModificator.commitChanges();
    }
  });
  final AdditionalDataConfigurable configurable = getAdditionalDataConfigurable();
  if (configurable != null) {
    configurable.apply();
  }
}
 
Example #27
Source File: RemoveInvalidElementsDialog.java    From consulo with Apache License 2.0 5 votes vote down vote up
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("<html><body>" + StringUtil.replace(error.getDescription(), "\n", "<br>") + "</body></html>"), 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"));
}
 
Example #28
Source File: OCamlBinaryRootEditHandler.java    From reasonml-idea-plugin with MIT License 5 votes vote down vote up
private ResourceRootPropertiesDialog(@NotNull JComponent parentComponent, @NotNull OCamlBinaryRootProperties 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();
}
 
Example #29
Source File: ModulesConfigurator.java    From consulo with Apache License 2.0 5 votes vote down vote up
private boolean doRemoveModule(@Nonnull ModuleEditor selectedEditor) {

    String question;
    if (myModuleEditors.size() == 1) {
      question = ProjectBundle.message("module.remove.last.confirmation");
    }
    else {
      question = ProjectBundle.message("module.remove.confirmation", selectedEditor.getModule().getName());
    }
    int result = Messages.showYesNoDialog(myProject, question, ProjectBundle.message("module.remove.confirmation.title"), Messages.getQuestionIcon());
    if (result != Messages.YES) {
      return false;
    }
    // do remove
    myModuleEditors.remove(selectedEditor);

    // destroyProcess removed module
    final Module moduleToRemove = selectedEditor.getModule();
    // remove all dependencies on the module that is about to be removed
    List<ModifiableRootModel> modifiableRootModels = new ArrayList<>();
    for (final ModuleEditor moduleEditor : myModuleEditors) {
      final ModifiableRootModel modifiableRootModel = moduleEditor.getModifiableRootModelProxy();
      modifiableRootModels.add(modifiableRootModel);
    }

    // destroyProcess editor
    ModuleDeleteProvider.removeModule(moduleToRemove, null, modifiableRootModels, myModuleModel);
    processModuleCountChanged();
    Disposer.dispose(selectedEditor);

    return true;
  }
 
Example #30
Source File: SdkComboBox.java    From consulo with Apache License 2.0 5 votes vote down vote up
public void setSetupButton(@Nonnull final JButton setUpButton,
                           @Nullable final Project project,
                           @Nonnull final SdkModel sdksModel,
                           @Nullable final SdkComboBoxItem firstItem,
                           @Nullable final Condition<Sdk> additionalSetup) {
  setUpButton.addActionListener(new ActionListener() {
    @Override
    @RequiredUIAccess
    public void actionPerformed(ActionEvent e) {
      DefaultActionGroup group = new DefaultActionGroup();
      ((DefaultSdksModel)sdksModel).createAddActions(group, SdkComboBox.this, new Consumer<Sdk>() {
        @Override
        public void consume(final Sdk sdk) {
          if (project != null) {
            final SdkListConfigurable configurable = SdkListConfigurable.getInstance(project);
            configurable.addSdkNode(sdk, false);
          }
          reloadModel(new SdkComboBoxItem(sdk), project);
          setSelectedSdk(sdk); //restore selection
          if (additionalSetup != null) {
            if (additionalSetup.value(sdk)) { //leave old selection
              setSelectedSdk(firstItem.getSdk());
            }
          }
        }
      }, myCreationFilter);
      final DataContext dataContext = DataManager.getInstance().getDataContext(SdkComboBox.this);
      if (group.getChildrenCount() > 1) {
        JBPopupFactory.getInstance().createActionGroupPopup(ProjectBundle.message("set.up.jdk.title"), group, dataContext,
                                                            JBPopupFactory.ActionSelectionAid.MNEMONICS, false)
                .showUnderneathOf(setUpButton);
      }
      else {
        final AnActionEvent event = new AnActionEvent(null, dataContext, ActionPlaces.UNKNOWN, new Presentation(""),
                                                      ActionManager.getInstance(), 0);
        group.getChildren(event)[0].actionPerformed(event);
      }
    }
  });
}