Search in sources :

Example 56 with ArrayContentProvider

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

the class NewProjectTmPage 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));
    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 (dbModel != null && !dbModel.isHasMatch()) {
                setMessage(Messages.getString("newproject.NewProjectTmPage.msg1"));
            } else {
                setMessage(null);
            }
        }
    });
    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("newproject.NewProjectTmPage.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>(1);
                dbList.add(dbModel);
                addToCurrDbList(dbList);
            }
        }
    });
    Button removeBtn = new Button(composite, SWT.NONE);
    removeBtn.setText(Messages.getString("newproject.NewProjectTmPage.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("newproject.NewProjectTmPage.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, "M");
                    tableViewer.refresh();
                }
            } else {
                MessageDialog.openInformation(getShell(), Messages.getString("newproject.NewProjectTmPage.msgTitle"), Messages.getString("newproject.NewProjectTmPage.msg3"));
            }
        }
    });
    addBtn.setFocus();
    setControl(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) ArrayList(java.util.ArrayList) List(java.util.List) 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) SQLException(java.sql.SQLException) 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) FileDialog(org.eclipse.swt.widgets.FileDialog) File(java.io.File) Map(java.util.Map)

Example 57 with ArrayContentProvider

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

the class UpdateTMWizardPage method createContent.

public void createContent(Composite parent) {
    TableViewer tableViewer = new TableViewer(parent, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION);
    final Table table = tableViewer.getTable();
    GridData tableData = new GridData(GridData.GRAB_HORIZONTAL | GridData.GRAB_VERTICAL | GridData.FILL_BOTH);
    tableData.heightHint = 160;
    table.setLayoutData(tableData);
    table.setLinesVisible(true);
    table.setHeaderVisible(true);
    TableColumn columnNumber = new TableColumn(table, SWT.LEFT);
    columnNumber.setText(Messages.getString("wizard.UpdateTMWizardPage.columnNumber"));
    columnNumber.setWidth(50);
    TableColumn columnPath = new TableColumn(table, SWT.LEFT);
    columnPath.setText(Messages.getString("wizard.UpdateTMWizardPage.columnPath"));
    columnPath.setWidth(400);
    tableViewer.setLabelProvider(new TableViewerLabelProvider());
    tableViewer.setContentProvider(new ArrayContentProvider());
    tableViewer.setInput(getTableInfo());
    Group groupStatus = new Group(parent, SWT.None);
    groupStatus.setLayout(new GridLayout());
    groupStatus.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    groupStatus.setText(Messages.getString("dialog.UpdateTMDialog.lbl"));
    btnDraft = new Button(groupStatus, SWT.CHECK);
    btnDraft.setText(Messages.getString("dialog.UpdateTMDialog.btnDraft"));
    btnTranslated = new Button(groupStatus, SWT.CHECK);
    btnTranslated.setText(Messages.getString("dialog.UpdateTMDialog.btnTranslated"));
    btnTranslated.setSelection(true);
    btnApproved = new Button(groupStatus, SWT.CHECK);
    btnApproved.setText(Messages.getString("dialog.UpdateTMDialog.btnApproved"));
    btnApproved.setSelection(true);
    btnSignedOff = new Button(groupStatus, SWT.CHECK);
    btnSignedOff.setText(Messages.getString("dialog.UpdateTMDialog.btnSignedOff"));
    btnSignedOff.setSelection(true);
    btnLocked = new Button(groupStatus, SWT.CHECK);
    btnLocked.setText(Messages.getString("dialog.UpdateTMWizardPage.btnLocked"));
}
Also used : Group(org.eclipse.swt.widgets.Group) GridLayout(org.eclipse.swt.layout.GridLayout) Table(org.eclipse.swt.widgets.Table) Button(org.eclipse.swt.widgets.Button) GridData(org.eclipse.swt.layout.GridData) ArrayContentProvider(org.eclipse.jface.viewers.ArrayContentProvider) TableViewer(org.eclipse.jface.viewers.TableViewer) TableColumn(org.eclipse.swt.widgets.TableColumn)

Example 58 with ArrayContentProvider

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

the class PreMachineTranslationResultDialog method createDialogArea.

