Package com.google.gdt.eclipse.designer.uibinder.gefTree

Source Code of com.google.gdt.eclipse.designer.uibinder.gefTree.EditPartFactory

/*******************************************************************************
* Copyright 2011 Google Inc. All Rights Reserved.
*
* 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
*
* 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.google.gdt.eclipse.designer.uibinder.gefTree;

import com.google.common.collect.ImmutableList;
import com.google.gdt.eclipse.designer.uibinder.gefTree.part.UiChildPositionEditPart;
import com.google.gdt.eclipse.designer.uibinder.model.util.UiChildSupport;

import org.eclipse.wb.core.gef.MatchingEditPartFactory;
import org.eclipse.wb.gef.core.EditPart;
import org.eclipse.wb.gef.core.IEditPartFactory;

/**
* {@link IEditPartFactory} for GWT UiBinder.
*
* @author scheglov_ke
* @coverage GWT.UiBinder.gefTree
*/
public final class EditPartFactory implements IEditPartFactory {
  private final IEditPartFactory[] FACTORIES = {MATCHING_FACTORY};
  private final static IEditPartFactory MATCHING_FACTORY =
      new MatchingEditPartFactory(ImmutableList.of("com.google.gdt.eclipse.designer.uibinder.model.widgets"),
          ImmutableList.of("com.google.gdt.eclipse.designer.uibinder.gefTree.part"));

  ////////////////////////////////////////////////////////////////////////////
  //
  // IEditPartFactory
  //
  ////////////////////////////////////////////////////////////////////////////
  public EditPart createEditPart(EditPart context, Object model) {
    for (IEditPartFactory factory : FACTORIES) {
      EditPart editPart = factory.createEditPart(null, model);
      if (editPart != null) {
        return editPart;
      }
    }
    if (model instanceof UiChildSupport.Position) {
      return new UiChildPositionEditPart((UiChildSupport.Position) model);
    }
    return null;
  }
}
TOP

Related Classes of com.google.gdt.eclipse.designer.uibinder.gefTree.EditPartFactory

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.