Java Code Examples for org.eclipse.swt.SWT#PASSWORD

The following examples show how to use org.eclipse.swt.SWT#PASSWORD . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: hop   File: UsernamePasswordDialog.java    License: Apache License 2.0 6 votes vote down vote up
@Override
protected Control createDialogArea( Composite parent ) {
  Composite comp = (Composite) super.createDialogArea( parent );

  GridLayout layout = (GridLayout) comp.getLayout();
  layout.numColumns = 2;

  Label usernameLabel = new Label( comp, SWT.RIGHT );
  usernameLabel.setText( "Username: " );
  usernameText = new Text( comp, SWT.SINGLE | SWT.BORDER );
  usernameText.setLayoutData( new GridData( GridData.FILL_HORIZONTAL ) );

  Label passwordLabel = new Label( comp, SWT.RIGHT );
  passwordLabel.setText( "Password: " );
  passwordText = new Text( comp, SWT.SINGLE | SWT.BORDER | SWT.PASSWORD );
  passwordText.setLayoutData( new GridData( GridData.FILL_HORIZONTAL ) );

  return comp;
}
 
Example 2
Source Project: nebula   File: LoginDialog.java    License: Eclipse Public License 2.0 6 votes vote down vote up
/**
 * Build the password part of the box
 */
private void buildPassword() {
	final Label label = new Label(shell, SWT.NONE);
	final GridData gridData = new GridData(GridData.END, GridData.CENTER, false, false, 1, 1);
	gridData.horizontalIndent = 35;
	label.setLayoutData(gridData);
	label.setText(ResourceManager.getLabel(ResourceManager.PASSWORD));

	final Text text = new Text(shell, SWT.PASSWORD | SWT.BORDER);
	text.setText(password == null ? "" : password);
	text.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false, 3, 1));
	text.addListener(SWT.Modify, e -> {
		password = text.getText();
		changeButtonOkState();
	});
}
 
Example 3
public ExpressionViewer createPasswordControl(final Composite composite, final Password object) {
    final Input input = getConnectorInput(object.getInputName());
    final ConnectorParameter parameter = connectorConfigurationSupport.getConnectorParameter(object.getInputName(),
            object, input);

    if (parameter != null) {
        createFieldLabel(composite, SWT.CENTER, object.getId(), input.isMandatory());
        final ExpressionViewer viewer = new ExpressionViewer(composite, SWT.BORDER | SWT.PASSWORD);
        viewer.setIsPageFlowContext(isPageFlowContext);
        viewer.getControl().setLayoutData(GridDataFactory.fillDefaults().grab(true, false).create());
        viewer.setContext(container);
        if (input.isMandatory()) {
            viewer.setMandatoryField(getLabel(object.getId()), context);
        }
        viewer.addFilter(connectorExpressionContentTypeFilter);
        viewer.setInput(parameter);
        final String desc = getDescription(object.getId());
        if (desc != null && !desc.isEmpty()) {
            viewer.setMessage(desc);
        }
        context.bindValue(ViewersObservables.observeSingleSelection(viewer),
                EMFObservables.observeValue(parameter,
                        ConnectorConfigurationPackage.Literals.CONNECTOR_PARAMETER__EXPRESSION));
        return viewer;
    }
    return null;
}
 
Example 4
static public DCText createPasswordText(Composite parent, String attrName, int horzSpan, int horzIndent, int cols) {
    DCText ourText = new DCText(parent, SWT.BORDER | SWT.PASSWORD, attrName);
    ourText.setAttributeName(attrName);
    if (cols > 0)
        ourText.setCols(cols);
    GridData gd = new GridData(GridData.FILL, GridData.CENTER, true, false, horzSpan, 1);
    if (horzIndent > 0)
        gd.horizontalIndent = horzIndent;
    ourText.setLayoutData(gd);
    return ourText;
}
 
