Java Code Examples for org.eclipse.swt.layout.GridData#HORIZONTAL_ALIGN_FILL

The following examples show how to use org.eclipse.swt.layout.GridData#HORIZONTAL_ALIGN_FILL . 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: TypeScriptTemplatePreferencePage.java    From typescript.java with MIT License 6 votes vote down vote up
protected SourceViewer createViewer(Composite parent) {
	IDocument document= new Document();
	JavaScriptTextTools tools= JSDTTypeScriptUIPlugin.getDefault().getJavaTextTools();
	tools.setupJavaDocumentPartitioner(document, IJavaScriptPartitions.JAVA_PARTITIONING);
	IPreferenceStore store= JSDTTypeScriptUIPlugin.getDefault().getCombinedPreferenceStore();
	SourceViewer viewer= new JavaSourceViewer(parent, null, null, false, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL, store);
	SimpleJavaSourceViewerConfiguration configuration= new SimpleJavaSourceViewerConfiguration(tools.getColorManager(), store, null, IJavaScriptPartitions.JAVA_PARTITIONING, false);
	viewer.configure(configuration);
	viewer.setEditable(false);
	viewer.setDocument(document);

	Font font= JFaceResources.getFont(PreferenceConstants.EDITOR_TEXT_FONT);
	viewer.getTextWidget().setFont(font);
	new TypeScriptSourcePreviewerUpdater(viewer, configuration, store);
	
	Control control= viewer.getControl();
	GridData data= new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.FILL_VERTICAL);
	control.setLayoutData(data);
	
	return viewer;
}
 
Example 2
Source File: AbstractTracePackageWizardPage.java    From tracecompass with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * Create the file path group that allows the user to type or browse for a
 * file path
 *
 * @param parent
 *            the parent composite
 * @param label
 *            the label to describe the file path (i.e. import/export)
 * @param fileDialogStyle
 *            SWT.OPEN or SWT.SAVE
 */
protected void createFilePathGroup(Composite parent, String label, final int fileDialogStyle) {

    Composite filePathSelectionGroup = new Composite(parent, SWT.NONE);
    GridLayout layout = new GridLayout();
    layout.numColumns = 3;
    filePathSelectionGroup.setLayout(layout);
    filePathSelectionGroup.setLayoutData(new GridData(
            GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_FILL));

    Label destinationLabel = new Label(filePathSelectionGroup, SWT.NONE);
    destinationLabel.setText(label);

    fFilePathCombo = new Combo(filePathSelectionGroup, SWT.SINGLE
            | SWT.BORDER);
    GridData data = new GridData(GridData.HORIZONTAL_ALIGN_FILL
            | GridData.GRAB_HORIZONTAL);
    data.grabExcessHorizontalSpace = true;
    fFilePathCombo.setLayoutData(data);

    fBrowseButton = new Button(filePathSelectionGroup,
            SWT.PUSH);
    fBrowseButton.setText(org.eclipse.tracecompass.internal.tmf.ui.project.wizards.tracepkg.Messages.TracePackage_Browse);
    fBrowseButton.addListener(SWT.Selection, event -> handleFilePathBrowseButtonPressed(fileDialogStyle));
    setButtonLayoutData(fBrowseButton);
}
 
Example 3
Source File: OptionsConfigurationBlock.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
protected Link addLink(Composite parent, String label, Key key, SelectionListener linkListener, int indent, int widthHint) {
	GridData gd= new GridData(GridData.HORIZONTAL_ALIGN_FILL);
	gd.horizontalSpan= 3;
	gd.horizontalIndent= indent;
	gd.widthHint= widthHint;

	Link link= new Link(parent, SWT.NONE);
	link.setFont(JFaceResources.getDialogFont());
	link.setText(label);
	link.setData(key);
	link.setLayoutData(gd);
	link.addSelectionListener(linkListener);

	makeScrollableCompositeAware(link);

	fLinks.add(link);

	return link;
}
 
