Search in sources :

Example 21 with TableViewerSorter

use of com.cubrid.common.ui.spi.TableViewerSorter in project cubrid-manager by CUBRID.

the class LockInfoDialog method createHistoryComposite.

/**
	 * Create history composite
	 * 
	 * @return the history composite
	 */
private Composite createHistoryComposite() {
    final Composite composit = new Composite(tabFolder, SWT.NONE);
    composit.setLayoutData(new GridData(GridData.FILL_BOTH));
    GridLayout layout = new GridLayout();
    layout.marginWidth = 10;
    layout.marginHeight = 10;
    composit.setLayout(layout);
    final Group lockTableGroup = new Group(composit, SWT.NONE);
    lockTableGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    layout = new GridLayout();
    lockTableGroup.setLayout(layout);
    lockTableGroup.setText(Messages.grpLockTable);
    lockedNumLabel = new Label(lockTableGroup, SWT.NONE);
    lockedNumLabel.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false));
    maxLockLabel = new Label(lockTableGroup, SWT.NONE);
    maxLockLabel.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false));
    final Group clientsTableGroup = new Group(composit, SWT.NONE);
    clientsTableGroup.setLayoutData(new GridData(GridData.FILL_BOTH));
    clientsTableGroup.setText(Messages.grpClientsCur);
    layout = new GridLayout();
    clientsTableGroup.setLayout(layout);
    final String[] columnNameArr = new String[] { Messages.tblColLockInfoOid, Messages.tblColLockInfoObjectType, Messages.tblColLockInfoNumHolders, Messages.tblColLockInfoNumBlockedHolders, Messages.tblColLockInfoNumWaiters };
    lockTableViewer = CommonUITool.createCommonTableViewer(clientsTableGroup, new TableViewerSorter(), columnNameArr, CommonUITool.createGridData(GridData.FILL_BOTH, 3, 1, -1, 200));
    lockTableViewer.setInput(lockListData);
    lockList = lockTableViewer.getTable();
    lockList.addListener(SWT.MouseDoubleClick, new Listener() {

        public void handleEvent(Event event) {
            openTransactionDetail();
        }
    });
    Button detailButton = new Button(composit, SWT.PUSH);
    detailButton.setFont(JFaceResources.getDialogFont());
    detailButton.setText(com.cubrid.cubridmanager.ui.common.Messages.btnDetail);
    detailButton.addSelectionListener(new org.eclipse.swt.events.SelectionAdapter() {

        public void widgetSelected(org.eclipse.swt.events.SelectionEvent event) {
            openTransactionDetail();
        }
    });
    GridData data = new GridData(SWT.RIGHT, SWT.CENTER, false, false);
    int widthHint = convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH);
    Point minSize = detailButton.computeSize(SWT.DEFAULT, SWT.DEFAULT, true);
    data.widthHint = Math.max(widthHint, minSize.x);
    detailButton.setLayoutData(data);
    return composit;
}
Also used : Group(org.eclipse.swt.widgets.Group) Listener(org.eclipse.swt.widgets.Listener) Composite(org.eclipse.swt.widgets.Composite) Label(org.eclipse.swt.widgets.Label) Point(org.eclipse.swt.graphics.Point) Point(org.eclipse.swt.graphics.Point) GridLayout(org.eclipse.swt.layout.GridLayout) TableViewerSorter(com.cubrid.common.ui.spi.TableViewerSorter) Button(org.eclipse.swt.widgets.Button) GridData(org.eclipse.swt.layout.GridData) Event(org.eclipse.swt.widgets.Event)

Example 22 with TableViewerSorter

use of com.cubrid.common.ui.spi.TableViewerSorter in project cubrid-manager by CUBRID.

the class RenameDatabaseDialog method createNewDatabaseInfoComp.

/**
	 * 
	 * Create database name group
	 * 
	 * @param parent the parent composite
	 */
