org.eclipse.swt.layout.GridLayout Java Examples

The following examples show how to use org.eclipse.swt.layout.GridLayout. 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: PromptSupportSnippet.java    From nebula with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * @param args
 */
public static void main(final String[] args) {
	final Display display = new Display();
	final Shell shell = new Shell(display);
	shell.setLayout(new GridLayout(2, true));

	createText(createGroup(shell));
	createStyledText(createGroup(shell));
	createCombo(createGroup(shell));
	createCCombo(createGroup(shell));

	shell.pack();
	shell.open();

	while (!shell.isDisposed()) {
		if (!display.readAndDispatch()) {
			display.sleep();
		}
	}
	display.dispose();

}
 
Example #2
Source File: AbstractWidgetTest.java    From nebula with Eclipse Public License 2.0 6 votes vote down vote up
@Test
public void testAll() throws Exception {
	shell = new Shell();

	shell.open();
	shell.setLayout(new GridLayout(1, false));
	final Canvas canvas = new Canvas(shell, SWT.None);
	canvas.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
	text = new Text(shell, SWT.READ_ONLY);
	text.setFont(XYGraphMediaFactory.getInstance().getFont("default", 18,
			SWT.BOLD));
	text.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false));
	final LightweightSystem lws = new LightweightSystem(canvas);
	lws.setContents(getTestBench());
	shell.setSize(800, 500);
	testGetBeanInfo();
	testWidget();
}
 
Example #3
Source File: DetailsDialog.java    From hop with Apache License 2.0 6 votes vote down vote up
@Override
protected Control createMessageArea( Composite composite ) {
  GridLayout gridLayout = (GridLayout) composite.getLayout();
  gridLayout.numColumns = 1;
  composite.setLayout( gridLayout );

  if ( this.message != null ) {
    this.messageLabel = new Label( composite, this.getMessageLabelStyle() );
    this.messageLabel.setText( this.message );
  }

  if ( this.details != null ) {
    this.detailsText = new Text( composite, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL );
    this.detailsText.pack();
    this.detailsText.setText( this.details );
    GridData gridData = new GridData();
    gridData.widthHint = 1024;
    gridData.heightHint = 300;
    this.detailsText.setLayoutData( gridData );
    this.detailsText.setSelection( this.details.length() );
  }

  return composite;
}
 
Example #4
Source File: UsernamePasswordDialog.java    From hop with Apache License 2.0 6 votes vote down vote up
@Override
protected Control createDialogArea( Composite parent ) {
  Composite comp = (Composite) super.createDialogArea( parent );

  GridLayout layout = (GridLayout) comp.getLayout();
  layout.numColumns = 2;

  Label usernameLabel = new Label( comp, SWT.RIGHT );
  usernameLabel.setText( "Username: " );
  usernameText = new Text( comp, SWT.SINGLE | SWT.BORDER );
  usernameText.setLayoutData( new GridData( GridData.FILL_HORIZONTAL ) );

  Label passwordLabel = new Label( comp, SWT.RIGHT );
  passwordLabel.setText( "Password: " );
  passwordText = new Text( comp, SWT.SINGLE | SWT.BORDER | SWT.PASSWORD );
  passwordText.setLayoutData( new GridData( GridData.FILL_HORIZONTAL ) );

  return comp;
}
 
Example #5
Source File: ChooseGhidraModuleProjectWizardPage.java    From ghidra with Apache License 2.0 6 votes vote down vote up
@Override
public void createControl(Composite parent) {

	Composite container = new Composite(parent, SWT.NULL);
	container.setLayout(new GridLayout(2, false));

	Label projectNameLabel = new Label(container, SWT.NULL);
	projectNameLabel.setText("Ghida module project:");
	projectCombo = new Combo(container, SWT.DROP_DOWN | SWT.READ_ONLY);
	GridData gd = new GridData(GridData.FILL_HORIZONTAL);
	projectCombo.setLayoutData(gd);
	projectCombo.addModifyListener(evt -> validate());
	for (IJavaProject javaProject : GhidraProjectUtils.getGhidraProjects()) {
		if (GhidraProjectUtils.isGhidraModuleProject(javaProject.getProject())) {
			IProject project = javaProject.getProject();
			projectCombo.add(project.getName());
			if (project.equals(selectedProject)) {
				projectCombo.setText(project.getName());
			}
		}
	}

	validate();
	setControl(container);
}
 
