Search in sources :

Example 31 with ToolItem

use of org.eclipse.swt.widgets.ToolItem in project cubrid-manager by CUBRID.

the class UnifyHostConfigEditor method createToolBar.

/**
	 * 
	 * Create the tool bar
	 * 
	 * @param parent the Composite
	 * 
	 */
private void createToolBar(Composite parent) {
    final Composite toolBarComp = new Composite(parent, SWT.NONE);
    {
        GridData gd = new GridData(GridData.FILL_HORIZONTAL);
        toolBarComp.setLayoutData(gd);
        GridLayout gridLayout = new GridLayout();
        gridLayout.marginHeight = 0;
        gridLayout.horizontalSpacing = 0;
        gridLayout.marginWidth = 0;
        toolBarComp.setLayout(gridLayout);
    }
    ToolBar toolBar = new ToolBar(toolBarComp, SWT.FLAT);
    ToolItem saveItem = new ToolItem(toolBar, SWT.PUSH);
    saveItem.setImage(CubridManagerUIPlugin.getImage("icons/queryeditor/file_save.png"));
    saveItem.setToolTipText(Messages.msgTipSaveAction);
    saveItem.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {
            if (isDirty) {
                String errMsg = validate();
                if (errMsg != null) {
                    CommonUITool.openErrorBox(errMsg);
                    return;
                }
                doSave(new NullProgressMonitor());
                setDirty(false);
            }
        }
    });
    new ToolItem(toolBar, SWT.SEPARATOR);
    ToolItem addPropItem = new ToolItem(toolBar, SWT.PUSH);
    addPropItem.setImage(CommonUIPlugin.getImage("icons/queryeditor/table_record_insert.png"));
    addPropItem.setToolTipText(com.cubrid.common.ui.common.Messages.cubridBrokerConfEditorAddPropItemLabel);
    addPropItem.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {
            HashMap<String, String> dataMap = new HashMap<String, String>();
            dataMap.put("0", "new property");
            TableViewer addDataTableViewer = null;
            if (confTabFolder.getSelection() == brokerConfTableCTabItem) {
                cubridBrokerConfListData.add(dataMap);
                addDataTableViewer = brokerConfTabTableViewer;
            } else if (confTabFolder.getSelection() == cubridConfTableCTabItem) {
                cubridConfConfigListData.add(dataMap);
                addDataTableViewer = cubridConfTabTableViewer;
            } else if (confTabFolder.getSelection() == cubridCMConfTableCTabItem) {
                cubridConfCMConfigListData.add(dataMap);
                addDataTableViewer = cubridCMConfTabTableViewer;
            }
            for (int i = 1; i < addDataTableViewer.getTable().getColumnCount(); i++) {
                dataMap.put(i + "", "");
            }
            addDataTableViewer.refresh();
            setDirty(true);
            addDataTableViewer.getTable().showItem(addDataTableViewer.getTable().getItem(addDataTableViewer.getTable().getItemCount() - 1));
        }
    });
    ToolItem deletePropItem = new ToolItem(toolBar, SWT.PUSH);
    deletePropItem.setImage(CommonUIPlugin.getImage("icons/queryeditor/table_record_delete.png"));
    deletePropItem.setToolTipText(com.cubrid.common.ui.common.Messages.cubridBrokerConfEditorDeletePropItemLabel);
    deletePropItem.addSelectionListener(new SelectionAdapter() {

        @SuppressWarnings("all")
        public void widgetSelected(SelectionEvent event) {
            TableViewer delDataTableViewer = null;
            List<Map<String, String>> delConfListData = null;
            if (confTabFolder.getSelection() == brokerConfTableCTabItem) {
                delDataTableViewer = brokerConfTabTableViewer;
                delConfListData = cubridBrokerConfListData;
            } else if (confTabFolder.getSelection() == cubridConfTableCTabItem) {
                delDataTableViewer = cubridConfTabTableViewer;
                delConfListData = cubridConfConfigListData;
            } else if (confTabFolder.getSelection() == cubridCMConfTableCTabItem) {
                delDataTableViewer = cubridCMConfTabTableViewer;
                delConfListData = cubridConfCMConfigListData;
            }
            int selectionIndex = delDataTableViewer.getTable().getSelectionIndex();
            if (selectionIndex < 0) {
                CommonUITool.openErrorBox(com.cubrid.common.ui.common.Messages.cubridBrokerConfEditorDeletePropertyMsg);
                return;
            }
            IStructuredSelection selection = (IStructuredSelection) delDataTableViewer.getSelection();
            HashMap<String, String> valueMap = (HashMap<String, String>) selection.getFirstElement();
            if (!CommonUITool.openConfirmBox(Messages.bind(com.cubrid.common.ui.common.Messages.cubridBrokerConfEditorDeleteBrokerPropConfirm, valueMap.get("0")))) {
                return;
            }
            delConfListData.remove(valueMap);
            delDataTableViewer.refresh();
            setDirty(true);
        }
    });
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) Composite(org.eclipse.swt.widgets.Composite) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) GridLayout(org.eclipse.swt.layout.GridLayout) GridData(org.eclipse.swt.layout.GridData) ToolBar(org.eclipse.swt.widgets.ToolBar) SelectionEvent(org.eclipse.swt.events.SelectionEvent) List(java.util.List) ArrayList(java.util.ArrayList) TableViewer(org.eclipse.jface.viewers.TableViewer) ToolItem(org.eclipse.swt.widgets.ToolItem)