private void createNewDatabaseInfoComp(Composite parent) {
    Composite comp = new Composite(parent, SWT.NONE);
    GridData gridData = new GridData(GridData.FILL_BOTH);
    comp.setLayoutData(gridData);
    GridLayout layout = new GridLayout();
    layout.numColumns = 3;
    comp.setLayout(layout);
    Label databaseNameLabel = new Label(comp, SWT.LEFT | SWT.WRAP);
    databaseNameLabel.setText(Messages.lblNewDbName);
    gridData = new GridData();
    gridData.widthHint = 150;
    databaseNameLabel.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
    databaseNameText = new Text(comp, SWT.BORDER);
    databaseNameText.setTextLimit(ValidateUtil.MAX_DB_NAME_LENGTH);
    databaseNameText.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 2, 1, -1, -1));
    exVolumePathButton = new Button(comp, SWT.LEFT | SWT.RADIO);
    exVolumePathButton.setText(Messages.btnExtendedVolumePath);
    exVolumePathButton.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
    exVolumePathButton.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {
            if (exVolumePathButton.getSelection()) {
                exVolumePathText.setEditable(true);
                renameVolumeButton.setSelection(false);
                volumeTable.setEnabled(false);
                if (selectVolumeDirectoryButton != null) {
                    ServerInfo serverInfo = database.getServer().getServerInfo();
                    selectVolumeDirectoryButton.setEnabled(serverInfo != null && serverInfo.isLocalServer());
                }
            } else {
                exVolumePathText.setEditable(false);
                volumeTable.setEnabled(true);
                if (selectVolumeDirectoryButton != null) {
                    selectVolumeDirectoryButton.setEnabled(false);
                }
            }
        }
    });
    exVolumePathButton.setSelection(true);
    boolean isLocalServer = database.getServer().getServerInfo().isLocalServer();
    exVolumePathText = new Text(comp, SWT.BORDER);
    exVolumePathText.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, isLocalServer ? 1 : 2, 1, -1, -1));
    if (isLocalServer) {
        selectVolumeDirectoryButton = new Button(comp, SWT.NONE);
        selectVolumeDirectoryButton.setText(Messages.btnBrowse);
        selectVolumeDirectoryButton.setLayoutData(CommonUITool.createGridData(1, 1, 80, -1));
        selectVolumeDirectoryButton.addSelectionListener(new SelectionAdapter() {

            public void widgetSelected(SelectionEvent event) {
                String text = exVolumePathText.getText();
                if (text == null || text.trim().length() == 0) {
                    text = CubridManagerUIPlugin.getPluginDialogSettings().get(KEY_EXTENDED_VOLUME_PATH + database.getId());
                }
                if (text == null || text.trim().length() == 0) {
                    text = extVolumePath;
                }
                DirectoryDialog dlg = new DirectoryDialog(getShell());
                if (text != null) {
                    dlg.setFilterPath(text);
                }
                dlg.setText(Messages.msgSelectDir);
                dlg.setMessage(Messages.msgSelectDir);
                String dir = dlg.open();
                if (dir != null) {
                    exVolumePathText.setText(dir);
                    CubridManagerUIPlugin.getPluginDialogSettings().put(KEY_EXTENDED_VOLUME_PATH + database.getId(), dir);
                }
            }
        });
        selectVolumeDirectoryButton.setEnabled(true);
    }
    renameVolumeButton = new Button(comp, SWT.LEFT | SWT.RADIO);
    renameVolumeButton.setText(Messages.btnRenameIndiVolume);
    renameVolumeButton.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 3, 1, -1, -1));
    renameVolumeButton.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {
            if (renameVolumeButton.getSelection()) {
                volumeTable.setEnabled(true);
            } else {
                volumeTable.setEnabled(false);
            }
        }
    });
    final String[] columnNameArr = new String[] { Messages.tblColumnCurrVolName, Messages.tblColumnNewVolName, Messages.tblColumnCurrDirPath, Messages.tblColumnNewDirPath };
    volumeTableViewer = CommonUITool.createCommonTableViewer(comp, new TableViewerSorter(), columnNameArr, CommonUITool.createGridData(GridData.FILL_BOTH, 3, 1, -1, 200));
    volumeTable = volumeTableViewer.getTable();
    volumeTable.setEnabled(false);
    volumeTableViewer.setColumnProperties(columnNameArr);
    CellEditor[] editors = new CellEditor[4];
    editors[0] = null;
    editors[1] = new TextCellEditor(volumeTable);
    editors[2] = null;
    editors[3] = new TextCellEditor(volumeTable);
    volumeTableViewer.setCellEditors(editors);
    volumeTableViewer.setCellModifier(new ICellModifier() {

        @SuppressWarnings("unchecked")
        public boolean canModify(Object element, String property) {
            Map<String, String> map = (Map<String, String>) element;
            String name = map.get("0");
            if (property.equals(columnNameArr[0]) || property.equals(columnNameArr[2])) {
                return false;
            } else if (property.equals(columnNameArr[1]) && name.equals(database.getName())) {
                return false;
            }
            return true;
        }

        @SuppressWarnings("unchecked")
        public Object getValue(Object element, String property) {
            Map<String, String> map = (Map<String, String>) element;
            if (property.equals(columnNameArr[1])) {
                return map.get("1");
            } else if (property.equals(columnNameArr[3])) {
                return map.get("3");
            }
            return null;
        }

        @SuppressWarnings("unchecked")
        public void modify(Object element, String property, Object value) {
            Object obj = null;
            if (element instanceof Item) {
                obj = ((Item) element).getData();
            }
            if (obj == null) {
                return;
            }
            Map<String, String> map = (Map<String, String>) obj;
            if (property.equals(columnNameArr[1])) {
                map.put("1", value.toString());
            } else if (property.equals(columnNameArr[3])) {
                map.put("3", value.toString());
            }
            volumeTableViewer.refresh();
        }
    });
    forceDelBackupVolumeButton = new Button(comp, SWT.LEFT | SWT.CHECK);
    forceDelBackupVolumeButton.setText(Messages.btnForceDelBackupVolume);
    forceDelBackupVolumeButton.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 3, 1, -1, -1));
}
Also used : Composite(org.eclipse.swt.widgets.Composite) ServerInfo(com.cubrid.cubridmanager.core.common.model.ServerInfo) CellEditor(org.eclipse.jface.viewers.CellEditor) TextCellEditor(org.eclipse.jface.viewers.TextCellEditor) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Label(org.eclipse.swt.widgets.Label) Text(org.eclipse.swt.widgets.Text) Item(org.eclipse.swt.widgets.Item) GridLayout(org.eclipse.swt.layout.GridLayout) TableViewerSorter(com.cubrid.common.ui.spi.TableViewerSorter) Button(org.eclipse.swt.widgets.Button) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) ICellModifier(org.eclipse.jface.viewers.ICellModifier) TextCellEditor(org.eclipse.jface.viewers.TextCellEditor) Map(java.util.Map) HashMap(java.util.HashMap) DirectoryDialog(org.eclipse.swt.widgets.DirectoryDialog)

