Search in sources :

Example 1 with LabeledText

use of org.netxms.ui.eclipse.widgets.LabeledText in project netxms by netxms.

the class LoginDialog method createDialogArea.

/*
    * (non-Javadoc)
    * 
    * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite)
    */
@Override
protected Control createDialogArea(Composite parent) {
    IDialogSettings settings = Activator.getDefault().getDialogSettings();
    toolkit = new FormToolkit(parent.getDisplay());
    Form dialogArea = toolkit.createForm(parent);
    dialogArea.setLayoutData(new GridData(GridData.FILL_BOTH));
    applyDialogFont(dialogArea);
    GridLayout dialogLayout = new GridLayout();
    dialogLayout.numColumns = 2;
    dialogLayout.marginWidth = WidgetHelper.DIALOG_WIDTH_MARGIN;
    dialogLayout.marginHeight = WidgetHelper.DIALOG_HEIGHT_MARGIN;
    dialogLayout.horizontalSpacing = WidgetHelper.DIALOG_SPACING * 2;
    dialogArea.getBody().setLayout(dialogLayout);
    RGB customColor = BrandingManager.getInstance().getLoginTitleColor();
    labelColor = (customColor != null) ? new Color(dialogArea.getDisplay(), customColor) : new Color(dialogArea.getDisplay(), dialogArea.getBody().getBackground().getRGB());
    dialogArea.addDisposeListener(new DisposeListener() {

        @Override
        public void widgetDisposed(DisposeEvent e) {
            labelColor.dispose();
        }
    });
    // Login image
    Label label = new Label(dialogArea.getBody(), SWT.NONE);
    label.setBackground(labelColor);
    label.setImage(loginImage.createImage());
    label.addDisposeListener(new DisposeListener() {

        @Override
        public void widgetDisposed(DisposeEvent event) {
            ((Label) event.widget).getImage().dispose();
        }
    });
    GridData gd = new GridData();
    gd.horizontalAlignment = SWT.CENTER;
    gd.verticalAlignment = SWT.TOP;
    gd.grabExcessVerticalSpace = true;
    label.setLayoutData(gd);
    final Composite fields = toolkit.createComposite(dialogArea.getBody());
    fields.setBackgroundMode(SWT.INHERIT_DEFAULT);
    GridLayout fieldsLayout = new GridLayout();
    fieldsLayout.verticalSpacing = WidgetHelper.DIALOG_SPACING;
    fieldsLayout.marginHeight = 0;
    fieldsLayout.marginWidth = 0;
    fields.setLayout(fieldsLayout);
    gd = new GridData();
    gd.horizontalAlignment = SWT.FILL;
    gd.grabExcessHorizontalSpace = true;
    gd.verticalAlignment = SWT.TOP;
    gd.grabExcessVerticalSpace = true;
    fields.setLayoutData(gd);
    gd = new GridData();
    gd.horizontalAlignment = SWT.FILL;
    gd.grabExcessHorizontalSpace = true;
    comboServer = WidgetHelper.createLabeledCombo(fields, SWT.DROP_DOWN, Messages.get().LoginDialog_server, gd, toolkit);
    checkSlowLink = new Button(fields, SWT.CHECK);
    checkSlowLink.setText(Messages.get().LoginDialog_SlowLinkConnection);
    gd = new GridData();
    gd.horizontalIndent = 8;
    checkSlowLink.setLayoutData(gd);
    textLogin = new LabeledText(fields, SWT.NONE, SWT.SINGLE | SWT.BORDER, toolkit);
    textLogin.setLabel(Messages.get().LoginDialog_login);
    gd = new GridData();
    gd.horizontalAlignment = SWT.FILL;
    gd.grabExcessHorizontalSpace = true;
    // $NON-NLS-1$
    gd.widthHint = WidgetHelper.getTextWidth(textLogin, "M") * 24;
    textLogin.setLayoutData(gd);
    gd = new GridData();
    gd.horizontalAlignment = SWT.FILL;
    gd.grabExcessHorizontalSpace = true;
    comboAuth = WidgetHelper.createLabeledCombo(fields, SWT.DROP_DOWN | SWT.READ_ONLY, Messages.get().LoginDialog_Auth, gd, toolkit);
    comboAuth.add(Messages.get().LoginDialog_Passwd);
    comboAuth.add(Messages.get().LoginDialog_Cert);
    comboAuth.select(authMethod.getValue());
    comboAuth.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            selectAuthenticationField(true);
        }
    });
    authEntryFields = toolkit.createComposite(fields);
    authEntryFields.setLayout(new StackLayout());
    authEntryFields.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
    textPassword = new LabeledText(authEntryFields, SWT.NONE, SWT.SINGLE | SWT.BORDER | SWT.PASSWORD, toolkit);
    textPassword.setLabel(Messages.get().LoginDialog_Passwd);
    comboCert = WidgetHelper.createLabeledCombo(authEntryFields, SWT.DROP_DOWN | SWT.READ_ONLY, Messages.get().LoginDialog_Cert, null, toolkit);
    comboCert.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            selectCertificate();
        }
    });
    // Read field data
    // $NON-NLS-1$
    String[] items = settings.getArray("Connect.ServerHistory");
    if (items != null)
        comboServer.setItems(items);
    // $NON-NLS-1$
    String text = settings.get("Connect.Server");
    if (text != null)
        comboServer.setText(text);
    // $NON-NLS-1$
    text = settings.get("Connect.Login");
    if (text != null)
        textLogin.setText(text);
    // $NON-NLS-1$
    checkSlowLink.setSelection(settings.getBoolean("Connect.SlowLink"));
    try {
        // $NON-NLS-1$
        authMethod = AuthenticationType.getByValue(settings.getInt("Connect.AuthMethod"));
    } catch (NumberFormatException e) {
        authMethod = AuthenticationType.PASSWORD;
    }
    comboAuth.select(authMethod.getValue());
    selectAuthenticationField(false);
    // Set initial focus
    if (comboServer.getText().isEmpty()) {
        comboServer.setFocus();
    } else if (textLogin.getText().isEmpty()) {
        textLogin.setFocus();
    } else {
        if (authMethod == AuthenticationType.PASSWORD)
            textPassword.setFocus();
        else if (authMethod == AuthenticationType.CERTIFICATE)
            comboCert.setFocus();
    }
    return dialogArea;
}
Also used : DisposeListener(org.eclipse.swt.events.DisposeListener) FormToolkit(org.eclipse.ui.forms.widgets.FormToolkit) Composite(org.eclipse.swt.widgets.Composite) Form(org.eclipse.ui.forms.widgets.Form) LabeledText(org.netxms.ui.eclipse.widgets.LabeledText) Color(org.eclipse.swt.graphics.Color) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Label(org.eclipse.swt.widgets.Label) RGB(org.eclipse.swt.graphics.RGB) DisposeEvent(org.eclipse.swt.events.DisposeEvent) GridLayout(org.eclipse.swt.layout.GridLayout) IDialogSettings(org.eclipse.jface.dialogs.IDialogSettings) Button(org.eclipse.swt.widgets.Button) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) StackLayout(org.eclipse.swt.custom.StackLayout)

