List of usage examples for org.eclipse.jface.resource JFaceResources getFontDescriptor
public static FontDescriptor getFontDescriptor(String symbolicName)
From source file:org.eclipse.dd.dsf.debug.internal.provisional.ui.viewmodel.register.RegisterVMNode.java
License:Open Source License
protected void updateLabelInSessionThread(final ILabelUpdate[] updates) { /*//from w w w .j a va 2 s .c o m * This list represents all the QUEUED requests for formatted DMCs. This allows us to issue the * requests for the data in the same dispatch cycle. Thus the lower level services is given its * best chance to coalesce the registers in to a single request. */ final ArrayList<QueuedValueUpdate> valueUpdatesToProcess = new ArrayList<QueuedValueUpdate>(); final DsfExecutor dsfExecutor = getSession().getExecutor(); final CountingRequestMonitor crm = new CountingRequestMonitor(dsfExecutor, null) { @Override public void handleCompleted() { if (!isSuccess()) { for (ILabelUpdate up : updates) { handleFailedUpdate(up); } return; } /* * We have all of the formatted DMCs. Go issue the requests for the formatted data * in a single dispatch cycle. */ retrieveAllFormattedDataValues(valueUpdatesToProcess); } }; crm.setDoneCount(calculateTheNumberOfRowsWithValueColumns(updates)); /* * Process each update request, creating a QUEUE of requests which need further processing * for the formatted values. */ for (final ILabelUpdate update : updates) { final IRegisterDMContext dmc = findDmcInPath(update.getViewerInput(), update.getElementPath(), IRegisterDMContext.class); if (dmc == null) { handleFailedUpdate(update); continue; } IRegisters regService = getServicesTracker().getService(IRegisters.class); if (regService == null) { handleFailedUpdate(update); continue; } getDMVMProvider().getModelData(this, update, regService, dmc, new ViewerDataRequestMonitor<IRegisterDMData>(getSession().getExecutor(), update) { @Override protected void handleCompleted() { /* * Check that the request was evaluated and data is still * valid. The request could fail if the state of the * service changed during the request, but the view model * has not been updated yet. */ if (!isSuccess()) { assert getStatus().isOK() || getStatus().getCode() != IDsfStatusConstants.INTERNAL_ERROR || getStatus().getCode() != IDsfStatusConstants.NOT_SUPPORTED; /* * Instead of just failing this outright we are going to attempt to do more here. * Failing it outright causes the view to display ... for all columns in the line * and this is uninformative about what is happening. We may be trying to show a * register whos retrieval has been cancelled by the lower level. Perhaps because * we are stepping extremely fast and state changes cause the register service to * return these requests without ever sending them to the debug engine. * */ String[] localColumns = update.getColumnIds(); if (localColumns == null) localColumns = new String[] { IDebugVMConstants.COLUMN_ID__NAME }; for (int idx = 0; idx < localColumns.length; idx++) { if (IDebugVMConstants.COLUMN_ID__NAME.equals(localColumns[idx])) { /* * This used to be easy in that the DMC contained the name. Which allowed us * to display the register name and an error message across from it. Now that * name must come from the data and we could not retrieve the data we do not * have anything intelligent to show here. I think this is going to look very * ugly and will need to be worked on. We know the service has the name with * it, it is just the dynamic part which cannot be obtained ( as explained in * comments above ). */ update.setLabel("Unknown name", idx); //$NON-NLS-1$ update.setImageDescriptor(DebugPluginImages .getImageDescriptor(IDebugUIConstants.IMG_OBJS_REGISTER), idx); } else if (IDebugVMConstants.COLUMN_ID__TYPE.equals(localColumns[idx])) { update.setLabel("", idx); //$NON-NLS-1$ } else if (IDebugVMConstants.COLUMN_ID__VALUE.equals(localColumns[idx])) { if (getStatus().getCode() == IDsfStatusConstants.INVALID_STATE) { update.setLabel("...", idx); //$NON-NLS-1$ } else { update.setLabel("Error: " + getStatus().getMessage(), idx); //$NON-NLS-1$ } } else if (IDebugVMConstants.COLUMN_ID__DESCRIPTION.equals(localColumns[idx])) { update.setLabel("...", idx); //$NON-NLS-1$ } else if (IDebugVMConstants.COLUMN_ID__EXPRESSION.equals(localColumns[idx])) { update.setLabel("", idx); //$NON-NLS-1$ } update.setFontData(JFaceResources .getFontDescriptor(IInternalDebugUIConstants.VARIABLE_TEXT_FONT) .getFontData()[0], idx); } update.done(); return; } /* * If columns are configured, extract the selected values for each understood column. First we fill all * of those columns which can be filled without the extra data mining. We also note, if we do have to * datamine. Any columns need to set the processing flag so we know we have further work to do. If there * are more columns which need data extraction they need to be added in both "for" loops. */ String[] localColumns = update.getColumnIds(); if (localColumns == null) localColumns = new String[] { IDebugVMConstants.COLUMN_ID__NAME }; boolean allFieldsProcessed = true; for (int idx = 0; idx < localColumns.length; idx++) { update.setFontData(JFaceResources .getFontDescriptor(IInternalDebugUIConstants.VARIABLE_TEXT_FONT) .getFontData()[0], idx); if (IDebugVMConstants.COLUMN_ID__NAME.equals(localColumns[idx])) { update.setLabel(getData().getName(), idx); update.setImageDescriptor(DebugPluginImages .getImageDescriptor(IDebugUIConstants.IMG_OBJS_REGISTER), idx); } else if (IDebugVMConstants.COLUMN_ID__VALUE.equals(localColumns[idx])) { allFieldsProcessed = false; /* * Create an entry which holds all related data and add it to the list to process * when all the formatted DMCs are gathered. */ final QueuedValueUpdate valueUpdate = new QueuedValueUpdate(update, idx, dmc); valueUpdatesToProcess.add(valueUpdate); /* * Fetch the associated formatted DMC for this field. Note that every time we * complete the request for a Formatted DMC we tell the Counting Request Monitor * we have completed one in the list. */ getFormattedDmcForReqister(update, dmc, new ViewerDataRequestMonitor<FormattedValueDMContext>(dsfExecutor, update) { @Override public void handleCompleted() { if (getStatus().isOK()) { valueUpdate.setValueDmc(getData()); } else { valueUpdate.setValueDmc(null); } crm.done(); } }); } else if (IDebugVMConstants.COLUMN_ID__TYPE.equals(localColumns[idx])) { IRegisterDMData data = getData(); String typeStr = "Unsigned"; //$NON-NLS-1$ String ReadAttrStr = "ReadNone"; //$NON-NLS-1$ String WriteAddrStr = "WriteNone"; //$NON-NLS-1$ if (data.isFloat()) { typeStr = "Floating Point"; //$NON-NLS-1$ } if (data.isReadOnce()) { ReadAttrStr = "ReadOnce"; //$NON-NLS-1$ } else if (data.isReadable()) { ReadAttrStr = "Readable"; //$NON-NLS-1$ } if (data.isReadOnce()) { WriteAddrStr = "WriteOnce"; //$NON-NLS-1$ } else if (data.isReadable()) { WriteAddrStr = "Writeable"; //$NON-NLS-1$ } typeStr += " - " + ReadAttrStr + "/" + WriteAddrStr; //$NON-NLS-1$ //$NON-NLS-2$ update.setLabel(typeStr, idx); } else if (IDebugVMConstants.COLUMN_ID__DESCRIPTION.equals(localColumns[idx])) { update.setLabel(getData().getDescription(), idx); } else if (IDebugVMConstants.COLUMN_ID__EXPRESSION.equals(localColumns[idx])) { IVMContext vmc = (IVMContext) update.getElement(); IExpression expression = (IExpression) vmc.getAdapter(IExpression.class); if (expression != null) { update.setLabel(expression.getExpressionText(), idx); } else { update.setLabel(getData().getName(), idx); } } } if (allFieldsProcessed) { update.done(); } } }, getSession().getExecutor()); } }
From source file:org.eclipse.dd.dsf.debug.internal.provisional.ui.viewmodel.variable.VariableVMNode.java
License:Open Source License
private void fillInExpressionErrorInfo(ILabelUpdate update, IExpressionDMContext dmc, IStatus status) { /*/* ww w . j a va2 s. c om*/ * Instead of just failing this outright we are going to attempt to do more here. * Failing it outright causes the view to display ... for all columns in the line * and this is uninformative about what is happening. It will be very common that * one or more variables at that given instance in time are not evaluatable. They * may be out of scope and will come back into scope later. */ String[] localColumns = update.getColumnIds(); if (localColumns == null) localColumns = new String[] { IDebugVMConstants.COLUMN_ID__NAME }; for (int idx = 0; idx < localColumns.length; idx++) { if (IDebugVMConstants.COLUMN_ID__NAME.equals(localColumns[idx])) { update.setLabel(dmc.getExpression(), idx); } else if (IDebugVMConstants.COLUMN_ID__TYPE.equals(localColumns[idx])) { update.setLabel("", idx); } else if (IDebugVMConstants.COLUMN_ID__VALUE.equals(localColumns[idx])) { update.setLabel("Error : " + status.getMessage(), idx); } else if (IDebugVMConstants.COLUMN_ID__ADDRESS.equals(localColumns[idx])) { update.setLabel("", idx); } else if (IDebugVMConstants.COLUMN_ID__DESCRIPTION.equals(localColumns[idx])) { update.setLabel("", idx); } else if (IDebugVMConstants.COLUMN_ID__EXPRESSION.equals(localColumns[idx])) { update.setLabel(dmc.getExpression(), idx); } else { update.setLabel("", idx); } update.setFontData( JFaceResources.getFontDescriptor(IInternalDebugUIConstants.VARIABLE_TEXT_FONT).getFontData()[0], idx); } }
From source file:org.eclipse.dd.dsf.debug.internal.provisional.ui.viewmodel.variable.VariableVMNode.java
License:Open Source License
protected void updateLabelInSessionThread(ILabelUpdate[] updates) { for (final ILabelUpdate update : updates) { final IExpressionDMContext dmc = findDmcInPath(update.getViewerInput(), update.getElementPath(), IExpressions.IExpressionDMContext.class); if (dmc == null) { // Workaround for a bug in platform, where the find operation may use wrong label provider. // See bug 246618. update.done();//w w w . ja va 2 s . co m continue; } getDMVMProvider().getModelData(this, update, getServicesTracker().getService(IExpressions.class, null), dmc, new ViewerDataRequestMonitor<IExpressionDMData>(getSession().getExecutor(), update) { @Override protected void handleCompleted() { // Check that the request was evaluated and data is still valid. The request could // fail if the state of the service changed during the request, but the view model // has not been updated yet. if (!isSuccess()) { assert getStatus().isOK() || getStatus().getCode() != IDsfStatusConstants.INTERNAL_ERROR || getStatus().getCode() != IDsfStatusConstants.NOT_SUPPORTED; fillInExpressionErrorInfo(update, dmc, getStatus()); update.done(); return; } // If columns are configured, extract the selected values for each understood column. // First, we fill all of those columns which can be filled without extra data mining. // We also note if we do have to do extra data mining. Any columns need to set the // processing flag so we know we have further work to do. If there are more columns // which need data extraction they need to be added in both "for" loops. String[] localColumns = update.getColumnIds(); if (localColumns == null) localColumns = new String[] { IDebugVMConstants.COLUMN_ID__NAME }; int extractingFormattedDataIndex = -1; int extractingAddressDataIndex = -1; for (int idx = 0; idx < localColumns.length; idx++) { if (IDebugVMConstants.COLUMN_ID__NAME.equals(localColumns[idx])) { update.setLabel(getData().getName(), idx); } else if (IDebugVMConstants.COLUMN_ID__TYPE.equals(localColumns[idx])) { update.setLabel(getData().getTypeName(), idx); } else if (IDebugVMConstants.COLUMN_ID__VALUE.equals(localColumns[idx])) { extractingFormattedDataIndex = idx; } else if (IDebugVMConstants.COLUMN_ID__ADDRESS.equals(localColumns[idx])) { extractingAddressDataIndex = idx; } else if (IDebugVMConstants.COLUMN_ID__DESCRIPTION.equals(localColumns[idx])) { update.setLabel("", idx); } else if (IDebugVMConstants.COLUMN_ID__EXPRESSION.equals(localColumns[idx])) { IVMContext vmc = (IVMContext) update.getElement(); IExpression expression = (IExpression) vmc.getAdapter(IExpression.class); if (expression != null) { update.setLabel(expression.getExpressionText(), idx); } else { update.setLabel(getData().getName(), idx); } } update.setFontData(JFaceResources .getFontDescriptor(IInternalDebugUIConstants.VARIABLE_TEXT_FONT) .getFontData()[0], idx); } if ((extractingFormattedDataIndex == -1) && (extractingAddressDataIndex == -1)) { update.done(); } else { /* * We are either updating the value or the address or possibly both. * We will create a overarching monitor to handle completing the update * when either/both of the lower level updates are done. */ final DsfExecutor dsfExecutor = getSession().getExecutor(); final MultiRequestMonitor<RequestMonitor> mrm = new MultiRequestMonitor<RequestMonitor>( dsfExecutor, null) { @Override public void handleCompleted() { if (!isSuccess()) { handleFailedUpdate(update); return; } update.done(); } }; /* * Deal with the value. */ if (extractingFormattedDataIndex != -1) { RequestMonitor rm = new RequestMonitor(dsfExecutor, null) { @Override public void handleCompleted() { mrm.requestMonitorDone(this); } }; mrm.add(rm); updateFormattedExpressionValue(update, extractingFormattedDataIndex, dmc, getData(), rm); } /* * Deal with the address. */ if (extractingAddressDataIndex != -1) { RequestMonitor rm = new RequestMonitor(dsfExecutor, null) { @Override public void handleCompleted() { mrm.requestMonitorDone(this); } }; mrm.add(rm); updateAddressData(update, extractingAddressDataIndex, dmc, rm); } } } }, getExecutor()); } }
From source file:org.eclipse.dd.dsf.debug.internal.provisional.ui.viewmodel.variable.VariableVMNode.java
License:Open Source License
/** * Private data access routine which performs the extra level of data access needed to * get the formatted data value for a specific register. *///from w ww . j a v a2s .co m private void updateAddressData(final ILabelUpdate update, final int labelIndex, final IExpressionDMContext dmc, final RequestMonitor monitor) { /* * First select the format to be used. This involves checking so see that the preference * page format is supported by the register service. If the format is not supported then * we will pick the first available format. */ final IExpressions expressionService = getServicesTracker().getService(IExpressions.class); // Get the variable information and update the corresponding memory locations if (expressionService != null) { expressionService.getExpressionAddressData(dmc, new DataRequestMonitor<IExpressionDMAddress>(getExecutor(), monitor) { @Override protected void handleCompleted() { if (isSuccess()) { // Figure out which memory area was modified IExpressionDMAddress expression = getData(); IAddress expAddress = expression.getAddress(); if (expAddress instanceof Addr64) { update.setLabel("0x" + ((Addr64) expAddress).toString(16), labelIndex); } else if (expAddress instanceof Addr32) { update.setLabel("0x" + ((Addr32) expAddress).toString(16), labelIndex); } else { update.setLabel("Unknown address format", labelIndex); } } else { /* * We could not get the format. Currently GDB does not handle getting the address of * a constant for example. We could put the error message in, but that would not be * all that helpful top the user. The interface is a new one and perhaps failing to * return a valid set of information is just saying it does not exist. Anyway, for * now we will just put nothing in. */ update.setLabel("", labelIndex); } update.setFontData( JFaceResources.getFontDescriptor(IInternalDebugUIConstants.VARIABLE_TEXT_FONT) .getFontData()[0], labelIndex); monitor.done(); } }); } }
From source file:org.eclipse.dd.dsf.debug.internal.provisional.ui.viewmodel.variable.VariableVMNode.java
License:Open Source License
private void completeFillinInUpdateWithValue(ILabelUpdate update, int labelIndex, FormattedValueDMContext valueDmc, String value, FormattedValueDMContext stringFormatDmc, String stringFormatValue, RequestMonitor monitor) { /*/*from ww w . j av a 2 s . c o m*/ * Complete filling in the VALUE. The form is * * "Numerical value" "STRING_FORMAT value" * * This makes it so if the value is a pointer to something else we conveniently * fill in the something else ( typically a string ). */ StringBuffer stringValueBuf = new StringBuffer(value); if (stringFormatValue != null && stringFormatValue.length() > 0) { stringValueBuf.append(" "); stringValueBuf.append(stringFormatValue); } update.setLabel(stringValueBuf.toString(), labelIndex); update.setFontData( JFaceResources.getFontDescriptor(IInternalDebugUIConstants.VARIABLE_TEXT_FONT).getFontData()[0], labelIndex); /* * Get old values for comparison ( if available ). */ FormattedValueDMData oldStringData = null; FormattedValueDMData oldData = (FormattedValueDMData) getDMVMProvider().getArchivedModelData(VariableVMNode.this, update, valueDmc); if (stringFormatDmc != null) { oldStringData = (FormattedValueDMData) getDMVMProvider().getArchivedModelData(VariableVMNode.this, update, stringFormatDmc); } /* * Highlight the value if either the value (address) has changed or the string (memory at the value) has changed */ if ((oldData != null && !oldData.getFormattedValue().equals(value)) || (oldStringData != null && !oldStringData.getFormattedValue().equals(stringFormatValue))) { RGB rgb = DebugUIPlugin.getPreferenceColor(IInternalDebugUIConstants.PREF_CHANGED_VALUE_BACKGROUND) .getRGB(); update.setBackground(rgb, labelIndex); } /* * Now we finally can complete this one. */ monitor.done(); }
From source file:org.eclipse.debug.internal.ui.model.elements.VariableLabelProvider.java
License:Open Source License
protected FontData getFontData(TreePath elementPath, IPresentationContext presentationContext, String columnId) throws CoreException { return JFaceResources.getFontDescriptor(IDebugUIConstants.PREF_VARIABLE_TEXT_FONT).getFontData()[0]; }
From source file:org.eclipse.etrice.core.ui.labeling.RoomLabelProvider.java
License:Open Source License
private Styler getKeywordStyler() { if (keywordStyler == null) { FontDescriptor font = JFaceResources.getFontDescriptor(JFaceResources.TEXT_FONT); FontDescriptor boldFont = font.setStyle(SWT.BOLD); keywordStyler = stylerFactory.createStyler(boldFont, KEYWORD_COLOR, null); }/*from w ww . ja v a2 s. c om*/ return keywordStyler; }
From source file:org.eclipse.etrice.core.ui.labeling.RoomLabelProvider.java
License:Open Source License
private Styler getTypeStyler() { if (typeStyler == null) { FontDescriptor font = JFaceResources.getFontDescriptor(JFaceResources.TEXT_FONT); FontDescriptor italicFont = font.setStyle(SWT.ITALIC); typeStyler = stylerFactory.createStyler(italicFont, null, null); }/*from w ww .jav a 2s .c o m*/ return typeStyler; }
From source file:org.eclipse.tcf.internal.debug.ui.model.TCFDetailPane.java
License:Open Source License
private Font getMonospacedFont() { if (mono_font == null) { FontData[] fd = source_viewer.getControl().getFont().getFontData(); FontDescriptor d = JFaceResources.getFontDescriptor(IDebugUIConstants.PREF_DETAIL_PANE_FONT); if (fd != null && fd.length > 0) d = d.setHeight(fd[0].getHeight()); mono_font = d.createFont(display); }/*from ww w . ja v a 2 s .co m*/ return mono_font; }
From source file:org.eclipse.tcf.internal.debug.ui.model.TCFModelFonts.java
License:Open Source License
public static FontData getNormalFontData(String view_id) { FontData fd = fd_normal.get(view_id); if (fd == null) { if (listener == null) { listener = new IPropertyChangeListener() { public void propertyChange(PropertyChangeEvent event) { Protocol.invokeLater(new Runnable() { public void run() { fd_normal.clear(); fd_italic.clear(); fd_monospaced.clear(); }// ww w .jav a 2 s . c om }); } }; JFaceResources.getFontRegistry().addListener(listener); } if (IDebugUIConstants.ID_DEBUG_VIEW.equals(view_id)) { fd = JFaceResources.getFontDescriptor(JFaceResources.DEFAULT_FONT).getFontData()[0]; } else if (TCFDetailPane.ID.equals(view_id)) { FontData ff = JFaceResources.getFontDescriptor(JFaceResources.DEFAULT_FONT).getFontData()[0]; FontData fp = JFaceResources.getFontDescriptor(IDebugUIConstants.PREF_DETAIL_PANE_FONT) .getFontData()[0]; fd = new FontData(fp.getName(), ff.getHeight(), SWT.NORMAL); } else { fd = JFaceResources.getFontDescriptor(IDebugUIConstants.PREF_VARIABLE_TEXT_FONT).getFontData()[0]; } fd_normal.put(view_id, fd); } return fd; }