Example 23 with TableViewerSorter

use of com.cubrid.common.ui.spi.TableViewerSorter in project cubrid-manager by CUBRID.

the class CreateDirDialog method createDirTableComp.

/**
	 * 
	 * Create directory table
	 * 
	 * @param parent the parent composite
	 */
private void createDirTableComp(Composite parent) {
    Composite comp = new Composite(parent, SWT.NONE);
    GridData gridData = new GridData(GridData.FILL_BOTH);
    comp.setLayoutData(gridData);
    GridLayout layout = new GridLayout();
    comp.setLayout(layout);
    Label tipLabel = new Label(comp, SWT.NONE);
    tipLabel.setText(Messages.msgDirList);
    tipLabel.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 1, 1, -1, -1));
    final String[] columnNameArr = new String[] { "Directory" };
    TableViewer tableViewer = CommonUITool.createCommonTableViewer(comp, new TableViewerSorter(), columnNameArr, CommonUITool.createGridData(GridData.FILL_BOTH, 1, 4, -1, 200));
    Table dirTable = tableViewer.getTable();
    tableViewer.setInput(getTableModel());
    for (int i = 0; i < dirTable.getColumnCount(); i++) {
        dirTable.getColumn(i).pack();
    }
}
Also used : GridLayout(org.eclipse.swt.layout.GridLayout) TableViewerSorter(com.cubrid.common.ui.spi.TableViewerSorter) Table(org.eclipse.swt.widgets.Table) Composite(org.eclipse.swt.widgets.Composite) GridData(org.eclipse.swt.layout.GridData) Label(org.eclipse.swt.widgets.Label) TableViewer(org.eclipse.jface.viewers.TableViewer)

Example 24 with TableViewerSorter

use of com.cubrid.common.ui.spi.TableViewerSorter in project cubrid-manager by CUBRID.

the class TransactionInfoDialog method createTransactionGroup.

/**
	 *
	 * Create transaction group
	 *
	 * @param composite the parent composite
	 */
