Search in sources :

Example 76 with DatabaseInfo

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);
}
Also used : DbUserInfo(com.cubrid.cubridmanager.core.cubrid.user.model.DbUserInfo) TaskExecutor(com.cubrid.common.ui.spi.progress.TaskExecutor) DatabaseInfo(com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo) ServerInfo(com.cubrid.cubridmanager.core.common.model.ServerInfo) ExecTaskWithProgress(com.cubrid.common.ui.spi.progress.ExecTaskWithProgress) CubridServer(com.cubrid.common.ui.spi.model.CubridServer) ConnectDatabaseExecutor(com.cubrid.common.ui.spi.util.ConnectDatabaseExecutor)

Example 77 with DatabaseInfo

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());
}
Also used : DatabaseInfo(com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo) CubridDatabase(com.cubrid.common.ui.spi.model.CubridDatabase)

Example 78 with DatabaseInfo

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;
}
Also used : DbUserInfo(com.cubrid.cubridmanager.core.cubrid.user.model.DbUserInfo) DatabaseInfo(com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo) CubridDatabase(com.cubrid.common.ui.spi.model.CubridDatabase)

Example 79 with DatabaseInfo

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);
        }
    });
}
Also used : DbStatDumpData(com.cubrid.cubridmanager.core.monitoring.model.DbStatDumpData) DatabaseInfo(com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo) Label(org.eclipse.swt.widgets.Label) ArrayList(java.util.ArrayList) IDiagPara(com.cubrid.cubridmanager.core.monitoring.model.IDiagPara) GridLayout(org.eclipse.swt.layout.GridLayout) ShowSetting(com.cubrid.cubridmanager.ui.monitoring.editor.internal.ShowSetting) SelectionEvent(org.eclipse.swt.events.SelectionEvent) ChartCompositePart(com.cubrid.cubridmanager.ui.monitoring.editor.internal.ChartCompositePart) ArrayList(java.util.ArrayList) List(java.util.List) Composite(org.eclipse.swt.widgets.Composite) HistoryComposite(com.cubrid.cubridmanager.ui.monitoring.editor.internal.HistoryComposite) IPath(org.eclipse.core.runtime.IPath) Calendar(java.util.Calendar) IOException(java.io.IOException) TreeMap(java.util.TreeMap) HistoryComposite(com.cubrid.cubridmanager.ui.monitoring.editor.internal.HistoryComposite) DbStatDumpEnum(com.cubrid.cubridmanager.core.monitoring.model.DbStatDumpEnum) XYPlot(org.jfree.chart.plot.XYPlot) CounterFile(com.cubrid.cubridmanager.ui.monitoring.editor.count.CounterFile) GridData(org.eclipse.swt.layout.GridData) Map(java.util.Map) TreeMap(java.util.TreeMap) SelectionListener(org.eclipse.swt.events.SelectionListener)

Example 80 with DatabaseInfo

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();
}
Also used : Composite(org.eclipse.swt.widgets.Composite) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) HistoryComposite(com.cubrid.cubridmanager.ui.monitoring.editor.internal.HistoryComposite) DatabaseInfo(com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo) Label(org.eclipse.swt.widgets.Label) ArrayList(java.util.ArrayList) HistoryComposite(com.cubrid.cubridmanager.ui.monitoring.editor.internal.HistoryComposite) GridLayout(org.eclipse.swt.layout.GridLayout) GridData(org.eclipse.swt.layout.GridData) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) DbRunningType(com.cubrid.cubridmanager.core.common.model.DbRunningType)

Aggregations

DatabaseInfo (com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo)188 CubridDatabase (com.cubrid.common.ui.spi.model.CubridDatabase)79 ArrayList (java.util.ArrayList)45 ServerInfo (com.cubrid.cubridmanager.core.common.model.ServerInfo)35 ICubridNode (com.cubrid.common.ui.spi.model.ICubridNode)31 ISchemaNode (com.cubrid.common.ui.spi.model.ISchemaNode)30 DbUserInfo (com.cubrid.cubridmanager.core.cubrid.user.model.DbUserInfo)30 ExecTaskWithProgress (com.cubrid.common.ui.spi.progress.ExecTaskWithProgress)25 CubridNodeChangedEvent (com.cubrid.common.ui.spi.event.CubridNodeChangedEvent)24 TaskExecutor (com.cubrid.common.ui.spi.progress.TaskExecutor)24 ServerUserInfo (com.cubrid.cubridmanager.core.common.model.ServerUserInfo)23 ITask (com.cubrid.common.core.task.ITask)20 DefaultSchemaNode (com.cubrid.common.ui.spi.model.DefaultSchemaNode)18 GetDatabaseListTask (com.cubrid.cubridmanager.core.cubrid.database.task.GetDatabaseListTask)18 Map (java.util.Map)15 CommonTaskExec (com.cubrid.common.ui.spi.progress.CommonTaskExec)14 HashMap (java.util.HashMap)14 Composite (org.eclipse.swt.widgets.Composite)14 UpdateCMUserTask (com.cubrid.cubridmanager.core.common.task.UpdateCMUserTask)13 GridLayout (org.eclipse.swt.layout.GridLayout)13