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

The following examples show how to use org.eclipse.swt.widgets.Label#addMouseListener() . 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
Source File: StatechartDefinitionSection.java    From statecharts with Eclipse Public License 1.0 6 votes vote down vote up
protected Label createSwitchControl() {
	Label switchControl = new Label(this, SWT.PUSH);
	switchControl.setToolTipText(sectionExpanded ? HIDE_SECTION_TOOLTIP : SHOW_SECTION_TOOLTIP);
	switchControl.setImage(sectionExpanded ? StatechartImages.COLLAPSE.image() : StatechartImages.EXPAND.image());
	switchControl.setCursor(new Cursor(getDisplay(), SWT.CURSOR_HAND));
	GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).indent(-1, -1).hint(MIN_SIZE[0], MIN_SIZE[1])
	.applyTo(switchControl);
	mouseListener = new MouseAdapter() {
		@Override
		public void mouseUp(MouseEvent e) {
			toggleExpandState();
		}
	};
	switchControl.addMouseListener(mouseListener);
	return switchControl;
}
 
Example 2
Source File: TitaniumUpdatePopup.java    From APICloud-Studio with GNU General Public License v3.0 6 votes vote down vote up
protected Control createDialogArea(Composite parent)
{
	dialogArea = new Composite(parent, SWT.NONE);
	dialogArea.setLayoutData(new GridData(GridData.FILL_BOTH));
	GridLayout layout = new GridLayout();
	layout.numColumns = 1;
	dialogArea.setLayout(layout);
	dialogArea.addMouseListener(clickListener);

	// The "click to update" label
	Label infoLabel = new Label(dialogArea, SWT.NONE);
	infoLabel.setText(MessageFormat.format(EplMessages.TitaniumUpdatePopup_update_detail,
			EclipseUtil.getStudioPrefix()));
	infoLabel.setLayoutData(new GridData(GridData.FILL_BOTH));
	infoLabel.addMouseListener(clickListener);

	return dialogArea;

}
 
Example 3
Source File: GenericInfoPopupDialog.java    From APICloud-Studio with GNU General Public License v3.0 6 votes vote down vote up
@Override
protected Control createDialogArea(Composite parent)
{
	Composite main = new Composite(parent, SWT.NONE);
	main.setLayout(GridLayoutFactory.swtDefaults().create());
	main.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create());
	if (clickListener != null)
	{
		main.addMouseListener(clickListener);
	}

	Label infoLabel = new Label(main, SWT.WRAP);
	infoLabel.setText(message);
	infoLabel.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create());
	if (clickListener != null)
	{
		infoLabel.addMouseListener(clickListener);
	}

	return main;
}
 
Example 4
Source File: CustomPreviewTable.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
private void addHeaderSplitter( )
{
	Label splitter = new Label( cmpHeaders, SWT.NONE );
	FormData fd = new FormData( );
	fd.top = new FormAttachment( 2 );
	int i = btnHeaders.size( );
	if ( i == 0 )
	{
		fd.left = new FormAttachment( 0 );
	}
	else
	{
		Button btnNeighbor = btnHeaders.get( i - 1 );
		fd.left = new FormAttachment( btnNeighbor );
	}
	fd.width = SPLITTER_WIDTH;
	splitter.setLayoutData( fd );
	splitter.setData( Integer.valueOf( i - 1 ) );
	splitter.addMouseListener( this );
	splitter.addMouseMoveListener( this );
}
 
Example 5
Source File: SWTHelper.java    From elexis-3-core with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Return a Label that acts as a hyperlink
 * 
 * @param parent
 *            parent control
 * @param text
 *            text to display
 * @param lis
 *            hyperlink listener that is called on Mouse click
 * @return a Label
 */
public static Label createHyperlink(final Composite parent, final String text,
	final IHyperlinkListener lis){
	final Label ret = new Label(parent, SWT.NONE);
	ret.setText(text);
	ret.setForeground(UiDesk.getColorRegistry().get(Messages.SWTHelper_blue)); //$NON-NLS-1$
	ret.addMouseListener(new MouseAdapter() {
		@Override
		public void mouseDown(final MouseEvent e){
			if (lis != null) {
				lis.linkActivated(new HyperlinkEvent(ret, ret, text, e.stateMask));
			}
		}
		
	});
	return ret;
}
 
Example 6
Source File: AbstractSelectableRow.java    From nebula with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * This method initializes this
 * 
 */
