2017-05-26 342 views
0

我想建立一個基於GEF5一句Visualiser的接口,這種接口將有2個部分:E4 RCP + GEF5應用實施

  1. 輸入部分 - 在那裏你可以把你的句子,
  2. 輸出部分,這將展示GEF5圖

組織這些部件的最簡單的方法是使用E4 RCP,因爲他們可以有單獨的javafx..Panes

這裏是交易,E4 RCP使用零件作爲分離javafx..BorderPanes

public class DictionaryPart { 
    @PostConstruct 
    void initUI(BorderPane pane) { 
     try { 
      TextArea textbox = new TextArea(); 
      pane.setCenter(textbox); 
     } 
     catch (Exception e) 
     { 
      e.printStackTrace(); 
     } 
    } 
} 

然而,GEF5實例包括使用javafx..Stage和IViewer接口簡單的應用程序實現。

public void start(final Stage primaryStage) throws Exception { 
     // create graph 
     graph = createGraph(); 

     // configure application 
     Injector injector = Guice.createInjector(createModule()); 
     domain = injector.getInstance(IDomain.class); 
     viewer = domain.getAdapter(
       AdapterKey.get(IViewer.class, IDomain.CONTENT_VIEWER_ROLE)); 
     primaryStage.setScene(createScene(viewer)); 

     primaryStage.setResizable(true); 
     primaryStage.setWidth(getStageWidth()); 
     primaryStage.setHeight(getStageHeight()); 
     primaryStage.setTitle(title); 
     primaryStage.show(); 

     // activate domain only after viewers have been hooked 
     domain.activate(); 

     // set contents in the JavaFX application thread because it alters the 
     // scene graph 
     Platform.runLater(new Runnable() { 
      @Override 
      public void run() { 
       viewer.getContents().setAll(Collections.singletonList(graph)); 
      } 
     }); 
    } 

    protected Scene createScene(IViewer viewer) { 
     return new Scene(((IViewer) viewer).getCanvas()); 
    } 

從我的第二類描述部分的這段代碼在我的應用程序前面帶來舞臺,當我只需要一個窗格時。

我只是不明白我如何正確實施GEF5到E4?是否有任何教程免除GEF文檔?

UPD:發現GEF4 MVC徽標示例轉換爲e4 RCP應用程序,但已過時。

回答

0

迫使它這樣的工作:

@PostConstruct 
void initUIPane(BorderPane pane){ 
    graph = createGraph(); 
    // configure application 
    Injector injector = Guice.createInjector(createModule()); 
    domain = injector.getInstance(IDomain.class); 
    viewer = domain.getAdapter(AdapterKey.get(IViewer.class, IDomain.CONTENT_VIEWER_ROLE)); 
    InfiniteCanvas canvas = (InfiniteCanvas)viewer.getCanvas(); 
    pane.setCenter(canvas); 
    canvas.sceneProperty().addListener((observable, oldValue, newValue) -> { 
     if (canvas.getScene() != null) { 
     domain.activate(); 
     try { 
      viewer.getContents().setAll(Collections.singletonList(graph)); 
     } catch (Exception e) { 
      e.printStackTrace(); 
     } 
     } 
    }); 
}