IDE, fix newfield form to allow data field type, from Marcelo Borges de Paula, issue #16941

git-svn-id: trunk@26694 -
This commit is contained in:
jesus 2010-07-16 19:22:34 +00:00
parent c4f8693efa
commit 48387376be
3 changed files with 87 additions and 68 deletions

View File

@ -131,7 +131,7 @@ msgstr "Acima"
#: objinspstrconsts.fescalculated #: objinspstrconsts.fescalculated
msgid "&Calculated" msgid "&Calculated"
msgstr "" msgstr "&Calculado"
#: objinspstrconsts.fescancelbtn #: objinspstrconsts.fescancelbtn
msgctxt "objinspstrconsts.fescancelbtn" msgctxt "objinspstrconsts.fescancelbtn"
@ -142,53 +142,60 @@ msgstr "Cancelar"
msgid "Check dataset settings" msgid "Check dataset settings"
msgstr "Verificar configurações \"dataset\"" msgstr "Verificar configurações \"dataset\""
#: objinspstrconsts.fesdata
msgid "&Data"
msgstr "&Dado"
#: objinspstrconsts.fesdataset #: objinspstrconsts.fesdataset
msgid "&Dataset:" msgid "&Dataset:"
msgstr "" msgstr "&Dataset:"
#: objinspstrconsts.fesfetitle #: objinspstrconsts.fesfetitle
#| msgid "Edit Fields" #| msgid "Edit Fields"
msgid "Edit Fields..." msgid "Edit Fields..."
msgstr "Editar Campos" msgstr "Editar Campos"
#: objinspstrconsts.fesfieldcantbec
msgid "Field %s cannot be created!"
msgstr "Campo %s não pôde ser criado!"
#: objinspstrconsts.fesfieldprops #: objinspstrconsts.fesfieldprops
msgid "Field properties" msgid "Field properties"
msgstr "" msgstr "Propriedades campo"
#: objinspstrconsts.fesfieldtype #: objinspstrconsts.fesfieldtype
msgid "Field Type" msgid "Field Type"
msgstr "" msgstr "Tipo de campo"
#: objinspstrconsts.fesfltitle #: objinspstrconsts.fesfltitle
msgid "FieldDefs" msgid "FieldDefs"
msgstr "Definições Campos" msgstr "Definições Campos"
#: objinspstrconsts.fesformcaption #: objinspstrconsts.fesformcaption
#, fuzzy
#| msgid "New fileld" #| msgid "New fileld"
msgctxt "objinspstrconsts.fesformcaption" msgctxt "objinspstrconsts.fesformcaption"
msgid "New field" msgid "New field"
msgstr "Caixa de diálogo" msgstr "Novo campo"
#: objinspstrconsts.feskeyfield #: objinspstrconsts.feskeyfield
msgid "&Key fields:" msgid "&Key fields:"
msgstr "" msgstr "Campos c&have:"
#: objinspstrconsts.feslookup #: objinspstrconsts.feslookup
msgid "&Lookup" msgid "&Lookup"
msgstr "" msgstr "&Lookup"
#: objinspstrconsts.feslookupdef #: objinspstrconsts.feslookupdef
msgid "Lookup definition" msgid "Lookup definition"
msgstr "" msgstr "Definição \"Lookup\""
#: objinspstrconsts.feslookupkeys #: objinspstrconsts.feslookupkeys
msgid "L&ookup keys:" msgid "L&ookup keys:"
msgstr "" msgstr "Chaves \"L&ookup\":"
#: objinspstrconsts.fesname #: objinspstrconsts.fesname
msgid "&Name:" msgid "&Name:"
msgstr "" msgstr "&Nome:"
#: objinspstrconsts.fesnofields #: objinspstrconsts.fesnofields
msgid "It was not possible to get the dataset field's list" msgid "It was not possible to get the dataset field's list"
@ -205,15 +212,15 @@ msgstr "OK"
#: objinspstrconsts.fesresultfield #: objinspstrconsts.fesresultfield
msgid "&Result Fields:" msgid "&Result Fields:"
msgstr "" msgstr "Campos &Resultado:"
#: objinspstrconsts.fessize #: objinspstrconsts.fessize
msgid "&Size:" msgid "&Size:"
msgstr "" msgstr "&Tamanho:"
#: objinspstrconsts.festype #: objinspstrconsts.festype
msgid "&Type:" msgid "&Type:"
msgstr "" msgstr "T&ipo:"
#: objinspstrconsts.ilesadd #: objinspstrconsts.ilesadd
msgctxt "objinspstrconsts.ilesadd" msgctxt "objinspstrconsts.ilesadd"

