use of com.intellij.ui.ComboboxWithBrowseButton in project android by JetBrains.
the class EmulatorTargetConfigurable method createUIComponents.
private void createUIComponents() {
myAvdCombo = new AvdComboBox(myProject, true, false) {
@Override
public Module getModule() {
return myContext.getModule();
}
};
myAvdCombo.startUpdatingAvds(ModalityState.current());
JComboBox avdComboBox = myAvdCombo.getComboBox();
avdComboBox.setRenderer(new ListCellRendererWrapper() {
@Override
public void customize(JList list, Object value, int index, boolean selected, boolean hasFocus) {
if (value instanceof IdDisplay) {
setText(((IdDisplay) value).getDisplay());
} else {
setText(String.format("<html><font color='red'>Unknown AVD %1$s</font></html>", value == null ? "" : value.toString()));
}
}
});
avdComboBox.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
resetAvdCompatibilityWarningLabel();
}
});
myAvdComboWithButton = new ComboboxWithBrowseButton(avdComboBox);
Disposer.register(myParentDisposable, myAvdCombo);
}
use of com.intellij.ui.ComboboxWithBrowseButton in project intellij-community by JetBrains.
the class ExternalToolsCheckinHandlerFactory method createHandler.
@NotNull
@Override
public CheckinHandler createHandler(@NotNull final CheckinProjectPanel panel, @NotNull CommitContext commitContext) {
final ToolsProjectConfig config = ToolsProjectConfig.getInstance(panel.getProject());
return new CheckinHandler() {
@Override
public RefreshableOnComponent getAfterCheckinConfigurationPanel(Disposable parentDisposable) {
final JLabel label = new JLabel(ToolsBundle.message("tools.after.commit.description"));
ComboboxWithBrowseButton listComponent = new ComboboxWithBrowseButton();
final JComboBox comboBox = listComponent.getComboBox();
comboBox.setModel(new CollectionComboBoxModel(getComboBoxElements(), null));
comboBox.setRenderer(new ListCellRendererWrapper<Object>() {
@Override
public void customize(JList list, Object value, int index, boolean selected, boolean hasFocus) {
if (value instanceof ToolsGroup) {
setText(StringUtil.notNullize(((ToolsGroup) value).getName(), ToolsBundle.message("tools.unnamed.group")));
} else if (value instanceof Tool) {
setText(" " + StringUtil.notNullize(((Tool) value).getName()));
} else {
setText(ToolsBundle.message("tools.list.item.none"));
}
}
});
listComponent.getButton().addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
final Object item = comboBox.getSelectedItem();
String id = null;
if (item instanceof Tool) {
id = ((Tool) item).getActionId();
}
final ToolSelectDialog dialog = new ToolSelectDialog(panel.getProject(), id, new ToolsPanel());
if (!dialog.showAndGet()) {
return;
}
comboBox.setModel(new CollectionComboBoxModel(getComboBoxElements(), dialog.getSelectedTool()));
}
});
BorderLayout layout = new BorderLayout();
layout.setVgap(3);
final JPanel panel = new JPanel(layout);
panel.add(label, BorderLayout.NORTH);
panel.add(listComponent, BorderLayout.CENTER);
listComponent.setBorder(BorderFactory.createEmptyBorder(0, 0, 3, 0));
if (comboBox.getItemCount() == 0 || (comboBox.getItemCount() == 1 && comboBox.getItemAt(0) == NONE_TOOL)) {
return null;
}
return new RefreshableOnComponent() {
@Override
public JComponent getComponent() {
return panel;
}
@Override
public void refresh() {
String id = config.getAfterCommitToolsId();
if (id == null) {
comboBox.setSelectedIndex(-1);
} else {
for (int i = 0; i < comboBox.getItemCount(); i++) {
final Object itemAt = comboBox.getItemAt(i);
if (itemAt instanceof Tool && id.equals(((Tool) itemAt).getActionId())) {
comboBox.setSelectedIndex(i);
return;
}
}
}
}
@Override
public void saveState() {
Object item = comboBox.getSelectedItem();
config.setAfterCommitToolId(item instanceof Tool ? ((Tool) item).getActionId() : null);
}
@Override
public void restoreState() {
refresh();
}
};
}
@Override
public void checkinSuccessful() {
final String id = config.getAfterCommitToolsId();
if (id == null) {
return;
}
DataManager.getInstance().getDataContextFromFocus().doWhenDone(new Consumer<DataContext>() {
@Override
public void consume(final DataContext context) {
UIUtil.invokeAndWaitIfNeeded(new Runnable() {
@Override
public void run() {
ToolAction.runTool(id, context);
}
});
}
});
}
};
}
use of com.intellij.ui.ComboboxWithBrowseButton in project intellij by bazelbuild.
the class BlazeCreateResourceFileDialog method setupUi.
/**
* Initially generated by IntelliJ from a .form file.
*/
private void setupUi() {
myPanel = new JPanel();
myPanel.setLayout(new GridLayoutManager(7, 3, new Insets(0, 0, 0, 0), -1, -1));
myPanel.setPreferredSize(new Dimension(800, 400));
myFileNameLabel = new JLabel();
myFileNameLabel.setText("File name:");
myFileNameLabel.setDisplayedMnemonic('F');
myFileNameLabel.setDisplayedMnemonicIndex(0);
myPanel.add(myFileNameLabel, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
myFileNameField = new JTextField();
myPanel.add(myFileNameField, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false));
myResTypeLabel = new JLabel();
myResTypeLabel.setText("Resource type:");
myResTypeLabel.setDisplayedMnemonic('R');
myResTypeLabel.setDisplayedMnemonicIndex(0);
myPanel.add(myResTypeLabel, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
myUpDownHint = new JLabel();
myUpDownHint.setToolTipText("Pressing Up or Down arrows while in editor changes the kind");
myPanel.add(myUpDownHint, new GridConstraints(0, 2, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
myResourceTypeCombo = new TemplateKindCombo();
myPanel.add(myResourceTypeCombo, new GridConstraints(1, 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));
myDeviceConfiguratorWrapper = new JPanel();
myDeviceConfiguratorWrapper.setLayout(new BorderLayout(0, 0));
myPanel.add(myDeviceConfiguratorWrapper, new GridConstraints(5, 0, 1, 3, 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));
myErrorLabel = new JBLabel();
myPanel.add(myErrorLabel, new GridConstraints(6, 0, 1, 3, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
final JBLabel jBLabel1 = new JBLabel();
jBLabel1.setText("Sub-directory:");
jBLabel1.setDisplayedMnemonic('Y');
jBLabel1.setDisplayedMnemonicIndex(12);
myPanel.add(jBLabel1, new GridConstraints(4, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
myDirectoryNameTextField = new JTextField();
myDirectoryNameTextField.setEditable(true);
myDirectoryNameTextField.setEnabled(true);
myPanel.add(myDirectoryNameTextField, new GridConstraints(4, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false));
myRootElementLabel = new JBLabel();
myRootElementLabel.setText("Root element:");
myRootElementLabel.setDisplayedMnemonic('E');
myRootElementLabel.setDisplayedMnemonicIndex(5);
myPanel.add(myRootElementLabel, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
myRootElementFieldWrapper = new JPanel();
myRootElementFieldWrapper.setLayout(new BorderLayout(0, 0));
myPanel.add(myRootElementFieldWrapper, new GridConstraints(2, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
myResDirLabel = new JBLabel();
myResDirLabel.setText("Base directory:");
myResDirLabel.setDisplayedMnemonic('B');
myResDirLabel.setDisplayedMnemonicIndex(0);
myPanel.add(myResDirLabel, new GridConstraints(3, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
myResDirCombo = new ComboboxWithBrowseButton();
myPanel.add(myResDirCombo, new GridConstraints(3, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
myFileNameLabel.setLabelFor(myFileNameField);
jBLabel1.setLabelFor(myDirectoryNameTextField);
}
Aggregations