Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: b34248cd22b0416140b6430382dc590d0ad01d86 (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
/*******************************************************************************
 * Copyright (c) 2012, 2016 Wind River Systems, Inc. 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:
 * Wind River Systems - initial API and implementation
 *******************************************************************************/
package org.eclipse.tcf.te.tcf.launch.ui.remote.app;

import org.eclipse.core.runtime.Assert;
import org.eclipse.debug.core.ILaunchConfiguration;
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
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.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Group;
import org.eclipse.swt.widgets.Label;
import org.eclipse.tcf.te.launch.core.persistence.DefaultPersistenceDelegate;
import org.eclipse.tcf.te.launch.ui.interfaces.ILaunchConfigurationTabFormPart;
import org.eclipse.tcf.te.tcf.launch.ui.nls.Messages;
import org.eclipse.tcf.te.ui.forms.parts.AbstractSection;
import org.eclipse.tcf.te.ui.swt.SWTControlUtil;
import org.eclipse.tm.terminal.view.core.interfaces.constants.ILineSeparatorConstants;
import org.eclipse.tm.terminal.view.core.interfaces.constants.ITerminalsConnectorConstants;
import org.eclipse.ui.forms.IManagedForm;
import org.eclipse.ui.forms.widgets.ExpandableComposite;
import org.eclipse.ui.forms.widgets.FormToolkit;
import org.eclipse.ui.forms.widgets.Section;

/**
 * Remote application advanced properties section implementation.
 */
public class LaunchConfigurationAdvancedTabSection extends AbstractSection implements ILaunchConfigurationTabFormPart {
	/* default */ Button lineSeparatorDefault;
	/* default */ Button lineSeparatorLF;
	/* default */ Button lineSeparatorCRLF;
	/* default */ Button lineSeparatorCR;

	/**
	 * Constructor.
	 *
	 * @param form The parent managed form. Must not be <code>null</code>.
	 * @param parent The parent composite. Must not be <code>null</code>.
	 */
	public LaunchConfigurationAdvancedTabSection(IManagedForm form, Composite parent) {
		super(form, parent, ExpandableComposite.TWISTIE);
		getSection().setBackground(parent.getBackground());
		createClient(getSection(), form.getToolkit());
	}

	/* (non-Javadoc)
	 * @see org.eclipse.tcf.te.ui.forms.parts.AbstractSection#createClient(org.eclipse.ui.forms.widgets.Section, org.eclipse.ui.forms.widgets.FormToolkit)
	 */
	@Override
	protected void createClient(final Section section, FormToolkit toolkit) {
		Assert.isNotNull(section);
		Assert.isNotNull(toolkit);

		// Configure the section
		section.setText(Messages.LaunchConfigurationAdvancedTabSection_title);
		if (section.getParent().getLayout() instanceof GridLayout) {
			section.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_FILL, SWT.CENTER, true, false));
		}

		// Create the section client
		Composite client = createClientContainer(section, 1, toolkit);
		Assert.isNotNull(client);
		GridLayout layout = new GridLayout();
		layout.marginLeft = 0; layout.marginHeight = 0;
		client.setLayout(layout);
		section.setClient(client);
		client.setBackground(section.getBackground());

		Group group = new Group(client, SWT.NONE);
		group.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
		group.setText(Messages.LaunchConfigurationAdvancedTabSection_group_label);
		group.setLayout(new GridLayout());

		Label label = new Label(group, SWT.NONE);
		label.setText(Messages.LaunchConfigurationAdvancedTabSection_lineseparator_label);
		label.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));

		Composite panel2 = new Composite(group, SWT.NONE);
		layout = new GridLayout(4, false);
		layout.marginLeft = 15; layout.marginHeight = 2;
		panel2.setLayout(layout);
		panel2.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));

		lineSeparatorDefault = toolkit.createButton(panel2, Messages.LaunchConfigurationAdvancedTabSection_lineseparator_default, SWT.RADIO);
		lineSeparatorDefault.addSelectionListener(new SelectionAdapter() {
			@Override
			public void widgetSelected(SelectionEvent e) {
				if (lineSeparatorDefault.getSelection()) {
					SWTControlUtil.setSelection(lineSeparatorLF, false);
					SWTControlUtil.setSelection(lineSeparatorCRLF, false);
					SWTControlUtil.setSelection(lineSeparatorCR, false);
				}
			}
		});

		lineSeparatorLF = toolkit.createButton(panel2, Messages.LaunchConfigurationAdvancedTabSection_lineseparator_lf, SWT.RADIO);
		lineSeparatorLF.addSelectionListener(new SelectionAdapter() {
			@Override
			public void widgetSelected(SelectionEvent e) {
				if (lineSeparatorDefault.getSelection()) {
					SWTControlUtil.setSelection(lineSeparatorDefault, false);
					SWTControlUtil.setSelection(lineSeparatorCRLF, false);
					SWTControlUtil.setSelection(lineSeparatorCR, false);
				}
			}
		});

		lineSeparatorCRLF = toolkit.createButton(panel2, Messages.LaunchConfigurationAdvancedTabSection_lineseparator_crlf, SWT.RADIO);
		lineSeparatorCRLF.addSelectionListener(new SelectionAdapter() {
			@Override
			public void widgetSelected(SelectionEvent e) {
				if (lineSeparatorDefault.getSelection()) {
					SWTControlUtil.setSelection(lineSeparatorDefault, false);
					SWTControlUtil.setSelection(lineSeparatorLF, false);
					SWTControlUtil.setSelection(lineSeparatorCR, false);
				}
			}
		});

		lineSeparatorCR = toolkit.createButton(panel2, Messages.LaunchConfigurationAdvancedTabSection_lineseparator_cr, SWT.RADIO);
		lineSeparatorCR.addSelectionListener(new SelectionAdapter() {
			@Override
			public void widgetSelected(SelectionEvent e) {
				if (lineSeparatorDefault.getSelection()) {
					SWTControlUtil.setSelection(lineSeparatorDefault, false);
					SWTControlUtil.setSelection(lineSeparatorLF, false);
					SWTControlUtil.setSelection(lineSeparatorCRLF, false);
				}
			}
		});
	}

	/* (non-Javadoc)
	 * @see org.eclipse.tcf.te.launch.ui.interfaces.ILaunchConfigurationTabFormPart#initializeFrom(org.eclipse.debug.core.ILaunchConfiguration)
	 */
    @Override
    public void initializeFrom(ILaunchConfiguration configuration) {
    	Assert.isNotNull(configuration);

		String lineSeparator = DefaultPersistenceDelegate.getAttribute(configuration, ITerminalsConnectorConstants.PROP_LINE_SEPARATOR, (String)null);
		if (lineSeparator == null) {
			SWTControlUtil.setSelection(lineSeparatorDefault, true);
		}
		else if (ILineSeparatorConstants.LINE_SEPARATOR_LF.equals(lineSeparator)) {
			SWTControlUtil.setSelection(lineSeparatorLF, true);
		}
		else if (ILineSeparatorConstants.LINE_SEPARATOR_CRLF.equals(lineSeparator)) {
			SWTControlUtil.setSelection(lineSeparatorCRLF, true);
		}
		else if (ILineSeparatorConstants.LINE_SEPARATOR_CR.equals(lineSeparator)) {
			SWTControlUtil.setSelection(lineSeparatorCR, true);
		}
    }

	/* (non-Javadoc)
	 * @see org.eclipse.tcf.te.launch.ui.interfaces.ILaunchConfigurationTabFormPart#performApply(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy)
	 */
    @Override
    public void performApply(ILaunchConfigurationWorkingCopy configuration) {
    	Assert.isNotNull(configuration);

		String lineSeparator = null;
		if (SWTControlUtil.getSelection(lineSeparatorLF)) {
			lineSeparator = ILineSeparatorConstants.LINE_SEPARATOR_LF;
		}
		else if (SWTControlUtil.getSelection(lineSeparatorCRLF)) {
			lineSeparator = ILineSeparatorConstants.LINE_SEPARATOR_CRLF;
		}
		else if (SWTControlUtil.getSelection(lineSeparatorCR)) {
			lineSeparator = ILineSeparatorConstants.LINE_SEPARATOR_CR;
		}
		DefaultPersistenceDelegate.setAttribute(configuration, ITerminalsConnectorConstants.PROP_LINE_SEPARATOR, lineSeparator);
    }

	/* (non-Javadoc)
	 * @see org.eclipse.tcf.te.launch.ui.interfaces.ILaunchConfigurationTabFormPart#isValid(org.eclipse.debug.core.ILaunchConfiguration)
	 */
    @Override
    public boolean isValid(ILaunchConfiguration configuration) {
	    return true;
    }
}

Back to the top