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