当前位置: 首页>>代码示例>>Java>>正文


Java FileChooser类代码示例

本文整理汇总了Java中com.intellij.openapi.fileChooser.FileChooser的典型用法代码示例。如果您正苦于以下问题:Java FileChooser类的具体用法?Java FileChooser怎么用?Java FileChooser使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


FileChooser类属于com.intellij.openapi.fileChooser包,在下文中一共展示了FileChooser类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: unpackCourseArchive

import com.intellij.openapi.fileChooser.FileChooser; //导入依赖的package包/类
private static void unpackCourseArchive(final Project project) {
  FileChooserDescriptor descriptor =
    new FileChooserDescriptor(true, true, true, true, true, false);

  final VirtualFile virtualFile = FileChooser.chooseFile(descriptor, project, null);
  if (virtualFile == null) {
    return;
  }
  final String basePath = project.getBasePath();
  if (basePath == null) return;

  Course course = StudyProjectGenerator.getCourse(virtualFile.getPath());
  if (course == null) {
    Messages.showErrorDialog("This course is incompatible with current version", "Failed to Unpack Course");
    return;
  }
  generateFromStudentCourse(project, course);
}
 
开发者ID:medvector,项目名称:educational-plugin,代码行数:19,代码来源:CCFromCourseArchive.java

示例2: createDirectory

import com.intellij.openapi.fileChooser.FileChooser; //导入依赖的package包/类
public static PsiDirectory createDirectory(Project project, String title, String description) {
    final FileChooserDescriptor descriptor = FileChooserDescriptorFactory.createSingleFolderDescriptor();
    descriptor.setTitle(title);
    descriptor.setShowFileSystemRoots(false);
    descriptor.setDescription(description);
    descriptor.setHideIgnored(true);
    descriptor.setRoots(project.getBaseDir());
    descriptor.setForcedToUseIdeaFileChooser(true);
    VirtualFile file = FileChooser.chooseFile(descriptor, project, project.getBaseDir());
    if(Objects.isNull(file)){
        Messages.showInfoMessage("Cancel " + title, "Error");
        return null;
    }

    PsiDirectory psiDirectory = PsiDirectoryFactory.getInstance(project).createDirectory(file);
    if(PsiDirectoryFactory.getInstance(project).isPackage(psiDirectory)){
        return psiDirectory;
    }else {
        Messages.showInfoMessage("请选择正确的 package 路径。", "Error");
        return createDirectory(project, title, description);
    }
}
 
开发者ID:hykes,项目名称:CodeGen,代码行数:23,代码来源:PsiUtil.java

示例3: selectSdk

import com.intellij.openapi.fileChooser.FileChooser; //导入依赖的package包/类
@Nullable public static MuleSdk selectSdk(@NotNull JComponent parentComponent)
{
    final VirtualFile initial = findFile(System.getenv("MULE_HOME"));

    final FileChooserDescriptor descriptor = new FileChooserDescriptor(false, true, false, false, false, false)
    {
        @Override
        public boolean isFileSelectable(VirtualFile file)
        {
            return super.isFileSelectable(file) && MuleSdk.isValidMuleHome(file.getCanonicalPath());
        }
    };
    descriptor.setTitle("Mule SDK");
    descriptor.setDescription("Choose a directory containing Mule distribution");
    final VirtualFile dir = FileChooser.chooseFile(descriptor, parentComponent, null, initial);
    if (dir == null || !MuleSdk.isValidMuleHome(dir.getCanonicalPath()))
    {
        return null;
    }
    return new MuleSdk(dir.getCanonicalPath());
}
 
开发者ID:machaval,项目名称:mule-intellij-plugins,代码行数:22,代码来源:MuleUIUtils.java

示例4: actionPerformed

