/******************************************************************************* * Copyright (c) 2007, 2008 Edgar Espina. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * *******************************************************************************/ package org.deved.antlride.internal.debug.ui.breakpoints; import org.deved.antlride.core.AntlrConstants; import org.eclipse.core.resources.IResource; import org.eclipse.core.runtime.IAdapterFactory; import org.eclipse.debug.ui.actions.IToggleBreakpointsTarget; import org.eclipse.ui.texteditor.ITextEditor; public class AntlrEditorAdapterFactory implements IAdapterFactory { @SuppressWarnings("unchecked") public Object getAdapter(Object adaptableObject, Class adapterType) { if (adaptableObject instanceof ITextEditor) { ITextEditor editorPart = (ITextEditor) adaptableObject; IResource resource = (IResource) editorPart.getEditorInput().getAdapter(IResource.class); if (resource != null) { String extension = resource.getFileExtension(); if (extension != null && extension.equals(AntlrConstants.ANTLR_GRAMMAR_FILE_EXTENSION)) { if (adapterType.equals(IToggleBreakpointsTarget.class)) { return new AntlrBreakpointAdapter(); } } } } return null; } @SuppressWarnings("unchecked") public Class[] getAdapterList() { return new Class[]{IToggleBreakpointsTarget.class}; } }