Example #6
Source File: FocusTests.java    From nebula with Eclipse Public License 2.0 6 votes vote down vote up
public void setUp2() throws Exception {
	Shell shell = getShell();
	shell.setLayout(new GridLayout(4, false));

	cdt1 = new CDateTime(shell, CDT.BORDER | CDT.SIMPLE);
	cdt1.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, false, false));

	button1 = new Button(shell, SWT.TOGGLE);
	button1.setText("B1");
	button1.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, false, false));

	cdt2 = new CDateTime(shell, CDT.BORDER | CDT.DROP_DOWN);
	cdt2.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, false, false));

	button2 = new Button(shell, SWT.PUSH);
	button2.setText("B2");
	button2.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, false, false));
}
 
Example #7
Source File: NewCodewindConnectionPage.java    From codewind-eclipse with Eclipse Public License 2.0 6 votes vote down vote up
@Override
public void createControl(Composite parent) {
	Composite outer = new Composite(parent, SWT.NONE);
	GridLayout layout = new GridLayout();
	layout.marginWidth = 0;
	layout.marginHeight = 0;
	layout.horizontalSpacing = 5;
	layout.verticalSpacing = 7;
	outer.setLayout(layout);
	outer.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
	
	composite = new CodewindConnectionComposite(outer, this);
	GridData data = new GridData(SWT.FILL, SWT.FILL, true, true);
	data.widthHint = 250;
	composite.setLayoutData(data);
	setControl(outer);
}
 
Example #8
Source File: EditConnectionDialog.java    From codewind-eclipse with Eclipse Public License 2.0 6 votes vote down vote up
protected Control createDialogArea(Composite parent) {
	setTitleImage(CodewindUIPlugin.getImage(CodewindUIPlugin.CODEWIND_BANNER));
	setTitle(Messages.EditConnectionDialogTitle);
	setMessage(NLS.bind(Messages.EditConnectionDialogMessage, connection.getName()));
	
	Composite content = (Composite) super.createDialogArea(parent);
	content.setLayout(new GridLayout(1, false));
	content.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, true));
	
	connectionComp = new CodewindConnectionComposite(content, this, connection);
	connectionComp.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
	
	GridLayout layout = new GridLayout();
	layout.numColumns = 1;
	layout.marginHeight = 10;
	layout.marginWidth = 20;
	progressMon = new ProgressMonitorPart(parent, layout, true);
	progressMon.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
	progressMon.setVisible(false);
	
	return parent;
}
 
Example #9
Source File: PageContainer.java    From nebula with Eclipse Public License 2.0 6 votes vote down vote up
public PageContainer(Composite parent, int style) {
	super(parent, style);
	addDisposeListener(e -> PageContainer.this.widgetDisposed(e));
	adapt(this);
	GridLayout layout = new GridLayout(1, false);
	layout.marginWidth = layout.marginHeight = 0;
	setLayout(layout);

	stackLayout = new StackLayout();

	TitleControl title = new TitleControl(this, null);
	adapt(title);
	title.setLayoutData(
			new GridData(GridData.FILL, GridData.BEGINNING, true, false));
	title.setText("SWT MapWidget");

	content = new Composite(this, SWT.NONE);
	content.setLayout(stackLayout);
	content.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
	adapt(content);
}
 
Example #10
Source File: Snippet8.java    From nebula with Eclipse Public License 2.0 6 votes vote down vote up
public Shell createShell() {
	printJob = new PrintJob("Snippet8.java", createPrint())
			.setMargins(108); // 1.5"

	shell = new Shell(display);
	shell.setText("Snippet8.java");
	shell.setBounds(100, 100, 800, 600);
	shell.setLayout(new GridLayout(1, false));

	createButtonPanel(shell).setLayoutData(
			new GridData(SWT.FILL, SWT.FILL, true, false));
	createScrollingPreview(shell).setLayoutData(
			new GridData(SWT.FILL, SWT.FILL, true, true));

	preview.setLazyPageLayout(true);
	preview.setPrintJob(printJob);
	updatePreviewSize();
	updatePageNumber();
	preview.startBackgroundLayout(() -> {
		updatePageNumber();
	});

	shell.setVisible(true);

	return shell;
}
 
