Skip to main content
summaryrefslogtreecommitdiffstats
blob: 1e8647fd24b1c0f59676cf8d8e9f50b1f7d754d8 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
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
/*******************************************************************************
 * Copyright (c) 2000, 2004 IBM Corporation and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 * 
 * Contributors:
 *     IBM Corporation - initial API and implementation
 *******************************************************************************/


package org.eclipse.jst.ws.internal.consumption.datamodel.validate;

import java.util.HashSet;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IWorkspace;
import org.eclipse.core.resources.IWorkspaceDescription;
import org.eclipse.core.resources.ResourcesPlugin;

/**
  * This class manages the validation state of projects that some tasks may want
  * to disable.  The manager can then be used to restore the validation state.
**/
public class ValidationManager
{

  // Copyright
  public static final String copyright = "(c) Copyright IBM Corporation 2000, 2002.";

  /**
    * This set contains a set of IProjects that need to be validated.
  **/
  private HashSet projects = null;              

  /**
    * This object contains a reference to the j2ee validator.
  **/
  //pgm private ValidatorManager j2eeManager = null;

  /**
    * This boolean contains the auto build setting under preferrence
  **/
  private boolean isAutoBuild_;
  private boolean autoBuildDisabled_;
                                             
  public ValidationManager()
  {
    projects    = new HashSet();
    //pgm j2eeManager = ValidatorManager.getManager();
    setAutoBuildPreference();
    autoBuildDisabled_ = false;
  }
  
  /**
    * Disables the validation for a project if required.
  **/
  public void disableValidationForProject( IProject project )
  {    
    // We need to remember that this project needs have validation turned back on.
    projects.add( project );
    
    //pgm j2eeManager.suspendAllValidation( true );
  }

  /**
    * Restores the validation state for all needed projects.
  **/
  public void restoreValidationForProjects( boolean runValidation )
  {
  }

  public void modifyAutoBuild(boolean isAutoBuild) {
    try {
      IWorkspace workspace = ResourcesPlugin.getWorkspace();
      IWorkspaceDescription workspaceDesc = workspace.getDescription();
      workspaceDesc.setAutoBuilding(isAutoBuild);
      workspace.setDescription(workspaceDesc);
    }
    catch (Exception e) {}
  }

  public void disableAutoBuild() {
    if (!autoBuildDisabled_) {
      setAutoBuildPreference();
      modifyAutoBuild(false);
      autoBuildDisabled_ = true;
    }
  }

  public void restoreAutoBuild() {
    if (autoBuildDisabled_) {
      modifyAutoBuild(getAutoBuildPreference());
      autoBuildDisabled_ = false;
    }
  }

  public boolean setAutoBuildPreference() {
    isAutoBuild_ = getWorkspaceAutoBuildPreference();
    return isAutoBuild_;
  }

  public boolean getAutoBuildPreference() {
    return isAutoBuild_;
  }

  public boolean getWorkspaceAutoBuildPreference() {
    IWorkspaceDescription workspaceDesc = ResourcesPlugin.getWorkspace().getDescription();
    return workspaceDesc.isAutoBuilding();
  }

}

Back to the top