Search in sources :

Example 96 with Composite

use of org.eclipse.swt.widgets.Composite in project translationstudio8 by heartsome.

the class AbstractStyleEditorDialog method createButtons.

/**
	 * Create OK, Reset and Cancel buttons
	 */
protected void createButtons(final Shell shell) {
    Composite buttonPanel = new Composite(shell, SWT.NONE);
    GridLayout gridLayout = new GridLayout();
    gridLayout.numColumns = 3;
    gridLayout.marginLeft = 65;
    buttonPanel.setLayout(gridLayout);
    GridData gridLayoutData = new GridData();
    gridLayoutData.horizontalAlignment = GridData.FILL_HORIZONTAL;
    buttonPanel.setLayoutData(gridLayoutData);
    Button okButton = new Button(buttonPanel, SWT.PUSH);
    okButton.setText("OK");
    okButton.setLayoutData(new GridData(70, 25));
    okButton.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            doFormOK(shell);
        }
    });
    Button clearButton = new Button(buttonPanel, SWT.PUSH);
    clearButton.setText("Clear");
    clearButton.setToolTipText("Reset to original settings");
    clearButton.setLayoutData(new GridData(80, 25));
    clearButton.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            doFormClear(shell);
        }
    });
    Button cancelButton = new Button(buttonPanel, SWT.NONE);
    cancelButton.setText("Cancel");
    cancelButton.setLayoutData(new GridData(80, 25));
    cancelButton.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            doFormCancel(shell);
        }
    });
    shell.setDefaultButton(okButton);
}
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) SelectionEvent(org.eclipse.swt.events.SelectionEvent)

Example 97 with Composite

use of org.eclipse.swt.widgets.Composite in project translationstudio8 by heartsome.

the class WaitDialog method createContents.

@Override
protected Control createContents(Composite parent) {
    centerDialogOnScreen(getShell());
    Composite composite = new Composite(parent, SWT.NONE);
    composite.setLayout(new GridLayout(2, false));
    composite.setLayoutData(new GridData(CENTER, CENTER, true, true));
    composite.setRedraw(true);
    Label imgLabel = new Label(composite, SWT.NONE);
    imgLabel.setImage(iconImage);
    textLabel = new Label(composite, SWT.NONE);
    textLabel.setLayoutData(new GridData(CENTER, CENTER, true, true));
    textLabel.setFont(GUIHelper.getFont(new FontData("Arial", 9, SWT.BOLD)));
    textLabel.setRedraw(true);
    textLabel.setText(msg);
    return composite;
}
Also used : GridLayout(org.eclipse.swt.layout.GridLayout) Composite(org.eclipse.swt.widgets.Composite) FontData(org.eclipse.swt.graphics.FontData) GridData(org.eclipse.swt.layout.GridData) Label(org.eclipse.swt.widgets.Label)

Example 98 with Composite

use of org.eclipse.swt.widgets.Composite in project translationstudio8 by heartsome.

the class FileTypePreferencePage method createContents.

@Override
protected Control createContents(Composite parent) {
    Composite tparent = new Composite(parent, SWT.NONE);
    tparent.setLayout(new GridLayout());
    tparent.setLayoutData(new GridData(GridData.FILL_BOTH));
    HsImageLabel imageLabel = new HsImageLabel(Messages.getString("preference.FileTypePreferencePage.imageLabel"), null);
    imageLabel.createControl(tparent);
    imageLabel.computeSize();
    return parent;
}
Also used : GridLayout(org.eclipse.swt.layout.GridLayout) Composite(org.eclipse.swt.widgets.Composite) HsImageLabel(net.heartsome.cat.common.ui.HsImageLabel) GridData(org.eclipse.swt.layout.GridData)

Example 99 with Composite

use of org.eclipse.swt.widgets.Composite in project translationstudio8 by heartsome.

the class MergeXliffWizardPage method createMergeXlfGroup.

public void createMergeXlfGroup(Composite tparent) {
    final Group xliffDataGroup = new Group(tparent, SWT.NONE);
    GridLayoutFactory.fillDefaults().numColumns(2).margins(8, 8).applyTo(xliffDataGroup);
    GridDataFactory.fillDefaults().grab(true, true).applyTo(xliffDataGroup);
    xliffDataGroup.setText(Messages.getString("wizard.MergeXliffWizardPage.xliffDataGroup"));
    tableViewer = new TableViewer(xliffDataGroup, 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.MergeXliffWizardPage.columnNames1"), Messages.getString("wizard.MergeXliffWizardPage.columnNames2") };
    int[] columnAlignments = new int[] { 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(getSplitTableInfos());
    validXlf();
    // 让列表列宽动态变化
    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.15, 0.75 };
                    for (int i = 0; i < columns.length; i++) columns[i].setWidth((int) (table.getBounds().width * columnWidths[i]));
                }
            });
        }
    });
    Composite buttonComp = new Composite(xliffDataGroup, SWT.None);
    GridLayoutFactory.fillDefaults().numColumns(1).margins(8, 8).applyTo(buttonComp);
    GridDataFactory.fillDefaults().grab(false, true).hint(100, SWT.DEFAULT).applyTo(buttonComp);
    Button addbutton = new Button(buttonComp, SWT.NONE);
    addbutton.setText(Messages.getString("wizard.MergeXliffWizardPage.addbutton"));
    addbutton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    addbutton.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent e) {
            FileFolderSelectionDialog dialog = new FileFolderSelectionDialog(xliffDataGroup.getShell(), true, IResource.FILE);
            dialog.setMessage(Messages.getString("wizard.MergeXliffWizardPage.dialogMsg"));
            dialog.setTitle(Messages.getString("wizard.MergeXliffWizardPage.dialogTitle"));
            dialog.setDoubleClickSelects(true);
            try {
                dialog.setInput(EFS.getStore(root.getLocationURI()));
            } catch (CoreException e1) {
                LOGGER.error("", e1);
                e1.printStackTrace();
            }
            dialog.addFilter(new ViewerFilter() {

                @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") || folder.getName().equalsIgnoreCase(".config") || folder.getName().equalsIgnoreCase(".nonTransElement")) {
                            return false;
                        }
                        if (projectPath.equals(folder.toString())) {
                            return true;
                        }
                        String xliffFolderPath = folder.toString();
                        String tempPath = projectPath + System.getProperty("file.separator") + ".TEMP";
                        String configPath = projectPath + System.getProperty("file.separator") + ".config";
                        String projectFilePath = projectPath + System.getProperty("file.separator") + ".project";
                        if (xliffFolderPath.startsWith(tempPath) || xliffFolderPath.startsWith(configPath) || xliffFolderPath.startsWith(projectFilePath)) {
                            return false;
                        } else if (xliffFolderPath.startsWith(projectPath)) {
                            return xliffFolderPath.substring(projectPath.length()).startsWith(System.getProperty("file.separator"));
                        }
                    }
                    return false;
                }
            });
            dialog.create();
            dialog.open();
            if (dialog.getResult() != null) {
                Object[] selectFiles = dialog.getResult();
                XLFValidator.resetFlag();
                for (int i = 0; i < selectFiles.length; i++) {
                    IFile iFile = root.getFileForLocation(Path.fromOSString(selectFiles[i].toString()));
                    if (XLFValidator.validateXliffFile(iFile)) {
                        // 如果该文件已经存在于列表中,就向添加到重复集合中
                        if (model.getMergeXliffFile().indexOf(iFile) >= 0) {
                            exsistFileList.add(iFile);
                        }
                        model.getMergeXliffFile().add(iFile);
                    }
                }
                XLFValidator.resetFlag();
                tableViewer.setInput(getSplitTableInfos());
                if (!validIsRepeate()) {
                    validXlf();
                }
            //					for (int i = 0; i < selectFiles.length; i++) {
            //						IFile file = root.getFileForLocation(Path.fromOSString(selectFiles[i].toString()));
            //						// 如果该文件已经存在于列表中,就向添加到重复集合中
            //						if (model.getMergeXliffFile().indexOf(file) >= 0) {
            //							exsistFileList.add(file);
            //						}
            //						model.getMergeXliffFile().add(file);
            //					}
            //					tableViewer.setInput(getSplitTableInfos());
            //					if (!validIsRepeate()) {
            //						validXlf();
            //					}
            }
        }
    });
    Button deleteButton = new Button(buttonComp, SWT.NONE);
    deleteButton.setText(Messages.getString("wizard.MergeXliffWizardPage.deleteButton"));
    deleteButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    deleteButton.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent e) {
            ISelection selection = tableViewer.getSelection();
            Table table = tableViewer.getTable();
            if (selection != null && !selection.isEmpty()) {
                int[] indices = table.getSelectionIndices();
                for (int index : indices) {
                    String fileFullPath = table.getItem(index).getText(1);
                    for (int i = 0; i < model.getMergeXliffFile().size(); i++) {
                        if (model.getMergeXliffFile().get(i).getFullPath().toOSString().equals(fileFullPath)) {
                            model.getMergeXliffFile().remove(i);
                            break;
                        }
                    }
                    // 如果该文件存在于重复集合中,则从该集合中删除
                    for (int j = 0; j < exsistFileList.size(); j++) {
                        if (exsistFileList.get(j).getFullPath().toOSString().equals(fileFullPath)) {
                            exsistFileList.remove(j);
                            break;
                        }
                    }
                }
                tableViewer.setInput(getSplitTableInfos());
            }
            if (!validIsRepeate()) {
                validXlf();
            }
        }
    });
}
Also used : Group(org.eclipse.swt.widgets.Group) Listener(org.eclipse.swt.widgets.Listener) IFile(org.eclipse.core.resources.IFile) ViewerFilter(org.eclipse.jface.viewers.ViewerFilter) TableViewer(org.eclipse.jface.viewers.TableViewer) Viewer(org.eclipse.jface.viewers.Viewer) Button(org.eclipse.swt.widgets.Button) SelectionEvent(org.eclipse.swt.events.SelectionEvent) ISelection(org.eclipse.jface.viewers.ISelection) FileFolderSelectionDialog(net.heartsome.cat.common.ui.dialog.FileFolderSelectionDialog) Table(org.eclipse.swt.widgets.Table) Composite(org.eclipse.swt.widgets.Composite) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) TableColumn(org.eclipse.swt.widgets.TableColumn) LocalFile(org.eclipse.core.internal.filesystem.local.LocalFile) CoreException(org.eclipse.core.runtime.CoreException) 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) SelectionEvent(org.eclipse.swt.events.SelectionEvent) TableViewer(org.eclipse.jface.viewers.TableViewer)

Example 100 with Composite

use of org.eclipse.swt.widgets.Composite in project translationstudio8 by heartsome.

the class MergeXliffWizardPage method createControl.

public void createControl(Composite parent) {
    setTitle(Messages.getString("wizard.MergeXliffWizardPage.title"));
    setMessage(Messages.getString("wizard.MergeXliffWizardPage.desc"));
    Composite tparent = new Composite(parent, SWT.NONE);
    GridLayout layout = new GridLayout();
    tparent.setLayout(layout);
    GridDataFactory.fillDefaults().hint(600, 500).grab(true, true).applyTo(tparent);
    createMergeXlfGroup(tparent);
    setImageDescriptor(Activator.getImageDescriptor("images/file/file-merge-logo.png"));
    setControl(parent);
}
Also used : GridLayout(org.eclipse.swt.layout.GridLayout) Composite(org.eclipse.swt.widgets.Composite)

Aggregations

Composite (org.eclipse.swt.widgets.Composite)1543 GridData (org.eclipse.swt.layout.GridData)1136 GridLayout (org.eclipse.swt.layout.GridLayout)1098 Label (org.eclipse.swt.widgets.Label)594 SelectionEvent (org.eclipse.swt.events.SelectionEvent)495 Button (org.eclipse.swt.widgets.Button)492 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)421 Text (org.eclipse.swt.widgets.Text)373 Group (org.eclipse.swt.widgets.Group)233 ModifyListener (org.eclipse.swt.events.ModifyListener)152 ModifyEvent (org.eclipse.swt.events.ModifyEvent)149 Combo (org.eclipse.swt.widgets.Combo)135 FillLayout (org.eclipse.swt.layout.FillLayout)131 TableViewer (org.eclipse.jface.viewers.TableViewer)127 ScrolledComposite (org.eclipse.swt.custom.ScrolledComposite)114 Table (org.eclipse.swt.widgets.Table)112 Point (org.eclipse.swt.graphics.Point)104 SelectionListener (org.eclipse.swt.events.SelectionListener)90 Control (org.eclipse.swt.widgets.Control)88 FormData (org.eclipse.swt.layout.FormData)87