public TaskCompletionProvider(@NotNull Project project, @NotNull ProjectSystemId externalSystemId, @NotNull TextAccessor workDirectoryField, @NotNull Options options) { super(options); myProject = project; mySystemId = externalSystemId; myProjectPathAccessor = workDirectoryField; }
/** * Retrieve a value from the given JComponent */ @Nullable protected Object getComponentValue(@NotNull JComponent component) { Object newValue = null; if (component instanceof JCheckBox) { newValue = ((JCheckBox)component).isSelected(); } else if (component instanceof JComboBox) { Object selectedObject = ((JComboBox)component).getSelectedItem(); if (selectedObject instanceof ComboBoxItem) { ComboBoxItem selectedItem = (ComboBoxItem)selectedObject; newValue = selectedItem.id; } else { newValue = selectedObject; } } else if (component instanceof JSlider) { newValue = ((JSlider)component).getValue(); } else if (component instanceof JSpinner) { newValue = ((JSpinner)component).getValue(); } else if (component instanceof ColorPanel) { newValue = ((ColorPanel)component).getSelectedColor(); } else { TextAccessor accessor = TextAccessors.getTextAccessor(component); if (accessor != null) { newValue = accessor.getText(); } } return newValue; }
protected void register(@NotNull Key<String> key, @NotNull final TextAccessor field) { assert field instanceof JComponent; JComponent component = (JComponent)field; String value = bindAndGet(key, component, null); if (value != null) { field.setText(value); } else { myState.put(key, field.getText()); } component.addFocusListener(this); }
@Nullable public static TextAccessor getTextAccessor(@NotNull final JComponent component) { if (component instanceof TextAccessor) { return (TextAccessor)component; } else if (component instanceof JTextComponent) { return new JTextComponentTextAccessor(component); } else if (component instanceof JLabel) { return new JLabelTextAccessor(component); } else { return null; } }
public static ActionListener createApplyPathAction(final TextAccessor textField, final String executable) { return new ActionListener() { @Override public void actionPerformed(ActionEvent e) { String guessedPath = ExecUtil.locateExecutableByGuessing(executable); if (guessedPath != null) { textField.setText(guessedPath); } else { Messages.showErrorDialog("Could not find '" + executable + "'.", "HaskForce"); } } }; }
CamelChosenIconCellRender(TextAccessor textAccessor) { this.textAccessor = textAccessor; }
public TaskCompletionProvider(@NotNull Project project, @NotNull ProjectSystemId externalSystemId, @NotNull TextAccessor workDirectoryField) { this(project, externalSystemId, workDirectoryField, new Options()); }
@Nullable protected String fromTextField(@NotNull TextAccessor textAccessor, @NotNull CommonProgramRunConfigurationParameters configuration) { return textAccessor.getText(); }
@Override public void actionPerformed(final ActionEvent e) { final String text = showDialog(); if (text != null) ((TextAccessor)myField).setText(text); }
public String getText() { return ((TextAccessor)myField).getText(); }
public GradleArgumentsCompletionProvider(@NotNull Project project, @NotNull TextAccessor workDirectoryField) { super(project, GradleConstants.SYSTEM_ID, workDirectoryField, GradleCommandLineOptionsProvider.getSupportedOptions()); }
public static void addApplyPathAction(final AbstractButton button, final TextAccessor textField, final String executable) { button.addActionListener(createApplyPathAction(textField, executable)); }
PropertyField(@NotNull String propertyKey, @NotNull TextAccessor field) { this(propertyKey, field, ""); }
PropertyField(@NotNull String propertyKey, @NotNull TextAccessor field, @NotNull String defaultValue) { this.propertyKey = propertyKey; this.field = field; this.oldValue = propertiesComponent.getValue(propertyKey, defaultValue); field.setText(oldValue); }
public void validateExecutable(String name, TextAccessor field) throws ConfigurationException { if (new File(field.getText()).canExecute()) return; throw new ConfigurationException("Not a valid '" + name + "' executable: '" + field.getText() + "'"); }
public void validateExecutableIfNonEmpty(String name, TextAccessor field) throws ConfigurationException { if (field.getText().isEmpty()) return; validateExecutable(name, field); }
private void validateExecutable(String name, TextAccessor field) throws ConfigurationException { if (new File(field.getText()).canExecute() || new File(myProject.getBasePath(), field.getText()).exists()) return; throw new ConfigurationException("Not a valid '" + name + "' executable: '" + field.getText() + "'"); }
private void validateFileExists(String name, TextAccessor field) throws ConfigurationException { if (new File(field.getText()).exists() || new File(myProject.getBasePath(), field.getText()).exists()) return; throw new ConfigurationException("'" + name + "' file does not exist: '" + field.getText() + "'"); }
public TextAccessor getWorkingDirectoryAccessor() { return myWorkingDirectoryComboBox; }
@Nullable protected String fromTextField(@Nonnull TextAccessor textAccessor, @Nonnull CommonProgramRunConfigurationParameters configuration) { return textAccessor.getText(); }