當前位置: 首頁>>代碼示例>>Java>>正文


Java List.setSelection方法代碼示例

本文整理匯總了Java中org.eclipse.swt.widgets.List.setSelection方法的典型用法代碼示例。如果您正苦於以下問題:Java List.setSelection方法的具體用法?Java List.setSelection怎麽用?Java List.setSelection使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.eclipse.swt.widgets.List的用法示例。


在下文中一共展示了List.setSelection方法的13個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: createContents

import org.eclipse.swt.widgets.List; //導入方法依賴的package包/類
@Override
protected Control createContents(Composite parent) {
    Label trackerListLabel = new Label(parent, SWT.NONE);
    trackerListLabel.setText("Eye Tracker Interface");

    //Get currently selected eye tracker type as index into list.
    TrackerType[] trackerKeys = EyeTrackerFactory.getAvailableEyeTrackers()
                                .keySet().toArray(new TrackerType[0]);
    int trackerSelectionIndex = Arrays.asList(trackerKeys).indexOf(
            TrackerType.valueOf(getPreferenceStore()
            .getString(EYE_TRACKER_TYPE)));

    //Create tracker list.
    trackerList = new List(parent, SWT.BORDER);
    String[] items = EyeTrackerFactory.getAvailableEyeTrackers().values()
                                      .toArray(new String[0]);
    trackerList.setItems(items);
    trackerList.setSelection(trackerSelectionIndex);

    return parent;
}
 
開發者ID:SERESLab,項目名稱:iTrace-Archive,代碼行數:22,代碼來源:PluginPreferences.java

示例2: loadListOfServers

import org.eclipse.swt.widgets.List; //導入方法依賴的package包/類
private void loadListOfServers(List list) {
	ServerStore serverStore = new ServerStore(
			uk.ac.york.mondo.integration.api.dt.Activator.getDefault().getPreferenceStore());
	java.util.List<Server> servers = serverStore.readAllServers();

	list.removeAll();
	
	list.add(CUSTOM_URL_TEXT);

	list.setSelection(0); // by default select option "Custom URL"

	for (Server server : servers) {
		list.add(server.getBaseURL());
	}
	userName.setEnabled(false);
	userName.setText("");
	frontRepoURL.setText("");
}
 
開發者ID:mondo-project,項目名稱:mondo-integration,代碼行數:19,代碼來源:MONDOServerView.java

示例3: createTemplateControl

import org.eclipse.swt.widgets.List; //導入方法依賴的package包/類
/**
   * 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);
  }
 
開發者ID:eclipse,項目名稱:texlipse,代碼行數:30,代碼來源:TexlipseProjectCreationWizardPage.java

示例4: createPopup

import org.eclipse.swt.widgets.List; //導入方法依賴的package包/類
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);
}
 
開發者ID:eclipse,項目名稱:birt,代碼行數:22,代碼來源:CCombo.java

示例5: initialize

import org.eclipse.swt.widgets.List; //導入方法依賴的package包/類
/**
 * This method initializes this
 * 
 */
private void initialize() {
	ScreenClassTrigger trigger = (parent.getTrigger() instanceof ScreenClassTrigger) ? (ScreenClassTrigger) parent
			.getTrigger() : null;

	scrClass_label = new Label(this, SWT.NONE);
	scrClass_label.setText("Screen classes");
	scrClass_list = new List(this, SWT.BORDER | SWT.MULTI | SWT.V_SCROLL);

	java.util.List<HtmlScreenClass> scList = getScreenClassList();

	java.util.List<String> items = new ArrayList<String>();

	for (ScreenClass sc : scList) {
		String scName = sc.getName();
		scrClass_list.add(scName);
		if (trigger != null) {
			if (trigger.getScreenClasses().contains(scName)) {
				items.add(scName);
			}
		}
	}

	scrClass_list.setSelection(items.toArray(new String[items.size()]));
	GridData gridData2 = new GridData();
	gridData2.horizontalAlignment = GridData.FILL;
	gridData2.verticalAlignment = GridData.FILL;
	gridData2.grabExcessHorizontalSpace = true;
	scrClass_list.setLayoutData(gridData2);
	scrClass_list.setSize(400, 250);
}
 
開發者ID:convertigo,項目名稱:convertigo-eclipse,代碼行數:35,代碼來源:HttpTriggerScreenClassEditorComposite.java

示例6: createDialogArea

import org.eclipse.swt.widgets.List; //導入方法依賴的package包/類
/**
 * This is the method that puts the content into the popup's
 * dialog area.  It puts an org.eclipse.swt.widgets.List
 * (note that this isn't an ordinary Java List) there.
 * 
 */
