mirror of
https://github.com/mitb-archive/filebot
synced 2024-08-13 17:03:45 -04:00
* rename panel file list will now display file name and file type
* some minor refactoring
This commit is contained in:
parent
94290d46a0
commit
a1b118d0f6
@ -31,16 +31,6 @@ public class FileFormat {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static String formatName(File file) {
|
|
||||||
String name = file.getName();
|
|
||||||
|
|
||||||
if (file.isDirectory())
|
|
||||||
return name;
|
|
||||||
|
|
||||||
return getNameWithoutExtension(name);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public static String formatNumberOfFiles(int n) {
|
public static String formatNumberOfFiles(int n) {
|
||||||
if (n == 1)
|
if (n == 1)
|
||||||
return n + " file";
|
return n + " file";
|
||||||
@ -50,7 +40,7 @@ public class FileFormat {
|
|||||||
|
|
||||||
|
|
||||||
public static boolean hasExtension(File file, String... extensions) {
|
public static boolean hasExtension(File file, String... extensions) {
|
||||||
if (!file.isFile())
|
if (file.isDirectory())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
String extension = getExtension(file);
|
String extension = getExtension(file);
|
||||||
@ -70,10 +60,14 @@ public class FileFormat {
|
|||||||
|
|
||||||
|
|
||||||
public static String getExtension(File file, boolean includeDot) {
|
public static String getExtension(File file, boolean includeDot) {
|
||||||
String name = file.getName();
|
return getExtension(file.getName(), includeDot);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static String getExtension(String name, boolean includeDot) {
|
||||||
int dotIndex = name.lastIndexOf(".");
|
int dotIndex = name.lastIndexOf(".");
|
||||||
|
|
||||||
// .config -> no extension
|
// .config -> no extension, just hidden
|
||||||
if (dotIndex >= 1) {
|
if (dotIndex >= 1) {
|
||||||
int startIndex = dotIndex;
|
int startIndex = dotIndex;
|
||||||
|
|
||||||
@ -99,15 +93,15 @@ public class FileFormat {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static String getNameWithoutExtension(File file) {
|
public static String getFileName(File file) {
|
||||||
|
if (file.isDirectory())
|
||||||
|
return getFolderName(file);
|
||||||
|
|
||||||
return getNameWithoutExtension(file.getName());
|
return getNameWithoutExtension(file.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static String getName(File file) {
|
public static String getFolderName(File file) {
|
||||||
if (file == null)
|
|
||||||
return "";
|
|
||||||
|
|
||||||
String name = file.getName();
|
String name = file.getName();
|
||||||
|
|
||||||
if (!name.isEmpty())
|
if (!name.isEmpty())
|
||||||
@ -117,4 +111,23 @@ public class FileFormat {
|
|||||||
return file.toString();
|
return file.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static String getFileType(File file) {
|
||||||
|
if (file.isDirectory())
|
||||||
|
return "Folder";
|
||||||
|
|
||||||
|
return getFileType(file.getName());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static String getFileType(String name) {
|
||||||
|
String extension = getExtension(name, false);
|
||||||
|
|
||||||
|
if (!extension.isEmpty())
|
||||||
|
return extension;
|
||||||
|
|
||||||
|
// some file with no suffix
|
||||||
|
return "File";
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -49,7 +49,7 @@ class FileBotPanelSelectionList extends JList {
|
|||||||
private class PanelCellRenderer extends DefaultFancyListCellRenderer {
|
private class PanelCellRenderer extends DefaultFancyListCellRenderer {
|
||||||
|
|
||||||
public PanelCellRenderer() {
|
public PanelCellRenderer() {
|
||||||
super(BorderLayout.CENTER, 10, 0, Color.decode("#163264"));
|
super(BorderLayout.CENTER, 10, 0, new Color(0x163264));
|
||||||
|
|
||||||
setHighlightingEnabled(false);
|
setHighlightingEnabled(false);
|
||||||
|
|
||||||
|
@ -41,7 +41,7 @@ class FileListTransferablePolicy extends FileTransferablePolicy {
|
|||||||
@Override
|
@Override
|
||||||
protected void load(List<File> files) {
|
protected void load(List<File> files) {
|
||||||
if (files.size() > 1) {
|
if (files.size() > 1) {
|
||||||
list.setTitle(FileFormat.getName(files.get(0).getParentFile()));
|
list.setTitle(FileFormat.getFolderName(files.get(0).getParentFile()));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (FileBotUtil.containsOnlyFolders(files)) {
|
if (FileBotUtil.containsOnlyFolders(files)) {
|
||||||
@ -56,12 +56,12 @@ class FileListTransferablePolicy extends FileTransferablePolicy {
|
|||||||
|
|
||||||
private void loadFolderList(List<File> folders) {
|
private void loadFolderList(List<File> folders) {
|
||||||
if (folders.size() == 1) {
|
if (folders.size() == 1) {
|
||||||
list.setTitle(FileFormat.getName(folders.get(0)));
|
list.setTitle(FileFormat.getFolderName(folders.get(0)));
|
||||||
}
|
}
|
||||||
|
|
||||||
for (File folder : folders) {
|
for (File folder : folders) {
|
||||||
for (File file : folder.listFiles()) {
|
for (File file : folder.listFiles()) {
|
||||||
list.getModel().add(FileFormat.formatName(file));
|
list.getModel().add(FileFormat.getFolderName(file));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -93,7 +93,7 @@ class FileListTransferablePolicy extends FileTransferablePolicy {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void load(File file) {
|
protected void load(File file) {
|
||||||
list.getModel().add(FileFormat.formatName(file));
|
list.getModel().add(FileFormat.getFileName(file));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -2,12 +2,24 @@
|
|||||||
package net.sourceforge.filebot.ui.panel.rename;
|
package net.sourceforge.filebot.ui.panel.rename;
|
||||||
|
|
||||||
|
|
||||||
|
import java.awt.AlphaComposite;
|
||||||
import java.awt.Color;
|
import java.awt.Color;
|
||||||
|
import java.awt.Graphics;
|
||||||
|
import java.awt.Graphics2D;
|
||||||
|
import java.awt.Insets;
|
||||||
|
import java.awt.RenderingHints;
|
||||||
|
import java.awt.geom.Rectangle2D;
|
||||||
|
import java.awt.geom.RoundRectangle2D;
|
||||||
|
|
||||||
|
import javax.swing.Box;
|
||||||
|
import javax.swing.BoxLayout;
|
||||||
import javax.swing.JLabel;
|
import javax.swing.JLabel;
|
||||||
import javax.swing.JList;
|
import javax.swing.JList;
|
||||||
import javax.swing.ListModel;
|
import javax.swing.ListModel;
|
||||||
|
import javax.swing.border.CompoundBorder;
|
||||||
|
import javax.swing.border.EmptyBorder;
|
||||||
|
|
||||||
|
import net.sourceforge.filebot.ui.panel.rename.entry.AbstractFileEntry;
|
||||||
import net.sourceforge.tuned.ui.DefaultFancyListCellRenderer;
|
import net.sourceforge.tuned.ui.DefaultFancyListCellRenderer;
|
||||||
|
|
||||||
|
|
||||||
@ -16,7 +28,7 @@ class RenameListCellRenderer extends DefaultFancyListCellRenderer {
|
|||||||
private final ListModel names;
|
private final ListModel names;
|
||||||
private final ListModel files;
|
private final ListModel files;
|
||||||
|
|
||||||
private final JLabel extension = new JLabel(".png");
|
private final ExtensionLabel extension = new ExtensionLabel();
|
||||||
|
|
||||||
|
|
||||||
public RenameListCellRenderer(ListModel names, ListModel files) {
|
public RenameListCellRenderer(ListModel names, ListModel files) {
|
||||||
@ -25,23 +37,36 @@ class RenameListCellRenderer extends DefaultFancyListCellRenderer {
|
|||||||
|
|
||||||
setHighlightingEnabled(false);
|
setHighlightingEnabled(false);
|
||||||
|
|
||||||
this.add(extension);
|
setLayout(new BoxLayout(this, BoxLayout.X_AXIS));
|
||||||
|
add(Box.createHorizontalGlue());
|
||||||
|
add(extension);
|
||||||
}
|
}
|
||||||
|
|
||||||
private final Color noMatchGradientBeginColor = Color.decode("#B7B7B7");
|
private final Color noMatchGradientBeginColor = new Color(0xB7B7B7);
|
||||||
private final Color noMatchGradientEndColor = Color.decode("#9A9A9A");
|
private final Color noMatchGradientEndColor = new Color(0x9A9A9A);
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void configureListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
|
public void configureListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
|
||||||
super.configureListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
|
super.configureListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
|
||||||
|
|
||||||
|
if ((list.getModel() == files) && (value instanceof AbstractFileEntry<?>)) {
|
||||||
|
AbstractFileEntry<?> entry = (AbstractFileEntry<?>) value;
|
||||||
|
|
||||||
|
extension.setText(entry.getType());
|
||||||
|
extension.setVisible(true);
|
||||||
|
} else {
|
||||||
|
extension.setVisible(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
extension.setAlpha(1.0f);
|
||||||
|
|
||||||
if (index >= getMinLength()) {
|
if (index >= getMinLength()) {
|
||||||
if (isSelected) {
|
if (isSelected) {
|
||||||
setForeground(Color.WHITE);
|
|
||||||
setGradientColors(noMatchGradientBeginColor, noMatchGradientEndColor);
|
setGradientColors(noMatchGradientBeginColor, noMatchGradientEndColor);
|
||||||
} else {
|
} else {
|
||||||
setForeground(noMatchGradientBeginColor);
|
setForeground(noMatchGradientBeginColor);
|
||||||
|
extension.setAlpha(0.5f);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -57,4 +82,52 @@ class RenameListCellRenderer extends DefaultFancyListCellRenderer {
|
|||||||
return Math.min(n1, n2);
|
return Math.min(n1, n2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private class ExtensionLabel extends JLabel {
|
||||||
|
|
||||||
|
private final Insets margin = new Insets(0, 10, 0, 0);
|
||||||
|
private final Insets padding = new Insets(1, 6, 1, 5);
|
||||||
|
private final int arc = 10;
|
||||||
|
|
||||||
|
private Color gradientBeginColor = new Color(0xFFCC00);
|
||||||
|
private Color gradientEndColor = new Color(0xFF9900);
|
||||||
|
|
||||||
|
private float alpha = 1.0f;
|
||||||
|
|
||||||
|
|
||||||
|
public ExtensionLabel() {
|
||||||
|
setOpaque(false);
|
||||||
|
setForeground(new Color(42, 42, 42));
|
||||||
|
|
||||||
|
setBorder(new CompoundBorder(new EmptyBorder(margin), new EmptyBorder(padding)));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void paintComponent(Graphics g) {
|
||||||
|
Graphics2D g2d = (Graphics2D) g;
|
||||||
|
|
||||||
|
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
|
||||||
|
|
||||||
|
RoundRectangle2D shape = new RoundRectangle2D.Float(margin.left, margin.top, getWidth() - (margin.left + margin.right), getHeight(), arc, arc);
|
||||||
|
|
||||||
|
g2d.setComposite(AlphaComposite.SrcOver.derive(alpha));
|
||||||
|
|
||||||
|
g2d.setPaint(getGradientStyle().getGradientPaint(shape, gradientBeginColor, gradientEndColor));
|
||||||
|
g2d.fill(shape);
|
||||||
|
|
||||||
|
g2d.setFont(getFont());
|
||||||
|
g2d.setPaint(getForeground());
|
||||||
|
|
||||||
|
Rectangle2D textBounds = g2d.getFontMetrics().getStringBounds(getText(), g2d);
|
||||||
|
|
||||||
|
g2d.drawString(getText(), (float) (shape.getCenterX() - textBounds.getX() - (textBounds.getWidth() / 2f)), (float) (shape.getCenterY() - textBounds.getY() - (textBounds.getHeight() / 2)));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void setAlpha(float alpha) {
|
||||||
|
this.alpha = alpha;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -9,11 +9,11 @@ import javax.swing.event.ListSelectionListener;
|
|||||||
|
|
||||||
class SelectionSynchronizer {
|
class SelectionSynchronizer {
|
||||||
|
|
||||||
private JList list1;
|
private final JList list1;
|
||||||
private JList list2;
|
private final JList list2;
|
||||||
|
|
||||||
private SelectionSynchronizeListener selectionSynchronizeListener1;
|
private final SelectionSynchronizeListener selectionSynchronizeListener1;
|
||||||
private SelectionSynchronizeListener selectionSynchronizeListener2;
|
private final SelectionSynchronizeListener selectionSynchronizeListener2;
|
||||||
|
|
||||||
|
|
||||||
public SelectionSynchronizer(JList list1, JList list2) {
|
public SelectionSynchronizer(JList list1, JList list2) {
|
||||||
@ -45,8 +45,8 @@ class SelectionSynchronizer {
|
|||||||
private JList target;
|
private JList target;
|
||||||
|
|
||||||
|
|
||||||
public SelectionSynchronizeListener(JList to) {
|
public SelectionSynchronizeListener(JList target) {
|
||||||
this.target = to;
|
this.target = target;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -40,7 +40,7 @@ class SimilarityPanel extends Box {
|
|||||||
|
|
||||||
private Border labelMarginBorder = BorderFactory.createEmptyBorder(0, 3, 0, 0);
|
private Border labelMarginBorder = BorderFactory.createEmptyBorder(0, 3, 0, 0);
|
||||||
|
|
||||||
private Border separatorBorder = new SeparatorBorder(1, Color.decode("#ACA899"), SeparatorBorder.Position.TOP);
|
private Border separatorBorder = new SeparatorBorder(1, new Color(0xACA899), SeparatorBorder.Position.TOP);
|
||||||
|
|
||||||
|
|
||||||
public SimilarityPanel(JList nameList, JList fileList) {
|
public SimilarityPanel(JList nameList, JList fileList) {
|
||||||
|
@ -53,7 +53,7 @@ public class ValidateNamesDialog extends JDialog {
|
|||||||
JList list = new JList(new SimpleListModel(entries));
|
JList list = new JList(new SimpleListModel(entries));
|
||||||
list.setEnabled(false);
|
list.setEnabled(false);
|
||||||
|
|
||||||
list.setCellRenderer(new HighlightListCellRenderer(FileBotUtil.INVALID_CHARACTERS_PATTERN, new CharacterHighlightPainter(Color.decode("#FF4200"), Color.decode("#FF1200")), 4));
|
list.setCellRenderer(new HighlightListCellRenderer(FileBotUtil.INVALID_CHARACTERS_PATTERN, new CharacterHighlightPainter(new Color(0xFF4200), new Color(0xFF1200)), 4));
|
||||||
|
|
||||||
JLabel label = new JLabel("Some names contain invalid characters:");
|
JLabel label = new JLabel("Some names contain invalid characters:");
|
||||||
|
|
||||||
|
@ -11,11 +11,11 @@ import javax.swing.event.ChangeListener;
|
|||||||
|
|
||||||
class ViewPortSynchronizer {
|
class ViewPortSynchronizer {
|
||||||
|
|
||||||
private JViewport viewport1;
|
private final JViewport viewport1;
|
||||||
private JViewport viewport2;
|
private final JViewport viewport2;
|
||||||
|
|
||||||
private ViewPortSynchronizeListener viewPortSynchronizeListener1;
|
private final ViewPortSynchronizeListener viewPortSynchronizeListener1;
|
||||||
private ViewPortSynchronizeListener viewPortSynchronizeListener2;
|
private final ViewPortSynchronizeListener viewPortSynchronizeListener2;
|
||||||
|
|
||||||
|
|
||||||
public ViewPortSynchronizer(JViewport viewport1, JViewport viewport2) {
|
public ViewPortSynchronizer(JViewport viewport1, JViewport viewport2) {
|
||||||
@ -44,7 +44,7 @@ class ViewPortSynchronizer {
|
|||||||
|
|
||||||
private static class ViewPortSynchronizeListener implements ChangeListener {
|
private static class ViewPortSynchronizeListener implements ChangeListener {
|
||||||
|
|
||||||
private JViewport target;
|
private final JViewport target;
|
||||||
|
|
||||||
|
|
||||||
public ViewPortSynchronizeListener(JViewport target) {
|
public ViewPortSynchronizeListener(JViewport target) {
|
||||||
@ -59,11 +59,10 @@ class ViewPortSynchronizer {
|
|||||||
Point viewPosition = source.getViewPosition();
|
Point viewPosition = source.getViewPosition();
|
||||||
|
|
||||||
// return if both viewports have the same view position
|
// return if both viewports have the same view position
|
||||||
if (viewPosition.equals(target.getViewPosition()))
|
if (!viewPosition.equals(target.getViewPosition())) {
|
||||||
return;
|
target.setViewPosition(viewPosition);
|
||||||
|
target.repaint();
|
||||||
target.setViewPosition(viewPosition);
|
}
|
||||||
target.repaint();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,10 +6,13 @@ public abstract class AbstractFileEntry<T> extends ListEntry<T> {
|
|||||||
|
|
||||||
private final long length;
|
private final long length;
|
||||||
|
|
||||||
|
private final String type;
|
||||||
|
|
||||||
public AbstractFileEntry(String name, T value, long length) {
|
|
||||||
|
public AbstractFileEntry(String name, T value, String type, long length) {
|
||||||
super(name, value);
|
super(name, value);
|
||||||
this.length = length;
|
this.length = length;
|
||||||
|
this.type = type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -17,4 +20,9 @@ public abstract class AbstractFileEntry<T> extends ListEntry<T> {
|
|||||||
return length;
|
return length;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public String getType() {
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -10,7 +10,7 @@ import net.sourceforge.filebot.FileFormat;
|
|||||||
public class FileEntry extends AbstractFileEntry<File> {
|
public class FileEntry extends AbstractFileEntry<File> {
|
||||||
|
|
||||||
public FileEntry(File file) {
|
public FileEntry(File file) {
|
||||||
super(FileFormat.formatName(file), file, file.length());
|
super(FileFormat.getFileName(file), file, FileFormat.getFileType(file), file.length());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -10,7 +10,6 @@ import net.sourceforge.filebot.torrent.Torrent.Entry;
|
|||||||
public class TorrentEntry extends AbstractFileEntry<Torrent.Entry> {
|
public class TorrentEntry extends AbstractFileEntry<Torrent.Entry> {
|
||||||
|
|
||||||
public TorrentEntry(Entry value) {
|
public TorrentEntry(Entry value) {
|
||||||
super(FileFormat.getNameWithoutExtension(value.getName()), value, value.getLength());
|
super(FileFormat.getNameWithoutExtension(value.getName()), value, FileFormat.getFileType(value.getName()), value.getLength());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -38,7 +38,7 @@ class ChecksumTableModel extends AbstractTableModel {
|
|||||||
|
|
||||||
if (columnIndex >= checksumColumnsOffset) {
|
if (columnIndex >= checksumColumnsOffset) {
|
||||||
File columnRoot = checksumColumnRoots.get(columnIndex - checksumColumnsOffset);
|
File columnRoot = checksumColumnRoots.get(columnIndex - checksumColumnsOffset);
|
||||||
return FileFormat.getName(columnRoot);
|
return FileFormat.getFolderName(columnRoot);
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
|
@ -110,7 +110,7 @@ public class SfvPanel extends FileBotPanel {
|
|||||||
@Override
|
@Override
|
||||||
protected String convertValueToString(Object value) {
|
protected String convertValueToString(Object value) {
|
||||||
File columnRoot = (File) value;
|
File columnRoot = (File) value;
|
||||||
return FileFormat.getName(columnRoot);
|
return FileFormat.getFolderName(columnRoot);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -125,7 +125,7 @@ public class SfvPanel extends FileBotPanel {
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
index = options.indexOf(selected);
|
index = options.indexOf(selected);
|
||||||
name = FileFormat.getNameWithoutExtension(selected);
|
name = FileFormat.getFileName(selected);
|
||||||
|
|
||||||
if (name.isEmpty())
|
if (name.isEmpty())
|
||||||
name = "name";
|
name = "name";
|
||||||
|
@ -113,7 +113,7 @@ class SfvTable extends JTable implements TransferablePolicySupport, Saveable {
|
|||||||
String name = "";
|
String name = "";
|
||||||
|
|
||||||
if (columnRoot != null)
|
if (columnRoot != null)
|
||||||
name = FileFormat.getNameWithoutExtension(columnRoot);
|
name = FileFormat.getFileName(columnRoot);
|
||||||
|
|
||||||
if (name.isEmpty())
|
if (name.isEmpty())
|
||||||
name = "name";
|
name = "name";
|
||||||
|
@ -1,64 +0,0 @@
|
|||||||
|
|
||||||
package net.sourceforge.tuned;
|
|
||||||
|
|
||||||
|
|
||||||
import java.util.concurrent.BlockingQueue;
|
|
||||||
import java.util.concurrent.ThreadPoolExecutor;
|
|
||||||
import java.util.concurrent.TimeUnit;
|
|
||||||
import java.util.concurrent.locks.Condition;
|
|
||||||
import java.util.concurrent.locks.ReentrantLock;
|
|
||||||
|
|
||||||
|
|
||||||
public class PausableThreadPoolExecutor extends ThreadPoolExecutor {
|
|
||||||
|
|
||||||
private boolean paused;
|
|
||||||
private ReentrantLock pauseLock = new ReentrantLock();
|
|
||||||
private Condition unpaused = pauseLock.newCondition();
|
|
||||||
|
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
public PausableThreadPoolExecutor(int nThreads, BlockingQueue<? extends Runnable> workQueue) {
|
|
||||||
super(nThreads, nThreads, 0, TimeUnit.MILLISECONDS, (BlockingQueue<Runnable>) workQueue);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void beforeExecute(Thread t, Runnable r) {
|
|
||||||
super.beforeExecute(t, r);
|
|
||||||
pauseLock.lock();
|
|
||||||
try {
|
|
||||||
while (paused)
|
|
||||||
unpaused.await();
|
|
||||||
} catch (InterruptedException ie) {
|
|
||||||
t.interrupt();
|
|
||||||
} finally {
|
|
||||||
pauseLock.unlock();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public void pause() {
|
|
||||||
pauseLock.lock();
|
|
||||||
try {
|
|
||||||
paused = true;
|
|
||||||
} finally {
|
|
||||||
pauseLock.unlock();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public void resume() {
|
|
||||||
pauseLock.lock();
|
|
||||||
try {
|
|
||||||
paused = false;
|
|
||||||
unpaused.signalAll();
|
|
||||||
} finally {
|
|
||||||
pauseLock.unlock();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public boolean isPaused() {
|
|
||||||
return paused;
|
|
||||||
}
|
|
||||||
}
|
|
@ -17,25 +17,18 @@ public class DefaultFancyListCellRenderer extends AbstractFancyListCellRenderer
|
|||||||
|
|
||||||
|
|
||||||
public DefaultFancyListCellRenderer() {
|
public DefaultFancyListCellRenderer() {
|
||||||
this.add(label, BorderLayout.WEST);
|
add(label, BorderLayout.WEST);
|
||||||
initializeLabel(BorderLayout.WEST);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public DefaultFancyListCellRenderer(int padding) {
|
public DefaultFancyListCellRenderer(int padding) {
|
||||||
super(new Insets(padding, padding, padding, padding));
|
super(new Insets(padding, padding, padding, padding));
|
||||||
initializeLabel(BorderLayout.WEST);
|
add(label, BorderLayout.WEST);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
protected DefaultFancyListCellRenderer(Object constraint, int padding, int margin, Color selectedBorderColor) {
|
protected DefaultFancyListCellRenderer(Object constraint, int padding, int margin, Color selectedBorderColor) {
|
||||||
super(new Insets(padding, padding, padding, padding), new Insets(margin, margin, margin, margin), selectedBorderColor);
|
super(new Insets(padding, padding, padding, padding), new Insets(margin, margin, margin, margin), selectedBorderColor);
|
||||||
initializeLabel(constraint);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private void initializeLabel(Object constraint) {
|
|
||||||
label.setOpaque(false);
|
|
||||||
add(label, constraint);
|
add(label, constraint);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -44,6 +37,8 @@ public class DefaultFancyListCellRenderer extends AbstractFancyListCellRenderer
|
|||||||
protected void configureListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
|
protected void configureListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
|
||||||
super.configureListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
|
super.configureListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
|
||||||
|
|
||||||
|
label.setOpaque(false);
|
||||||
|
|
||||||
setText(value.toString());
|
setText(value.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -30,11 +30,11 @@ public class SelectButton<T> extends JButton implements ActionListener {
|
|||||||
|
|
||||||
private boolean hover = false;
|
private boolean hover = false;
|
||||||
|
|
||||||
private Color beginColor = Color.decode("#F0EEE4");
|
private Color beginColor = new Color(0xF0EEE4);
|
||||||
private Color endColor = Color.decode("#E0DED4");
|
private Color endColor = new Color(0xE0DED4);
|
||||||
|
|
||||||
private Color beginColorHover = beginColor;
|
private Color beginColorHover = beginColor;
|
||||||
private Color endColorHover = Color.decode("#D8D7CD");
|
private Color endColorHover = new Color(0xD8D7CD);
|
||||||
|
|
||||||
private Entry<T> selectedEntry = null;
|
private Entry<T> selectedEntry = null;
|
||||||
|
|
||||||
|
@ -21,7 +21,7 @@ public class TextFieldWithSelect<T> extends JPanel {
|
|||||||
private SelectButton<T> selectButton;
|
private SelectButton<T> selectButton;
|
||||||
|
|
||||||
private JTextField textfield = new JTextField();
|
private JTextField textfield = new JTextField();
|
||||||
private Color borderColor = Color.decode("#A4A4A4");
|
private Color borderColor = new Color(0xA4A4A4);
|
||||||
|
|
||||||
|
|
||||||
public TextFieldWithSelect(Collection<Entry<T>> options) {
|
public TextFieldWithSelect(Collection<Entry<T>> options) {
|
||||||
|
Loading…
Reference in New Issue
Block a user