use of com.cubrid.common.ui.spi.model.CubridDatabase in project cubrid-manager by CUBRID.
the class ExportConnectionUtil method getColumnText.
public String getColumnText(Object element, int columnIndex) {
if (element instanceof CubridServer && columnIndex == 0) {
CubridServer server = (CubridServer) element;
return server.getName();
}
if (element instanceof CubridDatabase) {
CubridDatabase database = (CubridDatabase) element;
DatabaseInfo dbInfo = database.getDatabaseInfo();
if (dbInfo == null) {
LOGGER.warn("DatabaseInfo is a null.");
return "";
}
switch(columnIndex) {
case 0:
return dbInfo.getDbName();
case 1:
return dbInfo.getBrokerIP();
case 2:
return dbInfo.getBrokerPort();
case 3:
return dbInfo.getAuthLoginedDbUserInfo().getName();
case 4:
DatabaseEditorConfig editorConfig = QueryOptions.getEditorConfig(database, isCMMode);
if (editorConfig != null) {
return editorConfig.getDatabaseComment() == null ? "" : editorConfig.getDatabaseComment();
}
return "";
case 5:
return NodeUtil.getJavaConnectionUrl(database.getDatabaseInfo());
case 6:
return NodeUtil.getPHPConnectionUrl(database.getDatabaseInfo());
}
}
return null;
}
use of com.cubrid.common.ui.spi.model.CubridDatabase in project cubrid-manager by CUBRID.
the class OIDNavigatorAction method run.
public void run() {
Object[] obj = this.getSelectedObj();
if (!isSupported(obj)) {
this.setEnabled(false);
return;
}
ISchemaNode node = (ISchemaNode) obj[0];
CubridDatabase database = node.getDatabase();
Connection conn = null;
try {
conn = JDBCConnectionManager.getConnection(database.getDatabaseInfo(), true);
OIDNavigatorDialog dialog = new OIDNavigatorDialog(getShell(), conn, null);
dialog.open();
} catch (SQLException e) {
LOGGER.error("Can not request oid information by jdbc.", e);
//TODO: error message localizing
String message = Messages.bind(Messages.errCommonTip, e.getErrorCode(), e.getMessage());
CommonUITool.openErrorBox(message);
} finally {
QueryUtil.freeQuery(conn);
}
}
use of com.cubrid.common.ui.spi.model.CubridDatabase in project cubrid-manager by CUBRID.
the class JdbcManageComposite method isJdbcDriverUsing.
/**
*
* Return whether the JDBC driver is using
*
* @param jdbcVersion String
* @return boolean
*/
private boolean isJdbcDriverUsing(String jdbcVersion) {
IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
if (window == null) {
return false;
}
IWorkbenchPage page = window.getActivePage();
if (page == null) {
return false;
}
IViewReference[] viewReference = page.getViewReferences();
for (int i = 0; viewReference != null && i < viewReference.length; i++) {
IViewPart viewPart = viewReference[i].getView(false);
if (!(viewPart instanceof CubridNavigatorView)) {
continue;
}
CubridNavigatorView navigatorView = (CubridNavigatorView) viewPart;
List<ICubridNode> list = getUsingJdbcNodeList(navigatorView);
if (list == null) {
continue;
}
for (ICubridNode node : list) {
if (NodeType.SERVER.equals(node.getType())) {
CubridServer server = (CubridServer) node;
ServerInfo serverInfo = server.getServerInfo();
if (serverInfo == null) {
continue;
}
if (serverInfo.isConnected() && serverInfo.getJdbcDriverVersion().equals(jdbcVersion)) {
CommonUITool.openErrorBox(Messages.bind(Messages.errDeleteJdbcServer, new Object[] { serverInfo.getServerName(), jdbcVersion }));
return true;
}
} else if (NodeType.DATABASE.equals(node.getType())) {
CubridDatabase database = (CubridDatabase) node;
if (database == null || database.getServer() == null || database.getServer().getServerInfo() == null) {
continue;
}
ServerInfo serverInfo = database.getServer().getServerInfo();
if (serverInfo == null) {
LOGGER.error("The serverInfo is a null.");
return false;
}
boolean isSameVersion = StringUtil.isEqual(serverInfo.getJdbcDriverVersion(), jdbcVersion);
if (isSameVersion && database.isLogined()) {
CommonUITool.openErrorBox(Messages.bind(Messages.errDeleteJdbcConn, new Object[] { database.getName(), jdbcVersion }));
return true;
}
}
}
}
IEditorReference[] editorReference = page.getEditorReferences();
for (int i = 0; editorReference != null && i < editorReference.length; i++) {
IEditorPart editorPart = editorReference[i].getEditor(false);
if (!(editorPart instanceof QueryEditorPart)) {
continue;
}
QueryEditorPart queryEditorPart = (QueryEditorPart) editorPart;
CubridServer server = queryEditorPart.getSelectedServer();
ServerInfo serverInfo = server == null ? null : server.getServerInfo();
String partName = queryEditorPart.getPartName();
if (serverInfo != null && serverInfo.getJdbcDriverVersion().equals(jdbcVersion)) {
CommonUITool.openErrorBox(Messages.bind(Messages.errDeleteJdbcQuery, new Object[] { partName, jdbcVersion }));
return true;
}
}
return false;
}
use of com.cubrid.common.ui.spi.model.CubridDatabase in project cubrid-manager by CUBRID.
the class CheckQueryEditorTask method doSave.
public void doSave() {
ApplicationPersistUtil.getInstance().clearAllEditorStatus();
Display.getDefault().syncExec(new Runnable() {
public void run() {
Date createTime = new Date();
List<QueryEditorPart> editorPartList = QueryEditorUtil.getAllQueryEditorPart();
for (QueryEditorPart editor : editorPartList) {
ArrayList<RestorableQueryEditorInfo> sqlTabItemList = new ArrayList<RestorableQueryEditorInfo>();
for (CombinedQueryEditorComposite combinedQueryEditorComposite : editor.getAllCombinedQueryEditorComposite()) {
StyledText text = combinedQueryEditorComposite.getSqlEditorComp().getText();
if (text == null) {
LOGGER.warn("The editor.getSqlTextEditor() is a null.");
continue;
}
if (StringUtil.isEmpty(text.getText())) {
LOGGER.warn("The text.getText() is a null.");
continue;
}
CubridDatabase cubridDatabase = editor.getSelectedDatabase();
RestorableQueryEditorInfo editorStatus = new RestorableQueryEditorInfo();
if (cubridDatabase != null) {
DatabaseInfo dbInfo = cubridDatabase.getDatabaseInfo();
if (dbInfo != null) {
editorStatus.setDatabaseName(dbInfo.getDbName());
}
CubridServer cubridServer = cubridDatabase.getServer();
if (cubridServer != null) {
editorStatus.setServerName(cubridServer.getId());
}
}
editorStatus.setQueryContents(text.getText());
editorStatus.setCreatedTime(createTime);
sqlTabItemList.add(editorStatus);
}
ApplicationPersistUtil.getInstance().addEditorStatus(sqlTabItemList);
}
}
});
ApplicationPersistUtil.getInstance().save();
}
use of com.cubrid.common.ui.spi.model.CubridDatabase in project cubrid-manager by CUBRID.
the class RunSQLFileDialog method registerContextMenu.
/**
* register context menu
*/
private void registerContextMenu() {
sqlFileTableViewer.getTable().addFocusListener(new FocusAdapter() {
public void focusGained(FocusEvent event) {
ActionManager.getInstance().changeFocusProvider(sqlFileTableViewer.getTable());
}
});
MenuManager menuManager = new MenuManager();
menuManager.setRemoveAllWhenShown(true);
Menu contextMenu = menuManager.createContextMenu(sqlFileTableViewer.getTable());
sqlFileTableViewer.getTable().setMenu(contextMenu);
Menu menu = new Menu(getShell(), SWT.POP_UP);
final MenuItem itemDelete = new MenuItem(menu, SWT.PUSH);
itemDelete.setText("delete");
itemDelete.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
List<String> deleteFiles = new ArrayList<String>();
for (int i = 0; i < sqlFileTableViewer.getTable().getSelectionIndices().length; i++) {
int index = sqlFileTableViewer.getTable().getSelectionIndices()[i];
deleteFiles.add(filesList.get(index));
}
filesList.removeAll(deleteFiles);
sqlFileTableViewer.setInput(filesList);
sqlFileTableViewer.refresh();
}
});
sqlFileTableViewer.getTable().setMenu(menu);
Menu dbTablecontextMenu = menuManager.createContextMenu(databaseTableViewer.getTable());
databaseTableViewer.getTable().setMenu(dbTablecontextMenu);
Menu dbTableMenu = new Menu(getShell(), SWT.POP_UP);
final MenuItem dbTableItemDelete = new MenuItem(dbTableMenu, SWT.PUSH);
dbTableItemDelete.setText("delete");
dbTableItemDelete.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
List<CubridDatabase> deleteCubridDatabase = new ArrayList<CubridDatabase>();
for (int i = 0; i < databaseTableViewer.getTable().getSelectionIndices().length; i++) {
int index = databaseTableViewer.getTable().getSelectionIndices()[i];
deleteCubridDatabase.add(cubridDatabases[index]);
}
List<CubridDatabase> dbList = Arrays.asList(cubridDatabases);
ArrayList<CubridDatabase> newDbList = new ArrayList<CubridDatabase>();
for (CubridDatabase cubridDatabase : dbList) {
if (deleteCubridDatabase.contains(cubridDatabase)) {
continue;
}
newDbList.add(cubridDatabase);
}
cubridDatabases = newDbList.toArray(new CubridDatabase[newDbList.size()]);
databaseTableViewer.setInput(cubridDatabases);
databaseTableViewer.refresh();
}
});
sqlFileTableViewer.getTable().setMenu(menu);
databaseTableViewer.getTable().setMenu(dbTableMenu);
runSQLFileDialogDNDController = new RunSQLFileDialogDNDController(this);
runSQLFileDialogDNDController.registerDropTarget();
}
Aggregations