/** * Gets all demo projects information. * * @return a list of <code>DemoProjectBean</code> */ public static List<DemoProjectBean> getAllDemoProjects() { SAXReader reader = new SAXReader(); Document doc = null; List<DemoProjectBean> demoProjectList = new ArrayList<DemoProjectBean>(); DemoProjectBean demoProject = null; List<File> xmlFilePath = getXMLFilePath(); for (int t = 0; t < xmlFilePath.size(); t++) { try { doc = reader.read(xmlFilePath.get(t)); } catch (DocumentException e) { ExceptionHandler.process(e); return null; } Element demoProjectsInfo = doc.getRootElement(); IBrandingService brandingService = (IBrandingService) GlobalServiceRegister.getDefault().getService(IBrandingService.class); String[] availableLanguages = brandingService.getBrandingConfiguration().getAvailableLanguages(); for (Iterator<DemoProjectBean> i = demoProjectsInfo.elementIterator("project"); i.hasNext(); ) { // $NON-NLS-1$ Element demoProjectElement = (Element) i.next(); demoProject = new DemoProjectBean(); demoProject.setProjectName(demoProjectElement.attributeValue("name")); // $NON-NLS-1$ String language = demoProjectElement.attributeValue("language"); // $NON-NLS-1$ if (!ArrayUtils.contains(availableLanguages, language)) { // if the language is not available in current branding, don't display this demo project continue; } demoProject.setLanguage(ECodeLanguage.getCodeLanguage(language)); String demoProjectFileType = demoProjectElement.attributeValue("demoProjectFileType"); // $NON-NLS-1$ demoProject.setDemoProjectFileType( EDemoProjectFileType.getDemoProjectFileTypeName(demoProjectFileType)); demoProject.setDemoProjectFilePath( demoProjectElement.attributeValue("demoFilePath")); // $NON-NLS-1$ demoProject.setDescriptionFilePath( demoProjectElement.attributeValue("descriptionFilePath")); // $NON-NLS-1$ // get the demo plugin Id demoProject.setPluginId(demoProjectElement.attributeValue("pluginId")); // $NON-NLS-1$ if (demoProject.getProjectName().equals("ESBDEMOS")) { if (!PluginChecker.isPluginLoaded("org.talend.repository.services")) { continue; } } demoProjectList.add(demoProject); } } return demoProjectList; }
public String getLabel(boolean checkVersion) { if (label == null && property != null) { if (checkVersion) { IBrandingService brandingService = (IBrandingService) GlobalServiceRegister.getDefault().getService(IBrandingService.class); boolean allowVerchange = brandingService.getBrandingConfiguration().isAllowChengeVersion(); if (allowVerchange && property.getItem().isNeedVersion()) { label = property.getLabel() + " " + property.getVersion(); // $NON-NLS-1$ return label; } } label = property.getLabel(); } return label; }
public String getItemName() { if (itemName == null) { IBrandingService brandingService = (IBrandingService) GlobalServiceRegister.getDefault().getService(IBrandingService.class); boolean allowVerchange = brandingService.getBrandingConfiguration().isAllowChengeVersion(); ERepositoryObjectType itemType = ERepositoryObjectType.getItemType(property.getItem()); StringBuffer sb = new StringBuffer(); if (itemType != null) { sb.append(itemType.toString()); sb.append(' '); } sb.append(property.getLabel()); if (allowVerchange) { sb.append(' '); sb.append(property.getVersion()); } itemName = sb.toString(); } return itemName; }
/* * (non-Javadoc) * * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite) */ public void createControl(Composite parent) { Composite container = new Composite(parent, SWT.NONE); GridLayout layout = new GridLayout(2, false); container.setLayout(layout); // Name Label nameLab = new Label(container, SWT.NONE); nameLab.setText(Messages.getString("NewProjectWizardPage.name")); // $NON-NLS-1$ nameText = new Text(container, SWT.BORDER); nameText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); // TechnicalName (for information only) Label technicalNameLab = new Label(container, SWT.NONE); technicalNameLab.setText( Messages.getString("NewProjectWizardPage.technicalName")); // $NON-NLS-1$ technicalNameText = new Text(container, SWT.BORDER); technicalNameText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); technicalNameText.setEnabled(false); // Description Label descriptionLab = new Label(container, SWT.NONE); descriptionLab.setText(Messages.getString("NewProjectWizardPage.comment")); // $NON-NLS-1$ descriptionLab.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING)); descriptionText = new Text(container, SWT.BORDER | SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL); GridData data = new GridData(GridData.FILL_HORIZONTAL); data.heightHint = 60; descriptionText.setLayoutData(data); // Language Label languageLab = new Label(container, SWT.NONE); languageLab.setText(Messages.getString("NewProjectWizardPage.language")); // $NON-NLS-1$ languageLab.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING)); Composite radioContainer = new Composite(container, SWT.NONE); radioContainer.setLayoutData( new GridData(GridData.FILL_HORIZONTAL + GridData.VERTICAL_ALIGN_BEGINNING)); GridLayout gridLayout = new GridLayout(); gridLayout.marginHeight = 0; radioContainer.setLayout(gridLayout); languageJavaRadio = new Button(radioContainer, SWT.RADIO); languageJavaRadio.setText(ECodeLanguage.JAVA.getName()); languageJavaRadio.setSelection(true); languagePerlRadio = new Button(radioContainer, SWT.RADIO); languagePerlRadio.setText(ECodeLanguage.PERL.getName() + " (deprecated)"); IBrandingService brandingService = (IBrandingService) GlobalServiceRegister.getDefault().getService(IBrandingService.class); String[] availableLanguages = brandingService.getBrandingConfiguration().getAvailableLanguages(); if (availableLanguages.length != 2) { if (ArrayUtils.contains(availableLanguages, ECodeLanguage.JAVA.getName())) { languagePerlRadio.setVisible(false); languageJavaRadio.setVisible(false); languageJavaRadio.setSelection(true); languageLab.setVisible(false); } if (ArrayUtils.contains(availableLanguages, ECodeLanguage.PERL.getName())) { languagePerlRadio.setSelection(true); languageJavaRadio.setVisible(false); languageJavaRadio.setVisible(false); languageLab.setVisible(false); } } // languageCombo = new Combo(container, SWT.BORDER | SWT.READ_ONLY); // languageCombo.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); // languageCombo.setItems(new String[] { ECodeLanguage.PERL.getName(), // ECodeLanguage.JAVA.getName() }); // languageCombo.select(0); setControl(container); addListeners(); setPageComplete(false); }
private boolean validateFields() { String errorMsg = null; boolean valid = true; if (dialog.getOKButton() != null) { dialog.getOKButton().setEnabled(true); } IBrandingService brandingService = (IBrandingService) GlobalServiceRegister.getDefault().getService(IBrandingService.class); boolean isOnlyRemoteConnection = brandingService.getBrandingConfiguration().isOnlyRemoteConnection(); boolean usesMailCheck = brandingService.getBrandingConfiguration().isUseMailLoginCheck(); LabelText emptyUrl = null; if (getRepository() != null) { for (LabelText currentUrlLabel : dynamicRequiredControls.get(getRepository()).values()) { if (valid && currentUrlLabel.getText().length() == 0) { emptyUrl = currentUrlLabel; } } } if (valid && getRepository() == null) { errorMsg = Messages.getString("connections.form.emptyField.repository"); // $NON-NLS-1$ } else if (valid && getTextName().length() == 0) { errorMsg = Messages.getString("connections.form.emptyField.connname"); // $NON-NLS-1$ } else if (valid && getUser().length() == 0) { errorMsg = Messages.getString("connections.form.emptyField.username"); // $NON-NLS-1$ } else if (valid && usesMailCheck && !Pattern.matches(RepositoryConstants.MAIL_PATTERN, getUser())) { errorMsg = Messages.getString("connections.form.malformedField.username"); // $NON-NLS-1$ } else if (valid && emptyUrl != null) { errorMsg = Messages.getString( "connections.form.dynamicFieldEmpty", emptyUrl.getLabel()); // $NON-NLS-1$ } else if (valid && !this.isValidatedWorkspace(this.getWorkspace())) { errorMsg = Messages.getString("ConnectionFormComposite.workspaceInvalid"); // $NON-NLS-1$ } else if (valid && isOnlyRemoteConnection) { // Uniserv feature 8,Add new Extension point to allow Uniserv to add some custom controls // during TAC // connection check List<ILoginConnectionService> loginConnections = LoginConnectionManager.getRemoteConnectionService(); for (ILoginConnectionService loginConncetion : loginConnections) { errorMsg = loginConncetion.checkConnectionValidation( getTextName(), getDesc(), getUser(), getPassword(), getWorkspace(), connection.getDynamicFields().get(RepositoryConstants.REPOSITORY_URL)); } } else if (valid && getTextName() != null) { List<ConnectionBean> connectionBeanList = dialog.getConnections(); if (connectionBeanList != null && connectionBeanList.size() > 1) { for (ConnectionBean connectionBean : connectionBeanList) { String connectionBeanName = connectionBean.getName(); if (connectionBeanName != null) { if (this.connection != connectionBean) { if (connectionBeanName.equals(getTextName())) { errorMsg = Messages.getString( "ConnectionFormComposite.connectionNameInvalid"); //$NON-NLS-1$ } } } } } } if (errorMsg != null && !errorMsg.equals("")) { // $NON-NLS-1$ valid = false; } if (!valid) { dialog.setErrorMessage(errorMsg); if (dialog.getOKButton() != null) { dialog.getOKButton().setEnabled(false); } } else { dialog.setErrorMessage(null); } if (connection != null) { connection.setComplete(valid); connectionsListComposite.refresh(connection); } return valid; }
/** * 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(); }