Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
Copyright (c) 2012 itemis AG (http://www.itemis.eu) and others. All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License v1.0 which accompanies this distribution, and is available at http://www.eclipse.org/legal/epl-v10.html /
  
  package org.eclipse.xtext.ui.validation;
  
 import java.util.List;
 
 import  org.eclipse.jface.dialogs.IDialogSettings;
 import  org.eclipse.jface.viewers.CellEditor.LayoutData;
 import  org.eclipse.swt.SWT;
 import  org.eclipse.swt.graphics.Point;
 import  org.eclipse.swt.layout.GridData;
 import  org.eclipse.swt.layout.GridLayout;
 import  org.eclipse.swt.widgets.Combo;
 import  org.eclipse.swt.widgets.Composite;
 import  org.eclipse.swt.widgets.Control;
 import  org.eclipse.swt.widgets.Label;
 import  org.eclipse.ui.forms.widgets.ExpandableComposite;
 

Author(s):
Dennis Huebner - Initial contribution and API
Since:
2.4
 
 	private IDialogSettings dialogSettings;
 	private String languageName;
 	private static final String PROPERTY_PREFIX = "ValidatorConfiguration"//$NON-NLS-1$
 
 		super();
 	}
 
 	public Control doCreateContents(Composite parent) {
 		 = new PixelConverter(parent);
 		setShell(parent.getShell());
 
 		Composite mainComp = new Composite(parent, SWT.NONE);
 		mainComp.setFont(parent.getFont());
 		GridLayout layout = new GridLayout();
 		layout.marginHeight = 0;
 		layout.marginWidth = 0;
 		mainComp.setLayout(layout);
 
 		Composite commonComposite = createStyleTabContent(mainComp);
 		GridData gridData = new GridData(GridData.FILL, GridData.FILL, truetrue);
 		gridData.heightHint = .convertHeightInCharsToPixels(20);
 		commonComposite.setLayoutData(gridData);
 		validateSettings(nullnullnull);
 		return mainComp;
 
 	}
 
 	private Composite createStyleTabContent(Composite folder) {
 		int nColumns = 3;
 		final ScrolledPageContent sc1 = new ScrolledPageContent(folder);
 
 		Composite composite = sc1.getBody();
 		GridLayout layout = new GridLayout(nColumnsfalse);
 		layout.marginHeight = 0;
 		layout.marginWidth = 0;
 		composite.setLayout(layout);
 
 		Label description = new Label(composite, SWT.LEFT | SWT.WRAP);
 		description.setFont(description.getFont());
 		description.setText("Select the severity level for the following optional " + lastSegment()
 				+ " compiler problems:");
 		description.setLayoutData(new GridData(GridData.BEGINNING, GridData.CENTER, truefalsenColumns - 1, 1));
 
 		fillSettingsPage(compositenColumns, 0);
 		addAdditionalComponentsToSettingsPage(compositenColumns, 0);
 
 		new Label(composite, SWT.NONE); // TODO what's this?
 		return sc1;
 
 	}

This implementation returns Dialog settings which were bind in org.eclipse.xtext.ui.DefaultUiModule normally org.eclipse.ui.plugin.AbstractUIPlugin.getDialogSettings()
Subclasses should override to get special section settings. Here is an example:
  
  
 protected IDialogSettings getDialogSettings() {
  IDialogSettings dialogSettings = super.getDialogSettings();
  IDialogSettings section = dialogSettings.getSection(SETTINGS_SECTION_NAME);
  if(section==null) {
   return dialogSettings.addNewSection(SETTINGS_SECTION_NAME);
  }
  return section;
 }
  
 

Returns:
Dialog settings which were bind in org.eclipse.xtext.ui.DefaultUiModule
Since:
2.7
	protected IDialogSettings getDialogSettings() {
		return this.;
	}

Since:
2.7
	protected void addAdditionalComponentsToSettingsPage(Composite settingsPageint nColumnsint defaultIndent) {
	}

Computes the common width hint (the largest width) and set it as GridData.widthHint for all combos, if the combo has a GridData as LayoutData.
	protected void adjustComboWidth(List<Combo> combos) {
		int withHint = SWT.DEFAULT;
		for (Combo comboBox : combos) {
			comboBox.pack(true);
			Point computeSize = comboBox.computeSize(SWT.DEFAULT, SWT.DEFAULT);
			int pixels = computeSize.x;
			if (pixels > withHint) {
				withHint = pixels;
			}
		}
		for (Combo comboBox : combos) {
			Object ld = comboBox.getLayoutData();
			if (ld instanceof GridData) {
				GridData layoutData = (GridData) ld;
				layoutData.widthHint = withHint;
			}
		}
	}
	private String lastSegment(String languageFQN) {
		String simplename = languageFQN;
		int lastDot = languageFQN.lastIndexOf('.');
		if (lastDot >= 0 && lastDot < languageFQN.length() - 1) {
			simplename = languageFQN.substring(lastDot + 1, languageFQN.length());
		}
		return simplename;
	}
	protected abstract void fillSettingsPage(Composite compositeint nColumnsint defaultIndent);
	protected Composite createSection(String label, Composite compositeint nColumns) {
		ExpandableComposite excomposite = createStyleSection(compositelabelnColumns);
		Composite inner = new Composite(excomposite, SWT.NONE);
		inner.setFont(composite.getFont());
		inner.setLayout(new GridLayout(nColumnsfalse));
		excomposite.setClient(inner);
		return inner;
	}

Since:
2.8
	}
New to GrepCode? Check out our FAQ X