use of com.intellij.lang.LanguagePerFileMappings in project intellij-community by JetBrains.
the class PerFileConfigurableBase method createDefaultMappingComponent.
@Nullable
protected JComponent createDefaultMappingComponent() {
myDefaultProps.addAll(getDefaultMappings());
if (myMappings instanceof LanguagePerFileMappings && param(ADD_PROJECT_MAPPING)) {
myDefaultProps.add(Trinity.create("Project " + StringUtil.capitalize(param(MAPPING_TITLE)), () -> ((LanguagePerFileMappings<T>) myMappings).getConfiguredMapping(null), o -> myMappings.setMapping(null, o)));
}
if (myDefaultProps.size() == 0)
return null;
JPanel panel = new JPanel(new GridBagLayout());
GridBagConstraints cons1 = new GridBagConstraints();
cons1.fill = GridBagConstraints.HORIZONTAL;
cons1.weightx = 0;
cons1.gridx = 0;
cons1.insets = JBUI.insets(0, 0, 5, UIUtil.DEFAULT_HGAP);
GridBagConstraints cons2 = new GridBagConstraints();
cons2.fill = GridBagConstraints.NONE;
cons2.anchor = GridBagConstraints.WEST;
cons2.weightx = 0;
cons2.gridx = 1;
cons2.insets = cons1.insets;
panel.add(Box.createGlue(), new GridBagConstraints(2, 0, 1, 1, 1., 1., GridBagConstraints.CENTER, GridBagConstraints.NONE, JBUI.emptyInsets(), 0, 0));
for (Trinity<String, Producer<T>, Consumer<T>> prop : myDefaultProps) {
myDefaultVals.put(prop.first, prop.second.produce());
JPanel p = createActionPanel(null, new Value<T>() {
@Override
public void commit() {
myModel.fireTableDataChanged();
}
@Override
public T get() {
return myDefaultVals.get(prop.first);
}
@Override
public void set(T value) {
myDefaultVals.put(prop.first, adjustChosenValue(null, value));
}
});
panel.add(new JBLabel(prop.first + ":"), cons1);
panel.add(p, cons2);
}
return panel;
}
Aggregations