Example #11
Source File: FocusTests.java    From nebula with Eclipse Public License 2.0 6 votes vote down vote up
public void setUp4() throws Exception {
	Shell shell = getShell();
	shell.setLayout(new GridLayout(4, false));

	cdt1 = new CDateTime(shell, CDT.BORDER | CDT.DROP_DOWN);
	cdt1.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, false, false));

	button1 = new Button(shell, SWT.TOGGLE);
	button1.setText("B1");
	button1.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, false, false));

	cdt2 = new CDateTime(shell, CDT.BORDER | CDT.SIMPLE);
	cdt2.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, false, false));

	button2 = new Button(shell, SWT.PUSH);
	button2.setText("B2");
	button2.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, false, false));
}
 
Example #12
Source File: SinkStatsDialog.java    From lapse-plus with GNU General Public License v3.0 6 votes vote down vote up
protected Control createDialogArea(Composite parent) {
    Composite superComposite = (Composite) super.createDialogArea(parent);
    Composite composite = new Composite(superComposite, SWT.NONE);
    composite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    GridLayout layout = new GridLayout();
    layout.marginHeight = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN);
    layout.marginWidth = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN);
    layout.verticalSpacing = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING);
    layout.horizontalSpacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
    composite.setLayout(layout);
    Text outputArea = new Text(composite, SWT.BORDER | SWT.MULTI | SWT.READ_ONLY | SWT.V_SCROLL);
    outputArea.setSize(500, 300);
    outputArea.setText(view.getStatisticsManager().getStatistics());
    outputArea.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_BLUE));
    return composite;
}
 
Example #13
Source File: GridVirtualTableViewer.java    From nebula with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * @param args
 */
public static void main(String[] args) {
	Display display = new Display();
	Shell shell = new Shell(display);
	shell.setLayout(new GridLayout());
	new GridVirtualTableViewer(shell);
	shell.open();

	while (!shell.isDisposed()) {
		if (!display.readAndDispatch())
			display.sleep();
	}

	display.dispose();

}
 
Example #14
Source File: FocusTests.java    From nebula with Eclipse Public License 2.0 6 votes vote down vote up
public void setUp5() throws Exception {
	Shell shell = getShell();
	shell.setLayout(new GridLayout(4, false));

	button1 = new Button(shell, SWT.TOGGLE);
	button1.setText("B1");
	button1.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, false, false));

	cdt1 = new CDateTime(shell, CDT.BORDER | CDT.DROP_DOWN | CDT.TAB_FIELDS);
	cdt1.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, false, false));

	button2 = new Button(shell, SWT.PUSH);
	button2.setText("B2");
	button2.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, false, false));

	cdt2 = new CDateTime(shell, CDT.BORDER | CDT.SIMPLE | CDT.TAB_FIELDS);
	cdt2.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, false, false));
}
 
Example #15
Source File: SnippetDarkPanel.java    From nebula with Eclipse Public License 2.0 6 votes vote down vote up
private static void createButtons(final Shell shell) {
	final DarkPanel p = new DarkPanel(shell);

	final Composite composite = new Composite(shell, SWT.NONE);
	composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 2, 1));
	composite.setLayout(new GridLayout(2, false));

	final Button ok = new Button(composite, SWT.PUSH);
	ok.setText("Ok");
	ok.setLayoutData(new GridData(SWT.END, SWT.END, true, true));
	ok.addListener(SWT.Selection, e -> {
		p.show();
		Dialog.isConfirmed("Confirmation", "Are you sure you want to save this form ?");
		p.hide();
	});

	final Button cancel = new Button(composite, SWT.PUSH);
	cancel.setText("Cancel");
	cancel.setLayoutData(new GridData(SWT.CENTER, SWT.END, false, true));
	cancel.addListener(SWT.Selection, e -> {
		shell.dispose();
	});
}
 
Example #16
Source File: InternalCompositeTable.java    From nebula with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * Initialize the overall table UI.
 */