Example 32 with ToolItem

use of org.eclipse.swt.widgets.ToolItem in project cubrid-manager by CUBRID.

the class EditConfigEditor method createToolBar.

/**
	 *
	 * Create the tool bar
	 *
	 * @param parent the Composite
	 *
	 */
private void createToolBar(Composite parent) {
    final Composite toolBarComp = new Composite(parent, SWT.NONE);
    {
        GridData gd = new GridData(GridData.FILL_HORIZONTAL);
        toolBarComp.setLayoutData(gd);
        GridLayout gridLayout = new GridLayout();
        gridLayout.marginHeight = 0;
        gridLayout.horizontalSpacing = 0;
        gridLayout.marginWidth = 0;
        toolBarComp.setLayout(gridLayout);
    }
    ToolBar toolBar = new ToolBar(toolBarComp, SWT.FLAT);
    ToolItem saveItem = new ToolItem(toolBar, SWT.PUSH);
    saveItem.setImage(CubridManagerUIPlugin.getImage("icons/queryeditor/file_save.png"));
    saveItem.setToolTipText(Messages.msgTipSaveAction);
    saveItem.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {
            if (isDirty) {
                doSave(new NullProgressMonitor());
            }
        }
    });
    new ToolItem(toolBar, SWT.SEPARATOR);
    ToolItem importItem = new ToolItem(toolBar, SWT.PUSH);
    importItem.setImage(CubridManagerUIPlugin.getImage("icons/queryeditor/file_open.png"));
    importItem.setToolTipText(Messages.msgTipOpenAction);
    importItem.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {
            doImport();
        }
    });
    ToolItem exportItem = new ToolItem(toolBar, SWT.PUSH);
    exportItem.setImage(CubridManagerUIPlugin.getImage("icons/queryeditor/file_saveas.png"));
    exportItem.setToolTipText(Messages.msgTipSaveasAction);
    exportItem.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {
            doExport();
        }
    });
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) GridLayout(org.eclipse.swt.layout.GridLayout) Composite(org.eclipse.swt.widgets.Composite) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) GridData(org.eclipse.swt.layout.GridData) ToolBar(org.eclipse.swt.widgets.ToolBar) SelectionEvent(org.eclipse.swt.events.SelectionEvent) ToolItem(org.eclipse.swt.widgets.ToolItem)

Example 33 with ToolItem

use of org.eclipse.swt.widgets.ToolItem 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 34 with ToolItem

use of org.eclipse.swt.widgets.ToolItem in project cubrid-manager by CUBRID.

the class SettingCubridConfPage method createControl.

/* (non-Javadoc)
	 * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
	 */
