package jetbrains.mps.build.mps.pluginSolution.plugin;
/*Generated by MPS */
import com.intellij.ide.wizard.StepAdapter;
import javax.swing.JPanel;
import java.awt.GridBagConstraints;
import java.awt.Insets;
import javax.swing.JComponent;
import java.awt.Dimension;
import org.jetbrains.annotations.NotNull;
import jetbrains.mps.util.annotation.ToRemove;
import java.awt.GridBagLayout;
import javax.swing.JLabel;
import javax.swing.border.EmptyBorder;
import jetbrains.mps.ide.common.LayoutUtil;
import javax.swing.border.CompoundBorder;
import javax.swing.border.EtchedBorder;
public abstract class AbstractStep extends StepAdapter {
protected JPanel myMainPanel;
public AbstractStep() {
}
@Override
public void _init() {
this.createComponent();
}
public GridBagConstraints createConstraint(int row, int wy) {
GridBagConstraints c = new GridBagConstraints();
c.fill = GridBagConstraints.HORIZONTAL;
c.gridx = 0;
c.gridy = row;
c.weightx = 1;
c.weighty = wy;
c.insets = new Insets(1, 0, 1, 0);
return c;
}
public abstract JComponent createMainComponent();
public abstract String getDescription();
@Override
public JComponent getComponent() {
this.createComponent();
return this.myMainPanel;
}
protected void createComponent() {
if (myMainPanel == null) {
myMainPanel = createStepPanel();
if (doLimitStepPanelHeight()) {
myMainPanel.setPreferredSize(new Dimension(myMainPanel.getPreferredSize().width, myMainPanel.getPreferredSize().height));
}
}
myMainPanel.doLayout();
}
@NotNull
@Deprecated
@ToRemove(version = 2017.1)
public String getImageText() {
// Not used any more
return "";
}
protected boolean doLimitStepPanelHeight() {
return false;
}
protected JPanel createStepPanel() {
JPanel stepPanel = new JPanel(new GridBagLayout());
JLabel label = new JLabel(this.getDescription());
label.setBorder(new EmptyBorder(5, 2, 10, 2));
stepPanel.add(label, LayoutUtil.createLabelConstraints(0));
JComponent mainComponent = this.createMainComponent();
mainComponent.setBorder(new CompoundBorder(new EtchedBorder(), new EmptyBorder(2, 2, 2, 2)));
stepPanel.add(mainComponent, LayoutUtil.createLabelConstraints(1));
stepPanel.add(new JPanel(), LayoutUtil.createPanelConstraints(2));
return stepPanel;
}
}