Search in sources :

Example 16 with IDoubleClickListener

use of org.eclipse.jface.viewers.IDoubleClickListener in project cubrid-manager by CUBRID.

the class EditVirtualTableDialog method createFkIndexTabItem.

/**
	 * Create foreign key/Index tab item.
	 *
	 * @param tabFolder the object of TabFolder
	 */
private void createFkIndexTabItem(final TabFolder tabFolder) {
    final TabItem foreignKeyTabItem = new TabItem(tabFolder, SWT.NONE);
    foreignKeyTabItem.setText(Messages.infoIndexesTab);
    final Composite composite = new Composite(tabFolder, SWT.NONE);
    GridLayout gridLayout = new GridLayout();
    composite.setLayout(gridLayout);
    foreignKeyTabItem.setControl(composite);
    // create the fk table viewer
    final Label fkLabel = new Label(composite, SWT.NONE);
    fkLabel.setText(Messages.lblFK);
    fkTableView = new TableViewer(composite, SWT.FULL_SELECTION | SWT.MULTI | SWT.BORDER);
    fkTable = fkTableView.getTable();
    final GridData gdFkTable = new GridData(SWT.FILL, SWT.FILL, true, true, 4, 1);
    fkTable.setLayoutData(gdFkTable);
    fkTable.setLinesVisible(true);
    fkTable.setHeaderVisible(true);
    TableColumn tblCol = new TableColumn(fkTable, SWT.NONE);
    tblCol.setWidth(100);
    tblCol.setText(Messages.tblColumnFK);
    tblCol = new TableColumn(fkTable, SWT.NONE);
    tblCol.setWidth(119);
    tblCol.setText(Messages.tblColumnColumnName);
    tblCol = new TableColumn(fkTable, SWT.NONE);
    tblCol.setWidth(93);
    tblCol.setText(Messages.tblColumnForeignTable);
    tblCol = new TableColumn(fkTable, SWT.NONE);
    tblCol.setWidth(143);
    tblCol.setText(Messages.tblColumnForeignColumnName);
    tblCol = new TableColumn(fkTable, SWT.NONE);
    tblCol.setWidth(84);
    tblCol.setText(Messages.tblColumnUpdateRule);
    tblCol = new TableColumn(fkTable, SWT.NONE);
    tblCol.setWidth(86);
    tblCol.setText(Messages.tblColumnDeleteRule);
    tblCol = new TableColumn(fkTable, SWT.NONE);
    tblCol.setWidth(100);
    tblCol.setText(Messages.tblColumnCacheColumn);
    FKTableViewerContentProvider fkContentProvider = new FKTableViewerContentProvider();
    FKTableViewerLabelProvider fkLabelProvider = new FKTableViewerLabelProvider(database.getDatabaseInfo(), erSchema);
    fkTableView.setContentProvider(fkContentProvider);
    fkTableView.setLabelProvider(fkLabelProvider);
    fkTableView.setInput(getNewSchemaInfo());
    final Composite fkBtnComposite = new Composite(composite, SWT.NONE);
    final GridData gdBtnComposite = new GridData(SWT.RIGHT, SWT.CENTER, false, false);
    fkBtnComposite.setLayoutData(gdBtnComposite);
    gridLayout = new GridLayout();
    gridLayout.numColumns = 3;
    fkBtnComposite.setLayout(gridLayout);
    final GridData gdFKBTN = new GridData(SWT.LEFT, SWT.CENTER, false, false);
    final Button addFKBTN = new Button(fkBtnComposite, SWT.NONE);
    addFKBTN.setLayoutData(gdFKBTN);
    addFKBTN.setText(Messages.btnAddFk);
    addFKBTN.addSelectionListener(new AddFkBtnListenerOnFkIndexTab());
    final Button editFKBTN = new Button(fkBtnComposite, SWT.NONE);
    editFKBTN.setLayoutData(gdFKBTN);
    editFKBTN.setEnabled(false);
    editFKBTN.setText(Messages.btnEditFk);
    editFKBTN.addSelectionListener(new EditFkBtnListenerOnFkIndexTab());
    final Button deleteFKBTN = new Button(fkBtnComposite, SWT.NONE);
    deleteFKBTN.setLayoutData(gdFKBTN);
    deleteFKBTN.setEnabled(false);
    deleteFKBTN.setText(Messages.btnDelFk);
    deleteFKBTN.addSelectionListener(new DelFkBtnListenerOnFkIndexTab());
    fkTable.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {
            SchemaInfo newSchemaInfo = getNewSchemaInfo();
            if (database == null || database.getDatabaseInfo() == null || newSchemaInfo == null) {
                return;
            }
            TableItem[] items = fkTable.getSelection();
            if (items == null || items.length == 0) {
                deleteFKBTN.setEnabled(false);
                editFKBTN.setEnabled(false);
            } else {
                deleteFKBTN.setEnabled(true);
                editFKBTN.setEnabled(items.length == 1);
                for (TableItem item : items) {
                    String fkName = item.getText(0);
                    List<SchemaInfo> superList = SuperClassUtil.getSuperClasses(database.getDatabaseInfo(), newSchemaInfo.getSuperClasses());
                    if (newSchemaInfo.isInSuperClasses(superList, fkName)) {
                        deleteFKBTN.setEnabled(false);
                        editFKBTN.setEnabled(false);
                    }
                }
            }
        }
    });
    // create index table view
    final Label indexLabel = new Label(composite, SWT.NONE);
    indexLabel.setText(Messages.lblIndexes);
    indexTableView = new TableViewer(composite, SWT.FULL_SELECTION | SWT.MULTI | SWT.BORDER);
    indexTable = indexTableView.getTable();
    indexTable.setLinesVisible(true);
    indexTable.setHeaderVisible(true);
    final GridData gdIndexTable = new GridData(SWT.FILL, SWT.FILL, true, true, 4, 1);
    indexTable.setLayoutData(gdIndexTable);
    tblCol = new TableColumn(indexTable, SWT.NONE);
    tblCol.setWidth(150);
    tblCol.setText(Messages.tblColumnIndexName);
    tblCol = new TableColumn(indexTable, SWT.NONE);
    tblCol.setWidth(78);
    tblCol.setText(Messages.tblColumnIndexType);
    tblCol = new TableColumn(indexTable, SWT.NONE);
    tblCol.setWidth(218);
    tblCol.setText(Messages.tblColumnOnColumns);
    tblCol = new TableColumn(indexTable, SWT.NONE);
    tblCol.setWidth(282);
    tblCol.setText(Messages.tblColumnIndexRule);
    IndexTableViewerContentProvider indexContentProvider = new IndexTableViewerContentProvider();
    IndexTableViewerLabelProvider indexLabelProvider = new IndexTableViewerLabelProvider();
    indexTableView.setContentProvider(indexContentProvider);
    indexTableView.setLabelProvider(indexLabelProvider);
    indexTableView.setInput(getNewSchemaInfo());
    indexTableView.addDoubleClickListener(new IDoubleClickListener() {

        public void doubleClick(DoubleClickEvent event) {
            StructuredSelection selected = (StructuredSelection) event.getSelection();
            if (selected == null) {
                return;
            }
            Constraint constraint = (Constraint) selected.getFirstElement();
            openEditIndexDialog(constraint);
        }
    });
    final Composite indexBtnComposite = new Composite(composite, SWT.NONE);
    final GridData gdIndexBtnComposite = new GridData(SWT.RIGHT, SWT.CENTER, false, false);
    indexBtnComposite.setLayoutData(gdIndexBtnComposite);
    gridLayout = new GridLayout();
    gridLayout.numColumns = 3;
    indexBtnComposite.setLayout(gridLayout);
    final GridData gdIndexBTN = new GridData(SWT.LEFT, SWT.CENTER, false, false);
    final Button addIndexBTN = new Button(indexBtnComposite, SWT.NONE);
    addIndexBTN.setLayoutData(gdIndexBTN);
    addIndexBTN.setText(Messages.btnAddIndex);
    addIndexBTN.addSelectionListener(new AddIndexBtnListenerOnFkIndexTab());
    final Button editIndexBTN = new Button(indexBtnComposite, SWT.NONE);
    editIndexBTN.setLayoutData(gdIndexBTN);
    editIndexBTN.setEnabled(false);
    editIndexBTN.setText(Messages.btnEditIndex);
    editIndexBTN.addSelectionListener(new EditIndexBtnListenerOnFkIndexTab());
    final Button deleteIndexBTN = new Button(indexBtnComposite, SWT.NONE);
    deleteIndexBTN.setLayoutData(gdIndexBTN);
    deleteIndexBTN.setEnabled(false);
    deleteIndexBTN.setText(Messages.btnDelIndex);
    deleteIndexBTN.addSelectionListener(new DelIndexBtnListenerOnFkIndexTab());
    indexTable.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {
            TableItem[] items = indexTable.getSelection();
            if (items == null || items.length == 0) {
                deleteIndexBTN.setEnabled(false);
                editIndexBTN.setEnabled(false);
            } else {
                deleteIndexBTN.setEnabled(true);
                editIndexBTN.setEnabled(items.length == 1);
            }
        }
    });
}
Also used : Constraint(com.cubrid.common.core.common.model.Constraint) TableItem(org.eclipse.swt.widgets.TableItem) Label(org.eclipse.swt.widgets.Label) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) FKTableViewerLabelProvider(com.cubrid.common.ui.cubrid.table.control.FKTableViewerLabelProvider) GridLayout(org.eclipse.swt.layout.GridLayout) Button(org.eclipse.swt.widgets.Button) IDoubleClickListener(org.eclipse.jface.viewers.IDoubleClickListener) SelectionEvent(org.eclipse.swt.events.SelectionEvent) ArrayList(java.util.ArrayList) List(java.util.List) SchemaInfo(com.cubrid.common.core.common.model.SchemaInfo) Composite(org.eclipse.swt.widgets.Composite) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) IndexTableViewerContentProvider(com.cubrid.common.ui.cubrid.table.control.IndexTableViewerContentProvider) DoubleClickEvent(org.eclipse.jface.viewers.DoubleClickEvent) TableColumn(org.eclipse.swt.widgets.TableColumn) ERTableColumn(com.cubrid.common.ui.er.model.ERTableColumn) IndexTableViewerLabelProvider(com.cubrid.common.ui.cubrid.table.control.IndexTableViewerLabelProvider) TabItem(org.eclipse.swt.widgets.TabItem) FKTableViewerContentProvider(com.cubrid.common.ui.cubrid.table.control.FKTableViewerContentProvider) GridData(org.eclipse.swt.layout.GridData) TableViewer(org.eclipse.jface.viewers.TableViewer)

