List of usage examples for org.eclipse.jface.resource JFaceResources getTextFont
public static Font getTextFont()
From source file:org.springframework.ide.eclipse.roo.ui.internal.wizard.NewRooProjectWizardPageTwo.java
License:Open Source License
public void createControl(Composite parent) { initializeDialogUnits(parent);//from w ww.ja va2 s. com final Composite composite = new Composite(parent, SWT.NULL); composite.setFont(parent.getFont()); composite.setLayout(initGridLayout(new GridLayout(1, false), true)); composite.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL)); text = new StyledText(composite, SWT.MULTI | SWT.BORDER | SWT.V_SCROLL | SWT.WRAP); GridData data = new GridData(GridData.FILL_BOTH); text.setLayoutData(data); text.setFont(JFaceResources.getTextFont()); text.setEditable(false); RooUiColors.applyShellBackground(text); RooUiColors.applyShellForeground(text); RooUiColors.applyShellFont(text); text.setText("Please click 'Finish' to create the new project using Roo." + StyledTextAppender.NL); setControl(composite); }
From source file:org.springsource.ide.eclipse.gradle.ui.cli.editor.TasksViewer.java
License:Open Source License
@SuppressWarnings("unchecked") public TasksViewer(Composite parent, GradleProjectIndex tasksIndex, boolean consoleMode) { super();// www .j a v a 2 s. c o m this.tasksIndex = tasksIndex; DefaultMarkerAnnotationAccess markerAccess = new DefaultMarkerAnnotationAccess(); OverviewRuler overviewRuler = consoleMode ? null : new OverviewRuler(markerAccess, 12, colorsCache); int style = SWT.NONE; if (!consoleMode) { style = SWT.V_SCROLL | SWT.H_SCROLL | SWT.MULTI | SWT.BORDER | SWT.FULL_SELECTION; } viewer = new SourceViewer(parent, null, overviewRuler, true, style); IPreferenceStore preferences = EditorsUI.getPreferenceStore(); viewer.configure(new TasksViewerConfiguration(tasksIndex, preferences)); decorationSupport = new SourceViewerDecorationSupport(viewer, overviewRuler, markerAccess, colorsCache); for (AnnotationPreference preference : (List<AnnotationPreference>) new MarkerAnnotationPreferences() .getAnnotationPreferences()) { decorationSupport.setAnnotationPreference(preference); } decorationSupport.install(preferences); Font font = null; if (preferences != null) { // Backward compatibility if (preferences.contains(JFaceResources.TEXT_FONT) && !preferences.isDefault(JFaceResources.TEXT_FONT)) { FontData data = PreferenceConverter.getFontData(preferences, JFaceResources.TEXT_FONT); if (data != null) { font = new Font(viewer.getTextWidget().getDisplay(), data); } } } if (font == null) font = JFaceResources.getTextFont(); if (!font.equals(viewer.getTextWidget().getFont())) { viewer.getTextWidget().setFont(font); } activateHandler(); }
From source file:org.thanlwinsoft.doccharconvert.eclipse.ConversionInputEditor.java
License:Open Source License
protected void showConversion(IDocument document) { // TODO move the conversion parsing / initialization into a separate thread if (charConverter == null) { // try to re-find the char converter IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); ConverterXmlParser xmlParser = ConverterUtil.parseConverters(window, this.getEditorSite().getShell()); if (this.getEditorInput() instanceof FileEditorInput) { String name = ((FileEditorInput) getEditorInput()).getFile().getLocation().removeFileExtension() .lastSegment();/*from w w w. j av a 2s .c o m*/ for (CharConverter cc : xmlParser.getChildConverters()) { if (ConverterUtil.cononicalizeName(cc.getName()).equals(name)) { setConversion(cc, ReverseConversion.get(xmlParser.getConverters(), cc)); break; } } } if (charConverter == null) return; } try { if (reinit || (charConverter.isInitialized() == false)) { charConverter.initialize(); } if (charConverter.isInitialized() == false) { Shell shell = this.getSite().getWorkbenchWindow().getShell(); MessageBox msgBox = new MessageBox(shell, SWT.ICON_WARNING); msgBox.setMessage(MessageUtil.getString("Converter_InitialisationFailed", charConverter.getName())); msgBox.open(); return; } String original = document.get(); String converted = charConverter.convert(original); ConversionResult cr = (ConversionResult) getSite().getPage().findView(Perspective.CONVERSION_RESULT); cr.setResult(charConverter.getNewStyle().getFontName(), fontSize, converted); cr = (ConversionResult) getSite().getPage().findView(Perspective.REVERSE_CONVERSION); String reversed = ""; if (reverseConverter != null) { if (reinit || (!reverseConverter.isInitialized())) reverseConverter.initialize(); if (reverseConverter.isInitialized()) reversed = reverseConverter.convert(converted); } cr.setResult(charConverter.getOldStyle().getFontName(), fontSize, reversed); ConversionResult unicode = (ConversionResult) getSite().getPage().findView(Perspective.DEBUG_UNICODE); StringBuilder hexCodes = new StringBuilder(); ConversionHelper.debugDump(original, hexCodes); hexCodes.append("\n"); ConversionHelper.debugDump(converted, hexCodes); hexCodes.append("\n"); ConversionHelper.debugDump(reversed, hexCodes); if (unicode != null) unicode.setResult(JFaceResources.getTextFont(), hexCodes.toString()); reinit = false; } catch (CharConverter.RecoverableException e) { Shell shell = this.getSite().getWorkbenchWindow().getShell(); MessageBox msgBox = new MessageBox(shell, SWT.ICON_WARNING); msgBox.setMessage(e.getLocalizedMessage()); msgBox.open(); } catch (CharConverter.FatalException e) { Shell shell = this.getSite().getWorkbenchWindow().getShell(); MessageBox msgBox = new MessageBox(shell, SWT.ICON_ERROR); msgBox.setMessage(e.getLocalizedMessage()); msgBox.open(); // prevent further conversions charConverter = null; } }
From source file:org.whole.lang.ui.PreferenceConstants.java
License:Open Source License
public static void initializeDefaultValues(IPreferenceStore store, ColorRegistry colorRegistry, FontRegistry fontRegistry) {/*from w ww . j a v a 2 s. c o m*/ PreferenceConverter.setDefault(store, FONT, JFaceResources.getTextFont().getFontData()); PreferenceConverter.setDefault(store, SELECTION_COLOR, GREEN_LIGHT_COLOR); PreferenceConverter.setDefault(store, MATCHING_SELECTION_COLOR, darker(GREEN_LIGHT_COLOR)); PreferenceConverter.setDefault(store, HOST_LANGUAGE_COLOR, new RGB(255, 255, 255)); PreferenceConverter.setDefault(store, TEMPLATE_LANGUAGE_COLOR, new RGB(238, 232, 213)); PreferenceConverter.setDefault(store, MODULES_COLOR, new RGB(115, 153, 0)); store.setDefault(MODULES_COLOR + BOLD, false); store.setDefault(MODULES_COLOR + ITALIC, false); PreferenceConverter.setDefault(store, DECLARATIONS_COLOR, new RGB(0, 0, 0)); store.setDefault(DECLARATIONS_COLOR + BOLD, true); store.setDefault(DECLARATIONS_COLOR + ITALIC, false); PreferenceConverter.setDefault(store, RELATIONS_COLOR, new RGB(230, 123, 0)); store.setDefault(RELATIONS_COLOR + BOLD, true); store.setDefault(RELATIONS_COLOR + ITALIC, false); PreferenceConverter.setDefault(store, KEYWORDS_COLOR, new RGB(127, 0, 85)); store.setDefault(KEYWORDS_COLOR + BOLD, true); store.setDefault(KEYWORDS_COLOR + ITALIC, false); PreferenceConverter.setDefault(store, IDENTIFIERS_COLOR, new RGB(0, 112, 191)); store.setDefault(IDENTIFIERS_COLOR + BOLD, false); store.setDefault(IDENTIFIERS_COLOR + ITALIC, false); PreferenceConverter.setDefault(store, LITERALS_COLOR, new RGB(128, 63, 0)); store.setDefault(LITERALS_COLOR + BOLD, false); store.setDefault(LITERALS_COLOR + ITALIC, false); PreferenceConverter.setDefault(store, ERRORS_COLOR, new RGB(255, 0, 0)); store.setDefault(ERRORS_COLOR + BOLD, false); store.setDefault(ERRORS_COLOR + ITALIC, false); PreferenceConverter.setDefault(store, CONTENT_COLOR, new RGB(0, 0, 0)); store.setDefault(CONTENT_COLOR + BOLD, false); store.setDefault(CONTENT_COLOR + ITALIC, false); PreferenceConverter.setDefault(store, CONTENT_DARK_COLOR, new RGB(7, 54, 66)); store.setDefault(CONTENT_DARK_COLOR + BOLD, false); store.setDefault(CONTENT_DARK_COLOR + ITALIC, false); PreferenceConverter.setDefault(store, CONTENT_LIGHT_COLOR, new RGB(88, 110, 117)); store.setDefault(CONTENT_LIGHT_COLOR + BOLD, false); store.setDefault(CONTENT_LIGHT_COLOR + ITALIC, false); PreferenceConverter.setDefault(store, CONTENT_LIGHTER_COLOR, new RGB(147, 161, 161)); store.setDefault(CONTENT_LIGHTER_COLOR + BOLD, false); store.setDefault(CONTENT_LIGHTER_COLOR + ITALIC, false); restoreRegistries(store, colorRegistry, fontRegistry); }
From source file:org.wso2.developerstudio.esb.form.editors.article.views.FormView.java
License:Open Source License
/** * This is a callback that will allow us to create the viewer and * initialize it.//from w ww .j av a2s .c om */ public void createPartControl(Composite parent) { toolkit = new FormToolkit(parent.getDisplay()); form = toolkit.createScrolledForm(parent); form.setText(Messages.getString("FormView.title")); //$NON-NLS-1$ TableWrapLayout layout = new TableWrapLayout(); //GridLayout layout = new GridLayout(); form.getBody().setLayout(layout); Hyperlink link = toolkit.createHyperlink(form.getBody(), Messages.getString("FormView.link"), //$NON-NLS-1$ SWT.WRAP); link.addHyperlinkListener(new HyperlinkAdapter() { public void linkActivated(HyperlinkEvent e) { System.out.println(Messages.getString("FormView.linkMessage")); //$NON-NLS-1$ } }); link.setText(Messages.getString("FormView.longLink")); //$NON-NLS-1$ layout.numColumns = 2; TableWrapData td = new TableWrapData(); td.colspan = 2; link.setLayoutData(td); //GridData gd = new GridData(); //gd.horizontalSpan = 2; //link.setLayoutData(gd); toolkit.createLabel(form.getBody(), Messages.getString("FormView.textLabel")); //$NON-NLS-1$ Text text = toolkit.createText(form.getBody(), ""); //$NON-NLS-1$ td = new TableWrapData(TableWrapData.FILL_GRAB); text.setLayoutData(td); //text.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); Button button = toolkit.createButton(form.getBody(), Messages.getString("FormView.checkbox"), SWT.CHECK); //$NON-NLS-1$ td = new TableWrapData(); td.colspan = 2; button.setLayoutData(td); //gd = new GridData(); //gd.horizontalSpan = 2; //button.setLayoutData(gd); ExpandableComposite ec = toolkit.createExpandableComposite(form.getBody(), ExpandableComposite.TREE_NODE | ExpandableComposite.CLIENT_INDENT); ImageHyperlink eci = toolkit.createImageHyperlink(ec, SWT.NULL); //eci.setImage(FormArticlePlugin.getDefault().getImageRegistry().get(FormArticlePlugin.IMG_SAMPLE)); ec.setTextClient(eci); ec.setText(Messages.getString("FormView.expandable")); //$NON-NLS-1$ String ctext = Messages.getString("FormView.expandableText") + //$NON-NLS-1$ Messages.getString("FormView.expandablText2") + //$NON-NLS-1$ Messages.getString("FormView.expandableText3") + //$NON-NLS-1$ Messages.getString("FormView.expandableText4"); //$NON-NLS-1$ Label client = toolkit.createLabel(ec, ctext, SWT.WRAP); ec.setClient(client); td = new TableWrapData(); td.colspan = 2; ec.setLayoutData(td); ec.addExpansionListener(new ExpansionAdapter() { public void expansionStateChanged(ExpansionEvent e) { form.reflow(true); } }); Section section = toolkit.createSection(form.getBody(), Section.DESCRIPTION | Section.TWISTIE | Section.TITLE_BAR | Section.EXPANDED); td = new TableWrapData(TableWrapData.FILL); td.colspan = 2; section.setLayoutData(td); section.addExpansionListener(new ExpansionAdapter() { public void expansionStateChanged(ExpansionEvent e) { form.reflow(true); } }); section.setText(Messages.getString("FormView.stitle")); //$NON-NLS-1$ section.setDescription(Messages.getString("FormView.sdesc")); //$NON-NLS-1$ Composite sectionClient = toolkit.createComposite(section); sectionClient.setLayout(new GridLayout()); button = toolkit.createButton(sectionClient, Messages.getString("FormView.radio1"), SWT.RADIO); //$NON-NLS-1$ button = toolkit.createButton(sectionClient, Messages.getString("FormView.radio2"), SWT.RADIO); //$NON-NLS-1$ section.setClient(sectionClient); StringBuffer buf = new StringBuffer(); buf.append("<form>"); //$NON-NLS-1$ buf.append("<p>"); //$NON-NLS-1$ buf.append(Messages.getString("FormView.ftext1")); //$NON-NLS-1$ buf.append(Messages.getString("FormView.ftext2")); //$NON-NLS-1$ buf.append("</p>"); //$NON-NLS-1$ buf.append("<p>"); //$NON-NLS-1$ buf.append(Messages.getString("FormView.ftext3")); //$NON-NLS-1$ buf.append("</p>"); //$NON-NLS-1$ buf.append(Messages.getString("FormView.ftext4")); //$NON-NLS-1$ buf.append(Messages.getString("FormView.ftext5")); //$NON-NLS-1$ buf.append("</p>"); //$NON-NLS-1$ buf.append(Messages.getString("FormView.ftext6")); //$NON-NLS-1$ buf.append(Messages.getString("FormView.ftext7")); //$NON-NLS-1$ buf.append(Messages.getString("FormView.ftext8")); //$NON-NLS-1$ buf.append(Messages.getString("FormView.ftext9")); //$NON-NLS-1$ buf.append(Messages.getString("FormView.ftext10")); //$NON-NLS-1$ buf.append(Messages.getString("FormView.ftext11")); //$NON-NLS-1$ buf.append(Messages.getString("FormView.ftext12")); //$NON-NLS-1$ buf.append(Messages.getString("FormView.ftext13")); //$NON-NLS-1$ buf.append("</form>"); //$NON-NLS-1$ FormText rtext = toolkit.createFormText(form.getBody(), true); rtext.setWhitespaceNormalized(true); td = new TableWrapData(TableWrapData.FILL); td.colspan = 2; rtext.setLayoutData(td); // rtext.setImage("image", FormArticlePlugin.getDefault().getImageRegistry().get(FormArticlePlugin.IMG_SAMPLE)); //$NON-NLS-1$ rtext.setColor("header", toolkit.getColors().getColor(FormColors.TITLE)); //$NON-NLS-1$ rtext.setFont("header", JFaceResources.getHeaderFont()); //$NON-NLS-1$ rtext.setFont("code", JFaceResources.getTextFont()); //$NON-NLS-1$ rtext.setText(buf.toString(), true, false); rtext.addHyperlinkListener(new HyperlinkAdapter() { public void linkActivated(HyperlinkEvent e) { System.out.println(Messages.getString("FormView.lmessage") + e.getHref()); //$NON-NLS-1$ } }); /* layout.numColumns = 3; Label label; TableWrapData td; label = toolkit.createLabel(form.getBody(), "Some text to put in the first column", SWT.WRAP); label = toolkit.createLabel(form.getBody() ,"Some text to put in the second column and make it a bit longer so that we can see what happens with column distribution. This text must be the longest so that it can get more space allocated to the columns it belongs to.", SWT.WRAP); td = new TableWrapData(); td.colspan = 2; label.setLayoutData(td); label = toolkit.createLabel(form.getBody(), "This text will span two rows and should not grow the column.", SWT.WRAP); td = new TableWrapData(); td.rowspan = 2; label.setLayoutData(td); label = toolkit.createLabel(form.getBody(), "This text goes into column 2 and consumes only one cell", SWT.WRAP); label.setLayoutData(new TableWrapData(TableWrapData.FILL_GRAB)); label = toolkit.createLabel(form.getBody(), "This text goes into column 3 and consumes only one cell too", SWT.WRAP); label.setLayoutData(new TableWrapData(TableWrapData.FILL)); label = toolkit.createLabel(form.getBody(), "This text goes into column 2 and consumes only one cell", SWT.WRAP); label.setLayoutData(new TableWrapData(TableWrapData.FILL_GRAB)); label = toolkit.createLabel(form.getBody(), "This text goes into column 3 and consumes only one cell too", SWT.WRAP); label.setLayoutData(new TableWrapData(TableWrapData.FILL)); form.getBody().setBackground(form.getBody().getDisplay().getSystemColor(SWT.COLOR_WIDGET_BACKGROUND)); */ toolkit.paintBordersFor(form.getBody()); }
From source file:org2.eclipse.php.internal.debug.ui.pathmapper.PathMapperEntryDialog.java
License:Open Source License
/** * Adds an example text label. //from w ww. java 2 s .c o m */ protected void addExampleText(Composite parent, String text) { new Label(parent, SWT.NONE); Label banner = new Label(parent, SWT.NONE); banner.setText(text); Font defaultFont = JFaceResources.getTextFont(); final Font smallFont = new Font(banner.getDisplay(), defaultFont.getFontData()[0].getName(), 8, SWT.NONE); banner.setFont(smallFont); banner.addDisposeListener(new DisposeListener() { public void widgetDisposed(DisposeEvent e) { smallFont.dispose(); } }); GridData gds = new GridData(GridData.FILL_HORIZONTAL); gds.horizontalSpan = 2; gds.verticalIndent = -2; gds.verticalAlignment = SWT.TOP; banner.setLayoutData(gds); }
From source file:v9t9.gui.client.swt.shells.debugger.CpuInstructionTableComposite.java
License:Open Source License
public CpuInstructionTableComposite(Composite parent, int style, IMachine machine_) { super(parent, style, machine_); GridLayoutFactory.fillDefaults().applyTo(this); ////*from ww w. j ava 2s. c om*/ instTable = new Table(this, SWT.BORDER + SWT.VIRTUAL + SWT.NO_FOCUS + SWT.FULL_SELECTION); // instTable.setLabelProvider(new InstLabelProvider( // //getDisplay().getSystemColor(SWT.COLOR_RED) // )); instLabelProvider = new InstLabelProvider(machine.getCpu().createInstructionEffectLabelProvider()); GridDataFactory.fillDefaults().grab(true, true).span(1, 1).applyTo(instTable); FontDescriptor fontDescriptor = FontUtils.getFontDescriptor(JFaceResources.getTextFont()); //fontDescriptor = fontDescriptor.increaseHeight(-2); tableFont = fontDescriptor.createFont(getDisplay()); FontDescriptor smallerFontDescriptor = fontDescriptor.increaseHeight(-2); smallerFont = smallerFontDescriptor.createFont(getDisplay()); instTable.setFont(smallerFont); GC gc = new GC(getDisplay()); gc.setFont(smallerFont); int charWidth = gc.stringExtent("M").x; gc.dispose(); TableColumn column; for (IInstructionEffectLabelProvider.Column col : instLabelProvider.getColumns()) { column = new TableColumn(instTable, SWT.LEFT); column.setText(col.label); column.setMoveable(true); column.setWidth(charWidth * (col.width + 2)); } instTable.setHeaderVisible(true); instTable.setLinesVisible(true); start(); }
From source file:v9t9.gui.client.swt.shells.debugger.CpuInstructionTextCanvasComposite.java
License:Open Source License
public CpuInstructionTextCanvasComposite(Composite parent, int style, IMachine machine) { super(parent, style | SWT.V_SCROLL, machine); this.instLabelProvider = new InstLabelProvider(machine.getCpu().createInstructionEffectLabelProvider()); GridLayoutFactory.fillDefaults().applyTo(this); text = new StyledText(this, SWT.BORDER | SWT.READ_ONLY | SWT.H_SCROLL); GridDataFactory.fillDefaults().grab(true, true).applyTo(text); FontDescriptor fontDescriptor = FontUtils.getFontDescriptor(JFaceResources.getTextFont()); FontDescriptor smallerFontDescriptor = fontDescriptor.increaseHeight(-2); smallerFont = smallerFontDescriptor.createFont(getDisplay()); baseTextStyle = new TextStyle(smallerFont, null, null); bg1Style = new TextStyle(baseTextStyle); bg1Style.background = getDisplay().getSystemColor(SWT.COLOR_LIST_BACKGROUND); bg2Style = new TextStyle(baseTextStyle); bg2Style.background = getDisplay().getSystemColor(SWT.COLOR_WIDGET_LIGHT_SHADOW); bpStyle = new TextStyle(baseTextStyle); bpStyle.background = getDisplay().getSystemColor(SWT.COLOR_RED); text.addLineStyleListener(new LineStyleListener() { @Override//from ww w. j ava 2 s .c om public void lineGetStyle(LineStyleEvent event) { StyleRange[] ranges = layoutStyles(event.lineOffset); event.styles = ranges; } }); start(); }
From source file:v9t9.gui.client.swt.shells.debugger.MemoryViewer.java
License:Open Source License
protected void createUI() { entryViewer = new ComboViewer(this, SWT.DROP_DOWN | SWT.READ_ONLY | SWT.NO_FOCUS); entryViewer.setContentProvider(new ArrayContentProvider()); entryViewer.setLabelProvider(new MemoryEntryLabelProvider()); entryViewer.setFilters(new ViewerFilter[] { new ViewerFilter() { @Override//from ww w . j a v a 2 s. com public boolean select(Viewer viewer, Object parentElement, Object element) { IMemoryEntry entry = (IMemoryEntry) element; if (!entry.hasReadAccess()) return false; if (filterMemory && !entry.hasWriteAccess()) return false; return true; } } }); entryViewer.addSelectionChangedListener(new ISelectionChangedListener() { public void selectionChanged(SelectionChangedEvent event) { Object element = ((IStructuredSelection) event.getSelection()).getFirstElement(); MemoryRange range; if (element instanceof IMemoryEntry) { range = new MemoryRange((IMemoryEntry) element); } else if (element instanceof MemoryRange) { range = (MemoryRange) element; } else { return; } changeCurrentRange(range); } }); Composite buttonBar = new Composite(this, SWT.NO_FOCUS); GridDataFactory.swtDefaults().align(SWT.RIGHT, SWT.CENTER).applyTo(buttonBar); buttonBar.setLayout(new RowLayout(SWT.HORIZONTAL)); filterButton = new Button(buttonBar, SWT.TOGGLE); filterButton.setImage(EmulatorGuiData.loadImage(getDisplay(), "icons/filter.png")); filterButton.setSize(24, 24); filterMemory = true; filterButton.setSelection(true); filterButton.setToolTipText("View only RAM entries if set"); filterButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { filterMemory = filterButton.getSelection(); entryViewer.refresh(); } }); refreshButton = new Button(buttonBar, SWT.TOGGLE); refreshButton.setImage(EmulatorGuiData.loadImage(getDisplay(), "icons/refresh.png")); refreshButton.setSize(24, 24); autoRefresh = true; refreshButton.setSelection(true); refreshButton.setToolTipText("Automatically refresh memory view if set"); refreshButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { autoRefresh = refreshButton.getSelection(); } }); decodeButton = new Button(buttonBar, SWT.TOGGLE); decodeButton.setImage(EmulatorGuiData.loadImage(getDisplay(), "icons/decode.png")); decodeButton.setSize(24, 24); decodeMemory = false; decodeButton.setSelection(false); decodeButton.setToolTipText("Decode memory to show underlying structure"); pinButton = new Button(buttonBar, SWT.TOGGLE); pinButton.setImage(EmulatorGuiData.loadImage(getDisplay(), "icons/pin.png")); pinButton.setSize(24, 24); pinMemory = false; pinButton.setSelection(false); pinButton.setToolTipText("Pin view to scroll position if set, else, scroll to active memory"); pinButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { pinMemory = pinButton.getSelection(); } }); refreshEntryCombo(); FontDescriptor fontDescriptor = FontUtils.getFontDescriptor(JFaceResources.getTextFont()); fontDescriptor = fontDescriptor.increaseHeight(-2); tableFont = fontDescriptor.createFont(getDisplay()); tableComposite = new Composite(this, SWT.NONE); tableLayout = new StackLayout(); tableComposite.setLayout(tableLayout); GridDataFactory.fillDefaults().grab(true, true).span(2, 1).applyTo(tableComposite); createByteTableViewer(tableComposite); createDecodedContentTableViewer(tableComposite); tableLayout.topControl = byteTableViewer.getControl(); decodeButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { decodeMemory = decodeButton.getSelection() && memoryDecoder != null; tableLayout.topControl = (decodeMemory ? decodedTableViewer : byteTableViewer).getTable(); tableComposite.layout(true); } }); }
From source file:v9t9.gui.client.swt.shells.debugger.RegisterViewer.java
License:Open Source License
/** * @param parent/*ww w. j av a2 s . c o m*/ * @param machine * @param style */ public RegisterViewer(Composite parent, IMachine machine, final IRegisterProvider regProvider, int perColumn) { super(parent, SWT.NONE); setLayout(new GridLayout()); Label label = new Label(this, SWT.NONE); label.setText(regProvider.getLabel()); GridDataFactory.fillDefaults().grab(true, false).span(1, 1).applyTo(label); FontDescriptor fontDescriptor = FontUtils.getFontDescriptor(JFaceResources.getTextFont()); tableFont = fontDescriptor.createFont(getDisplay()); FontDescriptor smallerFontDescriptor = fontDescriptor.increaseHeight(-2); smallerFont = smallerFontDescriptor.createFont(getDisplay()); ScrolledComposite tableScroller = new ScrolledComposite(this, SWT.H_SCROLL); GridDataFactory.fillDefaults().grab(true, true).span(1, 1).applyTo(tableScroller); Composite tables = new Composite(tableScroller, SWT.NONE); tables.setLayout(new GridLayout()); GridDataFactory.fillDefaults().grab(true, true).span(1, 1).applyTo(tables); tableScroller.setContent(tables); tableScroller.setExpandHorizontal(true); tableScroller.setExpandVertical(true); int cnt = regProvider.getRegisterCount(); if (cnt % perColumn < 3) perColumn++; int numColumns = (cnt + perColumn - 1) / perColumn; GridLayoutFactory.swtDefaults().numColumns(numColumns).applyTo(tables); int startReg = 0; regViewers = new TableViewer[numColumns]; int idx = 0; while (startReg < cnt) { int endReg = Math.min(startReg + perColumn, cnt); regViewers[idx] = createTable(tables, regProvider, startReg, endReg - startReg); GridDataFactory.fillDefaults().grab(true, true).applyTo(regViewers[idx].getTable()); startReg = endReg; idx++; } tableScroller.setMinSize(tables.computeSize(SWT.DEFAULT, SWT.DEFAULT)); addDisposeListener(new DisposeListener() { public void widgetDisposed(DisposeEvent e) { tableFont.dispose(); smallerFont.dispose(); } }); }