Use balloon to show announcements and update notifications

This commit is contained in:
bancika
2017-04-25 12:09:10 +02:00
parent 283232630c
commit dda588b28f
12 changed files with 35 additions and 12 deletions
Binary file not shown.
@@ -50,8 +50,7 @@ public class AnnouncementProvider {
}
}
if (!hasUnread)
return "";
sb.append("<br><font size='small'>Click OK to dismiss and mark these announcements as read.</font>");
return "";
sb.append("</html>");
return sb.toString();
}
@@ -88,7 +88,7 @@ public interface ISelectionProcessor {
*
* @param xOffset
* @param yOffset
* @param affectStuckComponents
* @param includeStuckComponents
*/
void nudgeSelection(Size xOffset, Size yOffset, boolean affectStuckComponents);
void nudgeSelection(Size xOffset, Size yOffset, boolean includeStuckComponents);
}
@@ -856,11 +856,11 @@ public class Presenter implements IPlugInPort {
}
@Override
public void nudgeSelection(Size xOffset, Size yOffset, boolean affectStuckComponents) {
public void nudgeSelection(Size xOffset, Size yOffset, boolean includeStuckComponents) {
if (selectedComponents == null || selectedComponents.isEmpty())
return;
LOG.debug(String.format("nudgeSelection(%s, %s)", xOffset, yOffset));
LOG.debug(String.format("nudgeSelection(%s, %s, %s)", xOffset, yOffset, includeStuckComponents));
Map<IDIYComponent<?>, Set<Integer>> controlPointMap = new HashMap<IDIYComponent<?>, Set<Integer>>();
// If there aren't any control points, try to add all the selected
// components with all their control points. That will allow the
@@ -878,7 +878,7 @@ public class Presenter implements IPlugInPort {
return;
}
if (affectStuckComponents) {
if (includeStuckComponents) {
includeStuckComponents(controlPointMap);
}
Binary file not shown.
+3 -2
View File
@@ -7,9 +7,10 @@
<classpathentry kind="lib" path="lib/junit-4.7.jar"/>
<classpathentry kind="lib" path="lib/iText-2.1.7.jar"/>
<classpathentry kind="lib" path="lib/jettison-1.0.1.jar"/>
<classpathentry kind="lib" path="lib/app-framework.jar"/>
<classpathentry kind="lib" path="lib/swing-framework.jar"/>
<classpathentry kind="lib" path="lib/app-framework.jar" sourcepath="/app-framework"/>
<classpathentry kind="lib" path="lib/swing-framework.jar" sourcepath="/swing-framework"/>
<classpathentry kind="lib" path="library/main.jar" sourcepath="/diylc-library"/>
<classpathentry kind="lib" path="lib/balloontip-1.2.4.1.jar"/>
<classpathentry combineaccessrules="false" kind="src" path="/diylc-core"/>
<classpathentry kind="lib" path="lib/xstream-1.4.3.jar"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/jdk1.6.0_45"/>
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -86,7 +86,7 @@ public class MainFrame extends JFrame implements ISwingUI {
public MainFrame() {
super("DIYLC 3");
setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
setPreferredSize(new Dimension(800, 600));
setPreferredSize(new Dimension(1024, 768));
createBasePanels();
menuMap = new HashMap<String, JMenu>();
buttonGroupMap = new HashMap<String, ButtonGroup>();
@@ -13,6 +13,7 @@ import java.awt.event.MouseEvent;
import java.awt.geom.Point2D;
import java.text.DecimalFormat;
import java.text.Format;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
@@ -27,6 +28,10 @@ import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.SwingUtilities;
import javax.swing.UIManager;
import net.java.balloontip.BalloonTip;
import net.java.balloontip.styles.EdgedBalloonStyle;
import org.apache.log4j.Logger;
import org.diylc.announcements.AnnouncementProvider;
@@ -93,7 +98,20 @@ public class StatusBar extends JPanel implements IPlugIn {
@Override
public String doInBackground() throws Exception {
Thread.sleep(1000);
return announcementProvider.getCurrentAnnouncements(false);
String announcements = announcementProvider.getCurrentAnnouncements(false);
String update = getUpdateLabel().getUpdateChecker().findNewVersionShort();
if (update != null) {
String updateHtml =
"<font size='4'><b>New version available:</b> " + update
+ "</font><br>Click the lighbulb icon in the bottom-right corner of the window for more info.";
if (announcements == null || announcements.length() == 0)
return "<html>" + updateHtml + "</html>";
announcements = announcements.replace("<html>", "<html>" + updateHtml + "<br>");
}
return announcements;
}
@Override
@@ -104,7 +122,8 @@ public class StatusBar extends JPanel implements IPlugIn {
@Override
public void complete(String result) {
if (result != null && result.length() > 0) {
StatusBar.this.swingUI.showMessage(result, "Public Announcement", IView.INFORMATION_MESSAGE);
new BalloonTip(getUpdateLabel(), result, new EdgedBalloonStyle(UIManager.getColor("ToolTip.background"),
UIManager.getColor("ToolTip.foreground")), true);
announcementProvider.dismissed();
}
}
+4
View File
@@ -1729,6 +1729,10 @@
<org.diylc.appframework.update.Change>
<changeType>IMPROVEMENT</changeType>
<description>Use standard OSX/Mac "command" key for menu shortcuts and to un-stuck components</description>
</org.diylc.appframework.update.Change>
<org.diylc.appframework.update.Change>
<changeType>IMPROVEMENT</changeType>
<description>Use balloon to show announcements and update notifications</description>
</org.diylc.appframework.update.Change>
<org.diylc.appframework.update.Change>
<changeType>BUG_FIX</changeType>