Search in sources :

Example 1 with GenerateTemplateConfigurable

use of org.jetbrains.java.generate.view.GenerateTemplateConfigurable in project intellij-community by JetBrains.

the class EqualsHashCodeTemplatesPanel method createConfigurable.

@Override
protected UnnamedConfigurable createConfigurable(Couple<TemplateResource> item) {
    final GenerateTemplateConfigurable equalsConfigurable = new GenerateTemplateConfigurable(item.first, GenerateEqualsHelper.getEqualsImplicitVars(myProject), myProject);
    final GenerateTemplateConfigurable hashCodeConfigurable = new GenerateTemplateConfigurable(item.second, GenerateEqualsHelper.getHashCodeImplicitVars(), myProject);
    return new UnnamedConfigurable() {

        @Nullable
        @Override
        public JComponent createComponent() {
            final Splitter splitter = new Splitter(true);
            final JPanel eqPanel = new JPanel(new BorderLayout());
            eqPanel.add(new TitledSeparator("Equals Template:"), BorderLayout.NORTH);
            final JComponent eqPane = equalsConfigurable.createComponent();
            eqPane.setPreferredSize(JBUI.size(300, 200));
            eqPanel.add(eqPane, BorderLayout.CENTER);
            splitter.setFirstComponent(eqPanel);
            final JPanel hcPanel = new JPanel(new BorderLayout());
            hcPanel.add(new TitledSeparator("HashCode Template:"), BorderLayout.NORTH);
            final JComponent hcPane = hashCodeConfigurable.createComponent();
            hcPane.setPreferredSize(JBUI.size(300, 200));
            hcPanel.add(hcPane, BorderLayout.CENTER);
            splitter.setSecondComponent(hcPanel);
            return splitter;
        }

        @Override
        public boolean isModified() {
            return equalsConfigurable.isModified() || hashCodeConfigurable.isModified();
        }

        @Override
        public void apply() throws ConfigurationException {
            equalsConfigurable.apply();
            hashCodeConfigurable.apply();
        }

        @Override
        public void reset() {
            equalsConfigurable.reset();
            hashCodeConfigurable.reset();
        }

        @Override
        public void disposeUIResources() {
            equalsConfigurable.disposeUIResources();
            hashCodeConfigurable.disposeUIResources();
        }
    };
}
Also used : Splitter(com.intellij.openapi.ui.Splitter) TitledSeparator(com.intellij.ui.TitledSeparator) UnnamedConfigurable(com.intellij.openapi.options.UnnamedConfigurable) GenerateTemplateConfigurable(org.jetbrains.java.generate.view.GenerateTemplateConfigurable)

Aggregations

UnnamedConfigurable (com.intellij.openapi.options.UnnamedConfigurable)1 Splitter (com.intellij.openapi.ui.Splitter)1 TitledSeparator (com.intellij.ui.TitledSeparator)1 GenerateTemplateConfigurable (org.jetbrains.java.generate.view.GenerateTemplateConfigurable)1