package gov.nasa.jpl.mbee.mdk.ui;
import com.nomagic.magicdraw.core.Application;
import javax.swing.*;
import java.awt.*;
import java.util.List;
/**
* Created by ablack on 1/17/17.
*/
public class ViewEditorLinkForm extends JFrame {
private JPanel buttonPanel;
private JPanel rootPanel;
private JScrollPane scrollPane;
private static final int DISPLAYED_LINKS = 4;
public ViewEditorLinkForm(String label, List<JButton> buttons) {
super(label);
buttonPanel.setLayout(new GridLayout(0, 1, 0, 2));
for (JButton button : buttons) {
buttonPanel.add(button);
}
buttonPanel.setPreferredSize(new Dimension(320, buttons.size() * 25));
scrollPane.setPreferredSize(new Dimension(340, Math.min(DISPLAYED_LINKS, buttons.size()) * 25 + 4));
rootPanel.setPreferredSize(new Dimension(360, scrollPane.getPreferredSize().height + 12));
setContentPane(rootPanel);
setLocationRelativeTo(Application.getInstance().getMainFrame());
pack();
setMinimumSize(getSize());
setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
setResizable(false);
// setAlwaysOnTop(true);
}
{
// GUI initializer generated by IntelliJ IDEA GUI Designer
// >>> IMPORTANT!! <<<
// DO NOT EDIT OR ADD ANY CODE HERE!
$$$setupUI$$$();
}
/**
* Method generated by IntelliJ IDEA GUI Designer
* >>> IMPORTANT!! <<<
* DO NOT edit this method OR call it in your code!
*
* @noinspection ALL
*/
private void $$$setupUI$$$() {
rootPanel = new JPanel();
rootPanel.setLayout(new GridBagLayout());
rootPanel.setMaximumSize(new Dimension(406, 404));
rootPanel.setMinimumSize(new Dimension(406, 20));
rootPanel.setPreferredSize(new Dimension(406, 20));
rootPanel.setRequestFocusEnabled(true);
scrollPane = new JScrollPane();
scrollPane.setHorizontalScrollBarPolicy(31);
scrollPane.setMaximumSize(new Dimension(300, 400));
scrollPane.setMinimumSize(new Dimension(300, 20));
scrollPane.setPreferredSize(new Dimension(300, 20));
scrollPane.setVerticalScrollBarPolicy(20);
GridBagConstraints gbc;
gbc = new GridBagConstraints();
gbc.gridx = 0;
gbc.gridy = 0;
gbc.weightx = 1.0;
gbc.weighty = 1.0;
gbc.anchor = GridBagConstraints.NORTH;
gbc.insets = new Insets(6, 6, 6, 6);
rootPanel.add(scrollPane, gbc);
buttonPanel = new JPanel();
buttonPanel.setLayout(new GridBagLayout());
buttonPanel.setAutoscrolls(false);
buttonPanel.setMaximumSize(new Dimension(280, 400));
buttonPanel.setMinimumSize(new Dimension(280, 20));
buttonPanel.setOpaque(true);
buttonPanel.setPreferredSize(new Dimension(280, 20));
scrollPane.setViewportView(buttonPanel);
}
/**
* @noinspection ALL
*/
public JComponent $$$getRootComponent$$$() {
return rootPanel;
}
}