Search in sources :

Example 96 with SelectionAdapter

use of org.eclipse.swt.events.SelectionAdapter in project tdi-studio-se by Talend.

the class WizardJetFilesChoosePage method creatResourceLangGrp.

private void creatResourceLangGrp(Composite groupsComposite) {
    Group resourceLangGrp = new Group(groupsComposite, SWT.NONE);
    //$NON-NLS-1$
    resourceLangGrp.setText("Select language dependent file");
    // GridDataFactory.fillDefaults().span(1, 1).grab(true, false).applyTo(
    // filesSelectionGrp);
    resourceLangGrp.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    GridLayout groupLayout = new GridLayout(3, false);
    resourceLangGrp.setLayout(groupLayout);
    useDefaultResourceButton = new Button(resourceLangGrp, SWT.CHECK | SWT.RIGHT);
    useDefaultResourceButton.setText(PluginConstant.DEFAULTLANG_RESOURCE);
    useZHResourceButton = new Button(resourceLangGrp, SWT.CHECK | SWT.RIGHT);
    useZHResourceButton.setText(PluginConstant.ZHLANG_RESOURCE);
    useFRResourceButton = new Button(resourceLangGrp, SWT.CHECK | SWT.RIGHT);
    useFRResourceButton.setText(PluginConstant.FRLANG_RESOURCE);
    SelectionListener listener = new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            setPageComplete(validatePage());
            Button button = ((Button) e.getSource());
            if (button.getSelection()) {
                componentPref.getResourceLanguageTypes().add(ResourceLanguageType.find(button.getText()));
            } else {
                componentPref.getResourceLanguageTypes().remove(ResourceLanguageType.find(button.getText()));
            }
        // propertyChangeBean.firePropertyChange(PluginConstant.RESOURCETYPE_PROPERTY, null, resourceTypes);
        }
    };
    useDefaultResourceButton.addSelectionListener(listener);
    useZHResourceButton.addSelectionListener(listener);
    useFRResourceButton.addSelectionListener(listener);
}
Also used : Group(org.eclipse.swt.widgets.Group) GridLayout(org.eclipse.swt.layout.GridLayout) Button(org.eclipse.swt.widgets.Button) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) SelectionListener(org.eclipse.swt.events.SelectionListener)

Example 97 with SelectionAdapter

use of org.eclipse.swt.events.SelectionAdapter in project tdi-studio-se by Talend.

the class AbstractXMLConfigPage method initialize.

/*
     * (non-Javadoc)
     * 
     * @see org.talend.componentdesigner.ui.wizard.creatcomponent.AbstractComponentPage#initialize()
     */
protected void initialize() {
    availableXmlTree.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent event) {
            if (availableXmlTree.getMenu() != null) {
                availableXmlTree.getMenu().dispose();
            }
            final TreeItem[] treeItem = ((Tree) event.getSource()).getSelection();
            Menu popMenu = new Menu(availableXmlTree);
            MenuItem itemNew = new MenuItem(popMenu, SWT.CASCADE);
            //$NON-NLS-1$
            itemNew.setText(Messages.getString("AbstractXMLConfigPage.New"));
            MenuItem itemDel = new MenuItem(popMenu, SWT.CASCADE);
            //$NON-NLS-1$
            itemDel.setText(Messages.getString("AbstractXMLConfigPage.Delete"));
            itemDel.addSelectionListener(new SelectionAdapter() {

                public void widgetSelected(SelectionEvent e) {
                    TreeNodeData currentNodeData = (TreeNodeData) treeItem[0].getParentItem().getData();
                    currentNodeData.getXMLNode().removeChild(((TreeNodeData) treeItem[0].getData()).getXMLNode());
                    treeItem[0].dispose();
                }
            });
            final TreeNodeData treeNodeData = ((TreeNodeData) treeItem[0].getData());
            if (treeNodeData.isHasChildTreeNode()) {
                Menu subNewMenu = new Menu(itemNew);
                itemNew.setMenu(subNewMenu);
                Object[] subNodeNames = treeNodeData.getChildNodeNames();
                for (Object nodeName : subNodeNames) {
                    final MenuItem nodeMenuItem = new MenuItem(subNewMenu, SWT.CASCADE);
                    final String itemName = (String) nodeName;
                    nodeMenuItem.setText(itemName);
                    nodeMenuItem.addSelectionListener(new SelectionAdapter() {

                        public void widgetSelected(SelectionEvent e) {
                            TreeItem newItem = new TreeItem(treeItem[0], 0);
                            newItem.setText(itemName);
                            TreeNodeData newNodeData = null;
                            newNodeData = new TreeNodeData();
                            Node parentNode = treeNodeData.getXMLNode();
                            newNodeData.setXMLNode(parentNode.appendChild(parentNode.getOwnerDocument().createElement(itemName)));
                            //$NON-NLS-1$
                            newNodeData.setTreePath(treeNodeData.getTreePath() + "/" + itemName);
                            newNodeData.setTreeNode(ATreeNodeUtil.getTreeNodeByPath(newNodeData.getTreePath()));
                            newItem.setData(newNodeData);
                        }
                    });
                }
            } else {
                itemNew.setEnabled(false);
            }
            availableXmlTree.setMenu(popMenu);
            if (nodeAttrCompsite != null) {
                nodeAttrCompsite.dispose();
            }
            rebuildAttrComposite(treeNodeData);
            setComponentMinSize(treeNodeData.getTreeNode().getLabel());
            rightComposite.layout();
        }
    });
}
Also used : TreeNodeData(org.talend.componentdesigner.ui.composite.xmltree.TreeNodeData) TreeItem(org.eclipse.swt.widgets.TreeItem) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Node(org.w3c.dom.Node) SelectionEvent(org.eclipse.swt.events.SelectionEvent) MenuItem(org.eclipse.swt.widgets.MenuItem) Menu(org.eclipse.swt.widgets.Menu)

