Java Code Examples for org.netbeans.swing.tabcontrol.TabData#getComponent()

The following examples show how to use org.netbeans.swing.tabcontrol.TabData#getComponent() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AbstractViewTabDisplayerUI.java    From netbeans with Apache License 2.0 6 votes vote down vote up
void showHideControlButtons() {
    Component tabComponent = null;
    boolean tcSlidingEnabled = true;
    boolean tcClosingEnabled = true;
    int selIndex = Math.max( 0, displayer.getSelectionModel().getSelectedIndex() );
    if( selIndex >= 0 && selIndex < displayer.getModel().size() ) {
        TabData tab = displayer.getModel().getTab( selIndex );
        tabComponent = tab.getComponent();
        if( tabComponent instanceof TopComponent ) {
            tcSlidingEnabled = displayer.getContainerWinsysInfo().isTopComponentSlidingEnabled( (TopComponent)tabComponent );
            tcClosingEnabled = displayer.getContainerWinsysInfo().isTopComponentClosingEnabled( (TopComponent)tabComponent );
        }
    }
    btnAutoHidePin.setVisible( tabComponent != null 
            && !TabDisplayer.ORIENTATION_INVISIBLE.equals( displayer.getContainerWinsysInfo().getOrientation( tabComponent ) )
            && displayer.getContainerWinsysInfo().isTopComponentSlidingEnabled()
            && tcSlidingEnabled );

    if( null != btnClose ) {
        btnClose.setVisible(tabComponent != null && tcClosingEnabled);
    }
}
 
Example 2
Source File: BasicScrollingTabDisplayerUI.java    From netbeans with Apache License 2.0 6 votes vote down vote up
@Override
public void makeTabVisible (int tab) {
    if( tab < 0 ) //#219681 - nobody has set the selected tab yet
        return;
    if (scroll().makeVisible(tab, getTabsAreaWidth())) {
        getTabsVisibleArea(scratch);
        displayer.repaint(scratch.x, scratch.y, scratch.width, scratch.height);
    }

    if( null == btnMaximizeRestore )
        return;
    TabData td = displayer.getModel().getTab(tab);
    Component c = td.getComponent();
    if( !(c instanceof TopComponent) )
        return;
    boolean maximizeEnabled = displayer.getContainerWinsysInfo().isTopComponentMaximizationEnabled((TopComponent)c);
    btnMaximizeRestore.setEnabled(maximizeEnabled);
}
 
Example 3
Source File: FolderNameTabDecorator.java    From netbeans with Apache License 2.0 6 votes vote down vote up
@Override
public String getText( TabData tab ) {
    if( !settings.isShowFolderName() )
        return null;
    if( tab.getComponent() instanceof TopComponent ) {
        TopComponent tc = ( TopComponent ) tab.getComponent();
        DataObject dob = tc.getLookup().lookup( DataObject.class );
        if( null != dob ) {
            FileObject fo = dob.getPrimaryFile();
            if( fo.isData() ) {
                FileObject folder = fo.getParent();
                if( null != folder ) {
                    String folderName = folder.getNameExt() + pathSeparator;
                    String defaultText = tab.getText();

                    return merge( folderName, defaultText );
                }
            }
        }
    }
    return null;
}
 
Example 4
Source File: CakePHPTabDecorator.java    From cakephp3-netbeans with Apache License 2.0 6 votes vote down vote up
@Override
public String getText(TabData tab) {
    // show a parent directory name if it's a view file
    // e.g. home.ctp [Pages]
    String text = tab.getText();
    if (text.endsWith(".ctp")) { // NOI18N
        Component component = tab.getComponent();
        if (component instanceof TopComponent) {
            TopComponent topComponent = (TopComponent) component;
            Lookup lookup = topComponent.getLookup();
            if (lookup != null) {
                FileObject fileObject = lookup.lookup(FileObject.class);
                if (fileObject != null) {
                FileObject parent = fileObject.getParent();
                    if (parent != null) {
                        String parentName = parent.getName();
                        return String.format("%s [%s]", text, parentName); // NOI18N
                    }
                }
            }
        }
    }
    return super.getText(tab);
}
 