/**
	 * Create contents of the dialog.
	 * @param parent
	 */
@Override
protected Control createDialogArea(Composite parent) {
    Composite container = (Composite) super.createDialogArea(parent);
    container.setLayout(new GridLayout(1, false));
    Composite composite = new Composite(container, SWT.NONE);
    GridLayout gl_composite = new GridLayout(1, false);
    gl_composite.verticalSpacing = 0;
    gl_composite.marginWidth = 0;
    gl_composite.marginHeight = 0;
    composite.setLayout(gl_composite);
    composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
    tableViewer = new TableViewer(composite, SWT.BORDER | SWT.FULL_SELECTION | SWT.V_SCROLL | SWT.H_SCROLL);
    Table table = tableViewer.getTable();
    GridData tableGd = new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1);
    tableGd.heightHint = 220;
    table.setLayoutData(tableGd);
    table.setLinesVisible(true);
    table.setHeaderVisible(true);
    String[] clmnTitles = new String[] { Messages.getString("dialog.PreTranslationResultDialog.clmnTitles1"), Messages.getString("dialog.PreTranslationResultDialog.clmnTitles2"), Messages.getString("dialog.PreTranslationResultDialog.clmnTitles3"), Messages.getString("dialog.PreTranslationResultDialog.clmnTitles4"), Messages.getString("dialog.PreTranslationResultDialog.clmnTitles5"), Messages.getString("dialog.PreTranslationResultDialog.clmnTitles6") };
    int[] clmnBounds = { 60, 200, 100, 110, 110, 110 };
    for (int i = 0; i < clmnTitles.length; i++) {
        createTableViewerColumn(tableViewer, clmnTitles[i], clmnBounds[i], i);
    }
    tableViewer.setLabelProvider(new TableViewerLabelProvider());
    tableViewer.setContentProvider(new ArrayContentProvider());
    tableViewer.setInput(this.getTableViewerInput());
    return container;
}
Also used : GridLayout(org.eclipse.swt.layout.GridLayout) Table(org.eclipse.swt.widgets.Table) Composite(org.eclipse.swt.widgets.Composite) GridData(org.eclipse.swt.layout.GridData) ArrayContentProvider(org.eclipse.jface.viewers.ArrayContentProvider) TableViewer(org.eclipse.jface.viewers.TableViewer) Point(org.eclipse.swt.graphics.Point)

Example 59 with ArrayContentProvider

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

the class SplitXliffWizardPage method createSplitInfo.

/**
	 * 创建分割文件段的相关信息
	 * @param tparent
	 */
public void createSplitInfo(Composite tparent) {
    tableViewer = new TableViewer(tparent, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | SWT.MULTI | SWT.FULL_SELECTION);
    final Table table = tableViewer.getTable();
    GridData tableData = new GridData(GridData.GRAB_HORIZONTAL | GridData.GRAB_VERTICAL | GridData.FILL_BOTH);
    tableData.heightHint = 50;
    table.setLayoutData(tableData);
    table.setLinesVisible(true);
    table.setHeaderVisible(true);
    String[] columnNames = new String[] { Messages.getString("wizard.SplitXliffWizardPage.columnNames1"), Messages.getString("wizard.SplitXliffWizardPage.columnNames2"), Messages.getString("wizard.SplitXliffWizardPage.columnNames3") };
    int[] columnAlignments = new int[] { SWT.LEFT, SWT.LEFT, SWT.LEFT };
    for (int i = 0; i < columnNames.length; i++) {
        TableColumn tableColumn = new TableColumn(table, columnAlignments[i]);
        tableColumn.setText(columnNames[i]);
    }
    tableViewer.setLabelProvider(new TableViewerLabelProvider());
    tableViewer.setContentProvider(new ArrayContentProvider());
    tableViewer.setInput(splitXliff.getSplitTableInfos());
    // 让列表列宽动态变化
    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.5, 0.29 };
                    for (int i = 0; i < columns.length; i++) columns[i].setWidth((int) (table.getBounds().width * columnWidths[i]));
                }
            });
        }
    });
}
Also used : Table(org.eclipse.swt.widgets.Table) Listener(org.eclipse.swt.widgets.Listener) TableColumn(org.eclipse.swt.widgets.TableColumn) TableViewerLabelProvider(net.heartsome.cat.ts.handlexlf.split.TableViewerLabelProvider) GridData(org.eclipse.swt.layout.GridData) ArrayContentProvider(org.eclipse.jface.viewers.ArrayContentProvider) Event(org.eclipse.swt.widgets.Event) TableViewer(org.eclipse.jface.viewers.TableViewer)

Example 60 with ArrayContentProvider

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

the class LockRepeatedSegmentResultDialog method createDialogArea.

/**
	 * Create contents of the dialog.
	 * @param parent
	 */
@Override
protected Control createDialogArea(Composite parent) {
    Composite container = (Composite) super.createDialogArea(parent);
    container.setLayout(new GridLayout(1, false));
    Composite composite = new Composite(container, SWT.NONE);
    GridLayout gl_composite = new GridLayout(1, false);
    gl_composite.verticalSpacing = 0;
    gl_composite.marginWidth = 0;
    gl_composite.marginHeight = 0;
    composite.setLayout(gl_composite);
    composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
    tableViewer = new TableViewer(composite, SWT.BORDER | SWT.FULL_SELECTION | SWT.V_SCROLL | SWT.H_SCROLL);
    Table table = tableViewer.getTable();
    GridData tableGd = new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1);
    tableGd.heightHint = 220;
    table.setLayoutData(tableGd);
    table.setLinesVisible(true);
    table.setHeaderVisible(true);
    String[] clmnTitles = new String[] { Messages.getString("dialog.LockRepeatedSegmentResultDialog.clmnTitles1"), Messages.getString("dialog.LockRepeatedSegmentResultDialog.clmnTitles2"), Messages.getString("dialog.LockRepeatedSegmentResultDialog.clmnTitles3"), Messages.getString("dialog.LockRepeatedSegmentResultDialog.clmnTitles4"), Messages.getString("dialog.LockRepeatedSegmentResultDialog.clmnTitles5"), Messages.getString("dialog.LockRepeatedSegmentResultDialog.clmnTitles6") };
    int[] clmnBounds = { 60, 200, 100, 110, 110, 110 };
    for (int i = 0; i < clmnTitles.length; i++) {
        createTableViewerColumn(tableViewer, clmnTitles[i], clmnBounds[i], i);
    }
    tableViewer.setLabelProvider(new TableViewerLabelProvider());
    tableViewer.setContentProvider(new ArrayContentProvider());
    tableViewer.setInput(this.getTableViewerInput());
    return container;
}
Also used : GridLayout(org.eclipse.swt.layout.GridLayout) Table(org.eclipse.swt.widgets.Table) Composite(org.eclipse.swt.widgets.Composite) GridData(org.eclipse.swt.layout.GridData) ArrayContentProvider(org.eclipse.jface.viewers.ArrayContentProvider) TableViewer(org.eclipse.jface.viewers.TableViewer) Point(org.eclipse.swt.graphics.Point)

Aggregations

ArrayContentProvider (org.eclipse.jface.viewers.ArrayContentProvider)92 GridData (org.eclipse.swt.layout.GridData)67 Composite (org.eclipse.swt.widgets.Composite)59 TableViewer (org.eclipse.jface.viewers.TableViewer)56 SelectionEvent (org.eclipse.swt.events.SelectionEvent)45 Table (org.eclipse.swt.widgets.Table)43 GridLayout (org.eclipse.swt.layout.GridLayout)41 Button (org.eclipse.swt.widgets.Button)37 Label (org.eclipse.swt.widgets.Label)36 ISelectionChangedListener (org.eclipse.jface.viewers.ISelectionChangedListener)32 SelectionChangedEvent (org.eclipse.jface.viewers.SelectionChangedEvent)32 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)30 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)30 Group (org.eclipse.swt.widgets.Group)23 ComboViewer (org.eclipse.jface.viewers.ComboViewer)21 TableColumn (org.eclipse.swt.widgets.TableColumn)21 LabelProvider (org.eclipse.jface.viewers.LabelProvider)19 Combo (org.eclipse.swt.widgets.Combo)19 Text (org.eclipse.swt.widgets.Text)19 Point (org.eclipse.swt.graphics.Point)18