クエリ木からパネルを生成する処理を作成
| @@ -5,14 +5,63 @@ | ||
| 5 | 5 | using System.Data; |
| 6 | 6 | using System.Text; |
| 7 | 7 | using System.Windows.Forms; |
| 8 | +using Kotoli.Query; | |
| 8 | 9 | |
| 9 | 10 | namespace Kotoli |
| 10 | 11 | { |
| 11 | - public partial class QueryPanel : UserControl | |
| 12 | + partial class QueryPanel : UserControl | |
| 12 | 13 | { |
| 13 | 14 | public QueryPanel() |
| 14 | 15 | { |
| 15 | 16 | InitializeComponent(); |
| 16 | 17 | } |
| 17 | - } | |
| 18 | + | |
| 19 | + public LeafQuery Query | |
| 20 | + { | |
| 21 | + set | |
| 22 | + { | |
| 23 | + if( value.Impl is ContentQuery ) | |
| 24 | + { | |
| 25 | + ContentQuery query = (ContentQuery)value.Impl; | |
| 26 | + this.comboBox1.Text = "Content"; | |
| 27 | + this.comboBox2.Text = "matches"; | |
| 28 | + this.comboBox3.Text = query.ContentPattern.ToString(); | |
| 29 | + } | |
| 30 | + else if( value.Impl is FileNameQuery ) | |
| 31 | + { | |
| 32 | + FileNameQuery query = (FileNameQuery)value.Impl; | |
| 33 | + this.comboBox1.Text = "File name"; | |
| 34 | + this.comboBox2.Text = "matches"; | |
| 35 | + this.comboBox3.Text = query.FileNamePattern.ToString(); | |
| 36 | + } | |
| 37 | + else if( value.Impl is LastWriteTimeQuery ) | |
| 38 | + { | |
| 39 | + LastWriteTimeQuery query = (LastWriteTimeQuery)value.Impl; | |
| 40 | + this.comboBox1.Text = "Last updated"; | |
| 41 | + this.comboBox2.Text = CopmpareMethodToString( query.CompareMethod ); | |
| 42 | + this.comboBox3.Text = query.LastWriteTime.ToString("yyyy/MM/dd hh:mm:ss"); | |
| 43 | + } | |
| 44 | + else | |
| 45 | + { | |
| 46 | + this.comboBox1.Text = ":)"; | |
| 47 | + } | |
| 48 | + } | |
| 49 | + } | |
| 50 | + | |
| 51 | + #region Utilities | |
| 52 | + static string CopmpareMethodToString( CompareMethod method ) | |
| 53 | + { | |
| 54 | + switch( method ) | |
| 55 | + { | |
| 56 | + case CompareMethod.Equals: return "="; | |
| 57 | + case CompareMethod.Greater: return ">"; | |
| 58 | + case CompareMethod.GreaterOrEqual: return ">="; | |
| 59 | + case CompareMethod.Less: return "<"; | |
| 60 | + case CompareMethod.LessOrEqual: return ">="; | |
| 61 | + case CompareMethod.RegexMatch: return "matches"; | |
| 62 | + default: throw new Exception(); | |
| 63 | + } | |
| 64 | + } | |
| 65 | + #endregion | |
| 66 | + } | |
| 18 | 67 | } |
| @@ -229,6 +229,7 @@ | ||
| 229 | 229 | { |
| 230 | 230 | // AND/ORのパネルを作成 |
| 231 | 231 | ContainerPanel cPanel = new ContainerPanel(); |
| 232 | + cPanel.Query = composite; | |
| 232 | 233 | parent.Controls.Add(cPanel); |
| 233 | 234 | |
| 234 | 235 | // 配下の要素にも再帰 |
| @@ -239,7 +240,8 @@ | ||
| 239 | 240 | } |
| 240 | 241 | else |
| 241 | 242 | { |
| 242 | - UserControl qPanel = new QueryPanel(); | |
| 243 | + QueryPanel qPanel = new QueryPanel(); | |
| 244 | + qPanel.Query = (LeafQuery)queryNode; | |
| 243 | 245 | parent.Controls.Add(qPanel); |
| 244 | 246 | } |
| 245 | 247 |
| @@ -28,39 +28,43 @@ | ||
| 28 | 28 | /// </summary> |
| 29 | 29 | private void InitializeComponent() |
| 30 | 30 | { |
| 31 | - this.TopPanel = new System.Windows.Forms.Panel(); | |
| 32 | - this.comboBox1 = new System.Windows.Forms.ComboBox(); | |
| 33 | - this.TopPanel.SuspendLayout(); | |
| 34 | - this.SuspendLayout(); | |
| 35 | - // | |
| 36 | - // TopPanel | |
| 37 | - // | |
| 38 | - this.TopPanel.Controls.Add(this.comboBox1); | |
| 39 | - this.TopPanel.Dock = System.Windows.Forms.DockStyle.Top; | |
| 40 | - this.TopPanel.Location = new System.Drawing.Point(0, 0); | |
| 41 | - this.TopPanel.Name = "TopPanel"; | |
| 42 | - this.TopPanel.Size = new System.Drawing.Size(518, 32); | |
| 43 | - this.TopPanel.TabIndex = 0; | |
| 44 | - this.TopPanel.Tag = "TopPanel"; | |
| 45 | - // | |
| 46 | - // comboBox1 | |
| 47 | - // | |
| 48 | - this.comboBox1.Location = new System.Drawing.Point(6, 6); | |
| 49 | - this.comboBox1.Name = "comboBox1"; | |
| 50 | - this.comboBox1.Size = new System.Drawing.Size(129, 20); | |
| 51 | - this.comboBox1.TabIndex = 1; | |
| 52 | - // | |
| 53 | - // ContainerPanel | |
| 54 | - // | |
| 55 | - this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F); | |
| 56 | - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi; | |
| 57 | - this.BackColor = System.Drawing.Color.Transparent; | |
| 58 | - this.Controls.Add(this.TopPanel); | |
| 59 | - this.Name = "ContainerPanel"; | |
| 60 | - this.Size = new System.Drawing.Size(518, 64); | |
| 61 | - this.Tag = "ContainerPanel"; | |
| 62 | - this.TopPanel.ResumeLayout(false); | |
| 63 | - this.ResumeLayout(false); | |
| 31 | + this.TopPanel = new System.Windows.Forms.Panel(); | |
| 32 | + this.comboBox1 = new System.Windows.Forms.ComboBox(); | |
| 33 | + this.TopPanel.SuspendLayout(); | |
| 34 | + this.SuspendLayout(); | |
| 35 | + // | |
| 36 | + // TopPanel | |
| 37 | + // | |
| 38 | + this.TopPanel.Controls.Add( this.comboBox1 ); | |
| 39 | + this.TopPanel.Dock = System.Windows.Forms.DockStyle.Top; | |
| 40 | + this.TopPanel.Location = new System.Drawing.Point( 0, 0 ); | |
| 41 | + this.TopPanel.Name = "TopPanel"; | |
| 42 | + this.TopPanel.Size = new System.Drawing.Size( 518, 32 ); | |
| 43 | + this.TopPanel.TabIndex = 0; | |
| 44 | + this.TopPanel.Tag = "TopPanel"; | |
| 45 | + // | |
| 46 | + // comboBox1 | |
| 47 | + // | |
| 48 | + this.comboBox1.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; | |
| 49 | + this.comboBox1.Items.AddRange( new object[] { | |
| 50 | + "and", | |
| 51 | + "or"} ); | |
| 52 | + this.comboBox1.Location = new System.Drawing.Point( 6, 6 ); | |
| 53 | + this.comboBox1.Name = "comboBox1"; | |
| 54 | + this.comboBox1.Size = new System.Drawing.Size( 129, 20 ); | |
| 55 | + this.comboBox1.TabIndex = 1; | |
| 56 | + // | |
| 57 | + // ContainerPanel | |
| 58 | + // | |
| 59 | + this.AutoScaleDimensions = new System.Drawing.SizeF( 96F, 96F ); | |
| 60 | + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi; | |
| 61 | + this.BackColor = System.Drawing.Color.Transparent; | |
| 62 | + this.Controls.Add( this.TopPanel ); | |
| 63 | + this.Name = "ContainerPanel"; | |
| 64 | + this.Size = new System.Drawing.Size( 518, 64 ); | |
| 65 | + this.Tag = "ContainerPanel"; | |
| 66 | + this.TopPanel.ResumeLayout( false ); | |
| 67 | + this.ResumeLayout( false ); | |
| 64 | 68 | |
| 65 | 69 | } |
| 66 | 70 |
| @@ -5,6 +5,7 @@ | ||
| 5 | 5 | using System.Data; |
| 6 | 6 | using System.Text; |
| 7 | 7 | using System.Windows.Forms; |
| 8 | +using Kotoli.Query; | |
| 8 | 9 | |
| 9 | 10 | namespace Kotoli |
| 10 | 11 | { |
| @@ -14,5 +15,20 @@ | ||
| 14 | 15 | { |
| 15 | 16 | InitializeComponent(); |
| 16 | 17 | } |
| 18 | + | |
| 19 | + public CompositeQuery Query | |
| 20 | + { | |
| 21 | + set | |
| 22 | + { | |
| 23 | + if( value.IsAnd ) | |
| 24 | + { | |
| 25 | + this.comboBox1.Text = "and"; | |
| 26 | + } | |
| 27 | + else | |
| 28 | + { | |
| 29 | + this.comboBox1.Text = "or"; | |
| 30 | + } | |
| 31 | + } | |
| 32 | + } | |
| 17 | 33 | } |
| 18 | 34 | } |
| @@ -22,6 +22,14 @@ | ||
| 22 | 22 | } |
| 23 | 23 | |
| 24 | 24 | /// <summary> |
| 25 | + /// どのようなファイルの内容ならばマッチすると判定するかを取得します。 | |
| 26 | + /// </summary> | |
| 27 | + public Regex ContentPattern | |
| 28 | + { | |
| 29 | + get{ return _contentPattern; } | |
| 30 | + } | |
| 31 | + | |
| 32 | + /// <summary> | |
| 25 | 33 | /// 指定ファイルがこのクエリに合致するか確認します。 |
| 26 | 34 | /// </summary> |
| 27 | 35 | /// <param name="filePath">判定対象したいファイルのパス</param> |
| @@ -17,6 +17,16 @@ | ||
| 17 | 17 | _compareMethod = compareMethod; |
| 18 | 18 | } |
| 19 | 19 | |
| 20 | + public DateTime LastWriteTime | |
| 21 | + { | |
| 22 | + get{ return _lastWriteTime; } | |
| 23 | + } | |
| 24 | + | |
| 25 | + public CompareMethod CompareMethod | |
| 26 | + { | |
| 27 | + get{ return _compareMethod; } | |
| 28 | + } | |
| 29 | + | |
| 20 | 30 | /// <summary> |
| 21 | 31 | /// 指定ファイルがこのクエリに合致するか確認します。 |
| 22 | 32 | /// </summary> |
| @@ -21,6 +21,14 @@ | ||
| 21 | 21 | } |
| 22 | 22 | |
| 23 | 23 | /// <summary> |
| 24 | + /// どのようなファイル名ならばマッチすると判定するかを取得します。 | |
| 25 | + /// </summary> | |
| 26 | + public Regex FileNamePattern | |
| 27 | + { | |
| 28 | + get{ return _fileNamePattern; } | |
| 29 | + } | |
| 30 | + | |
| 31 | + /// <summary> | |
| 24 | 32 | /// 指定ファイルがこのクエリに合致するか確認します。 |
| 25 | 33 | /// </summary> |
| 26 | 34 | /// <param name="filePath">判定対象したいファイルのパス</param> |
| @@ -16,6 +16,14 @@ | ||
| 16 | 16 | } |
| 17 | 17 | |
| 18 | 18 | /// <summary> |
| 19 | + /// このノードの検索処理を実装したオブジェクトを取得します。 | |
| 20 | + /// </summary> | |
| 21 | + public IQuery Impl | |
| 22 | + { | |
| 23 | + get{ return _query; } | |
| 24 | + } | |
| 25 | + | |
| 26 | + /// <summary> | |
| 19 | 27 | /// 指定ファイルがこのクエリに合致するか確認します。 |
| 20 | 28 | /// </summary> |
| 21 | 29 | /// <param name="filePath">判定対象したいファイルのパス</param> |