You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@netbeans.apache.org by lk...@apache.org on 2020/01/19 01:11:43 UTC
[netbeans] branch master updated: [NETBEANS-3713] FlatLaf: progress
bar improvements - progress bar in status bar now always has large height -
cancel button replaced with vector icon - fixed color of separator in
"Processes" popup - remove separator of last row in "Processes" popup - use
preferred height for progress bars in "Processes" popup
This is an automated email from the ASF dual-hosted git repository.
lkishalmi pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/netbeans.git
The following commit(s) were added to refs/heads/master by this push:
new 9e5cafb [NETBEANS-3713] FlatLaf: progress bar improvements - progress bar in status bar now always has large height - cancel button replaced with vector icon - fixed color of separator in "Processes" popup - remove separator of last row in "Processes" popup - use preferred height for progress bars in "Processes" popup
9e5cafb is described below
commit 9e5cafb440fc655b03fa54f5a263ffc15f0c8f6f
Author: Karl Tauber <ka...@jformdesigner.com>
AuthorDate: Sat Jan 18 23:33:52 2020 +0100
[NETBEANS-3713] FlatLaf: progress bar improvements
- progress bar in status bar now always has large height
- cancel button replaced with vector icon
- fixed color of separator in "Processes" popup
- remove separator of last row in "Processes" popup
- use preferred height for progress bars in "Processes" popup
---
.../netbeans/swing/laf/flatlaf/FlatLFCustoms.java | 5 ++++
platform/progress.ui/nbproject/project.properties | 2 +-
.../modules/progress/ui/AbstractWindowRunner.java | 13 +++++----
.../modules/progress/ui/ListComponent.java | 32 ++++++++++++++++------
.../modules/progress/ui/NbProgressBar.java | 4 +++
.../netbeans/modules/progress/ui/PopupPane.java | 16 +++++++++--
.../modules/progress/ui/StatusLineComponent.java | 18 ++++++------
7 files changed, 61 insertions(+), 29 deletions(-)
diff --git a/platform/o.n.swing.laf.flatlaf/src/org/netbeans/swing/laf/flatlaf/FlatLFCustoms.java b/platform/o.n.swing.laf.flatlaf/src/org/netbeans/swing/laf/flatlaf/FlatLFCustoms.java
index 570feb7..e6d5436 100644
--- a/platform/o.n.swing.laf.flatlaf/src/org/netbeans/swing/laf/flatlaf/FlatLFCustoms.java
+++ b/platform/o.n.swing.laf.flatlaf/src/org/netbeans/swing/laf/flatlaf/FlatLFCustoms.java
@@ -72,6 +72,11 @@ public class FlatLFCustoms extends LFCustoms {
"nb.multitabs.button.right.icon", FlatTabControlIcon.get(TabControlButton.ID_SCROLL_RIGHT_BUTTON), // NOI18N
"nb.multitabs.button.rollover", true, // NOI18N
+ // for module progress.ui
+ "nb.progress.cancel.icon", FlatTabControlIcon.get(TabControlButton.ID_CLOSE_BUTTON, TabControlButton.STATE_DEFAULT), // NOI18N
+ "nb.progress.cancel.icon.pressed", FlatTabControlIcon.get(TabControlButton.ID_CLOSE_BUTTON, TabControlButton.STATE_PRESSED), // NOI18N
+ "nb.progress.cancel.icon.mouseover", FlatTabControlIcon.get(TabControlButton.ID_CLOSE_BUTTON, TabControlButton.STATE_ROLLOVER), // NOI18N
+
// Change some colors from ColorUIResource to Color because they are used as
// background colors for checkboxes (e.g. in org.netbeans.modules.palette.ui.CategoryButton),
// which in FlatLaf paint background only if background color is not a UIResource.
diff --git a/platform/progress.ui/nbproject/project.properties b/platform/progress.ui/nbproject/project.properties
index 94a11b0..50d6a31 100644
--- a/platform/progress.ui/nbproject/project.properties
+++ b/platform/progress.ui/nbproject/project.properties
@@ -18,7 +18,7 @@
# Sample ResourceBundle properties file
is.autoload=true
javac.compilerargs=-Xlint:unchecked
-javac.source=1.6
+javac.source=1.8
javadoc.arch=${basedir}/arch.xml
test.config.stableBTD.includes=**/*Test.class
diff --git a/platform/progress.ui/src/org/netbeans/modules/progress/ui/AbstractWindowRunner.java b/platform/progress.ui/src/org/netbeans/modules/progress/ui/AbstractWindowRunner.java
index 7606967..a33d5c0 100644
--- a/platform/progress.ui/src/org/netbeans/modules/progress/ui/AbstractWindowRunner.java
+++ b/platform/progress.ui/src/org/netbeans/modules/progress/ui/AbstractWindowRunner.java
@@ -42,6 +42,7 @@ import java.util.concurrent.CountDownLatch;
import java.util.concurrent.Future;
import javax.swing.AbstractAction;
import javax.swing.BorderFactory;
+import javax.swing.Icon;
import javax.swing.JButton;
import javax.swing.JComponent;
import javax.swing.JDialog;
@@ -252,21 +253,21 @@ abstract class AbstractWindowRunner<T> extends WindowAdapter implements Runnable
closeButton.setOpaque(false);
closeButton.setContentAreaFilled(false);
- Image img = (Image)UIManager.get("nb.progress.cancel.icon"); //NOI18N
+ Object img = UIManager.get("nb.progress.cancel.icon"); //NOI18N
if( null != img ) {
- closeButton.setIcon( ImageUtilities.image2Icon( img ) );
+ closeButton.setIcon( (img instanceof Icon) ? (Icon) img : ImageUtilities.image2Icon( (Image) img ) );
} else {
closeButton.setText ( NbBundle.getMessage(AbstractWindowRunner.class,
"ModalDialog.btnClose.text")); //NOI18N
}
- img = (Image)UIManager.get("nb.progress.cancel.icon.mouseover"); //NOI18N
+ img = UIManager.get("nb.progress.cancel.icon.mouseover"); //NOI18N
if( null != img ) {
closeButton.setRolloverEnabled(true);
- closeButton.setRolloverIcon( ImageUtilities.image2Icon( img ) );
+ closeButton.setRolloverIcon( (img instanceof Icon) ? (Icon) img : ImageUtilities.image2Icon( (Image) img ) );
}
- img = (Image)UIManager.get("nb.progress.cancel.icon.pressed"); //NOI18N
+ img = UIManager.get("nb.progress.cancel.icon.pressed"); //NOI18N
if( null != img ) {
- closeButton.setPressedIcon( ImageUtilities.image2Icon( img ) ); //NOI18N
+ closeButton.setPressedIcon( (img instanceof Icon) ? (Icon) img : ImageUtilities.image2Icon( (Image) img ) );
}
closeButton.setToolTipText(NbBundle.getMessage(AbstractWindowRunner.class,
"ModalDialog.btnClose.tooltip")); //NOI18N
diff --git a/platform/progress.ui/src/org/netbeans/modules/progress/ui/ListComponent.java b/platform/progress.ui/src/org/netbeans/modules/progress/ui/ListComponent.java
index 8b30594..b4ca8c5 100644
--- a/platform/progress.ui/src/org/netbeans/modules/progress/ui/ListComponent.java
+++ b/platform/progress.ui/src/org/netbeans/modules/progress/ui/ListComponent.java
@@ -34,6 +34,7 @@ import java.awt.event.MouseEvent;
import javax.swing.AbstractAction;
import javax.swing.Action;
import javax.swing.BorderFactory;
+import javax.swing.Icon;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JLabel;
@@ -130,18 +131,18 @@ public class ListComponent extends JPanel {
closeButton.setContentAreaFilled(false);
closeButton.setFocusable(false);
- Image img = (Image)UIManager.get("nb.progress.cancel.icon");
+ Object img = UIManager.get("nb.progress.cancel.icon");
if( null != img ) {
- closeButton.setIcon( new ImageIcon( img ) );
+ closeButton.setIcon( iconOrImage2icon( img ) );
}
- img = (Image)UIManager.get("nb.progress.cancel.icon.mouseover");
+ img = UIManager.get("nb.progress.cancel.icon.mouseover");
if( null != img ) {
closeButton.setRolloverEnabled(true);
- closeButton.setRolloverIcon( new ImageIcon( img ) );
+ closeButton.setRolloverIcon( iconOrImage2icon( img ) );
}
- img = (Image)UIManager.get("nb.progress.cancel.icon.pressed");
+ img = UIManager.get("nb.progress.cancel.icon.pressed");
if( null != img ) {
- closeButton.setPressedIcon( new ImageIcon( img ) );
+ closeButton.setPressedIcon( iconOrImage2icon( img ) );
}
closeButton.setToolTipText(NbBundle.getMessage(ListComponent.class, "ListComponent.btnClose.tooltip"));
@@ -191,6 +192,12 @@ public class ListComponent extends JPanel {
});
}
+
+ static Icon iconOrImage2icon( Object iconOrImage ) {
+ return (iconOrImage instanceof Icon)
+ ? (Icon) iconOrImage
+ : new ImageIcon( (Image) iconOrImage );
+ }
Action getCancelAction() {
@@ -296,12 +303,12 @@ public class ListComponent extends JPanel {
putValue(Action.NAME, NbBundle.getMessage(ListComponent.class, "StatusLineComponent.Cancel"));
putValue(Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 0));
} else {
- Image icon = (Image)UIManager.get("nb.progress.cancel.icon");
+ Object icon = UIManager.get("nb.progress.cancel.icon");
if (icon == null) {
// for custom L&F?
icon = ImageUtilities.loadImage("org/netbeans/progress/module/resources/buton.png");
}
- putValue(Action.SMALL_ICON, new ImageIcon(icon));
+ putValue(Action.SMALL_ICON, iconOrImage2icon(icon));
}
setEnabled(handle == null ? false : handle.isAllowCancel());
}
@@ -395,7 +402,14 @@ public class ListComponent extends JPanel {
}
// have the bar approx 30 percent of the width
int barOffset = offset - (ITEM_WIDTH / 3);
- bar.setBounds(barOffset, UPPERMARGIN, offset - barOffset, mainHeight);
+ int barY = UPPERMARGIN;
+ int barHeight = mainHeight;
+ if (UIManager.getLookAndFeel().getID().startsWith("FlatLaf")) {
+ // use smaller (preferred) height
+ barHeight = bar.getPreferredSize().height;
+ barY += (mainHeight - barHeight) / 2;
+ }
+ bar.setBounds(barOffset, barY, offset - barOffset, barHeight);
mainLabel.setBounds(LEFTMARGIN, UPPERMARGIN, barOffset - LEFTMARGIN, mainHeight);
dynaLabel.setBounds(LEFTMARGIN, mainHeight + UPPERMARGIN + BETWEENTEXTMARGIN,
parentWidth - LEFTMARGIN, dynaHeight);
diff --git a/platform/progress.ui/src/org/netbeans/modules/progress/ui/NbProgressBar.java b/platform/progress.ui/src/org/netbeans/modules/progress/ui/NbProgressBar.java
index c1d9ea4..90ad1ae 100644
--- a/platform/progress.ui/src/org/netbeans/modules/progress/ui/NbProgressBar.java
+++ b/platform/progress.ui/src/org/netbeans/modules/progress/ui/NbProgressBar.java
@@ -62,6 +62,10 @@ public class NbProgressBar extends JProgressBar implements ExtractedProgressUIWo
public void setUseInStatusBar(boolean use) {
usedInStatusBar = use;
+
+ if (UIManager.getLookAndFeel().getID().startsWith("FlatLaf")) { //NOI18N
+ putClientProperty("JProgressBar.largeHeight", use ? true : null); //NOI18N
+ }
}
public Dimension getPreferredSize() {
diff --git a/platform/progress.ui/src/org/netbeans/modules/progress/ui/PopupPane.java b/platform/progress.ui/src/org/netbeans/modules/progress/ui/PopupPane.java
index ef0c342..902594a 100644
--- a/platform/progress.ui/src/org/netbeans/modules/progress/ui/PopupPane.java
+++ b/platform/progress.ui/src/org/netbeans/modules/progress/ui/PopupPane.java
@@ -38,9 +38,9 @@ import javax.swing.JComponent;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.KeyStroke;
+import javax.swing.UIManager;
import javax.swing.border.Border;
import org.netbeans.modules.progress.spi.InternalHandle;
-import org.netbeans.modules.progress.spi.UIInternalHandle;
import org.openide.util.Mutex;
/**
@@ -119,6 +119,11 @@ public class PopupPane extends JScrollPane {
break;
}
}
+ if (view.getComponentCount() > 0) {
+ // remove bottom border from last component
+ JComponent last = (JComponent)view.getComponent(view.getComponentCount() - 1);
+ last.setBorder(null);
+ }
if (listComponents.size() > 3) {
setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
} else {
@@ -155,9 +160,14 @@ public class PopupPane extends JScrollPane {
private static class BottomLineBorder implements Border {
private Insets ins = new Insets(0, 0, 1, 0);
- private Color col = new Color(221, 229, 248);
+ private Color col;
- public BottomLineBorder () {}
+ public BottomLineBorder () {
+ col = UIManager.getColor("Separator.foreground"); // NOI18N
+ if (col == null) {
+ col = new Color(221, 229, 248);
+ }
+ }
public @Override Insets getBorderInsets(Component c) {
return ins;
diff --git a/platform/progress.ui/src/org/netbeans/modules/progress/ui/StatusLineComponent.java b/platform/progress.ui/src/org/netbeans/modules/progress/ui/StatusLineComponent.java
index b5c4c05..4a701f1 100644
--- a/platform/progress.ui/src/org/netbeans/modules/progress/ui/StatusLineComponent.java
+++ b/platform/progress.ui/src/org/netbeans/modules/progress/ui/StatusLineComponent.java
@@ -28,7 +28,6 @@ import java.awt.FlowLayout;
import java.awt.Frame;
import java.awt.Graphics;
import java.awt.GraphicsEnvironment;
-import java.awt.Image;
import java.awt.Point;
import java.awt.Rectangle;
import java.awt.Toolkit;
@@ -48,7 +47,6 @@ import javax.swing.AbstractAction;
import javax.swing.Action;
import javax.swing.BorderFactory;
import javax.swing.Icon;
-import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JComponent;
import javax.swing.JLabel;
@@ -191,18 +189,18 @@ public class StatusLineComponent extends JPanel implements ProgressUIWorkerWithM
closeButton.setOpaque(false);
closeButton.setContentAreaFilled(false);
- Image img = (Image)UIManager.get("nb.progress.cancel.icon");
+ Object img = UIManager.get("nb.progress.cancel.icon");
if( null != img ) {
- closeButton.setIcon( new ImageIcon( img ) );
+ closeButton.setIcon( ListComponent.iconOrImage2icon( img ) );
}
- img = (Image)UIManager.get("nb.progress.cancel.icon.mouseover");
+ img = UIManager.get("nb.progress.cancel.icon.mouseover");
if( null != img ) {
closeButton.setRolloverEnabled(true);
- closeButton.setRolloverIcon( new ImageIcon( img ) );
+ closeButton.setRolloverIcon( ListComponent.iconOrImage2icon( img ) );
}
- img = (Image)UIManager.get("nb.progress.cancel.icon.pressed");
+ img = UIManager.get("nb.progress.cancel.icon.pressed");
if( null != img ) {
- closeButton.setPressedIcon( new ImageIcon( img ) );
+ closeButton.setPressedIcon( ListComponent.iconOrImage2icon( img ) );
}
}
@@ -620,12 +618,12 @@ public class StatusLineComponent extends JPanel implements ProgressUIWorkerWithM
if (text) {
putValue(Action.NAME, NbBundle.getMessage(StatusLineComponent.class, "StatusLineComponent.Cancel"));
} else {
- Image icon = (Image)UIManager.get("nb.progress.cancel.icon");
+ Object icon = UIManager.get("nb.progress.cancel.icon");
if (icon == null) {
// for custom L&F?
putValue(Action.SMALL_ICON, ImageUtilities.loadImageIcon("org/netbeans/progress/module/resources/buton.png", true));
} else {
- putValue(Action.SMALL_ICON, new ImageIcon(icon));
+ putValue(Action.SMALL_ICON, ListComponent.iconOrImage2icon(icon));
}
}
setEnabled(handle == null ? false : handle.isAllowCancel());
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@netbeans.apache.org
For additional commands, e-mail: commits-help@netbeans.apache.org
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists