public Control createControl(Composite parent) { Composite comp = new Composite(parent, SWT.NONE); comp.setLayout(new GridLayout(3, false)); comp.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); fButton = new Button(comp, SWT.CHECK); fButton.setText(PDEUIMessages.AdvancedPluginExportPage_signButton); GridData gd = new GridData(); gd.horizontalSpan = 3; fButton.setLayoutData(gd); fButton.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { updateGroup(fButton.getSelection()); fPage.pageChanged(); } }); fKeystoreLabel = createLabel(comp, PDEUIMessages.AdvancedPluginExportPage_keystore); fKeystoreText = createText(comp, 1); fBrowseButton = new Button(comp, SWT.PUSH); fBrowseButton.setText(PDEUIMessages.ExportWizard_browse); fBrowseButton.setLayoutData(new GridData()); SWTUtil.setButtonDimensionHint(fBrowseButton); fBrowseButton.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { FileDialog dialog = new FileDialog(fPage.getShell(), SWT.OPEN); String path = fKeystoreText.getText(); if (path.trim().length() == 0) path = PDEPlugin.getWorkspace().getRoot().getLocation().toString(); dialog.setFileName(path); String res = dialog.open(); if (res != null) { fKeystoreText.setText(res); } } }); fKeypassLabel = createLabel(comp, PDEUIMessages.JARSigningTab_keypass); fKeypassText = createText(comp, 2); fKeypassText.setEchoChar('*'); fAliasLabel = createLabel(comp, PDEUIMessages.AdvancedPluginExportPage_alias); fAliasText = createText(comp, 2); fPasswordLabel = createLabel(comp, PDEUIMessages.AdvancedPluginExportPage_password); fPasswordText = createText(comp, 2); fPasswordText.setEchoChar('*'); Dialog.applyDialogFont(comp); PlatformUI.getWorkbench().getHelpSystem().setHelp(comp, IHelpContextIds.ADVANCED_PLUGIN_EXPORT); return comp; }
/** * Returns this field editor's text control. * * <p>The control is created if it does not yet exist * * @param parent the parent * @return the text control */ public Text getTextControl(Composite parent) { if (textField == null) { textField = new Text(parent, SWT.SINGLE | SWT.BORDER); textField.setEchoChar('*'); textField.setFont(parent.getFont()); switch (validateStrategy) { case VALIDATE_ON_KEY_STROKE: textField.addKeyListener( new KeyAdapter() { /** {@inheritDoc} */ @Override public void keyReleased(KeyEvent e) { valueChanged(); } }); break; case VALIDATE_ON_FOCUS_LOST: textField.addKeyListener( new KeyAdapter() { @Override public void keyPressed(KeyEvent e) { clearErrorMessage(); } }); textField.addFocusListener( new FocusAdapter() { @Override public void focusGained(FocusEvent e) { refreshValidState(); } @Override public void focusLost(FocusEvent e) { valueChanged(); clearErrorMessage(); } }); break; default: Assert.isTrue(false, "Unknown validate strategy"); // $NON-NLS-1$ } textField.addDisposeListener( new DisposeListener() { @Override public void widgetDisposed(DisposeEvent event) { textField = null; } }); if (textLimit > 0) { // Only set limits above 0 - see SWT spec textField.setTextLimit(textLimit); } } else { checkParent(textField, parent); } return textField; }
@Test public void testEchoChar() { // single line text field Text singleText = new Text(shell, SWT.NONE); assertEquals((char) 0, singleText.getEchoChar()); singleText.setEchoChar('?'); assertEquals('?', singleText.getEchoChar()); // multi line text field Text multiText = new Text(shell, SWT.MULTI); assertEquals((char) 0, multiText.getEchoChar()); multiText.setEchoChar('?'); assertEquals((char) 0, multiText.getEchoChar()); // password text field Text passwordText = new Text(shell, SWT.PASSWORD); assertEquals('?', passwordText.getEchoChar()); passwordText.setEchoChar('*'); assertEquals('*', passwordText.getEchoChar()); }
/** * Create contents of the wizard * * @param parent */ public void createControl(Composite parent) { Composite container = new Composite(parent, SWT.NULL); final GridLayout gridLayout = new GridLayout(); gridLayout.numColumns = 2; container.setLayout(gridLayout); // setControl(container); final Label hotnameLabel = new Label(container, SWT.NONE); hotnameLabel.setText("Hostname"); hostnameText = new Text(container, SWT.BORDER); hostnameText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); final Label usernameLabel = new Label(container, SWT.NONE); usernameLabel.setText("Username"); usernameText = new Text(container, SWT.BORDER); usernameText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); final Label passwordLabel = new Label(container, SWT.NONE); passwordLabel.setText("Password"); passwordText = new Text(container, SWT.BORDER); passwordText.setEchoChar('*'); passwordText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); final Label portLabel = new Label(container, SWT.NONE); portLabel.setText("Port"); portText = new Text(container, SWT.BORDER); portText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); final DataBindingContext dbc = new DataBindingContext(); dbc.bindValue( SWTObservables.observeText(hostnameText, SWT.Modify), BeansObservables.observeValue(server, "hostname"), new UpdateValueStrategy().setAfterConvertValidator(new HostnameValidator()), null); dbc.bindValue( SWTObservables.observeText(usernameText, SWT.Modify), BeansObservables.observeValue(server, "username"), new UpdateValueStrategy().setAfterConvertValidator(new NotEmptyValidator("username")), null); dbc.bindValue( SWTObservables.observeText(passwordText, SWT.Modify), BeansObservables.observeValue(server, "password"), new UpdateValueStrategy().setAfterConvertValidator(new NotEmptyValidator("password")), null); dbc.bindValue( SWTObservables.observeText(portText, SWT.Modify), BeansObservables.observeValue(server, "port"), null, null); }
private Control getConsumerTabControl(Composite tabFolder) { Composite composite = new Composite(tabFolder, SWT.NONE); GridLayout gl = new GridLayout(2, false); composite.setLayout(gl); _nameText = createLabelAndText(composite, Messages.label_name); _hostText = createLabelAndText(composite, Messages.label_hostStar); _portText = createLabelAndText(composite, Messages.label_port); _usernameText = createLabelAndText(composite, Messages.label_userName); _passwordText = createLabelAndText(composite, Messages.label_password); _passwordText.setEchoChar('*'); _securedCheckbox = createCheckbox(composite, Messages.label_secured, 2); Group consumeGroup = new Group(composite, SWT.NONE); consumeGroup.setLayoutData(new GridData(SWT.FILL, SWT.BEGINNING, true, false, 2, 1)); consumeGroup.setLayout(new GridLayout(2, false)); consumeGroup.setText(Messages.label_consumerOptions); getToolkit().createLabel(consumeGroup, Messages.label_accountType, SWT.NONE); _accountTypeCombo = new ComboViewer(consumeGroup); _accountTypeCombo.getControl().setLayoutData(new GridData(SWT.FILL, SWT.NONE, true, false)); _accountTypeCombo.setContentProvider(ArrayContentProvider.getInstance()); _accountTypeCombo.setLabelProvider(new LabelProvider()); MailConsumerAccountType[] accountTypes = new MailConsumerAccountType[] {MailConsumerAccountType.IMAP, MailConsumerAccountType.POP3}; _accountTypeCombo.setInput(accountTypes); getToolkit().adapt(_accountTypeCombo.getControl(), true, true); _folderNameText = createLabelAndText(consumeGroup, Messages.label_folderName); _fetchSizeText = createLabelAndText(consumeGroup, Messages.label_fetchSize, 2); _unseenCheckbox = createCheckbox(consumeGroup, Messages.label_unreadOnly, 2); _deleteCheckbox = createCheckbox(consumeGroup, Messages.label_delete, 2); _opSelectorComposite = new OperationSelectorComposite(composite, SWT.NONE, this); _opSelectorComposite.setLayoutData(new GridData(SWT.FILL, SWT.BEGINNING, true, false, 2, 1)); _opSelectorComposite.setLayout(new GridLayout(2, false)); _opSelectorComposite.addChangeListener( new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { handleModify(_opSelectorComposite); } }); return composite; }
/** * Create contents of the dialog * * @param parent */ @Override protected Control createDialogArea(Composite parent) { // TODO get properties from file to save settings Composite container = (Composite) super.createDialogArea(parent); final GridLayout gridLayout = new GridLayout(); gridLayout.numColumns = 2; container.setLayout(gridLayout); final Label pleaseLoginToLabel = new Label(container, SWT.NONE); final GridData gridData = new GridData(SWT.LEFT, SWT.FILL, false, false); gridData.heightHint = 34; pleaseLoginToLabel.setLayoutData(gridData); pleaseLoginToLabel.setText("Please login to your yafra server:"); new Label(container, SWT.NONE); final Label usernameLabel = new Label(container, SWT.NONE); usernameLabel.setText("Username:"******"Password:"******"Servername:"); combo = new Combo(container, SWT.NONE); // TODO take hosts from preferences - initial preference should be localhost only but can be // added in a list with own combo.add("localhost"); combo.add("vmjboss"); combo.add("webdevelop"); combo.select(0); combo.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); return container; }
@SuppressWarnings("unused") public void createControl(Composite parent) { Composite topComp = new Composite(parent, SWT.NONE); GridLayout innerLayout = new GridLayout(); innerLayout.numColumns = 1; innerLayout.marginHeight = 0; innerLayout.marginWidth = 0; topComp.setLayout(innerLayout); GridData gd = new GridData(GridData.FILL_BOTH); topComp.setLayoutData(gd); // General Settings Group general_grp = new Group(topComp, SWT.NONE); general_grp.setText("General"); GridLayout general_layout = new GridLayout(); general_layout.horizontalSpacing = 8; general_layout.numColumns = 2; general_grp.setLayout(general_layout); gd = new GridData(GridData.FILL_HORIZONTAL); general_grp.setLayoutData(gd); Label versionLabel = newLabel(general_grp, "Django version"); djVersionCombo = new Combo(general_grp, SWT.READ_ONLY); gd = new GridData(GridData.FILL_HORIZONTAL); djVersionCombo.setLayoutData(gd); // Database Settings Group group = new Group(topComp, SWT.NONE); group.setText("Database settings"); GridLayout layout = new GridLayout(); layout.horizontalSpacing = 8; layout.numColumns = 2; group.setLayout(layout); gd = new GridData(GridData.FILL_HORIZONTAL); group.setLayoutData(gd); // Database Engine Label engineLabel = newLabel(group, "Database &Engine"); engineCombo = new Combo(group, 0); final IWizardNewProjectNameAndLocationPage projectPage = projectPageCallback.call(); engineCombo.addSelectionListener( new SelectionListener() { public void widgetSelected(SelectionEvent e) { updateSqlitePathIfNeeded(projectPage); } public void widgetDefaultSelected(SelectionEvent e) {} }); gd = new GridData(GridData.FILL_HORIZONTAL); engineCombo.setLayoutData(gd); // Database Name Label nameLabel = newLabel(group, "Database &Name"); nameText = newText(group); // Database Host Label hostLabel = newLabel(group, "Database &Host"); hostText = newText(group); // Database Port Label portLabel = newLabel(group, "Database P&ort"); portText = newText(group); // Database User Label userLabel = newLabel(group, "&Username"); userText = newText(group); // Database Pass Label passLabel = newLabel(group, "&Password"); passText = newText(group); passText.setEchoChar('*'); setErrorMessage(null); setMessage(null); setControl(topComp); }
public void setEchoChar(char c) { wText.setEchoChar(c); }
private void createTryProjectConfigurationForm(FormToolkit toolkit, Composite parent) { Form form = toolkit.createForm(parent); form.setText("Project Configuration"); Label lblRemoteHost = new Label(form.getBody(), SWT.NONE); lblRemoteHost.setBounds(10, 14, 102, 25); lblRemoteHost.setText("Remote host:"); remoteHostText = new Text(form.getBody(), SWT.BORDER); remoteHostText.setBounds(158, 10, 172, 25); Label lblUsername = new Label(form.getBody(), SWT.NONE); lblUsername.setText("Username:"******"Password:"******"Instructor account:"); lblInstructorAccount.setBounds(10, 98, 143, 25); instructorAccountText = new Text(form.getBody(), SWT.BORDER); instructorAccountText.setBounds(158, 97, 172, 25); Label lblAssignmentCode = new Label(form.getBody(), SWT.NONE); lblAssignmentCode.setText("Assignment code:"); lblAssignmentCode.setBounds(10, 126, 143, 25); assignmentCodeText = new Text(form.getBody(), SWT.BORDER); assignmentCodeText.setBounds(158, 126, 172, 25); Button btnRun = new Button(form.getBody(), SWT.NONE); /* * Business logic when running the plugin */ btnRun.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { // create try command runner object TryCommandRunner runner = new TryCommandRunner(); // create the remote server configuration ServerConfig config = new ServerConfig( remoteHostText.getText(), usernameText.getText(), passwordText.getText()); // get the files to uploaded ArrayList<String> filenames = new ArrayList<String>(); for (FileModel fileModel : tryElement) filenames.add(fileModel.fullPath); // create the try project configuration TryProject project = new TryProject( instructorAccountText.getText(), assignmentCodeText.getText(), filenames); // set the view listener to SSH events runner.setView(tryCommandView); // run the try command runner.run(config, project); } }); btnRun.setBounds(10, 160, 60, 60); btnRun.setText("Run"); }
@Override public void createPartControl(Composite parent) { // TODO Auto-generated method stub FormToolkit toolkit = new FormToolkit(parent.getDisplay()); Composite composite = toolkit.createComposite(parent, SWT.NONE); // composite.setBounds(10, 94, 64, 64); composite.setBounds(10, 94, 64, 64); FormData fd_composite = new FormData(); fd_composite.bottom = new FormAttachment(100, -10); fd_composite.right = new FormAttachment(0, 751); fd_composite.left = new FormAttachment(0, 10); composite.setLayoutData(fd_composite); composite.setLayout(new TreeColumnLayout()); treeViewer = new TreeViewer(composite, SWT.BORDER); Tree localFilesTree = treeViewer.getTree(); localFilesTree.setHeaderVisible(true); localFilesTree.setLinesVisible(true); Label lblNewLabel = toolkit.createLabel(parent, "Files on local machine"); // new Label(this, SWT.NONE); fd_composite.top = new FormAttachment(0, 212); FormData fd_lblNewLabel = new FormData(); fd_lblNewLabel.bottom = new FormAttachment(composite, -6); fd_lblNewLabel.left = new FormAttachment(0, 10); fd_lblNewLabel.right = new FormAttachment(0, 230); lblNewLabel.setLayoutData(fd_lblNewLabel); // lblNewLabel.setText("Files on local machine"); Label lblNewLabel_1 = toolkit.createLabel(parent, ""); // new Label(this, SWT.NONE); FormData fd_lblNewLabel_1 = new FormData(); fd_lblNewLabel_1.left = new FormAttachment(0, 426); lblNewLabel_1.setLayoutData(fd_lblNewLabel_1); lblNewLabel_1.setText("Files added"); ListViewer listViewer = new ListViewer(parent, SWT.BORDER | SWT.V_SCROLL); List addedFilesList = listViewer.getList(); fd_lblNewLabel_1.bottom = new FormAttachment(addedFilesList, -6); FormData fd_addedFilesList = new FormData(); fd_addedFilesList.bottom = new FormAttachment(composite, -6); fd_addedFilesList.left = new FormAttachment(0, 420); fd_addedFilesList.right = new FormAttachment(100, -73); fd_addedFilesList.top = new FormAttachment(0, 30); addedFilesList.setLayoutData(fd_addedFilesList); Composite composite_1 = toolkit.createComposite(parent, SWT.NONE); // new Composite(this, SWT.NONE); FormData fd_composite_1 = new FormData(); fd_composite_1.top = new FormAttachment(addedFilesList, 0, SWT.TOP); fd_composite_1.left = new FormAttachment(composite, 0, SWT.LEFT); fd_composite_1.right = new FormAttachment(addedFilesList, -6); fd_composite_1.bottom = new FormAttachment(lblNewLabel, -4); composite_1.setLayoutData(fd_composite_1); Label lblRemoteHost = toolkit.createLabel(parent, ""); // new Label(composite_1, SWT.NONE); lblRemoteHost.setBounds(10, 14, 102, 14); lblRemoteHost.setText("Remote host:"); Label lblUsername = new Label(composite_1, SWT.NONE); lblUsername.setText("Username:"******"Password:"******"Instructor Account:"); lblInstructorAccount.setBounds(10, 98, 114, 14); assignmentCodeText = new Text(composite_1, SWT.BORDER); assignmentCodeText.setBounds(128, 126, 172, 19); Label lblAssignmentCode = new Label(composite_1, SWT.NONE); lblAssignmentCode.setText("Assignment code:"); lblAssignmentCode.setBounds(10, 126, 102, 14); instructorAccountText = new Text(composite_1, SWT.BORDER); instructorAccountText.setBounds(128, 97, 172, 19); Button btnRun = new Button(composite_1, SWT.NONE); btnRun.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { usernameText.setText("Hello worlds"); } }); btnRun.setBounds(318, 10, 76, 46); btnRun.setText("Run"); Label lblTryProjectConfiguration = toolkit.createLabel(parent, ""); // new Label(this, SWT.NONE); FormData fd_lblTryProjectConfiguration = new FormData(); fd_lblTryProjectConfiguration.top = new FormAttachment(lblNewLabel_1, 0, SWT.TOP); fd_lblTryProjectConfiguration.left = new FormAttachment(0, 10); lblTryProjectConfiguration.setLayoutData(fd_lblTryProjectConfiguration); lblTryProjectConfiguration.setText("Try project configuration"); }
protected authDialog( AESemaphore _sem, Display display, String realm, boolean is_tracker, String target, String details) { sem = _sem; if (display.isDisposed()) { sem.releaseForever(); return; } final String ignore_key = "IgnoreAuth:" + realm + ":" + target + ":" + details; if (RememberedDecisionsManager.getRememberedDecision(ignore_key) == 1) { Debug.out( "Authentication for " + realm + "/" + target + "/" + details + " ignored as told not to ask again"); sem.releaseForever(); return; } shell = ShellFactory.createMainShell(SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL); Utils.setShellIcon(shell); Messages.setLanguageText(shell, "authenticator.title"); GridLayout layout = new GridLayout(); layout.numColumns = 3; shell.setLayout(layout); GridData gridData; // realm Label realm_label = new Label(shell, SWT.NULL); Messages.setLanguageText(realm_label, "authenticator.realm"); gridData = new GridData(GridData.FILL_BOTH); gridData.horizontalSpan = 1; realm_label.setLayoutData(gridData); Label realm_value = new Label(shell, SWT.NULL); realm_value.setText(realm.replaceAll("&", "&&")); gridData = new GridData(GridData.FILL_BOTH); gridData.horizontalSpan = 2; realm_value.setLayoutData(gridData); // target Label target_label = new Label(shell, SWT.NULL); Messages.setLanguageText( target_label, is_tracker ? "authenticator.tracker" : "authenticator.location"); gridData = new GridData(GridData.FILL_BOTH); gridData.horizontalSpan = 1; target_label.setLayoutData(gridData); Label target_value = new Label(shell, SWT.NULL); target_value.setText(target.replaceAll("&", "&&")); gridData = new GridData(GridData.FILL_BOTH); gridData.horizontalSpan = 2; target_value.setLayoutData(gridData); if (details != null) { Label details_label = new Label(shell, SWT.NULL); Messages.setLanguageText( details_label, is_tracker ? "authenticator.torrent" : "authenticator.details"); gridData = new GridData(GridData.FILL_BOTH); gridData.horizontalSpan = 1; details_label.setLayoutData(gridData); Label details_value = new Label(shell, SWT.NULL); details_value.setText(details.replaceAll("&", "&&")); gridData = new GridData(GridData.FILL_BOTH); gridData.horizontalSpan = 2; details_value.setLayoutData(gridData); } // user Label user_label = new Label(shell, SWT.NULL); Messages.setLanguageText(user_label, "authenticator.user"); gridData = new GridData(GridData.FILL_BOTH); gridData.horizontalSpan = 1; user_label.setLayoutData(gridData); final Text user_value = new Text(shell, SWT.BORDER); user_value.setText(""); gridData = new GridData(GridData.FILL_BOTH); gridData.horizontalSpan = 2; user_value.setLayoutData(gridData); user_value.addListener( SWT.Modify, new Listener() { public void handleEvent(Event event) { username = user_value.getText(); } }); // password Label password_label = new Label(shell, SWT.NULL); Messages.setLanguageText(password_label, "authenticator.password"); gridData = new GridData(GridData.FILL_BOTH); gridData.horizontalSpan = 1; password_label.setLayoutData(gridData); final Text password_value = new Text(shell, SWT.BORDER); password_value.setEchoChar('*'); password_value.setText(""); gridData = new GridData(GridData.FILL_BOTH); gridData.horizontalSpan = 2; password_value.setLayoutData(gridData); password_value.addListener( SWT.Modify, new Listener() { public void handleEvent(Event event) { password = password_value.getText(); } }); // persist Label blank_label = new Label(shell, SWT.NULL); gridData = new GridData(GridData.FILL_BOTH); gridData.horizontalSpan = 1; blank_label.setLayoutData(gridData); final Button checkBox = new Button(shell, SWT.CHECK); checkBox.setText(MessageText.getString("authenticator.savepassword")); gridData = new GridData(GridData.FILL_BOTH); gridData.horizontalSpan = 1; checkBox.setLayoutData(gridData); checkBox.addListener( SWT.Selection, new Listener() { public void handleEvent(Event e) { persist = checkBox.getSelection(); } }); final Button dontAsk = new Button(shell, SWT.CHECK); dontAsk.setText(MessageText.getString("general.dont.ask.again")); gridData = new GridData(GridData.FILL_BOTH); gridData.horizontalSpan = 1; dontAsk.setLayoutData(gridData); dontAsk.addListener( SWT.Selection, new Listener() { public void handleEvent(Event e) { RememberedDecisionsManager.setRemembered(ignore_key, dontAsk.getSelection() ? 1 : 0); } }); // line Label labelSeparator = new Label(shell, SWT.SEPARATOR | SWT.HORIZONTAL); gridData = new GridData(GridData.FILL_HORIZONTAL); gridData.horizontalSpan = 3; labelSeparator.setLayoutData(gridData); // buttons new Label(shell, SWT.NULL); Button bOk = new Button(shell, SWT.PUSH); Messages.setLanguageText(bOk, "Button.ok"); gridData = new GridData( GridData.FILL_HORIZONTAL | GridData.HORIZONTAL_ALIGN_END | GridData.HORIZONTAL_ALIGN_FILL); gridData.grabExcessHorizontalSpace = true; gridData.widthHint = 70; bOk.setLayoutData(gridData); bOk.addListener( SWT.Selection, new Listener() { public void handleEvent(Event e) { close(true); } }); Button bCancel = new Button(shell, SWT.PUSH); Messages.setLanguageText(bCancel, "Button.cancel"); gridData = new GridData(GridData.HORIZONTAL_ALIGN_END); gridData.grabExcessHorizontalSpace = false; gridData.widthHint = 70; bCancel.setLayoutData(gridData); bCancel.addListener( SWT.Selection, new Listener() { public void handleEvent(Event e) { close(false); } }); shell.setDefaultButton(bOk); shell.addListener( SWT.Traverse, new Listener() { public void handleEvent(Event e) { if (e.character == SWT.ESC) { close(false); } } }); shell.pack(); Utils.centreWindow(shell); shell.open(); }
protected authDialog( AESemaphore _sem, Display display, String realm, String tracker, String torrent_name) { sem = _sem; if (display.isDisposed()) { sem.release(); return; } shell = new Shell(display, SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL); Utils.setShellIcon(shell); Messages.setLanguageText(shell, "authenticator.title"); GridLayout layout = new GridLayout(); layout.numColumns = 3; shell.setLayout(layout); GridData gridData; // realm Label realm_label = new Label(shell, SWT.NULL); Messages.setLanguageText(realm_label, "authenticator.realm"); gridData = new GridData(GridData.FILL_BOTH); gridData.horizontalSpan = 1; realm_label.setLayoutData(gridData); Label realm_value = new Label(shell, SWT.NULL); realm_value.setText(realm.replaceAll("&", "&&")); gridData = new GridData(GridData.FILL_BOTH); gridData.horizontalSpan = 2; realm_value.setLayoutData(gridData); // tracker Label tracker_label = new Label(shell, SWT.NULL); Messages.setLanguageText(tracker_label, "authenticator.tracker"); gridData = new GridData(GridData.FILL_BOTH); gridData.horizontalSpan = 1; tracker_label.setLayoutData(gridData); Label tracker_value = new Label(shell, SWT.NULL); tracker_value.setText(tracker.replaceAll("&", "&&")); gridData = new GridData(GridData.FILL_BOTH); gridData.horizontalSpan = 2; tracker_value.setLayoutData(gridData); if (torrent_name != null) { Label torrent_label = new Label(shell, SWT.NULL); Messages.setLanguageText(torrent_label, "authenticator.torrent"); gridData = new GridData(GridData.FILL_BOTH); gridData.horizontalSpan = 1; torrent_label.setLayoutData(gridData); Label torrent_value = new Label(shell, SWT.NULL); torrent_value.setText(torrent_name.replaceAll("&", "&&")); gridData = new GridData(GridData.FILL_BOTH); gridData.horizontalSpan = 2; torrent_value.setLayoutData(gridData); } // user Label user_label = new Label(shell, SWT.NULL); Messages.setLanguageText(user_label, "authenticator.user"); gridData = new GridData(GridData.FILL_BOTH); gridData.horizontalSpan = 1; user_label.setLayoutData(gridData); final Text user_value = new Text(shell, SWT.BORDER); user_value.setText(""); gridData = new GridData(GridData.FILL_BOTH); gridData.horizontalSpan = 2; user_value.setLayoutData(gridData); user_value.addListener( SWT.Modify, new Listener() { public void handleEvent(Event event) { username = user_value.getText(); } }); // password Label password_label = new Label(shell, SWT.NULL); Messages.setLanguageText(password_label, "authenticator.password"); gridData = new GridData(GridData.FILL_BOTH); gridData.horizontalSpan = 1; password_label.setLayoutData(gridData); final Text password_value = new Text(shell, SWT.BORDER); password_value.setEchoChar('*'); password_value.setText(""); gridData = new GridData(GridData.FILL_BOTH); gridData.horizontalSpan = 2; password_value.setLayoutData(gridData); password_value.addListener( SWT.Modify, new Listener() { public void handleEvent(Event event) { password = password_value.getText(); } }); // persist Label blank_label = new Label(shell, SWT.NULL); gridData = new GridData(GridData.FILL_BOTH); gridData.horizontalSpan = 1; blank_label.setLayoutData(gridData); final Button checkBox = new Button(shell, SWT.CHECK); checkBox.setText(MessageText.getString("authenticator.savepassword")); gridData = new GridData(GridData.FILL_BOTH); gridData.horizontalSpan = 2; checkBox.setLayoutData(gridData); checkBox.addListener( SWT.Selection, new Listener() { public void handleEvent(Event e) { persist = checkBox.getSelection(); } }); // line Label labelSeparator = new Label(shell, SWT.SEPARATOR | SWT.HORIZONTAL); gridData = new GridData(GridData.FILL_HORIZONTAL); gridData.horizontalSpan = 3; labelSeparator.setLayoutData(gridData); // buttons new Label(shell, SWT.NULL); Button bOk = new Button(shell, SWT.PUSH); Messages.setLanguageText(bOk, "Button.ok"); gridData = new GridData( GridData.FILL_HORIZONTAL | GridData.HORIZONTAL_ALIGN_END | GridData.HORIZONTAL_ALIGN_FILL); gridData.grabExcessHorizontalSpace = true; gridData.widthHint = 70; bOk.setLayoutData(gridData); bOk.addListener( SWT.Selection, new Listener() { public void handleEvent(Event e) { close(true); } }); Button bCancel = new Button(shell, SWT.PUSH); Messages.setLanguageText(bCancel, "Button.cancel"); gridData = new GridData(GridData.HORIZONTAL_ALIGN_END); gridData.grabExcessHorizontalSpace = false; gridData.widthHint = 70; bCancel.setLayoutData(gridData); bCancel.addListener( SWT.Selection, new Listener() { public void handleEvent(Event e) { close(false); } }); shell.setDefaultButton(bOk); shell.addListener( SWT.Traverse, new Listener() { public void handleEvent(Event e) { if (e.character == SWT.ESC) { close(false); } } }); shell.pack(); Utils.centreWindow(shell); shell.open(); shell.forceActive(); }