Exemplo n.º 1
0
        private void AddTabWithFilter(string tabName, TabFilter filter, int order)
        {
            int insertIndex = _tabBar.TabCount;

            if (_tabBar.TabCount > 0)
            {
                // All Resources is always the first tab
                for (int i = 1; i < _tabBar.TabCount; i++)
                {
                    string oldTabID = GetTabId(i);
                    int    oldOrder = 0;
                    if (_resourceTabOrder.Contains(oldTabID))
                    {
                        oldOrder = (int)_resourceTabOrder[oldTabID];
                    }
                    if (oldOrder > order)
                    {
                        insertIndex = i;
                        break;
                    }
                }
            }
            _tabBar.InsertTab(insertIndex, tabName, filter);
            _resourceTabOrder[filter.Id] = order;
        }
Exemplo n.º 2
0
        public Tab Map(TabFilter filter, Tab tab, CreateOrEditViewModel createOrEdit)
        {
            if (tab.Id == 0)
            {
                tab.ClassId = (int)filter.Class.Id;
            }

            tab.Name     = createOrEdit.Name;
            tab.Position = createOrEdit.Position;
            return(tab);
        }
Exemplo n.º 3
0
 /// <summary>
 /// Finds the tab where resources with the specified property are displayed.
 /// </summary>
 public string FindLinkPropTab(int linkPropId)
 {
     for (int i = 0; i < _tabBar.TabCount; i++)
     {
         TabFilter filter = (TabFilter)_tabBar.GetTabTag(i);
         if (filter.LinkPropId == linkPropId)
         {
             return(filter.Id);
         }
     }
     return(null);
 }
Exemplo n.º 4
0
 /// <summary>
 /// Finds the tab where the resources of the specified type are displayed.
 /// </summary>
 public string FindResourceTypeTab(string type)
 {
     for (int i = 0; i < _tabBar.TabCount; i++)
     {
         TabFilter filter = (TabFilter)_tabBar.GetTabTag(i);
         if (filter != null && filter.ContainsResourceType(type))
         {
             return(filter.Id);
         }
     }
     return(null);
 }
Exemplo n.º 5
0
 /// <summary>
 /// Returns the index of a tab with the specified name.
 /// </summary>
 public int FindTabByID(string id)
 {
     for (int i = 0; i < _tabBar.TabCount; i++)
     {
         TabFilter filter = (TabFilter)_tabBar.GetTabTag(i);
         if (filter.Id == id)
         {
             return(i);
         }
     }
     return(-1);
 }
Exemplo n.º 6
0
        /// <summary>
        /// Returns the link type filtering the specified tab, or null if there is no
        /// link type filter.
        /// </summary>
        public int GetTabLinkPropId(string tabId)
        {
            int tabIndex = FindTabByID(tabId);

            if (tabIndex < 0)
            {
                throw new ArgumentException("Invalid tab ID " + tabId, "tabId");
            }

            TabFilter tabFilter = (TabFilter)_tabBar.GetTabTag(tabIndex);

            return(tabFilter.LinkPropId);
        }
Exemplo n.º 7
0
        /// <summary>
        /// Returns the list of resource types displayed in the specified tab, or null if
        /// all resources are displayed.
        /// </summary>
        public string[] GetTabResourceTypes(string tabId)
        {
            int tabIndex = FindTabByID(tabId);

            if (tabIndex < 0)
            {
                throw new ArgumentException("Invalid tab ID " + tabId, "tabId");
            }

            TabFilter tabFilter = (TabFilter)_tabBar.GetTabTag(tabIndex);

            return(tabFilter.GetResourceTypes());
        }
Exemplo n.º 8
0
 public IResourceTypeTab this[string tabId]
 {
     get
     {
         for (int i = 0; i < _tabBar.TabCount; i++)
         {
             TabFilter tabFilter = (TabFilter)_tabBar.GetTabTag(i);
             if (tabFilter.Id == tabId)
             {
                 return(tabFilter);
             }
         }
         throw new ArgumentException("Tab '" + tabId + "' not found ", "tabId");
     }
 }
 private void TabShow_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (TabShow.SelectedIndex == 1)
     {
         tabController.SelectTab(1);
         TabSort.SelectTab(1);
         TabFilter.SelectTab(1);
     }
     else if (TabShow.SelectedIndex == 0)
     {
         TabSort.SelectTab(0);
         tabController.SelectTab(0);
         TabFilter.SelectTab(0);
     }
 }
