Java Code Examples for org.eclipse.swt.widgets.Label.setImage()

The following are Jave code examples for showing how to use setImage() of the org.eclipse.swt.widgets.Label class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: ide-plugins   File: PluginDialog.java   View Source Code Vote up 6 votes
protected void createTopContent(String title, InputStream imageName) {
    Composite top = new Composite(composite, SWT.NONE);

    top.setLayout(new GridLayout(2, false));
    top.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
    top.setBackground(display.getSystemColor(SWT.COLOR_WHITE));
    
    final Image image = new Image(top.getDisplay(), imageName);
    Image resized = resizeImage(image, 48, 48);
    Label labelImage = new Label(top, SWT.CENTER);
    labelImage.setImage(resized);
    
    Label label = new Label(top, SWT.NONE);
    label.setText(title);
    final Font newFont = new Font(display, fontName, getTitleFontSize(), SWT.NORMAL);
    label.setFont(newFont);
    label.setBackground(rowColorSelection);
    
    createLineContent();
    
    top.addDisposeListener(e -> {
        newFont.dispose();
        resized.dispose();
    });
}
 
Example 2
Project: scanning   File: XcenDiagram.java   View Source Code Vote up 6 votes
@Override
public void createPartControl(Composite parent) {

       if (system==null) {
	parent.setLayout(new GridLayout(1, false));
	final Label msg = new Label(parent, SWT.WRAP);
	msg.setText("No plotting system found available.\nThere are probably no bundles providing plotting in the run configuration.\nThese may be obtained from dawn p2, for instance:\nhttp://opengda.org/DawnDiamond/2.0/updates/release/\n\nA static image is shown for our enjoyment.");
	final Label img = new Label(parent, SWT.NONE);
	img.setImage(XcenActivator.getImageDescriptor("icons/xstall.png").createImage());
	return;
       }
       super.createPartControl(parent);


       // TODO Hard coded an x-stall, should come from current data acquisition.
       try {
		final File loc = new File(BundleUtils.getBundleLocation(XcenActivator.PLUGIN_ID), "icons/xstall.png");
		final IDataset image = service.getDataset(loc.getAbsolutePath(), new IMonitor.Stub());

		system.createPlot2D(image, null, new NullProgressMonitor());

       } catch (Exception ne) {
	logger.error("Cannot load dataset!", ne);
       }
}
 
Example 3
Project: SWET   File: TipDayEx.java   View Source Code Vote up 6 votes
private void buildLeftColumn() {
	final Composite composite = new Composite(this.shell, SWT.NONE);
	final GridData gd = new GridData(GridData.FILL, GridData.BEGINNING, false,
			true, 1, 1);
	composite.setLayoutData(gd);
	final FillLayout compositeLayout = new FillLayout();
	compositeLayout.marginWidth = 2;
	composite.setLayout(compositeLayout);
	final Label label = new Label(composite, SWT.NONE);
	if (this.image == null) {
		this.image = new Image(display, this.getClass().getClassLoader()
				.getResourceAsStream("images/document_wrench_color.png"));
		shell.addListener(SWT.Close, new Listener() {
			@Override
			public void handleEvent(Event event) {
				image.dispose();
			}
		});

	}
	label.setImage(this.image);
}
 
Example 4
Project: SWET   File: TipDayEx.java   View Source Code Vote up 6 votes
private void buildLeftColumn() {
	final Composite composite = new Composite(this.shell, SWT.NONE);
	final GridData gd = new GridData(GridData.FILL, GridData.BEGINNING, false,
			true, 1, 1);
	composite.setLayoutData(gd);
	final FillLayout compositeLayout = new FillLayout();
	compositeLayout.marginWidth = 2;
	composite.setLayout(compositeLayout);
	final Label label = new Label(composite, SWT.NONE);
	if (this.image == null) {
		this.image = new Image(display, this.getClass().getClassLoader()
				.getResourceAsStream("images/light1.png"));
		shell.addListener(SWT.Close, new Listener() {
			@Override
			public void handleEvent(Event event) {
				image.dispose();
			}
		});

	}
	label.setImage(this.image);
}
 