Example 5
Source Project: arx   File: ImportWizardPageJDBC.java    License: Apache License 2.0 4 votes vote down vote up
/**
 * Creates the content of {@link #compositeRemote}
 *
 * This adds all of the labels and text fields necessary to connect to a
 * remote database server. If everything is fine, the tables from the
 * database will be read.
 *
 * @see {@link #readTables()}
 */
private void createCompositeRemote() {
    
    compositeRemote = new Composite(compositeSwap, SWT.NONE);
    compositeRemote.setLayout(new GridLayout(2, false));
    
    // Tries to connect to database on changes
    DelayedChangeListener connectionTester = new DelayedChangeListener(1000) {
        @Override
        public void delayedEvent() {
            tryToConnect();
        }
    };
    
    Label lblServer = new Label(compositeRemote, SWT.NONE);
    lblServer.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
    lblServer.setText(Resources.getMessage("ImportWizardPageJDBC.14")); //$NON-NLS-1$
    
    txtServer = new Text(compositeRemote, SWT.BORDER);
    txtServer.setText("localhost"); //$NON-NLS-1$
    txtServer.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
    txtServer.addModifyListener(connectionTester);
    
    Label lblPort = new Label(compositeRemote, SWT.NONE);
    lblPort.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
    lblPort.setText(Resources.getMessage("ImportWizardPageJDBC.16")); //$NON-NLS-1$
    
    txtPort = new Text(compositeRemote, SWT.BORDER);
    txtPort.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
    txtPort.addModifyListener(connectionTester);
    
    Label lblUsername = new Label(compositeRemote, SWT.NONE);
    lblUsername.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
    lblUsername.setText(Resources.getMessage("ImportWizardPageJDBC.0")); //$NON-NLS-1$
    
    txtUsername = new Text(compositeRemote, SWT.BORDER);
    txtUsername.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
    txtUsername.addModifyListener(connectionTester);
    
    Label lblPassword = new Label(compositeRemote, SWT.NONE);
    lblPassword.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
    lblPassword.setText(Resources.getMessage("ImportWizardPageJDBC.1")); //$NON-NLS-1$
    
    txtPassword = new Text(compositeRemote, SWT.BORDER | SWT.PASSWORD);
    txtPassword.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
    txtPassword.addModifyListener(connectionTester);
    
    Label lblDatabase = new Label(compositeRemote, SWT.NONE);
    lblDatabase.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
    lblDatabase.setText(Resources.getMessage("ImportWizardPageJDBC.19")); //$NON-NLS-1$
    
    txtDatabase = new Text(compositeRemote, SWT.BORDER);
    txtDatabase.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
    txtDatabase.addModifyListener(connectionTester);
}
 
Example 6
Source Project: hop   File: PasswordTextVar.java    License: Apache License 2.0 4 votes vote down vote up
public PasswordTextVar( IVariables variables, Composite composite, int flags ) {
  super( variables, composite, flags | SWT.PASSWORD, null, null, null );
}
 
