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);
}
Related
My extension have sidebar webview that can create additional webviews as panels in the active text editor. Each of these additional webviews is for an unique item and I want to revive/activate existing webview, for the specific item, if it exists.
My issues:
I can get a list of the existing tabs with window.tabGroups.all and loop through the result. But there is no way, as far as i can see, to reactivate the desired tab. I can get some properties from there but no methods. The question here is: is there a API to get a list of the tabs and be able to revive/activate it?
Because of the first point ive decided to keep list of the instances of the additional webviews and when new webview is about the be created im checking if its unique id (in the title) is in the list and if it is then just revive the tab instead of creating a new one. Dont like this approach much but its working. The problem here is when the additional webview is closed. When closed it has to be removed from the array. Ive implemented onDidDispose for the panel but somehow the filter function, inside it, is not called:
// panels: vscode.WebviewPanel[]
// create new panel
const panel = vscode.window.createWebviewPanel(...)
// add the webview instance to the panel
const newWebview = new AdditionalWebview(panel, this.context);
this.panels.push(panel);
panel.onDidDispose(() => {
console.log("Before remove the panel"); // can see this in the console
this.panels = this.panels.filter((p) => p.title != panel.title);
console.log("Before remove the panel"); // for some reason this never appears
});
Not sure why but the panel filter functionality is never triggered (and everything after it is also not ran).
extra question: at the moment the uniqueness of the additional panels is based on their label/title. In my case thats is ok but is there any other way to get unique identifier of each tab? id/guid somewhere?
On your first question about activating a given editor, you have a couple of options.
If you know the editor's index/position in its group. That can be obtained from its tabGroup.tabs position - it seems that the tab's index in that array is faithfully its index in the editor. So you could do a Array.findIndex to get the tab uri you want to set to active.
await vscode.commands.executeCommand('workbench.action.openEditorAtIndex', [indexToOpen]);
// note the [] around the index argument
The only problem with this approach is that it works within the active group only, so you may have to activate the correct group first via:
await vscode.commands.executeCommand('workbench.action.focusSecondEditorGroup');
// or whichever group the tab you want to open is in
Or second method:
// assumes you have the tab
const openOptions = { preserveFocus: true, preview: tab.isPreview, viewColumn: tab.group.viewColumn};
// check if a uri, might be viewtype, etc., instead
if (tab.input instanceof vscode.TabInputText) {
await vscode.commands.executeCommand('vscode.open', tab.input.uri, openOptions);
}
// are your editors regular text editors?
This looks like it is opening a new tab but it will focus an existing tab if one exists at that location with that same uri.
Is there a way to have the categories sidebar menu start in the expanded state? Currently it starts out collapsed and requires the user to expand the top level categories to view the ones underneath.
My store has only one main category right now and I would like to have it expanded unless the user chooses to collapse it
here is a link to the demo page as my site has not been published yet.
http://hawaii-demo.mybigcommerce.com/
[
Since the category list is controlled by a snippet, you would need to use javascript to autoselect/autoexpand that particular parent category.
Something like:
$(document).ready(function(){
if ($('li:contains(parentCategoryName)').hasClass('expandable') {
$(this).addClass('collapsable');
$(this).removeClass('expandable');
}
else {
return null;
}
});
I haven't tested the above script, but that would be one of my first tries. It may require tweaks. You should replace "parentCategoryName" with the name of your parent category that you want to expand.
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);
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);
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.