Java 类com.intellij.uiDesigner.ImageFileFilter 实例源码

项目:intellij-ce-playground    文件:IconEditor.java   
public IconEditor() {
  myTextField.getTextField().setBorder(null);
  myTextField.addActionListener(new ActionListener() {
    public void actionPerformed(ActionEvent e) {
      final TreeClassChooserFactory factory = TreeClassChooserFactory.getInstance(getModule().getProject());
      PsiFile iconFile = null;
      if (myValue != null) {
        VirtualFile iconVFile = ResourceFileUtil.findResourceFileInScope(myValue.getIconPath(), getModule().getProject(),
                                                                         getModule()
                                                                           .getModuleWithDependenciesAndLibrariesScope(true));
        if (iconVFile != null) {
          iconFile = PsiManager.getInstance(getModule().getProject()).findFile(iconVFile);
        }
      }
      TreeFileChooser fileChooser = factory.createFileChooser(UIDesignerBundle.message("title.choose.icon.file"), iconFile,
                                                              null, new ImageFileFilter(getModule()), false, true);
      fileChooser.showDialog();
      PsiFile file = fileChooser.getSelectedFile();
      if (file != null) {
        String resourceName = FormEditingUtil.buildResourceName(file);
        if (resourceName != null) {
          IconDescriptor descriptor = new IconDescriptor(resourceName);
          IntroIconProperty.loadIconFromFile(file.getVirtualFile(), descriptor);
          myValue = descriptor;
          myTextField.setText(descriptor.getIconPath());
        }
      }
    }
  });
}
项目:tools-idea    文件:IconEditor.java   
public IconEditor() {
  myTextField.getTextField().setBorder(null);
  myTextField.addActionListener(new ActionListener() {
    public void actionPerformed(ActionEvent e) {
      final TreeClassChooserFactory factory = TreeClassChooserFactory.getInstance(getModule().getProject());
      PsiFile iconFile = null;
      if (myValue != null) {
        VirtualFile iconVFile = ResourceFileUtil.findResourceFileInScope(myValue.getIconPath(), getModule().getProject(),
                                                                         getModule()
                                                                           .getModuleWithDependenciesAndLibrariesScope(true));
        if (iconVFile != null) {
          iconFile = PsiManager.getInstance(getModule().getProject()).findFile(iconVFile);
        }
      }
      TreeFileChooser fileChooser = factory.createFileChooser(UIDesignerBundle.message("title.choose.icon.file"), iconFile,
                                                              null, new ImageFileFilter(getModule()), false, true);
      fileChooser.showDialog();
      PsiFile file = fileChooser.getSelectedFile();
      if (file != null) {
        String resourceName = FormEditingUtil.buildResourceName(file);
        if (resourceName != null) {
          IconDescriptor descriptor = new IconDescriptor(resourceName);
          IntroIconProperty.loadIconFromFile(file.getVirtualFile(), descriptor);
          myValue = descriptor;
          myTextField.setText(descriptor.getIconPath());
        }
      }
    }
  });
}
项目:consulo-ui-designer    文件:IconEditor.java   
public IconEditor() {
  myTextField.getTextField().setBorder(null);
  myTextField.addActionListener(new ActionListener() {
    public void actionPerformed(ActionEvent e) {
      final TreeClassChooserFactory factory = TreeClassChooserFactory.getInstance(getModule().getProject());
      PsiFile iconFile = null;
      if (myValue != null) {
        VirtualFile iconVFile = ResourceFileUtil.findResourceFileInScope(myValue.getIconPath(), getModule().getProject(),
                                                                         getModule()
                                                                           .getModuleWithDependenciesAndLibrariesScope(true));
        if (iconVFile != null) {
          iconFile = PsiManager.getInstance(getModule().getProject()).findFile(iconVFile);
        }
      }
      TreeFileChooser fileChooser = factory.createFileChooser(UIDesignerBundle.message("title.choose.icon.file"), iconFile,
                                                              null, new ImageFileFilter(getModule()), false, true);
      fileChooser.showDialog();
      PsiFile file = fileChooser.getSelectedFile();
      if (file != null) {
        String resourceName = FormEditingUtil.buildResourceName(file);
        if (resourceName != null) {
          IconDescriptor descriptor = new IconDescriptor(resourceName);
          IntroIconProperty.loadIconFromFile(file.getVirtualFile(), descriptor);
          myValue = descriptor;
          myTextField.setText(descriptor.getIconPath());
        }
      }
    }
  });
}