Java Code Examples for org.openide.windows.TopComponent#getDisplayName()

The following examples show how to use org.openide.windows.TopComponent#getDisplayName() . 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: ActionManager.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private void someoneActivated() {
    TopComponent win = TopComponent.getRegistry().getActivated();
    if (LOG.isLoggable(Level.FINER)) {
        String winId;
        if (win == null) {
            winId = "<null>";
        } else {
            String winName = win.getDisplayName();
            if (winName == null) {
                winName = win.getHtmlDisplayName();
            }
            if (winName == null) {
                winName = win.getName();
            }
            if (winName != null) {
                winName = '"' + winName + '"';
            } else {
                winName = "<noname>";
            }
            winId = winName + '(' + win.getClass().getName() + ')';
        }
        LOG.log(Level.FINER, "someoneActivated ({0})", winId);
    }

    if ((win == null) || (win instanceof CloneableEditorSupport.Pane)) {
        return;
    }

    Object key = getActionMapKey();
    ActionMap actionMap = win.getActionMap();

    if ((actionMap.get(key) == null) && activatedOnWindows.add(win)) {
        Action ls = getAction();
        actionMap.put(key, ls);
        win.putClientProperty(getMappedActionKey(),
                new WeakReference<Action>(ls));
    }
}
 
Example 2
Source File: ButtonPopupSwitcher.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private Item[] createSwitcherItems(final TabDisplayer displayer) {
    java.util.List<TabData> tabs = displayer.getModel().getTabs();
    Item[] items = new Item[tabs.size()];
    int i = 0;
    int selIdx = displayer.getSelectionModel().getSelectedIndex();
    TabData selectedTab = selIdx >= 0 ? displayer.getModel().getTab(selIdx) : null;
    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();
        }
        items[i++] = new Item(
                new ActivatableTab(tab),
                name,
                htmlName,
                tab,
                tab == selectedTab);
    }
    return items;
}
 
Example 3
Source File: Item.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private static String extractDisplayName( TopComponent tc ) {
    String name = tc.getShortName();
    if( name == null || name.isEmpty() ) {
        name = tc.getHtmlDisplayName();
    }
    if( name == null || name.isEmpty() ) {
        name = tc.getDisplayName();
    }
    if( name == null || name.isEmpty() ) {
        name = tc.getName();
    }
    return name;
}
 
Example 4
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()] );
}