Java Code Examples for org.eclipse.swt.widgets.List#add()

The following examples show how to use org.eclipse.swt.widgets.List#add() . 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: DisplayLabDokumenteDialog.java    From elexis-3-core with Eclipse Public License 1.0 6 votes vote down vote up
@Override
protected Control createDialogArea(Composite parent){
	Composite composite = new Composite(parent, SWT.BORDER);
	composite.setLayout(new GridLayout(1, true));
	composite.setLayoutData(SWTHelper.getFillGridData(1, true, 1, true));
	
	final List list = new List(composite, SWT.BORDER);
	GridDataFactory.fillDefaults().grab(true, true).applyTo(list);
	for (LabResult lr : this.labResultList) {
		list.add(lr.getResult());
	}
	
	list.addSelectionListener(new SelectionAdapter() {
		@Override
		public void widgetSelected(SelectionEvent e){
			if (docManager != null && list.getSelectionCount() > 0) {
				openDocument(list.getSelection()[0]);
			}
		}
	});
	
	SWTHelper.center(UiDesk.getTopShell(), getShell());
	return composite;
}
 
Example 2
Source File: AddTypeToPriorityListDialog.java    From uima-uimaj with Apache License 2.0 6 votes vote down vote up
@Override
protected Control createDialogArea(Composite parent) {
  // create composite
  Composite composite = (Composite) super.createDialogArea(parent);

  typeList = new List(composite, SWT.MULTI | SWT.BORDER | SWT.V_SCROLL);
  GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
  gridData.heightHint = 100;
  typeList.setLayoutData(gridData);

  for (int i = 0; i < m_availableTypeNames.length; i++) {
    typeList.add(m_availableTypeNames[i]);
  }

  return composite;
}
 
Example 3
Source File: CommandCategoryEditor.java    From e4macs with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * @see Dialog#createDialogArea(Composite)
 */
protected Control createDialogArea(Composite parent) {
	Composite result = new Composite(parent, SWT.NONE);
	result.setLayout(new GridLayout());
	result.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
	catList = new List(result, SWT.BORDER | SWT.MULTI );
	catList.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
	if (categoryArray != null){
		for (int i=0; i< categoryArray.size(); i++){
			catList.add(getLabel(categoryArray.get(i)));
		}
		catList.pack(true);
		catList.computeSize(SWT.DEFAULT, SWT.DEFAULT);
		catList.setVisible(true);
	} 
	result.setVisible(true);
	catList.addDisposeListener(new DisposeListener() {
		public void widgetDisposed(DisposeEvent e) {
			catList = null;
		}
	});
	return result;
}
 
Example 4
Source File: KbdMacroListEditor.java    From e4macs with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * @see Dialog#createDialogArea(Composite)
 */
protected Control createDialogArea(Composite parent) {
	Composite result = new Composite(parent, SWT.NONE);
	result.setLayout(new GridLayout());
	result.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
	macList = new List(result, SWT.BORDER | SWT.MULTI );
	macList.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
	if (macroArray != null){
		for (int i=0; i< macroArray.size(); i++){
			macList.add(getLabel(macroArray.get(i)));
		}
		macList.pack(true);
		macList.computeSize(SWT.DEFAULT, SWT.DEFAULT);
		macList.setVisible(true);
	} 
	result.setVisible(true);
	macList.addDisposeListener(new DisposeListener() {
		public void widgetDisposed(DisposeEvent e) {
			macList = null;
		}
	});
	return result;
}
 
Example 5
Source File: KbdMacroListEditor.java    From e4macs with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * If the active set is different from widget set, then update the widget set
 */
private void activeChangeCheck() {
	List myList = getListUnchecked();
	if (myList != null) {
		String[] items = myList.getItems();
		if (active.size() != items.length && !active.equals(Arrays.asList(items))) {
			myList.removeAll();
			for (String item : active) {
				myList.add(item);
			}
			setPresentsDefaultValue(checkDefaults(active));
			super.selectionChanged();
		}
	}    	
}
 
Example 6
Source File: BonitaErrorDialog.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
private void addLocalizedMesssageToList(final List list, final Throwable exception) {
    final String message = exception.getLocalizedMessage();
    if (message != null) {
        for (final String line : message.split(System.getProperty("line.separator"))) {
            list.add(line);
        }
    }
}
 
Example 7
Source File: MultipleSelectionCombo.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
private void initFloatShell() {
  Point p = displayText.getParent().toDisplay( displayText.getLocation() );
  Point size = displayText.getSize();
  Rectangle shellRect = new Rectangle( p.x, p.y + size.y, size.x, 0 );
  floatShell = new Shell( MultipleSelectionCombo.this.getShell(),
          SWT.NO_TRIM );

  GridLayout gl = new GridLayout();
  gl.marginBottom = 2;
  gl.marginTop = 2;
  gl.marginRight = 0;
  gl.marginLeft = 0;
  gl.marginWidth = 0;
  gl.marginHeight = 0;
  floatShell.setLayout( gl );

  list = new List( floatShell, SWT.BORDER | SWT.MULTI | SWT.H_SCROLL
          | SWT.V_SCROLL );
  for ( String value : comboItems ) {
    list.add( value );
  }

  GridData gd = new GridData( GridData.FILL_BOTH );
  list.setLayoutData( gd );
  floatShell.setSize( shellRect.width, 100 );
  floatShell.setLocation( shellRect.x, shellRect.y );
  list.addMouseListener( new MouseAdapter() {
    @Override
    public void mouseUp( MouseEvent event ) {
      super.mouseUp( event );
      comboSelection = list.getSelectionIndices();
      displayText();
    }
  } );

  floatShell.open();
}
 
Example 8
Source File: CustomMatchConditionDialog.java    From tmxeditor8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 为List组件设置数据
 * @param list
 * @param data
 */
private void setListData(List list, Map<String, String> data) {
	list.removeAll();
	if (data == null) {
		return;
	}
	for (Entry<String, String> entry : data.entrySet()) {
		list.add(entry.getKey());
	}
}
 
Example 9
Source File: LoadQueryDialog.java    From Rel with Apache License 2.0 5 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 FillLayout(SWT.HORIZONTAL));
	
	List list = new List(container, SWT.BORDER);
	for (String item: items)
		list.add(item);
	list.addListener(SWT.Selection, e -> item = list.getSelection()[0]);

	return container;
}
 
Example 10
Source File: RuntimeErrorDialog.java    From tesb-studio-se with Apache License 2.0 5 votes vote down vote up
@Override
protected List createDropDownList(Composite parent) {
    List list = super.createDropDownList(parent);
    for (StackTraceElement st : initStatus.getException().getStackTrace()) {
        list.add(st.toString());
    }
    return list;
}
 
Example 11
Source File: CustomFilterDialog.java    From translationstudio8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 为List组件设置数据
 * @param list
 * @param data
 */
private void setListData(List list, Map<String, String> data) {
	list.removeAll();
	if (data == null || data.size() == 0) {
		return;
	}
	for (Entry<String, String> entry : data.entrySet()) {
		list.add(entry.getKey());
	}
}
 
Example 12
Source File: CustomMatchConditionDialog.java    From translationstudio8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 为List组件设置数据
 * @param list
 * @param data
 */
private void setListData(List list, Map<String, String> data) {
	list.removeAll();
	if (data == null) {
		return;
	}
	for (Entry<String, String> entry : data.entrySet()) {
		list.add(entry.getKey());
	}
}
 
Example 13
Source File: SeriesPageBubble.java    From slr-toolkit with Eclipse Public License 1.0 5 votes vote down vote up
private void buildListPerSubclass(Term t, List l, java.util.List<BubbleDataTerm> templist) {		
	EList<Term> subterms = t.getSubclasses();
	for(Term subterm : subterms) {
		templist.add(new BubbleDataTerm(subterm));
		l.add(subterm.getName());
	}		
}
 
