Skip to content

Commit 136fc89

Browse files
committed
Reduce icon opacity for hidden files
1 parent 3b302b2 commit 136fc89

4 files changed

Lines changed: 51 additions & 19 deletions

File tree

shellfx-dialogs/src/main/java/com/techsenger/shellfx/dialogs/file/FileChooserDialogFxView.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
import com.techsenger.shellfx.storage.FileColumnBuilder;
3939
import com.techsenger.shellfx.storage.FileColumns;
4040
import com.techsenger.shellfx.storage.FileStringConverter;
41+
import com.techsenger.shellfx.storage.FileViewConstants;
4142
import com.techsenger.shellfx.storage.GenericFile;
4243
import com.techsenger.toolkit.fx.value.ValueUtils;
4344
import java.util.Comparator;
@@ -124,6 +125,8 @@ protected AlertDialogFxView<?> createAlertDialog(AlertDialogParams params) {
124125

125126
private final class DialogTextFieldColumnListCell extends TextFieldColumnListCell<T> {
126127

128+
private final FontIconView iconView = new FontIconView();
129+
127130
private DialogTextFieldColumnListCell(StringConverter converter) {
128131
super(converter);
129132
addEventFilter(MouseEvent.MOUSE_CLICKED, e -> {
@@ -156,7 +159,13 @@ protected void updateItem(T item, boolean empty) {
156159
} else {
157160
if (item.getEntryType() != null) {
158161
var icon = iconProvider.apply(item);
159-
setGraphic(new FontIconView(icon));
162+
iconView.setIcon(icon);
163+
if (item.isHidden()) {
164+
iconView.setOpacity(FileViewConstants.HIDDEN_FILE_OPACITY);
165+
} else {
166+
iconView.setOpacity(1.0);
167+
}
168+
setGraphic(iconView);
160169
} else {
161170
setGraphic(null);
162171
}

shellfx-dialogs/src/main/java/com/techsenger/shellfx/dialogs/file/FileListView.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
package com.techsenger.shellfx.dialogs.file;
1818

1919
import com.techsenger.shellfx.material.list.ColumnListView;
20-
import com.techsenger.shellfx.storage.FileStringConverter;
2120
import com.techsenger.shellfx.storage.GenericFile;
2221
import javafx.collections.ObservableList;
2322
import javafx.scene.control.ContextMenu;
@@ -28,8 +27,6 @@
2827
*/
2928
class FileListView<T extends GenericFile> extends ColumnListView<T> {
3029

31-
private final FileStringConverter<T> stringConverter = new FileStringConverter<>();
32-
3330
FileListView(ObservableList<T> files, ContextMenu cellContextMenu) {
3431
setItems(files);
3532
setManualRefresh(true);

shellfx-storage/src/main/java/com/techsenger/shellfx/storage/FileColumnBuilder.java

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
import java.util.Comparator;
2929
import java.util.function.Function;
3030
import javafx.beans.property.ReadOnlyObjectWrapper;
31-
import javafx.scene.Node;
3231
import javafx.scene.control.TableCell;
3332
import javafx.scene.layout.HBox;
3433
import javafx.scene.text.Font;
@@ -57,43 +56,40 @@ public <F extends GenericFile> NamedTableColumn<F, F> buildNameColumn(Function<F
5756
var converter = new FileStringConverter<F>();
5857
nameColumn.setCellFactory(col -> new TextFieldTableCell<F, F>(converter) {
5958

59+
private final FontIconView iconView = new FontIconView();
60+
6061
@Override
6162
public void updateItem(F file, boolean empty) {
6263
super.updateItem(file, empty);
6364
if (file == null || empty) {
6465
setGraphic(null);
6566
setText(null);
6667
} else {
67-
setGraphic(buildIcon(file));
68+
if (file.isHidden()) {
69+
iconView.setOpacity(FileViewConstants.HIDDEN_FILE_OPACITY);
70+
} else {
71+
iconView.setOpacity(1.0);
72+
}
73+
iconView.setIcon(iconProvider.apply(file));
74+
setGraphic(iconView);
6875
setText(file.getName());
6976
}
7077
}
7178

7279
@Override
7380
protected HBox buildEditGraphic() {
74-
var icon = buildIcon(getItem());
75-
var box = new HBox(getTextField());
76-
if (icon != null) {
77-
box.getChildren().add(0, icon);
78-
}
81+
var box = new HBox(iconView, getTextField());
7982
return box;
8083
}
8184

8285
@Override
8386
protected void updateDisplay() {
8487
var file = getItem();
8588
if (file != null) {
86-
setGraphic(buildIcon(file));
89+
setGraphic(iconView);
8790
setText(file.getName());
8891
}
8992
}
90-
91-
private Node buildIcon(F file) {
92-
if (file.getEntryType() == null) {
93-
return null;
94-
}
95-
return new FontIconView(iconProvider.apply(file));
96-
}
9793
});
9894
nameColumn.setComparator(Comparator.comparing(GenericFile::getName, String.CASE_INSENSITIVE_ORDER));
9995
return nameColumn;
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/*
2+
* Copyright 2024-2026 Pavel Castornii.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package com.techsenger.shellfx.storage;
18+
19+
/**
20+
*
21+
* @author Pavel Castornii
22+
*/
23+
public final class FileViewConstants {
24+
25+
public static final double HIDDEN_FILE_OPACITY = 0.5;
26+
27+
private FileViewConstants() {
28+
// empty
29+
}
30+
}

0 commit comments

Comments
 (0)