Search in sources :

Example 1 with Transaction

use of com.cubrid.cubridmanager.core.cubrid.database.model.transaction.Transaction in project cubrid-manager by CUBRID.

the class DatabaseDashboardEditor method createLockAndTransactionComposite.

/**
	 * create lock and transaction composite
	 *
	 * @param bar ExpandBar
	 * @param bar index
	 *
	 */
public void createLockAndTransactionComposite(ExpandBar bar, int index) {
    ExpandItem lockAndTransactionItem = new ExpandItem(bar, SWT.NONE, index);
    lockAndTransactionItem.setText(Messages.exportDashboardLockTableTitle);
    Composite lockAndTransactionComposite = new Composite(bar, SWT.NONE);
    lockAndTransactionComposite.setLayout(new FillLayout());
    lockAndTransactionTableViewer = new TableViewer(lockAndTransactionComposite, SWT.BORDER | SWT.FULL_SELECTION);
    lockAndTransactionTable = lockAndTransactionTableViewer.getTable();
    lockAndTransactionTable.setHeaderVisible(true);
    lockAndTransactionTable.setLinesVisible(true);
    final TableViewerColumn columnTranIndex = new TableViewerColumn(lockAndTransactionTableViewer, SWT.CENTER);
    columnTranIndex.getColumn().setWidth(80);
    columnTranIndex.getColumn().setText(Messages.tblColTranInfoTranIndex);
    columnTranIndex.getColumn().setToolTipText(Messages.tblColTranInfoTranIndex);
    final TableViewerColumn columnUserName = new TableViewerColumn(lockAndTransactionTableViewer, SWT.CENTER);
    columnUserName.getColumn().setWidth(80);
    columnUserName.getColumn().setText(Messages.tblColTranInfoUserName);
    columnUserName.getColumn().setToolTipText(Messages.tblColTranInfoUserName);
    final TableViewerColumn columnHost = new TableViewerColumn(lockAndTransactionTableViewer, SWT.CENTER);
    columnHost.getColumn().setWidth(130);
    columnHost.getColumn().setText(Messages.tblColTranInfoHost);
    columnHost.getColumn().setToolTipText(Messages.tblColTranInfoHost);
    final TableViewerColumn columnPid = new TableViewerColumn(lockAndTransactionTableViewer, SWT.CENTER);
    columnPid.getColumn().setWidth(80);
    columnPid.getColumn().setText(Messages.tblColTranInfoProcessId);
    columnPid.getColumn().setToolTipText(Messages.tblColTranInfoProcessId);
    final TableViewerColumn columnType = new TableViewerColumn(lockAndTransactionTableViewer, SWT.BEGINNING);
    columnType.getColumn().setWidth(320);
    columnType.getColumn().setText(Messages.tblColLockInfoObjectType);
    columnType.getColumn().setToolTipText(Messages.tblColLockInfoObjectType);
    columnPid.getColumn().setAlignment(SWT.CENTER);
    final TableViewerColumn columnMode = new TableViewerColumn(lockAndTransactionTableViewer, SWT.CENTER);
    columnMode.getColumn().setWidth(100);
    columnMode.getColumn().setText(Messages.tblColLockInfoMode);
    columnMode.getColumn().setToolTipText(Messages.tblColLockInfoMode);
    lockAndTransactionTableViewer.setContentProvider(new TableContentProvider());
    lockAndTransactionTableViewer.setLabelProvider(new TableLabelProvider());
    lockAndTransactionTableViewer.setInput(lockAndTransactionListData);
    lockAndTransactionItem.setControl(lockAndTransactionComposite);
    lockAndTransactionItem.setHeight(140);
    lockAndTransactionItem.setExpanded(true);
    Menu menu = new Menu(this.getSite().getShell(), SWT.POP_UP);
    final MenuItem itemKillTran = new MenuItem(menu, SWT.PUSH);
    itemKillTran.setText(Messages.menuKillTransaction);
    itemKillTran.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {
            int i = lockAndTransactionTable.getSelectionIndex();
            if (i < 0) {
                return;
            }
            String pid = lockAndTransactionTable.getItem(i).getText(3);
            if (i >= 0 && dbTransactionList != null && dbTransactionList.getTransationInfo() != null && dbTransactionList.getTransationInfo().getTransactionList() != null) {
                KillTransactionDialog dlg = new KillTransactionDialog(Display.getCurrent().getActiveShell());
                Transaction bean = null;
                for (Transaction t : dbTransactionList.getTransationInfo().getTransactionList()) {
                    if (pid.equals(t.getPid())) {
                        bean = t;
                    }
                }
                dlg.setTransationInfo(bean);
                dlg.setDatabase(database);
                if (dlg.open() == IDialogConstants.CANCEL_ID) {
                    return;
                }
                dbTransactionList.getTransationInfo().setTransactionList(dlg.getKillTransactionList().getTransationInfo().getTransactionList());
                lockAndTransactionListData.clear();
                lockAndTransactionTableViewer.getTable().clearAll();
                loadTransactionInfo();
                lockAndTransactionTableViewer.refresh();
            }
        }
    });
    menu.addMenuListener(new MenuListener() {

        public void menuHidden(MenuEvent e) {
        }

        public void menuShown(MenuEvent e) {
            int i = lockAndTransactionTableViewer.getTable().getSelectionIndex();
            if (i < 0) {
                Menu menu = (Menu) e.getSource();
                menu.setVisible(false);
            }
        }
    });
    lockAndTransactionTable.setMenu(menu);
    tableViewOnBarIndexMap.put(lockAndTransactionTableViewer, index);
}
Also used : Composite(org.eclipse.swt.widgets.Composite) MenuListener(org.eclipse.swt.events.MenuListener) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) MenuItem(org.eclipse.swt.widgets.MenuItem) FillLayout(org.eclipse.swt.layout.FillLayout) TableLabelProvider(com.cubrid.common.ui.spi.TableLabelProvider) KillTransactionDialog(com.cubrid.cubridmanager.ui.cubrid.database.dialog.KillTransactionDialog) DatabaseTransaction(com.cubrid.cubridmanager.core.cubrid.database.model.lock.DatabaseTransaction) Transaction(com.cubrid.cubridmanager.core.cubrid.database.model.transaction.Transaction) ExpandItem(org.eclipse.swt.widgets.ExpandItem) TableContentProvider(com.cubrid.common.ui.spi.TableContentProvider) SelectionEvent(org.eclipse.swt.events.SelectionEvent) Menu(org.eclipse.swt.widgets.Menu) TableViewer(org.eclipse.jface.viewers.TableViewer) TableViewerColumn(org.eclipse.jface.viewers.TableViewerColumn) MenuEvent(org.eclipse.swt.events.MenuEvent)

