com.intellij.ui.DocumentAdapter Java Examples

The following examples show how to use com.intellij.ui.DocumentAdapter. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CreateRTAction.java    From react-templates-plugin with MIT License 6 votes vote down vote up
public MyDialog(final Project project, final MyInputValidator validator) {
            super(project, true);
            myProject = project;
            myValidator = validator;
            myBaseLayoutManagerCombo.registerUpDownHint(myFormNameTextField);
            myUpDownHintForm.setIcon(PlatformIcons.UP_DOWN_ARROWS);
            myBaseLayoutManagerCombo.addItem("None", RTIcons.RT, "none");
            myBaseLayoutManagerCombo.addItem("AMD", RTIcons.RT, "amd");
            myBaseLayoutManagerCombo.addItem("CommonJS", RTIcons.RT, "commonjs");
            myBaseLayoutManagerCombo.addItem("ES6", RTIcons.RT, "es6");
            myBaseLayoutManagerCombo.addItem("Typescript", RTIcons.RT, "typescript");
            init();
            setTitle(RTBundle.message("title.new.gui.form"));
            setOKActionEnabled(false);

            myFormNameTextField.getDocument().addDocumentListener(new DocumentAdapter() {
                protected void textChanged(DocumentEvent e) {
                    setOKActionEnabled(!myFormNameTextField.getText().isEmpty());
                }
            });

            myBaseLayoutManagerCombo.setSelectedName(Settings.getInstance(project).modules);
            myBaseLayoutManagerCombo.setEnabled(false);
//            myBaseLayoutManagerCombo.setSelectedName(GuiDesignerConfiguration.getInstance(project).DEFAULT_LAYOUT_MANAGER);
        }
 
Example #2
Source File: CloneDvcsDialog.java    From consulo with Apache License 2.0 6 votes vote down vote up
private void createUIComponents() {
  myRepositoryURL = new EditorComboBox("");
  final DvcsRememberedInputs rememberedInputs = getRememberedInputs();
  List<String> urls = new ArrayList<>(rememberedInputs.getVisitedUrls());
  if (myDefaultRepoUrl != null) {
    urls.add(0, myDefaultRepoUrl);
  }
  myRepositoryURL.setHistory(ArrayUtil.toObjectArray(urls, String.class));
  myRepositoryURL.addDocumentListener(new com.intellij.openapi.editor.event.DocumentAdapter() {
    @Override
    public void documentChanged(com.intellij.openapi.editor.event.DocumentEvent e) {
      // enable test button only if something is entered in repository URL
      final String url = getCurrentUrlText();
      myTestButton.setEnabled(url.length() != 0);
      if (myDefaultDirectoryName.equals(myDirectoryName.getText()) || myDirectoryName.getText().length() == 0) {
        // modify field if it was unmodified or blank
        myDefaultDirectoryName = defaultDirectoryName(url, myVcsDirectoryName);
        myDirectoryName.setText(myDefaultDirectoryName);
      }
      updateButtons();
    }
  });
}
 
Example #3
Source File: ExtractArtifactDialog.java    From consulo with Apache License 2.0 6 votes vote down vote up
public ExtractArtifactDialog(ArtifactEditorContext context, LayoutTreeComponent treeComponent, String initialName) {
  super(treeComponent.getLayoutTree(), true);
  myContext = context;
  setTitle(ProjectBundle.message("dialog.title.extract.artifact"));
  for (ArtifactType type : ArtifactType.EP_NAME.getExtensions()) {
    myTypeBox.addItem(type);
  }
  myTypeBox.setSelectedItem(PlainArtifactType.getInstance());
  myTypeBox.setRenderer(new ArtifactTypeCellRenderer());
  myNameField.getDocument().addDocumentListener(new DocumentAdapter() {
    @Override
    protected void textChanged(DocumentEvent e) {
      setOKActionEnabled(!StringUtil.isEmptyOrSpaces(getArtifactName()));
    }
  });
  myNameField.setText(initialName);
  init();
}
 
