Search in sources :

Example 41 with IDoubleClickListener

use of org.eclipse.jface.viewers.IDoubleClickListener in project translationstudio8 by heartsome.

the class XmlConvertManagerDialog method createTable.

protected void createTable(Composite tparent) {
    tableViewer = new TableViewer(tparent, SWT.FULL_SELECTION | SWT.V_SCROLL | SWT.H_SCROLL | SWT.MULTI | SWT.BORDER);
    table = tableViewer.getTable();
    table.setHeaderVisible(true);
    table.setLinesVisible(true);
    GridDataFactory.fillDefaults().grab(true, true).applyTo(table);
    createTableColumns();
    // 让列表列宽动态变化
    table.addListener(SWT.Resize, new Listener() {

        public void handleEvent(Event event) {
            final Table table = ((Table) event.widget);
            final TableColumn[] columns = table.getColumns();
            event.widget.getDisplay().syncExec(new Runnable() {

                public void run() {
                    double[] columnWidths = new double[] { 0.2, 0.2, 0.2, 0.20, 0.14 };
                    for (int i = 0; i < columns.length; i++) columns[i].setWidth((int) (table.getBounds().width * columnWidths[i]));
                }
            });
        }
    });
    tableViewer.setLabelProvider(new TViewerLabelProvider());
    tableViewer.setContentProvider(new ArrayContentProvider());
    tableViewer.addDoubleClickListener(new IDoubleClickListener() {

        public void doubleClick(DoubleClickEvent event) {
            editElement();
        }
    });
}
Also used : Listener(org.eclipse.swt.widgets.Listener) IDoubleClickListener(org.eclipse.jface.viewers.IDoubleClickListener) Table(org.eclipse.swt.widgets.Table) IDoubleClickListener(org.eclipse.jface.viewers.IDoubleClickListener) ArrayContentProvider(org.eclipse.jface.viewers.ArrayContentProvider) Event(org.eclipse.swt.widgets.Event) DoubleClickEvent(org.eclipse.jface.viewers.DoubleClickEvent) SelectionEvent(org.eclipse.swt.events.SelectionEvent) DoubleClickEvent(org.eclipse.jface.viewers.DoubleClickEvent) TableViewer(org.eclipse.jface.viewers.TableViewer)

Example 42 with IDoubleClickListener

use of org.eclipse.jface.viewers.IDoubleClickListener in project translationstudio8 by heartsome.

the class SrxMapRulesManageDialog method createTable.

private void createTable(Composite tparent) {
    tableViewer = new TableViewer(tparent, SWT.FULL_SELECTION | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | SWT.MULTI);
    table = tableViewer.getTable();
    table.setLinesVisible(true);
    table.setHeaderVisible(true);
    GridDataFactory.fillDefaults().span(4, SWT.DEFAULT).grab(true, true).applyTo(table);
    tableViewer.setLabelProvider(new TViewerLabelProvider());
    tableViewer.setContentProvider(new ArrayContentProvider());
    String[] columnNames = new String[] { Messages.getString("srx.SrxMapRulesManageDialog.columnNames1"), Messages.getString("srx.SrxMapRulesManageDialog.columnNames2") };
    int[] columnAlignments = new int[] { SWT.LEFT, SWT.LEFT };
    for (int i = 0; i < columnNames.length; i++) {
        TableColumn tableColumn = new TableColumn(table, columnAlignments[i]);
        tableColumn.setText(columnNames[i]);
        tableColumn.setWidth(50);
    }
    // 让列表列宽动态变化
    table.addListener(SWT.Resize, new Listener() {

        public void handleEvent(Event event) {
            final Table table = ((Table) event.widget);
            final TableColumn[] columns = table.getColumns();
            event.widget.getDisplay().syncExec(new Runnable() {

                public void run() {
                    double[] columnWidths = new double[] { 0.2, 0.77 };
                    for (int i = 0; i < columns.length; i++) columns[i].setWidth((int) (table.getBounds().width * columnWidths[i]));
                }
            });
        }
    });
    tableViewer.addDoubleClickListener(new IDoubleClickListener() {

        public void doubleClick(DoubleClickEvent event) {
            editMapRule();
        }
    });
}
Also used : Listener(org.eclipse.swt.widgets.Listener) IDoubleClickListener(org.eclipse.jface.viewers.IDoubleClickListener) Table(org.eclipse.swt.widgets.Table) DoubleClickEvent(org.eclipse.jface.viewers.DoubleClickEvent) TableColumn(org.eclipse.swt.widgets.TableColumn) IDoubleClickListener(org.eclipse.jface.viewers.IDoubleClickListener) ArrayContentProvider(org.eclipse.jface.viewers.ArrayContentProvider) Event(org.eclipse.swt.widgets.Event) DoubleClickEvent(org.eclipse.jface.viewers.DoubleClickEvent) SelectionEvent(org.eclipse.swt.events.SelectionEvent) TableViewer(org.eclipse.jface.viewers.TableViewer)

