Search in sources :

Example 81 with GridLayout

use of org.eclipse.swt.layout.GridLayout in project translationstudio8 by heartsome.

the class AnalysisXmlConvertConfigDialg method createButtonBar.

@Override
protected Control createButtonBar(Composite parent) {
    Composite buttonCmp = new Composite(parent, SWT.NONE);
    GridLayout layout = new GridLayout();
    layout.numColumns = 2;
    layout.makeColumnsEqualWidth = false;
    layout.marginWidth = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN);
    layout.marginHeight = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN);
    layout.horizontalSpacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
    layout.verticalSpacing = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING);
    buttonCmp.setLayout(layout);
    GridData data = new GridData(SWT.FILL, SWT.FILL, true, false);
    buttonCmp.setLayoutData(data);
    buttonCmp.setFont(parent.getFont());
    Composite leftCmp = new Composite(buttonCmp, SWT.NONE);
    GridDataFactory.fillDefaults().grab(true, false).applyTo(leftCmp);
    GridLayoutFactory.fillDefaults().extendedMargins(0, 0, 0, 0).numColumns(3).equalWidth(false).applyTo(leftCmp);
    addBtn = createButton(leftCmp, IDialogConstants.CLIENT_ID, Messages.getString("dialogs.AnalysisXmlConvertConfigDialg.addBtn"), false);
    editBtn = createButton(leftCmp, IDialogConstants.CLIENT_ID, Messages.getString("dialogs.AnalysisXmlConvertConfigDialg.editBtn"), false);
    deleteBtn = createButton(leftCmp, IDialogConstants.CLIENT_ID, Messages.getString("dialogs.AnalysisXmlConvertConfigDialg.deleteBtn"), false);
    Composite rightCmp = new Composite(buttonCmp, SWT.NONE);
    GridLayoutFactory.fillDefaults().extendedMargins(0, 0, 0, 0).numColumns(1).equalWidth(false).applyTo(rightCmp);
    new Label(rightCmp, SWT.NONE);
    Label separatorLbl = new Label(buttonCmp, SWT.HORIZONTAL | SWT.SEPARATOR);
    GridDataFactory.fillDefaults().span(2, SWT.DEFAULT).applyTo(separatorLbl);
    new Label(buttonCmp, SWT.NONE);
    Composite bottomCmp = new Composite(buttonCmp, SWT.NONE);
    GridDataFactory.fillDefaults().grab(false, false).applyTo(bottomCmp);
    GridLayoutFactory.fillDefaults().extendedMargins(0, 0, 0, 0).numColumns(2).applyTo(bottomCmp);
    okBtn = createButton(bottomCmp, IDialogConstants.OK_ID, Messages.getString("dialogs.AnalysisXmlConvertConfigDialg.ok"), false);
    // 禁用确定按钮
    okBtn.setEnabled(false);
    createButton(bottomCmp, IDialogConstants.CANCEL_ID, Messages.getString("dialogs.AnalysisXmlConvertConfigDialg.cancel"), true).setFocus();
    initListener();
    return buttonCmp;
}
Also used : GridLayout(org.eclipse.swt.layout.GridLayout) Composite(org.eclipse.swt.widgets.Composite) GridData(org.eclipse.swt.layout.GridData) Label(org.eclipse.swt.widgets.Label)

Example 82 with GridLayout

use of org.eclipse.swt.layout.GridLayout in project translationstudio8 by heartsome.

the class AddOrEditCatalogDialog method createDialogArea.

@Override
protected Control createDialogArea(Composite parent) {
    Composite tParent = (Composite) super.createDialogArea(parent);
    GridDataFactory.fillDefaults().hint(600, 150).grab(true, true).applyTo(tParent);
    Composite contentCmp = new Composite(tParent, SWT.NONE);
    GridDataFactory.fillDefaults().grab(true, false).applyTo(contentCmp);
    GridLayoutFactory.fillDefaults().numColumns(3).applyTo(contentCmp);
    GridData labelData = new GridData(SWT.FILL, SWT.CENTER, false, false);
    // 第一行,类型选择行
    Label typeLbl = new Label(contentCmp, SWT.RIGHT | SWT.NONE);
    typeLbl.setText(Messages.getString("dialogs.AddOrEditCatalogDialog.typeLbl"));
    typeLbl.setLayoutData(labelData);
    Composite radioCmp = new Composite(contentCmp, SWT.NONE);
    radioCmp.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 2, SWT.DEFAULT));
    radioCmp.setLayout(new GridLayout(4, false));
    publicBtn = new Button(radioCmp, SWT.RADIO);
    publicBtn.setText(Messages.getString("dialogs.AddOrEditCatalogDialog.publicBtn"));
    systermBtn = new Button(radioCmp, SWT.RADIO);
    systermBtn.setText(Messages.getString("dialogs.AddOrEditCatalogDialog.systermBtn"));
    uriBtn = new Button(radioCmp, SWT.RADIO);
    uriBtn.setText(Messages.getString("dialogs.AddOrEditCatalogDialog.uriBtn"));
    nextCataBtn = new Button(radioCmp, SWT.RADIO);
    nextCataBtn.setText(Messages.getString("dialogs.AddOrEditCatalogDialog.nextCataBtn"));
    // 第二行--id行
    idLbl = new Label(contentCmp, SWT.RIGHT);
    idLbl.setText(Messages.getString("dialogs.AddOrEditCatalogDialog.idLbl"));
    GridDataFactory.swtDefaults().align(SWT.RIGHT, SWT.CENTER).applyTo(idLbl);
    idTxt = new Text(contentCmp, SWT.BORDER);
    idTxt.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 2, SWT.DEFAULT));
    // 第三行--url选择行
    Label urlLbl = new Label(contentCmp, SWT.RIGHT);
    urlLbl.setText(Messages.getString("dialogs.AddOrEditCatalogDialog.urlLbl"));
    GridDataFactory.swtDefaults().align(SWT.RIGHT, SWT.CENTER).applyTo(urlLbl);
    urlTxt = new Text(contentCmp, SWT.BORDER);
    urlTxt.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
    urlTxt.setEditable(false);
    Button browseBtn = new Button(contentCmp, SWT.NONE);
    browseBtn.setText(Messages.getString("dialogs.AddOrEditCatalogDialog.browseBtn"));
    browseBtn.addSelectionListener(new SelectionListener() {

        public void widgetSelected(SelectionEvent e) {
            browseFiles();
        }

        public void widgetDefaultSelected(SelectionEvent e) {
            browseFiles();
        }
    });
    publicBtn.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            displayIdTxt(true);
        }
    });
    systermBtn.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            displayIdTxt(true);
        }
    });
    uriBtn.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            displayIdTxt(true);
        }
    });
    nextCataBtn.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            displayIdTxt(false);
        }
    });
    return tParent;
}
Also used : GridLayout(org.eclipse.swt.layout.GridLayout) Composite(org.eclipse.swt.widgets.Composite) Button(org.eclipse.swt.widgets.Button) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) GridData(org.eclipse.swt.layout.GridData) Label(org.eclipse.swt.widgets.Label) SelectionEvent(org.eclipse.swt.events.SelectionEvent) Text(org.eclipse.swt.widgets.Text) SelectionListener(org.eclipse.swt.events.SelectionListener)

Example 83 with GridLayout

use of org.eclipse.swt.layout.GridLayout in project translationstudio8 by heartsome.

the class SrxMapRulesManageDialog method createButtonBar.

@Override
protected Control createButtonBar(Composite parent) {
    Composite buttonCmp = new Composite(parent, SWT.NONE);
    GridLayout layout = new GridLayout();
    layout.numColumns = 2;
    layout.makeColumnsEqualWidth = false;
    layout.marginWidth = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN);
    layout.marginHeight = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN);
    layout.horizontalSpacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
    layout.verticalSpacing = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING);
    buttonCmp.setLayout(layout);
    GridData data = new GridData(SWT.FILL, SWT.FILL, true, false);
    buttonCmp.setLayoutData(data);
    buttonCmp.setFont(parent.getFont());
    Composite leftCmp = new Composite(buttonCmp, SWT.NONE);
    GridDataFactory.fillDefaults().grab(true, false).applyTo(leftCmp);
    GridLayoutFactory.fillDefaults().extendedMargins(0, 0, 0, 0).numColumns(3).equalWidth(false).applyTo(leftCmp);
    addBtn = createButton(leftCmp, IDialogConstants.CLIENT_ID, Messages.getString("srx.SrxMapRulesManageDialog.addBtn"), false);
    editBtn = createButton(leftCmp, IDialogConstants.CLIENT_ID, Messages.getString("srx.SrxMapRulesManageDialog.editBtn"), false);
    deleteBtn = createButton(leftCmp, IDialogConstants.CLIENT_ID, Messages.getString("srx.SrxMapRulesManageDialog.deleteBtn"), false);
    Composite rightCmp = new Composite(buttonCmp, SWT.NONE);
    GridLayoutFactory.fillDefaults().extendedMargins(0, 0, 0, 0).numColumns(1).equalWidth(false).applyTo(rightCmp);
    new Label(rightCmp, SWT.NONE);
    Label separatorLbl = new Label(buttonCmp, SWT.HORIZONTAL | SWT.SEPARATOR);
    GridDataFactory.fillDefaults().span(2, SWT.DEFAULT).applyTo(separatorLbl);
    new Label(buttonCmp, SWT.NONE);
    Composite bottomCmp = new Composite(buttonCmp, SWT.NONE);
    GridDataFactory.fillDefaults().grab(false, false).applyTo(bottomCmp);
    GridLayoutFactory.fillDefaults().extendedMargins(0, 0, 0, 0).numColumns(2).applyTo(bottomCmp);
    createButton(bottomCmp, IDialogConstants.OK_ID, Messages.getString("srx.SrxMapRulesManageDialog.ok"), false);
    createButton(bottomCmp, IDialogConstants.CANCEL_ID, Messages.getString("srx.SrxMapRulesManageDialog.cancel"), true).setFocus();
    initListener();
    return buttonCmp;
}
Also used : GridLayout(org.eclipse.swt.layout.GridLayout) Composite(org.eclipse.swt.widgets.Composite) GridData(org.eclipse.swt.layout.GridData) Label(org.eclipse.swt.widgets.Label)

Example 84 with GridLayout

use of org.eclipse.swt.layout.GridLayout in project translationstudio8 by heartsome.

the class ExportExternalDialog method createDialogArea.

protected Control createDialogArea(Composite parent) {
    Composite tparent = (Composite) super.createDialogArea(parent);
    GridDataFactory.createFrom(new GridData(GridData.FILL_BOTH)).hint(600, SWT.DEFAULT).applyTo(tparent);
    final Group groupFile = new Group(tparent, SWT.NONE);
    groupFile.setText(Messages.getString("ExportDocxDialog.lable.xliff"));
    groupFile.setLayout(new GridLayout(1, false));
    groupFile.setLayoutData(new GridData(GridData.FILL_BOTH));
    final TableViewer tbv = new TableViewer(groupFile, SWT.V_SCROLL | SWT.FULL_SELECTION | SWT.BORDER);
    final Table table = tbv.getTable();
    table.setHeaderVisible(true);
    table.setLinesVisible(true);
    TableLayout tableLayout = new TableLayout();
    table.setLayout(tableLayout);
    GridDataFactory.swtDefaults().align(SWT.FILL, SWT.FILL).grab(true, true).hint(SWT.DEFAULT, 90).applyTo(table);
    tableLayout.addColumnData(new ColumnWeightData(1));
    new TableColumn(table, SWT.NONE).setText(Messages.getString("ExportDocxDialog.lable.nodot"));
    tableLayout.addColumnData(new ColumnWeightData(10));
    new TableColumn(table, SWT.NONE).setText(Messages.getString("ExportDocxDialog.lable.fullPath"));
    tableLayout.addColumnData(new ColumnWeightData(2));
    new TableColumn(table, SWT.NONE).setText(Messages.getString("ExportDocxDialog.lable.srcLang"));
    tableLayout.addColumnData(new ColumnWeightData(2));
    new TableColumn(table, SWT.NONE).setText(Messages.getString("ExportDocxDialog.lable.tgtLang"));
    tbv.setLabelProvider(new TableViewLabelProvider());
    tbv.setContentProvider(new ArrayContentProvider());
    tbv.setInput(xlfBeans);
    final Group groupExportType = new Group(tparent, SWT.NONE);
    groupExportType.setText(Messages.getString("ExportDocxDialog.lable.exporttype"));
    groupExportType.setLayout(new GridLayout(3, false));
    groupExportType.setLayoutData(new GridData(GridData.FILL_BOTH));
    final Label lblExportType = new Label(groupExportType, SWT.NONE);
    lblExportType.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
    lblExportType.setText(Messages.getString("ExportDocxDialog.lable.exportchoose"));
    cmb = new Combo(groupExportType, SWT.NONE | SWT.READ_ONLY);
    GridDataFactory.swtDefaults().span(2, 1).grab(true, false).align(SWT.FILL, SWT.FILL).applyTo(cmb);
    for (String type : ExportExternal.getExportTypes()) {
        cmb.add(type);
    }
    cmb.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            final int exportCode = ExportExternal.getExportTypeCode(cmb.getSelectionIndex());
            btnHsproofNote.setEnabled(exportCode == ExportExternal.EXPORT_HSPROOF);
            btnHsproofState.setEnabled(btnHsproofNote.getEnabled());
            btnNotrans.setEnabled(exportCode != ExportExternal.EXPORT_TMX && btnFilterWhenState.getSelection());
            if (ExportExternal.EXPORT_TMX == exportCode && btnFilterWhenState.getSelection()) {
                btnNotrans.setSelection(false);
            }
        }
    });
    final Label lblR8State = new Label(groupExportType, SWT.NONE);
    lblR8State.setText(Messages.getString("ExportDocxDialog.lable.hsproof"));
    btnHsproofState = new Button(groupExportType, SWT.CHECK);
    btnHsproofState.setText(Messages.getString("ExportDocxDialog.statusBtn"));
    btnHsproofNote = new Button(groupExportType, SWT.CHECK);
    btnHsproofNote.setText(Messages.getString("ExportDocxDialog.commentBtn"));
    final Group groupFilter = new Group(tparent, SWT.NONE);
    groupFilter.setText(Messages.getString("ExportDocxDialog.lable.filter"));
    groupFilter.setLayout(new GridLayout(3, false));
    groupFilter.setLayoutData(new GridData(GridData.FILL_BOTH));
    // 过滤大类
    btnAllTrans = new Button(groupFilter, SWT.RADIO);
    btnAllTrans.setText(Messages.getString("ExportDocxDialog.lable.filterAll"));
    btnAllTrans.setSelection(true);
    btnAllTrans.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            if (btnAllTrans.getSelection()) {
                setFilterDefaultValue();
            }
        }
    });
    btnOnlySpecial = new Button(groupFilter, SWT.RADIO);
    btnOnlySpecial.setText(Messages.getString("ExportDocxDialog.onlyExportBtn"));
    btnOnlySpecial.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            if (btnOnlySpecial.getSelection()) {
                setFilterDefaultValue();
            }
        }

        ;
    });
    btnFilterWhenState = new Button(groupFilter, SWT.RADIO);
    btnFilterWhenState.setText(Messages.getString("ExportDocxDialog.lable.hasState"));
    btnFilterWhenState.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            if (btnFilterWhenState.getSelection()) {
                setFilterDefaultValue();
            }
        }

        ;
    });
    // 大类细节
    cmpFilterAllTrans = new Composite(groupFilter, SWT.NONE);
    cmpFilterAllTrans.setLayout(new GridLayout(1, false));
    cmpFilterAllTrans.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
    btnExceptLocked = new Button(cmpFilterAllTrans, SWT.CHECK);
    btnExceptLocked.setText(Messages.getString("ExportDocxDialog.lable.exceptLock"));
    btnExceptLocked.setEnabled(true);
    btnExceptContextMatch = new Button(cmpFilterAllTrans, SWT.CHECK);
    btnExceptContextMatch.setText(Messages.getString("ExportDocxDialog.lable.exceptCxtMatch"));
    btnExceptContextMatch.setEnabled(true);
    btnExceptFullMatch = new Button(cmpFilterAllTrans, SWT.CHECK);
    btnExceptFullMatch.setText(Messages.getString("ExportDocxDialog.lable.exceptFullMatch"));
    cmpFilterOnlySpecial = new Composite(groupFilter, SWT.NONE);
    cmpFilterOnlySpecial.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
    cmpFilterOnlySpecial.setLayout(new GridLayout(1, false));
    btnHasNote = new Button(cmpFilterOnlySpecial, SWT.CHECK);
    btnHasNote.setText(Messages.getString("ExportDocxDialog.onlyExportNoteBtn"));
    btnNeedReview = new Button(cmpFilterOnlySpecial, SWT.CHECK);
    btnNeedReview.setText(Messages.getString("ExportDocxDialog.onlyExportReviewBtn"));
    cmpFilterWhenState = new Composite(groupFilter, SWT.NONE);
    cmpFilterWhenState.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
    cmpFilterWhenState.setLayout(new GridLayout(1, false));
    btnNotrans = new Button(cmpFilterWhenState, SWT.CHECK);
    btnNotrans.setText(Messages.getString("ExportDocxDialog.lable.state.noTrans"));
    btnNotrans.setText(Messages.getString("ExportDocxDialog.lable.state.noTrans"));
    btnNewtrans = new Button(cmpFilterWhenState, SWT.CHECK);
    btnNewtrans.setText(Messages.getString("ExportDocxDialog.lable.state.new"));
    btnNewtrans.setText(Messages.getString("ExportDocxDialog.lable.state.new"));
    btnTransed = new Button(cmpFilterWhenState, SWT.CHECK);
    btnTransed.setText(Messages.getString("ExportDocxDialog.lable.state.hasTrans"));
    btnApproved = new Button(cmpFilterWhenState, SWT.CHECK);
    btnApproved.setText(Messages.getString("ExportDocxDialog.lable.state.hasApprove"));
    Composite cmpSaveas = new Composite(tparent, SWT.NONE);
    cmpSaveas.setLayout(GridLayoutFactory.swtDefaults().numColumns(3).create());
    cmpSaveas.setLayoutData(new GridData(GridData.FILL_BOTH));
    Label lblSaveas = new Label(cmpSaveas, SWT.NONE);
    lblSaveas.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
    lblSaveas.setText(Messages.getString("ExportDocxDialog.lable.saveas"));
    txtSaveas = new Text(cmpSaveas, SWT.BORDER | SWT.READ_ONLY);
    txtSaveas.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
    txtSaveas.addModifyListener(new ModifyListener() {

        @Override
        public void modifyText(ModifyEvent e) {
            getButton(IDialogConstants.OK_ID).setEnabled(!txtSaveas.getText().isEmpty());
        }
    });
    Button btnSaveas = new Button(cmpSaveas, SWT.NONE);
    btnSaveas.setText(Messages.getString("ExportDocxDialog.browseDocxBtn"));
    btnSaveas.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent e) {
            DirectoryDialog dialog = new DirectoryDialog(getShell());
            dialog.setFilterPath(dialogSetting.get("defaultPath"));
            String path = dialog.open();
            if (path != null) {
                txtSaveas.setText(path);
                dialogSetting.put("defaultPath", path);
            }
        }
    });
    setDefaultValue();
    return parent;
}
Also used : ColumnWeightData(org.eclipse.jface.viewers.ColumnWeightData) Group(org.eclipse.swt.widgets.Group) Table(org.eclipse.swt.widgets.Table) Composite(org.eclipse.swt.widgets.Composite) ModifyListener(org.eclipse.swt.events.ModifyListener) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Label(org.eclipse.swt.widgets.Label) Combo(org.eclipse.swt.widgets.Combo) Text(org.eclipse.swt.widgets.Text) TableColumn(org.eclipse.swt.widgets.TableColumn) GridLayout(org.eclipse.swt.layout.GridLayout) ModifyEvent(org.eclipse.swt.events.ModifyEvent) Button(org.eclipse.swt.widgets.Button) GridData(org.eclipse.swt.layout.GridData) ArrayContentProvider(org.eclipse.jface.viewers.ArrayContentProvider) SelectionEvent(org.eclipse.swt.events.SelectionEvent) TableViewer(org.eclipse.jface.viewers.TableViewer) TableLayout(org.eclipse.jface.viewers.TableLayout) DirectoryDialog(org.eclipse.swt.widgets.DirectoryDialog)

Example 85 with GridLayout

use of org.eclipse.swt.layout.GridLayout in project translationstudio8 by heartsome.

the class ImportExternalDialog method createDialogArea.

@Override
protected Control createDialogArea(Composite parent) {
    Composite composite = (Composite) super.createDialogArea(parent);
    composite.setLayout(new GridLayout(1, false));
    GridDataFactory.fillDefaults().hint(500, 180).grab(true, true).applyTo(composite);
    Group groupXLIFF = new Group(composite, SWT.None);
    groupXLIFF.setLayoutData(new GridData(GridData.FILL_BOTH));
    groupXLIFF.setLayout(new GridLayout(3, false));
    groupXLIFF.setText(Messages.getString("ImportDocxDialog.XLIFFgroup"));
    Label lblXLIFF = new Label(groupXLIFF, SWT.None);
    lblXLIFF.setText(Messages.getString("ImportDocxDialog.lable.xliff"));
    xliffPathTxt = new Text(groupXLIFF, SWT.BORDER);
    xliffPathTxt.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    xliffPathTxt.setEditable(false);
    if (xliffRelativePath != null) {
        xliffPathTxt.setText(xliffRelativePath);
    }
    browseXLIFFBtn = new Button(groupXLIFF, SWT.None);
    browseXLIFFBtn.setText(Messages.getString("ImportDocxDialog.browseXLIFFBtn"));
    browseXLIFFBtn.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {
            FileFolderSelectionDialog dialog = new FileFolderSelectionDialog(getShell(), false, IResource.FILE) {

                // 打开对话框时展开树形目录
                public void create() {
                    super.create();
                    super.getTreeViewer().expandAll();
                }
            };
            dialog.setTitle(Messages.getString("ImportDocxDialog.browseXLIFFBtn.msg0"));
            dialog.setMessage(Messages.getString("ImportDocxDialog.browseXLIFFBtn.msg1"));
            dialog.setDoubleClickSelects(true);
            dialog.setAllowMultiple(false);
            try {
                dialog.setInput(EFS.getStore(root.getLocationURI()));
            } catch (CoreException e1) {
                LOGGER.error(Messages.getString("ImportDocxDialog.LOGGER.logger1"), e1);
            }
            dialog.addFilter(new ViewerFilter() {

                @SuppressWarnings("restriction")
                @Override
                public boolean select(Viewer viewer, Object parentElement, Object element) {
                    if (element instanceof LocalFile) {
                        LocalFile folder = (LocalFile) element;
                        if (folder.getName().equalsIgnoreCase(".hsConfig") || folder.getName().equalsIgnoreCase(".metadata")) {
                            return false;
                        }
                        if (lstProject.contains(folder.toString())) {
                            return true;
                        }
                        String xliffFolderPath = folder.toString();
                        for (String projectPath : lstProject) {
                            String path1 = projectPath + System.getProperty("file.separator") + Constant.FOLDER_XLIFF;
                            if (xliffFolderPath.startsWith(path1)) {
                                return true;
                            }
                        }
                    }
                    return false;
                }
            });
            dialog.create();
            if (Window.OK == dialog.open()) {
                if (dialog.getResult() != null) {
                    Object obj = dialog.getFirstResult();
                    IFile file = root.getFileForLocation(Path.fromOSString(obj.toString()));
                    xliffPathTxt.setText(file.getFullPath().toOSString());
                    xliffFullPath = ResourceUtils.iFileToOSPath(file);
                }
                getButton(IDialogConstants.OK_ID).setEnabled(!docxPathTxt.getText().isEmpty());
            }
        }
    });
    Group groupExternal = new Group(composite, SWT.NONE);
    groupExternal.setText(Messages.getString("ImportDocxDialog.label.docx.title"));
    groupExternal.setLayout(new GridLayout(3, false));
    groupExternal.setLayoutData(new GridData(GridData.FILL_BOTH));
    Label lblRTF = new Label(groupExternal, SWT.None);
    lblRTF.setText(Messages.getString("ImportDocxDialog.label.docx"));
    GridDataFactory.swtDefaults().align(SWT.RIGHT, SWT.CENTER).grab(false, false).applyTo(lblRTF);
    docxPathTxt = new Text(groupExternal, SWT.BORDER);
    docxPathTxt.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    docxPathTxt.setEditable(false);
    browseDocxBtn = new Button(groupExternal, SWT.None);
    browseDocxBtn.setText(Messages.getString("ImportDocxDialog.browseDocxBtn"));
    browseDocxBtn.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent e) {
            FileDialog dialog = new FileDialog(getShell());
            dialog.setText(Messages.getString("ImportDocxDialog.browseDocx.title"));
            dialog.setFilterExtensions(new String[] { "*.docx;", "*.*" });
            dialog.setFilterPath(dialogSetting.get("defaultPath"));
            String path = dialog.open();
            if (path != null) {
                if (testFileType(path)) {
                    dialogSetting.put("defaultPath", path.substring(0, path.lastIndexOf(File.separator)));
                    docxPathTxt.setText(path);
                    getButton(IDialogConstants.OK_ID).setEnabled(true && (!xliffPathTxt.getText().isEmpty()));
                } else {
                    getButton(IDialogConstants.OK_ID).setEnabled(false);
                }
            }
        }
    });
    txtImportType = new Label(composite, SWT.READ_ONLY);
    GridDataFactory.swtDefaults().align(SWT.FILL, SWT.BOTTOM).span(1, 3).grab(true, true).applyTo(txtImportType);
    return composite;
}
Also used : Group(org.eclipse.swt.widgets.Group) IFile(org.eclipse.core.resources.IFile) Composite(org.eclipse.swt.widgets.Composite) ViewerFilter(org.eclipse.jface.viewers.ViewerFilter) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Label(org.eclipse.swt.widgets.Label) Text(org.eclipse.swt.widgets.Text) Viewer(org.eclipse.jface.viewers.Viewer) GridLayout(org.eclipse.swt.layout.GridLayout) LocalFile(org.eclipse.core.internal.filesystem.local.LocalFile) CoreException(org.eclipse.core.runtime.CoreException) Button(org.eclipse.swt.widgets.Button) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) FileFolderSelectionDialog(net.heartsome.cat.common.ui.dialog.FileFolderSelectionDialog) FileDialog(org.eclipse.swt.widgets.FileDialog)

Aggregations

GridLayout (org.eclipse.swt.layout.GridLayout)1868 GridData (org.eclipse.swt.layout.GridData)1646 Composite (org.eclipse.swt.widgets.Composite)1417 Label (org.eclipse.swt.widgets.Label)839 Button (org.eclipse.swt.widgets.Button)672 SelectionEvent (org.eclipse.swt.events.SelectionEvent)597 Text (org.eclipse.swt.widgets.Text)510 Group (org.eclipse.swt.widgets.Group)491 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)481 Combo (org.eclipse.swt.widgets.Combo)215 ModifyListener (org.eclipse.swt.events.ModifyListener)199 SelectionListener (org.eclipse.swt.events.SelectionListener)197 ModifyEvent (org.eclipse.swt.events.ModifyEvent)190 Table (org.eclipse.swt.widgets.Table)138 Point (org.eclipse.swt.graphics.Point)131 TableViewer (org.eclipse.jface.viewers.TableViewer)112 ScrolledComposite (org.eclipse.swt.custom.ScrolledComposite)109 Shell (org.eclipse.swt.widgets.Shell)107 FillLayout (org.eclipse.swt.layout.FillLayout)96 ArrayList (java.util.ArrayList)89