Example 14
Source File: TransDialog.java    From pentaho-kettle with Apache License 2.0 4 votes vote down vote up
private void addLogTab() {
  // ////////////////////////
  // START OF LOG TAB///
  // /
  wLogTab = new CTabItem( wTabFolder, SWT.NONE );
  wLogTab.setText( BaseMessages.getString( PKG, "TransDialog.LogTab.Label" ) );

  FormLayout LogLayout = new FormLayout();
  LogLayout.marginWidth = Const.MARGIN;
  LogLayout.marginHeight = Const.MARGIN;

  wLogComp = new Composite( wTabFolder, SWT.NONE );
  props.setLook( wLogComp );
  wLogComp.setLayout( LogLayout );

  // Add a log type List on the left hand side...
  //
  wLogTypeList = new List( wLogComp, SWT.SINGLE | SWT.V_SCROLL | SWT.H_SCROLL | SWT.BORDER );
  props.setLook( wLogTypeList );

  wLogTypeList.add( BaseMessages.getString( PKG, "TransDialog.LogTableType.Transformation" ) ); // Index 0
  wLogTypeList.add( BaseMessages.getString( PKG, "TransDialog.LogTableType.Step" ) ); // Index 1
  wLogTypeList.add( BaseMessages.getString( PKG, "TransDialog.LogTableType.Performance" ) ); // Index 2
  wLogTypeList.add( BaseMessages.getString( PKG, "TransDialog.LogTableType.LoggingChannels" ) ); // Index 3
  wLogTypeList.add( BaseMessages.getString( PKG, "TransDialog.LogTableType.Metrics" ) ); // Index 3

  FormData fdLogTypeList = new FormData();
  fdLogTypeList.left = new FormAttachment( 0, 0 );
  fdLogTypeList.top = new FormAttachment( 0, 0 );
  fdLogTypeList.right = new FormAttachment( middle / 2, 0 );
  fdLogTypeList.bottom = new FormAttachment( 100, 0 );
  wLogTypeList.setLayoutData( fdLogTypeList );

  wLogTypeList.addSelectionListener( new SelectionAdapter() {
    public void widgetSelected( SelectionEvent arg0 ) {
      showLogTypeOptions( wLogTypeList.getSelectionIndex() );
    }
  } );

  // On the right side we see a dynamic area : a composite...
  //
  wLogOptionsComposite = new Composite( wLogComp, SWT.BORDER );

  FormLayout logOptionsLayout = new FormLayout();
  logOptionsLayout.marginWidth = Const.MARGIN;
  logOptionsLayout.marginHeight = Const.MARGIN;
  wLogOptionsComposite.setLayout( logOptionsLayout );

  props.setLook( wLogOptionsComposite );
  FormData fdLogOptionsComposite = new FormData();
  fdLogOptionsComposite.left = new FormAttachment( wLogTypeList, margin );
  fdLogOptionsComposite.top = new FormAttachment( 0, 0 );
  fdLogOptionsComposite.right = new FormAttachment( 100, 0 );
  fdLogOptionsComposite.bottom = new FormAttachment( 100, 0 );
  wLogOptionsComposite.setLayoutData( fdLogOptionsComposite );

  FormData fdLogComp = new FormData();
  fdLogComp.left = new FormAttachment( 0, 0 );
  fdLogComp.top = new FormAttachment( 0, 0 );
  fdLogComp.right = new FormAttachment( 100, 0 );
  fdLogComp.bottom = new FormAttachment( 100, 0 );
  wLogComp.setLayoutData( fdLogComp );

  wLogComp.layout();
  wLogTab.setControl( wLogComp );

  // ///////////////////////////////////////////////////////////
  // / END OF LOG TAB
  // ///////////////////////////////////////////////////////////
}
 
Example 15
Source File: SDViewerPage.java    From tracecompass with Eclipse Public License 2.0 4 votes vote down vote up
@Override
protected Control createContents(Composite parent) {
    GridLayout gl = new GridLayout();
    gl.marginHeight = 0;
    gl.marginWidth = 0;
    parent.setLayout(gl);
    Composite page = new Composite(parent, SWT.NONE);
    GridLayout pageLayout = new GridLayout();
    pageLayout.numColumns = 2;
    GridData pageLayoutdata = new GridData(GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL | GridData.GRAB_VERTICAL | GridData.VERTICAL_ALIGN_FILL);
    page.setLayoutData(pageLayoutdata);
    page.setLayout(pageLayout);

    fTooltip = new BooleanFieldEditor(ISDPreferences.PREF_TOOLTIP, Messages.SequenceDiagram_ShowTooltips, page);
    fTooltip.setPreferenceStore(fPreferences.getPreferenceStore());
    fTooltip.load();

    // link font with zoom pref
    fLink = new BooleanFieldEditor(ISDPreferences.PREF_LINK_FONT, Messages.SequenceDiagram_IncreaseFontSizeWhenZooming, page);
    fLink.setPreferenceStore(fPreferences.getPreferenceStore());
    fLink.load();

    fNoExternalTime = new BooleanFieldEditor(ISDPreferences.PREF_EXCLUDE_EXTERNAL_TIME, Messages.SequenceDiagram_ExcludeExternalTime, page);
    fNoExternalTime.setPreferenceStore(fPreferences.getPreferenceStore());
    fNoExternalTime.load();

    // use gradient color pref
    fUseGrad = new BooleanFieldEditor(ISDPreferences.PREF_USE_GRADIENT, Messages.SequenceDiagram_UseGradientColor, page);
    fUseGrad.setPreferenceStore(fPreferences.getPreferenceStore());
    fUseGrad.load();

    Label separator = new Label(page, SWT.SEPARATOR | SWT.HORIZONTAL | SWT.SHADOW_NONE);
    GridData sepData = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.GRAB_HORIZONTAL | GridData.VERTICAL_ALIGN_FILL);
    separator.setLayoutData(sepData);

    Composite prefPage = new Composite(page, SWT.NONE);
    GridLayout prefPageLayout = new GridLayout();
    prefPage.setLayoutData(pageLayoutdata);
    prefPageLayout.numColumns = 1;
    prefPage.setLayout(prefPageLayout);

    // swimLane width pref
    fLifelineWidth = new IntegerFieldEditor(ISDPreferences.PREF_LIFELINE_WIDTH, Messages.SequenceDiagram_LifelineWidth, prefPage);
    fLifelineWidth.setPreferenceStore(fPreferences.getPreferenceStore());
    fLifelineWidth.setValidRange(119, 500);
    fLifelineWidth.load();

    // not very nice
    new Label(prefPage, SWT.SEPARATOR | SWT.HORIZONTAL | SWT.SHADOW_NONE);
    new Label(prefPage, SWT.SEPARATOR | SWT.HORIZONTAL | SWT.SHADOW_NONE);

    // Font list pref
    fClassItemList = new List(prefPage, SWT.SINGLE | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);
    GridData tabItemLayoutdata = new GridData(GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL | GridData.GRAB_VERTICAL | GridData.VERTICAL_ALIGN_FILL);
    fClassItemList.setLayoutData(tabItemLayoutdata);

    String[] fontList2 = SDViewPref.getFontList2();
    for (int i = 0; i < fontList2.length; i++) {
        fClassItemList.add(fontList2[i]);
    }
    fClassItemList.setSelection(0);
    fClassItemList.addSelectionListener(this);
    fButtonArea = new Composite(prefPage, SWT.NONE);
    GridData tabItemLayoutdata2 = new GridData(GridData.HORIZONTAL_ALIGN_FILL/* |GridData.GRAB_HORIZONTAL */| GridData.GRAB_VERTICAL | GridData.VERTICAL_ALIGN_FILL);
    fButtonArea.setLayoutData(tabItemLayoutdata2);
    GridLayout buttonAreaLayout = new GridLayout();
    buttonAreaLayout.numColumns = 1;
    fButtonArea.setLayout(buttonAreaLayout);

    // font selector initialise for the lifeline font pref
    String[] fontList = SDViewPref.getFontList();
    fFont = new FontFieldEditor(fontList[0], "",//$NON-NLS-1$
            Messages.SequenceDiagram_AaBbYyZz, fButtonArea);
    fFont.getPreviewControl().setSize(500, 500);
    fFont.setPreferenceStore(fPreferences.getPreferenceStore());
    fFont.load();

    fBackGroundColor = new ColorFieldEditor(fontList[0] + SDViewPref.BACK_COLOR_POSTFIX, Messages.SequenceDiagram_Background, fButtonArea);
    fBackGroundColor.setPreferenceStore(fPreferences.getPreferenceStore());
    fBackGroundColor.load();

    fLineColor = new ColorFieldEditor(fontList[0] + SDViewPref.FORE_COLOR_POSTFIX, Messages.SequenceDiagram_Lines, fButtonArea);
    fLineColor.setPreferenceStore(fPreferences.getPreferenceStore());
    fLineColor.load();

    fTextColor = new ColorFieldEditor(fontList[0] + SDViewPref.TEXT_COLOR_POSTFIX, Messages.SequenceDiagram_Text, fButtonArea);
    fTextColor.setPreferenceStore(fPreferences.getPreferenceStore());
    fTextColor.load();
    swapPref(true);
    Dialog.applyDialogFont(page);

    return page;
}
 
Example 16
Source File: VarTypeDialog.java    From Rel with Apache License 2.0 4 votes vote down vote up
/**
 * Create contents of the dialog.
 */
private void createContents() {
	shlVariableTypeAndName = new Shell(getParent(), getStyle());
	shlVariableTypeAndName.setSize(550, 320);
	shlVariableTypeAndName.setText("Variable Type and Name");
	shlVariableTypeAndName.setLayout(new FormLayout());

	Label lblChooseTheKind = new Label(shlVariableTypeAndName, SWT.NONE);
	FormData fd_lblChooseTheKind = new FormData();
	fd_lblChooseTheKind.left = new FormAttachment(0, 10);
	fd_lblChooseTheKind.top = new FormAttachment(0, 10);
	fd_lblChooseTheKind.bottom = new FormAttachment(0, 24);
	fd_lblChooseTheKind.right = new FormAttachment(100, -10);
	lblChooseTheKind.setLayoutData(fd_lblChooseTheKind);
	lblChooseTheKind.setText("Choose the kind of variable you wish to create.");

	List listVarType = new List(shlVariableTypeAndName, SWT.BORDER);
	FormData fd_listVarType = new FormData();
	fd_listVarType.top = new FormAttachment(lblChooseTheKind, 6);
	fd_listVarType.left = new FormAttachment(0, 10);
	fd_listVarType.right = new FormAttachment(100, -10);
	listVarType.setLayoutData(fd_listVarType);

	if (lastVariableType == null)
		lastVariableType = "REAL";
	int index = 0;
	for (String relvarType : database.getRelvarTypes()) {
		listVarType.add(relvarType);
		if (getVarTypeCode(relvarType).equalsIgnoreCase(lastVariableType))
			listVarType.setSelection(index);
		index++;
	}

	Button btnCancel = new Button(shlVariableTypeAndName, SWT.NONE);
	FormData fd_btnCancel = new FormData();
	fd_btnCancel.bottom = new FormAttachment(100, -10);
	fd_btnCancel.right = new FormAttachment(100, -10);
	btnCancel.setLayoutData(fd_btnCancel);
	btnCancel.setText("Cancel");

	Button btnOk = new Button(shlVariableTypeAndName, SWT.NONE);
	FormData fd_btnOk = new FormData();
	fd_btnOk.bottom = new FormAttachment(100, -10);
	fd_btnOk.right = new FormAttachment(btnCancel, -10);
	btnOk.setLayoutData(fd_btnOk);
	btnOk.setText("Ok");

	fd_listVarType.bottom = new FormAttachment(btnCancel, -10);

	listVarType.addListener(SWT.Selection, e -> variableType = obtainSelectedType(listVarType));

	btnCancel.addListener(SWT.Selection, e -> {
		variableType = null;
		shlVariableTypeAndName.dispose();
	});

	btnOk.addListener(SWT.Selection, e -> {
		variableType = obtainSelectedType(listVarType);
		shlVariableTypeAndName.dispose();
	});

	listVarType.addListener(SWT.MouseDoubleClick, e -> {
		variableType = obtainSelectedType(listVarType);
		shlVariableTypeAndName.dispose();
	});

}
 
Example 17
Source File: JobDialog.java    From pentaho-kettle with Apache License 2.0 4 votes vote down vote up
private void addLogTab() {
  // ////////////////////////
  // START OF LOG TAB///
  // /
  wLogTab = new CTabItem( wTabFolder, SWT.NONE );
  wLogTab.setText( BaseMessages.getString( PKG, "JobDialog.LogTab.Label" ) );

  FormLayout LogLayout = new FormLayout();
  LogLayout.marginWidth = Const.MARGIN;
  LogLayout.marginHeight = Const.MARGIN;

  wLogComp = new Composite( wTabFolder, SWT.NONE );
  props.setLook( wLogComp );
  wLogComp.setLayout( LogLayout );

  // Add a log type List on the left hand side...
  //
  wLogTypeList = new List( wLogComp, SWT.SINGLE | SWT.V_SCROLL | SWT.H_SCROLL | SWT.BORDER );
  props.setLook( wLogTypeList );

  for ( LogTableInterface logTable : logTables ) {
    wLogTypeList.add( logTable.getLogTableType() );
  }

  FormData fdLogTypeList = new FormData();
  fdLogTypeList.left = new FormAttachment( 0, 0 );
  fdLogTypeList.top = new FormAttachment( 0, 0 );
  fdLogTypeList.right = new FormAttachment( middle / 2, 0 );
  fdLogTypeList.bottom = new FormAttachment( 100, 0 );
  wLogTypeList.setLayoutData( fdLogTypeList );

  wLogTypeList.addSelectionListener( new SelectionAdapter() {
    public void widgetSelected( SelectionEvent arg0 ) {
      showLogTypeOptions( wLogTypeList.getSelectionIndex() );
    }
  } );

  // On the right side we see a dynamic area : a composite...
  //
  wLogOptionsComposite = new Composite( wLogComp, SWT.BORDER );

  FormLayout logOptionsLayout = new FormLayout();
  logOptionsLayout.marginWidth = Const.MARGIN;
  logOptionsLayout.marginHeight = Const.MARGIN;
  wLogOptionsComposite.setLayout( logOptionsLayout );

  props.setLook( wLogOptionsComposite );
  FormData fdLogOptionsComposite = new FormData();
  fdLogOptionsComposite.left = new FormAttachment( wLogTypeList, margin );
  fdLogOptionsComposite.top = new FormAttachment( 0, 0 );
  fdLogOptionsComposite.right = new FormAttachment( 100, 0 );
  fdLogOptionsComposite.bottom = new FormAttachment( 100, 0 );
  wLogOptionsComposite.setLayoutData( fdLogOptionsComposite );

  FormData fdLogComp = new FormData();
  fdLogComp.left = new FormAttachment( 0, 0 );
  fdLogComp.top = new FormAttachment( 0, 0 );
  fdLogComp.right = new FormAttachment( 100, 0 );
  fdLogComp.bottom = new FormAttachment( 100, 0 );
  wLogComp.setLayoutData( fdLogComp );

  wLogComp.layout();
  wLogTab.setControl( wLogComp );

  // ///////////////////////////////////////////////////////////
  // / END OF LOG TAB
  // ///////////////////////////////////////////////////////////
}
 
Example 18
Source File: BonitaErrorDialog.java    From bonita-studio with GNU General Public License v2.0 4 votes vote down vote up
private void addStackTraceToList(final List list, final Throwable targetException) {
    for (final StackTraceElement stack : targetException.getStackTrace()) {
        list.add(stack.toString());
    }
}
 
Example 19
Source File: SWTListBoxWidget.java    From atdl4j with MIT License 4 votes vote down vote up
public Widget createWidget(Composite parent, int style)
{
	String tooltip = getTooltip();
	GridData controlGD = new GridData( SWT.FILL, SWT.TOP, false, false );
	
	// label
	if ( control.getLabel() != null ) {
		label = new Label( parent, SWT.NONE );
		label.setText( control.getLabel() );
		if ( tooltip != null ) label.setToolTipText( tooltip );
		label.setLayoutData( new GridData( SWT.LEFT, SWT.TOP, false, false ) );
		controlGD.horizontalSpan = 1;
	} else {
		controlGD.horizontalSpan = 2;
	}

	// dropDownList
	style = style | SWT.BORDER;
	if ( control instanceof MultiSelectListT )
	{
		style |= SWT.MULTI;
	}
	else if ( control instanceof SingleSelectListT )
	{
		style |= SWT.SINGLE;
	}
	listBox = new List( parent, style );
	listBox.setLayoutData( controlGD );

	// listBox items
	java.util.List<ListItemT> listItems = control instanceof MultiSelectListT ? ( (MultiSelectListT) control ).getListItem()
			: ( (SingleSelectListT) control ).getListItem();
	for ( ListItemT listItem : listItems )
	{
		listBox.add( listItem.getUiRep() );
	}

	// tooltip
	if ( tooltip != null ) listBox.setToolTipText( tooltip );

	// init value
	String initValue = (String) ControlHelper.getInitValue( control, getAtdl4jOptions() );
	if ( initValue != null )
		setValue( initValue, true );

	return parent;
}
 
