Java 类org.eclipse.ui.views.properties.IPropertySource2 实例源码

项目:PDFReporter-Studio    文件:ResetValueCommand.java   
/**
 * Returns <code>true</code> IFF:<br>
 * 1) the target and property have been specified<br>
 * 2) the property has a default value<br>
 * 3) the value set for that property is not the default.
 * 
 * @return true, if successful
 * @see org.eclipse.gef.commands.Command#canExecute()
 */
@Override
public boolean canExecute() {
    boolean answer = false;
    if (target != null && propertyName != null) {
        answer = target.isPropertySet(propertyName);
        if (target instanceof IPropertySource2)
            answer = answer && (((IPropertySource2) target).isPropertyResettable(propertyName));
    }
    return answer;
}
项目:PDFReporter-Studio    文件:RepositoryView.java   
@SuppressWarnings("rawtypes")
@Override
public Object getAdapter(Class type) {
    if (type == IPropertySource.class)
        return getPropertySheetPage();
    if (type == IPropertySource2.class)
        return getPropertySheetPage();
    if (type == IPropertySheetPage.class)
        return getPropertySheetPage();
    return super.getAdapter(type);
}
项目:PDFReporter-Studio    文件:ReportContainer.java   
@Override
public Object getAdapter(@SuppressWarnings("rawtypes") Class type) {
    if (type == IPropertySource.class)
        return getPropertySheetPage();
    if (type == IPropertySource2.class)
        return getPropertySheetPage();
    if (type == IPropertySheetPage.class)
        return getPropertySheetPage();
    return super.getAdapter(type);
}
项目:gef-gwt    文件:SetPropertyValueCommand.java   
/**
 * @see org.eclipse.gef.commands.Command#execute()
 */
public void execute() {
    /*
     * Fix for bug #54250 IPropertySource.isPropertySet(String) returns
     * false both when there is no default value, and when there is a
     * default value and the property is set to that value. To correctly
     * determine if a reset should be done during undo, we compare the
     * return value of isPropertySet(String) before and after
     * setPropertyValue(...) is invoked. If they are different (it must have
     * been false before and true after -- it cannot be the other way
     * around), then that means we need to reset.
     */
    boolean wasPropertySet = propertySource.isPropertySet(propertyId);
    oldValue = unwrapValue(propertySource.getPropertyValue(propertyId));

    // set value of property to new value or reset the value, if specified
    if (newValue == DEFAULT_VALUE) {
        propertySource.resetPropertyValue(propertyId);
    } else {
        propertySource.setPropertyValue(propertyId, unwrapValue(newValue));
    }

    // check if property was set to its default value before (so it will
    // have to be resetted during undo); note that if the new value is
    // DEFAULT_VALUE the old value may not have been the default value as
    // well, as the command would not be executable in this case.
    if (propertySource instanceof IPropertySource2) {
        if (!wasPropertySet
                && ((IPropertySource2) propertySource)
                        .isPropertyResettable(propertyId)) {
            oldValue = DEFAULT_VALUE;
        }
    } else {
        if (!wasPropertySet && propertySource.isPropertySet(propertyId)) {
            oldValue = DEFAULT_VALUE;
        }
    }
}