org.eclipse.swt.widgets.Text#addListener ( )源码实例Demo

下面列出了org.eclipse.swt.widgets.Text#addListener ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: bonita-studio   文件: TextAreaWidget.java
@Override
protected Text newText(final Composite textContainer) {
    final Text text = new Text(textContainer, SWT.MULTI | SWT.V_SCROLL | SWT.WRAP);
    text.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create());
    final Listener scrollBarListener = event -> {
        final Text t = (Text) event.widget;
        final Rectangle r1 = t.getClientArea();
        final Rectangle r2 = t.computeTrim(r1.x, r1.y, r1.width, r1.height);
        final Point p = t.computeSize(SWT.DEFAULT, SWT.DEFAULT, true);
        t.getVerticalBar().setVisible(r2.height <= p.y);
        if (event.type == SWT.Modify) {
            t.getParent().layout(true);
            t.showSelection();
        }
    };
    text.addListener(SWT.Resize, scrollBarListener);
    text.addListener(SWT.Modify, scrollBarListener);
    return text;
}
 
源代码2 项目: tracecompass   文件: NewFolderDialog.java
private void createFolderNameGroup(Composite parent) {
    Font font = parent.getFont();
    Composite folderGroup = new Composite(parent, SWT.NONE);
    GridLayout layout = new GridLayout();
    layout.numColumns = 2;
    folderGroup.setLayout(layout);
    folderGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

    // New folder label
    Label folderLabel = new Label(folderGroup, SWT.NONE);
    folderLabel.setFont(font);
    folderLabel.setText(Messages.NewFolderDialog_FolderName);

    // New folder name entry field
    fFolderName = new Text(folderGroup, SWT.BORDER);
    GridData data = new GridData(GridData.FILL_HORIZONTAL);
    data.widthHint = IDialogConstants.ENTRY_FIELD_WIDTH;
    fFolderName.setLayoutData(data);
    fFolderName.setFont(font);
    fFolderName.addListener(SWT.Modify, new Listener() {
        @Override
        public void handleEvent(Event event) {
            validateNewFolderName();
        }
    });
}
 
源代码3 项目: tracecompass   文件: NewExperimentDialog.java
private void createExperimentNameGroup(Composite parent) {
    Font font = parent.getFont();
    Composite folderGroup = new Composite(parent, SWT.NONE);
    GridLayout layout = new GridLayout();
    layout.numColumns = 2;
    folderGroup.setLayout(layout);
    folderGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

    // New experiment label
    Label experimentLabel = new Label(folderGroup, SWT.NONE);
    experimentLabel.setFont(font);
    experimentLabel.setText(Messages.NewExperimentDialog_ExperimentName);

    // New experiment name entry field
    fExperimentName = new Text(folderGroup, SWT.BORDER);
    GridData data = new GridData(GridData.FILL_HORIZONTAL);
    data.widthHint = IDialogConstants.ENTRY_FIELD_WIDTH;
    fExperimentName.setLayoutData(data);
    fExperimentName.setFont(font);
    fExperimentName.addListener(SWT.Modify, event -> validateNewExperimentName());
}
 
源代码4 项目: Pydev   文件: AppEngineConfigWizardPage.java
/**
 * Creates the app engine location specification controls.
 *
 * @param appEngineGroup the parent composite
 * @param enabled the initial enabled state of the widgets created
 */
private void createUserSpecifiedGoogleAppEngineLocationGroup(Composite appEngineGroup) {
    Font font = appEngineGroup.getFont();
    // location label
    locationLabel = new Label(appEngineGroup, SWT.NONE);
    locationLabel.setFont(font);
    locationLabel.setText("Google App Engine Director&y");

    // app engine location entry field
    locationPathField = new Text(appEngineGroup, SWT.BORDER);
    GridData data = new GridData(GridData.FILL_HORIZONTAL);
    data.widthHint = SIZING_TEXT_FIELD_WIDTH;
    locationPathField.setLayoutData(data);
    locationPathField.setFont(font);

    // browse button
    browseButton = new Button(appEngineGroup, SWT.PUSH);
    browseButton.setFont(font);
    browseButton.setText("B&rowse");
    browseButton.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent event) {
            handleLocationBrowseButtonPressed();
        }
    });

    // Set the initial value first before listener
    // to avoid handling an event during the creation.
    if (initialLocationFieldValue != null) {
        locationPathField.setText(initialLocationFieldValue.toOSString());
    }
    locationPathField.addListener(SWT.Modify, locationModifyListener);
}
 
源代码5 项目: nebula   文件: MessageArea.java
/**
 * Create a text box
 */
private void createTextBox() {
	final Text textbox = new Text(composite, SWT.BORDER | SWT.WRAP);
	textbox.setText(textBoxValue);
	final GridData gd = new GridData(GridData.FILL, GridData.FILL, true, true, 1, 1);
	textbox.setLayoutData(gd);
	textbox.addListener(SWT.Modify, e -> {
		textBoxValue = textbox.getText();
	});

	textbox.addListener(SWT.KeyUp, e -> {
		if (e.keyCode == SWT.CR || e.keyCode == SWT.KEYPAD_CR) {
			MessageArea.this.parent.shell.dispose();
			MessageArea.this.parent.getFooterArea().selectedButtonIndex = 0;
		}
	});

	textbox.getShell().addListener(SWT.Activate, new Listener() {

		@Override
		public void handleEvent(final Event arg0) {
			textbox.forceFocus();
			textbox.setSelection(textbox.getText().length());
			textbox.getShell().removeListener(SWT.Activate, this);
		}
	});

}
 
/**
 * Creates the project name specification controls.
 *
 * @param parent the parent composite
 */
private final void createProjectNameGroup(Composite parent) {
    Font font = parent.getFont();
    // project specification group
    Composite projectGroup = new Composite(parent, SWT.NONE);
    GridLayout layout = new GridLayout();
    layout.numColumns = 2;
    projectGroup.setLayout(layout);
    projectGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

    // new project label
    Label projectLabel = new Label(projectGroup, SWT.NONE);
    projectLabel.setFont(font);

    projectLabel.setText("&Project name:");

    // new project name entry field
    projectNameField = new Text(projectGroup, SWT.BORDER);
    GridData data = new GridData(GridData.FILL_HORIZONTAL);
    data.widthHint = SIZING_TEXT_FIELD_WIDTH;
    projectNameField.setLayoutData(data);
    projectNameField.setFont(font);

    // Set the initial value first before listener
    // to avoid handling an event during the creation.
    if (initialProjectFieldValue != null) {
        projectNameField.setText(initialProjectFieldValue);
    }
    projectNameField.addListener(SWT.Modify, nameModifyListener);
}
 
/**
 * Create the export destination specification widgets
 * @param parent
 *            org.eclipse.swt.widgets.Composite
 */
protected void createDestinationGroup(Composite parent) {

	Font font = parent.getFont();
	// destination specification group
	Composite destinationSelectionGroup = new Composite(parent, SWT.NONE);
	GridLayout layout = new GridLayout();
	layout.numColumns = 3;
	destinationSelectionGroup.setLayout(layout);
	destinationSelectionGroup.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL
			| GridData.VERTICAL_ALIGN_FILL));
	destinationSelectionGroup.setFont(font);

	Label destinationLabel = new Label(destinationSelectionGroup, SWT.NONE);
	destinationLabel.setText(getDestinationLabel());
	destinationLabel.setFont(font);

	// destination name entry field
	destinationNameField = new Text(destinationSelectionGroup, SWT.BORDER);
	destinationNameField.addListener(SWT.Modify, this);
	destinationNameField.addListener(SWT.Selection, this);
	GridData data = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.GRAB_HORIZONTAL);
	data.widthHint = SIZING_TEXT_FIELD_WIDTH;
	destinationNameField.setLayoutData(data);
	destinationNameField.setFont(font);

	// destination browse button
	destinationBrowseButton = new Button(destinationSelectionGroup, SWT.PUSH);
	destinationBrowseButton.setText(DataTransferMessages.DataTransfer_browse);
	destinationBrowseButton.addListener(SWT.Selection, this);
	destinationBrowseButton.setFont(font);
	setButtonLayoutData(destinationBrowseButton);

	new Label(parent, SWT.NONE); // vertical spacer
}
 
源代码8 项目: nebula   文件: PTWindowEditor.java
/**
 * Add a verify listener to a given text that accepts only integers
 *
 * @param text text widget
 */
protected void addVerifyListeners(final Text text) {
	text.addListener(SWT.Verify, e -> {
		final String string = e.text;
		final char[] chars = new char[string.length()];
		string.getChars(0, chars.length, chars, 0);
		for (int i = 0; i < chars.length; i++) {
			if (!('0' <= chars[i] && chars[i] <= '9') && e.keyCode != SWT.BS && e.keyCode != SWT.DEL) {
				e.doit = false;
				return;
			}
		}
	});
}
 
/**
 * Creates the project name specification controls.
 *
 * @param parent
 *            the parent composite
 */
private final void createProjectNameGroup(Composite parent) {
	// project specification group
	Composite projectGroup = new Composite(parent, SWT.NONE);
	GridLayout layout = new GridLayout();
	layout.numColumns = 2;
	projectGroup.setLayout(layout);
	projectGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

	// new project label
	Label projectLabel = new Label(projectGroup, SWT.NONE);
	projectLabel.setText(IDEWorkbenchMessages.WizardNewProjectCreationPage_nameLabel);
	projectLabel.setFont(parent.getFont());

	// new project name entry field
	projectNameField = new Text(projectGroup, SWT.BORDER);
	GridData data = new GridData(GridData.FILL_HORIZONTAL);
	data.widthHint = SIZING_TEXT_FIELD_WIDTH;
	projectNameField.setLayoutData(data);
	projectNameField.setFont(parent.getFont());

	// Set the initial value first before listener
	// to avoid handling an event during the creation.
	if (initialProjectFieldValue != null) {
		projectNameField.setText(initialProjectFieldValue);
	}
	projectNameField.addListener(SWT.Modify, nameModifyListener);
	BidiUtils.applyBidiProcessing(projectNameField, BidiUtils.BTD_DEFAULT);
}
 
源代码10 项目: xds-ide   文件: SWTFactory.java
public static void addCharsFilterValidator(Text t, final String charsToExclude) {
	t.addListener(SWT.Verify, new Listener() {
	   public void handleEvent(Event e) {
	      String s = e.text;
	      for (int i=0; i<charsToExclude.length(); ++i) {
	    	  if (s.indexOf(charsToExclude.charAt(i))>= 0) {
		            e.doit = false;
		            return;
	    	  }
	      }
	   }
	});
}
 
源代码11 项目: tracecompass   文件: RenameExperimentDialog.java
private void createNewExperimentNameGroup(Composite parent) {
    Font font = parent.getFont();
    Composite folderGroup = new Composite(parent, SWT.NONE);
    GridLayout layout = new GridLayout();
    layout.numColumns = 2;
    folderGroup.setLayout(layout);
    folderGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

    String name = fExperiment.getName();

    // New experiment name label
    Label newExperimentLabel = new Label(folderGroup, SWT.NONE);
    newExperimentLabel.setFont(font);
    newExperimentLabel.setText(Messages.RenameExperimentDialog_ExperimentNewName);

    // New experiment name entry field
    fNewExperimentName = new Text(folderGroup, SWT.BORDER);
    GridData data = new GridData(GridData.FILL_HORIZONTAL);
    data.widthHint = IDialogConstants.ENTRY_FIELD_WIDTH;
    fNewExperimentName.setLayoutData(data);
    fNewExperimentName.setFont(font);
    fNewExperimentName.setFocus();
    fNewExperimentName.setText(name);
    fNewExperimentName.setSelection(0, name.length());

    fNewExperimentName.addListener(SWT.Modify, event -> validateNewExperimentName());
}
 
源代码12 项目: Rel   文件: DbTab.java
public DbTab() {
	super(Core.getTabFolder(), SWT.None);

	crashTrap = new CrashTrap(this.getParent().getShell(), Version.getVersion());

	setImage(IconLoader.loadIcon("plusIcon"));

	Composite core = new Composite(Core.getTabFolder(), SWT.None);
	core.setLayout(new FormLayout());

	CBanner bannerDbLocationMode = new CBanner(core, SWT.NONE);
	FormData fd_bannerDbLocationMode = new FormData();
	fd_bannerDbLocationMode.right = new FormAttachment(100);
	fd_bannerDbLocationMode.top = new FormAttachment(0);
	fd_bannerDbLocationMode.left = new FormAttachment(0);
	bannerDbLocationMode.setLayoutData(fd_bannerDbLocationMode);

	Composite compDbLocation = new Composite(bannerDbLocationMode, SWT.NONE);
	bannerDbLocationMode.setLeft(compDbLocation);
	GridLayout gl_compDbLocation = new GridLayout(2, false);
	gl_compDbLocation.verticalSpacing = 0;
	gl_compDbLocation.marginWidth = 0;
	gl_compDbLocation.marginHeight = 0;
	compDbLocation.setLayout(gl_compDbLocation);

	ManagedToolbar toolBarDatabase = new ManagedToolbar(compDbLocation);
	
	if (DBrowser.hasLocalRel()) {
		new CommandActivator(null, toolBarDatabase, "NewDBIcon", SWT.NONE, "New database", e -> Core.newDatabase());
		new CommandActivator(null, toolBarDatabase, "database_restore", SWT.NONE, "New database from a backup", e -> Core.restoreDatabase());
		new CommandActivator(null, toolBarDatabase, "OpenDBLocalIcon", SWT.NONE, "Open local database", e -> Core.openLocalDatabase());
	}
	new CommandActivator(null, toolBarDatabase, "OpenDBRemoteIcon", SWT.NONE, "Open remote database", e -> Core.openRemoteDatabase());

	textDbLocation = new Text(compDbLocation, SWT.BORDER);
	textDbLocation.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, true, 1, 1));
	textDbLocation.addListener(SWT.KeyUp, e -> {
		if (e.character == 0xD && !textDbLocation.getText().trim().equals(oldText)) {
			oldText = textDbLocation.getText().trim();
			if (textDbLocation.getText().trim().length() == 0)
				textDbLocation.setText(lastURI);
			else {
				openDatabaseAtURI(textDbLocation.getText(), false);
			}
		}
	});

	toolBarMode = new ManagedToolbar(bannerDbLocationMode);
	toolBarMode.setEnabled(false);
	bannerDbLocationMode.setRight(toolBarMode);

	modeContent = new Composite(core, SWT.NONE);
	contentStack = new StackLayout();
	modeContent.setLayout(contentStack);
	FormData fd_modeContent = new FormData();
	fd_modeContent.bottom = new FormAttachment(100);
	fd_modeContent.top = new FormAttachment(bannerDbLocationMode);
	fd_modeContent.right = new FormAttachment(100);
	fd_modeContent.left = new FormAttachment(0);
	modeContent.setLayoutData(fd_modeContent);

	tltmModeRel = new CommandActivator(null, toolBarMode, "ModeRelIcon", SWT.RADIO, "Rel", e -> showRel());
	tltmModeRev = new CommandActivator(null, toolBarMode, "ModeRevIcon", SWT.RADIO, "Rev", e -> showRev());
	tltmModeCmd = new CommandActivator(null, toolBarMode, "ModeCmdIcon", SWT.RADIO, "Command line", e -> showCmd());

	setControl(core);

	preferenceChangeListener = new PreferenceChangeAdapter("DbTab") {
		@Override
		public void preferenceChange(PreferenceChangeEvent evt) {
			if (connection != null && connection.client != null)
				setImage(IconLoader.loadIcon("DatabaseIcon"));
			else
				setImage(IconLoader.loadIcon("plusIcon"));
		}
	};
	Preferences.addPreferenceChangeListener(PreferencePageGeneral.LARGE_ICONS, preferenceChangeListener);

	showRecentlyUsedList();
	
	core.pack();
}
 
源代码13 项目: nebula   文件: StringSortPageableTableExample.java
public static void main(String[] args) {
	Display display = new Display();
	Shell shell = new Shell(display);
	GridLayout layout = new GridLayout(2, false);
	shell.setLayout(layout);

	final List<String> items = createList();

	// 1) Create pageable table with 10 items per page
	// This SWT Component create internally a SWT Table+JFace TreeViewer
	int pageSize = 10;
	paginationTable = new PageableTable(shell, SWT.BORDER, SWT.BORDER | SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL, pageSize);
	paginationTable.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, true, 2, 1));

	// 2) Initialize the table viewer + SWT Table
	TableViewer viewer = paginationTable.getViewer();
	viewer.setContentProvider(ArrayContentProvider.getInstance());
	viewer.setLabelProvider(new LabelProvider());

	Table table = viewer.getTable();
	table.setHeaderVisible(true);
	table.setLinesVisible(true);

	// 3) Create column by adding SortTableColumnSelectionListener listener
	// to sort the paginated table.
	TableViewerColumn col = createTableViewerColumn(viewer, "Name", 150);
	col.setLabelProvider(new ColumnLabelProvider() {
		@Override
		public String getText(Object element) {
			String p = (String) element;
			return p;
		}
	});

	// Call SortTableColumnSelectionListener with null property name because
	// it's a list of String.
	col.getColumn().addSelectionListener(new SortTableColumnSelectionListener(null));

	// 4) Set the page loader used to load a page (sublist of String)
	// according the page index selected, the page size etc.
	paginationTable.setPageLoader(new PageResultLoaderList<>(items));

	// 5) Set current page to 0 to display the first page
	paginationTable.setCurrentPage(0);

	Label lbl = new Label(shell, SWT.NONE);
	lbl.setText("Max rows per page: ");
	lbl.setLayoutData(new GridData(GridData.END, GridData.CENTER, false, false));

	txt = new Text(shell, SWT.BORDER);
	txt.setText("10");
	GridData gd = new GridData(GridData.BEGINNING, GridData.CENTER, false, false);
	gd.widthHint = 30;
	txt.setLayoutData(gd);
	txt.addTraverseListener(e -> updatePageSize());
	txt.addListener(SWT.FocusOut, e -> updatePageSize());

	// paginationTable.getController().setPageSize(10);

	shell.setSize(550, 320);
	shell.open();
	while (!shell.isDisposed()) {
		if (!display.readAndDispatch())
			display.sleep();
	}
	display.dispose();
}
 
源代码14 项目: nebula   文件: CTreeCombo.java
/**
 * The CTreeCombo class represents a selectable user interface object
 * that combines a text field and a tree and issues notification
 * when an item is selected from the tree.
 * <p>
 * Note that although this class is a subclass of <code>Composite</code>,
 * it does not make sense to add children to it, or set a layout on it.
 * </p>
 * <dl>
 * <dt><b>Styles:</b>
 * <dd>BORDER, READ_ONLY, FLAT</dd>
 * <dt><b>Events:</b>
 * <dd>DefaultSelection, Modify, Selection, Verify</dd>
 * </dl>
 */
public CTreeCombo(Composite parent, int style) {
	super(parent, style = checkStyle(style));

	int textStyle = SWT.SINGLE;
	if ((style & SWT.READ_ONLY) != 0) {
		textStyle |= SWT.READ_ONLY;
	}
	if ((style & SWT.FLAT) != 0) {
		textStyle |= SWT.FLAT;
	}
	text = new Text(this, textStyle);
	int arrowStyle = SWT.ARROW | SWT.DOWN;
	if ((style & SWT.FLAT) != 0) {
		arrowStyle |= SWT.FLAT;
	}
	arrow = new Button(this, arrowStyle);

	listener = new Listener() {
		@Override
		public void handleEvent(Event event) {
			if (popup == event.widget) {
				popupEvent(event);
				return;
			}
			if (text == event.widget) {
				textEvent(event);
				return;
			}
			if (tree == event.widget) {
				treeEvent(event);
				return;
			}
			if (arrow == event.widget) {
				arrowEvent(event);
				return;
			}
			if (CTreeCombo.this == event.widget) {
				comboEvent(event);
				return;
			}
			if (getShell() == event.widget) {
				getDisplay().asyncExec(new Runnable() {
					@Override
					public void run() {
						if (isDisposed()) {
							return;
						}
						handleFocus(SWT.FocusOut);
					}
				});
			}
		}
	};
	filter = (event) -> {
		final Shell shell = ((Control) event.widget).getShell();
		if (shell == CTreeCombo.this.getShell()) {
			handleFocus(SWT.FocusOut);
		}
	};

	final int[] comboEvents = { SWT.Dispose, SWT.FocusIn, SWT.Move, SWT.Resize };
	for (int i = 0; i < comboEvents.length; i++) {
		addListener(comboEvents[i], listener);
	}

	final int[] textEvents = { SWT.DefaultSelection, SWT.KeyDown, SWT.KeyUp, SWT.MenuDetect, SWT.Modify, SWT.MouseDown, SWT.MouseUp, SWT.MouseDoubleClick, SWT.MouseWheel, SWT.Traverse, SWT.FocusIn, SWT.Verify };
	for (int i = 0; i < textEvents.length; i++) {
		text.addListener(textEvents[i], listener);
	}

	final int[] arrowEvents = { SWT.MouseDown, SWT.MouseUp, SWT.Selection, SWT.FocusIn };
	for (int i = 0; i < arrowEvents.length; i++) {
		arrow.addListener(arrowEvents[i], listener);
	}

	createPopup(null, null);
	initAccessible();
}
 
源代码15 项目: thym   文件: IOSSimOptionsTab.java
/**
 * @wbp.parser.entryPoint
 */
@Override
public void createControl(Composite parent) {
	Composite comp = new Composite(parent, SWT.NONE);
	setControl(comp);
	comp.setLayout(new GridLayout(1, false));
	
	Group grpProject = new Group(comp, SWT.NONE);
	grpProject.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
	grpProject.setText("Project");
	grpProject.setLayout(new GridLayout(3, false));
	
	Label lblProject = new Label(grpProject, SWT.NONE);
	lblProject.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
	lblProject.setText("Project:");
	
	textProject = new Text(grpProject, SWT.BORDER);
	textProject.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
	textProject.addListener(SWT.Modify, dirtyFlagListener);
	
	
	Button btnProjectBrowse = new Button(grpProject, SWT.NONE);
	btnProjectBrowse.addSelectionListener(new SelectionAdapter() {
		@Override
		public void widgetSelected(SelectionEvent e) {
			ElementListSelectionDialog es = new ElementListSelectionDialog(getShell(), WorkbenchLabelProvider.getDecoratingWorkbenchLabelProvider());
			es.setElements(HybridCore.getHybridProjects().toArray());
			es.setTitle("Project Selection");
			es.setMessage("Select a project to run");
			if (es.open() == Window.OK) {			
				HybridProject project = (HybridProject) es.getFirstResult();
				textProject.setText(project.getProject().getName());
			}		
		}
	});
	btnProjectBrowse.setText("Browse...");
	
	Group grpSimulator = new Group(comp, SWT.NONE);
	grpSimulator.setLayout(new GridLayout(2, false));
	grpSimulator.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
	grpSimulator.setText("Simulator");
	
	Label lblSdkVersion = new Label(grpSimulator, SWT.NONE);
	lblSdkVersion.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
	lblSdkVersion.setText("Device:");
	
	comboSDKVer = new Combo(grpSimulator, SWT.READ_ONLY);
	
	comboSDKVer.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
	comboSDKVer.addListener(SWT.Selection, dirtyFlagListener);

	comboViewer = new ComboViewer(comboSDKVer);
	comboViewer.setContentProvider(new SDKContentProvider());
	comboViewer.setLabelProvider( new LabelProvider() {
		@Override
		public String getText(Object element) {
			IOSDevice device = (IOSDevice) element;
			return NLS.bind("{0} ({1})", new String[]{device.getDeviceName(), device.getiOSName()});
		}
	});
	comboViewer.setInput(getSimulatorDevices());
}
 
源代码16 项目: Pydev   文件: TableCellEditorListener.java
/**
 * http://www.eclipse.org/swt/snippets/
 */