Example 20
Source File: PickTaeForTypesDialog.java    From uima-uimaj with Apache License 2.0 4 votes vote down vote up
@Override
protected Control createDialogArea(Composite parent) {
  Composite composite = (Composite) super.createDialogArea(parent);
  Label specialMsgLabel = new Label(composite, SWT.WRAP);
  AbstractSection.spacer(composite);

  // create m_taePrompt
  createWideLabel(composite, "Delegate Components:");

  delegateComponentListGUI = new List(composite, SWT.MULTI | SWT.BORDER | SWT.V_SCROLL);
  GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
  gridData.heightHint = 100;
  delegateComponentListGUI.setLayoutData(gridData);
  boolean bContainsConstituentsAlreadyInAggregate = false;
  boolean bContainsAggregate = false;
  for (int i = 0; i < m_DelegateComponentDescriptors.size(); i++) {
    String sAdditional = "";
    if (m_aggregateFileName.equals(m_DelegateComponentDescriptors.get(i))) {
      sAdditional = "**";
      bContainsAggregate = true;
    }
    delegateComponentListGUI.add((String) m_DelegateComponentDescriptors.get(i) + sAdditional);
  }
  delegateComponentListGUI.addSelectionListener(dialogSelectionListener);

  if (bContainsConstituentsAlreadyInAggregate && bContainsAggregate) {
    specialMsgLabel
            .setText("(* indicates delegate component is already part of aggregate, ** is aggregate currently being configured)");
  } else if (bContainsConstituentsAlreadyInAggregate) {
    specialMsgLabel.setText("(* indicates delegate component is already part of aggregate)");
  } else if (bContainsAggregate) {
    specialMsgLabel.setText("(** is aggregate currently being configured)");
  }

  createWideLabel(composite, "Delegate Component Description:");

  delegateComponentDescriptionText = new Text(composite, SWT.MULTI | SWT.WRAP | SWT.V_SCROLL
          | SWT.BORDER);
  delegateComponentDescriptionText.setLayoutData(new GridData(GridData.FILL_BOTH));
  GridData dcgd = new GridData(GridData.FILL_HORIZONTAL);
  dcgd.heightHint = 50;
  delegateComponentDescriptionText.setLayoutData(dcgd);
  delegateComponentDescriptionText.setEditable(false);

  createWideLabel(composite, "Input Types:");

  inputTypesList = new List(composite, SWT.BORDER | SWT.V_SCROLL);
  inputTypesList.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

  createWideLabel(composite, "Output Types:");

  outputTypesList = new List(composite, SWT.BORDER | SWT.V_SCROLL);
  outputTypesList.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

  // autoAddToFlowButton = new Button(composite, SWT.CHECK);
  // autoAddToFlowButton.setText("Add selected delegate components to end of flow");
  // autoAddToFlowButton.setSelection(true);
  // autoAddToFlowButton.setBackground(null);

  importByNameUI = newButton(composite, SWT.RADIO, "Import by Name",
          "Importing by name looks up the name on the classpath and datapath.");
  importByLocationUI = newButton(composite, SWT.RADIO, "Import by Location",
          "Importing by location requires a relative or absolute URL");

  String defaultBy = CDEpropertyPage.getImportByDefault(editor.getProject());
  if (defaultBy.equals("location")) {
    importByNameUI.setSelection(false);
    importByLocationUI.setSelection(true);
  } else {
    importByNameUI.setSelection(true);
    importByLocationUI.setSelection(false);
  }
  return composite;
}