/** * DOC smallet ConnectionsComposite constructor comment. * * @param parent * @param style */ public ConnectionFormComposite( Composite parent, int style, ConnectionsListComposite connectionsListComposite, ConnectionsDialog dialog) { super(parent, style); this.dialog = dialog; this.connectionsListComposite = connectionsListComposite; toolkit = new FormToolkit(this.getDisplay()); toolkit.setBackground(ColorConstants.white); Composite formBody = toolkit.createComposite(this); formBody.setBackground(ColorConstants.white); GridLayout layout = new GridLayout(); layout.marginHeight = 0; layout.marginWidth = 0; setLayout(layout); formBody.setLayoutData(new GridData(GridData.FILL_BOTH)); formBody.setLayout(new GridLayout(3, false)); GridDataFactory formDefaultFactory = GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER); // Repository Label repositoryLabel = toolkit.createLabel( formBody, Messages.getString("connections.form.field.repository")); // $NON-NLS-1$ formDefaultFactory.copy().applyTo(repositoryLabel); repositoryCombo = new ComboViewer(formBody, SWT.BORDER | SWT.READ_ONLY); repositoryCombo.setContentProvider(ArrayContentProvider.getInstance()); repositoryCombo.setLabelProvider(new RepositoryFactoryLabelProvider()); formDefaultFactory.copy().grab(true, false).span(2, 1).applyTo(repositoryCombo.getControl()); // Name Label nameLabel = toolkit.createLabel( formBody, Messages.getString("connections.form.field.name")); // $NON-NLS-1$ formDefaultFactory.copy().applyTo(nameLabel); nameText = toolkit.createText(formBody, "", SWT.BORDER); // $NON-NLS-1$ formDefaultFactory.copy().grab(true, false).span(2, 1).applyTo(nameText); // Comment Label descriptionLabel = toolkit.createLabel( formBody, Messages.getString("connections.form.field.description")); // $NON-NLS-1$ formDefaultFactory.copy().applyTo(descriptionLabel); descriptionText = toolkit.createText(formBody, "", SWT.BORDER); // $NON-NLS-1$ formDefaultFactory.copy().grab(true, false).span(2, 1).applyTo(descriptionText); // User IBrandingService brandingService = (IBrandingService) GlobalServiceRegister.getDefault().getService(IBrandingService.class); boolean usesMailCheck = brandingService.getBrandingConfiguration().isUseMailLoginCheck(); Label userLabel; if (usesMailCheck) { userLabel = toolkit.createLabel( formBody, Messages.getString("connections.form.field.username")); // $NON-NLS-1$ } else { userLabel = toolkit.createLabel( formBody, Messages.getString("connections.form.field.usernameNoMail")); // $NON-NLS-1$ } formDefaultFactory.copy().applyTo(userLabel); userText = toolkit.createText(formBody, "", SWT.BORDER); // $NON-NLS-1$ formDefaultFactory.copy().grab(true, false).span(2, 1).applyTo(userText); // Password passwordLabel = toolkit.createLabel( formBody, Messages.getString("connections.form.field.password")); // $NON-NLS-1$ formDefaultFactory.copy().applyTo(passwordLabel); passwordText = toolkit.createText(formBody, "", SWT.PASSWORD | SWT.BORDER); // $NON-NLS-1$ formDefaultFactory.copy().grab(true, false).span(2, 1).applyTo(passwordText); Label workSpaceLabel = toolkit.createLabel( formBody, Messages.getString("ConnectionFormComposite.WORKSPACE")); // $NON-NLS-1$ formDefaultFactory.copy().applyTo(workSpaceLabel); Composite wsCompo = toolkit.createComposite(formBody); GridLayout wsCompoLayout = new GridLayout(2, false); wsCompoLayout.marginHeight = 0; wsCompoLayout.marginWidth = 0; wsCompo.setLayout(wsCompoLayout); formDefaultFactory.copy().grab(true, false).span(2, 1).applyTo(wsCompo); workSpaceText = toolkit.createText(wsCompo, "", SWT.BORDER); // $NON-NLS-1$ formDefaultFactory.copy().grab(true, false).applyTo(workSpaceText); workSpaceButton = toolkit.createButton(wsCompo, null, SWT.PUSH); workSpaceButton.setToolTipText( Messages.getString("ConnectionFormComposite.SELECT_WORKSPACE")); // $NON-NLS-1$ workSpaceButton.setImage(ImageProvider.getImage(EImage.THREE_DOTS_ICON)); GridDataFactory.fillDefaults().applyTo(workSpaceButton); List<IRepositoryFactory> availableRepositories = getUsableRepositoryProvider(); for (IRepositoryFactory current : availableRepositories) { Map<String, LabelText> list = new HashMap<String, LabelText>(); Map<String, LabelText> listRequired = new HashMap<String, LabelText>(); Map<String, Button> listButtons = new HashMap<String, Button>(); Map<String, LabelledCombo> listChoices = new HashMap<String, LabelledCombo>(); dynamicControls.put(current, list); dynamicRequiredControls.put(current, listRequired); dynamicButtons.put(current, listButtons); dynamicChoices.put(current, listChoices); for (final DynamicChoiceBean currentChoiceBean : current.getChoices()) { Label label = toolkit.createLabel(formBody, currentChoiceBean.getName()); formDefaultFactory.copy().applyTo(label); Combo combo = new Combo(formBody, SWT.BORDER | SWT.READ_ONLY); for (String label1 : currentChoiceBean.getChoices().values()) { combo.add(label1); } formDefaultFactory.copy().grab(true, false).applyTo(combo); listChoices.put(currentChoiceBean.getId(), new LabelledCombo(label, combo)); } for (DynamicFieldBean currentField : current.getFields()) { int textStyle = SWT.BORDER; if (currentField.isPassword()) { textStyle = textStyle | SWT.PASSWORD; } Label label = toolkit.createLabel(formBody, currentField.getName()); formDefaultFactory.copy().align(SWT.FILL, SWT.CENTER).applyTo(label); Text text = toolkit.createText(formBody, "", textStyle); // $NON-NLS-1$ formDefaultFactory.copy().grab(true, false).align(SWT.FILL, SWT.CENTER).applyTo(text); LabelText labelText = new LabelText(label, text); if (currentField.isRequired()) { listRequired.put(currentField.getId(), labelText); } list.put(currentField.getId(), labelText); } for (final DynamicButtonBean currentButtonBean : current.getButtons()) { Button button = new Button(formBody, SWT.PUSH); button.setText(currentButtonBean.getName()); button.addSelectionListener(new DelegateSelectionListener(currentButtonBean)); formDefaultFactory.copy().align(SWT.RIGHT, SWT.CENTER).applyTo(button); listButtons.put(currentButtonBean.getId(), button); } } Label seperator = new Label(formBody, SWT.NONE); seperator.setVisible(false); GridData seperatorGridData = new GridData(); seperatorGridData.horizontalSpan = 3; seperatorGridData.heightHint = 0; seperator.setLayoutData(seperatorGridData); Label placeHolder = new Label(formBody, SWT.NONE); // add delete buttons deleteProjectsButton = new Button(formBody, SWT.NONE); deleteProjectsButton.setText( Messages.getString("ConnectionFormComposite.deleteExistingProject")); // $NON-NLS-1$ GridData deleteButtonGridData = new GridData(); deleteButtonGridData.widthHint = LoginDialogV2.getNewButtonSize(deleteProjectsButton).x; deleteButtonGridData.horizontalSpan = 2; deleteProjectsButton.setLayoutData(deleteButtonGridData); addListeners(); addWorkSpaceListener(); fillLists(); showHideDynamicsControls(); showHideTexts(); // validateFields(); }
/** * DOC smallet ConnectionsComposite constructor comment. * * @param parent * @param style */ public ConnectionFormComposite( Composite parent, int style, ConnectionsListComposite connectionsListComposite, ConnectionsDialog dialog) { super(parent, style); this.dialog = dialog; this.connectionsListComposite = connectionsListComposite; toolkit = new FormToolkit(this.getDisplay()); ScrolledForm form = toolkit.createScrolledForm(this); Composite formBody = form.getBody(); GridLayout layout = new GridLayout(); layout.marginHeight = 0; layout.marginWidth = 0; setLayout(layout); form.setLayoutData(new GridData(GridData.FILL_BOTH)); final int hSpan = 10; formBody.setLayout(new GridLayout(2, false)); // Repository Label repositoryLabel = toolkit.createLabel( formBody, Messages.getString("connections.form.field.repository")); // $NON-NLS-1$ GridDataFactory.fillDefaults().applyTo(repositoryLabel); repositoryCombo = new ComboViewer(formBody, SWT.BORDER | SWT.READ_ONLY); repositoryCombo.setContentProvider(new ArrayContentProvider()); repositoryCombo.setLabelProvider(new RepositoryFactoryLabelProvider()); GridDataFactory.fillDefaults().grab(true, false).applyTo(repositoryCombo.getControl()); // Name Label nameLabel = toolkit.createLabel( formBody, Messages.getString("connections.form.field.name")); // $NON-NLS-1$ GridDataFactory.fillDefaults().applyTo(nameLabel); nameText = toolkit.createText(formBody, "", SWT.BORDER); // $NON-NLS-1$ GridDataFactory.fillDefaults().grab(true, false).applyTo(nameText); // Comment Label descriptionLabel = toolkit.createLabel( formBody, Messages.getString("connections.form.field.description")); // $NON-NLS-1$ GridDataFactory.fillDefaults().applyTo(descriptionLabel); descriptionText = toolkit.createText(formBody, "", SWT.BORDER); // $NON-NLS-1$ GridDataFactory.fillDefaults().grab(true, false).applyTo(descriptionText); // User IBrandingService brandingService = (IBrandingService) GlobalServiceRegister.getDefault().getService(IBrandingService.class); boolean usesMailCheck = brandingService.getBrandingConfiguration().isUseMailLoginCheck(); Label userLabel; if (usesMailCheck) { userLabel = toolkit.createLabel( formBody, Messages.getString("connections.form.field.username")); // $NON-NLS-1$ } else { userLabel = toolkit.createLabel( formBody, Messages.getString("connections.form.field.usernameNoMail")); // $NON-NLS-1$ } GridDataFactory.fillDefaults().applyTo(userLabel); userText = toolkit.createText(formBody, "", SWT.BORDER); // $NON-NLS-1$ GridDataFactory.fillDefaults().grab(true, false).applyTo(userText); // Password Label passwordLabel = toolkit.createLabel( formBody, Messages.getString("connections.form.field.password")); // $NON-NLS-1$ GridDataFactory.fillDefaults().applyTo(passwordLabel); passwordText = toolkit.createText(formBody, "", SWT.PASSWORD | SWT.BORDER); // $NON-NLS-1$ GridDataFactory.fillDefaults().grab(true, false).applyTo(passwordText); GridData data; List<IRepositoryFactory> availableRepositories = getUsableRepositoryProvider(); for (IRepositoryFactory current : availableRepositories) { Map<String, LabelText> list = new HashMap<String, LabelText>(); Map<String, LabelText> listRequired = new HashMap<String, LabelText>(); Map<String, Button> listButtons = new HashMap<String, Button>(); Map<String, LabelledCombo> listChoices = new HashMap<String, LabelledCombo>(); dynamicControls.put(current, list); dynamicRequiredControls.put(current, listRequired); dynamicButtons.put(current, listButtons); dynamicChoices.put(current, listChoices); Control baseControl = passwordLabel; for (final DynamicChoiceBean currentChoiceBean : current.getChoices()) { Label label = toolkit.createLabel(formBody, currentChoiceBean.getName()); GridDataFactory.fillDefaults().applyTo(label); Combo combo = new Combo(formBody, SWT.BORDER | SWT.READ_ONLY); for (String label1 : currentChoiceBean.getChoices().values()) { combo.add(label1); } GridDataFactory.fillDefaults().grab(true, false).applyTo(combo); baseControl = combo; listChoices.put(currentChoiceBean.getId(), new LabelledCombo(label, combo)); } for (DynamicFieldBean currentField : current.getFields()) { int textStyle = SWT.BORDER; if (currentField.isPassword()) { textStyle = textStyle | SWT.PASSWORD; } Label label = toolkit.createLabel(formBody, currentField.getName()); GridDataFactory.fillDefaults().applyTo(label); Text text = toolkit.createText(formBody, "", textStyle); // $NON-NLS-1$ GridDataFactory.fillDefaults().grab(true, false).applyTo(text); baseControl = text; LabelText labelText = new LabelText(label, text); if (currentField.isRequired()) { listRequired.put(currentField.getId(), labelText); } list.put(currentField.getId(), labelText); } for (final DynamicButtonBean currentButtonBean : current.getButtons()) { Label label = toolkit.createLabel(formBody, ""); // $NON-NLS-1$ label.setVisible(false); GridDataFactory.fillDefaults().applyTo(label); Button button = new Button(formBody, SWT.PUSH); button.setText(currentButtonBean.getName()); button.addSelectionListener(new DelegateSelectionListener(currentButtonBean)); GridDataFactory.fillDefaults().grab(true, false).applyTo(button); baseControl = button; listButtons.put(currentButtonBean.getId(), button); } } addListeners(); fillLists(); showHideDynamicsControls(); showHideTexts(); // validateFields(); }