Example 7
@Override
protected Control createDialogArea(Composite parent){
	Composite ret = new Composite(parent, SWT.NONE);
	ret.setLayoutData(SWTHelper.getFillGridData(1, true, 1, true));
	ret.setLayout(new GridLayout(2, false));
	
	Label lu = new Label(ret, SWT.NONE);
	lu.setText(Messages.LoginDialog_0);
	usr = new Text(ret, SWT.BORDER);
	usr.setLayoutData(SWTHelper.getFillGridData(1, true, 1, false));
	new Label(ret, SWT.NONE).setText(Messages.LoginDialog_1);
	pwd = new Text(ret, SWT.BORDER | SWT.PASSWORD);
	pwd.setLayoutData(SWTHelper.getFillGridData(1, true, 1, false));
	if (hasUsers == false) {
		usr.setText("Administrator"); //$NON-NLS-1$
		pwd.setText("admin"); //$NON-NLS-1$
	}
	
	if (elexisEnvironmentLoginContributor != null) {
		Button btnLoginElexisEnv = new Button(ret, SWT.NONE);
		GridData gd_btnLoginElexisEnv = new GridData(SWT.FILL, SWT.CENTER, false, false, 2, 1);
		btnLoginElexisEnv.setLayoutData(gd_btnLoginElexisEnv);
		btnLoginElexisEnv.setText("Elexis-Environment Login");
		btnLoginElexisEnv.addSelectionListener(new SelectionAdapter() {
			@Override
			public void widgetSelected(SelectionEvent e){
				setReturnCode(302);
				close();
			}
		});
	}
	
	@SuppressWarnings("unchecked")
	List<ILoginNews> newsModules =
		Extensions.getClasses(ExtensionPointConstantsUi.LOGIN_NEWS, "class");
	
	if (newsModules.size() > 0) {
		Composite cNews = new Composite(ret, SWT.NONE);
		cNews.setLayoutData(SWTHelper.getFillGridData(2, true, 1, true));
		cNews.setLayout(new GridLayout());
		for (ILoginNews lm : newsModules) {
			try {
				Composite comp = lm.getComposite(cNews);
				comp.setLayoutData(SWTHelper.getFillGridData());
			} catch (Exception ex) {
				// Note: This is NOT a fatal error. It just means, that the Newsmodule could not
				// load. Maybe we are offline.
				ExHandler.handle(ex);
				
			}
		}
		
	}
	
	return ret;
}
 
Example 8
Source Project: pentaho-kettle   File: PasswordTextVar.java    License: Apache License 2.0 4 votes vote down vote up
public PasswordTextVar( VariableSpace space, Composite composite, int flags, String toolTipText,
    GetCaretPositionInterface getCaretPositionInterface, InsertTextInterface insertTextInterface ) {
  super( space, composite, flags | SWT.PASSWORD, toolTipText, getCaretPositionInterface, insertTextInterface );
}
 
Example 9
@Override
protected Control createDialogArea(Composite parent){
	Composite rx = (Composite) super.createDialogArea(parent);
	Composite ret = new Composite(rx, SWT.NONE);
	ret.setLayoutData(SWTHelper.getFillGridData(1, true, 1, true));
	ret.setLayout(new GridLayout(2, false));
	new Label(ret, SWT.NONE).setText(Messages.ErsterMandantDialog_Username); //$NON-NLS-1$
	tUsername = new Text(ret, SWT.BORDER);
	tUsername.setLayoutData(SWTHelper.getFillGridData(1, true, 1, false));
	new Label(ret, SWT.NONE).setText(Messages.ErsterMandantDialog_Password); //$NON-NLS-1$
	tPwd1 = new Text(ret, SWT.BORDER | SWT.PASSWORD);
	tPwd1.setLayoutData(SWTHelper.getFillGridData(1, true, 1, false));
	new Label(ret, SWT.NONE).setText(Messages.ErsterMandantDialog_PasswordRepeat); //$NON-NLS-1$
	tPwd2 = new Text(ret, SWT.BORDER | SWT.PASSWORD);
	tPwd2.setLayoutData(SWTHelper.getFillGridData(1, true, 1, false));
	new Label(ret, SWT.NONE).setText(Messages.ErsterMandantDialog_Anrede); //$NON-NLS-1$
	cbAnrede = new Combo(ret, SWT.SIMPLE | SWT.SINGLE);
	cbAnrede.setItems(anreden);
	
	new Label(ret, SWT.NONE).setText(Messages.ErsterMandantDialog_Title); //$NON-NLS-1$
	tTitle = new Text(ret, SWT.BORDER);
	tTitle.setLayoutData(SWTHelper.getFillGridData(1, true, 1, false));
	new Label(ret, SWT.NONE).setText(Messages.ErsterMandantDialog_Firstname); //$NON-NLS-1$
	tFirstname = new Text(ret, SWT.BORDER);
	tFirstname.setLayoutData(SWTHelper.getFillGridData(1, true, 1, false));
	new Label(ret, SWT.NONE).setText(Messages.ErsterMandantDialog_Lastname); //$NON-NLS-1$
	tLastname = new Text(ret, SWT.BORDER);
	tLastname.setLayoutData(SWTHelper.getFillGridData(1, true, 1, false));
	new Label(ret, SWT.NONE).setText(Messages.ErsterMandantDialog_EMail); //$NON-NLS-1$
	tEmail = new Text(ret, SWT.BORDER);
	tEmail.setLayoutData(SWTHelper.getFillGridData(1, true, 1, false));
	new Label(ret, SWT.NONE).setText(Messages.ErsterMandantDialog_Street); //$NON-NLS-1$
	tStreet = new Text(ret, SWT.BORDER);
	tStreet.setLayoutData(SWTHelper.getFillGridData(1, true, 1, false));
	new Label(ret, SWT.NONE).setText(Messages.ErsterMandantDialog_zip); //$NON-NLS-1$
	tZip = new Text(ret, SWT.BORDER);
	tZip.setLayoutData(SWTHelper.getFillGridData(1, true, 1, false));
	new Label(ret, SWT.NONE).setText(Messages.ErsterMandantDialog_place); //$NON-NLS-1$
	tPlace = new Text(ret, SWT.BORDER);
	tPlace.setLayoutData(SWTHelper.getFillGridData(1, true, 1, false));
	new Label(ret, SWT.NONE).setText(Messages.ErsterMandantDialog_phone); //$NON-NLS-1$
	tPhone = new Text(ret, SWT.BORDER);
	tPhone.setLayoutData(SWTHelper.getFillGridData(1, true, 1, false));
	new Label(ret, SWT.NONE).setText(Messages.ErsterMandantDialog_fax); //$NON-NLS-1$
	tFax = new Text(ret, SWT.BORDER);
	tFax.setLayoutData(SWTHelper.getFillGridData(1, true, 1, false));
	return rx;
}
 
