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


Java List.addListener方法代碼示例

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


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

示例1: 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

示例2: createControl

import org.eclipse.swt.widgets.List; //導入方法依賴的package包/類
@Override
public void createControl(Composite parent) {
	composite = new Composite(parent, SWT.NONE);
	GridLayout layout = new GridLayout();
	int nCols = 3;
	layout.numColumns = nCols;
	composite.setLayout(layout);
	composite.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_FILL));
	
	Label projectLabel = new Label(composite, SWT.NONE);
	projectLabel.setText(projectsListLabel);
	GridData gridData = new GridData();
	gridData.horizontalSpan = nCols;
	projectLabel.setLayoutData(gridData);
	
	projectsList = new List(composite, SWT.BORDER | SWT.V_SCROLL);
	addProjectsToList();
	gridData = new GridData(SWT.FILL, SWT.FILL, true, false, nCols, 1);
	int listHeight = projectsList.getItemHeight() * 3;
	Rectangle trim = projectsList.computeTrim(0, 0, 0, listHeight);
	gridData.heightHint = trim.height;
	projectsList.setLayoutData(gridData);
	projectsList.addListener(SWT.Selection, this);
	initProjectSelection();
	
	createLine(composite, nCols);
	setControl(composite);
}
 
開發者ID:jason-lang,項目名稱:jason-eclipse-plugin,代碼行數:29,代碼來源:JasonWizardPage.java

示例3: addMachineTab

import org.eclipse.swt.widgets.List; //導入方法依賴的package包/類
private static void addMachineTab(final String name) {
    final CTabItem tabItem = new CTabItem(tabHandsetName, SWT.MULTI | SWT.V_SCROLL);
    tabItem.setImage(new Image(display, ClassLoader
        .getSystemResourceAsStream("icons/device.png")));
    tabItem.setText(name);

    listHandsets = new List(tabHandsetName, SWT.BORDER);

    tabItem.setControl(listHandsets);
    listHandsets.setFont(new Font(display, "宋體", 10, SWT.NONE));
    listHandsets.addListener(SWT.MenuDetect, new Listener() {
        public void handleEvent(Event event) {
            if (event.detail == 0) {
                //select handset
                if (listHandsets.getSelectionIndex() >= 0) {
                    device = findDevices.getDevices()[listHandsets.getSelectionIndex()];
                    //get device node from tree
                    listHandsets.setMenu(null);
                    createHandsetRightClickRecord();
                    listHandsets.setMenu(handsetMenu);

                }
            }
        }
    });
    //show it
    tabHandsetName.setSelection(tabItem);
}
 
開發者ID:hoozheng,項目名稱:AndroidRobot,代碼行數:29,代碼來源:AndroidRobot.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 };
	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

示例5: createDialogArea

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

示例6: 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

示例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, 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


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