private void initialize() {
	this.labels = new ArrayList();
	for (int i = 0; i < getColumnCount(); i++) {
		Label label = new Label(this, SWT.NONE);
		this.labels.add(label);
		label.addMouseListener(this);
	}
}
 
Example 7
Source File: DayEditorCalendarableItemControl.java    From nebula with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * Create the event control's layout
 */
private void initialize() {
	setBackground(BACKGROUND_COLOR);
       label = new Label(this, SWT.WRAP);
       label.setText("Label");
       label.setBackground(BACKGROUND_COLOR);
       FillLayout fillLayout = new FillLayout();
       fillLayout.marginHeight = MARGIN;
       fillLayout.marginWidth = MARGIN;
       setBackground(BORDER_COLOR);
       setLayout(fillLayout);
       addPaintListener(paintListener);
       label.addMouseListener(labelMouseListener);
}
 
Example 8
Source File: MultiLineCheckbox.java    From ermasterr with Apache License 2.0 5 votes vote down vote up
public MultiLineCheckbox(final AbstractDialog dialog, final Composite parent, final String title, final boolean indent, final int span) {
    super();

    final Composite box = new Composite(parent, SWT.NONE);

    final GridData boxGridData = new GridData(SWT.FILL, SWT.LEFT, true, false, span, 1);
    if (indent) {
        boxGridData.horizontalIndent = Resources.INDENT;
    }
    box.setLayoutData(boxGridData);

    final GridLayout layout = new GridLayout(2, false);
    layout.marginWidth = 0;
    box.setLayout(layout);

    checkboxButton = new Button(box, SWT.CHECK);
    final GridData checkboxGridData = new GridData();
    checkboxGridData.verticalAlignment = SWT.TOP;
    checkboxButton.setLayoutData(checkboxGridData);

    label = new Label(box, SWT.NONE);
    final GridData labelGridData = new GridData();
    labelGridData.horizontalIndent = Resources.CHECKBOX_INDENT;

    label.setLayoutData(labelGridData);
    label.setText(ResourceString.getResourceString(title));

    ListenerAppender.addCheckBoxListener(checkboxButton, dialog);

    label.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseUp(final MouseEvent e) {
            checkboxButton.setSelection(!checkboxButton.getSelection());
            dialog.validate();
        }
    });
}
 
Example 9
Source File: StatechartDefinitionSection.java    From statecharts with Eclipse Public License 1.0 5 votes vote down vote up
public InlineIcon(Composite parent, int style) {
	super(parent, style);
	GridLayoutFactory.fillDefaults().applyTo(this);
	icon = new Label(this, style);
	icon.setCursor(handCursor);
	icon.setImage(StatechartImages.PIN.image());
	icon.setToolTipText(INLINE_TOOLTIP);
	icon.setEnabled(isStatechart());
	icon.addMouseListener(this);
	icon.addMouseTrackListener(this);
	icon.addPaintListener(this);
}
 
Example 10
Source File: DisplayOverlay.java    From gama with GNU General Public License v3.0 5 votes vote down vote up
private Label label(final Composite c, final int horizontalAlign) {
	final Label l = new Label(c, SWT.None);
	l.setForeground(IGamaColors.WHITE.color());
	l.setBackground(IGamaColors.BLACK.color());
	l.setText(" ");
	l.setLayoutData(infoData(horizontalAlign));
	l.addMouseListener(toggleListener);
	return l;
}
 
