Search in sources :

Example 6 with CollectionComboBoxModel

use of com.intellij.ui.CollectionComboBoxModel in project intellij-community by JetBrains.

the class LibrariesDownloadUiUtil method loadItems.

private static void loadItems(@NotNull final JComboBox jComboBox, final List<Object> items, final String groupId, final URL... localUrls) {
    final ModalityState state = ModalityState.current();
    ApplicationManager.getApplication().executeOnPooledThread(() -> {
        final List<Object> newItems = new ArrayList<>();
        newItems.addAll(Arrays.asList(LibrariesDownloadAssistant.getVersions(groupId, localUrls)));
        ApplicationManager.getApplication().invokeLater(() -> {
            items.clear();
            if (!newItems.isEmpty()) {
                items.addAll(newItems);
                final CollectionComboBoxModel model = (CollectionComboBoxModel) jComboBox.getModel();
                model.update();
                jComboBox.setSelectedIndex(0);
            }
            jComboBox.setEnabled(true);
        }, state);
    });
}
Also used : ModalityState(com.intellij.openapi.application.ModalityState) ArrayList(java.util.ArrayList) CollectionComboBoxModel(com.intellij.ui.CollectionComboBoxModel)

Example 7 with CollectionComboBoxModel

use of com.intellij.ui.CollectionComboBoxModel in project intellij-community by JetBrains.

the class LibrariesDownloadUiUtil method initAsyncComboBoxModel.

public static void initAsyncComboBoxModel(@NotNull final JComboBox jComboBox, @NotNull final String groupId, final URL... localUrls) {
    final List<Object> items = new ArrayList<>();
    new UiNotifyConnector.Once(jComboBox, new Activatable() {

        @Override
        public void showNotify() {
            loadItems(jComboBox, items, groupId, localUrls);
        }

        @Override
        public void hideNotify() {
        }
    });
    items.add("loading...");
    jComboBox.setModel(new CollectionComboBoxModel(items, items.get(0)));
    jComboBox.setEnabled(false);
}
Also used : Activatable(com.intellij.util.ui.update.Activatable) ArrayList(java.util.ArrayList) CollectionComboBoxModel(com.intellij.ui.CollectionComboBoxModel)

Example 8 with CollectionComboBoxModel

use of com.intellij.ui.CollectionComboBoxModel in project intellij-community by JetBrains.

the class VersionsComponent method createComboBox.

private JComboBox createComboBox(String ri) {
    final JComboBox comboBox = new JComboBox();
    List<Artifact> versions = getSupportedVersions(ri);
    comboBox.setModel(new CollectionComboBoxModel(versions, null));
    comboBox.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            updateCurrentVersion(comboBox);
        }
    });
    return comboBox;
}
Also used : ActionListener(java.awt.event.ActionListener) ActionEvent(java.awt.event.ActionEvent) CollectionComboBoxModel(com.intellij.ui.CollectionComboBoxModel) Artifact(com.intellij.facet.frameworks.beans.Artifact)

Example 9 with CollectionComboBoxModel

use of com.intellij.ui.CollectionComboBoxModel in project Perl5-IDEA by Camelcade.

the class PerlConfigurationEditor method getGeneralComponent.

@Nullable
@Override
protected JComponent getGeneralComponent() {
    myScriptField = new TextFieldWithBrowseButton();
    myScriptField.addBrowseFolderListener(PerlBundle.message("perl.run.config.select.script.header"), PerlBundle.message("perl.run.config.select.script.prompt"), myProject, FileChooserDescriptorFactory.createSingleFileNoJarsDescriptor().withFileFilter(PerlConfigurationProducer::isExecutableFile), TextComponentAccessor.TEXT_FIELD_WHOLE_TEXT);
    myConsoleCharset = new ComboBox(new CollectionComboBoxModel(new ArrayList<>(Charset.availableCharsets().keySet())));
    myScriptField.getTextField().getDocument().addDocumentListener(new DocumentAdapter() {

        @Override
        protected void textChanged(DocumentEvent documentEvent) {
            VirtualFile file = LocalFileSystem.getInstance().findFileByPath(myScriptField.getText());
            if (file != null) {
                myConsoleCharset.setSelectedItem(file.getCharset().displayName());
            } else {
                myConsoleCharset.setSelectedItem(null);
            }
        }
    });
    myAlternativeSdkPanel = new PerlAlternativeSdkPanel();
    myParametersPanel = new CommonProgramParametersPanel() {

        @Override
        protected void addComponents() {
            LabeledComponent<?> scriptLabel = LabeledComponent.create(myScriptField, PerlBundle.message("perl.run.option.script"));
            scriptLabel.setLabelLocation(BorderLayout.WEST);
            add(scriptLabel);
            LabeledComponent<?> consoleEncoding = LabeledComponent.create(myConsoleCharset, PerlBundle.message("perl.run.option.output.encoding"));
            consoleEncoding.setLabelLocation(BorderLayout.WEST);
            add(consoleEncoding);
            myPerlParametersPanel = new RawCommandLineEditor();
            LabeledComponent<RawCommandLineEditor> perlParametersPanel = LabeledComponent.create(myPerlParametersPanel, PerlBundle.message("perl.run.option.perl.parameters"));
            perlParametersPanel.setLabelLocation(BorderLayout.WEST);
            copyDialogCaption(perlParametersPanel);
            add(perlParametersPanel);
            super.addComponents();
            add(myAlternativeSdkPanel);
            setLayout(new VerticalFlowLayout(VerticalFlowLayout.TOP, 0, 5, true, false));
        }
    };
    myParametersPanel.setProgramParametersLabel(PerlBundle.message("perl.run.option.script.parameters"));
    return myParametersPanel;
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) DocumentAdapter(com.intellij.ui.DocumentAdapter) DocumentEvent(javax.swing.event.DocumentEvent) CommonProgramParametersPanel(com.intellij.execution.ui.CommonProgramParametersPanel) RawCommandLineEditor(com.intellij.ui.RawCommandLineEditor) CollectionComboBoxModel(com.intellij.ui.CollectionComboBoxModel) Nullable(org.jetbrains.annotations.Nullable)

