Index: VerpakkingsDefinitie/ApplicationContext.pas =================================================================== diff -u -r582 -r585 --- VerpakkingsDefinitie/ApplicationContext.pas (.../ApplicationContext.pas) (revision 582) +++ VerpakkingsDefinitie/ApplicationContext.pas (.../ApplicationContext.pas) (revision 585) @@ -287,7 +287,7 @@ Namen := TList.Create(); for ProductVerpakkingTeZoeken in FProductVerpakkingen do begin - if ProductVerpakkingTeZoeken.Equals(ProductVerpakking) then + if not ProductVerpakkingTeZoeken.Equals(ProductVerpakking) then Namen.Add(intToStr(ProductVerpakkingTeZoeken.CutOrder) + ': ' + ProductVerpakkingTeZoeken.MetaCaption) end; @@ -297,7 +297,7 @@ // Product verpakking function TProductVerpakking.Equals(Obj: TObject): Boolean; begin - if Obj <> nil then + if Obj = nil then Result := false else if not(Obj is TProductVerpakking) then Result := false Index: VerpakkingsDefinitie/UI/ProductDetailScherm.pas =================================================================== diff -u -r582 -r585 --- VerpakkingsDefinitie/UI/ProductDetailScherm.pas (.../ProductDetailScherm.pas) (revision 582) +++ VerpakkingsDefinitie/UI/ProductDetailScherm.pas (.../ProductDetailScherm.pas) (revision 585) @@ -7,7 +7,7 @@ Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, Subscherm, Main, ApplicationContext, ObserverPattern, Vcl.ComCtrls, Vcl.CheckLst, - CheckCombo; + CheckCombo, Vcl.ExtCtrls; resourceString GEEN_DATA_CAPTION = 'Geen data om te tonen'; @@ -19,7 +19,7 @@ LabelOmschrijving2: TLabel; Label1: TLabel; LabelProductNaam: TLabel; - ListViewDozen: TListView; + ListViewVerpakkingen: TListView; GroupBox1: TGroupBox; ButtonNieuw: TButton; ButtonVerwijder: TButton; @@ -46,9 +46,11 @@ ComboBoxRichting: TComboBox; ButtonMeta: TButton; MemoParameters: TMemo; + PanelVerpakkingControls: TPanel; procedure FormCreate(Sender: TObject); procedure FormDestroy(Sender: TObject); + procedure ListViewVerpakkingenSelectItem(Sender: TObject; Item: TListItem; Selected: Boolean); private FProductDetailsSubject: TSubject; FProductDetailsSubjectObserver: TSubjectObserver; @@ -58,8 +60,9 @@ CheckComboBoxRichting: TCheckedComboBox; procedure UpdateGui(Sender: TObject); + procedure ToonProductVerpakking(ProductVerpakking: TProductVerpakking); procedure UpdateControlsEnableStatus(); - procedure UpdateGuiDataAanwezigheid(Aanwezig: boolean); + procedure UpdateGuiDataAanwezigheid(Aanwezig: Boolean); public Constructor Create(AOwner: TComponent; Navigator: INavigator; ApplicationContext: TApplicationContext; ProductDetailsSubject: TSubject); @@ -100,12 +103,16 @@ FProductDetailsSubject.UnregisterObserver(FProductDetailsSubjectObserver); end; +procedure TFormProductDetail.ListViewVerpakkingenSelectItem(Sender: TObject; Item: TListItem; Selected: Boolean); +begin + if Selected then + if (ListViewVerpakkingen.Selected.Data <> nil) then + ToonProductVerpakking(TProductVerpakking(ListViewVerpakkingen.Selected.Data)); +end; + procedure TFormProductDetail.UpdateGui(Sender: TObject); var ProductVerpakking: TProductVerpakking; - TempStr: string; - Item: string; - I: Integer; VorigeIndexInList: Integer; begin if (ApplicationContext.ProductDetailContext.GeselecteerdProduct = nil) or @@ -122,21 +129,22 @@ LabelOmschrijving2.Caption := ApplicationContext.ProductDetailContext.GeselecteerdProduct.Omschrijving2; LabelProductNaam.Caption := ApplicationContext.ProductDetailContext.GeselecteerdProduct.Kol1; - VorigeIndexInList := ListViewDozen.ItemIndex; + VorigeIndexInList := ListViewVerpakkingen.ItemIndex; // List view (grid) - ListViewDozen.Clear(); + ListViewVerpakkingen.Clear(); for ProductVerpakking in ApplicationContext.ProductDetailContext.ProductVerpakkingen do begin - With ListViewDozen.Items.Add Do + With ListViewVerpakkingen.Items.Add Do begin // Caption := IntToStr(Product.ProductNr); // Deze casting geeft geen access violation Caption := IntToStr(ProductVerpakking.CutOrder); SubItems.Add(ProductVerpakking.MetaCaption); SubItems.Add(ProductVerpakking.Breedte + ' x ' + ProductVerpakking.Diepte + ' x ' + ProductVerpakking.Hoogte); SubItems.Add(ProductVerpakking.Aantal); SubItems.Add(ProductVerpakking.MaxCombinAantal); - // SubItems.Add(ProductVerpakking.DeelVanCaption); + SubItems.Add(ifthen(ProductVerpakking.DeelVan <> nil, ProductVerpakking.DeelVan.MetaCaption, '')); + Data := ProductVerpakking; end; end; @@ -146,8 +154,20 @@ else if ApplicationContext.ProductDetailContext.ProductVerpakkingen.Count > 0 then ProductVerpakking := ApplicationContext.ProductDetailContext.ProductVerpakkingen[0] // Default eerste verpakking selecteren else - exit; // Geen verpakking aanwezig + ProductVerpakking := nil; // Geen verpakking aanwezig + if ProductVerpakking <> nil then + ToonProductVerpakking(ProductVerpakking); + + UpdateControlsEnableStatus() +end; + +procedure TFormProductDetail.ToonProductVerpakking(ProductVerpakking: TProductVerpakking); +var + I: Integer; + TempStr: string; + Item: string; +begin // Linkerhelft EditMeta.Text := ProductVerpakking.MetaCaption; @@ -164,7 +184,8 @@ // Index zoeken in lijst van producten ComboBoxDeelVan.ItemIndex := ApplicationContext.ProductDetailContext.ProductVerpakkingen.IndexOf(ProductVerpakking.DeelVan) else - ComboBoxDeelVan.ItemIndex := ComboBoxDeelVan.Items.Count - 1; // Default waarde: 'niks' optie selecteren + ComboBoxDeelVan.ItemIndex := ComboBoxDeelVan.Items.Count - 1; + // Default waarde: 'niks' optie selecteren if ProductVerpakking.Breedte <> '' then EditBreedte.Text := ProductVerpakking.Breedte @@ -226,17 +247,26 @@ if CheckComboBoxRichting.Items.IndexOf(TempStr) >= 0 then CheckComboBoxRichting.Checked[CheckComboBoxRichting.Items.IndexOf(TempStr)] := True; end; - - UpdateControlsEnableStatus() end; procedure TFormProductDetail.UpdateControlsEnableStatus(); +var + VerpakkingAanwezigEnGeselecteerd: Boolean; + I: Integer; begin + // Details controls enable status aanpassen naargelang er een verpakking geselecteerd is. + VerpakkingAanwezigEnGeselecteerd := (ListViewVerpakkingen.Items.Count = 0) or (ListViewVerpakkingen.ItemIndex < 0); + for I := 0 to PanelVerpakkingControls.ControlCount - 1 do + if Assigned(PanelVerpakkingControls.Controls[I]) then + PanelVerpakkingControls.Controls[I].Enabled := VerpakkingAanwezigEnGeselecteerd; + + ButtonVerwijder.Enabled := VerpakkingAanwezigEnGeselecteerd; + // Linkerdeel - ComboBoxDeelVan.Enabled := ComboBoxDeelVan.Items.Count > 0; + ComboBoxDeelVan.Enabled := (ComboBoxDeelVan.Items.Count > 0) and VerpakkingAanwezigEnGeselecteerd; end; -procedure TFormProductDetail.UpdateGuiDataAanwezigheid(Aanwezig: boolean); +procedure TFormProductDetail.UpdateGuiDataAanwezigheid(Aanwezig: Boolean); var I: Integer; begin @@ -251,6 +281,8 @@ if Assigned(self.Controls[I]) then self.Controls[I].Visible := True; + LabelGeenData.Visible := False; + PanelVerpakkingControls.Refresh(); // Anders verdwijnt label enkel op resize FreeAndNil(LabelGeenData); end else Index: VerpakkingsDefinitie/UI/ProductDetailScherm.dfm =================================================================== diff -u -r581 -r585 --- VerpakkingsDefinitie/UI/ProductDetailScherm.dfm (.../ProductDetailScherm.dfm) (revision 581) +++ VerpakkingsDefinitie/UI/ProductDetailScherm.dfm (.../ProductDetailScherm.dfm) (revision 585) @@ -52,94 +52,220 @@ Font.Style = [fsBold] ParentFont = False end - object Label2: TLabel + object PanelVerpakkingControls: TPanel Left = 8 - Top = 280 - Width = 24 - Height = 13 - Anchors = [akLeft, akBottom] - Caption = 'Meta' + Top = 257 + Width = 792 + Height = 416 + Anchors = [akLeft, akRight, akBottom] + TabOrder = 1 + DesignSize = ( + 792 + 416) + object Label10: TLabel + Left = 8 + Top = 279 + Width = 55 + Height = 13 + Anchors = [akLeft, akBottom] + Caption = 'Parameters' + ExplicitTop = 275 + end + object Label11: TLabel + Left = 400 + Top = 15 + Width = 43 + Height = 13 + Anchors = [akLeft, akBottom] + Caption = 'Plaatsing' + ExplicitTop = 11 + end + object Label12: TLabel + Left = 400 + Top = 47 + Width = 31 + Height = 13 + Anchors = [akLeft, akBottom] + Caption = 'Positie' + ExplicitTop = 43 + end + object Label13: TLabel + Left = 400 + Top = 79 + Width = 38 + Height = 13 + Anchors = [akLeft, akBottom] + Caption = 'Richting' + ExplicitTop = 75 + end + object Label2: TLabel + Left = 8 + Top = 15 + Width = 24 + Height = 13 + Anchors = [akLeft, akBottom] + Caption = 'Meta' + ExplicitTop = 11 + end + object Label4: TLabel + Left = 8 + Top = 79 + Width = 42 + Height = 13 + Anchors = [akLeft, akBottom] + Caption = 'Deel van' + ExplicitTop = 75 + end + object Label5: TLabel + Left = 8 + Top = 111 + Width = 38 + Height = 13 + Anchors = [akLeft, akBottom] + Caption = 'Breedte' + ExplicitTop = 107 + end + object Label6: TLabel + Left = 8 + Top = 143 + Width = 31 + Height = 13 + Anchors = [akLeft, akBottom] + Caption = 'Diepte' + ExplicitTop = 139 + end + object Label7: TLabel + Left = 8 + Top = 173 + Width = 35 + Height = 13 + Anchors = [akLeft, akBottom] + Caption = 'Hoogte' + ExplicitTop = 169 + end + object Label8: TLabel + Left = 8 + Top = 223 + Width = 85 + Height = 13 + Anchors = [akLeft, akBottom] + Caption = 'Max comb. aantal' + ExplicitTop = 219 + end + object Label9: TLabel + Left = 8 + Top = 252 + Width = 31 + Height = 13 + Anchors = [akLeft, akBottom] + Caption = 'Aantal' + ExplicitTop = 248 + end + object ButtonMeta: TButton + Left = 272 + Top = 12 + Width = 40 + Height = 21 + Anchors = [akLeft, akBottom] + Caption = '...' + TabOrder = 0 + end + object ComboBoxDeelVan: TComboBox + Left = 112 + Top = 76 + Width = 200 + Height = 21 + Style = csDropDownList + Anchors = [akLeft, akBottom] + TabOrder = 1 + end + object ComboBoxPlaatsing: TComboBox + Left = 518 + Top = 12 + Width = 162 + Height = 21 + Style = csDropDownList + Anchors = [akLeft, akBottom] + TabOrder = 2 + end + object ComboBoxPositie: TComboBox + Left = 518 + Top = 44 + Width = 162 + Height = 21 + Style = csDropDownList + Anchors = [akLeft, akBottom] + TabOrder = 3 + end + object ComboBoxRichting: TComboBox + Left = 518 + Top = 76 + Width = 162 + Height = 21 + Style = csDropDownList + Anchors = [akLeft, akBottom] + TabOrder = 4 + end + object EditAantal: TEdit + Left = 112 + Top = 252 + Width = 200 + Height = 21 + Anchors = [akLeft, akBottom] + TabOrder = 5 + end + object EditBreedte: TEdit + Left = 112 + Top = 108 + Width = 200 + Height = 21 + Anchors = [akLeft, akBottom] + TabOrder = 6 + end + object EditDiepte: TEdit + Left = 112 + Top = 140 + Width = 200 + Height = 21 + Anchors = [akLeft, akBottom] + TabOrder = 7 + end + object EditHoogte: TEdit + Left = 112 + Top = 172 + Width = 200 + Height = 21 + Anchors = [akLeft, akBottom] + TabOrder = 8 + end + object EditMaxCombAantal: TEdit + Left = 112 + Top = 220 + Width = 200 + Height = 21 + Anchors = [akLeft, akBottom] + TabOrder = 9 + end + object EditMeta: TEdit + Left = 112 + Top = 12 + Width = 154 + Height = 21 + Anchors = [akLeft, akBottom] + Enabled = False + TabOrder = 10 + end + object MemoParameters: TMemo + Left = 112 + Top = 282 + Width = 200 + Height = 125 + Anchors = [akLeft, akBottom] + Lines.Strings = ( + '') + TabOrder = 11 + end end - object Label4: TLabel - Left = 8 - Top = 344 - Width = 42 - Height = 13 - Anchors = [akLeft, akBottom] - Caption = 'Deel van' - end - object Label5: TLabel - Left = 8 - Top = 376 - Width = 38 - Height = 13 - Anchors = [akLeft, akBottom] - Caption = 'Breedte' - end - object Label6: TLabel - Left = 8 - Top = 408 - Width = 31 - Height = 13 - Anchors = [akLeft, akBottom] - Caption = 'Diepte' - end - object Label7: TLabel - Left = 8 - Top = 438 - Width = 35 - Height = 13 - Anchors = [akLeft, akBottom] - Caption = 'Hoogte' - end - object Label8: TLabel - Left = 8 - Top = 488 - Width = 85 - Height = 13 - Anchors = [akLeft, akBottom] - Caption = 'Max comb. aantal' - end - object Label9: TLabel - Left = 8 - Top = 517 - Width = 31 - Height = 13 - Anchors = [akLeft, akBottom] - Caption = 'Aantal' - end - object Label10: TLabel - Left = 8 - Top = 544 - Width = 55 - Height = 13 - Anchors = [akLeft, akBottom] - Caption = 'Parameters' - end - object Label11: TLabel - Left = 400 - Top = 280 - Width = 43 - Height = 13 - Anchors = [akLeft, akBottom] - Caption = 'Plaatsing' - end - object Label12: TLabel - Left = 400 - Top = 312 - Width = 31 - Height = 13 - Anchors = [akLeft, akBottom] - Caption = 'Positie' - end - object Label13: TLabel - Left = 400 - Top = 344 - Width = 38 - Height = 13 - Anchors = [akLeft, akBottom] - Caption = 'Richting' - end object GroupBox1: TGroupBox Left = 8 Top = 83 @@ -151,7 +277,7 @@ DesignSize = ( 792 168) - object ListViewDozen: TListView + object ListViewVerpakkingen: TListView Left = 3 Top = 16 Width = 669 @@ -184,6 +310,7 @@ end> TabOrder = 0 ViewStyle = vsReport + OnSelectItem = ListViewVerpakkingenSelectItem end object ButtonNieuw: TButton Left = 688 @@ -204,108 +331,4 @@ TabOrder = 2 end end - object EditMeta: TEdit - Left = 112 - Top = 277 - Width = 154 - Height = 21 - Anchors = [akLeft, akBottom] - Enabled = False - TabOrder = 1 - end - object ComboBoxDeelVan: TComboBox - Left = 112 - Top = 341 - Width = 200 - Height = 21 - Style = csDropDownList - Anchors = [akLeft, akBottom] - TabOrder = 2 - end - object EditBreedte: TEdit - Left = 112 - Top = 373 - Width = 200 - Height = 21 - Anchors = [akLeft, akBottom] - TabOrder = 3 - end - object EditDiepte: TEdit - Left = 112 - Top = 405 - Width = 200 - Height = 21 - Anchors = [akLeft, akBottom] - TabOrder = 4 - end - object EditHoogte: TEdit - Left = 112 - Top = 435 - Width = 200 - Height = 21 - Anchors = [akLeft, akBottom] - TabOrder = 5 - end - object EditMaxCombAantal: TEdit - Left = 112 - Top = 485 - Width = 200 - Height = 21 - Anchors = [akLeft, akBottom] - TabOrder = 6 - end - object EditAantal: TEdit - Left = 112 - Top = 514 - Width = 200 - Height = 21 - Anchors = [akLeft, akBottom] - TabOrder = 7 - end - object ComboBoxPlaatsing: TComboBox - Left = 503 - Top = 277 - Width = 162 - Height = 21 - Style = csDropDownList - Anchors = [akLeft, akBottom] - TabOrder = 8 - end - object ComboBoxPositie: TComboBox - Left = 503 - Top = 309 - Width = 162 - Height = 21 - Style = csDropDownList - Anchors = [akLeft, akBottom] - TabOrder = 9 - end - object ComboBoxRichting: TComboBox - Left = 503 - Top = 341 - Width = 162 - Height = 21 - Style = csDropDownList - Anchors = [akLeft, akBottom] - TabOrder = 10 - end - object ButtonMeta: TButton - Left = 272 - Top = 277 - Width = 40 - Height = 21 - Anchors = [akLeft, akBottom] - Caption = '...' - TabOrder = 11 - end - object MemoParameters: TMemo - Left = 112 - Top = 544 - Width = 200 - Height = 125 - Anchors = [akLeft, akBottom] - Lines.Strings = ( - '') - TabOrder = 12 - end end Index: VerpakkingsDefinitie/WS/ProductsAgent.pas =================================================================== diff -u -r582 -r585 --- VerpakkingsDefinitie/WS/ProductsAgent.pas (.../ProductsAgent.pas) (revision 582) +++ VerpakkingsDefinitie/WS/ProductsAgent.pas (.../ProductsAgent.pas) (revision 585) @@ -438,6 +438,7 @@ if ProductVerpakking.DeelVanID = ProductVerpakkingAndere.ID then ProductVerpakking.DeelVan := ProductVerpakkingAndere; end; + ProductDetailContext.NotifyChanged(); finally FreeAndNil(BoxDataIDs); FreeAndNil(ZoekData); @@ -458,6 +459,7 @@ with Verpakking do begin RawData := pxBoxDataObj; + ID := pxBoxDataObj.ID; MetaCaption := pxBoxDataObj.MetaCaption; CutOrder := pxBoxDataObj.CutOrder; Breedte := pxBoxDataObj.Breedte; @@ -476,8 +478,6 @@ end; ProductDetailContext.ProductVerpakkingen.Add(Verpakking); - - ProductDetailContext.NotifyChanged(); end; procedure TProductsAgent.RegistreerMislukteOpzoeking(ProductDetailContext: TProductDetailContext; Index: VerpakkingsDefinitie/UI/GevondenProductenScherm.pas =================================================================== diff -u -r584 -r585 --- VerpakkingsDefinitie/UI/GevondenProductenScherm.pas (.../GevondenProductenScherm.pas) (revision 584) +++ VerpakkingsDefinitie/UI/GevondenProductenScherm.pas (.../GevondenProductenScherm.pas) (revision 585) @@ -85,7 +85,8 @@ Product: TProductInformatie; begin ListViewProducten.Items.Clear(); - // Update with data from ApplicationContext + + ListViewProducten.Items.beginupdate(); for Product in ApplicationContext.ProductsContext.Producten do begin With ListViewProducten.Items.Add Do @@ -99,6 +100,7 @@ Data := Product; end; end; + ListViewProducten.Items.EndUpdate; // Bij opnieuw inladen is de selectie verloren gegaan. self.ApplicationContext.ProductDetailContext.Reset();