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();
}
};
}
Aggregations