Changeset 1635 for trunk/modelicaml
- Timestamp:
- 08/20/12 13:13:59 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/modelicaml/org.openmodelica.modelicaml.view.componentstree/src/org/openmodelica/modelicaml/view/componentstree/views/ComponentsTree.java
r1633 r1635 62 62 import org.eclipse.jface.dialogs.MessageDialog; 63 63 import org.eclipse.jface.dialogs.ProgressMonitorDialog; 64 import org.eclipse.jface.operation.IRunnableWithProgress; 64 65 import org.eclipse.jface.resource.ImageDescriptor; 65 66 import org.eclipse.jface.util.LocalSelectionTransfer; … … 2179 2180 2180 2181 // build new tree 2181 createTree(); 2182 if (sel instanceof IStructuredSelection) { 2183 EObject selectedElement = null; 2184 2185 if (getCurrentSelections() != null && getCurrentSelections().size() > 0 ) { 2186 selectedElement = (EObject) adaptSelectedElement(getCurrentSelections().get(0)); 2187 if (selectedElement instanceof Class ) { 2188 selectedClass = (Class) selectedElement; 2189 2190 createTree(); 2191 } 2192 } 2193 } 2182 2194 2183 2195 // set new input from the selection. … … 2280 2292 getSite().getWorkbenchWindow().getSelectionService().addSelectionListener(listener); 2281 2293 2282 createTree(); 2294 if (sel instanceof IStructuredSelection) { 2295 EObject selectedElement = null; 2296 2297 if (getCurrentSelections() != null && getCurrentSelections().size() > 0 ) { 2298 selectedElement = (EObject) adaptSelectedElement(getCurrentSelections().get(0)); 2299 if (selectedElement instanceof Class ) { 2300 selectedClass = (Class) selectedElement; 2301 2302 createTree(); 2303 } 2304 } 2305 } 2306 2307 // createTree(); 2283 2308 } 2284 2309 } … … 2292 2317 */ 2293 2318 private void createClassTree(Class selectedClass){ 2294 // reset 2295 // org.openmodelica.modelicaml.common.instantiation.TreeUtls.componentsTreeRoot = null; 2296 2319 2297 2320 if (selectedClass != null && !(selectedClass instanceof Behavior) && isValid(selectedClass)) { 2298 2321 … … 2304 2327 root = ast.getTreeRoot(); 2305 2328 2306 // set the static variable to be used by other plugins. This is done in order to avoid cyclic plugin depende cies2329 // set the static variable to be used by other plugins. This is done in order to avoid cyclic plugin dependencies 2307 2330 org.openmodelica.modelicaml.common.instantiation.TreeUtls.classInstantiation = ast; 2308 2331 org.openmodelica.modelicaml.common.instantiation.TreeUtls.componentsTreeRoot = root; … … 2314 2337 public void createTree(){ 2315 2338 2316 if (sel instanceof IStructuredSelection) { 2317 EObject selectedElement = null; 2318 2319 if (getCurrentSelections() != null && getCurrentSelections().size() > 0 ) { 2320 selectedElement = (EObject) adaptSelectedElement(getCurrentSelections().get(0)); 2321 } 2339 if (selectedClass != null && !(selectedClass instanceof Behavior) && isValid(selectedClass)) { 2322 2340 2323 if (selectedElement instanceof Class ) { 2324 selectedClass = (Class) selectedElement; 2325 2326 if (selectedClass != null && !(selectedClass instanceof Behavior) && isValid(selectedClass)) { 2327 actionSimulate.setEnabled(true); 2328 actionValidate.setEnabled(true); 2329 actionReload.setEnabled(true); 2330 actionCollapseAll.setEnabled(true); 2331 2332 createClassTree(selectedClass); // build the entire tree 2333 } 2334 else { 2335 actionSimulate.setEnabled(false); 2336 actionValidate.setEnabled(false); 2337 actionReload.setEnabled(false); 2338 actionCollapseAll.setEnabled(false); 2339 } 2340 } 2341 // set actions 2342 actionSimulate.setEnabled(true); 2343 actionValidate.setEnabled(true); 2344 actionReload.setEnabled(true); 2345 actionCollapseAll.setEnabled(true); 2346 2347 ProgressMonitorDialog progressDialog = new ProgressMonitorDialog(ModelicaMLServices.getShell()); 2348 progressDialog.getProgressMonitor().setTaskName("Instantiating " + ModelicaMLServices.getName(selectedClass)); 2349 2350 try { 2351 progressDialog.run(false, true, new IRunnableWithProgress() { 2352 2353 @Override 2354 public void run(IProgressMonitor monitor) throws InvocationTargetException, 2355 InterruptedException { 2356 2357 monitor.subTask("Creating class components tree ..."); 2358 // instantiate the selected class 2359 createClassTree(selectedClass); // build the entire tree 2360 2361 //validate component modifications 2362 monitor.subTask("Validating component modifications ..."); 2363 2364 ComponentModificationValidator validator = new ComponentModificationValidator(root); 2365 validator.validate(); 2366 2367 viewer.refresh(); 2368 2369 monitor.done(); 2370 } 2371 }); 2372 } catch (InvocationTargetException e) { 2373 e.printStackTrace(); 2374 MessageDialog.openError(ModelicaMLServices.getShell(), "Class Instantiation Error", "Could not invoce the class instantiation operation."); 2375 } catch (InterruptedException e) { 2376 e.printStackTrace(); 2377 MessageDialog.openInformation(ModelicaMLServices.getShell(), "Class Instantiation Canceled", "Class instantiation operation was canceled."); 2378 } 2379 } 2380 else { 2381 actionSimulate.setEnabled(false); 2382 actionValidate.setEnabled(false); 2383 actionReload.setEnabled(false); 2384 actionCollapseAll.setEnabled(false); 2385 } 2386 2387 2388 // if (sel instanceof IStructuredSelection) { 2389 // EObject selectedElement = null; 2390 // 2391 // if (getCurrentSelections() != null && getCurrentSelections().size() > 0 ) { 2392 // selectedElement = (EObject) adaptSelectedElement(getCurrentSelections().get(0)); 2393 // } 2394 // 2395 // if (selectedElement instanceof Class ) { 2396 // selectedClass = (Class) selectedElement; 2397 // 2398 // if (selectedClass != null && !(selectedClass instanceof Behavior) && isValid(selectedClass)) { 2399 // actionSimulate.setEnabled(true); 2400 // actionValidate.setEnabled(true); 2401 // actionReload.setEnabled(true); 2402 // actionCollapseAll.setEnabled(true); 2403 // 2404 // ProgressMonitorDialog progressDialog = new ProgressMonitorDialog(ModelicaMLServices.getShell()); 2405 // progressDialog.getProgressMonitor().setTaskName("Instantiating " + ModelicaMLServices.getName(selectedClass)); 2406 // 2407 // try { 2408 // progressDialog.run(false, true, new IRunnableWithProgress() { 2409 // 2410 // @Override 2411 // public void run(IProgressMonitor monitor) throws InvocationTargetException, 2412 // InterruptedException { 2413 // 2414 // monitor.subTask("Creating class components tree ..."); 2415 // // instantiate the selected class 2416 // createClassTree(selectedClass); // build the entire tree 2417 // 2418 // //validate component modifications 2419 // monitor.subTask("Validating component modifications ..."); 2420 // 2421 // ComponentModificationValidator validator = new ComponentModificationValidator(root); 2422 // validator.validate(); 2423 // 2424 // viewer.refresh(); 2425 // 2426 // monitor.done(); 2427 // } 2428 // }); 2429 // } catch (InvocationTargetException e) { 2430 // e.printStackTrace(); 2431 // MessageDialog.openError(ModelicaMLServices.getShell(), "Class Instantiation Error", "Could not invoce the class instantiation operation."); 2432 // } catch (InterruptedException e) { 2433 // e.printStackTrace(); 2434 // MessageDialog.openInformation(ModelicaMLServices.getShell(), "Class Instantiation Canceled", "Class instantiation operation was canceled."); 2435 // } 2436 // } 2437 // else { 2438 // actionSimulate.setEnabled(false); 2439 // actionValidate.setEnabled(false); 2440 // actionReload.setEnabled(false); 2441 // actionCollapseAll.setEnabled(false); 2442 // } 2443 // } 2341 2444 2342 2445 // createTree(selectedClass); // build the entire tree 2343 }2446 // } 2344 2447 } 2345 2448
Note: See TracChangeset
for help on using the changeset viewer.