Remove SingleCDockable

Hi it’s me again :slight_smile:

i tried to remove a dockable. I found a solution here but when i remove a dockable, i get an exception.

that’s my code:


public void removeServiceTabs(){
        //TODO Settings Exception entfernen?
        int dockCounter = 0;
        String dockTitle = null;
        dockCounter = control.getCDockableCount();
        
        for(int i = 0; i < dockCounter; i++){
            SingleCDockable dockToRemove = (SingleCDockable) control.getCDockable(i);
            dockTitle = dockToRemove.intern().getTitleText();
            
            if(!dockTitle.equals("Project Information") && !dockTitle.equals("Settings")
                    && !dockTitle.equals("Projects") && !dockTitle.equals("Output")){
                dockToRemove.setVisible(false);
                control.removeSingleDockable(dockTitle);
                
            }
        }
    }

Here is the exception:


Exception in thread "AWT-EventQueue-0" java.lang.IllegalArgumentException: not a valid character of a segment: ' '
    at bibliothek.util.Path.<init>(Unknown Source)
    at bibliothek.gui.dock.common.intern.CPlaceholderStrategy$1.removed(Unknown Source)
    at bibliothek.gui.dock.common.CControl.remove(Unknown Source)
    at bibliothek.gui.dock.common.CControl.removeSingleDockable(Unknown Source)
    at mvc.view.DiagnosticClient.removeServiceTabs(DiagnosticClient.java:126)


What are the unique identifiers of your Dockables? Looks like one of them is not parsed correct.

there is one tab named Start Diagnostic Session. This tab i want to remove.

Which version are you using? With 1.1.0 final this should not happen. To be more exact, the code below works with 1.1.0, but should not work with your version.

DefaultSingleCDockable dockable = new DefaultSingleCDockable( "Start Diagnostic Session" );
control.addDockable( dockable );
control.remove( dockable );```

I use 1.0.8. I will try the new Version.

At the moment this code works for me:


try {
                if(!dockTitle.equals("Project Information") && !dockTitle.equals("Settings")
                        && !dockTitle.equals("Projects") && !dockTitle.equals("Output")){
                    dockToRemove.setVisible(false);
                    dockCounter--;
                    i = 0;
                    control.removeSingleDockable(dockTitle);    
                }
            } catch (Exception e) {
    
            }


Thx. The new Version 1.1.0 works :slight_smile: