Java Code Examples for org.eclipse.swt.custom.ScrolledComposite#setMinSize()

The following examples show how to use org.eclipse.swt.custom.ScrolledComposite#setMinSize() . 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: TaskSelectType.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
protected void createBottomTypeArea( Composite parent )
{
	ScrolledComposite sc = new ScrolledComposite( parent, SWT.V_SCROLL
			| SWT.H_SCROLL );
	{
		GridLayout layout = new GridLayout( );
		sc.setLayout( layout );
		GridData gridData = new GridData( GridData.FILL_BOTH );
		sc.setLayoutData( gridData );
		sc.setExpandHorizontal( true );
		sc.setExpandVertical( true );
	}

	cmpType = new Composite( sc, SWT.NONE );
	cmpType.setLayout( new GridLayout( 2, false ) );
	cmpType.setLayoutData( new GridData( GridData.FILL_HORIZONTAL ) );
	sc.setContent( cmpType );

	createLeftTypeTable( cmpType );
	populateChartTypes( );

	createRightDetails( cmpType );

	Point size = cmpType.computeSize( SWT.DEFAULT, SWT.DEFAULT );
	sc.setMinSize( size );
}
 
Example 2
Source File: MainView.java    From mappwidget with Apache License 2.0 6 votes vote down vote up
private void fillTop(Composite top, ScrolledComposite scrolledComposite)
{
	GridLayout layout = new GridLayout();
	layout.numColumns = 1;

	GridData data = new GridData();
	data.grabExcessHorizontalSpace = true;
	data.horizontalAlignment = GridData.FILL;

	top.setLayoutData(data);
	top.setLayout(layout);

	scrolledComposite.setMinSize(500, 250);
	scrolledComposite.setExpandHorizontal(true);
	scrolledComposite.setExpandVertical(true);
	scrolledComposite.setContent(top);
}
 
Example 3
Source File: TestDatabaseConnectorOutputWizardPage.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
@Override
protected void buildListOfOutputForOneRowNCols(final ScrolledComposite scrolledComposite,final EMFDataBindingContext context) {
	if(scrolledComposite.getContent() != null){
		scrolledComposite.getContent().dispose();
		scrolledComposite.setContent(null);
	}
	final Composite oneRowNColsComposite = new Composite(scrolledComposite, SWT.NONE) ;
	oneRowNColsComposite.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create()) ;
	oneRowNColsComposite.setLayout(GridLayoutFactory.fillDefaults().numColumns(2).margins(10, 10).create());


	final ConnectorConfiguration configuration = getConnector().getConfiguration();
	final Expression scriptExpression = (Expression) getConnectorParameter(configuration, getInput(SCRIPT_KEY)).getExpression();
	final List<Operation> operations = getOuputOperationsFor(ONEROW_NCOL_RESULT_OUTPUT,scriptExpression);
	for(final Operation op : operations){
		final Label expressionLabel = new Label(oneRowNColsComposite, SWT.READ_ONLY);
		expressionLabel.setText(Messages.connectorExpressionViewerLabel);

		final Text columnText = new Text(oneRowNColsComposite,SWT.BORDER | SWT.READ_ONLY) ;
		columnText.setLayoutData(GridDataFactory.fillDefaults().grab(true,false).create());
		columnText.setText(op.getRightOperand().getName());
	}
	scrolledComposite.setMinSize(oneRowNColsComposite.computeSize(SWT.DEFAULT, SWT.DEFAULT));
	scrolledComposite.setAlwaysShowScrollBars(false);
	scrolledComposite.setExpandHorizontal(true);
	scrolledComposite.setExpandVertical(true);
	scrolledComposite.setContent(oneRowNColsComposite);
}
 
Example 4
Source File: WizardPageOperationsComposite.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void refresh() {
       final Composite shell = parent.getShell();
       final Point compositesize = parent.getSize();
       final Point newcompositesize = computeSize(SWT.DEFAULT, SWT.DEFAULT, true);
       final Point defaultSize = shell.getSize();
       final Point size = shell.computeSize(SWT.DEFAULT, SWT.DEFAULT, true);
       if (compositesize.x < newcompositesize.x) {
           shell.setSize(size.x, defaultSize.y);
       }
       shell.layout(true, true);

       if (parent.getParent() instanceof ScrolledComposite) {
           final ScrolledComposite scrolledComposite = (ScrolledComposite) parent.getParent();
           scrolledComposite.setMinSize(computeSize(SWT.DEFAULT, SWT.DEFAULT));
           Display.getDefault().asyncExec(new Runnable() {

               @Override
               public void run() {
                   scrolledComposite.getVerticalBar().setSelection(scrolledComposite.getVerticalBar().getMaximum());
               }
           });

       }
	if (tabbedPropertySheetPage != null) {
		tabbedPropertySheetPage.resizeScrolledComposite();
	}
}
 
Example 5
Source File: GenericSelectionComposite.java    From elexis-3-core with Eclipse Public License 1.0 5 votes vote down vote up
@Override
protected Control createDialogArea(Composite parent){
	Composite ret = (Composite) super.createDialogArea(parent);
	ScrolledComposite sc = new ScrolledComposite(ret, SWT.H_SCROLL | SWT.V_SCROLL);
	
	Composite child = new Composite(sc, SWT.NONE);
	child.setLayout(new GridLayout());
	
	GridData data = new GridData(SWT.FILL, SWT.FILL, true, true);
	data.heightHint = 400;
	sc.setLayoutData(data);

	Label title = new Label(child, SWT.NONE);
	title.setText("Auswahl:");
	// create the UI
	for (Object object : input) {
		Button button = new Button(child, SWT.CHECK);
		button.setText(getLabel(object));
		button.addSelectionListener(new SelectionAdapter() {
			@Override
			public void widgetSelected(SelectionEvent e){
				if (button.getSelection()) {
					selection.add(object);
				} else {
					selection.remove(object);
				}
			}
		});
		buttonMap.put(object, button);
	}
	sc.setMinSize(child.computeSize(SWT.DEFAULT, SWT.DEFAULT));
	sc.setExpandHorizontal(true);
	sc.setExpandVertical(true);
    sc.setContent(child);

	updateSelectionUi();
	
	return ret;
}
 
Example 6
Source File: PropertiesView.java    From tmxeditor8 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void createPartControl(Composite parent) {
	parent.setLayout(new FillLayout());
	addToolBarAction();
	scrolledComposite = new ScrolledComposite(parent, SWT.H_SCROLL | SWT.V_SCROLL);
	scrolledComposite.setLayout(new FillLayout());
	scrolledComposite.setExpandHorizontal(true);
	scrolledComposite.setExpandVertical(true);

	compostie = new Composite(scrolledComposite, SWT.NONE);
	compostie.setLayout(new GridLayout(1, false));

	// TU 属性
	TableViewer tbvTu = createTuAttrTable(createMenuManager());
	tableViewerManager.put(TU_ATTRS, tbvTu);

	// TUV 属性
	TableViewer tbvProp = createTuPropTable(createMenuManager());
	tableViewerManager.put(TU_NODE_PROPS, tbvProp);

	// Prop 节点
	TableViewer tbvTuv = createTuvAttrTable(createMenuManager());
	tableViewerManager.put(TUV_ATTRS, tbvTuv);

	// Note 节点
	TableViewer tbvNote = createTuNoteTable(createMenuManager());
	tableViewerManager.put(TU_NODE_NOTE, tbvNote);

	scrolledComposite.setContent(compostie);
	scrolledComposite.setMinSize(compostie.computeSize(SWT.DEFAULT, SWT.DEFAULT));
	setGlobalActionHandler();
}
 
Example 7
Source File: AccordionControl.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
/** Toggles the visibility of the children of the given label */
private void toggle( AccordionLabel label, boolean performLayout,
		boolean autoClose )
{
	if ( autoClose )
	{
		collapseAll( true );
	}
	ScrolledComposite scrolledComposite = getContentArea( label );

	GridData scrollGridData = (GridData) scrolledComposite.getLayoutData( );
	boolean close = !scrollGridData.exclude;
	scrollGridData.exclude = close;
	scrolledComposite.setVisible( !close );
	updateIcon( label );

	if ( !scrollGridData.exclude && scrolledComposite.getContent( ) == null )
	{
		Composite composite = createChildContainer( scrolledComposite );
		Object header = getHeader( label );
		createChildren( composite, header );
		scrolledComposite.setContent( composite );
		scrolledComposite.setMinSize( composite.computeSize( SWT.DEFAULT,
				SWT.DEFAULT ) );
	}

	if ( performLayout )
	{
		layout( true );
	}

	Event event = new Event( );
	event.widget = this;
	notifyListeners( SWT.SELECTED, event );
}
 
Example 8
Source File: LibrarySelectorGroup.java    From google-cloud-eclipse with Apache License 2.0 5 votes vote down vote up
private void createContents(Composite parentContainer, String groupLabel) {
  ScrolledComposite scrolledComposite = new ScrolledComposite(parentContainer, SWT.V_SCROLL);

  Group apiGroup = new Group(scrolledComposite, SWT.NONE);
  apiGroup.setText(groupLabel);

  for (Library library : availableLibraries.values()) {
    Button libraryButton = new Button(apiGroup, SWT.CHECK);
    libraryButton.setText(getLibraryName(library));
    String toolTip = library.getToolTip();
    if (toolTip != null) {
      String stage = library.getLaunchStage();
      if (!"GA".equals(stage)) { //$NON-NLS-1
        toolTip += " (" + stage + ")";
      }
      libraryButton.setToolTipText(toolTip);
    }
    libraryButton.setData(library);
    libraryButton.addSelectionListener(new ManualSelectionTracker());
    libraryButtons.put(library, libraryButton);
  }
  GridLayoutFactory.swtDefaults().generateLayout(apiGroup);
  apiGroup.pack();

  scrolledComposite.setContent(apiGroup);
  scrolledComposite.setMinSize(apiGroup.computeSize(SWT.DEFAULT, SWT.DEFAULT));
  scrolledComposite.setShowFocusedControl(true);
  scrolledComposite.setExpandHorizontal(true);

  GridDataFactory.fillDefaults().grab(true, true).applyTo(scrolledComposite);
  GridLayoutFactory.fillDefaults().generateLayout(scrolledComposite);
}
 
Example 9
Source File: BitwiseFlagsPicker.java    From XPagesExtensionLibrary with Apache License 2.0 5 votes vote down vote up
@Override
protected void fillClientArea(Composite parent) {
    //create the scrolled area that will contain the checkBox container composite.
    ScrolledComposite scrolledParentComposite = createScrolledComposite(parent);
    //create the composite that will hold the checkBoxes and become the content of the scrolled composite 
    Composite checkBoxContainerComposite = new Composite(scrolledParentComposite, SWT.NONE); // $NON-NLS-1$
    checkBoxContainerComposite.setLayout(new GridLayout());
    checkBoxContainerComposite.setLayoutData(new GridData(GridData.FILL_BOTH));
    checkBoxContainerComposite.setBackground(parent.getDisplay().getSystemColor(SWT.COLOR_WHITE));
    
    //parse the parameters to get a HashMap of value label pairs, that we use to create checkBoxes. 
    HashMap<ComparableHexString,String> valueLabelPairs = parseParameters(); 
    
    if(!valueLabelPairs.isEmpty()){
        ArrayList<ComparableHexString> values = new ArrayList<ComparableHexString>(valueLabelPairs.keySet());
        Collections.sort(values);
        Iterator<ComparableHexString> valuesIter = values.iterator();
        while(valuesIter.hasNext()){
            //double check that value is in fact an int that we can do bitwise operation on.
            ComparableHexString value = valuesIter.next();
            if(value.getIntValue() > -1){
                String label = valueLabelPairs.get(value);
                if(StringUtil.isNotEmpty(label)){
                    //create the checkBox that will set this bit flag and add it to our list of checkBoxes. 
                    ExtendedCustomCheckbox checkBox = createCheckBox(checkBoxContainerComposite, label, value.getHexString());
                    _optionCheckBoxes.add(checkBox);
                }
            }
        }
        //if there was already a value set then we need to see which checkBoxes should be checked based on that value.
        updateCheckboxState(); 
        //set the checkBox container composite as the content of the scrolled composite
        scrolledParentComposite.setContent(checkBoxContainerComposite);
        scrolledParentComposite.setMinSize(checkBoxContainerComposite.computeSize(SWT.DEFAULT, SWT.DEFAULT));
        
    }
}
 
Example 10
Source File: TmfAbstractToolTipHandler.java    From tracecompass with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public Point create() {
    Composite parent = getParent();
    Table<ToolTipString, ToolTipString, ToolTipString> model = getModel();
    if (parent == null || model.size() == 0) {
        // avoid displaying empty tool tips.
        return null;
    }
    setupControl(parent);
    ScrolledComposite scrolledComposite = new ScrolledComposite(parent, SWT.H_SCROLL | SWT.V_SCROLL);
    scrolledComposite.setExpandVertical(true);
    scrolledComposite.setExpandHorizontal(true);
    setupControl(scrolledComposite);

    Composite composite = new Composite(scrolledComposite, SWT.NONE);
    fComposite = composite;
    composite.setLayout(new GridLayout(3, false));
    setupControl(composite);
    Set<ToolTipString> rowKeySet = model.rowKeySet();
    for (ToolTipString row : rowKeySet) {
        Set<Entry<ToolTipString, ToolTipString>> entrySet = model.row(row).entrySet();
        for (Entry<ToolTipString, ToolTipString> entry : entrySet) {
            Label nameLabel = new Label(composite, SWT.NO_FOCUS);
            nameLabel.setText(entry.getKey().toString());
            setupControl(nameLabel);
            Label separator = new Label(composite, SWT.NO_FOCUS | SWT.SEPARATOR | SWT.VERTICAL);
            GridData gd = new GridData(SWT.CENTER, SWT.CENTER, false, false);
            gd.heightHint = nameLabel.computeSize(SWT.DEFAULT, SWT.DEFAULT).y;
            separator.setLayoutData(gd);
            setupControl(separator);
            Label valueLabel = new Label(composite, SWT.NO_FOCUS);
            valueLabel.setText(entry.getValue().toString());
            setupControl(valueLabel);
        }
    }
    scrolledComposite.setContent(composite);
    Point preferredSize = computePreferredSize();
    scrolledComposite.setMinSize(preferredSize.x, preferredSize.y);
    return preferredSize;
}
 
Example 11
Source File: CustomXmlParserOutputWizardPage.java    From tracecompass with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public void createControl(final Composite parent) {
    container = new Composite(parent, SWT.NULL);
    container.setLayout(new GridLayout());

    sash = new SashForm(container, SWT.VERTICAL);
    sash.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
    sash.setBackground(sash.getDisplay().getSystemColor(SWT.COLOR_GRAY));

    outputsScrolledComposite = new ScrolledComposite(sash, SWT.V_SCROLL);
    outputsScrolledComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
    outputsContainer = new Composite(outputsScrolledComposite, SWT.NONE);
    final GridLayout outputsLayout = new GridLayout(4, false);
    outputsLayout.marginHeight = 10;
    outputsLayout.marginWidth = 0;
    outputsContainer.setLayout(outputsLayout);
    outputsScrolledComposite.setContent(outputsContainer);
    outputsScrolledComposite.setExpandHorizontal(true);
    outputsScrolledComposite.setExpandVertical(true);

    outputsContainer.layout();

    outputsScrolledComposite.setMinSize(outputsContainer.computeSize(SWT.DEFAULT, SWT.DEFAULT).x, outputsContainer.computeSize(SWT.DEFAULT, SWT.DEFAULT).y-5);

    tableContainer = new Composite(sash, SWT.NONE);
    final GridLayout tableLayout = new GridLayout();
    tableLayout.marginHeight = 0;
    tableLayout.marginWidth = 0;
    tableContainer.setLayout(tableLayout);
    previewTable = new TmfEventsTable(tableContainer, 0, CustomEventAspects.generateAspects(new CustomXmlTraceDefinition()));
    previewTable.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));

    if (wizard.definition != null) {
        loadDefinition(wizard.definition);
    }
    setControl(container);

}
 
Example 12
Source File: OutputPropertyDescriptor.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
private void dealParentLayout( Composite container )
{
	if ( container == null )
		return;
	if ( !( container instanceof ScrolledComposite ) )
	{
		dealParentLayout( container.getParent( ) );
		return;
	}
	ScrolledComposite composite = (ScrolledComposite) container;
	Composite control = (Composite) composite.getContent( );
	composite.setMinSize( control.computeSize( SWT.DEFAULT, SWT.DEFAULT ) );
	control.layout( );
}
 
Example 13
Source File: ExportFilterSettingDialog.java    From tmxeditor8 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Create contents of the dialog.
 * @param parent
 */
