當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。