Search in sources :

Example 61 with GridLayout

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

the class TmDbManagerDialog method createDialogArea.

/**
	 * Create contents of the dialog.
	 * @param parent
	 */
@Override
protected Control createDialogArea(Composite parent) {
    final Composite composite = (Composite) super.createDialogArea(parent);
    GridLayout parentLayout = ((GridLayout) composite.getLayout());
    parentLayout.numColumns = 4;
    parentLayout.marginHeight = 0;
    parentLayout.marginWidth = 0;
    parentLayout.marginTop = 0;
    parentLayout.verticalSpacing = 0;
    parentLayout.horizontalSpacing = 0;
    Control treeControl = createTreeAreaContents(composite);
    createSash(composite, treeControl);
    Label versep = new Label(composite, SWT.SEPARATOR | SWT.VERTICAL);
    GridData verGd = new GridData(GridData.FILL_VERTICAL | GridData.GRAB_VERTICAL);
    versep.setLayoutData(verGd);
    versep.setLayoutData(new GridData(SWT.LEFT, SWT.FILL, false, true));
    Composite pageAreaComposite = new Composite(composite, SWT.NONE);
    pageAreaComposite.setLayoutData(new GridData(GridData.FILL_BOTH));
    GridLayout layout = new GridLayout(1, true);
    layout.marginHeight = 0;
    layout.marginWidth = 0;
    layout.verticalSpacing = 0;
    pageAreaComposite.setLayout(layout);
    // Build the Page container
    Composite pageContainer = createPageContainer(pageAreaComposite);
    GridData pageContainerData = new GridData(GridData.FILL_BOTH);
    pageContainerData.horizontalIndent = IDialogConstants.HORIZONTAL_MARGIN;
    pageContainer.setLayoutData(pageContainerData);
    // Build the separator line
    Label bottomSeparator = new Label(parent, SWT.HORIZONTAL | SWT.SEPARATOR);
    bottomSeparator.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL));
    return composite;
}
Also used : GridLayout(org.eclipse.swt.layout.GridLayout) Control(org.eclipse.swt.widgets.Control) Composite(org.eclipse.swt.widgets.Composite) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) Label(org.eclipse.swt.widgets.Label) GridData(org.eclipse.swt.layout.GridData)

Example 62 with GridLayout

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

the class NewTmDbImportPage method createControl.

/**
	 * Create contents of the wizard.
	 * @param parent
	 */
public void createControl(Composite parent) {
    Composite container = new Composite(parent, SWT.NULL);
    setControl(container);
    container.setLayout(new GridLayout(3, false));
    Label lblTmx = new Label(container, SWT.NONE);
    lblTmx.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
    lblTmx.setText(Messages.getString("wizard.NewTmDbImportPage.lblTmx"));
    tmxFileText = new Text(container, SWT.BORDER);
    tmxFileText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
    tmxFileText.setEditable(false);
    Button tmxFileBorwserBtn = new Button(container, SWT.NONE);
    tmxFileBorwserBtn.setText(Messages.getString("wizard.NewTmDbImportPage.tmxFileBorwserBtn"));
    tmxFileBorwserBtn.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent e) {
            FileDialog dlg = new FileDialog(getShell());
            String[] filterExt = { "*.tmx;*.xlsx;*.txt" };
            dlg.setFilterExtensions(filterExt);
            String path = dlg.open();
            if (path != null) {
                tmxFileText.setText(path);
            }
        }
    });
}
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) Label(org.eclipse.swt.widgets.Label) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) Text(org.eclipse.swt.widgets.Text) FileDialog(org.eclipse.swt.widgets.FileDialog)

Example 63 with GridLayout

use of org.eclipse.swt.layout.GridLayout 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)

Example 64 with GridLayout

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

the class XLIFFEditorStatusLineItem method fill.

public void fill(Composite parent) {
    statusLine = parent;
    new Label(parent, SWT.SEPARATOR);
    Composite container = new Composite(parent, SWT.NONE);
    GridLayout gl = new GridLayout(1, false);
    gl.marginWidth = 0;
    gl.marginHeight = 0;
    gl.marginTop = 0;
    gl.marginRight = 0;
    gl.marginBottom = 0;
    container.setLayout(gl);
    label = new Label(container, SWT.SHADOW_NONE);
    label.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, true, 1, 1));
    label.setAlignment(SWT.CENTER);
    label.setText(text);
    if (image != null) {
        label.setImage(image);
        label.setToolTipText(text);
    }
//		Point preferredSize = label.computeSize(SWT.DEFAULT, SWT.DEFAULT);
//		int widthHint = preferredSize.x;
//		int heightHint = preferredSize.y;
//		if (widthHint < 0) {
//			// Compute the size base on 'charWidth' average char widths
//			GC gc = new GC(statusLine);
//			gc.setFont(statusLine.getFont());
//			FontMetrics fm = gc.getFontMetrics();
//			widthHint = fm.getAverageCharWidth() * 40;
//			heightHint = fm.getHeight();
//			gc.dispose();
//		}
//		StatusLineLayoutData data = new StatusLineLayoutData();
//		data.widthHint = widthHint;
//		label.setLayoutData(data);
//		StatusLineLayoutData data = new StatusLineLayoutData();
//		data.heightHint = heightHint;
//		speLb.setLayoutData(data);
}
Also used : GridLayout(org.eclipse.swt.layout.GridLayout) Composite(org.eclipse.swt.widgets.Composite) Label(org.eclipse.swt.widgets.Label) GridData(org.eclipse.swt.layout.GridData)