@Override
protected Control createDialogArea(Composite parent) {
	Composite container = (Composite) super.createDialogArea(parent);
	container.setLayout(new GridLayout(1, false));

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

	Label filterNameLabel = new Label(composite, SWT.NONE);
	filterNameLabel.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
	filterNameLabel.setText(Messages.getString("dialog.ExportFilterSettingDialog.filterNameLabel"));

	filterNameText = new Text(composite, SWT.BORDER);
	filterNameText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));

	Composite optionComposite = new Composite(container, SWT.NONE);
	optionComposite.setLayout(new GridLayout(2, false));
	optionComposite.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));

	isAllCbtn = new Button(optionComposite, SWT.RADIO);
	isAllCbtn.setSize(152, 26);
	isAllCbtn.setText(Messages.getString("dialog.ExportFilterSettingDialog.isAllCbtn"));
	isAllCbtn.setSelection(true);

	isAnyCbtn = new Button(optionComposite, SWT.RADIO);
	isAnyCbtn.setText(Messages.getString("dialog.ExportFilterSettingDialog.isAnyCbtn"));

	ScrolledComposite scrolledComposite = new ScrolledComposite(container, SWT.V_SCROLL | SWT.BORDER);
	scrolledComposite.setAlwaysShowScrollBars(false);
	scrolledComposite.setLayoutData(new GridData(GridData.FILL_BOTH));
	scrolledComposite.setExpandHorizontal(true);
	scrolledComposite.setExpandVertical(true);

	dynaComposite = new Composite(scrolledComposite, SWT.NONE);
	dynaComposite.setBackground(Display.getDefault().getSystemColor((SWT.COLOR_WHITE)));
	scrolledComposite.setContent(dynaComposite);
	scrolledComposite.setMinSize(dynaComposite.computeSize(SWT.DEFAULT, SWT.DEFAULT));
	GridLayout gl_dynaComposite = new GridLayout(1, false);
	dynaComposite.setLayout(gl_dynaComposite);

	ExportFilterComposite exportFilterComponent = new ExportFilterComposite(dynaComposite, SWT.None, ruleType);
	exportFilterComponent.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
	exportFilterComponent.setDeleteButtonEnabled(false);
	dynaComposite.setData("currentNumber", 1);

	scrolledComposite.setMinSize(dynaComposite.computeSize(SWT.DEFAULT, SWT.DEFAULT));

	initData();

	return container;
}
 
Example 14
Source File: GanttTester.java    From nebula with Eclipse Public License 2.0 4 votes vote down vote up
public GanttTester() {
    final Display display = Display.getDefault(); //new Display();
    final Monitor m = display.getMonitors()[0];
    final Shell shell = new Shell(display);
    shell.setText("GanttChart Test Application");
    shell.setLayout(new FillLayout());

    final SashForm sfVSplit = new SashForm(shell, SWT.VERTICAL);
    final SashForm sfHSplit = new SashForm(sfVSplit, SWT.HORIZONTAL);

    final ViewForm vfBottom = new ViewForm(sfVSplit, SWT.NONE);
    _vfChart = new ViewForm(sfHSplit, SWT.NONE);
    final ViewForm rightForm = new ViewForm(sfHSplit, SWT.NONE);

    final ScrolledComposite sc = new ScrolledComposite(rightForm, SWT.V_SCROLL | SWT.H_SCROLL);
    rightForm.setContent(sc);
    sc.setExpandHorizontal(true);
    sc.setExpandVertical(true);
    sc.getVerticalBar().setPageIncrement(150);

    final Composite rightComposite = new Composite(sc, SWT.NONE);
    final GridLayout gl = new GridLayout();
    gl.marginLeft = 0;
    gl.marginTop = 0;
    gl.horizontalSpacing = 0;
    gl.verticalSpacing = 0;
    gl.marginBottom = 0;
    gl.marginHeight = 0;
    gl.marginWidth = 0;
    rightComposite.setLayout(gl);

    sc.setContent(rightComposite);

    rightComposite.addListener(SWT.Resize, new Listener() {

        public void handleEvent(final Event event) {
            sc.setMinSize(rightComposite.computeSize(SWT.DEFAULT, SWT.DEFAULT));
        }

    });

    sfVSplit.setWeights(new int[] { 91, 9 });
    sfHSplit.setWeights(new int[] { 70, 30 });

    // top left side
    _ganttChart = new GanttChart(_vfChart, SWT.MULTI);
    _vfChart.setContent(_ganttChart);
    _ganttComposite = _ganttChart.getGanttComposite();

    final TabFolder tfRight = new TabFolder(rightComposite, SWT.BORDER);
    final TabItem tiGeneral = new TabItem(tfRight, SWT.NONE);
    tiGeneral.setText("Creation");

    final TabItem tiAdvanced = new TabItem(tfRight, SWT.NONE);
    tiAdvanced.setText("Advanced");

    final TabItem tiEventLog = new TabItem(tfRight, SWT.NONE);
    tiEventLog.setText("Event Log");

    final Composite bottom = new Composite(rightComposite, SWT.NONE);
    bottom.setLayout(new GridLayout());
    createCreateButtons(bottom);

    vfBottom.setContent(createBottom(vfBottom));
    tiGeneral.setControl(createCreationTab(tfRight)); // NOPMD
    tiAdvanced.setControl(createAdvancedTab(tfRight));
    tiEventLog.setControl(createEventLogTab(tfRight));

    shell.setMaximized(true);
    // uncomment to put on right-hand-side monitor
    shell.setLocation(new Point(m.getClientArea().x, 0));

    sc.setMinSize(rightComposite.computeSize(SWT.DEFAULT, SWT.DEFAULT));

    shell.open();

    while (!shell.isDisposed()) {
        if (!display.readAndDispatch()) {
            display.sleep();
        }
    }
    display.removeListener(SWT.KeyDown, _undoRedoListener);

    shell.dispose();
}
 
