DesignFlowView.java 70.1 KB
Newer Older
1 2 3
/*******************************************************************************
 * Copyright (c) 2014 Elphel, Inc.
 * Copyright (c) 2006 Elphel, Inc and Excelsior, LLC.
4 5
 * This file is a part of VDT plug-in.
 * VDT plug-in is free software; you can redistribute it and/or modify
6 7 8 9
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
10
 * VDT plug-in is distributed in the hope that it will be useful,
11 12 13 14 15 16
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
Andrey Filippov's avatar
Andrey Filippov committed
17 18 19 20 21 22 23 24 25
 * 
 *  Additional permission under GNU GPL version 3 section 7:
 * If you modify this Program, or any covered work, by linking or combining it
 * with Eclipse or Eclipse plugins (or a modified version of those libraries),
 * containing parts covered by the terms of EPL/CPL, the licensors of this
 * Program grant you additional permission to convey the resulting work.
 * {Corresponding Source for a non-source form of such a combination shall
 * include the source code for the parts of Eclipse or Eclipse plugins used
 * as well as that of the covered work.}
26
 *******************************************************************************/
27 28 29
package com.elphel.vdt.ui.views;

import java.util.List;
30
import java.util.Map;
31 32

import org.eclipse.swt.widgets.Composite;
Andrey Filippov's avatar
Andrey Filippov committed
33

34 35
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Listener;
36
import org.eclipse.swt.widgets.Shell;
37 38
import org.eclipse.swt.widgets.Tree;
import org.eclipse.swt.widgets.TreeItem;
39 40 41 42
import org.eclipse.ui.part.*;
import org.eclipse.jface.viewers.*;
import org.eclipse.jface.window.Window;
import org.eclipse.swt.graphics.Image;
43
//import org.eclipse.swt.graphics.ImageData;
44 45
import org.eclipse.jface.action.*;
import org.eclipse.jface.text.IDocument;
46 47 48
import org.eclipse.ui.*;
import org.eclipse.swt.widgets.Menu;
import org.eclipse.swt.SWT;
49
import org.eclipse.core.resources.IFile;
50 51 52 53
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
54
import org.eclipse.core.runtime.IPath;
55
import org.eclipse.core.runtime.Path;
56
import org.eclipse.core.runtime.QualifiedName;
57

58
import java.io.File;
59

60
import com.elphel.vdt.core.launching.LaunchCore;
61
import com.elphel.vdt.core.launching.ToolLogFile;
62 63 64 65 66 67
import com.elphel.vdt.core.options.OptionsCore;
import com.elphel.vdt.core.options.ValueBasedOption;
import com.elphel.vdt.core.tools.ToolsCore;
import com.elphel.vdt.core.tools.contexts.Context;
import com.elphel.vdt.core.tools.menu.DesignMenu;
import com.elphel.vdt.core.tools.params.Tool;
68
import com.elphel.vdt.core.tools.params.Tool.TOOL_MODE;
69 70
import com.elphel.vdt.core.tools.params.Tool.TOOL_STATE;
import com.elphel.vdt.core.tools.params.ToolSequence;
71
import com.elphel.vdt.core.tools.params.types.RunFor;
72 73
import com.elphel.vdt.Txt;
import com.elphel.vdt.VDT;
74
import com.elphel.vdt.VerilogUtils;
75 76 77
import com.elphel.vdt.veditor.VerilogPlugin;
import com.elphel.vdt.veditor.document.HdlDocument;
import com.elphel.vdt.veditor.editor.HdlEditor;
78
import com.elphel.vdt.veditor.preference.PreferenceStrings;
79 80 81 82 83 84
import com.elphel.vdt.ui.MessageUI;
import com.elphel.vdt.ui.VDTPluginImages;
import com.elphel.vdt.ui.variables.SelectedResourceManager;
import com.elphel.vdt.ui.views.DesignMenuModel;
import com.elphel.vdt.ui.dialogs.DesignMenuSelectionDialog;
import com.elphel.vdt.ui.options.ContextOptionsDialog;
85
import com.elphel.vdt.ui.options.FilteredFileSelector;
86 87
import com.elphel.vdt.ui.options.SetupOptionsDialog;
import com.elphel.vdt.ui.options.SetupOptionsManager;
88

89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112
import org.eclipse.debug.core.ILaunchConfiguration;
import org.eclipse.debug.ui.DebugUITools;

/**
 * This sample class demonstrates how to plug-in a new
 * workbench view. The view shows data obtained from the
 * model. The sample creates a dummy model on the fly,
 * but a real implementation would connect to the model
 * available either in this or another plug-in (e.g. the workspace).
 * The view is connected to the model using a content provider.
 * <p>
 * The view uses a label provider to define how model
 * objects should be presented in the view. Each
 * view can present the same model objects using
 * different labels and icons, if needed. Alternatively,
 * a single label provider can be shared between views
 * in order to ensure that objects of the same type are
 * presented in the same way everywhere.
 * <p>
 */

public class DesignFlowView extends ViewPart implements ISelectionListener {

    // Persistance tags.
113 114 115
    private static final String TAG_SELECTED_RESOURCE =   "SelectedProject";
    private static final String TAG_SELECTED_HDL_FILE =   "SelectedHdlFile";
    private static final String TAG_SELECTED_HDL_FILTER = "SelectedHdlFilter";
116
    private static final String TAG_LINKED_TOOLS =        "LinkedTools";
117 118

    private TreeViewer viewer;
Andrey Filippov's avatar
Andrey Filippov committed
119
//    private DrillDownAdapter drillDownAdapter;
120
    private Action showLaunchConfigAction;
121 122
//    private Action launchAction;
    
123
    private Action toggleLinkedTools;
124 125
    private Action toggleSaveTools;
    private Action toggleStopTools;
126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141

    private Action showInstallationPropertiesAction;
    private ClearAction clearInstallationPropertiesAction;
    
    private Action showPackagePropertiesAction;
    private GlobalContextsAction showPackagePropertiesToolbarAction;
    private ClearContextAction clearPackagePropertiesAction;
    
    private Action showProjectAction;
    private LocalContextsAction showProjectPropertiesToolbarAction;
    private ClearLocalContextAction clearProjectPropertiesAction;
    
    private Action showPropertiesAction;
    private ClearAction clearToolPropertiesAction;

    private Action selectDesignMenuAction;
142
    private ClearToolStates clearToolStatesAction;
143 144
    
    private ClearProjectStates clearProjectStatesAction;
145 146 147 148
    private ClearStateFiles clearStateFilesAction;
    private ClearLogFiles clearLogFilesAction;

    
149 150 151 152 153 154 155 156 157 158 159
    
    private IResource selectedResource;
    
    private DesignMenuModel.Item selectedItem;
    
    private ValueBasedOption desigMenuName;
    
    private String defaultPartName;

    private IMemento memento;
    
160 161 162 163
    private Action pinAction;
    private Action restoreAction;
    private Action restoreSelectAction;

164 165 166 167
    private Action playbackLogLatestAction;
    private Action playbackLogSelectAction;
    
    
168 169
    IDoubleClickListener doubleClickListener=null;
    private Action [] launchActions;
170
    private ToolSequence toolSequence=null;
Andrey Filippov's avatar
Andrey Filippov committed
171
//    private Composite compositeParent;
172 173 174 175 176
    /**
     * The constructor.
     */
    public DesignFlowView() {
        desigMenuName = new ValueBasedOption(VDT.OPTION_PROJECT_MENU);
177 178 179 180
        toolSequence = new ToolSequence(this);
    }
    public ToolSequence getToolSequence(){
    	return toolSequence;
181
    }
182 183 184 185 186 187
    public void setToggleSaveTools(boolean checked){
    	toggleSaveTools.setChecked(checked);
    }
    public void setToggleStopTools(boolean checked){
    	toggleStopTools.setChecked(checked);
    }
188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214

    /* 
     * Method declared on IViewPart.
     */
     public void init(IViewSite site, IMemento memento) throws PartInitException {
         defaultPartName = getPartName();
         super.init(site, memento);
         this.memento = memento;
         // add itself as a global selection listener
         getSite().getPage().addSelectionListener(this);
     }
    
    /* 
     * Method declared on IWorkbenchPart.
     */
    public void dispose() {
        // remove ourself as a global selection listener
        getSite().getPage().removeSelectionListener(this);
        // run super.
        super.dispose();
    }

    /**
     * This is a callback that will allow us
     * to create the viewer and initialize it.
     */
    public void createPartControl(Composite parent) {
215 216 217
		if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_OTHER))
			System.out.println("+++++ createPartControl()");
    	
Andrey Filippov's avatar
Andrey Filippov committed
218
//    	compositeParent=parent; // will it help to re-draw
219
        viewer = new TreeViewer(parent, SWT.SINGLE | SWT.H_SCROLL | SWT.V_SCROLL);
