Example usage for org.eclipse.jface.resource ImageDescriptor createImage

List of usage examples for org.eclipse.jface.resource ImageDescriptor createImage

Introduction

In this page you can find the example usage for org.eclipse.jface.resource ImageDescriptor createImage.

Prototype

public Image createImage() 

Source Link

Document

Creates and returns a new SWT image for this image descriptor.

Usage

From source file:it.eng.spagobi.meta.editor.multi.BusinessTableSelectionPage.java

License:Mozilla Public License

/**
 * @param pageName/*from w  ww .j av  a2s.  co  m*/
 */
public BusinessTableSelectionPage(String pageName) {
    super(pageName);
    setTitle(RL.getString("multi.editor.wizard.businessclassselection.title"));
    setMessage(RL.getString("multi.editor.wizard.businessclassselection.message"));
    ImageDescriptor image = ImageDescriptor.createFromURL(
            (URL) RL.getImage("it.eng.spagobi.meta.editor.business.wizards.inline.selectTables"));
    if (image != null) {
        setImageDescriptor(image);
    }
    ImageDescriptor physicalTableImageDescriptor = ImageDescriptor.createFromURL(
            (URL) RL.getImage("it.eng.spagobi.meta.editor.business.wizards.inline.PhysicalTable"));
    physicalTableImage = null;
    if (physicalTableImageDescriptor != null) {
        physicalTableImage = physicalTableImageDescriptor.createImage();
    }

    ImageDescriptor dbTableImageDescriptor = ImageDescriptor.createFromURL(
            (URL) RL.getImage("it.eng.spagobi.meta.editor.business.wizards.inline.BusinessTable"));
    if (dbTableImageDescriptor != null) {
        businessTableImage = dbTableImageDescriptor.createImage();
    }

}

From source file:it.eng.spagobi.meta.editor.multi.wizards.PhysicalTableSelectionPage.java

License:Mozilla Public License

/**
 * @param pageName//from   w w w .j a  va 2  s .  c om
 */
protected PhysicalTableSelectionPage(String pageName) {
    super(pageName);
    setTitle(RL.getString("multi.editor.wizard.physicaltablesselection.title"));
    setMessage(RL.getString("multi.editor.wizard.physicaltablesselection.message"));
    ImageDescriptor image = ImageDescriptor.createFromURL(
            (URL) RL.getImage("it.eng.spagobi.meta.editor.business.wizards.inline.selectTables"));
    if (image != null) {
        setImageDescriptor(image);
    }
    ImageDescriptor physicalTableImageDescriptor = ImageDescriptor.createFromURL(
            (URL) RL.getImage("it.eng.spagobi.meta.editor.business.wizards.inline.PhysicalTable"));
    physicalTableImage = null;
    if (physicalTableImageDescriptor != null) {
        physicalTableImage = physicalTableImageDescriptor.createImage();
    }

    ImageDescriptor dbTableImageDescriptor = ImageDescriptor.createFromURL(
            (URL) RL.getImage("it.eng.spagobi.meta.editor.business.wizards.inline.DatabaseTable"));
    if (dbTableImageDescriptor != null) {
        dbTableImage = dbTableImageDescriptor.createImage();
    }

    dseBridge = new DSEBridge();

}

From source file:it.eng.spagobi.meta.editor.physical.wizards.inline.SelectPhysicalTablesWizardPage.java

License:Mozilla Public License

protected SelectPhysicalTablesWizardPage(String pageName, PhysicalModel physicalModel,
        List<String> missingTablesNames) {
    super(pageName);
    setTitle(RL.getString("physical.editor.wizard.update.selecttables.title"));
    setDescription(RL.getString("physical.editor.wizard.update.selecttables.description"));
    ImageDescriptor image = ImageDescriptor
            .createFromURL((URL) RL.getImage("it.eng.spagobi.meta.editor.physical.wizards.inline.updateModel"));
    if (image != null)
        setImageDescriptor(image);/* ww  w.j a  v  a2  s . co m*/

    ImageDescriptor physicalTableImageDescriptor = ImageDescriptor.createFromURL(
            (URL) RL.getImage("it.eng.spagobi.meta.editor.business.wizards.inline.PhysicalTable"));
    if (physicalTableImageDescriptor != null) {
        physicalTableImage = physicalTableImageDescriptor.createImage();
    }
    ImageDescriptor dbTableImageDescriptor = ImageDescriptor.createFromURL(
            (URL) RL.getImage("it.eng.spagobi.meta.editor.business.wizards.inline.DatabaseTable"));
    if (dbTableImageDescriptor != null) {
        dbTableImage = dbTableImageDescriptor.createImage();
    }

    this.physicalModel = physicalModel;
    this.missingTablesNames = missingTablesNames;
}

