Ignore:
Timestamp:
02/11/13 15:43:54 (12 years ago)
Author:
wschamai
Message:

MOD: reload buttons consistent in all views
ADD: reload button with element selection for component tree view
MOD: plotting of leaf variables only

Location:
trunk/modelicaml/org.openmodelica.modelicaml.view.componentstree/src/org/openmodelica/modelicaml/view/componentstree
Files:
1 added
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/modelicaml/org.openmodelica.modelicaml.view.componentstree/src/org/openmodelica/modelicaml/view/componentstree/views/ComponentsTree.java

    r1694 r1707  
    130130import org.openmodelica.modelicaml.common.services.StringUtls;
    131131import org.openmodelica.modelicaml.common.utls.ResourceManager;
     132import org.openmodelica.modelicaml.common.utls.SWTResourceManager;
    132133import org.openmodelica.modelicaml.common.validation.services.ModelicaMLMarkerSupport;
    133134import org.openmodelica.modelicaml.gen.modelica.cg.helpers.OMCClassValidator;
     
    139140import org.openmodelica.modelicaml.view.componentstree.Activator;
    140141import org.openmodelica.modelicaml.view.componentstree.dialogs.DialogComponentModification;
     142import org.openmodelica.modelicaml.view.componentstree.dialogs.ElementSelectionDialog;
    141143import org.openmodelica.modelicaml.view.componentstree.dialogs.SearchDialog;
    142144import org.openmodelica.modelicaml.view.componentstree.dialogs.UpdateBindingsConfirmationDialog;
     
    246248    private Action actionReload;
    247249
     250    public Action actionReloadAndValidate;
     251
    248252    private IAction actionExpandArrays;
    249253
     
    284288    private String markerType = Constants.MARKERTYPE_COMPONENT_MODIFICATION;
    285289
    286    
     290    /*
     291     * dialog used to select an element from the model browser
     292     */
     293    private ElementSelectionDialog elementSelectionDialog;
     294
     295    private Action actionElementSelectedByDialog;
    287296   
    288297   
     
    617626     */
    618627    private void fillLocalToolBar(IToolBarManager manager) {
     628        manager.add(actionReload);
     629        manager.add(new Separator());
    619630        manager.add(actionFind);
    620         manager.add(new Separator());
    621         manager.add(actionReload);
     631//      manager.add(new Separator());
     632//      manager.add(actionReloadAndValidate);
    622633        manager.add(new Separator());
    623634        manager.add(actionValidate);
     
    710721        actionFind.setImageDescriptor(ImageDescriptor.createFromFile(Activator.class, "/icons/find.png"));
    711722       
    712        
    713        
    714723        actionReload = new Action("actionReload") {
    715724            public void run() {
     725               
     726               
     727                elementSelectionDialog = new ElementSelectionDialog(
     728                        //PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), // don't use this because it will block the window underneath
     729                        new Shell(),
     730                        SWTResourceManager.getImage(ElementSelectionDialog.class,"/icons/selectItem.gif"),
     731                        "Element Selection",
     732                        "Select the model to be instantiated",
     733                        selectedClass,
     734                        actionElementSelectedByDialog
     735                        );
     736               
     737                elementSelectionDialog.open();
     738            }
     739        };
     740        actionReload.setText("(Reload");
     741        actionReload.setToolTipText("Reload");
     742        actionReload.setImageDescriptor(ImageDescriptor.createFromFile(Activator.class, "/icons/refresh.gif"));
     743        actionReload.setEnabled(true);
     744
     745       
     746        actionElementSelectedByDialog = new Action("actionElementSelectedByDialog") {
     747            public void run() {
     748               
     749                // get the selected element from the dialog and set the view selected class
     750                if (elementSelectionDialog != null) {
     751                    EObject selectedElement = elementSelectionDialog.getSelectedElement();
     752                    if (selectedElement instanceof Class) {
     753                        selectedClass = (Class) selectedElement;
     754
     755                        // close the dialog
     756                        elementSelectionDialog.dispose();
     757                       
     758                        // re-create the tree
     759                        reCreateTree();
     760                    }
     761                }
     762            }
     763        };
     764        actionElementSelectedByDialog.setText("(Reload");
     765        actionElementSelectedByDialog.setToolTipText("Reload");
     766        actionElementSelectedByDialog.setImageDescriptor(ImageDescriptor.createFromFile(Activator.class, "/icons/refresh.gif"));
     767        actionElementSelectedByDialog.setEnabled(true);
     768
     769       
     770
     771       
     772       
     773        actionReloadAndValidate = new Action("actionReloadAndValidate") {
     774            public void run() {
     775
    716776                showSelection(par, sel);
    717777               
     
    725785            }
    726786        };
    727         actionReload.setText("(Re)load and validate");
    728         actionReload.setToolTipText("(Re)load and validate");
    729         actionReload.setImageDescriptor(ImageDescriptor.createFromFile(Activator.class, "/icons/refresh.gif"));
    730         actionReload.setEnabled(false);
     787        actionReloadAndValidate.setText("(Re)load and validate");
     788        actionReloadAndValidate.setToolTipText("(Re)load and validate");
     789        actionReloadAndValidate.setImageDescriptor(ImageDescriptor.createFromFile(Activator.class, "/icons/refresh.gif"));
     790        actionReloadAndValidate.setEnabled(false);
    731791       
    732792        actionValidateComponentModifications = new Action("actionValidateComponentModifications") { //obviously a check box style
     
    22262286        par = sourcepart;
    22272287       
    2228         Object[] expandedElements = viewer.getExpandedElements();
    2229         TreePath[] expandedTreePaths = viewer.getExpandedTreePaths();
     2288//      Object[] expandedElements = viewer.getExpandedElements();
     2289//      TreePath[] expandedTreePaths = viewer.getExpandedTreePaths();
    22302290       
    22312291        // build new tree
     
    22402300                    selectedClass = (Class) selectedElement;
    22412301
    2242                     createTree();
    2243                 }
    2244             }
     2302//                  createTree();
     2303                }
     2304            }
     2305        }
     2306       
     2307        // set new input from the selection.
     2308//      viewer.setInput(getViewSite());
     2309//
     2310//      viewer.setExpandedElements(expandedElements);
     2311//      viewer.setExpandedTreePaths(expandedTreePaths);
     2312       
     2313        reCreateTree();
     2314    }
     2315   
     2316   
     2317    public void reCreateTree() {
     2318
     2319        Object[] expandedElements = viewer.getExpandedElements();
     2320        TreePath[] expandedTreePaths = viewer.getExpandedTreePaths();
     2321       
     2322        if (selectedClass instanceof Class) {
     2323            createTree();
    22452324        }
    22462325       
     
    22512330        viewer.setExpandedTreePaths(expandedTreePaths);
    22522331    }
     2332
    22532333
    22542334    /*
     
    23942474            actionSimulate.setEnabled(true);
    23952475            actionValidate.setEnabled(true);
    2396             actionReload.setEnabled(true);
     2476            actionReloadAndValidate.setEnabled(true);
    23972477            actionCollapseAll.setEnabled(true);
    23982478           
     
    24392519            actionSimulate.setEnabled(false);
    24402520            actionValidate.setEnabled(false);
    2441             actionReload.setEnabled(false);
     2521            actionReloadAndValidate.setEnabled(false);
    24422522            actionCollapseAll.setEnabled(false);
    24432523        }
Note: See TracChangeset for help on using the changeset viewer.