private void initialize() {
	GridLayout gl = new GridLayout();
	gl.numColumns = 2;
	gl.verticalSpacing = 0;
	gl.marginWidth = 0;
	gl.marginHeight = 0;
	// borderWidth times two, since border steals pixels from both sides
	int borderInPixels = getParent().getBorderWidth() * 2;
	gl.marginRight = borderInPixels;
	gl.marginBottom = borderInPixels;
	gl.horizontalSpacing = 0;
	this.setLayout(gl);
	createControlHolder();
	createVSliderHolder();
	createHSliderHolder();
}
 
Example #17
Source File: PageSizeComboRenderer.java    From nebula with Eclipse Public License 2.0 6 votes vote down vote up
@Override
protected void createUI(Composite parent) {
	GridLayout layout = new GridLayout(2, false);
	layout.marginWidth = 0;
	layout.marginHeight = 0;
	this.setLayout(layout);

	itemsPerPageLabel = new Label(parent, SWT.NONE);
	itemsPerPageLabel.setText(Resources.getText(
			Resources.PaginationRenderer_itemsPerPage, getLocale()));
	itemsPerPageLabel.setLayoutData(new GridData());

	comboViewer = new ComboViewer(parent, SWT.READ_ONLY);
	comboViewer.setContentProvider(ArrayContentProvider.getInstance());
	comboViewer.setLabelProvider(InternalLabelProvider.getInstance());
	comboViewer.getCombo().setLayoutData(
			new GridData(GridData.FILL_HORIZONTAL));
	comboViewer.getCombo().addSelectionListener(this);

}
 
Example #18
Source File: Header.java    From nebula with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * Redraw the composite
 */
private void redrawComposite() {
	// Dispose previous content
	for (final Control c : getChildren()) {
		c.dispose();
	}

	int numberOfColumns = 1;
	if (image != null) {
		numberOfColumns++;
	}

	super.setLayout(new GridLayout(numberOfColumns, false));
	createContent();
	drawBackground();
}
 
Example #19
Source File: CollapsibleButtonsExampleTab.java    From nebula with Eclipse Public License 2.0 6 votes vote down vote up
@Override
public Control createControl(Composite parent) {

	itemImage24 = new Image(PlatformUI.getWorkbench().getDisplay(), PlatformUI.getWorkbench().getDisplay().getSystemImage(SWT.ICON_WORKING).getImageData().scaledTo(24, 24));
	itemImage16 = new Image(PlatformUI.getWorkbench().getDisplay(), PlatformUI.getWorkbench().getDisplay().getSystemImage(SWT.ICON_WORKING).getImageData().scaledTo(16, 16));

	parent.setLayout(new FillLayout());

	Composite inner = new Composite(parent, SWT.NONE);
	GridLayout gl = new GridLayout(1, true);
	gl.marginBottom = 0;
	gl.marginHeight = 0;
	gl.marginWidth = 0;
	gl.marginHeight = 0;
	inner.setLayout(gl);

	collapsibleButtons = new CollapsibleButtons(inner, SWT.NONE, IColorManager.SKIN_OFFICE_2007);
	collapsibleButtons.setLayoutData(
			new GridData(GridData.GRAB_VERTICAL | GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_END));

	for (int i = 0; i < 5; i++) {
		collapsibleButtons.addButton("Button " + i, "Tooltip " + i, itemImage24, itemImage16);
	}

	return collapsibleButtons;
}
 
Example #20
Source File: AbstractExampleTab.java    From nebula with Eclipse Public License 2.0 6 votes vote down vote up
private void createLinks(Composite parent) {
	parent.setLayout(new GridLayout());

	String[] links = createLinks();

	if (links == null) {
		return;
	}

	for (String link2 : links) {
		Link link = new Link(parent, SWT.NONE);
		link.setText(link2);
		link.addSelectionListener(new SelectionAdapter() {
			@Override
			public void widgetSelected(SelectionEvent e) {
				Program.launch(e.text);
			}
		});
	}
}
 
Example #21
Source File: GridPrintCellClippingExample.java    From nebula with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * Executes the GridPrintNoBreak example.
 * 
 * @param args
 *            the command line arguments.
 */
