How to expand/turn a view programmatically? - eclipse-rcp

I have a tableviewer with list of news titles, and when I click on a row, the news content view with browser is opened. But news page is too large and user should expand the news content view to see all it content. So I look for the way to expand a view programmatically.
I searched for the way in the Google and did not find anything. I looked the code of org/eclipse/jdt/internal/ui/packageview/PackageExplorerPart.java and did not find anything again. Then I realized, that expanding of a view should be implemented in more common way, by an extension point with actions or something similar. Then I remembered about IWorkbenchPage.showView(). I looked for the appropriate method and did not find such method. Expanding of a view should be implemented in something similar way, but I have no thoughts, what it could be.

You can maximize a part using IWorkbenchPage.toggleZoom
For example the Maximize Part command handler does this:
IWorkbenchWindow activeWorkbenchWindow = HandlerUtil.getActiveWorkbenchWindow(event);
if (activeWorkbenchWindow != null) {
IWorkbenchPage page = activeWorkbenchWindow.getActivePage();
if (page != null) {
IWorkbenchPartReference partRef = page.getActivePartReference();
if (partRef != null) {
page.toggleZoom(partRef);
}
}
}

Also there is the method IWorkbenchPage.setPartState() with using constants IWorkbenchPage.STATE_MAXIMIZED, IWorkbenchPage.STATE_MINIMIZED and IWorkbenchPage.STATE_RESTORED.

Related

multiple view models in a single page mvvmcross

I am trying to make an App for multiple platforms using Xamarin. The App uses the Mvvm structure and MvvmCross.
Currently, I have various View Models and they all bind great (using MvvmCross), as long as they are in separate pages.
However, I would like to make a single page that references multiple View Models. For example, a page that has few buttons each binding to methods in different View Models.
I understand that to do this I should:
1) Divide the screen to different views.
2) Assign the buttons to different views according to their View Model.
I am not sure how can I divide the screen? Are fragments the answer?
Also, does this mean a View Model that would know about all view models in the page is necessary?
My current work around is having tabs in all pages that change the current view model of that page, as follow:
public ICommand VM1Command
{
get { return new MvxCommand(() => ShowViewModel<ViewModel1>()); }
}
public ICommand VM2Command
{
get { return new MvxCommand(() => ShowViewModel<ViewModel2>()); }
}
public ICommand VM3Command
{
get { return new MvxCommand(() => ShowViewModel<ViewModel3>()); }
}
This is pretty ugly, I would really appreciate if anyone could refer me to somewhere where this is explained or even better tell me how to do it.
Cheers!
The SpheroViewModel is used in the SpheroView (see: SpheroView.cs). This View is a MvxBindingTabActivityView. So it uses an Android TabHost to display the Subviews as Tab. The setup is done in the lines 30 - 48. For each SubViewModel you have an own view (e.g. SpheroAccelMovementView.cs) that binds and displays the separate data.
For more Details on Tabs and MvvMCross and different Platforms have a look at N = 25 - Video Tutorial. There are perhaps some API changes since stuart has recored the video. But it explains the general idea of tabs and subviewmodels.

bugs about using DataGrid wrapped by StackLayoutPanel

I tried to use DataGrid and put it in the stacklayoutpanel.At the time when I provide the data for the ListDataProvider, the CellTable is not visible in the browser because it's on a non active tab (although it's visible in the DOM tree). After switching to the tab containing the CellTable there is no data in it. If the tab is active at time of data provisioning the table is filled correctly. Since I have made a column sortable, if I clicked the sorting, the data would be displayed correctly. I want the data to be displayed automatically when I click the other inative tab. This will not be the problem if I switch to use celltable.
I knew this was the bug in GWT and it is fixed in GWT 2.5 RC. But my boss does not want me to use GWT2.5RC yet. I have to workaround to fix this. I knew that someone said datagrid.redraw() could sort of fix it. I tired it, but the display is weird. For example, I have 10 rows in DataGrid, after selecting the 2nd tab, redraw() is called, the data is automatically displayed, but there is only like 10px of block displaying the data and the scroll bar. I have to scroll down to see other rows. There are lots of space in the bottom of the tab not being used. Could anyone tell me how to fix this? So did I use the wrong way to fix it?
is there anything else I can do to fix this problem.
Could anyone give me some tips please.
Thanks
Best Regards
I have been struggled with this thing for almost 3 days. Thanks for Papick G. Taboada and Thomas Broyer.
You guys' ideas are really helpful. Bascially either of your solution does not solve the problem. but after I combined both solutions, dang~ it worked!!.
So. the completed solution is that, add the selection handler on the non-active tab, then when the event is called, used datagrid.onResize() and then stackLayoutPanel.forcelayout(). This can solve my problem. I have also tried replacing datagrid.onResize() with datagrid.redraw(). It works as well.
I hope this can help other people who have the same problem before using GWT 2.5RC
I came across this problem with a DataGrid within and Panel that was in a StackPanelLayout. DataGrid implements RequiresResize, so I made the Panel that contained the DataGrid implement RequiresResize so it could call onResize() for the DataGrid.
in the Panel that contained the DataGrid
#Override
public void onResize()
{
dataGrid.onResize();
}
On the StackLayoutPanel
stackLayoutPanel.addSelectionHandler(new SelectionHandler<Integer>() {
// http://code.google.com/p/google-web-toolkit/issues/detail?id=6889
#Override
public void onSelection(SelectionEvent<Integer> event) {
Integer selectedItem = event.getSelectedItem();
StackLayoutPanel panel = (StackLayoutPanel) event.getSource();
Widget selectedWidget = panel.getWidget(selectedItem);
if (selectedWidget != null && selectedWidget instanceof RequiresResize)
{
((RequiresResize)selectedWidget).onResize();
}
}
});
I believe a more general answer would be that any container in a StackLayoutPanel that contains a widget that implements RequiresResize should also implement RequiresResize and pass it on.