Example 2 with LabeledText

use of org.netxms.ui.eclipse.widgets.LabeledText in project netxms by netxms.

the class PasswordRequestDialog method createDialogArea.

/* (non-Javadoc)
	 * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite)
	 */
@Override
protected Control createDialogArea(Composite parent) {
    final Composite container = (Composite) super.createDialogArea(parent);
    GridLayout layout = new GridLayout();
    layout.verticalSpacing = WidgetHelper.DIALOG_SPACING;
    layout.marginWidth = WidgetHelper.DIALOG_WIDTH_MARGIN;
    layout.marginHeight = WidgetHelper.DIALOG_HEIGHT_MARGIN;
    container.setLayout(layout);
    lblMessage = new Label(container, SWT.NONE | SWT.WRAP);
    lblMessage.setText(message);
    lblMessage.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
    textPassword = new LabeledText(container, SWT.NONE, SWT.BORDER | SWT.PASSWORD);
    textPassword.setLabel(Messages.get().LoginDialog_Passwd);
    GridData gd = new GridData();
    gd.grabExcessHorizontalSpace = true;
    gd.horizontalAlignment = SWT.FILL;
    gd.widthHint = 400;
    textPassword.setLayoutData(gd);
    return container;
}
Also used : GridLayout(org.eclipse.swt.layout.GridLayout) Composite(org.eclipse.swt.widgets.Composite) LabeledText(org.netxms.ui.eclipse.widgets.LabeledText) Label(org.eclipse.swt.widgets.Label) GridData(org.eclipse.swt.layout.GridData)

