Example usage for org.eclipse.jface.resource JFaceResources getFontDescriptor

List of usage examples for org.eclipse.jface.resource JFaceResources getFontDescriptor

Introduction

In this page you can find the example usage for org.eclipse.jface.resource JFaceResources getFontDescriptor.

Prototype

public static FontDescriptor getFontDescriptor(String symbolicName) 

Source Link

Document

Returns the font descriptor for in JFace's font registry with the given symbolic name.

Usage

From source file:org.eclipse.cdt.debug.internal.ui.elements.adapters.CVariableLabelProvider.java

License:Open Source License

@Override
protected FontData getFontData(TreePath elementPath, IPresentationContext presentationContext, String columnId)
        throws CoreException {
    // No public access to the Variables view text font id. See https://bugs.eclipse.org/bugs/show_bug.cgi?id=187509
    return JFaceResources.getFontDescriptor(IDebugUIConstants.PREF_VARIABLE_TEXT_FONT).getFontData()[0];
}

From source file:org.eclipse.cdt.dsf.debug.ui.viewmodel.expression.ExpressionManagerVMNode.java

License:Open Source License

/**
 * Updates the label for the NewExpressionVMC.
 */// www  .  j av a  2s.  com
private void updateNewExpressionVMCLabel(ILabelUpdate update, NewExpressionVMC vmc) {
    String[] columnIds = update.getColumnIds() != null ? update.getColumnIds() : new String[0];

    for (int i = 0; i < columnIds.length; i++) {
        // Bug 373468: show "Add New Expression" label in name column if 
        // expression column is not shown.
        if (IDebugVMConstants.COLUMN_ID__EXPRESSION.equals(columnIds[i])
                || (IDebugVMConstants.COLUMN_ID__NAME.equals(columnIds[i])
                        && !Arrays.asList(columnIds).contains(IDebugVMConstants.COLUMN_ID__EXPRESSION))) {
            update.setLabel(MessagesForExpressionVM.ExpressionManagerLayoutNode__newExpression_label, i);
            update.setImageDescriptor(DebugUITools.getImageDescriptor(IDebugUIConstants.IMG_LCL_ADD), i);
            FontData fontData = JFaceResources.getFontDescriptor(IDebugUIConstants.PREF_VARIABLE_TEXT_FONT)
                    .getFontData()[0];
            // Bugzilla 287598: Distinguish 'Add new expression' entry from actual expressions
            fontData.setStyle(SWT.ITALIC);
            update.setFontData(fontData, i);
        } else {
            update.setLabel("", i); //$NON-NLS-1$
        }
    }

    update.done();
}

From source file:org.eclipse.cdt.dsf.debug.ui.viewmodel.expression.InvalidExpressionVMContext.java

License:Open Source License

/**
 * Updates the label for the InvalidExpressionVMC.
 *//*from  w  w w. j a v  a  2 s. c o  m*/
@Override
public void update(ILabelUpdate[] updates) {
    for (ILabelUpdate update : updates) {
        String[] columnIds = update.getColumnIds() != null ? update.getColumnIds()
                : new String[] { IDebugVMConstants.COLUMN_ID__NAME };

        for (int i = 0; i < columnIds.length; i++) {
            if (IDebugVMConstants.COLUMN_ID__EXPRESSION.equals(columnIds[i])) {
                update.setLabel(getExpression().getExpressionText(), i);
                update.setImageDescriptor(
                        DebugUITools.getImageDescriptor(IDebugUIConstants.IMG_OBJS_EXPRESSION), i);
            } else if (IDebugVMConstants.COLUMN_ID__NAME.equals(columnIds[i])) {
                update.setLabel(getExpression().getExpressionText(), i);
                update.setImageDescriptor(
                        DebugUITools.getImageDescriptor(IDebugUIConstants.IMG_OBJS_EXPRESSION), i);
            } else if (IDebugVMConstants.COLUMN_ID__VALUE.equals(columnIds[i])) {
                update.setLabel(
                        MessagesForExpressionVM.ExpressionManagerLayoutNode__invalidExpression_valueColumn_label,
                        i);
            } else {
                update.setLabel("", i); //$NON-NLS-1$
            }
            update.setFontData(JFaceResources.getFontDescriptor(IDebugUIConstants.PREF_VARIABLE_TEXT_FONT)
                    .getFontData()[0], i);
        }

        update.done();
    }
}

From source file:org.eclipse.cdt.dsf.debug.ui.viewmodel.modules.ModulesVMNode.java

License:Open Source License

/**
 * Creates the label provider delegate.  This VM node will delegate label 
 * updates to this provider which can be created by sub-classes.   
 *  //from   ww w  . j  a  v a  2 s .c  o m
 * @return Returns the label provider for this node. 
 *  
 * @since 2.0
 */
