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

The following examples show how to use org.eclipse.swt.widgets.List#setItems() . 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: KeyValueListFieldEditor.java    From texlipse with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Creates and returns the contents of an area of the dialog which appears
 * below the message and above the button bar.
 * 
 * This implementation creates two labels and two textfields.
 * 
 * @param parent parent composite to contain the custom area
 * @return the custom area control, or <code>null</code>
 */
protected Control createCustomArea(Composite parent) {

    Composite composite = new Composite(parent, SWT.NULL);
    composite.setLayoutData(new GridData(GridData.FILL_BOTH));
    composite.setLayout(new GridLayout());
    
    envVarList = new List(composite, SWT.MULTI | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL);
    envVarList.setLayoutData(new GridData(GridData.FILL_BOTH));
    envVarList.setItems(items);
    envVarList.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent event) {
            selections = envVarList.getSelectionIndices();
        }});
    
    return composite;
}
 
Example 2
Source File: StyleListFieldEditor.java    From texlipse with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Creates and returns the contents of an area of the dialog which appears
 * below the message and above the button bar.
 * 
 * This implementation creates two labels and two textfields.
 * 
 * @param parent parent composite to contain the custom area
 * @return the custom area control, or <code>null</code>
 */
protected Control createCustomArea(Composite parent) {
    
    Composite composite = new Composite(parent, SWT.NULL);
    composite.setLayoutData(new GridData(GridData.FILL_BOTH));
    composite.setLayout(new GridLayout());
    
    skVarList = new List(composite, SWT.MULTI | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL);
    skVarList.setLayoutData(new GridData(GridData.FILL_BOTH));
    skVarList.setItems(items);
    skVarList.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent event) {
            selections = skVarList.getSelectionIndices();
        }});
    
    return composite;
}
 
Example 3
Source File: TexlipseProjectCreationWizardPage.java    From texlipse with Eclipse Public License 1.0 6 votes vote down vote up
/**
   * Creates a list element containing available templates (system and user)
   * and a text area next to it for showing description about the selected template
   * 
   * @param composite the parent container
   */
  private void createTemplateControl(Composite composite) {
      // add list for templates
      templateList = new List(composite, SWT.SINGLE | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL);
templateList.setItems(ProjectTemplateManager.loadTemplateNames());
      templateList.setLayoutData(new GridData(GridData.FILL_VERTICAL));
      templateList.setToolTipText(TexlipsePlugin.getResourceString("projectWizardTemplateTooltip"));
      templateList.addSelectionListener(new SelectionAdapter() {
          public void widgetSelected(SelectionEvent e) {
          	attributes.setTemplate(templateList.getSelection()[0]);
          	updateEntries();
          }});
      
      templateList.setSelection(0);
      // this has to be done, because setSelection() doesn't generate an event
      attributes.setTemplate(templateList.getItem(0));

      
      // add TextField for the selected template's description
      descriptionField = new Text(composite, SWT.MULTI | SWT.BORDER);
      descriptionField.setToolTipText(TexlipsePlugin.getResourceString("projectWizardTemplateDescriptionTooltip"));
      descriptionField.setLayoutData(new GridData(GridData.FILL_BOTH));
      descriptionField.setEditable(false);
  }
 
Example 4
Source File: CCombo.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
void createPopup(String[] items, int selectionIndex) {		
		// create shell and list
		popup = new Shell (getShell(), SWT.NO_TRIM | SWT.ON_TOP);
		int style = getStyle();
		int listStyle = SWT.SINGLE | SWT.V_SCROLL;
		if ((style & SWT.FLAT) != 0) listStyle |= SWT.FLAT;
		if ((style & SWT.RIGHT_TO_LEFT) != 0) listStyle |= SWT.RIGHT_TO_LEFT;
		if ((style & SWT.LEFT_TO_RIGHT) != 0) listStyle |= SWT.LEFT_TO_RIGHT;
		list = new List (popup, listStyle);
		if (font != null) list.setFont(font);
		if (foreground != null) list.setForeground(foreground);
		if (background != null) list.setBackground(background);
		
		int [] popupEvents = {SWT.Close, SWT.Paint, SWT.Deactivate};
		for (int i=0; i<popupEvents.length; i++) popup.addListener (popupEvents [i], listener);
		int [] listEvents = {SWT.MouseUp, SWT.Selection, SWT.Traverse, SWT.KeyDown, SWT.KeyUp, SWT.FocusIn, SWT.FocusOut, SWT.Dispose};
		for (int i=0; i<listEvents.length; i++) list.addListener (listEvents [i], listener);
		
		if (items != null) list.setItems(items);
		if (selectionIndex != -1) list.setSelection(selectionIndex);
}
 
