in PluginsAndFeatures/azure-toolkit-for-eclipse/com.microsoft.azuretools.azureexplorer/src/com/microsoft/azuretools/azureexplorer/editors/rediscache/RedisExplorerEditor.java [126:314]
public void createPartControl(Composite parent) {
ScrolledComposite scrolledComposite = new ScrolledComposite(parent, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL);
scrolledComposite.setExpandHorizontal(true);
scrolledComposite.setExpandVertical(true);
Composite cmpoMain = new Composite(scrolledComposite, SWT.NONE);
GridLayout gridLayout = new GridLayout(2, false);
cmpoMain.setLayout(gridLayout);
Label lblChooseDb = new Label(cmpoMain, SWT.NONE);
lblChooseDb.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
lblChooseDb.setText("Database :");
cbDatabase = new Combo(cmpoMain, SWT.READ_ONLY);
cbDatabase.setEnabled(false);
GridData cbDataBaseLayout = new GridData(SWT.LEFT, SWT.CENTER, true, false, 1, 1);
cbDataBaseLayout.minimumWidth = 50;
cbDatabase.setLayoutData(cbDataBaseLayout);
SashForm sashForm = new SashForm(cmpoMain, SWT.HORIZONTAL);
sashForm.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, true, 2, 1));
Composite cmpoKeyArea = new Composite(sashForm, SWT.BORDER);
cmpoKeyArea.setLayout(new GridLayout(3, false));
cbActionType = new Combo(cmpoKeyArea, SWT.READ_ONLY);
cbActionType.setEnabled(false);
cbActionType.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
cbActionType.add(ACTION_SCAN);
cbActionType.add(ACTION_GET);
cbActionType.select(0);
txtKeyPattern = new Text(cmpoKeyArea, SWT.BORDER);
txtKeyPattern.setEditable(false);
txtKeyPattern.setText(DEFAULT_SCAN_PATTERN);
txtKeyPattern.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
btnSearch = new Button(cmpoKeyArea, SWT.NONE);
btnSearch.setEnabled(false);
btnSearch.setImage(Activator.getImageDescriptor(SEARCH_ICON_PATH).createImage());
lstKey = new List(cmpoKeyArea, SWT.BORDER | SWT.V_SCROLL);
lstKey.setEnabled(false);
lstKey.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, true, 3, 1));
btnScanMoreKey = new Button(cmpoKeyArea, SWT.NONE);
btnScanMoreKey.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 3, 1));
btnScanMoreKey.setEnabled(false);
btnScanMoreKey.setText("Scan More");
Composite cmpoValueArea = new Composite(sashForm, SWT.NONE);
GridLayout cmpoValueAreaLayout = new GridLayout(2, false);
cmpoValueAreaLayout.marginWidth = NO_MARGIN;
cmpoValueAreaLayout.marginHeight = NO_MARGIN;
cmpoValueArea.setLayout(cmpoValueAreaLayout);
cmpoValue = new Composite(cmpoValueArea, SWT.BORDER);
cmpoValue.setLayout(new GridLayout(2, false));
cmpoValue.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 2, 1));
GridLayout cmpoKeyInfoLayout = new GridLayout(2, false);
cmpoKeyInfoLayout.verticalSpacing = 8;
cmpoKeyInfoLayout.marginHeight = NO_MARGIN;
cmpoKeyInfoLayout.marginTop = NO_MARGIN;
cmpoKeyInfoLayout.marginWidth = NO_MARGIN;
Composite cmpoKeyInfo = new Composite(cmpoValue, SWT.NONE);
cmpoKeyInfo.setLayout(cmpoKeyInfoLayout);
cmpoKeyInfo.setLayoutData(new GridData(SWT.FILL, SWT.BOTTOM, true, false, 2, 1));
Label lblType = new Label(cmpoKeyInfo, SWT.NONE);
lblType.setText("Type :");
lblTypeValue = new Label(cmpoKeyInfo, SWT.NONE);
lblTypeValue.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
Label lblKey = new Label(cmpoKeyInfo, SWT.NONE);
lblKey.setText("Key :");
lblKeyValue = new Label(cmpoKeyInfo, SWT.NONE);
lblKeyValue.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
Label lblValue = new Label(cmpoKeyInfo, SWT.NONE);
lblValue.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false, 2, 1));
lblValue.setText("Value :");
cmpoInnerValue = new Composite(cmpoValue, SWT.NONE);
cmpoInnerValue.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 2, 1));
cmpoInnerValue.setVisible(false);
GridLayout cmpoInnerValueLayout = new GridLayout(1, false);
cmpoInnerValueLayout.marginHeight = NO_MARGIN;
cmpoInnerValueLayout.marginWidth = NO_MARGIN;
cmpoInnerValue.setLayout(cmpoInnerValueLayout);
tblInnerValue = new Table(cmpoInnerValue, SWT.BORDER | SWT.FULL_SELECTION);
tblInnerValue.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
tblInnerValue.setHeaderVisible(true);
tblInnerValue.setLinesVisible(true);
cmpoStringValue = new Composite(cmpoValue, SWT.NONE);
cmpoStringValue.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 2, 1));
cmpoStringValue.setVisible(false);
GridLayout cmpoStringValueLayout = new GridLayout(1, false);
cmpoStringValueLayout.marginHeight = NO_MARGIN;
cmpoStringValueLayout.marginWidth = NO_MARGIN;
cmpoStringValue.setLayout(cmpoStringValueLayout);
txtStringValue = new Text(cmpoStringValue, SWT.BORDER | SWT.READ_ONLY | SWT.MULTI);
txtStringValue.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
txtStringValue.setBackground(tblInnerValue.getBackground());
GridLayout cmpoProgressLayout = new GridLayout(1, false);
cmpoProgressLayout.marginWidth = NO_MARGIN;
cmpoProgressLayout.marginTop = PROGRESS_MARGIN_TOP;
cmpoProgressLayout.marginBottom = PROGRESS_MARGIN_BOTTOM;
Composite cmpoProgress = new Composite(cmpoValueArea, SWT.NONE);
cmpoProgress.setLayout(cmpoProgressLayout);
cmpoProgress.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 2, 1));
progressBar = new ProgressBar(cmpoProgress, SWT.HORIZONTAL | SWT.INDETERMINATE);
GridData progressBarLayout = new GridData(SWT.RIGHT, SWT.BOTTOM, false, false, 1, 1);
progressBarLayout.widthHint = PROGRESS_WIDTH;
progressBar.setLayoutData(progressBarLayout);
sashForm.setWeights(new int[] { 1, 1 });
scrolledComposite.setContent(cmpoMain);
scrolledComposite.setMinSize(cmpoMain.computeSize(SWT.DEFAULT, SWT.DEFAULT));
cbDatabase.addListener(SWT.Selection, new AzureListenerWrapper(INSIGHT_NAME, "cbDatabase", null) {
@Override
protected void handleEventFunc(Event event) {
if (cbActionType.getText().equals(ACTION_GET)) {
return;
}
setWidgetEnableStatus(false);
txtKeyPattern.setText(DEFAULT_SCAN_PATTERN);
onDataBaseSelect();
}
});
lstKey.addListener(SWT.Selection, new AzureListenerWrapper(INSIGHT_NAME, "lstKey", null) {
@Override
protected void handleEventFunc(Event event) {
String selectedKey = lstKey.getItem(lstKey.getSelectionIndex());
if (selectedKey.equals(lastChosenKey)) {
return;
}
setWidgetEnableStatus(false);
lastChosenKey = selectedKey;
redisExplorerPresenter.onkeySelect(cbDatabase.getSelectionIndex(), selectedKey);
}
});
btnSearch.addListener(SWT.Selection, new AzureListenerWrapper(INSIGHT_NAME, "btnSearch", null) {
@Override
protected void handleEventFunc(Event event) {
onBtnSearchClick();
}
});
btnScanMoreKey.addListener(SWT.Selection, new AzureListenerWrapper(INSIGHT_NAME, "btnScanMoreKey", null) {
@Override
protected void handleEventFunc(Event event) {
setWidgetEnableStatus(false);
redisExplorerPresenter.onKeyList(cbDatabase.getSelectionIndex(),
currentCursor, txtKeyPattern.getText());
}
});
txtKeyPattern.addListener(SWT.KeyDown, event -> {
// Enter key pressed
if (event.keyCode == SWT.CR) {
onBtnSearchClick();
}
});
cbActionType.addListener(SWT.Selection, new AzureListenerWrapper(INSIGHT_NAME, "cbActionType", null) {
@Override
protected void handleEventFunc(Event event) {
String selected = cbActionType.getText();
if (selected.equals(ACTION_GET)) {
btnScanMoreKey.setEnabled(false);
} else if (selected.equals(ACTION_SCAN)) {
btnScanMoreKey.setEnabled(true);
}
}
});
}