protected IElementLabelProvider createLabelProvider() {
    PropertiesBasedLabelProvider provider = new PropertiesBasedLabelProvider();

    provider.setColumnInfo(PropertiesBasedLabelProvider.ID_COLUMN_NO_COLUMNS,
            new LabelColumnInfo(new LabelAttribute[] {
                    new LabelText(MessagesForModulesVM.ModulesVMNode_No_columns__text_format,
                            new String[] { PROP_NAME }),
                    new DsfUILabelImage(IDsfDebugUIConstants.IMG_OBJS_SHARED_LIBRARY_SYMBOLS_LOADED) {
                        {
                            setPropertyNames(new String[] { PROP_IS_LOADED });
                        }

                        @Override
                        public boolean checkProperty(String propertyName, IStatus status,
                                Map<String, Object> properties) {
                            if (PROP_IS_LOADED.equals(propertyName)) {
                                return Boolean.TRUE.equals(properties.get(propertyName));
                            }
                            return super.checkProperty(propertyName, status, properties);
                        };
                    }, new DsfUILabelImage(IDsfDebugUIConstants.IMG_OBJS_SHARED_LIBRARY_SYMBOLS_UNLOADED),
                    new StaleDataLabelBackground(), new LabelFont(JFaceResources
                            .getFontDescriptor(IDebugUIConstants.PREF_VARIABLE_TEXT_FONT).getFontData()[0]) }));

    return provider;
}

From source file:org.eclipse.cdt.dsf.debug.ui.viewmodel.variable.VariableLabelFont.java

License:Open Source License

public VariableLabelFont() {
    super(JFaceResources.getFontDescriptor(IDebugUIConstants.PREF_VARIABLE_TEXT_FONT).getFontData()[0]);
}

From source file:org.eclipse.dd.dsf.debug.internal.provisional.ui.viewmodel.expression.ExpressionManagerVMNode.java

License:Open Source License

/**
 * Updates the label for the NewExpressionVMC.
 *//* w ww . java  2  s . c  om*/
private void updateNewExpressionVMCLabel(ILabelUpdate update, NewExpressionVMC vmc) {
    String[] columnIds = update.getColumnIds() != null ? update.getColumnIds()
            : new String[] { IDebugVMConstants.COLUMN_ID__NAME };

    for (int i = 0; i < columnIds.length; i++) {
        if (IDebugVMConstants.COLUMN_ID__EXPRESSION.equals(columnIds[i])) {
            update.setLabel(MessagesForExpressionVM.ExpressionManagerLayoutNode__newExpression_label, i);
            update.setFontData(JFaceResources.getFontDescriptor(IInternalDebugUIConstants.VARIABLE_TEXT_FONT)
                    .getFontData()[0], i);
        } else {
            update.setLabel("", i); //$NON-NLS-1$
        }
    }

    update.done();
}

From source file:org.eclipse.dd.dsf.debug.internal.provisional.ui.viewmodel.register.RegisterBitFieldVMNode.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.
 */// www  . ja  v a2s . c  o m