Example 5
Source File: CustomCombo.java    From nebula with Eclipse Public License 2.0 5 votes vote down vote up
void createPopup(String[] items, int selectionIndex) {
	// create shell and list
	popup = new Shell(getShell(), SWT.NO_TRIM | SWT.ON_TOP);
	int style = getStyle();
	int listStyle = SWT.SINGLE | SWT.V_SCROLL;
	if ((style & SWT.FLAT) != 0)
		listStyle |= SWT.FLAT;
	if ((style & SWT.RIGHT_TO_LEFT) != 0)
		listStyle |= SWT.RIGHT_TO_LEFT;
	if ((style & SWT.LEFT_TO_RIGHT) != 0)
		listStyle |= SWT.LEFT_TO_RIGHT;
	list = new List(popup, listStyle);
	if (font != null)
		list.setFont(font);
	if (foreground != null)
		list.setForeground(foreground);
	if (background != null)
		list.setBackground(background);

	int[] popupEvents = { SWT.Close, SWT.Paint, SWT.Deactivate };
	for (int i = 0; i < popupEvents.length; i++)
		popup.addListener(popupEvents[i], listener);
	int[] listEvents = { SWT.MouseUp, SWT.Selection, SWT.Traverse, SWT.KeyDown, SWT.KeyUp, SWT.FocusIn, SWT.Dispose };
	for (int i = 0; i < listEvents.length; i++)
		list.addListener(listEvents[i], listener);

	if (items != null)
		list.setItems(items);
	if (selectionIndex != -1)
		list.setSelection(selectionIndex);
}
 
Example 6
Source File: ViewerListFieldEditor.java    From texlipse with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Load the values from preferences.
 * @see super.doLoad()
 */
protected void doLoad() {
    super.doLoad();
    registry.load(getPreferenceStore());
    List list = getListControl(parent);
    list.setItems(addPaths(TexlipsePlugin.getPreferenceArray(ViewerAttributeRegistry.VIEWER_NAMES)));
}
 
Example 7
Source File: ViewerListFieldEditor.java    From texlipse with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Load the default values from preferences.
 * @see super.doLoadDefault()
 */
protected void doLoadDefault() {
    super.doLoadDefault();
    registry = new ViewerAttributeRegistry();
    List list = getListControl(parent);
    list.setItems(addPaths(TexlipsePlugin.getPreferenceArray(ViewerAttributeRegistry.VIEWER_NAMES)));
}
 
Example 8
Source File: DeleteColumnPage.java    From gama with GNU General Public License v3.0 5 votes vote down vote up
/**
 * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite)
 */
@Override
protected Control createDialogArea(final Composite parent) {
	final Composite container = (Composite) super.createDialogArea(parent);
	final GridLayout gridLayout = new GridLayout();
	gridLayout.numColumns = 2;
	container.setLayout(gridLayout);
	final Label filterLabel = new Label(container, SWT.NONE);
	filterLabel.setLayoutData(new GridData(GridData.BEGINNING, GridData.BEGINNING, false, false, 2, 1));
	filterLabel.setText("Select the column that you want to delete:");

	final Label nameLabel = new Label(container, SWT.NONE);
	nameLabel.setLayoutData(new GridData(GridData.END, GridData.CENTER, false, false));
	nameLabel.setText("Column:");

	final List columnList = new List(container, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | SWT.MULTI);
	columnList.setBounds(40, 20, 220, 100);
	columnList.setItems(columnTitle);

	columnList.addSelectionListener(new SelectionAdapter() {
		@Override
		public void widgetSelected(final SelectionEvent e) {
			selectedColumn.clear();
			selectedColumn.addAll(Arrays.asList(columnList.getSelection()));
		}
	});

	return container;
}
 
Example 9
Source File: PatListFilterBox.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);
	ret.setLayoutData(SWTHelper.getFillGridData(1, true, 1, true));
	lEtiketten = new List(ret, SWT.MULTI);
	Query<Sticker> qbe = new Query<Sticker>(Sticker.class);
	etiketten = qbe.execute().toArray(new Sticker[0]);
	String[] etexts = new String[etiketten.length];
	for (int i = 0; i < etiketten.length; i++) {
		etexts[i] = etiketten[i].getLabel();
	}
	lEtiketten.setItems(etexts);
	return ret;
}
 
