Exemplo n.º 1
0
  @NotNull
  protected IOperationContext createOperationContext() {
    if (myContext != null) {
      return myContext;
    }

    assert isValid()
        : "createOperationContext() was called for MPSFileNodeEditor with invalid file: " + myFile;
    SModelDescriptor sm = myFile.getNode().getModel().getModelDescriptor();
    assert sm != null : "Model descriptor is null for model: " + myFile.getNode().getModel();

    IOperationContext result =
        new ModuleContext(sm.getModule(), ProjectHelper.toMPSProject(myProject));
    assert result.getModule() == sm.getModule()
        : "Different modules: " + result.getModule() + "/" + sm.getModule();
    return result;
  }
Exemplo n.º 2
0
  protected IOperationContext createOperationContext() {
    if (myContext != null) {
      return myContext;
    }

    assert isValid()
        : "createOperationContext() was called for MPSFileNodeEditor with invalid file: " + myFile;
    SNode node = myFile.getNode();
    if (node == null || node.getModel() == null || node.getModel().getModelDescriptor() == null) {
      myIsValid = false;
      return null;
    }
    SModelDescriptor sm = node.getModel().getModelDescriptor();

    IOperationContext result =
        new ModuleContext(sm.getModule(), ProjectHelper.toMPSProject(myProject));
    assert result.getModule() == sm.getModule()
        : "Different modules: " + result.getModule() + "/" + sm.getModule();
    return result;
  }
Exemplo n.º 3
0
  public void recreateEditor() {
    if (myProject.isDisposed() || !isValid()) return;
    // if (myNodeEditor instanceof NodeEditor) return;

    myComponent.removeAll();

    FileEditorState state = myNodeEditor != null ? getState(FileEditorStateLevel.FULL) : null;

    IOperationContext context = createOperationContext();
    Editor oldNodeEditor = myNodeEditor;
    myNodeEditor = new MPSEditorOpener(myProject).createEditorFor(context, myFile.getNode());
    if (oldNodeEditor != null) {
      oldNodeEditor.dispose();
    }

    if (state != null) {
      setState(state);
    }

    myComponent.add(((BaseNodeEditor) myNodeEditor).getComponent(), BorderLayout.CENTER);
    myComponent.validate();
  }
Exemplo n.º 4
0
 public boolean isValid() {
   return myFile.isValid();
 }
Exemplo n.º 5
0
 public boolean isValid() {
   return myFile.isValid() && myIsValid && !myDisposed;
 }