Andrey Filippov's avatar
Andrey Filippov committed
220
//        drillDownAdapter = new DrillDownAdapter(viewer);
221 222 223 224 225 226 227 228

        viewer.setContentProvider(new ViewContentProvider());
        viewer.setLabelProvider(new ViewLabelProvider());
// more complex sorter is needed        
//        viewer.setSorter(new NameSorter());
//        viewer.setInput(getViewSite());
//        viewer.setInput(ToolsCore.getDesignMenu());
        viewer.addSelectionChangedListener(new ToolSelectionChangedListener());
229 230 231 232 233 234 235 236 237 238 239 240 241 242
        // Draw tool state (running, success, failure, ...) icon after the label in the tree
        final Tree tree=  viewer.getTree();
        tree.addListener(SWT.MeasureItem, new Listener() {
        	public void handleEvent(Event event) {
    			((DesignMenuModel.Item) ((TreeItem)event.item).getData()).measureItem (event);
        	}
        });
        
        tree.addListener(SWT.PaintItem, new Listener() {
        	   public void handleEvent(Event event) {
         	      TreeItem item = (TreeItem)event.item;
         	     ((DesignMenuModel.Item) item.getData()).showStateIcon(event,tree,item);
        	   }
        	});
243 244
        makeActions();
        hookContextMenu();
245
/**+       hookDoubleClickAction(); */
246 247 248 249 250
        contributeToActionBars();

        if (memento != null)
            restoreState(memento);
        memento = null;
251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269
        
        tree.addListener(SWT.KeyUp, new Listener(){
            @Override
            public void handleEvent(Event event) {
            	if (event.keyCode == SWT.SHIFT) {
            		toolSequence.setShiftPressed(false);
            	}
            }
        });
        tree.addListener(SWT.KeyDown, new Listener(){
            @Override
            public void handleEvent(Event event) {
            	if (event.keyCode == SWT.SHIFT) {
            		toolSequence.setShiftPressed(true);
            	}
            }
        });

        
270 271
    } // createPartControl()

272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290
    private void doLoadDesignMenu(IProject newProject) {
		if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_OTHER)) {
			System.out.println("##### doLoadDesignMenu("+newProject+"): current project="+selectedResource.getProject().toString());
		}
		if (newProject!=null){
			restoreCurrentState(newProject);
    		if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_OTHER))
    			System.out.println("Restored new project: "+newProject.toString());
   	   	    IResource HDLFile=SelectedResourceManager.getDefault().getChosenVerilogFile();
   	   	    if ((HDLFile!=null) && (toolSequence!=null)){
   	   	    	if (VerilogUtils.existsVeditorOutlineDatabase(newProject)){
   	   	    		if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_OTHER))
   	   	    			System.out.println("VEditor DB for "+newProject+" already exist");
   	   	    		toolSequence.setUnfinishedBoot(null,false);
   	   	    		finalizeAfterVEditorDB(memento);
   	   	    	} else {
   	   	    		if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_OTHER))
   	   	    			System.out.println("Initiating DB rebuild HDLFile="+HDLFile);
   	   	    		toolSequence.setUnfinishedBoot(null,true);
Andrey Filippov's avatar
Andrey Filippov committed
291 292 293
   	   	    		VerilogUtils.getTopModuleNames((IFile) HDLFile); // will initiate DB rebuild, updateDirty and call doLoadDesignMenu();
//   	   	  java.lang.ClassCastException: org.eclipse.core.internal.resources.Project cannot be cast to org.eclipse.core.resources.IFile
//   	   	  	at com.elphel.vdt.ui.views.DesignFlowView.doLoadDesignMenu(DesignFlowView.java:279)
294 295 296 297 298 299 300
   	   	    	}
   	   	    	return; 
   	   	    }
		}
		doLoadDesignMenu();
    }

301
    private void doLoadDesignMenu() {
302 303 304
		if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_OTHER)) {
			System.out.println("#### doLoadDesignMenu(): project="+selectedResource.getProject().toString());
		}
305 306 307 308
        String menuName = selectedResource == null
                        ? null
                        : OptionsCore.doLoadOption(desigMenuName, selectedResource.getProject()); 
        doLoadDesignMenu(menuName);
309
        
310 311
    }

312
    
313
    private void doLoadDesignMenu(String menuName) {
314
        if (menuName != null) { // Horizontal menu bar
315 316 317 318
            DesignMenu designMenu = ToolsCore.getDesignMenuManager().findDesignMenu(menuName);
            viewer.setInput(designMenu);
            List<Context> packages = ToolsCore.getDesignMenuManager().getPackageContexts(designMenu);
            showPackagePropertiesToolbarAction.setContexts(packages);
319
            clearPackagePropertiesAction.setContexts(packages); // toolBarSeparator already null here
320 321 322 323 324 325 326 327 328 329 330 331 332
            List<Context> projects = ToolsCore.getDesignMenuManager().getProjectContexts(designMenu);
            showProjectPropertiesToolbarAction.setContexts(projects);
            clearProjectPropertiesAction.setContexts(projects);
            setPartName(designMenu.getLabel());
            setTitleToolTip(designMenu.getDescription());
        } else {
            viewer.setInput(null);
            showPackagePropertiesToolbarAction.setContexts(null);
            showProjectPropertiesToolbarAction.setContexts(null);
            setPartName(defaultPartName);
            setTitleToolTip(null);
        }
    }
333 334 335 336
    
    public void changeMenuTitle(String title){
    	setPartName(title);
    }
337 338 339
    public String getMenuTitle(){
    	return getPartName();
    }
340 341 342 343 344 345

    private void hookContextMenu() {
        MenuManager menuMgr = new MenuManager("#PopupMenu");
        menuMgr.setRemoveAllWhenShown(true);
        menuMgr.addMenuListener(new IMenuListener() {
            public void menuAboutToShow(IMenuManager manager) {
346
                DesignFlowView.this.fillContextMenu(manager);  // context (right-click) menu
347 348 349 350 351 352 353
            }
        });
        Menu menu = menuMgr.createContextMenu(viewer.getControl());
        viewer.getControl().setMenu(menu);
        getSite().registerContextMenu(menuMgr, viewer);
    }

354 355
    
    //
356 357
    private void contributeToActionBars() {
        IActionBars bars = getViewSite().getActionBars();
358 359
        fillLocalPullDown(bars.getMenuManager());   // rightmost pull-down 
        fillLocalToolBar(bars.getToolBarManager()); // horizontal bar
360 361
    }

362
    private void fillLocalPullDown(IMenuManager manager) { //rightmost pull-down
363 364 365 366 367
        manager.add(clearInstallationPropertiesAction);
        manager.add(clearPackagePropertiesAction);
        manager.add(clearProjectPropertiesAction);
        manager.add(clearToolPropertiesAction);
        manager.add(new Separator());
368
        manager.add(selectDesignMenuAction); // got null
369
        manager.add(new Separator());
370 371
        manager.add(clearStateFilesAction);
        manager.add(clearLogFilesAction);
372
        manager.add(clearToolStatesAction);
373
        manager.add(new Separator());
374
        manager.add(clearProjectStatesAction);
375
    }
376 377 378 379 380 381 382 383 384 385
    
    private void fillContextMenu(IMenuManager manager) { // context (right-click) menu
    	// Always come here after setting launchActions, so just add all launchActions here
    	/**+       manager.add(launchAction); */
    	if (launchActions!=null) { 
    		for (Action action:launchActions){
    			manager.add(action); // No Separator??
    		}
    	}
   	
386
//    	System.out.println("fillContextMenu(), launchActions="+launchActions);
387
        //      manager.add(new Separator());
388
//      drillDownAdapter.addNavigationActions(manager);
389
      // Other plug-ins can contribute their actions here
390 391 392 393 394 395 396 397 398 399
    	
    	if (pinAction!=null){
    		manager.add(new Separator());
    		manager.add(pinAction);
    	}    	
    	if ((restoreAction!=null) || (restoreSelectAction!=null) ) {
    		manager.add(new Separator()); 
    		if (restoreAction!=null) manager.add(restoreAction);
    		if (restoreSelectAction!=null) manager.add(restoreSelectAction);
    	}    	
400 401 402 403 404
    	if ((playbackLogLatestAction!=null) || (playbackLogSelectAction!=null) ) {
    		manager.add(new Separator()); 
    		if (playbackLogLatestAction!=null) manager.add(playbackLogLatestAction);
    		if (playbackLogSelectAction!=null) manager.add(playbackLogSelectAction);
    	}
405
        manager.add(new Separator()); 
406 407 408 409
        manager.add(showInstallationPropertiesAction);
        manager.add(showPackagePropertiesAction);
        manager.add(showProjectAction);
        manager.add(showPropertiesAction);
410
//        manager.add(showLaunchConfigAction);
411 412 413
        manager.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));
    }
        
