Search in sources :

Example 31 with DocumentAdapter

use of com.intellij.ui.DocumentAdapter 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 32 with DocumentAdapter

use of com.intellij.ui.DocumentAdapter in project intellij by bazelbuild.

the class NewRuleUI method syncRuleNameTo.

void syncRuleNameTo(JBTextField textField) {
    ruleNameField.getDocument().addDocumentListener(new DocumentAdapter() {

        @Override
        protected void textChanged(DocumentEvent e) {
            ruleNameEditedByUser = true;
        }
    });
    textField.getDocument().addDocumentListener(new DocumentAdapter() {

        @Override
        protected void textChanged(DocumentEvent e) {
            if (!ruleNameEditedByUser) {
                syncRuleName(textField.getText());
            }
        }
    });
}
Also used : DocumentAdapter(com.intellij.ui.DocumentAdapter) DocumentEvent(javax.swing.event.DocumentEvent)

Example 33 with DocumentAdapter

use of com.intellij.ui.DocumentAdapter in project flutter-intellij by flutter.

the class FlutterGeneratorPeer method init.

private void init() {
    mySdkPathComboWithBrowse.getComboBox().setEditable(true);
    FlutterSdkUtil.addKnownSDKPathsToCombo(mySdkPathComboWithBrowse.getComboBox());
    mySdkPathComboWithBrowse.addBrowseFolderListener(FlutterBundle.message("flutter.sdk.browse.path.label"), null, null, FileChooserDescriptorFactory.createSingleFolderDescriptor(), TextComponentAccessor.STRING_COMBOBOX_WHOLE_TEXT);
    final JTextComponent editorComponent = (JTextComponent) getSdkEditor().getEditorComponent();
    editorComponent.getDocument().addDocumentListener(new DocumentAdapter() {

        @Override
        protected void textChanged(DocumentEvent e) {
            validate();
        }
    });
    // When this changes the corresponding parts of FlutterProjectStep should also be changed.
    myInstallActionLink.setIcon(myInstallSdkAction.getLinkIcon());
    myInstallActionLink.setDisabledIcon(IconLoader.getDisabledIcon(myInstallSdkAction.getLinkIcon()));
    myInstallActionLink.setText(myInstallSdkAction.getLinkText());
    // noinspection unchecked
    myInstallActionLink.setListener((label, linkUrl) -> myInstallSdkAction.actionPerformed(null), null);
    myProgressText.setFont(UIUtil.getLabelFont(UIUtil.FontSize.NORMAL).deriveFont(Font.ITALIC));
    // Some feedback on hover.
    myCancelProgressButton.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
    myCancelProgressButton.addMouseListener(new MouseAdapter() {

        @Override
        public void mouseClicked(MouseEvent e) {
            myListener.actionCanceled();
        }
    });
}
Also used : MouseEvent(java.awt.event.MouseEvent) MouseAdapter(java.awt.event.MouseAdapter) DocumentAdapter(com.intellij.ui.DocumentAdapter) JTextComponent(javax.swing.text.JTextComponent) DocumentEvent(javax.swing.event.DocumentEvent)

Example 34 with DocumentAdapter

use of com.intellij.ui.DocumentAdapter in project google-cloud-intellij by GoogleCloudPlatform.

the class CloudSdkPanel method initEvents.