Example 11
Source File: SeriesPagePie.java    From slr-toolkit with Eclipse Public License 1.0 4 votes vote down vote up
public SeriesPagePie(Composite parent, int style) {
	super(parent, style);
	setLayout(new GridLayout(1, false));
	
	compositeFirst = new Composite(this, SWT.NONE);
	compositeFirst.setLayout(new GridLayout(2, false));
	compositeFirst.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
	
	btnNewButton = new Button(compositeFirst, SWT.NONE);
	btnNewButton.setText("Select Term");
	
	lblSelectedTermIs = new Label(compositeFirst, SWT.CENTER);
	GridData gd_lblSelectedTermIs = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1);
	gd_lblSelectedTermIs.widthHint = 367;
	lblSelectedTermIs.setLayoutData(gd_lblSelectedTermIs);
	lblSelectedTermIs.setText("No Term Selected");
	btnNewButton.addSelectionListener(this);
	
	
	
	Composite compositeCentre = new Composite(this, SWT.NONE);
	compositeCentre.setLayout(new GridLayout(1, false));
	compositeCentre.setLayoutData(new GridData(SWT.LEFT, SWT.FILL, true, true, 1, 1));
	
	list = new List(compositeCentre, SWT.BORDER | SWT.V_SCROLL);
	GridData gd_list = new GridData(SWT.LEFT, SWT.FILL, true, true, 1, 1);
	gd_list.widthHint = 400;
	list.setLayoutData(gd_list);
	list.setBounds(0, 0, 71, 68);
	list.addSelectionListener(this);
	
	Composite compositeNorth = new Composite(this, SWT.NONE);
	compositeNorth.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, false, 1, 1));
	FillLayout fl_compositeNorth = new FillLayout(SWT.HORIZONTAL);
	fl_compositeNorth.marginWidth = 5;
	fl_compositeNorth.spacing = 5;
	compositeNorth.setLayout(fl_compositeNorth);
	
	lblColor = new Label(compositeNorth, SWT.NONE);
	lblColor.setText("Color:");
	
	btnRadioButtonGrey = new Button(compositeNorth, SWT.RADIO);
	btnRadioButtonGrey.setText("Grey");
	btnRadioButtonGrey.addSelectionListener(this);
	
	btnRadioButtonCustom = new Button(compositeNorth, SWT.RADIO);
	btnRadioButtonCustom.setText("Custom");
	btnRadioButtonCustom.addSelectionListener(this);
	
	btnRadioButtonRandom = new Button(compositeNorth, SWT.RADIO);
	btnRadioButtonRandom.setSelection(true);
	btnRadioButtonRandom.setText("Random");
	
	btnOneColor = new Button(compositeNorth, SWT.RADIO);
	btnOneColor.setText("One Color");
	btnOneColor.addSelectionListener(this);
	
	btnRadioButtonRandom.addSelectionListener(this);
	
	Composite compositeSouth = new Composite(this, SWT.NONE);
	compositeSouth.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
	compositeSouth.setLayout(new GridLayout(5, false));
	
	btnCheckButton = new Button(compositeSouth, SWT.CHECK);
	btnCheckButton.setBounds(0, 0, 111, 20);
	btnCheckButton.setText("Show in Chart");
	btnCheckButton.addSelectionListener(this);
	
	labelShowColor = new Label(compositeSouth, SWT.BORDER);
	GridData gd_labelShowColor = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1);
	gd_labelShowColor.widthHint = 100;
	labelShowColor.setLayoutData(gd_labelShowColor);
	labelShowColor.setBounds(0, 0, 70, 20);
	labelShowColor.setText(" ");
	labelShowColor.addMouseListener(this);
	new Label(compositeSouth, SWT.NONE);
	new Label(compositeSouth, SWT.NONE);
	new Label(compositeSouth, SWT.NONE);
	
	loadSettings();

}
 