Example 98 with SelectionAdapter

use of org.eclipse.swt.events.SelectionAdapter in project translationstudio8 by heartsome.

the class ConversionWizardPage method createConversionOptionsGroup.

/**
	 * 转换选项组
	 * @param contents
	 *            ;
	 */
private void createConversionOptionsGroup(Composite contents) {
    Group options = new Group(contents, SWT.NONE);
    //$NON-NLS-1$
    options.setText(Messages.getString("wizard.ConversionWizardPage.options"));
    options.setLayout(new GridLayout(1, false));
    options.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    /* 如果已经存在,是否要替换 */
    final Button btnReplaceTarget = new Button(options, SWT.CHECK);
    //$NON-NLS-1$
    btnReplaceTarget.setText(Messages.getString("wizard.ConversionWizardPage.btnReplaceTarget"));
    btnReplaceTarget.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    btnReplaceTarget.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            isReplaceTarget = btnReplaceTarget.getSelection();
            for (ConversionConfigBean conversionConfigBean : conversionConfigBeans) {
                conversionConfigBean.setReplaceTarget(btnReplaceTarget.getSelection());
            }
            validate();
        }
    });
    final Button btnOpenPreTrans = new Button(options, SWT.CHECK);
    btnOpenPreTrans.setText(Messages.getString("wizard.ConversionWizardPage.btnOpenPreTrans"));
    btnOpenPreTrans.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    btnOpenPreTrans.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            isOpenPreTrans = btnOpenPreTrans.getSelection();
        }
    });
    Composite composite = new Composite(options, SWT.NONE);
    GridLayout gd = new GridLayout(1, false);
    gd.marginWidth = 0;
    gd.marginHeight = 0;
    composite.setLayout(gd);
    composite.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
    Label tgtLangLbl = new Label(composite, SWT.NONE);
    tgtLangLbl.setText(Messages.getString("wizard.ConversionWizardPage.tgtLangLbl"));
    tgtLangViewer = new TableViewer(composite, SWT.BORDER | SWT.FULL_SELECTION | SWT.MULTI);
    Table tgtLangTable = tgtLangViewer.getTable();
    GridData gdTgtLangTable = new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1);
    gdTgtLangTable.heightHint = 80;
    tgtLangTable.setLayoutData(gdTgtLangTable);
    tgtLangViewer.setLabelProvider(new LanguageLabelProvider());
    tgtLangViewer.setContentProvider(new ArrayContentProvider());
    tgtLangViewer.setInput(conversionConfigBeans.get(0).getTgtLangList());
    tgtLangViewer.addSelectionChangedListener(new ISelectionChangedListener() {

        public void selectionChanged(SelectionChangedEvent event) {
            IStructuredSelection sel = (IStructuredSelection) event.getSelection();
            @SuppressWarnings("unchecked") List<Language> selectedList = sel.toList();
            for (ConversionConfigBean conversionConfigBean : conversionConfigBeans) {
                conversionConfigBean.setHasSelTgtLangList(selectedList);
            }
            validate();
        }
    });
    tgtLangViewer.getTable().select(0);
    IDialogSettings dialogSettings = Activator.getDefault().getDialogSettings();
    btnReplaceTarget.setSelection(dialogSettings.getBoolean(REPLACE_TARGET));
    btnOpenPreTrans.setSelection(dialogSettings.getBoolean(OPEN_PRE_TRANS));
    this.isOpenPreTrans = btnOpenPreTrans.getSelection();
    isReplaceTarget = btnReplaceTarget.getSelection();
    for (ConversionConfigBean conversionConfigBean : conversionConfigBeans) {
        conversionConfigBean.setReplaceTarget(isReplaceTarget);
    }
    validate();
}
Also used : Group(org.eclipse.swt.widgets.Group) Table(org.eclipse.swt.widgets.Table) Composite(org.eclipse.swt.widgets.Composite) LanguageLabelProvider(net.heartsome.cat.ts.ui.composite.LanguageLabelProvider) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) Label(org.eclipse.swt.widgets.Label) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) GridLayout(org.eclipse.swt.layout.GridLayout) Button(org.eclipse.swt.widgets.Button) ConversionConfigBean(net.heartsome.cat.convert.ui.model.ConversionConfigBean) IDialogSettings(org.eclipse.jface.dialogs.IDialogSettings) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) ArrayContentProvider(org.eclipse.jface.viewers.ArrayContentProvider) WritableList(org.eclipse.core.databinding.observable.list.WritableList) List(java.util.List) ArrayList(java.util.ArrayList) TableViewer(org.eclipse.jface.viewers.TableViewer)