@Override
public void handleEvent(Event event) {

    final TableEditor editor = new TableEditor(table);
    editor.horizontalAlignment = SWT.LEFT;
    editor.grabHorizontal = true;

    Rectangle clientArea = table.getClientArea();
    if (table.getSelection().length != 1) {
        return;
    }

    Rectangle bounds = table.getSelection()[0].getBounds();
    Point pt = new Point(bounds.x, bounds.y);
    int index = table.getTopIndex();
    while (index < table.getItemCount()) {
        boolean visible = false;
        final SimpleTableItem item = (SimpleTableItem) table.getItem(index);
        for (int i = 0; i < table.getColumnCount(); i++) {
            Rectangle rect = item.getBounds(i);
            if (rect.contains(pt)) {

                final Text text = new Text(table, SWT.NONE);
                Listener textListener = new TextListener(item, text);

                text.addListener(SWT.FocusOut, textListener);
                text.addListener(SWT.Traverse, textListener);
                text.addListener(SWT.FocusOut, wizard);
                editor.setEditor(text, item, i);
                text.setText(item.getText(i));
                text.selectAll();
                text.setFocus();
                return;
            }
            if (!visible && rect.intersects(clientArea)) {
                visible = true;
            }
        }
        if (!visible) {
            return;
        }
        index++;
    }
}
 
源代码17 项目: birt   文件: ExtendedPropertyEditorComposite.java
public void widgetSelected( SelectionEvent e )
{
	if ( e.getSource( ).equals( btnAdd ) )
	{
		String sKey = txtNewKey.getText( );
		if ( sKey.length( ) > 0 && !propMap.containsKey( sKey ) )
		{
			String[] sProperty = new String[2];
			sProperty[0] = sKey;
			sProperty[1] = ""; //$NON-NLS-1$

			TableItem tiProp = new TableItem( table, SWT.NONE );
			tiProp.setText( sProperty );
			table.select( table.getItemCount( ) - 1 );

			updateModel( sProperty[0], sProperty[1] );
			txtNewKey.setText( "" ); //$NON-NLS-1$
		}
	}
	else if ( e.getSource( ).equals( btnRemove ) )
	{
		if ( table.getSelection( ).length != 0 )
		{
			int index = table.getSelectionIndex( );
			String key = table.getSelection( )[0].getText( 0 );
			ExtendedProperty property = propMap.get( key );
			if ( property != null )
			{
				extendedProperties.remove( property );
				propMap.remove( key );
				table.remove( table.getSelectionIndex( ) );
				table.select( index<table.getItemCount( ) ?index:table.getItemCount( )- 1 );
			}
			Control editor = editorValue.getEditor( );
			if ( editor != null )
			{
				editor.dispose( );
			}
		}
	}
	else if ( e.getSource( ).equals( table ) )
	{
		Control oldEditor = editorValue.getEditor( );
		if ( oldEditor != null )
			oldEditor.dispose( );

		// Identify the selected row
		final TableItem item = (TableItem) e.item;
		if ( item == null )
		{
			return;
		}

		// The control that will be the editor must be a child of the Table
		Text newEditor = new Text( table, SWT.NONE );
		newEditor.setText( item.getText( 1 ) );
		newEditor.addListener( SWT.FocusOut, new Listener( ) {

			public void handleEvent( Event event )
			{
				Text text = (Text) event.widget;
				editorValue.getItem( ).setText( 1, text.getText( ) );
				updateModel( item.getText( 0 ), text.getText( ) );
			}
		} );
		newEditor.selectAll( );
		newEditor.setFocus( );
		editorValue.setEditor( newEditor, item, 1 );
	}
	btnRemove.setEnabled( !propDisabledMap.containsKey( table.getSelection( )[0].getText( 0 ) ) );
}
 
