Skip to content

Commit

Permalink
Merge branch 'master' into github
Browse files Browse the repository at this point in the history
  • Loading branch information
dofs197 committed Aug 2, 2020
2 parents 7a8fce6 + 3ed1c7f commit 913df4b
Show file tree
Hide file tree
Showing 15 changed files with 731 additions and 139 deletions.
2 changes: 1 addition & 1 deletion src/main/assembly/run.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#export MOZILLA_FIVE_HOME=/usr/lib/firefox
#export LD_LIBRARY_PATH=/usr/lib/firefox

java -Dorg.eclipse.swt.browser.UseWebKitGTK=true -cp ".:rtn.jar:swt-gtk.jar" ru.runa.notifier.PlatformLoader
java -Dorg.eclipse.swt.browser.UseWebKitGTK=true -Drtn.log.dir="$HOME" -cp ".:rtn.jar:swt-gtk.jar" ru.runa.notifier.PlatformLoader
7 changes: 6 additions & 1 deletion src/main/java/ru/runa/notifier/GUI.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
import ru.runa.notifier.util.AePlayWave;
import ru.runa.notifier.util.ImageManager;
import ru.runa.notifier.util.ResourcesManager;
import ru.runa.notifier.util.Setting;
import ru.runa.notifier.util.WidgetsManager;
import ru.runa.notifier.view.ViewChangeListener;

Expand All @@ -67,8 +68,11 @@ public class GUI implements PropertyChangeListener, ViewChangeListener, Location

private static BrowserView browserView;

public static final Setting setting = Setting.SETTING;