Example 17 with IDoubleClickListener

use of org.eclipse.jface.viewers.IDoubleClickListener in project cubrid-manager by CUBRID.

the class JobAutoDashboardEditorPart method createQueryPlanInfoTable.

public void createQueryPlanInfoTable(Composite parent) {
    parent.setLayout(new GridLayout(1, false));
    ToolBar toolBar = new ToolBar(parent, SWT.RIGHT);
    toolBar.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
    ToolItem refreshItem = new ToolItem(toolBar, SWT.PUSH);
    refreshItem.setText(com.cubrid.common.ui.cubrid.table.Messages.tablesDetailInfoPartRefreshBtn);
    refreshItem.setImage(CommonUIPlugin.getImage("icons/action/refresh.png"));
    refreshItem.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(final SelectionEvent event) {
            refreshQueryPlan();
        }
    });
    ToolItem createItem = new ToolItem(toolBar, SWT.PUSH);
    createItem.setText(Messages.jobAutoInfoDetailPartCreateQueryPlanBtn);
    createItem.setImage(CubridManagerUIPlugin.getImage("icons/action/auto_query_add.png"));
    createItem.setEnabled(canAddOrEdit);
    createItem.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(final SelectionEvent event) {
            addQueryPlan();
        }
    });
    ToolItem editItem = new ToolItem(toolBar, SWT.PUSH);
    editItem.setText(Messages.jobAutoInfoDetailPartEditQueryPlanBtn);
    editItem.setImage(CubridManagerUIPlugin.getImage("icons/action/auto_query_edit.png"));
    editItem.setEnabled(canAddOrEdit);
    editItem.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(final SelectionEvent event) {
            editQueryPlan();
        }
    });
    ToolItem deleteItem = new ToolItem(toolBar, SWT.PUSH);
    deleteItem.setText(Messages.jobAutoInfoDetailPartDeleteQueryPlanBtn);
    deleteItem.setImage(CubridManagerUIPlugin.getImage("icons/action/auto_query_delete.png"));
    deleteItem.setEnabled(canAddOrEdit);
    deleteItem.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(final SelectionEvent event) {
            deleteQueryPlan();
        }
    });
    ToolItem openLogItem = new ToolItem(toolBar, SWT.PUSH);
    openLogItem.setText(Messages.jobAutoInfoDetailPartOpenQueryLogBtn);
    openLogItem.setImage(CubridManagerUIPlugin.getImage("icons/action/auto_log.png"));
    openLogItem.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(final SelectionEvent event) {
            openQueryPlanLog();
        }
    });
    final Composite tableComposite = new Composite(parent, SWT.NONE);
    tableComposite.setLayout(new FillLayout());
    tableComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
    queryPlanInfoTable = new TableViewer(tableComposite, SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION | SWT.MULTI | SWT.BORDER);
    queryPlanInfoTable.getTable().setHeaderVisible(true);
    queryPlanInfoTable.getTable().setLinesVisible(true);
    queryPlanInfoTable.addDoubleClickListener(new IDoubleClickListener() {

        public void doubleClick(DoubleClickEvent event) {
            editQueryPlan();
        }
    });
    final TableViewerColumn nameColumn = new TableViewerColumn(queryPlanInfoTable, SWT.LEFT);
    nameColumn.getColumn().setWidth(120);
    nameColumn.getColumn().setText(Messages.queryPlanInfoTableNameColumn);
    final TableViewerColumn periodTypeColumn = new TableViewerColumn(queryPlanInfoTable, SWT.LEFT);
    periodTypeColumn.getColumn().setWidth(100);
    periodTypeColumn.getColumn().setText(Messages.queryPlanInfoTablePeriodTypeColumn);
    final TableViewerColumn periodDetailColumn = new TableViewerColumn(queryPlanInfoTable, SWT.LEFT);
    periodDetailColumn.getColumn().setWidth(150);
    periodDetailColumn.getColumn().setText(Messages.queryPlanInfoTablePeriodDetailColumn);
    final TableViewerColumn queryTimeColumn = new TableViewerColumn(queryPlanInfoTable, SWT.LEFT);
    queryTimeColumn.getColumn().setWidth(90);
    queryTimeColumn.getColumn().setText(Messages.queryPlanInfoTablePeriodTimeColumn);
    if (isSupportPeriodicAutoJob) {
        final TableViewerColumn queryIntervalColumn = new TableViewerColumn(queryPlanInfoTable, SWT.LEFT);
        queryIntervalColumn.getColumn().setWidth(100);
        queryIntervalColumn.getColumn().setText(Messages.queryPlanInfoTablePeriodIntervalColumn);
    }
    final TableViewerColumn queryColumn = new TableViewerColumn(queryPlanInfoTable, SWT.LEFT);
    queryColumn.getColumn().setWidth(200);
    queryColumn.getColumn().setText(Messages.queryPlanInfoTableQueryColumn);
    queryPlanInfoTable.setContentProvider(new QueryPlanTableViewerContentProvider());
    queryPlanInfoTable.setLabelProvider(new QueryPlanTableViewerLabelProvider());
    MenuManager menuManager = new MenuManager();
    menuManager.setRemoveAllWhenShown(true);
    Menu contextMenu = menuManager.createContextMenu(queryPlanInfoTable.getTable());
    queryPlanInfoTable.getTable().setMenu(contextMenu);
    Menu menu = new Menu(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), SWT.POP_UP);
    final MenuItem createMenuItem = new MenuItem(menu, SWT.PUSH);
    createMenuItem.setText(Messages.jobAutoInfoDetailPartCreateQueryPlanBtn);
    createMenuItem.setImage(CubridManagerUIPlugin.getImage("icons/action/auto_query_add.png"));
    createMenuItem.setEnabled(canAddOrEdit);
    createMenuItem.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {
            addQueryPlan();
        }
    });
    final MenuItem editMenuItem = new MenuItem(menu, SWT.PUSH);
    editMenuItem.setText(Messages.jobAutoInfoDetailPartEditQueryPlanBtn);
    editMenuItem.setImage(CubridManagerUIPlugin.getImage("icons/action/auto_query_edit.png"));
    editMenuItem.setEnabled(canAddOrEdit);
    editMenuItem.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {
            editQueryPlan();
        }
    });
    final MenuItem dropMenuItem = new MenuItem(menu, SWT.PUSH);
    dropMenuItem.setText(Messages.jobAutoInfoDetailPartDeleteQueryPlanBtn);
    dropMenuItem.setImage(CubridManagerUIPlugin.getImage("icons/action/auto_query_delete.png"));
    dropMenuItem.setEnabled(canAddOrEdit);
    dropMenuItem.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {
            deleteQueryPlan();
        }
    });
    final MenuItem openLogMenuItem = new MenuItem(menu, SWT.PUSH);
    openLogMenuItem.setText(Messages.jobAutoInfoDetailPartOpenQueryLogBtn);
    openLogMenuItem.setImage(CubridManagerUIPlugin.getImage("icons/action/auto_log.png"));
    openLogMenuItem.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {
            openQueryPlanLog();
        }
    });
    queryPlanInfoTable.getTable().setMenu(menu);
}
Also used : Composite(org.eclipse.swt.widgets.Composite) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) DoubleClickEvent(org.eclipse.jface.viewers.DoubleClickEvent) MenuItem(org.eclipse.swt.widgets.MenuItem) FillLayout(org.eclipse.swt.layout.FillLayout) GridLayout(org.eclipse.swt.layout.GridLayout) IDoubleClickListener(org.eclipse.jface.viewers.IDoubleClickListener) ToolBar(org.eclipse.swt.widgets.ToolBar) SelectionEvent(org.eclipse.swt.events.SelectionEvent) GridData(org.eclipse.swt.layout.GridData) MenuManager(org.eclipse.jface.action.MenuManager) Menu(org.eclipse.swt.widgets.Menu) TableViewer(org.eclipse.jface.viewers.TableViewer) ToolItem(org.eclipse.swt.widgets.ToolItem) TableViewerColumn(org.eclipse.jface.viewers.TableViewerColumn)

Example 18 with IDoubleClickListener

use of org.eclipse.jface.viewers.IDoubleClickListener in project cubrid-manager by CUBRID.

the class ColumnViewerSorter method createTablesDetailInfoTable.

/**
	 * createTablesDetailInfoTable
	 *
	 * @param parent
	 */
public void createTablesDetailInfoTable(Composite parent) {
    final Composite tableComposite = new Composite(parent, SWT.NONE);
    tableComposite.setLayout(new FillLayout());
    tableComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
    tableListView = new TableViewer(tableComposite, SWT.FULL_SELECTION | SWT.MULTI | SWT.BORDER);
    tableListView.getTable().setHeaderVisible(true);
    tableListView.getTable().setLinesVisible(true);
    final TableViewerColumn columnTableName = new TableViewerColumn(tableListView, SWT.LEFT);
    columnTableName.getColumn().setWidth(150);
    columnTableName.getColumn().setText(Messages.tablesDetailInfoPartColTableName);
    columnTableName.getColumn().addSelectionListener(new SelectionAdapter() {

        boolean isAsc = false;

        public void widgetSelected(SelectionEvent e) {
            tableListView.setSorter(new ColumnViewerSorter(isAsc, ColumnViewerSorter.PROPERTY_NAME));
            tableListView.getTable().setSortColumn(columnTableName.getColumn());
            tableListView.getTable().setSortDirection(isAsc ? SWT.UP : SWT.DOWN);
            isAsc = !isAsc;
        }
    });
    final TableViewerColumn columnTableDesc = new TableViewerColumn(tableListView, SWT.LEFT);
    columnTableDesc.getColumn().setWidth(200);
    columnTableDesc.getColumn().setText(Messages.tablesDetailInfoPartColTableMemo);
    columnTableDesc.getColumn().addSelectionListener(new SelectionAdapter() {

        boolean isAsc = false;

        public void widgetSelected(SelectionEvent e) {
            tableListView.setSorter(new ColumnViewerSorter(isAsc, ColumnViewerSorter.PROPERTY_MEMO));
            tableListView.getTable().setSortColumn(columnTableDesc.getColumn());
            tableListView.getTable().setSortDirection(isAsc ? SWT.UP : SWT.DOWN);
            isAsc = !isAsc;
        }
    });
    final TableViewerColumn columnRecordsCount = new TableViewerColumn(tableListView, SWT.LEFT);
    columnRecordsCount.getColumn().setWidth(60);
    columnRecordsCount.getColumn().setText(Messages.tablesDetailInfoPartColRecordsCount);
    columnRecordsCount.getColumn().addSelectionListener(new SelectionAdapter() {

        boolean isAsc = false;

        public void widgetSelected(SelectionEvent e) {
            tableListView.setSorter(new ColumnViewerSorter(isAsc, ColumnViewerSorter.PROPERTY_RECORD));
            tableListView.getTable().setSortColumn(columnRecordsCount.getColumn());
            tableListView.getTable().setSortDirection(isAsc ? SWT.UP : SWT.DOWN);
            isAsc = !isAsc;
        }
    });
    final TableViewerColumn columnColumnsCount = new TableViewerColumn(tableListView, SWT.LEFT);
    columnColumnsCount.getColumn().setWidth(80);
    columnColumnsCount.getColumn().setText(Messages.tablesDetailInfoPartColColumnsCount);
    columnColumnsCount.getColumn().addSelectionListener(new SelectionAdapter() {

        boolean isAsc = false;

        public void widgetSelected(SelectionEvent e) {
            tableListView.setSorter(new ColumnViewerSorter(isAsc, ColumnViewerSorter.PROPERTY_COLUMN));
            tableListView.getTable().setSortColumn(columnColumnsCount.getColumn());
            tableListView.getTable().setSortDirection(isAsc ? SWT.UP : SWT.DOWN);
            isAsc = !isAsc;
        }
    });
    final TableViewerColumn columnPK = new TableViewerColumn(tableListView, SWT.LEFT);
    columnPK.getColumn().setWidth(50);
    columnPK.getColumn().setText(Messages.tablesDetailInfoPartColPK);
    columnPK.getColumn().addSelectionListener(new SelectionAdapter() {

        boolean isAsc = false;

        public void widgetSelected(SelectionEvent e) {
            tableListView.setSorter(new ColumnViewerSorter(isAsc, ColumnViewerSorter.PROPERTY_PK));
            tableListView.getTable().setSortColumn(columnPK.getColumn());
            tableListView.getTable().setSortDirection(isAsc ? SWT.UP : SWT.DOWN);
            isAsc = !isAsc;
        }
    });
    final TableViewerColumn columnTableUK = new TableViewerColumn(tableListView, SWT.LEFT);
    columnTableUK.getColumn().setWidth(50);
    columnTableUK.getColumn().setText(Messages.tablesDetailInfoPartColUK);
    columnTableUK.getColumn().addSelectionListener(new SelectionAdapter() {

        boolean isAsc = false;

        public void widgetSelected(SelectionEvent e) {
            tableListView.setSorter(new ColumnViewerSorter(isAsc, ColumnViewerSorter.PROPERTY_UK));
            tableListView.getTable().setSortColumn(columnTableUK.getColumn());
            tableListView.getTable().setSortDirection(isAsc ? SWT.UP : SWT.DOWN);
            isAsc = !isAsc;
        }
    });
    final TableViewerColumn columnFK = new TableViewerColumn(tableListView, SWT.LEFT);
    columnFK.getColumn().setWidth(50);
    columnFK.getColumn().setText(Messages.tablesDetailInfoPartColFK);
    columnFK.getColumn().addSelectionListener(new SelectionAdapter() {

        boolean isAsc = false;

        public void widgetSelected(SelectionEvent e) {
            tableListView.setSorter(new ColumnViewerSorter(isAsc, ColumnViewerSorter.PROPERTY_FK));
            tableListView.getTable().setSortColumn(columnFK.getColumn());
            tableListView.getTable().setSortDirection(isAsc ? SWT.UP : SWT.DOWN);
            isAsc = !isAsc;
        }
    });
    final TableViewerColumn columnIndex = new TableViewerColumn(tableListView, SWT.LEFT);
    columnIndex.getColumn().setWidth(50);
    columnIndex.getColumn().setText(Messages.tablesDetailInfoPartColIndex);
    columnIndex.getColumn().addSelectionListener(new SelectionAdapter() {

        boolean isAsc = false;

        public void widgetSelected(SelectionEvent e) {
            tableListView.setSorter(new ColumnViewerSorter(isAsc, ColumnViewerSorter.PROPERTY_INDEX));
            tableListView.getTable().setSortColumn(columnIndex.getColumn());
            tableListView.getTable().setSortDirection(isAsc ? SWT.UP : SWT.DOWN);
            isAsc = !isAsc;
        }
    });
    final TableViewerColumn columnRecordsSize = new TableViewerColumn(tableListView, SWT.LEFT);
    columnRecordsSize.getColumn().setWidth(100);
    columnRecordsSize.getColumn().setText(Messages.tablesDetailInfoPartColTableRecordsSize);
    columnRecordsSize.getColumn().addSelectionListener(new SelectionAdapter() {

        boolean isAsc = false;

        public void widgetSelected(SelectionEvent e) {
            tableListView.setSorter(new ColumnViewerSorter(isAsc, ColumnViewerSorter.PROPERTY_SIZE));
            tableListView.getTable().setSortColumn(columnRecordsSize.getColumn());
            tableListView.getTable().setSortDirection(isAsc ? SWT.UP : SWT.DOWN);
            isAsc = !isAsc;
        }
    });
    tableListView.setContentProvider(new TableDashboardContentProvider());
    tableListView.setLabelProvider(new TableDashboardLabelProvider());
    tableListView.addDoubleClickListener(new IDoubleClickListener() {

        public void doubleClick(DoubleClickEvent event) {
            IStructuredSelection selection = (IStructuredSelection) event.getSelection();
            TableDetailInfo oneTableDetail = (TableDetailInfo) selection.getFirstElement();
            openTableDetail(oneTableDetail);
        }
    });
    tableListView.getTable().addKeyListener(new KeyAdapter() {

        public void keyPressed(KeyEvent event) {
            if ((event.stateMask & SWT.CTRL) != 0 && event.keyCode == 'c') {
                copySelectedTableNamesToClipboard();
            } else if (event.keyCode == SWT.CR) {
                showEditDialog(tableListView.getTable(), tableListView.getTable().getSelectionIndex());
            }
        }
    });
    registerContextMenu();
}
Also used : Composite(org.eclipse.swt.widgets.Composite) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) KeyAdapter(org.eclipse.swt.events.KeyAdapter) TableDetailInfo(com.cubrid.common.core.common.model.TableDetailInfo) DoubleClickEvent(org.eclipse.jface.viewers.DoubleClickEvent) FillLayout(org.eclipse.swt.layout.FillLayout) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) KeyEvent(org.eclipse.swt.events.KeyEvent) IDoubleClickListener(org.eclipse.jface.viewers.IDoubleClickListener) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) TableViewer(org.eclipse.jface.viewers.TableViewer) TableViewerColumn(org.eclipse.jface.viewers.TableViewerColumn)

