import eu.etaxonomy.cdm.api.application.CdmApplicationState;
import eu.etaxonomy.cdm.api.service.IUserService;
import eu.etaxonomy.cdm.model.metadata.CdmMetaData;
+import eu.etaxonomy.taxeditor.Messages;
import eu.etaxonomy.taxeditor.model.MessagingUtils;
import eu.etaxonomy.taxeditor.preference.IPreferenceKeys;
import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
*/
public class RemotingLoginDialog extends Dialog implements ICDMServerError {
- protected Object result;
+ private static final String UBUNTU = "Ubuntu"; //$NON-NLS-1$
+ protected Object result;
protected Shell shlConnect;
private Text txtCdmServerStatus;
private Text txtCdmInstanceStatus;
private final Map<String, CdmServerInfo> csiiMap = new HashMap<String, CdmServerInfo>();
- private final static String STATUS_AVAILABLE = "Available";
- private final static String STATUS_NOT_AVAILABLE = "Not Available";
- private final static String STATUS_STARTED = "Started";
- private final static String STATUS_NOT_STARTED = "Not Started";
- private final static String STATUS_RETRIEVING = "Retrieving ...";
- private final static String STATUS_CHECKING_AVAILABILITY = "Checking ...";
- private final static String STATUS_NO_INSTANCES = "No Instances Found";
- private final static String STATUS_ERROR = "Error";
- private final static String STATUS_REMOTING_NOT_ACTIVATED = "Remoting not activated";
- private final static String STATUS_NOT_COMPATIBLE = "Not Compatible";
+ private final static String STATUS_AVAILABLE = ""; //$NON-NLS-1$
+ private final static String STATUS_NOT_AVAILABLE = ""; //$NON-NLS-1$
+ private final static String STATUS_STARTED = ""; //$NON-NLS-1$
+ private final static String STATUS_NOT_STARTED = ""; //$NON-NLS-1$
+ private final static String STATUS_RETRIEVING = ""; //$NON-NLS-1$
+ private final static String STATUS_CHECKING_AVAILABILITY = ""; //$NON-NLS-1$
+ private final static String STATUS_NO_INSTANCES = ""; //$NON-NLS-1$
+ private final static String STATUS_ERROR = ""; //$NON-NLS-1$
+ private final static String STATUS_REMOTING_NOT_ACTIVATED = ""; //$NON-NLS-1$
+ private final static String STATUS_NOT_COMPATIBLE = ""; //$NON-NLS-1$
- private final static String MESG_COMPATIBLE_EDITOR_OLD = "Please update the Taxonomic Editor (Help->Check for Updates) or choose a compatible cdm-server";
- private final static String MESG_COMPATIBLE_SERVER_OLD = "Please choose a compatible cdm-server or update the chosen cdm-server";
+ private final static String MESG_COMPATIBLE_EDITOR_OLD = ""; //$NON-NLS-1$
+ private final static String MESG_COMPATIBLE_SERVER_OLD = ""; //$NON-NLS-1$
- private final static String STORE_PREFERENCES_NODE = "eu.etaxonomy.taxeditor.store";
+ private final static String STORE_PREFERENCES_NODE = "eu.etaxonomy.taxeditor.store"; //$NON-NLS-1$
- private final static String LOGIN_NODE = "login";
- private final static String USERNAME_SUFFIX = "_username";
- private final static String PASSWORD_SUFFIX = "_password";
+ private final static String LOGIN_NODE = "login"; //$NON-NLS-1$
+ private final static String USERNAME_SUFFIX = "_username"; //$NON-NLS-1$
+ private final static String PASSWORD_SUFFIX = "_password"; //$NON-NLS-1$
- private final static String LAST_SERVER_INSTANCE_NODE = "lastServerInstance";
- private final static String LAST_SERVER_KEY = "lastServerKey";
- private final static String LAST_INSTANCE_KEY = "lastInstanceKey";
+ private final static String LAST_SERVER_INSTANCE_NODE = "lastServerInstance"; //$NON-NLS-1$
+ private final static String LAST_SERVER_KEY = "lastServerKey"; //$NON-NLS-1$
+ private final static String LAST_INSTANCE_KEY = "lastInstanceKey"; //$NON-NLS-1$
- private final static String REFRESH_LABEL = "Refresh";
+ private final static String REFRESH_LABEL = ""; //$NON-NLS-1$
private Composite remotingComposite;
private CdmServerInfo selectedCsii;
*/
public RemotingLoginDialog(Shell parent, int style) {
super(parent, style);
- setText("Login");
+ setText(""); //$NON-NLS-1$
}
public Object open(CdmRemoteSource source, boolean loadLoginPrefs, boolean autoConnect) {
this.loadLoginPrefs = loadLoginPrefs;
this.serverName = source.getName();
String contextPath = source.getContextPath();
- this.instanceName = contextPath.substring(contextPath.lastIndexOf("/") + 1);
+ this.instanceName = contextPath.substring(contextPath.lastIndexOf("/") + 1); //$NON-NLS-1$
return open(serverName, instanceName, loadLoginPrefs, autoConnect);
}
shlConnect = new Shell(getParent(), SWT.DIALOG_TRIM);
shlConnect.setMinimumSize(new Point(MIN_WIDTH, MIN_HEIGHT));
shlConnect.setSize(MIN_WIDTH, MIN_HEIGHT);
- shlConnect.setText("Connect");
+ shlConnect.setText(""); //$NON-NLS-1$
shlConnect.setLayout(new FillLayout(SWT.HORIZONTAL));
remotingComposite = new Composite(shlConnect, SWT.NONE);
cdmServerComposite.setLayout(new GridLayout(4, false));
Label lblCdmServer = new Label(cdmServerComposite, SWT.NONE);
- lblCdmServer.setText("CDM Server : ");
- lblCdmServer.setFont(SWTResourceManager.getFont("Ubuntu", 9, SWT.NORMAL));
+ lblCdmServer.setText(""); //$NON-NLS-1$
+ lblCdmServer.setFont(SWTResourceManager.getFont(UBUNTU, 9, SWT.NORMAL));
lblCdmServer.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
comboCdmServer = new Combo(cdmServerComposite, SWT.READ_ONLY);
}
});
btnCdmServerRefresh.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
- btnCdmServerRefresh.setText("Refresh");
+ btnCdmServerRefresh.setText(""); //$NON-NLS-1$
Label lblCdmInstance = new Label(cdmServerComposite, SWT.NONE);
GridData gd_lblCdmInstance = new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1);
gd_lblCdmInstance.heightHint = 30;
lblCdmInstance.setLayoutData(gd_lblCdmInstance);
- lblCdmInstance.setText("CDM Instance : ");
- lblCdmInstance.setFont(SWTResourceManager.getFont("Ubuntu", 9, SWT.NORMAL));
+ lblCdmInstance.setText(""); //$NON-NLS-1$
+ lblCdmInstance.setFont(SWTResourceManager.getFont(UBUNTU, 9, SWT.NORMAL));
comboCdmInstance = new Combo(cdmServerComposite, SWT.READ_ONLY);
comboCdmInstance.addSelectionListener(new SelectionAdapter() {
gd_btnCdmInstanceRefresh.widthHint = 110;
gd_btnCdmInstanceRefresh.heightHint = 30;
btnCdmInstanceRefresh.setLayoutData(gd_btnCdmInstanceRefresh);
- btnCdmInstanceRefresh.setText("Refresh");
+ btnCdmInstanceRefresh.setText(""); //$NON-NLS-1$
loginComposite = new Composite(remotingComposite, SWT.NONE);
GridData gd_loginComposite = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1);
GridData gd_lblLogin = new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1);
gd_lblLogin.widthHint = 50;
lblLogin.setLayoutData(gd_lblLogin);
- lblLogin.setText("Login : ");
- lblLogin.setFont(SWTResourceManager.getFont("Ubuntu", 9, SWT.NORMAL));
+ lblLogin.setText(""); //$NON-NLS-1$
+ lblLogin.setFont(SWTResourceManager.getFont(UBUNTU, 9, SWT.NORMAL));
txtLogin = new Text(loginComposite, SWT.BORDER);
GridData gd_txtLogin = new GridData(SWT.FILL, SWT.FILL, true, false, 1, 1);
lblPassword = new Label(loginComposite, SWT.CENTER);
lblPassword.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
- lblPassword.setText("Password : ");
- lblPassword.setFont(SWTResourceManager.getFont("Ubuntu", 9, SWT.NORMAL));
+ lblPassword.setText(""); //$NON-NLS-1$
+ lblPassword.setFont(SWTResourceManager.getFont(UBUNTU, 9, SWT.NORMAL));
txtPassword = new Text(loginComposite, SWT.BORDER | SWT.PASSWORD);
GridData gd_txtPassword = new GridData(SWT.FILL, SWT.FILL, true, false, 1, 1);
}
}
});
- btnConnect.setText("Connect");
+ btnConnect.setText(""); //$NON-NLS-1$
btnRememberMe = new Button(loginComposite, SWT.CHECK);
btnRememberMe.setSelection(true);
GridData gd_btnRememberMe = new GridData(SWT.LEFT, SWT.CENTER, false, false, 2, 1);
gd_btnRememberMe.widthHint = 107;
btnRememberMe.setLayoutData(gd_btnRememberMe);
- btnRememberMe.setText("Remember Me");
+ btnRememberMe.setText(""); //$NON-NLS-1$
new Label(loginComposite, SWT.NONE);
new Label(loginComposite, SWT.NONE);
new Label(loginComposite, SWT.NONE);
styledTxtMessage = new StyledText(remotingComposite, SWT.NONE);
styledTxtMessage.setBackground(SWTResourceManager.getColor(SWT.COLOR_INFO_BACKGROUND));
styledTxtMessage.setForeground(SWTResourceManager.getColor(SWT.COLOR_DARK_RED));
- styledTxtMessage.setFont(SWTResourceManager.getFont("Ubuntu", 12, SWT.BOLD));
+ styledTxtMessage.setFont(SWTResourceManager.getFont(UBUNTU, 12, SWT.BOLD));
styledTxtMessage.setSelectionBackground(SWTResourceManager.getColor(SWT.COLOR_LIST_SELECTION_TEXT));
styledTxtMessage.setSelectionForeground(SWTResourceManager.getColor(SWT.COLOR_DARK_RED));
styledTxtMessage.setDoubleClickEnabled(false);
public void expansionStateChanging(ExpansionEvent e) {
}
});
- xpndblcmpstAdvanced.setText("advanced");
+ xpndblcmpstAdvanced.setText(""); //$NON-NLS-1$
xpndblcmpstAdvanced.setExpanded(true);
compAdvanced = new Composite(xpndblcmpstAdvanced, SWT.NONE);
lblPort = new Label(compAdvanced, SWT.CENTER);
lblPort.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
lblPort.setSize(0, 0);
- lblPort.setText("Port : ");
- lblPort.setFont(SWTResourceManager.getFont("Ubuntu", 9, SWT.NORMAL));
+ lblPort.setText(""); //$NON-NLS-1$
+ lblPort.setFont(SWTResourceManager.getFont(UBUNTU, 9, SWT.NORMAL));
txtPort = new Text(compAdvanced, SWT.BORDER);
GridData gd_txtPort = new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1);
lblServerVersion = new Label(compAdvanced, SWT.CENTER);
lblServerVersion.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
- lblServerVersion.setText("Server Cdmlib Version :");
- lblServerVersion.setFont(SWTResourceManager.getFont("Ubuntu", 9, SWT.NORMAL));
+ lblServerVersion.setText(""); //$NON-NLS-1$
+ lblServerVersion.setFont(SWTResourceManager.getFont(UBUNTU, 9, SWT.NORMAL));
txtServerVersion = new Text(compAdvanced, SWT.BORDER);
txtServerVersion.setEditable(false);
stopManagedServer();
}
});
- btnStopServer.setText("Stop Managed Server");
+ btnStopServer.setText(""); //$NON-NLS-1$
lblEditorVersion = new Label(compAdvanced, SWT.CENTER);
lblEditorVersion.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
- lblEditorVersion.setText("Editor Cdmlib Version :");
- lblEditorVersion.setFont(SWTResourceManager.getFont("Ubuntu", 9, SWT.NORMAL));
+ lblEditorVersion.setText(""); //$NON-NLS-1$
+ lblEditorVersion.setFont(SWTResourceManager.getFont(UBUNTU, 9, SWT.NORMAL));
txtEditorVersion = new Text(compAdvanced, SWT.BORDER);
txtEditorVersion.setEditable(false);
lblServerCDMVersion = new Label(compAdvanced, SWT.CENTER);
lblServerCDMVersion.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
- lblServerCDMVersion.setText("Server CDM Version :");
- lblServerCDMVersion.setFont(SWTResourceManager.getFont("Ubuntu", 9, SWT.NORMAL));
+ lblServerCDMVersion.setText(""); //$NON-NLS-1$
+ lblServerCDMVersion.setFont(SWTResourceManager.getFont(UBUNTU, 9, SWT.NORMAL));
txtServerCDMVersion = new Text(compAdvanced, SWT.BORDER);
txtServerCDMVersion.setEditable(false);
lblEditorCDMVersion = new Label(compAdvanced, SWT.CENTER);
lblEditorCDMVersion.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
- lblEditorCDMVersion.setText("Editor CDM Version :");
- lblEditorCDMVersion.setFont(SWTResourceManager.getFont("Ubuntu", 9, SWT.NORMAL));
+ lblEditorCDMVersion.setText(""); //$NON-NLS-1$
+ lblEditorCDMVersion.setFont(SWTResourceManager.getFont(UBUNTU, 9, SWT.NORMAL));
txtEditorCDMVersion = new Text(compAdvanced, SWT.BORDER);
txtEditorCDMVersion.setEditable(false);
private void populateCdmServerCombo() {
- Job job = new Job("Retrieve Server Instances") {
+ Job job = new Job("") { //$NON-NLS-1$
@Override
protected IStatus run(IProgressMonitor monitor) {
Display.getDefault().syncExec(new Runnable() {
CdmRemoteSource devRemoteSource = CdmServerInfo.getDevServerRemoteSource();
if(devRemoteSource != null) {
isDevRemoteSource = true;
- String username = System.getProperty("cdm.server.dev.username");
- String password = System.getProperty("cdm.server.dev.password");
+ String username = System.getProperty("cdm.server.dev.username"); //$NON-NLS-1$
+ String password = System.getProperty("cdm.server.dev.password"); //$NON-NLS-1$
if(username != null && !username.isEmpty() && password != null && !password.isEmpty()) {
txtLogin.setText(username);
txtPassword.setText(password);
}
private void updatePort() {
- txtPort.setText("");
+ txtPort.setText(""); //$NON-NLS-1$
if(selectedCsii != null) {
int port = selectedCsii.getPort();
if(port == CdmServerInfo.NULL_PORT) {
port = Integer.valueOf(txtPort.getText());
} catch (NumberFormatException nfe) {
if(!CdmServerInfo.NULL_PORT_STRING.equals(txtPort.getText())) {
- setMessage("Port should be an integer");
+ setMessage(""); //$NON-NLS-1$
}
}
return port;
txtCdmServerStatus.setText(STATUS_AVAILABLE);
populateCdmInstanceCombo(true);
String serverVersionTimestamp = generateLastModifiedTooltip(selectedCsii.getCdmlibLastModified());
- txtServerVersion.setText(selectedCsii.getCdmlibServicesVersion() + ":" + serverVersionTimestamp);
+ txtServerVersion.setText(selectedCsii.getCdmlibServicesVersion() + ":" + serverVersionTimestamp); //$NON-NLS-1$
} else {
txtCdmServerStatus.setText(STATUS_NOT_AVAILABLE);
comboCdmInstance.removeAll();
- disableCdmInstanceControls("", "");
+ disableCdmInstanceControls("", ""); //$NON-NLS-1$ //$NON-NLS-2$
}
}
updatePort();
comboCdmInstance.setEnabled(false);
btnConnect.setEnabled(false);
txtCdmInstanceStatus.setText(STATUS_RETRIEVING);
- txtCdmInstanceStatus.setToolTipText("");
+ txtCdmInstanceStatus.setToolTipText(""); //$NON-NLS-1$
- serverJob = new Job("Retrieve Server Instances") {
+ serverJob = new Job("") { //$NON-NLS-1$
@Override
protected IStatus run(IProgressMonitor monitor) {
try {
}
- Job job = new Job("Managed CDM Server Launch") {
+ Job job = new Job(Messages.RemotingLoginDialog_JOB_SERVER_LAUNCH) {
@Override
public IStatus run(IProgressMonitor monitor) {
- String mgdServerConfigFileName = "mgd.datasources.xml";
+ String mgdServerConfigFileName = "mgd.datasources.xml"; //$NON-NLS-1$
String config = CDMServerUtils.convertEditorToServerConfig();
File managedServerConfigFile;
int maxUnits = 50;
- monitor.beginTask("Launching Managed CDM Server", maxUnits);
+ monitor.beginTask(Messages.RemotingLoginDialog_TASK_LAUNCHING_SERVER, maxUnits);
try {
- monitor.subTask("Generating datasources config file for " + selectedCdmInstance.getName());
+ monitor.subTask(String.format(Messages.RemotingLoginDialog_GENERATING_CONFIG_FILE, selectedCdmInstance.getName()));
managedServerConfigFile = CDMServerUtils.writeManagedServerConfig(config, mgdServerConfigFileName);
monitor.worked(1);
CdmStore.setManagedServer(new CDMServer(selectedCdmInstance.getName(), managedServerConfigFile));
- monitor.subTask("Starting Managed CDM Server. This may take a while.");
+ monitor.subTask(Messages.RemotingLoginDialog_STARTING_MGD_SERVER);
CdmStore.getManagedServer().start(false, RemotingLoginDialog.this);
int serverUnits = 0;
}
});
} catch (IOException ioe) {
- MessagingUtils.errorDialog("Error generating server config file",
+ MessagingUtils.errorDialog(Messages.RemotingLoginDialog_ERROR_GENERATING_CONFIG_FILE,
this,
ioe.getMessage(),
TaxeditorStorePlugin.PLUGIN_ID,
ioe,
true);
} catch (CDMEmbeddedServerException cse) {
- MessagingUtils.errorDialog("Error starting managed server",
+ MessagingUtils.errorDialog(Messages.RemotingLoginDialog_ERROR_STARTING_SERVER,
this,
cse.getMessage(),
TaxeditorStorePlugin.PLUGIN_ID,
try {
CdmStore.getManagedServer().stop();
} catch (Exception e) {
- MessagingUtils.errorDialog("Error stopping managed server",
+ MessagingUtils.errorDialog(Messages.RemotingLoginDialog_ERROR_STOPPING_SERVER,
this,
- "Could not stop managed server running at port " + CdmStore.getManagedServer().getPort() + ". Please stop it manually",
+ String.format(Messages.RemotingLoginDialog_COULD_NOT_STOP_SERVER, CdmStore.getManagedServer().getPort()),
TaxeditorStorePlugin.PLUGIN_ID,
e,
true);
} else {
status = STATUS_AVAILABLE;
available = true;
- message = "";
+ message = ""; //$NON-NLS-1$
}
}
} catch (Exception e) {
String username, password;
IEclipsePreferences preferences = ConfigurationScope.INSTANCE.getNode(STORE_PREFERENCES_NODE);
Preferences credentialsPrefs = preferences.node(LOGIN_NODE);
- username = credentialsPrefs.get(getUsernamePrefKey(), "");
+ username = credentialsPrefs.get(getUsernamePrefKey(), ""); //$NON-NLS-1$
txtLogin.setText(username);
- password = credentialsPrefs.get(getPasswordPrefKey(),"");
+ password = credentialsPrefs.get(getPasswordPrefKey(),""); //$NON-NLS-1$
txtPassword.setText(password);
if(username.isEmpty() || password.isEmpty()) {
autoConnect = false;
}
private void emptyCredentials() {
- txtLogin.setText("");
- txtPassword.setText("");
+ txtLogin.setText(""); //$NON-NLS-1$
+ txtPassword.setText(""); //$NON-NLS-1$
}
private String getUsernamePrefKey() {
private boolean validateLogin(ICdmRemoteSource remoteSource) {
if(getUsername() == null || getUsername().isEmpty()) {
- setMessage("User login cannot be empty");
+ setMessage(""); //$NON-NLS-1$
return false;
}
if(getPassword() == null || getPassword().isEmpty()) {
- setMessage("Password cannot be empty");
+ setMessage(""); //$NON-NLS-1$
return false;
}
if(message != null && !message.isEmpty()) {
if(message.length() > 60) {
styledTxtMessage.setToolTipText(message);
- message = message.substring(0, 60) + "...";
+ message = message.substring(0, 60) + "..."; //$NON-NLS-1$
}
styledTxtMessage.setText(message);
styledTxtMessage.setVisible(true);
shlConnect.setSize(MIN_WIDTH, getHeightWithoutMessage() + MESSAGE_HEIGHT);
shlConnect.setMinimumSize(MIN_WIDTH, getHeightWithoutMessage() + MESSAGE_HEIGHT);
} else {
- styledTxtMessage.setText("");
+ styledTxtMessage.setText(""); //$NON-NLS-1$
styledTxtMessage.setVisible(false);
((GridData)styledTxtMessage.getLayoutData()).exclude = true;
shlConnect.setSize(MIN_WIDTH, getHeightWithoutMessage());
private String generateLastModifiedTooltip(String cdmlibLastModified) {
if(StringUtils.isBlank(cdmlibLastModified)) {
- return "";
+ return ""; //$NON-NLS-1$
}
- SimpleDateFormat sdf = new SimpleDateFormat("yyyy.MM.dd.HH.mm.z");
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy.MM.dd.HH.mm.z"); //$NON-NLS-1$
Date cdmlibLastModifiedDate;
- String cdmlibLastModifiedTimestamp = "";
+ String cdmlibLastModifiedTimestamp = ""; //$NON-NLS-1$
cdmlibLastModifiedDate = new Date(Long.valueOf(cdmlibLastModified));
cdmlibLastModifiedTimestamp = sdf.format(cdmlibLastModifiedDate);
private void setEditorInfo() {
txtEditorCDMVersion.setText(CdmMetaData.getDbSchemaVersion());
String editorVersionTimestamp = generateLastModifiedTooltip(CdmApplicationState.getCdmlibLastModified());
- txtEditorVersion.setText(CdmApplicationState.getCdmlibVersion() + ":" + editorVersionTimestamp);
+ txtEditorVersion.setText(CdmApplicationState.getCdmlibVersion() + ":" + editorVersionTimestamp); //$NON-NLS-1$
}
private void clearOnServerChange() {
- setMessage("");
- txtServerCDMVersion.setText("");
- txtServerVersion.setText("");
- txtServerVersion.setToolTipText("");
- txtServerCDMVersion.setText("");
+ setMessage(""); //$NON-NLS-1$
+ txtServerCDMVersion.setText(""); //$NON-NLS-1$
+ txtServerVersion.setText(""); //$NON-NLS-1$
+ txtServerVersion.setToolTipText(""); //$NON-NLS-1$
+ txtServerCDMVersion.setText(""); //$NON-NLS-1$
comboCdmInstance.removeAll();
- txtCdmInstanceStatus.setText("");
+ txtCdmInstanceStatus.setText(""); //$NON-NLS-1$
txtPort.setEditable(false);
txtPort.setEnabled(false);
}
private void clearOnInstanceChange() {
- setMessage("");
- txtServerCDMVersion.setText("");
+ setMessage(""); //$NON-NLS-1$
+ txtServerCDMVersion.setText(""); //$NON-NLS-1$
}
/**
public void run() {
serverJob.cancel();
- String title = "CDM Server launch error";
+ String title = ""; //$NON-NLS-1$
String message = t.getMessage();