public GUI(Display display, Shell splashShell) {
GUI.display = display;
setting.read();
initComponents();
splashShell.dispose();
}
Expand Down Expand Up @@ -135,7 +139,8 @@ public boolean isChangeUrl() {
public void openStartPage() {
if (isChangeUrl()) {
String targetUrl;
String serverUrl = ResourcesManager.getHttpServerUrl();
Setting.SETTING.getUrl();
String serverUrl = GUI.setting.getUrl() + "/wfe";
if (LoginHelper.getWebParameters() == null || LoginHelper.getWebParameters().length() == 0) {
targetUrl = serverUrl + ResourcesManager.getLoginRelativeUrl();
} else {
Expand Down
82 changes: 41 additions & 41 deletions src/main/java/ru/runa/notifier/PlatformLoader.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
*/

package ru.runa.notifier;

import org.apache.commons.logging.Log;
Expand All @@ -31,53 +30,54 @@

/**
* Created on 2006
*
*
* @author Gritsenko_S
*/
public class PlatformLoader {

private static final Log log = LogFactory.getLog(PlatformLoader.class);

private Display display;
private Shell invisibleShell;
private PlatformLoader() {
Display.setAppName("RUNA Task Notifier");
display = new Display();
invisibleShell = new Shell(display, SWT.NONE);
ImageManager.initIcons();

Shell shell = new Shell(invisibleShell, SWT.TOOL);
FillLayout fillLayout = new FillLayout();
fillLayout.marginHeight = 0;
fillLayout.marginWidth = 0;
shell.setLayout(fillLayout);
Label label = new Label(shell, SWT.NONE);
label.setImage(ImageManager.imageSplash);
shell.pack();
shell.setText("SWT RUNA");
Rectangle displayBounds = display.getPrimaryMonitor().getBounds();
Rectangle shellBounds = shell.getBounds();
int x = displayBounds.x + (displayBounds.width - shellBounds.width) >> 1;
int y = displayBounds.y + (displayBounds.height - shellBounds.height) >> 1;
shell.setLocation(x, y);
shell.open();
new GUI(display, invisibleShell).showGui();
}

public static void main(String[] args) {
try {
private Display display;
private Shell invisibleShell;

private PlatformLoader() {
Display.setAppName("RUNA Task Notifier");

display = new Display();

invisibleShell = new Shell(display, SWT.NONE);

ImageManager.initIcons();

Shell shell = new Shell(invisibleShell, SWT.TOOL);
FillLayout fillLayout = new FillLayout();
fillLayout.marginHeight = 0;
fillLayout.marginWidth = 0;
shell.setLayout(fillLayout);

Label label = new Label(shell, SWT.NONE);
label.setImage(ImageManager.imageSplash);

shell.pack();

shell.setText("SWT RUNA");

Rectangle displayBounds = display.getPrimaryMonitor().getBounds();
Rectangle shellBounds = shell.getBounds();
int x = displayBounds.x + (displayBounds.width - shellBounds.width) >> 1;
int y = displayBounds.y + (displayBounds.height - shellBounds.height) >> 1;
shell.setLocation(x, y);

shell.open();

new GUI(display, invisibleShell).showGui();
}

public static void main(String[] args) {
try {
new PlatformLoader();
} catch (Throwable th) {
log.error("Critical error", th);
}
}
}
}
2 changes: 1 addition & 1 deletion src/main/java/ru/runa/notifier/WFEConnection.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public class WFEConnection {

private static URL getUrl(String serviceName) {
try {
String url = ResourcesManager.getWebServiceUrl();
String url = GUI.setting.getUrl() + ResourcesManager.getWebServiceUrl();
url = url.replaceAll("SERVICE_NAME", serviceName);
log.debug("Using " + url);
return new URL(url);
Expand Down
5 changes: 1 addition & 4 deletions src/main/java/ru/runa/notifier/auth/LoginHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,11 @@

import java.util.HashMap;
import java.util.Map;

import javax.security.auth.login.Configuration;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.MessageBox;

import ru.runa.notifier.GUI;
import ru.runa.notifier.util.ClassLoaderUtil;
import ru.runa.notifier.util.ResourcesManager;
Expand Down Expand Up @@ -71,7 +68,7 @@ public static void login() {
if (!tryLogin) {
return;
}
String authType = ResourcesManager.getAuthenticationType();
String authType = GUI.setting.getAuthenticationType();
Authenticator authenticator = ClassLoaderUtil.instantiate(authenticators.get(authType));
while (user == null) {
if (!tryLogin) {
Expand Down
47 changes: 30 additions & 17 deletions src/main/java/ru/runa/notifier/auth/UserInputAuthenticator.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@

import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.KeyEvent;
import org.eclipse.swt.events.KeyListener;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
Expand All @@ -16,16 +17,17 @@
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.Link;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;

import ru.runa.notifier.GUI;
import ru.runa.notifier.WFEConnection;
import ru.runa.notifier.util.ResourcesManager;
import ru.runa.notifier.util.SettingDialog;
import ru.runa.wfe.webservice.User;

public class UserInputAuthenticator implements Authenticator {

private static final Log log = LogFactory.getLog(UserInputAuthenticator.class);

private String login = null;
Expand All @@ -34,10 +36,10 @@ public class UserInputAuthenticator implements Authenticator {
@Override
public User authenticate() throws Exception {
try {
if (ResourcesManager.isLoginSilently()) {
if (GUI.setting.isLoginSilently()) {
try {
login = ResourcesManager.getDefaultLogin();
password = ResourcesManager.getDefaultPassword();
login = GUI.setting.getLogin();
password = GUI.setting.getPassword();
return WFEConnection.getAuthenticationAPI().authenticateByLoginPassword(login, password);
} catch (Exception e) {
log.warn("Auth with default credentials failed, requesting", e);
Expand Down Expand Up @@ -89,6 +91,7 @@ public boolean isRetryDialogEnabled() {
}

public class LoginDialog extends Dialog {

private String[] returnValue = null;
private Shell shell;
private Text loginField;
Expand Down Expand Up @@ -121,17 +124,27 @@ public String[] open() {
passwordField = new Text(composite, SWT.BORDER | SWT.PASSWORD);
passwordField.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

Button buttonLogin = new Button(shell, SWT.PUSH);
buttonLogin.setText(ResourcesManager.getLoginMessage());
Link settingsLink = new Link(composite, SWT.NONE);
settingsLink.setText("<a>" + ResourcesManager.getLabelSetting() + "</a>");

settingsLink.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
SettingDialog settingsDialog = new SettingDialog(shell);
settingsDialog.open();
}
});

Button buttonLogin = new Button(composite, SWT.PUSH);
GridData buttonData = new GridData(GridData.FILL_HORIZONTAL);
buttonData.widthHint = 100;
buttonData.widthHint = 120;
buttonData.heightHint = 36;

buttonData.horizontalAlignment = GridData.END;
buttonLogin.setLayoutData(buttonData);
buttonLogin.addListener(SWT.Selection, new Listener() {
@Override
public void handleEvent(Event event) {
harvestDataAndClose();
}
buttonLogin.setText(ResourcesManager.getLoginMessage());
buttonLogin.addListener(SWT.Selection, (Event event) -> {
harvestDataAndClose();
});

loginField.addKeyListener(new KeyListener() {
Expand Down Expand Up @@ -159,8 +172,8 @@ public void keyReleased(KeyEvent keyEvent) {
}
});

loginField.setText(ResourcesManager.getDefaultLogin());
passwordField.setText(ResourcesManager.getDefaultPassword());
loginField.setText(GUI.setting.getLogin());
passwordField.setText(GUI.setting.getPassword());

loginField.setFocus();

Expand All @@ -178,7 +191,7 @@ public void keyReleased(KeyEvent keyEvent) {
}

private void harvestDataAndClose() {
returnValue = new String[] { loginField.getText(), passwordField.getText() };
returnValue = new String[]{loginField.getText(), passwordField.getText()};
shell.dispose();
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/ru/runa/notifier/checker/TaskChecker.java
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ public TaskChecker(SystemTray systemTray) {

public void start() {
timer1 = new Timer();
timer1.schedule(tasksChecker, 0, ResourcesManager.getCheckTasksTimeout());
int unreadTasksNotification = ResourcesManager.getUnreadTasksNotificationTimeout();
timer1.schedule(tasksChecker, 0, GUI.setting.getCheckTasksTimeout());
int unreadTasksNotification = GUI.setting.getUnreadTasksNotificationTimeout();
if (unreadTasksNotification > 0) {
timer2 = new Timer();
timer2.schedule(unreadTaskNotifier, unreadTasksNotification, unreadTasksNotification);
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/ru/runa/notifier/tray/SystemTrayAlert.java
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ private void startAutoCloseThread() {
if (autoClosePopup != null && !autoClosePopup.isStopped()) {
autoClosePopup.stopThread();
}
final int timeout = ResourcesManager.getAutoClosePopupTimeout();
final int timeout = GUI.setting.getAutoClosePopupTimeout();
if (timeout <= 0) {
return;
}
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/ru/runa/notifier/util/AePlayWave.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import ru.runa.notifier.GUI;

public class AePlayWave extends Thread {
private static final Log log = LogFactory.getLog(AePlayWave.class);
Expand Down Expand Up @@ -50,7 +51,7 @@ public void run() {
}

public static void playNotification(String wavFile) {
if (ResourcesManager.isSoundsEnabled()) {
if (GUI.setting.isSoundsEnabled()) {
new AePlayWave(wavFile).start();
}
}
Expand Down
41 changes: 0 additions & 41 deletions src/main/java/ru/runa/notifier/util/AppServerType.java

This file was deleted.

Loading

0 comments on commit 913df4b

Please sign in to comment.