Example 15
Source File: UsersWizardPage.java    From bonita-studio with GNU General Public License v2.0 4 votes vote down vote up
private void updatedScrolMinSize(final Control control, final ScrolledComposite sc) {
    final Point point = control.computeSize(SWT.DEFAULT, SWT.DEFAULT);
    sc.setMinSize(new Point(point.x, point.y));
}
 
Example 16
Source File: ExportFilterSettingDialog.java    From translationstudio8 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Create contents of the dialog.
 * @param parent
 */
@Override
protected Control createDialogArea(Composite parent) {
	Composite container = (Composite) super.createDialogArea(parent);
	container.setLayout(new GridLayout(1, false));

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

	Label filterNameLabel = new Label(composite, SWT.NONE);
	filterNameLabel.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
	filterNameLabel.setText(Messages.getString("dialog.ExportFilterSettingDialog.filterNameLabel"));

	filterNameText = new Text(composite, SWT.BORDER);
	filterNameText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));

	Composite optionComposite = new Composite(container, SWT.NONE);
	optionComposite.setLayout(new GridLayout(2, false));
	optionComposite.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));

	isAllCbtn = new Button(optionComposite, SWT.RADIO);
	isAllCbtn.setSize(152, 26);
	isAllCbtn.setText(Messages.getString("dialog.ExportFilterSettingDialog.isAllCbtn"));
	isAllCbtn.setSelection(true);

	isAnyCbtn = new Button(optionComposite, SWT.RADIO);
	isAnyCbtn.setText(Messages.getString("dialog.ExportFilterSettingDialog.isAnyCbtn"));

	ScrolledComposite scrolledComposite = new ScrolledComposite(container, SWT.V_SCROLL | SWT.BORDER);
	scrolledComposite.setAlwaysShowScrollBars(false);
	scrolledComposite.setLayoutData(new GridData(GridData.FILL_BOTH));
	scrolledComposite.setExpandHorizontal(true);
	scrolledComposite.setExpandVertical(true);

	dynaComposite = new Composite(scrolledComposite, SWT.NONE);
	dynaComposite.setBackground(Display.getDefault().getSystemColor((SWT.COLOR_WHITE)));
	scrolledComposite.setContent(dynaComposite);
	scrolledComposite.setMinSize(dynaComposite.computeSize(SWT.DEFAULT, SWT.DEFAULT));
	GridLayout gl_dynaComposite = new GridLayout(1, false);
	dynaComposite.setLayout(gl_dynaComposite);

	ExportFilterComposite exportFilterComponent = new ExportFilterComposite(dynaComposite, SWT.None, ruleType);
	exportFilterComponent.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
	exportFilterComponent.setDeleteButtonEnabled(false);
	dynaComposite.setData("currentNumber", 1);

	scrolledComposite.setMinSize(dynaComposite.computeSize(SWT.DEFAULT, SWT.DEFAULT));

	initData();

	return container;
}
 