public void createControl(Composite parent) {
    Composite container = new Composite(parent, SWT.NONE);
    container.setLayout(new FormLayout());
    setControl(container);
    setDescription(Messages.descSettingCubridPage);
    Composite leftComposite = new Composite(container, SWT.NONE);
    leftComposite.setLayout(new GridLayout(3, false));
    FormData leftData = new FormData();
    leftData.top = new FormAttachment(0, 5);
    leftData.bottom = new FormAttachment(100, 0);
    leftData.left = new FormAttachment(0, 5);
    leftData.right = new FormAttachment(50, -5);
    leftComposite.setLayoutData(leftData);
    Label separator = new Label(container, SWT.SEPARATOR);
    FormData separatorData = new FormData();
    separatorData.top = new FormAttachment(0, 5);
    separatorData.bottom = new FormAttachment(100, -5);
    separatorData.left = new FormAttachment(50, -5);
    separatorData.right = new FormAttachment(50, 5);
    separator.setLayoutData(separatorData);
    Composite rightComposite = new Composite(container, SWT.NONE);
    rightComposite.setLayout(new GridLayout(3, false));
    FormData rightData = new FormData();
    rightData.top = new FormAttachment(0, 5);
    rightData.bottom = new FormAttachment(100, 0);
    rightData.left = new FormAttachment(50, 5);
    rightData.right = new FormAttachment(100, -5);
    rightComposite.setLayoutData(rightData);
    /*Create left widget*/
    Label hostALabel = new Label(leftComposite, SWT.None);
    hostALabel.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
    hostALabel.setText(Messages.lblMaster);
    masterHostLabel = new Label(leftComposite, SWT.None);
    masterHostLabel.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 2, 1, -1, -1));
    masterViewer = new TableViewer(leftComposite, SWT.BORDER | SWT.FULL_SELECTION);
    masterViewer.getTable().setLayoutData(CommonUITool.createGridData(GridData.FILL_BOTH, 3, 1, -1, -1));
    masterViewer.getTable().setLinesVisible(true);
    masterViewer.getTable().setHeaderVisible(true);
    masterViewer.setContentProvider(new TableContentProvider());
    masterViewer.setLabelProvider(new CubridConfTableProvider());
    masterViewer.setColumnProperties(PROPS);
    CellEditor[] editorsA = new CellEditor[2];
    editorsA[0] = null;
    editorsA[1] = new TextCellEditor(masterViewer.getTable());
    masterViewer.setCellEditors(editorsA);
    masterViewer.setCellModifier(new ICellModifier() {

        public boolean canModify(Object element, String property) {
            if (property.equals(PROPS[1])) {
                return true;
            }
            return false;
        }

        public Object getValue(Object element, String property) {
            DataModel model = (DataModel) element;
            if (property.equals(PROPS[0])) {
                return model.getKey() == null ? "" : model.getKey();
            } else if (property.equals(PROPS[1])) {
                return model.getValue() == null ? "" : model.getValue();
            }
            return "";
        }

        public void modify(Object element, String property, Object value) {
            TableItem item = (TableItem) element;
            DataModel model = (DataModel) item.getData();
            model.setValue(value.toString());
            masterViewer.refresh(model);
            updateHAModel(masterViewer, model, false);
        }
    });
    TableColumn keyAColumn = new TableColumn(masterViewer.getTable(), SWT.LEFT);
    keyAColumn.setText(Messages.lblKey);
    keyAColumn.setWidth(160);
    TableColumn valueAColumn = new TableColumn(masterViewer.getTable(), SWT.LEFT);
    valueAColumn.setText(Messages.lblValue);
    valueAColumn.setWidth(200);
    Label masterDBLabel = new Label(leftComposite, SWT.None);
    masterDBLabel.setText(Messages.lblDatabase);
    masterDBLabel.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
    masterDBCombo = new Combo(leftComposite, SWT.BORDER | SWT.READ_ONLY);
    masterDBCombo.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
    masterDBCombo.addSelectionListener(new SelectionListener() {

        public void widgetSelected(SelectionEvent e) {
            widgetDefaultSelected(e);
        }

        public void widgetDefaultSelected(SelectionEvent e) {
            HAModel haModel = getConfigHAWizard().getHaModel();
            /*Init table data*/
            initTableData(haModel.getMasterServer(), true);
            HAServer haServer = haModel.getSlaveServer();
            initTableData(haServer, false);
        }
    });
    ToolBar toolBarA = new ToolBar(leftComposite, SWT.None);
    toolBarA.setLayoutData(CommonUITool.createGridData(GridData.HORIZONTAL_ALIGN_END, 1, 1, -1, -1));
    ToolItem addItemA = new ToolItem(toolBarA, SWT.None);
    addItemA.setToolTipText(Messages.itemAddParameter);
    addItemA.setImage(CubridManagerUIPlugin.getImage("/icons/replication/add_param.gif"));
    addItemA.addSelectionListener(new SelectionListener() {

        public void widgetSelected(SelectionEvent e) {
            widgetDefaultSelected(e);
        }

        public void widgetDefaultSelected(SelectionEvent e) {
            addParameter(masterViewer);
        }
    });
    ToolItem editItemA = new ToolItem(toolBarA, SWT.None);
    editItemA.setToolTipText(Messages.itemEditParameter);
    editItemA.setImage(CubridManagerUIPlugin.getImage("/icons/replication/edit_param.gif"));
    editItemA.addSelectionListener(new SelectionListener() {

        public void widgetSelected(SelectionEvent e) {
            widgetDefaultSelected(e);
        }

        public void widgetDefaultSelected(SelectionEvent e) {
            editParameter(masterViewer);
        }
    });
    ToolItem dropItemA = new ToolItem(toolBarA, SWT.None);
    dropItemA.setToolTipText(Messages.itemDeleteParameter);
    dropItemA.setImage(CubridManagerUIPlugin.getImage("/icons/replication/delete_param.gif"));
    dropItemA.addSelectionListener(new SelectionListener() {

        public void widgetSelected(SelectionEvent e) {
            widgetDefaultSelected(e);
        }

        public void widgetDefaultSelected(SelectionEvent e) {
            dropParameter(masterViewer);
        }
    });
    /*Create right widget*/
    Label hostBLabel = new Label(rightComposite, SWT.None);
    hostBLabel.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
    hostBLabel.setText(Messages.lblSlave);
    slaveHostLabel = new Label(rightComposite, SWT.None);
    slaveHostLabel.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 2, 1, -1, -1));
    slaveViewer = new TableViewer(rightComposite, SWT.BORDER | SWT.FULL_SELECTION);
    slaveViewer.getTable().setLayoutData(CommonUITool.createGridData(GridData.FILL_BOTH, 3, 1, -1, -1));
    slaveViewer.getTable().setLinesVisible(true);
    slaveViewer.getTable().setHeaderVisible(true);
    slaveViewer.setContentProvider(new TableContentProvider());
    slaveViewer.setLabelProvider(new CubridConfTableProvider());
    slaveViewer.setColumnProperties(PROPS);
    CellEditor[] editorsB = new CellEditor[2];
    editorsB[0] = null;
    editorsB[1] = new TextCellEditor(slaveViewer.getTable());
    slaveViewer.setCellEditors(editorsB);
    slaveViewer.setCellModifier(new ICellModifier() {

        public boolean canModify(Object element, String property) {
            if (property.equals(PROPS[1])) {
                return true;
            }
            return false;
        }

        public Object getValue(Object element, String property) {
            DataModel model = (DataModel) element;
            if (property.equals(PROPS[0])) {
                return model.getKey() == null ? "" : model.getKey();
            } else if (property.equals(PROPS[1])) {
                return model.getValue() == null ? "" : model.getValue();
            }
            return "";
        }

        public void modify(Object element, String property, Object value) {
            TableItem item = (TableItem) element;
            DataModel model = (DataModel) item.getData();
            model.setValue(value.toString());
            slaveViewer.refresh(model);
            updateHAModel(slaveViewer, model, false);
        }
    });
    TableColumn keyBColumn = new TableColumn(slaveViewer.getTable(), SWT.LEFT);
    keyBColumn.setText(Messages.lblKey);
    keyBColumn.setWidth(160);
    TableColumn valueBColumn = new TableColumn(slaveViewer.getTable(), SWT.LEFT);
    valueBColumn.setText(Messages.lblValue);
    valueBColumn.setWidth(200);
    ToolBar toolBarB = new ToolBar(rightComposite, SWT.None);
    toolBarB.setLayoutData(CommonUITool.createGridData(GridData.HORIZONTAL_ALIGN_END, 3, 1, -1, -1));
    ToolItem addItemB = new ToolItem(toolBarB, SWT.None);
    addItemB.setToolTipText(Messages.itemAddParameter);
    addItemB.setImage(CubridManagerUIPlugin.getImage("/icons/replication/add_param.gif"));
    addItemB.addSelectionListener(new SelectionListener() {

        public void widgetSelected(SelectionEvent e) {
            widgetDefaultSelected(e);
        }

        public void widgetDefaultSelected(SelectionEvent e) {
            addParameter(slaveViewer);
        }
    });
    ToolItem editItemB = new ToolItem(toolBarB, SWT.None);
    editItemB.setToolTipText(Messages.itemEditParameter);
    editItemB.setImage(CubridManagerUIPlugin.getImage("/icons/replication/edit_param.gif"));
    editItemB.addSelectionListener(new SelectionListener() {

        public void widgetSelected(SelectionEvent e) {
            widgetDefaultSelected(e);
        }

        public void widgetDefaultSelected(SelectionEvent e) {
            editParameter(slaveViewer);
        }
    });
    ToolItem dropItemB = new ToolItem(toolBarB, SWT.None);
    dropItemB.setToolTipText(Messages.itemDeleteParameter);
    dropItemB.setImage(CubridManagerUIPlugin.getImage("/icons/replication/delete_param.gif"));
    dropItemB.addSelectionListener(new SelectionListener() {

        public void widgetSelected(SelectionEvent e) {
            widgetDefaultSelected(e);
        }

        public void widgetDefaultSelected(SelectionEvent e) {
            dropParameter(slaveViewer);
        }
    });
}
Also used : CellEditor(org.eclipse.jface.viewers.CellEditor) TextCellEditor(org.eclipse.jface.viewers.TextCellEditor) TableItem(org.eclipse.swt.widgets.TableItem) Label(org.eclipse.swt.widgets.Label) Combo(org.eclipse.swt.widgets.Combo) GridLayout(org.eclipse.swt.layout.GridLayout) TableContentProvider(com.cubrid.common.ui.spi.TableContentProvider) ICellModifier(org.eclipse.jface.viewers.ICellModifier) SelectionEvent(org.eclipse.swt.events.SelectionEvent) FormAttachment(org.eclipse.swt.layout.FormAttachment) ToolItem(org.eclipse.swt.widgets.ToolItem) FormLayout(org.eclipse.swt.layout.FormLayout) FormData(org.eclipse.swt.layout.FormData) Composite(org.eclipse.swt.widgets.Composite) TableColumn(org.eclipse.swt.widgets.TableColumn) ToolBar(org.eclipse.swt.widgets.ToolBar) TextCellEditor(org.eclipse.jface.viewers.TextCellEditor) TableViewer(org.eclipse.jface.viewers.TableViewer) SelectionListener(org.eclipse.swt.events.SelectionListener)