protected Control createDialogArea(Composite composite)
{
    // create the list
    list = new List(composite, SWT.SINGLE | SWT.V_SCROLL | SWT.RESIZE);

    // Populate the popup's display area.
    setList();

    // list.addKeyListener(listener);

    /* 
     *  To put a Composite instead of a List in the
     *  dialog area, do something like the following:
    Composite stuff = new Composite(composite, SWT.NONE);
    stuff.setLayoutData(new GridData());
    stuff.setLayout(new FillLayout(SWT.VERTICAL));
    Button button1 = new Button(stuff, SWT.FLAT);
    button1.setText("Button 1");
    // button1.setParent(stuff);
    Button button2 = new Button(stuff, SWT.PUSH);
    button2.setText("Button 2");
    */
    list.addSelectionListener(new ShowDeclarationsSelectionListener(EditorUtil.getTLAEditorWithFocus()));

    // Adding the KeyListener after the SelectionListener is necessary for the handling
    // of keystrokes to work. If they're added in the opposite order, some keys change
    // the selection and call the SelectionListener.

    list.addKeyListener(new ShowDeclarationsKeyListener(this)); // Testing

    // System.out.println("testing showAll = " + showAll);

    // It is necessary to select an item on the list if one is to be
    // able to listen for keystrokes. Otherwise, a keystroke causes the
    // current selection to change, calling the SelectionListener's widgetSelected()
    // method.
    list.setSelection(0);
    return list;
}
 
開發者ID:tlaplus,項目名稱:tlaplus,代碼行數:46,代碼來源:ShowDeclarationsHandler.java

示例7: createPopup

import org.eclipse.swt.widgets.List; //導入方法依賴的package包/類
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 };
	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);
}
 
開發者ID:ghillairet,項目名稱:gef-gwt,代碼行數:33,代碼來源:CCombo.java

示例8: updateWidget

import org.eclipse.swt.widgets.List; //導入方法依賴的package包/類
protected void updateWidget(List widget, boolean enabled) {
	widget.setEnabled(enabled);
	if(!enabled){
		widget.setSelection(0);
	}
}
 
開發者ID:theokyr,項目名稱:TuxGuitar-1.3.1-fork,代碼行數:7,代碼來源:TGChordSelector.java

示例9: initFloatShell

import org.eclipse.swt.widgets.List; //導入方法依賴的package包/類
private void initFloatShell() {
      Point p = txtCurrentSelection.getParent().toDisplay(txtCurrentSelection.getLocation());
      Point size = txtCurrentSelection.getSize();
      Rectangle shellRect = new Rectangle(p.x, p.y + size.y, size.x, 0);
      shell = new Shell(MultiSelectionCombo.this.getShell(), SWT.NO_TRIM);
      
      GridLayout gl = new GridLayout();
      gl.marginBottom = 2;
      gl.marginTop = 2;
      gl.marginRight = 2;
      gl.marginLeft = 2;
      gl.marginWidth = 0;
      gl.marginHeight = 0;
      shell.setLayout(gl);

      list = new List(shell, SWT.BORDER | SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);
      list.setToolTipText("Click and hold or use Ctrl to select multiple items");
      for (String value: textItems) {
    	  if(value!=null){
    		  list.add(value);
    	  }	 
         
      }

      if(currentSelection.length > 0){
    	  if(currentSelection[0]!=0){
    		  list.setSelection(currentSelection);
    	  }
      }
      

      GridData gd = new GridData(GridData.FILL_BOTH);
      list.setLayoutData(gd);

      shell.setSize(shellRect.width, 200);
      shell.setLocation(shellRect.x, shellRect.y);

      list.addMouseListener(new MouseAdapter() {

         @Override
         public void mouseUp(MouseEvent event) {
            super.mouseUp(event);
            if(list.getSelectionIndices().length > 0){
            	currentSelection = list.getSelectionIndices(); 
            } else {
            	currentSelection = new int[] { 0 };
            }
                       
            if ((event.stateMask & SWT.CTRL) == 0) {
//               displayText();
               parentComp.start = 0;
               parentComp.findText();               
               shell.dispose();
               
            }
         }
      });

      shell.addShellListener(new ShellAdapter() {

         public void shellDeactivated(ShellEvent arg0) {
            if (shell != null && !shell.isDisposed()) {
               if(list.getSelectionIndices().length > 0){
            	   currentSelection = list.getSelectionIndices(); 
               } else {
            	   currentSelection = new int[] { 0 };
               }
//               displayText();
               parentComp.start = 0;
               parentComp.findText();
               shell.dispose();
            }
         }
      });      
      shell.open();
      
   }
 
開發者ID:Transkribus,項目名稱:TranskribusSwtGui,代碼行數:78,代碼來源:MultiSelectionCombo.java

