Search in sources :

Example 1 with LabelText

use of org.talend.commons.ui.swt.formtools.LabelText in project tdi-studio-se by Talend.

the class ConnectionFormComposite method fillBean.

private void fillBean(boolean cleanDynamicValue) {
    if (connection != null) {
        if (getRepository() != null) {
            connection.setRepositoryId(getRepository().getId());
            Map<String, String> connFields = new HashMap<String, String>();
            Map<String, LabelText> map = dynamicControls.get(getRepository());
            for (String fieldKey : map.keySet()) {
                if (cleanDynamicValue) {
                    map.get(fieldKey).setText("");
                }
                connFields.put(fieldKey, map.get(fieldKey).getText());
            }
            Map<String, LabelledCombo> map2 = dynamicChoices.get(getRepository());
            for (String fieldKey : map2.keySet()) {
                for (DynamicChoiceBean dynamicChoiceBean : getRepository().getChoices()) {
                    if (dynamicChoiceBean.getId().equals(fieldKey)) {
                        int selectionIndex = map2.get(fieldKey).getCombo().getSelectionIndex();
                        connFields.put(fieldKey, dynamicChoiceBean.getChoiceValue(selectionIndex));
                    }
                }
            }
            connection.setDynamicFields(connFields);
        }
        connection.setName(nameText.getText());
        connection.setDescription(descriptionText.getText());
        connection.setUser(userText.getText());
        connection.setPassword(passwordText.getText());
        connection.setWorkSpace(workSpaceText.getText());
        connectionsListComposite.refresh(connection);
    }
}
Also used : LabelledCombo(org.talend.commons.ui.swt.formtools.LabelledCombo) HashMap(java.util.HashMap) LabelText(org.talend.commons.ui.swt.formtools.LabelText) DynamicChoiceBean(org.talend.core.repository.model.DynamicChoiceBean)

Example 2 with LabelText

use of org.talend.commons.ui.swt.formtools.LabelText in project tdi-studio-se by Talend.

the class ConnectionFormComposite method fillFields.

private void fillFields() {
    if (connection != null) {
        removeListeners();
        String repositoryId = connection.getRepositoryId();
        if (repositoryId == null || "".equals(repositoryId)) {
            if (getRepository() != null) {
                connection.setRepositoryId(getRepository().getId());
            } else {
                connection.setRepositoryId(RepositoryConstants.REPOSITORY_LOCAL_ID);
            }
        }
        IRepositoryFactory repositoriyById = RepositoryFactoryProvider.getRepositoriyById(repositoryId);
        repositoryCombo.setSelection(new StructuredSelection(new Object[] { repositoriyById }));
        if (getRepository() != null) {
            Map<String, LabelText> map = dynamicControls.get(getRepository());
            for (String fieldKey : map.keySet()) {
                LabelText current = map.get(fieldKey);
                String string = connection.getDynamicFields().get(fieldKey);
                //$NON-NLS-1$
                current.setText(string == null ? "" : string);
            }
            Map<String, LabelledCombo> map2 = dynamicChoices.get(getRepository());
            for (String fieldKey : map2.keySet()) {
                Combo combo = map2.get(fieldKey).getCombo();
                String value = connection.getDynamicFields().get(fieldKey);
                combo.deselectAll();
                for (DynamicChoiceBean dynamicChoiceBean : getRepository().getChoices()) {
                    if (dynamicChoiceBean.getId().equals(fieldKey)) {
                        combo.select(dynamicChoiceBean.getChoiceIndex(value));
                    }
                }
            }
        }
        //$NON-NLS-1$
        nameText.setText((connection.getName() == null ? "" : connection.getName()));
        //$NON-NLS-1$
        descriptionText.setText((connection.getDescription() == null ? "" : connection.getDescription()));
        //$NON-NLS-1$
        userText.setText((connection.getUser() == null ? "" : connection.getUser()));
        //$NON-NLS-1$
        passwordText.setText((connection.getPassword() == null ? "" : connection.getPassword()));
        workSpaceText.setText(//$NON-NLS-1$
        ("".equals(connection.getWorkSpace()) || connection.getWorkSpace() == null) ? getRecentWorkSpace() : connection.getWorkSpace());
        addListeners();
    }
}
Also used : LabelledCombo(org.talend.commons.ui.swt.formtools.LabelledCombo) IRepositoryFactory(org.talend.core.repository.model.IRepositoryFactory) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) LabelText(org.talend.commons.ui.swt.formtools.LabelText) Combo(org.eclipse.swt.widgets.Combo) LabelledCombo(org.talend.commons.ui.swt.formtools.LabelledCombo) DynamicChoiceBean(org.talend.core.repository.model.DynamicChoiceBean)

Example 3 with LabelText

use of org.talend.commons.ui.swt.formtools.LabelText in project tdi-studio-se by Talend.

