use of com.cubrid.common.ui.spi.model.ICubridNode in project cubrid-manager by CUBRID.
the class ExportSettingPage method setOptionsToExportConfigModel.
/**
* set page parameter to config model
*
* @param exportConfig
*/
public boolean setOptionsToExportConfigModel(ExportConfig exportConfig) {
exportConfig.setExportSchema(schemaButton.getSelection());
exportConfig.setExportData(dataButton.getSelection());
exportConfig.setExportIndex(indexButton.getSelection());
exportConfig.setExportSerial(serialButton.getSelection());
exportConfig.setExportView(viewButton.getSelection());
exportConfig.setExportSerialStartValue(startValueButton.getSelection());
int fileType = ExportConfig.FILE_TYPE_SQL;
if (sqlButton.getSelection()) {
fileType = ExportConfig.FILE_TYPE_SQL;
} else if (csvButton.getSelection()) {
fileType = ExportConfig.FILE_TYPE_CSV;
} else if (xlsButton.getSelection()) {
fileType = ExportConfig.FILE_TYPE_XLS;
} else if (xlsxButton.getSelection()) {
fileType = ExportConfig.FILE_TYPE_XLSX;
} else if (obsButton.getSelection()) {
fileType = ExportConfig.FILE_TYPE_OBS;
} else if (txtButton.getSelection()) {
fileType = ExportConfig.FILE_TYPE_TXT;
}
exportConfig.setExportFileType(fileType);
exportConfig.setThreadCount(threadCountSpinner.getSelection());
exportConfig.setFileCharset(fileCharsetCombo.getText());
exportConfig.setFirstRowAsColumnName(useFirstAsColumnBtn.getSelection());
exportConfig.setRowDelimeter(getRowDelimeter());
exportConfig.setColumnDelimeter(getColumnDelimeter());
String nullValue = "";
if (nullOneButton.getSelection()) {
nullValue = "NULL";
} else if (nullTwoButton.getSelection()) {
nullValue = "\\N";
} else if (nullThreeButton.getSelection()) {
nullValue = "(NULL)";
} else if (otherButton.getSelection()) {
nullValue = otherText.getText();
}
exportConfig.setNULLValueTranslation(nullValue);
List<String> checkedTableList = new ArrayList<String>();
List<ICubridNode> selectedTableOrViews = new ArrayList<ICubridNode>();
Object[] objects = treeViewer.getCheckedElements();
for (Object object : objects) {
ICubridNode node = (ICubridNode) object;
if (node.getType() == NodeType.TABLE_COLUMN_FOLDER && "false".equals(node.getData(VIEWNODEFLAG))) {
selectedTableOrViews.add(node);
checkedTableList.add(node.getName());
}
}
exportConfig.setTableNameList(checkedTableList);
removeUncheckedTablesOnConfig(exportConfig, checkedTableList);
String fileExt = getFileType();
File savedDirFile = new File(pathText.getText());
String[] filesInSavedDir = savedDirFile.list();
if (filesInSavedDir.length > 0) {
String duplicatedErrorMessage = Messages.bind(Messages.canceledBecauseOfExistsWithFolderName, pathText.getText());
CommonUITool.openErrorBox(duplicatedErrorMessage);
return false;
}
for (ICubridNode tableOrView : selectedTableOrViews) {
String filePath = savedDirFile.getAbsolutePath() + File.separator + tableOrView.getName() + fileExt;
Object whereCondition = tableOrView.getData(ExportObjectLabelProvider.CONDITION);
if (whereCondition != null) {
String sqlFilterPart = ((String) whereCondition).trim();
// append "where" if necessary
if (StringUtil.isNotEmpty(sqlFilterPart)) {
if (!sqlFilterPart.startsWith("where")) {
sqlFilterPart = " where " + sqlFilterPart;
}
exportConfig.setWhereCondition(tableOrView.getName(), sqlFilterPart);
}
}
exportConfig.setDataFilePath(tableOrView.getName(), filePath);
}
exportConfig.setDataFileFolder(pathText.getText());
if (exportLobButton.isEnabled()) {
exportConfig.setExportLob(exportLobButton.getSelection());
}
return true;
}
use of com.cubrid.common.ui.spi.model.ICubridNode in project cubrid-manager by CUBRID.
the class AddTableFileDialog method handleSelectEventForFirstRowAsColBtn.
/**
* Handle with the selection event for button of first row as column
*/
private void handleSelectEventForFirstRowAsColBtn() {
ICubridNode classNode = mappingComposite.getTableNode(tableName);
int noEmptySheetNum = 0;
if (itemsNumberOfSheets != null) {
for (Integer itemsNum : itemsNumberOfSheets) {
if (itemsNum != 0) {
noEmptySheetNum++;
}
}
}
if (firstRowAsColumnBtn.getSelection()) {
totalLine = totalLine - noEmptySheetNum;
} else {
totalLine = totalLine + noEmptySheetNum;
}
if (mappingComposite.isNewClassNode(classNode)) {
mappingComposite.removeClassNode(classNode);
ICubridNode node = mappingComposite.createClassNode(classNode.getName(), firstRowAsColumnBtn.getSelection(), firstRowColsLst, new ArrayList<String>(), new ArrayList<String>());
node.setData(ImportObjectLabelProvider.IS_MAPPED, true);
node.setData(ImportObjectLabelProvider.FILE_PAHT, fileNameTxt.getText());
node.setData(ImportObjectLabelProvider.ROW_COUNT, totalLine);
refreshInToList(node);
mappingComposite.refreshTable();
}
fillInFromList();
validate();
}
use of com.cubrid.common.ui.spi.model.ICubridNode in project cubrid-manager by CUBRID.
the class FileToTableMappingComposite method loadClassInfo.
public List<ICubridNode> loadClassInfo() {
// FIXME move this logic to core module
allTableList = new ArrayList<ICubridNode>();
try {
ProgressMonitorDialog progress = new ProgressMonitorDialog(Display.getCurrent().getActiveShell());
progress.setCancelable(true);
progress.run(true, true, new IRunnableWithProgress() {
public void run(IProgressMonitor monitor) throws InvocationTargetException {
monitor.beginTask(Messages.taskLoading, 2);
Connection conn = null;
Statement stmt = null;
ResultSet rsTable = null;
try {
monitor.subTask(Messages.taskLoadingTable);
monitor.worked(1);
StringBuilder sql = new StringBuilder();
sql.append("SELECT c.class_name ");
sql.append("FROM db_class c, db_attribute a ");
sql.append("WHERE c.class_name = a.class_name AND c.is_system_class = 'NO' ");
sql.append("AND a.from_class_name IS NULL ");
sql.append("AND c.class_type = 'CLASS' ");
sql.append("GROUP BY c.class_name ");
sql.append("ORDER BY c.class_name");
conn = JDBCConnectionManager.getConnection(database.getDatabaseInfo(), true);
stmt = conn.createStatement();
rsTable = stmt.executeQuery(sql.toString());
while (rsTable.next()) {
//$NON-NLS-1$
String tableName = rsTable.getString(1);
if (ConstantsUtil.isExtensionalSystemTable(tableName)) {
continue;
}
String iconPath = "icons/navigator/schema_table_item.png";
ICubridNode classNode = new DefaultSchemaNode(tableName, tableName, iconPath);
classNode.setContainer(true);
allTableList.add(classNode);
}
monitor.subTask(Messages.taskLoadingColumn);
monitor.worked(1);
} catch (SQLException e) {
String msg = e.getErrorCode() + StringUtil.NEWLINE + Messages.importErrorHead + e.getMessage();
CommonUITool.openErrorBox(getShell(), msg);
LOGGER.error("", e);
} finally {
QueryUtil.freeQuery(conn, stmt, rsTable);
}
}
});
} catch (Exception e) {
LOGGER.error("", e);
}
return allTableList;
}
use of com.cubrid.common.ui.spi.model.ICubridNode in project cubrid-manager by CUBRID.
the class FileToTableMappingComposite method createClassNode.
public ICubridNode createClassNode(String tableName, boolean isFirstRowAsColumnName, List<String> firstRowColsLst, List<String> colNameList, List<String> colTypeList) {
// FIXME move this logic to core module
int columnCount = firstRowColsLst.size();
String iconPath = "icons/navigator/schema_table_item.png";
ICubridNode classNode = new DefaultSchemaNode(tableName, tableName, iconPath);
classNode.setContainer(true);
List<String> columnNames;
if (isFirstRowAsColumnName) {
columnNames = firstRowColsLst;
} else {
columnNames = new ArrayList<String>();
for (int i = 0; i < columnCount; i++) {
columnNames.add("Column_" + String.valueOf(i));
}
}
for (String columnName : columnNames) {
colNameList.add(columnName);
colTypeList.add(NEW_ATTR_TYPE);
}
classNode.setData(ImportObjectLabelProvider.IS_NEW, true);
classNode.setData(ImportObjectLabelProvider.CREATE_DDL, getCreateTableDDL(classNode, colNameList, colTypeList));
allTableList.add(classNode);
refreshTable();
return classNode;
}
use of com.cubrid.common.ui.spi.model.ICubridNode in project cubrid-manager by CUBRID.
the class DropTriggerAction method run.
public void run(ISchemaNode[] nodeArray) {
// FIXME move this logic to core module
if (nodeArray == null) {
LOGGER.error("The nodeArray is a null.");
return;
}
List<String> triggerNameList = new ArrayList<String>();
StringBuffer bf = new StringBuffer();
for (int i = 0; nodeArray != null && i < nodeArray.length; i++) {
DefaultSchemaNode trigger = (DefaultSchemaNode) nodeArray[i];
triggerNameList.add(trigger.getName());
if (i == 0) {
bf.append(trigger.getName());
}
}
if (nodeArray.length > 1) {
bf.append(", ...");
}
String cfmMsg = Messages.bind(Messages.dropTriggerWarnMSG1, nodeArray.length, bf.toString());
boolean ret = CommonUITool.openConfirmBox(cfmMsg);
if (!ret) {
return;
}
ISchemaNode triggerNode = (ISchemaNode) nodeArray[0];
CommonSQLExcuterTask task = new CommonSQLExcuterTask(triggerNode.getDatabase().getDatabaseInfo());
for (String triggerName : triggerNameList) {
String sql = "DROP TRIGGER " + QuerySyntax.escapeKeyword(triggerName);
task.addSqls(sql);
}
String taskName = Messages.bind(Messages.dropTriggerTaskName, bf.toString());
TaskExecutor taskExecutor = new CommonTaskExec(taskName);
taskExecutor.addTask(task);
new ExecTaskWithProgress(taskExecutor).busyCursorWhile();
if (!taskExecutor.isSuccess()) {
return;
}
String title = com.cubrid.common.ui.common.Messages.titleSuccess;
String msg = Messages.dropTriggerSuccessMsg;
CommonUITool.openInformationBox(title, msg);
ISelectionProvider provider = this.getSelectionProvider();
ICubridNode parent = triggerNode.getParent();
if (provider instanceof TreeViewer) {
TreeViewer viewer = (TreeViewer) provider;
for (int i = 0; nodeArray != null && i < nodeArray.length; i++) {
parent.removeChild((ISchemaNode) nodeArray[i]);
}
viewer.remove(parent, nodeArray);
viewer.setSelection(new StructuredSelection(parent), true);
CommonUITool.updateFolderNodeLabelIncludingChildrenCount(viewer, parent);
}
}
Aggregations