Example 43 with IDoubleClickListener

use of org.eclipse.jface.viewers.IDoubleClickListener in project translationstudio8 by heartsome.

the class LocationPageContentProvider method setupListeners.

/**
	 * 注册监听 ;
	 */
void setupListeners() {
    wsTreeViewer.addSelectionChangedListener(new ISelectionChangedListener() {

        public void selectionChanged(SelectionChangedEvent event) {
            IStructuredSelection s = (IStructuredSelection) event.getSelection();
            Object obj = s.getFirstElement();
            if (obj instanceof IContainer) {
                wsContainer = (IContainer) obj;
            } else if (obj instanceof IFile) {
                IFile tempFile = (IFile) obj;
                wsContainer = tempFile.getParent();
                wsFilenameText.setText(tempFile.getName());
            }
        }
    });
    wsTreeViewer.addDoubleClickListener(new IDoubleClickListener() {

        public void doubleClick(DoubleClickEvent event) {
            ISelection s = event.getSelection();
            if (s instanceof IStructuredSelection) {
                Object item = ((IStructuredSelection) s).getFirstElement();
                if (wsTreeViewer.getExpandedState(item)) {
                    wsTreeViewer.collapseToLevel(item, 1);
                } else {
                    wsTreeViewer.expandToLevel(item, 1);
                }
            }
        }
    });
    wsFilenameText.addModifyListener(new ModifyListener() {

        public void modifyText(ModifyEvent e) {
            String patchName = wsFilenameText.getText();
            if (patchName.trim().equals("")) {
                //$NON-NLS-1$
                okButton.setEnabled(false);
                setErrorMessage(Messages.getString("dialog.WorkspaceDialog.msg1"));
            } else if (!(ResourcesPlugin.getWorkspace().validateName(patchName, IResource.FILE)).isOK()) {
                // make sure that the filename does not contain more than one segment
                okButton.setEnabled(false);
                setErrorMessage(Messages.getString("dialog.WorkspaceDialog.msg2"));
            } else {
                okButton.setEnabled(true);
                setErrorMessage(null);
            }
        }
    });
}
Also used : ModifyEvent(org.eclipse.swt.events.ModifyEvent) IFile(org.eclipse.core.resources.IFile) ModifyListener(org.eclipse.swt.events.ModifyListener) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) IDoubleClickListener(org.eclipse.jface.viewers.IDoubleClickListener) ISelection(org.eclipse.jface.viewers.ISelection) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) DoubleClickEvent(org.eclipse.jface.viewers.DoubleClickEvent) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) IContainer(org.eclipse.core.resources.IContainer)

Example 44 with IDoubleClickListener

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

the class SerialDashboardEditorPart method createSerialsDetailInfoTable.