Example 19 with IDoubleClickListener

use of org.eclipse.jface.viewers.IDoubleClickListener in project cubrid-manager by CUBRID.

the class TableContentProvider method createPartControl.

/**
	 * Create part controls
	 * 
	 * @param parent of the controls
	 * 
	 */
public void createPartControl(Composite parent) {
    Composite backPanel = new Composite(parent, SWT.NONE);
    backPanel.setLayout(new GridLayout(1, false));
    backPanel.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
    Composite progressPanel = new Composite(backPanel, SWT.NONE);
    progressPanel.setLayout(new GridLayout(3, false));
    progressPanel.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false));
    progressIndicator = new ProgressIndicator(progressPanel, SWT.NONE);
    progressIndicator.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, true));
    btnStop = new Button(progressPanel, SWT.NONE);
    btnStop.setText(Messages.btnStop);
    btnStop.setImage(CommonUIPlugin.getImage("icons/queryeditor/query_run_stop.png"));
    btnStop.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {
            processStop();
        }
    });
    openLogFolderButton = new Button(progressPanel, SWT.NONE);
    openLogFolderButton.setText(Messages.runSQLOpenBtn);
    openLogFolderButton.setEnabled(false);
    openLogFolderButton.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {
            try {
                java.awt.Desktop.getDesktop().open(new File(importConfig.getErrorLogFolderPath()));
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    });
    progressTableViewer = new TableViewer(backPanel, SWT.BORDER | SWT.FULL_SELECTION);
    progressTableViewer.getTable().setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, true));
    progressTableViewer.getTable().setLinesVisible(true);
    progressTableViewer.getTable().setHeaderVisible(true);
    final TableViewerColumn tableName = new TableViewerColumn(progressTableViewer, SWT.NONE);
    final TableViewerColumn totalCount = new TableViewerColumn(progressTableViewer, SWT.NONE);
    final TableViewerColumn parseCount = new TableViewerColumn(progressTableViewer, SWT.NONE);
    final TableViewerColumn failedCount = new TableViewerColumn(progressTableViewer, SWT.NONE);
    final TableViewerColumn status = new TableViewerColumn(progressTableViewer, SWT.NONE);
    final TableViewerColumn elapsedTime = new TableViewerColumn(progressTableViewer, SWT.NONE);
    final TableViewerColumn buttonColumn = new TableViewerColumn(progressTableViewer, SWT.NONE);
    tableName.getColumn().setWidth(250);
    tableName.getColumn().setText(Messages.columnName);
    totalCount.getColumn().setWidth(100);
    totalCount.getColumn().setText(Messages.columnCount);
    parseCount.getColumn().setWidth(100);
    parseCount.getColumn().setText(Messages.columnFinished);
    failedCount.getColumn().setWidth(100);
    failedCount.getColumn().setText(Messages.columnFailed);
    status.getColumn().setWidth(100);
    status.getColumn().setText(Messages.columnStatus);
    elapsedTime.getColumn().setWidth(130);
    elapsedTime.getColumn().setText(Messages.columnTime);
    buttonColumn.getColumn().setWidth(90);
    progressTableViewer.setContentProvider(new TableContentProvider());
    progressTableViewer.setLabelProvider(new TableLabelProvider());
    progressTableViewer.addDoubleClickListener(new IDoubleClickListener() {

        public void doubleClick(DoubleClickEvent event) {
            IStructuredSelection selection = (IStructuredSelection) event.getSelection();
            ImportMonitor monitor = (ImportMonitor) selection.getFirstElement();
            openViewDialog(monitor);
        }
    });
    Composite historyComposite = new Composite(backPanel, SWT.NONE);
    historyComposite.setLayout(new GridLayout(4, false));
    historyComposite.setLayoutData(new GridData(SWT.FILL, SWT.TOP, false, false));
    historyLabel = new Label(historyComposite, SWT.NONE);
    historyLabel.setText(Messages.lblHistory);
    historyText = new Text(historyComposite, SWT.BORDER);
    historyText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    saveButton = new Button(historyComposite, SWT.NONE);
    saveButton.setText(Messages.btnSaveAndClose);
    saveButton.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {
            if (historyText.getText().trim().length() == 0) {
                CommonUITool.openErrorBox(Messages.errHistoryEmpty);
                return;
            }
            if (ImportConfigManager.getInstance().getConfig(historyText.getText()) != null) {
                CommonUITool.openErrorBox(Messages.errHistoryExist);
                return;
            }
            importConfig.setName(historyText.getText().trim());
            ImportConfigManager.getInstance().addConfig(importConfig);
            close();
        }
    });
    closeButton = new Button(historyComposite, SWT.NONE);
    closeButton.setText(Messages.btnClose);
    closeButton.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {
            close();
        }
    });
    setHistroyWidgetStatus(false);
    init();
}
Also used : Composite(org.eclipse.swt.widgets.Composite) ImportMonitor(com.cubrid.common.ui.cubrid.table.dialog.imp.model.ImportMonitor) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Label(org.eclipse.swt.widgets.Label) DoubleClickEvent(org.eclipse.jface.viewers.DoubleClickEvent) Text(org.eclipse.swt.widgets.Text) IOException(java.io.IOException) ITableLabelProvider(org.eclipse.jface.viewers.ITableLabelProvider) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) GridLayout(org.eclipse.swt.layout.GridLayout) Button(org.eclipse.swt.widgets.Button) ProgressIndicator(org.eclipse.jface.dialogs.ProgressIndicator) IDoubleClickListener(org.eclipse.jface.viewers.IDoubleClickListener) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) File(java.io.File) TableViewer(org.eclipse.jface.viewers.TableViewer) TableViewerColumn(org.eclipse.jface.viewers.TableViewerColumn)

