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


Java FileChooser.chooseFile方法代码示例

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


在下文中一共展示了FileChooser.chooseFile方法的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: 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

示例6: actionPerformed

import com.intellij.openapi.fileChooser.FileChooser; //导入方法依赖的package包/类
@Override
public void actionPerformed(AnActionEvent e) {
  if (pathToFile() == null) {
    VirtualFile selectedFile = FileChooser.chooseFile(FILE_DESCRIPTOR, myComponent, getEventProject(e), null);
    if (selectedFile != null) {
      myState.currentScript = selectedFile.getPresentableUrl();
      myCurrentScript.setText(myState.currentScript);
    }
    else {
      Messages.showErrorDialog("File to save is not selected.", "Cannot save script");
      return;
    }
  }
  ApplicationManager.getApplication().runWriteAction(new Runnable() {
    @Override
    public void run() {
      save();
    }
  });
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:21,代码来源:PlaybackDebugger.java

示例7: selectConfigurationDirectory

import com.intellij.openapi.fileChooser.FileChooser; //导入方法依赖的package包/类
public static void selectConfigurationDirectory(@NotNull String path,
                                                @NotNull final Consumer<String> dirConsumer,
                                                final Project project,
                                                @Nullable final Component component) {
  FileChooserDescriptor descriptor =  FileChooserDescriptorFactory.createSingleFolderDescriptor()
    .withTitle(SvnBundle.message("dialog.title.select.configuration.directory"))
    .withDescription(SvnBundle.message("dialog.description.select.configuration.directory"))
    .withShowFileSystemRoots(true)
    .withHideIgnored(false)
    .withShowHiddenFiles(true);

  path = "file://" + path.replace(File.separatorChar, '/');
  VirtualFile root = VirtualFileManager.getInstance().findFileByUrl(path);

  VirtualFile file = FileChooser.chooseFile(descriptor, component, project, root);
  if (file == null) {
    return;
  }
  final String resultPath = file.getPath().replace('/', File.separatorChar);
  dirConsumer.consume(resultPath);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:22,代码来源:SvnConfigurable.java

示例8: actionPerformed

import com.intellij.openapi.fileChooser.FileChooser; //导入方法依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public void actionPerformed(final AnActionEvent e) {
    final Project project = e.getRequiredData(CommonDataKeys.PROJECT);

    final FileChooserDescriptor chooserDescriptor = FileChooserDescriptorFactory
            .createSingleFolderDescriptor();
    @Nullable final VirtualFile folder = FileChooser.chooseFile(chooserDescriptor, project, null);
    if (folder == null)
        return;

    try {
        final Iterable<ILanguageDiscoveryRequest> requests = this.languageManager.requestFromFolder(folder);
        addRequests(requests);
    } catch (final IOException ex) {
        throw LoggerUtils2.exception(this.logger, UnhandledException.class,
                "Unhandled exception while requesting languages from folder: {}", ex, folder);
    }
}
 
开发者ID:metaborg,项目名称:spoofax-intellij,代码行数:22,代码来源:AddLanguageFromDirectoryAction.java

示例9: actionPerformed

import com.intellij.openapi.fileChooser.FileChooser; //导入方法依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public void actionPerformed(final AnActionEvent e) {
    final Project project = e.getRequiredData(CommonDataKeys.PROJECT);

    final FileChooserDescriptor chooserDescriptor = FileChooserDescriptorFactory
            .createSingleFileDescriptor(this.artifactFileType);
    @Nullable final VirtualFile file = FileChooser.chooseFile(chooserDescriptor, project, null);
    if (file == null)
        return;

    try {
        final Iterable<ILanguageDiscoveryRequest> requests = this.languageManager.requestFromArtifact(file);
        addRequests(requests);
    } catch (final IOException ex) {
        throw LoggerUtils2.exception(this.logger, UnhandledException.class,
                "Unhandled exception while requesting languages from artifact: {}", ex, file);
    }
}
 
开发者ID:metaborg,项目名称:spoofax-intellij,代码行数:22,代码来源:AddLanguageFromArtifactAction.java

示例10: actionPerformed

import com.intellij.openapi.fileChooser.FileChooser; //导入方法依赖的package包/类
@Override
public void actionPerformed(ActionEvent e) {
    FileChooserDescriptor fileChooserDescriptor = this.myFileChooserDescriptor;
    if (this.title != null) {
        fileChooserDescriptor = (FileChooserDescriptor) this.myFileChooserDescriptor.clone();
        fileChooserDescriptor.setTitle(this.title);
    }

    FileChooser.chooseFile(fileChooserDescriptor, this.getProject(), this.getInitialFile(), new Consumer<VirtualFile>() {
        @SuppressWarnings("deprecation")
        @Override
        public void consume(VirtualFile file) {
            SettingsHelper.saveLastImageFolder(project, file.getCanonicalPath());
            onFileChoosen(file);
        }
    });
}
 
