Java Code Examples for org.eclipse.swt.graphics.Image#setBackground()

The following examples show how to use org.eclipse.swt.graphics.Image#setBackground() . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
public void
setImage(
	Image	i )
{
	if (i != null)
		i.setBackground(item.getParent().getBackground());
	item.setImage(i);
}
 
Example 2
public void createControl(Composite parent) {
	initializeDialogUnits(parent);
	Composite result= new Composite(parent, SWT.NONE);
	setControl(result);
	GridLayout layout= new GridLayout();
	layout.marginHeight= convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN) * 3 / 2;
	layout.marginWidth= convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN);
	layout.verticalSpacing= convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING);
	layout.horizontalSpacing= convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING) * 2;
	layout.numColumns= 2;
	result.setLayout(layout);

	Image image= getMessageImage();
	if (image != null) {
		Label label= new Label(result, SWT.NULL);
		image.setBackground(label.getBackground());
		label.setImage(image);
		label.setLayoutData(new GridData(
			GridData.HORIZONTAL_ALIGN_CENTER | GridData.VERTICAL_ALIGN_BEGINNING));
	}

	String message= getMessageString();
	if (message != null) {
		Label messageLabel= new Label(result, SWT.WRAP);
		messageLabel.setText(message);
		GridData data= new GridData(GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_BEGINNING);
		data.widthHint= convertHorizontalDLUsToPixels(IDialogConstants.MINIMUM_MESSAGE_AREA_WIDTH);
		messageLabel.setLayoutData(data);
		messageLabel.setFont(result.getFont());
	}
	Dialog.applyDialogFont(result);
}
 
Example 3
@Override
protected Control createMessageArea(Composite composite) {
	Image image = getImage();
	if (image != null) {
		imageLabel = new Label(composite, SWT.NULL);
		image.setBackground(imageLabel.getBackground());
		imageLabel.setImage(image);
		addAccessibleListeners(imageLabel, image);
		GridDataFactory.fillDefaults().align(SWT.CENTER, SWT.BEGINNING)
				.applyTo(imageLabel);
	}
	// create message
	if (message != null) {
		text = new StyledText(composite, getMessageLabelStyle());
		text.setBackground(composite.getBackground());
		text.setText(message);
		text.setEditable(false);
		GridDataFactory
				.fillDefaults()
				.align(SWT.FILL, SWT.BEGINNING)
				.grab(true, false)
				.hint(
						convertHorizontalDLUsToPixels(IDialogConstants.MINIMUM_MESSAGE_AREA_WIDTH),
						SWT.DEFAULT).applyTo(text);
		setStyle();
	}
	return composite;
}
 
Example 4
@Override
protected Control createMessageArea(Composite composite) {
    // create image
    Image image = getImage();
    if (image != null) {
        imageLabel = new Label(composite, SWT.NULL);
        image.setBackground(imageLabel.getBackground());
        imageLabel.setImage(image);
        GridDataFactory.fillDefaults().align(SWT.CENTER, SWT.BEGINNING).applyTo(imageLabel);
    }
    Link link = new Link(composite, SWT.WRAP);
    link.setText("Local runtime serview has been started, totally installed bundles: <a href=\"#\">" + bundlesName.length
            + "</a>.");

    link.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            ElementListSelectionDialog report = new ElementListSelectionDialog(getShell(), new LabelProvider());
            report.setTitle("Installed bundles:");
            report.setMessage("Search bundle (? = any character, * = any string):");
            report.setElements(bundlesName);
            report.open();
        }
    });
    return composite;
}
 
Example 5
@Override
protected Control createMessageArea(Composite composite) {
	Image image = getImage();
	if (image != null) {
		imageLabel = new Label(composite, SWT.NULL);
		image.setBackground(imageLabel.getBackground());
		imageLabel.setImage(image);
		addAccessibleListeners(imageLabel, image);
		GridDataFactory.fillDefaults().align(SWT.CENTER, SWT.BEGINNING)
				.applyTo(imageLabel);
	}
	// create message
	if (message != null) {
		text = new StyledText(composite, getMessageLabelStyle());
		text.setBackground(composite.getBackground());
		text.setText(message);
		text.setEditable(false);
		GridDataFactory
				.fillDefaults()
				.align(SWT.FILL, SWT.BEGINNING)
				.grab(true, false)
				.hint(
						convertHorizontalDLUsToPixels(IDialogConstants.MINIMUM_MESSAGE_AREA_WIDTH),
						SWT.DEFAULT).applyTo(text);
		setStyle();
	}
	return composite;
}
 
