Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 8e5eddcd81320af6e7c3fb87dd2d9816f28a4e5c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
/*
 * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
 * 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
 * 
 * Contributors:
 *    Martin Fluegge - initial API and implementation
 */
package org.eclipse.emf.cdo.dawn.codegen.dawngenmodel.editor.registry;

import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.core.runtime.Platform;
import org.eclipse.ui.IEditorPart;

import java.util.ArrayList;
import java.util.List;

/**
 * @author Martin Fluegge
 * @since 1.0
 */
public class DawnGenModelEditorRegistry
{
  private static final String EXTENSION_POINT_ID = "org.eclipse.emf.cdo.dawn.genmodel.ui.editors";

  public static DawnGenModelEditorRegistry instance = new DawnGenModelEditorRegistry();

  public List<EditorExtension> getRegisteredEditors() throws CoreException
  {
    List<EditorExtension> editors = new ArrayList<EditorExtension>();
    IConfigurationElement[] config = Platform.getExtensionRegistry().getConfigurationElementsFor(EXTENSION_POINT_ID);
    for (IConfigurationElement e : config)
    {
      IEditorPart editorPart = (IEditorPart)e.createExecutableExtension("editor");
      String fileExtension = e.getAttribute("file_extension");
      editors.add(new EditorExtension(editorPart, fileExtension));
    }
    return editors;
  }

  /**
   * @author Martin Fluegge
   */
  public static class EditorExtension
  {
    private IEditorPart editorPart;

    private String fileExtension;

    public EditorExtension(IEditorPart editorPart, String fileExtension)
    {
      this.editorPart = editorPart;
      this.fileExtension = fileExtension;
    }

    public IEditorPart getEditorPart()
    {
      return editorPart;
    }

    public String getFileExtension()
    {
      return fileExtension;
    }
  }
}

Back to the top