use of org.talend.repository.nosql.db.model.mongodb.MongoDBReplicaFieldModel in project tbd-studio-se by Talend.
the class MongoDBConnForm method addConnectionGroup.
/**
* DOC PLV Comment method "addConnectionGroup".
*/
private void addConnectionGroup(Composite composite) {
// create group
// $NON-NLS-1$
connectionGroup = Form.createGroup(composite, 4, Messages.getString("MongoDBConnForm.connection"));
connectionGroup.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
GridLayout gpGrid = new GridLayout(4, false);
gpGrid.marginWidth = 5;
gpGrid.marginHeight = 5;
connectionGroup.setLayout(gpGrid);
Composite versionComposite = new Composite(connectionGroup, SWT.NONE);
versionComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 4, 1));
GridLayout versionCompLayout = new GridLayout(4, false);
versionCompLayout.marginWidth = 0;
versionCompLayout.marginHeight = 0;
versionComposite.setLayout(versionCompLayout);
// create DB_Version Combo
NoSQLRepositoryFactory repFactory = NoSQLRepositoryFactory.getInstance();
List<String> dbVersions = repFactory.getDBVersions(getConnection().getDbType());
List<String> dbVersionLabels = repositoryTranslator.getLabels(dbVersions);
dbVersionCombo = new LabelledCombo(versionComposite, Messages.getString("MongoDBConnForm.dbVersion"), Messages.getString("MongoDBConnForm.dbVersionTip"), dbVersionLabels.toArray(new String[0]), 3, // $NON-NLS-1$ //$NON-NLS-2$
true);
// create replica button
checkUseReplicaBtn = new Button(versionComposite, SWT.CHECK);
// $NON-NLS-1$
checkUseReplicaBtn.setText(Messages.getString("MongoDBConnForm.useReplicaBtn"));
checkUseReplicaBtn.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, true, false, 4, 1));
// create connection string
Composite connstrComposite = new Composite(versionComposite, SWT.NONE);
connstrComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 4, 1));
GridLayout connstrCompLayout = new GridLayout(4, false);
connstrCompLayout.marginWidth = 0;
connstrCompLayout.marginHeight = 0;
connstrComposite.setLayout(versionCompLayout);
checkUseConnStringBtn = new Button(connstrComposite, SWT.CHECK);
// $NON-NLS-1$
checkUseConnStringBtn.setText(Messages.getString("MongoDBConnForm.useConnStringBtn"));
checkUseConnStringBtn.setLayoutData(new GridData(SWT.BEGINNING, SWT.LEFT, false, false, 1, 1));
connStringText = new Text(connstrComposite, SWT.BORDER | SWT.SINGLE);
connStringText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 3, 1));
connStringText.setVisible(false);
// create connection composite
connComposite = new Composite(connectionGroup, SWT.NONE);
connComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 4, 1));
GridLayout connCompLayout = new GridLayout(4, false);
connCompLayout.marginWidth = 0;
connCompLayout.marginHeight = 0;
connComposite.setLayout(connCompLayout);
// $NON-NLS-1$
serverText = new LabelledText(connComposite, Messages.getString("MongoDBConnForm.server"), 1);
// $NON-NLS-1$
portText = new LabelledText(connComposite, Messages.getString("MongoDBConnForm.port"), 1);
// create replica field
replicaComposite = new Composite(connectionGroup, SWT.NONE);
replicaComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 4, 1));
GridLayout replicaLayout = new GridLayout();
replicaLayout.marginWidth = 0;
replicaLayout.marginHeight = 0;
replicaComposite.setLayout(replicaLayout);
Composite databaseComposite = new Composite(connectionGroup, SWT.NONE);
databaseComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 4, 1));
GridLayout dbCompLayout = new GridLayout(4, false);
dbCompLayout.marginWidth = 0;
dbCompLayout.marginHeight = 0;
databaseComposite.setLayout(dbCompLayout);
// $NON-NLS-1$
databaseText = new LabelledText(databaseComposite, Messages.getString("MongoDBConnForm.database"), 3, true);
initReplicaField();
MongoDBReplicaFieldModel model = new MongoDBReplicaFieldModel(replicaList, // $NON-NLS-1$
Messages.getString("MongoDBConnForm.replicaView"));
replicaTableView = new MongoDBReplicaTableView(model, replicaComposite);
final Composite fieldTableEditorComposite = replicaTableView.getMainComposite();
GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, false);
gridData.heightHint = 180;
fieldTableEditorComposite.setLayoutData(gridData);
fieldTableEditorComposite.setBackground(null);
}
use of org.talend.repository.nosql.db.model.mongodb.MongoDBReplicaFieldModel in project tbd-studio-se by Talend.
the class MongoDBConnForm method saveReplicaModel.
private void saveReplicaModel() {
try {
MongoDBReplicaFieldModel model = (MongoDBReplicaFieldModel) replicaTableView.getExtendedTableModel();
getConnection().getAttributes().put(IMongoDBAttributes.REPLICA_SET, model.getBeanListString());
} catch (JSONException e) {
//
}
}
use of org.talend.repository.nosql.db.model.mongodb.MongoDBReplicaFieldModel in project tbd-studio-se by Talend.
the class MongoDBReplicaTableView method initToolBar.
@Override
protected ExtendedToolbarView initToolBar() {
return new ExtendedToolbarView(getMainComposite(), SWT.NONE, getExtendedTableViewer()) {
@Override
protected AddPushButtonForExtendedTable createAddPushButton() {
return new AddPushButtonForExtendedTable(this.toolbar, getExtendedTableViewer()) {
@Override
protected Object getObjectToAdd() {
HashMap<String, Object> hpt = getModel().createReplicaType();
hpt.put(IMongoConstants.REPLICA_HOST_KEY, IMongoConstants.DEFAULT_HOST);
hpt.put(IMongoConstants.REPLICA_PORT_KEY, IMongoConstants.DEFAULT_PORT);
return hpt;
}
};
}
@Override
protected PastePushButton createPastePushButton() {
return new PastePushButtonForExtendedTable(toolbar, extendedTableViewer) {
@Override
protected Command getCommandToExecute(ExtendedTableModel extendedTableModel, Integer indexWhereInsert) {
return new ExtendedTablePasteCommand(extendedTableModel, indexWhereInsert) {
@Override
public List<HashMap<String, Object>> createPastableBeansList(ExtendedTableModel extendedTableModel, List copiedObjectsList) {
List list = new ArrayList();
MongoDBReplicaFieldModel fieldsModel = (MongoDBReplicaFieldModel) extendedTableModel;
for (Object current : copiedObjectsList) {
if (current instanceof HashMap) {
Map<String, Object> original = (HashMap<String, Object>) current;
Map<String, Object> copy = fieldsModel.createReplicaType();
copy.putAll(original);
list.add(copy);
}
}
return list;
}
};
}
};
}
};
}
Aggregations