Home > m > gui > ltpdaRepoGUI > callbacks > buildConditions.m

buildConditions

PURPOSE ^

SYNOPSIS ^

function buildConditions(varargin)

DESCRIPTION ^

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function buildConditions(varargin)
0002 
0003 
0004 panel   = varargin{1};
0005 Ppos    = get(panel, 'Position');
0006 mainfig = findobj('Tag', 'LTPDARepomainfig');
0007 Nc      = getappdata(mainfig, 'Nconditions');
0008 conn    = getappdata(mainfig, 'connection');
0009 Gproperties = getappdata(mainfig, 'Gproperties');
0010 
0011 % before deleting, record the table selection
0012 tableSelected = getappdata(mainfig, 'tableSelected')
0013 
0014 delete(get(panel, 'Children'))
0015 drawnow
0016 %--------------------------------------------------------------------------
0017 %-- Draw Table selection
0018 
0019 % get tables
0020 tables  = getTables(conn);
0021 Sleft   = 10;
0022 Sheight = 20;
0023 Sbottom = Ppos(2) + Ppos(4) - 20 - Sheight;
0024 Swidth  = 50;
0025 
0026 sth = uicontrol(panel,'Style','text',...
0027                 'String', 'From',...
0028                 'Fontsize', 14,...
0029                 'BackgroundColor', Gproperties.Gcol,...
0030                 'HorizontalAlignment', 'left',...
0031                 'Position',[Sleft Sbottom Swidth Sheight]);
0032 
0033 Sleft  = Sleft + Swidth + 10;
0034 Swidth = 150;
0035 pmh = uicontrol(panel,'Style','popupmenu',...
0036                 'String', tables,...
0037                 'Fontsize', 14,...
0038                 'BackgroundColor', Gproperties.Gcol,...
0039                 'Value', tableSelected,...
0040                 'Position',[Sleft Sbottom Swidth Sheight],...
0041                 'Tag', 'tableSelect');
0042 
0043 set(pmh, 'Callback', {'cb_tableSelect', pmh, mainfig});
0044 
0045 %--------------------------------------------------------------------------
0046 %-- Draw Fields Selection list
0047 
0048 % get fields
0049 fields = getFields(conn);
0050 pos = get(pmh, 'Position');
0051 Sleft   = 10;
0052 Sheight = 20;
0053 Sbottom = pos(2) + pos(4) - 40 - Sheight;
0054 Swidth  = 50;
0055 
0056 sth = uicontrol(panel,'Style','text',...
0057                 'String', 'Select',...
0058                 'Fontsize', 14,...
0059                 'BackgroundColor', Gproperties.Gcol,...
0060                 'HorizontalAlignment', 'left',...
0061                 'Position',[Sleft Sbottom Swidth Sheight]);
0062 
0063 Sleft   = Sleft + Swidth + 10;
0064 Swidth  = 150;
0065 Sheight = 200;
0066 Sbottom = pos(2) + pos(4) - 40 - Sheight;
0067 lbh = uicontrol(panel,'Style','listbox',...
0068                 'String', fields,...
0069                 'Value',1,...
0070                 'BackgroundColor', 'w',...
0071                 'Fontsize', 14,...
0072                 'Max', 1000,...
0073                 'Position',[Sleft Sbottom Swidth Sheight],...
0074                 'Tag', 'fieldsList');
0075 
0076 set(lbh, 'Callback', {'cb_fieldSelect', pmh, mainfig});
0077               
0078 %--------------------------------------------------------------------------
0079 %-- Query display
0080 listpos = get(lbh, 'Position');
0081 Sleft   = 10;
0082 Sheight = 40;
0083 Sbottom = listpos(2)  - 40 - Sheight;
0084 Swidth  = 60;
0085 
0086 sth = uicontrol(panel,'Style','text',...
0087                 'String', 'Query:',...
0088                 'Fontsize', 14,...
0089                 'Max', 5,...
0090                 'BackgroundColor', Gproperties.Gcol,...
0091                 'HorizontalAlignment', 'left',...
0092                 'Position', [Sleft Sbottom Swidth Sheight]);
0093 
0094 Sleft   = 10 + Swidth + 20;
0095 Swidth  = 650;
0096 Sheight = 100;
0097 Sbottom = listpos(2)  - 40 - Sheight;
0098 sth = uicontrol(panel,'Style','edit',...
0099                 'String', '',...
0100                 'Fontsize', 14,...
0101                 'Max', 5,...
0102                 'BackgroundColor', 'w',...
0103                 'HorizontalAlignment', 'left',...
0104                 'Position', [Sleft Sbottom Swidth Sheight],...
0105                 'Tag', 'queryDisplayTxt');
0106 
0107 
0108               
0109 %--------------------------------------------------------------------------
0110 %-- Draw conditions
0111 
0112 conditions = {'=', '<>', '<=', '>=', '<', '>', 'like', 'not like', 'is'};
0113 compounds  = {'AND', 'OR', 'XOR'};
0114 
0115 pos = get(lbh, 'Position');
0116 Sleft   = pos(1) + pos(3) + 20;
0117 Sheight = 20;
0118 Sbottom = Ppos(2) + Ppos(4) - 20 - Sheight;
0119 Swidth  = 50;
0120 
0121 sth = uicontrol(panel,'Style','text',...
0122                 'String', 'Where',...
0123                 'Fontsize', 14,...
0124                 'BackgroundColor', Gproperties.Gcol,...
0125                 'HorizontalAlignment', 'left',...
0126                 'Position',[Sleft Sbottom Swidth Sheight]);
0127 
0128 
0129 % pos = get(sth, 'Position');
0130 Cheight = 20;
0131 
0132 for k=1:Nc
0133   Cleft   = pos(1) + pos(3) + 20;
0134   Cbottom = pos(2) + pos(4)  - (k-1)*(Cheight+20);
0135   Cwidth  = 150;
0136   % Field Dropdown
0137   pmh = uicontrol(panel,'Style','popupmenu',...
0138     'String', fields,...
0139     'Fontsize', 14,...
0140     'BackgroundColor', Gproperties.Gcol,...
0141     'Value',1,'Position',[Cleft Cbottom Cwidth Cheight],...
0142     'Tag', sprintf('c%02dField', k));
0143   set(pmh, 'Callback', 'buildquery');
0144 
0145   % Condition Dropdown
0146   Cleft  = Cleft + Cwidth + 20;
0147   Cwidth = 100;
0148   pmh = uicontrol(panel,'Style','popupmenu',...
0149     'String', conditions,...
0150     'Fontsize', 14,...
0151     'BackgroundColor', Gproperties.Gcol,...
0152     'Value',1,'Position',[Cleft Cbottom Cwidth Cheight],...
0153     'Tag', sprintf('c%02dCondition', k));
0154   set(pmh, 'Callback', 'buildquery');
0155   
0156   % Value txt box
0157   Cleft  = Cleft + Cwidth + 20;
0158   Cwidth = 150;
0159   sth = uicontrol(panel,'Style','edit',...
0160     'String','',...
0161     'Fontsize', 14,...
0162     'BackgroundColor', 'w',...
0163     'HorizontalAlignment', 'left',...
0164     'Position',[Cleft Cbottom Cwidth Cheight],...
0165     'Tag', sprintf('c%02dValue', k));
0166   set(sth, 'Callback', 'buildquery');
0167   
0168   % Add compound statement
0169   if k<Nc
0170     
0171     Cleft  = Cleft + Cwidth + 20;
0172     Cwidth = 60;
0173     pmh = uicontrol(panel,'Style','popupmenu',...
0174       'String', compounds,...
0175       'Fontsize', 10,...
0176       'BackgroundColor', Gproperties.Gcol,...
0177       'Value',1,'Position',[Cleft Cbottom Cwidth Cheight],...
0178       'Tag', sprintf('c%02dCompound', k));
0179     set(pmh, 'Callback', 'buildquery');
0180     
0181   end
0182   
0183 end
0184 
0185 %--------------------------------------------------------------------------
0186 %-- add +/- buttons
0187 k = Nc+1;
0188 Bbottom = pos(2) + pos(4)  - (k-1)*(Cheight+20); 
0189 Bleft   = pos(1) + pos(3) + 20;
0190 Bheight = 20;
0191 Bwidth  = 20;
0192 pbh = uicontrol(panel,'Style','pushbutton','Fontsize', 14, 'String','+',...
0193                 'Position',[Bleft Bbottom Bwidth Bheight ],...
0194                 'Tag', 'condPlusBtn');
0195 set(pbh, 'Callback', {'cb_condPlusBtn', pbh, panel, mainfig});
0196 Bleft   = pos(1) + pos(3) + 20 + 30;
0197 pbh = uicontrol(panel,'Style','pushbutton','Fontsize', 14, 'String','-',...
0198                 'Position',[Bleft Bbottom Bwidth Bheight ],...
0199                 'Tag', 'condSubtractBtn');
0200 set(pbh, 'Callback', {'cb_condSubtractBtn', pbh, panel, mainfig});
0201 
0202 
0203 %--------------------------------------------------------------------------
0204 %-- order by
0205 k = Nc + 2;
0206 Sleft   = pos(1) + pos(3) + 20;
0207 Sheight = 20;
0208 Swidth  = 60;
0209 Sbottom = pos(2) + pos(4)  - (k-1)*(Cheight+20); 
0210 sth = uicontrol(panel,'Style','text',...
0211                 'String', 'Order by',...
0212                 'Fontsize', 14,...
0213                 'BackgroundColor', Gproperties.Gcol,...
0214                 'HorizontalAlignment', 'left',...
0215                 'Position',[Sleft Sbottom Swidth Sheight]);
0216 
0217 % Field Dropdown
0218 Sleft = pos(1) + pos(3) + 20 + Swidth + 20;
0219 Swidth = 100;
0220 pmh = uicontrol(panel,'Style','popupmenu',...
0221   'String', fields,...
0222   'Fontsize', 14,...
0223   'BackgroundColor', Gproperties.Gcol,...
0224   'Value',1,'Position',[Sleft Sbottom Swidth Sheight],...
0225   'Tag', 'fieldOrderBy');
0226 set(pmh, 'Callback', 'buildquery');
0227 
0228 % Desc Dropdown
0229 Sleft = Sleft + 20 + Swidth;
0230 Swidth = 100;
0231 pmh = uicontrol(panel,'Style','popupmenu',...
0232   'String', {'DESC', 'ASC'},...
0233   'Fontsize', 14,...
0234   'BackgroundColor', Gproperties.Gcol,...
0235   'Value',1,'Position',[Sleft Sbottom Swidth Sheight],...
0236   'Tag', 'sortDir');
0237 set(pmh, 'Callback', 'buildquery');
0238 
0239 
0240 %--------------------------------------------------------------------------
0241 %-- Run query
0242 
0243 k = Nc + 3;
0244 Sleft   = Ppos(1) + 10;
0245 Sheight = 20;
0246 Swidth  = 100;
0247 Sbottom = Ppos(2) + 10; 
0248 pbh = uicontrol(panel,'Style','pushbutton','String','Execute query',...
0249                 'Position',[Sleft Sbottom Swidth Sheight ],...
0250                 'Tag', 'refreshListBtn');
0251 set(pbh, 'Callback', {'cb_executeQuery', pbh, mainfig});
0252 
0253 
0254 % Build query
0255 buildquery()
0256 
0257 drawnow
0258

Generated on Fri 02-Nov-2007 19:39:27 by m2html © 2003