From source file:it.eng.spagobi.studio.core.util.SdkFunctionalityTreeGenerator.java

License:Mozilla Public License

private void createDocumentsList(TreeItem parent, Document doc) {
    TreeItem currDoc = new TreeItem(parent, SWT.CHECK);
    currDoc.setText(doc.getName());/*from   w w  w.  j  a  v a2  s  . c o  m*/
    currDoc.setData(doc);
    if (doc.getType() != null) {
        ImageDescriptor descriptor = imageDescriptors.get(doc.getType().toUpperCase());
        if (descriptor != null) {
            currDoc.setImage(descriptor.createImage());
        }
    }
}

From source file:it.rcpvision.emf.components.runtime.ui.PluginImageHelper.java

License:Open Source License

/**
 * Returns the image associated with the given image descriptor.
 * /*  w  w  w. ja  va2 s . c o  m*/
 * @param descriptor
 *            the image descriptor for which the helper manages an image, or <code>null</code> for a missing image
 *            descriptor
 * @return the image associated with the image descriptor or <code>null</code> if the image descriptor can't create
 *         the requested image.
 */
public Image getImage(ImageDescriptor descriptor) {
    if (descriptor == null) {
        descriptor = ImageDescriptor.getMissingImageDescriptor();
    }

    Image result = registry.get(descriptor);
    if (result != null) {
        return result;
    }
    result = descriptor.createImage();
    if (result != null) {
        registry.put(descriptor, result);
    }
    return result;
}

From source file:it.rcpvision.emf.components.runtime.ui.PluginImageHelper.java

License:Open Source License

public Image getImage(String imageName) {
    String imgname = imageName == null ? defaultImage : imageName;
    if (imgname != null) {
        Image result = null;/*from  w ww .j  av  a2 s .  c  om*/
        URL imgUrl = getPlugin().getBundle().getEntry(getPathSuffix() + imgname);
        if (imgUrl != null) {
            ImageDescriptor id = null;
            result = getPlugin().getImageRegistry().get(imgUrl.toExternalForm());
            if (result == null) {
                id = ImageDescriptor.createFromURL(imgUrl);
                if (id != null) {
                    result = id.createImage();
                    getPlugin().getImageRegistry().put(imgUrl.toExternalForm(), result);
                }
            }
            return result;
        }
        if (!imgname.equals(notFound)) {
            return getImage(notFound);
        }
    }
    return null;
}

From source file:it.uniba.di.cdg.econference.planningpoker.ui.dialogs.DefaultDeckEditorDialog.java

License:Open Source License

