public List getListControl(Composite parent) { listControl = super.getListControl(parent); listControl.addMouseListener( new MouseListener() { public void mouseUp(MouseEvent arg0) { selectionChanged1(); } public void mouseDown(MouseEvent arg0) {} public void mouseDoubleClick(MouseEvent arg0) {} }); listControl.addKeyListener( new KeyListener() { public void keyReleased(KeyEvent event) { if (event.keyCode == 32) { storeDefault(); } selectionChanged1(); } public void keyPressed(KeyEvent arg0) {} }); return listControl; }
public String open() { Shell parent = getParent(); Display display = parent.getDisplay(); shell = new Shell( parent, SWT.DIALOG_TRIM | (modal ? SWT.APPLICATION_MODAL | SWT.SHEET : SWT.NONE) | SWT.RESIZE | SWT.MIN | SWT.MAX); props.setLook(shell); FormLayout formLayout = new FormLayout(); formLayout.marginWidth = Const.FORM_MARGIN; formLayout.marginHeight = Const.FORM_MARGIN; shell.setLayout(formLayout); shell.setText(shellText); shell.setImage(GUIResource.getInstance().getImageSpoon()); int margin = Const.MARGIN; if (quickSearch) { ToolBar treeTb = new ToolBar(shell, SWT.HORIZONTAL | SWT.FLAT); props.setLook(treeTb); ToolItem wtfilter = new ToolItem(treeTb, SWT.SEPARATOR); Label wlfilter = new Label(treeTb, SWT.SEARCH); props.setLook(wlfilter); wlfilter.setText(BaseMessages.getString(PKG, "EnterSelectionDialog.FilterString.Label")); wtfilter.setControl(wlfilter); if (Const.isOSX()) { wtfilter.setWidth(100); } else { wtfilter.setWidth(70); } wfilter = new ToolItem(treeTb, SWT.SEPARATOR); searchText = new Text(treeTb, SWT.SEARCH | SWT.CANCEL); props.setLook(searchText); searchText.setToolTipText( BaseMessages.getString(PKG, "EnterSelectionDialog.FilterString.ToolTip")); wfilter.setControl(searchText); wfilter.setWidth(120); wbRegex = new ToolItem(treeTb, SWT.CHECK); wbRegex.setImage(GUIResource.getInstance().getImageRegexSmall()); wbRegex.setToolTipText(BaseMessages.getString(PKG, "EnterSelectionDialog.useRegEx.Tooltip")); goSearch = new ToolItem(treeTb, SWT.PUSH); goSearch.setImage(GUIResource.getInstance().getImageSearchSmall()); goSearch.setToolTipText(BaseMessages.getString(PKG, "EnterSelectionDialog.refresh.Label")); goSearch.addSelectionListener( new SelectionAdapter() { public void widgetSelected(SelectionEvent event) { updateFilter(); } }); if (this.databasesInterface != null) { addConnection = new ToolItem(treeTb, SWT.PUSH); addConnection.setImage(GUIResource.getInstance().getImageAdd()); addConnection.setToolTipText(BaseMessages.getString(PKG, "Add.Datasource.Label")); addConnection.addSelectionListener( new SelectionAdapter() { public void widgetSelected(SelectionEvent event) { addDataSource(); } }); } FormData fd = new FormData(); fd.right = new FormAttachment(100, -margin); fd.top = new FormAttachment(0, margin); treeTb.setLayoutData(fd); searchText.addSelectionListener( new SelectionAdapter() { public void widgetDefaultSelected(SelectionEvent e) { updateFilter(); } }); // From step line wlSelection = new Label(shell, SWT.NONE); wlSelection.setText(lineText); props.setLook(wlSelection); fdlSelection = new FormData(); fdlSelection.left = new FormAttachment(0, 0); fdlSelection.top = new FormAttachment(treeTb, margin); wlSelection.setLayoutData(fdlSelection); } else { // From step line wlSelection = new Label(shell, SWT.NONE); wlSelection.setText(lineText); props.setLook(wlSelection); fdlSelection = new FormData(); fdlSelection.left = new FormAttachment(0, 0); wlSelection.setLayoutData(fdlSelection); } int options = SWT.LEFT | SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL; if (multi) { options |= SWT.MULTI; } else { options |= SWT.SINGLE; } wSelection = new List(shell, options); for (int i = 0; i < choices.length; i++) { wSelection.add(choices[i]); } if (selectedNrs != null) { wSelection.select(selectedNrs); wSelection.showSelection(); } if (fixed) { props.setLook(wSelection, Props.WIDGET_STYLE_FIXED); } else { props.setLook(wSelection); } // Some buttons wOK = new Button(shell, SWT.PUSH); if (viewOnly) { wOK.setText(BaseMessages.getString(PKG, "System.Button.Close")); } else { wOK.setText(BaseMessages.getString(PKG, "System.Button.OK")); } lsOK = new Listener() { public void handleEvent(Event e) { ok(); } }; wOK.addListener(SWT.Selection, lsOK); Button[] buttons = new Button[] {wOK}; if (!viewOnly) { wCancel = new Button(shell, SWT.PUSH); wCancel.setText(BaseMessages.getString(PKG, "System.Button.Cancel")); lsCancel = new Listener() { public void handleEvent(Event e) { cancel(); } }; wCancel.addListener(SWT.Selection, lsCancel); buttons = new Button[] {wOK, wCancel}; } BaseStepDialog.positionBottomButtons(shell, buttons, margin, null); fdSelection = new FormData(); fdSelection.left = new FormAttachment(0, 0); fdSelection.right = new FormAttachment(100, 0); fdSelection.top = new FormAttachment(wlSelection, margin); fdSelection.bottom = new FormAttachment(wOK, -margin * 3); wSelection.setLayoutData(fdSelection); // Add listeners lsDef = new SelectionAdapter() { public void widgetDefaultSelected(SelectionEvent e) { ok(); } }; wSelection.addSelectionListener(lsDef); wSelection.addKeyListener( new KeyAdapter() { public void keyPressed(KeyEvent e) { if (e.character == SWT.CR) { ok(); } } }); // Detect [X] or ALT-F4 or something that kills this window... shell.addShellListener( new ShellAdapter() { public void shellClosed(ShellEvent e) { cancel(); } }); getData(); BaseStepDialog.setSize(shell); wOK.setFocus(); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } return selection; }