Adding a view on perspective in particular folder - eclipse-plugin

In my Eclipse RCP application I have four views A, B, C, D. I want to display only A, B, C view at application start-up, and D view to be displayed when user click on button.
I am adding a view dynamically
PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().showView("D_ViewID",null, IWorkbenchPage.VIEW_ACTIVATE);
this view is added at the bottom but I want this D view adjacent to B_View in such a way
my perspective code is here:
#Override
public void createInitialLayout(IPageLayout layout) {
String editor = layout.getEditorArea();
layout.setEditorAreaVisible(false);
IFolderLayout top=layout.createFolder("view",IPageLayout.TOP , 0.80f, editor);
top.addView(B.ID);
layout.addView(A.ID, IPageLayout.LEFT, 0.20f, BrowserView.B);
layout.addView(c.ID, IPageLayout.BOTTOM, 0.20f,editor);
}

You need to add a placeholder to the perspective, just like you added your already visible views. If you look at the top of the IPageLayout documentation, there is an example adding the bookmarks view as placeholder.

Related

RowFilter on JFace TreeViewer

I have a TreeViewer as shown here:
.
I have a text field to enter the percentage values. Suppose the percentage entered is 30 %, I should hide all the rows that are below 30% and display only the rows above 30%. Is there any row filter that I can use for my TreeViewer? It would be great if some examples are provided.
I am using e4 RCP. I want to do View based filtering and prefer not to change the Model.
You use a class which extends ViewFilter to filter the rows in a tree viewer.
The main method to override in the ViewFilter is the select method:
#Override
public boolean select(Viewer viewer, Object parentElement, Object element)
here you are given the object being considered (element) along with its parent and the viewer. You return true to keep displaying the element and false to hide it.
You can have several filters active if required, set them in the tree viewer using:
treeViewer.setFilters(array of view filters);
You may need to call
treeViewer.filter();
when something changes in the tree which requires the filters to be re-run.

TableView delete column via contextual menu

It is my first time asking here, sorry if i do something wrong (also not in my mother tongue).
Recently, i moved from Swing&AWT to JavaFX.
I am discovering the new Table which is quite different from the Swing version. Better i would say, it needs less operation and do more things, but ... lord, it's way more difficult to understand !
I am currently trying to modify the TableView dynamically. While the addColumn method is not a big challenge, i need help for my deleteColumn method :/
Let's talk about my problem :
I have a scene with many components on it (panes, buttons, menus, ...) and one pane (actually an anchorpane) hosts a TableView.
I would like to dynamically delete an entire column when this operation occurs :
The user right clicks on the TableView > a contextual menu shows up > he selects the item "delete"
So, basically a contextual menu that offers the option to delete the column where the user right-clicked.
I tried this :
-> When the user right-clicks on the TableView, this method is called :
public void setTargetForContext(ContextMenuEvent event){
if(event.getTarget() instanceof Label){
ObservableList list =(((Label)event.getTarget()).getChildrenUnmodifiable());
activeColumn = ((Text)((ObservableList)list)).getText();
}...
And the goal was to set the column name in "activeColumn".
Then, when the user will select the "delete" option from the contextual menu, another method would be called to compare the name of the columns and delete the right one.
But it seems that i can't call a getChildren() method on the label, only an unmodifiable one. And it does not allow a cast and throw the exception.
Do you have a solution to allow me to get the column name ?
Or maybe i am going the wrong way and i have to find another way to delete the right-clicked column, but in this case i will need your help too.
Thanks a lot for reading, and thanks in advance for your help.
First, let me point out that if you call
table.setTableMenuButtonVisible(true);
then the table will have a built-in menu button with radio buttons allowing the user to select which columns are displayed. Maybe this is all you need.
In Swing, the renderers for table cells are just "rubber stamps" that are painted onto the table. Thus you can't register listeners for UI events with them.
By contrast, in JavaFX, the cells in a table are real UI controls with full functionality. This means there's no real need for API that gets the cell coordinates from a table. You should not register your listener with the TableView, but with the actual cells on which you want to operate. You access the cells from the table column's cell factory.
// the table:
TableView<RowDataType> table = new TableView<>();
//...
// A table column:
TableColumn<RowDataType, CellDataType> column = new TableColum<>("Header text");
// A context menu for the table column cells:
ContextMenu contextMenu = new ContextMenu();
MenuItem deleteColumnItem = new MenuItem("Remove Column");
deleteColumnItem.setOnAction(e -> table.getColumns().remove(column));
contextMenu.getItems().add(deleteColumnItem);
// Cell factory for the column
column.setCellFactory(col -> {
// basically a cell with default behavior:
TableCell<RowDataType, CellDataType> cell = new TableCell<RowDataType, CellDataType>() {
#Override
public void updateItem(CellDataType item, boolean empty) {
super.updateItem(item, empty);
if (item == null) {
setText(null);
} else {
setText(item.toString());
}
}
});
// add the context menu to the cell:
cell.setContextMenu(contextMenu);
return cell ;
});
If you want the context menu to appear in the table column header as well, you just need to do
column.setContextMenu(contextMenu);