Example 4
Source File: InputDialogWithLongMessage.java    From Pydev with Eclipse Public License 1.0 5 votes vote down vote up
@Override
protected Control createDialogArea(Composite parent) {
    // create composite
    Composite composite = (Composite) super.createDialogArea(parent);
    // create message
    if (message != null) {
        Text messageText = new Text(composite,
                SWT.BORDER | SWT.MULTI | SWT.READ_ONLY | SWT.V_SCROLL | SWT.H_SCROLL);
        messageText.setText(message);
        GridData data = new GridData(GridData.GRAB_HORIZONTAL
                | GridData.GRAB_VERTICAL | GridData.HORIZONTAL_ALIGN_FILL
                | GridData.VERTICAL_ALIGN_CENTER);
        data.widthHint = convertHorizontalDLUsToPixels(IDialogConstants.MINIMUM_MESSAGE_AREA_WIDTH);
        messageText.setLayoutData(data);
        messageText.setFont(parent.getFont());
    }
    text = new Text(composite, getInputTextStyle());
    text.setLayoutData(new GridData(GridData.GRAB_HORIZONTAL
            | GridData.HORIZONTAL_ALIGN_FILL));
    text.addModifyListener(e -> validateInput());
    errorMessageText = new Text(composite, SWT.READ_ONLY | SWT.WRAP);
    errorMessageText.setLayoutData(new GridData(GridData.GRAB_HORIZONTAL
            | GridData.HORIZONTAL_ALIGN_FILL));
    errorMessageText.setBackground(errorMessageText.getDisplay()
            .getSystemColor(SWT.COLOR_WIDGET_BACKGROUND));
    // Set the error message text
    // See https://bugs.eclipse.org/bugs/show_bug.cgi?id=66292
    setErrorMessage(errorMessage);

    applyDialogFont(composite);
    return composite;
}
 
Example 5
Source File: AddRemoveList.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Sets the <code>GridData</code> on the specified button to be one that is spaced for the current dialog page
 * units. The method <code>initializeDialogUnits</code> must be called once before calling this method for the first
 * time.
 * 
 * @param button
 *            the button to set the <code>GridData</code>
 * @return the <code>GridData</code> set on the specified button
 */
protected GridData setButtonLayoutData(Button button)
{
	GridData data = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
	PixelConverter converter = new PixelConverter(button);
	int widthHint = converter.convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH);
	Point minSize = button.computeSize(SWT.DEFAULT, SWT.DEFAULT, true);
	data.widthHint = Math.max(widthHint, minSize.x);
	button.setLayoutData(data);
	return data;
}
 
Example 6
Source File: SDView.java    From tracecompass with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public void createPartControl(Composite c) {
    Composite parent = new Composite(c, SWT.NONE);
    GridLayout parentLayout = new GridLayout();
    parentLayout.numColumns = 2;
    parentLayout.marginWidth = 0;
    parentLayout.marginHeight = 0;
    parent.setLayout(parentLayout);

    GridData timeLayoutdata = new GridData(GridData.GRAB_VERTICAL | GridData.VERTICAL_ALIGN_FILL);
    timeLayoutdata.widthHint = 10;
    GridData seqDiagLayoutData = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.GRAB_HORIZONTAL | GridData.GRAB_VERTICAL | GridData.VERTICAL_ALIGN_FILL);
    fTimeCompressionBar = new TimeCompressionBar(parent, SWT.NONE);
    fTimeCompressionBar.setLayoutData(timeLayoutdata);
    fSdWidget = new SDWidget(parent, SWT.NONE);
    fSdWidget.setLayoutData(seqDiagLayoutData);
    fSdWidget.setSite(this);
    fSdWidget.setTimeBar(fTimeCompressionBar);

    // Add this view to the key bindings manager
    KeyBindingsManager.getInstance().add(this.getSite().getId());

    createCoolbarContent();

    hookContextMenu();

    fTimeCompressionBar.setVisible(false);
    parent.layout(true);

    fPrintActionHandler = new ActionHandler(new Print(this));
    getSite().getPage().addPartListener(this);

    fNeedInit = restoreLoader();
}
 
Example 7
Source File: SignalTab.java    From ProtocolAnalyzer with GNU General Public License v3.0 5 votes vote down vote up
public SignalTab(RawProtocolMessage message, CTabFolder chartFolder) {
    // Check what kind of data we have, if it is only pulses, then just generate
    // the pulse series and if we have samples, then generate the sampleSeries as well
    if (messageHasOnlyPulseData(message)) {
        signalSeriesCollection = createPlotDataFromPulsesOnly(message.m_PulseLengths);
    } else {
        signalSeriesCollection = createPlotDataFromSamplesAndPulses(message);
    }
    selectedPulseSeries = new XYSeries("Selected Pulses", false);
    signalSeriesCollection.addSeries(selectedPulseSeries);

    // Create tab for signal
    CTabItem signalTab = new CTabItem(chartFolder, SWT.NONE);
    signalTab.setText("Signal");

    // Create a Chart and a panel for signal
    JFreeChart chart = ChartFactory.createXYLineChart("Signal", "ms", "Amplitude", signalSeriesCollection, PlotOrientation.VERTICAL, true, false, false);
    ChartPanel chartPanel = new ChartPanel(chart);
    chartPanel.setPreferredSize(new Dimension(700, 290));
    RawSignalWindow.configurePanelLooks(chart, 2);

    // Create a ChartComposite on our window
    ChartComposite frame = new ChartComposite(chartFolder, SWT.NONE, chart, true);
    frame.setHorizontalAxisTrace(false);
    frame.setVerticalAxisTrace(false);
    frame.setDisplayToolTips(true);
    GridData gridDatap = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_BEGINNING);
    gridDatap.grabExcessHorizontalSpace = true;
    gridDatap.grabExcessVerticalSpace = false;
    //gridDatap.heightHint = 270;
    frame.setLayoutData(gridDatap);
    signalTab.setControl(frame);
}
 