import com.intellij.openapi.fileChooser.FileChooser; //导入依赖的package包/类
@Override
public void actionPerformed(AnActionEvent anActionEvent) {
    logger.debug("Loading sample!");

    final Project project = anActionEvent.getProject();
    final PsiFile psiFile = anActionEvent.getData(CommonDataKeys.PSI_FILE);

    VirtualFile sample = FileChooser.chooseFile(FileChooserDescriptorFactory.createSingleFileNoJarsDescriptor(),
            project, null);
    if (sample == null)
        return;

    try {
        final String text = new String(sample.contentsToByteArray(), sample.getCharset());

        new WriteCommandAction.Simple(project, psiFile) {
            @Override
            protected void run() throws Throwable {
                document.setText(text);
            }
        }.execute();
    } catch (Exception e) {
        logger.error(e);
    }

}
 
开发者ID:machaval,项目名称:mule-intellij-plugins,代码行数:27,代码来源:OpenSampleAction.java

示例5: onExportAction

import com.intellij.openapi.fileChooser.FileChooser; //导入依赖的package包/类
@Override
    public void onExportAction(String path) {
        VirtualFile[] files = FileChooser.chooseFiles(FileReaderUtil.getDirectoryDescriptor(), project,
                null);
        //todo remove
//                LocalFileSystem.getInstance().findFileByIoFile(new File("E:" + File.separator + "Downloads")));

        if (files.length <= 0) {
            return;
        }

        PackageTemplate pt = PackageTemplateHelper.getPackageTemplate(path);
        VirtualFile directoryToExport = files[0];

        PackageTemplateHelper.exportPackageTemplate(project, pt, directoryToExport.getPath());
    }
 
开发者ID:CeH9,项目名称:PackageTemplates,代码行数:17,代码来源:SelectPackageTemplatePresenterImpl.java

示例6: specifyADBPath

import com.intellij.openapi.fileChooser.FileChooser; //导入依赖的package包/类
private void specifyADBPath() {
    final String adbPath = Global.instance().adbPath();
    final VirtualFile toSelect;

    if (Utils.isBlank(adbPath)) {
        toSelect = null;
    } else {
        toSelect = LocalFileSystem.getInstance().refreshAndFindFileByPath(adbPath);
    }

    final VirtualFile vFile = FileChooser.chooseFile(
            FileChooserDescriptorFactory.createSingleFileOrFolderDescriptor(), Global.instance().project(), toSelect);

    if (vFile == null || !vFile.exists()) {
        return;
    }

    mPresenter.chooseADBPath(vFile);
}
 
开发者ID:huazhouwang,项目名称:WIFIADB,代码行数:20,代码来源:RootWindow.java

示例7: actionPerformed

import com.intellij.openapi.fileChooser.FileChooser; //导入依赖的package包/类
@Override
public void actionPerformed(AnActionEvent event) {
    final Project project = event.getProject();
    if (project == null) {
        return;
    }

    FileChooserDescriptor chooserDescriptor = new FileChooserDescriptor(true, false, true, false, false, false);
    VirtualFile virtualFile = FileChooser.chooseFile(chooserDescriptor, project, null);
    if (virtualFile != null && virtualFile.isValid() && !virtualFile.isDirectory()) {
        DeltaHexVirtualFile deltaHexVirtualFile = new DeltaHexVirtualFile(virtualFile);
        OpenFileDescriptor descriptor = new OpenFileDescriptor(project, deltaHexVirtualFile, 0);
        FileEditorManager fileEditorManager = FileEditorManager.getInstance(project);
        List<FileEditor> editors = fileEditorManager.openEditor(descriptor, true);
        fileEditorManager.setSelectedEditor(virtualFile, DeltaHexWindowProvider.DELTAHEX_EDITOR_TYPE_ID);
        for (FileEditor fileEditor : editors) {
            if (fileEditor instanceof DeltaHexFileEditor) {
                ((DeltaHexFileEditor) fileEditor).openFile(deltaHexVirtualFile);
            }
        }
    }
}
 
开发者ID:hajdam,项目名称:deltahex-intellij-plugin,代码行数:23,代码来源:FileOpenAsHexAction.java

示例8: createLogFileChooser

import com.intellij.openapi.fileChooser.FileChooser; //导入依赖的package包/类
private void createLogFileChooser() {
  myLogFile = new TextFieldWithHistory();
  JPanel panel = GuiUtils.constructFieldWithBrowseButton(myLogFile, new ActionListener() {
    @Override
    public void actionPerformed(ActionEvent e) {
      FileChooserDescriptor descriptor = FileChooserDescriptorFactory.createSingleFileNoJarsDescriptor();
      FileChooser.chooseFiles(descriptor, myProject, null, new Consumer<List<VirtualFile>>() {
        @Override
        public void consume(List<VirtualFile> files) {
          myLogFile.setText(FileUtil.toSystemDependentName(files.get(files.size() - 1).getPath()));
        }
      });
    }
  });
  myLogFileChooserPanel.setLayout(new BorderLayout());
  myLogFileChooserPanel.add(panel, BorderLayout.CENTER);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:UnscrambleDialog.java

示例9: downloadJar

import com.intellij.openapi.fileChooser.FileChooser; //导入依赖的package包/类
private void downloadJar(String jarUrl, String jarName) {
  final Project project = myModule.getProject();
  final String dirPath = PropertiesComponent.getInstance(project).getValue("findjar.last.used.dir");
  VirtualFile toSelect = dirPath == null ? null : LocalFileSystem.getInstance().findFileByIoFile(new File(dirPath));
  final VirtualFile file = FileChooser.chooseFile(FileChooserDescriptorFactory.createSingleFolderDescriptor(), project, toSelect);
  if (file != null) {
    PropertiesComponent.getInstance(project).setValue("findjar.last.used.dir", file.getPath());
    final DownloadableFileService downloader = DownloadableFileService.getInstance();
    final DownloadableFileDescription description = downloader.createFileDescription(jarUrl, jarName);
    final List<VirtualFile> jars =
      downloader.createDownloader(Arrays.asList(description), jarName)
                .downloadFilesWithProgress(file.getPath(), project, myEditorComponent);
    if (jars != null && jars.size() == 1) {
      AccessToken token = WriteAction.start();
      try {
        OrderEntryFix.addJarToRoots(jars.get(0).getPresentableUrl(), myModule, myRef);
      }
      finally {
        token.finish();
      }
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:24,代码来源:FindJarFix.java

示例10: createNewLibrary

import com.intellij.openapi.fileChooser.FileChooser; //导入依赖的package包/类
@Override
public NewLibraryConfiguration createNewLibrary(@NotNull JComponent parentComponent, VirtualFile contextDirectory) {
  final FileChooserDescriptor descriptor = new FileChooserDescriptor(false, false, true, false, false, true);
  descriptor.setTitle(IdeBundle.message("new.library.file.chooser.title"));
  descriptor.setDescription(IdeBundle.message("new.library.file.chooser.description"));
  final VirtualFile[] files = FileChooser.chooseFiles(descriptor, parentComponent, null, contextDirectory);
  if (files.length == 0) {
    return null;
  }
  return new NewLibraryConfiguration(myDefaultLibraryName, getDownloadableLibraryType(), new LibraryVersionProperties()) {
    @Override
    public void addRoots(@NotNull LibraryEditor editor) {
      for (VirtualFile file : files) {
        editor.addRoot(file, OrderRootType.CLASSES);
      }
    }
  };
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:19,代码来源:CustomLibraryDescriptionBase.java

示例11: constructFileURLBrowserField

import com.intellij.openapi.fileChooser.FileChooser; //导入依赖的package包/类
public static JPanel constructFileURLBrowserField(final TextFieldWithHistory field, final String objectName) {
  return constructFieldWithBrowseButton(field, new ActionListener() {
    @Override
    public void actionPerformed(ActionEvent e) {
      FileChooserDescriptor descriptor =
        FileChooserDescriptorFactory.createSingleFileNoJarsDescriptor().withTitle("Select " + objectName);
      VirtualFile file = FileChooser.chooseFile(descriptor, field, null, null);
      if (file != null) {
        try {
          field.setText(VfsUtilCore.virtualToIoFile(file).toURI().toURL().toString());
        }
        catch (MalformedURLException e1) {
          field.setText("");
        }
      }
    }
  });
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:19,代码来源:GuiUtils.java

示例12: actionPerformed

import com.intellij.openapi.fileChooser.FileChooser; //导入依赖的package包/类
public void actionPerformed(AnActionEvent e) {
  String selectedText = myTextField.getSelectedText();
  VirtualFile virtualFile;
  if (selectedText != null ) {
    virtualFile = LocalFileSystem.getInstance().findFileByPath(selectedText.replace(File.separatorChar, '/'));
  }
  else {
    virtualFile = null;
  }
  //TODO use from openapi
  //FeatureUsageTracker.getInstance().triggerFeatureUsed("ui.commandLine.insertPath");
  VirtualFile[] files = FileChooser.chooseFiles(myDescriptor, myTextField, getEventProject(e), virtualFile);
  if (files.length != 0) {
    myTextField.replaceSelection(files[0].getPresentableUrl());
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:17,代码来源:InsertPathAction.java

示例13: createActionListener

import com.intellij.openapi.fileChooser.FileChooser; //导入依赖的package包/类
protected ActionListener createActionListener(final JTable table) {
  return new ActionListener() {
    @Override
    public void actionPerformed(ActionEvent e) {
      String initial = (String)getCellEditorValue();
      VirtualFile initialFile = StringUtil.isNotEmpty(initial) ? LocalFileSystem.getInstance().findFileByPath(initial) : null;
      FileChooser.chooseFile(getFileChooserDescriptor(), myProject, table, initialFile, new Consumer<VirtualFile>() {
        @Override
        public void consume(VirtualFile file) {
          String path = file.getPresentableUrl();
          if (SystemInfo.isWindows && path.length() == 2 && Character.isLetter(path.charAt(0)) && path.charAt(1) == ':') {
            path += "\\"; // make path absolute
          }
          myComponent.getChildComponent().setText(path);
        }
      });
    }
  };
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:20,代码来源:LocalPathCellEditor.java

示例14: actionPerformed

import com.intellij.openapi.fileChooser.FileChooser; //导入依赖的package包/类
@Override
public void actionPerformed(@NotNull AnActionEvent e) {
  final Project project = e.getProject();
  final boolean showFiles = project != null || PlatformProjectOpenProcessor.getInstanceIfItExists() != null;
  final FileChooserDescriptor descriptor = showFiles ? new ProjectOrFileChooserDescriptor() : new ProjectOnlyFileChooserDescriptor();
  descriptor.putUserData(PathChooserDialog.PREFER_LAST_OVER_EXPLICIT, showFiles);

  FileChooser.chooseFiles(descriptor, project, VfsUtil.getUserHomeDir(), new Consumer<List<VirtualFile>>() {
    @Override
    public void consume(final List<VirtualFile> files) {
      for (VirtualFile file : files) {
        if (!descriptor.isFileSelectable(file)) {
          String message = IdeBundle.message("error.dir.contains.no.project", file.getPresentableUrl());
          Messages.showInfoMessage(project, message, IdeBundle.message("title.cannot.open.project"));
          return;
        }
      }
      doOpenFile(project, files);
    }
  });
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:22,代码来源:OpenFileAction.java

示例15: run

import com.intellij.openapi.fileChooser.FileChooser; //导入依赖的package包/类
public void run() {
  final FileChooserDescriptor descriptor = FileChooserDescriptorFactory.createSingleFolderDescriptor();
  VirtualFile selectedFile = FileChooser.chooseFile(descriptor, myProject, null);
  if (selectedFile == null) {
    return;
  }

  final List<AbstractFilePatchInProgress.PatchChange> selectedChanges = myChangesTreeList.getSelectedChanges();
  if (selectedChanges.size() >= 1) {
    for (AbstractFilePatchInProgress.PatchChange patchChange : selectedChanges) {
      final AbstractFilePatchInProgress patch = patchChange.getPatchInProgress();
      patch.setNewBase(selectedFile);
    }
    updateTree(false);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:17,代码来源:ApplyPatchDifferentiatedDialog.java


注:本文中的com.intellij.openapi.fileChooser.FileChooser类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。