源代码18 项目: birt   文件: CCombo.java
/**
 * Constructs a new instance of this class given its parent
 * and a style value describing its behavior and appearance.
 * <p>
 * The style value is either one of the style constants defined in
 * class <code>SWT</code> which is applicable to instances of this
 * class, or must be built by <em>bitwise OR</em>'ing together 
 * (that is, using the <code>int</code> "|" operator) two or more
 * of those <code>SWT</code> style constants. The class description
 * lists the style constants that are applicable to the class.
 * Style bits are also inherited from superclasses.
 * </p>
 *
 * @param parent a widget which will be the parent of the new instance (cannot be null)
 * @param style the style of widget to construct
 *
 * @exception IllegalArgumentException <ul>
 *    <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
 * </ul>
 * @exception SWTException <ul>
 *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
 * </ul>
 *
 * @see SWT#BORDER
 * @see SWT#READ_ONLY
 * @see SWT#FLAT
 * @see Widget#getStyle()
 */
public CCombo (Composite parent, int style) {
	super (parent, style = checkStyle (style));
	
	int textStyle = SWT.SINGLE;
	if ((style & SWT.READ_ONLY) != 0) textStyle |= SWT.READ_ONLY;
	if ((style & SWT.FLAT) != 0) textStyle |= SWT.FLAT;
	text = new Text (this, textStyle);
	int arrowStyle = SWT.ARROW | SWT.DOWN;
	if ((style & SWT.FLAT) != 0) arrowStyle |= SWT.FLAT;
	arrow = new Button (this, arrowStyle);

	listener = new Listener () {
		public void handleEvent (Event event) {
			if (popup == event.widget) {
				popupEvent (event);
				return;
			}
			if (text == event.widget) {
				textEvent (event);
				return;
			}
			if (list == event.widget) {
				listEvent (event);
				return;
			}
			if (arrow == event.widget) {
				arrowEvent (event);
				return;
			}
			if (CCombo.this == event.widget) {
				comboEvent (event);
				return;
			}

		}
	};
	
	
	int [] comboEvents = {SWT.Dispose, SWT.Move, SWT.Resize};
	for (int i=0; i<comboEvents.length; i++) this.addListener (comboEvents [i], listener);
	
	int [] textEvents = {SWT.KeyDown, SWT.KeyUp, SWT.Modify, SWT.MouseDown, SWT.MouseUp, SWT.Traverse, SWT.FocusIn, SWT.FocusOut};
	for (int i=0; i<textEvents.length; i++) text.addListener (textEvents [i], listener);
	
	int [] arrowEvents = {SWT.Selection, SWT.FocusIn, SWT.FocusOut};
	for (int i=0; i<arrowEvents.length; i++) arrow.addListener (arrowEvents [i], listener);
	
	createPopup(null, -1);
	initAccessible();
	
}
 
源代码19 项目: nebula   文件: IPAddressFormatter.java
/**
 * Sets the <code>Text</code> widget that will be managed by this formatter.
 * <p>
 *
 * The ancestor is overrided to add a key listener on the text widget.
 *
 * @param text Text widget
 * @see ITextFormatter#setText(Text)
 */
public void setText(Text text) {
	super.setText(text);
	text.addListener(SWT.KeyDown, keyListener);
}
 
源代码20 项目: translationstudio8   文件: NewFolderDialogOfHs.java
/**
		 * Creates the folder name specification controls.
		 *
		 * @param parent the parent composite
		 */
		private void createFolderNameGroup(Composite parent) {
			Font font = parent.getFont();
			// project specification group
			Composite folderGroup = new Composite(parent, SWT.NONE);
			GridLayout layout = new GridLayout();
			layout.numColumns = 2;
			folderGroup.setLayout(layout);
			folderGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

			// new folder label
			Label folderLabel = new Label(folderGroup, SWT.NONE);
			folderLabel.setFont(font);
			folderLabel.setText(IDEWorkbenchMessages.NewFolderDialog_nameLabel);

			// new folder name entry field
			folderNameField = new Text(folderGroup, SWT.BORDER);
			GridData data = new GridData(GridData.FILL_HORIZONTAL);
			data.widthHint = IDialogConstants.ENTRY_FIELD_WIDTH;
			folderNameField.setLayoutData(data);
			folderNameField.setFont(font);
			folderNameField.addListener(SWT.Modify, new Listener() {
				public void handleEvent(Event event) {
					validateLinkedResource();
				}
			});
		}