Commit 791a8a2b authored by Matija Obreza's avatar Matija Obreza
Browse files

SwtUtil#showMessageBox

parent e5af0384
......@@ -230,8 +230,12 @@ public class SettingsDialog extends Dialog {
try {
genesysClient.me();
oauthSettings.setAccessToken(genesysClient.getAccessToken().getToken());
SwtUtil.showMessageBox(getParent(), "OAuth", "Tokens are up to date.");
} catch (OAuthConnectionException e) {
_log.error(e.getMessage(), e);
SwtUtil.showMessageBox(getParent(), "Problem connecting to server", "Could not access remote service at:\n" + oauthSettings.getServerUrl() + "\n\n" + e.getMessage());
} catch (OAuthAuthenticationException e) {
_log.warn(e.getMessage());
String authorizationUrl = genesysClient.getAuthorizationUrl(null);
......
......@@ -22,7 +22,6 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import org.apache.commons.lang3.StringUtils;
import org.apache.log4j.Logger;
import org.eclipse.core.databinding.Binding;
import org.eclipse.core.databinding.DataBindingContext;
......@@ -63,7 +62,6 @@ import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.MessageBox;
import org.eclipse.swt.widgets.TabFolder;
import org.eclipse.swt.widgets.TabItem;
import org.eclipse.swt.widgets.Table;
......@@ -459,7 +457,7 @@ public class SheetDisplay extends Composite {
try {
final ObjectNode jsonObject = RowConverter.toJson(map1);
final String prettyJson = mapper.writerWithDefaultPrettyPrinter().writeValueAsString(jsonObject);
showMessageBox("Genesys JSON Preview", prettyJson);
SwtUtil.showMessageBox(getShell(), "Genesys JSON Preview", prettyJson);
} catch (Exception e) {
_log.error(e.getMessage(), e);
showMessageBox("Conversion error", e);
......@@ -472,19 +470,7 @@ public class SheetDisplay extends Composite {
pw.println(e.getMessage());
e.printStackTrace(pw);
sw.flush();
showMessageBox(title, sw.toString());
}
public void showMessageBox(final String title, final String message) {
getDisplay().syncExec(new Runnable() {
@Override
public void run() {
MessageBox mb = new MessageBox(getShell());
mb.setMessage(StringUtils.defaultIfBlank(message, "?"));
mb.setText(StringUtils.defaultIfBlank(title, "A message from our sponsors"));
mb.open();
}
});
SwtUtil.showMessageBox(getShell(), title, sw.toString());
}
protected void doDataReload() {
......
package org.genesys2.anno.gui;
import org.apache.commons.lang3.StringUtils;
import org.eclipse.swt.widgets.MessageBox;
import org.eclipse.swt.widgets.Shell;
public class SwtUtil {
public static void showMessageBox(final Shell shell, final String title, final String message) {
shell.getDisplay().syncExec(new Runnable() {
@Override
public void run() {
MessageBox mb = new MessageBox(shell);
mb.setMessage(StringUtils.defaultIfBlank(message, "?"));
mb.setText(StringUtils.defaultIfBlank(title, "A message from our sponsors"));
mb.open();
}
});
}
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment