mirror of
https://github.com/bancika/diy-layout-creator
synced 2026-11-10 17:22:09 +10:00
show recent updates, added to status bar and help menu
This commit is contained in:
Binary file not shown.
@@ -21,23 +21,24 @@
|
||||
*/
|
||||
package org.diylc.common;
|
||||
|
||||
import java.awt.Cursor;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.Point;
|
||||
import java.awt.geom.Point2D;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.diylc.appframework.simplemq.IMessageListener;
|
||||
import org.diylc.appframework.simplemq.MessageDispatcher;
|
||||
import org.diylc.appframework.update.VersionNumber;
|
||||
import org.diylc.core.IDIYComponent;
|
||||
import org.diylc.core.Project;
|
||||
import org.diylc.core.Template;
|
||||
import org.diylc.core.Theme;
|
||||
import java.awt.Cursor;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.Point;
|
||||
import java.awt.geom.Point2D;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.diylc.appframework.simplemq.IMessageListener;
|
||||
import org.diylc.appframework.simplemq.MessageDispatcher;
|
||||
import org.diylc.appframework.update.Version;
|
||||
import org.diylc.appframework.update.VersionNumber;
|
||||
import org.diylc.core.IDIYComponent;
|
||||
import org.diylc.core.Project;
|
||||
import org.diylc.core.Template;
|
||||
import org.diylc.core.Theme;
|
||||
|
||||
/**
|
||||
* Interface for communication between plug-ins and the application. Plug-ins may acquire
|
||||
@@ -198,7 +199,14 @@ public interface IPlugInPort extends ISelectionProcessor, IMouseProcessor, IKeyP
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
VersionNumber getCurrentVersionNumber();
|
||||
VersionNumber getCurrentVersionNumber();
|
||||
|
||||
/**
|
||||
* Returns few most recent versions.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
List<Version> getRecentUpdates();
|
||||
|
||||
/**
|
||||
* Adds a list of components to the project.
|
||||
|
||||
@@ -86,6 +86,7 @@ public class Presenter implements IPlugInPort {
|
||||
private static final Logger LOG = Logger.getLogger(Presenter.class);
|
||||
|
||||
public static VersionNumber CURRENT_VERSION = new VersionNumber(3, 0, 0);
|
||||
public static List<Version> RECENT_VERSIONS = null;
|
||||
// Read the latest version from the local update.xml file
|
||||
static {
|
||||
try {
|
||||
@@ -93,6 +94,14 @@ public class Presenter implements IPlugInPort {
|
||||
XStream xStream = new XStream(new DomDriver());
|
||||
@SuppressWarnings("unchecked")
|
||||
List<Version> allVersions = (List<Version>) xStream.fromXML(in);
|
||||
RECENT_VERSIONS = allVersions.subList(allVersions.size() - 4, allVersions.size() - 1);
|
||||
Collections.sort(RECENT_VERSIONS, new Comparator<Version>() {
|
||||
|
||||
@Override
|
||||
public int compare(Version o1, Version o2) {
|
||||
return -o1.getVersionNumber().compareTo(o2.getVersionNumber());
|
||||
}
|
||||
});
|
||||
in.close();
|
||||
CURRENT_VERSION = allVersions.get(allVersions.size() - 1).getVersionNumber();
|
||||
} catch (IOException e) {
|
||||
@@ -956,6 +965,11 @@ public class Presenter implements IPlugInPort {
|
||||
public VersionNumber getCurrentVersionNumber() {
|
||||
return CURRENT_VERSION;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Version> getRecentUpdates() {
|
||||
return RECENT_VERSIONS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dragStarted(Point point, int dragAction, boolean forceSelectionRect) {
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -62,7 +62,7 @@ public enum IconLoader {
|
||||
"pin_green.png"), CoffeebeanEdit("coffeebean_edit.png"), ApplicationEdit("application_edit.png"), ComponentAdd(
|
||||
"component_add.png"), History("history.png"), DocumentPlain("document_plain.png"), FitToSize("fit_to_size.png"), DocumentsGear(
|
||||
"documents_gear.png"), SplashResistor("splash_resistor.png"), SplashCeramic("splash_ceramic.png"), SplashElectrolytic(
|
||||
"splash_electrolytic.png"), SplashFilm("splash_film.png"), Splash("splash.png"), Help("help2.png");
|
||||
"splash_electrolytic.png"), SplashFilm("splash_film.png"), Splash("splash.png"), Help("help2.png"), ScrollInformation("scroll_information.png");
|
||||
|
||||
protected String name;
|
||||
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 913 B |
@@ -23,20 +23,25 @@ package org.diylc.swing.plugins.help;
|
||||
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.util.EnumSet;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.swing.AbstractAction;
|
||||
import javax.swing.Icon;
|
||||
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.diylc.appframework.miscutils.Utils;
|
||||
import org.diylc.appframework.update.UpdateChecker;
|
||||
import org.diylc.appframework.update.Version;
|
||||
import org.diylc.common.EventType;
|
||||
import org.diylc.common.IPlugIn;
|
||||
import org.diylc.common.IPlugInPort;
|
||||
import org.diylc.core.IView;
|
||||
import org.diylc.images.IconLoader;
|
||||
import org.diylc.swing.ISwingUI;
|
||||
import org.diylc.swing.gui.DialogFactory;
|
||||
import org.diylc.swingframework.AboutDialog;
|
||||
import org.diylc.swingframework.LinkLabel;
|
||||
import org.diylc.swingframework.update.UpdateDialog;
|
||||
|
||||
/**
|
||||
* Entry point class for help-related utilities.
|
||||
@@ -55,17 +60,21 @@ public class HelpMenuPlugin implements IPlugIn {
|
||||
public static String DONATE_URL = "http://diy-fever.com/donate";
|
||||
|
||||
private IPlugInPort plugInPort;
|
||||
private AboutDialog aboutDialog;
|
||||
private AboutDialog aboutDialog;
|
||||
private ISwingUI swingUI;
|
||||
|
||||
public HelpMenuPlugin(ISwingUI swingUI) {
|
||||
this.swingUI = swingUI;
|
||||
swingUI.injectMenuAction(new NavigateURLAction("User Manual", IconLoader.Manual.getIcon(), MANUAL_URL), HELP_TITLE);
|
||||
swingUI.injectMenuAction(new NavigateURLAction("FAQ", IconLoader.Faq.getIcon(), FAQ_URL), HELP_TITLE);
|
||||
swingUI.injectMenuAction(new NavigateURLAction("Component API", IconLoader.CoffeebeanEdit.getIcon(), COMPONENT_URL),
|
||||
HELP_TITLE);
|
||||
swingUI.injectMenuAction(new NavigateURLAction("Plugin API", IconLoader.ApplicationEdit.getIcon(), PLUGIN_URL), HELP_TITLE);
|
||||
swingUI.injectMenuAction(new NavigateURLAction("Submit a Bug", IconLoader.Bug.getIcon(), BUG_URL), HELP_TITLE);
|
||||
swingUI.injectMenuAction(null, HELP_TITLE);
|
||||
swingUI.injectMenuAction(new RecentUpdatesAction(), HELP_TITLE);
|
||||
swingUI.injectMenuAction(null, HELP_TITLE);
|
||||
swingUI.injectMenuAction(new NavigateURLAction("Donate", IconLoader.Donate.getIcon(), DONATE_URL), HELP_TITLE);
|
||||
swingUI.injectMenuAction(new NavigateURLAction("Donate", IconLoader.Donate.getIcon(), DONATE_URL), HELP_TITLE);
|
||||
swingUI.injectMenuAction(new AboutAction(), HELP_TITLE);
|
||||
}
|
||||
|
||||
@@ -118,6 +127,29 @@ public class HelpMenuPlugin implements IPlugIn {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
getAboutDialog().setVisible(true);
|
||||
}
|
||||
}
|
||||
|
||||
class RecentUpdatesAction extends AbstractAction {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public RecentUpdatesAction() {
|
||||
super();
|
||||
putValue(AbstractAction.NAME, "Recent Updates");
|
||||
putValue(AbstractAction.SMALL_ICON, IconLoader.ScrollInformation.getIcon());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
List<Version> updates = plugInPort.getRecentUpdates();
|
||||
if (updates == null)
|
||||
swingUI.showMessage("Version history is not available.", "Information", IView.INFORMATION_MESSAGE);
|
||||
else {
|
||||
String html = UpdateChecker.createUpdateHTML(updates);
|
||||
UpdateDialog updateDialog = new UpdateDialog(swingUI.getOwnerFrame().getRootPane(), html, (String)null);
|
||||
updateDialog.setVisible(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class NavigateURLAction extends AbstractAction {
|
||||
|
||||
@@ -44,6 +44,7 @@ import java.util.Map;
|
||||
|
||||
import javax.swing.BorderFactory;
|
||||
import javax.swing.JComboBox;
|
||||
import javax.swing.JComponent;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JOptionPane;
|
||||
import javax.swing.JPanel;
|
||||
@@ -56,6 +57,8 @@ import net.java.balloontip.styles.EdgedBalloonStyle;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.diylc.announcements.AnnouncementProvider;
|
||||
import org.diylc.appframework.miscutils.Utils;
|
||||
import org.diylc.appframework.update.UpdateChecker;
|
||||
import org.diylc.appframework.update.Version;
|
||||
import org.diylc.common.BadPositionException;
|
||||
import org.diylc.common.ComponentType;
|
||||
import org.diylc.common.EventType;
|
||||
@@ -68,6 +71,7 @@ import org.diylc.images.IconLoader;
|
||||
import org.diylc.swing.ISwingUI;
|
||||
import org.diylc.swingframework.MemoryBar;
|
||||
import org.diylc.swingframework.miscutils.PercentageListCellRenderer;
|
||||
import org.diylc.swingframework.update.UpdateDialog;
|
||||
import org.diylc.swingframework.update.UpdateLabel;
|
||||
|
||||
public class StatusBar extends JPanel implements IPlugIn {
|
||||
@@ -81,7 +85,8 @@ public class StatusBar extends JPanel implements IPlugIn {
|
||||
|
||||
private JComboBox zoomBox;
|
||||
private UpdateLabel updateLabel;
|
||||
private JLabel announcementLabel;
|
||||
private JLabel announcementLabel;
|
||||
private JLabel recentChangesLabel;
|
||||
private MemoryBar memoryPanel;
|
||||
private JLabel statusLabel;
|
||||
private JLabel sizeLabel;
|
||||
@@ -179,9 +184,6 @@ public class StatusBar extends JPanel implements IPlugIn {
|
||||
return new Point(0, -16);
|
||||
}
|
||||
};
|
||||
// updateLabel.setBorder(BorderFactory.createCompoundBorder(
|
||||
// BorderFactory.createEtchedBorder(), BorderFactory
|
||||
// .createEmptyBorder(2, 4, 2, 4)));
|
||||
updateLabel.setBorder(BorderFactory.createEmptyBorder(2, 4, 2, 4));
|
||||
}
|
||||
return updateLabel;
|
||||
@@ -232,6 +234,38 @@ public class StatusBar extends JPanel implements IPlugIn {
|
||||
});
|
||||
}
|
||||
return announcementLabel;
|
||||
}
|
||||
|
||||
public JLabel getRecentChangesLabel() {
|
||||
if (recentChangesLabel == null) {
|
||||
recentChangesLabel = new JLabel(IconLoader.ScrollInformation.getIcon()){
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Override
|
||||
public Point getToolTipLocation(MouseEvent event) {
|
||||
return new Point(0, -16);
|
||||
}
|
||||
};
|
||||
recentChangesLabel.setToolTipText("Click to show recent changes and updates");
|
||||
recentChangesLabel.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
|
||||
|
||||
recentChangesLabel.addMouseListener(new MouseAdapter() {
|
||||
|
||||
@Override
|
||||
public void mouseClicked(MouseEvent e) {
|
||||
List<Version> updates = plugInPort.getRecentUpdates();
|
||||
if (updates == null)
|
||||
swingUI.showMessage("Version history is not available.", "Information", IView.INFORMATION_MESSAGE);
|
||||
else {
|
||||
String html = UpdateChecker.createUpdateHTML(updates);
|
||||
UpdateDialog updateDialog = new UpdateDialog(swingUI.getOwnerFrame().getRootPane(), html, (String)null);
|
||||
updateDialog.setVisible(true);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
return recentChangesLabel;
|
||||
}
|
||||
|
||||
private MemoryBar getMemoryPanel() {
|
||||
@@ -321,7 +355,11 @@ public class StatusBar extends JPanel implements IPlugIn {
|
||||
|
||||
gbc.gridx++;
|
||||
gbc.insets = new Insets(0, 0, 0, 0);
|
||||
add(getUpdateLabel(), gbc);
|
||||
add(getUpdateLabel(), gbc);
|
||||
|
||||
gbc.gridx++;
|
||||
gbc.insets = new Insets(0, 0, 0, 4);
|
||||
add(getRecentChangesLabel(), gbc);
|
||||
|
||||
gbc.gridx++;
|
||||
gbc.fill = GridBagConstraints.NONE;
|
||||
|
||||
@@ -2268,8 +2268,12 @@
|
||||
</org.diylc.appframework.update.Change>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>NEW_FEATURE</changeType>
|
||||
<description>Ability to flip letters and numbers for board coordinates</description>
|
||||
<description>Ability to flip the letters and numbers for board coordinates</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>NEW_FEATURE</changeType>
|
||||
<description>"Recent Updates" added to status bar and Help menu</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>IMPROVEMENT</changeType>
|
||||
<description>Fixed the issue with Ohm symbol rendering with some fonts and changed default project font back to "Square721 BT"</description>
|
||||
|
||||
Reference in New Issue
Block a user