Package org.gvt.model.sif

Examples of org.gvt.model.sif.SIFGraph


  public void run()
  {
    String fileName = null;
    boolean done = false;

    SIFGraph sifGraph = null;
    BasicSIFGraph basicSifGraph = null;

    if (main.getPathwayGraph().getGraphType().equals(BioPAXGraph.SIF))
    {
      sifGraph = (SIFGraph) main.getPathwayGraph();
    }
    else if (main.getPathwayGraph().getGraphType().equals(BioPAXGraph.BASIC_SIF))
    {
      basicSifGraph = (BasicSIFGraph) main.getPathwayGraph();
    }

    if (sifGraph == null && basicSifGraph == null)
    {
      MessageDialog.openError(main.getShell(), "Not A Valid View!",
        "Only Simple Interaction Views can be written in SIF format.");
      return;
    }

    while (!done)
    {
      // Get the user to choose a file name and type to save.
      FileDialog fileChooser = new FileDialog(main.getShell(), SWT.SAVE);

      // Do not let user to overwrite a non-graphml file by default

      String currentFilename = main.getOwlFileName();
      if (!currentFilename.endsWith(".sif"))
      {
        if (currentFilename.indexOf(".") > 0)
        {
          currentFilename = currentFilename.substring(
            0, currentFilename.lastIndexOf("."));
        }
        currentFilename += ".sif";
      }

      fileChooser.setFileName(currentFilename);

      String[] filterExtensions = new String[]{"*.sif"};
      String[] filterNames = new String[]{"Simple Interaction Format (*.sif)"};

      fileChooser.setFilterExtensions(filterExtensions);
      fileChooser.setFilterNames(filterNames);
      fileName = fileChooser.open();

      if (fileName == null)
      {
        // User has cancelled, so quit and return
        done = true;
      }
      else
      {
        // User has selected a file; see if it already exists
        File file = new File(fileName);

        if (file.exists())
        {
          // The file already exists; asks for confirmation
          MessageBox mb = new MessageBox(
            fileChooser.getParent(),
            SWT.ICON_WARNING | SWT.YES | SWT.NO);

          // We really should read this string from a
          // resource bundle
          mb.setMessage(fileName + " already exists. Do you want to replace it?");
          mb.setText("Confirm Replace File");
          // If they click Yes, we're done and we drop out. If
          // they click No, we redisplay the File Dialog
          done = mb.open() == SWT.YES;
        }
        else
        {
          // File does not exist, so drop out
          done = true;
        }
      }
    }

    if (fileName == null)
    {
      isSaved = false;
      return;
    }

    try
    {
      OutputStream os = new FileOutputStream(fileName);

      if (sifGraph != null)
      {
        sifGraph.write(os);
      }
      else if (basicSifGraph != null)
      {
        basicSifGraph.write(os);
      }
View Full Code Here


    ExportToSIFDialog dialog = new ExportToSIFDialog(main.getShell(),
      possibleRuleTypes, ruleTypes);

    if (dialog.open() && !ruleTypes.isEmpty())
    {
      SIFGraph sif = new SIFGraph(model, ruleTypes);

      int nodenum = sif.getNodes().size();
      int edgenum = sif.getEdges().size();

      System.out.println("created nodenum = " + nodenum + " edgenum = " + edgenum);

      if (nodenum > 0)
      {
        String name = main.getOwlFileName();

        if (name == null)
        {
          name = "SIF View";
        }
        else
        {
          if (name.contains("/"))
          {
            name = name.substring(name.lastIndexOf("/")+1, name.lastIndexOf("."));
          }
          else if (name.contains("\\"))
          {
            name = name.substring(name.lastIndexOf("\\")+ 1, name.lastIndexOf("."));
          }
        }

        sif.setName(name);
        main.createNewTab(sif);
        main.associateGraphWithExperimentData(sif);
        new CoSELayoutAction(main).run();
      }
      else
View Full Code Here

  public void run()
  {
    String fileName = null;
    boolean done = false;

    SIFGraph sifGraph = null;
    BasicSIFGraph basicSifGraph = null;

    if (main.getPathwayGraph().getGraphType().equals(BioPAXGraph.SIF))
    {
      sifGraph = (SIFGraph) main.getPathwayGraph();
    }
    else if (main.getPathwayGraph().getGraphType().equals(BioPAXGraph.BASIC_SIF))
    {
      basicSifGraph = (BasicSIFGraph) main.getPathwayGraph();
    }

    if (sifGraph == null && basicSifGraph == null)
    {
      MessageDialog.openError(main.getShell(), "Not A Valid View!",
        "Only Simple Interaction Views can be written in SIF format.");
      return;
    }

    while (!done)
    {
      // Get the user to choose a file name and type to save.
      FileDialog fileChooser = new FileDialog(main.getShell(), SWT.SAVE);

      // Do not let user to overwrite a non-graphml file by default

      String currentFilename = main.getOwlFileName();
      if (!currentFilename.endsWith(".sif"))
      {
        if (currentFilename.indexOf(".") > 0)
        {
          currentFilename = currentFilename.substring(
            0, currentFilename.lastIndexOf("."));
        }
        currentFilename += ".sif";
      }

      fileChooser.setFileName(currentFilename);

      String[] filterExtensions = new String[]{"*.sif"};
      String[] filterNames = new String[]{"Simple Interaction Format (*.sif)"};

      fileChooser.setFilterExtensions(filterExtensions);
      fileChooser.setFilterNames(filterNames);
      fileName = fileChooser.open();

      if (fileName == null)
      {
        // User has cancelled, so quit and return
        done = true;
      }
      else
      {
        // User has selected a file; see if it already exists
        File file = new File(fileName);

        if (file.exists())
        {
          // The file already exists; asks for confirmation
          MessageBox mb = new MessageBox(
            fileChooser.getParent(),
            SWT.ICON_WARNING | SWT.YES | SWT.NO);

          // We really should read this string from a
          // resource bundle
          mb.setMessage(fileName + " already exists. Do you want to replace it?");
          mb.setText("Confirm Replace File");
          // If they click Yes, we're done and we drop out. If
          // they click No, we redisplay the File Dialog
          done = mb.open() == SWT.YES;
        }
        else
        {
          // File does not exist, so drop out
          done = true;
        }
      }
    }

    if (fileName == null)
    {
      isSaved = false;
      return;
    }

    try
    {
      OutputStream os = new FileOutputStream(fileName);

      if (sifGraph != null)
      {
        sifGraph.write(os);
      }
      else if (basicSifGraph != null)
      {
        basicSifGraph.write(os);
      }
View Full Code Here

    ExportToSIFDialog dialog = new ExportToSIFDialog(main.getShell(),
      possibleRuleTypes, ruleTypes);

    if (dialog.open() && !ruleTypes.isEmpty())
    {
      SIFGraph sif = new SIFGraph(model, ruleTypes);

      int nodenum = sif.getNodes().size();
      int edgenum = sif.getEdges().size();

      System.out.println("created nodenum = " + nodenum + " edgenum = " + edgenum);

      if (nodenum > 0)
      {
        String name = main.getOwlFileName();

        if (name == null)
        {
          name = "SIF View";
        }
        else
        {
          if (name.contains("/"))
          {
            name = name.substring(name.lastIndexOf("/")+1, name.lastIndexOf("."));
          }
          else if (name.contains("\\"))
          {
            name = name.substring(name.lastIndexOf("\\")+ 1, name.lastIndexOf("."));
          }
        }

        sif.setName(name);
        main.createNewTab(sif);
        main.associateGraphWithExperimentData(sif);
        new CoSELayoutAction(main).run();
      }
      else
View Full Code Here

TOP

Related Classes of org.gvt.model.sif.SIFGraph

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.