414
    private void fillLocalToolBar(IToolBarManager manager) { // On Horizontal bar
415 416 417 418 419 420 421 422
/**+               manager.add(launchAction); */
     	if (launchActions!=null) { 
    		for (Action action:launchActions){
    			manager.add(action); // No Separator??
    		}
    	}
//    	System.out.println("fillLocalToolBar(), launchActions="+launchActions);
   	 
423
//        manager.add(launchAction);  // test
424 425
//      manager.add(new Separator());
//      drillDownAdapter.addNavigationActions(manager);
426
        manager.add(new Separator("toolbar-separator"));
427
        manager.add(toggleLinkedTools);
428 429 430
        manager.add(toggleSaveTools);
        manager.add(toggleStopTools);
        manager.add(new Separator());
431 432 433 434
        manager.add(showInstallationPropertiesAction);
        manager.add(showPackagePropertiesToolbarAction);
        manager.add(showProjectPropertiesToolbarAction);
        manager.add(showPropertiesAction);
435 436
        manager.update(false); // (force) - added new, but removed project, tool and clear/change menu for Icarus (kept the same number of items) Need to update higher menu
        getViewSite().getActionBars().updateActionBars();
437
    }
438
    
439
    private void makeActions() {
440 441 442 443
    	final DesignFlowView fDesignFlowView=this;
		if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_OTHER)) {
			System.out.println("makeActions()");
		}
444 445 446 447 448 449 450 451 452 453
		
	    toggleLinkedTools= new Action("Toggle tool dependency", Action.AS_CHECK_BOX) {
            public void run() {
//            	System.out.println("isChecked()="+isChecked());
            	SelectedResourceManager.getDefault().setToolsLinked(!isChecked());
            	if (isChecked()){
            		toggleLinkedTools.setImageDescriptor(VDTPluginImages.DESC_TOOLS_UNLINKED);
            	} else {
            		toggleLinkedTools.setImageDescriptor(VDTPluginImages.DESC_TOOLS_LINKED);
            	}
Andrey Filippov's avatar
Andrey Filippov committed
454 455
//            	toolSequence.setToolsDirtyFlag(false); //boolean update) - recalculate dirty flags
            	fDesignFlowView.updateLaunchAction(true); // will call toolSequence.setToolsDirtyFlag(false)
456 457 458 459 460
            }
        };
        toggleLinkedTools.setToolTipText("Toggle tool dependency");
        toggleLinkedTools.setImageDescriptor(VDTPluginImages.DESC_TOOLS_LINKED);
        toggleLinkedTools.setChecked(!SelectedResourceManager.getDefault().isToolsLinked()); // normally happens before reading memento
461 462 463 464 465 466 467 468 469 470
        

        toggleSaveTools= new Action("Save tool state", Action.AS_CHECK_BOX) {
            public void run() {
            	toolSequence.setSave(isChecked());
            }
        };
        toggleSaveTools.setToolTipText("Save tool state");
        toggleSaveTools.setImageDescriptor(VDTPluginImages.DESC_TOOLS_SAVE);
        
471 472
        //isSaveEnabled()
        
473 474 475 476 477 478 479 480 481

        toggleStopTools= new Action("Stop tools", Action.AS_CHECK_BOX) {
            public void run() {
            	toolSequence.setStop(isChecked());
            }
        };
        toggleStopTools.setToolTipText("Request tool sequence stop (when convenient), with <SHFT> - mark stopped (for debug)");
        toggleStopTools.setImageDescriptor(VDTPluginImages.DESC_TOOLS_STOP);
         
482
		
483 484
        showInstallationPropertiesAction = new Action() {
            public void run() {
485
                if (openInstallationPropertiesDialog()==Window.OK){
486 487 488
            		if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_OTHER)) {
            			System.out.println("openInstallationPropertiesDialog()-> OK");
            		}
Andrey Filippov's avatar
Andrey Filippov committed
489
                	fDesignFlowView.updateLaunchAction(true);
490
                }; 
491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507
            }
        };
        showInstallationPropertiesAction.setText("Installation Parameters");
        showInstallationPropertiesAction.setToolTipText("Set installation parameters");
        showInstallationPropertiesAction.setImageDescriptor(VDTPluginImages.DESC_INSTALL_PROPERTIES);
        showInstallationPropertiesAction.setEnabled(ToolsCore.getInstallationContext() != null);

        clearInstallationPropertiesAction = new ClearAction("Do you wish to delete values of installation parameters?") {
            public void clear() {
                SetupOptionsManager.clear();    
            }
        };
        clearInstallationPropertiesAction.setText("Clear Installation Parameters");
        clearInstallationPropertiesAction.setImageDescriptor(VDTPluginImages.DESC_INSTALL_PROPERTIES);
        clearInstallationPropertiesAction.setEnabled(ToolsCore.getInstallationContext() != null);
        
        
508
        showPackagePropertiesToolbarAction = new GlobalContextsAction("Package Parameters",fDesignFlowView);
509 510 511 512 513 514
        showPackagePropertiesToolbarAction.setText("Package Parameters");
        showPackagePropertiesToolbarAction.setToolTipText("Set package parameters for this tool");
        showPackagePropertiesToolbarAction.setImageDescriptor(VDTPluginImages.DESC_PACKAGE_PROPERTIES);
        
        showPackagePropertiesAction = new Action() {
            public void run() {
515 516 517 518 519
            	if (GlobalContextsAction.openDialog( "Package Parameters"
                                               , selectedItem.getPackageContext() )==Window.OK){
            		if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_OTHER)) {
            			System.out.println("GlobalContextsAction.openDialog()-> OK");
            		}
Andrey Filippov's avatar
Andrey Filippov committed
520
                	fDesignFlowView.updateLaunchAction(); // is it already updated?
521
                }; 
522 523 524 525 526 527 528 529 530 531 532
            }
        };
        showPackagePropertiesAction.setText("Package Parameters");
        showPackagePropertiesAction.setToolTipText("Set package parameters");
        showPackagePropertiesAction.setImageDescriptor(VDTPluginImages.DESC_PACKAGE_PROPERTIES);

        clearPackagePropertiesAction = new ClearContextAction("Do you wish to delete values of packages parameters?");
        clearPackagePropertiesAction.setText("Clear Package Parameters");
        clearPackagePropertiesAction.setImageDescriptor(VDTPluginImages.DESC_PACKAGE_PROPERTIES);

        
533
        showProjectPropertiesToolbarAction = new LocalContextsAction("Project Parameters",fDesignFlowView);
534
        showProjectPropertiesToolbarAction.setText("Project Parameters");
535
        showProjectPropertiesToolbarAction.setToolTipText("Set project parameters (toolbar)");
536 537 538 539
        showProjectPropertiesToolbarAction.setImageDescriptor(VDTPluginImages.DESC_PROJECT_PROPERTIES);

        showProjectAction = new Action() {
            public void run() {
540
            	if (LocalContextsAction.openDialog( "Project Parameters"
541
                                              , selectedItem.getProjectContext() 
542
                                              , selectedResource.getProject() )==Window.OK){
543 544 545
            		if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_OTHER)) {
            			System.out.println("LocalContextsAction.openDialog()-> OK");
            		}
Andrey Filippov's avatar
Andrey Filippov committed
546
                	fDesignFlowView.updateLaunchAction(); // is it already updated?
547
                }; 
548 549 550
            }
        };
        showProjectAction.setText("Project Parameters");
551
        showProjectAction.setToolTipText("Set project parameters (context menue)");
552 553 554 555 556 557 558 559 560
        showProjectAction.setImageDescriptor(VDTPluginImages.DESC_PROJECT_PROPERTIES);
        
        clearProjectPropertiesAction = new ClearLocalContextAction("Do you wish to delete values of projects parameters?");
        clearProjectPropertiesAction.setText("Clear Project Parameters");
        clearProjectPropertiesAction.setImageDescriptor(VDTPluginImages.DESC_PROJECT_PROPERTIES);

        
        showPropertiesAction = new Action() {
            public void run() {
561
            	if (openToolPropertiesDialog(selectedItem)==Window.OK){
562 563 564
            		if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_OTHER)) {
            			System.out.println("openToolPropertiesDialog()-> OK");
            		}
Andrey Filippov's avatar
Andrey Filippov committed
565
                	fDesignFlowView.updateLaunchAction(true);
566
                };  
567 568 569 570 571 572 573
//              ConsoleView.getDefault().println("Action 1 executed", ConsoleView.MSG_INFORMATION);                
            }
        };
        showPropertiesAction.setText("Tool Parameters");
        showPropertiesAction.setToolTipText("Set tool parameters");
        showPropertiesAction.setImageDescriptor(VDTPluginImages.DESC_TOOL_PROPERTIES);

