@Override protected void doUpdatePreview() { fCleanUpPreview.setWorkingValues(fValues); fCleanUpPreview.update(); }
@Override public void widgetSelected(SelectionEvent e) { fPreview.showInvisibleCharacters(showInvisibleButton.getSelection()); fDialogSettings.put(SHOW_INVISIBLE_PREFERENCE_KEY, showInvisibleButton.getSelection()); } });
public void update() { if (fUpdateScheduled) return; fUpdateScheduled= true; Display.getDefault().asyncExec(() -> { doUpdate(); fUpdateScheduled= false; }); }
@Override public void valuesModified() { if (fPreview != null) { HashMap<String, String> workingValuesForPreview= new HashMap<>(fWorkingValues); workingValuesForPreview.put(DefaultCodeFormatterConstants.FORMATTER_LINE_SPLIT, fDialogSettings.get(PREVIEW_LINE_WIDTH_PREFERENCE_KEY)); fPreview.setWorkingValues(workingValuesForPreview); fPreviewRawButton.setSelection(false); fPreview.setEditorMode(false); fPreview.update(); } }
@Override public void update(Observable o, Object arg) { if (o instanceof ProfileManager) { final int value= ((Integer) arg).intValue(); switch (value) { case ProfileManager.PROFILE_CREATED_EVENT: case ProfileManager.PROFILE_DELETED_EVENT: case ProfileManager.SELECTION_CHANGED_EVENT: case ProfileManager.SETTINGS_CHANGED_EVENT: fJavaPreview.setWorkingValues(((ProfileManager) o).getSelected().getSettings()); fJavaPreview.update(); } } else if (o instanceof CustomCodeFormatterBlock) { final String value = (String) arg; fJavaPreview.setFormatterId(value); fJavaPreview.update(); } }
final int lineWidth= getPositiveIntValue(value, 0); fMarginPainter.setMarginRulerColumn(lineWidth); final int tabSize= getPositiveIntValue((String) fWorkingValues.get(DefaultCodeFormatterConstants.FORMATTER_TAB_SIZE), 0); if (tabSize != fTabSize) fSourceViewer.getTextWidget().setTabs(tabSize); fTabSize= tabSize; final int top0= widget.getTopPixel(); final int totalPixels0= getHeightOfAllLines(widget); final int topPixelRange0= totalPixels0 > height ? totalPixels0 - height : 0; doFormatPreview(); fSourceViewer.setSelection(null); final int totalPixels1= getHeightOfAllLines(widget); final int topPixelRange1= totalPixels1 > height ? totalPixels1 - height : 0;
protected Composite doCreatePreviewPane(Composite composite, int numColumns) { createLabel(numColumns - 1, composite, FormatterMessages.ModifyDialogTabPage_preview_label_text); fShowInvisibleButton= new Button(composite, SWT.CHECK); fShowInvisibleButton.setText(FormatterMessages.FormatterTabPage_ShowInvisibleCharacters_label); fShowInvisibleButton.setLayoutData(new GridData(SWT.RIGHT, SWT.TOP, true, false)); fShowInvisibleButton.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { fPreview.showInvisibleCharacters(fShowInvisibleButton.getSelection()); fDialogSettings.put(SHOW_INVISIBLE_PREFERENCE_KEY, fShowInvisibleButton.getSelection()); } }); fShowInvisibleButton.setSelection(isShowInvisible()); fPreview= doCreateJavaPreview(composite); fDefaultFocusManager.add(fPreview.getControl()); fPreview.showInvisibleCharacters(fShowInvisibleButton.getSelection()); final GridData gd= createGridData(numColumns, GridData.FILL_BOTH, 0); gd.widthHint= 0; gd.heightHint=0; fPreview.getControl().setLayoutData(gd); return composite; }
@Override protected void initializePage() { fCleanUpPreview.update(); }
@Override protected void configurePreview(Composite composite, int numColumns, ProfileManager profileManager) { fCustomCodeFormatterBlock.createContents(composite, numColumns); createLabel(composite, FormatterMessages.CodingStyleConfigurationBlock_preview_label_text, numColumns); JavaPreview result= new JavaPreview(profileManager.getSelected().getSettings(), composite); result.setFormatterId(fCustomCodeFormatterBlock.getFormatterId()); result.setPreviewText(PREVIEW, CodeFormatter.K_COMPILATION_UNIT); fJavaPreview= result; final GridData gd = new GridData(GridData.FILL_VERTICAL | GridData.HORIZONTAL_ALIGN_FILL); gd.horizontalSpan = numColumns; gd.verticalSpan= 7; gd.widthHint = 0; gd.heightHint = 0; fJavaPreview.getControl().setLayoutData(gd); PreviewController previewController = new PreviewController(profileManager); fCustomCodeFormatterBlock.addObserver(previewController); }
/** * Create the right side of the modify dialog. By default, the preview is displayed there. * Subclasses can override this method in order to customize the right-hand side of the * dialog. * @param composite Composite to create in * @param numColumns Number of columns to use * @return Created composite */ protected Composite doCreatePreviewPane(Composite composite, int numColumns) { createLabel(numColumns, composite, FormatterMessages.ModifyDialogTabPage_preview_label_text); final JavaPreview preview= doCreateJavaPreview(composite); fDefaultFocusManager.add(preview.getControl()); final GridData gd= createGridData(numColumns, GridData.FILL_BOTH, 0); gd.widthHint= 0; gd.heightHint=0; preview.getControl().setLayoutData(gd); return composite; }
protected Composite createPreviewPane(Composite parent) { final Composite previewPane= new Composite(parent, SWT.NONE); createGridLayout(previewPane, 1, true); previewPane.setFont(parent.getFont()); createLabel(1, previewPane, FormatterMessages.ModifyDialogTabPage_preview_label_text, 0); fPreview= new JavaPreview(fWorkingValues, previewPane); fPreview.getControl().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); return previewPane; }
public void update() { if (fWorkingValues == null) { fPreviewDocument.set(""); //$NON-NLS-1$ return; } // update the print margin final String value= fWorkingValues.get(DefaultCodeFormatterConstants.FORMATTER_LINE_SPLIT); final int lineWidth= getPositiveIntValue(value, 0); fMarginPainter.setMarginRulerColumn(lineWidth); // update the tab size final int tabSize= getPositiveIntValue(fWorkingValues.get(DefaultCodeFormatterConstants.FORMATTER_TAB_SIZE), 0); if (tabSize != fTabSize) fSourceViewer.getTextWidget().setTabs(tabSize); fTabSize= tabSize; final StyledText widget= (StyledText)fSourceViewer.getControl(); final int height= widget.getClientArea().height; final int top0= widget.getTopPixel(); final int totalPixels0= getHeightOfAllLines(widget); final int topPixelRange0= totalPixels0 > height ? totalPixels0 - height : 0; widget.setRedraw(false); doFormatPreview(); fSourceViewer.setSelection(null); final int totalPixels1= getHeightOfAllLines(widget); final int topPixelRange1= totalPixels1 > height ? totalPixels1 - height : 0; final int top1= topPixelRange0 > 0 ? (int)(topPixelRange1 * top0 / (double)topPixelRange0) : 0; widget.setTopPixel(top1); widget.setRedraw(true); }
@Override protected Composite doCreatePreviewPane(Composite composite, int numColumns) { createLabel(numColumns - 1, composite, FormatterMessages.ModifyDialogTabPage_preview_label_text); fShowInvisibleButton= new Button(composite, SWT.CHECK); fShowInvisibleButton.setText(FormatterMessages.FormatterTabPage_ShowInvisibleCharacters_label); fShowInvisibleButton.setLayoutData(new GridData(SWT.RIGHT, SWT.TOP, true, false)); fShowInvisibleButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { fPreview.showInvisibleCharacters(fShowInvisibleButton.getSelection()); fDialogSettings.put(SHOW_INVISIBLE_PREFERENCE_KEY, fShowInvisibleButton.getSelection()); doUpdatePreview(); } }); fShowInvisibleButton.setSelection(isShowInvisible()); fPreview= doCreateJavaPreview(composite); fDefaultFocusManager.add(fPreview.getControl()); fPreview.showInvisibleCharacters(fShowInvisibleButton.getSelection()); final GridData gd= createGridData(numColumns, GridData.FILL_BOTH, 0); gd.widthHint= 0; gd.heightHint=0; fPreview.getControl().setLayoutData(gd); return composite; }
@Override protected void initializePage() { fCleanUpPreview.update(); }
/** * Create the right side of the modify dialog. By default, the preview is displayed there. * Subclasses can override this method in order to customize the right-hand side of the * dialog. * @param composite Composite to create in * @param numColumns Number of columns to use * @return Created composite */ protected Composite doCreatePreviewPane(Composite composite, int numColumns) { createLabel(numColumns, composite, FormatterMessages.ModifyDialogTabPage_preview_label_text); final JavaPreview preview= doCreateJavaPreview(composite); fDefaultFocusManager.add(preview.getControl()); final GridData gd= createGridData(numColumns, GridData.FILL_BOTH, 0); gd.widthHint= 0; gd.heightHint=0; preview.getControl().setLayoutData(gd); return composite; }
final int lineWidth= getPositiveIntValue(value, 0); fMarginPainter.setMarginRulerColumn(lineWidth); ? getPositiveIntValue(fWorkingValues.get(DefaultCodeFormatterConstants.FORMATTER_INDENTATION_SIZE), 0) : getPositiveIntValue(fWorkingValues.get(DefaultCodeFormatterConstants.FORMATTER_TAB_SIZE), 0); if (tabSize != fTabSize) widget.setTabs(tabSize); final int top0= widget.getTopPixel(); final int totalPixels0= getHeightOfAllLines(widget); final int topPixelRange0= totalPixels0 > height ? totalPixels0 - height : 0; fPreviewDocument.set(fPreviewText); } else { doFormatPreview(); fSourceViewer.getUndoManager().reset(); final int totalPixels1= getHeightOfAllLines(widget); final int topPixelRange1= totalPixels1 > height ? totalPixels1 - height : 0;
@Override protected void doUpdatePreview() { fCleanUpPreview.setWorkingValues(fValues); fCleanUpPreview.update(); }
protected void initializePage() { fCleanUpPreview.update(); }
protected void doUpdatePreview() { boolean showInvisible= isShowInvisible(); fPreview.showInvisibleCharacters(showInvisible); fShowInvisibleButton.setSelection(showInvisible); }
/** * Create the right side of the modify dialog. By default, the preview is displayed there. * Subclasses can override this method in order to customize the right-hand side of the * dialog. * @param composite Composite to create in * @param numColumns Number of columns to use * @return Created composite */ protected Composite doCreatePreviewPane(Composite composite, int numColumns) { createLabel(numColumns, composite, FormatterMessages.ModifyDialogTabPage_preview_label_text); final JavaPreview preview= doCreateJavaPreview(composite); fDefaultFocusManager.add(preview.getControl()); final GridData gd= createGridData(numColumns, GridData.FILL_BOTH, 0); gd.widthHint= 0; gd.heightHint=0; preview.getControl().setLayoutData(gd); return composite; }