Example 10 with CollectionComboBoxModel

use of com.intellij.ui.CollectionComboBoxModel in project azure-tools-for-java by Microsoft.

the class FunctionsModuleInfoStep method _init.

@Override
public void _init() {
    panel = new JPanel(new BorderLayout());
    final String groupId = context.getUserData(AzureFunctionsConstants.WIZARD_GROUPID_KEY);
    final String artifactId = context.getUserData(AzureFunctionsConstants.WIZARD_ARTIFACTID_KEY);
    final String version = context.getUserData(AzureFunctionsConstants.WIZARD_VERSION_KEY);
    final String packageName = context.getUserData(AzureFunctionsConstants.WIZARD_PACKAGE_NAME_KEY);
    try {
        final FormBuilder formBuilder = new FormBuilder();
        final CollectionComboBoxModel<String> toolModel = new CollectionComboBoxModel<>(Arrays.asList(MAVEN_TOOL, GRADLE_TOOL));
        toolComboBox = new ComboBox<>(toolModel);
        formBuilder.addLabeledComponent("Tool:", toolComboBox);
        groupIdField = new JBTextField(getCurrentOrDefaultValue(groupId, "com.example"));
        formBuilder.addLabeledComponent("Group:", groupIdField);
        artifactIdField = new JBTextField(getCurrentOrDefaultValue(artifactId, "azure-function-examples"));
        formBuilder.addLabeledComponent("Artifact:", artifactIdField);
        versionField = new JBTextField(getCurrentOrDefaultValue(version, "1.0.0-SNAPSHOT"));
        formBuilder.addLabeledComponent("Version:", versionField);
        packageNameField = new JBTextField(getCurrentOrDefaultValue(packageName, "org.example.functions"));
        formBuilder.addLabeledComponent("Package name:", packageNameField);
        panel.add(ScrollPaneFactory.createScrollPane(formBuilder.getPanel(), true), "North");
    } catch (final RuntimeException e) {
        LOGGER.error(e.getLocalizedMessage(), e);
        throw e;
    }
}
Also used : FormBuilder(com.intellij.util.ui.FormBuilder) CollectionComboBoxModel(com.intellij.ui.CollectionComboBoxModel) JBTextField(com.intellij.ui.components.JBTextField)

Aggregations

CollectionComboBoxModel (com.intellij.ui.CollectionComboBoxModel)16 ArrayList (java.util.ArrayList)4 Sdk (com.intellij.openapi.projectRoots.Sdk)3 VirtualFile (com.intellij.openapi.vfs.VirtualFile)2 ActionEvent (java.awt.event.ActionEvent)2 ActionListener (java.awt.event.ActionListener)2 ItemEvent (java.awt.event.ItemEvent)2 ItemListener (java.awt.event.ItemListener)2 NotNull (org.jetbrains.annotations.NotNull)2 InvalidationListener (com.android.tools.idea.ui.properties.InvalidationListener)1 ObservableValue (com.android.tools.idea.ui.properties.ObservableValue)1 CommonProgramParametersPanel (com.intellij.execution.ui.CommonProgramParametersPanel)1 Artifact (com.intellij.facet.frameworks.beans.Artifact)1 Disposable (com.intellij.openapi.Disposable)1 DataContext (com.intellij.openapi.actionSystem.DataContext)1 ModalityState (com.intellij.openapi.application.ModalityState)1 ComboBox (com.intellij.openapi.ui.ComboBox)1 MultiLineLabelUI (com.intellij.openapi.ui.MultiLineLabelUI)1 CheckinHandler (com.intellij.openapi.vcs.checkin.CheckinHandler)1 RefreshableOnComponent (com.intellij.openapi.vcs.ui.RefreshableOnComponent)1