Search in sources :

Example 41 with DoubleClickEvent

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

the class AddOrEditSrxConfigDialog method createLanguageGroup.

/**
	 * 创建语言规则配置
	 * @param tparent
	 *            ;
	 */
private void createLanguageGroup(Composite tparent, GridData groupData, GridLayout groupLayout) {
    Group group = new Group(tparent, SWT.BORDER);
    group.setLayoutData(groupData);
    group.setLayout(groupLayout);
    group.setText(Messages.getString("srx.AddOrEditSrxConfigDialog.groupLang"));
    langTableViewer = new TableViewer(group, SWT.FULL_SELECTION | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | SWT.MULTI);
    langTable = langTableViewer.getTable();
    langTable.setLinesVisible(true);
    langTable.setHeaderVisible(true);
    GridDataFactory.fillDefaults().span(4, SWT.DEFAULT).grab(true, true).applyTo(langTable);
    langTableViewer.setLabelProvider(new TableViewerLabelProvider());
    langTableViewer.setContentProvider(new ArrayContentProvider());
    String[] columnNames = new String[] { Messages.getString("srx.AddOrEditSrxConfigDialog.langColumnNames1"), Messages.getString("srx.AddOrEditSrxConfigDialog.langColumnNames2") };
    int[] columnAlignments = new int[] { SWT.LEFT, SWT.LEFT };
    for (int i = 0; i < columnNames.length; i++) {
        TableColumn tableColumn = new TableColumn(langTable, columnAlignments[i]);
        tableColumn.setText(columnNames[i]);
        tableColumn.setWidth(50);
    }
    refreshTableWidth(langTable);
    langAddBtn = new Button(group, SWT.NONE);
    langAddBtn.setText(Messages.getString("srx.AddOrEditSrxConfigDialog.langAddBtn"));
    setButtonLayoutData(langAddBtn);
    langEditBtn = new Button(group, SWT.NONE);
    langEditBtn.setText(Messages.getString("srx.AddOrEditSrxConfigDialog.langEditBtn"));
    setButtonLayoutData(langEditBtn);
    langDeleteBtn = new Button(group, SWT.NONE);
    langDeleteBtn.setText(Messages.getString("srx.AddOrEditSrxConfigDialog.langDeleteBtn"));
    setButtonLayoutData(langDeleteBtn);
    new Label(group, SWT.NONE);
    langTableViewer.addDoubleClickListener(new IDoubleClickListener() {

        public void doubleClick(DoubleClickEvent event) {
            editLangRules();
        }
    });
}
Also used : Group(org.eclipse.swt.widgets.Group) Label(org.eclipse.swt.widgets.Label) DoubleClickEvent(org.eclipse.jface.viewers.DoubleClickEvent) TableColumn(org.eclipse.swt.widgets.TableColumn) Button(org.eclipse.swt.widgets.Button) TableViewerLabelProvider(net.heartsome.cat.ts.ui.advanced.TableViewerLabelProvider) IDoubleClickListener(org.eclipse.jface.viewers.IDoubleClickListener) ArrayContentProvider(org.eclipse.jface.viewers.ArrayContentProvider) TableViewer(org.eclipse.jface.viewers.TableViewer)

Example 42 with DoubleClickEvent

use of org.eclipse.jface.viewers.DoubleClickEvent 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 43 with DoubleClickEvent

use of org.eclipse.jface.viewers.DoubleClickEvent 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 44 with DoubleClickEvent

use of org.eclipse.jface.viewers.DoubleClickEvent 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 45 with DoubleClickEvent

use of org.eclipse.jface.viewers.DoubleClickEvent 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)

Aggregations

DoubleClickEvent (org.eclipse.jface.viewers.DoubleClickEvent)68 IDoubleClickListener (org.eclipse.jface.viewers.IDoubleClickListener)67 GridData (org.eclipse.swt.layout.GridData)40 TableViewer (org.eclipse.jface.viewers.TableViewer)37 SelectionEvent (org.eclipse.swt.events.SelectionEvent)33 Composite (org.eclipse.swt.widgets.Composite)33 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)29 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 TreeViewer (org.eclipse.jface.viewers.TreeViewer)12 ISelection (org.eclipse.jface.viewers.ISelection)11 FillLayout (org.eclipse.swt.layout.FillLayout)10