Skip to main content
summaryrefslogtreecommitdiffstats
blob: d655c3d87e49261dd260716edea7bb5804edfaa6 (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
132
133
134
135
136
137
138
139
140
141
/*******************************************************************************
 * 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
 *******************************************************************************/
/*
 * Created on Mar 8, 2004
 *
 * To change the template for this generated file go to
 * Window - Preferences - Java - Code Generation - Code and Comments
 */
package org.eclipse.jst.j2ee.internal.wizard;

import org.eclipse.jst.j2ee.internal.plugin.J2EEUIMessages;
import org.eclipse.jst.j2ee.project.datamodel.properties.IJ2EEProjectServerTargetDataModelProperties;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Label;
import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
import org.eclipse.wst.common.frameworks.internal.datamodel.ui.DataModelSynchHelper;


/**
 * @author vijayb
 * 
 * To change the template for this generated type comment go to Window - Preferences - Java - Code
 * Generation - Code and Comments
 */
public class ServerTargetGroup implements IJ2EEProjectServerTargetDataModelProperties{
	private IDataModel model;
	private DataModelSynchHelper synchHelper;
	private Combo targetServerCombo;
	private Button newTargetServerButton;
	public Composite parentUI;

	/**
	 *  
	 */
	public ServerTargetGroup() {
		super();
		// TODO Auto-generated constructor stub
	}

	/**
	 * @param parent
	 * @param style
	 */
	public ServerTargetGroup(Composite parent, int style, IDataModel model, DataModelSynchHelper helper) {
		this.model = model;
		this.parentUI = parent;
		synchHelper = helper;
		buildComposites(parent);
	}

	/**
	 * Create the controls within this composite
	 */
	public void buildComposites(Composite parent) {
		createServerTargetGroup(parent);
	}

	/**
	 * @param parent
	 */
	private void createServerTargetGroup(Composite parent) {
		Label serverTargetLabel = new Label(parent, SWT.NONE);
		serverTargetLabel.setText(J2EEUIMessages.getResourceString(J2EEUIMessages.TARGET_RUNTIME_LBL));
		GridData data = new GridData();
		serverTargetLabel.setLayoutData(data);


		targetServerCombo = new Combo(parent, SWT.BORDER | SWT.READ_ONLY);
		targetServerCombo.setLayoutData((new GridData(GridData.FILL_HORIZONTAL)));

		newTargetServerButton = new Button(parent, SWT.NONE);
		newTargetServerButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
		newTargetServerButton.setText(J2EEUIMessages.getResourceString(J2EEUIMessages.NEW_THREE_DOTS_E));
		newTargetServerButton.addSelectionListener(new SelectionAdapter() {
			public void widgetSelected(SelectionEvent e) {
				handleNewTargetServerButtonPressed();
			}
		});
		newTargetServerButton.setEnabled(true);

		Control[] deps = new Control[]{serverTargetLabel, newTargetServerButton};
		synchHelper.synchCombo(targetServerCombo, RUNTIME_TARGET_ID, deps);
	}

	/**
	 *  
	 */
	protected void handleNewTargetServerButtonPressed() {
		FlexibleProjectCreationWizardPage.launchNewRuntimeWizard(parentUI.getShell(), model);
	}

	public void dispose() {
		model.removeListener(synchHelper);
		model = null;
	}

	/**
	 * @return Returns the targetServerCombo.
	 */
	public Combo getTargetServerCombo() {
		return targetServerCombo;
	}

	/**
	 * @param targetServerCombo
	 *            The targetServerCombo to set.
	 */
	public void setTargetServerCombo(Combo targetServerCombo) {
		this.targetServerCombo = targetServerCombo;
	}

	/**
	 * @return Returns the newTargetServerButton.
	 */
	public Button getNewTargetServerButton() {
		return newTargetServerButton;
	}

	/**
	 * @param newTargetServerButton
	 *            The newTargetServerButton to set.
	 */
	public void setNewTargetServerButton(Button newTargetServerButton) {
		this.newTargetServerButton = newTargetServerButton;
	}
}

Back to the top