Example 8
Source File: LevelDynamicAttributeDialog.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
protected Control createDialogArea( Composite parent )
{
	Composite composite = (Composite) super.createDialogArea( parent );

	Composite container = new Composite( composite, SWT.NONE );
	container.setLayoutData( new GridData( GridData.FILL_BOTH ) );

	GridLayout layout = new GridLayout( );
	layout.numColumns = 2;
	layout.marginWidth = layout.marginHeight = 0;
	container.setLayout( layout );

	Label nameLabel = new Label( container, SWT.WRAP );
	nameLabel.setText( Messages.getString("LevelDynamicAttributeDialog.Label.Member") ); //$NON-NLS-1$
	nameLabel.setLayoutData( new GridData( ) );
	nameLabel.setFont( parent.getFont( ) );

	memberCombo = new Combo( container, SWT.BORDER | SWT.READ_ONLY );
	memberCombo.setVisibleItemCount( 30 );
	GridData gd = new GridData( GridData.GRAB_HORIZONTAL
			| GridData.HORIZONTAL_ALIGN_FILL );
	gd.widthHint = 250;
	memberCombo.setLayoutData( gd );
	memberCombo.addSelectionListener( new SelectionAdapter( ) {

		public void widgetSelected( SelectionEvent e )
		{
			checkButtonStatus( );
		}
	} );

	applyDialogFont( composite );

	UIUtil.bindHelp( parent, IHelpContextIds.LEVEL_DYNAMIC_ATTRIBUTE_DIALOG );

	initDialog( );

	return composite;
}
 
Example 9
Source File: MarkOccurrencesConfigurationBlock.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
private void addFiller(Composite composite) {
	PixelConverter pixelConverter= new PixelConverter(composite);

	Label filler= new Label(composite, SWT.LEFT );
	GridData gd= new GridData(GridData.HORIZONTAL_ALIGN_FILL);
	gd.horizontalSpan= 2;
	gd.heightHint= pixelConverter.convertHeightInCharsToPixels(1) / 2;
	filler.setLayoutData(gd);
}
 
Example 10
Source File: RawSignalWindow.java    From ProtocolAnalyzer with GNU General Public License v3.0 5 votes vote down vote up
private CTabFolder createTabFolder(Shell shell1) {
    CTabFolder chartFolder = new CTabFolder(shell1, SWT.NONE);
    GridData folderGridData = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_BEGINNING);
    folderGridData.grabExcessHorizontalSpace = true;
    folderGridData.grabExcessVerticalSpace = false;
    folderGridData.heightHint = 280;
    chartFolder.setLayoutData(folderGridData);
    return chartFolder;
}
 
Example 11
Source File: InputDialog.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
protected Control createDialogArea(Composite parent) {
    // create composite
    Composite composite = (Composite) super.createDialogArea(parent);
    // create message
    if (message != null) {
        Label label = new Label(composite, SWT.WRAP);
        label.setText(message);
        GridData data = new GridData(GridData.GRAB_HORIZONTAL
                | GridData.GRAB_VERTICAL | GridData.HORIZONTAL_ALIGN_FILL
                | GridData.VERTICAL_ALIGN_CENTER);
        data.widthHint = convertHorizontalDLUsToPixels(IDialogConstants.MINIMUM_MESSAGE_AREA_WIDTH);
        label.setLayoutData(data);
        label.setFont(parent.getFont());
    }
    text = new Text(composite, SWT.PASSWORD);
    text.setLayoutData(new GridData(GridData.GRAB_HORIZONTAL
            | GridData.HORIZONTAL_ALIGN_FILL));
    text.addModifyListener(new ModifyListener() {
        public void modifyText(ModifyEvent e) {
            validateInput();
        }
    });
    errorMessageText = new Text(composite, SWT.READ_ONLY | SWT.WRAP);
    errorMessageText.setLayoutData(new GridData(GridData.GRAB_HORIZONTAL
            | GridData.HORIZONTAL_ALIGN_FILL));
    errorMessageText.setBackground(errorMessageText.getDisplay()
            .getSystemColor(SWT.COLOR_WIDGET_BACKGROUND));
    // Set the error message text
    // See https://bugs.eclipse.org/bugs/show_bug.cgi?id=66292
    setErrorMessage(errorMessage);

    applyDialogFont(composite);
    return composite;
}
 