@Override
protected Control createDialogArea(Composite parent) {
    setTitle("Change your deck configuration");

    Composite root = parent;//from   w  ww  . j ava2s.com
    root.setLayout(new GridLayout(3, false));

    GridData gd = new GridData();

    //If you want add new card, uncomment following lines
    //      gd.horizontalSpan = 3;
    //      
    //      Button newCard = new Button(root, SWT.PUSH);
    //      newCard.setText("Add new Card");
    //      newCard.setLayoutData(gd);
    //      
    //      gd = new GridData();
    gd.horizontalAlignment = SWT.CENTER;

    Label availableLabel = new Label(root, SWT.NONE);
    availableLabel.setText("Available Cards");
    availableLabel.setLayoutData(gd);

    gd = new GridData();
    gd.horizontalSpan = 2;
    gd.horizontalAlignment = SWT.CENTER;

    Label actualLabel = new Label(root, SWT.NONE);
    actualLabel.setText("Selected Cards");
    actualLabel.setLayoutData(gd);

    gd = new GridData();

    gd.verticalSpan = 4;
    gd.widthHint = 150;
    gd.heightHint = 120;

    availableCardsViewer = new TableViewer(root, SWT.FULL_SELECTION | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL);
    availableCardsViewer.getTable().setLayoutData(gd);
    availableCardsViewer.setContentProvider(contentProvider);
    availableCardsViewer.setLabelProvider(labelProvider);

    gd = new GridData();
    gd.widthHint = 30;
    gd.verticalAlignment = SWT.TOP;

    Button removeCard = new Button(root, SWT.PUSH);
    removeCard.setText("<<");
    removeCard.setLayoutData(gd);
    removeCard.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            removeSelectedCard();
        }
    });

    gd = new GridData();
    gd.verticalSpan = 4;
    gd.widthHint = 150;
    gd.heightHint = 120;

    actualCardsViewer = new TableViewer(root, SWT.FULL_SELECTION | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL);
    actualCardsViewer.getTable().setLayoutData(gd);
    actualCardsViewer.setContentProvider(contentProvider);
    actualCardsViewer.setLabelProvider(labelProvider);

    gd = new GridData();
    gd.widthHint = 30;
    gd.verticalAlignment = SWT.CENTER;

    Button upButton = new Button(root, SWT.PUSH);
    ImageDescriptor upImage = PlanningPokerPlugin.imageDescriptorFromPlugin(PlanningPokerPlugin.ID,
            "icons/deck/up16x16.png");
    if (upImage != null) {
        upButton.setImage(upImage.createImage());
    } else {
        upButton.setText("Up");
    }
    upButton.setLayoutData(gd);
    upButton.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            moveCardUp();
        }
    });

    gd = new GridData();
    gd.widthHint = 30;
    gd.verticalAlignment = SWT.CENTER;

    Button downButton = new Button(root, SWT.PUSH);
    ImageDescriptor downImage = PlanningPokerPlugin.imageDescriptorFromPlugin(PlanningPokerPlugin.ID,
            "icons/deck/down16x16.png");
    if (downImage != null) {
        downButton.setImage(downImage.createImage());
    } else {
        downButton.setText("Down");
    }
    downButton.setLayoutData(gd);
    downButton.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            moveCardDown();
        }
    });

    gd = new GridData();
    gd.widthHint = 30;
    gd.verticalAlignment = SWT.BOTTOM;

    Button addCard = new Button(root, SWT.PUSH);
    addCard.setText(">>");
    addCard.setLayoutData(gd);
    addCard.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            addSelectedCard();
        }
    });

    fillLists();

    return root;
}

From source file:it.uniba.di.cdg.xcore.ui.views.LabelProviderWithTooltips.java

License:Open Source License

/**
 * Auth: Malerba Francesco//from w  ww .  java2  s  .  co  m
 * 
 * overrided from superclass, this method provide the image associated with the tooltip that
 * comes for every buddy showing his image.
 */
public Image getToolTipImage(Object element) {
    if (element instanceof IBuddy) {
        IBuddy i = (IBuddy) element;
        String URLL = BuddyListView.getBuddy(i.getId());
        if (URLL != null) {
            System.out.print("URL OF " + i.getId() + " IS " + URLL + " AND HIS BUDDYNAME IS " + i.getName());
            ImageDescriptor des;
            try {
                des = ImageDescriptor.createFromURL(new URL(URLL));
                Image w = des.createImage();
                return w;
            } catch (MalformedURLException e) {
                e.printStackTrace();
            }
        } else {
            return UiPlugin.getDefault().getImageDescriptor(IImageResources.BUDDYDEFAULTIMAGE).createImage();
        }

    }
    return null;

}

From source file:it.uniba.di.cdg.xcore.ui.wizards.GMailPage.java

License:Open Source License

/**
 * Show the form/*from w  ww . ja v  a  2  s.  c o  m*/
 * 
 * @see WizardPage#createControl(Composite)
 */