Example 3 with LabeledText

use of org.netxms.ui.eclipse.widgets.LabeledText in project netxms by netxms.

the class CreateNewCertificateDialog method createDialogArea.

/* (non-Javadoc)
	 * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite)
	 */
@Override
protected Control createDialogArea(Composite parent) {
    Composite dialogArea = (Composite) super.createDialogArea(parent);
    GridLayout layout = new GridLayout();
    layout.marginHeight = WidgetHelper.DIALOG_HEIGHT_MARGIN;
    layout.marginWidth = WidgetHelper.DIALOG_WIDTH_MARGIN;
    layout.verticalSpacing = WidgetHelper.DIALOG_SPACING;
    dialogArea.setLayout(layout);
    textFileName = WidgetHelper.createLabeledText(dialogArea, SWT.BORDER, 300, Messages.get().CreateNewCertificateDialog_FileNameLabel, null, WidgetHelper.DEFAULT_LAYOUT_DATA);
    browseButton = new Button(dialogArea, SWT.PUSH);
    browseButton.setText(Messages.get().CreateNewCertificateDialog_BrowseLabel);
    GridData gd = new GridData();
    gd.horizontalAlignment = SWT.RIGHT;
    gd.widthHint = WidgetHelper.BUTTON_WIDTH_HINT;
    browseButton.setLayoutData(gd);
    browseButton.addSelectionListener(new SelectionListener() {

        @Override
        public void widgetDefaultSelected(SelectionEvent e) {
            widgetSelected(e);
        }

        @Override
        public void widgetSelected(SelectionEvent e) {
            FileDialog fd = new FileDialog(getShell(), SWT.OPEN);
            fd.setText(Messages.get().CreateNewCertificateDialog_SelectFileHeader);
            String selected = fd.open();
            if (selected != null)
                textFileName.setText(selected);
        }
    });
    textComments = new LabeledText(dialogArea, SWT.MULTI);
    textComments.setLabel(Messages.get().CreateNewCertificateDialog_CertificateCommentLabel);
    GridData gdText = new GridData();
    gdText.horizontalAlignment = SWT.FILL;
    gdText.horizontalSpan = 2;
    gdText.grabExcessHorizontalSpace = true;
    textComments.setLayoutData(gdText);
    return dialogArea;
}
Also used : GridLayout(org.eclipse.swt.layout.GridLayout) Composite(org.eclipse.swt.widgets.Composite) Button(org.eclipse.swt.widgets.Button) LabeledText(org.netxms.ui.eclipse.widgets.LabeledText) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) FileDialog(org.eclipse.swt.widgets.FileDialog) SelectionListener(org.eclipse.swt.events.SelectionListener)

Example 4 with LabeledText

use of org.netxms.ui.eclipse.widgets.LabeledText in project netxms by netxms.

the class EditCertificateDialog method createDialogArea.

/*
    * (non-Javadoc)
    * 
    * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite)
    */