574
        clearToolPropertiesAction = new ClearAction("Do you wish to delete values of the tool parameters?") {
575 576 577 578 579
            public void clear() {
                OptionsCore.doClearContextOptions(selectedItem.getTool(), selectedResource.getProject());
            }
        };
        clearToolPropertiesAction.setText("Clear Tool Parameters");
580
        clearToolPropertiesAction.setImageDescriptor(VDTPluginImages.DESC_TOOL_PROPERTIES);
581
        selectDesignMenuAction = new Action() {
582 583
            public void run() {
                if (selectedResource == null){
584
                	HdlEditor editor = HdlEditor.getCurrentEditor();
585 586 587 588 589 590
                	if ((editor != null) && (editor.getDocument() != null) && (editor.getDocument() instanceof HdlDocument) ){
                		selectedResource = ((HdlDocument)editor.getDocument()).getFile();
                	} else {
                		return;
                	}
                }
591 592 593 594
                openDesignMenuSelectionDialog(selectedResource.getProject());
            }
        };
        selectDesignMenuAction.setText("Change Design Menu");
595
        selectDesignMenuAction.setImageDescriptor(VDTPluginImages.DESC_DESIGN_MENU);
596 597

        clearToolStatesAction = new ClearToolStates("Do you wish to reset all tool states (as if they never ran)?",toolSequence);
598
        clearToolStatesAction.setText("Clear tool states");
599 600 601 602 603 604
        clearToolStatesAction.setImageDescriptor(VDTPluginImages.DESC_ERASE);

        clearProjectStatesAction = new ClearProjectStates("Do you wish to reset the project state (persistent storage) as if no tools ran?",
        		toolSequence);
        clearProjectStatesAction.setText("Clear project state (debug feature)");
        clearProjectStatesAction.setImageDescriptor(VDTPluginImages.DESC_ERASE);
605 606

        clearStateFilesAction = new ClearStateFiles("Do you wisth to remove all state files (snapshots), but the current ones?",toolSequence);
607
        clearStateFilesAction.setText("Clear all but the latest snapshot files");
608
        clearStateFilesAction.setImageDescriptor(VDTPluginImages.DESC_ERASE);
609 610

        clearLogFilesAction = new ClearLogFiles("Do you wisth to remove all log files, but the most recent?",toolSequence);
611
        clearLogFilesAction.setText("Clear all but the latest log files");
612
        clearLogFilesAction.setImageDescriptor(VDTPluginImages.DESC_ERASE);
613
        
614
        showLaunchConfigAction = new Action() {
615 616
            public void run() {
                try {
617 618 619
                    int result = openToolLaunchDialog(
                    		selectedItem,
                    		fDesignFlowView);
620 621 622
            		if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_OTHER)) {
            			System.out.println("Ran openToolLaunchDialog() ->"+result);
            		}
Andrey Filippov's avatar
Andrey Filippov committed
623
                	fDesignFlowView.updateLaunchAction(true);
624 625 626 627 628 629 630
                } catch (CoreException e) {
                    MessageUI.error(Txt.s("Action.OpenLaunchConfigDialog.Error", 
                                          new String[] {selectedItem.getLabel(), e.getMessage()}),
                                    e);
                }    
            }
        };
631
        showLaunchConfigAction.setText("Launch configuration");
632
        showLaunchConfigAction.setToolTipText("Open launch configuration dialog for this tool");
633
        showLaunchConfigAction.setImageDescriptor(VDTPluginImages.DESC_LAUNCH_CONFIG);
634 635 636
        launchActions=null;
        doubleClickListener=null;
        
637 638
    } // makeActions()

639 640 641 642 643 644
    private void removeDoubleClickAction() {
    	if (doubleClickListener!=null){
        	viewer.removeDoubleClickListener(doubleClickListener);
        	doubleClickListener=null;
    	}
    }
645
    private void hookDoubleClickAction() {
646 647 648 649 650 651 652
    	if ((launchActions==null) || (launchActions[0]==null)) return;
    	doubleClickListener=new IDoubleClickListener() {
    		public void doubleClick(DoubleClickEvent event) {
    			launchActions[0].run();  // Andrey: will go to launchAction[0].run
    		}
    	};
    	viewer.addDoubleClickListener(doubleClickListener);
653
    }
654
    
655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679
//    private void showMessage(String message) {
//        MessageDialog.openInformation( viewer.getControl().getShell()
//                                     , "Design Flow"
//                                     , message );
//    }

    /**
     * Passing the focus request to the viewer's control.
     */
    public void setFocus() {
        viewer.getControl().setFocus();
    }

//    private IWorkbenchPart getActivePart() {
//        IWorkbenchWindow window= getSite().getWorkbenchWindow();
//        IPartService service= window.getPartService();
//        return service.getActivePart();
//    }
    
    // ------------------------------------------------------------------------
    //                    Design Flow logic 
    // ------------------------------------------------------------------------

    /* Method declared on ISelectionListener */
    public void selectionChanged(IWorkbenchPart part, ISelection selection) {
680 681
		if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_OTHER))
			System.out.println(">>>>> DesignFlowView.selectionChanged(, new selection)="+selection+" selectedResource="+selectedResource);
682
        IResource oldSelection = selectedResource; 
683 684 685 686 687 688 689 690 691 692 693
     // Save old project if it changed, before doin anything else
        IProject oldProject= (selectedResource ==null)? null : selectedResource.getProject();
        IResource newSelectedResource=SelectedResourceManager.getDefault().getSelectedResource(part, selection);
        IProject newProject= (newSelectedResource ==null)? null : newSelectedResource.getProject();
//        	if (HDLFile.getProject().getFullPath().toPortableString().equals(project.getFullPath().toPortableString())){
        
        if ((oldProject != null) && 
        		((newProject == null) ||
        		!oldProject.getFullPath().toPortableString().equals(newProject.getFullPath().toPortableString()))){
		    saveState(oldProject);
        }
694
        selectedResource = SelectedResourceManager.getDefault().getSelectedResource(part, selection);
695 696 697
//        IProject newProject = selectedResource == null 
//                            ? null
//                            : selectedResource.getProject();
698 699 700 701
        
        if ( (oldSelection == null) || 
             (newProject != oldSelection.getProject())
           ) {
702
            doLoadDesignMenu(newProject);
703 704 705
        }
        updateLaunchAction();
    } // selectionChanged()
706 707 708
    // Made it public to call from ContexOptionsDialog.okPressed() as launch actions might change
//    private void updateLaunchAction() {
    public void updateLaunchAction() {
Andrey Filippov's avatar
Andrey Filippov committed
709 710 711 712 713 714 715
    	updateLaunchAction(false);
    }

    public void updateLaunchAction(boolean updateDirty) {
    	if (updateDirty){
    		toolSequence.setToolsDirtyFlag(false); // if true - recalculates parameters
    	}
716

717 718
//    	System.out.println("DesignFlowView.updateLaunchAction()");

719 720 721 722 723 724
        IProject project = selectedResource == null 
                         ? null
                         : selectedResource.getProject();
        showProjectPropertiesToolbarAction.setProject(project);
        clearProjectPropertiesAction.setProject(project);

725 726
     // Selected item should be not null, but resource - may be        
     // RunFor[] getMenuActions()
727
        RunFor [] runFor=null;
728
        Tool tool=null;
729
        String ignoreFilter=null;
730
        if (selectedItem != null){
731
        	tool= selectedItem.getTool();
732
        	if (tool!=null){
733
        		runFor=tool.getMenuActions(project);
734
        		ignoreFilter=tool.getIgnoreFilter(); // should be after getMenuActions(project) that recalculates parameters
735
        		tool.initIcons(false); // if not done before - add icons list for actions
736 737 738 739 740 741 742 743 744 745 746
        		if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_OTHER)) {
        			System.out.println("Got Runfor["+((runFor!=null)?runFor.length:"null")+"]");
        			if (runFor!=null){
        				for (int i=0;i<runFor.length;i++){
        					System.out.println(
        							"    label='"+runFor[i].getLabel()+
        							"', resource='"+runFor[i].getResource()+
        							"', checkExtension='"+runFor[i].getCheckExtension()+
        							"', checkExistence='"+runFor[i].getCheckExistence()+
        							"'");
        				}
747 748 749 750
        			}
        		}
        	}
        }
751
        final Tool fTool=tool;
752 753
        boolean enabled = (selectedItem != null) // At startup null (twice went through this); Right Click - "Icarus Ver..."
                       && (selectedResource != null) // at startup x353_1.tf;  Right Click - "L/x353/x353_1.tf
754
                       && (selectedItem.isEnabled(selectedResource));
755 756 757 758 759
        
 // Deal with new menus
