Search in sources :

Example 11 with ImageData

use of org.eclipse.swt.graphics.ImageData in project translationstudio8 by heartsome.

the class Activator method getIconDescriptor.

/**
	 * 提供一个图片文件对插件的相对路径,返回该图片被伸缩变换为16*16像素的描述信息。
	 * @param path
	 *            the path
	 * @return the icon descriptor
	 */
public static ImageDescriptor getIconDescriptor(String path) {
    ImageDescriptor image = getImageDescriptor(path);
    ImageData data = image.getImageData();
    data = data.scaledTo(16, 16);
    image = ImageDescriptor.createFromImageData(data);
    return image;
}
Also used : ImageData(org.eclipse.swt.graphics.ImageData) ImageDescriptor(org.eclipse.jface.resource.ImageDescriptor)

Example 12 with ImageData

use of org.eclipse.swt.graphics.ImageData in project translationstudio8 by heartsome.

the class Activator method getIconDescriptor.

/**
	 * 提供一个图片文件对插件的相对路径,返回该图片被伸缩变换为16*16像素的描述信息。
	 * @param path
	 *            the path
	 * @return the icon descriptor
	 */
public static ImageDescriptor getIconDescriptor(String path) {
    ImageDescriptor image = getImageDescriptor(path);
    ImageData data = image.getImageData();
    data = data.scaledTo(16, 16);
    image = ImageDescriptor.createFromImageData(data);
    return image;
}
Also used : ImageData(org.eclipse.swt.graphics.ImageData) ImageDescriptor(org.eclipse.jface.resource.ImageDescriptor)

Example 13 with ImageData

use of org.eclipse.swt.graphics.ImageData in project translationstudio8 by heartsome.

the class Activator method getIconDescriptor.

/**
	 * 提供一个图片文件对插件的相对路径,返回该图片被伸缩变换为16*16像素的描述信息。
	 * @param path
	 *            the path
	 * @return the icon descriptor
	 */
public static ImageDescriptor getIconDescriptor(String path) {
    ImageDescriptor image = getImageDescriptor(path);
    ImageData data = image.getImageData();
    data = data.scaledTo(16, 16);
    image = ImageDescriptor.createFromImageData(data);
    return image;
}
Also used : ImageData(org.eclipse.swt.graphics.ImageData) ImageDescriptor(org.eclipse.jface.resource.ImageDescriptor)

Example 14 with ImageData

use of org.eclipse.swt.graphics.ImageData in project translationstudio8 by heartsome.

the class Activator method getIconDescriptor.

/**
	 * 提供一个图片文件对插件的相对路径,返回该图片被伸缩变换为16*16像素的描述信息。
	 * @param path
	 *            the path
	 * @return the icon descriptor
	 */
public static ImageDescriptor getIconDescriptor(String path) {
    ImageDescriptor image = getImageDescriptor(path);
    ImageData data = image.getImageData();
    data = data.scaledTo(16, 16);
    image = ImageDescriptor.createFromImageData(data);
    return image;
}
Also used : ImageData(org.eclipse.swt.graphics.ImageData) ImageDescriptor(org.eclipse.jface.resource.ImageDescriptor)

Example 15 with ImageData

use of org.eclipse.swt.graphics.ImageData 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

ImageData (org.eclipse.swt.graphics.ImageData)54 Image (org.eclipse.swt.graphics.Image)29 Point (org.eclipse.swt.graphics.Point)15 ImageDescriptor (org.eclipse.jface.resource.ImageDescriptor)11 ByteArrayInputStream (java.io.ByteArrayInputStream)7 GC (org.eclipse.swt.graphics.GC)7 ImageLoader (org.eclipse.swt.graphics.ImageLoader)7 Display (org.eclipse.swt.widgets.Display)6 Composite (org.eclipse.swt.widgets.Composite)5 ByteArrayOutputStream (java.io.ByteArrayOutputStream)4 IOException (java.io.IOException)4 InputStream (java.io.InputStream)4 PaletteData (org.eclipse.swt.graphics.PaletteData)3 RGB (org.eclipse.swt.graphics.RGB)3 Rectangle (org.eclipse.swt.graphics.Rectangle)3 Event (org.eclipse.swt.widgets.Event)3 FileDialog (org.eclipse.swt.widgets.FileDialog)3 Listener (org.eclipse.swt.widgets.Listener)3 EImage (org.talend.commons.ui.runtime.image.EImage)3 IImage (org.talend.commons.ui.runtime.image.IImage)3