Example 6
Source Project: Pydev   File: MessageWizardPage.java    License: Eclipse Public License 1.0 5 votes vote down vote up
@Override
public void createControl(Composite parent) {
    initializeDialogUnits(parent);
    Composite result = new Composite(parent, SWT.NONE);
    setControl(result);
    GridLayout layout = new GridLayout();
    layout.marginHeight = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN) * 3 / 2;
    layout.marginWidth = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN);
    layout.verticalSpacing = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING);
    layout.horizontalSpacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING) * 2;
    layout.numColumns = 2;
    result.setLayout(layout);

    Image image = getMessageImage();
    if (image != null) {
        Label label = new Label(result, SWT.NULL);
        image.setBackground(label.getBackground());
        label.setImage(image);
        label.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_CENTER | GridData.VERTICAL_ALIGN_BEGINNING));
    }

    String message = getMessageString();
    if (message != null) {
        Label messageLabel = new Label(result, SWT.WRAP);
        messageLabel.setText(message);
        GridData data = new GridData(GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL
                | GridData.VERTICAL_ALIGN_BEGINNING);
        data.widthHint = convertHorizontalDLUsToPixels(IDialogConstants.MINIMUM_MESSAGE_AREA_WIDTH);
        messageLabel.setLayoutData(data);
        messageLabel.setFont(result.getFont());
    }
    Dialog.applyDialogFont(result);
}
 
Example 7
@Override
protected Control createMessageArea(final Composite composite) {
    // create composite
    // create image
    final Image image = getImage();
    if (image != null) {
        imageLabel = new Label(composite, SWT.NULL);
        image.setBackground(imageLabel.getBackground());
        imageLabel.setImage(image);
        GridDataFactory.fillDefaults().align(SWT.CENTER, SWT.BEGINNING)
                .applyTo(imageLabel);
    }
    // create message
    if (message != null) {
        final Link messageLabel = new Link(composite, getMessageLabelStyle());
        messageLabel.addSelectionListener(new SelectionAdapter() {

            @Override
            public void widgetSelected(final org.eclipse.swt.events.SelectionEvent e) {
                try {
                    java.awt.Desktop.getDesktop().browse(uri);
                } catch (final IOException e1) {
                    BonitaStudioLog.error(e1);
                }

            };
        });
        messageLabel.setText(message);
        GridDataFactory
                .fillDefaults()
                .align(SWT.FILL, SWT.BEGINNING)
                .grab(true, false)
                .hint(
                        convertHorizontalDLUsToPixels(IDialogConstants.MINIMUM_MESSAGE_AREA_WIDTH),
                        SWT.DEFAULT).applyTo(messageLabel);
    }
    return composite;
}
 
Example 8
@Override
protected Control createMessageArea(final Composite composite) {
    // create composite
    // create image
    final Image image = getImage();
    if (image != null) {
        imageLabel = new Label(composite, SWT.NULL);
        image.setBackground(imageLabel.getBackground());
        imageLabel.setImage(image);
        GridDataFactory.fillDefaults().align(SWT.CENTER, SWT.BEGINNING)
                .applyTo(imageLabel);
    }
    // create message
    if (message != null) {
        final Link messageLabel = new Link(composite, getMessageLabelStyle());
        linkSelectionListener.ifPresent(listener -> messageLabel.addListener(SWT.Selection, listener));
        messageLabel.setText(message);
        GridDataFactory
                .fillDefaults()
                .align(SWT.FILL, SWT.BEGINNING)
                .grab(true, false)
                .hint(
                        convertHorizontalDLUsToPixels(IDialogConstants.MINIMUM_MESSAGE_AREA_WIDTH),
                        SWT.DEFAULT)
                .applyTo(messageLabel);
    }
    return composite;
}
 
