use of com.cubrid.common.ui.spi.model.DefaultSchemaNode in project cubrid-manager by CUBRID.
the class ImportSettingTxtPage method handlePageLeaving.
protected void handlePageLeaving(PageChangingEvent event) {
if ((event.getTargetPage() instanceof ImportTypePage)) {
if (!CommonUITool.openConfirmBox(Messages.importWizardBackConfirmMsg)) {
event.doit = false;
} else {
clearOptions();
}
return;
}
ImportConfig importConfig = getImportDataWizard().getImportConfig();
/*NULL setting*/
importConfig.getNullValueList().clear();
if (nullOneButton.getSelection()) {
importConfig.getNullValueList().add("NULL");
}
if (nullTwoButton.getSelection()) {
importConfig.getNullValueList().add("\\N");
}
if (nullThreeButton.getSelection()) {
importConfig.getNullValueList().add("(NULL)");
}
if (otherButton.getSelection() && otherText.getText().length() > 0) {
String[] others = otherText.getText().split(",");
for (String value : others) {
if (importConfig.getNullValueList().indexOf(value) < 0) {
importConfig.getNullValueList().add(value);
}
}
}
/*Error handle*/
if (breakButton.getSelection()) {
importConfig.setErrorHandle(ImportConfig.ERROR_HANDLE_BREAK);
}
if (ignoreButton.getSelection()) {
importConfig.setErrorHandle(ImportConfig.ERROR_HANDLE_IGNORE);
}
importConfig.setFilesCharset(fileCharsetCombo.getText());
importConfig.setRowDelimiter(getRowdelimeter());
importConfig.setColumnDelimiter(getColumnDelimeter());
importConfig.setThreadCount(threadCountSpinner.getSelection());
importConfig.setCommitLine(commitCountSpinner.getSelection());
importConfig.setImportCLobData(importClobButton.getSelection());
importConfig.setImportBLobData(importBlobButton.getSelection());
/*Update the selected table*/
List<DefaultSchemaNode> selectedNodeList = mappingComposite.getSelectedTableNode();
List<String> removedList = new ArrayList<String>();
for (String tableName : importConfig.getSelectedMap().keySet()) {
boolean isChecked = false;
for (DefaultSchemaNode node : selectedNodeList) {
if (tableName.equals(node.getName())) {
isChecked = true;
break;
}
}
if (!isChecked) {
removedList.add(tableName);
}
}
for (String tableName : removedList) {
importConfig.deleteTableConfig(tableName);
}
}
use of com.cubrid.common.ui.spi.model.DefaultSchemaNode in project cubrid-manager by CUBRID.
the class ImportSettingTxtPage method validate.
public boolean validate() {
setErrorMessage(null);
setPageComplete(false);
ImportConfig importConfig = getImportDataWizard().getImportConfig();
List<DefaultSchemaNode> result = mappingComposite.getSelectedTableNode();
if (result.size() == 0) {
setErrorMessage(Messages.errNoSelectedTable);
return false;
}
for (DefaultSchemaNode node : result) {
Object value = node.getData(ImportObjectLabelProvider.IS_MAPPED);
if (value == null || !Boolean.parseBoolean(value.toString())) {
setErrorMessage(Messages.bind(Messages.errTableSetting, node.getName()));
return false;
}
TableConfig tableConfig = importConfig.getTableConfig(node.getName());
if (tableConfig != null) {
String filePath = tableConfig.getFilePath();
if (!StringUtil.isEmpty(filePath)) {
File file = new File(filePath);
if (!file.exists()) {
setErrorMessage(Messages.bind(Messages.errFileNotExist, filePath));
return false;
}
}
}
}
setPageComplete(true);
return true;
}
use of com.cubrid.common.ui.spi.model.DefaultSchemaNode in project cubrid-manager by CUBRID.
the class ImportSettingExcelPage method handlePageLeaving.
protected void handlePageLeaving(PageChangingEvent event) {
if ((event.getTargetPage() instanceof ImportTypePage)) {
if (!CommonUITool.openConfirmBox(Messages.importWizardBackConfirmMsg)) {
event.doit = false;
} else {
clearOptions();
}
return;
}
ImportConfig importConfig = getImportDataWizard().getImportConfig();
/*NULL setting*/
importConfig.getNullValueList().clear();
if (nullOneButton.getSelection()) {
importConfig.getNullValueList().add("NULL");
}
if (nullTwoButton.getSelection()) {
importConfig.getNullValueList().add("\\N");
}
if (nullThreeButton.getSelection()) {
importConfig.getNullValueList().add("(NULL)");
}
if (otherButton.getSelection() && otherText.getText().length() > 0) {
String[] others = otherText.getText().split(",");
for (String value : others) {
if (importConfig.getNullValueList().indexOf(value) < 0) {
importConfig.getNullValueList().add(value);
}
}
}
/*Error handle*/
if (breakButton.getSelection()) {
importConfig.setErrorHandle(ImportConfig.ERROR_HANDLE_BREAK);
}
if (ignoreButton.getSelection()) {
importConfig.setErrorHandle(ImportConfig.ERROR_HANDLE_IGNORE);
}
importConfig.setFilesCharset(fileCharsetCombo.getText());
importConfig.setThreadCount(threadCountSpinner.getSelection());
importConfig.setCommitLine(commitCountSpinner.getSelection());
importConfig.setImportCLobData(importClobButton.getSelection());
importConfig.setImportBLobData(importBlobButton.getSelection());
/*Update the selected table*/
List<DefaultSchemaNode> selectedNodeList = mappingComposite.getSelectedTableNode();
List<String> removedList = new ArrayList<String>();
for (String tableName : importConfig.getSelectedMap().keySet()) {
boolean isChecked = false;
for (DefaultSchemaNode node : selectedNodeList) {
if (tableName.equals(node.getName())) {
isChecked = true;
break;
}
}
if (!isChecked) {
removedList.add(tableName);
}
}
for (String tableName : removedList) {
importConfig.deleteTableConfig(tableName);
}
}
use of com.cubrid.common.ui.spi.model.DefaultSchemaNode in project cubrid-manager by CUBRID.
the class TableToJavaCodeAction method doRun.
/**
* Do run
*
* @param objects
*/
private void doRun(final Object[] objects) {
final File filepath = TableUtil.getSavedDirForCreateCodes(getShell(), null);
if (filepath == null) {
return;
}
if (!CommonUITool.openConfirmBox(Messages.msgConfirmTableToCode)) {
return;
}
final Map<CubridDatabase, Connection> connections = new HashMap<CubridDatabase, Connection>();
try {
final Display display = PlatformUI.getWorkbench().getDisplay();
BusyIndicator.showWhile(display, new Runnable() {
public void run() {
// FIXME move this logic to core module
StringBuilder notExportedList = new StringBuilder();
for (int i = 0; i < objects.length; i++) {
DefaultSchemaNode table = (DefaultSchemaNode) objects[i];
Connection connection = connections.get(table.getDatabase());
if (connection == null) {
try {
connection = JDBCConnectionManager.getConnection(table.getDatabase().getDatabaseInfo(), true);
connections.put(table.getDatabase(), connection);
} catch (Exception e) {
e.printStackTrace();
}
}
if (connection == null) {
if (notExportedList.length() > 0) {
notExportedList.append(", ");
}
notExportedList.append(table.getName());
continue;
}
String pojoClassFileName = getPojoFileName(table);
String pojoClassData = getPojoString(connection, table);
String pojoClassPath = filepath.getAbsolutePath() + File.separator + pojoClassFileName;
boolean result = FileUtil.writeToFile(pojoClassPath, pojoClassData, //TODO: error handling
"utf-8");
if (!result) {
if (notExportedList.length() > 0) {
notExportedList.append(", ");
}
notExportedList.append(table.getName());
}
}
finishNotice(notExportedList.toString());
}
});
} finally {
Collection<Connection> items = connections.values();
for (Connection conn : items) {
QueryUtil.freeQuery(conn);
}
}
}
use of com.cubrid.common.ui.spi.model.DefaultSchemaNode in project cubrid-manager by CUBRID.
the class CombinedQueryEditorComposite method fireSchemaNodeChanged.
/**
* Fire the schema node changed
*
* @param schemaNode
*/
public void fireSchemaNodeChanged(DefaultSchemaNode schemaNode) {
CTabItem[] tabItems = resultTabFolder.getItems();
for (CTabItem tabItem : tabItems) {
if (!isObjectInfoTab(tabItem)) {
continue;
}
ObjectInfoComposite infoCom = (ObjectInfoComposite) tabItem.getControl();
DefaultSchemaNode node = infoCom.getSchemaNode();
/* If the schema node is equal, then close the tabitem */
if (schemaNode != null && node != null && schemaNode.getDatabase() != null && schemaNode.getDatabase().equals(node.getDatabase()) && schemaNode.equals(node)) {
tabItem.dispose();
}
}
}
Aggregations