mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-02 12:07:52 +00:00
Fix bookmarks window, add new file for Window Mediator.
NOT PART OF BUILD
This commit is contained in:
parent
5828cbd866
commit
d19441396c
@ -37,6 +37,7 @@ namespace Silverstone.Manticore.Bookmarks
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.Windows.Forms;
|
||||
using System.Collections;
|
||||
|
||||
using Silverstone.Manticore.Core;
|
||||
using Silverstone.Manticore.Toolkit;
|
||||
@ -47,6 +48,7 @@ namespace Silverstone.Manticore.Bookmarks
|
||||
public class BookmarksTreeView : ManticoreTreeView
|
||||
{
|
||||
protected BaseTreeBuilder mBuilder;
|
||||
protected Queue mFilterAttributes;
|
||||
|
||||
public BookmarksTreeView(String aRoot)
|
||||
{
|
||||
@ -91,6 +93,30 @@ namespace Silverstone.Manticore.Bookmarks
|
||||
}
|
||||
}
|
||||
|
||||
public void AddCriteria(String[] aAttrValuePair)
|
||||
{
|
||||
if (mFilterAttributes == null)
|
||||
mFilterAttributes = new Queue();
|
||||
mFilterAttributes.Enqueue(aAttrValuePair);
|
||||
}
|
||||
|
||||
public override bool ShouldBuild(CommandTarget aTarget)
|
||||
{
|
||||
Bookmarks bmks = ServiceManager.Bookmarks;
|
||||
|
||||
if (mFilterAttributes != null)
|
||||
{
|
||||
IEnumerator criteria = mFilterAttributes.GetEnumerator();
|
||||
while (criteria.MoveNext())
|
||||
{
|
||||
String[] singleCriteria = criteria.Current as String[];
|
||||
if (bmks.GetBookmarkAttribute(aTarget.Data as String, singleCriteria[0]) != singleCriteria[1])
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public override int GetIconIndex(CommandTarget aTarget)
|
||||
{
|
||||
int index = 2;
|
||||
@ -133,7 +159,7 @@ namespace Silverstone.Manticore.Bookmarks
|
||||
protected void OnAfterLabelEdit(Object sender, NodeLabelEditEventArgs e)
|
||||
{
|
||||
ManticoreTreeNode root = GetRootItem();
|
||||
if (root != null)
|
||||
if (root != null && e.Label != "")
|
||||
{
|
||||
ManticoreTreeNode temp = e.Node as ManticoreTreeNode;
|
||||
String parentID = root.Data as String;
|
||||
|
@ -40,7 +40,10 @@ namespace Silverstone.Manticore.Bookmarks
|
||||
using System.ComponentModel;
|
||||
using System.Windows.Forms;
|
||||
|
||||
using Silverstone.Manticore.App;
|
||||
using Silverstone.Manticore.Core;
|
||||
using Silverstone.Manticore.Toolkit;
|
||||
using Silverstone.Manticore.Bookmarks;
|
||||
|
||||
/// <summary>
|
||||
/// Summary description for BookmarksWindow.
|
||||
@ -49,7 +52,7 @@ namespace Silverstone.Manticore.Bookmarks
|
||||
{
|
||||
private System.Windows.Forms.StatusBar statusBar1;
|
||||
private System.Windows.Forms.StatusBarPanel statusBarPanel1;
|
||||
private ManticoreTreeView treeView1;
|
||||
private BookmarksTreeView mBookmarksTree;
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
@ -65,18 +68,21 @@ namespace Silverstone.Manticore.Bookmarks
|
||||
InitializeComponent();
|
||||
|
||||
//
|
||||
// treeView1
|
||||
// mBookmarksTree
|
||||
//
|
||||
treeView1 = new ManticoreTreeView();
|
||||
treeView1.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
treeView1.ImageIndex = -1;
|
||||
treeView1.Name = "treeView1";
|
||||
treeView1.SelectedImageIndex = -1;
|
||||
treeView1.Size = new System.Drawing.Size(584, 409);
|
||||
treeView1.TabIndex = 1;
|
||||
mBookmarksTree = new BookmarksTreeView("BookmarksRoot");
|
||||
mBookmarksTree.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
mBookmarksTree.ImageIndex = -1;
|
||||
mBookmarksTree.Name = "bookmarksTree";
|
||||
mBookmarksTree.SelectedImageIndex = -1;
|
||||
mBookmarksTree.Size = new System.Drawing.Size(584, 409);
|
||||
mBookmarksTree.TabIndex = 1;
|
||||
|
||||
mBuilder = new BaseTreeBuilder(treeView1, null);
|
||||
mBuilder.Build();
|
||||
mBookmarksTree.AfterSelect += new TreeViewEventHandler(OnTreeAfterSelect);
|
||||
mBookmarksTree.DoubleClick += new EventHandler(OnTreeDoubleClick);
|
||||
|
||||
Controls.Add(mBookmarksTree);
|
||||
mBookmarksTree.Build();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -124,9 +130,7 @@ namespace Silverstone.Manticore.Bookmarks
|
||||
//
|
||||
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
|
||||
this.ClientSize = new System.Drawing.Size(584, 429);
|
||||
this.Controls.AddRange(new System.Windows.Forms.Control[] {
|
||||
this.treeView1,
|
||||
this.statusBar1});
|
||||
this.Controls.AddRange(new System.Windows.Forms.Control[] {this.statusBar1});
|
||||
this.Name = "BookmarksWindow";
|
||||
this.Text = "Bookmarks for %USER%";
|
||||
((System.ComponentModel.ISupportInitialize)(this.statusBarPanel1)).EndInit();
|
||||
@ -134,5 +138,22 @@ namespace Silverstone.Manticore.Bookmarks
|
||||
|
||||
}
|
||||
#endregion
|
||||
|
||||
protected void OnTreeAfterSelect(Object sender, TreeViewEventArgs e)
|
||||
{
|
||||
ManticoreTreeNode node = e.Node as ManticoreTreeNode;
|
||||
Bookmarks bmks = ServiceManager.Bookmarks;
|
||||
String bookmarkURL = bmks.GetBookmarkAttribute(node.Data as String, "url");
|
||||
statusBar1.Text = bookmarkURL;
|
||||
}
|
||||
|
||||
protected void OnTreeDoubleClick(Object sender, EventArgs e)
|
||||
{
|
||||
ManticoreTreeNode node = mBookmarksTree.SelectedNode as ManticoreTreeNode;
|
||||
Bookmarks bmks = ServiceManager.Bookmarks;
|
||||
String bookmarkURL = bmks.GetBookmarkAttribute(node.Data as String, "url");
|
||||
ManticoreApp.MostRecentBrowserWindow.LoadURL(bookmarkURL);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -86,6 +86,10 @@ namespace Silverstone.Manticore.Bookmarks
|
||||
mFolderTree.SelectedImageIndex = -1;
|
||||
mFolderTree.Size = new System.Drawing.Size(208, 144);
|
||||
mFolderTree.TabIndex = 5;
|
||||
|
||||
// Only show folders in this |TreeView|
|
||||
mFolderTree.AddCriteria(new String[] {"container", "true"});
|
||||
|
||||
Controls.Add(mFolderTree);
|
||||
mFolderTree.Build();
|
||||
|
||||
|
@ -223,7 +223,7 @@ namespace Silverstone.Manticore.Browser
|
||||
public void OnTitleChange(String aTitle)
|
||||
{
|
||||
mTitle = aTitle;
|
||||
this.Text = (aTitle == "about:blank") ? "Manticore" : aTitle + " - Manticore";
|
||||
this.Text = (aTitle == "about:blank") ? "No page to display" : aTitle;
|
||||
}
|
||||
|
||||
public void OnStatusTextChange(String aStatusText)
|
||||
@ -271,6 +271,12 @@ namespace Silverstone.Manticore.Browser
|
||||
case "file-exit":
|
||||
Quit();
|
||||
break;
|
||||
case "view-statusbar":
|
||||
if (mStatusBar.Visible)
|
||||
mStatusBar.Hide();
|
||||
else
|
||||
mStatusBar.Show();
|
||||
break;
|
||||
case "view-go-back":
|
||||
mWebBrowser.GoBack();
|
||||
break;
|
||||
|
29
extensions/manticore/core/WindowMediator.cs
Normal file
29
extensions/manticore/core/WindowMediator.cs
Normal file
@ -0,0 +1,29 @@
|
||||
|
||||
namespace Silverstone.Manticore.Core
|
||||
{
|
||||
using System;
|
||||
|
||||
/// <summary>
|
||||
/// Summary description for WindowMediator.
|
||||
/// </summary>
|
||||
public class WindowMediator
|
||||
{
|
||||
public WindowMediator()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public IEnumerator GetEnumerator()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// ManticoreWindow GetMostRecentWindow(String aType);
|
||||
// void SetMostRecentWindow(ManticoreWindow);
|
||||
// void RegisterWindow (ManticoreWindow);
|
||||
// void UnregisterWindow (ManticoreWindow);
|
||||
}
|
||||
}
|
@ -182,6 +182,11 @@ namespace Silverstone.Manticore.Toolkit
|
||||
if (childTarget == null && parentTarget == null)
|
||||
return;
|
||||
|
||||
// Determine based on conditions defined by the |TreeView|
|
||||
// whether or not this node should be built.
|
||||
if (!mTreeView.ShouldBuild(childTarget))
|
||||
return;
|
||||
|
||||
int childKey = childTarget.Data.GetHashCode();
|
||||
if (!mNodes.ContainsKey(childKey))
|
||||
{
|
||||
@ -263,8 +268,13 @@ namespace Silverstone.Manticore.Toolkit
|
||||
CommandTarget current = items.Current as CommandTarget;
|
||||
if (current != null)
|
||||
{
|
||||
// Determine based on conditions defined by the |TreeView|
|
||||
// whether or not this node should be built.
|
||||
if (!mTreeView.ShouldBuild(current))
|
||||
continue;
|
||||
|
||||
String id = current.Data as String;
|
||||
|
||||
|
||||
int idKey = id.GetHashCode();
|
||||
|
||||
if (!mNodes.ContainsKey(idKey))
|
||||
|
@ -232,6 +232,11 @@ namespace Silverstone.Manticore.Toolkit
|
||||
/// </summary>
|
||||
protected Color mIconTransparentColor;
|
||||
|
||||
public virtual bool ShouldBuild(CommandTarget aTarget)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public int GetIconIndex(String aIconURL)
|
||||
{
|
||||
if (aIconURL == "")
|
||||
|
Loading…
x
Reference in New Issue
Block a user