@Override
public void exception(final Throwable t) {
- SWTUtils.asyncExec(button, new Runnable() {
-
- @Override
- public void run() {
- if(isDisposed()) return;
-// System.out.println("Button received new text: " + text);
- button.setText(t.toString());
- }
-
+ SWTUtils.asyncExec(button, () -> {
+ if(isDisposed()) return;
+// System.out.println("Button received new text: " + text);
+ button.setText(t.toString());
});
}
@Override
public void execute(final String text) {
- SWTUtils.asyncExec(button, new Runnable() {
-
- @Override
- public void run() {
- if(isDisposed()) return;
-// System.out.println("Button received new text: " + text);
- button.setText(text);
- }
-
+ SWTUtils.asyncExec(button, () -> {
+ if(isDisposed()) return;
+// System.out.println("Button received new text: " + text);
+ button.setText(text);
});
}
@Override
public void execute(final String text) {
- SWTUtils.asyncExec(button, new Runnable() {
-
- @Override
- public void run() {
- if(isDisposed()) return;
-// System.out.println("Button received new tooltip: " + text);
- button.setToolTipText(text);
- }
-
+ SWTUtils.asyncExec(button, () -> {
+ if(isDisposed()) return;
+// System.out.println("Button received new tooltip: " + text);
+ button.setToolTipText(text);
});
}
@Override
public void execute(final ImageDescriptor imageDescriptor) {
- SWTUtils.asyncExec(button, new Runnable() {
-
- @Override
- public void run() {
-
- if(isDisposed()) return;
-// System.out.println("Button received new image");
- ResourceManager rm = support.getParameter(WidgetSupport.RESOURCE_MANAGER);
- if (rm != null) {
- Image image = (Image) rm.get(imageDescriptor);
- button.setImage(image);
- }
- // TODO: how can we resize without this knife??
- button.getParent().layout();
- button.getParent().getParent().layout();
-
+ SWTUtils.asyncExec(button, () -> {
+ if(isDisposed()) return;
+// System.out.println("Button received new image");
+ ResourceManager rm = support.getParameter(WidgetSupport.RESOURCE_MANAGER);
+ if (rm != null) {
+ Image image = (Image) rm.get(imageDescriptor);
+ button.setImage(image);
}
-
+ // TODO: how can we resize without this knife??
+ button.getParent().layout();
+ button.getParent().getParent().layout();
});
}
}
@Override
public void execute(final Boolean selected) {
- SWTUtils.asyncExec(button, new Runnable() {
- @Override
- public void run() {
- if(isDisposed()) return;
- button.setSelection(selected);
- }
+ SWTUtils.asyncExec(button, () -> {
+ if(isDisposed()) return;
+ button.setSelection(Boolean.TRUE.equals(selected));
});
}
@Override
}
public <T> void setText(final ParametrizedRead<T, String> read) {
-
- Simantics.getSession().async(new UniqueRead<String>() {
-
- @Override
- public String perform(ReadGraph graph) throws DatabaseException {
- T input = support.getInput(graph);
- return graph.syncRequest(read.get(input));
- }
-
- }, new Listener<String>() {
-
- @Override
- public void exception(Throwable t) {
- t.printStackTrace();
- }
-
- @Override
- public void execute(final String text) {
-
- if(isDisposed()) return;
-
- button.getDisplay().asyncExec(new Runnable() {
-
- @Override
- public void run() {
- button.setText(text);
- }
-
- });
- }
-
- @Override
- public boolean isDisposed() {
- return button.isDisposed();
- }
+ Simantics.getSession().async(new UniqueRead<String>() {
+ @Override
+ public String perform(ReadGraph graph) throws DatabaseException {
+ T input = support.getInput(graph);
+ return graph.syncRequest(read.get(input));
+ }
+ }, new Listener<String>() {
+ @Override
+ public void exception(Throwable t) {
+ ErrorLogger.defaultLogError(t);
+ }
- });
+ @Override
+ public void execute(final String text) {
+ if(isDisposed()) return;
+ button.getDisplay().asyncExec(() -> {
+ if(isDisposed()) return;
+ button.setText(text);
+ });
+ }
+ @Override
+ public boolean isDisposed() {
+ return button.isDisposed();
+ }
+ });
}
-
+
public void setTooltipText(String text) {
button.setToolTipText(text);
}