Example #4
Source File: MasterKeyUtils.java    From consulo with Apache License 2.0 6 votes vote down vote up
/**
 * Match passwords
 *
 * @param passwordField1 the first password field
 * @param passwordField2 the second password field
 * @param setError       the callback used to set or to clear an error
 */
static void matchPasswords(final JPasswordField passwordField1, final JPasswordField passwordField2, final Processor<String> setError) {
  DocumentAdapter l = new DocumentAdapter() {
    @Override
    protected void textChanged(DocumentEvent e) {
      if (Arrays.equals(passwordField1.getPassword(), passwordField2.getPassword())) {
        setError.process(null);
      }
      else {
        setError.process("The new password and confirm passwords do not match.");
      }
    }
  };
  passwordField1.getDocument().addDocumentListener(l);
  passwordField2.getDocument().addDocumentListener(l);
}
 
Example #5
Source File: ConnectionParametersPanel.java    From intellij-xquery with Apache License 2.0 6 votes vote down vote up
private void setUpChangeListeners(final DataSourceConfigurationAggregatingPanel
                                          aggregatingPanel,
                                  final ConfigurationChangeListener listener) {
    DocumentListener textFieldListener = new DocumentAdapter() {
        @Override
        protected void textChanged(DocumentEvent e) {
            listener.changeApplied(aggregatingPanel
                    .getCurrentConfigurationState());
        }
    };
    host.getComponent().getDocument().addDocumentListener(textFieldListener);
    port.getComponent().getDocument().addDocumentListener(textFieldListener);
    username.getComponent().getDocument().addDocumentListener(textFieldListener);
    password.getComponent().getDocument().addDocumentListener(textFieldListener);
    databaseName.getComponent().getDocument().addDocumentListener(textFieldListener);
}
 
Example #6
Source File: CreateRTAction.java    From react-templates-plugin with MIT License 6 votes vote down vote up
public MyDialog(final Project project, final MyInputValidator validator) {
            super(project, true);
            myProject = project;
            myValidator = validator;
            myBaseLayoutManagerCombo.registerUpDownHint(myFormNameTextField);
            myUpDownHintForm.setIcon(PlatformIcons.UP_DOWN_ARROWS);
            myBaseLayoutManagerCombo.addItem("None", RTIcons.RT, "none");
            myBaseLayoutManagerCombo.addItem("AMD", RTIcons.RT, "amd");
            myBaseLayoutManagerCombo.addItem("CommonJS", RTIcons.RT, "commonjs");
            myBaseLayoutManagerCombo.addItem("ES6", RTIcons.RT, "es6");
            myBaseLayoutManagerCombo.addItem("Typescript", RTIcons.RT, "typescript");
            init();
            setTitle(RTBundle.message("title.new.gui.form"));
            setOKActionEnabled(false);

            myFormNameTextField.getDocument().addDocumentListener(new DocumentAdapter() {
                protected void textChanged(DocumentEvent e) {
                    setOKActionEnabled(!myFormNameTextField.getText().isEmpty());
                }
            });

            myBaseLayoutManagerCombo.setSelectedName(Settings.getInstance(project).modules);
            myBaseLayoutManagerCombo.setEnabled(false);
//            myBaseLayoutManagerCombo.setSelectedName(GuiDesignerConfiguration.getInstance(project).DEFAULT_LAYOUT_MANAGER);
        }
 
Example #7
Source File: SingleIntegerFieldOptionsPanel.java    From consulo with Apache License 2.0 6 votes vote down vote up
/**
 * Sets integer number format to JFormattedTextField instance,
 * sets value of JFormattedTextField instance to object's field value,
 * synchronizes object's field value with the value of JFormattedTextField instance.
 *
 * @param textField  JFormattedTextField instance
 * @param owner      an object whose field is synchronized with {@code textField}
 * @param property   object's field name for synchronization
 */