public void createSerialsDetailInfoTable(Composite parent) {
    final Composite tableComposite = new Composite(parent, SWT.NONE);
    tableComposite.setLayout(new FillLayout());
    tableComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
    serialsDetailInfoTable = new TableViewer(tableComposite, SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION | SWT.MULTI | SWT.BORDER);
    serialsDetailInfoTable.getTable().setHeaderVisible(true);
    serialsDetailInfoTable.getTable().setLinesVisible(true);
    CommonUITool.hackForYosemite(serialsDetailInfoTable.getTable());
    final TableViewerColumn nameColumn = new TableViewerColumn(serialsDetailInfoTable, SWT.LEFT);
    nameColumn.getColumn().setWidth(150);
    nameColumn.getColumn().setText(Messages.serialsDetailInfoPartTableNameCol);
    final TableViewerColumn curValColumn = new TableViewerColumn(serialsDetailInfoTable, SWT.LEFT);
    curValColumn.getColumn().setWidth(120);
    curValColumn.getColumn().setText(Messages.serialsDetailInfoPartTableCurValCol);
    final TableViewerColumn increValColumn = new TableViewerColumn(serialsDetailInfoTable, SWT.LEFT);
    increValColumn.getColumn().setWidth(120);
    increValColumn.getColumn().setText(Messages.serialsDetailInfoPartTableIncreValCol);
    final TableViewerColumn minValColumn = new TableViewerColumn(serialsDetailInfoTable, SWT.LEFT);
    minValColumn.getColumn().setWidth(100);
    minValColumn.getColumn().setText(Messages.serialsDetailInfoPartTableMinValCol);
    final TableViewerColumn maxValColumn = new TableViewerColumn(serialsDetailInfoTable, SWT.LEFT);
    maxValColumn.getColumn().setWidth(100);
    maxValColumn.getColumn().setText(Messages.serialsDetailInfoPartTableMaxValCol);
    final TableViewerColumn cacheNumColumn = new TableViewerColumn(serialsDetailInfoTable, SWT.LEFT);
    cacheNumColumn.getColumn().setWidth(70);
    cacheNumColumn.getColumn().setText(Messages.serialsDetailInfoPartTableCacheNumCol);
    final TableViewerColumn cycleColumn = new TableViewerColumn(serialsDetailInfoTable, SWT.LEFT);
    cycleColumn.getColumn().setWidth(50);
    cycleColumn.getColumn().setText(Messages.serialsDetailInfoPartTableCycleCol);
    serialsDetailInfoTable.setComparator(new ColumnViewerSorter());
    serialsDetailInfoTable.setContentProvider(new SerialsDetailTableViewerContentProvider());
    serialsDetailInfoTable.setLabelProvider(new SerialTableViewerLabelProvider());
    serialsDetailInfoTable.addDoubleClickListener(new IDoubleClickListener() {

        public void doubleClick(DoubleClickEvent event) {
            StructuredSelection sel = (StructuredSelection) event.getSelection();
            if (sel == null) {
                return;
            }
            SerialInfo serialInfo = (SerialInfo) sel.getFirstElement();
            if (serialInfo == null) {
                return;
            }
            openEditSerialDialog(serialInfo);
        }
    });
    registerContextMenu();
}
Also used : Composite(org.eclipse.swt.widgets.Composite) IDoubleClickListener(org.eclipse.jface.viewers.IDoubleClickListener) GridData(org.eclipse.swt.layout.GridData) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) DoubleClickEvent(org.eclipse.jface.viewers.DoubleClickEvent) FillLayout(org.eclipse.swt.layout.FillLayout) SerialInfo(com.cubrid.common.core.common.model.SerialInfo) TableViewer(org.eclipse.jface.viewers.TableViewer) TableViewerColumn(org.eclipse.jface.viewers.TableViewerColumn)

Example 45 with IDoubleClickListener

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

the class FavoriteQueryNavigatorView method createTableGroup.

