mirror of
https://github.com/arduino/Arduino.git
synced 2025-01-29 18:52:13 +01:00
Update notification: UX feedback
This commit is contained in:
parent
0bb7fd7e8b
commit
a43757d5c3
@ -59,11 +59,11 @@ public class ContributionsSelfCheck extends TimerTask {
|
||||
|
||||
String text;
|
||||
if (updatableLibraries > 0 && updatablePlatforms <= 0) {
|
||||
text = I18n.format(_("Some {0}libraries{1} may be updated"), "<a href=\"http://librarymanager\">", "</a>");
|
||||
text = I18n.format(_("<br/>Update available for some of your {0}libraries{1}"), "<a href=\"http://librarymanager\">", "</a>");
|
||||
} else if (updatableLibraries <= 0 && updatablePlatforms > 0) {
|
||||
text = I18n.format(_("Some {0}boards{1} may be updated"), "<a href=\"http://boardsmanager\">", "</a>");
|
||||
text = I18n.format(_("<br/>Update available for some of your {0}boards{1}"), "<a href=\"http://boardsmanager\">", "</a>");
|
||||
} else {
|
||||
text = I18n.format(_("Some {0}boards{1} and some {2}libraries{3} may be updated"), "<a href=\"http://boardsmanager\">", "</a>", "<a href=\"http://librarymanager\">", "</a>");
|
||||
text = I18n.format(_("<br/>Update available for some of your {0}boards{1} and {2}libraries{3}"), "<a href=\"http://boardsmanager\">", "</a>", "<a href=\"http://librarymanager\">", "</a>");
|
||||
}
|
||||
|
||||
if (cancelled) {
|
||||
@ -71,7 +71,7 @@ public class ContributionsSelfCheck extends TimerTask {
|
||||
}
|
||||
|
||||
SwingUtilities.invokeLater(() -> {
|
||||
notificationPopup = new NotificationPopup(base.getActiveEditor(), hyperlinkListener, _("Updates available"), text);
|
||||
notificationPopup = new NotificationPopup(base.getActiveEditor(), hyperlinkListener, text);
|
||||
notificationPopup.setVisible(true);
|
||||
});
|
||||
}
|
||||
|
@ -7,7 +7,13 @@
|
||||
<Property name="focusable" type="boolean" value="false"/>
|
||||
<Property name="focusableWindowState" type="boolean" value="false"/>
|
||||
<Property name="undecorated" type="boolean" value="true"/>
|
||||
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
|
||||
<Dimension value="[350, 70]"/>
|
||||
</Property>
|
||||
<Property name="resizable" type="boolean" value="false"/>
|
||||
<Property name="size" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
|
||||
<Dimension value="[350, 70]"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
<SyntheticProperties>
|
||||
<SyntheticProperty name="formSizePolicy" type="int" value="1"/>
|
||||
@ -23,74 +29,24 @@
|
||||
<AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
|
||||
<AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
|
||||
<AuxValue name="designerSize" type="java.awt.Dimension" value="-84,-19,0,5,115,114,0,18,106,97,118,97,46,97,119,116,46,68,105,109,101,110,115,105,111,110,65,-114,-39,-41,-84,95,68,20,2,0,2,73,0,6,104,101,105,103,104,116,73,0,5,119,105,100,116,104,120,112,0,0,1,0,0,0,2,14"/>
|
||||
</AuxValues>
|
||||
|
||||
<Layout>
|
||||
<DimensionLayout dim="0">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" attributes="0">
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="jLabel1" min="-2" pref="48" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" attributes="0">
|
||||
<Component id="text" min="-2" pref="264" max="-2" attributes="0"/>
|
||||
<EmptySpace max="32767" attributes="0"/>
|
||||
</Group>
|
||||
<Group type="102" alignment="0" attributes="0">
|
||||
<Component id="title" max="32767" attributes="0"/>
|
||||
<EmptySpace min="-2" pref="24" max="-2" attributes="0"/>
|
||||
<Component id="closeButton" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</Group>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
<DimensionLayout dim="1">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" attributes="0">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" attributes="0">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" attributes="0">
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="title" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<Component id="closeButton" alignment="0" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="text" min="-2" pref="42" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<Group type="102" alignment="0" attributes="0">
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="jLabel1" min="-2" pref="48" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
<EmptySpace max="32767" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout">
|
||||
<Property name="useNullLayout" type="boolean" value="true"/>
|
||||
</Layout>
|
||||
<SubComponents>
|
||||
<Component class="javax.swing.JLabel" name="title">
|
||||
<Properties>
|
||||
<Property name="font" type="java.awt.Font" editor="org.netbeans.modules.form.editors2.FontEditor">
|
||||
<FontInfo relative="true">
|
||||
<Font bold="true" component="title" property="font" relativeSize="true" size="0"/>
|
||||
</FontInfo>
|
||||
</Property>
|
||||
</Properties>
|
||||
</Component>
|
||||
<Component class="javax.swing.JLabel" name="jLabel1">
|
||||
<Component class="javax.swing.JLabel" name="icon">
|
||||
<Properties>
|
||||
<Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
|
||||
<Connection code="new ImageIcon(Paths.get(BaseNoGui.getContentFile("lib").getAbsolutePath(), "arduino_small.png").toFile().getAbsolutePath())" type="code"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
<AuxValues>
|
||||
<AuxValue name="JavaCodeGenerator_VariableLocal" type="java.lang.Boolean" value="true"/>
|
||||
<AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="0"/>
|
||||
</AuxValues>
|
||||
<Constraints>
|
||||
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription">
|
||||
<AbsoluteConstraints x="10" y="10" width="50" height="50"/>
|
||||
</Constraint>
|
||||
</Constraints>
|
||||
</Component>
|
||||
<Component class="javax.swing.JEditorPane" name="text">
|
||||
<Properties>
|
||||
@ -103,6 +59,11 @@
|
||||
<Property name="contentType" type="java.lang.String" value="text/html" noResource="true"/>
|
||||
<Property name="opaque" type="boolean" value="false"/>
|
||||
</Properties>
|
||||
<Constraints>
|
||||
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription">
|
||||
<AbsoluteConstraints x="70" y="10" width="270" height="50"/>
|
||||
</Constraint>
|
||||
</Constraints>
|
||||
</Component>
|
||||
<Component class="javax.swing.JButton" name="closeButton">
|
||||
<Properties>
|
||||
@ -118,6 +79,11 @@
|
||||
<Events>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="closeButtonActionPerformed"/>
|
||||
</Events>
|
||||
<Constraints>
|
||||
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription">
|
||||
<AbsoluteConstraints x="328" y="0" width="22" height="22"/>
|
||||
</Constraint>
|
||||
</Constraints>
|
||||
</Component>
|
||||
</SubComponents>
|
||||
</Form>
|
||||
|
@ -29,7 +29,6 @@
|
||||
|
||||
package cc.arduino.view;
|
||||
|
||||
import cc.arduino.Constants;
|
||||
import processing.app.Base;
|
||||
import processing.app.BaseNoGui;
|
||||
|
||||
@ -43,9 +42,8 @@ import java.nio.file.Paths;
|
||||
public class NotificationPopup extends JDialog {
|
||||
|
||||
private final ComponentAdapter parentMovedListener;
|
||||
private final Timer autoCloseAfterTimeout;
|
||||
|
||||
public NotificationPopup(Frame parent, HyperlinkListener hyperlinkListener, String titleText, String message) {
|
||||
public NotificationPopup(Frame parent, HyperlinkListener hyperlinkListener, String message) {
|
||||
super(parent, false);
|
||||
initComponents();
|
||||
|
||||
@ -58,10 +56,15 @@ public class NotificationPopup extends JDialog {
|
||||
};
|
||||
parent.addComponentListener(parentMovedListener);
|
||||
|
||||
title.setText(titleText);
|
||||
text.setText("<html><body style=\"font-family:sans-serif;font-size:12pt\">" + message.replace("\n", "<br/>") + "</body></html>");
|
||||
text.setText("<html><body style=\"font-family:sans-serif;font-size:12pt\">" + message + "</body></html>");
|
||||
|
||||
text.addHyperlinkListener(hyperlinkListener);
|
||||
text.addHyperlinkListener(e -> {
|
||||
if (e.getEventType() != HyperlinkEvent.EventType.ACTIVATED) {
|
||||
return;
|
||||
}
|
||||
close();
|
||||
});
|
||||
|
||||
addWindowListener(new WindowAdapter() {
|
||||
@Override
|
||||
@ -70,24 +73,17 @@ public class NotificationPopup extends JDialog {
|
||||
}
|
||||
});
|
||||
|
||||
autoCloseAfterTimeout = new Timer(Constants.NOTIFICATION_POPUP_AUTOCLOSE_DELAY, (e) -> close());
|
||||
autoCloseAfterTimeout.start();
|
||||
|
||||
text.addHyperlinkListener(e -> {
|
||||
if (e.getEventType() != HyperlinkEvent.EventType.ACTIVATED) {
|
||||
return;
|
||||
}
|
||||
close();
|
||||
});
|
||||
|
||||
Base.registerWindowCloseKeys(getRootPane(), e -> close());
|
||||
|
||||
addMouseListener(new MouseAdapter() {
|
||||
MouseAdapter closeOnClick = new MouseAdapter() {
|
||||
@Override
|
||||
public void mouseClicked(MouseEvent e) {
|
||||
close();
|
||||
}
|
||||
});
|
||||
};
|
||||
addMouseListener(closeOnClick);
|
||||
text.addMouseListener(closeOnClick);
|
||||
icon.addMouseListener(closeOnClick);
|
||||
}
|
||||
|
||||
private void updateLocation(Frame parent) {
|
||||
@ -95,14 +91,10 @@ public class NotificationPopup extends JDialog {
|
||||
|
||||
int parentX = Double.valueOf(parentLocation.getX()).intValue();
|
||||
int parentY = Double.valueOf(parentLocation.getY()).intValue();
|
||||
setLocation(parentX + parent.getWidth() - getWidth(), parentY + parent.getHeight() - getHeight());
|
||||
setLocation(parentX, parentY + parent.getHeight() - getHeight());
|
||||
}
|
||||
|
||||
public void close() {
|
||||
if (autoCloseAfterTimeout.isRunning()) {
|
||||
autoCloseAfterTimeout.stop();
|
||||
}
|
||||
|
||||
dispatchEvent(new WindowEvent(NotificationPopup.this, WindowEvent.WINDOW_CLOSING));
|
||||
}
|
||||
|
||||
@ -115,8 +107,7 @@ public class NotificationPopup extends JDialog {
|
||||
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
|
||||
private void initComponents() {
|
||||
|
||||
title = new javax.swing.JLabel();
|
||||
javax.swing.JLabel jLabel1 = new javax.swing.JLabel();
|
||||
icon = new javax.swing.JLabel();
|
||||
text = new javax.swing.JEditorPane();
|
||||
closeButton = new javax.swing.JButton();
|
||||
|
||||
@ -125,16 +116,21 @@ public class NotificationPopup extends JDialog {
|
||||
setFocusable(false);
|
||||
setFocusableWindowState(false);
|
||||
setUndecorated(true);
|
||||
setPreferredSize(new java.awt.Dimension(350, 70));
|
||||
setResizable(false);
|
||||
setSize(new java.awt.Dimension(350, 70));
|
||||
getContentPane().setLayout(null);
|
||||
|
||||
title.setFont(title.getFont().deriveFont(title.getFont().getStyle() | java.awt.Font.BOLD));
|
||||
|
||||
jLabel1.setIcon(new ImageIcon(Paths.get(BaseNoGui.getContentFile("lib").getAbsolutePath(), "arduino_small.png").toFile().getAbsolutePath()));
|
||||
icon.setIcon(new ImageIcon(Paths.get(BaseNoGui.getContentFile("lib").getAbsolutePath(), "arduino_small.png").toFile().getAbsolutePath()));
|
||||
getContentPane().add(icon);
|
||||
icon.setBounds(10, 10, 50, 50);
|
||||
|
||||
text.setEditable(false);
|
||||
text.setBorder(new javax.swing.border.LineBorder(new java.awt.Color(0, 0, 0), 0, true));
|
||||
text.setContentType("text/html"); // NOI18N
|
||||
text.setOpaque(false);
|
||||
getContentPane().add(text);
|
||||
text.setBounds(70, 10, 270, 50);
|
||||
|
||||
closeButton.setIcon(new ImageIcon(Paths.get(BaseNoGui.getContentFile("lib").getAbsolutePath(), "theme", "close.png").toFile().getAbsolutePath()));
|
||||
closeButton.setBorder(null);
|
||||
@ -145,41 +141,8 @@ public class NotificationPopup extends JDialog {
|
||||
closeButtonActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
|
||||
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
|
||||
getContentPane().setLayout(layout);
|
||||
layout.setHorizontalGroup(
|
||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addContainerGap()
|
||||
.addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 48, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addComponent(text, javax.swing.GroupLayout.PREFERRED_SIZE, 264, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addContainerGap())
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addComponent(title, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addGap(24, 24, 24)
|
||||
.addComponent(closeButton))))
|
||||
);
|
||||
layout.setVerticalGroup(
|
||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addContainerGap()
|
||||
.addComponent(title))
|
||||
.addComponent(closeButton))
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(text, javax.swing.GroupLayout.PREFERRED_SIZE, 42, javax.swing.GroupLayout.PREFERRED_SIZE))
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addContainerGap()
|
||||
.addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 48, javax.swing.GroupLayout.PREFERRED_SIZE)))
|
||||
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
|
||||
);
|
||||
getContentPane().add(closeButton);
|
||||
closeButton.setBounds(328, 0, 22, 22);
|
||||
|
||||
pack();
|
||||
}// </editor-fold>//GEN-END:initComponents
|
||||
@ -196,7 +159,7 @@ public class NotificationPopup extends JDialog {
|
||||
/* Create and display the dialog */
|
||||
EventQueue.invokeLater(new Runnable() {
|
||||
public void run() {
|
||||
NotificationPopup dialog = new NotificationPopup(new JFrame(), System.out::println, "title", "<a href='arduinoide://boardsmanager'>test</a> test test test test test test test test\n" +
|
||||
NotificationPopup dialog = new NotificationPopup(new JFrame(), System.out::println, "<a href='arduinoide://boardsmanager'>test</a> test test test test test test test test\n" +
|
||||
" test test test test test test test test test test test");
|
||||
dialog.addWindowListener(new WindowAdapter() {
|
||||
@Override
|
||||
@ -211,8 +174,8 @@ public class NotificationPopup extends JDialog {
|
||||
|
||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||
private javax.swing.JButton closeButton;
|
||||
private javax.swing.JLabel icon;
|
||||
private javax.swing.JEditorPane text;
|
||||
private javax.swing.JLabel title;
|
||||
// End of variables declaration//GEN-END:variables
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user