Java Code Examples for org.eclipse.ui.forms.widgets.FormToolkit#createForm()

The following examples show how to use org.eclipse.ui.forms.widgets.FormToolkit#createForm() . 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: AbstractEditorPropertySection.java    From statecharts with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public final void createControls(Composite parent, TabbedPropertySheetPage aTabbedPropertySheetPage) {
	toolkit = new FormToolkit(parent.getDisplay());
	toolkit.setBorderStyle(SWT.BORDER);
	super.createControls(parent, aTabbedPropertySheetPage);
	GridDataFactory.fillDefaults().grab(true, true).applyTo(parent);
	parent.setLayout(new GridLayout(1, true));
	form = toolkit.createForm(parent);
	toolkit.decorateFormHeading(form);
	GridDataFactory.fillDefaults().grab(true, true).applyTo(form);
	form.getBody().setLayout(createBodyLayout());
	createControls(form.getBody());
}
 
Example 2
Source File: DBImportFirstPage.java    From elexis-3-core with Eclipse Public License 1.0 4 votes vote down vote up
public void createControl(Composite parent){
	DBImportWizard wiz = (DBImportWizard) getWizard();
	
	FormToolkit tk = UiDesk.getToolkit();
	Form form = tk.createForm(parent);
	form.setText(Messages.DBImportFirstPage_Connection); //$NON-NLS-1$
	Composite body = form.getBody();
	body.setLayout(new TableWrapLayout());
	tk.createLabel(body, Messages.DBImportFirstPage_EnterType); //$NON-NLS-1$
	dbTypes = new List(body, SWT.BORDER);
	dbTypes.setItems(supportedDB);
	dbTypes.addSelectionListener(new SelectionAdapter() {
		@Override
		public void widgetSelected(SelectionEvent e){
			int it = dbTypes.getSelectionIndex();
			switch (it) {
			case MYSQL:
			case POSTGRESQL:
				server.setEnabled(true);
				dbName.setEnabled(true);
				defaultUser = ""; //$NON-NLS-1$
				defaultPassword = ""; //$NON-NLS-1$
				break;
			case H2:
				server.setEnabled(false);
				dbName.setEnabled(true);
				defaultUser = "sa";
				defaultPassword = "";
				break;
			case ODBC:
				server.setEnabled(false);
				dbName.setEnabled(true);
				defaultUser = "sa"; //$NON-NLS-1$
				defaultPassword = ""; //$NON-NLS-1$
				break;
			default:
				break;
			}
			DBImportSecondPage sec = (DBImportSecondPage) getNextPage();
			sec.name.setText(defaultUser);
			sec.pwd.setText(defaultPassword);
			
		}
		
	});
	
	tk.adapt(dbTypes, true, true);
	tk.createLabel(body, Messages.DBImportFirstPage_serverAddress); //$NON-NLS-1$
	server = tk.createText(body, "", SWT.BORDER); //$NON-NLS-1$
	
	TableWrapData twr = new TableWrapData(TableWrapData.FILL_GRAB);
	server.setLayoutData(twr);
	tk.createLabel(body, Messages.DBImportFirstPage_databaseName); //$NON-NLS-1$
	dbName = tk.createText(body, "", SWT.BORDER); //$NON-NLS-1$
	TableWrapData twr2 = new TableWrapData(TableWrapData.FILL_GRAB);
	dbName.setLayoutData(twr2);
	if (wiz.preset != null && wiz.preset.length > 1) {
		int idx = StringTool.getIndex(supportedDB, wiz.preset[0]);
		if (idx < dbTypes.getItemCount()) {
			dbTypes.select(idx);
		}
		server.setText(wiz.preset[1]);
		dbName.setText(wiz.preset[2]);
	}
	setControl(form);
}
 