Example 12
Source File: SeriesPageBubble.java    From slr-toolkit with Eclipse Public License 1.0 4 votes vote down vote up
public SeriesPageBubble(Composite parent, int style) {
	super(parent, style);
	setLayout(new GridLayout(1, false));
	
	compositeFirst = new Composite(this, SWT.NONE);
	compositeFirst.setLayout(new GridLayout(4, true));
	compositeFirst.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
	
	btnGetYTerm = new Button(compositeFirst, SWT.NONE);
	btnGetYTerm.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
	btnGetYTerm.setText("Select Y Term");
	btnGetYTerm.addSelectionListener(this);
	
	lblySelectedTermIs = new Label(compositeFirst, SWT.NONE);
	lblySelectedTermIs.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
	lblySelectedTermIs.setText("No Term Selected");
	
	btnGetXTerm = new Button(compositeFirst, SWT.NONE);
	btnGetXTerm.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
	btnGetXTerm.setText("Select X Term");
	btnGetXTerm.addSelectionListener(this);
	
	lblxNewLabel = new Label(compositeFirst, SWT.NONE);
	lblxNewLabel.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
	lblxNewLabel.setText("No Term Selected");
	
	
	Composite compositeCentre = new Composite(this, SWT.NONE);
	compositeCentre.setLayout(new FillLayout(SWT.HORIZONTAL));
	GridData gd_compositeCentre = new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1);
	gd_compositeCentre.widthHint = 218;
	compositeCentre.setLayoutData(gd_compositeCentre);
	
	list_y = new List(compositeCentre, SWT.BORDER | SWT.V_SCROLL);
	list_y.setBounds(0, 0, 71, 68);
	list_y.addSelectionListener(this);
	
	list_x = new List(compositeCentre, SWT.BORDER | SWT.V_SCROLL);
	list_x.addSelectionListener(this);
	
	Composite compositeNorth = new Composite(this, SWT.NONE);
	compositeNorth.setLayout(new GridLayout(2, false));
	compositeNorth.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
	
	btnShowInChartY = new Button(compositeNorth, SWT.CHECK);
	btnShowInChartY.setBounds(0, 0, 111, 20);
	btnShowInChartY.setText("Show in Chart");
	btnShowInChartY.addSelectionListener(this);
	
	btnShowInChartX = new Button(compositeNorth, SWT.CHECK);
	btnShowInChartX.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, true, false, 1, 1));
	btnShowInChartX.setText("Show in Chart");
	btnShowInChartX.addSelectionListener(this);
	
	Composite compositeSouth = new Composite(this, SWT.NONE);
	compositeSouth.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
	compositeSouth.setLayout(new GridLayout(6, false));
	
	lblColorYSeries = new Label(compositeSouth, SWT.NONE);
	GridData gd_lblColorYSeries = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1);
	gd_lblColorYSeries.widthHint = 100;
	lblColorYSeries.setLayoutData(gd_lblColorYSeries);
	lblColorYSeries.setText("Color Y Series:");
	
	labelShowColor = new Label(compositeSouth, SWT.BORDER);
	GridData gd_labelShowColor = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1);
	gd_labelShowColor.widthHint = 100;
	labelShowColor.setLayoutData(gd_labelShowColor);
	labelShowColor.setBounds(0, 0, 70, 20);
	labelShowColor.setText(" ");
	
	btnRadioButtonGrey = new Button(compositeSouth, SWT.RADIO);
	btnRadioButtonGrey.setText("Grey");
	
	btnRadioButtonCustom = new Button(compositeSouth, SWT.RADIO);
	btnRadioButtonCustom.setText("Custom");
	
	btnRadioButtonRandom = new Button(compositeSouth, SWT.RADIO);
	btnRadioButtonRandom.setSelection(true);
	btnRadioButtonRandom.setText("Random");
	
	btnOneColor = new Button(compositeSouth, SWT.RADIO);
	btnOneColor.setText("One color");
	btnOneColor.addSelectionListener(this);
	btnRadioButtonRandom.addSelectionListener(this);
	btnRadioButtonCustom.addSelectionListener(this);
	btnRadioButtonGrey.addSelectionListener(this);
	labelShowColor.addMouseListener(this);
	
	loadSettings();

}
 
Example 13
Source File: LegendPageBar.java    From slr-toolkit with Eclipse Public License 1.0 4 votes vote down vote up
/**
 * Create the composite.
 * @param parent
 * @param style
 */
public LegendPageBar(Composite parent, int style) {
	super(parent, style);
	setLayout(new GridLayout(2, false));
	
	lblLegend = new Label(this, SWT.NONE);
	lblLegend.setText("Legend ");
	
	btnEnableLegend = new Button(this, SWT.CHECK);
	btnEnableLegend.setText("Enable Legend");
	
	Label lblBackgroundColor = new Label(this, SWT.NONE);
	GridData gd_lblBackgroundColor = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1);
	gd_lblBackgroundColor.widthHint = 150;
	lblBackgroundColor.setLayoutData(gd_lblBackgroundColor);
	lblBackgroundColor.setText("Background Color");
	
	labelColorShow = new Label(this, SWT.BORDER);
	GridData gd_labelColorShow = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1);
	gd_labelColorShow.widthHint = 100;
	labelColorShow.setLayoutData(gd_labelColorShow);
	labelColorShow.setText(" ");
	labelColorShow.setBackground(PageSupport.getColor(parent, 0));
	labelColorShow.addMouseListener(this);
	
	Label lblOutline = new Label(this, SWT.NONE);
	lblOutline.setText("Outline Style");
	
	comboOutline = new Combo(this, SWT.READ_ONLY);
	comboOutline.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, false, 1, 1));
	comboOutline.add("None");
	comboOutline.add("Dashed");
	comboOutline.add("Dash Dotted");
	comboOutline.add("Dotted");
	comboOutline.add("Solid");
	comboOutline.select(0);
	
	lblMaxPercent = new Label(this, SWT.NONE);
	lblMaxPercent.setText("Max. Percent");
	
	scale = new Scale(this, SWT.NONE);
	scale.setIncrement(2);
	GridData gd_scale = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1);
	gd_scale.widthHint = 309;
	scale.setLayoutData(gd_scale);
	scale.setPageIncrement(2);
	scale.setMaximum(50);
	scale.setSelection(10);
	scale.addSelectionListener(this);
	
	Label lblPosition = new Label(this, SWT.NONE);
	lblPosition.setText("Position");
	
	comboPosition = new Combo(this, SWT.READ_ONLY);
	comboPosition.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, false, 1, 1));
	comboPosition.add("Right");
	comboPosition.add("Left");
	comboPosition.add("Below");
	comboPosition.add("Top");
	comboPosition.select(0);		

	loadSettings();
}
 
