Package hu.u_szeged.nbo.client.model

Examples of hu.u_szeged.nbo.client.model.Model


    IStructuredSelection selection =
      (IStructuredSelection)mainWindow.getProblemBrowserTree().getTreeViewer().getSelection();
     
    if (!selection.isEmpty()) {
      Model model = (Model)selection.getFirstElement();
           
          if (model instanceof ResourceAllocation) {
            ResourceAllocation raProblem = (ResourceAllocation)model;
           
            fileDialog.setFileName(raProblem.getName() + "_" + raProblem.getAlgorithm());
View Full Code Here


    this.mainWindow = mainWindow;
    this.domain = model;
  }

  public void run() {
    final Model problem = this.domain;
    long solutionSleep = Long.parseLong(ConfigurationManager.settings.get("solution_sleep"));
    //int lastState = problem.getState();

    asyncRunnable = new Runnable() {
      public void run() {
        IStructuredSelection selection = (IStructuredSelection) mainWindow.getProblemBrowserTree().getTreeViewer().getSelection();

        if (selection.getFirstElement() == problem) {
          if (problem instanceof ResourceAllocation) {
            mainWindow.getRAPerspective().setSummaryText(((ResourceAllocation)domain).getSummary());
            ((ResourceAllocation)problem).updateSummary();
          }
        }

        // FIX: update only on Model state change
        mainWindow.getProblemBrowserTree().getTreeViewer().update(problem, null);
      }
    };

    while ((!this.domain.isSolved()) && (!this.domain.isFailed())) {
      mainWindow.getShell().getDisplay().asyncExec(asyncRunnable);

      if (stop) {
        return;
      }

      try {
        sleep(solutionSleep * 1000);
      }

      catch (Exception e) {
        ClientLogManager.addClientLog("Exception in " + this.getName() + ":\n\t" + e.toString(), true);
      }
    }

    try {
      final String finalTextSolution = new String(domain.getSolution().get(domain.getName()));
      final String log = new String(domain.getLog());

      mainWindow.getShell().getDisplay().asyncExec(
          new Runnable() {
            public void run() {
              IStructuredSelection selection =
                (IStructuredSelection)mainWindow.getProblemBrowserTree().getTreeViewer().getSelection();

              String success = "";

              if (selection.getFirstElement() == problem) {
                if (problem instanceof ResourceAllocation) {
                  ResourceAllocation raProblem = ((ResourceAllocation)problem);
                  ResourceAllocationPerspective perspective = mainWindow.getRAPerspective();

                  raProblem.setState(Model.ACKNOWLEDGED);
                  perspective.setSummaryText(raProblem.getSummary());
                  perspective.setSolutionText(finalTextSolution);
                  perspective.setSolutionTables((ResourceAllocation)problem);
                  perspective.setServerOutputText(log);
                 
                  perspective.getAlgSelector().setEnabled(false);
                  perspective.getOptionsGroup().setEnabled(false);
                }
              }

              if (!problem.isFailed()) {
                success = "Excercise " + domain.getName()
                + " [#" + domain.getUniqueID() + "]" + " solved!";
              }

              else {
                System.out.println("SHOULD NOT SEE ME: SolutionMonitorThread:95");
                success = "Excercise " + domain.getName()
                + " [#" + domain.getUniqueID() + "]"+ " is failed to solve!";
              }

              ClientLogManager.addUserLog(success, (problem.isFailed() ? true: false));

              mainWindow.getEventCentral().updateActionStates();
              mainWindow.getProblemBrowserTree().getTreeViewer().refresh();
             
            }
View Full Code Here

  public Font getFont(Object element) {
    Font font = null;

    if (element instanceof Model) {
      Model problem = ((Model)element);

      // TODO: create resource class to get system font size, image size, etc. settings
      if (problem.isSolved() && !problem.isAcknowledged())
        font = new Font(null, "Tahoma", 8, SWT.BOLD);

      if (problem.isAcknowledged())
        font = new Font(null, "Tahoma", 8, SWT.NORMAL)
    }

    else font = new Font(null, "Tahoma", 8, SWT.NORMAL);
View Full Code Here

  public void run() {
    this.tree = mainWindow.getProblemBrowserTree().getTreeViewer();
    IStructuredSelection selection = (IStructuredSelection) tree.getSelection();
   
    Problem parent = null;
    Model model = null;

    for (Iterator iterator = selection.iterator(); iterator.hasNext();) {
      if (selection.isEmpty()) return;
     
      model = (Model) iterator.next();
      parent = (Problem)model.getParent();
       
      if (model instanceof ResourceAllocation) {
        tree.remove(model);
        parent.removeRAProblem((ResourceAllocation)model);
        model.kill();
        tree.setInput(parent.getParent());
       
        mainWindow.getRAPerspective().clearSourceTables(model.getName());
        mainWindow.getRAPerspective().clearSolutionTables(model.getName());
        mainWindow.getProblemBrowserTree().getTreeViewer().expandAll();   
      }
     
      ClientLogManager.addUserLog("Problem " + model.getName() + " [#" + model.getUniqueID() + "]"+ " closed.", false);
    }   
  }
View Full Code Here

    IStructuredSelection selection = (IStructuredSelection) tree.getSelection();
   
    if (selection.isEmpty()) return;
   
    for (Iterator iterator = selection.iterator(); iterator.hasNext();) {
      Model model = (Model)iterator.next();
     
      if (model instanceof ResourceAllocation) {
        ResourceAllocationPerspective perspective = mainWindow.getRAPerspective();
        ResourceAllocation raProblem = (ResourceAllocation) model;
               
View Full Code Here

TOP

Related Classes of hu.u_szeged.nbo.client.model.Model

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.