Example 10
public static void main(final String[] args) {
	final Display display = new Display();
	final Shell shell = new Shell(display);
	shell.setBackgroundMode(SWT.INHERIT_DEFAULT);
	final FillLayout layout1 = new FillLayout(SWT.VERTICAL);
	layout1.marginWidth = layout1.marginHeight = 10;
	shell.setLayout(layout1);

	// Displays the group
	final CheckBoxGroup group = new CheckBoxGroup(shell, SWT.NONE);
	group.setLayout(new GridLayout(4, false));
	group.setText("Use proxy server");

	final Composite content = group.getContent();

	final Label lblServer = new Label(content, SWT.NONE);
	lblServer.setText("Server:");
	lblServer.setLayoutData(new GridData(GridData.END, GridData.CENTER, false, false));

	final Text txtServer = new Text(content, SWT.NONE);
	txtServer.setText("proxy.host.com");
	txtServer.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false));

	final Label lblPort = new Label(content, SWT.NONE);
	lblPort.setText("Port:");
	lblPort.setLayoutData(new GridData(GridData.END, GridData.CENTER, false, false));

	final Text txtPort = new Text(content, SWT.NONE);
	txtPort.setText("1234");
	txtPort.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false));

	final Label lblUser = new Label(content, SWT.NONE);
	lblUser.setText("User ID:");
	lblUser.setLayoutData(new GridData(GridData.END, GridData.CENTER, false, false));

	final Text txtUser = new Text(content, SWT.NONE);
	txtUser.setText("MyName");
	txtUser.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false));

	final Label lblPassword = new Label(content, SWT.NONE);
	lblPassword.setText("Password:");
	lblPassword.setLayoutData(new GridData(GridData.END, GridData.CENTER, false, false));

	final Text txtPassword = new Text(content, SWT.PASSWORD);
	txtPassword.setText("password");
	txtPassword.setEnabled(false);
	txtPassword.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false));

	// Open the shell
	shell.setSize(640, 360);
	SWTGraphicUtil.centerShell(shell);
	shell.open();
	while (!shell.isDisposed()) {
		if (!display.readAndDispatch()) {
			display.sleep();
		}
	}
	display.dispose();
}
 