public void createControl(final Composite parent) {
    /* Search data in preferences */
    Preferences preferences = ConfigurationScope.INSTANCE
            .getNode(IConfigurationConstant.CONFIGURATION_NODE_QUALIFIER);
    Preferences gmailPref = preferences.node(IConfigurationConstant.GMAIL);
    String usernamePref = gmailPref.get(IConfigurationConstant.USERNAME, "");
    String passwordPref = gmailPref.get(IConfigurationConstant.PASSWORD, "");

    /* Setup container layout */
    Composite container = new Composite(parent, SWT.NULL);
    org.eclipse.swt.layout.GridLayout g = new GridLayout();
    g.numColumns = 9;
    container.setLayout(g);
    setControl(container);

    /* Setup group layout */
    Group gmailGroup = new Group(container, SWT.SHADOW_IN);
    gmailGroup.setText("GMail account data");

    /* Add username label */
    GridLayout gl_gmailGroup = new GridLayout(2, false);
    gmailGroup.setLayout(gl_gmailGroup);
    Label usernameLabel = new Label(gmailGroup, SWT.NONE);
    usernameLabel.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
    usernameLabel.setText("Username:");

    /* Add username text line */
    username = new Text(gmailGroup, SWT.BORDER);
    GridData gd_username = new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1);
    gd_username.widthHint = 179;
    username.setLayoutData(gd_username);
    username.setText(usernamePref);
    username.addListener(SWT.Modify, new Listener() {

        /* Checks the validity of the data if it changes */
        @Override
        public void handleEvent(Event event) {
            dataControl();
        }
    });
    username.addListener(SWT.FocusOut, new Listener() {

        /* Add @gmail.com suffix to username if necessary */
        @Override
        public void handleEvent(Event event) {
            String usernameRegex = "[a-zA-Z0-9._%-]+";
            Pattern usernamePattern = Pattern.compile(usernameRegex);
            Matcher usernameMatcher = usernamePattern.matcher(username.getText());

            if (usernameMatcher.matches()) {
                username.setText(username.getText() + "@gmail.com");
            }
        }
    });

    /* Add a spacer */
    new Label(gmailGroup, SWT.NONE);
    new Label(gmailGroup, SWT.NONE);
    Label spacer1Label = new Label(gmailGroup, SWT.NONE);
    spacer1Label.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false, 2, 1));

    /* Add password label */
    Label passwordLabel = new Label(gmailGroup, SWT.NONE);
    passwordLabel.setText("Password:");

    /* Add password text line */
    password = new Text(gmailGroup, SWT.BORDER);
    password.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
    password.setEchoChar('*');
    password.setText(passwordPref);
    password.addListener(SWT.Modify, new Listener() {

        /* Checks the validity of the data if it changes */
        @Override
        public void handleEvent(Event event) {
            dataControl();
        }
    });

    new Label(gmailGroup, SWT.NONE);
    new Label(gmailGroup, SWT.NONE);
    new Label(container, SWT.NONE);
    new Label(container, SWT.NONE);
    new Label(container, SWT.NONE);
    new Label(container, SWT.NONE);

    // creating profile info layout

    Composite composite = new Composite(container, SWT.NONE);
    GridData gd_composite = new GridData(SWT.LEFT, SWT.CENTER, false, false, 4, 2);
    gd_composite.heightHint = 105;
    gd_composite.widthHint = 179;
    composite.setLayoutData(gd_composite);

    final Label lblLoggedAs = new Label(composite, SWT.NONE);
    lblLoggedAs.setBounds(0, 59, 64, 15);
    lblLoggedAs.setText("");

    final Canvas canvas = new Canvas(composite, SWT.NONE);
    canvas.setBounds(115, 0, 64, 64);

    final Label lblName = new Label(composite, SWT.NONE);
    lblName.setBounds(0, 80, 169, 15);
    lblName.setText("");
    new Label(container, SWT.NONE);
    new Label(container, SWT.NONE);
    new Label(container, SWT.NONE);
    new Label(container, SWT.NONE);
    new Label(container, SWT.NONE);
    if (im != null) {
        GC gc = new GC(canvas);
        gc.drawImage(im, 0, 0);
        gc.dispose();
    }
    // end creating profile info layout

    // creating validate account layout
    Group validateGroup = new Group(container, SWT.SHADOW_IN);
    GridData gd_validateGroup = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1);
    gd_validateGroup.widthHint = 264;
    validateGroup.setLayoutData(gd_validateGroup);
    validateGroup.setText("Validate GoogleAccount");
    validateGroup.setLayout(new GridLayout(1, false));

    final Button validateButton = new Button(validateGroup, SWT.NONE);
    validateButton.setText("Connect Google Account");
    new Label(validateGroup, SWT.NONE);
    new Label(validateGroup, SWT.NONE);

    Label tokenLabel = new Label(validateGroup, SWT.NONE);
    tokenLabel.setText("Autentication token");

    token = new Text(validateGroup, SWT.BORDER);
    token.setText("");
    GridData gd_token = new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1);
    gd_token.widthHint = 244;
    token.setLayoutData(gd_token);
    new Label(container, SWT.NONE);
    new Label(container, SWT.NONE);
    new Label(container, SWT.NONE);
    new Label(container, SWT.NONE);
    new Label(container, SWT.NONE);
    new Label(container, SWT.NONE);
    new Label(container, SWT.NONE);
    new Label(container, SWT.NONE);

    Listener buttonListener = new Listener() {
        @Override
        public void handleEvent(Event event) {
            Auth autorizzazione = new Auth();
            if (!(tokeninserito))
                try {
                    autorizzazione.askauthorize();

                } catch (IOException e) {
                    codiceerrore = 1;
                    e.printStackTrace();
                    dataControl();

                }

            else {
                System.out.print("Trying to autorize with token");
                String s = token.getText();
                autorizzazione.authorize(s);

                // use the token
                String accesstoken = autorizzazione.getAccessToken();
                if (!(accesstoken.equals(""))) {
                    try {
                        System.out.print("Autorized, getAccessToken not empty");
                        Plus plusdausare = Plusclass.getPlus(autorizzazione);
                        Person mePerson = null;
                        mePerson = plusdausare.people().get("me").execute();

                        Plusclass.show(mePerson);
                        if (!(mePerson == null)) {
                            imageurl = mePerson.getImage().getUrl();
                            profileurl = mePerson.getUrl();
                            plusid = mePerson.getId();
                            name = mePerson.getDisplayName();
                            lblLoggedAs.setText("Logged as:");
                            lblName.setText(name);
                            ImageDescriptor i = ImageDescriptor.createFromURL(new URL(imageurl));
                            if (i == null)
                                System.out.println("image null");
                            im = i.createImage();
                            if (im == null)
                                System.out.println("immage null");

                            GC gc = new GC(canvas);
                            gc.drawImage(im, 0, 0);
                            gc.dispose();
                            setMessage("Autantication succeeded.");
                            validateButton.setEnabled(false);
                            token.setEnabled(false);
                            utenteloggato = true;
                            dataControl();
                        }
                        // gooogleplus profile is ok

                    } catch (Exception e) {

                        codiceerrore = 2;
                        validateButton.setText("Connect Google Account");
                        tokeninserito = false;
                        e.printStackTrace();
                        dataControl();
                    }
                } else {
                    // validation of token failed, re execute the connection of the account
                    codiceerrore = 3;
                    tokeninserito = false;
                    validateButton.setText("Connect Google Account");
                    dataControl();
                }

            }

        }

    };

    Listener tokenlistener = new Listener() {
        @Override
        public void handleEvent(Event event) {

            try {
                String contenutocopy;
                // read what's inside ctrl c
                Toolkit tk = Toolkit.getDefaultToolkit();
                Clipboard clipboard = tk.getSystemClipboard();
                Transferable t = clipboard.getContents(null);
                contenutocopy = (String) t.getTransferData(DataFlavor.stringFlavor);

                String contenutotoken = token.getText();

                // System.out.println("Contenct of ctrl + c: " + contenutocopy);
                if (!(contenutotoken.equals(contenutocopy))) {
                    token.setText(contenutocopy);
                }
                validateButton.setText("Validate Google Account");
                tokeninserito = true;
                setMessage("Now click on validate google account");

            } catch (UnsupportedFlavorException e) {
                setMessage(
                        "Autentication failed.\nCopy the token from the Web Image and than select the Authorizazion token field");
                e.printStackTrace();
            } catch (IOException e) {
                setMessage(
                        "Autentication failed.\nCopy the token from the Web Image and than select the Authorizazion token field");
                e.printStackTrace();
            }

        }
    };

    token.addListener(SWT.FOCUSED, tokenlistener);
    validateButton.addListener(SWT.Selection, buttonListener);

    // end validate account layout

    dataControl();
}

From source file:jbt.tools.bteditor.ApplicationIcons.java

License:Open Source License

/**
 * Loads an icon into {@link #applicationIcons} from an icon path.
 *//*from   ww  w. j ava 2s  . c  o  m*/
private static void loadIcon(String iconPath) {
    ImageDescriptor imageDescriptor = AbstractUIPlugin.imageDescriptorFromPlugin(Activator.PLUGIN_ID, iconPath);
    Image icon = imageDescriptor == null ? null : imageDescriptor.createImage();

    applicationIcons.put(iconPath, icon);
}