com.mercatis.lighthouse3.ui.environment.model.adapters.LocationWorkbenchAdapter.java Source code

Java tutorial

Introduction

Here is the source code for com.mercatis.lighthouse3.ui.environment.model.adapters.LocationWorkbenchAdapter.java

Source

/*
 * Copyright 2011 mercatis Technologies AG
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *     http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.mercatis.lighthouse3.ui.environment.model.adapters;

import org.eclipse.core.runtime.Platform;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.ui.model.IWorkbenchAdapter;

import com.mercatis.lighthouse3.ui.environment.base.adapters.HierarchicalEntityAdapter;
import com.mercatis.lighthouse3.ui.environment.base.model.Location;

public class LocationWorkbenchAdapter implements IWorkbenchAdapter {

    /* (non-Javadoc)
     * @see org.eclipse.ui.model.IWorkbenchAdapter#getChildren(java.lang.Object)
     */
    public Object[] getChildren(Object adaptee) {
        return ((HierarchicalEntityAdapter) Platform.getAdapterManager().getAdapter(adaptee,
                HierarchicalEntityAdapter.class)).getChildren(adaptee);
    }

    /* (non-Javadoc)
     * @see org.eclipse.ui.model.IWorkbenchAdapter#getImageDescriptor(java.lang.Object)
     */
    public ImageDescriptor getImageDescriptor(Object adaptee) {
        return ImageDescriptor.createFromURL(getClass().getResource("/icons/location.png"));
    }

    /* (non-Javadoc)
     * @see org.eclipse.ui.model.IWorkbenchAdapter#getLabel(java.lang.Object)
     */
    public String getLabel(Object adaptee) {
        Location location = (Location) adaptee;
        return location.getLabel();
    }

    /* (non-Javadoc)
     * @see org.eclipse.ui.model.IWorkbenchAdapter#getParent(java.lang.Object)
     */
    public Object getParent(Object adaptee) {
        return ((HierarchicalEntityAdapter) Platform.getAdapterManager().getAdapter(adaptee,
                HierarchicalEntityAdapter.class)).getParent(adaptee);
    }

}