Search in sources :

Example 61 with SelectionEvent

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

the class XLIFFEditorImplWithNatTable method addFilterComposite.

/**
	 * 添加填充过滤器面板内容的面板
	 * @param parent
	 * @return 过滤器面板;
	 */
private void addFilterComposite(Composite main) {
    Composite top = new Composite(main, SWT.NONE);
    GridLayoutFactory.fillDefaults().numColumns(3).equalWidth(false).margins(0, 0).applyTo(top);
    top.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    // 输入行号进行定位
    final String rowLocationStr = Messages.getString("editor.XLIFFEditorImplWithNatTable.rowLocationStr");
    Text txtRowLocation = new Text(top, SWT.BORDER);
    txtRowLocation.setText(rowLocationStr);
    int width = 40;
    if (Util.isLinux()) {
        width = 35;
    }
    GridDataFactory.swtDefaults().hint(width, SWT.DEFAULT).applyTo(txtRowLocation);
    txtRowLocation.addFocusListener(new FocusAdapter() {

        @Override
        public void focusGained(FocusEvent e) {
            Text text = (Text) e.widget;
            if (rowLocationStr.equals(text.getText())) {
                text.setText("");
            }
        }

        @Override
        public void focusLost(FocusEvent e) {
            Text text = (Text) e.widget;
            if ("".equals(text.getText())) {
                text.setText(rowLocationStr);
            }
        }
    });
    txtRowLocation.addKeyListener(new KeyAdapter() {

        @Override
        public void keyPressed(KeyEvent event) {
            if (event.keyCode == SWT.CR || event.keyCode == SWT.KEYPAD_CR) {
                String rowNumString = ((Text) event.widget).getText().trim();
                if (rowNumString != null && !"".equals(rowNumString)) {
                    int rowPosition;
                    try {
                        rowPosition = Integer.parseInt(rowNumString) - 1;
                        jumpToRow(rowPosition, false);
                        updateStatusLine();
                    } catch (NumberFormatException e) {
                        Text text = (Text) event.widget;
                        text.setText("");
                    }
                }
            }
        }
    });
    txtRowLocation.addVerifyListener(new VerifyListener() {

        public void verifyText(VerifyEvent event) {
            if (event.keyCode == 0 && event.stateMask == 0) {
            // 文本框得到焦点时
            } else if (Character.isDigit(event.character) || event.character == '\b' || event.keyCode == 127) {
                // 输入数字,或者按下Backspace、Delete键
                if ("".equals(((Text) event.widget).getText().trim()) && event.character == '0') {
                    event.doit = false;
                } else {
                    event.doit = true;
                }
            } else {
                event.doit = false;
            }
        }
    });
    cmbFilter = new Combo(top, SWT.BORDER | SWT.READ_ONLY);
    cmbFilter.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    // TODO 完善过滤器初始化数据。
    // cmbFilter.add("所有文本段");
    // cmbFilter.add("未翻译文本段");
    // cmbFilter.add("已翻译文本段");
    // cmbFilter.add("未批准文本段");
    // cmbFilter.add("已批准文本段");
    // cmbFilter.add("有批注文本段");
    // cmbFilter.add("锁定文本段");
    // cmbFilter.add("未锁定文本段");
    // cmbFilter.add("重复文本段");
    // cmbFilter.add("疑问文本段");
    // cmbFilter.add("上下文匹配文本段");
    // cmbFilter.add("完全匹配文本段");
    // cmbFilter.add("模糊匹配文本段");
    // cmbFilter.add("快速翻译文本段");
    // cmbFilter.add("自动繁殖文本段");
    // cmbFilter.add("错误标记文本段");
    // cmbFilter.add("术语不一致文本段");
    // cmbFilter.add("译文不一致文本段");
    // cmbFilter.add("带修订标记文本段");
    final Set<String> filterNames = XLFHandler.getFilterNames();
    for (String filterName : filterNames) {
        cmbFilter.add(filterName);
    }
    // 添加选项改变监听
    cmbFilter.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            // Fixed Bug #2243 by Jason 当鼠标焦点在源文单元框中使用过滤器,对过滤后的译文进行操作会提示该行锁定不能操作
            // ActiveCellEditor.commit();
            HsMultiActiveCellEditor.commit(true);
            Combo cmbFilter = (Combo) e.widget;
            boolean isUpdated = handler.doFilter(cmbFilter.getText(), langFilterCondition);
            if (isUpdated) {
                if (table != null) {
                    bodyLayer.getSelectionLayer().clear();
                    if (bodyLayer.selectionLayer.getRowCount() > 0) {
                        // 默认选中第一行
                        HsMultiActiveCellEditor.commit(true);
                        bodyLayer.selectionLayer.doCommand(new SelectCellCommand(bodyLayer.getSelectionLayer(), getTgtColumnIndex(), isHorizontalLayout ? 0 : 1, false, false));
                        HsMultiCellEditorControl.activeSourceAndTargetCell(XLIFFEditorImplWithNatTable.this);
                    }
                    table.setFocus();
                }
                // 自动调整 NatTable 大小 ;
                autoResize();
                // 更新状态栏
                updateStatusLine();
                NattableUtil.refreshCommand(XLIFFEditorSelectionPropertyTester.PROPERTY_NAMESPACE, XLIFFEditorSelectionPropertyTester.PROPERTY_ENABLED);
            }
        }
    });
    Button btnSaveFilter = new Button(top, SWT.NONE);
    // TODO 考虑换成图片显示。
    btnSaveFilter.setText(Messages.getString("editor.XLIFFEditorImplWithNatTable.btnAddFilter"));
    btnSaveFilter.setToolTipText(Messages.getString("editor.XLIFFEditorImplWithNatTable.btnAddFilterTooltip"));
    btnSaveFilter.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            CustomFilterDialog dialog = new CustomFilterDialog(table.getShell(), cmbFilter);
            dialog.open();
        // int res = dialog.open();
        // if (res == CustomFilterDialog.OK) {
        // cmbFilter.select(cmbFilter.getItemCount() - 1); // 选中最后一行数据
        // cmbFilter.notifyListeners(SWT.Selection, null);
        // }
        }
    });
    // 默认选中第一行数据
    cmbFilter.select(0);
    cmbFilter.notifyListeners(SWT.Selection, null);
    // 更新nattable的列名为语言对
    renameColumn();
    top.pack();
}
Also used : FocusAdapter(org.eclipse.swt.events.FocusAdapter) VerifyListener(org.eclipse.swt.events.VerifyListener) CustomFilterDialog(net.heartsome.cat.ts.ui.xliffeditor.nattable.dialog.CustomFilterDialog) Composite(org.eclipse.swt.widgets.Composite) SelectCellCommand(net.sourceforge.nattable.selection.command.SelectCellCommand) KeyAdapter(org.eclipse.swt.events.KeyAdapter) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) StyledText(org.eclipse.swt.custom.StyledText) Text(org.eclipse.swt.widgets.Text) Combo(org.eclipse.swt.widgets.Combo) FocusEvent(org.eclipse.swt.events.FocusEvent) Point(org.eclipse.swt.graphics.Point) KeyEvent(org.eclipse.swt.events.KeyEvent) Button(org.eclipse.swt.widgets.Button) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) VerifyEvent(org.eclipse.swt.events.VerifyEvent)

