Skip to main content
summaryrefslogtreecommitdiffstats
blob: 4fefc5f5541d402c8265aa561223eac6d46641e7 (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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
/*******************************************************************************
 * Copyright (c) 2003, 2005 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.j2ee.internal.wizard;


import org.eclipse.jst.j2ee.project.facet.IJ2EEModuleFacetInstallDataModelProperties;
import org.eclipse.jst.j2ee.ui.project.facet.EarSelectionPanel;
import org.eclipse.osgi.util.NLS;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
import org.eclipse.wst.common.frameworks.datamodel.DataModelEvent;
import org.eclipse.wst.common.frameworks.datamodel.IDataModelListener;
import org.eclipse.wst.web.ui.internal.wizards.DataModelFacetInstallPage;

public abstract class J2EEModuleFacetInstallPage extends DataModelFacetInstallPage implements IJ2EEModuleFacetInstallDataModelProperties {

    private IDataModelListener facetVersionListener = null;
    protected Button addDD;
    
	public J2EEModuleFacetInstallPage(String pageName) {
		super(pageName);
	}

	/**
	 * @deprecated This member should not be used any more. The EAR Panel is moved to the first wizard page. 
	 */
	protected EarSelectionPanel earPanel;

	public void dispose() {
		if (null != earPanel) {
			earPanel.dispose();
		}
		this.model.removeListener( this.facetVersionListener );
		super.dispose();
	}

	/**
	 * @deprecated This method should not be called any more. The EAR Panel is moved to the first wizard page. 
	 */
	protected void setupEarControl(final Composite parent) {
		Composite c = new Composite(parent, SWT.NONE);
		c.setLayoutData(gdhfill());
		final GridLayout layout = new GridLayout(3, false);
		layout.marginWidth = 0;
		layout.marginHeight = 0;
		c.setLayout(layout);
		this.earPanel = new EarSelectionPanel(model, c);
	}
	
	protected void createGenerateDescriptorControl(Composite parent) {
		createGenerateDescriptorControl(parent, null);
	}
	
	protected void createGenerateDescriptorControl(Composite parent, String ddFileName)	{
        this.addDD = new Button(parent, SWT.CHECK);
        if (ddFileName == null) {
        	this.addDD.setText(Resources.generateDeploymentDescriptor);
        } else {
        	this.addDD.setText(NLS.bind(Resources.generateDeploymentDescriptorWithFileName, ddFileName));
        }
        //synchHelper.synchCheckbox(addDD, GENERATE_DD, null); bug 215284 - see enter()
        GridData gd = new GridData(GridData.FILL_HORIZONTAL);
        gd.horizontalSpan = 2;
        this.addDD.setLayoutData(gd);
	}
	
	protected void registerFacetVersionChangeListener()
	{
        this.facetVersionListener = new IDataModelListener()
        {
            public void propertyChanged( final DataModelEvent event )
            {
                if( event.getFlag() == DataModelEvent.VALUE_CHG &&
                    event.getPropertyName().equals( FACET_VERSION ) )
                {
                    final Runnable runnable = new Runnable()
                    {
                        public void run()
                        {
                            handleFacetVersionChangedEvent();
                        }
                    };
                    if(Thread.currentThread() == Display.getDefault().getThread()){
                    	runnable.run();
                    } else {
                    	Display.getDefault().asyncExec( runnable );
                    }
                }
            }
        };
        
        this.model.addListener( facetVersionListener );
        handleFacetVersionChangedEvent();
	}
	
    protected void handleFacetVersionChangedEvent()
    {
        // The default implementation doesn't do anything. The subclass should override
        // to handle this event.
    }

    private static final class Resources extends NLS {
        public static String generateDeploymentDescriptor;
        public static String generateDeploymentDescriptorWithFileName;

        static {
            initializeMessages(J2EEModuleFacetInstallPage.class.getName(), Resources.class);
        }
    }

    protected void enter() {
    	if (isFirstTimeToPage() && addDD != null)
    	{
    		synchHelper.synchCheckbox(addDD, GENERATE_DD, null);
    	}
    	super.enter();
    }

}

Back to the top