Eclipse plug-in/product - force top-level coolbar layout?

I have an Eclipse product defined in a plugin - it does not define its own Application class (i.e. no custom implementation of IApplication). I am using some dynamic drop-down items in the main toolbar, defined in plugin.xml. I am building the Product using the Eclipse 4.3 (Kepler) platform.
At runtime, I would like the toolbar items to show which of the drop-down items are currently selected. For generic items, I use an icon, but for non-generic items I would like to show some identifying text. The identifying text is not always of the same length.
I am using an IElementUpdater to update the drop-down items and also the toolbar item. Everything works fine, except that the coolbar/toolbar/trimbar does not re-layout. If the new text is longer than the text it is replacing, or if I switch from icon to text or vice-versa, the toolbar appears empty - not even the drop-down arrow is showing. My test team reports that the Drop-down tool item "disappears", which is a pretty good description of the experience.
Is there any way to force the main toolbar/coolbar/trimbar complex re-layout?
I have done some research and it seems that I might be able to do this by defining my own IApplication implementation and capturing the Coolbar/Toolbar manager using an ActionBarAdvisor subclass for later calls to layout(). This is a pretty heavyweight solution - is there any other?
You can always retrieve toolbar manager from PartSite. There are also subclasses EditorSite and ViewSite:
IWorkbenchPartSite site = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActivePart().getSite();
ToolBarManager mgr = null;
if (site instanceof IEditorSite) {
IEditorSite editorSite = (IEditorSite) site;
mgr = (ToolBarManager) editorSite.getActionBars().getToolBarManager();
} else if (site instanceof IViewSite) {
IViewSite viewSite = (IViewSite) site;
mgr = (ToolBarManager) viewSite.getActionBars().getToolBarManager();
}
Or if you know there is an active editor available:
PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor().getEditorSite().getActionBars().getToolBarManager();
Or inside of a view:
ToolBarManager mgr = getViewSite().getActionBars().getToolBarManager();
Then you will get a possibity to layout it:
mgr.getControl().layout(true);

ExtJS grid 'reset'

I'm on ExtJS 4 and using an MVC approach. I've created a simple grid view class, and have added a componentquery type 'ref' to that view in my controller. Within the initial grid view itself I set several columns to be hidden and some to be visible by default. The rendering of the grid with those settings is all working fine.
Then I have a button that, when clicked and based on some other conditions, will make some of the initially hidden grid columns visible. This works as well.
But what I need is a way to later 'reset' the grid to its initial view (with the correct columns hidden/visible, as they were initially).
I've tried various permutations of the following with no effect:
var theGrid = this.getTheGrid();
theGrid.reconfigure(store, theGrid.initialConfig.columns);
theGrid.getView().refresh();
I suppose I could loop through every column and reset its 'hidden' state, but would think there's a way to just 'reset' back to what's set in the class? Advice?
SOLUTION UPDATE
Appreciate the pointer from tuespetre. For anyone coming along in the future looking for specifics, here is what was needed (at least for my implementation):
Within the view, moved the column defs into a variable
Within the view, columns ref within the class becomes:
columns: myColumns,
Within the view, the following function created within the class:
resetGrid: function(){
this.reconfigure(null, myColumns);
},
Within the controller:
var theGrid = this.getTheGrid();
theGrid.resetGrid();
You will just need to create a function on your view class to encapsulate that functionality.

SharePoint 2010: Quick Launch Navigation Levels

Can someone tell me how to configure the OOTB AspMenu control to achieve the following:
The quick launch should only show 1 level of static items
Except for headings, these are meaningless on their own so the pages/links beneath them should also be displayed
The menu should not display an dynamic flyouts
Essentially, the navigation menu should appear as follows (assume that the subsites both have child sites and/or pages but which should be hidden):
Starting Node
- Subsite1
- Subsite2
- Page1
- Heading
- Page2
- Page3
I couldn't find a way to achieve this functionality using the properties of the AspMenu control, so instead I just explicitly removed and subsite's child items in the MenuItemDataBoundEvent as follows:
protected void CurrentNavigationMenu_MenuItemDataBound(object sender, MenuEventArgs e)
{
// Hide the contents of subsites (only level-1 links beneath headings are displayed).
if (e.Item.Parent != null && e.Item.Parent.Selectable)
e.Item.Parent.ChildItems.Remove(e.Item);
}