public static void setupIntegerFieldTrackingValue(final JFormattedTextField textField,
                                                  final InspectionProfileEntry owner,
                                                  final String property) {
    NumberFormat formatter = NumberFormat.getIntegerInstance();
    formatter.setParseIntegerOnly(true);
    textField.setFormatterFactory(new DefaultFormatterFactory(new NumberFormatter(formatter)));
    textField.setValue(getPropertyValue(owner, property));
    final Document document = textField.getDocument();
    document.addDocumentListener(new DocumentAdapter() {
        @Override
        public void textChanged(DocumentEvent e) {
            try {
                textField.commitEdit();
                setPropertyValue(owner, property,
                        ((Number) textField.getValue()).intValue());
            } catch (ParseException e1) {
                // No luck this time
            }
        }
    });
}
 
Example #8
Source File: VueSettingsPage.java    From vue-for-idea with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
public VueSettingsPage(@NotNull final Project project) {
    this.project = project;
    configRTBinField();
    configNodeField();


    this.packagesNotificationPanel = new PackagesNotificationPanel(project);
    errorPanel.add(this.packagesNotificationPanel.getComponent(), BorderLayout.CENTER);

    DocumentAdapter docAdp = new DocumentAdapter() {
        protected void textChanged(DocumentEvent e) {
            updateLaterInEDT();
        }
    };
    rtBinField.getChildComponent().getTextEditor().getDocument().addDocumentListener(docAdp);
    nodeInterpreterField.getChildComponent().getTextEditor().getDocument().addDocumentListener(docAdp);
}
 
Example #9
Source File: NamedConfigurable.java    From consulo with Apache License 2.0 6 votes vote down vote up
protected NamedConfigurable(boolean isNameEditable, @Nullable final Runnable updateTree) {
  myNameEditable = isNameEditable;
  myNamePanel.setVisible(myNameEditable);
  if (myNameEditable) {
    myNameField.getDocument().addDocumentListener(new DocumentAdapter() {
      @Override
      protected void textChanged(DocumentEvent e) {
        setDisplayName(myNameField.getText());
        if (updateTree != null){
          updateTree.run();
        }
      }
    });
  }
  myNamePanel.setBorder(JBUI.Borders.empty(10, 10, 6, 10));
}
 
Example #10
Source File: ExtractWidgetAction.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
public ExtractWidgetDialog(@NotNull Project project,
                           @Nullable Editor editor,
                           @NotNull ExtractWidgetRefactoring refactoring) {
  super(project, editor, refactoring);
  myRefactoring = refactoring;
  setTitle("Extract Widget");
  init();

  myNameField.setText("NewWidget");
  myNameField.selectAll();
  myNameField.getDocument().addDocumentListener(new DocumentAdapter() {
    @Override
    protected void textChanged(DocumentEvent e) {
      updateRefactoringOptions();
    }
  });

  updateRefactoringOptions();
}
 
Example #11
Source File: AbstractExtractMethodDialog.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Override
protected void init() {
  super.init();
  // Set default name and select it
  myMethodNameTextField.setText(myDefaultName);
  myMethodNameTextField.setSelectionStart(0);
  myMethodNameTextField.setSelectionStart(myDefaultName.length());
  myMethodNameTextField.getDocument().addDocumentListener(new DocumentAdapter() {
    @Override
    protected void textChanged(DocumentEvent e) {
      updateOutputVariables();
      updateSignature();
      updateOkStatus();
    }
  });


  myVariableData = createVariableDataByNames(myArguments);
  myVariablesMap = createVariableMap(myVariableData);
  myParametersPanel.init(myVariableData);

  updateOutputVariables();
  updateSignature();
  updateOkStatus();
}
 
Example #12
Source File: FileSaverDialogImpl.java    From consulo with Apache License 2.0 6 votes vote down vote up
protected JComponent createFileNamePanel() {
  final JPanel panel = new JPanel(new BorderLayout());
  panel.add(new JLabel(UIBundle.message("file.chooser.save.dialog.file.name")), BorderLayout.WEST);
  myFileName.setText("");
  myFileName.getDocument().addDocumentListener(new DocumentAdapter() {
    protected void textChanged(DocumentEvent e) {
      updateOkButton();
    }
  });

  panel.add(myFileName, BorderLayout.CENTER);
  if (myExtensions.getModel().getSize() > 0) {
    myExtensions.setSelectedIndex(0);
    panel.add(myExtensions, BorderLayout.EAST);
  }
  return panel;
}
 