//        removeLaunchActions(); 
        removeDoubleClickAction();
        launchActions=null;
760 761
        playbackLogLatestAction=null;
        playbackLogSelectAction=null;
762 763 764 765
        pinAction=null;
        restoreAction=null;
        restoreSelectAction=null;

766 767 768 769 770
        if ((runFor!=null) && (project!=null)){
        	launchActions=new Action [runFor.length];
        	for (int i=0;i<runFor.length;i++){
//                String name=runFor[i].getResource();
                String name=SelectedResourceManager.getDefault().tryRelativePath(runFor[i].getResource());
771 772
//                String shortName=name;
                String shortName=runFor[i].getResource(); // as entered
773 774 775 776
                String fullPath=name;
                enabled=(selectedItem != null);
                if (enabled && runFor[i].getCheckExistence()){
                	IPath path = new Path(name);
777 778 779 780 781 782 783 784 785
                	IFile file = null;
                	if (path!=null) {
                		try {
                			file = project.getFile(path);
                		} catch (IllegalArgumentException e) {

                		}
                	}
                	
786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809
                	if (file==null){
//                		System.out.println(name+" does not exist");
                		enabled=false;
                	} else {
                		shortName=file.getName();
//                		fullPath=file.getFullPath().toString(); // What is different?
                		fullPath=file.getLocation().toOSString(); // that matches generators
                		
                	}
                }
                if (enabled && runFor[i].getCheckExtension()){
                	enabled= selectedItem.isEnabled(name);
                	if (enabled && !runFor[i].getCheckExistence()) { // try to get resource and full path name, but no error if it fails
                    	IPath path = new Path(name);
                    	IFile file = (path==null)?null:project.getFile(path);
                    	if (file!=null){
                    		shortName=file.getName();
//                    		fullPath=file.getFullPath().toString(); // What is different?
                    		fullPath=file.getLocation().toOSString(); // that matches generators
                    	}
                	}
                }
        		final int finalI=i;
        		final String fFullPath=fullPath;
810
                final String fIgnoreFilter=ignoreFilter;
811
//                final DesignFlowView fDesignFlowView=this;
812

813 814 815
                launchActions[i] = new Action() {
                    public void run() {
                        try {
816
                            launchTool(
817
                            		fTool, // tool, will get 
818
                            		TOOL_MODE.RUN,
819 820 821
                            		finalI,
                            		fFullPath,
                            		fIgnoreFilter);
822 823 824 825 826 827 828 829
                        } catch (Exception e) {
                            MessageUI.error( Txt.s("Action.ToolLaunch.Error", 
                                                   new String[] {selectedItem.getLabel(), e.getMessage()})
                                            , e);
                        }    
                    }
                };
                launchActions[i].setToolTipText(i+": "+runFor[i].getLabel()+" "+shortName);
830 831 832 833 834
                if (shortName.indexOf("@")>=0){
                    launchActions[i].setText(runFor[i].getLabel()+" "+shortName+"@");
                } else {
                    launchActions[i].setText(runFor[i].getLabel()+" "+shortName);
                }
835
                launchActions[i].setEnabled(enabled);
836 837 838 839
        		if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_OTHER)) {
        			System.out.println("shortName="+shortName);
        			System.out.println("launchActions[i].getText()="+launchActions[i].getText());
        		}
840
                String actionIconKey=tool.getImageKey(i);
841
                if ((actionIconKey!=null) && (VDTPluginImages.getImageDescriptor(actionIconKey)!=null)) {
842
                	launchActions[i].setImageDescriptor(VDTPluginImages.getImageDescriptor(actionIconKey));
843 844
//                	System.out.println(i+":"+actionIconKey+" - "+ VDTPluginImages.getImageDescriptor(actionIconKey));
                }else
845
                	launchActions[i].setImageDescriptor(VDTPluginImages.DESC_RUN_TOOL);
846 847
                
                if (i==0) { // set log play-back (always for default tool only)
848 849 850 851 852 853 854 855 856
// Add pinned action;                	
                	pinAction=new Action("Toggle tool dependency", Action.AS_CHECK_BOX){
                		public void run(){
                			fTool.setPinned(isChecked());
                		}
                	};
                	pinAction.setText("Pin "+tool.getName());
                	pinAction.setToolTipText("Do not automatically re-run "+tool.getName()+" when its dependency changes");
                	pinAction.setEnabled((tool.getState()==TOOL_STATE.SUCCESS) || (tool.isPinned()));
857
                	pinAction.setChecked(tool.isPinned());
858 859 860 861 862
                	pinAction.setImageDescriptor(VDTPluginImages.DESC_TOOLS_PIN);
                	if (tool.getRestore()!=null){
                		restoreAction=new Action(){
                    		public void run(){
                    			String stateFileName=toolSequence.getSelectedStateFile(fTool, false);
863 864 865 866
                    			if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_TOOL_SEQUENCE)) { 
                    				System.out.println("*** Will restore latest state of "+fTool.getName());
                    				System.out.println("***Selected restore file: "+stateFileName);
                    			}
867 868 869 870 871 872
                    			Tool restoreTool=fTool.getRestore();
                    			if ((stateFileName!=null) && (restoreTool!=null)){
                    				restoreTool.setResultFile(stateFileName);
                                    try {
                                        launchTool(
                                        		restoreTool,
873
                                        		TOOL_MODE.RESTORE,
874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894
                                        		0,
                                        		fFullPath,
                                        		fIgnoreFilter);
                                    } catch (Exception e) {
                                    	MessageUI.error( Txt.s("Action.ToolLaunch.Error", 
                                    			new String[] {fTool.getName()+" -> "+
                                    					restoreTool.getName() , e.getMessage()}), e);
                                    }    
                    				
                    			}
                    			
                    		}
                    	};
                    	restoreAction.setText("Restote latest "+tool.getName());
                    	restoreAction.setToolTipText("Restore state of the latest successful run of "+tool.getName());
                    	restoreAction.setEnabled(tool.getRestore()!=null); // just to decide should it be removed or disabled
                    	restoreAction.setImageDescriptor(VDTPluginImages.DESC_TOOLS_RESTORE);

                    	restoreSelectAction=new Action(){
                    		public void run(){
                    			System.out.println("*** Will restore selected state of "+fTool.getName());
Andrey Filippov's avatar
Andrey Filippov committed
895
                    			String stateFileName=toolSequence.getSelectedStateFile(fTool, true);
896 897 898 899 900 901 902
                    			System.out.println("***Selected restore file: "+stateFileName);
                    			Tool restoreTool=fTool.getRestore();
                    			if ((stateFileName!=null) && (restoreTool!=null)){
                    				restoreTool.setResultFile(stateFileName);
                                    try {
                                        launchTool(
                                        		restoreTool,
903
                                        		TOOL_MODE.RESTORE,
904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919
                                        		0,
                                        		fFullPath,
                                        		fIgnoreFilter);
                                    } catch (Exception e) {
                                    	MessageUI.error( Txt.s("Action.ToolLaunch.Error", 
                                    			new String[] {fTool.getName()+" -> "+
                                    					restoreTool.getName() , e.getMessage()}), e);
                                    }    
                    			}
                    		}
                    	};
                    	restoreSelectAction.setText("Restote selected "+tool.getName());
                    	restoreSelectAction.setToolTipText("Restore state of the selected successful run of "+tool.getName());
                    	restoreSelectAction.setEnabled(tool.getRestore()!=null); // just to decide should it be removed or disabled
                    	restoreSelectAction.setImageDescriptor(VDTPluginImages.DESC_TOOLS_RESTORE_SELECT);
                	}
920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958
                	boolean logEnabled=(tool.getLogDir()!=null);
// see if tool has log-dir                	
                	playbackLogLatestAction=new Action() {
                        public void run() {
                            try {
                            	playLogs(
                                		false,
                                		fFullPath,
                                		fIgnoreFilter);
                            } catch (Exception e) {
                                MessageUI.error( Txt.s("Action.ToolLaunch.Error", 
                                                       new String[] {selectedItem.getLabel(), e.getMessage()})
                                                , e);
                            }    
                        }
                    };
                    playbackLogSelectAction=new Action() {
                        public void run() {
                            try {
                            	playLogs(
                                		true,
                                		fFullPath,
                                		fIgnoreFilter);
                            } catch (Exception e) {
                                MessageUI.error( Txt.s("Action.ToolLaunch.Error", 
                                                       new String[] {selectedItem.getLabel(), e.getMessage()})
                                                , e);
                            }    
                        }
                    };
                    playbackLogLatestAction.setText("Playback latest log for "+tool.getName());
                    playbackLogSelectAction.setText("Select/playback log for "+tool.getName());
                    playbackLogLatestAction.setToolTipText("Playback latest log for "+runFor[i].getLabel()+" "+shortName);
                    playbackLogSelectAction.setToolTipText("Select and playback log for "+runFor[i].getLabel()+" "+shortName);
                    playbackLogLatestAction.setEnabled(logEnabled);
                    playbackLogSelectAction.setEnabled(logEnabled);
                    playbackLogLatestAction.setImageDescriptor(VDTPluginImages.DESC_PLAY_BACK);
                    playbackLogSelectAction.setImageDescriptor(VDTPluginImages.DESC_PLAY_BACK_SELECT);
                }
