/** Copy information from the meta-data input to the dialog fields. */ public void getData() { wStepname.setText(stepname); for (int i = 0; i < input.getFieldCCType().length; i++) { TableItem item = wFields.table.getItem(i); String type = input.getFieldCCType()[i]; String len = input.getFieldCCLength()[i]; String size = input.getFieldCCSize()[i]; if (type != null) item.setText(1, type); if (len != null) item.setText(2, len); if (size != null) item.setText(3, size); } wFields.setRowNums(); wFields.optWidth(true); if (input.getCardNumberFieldName() != null) wCCNumberField.setText(input.getCardNumberFieldName()); if (input.getCardTypeFieldName() != null) wCCTypeField.setText(input.getCardTypeFieldName()); if (input.getCardLengthFieldName() != null) wCCLengthField.setText(input.getCardLengthFieldName()); wStepname.selectAll(); }
/** Copy information from the meta-data input to the dialog fields. */ public void getData() { if (jobEntry.getName() != null) wName.setText(jobEntry.getName()); wName.selectAll(); if (jobEntry.getxmlFilename() != null) wxmlFilename.setText(jobEntry.getxmlFilename()); if (jobEntry.getdtdFilename() != null) wdtdFilename.setText(jobEntry.getdtdFilename()); wDTDIntern.setSelection(jobEntry.getDTDIntern()); }
@Override protected void doSetFocus() { if (text != null) { text.selectAll(); text.setFocus(); } }
public long open(long aLimit) { limit = aLimit; finalResult = -1L; buttonPressed = 0; if (sShell == null || sShell.isDisposed()) { createSShell(); } sShell.pack(); Manager.reduceDistance(getParent(), sShell); if (lastHexButtonSelected) { hexRadioButton.setSelection(true); } else { decRadioButton.setSelection(true); } label.setText( "Enter location number, 0 to " + limit + " (0x0 to 0x" + Long.toHexString(limit) + ")"); text.setText(lastLocationText); text.selectAll(); text.setFocus(); sShell.open(); Display display = getParent().getDisplay(); while (!sShell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } return finalResult; }
/** Copy information from the meta-data input to the dialog fields. */ public void getData() { wName.setText(Const.nullToEmpty(jobEntry.getName())); if (jobEntry.getSchemaname() != null) { wSchemaname.setText(jobEntry.getSchemaname()); } if (jobEntry.getTablename() != null) { wTablename.setText(jobEntry.getTablename()); } if (jobEntry.getFilename() != null) { wFilename.setText(jobEntry.getFilename()); } if (jobEntry.getSeparator() != null) { wSeparator.setText(jobEntry.getSeparator()); } if (jobEntry.getEnclosed() != null) { wEnclosed.setText(jobEntry.getEnclosed()); } if (jobEntry.getEscaped() != null) { wEscaped.setText(jobEntry.getEscaped()); } if (jobEntry.getLinestarted() != null) { wLinestarted.setText(jobEntry.getLinestarted()); } if (jobEntry.getLineterminated() != null) { wLineterminated.setText(jobEntry.getLineterminated()); } wReplacedata.setSelection(jobEntry.isReplacedata()); wLocalInfile.setSelection(jobEntry.isLocalInfile()); if (jobEntry.getIgnorelines() != null) { wIgnorelines.setText(jobEntry.getIgnorelines()); } else { wIgnorelines.setText("0"); } if (jobEntry.getListattribut() != null) { wListattribut.setText(jobEntry.getListattribut()); } if (jobEntry.prorityvalue >= 0) { wProrityValue.select(jobEntry.prorityvalue); } else { wProrityValue.select(0); // NORMAL priority } if (jobEntry.getDatabase() != null) { wConnection.setText(jobEntry.getDatabase().getName()); } wAddFileToResult.setSelection(jobEntry.isAddFileToResult()); wName.selectAll(); wName.setFocus(); }
public void focusGained(FocusEvent e) { Object source = e.getSource(); if (source instanceof Text) { Text text = (Text) source; textBak = text.getText(); text.selectAll(); } }
/** Copy information from the meta-data input to the dialog fields. */ public void getData() { if (jobEntry.getName() != null) wName.setText(jobEntry.getName()); wName.selectAll(); if (jobEntry.getHostname() != null) wHostname.setText(jobEntry.getHostname()); wPort.setText(Const.NVL(jobEntry.getPort(), String.valueOf(JobEntryTelnet.DEFAULT_PORT))); wTimeOut.setText( Const.NVL(jobEntry.getTimeOut(), String.valueOf(JobEntryTelnet.DEFAULT_TIME_OUT))); }
void onGenerateName() { List<ISearchCondition> conditions = fSearchConditionList.createConditions(); ISearchCondition locationCondition = fLocationControl.toScopeCondition(); if (locationCondition != null) conditions.add(locationCondition); String name = CoreUtils.getName(conditions, fMatchAllRadio.getSelection()); if (name.length() > 0) { fNameInput.setText(name); fNameInput.selectAll(); } }
/** Copy information from the meta-data input to the dialog fields. */ public void getData() { wName.setText(Const.NVL(jobEntry.getName(), "")); wMailAddress.setText(Const.NVL(jobEntry.getEmailAddress(), "")); wTimeOut.setText(Const.NVL(jobEntry.getTimeOut(), "0")); wSMTPCheck.setSelection(jobEntry.isSMTPCheck()); wDefaultSMTP.setText(Const.NVL(jobEntry.getDefaultSMTP(), "")); weMailSender.setText(Const.NVL(jobEntry.geteMailSender(), "")); wName.selectAll(); wName.setFocus(); }
/** Copy information from the meta-data input to the dialog fields. */ public void getData() { if (jobEntry.getName() != null) wName.setText(jobEntry.getName()); wName.selectAll(); wFilename.setText(Const.NVL(jobEntry.getFilename(), "")); wMaximumTimeout.setText(Const.NVL(jobEntry.getMaximumTimeout(), "")); wCheckCycleTime.setText(Const.NVL(jobEntry.getCheckCycleTime(), "")); wSuccesOnTimeout.setSelection(jobEntry.isSuccessOnTimeout()); wFileSizeCheck.setSelection(jobEntry.isFileSizeCheck()); wAddFilenameResult.setSelection(jobEntry.isAddFilenameToResult()); }
private void suggestBranchName(String ref) { if (nameText.getText().length() == 0 || nameIsSuggestion) { String branchNameSuggestion = getBranchNameSuggestionFromProvider(); if (branchNameSuggestion == null) branchNameSuggestion = getProposedTargetName(ref); if (branchNameSuggestion != null) { nameText.setText(branchNameSuggestion); nameText.selectAll(); nameIsSuggestion = true; } } }
public void setResourceProvider(ResourceProvider rp) { this.resourceProvider = rp; name = findPotentialName(rp); if (text != null && !text.isDisposed()) { text.setText(name); text.setFocus(); text.selectAll(); } setPageComplete(!name.isEmpty()); }
/* * (non-Javadoc) * * @see org.eclipse.jface.dialogs.Dialog#createButtonsForButtonBar(org.eclipse.swt.widgets.Composite) */ protected void createButtonsForButtonBar(Composite parent) { // create OK and Cancel buttons by default okButton = createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, true); createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false); // do this here because setting the text will set enablement on the ok // button text.setFocus(); if (value != null) { text.setText(value); text.selectAll(); } initialize(); }
/** * Sets the contents of the receiver's text field to the given string. * * <p>Note: The text field in a <code>Combo</code> is typically only capable of displaying a * single line of text. Thus, setting the text to a string containing line breaks or other special * characters will probably cause it to display incorrectly. * * @param string the new text * @exception IllegalArgumentException * <ul> * <li>ERROR_NULL_ARGUMENT - if the string is null * </ul> * * @exception SWTException * <ul> * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver * </ul> */ public void setText(String string) { checkWidget(); if (string == null) SWT.error(SWT.ERROR_NULL_ARGUMENT); int index = list.indexOf(string); if (index == -1) { list.deselectAll(); text.setText(string); return; } text.setText(string); text.selectAll(); list.setSelection(index); list.showSelection(); }
/** * Selects the item at the given zero-relative index in the receiver's list. If the item at the * index was already selected, it remains selected. Indices that are out of range are ignored. * * @param index the index of the item to select * @exception SWTException * <ul> * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver * </ul> */ public void select(int index) { checkWidget(); if (index == -1) { list.deselectAll(); text.setText(""); // $NON-NLS-1$ return; } if (0 <= index && index < list.getItemCount()) { if (index != getSelectionIndex()) { text.setText(list.getItem(index)); text.selectAll(); list.select(index); list.showSelection(); } } }
@Override public void createControl(Composite parent) { Composite superComposite = new Composite(parent, SWT.NONE); setControl(superComposite); initializeDialogUnits(superComposite); superComposite.setLayout(new GridLayout()); Composite composite = new Composite(superComposite, SWT.NONE); composite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); GridLayout layout = new GridLayout(); layout.numColumns = 2; layout.marginHeight = 0; layout.marginWidth = 0; composite.setLayout(layout); RowLayouter layouter = new RowLayouter(2); Label label = new Label(composite, SWT.NONE); label.setText(getLabelText()); Text text = createTextInputField(composite); text.selectAll(); GridData gd = new GridData(GridData.FILL_HORIZONTAL); gd.widthHint = convertWidthInCharsToPixels(25); text.setLayoutData(gd); layouter.perform(label, text, 1); Label separator = new Label(composite, SWT.NONE); GridData gridData = new GridData(SWT.FILL, SWT.FILL, false, false); gridData.heightHint = 2; separator.setLayoutData(gridData); int indent = convertWidthInCharsToPixels(2); addOptionalUpdateReferencesCheckbox(composite, layouter); addAdditionalOptions(composite, layouter); addOptionalUpdateTextualMatches(composite, layouter); // addOptionalUpdateQualifiedNameComponent(composite, layouter, indent); addOptionalLeaveDelegateCheckbox(composite, layouter); // addOptionalDeprecateDelegateCheckbox(composite, layouter, indent); updateForcePreview(); Dialog.applyDialogFont(superComposite); PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(), fHelpContextID); }
/** Copy information from the meta-data input to the dialog fields. */ public void getData() { if (jobEntry.getName() != null) wName.setText(jobEntry.getName()); if (jobEntry.connections != null) { for (int i = 0; i < jobEntry.connections.length; i++) { TableItem ti = wFields.table.getItem(i); if (jobEntry.connections[i] != null) { ti.setText(1, jobEntry.connections[i].getName()); ti.setText(2, "" + Const.toInt(jobEntry.waitfors[i], 0)); ti.setText(3, JobEntryCheckDbConnections.getWaitTimeDesc(jobEntry.waittimes[i])); } } wFields.setRowNums(); wFields.optWidth(true); } wName.selectAll(); wName.setFocus(); }
/** Copy information from the meta-data input to the dialog fields. */ public void getData() { wStepname.setText(stepname); for (int i = 0; i < input.getFieldName().length; i++) { TableItem item = wFields.table.getItem(i); String name = input.getFieldName()[i]; String type = input.getFieldValue()[i]; if (name != null) item.setText(1, name); if (type != null) item.setText(2, type); } wFields.setRowNums(); wFields.optWidth(true); wStepname.selectAll(); wStepname.setFocus(); }
@Test public void testSelection() { // test select all text.setText("abc"); text.selectAll(); assertEquals(new Point(0, 3), text.getSelection()); assertEquals("abc", text.getSelectionText()); // test clearSelection text.setText("abc"); text.clearSelection(); assertEquals(new Point(0, 0), text.getSelection()); assertEquals("", text.getSelectionText()); // test setSelection text.setText("abc"); text.setSelection(1); assertEquals(new Point(1, 1), text.getSelection()); assertEquals(0, text.getSelectionCount()); assertEquals("", text.getSelectionText()); text.setSelection(1000); assertEquals(new Point(3, 3), text.getSelection()); assertEquals(0, text.getSelectionCount()); assertEquals("", text.getSelectionText()); Point saveSelection = text.getSelection(); text.setSelection(-1); assertEquals(saveSelection, text.getSelection()); assertEquals(0, text.getSelectionCount()); assertEquals("", text.getSelectionText()); text.setText("abcdefg"); text.setSelection(new Point(5, 2)); assertEquals(new Point(2, 5), text.getSelection()); // test selection when changing text text.setText("abcefg"); text.setSelection(1, 2); text.setText("gfecba"); assertEquals(new Point(0, 0), text.getSelection()); // ... even setting the same text again will clear the selection text.setText("abcefg"); text.setSelection(1, 2); text.setText(text.getText()); assertEquals(new Point(0, 0), text.getSelection()); }
private void preload() { ICredentials authCredentials = null; try { if (gCredProvider != null) authCredentials = gCredProvider.getAuthCredentials(gLink, null); } catch (CredentialsException e) { Activator.getDefault().getLog().log(e.getStatus()); } if (authCredentials != null) { String username = authCredentials.getUsername(); String password = authCredentials.getPassword(); if (StringUtils.isSet(username)) { usernameField.setText(username); usernameField.selectAll(); } if (StringUtils.isSet(password)) passwordField.setText(password); } }
private boolean saveData() { if (chkUseCodeFinder.getSelection()) { if (pnlCodeFinder.getRules() == null) { return false; } else { params.setCodeFinderData(pnlCodeFinder.getRules()); } } String tmp = checkExceptionsSyntax(); if (tmp != null) { edExceptions.selectAll(); edExceptions.setFocus(); Dialogs.showError(shell, tmp, null); return false; } params.setUseCodeFinder(chkUseCodeFinder.getSelection()); params.setExceptions(edExceptions.getText()); params.setExtractStandalone(chkExtractStandalone.getSelection()); params.setExtractAllPairs(rdExtractAllPairs.getSelection()); return true; }
void handleFocus(int type) { if (isDisposed()) return; switch (type) { case SWT.FocusIn: { if (hasFocus) return; if (getEditable()) text.selectAll(); hasFocus = true; Shell shell = getShell(); shell.removeListener(SWT.Deactivate, listener); shell.addListener(SWT.Deactivate, listener); Display display = getDisplay(); display.removeFilter(SWT.FocusIn, filter); display.addFilter(SWT.FocusIn, filter); Event e = new Event(); notifyListeners(SWT.FocusIn, e); break; } case SWT.FocusOut: { if (!hasFocus) return; Control focusControl = getDisplay().getFocusControl(); if (focusControl == arrow || focusControl == list || focusControl == icon || focusControl == text) return; hasFocus = false; Shell shell = getShell(); shell.removeListener(SWT.Deactivate, listener); Display display = getDisplay(); display.removeFilter(SWT.FocusIn, filter); Event e = new Event(); notifyListeners(SWT.FocusOut, e); dropDown(false); break; } } }
/** Copy information from the meta-data input to the dialog fields. */ public void getData() { if (jobEntry.getName() != null) wName.setText(jobEntry.getName()); wName.selectAll(); if (jobEntry.source_filefolder != null) { for (int i = 0; i < jobEntry.source_filefolder.length; i++) { TableItem ti = wFields.table.getItem(i); if (jobEntry.source_filefolder[i] != null) ti.setText(1, jobEntry.source_filefolder[i]); if (jobEntry.wildcard[i] != null) ti.setText(3, jobEntry.wildcard[i]); } wFields.setRowNums(); wFields.optWidth(true); } wPrevious.setSelection(jobEntry.arg_from_previous); wIncludeSubfolders.setSelection(jobEntry.include_subfolders); if (jobEntry.getNrErrorsLessThan() != null) wNrErrorsLessThan.setText(jobEntry.getNrErrorsLessThan()); else wNrErrorsLessThan.setText("10"); if (jobEntry.getSuccessCondition() != null) { if (jobEntry.getSuccessCondition().equals(jobEntry.SUCCESS_IF_AT_LEAST_X_FILES_WELL_FORMED)) wSuccessCondition.select(1); else if (jobEntry.getSuccessCondition().equals(jobEntry.SUCCESS_IF_BAD_FORMED_FILES_LESS)) wSuccessCondition.select(2); else wSuccessCondition.select(0); } else wSuccessCondition.select(0); if (jobEntry.getResultFilenames() != null) { if (jobEntry.getResultFilenames().equals(jobEntry.ADD_WELL_FORMED_FILES_ONLY)) wAddFilenameToResult.select(1); else if (jobEntry.getResultFilenames().equals(jobEntry.ADD_BAD_FORMED_FILES_ONLY)) wAddFilenameToResult.select(2); else wAddFilenameToResult.select(0); } else wAddFilenameToResult.select(0); }
void textEvent(Event event) { switch (event.type) { case SWT.FocusIn: { handleFocus(SWT.FocusIn); break; } case SWT.KeyDown: { if (event.character == SWT.CR) { dropDown(false); Event e = new Event(); e.time = event.time; e.stateMask = event.stateMask; notifyListeners(SWT.DefaultSelection, e); } // At this point the widget may have been disposed. // If so, do not continue. if (isDisposed()) break; if (event.keyCode == SWT.ARROW_UP || event.keyCode == SWT.ARROW_DOWN) { event.doit = false; if ((event.stateMask & SWT.ALT) != 0) { boolean dropped = isDropped(); text.selectAll(); if (!dropped) setFocus(); dropDown(!dropped); break; } int oldIndex = getSelectionIndex(); if (event.keyCode == SWT.ARROW_UP && popup.isVisible()) { select(Math.max(oldIndex - 1, 0)); } else if (popup.isVisible()) { select(Math.min(oldIndex + 1, getItemCount() - 1)); } if (oldIndex != getSelectionIndex()) { Event e = new Event(); e.time = event.time; e.stateMask = event.stateMask; notifyListeners(SWT.Selection, e); } // At this point the widget may have been disposed. // If so, do not continue. if (isDisposed()) break; } // Further work : Need to add support for incremental search in // pop up list as characters typed in text widget Event e = new Event(); e.time = event.time; e.character = event.character; e.keyCode = event.keyCode; e.stateMask = event.stateMask; notifyListeners(SWT.KeyDown, e); break; } case SWT.KeyUp: { Event e = new Event(); e.time = event.time; e.character = event.character; e.keyCode = event.keyCode; e.stateMask = event.stateMask; notifyListeners(SWT.KeyUp, e); break; } case SWT.Modify: { list.deselectAll(); Event e = new Event(); e.time = event.time; notifyListeners(SWT.Modify, e); break; } case SWT.MouseDown: { if (event.button != 1) return; if (text.getEditable()) return; boolean dropped = isDropped(); text.selectAll(); if (!dropped) setFocus(); dropDown(!dropped); break; } case SWT.MouseUp: { if (event.button != 1) return; if (text.getEditable()) return; text.selectAll(); break; } case SWT.Traverse: { switch (event.detail) { case SWT.TRAVERSE_RETURN: case SWT.TRAVERSE_ARROW_PREVIOUS: case SWT.TRAVERSE_ARROW_NEXT: // The enter causes default selection and // the arrow keys are used to manipulate the list contents so // do not use them for traversal. event.doit = false; break; } Event e = new Event(); e.time = event.time; e.detail = event.detail; e.doit = event.doit; e.character = event.character; e.keyCode = event.keyCode; notifyListeners(SWT.Traverse, e); event.doit = e.doit; event.detail = e.detail; break; } } }
protected Control createTop(final Composite parent) { Composite c0 = new Composite(parent, SWT.NONE); c0.setLayout(new FormLayout()); Label wlId = new Label(c0, SWT.RIGHT); wlId.setText(Messages.getString("PhysicalTableDialog.USER_NAME_ID")); // $NON-NLS-1$ wId = new Text(c0, SWT.SINGLE | SWT.LEFT | SWT.BORDER); FormData fdlId = new FormData(); fdlId.left = new FormAttachment(0, 0); fdlId.top = new FormAttachment(wId, 0, SWT.CENTER); wlId.setLayoutData(fdlId); Label conLabel = new Label(c0, SWT.RIGHT); conLabel.setText("Connection:"); conField = new Combo(c0, SWT.BORDER | SWT.READ_ONLY | SWT.V_SCROLL | SWT.H_SCROLL); comboViewer = new ComboViewer(conField); comboViewer.setContentProvider( new IStructuredContentProvider() { public Object[] getElements(final Object inputElement) { List ul = (List) inputElement; return ul.toArray(); } public void dispose() { if (logger.isDebugEnabled()) { logger.debug("Disposing ..."); } } public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { if (logger.isDebugEnabled()) { logger.debug("Input changed: old=" + oldInput + ", new=" + newInput); } } }); List<Object> list2 = new ArrayList<Object>(); list2.add(dummyConInstance); list2.addAll(schemaMeta.getDatabases().getList()); comboViewer.setInput(list2); comboViewer.setLabelProvider( new LabelProvider() { public Image getImage(Object element) { return null; } public String getText(Object element) { DatabaseMeta meta = (DatabaseMeta) element; if (DUMMY_CON_NAME.equals(meta.getName())) { return ""; } else { return ((DatabaseMeta) element).getName(); } } }); BusinessModel busModel = (BusinessModel) conceptUtil; if (null != busModel.getConnection()) { comboViewer.setSelection(new StructuredSelection(busModel.getConnection())); } else { comboViewer.setSelection(new StructuredSelection(dummyConInstance)); } FormData fdId = new FormData(); fdId.left = new FormAttachment(wlId, 10); fdId.top = new FormAttachment(0, 0); fdId.right = new FormAttachment(conLabel, -10); wId.setLayoutData(fdId); FormData fdConLabel = new FormData(); fdConLabel.left = new FormAttachment(50, 0); fdConLabel.top = new FormAttachment(conField, 0, SWT.CENTER); conLabel.setLayoutData(fdConLabel); FormData fdConField = new FormData(); fdConField.left = new FormAttachment(conLabel, 10); fdConField.top = new FormAttachment(0, 0); fdConField.right = new FormAttachment(100, 0); conField.setLayoutData(fdConField); if (conceptUtil.getId() != null) { wId.setText(conceptUtil.getId()); wId.selectAll(); } return c0; }
public void getData() { wString.setText(string); wString.selectAll(); }
protected void selectAll() { if (filterText != null) { filterText.selectAll(); } }
/* * @see org.rssowl.ui.dialogs.properties.IEntityPropertyPage#setFocus() */ public void setFocus() { if (fNameInput != null) { fNameInput.setFocus(); fNameInput.selectAll(); } }
private void createLocationGroup(final Composite parent) { final Group g = createGroup(parent, UIText.RepositorySelectionPage_groupLocation); g.setLayout(new GridLayout(3, false)); newLabel(g, UIText.RepositorySelectionPage_promptURI + ":"); // $NON-NLS-1$ uriText = new Text(g, SWT.BORDER); if (presetUri != null) { uriText.setText(presetUri); uriText.selectAll(); } uriText.setLayoutData(createFieldGridData()); uriText.addModifyListener( new ModifyListener() { public void modifyText(final ModifyEvent e) { updateFields(uriText.getText()); } }); uriProposalHandler = UIUtils.addPreviousValuesContentProposalToText(uriText, USED_URIS_PREF); Button browseButton = new Button(g, SWT.NULL); browseButton.setText(UIText.RepositorySelectionPage_BrowseLocalFile); browseButton.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent evt) { DirectoryDialog dialog = new DirectoryDialog(getShell()); // if a file was selected before, let's try to open // the directory dialog on the same directory if (!uriText.getText().equals(EMPTY_STRING)) try { // first we try if this is a simple file name File testFile = new File(uriText.getText()); if (testFile.exists()) dialog.setFilterPath(testFile.getPath()); else { // this could still be a file URIish URIish testUri = new URIish(uriText.getText()); if (testUri.getScheme().equals(Protocol.FILE.defaultScheme)) { testFile = new File(uri.getPath()); if (testFile.exists()) dialog.setFilterPath(testFile.getPath()); } } } catch (IllegalArgumentException e) { // ignore here, we just' don't set the directory in the // browser } catch (URISyntaxException e) { // ignore here, we just' don't set the directory in the // browser } // if nothing else, we start the search from the default folder for repositories if (EMPTY_STRING.equals(dialog.getFilterPath())) dialog.setFilterPath(UIUtils.getDefaultRepositoryDir()); String result = dialog.open(); if (result != null) uriText.setText("file:///" + result); // $NON-NLS-1$ } }); newLabel(g, UIText.RepositorySelectionPage_promptHost + ":"); // $NON-NLS-1$ hostText = new Text(g, SWT.BORDER); GridDataFactory.fillDefaults().span(2, 1).applyTo(hostText); hostText.addModifyListener( new ModifyListener() { public void modifyText(final ModifyEvent e) { setURI(uri.setHost(nullString(hostText.getText()))); } }); newLabel(g, UIText.RepositorySelectionPage_promptPath + ":"); // $NON-NLS-1$ pathText = new Text(g, SWT.BORDER); GridDataFactory.fillDefaults().span(2, 1).applyTo(pathText); pathText.addModifyListener( new ModifyListener() { public void modifyText(final ModifyEvent e) { setURI(uri.setPath(nullString(pathText.getText()))); } }); }
private void create(Shell parent, final SymitarFile file) { FormLayout layout = new FormLayout(); layout.marginTop = 5; layout.marginBottom = 5; layout.marginLeft = 5; layout.marginRight = 5; layout.spacing = 5; shell = new Shell(parent, SWT.APPLICATION_MODAL | SWT.DIALOG_TRIM); shell.setText("Line Printer Options"); shell.setLayout(layout); Label queueLabel = new Label(shell, SWT.NONE); queueLabel.setText("LPT Queue"); Label overrideLabel = new Label(shell, SWT.NONE); overrideLabel.setText("Forms Override"); Label lengthLabel = new Label(shell, SWT.NONE); lengthLabel.setText("Form Length"); Label startLabel = new Label(shell, SWT.NONE); startLabel.setText("Start Page"); Label endLabel = new Label(shell, SWT.NONE); endLabel.setText("End Page"); Label copiesLabel = new Label(shell, SWT.NONE); copiesLabel.setText("Copies"); Label landscapeLabel = new Label(shell, SWT.NONE); landscapeLabel.setText("Landscape"); Label duplexLabel = new Label(shell, SWT.NONE); duplexLabel.setText("Duplex"); Label priorityLabel = new Label(shell, SWT.NONE); priorityLabel.setText("Queue Priority"); // Select All when tabbing through FocusListener selectAllFocuser = new FocusListener() { public void focusGained(FocusEvent e) { if (e.widget instanceof Text) ((Text) e.widget).selectAll(); } public void focusLost(FocusEvent e) {} }; MouseListener mouseFocuser = new MouseAdapter() { public void mouseDown(MouseEvent e) { if (e.widget instanceof Text) ((Text) e.widget).selectAll(); } }; final Text queueText = new Text(shell, SWT.BORDER); queueText.setText("0"); queueText.selectAll(); queueText.addFocusListener(selectAllFocuser); queueText.addMouseListener(mouseFocuser); final Combo overrideCombo = new Combo(shell, SWT.READ_ONLY); overrideCombo.add("No"); overrideCombo.add("Yes"); overrideCombo.select(0); final Text lengthText = new Text(shell, SWT.BORDER); lengthText.setText("0"); lengthText.addFocusListener(selectAllFocuser); lengthText.addMouseListener(mouseFocuser); final Text startText = new Text(shell, SWT.BORDER); startText.setText("0"); startText.addFocusListener(selectAllFocuser); startText.addMouseListener(mouseFocuser); final Text endText = new Text(shell, SWT.BORDER); endText.setText("0"); endText.addFocusListener(selectAllFocuser); endText.addMouseListener(mouseFocuser); final Text copiesText = new Text(shell, SWT.BORDER); copiesText.setText("1"); copiesText.addFocusListener(selectAllFocuser); copiesText.addMouseListener(mouseFocuser); final Combo landscapeCombo = new Combo(shell, SWT.READ_ONLY); landscapeCombo.add("No"); landscapeCombo.add("Yes"); landscapeCombo.select(0); final Combo duplexCombo = new Combo(shell, SWT.READ_ONLY); duplexCombo.add("No"); duplexCombo.add("Yes"); duplexCombo.select(0); final Text priorityText = new Text(shell, SWT.BORDER); priorityText.setText("4"); priorityText.addFocusListener(selectAllFocuser); priorityText.addMouseListener(mouseFocuser); Button okButton = new Button(shell, SWT.PUSH); okButton.setText("Print"); Button cancelButton = new Button(shell, SWT.PUSH); cancelButton.setText("Cancel"); shell.setDefaultButton(okButton); queueText.setFocus(); FormData data = new FormData(); data.left = new FormAttachment(0); data.top = new FormAttachment(0); data.width = 120; queueLabel.setLayoutData(data); data = new FormData(); data.left = new FormAttachment(overrideLabel); data.top = new FormAttachment(0); data.right = new FormAttachment(100); data.width = 80; queueText.setLayoutData(data); data = new FormData(); data.left = new FormAttachment(0); data.top = new FormAttachment(queueText); data.width = 120; overrideLabel.setLayoutData(data); data = new FormData(); data.left = new FormAttachment(overrideLabel); data.top = new FormAttachment(queueText); data.right = new FormAttachment(100); data.width = 80; overrideCombo.setLayoutData(data); data = new FormData(); data.left = new FormAttachment(0); data.top = new FormAttachment(overrideCombo); data.width = 120; lengthLabel.setLayoutData(data); data = new FormData(); data.left = new FormAttachment(lengthLabel); data.top = new FormAttachment(overrideCombo); data.right = new FormAttachment(100); data.width = 80; lengthText.setLayoutData(data); data = new FormData(); data.left = new FormAttachment(0); data.top = new FormAttachment(lengthText); data.width = 120; startLabel.setLayoutData(data); data = new FormData(); data.left = new FormAttachment(startLabel); data.top = new FormAttachment(lengthText); data.right = new FormAttachment(100); data.width = 80; startText.setLayoutData(data); data = new FormData(); data.left = new FormAttachment(0); data.top = new FormAttachment(startText); data.width = 120; endLabel.setLayoutData(data); data = new FormData(); data.left = new FormAttachment(endLabel); data.top = new FormAttachment(startText); data.right = new FormAttachment(100); data.width = 80; endText.setLayoutData(data); data = new FormData(); data.left = new FormAttachment(0); data.top = new FormAttachment(endText); data.width = 120; copiesLabel.setLayoutData(data); data = new FormData(); data.left = new FormAttachment(copiesLabel); data.top = new FormAttachment(endText); data.right = new FormAttachment(100); data.width = 80; copiesText.setLayoutData(data); data = new FormData(); data.left = new FormAttachment(0); data.top = new FormAttachment(copiesText); data.width = 120; landscapeLabel.setLayoutData(data); data = new FormData(); data.left = new FormAttachment(landscapeLabel); data.top = new FormAttachment(copiesText); data.right = new FormAttachment(100); data.width = 80; landscapeCombo.setLayoutData(data); data = new FormData(); data.left = new FormAttachment(0); data.top = new FormAttachment(landscapeCombo); data.width = 120; duplexLabel.setLayoutData(data); data = new FormData(); data.left = new FormAttachment(duplexLabel); data.top = new FormAttachment(landscapeCombo); data.right = new FormAttachment(100); data.width = 80; duplexCombo.setLayoutData(data); data = new FormData(); data.left = new FormAttachment(0); data.top = new FormAttachment(duplexCombo); data.width = 120; priorityLabel.setLayoutData(data); data = new FormData(); data.left = new FormAttachment(priorityLabel); data.top = new FormAttachment(duplexCombo); data.right = new FormAttachment(100); data.width = 80; priorityText.setLayoutData(data); data = new FormData(); data.top = new FormAttachment(priorityText); data.right = new FormAttachment(100); cancelButton.setLayoutData(data); cancelButton.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { result = false; shell.dispose(); } }); data = new FormData(); data.right = new FormAttachment(cancelButton); data.top = new FormAttachment(priorityText); okButton.setLayoutData(data); okButton.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { result = true; SessionError result = SessionError.INPUT_ERROR; try { result = RepDevMain.SYMITAR_SESSIONS .get(file.getSym()) .printFileLPT( file, Integer.parseInt(queueText.getText()), false, 0, Integer.parseInt(startText.getText()), Integer.parseInt(endText.getText()), Integer.parseInt(copiesText.getText()), landscapeCombo.getSelectionIndex() == 1, duplexCombo.getSelectionIndex() == 1, Integer.parseInt(priorityText.getText())); } catch (NumberFormatException e1) { } if (result != SessionError.NONE) { MessageBox dialog = new MessageBox(shell, SWT.OK | SWT.ICON_ERROR); dialog.setText("Print Error"); dialog.setMessage(result.toString()); dialog.open(); } shell.dispose(); } }); shell.pack(); shell.open(); }