Example 12
Source File: JavaBasePreferencePage.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
private Button addRadioButton(Composite parent, String label, String key, String value) {
	GridData gd= new GridData(GridData.HORIZONTAL_ALIGN_FILL);

	Button button= new Button(parent, SWT.RADIO);
	button.setText(label);
	button.setData(new String[] { key, value });
	button.setLayoutData(gd);

	button.setSelection(value.equals(getPreferenceStore().getString(key)));

	fRadioButtons.add(button);
	return button;
}
 
Example 13
Source File: DetailsDialogWithProjects.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
/**
 * @see DetailsDialog#createMainDialogArea(Composite)
 */
protected void createMainDialogArea(Composite composite) {
	Label label = new Label(composite, SWT.WRAP);
	label.setText(message); //$NON-NLS-1$
	GridData data = new GridData(
		GridData.GRAB_HORIZONTAL |
		GridData.GRAB_VERTICAL |
		GridData.HORIZONTAL_ALIGN_FILL |
		GridData.VERTICAL_ALIGN_CENTER);
	data.widthHint = convertHorizontalDLUsToPixels(IDialogConstants.MINIMUM_MESSAGE_AREA_WIDTH);
	label.setLayoutData(data);
	label.setFont(composite.getFont());
	updateEnablements();
}
 
Example 14
Source File: CustomDataSetWizardPage.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Creates custom control for user-defined query text.
 */
private Control createPageControl( Composite parent )
{
    Composite composite = new Composite( parent, SWT.NONE );
    composite.setLayout( new GridLayout( 1, false ) );
    GridData gridData = new GridData( GridData.HORIZONTAL_ALIGN_FILL
            | GridData.VERTICAL_ALIGN_FILL );

    composite.setLayoutData( gridData );

    Label fieldLabel = new Label( composite, SWT.NONE );
    fieldLabel.setText( "&Query Text:" );

    m_queryTextField = new Text( composite, SWT.BORDER
            | SWT.V_SCROLL | SWT.H_SCROLL );
    GridData data = new GridData( GridData.FILL_HORIZONTAL );
    data.heightHint = 100;
    m_queryTextField.setLayoutData( data );
    m_queryTextField.addModifyListener( new ModifyListener( )
    {
        public void modifyText( ModifyEvent e )
        {
            validateData();
        }
    } );

    setPageComplete( false );
    return composite;
}
 
Example 15
Source File: OptionsConfigurationBlock.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
protected Text addTextField(Composite parent, String label, Key key, int indent, int widthHint) {
	Label labelControl= new Label(parent, SWT.WRAP);
	labelControl.setText(label);
	labelControl.setFont(JFaceResources.getDialogFont());
	GridData gd= new GridData();
	gd.horizontalIndent= indent;
	labelControl.setLayoutData(gd);

	Text textBox= new Text(parent, SWT.BORDER | SWT.SINGLE);
	textBox.setData(key);

	makeScrollableCompositeAware(textBox);

	fLabels.put(textBox, labelControl);

	updateText(textBox);
	
	textBox.addModifyListener(getTextModifyListener());

	GridData data= new GridData(GridData.HORIZONTAL_ALIGN_FILL);
	if (widthHint != 0) {
		data.widthHint= widthHint;
	}
	data.horizontalSpan= 2;
	textBox.setLayoutData(data);

	fTextBoxes.add(textBox);
	return textBox;
}
 
Example 16
Source File: DerbyPropertiesPage.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
protected GridData getSeperatorLabelGridData() {

    GridData gridData = new GridData(GridData.BEGINNING |
                            GridData.HORIZONTAL_ALIGN_FILL |
                            GridData.GRAB_VERTICAL |
                            GridData.BEGINNING |
                            GridData.VERTICAL_ALIGN_BEGINNING |
                            GridData.VERTICAL_ALIGN_FILL) ;
    gridData.horizontalSpan = 2;
    gridData.grabExcessVerticalSpace  = false;
    gridData.grabExcessHorizontalSpace = true;
    return gridData;

}
 
