Search in sources :

Example 1 with LanguagePerFileMappings

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;
}
Also used : com.intellij.openapi.util(com.intellij.openapi.util) VirtualFileWindow(com.intellij.injected.editor.VirtualFileWindow) UIUtil(com.intellij.util.ui.UIUtil) AbstractTableCellEditor(com.intellij.util.ui.AbstractTableCellEditor) java.util(java.util) VirtualFile(com.intellij.openapi.vfs.VirtualFile) ProjectFileIndex(com.intellij.openapi.roots.ProjectFileIndex) javax.swing.table(javax.swing.table) LanguagePerFileMappings(com.intellij.lang.LanguagePerFileMappings) PerFileMappingsBase(com.intellij.lang.PerFileMappingsBase) ContainerUtil(com.intellij.util.containers.ContainerUtil) JBLabel(com.intellij.ui.components.JBLabel) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) JBUI(com.intellij.util.ui.JBUI) Project(com.intellij.openapi.project.Project) SpeedSearchUtil(com.intellij.ui.speedSearch.SpeedSearchUtil) FileChooserDescriptor(com.intellij.openapi.fileChooser.FileChooserDescriptor) Messages(com.intellij.openapi.ui.Messages) PerFileMappings(com.intellij.lang.PerFileMappings) FileUtil(com.intellij.openapi.util.io.FileUtil) ComboBoxAction(com.intellij.openapi.actionSystem.ex.ComboBoxAction) TIntArrayList(gnu.trove.TIntArrayList) CustomComponentAction(com.intellij.openapi.actionSystem.ex.CustomComponentAction) VfsUtilCore(com.intellij.openapi.vfs.VfsUtilCore) StringUtil(com.intellij.openapi.util.text.StringUtil) Configurable(com.intellij.openapi.options.Configurable) KeymapUtil(com.intellij.openapi.keymap.KeymapUtil) com.intellij.ui(com.intellij.ui) Collectors(java.util.stream.Collectors) JBPopup(com.intellij.openapi.ui.popup.JBPopup) MouseEvent(java.awt.event.MouseEvent) File(java.io.File) java.awt(java.awt) com.intellij.openapi.actionSystem(com.intellij.openapi.actionSystem) JBTable(com.intellij.ui.table.JBTable) Nullable(org.jetbrains.annotations.Nullable) DumbAwareAction(com.intellij.openapi.project.DumbAwareAction) List(java.util.List) IdeBorderFactory(com.intellij.ui.IdeBorderFactory) JBPopupFactory(com.intellij.openapi.ui.popup.JBPopupFactory) ConfigurationException(com.intellij.openapi.options.ConfigurationException) com.intellij.util(com.intellij.util) NotNull(org.jetbrains.annotations.NotNull) SimpleDataContext(com.intellij.openapi.actionSystem.impl.SimpleDataContext) FileChooser(com.intellij.openapi.fileChooser.FileChooser) SearchableConfigurable(com.intellij.openapi.options.SearchableConfigurable) javax.swing(javax.swing) JBLabel(com.intellij.ui.components.JBLabel) LanguagePerFileMappings(com.intellij.lang.LanguagePerFileMappings) Nullable(org.jetbrains.annotations.Nullable)

Aggregations

VirtualFileWindow (com.intellij.injected.editor.VirtualFileWindow)1 LanguagePerFileMappings (com.intellij.lang.LanguagePerFileMappings)1 PerFileMappings (com.intellij.lang.PerFileMappings)1 PerFileMappingsBase (com.intellij.lang.PerFileMappingsBase)1 com.intellij.openapi.actionSystem (com.intellij.openapi.actionSystem)1 ComboBoxAction (com.intellij.openapi.actionSystem.ex.ComboBoxAction)1 CustomComponentAction (com.intellij.openapi.actionSystem.ex.CustomComponentAction)1 SimpleDataContext (com.intellij.openapi.actionSystem.impl.SimpleDataContext)1 FileChooser (com.intellij.openapi.fileChooser.FileChooser)1 FileChooserDescriptor (com.intellij.openapi.fileChooser.FileChooserDescriptor)1 KeymapUtil (com.intellij.openapi.keymap.KeymapUtil)1 Configurable (com.intellij.openapi.options.Configurable)1 ConfigurationException (com.intellij.openapi.options.ConfigurationException)1 SearchableConfigurable (com.intellij.openapi.options.SearchableConfigurable)1 DumbAwareAction (com.intellij.openapi.project.DumbAwareAction)1 Project (com.intellij.openapi.project.Project)1 ProjectFileIndex (com.intellij.openapi.roots.ProjectFileIndex)1 Messages (com.intellij.openapi.ui.Messages)1 JBPopup (com.intellij.openapi.ui.popup.JBPopup)1 JBPopupFactory (com.intellij.openapi.ui.popup.JBPopupFactory)1