@Override
protected Control createDialogArea(Composite parent) {
    Composite dialogArea = (Composite) super.createDialogArea(parent);
    GridLayout layout = new GridLayout();
    layout.marginHeight = WidgetHelper.DIALOG_HEIGHT_MARGIN;
    layout.marginWidth = WidgetHelper.DIALOG_WIDTH_MARGIN;
    layout.verticalSpacing = WidgetHelper.DIALOG_SPACING;
    dialogArea.setLayout(layout);
    GridData gd = new GridData();
    gd.horizontalAlignment = SWT.FILL;
    gd.grabExcessHorizontalSpace = true;
    gd.widthHint = 300;
    textId = new LabeledText(dialogArea, SWT.NONE);
    textId.setEditable(false);
    textId.setLabel(Messages.get().EditCertificateDialog_CertIDLabel);
    textId.setText(Long.toString(cert.getId()));
    textId.setLayoutData(gd);
    comboType = WidgetHelper.createLabeledCombo(dialogArea, SWT.READ_ONLY, Messages.get().EditCertificateDialog_CertTypeLabel, WidgetHelper.DEFAULT_LAYOUT_DATA);
    String[] options = { Messages.get().EditCertificateDialog_CertType_AC, Messages.get().EditCertificateDialog_CertType_UC };
    comboType.add(options[cert.getType()]);
    comboType.select(0);
    textSubject = new LabeledText(dialogArea, SWT.NONE);
    textSubject.setEditable(false);
    textSubject.setLabel(Messages.get().EditCertificateDialog_CertSubjectLabel);
    textSubject.setText(cert.getSubject());
    textSubject.setLayoutData(gd);
    textComments = new LabeledText(dialogArea, SWT.NONE);
    textComments.setLabel(Messages.get().EditCertificateDialog_CertCommentLabel);
    textComments.setText(cert.getComments());
    textComments.setLayoutData(gd);
    return dialogArea;
}
Also used : GridLayout(org.eclipse.swt.layout.GridLayout) Composite(org.eclipse.swt.widgets.Composite) LabeledText(org.netxms.ui.eclipse.widgets.LabeledText) GridData(org.eclipse.swt.layout.GridData)

Example 5 with LabeledText

use of org.netxms.ui.eclipse.widgets.LabeledText in project netxms by netxms.

the class EventMonitor method createContents.

@Override
protected Control createContents(Composite parent) {
    config = (EventMonitorConfig) getElement().getAdapter(EventMonitorConfig.class);
    Composite dialogArea = new Composite(parent, SWT.NONE);
    GridLayout layout = new GridLayout();
    dialogArea.setLayout(layout);
    objectSelector = new ObjectSelector(dialogArea, SWT.NONE, true);
    objectSelector.setLabel("Root object");
    objectSelector.setObjectClass(AbstractObject.class);
    objectSelector.setObjectId(config.getObjectId());
    GridData gd = new GridData();
    gd.horizontalAlignment = SWT.FILL;
    gd.grabExcessHorizontalSpace = true;
    objectSelector.setLayoutData(gd);
    title = new LabeledText(dialogArea, SWT.NONE);
    title.setLabel("Title");
    title.setText(config.getTitle());
    gd = new GridData();
    gd.horizontalAlignment = SWT.FILL;
    gd.grabExcessHorizontalSpace = true;
    title.setLayoutData(gd);
    return dialogArea;
}
Also used : GridLayout(org.eclipse.swt.layout.GridLayout) ObjectSelector(org.netxms.ui.eclipse.objectbrowser.widgets.ObjectSelector) Composite(org.eclipse.swt.widgets.Composite) LabeledText(org.netxms.ui.eclipse.widgets.LabeledText) GridData(org.eclipse.swt.layout.GridData)

Aggregations

Composite (org.eclipse.swt.widgets.Composite)104 LabeledText (org.netxms.ui.eclipse.widgets.LabeledText)104 GridLayout (org.eclipse.swt.layout.GridLayout)103 GridData (org.eclipse.swt.layout.GridData)102 Button (org.eclipse.swt.widgets.Button)50 SelectionEvent (org.eclipse.swt.events.SelectionEvent)37 SelectionListener (org.eclipse.swt.events.SelectionListener)31 Group (org.eclipse.swt.widgets.Group)24 ObjectSelector (org.netxms.ui.eclipse.objectbrowser.widgets.ObjectSelector)22 Label (org.eclipse.swt.widgets.Label)18 RowLayout (org.eclipse.swt.layout.RowLayout)11 Spinner (org.eclipse.swt.widgets.Spinner)11 ModifyEvent (org.eclipse.swt.events.ModifyEvent)9 ModifyListener (org.eclipse.swt.events.ModifyListener)9 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)8 LabeledSpinner (org.netxms.ui.eclipse.widgets.LabeledSpinner)8 ColorSelector (org.eclipse.jface.preference.ColorSelector)6 DisposeEvent (org.eclipse.swt.events.DisposeEvent)6 DisposeListener (org.eclipse.swt.events.DisposeListener)6 WidgetFactory (org.netxms.ui.eclipse.tools.WidgetFactory)6