private void initEvents() {
    // track all changes in UI to report settings changes.
    UserActivityWatcher activityWatcher = new UserActivityWatcher();
    activityWatcher.register(cloudSdkPanel);
    activityWatcher.addUserActivityListener(() -> settingsModified = true);
    ButtonGroup sdkChoiceGroup = new ButtonGroup();
    sdkChoiceGroup.add(managedRadioButton);
    sdkChoiceGroup.add(customRadioButton);
    managedRadioButton.addActionListener((e) -> {
        setManagedSdkUiAvailable(true);
        setCustomSdkUiAvailable(false);
        selectedCloudSdkServiceType = CloudSdkServiceType.MANAGED_SDK;
    });
    customRadioButton.addActionListener((e) -> {
        setCustomSdkUiAvailable(true);
        setManagedSdkUiAvailable(false);
        selectedCloudSdkServiceType = CloudSdkServiceType.CUSTOM_SDK;
    });
    checkForUpdatesHyperlink.addHyperlinkListener(new HyperlinkAdapter() {

        @Override
        protected void hyperlinkActivated(HyperlinkEvent e) {
        // TODO(ivanporty) will call ManagedSdk#update if it's installed and active.
        }
    });
    cloudSdkDirectoryField.addBrowseFolderListener(GctBundle.message("cloudsdk.location.browse.window.title"), null, /* description */
    null, /* project */
    FileChooserDescriptorFactory.createSingleFolderDescriptor());
    cloudSdkDirectoryField.getTextField().getDocument().addDocumentListener(new DocumentAdapter() {

        @Override
        protected void textChanged(DocumentEvent event) {
            checkSdkInBackground();
        }
    });
}
Also used : HyperlinkEvent(javax.swing.event.HyperlinkEvent) ButtonGroup(javax.swing.ButtonGroup) UserActivityWatcher(com.intellij.ui.UserActivityWatcher) DocumentAdapter(com.intellij.ui.DocumentAdapter) DocumentEvent(javax.swing.event.DocumentEvent) HyperlinkAdapter(com.intellij.ui.HyperlinkAdapter)

Example 35 with DocumentAdapter

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

the class SpringCloudAppConfigPanel method init.

private void init() {
    final TailingDebouncer debouncer = new TailingDebouncer(this::onDataChanged, 300);
    this.toggleStorage.addActionListener(e -> {
        toggleStorage("enable".equals(e.getActionCommand()));
        debouncer.debounce();
    });
    this.toggleEndpoint.addActionListener(e -> {
        toggleEndpoint("enable".equals(e.getActionCommand()));
        debouncer.debounce();
    });
    this.txtStorage.setBorder(JBUI.Borders.empty(0, 2));
    this.useJava8.addActionListener((e) -> debouncer.debounce());
    this.useJava11.addActionListener((e) -> debouncer.debounce());
    this.txtJvmOptions.getDocument().addDocumentListener(new DocumentAdapter() {

        @Override
        protected void textChanged(DocumentEvent documentEvent) {
            debouncer.debounce();
        }
    });
    this.envTable.addChangeListener((e) -> debouncer.debounce());
    this.numCpu.addActionListener((e) -> debouncer.debounce());
    this.numMemory.addActionListener((e) -> debouncer.debounce());
    this.numInstance.addChangeListener((e) -> debouncer.debounce());
}
Also used : TailingDebouncer(com.microsoft.azure.toolkit.lib.common.utils.TailingDebouncer) DocumentAdapter(com.intellij.ui.DocumentAdapter) DocumentEvent(javax.swing.event.DocumentEvent)

Aggregations

DocumentAdapter (com.intellij.ui.DocumentAdapter)81 DocumentEvent (javax.swing.event.DocumentEvent)81 ActionEvent (java.awt.event.ActionEvent)15 ActionListener (java.awt.event.ActionListener)15 FileChooserDescriptor (com.intellij.openapi.fileChooser.FileChooserDescriptor)11 Document (javax.swing.text.Document)8 JTextComponent (javax.swing.text.JTextComponent)8 VirtualFile (com.intellij.openapi.vfs.VirtualFile)6 ItemEvent (java.awt.event.ItemEvent)6 ItemListener (java.awt.event.ItemListener)6 NotNull (org.jetbrains.annotations.NotNull)6 Nullable (org.jetbrains.annotations.Nullable)6 JBTextField (com.intellij.ui.components.JBTextField)5 ChangeEvent (javax.swing.event.ChangeEvent)5 Project (com.intellij.openapi.project.Project)4 FieldPanel (com.intellij.ui.FieldPanel)4 ChangeListener (javax.swing.event.ChangeListener)4 List (java.util.List)3 DocumentListener (javax.swing.event.DocumentListener)3 ProjectSelector (com.google.cloud.tools.intellij.project.ProjectSelector)2