Esempio n. 1
0
  protected AutoCompletion(final JComboBox comboBox, boolean strict, boolean allowsUserValues) {
    this.comboBox = comboBox;
    textEditor = ((JTextComponent) comboBox.getEditor().getEditorComponent());

    this.allowsUserValues = allowsUserValues;

    suggestionList = new SuggestionList(comboBox, strict);

    /** Marking combobox as auto-completing */
    comboBox.putClientProperty(AUTOCOMPLETION_PROPERTY, Boolean.TRUE);
  }
    private void showComboPreview(ResourceItem element) {
      java.util.List<ResourceElement> resources = element.getPreviewResources();
      String selection = (String) myComboBox.getSelectedItem();
      if (selection == null) {
        selection = element.getPreviewComboDefaultSelection();
      }

      int index = element.getPreviewComboModel().getIndexOf(selection);
      if (index == -1) {
        index = 0;
      }

      myComboBox.setModel(element.getPreviewComboModel());
      myComboBox.putClientProperty(COMBO, resources);
      myComboBox.setSelectedIndex(index);
      myComboTextArea.setText(getResourceElementValue(resources.get(index)));

      CardLayout layout = (CardLayout) myPreviewPanel.getLayout();
      layout.show(myPreviewPanel, COMBO);
    }
 private static void setAdjusting(JComboBox cbInput, boolean adjusting) {
   cbInput.putClientProperty("is_adjusting", adjusting);
 }
 public DropDownCellEditor(WbTable dataTable) {
   table = dataTable;
   input = new JComboBox();
   input.putClientProperty("JComboBox.isTableCellEditor", Boolean.TRUE);
   input.setEditable(GuiSettings.getVariablesDDEditable());
 }
 public static void registerTableCellEditor(
     @NotNull JComboBox comboBox, @NotNull TableCellEditor cellEditor) {
   comboBox.putClientProperty(TABLE_CELL_EDITOR_PROPERTY, cellEditor);
   comboBox.putClientProperty("JComboBox.isTableCellEditor", Boolean.TRUE);
 }
  public JComponent createComponent() {
    final JPanel panel = new JPanel(new GridBagLayout());
    panel.setBorder(IdeBorderFactory.createTitledBorder("File Context", false));
    myCombo = new ComboBox();
    myCombo.putClientProperty(CONTEXTS_COMBO_KEY, Boolean.TRUE);
    panel.add(
        new JLabel("Included into:"),
        new GridBagConstraints(
            0,
            0,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.WEST,
            GridBagConstraints.NONE,
            new Insets(5, 0, 5, 0),
            0,
            0));
    panel.add(
        myCombo,
        new GridBagConstraints(
            1,
            0,
            1,
            1,
            1.0,
            0.0,
            GridBagConstraints.WEST,
            GridBagConstraints.HORIZONTAL,
            new Insets(5, 5, 5, 0),
            0,
            0));

    final PsiManager psiManager = PsiManager.getInstance(myProject);
    final FileBasedIndex fbi = FileBasedIndex.getInstance();
    final Collection<VirtualFile> antFiles =
        fbi.getContainingFiles(
            AntImportsIndex.INDEX_NAME, AntImportsIndex.ANT_FILES_WITH_IMPORTS_KEY, myFileFilter);

    for (VirtualFile file : antFiles) {
      final PsiFile psiFile = psiManager.findFile(file);
      if (!(psiFile instanceof XmlFile)) {
        continue;
      }
      final XmlFile xmlFile = (XmlFile) psiFile;
      if (!xmlFile.equals(myFile) && AntDomFileDescription.isAntFile(xmlFile)) {
        final String path = PathUtil.getLocalPath(file);
        final XmlFile previous = myPathToFileMap.put(path, xmlFile);
        assert previous == null;
      }
    }

    final List<String> paths = new ArrayList<String>(myPathToFileMap.keySet());
    Collections.sort(
        paths,
        new Comparator<String>() {
          public int compare(final String o1, final String o2) {
            return o1.compareTo(o2);
          }
        });

    myCombo.addItem(NONE);
    for (String path : paths) {
      myCombo.addItem(path);
    }

    final AntConfigurationBase antConfig = AntConfigurationBase.getInstance(myProject);
    final XmlFile currentContext = antConfig.getContextFile(myFile);
    if (currentContext != null) {
      final VirtualFile vFile = currentContext.getVirtualFile();

      assert vFile != null;

      final String path = PathUtil.getLocalPath(vFile);
      if (!FileUtil.pathsEqual(path, myLocalPath)) {
        myOriginalContext = path;
      }
    }
    myCombo.setSelectedItem(myOriginalContext);

    return panel;
  }