Example 5
Project: Hydrograph   File: CategoriesDialogTargetComposite.java   View Source Code Vote up 6 votes
private void createMiddleLayer() {
	Composite middleComposite = new Composite(this, SWT.NONE);
	middleComposite.setLayout(new GridLayout(1, false));
	middleComposite.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, true, 1, 1));
	
	addAllSelectedPackagesLabel = new Label(middleComposite, SWT.NONE);
	addAllSelectedPackagesLabel.setBounds(6, 70, 25, 25);
	addAllSelectedPackagesLabel.setImage(ImagePathConstant.SELECT_ALL_ICON.getImageFromRegistry());
	addAllSelectedPackagesLabel.setToolTipText("Add all packages");
	addListenerToSelectAllLable(addAllSelectedPackagesLabel);
	addAllSelectedPackagesLabel.setEnabled(false);
	
	Label dummyLabel = new Label(middleComposite, SWT.NONE);
	
	addSelectedPackagesLabel = new Label(middleComposite, SWT.NONE);
	addSelectedPackagesLabel.setBounds(6, 110, 25, 25);
	addSelectedPackagesLabel.setImage(ImagePathConstant.SELECT_ICON.getImageFromRegistry());
	addSelectedPackagesLabel.setToolTipText("Add selected packages");
	addListenerToSelectLable(addSelectedPackagesLabel);
	addSelectedPackagesLabel.setEnabled(false);
}
 
Example 6
Project: avro-schema-editor   File: SchemaViewer.java   View Source Code Vote up 6 votes
protected void createToolBarManagerWithTitle(Composite parent, ToolBarConfiguration toolBarConfiguration, String toolBarId) {
	
	Composite compo = new Composite(composite, SWT.NONE);
	GridLayout layout = new GridLayout(3, false);
	layout.marginHeight = 0;
	layout.marginWidth = 0;
	layout.verticalSpacing = 0;
	compo.setLayout(layout);
	compo.setLayoutData(new  GridData(GridData.FILL_HORIZONTAL));
	
	Label imageLabel = new Label(compo, SWT.NONE);
	imageLabel.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING));
	imageLabel.setImage(AvroSchemaEditorActivator.getNoneImage());
	toolBarImageLabels.put(toolBarId, imageLabel);
	
	Label titleLabel = new Label(compo, SWT.NONE);
	titleLabel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
	toolBarTextLabels.put(toolBarId, titleLabel);
	
	createToolBarManager(compo, toolBarConfiguration, toolBarId);
}
 
Example 7
Project: eZooKeeper   File: ZnodeNewWizardComposite.java   View Source Code Vote up 5 votes
@Override
protected void createContents() {

    ZnodeModel parentZnodeModel = getParentZnodeModel();

    Label connectionLabel = new Label(this, SWT.LEAD);
    connectionLabel.setText("Connection:");
    connectionLabel.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, false, false));

    Label connectionImageLabel = new Label(this, SWT.LEAD);
    connectionImageLabel.setImage(ZooKeeperActivator
            .getManagedImage(ZooKeeperActivator.IMAGE_KEY_OBJECT_ZOO_KEEPER_CONNECTION));
    connectionImageLabel.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, false, false));

    Label connectionValueLabel = new Label(this, SWT.LEAD);
    connectionValueLabel.setText(parentZnodeModel.getOwnerModel().getKey().getName());
    connectionValueLabel.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
    addControl(CONTROL_NAME_CONNECTION_LABEL, connectionValueLabel);
    addControlDecoration(CONTROL_NAME_CONNECTION_LABEL, connectionValueLabel);

    Label parentLabel = new Label(this, SWT.LEAD);
    parentLabel.setText("Parent:");
    parentLabel.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, false, false));

    Label parentImageLabel = new Label(this, SWT.LEAD);
    parentImageLabel.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, false, false));
    addControl(CONTROL_NAME_PARENT_IMAGE_LABEL, parentImageLabel);
    updateParentZnodeImage();

    Label parentValueLabel = new Label(this, SWT.LEAD);
    parentValueLabel.setText(parentZnodeModel.getData().getPath());
    parentValueLabel.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
    addControl(CONTROL_NAME_PARENT_PATH_LABEL, parentValueLabel);
    addControlDecoration(CONTROL_NAME_PARENT_PATH_LABEL, parentValueLabel);

}
 