Example 3
Source File: DBConnectFirstPage.java    From elexis-3-core with Eclipse Public License 1.0 4 votes vote down vote up
public void createControl(Composite parent){
	FormToolkit tk = UiDesk.getToolkit();
	Form form = tk.createForm(parent);
	form.setText(Messages.DBConnectFirstPage_connectioNDetails); //$NON-NLS-1$
	Composite body = form.getBody();
	body.setLayout(new TableWrapLayout());
	FormText alt = tk.createFormText(body, false);
	StringBuilder old = new StringBuilder();
	old.append("<form>"); //$NON-NLS-1$
	String driver = "";
	String user = "";
	String typ = "";
	String connectString = "";
	Hashtable<Object, Object> hConn = null;
	String cnt = CoreHub.localCfg.get(Preferences.CFG_FOLDED_CONNECTION, null);
	if (cnt != null) {
		hConn = PersistentObject.fold(StringTool.dePrintable(cnt));
		if (hConn != null) {
			driver =
				PersistentObject.checkNull(hConn.get(Preferences.CFG_FOLDED_CONNECTION_DRIVER));
			connectString =
				PersistentObject.checkNull(hConn
					.get(Preferences.CFG_FOLDED_CONNECTION_CONNECTSTRING));
			user =
				PersistentObject.checkNull(hConn.get(Preferences.CFG_FOLDED_CONNECTION_USER));
			typ = PersistentObject.checkNull(hConn.get(Preferences.CFG_FOLDED_CONNECTION_TYPE));
		}
	}
	// Check whether we were overridden
	String dbUser = System.getProperty(ElexisSystemPropertyConstants.CONN_DB_USERNAME);
	String dbPw = System.getProperty(ElexisSystemPropertyConstants.CONN_DB_PASSWORD);
	String dbFlavor = System.getProperty(ElexisSystemPropertyConstants.CONN_DB_FLAVOR);
	String dbSpec = System.getProperty(ElexisSystemPropertyConstants.CONN_DB_SPEC);
	if (dbUser != null && dbPw != null && dbFlavor != null && dbSpec != null) {
		old.append("<br/><li><b>Aktuelle Verbindung wurde via Übergabeparameter ans Programm gesetzt!</b></li><br/>"); //$NON-NLS-1$
	}
	if (ch.rgw.tools.StringTool.isNothing(connectString)) {
		old.append("<br/>"); //$NON-NLS-1$
		old.append("Keine konfigurierte Verbindung."); //$NON-NLS-1$
	} else {
		old.append("Konfigurierte Verbindung ist:<br/>"); //$NON-NLS-1$
		old.append("<li><b>Typ:</b>       ").append(typ).append("</li>"); //$NON-NLS-1$ //$NON-NLS-2$
		old.append("<li><b>Treiber</b>    ").append(driver).append("</li>"); //$NON-NLS-1$ //$NON-NLS-2$
		old.append("<li><b>Verbinde</b>   ").append(connectString).append("</li>"); //$NON-NLS-1$ //$NON-NLS-2$
		old.append("<li><b>Username</b>   ").append(user).append("</li>"); //$NON-NLS-1$ //$NON-NLS-2$
	}
	if (PersistentObject.getConnection() != null
		&& PersistentObject.getConnection().getConnectString() != null) {
		old.append("<li><b>Effektiv</b> verwendet wird:").append( //$NON-NLS-1$
			PersistentObject.getConnection().getConnectString()).append("</li>"); //$NON-NLS-1$
	}
	old.append("</form>"); //$NON-NLS-1$
	alt.setText(old.toString(), true, false);
	// Composite form=new Composite(parent, SWT.BORDER);
	Label sep = tk.createSeparator(body, SWT.NONE);
	TableWrapData twd = new TableWrapData();
	twd.heightHint = 5;
	sep.setLayoutData(twd);
	tk.createLabel(body, Messages.DBConnectFirstPage_enterType); //$NON-NLS-1$
	dbTypes = new Combo(body, SWT.BORDER | SWT.SIMPLE);
	dbTypes.setItems(supportedDB);
	dbTypes.addSelectionListener(new SelectionAdapter() {
		@Override
		public void widgetSelected(SelectionEvent e){
			int it = dbTypes.getSelectionIndex();
			switch (it) {
			case 0:
			case 1:
				server.setEnabled(true);
				dbName.setEnabled(true);
				defaultUser = "elexis"; //$NON-NLS-1$
				defaultPassword = "elexisTest"; //$NON-NLS-1$
				break;
			case 2:
				server.setEnabled(false);
				dbName.setEnabled(true);
				defaultUser = "sa"; //$NON-NLS-1$
				defaultPassword = ""; //$NON-NLS-1$
				break;
			default:
				break;
			}
			DBConnectSecondPage sec = (DBConnectSecondPage) getNextPage();
			sec.name.setText(defaultUser);
			sec.pwd.setText(defaultPassword);
			
		}
		
	});
	tk.adapt(dbTypes, true, true);
	tk.createLabel(body, Messages.DBConnectFirstPage_serevrAddress); //$NON-NLS-1$
	server = tk.createText(body, "", SWT.BORDER); //$NON-NLS-1$
	TableWrapData twr = new TableWrapData(TableWrapData.FILL_GRAB);
	server.setLayoutData(twr);
	tk.createLabel(body, Messages.DBConnectFirstPage_databaseName); //$NON-NLS-1$
	dbName = tk.createText(body, "", SWT.BORDER); //$NON-NLS-1$
	TableWrapData twr2 = new TableWrapData(TableWrapData.FILL_GRAB);
	dbName.setLayoutData(twr2);
	setControl(form);
}