Example #13
Source File: ExtractWidgetAction.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
public ExtractWidgetDialog(@NotNull Project project,
                           @Nullable Editor editor,
                           @NotNull ExtractWidgetRefactoring refactoring) {
  super(project, editor, refactoring);
  myRefactoring = refactoring;
  setTitle("Extract Widget");
  init();

  myNameField.setText("NewWidget");
  myNameField.selectAll();
  myNameField.getDocument().addDocumentListener(new DocumentAdapter() {
    @Override
    protected void textChanged(DocumentEvent e) {
      updateRefactoringOptions();
    }
  });

  updateRefactoringOptions();
}
 
Example #14
Source File: NamePathComponent.java    From consulo with Apache License 2.0 5 votes vote down vote up
public NameFieldDocument() {
  addDocumentListener(new DocumentAdapter() {
    @Override
    public void textChanged(DocumentEvent event) {
      myIsNameChangedByUser = true;
      syncNameAndPath();
    }
  });
}
 
Example #15
Source File: KeymapPanel.java    From consulo with Apache License 2.0 5 votes vote down vote up
public MyEditor() {
  getField().getDocument().addDocumentListener(new DocumentAdapter() {
    @Override
    protected void textChanged(DocumentEvent e) {
      if (myKeymap != null && myKeymap.canModify()) {
        myKeymap.setName(getField().getText());
      }
    }
  });
}
 
Example #16
Source File: ValueAccessor.java    From consulo with Apache License 2.0 5 votes vote down vote up
public static ControlValueAccessor textFieldAccessor(final JTextField from) {
  return new ControlValueAccessor<String>() {
    public String getValue() {
      return from.getText();
    }

    public void setValue(String value) {
      from.setText(value);
    }

    public Class<String> getType() {
      return String.class;
    }

    public boolean isEnabled() {
      return from.isEnabled();
    }

    public void addChangeListener(final Runnable listener) {
      from.getDocument().addDocumentListener(new DocumentAdapter() {
        @Override
        protected void textChanged(DocumentEvent e) {
          listener.run();
        }
      });
    }
  };
}
 
Example #17
Source File: FirefoxSettingsConfigurable.java    From consulo with Apache License 2.0 5 votes vote down vote up
public FirefoxSettingsConfigurable(FirefoxSettings settings) {
  mySettings = settings;
  myProfilesIniPathField.addBrowseFolderListener(IdeBundle.message("chooser.title.select.profiles.ini.file"), null, null, PROFILES_INI_CHOOSER_DESCRIPTOR);
  myProfilesIniPathField.getTextField().getDocument().addDocumentListener(new DocumentAdapter() {
    @Override
    protected void textChanged(DocumentEvent e) {
      updateProfilesList();
    }
  });
}
 
Example #18
Source File: TextFieldValueEditor.java    From consulo with Apache License 2.0 5 votes vote down vote up
public TextFieldValueEditor(@Nonnull JTextField field, @Nullable String valueName, @Nonnull T defaultValue) {
  super(valueName, defaultValue);
  myField = field;
  myField.getDocument().addDocumentListener(new DocumentAdapter() {
    @Override
    protected void textChanged(@Nonnull DocumentEvent e) {
      String errorText = validateTextOnChange(myField.getText(), e);
      highlightState(StringUtil.isEmpty(errorText));
      if (StringUtil.isNotEmpty(errorText)) {
        setErrorText(errorText);
      }
    }
  });
}
 
Example #19
Source File: LabeledTextComponent.java    From consulo with Apache License 2.0 5 votes vote down vote up
public void addCommentsListener(final TextListener l) {
  myTextPane.getDocument().addDocumentListener(new DocumentAdapter() {
    @Override
    protected void textChanged(DocumentEvent e) {
      l.textChanged(myTextPane.getText());
    }
  });
}
 
Example #20
Source File: SingleConfigurationConfigurable.java    From consulo with Apache License 2.0 5 votes vote down vote up
private SingleConfigurationConfigurable(RunnerAndConfigurationSettings settings, @Nullable Executor executor) {
  super(new ConfigurationSettingsEditorWrapper(settings), settings);
  myExecutor = executor;

  final Config configuration = getConfiguration();
  myDisplayName = getSettings().getName();
  myHelpTopic = "reference.dialogs.rundebug." + configuration.getType().getId();

  myBrokenConfiguration = configuration instanceof UnknownRunConfiguration;
  setFolderName(getSettings().getFolderName());

  setNameText(configuration.getName());
  myNameDocument.addDocumentListener(new DocumentAdapter() {
    @Override
    public void textChanged(DocumentEvent event) {
      setModified(true);
      if (!myChangingNameFromCode) {
        RunConfiguration runConfiguration = getSettings().getConfiguration();
        if (runConfiguration instanceof LocatableConfigurationBase) {
          ((LocatableConfigurationBase) runConfiguration).setNameChangedByUser(true);
        }
      }
    }
  });

  getEditor().addSettingsEditorListener(new SettingsEditorListener<RunnerAndConfigurationSettings>() {
    @Override
    public void stateChanged(SettingsEditor<RunnerAndConfigurationSettings> settingsEditor) {
      myValidationResultValid = false;
    }
  });
}
 
Example #21
Source File: NamePathComponent.java    From consulo with Apache License 2.0 5 votes vote down vote up
public void addChangeListener(final Runnable callback) {
  DocumentAdapter adapter = new DocumentAdapter() {
    @Override
    protected void textChanged(DocumentEvent e) {
      callback.run();
    }
  };
  myTfName.getDocument().addDocumentListener(adapter);
  myTfPath.getDocument().addDocumentListener(adapter);
}
 
Example #22
Source File: ListWithFilter.java    From consulo with Apache License 2.0 5 votes vote down vote up
private MySpeedSearch(boolean highlightAllOccurrences) {
  super(highlightAllOccurrences);
  // native mac "clear button" is not captured by SearchTextField.onFieldCleared
  mySearchField.addDocumentListener(new DocumentAdapter() {
    @Override
    protected void textChanged(@Nonnull DocumentEvent e) {
      if (myInUpdate) return;
      if (mySearchField.getText().isEmpty()) {
        mySpeedSearch.reset();
      }
    }
  });
  installSupplyTo(myList);
}
 
Example #23
Source File: NamePathComponent.java    From consulo with Apache License 2.0 5 votes vote down vote up
public PathFieldDocument() {
  addDocumentListener(new DocumentAdapter() {
    @Override
    public void textChanged(DocumentEvent event) {
      myIsPathChangedByUser = true;
      syncPathAndName();
    }
  });
}
 
Example #24
Source File: EditLogPatternDialog.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
protected JComponent createCenterPanel() {
  myFilePattern.addBrowseFolderListener(UIBundle.message("file.chooser.default.title"), null, null, FileChooserDescriptorFactory.createSingleFileOrFolderDescriptor(), TextComponentAccessor.TEXT_FIELD_WHOLE_TEXT);
  myFilePattern.getTextField().getDocument().addDocumentListener(new DocumentAdapter() {
    @Override
    protected void textChanged(DocumentEvent e) {
      setOKActionEnabled(myFilePattern.getText() != null && myFilePattern.getText().length() > 0);
    }
  });
  return myWholePanel;
}
 
Example #25
Source File: DocumentSwingValidator.java    From consulo with Apache License 2.0 5 votes vote down vote up
protected void addDocumentListenerForValidator(Document document) {
  document.addDocumentListener(new DocumentAdapter() {
    @Override
    protected void textChanged(DocumentEvent e) {
      myValidator.validateValue(toAWTComponent(), getPrevValue(e), true);
    }
  });
}
 
