org.chromium.debug.core/src/org/chromium/debug/core/model/BreakpointAdapterFactory.java
changeset 2 e4420d2515f1
child 52 f577ea64429e
equal deleted inserted replaced
1:ef76fc2ac88c 2:e4420d2515f1
       
     1 // Copyright (c) 2009 The Chromium Authors. All rights reserved.
       
     2 // Use of this source code is governed by a BSD-style license that can be
       
     3 // found in the LICENSE file.
       
     4 
       
     5 package org.chromium.debug.core.model;
       
     6 
       
     7 import org.chromium.debug.core.util.ChromiumDebugPluginUtil;
       
     8 import org.eclipse.core.resources.IResource;
       
     9 import org.eclipse.core.runtime.IAdapterFactory;
       
    10 import org.eclipse.debug.ui.actions.IToggleBreakpointsTarget;
       
    11 import org.eclipse.ui.texteditor.ITextEditor;
       
    12 
       
    13 /**
       
    14  * Factory of LineBreakpointAdapters for browser scripts.
       
    15  */
       
    16 public class BreakpointAdapterFactory implements IAdapterFactory {
       
    17 
       
    18   @SuppressWarnings("unchecked")
       
    19   public Object getAdapter(Object adaptableObject, Class adapterType) {
       
    20     if (adaptableObject instanceof ITextEditor) {
       
    21       ITextEditor editorPart = (ITextEditor) adaptableObject;
       
    22       IResource resource =
       
    23           (IResource) editorPart.getEditorInput().getAdapter(IResource.class);
       
    24       if (resource != null) {
       
    25         String extension = resource.getFileExtension();
       
    26         if (extension != null && ChromiumDebugPluginUtil.CHROMIUM_EXTENSION.equals(extension)) {
       
    27           return new LineBreakpointAdapter();
       
    28         }
       
    29       }
       
    30     }
       
    31     return null;
       
    32   }
       
    33 
       
    34   @SuppressWarnings("unchecked")
       
    35   public Class[] getAdapterList() {
       
    36     return new Class[] { IToggleBreakpointsTarget.class };
       
    37   }
       
    38 }