Example 11
private void create() {
	failShell = new Shell(SWT.APPLICATION_MODAL | SWT.TITLE | SWT.CLOSE);
	failShell.setText("Invalid Password");
	failShell.setImage(RepDevMain.smallSymAddImage);
	
	FormLayout layout = new FormLayout();
	layout.marginTop = 5;
	layout.marginBottom = 5;
	layout.marginLeft = 5;
	layout.marginRight = 5;
	layout.spacing = 5;
	failShell.setLayout(layout);
	
	FailText = new Label(failShell, SWT.NONE);
	FailText.setText("Please retype your userID:");
	
	pass = new Text(failShell, SWT.SINGLE | SWT.BORDER | SWT.PASSWORD);	
	
	Button ok = new Button(failShell, SWT.PUSH);
	ok.setText("Submit");
	ok.addSelectionListener(new SelectionAdapter() {
		public void widgetSelected(SelectionEvent e) {	
			newPass = pass.getText();
			failShell.close();
		}
	});
	
	FormData data = new FormData();
	
	data = new FormData();
	data.left = new FormAttachment(0);
	//data.right = new FormAttachment(100);
	data.top = new FormAttachment(0);
	//data.bottom = new FormAttachment();
	FailText.setLayoutData(data);
	
	data = new FormData();
	data.left = new FormAttachment(0);
	data.right = new FormAttachment(100);
	data.top = new FormAttachment(FailText);
	//data.bottom = new FormAttachment(ok);
	pass.setLayoutData(data);
	
	data = new FormData();
	data.left = new FormAttachment(0);
	//data.right = new FormAttachment(100);
	data.top = new FormAttachment(pass);
	data.bottom = new FormAttachment(100);
	ok.setLayoutData(data);
	
	failShell.setDefaultButton(ok);
	
	failShell.pack();
	failShell.open();
	
	while (!failShell.isDisposed()) {
		if (!failShell.getDisplay().readAndDispatch())
			failShell.getDisplay().sleep();
	}
}
 
Example 12
Source Project: nebula   File: PasswordRevealer.java    License: Eclipse Public License 2.0 4 votes vote down vote up
/**
 * Constructs a new instance of this class given its parent and a style value
 * describing its behavior and appearance.
 * <p>
 * The style value is either one of the style constants defined in class
 * <code>SWT</code> which is applicable to instances of this class, or must be
 * built by <em>bitwise OR</em>'ing together (that is, using the
 * <code>int</code> "|" operator) two or more of those <code>SWT</code> style
 * constants. The class description lists the style constants that are
 * applicable to the class. Style bits are also inherited from superclasses.
 * </p>
 *
 * @param parent a composite control which will be the parent of the new
 *            instance (cannot be null)
 * @param style the style of control to construct
 *
 * @exception IllegalArgumentException
 *                <ul>
 *                <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
 *                </ul>
 * @exception SWTException
 *                <ul>
 *                <li>ERROR_THREAD_INVALID_ACCESS - if not called from the
 *                thread that created the parent</li>
 *                <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed
 *                subclass</li>
 *                </ul>
 *
 * @see Widget#getStyle()
 */
public PasswordRevealer(final Composite parent, final int style) {
	super(parent, SWT.BORDER);
	final GridLayout gl = new GridLayout(2, false);
	gl.horizontalSpacing = gl.verticalSpacing = gl.marginHeight = gl.marginWidth = 0;
	setLayout(gl);

	comp = new Composite(this, SWT.NONE);
	final GridLayout glComp = new GridLayout(1, false);
	glComp.horizontalSpacing = glComp.verticalSpacing = glComp.marginHeight = glComp.marginWidth = 0;
	comp.setLayout(glComp);
	comp.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, true));

	passwordField = new Text(comp, style | SWT.PASSWORD | removeFields(style, SWT.BORDER));
	passwordField.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, false));
	defaultEchoChar = passwordField.getEchoChar();

	eyeButton = new EyeButton(this, SWT.NONE);
	eyeButton.setLayoutData(new GridData(GridData.FILL, GridData.FILL, false, false));
}
 