public static void main(String[] args) {
	final Display display = new Display();

	Shell shell = new Shell(display, SWT.SHELL_TRIM);
	shell.setLayout(new GridLayout());
	shell.setSize(600, 600);

	PrintJob job = new PrintJob("GridPrintNoBreakExample", createPrint());

	final PrintPreview preview = new PrintPreview(shell, SWT.BORDER);
	preview.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
	preview.setPrintJob(job);

	shell.open();

	while (!shell.isDisposed())
		if (!display.readAndDispatch())
			display.sleep();

	PaperClips.print(job, new PrinterData());
}
 
Example #22
Source File: NumberFormatterSnippet3.java    From nebula with Eclipse Public License 2.0 6 votes vote down vote up
public static void main(String[] args) {
	Display display = new Display();
   Shell shell = new Shell(display);
   shell.setLayout(new GridLayout());

   FormattedText text = new FormattedText(shell, SWT.BORDER | SWT.RIGHT);
   NumberFormatter formatter = new NumberFormatter();
   formatter.setFixedLengths(false, true);
   text.setFormatter(formatter);
   text.setValue(new Double(123.4));
   GridData data = new GridData();
   data.widthHint = 100;
   text.getControl().setLayoutData(data);

   shell.open();
   while ( ! shell.isDisposed() ) {
   	if (!display.readAndDispatch()) display.sleep();
   }
   display.dispose();
}
 
Example #23
Source File: NumberFormatterSnippet2.java    From nebula with Eclipse Public License 2.0 6 votes vote down vote up
public static void main(String[] args) {
	Display display = new Display();
   Shell shell = new Shell(display);
   shell.setLayout(new GridLayout());

   FormattedText text = new FormattedText(shell, SWT.BORDER | SWT.RIGHT);
   text.setFormatter(new NumberFormatter(Locale.FRENCH));
   GridData data = new GridData();
   data.widthHint = 100;
   text.getControl().setLayoutData(data);

   shell.open();
   while ( ! shell.isDisposed() ) {
   	if (!display.readAndDispatch()) display.sleep();
   }
   display.dispose();
}
 
Example #24
Source File: DateChooserComboSnippet1.java    From nebula with Eclipse Public License 2.0 6 votes vote down vote up
public static void main(String[] args) {
	Display display = new Display();
   Shell shell = new Shell(display);
   shell.setLayout(new GridLayout());
   shell.setSize(300, 200);

   DateChooserCombo combo = new DateChooserCombo(shell, SWT.BORDER);
   GridData data = new GridData();
	data.widthHint = 110;
	combo.setLayoutData(data);

   shell.open();
   while ( ! shell.isDisposed() ) {
   	if (!display.readAndDispatch()) display.sleep();
   }
   display.dispose();
}
 
Example #25
Source File: FocusTests.java    From nebula with Eclipse Public License 2.0 6 votes vote down vote up
public void setUp3() throws Exception {
	Shell shell = getShell();
	shell.setLayout(new GridLayout(4, false));

	button1 = new Button(shell, SWT.TOGGLE);
	button1.setText("B1");
	button1.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, false, false));

	cdt1 = new CDateTime(shell, CDT.BORDER | CDT.SIMPLE);
	cdt1.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, false, false));

	button2 = new Button(shell, SWT.PUSH);
	button2.setText("B2");
	button2.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, false, false));

	cdt2 = new CDateTime(shell, CDT.BORDER | CDT.DROP_DOWN);
	cdt2.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, false, false));
}
 
Example #26
Source File: JFaceViewerIntegrationExample.java    From nebula with Eclipse Public License 2.0 6 votes vote down vote up
public static void main(String[] args) {
	Display display = new Display();

	final Shell shell = new Shell(display);
	shell.setText("Rich Text Editor JFace viewer integration example");
	shell.setSize(800, 600);

	shell.setLayout(new GridLayout(1, true));

	JFaceViewerIntegrationExample example = new JFaceViewerIntegrationExample();
	example.createControls(shell);

	shell.open();
	while (!shell.isDisposed()) {
		if (!display.readAndDispatch())
			display.sleep();
	}
	display.dispose();
}
 
Example #27
Source File: CDTSnippet01.java    From nebula with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * @param args
 */
