Changeset 34415

Show
Ignore:
Timestamp:
07/13/09 20:30:25 (4 years ago)
Author:
hoge1e3
Message:

文書の変更にリストが同期

Location:
lang/csharp/soyText/soyText
Files:
18 modified

Legend:

Unmodified
Added
Removed
  • lang/csharp/soyText/soyText/DThread.cs

    r33756 r34415  
    1010    { 
    1111        Thread th; 
    12         public DThread(string name,ThreadStart t) 
     12        /*public DThread(string name,ThreadStart t) 
    1313        { 
    1414            th = new Thread(delegate() { 
     
    1616            }); 
    1717            th.Name = name; 
    18         } 
     18        }*/ 
    1919        public void Start() 
    2020        { 
  • lang/csharp/soyText/soyText/Debug.cs

    r34144 r34415  
    4141        public static void syslog(string msg) 
    4242        { 
    43             if (syslogF == null) 
     43            /*if (syslogF == null) 
    4444            { 
    4545                syslogF = Mkdir.openStream("sys.log", true); 
    46             } 
    47              
     46            }*/ 
     47            System.Diagnostics.Debug.Print(msg); 
    4848        } 
    4949    } 
  • lang/csharp/soyText/soyText/DocumentSet.cs

    r34144 r34415  
    1313    public class DocumentSet 
    1414    { 
     15        internal ListSyncerSet listSyncerSet = new ListSyncerSet(); 
    1516        internal SearchLogSet searchLogSet; 
    1617        public int maxHandle = -1; 
     
    6263            return (d == 0 ? 0 : (d < 0 ? 1 : -1)); 
    6364        } 
     65        static int count = 0; 
    6466        public DocumentList getRecents() 
    6567        { 
     68            Debug.syslog("Getrecent called " + (++count) + "times"); 
    6669            if (cache != null) return cache.getRecents(); 
    6770            Debug.print("文書一覧取得中..."); 
     
    171174            if (cache == null) return; 
    172175            cache.update(document); 
     176            listSyncerSet.notifyAll(document); 
    173177        } 
    174178    } 
  • lang/csharp/soyText/soyText/EditorTab.cs

    r34185 r34415  
    1818        public Workspace workspace; 
    1919        public Form2 parentForm; 
    20         public static EditorTab active; 
     20        public static EditorTab active=null; 
    2121        Document _curDoc; 
    2222        public Document curDoc 
     
    3232        public void onLoad(object sender, EventArgs e) 
    3333        { 
    34             if (searchOnLoad) initList(); 
    35             ActiveControl = command; 
    36         } 
    37         public void initList() 
    38         { 
    39             if (listInited) return; 
    40             documentSet.getRecents(); 
     34            /*if (searchOnLoad) initList(); 
     35            ActiveControl = command;*/ 
     36        } 
     37        public void reload() 
     38        { 
     39            if (!listInited) 
     40            { 
     41                listInited = true; 
     42                documentSet.getRecents(); 
     43            } 
    4144            if (condition != "") 
    4245            { 
     
    4851                refreshList(null); 
    4952            } 
    50             listInited = true; 
    5153        } 
    5254        /*public String statusText 
     
    5961        bool searchOnLoad; 
    6062        bool listInited = false; 
    61  
     63        ListSyncer listSyncer; 
    6264        public EditorTab(Form2 parent,string condition, bool searchOnLoad) 
    6365        { 
     
    7476            inst++; 
    7577            defaultInstance = this; 
     78            listSyncer = documentSet.listSyncerSet.add(docListBox, condition); 
    7679        } 
    7780 
     
    9598        public void refreshList() 
    9699        { 
     100            /*if (searchThread.running) 
     101            { 
     102                Debug.syslog("Already running.... stop"); 
     103                     
     104                return; 
     105            }*/ 
    97106            refreshList(condition); 
    98107        } 
     
    104113        } 
    105114        static bool firstTab=true; 
     115         
    106116        public void refreshList(string kw) 
    107117        { 
     
    120130            } 
    121131            condition = newCond; 
     132            listSyncer.condExpr=condition; 
    122133            if (titleChanged != null) titleChanged(kw); 
    123134            if (documentSearcher != null) documentSearcher.terminate(); 
    124             /*Document searchLog=null; 
    125             if (kw != null && kw != "") 
    126             { 
    127                 searchLog = documentSet.searchLogSet.addOrGet(kw); 
    128                 searchLog.parsed["closed"] = "false"; 
    129                 searchLog.save(); 
    130             }*/ 
     135            
    131136            var ft = firstTab; 
    132137            firstTab = false; 
    133138            searchThread.exec(delegate(TerminableThread t) 
    134139            { 
     140                Debug.syslog("Start search kw="+kw); 
    135141                var cnt = 0; 
    136                 syncUI(delegate() 
     142                /*syncUI(delegate() 
    137143                { 
    138144                    docListBox.Items.Clear(); 
    139                 }); 
     145                });*/ 
     146                listSyncer.openSyncSession(); 
    140147                documentSearcher = documentSet.createDocumentSearcher(kw,true); 
    141148                                                
    142149                foreach (var d2 in documentSearcher.search())  
    143                 //delegate(Document d) 
    144150                { 
    145151                    var d = d2; 
     
    148154                        if (documentSet.searchLogSet.add(d)) 
    149155                        { 
    150                             //Debug.alert(d.parsed["condition"] + " - " + d.parsed["closed"]+" - "+(d.parsed["closed"] != "false")); 
     156                            Debug.syslog("newtab - " + d.parsed["condition"]+" ft = "+ft+"  closed ="+d.parsed["closed"]); 
    151157                            if (ft && d.parsed["closed"] != "true") 
    152158                            { 
     159 
    153160                                    syncUI(delegate() 
    154161                                    { 
     
    160167                        { 
    161168                            cnt++; 
    162                             syncUI(delegate() { docListBox.Items.Add(d); }); 
     169                            listSyncer.add(d); 
     170                            //syncUI(delegate() { docListBox.Items.Add(d); }); 
    163171                        }  
    164                         //return FoundHandlerAction.Accept; 
    165172                    } 
    166173                    else 
    167174                    { 
    168175                        break; 
    169                         //return FoundHandlerAction.End; 
    170176                    } 
    171                 }//); 
    172                 //documentSearcher.search2(); 
     177                } 
     178                listSyncer.closeSyncSession(); 
    173179                Debug.print("完了"); 
    174180            }); 
    175181        } 
    176 /*        public void syncUI(SyncUIAction u) 
    177         { 
    178             uiActionQueue.Enqueue(u); 
    179         }*/ 
    180182        public void newDocument() 
    181183        { 
     
    383385        internal void activate() 
    384386        { 
     387            if (active == this) return; 
    385388            active = this; 
     389 
     390            //if (searchOnLoad)  
     391            reload(); 
     392            ActiveControl = command; 
     393            //refreshList(); 
    386394        } 
    387395 
     
    390398            if (curDoc == null) newDocument(); 
    391399        } 
     400 
    392401    } 
    393402} 
  • lang/csharp/soyText/soyText/ExecForm.Designer.cs

    r34279 r34415  
    8888            this.lowerTable.RowCount = 1; 
    8989            this.lowerTable.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50F)); 
    90             this.lowerTable.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 107F)); 
     90            this.lowerTable.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 187F)); 
    9191            this.lowerTable.Size = new System.Drawing.Size(413, 187); 
    9292            this.lowerTable.TabIndex = 2; 
  • lang/csharp/soyText/soyText/ExecForm.cs

    r34279 r34415  
    2121        internal void exec(Document document) 
    2222        { 
    23             new DThread("Exec "+document.fileName,delegate() 
     23            new Thread(/*"Exec "+document.fileName,*/delegate() 
    2424            { 
    2525                var d = new DocExecutor(document, null, delegate(string o) 
  • lang/csharp/soyText/soyText/Form2.Designer.cs

    r34038 r34415  
    4646            this.実行RToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); 
    4747            this.外部プログラムを実行RToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); 
     48            this.tESTToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); 
    4849            this.timer1 = new System.Windows.Forms.Timer(this.components); 
    4950            this.tabMenu = new System.Windows.Forms.ContextMenuStrip(this.components); 
    5051            this.閉じるCToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); 
    5152            this.tabControl1 = new SoyText.TabControl2(); 
    52             this.tESTToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); 
    5353            this.menuStrip1.SuspendLayout(); 
    5454            this.tabMenu.SuspendLayout(); 
     
    178178            this.外部プログラムを実行RToolStripMenuItem.Click += new System.EventHandler(this.外部プログラムを実行RToolStripMenuItem_Click); 
    179179            //  
     180            // tESTToolStripMenuItem 
     181            //  
     182            this.tESTToolStripMenuItem.Name = "tESTToolStripMenuItem"; 
     183            this.tESTToolStripMenuItem.Size = new System.Drawing.Size(206, 22); 
     184            this.tESTToolStripMenuItem.Text = "TEST"; 
     185            this.tESTToolStripMenuItem.Click += new System.EventHandler(this.tESTToolStripMenuItem_Click); 
     186            //  
    180187            // timer1 
    181188            //  
     
    209216            this.tabControl1.SelectedIndexChanged += new System.EventHandler(this.tabControl1_SelectedIndexChanged); 
    210217            //  
    211             // tESTToolStripMenuItem 
    212             //  
    213             this.tESTToolStripMenuItem.Name = "tESTToolStripMenuItem"; 
    214             this.tESTToolStripMenuItem.Size = new System.Drawing.Size(206, 22); 
    215             this.tESTToolStripMenuItem.Text = "TEST"; 
    216             this.tESTToolStripMenuItem.Click += new System.EventHandler(this.tESTToolStripMenuItem_Click); 
    217             //  
    218218            // Form2 
    219219            //  
     
    227227            this.Text = "Form2"; 
    228228            this.ResizeBegin += new System.EventHandler(this.Form2_ResizeBegin); 
     229            this.Activated += new System.EventHandler(this.Form2_Activated); 
    229230            this.FormClosed += new System.Windows.Forms.FormClosedEventHandler(this.Form2_FormClosed); 
    230231            this.MouseDown += new System.Windows.Forms.MouseEventHandler(this.Form2_MouseDown); 
  • lang/csharp/soyText/soyText/Form2.cs

    r34185 r34415  
    128128                curTab.activate(); 
    129129                Text = curTab.Text; 
    130                 curTab.initList(); 
     130                //curTab.initList(); 
    131131            } 
    132132        } 
     
    167167        private void Form2_ResizeBegin(object sender, EventArgs e) 
    168168        { 
     169            if (curTab == null) return; 
    169170            curTab.ResizeBegin(sender, e); 
    170171        } 
     
    172173        private void Form2_ResizeEnd(object sender, EventArgs e) 
    173174        { 
     175            if (curTab == null) return; 
    174176            curTab.ResizeEnd(sender, e); 
    175177        } 
     
    216218        } 
    217219 
     220        private void Form2_Activated(object sender, EventArgs e) 
     221        { 
     222            if (curTab!=null) curTab.activate(); 
     223        } 
     224 
    218225    } 
    219226} 
  • lang/csharp/soyText/soyText/ImportDialog.cs

    r33756 r34415  
    2828        { 
    2929            var i = new DocumentImporter(path.Text,workspace.documentSet); 
    30             new DThread("imp",delegate() 
     30            new Thread(delegate() 
    3131            { 
    3232                i.traverse(); 
  • lang/csharp/soyText/soyText/ListSyncer.cs

    r34296 r34415  
    1010    { 
    1111        static HashSet<ListSyncer> s=new HashSet<ListSyncer>(); 
    12         static ListSyncer add(ListBox list, SearchCondition cond) 
     12        public ListSyncer add(ListBox list, string cond) 
    1313        { 
    1414            var res = new ListSyncer(list, cond); 
     
    1616            return res; 
    1717        } 
     18        public void remove(ListSyncer listsyncer) 
     19        { 
     20            s.Remove(listsyncer); 
     21        } 
     22 
     23        internal void notifyAll(Document document) 
     24        { 
     25           /* foreach (var sy in s) 
     26            { 
     27                sy.update(document); 
     28            }*/ 
     29        } 
    1830    } 
    1931    internal class ListSyncer 
    2032    { 
    2133        ListBox list; 
     34        string _condExpr; 
     35        public string condExpr 
     36        { 
     37            set 
     38            { 
     39                if (_condExpr == value) return; 
     40                _condExpr = value; 
     41                cond = SearchCondition.fromExpression(value); 
     42                list.Items.Clear(); 
     43            } 
     44        } 
    2245        SearchCondition cond; 
    23         public ListSyncer(ListBox list, SearchCondition cond) 
     46        public ListSyncer(ListBox list, string condExpr) 
    2447        { 
    2548            this.list = list; 
    26             this.cond = cond; 
     49            this.condExpr = condExpr; 
    2750        } 
    28         public bool add(Document d) { 
     51         
     52        public bool update(Document d) 
     53        { 
     54            if (list.Items.Contains(d)) return removeUnlessMatch(d); 
     55            else return addIfMatch(d); 
     56        } 
     57        bool addIfMatch(Document d) { 
    2958            if (cond.matches(d)) 
    3059            { 
    31                 list.Items.Add(d); 
     60                add(d); 
    3261                return true; 
    3362            } 
    3463            return false; 
    3564        } 
    36         public bool remove(Document d) 
     65        public void add(Document d) 
    3766        { 
    38             if (list.Items.Contains(d)) 
     67            SyncUI.exe(delegate() 
    3968            { 
    40                 list.Items.Remove(d); 
     69                if (isFirstSession) 
     70                { 
     71                    list.Items.Add(d); 
     72                    return; 
     73                } 
     74                if (list.Items.Contains(d)) return; 
     75                if (list.Items.Count >= 1) 
     76                { 
     77                    list.Items.Insert(0, d); 
     78                } 
     79                else 
     80                { 
     81                    list.Items.Add(d); 
     82                } 
     83            }); 
     84 
     85        } 
     86        bool removeUnlessMatch(Document d) 
     87        { 
     88            if (!cond.matches(d)) 
     89            { 
     90                SyncUI.exe(delegate() 
     91                { 
     92                    if (!list.Items.Contains(d)) return; 
     93                    list.Items.Remove(d); 
     94                }); 
    4195                return true; 
    4296            } 
    4397            return false; 
    4498        } 
     99        bool isFirstSession; 
     100        public void openSyncSession() 
     101        { 
     102            isFirstSession = list.Items.Count == 0; 
     103            System.Diagnostics.Debug.Print("ISF "+cond+" : "+isFirstSession); 
     104        } 
     105        public void closeSyncSession() 
     106        { 
     107            removeAllUnmatch(); 
     108        } 
     109        private void removeAllUnmatch() 
     110        { 
     111            var ls = new object[list.Items.Count]; 
     112            list.Items.CopyTo(ls,0); 
     113            foreach (object e in ls) 
     114            { 
     115                if (e is Document) 
     116                { 
     117                    var d = (Document)e; 
     118                    if (!cond.matches(d)) 
     119                    { 
     120                        SyncUI.exe(delegate() 
     121                        { 
     122                            list.Items.Remove(d); 
     123                        }); 
     124                    } 
     125                } 
     126            } 
     127        } 
    45128    } 
    46129} 
  • lang/csharp/soyText/soyText/Program.cs

    r33756 r34415  
    1616            Application.EnableVisualStyles(); 
    1717            Application.SetCompatibleTextRenderingDefault(false); 
    18             Debug.Try("Main", delegate() 
    19             { 
     18            /*Debug.Try("Main", delegate() 
     19            {*/ 
    2020                Application.Run(new WorkspaceSelector()); 
    21             }); 
     21            //}); 
    2222        } 
    2323    } 
  • lang/csharp/soyText/soyText/TerminableThread.cs

    r33756 r34415  
    4141                    else _running = true; 
    4242                } 
    43                 if (r!=null) new DThread(name, r).Start(); 
     43                if (r!=null) new Thread(r).Start(); 
    4444            } 
    4545        } 
     
    7171                } 
    7272            } 
    73             if (r) new DThread(name, d).Start(); 
     73            if (r) new Thread(d).Start(); 
    7474        } 
    7575    } 
  • lang/csharp/soyText/soyText/bin/Debug/soyText.application

    r34279 r34415  
    1212        </dsig:Transforms> 
    1313        <dsig:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1" /> 
    14         <dsig:DigestValue>zUdISs7VamOXM/l91giRXwP07rk=</dsig:DigestValue> 
     14        <dsig:DigestValue>2V7AMEy6UTkeQ7vRbogHsGWi13w=</dsig:DigestValue> 
    1515      </hash> 
    1616    </dependentAssembly> 
  • lang/csharp/soyText/soyText/bin/Debug/soyText.exe.manifest

    r34279 r34415  
    113113  </dependency> 
    114114  <dependency> 
    115     <dependentAssembly dependencyType="install" allowDelayedBinding="true" codebase="soyText.exe" size="82944"> 
     115    <dependentAssembly dependencyType="install" allowDelayedBinding="true" codebase="soyText.exe" size="84480"> 
    116116      <assemblyIdentity name="soyText" version="1.0.0.0" language="neutral" processorArchitecture="msil" /> 
    117117      <hash> 
     
    120120        </dsig:Transforms> 
    121121        <dsig:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1" /> 
    122         <dsig:DigestValue>CBgmbBvumgAZxMXXzPeQPl0CgPk=</dsig:DigestValue> 
     122        <dsig:DigestValue>9VkzjS3QpI2zx/U6AIMTvmxrXhc=</dsig:DigestValue> 
    123123      </hash> 
    124124    </dependentAssembly> 
  • lang/csharp/soyText/soyText/bin/Debug/soyText.vshost.application

    r34279 r34415  
    1212        </dsig:Transforms> 
    1313        <dsig:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1" /> 
    14         <dsig:DigestValue>zUdISs7VamOXM/l91giRXwP07rk=</dsig:DigestValue> 
     14        <dsig:DigestValue>2V7AMEy6UTkeQ7vRbogHsGWi13w=</dsig:DigestValue> 
    1515      </hash> 
    1616    </dependentAssembly>