Example 10
Source File: ProjectTemplatesPreferencePage.java    From texlipse with Eclipse Public License 1.0 4 votes vote down vote up
/**
    * Creates the page components.
 */
   protected Control createContents(Composite parent) {
       
       Composite field = new Composite(parent, SWT.NONE);
       GridData fgd = new GridData(GridData.FILL_BOTH);
       fgd.horizontalSpan = 3;
       field.setLayoutData(fgd);
       GridLayout gl = new GridLayout();
       gl.numColumns = 2;
       field.setLayout(gl);
       
       Label label = new Label(field, SWT.LEFT);
       label.setText(TexlipsePlugin.getResourceString("preferenceProjectTemplateLabel"));
       label.setLayoutData(new GridData());
       
       Label empty = new Label(field, SWT.LEFT);
       empty.setLayoutData(new GridData());
       
       templateList = new List(field, SWT.SINGLE | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL);
       templateList.setItems(ProjectTemplateManager.loadUserTemplateNames());
       templateList.setLayoutData(new GridData(GridData.FILL_BOTH));
       
       Composite column = new Composite(field, SWT.NONE);
       column.setLayoutData(new GridData(GridData.FILL_BOTH));
       column.setLayout(new GridLayout());
       
       Button remove = new Button(column, SWT.PUSH);
       remove.setText(TexlipsePlugin.getResourceString("preferenceProjectTemplateRemoveButton"));
       remove.setLayoutData(new GridData());
       remove.addSelectionListener(new SelectionAdapter() {
           public void widgetSelected(SelectionEvent event) {
               int s = templateList.getSelectionIndex();
               if (s >= 0) {
                   boolean reallyDelete = MessageDialog.openConfirm(new Shell(),
                           TexlipsePlugin.getResourceString("preferenceProjectTemplateConfirmTitle"),
                           TexlipsePlugin.getResourceString("preferenceProjectTemplateConfirmDelete").replaceAll("%s", templateList.getItem(s)));
                   if (reallyDelete) {
                       String item = templateList.getItem(s);
                       ProjectTemplateManager.deleteUserTemplate(item);
                       templateList.remove(s);
                   }
               }
           }});
       
       Label spacer = new Label(column, SWT.LEFT);
       spacer.setLayoutData(new GridData(GridData.FILL_VERTICAL | GridData.GRAB_VERTICAL));
       
       return field;
}
 
Example 11
Source File: DataItemCombo.java    From birt with Eclipse Public License 1.0 4 votes vote down vote up
void createPopup( String[] items, int selectionIndex )
{
	// create shell and list
	popup = new Shell( getShell( ), SWT.NO_TRIM | SWT.ON_TOP );
	int style = getStyle( );
	int listStyle = SWT.SINGLE | SWT.V_SCROLL;
	if ( ( style & SWT.FLAT ) != 0 )
		listStyle |= SWT.FLAT;
	if ( ( style & SWT.RIGHT_TO_LEFT ) != 0 )
		listStyle |= SWT.RIGHT_TO_LEFT;
	if ( ( style & SWT.LEFT_TO_RIGHT ) != 0 )
		listStyle |= SWT.LEFT_TO_RIGHT;
	list = new List( popup, listStyle );
	if ( font != null )
		list.setFont( font );
	if ( foreground != null )
		list.setForeground( foreground );
	if ( background != null )
		list.setBackground( background );

	int[] popupEvents = {
			SWT.Close, SWT.Paint, SWT.Deactivate
	};
	for ( int i = 0; i < popupEvents.length; i++ )
		popup.addListener( popupEvents[i], listener );
	int[] listEvents = {
			SWT.MouseUp,
			SWT.Selection,
			SWT.Traverse,
			SWT.KeyDown,
			SWT.KeyUp,
			SWT.FocusIn,
			SWT.Dispose
	};
	for ( int i = 0; i < listEvents.length; i++ )
		list.addListener( listEvents[i], listener );

	if ( items != null )
		list.setItems( items );
	if ( selectionIndex != -1 )
		list.setSelection( selectionIndex );
}
 
Example 12
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);
}