959 960 961 962 963 964
        	}
            IToolBarManager toolbarManager= getViewSite().getActionBars().getToolBarManager();
            toolbarManager.removeAll();
            fillLocalToolBar(toolbarManager);
        	hookDoubleClickAction();
        }
965

966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997
        enabled = (selectedItem != null)
               && (selectedResource != null)
               && (selectedItem.getPackageContext() != null);
        showPackagePropertiesAction.setEnabled(enabled);
        clearPackagePropertiesAction.setEnabled(enabled);
        if (enabled){
            String projectName = project.getName(); 
            showPackagePropertiesAction.setText(Txt.s("Action.PackageProperties.Caption", new String[]{selectedItem.getLabel()}));
            showPackagePropertiesAction.setToolTipText(Txt.s("Action.PackageProperties.ToolTip", new String[]{selectedItem.getLabel(), projectName}));
        } else {
            showPackagePropertiesAction.setText(Txt.s("Action.PackageProperties.Caption.Default"));
            showPackagePropertiesAction.setToolTipText(Txt.s("Action.PackageProperties.ToolTip.Default"));
        }
        
        enabled = (selectedItem != null)
               && (selectedResource != null)
               && (selectedItem.getProjectContext() != null);
        showProjectAction.setEnabled(enabled);
        clearProjectPropertiesAction.setEnabled(enabled);
        if (enabled){
            String projectName = project.getName(); 
            showProjectAction.setText(Txt.s("Action.ProjectProperties.Caption", new String[]{selectedItem.getLabel()}));
            showProjectAction.setToolTipText(Txt.s("Action.ProjectProperties.ToolTip", new String[]{selectedItem.getLabel(), projectName}));
        } else {
            showProjectAction.setText(Txt.s("Action.ProjectProperties.Caption.Default"));
            showProjectAction.setToolTipText(Txt.s("Action.ProjectProperties.ToolTip.Default"));
        }
        
        enabled = (selectedItem != null)
               && (selectedItem.getTool() != null);
        showPropertiesAction.setEnabled(enabled);
        clearToolPropertiesAction.setEnabled(enabled);
998
        
999 1000
        toggleSaveTools.setEnabled(toolSequence.isSaveEnabled());
        
1001
        ((ViewLabelProvider) viewer.getLabelProvider()).fireChanged();
1002 1003
    } // updateLaunchAction()

1004
    private void launchTool(
1005
    		Tool tool,
1006
    		TOOL_MODE mode,
1007 1008 1009
    		int choice,
    		String fullPath,
    		String ignoreFilter) throws CoreException {
1010
    	if (tool != null) {
Andrey Filippov's avatar
Andrey Filippov committed
1011
    		toolSequence.launchToolSequence(tool,mode, choice, fullPath, ignoreFilter);
1012 1013 1014 1015 1016 1017
    	} else if (selectedItem.hasChildren()) {
    		if (viewer.getExpandedState(selectedItem))
    			viewer.collapseToLevel(selectedItem, AbstractTreeViewer.ALL_LEVELS);
    		else    
    			viewer.expandToLevel(selectedItem, 1);
    	}
1018 1019
    } // launchTool()
    
1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030
    private void playLogs(
    		boolean select, // select log file
    		String fullPath,
    		String ignoreFilter) throws CoreException {
        Tool tool = selectedItem.getTool();
        if (tool != null) {
        	String logBuildStamp=select?selectBuildStamp(tool):""; // "" - latest (link)
        	if (logBuildStamp==null) return; // cancelled selection
    		if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_OTHER)) {
    			System.out.println("logBuildStamp="+logBuildStamp);
    		}
Andrey Filippov's avatar
Andrey Filippov committed
1031 1032 1033 1034
        	toolSequence.playLogs(
        			tool,
            		fullPath,
            		logBuildStamp);
1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071
        } else if (selectedItem.hasChildren()) {
            if (viewer.getExpandedState(selectedItem))
                viewer.collapseToLevel(selectedItem, AbstractTreeViewer.ALL_LEVELS);
            else    
                viewer.expandToLevel(selectedItem, 1);
        }
    } // launchTool()
    
    private String selectBuildStamp(Tool tool){
//    	System.out.println("tool.getLogDir()="+tool.getLogDir());
//    	System.out.println("ToolLogFile.getDir(tool.getLogDir()).getLocation()="+ToolLogFile.getDir(tool.getLogDir()).getLocation());
    	FilteredFileSelector selector= new FilteredFileSelector(
    			ToolLogFile.getDir(tool.getLogDir()).getLocation().toFile() , //File dir,
    			"Select log file", //String title,
    			 null, // Component parent, or convert from SHell VerilogPlugin.getActiveWorkbenchShell()
    			"Select", //String approveText,
    			"Select timestamp by selecting available log file", //String approveToolTip,
    			ToolLogFile.getBaseRegex(tool.getName()), // String filterRegex,
    			"Matchig log files for "+tool.getName(), //String filterDescription,
    			false //boolean allowDirs
    			);
    	File result=selector.openDialog();
    	if (result == null) {
    		if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_OTHER))
    			System.out.println("Selection canceled");
    		return null;
    	}
//    	System.out.println("Got file "+result.toString());
//    	System.out.println("Timestamp="+ToolLogFile.getTimeStamp(
//    			tool.getName(),
//    			result.getName()));
    	return ToolLogFile.getTimeStamp(
    			tool.getName(),
    			result.getName());
    }
    
    
1072
    private int openInstallationPropertiesDialog() {
1073 1074 1075 1076 1077
        Shell shell = VerilogPlugin.getActiveWorkbenchShell();
        SetupOptionsDialog dialog = new SetupOptionsDialog(shell);
//        ContextOptionsDialog dialog = new ContextOptionsDialog(shell, ToolsCore.getContextManager().getInstallationContext());
        dialog.setTitle("Instalation Parameters");
        dialog.create();
1078 1079
        return dialog.open();
        
1080 1081 1082
    } // openInstallationPropertiesDialog()

    
1083
    private int openToolPropertiesDialog(DesignMenuModel.Item item) {
1084
        Shell shell = VerilogPlugin.getActiveWorkbenchShell();
1085 1086
        Context context = item.getTool();
        context.setTreeReparse(true); 
1087 1088 1089 1090 1091
        ContextOptionsDialog dialog = new ContextOptionsDialog( shell
                                                              , context 
                                                              , selectedResource.getProject() );
        dialog.setTitle("Tool Parameters");
        dialog.create();
1092
        return dialog.open();
1093 1094
    } // openToolPropertiesDialog()

1095
    private int openDesignMenuSelectionDialog(IProject project) {
1096 1097 1098 1099
        Shell shell = VerilogPlugin.getActiveWorkbenchShell();
        DesignMenuSelectionDialog dialog = new DesignMenuSelectionDialog( shell
                                                                        , desigMenuName.getValue() ); 
        dialog.create();
1100 1101
        int result=dialog.open();
        if (result == Window.OK) {
1102
 //       	System.out.println("openDesignMenuSelectionDialog()-> OK");
1103 1104 1105
            DesignMenu newDesignMenu = dialog.getSelectedDesignMenu();
            String newDesignMenuName = newDesignMenu == null ? null
                                                             : newDesignMenu.getName();
1106
            desigMenuName.setValue(newDesignMenuName); // ??? Andrey
1107 1108 1109
            OptionsCore.doStoreOption(desigMenuName, project);
            doLoadDesignMenu(newDesignMenuName);
        }
1110
        return result;
1111 1112
    }

1113

