Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'proctools/plugins/org.eclipse.sequoyah.device.linuxtools.base/src/org/eclipse/sequoyah/linuxtools/ui/DialogLogin.java')
-rw-r--r--proctools/plugins/org.eclipse.sequoyah.device.linuxtools.base/src/org/eclipse/sequoyah/linuxtools/ui/DialogLogin.java127
1 files changed, 127 insertions, 0 deletions
diff --git a/proctools/plugins/org.eclipse.sequoyah.device.linuxtools.base/src/org/eclipse/sequoyah/linuxtools/ui/DialogLogin.java b/proctools/plugins/org.eclipse.sequoyah.device.linuxtools.base/src/org/eclipse/sequoyah/linuxtools/ui/DialogLogin.java
new file mode 100644
index 0000000000..ee77f1a131
--- /dev/null
+++ b/proctools/plugins/org.eclipse.sequoyah.device.linuxtools.base/src/org/eclipse/sequoyah/linuxtools/ui/DialogLogin.java
@@ -0,0 +1,127 @@
+/********************************************************************************
+ * Copyright (c) 2008 Motorola Inc. All rights reserved.
+ * This program and the accompanying materials are made available under the terms
+ * of the Eclipse Public License v1.0 which accompanies this distribution, and is
+ * available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Initial Contributor:
+ * Otávio Ferranti (Motorola)
+ *
+ * Contributors:
+ * {Name} (company) - description of contribution.
+ ********************************************************************************/
+
+package org.eclipse.tml.linuxtools.ui;
+
+import org.eclipse.tml.linuxtools.tools.ITool;
+
+import org.eclipse.jface.dialogs.TitleAreaDialog;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Text;
+
+/**
+ * @author Otávio Ferranti
+ */
+public class DialogLogin extends TitleAreaDialog {
+
+ final private String WINDOW_TITLE = Messages.LoginDialog_Window_Title;
+ final private String WINDOW_MESSAGE = Messages.LoginDialog_Window_Message;
+ final private String WINDOW_MESSAGE_LOGIN_INVALID =
+ Messages.LoginDialog_Msg_Login_Invalid;
+ final private String LABEL_USER = Messages.LoginDialog_Label_User;
+ final private String LABEL_PASSWORD = Messages.LoginDialog_Label_Password;
+
+ private Text userText;
+ private Text passwordText;
+
+ private ITool tool;
+ private boolean login_retry = false;
+
+ /**
+ * The constructor.
+ * @param parentShell
+ * @param tool
+ */
+ public DialogLogin(Shell parentShell, ITool tool) {
+ this(parentShell, tool, false);
+ }
+
+ /**
+ * The other constructor.
+ * @param parentShell
+ * @param tool
+ * @param login_retry
+ */
+ public DialogLogin(Shell parentShell, ITool tool, boolean login_retry) {
+ super(parentShell);
+ this.login_retry = login_retry;
+ this.tool = tool;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.dialogs.TitleAreaDialog#createDialogArea(org.eclipse.swt.widgets.Composite)
+ */
+ protected Control createDialogArea(Composite parent) {
+ setTitle(WINDOW_TITLE);
+
+ if (login_retry) {
+ setErrorMessage(WINDOW_MESSAGE_LOGIN_INVALID);
+ } else {
+ setMessage(WINDOW_MESSAGE);
+ }
+
+ Composite dialogArea = new Composite(parent, SWT.NONE);
+ GridLayout gridLayout = new GridLayout(2, false);
+
+ gridLayout.marginLeft = 7;
+ gridLayout.marginRight = 7;
+
+ dialogArea.setLayout(gridLayout);
+ dialogArea.setLayoutData(new GridData(GridData.FILL_BOTH));
+ dialogArea.setFont(parent.getFont());
+
+ GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
+
+ Label hostLabel = new Label(dialogArea, SWT.NULL);
+ hostLabel.setText(LABEL_USER);
+ userText = new Text(dialogArea, SWT.BORDER);
+ userText.setLayoutData(gridData);
+
+ Label portLabel = new Label(dialogArea, SWT.NULL);
+ portLabel.setText(LABEL_PASSWORD);
+ passwordText = new Text(dialogArea, SWT.BORDER | SWT.PASSWORD);
+ passwordText.setLayoutData(gridData);
+
+ return dialogArea;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.dialogs.TitleAreaDialog#getInitialSize()
+ */
+ protected Point getInitialSize() {
+ return super.getInitialSize();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.dialogs.Dialog#okPressed()
+ */
+ protected void okPressed() {
+ tool.login(userText.getText(), passwordText.getText());
+ super.okPressed();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.dialogs.Dialog#cancelPressed()
+ */
+ protected void cancelPressed() {
+ tool.disconnect();
+ super.cancelPressed();
+ }
+}

Back to the top