use of com.intellij.openapi.ui.TextFieldWithBrowseButton in project intellij-community by JetBrains.
the class ClassFilterEditorAddDialog method createCenterPanel.
protected JComponent createCenterPanel() {
final JPanel panel = new JPanel(new GridBagLayout());
final JLabel header = new JLabel(UIBundle.message("label.class.filter.editor.add.dialog.filter.pattern"));
myClassName = new TextFieldWithBrowseButton(new JTextField(35));
final JLabel iconLabel = new JLabel(Messages.getQuestionIcon());
panel.add(header, new GridBagConstraints(1, 0, 1, 1, 1.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, new Insets(5, 10, 0, 0), 0, 0));
panel.add(myClassName, new GridBagConstraints(1, 1, 1, 1, 1.0, 1.0, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, new Insets(5, 10, 0, 0), 0, 0));
panel.add(iconLabel, new GridBagConstraints(0, 0, 1, 2, 0.0, 1.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(15, 0, 0, 0), 0, 0));
myClassName.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
PsiClass currentClass = getSelectedClass();
TreeClassChooser chooser = TreeClassChooserFactory.getInstance(myProject).createNoInnerClassesScopeChooser(UIBundle.message("class.filter.editor.choose.class.title"), GlobalSearchScope.allScope(myProject), null, null);
if (currentClass != null) {
PsiFile containingFile = currentClass.getContainingFile();
if (containingFile != null) {
PsiDirectory containingDirectory = containingFile.getContainingDirectory();
if (containingDirectory != null) {
chooser.selectDirectory(containingDirectory);
}
}
}
chooser.showDialog();
PsiClass selectedClass = chooser.getSelected();
if (selectedClass != null) {
myClassName.setText(selectedClass.getQualifiedName());
}
}
});
myClassName.setEnabled(myProject != null);
return panel;
}
use of com.intellij.openapi.ui.TextFieldWithBrowseButton in project android by JetBrains.
the class ScopedDataBinderTest method testRegisterTextFieldWithBrowseButton.
public void testRegisterTextFieldWithBrowseButton() throws Exception {
Key<String> textKey = myState.createKey("textField", String.class);
Key<String> textKey2 = myState.createKey("boundSecond", String.class);
final Key<String> triggerKey = myState.createKey("triggerKey", String.class);
TextFieldWithBrowseButton textField = new TextFieldWithBrowseButton();
myScopedDataBinder.register(textKey, textField);
myScopedDataBinder.register(textKey2, textField);
// Test binding UI -> Store
textField.setText("Hello World!");
assertEquals("Hello World!", myState.get(textKey));
assertEquals("Hello World!", myState.get(textKey2));
// Test binding Store -> UI
myState.put(textKey, "Awesome");
assertEquals("Awesome", textField.getText());
assertEquals("Awesome", myState.get(textKey2));
myState.put(textKey2, "Goodbye");
assertEquals("Goodbye", textField.getText());
assertEquals("Goodbye", myState.get(textKey));
final AtomicBoolean respectsUserEdits = new AtomicBoolean(true);
// Test value derivation
myScopedDataBinder.registerValueDeriver(textKey, new ValueDeriver<String>() {
@Nullable
@Override
public Set<Key<?>> getTriggerKeys() {
return makeSetOf(triggerKey);
}
@Override
public boolean respectUserEdits() {
return respectsUserEdits.get();
}
@NotNull
@Override
public String deriveValue(ScopedStateStore state, Key changedKey, @Nullable String currentValue) {
String trigger = state.get(triggerKey);
if (trigger == null) {
return "UNEXPECTED NULL!";
} else {
return trigger.toUpperCase();
}
}
});
myState.put(triggerKey, "Some value to trigger update");
// The deriver does not fire because user edits are respected
assertEquals("Goodbye", textField.getText());
respectsUserEdits.set(false);
myState.put(triggerKey, "the quick brown fox");
// The deriver fires because user edits are not respected
assertEquals("THE QUICK BROWN FOX", textField.getText());
}
use of com.intellij.openapi.ui.TextFieldWithBrowseButton in project intellij-plugins by JetBrains.
the class CompilerOptionsConfigurable method createValueEditor.
private TableCellEditor createValueEditor() {
return new AbstractTableCellEditor() {
//private CellEditorComponentWithBrowseButton<JTextField> myTextWithBrowse;
//private LocalPathCellEditor myLocalPathCellEditor;
private final JTextField myTextField = new JTextField();
private final TextFieldWithBrowseButton myTextWithBrowse = new TextFieldWithBrowseButton();
private final RepeatableValueEditor myRepeatableValueEditor = new RepeatableValueEditor(myProject);
private final ExtensionAwareFileChooserDescriptor myFileChooserDescriptor = new ExtensionAwareFileChooserDescriptor();
private final JCheckBox myCheckBox = new JCheckBox();
{
myTextWithBrowse.addBrowseFolderListener(null, null, myProject, myFileChooserDescriptor);
myCheckBox.addActionListener(new ActionListener() {
public void actionPerformed(final ActionEvent e) {
// apply new check box state immediately
TableUtil.stopEditing(myTreeTable);
}
});
}
private Component myCurrentEditor;
public Component getTableCellEditorComponent(final JTable table, Object value, boolean isSelected, final int row, int column) {
assert value instanceof CompilerOptionInfo;
final CompilerOptionInfo info = (CompilerOptionInfo) value;
final Sdk sdk = myDependenciesConfigurable.getCurrentSdk();
final String sdkHome = sdk == null || sdk.getSdkType() == FlexmojosSdkType.getInstance() ? null : sdk.getHomePath();
final String optionValue = sdkHome == null ? getValueAndSource(info).first : getValueAndSource(info).first.replace(CompilerOptionInfo.FLEX_SDK_MACRO, sdkHome);
switch(info.TYPE) {
case Boolean:
myCheckBox.setBackground(table.getBackground());
myCheckBox.setSelected("true".equalsIgnoreCase(optionValue));
myCurrentEditor = myCheckBox;
break;
case List:
myRepeatableValueEditor.setInfoAndValue(info, optionValue);
myCurrentEditor = myRepeatableValueEditor;
break;
case String:
case Int:
case IncludeClasses:
case IncludeFiles:
myTextField.setText(optionValue);
myCurrentEditor = myTextField;
break;
case File:
myFileChooserDescriptor.setAllowedExtensions(info.FILE_EXTENSION);
myTextWithBrowse.setText(FileUtil.toSystemDependentName(optionValue));
myCurrentEditor = myTextWithBrowse;
break;
case Group:
default:
assert false;
}
return myCurrentEditor;
}
public Object getCellEditorValue() {
if (myCurrentEditor == myCheckBox) {
return String.valueOf(myCheckBox.isSelected());
}
if (myCurrentEditor == myTextField) {
return myTextField.getText().trim();
}
if (myCurrentEditor == myTextWithBrowse) {
final Sdk sdk = myDependenciesConfigurable.getCurrentSdk();
final String sdkHome = sdk == null || sdk.getSdkType() == FlexmojosSdkType.getInstance() ? null : sdk.getHomePath();
final String path = FileUtil.toSystemIndependentName(myTextWithBrowse.getText().trim());
return sdkHome == null ? path : path.replace(sdkHome, CompilerOptionInfo.FLEX_SDK_MACRO);
}
if (myCurrentEditor == myRepeatableValueEditor) {
final Sdk sdk = myDependenciesConfigurable.getCurrentSdk();
final String sdkHome = sdk == null ? null : sdk.getHomePath();
final String value = myRepeatableValueEditor.getValue();
return sdkHome == null ? value : value.replace(sdkHome, CompilerOptionInfo.FLEX_SDK_MACRO);
}
assert false;
return null;
}
};
}
use of com.intellij.openapi.ui.TextFieldWithBrowseButton in project android by JetBrains.
the class KeyValuePane method updateCurrentObjectFromUi.
/**
* Reads the state of the UI form objects and writes them into the currently selected object in the list, setting the dirty bit as
* appropriate.
*/
private void updateCurrentObjectFromUi() {
if (myIsUpdating || myCurrentBuildFileObject == null) {
return;
}
for (Map.Entry<BuildFileKey, JComponent> entry : myProperties.entrySet()) {
BuildFileKey key = entry.getKey();
JComponent component = entry.getValue();
Object currentValue = myCurrentBuildFileObject.get(key);
Object newValue;
BuildFileKeyType type = key.getType();
switch(type) {
case BOOLEAN:
{
ComboBox comboBox = (ComboBox) component;
JBTextField editorComponent = (JBTextField) comboBox.getEditor().getEditorComponent();
int index = comboBox.getSelectedIndex();
if (index == 2) {
newValue = Boolean.FALSE;
editorComponent.setForeground(JBColor.BLACK);
} else if (index == 1) {
newValue = Boolean.TRUE;
editorComponent.setForeground(JBColor.BLACK);
} else {
newValue = null;
editorComponent.setForeground(JBColor.GRAY);
}
break;
}
case FILE:
case FILE_AS_STRING:
{
newValue = ((TextFieldWithBrowseButton) component).getText();
if ("".equals(newValue)) {
newValue = null;
}
if (newValue != null) {
newValue = new File(newValue.toString());
}
break;
}
case INTEGER:
{
try {
if (hasKnownValues(key)) {
String newStringValue = ((ComboBox) component).getEditor().getItem().toString();
newStringValue = getMappedValue(myKeysWithKnownValues.get(key).inverse(), newStringValue);
newValue = Integer.valueOf(newStringValue);
} else {
newValue = Integer.valueOf(((JBTextField) component).getText());
}
} catch (Exception e) {
newValue = null;
}
break;
}
case REFERENCE:
{
newValue = ((ComboBox) component).getEditor().getItem();
String newStringValue = (String) newValue;
if (hasKnownValues(key)) {
newStringValue = getMappedValue(myKeysWithKnownValues.get(key).inverse(), newStringValue);
}
if (newStringValue != null && newStringValue.isEmpty()) {
newStringValue = null;
}
String prefix = getReferencePrefix(key);
if (newStringValue != null && !newStringValue.startsWith(prefix)) {
newStringValue = prefix + newStringValue;
}
newValue = newStringValue;
break;
}
case CLOSURE:
case STRING:
default:
{
if (hasKnownValues(key)) {
String newStringValue = ((ComboBox) component).getEditor().getItem().toString();
newStringValue = getMappedValue(myKeysWithKnownValues.get(key).inverse(), newStringValue);
if (newStringValue.isEmpty()) {
newStringValue = null;
}
newValue = newStringValue;
} else {
newValue = ((JBTextField) component).getText();
if ("".equals(newValue)) {
newValue = null;
}
}
if (type == BuildFileKeyType.CLOSURE && newValue != null) {
List newListValue = new ArrayList();
for (String s : Splitter.on(',').omitEmptyStrings().trimResults().split((String) newValue)) {
newListValue.add(key.getValueFactory().parse(s, myProject));
}
newValue = newListValue;
}
break;
}
}
if (!Objects.equal(currentValue, newValue)) {
if (newValue == null) {
myCurrentBuildFileObject.remove(key);
} else {
myCurrentBuildFileObject.put(key, newValue);
}
if (GradleBuildFile.shouldWriteValue(currentValue, newValue)) {
myListener.modified(key);
}
}
}
}
use of com.intellij.openapi.ui.TextFieldWithBrowseButton in project ServiceStack.Java by ServiceStack.
the class AddRef method $$$setupUI$$$.
/**
* Method generated by IntelliJ IDEA GUI Designer
* >>> IMPORTANT!! <<<
* DO NOT edit this method OR call it in your code!
*
* @noinspection ALL
*/
private void $$$setupUI$$$() {
contentPane = new JPanel();
contentPane.setLayout(new GridLayoutManager(3, 1, new Insets(10, 10, 10, 10), -1, -1));
contentPane.setMaximumSize(new Dimension(700, 420));
contentPane.setMinimumSize(new Dimension(400, 220));
contentPane.setOpaque(true);
contentPane.setPreferredSize(new Dimension(550, 220));
contentPane.setRequestFocusEnabled(true);
final JPanel panel1 = new JPanel();
panel1.setLayout(new GridLayoutManager(1, 2, new Insets(0, 0, 0, 0), -1, -1));
contentPane.add(panel1, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, 1, null, null, null, 0, false));
final Spacer spacer1 = new Spacer();
panel1.add(spacer1, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, null, null, 0, false));
final JPanel panel2 = new JPanel();
panel2.setLayout(new GridLayoutManager(1, 2, new Insets(0, 0, 0, 0), -1, -1, true, false));
panel1.add(panel2, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false));
buttonOK = new JButton();
buttonOK.setText("OK");
panel2.add(buttonOK, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
buttonCancel = new JButton();
buttonCancel.setText("Cancel");
panel2.add(buttonCancel, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
final JPanel panel3 = new JPanel();
panel3.setLayout(new GridLayoutManager(2, 1, new Insets(0, 0, 0, 0), -1, -1));
panel3.setFocusable(false);
contentPane.add(panel3, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false));
errorTextPane = new JTextPane();
errorTextPane.setEditable(false);
errorTextPane.setFocusCycleRoot(false);
errorTextPane.setFocusable(true);
errorTextPane.setFont(new Font("Arial", errorTextPane.getFont().getStyle(), errorTextPane.getFont().getSize()));
errorTextPane.setOpaque(false);
errorTextPane.setVisible(false);
panel3.add(errorTextPane, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_GROW, null, new Dimension(150, 25), null, 0, false));
infoTextPane = new JTextPane();
infoTextPane.setEditable(false);
infoTextPane.setFocusCycleRoot(false);
infoTextPane.setFocusable(false);
infoTextPane.setFont(new Font("Arial", infoTextPane.getFont().getStyle(), infoTextPane.getFont().getSize()));
infoTextPane.setOpaque(false);
infoTextPane.setRequestFocusEnabled(false);
infoTextPane.setText("To generate the DTO Service Model types for a specific ServiceStack instance, enter the base URI for the remote ServiceStack server and click OK.");
panel3.add(infoTextPane, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_GROW, null, new Dimension(150, 25), null, 0, false));
final JPanel panel4 = new JPanel();
panel4.setLayout(new GridLayoutManager(3, 3, new Insets(0, 0, 0, 0), -1, -1));
contentPane.add(panel4, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false));
final JLabel label1 = new JLabel();
label1.setText("Address Url");
panel4.add(label1, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
addressUrlTextField = new JTextField();
addressUrlTextField.setToolTipText("eg, http://example.com/");
panel4.add(addressUrlTextField, new GridConstraints(0, 1, 1, 2, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false));
final JLabel label2 = new JLabel();
label2.setText("Package");
panel4.add(label2, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
packageBrowse = new TextFieldWithBrowseButton();
panel4.add(packageBrowse, new GridConstraints(1, 1, 1, 2, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false));
final JLabel label3 = new JLabel();
label3.setText("Name");
panel4.add(label3, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
nameTextField = new JTextField();
nameTextField.setText("dtos.java");
panel4.add(nameTextField, new GridConstraints(2, 1, 1, 2, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false));
label1.setLabelFor(addressUrlTextField);
label3.setLabelFor(nameTextField);
}
Aggregations