1114 1115 1116 1117
    private int openToolLaunchDialog(
    		DesignMenuModel.Item item,
    		DesignFlowView designFlowView
    		) throws CoreException {
1118 1119
    	System.out.println("openToolLaunchDialog()");

1120
        Shell shell = VerilogPlugin.getActiveWorkbenchShell();
1121 1122 1123 1124 1125
        ILaunchConfiguration launchConfig = LaunchCore.createLaunchConfiguration(
        		item.getTool(),
        		selectedResource.getProject(),
        		null,
        		null);
1126
        IStructuredSelection selection = new StructuredSelection(launchConfig);
1127
        return DebugUITools.openLaunchConfigurationDialogOnGroup( shell
1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143
                                                         , selection
                                                         , VDT.ID_VERILOG_TOOLS_LAUNCH_GROUP );                        
    } // openToolLaunchDialog()
    
    
    // ------------------------------------------------------------------------
    //                      Tree of the tools 
    // ------------------------------------------------------------------------

    class ToolSelectionChangedListener implements ISelectionChangedListener {
        
        public void selectionChanged(SelectionChangedEvent event) {
            ISelection selection = event.getSelection();
            Object obj = ((IStructuredSelection)selection).getFirstElement();
            selectedItem = (DesignMenuModel.Item) obj;
            if (selectedResource == null)
Andrey Filippov's avatar
Andrey Filippov committed
1144 1145 1146
//                selectedResource = SelectedResourceManager.getDefault().getViewSelectedResource(IPageLayout.ID_RES_NAV);
            	selectedResource = SelectedResourceManager.getDefault().getViewSelectedResource(IPageLayout.ID_PROJECT_EXPLORER);
            //
1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219
            updateLaunchAction();
        }    
    } // class ToolSelectionChangedListener
    
    
    // ------------------------------------------------------------------------
    /*
     * The content provider class is responsible for providing objects to 
     * the view. It can wrap existing objects in adapters or simply return
     * objects as-is. These objects may be sensitive to the current input 
     * of the view, or ignore it and always show the same content 
     * (like Task List, for example).
     */
    class ViewContentProvider implements IStructuredContentProvider 
                                       , ITreeContentProvider {
        private DesignMenuModel invisibleRoot;
        private DesignMenu designMenu;

        public void inputChanged(Viewer v, Object oldInput, Object newInput) {
            invisibleRoot = null;
            if ((newInput != null) && (newInput instanceof DesignMenu))
                designMenu = (DesignMenu) newInput;
            else 
                designMenu = null;
            v.refresh();
        }
        
        public void dispose() { }
  
        public Object[] getElements(Object parent) {
//            if (parent.equals(getViewSite())) {
            if (parent == designMenu) {
                if (invisibleRoot == null) 
                    initialize();
                return getChildren(invisibleRoot);
            }
            return getChildren(parent);
        }
        public Object getParent(Object child) {
            if (child instanceof DesignMenuModel.Item) {
                return ((DesignMenuModel.Item)child).getParent();
            }
            return null;
        }
        public Object [] getChildren(Object parent) {
            if (parent == null) {
                return new Object[0];
            } else if (parent == invisibleRoot) {
                return invisibleRoot.getItems();
            } else if (parent instanceof DesignMenuModel.Item) {
                return ((DesignMenuModel.Item)parent).getChildren();
            }
            return new Object[0];
        }
        public boolean hasChildren(Object parent) {
            if (parent == null) {
                return false;
            } else if (parent == invisibleRoot) {
                return invisibleRoot.getItems().length > 0;
            } else if (parent instanceof DesignMenuModel.Item) {
                return ((DesignMenuModel.Item)parent).hasChildren();
            }    
            return false;
        }

        private void initialize() {
            if (designMenu != null)
                invisibleRoot = new DesignMenuModel(designMenu);
        }
    } // class ViewContentProvider
    
    //-------------------------------------------------------------------------
    class ViewLabelProvider extends LabelProvider {
1220 1221 1222 1223
    	
    	public void fireChanged(){
    		fireLabelProviderChanged(new LabelProviderChangedEvent(this));
    	}
1224 1225 1226 1227

        public String getText(Object obj) {
            return obj.toString();
        }
1228
        
1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252

        public Image getImage(Object obj) {
            String imageKey = ((DesignMenuModel.Item)obj).getImageKey();
            if (imageKey != null) {
                return VDTPluginImages.getImage(imageKey);
            } else {
                imageKey = ISharedImages.IMG_OBJ_ELEMENT;
                if (((DesignMenuModel.Item)obj).hasChildren())
                   imageKey = ISharedImages.IMG_OBJ_FOLDER;
                return PlatformUI.getWorkbench().getSharedImages().getImage(imageKey);
            }    
        }
    } // class ViewLabelProvider

    class NameSorter extends ViewerSorter {
    }

    /**
     * Restores the state of the receiver to the state described in the specified memento.
     *
     * @param memento the memento
     * @since 2.0
     */
    protected void restoreState(IMemento memento) {
1253
        SelectedResourceManager.getDefault().setToolSequence(toolSequence); // to enable access through static method
1254 1255
    	Boolean linkedTools= memento.getBoolean(TAG_LINKED_TOOLS);
    	ToolsCore.restoreToolsState(memento);
1256
        String location = memento.getString(TAG_SELECTED_RESOURCE);
1257 1258
        if (location == null) {
        	System.out.println("No project selected");
1259
            return;
1260
        }
1261
        selectedResource = ResourcesPlugin.getWorkspace().getRoot().findMember(Path.fromPortableString(location));
1262
        String HDLLocation=memento.getString(TAG_SELECTED_HDL_FILE);
1263 1264
        if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_OTHER))
        	System.out.println("restoreState(memento): selectedResource="+selectedResource+ " HDLLocation="+HDLLocation);
1265 1266
        if (HDLLocation!=null) {
        	IResource HDLFile=ResourcesPlugin.getWorkspace().getRoot().findMember(Path.fromPortableString(HDLLocation));
1267 1268 1269 1270 1271
        	if (HDLFile!=null){
        		SelectedResourceManager.getDefault().setChosenVerilogFile(HDLFile);
        		if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_OTHER))
        			System.out.println("Setting HDL file to "+HDLFile.toString());
        	}
1272 1273 1274 1275
        }
        String HDLFilter=memento.getString(TAG_SELECTED_HDL_FILTER); //SelectedResourceManager.getDefault().getFilter();
        if (HDLFilter!=null){
        	SelectedResourceManager.getDefault().setFilter(HDLFilter);
1276 1277
        	if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_OTHER))
        		System.out.println("Setting HDL filter to "+HDLFilter);
1278 1279 1280 1281 1282 1283
        }
    	if (linkedTools==null) linkedTools=true;
    	SelectedResourceManager.getDefault().setToolsLinked(linkedTools);
        toggleLinkedTools.setChecked(!SelectedResourceManager.getDefault().isToolsLinked());
        // Initialize VEditor database build
   	    IResource HDLFile=SelectedResourceManager.getDefault().getChosenVerilogFile();
1284
   	    
1285
   	    if ((HDLFile!=null) && HDLFile.exists()){
1286 1287 1288 1289 1290 1291 1292 1293
  	    	// restore properties from the project, overwrite global ones
	   	    IProject project;
	   	    if (selectedResource == null) {
	   	    	project = SelectedResourceManager.getDefault().getSelectedProject();
	   	    } else {
	   	    	project = HDLFile.getProject();
	   	    }
	   	    restoreCurrentState(project); // null OK
1294 1295 1296
   	    	toolSequence.setUnfinishedBoot(memento,true);
        	if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_OTHER))
        		System.out.println("Initiating DB rebuild HDLFile="+HDLFile);
Andrey Filippov's avatar
Andrey Filippov committed
1297 1298 1299 1300
   	    	VerilogUtils.getTopModuleNames((IFile) HDLFile);
// 	    	java.lang.ClassCastException: org.eclipse.core.internal.resources.Project cannot be cast to org.eclipse.core.resources.IFile
//   	 	at com.elphel.vdt.ui.views.DesignFlowView.restoreState(DesignFlowView.java:1270)
//  	 	at com.elphel.vdt.ui.views.DesignFlowView.createPartControl(DesignFlowView.java:237)   	    	
1301
   	    } else {
1302 1303 1304
        	if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_OTHER))
        		System.out.println("Skipping DB rebuild HDLFile=NULL");
   	    	toolSequence.setUnfinishedBoot(null,false);
1305 1306 1307 1308
   	    	finalizeAfterVEditorDB(memento);
   	    }
    }
    public void finalizeAfterVEditorDB(IMemento memento){
1309 1310 1311 1312 1313 1314 1315 1316 1317
    	if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_OTHER))
    		System.out.println("finalizeAfterVEditorDB(), memento is "+((memento==null)?"NULL":"not NULL"));
    	if (memento!=null) {
    		toolSequence.restoreCurrentStates(memento); // restore states and recalc "dirty" flags - should be after tools themselves
    	}
        if (selectedResource!=null) toolSequence.restoreCurrentStates(selectedResource.getProject()); // restore states and recalc "dirty" flags - should be after tools themselves
        IResource HDLFile=SelectedResourceManager.getDefault().getChosenVerilogFile();
        if ((HDLFile!=null) && HDLFile.exists()){
        	toolSequence.setToolsDirtyFlag(true); // recalculate each successful tool's parameters - does it trigger Database rebuild?
1318 1319 1320
        }
        doLoadDesignMenu();
        updateLaunchAction(true); // true?
1321 1322
    }
    