View File

@ -2,13 +2,13 @@ object NewFieldFrm: TNewFieldFrm
Left = 447 Left = 447
Height = 428 Height = 428
Top = 271 Top = 271
Width = 354 Width = 357
HorzScrollBar.Page = 261 HorzScrollBar.Page = 261
VertScrollBar.Page = 375 VertScrollBar.Page = 375
BorderStyle = bsDialog BorderStyle = bsDialog
Caption = 'Dialog' Caption = 'Dialog'
ClientHeight = 428 ClientHeight = 428
ClientWidth = 354 ClientWidth = 357
OnCreate = FormCreate OnCreate = FormCreate
ParentFont = True ParentFont = True
Position = poScreenCenter Position = poScreenCenter
@ -18,52 +18,52 @@ object NewFieldFrm: TNewFieldFrm
Left = 0 Left = 0
Height = 121 Height = 121
Top = 112 Top = 112
Width = 354 Width = 357
Align = alTop Align = alTop
ClientHeight = 121 ClientHeight = 121
ClientWidth = 354 ClientWidth = 357
FullRepaint = False FullRepaint = False
TabOrder = 0 TabOrder = 0
object GroupBox1: TGroupBox object GroupBox1: TGroupBox
Left = 8 Left = 8
Height = 105 Height = 105
Top = 8 Top = 8
Width = 336 Width = 339
Anchors = [akTop, akLeft, akRight] Anchors = [akTop, akLeft, akRight]
Caption = 'Field properties' Caption = 'Field properties'
ClientHeight = 87 ClientHeight = 83
ClientWidth = 332 ClientWidth = 335
TabOrder = 0 TabOrder = 0
object Label1: TLabel object Label1: TLabel
Left = 6 Left = 6
Height = 14 Height = 18
Top = 11 Top = 11
Width = 32 Width = 41
Caption = '&Name:' Caption = '&Name:'
FocusControl = EditName FocusControl = EditName
ParentColor = False ParentColor = False
end end
object Label2: TLabel object Label2: TLabel
Left = 6 Left = 6
Height = 14 Height = 18
Top = 35 Top = 35
Width = 29 Width = 37
Caption = '&Type:' Caption = '&Type:'
FocusControl = SelectType FocusControl = SelectType
ParentColor = False ParentColor = False
end end
object Label3: TLabel object Label3: TLabel
Left = 6 Left = 6
Height = 14 Height = 18
Top = 59 Top = 59
Width = 24 Width = 29
Caption = '&Size:' Caption = '&Size:'
FocusControl = EditSize FocusControl = EditSize
ParentColor = False ParentColor = False
end end
object EditName: TEdit object EditName: TEdit
Left = 158 Left = 158
Height = 21 Height = 25
Hint = 'Field name' Hint = 'Field name'
Top = 8 Top = 8
Width = 168 Width = 168
@ -74,11 +74,11 @@ object NewFieldFrm: TNewFieldFrm
end end
object SelectType: TComboBox object SelectType: TComboBox
Left = 158 Left = 158
Height = 21 Height = 25
Hint = 'Field type' Hint = 'Field type'
Top = 32 Top = 32
Width = 168 Width = 168
ItemHeight = 13 ItemHeight = 17
Items.Strings = ( Items.Strings = (
'String' 'String'
'Integer' 'Integer'
@ -101,7 +101,7 @@ object NewFieldFrm: TNewFieldFrm
end end
object EditSize: TEdit object EditSize: TEdit
Left = 158 Left = 158
Height = 21 Height = 25
Hint = 'Field size' Hint = 'Field size'
Top = 56 Top = 56
Width = 168 Width = 168
@ -114,10 +114,10 @@ object NewFieldFrm: TNewFieldFrm
Left = 0 Left = 0
Height = 144 Height = 144
Top = 233 Top = 233
Width = 354 Width = 357
Align = alTop Align = alTop
ClientHeight = 144 ClientHeight = 144
ClientWidth = 354 ClientWidth = 357
FullRepaint = False FullRepaint = False
TabOrder = 1 TabOrder = 1
Visible = False Visible = False
@ -125,54 +125,54 @@ object NewFieldFrm: TNewFieldFrm
Left = 8 Left = 8
Height = 129 Height = 129
Top = 8 Top = 8
Width = 336 Width = 339
Anchors = [akTop, akLeft, akRight, akBottom] Anchors = [akTop, akLeft, akRight, akBottom]
Caption = 'Lookup definition' Caption = 'Lookup definition'
ClientHeight = 111 ClientHeight = 107
ClientWidth = 332 ClientWidth = 335
TabOrder = 0 TabOrder = 0
object Label4: TLabel object Label4: TLabel
Left = 6 Left = 6
Height = 14 Height = 18
Top = 10 Top = 10
Width = 47 Width = 57
Caption = '&Key fields' Caption = '&Key fields'
FocusControl = SelectKeyFields FocusControl = SelectKeyFields
ParentColor = False ParentColor = False
end end
object Label5: TLabel object Label5: TLabel
Left = 6 Left = 6
Height = 14 Height = 18
Top = 58 Top = 58
Width = 60 Width = 79
Caption = 'L&ookup keys' Caption = 'L&ookup keys'
FocusControl = SelectLookupKeys FocusControl = SelectLookupKeys
ParentColor = False ParentColor = False
end end
object Label6: TLabel object Label6: TLabel
Left = 6 Left = 6
Height = 14 Height = 18
Top = 82 Top = 82
Width = 61 Width = 74
Caption = '&Result Fields' Caption = '&Result Fields'
FocusControl = SelectResultField FocusControl = SelectResultField
ParentColor = False ParentColor = False
end end
object Label10: TLabel object Label10: TLabel
Left = 6 Left = 6
Height = 14 Height = 18
Top = 34 Top = 34
Width = 39 Width = 48
Caption = 'Dataset' Caption = 'Dataset'
ParentColor = False ParentColor = False
end end
object SelectKeyFields: TComboBox object SelectKeyFields: TComboBox
Left = 158 Left = 158
Height = 21 Height = 25
Hint = 'Key fields' Hint = 'Key fields'
Top = 7 Top = 7
Width = 168 Width = 168
ItemHeight = 13 ItemHeight = 17
OnChange = SelectKeyFieldsChange OnChange = SelectKeyFieldsChange
ParentShowHint = False ParentShowHint = False
ShowHint = True ShowHint = True
@ -180,31 +180,31 @@ object NewFieldFrm: TNewFieldFrm
end end
object SelectLookupKeys: TComboBox object SelectLookupKeys: TComboBox
Left = 158 Left = 158
Height = 21 Height = 25
Top = 55 Top = 55
Width = 168 Width = 168
Enabled = False Enabled = False
ItemHeight = 13 ItemHeight = 17
OnChange = SelectLookupKeysChange OnChange = SelectLookupKeysChange
TabOrder = 2 TabOrder = 2
end end
object SelectResultField: TComboBox object SelectResultField: TComboBox
Left = 158 Left = 158
Height = 21 Height = 25
Top = 79 Top = 79
Width = 168 Width = 168
Enabled = False Enabled = False
ItemHeight = 13 ItemHeight = 17
OnChange = SelectResultFieldChange OnChange = SelectResultFieldChange
TabOrder = 3 TabOrder = 3
end end
object DataSetsCombo: TComboBox object DataSetsCombo: TComboBox
Left = 158 Left = 158
Height = 21 Height = 25
Hint = 'Lookup dataset' Hint = 'Lookup dataset'
Top = 31 Top = 31
Width = 168 Width = 168
ItemHeight = 13 ItemHeight = 17
OnChange = DataSetsComboChange OnChange = DataSetsComboChange
ParentShowHint = False ParentShowHint = False
ShowHint = True ShowHint = True
@ -217,10 +217,10 @@ object NewFieldFrm: TNewFieldFrm
Left = 0 Left = 0
Height = 47 Height = 47
Top = 381 Top = 381
Width = 354 Width = 357
Align = alBottom Align = alBottom
ClientHeight = 47 ClientHeight = 47
ClientWidth = 354 ClientWidth = 357
FullRepaint = False FullRepaint = False
TabOrder = 2 TabOrder = 2
object OKBtn: TButton object OKBtn: TButton
@ -252,17 +252,17 @@ object NewFieldFrm: TNewFieldFrm
Left = 0 Left = 0
Height = 112 Height = 112
Top = 0 Top = 0
Width = 354 Width = 357
Align = alTop Align = alTop
ClientHeight = 112 ClientHeight = 112
ClientWidth = 354 ClientWidth = 357
FullRepaint = False FullRepaint = False
TabOrder = 3 TabOrder = 3
object NoteLbl: TLabel object NoteLbl: TLabel
Left = 8 Left = 8
Height = 37 Height = 37
Top = 58 Top = 58
Width = 336 Width = 339
Anchors = [akTop, akLeft, akRight] Anchors = [akTop, akLeft, akRight]
AutoSize = False AutoSize = False
Caption = 'NoteLbl' Caption = 'NoteLbl'
@ -274,7 +274,7 @@ object NewFieldFrm: TNewFieldFrm
Left = 8 Left = 8
Height = 48 Height = 48
Top = 8 Top = 8
Width = 336 Width = 339
Anchors = [akTop, akLeft, akRight] Anchors = [akTop, akLeft, akRight]
AutoFill = True AutoFill = True
Caption = 'Field Type' Caption = 'Field Type'
@ -285,12 +285,13 @@ object NewFieldFrm: TNewFieldFrm
ChildSizing.ShrinkHorizontal = crsScaleChilds ChildSizing.ShrinkHorizontal = crsScaleChilds
ChildSizing.ShrinkVertical = crsScaleChilds ChildSizing.ShrinkVertical = crsScaleChilds
ChildSizing.Layout = cclLeftToRightThenTopToBottom ChildSizing.Layout = cclLeftToRightThenTopToBottom
ChildSizing.ControlsPerLine = 2 ChildSizing.ControlsPerLine = 3
ClientHeight = 30 ClientHeight = 26
ClientWidth = 332 ClientWidth = 335
Columns = 2 Columns = 3
ItemIndex = 0 ItemIndex = 0
Items.Strings = ( Items.Strings = (
'&Data'
'&Calculated' '&Calculated'
'&Lookup' '&Lookup'
) )

View File

@ -13,6 +13,7 @@
* * * *
***************************************************************************** *****************************************************************************
} }
{ 2010-07-15 - New field type option (Data) Marcelo B. Paula }
unit newfield; unit newfield;
{$mode Delphi} {$H+} {$mode Delphi} {$H+}
@ -160,6 +161,7 @@ begin
Caption := fesFormCaption; Caption := fesFormCaption;
RadioGroup1.Caption := fesFieldType; RadioGroup1.Caption := fesFieldType;
RadioGroup1.Items.Clear; RadioGroup1.Items.Clear;
RadioGroup1.Items.Add(fesData);
RadioGroup1.Items.Add(fesCalculated); RadioGroup1.Items.Add(fesCalculated);
RadioGroup1.Items.Add(fesLookup); RadioGroup1.Items.Add(fesLookup);
GroupBox1.Caption := fesFieldProps; GroupBox1.Caption := fesFieldProps;
@ -241,7 +243,16 @@ begin
LinkDataSet.Active := False; LinkDataSet.Active := False;
try try
case RadioGroup1.ItemIndex of case RadioGroup1.ItemIndex of
0: begin //Create calc field 0: begin //Create data field
fldType := TFieldType(PtrUInt(SelectType.Items.Objects[SelectType.ItemIndex]));
NewField := CreateField(fldType, CheckName(EditName.Text));
NewField.Calculated := False;
NewField.FieldKind := fkData;
FDesigner.PropertyEditorHook.PersistentAdded(NewField, True);
FDesigner.Modified;
end;
1: begin //Create calc field
fldType := TFieldType(PtrUInt(SelectType.Items.Objects[SelectType.ItemIndex])); fldType := TFieldType(PtrUInt(SelectType.Items.Objects[SelectType.ItemIndex]));
NewField := CreateField(fldType, CheckName(EditName.Text)); NewField := CreateField(fldType, CheckName(EditName.Text));
NewField.Calculated := True; NewField.Calculated := True;
@ -268,7 +279,7 @@ begin
FDesigner.PropertyEditorHook.PersistentAdded(NewField, True); FDesigner.PropertyEditorHook.PersistentAdded(NewField, True);
end else end else
ShowMessage('Field ''' + L[i] + ''' can''t be created!'); ShowMessage(Format(fesFieldCanTBeC, [L[i]]));
end; end;
FDesigner.Modified; FDesigner.Modified;
finally finally
@ -285,12 +296,12 @@ end;
procedure TNewFieldFrm.RadioGroup1Click(Sender: TObject); procedure TNewFieldFrm.RadioGroup1Click(Sender: TObject);
begin begin
case RadioGroup1.ItemIndex of case RadioGroup1.ItemIndex of
0: begin //calculated field 0..1: begin //data,calculated field
Panel3.Visible := False; Panel3.Visible := False;
Panel2.Visible := True; Panel2.Visible := True;
ClientHeight := Panel1.Height + Panel2.Height + Panel4.Height; ClientHeight := Panel1.Height + Panel2.Height + Panel4.Height;
end; end;
1: begin //lookup field 2: begin //lookup field
Panel3.Visible := True; Panel3.Visible := True;
Panel2.Visible := False; Panel2.Visible := False;
ClientHeight := Panel1.Height + Panel3.Height + Panel4.Height; ClientHeight := Panel1.Height + Panel3.Height + Panel4.Height;
@ -330,9 +341,9 @@ begin
end end
else EditSize.Enabled := False; else EditSize.Enabled := False;
case RadioGroup1.ItemIndex of case RadioGroup1.ItemIndex of
0: OkBtn.Enabled := (Length(EditName.Text) > 0) And 0..1: OkBtn.Enabled := (Length(EditName.Text) > 0) And
(SelectType.ItemIndex > -1); (SelectType.ItemIndex > -1);
1: OkBtn.Enabled := (SelectKeyFields.Text <> '') And 2: OkBtn.Enabled := (SelectKeyFields.Text <> '') And
(DataSetsCombo.ItemIndex > -1) And (DataSetsCombo.ItemIndex > -1) And
(SelectLookupKeys.Text <> '') And (SelectLookupKeys.Text <> '') And
(SelectResultField.Text <> ''); (SelectResultField.Text <> '');