Example 99 with SelectionAdapter

use of org.eclipse.swt.events.SelectionAdapter in project translationstudio8 by heartsome.

the class ReverseConversionWizardPage method createFilesGroup.

/**
	 * 创建文件列表区域
	 * @param contents
	 *            ;
	 */
private Composite createFilesGroup(Composite contents) {
    Composite filesComposite = new Composite(contents, SWT.NONE);
    filesComposite.setLayout(new GridLayout(1, false));
    filesComposite.setLayoutData(new GridData(GridData.FILL_BOTH));
    filesTable = new Table(filesComposite, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | SWT.MULTI | SWT.FULL_SELECTION);
    GridData tableData = new GridData(GridData.GRAB_HORIZONTAL | GridData.GRAB_VERTICAL | GridData.FILL_BOTH);
    tableData.heightHint = 100;
    filesTable.setLayoutData(tableData);
    filesTable.setLinesVisible(true);
    filesTable.setHeaderVisible(true);
    filesTable.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            TableItem[] selected = filesTable.getSelection();
            if (selected.length == 0) {
                return;
            }
            //$NON-NLS-1$
            String strTgtEnc = "";
            for (int i = 0; i < selected.length; i++) {
                String curTgtEnc = selected[i].getText(2);
                if (i == 0) {
                    strTgtEnc = curTgtEnc;
                } else {
                    if (!strTgtEnc.equals(curTgtEnc)) {
                        //$NON-NLS-1$
                        strTgtEnc = "";
                        break;
                    }
                }
            }
            if (!"".equals(strTgtEnc)) {
                //$NON-NLS-1$
                tgtEncCombo.setText(strTgtEnc);
            } else {
                tgtEncCombo.deselectAll();
            }
        }
    });
    tableViewer = new TableViewer(filesTable);
    lineNumberColumn = new TableViewerColumn(tableViewer, SWT.NONE).getColumn();
    lineNumberColumn.setText(Messages.getString("wizard.ReverseConversionWizardPage.lineNumberColumn"));
    xliffColumn = new TableViewerColumn(tableViewer, SWT.NONE).getColumn();
    //$NON-NLS-1$
    xliffColumn.setText(Messages.getString("wizard.ReverseConversionWizardPage.xliffColumn"));
    tgtEncColumn = new TableViewerColumn(tableViewer, SWT.NONE).getColumn();
    //$NON-NLS-1$
    tgtEncColumn.setText(Messages.getString("wizard.ReverseConversionWizardPage.tgtEncColumn"));
    targetColumn = new TableViewerColumn(tableViewer, SWT.NONE).getColumn();
    //$NON-NLS-1$
    targetColumn.setText(Messages.getString("wizard.ReverseConversionWizardPage.targetColumn"));
    IValueProperty[] valueProperties = BeanProperties.values(ConversionConfigBean.class, new String[] { "index", "source", "targetEncoding", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
    "target" });
    ViewerSupport.bind(tableViewer, new WritableList(conversionConfigBeans, ConversionConfigBean.class), valueProperties);
    filesComposite.addPaintListener(new PaintListener() {

        public void paintControl(PaintEvent arg0) {
            int width = filesTable.getClientArea().width;
            lineNumberColumn.setWidth(width * 1 / 10);
            targetColumn.setWidth(width * 4 / 10);
            tgtEncColumn.setWidth(width * 1 / 10);
            xliffColumn.setWidth(width * 4 / 10);
        }
    });
    return filesComposite;
}
Also used : Table(org.eclipse.swt.widgets.Table) PaintEvent(org.eclipse.swt.events.PaintEvent) Composite(org.eclipse.swt.widgets.Composite) PaintListener(org.eclipse.swt.events.PaintListener) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) GridLayout(org.eclipse.swt.layout.GridLayout) WritableList(org.eclipse.core.databinding.observable.list.WritableList) ConversionConfigBean(net.heartsome.cat.convert.ui.model.ConversionConfigBean) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) IValueProperty(org.eclipse.core.databinding.property.value.IValueProperty) TableViewer(org.eclipse.jface.viewers.TableViewer) TableViewerColumn(org.eclipse.jface.viewers.TableViewerColumn)

