Author |
Share Topic Topic Search Topic Options
|
Bill Jensen
IdeaBlade
Joined: 31-Jul-2007
Location: United States
Posts: 229
|
Post Options
Quote Reply
Topic: [Resolved] TabShellLayout Posted: 30-Oct-2007 at 2:37pm |
Sounds like a good solution to me. Keeping the knowledge of the tabs in a TabService avoids having any other components depend on the particular shell layout type.
This could be generalized slightly into a "PageVisibilityService" with a MakeVisible(pageViewId) method. If the page isn't part of a TabShellLyaout, the service does nothing. That way, page's don't care at all about where they're displayed.
Bill J.
|
|
orcities
Senior Member
Joined: 28-Aug-2007
Location: United States
Posts: 454
|
Post Options
Quote Reply
Posted: 30-Oct-2007 at 12:55pm |
This is my solution, atleast until refactoring.
I created a TabService. This service adds each tab to a collection, built with a helper class that add the tab with an allowclose flag. If the page is to not ever be closed then the flag is false. When a new page is selected I see if the page exists in the collection if not I add it.
Then in the ShowPage static method of each page I make the page visible by pulling the Tab from the service and changing the visibility. Then I refresh the page, as noted above by Bill, if necessary.
|
|
Bill Jensen
IdeaBlade
Joined: 31-Jul-2007
Location: United States
Posts: 229
|
Post Options
Quote Reply
Posted: 29-Oct-2007 at 3:33pm |
The static ShowPage() method of the page controller (mine is named Page1) calls the generic base class method:
ShowPage< Page1PageController>(pParentWorkItem, pPageWorkItemId, pPageWorkspace);
Examining this method, we find:
protected static void ShowPage<T>(WorkItem pParentWorkItem, string pPageWorkItemId, IWorkspace pPageWorkspace)
where T : PageController<TRootObj> {
T controller = GetPageController<T>(pParentWorkItem, pPageWorkItemId);
We note that GetPageController<>() is protected static, so it's available in our page controller's static ShowPage method. So, in your page controller's static ShowPage() method try:
public static void ShowPage(WorkItem pParentWorkItem, string pPageWorkItemId, IWorkspace pPageWorkspace)
{
// Refresh entities before displaying
Page1PageController controller = GetPageController<Page1PageController>(pParentWorkItem, pPageWorkItemId);
controller.RefreshEntities();
// Base ShowPage method will call back to overridden methods in this class
ShowPage< Page1PageController>(pParentWorkItem, pPageWorkItemId, pPageWorkspace);
}
Then write a RefreshEntities() method (perhaps similar to what you do in GetInitialEntities() to re-query the data.
Full disclosure: I haven't tested this code.
Bill J.
|
|
orcities
Senior Member
Joined: 28-Aug-2007
Location: United States
Posts: 454
|
Post Options
Quote Reply
Posted: 29-Oct-2007 at 2:34pm |
Because I am an idiot and can't figure out how to do it.
I know I want to "Re-execute the original query and assign the result as the data source for the binding source." but I can't figure it out.
ShowPage is static. This method runs when you click on the link in the NavBar. Therefore, I do not have the same access to the variables. The MainBindingSource is not static.
The main reason I was trying to remove the page from the WorkItem is because ShowPage either adds a new page, if the current page hasn't been created, or makes it the active page. I thought it would be simpler to remove it. This would only require me to add code to the TabShellLayout presenter and view.
|
|
Bill Jensen
IdeaBlade
Joined: 31-Jul-2007
Location: United States
Posts: 229
|
Post Options
Quote Reply
Posted: 29-Oct-2007 at 2:22pm |
The concept of destroying and recreating a view each time it becomes visible is rather foreign to CAB and Cabana.
Since you've succeeded in hiding and revealing a view, I'm still not understanding why you can't merely refresh the data source of a view when it becomes visible.
Bill J.
|
|
orcities
Senior Member
Joined: 28-Aug-2007
Location: United States
Posts: 454
|
Post Options
Quote Reply
Posted: 29-Oct-2007 at 12:20pm |
Ok, I know what I want to do. But I have no idea on how to do it.
The following is built into the page controllers ShowPage:
if ( controller == null ) {
controller = MakeNewPage<T>(pParentWorkItem, pPageWorkItemId);
ShowPage(controller, pPageWorkspace);
} else {
controller.MainWorkspace.Activate(controller.MainView);
}
Meaning that if the controller doesn't exist then add one. This will do the refresh of the content.
Now, in the TabbedShellLayout I can hide a page. I can also get the ActiveSmartPart and the current IPageView, to keep it generic.
I want to dispose of that PageView, that way when the user clicks on the nav item again it will create the page again, but I have no idea how to do that.
So far, I have been successful in hiding the tab, remove it from the WorkItem. But, the page will not load again when the user clicks on the nav item.
HELP
|
|
orcities
Senior Member
Joined: 28-Aug-2007
Location: United States
Posts: 454
|
Post Options
Quote Reply
Posted: 26-Oct-2007 at 3:49pm |
I am going to alter the ShellService and the Nave service to do what I want. I will let you know how it goes.
|
|
Linguinut
Senior Member
Joined: 14-Jun-2007
Location: United States
Posts: 394
|
Post Options
Quote Reply
Posted: 26-Oct-2007 at 2:47pm |
Dan,
For what it's worth, I really wish I could help. I have been tracking with you. As I keep up with you, if anything comes to mind, I will certainly let you know. Keep at it. The solution is waiting for you to find.
Bill
|
|
orcities
Senior Member
Joined: 28-Aug-2007
Location: United States
Posts: 454
|
Post Options
Quote Reply
Posted: 26-Oct-2007 at 2:41pm |
I have got the command to run when I click a group in the nav bar. I just can't get it to run when I click an item in that group.
|
|
orcities
Senior Member
Joined: 28-Aug-2007
Location: United States
Posts: 454
|
Post Options
Quote Reply
Posted: 26-Oct-2007 at 2:12pm |
The TabPresenter registers an event (ToggleVisibility) that fires when the user clicks the close button.
The problem is that I am not sure how to get the nav bar to fire an event that fires the ToggleVisbility event as well.
Not sure how I would get the Nav bar to fire another event, one is fired automatically for ShowPage<>, that will fire the ToggleVisibility event again.
help please.
|
|
orcities
Senior Member
Joined: 28-Aug-2007
Location: United States
Posts: 454
|
Post Options
Quote Reply
Posted: 26-Oct-2007 at 1:46pm |
I can get the tab to hide and the SmartPart to hide. But I can not get them to reload.
I am looking for a way to get the tab/page to reload when you choose its item from the Nav bar. Unfortunately it does not.
I believe I will need to set the tab visibility at the PageController or the ModuleController.
I know that the Page.ShowPage function is called whenever the nav bar item is selected. So, this would be a good place to set the page back to visible.
But, that brings me back to one of my original questions. If I want this to be loose coupling how do I know from the ShellServices.ShellContent that a tab even exists? How do I reload the tab and keep it loosely coupled.
|
|
orcities
Senior Member
Joined: 28-Aug-2007
Location: United States
Posts: 454
|
Post Options
Quote Reply
Posted: 26-Oct-2007 at 12:42pm |
I am now able to get the workspace to hide and show again. I used the DemoDotNetTabVisibility as a guide.
I combined the Presenter and the Buildcore info from the demo into the ShellTabLayoutPresenter:
public void SetToggleTabVisibilityCommandElement(
object pUiElement, string pUiElementEventName, IWorkspace pWorkspace)
{
ShellTabVisibility.SetTabControl(WorkItem, pWorkspace);
CabFns.AddLocalCommandInvoker(
WorkItem, "ToggleTabVisibility", pUiElement, pUiElementEventName);
}
And added the InjectPresenter call in the ShellTabLayoutView
pPresenter.SetToggleTabVisibilityCommandElement(mShellContentWorkspace, "CloseButtonClick", mShellContentWorkspace);
There are other little changes, like making it DevEx.
Now I just have to get the Tab itself to hide a reappear. And then refreshing the data on some occurances.
|
|
orcities
Senior Member
Joined: 28-Aug-2007
Location: United States
Posts: 454
|
Post Options
Quote Reply
Posted: 26-Oct-2007 at 10:24am |
I am trying to find a way to see the state of the current tab. I know I can get to the TabController by using ShellService.ShellContentWorkspace.
But, if I don't want to make it a specific type of workspace how do I get the current page?
There is a ShellContentWorkspace.Hide and Show; but, you have to send it a SmartPart. I can access the Show using the NavViewContext on PageController but, how do I know the SmartPart to use when I am at the TabShellLayoutPresenter?
|
|
orcities
Senior Member
Joined: 28-Aug-2007
Location: United States
Posts: 454
|
Post Options
Quote Reply
Posted: 23-Oct-2007 at 10:20am |
duh
|
|
Bill Jensen
IdeaBlade
Joined: 31-Jul-2007
Location: United States
Posts: 229
|
Post Options
Quote Reply
Posted: 23-Oct-2007 at 10:16am |
Re-execute the original query and assign the result as the data source for the binding source.
|
|
orcities
Senior Member
Joined: 28-Aug-2007
Location: United States
Posts: 454
|
Post Options
Quote Reply
Posted: 23-Oct-2007 at 8:16am |
How would I refresh the contents of the datasource? I have been trying to figure that out for a while.
|
|