示例10: createContents

import org.eclipse.swt.widgets.List; //導入方法依賴的package包/類
/**
 * 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();
	});

}
 
開發者ID:DaveVoorhis,項目名稱:Rel,代碼行數:70,代碼來源:VarTypeDialog.java

示例11: createContents

import org.eclipse.swt.widgets.List; //導入方法依賴的package包/類
@Override
protected Control createContents(Composite parent) {
	Composite container = new Composite(parent, SWT.NONE);
	
	GridLayout gridLayout = new GridLayout(2, false);
			
	container.setLayout(gridLayout);
	
	//Initialize and populate list
	final List list = new List(container, SWT.NONE);
	list.setLayoutData(new GridData(SWT.FILL));
	populateList(list);
	list.setSelection(0);
	list.setSize(10, 20);
	list.addSelectionListener(new SomeSelectionListener(list));
	
	Composite selectorContainer = new Composite(container, SWT.NONE);
	selectorContainer.setLayout(new GridLayout(1, false));
	
	String selection = options[0];
	
	//Add color editor
	Composite colorContainer = new Composite(selectorContainer, SWT.NONE);
	color = new ColorFieldEditor(RustConstants.SYNTAXCOLOR_COLOR + selection, "Color", colorContainer);

	//Create and add style group
	Group styleContainer = new Group(selectorContainer, SWT.NONE);
	styleContainer.setText("Style");
	
	GridLayout gridLayout2 = new GridLayout(1, false);
	styleContainer.setLayout(gridLayout2);
	
	Composite styleBoldContainer          = new Composite(styleContainer, SWT.NONE);
	Composite styleItalicContainer        = new Composite(styleContainer, SWT.NONE);
	Composite styleUnderlineContainer     = new Composite(styleContainer, SWT.NONE);
	Composite styleStrikethroughContainer = new Composite(styleContainer, SWT.NONE);
	
	styleBold          = new BooleanFieldEditor(RustConstants.SYNTAXCOLOR_BOLD + selection, "Bold", styleBoldContainer);
	styleItalic        = new BooleanFieldEditor(RustConstants.SYNTAXCOLOR_ITALIC + selection, "Italic", styleItalicContainer);
	styleUnderline     = new BooleanFieldEditor(RustConstants.SYNTAXCOLOR_UNDERLINE + selection, "Underline", styleUnderlineContainer);
	styleStrikethrough = new BooleanFieldEditor(RustConstants.SYNTAXCOLOR_STRIKETHROUGH + selection, "Strike through", styleStrikethroughContainer);
	
	//Link editors with the default preferenceStore
	color.setPreferenceStore(RustCorePlugin.getDefaultPreferenceStore());
	styleBold.setPreferenceStore(RustCorePlugin.getDefaultPreferenceStore());
	styleItalic.setPreferenceStore(RustCorePlugin.getDefaultPreferenceStore());
	styleUnderline.setPreferenceStore(RustCorePlugin.getDefaultPreferenceStore());
	styleStrikethrough.setPreferenceStore(RustCorePlugin.getDefaultPreferenceStore());
	
	//Load values for keyword
	updateEditors(selection);
	return container;
}
 
開發者ID:peq,項目名稱:rustyeclipse,代碼行數:54,代碼來源:RustSyntaxColoring.java

示例12: createPopup

import org.eclipse.swt.widgets.List; //導入方法依賴的package包/類
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 );
}
 
開發者ID:eclipse,項目名稱:birt,代碼行數:43,代碼來源:DataItemCombo.java

示例13: createDialogArea

import org.eclipse.swt.widgets.List; //導入方法依賴的package包/類
/**
 * This is the method that puts the content into the popup's
 * dialog area.  It puts an org.eclipse.swt.widgets.List
 * (note that this isn't an ordinary Java List) there.
 * 
 * This is identical to the corresponding method in 
 * ShowDeclarationsHandler except for the obvious name changes
 * and the different setList method.  See that method
 * for the comments.
 * 
 */
protected Control createDialogArea(Composite composite)
{
    list = new List(composite, SWT.SINGLE | SWT.V_SCROLL | SWT.RESIZE);
    setList();
    list.addSelectionListener(new ShowUsesSelectionListener(this.showUses, this.moduleList)); // EditorUtil.getTLAEditorWithFocus()));
    list.addKeyListener(new ShowUsesKeyListener(this)); // Testing
    list.setSelection(0);
    return list;
}
 
開發者ID:tlaplus,項目名稱:tlaplus,代碼行數:21,代碼來源:ShowUsesHandler.java


注:本文中的org.eclipse.swt.widgets.List.setSelection方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。