public BrowserTab getSelectedTabView() { return BrowserTab.byPosition(browserTabView.indexOfTabViewItem(browserTabView.selectedTabViewItem())); }
/** * Change the toolbar selection and display the tab index. * * @param selected The index of the tab to be selected */ protected void setSelectedPanel(final int selected) { int tab = selected; if(-1 == tab) { tab = 0; } String identifier = tabView.tabViewItemAtIndex(tab).identifier(); if(!this.validateTabWithIdentifier(identifier)) { tab = 0; identifier = tabView.tabViewItemAtIndex(tab).identifier(); } tabView.selectTabViewItemAtIndex(tab); NSTabViewItem page = tabView.selectedTabViewItem(); if(page == null) { page = tabView.tabViewItemAtIndex(0); } toolbar.setSelectedItemIdentifier(page.identifier()); this.initializePanel(identifier); }
public void toolbarItemSelected(final NSToolbarItem sender) { this.setSelectedPanel(tabView.indexOfTabViewItemWithIdentifier(sender.itemIdentifier())); }
public void setTabView(NSTabView view) { this.tabView = view; this.tabView.setAutoresizingMask(new NSUInteger(NSView.NSViewWidthSizable | NSView.NSViewHeightSizable)); this.tabView.setDelegate(this.id()); }
@Override public void awakeFromNib() { // Reset NSEnumerator items = this.tabView.tabViewItems().objectEnumerator(); NSObject object; while(((object = items.nextObject()) != null)) { this.tabView.removeTabViewItem(Rococoa.cast(object, NSTabViewItem.class)); } // Insert all panels into tab view for(Map.Entry<Label, NSView> tab : this.getPanels().entrySet()) { final NSTabViewItem item = NSTabViewItem.itemWithIdentifier(tab.getKey().identifier); item.setView(tab.getValue()); item.setLabel(tab.getKey().label); this.tabView.addTabViewItem(item); } // Set up toolbar properties: Allow customization, give a default display mode, and remember state in user defaults toolbar.setAllowsUserCustomization(false); toolbar.setSizeMode(this.getToolbarSize()); toolbar.setDisplayMode(this.getToolbarMode()); toolbar.setDelegate(this.id()); window.setToolbar(toolbar); // Change selection to last selected item in preferences final int index = preferences.getInteger(String.format("%s.selected", this.getToolbarName())); this.setSelectedPanel(index < this.getPanels().size() ? index : 0); this.setTitle(this.getTitle(tabView.selectedTabViewItem())); super.awakeFromNib(); }
public void setFiles(List<Path> files) { if(files.isEmpty()) { return; } this.files = files; this.initializePanel(this.getSelectedTab()); this.setTitle(this.getTitle(tabView.selectedTabViewItem())); }
private void selectBrowser(final BrowserSwitchSegement selected) { bookmarkSwitchView.setSelectedSegment(BookmarkSwitchSegement.browser.ordinal()); this.setNavigation(this.isMounted()); switch(selected) { case list: browserTabView.selectTabViewItemAtIndex(BrowserTab.list.ordinal()); break; case outline: browserTabView.selectTabViewItemAtIndex(BrowserTab.outline.ordinal()); break; } // Save selected browser view preferences.setProperty("browser.view", selected.ordinal()); // Remove any custom file filter this.setFilter(null); // Update from model this.reload(); // Focus on browser view this.getFocus(); }
@Override public void tabView_didSelectTabViewItem(final NSTabView view, final NSTabViewItem item) { this.setTitle(this.getTitle(item)); this.resize(); preferences.setProperty(String.format("%s.selected", this.getToolbarName()), view.indexOfTabViewItem(item)); }
@Override public NSToolbarItem toolbar_itemForItemIdentifier_willBeInsertedIntoToolbar(final NSToolbar toolbar, final String itemIdentifier, final boolean flag) { if(!cache.containsKey(itemIdentifier)) { cache.put(itemIdentifier, NSToolbarItem.itemWithIdentifier(itemIdentifier)); } final NSToolbarItem toolbarItem = cache.get(itemIdentifier); final NSTabViewItem tab = tabView.tabViewItemAtIndex(tabView.indexOfTabViewItemWithIdentifier(itemIdentifier)); if(null == tab) { log.warn(String.format("No tab for toolbar item %s", itemIdentifier)); return null; } toolbarItem.setLabel(tab.label()); toolbarItem.setPaletteLabel(tab.label()); toolbarItem.setToolTip(tab.label()); toolbarItem.setImage(IconCacheFactory.<NSImage>get().iconNamed(String.format("%s.tiff", itemIdentifier), 32)); toolbarItem.setTarget(this.id()); toolbarItem.setAction(Foundation.selector("toolbarItemSelected:")); return toolbarItem; }
@Override public void invalidate() { toolbar.setDelegate(null); tabView.setDelegate(null); super.invalidate(); }
/** * @return Minimum size to fit content view of currently selected tab. */ private NSRect getContentRect() { NSRect contentRect = new NSRect(0, 0); final NSView view = tabView.selectedTabViewItem().view(); final NSEnumerator enumerator = view.subviews().objectEnumerator(); NSObject next; while(null != (next = enumerator.nextObject())) { final NSView subview = Rococoa.cast(next, NSView.class); contentRect = FoundationKitFunctionsLibrary.NSUnionRect(contentRect, subview.frame()); } return contentRect; } }
this.setNavigation(false); browserTabView.selectTabViewItemAtIndex(BrowserTab.bookmarks.ordinal()); final AbstractHostCollection source; switch(selected) {