import org.eclipse.e4.ui.model.application.ui.basic.MPart;
import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.MouseEvent;
+import org.eclipse.swt.events.MouseTrackListener;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
Composite c = new Composite(parent, SWT.NONE);
c.setLayout(new GridLayout(4, false));
Button pauseButton = new Button(c, SWT.TOGGLE);
- pauseButton.setText("Running");
+ pauseButton.setSelection(true);
+ setPauseText(pauseButton, false);
pauseButton.addListener(SWT.Selection, e ->
{
- if (!pauseButton.getSelection())
+ setPauseText(pauseButton, false);
+ if (pauseButton.getSelection())
{
- pauseButton.setText("Running");
exec.unpauseLiveExecution();
} else
{
- pauseButton.setText("Paused");
exec.pauseLiveExecution();
}
});
+ pauseButton.addMouseTrackListener(new MouseTrackListener()
+ {
+ @Override
+ public void mouseHover(MouseEvent e)
+ {
+ // nothing
+ }
+
+ @Override
+ public void mouseExit(MouseEvent e)
+ {
+ setPauseText(pauseButton, false);
+ }
+
+ @Override
+ public void mouseEnter(MouseEvent e)
+ {
+ setPauseText(pauseButton, true);
+ }
+ });
Label speedLabel = new Label(c, SWT.NONE);
speedLabel.setText("Simulation Speed: ");
c.setVisible(true);
}
+ private void setPauseText(Button pauseButton, boolean hovered)
+ {
+ if (hovered)
+ {
+ if (pauseButton.getSelection())
+ {
+ pauseButton.setText("Pause?");
+ } else
+ {
+ pauseButton.setText("Resume?");
+ }
+ } else
+ {
+ if (pauseButton.getSelection())
+ {
+ pauseButton.setText("Running");
+ } else
+ {
+ pauseButton.setText("Paused");
+ }
+ }
+ }
+
@Override
public void setFocus()
{