2013-08-23 1 views
1
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); 
    } 

이는보기로 사용될 샘플 콘크리트 빌더 패턴입니다. 건축가지만보기가 아니기 때문에 정말 적절한가요? 나는 아직 패턴을 디자인하는 데있어 초보자입니다. 그 죄송합니다. 어쨌든 고마워!MVC 패턴에서보기 파트의 빌더 패턴을 사용하는 것이 적절합니까?

답변

1

저는 빌더가 뷰의 역할에 사용하기에 완벽하게 좋은 것이라고 말하고 싶습니다.

자신에게 물어 보는 것은 좋은 질문이 아닙니다. 특정 문제에 대한 해결책을 찾고 일반적인 어휘를 사용하여 다른 사람들과 토론하는 데 도움이되는 디자인 패턴이 있습니다. 코드가 일관성, 일관성 등과 같은 좋은 OOP 원칙을 따르고 이해하기 쉽고 유지 관리가 쉬운 경우 코드가 특정 명명 된 디자인 패턴 또는 기타의 정의를 엄격하게 충족하는지 여부는 중요하지 않습니다.