public static void main(String[] args) {
	final Display display = new Display();
	final Shell shell = new Shell(display);
	shell.setText("Nebula CDateTime");
	shell.setLayout(new GridLayout());

	GridLayout layout = new GridLayout();
	shell.setLayout(layout);

	final CDateTime cdt = new CDateTime(shell, CDT.BORDER | CDT.DROP_DOWN);
	cdt.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));

	shell.pack();
	Point size = shell.getSize();
	Rectangle screen = display.getMonitors()[0].getBounds();
	shell.setBounds(
			(screen.width-size.x)/2,
			(screen.height-size.y)/2,
			size.x,
			size.y
	);
	shell.open();
	while (!shell.isDisposed()) {
		if (!display.readAndDispatch())
			display.sleep();
	}
	display.dispose();
}
 
Example #28
Source File: PWRadio.java    From nebula with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * @see org.eclipse.nebula.widgets.opal.preferencewindow.widgets.PWWidget#build(org.eclipse.swt.widgets.Composite)
 */
@Override
public Control build(final Composite parent) {
	buildLabel(parent, GridData.BEGINNING);

	final Composite composite = new Composite(parent, SWT.NONE);
	final GridLayout gridLayout = new GridLayout();
	gridLayout.marginHeight = gridLayout.marginWidth = 0;
	composite.setLayout(gridLayout);

	for (final Object datum : data) {
		final Button button = new Button(composite, SWT.RADIO);
		addControl(button);
		button.setText(datum.toString());
		button.setLayoutData(new GridData(GridData.FILL, GridData.BEGINNING, true, false));
		button.setSelection(datum.equals(PreferenceWindow.getInstance().getValueFor(getPropertyKey())));
		button.setData(datum);
		button.addListener(SWT.Selection, event -> {
			if (button.getSelection()) {
				PreferenceWindow.getInstance().setValue(getPropertyKey(), button.getData());
			}
		});

		buttons.add(button);
	}
	return composite;
}
 
Example #29
Source File: CDTSnippet02.java    From nebula with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * @param args
 */
public static void main(String[] args) {
	final Display display = new Display();
	final Shell shell = new Shell(display);
	shell.setText("CDateTime");
	GridLayout layout = new GridLayout();
	layout.marginHeight = 25;
	layout.marginWidth = 25;
	shell.setLayout(layout);

	CDateTime cdt = new CDateTime(shell, CDT.BORDER | CDT.COMPACT | CDT.DROP_DOWN | CDT.DATE_LONG | CDT.TIME_MEDIUM);
	cdt.setSelection(new Date());
	cdt.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));

	shell.pack();
	Point size = shell.getSize();
	Rectangle screen = display.getMonitors()[0].getBounds();
	shell.setBounds(
			(screen.width-size.x)/2,
			(screen.height-size.y)/2,
			size.x,
			size.y
	);
	shell.open();
	while (!shell.isDisposed()) {
		if (!display.readAndDispatch())
			display.sleep();
	}
	display.dispose();
}
 
Example #30
Source File: CDTSnippet03.java    From nebula with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * @param args
 */
public static void main(final String[] args) {
	final Display display = new Display();
	final Shell shell = new Shell(display);
	shell.setText("CDateTime");
	shell.setLayout(new GridLayout());

	final CDateTime cdt = new CDateTime(shell, CDT.BORDER | CDT.SIMPLE);
	cdt.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false));

	cdt.setBackground(display.getSystemColor(SWT.COLOR_BLUE));
	cdt.setForeground(display.getSystemColor(SWT.COLOR_WHITE));
	cdt.setPickerBackgroundColor(display.getSystemColor(SWT.COLOR_BLUE));
	cdt.setPickerForegroundColor(display.getSystemColor(SWT.COLOR_WHITE));
	cdt.setPickerTodayColor(display.getSystemColor(SWT.COLOR_YELLOW));

	shell.pack();
	final Point size = shell.getSize();
	final Rectangle screen = display.getMonitors()[0].getBounds();
	shell.setBounds((screen.width - size.x) / 2, (screen.height - size.y) / 2, size.x, size.y);
	shell.open();
	while (!shell.isDisposed()) {
		if (!display.readAndDispatch()) {
			display.sleep();
		}
	}
	display.dispose();
}