All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.openxma.rwt.launch.TestComponent Maven / Gradle / Ivy

The newest version!
package org.openxma.rwt.launch;

import org.eclipse.rwt.lifecycle.IEntryPoint;
import org.eclipse.rwt.lifecycle.WidgetUtil;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.layout.FormAttachment;
import org.eclipse.swt.layout.FormData;
import org.eclipse.swt.layout.FormLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;

/**
 * This class controls all aspects of the application's execution
 * and is contributed through the plugin.xml.
 */
public class TestComponent extends OpenxmaLauncher implements IEntryPoint {
	
	Label componentTextL;	
	Text componentText;	
	Button launchButton;
	Composite dialogContainer;
	

	public int createUI() {

		// Display and shell
		Display display = new Display();
		final Shell shell = new Shell(display, SWT.NO_TRIM);
		shell.setMaximized(true);
		shell.setLayout(new FormLayout());
		
		// Widgets
		createWidgets(shell);
		layoutWidgets();		
		
		shell.open();
		while (!shell.isDisposed()) {
			if (!display.readAndDispatch()) {
				display.sleep();
			}
		}
		display.dispose();
		return 0;
	}
	
	private void createWidgets(final Composite composite) {		
		// Label
		componentTextL = new Label(composite,SWT.LEFT);
		componentTextL.setText("Component url: ");		
		// Text
		componentText = new Text(composite, SWT.SINGLE | SWT.BORDER | SWT.LEFT);
		componentText.setText(determineComponentUrl());	
		// Launch button
		launchButton = new Button(composite, SWT.NONE);
		launchButton.setText("Launch component...");
		launchButton.addSelectionListener(new SelectionListener() {
			public void widgetSelected(SelectionEvent e) {
				invokeComponent(componentText.getText(),composite);
			}
			public void widgetDefaultSelected(SelectionEvent e) {
			}
		});		
		// DialogContainer
		dialogContainer = new Composite(composite,SWT.NONE);	
		dialogContainer.setLayout(new FormLayout());
	    Color red = composite.getDisplay().getSystemColor(SWT.COLOR_GRAY);		
		dialogContainer.setBackground(red);
		
		dialogContainer.setData( WidgetUtil.CUSTOM_VARIANT, "mybutton" );
		
	}
	
	private void layoutWidgets() {
		// Label
		FormData data = new FormData();
		data.left = new FormAttachment(0, 100, 10);
		data.top = new FormAttachment(componentText, 0, SWT.CENTER);
		componentTextL.setLayoutData(data);
		// Text		
		data = new FormData();
		data.left = new FormAttachment(componentTextL, 3, SWT.RIGHT);
		data.top = new FormAttachment(0, 100, 10);
		data.right = new FormAttachment(100, 100, -10);						
		componentText.setLayoutData(data);			
		// Launch button		
		data = new FormData();
		data.left = new FormAttachment(componentText, 0, SWT.LEFT);
		data.top = new FormAttachment(componentText, 5, SWT.BOTTOM);			
		launchButton.setLayoutData(data);		
		// DialogContainer
		data = new FormData();		
		data.top = new FormAttachment(launchButton, 5, SWT.BOTTOM);					
		data.left = new FormAttachment(0, 100, 0);	
		data.right = new FormAttachment(100, 100, 0);		
		data.bottom = new FormAttachment(100, 100, 0);		
		dialogContainer.setLayoutData(data);	
		/* canvas */		
		data = new FormData();		
		data.top = new FormAttachment(0, 100, 50);						
		data.left = new FormAttachment(0, 100, 50);	
		data.right = new FormAttachment(0, 100, 250);		
		data.bottom = new FormAttachment(0, 100, 250);		
	}
        
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy