extra: import at 3.0.1 beta 1
[mozilla-extra.git] / extensions / manticore / bookmarks / BookmarksWindow.cs
blob8fadd21cd8745dae025d335c606e062e43d11bcd
1 /* -*- Mode: C#; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
3 * ***** BEGIN LICENSE BLOCK *****
4 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
6 * The contents of this file are subject to the Mozilla Public License Version
7 * 1.1 (the "License"); you may not use this file except in compliance with
8 * the License. You may obtain a copy of the License at
9 * http://www.mozilla.org/MPL/
11 * Software distributed under the License is distributed on an "AS IS" basis,
12 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
13 * for the specific language governing rights and limitations under the
14 * License.
16 * The Original Code is Manticore.
18 * The Initial Developer of the Original Code is
19 * Silverstone Interactive.
20 * Portions created by the Initial Developer are Copyright (C) 2001
21 * the Initial Developer. All Rights Reserved.
23 * Contributor(s):
24 * Ben Goodger <ben@netscape.com> (Original Author)
26 * Alternatively, the contents of this file may be used under the terms of
27 * either the GNU General Public License Version 2 or later (the "GPL"), or
28 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
29 * in which case the provisions of the GPL or the LGPL are applicable instead
30 * of those above. If you wish to allow use of your version of this file only
31 * under the terms of either the GPL or the LGPL, and not to allow others to
32 * use your version of this file under the terms of the MPL, indicate your
33 * decision by deleting the provisions above and replace them with the notice
34 * and other provisions required by the GPL or the LGPL. If you do not delete
35 * the provisions above, a recipient may use your version of this file under
36 * the terms of any one of the MPL, the GPL or the LGPL.
38 * ***** END LICENSE BLOCK ***** */
40 namespace Silverstone.Manticore.Bookmarks
42 using System;
43 using System.Drawing;
44 using System.Collections;
45 using System.ComponentModel;
46 using System.Windows.Forms;
48 using Silverstone.Manticore.App;
49 using Silverstone.Manticore.Core;
50 using Silverstone.Manticore.Toolkit;
51 using Silverstone.Manticore.Bookmarks;
52 using Silverstone.Manticore.Browser;
54 /// <summary>
55 /// Summary description for BookmarksWindow.
56 /// </summary>
57 public class BookmarksWindow : ManticoreWindow
59 private StatusBar mStatusBar;
60 private StatusBarPanel mStatusBarPanel;
61 private BookmarksTreeView mBookmarksTree;
63 private BaseTreeBuilder mBuilder = null;
65 public BookmarksWindow()
67 mType = "BookmarksWindow";
69 Init();
72 protected void Init()
74 // Set up UI
75 InitializeComponent();
77 base.Init();
80 #region Windows Form Designer generated code
81 /// <summary>
82 /// Required method for Designer support - do not modify
83 /// the contents of this method with the code editor.
84 /// </summary>
85 private void InitializeComponent()
87 mStatusBar = new StatusBar();
88 mStatusBarPanel = new StatusBarPanel();
89 ((ISupportInitialize)mStatusBarPanel).BeginInit();
90 SuspendLayout();
92 mStatusBar.Name = "statusBar";
93 mStatusBar.Panels.Add(mStatusBarPanel);
94 mStatusBar.TabIndex = 0;
95 mStatusBar.Text = "";
96 mStatusBarPanel.Text = "";
97 Controls.Add(mStatusBar);
99 mBookmarksTree = new BookmarksTreeView("BookmarksRoot");
100 mBookmarksTree.Dock = DockStyle.Fill;
101 mBookmarksTree.ImageIndex = -1;
102 mBookmarksTree.Name = "bookmarksTree";
103 mBookmarksTree.SelectedImageIndex = -1;
104 mBookmarksTree.Size = new System.Drawing.Size(584, 409);
105 mBookmarksTree.TabIndex = 1;
107 mBookmarksTree.AfterSelect += new TreeViewEventHandler(OnTreeAfterSelect);
108 mBookmarksTree.DoubleClick += new EventHandler(OnTreeDoubleClick);
110 Controls.Add(mBookmarksTree);
111 mBookmarksTree.Build();
114 AutoScaleBaseSize = new System.Drawing.Size(5, 13);
115 ClientSize = new System.Drawing.Size(584, 429);
116 Name = "BookmarksWindow";
117 Text = Environment.UserName + "'s Bookmarks";
118 ((ISupportInitialize)(mStatusBarPanel)).EndInit();
119 ResumeLayout(false);
121 #endregion
123 protected void OnTreeAfterSelect(Object sender, TreeViewEventArgs e)
125 ManticoreTreeNode node = e.Node as ManticoreTreeNode;
126 Bookmarks bmks = ServiceManager.Bookmarks;
127 String bookmarkURL = bmks.GetBookmarkAttribute(node.Data as String, "url");
128 mStatusBar.Text = bookmarkURL;
131 protected void OnTreeDoubleClick(Object sender, EventArgs e)
133 ManticoreTreeNode node = mBookmarksTree.SelectedNode as ManticoreTreeNode;
134 Bookmarks bmks = ServiceManager.Bookmarks;
135 String bookmarkURL = bmks.GetBookmarkAttribute(node.Data as String, "url");
136 if (bookmarkURL != "")
138 WindowMediator wm = ServiceManager.WindowMediator;
139 BrowserWindow window = wm.GetMostRecentWindow("BrowserWindow") as BrowserWindow;
140 if (window != null)
141 window.LoadURL(bookmarkURL);