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

The following examples show how to use com.intellij.openapi.ui.NonEmptyInputValidator. These examples are extracted from open source projects. 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 Project: consulo   Source File: SdkListConfigurable.java    License: Apache License 2.0 6 votes vote down vote up
@RequiredUIAccess
@Override
public void actionPerformed(final AnActionEvent e) {
  final Object o = getSelectedObject();
  if (o instanceof SdkImpl) {
    final SdkImpl selected = (SdkImpl)o;
    String defaultNewName = SdkConfigurationUtil.createUniqueSdkName(selected.getName(), mySdksModel.getSdks());
    final String newName = Messages.showInputDialog("Enter bundle name:", "Copy Bundle", null, defaultNewName, new NonEmptyInputValidator() {
      @Override
      public boolean checkInput(String inputString) {
        return super.checkInput(inputString) && mySdksModel.findSdk(inputString) == null;
      }
    });
    if (newName == null) return;

    SdkImpl sdk = selected.clone();
    sdk.setName(newName);
    sdk.setPredefined(false);

    mySdksModel.doAdd(sdk, sdk1 -> addSdkNode(sdk1, true));
  }
}
 
Example 2
Source Project: consulo   Source File: BaseLibrariesConfigurable.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public void actionPerformed(final AnActionEvent e) {
  final Object o = getSelectedObject();
  if (o instanceof LibraryEx) {
    final LibraryEx selected = (LibraryEx)o;
    final String newName = Messages.showInputDialog("Enter library name:", "Copy Library", null, selected.getName() + "2", new NonEmptyInputValidator());
    if (newName == null) return;

    BaseLibrariesConfigurable configurable = BaseLibrariesConfigurable.this;
    final LibraryEx library = (LibraryEx)myContext.getLibrary(selected.getName(), myLevel);
    LOG.assertTrue(library != null);

    final LibrariesModifiableModel libsModel = configurable.getModelProvider().getModifiableModel();
    final Library lib = libsModel.createLibrary(newName, library.getKind());
    final LibraryEx.ModifiableModelEx model = (LibraryEx.ModifiableModelEx)libsModel.getLibraryEditor(lib).getModel();
    LibraryEditingUtil.copyLibrary(library, Collections.<String, String>emptyMap(), model);
  }
}
 
Example 3
Source Project: consulo   Source File: SdkListConfigurable.java    License: Apache License 2.0 6 votes vote down vote up
@RequiredUIAccess
@Override
public void actionPerformed(final AnActionEvent e) {
  final Object o = getSelectedObject();
  if (o instanceof SdkImpl) {
    final SdkImpl selected = (SdkImpl)o;
    String defaultNewName = SdkConfigurationUtil.createUniqueSdkName(selected.getName(), mySdksModel.getSdks());
    final String newName = Messages.showInputDialog("Enter bundle name:", "Copy Bundle", null, defaultNewName, new NonEmptyInputValidator() {
      @Override
      public boolean checkInput(String inputString) {
        return super.checkInput(inputString) && mySdksModel.findSdk(inputString) == null;
      }
    });
    if (newName == null) return;

    SdkImpl sdk = selected.clone();
    sdk.setName(newName);
    sdk.setPredefined(false);

    mySdksModel.doAdd(sdk, sdk1 -> addSdkNode(sdk1, true));
  }
}
 
Example 4
Source Project: lsp4intellij   Source File: LSPRenameHandler.java    License: Apache License 2.0 5 votes vote down vote up
private void performDialogRename(Editor editor) {
    EditorEventManager manager = EditorEventManagerBase.forEditor(editor);
    if (manager != null) {
        String renameTo = Messages.showInputDialog(
                editor.getProject(), "Enter new name: ", "Rename", Messages.getQuestionIcon(), "",
                new NonEmptyInputValidator());
        if (renameTo != null && !renameTo.equals("")) {
            manager.rename(renameTo);
        }
    }
}
 
Example 5
Source Project: consulo   Source File: PutLabelAction.java    License: Apache License 2.0 5 votes vote down vote up
@Override
protected void showDialog(Project p, IdeaGateway gw, VirtualFile f, AnActionEvent e) {
  String labelName = Messages.showInputDialog(p, message("put.label.name"), message("put.label.dialog.title"),null,
                                              "", new NonEmptyInputValidator());
  if (labelName == null) return;
  LocalHistory.getInstance().putUserLabel(p, labelName);
}