private void updateSignaturePreview() { try { int top = fSignaturePreview.getTextWidget().getTopPixel(); fSignaturePreviewDocument.set(getChangeMethodSignatureProcessor().getNewMethodSignature()); fSignaturePreview.getTextWidget().setTopPixel(top); } catch (JavaModelException e) { ExceptionHandler.handle( e, RefactoringMessages.ChangeSignatureRefactoring_modify_Parameters, RefactoringMessages.ChangeSignatureInputPage_exception); } }
private void createSignaturePreview(Composite composite) { Label previewLabel = new Label(composite, SWT.NONE); previewLabel.setText(RefactoringMessages.ChangeSignatureInputPage_method_Signature_Preview); // //XXX: use ViewForm to draw a flat border. Beware of common problems with wrapping // layouts // //inside GridLayout. GridData must be constrained to force wrapping. See bug 9866 et al. // ViewForm border= new ViewForm(composite, SWT.BORDER | SWT.FLAT); IPreferenceStore store = JavaPlugin.getDefault().getCombinedPreferenceStore(); fSignaturePreview = new JavaSourceViewer( composite, null, null, false, SWT.READ_ONLY | SWT.V_SCROLL | SWT.WRAP /*| SWT.BORDER*/, store); fSignaturePreview.configure( new JavaSourceViewerConfiguration( JavaPlugin.getDefault().getJavaTextTools().getColorManager(), store, null, null)); fSignaturePreview .getTextWidget() .setFont(JFaceResources.getFont(PreferenceConstants.EDITOR_TEXT_FONT)); fSignaturePreview.adaptBackgroundColor(composite); fSignaturePreview.setDocument(fSignaturePreviewDocument); fSignaturePreview.setEditable(false); // Layouting problems with wrapped text: see // https://bugs.eclipse.org/bugs/show_bug.cgi?id=9866 Control signaturePreviewControl = fSignaturePreview.getControl(); PixelConverter pixelConverter = new PixelConverter(signaturePreviewControl); GridData gdata = new GridData(GridData.FILL_BOTH); gdata.widthHint = pixelConverter.convertWidthInCharsToPixels(50); gdata.heightHint = pixelConverter.convertHeightInCharsToPixels(2); signaturePreviewControl.setLayoutData(gdata); // //XXX must force JavaSourceViewer text widget to wrap: // border.setContent(signaturePreviewControl); // GridData borderData= new GridData(GridData.FILL_BOTH); // borderData.widthHint= gdata.widthHint; // borderData.heightHint= gdata.heightHint; // border.setLayoutData(borderData); }