1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360
    private void restoreCurrentState(IProject project){
    	if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_OTHER))
    		System.out.println("^^^^ restoreCurrentState("+project+")");
    	if ((project==null) || !project.exists()){
    		System.out.println("Can not restore persistent properties from non-existent project "+project);
    		return;
    	}
    	if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_OTHER)){
    		System.out.println("::::: Restoring persistent properties from the project "+project);
    	}

    	ToolsCore.restoreToolsState(project);
    	Map<QualifiedName,String> pp;
    	try {
    		pp=project.getPersistentProperties();
    	} catch (CoreException e){
    		System.out.println(project+": Failed getPersistentProperties(), e="+e);
    		return;
    	}
    	String location=	pp.get(new QualifiedName(VDT.ID_VDT, TAG_SELECTED_RESOURCE));
    	if (location!=null) {
    		IResource resource=ResourcesPlugin.getWorkspace().getRoot().findMember(Path.fromPortableString(location));
        	if (resource.getProject().getFullPath().toPortableString().equals(project.getFullPath().toPortableString())){
        		selectedResource = resource;
        	} else {
        		System.out.println("**** Wrong selected resource "+location+" for project "+project.getFullPath().toPortableString());
        	}
    	}
    	String HDLLocation=	pp.get(new QualifiedName(VDT.ID_VDT, TAG_SELECTED_HDL_FILE));
    	if (HDLLocation!=null) {
            if (HDLLocation!=null) {
            	IResource HDLFile=ResourcesPlugin.getWorkspace().getRoot().findMember(Path.fromPortableString(HDLLocation));
            	if (HDLFile!=null){
            		if (HDLFile.getProject().getFullPath().toPortableString().equals(project.getFullPath().toPortableString())){
            			SelectedResourceManager.getDefault().setChosenVerilogFile(HDLFile);
            			if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_OTHER))
            				System.out.println("Setting HDL file to "+HDLFile.toString());
            		} else {
1361 1362 1363
                		if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_OTHER)) {
                			System.out.println("**** Wrong HDLFile "+HDLLocation+" for project "+project.getFullPath().toPortableString());
                		}
1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382
            		}
            	}
            }
    	}
        String HDLFilter= pp.get(new QualifiedName(VDT.ID_VDT, TAG_SELECTED_HDL_FILTER));
        if (HDLFilter!=null){
        	SelectedResourceManager.getDefault().setFilter(HDLFilter);
        	if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_OTHER))
        		System.out.println("Setting HDL filter to "+HDLFilter);
        }
    	
    	String LinkedToolsStr=pp.get(new QualifiedName(VDT.ID_VDT, TAG_LINKED_TOOLS));
    	if (LinkedToolsStr!=null)	try {
    		SelectedResourceManager.getDefault().setToolsLinked(Boolean.parseBoolean(LinkedToolsStr));
            toggleLinkedTools.setChecked(!SelectedResourceManager.getDefault().isToolsLinked());
    	} catch (Exception e){
    		System.out.println(project+"Failed .setToolsLinked("+LinkedToolsStr+"), e="+e);
    	}
    }
1383 1384 1385 1386
    
    
    
    
1387 1388 1389 1390 1391

    /** 
     * @see ViewPart#saveState
     */
    public void saveState(IMemento memento) {
1392 1393
    	if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_OTHER))
    		System.out.println("^^^^saveState()");
1394 1395 1396
        if (viewer == null) {
            if (this.memento != null) //Keep the old state;
                memento.putMemento(this.memento);
1397
//            return;
1398
        }
1399 1400 1401 1402 1403 1404 1405 1406
        IProject project = selectedResource == null 
                ? null
                : selectedResource.getProject();
        if (project==null) {
        	System.out.println("No project selected, nothing to save");
        	return;
        }

1407 1408 1409
        if (selectedResource != null) {
            String location = selectedResource.getFullPath().toPortableString();
            memento.putString(TAG_SELECTED_RESOURCE, location);
Andrey Filippov's avatar
Andrey Filippov committed
1410 1411
        	if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_OTHER))
        		System.out.println("saveState(memento): selectedResource="+selectedResource);
1412
        }
1413 1414 1415
        IResource HDLFile=SelectedResourceManager.getDefault().getChosenVerilogFile();
        if (HDLFile!=null){
        	memento.putString(TAG_SELECTED_HDL_FILE,HDLFile.getFullPath().toPortableString());
1416 1417
        	if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_OTHER))
        		System.out.println("memento.putString("+TAG_SELECTED_HDL_FILE+","+HDLFile.getFullPath().toPortableString()+")");
1418 1419 1420 1421
        }
        String HDLFilter=SelectedResourceManager.getDefault().getFilter();
        if (HDLFilter!=null){
        	memento.putString(TAG_SELECTED_HDL_FILTER,HDLFilter);
1422 1423
        	if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_OTHER))
        		System.out.println("memento.putString("+TAG_SELECTED_HDL_FILTER+","+HDLFilter+")");
1424
        }
1425 1426
        memento.putBoolean(TAG_LINKED_TOOLS, new Boolean(SelectedResourceManager.getDefault().isToolsLinked()));
        ToolsCore.saveToolsState(memento);
1427 1428 1429 1430 1431 1432 1433
        if (toolSequence!=null) {
        	toolSequence.saveCurrentStates(memento);
        }
// set project properties  
        
        if ((project!=null) && project.exists())
        	saveState(project); 
1434
    }
1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454
// this may need some synchronization as saveState(IMemento memento) is called by the timer (what if selectedResource changes while save is in progress?
    public void saveState(IProject project) {
    	if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_OTHER))
    		System.out.println("^^^^ SaveState("+project+")");
    	if ((project==null) || !project.exists()){
    		System.out.println("Can not save persistent properties to non-existent project "+project);
    		return;
    	}
    	QualifiedName qn;
        if (selectedResource != null) {
        	if (selectedResource.getProject().getFullPath().toPortableString().equals(project.getFullPath().toPortableString())){
        		String location = selectedResource.getFullPath().toPortableString();
        		qn= new QualifiedName(VDT.ID_VDT, TAG_SELECTED_RESOURCE);
        		try {project.setPersistentProperty(qn, location);}
        		catch (CoreException e)  {System.out.println(project+"Failed setPersistentProperty("+qn+", "+location+", e="+e);}
        	} else {
        		System.out.println("*** Wrong selected resource "+selectedResource+" for project "+project);
        		return;
        	}
        }
1455

1456 1457 1458 1459 1460 1461 1462 1463 1464
        IResource HDLFile=SelectedResourceManager.getDefault().getChosenVerilogFile();
        if (HDLFile!=null){
        	if (HDLFile.getProject().getFullPath().toPortableString().equals(project.getFullPath().toPortableString())){
        		qn= new QualifiedName(VDT.ID_VDT, TAG_SELECTED_HDL_FILE);
        		try {project.setPersistentProperty(qn, HDLFile.getFullPath().toPortableString());}
        		catch (CoreException e)  {System.out.println(project+"Failed setPersistentProperty("+qn+", "+HDLFile.getFullPath().toPortableString()+", e="+e);}
        		if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_OTHER))
        			System.out.println("project.setPersistentProperty("+qn.toString()+","+HDLFile.getFullPath().toPortableString()+")");
        	} else {
1465 1466 1467
        		if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_OTHER)) {
        			System.out.println("*** Wrong HDLFile "+HDLFile+" for project "+project);
        		}
1468 1469 1470 1471
        		return;
        	}
        }
        String HDLFilter=SelectedResourceManager.getDefault().getFilter();
1472 1473
        //OK with null - will just arase that property
//        if (HDLFilter!=null){
1474 1475 1476 1477 1478
        	qn= new QualifiedName(VDT.ID_VDT, TAG_SELECTED_HDL_FILTER);
        	try {project.setPersistentProperty(qn, HDLFilter);}
        	catch (CoreException e)  {System.out.println(project+"Failed setPersistentProperty("+qn+", "+HDLFilter+", e="+e);}
        	if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_OTHER))
        		System.out.println("project.setPersistentProperty("+qn.toString()+","+HDLFilter+")");
1479
//        }
1480 1481 1482 1483 1484 1485 1486 1487 1488
        qn= new QualifiedName(VDT.ID_VDT, TAG_LINKED_TOOLS);
        try {project.setPersistentProperty(qn, new Boolean(SelectedResourceManager.getDefault().isToolsLinked()).toString());}
        catch (CoreException e)  {System.out.println(project+"Failed setPersistentProperty("+qn+", "+
        		SelectedResourceManager.getDefault().isToolsLinked()+", e="+e);}
        ToolsCore.saveToolsState(project);
        if (toolSequence!=null) {
        	toolSequence.saveCurrentStates(project);
        }
    }
1489
} // class DesignFlowView