Example 17
Source File: DatabaseConnectorOutputWizardPage.java    From bonita-studio with GNU General Public License v2.0 4 votes vote down vote up
protected void buildListOfOutputForOneRowNCols(final ScrolledComposite scrolledComposite,
        final EMFDataBindingContext context) {
    if (scrolledComposite.getContent() != null) {
        scrolledComposite.getContent().dispose();
        scrolledComposite.setContent(null);
    }
    final Composite oneRowNColsComposite = new Composite(scrolledComposite, SWT.NONE);
    oneRowNColsComposite.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create());
    oneRowNColsComposite.setLayout(GridLayoutFactory.fillDefaults().numColumns(3).margins(10, 10).create());

    final ConnectorConfiguration configuration = getConnector().getConfiguration();
    final Expression scriptExpression = (Expression) getConnectorParameter(configuration, getInput(SCRIPT_KEY))
            .getExpression();
    final List<Operation> operations = getOuputOperationsFor(ONEROW_NCOL_RESULT_OUTPUT, scriptExpression);
    for (final Operation op : operations) {
        final ReadOnlyExpressionViewer targetDataExpressionViewer = new ReadOnlyExpressionViewer(oneRowNColsComposite,
                SWT.BORDER, null, null, ExpressionPackage.Literals.OPERATION__LEFT_OPERAND);
        targetDataExpressionViewer.getControl().setLayoutData(GridDataFactory.fillDefaults().grab(true, false).create());
        final IExpressionNatureProvider storageExpressionProvider = getStorageExpressionProvider();
        if (storageExpressionProvider != null) {
            targetDataExpressionViewer.setExpressionNatureProvider(storageExpressionProvider);
        }
        targetDataExpressionViewer.addFilter(leftFilter);
        targetDataExpressionViewer.setContext(getElementContainer());
        targetDataExpressionViewer.setInput(op);

        context.bindValue(ViewersObservables.observeSingleSelection(targetDataExpressionViewer),
                EMFObservables.observeValue(op, ExpressionPackage.Literals.OPERATION__LEFT_OPERAND));

        final Label takeValueOfLabel = new Label(oneRowNColsComposite, SWT.NONE);
        takeValueOfLabel.setLayoutData(GridDataFactory.swtDefaults().align(SWT.FILL, SWT.CENTER).create());
        takeValueOfLabel.setText(Messages.takeValueOf);

        final Text columnText = new Text(oneRowNColsComposite, SWT.BORDER | SWT.READ_ONLY);
        columnText.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).create());
        columnText.setText(op.getRightOperand().getName());
    }
    scrolledComposite.setMinSize(oneRowNColsComposite.computeSize(SWT.DEFAULT, SWT.DEFAULT));
    scrolledComposite.setAlwaysShowScrollBars(false);
    scrolledComposite.setExpandHorizontal(true);
    scrolledComposite.setExpandVertical(true);
    scrolledComposite.setContent(oneRowNColsComposite);
}
 
Example 18
Source File: SWTStrategyPanelHelper.java    From atdl4j with MIT License 4 votes vote down vote up
public static void relayoutExpandBar(ExpandBar expandBar, boolean relayoutParents)
{
	Composite c = expandBar;
	int tempMaxControlX = 0;
	
	logger.debug( "----- relayoutExpandBar (relayoutParents: " + relayoutParents + " expandBar: " + expandBar + " -----" );
	
	do
	{
		logger.debug( "c: " + c.getClass() + " c.getParent(): " + c.getParent().getClass() );
		
		if ( c instanceof ExpandBar )
		{
			ExpandBar eb = (ExpandBar) c;
			
			logger.debug( "ExpandBar.getSize(): " + eb.getSize() );
			
			for ( ExpandItem expandItem : eb.getItems() )
			{
				logger.debug( "expandItem: " + expandItem + " text: " + expandItem.getText() + " control: " + expandItem.getControl() + " controlLocation: " + expandItem.getControl().getLocation());					
				logger.debug( "before pack(): expandItem.getControl().getSize(): " + expandItem.getControl().getSize() );

				expandItem.getControl().pack();
				
				if ( expandItem.getControl().getSize().x > tempMaxControlX )
				{
					tempMaxControlX = expandItem.getControl().getSize().x;
				}

				logger.debug( "before: expandItem.getHeight(): " + expandItem.getHeight() + " expandItem.getControl().getSize(): " + expandItem.getControl().getSize() );

				expandItem.setHeight( expandItem.getControl().computeSize( eb.getSize().x, SWT.DEFAULT, true ).y );
			}

			// -- Need to set ExpandBar's GridData.widthHint to the width of the widest control within it -- 
			GridData tempGridData2 = (GridData) expandBar.getLayoutData();
			tempGridData2.widthHint = tempMaxControlX;
			// do not set height as ExpandBar handles this tempGridData2.heightHint = expandBar.getSize().y;
			expandBar.setLayoutData( tempGridData2 );
			
				
			if ( relayoutParents )
			{
				Control p = c.getParent();
				
				if ( p instanceof ScrolledComposite )
				{
					ScrolledComposite scrolledComposite = (ScrolledComposite) p;
					if ( scrolledComposite.getExpandHorizontal() || scrolledComposite.getExpandVertical() )
					{
						scrolledComposite.setMinSize( scrolledComposite.getContent().computeSize( SWT.DEFAULT, SWT.DEFAULT, true ) );
					}
					else
					{
						scrolledComposite.getContent().pack( true );
					}
				}

				if ( p instanceof Composite )
				{
					Composite composite = (Composite) p;
					composite.layout();
				}
			}
			else
			{
				// -- this (or relayoutParents=true) is needed (otherwise ExampleStrategyPanelTests2.xml with 2 "columns" of StrategyPanels may not draw all of the ExpandBars initially) --
				expandBar.getParent().layout();
			}

		}
		c = c.getParent();
	}
	while ( c != null && c.getParent() != null && !( c instanceof ScrolledComposite ) );


	// -- Needed to ensure that strategy panel is expanded vertically as panels go from collapsed to expanded
	expandBar.getShell().layout();
	expandBar.getShell().pack();
}
 