Example 35 with ToolItem

use of org.eclipse.swt.widgets.ToolItem in project cubrid-manager by CUBRID.

the class SerialDashboardEditorPart method createPartControl.

public void createPartControl(Composite parent) {
    parent.setLayout(new GridLayout(1, false));
    ToolBar toolBar = new ToolBar(parent, SWT.LEFT_TO_RIGHT | SWT.FLAT);
    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) {
            refresh();
        }
    });
    new ToolItem(toolBar, SWT.SEPARATOR);
    ToolItem addSerailItem = new ToolItem(toolBar, SWT.NONE);
    addSerailItem.setText(Messages.serialsDetailInfoPartCreateSerialBtn);
    addSerailItem.setImage(CommonUIPlugin.getImage("icons/action/serial_add.png"));
    addSerailItem.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(final SelectionEvent event) {
            addSerial();
        }
    });
    ToolItem editSerailItem = new ToolItem(toolBar, SWT.NONE);
    editSerailItem.setText(Messages.serialsDetailInfoPartEditSerialBtn);
    editSerailItem.setImage(CommonUIPlugin.getImage("icons/action/serial_edit.png"));
    editSerailItem.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(final SelectionEvent event) {
            editSerial();
        }
    });
    ToolItem dropSerailItem = new ToolItem(toolBar, SWT.NONE);
    dropSerailItem.setText(Messages.serialsDetailInfoPartDropSerialBtn);
    dropSerailItem.setImage(CommonUIPlugin.getImage("icons/action/serial_delete.png"));
    dropSerailItem.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(final SelectionEvent event) {
            dropSerial();
        }
    });
    createSerialsDetailInfoTable(parent);
    this.setInputs();
}
Also used : GridLayout(org.eclipse.swt.layout.GridLayout) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) ToolBar(org.eclipse.swt.widgets.ToolBar) SelectionEvent(org.eclipse.swt.events.SelectionEvent) ToolItem(org.eclipse.swt.widgets.ToolItem)

Aggregations

ToolItem (org.eclipse.swt.widgets.ToolItem)140 ToolBar (org.eclipse.swt.widgets.ToolBar)110 SelectionEvent (org.eclipse.swt.events.SelectionEvent)91 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)81 GridData (org.eclipse.swt.layout.GridData)73 Composite (org.eclipse.swt.widgets.Composite)64 GridLayout (org.eclipse.swt.layout.GridLayout)58 Image (org.eclipse.swt.graphics.Image)36 Label (org.eclipse.swt.widgets.Label)32 Point (org.eclipse.swt.graphics.Point)26 DisposeEvent (org.eclipse.swt.events.DisposeEvent)25 DisposeListener (org.eclipse.swt.events.DisposeListener)24 Cursor (org.eclipse.swt.graphics.Cursor)20 FillLayout (org.eclipse.swt.layout.FillLayout)18 SelectionListener (org.eclipse.swt.events.SelectionListener)17 TableViewer (org.eclipse.jface.viewers.TableViewer)16 Text (org.eclipse.swt.widgets.Text)16 Display (org.eclipse.swt.widgets.Display)15 ArrayList (java.util.ArrayList)14 List (java.util.List)14