Ignore:
Timestamp:
07/27/12 18:55:51 (12 years ago)
Author:
wschamai
Message:

MOD:

  • papyrus notifications for code generation, validation, etc. added
  • enhancements VeM generation and reporting
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/modelicaml/org.openmodelica.modelicaml.common/src/org/openmodelica/modelicaml/common/services/ModelicaMLServices.java

    r1593 r1594  
    88import java.io.OutputStreamWriter;
    99import java.io.UnsupportedEncodingException;
     10import java.text.SimpleDateFormat;
    1011import java.util.ArrayList;
    1112import java.util.Collections;
     
    3233import org.eclipse.papyrus.core.utils.BusinessModelResolver;
    3334import org.eclipse.papyrus.resource.uml.UmlModel;
     35import org.eclipse.papyrus.ui.toolbox.notification.builders.NotificationBuilder;
     36import org.eclipse.swt.widgets.Display;
    3437import org.eclipse.swt.widgets.Shell;
    3538import org.eclipse.ui.IWorkbench;
     
    4447import org.openmodelica.modelicaml.common.instantiation.ClassInstantiation;
    4548import org.openmodelica.modelicaml.common.instantiation.TreeObject;
     49import org.openmodelica.modelicaml.common.utls.ResourceManager;
    4650
    4751public class ModelicaMLServices {
    4852
     53    /*
     54     * Papyrus notification popup
     55     */
     56    public static void notify(final String title, final String message, final int messageType, final long displayTimeInSeconds){
     57        Display.getDefault().asyncExec(new Runnable() {
     58            public void run() {
     59               
     60                NotificationBuilder notification = new NotificationBuilder();
     61
     62                notification.setAsynchronous(true);
     63                notification.setTemporary(true);
     64                notification.setDelay(displayTimeInSeconds * 1000);
     65//              notification.setHTML(true); // does not work :(
     66               
     67                if (messageType == 0) {
     68                    notification.setType(org.eclipse.papyrus.ui.toolbox.notification.Type.INFO);
     69                }
     70                else if (messageType == 1) {
     71                    notification.setType(org.eclipse.papyrus.ui.toolbox.notification.Type.WARNING);
     72                }
     73                else if (messageType == 2) {
     74                    notification.setType(org.eclipse.papyrus.ui.toolbox.notification.Type.ERROR);
     75                }
     76               
     77                notification.setTitle(title);
     78                notification.setMessage(message);
     79               
     80                // set ModelicaML image
     81                notification.setImage(ResourceManager.getPluginImage("org.openmodelica.modelicaml.common", "icons/ModelicaML_logo.gif"));
     82               
     83                // run
     84                notification.run();
     85            }
     86        });
     87    }
    4988   
    5089   
     
    68107//      }
    69108       
     109//      notify("Checking if code generation is needed ... ", 1);
     110       
    70111        if (generatedCodeTimeStamp != null && modifiedModelTimeStamp != null) {
    71112            // if code was generated after the model modification -> no need for regenerating code
     
    84125                boolean codeGenDirExists = folder.isDirectory();
    85126                if (codeGenDirExists) {
    86                     System.err.println("Skipping code generation ... ");
     127                   
     128//                  System.err.println("Skipping Modelica code generation ... ");
     129
     130                    String resourceName = resource.getURI().toPlatformString(true);
     131                    SimpleDateFormat sdf = new SimpleDateFormat("yyyy.MM.dd HH:mm:ss");
     132                    String lastCodeGeneration = sdf.format(generatedCodeTimeStamp);
     133                    String lastModification = sdf.format(modifiedModelTimeStamp);
     134                   
     135                    notify("ModelicaML Code Generation",
     136                            "Code generation was skipped." +
     137                            "\nThe model '"+resourceName+"' " +
     138                            "\nhas not changed since the last code generation." +
     139                           
     140                            "\n\nLast model modification: "+lastModification +
     141                            "\nLast code generation : "+lastCodeGeneration,
     142                            -1,
     143                            2);
     144
    87145                    return false;
    88146                }
Note: See TracChangeset for help on using the changeset viewer.