public void init(
      final Project project,
      final boolean suggestSearchInLibs,
      final boolean prevSearchWholeFiles,
      final String preselect) {
    mySuggestSearchInLibs = suggestSearchInLibs;
    myPrevSearchFiles = prevSearchWholeFiles;
    myProject = project;
    myScopeListener =
        new NamedScopesHolder.ScopeListener() {
          @Override
          public void scopesChanged() {
            final SearchScope selectedScope = getSelectedScope();
            rebuildModel();
            if (selectedScope != null) {
              selectScope(selectedScope.getDisplayName());
            }
          }
        };
    myNamedScopeManager = NamedScopeManager.getInstance(project);
    myNamedScopeManager.addScopeListener(myScopeListener);
    myValidationManager = DependencyValidationManager.getInstance(project);
    myValidationManager.addScopeListener(myScopeListener);
    addActionListener(createScopeChooserListener());

    final JComboBox combo = getComboBox();
    combo.setRenderer(new ScopeDescriptionWithDelimiterRenderer(combo.getRenderer()));

    rebuildModel();

    selectScope(preselect);
  }
 @NotNull
 JComponent createComponent() {
   myRemoteCombobox = new JComboBox();
   myRemoteCombobox.setRenderer(new RemoteCellRenderer(myRemoteCombobox.getRenderer()));
   for (GitRemote remote : myRemotes) {
     myRemoteCombobox.addItem(remote);
   }
   myRemoteCombobox.setToolTipText("Select remote");
   if (myRemotes.size() == 1) {
     myRemoteCombobox.setEnabled(false);
   }
   return myRemoteCombobox;
 }
  public CreateXmlResourceDialog(
      @NotNull Module module,
      @NotNull ResourceType resourceType,
      @Nullable String predefinedName,
      @Nullable String predefinedValue,
      boolean chooseName,
      @Nullable VirtualFile defaultFile) {
    super(module.getProject());
    myResourceType = resourceType;

    if (predefinedName != null && predefinedName.length() > 0) {
      if (!chooseName) {
        myNameLabel.setVisible(false);
        myNameField.setVisible(false);
      }
      myNameField.setText(predefinedName);
    }

    if (predefinedValue != null && predefinedValue.length() > 0) {
      myValueLabel.setVisible(false);
      myValueField.setVisible(false);
      myValueField.setText(predefinedValue);
    }
    final Set<Module> modulesSet = new HashSet<Module>();
    modulesSet.add(module);

    for (AndroidFacet depFacet : AndroidUtils.getAllAndroidDependencies(module, true)) {
      modulesSet.add(depFacet.getModule());
    }

    assert modulesSet.size() > 0;

    if (modulesSet.size() == 1) {
      myModule = module;
      myModuleLabel.setVisible(false);
      myModuleCombo.setVisible(false);
    } else {
      myModule = null;

      final Module[] modules = modulesSet.toArray(new Module[modulesSet.size()]);
      Arrays.sort(
          modules,
          new Comparator<Module>() {
            @Override
            public int compare(Module m1, Module m2) {
              return m1.getName().compareTo(m2.getName());
            }
          });

      myModuleCombo.setModel(new DefaultComboBoxModel(modules));
      myModuleCombo.setSelectedItem(module);
      myModuleCombo.setRenderer(new ModuleListCellRendererWrapper(myModuleCombo.getRenderer()));
    }

    if (defaultFile == null) {
      final String defaultFileName = AndroidResourceUtil.getDefaultResourceFileName(resourceType);

      if (defaultFileName != null) {
        myFileNameCombo.getEditor().setItem(defaultFileName);
      }
    }
    myDirectoriesList = new CheckBoxList();
    myDirectoriesLabel.setLabelFor(myDirectoriesList);
    final ToolbarDecorator decorator = ToolbarDecorator.createDecorator(myDirectoriesList);

    decorator.setEditAction(null);
    decorator.disableUpDownActions();

    decorator.setAddAction(
        new AnActionButtonRunnable() {
          @Override
          public void run(AnActionButton button) {
            doAddNewDirectory();
          }
        });

    decorator.setRemoveAction(
        new AnActionButtonRunnable() {
          @Override
          public void run(AnActionButton button) {
            doDeleteDirectory();
          }
        });

    final AnActionButton selectAll =
        new AnActionButton("Select All", null, PlatformIcons.SELECT_ALL_ICON) {
          @Override
          public void actionPerformed(AnActionEvent e) {
            doSelectAllDirs();
          }
        };
    decorator.addExtraAction(selectAll);

    final AnActionButton unselectAll =
        new AnActionButton("Unselect All", null, PlatformIcons.UNSELECT_ALL_ICON) {
          @Override
          public void actionPerformed(AnActionEvent e) {
            doUnselectAllDirs();
          }
        };
    decorator.addExtraAction(unselectAll);

    myDirectoriesPanel.add(decorator.createPanel());

    updateDirectories(true);

    myModuleCombo.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            updateDirectories(true);
          }
        });
    final JCheckBox valuesCheckBox = myCheckBoxes.get(SdkConstants.FD_RES_VALUES);
    if (valuesCheckBox != null) {
      valuesCheckBox.setSelected(true);
    }

    if (defaultFile != null) {
      resetFromFile(defaultFile, module.getProject());
    }
    init();
  }
示例#4
0
 protected void setBackgroundColor(Color color) {
   super.setBackgroundColor(color);
   if (m_cmbUser != null) ((BasicComboBoxRenderer) m_cmbUser.getRenderer()).setBackground(color);
 }