Example 8
Project: eZooKeeper   File: ZnodeNewWizardComposite.java   View Source Code Vote up 5 votes
private void updateParentZnodeImage() {
    ZnodeModel parentZnodeModel = getParentZnodeModel();
    Label parentImageLabel = (Label) getControl(CONTROL_NAME_PARENT_IMAGE_LABEL);
    if (parentImageLabel != null && !parentImageLabel.isDisposed()) {
        parentImageLabel.setImage(ZooKeeperActivator.getZnodeSmallImage(parentZnodeModel.getData()));
    }
}
 
Example 9
Project: Hydrograph   File: ParameterGridDialog.java   View Source Code Vote up 5 votes
private void attachRemoveRowButton(Composite composite) {
	Label btnRemove = new Label(composite, SWT.NONE);
	btnRemove.setLayoutData(getGridControlButtonLayout());
	btnRemove.setText("");
	btnRemove.setImage(ImagePathConstant.DELETE_BUTTON.getImageFromRegistry());
	addRemoveRowButtonListener(btnRemove);
}
 
Example 10
Project: Hydrograph   File: ParameterGridDialog.java   View Source Code Vote up 5 votes
private void attachAddRowButton(Composite composite) {
	Label btnAdd = new Label(composite, SWT.NONE);
	GridData gd_btnAdd = getGridControlButtonLayout();
	btnAdd.setLayoutData(gd_btnAdd);
	btnAdd.setText("");
	btnAdd.setImage(ImagePathConstant.ADD_BUTTON.getImageFromRegistry());
	
	attachAddRowButtonListener(btnAdd);
}
 
Example 11
Project: Hydrograph   File: ELTSWTWidgets.java   View Source Code Vote up 5 votes
public Label labelWidget(Composite parent, int style, int[] bounds,
		String value, Image image) {
	Label label = new Label(parent, style);
	label.setBounds(bounds[0], bounds[1], bounds[2], bounds[3]);
	label.setText(value);
	label.setImage(image);

	return label;
}
 
Example 12
Project: Hydrograph   File: HiveOutputFieldDialog.java   View Source Code Vote up 5 votes
protected Composite addButtonPanel(Composite container) {
	Composite composite_1 = new Composite(container, SWT.NONE);
	composite_1.setLayout(new GridLayout(5, false));
	ColumnLayoutData cld_composite_1 = new ColumnLayoutData();
	cld_composite_1.horizontalAlignment = ColumnLayoutData.RIGHT;
	cld_composite_1.heightHint = 28;
	composite_1.setLayoutData(cld_composite_1);

	Label addButton = new Label(composite_1, SWT.NONE);
	addButton.setToolTipText(Messages.ADD_KEY_SHORTCUT_TOOLTIP);
	addButton.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
	addButton.setImage(ImagePathConstant.ADD_BUTTON.getImageFromRegistry());
	attachAddButtonListern(addButton);

	deleteButton = new Label(composite_1, SWT.NONE);
	deleteButton.setToolTipText(Messages.DELETE_KEY_SHORTCUT_TOOLTIP);
	deleteButton.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
	deleteButton.setImage(ImagePathConstant.DELETE_BUTTON.getImageFromRegistry());
	attachDeleteButtonListener(deleteButton);

	upButton = new Label(composite_1, SWT.NONE);
	upButton.setToolTipText(Messages.MOVE_UP_KEY_SHORTCUT_TOOLTIP);
	upButton.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
	upButton.setImage(ImagePathConstant.MOVEUP_BUTTON.getImageFromRegistry());
	attachUpButtonListener(upButton);

	downButton = new Label(composite_1, SWT.NONE);
	downButton.setToolTipText(Messages.MOVE_DOWN_KEY_SHORTCUT_TOOLTIP);
	downButton.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
	downButton.setImage(ImagePathConstant.MOVEDOWN_BUTTON.getImageFromRegistry());
	attachDownButtonListerner(downButton);
	deleteButton.setEnabled(false);
	upButton.setEnabled(false);
	downButton.setEnabled(false);
	return composite_1;
}
 