private void createTableGroup(Composite composite) {
    final String[] columnNames = new String[] { "", com.cubrid.common.ui.query.Messages.msgBatchRunSqlFile, com.cubrid.common.ui.query.Messages.msgBatchRunMemo, com.cubrid.common.ui.query.Messages.msgBatchRunRegdate };
    tv = CommonUITool.createCommonTableViewer(composite, null, columnNames, CommonUITool.createGridData(GridData.FILL_BOTH, 3, 1, -1, 200));
    tv.setInput(FavoriteQueryPersistUtil.getInstance().getListData());
    {
        TableLayout tableLayout = new TableLayout();
        tableLayout.addColumnData(new ColumnPixelData(0));
        tableLayout.addColumnData(new ColumnPixelData(209));
        tableLayout.addColumnData(new ColumnPixelData(80));
        tableLayout.addColumnData(new ColumnPixelData(118));
        tv.getTable().setLayout(tableLayout);
    }
    editor = new TableEditor(tv.getTable());
    editor.horizontalAlignment = SWT.LEFT;
    editor.grabHorizontal = true;
    tv.getTable().addSelectionListener(new SelectionListener() {

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

        public void widgetDefaultSelected(SelectionEvent e) {
            updateButtonStatus();
        }
    });
    tv.getTable().addListener(SWT.MouseUp, new Listener() {

        public void handleEvent(Event event) {
            if (event.button != 1) {
                return;
            }
            updateButtonStatus();
            Point pt = new Point(event.x, event.y);
            int newIndex = tv.getTable().getSelectionIndex();
            if (tv.getTable().getItemCount() <= newIndex || newIndex < 0) {
                return;
            }
            final TableItem item = tv.getTable().getItem(newIndex);
            if (item == null) {
                return;
            }
            Rectangle rect = item.getBounds(2);
            if (rect.contains(pt)) {
                focusCell(item, newIndex, 2);
            }
        }
    });
    tv.addDoubleClickListener(new IDoubleClickListener() {

        public void doubleClick(DoubleClickEvent event) {
            ISelection selection = event.getSelection();
            openSelectedFile(selection);
        }
    });
    createContextMenu();
}
Also used : IDoubleClickListener(org.eclipse.jface.viewers.IDoubleClickListener) TraverseListener(org.eclipse.swt.events.TraverseListener) MenuListener(org.eclipse.swt.events.MenuListener) SelectionListener(org.eclipse.swt.events.SelectionListener) Listener(org.eclipse.swt.widgets.Listener) TableItem(org.eclipse.swt.widgets.TableItem) ColumnPixelData(org.eclipse.jface.viewers.ColumnPixelData) Rectangle(org.eclipse.swt.graphics.Rectangle) DoubleClickEvent(org.eclipse.jface.viewers.DoubleClickEvent) Point(org.eclipse.swt.graphics.Point) TableEditor(org.eclipse.swt.custom.TableEditor) IDoubleClickListener(org.eclipse.jface.viewers.IDoubleClickListener) SelectionEvent(org.eclipse.swt.events.SelectionEvent) ISelection(org.eclipse.jface.viewers.ISelection) MenuEvent(org.eclipse.swt.events.MenuEvent) TraverseEvent(org.eclipse.swt.events.TraverseEvent) Event(org.eclipse.swt.widgets.Event) DoubleClickEvent(org.eclipse.jface.viewers.DoubleClickEvent) SelectionEvent(org.eclipse.swt.events.SelectionEvent) TableLayout(org.eclipse.jface.viewers.TableLayout) SelectionListener(org.eclipse.swt.events.SelectionListener)

Aggregations

DoubleClickEvent (org.eclipse.jface.viewers.DoubleClickEvent)67 IDoubleClickListener (org.eclipse.jface.viewers.IDoubleClickListener)67 GridData (org.eclipse.swt.layout.GridData)40 TableViewer (org.eclipse.jface.viewers.TableViewer)37 Composite (org.eclipse.swt.widgets.Composite)33 SelectionEvent (org.eclipse.swt.events.SelectionEvent)32 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)28 ISelectionChangedListener (org.eclipse.jface.viewers.ISelectionChangedListener)25 SelectionChangedEvent (org.eclipse.jface.viewers.SelectionChangedEvent)25 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)23 GridLayout (org.eclipse.swt.layout.GridLayout)21 Table (org.eclipse.swt.widgets.Table)16 TableViewerColumn (org.eclipse.jface.viewers.TableViewerColumn)15 ArrayContentProvider (org.eclipse.jface.viewers.ArrayContentProvider)13 Button (org.eclipse.swt.widgets.Button)13 Label (org.eclipse.swt.widgets.Label)13 TableColumn (org.eclipse.swt.widgets.TableColumn)13 ISelection (org.eclipse.jface.viewers.ISelection)11 TreeViewer (org.eclipse.jface.viewers.TreeViewer)11 FillLayout (org.eclipse.swt.layout.FillLayout)10