use of com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo in project cubrid-manager by CUBRID.
the class LoginQueryEditDialog method buttonPressed.
/**
* @see org.eclipse.jface.dialogs.Dialog#buttonPressed(int)
* @param buttonId the id of the button that was pressed (see
* <code>IDialogConstants.*_ID</code> constants)
*/
protected void buttonPressed(int buttonId) {
if (buttonId == IDialogConstants.OK_ID || buttonId == TEST_CONNECT_ID) {
String brokerIp = connectionComp.getBrokerIpText().getText();
CubridServer cubridServer = DatabaseNavigatorMenu.SELF_DATABASE.getServer();
ServerInfo serverInfo = new ServerInfo();
serverInfo.setServerName(DatabaseNavigatorMenu.SELF_DATABASE_ID);
serverInfo.setHostAddress(brokerIp);
cubridServer.setServerInfo(serverInfo);
String databaseName = connectionComp.getDatabaseCombo().getText();
DatabaseInfo dbInfo = new DatabaseInfo(databaseName, cubridServer.getServerInfo());
dbInfo.setBrokerIP(brokerIp);
dbInfo.setBrokerPort(connectionComp.getBrokerPortCombo().getText());
dbInfo.getServerInfo().setJdbcDriverVersion(connectionComp.getJdbcCombo().getText());
String userName = connectionComp.getUserNameText().getText();
String password = connectionComp.getPasswordText().getText();
DbUserInfo userInfo = new DbUserInfo();
userInfo.setDbName(databaseName);
userInfo.setName(userName);
userInfo.setNoEncryptPassword(password);
dbInfo.setAuthLoginedDbUserInfo(userInfo);
int currentShardId = connectionComp.getCurShardId();
dbInfo.setCurrentShardId(currentShardId);
String charset = connectionComp.getCharsetCombo().getText();
dbInfo.setCharSet(charset);
boolean isShard = connectionComp.getBtnShard().getSelection();
dbInfo.setShard(isShard);
boolean sureCharset = CommonUITool.openConfirmBox(Messages.bind(com.cubrid.cubridmanager.ui.host.Messages.msgConfirmCharset, charset));
if (!sureCharset) {
connectionComp.getCharsetCombo().setFocus();
return;
}
TaskExecutor taskExcutor = new ConnectDatabaseExecutor(dbInfo);
new ExecTaskWithProgress(taskExcutor).exec();
if (!taskExcutor.isSuccess()) {
return;
}
if (buttonId == TEST_CONNECT_ID) {
CommonUITool.openInformationBox(com.cubrid.cubridmanager.ui.common.Messages.titleSuccess, com.cubrid.cubridmanager.ui.host.Messages.msgTestConnSuccess);
return;
}
dbInfo.setLogined(true);
dbInfo.setRunningType(DbRunningType.CS);
DatabaseNavigatorMenu.SELF_DATABASE.setDatabaseInfo(dbInfo);
}
super.buttonPressed(buttonId);
}
use of com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo in project cubrid-manager by CUBRID.
the class LoginQueryEditDialog method fillDatabaseCombo.
/**
*
* Fill in the database combo
*
* @param list the database list
*/
private void fillDatabaseCombo(List<CubridDatabase> list) {
selectDatabase = null;
connectionComp.getDatabaseCombo().removeAll();
if (list == null || list.isEmpty()) {
//For Cubrid Manager, if the server host is disconnected or has no database, 'demodb' will be set as default.
connectionComp.getDatabaseCombo().setText("demodb");
return;
}
CubridDatabase firstDb = null;
for (CubridDatabase db : list) {
DatabaseInfo databaseInfo = db.getDatabaseInfo();
if (databaseInfo == null) {
continue;
}
connectionComp.getDatabaseCombo().add(databaseInfo.getDbName());
firstDb = firstDb == null ? db : firstDb;
if (selDatabaseName != null && selDatabaseName.equals(databaseInfo.getDbName())) {
selectDatabase = db;
}
}
if (selectDatabase == null && firstDb != null) {
selectDatabase = firstDb;
selDatabaseName = selectDatabase.getDatabaseInfo() == null ? "" : selectDatabase.getDatabaseInfo().getDbName();
}
if (selectDatabase == null || null == selectDatabase.getDatabaseInfo()) {
return;
}
connectionComp.getDatabaseCombo().setText(selectDatabase.getDatabaseInfo().getDbName());
}
use of com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo in project cubrid-manager by CUBRID.
the class LoadDatabaseAction method isSupported.
public boolean isSupported(Object obj) {
if (obj != null && obj instanceof CubridDatabase) {
/* TOOLS-3624 Database loading is performed in standalone mode with DBA authorization.*/
CubridDatabase database = (CubridDatabase) obj;
DatabaseInfo dbInfo = database.getDatabaseInfo();
DbUserInfo dbUserInfo = dbInfo.getAuthLoginedDbUserInfo();
if (database.getRunningType() == DbRunningType.STANDALONE && dbUserInfo != null && dbUserInfo.isDbaAuthority() && dbInfo.isLogined()) {
return true;
}
}
return false;
}
use of com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo in project cubrid-manager by CUBRID.
the class DbStatusHistoryViewPart method createPartControl.
/**
* Creates the SWT controls for this workbench part.
*
* @param parent the parent control
* @see IWorkbenchPart
*/
public void createPartControl(Composite parent) {
final Composite composite = new Composite(parent, SWT.RESIZE);
composite.setLayout(new GridLayout());
composite.setLayoutData(new GridData(GridData.FILL_BOTH));
final HistoryComposite historyComposite = new HistoryComposite();
historyComposite.loadTimeSelection(composite);
serverInfo = cubridNode.getServer().getServerInfo();
Label sepWithResult = new Label(composite, SWT.SEPARATOR | SWT.HORIZONTAL | SWT.SHADOW_OUT);
sepWithResult.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
DbStatDumpData dbStatDumpData = new DbStatDumpData();
TreeMap<String, String> map = new TreeMap<String, String>();
for (Map.Entry<IDiagPara, String> entry : dbStatDumpData.getDiagStatusResultMap().entrySet()) {
map.put(entry.getKey().getName(), entry.getValue());
}
chartPart = new ChartCompositePart(composite, map);
dbCombo = new DbComboContribution("database");
List<String> databaseLst = new ArrayList<String>();
List<DatabaseInfo> databaseInfoLst = serverInfo.getLoginedUserInfo().getDatabaseInfoList();
if (null != databaseInfoLst && !databaseInfoLst.isEmpty()) {
for (DatabaseInfo databaseInfo : databaseInfoLst) {
databaseLst.add(databaseInfo.getDbName());
}
dbCombo.setDatabaseLst(databaseLst);
if (!databaseLst.isEmpty()) {
dbCombo.setSelectedDb(databaseLst.get(0));
}
}
for (Map.Entry<String, String> entry : map.entrySet()) {
String key = entry.getKey();
ShowSetting showSetting = chartPart.getSettingMap().get(key);
ShowSettingMatching.match(key, showSetting, MonitorType.DATABASE);
}
chartPart.setChartTitle(Messages.databaseHistoryChartTtl);
String dbName = dbCombo.getSelectedDb();
String hostAddress = serverInfo.getHostAddress();
int monPort = serverInfo.getHostMonPort();
String historyFileName = HistoryComposite.DB_HISTORY_FILE_PREFIX + dbName + "@" + hostAddress + "_" + monPort + HistoryComposite.HISTORY_SUFFIX;
chartPart.setHistoryFileName(historyFileName);
IPath historyPath = CubridManagerCorePlugin.getDefault().getStateLocation();
String sHistoryPath = historyPath.toOSString() + File.separator + historyFileName;
chartPart.setHistoryPath(sHistoryPath);
chartPart.loadContent();
chartPart.addChartMouseListener();
makeActions();
historyComposite.getQueryBtn().addSelectionListener(new SelectionListener() {
public void widgetDefaultSelected(SelectionEvent ex) {
String date = historyComposite.getDate();
String fromTime = historyComposite.getFromTime();
String toTime = historyComposite.getToTime();
// check date/fromTime/toTime
boolean timeOrder = historyComposite.checkTime(date, fromTime, toTime);
if (!timeOrder) {
CommonUITool.openErrorBox(Messages.errDbHistorySettingTime);
return;
}
String[] ymd = date.split("-");
int year = Integer.valueOf(ymd[0]);
int month = Integer.valueOf(ymd[1]);
int day = Integer.valueOf(ymd[2]);
String[] fromHms = fromTime.split(":");
int fromHour = Integer.valueOf(fromHms[0]);
int fromMinute = Integer.valueOf(fromHms[1]);
int fromSecond = Integer.valueOf(fromHms[2]);
Calendar calFrom = Calendar.getInstance();
calFrom.set(year, month, day, fromHour, fromMinute, fromSecond);
long millisFrom = calFrom.getTimeInMillis();
String[] toHms = toTime.split(":");
int toHour = Integer.valueOf(toHms[0]);
int toMinute = Integer.valueOf(toHms[1]);
int toSecond = Integer.valueOf(toHms[2]);
Calendar calTo = Calendar.getInstance();
calTo.set(year, month, day, toHour, toMinute, toSecond);
long millisTo = calTo.getTimeInMillis();
XYPlot plot = (XYPlot) chartPart.getChart().getPlot();
plot.getDomainAxis().setRange(millisFrom, millisTo);
CounterFile countFile = chartPart.openHistoryFile();
if (countFile == null) {
return;
}
List<String> types = new ArrayList<String>();
for (DbStatDumpEnum diagName : DbStatDumpEnum.values()) {
String type = diagName.getName();
types.add(type);
}
chartPart.executeQueryWithBusyCursor(countFile, types, millisFrom, millisTo);
try {
countFile.close();
} catch (IOException e1) {
LOGGER.error(e1.getMessage());
}
}
public void widgetSelected(SelectionEvent ex) {
widgetDefaultSelected(ex);
}
});
}
use of com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo in project cubrid-manager by CUBRID.
the class DbSystemMonitorHistoryViewPart method createPartControl.
/**
* Creates the SWT controls for this workbench part.
*
* @param parent the parent control
*/
public void createPartControl(Composite parent) {
final ScrolledComposite scrolledComp = new ScrolledComposite(parent, SWT.V_SCROLL | SWT.H_SCROLL);
composite = new Composite(scrolledComp, SWT.RESIZE);
GridLayout layout = new GridLayout(1, false);
composite.setLayout(layout);
composite.setLayoutData(new GridData(GridData.FILL_BOTH));
final HistoryComposite historyComposite = new HistoryComposite();
historyComposite.loadTimeSelection(composite);
Label sepWithResult = new Label(composite, SWT.SEPARATOR | SWT.HORIZONTAL | SWT.SHADOW_OUT);
sepWithResult.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
chartComp = new Composite(composite, SWT.RESIZE);
GridLayout chartCompLayout = new GridLayout(1, true);
chartComp.setLayout(chartCompLayout);
chartComp.setLayoutData(new GridData(GridData.FILL_BOTH));
loadCpuChart(chartComp);
loadMemoryChart(chartComp);
scrolledComp.setContent(composite);
scrolledComp.setExpandHorizontal(true);
scrolledComp.setExpandVertical(true);
scrolledComp.setMinHeight(800);
scrolledComp.setMinWidth(545);
historyComposite.getQueryBtn().addSelectionListener(new HistoryBtnSelectionListener(historyComposite));
List<String> databaseLst = new ArrayList<String>();
List<DatabaseInfo> databaseInfoLst = serverInfo.getLoginedUserInfo().getDatabaseInfoList();
for (DatabaseInfo databaseInfo : databaseInfoLst) {
DbRunningType dbRunningType = databaseInfo.getRunningType();
if (dbRunningType == DbRunningType.CS) {
databaseLst.add(databaseInfo.getDbName());
}
}
dbCombo = new DbComboContribution("database");
dbCombo.setDatabaseLst(databaseLst);
if (!databaseLst.isEmpty()) {
databaseLst.add(0, ALL_DB_NAME);
dbCombo.setSelectedDb(databaseLst.get(0));
}
String selectDb = dbCombo.getSelectedDb();
if (ALL_DB_NAME.equals(selectDb)) {
dbName = "";
} else {
dbName = selectDb;
}
makeActions();
}
Aggregations