Example 100 with SelectionAdapter

use of org.eclipse.swt.events.SelectionAdapter in project ACS by ACS-Community.

the class TableViewBase method createPartControl.

@Override
public void createPartControl(Composite parent) {
    tableViewer = new TableViewer(parent, SWT.SINGLE | SWT.H_SCROLL | SWT.V_SCROLL);
    Table table = tableViewer.getTable();
    table.setLinesVisible(true);
    table.setHeaderVisible(true);
    // Set the column
    for (int t = 0; t < colNames.length; t++) {
        int style = t == 0 ? SWT.LEFT : SWT.CENTER;
        final TableViewerColumn viewerColumn = new TableViewerColumn(tableViewer, style);
        final TableColumn column = viewerColumn.getColumn();
        column.setText(colNames[t]);
        final int index = t;
        // Setting the right sorter
        column.addSelectionListener(new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent e) {
                sorter.setColumn(index);
                int dir = tableViewer.getTable().getSortDirection();
                if (tableViewer.getTable().getSortColumn() == column) {
                    dir = dir == SWT.UP ? SWT.DOWN : SWT.UP;
                } else {
                    dir = SWT.DOWN;
                }
                tableViewer.getTable().setSortDirection(dir);
                tableViewer.getTable().setSortColumn(column);
                tableViewer.refresh();
            }
        });
        column.pack();
        column.setWidth(colWidths[t]);
    }
    tableViewer.setContentProvider(new ViewContentProvider());
}
Also used : Table(org.eclipse.swt.widgets.Table) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) SelectionEvent(org.eclipse.swt.events.SelectionEvent) TableViewer(org.eclipse.jface.viewers.TableViewer) TableColumn(org.eclipse.swt.widgets.TableColumn) TableViewerColumn(org.eclipse.jface.viewers.TableViewerColumn)

Aggregations

SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)3041 SelectionEvent (org.eclipse.swt.events.SelectionEvent)3036 GridData (org.eclipse.swt.layout.GridData)1608 Button (org.eclipse.swt.widgets.Button)1600 Composite (org.eclipse.swt.widgets.Composite)1220 Label (org.eclipse.swt.widgets.Label)1106 GridLayout (org.eclipse.swt.layout.GridLayout)1095 Text (org.eclipse.swt.widgets.Text)773 ModifyListener (org.eclipse.swt.events.ModifyListener)638 ModifyEvent (org.eclipse.swt.events.ModifyEvent)630 Group (org.eclipse.swt.widgets.Group)459 FormAttachment (org.eclipse.swt.layout.FormAttachment)428 FormData (org.eclipse.swt.layout.FormData)428 Shell (org.eclipse.swt.widgets.Shell)407 FormLayout (org.eclipse.swt.layout.FormLayout)406 Event (org.eclipse.swt.widgets.Event)384 Listener (org.eclipse.swt.widgets.Listener)378 Display (org.eclipse.swt.widgets.Display)353 ShellEvent (org.eclipse.swt.events.ShellEvent)323 ShellAdapter (org.eclipse.swt.events.ShellAdapter)321