Search in sources :

Example 76 with DocumentAdapter

use of com.intellij.ui.DocumentAdapter in project watchdog by TestRoots.

the class WelcomeStepBase method createLoginJPanel.

/**
 * Creates and returns an input field, in which user can enter their
 * existing WatchDog ID.
 */
private JPanel createLoginJPanel(final JPanel parent) {
    JPanel panel = UIUtils.createFlowJPanelLeft(parent);
    userInput = UIUtils.createLinkedFieldInput(panel, labelText, ID_LENGTH, inputToolTip);
    userInput.setDocument(new UIUtils.JTextFieldLimit(ID_LENGTH));
    userInput.getDocument().addDocumentListener(new DocumentAdapter() {

        @Override
        protected void textChanged(DocumentEvent e) {
            if (userInput.getText().length() == ID_LENGTH) {
                setErrorMessageAndStepComplete(null);
            } else {
                setErrorMessageAndStepComplete("Not a valid id.");
            }
            parent.updateUI();
            getWizard().updateButtons();
        }
    });
    return panel;
}
Also used : DocumentAdapter(com.intellij.ui.DocumentAdapter) UIUtils(nl.tudelft.watchdog.intellij.ui.util.UIUtils) DocumentEvent(javax.swing.event.DocumentEvent)

Example 77 with DocumentAdapter

use of com.intellij.ui.DocumentAdapter in project watchdog by TestRoots.

the class PreferencePage method createComponent.

@Nullable
@Override
public JComponent createComponent() {
    main = new JPanel();
    main.setLayout(new BoxLayout(main, BoxLayout.Y_AXIS));
    JPanel localGroup = UIUtils.createGroup(main, "Local Settings", 1);
    UIUtils.createLabel(localGroup, "Here you can define the local WatchDog settings for this project.");
    UIUtils.createLabel(localGroup, "");
    JPanel projectJPanel = UIUtils.createFlowJPanelLeft(localGroup);
    UIUtils.createLabel(projectJPanel, "Project-ID ");
    projectIDInput = UIUtils.createLimitedTextInputField(projectJPanel, ID_LENGTH);
    ProjectPreferenceSetting projectSetting = preferences.getOrCreateProjectSetting(WatchDogUtils.getProjectName());
    projectIDInput.setText(projectSetting.projectId);
    enableWatchdogInput = UIUtils.createCheckBox(localGroup, "Monitor this project with WatchDog ");
    enableWatchdogInput.setSelected(projectSetting.enableWatchdog);
    UIUtils.createLabel(main, "");
    JPanel globalGroup = UIUtils.createGroup(main, "Global Settings", 1);
    UIUtils.createLabel(globalGroup, "Here you can enter settings that will affect WatchDog no matter which project you have opened.  ");
    UIUtils.createLabel(globalGroup, "");
    JPanel userJPanel = UIUtils.createFlowJPanelLeft(globalGroup);
    UIUtils.createLabel(userJPanel, "User-ID ");
    userIDInput = UIUtils.createLimitedTextInputField(userJPanel, ID_LENGTH);
    userIDInput.setText(preferences.getUserId());
    JPanel serverJPanel = UIUtils.createFlowJPanelLeft(globalGroup);
    UIUtils.createLabel(serverJPanel, "Server-URL ");
    serverURLInput = UIUtils.createTextInputField(serverJPanel, WatchDogGlobals.DEFAULT_SERVER_URI.length());
    serverURLInput.setMinimumSize(serverURLInput.getPreferredSize());
    serverURLInput.setMaximumSize(serverURLInput.getPreferredSize());
    serverURLInput.setText(preferences.getServerURI());
    serverURLInput.getDocument().addDocumentListener(new DocumentAdapter() {

        @Override
        protected void textChanged(DocumentEvent e) {
            isModified = true;
        }
    });
    enableAuthentication = UIUtils.createCheckBox(globalGroup, "Enable Authentication");
    enableAuthentication.setSelected(preferences.isAuthenticationEnabled());
    enableLogging = UIUtils.createCheckBox(globalGroup, "Enable Logging");
    enableLogging.setSelected(preferences.isLoggingEnabled());
    addModificationListeners();
    return main;
}
Also used : DocumentAdapter(com.intellij.ui.DocumentAdapter) DocumentEvent(javax.swing.event.DocumentEvent) ProjectPreferenceSetting(nl.tudelft.watchdog.core.ui.preferences.ProjectPreferenceSetting) Nullable(org.jetbrains.annotations.Nullable)