private void updateFormattedRegisterValue(final ILabelUpdate update, final int labelIndex,
        final IBitFieldDMContext dmc, final IBitFieldDMData data) {
    final IRegisters regService = getServicesTracker().getService(IRegisters.class);

    /*
     *  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 IPresentationContext context = update.getPresentationContext();
    final String preferencePageFormatId = fFormattedPrefStore.getCurrentNumericFormat(context);

    regService.getAvailableFormats(dmc,
            new ViewerDataRequestMonitor<String[]>(getSession().getExecutor(), update) {
                @Override
                public void handleCompleted() {
                    if (!isSuccess()) {
                        handleFailedUpdate(update);
                        return;
                    }

                    /*
                     *  See if the desired format is supported.
                     */
                    String[] formatIds = getData();
                    String finalFormatId = IFormattedValues.HEX_FORMAT;
                    boolean requestedFormatIsSupported = false;

                    for (String fId : formatIds) {
                        if (preferencePageFormatId.equals(fId)) {
                            /*
                             *  Desired format is supported.
                             */
                            finalFormatId = preferencePageFormatId;
                            requestedFormatIsSupported = true;
                            break;
                        }
                    }

                    if (!requestedFormatIsSupported) {
                        /*
                         *  Desired format is not supported. If there are any formats supported
                         *  then use the first available.
                         */
                        if (formatIds.length != 0) {
                            finalFormatId = formatIds[0];
                        } else {
                            /*
                             *  Register service does not support any format.
                             */
                            handleFailedUpdate(update);
                            return;
                        }
                    }

                    /*
                     *  Format has been validated. Get the formatted value.
                     */
                    final FormattedValueDMContext valueDmc = regService.getFormattedValueContext(dmc,
                            finalFormatId);

                    getDMVMProvider().getModelData(RegisterBitFieldVMNode.this, update, regService, valueDmc,
                            new ViewerDataRequestMonitor<FormattedValueDMData>(getSession().getExecutor(),
                                    update) {
                                @Override
                                public void handleCompleted() {
                                    if (!isSuccess()) {
                                        if (getStatus().getCode() == IDsfStatusConstants.INVALID_STATE) {
                                            update.setLabel("...", labelIndex); //$NON-NLS-1$
                                        } else {
                                            update.setLabel("Error: " + getStatus().getMessage(), labelIndex); //$NON-NLS-1$
                                        }
                                        update.setFontData(JFaceResources
                                                .getFontDescriptor(IInternalDebugUIConstants.VARIABLE_TEXT_FONT)
                                                .getFontData()[0], labelIndex);
                                        update.done();
                                        return;
                                    }

                                    /*
                                     *  Fill the label/column with the properly formatted data value.
                                     */
                                    IMnemonic mnemonic = data.getCurrentMnemonicValue();
                                    if (mnemonic != null) {
                                        String mnemstr = mnemonic.getLongName() + " - " //$NON-NLS-1$
                                                + getData().getFormattedValue();
                                        update.setLabel(mnemstr, labelIndex);
                                    } else {
                                        update.setLabel(getData().getFormattedValue(), labelIndex);
                                    }

                                    update.setFontData(JFaceResources
                                            .getFontDescriptor(IInternalDebugUIConstants.VARIABLE_TEXT_FONT)
                                            .getFontData()[0], labelIndex);

                                    // color based on change history

                                    FormattedValueDMData oldData = (FormattedValueDMData) getDMVMProvider()
                                            .getArchivedModelData(RegisterBitFieldVMNode.this, update,
                                                    valueDmc);
                                    if (oldData != null && !oldData.getFormattedValue()
                                            .equals(getData().getFormattedValue())) {
                                        update.setBackground(DebugUIPlugin
                                                .getPreferenceColor(
                                                        IInternalDebugUIConstants.PREF_CHANGED_VALUE_BACKGROUND)
                                                .getRGB(), labelIndex);
                                    }
                                    update.done();
                                }
                            }, getExecutor());
                }
            });
}

From source file:org.eclipse.dd.dsf.debug.internal.provisional.ui.viewmodel.register.RegisterBitFieldVMNode.java

License:Open Source License

protected void updateLabelInSessionThread(ILabelUpdate[] updates) {
    for (final ILabelUpdate update : updates) {

        final IRegisters regService = getServicesTracker().getService(IRegisters.class);

        if (regService == null) {
            handleFailedUpdate(update);// w w  w . j  av a 2s . c o  m
            continue;
        }

        final IBitFieldDMContext dmc = findDmcInPath(update.getViewerInput(), update.getElementPath(),
                IBitFieldDMContext.class);

        getDMVMProvider().getModelData(this, update, regService, dmc,
                new ViewerDataRequestMonitor<IBitFieldDMData>(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 weAreExtractingFormattedData = false;

                        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__VALUE.equals(localColumns[idx])) {
                                weAreExtractingFormattedData = true;
                            } else if (IDebugVMConstants.COLUMN_ID__TYPE.equals(localColumns[idx])) {
                                IBitFieldDMData data = getData();
                                String typeStr = "Unsigned"; //$NON-NLS-1$
                                String ReadAttrStr = "ReadNone"; //$NON-NLS-1$
                                String WriteAddrStr = "WriteNone"; //$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);
                                }
                            }

                            update.setFontData(JFaceResources
                                    .getFontDescriptor(IInternalDebugUIConstants.VARIABLE_TEXT_FONT)
                                    .getFontData()[0], idx);
                        }

                        if (!weAreExtractingFormattedData) {
                            update.done();
                        } else {
                            for (int idx = 0; idx < localColumns.length; idx++) {
                                if (IDebugVMConstants.COLUMN_ID__VALUE.equals(localColumns[idx])) {
                                    updateFormattedRegisterValue(update, idx, dmc, getData());
                                }
                                update.setFontData(JFaceResources
                                        .getFontDescriptor(IInternalDebugUIConstants.VARIABLE_TEXT_FONT)
                                        .getFontData()[0], idx);
                            }
                        }
                    }
                }, getExecutor());
    }
}

From source file:org.eclipse.dd.dsf.debug.internal.provisional.ui.viewmodel.register.RegisterGroupVMNode.java

License:Open Source License