Example 17
Source File: NativeLibrariesPropertyPage.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 4 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
protected Control createContents(Composite parent) {
	if (!fIsValidElement || fIsReadOnly) {
		Composite inner= new Composite(parent, SWT.NONE);
		
		if (fIsReadOnly) {
			GridLayout layout= new GridLayout();
			layout.marginWidth= 0;
			inner.setLayout(layout);

			Label label= new Label(inner, SWT.WRAP);
			label.setText(PreferencesMessages.NativeLibrariesPropertyPage_location_path);
			
			Text location= new Text(inner, SWT.READ_ONLY | SWT.WRAP);
			SWTUtil.fixReadonlyTextBackground(location);
			GridData gd= new GridData(GridData.HORIZONTAL_ALIGN_FILL);
			gd.widthHint= convertWidthInCharsToPixels(80);
			location.setLayoutData(gd);
			String locationPath= PreferencesMessages.NativeLibrariesPropertyPage_locationPath_none;
			if (fEntry != null) {
				String nativeLibrariesPath= getNativeLibrariesPath(fEntry);
				if (nativeLibrariesPath != null)
					locationPath= nativeLibrariesPath;
			}
			location.setText(locationPath);
			Dialog.applyDialogFont(inner);
		}
		return inner;
	}

	IJavaElement elem= getJavaElement();
	if (elem == null)
		return new Composite(parent, SWT.NONE);

	fInitialNativeLibPath= getNativeLibrariesPath(fEntry);
	fConfigurationBlock= new NativeLibrariesConfigurationBlock(this, getShell(), fInitialNativeLibPath, fEntry);
	Control control= fConfigurationBlock.createContents(parent);

	Dialog.applyDialogFont(control);
	return control;
}
 
Example 18
Source File: WizardSaveAsPage.java    From birt with Eclipse Public License 1.0 4 votes vote down vote up
/**
 * Creates this object's visual components.
 * 
 * @param parent
 *            org.eclipse.swt.widgets.Composite
 * @param heightHint
 *            height hint for the container selection widget group
 */
protected void createContents( Composite parent,
		String resourceLabelString, int heightHint )
{

	Font font = parent.getFont( );
	// server name group
	Composite composite = new Composite( parent, SWT.NONE );
	GridLayout layout = new GridLayout( );
	layout.marginWidth = 0;
	layout.marginHeight = 0;
	composite.setLayout( layout );
	composite.setLayoutData( new GridData( SWT.FILL, SWT.FILL, true, true ) );
	composite.setFont( font );

	// container group
	if ( heightHint == SWT.DEFAULT )
		containerGroup = new ContainerSelectionGroup( composite,
				this,
				true,
				null,
				showClosedProjects );
	else
		containerGroup = new ContainerSelectionGroup( composite,
				this,
				true,
				null,
				showClosedProjects,
				heightHint );

	// resource name group
	Composite nameGroup = new Composite( composite, SWT.NONE );
	layout = new GridLayout( );
	layout.numColumns = 2;
	layout.marginWidth = 0;
	nameGroup.setLayout( layout );
	nameGroup.setLayoutData( new GridData( GridData.HORIZONTAL_ALIGN_FILL
			| GridData.GRAB_HORIZONTAL ) );
	nameGroup.setFont( font );

	Label label = new Label( nameGroup, SWT.NONE );
	label.setText( resourceLabelString );
	label.setFont( font );

	// resource name entry field
	resourceNameField = new Text( nameGroup, SWT.BORDER );
	resourceNameField.addListener( SWT.Modify, this );
	GridData data = new GridData( GridData.HORIZONTAL_ALIGN_FILL
			| GridData.GRAB_HORIZONTAL );
	data.widthHint = SIZING_TEXT_FIELD_WIDTH;
	resourceNameField.setLayoutData( data );
	resourceNameField.setFont( font );

	validateControls( );
}
 
Example 19
Source File: MinMaxDialog.java    From tracecompass with Eclipse Public License 2.0 4 votes vote down vote up
/**
 * Method to create a grid data base on horizontal span.
 * @param span The horizontal span
 * @return a grid data object
 */
protected GridData newGridData(int span) {
    GridData data = new GridData(GridData.GRAB_VERTICAL | GridData.VERTICAL_ALIGN_FILL | GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL);
    data.horizontalSpan = span;
    return data;
}
 
Example 20
Source File: DialogField.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
protected static GridData gridDataForLabel(int span) {
	GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
	gd.horizontalSpan = span;
	return gd;
}