Skip to content

Commit

Permalink
Small improvements to the “Show parent folder name in tab title” option:
Browse files Browse the repository at this point in the history
- parent folder name is displayed in opened documents list;
- parent folder name is displayed in a different color from the file name.
  • Loading branch information
troizet committed Oct 31, 2024
1 parent 45696ba commit 1591db6
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,10 @@ public boolean isTabRowPerProject() {
return impl.isTabRowPerProject();
}

public boolean isShowFolderName() {
return impl.isShowFolderName();
}

/**
* @return Maximum tab row count.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,18 +63,26 @@ class DocumentSwitcherTable extends SwitcherTable {

private final JButton btnClose;
private final Controller controller;
private final ProjectColorTabDecorator decorator;
private final ProjectColorTabDecorator projectColorTabDecorator;
private final FolderNameTabDecorator folderNameDecorator;
private final ItemBorder ITEM_BORDER = new ItemBorder();
private final Border SEPARATOR_BORDER = BorderFactory.createEmptyBorder( 2, 2, 0, 5 );

private String itemText;

public DocumentSwitcherTable( Controller controller, SwitcherTableItem[] items, int y ) {
super( items, y );
this.controller = controller;
btnClose = createCloseButton();
if( Settings.getDefault().isSameProjectSameColor() ) {
decorator = new ProjectColorTabDecorator();
projectColorTabDecorator = new ProjectColorTabDecorator();
} else {
projectColorTabDecorator = null;
}
if( Settings.getDefault().isShowFolderName() ) {
folderNameDecorator = new FolderNameTabDecorator();
} else {
decorator = null;
folderNameDecorator = null;
}
ToolTipManager.sharedInstance().registerComponent( this );
}
Expand Down Expand Up @@ -103,6 +111,13 @@ public Component prepareRenderer( TableCellRenderer renderer, int row, int colum
lbl.setIcon( null );
lbl.setText( item.getHtmlName() );
} else {
if(null != folderNameDecorator && null != item) {
TabData tab = item.getTabData();
if(null != tab) {
itemText = folderNameDecorator.getText(tab) + (item.isActive() ? " ←" : ""); //NOI18N
lbl.setText(itemText);
}
}
lbl.setBorder( ITEM_BORDER );
}
}
Expand All @@ -115,10 +130,10 @@ public Component prepareRenderer( TableCellRenderer renderer, int row, int colum
res.setBackground( renComponent.getBackground() );
return res;
}
if( null != decorator && null != item && !selected ) {
if( null != projectColorTabDecorator && null != item && !selected ) {
TabData tab = item.getTabData();
if( null != tab ) {
ITEM_BORDER.color = decorator.getBackground( tab, selected);
ITEM_BORDER.color = projectColorTabDecorator.getBackground( tab, selected);
}
}
return renComponent;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ public class FolderNameTabDecorator extends TabDecorator {

private final SettingsImpl settings = new SettingsImpl();
private static final String pathSeparator = System.getProperty( "file.separator", "/" ); //NOI18N
private static final String FONT_COLOR = "<font color=\"#9f9d9b\">"; //NOI18N
private static final String FONT_COLOR_END = "</font>"; //NOI18N

@Override
public String getText( TabData tab ) {
Expand All @@ -54,7 +56,7 @@ public String getText( TabData tab ) {
if( fo.isData() ) {
FileObject folder = fo.getParent();
if( null != folder ) {
String folderName = folder.getNameExt() + pathSeparator;
String folderName = FONT_COLOR + folder.getNameExt() + pathSeparator + FONT_COLOR_END;
String defaultText = tab.getText();

return merge( folderName, defaultText );
Expand Down

0 comments on commit 1591db6

Please sign in to comment.