Example 65 with GridLayout

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

the class AddOrUpdateLanguageDialog method createDialogArea.

@Override
protected Control createDialogArea(Composite parent) {
    Composite tparent = (Composite) super.createDialogArea(parent);
    GridData data = new GridData(SWT.FILL, SWT.FILL, true, true);
    tparent.setLayoutData(data);
    GridLayout layout = new GridLayout(3, false);
    tparent.setLayout(layout);
    GridData txtData = new GridData(GridData.FILL_HORIZONTAL);
    txtData.horizontalSpan = 2;
    Label lbl = new Label(tparent, SWT.NONE);
    lbl.setText(Messages.getString("languagecode.AddOrUpdateLanguageDialog.lblLangImage"));
    GridDataFactory.swtDefaults().align(SWT.RIGHT, SWT.CENTER).applyTo(lbl);
    imageLabel = new Label(tparent, SWT.NONE);
    GridData imGd = new GridData();
    imGd.widthHint = 16;
    imGd.heightHint = 12;
    imageLabel.setLayoutData(imGd);
    imageLabel.setBackground(Display.getDefault().getSystemColor(SWT.COLOR_WHITE));
    try {
        String bundlePath = FileLocator.toFileURL(Activator.getDefault().getBundle().getEntry("")).getPath();
        if (this.imagePath != null && !this.imagePath.equals("")) {
            String imagePath = bundlePath + this.imagePath;
            if (image != null && !image.isDisposed()) {
                image.dispose();
            }
            image = new Image(getShell().getDisplay(), imagePath);
        }
        if (image != null) {
            ImageData imgData = image.getImageData().scaledTo(16, 12);
            if (image != null && !image.isDisposed()) {
                image.dispose();
            }
            image = new Image(getShell().getDisplay(), imgData);
            imageLabel.setData(this.imagePath);
        } else {
            if (image != null && !image.isDisposed()) {
                image.dispose();
            }
            image = new Image(getShell().getDisplay(), bundlePath + ImageConstant.LANG_EMPTYPIC);
        }
        imageLabel.setImage(image);
    } catch (IOException e) {
        e.printStackTrace();
    }
    imageLabel.setToolTipText(Messages.getString("languagecode.AddOrUpdateLanguageDialog.imageLabel"));
    imageLabel.addListener(SWT.MouseUp, new Listener() {

        public void handleEvent(Event event) {
            FileDialog dlg = new FileDialog(getShell());
            dlg.setFilterExtensions(new String[] { "*.png" });
            String path = dlg.open();
            if (path != null) {
                ImageData data = new ImageData(path).scaledTo(16, 12);
                if (image != null && !image.isDisposed()) {
                    image.dispose();
                }
                image = new Image(getShell().getDisplay(), data);
                imageLabel.setImage(image);
                imageLabel.setData(path);
            }
        }
    });
    new Label(tparent, SWT.NONE).setText(Messages.getString("languagecode.AddOrUpdateLanguageDialog.lblImage"));
    lbl = new Label(tparent, SWT.NONE);
    lbl.setText(Messages.getString("languagecode.AddOrUpdateLanguageDialog.txtCode"));
    GridDataFactory.swtDefaults().align(SWT.RIGHT, SWT.CENTER).applyTo(lbl);
    txtCode = new Text(tparent, SWT.BORDER);
    txtCode.setLayoutData(txtData);
    txtCode.setText(strCode == null ? "" : strCode);
    lbl = new Label(tparent, SWT.NONE);
    lbl.setText(Messages.getString("languagecode.AddOrUpdateLanguageDialog.txtName"));
    GridDataFactory.swtDefaults().align(SWT.RIGHT, SWT.CENTER).applyTo(lbl);
    txtName = new Text(tparent, SWT.BORDER);
    txtName.setLayoutData(txtData);
    txtName.setText(strName == null ? "" : strName);
    lbl = new Label(tparent, SWT.NONE);
    lbl.setText(Messages.getString("languagecode.AddOrUpdateLanguageDialog.isBidi"));
    GridDataFactory.swtDefaults().align(SWT.RIGHT, SWT.CENTER).applyTo(lbl);
    btnIsBidi = new Button(tparent, SWT.RADIO);
    btnIsBidi.setText(Messages.getString("languagecode.AddOrUpdateLanguageDialog.btnIsBidi"));
    btnIsNotBidi = new Button(tparent, SWT.RADIO);
    btnIsNotBidi.setText(Messages.getString("languagecode.AddOrUpdateLanguageDialog.btnIsNotBidi"));
    if (blnIsBidi) {
        btnIsBidi.setSelection(true);
    } else {
        btnIsNotBidi.setSelection(true);
    }
    tparent.computeSize(SWT.DEFAULT, SWT.DEFAULT);
    txtCode.forceFocus();
    txtCode.selectAll();
    return tparent;
}
Also used : Listener(org.eclipse.swt.widgets.Listener) Composite(org.eclipse.swt.widgets.Composite) Label(org.eclipse.swt.widgets.Label) Text(org.eclipse.swt.widgets.Text) IOException(java.io.IOException) Image(org.eclipse.swt.graphics.Image) GridLayout(org.eclipse.swt.layout.GridLayout) Button(org.eclipse.swt.widgets.Button) ImageData(org.eclipse.swt.graphics.ImageData) GridData(org.eclipse.swt.layout.GridData) Event(org.eclipse.swt.widgets.Event) 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