Java Code Examples for org.eclipse.core.resources.IFile#getPersistentProperty()

The following examples show how to use org.eclipse.core.resources.IFile#getPersistentProperty() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: OriginalEditorSelector.java    From xtext-eclipse with Eclipse Public License 2.0 6 votes vote down vote up
public IEditorDescriptor findXbaseEditor(IEditorInput editorInput, boolean ignorePreference) {
	IFile file = ResourceUtil.getFile(editorInput);
	if (file == null)
		return null;
	if (!ignorePreference) {
		if (file.exists()) {
			try {
				String favoriteEditor = file.getPersistentProperty(IDE.EDITOR_KEY);
				if (favoriteEditor != null)
					return null;
			} catch (CoreException e) {
				logger.debug(e.getMessage(), e);
			}
		}
	}
	// TODO stay in same editor if local navigation
	Decision decision = decisions.decideAccordingToCaller();
	if (decision == Decision.FORCE_JAVA) {
		return null;
	}
	IEclipseTrace traceToSource = traceInformation.getTraceToSource(file);
	return getXtextEditor(traceToSource);
}
 
Example 2
Source File: EditorInputPropertyTester.java    From tracecompass with Eclipse Public License 2.0 6 votes vote down vote up
@Override
public boolean test(Object receiver, String property, Object[] args, Object expectedValue) {

    if (IS_EXPERIMENT_EDITOR_INPUT.equals(property)) {
        if (receiver instanceof IFileEditorInput) {
            IFileEditorInput editorInput = (IFileEditorInput) receiver;
            IFile file = editorInput.getFile();
            if (file != null) {
                try {
                    final String traceTypeId = file.getPersistentProperty(TmfCommonConstants.TRACETYPE);
                    if (traceTypeId != null && ITmfEventsEditorConstants.EXPERIMENT_INPUT_TYPE_CONSTANTS.contains(traceTypeId)) {
                        return true;
                    }
                } catch (CoreException e) {
                    // Ignore
                }
            }
        }
    }
    return false;
}