下面列出了org.eclipse.swt.events.ShellEvent#org.eclipse.swt.widgets.List 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
private java.util.List<Point> getNodeSizes() {
java.util.List<Point> sizes = new ArrayList<>();
Image image = new Image( shell.getDisplay(), 100, 100 );
GC gc = new GC( image );
gc.setFont( GUIResource.getInstance().getFontMediumBold() );
for ( GraphNode node : graphModel.getNodes() ) {
Point textExtent = gc.textExtent( node.getName() );
int width = textExtent.x + 2 * 10; // 10 : margin
int height = textExtent.y + 2 * 10;
sizes.add( new Point( width, height ) );
}
gc.dispose();
image.dispose();
return sizes;
}
@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;
}
/**
* remove the given items from the saved selectedComlumnsInfo
*
* @param removedItemsList
* list that contains the given elements that are going to be
* removed
*/
private void removeItemsFromSelectedOnes(
java.util.List<String[]> removedItemsList )
{
for ( int i = 0; i < removedItemsList.size( ); i++ )
{
for ( int j = 0; j < savedSelectedColumnsInfoList.size( ); j++ )
{
if ( removedItemsList.get( i )[0].equals( savedSelectedColumnsInfoList.get( j )[0] )
&& ( (String[]) removedItemsList.get( i ) )[1].equals( ( (String[]) savedSelectedColumnsInfoList.get( j ) )[1] )
&& ( (String[]) removedItemsList.get( i ) )[2].equals( ( (String[]) savedSelectedColumnsInfoList.get( j ) )[2] ) )
{
savedSelectedColumnsInfoList.remove( j );
break;
}
}
}
}
private java.util.List<KeyOccurrence> getTodoList( String locale, String messagesPackage, String sourceFolder,
boolean strict ) {
// Get the list of keys that need a translation...
//
java.util.List<KeyOccurrence> keys = crawler.getOccurrencesForPackage( messagesPackage );
java.util.List<KeyOccurrence> todo = new ArrayList<KeyOccurrence>();
for ( KeyOccurrence keyOccurrence : keys ) {
// Avoid the System keys. Those are taken care off in a different package
//
if ( showKey( keyOccurrence.getKey(), keyOccurrence.getMessagesPackage() ) ) {
String value = store.lookupKeyValue( locale, messagesPackage, keyOccurrence.getKey() );
if ( Utils.isEmpty( value ) || ( wAll.getSelection() && !strict ) ) {
todo.add( keyOccurrence );
}
}
}
return todo;
}
protected void createList(final Composite mainComposite) {
final List list = getWidgetFactory().createList(mainComposite, SWT.BORDER | SWT.V_SCROLL);
list.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).hint(SWT.DEFAULT, 90).create());
listViewer = new ListViewer(list);
listViewer.setContentProvider(new ObservableListContentProvider<Element>());
listViewer.setLabelProvider(new LabelProvider(){
@Override
public String getText(final Object element) {
if(element != null && element instanceof Connection){
final String transitionName = ((Connection) element).getName();
return transitionName +" -- "+((Connection) element).getTarget().getName();
}
return super.getText(element);
}
});
listViewer.addSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(final SelectionChangedEvent event) {
updateButtonsEnablement();
}
});
}
/**
* Set the content of the ColumnsViewer
*
*/
private void setColumnsViewerContent( )
{
selectedColumnsViewer.setContentProvider( new IStructuredContentProvider( ) {
public Object[] getElements( Object inputElement )
{
if ( inputElement instanceof java.util.List )
{
return ( (java.util.List<?>) inputElement ).toArray( );
}
return new Object[0];
}
public void dispose( )
{
}
public void inputChanged( Viewer viewer, Object oldInput,
Object newInput )
{
}
} );
}
private void setEncodings() {
// Encoding of the text file:
if ( !gotEncodings ) {
gotEncodings = true;
wEncoding.removeAll();
java.util.List<Charset> values = new ArrayList<Charset>( Charset.availableCharsets().values() );
for ( Charset charSet : values ) {
wEncoding.add( charSet.displayName() );
}
// Now select the default!
String defEncoding = Const.getEnvironmentVariable( "file.encoding", "UTF-8" );
int idx = Const.indexOfString( defEncoding, wEncoding.getItems() );
if ( idx >= 0 ) {
wEncoding.select( idx );
}
}
}
public boolean quitFile() {
java.util.List<MessagesStore> changedMessagesStores = store.getChangedMessagesStores();
if ( !changedMessagesStores.isEmpty() ) {
MessageBox mb = new MessageBox( shell, SWT.YES | SWT.NO | SWT.ICON_WARNING );
mb.setMessage( BaseMessages.getString( PKG, "i18nDialog.ChangedFilesWhenExit", changedMessagesStores.size()
+ EMPTY_STRING ) );
mb.setText( BaseMessages.getString( PKG, "i18nDialog.Warning" ) );
int answer = mb.open();
if ( answer == SWT.NO ) {
return false;
}
}
WindowProperty winprop = new WindowProperty( shell );
props.setScreen( winprop );
props.saveProps();
shell.dispose();
display.dispose();
return true;
}
/**
* @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;
}
/**
* Open the config editor dialog for editing an existing configuration.
* This is called, when edit button is pressed.
*/
private void openEditorDialog() {
List list = getListControl(parent);
int index = list.getSelectionIndex();
if (index < 0) {
// no item selected from the list, do nothing
return;
}
String name = list.getItem(index);
if (name == null || name.length() == 0) {
// no name for the item, can't load config
return;
}
registry.setActiveViewer(name.substring(0, name.indexOf('(')-1));
ViewerConfigDialog dialog = new ViewerConfigDialog(editButton.getShell(),
(ViewerAttributeRegistry) registry.clone());
int code = dialog.open();
if (code == Window.OK) {
registry.mergeWith(dialog.getRegistry());
list.setItem(index, registry.getActiveViewer() + " (" + registry.getCommand() + ")");
}
}
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);
}
/**
* 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;
}
public ValidatorDialog( Shell parent, Object in, TransMeta tr, String sname ) {
super( parent, (BaseStepMeta) in, tr, sname );
input = (ValidatorMeta) in;
// Just to make sure everything is nicely in sync...
//
java.util.List<StreamInterface> infoStreams = input.getStepIOMeta().getInfoStreams();
for ( int i = 0; i < infoStreams.size(); i++ ) {
input.getValidations().get( i ).setSourcingStepName( infoStreams.get( i ).getStepname() );
}
selectedField = null;
selectionList = new ArrayList<Validation>();
// Copy the data from the input into the map...
//
for ( Validation field : input.getValidations() ) {
selectionList.add( field.clone() );
}
}
/**
* 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);
}
public static List createList(Composite parent, int hspan, int style, int nLines) {
List l = new List(parent, style);
l.setFont(parent.getFont());
GC gc = new GC(l);
int cyLine;
try{
cyLine = gc.textExtent("Wq").y; //$NON-NLS-1$
}
finally{
gc.dispose();
}
GridData gd = new GridData(GridData.FILL_HORIZONTAL);
gd.horizontalSpan = hspan;
gd.heightHint = cyLine * nLines + 5;
l.setLayoutData(gd);
return l;
}
@Override
protected Control createDialogArea(Composite parent){
Composite ret = new Composite(parent, SWT.None);
ret.setLayoutData(SWTHelper.getFillGridData(1, true, 1, true));
GridLayout gl_ret = new GridLayout(1, false);
gl_ret.marginWidth = 0;
gl_ret.marginHeight = 0;
ret.setLayout(gl_ret);
list = new List(ret, SWT.BORDER);
list.setLayoutData(SWTHelper.getFillGridData(1, true, 1, true));
reloadFaelleList();
ToolBarManager tbManager = new ToolBarManager(SWT.FLAT | SWT.HORIZONTAL | SWT.WRAP);
tbManager.add(GlobalActions.neuerFallAction);
tbManager.createControl(ret);
ElexisEventDispatcher.getInstance().addListeners(updateFallListener);
return ret;
}
private String[] sortSelectedList(java.util.List<String> itemList)
{
//sort original data
java.util.List<String> tempResult = new ArrayList<String>();
java.util.List datas = new ArrayList();
for(String item : itemList)
{
if(displayObjectMaps.get(item) != null)
{
datas.add(displayObjectMaps.get(item));
}
}
Collections.sort(datas);
for(int i = 0;i<datas.size();i++)
{
tempResult.add((String)(objectDisplayMaps.get(datas.get(i))));
}
return tempResult.toArray(new String[tempResult.size()]);
}
private void addList() {
Composite composite = new Composite( sashform, SWT.NONE );
props.setLook( composite );
FillLayout fillLayout = new FillLayout();
fillLayout.marginWidth = Const.FORM_MARGIN;
fillLayout.marginHeight = Const.FORM_MARGIN;
composite.setLayout( fillLayout );
// Make a listbox
wList = new List( composite, SWT.MULTI | SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL );
// Add a selection listener.
wList.addSelectionListener( new SelectionAdapter() {
public void widgetSelected( SelectionEvent arg0 ) {
refreshGrid();
}
} );
}
private void setEncodings() {
// Encoding of the text file:
if ( !gotEncodings ) {
gotEncodings = true;
wEncoding.removeAll();
java.util.List<Charset> values = new ArrayList<Charset>( Charset.availableCharsets().values() );
for ( Charset charSet : values ) {
wEncoding.add( charSet.displayName() );
}
// Now select the default!
String defEncoding = Const.getEnvironmentVariable( "file.encoding", "UTF-8" );
int idx = Const.indexOfString( defEncoding, wEncoding.getItems() );
if ( idx >= 0 ) {
wEncoding.select( idx );
}
}
}
@Override
protected Control createDialogArea(Composite parent) {
Composite control = (Composite) super.createDialogArea(parent);
Label termPositionLabel = new Label(control, SWT.NONE);
GridData termPositionGrid = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1);
termPositionGrid.horizontalIndent = 1;
termPositionLabel.setLayoutData(termPositionGrid);
termPositionLabel.setText("Create Term: ");
this.positionList = new List(control, SWT.SINGLE);
GridData positionListGrid = new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1);
positionListGrid.horizontalAlignment = 1;
this.positionList.setLayoutData(positionListGrid);
this.positionList.add("As Subterm.");
this.positionList.add("As Neighbor.");
return control;
}
/**
* Constructs a new instance of the dialog
*/
public ImportValueDialog( String style, java.util.List<String> choices )
{
super( DLG_TITLE );
assert DATA_TYPE_CHOICE_SET.contains( style );
this.style = style;
this.choiceList = choices;
expectedColumnDataType = DataAdapterUtil.modelDataTypeToCoreDataType( style );
try
{
compatibleDataTypes = DataAdapterUtil.getCompatibleDataTypes( expectedColumnDataType );
}
catch ( AdapterException e )
{
e.printStackTrace( );
}
}
/**
* @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;
}
public TextFileImportWizardPage2( String arg, PropsUI props, java.util.List<String> rows,
Vector<TextFileInputFieldInterface> fields ) {
super( arg );
this.props = props;
this.rows = rows;
this.fields = fields;
setTitle( BaseMessages.getString( PKG, "TextFileImportWizardPage2.DialogTitle" ) );
setDescription( "Give a name to the fields in this text file" );
}
/**
* @param selectedNrs the selectedNrs to set
*/
public void setSelectedNrs( java.util.List<Integer> selectedNrs ) {
this.selectedNrs = new int[ selectedNrs.size() ];
for ( int i = 0; i < selectedNrs.size(); i++ ) {
this.selectedNrs[ i ] = selectedNrs.get( i );
}
}
/**
* Create a new dialog allowing the user to enter a mapping
*
* @param parent the parent shell
* @param source the source values
* @param target the target values
* @param mappings the already selected mappings (ArrayList containing <code>SourceToTargetMapping</code>s)
*/
public EnterMappingDialog( Shell parent, String[] source, String[] target,
java.util.List<SourceToTargetMapping> mappings ) {
super( parent, SWT.NONE );
props = PropsUi.getInstance();
this.sourceList = source;
this.targetList = target;
this.mappings = mappings;
}
private static final void applyChanges( Shell shell, List list, Control control, int position,
IInsertText insertTextInterface ) {
String selection =
list.getSelection()[ 0 ].contains( Const.getDeprecatedPrefix() )
? list.getSelection()[ 0 ].replace( Const.getDeprecatedPrefix(), "" )
: list.getSelection()[ 0 ];
String extra = "${" + selection + "}";
if ( insertTextInterface != null ) {
insertTextInterface.insertText( extra, position );
} else {
if ( control.isDisposed() ) {
return;
}
if ( list.getSelectionCount() <= 0 ) {
return;
}
if ( control instanceof Text ) {
( (Text) control ).insert( extra );
} else if ( control instanceof CCombo ) {
CCombo combo = (CCombo) control;
combo.setText( extra ); // We can't know the location of the cursor yet. All we can do is overwrite.
} else if ( control instanceof StyledTextComp ) {
( (StyledTextComp) control ).insert( extra );
} else if ( control instanceof StyledText ) {
( (StyledText) control ).insert( extra );
}
}
if ( !shell.isDisposed() ) {
shell.dispose();
}
if ( !control.isDisposed() ) {
control.setData( Boolean.FALSE );
}
}
public void refreshGrid() {
applyChangedValue();
wTodo.removeAll();
wKey.setText( EMPTY_STRING );
wMain.setText( EMPTY_STRING );
wValue.setText( EMPTY_STRING );
wSource.setText( EMPTY_STRING );
selectedLocale = wLocale.getSelectionCount() == 0 ? null : wLocale.getSelection()[0];
selectedSourceFolder =
wPackages.table.getSelectionCount() == 0 ? null : wPackages.table.getSelection()[0].getText( 1 );
selectedMessagesPackage =
wPackages.table.getSelectionCount() == 0 ? null : wPackages.table.getSelection()[0].getText( 2 );
refreshPackages();
// Only continue with a locale & a messages package, otherwise we won't
// budge ;-)
//
if ( selectedLocale != null && selectedSourceFolder != null && selectedMessagesPackage != null ) {
// Get the list of keys that need a translation...
//
java.util.List<KeyOccurrence> todo =
getTodoList( selectedLocale, selectedMessagesPackage, selectedSourceFolder, false );
String[] todoItems = new String[todo.size()];
for ( int i = 0; i < todoItems.length; i++ ) {
todoItems[i] = todo.get( i ).getKey();
}
wTodo.setItems( todoItems );
}
}
public void refreshGrid() {
applyChangedValue();
wTodo.removeAll();
wKey.setText( "" );
wMain.setText( "" );
wValue.setText( "" );
wSource.setText( "" );
selectedLocale = wLocale.getSelectionCount() == 0 ? null : wLocale.getSelection()[ 0 ];
selectedSourceFolder = wPackages.table.getSelectionCount() == 0 ? null : wPackages.table.getSelection()[ 0 ].getText( 1 );
selectedMessagesPackage = wPackages.table.getSelectionCount() == 0 ? null : wPackages.table.getSelection()[ 0 ].getText( 2 );
refreshPackages();
// Only continue with a locale & a messages package, otherwise we won't
// budge ;-)
//
if ( selectedLocale != null && selectedSourceFolder != null && selectedMessagesPackage != null ) {
// Get the list of keys that need a translation...
//
java.util.List<KeyOccurrence> todo = getTodoList( selectedLocale, selectedMessagesPackage, selectedSourceFolder, false );
String[] todoItems = new String[ todo.size() ];
for ( int i = 0; i < todoItems.length; i++ ) {
todoItems[ i ] = todo.get( i ).getKey();
}
wTodo.setItems( todoItems );
}
}
public TextFileImportWizardPage2( String arg, PropsUi props, java.util.List<String> rows,
Vector<ITextFileInputField> fields ) {
super( arg );
this.props = props;
this.rows = rows;
this.fields = fields;
setTitle( BaseMessages.getString( PKG, "TextFileImportWizardPage2.DialogTitle" ) );
setDescription( "Give a name to the fields in this text file" );
}
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);
}