Example 13
@Override
protected void createInput ( final DataBindingContext dbc, final Label label, final Composite composite )
{
    this.input = new Text ( composite, SWT.PASSWORD | SWT.BORDER );
    this.input.setLayoutData ( new GridData ( SWT.FILL, SWT.CENTER, true, false ) );
}
 
Example 14
/**
     * Create contents of the preference page.
     *
     * @param parent the parent composite
     */
    @Override
    public Control createContents(Composite parent) {
        Composite container = new Composite(parent, SWT.NONE);

        GridLayout gl_grpTestnet = new GridLayout(2, false);
        gl_grpTestnet.marginTop = 5;
        gl_grpTestnet.marginRight = 5;
        gl_grpTestnet.marginLeft = 5;
        gl_grpTestnet.marginBottom = 5;
        container.setLayout(gl_grpTestnet);

//        Label oldPasswordLabel = new Label(container, SWT.NONE);
//        oldPasswordLabel.setText("Old Password");
//
//        Text oldPasswordText = new Text(container, SWT.BORDER | SWT.PASSWORD);
//        oldPasswordText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
//        oldPasswordText.setEnabled(isPasswordSaved());
//        if (!isPasswordSaved()) {
//            oldPasswordText.setMessage("Password not set");
//        }
//
//        Label newPasswordLabel = new Label(container, SWT.NONE);
//        newPasswordLabel.setText("New Password");
//
//        Text newPasswordText = new Text(container, SWT.BORDER | SWT.PASSWORD);
//        newPasswordText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));

        Label repeatPasswordLabel = new Label(container, SWT.NONE);
        repeatPasswordLabel.setText("Password");

        Text repeatPasswordText = new Text(container, SWT.BORDER | SWT.PASSWORD);
        repeatPasswordText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));

//        this.oldPasswordText = oldPasswordText;
//        this.newPasswordText = newPasswordText;
        this.repeatPasswordText = repeatPasswordText;

        initialize(); // initialize properties values

        return container;
    }
 
Example 15
public SWTPasswordField(SWTContainer<? extends Composite> parent) {
	super(parent, SWT.PASSWORD);
}
 
Example 16
Source Project: pentaho-kettle   File: PasswordTextVar.java    License: Apache License 2.0 4 votes vote down vote up
public PasswordTextVar( VariableSpace space, Composite composite, int flags ) {
  super( space, composite, flags | SWT.PASSWORD, null, null, null );
}
 