Example #26
Source File: DesktopTextBoxWithExpandAction.java    From consulo with Apache License 2.0 5 votes vote down vote up
private SupportedTextBoxWithExpandAction(Function<String, List<String>> parser, Function<List<String>, String> joiner, SupportTextBoxWithExpandActionExtender lookAndFeel) {
  ExpandableTextField field = new ExpandableTextField(parser::apply, joiner::apply, lookAndFeel);
  TextFieldPlaceholderFunction.install(field);
  initialize(field);
  addDocumentListenerForValidator(field.getDocument());

  field.getDocument().addDocumentListener(new DocumentAdapter() {
    @Override
    @SuppressWarnings("unchecked")
    @RequiredUIAccess
    protected void textChanged(DocumentEvent e) {
      getListenerDispatcher(ValueListener.class).valueChanged(new ValueEvent(SupportedTextBoxWithExpandAction.this, getValue()));
    }
  });
}
 
Example #27
Source File: DesktopTextBoxWithExtensions.java    From consulo with Apache License 2.0 5 votes vote down vote up
public Supported(String text) {
  initialize(new ExtendableTextField(text));
  TextFieldPlaceholderFunction.install(toAWTComponent());

  addDocumentListenerForValidator(toAWTComponent().getDocument());

  toAWTComponent().getDocument().addDocumentListener(new DocumentAdapter() {
    @Override
    @SuppressWarnings("unchecked")
    @RequiredUIAccess
    protected void textChanged(DocumentEvent e) {
      getListenerDispatcher(ValueListener.class).valueChanged(new ValueEvent(Supported.this, getValue()));
    }
  });
}
 
Example #28
Source File: JBTextArea.java    From consulo with Apache License 2.0 5 votes vote down vote up
public JBTextArea(Document doc, String text, int rows, int columns) {
  super(doc, text, rows, columns);

  myEmptyText = new TextComponentEmptyText(this) {
    @Override
    protected boolean isStatusVisible() {
      Object function = getClientProperty("StatusVisibleFunction");
      if (function instanceof BooleanFunction) {
        //noinspection unchecked
        return ((BooleanFunction<JTextComponent>)function).fun(JBTextArea.this);
      }
      return super.isStatusVisible();
    }

    @Override
    protected Rectangle getTextComponentBound() {
      Insets insets = ObjectUtils.notNull(getInsets(), JBUI.emptyInsets());
      Insets margin = ObjectUtils.notNull(getMargin(), JBUI.emptyInsets());
      Insets ipad = getComponent().getIpad();
      Dimension size = getSize();
      int left = insets.left + margin.left - ipad.left;
      int top = insets.top + margin.top - ipad.top;
      int right = size.width - (insets.right + margin.right - ipad.right);
      return new Rectangle(left, top, right - left, getRowHeight());
    }
  };

  getDocument().addDocumentListener(new DocumentAdapter() {
    @Override
    protected void textChanged(@Nonnull DocumentEvent e) {
      invalidate();
      revalidate();
      repaint();
    }
  });
}
 
Example #29
Source File: LogFilterTextField.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public LogFilterTextField() {
  super(true);
  addDocumentListener(new DocumentAdapter() {
    @Override
    protected void textChanged(@NotNull DocumentEvent e) {
      doFilterIfNeeded();
    }
  });
}
 
Example #30
Source File: FlutterSmallIDEGeneratorPeer.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
public void addSettingsStateListener(@NotNull WebProjectGenerator.SettingsStateListener stateListener) {
  final JTextComponent editorComponent = (JTextComponent)sdkPathComboWithBrowse.getComboBox().getEditor().getEditorComponent();
  editorComponent.getDocument().addDocumentListener(new DocumentAdapter() {
    protected void textChanged(DocumentEvent e) {
      stateListener.stateChanged(validate() == null);
    }
  });

  if (validate() != null) {
    stateListener.stateChanged(false);
  }
}