Example 9
@Override
protected Control createMessageArea(final Composite composite) {
    final Image image = getImage();
    if (image != null) {
        imageLabel = new Label(composite, SWT.NULL);
        image.setBackground(imageLabel.getBackground());
        imageLabel.setImage(image);
        GridDataFactory.fillDefaults().align(SWT.CENTER, SWT.BEGINNING)
                .applyTo(imageLabel);
    }
    final Link messageLabel = new Link(composite, getMessageLabelStyle());
    messageLabel.setText(NLS.bind(Messages.exitWarningMessage, new String[] { org.bonitasoft.studio.common.Messages.bonitaStudioModuleName,
            org.bonitasoft.studio.common.Messages.bonitaPortalModuleName, org.bonitasoft.studio.common.Messages.uiDesignerModuleName }));
    messageLabel.addSelectionListener(new SelectionAdapter() {

        /*
         * (non-Javadoc)
         * @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent)
         */
        @Override
        public void widgetSelected(final SelectionEvent e) {
            final BonitaPreferenceDialog dialog = new BonitaPreferenceDialog(Display.getDefault().getActiveShell());
            dialog.create();
            dialog.setSelectedPreferencePage(BonitaPreferenceDialog.DATABASE_PAGE_ID);
            dialog.open();
        }
    });
    GridDataFactory
            .fillDefaults()
            .align(SWT.FILL, SWT.BEGINNING)
            .grab(true, false)
            .hint(
                    convertHorizontalDLUsToPixels(IDialogConstants.MINIMUM_MESSAGE_AREA_WIDTH),
                    SWT.DEFAULT).applyTo(messageLabel);
    return composite;
}
 
Example 10
private void createErrorControl( Composite parent )
{
	Color bgColor = parent.getDisplay( )
			.getSystemColor( SWT.COLOR_LIST_BACKGROUND );
	Color fgColor = parent.getDisplay( )
			.getSystemColor( SWT.COLOR_LIST_FOREGROUND );

	parent.setBackground( bgColor );
	parent.setForeground( fgColor );

	GridLayout layout = new GridLayout( );

	layout.numColumns = 3;

	int spacing = 8;
	int margins = 8;
	layout.marginBottom = margins;
	layout.marginTop = margins;
	layout.marginLeft = margins;
	layout.marginRight = margins;
	layout.horizontalSpacing = spacing;
	layout.verticalSpacing = spacing;
	parent.setLayout( layout );

	Label imageLabel = new Label( parent, SWT.NONE );
	imageLabel.setBackground( bgColor );
	Image image = getImage( );
	if ( image != null )
	{
		image.setBackground( bgColor );
		imageLabel.setImage( image );
		imageLabel.setLayoutData( new GridData( GridData.HORIZONTAL_ALIGN_CENTER
				| GridData.VERTICAL_ALIGN_BEGINNING ) );
	}

	Text text = new Text( parent, SWT.MULTI | SWT.READ_ONLY | SWT.WRAP );
	text.setBackground( bgColor );
	text.setForeground( fgColor );

	// text.setForeground(JFaceColors.getErrorText(text.getDisplay()));
	text.setLayoutData( new GridData( SWT.FILL, SWT.CENTER, true, false ) );
	text.setText( Messages.getString("ReportDocumentEditor.errorMessage") ); //$NON-NLS-1$

	detailsButton = new Button( parent, SWT.PUSH );
	detailsButton.addSelectionListener( new SelectionAdapter( ) {

		public void widgetSelected( SelectionEvent e )
		{
			showDetails( !showingDetails );
		}
	} );

	detailsButton.setLayoutData( new GridData( SWT.BEGINNING,
			SWT.CENTER,
			false,
			false ) );
	detailsButton.setVisible( e != null );

	updateDetailsText( );

	detailsArea = new Composite( parent, SWT.NONE );
	detailsArea.setBackground( bgColor );
	detailsArea.setForeground( fgColor );
	GridData data = new GridData( GridData.FILL_BOTH );
	data.horizontalSpan = 3;
	data.verticalSpan = 1;
	detailsArea.setLayoutData( data );
	detailsArea.setLayout( new FillLayout( ) );
	parent.layout( true );
}