Skip to main content
summaryrefslogtreecommitdiffstats
blob: e294292cbf3673d338153c5c46bd4e50d9cd30d9 (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
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
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
215
216
217
218
/********************************************************************************
 * Copyright (c) 2002, 2006 IBM Corporation. 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
 * 
 * Initial Contributors:
 * The following IBM employees contributed to the Remote System Explorer
 * component that contains this file: David McKnight, Kushal Munir, 
 * Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson, 
 * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
 * 
 * Contributors:
 * {Name} (company) - description of contribution.
 ********************************************************************************/

package org.eclipse.rse.ui.propertypages;
import java.util.ResourceBundle;

import org.eclipse.jface.wizard.WizardPage;
import org.eclipse.rse.core.subsystems.ISubSystem;
import org.eclipse.rse.core.subsystems.ISubSystemConfiguration;
import org.eclipse.rse.services.clientserver.messages.SystemMessage;
import org.eclipse.rse.ui.SystemResources;
import org.eclipse.rse.ui.SystemWidgetHelpers;
import org.eclipse.rse.ui.dialogs.SystemPromptDialog;
import org.eclipse.rse.ui.messages.ISystemMessageLine;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.dialogs.PropertyPage;

/**
 * The form for the property page for core subsystem properties.
 */
public abstract class AbstractSystemSubSystemPropertyPageCoreForm 
       implements ISystemSubSystemPropertyPageCoreForm
{
	
	protected Label labelTypePrompt, labelVendorPrompt, labelNamePrompt, labelConnectionPrompt, labelProfilePrompt;

	protected Label labelType, labelVendor, labelName, labelConnection, labelProfile;

	protected SystemMessage errorMessage;
    protected ResourceBundle rb;	
    protected boolean initDone = false;
 	protected String xlatedNotApplicable = null;
	// Inputs from caller
	protected ISystemMessageLine msgLine;
	protected Object inputElement;
    protected Shell  shell;
    protected Object caller;
	protected boolean callerInstanceOfWizardPage, callerInstanceOfSystemPromptDialog, callerInstanceOfPropertyPage;
		
	/**
	 * Constructor 
	 */
	public AbstractSystemSubSystemPropertyPageCoreForm(ISystemMessageLine msgLine, Object caller)
	{
		super();
		this.msgLine = msgLine;
		this.caller = caller;
		callerInstanceOfWizardPage         = (caller instanceof WizardPage);
		callerInstanceOfSystemPromptDialog = (caller instanceof SystemPromptDialog);		
		callerInstanceOfPropertyPage       = (caller instanceof PropertyPage);
	}
	/**
	 * Get the input element
	 */
	private Object getElement()
	{
		return inputElement;
	}
	/**
	 * Get the shell
	 */
	protected Shell getShell()
	{
		return shell;
	}
	

	
	/**
	 * Create the GUI contents.
	 */
	public Control createContents(Composite parent, Object inputElement, Shell shell)
	{
		this.shell = shell;
		this.inputElement = inputElement;
		String labelText = null;
		// Inner composite
		Composite composite_prompts = SystemWidgetHelpers.createComposite(parent, 2);	

		// Type display
		labelText = SystemWidgetHelpers.appendColon(SystemResources.RESID_SUBSYSTEM_TYPE_LABEL);
		labelTypePrompt = SystemWidgetHelpers.createLabel(composite_prompts, labelText);
		labelType = SystemWidgetHelpers.createLabel(composite_prompts, SystemResources.RESID_SUBSYSTEM_TYPE_VALUE);

		// Vendor display
		labelText = SystemWidgetHelpers.appendColon(SystemResources.RESID_SUBSYSTEM_VENDOR_LABEL);
		labelVendorPrompt = SystemWidgetHelpers.createLabel(composite_prompts, labelText);
		labelVendor = SystemWidgetHelpers.createLabel(composite_prompts, " "); //$NON-NLS-1$

		// Name display
		labelText = SystemWidgetHelpers.appendColon(SystemResources.RESID_SUBSYSTEM_NAME_LABEL);
		labelNamePrompt = SystemWidgetHelpers.createLabel(composite_prompts, labelText);
		labelName = SystemWidgetHelpers.createLabel(composite_prompts, " "); //$NON-NLS-1$

		// Connection display
		labelText = SystemWidgetHelpers.appendColon(SystemResources.RESID_SUBSYSTEM_CONNECTION_LABEL);
		labelConnectionPrompt = SystemWidgetHelpers.createLabel(composite_prompts, labelText);
		labelConnection = SystemWidgetHelpers.createLabel(composite_prompts, " "); //$NON-NLS-1$

		// Profile display
		labelText = SystemWidgetHelpers.appendColon(SystemResources.RESID_SUBSYSTEM_PROFILE_LABEL);
		labelProfilePrompt = SystemWidgetHelpers.createLabel(composite_prompts, labelText);
		labelProfile = SystemWidgetHelpers.createLabel(composite_prompts, " "); //$NON-NLS-1$

		createInner(composite_prompts, inputElement, shell);
	
		return composite_prompts;
	}

	/**
	 * Return control to recieve initial focus
	 */
	public Control getInitialFocusControl()
	{
		  return null;
	}
	/**
	 * Get the input subsystem object
	 */
	protected ISubSystem getSubSystem()
	{
		Object element = getElement();
		if (element instanceof ISubSystem)
		  return (ISubSystem)element;
		else  
		  return null;
	}


	/**
	 * Initialize values of input fields based on input
	 */
	protected void doInitializeFields()
	{
		initDone = true;
	    ISubSystem ss = getSubSystem();
	    ISubSystemConfiguration ssFactory = ss.getSubSystemConfiguration();

	    //getPortValidator();
	    // vendor    
	    labelVendor.setText(ssFactory.getVendor());	    
	    // name    
	    labelName.setText(ss.getName());
	    // connection
	    labelConnection.setText(ss.getHostAliasName());
	    // profile
	    labelProfile.setText(ss.getSystemProfileName());
	 
	    doInitializeInnerFields();
	}
	





	/**
	 * This method can be called by the dialog or wizard page host, to decide whether to enable
	 * or disable the next, final or ok buttons. It returns true if the minimal information is
	 * available and is correct.
	 */
	public boolean isPageComplete()
	{
		boolean pageComplete = false;
		return pageComplete;
	}
	/**
	 * Inform caller of page-complete status of this form
	 */
	public void setPageComplete()
	{
		boolean complete = isPageComplete();
		if (callerInstanceOfWizardPage)
		{			
		  ((WizardPage)caller).setPageComplete(complete);
		}
		else if (callerInstanceOfSystemPromptDialog)
		{
		  ((SystemPromptDialog)caller).setPageComplete(complete);
		}		
		else if (callerInstanceOfPropertyPage)
		{
		  ((PropertyPage)caller).setValid(complete);
		}		
	}

 

    
 

	/*
	 * Create the inner portion of the contents.  These include any additional fields for the subsystem
	 */
	protected abstract Control createInner(Composite parent, Object inputElement, Shell shell);
	
	/*
	 * Initialize the inner portion of the contents.  These include any additional fields for the subsystem
	 */
	protected abstract void doInitializeInnerFields();

}

Back to the top