Skip to content

Commit

Permalink
Minor code refactoring.
Browse files Browse the repository at this point in the history
  • Loading branch information
chrtannus committed Sep 10, 2018
1 parent 8ef30a3 commit 1fcb29d
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 26 deletions.
Expand Up @@ -27,21 +27,20 @@ public class JobStatusBar extends JPanel implements StatusBarPanelFactory {

public static final String TASK_HISTORY_CLICK = "job-status-click";

private static final int CLEAR_DELAY_MS = 5000;

public static final String ICON_RUNNING = IconManager.ICON_HOURGLASS_1;
public static final String ICON_WARN = IconManager.ICON_EXCLAMATION_TRIANGLE;
public static final String ICON_ERROR = IconManager.ICON_MINUS_CIRCLE;
public static final String ICON_CANCELLED = IconManager.ICON_BAN;
public static final String ICON_FINISHED = IconManager.ICON_CLOUD_DOWNLOAD;
public static final String ICON_JOBS = IconManager.ICON_CLOUD;

public static enum JobsIcon {
RUNNING(ICON_RUNNING),
WARN(ICON_WARN),
ERROR(ICON_ERROR),
CANCELLED(ICON_CANCELLED),
FINISHED(ICON_FINISHED),
JOBS(IconManager.ICON_CLOUD);
JOBS(ICON_JOBS);

private final String text;

Expand Down Expand Up @@ -117,10 +116,12 @@ public void updateIcon(Collection<CyJobStatus> values) {
if (values != null && values.size() > 0) {
for (CyJobStatus status: values) {
CyJobStatus.Status jobStatus = status.getStatus();

if (jobStatus.equals(CyJobStatus.Status.FINISHED)) {
icon = JobsIcon.FINISHED;
break;
}

if (jobStatus.equals(CyJobStatus.Status.ERROR) ||
jobStatus.equals(CyJobStatus.Status.FAILED)) {
icon = JobsIcon.ERROR;
Expand All @@ -147,12 +148,7 @@ public void updateIcon(Collection<CyJobStatus> values) {

public void setIcon(final JobsIcon icon) {
if (!SwingUtilities.isEventDispatchThread()) {
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
setIcon(icon);
}
});
SwingUtilities.invokeLater(() -> setIcon(icon));
return;
}

Expand All @@ -179,12 +175,10 @@ else if (text.equals(IconManager.ICON_HOURGLASS_3))
showBtn.setForeground(iconColor);
currentStatus = icon;
}

}

@Override
public JPanel createTaskStatusPanel() {
return this;
}

}
Expand Up @@ -2,9 +2,9 @@

import static javax.swing.GroupLayout.DEFAULT_SIZE;
import static javax.swing.GroupLayout.PREFERRED_SIZE;
import static org.cytoscape.util.swing.LookAndFeelUtil.makeSmall;

import java.awt.Color;
import java.awt.Font;
import java.awt.Graphics2D;
import java.awt.RenderingHints;
import java.awt.image.BufferedImage;
Expand All @@ -14,7 +14,6 @@
import javax.swing.Icon;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JComponent;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JToggleButton;
Expand Down Expand Up @@ -215,14 +214,4 @@ private void updateMemStatus() {

memAmountLabel.setText(String.format("%.1f%% used of %s", memUsed * 100.0f, memTotalFmt));
}

private static void makeSmall(final JComponent component) {
if (LookAndFeelUtil.isAquaLAF()) {
component.putClientProperty("JComponent.sizeVariant", "small");
} else {
final Font font = component.getFont();
final Font newFont = new Font(font.getFontName(), font.getStyle(), (int)LookAndFeelUtil.getSmallFontSize());
component.setFont(newFont);
}
}
}
Expand Up @@ -65,7 +65,7 @@ public final class GUIDefaults {
public static final String ICON_FINISHED = IconManager.ICON_CHECK;

public static enum TaskIcon {
INFO(ICON_WARN),
INFO(ICON_INFO),
WARN(ICON_WARN),
ERROR(ICON_ERROR),
CANCELLED(ICON_CANCELLED),
Expand Down
Expand Up @@ -132,7 +132,7 @@ public void setTitle(final FinishStatus.Type finishType, final String title) {
}
}

this.setTitle(type, icon, title);
setTitle(type, icon, title);
}

public void setTitle(final Level level, final String title) {
Expand All @@ -156,7 +156,7 @@ public void setTitle(final Level level, final String title) {
}
}

this.setTitle(type, icon, title);
setTitle(type, icon, title);
}

public void setTitle(final String type, final TaskIcon icon, final String title) {
Expand Down

0 comments on commit 1fcb29d

Please sign in to comment.