the class ConnectionFormComposite method validateFields.

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) {
        //$NON-NLS-1$
        errorMsg = Messages.getString("connections.form.emptyField.repository");
    } else if (valid && getTextName().length() == 0) {
        //$NON-NLS-1$
        errorMsg = Messages.getString("connections.form.emptyField.connname");
    } else if (valid && getUser().length() == 0) {
        //$NON-NLS-1$
        errorMsg = Messages.getString("connections.form.emptyField.username");
    } else if (valid && isLocalConnection() && !Pattern.matches(RepositoryConstants.MAIL_PATTERN, getUser())) {
        //$NON-NLS-1$
        errorMsg = Messages.getString("connections.form.malformedField.username");
    } else if (valid && emptyUrl != null) {
        //$NON-NLS-1$
        errorMsg = Messages.getString("connections.form.dynamicFieldEmpty", emptyUrl.getLabel());
    } else if (valid && !this.isValidatedWorkspace(this.getWorkspace())) {
        //$NON-NLS-1$
        errorMsg = Messages.getString("ConnectionFormComposite.workspaceInvalid");
    } 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())) {
                            //$NON-NLS-1$
                            errorMsg = Messages.getString("ConnectionFormComposite.connectionNameInvalid");
                        }
                    }
                }
            }
        }
    }
    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;
}
Also used : ILoginConnectionService(org.talend.core.repository.services.ILoginConnectionService) LabelText(org.talend.commons.ui.swt.formtools.LabelText) List(java.util.List) ArrayList(java.util.ArrayList) ConnectionBean(org.talend.core.model.general.ConnectionBean) IBrandingService(org.talend.core.ui.branding.IBrandingService)

Example 4 with LabelText

use of org.talend.commons.ui.swt.formtools.LabelText in project tdi-studio-se by Talend.

the class ConnectionFormComposite method addListeners.

private void addListeners() {
    repositoryCombo.addPostSelectionChangedListener(repositoryListener);
    nameText.addModifyListener(standardTextListener);
    descriptionText.addModifyListener(standardTextListener);
    userText.addModifyListener(standardTextListener);
    passwordText.addModifyListener(standardTextListener);
    workSpaceText.addModifyListener(standardTextListener);
    for (IRepositoryFactory f : dynamicControls.keySet()) {
        for (LabelText control : dynamicControls.get(f).values()) {
            control.addModifyListener(standardTextListener);
        }
    }
    for (IRepositoryFactory f : dynamicChoices.keySet()) {
        for (LabelledCombo control : dynamicChoices.get(f).values()) {
            control.getCombo().addModifyListener(standardTextListener);
        }
    }
    deleteProjectsButton.addSelectionListener(deleteProjectClickListener);
}
Also used : LabelledCombo(org.talend.commons.ui.swt.formtools.LabelledCombo) IRepositoryFactory(org.talend.core.repository.model.IRepositoryFactory) LabelText(org.talend.commons.ui.swt.formtools.LabelText)

Example 5 with LabelText

use of org.talend.commons.ui.swt.formtools.LabelText in project tdi-studio-se by Talend.

the class ConnectionFormComposite method showHideDynamicsControls.

private void showHideDynamicsControls() {
    // 1. Hide all controls:
    for (IRepositoryFactory f : dynamicControls.keySet()) {
        for (LabelText control : dynamicControls.get(f).values()) {
            // control.setVisible(false);
            hideControl(control.getLabelControl(), true, false);
            hideControl(control.getTextControl(), true, false);
        }
        for (Button control : dynamicButtons.get(f).values()) {
            // control.setVisible(false);
            hideControl(control, true, false);
        }
        for (LabelledCombo control : dynamicChoices.get(f).values()) {
            // control.setVisible(false);
            hideControl(control.getCombo(), true, false);
        }
    }
    // 2. Show active repository controls:
    if (getRepository() != null) {
        for (LabelText control : dynamicControls.get(getRepository()).values()) {
            // control.setVisible(true);
            hideControl(control.getLabelControl(), false, false);
            hideControl(control.getTextControl(), false, false);
        }
        for (Button control : dynamicButtons.get(getRepository()).values()) {
            // control.setVisible(true);
            hideControl(control, false, false);
        }
        for (LabelledCombo control : dynamicChoices.get(getRepository()).values()) {
            // control.setVisible(true);
            hideControl(control.getCombo(), false, false);
        }
    }
    nameText.getParent().layout();
}
Also used : LabelledCombo(org.talend.commons.ui.swt.formtools.LabelledCombo) IRepositoryFactory(org.talend.core.repository.model.IRepositoryFactory) Button(org.eclipse.swt.widgets.Button) LabelText(org.talend.commons.ui.swt.formtools.LabelText)

Aggregations

LabelText (org.talend.commons.ui.swt.formtools.LabelText)6 LabelledCombo (org.talend.commons.ui.swt.formtools.LabelledCombo)5 IRepositoryFactory (org.talend.core.repository.model.IRepositoryFactory)4 DynamicChoiceBean (org.talend.core.repository.model.DynamicChoiceBean)2 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 List (java.util.List)1 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)1 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)1 Button (org.eclipse.swt.widgets.Button)1 Combo (org.eclipse.swt.widgets.Combo)1 ConnectionBean (org.talend.core.model.general.ConnectionBean)1 ILoginConnectionService (org.talend.core.repository.services.ILoginConnectionService)1 IBrandingService (org.talend.core.ui.branding.IBrandingService)1