private void createTransactionGroup(Composite composite) {
    final Group transactionGroup = new Group(composite, SWT.NONE);
    transactionGroup.setText(Messages.grpTransaction);
    transactionGroup.setLayoutData(new GridData(GridData.FILL_BOTH));
    GridLayout layout = new GridLayout(1, true);
    transactionGroup.setLayout(layout);
    final String[] columnNameArr = new String[] { Messages.tblColTranInfoTranIndex, Messages.tblColTranInfoUserName, Messages.tblColTranInfoHost, Messages.tblColTranInfoProcessId, Messages.tblColTranInfoProgramName };
    transactionTableViewer = CommonUITool.createCommonTableViewer(transactionGroup, new TableViewerSorter(), columnNameArr, CommonUITool.createGridData(GridData.FILL_BOTH, 3, 1, -1, 200));
    transactionTableViewer.setInput(transactionListData);
    transactionTable = transactionTableViewer.getTable();
    Menu menu = new Menu(getShell(), SWT.POP_UP);
    final MenuItem itemCopy = new MenuItem(menu, SWT.PUSH);
    itemCopy.setText(Messages.menuKillTransaction);
    itemCopy.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {
            int index = transactionTable.getSelectionIndex();
            transactionTable.getItem(index).getText(3);
            if (CommonUITool.openConfirmBox(parentComp.getShell(), Messages.bind(Messages.msgKillOnlyConfirm, transactionTable.getItem(index).getText(3)))) {
                killTransaction(KillTranType.T, transactionTable.getItem(index).getText(0));
                initial();
            } else {
                return;
            }
        }
    });
    transactionTable.setMenu(menu);
}
Also used : Group(org.eclipse.swt.widgets.Group) GridLayout(org.eclipse.swt.layout.GridLayout) TableViewerSorter(com.cubrid.common.ui.spi.TableViewerSorter) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) MenuItem(org.eclipse.swt.widgets.MenuItem) Menu(org.eclipse.swt.widgets.Menu)

Example 25 with TableViewerSorter

use of com.cubrid.common.ui.spi.TableViewerSorter in project cubrid-manager by CUBRID.

the class UnloadDatabaseResultDialog method createResultTableComp.

/**
	 * 
	 * Create unload database result table
	 * 
	 * @param parent the parent composite
	 */
private void createResultTableComp(Composite parent) {
    Composite comp = new Composite(parent, SWT.NONE);
    GridData gridData = new GridData(GridData.FILL_BOTH);
    comp.setLayoutData(gridData);
    GridLayout layout = new GridLayout();
    comp.setLayout(layout);
    Label tipLabel = new Label(comp, SWT.NONE);
    tipLabel.setText(Messages.msgUnloadDbResultDialog);
    tipLabel.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 1, 1, -1, -1));
    final String[] columnNameArr = new String[] { Messages.tblColumnTable, Messages.tblColumnRowCount, Messages.tblColumnProgress };
    TableViewerSorter sorter = new TableViewerSorter();
    TableViewer tableViewer = CommonUITool.createCommonTableViewer(comp, sorter, columnNameArr, CommonUITool.createGridData(GridData.FILL_BOTH, 1, 4, -1, 200));
    Table resultTable = tableViewer.getTable();
    tableViewer.setInput(getTableModel());
    sorter.doSort(2);
    tableViewer.refresh();
    for (int i = 0; i < resultTable.getColumnCount(); i++) {
        resultTable.getColumn(i).pack();
    }
}
Also used : GridLayout(org.eclipse.swt.layout.GridLayout) TableViewerSorter(com.cubrid.common.ui.spi.TableViewerSorter) Table(org.eclipse.swt.widgets.Table) Composite(org.eclipse.swt.widgets.Composite) GridData(org.eclipse.swt.layout.GridData) Label(org.eclipse.swt.widgets.Label) TableViewer(org.eclipse.jface.viewers.TableViewer)

Aggregations

TableViewerSorter (com.cubrid.common.ui.spi.TableViewerSorter)30 GridData (org.eclipse.swt.layout.GridData)20 GridLayout (org.eclipse.swt.layout.GridLayout)19 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)12 SelectionEvent (org.eclipse.swt.events.SelectionEvent)12 Label (org.eclipse.swt.widgets.Label)12 TableViewer (org.eclipse.jface.viewers.TableViewer)11 Composite (org.eclipse.swt.widgets.Composite)11 Group (org.eclipse.swt.widgets.Group)10 TableContentProvider (com.cubrid.common.ui.spi.TableContentProvider)7 TableColumn (org.eclipse.swt.widgets.TableColumn)7 HashMap (java.util.HashMap)6 Map (java.util.Map)6 Button (org.eclipse.swt.widgets.Button)5 TableLabelProvider (com.cubrid.common.ui.spi.TableLabelProvider)4 Table (org.eclipse.swt.widgets.Table)4 CellEditor (org.eclipse.jface.viewers.CellEditor)3 CLabel (org.eclipse.swt.custom.CLabel)3 Point (org.eclipse.swt.graphics.Point)3 CheckStateChangedEvent (org.eclipse.jface.viewers.CheckStateChangedEvent)2