tabs UI
This commit is contained in:
parent
b3b64f36fa
commit
61fb75854e
@ -9,6 +9,8 @@ import javax.swing.*;
|
|||||||
*/
|
*/
|
||||||
public class MainApp {
|
public class MainApp {
|
||||||
|
|
||||||
|
public static final String APP_VERSION = "0.0.2";
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
// Nastavení look and feel podle systému
|
// Nastavení look and feel podle systému
|
||||||
try {
|
try {
|
||||||
|
|||||||
@ -148,8 +148,11 @@ public class FilePanel extends JPanel {
|
|||||||
tabbedPane = new JTabbedPane();
|
tabbedPane = new JTabbedPane();
|
||||||
tabbedPane.setTabPlacement(JTabbedPane.TOP);
|
tabbedPane.setTabPlacement(JTabbedPane.TOP);
|
||||||
|
|
||||||
// Listener pro aktualizaci cesty při změně tabu
|
// Listener pro aktualizaci cesty a stylu při změně tabu
|
||||||
tabbedPane.addChangeListener(e -> updatePathField());
|
tabbedPane.addChangeListener(e -> {
|
||||||
|
updatePathField();
|
||||||
|
updateTabStyles();
|
||||||
|
});
|
||||||
|
|
||||||
add(tabbedPane, BorderLayout.CENTER);
|
add(tabbedPane, BorderLayout.CENTER);
|
||||||
}
|
}
|
||||||
@ -195,6 +198,7 @@ public class FilePanel extends JPanel {
|
|||||||
|
|
||||||
// Aktualizovat path field
|
// Aktualizovat path field
|
||||||
updatePathField();
|
updatePathField();
|
||||||
|
updateTabStyles();
|
||||||
|
|
||||||
// Nastavit focus na tabulku v novém tabu
|
// Nastavit focus na tabulku v novém tabu
|
||||||
SwingUtilities.invokeLater(() -> {
|
SwingUtilities.invokeLater(() -> {
|
||||||
@ -222,6 +226,7 @@ public class FilePanel extends JPanel {
|
|||||||
tabbedPane.setSelectedComponent(tab);
|
tabbedPane.setSelectedComponent(tab);
|
||||||
|
|
||||||
updatePathField();
|
updatePathField();
|
||||||
|
updateTabStyles();
|
||||||
|
|
||||||
SwingUtilities.invokeLater(() -> {
|
SwingUtilities.invokeLater(() -> {
|
||||||
tab.getFileTable().requestFocusInWindow();
|
tab.getFileTable().requestFocusInWindow();
|
||||||
@ -300,6 +305,7 @@ public class FilePanel extends JPanel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
updatePathField();
|
updatePathField();
|
||||||
|
updateTabStyles();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void populateDrives() {
|
private void populateDrives() {
|
||||||
@ -341,12 +347,31 @@ public class FilePanel extends JPanel {
|
|||||||
* Update the title of a tab according to its current directory
|
* Update the title of a tab according to its current directory
|
||||||
*/
|
*/
|
||||||
private void updateTabTitle(FilePanelTab tab) {
|
private void updateTabTitle(FilePanelTab tab) {
|
||||||
int index = tabbedPane.indexOfComponent(tab);
|
updateTabStyles();
|
||||||
if (index >= 0) {
|
}
|
||||||
File currentDir = tab.getCurrentDirectory();
|
|
||||||
if (currentDir != null) {
|
/**
|
||||||
String title = getTabTitle(currentDir.getAbsolutePath());
|
* Aktualizuje styl tabů - zvýrazní aktivní tab tučným písmem a barvou.
|
||||||
tabbedPane.setTitleAt(index, title);
|
*/
|
||||||
|
private void updateTabStyles() {
|
||||||
|
if (tabbedPane == null) return;
|
||||||
|
int selectedIndex = tabbedPane.getSelectedIndex();
|
||||||
|
for (int i = 0; i < tabbedPane.getTabCount(); i++) {
|
||||||
|
Component c = tabbedPane.getComponentAt(i);
|
||||||
|
if (c instanceof FilePanelTab) {
|
||||||
|
FilePanelTab tab = (FilePanelTab) c;
|
||||||
|
File dir = tab.getCurrentDirectory();
|
||||||
|
String title = getTabTitle(dir != null ? dir.getAbsolutePath() : "");
|
||||||
|
|
||||||
|
if (i == selectedIndex) {
|
||||||
|
// Aktivní tab: tučné písmo a tmavě modrá barva
|
||||||
|
tabbedPane.setTitleAt(i, "<html><b>" + title + "</b></html>");
|
||||||
|
tabbedPane.setForegroundAt(i, new Color(0, 51, 153));
|
||||||
|
} else {
|
||||||
|
// Neaktivní tab: normální písmo a výchozí barva
|
||||||
|
tabbedPane.setTitleAt(i, title);
|
||||||
|
tabbedPane.setForegroundAt(i, null);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -359,6 +384,7 @@ public class FilePanel extends JPanel {
|
|||||||
if (index >= 0 && tabbedPane.getTabCount() > 1) {
|
if (index >= 0 && tabbedPane.getTabCount() > 1) {
|
||||||
tabbedPane.removeTabAt(index);
|
tabbedPane.removeTabAt(index);
|
||||||
updatePathField();
|
updatePathField();
|
||||||
|
updateTabStyles();
|
||||||
|
|
||||||
// Set focus to the table in the newly active tab
|
// Set focus to the table in the newly active tab
|
||||||
FilePanelTab currentTab = getCurrentTab();
|
FilePanelTab currentTab = getCurrentTab();
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
package com.kfmanager.ui;
|
package com.kfmanager.ui;
|
||||||
|
|
||||||
|
import com.kfmanager.MainApp;
|
||||||
import com.kfmanager.config.AppConfig;
|
import com.kfmanager.config.AppConfig;
|
||||||
import com.kfmanager.model.FileItem;
|
import com.kfmanager.model.FileItem;
|
||||||
import com.kfmanager.service.FileOperations;
|
import com.kfmanager.service.FileOperations;
|
||||||
@ -22,10 +23,8 @@ public class MainWindow extends JFrame {
|
|||||||
private JTextField commandLine;
|
private JTextField commandLine;
|
||||||
private AppConfig config;
|
private AppConfig config;
|
||||||
|
|
||||||
private static final String APP_VERSION = "0.0.1";
|
|
||||||
|
|
||||||
public MainWindow() {
|
public MainWindow() {
|
||||||
super("KF Manager v" + APP_VERSION);
|
super("KF Manager v" + MainApp.APP_VERSION);
|
||||||
|
|
||||||
// Load configuration
|
// Load configuration
|
||||||
config = new AppConfig();
|
config = new AppConfig();
|
||||||
|
|||||||
BIN
src/main/resources/icon.png
Normal file
BIN
src/main/resources/icon.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.3 MiB |
Loading…
x
Reference in New Issue
Block a user