Example 13
Project: Hydrograph   File: ViewDataPreferencesDialog.java   View Source Code Vote up 5 votes
/**
 * Create contents of the button bar.
 * 
 * @param parent
 */
@Override
protected void createButtonsForButtonBar(Composite parent) {
	parent.setLayout(new GridLayout(1, false));
	Composite composite = new Composite(parent, SWT.NONE);
	composite.setLayout(new GridLayout(2, false));
	composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));

	warningImageLabel = new Label(composite, SWT.NONE);
	warningImageLabel.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, true, 1, 1));
	
	warningImageLabel.setImage(ImagePathConstant.WARNING_ICON.getImageFromRegistry());

	warningLabel = new Label(composite, SWT.NONE);
	warningLabel.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, true, true, 1, 1));
	warningLabel.setText(Messages.WARNING_MESSAGE);

	warningLabel.setVisible(false);
	warningImageLabel.setVisible(false);
	if (!delimiterTextBox.getText().equalsIgnoreCase(",")
			|| !quoteCharactorTextBox.getText().equalsIgnoreCase("\"")) {
		warningImageLabel.setVisible(true);
		warningLabel.setVisible(true);
	}
	createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, true);
	createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false);
}
 
Example 14
Project: BiglyBT   File: ImageLoader.java   View Source Code Vote up 5 votes
/**
 * @param label
 * @param key
 *
 * @since 4.0.0.5
 */
public void setLabelImage(Label label, final String key) {
	Image bg = getImage(key);
	label.setImage(bg);
	label.addDisposeListener(new DisposeListener() {
		@Override
		public void widgetDisposed(DisposeEvent e) {
			releaseImage(key);
		}
	});
}
 
Example 15
Project: neoscada   File: DataItemToolTip.java   View Source Code Vote up 4 votes
@Override
protected Composite createToolTipContentArea ( final Event event, final Composite parent )
{
    parent.setLayout ( new FillLayout () );
    final Composite wrapper = new Composite ( parent, SWT.NONE );

    wrapper.addDisposeListener ( new DisposeListener () {

        @Override
        public void widgetDisposed ( final DisposeEvent e )
        {
            DataItemToolTip.this.resourceManager.dispose ();
        }
    } );

    final GridLayout layout = new GridLayout ( 2, false );
    layout.marginHeight = 10;
    layout.marginWidth = 10;
    layout.horizontalSpacing = 20;
    layout.verticalSpacing = 20;

    wrapper.setLayout ( layout );
    wrapper.setBackground ( wrapper.getDisplay ().getSystemColor ( SWT.COLOR_WHITE ) );
    wrapper.setBackgroundMode ( SWT.INHERIT_DEFAULT );

    this.headerLabel = new Label ( wrapper, SWT.NONE );
    this.headerLabel.setText ( this.item.getId () );
    this.headerLabel.setLayoutData ( new GridData ( SWT.FILL, SWT.FILL, true, false, 2, 1 ) );
    this.headerLabel.setFont ( JFaceResources.getHeaderFont () );

    final Label warnIcon = new Label ( wrapper, SWT.NONE );
    warnIcon.setLayoutData ( new GridData ( SWT.CENTER, SWT.CENTER, false, false ) );
    warnIcon.setImage ( Activator.getDefault ().getImageRegistry ().get ( Activator.IMG_WARN_BIG ) );

    this.text = new StyledText ( wrapper, SWT.MULTI );
    this.text.setLayoutData ( new GridData ( SWT.FILL, SWT.FILL, true, true ) );

    if ( this.currentText != null )
    {
        this.text.setText ( this.currentText.getString () );
        this.text.setStyleRanges ( this.currentText.getStyleRanges () );
    }

    return wrapper;
}
 