Example 78 with DocumentAdapter

use of com.intellij.ui.DocumentAdapter in project watchdog by TestRoots.

the class PreferencePage method addModificationListeners.

private void addModificationListeners() {
    enableWatchdogInput.getAccessibleContext().addPropertyChangeListener(new PropertyChangeListener() {

        @Override
        public void propertyChange(PropertyChangeEvent evt) {
            isModified = true;
        }
    });
    projectIDInput.getDocument().addDocumentListener(new DocumentAdapter() {

        @Override
        protected void textChanged(DocumentEvent e) {
            isModified = true;
        }
    });
    enableAuthentication.getAccessibleContext().addPropertyChangeListener(new PropertyChangeListener() {

        @Override
        public void propertyChange(PropertyChangeEvent evt) {
            isModified = true;
        }
    });
    userIDInput.getDocument().addDocumentListener(new DocumentAdapter() {

        @Override
        protected void textChanged(DocumentEvent e) {
            isModified = true;
        }
    });
    enableLogging.getAccessibleContext().addPropertyChangeListener(new PropertyChangeListener() {

        @Override
        public void propertyChange(PropertyChangeEvent evt) {
            isModified = true;
        }
    });
}
Also used : PropertyChangeEvent(java.beans.PropertyChangeEvent) PropertyChangeListener(java.beans.PropertyChangeListener) DocumentAdapter(com.intellij.ui.DocumentAdapter) DocumentEvent(javax.swing.event.DocumentEvent)

Example 79 with DocumentAdapter

use of com.intellij.ui.DocumentAdapter in project go-lang-idea-plugin by go-lang-plugin-org.

the class GoSdkConfigurable method listenForPathUpdate.

private void listenForPathUpdate() {
    JTextField textField = mySdkPathField.getTextField();
    Ref<String> prevPathRef = Ref.create(StringUtil.notNullize(textField.getText()));
    textField.getDocument().addDocumentListener(new DocumentAdapter() {

        @Override
        protected void textChanged(DocumentEvent e) {
            String sdkPath = StringUtil.notNullize(textField.getText());
            String prevPath = prevPathRef.get();
            if (!prevPath.equals(sdkPath)) {
                asyncUpdateSdkVersion(sdkPath);
                prevPathRef.set(sdkPath);
            }
        }
    });
}
Also used : DocumentAdapter(com.intellij.ui.DocumentAdapter) DocumentEvent(javax.swing.event.DocumentEvent)

Example 80 with DocumentAdapter

use of com.intellij.ui.DocumentAdapter in project ballerina by ballerina-lang.

the class BallerinaSdkConfigurable method listenForPathUpdate.

private void listenForPathUpdate() {
    JTextField textField = mySdkPathField.getTextField();
    Ref<String> prevPathRef = Ref.create(StringUtil.notNullize(textField.getText()));
    textField.getDocument().addDocumentListener(new DocumentAdapter() {

        @Override
        protected void textChanged(DocumentEvent e) {
            String sdkPath = StringUtil.notNullize(textField.getText());
            String prevPath = prevPathRef.get();
            if (!prevPath.equals(sdkPath)) {
                asyncUpdateSdkVersion(sdkPath);
                prevPathRef.set(sdkPath);
            }
        }
    });
}
Also used : DocumentAdapter(com.intellij.ui.DocumentAdapter) JTextField(javax.swing.JTextField) 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