Package org.woped.editor.controller.vc

Examples of org.woped.editor.controller.vc.EditorVC


  private boolean closeEditor(IEditor editor)
  {
    boolean closeEditor = false;
    if (editor instanceof EditorVC)
    {
      EditorVC editorVC = (EditorVC) editor;
      if ((editor instanceof SubprocessEditorVC) && !editorVC.isTokenGameEnabled())
      {

        IQualanalysisService qualanService = QualAnalysisServiceFactory.createNewQualAnalysisService(editor);
               
        String inputID = ((SubprocessEditorVC)editor).getSubprocessInput().getId();
        String outputID = ((SubprocessEditorVC)editor).getId();

        // Try to get the first source place of the model as well as the
        // first sink place
        // Note that there is a chance neither a source nor a sink actually exist
        // so we need to check whether the iterator is valid!!
        String ainputID = null;
        String aoutputID = null;
        Iterator<AbstractPetriNetElementModel> i = qualanService.getSinkPlaces().iterator();
        if (i.hasNext())
          ainputID = ((AbstractPetriNetElementModel) i.next()).getId();
        i = qualanService.getSourcePlaces().iterator();
        if (i.hasNext())
          aoutputID = ((AbstractPetriNetElementModel) i.next()).getId();
       
        if (qualanService.getNotStronglyConnectedNodes().size() > 0
            || qualanService.getSinkPlaces().size() > 1
            || qualanService.getSourcePlaces().size() > 1
            || inputID.equals(ainputID)
            || outputID.equals(aoutputID))
        {
          String errorMessage = Messages
              .getString("Action.CloseSubProcessEditor.StructuralAnalysisResult.Message.Start");

          if (qualanService.getNotStronglyConnectedNodes().size() > 0)
          {
            errorMessage += Messages
                .getString("Action.CloseSubProcessEditor.StructuralAnalysisResult.Message.StronglyConnected");
          }
          if (qualanService.getSourcePlaces().size() > 1)
          {
            errorMessage += Messages
                .getString("Action.CloseSubProcessEditor.StructuralAnalysisResult.Message.Source");
          } else
          {
            if (inputID.equals(ainputID))
            {
              errorMessage += Messages
              .getString("Action.CloseSubProcessEditor.StructuralAnalysisResult.Message.Input");
            }
          }

          if (qualanService.getSinkPlaces().size() > 1)
          {
            errorMessage += Messages
                .getString("Action.CloseSubProcessEditor.StructuralAnalysisResult.Message.Sink");
          } else
          {
            if (outputID.equals(aoutputID))
            {
              errorMessage += Messages
              .getString("Action.CloseSubProcessEditor.StructuralAnalysisResult.Message.Output");
            }
          }

          errorMessage += Messages
              .getString("Action.CloseSubProcessEditor.StructuralAnalysisResult.Message.End");

          String textMessages[] = {   Messages.getString("Dialog.Yes"),
                        Messages.getString("Dialog.No")
            };

          int value = JOptionPane.showOptionDialog(editorVC.getEditorPanel(),
                  errorMessage,
                  Messages.getString("Action.CloseSubProcessEditor.StructuralAnalysisResult.Title"),
                  JOptionPane.YES_NO_OPTION,
                  JOptionPane.WARNING_MESSAGE,
                  null,
                  textMessages,
                  textMessages[0]);

          if (value == JOptionPane.YES_OPTION)
          {
            closeEditor = true;
          }

        } else
        {
          closeEditor = true;
        }
      }
      else if(editorVC.isSubprocessEditor() && editorVC.isTokenGameEnabled())
      {
        closeEditor = true;
      }
      else
      {
        if (!editorVC.isSaved())
        {
          // Check sample net
          if (editorVC.getDefaultFileType() != FileFilterImpl.SAMPLEFilter)
          {
            String args[] = { editorVC.getName() };

            String textMessages[] = {   Messages.getString("Dialog.Yes"),
                          Messages.getString("Dialog.No"),
                          Messages.getString("Dialog.Cancel")
            };

            int value = JOptionPane.showOptionDialog(editorVC.getEditorPanel(),
                Messages
                .getStringReplaced(
                    "Action.Confirm.File.Save.Text",
                    args),
                Messages.getString("Action.Confirm.File.Save.Title"),
                JOptionPane.YES_NO_CANCEL_OPTION,
                JOptionPane.ERROR_MESSAGE,
                null,
                textMessages,
                textMessages[0]);

            if (value == (JOptionPane.YES_OPTION))
            {
              // try to save
              getMediator()
                  .processViewEvent(
                      new ViewEvent(
                          editor,
                          AbstractViewEvent.VIEWEVENTTYPE_FILE,
                          AbstractViewEvent.SAVE));
              closeEditor = editorVC.isSaved();
            } else if (value == JOptionPane.NO_OPTION)
            {
              closeEditor = true;
            } else if (value == JOptionPane.CANCEL_OPTION)
            {
View Full Code Here


  }
 
  protected void checkSidebar()
  {
    boolean status = false;
    EditorVC editor = ((EditorVC)(am.getUi().getEditorFocus()));
   
    status = (editor == null) ? false : editor.getEditorPanel().isOverviewPanelVisible();
    setStatus(OVERVIEW_VISIBLE, status);
   
    status = (editor == null) ? false : editor.getEditorPanel().isTreeviewPanelVisible();
    setStatus(TREEVIEW_VISIBLE, status);
  }
View Full Code Here

    // ! Create a new editor window and register it with all visual controllers
    // ! @param undoSupport if set to true undo support is to be enabled
    // ! @return reference to new editor object
    @Override
    public IEditor createEditor(boolean undoSupport, boolean loadUI) {
        EditorVC editor = new EditorVC(EditorVC.ID_PREFIX + editorCounter, clipboard, undoSupport,
                this, loadUI);
        addViewController(editor);
        if(loadUI){
//          editor.getGraph().addMouseListener(visualController);

          editor.setName(Messages.getString("Document.Title.Untitled") + " - " + newEditorCounter++);
          // notify the editor aware vc
          Iterator<?> editorIter = getEditorAwareVCs().iterator();
          while (editorIter.hasNext()) {
              ((IEditorAware) editorIter.next()).addEditor(editor);
          }
          VisualController.getInstance()
                  .propertyChange(new PropertyChangeEvent(this, "InternalFrameCount", null, editor));
        }
        editor.setSaved(true);
        return editor;
    }
View Full Code Here

    super(vepID, mediator);
  }

  public void processViewEvent(AbstractViewEvent event)
  {
    EditorVC editor;
    if (event.getSource() instanceof EditorVC)
    {
      editor = (EditorVC) event.getSource();
    }
    else
    {
      editor = (EditorVC) getMediator().getUi().getEditorFocus();
    }
    Object cell;
    ArcModel anArc;
    Iterator<String> anIter;
    if (editor != null)
    {
      CreationMap map = CreationMap.createMap();
      if (editor.getLastMousePosition() != null)
      {
        map.setPosition((int)(editor.getLastMousePosition().getX() / editor.getGraph().getScale()),
                (int)(editor.getLastMousePosition().getY() / editor.getGraph().getScale()));               
      }

      switch (event.getOrder())
      {
      // Petrinet
      case AbstractViewEvent.ADD_PLACE:
        map.setType(AbstractPetriNetElementModel.PLACE_TYPE);
        editor.create(map);
        break;
      case AbstractViewEvent.ADD_TRANSITION:
        map.setType(AbstractPetriNetElementModel.TRANS_SIMPLE_TYPE);
        editor.create(map);
        break;
      case AbstractViewEvent.ADD_ANDJOIN:
        map.setType(AbstractPetriNetElementModel.TRANS_OPERATOR_TYPE);
        map.setOperatorType(OperatorTransitionModel.AND_JOIN_TYPE);
        editor.create(map);
        break;
      case AbstractViewEvent.ADD_ANDSPLIT:
        map.setType(AbstractPetriNetElementModel.TRANS_OPERATOR_TYPE);
        map.setOperatorType(OperatorTransitionModel.AND_SPLIT_TYPE);
        editor.create(map);
        break;
      case AbstractViewEvent.ADD_ANDSPLITJOIN:
        map.setType(AbstractPetriNetElementModel.TRANS_OPERATOR_TYPE);
        map.setOperatorType(OperatorTransitionModel.AND_SPLITJOIN_TYPE);
        editor.create(map);
        break;
      case AbstractViewEvent.ADD_XORJOIN:
        map.setType(AbstractPetriNetElementModel.TRANS_OPERATOR_TYPE);
        map.setOperatorType(OperatorTransitionModel.XOR_JOIN_TYPE);
        editor.create(map);
        break;
      case AbstractViewEvent.ADD_XORSPLIT:
        map.setType(AbstractPetriNetElementModel.TRANS_OPERATOR_TYPE);
        map.setOperatorType(OperatorTransitionModel.XOR_SPLIT_TYPE);
        editor.create(map);
        break;
      case AbstractViewEvent.ADD_XORSPLITJOIN:
        map.setType(AbstractPetriNetElementModel.TRANS_OPERATOR_TYPE);
        map.setOperatorType(OperatorTransitionModel.XOR_SPLITJOIN_TYPE);
        editor.create(map);
        break;
      case AbstractViewEvent.ADD_ANDJOINXORSPLIT:
        map.setType(AbstractPetriNetElementModel.TRANS_OPERATOR_TYPE);
        map.setOperatorType(OperatorTransitionModel.ANDJOIN_XORSPLIT_TYPE);
        editor.create(map);
        break;
      case AbstractViewEvent.ADD_XORJOINANDSPLIT:
        map.setType(AbstractPetriNetElementModel.TRANS_OPERATOR_TYPE);
        map.setOperatorType(OperatorTransitionModel.XORJOIN_ANDSPLIT_TYPE);
        editor.create(map);
        break;
      // General
      case AbstractViewEvent.RENAME:
        cell = editor.getGraph().getSelectionCell();
        if (cell instanceof TriggerModel)
        {
          cell = ((TriggerModel) cell).getParent();
        }
        if (cell instanceof GroupModel)
        {
          cell = ((GroupModel) cell).getMainElement();
        }
        editor.edit(cell);
        break;
      case AbstractViewEvent.REMOVE:
        editor.deleteSelection();
        break;
      case AbstractViewEvent.CUT:
        editor.cutSelection();
        break;
      case AbstractViewEvent.COPY:
        editor.copySelection();
        break;
      case AbstractViewEvent.PASTE:
        editor.paste();
        break;
      case AbstractViewEvent.PASTE_AT:
        editor.pasteAtMousePosition();
        break;
      case AbstractViewEvent.REDO:
        editor.redo();
        break;
      case AbstractViewEvent.UNDO:
        editor.undo();
        break;
      case AbstractViewEvent.UNGROUP:
        editor.getGraph().ungroupSelection();
        break;
      case AbstractViewEvent.GROUP:
        editor.getGraph().groupSelection();
        break;
      case AbstractViewEvent.OPEN_PROPERTIES:
        cell = editor.getGraph().getSelectionCell();
        AbstractPetriNetElementModel element = null;

        if (cell instanceof ArcModel && ((ArcModel) cell).isXORsplit(editor.getModelProcessor()))
        {
          new ArcPropertyEditor((JFrame) getMediator().getUi(), (Point)editor.getLastMousePosition(), (ArcModel) cell, editor);
        }

        if (cell instanceof TriggerModel)
        {
          cell = ((TriggerModel) cell).getParent();
        }
        if (cell instanceof GroupModel)
        {
          element = ((GroupModel) cell).getMainElement();
        }
        else if (cell instanceof AbstractPetriNetElementModel)
        {
          element = (AbstractPetriNetElementModel) cell;
        }
        if (element != null)
        {
          if (element instanceof TransitionModel)
          {
            new TransitionPropertyEditor((JFrame) getMediator()
                .getUi(), (Point)editor.getLastMousePosition(), (TransitionModel)element, editor);

          }
          if (element instanceof PlaceModel)
          {
            new PlacePropertyEditor((JFrame) getMediator().getUi(), (Point)editor.getLastMousePosition(), (PlaceModel)element, editor);
          }
        }
        break;
      case AbstractViewEvent.ADD_POINT:
        editor.addPointToSelectedArc();
        break;
      case AbstractViewEvent.REMOVE_POINT:
        editor.removeSelectedPoint();
        break;
      case AbstractViewEvent.ADD_EXT_TRIGGER:
        cell = editor.getGraph().getSelectionCell();
        removeResources(editor, cell);
        editor.createTrigger(getCreateTriggerMap(editor.getGraph().getSelectionCell(),
            TriggerModel.TRIGGER_MESSAGE));
        break;
      case AbstractViewEvent.ADD_RES_TRIGGER:
        editor.createTrigger(getCreateTriggerMap(editor.getGraph().getSelectionCell(),
            TriggerModel.TRIGGER_RESOURCE));
        break;
      case AbstractViewEvent.ADD_TIME_TRIGGER:
        cell = editor.getGraph().getSelectionCell();
        removeResources(editor, cell);
        editor.createTrigger(getCreateTriggerMap(editor.getGraph().getSelectionCell(),
            TriggerModel.TRIGGER_TIME));
        break;
      case AbstractViewEvent.REMOVE_TRIGGER:
        cell = editor.getGraph().getSelectionCell();
        removeResources(editor, cell);
        if (cell instanceof GroupModel)
        {
          cell = ((GroupModel) cell).getMainElement();
        }
        if (cell instanceof TransitionModel)
        {
          editor.deleteCell(((TransitionModel) cell).getToolSpecific().getTrigger(), true);
        }
        break;
      case AbstractViewEvent.ADD_SUBPROCESS:
        editor.createElement(AbstractPetriNetElementModel.SUBP_TYPE, -1, editor.getLastMousePosition(), false);
        break;
      case AbstractViewEvent.ROUTING_ACTIVE:
        cell = editor.getGraph().getSelectionCell();
        ((ArcModel) cell).setRoute(true);
        editor.getGraph().connect(((ArcModel) cell), true);
        break;
      case AbstractViewEvent.ROUTING_DEACTIVE:
        cell = editor.getGraph().getSelectionCell();
        ((ArcModel) cell).setRoute(false);
        editor.getGraph().connect(((ArcModel) cell), true);
        break;
      case AbstractViewEvent.ROUTING_ALL_ACTIVE:
        anIter = editor.getModelProcessor().getElementContainer().getArcMap().keySet().iterator();

        while (anIter.hasNext())
        {
          anArc = editor.getModelProcessor().getElementContainer().getArcById(anIter.next());
          anArc.setRoute(true);
          editor.getGraph().connect(anArc, true);
        }
        editor.updateNet();
        break;
      case AbstractViewEvent.ROUTING_ALL_DEACTIVE:
        anIter = editor.getModelProcessor().getElementContainer().getArcMap().keySet().iterator();
        while (anIter.hasNext())
        {
          anArc = editor.getModelProcessor().getElementContainer().getArcById(anIter.next());
          anArc.setRoute(false);
          editor.getGraph().connect(anArc, true);
        }
        editor.updateNet();
        break;
      case AbstractViewEvent.ADD_TOKEN:
        if ((cell = editor.getGraph().getSelectionCell()) instanceof GroupModel)
        {
          cell = ((GroupModel) cell).getMainElement();
        }
        if (cell instanceof PlaceModel)
        {
          ((PlaceModel) cell).addToken();
        }
        editor.updateNet();
        editor.getEditorPanel().autoRefreshAnalysisBar();
        editor.setSaved(false);
        break;
      case AbstractViewEvent.REMOVE_TOKEN:
        if ((cell = editor.getGraph().getSelectionCell()) instanceof GroupModel)
        {
          cell = ((GroupModel) cell).getMainElement();
        }
        if (cell instanceof PlaceModel)
        {
          ((PlaceModel) cell).removeToken();
        }
        editor.updateNet();
        editor.getEditorPanel().autoRefreshAnalysisBar();
        editor.setSaved(false);
        break;
      case AbstractViewEvent.ZOOM_IN:
        editor.zoom(0.1, false);
        break;
      case AbstractViewEvent.ZOOM_OUT:
        editor.zoom(-0.1, false);
        break;
      case AbstractViewEvent.ZOOM_ABSOLUTE:
        editor.zoom(Integer.parseInt((String) event.getData()), true);
        break;
      case AbstractViewEvent.COLORING:
        editor.toggleUnderstandColoring();       
        break;
      case AbstractViewEvent.OPEN_TOKENGAME:
        editor.toggleTokenGame();
        break;
      case AbstractViewEvent.CLOSE_TOKENGAME:
        editor.terminateTokenGameSession();
        break;
      case AbstractViewEvent.SHOWSIDEBAR:
        // Toggle visibility of side tree view
        editor.getEditorPanel().setSideTreeViewVisible(!editor.getEditorPanel().isSideTreeViewVisible());
        break;
      case AbstractViewEvent.SHOWOVERVIEW:
        // visbility of overview panel
        editor.getEditorPanel().setOverviewPanelVisible(!editor.getEditorPanel().isOverviewPanelVisible());
        break;
      case AbstractViewEvent.SHOWTREEVIEW:
        // visibility of elements tree panel
        editor.getEditorPanel().setTreeviewPanelVisible(!editor.getEditorPanel().isTreeviewPanelVisible());
        break;
      case AbstractViewEvent.PRESS:
        editor.scaleNet(0.5);
        break;
      case AbstractViewEvent.STRETCH:
        editor.scaleNet(2);
        break;
      case AbstractViewEvent.ROTATEVIEW:
        editor.getEditorPanel().rotateLayout(editor);
        break
      case AbstractViewEvent.ROTATETRANSLEFT:
        cell = editor.getGraph().getSelectionCell();
        if (cell instanceof TriggerModel)
        {
          cell = ((TriggerModel) cell).getParent();
        }
        if (cell instanceof GroupModel)
        {
          cell = ((GroupModel) cell).getMainElement();
        }
        //TODO auf die Methoden von Orientation zugreifen, nicht von EditorVC
        editor.rotateTransLeft(cell);
        break;
      case AbstractViewEvent.ROTATETRANSRIGHT:
        cell = editor.getGraph().getSelectionCell();
        if (cell instanceof TriggerModel)
        {
          cell = ((TriggerModel) cell).getParent();
        }
        if (cell instanceof GroupModel)
        {
          cell = ((GroupModel) cell).getMainElement();
        }
        editor.rotateTransRight(cell);
        break;
      case AbstractViewEvent.GRAPHBEAUTIFIER:
        editor.startBeautify(0,0,0);
        break;
      case AbstractViewEvent.GRAPHBEAUTIFIER_ADV:
        editor.advancedBeautifyDialog();
        break;
     
      case AbstractViewEvent.TOKENGAME_BACKWARD:
      case AbstractViewEvent.TOKENGAME_JUMPINTO:
      case AbstractViewEvent.TOKENGAME_FORWARD:
      case AbstractViewEvent.TOKENGAME_PAUSE:
      case AbstractViewEvent.TOKENGAME_START:
      case AbstractViewEvent.TOKENGAME_STOP:
      case AbstractViewEvent.TOKENGAME_LEAVE:
      case AbstractViewEvent.TOKENGAME_STEP:
      case AbstractViewEvent.TOKENGAME_AUTO:
        TokenGameSession tgbController =
          editor.getTokenGameController().getRemoteControl();
        if (tgbController!=null) {
          // Adaptor from view event produced by toolbar button to the legacy
          // action id of the token game bar controller. Generate "listener" for these
          // and forward to the token game bar controller
          int tgbAction = createTgbActionFromViewEvent(event.getOrder());
View Full Code Here

        super(vepID, mediator);
    }

    @Override
    public void processViewEvent(AbstractViewEvent event) {
        EditorVC editor = (EditorVC) getMediator().getUi().getEditorFocus();

        switch (event.getOrder()) {
        case AbstractViewEvent.OPEN:
            if (event.getData() != null && event.getData() instanceof File) {
                openFile((File) event.getData(), FileFilterImpl.PNMLFilter);
            } else {
                openEditor();
            }
            break;
        case AbstractViewEvent.OPEN_SAMPLE:
            openFile((File) event.getData(), FileFilterImpl.SAMPLEFilter);
            break;
        case AbstractViewEvent.SAVE:
            save((EditorVC) getMediator().getUi().getEditorFocus());
            break;
        case AbstractViewEvent.SAVEAS:
            saveAs((EditorVC) getMediator().getUi().getEditorFocus());
            break;
    case AbstractViewEvent.IMPORTAPRO:
      importApromore();
      break;
    case AbstractViewEvent.EXPORTAPRO:
      exportApromore((EditorVC) getMediator().getUi().getEditorFocus());
      break;
        case AbstractViewEvent.EXPORT:
            export((EditorVC) getMediator().getUi().getEditorFocus());
            break;
        case AbstractViewEvent.ANALYSIS_WOPED:
            if (editor != null) {
                editor.getEditorPanel().showAnalysisBar();
                LoggerManager.info(Constants.FILE_LOGGER, "Local WoPeD analysis started.");
            }
            break;
        
        case AbstractViewEvent.ANALYSIS_METRIC:
          // calls the new metrics sidebar
          if (!editor.getEditorPanel().isMetricsBarVisible())
          {
            editor.getEditorPanel().showMetricsBar();
           
          }
          else
          {
            editor.getEditorPanel().hideMetricsBar();
          }
           
            LoggerManager.info(Constants.FILE_LOGGER, Messages.getString("Metrics.General.MetricsStarted") + ".");

            //new MetricsUIRequestHandler().showInitialData(editor.getModelProcessor().getElementContainer());
View Full Code Here

     * OverviewPanel provides a 'birds-eye' view of the active document. Must
     * use the {@link #createOverviewPanel}method to create a new instance.
     */
    public OverviewPanel(IEditor editorInterface, JScrollPane scrollPane)
    {
      EditorVC editor2 = (EditorVC)editorInterface;
        originalGraph = editorInterface.getGraph();
        this.editor = editor2;
        v = new PannerViewfinder(this, scrollPane.getViewport());
        GraphLayoutCache view = new ViewRedirector(editorInterface.getGraph().getGraphLayoutCache());

View Full Code Here

TOP

Related Classes of org.woped.editor.controller.vc.EditorVC

Copyright © 2018 www.massapicom. 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.