|
Lines 8-13
Link Here
|
| 8 |
* Contributors: |
8 |
* Contributors: |
| 9 |
* Michael Scharf (Wind River) - initial implementation |
9 |
* Michael Scharf (Wind River) - initial implementation |
| 10 |
* Michael Scharf (Wing River) - [211659] Add field assist to terminal input field |
10 |
* Michael Scharf (Wing River) - [211659] Add field assist to terminal input field |
|
|
11 |
* Michael Scharf (Wing River) - [196447] The optional terminal input line should be resizeable |
| 11 |
*******************************************************************************/ |
12 |
*******************************************************************************/ |
| 12 |
package org.eclipse.tm.internal.terminal.control; |
13 |
package org.eclipse.tm.internal.terminal.control; |
| 13 |
import java.util.ArrayList; |
14 |
import java.util.ArrayList; |
|
Lines 24-31
Link Here
|
| 24 |
import org.eclipse.swt.events.KeyEvent; |
25 |
import org.eclipse.swt.events.KeyEvent; |
| 25 |
import org.eclipse.swt.events.KeyListener; |
26 |
import org.eclipse.swt.events.KeyListener; |
| 26 |
import org.eclipse.swt.graphics.Font; |
27 |
import org.eclipse.swt.graphics.Font; |
|
|
28 |
import org.eclipse.swt.graphics.Rectangle; |
| 27 |
import org.eclipse.swt.layout.GridData; |
29 |
import org.eclipse.swt.layout.GridData; |
| 28 |
import org.eclipse.swt.widgets.Composite; |
30 |
import org.eclipse.swt.widgets.Composite; |
|
|
31 |
import org.eclipse.swt.widgets.Event; |
| 32 |
import org.eclipse.swt.widgets.Listener; |
| 33 |
import org.eclipse.swt.widgets.Sash; |
| 29 |
import org.eclipse.swt.widgets.Text; |
34 |
import org.eclipse.swt.widgets.Text; |
| 30 |
import org.eclipse.ui.fieldassist.ContentAssistCommandAdapter; |
35 |
import org.eclipse.ui.fieldassist.ContentAssistCommandAdapter; |
| 31 |
|
36 |
|
|
Lines 108-113
Link Here
|
| 108 |
* The input text field. |
113 |
* The input text field. |
| 109 |
*/ |
114 |
*/ |
| 110 |
private Text fInputField; |
115 |
private Text fInputField; |
|
|
116 |
private Sash fSash; |
| 111 |
public CommandInputFieldWithHistory(int maxHistorySize) { |
117 |
public CommandInputFieldWithHistory(int maxHistorySize) { |
| 112 |
fMaxSize=maxHistorySize; |
118 |
fMaxSize=maxHistorySize; |
| 113 |
} |
119 |
} |
|
Lines 200-207
Link Here
|
| 200 |
fEditedHistory=null; |
206 |
fEditedHistory=null; |
| 201 |
fEditHistoryPos=0; |
207 |
fEditHistoryPos=0; |
| 202 |
} |
208 |
} |
| 203 |
public void createControl(Composite parent,final ITerminalViewControl terminal) { |
209 |
public void createControl(final Composite parent,final ITerminalViewControl terminal) { |
| 204 |
fInputField=new Text(parent, SWT.SINGLE|SWT.BORDER); |
210 |
// fSash = new Sash(parent,SWT.HORIZONTAL|SWT.SMOOTH); |
|
|
211 |
fSash = new Sash(parent,SWT.HORIZONTAL); |
| 212 |
final GridData gd_sash = new GridData(SWT.FILL, SWT.CENTER, true, false); |
| 213 |
gd_sash.heightHint=5; |
| 214 |
fSash.setLayoutData(gd_sash); |
| 215 |
fSash.addListener (SWT.Selection, new Listener () { |
| 216 |
public void handleEvent (Event e) { |
| 217 |
// no idea why this is needed |
| 218 |
GridData gdata = (GridData) fInputField.getLayoutData(); |
| 219 |
Rectangle sashRect = fSash.getBounds (); |
| 220 |
Rectangle containerRect = parent.getClientArea (); |
| 221 |
|
| 222 |
int h=fInputField.getLineHeight(); |
| 223 |
// make sure the input filed hight is a multiple of the line height |
| 224 |
gdata.heightHint = Math.max(((containerRect.height-e.y-sashRect.height)/h)*h,h); |
| 225 |
// do not show less then one line |
| 226 |
e.y=Math.min(e.y,containerRect.height-h); |
| 227 |
fInputField.setLayoutData(gdata); |
| 228 |
parent.layout(); |
| 229 |
// else the content assist icon will be replicated |
| 230 |
parent.redraw(); |
| 231 |
} |
| 232 |
}); |
| 233 |
fInputField=new Text(parent, SWT.MULTI|SWT.BORDER|SWT.WRAP|SWT.V_SCROLL); |
| 205 |
GridData data=new GridData(SWT.FILL, SWT.FILL, true, false); |
234 |
GridData data=new GridData(SWT.FILL, SWT.FILL, true, false); |
| 206 |
boolean installDecoration=true; |
235 |
boolean installDecoration=true; |
| 207 |
if(installDecoration) { |
236 |
if(installDecoration) { |
|
Lines 262-267
Link Here
|
| 262 |
fInputField.getParent().layout(true); |
291 |
fInputField.getParent().layout(true); |
| 263 |
} |
292 |
} |
| 264 |
public void dispose() { |
293 |
public void dispose() { |
|
|
294 |
fSash.dispose(); |
| 295 |
fSash=null; |
| 265 |
fInputField.dispose(); |
296 |
fInputField.dispose(); |
| 266 |
fInputField=null; |
297 |
fInputField=null; |