22import java.awt.Component;
23import java.awt.Dimension;
24import java.awt.FlowLayout;
25import java.awt.GridLayout;
26import java.awt.event.ActionEvent;
27import java.awt.event.ActionListener;
28import java.util.ArrayList;
29import java.util.Arrays;
32import javax.swing.BoxLayout;
33import javax.swing.DefaultComboBoxModel;
34import javax.swing.GroupLayout;
35import javax.swing.JButton;
36import javax.swing.JComboBox;
37import javax.swing.JLabel;
38import javax.swing.JOptionPane;
39import javax.swing.JPanel;
40import javax.swing.JRadioButton;
41import javax.swing.JScrollPane;
42import javax.swing.JTable;
43import javax.swing.SwingConstants;
44import javax.swing.UIManager;
45import javax.swing.table.DefaultTableModel;
46import javax.swing.table.JTableHeader;
48import denoptim.exception.DENOPTIMException;
49import denoptim.graph.APClass;
50import denoptim.graph.EmptyVertex;
51import denoptim.graph.Vertex.BBType;
105 cmbBBType.setModel(
new DefaultComboBoxModel<BBType>(bt));
129 @SuppressWarnings(
"serial")
132 super(refForPlacement);
134 setTitle(
"Create Empty Vertex");
139 JPanel titleAPs =
new JPanel(
new FlowLayout(FlowLayout.LEFT));
140 titleAPs.add(
new JLabel(
"Attachment Points:"));
145 public boolean isCellEditable(
int row,
int column) {
157 String column_names[]= {
"<html><b>AP#</b></html>",
"<html><b>APClass</b></html>"};
158 apTabModel.setColumnIdentifiers(column_names);
160 apTable.putClientProperty(
"terminateEditOnFocusLost",
true);
161 apTable.getColumnModel().getColumn(0).setMaxWidth(75);
162 apTable.setGridColor(Color.LIGHT_GRAY);
163 JTableHeader apTabHeader =
apTable.getTableHeader();
164 apTabHeader.setPreferredSize(
new Dimension(100, 20));
166 apTabPanel.setMaximumSize(
new Dimension(400, 150));
170 btnAPInsert.setToolTipText(
"Click to add an attachment point.");
171 btnAPInsert.addActionListener(
new ActionListener(){
172 public void actionPerformed(ActionEvent e){
173 List<APClass> selectedAPCs =
176 for (
APClass apc : selectedAPCs)
185 btnAPDelete.setToolTipText(
"Remove all selected APs from list.");
186 btnAPDelete.addActionListener(
new ActionListener(){
187 public void actionPerformed(ActionEvent e){
190 if (
apTable.getSelectedRowCount() > 0)
192 int selectedRowIds[] =
apTable.getSelectedRows();
193 Arrays.sort(selectedRowIds);
194 for (
int i=(selectedRowIds.length-1); i>-1; i--)
203 GroupLayout grpLyoAPs =
new GroupLayout(
lineAPsBtns);
205 grpLyoAPs.setAutoCreateGaps(
true);
206 grpLyoAPs.setAutoCreateContainerGaps(
true);
207 grpLyoAPs.setHorizontalGroup(grpLyoAPs.createSequentialGroup()
208 .addGroup(grpLyoAPs.createParallelGroup()
209 .addGroup(grpLyoAPs.createSequentialGroup()
214 grpLyoAPs.setVerticalGroup(grpLyoAPs.createParallelGroup(
215 GroupLayout.Alignment.CENTER)
216 .addGroup(grpLyoAPs.createSequentialGroup()
217 .addGroup(grpLyoAPs.createParallelGroup()
227 cmbBBType.setToolTipText(String.format(
"<html><body width='%1s'>"
228 +
"Speicfy the type of building block of the vertex. This"
229 +
"determines, for instance, the type of other vertexes "
230 +
"that can be used to replace thi one (if such mutation "
231 +
"is permitted).</html>",300));
232 lineBBType =
new JPanel(
new FlowLayout(FlowLayout.LEFT));
237 rcbIsRCV =
new JRadioButton(
"ring-closing vertex");
238 rcbIsRCV.setToolTipText(
"Select to mark this vertex as a ring-closing "
240 lineRCV =
new JPanel(
new FlowLayout(FlowLayout.LEFT));
319 this.
btnDone.setText(
"Create");
320 this.
btnDone.setToolTipText(
"<html>Create an empty vertex with the "
321 +
"given attachment points<br>and properties</html>");
322 this.
btnDone.addActionListener(
new ActionListener() {
325 public void actionPerformed(ActionEvent e) {
327 cmbBBType.getSelectedItem().toString()));
328 for (
int i=0; i<
apTabModel.getRowCount(); i++)
330 String apClass =
apTabModel.getValueAt(i, 1).toString();
336 e1.printStackTrace();
337 JOptionPane.showMessageDialog(
btnDone,
338 "<html>Could not add attachment point with "
339 +
"<br>APClass '" + apClass +
"'. "
340 +
"<br>Hint on cause: " + e1.getMessage()
343 JOptionPane.ERROR_MESSAGE,
344 UIManager.getIcon(
"OptionPane.errorIcon"));
367 List<BBType> collection =
new ArrayList<BBType>();
372 for (
int i=0; i<
BBType.values().length; i++)
373 if (!collection.contains(
BBType.values()[i]))
374 collection.add(
BBType.values()[i]);
384 for (
int i=0; i<
BBType.values().length; i++)
387 if (!collection.contains(cand)
389 collection.add(cand);
395 for (
int i=0; i<
BBType.values().length; i++)
398 if (!collection.contains(cand)
401 collection.add(cand);
408 for (
int i=0; i<collection.size(); i++)
410 types[i] = collection.get(i);
411 }
new DefaultComboBoxModel<BBType>(types);
412 cmbBBType.setModel(
new DefaultComboBoxModel<BBType>(types));
static APClass make(String ruleAndSubclass)
Creates an APClass if it does not exist already, or returns the reference to the existing instance.
An empty vertex has the behaviors of a vertex, but has no molecular structure.
void addAP()
Adds an attachment point with no APClass or other attribute.
void setAsRCV(boolean isRCV)
void updateBBTypeBasedOnAPCount()
DefaultTableModel apTabModel
JComboBox< BBType > cmbBBType
static final long serialVersionUID
Version UID.
GUIEmptyVertexMaker(Component parent)
Constructs a maker that can make empty vertexes freely.
GUIEmptyVertexMaker(Component parent, BBType givenType)
Constructs a maker that can make empty vertexes on a specific BBType and does not allow to change suc...
JButton btnCanc
The button that is used to close the dialog without processing any input.
JButton btnDone
The button that is used to launch the processing of the data given to the open dialog,...
Object result
The result to be returned once the dialog is closed.
void close()
Closes the dialog window.
A panel with a viewer capable of visualising DENOPTIM fragments and allows to create and edit fragmen...
static List< APClass > choseOrCreateNewAPClass(JComponent parent, boolean singleSelection)
Runs a dialog aimed at selecting an existing APClass or defining a new one.
The type of building block.