diff --git a/Core/src/org/sleuthkit/autopsy/corecomponents/Installer.java b/Core/src/org/sleuthkit/autopsy/corecomponents/Installer.java index 30d692747d4342c6df63e7c176f827bd834af69e..b896e14f1cd3b004325f95319612025d957aba6e 100644 --- a/Core/src/org/sleuthkit/autopsy/corecomponents/Installer.java +++ b/Core/src/org/sleuthkit/autopsy/corecomponents/Installer.java @@ -23,16 +23,19 @@ import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; import java.util.Collection; +import java.util.Enumeration; import java.util.Iterator; import java.util.Map; import java.util.TreeMap; import java.util.logging.Level; +import java.util.stream.Stream; import javax.swing.BorderFactory; import javax.swing.ImageIcon; import javax.swing.SwingUtilities; import javax.swing.UIManager; import javax.swing.UIManager.LookAndFeelInfo; import javax.swing.UnsupportedLookAndFeelException; +import javax.swing.plaf.FontUIResource; import org.netbeans.spi.sendopts.OptionProcessor; import org.netbeans.swing.tabcontrol.plaf.DefaultTabbedContainerUI; import org.openide.modules.ModuleInstall; @@ -52,6 +55,40 @@ public class Installer extends ModuleInstall { private static final long serialVersionUID = 1L; private static final Logger logger = Logger.getLogger(Installer.class.getName()); private static Installer instance; + // taken from https://stackoverflow.com/questions/7434845/setting-the-default-font-of-swing-program + private static final String[] SWING_FONT_ITEMS = {"Button.font", + "ToggleButton.font", + "RadioButton.font", + "CheckBox.font", + "ColorChooser.font", + "ComboBox.font", + "Label.font", + "List.font", + "MenuBar.font", + "MenuItem.font", + "RadioButtonMenuItem.font", + "CheckBoxMenuItem.font", + "Menu.font", + "PopupMenu.font", + "OptionPane.font", + "Panel.font", + "ProgressBar.font", + "ScrollPane.font", + "Viewport.font", + "TabbedPane.font", + "Table.font", + "TableHeader.font", + "TextField.font", + "PasswordField.font", + "TextArea.font", + "TextPane.font", + "EditorPane.font", + "TitledBorder.font", + "ToolBar.font", + "ToolTip.font", + "Tree.font"}; + + private static final FontUIResource DEFAULT_FONT = new FontUIResource("Tahoma", Font.PLAIN, 12); public synchronized static Installer getDefault() { if (null == instance) { @@ -128,7 +165,12 @@ private void setLookAndFeel() { UIManager.put("OptionPane.warningIcon", warningIcon); UIManager.put("OptionPane.questionIcon", questionIcon); UIManager.put("OptionPane.informationIcon", informationIcon); - + + // set default font for all font items + for (String fontKey : SWING_FONT_ITEMS) { + UIManager.put(fontKey, DEFAULT_FONT); + } + if (System.getProperty("os.name").toLowerCase().contains("mac")) { //NON-NLS setUnixLookAndFeel(); setModuleSettings("false"); diff --git a/ImageGallery/src/org/sleuthkit/autopsy/imagegallery/gui/drawableviews/GroupPane.java b/ImageGallery/src/org/sleuthkit/autopsy/imagegallery/gui/drawableviews/GroupPane.java index 4a4665e1ffb43a2329c660099ac8e33a1d1df1b3..906f19e1f960ad5ddf7308b886df765d60d84bb4 100644 --- a/ImageGallery/src/org/sleuthkit/autopsy/imagegallery/gui/drawableviews/GroupPane.java +++ b/ImageGallery/src/org/sleuthkit/autopsy/imagegallery/gui/drawableviews/GroupPane.java @@ -48,6 +48,7 @@ import javafx.beans.property.SimpleObjectProperty; import javafx.beans.value.ChangeListener; import javafx.beans.value.ObservableValue; +import javafx.collections.FXCollections; import javafx.collections.ObservableList; import javafx.event.ActionEvent; import javafx.event.EventHandler; @@ -241,6 +242,8 @@ public class GroupPane extends BorderPane { */ @ThreadConfined(type = ThreadType.JFX) private final Map<Long, DrawableCell> cellMap = new HashMap<>(); + + private final InvalidationListener filesSyncListener = (observable) -> { final String header = getHeaderString(); @@ -594,10 +597,7 @@ void setViewState(GroupViewState newViewState) { slideShowToggle.setDisable(true); groupLabel.setText(""); resetScrollBar(); - if (false == Case.isCaseOpen()) { - cellMap.values().stream().forEach(DrawableCell::resetItem); - cellMap.clear(); - } + cellMap.clear(); }); } else { @@ -659,41 +659,46 @@ void makeSelection(Boolean shiftDown, Long newFileID) { } } - private class DrawableCell extends GridCell<Long> { + private class DrawableCell extends GridCell<Long> implements AutoCloseable { private final DrawableTile tile = new DrawableTile(GroupPane.this, controller); - - protected final ChangeListener<Long> changeListener = (ObservableValue<? extends Long> observable, Long oldValue, Long newValue) -> { - if ((oldValue == null && newValue == null) || (oldValue != null && newValue != null && oldValue.equals(newValue))) { - // if no change, do nothing - return; - } - - DrawableCell oldValueCell = oldValue == null ? null : cellMap.remove(oldValue); - if (oldValueCell != null) { - // remove change listener to get garbage collected - oldValueCell.itemProperty().removeListener(oldValueCell.changeListener); - } - - if (newValue != null) { - cellMap.put(newValue, DrawableCell.this); - } - }; + + /** + * This stores the last non-null file id. So that only new file ids for + * this item are tracked. This prevents an infinite render loop. See + * https://github.com/controlsfx/controlsfx/issues/1241 for more + * information + */ + private Long oldItem = null; DrawableCell() { - itemProperty().addListener(changeListener); setGraphic(tile); } @Override protected void updateItem(Long item, boolean empty) { super.updateItem(item, empty); - tile.setFile(item); + + if (item != null && oldItem != item) { + tile.setFile(item); + } + + if (item != null) { + cellMap.put(item, this); + oldItem = item; + } else if (oldItem != null) { + cellMap.remove(oldItem); + } } void resetItem() { tile.setFile(null); } + + @Override + public void close() throws Exception { + resetItem(); + } } /**