01: /*******************************************************************************
02: * Copyright (c) 2000, 2006 IBM Corporation and others.
03: * All rights reserved. This program and the accompanying materials
04: * are made available under the terms of the Eclipse Public License v1.0
05: * which accompanies this distribution, and is available at
06: * http://www.eclipse.org/legal/epl-v10.html
07: *
08: * Contributors:
09: * IBM Corporation - initial API and implementation
10: *******************************************************************************/package org.eclipse.pde.internal.ui.editor.build;
11:
12: import org.eclipse.core.resources.IFolder;
13: import org.eclipse.core.resources.IResource;
14: import org.eclipse.pde.core.IModelChangedListener;
15: import org.eclipse.pde.core.build.IBuild;
16: import org.eclipse.pde.core.build.IBuildEntry;
17: import org.eclipse.pde.internal.build.IBuildPropertiesConstants;
18: import org.eclipse.pde.internal.ui.PDEUIMessages;
19: import org.eclipse.swt.widgets.Composite;
20:
21: public class SrcSection extends BuildContentsSection implements
22: IModelChangedListener {
23:
24: public SrcSection(BuildPage page, Composite parent) {
25: super (page, parent);
26: getSection()
27: .setText(PDEUIMessages.BuildEditor_SrcSection_title);
28: getSection().setDescription(
29: PDEUIMessages.BuildEditor_SrcSection_desc);
30:
31: }
32:
33: protected void initializeCheckState() {
34:
35: super .initializeCheckState();
36: IBuild build = fBuildModel.getBuild();
37: IBuildEntry srcIncl = build
38: .getEntry(IBuildPropertiesConstants.PROPERTY_SRC_INCLUDES);
39: IBuildEntry srcExcl = build
40: .getEntry(IBuildPropertiesConstants.PROPERTY_SRC_EXCLUDES);
41:
42: if (srcIncl == null)
43: return;
44:
45: super .initializeCheckState(srcIncl, srcExcl);
46: }
47:
48: protected void deleteFolderChildrenFromEntries(IFolder folder) {
49: IBuild build = fBuildModel.getBuild();
50: IBuildEntry srcIncl = build
51: .getEntry(IBuildPropertiesConstants.PROPERTY_SRC_INCLUDES);
52: IBuildEntry srcExcl = build
53: .getEntry(IBuildPropertiesConstants.PROPERTY_SRC_EXCLUDES);
54: String parentFolder = getResourceFolderName(folder
55: .getProjectRelativePath().toString());
56:
57: removeChildren(srcIncl, parentFolder);
58: removeChildren(srcExcl, parentFolder);
59: }
60:
61: protected void handleBuildCheckStateChange(
62: boolean wasTopParentChecked) {
63: IResource resource = fParentResource;
64: String resourceName = fParentResource.getFullPath()
65: .removeFirstSegments(1).toString();
66: IBuild build = fBuildModel.getBuild();
67: IBuildEntry includes = build
68: .getEntry(IBuildPropertiesConstants.PROPERTY_SRC_INCLUDES);
69: IBuildEntry excludes = build
70: .getEntry(IBuildPropertiesConstants.PROPERTY_SRC_EXCLUDES);
71:
72: resourceName = handleResourceFolder(resource, resourceName);
73:
74: if (isChecked)
75: handleCheck(includes, excludes, resourceName, resource,
76: wasTopParentChecked,
77: IBuildPropertiesConstants.PROPERTY_SRC_INCLUDES);
78: else
79: handleUncheck(includes, excludes, resourceName, resource,
80: IBuildPropertiesConstants.PROPERTY_SRC_EXCLUDES);
81:
82: deleteEmptyEntries();
83: }
84: }
|