public class AddFormConcreteBuilder extends FormBuilder
{
private JDateChooser dateChooser;
private InsertProducer producer;
private DataObject dataObject;
private JTextField AssetName;
private JTextField Financial;
private JTextField Location;
private JComboBox Custodian;
private JComboBox Type;
private JComboBox RetentionPeriod;
private JComboBox MaintenanceSched;
private JComboBox Confidentiality;
private JComboBox Integrity;
private JComboBox Availability;
private JComboBox Classification;
private JButton btnConfirm;
private JButton btnBack;
private ArrayList<DataSet> insertList = new ArrayList<DataSet>();
private int AssetID = generateNewAssetID();
private PanelManager PanelHolder;
/**
* @wbp.parser.entryPoint
*/
@Override
public void buildComponents()
{
PanelHolder = new PanelManager();
ComboBoxManager comboModelCreator= new ComboBoxManager();
myForm.setSize(1200,644);
myForm.setLayout(null);
Custodian = new JComboBox(comboModelCreator.CustodianData());
Custodian.setBounds(135, 130, 144, 20);
myForm.add(Custodian);
Type = new JComboBox(comboModelCreator.TypeData());
Type.setBounds(135, 163, 144, 20);
myForm.add(Type);
RetentionPeriod = new JComboBox(comboModelCreator.RetentionPeriodData());
RetentionPeriod.setBounds(161, 230, 118, 20);
myForm.add(RetentionPeriod);
MaintenanceSched = new JComboBox(comboModelCreator.MaintenanceSchedData());
MaintenanceSched.setBounds(161, 274, 118, 20);
myForm.add(MaintenanceSched);
Confidentiality = new JComboBox(comboModelCreator.ConfidentialityData());
Confidentiality.setBounds(161, 354, 118, 20);
myForm.add(Confidentiality);
Integrity = new JComboBox(comboModelCreator.IntegrityData());
Integrity.setBounds(161, 393, 118, 20);
myForm.add(Integrity);
Availability = new JComboBox(comboModelCreator.AvailabilityData());
Availability.setBounds(161, 429, 118, 20);
myForm.add(Availability);
Classification = new JComboBox(comboModelCreator.ClassificationData());
Classification.setBounds(161, 467, 118, 20);
myForm.add(Classification);
JLabel lblAssetName = new JLabel("Asset Name : ");
lblAssetName.setBounds(24, 92, 101, 24);
myForm.add(lblAssetName);
AssetName = new JTextField();
AssetName.setBounds(135, 94, 144, 20);
myForm.add(AssetName);
AssetName.setColumns(10);
JLabel lblCustodian = new JLabel("Custodian :");
lblCustodian.setBounds(24, 128, 75, 24);
myForm.add(lblCustodian);
JLabel lblType = new JLabel("Type :");
lblType.setBounds(24, 166, 60, 14);
myForm.add(lblType);
JLabel DateAcquired = new JLabel("Date Acquired :");
DateAcquired.setBounds(24, 191, 101, 24);
myForm.add(DateAcquired);
JLabel lblRetentionPeriod = new JLabel("Retention Period :");
lblRetentionPeriod.setBounds(24, 236, 118, 14);
myForm.add(lblRetentionPeriod);
JLabel MaintenanceSchedlbl = new JLabel("Maintenance Schedule : ");
MaintenanceSchedlbl.setBounds(24, 275, 153, 24);
myForm.add(MaintenanceSchedlbl);
JLabel lblFinancial = new JLabel("Financial : ");
lblFinancial.setBounds(24, 310, 90, 24);
myForm.add(lblFinancial);
Financial = new JTextField();
Financial.setBounds(135, 309, 144, 20);
myForm.add(Financial);
Financial.setColumns(10);
JLabel Confidential = new JLabel("Confidentiality: ");
Confidential.setBounds(24, 355, 127, 24);
myForm.add(Confidential);
JLabel lblIntegrity = new JLabel("Integrity :");
lblIntegrity.setBounds(24, 399, 75, 14);
myForm.add(lblIntegrity);
JLabel lblAvailability = new JLabel("Availability : ");
lblAvailability.setBounds(22, 435, 103, 14);
myForm.add(lblAvailability);
JLabel lblClassification = new JLabel("Classification :");
lblClassification.setBounds(24, 473, 118, 14);
myForm.add(lblClassification);
JLabel lblStorageLocation = new JLabel("Storage Location :");
lblStorageLocation.setBounds(24, 507, 127, 14);
myForm.add(lblStorageLocation);
Location = new JTextField();
Location.setBounds(161, 501, 118, 20);
myForm.add(Location);
Location.setColumns(10);
btnConfirm = new JButton("Confirm");
btnConfirm.setBounds(403, 524, 179, 49);
btnConfirm.setFont(new Font("Dialog", Font.BOLD, 22));
myForm.add(btnConfirm);
btnBack = new JButton("Back");
btnBack.setBounds(629, 524, 180, 49);
btnBack.setFont(new Font("Dialog", Font.BOLD, 22));
myForm.add(btnBack);
dateChooser = new JDateChooser();
dateChooser.setBounds(143, 191, 136, 20);
myForm.add(dateChooser);
}
这是将用作View的示例具体构建器模式。它是否真的合适,因为它是建造者而不是观点?我仍然是设计模式的新手。对不起不管怎样,谢谢!
答案 0 :(得分:1)
我认为构建器在视图角色中使用是一种非常好的东西。
虽然问自己这不是一个好问题。存在设计模式以帮助您找到特定问题的解决方案,并使用常用词汇与其他人讨论。如果代码遵循良好的OOP原则,例如一致性,一致性等,并且易于理解和维护,那么您的代码是否严格满足某些特定命名设计模式或其他的定义并不重要。