Java 类com.intellij.ui.ComboboxWithBrowseButton 实例源码

项目:intellij    文件:BlazeCreateResourceUtils.java   
static PsiDirectory getResDirFromUI(Project project, ComboboxWithBrowseButton directoryCombo) {
  PsiManager psiManager = PsiManager.getInstance(project);
  Object selectedItem = directoryCombo.getComboBox().getEditor().getItem();
  File selectedFile = null;
  if (selectedItem instanceof File) {
    selectedFile = (File) selectedItem;
  } else if (selectedItem instanceof String) {
    String selectedDir = (String) selectedItem;
    if (!selectedDir.equals(PLACEHOLDER_TEXT)) {
      selectedFile = new File(selectedDir);
    }
  }
  if (selectedFile == null) {
    return null;
  }
  final File finalSelectedFile = selectedFile;
  return ApplicationManager.getApplication()
      .runWriteAction(
          new Computable<PsiDirectory>() {
            @Override
            public PsiDirectory compute() {
              return DirectoryUtil.mkdirs(psiManager, finalSelectedFile.getPath());
            }
          });
}
项目:educational-plugin    文件:EduIntellijCourseProjectGeneratorBase.java   
@Nullable
@Override
public LabeledComponent<JComponent> getLanguageSettingsComponent(@NotNull Course selectedCourse) {
  myModel = ProjectStructureConfigurable.getInstance(ProjectManager.getInstance().getDefaultProject()).getProjectJdksModel();
  myJdkComboBox = new JdkComboBox(myModel, sdkTypeId -> sdkTypeId instanceof JavaSdkType && !((JavaSdkType)sdkTypeId).isDependent(), sdk -> true, sdkTypeId -> sdkTypeId instanceof JavaSdkType && !((JavaSdkType)sdkTypeId).isDependent(), true);
  ComboboxWithBrowseButton comboboxWithBrowseButton = new ComboboxWithBrowseButton(myJdkComboBox);
  FixedSizeButton setupButton = comboboxWithBrowseButton.getButton();
  myJdkComboBox.setSetupButton(setupButton, null, myModel, (JdkComboBox.JdkComboBoxItem) myJdkComboBox.getModel().getSelectedItem(), null, false);
  return LabeledComponent.create(comboboxWithBrowseButton, "Jdk", BorderLayout.WEST);
}
项目:intellij-ce-playground    文件:AppEngineSdkEditor.java   
public AppEngineSdkEditor(final @Nullable Project project) {
  myPathEditor = new ComboboxWithBrowseButton(new ComboBox(100));
  myPathEditor.addBrowseFolderListener(project, new ComponentWithBrowseButton.BrowseFolderActionListener<JComboBox>("Google App Engine SDK",
                                   "Specify Google App Engine Java SDK home",
                                   myPathEditor, project,
                                   FileChooserDescriptorFactory.createSingleFolderDescriptor(),
                                   TextComponentAccessor.STRING_COMBOBOX_WHOLE_TEXT));
  final JComboBox comboBox = myPathEditor.getComboBox();
  comboBox.setEditable(true);
  comboBox.removeAllItems();
  for (AppEngineSdk sdk : AppEngineSdkManager.getInstance().getValidSdks()) {
    comboBox.addItem(FileUtil.toSystemDependentName(sdk.getSdkHomePath()));
  }
}
项目:intellij-ce-playground    文件:RunWithAntBinding.java   
RunWithAntBinding(JRadioButton useDefaultAnt, JRadioButton useCustomAnt, ComboboxWithBrowseButton ants, final GlobalAntConfiguration antConfiguration) {
  myAntConfiguration = antConfiguration;
  myComponents.add(useDefaultAnt);
  myUseCustomAnt = useCustomAnt;
  myComponents.add(myUseCustomAnt);
  myAnts = ants;
  myUseDefaultAnt = useDefaultAnt;
  ButtonGroup group = new ButtonGroup();
  group.add(useDefaultAnt);
  group.add(myUseCustomAnt);

  myUseCustomAnt.addItemListener(new ItemListener() {
    public void itemStateChanged(ItemEvent e) {
      updateEnableCombobox();
      if (myUseCustomAnt.isSelected() && !myLoadingValues)
        myAnts.getComboBox().requestFocusInWindow();
    }
  });

  myAntsController = new ChooseAndEditComboBoxController<AntReference, AntReference>(myAnts, new ConvertingIterator.IdConvertor<AntReference>(), AntReference.COMPARATOR) {
    public Iterator<AntReference> getAllListItems() {
      return antConfiguration.getConfiguredAnts().keySet().iterator();
    }

    public AntReference openConfigureDialog(AntReference reference, JComponent parent) {
      AntSetPanel antSetPanel = new AntSetPanel();
      AntInstallation installation = myAntConfiguration.getConfiguredAnts().get(reference);
      if (installation == null) installation = myAntConfiguration.getConfiguredAnts().get(AntReference.BUNDLED_ANT);
      antSetPanel.reset();
      antSetPanel.setSelection(installation);
      AntInstallation antInstallation = antSetPanel.showDialog(parent);
      return antInstallation != null ? antInstallation.getReference() : null;
    }
  };
  myAntsController.setRenderer(new AntUIUtil.AntReferenceRenderer(myAntConfiguration));
}
项目:intellij-ce-playground    文件:ChooseAndEditComboBoxController.java   
public ChooseAndEditComboBoxController(ComboboxWithBrowseButton combobox,
                                       Convertor<Item, Ref> toRef,
                                       Comparator<Ref> comparator) {
  myCombobox = combobox;
  myToString = toRef;
  myCombobox.addActionListener(new ActionListener() {
    public void actionPerformed(ActionEvent e) {
      resetList(openConfigureDialog(myItems.get(getSelectedString()), getCombobox()));
    }
  });
  getCombobox().setModel(new SortedComboBoxModel<Ref>(comparator));
}
项目:tools-idea    文件:BrowserSelector.java   
public BrowserSelector(boolean allowDefaultBrowser) {
  myAllowDefaultBrowser = allowDefaultBrowser;
  myBrowserComboWithBrowse = new ComboboxWithBrowseButton(new ComboBox());
  myBrowserComboWithBrowse.addActionListener(new ActionListener() {
    public void actionPerformed(ActionEvent e) {
      final ShowSettingsUtil util = ShowSettingsUtil.getInstance();
      util.editConfigurable(myBrowserComboWithBrowse, new BrowserSettings());

      final BrowsersConfiguration.BrowserFamily selectedItem = getSelectedBrowser();
      initBrowsersComboModel();
      if (selectedItem != null) {
        setSelectedBrowser(selectedItem);
      }
    }
  });

  final JComboBox comboBox = myBrowserComboWithBrowse.getComboBox();
  comboBox.setRenderer(new ListCellRendererWrapper<BrowsersConfiguration.BrowserFamily>() {
    @Override
    public void customize(JList list,
                          BrowsersConfiguration.BrowserFamily value,
                          int index,
                          boolean selected,
                          boolean hasFocus) {
      final Icon baseIcon = value != null ? value.getIcon() : PlatformIcons.WEB_ICON;
      final Icon icon = myBrowserComboWithBrowse.isEnabled() ? baseIcon : IconLoader.getDisabledIcon(baseIcon);
      setIcon(icon);
      setText(value != null ? value.getName() : "Default");
    }
  });

  initBrowsersComboModel();
}
项目:tools-idea    文件:AppEngineSdkEditor.java   
public AppEngineSdkEditor(final @Nullable Project project) {
  myPathEditor = new ComboboxWithBrowseButton();
  final ComboboxWithBrowseButton pathEditor = myPathEditor;
  myPathEditor.addBrowseFolderListener(project, new ComponentWithBrowseButton.BrowseFolderActionListener<JComboBox>("Google App Engine SDK",
                                   "Specify Google App Engine Java SDK home",
                                   pathEditor, project,
                                   FileChooserDescriptorFactory.createSingleFolderDescriptor(),
                                   TextComponentAccessor.STRING_COMBOBOX_WHOLE_TEXT));
  final JComboBox comboBox = myPathEditor.getComboBox();
  comboBox.setEditable(true);
  comboBox.removeAllItems();
  for (AppEngineSdk sdk : AppEngineSdkManager.getInstance().getValidSdks()) {
    comboBox.addItem(FileUtil.toSystemDependentName(sdk.getSdkHomePath()));
  }
}
项目:tools-idea    文件:RunWithAntBinding.java   
RunWithAntBinding(JRadioButton useDefaultAnt, JRadioButton useCustomAnt, ComboboxWithBrowseButton ants, final GlobalAntConfiguration antConfiguration) {
  myAntConfiguration = antConfiguration;
  myComponents.add(useDefaultAnt);
  myUseCustomAnt = useCustomAnt;
  myComponents.add(myUseCustomAnt);
  myAnts = ants;
  myUseDefaultAnt = useDefaultAnt;
  ButtonGroup group = new ButtonGroup();
  group.add(useDefaultAnt);
  group.add(myUseCustomAnt);

  myUseCustomAnt.addItemListener(new ItemListener() {
    public void itemStateChanged(ItemEvent e) {
      updateEnableCombobox();
      if (myUseCustomAnt.isSelected() && !myLoadingValues)
        myAnts.getComboBox().requestFocusInWindow();
    }
  });

  myAntsController = new ChooseAndEditComboBoxController<AntReference, AntReference>(myAnts, new ConvertingIterator.IdConvertor<AntReference>(), AntReference.COMPARATOR) {
    public Iterator<AntReference> getAllListItems() {
      return antConfiguration.getConfiguredAnts().keySet().iterator();
    }

    public AntReference openConfigureDialog(AntReference reference, JComponent parent) {
      AntSetPanel antSetPanel = new AntSetPanel();
      AntInstallation installation = myAntConfiguration.getConfiguredAnts().get(reference);
      if (installation == null) installation = myAntConfiguration.getConfiguredAnts().get(AntReference.BUNDLED_ANT);
      antSetPanel.reset();
      antSetPanel.setSelection(installation);
      AntInstallation antInstallation = antSetPanel.showDialog(parent);
      return antInstallation != null ? antInstallation.getReference() : null;
    }
  };
  myAntsController.setRenderer(new AntUIUtil.AntReferenceRenderer(myAntConfiguration));
}
项目:tools-idea    文件:ChooseAndEditComboBoxController.java   
public ChooseAndEditComboBoxController(ComboboxWithBrowseButton combobox,
                                       Convertor<Item, Ref> toRef,
                                       Comparator<Ref> comparator) {
  myCombobox = combobox;
  myToString = toRef;
  myCombobox.addActionListener(new ActionListener() {
    public void actionPerformed(ActionEvent e) {
      resetList(openConfigureDialog(myItems.get(getSelectedString()), getCombobox()));
    }
  });
  getCombobox().setModel(new SortedComboBoxModel<Ref>(comparator));
}
项目:consulo-apache-ant    文件:ChooseAndEditComboBoxController.java   
public ChooseAndEditComboBoxController(ComboboxWithBrowseButton combobox,
                                       Convertor<Item, Ref> toRef,
                                       Comparator<Ref> comparator) {
  myCombobox = combobox;
  myToString = toRef;
  myCombobox.addActionListener(new ActionListener() {
    public void actionPerformed(ActionEvent e) {
      resetList(openConfigureDialog(myItems.get(getSelectedString()), getCombobox()));
    }
  });
  getCombobox().setModel(new SortedComboBoxModel<Ref>(comparator));
}
项目:SmartTomcat    文件:RunnerSetting.java   
public ComboboxWithBrowseButton getTomcatField() {
    return tomcatField;
}
项目:SmartTomcat    文件:TomcatSettingsEditor.java   
@NotNull
@Override
protected JComponent createEditor() {

    ComboboxWithBrowseButton tomcatField = runnerSetting.getTomcatField();
    TextFieldWithBrowseButton docBaseField = runnerSetting.getDocBaseField();
    JTextField contextPathField = runnerSetting.getContextPathField();
    JFormattedTextField portField = runnerSetting.getPortField();
    JXButton configrationButton = runnerSetting.getConfigrationButton();
    configrationButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {


            ShowSettingsUtil.getInstance().showSettingsDialog(project, TomcatSettingConfigurable.class);

        }
    });


    docBaseField.addBrowseFolderListener("webapp", "Choose Web Folder", project, FileChooserDescriptorFactory.createSingleFolderDescriptor().withRoots(project.getBaseDir()));
    docBaseField.getTextField().getDocument().addDocumentListener(new DocumentAdapter() {
        @Override
        protected void textChanged(DocumentEvent documentEvent) {

            if (!documentEvent.getType().equals(DocumentEvent.EventType.REMOVE)) {
                String text = docBaseField.getText();
                if (text != null && !text.trim().equals("")) {
                    VirtualFile fileByIoFile = LocalFileSystem.getInstance().findFileByIoFile(new File(text));
                    Module module = ModuleUtilCore.findModuleForFile(fileByIoFile, project);
                    String contextPath = module == null ? "/" : "/" + module.getName();
                    contextPathField.setText(contextPath);
                }
            }

        }
    });


    portField.setValue(8080);
    DefaultFormatterFactory tf = new DefaultFormatterFactory();
    NumberFormat format = NumberFormat.getInstance();
    format.setGroupingUsed(false);
    NumberFormatter formatter = new NumberFormatter(format);
    formatter.setValueClass(Integer.class);
    formatter.setMinimum(0);
    formatter.setMaximum(65535);
    tf.setDefaultFormatter(formatter);
    portField.setFormatterFactory(tf);

    return runnerSetting.getMainPanel();
}
项目:intellij-ce-playground    文件:BrowserSelector.java   
public BrowserSelector(@NotNull final Condition<WebBrowser> browserCondition) {
  myModel = createBrowsersComboModel(browserCondition);
  myBrowserComboWithBrowse = new ComboboxWithBrowseButton(new ComboBox(myModel));
  myBrowserComboWithBrowse.addActionListener(new ActionListener() {
    @Override
    public void actionPerformed(ActionEvent e) {
      WebBrowserManager browserManager = WebBrowserManager.getInstance();
      long modificationCount = browserManager.getModificationCount();
      ShowSettingsUtil.getInstance().editConfigurable(myBrowserComboWithBrowse, new BrowserSettings());

      WebBrowser selectedItem = getSelected();
      if (modificationCount != browserManager.getModificationCount()) {
        myModel = createBrowsersComboModel(browserCondition);
        //noinspection unchecked
        myBrowserComboWithBrowse.getComboBox().setModel(myModel);
      }
      if (selectedItem != null) {
        setSelected(selectedItem);
      }
    }
  });

  //noinspection unchecked
  myBrowserComboWithBrowse.getComboBox().setRenderer(new ListCellRendererWrapper<WebBrowser>() {
    @Override
    public void customize(JList list,
                          WebBrowser value,
                          int index,
                          boolean selected,
                          boolean hasFocus) {
      Icon baseIcon;
      if (value == null) {
        WebBrowser firstBrowser = WebBrowserManager.getInstance().getFirstActiveBrowser();
        baseIcon = firstBrowser == null ? PlatformIcons.WEB_ICON : firstBrowser.getIcon();
      }
      else {
        baseIcon = value.getIcon();
      }
      setIcon(myBrowserComboWithBrowse.isEnabled() ? baseIcon : IconLoader.getDisabledIcon(baseIcon));
      setText(value != null ? value.getName() : "Default");
    }
  });
}
项目:intellij-ce-playground    文件:RunWithAntBinding.java   
public RunWithAntBinding(JRadioButton useDefaultAnt, JRadioButton useCastomAnt, ComboboxWithBrowseButton ants) {
  this(useDefaultAnt, useCastomAnt, ants, GlobalAntConfiguration.getInstance());
}
项目:tools-idea    文件:RunWithAntBinding.java   
public RunWithAntBinding(JRadioButton useDefaultAnt, JRadioButton useCastomAnt, ComboboxWithBrowseButton ants) {
  this(useDefaultAnt, useCastomAnt, ants, GlobalAntConfiguration.getInstance());
}
项目:consulo-apache-ant    文件:RunWithAntBinding.java   
public RunWithAntBinding(JRadioButton useDefaultAnt, JRadioButton useCastomAnt, ComboboxWithBrowseButton ants)
{
    this(useDefaultAnt, useCastomAnt, ants, GlobalAntConfiguration.getInstance());
}
项目:consulo-apache-ant    文件:RunWithAntBinding.java   
RunWithAntBinding(JRadioButton useDefaultAnt,
        JRadioButton useCustomAnt,
        ComboboxWithBrowseButton ants,
        final GlobalAntConfiguration antConfiguration)
{
    myAntConfiguration = antConfiguration;
    myComponents.add(useDefaultAnt);
    myUseCustomAnt = useCustomAnt;
    myComponents.add(myUseCustomAnt);
    myAnts = ants;
    myUseDefaultAnt = useDefaultAnt;
    ButtonGroup group = new ButtonGroup();
    group.add(useDefaultAnt);
    group.add(myUseCustomAnt);

    myUseCustomAnt.addItemListener(new ItemListener()
    {
        @Override
        public void itemStateChanged(ItemEvent e)
        {
            updateEnableCombobox();
            if(myUseCustomAnt.isSelected() && !myLoadingValues)
            {
                myAnts.getComboBox().requestFocusInWindow();
            }
        }
    });

    myAntsController = new ChooseAndEditComboBoxController<AntReference, AntReference>(myAnts, new ConvertingIterator.IdConvertor<AntReference>
            (), AntReference.COMPARATOR)
    {
        @Override
        public Iterator<AntReference> getAllListItems()
        {
            return antConfiguration.getConfiguredAnts().keySet().iterator();
        }

        @Override
        public AntReference openConfigureDialog(AntReference reference, JComponent parent)
        {
            Sdk sdk = myAntConfiguration.getConfiguredAnts().get(reference);
            SingleSdkEditor editor = new SingleSdkEditor(sdk, parent);
            editor.show();

            Sdk selectedSdk = editor.getSelectedSdk();
            if(selectedSdk != null)
            {
                if(selectedSdk.isPredefined())
                {
                    return AntReference.BUNDLED_ANT;
                }
                return new AntReference.BindedReference(sdk);
            }
            else
            {
                return AntReference.BUNDLED_ANT;
            }
        }
    };
    myAntsController.setRenderer(new AntUIUtil.AntReferenceRenderer(myAntConfiguration));
}
项目:consulo-xml    文件:BrowserSelector.java   
public BrowserSelector(@NotNull final Condition<WebBrowser> browserCondition)
{
    myModel = createBrowsersComboModel(browserCondition);
    myBrowserComboWithBrowse = new ComboboxWithBrowseButton(new ComboBox(myModel));
    myBrowserComboWithBrowse.addActionListener(new ActionListener()
    {
        @Override
        public void actionPerformed(ActionEvent e)
        {
            WebBrowserManager browserManager = WebBrowserManager.getInstance();
            long modificationCount = browserManager.getModificationCount();
            ShowSettingsUtil.getInstance().editConfigurable(myBrowserComboWithBrowse, new BrowserSettings());

            WebBrowser selectedItem = getSelected();
            if(modificationCount != browserManager.getModificationCount())
            {
                myModel = createBrowsersComboModel(browserCondition);
                //noinspection unchecked
                myBrowserComboWithBrowse.getComboBox().setModel(myModel);
            }
            if(selectedItem != null)
            {
                setSelected(selectedItem);
            }
        }
    });

    //noinspection unchecked
    myBrowserComboWithBrowse.getComboBox().setRenderer(new ListCellRendererWrapper<WebBrowser>()
    {
        @Override
        public void customize(JList list, WebBrowser value, int index, boolean selected, boolean hasFocus)
        {
            Icon baseIcon;
            if(value == null)
            {
                WebBrowser defaultBrowser = WebBrowserManager.getInstance().getDefaultBrowser();
                baseIcon = defaultBrowser == null ? AllIcons.Nodes.PpWeb : defaultBrowser.getIcon();
            }
            else
            {
                baseIcon = value.getIcon();
            }
            setIcon(myBrowserComboWithBrowse.isEnabled() ? baseIcon : IconLoader.getDisabledIcon(baseIcon));
            setText(value != null ? value.getName() : "Default");
        }
    });
}