use of com.cubrid.cubridquery.ui.spi.model.DatabaseUIWrapper in project cubrid-manager by CUBRID.
the class ImportExportConnectionDialog method parseFile.
protected List<DatabaseUIWrapper> parseFile(String fileName) {
if (methodCache.size() == 0) {
initMethodCache();
}
counterMap.clear();
savedServer.clear();
savedServer.addAll(CQBDBNodePersistManager.getInstance().getAllDatabase());
servers.clear();
File file = new File(fileName);
if (!file.exists()) {
return null;
}
List<CubridDatabase> list = CQBDBNodePersistManager.getInstance().parseDatabaseFromXML(file);
for (CubridDatabase server : list) {
DatabaseUIWrapper wrapper = new DatabaseUIWrapper(server);
servers.put(server.getId(), wrapper);
}
for (DatabaseUIWrapper wrapper : servers.values()) {
handleDuplicateServer(wrapper);
}
return new ArrayList<DatabaseUIWrapper>(servers.values());
}
use of com.cubrid.cubridquery.ui.spi.model.DatabaseUIWrapper in project cubrid-manager by CUBRID.
the class ImportExportConnectionDialog method handleSelectAll.
@SuppressWarnings("unchecked")
private void handleSelectAll(boolean selected) {
List<DatabaseUIWrapper> input = (List<DatabaseUIWrapper>) hostListView.getInput();
for (DatabaseUIWrapper check : input) {
if (check.isSeleted() != selected)
check.setSeleted(selected);
}
hostListView.setAllChecked(selected);
updateWidgetStatus();
}
use of com.cubrid.cubridquery.ui.spi.model.DatabaseUIWrapper in project cubrid-manager by CUBRID.
the class DatabaseInfoTableViewerContentProvider method inputChanged.
@SuppressWarnings({ "rawtypes", "unchecked" })
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
if (newInput instanceof List) {
List<DatabaseUIWrapper> outputs = new ArrayList<DatabaseUIWrapper>();
List list = (List) newInput;
for (Object obj : list) {
if (obj instanceof DatabaseUIWrapper) {
break;
} else if (obj instanceof CubridDatabase) {
DatabaseUIWrapper wrapper = new DatabaseUIWrapper((CubridDatabase) obj);
outputs.add(list.indexOf(obj), wrapper);
}
}
if (!outputs.isEmpty()) {
list.clear();
list.addAll(outputs);
}
}
}
use of com.cubrid.cubridquery.ui.spi.model.DatabaseUIWrapper in project cubrid-manager by CUBRID.
the class ImportExportConnectionDialog method createTable.
private void createTable(Composite composite) {
hostListView = CheckboxTableViewer.newCheckList(composite, SWT.V_SCROLL | SWT.MULTI | SWT.BORDER | SWT.H_SCROLL | SWT.FULL_SELECTION);
tblHostList = hostListView.getTable();
final GridData gdColumnsTable = new GridData(SWT.FILL, SWT.FILL, true, true);
gdColumnsTable.horizontalSpan = 3;
gdColumnsTable.heightHint = 189;
tblHostList.setLayoutData(gdColumnsTable);
tblHostList.setLinesVisible(true);
tblHostList.setHeaderVisible(true);
final TableColumn hostName = new TableColumn(tblHostList, SWT.NONE);
hostName.setAlignment(SWT.LEFT);
hostName.setWidth(WIDTH_NAME);
hostName.setText(Messages.columnHeaderServerInfo);
if (export) {
hostName.setImage(CommonUIPlugin.getImage("icons/checked_green.png"));
} else {
hostName.setImage(CommonUIPlugin.getImage("icons/unchecked.gif"));
}
hostName.addListener(SWT.Selection, new Listener() {
public void handleEvent(Event event) {
selectAll = !selectAll;
hostListView.setAllChecked(selectAll);
Image image = selectAll ? CommonUIPlugin.getImage("icons/checked_green.png") : CommonUIPlugin.getImage("icons/unchecked.gif");
hostName.setImage(image);
handleSelectAll(selectAll);
}
});
final TableColumn hostAddress = new TableColumn(tblHostList, SWT.NONE);
hostAddress.setAlignment(SWT.CENTER);
hostAddress.setWidth(WIDTH_ADDRESS);
hostAddress.setText(Messages.columnHeaderServerAddress);
final TableColumn hostPort = new TableColumn(tblHostList, SWT.NONE);
hostPort.setAlignment(SWT.CENTER);
hostPort.setWidth(WIDTH_PORT);
hostPort.setText(Messages.columnHeaderServerPort);
final TableColumn jdbcVer = new TableColumn(tblHostList, SWT.NONE);
jdbcVer.setAlignment(SWT.CENTER);
jdbcVer.setWidth(WIDTH_JDBC);
jdbcVer.setText(Messages.columnHeaderServerJdbcVersion);
final TableColumn hostUser = new TableColumn(tblHostList, SWT.NONE);
hostUser.setAlignment(SWT.CENTER);
hostUser.setWidth(WIDTH_USER);
hostUser.setText(Messages.columnHeaderServerUserName);
final TableColumn savedPass = new TableColumn(tblHostList, SWT.NONE);
savedPass.setAlignment(SWT.CENTER);
savedPass.setWidth(WIDTH_SAVEPASS);
savedPass.setText(Messages.columnHeaderServerAutoSave);
DatabaseInfoTableViewerContentProvider contentProvider = new DatabaseInfoTableViewerContentProvider();
DatabaseInfoTableViewerLabelProvider labelProvider = new DatabaseInfoTableViewerLabelProvider();
hostListView.setContentProvider(contentProvider);
hostListView.setLabelProvider(labelProvider);
hostListView.addCheckStateListener(new ICheckStateListener() {
public void checkStateChanged(CheckStateChangedEvent event) {
boolean isSelect = event.getChecked();
Object obj = event.getElement();
if (obj instanceof DatabaseUIWrapper) {
((DatabaseUIWrapper) obj).setSeleted(isSelect);
}
updateWidgetStatus();
}
});
hostListView.addSelectionChangedListener(new ISelectionChangedListener() {
public void selectionChanged(SelectionChangedEvent arg0) {
ImportExportConnectionDialog.this.getButton(IDialogConstants.OK_ID).setEnabled(hostListView.getCheckedElements().length > 0);
}
});
if (export) {
initTableData();
setSelectAll(true);
}
}
use of com.cubrid.cubridquery.ui.spi.model.DatabaseUIWrapper in project cubrid-manager by CUBRID.
the class ImportExportConnectionDialog method isContainSameHost.
public boolean isContainSameHost(CubridDatabase server) {
SimpleDateFormat format = new SimpleDateFormat(IMPORT_DUPLICATED_HOST_SUFFIX_FORMAT);
for (int i = 0; i < savedServer.size(); i++) {
CubridDatabase serv = savedServer.get(i);
if (serv.getId().equals(server.getId())) {
setMessage(Messages.msgInfoChangeName, IMessageProvider.WARNING);
//check name has a time pattern
String oldId = server.getId();
updateTimePart(server, format);
servers.put(oldId, new DatabaseUIWrapper(server));
}
}
return false;
}
Aggregations