Saving page preference in site navigation using SiteMapPath control

I have created site navigation in my ASP.net application using SiteMapPath control and its working fine. Now my requirement is that, there is open page in my application which has Radio buttons and based on their selection datagrid is populated from database. I want to save the radio button selection in navigation url so that when I click on that page through navigation url then page will display the data from my selected options.
Any help would be highly appriciated.
Thanks,
Yogesh
I'm not sure that I understand. I propose some other solution (using Session). Add event to radioButton onSelectionChange. When selection change, remember this in Session
Session["name_param"] = some_params;
And in form with dataGrid get event PageLoad with code:
if ( Session["name_param"] != null ) {
var param = Session["name_param"];
// using param to load data to grid
} else {
// something else, maybe default chance for data to grid
}

Nvigation within a GWT application

I intend to build a web application where users can enter their time every week and have been struggling to get my head around the concept of a single page in GWT that gets repainted with data depending on the user actions. After researching a lot on this site and google, I found one link that I would like to emulate but dont know how to go about doing it in GWT. Although their source code is available, I dont think it is full and complete. I got some idea from this link - Multiple pages tutorial in Google Web Toolkit (GWT) but again dont know how to implement it into a working version. One small working sample would be great to help me understand and get started.
Could anyone please guide me as to how to achieve the look and feel of the screen with the link below and how the content can be repainted with data from the server ? Would I need to put all the logic in one EntryPoint class ? I would like to have the hyperlinks in the left navigation panel and show the content in the right panel. I seem to be completely lost after a few hours of research.
http://gwt.google.com/samples/Showcase/Showcase.html#!CwHyperlink
Thanks a lot for your help.
Regards,
Sonu.
A single page application layout is actually quite easy to achieve.
The first thing you do is define the general layout, using GWTs layout panels. For your layout, I'd suggest using a DockLayoutPanel.
Content content = new Content();
Button switchContent = new Button(content);
Navigation navigation = new Navigation();
navigation.add(switchContent);
DockLayoutPanel pageLayout = new DockLayoutPanel(Unit.EM);
p.addWest(new HTML(navigation), 7.5);
p.add(new HTML(content));
Here, the width of the navigation panel will be fixed, whereas the content will take the remaining space. You have to pass a reference of the button (or some other widget) which does the switch of the content area, add the button to the navigation area, and so on.
Put this into a class, e.g. called MasterPageFactory:
public class MasterPageFactory {
private MasterPageFactory() {}
public static MasterPage newInstance() {
Content content = new Content();
Button switchContent = new Button(content);
Navigation navigation = new Navigation();
navigation.add(switchContent);
DockLayoutPanel masterPage = new DockLayoutPanel(Unit.EM);
masterPage.addWest(new HTML(navigation), 7.5);
masterPage.add(new HTML(content));
return masterPage;
}
}
Now, in your EntryPoint class, call the factory:
RootLayoutPanel.get().add(MasterPageFactory.newInstance());
This example should get you an idea. Other options would be using a DI framework like Guice or the Command pattern.
Your question is mixing up a couple of concepts. If you want the user to click something that looks like a link, and in reponse the application sends a request to the server and shows a page that looks different than the page they're on, and that page has fresh data that just came from the server, then you want a perfectly normal anchor or form submit button. You don't need anything special or weird from GWT.
The showcase example you referenced lets the user click something that looks like a link, and looks like it loads a new page, even to the point of letting the back button work as expected, but does not actually hit the server to get a new page or new data.

Eclipse RCP get elements by ID

I don't know RCP very well yet, but I've been reading a lot of the docs. I don't know if my question makes sense; I apologize if not and beg that you try to work out what I mean and come up with some kind of answer.
I have a tree view element, which has a double click listener on it. In another part of the window there is a layout folder which contains views that are supposed to be inspectors for the items double-clicked on.
The only way I know to make another inspector appear is:
getActivePage().showView(Inspector.ID).
showView() doesn't give any opportunity to pass extra information to the view, so can it know which element to inspect?
Pointers in different directions appreciated. The Vogel tutorial doesn't seem to cover this, or I don't understand it.
You could check if the article "Link to Editor" can help you here.
That is, instead of trying to access the right view, define a Listener for the Editors:
private IPartListener2 partListener2 = new IPartListener2() {
public void partActivated(IWorkbenchPartReference ref) {
if (ref.getPart(true) instanceof IEditorPart)
editorActivated(getViewSite().getPage().getActiveEditor());
}
That way, you can get back the right Editor, and ask that Editor all you need for your View to update accordingly.
You can use the SelectionService. The Inspector view should register as a SelectionListener. And the other view with the tree should register a SelectionProvider. This view should listen for the double click in the tree and then update the selection