Example 2 with Transaction

use of com.cubrid.cubridmanager.core.cubrid.database.model.transaction.Transaction in project cubrid-manager by CUBRID.

the class TransactionInfoDialog method initial.

/**
	 *
	 * Initial data
	 *
	 */
private void initial() {
    transactionListData.clear();
    if (this.dbTransactionList != null && dbTransactionList.getTransationInfo() != null && dbTransactionList.getTransationInfo().getTransactionList() != null) {
        for (Transaction bean : dbTransactionList.getTransationInfo().getTransactionList()) {
            Map<String, String> map = new HashMap<String, String>();
            map.put("0", bean.getTranindex());
            map.put("1", bean.getUser());
            map.put("2", bean.getHost());
            map.put("3", bean.getPid());
            map.put("4", bean.getProgram());
            transactionListData.add(map);
        }
    }
    transactionTableViewer.refresh();
    for (int i = 0; i < transactionTable.getColumnCount(); i++) {
        transactionTable.getColumn(i).pack();
    }
    if (database != null) {
        objectIdLabel.setText(Messages.lblActiveTransaction + database.getName());
    }
}
Also used : Transaction(com.cubrid.cubridmanager.core.cubrid.database.model.transaction.Transaction) HashMap(java.util.HashMap)

Example 3 with Transaction

use of com.cubrid.cubridmanager.core.cubrid.database.model.transaction.Transaction in project cubrid-manager by CUBRID.

the class TransactionInfoDialog method buttonPressed.

/**
	 * When button press,call it
	 *
	 * @param buttonId the button id
	 */
protected void buttonPressed(int buttonId) {
    if (buttonId == KILL_TRANSACTION_ID) {
        int i = transactionTable.getSelectionIndex();
        String pid = transactionTable.getItem(i).getText(3);
        if (i >= 0 && dbTransactionList != null && dbTransactionList.getTransationInfo() != null && dbTransactionList.getTransationInfo().getTransactionList() != null && dbTransactionList.getTransationInfo().getTransactionList().size() > i) {
            KillTransactionDialog dlg = new KillTransactionDialog(parentComp.getShell());
            Transaction bean = null;
            for (Transaction t : dbTransactionList.getTransationInfo().getTransactionList()) {
                if (pid.equals(t.getPid())) {
                    bean = t;
                }
            }
            dlg.setTransationInfo(bean);
            dlg.setDatabase(database);
            if (dlg.open() == IDialogConstants.CANCEL_ID) {
                return;
            }
            // if (dlg.open() != IDialogConstants.CANCEL_ID) {
            if (dlg.isSuccess()) {
                //only when kill successfully refresh the data
                this.dbTransactionList.getTransationInfo().setTransactionList(dlg.getKillTransactionList().getTransationInfo().getTransactionList());
            }
            initial();
        // }
        }
    } else if (buttonId == REFRESH_ID) {
        loadData(getShell());
        initial();
        return;
    }
    super.buttonPressed(buttonId);
}
Also used : Transaction(com.cubrid.cubridmanager.core.cubrid.database.model.transaction.Transaction)

Aggregations

Transaction (com.cubrid.cubridmanager.core.cubrid.database.model.transaction.Transaction)3 TableContentProvider (com.cubrid.common.ui.spi.TableContentProvider)1 TableLabelProvider (com.cubrid.common.ui.spi.TableLabelProvider)1 DatabaseTransaction (com.cubrid.cubridmanager.core.cubrid.database.model.lock.DatabaseTransaction)1 KillTransactionDialog (com.cubrid.cubridmanager.ui.cubrid.database.dialog.KillTransactionDialog)1 HashMap (java.util.HashMap)1 TableViewer (org.eclipse.jface.viewers.TableViewer)1 TableViewerColumn (org.eclipse.jface.viewers.TableViewerColumn)1 MenuEvent (org.eclipse.swt.events.MenuEvent)1 MenuListener (org.eclipse.swt.events.MenuListener)1 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)1 SelectionEvent (org.eclipse.swt.events.SelectionEvent)1 FillLayout (org.eclipse.swt.layout.FillLayout)1 Composite (org.eclipse.swt.widgets.Composite)1 ExpandItem (org.eclipse.swt.widgets.ExpandItem)1 Menu (org.eclipse.swt.widgets.Menu)1 MenuItem (org.eclipse.swt.widgets.MenuItem)1