use of com.cubrid.common.ui.spi.model.CubridDatabase in project cubrid-manager by CUBRID.
the class RunSQLFileDialog method buttonPressed.
/**
* When press button,call it
*
* @param buttonId the button id
*/
protected void buttonPressed(int buttonId) {
if (buttonId == IDialogConstants.OK_ID) {
if (!validate()) {
return;
}
for (CubridDatabase database : cubridDatabases) {
RunSQLFileEditorInput input = new RunSQLFileEditorInput(database, filesList, fileCharsetCombo.getText(), threadCountSpinner.getSelection(), commitCountSpinner.getSelection(), saveErrExcelPath.getText());
try {
IWorkbench workbench = PlatformUI.getWorkbench();
IWorkbenchWindow workbenchWindow = workbench.getActiveWorkbenchWindow();
workbenchWindow.getActivePage().openEditor(input, RunSQLFileViewPart.ID);
} catch (Exception e) {
LOGGER.error("", e);
}
}
}
setReturnCode(buttonId);
close();
}
use of com.cubrid.common.ui.spi.model.CubridDatabase in project cubrid-manager by CUBRID.
the class NavigatorViewSorter method compare.
/**
* @see <code>ViewerSorter</code>
*
* @param viewer
* Viewer
* @param e1
* Object
* @param e2
* Object
*
* @return int
*/
public int compare(Viewer viewer, Object e1, Object e2) {
if (e1 == null && e2 == null) {
return 0;
}
if (e1 == null) {
return -1;
}
if (e2 == null) {
return -1;
}
if (!(e1 instanceof ICubridNode) || !(e2 instanceof ICubridNode)) {
return 0;
}
ICubridNode node1 = (ICubridNode) e1;
ICubridNode node2 = (ICubridNode) e2;
// If group node, not sorting
if (node1 instanceof CubridGroupNode) {
return 0;
} else // If cubrid group node ,use the list's order
if ((node1 instanceof CubridServer) || (node1 instanceof CubridDatabase)) {
return order * node1.getLabel().compareTo(node2.getLabel());
}
int cat1 = category(node1);
int cat2 = category(node2);
if (cat1 > 0 && cat2 > 0) {
return cat1 - cat2;
}
if (cat1 != cat2) {
return cat1 - cat2;
}
return node1.compareTo(node2);
}
use of com.cubrid.common.ui.spi.model.CubridDatabase in project cubrid-manager by CUBRID.
the class EditProcedureAction method run.
/**
* Open the EditProcedureDialog and edit procedure
*/
public void run() {
// FIXME logic code move to core module
Object[] objArr = this.getSelectedObj();
if (!isSupported(objArr)) {
this.setEnabled(false);
return;
}
Shell shell = getShell();
CubridDatabase database = null;
ISchemaNode node = null;
if (objArr[0] instanceof ISchemaNode && NodeType.STORED_PROCEDURE_PROCEDURE.equals(((ISchemaNode) objArr[0]).getType())) {
node = (ISchemaNode) objArr[0];
database = node.getDatabase();
}
if (database == null || node == null) {
CommonUITool.openErrorBox(shell, Messages.errSelectProcedure);
return;
}
final GetSPInfoListTask task = new GetSPInfoListTask(database.getDatabaseInfo());
task.setSpName(node.getName());
TaskExecutor taskExcutor = new CommonTaskExec(null);
taskExcutor.addTask(task);
new ExecTaskWithProgress(taskExcutor).busyCursorWhile();
if (!taskExcutor.isSuccess()) {
return;
}
List<SPInfo> list = task.getSPInfoList();
if (list.size() > 1) {
CommonUITool.openErrorBox(shell, Messages.errDuplicateName);
return;
}
if (list.isEmpty()) {
CommonUITool.openErrorBox(shell, Messages.errNotExistName);
return;
}
EditProcedureDialog dlg = new EditProcedureDialog(shell);
dlg.setDatabase(database);
dlg.setNewFlag(false);
dlg.setSpInfo(list.get(0));
if (dlg.open() == IDialogConstants.OK_ID) {
ActionManager.getInstance().fireSelectionChanged(getSelection());
}
}
use of com.cubrid.common.ui.spi.model.CubridDatabase in project cubrid-manager by CUBRID.
the class ImportERwinAction method createCompareModel.
/**
*
* @param tableSchema
* @param schemaInfos
*/
private void createCompareModel(final String modelName, final Map<String, TableSchema> tableSchema, final Map<String, ERWinSchemaInfo> schemaInfos) {
final List<TableSchemaCompareModelInputLazy> input = new ArrayList<TableSchemaCompareModelInputLazy>();
ITask reportBugTask = new AbstractUITask() {
private boolean success = false;
public void cancel() {
}
public void finish() {
}
public boolean isCancel() {
return false;
}
public boolean isSuccess() {
return success;
}
public void execute(IProgressMonitor monitor) {
List<TableDetailInfo> leftDbTableInfoList = TableSchemaCompareUtil.getTableInfoList(database);
final CubridDatabase virtualDb = new CubridDatabase(modelName, modelName);
virtualDb.setVirtual(true);
DatabaseInfo info = database.getDatabaseInfo();
virtualDb.setDatabaseInfo(info);
WrappedDatabaseInfo wrappedDatabaseInfo = new WrappedDatabaseInfo(info);
Map<String, SchemaInfo> dbSchemaInfos = new HashMap<String, SchemaInfo>();
Collection<ERWinSchemaInfo> erwinSchemas = schemaInfos.values();
for (ERWinSchemaInfo erwinSchema : erwinSchemas) {
SchemaInfo schemaInfo = (SchemaInfo) erwinSchema;
dbSchemaInfos.put(schemaInfo.getClassname(), schemaInfo);
}
wrappedDatabaseInfo.addSchemaInfos(dbSchemaInfos);
wrappedDatabaseInfo.addTableSchemas(tableSchema);
ERXmlDatabaseInfoMapper.addWrappedDatabaseInfo(info, wrappedDatabaseInfo);
TableSchemaModel leftModel = TableSchemaCompareUtil.createTableSchemaModel(leftDbTableInfoList);
TableSchemaModel rightModel = new TableSchemaModel();
rightModel.getTableSchemaMap().putAll(tableSchema);
TableSchemaComparator comparator = new TableSchemaComparator(database, virtualDb);
TableSchemaCompareModel model = comparator.compare(leftModel, rightModel);
model.setSourceDB(database);
model.setTargetDB(virtualDb);
// TODO rename class to ErwinCompareModelInput
input.add(new TableSchemaCompareModelInputLazy(model));
success = true;
}
};
TaskExecutor taskExecutor = new CommonTaskExec(Messages.titleSchemaComparison);
taskExecutor.addTask(reportBugTask);
new ExecTaskWithProgress(taskExecutor).exec();
if (taskExecutor.isSuccess()) {
try {
PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().openEditor(input.get(0), TableSchemaCompareInfoPart.ID);
} catch (Exception e) {
}
}
}
use of com.cubrid.common.ui.spi.model.CubridDatabase in project cubrid-manager by CUBRID.
the class SchemaCompareDialog method createDialogArea.
/**
* Create the dialog area
*
* @param parent
* Composite
* @return Control
*/
protected Control createDialogArea(Composite parent) {
Composite parentComp = (Composite) super.createDialogArea(parent);
Composite composite = new Composite(parentComp, SWT.NONE);
GridLayout layout = new GridLayout();
layout.numColumns = 2;
layout.marginHeight = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN);
layout.marginWidth = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN);
layout.verticalSpacing = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING);
layout.horizontalSpacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
composite.setLayout(layout);
composite.setLayoutData(new GridData(GridData.FILL_BOTH));
if (selections == null) {
return parentComp;
}
Label lblLeft = new Label(composite, SWT.None);
lblLeft.setText(Messages.lblSchemaComparisonBase);
Label lblRight = new Label(composite, SWT.None);
lblRight.setText(Messages.lblSchemaComparisonTarget);
leftCombo = new org.eclipse.swt.widgets.List(composite, SWT.BORDER | SWT.V_SCROLL);
leftCombo.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
rightCombo = new org.eclipse.swt.widgets.List(composite, SWT.BORDER | SWT.V_SCROLL);
rightCombo.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
for (Object obj : selections) {
CubridDatabase db = (CubridDatabase) obj;
if (db == null) {
LOGGER.warn("The cubridDatabase is a null.");
continue;
}
DatabaseInfo dbInfo = db.getDatabaseInfo();
if (dbInfo == null) {
LOGGER.warn("The databaseInfo is a null.");
continue;
}
leftCombo.add(db.getLabel() + " - " + dbInfo.getBrokerIP() + "@" + dbInfo.getDbName());
}
for (Object obj : selections) {
CubridDatabase db = (CubridDatabase) obj;
if (db == null) {
LOGGER.warn("The cubridDatabase is a null.");
continue;
}
DatabaseInfo dbInfo = db.getDatabaseInfo();
if (dbInfo == null) {
LOGGER.warn("The databaseInfo is a null.");
continue;
}
rightCombo.add(db.getLabel() + " - " + dbInfo.getBrokerIP() + "@" + dbInfo.getDbName());
}
//setTitle(Messages.titleSchemaComparison);
setMessage(Messages.msgSchemaComparison);
leftCombo.setSelection(0);
rightCombo.setSelection(1);
return parentComp;
}
Aggregations