use of org.talend.core.repository.model.DynamicChoiceBean 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);
}
}
use of org.talend.core.repository.model.DynamicChoiceBean 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();
}
}
Aggregations