Skip to content

Commit

Permalink
Merge pull request #33 from boyusun-SAG/SomeImprovements
Browse files Browse the repository at this point in the history
Some improvements
  • Loading branch information
anthonydahanne authored Jan 29, 2018
2 parents 72f4474 + 2ae64ff commit 4d1fcf6
Show file tree
Hide file tree
Showing 7 changed files with 241 additions and 76 deletions.
7 changes: 6 additions & 1 deletion README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,12 @@ java -jar tinypounderXXX.jar

If you usually run the TinyPounder with the same kit, you can provide its path at start time :
----
java -jar tinypounderXXX.jar --kit.path=/path/to/unzipped/kit/
java -jar tinypounderXXX.jar --kitPath=/path/to/unzipped/kit/ --licensePath=/path/to/license.xml
----

Disable auto-launch browser (when you already have a tinyPounder window)
----
java -jar tinypounderXXX.jar --autoLaunchBrowser=false
----

Then head to http://localhost:8080
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,14 @@ public class ApplicationReadyListener implements ApplicationListener<Application

@Value("${server.port}")
private int port;

@Value("${autoLaunchBrowser}")
private Boolean autoLaunch;

@SuppressWarnings("unchecked")
@Override
public void onApplicationEvent(ApplicationReadyEvent event) {
if (!autoLaunch) return;
URI uri = URI.create("http://localhost:" + port);
if (Desktop.isDesktopSupported()) {
Desktop desktop = Desktop.getDesktop();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
package org.terracotta.tinypounder;

public class DatasetConfiguration {
private final String keyType;
private final String offheapResourceName;
private final String diskResourceName;
private final boolean useIndex;

public DatasetConfiguration(String offheapResourceName, String diskResourceName, boolean useIndex) {
public DatasetConfiguration(String keyType, String offheapResourceName, String diskResourceName, boolean useIndex) {
this.keyType = keyType;
this.offheapResourceName = offheapResourceName;
this.diskResourceName = diskResourceName;
this.useIndex = useIndex;
}

public String getKeyType() { return keyType; }

public String getOffheapResourceName() {
return offheapResourceName;
}
Expand Down

Large diffs are not rendered by default.

59 changes: 51 additions & 8 deletions src/main/java/org/terracotta/tinypounder/TinyPounderMainUI.java
Original file line number Diff line number Diff line change
Expand Up @@ -1489,9 +1489,18 @@ private void addDatasetControls() {
datasetNameField.setPlaceholder("dataset name");
datasetNameField.addStyleName("align-bottom");

List<String> keyTypeValues = Arrays.asList("STRING", "INT", "LONG", "DOUBLE", "BOOL", "CHAR");
ComboBox<String> keyTypeComboBox = new ComboBox<>("Key type", keyTypeValues);
keyTypeComboBox.setStyleName("datasetAttribute");
keyTypeComboBox.setEmptySelectionAllowed(false);
keyTypeComboBox.setTextInputAllowed(false);
keyTypeComboBox.setValue(keyTypeValues.get(0));

HorizontalLayout offHeapOption = new HorizontalLayout();
offHeapOption.setStyleName("datasetAttribute");
TextField offHeapPersistenceLocationField = new TextField();
CheckBox offHeapCheckBox = new CheckBox("offheap", true);
offHeapCheckBox.addStyleName("shift-bottom-right-offheap");
offHeapCheckBox.addStyleName("bottom");
offHeapCheckBox.addValueChangeListener(valueChangeEvent -> {
if (valueChangeEvent.getValue()) {
offHeapPersistenceLocationField.setEnabled(true);
Expand All @@ -1501,11 +1510,13 @@ private void addDatasetControls() {
});
offHeapPersistenceLocationField.setCaption("offheap resource name");
offHeapPersistenceLocationField.setValue("offheap-1");
offHeapOption.addComponents(offHeapCheckBox, offHeapPersistenceLocationField);


HorizontalLayout diskOption = new HorizontalLayout();
diskOption.setStyleName("datasetAttribute");
TextField diskPersistenceLocationField = new TextField();
CheckBox diskCheckBox = new CheckBox("disk", true);
diskCheckBox.addStyleName("shift-bottom-right-disk");
diskCheckBox.addStyleName("bottom");
diskCheckBox.addValueChangeListener(valueChangeEvent -> {
if (valueChangeEvent.getValue()) {
diskPersistenceLocationField.setEnabled(true);
Expand All @@ -1515,18 +1526,20 @@ private void addDatasetControls() {
});
diskPersistenceLocationField.setCaption("disk resource name");
diskPersistenceLocationField.setValue("dataroot-1");
diskOption.addComponents(diskCheckBox, diskPersistenceLocationField);

CheckBox indexCheckBox = new CheckBox("use index", true);
indexCheckBox.addStyleName("shift-bottom-right-index");
indexCheckBox.setStyleName("datasetAttribute");
indexCheckBox.addStyleName("bottom");

Button addDatasetButton = new Button("Add dataset");
addDatasetButton.addStyleName("align-bottom");
addDatasetButton.setStyleName("datasetAttribute");

datasetCreation.addComponentsAndExpand(datasetNameField, offHeapCheckBox, offHeapPersistenceLocationField, diskCheckBox, diskPersistenceLocationField, indexCheckBox, addDatasetButton);
datasetCreation.addComponents(datasetNameField, keyTypeComboBox, offHeapOption, diskOption, indexCheckBox, addDatasetButton);
ListDataProvider<String> listDataProvider = new ListDataProvider<>(datasetNames);
addDatasetButton.addClickListener(clickEvent -> {
try {
DatasetConfiguration datasetConfiguration = new DatasetConfiguration(offHeapCheckBox.getValue() ? offHeapPersistenceLocationField.getValue() : null, diskCheckBox.getValue() ? diskPersistenceLocationField.getValue() : null, indexCheckBox.getValue());
DatasetConfiguration datasetConfiguration = new DatasetConfiguration(keyTypeComboBox.getValue(), offHeapCheckBox.getValue() ? offHeapPersistenceLocationField.getValue() : null, diskCheckBox.getValue() ? diskPersistenceLocationField.getValue() : null, indexCheckBox.getValue());
datasetManagerBusiness.createDataset(datasetNameField.getValue(), datasetConfiguration);
datasetNames.add(datasetNameField.getValue());
refreshDatasetStuff(listDataProvider);
Expand Down Expand Up @@ -1574,10 +1587,40 @@ private void addDatasetControls() {
if (datasetInstanceNames.size() > 0) {
destroyDatasetButton.setEnabled(false);
}
int count = 0;
for (String instanceName : datasetInstanceNames) {
HorizontalLayout datasetInstanceInfoLayout = new HorizontalLayout();
if ((count++) % 2 == 0) {
datasetInstanceInfoLayout.setStyleName("greyBackground");
}
Label datasetInstanceNameLabel = new Label(instanceName);
datasetInstanceNameLabel.setStyleName("instance");

TextField newCellField = new TextField();
newCellField.setPlaceholder("myCellName:STRING");
newCellField.setStyleName("instance");
Button addCellButton = new Button("Add cell");
addCellButton.setStyleName("instance");
addCellButton.addClickListener(event -> {
try {
datasetManagerBusiness.addCustomCell(newCellField.getValue());
displayWarningNotification("New cell is added.");
} catch (Exception e) {
displayErrorNotification("New cell cannot be added.", e);
}
});
Button removeCellButton = new Button("Remove cell");
removeCellButton.setStyleName("instance");
removeCellButton.addClickListener(event -> {
try {
datasetManagerBusiness.removeCustomCell(newCellField.getValue());
displayWarningNotification("New cell is removed.");
} catch (Exception e) {
displayErrorNotification("New cell cannot be removed.", e);
}
});
Button closeDatasetButton = new Button("Close dataset instance");
closeDatasetButton.setStyleName("instance");
closeDatasetButton.addClickListener(event -> {
try {
datasetManagerBusiness.closeDatasetInstance(datasetName, instanceName);
Expand Down Expand Up @@ -1605,7 +1648,7 @@ private void addDatasetControls() {
});


datasetInstanceInfoLayout.addComponentsAndExpand(datasetInstanceNameLabel, poundingSlider, closeDatasetButton);
datasetInstanceInfoLayout.addComponentsAndExpand(datasetInstanceNameLabel, newCellField, addCellButton, removeCellButton, poundingSlider, closeDatasetButton);
datasetListLayout.addComponent(datasetInstanceInfoLayout);
}

Expand Down
31 changes: 28 additions & 3 deletions src/main/resources/VAADIN/themes/tinypounder/styles.scss
Original file line number Diff line number Diff line change
Expand Up @@ -57,17 +57,42 @@ $v-layout-margin-bottom: 16px;

.v-slot-shift-bottom-right-offheap {
top: 28px;
left: 8%;
left: 5em;
}

.v-slot-shift-bottom-right-disk {
top: 28px;
left: 10%;
left: 5em;
}

.v-slot-shift-bottom-right-index {
top: 28px;
left: 6%;
left: 2em;
}

.v-slot-datasetAttribute {
margin-left: 3em;
}

.v-checkbox-bottom {
top: 2em;
}

.v-button-datasetAttribute {
top: 1em;
}

.v-label-instance {
margin-top: .5em;
margin-left: 1em;
}

.v-slot-greyBackground {
background-color: #EAEAEA;
}

.v-slot-instance {
top: .7em;
}

.tc-config-xml {
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ reconnectWindow=0
spring.devtools.livereload.enabled=false
spring.devtools.restart.enabled=false
server.port=9490
autoLaunchBrowser=true

0 comments on commit 4d1fcf6

Please sign in to comment.