Exemplo n.º 10
0
        private void NavBar_AfterSelect(object sender, TreeViewEventArgs e)
        {
            switch (e.Node.Text)
            {
            case "Filter":
                TabFilter.Visible           = true;
                TabDisplay.Visible          = false;
                TabFilter.SelectedIndex     = 0;
                TabSearchEngineInfo.Visible = false;
                break;

            case "Block Rules":
            case "New Rule":
                TabFilter.Visible           = true;
                TabDisplay.Visible          = false;
                TabSearchEngineInfo.Visible = false;
                TabFilter.SelectTab(e.Node.Index);
                break;

            case "Display":
                TabFilter.Visible  = false;
                TabDisplay.Visible = true;
                LoadDisplayConfig();
                TabSearchEngineInfo.Visible = false;
                break;

            case "Search Engine":
                TabSearchEngineInfo.Visible       = true;
                TabFilter.Visible                 = false;
                TabDisplay.Visible                = false;
                TabSearchEngineInfo.SelectedIndex = 0;
                TabSelectDefaultEngine_Enter(null, null);
                break;

            case "Select":
            case "URL":
                TabSelectDefaultEngine_Enter(null, null);
                TabSearchEngineInfo_Enter(null, null);
                TabDisplay.Visible          = false;
                TabSearchEngineInfo.Visible = true;
                TabFilter.Visible           = false;
                TabSearchEngineInfo.SelectTab(e.Node.Index);
                break;
            }
        }
Exemplo n.º 11
0
        /// <summary>
        /// Loads the pane switcher state for all tabs in the specified workspace.
        /// </summary>
        private void RestoreTabStatesForWorkspace(int workspaceID)
        {
            string workspaceText = (workspaceID == 0) ? "" : workspaceID + ".";

            for (int i = 0; i < _tabBar.TabCount; i++)
            {
                TabFilter    filter = (TabFilter)_tabBar.GetTabTag(i);
                SidebarState state  = SidebarState.RestoreFromIni("TabState." + workspaceText + filter.Id);
                if (state != null)
                {
                    TabState tabState = new TabState();
                    tabState.SidebarState = state;

                    WorkspaceTabState stateKey = new WorkspaceTabState(filter.Id, workspaceID);
                    _tabStates[stateKey] = tabState;
                }
            }
        }
Exemplo n.º 12
0
        public IndexViewModel Create(HttpContext httpContext, TabFilter filter, IEnumerable <Tab> tabs, string orderBy, int skip, int take, int total)
        {
            IStringLocalizer <IndexViewModelFactory> localizer = httpContext.GetStringLocalizer <IndexViewModelFactory>();

            return(new IndexViewModel()
            {
                Filter = filter,
                Grid = new GridViewModelFactory().Create(
                    httpContext,
                    new FilterViewModelFactory().Create(httpContext, "Name.Contains", localizer["Name"]),
                    orderBy, skip, take, total,
                    new[] {
                    new GridColumnViewModelFactory().Create(localizer["Name"], "Name"),
                    new GridColumnViewModelFactory().Create(localizer["Position"], "Position"),
                    new GridColumnViewModelFactory().CreateEmpty()
                },
                    tabs.Select(t => new TabViewModelFactory().Create(t)),
                    "_Tab"
                    )
            });
        }
Exemplo n.º 13
0
        public string GetResourceTab(IResource res)
        {
            string resType = res.Type;

            if (resType == "Fragment")
            {
                resType = res.GetStringProp("ContentType");
            }
            // TODO: optimize
            for (int i = 1; i < _tabBar.TabCount; i++)
            {
                TabFilter tabFilter = (TabFilter)_tabBar.GetTabTag(i);
                if (tabFilter.ContainsResourceType(resType))
                {
                    return(tabFilter.Id);
                }
                if (tabFilter.LinkPropId >= 0 && res.HasProp(tabFilter.LinkPropId))
                {
                    return(tabFilter.Id);
                }
            }
            return(null);
        }
Exemplo n.º 14
0
        public void RegisterResourceTypeTab(string tabID, string tabName, string[] resTypes,
                                            int linkPropID, int order)
        {
            int tabIndex = FindTabByID(tabID);

            if (tabIndex >= 0)
            {
                TabFilter filter = (TabFilter)_tabBar.GetTabTag(tabIndex);
                if (resTypes != null)
                {
                    filter.AddResourceTypes(resTypes);
                }
                if (linkPropID != -1)
                {
                    filter.SetLinkPropID(linkPropID);
                }

                return;
            }

            AddTabWithFilter(tabName, new TabFilter(this, tabID, resTypes, linkPropID), order);
            _querySidebar.RegisterTab(tabID, resTypes, linkPropID);
        }
