/******************************************************************************* | |
* Copyright (c) 2020 RBEI and others. | |
* | |
* This program and the accompanying materials | |
* are made available under the terms of the Eclipse Public License v. 2.0 | |
* which accompanies this distribution, and is available at | |
* https://www.eclipse.org/legal/epl-2.0/ | |
* | |
* SPDX-License-Identifier: EPL-2.0 | |
* | |
* Contributors: | |
* Santhosh Gokhale D - Initial contribution and API | |
*******************************************************************************/ | |
package org.eclipse.blockchain.ui.views; | |
import org.eclipse.swt.SWT; | |
import org.eclipse.swt.layout.GridData; | |
import org.eclipse.swt.layout.GridLayout; | |
import org.eclipse.swt.widgets.Button; | |
import org.eclipse.swt.widgets.Combo; | |
import org.eclipse.swt.widgets.Composite; | |
import org.eclipse.swt.widgets.Label; | |
import org.eclipse.swt.widgets.Text; | |
import org.eclipse.ui.part.ViewPart; | |
/** | |
* Class with the implementation for the Run time view that would deploy the | |
* selected smart contaracts belonging to an account on either a test network or | |
* an actual blockchain network. | |
*/ | |
public class RunViewPart extends ViewPart { | |
/** | |
* Empty constructor. | |
*/ | |
public RunViewPart() { | |
// Do nothing | |
} | |
@Override | |
public void createPartControl(final Composite parent) { | |
Composite composite = new Composite(parent, SWT.NONE); | |
GridLayout layout = new GridLayout(); | |
layout.numColumns = 2; | |
layout.horizontalSpacing = 5; | |
layout.verticalSpacing = 10; | |
layout.makeColumnsEqualWidth = true; | |
composite.setLayout(layout); | |
Button testNetButton = new Button(composite, SWT.RADIO); | |
testNetButton.setText("TestNet"); | |
Combo testNetCombo = new Combo(composite, | |
SWT.DROP_DOWN | SWT.READ_ONLY); | |
testNetCombo.add("TestNet A"); | |
testNetCombo.add("TestNet B"); | |
testNetCombo.add("TestNet C"); | |
GridData gridTestNetCombo = commonGridDataCreation(); | |
testNetCombo.setLayoutData(gridTestNetCombo); | |
Button atAddressButton = new Button(composite, SWT.RADIO); | |
atAddressButton.setText("At Address"); | |
Text addressText = new Text(composite, SWT.BORDER); | |
addressText.setText("0.0.0.0"); | |
GridData gridDataAddressText = commonGridDataCreation(); | |
addressText.setLayoutData(gridDataAddressText); | |
Label accountLabel = new Label(composite, 0); | |
accountLabel.setText("Account"); | |
Combo accountCombo = new Combo(composite, | |
SWT.DROP_DOWN | SWT.READ_ONLY); | |
accountCombo.add("0x76439311057c197e3ef6a9ad87f57e3550d36f5c"); | |
accountCombo.add("0xb304c9e034f29800b6cef17934a9e1a5564d9bc6"); | |
accountCombo.add("0x9d6a1232e12b793db22ba3f76a9e9f6650e4bf54"); | |
GridData gridDataAccText = commonGridDataCreation(); | |
accountCombo.setLayoutData(gridDataAccText); | |
Label gasLimitLabel = new Label(composite, 0); | |
gasLimitLabel.setText("Gas Limit"); | |
Text gasLimitText = new Text(composite, SWT.BORDER); | |
gasLimitText.setText("10000"); | |
GridData gridDataGasLimitText = commonGridDataCreation(); | |
gasLimitText.setLayoutData(gridDataGasLimitText); | |
Label valueLabel = new Label(composite, 0); | |
valueLabel.setText("Value"); | |
Text valueText = new Text(composite, SWT.BORDER); | |
valueText.setText("0"); | |
GridData gridDataValueText = commonGridDataCreation(); | |
valueText.setLayoutData(gridDataValueText); | |
Label environmentLabel = new Label(composite, 0); | |
environmentLabel.setText("Smart Contract"); | |
Combo environmentCombo = new Combo(composite, | |
SWT.DROP_DOWN | SWT.READ_ONLY); | |
environmentCombo.add("SC 1"); | |
environmentCombo.add("SC 2"); | |
environmentCombo.add("SC 3"); | |
GridData gridDataText = commonGridDataCreation(); | |
environmentCombo.setLayoutData(gridDataText); | |
Button deployButton = new Button(composite, SWT.PUSH); | |
deployButton.setText("Deploy"); | |
GridData gridDataDeployButton = commonGridDataCreation(); | |
gridDataDeployButton.horizontalSpan = 2; | |
deployButton.setLayoutData(gridDataDeployButton); | |
} | |
/** | |
* @return | |
*/ | |
private GridData commonGridDataCreation() { | |
GridData gridDataAddressText = new GridData(); | |
gridDataAddressText.horizontalAlignment = GridData.FILL; | |
gridDataAddressText.grabExcessHorizontalSpace = true; | |
return gridDataAddressText; | |
} | |
@Override | |
public void setFocus() { | |
} | |
} |