Java Code Examples for com.intellij.ide.util.DirectoryChooserUtil#getOrChooseDirectory()

The following examples show how to use com.intellij.ide.util.DirectoryChooserUtil#getOrChooseDirectory() . 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: NewBlazePackageAction.java    From intellij with Apache License 2.0 5 votes vote down vote up
@Override
protected void actionPerformedInBlazeProject(Project project, AnActionEvent event) {
  IdeView view = event.getData(LangDataKeys.IDE_VIEW);
  if (view == null) {
    return;
  }
  PsiDirectory directory = DirectoryChooserUtil.getOrChooseDirectory(view);
  if (directory == null) {
    return;
  }
  CreateDirectoryOrPackageHandler validator =
      new CreateDirectoryOrPackageHandler(project, directory, false, ".") {
        @Override
        protected void createDirectories(String subDirName) {
          super.createDirectories(subDirName);
          PsiFileSystemItem element = getCreatedElement();
          if (element instanceof PsiDirectory) {
            createBuildFile(project, (PsiDirectory) element);
          }
        }
      };
  Messages.showInputDialog(
      project,
      "Enter new package name:",
      String.format("New %s Package", Blaze.buildSystemName(project)),
      Messages.getQuestionIcon(),
      "",
      validator);
  PsiDirectory newDir = (PsiDirectory) validator.getCreatedElement();
  if (newDir != null) {
    PsiFile buildFile = findBuildFile(project, newDir);
    if (buildFile != null) {
      view.selectElement(buildFile);
      OpenFileAction.openFile(buildFile.getViewProvider().getVirtualFile(), project);
    }
  }
}
 
Example 2
Source File: CreateDirectoryOrPackageAction.java    From consulo with Apache License 2.0 5 votes vote down vote up
@RequiredUIAccess
@Override
public void actionPerformed(@Nonnull AnActionEvent e) {
  IdeView view = e.getData(LangDataKeys.IDE_VIEW);
  Project project = e.getData(CommonDataKeys.PROJECT);

  if (view == null || project == null) {
    return;
  }

  PsiDirectory directory = DirectoryChooserUtil.getOrChooseDirectory(view);

  if (directory == null) {
    return;
  }

  Trinity<ContentFolderTypeProvider, PsiDirectory, ChildType> info = getInfo(directory);

  boolean isDirectory = info.getThird() == ChildType.Directory;

  CreateDirectoryOrPackageHandler validator = new CreateDirectoryOrPackageHandler(project, directory, isDirectory, info.getThird().getSeparator());

  String title = isDirectory ? IdeBundle.message("title.new.directory") : IdeBundle.message("title.new.package");

  createLightWeightPopup(validator, title, element -> {
    if (element != null) {
      view.selectElement(element);
    }
  }).showCenteredInCurrentWindow(project);
}
 
Example 3
Source File: BxNewSectionAction.java    From bxfs with MIT License 4 votes vote down vote up
@Override
public void actionPerformed(@NotNull AnActionEvent event) {
	IdeView view
		= event.getData(LangDataKeys.IDE_VIEW);

	if (view != null) {
		Project project
			= event.getProject();

		if (project != null) {
			PsiDirectory directory
				= DirectoryChooserUtil.getOrChooseDirectory(view);

			if (directory != null) {
				CreateDirectoryOrPackageHandler validator
					= new CreateDirectoryOrPackageHandler(project, directory, true, "\\/");

				// Сообщение не нужно, так как заголовок окна и так близко. Они резонируют.
				Messages.showInputDialog(project, null, "Битрикс: Создание Нового Раздела", BitrixFramework.bxIcon, "", validator);

				PsiElement result = validator.getCreatedElement();
				if (result instanceof PsiDirectory) {
					PsiDirectory createdDir = (PsiDirectory) result;

					FileTemplateManager templateManager
						= FileTemplateManager.getInstance(project);

					FileTemplate cfgTemplate = templateManager.findInternalTemplate("Битрикс - Раздел (настройки)");
					FileTemplate idxTemplate = templateManager.findInternalTemplate("Битрикс - Раздел (титульная)");

					Properties properties
						= FileTemplateManager.getInstance(project).getDefaultProperties();

					try {
						PsiElement cfgFile = FileTemplateUtil.createFromTemplate(cfgTemplate, ".section", properties, createdDir);
						PsiElement idxFile = FileTemplateUtil.createFromTemplate(idxTemplate, "index", properties, createdDir);

						view.selectElement(idxFile);
					}
					catch (Exception e) {
						e.printStackTrace();
					}
				}
			}
		}
	}
}
 
Example 4
Source File: GaugeDataContext.java    From Intellij-Plugin with Apache License 2.0 4 votes vote down vote up
@Nullable
@Override
public PsiDirectory getOrChooseDirectory() {
    return DirectoryChooserUtil.getOrChooseDirectory(this);
}
 
Example 5
Source File: CommanderPanel.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Override
public PsiDirectory getOrChooseDirectory() {
  return DirectoryChooserUtil.getOrChooseDirectory(this);
}
 
Example 6
Source File: FavoritesTreeViewPanel.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Override
public PsiDirectory getOrChooseDirectory() {
  return DirectoryChooserUtil.getOrChooseDirectory(this);
}
 
Example 7
Source File: CreateFromTemplateActionBase.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Nullable
protected PsiDirectory getTargetDirectory(DataContext dataContext, IdeView view) {
  return DirectoryChooserUtil.getOrChooseDirectory(view);
}
 
Example 8
Source File: NavBarIdeView.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Override
public PsiDirectory getOrChooseDirectory() {
  return DirectoryChooserUtil.getOrChooseDirectory(this);
}
 
Example 9
Source File: ProjectViewImpl.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Override
public PsiDirectory getOrChooseDirectory() {
  return DirectoryChooserUtil.getOrChooseDirectory(this);
}
 
Example 10
Source File: ScopeTreeViewPanel.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Override
@Nullable
public PsiDirectory getOrChooseDirectory() {
  return DirectoryChooserUtil.getOrChooseDirectory(this);
}