use of com.intellij.openapi.ui.ComponentWithBrowseButton in project intellij-plugins by JetBrains.
the class CompilerOptionsConfigurable method createValueRenderer.
private TableCellRenderer createValueRenderer() {
return new TableCellRenderer() {
private final JLabel myLabel = new JLabel();
private final JCheckBox myCheckBox = new JCheckBox();
private final ComponentWithBrowseButton<JLabel> myLabelWithBrowse = new ComponentWithBrowseButton<>(new JLabel(), null);
public Component getTableCellRendererComponent(JTable table, Object value, boolean selected, boolean hasFocus, int row, int column) {
if (!(value instanceof CompilerOptionInfo)) {
// invisible root node or group node
myLabel.setText("");
return myLabel;
}
final CompilerOptionInfo info = (CompilerOptionInfo) value;
final Pair<String, ValueSource> valueAndSource = getValueAndSource(info);
switch(info.TYPE) {
case Boolean:
myCheckBox.setBackground(table.getBackground());
//myCheckBox.setForeground(UIUtil.getTableForeground());
//myCheckBox.setEnabled(moduleDefault || fromConfigFile || custom);
myCheckBox.setSelected("true".equalsIgnoreCase(valueAndSource.first));
return myCheckBox;
case String:
case Int:
case List:
case IncludeClasses:
case IncludeFiles:
myLabel.setBackground(table.getBackground());
myLabel.setText(getPresentableSummary(valueAndSource.first, info));
renderAccordingToSource(myLabel, valueAndSource.second, false);
return myLabel;
case File:
final JLabel label = myLabelWithBrowse.getChildComponent();
myLabelWithBrowse.setBackground(table.getBackground());
label.setText(FileUtil.toSystemDependentName(valueAndSource.first));
renderAccordingToSource(label, valueAndSource.second, false);
return myLabelWithBrowse;
case Group:
default:
assert false;
return null;
}
}
};
}
use of com.intellij.openapi.ui.ComponentWithBrowseButton in project ballerina by ballerina-lang.
the class BallerinaRunUtil method installFileChooser.
private static void installFileChooser(@NotNull Project project, @NotNull ComponentWithBrowseButton field, @Nullable Condition<VirtualFile> fileFilter) {
FileChooserDescriptor chooseDirectoryDescriptor = FileChooserDescriptorFactory.createSingleFileDescriptor(BallerinaFileType.INSTANCE);
chooseDirectoryDescriptor.setRoots(project.getBaseDir());
chooseDirectoryDescriptor.setShowFileSystemRoots(false);
chooseDirectoryDescriptor.withShowHiddenFiles(false);
chooseDirectoryDescriptor.withFileFilter(fileFilter);
if (field instanceof TextFieldWithBrowseButton) {
((TextFieldWithBrowseButton) field).addBrowseFolderListener(new TextBrowseFolderListener(chooseDirectoryDescriptor, project));
} else {
// noinspection unchecked
field.addBrowseFolderListener(project, new ComponentWithBrowseButton.BrowseFolderActionListener(null, null, field, project, chooseDirectoryDescriptor, TextComponentAccessor.TEXT_FIELD_WITH_HISTORY_WHOLE_TEXT));
}
}
use of com.intellij.openapi.ui.ComponentWithBrowseButton in project go-lang-idea-plugin by go-lang-plugin-org.
the class GoRunUtil method installFileChooser.
public static void installFileChooser(@NotNull Project project, @NotNull ComponentWithBrowseButton field, boolean directory, boolean showFileSystemRoots, @Nullable Condition<VirtualFile> fileFilter) {
FileChooserDescriptor chooseDirectoryDescriptor = directory ? FileChooserDescriptorFactory.createSingleFolderDescriptor() : FileChooserDescriptorFactory.createSingleLocalFileDescriptor();
chooseDirectoryDescriptor.setRoots(project.getBaseDir());
chooseDirectoryDescriptor.setShowFileSystemRoots(showFileSystemRoots);
chooseDirectoryDescriptor.withFileFilter(fileFilter);
if (field instanceof TextFieldWithBrowseButton) {
((TextFieldWithBrowseButton) field).addBrowseFolderListener(new TextBrowseFolderListener(chooseDirectoryDescriptor, project));
} else {
// noinspection unchecked
field.addBrowseFolderListener(project, new ComponentWithBrowseButton.BrowseFolderActionListener(null, null, field, project, chooseDirectoryDescriptor, TextComponentAccessor.TEXT_FIELD_WITH_HISTORY_WHOLE_TEXT));
}
}
use of com.intellij.openapi.ui.ComponentWithBrowseButton in project intellij-community by JetBrains.
the class MavenEnvironmentForm method createUIComponents.
private void createUIComponents() {
mavenHomeField = new TextFieldWithHistory();
mavenHomeField.setHistorySize(-1);
final ArrayList<String> foundMavenHomes = new ArrayList<>();
foundMavenHomes.add(MavenServerManager.BUNDLED_MAVEN_2);
foundMavenHomes.add(MavenServerManager.BUNDLED_MAVEN_3);
final File mavenHomeDirectory = MavenUtil.resolveMavenHomeDirectory(null);
if (mavenHomeDirectory != null) {
foundMavenHomes.add(FileUtil.toSystemIndependentName(mavenHomeDirectory.getPath()));
}
mavenHomeField.setHistory(foundMavenHomes);
mavenHomeComponent = LabeledComponent.create(new ComponentWithBrowseButton<>(mavenHomeField, null), "Maven &home directory");
final JBLabel versionLabel = new JBLabel();
versionLabel.setOpaque(true);
versionLabel.setVerticalAlignment(SwingConstants.TOP);
versionLabel.setVerticalTextPosition(SwingConstants.TOP);
mavenVersionLabelComponent = LabeledComponent.create(versionLabel, "");
}
use of com.intellij.openapi.ui.ComponentWithBrowseButton in project intellij-community by JetBrains.
the class GenerateGetterSetterHandlerBase method getHeaderPanel.
protected static JComponent getHeaderPanel(final Project project, final TemplatesManager templatesManager, final String templatesTitle) {
final JPanel panel = new JPanel(new BorderLayout());
final JLabel templateChooserLabel = new JLabel(templatesTitle);
panel.add(templateChooserLabel, BorderLayout.WEST);
final ComboBox comboBox = new ComboBox();
templateChooserLabel.setLabelFor(comboBox);
comboBox.setRenderer(new ListCellRendererWrapper<TemplateResource>() {
@Override
public void customize(JList list, TemplateResource value, int index, boolean selected, boolean hasFocus) {
setText(value.getName());
}
});
final ComponentWithBrowseButton<ComboBox> comboBoxWithBrowseButton = new ComponentWithBrowseButton<>(comboBox, new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
final TemplatesPanel ui = new TemplatesPanel(project, templatesManager) {
@Override
protected boolean onMultipleFields() {
return false;
}
@Nls
@Override
public String getDisplayName() {
return StringUtil.capitalizeWords(UIUtil.removeMnemonic(StringUtil.trimEnd(templatesTitle, ":")), true);
}
};
ui.setHint("Visibility is applied according to File | Settings | Editor | Code Style | Java | Code Generation");
ui.selectNodeInTree(templatesManager.getDefaultTemplate());
if (ShowSettingsUtil.getInstance().editConfigurable(panel, ui)) {
setComboboxModel(templatesManager, comboBox);
}
}
});
setComboboxModel(templatesManager, comboBox);
comboBox.addActionListener(new ActionListener() {
public void actionPerformed(@NotNull final ActionEvent M) {
templatesManager.setDefaultTemplate((TemplateResource) comboBox.getSelectedItem());
}
});
panel.add(comboBoxWithBrowseButton, BorderLayout.CENTER);
return panel;
}
Aggregations