Example 16
Project: neoscada   File: DataItemHeaderLabel.java   View Source Code Vote up 4 votes
private static void applyWidget ( final Label label, final CurrentStyle style )
{
    applyWidget ( (Control)label, style );
    label.setImage ( style.image );
}
 
Example 17
Project: Hydrograph   File: SaveJobFileBeforeRunDialog.java   View Source Code Vote up 4 votes
/**
 * Create contents of the dialog.
 * @param parent
 */
@Override
protected Control createDialogArea(Composite parent) {
	Composite container = (Composite) super .createDialogArea(parent);
	container.getShell().setText(Messages.CONFIRM_TO_SAVE_JOB_BEFORE_RUN_DIALOG_TITLE);
	
	container.setLayout(new GridLayout(1, false));
	
	Composite composite = new Composite(container, SWT.NONE);
	composite.setLayout(new GridLayout(2, false));
	composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
	
	Composite messageComposite = new Composite(composite, SWT.NONE);
	messageComposite.setLayout(new GridLayout(2, false));
	GridData gd_messageComposite = new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1);
	gd_messageComposite.heightHint = 34;
	messageComposite.setLayoutData(gd_messageComposite);
	
	Label iconLabel = new Label(messageComposite, SWT.NONE);
	iconLabel.setImage(getSWTImage());
	
	Label messageLabel = new Label(messageComposite, SWT.WRAP);
	messageLabel.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, true, 1, 1));
	
	messageLabel.setText(messageText);
	new Label(composite, SWT.NONE);
	
	Composite alwaysSaveComposite = new Composite(composite, SWT.NONE);
	alwaysSaveComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
	alwaysSaveComposite.setLayout(new GridLayout(3, false));
	
	Label blankSpaceLabel = new Label(alwaysSaveComposite, SWT.NONE);
	
	
	alwaysSaveCheckButton = new Button(alwaysSaveComposite, SWT.CHECK);
	alwaysSaveCheckButton.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
	alwaysSaveCheckButton.setText("Always save job before running");
	new Label(alwaysSaveComposite, SWT.NONE);
	new Label(composite, SWT.NONE);

	return container;
}
 
Example 18
Project: pandionj   File: PandionJView.java   View Source Code Vote up 4 votes
private Composite createIntroScreen(Composite parent) {
	Composite introComp = new Composite(parent, SWT.NONE);
	introComp.setLayoutData(new GridData(GridData.FILL_BOTH));
	introComp.setLayout(new GridLayout());

	Image image = PandionJUI.getImage("pandionj.png");
	Label imageLabel = new Label(introComp, SWT.NONE);
	imageLabel.setImage(image);
	imageLabel.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, true, true));

	Label versionLabel = new Label(introComp, SWT.NONE);
	versionLabel.setText(getTitleToolTip());
	versionLabel.setLayoutData(new GridData(SWT.CENTER, SWT.BEGINNING, false, false));

	Link pluginLabel = new Link(introComp, SWT.NONE);
	pluginLabel.setText("<a>view installed tags (@)</a>");
	pluginLabel.setLayoutData(new GridData(SWT.CENTER, SWT.BEGINNING, false, false));
	pluginLabel.addSelectionListener(new SelectionAdapter() {
		@Override
		public void widgetSelected(SelectionEvent e) {
			String info = "";
			
			for (ExtensionManager.TagDescription desc : ExtensionManager.getTagDescriptions()) {
				String where = desc.description;
				if(where == null)
					where = "";
				else
					where += "\n";
				info += desc.tag + "\n" + where + "\n";
			}
			MessageDialog.openInformation(Display.getDefault().getActiveShell(), "Installed tags", info);
		}
	});

	
	Label labelInit = new Label(introComp, SWT.WRAP);
	FontManager.setFont(labelInit, PandionJConstants.MESSAGE_FONT_SIZE, FontStyle.ITALIC);
	labelInit.setForeground(ColorConstants.gray);
	labelInit.setText(PandionJConstants.Messages.START);
	labelInit.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, true, true));

	return introComp;
}