Example 5
Source File: BasicTabDisplayerUI.java    From netbeans with Apache License 2.0 5 votes vote down vote up
/**
 * Get the cell renderer for a given tab.  The default implementation simply
 * returns the renderer created by createDefaultRenderer().
 * @param tab
 * @return 
 */
public TabCellRenderer getTabCellRenderer(int tab) {
    defaultRenderer.setShowCloseButton(displayer.isShowCloseButton());
    if( tab >=0 && tab < displayer.getModel().size() ) {
        TabData data = displayer.getModel().getTab(tab);
        boolean closingEnabled = true;
        if( data.getComponent() instanceof TopComponent ) {
            closingEnabled = displayer.getContainerWinsysInfo().isTopComponentClosingEnabled( (TopComponent)data.getComponent() );
        }

        defaultRenderer.setShowCloseButton(displayer.isShowCloseButton() && closingEnabled);
    }
    return defaultRenderer;
}
 
Example 6
Source File: TabControlButtonFactory.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private static Component getActiveTab( TabDisplayer displayer ) {
    Component res = null;
    int selIndex = displayer.getSelectionModel().getSelectedIndex();
    if( selIndex >= 0 ) {
        TabData tab = displayer.getModel().getTab( selIndex );
        res = tab.getComponent();
    }
    return res;
}
 
Example 7
Source File: CommandManager.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private Tabbed updateSlidedTabContainer(int tabIndex) {
        Tabbed container = getSlidingTabbed();
//        TabDataModel containerModel = container.getModel();
        SlideBarDataModel dataModel = slideBar.getModel();
        // creating new TabData instead of just referencing
        // to be able to compare and track changes between models of slide bar and 
        // slided tabbed container
        TabData origTab = dataModel.getTab(tabIndex);
        TopComponent tc = ( TopComponent ) origTab.getComponent();
        container.setTopComponents( new TopComponent[] { tc }, tc );
        return container;
    }
 
Example 8
Source File: TabbedSlideAdapter.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override
public Image createImageOfTab(int tabIndex) {
    TabData dt = slideBar.getModel().getTab(tabIndex);
    if (dt.getComponent() instanceof TopComponent) {
        DefaultTabDataModel tempModel = new DefaultTabDataModel( new TabData[] { dt } );
        TabbedContainer temp = new TabbedContainer( tempModel, TabbedContainer.TYPE_VIEW );
        temp.setSize( 300,300 );
        
        return temp.createImageOfTab(0);
    }
    
    return null;
}
 
Example 9
Source File: TabDataRenderer.java    From netbeans with Apache License 2.0 5 votes vote down vote up
static boolean isClosable( TabData tab ) {
    if( !SHOW_CLOSE_BUTTON )
        return false;
    
    if( !Utilities.isEditorTopComponentClosingEnabled() )
        return false;

    Component tc = tab.getComponent();
    if( tc instanceof TopComponent ) {
        return !Boolean.TRUE.equals(((TopComponent)tc).getClientProperty(TopComponent.PROP_CLOSING_DISABLED));
    }
    return true;
}
 
Example 10
Source File: MainView.java    From HiJson with Apache License 2.0 5 votes vote down vote up
private JTextArea getTextArea(){
    int selIndex = getTabIndex();
    if(selIndex >= 0){
        TabData selTabData = tabDataModel.getTab(selIndex);
        JSplitPane selSplitPane = (JSplitPane)selTabData.getComponent();
        JScrollPane sp = (JScrollPane)selSplitPane.getLeftComponent();
        JViewport vp = (JViewport)sp.getComponent(0);
        JTextArea ta = (JTextArea)vp.getComponent(0);
        return ta;
    }
    return null;
}
 