Example 20 with IDoubleClickListener

use of org.eclipse.jface.viewers.IDoubleClickListener in project cubrid-manager by CUBRID.

the class TableEditorPart method createPartitionTabItem.

private void createPartitionTabItem(final TabFolder tabFolder) {
    loadPartitionInfoList();
    final TabItem partTabItem = new TabItem(tabFolder, SWT.NONE);
    final Composite parentComp = new Composite(tabFolder, SWT.NONE);
    {
        GridLayout gd = new GridLayout();
        parentComp.setLayout(gd);
    }
    partTabItem.setControl(parentComp);
    partTabItem.setText(Messages.tabItemPartition);
    partitionTableView = new TableViewer(parentComp, SWT.FULL_SELECTION | SWT.MULTI | SWT.BORDER);
    final Table partitionTable = partitionTableView.getTable();
    {
        partitionTable.setLayout(TableViewUtil.createTableViewLayout(new int[] { 20, 15, 10, 20, 25, 10 }));
        GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true);
        gd.heightHint = 350;
        partitionTable.setLayoutData(gd);
    }
    partitionTable.setHeaderVisible(true);
    partitionTable.setLinesVisible(true);
    CommonUITool.hackForYosemite(partitionTable);
    TableViewUtil.createTableColumn(partitionTable, SWT.CENTER, Messages.tblColTableName);
    TableViewUtil.createTableColumn(partitionTable, SWT.CENTER, Messages.tblColPartitionName);
    TableViewUtil.createTableColumn(partitionTable, SWT.CENTER, Messages.tblColType);
    TableViewUtil.createTableColumn(partitionTable, SWT.CENTER, Messages.tblColExpr);
    TableViewUtil.createTableColumn(partitionTable, SWT.CENTER, Messages.tblColExprValue);
    TableViewUtil.createTableColumn(partitionTable, SWT.CENTER, Messages.tblColRows);
    partitionTableView.setLabelProvider(new PartitionTableLabelProvider());
    partitionTableView.setContentProvider(new PartitionContentProvider());
    partitionTableView.setInput(partitionInfoList);
    partitionTableView.addDoubleClickListener(new IDoubleClickListener() {

        public void doubleClick(DoubleClickEvent event) {
            editPartition();
        }
    });
    tabFolder.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(final SelectionEvent event) {
            if (tabFolder.getSelection()[0].getText().equals(Messages.tabItemPartition)) {
                partitionTableView.refresh();
            }
        }
    });
    createPartitionTabButtons(parentComp);
}
Also used : PartitionContentProvider(com.cubrid.common.ui.cubrid.table.control.PartitionContentProvider) TabItem(org.eclipse.swt.widgets.TabItem) PartitionTableLabelProvider(com.cubrid.common.ui.cubrid.table.control.PartitionTableLabelProvider) GridLayout(org.eclipse.swt.layout.GridLayout) Table(org.eclipse.swt.widgets.Table) Composite(org.eclipse.swt.widgets.Composite) IDoubleClickListener(org.eclipse.jface.viewers.IDoubleClickListener) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) DoubleClickEvent(org.eclipse.jface.viewers.DoubleClickEvent) TableViewer(org.eclipse.jface.viewers.TableViewer)

Aggregations

DoubleClickEvent (org.eclipse.jface.viewers.DoubleClickEvent)49 IDoubleClickListener (org.eclipse.jface.viewers.IDoubleClickListener)49 TableViewer (org.eclipse.jface.viewers.TableViewer)33 SelectionEvent (org.eclipse.swt.events.SelectionEvent)29 GridData (org.eclipse.swt.layout.GridData)28 Composite (org.eclipse.swt.widgets.Composite)28 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)23 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)22 ISelectionChangedListener (org.eclipse.jface.viewers.ISelectionChangedListener)16 SelectionChangedEvent (org.eclipse.jface.viewers.SelectionChangedEvent)16 GridLayout (org.eclipse.swt.layout.GridLayout)16 TableViewerColumn (org.eclipse.jface.viewers.TableViewerColumn)14 Table (org.eclipse.swt.widgets.Table)13 TableColumn (org.eclipse.swt.widgets.TableColumn)12 ArrayContentProvider (org.eclipse.jface.viewers.ArrayContentProvider)11 Label (org.eclipse.swt.widgets.Label)11 Button (org.eclipse.swt.widgets.Button)10 ISelection (org.eclipse.jface.viewers.ISelection)8 FillLayout (org.eclipse.swt.layout.FillLayout)8 Event (org.eclipse.swt.widgets.Event)8