Example 62 with SelectionEvent

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

the class LanguageCodesPreferencePage method addListener.

// 对需要添加监听的控件添加相应的监听器
private void addListener() {
    // 添加语言列表选择事件监听
    fFilteredTree.getViewer().addSelectionChangedListener(new ISelectionChangedListener() {

        public void selectionChanged(SelectionChangedEvent event) {
            ISelection selection = event.getSelection();
            if (selection.isEmpty()) {
                return;
            }
        // 暂时注释
        // if (selection instanceof IStructuredSelection) {
        // refreshFormatControls((IStructuredSelection) selection);
        // }
        }
    });
    // 注册添加按钮的选择监听器
    addBtn.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            addLanguage();
        }
    });
    // 注册编辑按钮的选择监听器
    editBtn.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            verifyCurrentSelected(EDIT);
        }
    });
    // 注册删除按钮的选择监听器
    removeBtn.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            verifyCurrentSelected(REMOVE);
        }
    });
}
Also used : ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) ISelection(org.eclipse.jface.viewers.ISelection) SelectionEvent(org.eclipse.swt.events.SelectionEvent) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent)

Example 63 with SelectionEvent

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

the class NewProjectWizardDialog method createButtonsForButtonBar.

@Override
protected void createButtonsForButtonBar(Composite parent) {
    btnSetting = createButton(parent, -1, Messages.getString("wizards.NewProjectWizardDialog.btnSetting"), true);
    super.createButtonsForButtonBar(parent);
    getButton(-1).addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent e) {
            PreferenceUtil.openPreferenceDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow(), ProjectPropertiesPreferencePage.ID);
            if (getCurrentPage() instanceof NewProjectWizardProjInfoPage) {
                NewProjectWizardProjInfoPage page = (NewProjectWizardProjInfoPage) getCurrentPage();
                page.reload();
            }
        }
    });
}
Also used : SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) SelectionEvent(org.eclipse.swt.events.SelectionEvent)

Example 64 with SelectionEvent

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

the class NewProjectWizardSourceFilePage method createControl.

/**
	 * Create contents of the wizard.
	 * @param parent
	 */
public void createControl(Composite parent) {
    Composite container = new Composite(parent, SWT.NULL);
    container.setLayout(new GridLayout(1, false));
    setControl(container);
    fileListViewer = new ListViewer(container, SWT.BORDER | SWT.V_SCROLL | SWT.MULTI);
    fileListViewer.getList().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
    fileListViewer.setContentProvider(new ArrayContentProvider());
    fileListViewer.setInput(srcFileList);
    if (this.converterCaller != null) {
        final Button btnConvert = new Button(container, SWT.CHECK);
        btnConvert.setText(Messages.getString("wizard.NewProjectWizardSourceFilePage.btnConvert"));
        btnConvert.setSelection(true);
        isOpenConverter = true;
        btnConvert.addSelectionListener(new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent e) {
                isOpenConverter = btnConvert.getSelection();
            }
        });
    }
    Composite composite = new Composite(container, SWT.NONE);
    composite.setLayout(new GridLayout(2, false));
    composite.setLayoutData(new GridData(SWT.RIGHT, SWT.FILL, false, false, 1, 1));
    Button addBtn = new Button(composite, SWT.NONE);
    addBtn.setText(Messages.getString("wizard.NewProjectWizardSourceFilePage.addBtn"));
    addBtn.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent e) {
            FileDialog dlg = new FileDialog(getShell(), SWT.MULTI);
            // CONVERTEREXTENTION
            String[] supExtentions = new String[] { "*.mif;*.idml;*.inx;*.xlf;*.rtf;*.po;*.properties;*.js;*.mqxlz;*.doc;*.xls;*.ppt;" + "*.docx;*.xlsx;*.pptx;*.odt;*.ods;*.odp;*.odg;*.rtf;*.sdlxliff;*.ttx;*.htm;*.html;*.txt;*.resx;*.rc;*.xml;*.txml", "*.*" };
            dlg.setFilterExtensions(supExtentions);
            if (dlg.open() != null) {
                String[] files = dlg.getFileNames();
                for (int i = 0; i < files.length; i++) {
                    StringBuffer buf = new StringBuffer(dlg.getFilterPath());
                    buf.append(File.separator);
                    buf.append(files[i]);
                    String file = buf.toString();
                    if (!srcFileList.contains(file)) {
                        srcFileList.add(file);
                    }
                }
                fileListViewer.refresh();
            }
        }
    });
    Button deleteBtn = new Button(composite, SWT.NONE);
    deleteBtn.setText(Messages.getString("wizard.NewProjectWizardSourceFilePage.deleteBtn"));
    deleteBtn.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent e) {
            IStructuredSelection selections = (IStructuredSelection) fileListViewer.getSelection();
            Iterator<?> it = selections.iterator();
            while (it.hasNext()) {
                String file = (String) it.next();
                srcFileList.remove(file);
            }
            fileListViewer.refresh();
        }
    });
}
Also used : ListViewer(org.eclipse.jface.viewers.ListViewer) Composite(org.eclipse.swt.widgets.Composite) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) GridLayout(org.eclipse.swt.layout.GridLayout) Button(org.eclipse.swt.widgets.Button) GridData(org.eclipse.swt.layout.GridData) ArrayContentProvider(org.eclipse.jface.viewers.ArrayContentProvider) SelectionEvent(org.eclipse.swt.events.SelectionEvent) Iterator(java.util.Iterator) FileDialog(org.eclipse.swt.widgets.FileDialog)

Example 65 with SelectionEvent

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

the class ProjectPropertiesPreferencePage method initListener.

private void initListener() {
    btnFieldAdd.addSelectionListener(new SelectionListener() {

        public void widgetSelected(SelectionEvent e) {
            String[] arrField = fieldList.getItems();
            InputDialog dialog = new InputDialog(getShell(), Messages.getString("preferencepage.ProjectPropertiesPreferencePage.AddDialog.title1"), Messages.getString("preferencepage.ProjectPropertiesPreferencePage.AddDialog.lbl1"), null, new InputValidator(FIELD_ADD, new ArrayList<String>(Arrays.asList(arrField))));
            if (dialog.open() == IDialogConstants.OK_ID) {
                String fieldVal = dialog.getValue();
                fieldList.add(fieldVal.trim());
            }
        }

        public void widgetDefaultSelected(SelectionEvent e) {
        }
    });
    btnFieldEdit.addSelectionListener(new SelectionListener() {

        public void widgetSelected(SelectionEvent e) {
            if (fieldList.getSelectionCount() <= 0) {
                MessageDialog.openInformation(getShell(), Messages.getString("preferencepage.ProjectPropertiesPreferencePage.msgTitle2"), Messages.getString("preferencepage.ProjectPropertiesPreferencePage.msg10"));
                return;
            } else if (fieldList.getSelectionCount() > 1) {
                MessageDialog.openInformation(getShell(), Messages.getString("preferencepage.ProjectPropertiesPreferencePage.msgTitle2"), Messages.getString("preferencepage.ProjectPropertiesPreferencePage.msg11"));
                return;
            } else {
                int selIndex = fieldList.getSelectionIndex();
                String selVal = fieldList.getSelection()[0];
                ArrayList<String> lstField = new ArrayList<String>(Arrays.asList(fieldList.getItems()));
                lstField.remove(selVal);
                InputDialog dialog = new InputDialog(getShell(), Messages.getString("preferencepage.ProjectPropertiesPreferencePage.AddDialog.title4"), Messages.getString("preferencepage.ProjectPropertiesPreferencePage.AddDialog.lbl1"), selVal, new InputValidator(FIELD_ADD, lstField));
                if (dialog.open() == IDialogConstants.OK_ID) {
                    String fieldVal = dialog.getValue().trim();
                    fieldList.remove(selIndex);
                    fieldList.add(fieldVal, selIndex);
                    fieldList.select(selIndex);
                }
            }
        }

        public void widgetDefaultSelected(SelectionEvent e) {
        }
    });
    btnFieldDel.addSelectionListener(new SelectionListener() {

        public void widgetSelected(SelectionEvent e) {
            if (fieldList.getSelectionCount() == 0) {
                MessageDialog.openInformation(getShell(), Messages.getString("preferencepage.ProjectPropertiesPreferencePage.msgTitle2"), Messages.getString("preferencepage.ProjectPropertiesPreferencePage.msg8"));
                return;
            }
            if (MessageDialog.openConfirm(getShell(), Messages.getString("preferencepage.ProjectPropertiesPreferencePage.msgTitle1"), Messages.getString("preferencepage.ProjectPropertiesPreferencePage.msg1"))) {
                fieldList.remove(fieldList.getSelectionIndices());
            }
        }

        public void widgetDefaultSelected(SelectionEvent e) {
        }
    });
    attrNameList.addSelectionListener(new SelectionListener() {

        public void widgetSelected(SelectionEvent e) {
            if (attrNameList.getSelectionCount() > 0) {
                String strSel = attrNameList.getSelection()[0];
                ArrayList<String> lstAttrVal = mapAttr.get(strSel);
                attrValList.removeAll();
                attrValList.setItems(lstAttrVal.toArray(new String[lstAttrVal.size()]));
            }
        }

        public void widgetDefaultSelected(SelectionEvent e) {
        }
    });
    btnAttrNameAdd.addSelectionListener(new SelectionListener() {

        public void widgetSelected(SelectionEvent e) {
            String[] arrAttrName = attrNameList.getItems();
            InputDialog dialog = new InputDialog(getShell(), Messages.getString("preferencepage.ProjectPropertiesPreferencePage.AddDialog.title2"), Messages.getString("preferencepage.ProjectPropertiesPreferencePage.AddDialog.lbl2"), null, new InputValidator(ATTRNAME_ADD, new ArrayList<String>(Arrays.asList(arrAttrName))));
            if (dialog.open() == IDialogConstants.OK_ID) {
                String attrName = dialog.getValue().trim();
                attrNameList.add(attrName);
                mapAttr.put(attrName, new ArrayList<String>());
                attrNameList.setSelection(new String[] { attrName });
                attrValList.removeAll();
            }
        }

        public void widgetDefaultSelected(SelectionEvent e) {
        }
    });
    btnAttrNameEdit.addSelectionListener(new SelectionListener() {

        public void widgetSelected(SelectionEvent e) {
            if (attrNameList.getSelectionCount() <= 0) {
                MessageDialog.openInformation(getShell(), Messages.getString("preferencepage.ProjectPropertiesPreferencePage.msgTitle2"), Messages.getString("preferencepage.ProjectPropertiesPreferencePage.msg10"));
                return;
            } else if (attrNameList.getSelectionCount() > 1) {
                MessageDialog.openInformation(getShell(), Messages.getString("preferencepage.ProjectPropertiesPreferencePage.msgTitle2"), Messages.getString("preferencepage.ProjectPropertiesPreferencePage.msg11"));
                return;
            } else {
                int selIndex = attrNameList.getSelectionIndex();
                String selVal = attrNameList.getSelection()[0];
                ArrayList<String> lstAttrVal = mapAttr.get(selVal);
                ArrayList<String> lstAttrName = new ArrayList<String>(Arrays.asList(attrNameList.getItems()));
                lstAttrName.remove(selVal);
                InputDialog dialog = new InputDialog(getShell(), Messages.getString("preferencepage.ProjectPropertiesPreferencePage.AddDialog.title5"), Messages.getString("preferencepage.ProjectPropertiesPreferencePage.AddDialog.lbl2"), selVal, new InputValidator(ATTRNAME_ADD, lstAttrName));
                if (dialog.open() == IDialogConstants.OK_ID) {
                    String attrNameVal = dialog.getValue().trim();
                    attrNameList.remove(selIndex);
                    attrNameList.add(attrNameVal, selIndex);
                    attrNameList.select(selIndex);
                    mapAttr.remove(selVal);
                    mapAttr.put(attrNameVal, lstAttrVal);
                }
            }
        }

        public void widgetDefaultSelected(SelectionEvent e) {
        }
    });
    btnAttrNameDel.addSelectionListener(new SelectionListener() {

        public void widgetSelected(SelectionEvent e) {
            if (attrNameList.getSelectionCount() == 0) {
                MessageDialog.openInformation(getShell(), Messages.getString("preferencepage.ProjectPropertiesPreferencePage.msgTitle2"), Messages.getString("preferencepage.ProjectPropertiesPreferencePage.msg8"));
                return;
            }
            if (MessageDialog.openConfirm(getShell(), Messages.getString("preferencepage.ProjectPropertiesPreferencePage.msgTitle1"), Messages.getString("preferencepage.ProjectPropertiesPreferencePage.msg1"))) {
                String[] arrSelName = attrNameList.getSelection();
                for (String attrName : arrSelName) {
                    mapAttr.remove(attrName);
                }
                attrNameList.remove(attrNameList.getSelectionIndices());
                if (attrNameList.getSelectionCount() > 0) {
                    String strSel = attrNameList.getSelection()[0];
                    ArrayList<String> lstAttrVal = mapAttr.get(strSel);
                    attrValList.removeAll();
                    attrValList.setItems(lstAttrVal.toArray(new String[lstAttrVal.size()]));
                } else {
                    attrValList.removeAll();
                }
            }
        }

        public void widgetDefaultSelected(SelectionEvent e) {
        }
    });
    btnAttrValAdd.addSelectionListener(new SelectionListener() {

        public void widgetSelected(SelectionEvent e) {
            if (attrNameList.getSelectionCount() != 1) {
                MessageDialog.openInformation(getShell(), Messages.getString("preferencepage.ProjectPropertiesPreferencePage.msgTitle2"), Messages.getString("preferencepage.ProjectPropertiesPreferencePage.msg9"));
                return;
            }
            String[] arrAttrVal = attrValList.getItems();
            InputDialog dialog = new InputDialog(getShell(), Messages.getString("preferencepage.ProjectPropertiesPreferencePage.AddDialog.title3"), Messages.getString("preferencepage.ProjectPropertiesPreferencePage.AddDialog.lbl3"), null, new InputValidator(ATTRVAL_ADD, new ArrayList<String>(Arrays.asList(arrAttrVal))));
            if (dialog.open() == IDialogConstants.OK_ID) {
                String attrVal = dialog.getValue().trim();
                attrValList.add(attrVal);
                String attrName = attrNameList.getSelection()[0];
                mapAttr.get(attrName).add(attrVal);
            }
        }

        public void widgetDefaultSelected(SelectionEvent e) {
        }
    });
    btnAttrValEdit.addSelectionListener(new SelectionListener() {

        public void widgetSelected(SelectionEvent e) {
            if (attrValList.getSelectionCount() <= 0) {
                MessageDialog.openInformation(getShell(), Messages.getString("preferencepage.ProjectPropertiesPreferencePage.msgTitle2"), Messages.getString("preferencepage.ProjectPropertiesPreferencePage.msg10"));
                return;
            } else if (attrValList.getSelectionCount() > 1) {
                MessageDialog.openInformation(getShell(), Messages.getString("preferencepage.ProjectPropertiesPreferencePage.msgTitle2"), Messages.getString("preferencepage.ProjectPropertiesPreferencePage.msg11"));
                return;
            } else {
                int selIndex = attrValList.getSelectionIndex();
                String selVal = attrValList.getSelection()[0];
                String attrName = attrNameList.getSelection()[0];
                ArrayList<String> lstAttrVal = new ArrayList<String>(Arrays.asList(attrValList.getItems()));
                lstAttrVal.remove(selVal);
                InputDialog dialog = new InputDialog(getShell(), Messages.getString("preferencepage.ProjectPropertiesPreferencePage.AddDialog.title6"), Messages.getString("preferencepage.ProjectPropertiesPreferencePage.AddDialog.lbl3"), selVal, new InputValidator(ATTRVAL_ADD, lstAttrVal));
                if (dialog.open() == IDialogConstants.OK_ID) {
                    String attrVal = dialog.getValue().trim();
                    attrValList.remove(selIndex);
                    attrValList.add(attrVal, selIndex);
                    attrValList.select(selIndex);
                    lstAttrVal = mapAttr.get(attrName);
                    lstAttrVal.set(selIndex, attrVal);
                }
            }
        }

        public void widgetDefaultSelected(SelectionEvent e) {
        }
    });
    btnAttrValDel.addSelectionListener(new SelectionListener() {

        public void widgetSelected(SelectionEvent e) {
            if (attrNameList.getSelectionCount() != 1) {
                MessageDialog.openInformation(getShell(), Messages.getString("preferencepage.ProjectPropertiesPreferencePage.msgTitle2"), Messages.getString("preferencepage.ProjectPropertiesPreferencePage.msg9"));
                return;
            }
            if (attrValList.getSelectionCount() == 0) {
                MessageDialog.openInformation(getShell(), Messages.getString("preferencepage.ProjectPropertiesPreferencePage.msgTitle2"), Messages.getString("preferencepage.ProjectPropertiesPreferencePage.msg8"));
                return;
            }
            if (MessageDialog.openConfirm(getShell(), Messages.getString("preferencepage.ProjectPropertiesPreferencePage.msgTitle1"), Messages.getString("preferencepage.ProjectPropertiesPreferencePage.msg1"))) {
                String attrName = attrNameList.getSelection()[0];
                String[] arrSelVal = attrValList.getSelection();
                mapAttr.get(attrName).removeAll(new ArrayList<String>(Arrays.asList(arrSelVal)));
                attrValList.remove(attrValList.getSelectionIndices());
            }
        }

        public void widgetDefaultSelected(SelectionEvent e) {
        }
    });
}
Also used : InputDialog(net.heartsome.cat.ts.ui.dialog.InputDialog) IInputValidator(org.eclipse.jface.dialogs.IInputValidator) SelectionEvent(org.eclipse.swt.events.SelectionEvent) ArrayList(java.util.ArrayList) Point(org.eclipse.swt.graphics.Point) SelectionListener(org.eclipse.swt.events.SelectionListener)

Aggregations

SelectionEvent (org.eclipse.swt.events.SelectionEvent)1136 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)923 GridData (org.eclipse.swt.layout.GridData)670 GridLayout (org.eclipse.swt.layout.GridLayout)566 Button (org.eclipse.swt.widgets.Button)558 Composite (org.eclipse.swt.widgets.Composite)553 Label (org.eclipse.swt.widgets.Label)370 SelectionListener (org.eclipse.swt.events.SelectionListener)262 Text (org.eclipse.swt.widgets.Text)253 Group (org.eclipse.swt.widgets.Group)193 ModifyEvent (org.eclipse.swt.events.ModifyEvent)160 ModifyListener (org.eclipse.swt.events.ModifyListener)159 Combo (org.eclipse.swt.widgets.Combo)140 Point (org.eclipse.swt.graphics.Point)98 MenuItem (org.eclipse.swt.widgets.MenuItem)95 Menu (org.eclipse.swt.widgets.Menu)94 TableViewer (org.eclipse.jface.viewers.TableViewer)91 Table (org.eclipse.swt.widgets.Table)91 ToolItem (org.eclipse.swt.widgets.ToolItem)90 ArrayList (java.util.ArrayList)88