Search in sources :

Example 36 with SelectionChangedEvent

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

the class ProjectSettingTBPage method createContents.

/**
	 * Create contents of the preference page.
	 * @param parent
	 */
@Override
public Control createContents(Composite parent) {
    Composite container = new Composite(parent, SWT.NULL);
    container.setLayout(new GridLayout(1, false));
    tableViewer = new TableViewer(container, SWT.BORDER | SWT.FULL_SELECTION | SWT.SINGLE);
    Table table = tableViewer.getTable();
    table.setLinesVisible(true);
    table.setHeaderVisible(true);
    table.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
    tableViewer.setContentProvider(new ArrayContentProvider());
    createColumn(tableViewer);
    tableViewer.setInput(curDbList);
    tableViewer.addSelectionChangedListener(new ISelectionChangedListener() {

        public void selectionChanged(SelectionChangedEvent event) {
            IStructuredSelection selection = (IStructuredSelection) tableViewer.getSelection();
            DatabaseModelBean dbModel = (DatabaseModelBean) selection.getFirstElement();
            if (null == dbModel) {
                return;
            }
            if (Constants.DBTYPE_SQLITE.equals(dbModel.getDbType())) {
                String path = dbModel.getItlDBLocation() + File.separator + dbModel.getDbName();
                File file = new File(path);
                if (!file.exists()) {
                    setMessage(Messages.getString("projectsetting.ProjectSettingTBPage.FileNotFoundMsg"));
                    return;
                } else {
                    setMessage(Messages.getString("projectsetting.ProjectSettingTBPage.title"));
                }
            }
            if (dbModel != null && !dbModel.isHasMatch()) {
                setMessage(Messages.getString("projectsetting.ProjectSettingTBPage.msg1"));
            }
        }
    });
    Composite composite = new Composite(container, SWT.NONE);
    composite.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
    composite.setLayout(new GridLayout(5, false));
    new Label(composite, SWT.NONE);
    HSDropDownButton addBtn = new HSDropDownButton(composite, SWT.NONE);
    addBtn.setText(Messages.getString("projectsetting.ProjectSettingTBPage.addBtn"));
    Menu addMenu = addBtn.getMenu();
    MenuItem item = new MenuItem(addMenu, SWT.PUSH);
    item.setText(Messages.getString("tb.dialog.addTb.DropDownButton.AddFileTb"));
    item.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent e) {
            FileDialog fileDialg = new FileDialog(getShell());
            fileDialg.setFilterExtensions(new String[] { "*.hstb", "*.*" });
            String result = fileDialg.open();
            if (result == null) {
                return;
            }
            File f = new File(result);
            if (!f.exists()) {
                return;
            }
            Map<DatabaseModelBean, String> r = null;
            try {
                r = Utils.convertFile2TbModel(f, false);
            } catch (Exception e1) {
                MessageDialog.openError(getShell(), Messages.getString("tb.dialog.addFileTb.errorTitle"), e1.getMessage());
            }
            if (r == null) {
                return;
            }
            Iterator<DatabaseModelBean> it = r.keySet().iterator();
            if (it.hasNext()) {
                DatabaseModelBean selectedVal = it.next();
                List<DatabaseModelBean> dbList = new ArrayList<DatabaseModelBean>();
                dbList.add(selectedVal);
                addToCurrDbList(dbList);
            }
        }
    });
    MenuItem serverItem = new MenuItem(addMenu, SWT.PUSH);
    serverItem.setText(Messages.getString("tb.dialog.addTb.DropDownButton.AddServerTb"));
    serverItem.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent e) {
            TermDbManagerDialog dialog = new TermDbManagerDialog(getShell());
            dialog.setDialogUseFor(TermDbManagerDialog.TYPE_DBSELECTED);
            if (dialog.open() == Window.OK) {
                Iterator<DatabaseModelBean> it = dialog.getHasSelectedDatabase().keySet().iterator();
                List<DatabaseModelBean> dbList = new ArrayList<DatabaseModelBean>();
                while (it.hasNext()) {
                    dbList.add(it.next());
                }
                addToCurrDbList(dbList);
            }
        }
    });
    Button createBtn = new Button(composite, SWT.NONE);
    createBtn.setText(Messages.getString("projectsetting.ProjectSettingTBPage.createBtn"));
    createBtn.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent e) {
            NewTermDbWizard wizard = new NewTermDbWizard();
            TermDbManagerImportWizardDialog dlg = new TermDbManagerImportWizardDialog(getShell(), wizard);
            if (dlg.open() == 0) {
                DatabaseModelBean dbModel = wizard.getCreateDb();
                List<DatabaseModelBean> dbList = new ArrayList<DatabaseModelBean>();
                dbList.add(dbModel);
                addToCurrDbList(dbList);
            }
        }
    });
    Button removeBtn = new Button(composite, SWT.NONE);
    removeBtn.setText(Messages.getString("projectsetting.ProjectSettingTBPage.removeBtn"));
    removeBtn.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent e) {
            removeForCurrDbList((IStructuredSelection) tableViewer.getSelection());
        }
    });
    Button importTmxBtn = new Button(composite, SWT.NONE);
    importTmxBtn.setText(Messages.getString("projectsetting.ProjectSettingTBPage.importTmxBtn"));
    importTmxBtn.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent e) {
            IStructuredSelection selection = (IStructuredSelection) tableViewer.getSelection();
            Iterator<?> it = selection.iterator();
            if (it.hasNext()) {
                DatabaseModelBean dbModel = (DatabaseModelBean) it.next();
                TbxImportWizard wizard = new TbxImportWizard(dbModel);
                TermDbManagerImportWizardDialog dlg = new TermDbManagerImportWizardDialog(getShell(), wizard);
                if (dlg.open() == 0) {
                    checkDbHashMatch(dbModel);
                    tableViewer.refresh();
                }
                // 刷新项目
                ResourceUtils.refreshCurentSelectProject();
            } else {
                MessageDialog.openInformation(getShell(), Messages.getString("projectsetting.ProjectSettingTBPage.msgTitle"), Messages.getString("projectsetting.ProjectSettingTBPage.msg2"));
            }
        }
    });
    addBtn.setFocus();
    Point addPoint = addBtn.computeSize(SWT.DEFAULT, SWT.DEFAULT, true);
    Point createPoint = createBtn.computeSize(SWT.DEFAULT, SWT.DEFAULT, true);
    Point remPoint = removeBtn.computeSize(SWT.DEFAULT, SWT.DEFAULT, true);
    Point importPoint = importTmxBtn.computeSize(SWT.DEFAULT, SWT.DEFAULT, true);
    int width = Math.max(importPoint.x, Math.max(remPoint.x, Math.max(addPoint.x, createPoint.x)));
    GridData btnData = new GridData();
    btnData.widthHint = width + 10;
    addBtn.setLayoutData(btnData);
    createBtn.setLayoutData(btnData);
    removeBtn.setLayoutData(btnData);
    importTmxBtn.setLayoutData(btnData);
    return container;
}
Also used : DatabaseModelBean(net.heartsome.cat.common.bean.DatabaseModelBean) Label(org.eclipse.swt.widgets.Label) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) TbxImportWizard(net.heartsome.cat.database.ui.tb.wizard.TbxImportWizard) TermDbManagerDialog(net.heartsome.cat.database.ui.tb.dialog.TermDbManagerDialog) GridLayout(org.eclipse.swt.layout.GridLayout) HSDropDownButton(net.heartsome.cat.common.ui.HSDropDownButton) Button(org.eclipse.swt.widgets.Button) SelectionEvent(org.eclipse.swt.events.SelectionEvent) Iterator(java.util.Iterator) List(java.util.List) ArrayList(java.util.ArrayList) Menu(org.eclipse.swt.widgets.Menu) HSDropDownButton(net.heartsome.cat.common.ui.HSDropDownButton) Table(org.eclipse.swt.widgets.Table) Composite(org.eclipse.swt.widgets.Composite) TermDbManagerImportWizardDialog(net.heartsome.cat.database.ui.tb.wizard.TermDbManagerImportWizardDialog) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) MenuItem(org.eclipse.swt.widgets.MenuItem) Point(org.eclipse.swt.graphics.Point) SQLException(java.sql.SQLException) Point(org.eclipse.swt.graphics.Point) GridData(org.eclipse.swt.layout.GridData) ArrayContentProvider(org.eclipse.jface.viewers.ArrayContentProvider) TableViewer(org.eclipse.jface.viewers.TableViewer) File(java.io.File) FileDialog(org.eclipse.swt.widgets.FileDialog) Map(java.util.Map) NewTermDbWizard(net.heartsome.cat.database.ui.tb.wizard.NewTermDbWizard)

Example 37 with SelectionChangedEvent

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

the class ExportFilterComposite method createContent.

/** 创建控件 */
private void createContent() {
    setBackground(Display.getDefault().getSystemColor(SWT.COLOR_WHITE));
    GridLayout gridLayout = new GridLayout(5, false);
    gridLayout.horizontalSpacing = 2;
    gridLayout.marginWidth = 0;
    gridLayout.marginHeight = 0;
    setLayout(gridLayout);
    conditionComboViewer = new ComboViewer(this, SWT.NONE | SWT.READ_ONLY);
    Combo conditionCombo = conditionComboViewer.getCombo();
    GridData gdConditionCombo = new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1);
    gdConditionCombo.widthHint = 200;
    conditionCombo.setLayoutData(gdConditionCombo);
    conditionComboViewer.setContentProvider(new ArrayContentProvider());
    conditionComboViewer.setInput(filterNames);
    conditionComboViewer.addSelectionChangedListener(new ISelectionChangedListener() {

        public void selectionChanged(SelectionChangedEvent event) {
            IStructuredSelection sel = (IStructuredSelection) event.getSelection();
            if (sel.isEmpty()) {
                return;
            }
            baseDataBean.setOptionName((String) sel.getFirstElement());
            handlerFilterChangedEvent();
            opratorComboViewer.setInput(baseDataBean.getCurrentFilterExpressions());
            // 默认选中第一个
            opratorComboViewer.getCombo().select(0);
            baseDataBean.setCurrentExpression(opratorComboViewer.getCombo().getText());
        }
    });
    opratorComboViewer = new ComboViewer(this, SWT.NONE | SWT.READ_ONLY);
    Combo opratorCombo = opratorComboViewer.getCombo();
    GridData gd_opratorCombo = new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1);
    gd_opratorCombo.widthHint = 100;
    opratorCombo.setLayoutData(gd_opratorCombo);
    opratorComboViewer.setContentProvider(new ArrayContentProvider());
    opratorComboViewer.setInput(this.baseDataBean.getCurrentFilterExpressions());
    opratorComboViewer.addSelectionChangedListener(new ISelectionChangedListener() {

        public void selectionChanged(SelectionChangedEvent event) {
            IStructuredSelection sel = (IStructuredSelection) event.getSelection();
            if (sel.isEmpty()) {
                return;
            }
            baseDataBean.setCurrentExpression((String) sel.getFirstElement());
        }
    });
    dynaComposite = new Composite(this, SWT.NONE);
    dynaComposite.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
    GridLayout gldynaComposite = new GridLayout(1, false);
    gldynaComposite.marginWidth = 0;
    gldynaComposite.marginHeight = 0;
    dynaComposite.setLayout(gldynaComposite);
    valueText = new Text(dynaComposite, SWT.BORDER);
    valueText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
    addButton = new Button(this, SWT.NONE);
    GridData gdAddButton = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1);
    gdAddButton.widthHint = 25;
    addButton.setLayoutData(gdAddButton);
    addButton.setText("+");
    addButton.addListener(SWT.Selection, this);
    deleteButton = new Button(this, SWT.NONE);
    GridData gdDeletebutton = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1);
    gdDeletebutton.widthHint = 25;
    deleteButton.setLayoutData(gdDeletebutton);
    deleteButton.setText("-");
    deleteButton.addListener(SWT.Selection, this);
}
Also used : GridLayout(org.eclipse.swt.layout.GridLayout) Composite(org.eclipse.swt.widgets.Composite) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) ComboViewer(org.eclipse.jface.viewers.ComboViewer) Button(org.eclipse.swt.widgets.Button) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) GridData(org.eclipse.swt.layout.GridData) ArrayContentProvider(org.eclipse.jface.viewers.ArrayContentProvider) Combo(org.eclipse.swt.widgets.Combo) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) Text(org.eclipse.swt.widgets.Text) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection)

Example 38 with SelectionChangedEvent

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

the class WebSearchPreferencePage method installListeners.

private void installListeners() {
    checkboxTableViewer.addSelectionChangedListener(new ISelectionChangedListener() {

        @Override
        public void selectionChanged(SelectionChangedEvent event) {
            updateState();
        }
    });
    upItemBtn.addSelectionListener(new SelectionAdapter() {

        /**
			 * (non-Javadoc)
			 * @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent)
			 */
        @Override
        public void widgetSelected(SelectionEvent e) {
            upSelectItem();
        }
    });
    downItemBtn.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            downSelectItem();
        }
    });
    deleteItemBtn.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            deleteSelectItem();
        }
    });
    addItemBtn.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            addItem();
        }
    });
    editItemBtn.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            editItem();
        }
    });
    importItemsBtn.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            importConfig();
        }
    });
    exportItemsBtn.addSelectionListener(new SelectionAdapter() {

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

Example 39 with SelectionChangedEvent

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

the class TmDbManagerDialog method addListeners.

/**
	 * Add Selection Listener to tree viewer
	 * @param viewer
	 *            ;
	 */
private void addListeners(final TreeViewer viewer) {
    // 选择事件
    viewer.addPostSelectionChangedListener(new ISelectionChangedListener() {

        public void selectionChanged(SelectionChangedEvent event) {
            ISelection selection = event.getSelection();
            if (selection.isEmpty()) {
                return;
            }
            IStructuredSelection structuredSelection = (IStructuredSelection) selection;
            Object obj = structuredSelection.getFirstElement();
            if (obj instanceof DatabaseModelBean) {
                DatabaseModelBean bean = (DatabaseModelBean) obj;
                setCurrDbType(bean.getDbType());
                bean.copyToOtherIntance(currServer);
                SystemDBOperator dbop = getCurrSysDbOp();
                if (dbop != null) {
                    executeSearch(dbop);
                }
                // 当数据库类型发生改变时重新初始化界面
                initUI(false);
            } else if (obj instanceof String) {
                setCurrDbType((String) obj);
                resetInputValue();
                currServerdbListInput.clear();
                initUI(true);
            }
        }
    });
    // 双击展开事件
    ((Tree) viewer.getControl()).addSelectionListener(new SelectionAdapter() {

        public void widgetDefaultSelected(final SelectionEvent event) {
            ISelection selection = viewer.getSelection();
            if (selection.isEmpty()) {
                return;
            }
            IStructuredSelection structuredSelection = (IStructuredSelection) selection;
            Object obj = structuredSelection.getFirstElement();
            if (obj instanceof String) {
                String type = (String) obj;
                boolean expanded = viewer.getExpandedState(type);
                viewer.setExpandedState(type, !expanded);
            }
        }
    });
    // 右键菜单事件,判断何时出现右键菜单
    viewer.getControl().addMenuDetectListener(new MenuDetectListener() {

        public void menuDetected(MenuDetectEvent e) {
            ISelection selection = viewer.getSelection();
            if (selection.isEmpty()) {
                return;
            }
            IStructuredSelection structuredSelection = (IStructuredSelection) selection;
            Object obj = structuredSelection.getFirstElement();
            Tree tree = treeViewer.getTree();
            if (obj instanceof DatabaseModelBean) {
                // 将菜单挂到树上
                tree.setMenu(treePopMenu);
            } else {
                tree.setMenu(null);
            }
        }
    });
}
Also used : ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) DatabaseModelBean(net.heartsome.cat.common.bean.DatabaseModelBean) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) SystemDBOperator(net.heartsome.cat.database.SystemDBOperator) MenuDetectEvent(org.eclipse.swt.events.MenuDetectEvent) ISelection(org.eclipse.jface.viewers.ISelection) SelectionEvent(org.eclipse.swt.events.SelectionEvent) Tree(org.eclipse.swt.widgets.Tree) MenuDetectListener(org.eclipse.swt.events.MenuDetectListener)

Example 40 with SelectionChangedEvent

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

the class ProjectSettingTMPage method createContents.

/**
	 * Create contents of the preference page.
	 * @param parent
	 */
@Override
public Control createContents(Composite parent) {
    Composite container = new Composite(parent, SWT.NULL);
    container.setLayout(new GridLayout(1, false));
    tableViewer = new TableViewer(container, SWT.BORDER | SWT.FULL_SELECTION | SWT.SINGLE);
    Table table = tableViewer.getTable();
    table.setLinesVisible(true);
    table.setHeaderVisible(true);
    table.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
    tableViewer.setContentProvider(new ArrayContentProvider());
    createColumn(tableViewer);
    tableViewer.setInput(curDbList);
    tableViewer.addSelectionChangedListener(new ISelectionChangedListener() {

        public void selectionChanged(SelectionChangedEvent event) {
            IStructuredSelection selection = (IStructuredSelection) tableViewer.getSelection();
            DatabaseModelBean dbModel = (DatabaseModelBean) selection.getFirstElement();
            if (null == dbModel) {
                return;
            }
            if (Constants.DBTYPE_SQLITE.equals(dbModel.getDbType())) {
                String path = dbModel.getItlDBLocation() + File.separator + dbModel.getDbName();
                File file = new File(path);
                if (!file.exists()) {
                    setMessage(Messages.getString("projectsetting.ProjectSettingTMPage.FileNotFound"));
                    return;
                } else {
                    setMessage(Messages.getString("projectsetting.ProjectSettingTMPage.title"));
                }
            }
            if (dbModel != null && !dbModel.isHasMatch()) {
                setMessage(Messages.getString("projectsetting.ProjectSettingTMPage.msg1"));
            }
        }
    });
    Composite composite = new Composite(container, SWT.NONE);
    composite.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
    composite.setLayout(new GridLayout(5, false));
    new Label(composite, SWT.NONE);
    HSDropDownButton addBtn = new HSDropDownButton(composite, SWT.NONE);
    addBtn.setText(Messages.getString("projectsetting.ProjectSettingTMPage.addBtn"));
    Menu addMenu = addBtn.getMenu();
    MenuItem item = new MenuItem(addMenu, SWT.PUSH);
    item.setText(Messages.getString("tm.dialog.addTm.DropDownButton.AddFileTm"));
    item.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent e) {
            FileDialog fileDialg = new FileDialog(getShell());
            fileDialg.setFilterExtensions(new String[] { "*.hstm", "*.*" });
            String result = fileDialg.open();
            if (result == null) {
                return;
            }
            File f = new File(result);
            if (!f.exists()) {
                return;
            }
            Map<DatabaseModelBean, String> r = null;
            try {
                r = Utils.convertFile2TmModel(f, false);
            } catch (Exception e1) {
                MessageDialog.openError(getShell(), Messages.getString("tm.dialog.addFileTm.errorTitle"), e1.getMessage());
            }
            if (r == null) {
                return;
            }
            Iterator<DatabaseModelBean> it = r.keySet().iterator();
            if (it.hasNext()) {
                DatabaseModelBean selectedVal = it.next();
                List<DatabaseModelBean> dbList = new ArrayList<DatabaseModelBean>();
                dbList.add(selectedVal);
                addToCurrDbList(dbList);
            }
        }
    });
    MenuItem serverItem = new MenuItem(addMenu, SWT.PUSH);
    serverItem.setText(Messages.getString("tm.dialog.addTm.DropDownButton.AddServerTm"));
    serverItem.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent e) {
            TmDbManagerDialog dialog = new TmDbManagerDialog(getShell());
            dialog.setDialogUseFor(TmDbManagerDialog.TYPE_DBSELECTED);
            if (dialog.open() == Window.OK) {
                Iterator<DatabaseModelBean> it = dialog.getHasSelectedDatabase().keySet().iterator();
                List<DatabaseModelBean> dbList = new ArrayList<DatabaseModelBean>();
                while (it.hasNext()) {
                    dbList.add(it.next());
                }
                addToCurrDbList(dbList);
            }
        }
    });
    Button createBtn = new Button(composite, SWT.NONE);
    createBtn.setText(Messages.getString("projectsetting.ProjectSettingTMPage.createBtn"));
    createBtn.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent e) {
            NewTmDbWizard wizard = new NewTmDbWizard();
            ImportTmxWizardDialog dlg = new ImportTmxWizardDialog(getShell(), wizard);
            if (dlg.open() == 0) {
                DatabaseModelBean dbModel = wizard.getCreateDb();
                List<DatabaseModelBean> dbList = new ArrayList<DatabaseModelBean>();
                dbList.add(dbModel);
                addToCurrDbList(dbList);
            }
        }
    });
    Button removeBtn = new Button(composite, SWT.NONE);
    removeBtn.setText(Messages.getString("projectsetting.ProjectSettingTMPage.removeBtn"));
    removeBtn.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent e) {
            removeForCurrDbList((IStructuredSelection) tableViewer.getSelection());
        }
    });
    Button importTmxBtn = new Button(composite, SWT.NONE);
    importTmxBtn.setText(Messages.getString("projectsetting.ProjectSettingTMPage.importTmxBtn"));
    importTmxBtn.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent e) {
            IStructuredSelection selection = (IStructuredSelection) tableViewer.getSelection();
            Iterator<?> it = selection.iterator();
            if (it.hasNext()) {
                DatabaseModelBean dbModel = (DatabaseModelBean) it.next();
                ImportTmxWizard wizard = new ImportTmxWizard(dbModel);
                ImportTmxWizardDialog dlg = new ImportTmxWizardDialog(getShell(), wizard);
                if (dlg.open() == 0) {
                    checkDbHashMatch(dbModel);
                    tableViewer.refresh();
                }
                // 刷新项目
                ResourceUtils.refreshCurentSelectProject();
            } else {
                MessageDialog.openInformation(getShell(), Messages.getString("projectsetting.ProjectSettingTMPage.msgTitle"), Messages.getString("projectsetting.ProjectSettingTMPage.msg2"));
            }
        }
    });
    addBtn.setFocus();
    Point addPoint = addBtn.computeSize(SWT.DEFAULT, SWT.DEFAULT, true);
    Point createPoint = createBtn.computeSize(SWT.DEFAULT, SWT.DEFAULT, true);
    Point remPoint = removeBtn.computeSize(SWT.DEFAULT, SWT.DEFAULT, true);
    Point importPoint = importTmxBtn.computeSize(SWT.DEFAULT, SWT.DEFAULT, true);
    int width = Math.max(importPoint.x, Math.max(remPoint.x, Math.max(addPoint.x, createPoint.x)));
    GridData btnData = new GridData();
    btnData.widthHint = width + 10;
    addBtn.setLayoutData(btnData);
    createBtn.setLayoutData(btnData);
    removeBtn.setLayoutData(btnData);
    importTmxBtn.setLayoutData(btnData);
    return container;
}
Also used : DatabaseModelBean(net.heartsome.cat.common.bean.DatabaseModelBean) Label(org.eclipse.swt.widgets.Label) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) ImportTmxWizard(net.heartsome.cat.database.ui.tm.wizard.ImportTmxWizard) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) GridLayout(org.eclipse.swt.layout.GridLayout) HSDropDownButton(net.heartsome.cat.common.ui.HSDropDownButton) Button(org.eclipse.swt.widgets.Button) SelectionEvent(org.eclipse.swt.events.SelectionEvent) Iterator(java.util.Iterator) List(java.util.List) ArrayList(java.util.ArrayList) Menu(org.eclipse.swt.widgets.Menu) HSDropDownButton(net.heartsome.cat.common.ui.HSDropDownButton) Table(org.eclipse.swt.widgets.Table) TmDbManagerDialog(net.heartsome.cat.database.ui.tm.dialog.TmDbManagerDialog) Composite(org.eclipse.swt.widgets.Composite) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) MenuItem(org.eclipse.swt.widgets.MenuItem) Point(org.eclipse.swt.graphics.Point) SQLException(java.sql.SQLException) Point(org.eclipse.swt.graphics.Point) NewTmDbWizard(net.heartsome.cat.database.ui.tm.wizard.NewTmDbWizard) GridData(org.eclipse.swt.layout.GridData) ArrayContentProvider(org.eclipse.jface.viewers.ArrayContentProvider) ImportTmxWizardDialog(net.heartsome.cat.database.ui.tm.wizard.ImportTmxWizardDialog) TableViewer(org.eclipse.jface.viewers.TableViewer) File(java.io.File) FileDialog(org.eclipse.swt.widgets.FileDialog) Map(java.util.Map)

Aggregations

SelectionChangedEvent (org.eclipse.jface.viewers.SelectionChangedEvent)802 ISelectionChangedListener (org.eclipse.jface.viewers.ISelectionChangedListener)754 GridData (org.eclipse.swt.layout.GridData)417 Composite (org.eclipse.swt.widgets.Composite)332 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)303 GridLayout (org.eclipse.swt.layout.GridLayout)245 SelectionEvent (org.eclipse.swt.events.SelectionEvent)187 Label (org.eclipse.swt.widgets.Label)158 TableViewer (org.eclipse.jface.viewers.TableViewer)153 AdapterFactoryLabelProvider (org.eclipse.emf.edit.ui.provider.AdapterFactoryLabelProvider)147 ArrayContentProvider (org.eclipse.jface.viewers.ArrayContentProvider)140 Button (org.eclipse.swt.widgets.Button)140 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)126 IDoubleClickListener (org.eclipse.jface.viewers.IDoubleClickListener)121 DoubleClickEvent (org.eclipse.jface.viewers.DoubleClickEvent)120 IPropertiesEditionEvent (org.eclipse.emf.eef.runtime.api.notify.IPropertiesEditionEvent)116 PropertiesEditionEvent (org.eclipse.emf.eef.runtime.impl.notify.PropertiesEditionEvent)116 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)116 Table (org.eclipse.swt.widgets.Table)93 ISelection (org.eclipse.jface.viewers.ISelection)84