List of usage examples for org.eclipse.jface.resource ImageDescriptor createImage
public Image createImage()
From source file:com.nokia.sdt.component.symbian.properties.TypeDescriptors.java
License:Open Source License
private static Image loadImage(Bundle emfEditPlugin, String fileName) { Image result = null;/* ww w . j av a 2 s .c om*/ Path path = new Path("/icons/full/obj16/" + fileName); //$NON-NLS-1$ URL url = FileLocator.find(emfEditPlugin, path, null); ImageDescriptor id = ImageDescriptor.createFromURL(url); result = id.createImage(); return result; }
From source file:com.nokia.sdt.symbian.ui.appeditor.OverviewPage.java
License:Open Source License
private void updateTitleIconImage() { ImageData titleIcon = null;//from w w w. j a v a2s . c om IImagePropertyRendering ipr = new SymbianImagePropertyRendering(); Point size = iconLabel.getSize(); if (size.x == 0 || size.y == 0) { size = new Point(20, 20); iconLabel.setSize(size); } ipr.setViewableSize(null); ipr.setScaling(true); ipr.setImageProperty(appUIComponentInstance, TITLE_ICON_PROPERTY_NAME, null); titleIcon = ipr.getImageData(); if (titleIcon != null) { if (iconLabel.getImage() != null) iconLabel.getImage().dispose(); iconLabel.setImage(new Image(Display.getDefault(), titleIcon)); } else { ImageDescriptor id = ResourceManager.getPluginImageDescriptor(UIPlugin.getDefault(), "icons/iconHolder.png"); //$NON-NLS-1$ iconLabel.setImage(id.createImage()); } iconSubcomposite.layout(); }
From source file:com.nokia.testfw.resultview.ResultViewPlugin.java
License:Open Source License
public static Image getImage(String imageName) { Image image = images.get(imageName); if (image == null) { ImageDescriptor desc = getImageDescriptor(imageName); image = desc.createImage(); images.put(imageName, image);/*from w w w. j a v a 2 s. c o m*/ } return image; }
From source file:com.nokia.tools.carbide.ui.dialogs.CarbideAboutDialog.java
License:Open Source License
/** * Creates and returns the contents of the upper part of the dialog (above * the button bar). Subclasses should overide. * /*from www .ja v a2 s .co m*/ * @param parent the parent composite to contain the dialog area * @return the dialog area control */ protected Control createDialogArea(Composite parent) { // brand the about box if there is product info Image aboutImage = null; AboutItem item = null; if (product != null) { ImageDescriptor imageDescriptor = ProductProperties.getAboutImage(product); if (imageDescriptor != null) { aboutImage = imageDescriptor.createImage(); } // if the about image is small enough, then show the text if (aboutImage == null || aboutImage.getBounds().width <= MAX_IMAGE_WIDTH_FOR_TEXT) { String aboutText = ProductProperties.getAboutText(product); if (aboutText != null) { item = AboutTextManager.scan(aboutText); } } if (aboutImage != null) { images.add(aboutImage); } } // create a composite which is the parent of the top area and the bottom // button bar, this allows there to be a second child of this composite // with // a banner background on top but not have on the bottom Composite workArea = new Composite(parent, SWT.NONE); GridLayout workLayout = new GridLayout(); workLayout.marginHeight = 0; workLayout.marginWidth = 0; workLayout.verticalSpacing = 0; workLayout.horizontalSpacing = 0; workArea.setLayout(workLayout); workArea.setLayoutData(new GridData(GridData.FILL_BOTH)); // page group Color background = JFaceColors.getBannerBackground(parent.getDisplay()); Color foreground = JFaceColors.getBannerForeground(parent.getDisplay()); Composite top = (Composite) super.createDialogArea(workArea); // override any layout inherited from createDialogArea GridLayout layout = new GridLayout(); layout.marginHeight = 0; layout.marginWidth = 0; layout.verticalSpacing = 0; layout.horizontalSpacing = 0; top.setLayout(layout); top.setLayoutData(new GridData(GridData.FILL_BOTH)); top.setBackground(background); top.setForeground(foreground); // the image & text final Composite topContainer = new Composite(top, SWT.NONE); topContainer.setBackground(background); topContainer.setForeground(foreground); layout = new GridLayout(); layout.numColumns = (aboutImage == null || item == null ? 1 : 2); layout.marginWidth = 0; layout.marginHeight = 0; layout.verticalSpacing = 0; layout.horizontalSpacing = 0; topContainer.setLayout(layout); GridData data = new GridData(); data.horizontalAlignment = GridData.FILL; data.grabExcessHorizontalSpace = true; topContainer.setLayoutData(data); GC gc = new GC(parent); // arbitrary default int topContainerHeightHint = 100; try { // default height enough for 6 lines of text topContainerHeightHint = Math.max(topContainerHeightHint, gc.getFontMetrics().getHeight() * 6); } finally { gc.dispose(); } // image on left side of dialog if (aboutImage != null) { Label imageLabel = new Label(topContainer, SWT.NONE); imageLabel.setBackground(background); imageLabel.setForeground(foreground); data = new GridData(); data.horizontalAlignment = GridData.FILL; data.verticalAlignment = GridData.BEGINNING; data.grabExcessHorizontalSpace = false; imageLabel.setLayoutData(data); imageLabel.setImage(aboutImage); // topContainerHeightHint = Math.max(topContainerHeightHint, // aboutImage.getBounds().height); } // data = new GridData(); // data.horizontalAlignment = GridData.FILL; // data.verticalAlignment = GridData.FILL; // data.grabExcessHorizontalSpace = true; // data.grabExcessVerticalSpace = true; // data.heightHint = topContainerHeightHint; // topContainer.setLayoutData(data); if (item != null) { final int minWidth = 400; // This value should really be calculated // from the computeSize(SWT.DEFAULT, // SWT.DEFAULT) of all the // children in infoArea excluding the // wrapped styled text // There is no easy way to do this. final ScrolledComposite scroller = new ScrolledComposite(topContainer, SWT.V_SCROLL | SWT.H_SCROLL); data = new GridData(GridData.FILL_BOTH); data.widthHint = minWidth; scroller.setLayoutData(data); final Composite textComposite = new Composite(scroller, SWT.NONE); textComposite.setBackground(background); layout = new GridLayout(); layout.numColumns = 1; layout.marginRight = 17; layout.marginTop = 0; textComposite.setLayout(layout); data = new GridData(); data.horizontalAlignment = GridData.FILL; data.verticalAlignment = GridData.BEGINNING; data.grabExcessHorizontalSpace = true; textComposite.setLayoutData(data); // Image on the right Label textImageLabel = new Label(textComposite, SWT.NONE); URL url = BrandingProperties.getUrl(product.getProperty("aboutTextImage"), product.getDefiningBundle()); Image textImage = ImageDescriptor.createFromURL(url).createImage(); images.add(textImage); textImageLabel.setImage(textImage); textImageLabel.setBackground(background); textImageLabel.setForeground(foreground); data = new GridData(); data.horizontalAlignment = SWT.RIGHT; data.verticalIndent = 7; textImageLabel.setLayoutData(data); // Version information on the right Label versionLabel = new Label(textComposite, SWT.NONE); data = new GridData(); data.horizontalAlignment = SWT.RIGHT; data.verticalIndent = 8; versionLabel.setText(product.getProperty("versionText")); versionLabel.setBackground(background); versionLabel.setForeground(foreground); versionLabel.setLayoutData(data); String buildId = product.getProperty("buildId"); if (buildId != null && !buildId.startsWith("@")) { // don't show build id if it's not resolved, @buildId@ Label buildIdLabel = new Label(textComposite, SWT.NONE); data = new GridData(); data.horizontalAlignment = SWT.RIGHT; data.verticalIndent = 8; buildIdLabel.setText(Messages.BuildId_Label + " " + buildId); buildIdLabel.setBackground(background); buildIdLabel.setForeground(foreground); buildIdLabel.setLayoutData(data); } text = new StyledText(textComposite, SWT.MULTI | SWT.WRAP | SWT.READ_ONLY); text.setCaret(null); text.setFont(parent.getFont()); text.setText(item.getText()); text.setCursor(null); text.setBackground(background); text.setForeground(foreground); aboutTextManager = new AboutTextManager(text); aboutTextManager.setItem(item); createTextMenu(); GridData gd = new GridData(); gd.verticalAlignment = GridData.BEGINNING; gd.horizontalAlignment = GridData.FILL; gd.grabExcessHorizontalSpace = true; text.setLayoutData(gd); // Adjust the scrollbar increments scroller.getHorizontalBar().setIncrement(20); scroller.getVerticalBar().setIncrement(20); final boolean[] inresize = new boolean[1]; // flag to stop // unneccesary // recursion textComposite.addControlListener(new ControlAdapter() { public void controlResized(ControlEvent e) { if (inresize[0]) return; inresize[0] = true; // required because of bugzilla report 4579 textComposite.layout(true); // required because you want to change the height that the // scrollbar will scroll over when the width changes. int width = textComposite.getClientArea().width; Point p = textComposite.computeSize(width, SWT.DEFAULT); scroller.setMinSize(minWidth, p.y); inresize[0] = false; } }); scroller.setExpandHorizontal(true); scroller.setExpandVertical(true); Point p = textComposite.computeSize(minWidth, SWT.DEFAULT); textComposite.setSize(p.x, p.y); scroller.setMinWidth(minWidth); scroller.setMinHeight(p.y); scroller.setContent(textComposite); } // horizontal bar Label bar = new Label(workArea, SWT.HORIZONTAL | SWT.SEPARATOR); data = new GridData(); data.horizontalAlignment = GridData.FILL; bar.setLayoutData(data); String[] s = new String[1]; URL url = Platform.getBundle(Activator.PLUGIN_ID).getEntry("doc/data.html"); try { s[0] = FileLocator.toFileURL(url).toString(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } int[][] index = { { Messages.Oss_Liense_Info.indexOf("Click"), Messages.Oss_Liense_Info.length() - Messages.Oss_Liense_Info.indexOf("Click") - 1 } }; AboutItem licenceItem = new AboutItem(Messages.Oss_Liense_Info, index, s); final Composite licenceTextComposite = new Composite(workArea, SWT.NONE); licenceTextComposite.setBackground(background); layout = new GridLayout(); layout.numColumns = 1; layout.marginRight = 17; layout.marginTop = 0; licenceTextComposite.setLayout(layout); data = new GridData(); data.horizontalAlignment = GridData.FILL; data.verticalAlignment = GridData.BEGINNING; data.grabExcessHorizontalSpace = true; licenceTextComposite.setLayoutData(data); StyledText licenceText = new StyledText(licenceTextComposite, SWT.MULTI | SWT.WRAP | SWT.READ_ONLY); licenceText.setCaret(null); licenceText.setText(licenceItem.getText()); licenceText.setCursor(null); aboutTextManager = new AboutTextManager(licenceText); aboutTextManager.setItem(licenceItem); bar = new Label(workArea, SWT.HORIZONTAL | SWT.SEPARATOR); data = new GridData(); data.horizontalAlignment = GridData.FILL; bar.setLayoutData(data); AboutItem ossItem = AboutTextManager.scan(Messages.Oss_Download_Info); final Composite ossTextComposite = new Composite(workArea, SWT.NONE); ossTextComposite.setBackground(background); layout = new GridLayout(); layout.numColumns = 1; layout.marginRight = 17; layout.marginTop = 0; ossTextComposite.setLayout(layout); data = new GridData(); data.horizontalAlignment = GridData.FILL; data.verticalAlignment = GridData.BEGINNING; data.grabExcessHorizontalSpace = true; ossTextComposite.setLayoutData(data); StyledText ossText = new StyledText(ossTextComposite, SWT.MULTI | SWT.WRAP | SWT.READ_ONLY); ossText.setCaret(null); ossText.setText(licenceItem.getText()); ossText.setCursor(null); aboutTextManager = new AboutTextManager(ossText); aboutTextManager.setItem(ossItem); bar = new Label(workArea, SWT.HORIZONTAL | SWT.SEPARATOR); data = new GridData(); data.horizontalAlignment = GridData.FILL; bar.setLayoutData(data); // add image buttons for bundle groups that have them Composite bottom = (Composite) super.createDialogArea(workArea); // override any layout inherited from createDialogArea layout = new GridLayout(); bottom.setLayout(layout); data = new GridData(); data.horizontalAlignment = SWT.FILL; data.verticalAlignment = SWT.FILL; data.grabExcessHorizontalSpace = true; bottom.setLayoutData(data); createFeatureImageButtonRow(bottom); // spacer bar = new Label(bottom, SWT.NONE); data = new GridData(); data.horizontalAlignment = GridData.FILL; bar.setLayoutData(data); return workArea; }
From source file:com.nokia.tools.carbide.ui.dialogs.CarbideAboutDialog.java
License:Open Source License
private Button createFeatureButton(Composite parent, final AboutBundleGroupData info) { if (!buttonManager.add(info)) { return null; }// w w w . j a va 2s.c o m ImageDescriptor desc = info.getFeatureImage(); Image featureImage = null; Button button = new Button(parent, SWT.FLAT | SWT.PUSH); button.setData(info); featureImage = desc.createImage(); images.add(featureImage); button.setImage(featureImage); button.setToolTipText(info.getProviderName()); button.getAccessible().addAccessibleListener(new AccessibleAdapter() { /* * (non-Javadoc) * @see * org.eclipse.swt.accessibility.AccessibleAdapter#getName(org.eclipse * .swt.accessibility.AccessibleEvent) */ public void getName(AccessibleEvent e) { e.result = info.getProviderName(); } }); button.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent event) { AboutBundleGroupData[] groupInfos = buttonManager.getRelatedInfos(info); AboutBundleGroupData selection = (AboutBundleGroupData) event.widget.getData(); AboutFeaturesDialog d = new AboutFeaturesDialog(getShell(), productName, groupInfos, selection); d.open(); } }); return button; }
From source file:com.nokia.tools.s60.ide.actions.ThemeModelDropDownAction.java
License:Open Source License
public ImageDescriptor getCustomImageDescriptor(String id, String text) { FontData fd = JFaceResources.getDefaultFont().getFontData()[0]; Font bigFont = new Font(Display.getDefault(), fd.getName(), 9, SWT.BOLD); Font smallFont = new Font(Display.getDefault(), fd.getName(), 5, SWT.NORMAL); Font normalFont = new Font(Display.getDefault(), fd.getName(), 7, SWT.NORMAL); ImageDescriptor desc = S60WorkspacePlugin.getImageDescriptor("icons/platform/platform_base.png"); Image bannerImage = null;/*from ww w .ja va 2 s .c o m*/ GC imageGC = null; int logoSpace; Color color1 = new Color(Display.getDefault(), 128, 132, 135); Color color2 = new Color(Display.getDefault(), 183, 83, 176); Color color3 = new Color(Display.getDefault(), 143, 0, 96); try { bannerImage = desc.createImage(); int imageWidth = bannerImage.getBounds().width; imageGC = new GC(bannerImage); if (id.contains("60")) { logoSpace = FigureUtilities.getTextWidth("S60", bigFont) + 2; imageGC.setForeground(color1); imageGC.setFont(bigFont); imageGC.drawString("S60", 1, 1, true); } else { logoSpace = 0; } imageGC.setForeground(ColorConstants.black); imageGC.setFont(normalFont); text = filtrateText(text); int freeSpace = imageWidth - logoSpace - 2; int textWidth = FigureUtilities.getTextWidth(text, normalFont); if (textWidth > freeSpace) { text = ScreenUtil.toShorterWithDots(text, freeSpace, normalFont); textWidth = FigureUtilities.getTextWidth(text, normalFont); } int x = (int) (((freeSpace) - textWidth) / 2) + logoSpace; imageGC.drawString(text, x, 3, true); ImageData data = bannerImage.getImageData(); data.transparentPixel = new java.awt.Color(192, 192, 192).getRGB(); return ImageDescriptor.createFromImageData(data); } finally { if (imageGC != null) { imageGC.dispose(); } if (bannerImage != null) { bannerImage.dispose(); } if (bigFont != null) { bigFont.dispose(); } if (normalFont != null) { normalFont.dispose(); } if (smallFont != null) { smallFont.dispose(); } if (color1 != null) { color1.dispose(); } if (color2 != null) { color2.dispose(); } if (color3 != null) { color3.dispose(); } } }
From source file:com.nokia.tools.s60ct.resources.resources.ResourceCategories.java
License:Open Source License
public static Image loadIcon(String pathInPlugin) { ImageDescriptor desc = Activator.getImageDescriptor(pathInPlugin); if (desc != null) return desc.createImage(); return null;/*from w w w.j a v a 2 s . c o m*/ }
From source file:com.nokia.tools.startuptip.branding.BrandingUtil.java
License:Open Source License
public static Image getDialogTitleBarImage() { ImageDescriptor iDesc = StartupTipPlugin.getImageDescriptor(Settings.STARTUP_TIP_DIALOG_TITLEBAR_IMAGE); return iDesc.createImage(); }
From source file:com.nokia.tools.theme.core.ThemeLabelProvider.java
License:Open Source License
@Override public Image getImage(Object element) { if (image != null) { image.dispose();/*from w w w .j a v a 2s . c o m*/ image = null; } boolean useLocId = true; if (element instanceof ThemeData) { useLocId = ((ThemeData) element).useLocId(); } ImageDescriptor desc = getIconImageDescriptor(element, useLocId, DEFAULT_SIZE, DEFAULT_SIZE); if (desc != null) { image = desc.createImage(); } return image; }
From source file:com.nokia.tools.theme.s60.ui.cstore.CStoreManageContentDialog.java
License:Open Source License
protected void updatePreview() { IStructuredSelection sel = (IStructuredSelection) list.getSelection(); if (imagePreview.getImage() != null) imagePreview.getImage().dispose(); imagePreview.setImage(null);//from w ww . ja v a2 s . com if (sel.isEmpty()) { deleteButton.setEnabled(false); } else { deleteButton.setEnabled(true); StoredElement selected = (StoredElement) sel.getFirstElement(); ThemeData td = (ThemeData) selected.link; SkinnableEntity ske = (SkinnableEntity) td.getData(); try { EditableEntityImage img = new EditableEntityImage(ske, null, null, 150, 150, 255); ImageDescriptor imgdesc = new RenderedImageDescriptor(img.getAggregateImage()); imagePreview.setImage(imgdesc.createImage()); } catch (ThemeException e) { e.printStackTrace(); } } imagePreview.getParent().layout(true); rightComposite.layout(true); rightComposite.getParent().pack(true); }