diff --git a/res/runtime/images/action/GoToHome.png b/res/runtime/images/action/GoToHome.png
index 69eac4780..34b588e1f 100644
Binary files a/res/runtime/images/action/GoToHome.png and b/res/runtime/images/action/GoToHome.png differ
diff --git a/res/runtime/images/action/GoToHome@2x.png b/res/runtime/images/action/GoToHome@2x.png
new file mode 100644
index 000000000..a40c245f0
Binary files /dev/null and b/res/runtime/images/action/GoToHome@2x.png differ
diff --git a/res/runtime/images/action/MarkGroup.png b/res/runtime/images/action/MarkGroup.png
index 294a258e7..7418aefaa 100644
Binary files a/res/runtime/images/action/MarkGroup.png and b/res/runtime/images/action/MarkGroup.png differ
diff --git a/res/runtime/images/action/MarkGroup@2x.png b/res/runtime/images/action/MarkGroup@2x.png
new file mode 100644
index 000000000..a8e0c6596
Binary files /dev/null and b/res/runtime/images/action/MarkGroup@2x.png differ
diff --git a/res/runtime/images/action/Pack.png b/res/runtime/images/action/Pack.png
index ba1579e38..e073bf43e 100644
Binary files a/res/runtime/images/action/Pack.png and b/res/runtime/images/action/Pack.png differ
diff --git a/res/runtime/images/action/Pack@2x.png b/res/runtime/images/action/Pack@2x.png
new file mode 100644
index 000000000..835479cb1
Binary files /dev/null and b/res/runtime/images/action/Pack@2x.png differ
diff --git a/res/runtime/images/action/Pack@3x.png b/res/runtime/images/action/Pack@3x.png
new file mode 100644
index 000000000..c4413dbf3
Binary files /dev/null and b/res/runtime/images/action/Pack@3x.png differ
diff --git a/res/runtime/images/action/SetSameFolder@2x.png b/res/runtime/images/action/SetSameFolder@2x.png
new file mode 100644
index 000000000..acd35d475
Binary files /dev/null and b/res/runtime/images/action/SetSameFolder@2x.png differ
diff --git a/res/runtime/images/action/SwapFolders@2x.png b/res/runtime/images/action/SwapFolders@2x.png
new file mode 100644
index 000000000..ea1eb0fef
Binary files /dev/null and b/res/runtime/images/action/SwapFolders@2x.png differ
diff --git a/res/runtime/images/action/UnmarkGroup.png b/res/runtime/images/action/UnmarkGroup.png
index ca6cae9b0..45c0149f1 100644
Binary files a/res/runtime/images/action/UnmarkGroup.png and b/res/runtime/images/action/UnmarkGroup.png differ
diff --git a/res/runtime/images/action/UnmarkGroup@2x.png b/res/runtime/images/action/UnmarkGroup@2x.png
new file mode 100644
index 000000000..7cce7ead1
Binary files /dev/null and b/res/runtime/images/action/UnmarkGroup@2x.png differ
diff --git a/res/runtime/images/action/Unpack.png b/res/runtime/images/action/Unpack.png
index cecd99b75..8633b1b99 100644
Binary files a/res/runtime/images/action/Unpack.png and b/res/runtime/images/action/Unpack.png differ
diff --git a/res/runtime/images/action/Unpack@2x.png b/res/runtime/images/action/Unpack@2x.png
new file mode 100644
index 000000000..51745d0f5
Binary files /dev/null and b/res/runtime/images/action/Unpack@2x.png differ
diff --git a/res/runtime/images/action/Unpack@3x.png b/res/runtime/images/action/Unpack@3x.png
new file mode 100644
index 000000000..f09abf55a
Binary files /dev/null and b/res/runtime/images/action/Unpack@3x.png differ
diff --git a/res/runtime/images/action/Unpack@4x.png b/res/runtime/images/action/Unpack@4x.png
new file mode 100644
index 000000000..8cd585fc3
Binary files /dev/null and b/res/runtime/images/action/Unpack@4x.png differ
diff --git a/src/main/com/mucommander/commons/file/FileFactory.java b/src/main/com/mucommander/commons/file/FileFactory.java
index 4b932477e..fd994eb00 100644
--- a/src/main/com/mucommander/commons/file/FileFactory.java
+++ b/src/main/com/mucommander/commons/file/FileFactory.java
@@ -328,14 +328,15 @@ private static void updateArchiveFormatProviderArray() {
* @param filename an archive filename that potentially matches one of the registered ArchiveFormatProvider
* @return the first ArchiveFormatProvider
that matches the specified filename, null
if there is none
*/
- public static ArchiveFormatProvider getArchiveFormatProvider(String filename) {
+ private static ArchiveFormatProvider getArchiveFormatProvider(String filename) {
if (filename == null || archiveFormatProviders == null) {
return null;
}
for (ArchiveFormatProvider provider : archiveFormatProviders) {
- if (provider.getFilenameFilter().accept(filename))
+ if (provider != null && provider.getFilenameFilter() != null && provider.getFilenameFilter().accept(filename)) {
return provider;
+ }
}
return null;
}
diff --git a/src/main/com/mucommander/commons/file/icon/impl/SwingFileIconProviderImpl.java b/src/main/com/mucommander/commons/file/icon/impl/SwingFileIconProviderImpl.java
index 4f61b523a..125f31af5 100644
--- a/src/main/com/mucommander/commons/file/icon/impl/SwingFileIconProviderImpl.java
+++ b/src/main/com/mucommander/commons/file/icon/impl/SwingFileIconProviderImpl.java
@@ -60,10 +60,10 @@ class SwingFileIconProviderImpl extends LocalFileIconProvider implements Cacheab
private static JFileChooser fileChooser;
/** Caches icons for directories, used only for non-local files */
- protected static IconCache directoryIconCache = CachedFileIconProvider.createCache();
+ private static IconCache directoryIconCache = CachedFileIconProvider.createCache();
/** Caches icons for regular files, used only for non-local files */
- protected static IconCache fileIconCache = CachedFileIconProvider.createCache();
+ private static IconCache fileIconCache = CachedFileIconProvider.createCache();
/** True if init has been called */
protected static boolean initialized;
@@ -72,10 +72,10 @@ class SwingFileIconProviderImpl extends LocalFileIconProvider implements Cacheab
private final static String SYMLINK_ICON_NAME = "link.png";
/** Icon that is painted over a symlink's target file icon to symbolize a symlink to the target file. */
- protected static ImageIcon SYMLINK_OVERLAY_ICON;
+ private static ImageIcon SYMLINK_OVERLAY_ICON;
/** Allows stderr to be 'silenced' when needed */
- protected static SilenceableOutputStream errOut;
+ private static SilenceableOutputStream errOut;
diff --git a/src/main/com/mucommander/ui/main/table/CellLabel.java b/src/main/com/mucommander/ui/main/table/CellLabel.java
index 79aa19d96..1d952bf1d 100644
--- a/src/main/com/mucommander/ui/main/table/CellLabel.java
+++ b/src/main/com/mucommander/ui/main/table/CellLabel.java
@@ -69,24 +69,26 @@ public class CellLabel extends JLabel {
// - Instance fields -----------------------------------------------------------------
// -----------------------------------------------------------------------------------
/** Last text set by the setText method */
- protected String lastText;
+ private String lastText;
/** Last icon set by the setIcon method */
- protected ImageIcon lastIcon;
+ private ImageIcon lastIcon;
/** Last tooltip text set by the setToolTipText method */
- protected String lastTooltip;
+ private String lastTooltip;
/** Last foreground color set by the setForeground method */
- protected Color lastForegroundColor;
+ private Color lastForegroundColor;
/** Last background color set by the setBackground method */
- protected Color lastBackgroundColor;
+ private Color lastBackgroundColor;
/** Outline color (top and bottom). */
protected Color outlineColor;
/** Gradient color for the background. */
- protected Color gradientColor;
+ private Color gradientColor;
- protected boolean hasSeparatorLine;
+ private boolean hasSeparatorLine;
private int progressValue;
+ private Color markerColor;
+
// - Initialisation ------------------------------------------------------------------
// -----------------------------------------------------------------------------------
@@ -245,9 +247,9 @@ public void setupText(String text, int maxWidth) {
*/
@Override
public void paint(Graphics g) {
- boolean doOutline;
-
- doOutline = outlineColor != null && !outlineColor.equals(lastBackgroundColor);
+ boolean doOutline = outlineColor != null && !outlineColor.equals(lastBackgroundColor);
+ final int w = getWidth();
+ final int h = getHeight();
// Checks whether we need to paint a gradient background.
if (gradientColor != null) {
@@ -259,33 +261,42 @@ public void paint(Graphics g) {
// TODO avoid object creation in paint methods
g2.setPaint(new GradientPaint(0, 0, lastBackgroundColor, 0, getHeight(), gradientColor, false));
if (doOutline) {
- g2.fillRect(0, 1, getWidth(), getHeight() - 2);
+ g2.fillRect(0, 1, w, h - 2);
} else {
- g2.fillRect(0, 0, getWidth(), getHeight());
+ g2.fillRect(0, 0, w, h);
}
// Restores the graphics to its previous state.
g2.setPaint(oldPaint);
}
- // Normal painting.
- super.paint(g);
+ if (markerColor != null) {
+ setSize(w - h, h);
+ super.paint(g);
+ setSize(w, h);
+ if (gradientColor == null) {
+ g.setColor(lastBackgroundColor);
+ g.fillRect(w - h, 1, h, h - 2);
+ }
+ g.setColor(markerColor);
+ g.fillArc(w - h, h/6, h*2/3, h*2/3, 0, 360);
+ } else {
+ // Normal painting
+ super.paint(g);
+ }
// If necessary, paints the outline color.
if (doOutline) {
paintOutline(g);
}
if (hasSeparatorLine) {
- int w = getWidth()-1;
Graphics2D g2d = (Graphics2D)g;
g2d.setColor(Color.GRAY);
g2d.setStroke(DASHED_STROKE);
- g2d.drawLine(w, 0, w, getHeight());
+ g2d.drawLine(w-1, 0, w-1, getHeight());
}
// TODO improve it
if (progressValue > 0) {
- int w = getWidth();
- int h = getHeight();
int a = -progressValue*20 % 360;
int r = h - 4;
if (r % 2 != 0) {
@@ -302,7 +313,7 @@ public void paint(Graphics g) {
g.fillOval(w - r + d, 2 + d, r2, r2);
//g.fillArc(w - r + d, 2 + d, r2, r2, a+100, 200);
}
- }
+ }
protected void paintOutline(Graphics g) {
g.setColor(outlineColor);
@@ -395,4 +406,12 @@ public void setProgressValue(int progressValue) {
this.progressValue = progressValue;
}
+ /**
+ * Set label color (Mac OS X only)
+ * @param markerColor color or null if file has no label
+ */
+ public void setMarkerColor(Color markerColor) {
+ this.markerColor = markerColor;
+ }
+
}
diff --git a/src/main/com/mucommander/ui/main/table/views/BaseCellRenderer.java b/src/main/com/mucommander/ui/main/table/views/BaseCellRenderer.java
index 45945b3ca..401384cce 100644
--- a/src/main/com/mucommander/ui/main/table/views/BaseCellRenderer.java
+++ b/src/main/com/mucommander/ui/main/table/views/BaseCellRenderer.java
@@ -90,8 +90,6 @@ public static Font getCellFont() {
}
-
-
/**
* Sets CellLabels' font to the current one.
*/
diff --git a/src/main/com/mucommander/ui/main/table/views/full/FileTableCellRenderer.java b/src/main/com/mucommander/ui/main/table/views/full/FileTableCellRenderer.java
index 34e654c47..4cbda6fa8 100644
--- a/src/main/com/mucommander/ui/main/table/views/full/FileTableCellRenderer.java
+++ b/src/main/com/mucommander/ui/main/table/views/full/FileTableCellRenderer.java
@@ -31,6 +31,7 @@
import com.mucommander.ui.quicksearch.QuickSearch;
import com.mucommander.ui.theme.*;
import com.mucommander.utils.FileIconsCache;
+import ru.trolsoft.macosx.FileLabelCache;
import javax.swing.*;
import javax.swing.table.TableColumn;
@@ -210,6 +211,12 @@ public Component getTableCellRendererComponent(JTable table, Object value, boole
label.setOutline(null);
}
+ if (column == Column.NAME) {
+ label.setMarkerColor(FileLabelCache.getInstance().getLabelColor(file));
+ } else {
+ label.setMarkerColor(null);
+ }
+
return label;
}
diff --git a/src/main/com/mucommander/utils/FileIconsCache.java b/src/main/com/mucommander/utils/FileIconsCache.java
index 2a07920ff..affc45a1d 100644
--- a/src/main/com/mucommander/utils/FileIconsCache.java
+++ b/src/main/com/mucommander/utils/FileIconsCache.java
@@ -100,7 +100,6 @@ public Icon getIcon(String path) {
public Image getImageIcon(AbstractFile file) {
Icon icon = getIcon(file);
-System.out.println("> " + icon.getClass().getName());
if (icon instanceof RetinaImageIcon) {
return ((RetinaImageIcon) icon).getImage();
} else if (icon instanceof ImageIcon) {
diff --git a/src/main/ru/trolsoft/macosx/FileLabelCache.java b/src/main/ru/trolsoft/macosx/FileLabelCache.java
new file mode 100644
index 000000000..32ae92e61
--- /dev/null
+++ b/src/main/ru/trolsoft/macosx/FileLabelCache.java
@@ -0,0 +1,103 @@
+/*
+ * This file is part of trolCommander, http://www.trolsoft.ru/en/soft/trolcommander
+ * Copyright (C) 2013-2016 Oleg Trifonov
+ *
+ * trolCommander is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * trolCommander is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+package ru.trolsoft.macosx;
+
+import ch.randelshofer.quaqua.osx.OSXFile;
+import com.mucommander.commons.file.AbstractFile;
+import com.mucommander.commons.file.impl.CachedFile;
+import com.mucommander.commons.file.impl.local.LocalFile;
+import com.mucommander.commons.runtime.OsFamily;
+import com.mucommander.utils.FileIconsCache;
+
+import java.awt.*;
+import java.io.File;
+import java.util.HashMap;
+import java.util.LinkedList;
+import java.util.Map;
+
+/**
+ * Created on 27/12/16.
+ * @author Oleg Trifonov
+ */
+public class FileLabelCache {
+
+ private static final int DEFAULT_SIZE = 100;
+
+ private static FileLabelCache instance;
+ private final Map colors = new HashMap<>();
+ private final LinkedList files = new LinkedList<>();
+ private int size = DEFAULT_SIZE;
+
+ public static FileLabelCache getInstance() {
+ if (instance == null) {
+ synchronized (FileIconsCache.class) {
+ if (instance == null) {
+ if (OsFamily.getCurrent() == OsFamily.MAC_OS_X) {
+ instance = new FileLabelCache();
+ } else {
+ instance = new FileLabelCache() {
+ @Override
+ public Color getLabelColor(AbstractFile file) {
+ return null;
+ }
+ };
+ }
+ }
+ }
+ }
+ return instance;
+ }
+
+
+ public Color getLabelColor(AbstractFile file) {
+ String path = file.getAbsolutePath();
+ Color result = colors.get(path);
+ if (result != null) {
+ // move record to top
+ files.remove(path);
+ files.addFirst(file);
+ return result;
+ }
+ return addColor(file);
+ }
+
+ private Color addColor(AbstractFile file) {
+ Color color = getFileLabel(file);
+ colors.put(file, color);
+ files.addFirst(file);
+
+ // remove oldest record if the cache is full
+ if (files.size() > size) {
+ colors.remove(files.removeLast());
+ }
+ return color;
+ }
+
+ private Color getFileLabel(AbstractFile file) {
+ if (file instanceof CachedFile) {
+ file = ((CachedFile) file).getProxiedFile();
+ }
+ if (file instanceof LocalFile) {
+ File f = (File) file.getUnderlyingFileObject();
+ return OSXFile.getLabelColor(OSXFile.getLabel(f), 0);
+ } else {
+ return null;
+ }
+ }
+
+}