|
@@ -5,13 +5,10 @@ import com.ur.urcap.api.contribution.toolbar.swing.SwingToolbarContribution;
|
|
|
import uraxis.Activator;
|
|
|
|
|
|
import javax.swing.*;
|
|
|
-import java.awt.Component;
|
|
|
-import java.awt.Dimension;
|
|
|
-import java.awt.Font;
|
|
|
+import java.awt.*;
|
|
|
import java.awt.event.ActionEvent;
|
|
|
-import java.util.Date;
|
|
|
-import java.util.Locale;
|
|
|
-import java.util.Random;
|
|
|
+import java.util.*;
|
|
|
+import java.util.Timer;
|
|
|
|
|
|
class MyToolbarContribution implements SwingToolbarContribution {
|
|
|
private static final int VERTICAL_SPACE = 10;
|
|
@@ -19,6 +16,8 @@ class MyToolbarContribution implements SwingToolbarContribution {
|
|
|
|
|
|
private final ToolbarContext context;
|
|
|
private JLabel demoToolStatus;
|
|
|
+ private Timer uiTimer;
|
|
|
+
|
|
|
|
|
|
MyToolbarContribution(ToolbarContext context) {
|
|
|
this.context = context;
|
|
@@ -26,11 +25,28 @@ class MyToolbarContribution implements SwingToolbarContribution {
|
|
|
|
|
|
@Override
|
|
|
public void openView() {
|
|
|
- demoToolStatus.setText("<HTML>" + get3rdPartyStatus() + "</HTML>");
|
|
|
+
|
|
|
+ //UI updates from non-GUI threads must use EventQueue.invokeLater (or SwingUtilities.invokeLater)
|
|
|
+ uiTimer = new Timer(true);
|
|
|
+ uiTimer.schedule(new TimerTask() {
|
|
|
+ @Override
|
|
|
+ public void run() {
|
|
|
+ EventQueue.invokeLater(new Runnable() {
|
|
|
+ @Override
|
|
|
+ public void run() {
|
|
|
+ demoToolStatus.setText("<HTML>" + get3rdPartyStatus() + "</HTML>");
|
|
|
+
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }, 0, 1000);
|
|
|
+
|
|
|
+
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public void closeView() {
|
|
|
+ uiTimer.cancel();
|
|
|
}
|
|
|
|
|
|
public void buildUI(JPanel jPanel) {
|
|
@@ -53,51 +69,51 @@ class MyToolbarContribution implements SwingToolbarContribution {
|
|
|
|
|
|
private Box createButtons() {
|
|
|
Box box = Box.createHorizontalBox();
|
|
|
- JButton left100 = new JButton("<<<100");
|
|
|
+ JButton left100 = new JButton("<<<1000");
|
|
|
left100.addActionListener(new AbstractAction() {
|
|
|
@Override
|
|
|
public void actionPerformed(ActionEvent e) {
|
|
|
- Activator.daemonInterface.rel(-100);
|
|
|
+ Activator.daemonInterface.rel(-1000, 20);
|
|
|
}
|
|
|
});
|
|
|
box.add(left100);
|
|
|
- JButton left10 = new JButton("<<10");
|
|
|
+ JButton left10 = new JButton("<<100");
|
|
|
left10.addActionListener(new AbstractAction() {
|
|
|
@Override
|
|
|
public void actionPerformed(ActionEvent e) {
|
|
|
- Activator.daemonInterface.rel(-10);
|
|
|
+ Activator.daemonInterface.rel(-100, 20);
|
|
|
}
|
|
|
});
|
|
|
box.add(left10);
|
|
|
- JButton left1 = new JButton("<1");
|
|
|
+ JButton left1 = new JButton("<10");
|
|
|
left1.addActionListener(new AbstractAction() {
|
|
|
@Override
|
|
|
public void actionPerformed(ActionEvent e) {
|
|
|
- Activator.daemonInterface.rel(-1);
|
|
|
+ Activator.daemonInterface.rel(-10, 20);
|
|
|
}
|
|
|
});
|
|
|
box.add(left1);
|
|
|
- JButton right1 = new JButton("1>");
|
|
|
+ JButton right1 = new JButton("10>");
|
|
|
right1.addActionListener(new AbstractAction() {
|
|
|
@Override
|
|
|
public void actionPerformed(ActionEvent e) {
|
|
|
- Activator.daemonInterface.rel(1);
|
|
|
+ Activator.daemonInterface.rel(10, 20);
|
|
|
}
|
|
|
});
|
|
|
box.add(right1);
|
|
|
- JButton right10 = new JButton("10>>");
|
|
|
+ JButton right10 = new JButton("100>>");
|
|
|
right10.addActionListener(new AbstractAction() {
|
|
|
@Override
|
|
|
public void actionPerformed(ActionEvent e) {
|
|
|
- Activator.daemonInterface.rel(10);
|
|
|
+ Activator.daemonInterface.rel(100, 20);
|
|
|
}
|
|
|
});
|
|
|
box.add(right10);
|
|
|
- JButton right100 = new JButton("100>>>");
|
|
|
+ JButton right100 = new JButton("1000>>>");
|
|
|
right100.addActionListener(new AbstractAction() {
|
|
|
@Override
|
|
|
public void actionPerformed(ActionEvent e) {
|
|
|
- Activator.daemonInterface.rel(100);
|
|
|
+ Activator.daemonInterface.rel(1000, 20);
|
|
|
}
|
|
|
});
|
|
|
box.add(right100);
|
|
@@ -112,12 +128,12 @@ class MyToolbarContribution implements SwingToolbarContribution {
|
|
|
// pane1.setText("<HTML>This is a sample URCap Toolbar contribution. Feel free to use this as an example for creating new contributions.</HTML>");
|
|
|
// pane1.setBackground(infoBox.getBackground());
|
|
|
// infoBox.add(pane1);
|
|
|
-
|
|
|
- JLabel pane2 = new JLabel();
|
|
|
- Locale locale = context.getAPIProvider().getSystemAPI().getSystemSettings().getLocalization().getLocale();
|
|
|
- pane2.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
|
|
|
- pane2.setText("<HTML>Currently, the robot is configured to use the Locale: " + locale.getDisplayName() + "</HTML>");
|
|
|
- infoBox.add(pane2);
|
|
|
+//
|
|
|
+// JLabel pane2 = new JLabel();
|
|
|
+// Locale locale = context.getAPIProvider().getSystemAPI().getSystemSettings().getLocalization().getLocale();
|
|
|
+// pane2.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
|
|
|
+// pane2.setText("<HTML>Currently, the robot is configured to use the Locale: " + locale.getDisplayName() + "</HTML>");
|
|
|
+// infoBox.add(pane2);
|
|
|
|
|
|
demoToolStatus = new JLabel();
|
|
|
demoToolStatus.setText("<HTML>" + get3rdPartyStatus() +"</HTML>");
|
|
@@ -132,7 +148,9 @@ class MyToolbarContribution implements SwingToolbarContribution {
|
|
|
|
|
|
private String get3rdPartyStatus() {
|
|
|
Date now = new Date();
|
|
|
- int number = new Random().nextInt(10) + 20;
|
|
|
- return String.format("Tool status reading: %d, read at %tF %tT.", number, now, now);
|
|
|
+ int curPos=Activator.daemonInterface.getpos();
|
|
|
+ String curStatus=Activator.daemonInterface.getstatus();
|
|
|
+
|
|
|
+ return String.format("Position: %d, read at %tF %tT.<br/>%s", curPos, now, now, curStatus);
|
|
|
}
|
|
|
}
|