Example 19
Source File: ScrolledComposites.java    From scava with Eclipse Public License 2.0 4 votes vote down vote up
public static final void updateOnlyVerticalScrollableComposite(ScrolledComposite scrolledComposite) {
	Control content = scrolledComposite.getContent();
	
	if (content == null)
		return;
	
	if( content instanceof Composite ) {
		((Composite)content).layout();
	}
	
	Rectangle clientArea = scrolledComposite.getClientArea();
	
	Point computeSize = content.computeSize(clientArea.width, SWT.DEFAULT, true);
	
	scrolledComposite.setMinSize(computeSize);
	scrolledComposite.layout();
	
	content.requestLayout();
}
 
Example 20
Source File: TaskSelectionPage.java    From CogniCrypt with Eclipse Public License 2.0 4 votes vote down vote up
@Override
public void createControl(final Composite parent) {
	final List<Task> tasks = TaskJSONReader.getTasks();

	final ScrolledComposite sc = new ScrolledComposite(parent, SWT.H_SCROLL | SWT.V_SCROLL);
	sc.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));

	this.container = new Composite(sc, SWT.NONE);
	this.container.setBounds(10, 10, 450, 200);

	//To display the Help view after clicking the help icon
	PlatformUI.getWorkbench().getHelpSystem().setHelp(sc, "de.cognicrypt.codegenerator.TaskSelectionHelp");

	final GridLayout gl = new GridLayout(2, false);
	gl.verticalSpacing = -6;
	this.container.setLayout(gl);

	new GridData(SWT.FILL, SWT.FILL, false, false, 1, 1);
	new Label(this.container, SWT.NONE);
	final Label useCaseDescriptionLabel = new Label(this.container, SWT.WRAP);
	final GridData gd_selectProjectLabel = new GridData(SWT.FILL, SWT.FILL, false, false, 1, tasks.size() + 1);
	gd_selectProjectLabel.heightHint = 200;
	gd_selectProjectLabel.widthHint = 600;
	useCaseDescriptionLabel.setLayoutData(gd_selectProjectLabel);
	Font a = useCaseDescriptionLabel.getFont();
	useCaseDescriptionLabel.setFont(new Font(useCaseDescriptionLabel.getDisplay(), new FontData(a.getFontData()[0].getName(), 12, SWT.None)));

	final List<Button> buttons = new ArrayList<Button>();
	final List<Image> unclickedImages = new ArrayList<Image>();
	new Label(this.container, SWT.NONE);
	for (Task ccTask : tasks) {
		final Image taskImage = loadImage(ccTask.getImage());
		unclickedImages.add(taskImage);

		final Button taskButton = createImageButton(this.container, taskImage, ccTask.getDescription());
		buttons.add(taskButton);
	}
	buttons.stream().forEach(e -> e.addListener(SWT.Selection, new SelectionButtonListener(buttons, unclickedImages, tasks, useCaseDescriptionLabel)));
	buttons.get(0).notifyListeners(SWT.Selection, new Event());

	setControl(this.container);
	new Label(this.container, SWT.NONE);
	new Label(this.container, SWT.NONE);

	sc.setContent(this.container);
	sc.setExpandHorizontal(true);
	sc.setExpandVertical(true);
	sc.setMinSize(this.container.computeSize(SWT.DEFAULT, SWT.DEFAULT));
	setControl(sc);
}