Exemplo n.º 15
0
        /// <summary>
        /// The main function for switching resource type tabs and workspaces.
        /// </summary>
        private void UpdateSelectedTab()
        {
            if (Core.State == CoreState.ShuttingDown)
            {
                return;
            }

            using (new WaitCursorDisplayer())
            {
                if (TabChanging != null)
                {
                    TabChanging(this, EventArgs.Empty);
                }

                _resourceBrowser.UnhookResourceList(null);

                Trace.WriteLine("--- Start tab switch ---");
                if (_curTabState != null)
                {
                    _curTabState.SidebarState = _querySidebar.CurrentState;
                }

                TabFilter tabFilter = (TabFilter)_tabBar.SelectedTabTag;

                string   tabText          = _tabBar.GetTabText(_tabBar.SelectedIndex);
                string   tabName          = (_tabBar.SelectedIndex > 0) ? tabText : null;
                string[] tabResourceTypes = tabFilter.GetResourceTypes();
                string   tabId            = tabFilter.Id;

                Trace.WriteLine("Setting default resource browser columns");
                _resourceBrowser.SetCaptionPrefix(tabName, false);
                _resourceBrowser.DefaultColumns = (tabResourceTypes == null)
                                        ? null
                                        : (Core.DisplayColumnManager as DisplayColumnManager).GetColumnsForTypes(tabResourceTypes);

                Trace.WriteLine("Initializing tab state");
                bool newState = false;
                WorkspaceTabState tabStateKey = GetCurStateKey();
                TabState          state       = (TabState)_tabStates[tabStateKey];
                if (state == null)
                {
                    newState = true;
                    state    = new TabState();
                    _tabStates[tabStateKey] = state;
                }

                //_resourceBrowser.ResourceListView.Filters.BeginUpdate();

                Trace.WriteLine("Updating ResourceListView filters");

                _curTabFilter = tabFilter;

                UpdateResourceBrowserFilterList();
                _resourceBrowser.UpdatePerTabSettings();

                Trace.WriteLine("Showing panes in QuerySidebar");
                _querySidebar.ShowPanesForTab(tabId, state.SidebarState);

                ResourceTreePaneBase defaultViewPane = _querySidebar.DefaultViewPane as ResourceTreePaneBase;
                if (defaultViewPane != null)
                {
                    defaultViewPane.UnreadState = _curUnreadState;
                }
                JetResourceTreePane structurePane = _querySidebar.ResourceStructurePane as JetResourceTreePane;
                if (structurePane != null)
                {
                    structurePane.UnreadState = _curUnreadState;
                }

                Trace.WriteLine("Firing TabSwitch handler");
                if (TabChanged != null)
                {
                    TabChanged(this, EventArgs.Empty);
                }

                if (newState)
                {
                    Trace.WriteLine("Showing columns for resource list");
                    if (_resourceBrowser.DefaultColumns != null)
                    {
                        _resourceBrowser.ShowListViewColumns(_resourceBrowser.DefaultColumns);
                    }
                    else
                    {
                        _resourceBrowser.ShowColumnsForResourceList();
                    }

                    Trace.WriteLine("Selecting default view");
//  Debug
                    try
                    {
                        SelectDefaultView(tabId);
                    }
                    catch (NullReferenceException)
                    {
                        throw new ApplicationException("Illegal name of the View [" + tabId + "] while switching to [" + tabText + "]");
                    }
//  endDebug
                }
                else
                {
                    Trace.WriteLine("Selecting default view");
                    if (state.SidebarState != null &&
                        state.SidebarState.SelectedResource == null)
                    {
//  Debug
                        try
                        {
                            SelectDefaultView(tabId);
                        }
                        catch (NullReferenceException)
                        {
                            throw new ApplicationException("Illegal name of the View [" + tabId + "] while switching to [" + tabText + "]");
                        }
//  endDebug
                    }
                }
                Trace.WriteLine("Ending filters update");
                //_resourceBrowser.ResourceListView.Filters.EndUpdate();
                _curTabState = state;
                Trace.WriteLine("--- Done tab switch ---");
            }
        }
Exemplo n.º 16
0
        /// <summary>
        /// Returns the state key for the current state of the switcher.
        /// </summary>
        public WorkspaceTabState GetCurStateKey()
        {
            TabFilter filter = (TabFilter)_tabBar.SelectedTabTag;

            return(new WorkspaceTabState(filter.Id, (_activeWorkspace == null) ? 0 : _activeWorkspace.Id));
        }
Exemplo n.º 17
0
        /// <summary>
        /// Returns the ID of the tab at the specified index.
        /// </summary>
        public string GetTabId(int index)
        {
            TabFilter filter = (TabFilter)_tabBar.GetTabTag(index);

            return(filter.Id);
        }