Example 14
Source File: LegendPagePie.java    From slr-toolkit with Eclipse Public License 1.0 4 votes vote down vote up
/**
 * Create the composite.
 * @param parent
 * @param style
 */
public LegendPagePie(Composite parent, int style) {
	super(parent, style);
	setLayout(new GridLayout(2, false));
	
	lblLegend = new Label(this, SWT.NONE);
	lblLegend.setText("Legend");
	
	btnEnableLegend = new Button(this, SWT.CHECK);
	btnEnableLegend.setText("Enable Legend");
	
	Label lblBackgroundColor = new Label(this, SWT.NONE);
	GridData gd_lblBackgroundColor = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1);
	gd_lblBackgroundColor.widthHint = 150;
	lblBackgroundColor.setLayoutData(gd_lblBackgroundColor);
	lblBackgroundColor.setText("Background Color");
	
	labelColorShow = new Label(this, SWT.BORDER);
	GridData gd_labelColorShow = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1);
	gd_labelColorShow.widthHint = 100;
	labelColorShow.setLayoutData(gd_labelColorShow);
	labelColorShow.setText(" ");
	labelColorShow.setBackground(PageSupport.getColor(parent, 0));
	labelColorShow.addMouseListener(this);
	
	Label lblOutline = new Label(this, SWT.NONE);
	lblOutline.setText("Outline Style");
	
	comboOutline = new Combo(this, SWT.READ_ONLY);
	comboOutline.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, false, 1, 1));
	comboOutline.add("None");
	comboOutline.add("Dashed");
	comboOutline.add("Dash Dotted");
	comboOutline.add("Dotted");
	comboOutline.add("Solid");
	comboOutline.select(0);
	
	lblMaxPercent = new Label(this, SWT.NONE);
	lblMaxPercent.setText("Max. Percent");
	
	scale = new Scale(this, SWT.NONE);
	scale.setIncrement(2);
	GridData gd_scale = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1);
	gd_scale.widthHint = 309;
	scale.setLayoutData(gd_scale);
	scale.setPageIncrement(2);
	scale.setMaximum(50);
	scale.setSelection(10);
	scale.addSelectionListener(this);
	
	Label lblPosition = new Label(this, SWT.NONE);
	lblPosition.setText("Position");
	
	comboPosition = new Combo(this, SWT.READ_ONLY);
	comboPosition.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, false, 1, 1));
	comboPosition.add("Right");
	comboPosition.add("Left");
	comboPosition.add("Below");
	comboPosition.add("Top");
	comboPosition.select(0);		
	
	

	loadSettings();
}
 
