mirror of
https://github.com/bancika/diy-layout-creator
synced 2026-11-11 01:32:08 +10:00
show recent updates, added to status bar and help menu
This commit is contained in:
Binary file not shown.
@@ -33,6 +33,7 @@ import java.util.Set;
|
|||||||
|
|
||||||
import org.diylc.appframework.simplemq.IMessageListener;
|
import org.diylc.appframework.simplemq.IMessageListener;
|
||||||
import org.diylc.appframework.simplemq.MessageDispatcher;
|
import org.diylc.appframework.simplemq.MessageDispatcher;
|
||||||
|
import org.diylc.appframework.update.Version;
|
||||||
import org.diylc.appframework.update.VersionNumber;
|
import org.diylc.appframework.update.VersionNumber;
|
||||||
import org.diylc.core.IDIYComponent;
|
import org.diylc.core.IDIYComponent;
|
||||||
import org.diylc.core.Project;
|
import org.diylc.core.Project;
|
||||||
@@ -200,6 +201,13 @@ public interface IPlugInPort extends ISelectionProcessor, IMouseProcessor, IKeyP
|
|||||||
*/
|
*/
|
||||||
VersionNumber getCurrentVersionNumber();
|
VersionNumber getCurrentVersionNumber();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns few most recent versions.
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
List<Version> getRecentUpdates();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds a list of components to the project.
|
* 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);
|
private static final Logger LOG = Logger.getLogger(Presenter.class);
|
||||||
|
|
||||||
public static VersionNumber CURRENT_VERSION = new VersionNumber(3, 0, 0);
|
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
|
// Read the latest version from the local update.xml file
|
||||||
static {
|
static {
|
||||||
try {
|
try {
|
||||||
@@ -93,6 +94,14 @@ public class Presenter implements IPlugInPort {
|
|||||||
XStream xStream = new XStream(new DomDriver());
|
XStream xStream = new XStream(new DomDriver());
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
List<Version> allVersions = (List<Version>) xStream.fromXML(in);
|
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();
|
in.close();
|
||||||
CURRENT_VERSION = allVersions.get(allVersions.size() - 1).getVersionNumber();
|
CURRENT_VERSION = allVersions.get(allVersions.size() - 1).getVersionNumber();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
@@ -957,6 +966,11 @@ public class Presenter implements IPlugInPort {
|
|||||||
return CURRENT_VERSION;
|
return CURRENT_VERSION;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<Version> getRecentUpdates() {
|
||||||
|
return RECENT_VERSIONS;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void dragStarted(Point point, int dragAction, boolean forceSelectionRect) {
|
public void dragStarted(Point point, int dragAction, boolean forceSelectionRect) {
|
||||||
LOG.debug(String.format("dragStarted(%s, %s)", point, dragAction));
|
LOG.debug(String.format("dragStarted(%s, %s)", point, dragAction));
|
||||||
|
|||||||
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(
|
"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(
|
"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(
|
"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;
|
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.awt.event.ActionEvent;
|
||||||
import java.util.EnumSet;
|
import java.util.EnumSet;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import javax.swing.AbstractAction;
|
import javax.swing.AbstractAction;
|
||||||
import javax.swing.Icon;
|
import javax.swing.Icon;
|
||||||
|
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
import org.diylc.appframework.miscutils.Utils;
|
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.EventType;
|
||||||
import org.diylc.common.IPlugIn;
|
import org.diylc.common.IPlugIn;
|
||||||
import org.diylc.common.IPlugInPort;
|
import org.diylc.common.IPlugInPort;
|
||||||
|
import org.diylc.core.IView;
|
||||||
import org.diylc.images.IconLoader;
|
import org.diylc.images.IconLoader;
|
||||||
import org.diylc.swing.ISwingUI;
|
import org.diylc.swing.ISwingUI;
|
||||||
import org.diylc.swing.gui.DialogFactory;
|
import org.diylc.swing.gui.DialogFactory;
|
||||||
import org.diylc.swingframework.AboutDialog;
|
import org.diylc.swingframework.AboutDialog;
|
||||||
import org.diylc.swingframework.LinkLabel;
|
import org.diylc.swingframework.LinkLabel;
|
||||||
|
import org.diylc.swingframework.update.UpdateDialog;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Entry point class for help-related utilities.
|
* Entry point class for help-related utilities.
|
||||||
@@ -56,8 +61,10 @@ public class HelpMenuPlugin implements IPlugIn {
|
|||||||
|
|
||||||
private IPlugInPort plugInPort;
|
private IPlugInPort plugInPort;
|
||||||
private AboutDialog aboutDialog;
|
private AboutDialog aboutDialog;
|
||||||
|
private ISwingUI swingUI;
|
||||||
|
|
||||||
public HelpMenuPlugin(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("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("FAQ", IconLoader.Faq.getIcon(), FAQ_URL), HELP_TITLE);
|
||||||
swingUI.injectMenuAction(new NavigateURLAction("Component API", IconLoader.CoffeebeanEdit.getIcon(), COMPONENT_URL),
|
swingUI.injectMenuAction(new NavigateURLAction("Component API", IconLoader.CoffeebeanEdit.getIcon(), COMPONENT_URL),
|
||||||
@@ -65,6 +72,8 @@ public class HelpMenuPlugin implements IPlugIn {
|
|||||||
swingUI.injectMenuAction(new NavigateURLAction("Plugin API", IconLoader.ApplicationEdit.getIcon(), PLUGIN_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(new NavigateURLAction("Submit a Bug", IconLoader.Bug.getIcon(), BUG_URL), HELP_TITLE);
|
||||||
swingUI.injectMenuAction(null, 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);
|
swingUI.injectMenuAction(new AboutAction(), HELP_TITLE);
|
||||||
}
|
}
|
||||||
@@ -120,6 +129,29 @@ public class HelpMenuPlugin implements IPlugIn {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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 {
|
class NavigateURLAction extends AbstractAction {
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|||||||
@@ -44,6 +44,7 @@ import java.util.Map;
|
|||||||
|
|
||||||
import javax.swing.BorderFactory;
|
import javax.swing.BorderFactory;
|
||||||
import javax.swing.JComboBox;
|
import javax.swing.JComboBox;
|
||||||
|
import javax.swing.JComponent;
|
||||||
import javax.swing.JLabel;
|
import javax.swing.JLabel;
|
||||||
import javax.swing.JOptionPane;
|
import javax.swing.JOptionPane;
|
||||||
import javax.swing.JPanel;
|
import javax.swing.JPanel;
|
||||||
@@ -56,6 +57,8 @@ import net.java.balloontip.styles.EdgedBalloonStyle;
|
|||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
import org.diylc.announcements.AnnouncementProvider;
|
import org.diylc.announcements.AnnouncementProvider;
|
||||||
import org.diylc.appframework.miscutils.Utils;
|
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.BadPositionException;
|
||||||
import org.diylc.common.ComponentType;
|
import org.diylc.common.ComponentType;
|
||||||
import org.diylc.common.EventType;
|
import org.diylc.common.EventType;
|
||||||
@@ -68,6 +71,7 @@ import org.diylc.images.IconLoader;
|
|||||||
import org.diylc.swing.ISwingUI;
|
import org.diylc.swing.ISwingUI;
|
||||||
import org.diylc.swingframework.MemoryBar;
|
import org.diylc.swingframework.MemoryBar;
|
||||||
import org.diylc.swingframework.miscutils.PercentageListCellRenderer;
|
import org.diylc.swingframework.miscutils.PercentageListCellRenderer;
|
||||||
|
import org.diylc.swingframework.update.UpdateDialog;
|
||||||
import org.diylc.swingframework.update.UpdateLabel;
|
import org.diylc.swingframework.update.UpdateLabel;
|
||||||
|
|
||||||
public class StatusBar extends JPanel implements IPlugIn {
|
public class StatusBar extends JPanel implements IPlugIn {
|
||||||
@@ -82,6 +86,7 @@ public class StatusBar extends JPanel implements IPlugIn {
|
|||||||
private JComboBox zoomBox;
|
private JComboBox zoomBox;
|
||||||
private UpdateLabel updateLabel;
|
private UpdateLabel updateLabel;
|
||||||
private JLabel announcementLabel;
|
private JLabel announcementLabel;
|
||||||
|
private JLabel recentChangesLabel;
|
||||||
private MemoryBar memoryPanel;
|
private MemoryBar memoryPanel;
|
||||||
private JLabel statusLabel;
|
private JLabel statusLabel;
|
||||||
private JLabel sizeLabel;
|
private JLabel sizeLabel;
|
||||||
@@ -179,9 +184,6 @@ public class StatusBar extends JPanel implements IPlugIn {
|
|||||||
return new Point(0, -16);
|
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));
|
updateLabel.setBorder(BorderFactory.createEmptyBorder(2, 4, 2, 4));
|
||||||
}
|
}
|
||||||
return updateLabel;
|
return updateLabel;
|
||||||
@@ -234,6 +236,38 @@ public class StatusBar extends JPanel implements IPlugIn {
|
|||||||
return announcementLabel;
|
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() {
|
private MemoryBar getMemoryPanel() {
|
||||||
if (memoryPanel == null) {
|
if (memoryPanel == null) {
|
||||||
memoryPanel = new MemoryBar(false) {
|
memoryPanel = new MemoryBar(false) {
|
||||||
@@ -323,6 +357,10 @@ public class StatusBar extends JPanel implements IPlugIn {
|
|||||||
gbc.insets = new Insets(0, 0, 0, 0);
|
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.gridx++;
|
||||||
gbc.fill = GridBagConstraints.NONE;
|
gbc.fill = GridBagConstraints.NONE;
|
||||||
gbc.insets = new Insets(0, 0, 0, 4);
|
gbc.insets = new Insets(0, 0, 0, 4);
|
||||||
|
|||||||
@@ -2268,7 +2268,11 @@
|
|||||||
</org.diylc.appframework.update.Change>
|
</org.diylc.appframework.update.Change>
|
||||||
<org.diylc.appframework.update.Change>
|
<org.diylc.appframework.update.Change>
|
||||||
<changeType>NEW_FEATURE</changeType>
|
<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>
|
||||||
<org.diylc.appframework.update.Change>
|
<org.diylc.appframework.update.Change>
|
||||||
<changeType>IMPROVEMENT</changeType>
|
<changeType>IMPROVEMENT</changeType>
|
||||||
|
|||||||
Reference in New Issue
Block a user