Пример #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;
  }
Пример #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;
  }
Пример #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();
  }
Пример #4
0
 public boolean isValid() {
   return myFile.isValid();
 }
Пример #5
0
 public boolean isValid() {
   return myFile.isValid() && myIsValid && !myDisposed;
 }