Example 15
Source File: SeriesPageBar.java    From slr-toolkit with Eclipse Public License 1.0 4 votes vote down vote up
public SeriesPageBar(Composite parent, int style) {
	super(parent, style);
	setLayout(new GridLayout(1, false));
	
	compositeFirst = new Composite(this, SWT.NONE);
	compositeFirst.setLayout(new GridLayout(2, false));
	compositeFirst.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
	
	btnNewButton = new Button(compositeFirst, SWT.NONE);
	btnNewButton.setText("Select Term");
	
	lblSelectedTermIs = new Label(compositeFirst, SWT.CENTER);
	GridData gd_lblSelectedTermIs = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1);
	gd_lblSelectedTermIs.widthHint = 367;
	lblSelectedTermIs.setLayoutData(gd_lblSelectedTermIs);
	lblSelectedTermIs.setText("No Term Selected");
	btnNewButton.addSelectionListener(this);
	
	
	
	Composite compositeCentre = new Composite(this, SWT.NONE);
	compositeCentre.setLayout(new GridLayout(1, false));
	compositeCentre.setLayoutData(new GridData(SWT.LEFT, SWT.FILL, true, true, 1, 1));
	
	list = new List(compositeCentre, SWT.BORDER | SWT.V_SCROLL);
	GridData gd_list = new GridData(SWT.LEFT, SWT.FILL, true, true, 1, 1);
	gd_list.widthHint = 400;
	list.setLayoutData(gd_list);
	list.setBounds(0, 0, 71, 68);
	list.addSelectionListener(this);
	
	Composite compositeNorth = new Composite(this, SWT.NONE);
	compositeNorth.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, false, 1, 1));
	FillLayout fl_compositeNorth = new FillLayout(SWT.HORIZONTAL);
	fl_compositeNorth.marginWidth = 5;
	fl_compositeNorth.spacing = 5;
	compositeNorth.setLayout(fl_compositeNorth);
	
	lblColor = new Label(compositeNorth, SWT.NONE);
	lblColor.setText("Color: ");
	
	btnRadioButtonGrey = new Button(compositeNorth, SWT.RADIO);
	btnRadioButtonGrey.setText("Grey");
	btnRadioButtonGrey.addSelectionListener(this);
	
	btnRadioButtonCustom = new Button(compositeNorth, SWT.RADIO);
	btnRadioButtonCustom.setText("Custom");
	btnRadioButtonCustom.addSelectionListener(this);
	
	btnRadioButtonRandom = new Button(compositeNorth, SWT.RADIO);
	btnRadioButtonRandom.setSelection(true);
	btnRadioButtonRandom.setText("Random");
	
	btnOneColor = new Button(compositeNorth, SWT.RADIO);
	btnOneColor.setText("One Color");
	btnOneColor.addSelectionListener(this);
	
	btnRadioButtonRandom.addSelectionListener(this);
	
	Composite compositeSouth = new Composite(this, SWT.NONE);
	compositeSouth.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
	compositeSouth.setLayout(new GridLayout(5, false));
	
	btnCheckButton = new Button(compositeSouth, SWT.CHECK);
	btnCheckButton.setBounds(0, 0, 111, 20);
	btnCheckButton.setText("Show in Chart");
	btnCheckButton.addSelectionListener(this);
	
	labelShowColor = new Label(compositeSouth, SWT.BORDER);
	GridData gd_labelShowColor = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1);
	gd_labelShowColor.widthHint = 100;
	labelShowColor.setLayoutData(gd_labelShowColor);
	labelShowColor.setBounds(0, 0, 70, 20);
	labelShowColor.setText(" ");
	labelShowColor.addMouseListener(this);
	new Label(compositeSouth, SWT.NONE);
	new Label(compositeSouth, SWT.NONE);
	new Label(compositeSouth, SWT.NONE);
	
	loadSettings();

}
 
Example 16
Source File: DecoratedStringChooser.java    From elexis-3-core with Eclipse Public License 1.0 4 votes vote down vote up
public DecoratedStringChooser(Composite parent, final Settings cfg,
	final DecoratedString[] strings){
	super(parent, SWT.BORDER);
	
	int num = strings.length;
	int typRows = ((int) Math.sqrt(num));
	int typCols = typRows + (num - (typRows * typRows));
	if (typCols < 4) {
		typCols = 4;
	}
	setLayout(new GridLayout(typCols, true));
	Label expl = new Label(this, SWT.WRAP);
	expl.setText(Messages.DecoratedStringChooser_howToChange); //$NON-NLS-1$
	expl.setLayoutData(SWTHelper.getFillGridData(typCols, false, 1, false));
	for (int i = 0; i < num; i++) {
		Label lab = new Label(this, SWT.NONE);
		lab.setText(strings[i].getText());
		lab.setData(strings[i].getValue());
		
		String coldesc;
		if(strings[i].getValue() != null) {
			coldesc = cfg.get(strings[i].getValue(), "FFFFFF"); //$NON-NLS-1$
		} else {
			coldesc = cfg.get(strings[i].getText(), "FFFFFF"); //$NON-NLS-1$
		}

		Color background = UiDesk.getColorFromRGB(coldesc);
		lab.setBackground(background);
		GridData gd = new GridData(GridData.FILL_BOTH);
		lab.setLayoutData(gd);
		lab.addMouseListener(new MouseAdapter() {
			
			@Override
			public void mouseDoubleClick(MouseEvent e){
				ColorDialog cd = new ColorDialog(getShell());
				Label l = (Label) e.getSource();
				RGB selected = cd.open();
				if (selected != null) {
					String symbolic = UiDesk.createColor(selected);
					l.setBackground(UiDesk.getColorFromRGB(symbolic));
					if(l.getData() != null) {
						cfg.set((String) l.getData(), symbolic);
					} else {
						cfg.set(l.getText(), symbolic);
					}
				}
			}
			
		});
	}
}