Example 17
@Override
protected Control createDialogArea(Composite parent)
{
	FontData msgPromptFontData = new FontData(MAC_DIALOG_FONT, MAC_DIALOG_FONT_SIZE, SWT.BOLD);
	final Font msgPromptFont = new Font(shell.getDisplay(), msgPromptFontData);

	// ----------------------------------------------------------
	// Composite for the header and prompt message.
	parent.setLayout(GridLayoutFactory.swtDefaults().numColumns(2).equalWidth(false).create());
	parent.setFont(msgPromptFont);

	Label authImageLbl = new Label(parent, SWT.None);
	final Image authImage = UIPlugin.getImageDescriptor(SECURITY_IMAGE).createImage();
	authImageLbl.setImage(authImage);

	Label promptMsg = new Label(parent, SWT.WRAP);
	promptMsg.setLayoutData(GridDataFactory.swtDefaults().grab(true, true).align(SWT.BEGINNING, SWT.BEGINNING)
			.create());
	promptMsg.setFont(parent.getFont());
	promptMsg.setText(promptMessage);

	// ----------------------------------------------------------
	// Now laying out UserName and Password fields.
	new Label(parent, SWT.NONE); // Dummy label to fill in.

	FontData fieldsFontData = new FontData(MAC_DIALOG_FONT, MAC_DIALOG_FONT_SIZE, SWT.NORMAL);
	final Font fieldsFont = new Font(shell.getDisplay(), fieldsFontData);

	Composite authDetails = new Composite(parent, SWT.None);
	authDetails.setLayout(GridLayoutFactory.swtDefaults().numColumns(2).equalWidth(false).create());
	authDetails.setLayoutData(GridDataFactory.swtDefaults().grab(true, false).align(SWT.FILL, SWT.BEGINNING)
			.create());
	authDetails.setFont(fieldsFont);

	Composite labels = new Composite(authDetails, SWT.None);
	labels.setLayout(GridLayoutFactory.swtDefaults().numColumns(1).equalWidth(true).create());

	Composite fieldsComp = new Composite(authDetails, SWT.None);
	fieldsComp.setLayout(GridLayoutFactory.swtDefaults().numColumns(1).equalWidth(true).create());
	fieldsComp
			.setLayoutData(GridDataFactory.swtDefaults().grab(true, true).align(SWT.FILL, SWT.BEGINNING).create());

	Label nameLbl = new Label(labels, SWT.None);
	nameLbl.setText(StringUtil.makeFormLabel(Messages.SudoPasswordPromptDialog_User));
	nameLbl.setLayoutData(GridDataFactory.swtDefaults().grab(true, false).align(SWT.END, SWT.BEGINNING).create());
	nameLbl.setFont(authDetails.getFont());

	Text nameText = new Text(fieldsComp, SWT.BORDER | SWT.READ_ONLY);
	nameText.setLayoutData(GridDataFactory.swtDefaults().grab(true, true).align(SWT.FILL, SWT.FILL).create());
	nameText.setText(System.getProperty("user.name")); //$NON-NLS-1$
	nameText.setForeground(parent.getDisplay().getSystemColor(SWT.COLOR_TITLE_INACTIVE_FOREGROUND));

	Label pwdLbl = new Label(labels, SWT.None);
	pwdLbl.setText(StringUtil.makeFormLabel(Messages.SudoPasswordPromptDialog_Password));
	pwdLbl.setLayoutData(GridDataFactory.swtDefaults().grab(true, false).align(SWT.END, SWT.BEGINNING).create());
	pwdLbl.setFont(authDetails.getFont());

	pwdText = new Text(fieldsComp, SWT.BORDER | SWT.PASSWORD);
	pwdText.setLayoutData(GridDataFactory.swtDefaults().grab(true, true).align(SWT.FILL, SWT.FILL).create());

	shell.addDisposeListener(new DisposeListener()
	{
		public void widgetDisposed(DisposeEvent e)
		{
			if (authImage != null)
			{
				authImage.dispose();
			}
			if (msgPromptFont != null)
			{
				msgPromptFont.dispose();
			}
			if (fieldsFont != null)
			{
				fieldsFont.dispose();
			}
		}
	});

	return parent;
}
 
Example 18
Source Project: pentaho-kettle   File: PasswordTextVar.java    License: Apache License 2.0 4 votes vote down vote up
public PasswordTextVar( VariableSpace space, Composite composite, int flags,
    GetCaretPositionInterface getCaretPositionInterface, InsertTextInterface insertTextInterface ) {
  super( space, composite, flags | SWT.PASSWORD, null, getCaretPositionInterface, insertTextInterface );
}
 
Example 19
public PasswordModifier(ModelEditor<?> editor, String field, Consumer<T> onChange) {
	super(editor, field, onChange);
	style = SWT.PASSWORD;
}
 
Example 20
Source Project: nebula   File: FormattedText.java    License: Eclipse Public License 2.0 2 votes vote down vote up
/**
 * Creates a formatted text on a newly-created text control under the given
* parent. The text control is created using the given SWT style bits.
 *
 * @param parent the parent control
 * @param style the SWT style bits used to create the text
 */
public FormattedText(Composite parent, int style) {
	this(new Text(parent, style & (~ (SWT.MULTI | SWT.PASSWORD | SWT.WRAP))));
}