开发者ID:sayedyousef,项目名称:plgin,代码行数:18,代码来源:ImageFileBrowserFolderActionListener.java

示例11: showSVGChooser

import com.intellij.openapi.fileChooser.FileChooser; //导入方法依赖的package包/类
private void showSVGChooser() {
    FileChooserDescriptor descriptor = FileChooserDescriptorFactory.createSingleFolderDescriptor();
    if (!batch.isSelected()) {
        descriptor = FileChooserDescriptorFactory.createSingleFileDescriptor("svg");
    }
    VirtualFile virtualFile = FileChooser.chooseFile(descriptor, project, null);
    if (virtualFile != null) {
        if (!virtualFile.isDirectory() && virtualFile.getName().toLowerCase().endsWith("svg")) {
            svg = (XmlFile) PsiManager.getInstance(project).findFile(virtualFile);
            //got *.svg file as xml
            svgPath.setText(virtualFile.getPath());
            xmlName.setEditable(true);
            xmlName.setEnabled(true);
            xmlName.setText(CommonUtil.getValidName(svg.getName().split("\\.")[0]) + ".xml");
        } else if (virtualFile.isDirectory()) {
            svgDir = PsiManager.getInstance(project).findDirectory(virtualFile);
            svgPath.setText(virtualFile.getPath());
            xmlName.setEditable(false);
            xmlName.setEnabled(false);
            xmlName.setText("keep origin name");
        }
    }
    frame.setAlwaysOnTop(true);
}
 
开发者ID:misakuo,项目名称:svgtoandroid,代码行数:25,代码来源:GUI.java

示例12: 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 VirtualFile[] jars = downloader.createDownloader(Arrays.asList(description), project, myEditorComponent, jarName)
      .toDirectory(file.getPath()).download();
    if (jars != null && jars.length == 1) {
      AccessToken token = WriteAction.start();
      try {
        OrderEntryFix.addJarToRoots(jars[0].getPresentableUrl(), myModule, myRef);
      }
      finally {
        token.finish();
      }
    }
  }
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:23,代码来源:FindJarFix.java

示例13: getTableCellEditorComponent

import com.intellij.openapi.fileChooser.FileChooser; //导入方法依赖的package包/类
public Component getTableCellEditorComponent(final JTable table, Object value, boolean isSelected, final int row, int column) {
  ActionListener listener = new ActionListener() {
    public void actionPerformed(ActionEvent e) {
      final FileChooserDescriptor d = getFileChooserDescriptor();
      String initial = (String)getCellEditorValue();
      VirtualFile initialFile = StringUtil.isNotEmpty(initial) ? LocalFileSystem.getInstance().findFileByPath(initial) : null;
      VirtualFile file = FileChooser.chooseFile(d, table, myProject, initialFile);
      if (file != null) {
        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);
      }
    }
  };
  myComponent = new CellEditorComponentWithBrowseButton<JTextField>(new TextFieldWithBrowseButton(listener), this);
  myComponent.getChildComponent().setText((String)value);
  return myComponent;
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:21,代码来源:LocalPathCellEditor.java

示例14: 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<FilePatchInProgress.PatchChange> selectedChanges = myChangesTreeList.getSelectedChanges();
  if (selectedChanges.size() >= 1) {
    for (FilePatchInProgress.PatchChange patchChange : selectedChanges) {
      final FilePatchInProgress patch = patchChange.getPatchInProgress();
      patch.setNewBase(selectedFile);
    }
    updateTree(false);
  }
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:17,代码来源:ApplyPatchDifferentiatedDialog.java

示例15: selectFile

import com.intellij.openapi.fileChooser.FileChooser; //导入方法依赖的package包/类
@Nullable
private File selectFile(String title, String description) {
  FileChooserDescriptor fcd = FileChooserDescriptorFactory.createSingleFolderDescriptor();
  fcd.setShowFileSystemRoots(true);
  fcd.setTitle(title);
  fcd.setDescription(description);
  fcd.setHideIgnored(false);
  VirtualFile file = FileChooser.chooseFile(fcd, myProject, null);
  if (file == null) {
    return null;
  }
  final String path = file.getPath();
  if (path.endsWith(":")) {   // workaround for VFS oddities with drive root (IDEADEV-20870)
    return new File(path + "/");
  }
  return new File(path);
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:18,代码来源:RepositoryBrowserDialog.java


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