protected void fillColumnLabel(IRegisterGroupDMContext dmContext, IRegisterGroupDMData dmData, String columnId,
        int idx, ILabelUpdate update) {
    update.setFontData(//  www  .j a  v  a  2 s.  c  o  m
            JFaceResources.getFontDescriptor(IInternalDebugUIConstants.VARIABLE_TEXT_FONT).getFontData()[0],
            idx);

    if (IDebugVMConstants.COLUMN_ID__NAME.equals(columnId)) {
        update.setLabel(dmData.getName(), idx);
        update.setImageDescriptor(
                DebugPluginImages.getImageDescriptor(IDebugUIConstants.IMG_OBJS_REGISTER_GROUP), idx);
    } else if (IDebugVMConstants.COLUMN_ID__VALUE.equals(columnId)) {
        update.setLabel("", idx); //$NON-NLS-1$
    } else if (IDebugVMConstants.COLUMN_ID__DESCRIPTION.equals(columnId)) {
        update.setLabel(dmData.getDescription(), idx);
    } else if (IDebugVMConstants.COLUMN_ID__TYPE.equals(columnId)) {
        update.setLabel("", idx); //$NON-NLS-1$
    } else if (IDebugVMConstants.COLUMN_ID__EXPRESSION.equals(columnId)) {
        IVMContext vmc = (IVMContext) update.getElement();
        IExpression expression = (IExpression) vmc.getAdapter(IExpression.class);
        if (expression != null) {
            update.setLabel(expression.getExpressionText(), idx);
        } else {
            update.setLabel(dmData.getName(), idx);
        }
    } else if (columnId == null) {
        /*
         *  If the Column ID comes in as "null" then this is the case where the user has decided
         *  to not have any columns. So we need a default action which makes the most sense  and
         *  is doable. In this case we elect to simply display the name.
         */
        update.setLabel(dmData.getName(), idx);
        update.setImageDescriptor(
                DebugPluginImages.getImageDescriptor(IDebugUIConstants.IMG_OBJS_REGISTER_GROUP), idx);
    }
}

From source file:org.eclipse.dd.dsf.debug.internal.provisional.ui.viewmodel.register.RegisterVMNode.java

License:Open Source License

private void retrieveAllFormattedDataValues(final ArrayList<QueuedValueUpdate> updates) {

    final IRegisters regService = getServicesTracker().getService(IRegisters.class);
    if (regService == null) {
        for (final QueuedValueUpdate up : updates) {
            handleFailedUpdate(up.getUpdate());
        }//ww  w .  j a va2  s.  com
        return;
    }

    for (final QueuedValueUpdate up : updates) {

        final ILabelUpdate update = up.getUpdate();
        final FormattedValueDMContext valueDmc = up.getValueDmc();

        /*
         *  It is possible that we could not get a formatted DMC. In this case the setup
         *  logic puts a null as the value. So in this case we just complete this one
         *  with nothing.
         */
        if (valueDmc == null) {
            update.done();
            continue;
        }

        final int idx = up.getIndex();

        getDMVMProvider().getModelData(RegisterVMNode.this, update, regService, valueDmc,
                new ViewerDataRequestMonitor<FormattedValueDMData>(getSession().getExecutor(), update) {
                    @Override
                    public void handleCompleted() {
                        if (!isSuccess()) {
                            if (getStatus().getCode() == IDsfStatusConstants.INVALID_STATE) {
                                update.setLabel("...", idx); //$NON-NLS-1$
                            } else {
                                update.setLabel("Error: " + getStatus().getMessage(), idx); //$NON-NLS-1$
                            }
                            update.setFontData(JFaceResources
                                    .getFontDescriptor(IInternalDebugUIConstants.VARIABLE_TEXT_FONT)
                                    .getFontData()[0], idx);
                            update.done();
                            return;
                        }
                        /*
                         *  Fill the label/column with the properly formatted data value.
                         */
                        update.setLabel(getData().getFormattedValue(), idx);

                        // color based on change history
                        FormattedValueDMData oldData = (FormattedValueDMData) getDMVMProvider()
                                .getArchivedModelData(RegisterVMNode.this, update, valueDmc);
                        if (oldData != null
                                && !oldData.getFormattedValue().equals(getData().getFormattedValue())) {
                            update.setBackground(DebugUIPlugin
                                    .getPreferenceColor(IInternalDebugUIConstants.PREF_CHANGED_VALUE_BACKGROUND)
                                    .getRGB(), idx);
                        }
                        update.setFontData(
                                JFaceResources.getFontDescriptor(IInternalDebugUIConstants.VARIABLE_TEXT_FONT)
                                        .getFontData()[0],
                                idx);
                        update.done();
                    }
                }, getSession().getExecutor());
    }
}