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