Example 11
Source File: MainView.java    From HiJson with Apache License 2.0 5 votes vote down vote up
private JTree getTree(TabData tabData){
    if(tabData==null){
        return null;
    }
    JSplitPane selSplitPane = (JSplitPane)tabData.getComponent();
    JSplitPane rightSplitPane = (JSplitPane)selSplitPane.getRightComponent();
    JScrollPane sp = (JScrollPane)rightSplitPane.getLeftComponent();
    JViewport vp = (JViewport)sp.getComponent(0);
    JTree t = (JTree)vp.getComponent(0);
    return t;
}
 
Example 12
Source File: MainView.java    From HiJson with Apache License 2.0 5 votes vote down vote up
private JTable getTable(int tabIndex){
    if(tabIndex >= 0){
        TabData selTabData = tabDataModel.getTab(tabIndex);
        JSplitPane selSplitPane = (JSplitPane)selTabData.getComponent();
        JSplitPane rightSplitPane = (JSplitPane)selSplitPane.getRightComponent();
        JScrollPane sp = (JScrollPane)rightSplitPane.getRightComponent();
        JViewport vp = (JViewport)sp.getComponent(0);
        JTable t = (JTable)vp.getComponent(0);
        return t;
    }
    return null;
}
 
Example 13
Source File: MainView.java    From HiJson with Apache License 2.0 5 votes vote down vote up
private void changeLayout() {
    int selIndex = getTabIndex();
    if(selIndex < 0){
        return;
    }
    TabData selTabData = tabDataModel.getTab(selIndex);
    JSplitPane splitPane = (JSplitPane)selTabData.getComponent();
    if (splitPane.getOrientation() == JSplitPane.VERTICAL_SPLIT) {
        splitPane.setOrientation(JSplitPane.HORIZONTAL_SPLIT);
        splitPane.setDividerLocation(0.45);
    } else {
        splitPane.setOrientation(JSplitPane.VERTICAL_SPLIT);
        splitPane.setDividerLocation(0.45);
    }
}
 
Example 14
Source File: ButtonPopupSwitcher.java    From netbeans with Apache License 2.0 4 votes vote down vote up
private Item[] createSwitcherItems(final Controller controller) {
    ProjectSupport projectSupport = ProjectSupport.getDefault();
    final boolean sortByProject = Settings.getDefault().isSortDocumentListByProject()
            && projectSupport.isEnabled();
    java.util.List<TabData> tabs = controller.getTabModel().getTabs();
    ArrayList<Item> items = new ArrayList<Item>(tabs.size());
    int selIdx = controller.getSelectedIndex();
    TabData selectedTab = selIdx >= 0 && selIdx < controller.getTabModel().size() ? controller.getTabModel().getTab(selIdx) : null;
    boolean hasProjectInfo = false;
    for (TabData tab : tabs) {
        String name;
        String htmlName;
        if (tab.getComponent() instanceof TopComponent) {
            TopComponent tabTC = (TopComponent) tab.getComponent();
            name = tabTC.getDisplayName();
            // #68291 fix - some hostile top components have null display name
            if (name == null) {
                name = tabTC.getName();
            }
            htmlName = tabTC.getHtmlDisplayName();
            if (htmlName == null) {
                htmlName = name;
            }
        } else {
            name = htmlName = tab.getText();
        }
        ProjectProxy project = null;
        if( sortByProject ) {
            project = projectSupport.getProjectForTab( tab );
            hasProjectInfo |= null != project;
        }
        items.add( new Item(
                new ActivatableTab(tab),
                name,
                htmlName,
                tab,
                tab == selectedTab,
                project));
    }
    Collections.sort( items );
    if( sortByProject && hasProjectInfo ) {
        //add project headers
        ProjectProxy currentProject = null;
        for( int i=0; i<items.size(); i++ ) {
            Item item = items.get( i );
            ProjectProxy p = item.getProject();
            if( null != p && !p.equals( currentProject ) ) {
                items.add( i, Item.create( p ) );
            } else if( null == p && null != currentProject ) {
                items.add( i, DocumentSwitcherTable.NO_PROJECT_SEPARATOR );
            }
            currentProject = p;
        }
    }
    return items.toArray( new Item[items.size()] );
}