compositeGD.verticalSpan = rows;
compositeGD.widthHint = 100;
mapcalcComposite.setLayoutData(compositeGD);
mapcalcComposite.setLayout(new GridLayout(2, false));
final StyledText text = new StyledText(mapcalcComposite, SWT.MULTI | SWT.WRAP | SWT.LEAD | SWT.BORDER | SWT.V_SCROLL);
GridData textGD = new GridData(SWT.FILL, SWT.FILL, true, true);
textGD.verticalSpan = rows;
textGD.heightHint = 100;
text.setLayoutData(textGD);
text.addModifyListener(new ModifyListener(){
public void modifyText( ModifyEvent e ) {
MapcalculatorUtils.checkStyle(text);
}
});
Composite buttonsComposite = new Composite(mapcalcComposite, SWT.NONE);
buttonsComposite.setLayoutData(new GridData(SWT.END, SWT.FILL, false, true));
GridLayout buttonsCompositeLayout = new GridLayout(1, true);
buttonsCompositeLayout.marginWidth = 0;
buttonsComposite.setLayout(buttonsCompositeLayout);
String[] mapcalcHistoryItems = new String[0];
String mapcalcHistory = OmsBoxPlugin.getDefault().getMapcalcHistory();
if (mapcalcHistory != null && mapcalcHistory.length() > 0) {
mapcalcHistoryItems = mapcalcHistory.split(OmsBoxConstants.MAPCALCHISTORY_SEPARATOR);
}
HashMap<String, String> items2ValuesMap = new HashMap<String, String>();
for( String item : mapcalcHistoryItems ) {
String descr = item.replaceAll("\n", " ");
items2ValuesMap.put(descr, item);
}
mapcalcHistoryItems = items2ValuesMap.keySet().toArray(new String[0]);
final Combo historyCombo = new Combo(mapcalcComposite, SWT.DROP_DOWN | SWT.READ_ONLY);
GridData historyComboGD = new GridData(SWT.FILL, SWT.CENTER, true, false);
historyComboGD.horizontalSpan = 2;
historyCombo.setLayoutData(historyComboGD);
historyCombo.setItems(mapcalcHistoryItems);
historyCombo.setData(items2ValuesMap);
historyCombo.select(0);
historyCombo.addSelectionListener(new SelectionAdapter(){
public void widgetSelected( SelectionEvent e ) {
int selectionIndex = historyCombo.getSelectionIndex();
String item = historyCombo.getItem(selectionIndex);
@SuppressWarnings("unchecked")
HashMap<String, String> descriptionsMap = (HashMap<String, String>) historyCombo.getData();
String value = descriptionsMap.get(item);
text.setText(value);
}
});
createMapcalcConstructsButtons(buttonsComposite, text);
MapcalculatorUtils.checkStyle(text);