Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix : Improve readability #212

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,8 @@
import com.insightfullogic.honest_profiler.ports.javafx.controller.filter.FilterDialogController;
import com.insightfullogic.honest_profiler.ports.javafx.model.ApplicationContext;
import com.insightfullogic.honest_profiler.ports.javafx.model.ProfileContext;
import com.insightfullogic.honest_profiler.ports.javafx.view.cell.CountTableCell;
import com.insightfullogic.honest_profiler.ports.javafx.view.cell.CountTreeTableCell;
import com.insightfullogic.honest_profiler.ports.javafx.view.cell.PercentageTableCell;
import com.insightfullogic.honest_profiler.ports.javafx.view.cell.PercentageTreeTableCell;
import com.insightfullogic.honest_profiler.ports.javafx.view.cell.TimeTableCell;
import com.insightfullogic.honest_profiler.ports.javafx.view.cell.TimeTreeTableCell;
import com.insightfullogic.honest_profiler.ports.javafx.view.cell.NumberTableCell;
import com.insightfullogic.honest_profiler.ports.javafx.view.cell.NumberTreeTableCell;
import com.insightfullogic.honest_profiler.ports.javafx.view.menu.ColumnGroupMenuItem;
import com.insightfullogic.honest_profiler.ports.javafx.view.menu.ColumnMenuItem;

Expand Down Expand Up @@ -186,6 +182,8 @@ protected void initializeColumnView(Button columnViewButton)
public void setApplicationContext(ApplicationContext applicationContext)
{
super.setApplicationContext(applicationContext);
applicationContext.getConfiguration()
.addListener((property, oldValue, newValue) -> refresh());

// If the subclass doesn't need filter management, no UI control should have been passed on in the initialize()
// method.
Expand Down Expand Up @@ -390,7 +388,7 @@ protected <U> void cfgPctCol(TableColumn<U, Number> column, String propertyName,
ProfileContext profileContext, String title)
{
column.setCellValueFactory(new PropertyValueFactory<>(propertyName));
column.setCellFactory(col -> new PercentageTableCell<>(null));
column.setCellFactory(col -> new NumberTableCell<>(appCtx()::displayPercent, null));
configureHeader(column, title, profileContext);
addColumnMenuItem(column, title, profileContext);
}
Expand All @@ -408,7 +406,8 @@ protected <U> void cfgPctDiffCol(TableColumn<U, Number> column, String propertyN
String title)
{
column.setCellValueFactory(new PropertyValueFactory<>(propertyName));
column.setCellFactory(col -> new PercentageTableCell<>(doubleDiffStyler));
column.setCellFactory(
col -> new NumberTableCell<>(appCtx()::displayPercent, doubleDiffStyler));
configureHeader(column, title, null);
addColumnMenuItem(column, title, null);
}
Expand All @@ -427,7 +426,7 @@ protected <U> void cfgNrCol(TableColumn<U, Number> column, String propertyName,
ProfileContext profileContext, String title)
{
column.setCellValueFactory(new PropertyValueFactory<>(propertyName));
column.setCellFactory(col -> new CountTableCell<>(null));
column.setCellFactory(col -> new NumberTableCell<>(appCtx()::displayIntegral, null));
configureHeader(column, title, profileContext);
addColumnMenuItem(column, title, profileContext);
}
Expand All @@ -445,7 +444,7 @@ protected <U> void cfgNrDiffCol(TableColumn<U, Number> column, String propertyNa
String title)
{
column.setCellValueFactory(new PropertyValueFactory<>(propertyName));
column.setCellFactory(col -> new CountTableCell<>(intDiffStyler));
column.setCellFactory(col -> new NumberTableCell<>(appCtx()::displayIntegral, intDiffStyler));
configureHeader(column, title, null);
addColumnMenuItem(column, title, null);
}
Expand All @@ -464,7 +463,7 @@ protected <U> void cfgTimeCol(TableColumn<U, Number> column, String propertyName
ProfileContext profileContext, String title)
{
column.setCellValueFactory(new PropertyValueFactory<>(propertyName));
column.setCellFactory(col -> new TimeTableCell<>(null));
column.setCellFactory(col -> new NumberTableCell<>(appCtx()::displayTime, null));
configureHeader(column, title, profileContext);
addColumnMenuItem(column, title, profileContext);
}
Expand All @@ -482,7 +481,7 @@ protected <U> void cfgTimeDiffCol(TableColumn<U, Number> column, String property
String title)
{
column.setCellValueFactory(new PropertyValueFactory<>(propertyName));
column.setCellFactory(col -> new TimeTableCell<>(longDiffStyler));
column.setCellFactory(col -> new NumberTableCell<>(appCtx()::displayTime, longDiffStyler));
configureHeader(column, title, null);
addColumnMenuItem(column, title, null);
}
Expand All @@ -503,7 +502,7 @@ protected <U> void cfgPctCol(TreeTableColumn<U, Number> column, String propertyN
ProfileContext profileContext, String title)
{
column.setCellValueFactory(new TreeItemPropertyValueFactory<>(propertyName));
column.setCellFactory(col -> new PercentageTreeTableCell<>(null));
column.setCellFactory(col -> new NumberTreeTableCell<>(appCtx()::displayPercent, null));
configureHeader(column, title, profileContext);
addColumnMenuItem(column, title, profileContext);
}
Expand All @@ -521,7 +520,8 @@ protected <U> void cfgPctDiffCol(TreeTableColumn<U, Number> column, String prope
String title)
{
column.setCellValueFactory(new TreeItemPropertyValueFactory<>(propertyName));
column.setCellFactory(col -> new PercentageTreeTableCell<>(doubleDiffStyler));
column.setCellFactory(
col -> new NumberTreeTableCell<>(appCtx()::displayPercent, doubleDiffStyler));
configureHeader(column, title, null);
addColumnMenuItem(column, title, null);
}
Expand All @@ -540,7 +540,7 @@ protected <U> void cfgNrCol(TreeTableColumn<U, Number> column, String propertyNa
ProfileContext profileContext, String title)
{
column.setCellValueFactory(new TreeItemPropertyValueFactory<>(propertyName));
column.setCellFactory(col -> new CountTreeTableCell<>(null));
column.setCellFactory(col -> new NumberTreeTableCell<>(appCtx()::displayIntegral, null));
configureHeader(column, title, profileContext);
addColumnMenuItem(column, title, profileContext);
}
Expand All @@ -558,7 +558,8 @@ protected <U> void cfgNrDiffCol(TreeTableColumn<U, Number> column, String proper
String title)
{
column.setCellValueFactory(new TreeItemPropertyValueFactory<>(propertyName));
column.setCellFactory(col -> new CountTreeTableCell<>(intDiffStyler));
column
.setCellFactory(col -> new NumberTreeTableCell<>(appCtx()::displayIntegral, intDiffStyler));
configureHeader(column, title, null);
addColumnMenuItem(column, title, null);
}
Expand All @@ -577,7 +578,7 @@ protected <U> void cfgTimeCol(TreeTableColumn<U, Number> column, String property
ProfileContext profileContext, String title)
{
column.setCellValueFactory(new TreeItemPropertyValueFactory<>(propertyName));
column.setCellFactory(col -> new TimeTreeTableCell<>(null));
column.setCellFactory(col -> new NumberTreeTableCell<>(appCtx()::displayTime, null));
configureHeader(column, title, profileContext);
addColumnMenuItem(column, title, profileContext);
}
Expand All @@ -595,7 +596,8 @@ protected <U> void cfgTimeDiffCol(TreeTableColumn<U, Number> column, String prop
String title)
{
column.setCellValueFactory(new TreeItemPropertyValueFactory<>(propertyName));
column.setCellFactory(col -> new TimeTreeTableCell<>(longDiffStyler));
column.setCellFactory(
col -> new NumberTreeTableCell<>(appCtx()::displayTime, longDiffStyler));
configureHeader(column, title, null);
addColumnMenuItem(column, title, null);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ protected void initializeHandlers()
appCtx(),
exportButton.getScene().getWindow(),
"flat_diff_profile.csv",
out -> writeFlatProfileDiffCsv(out, diff.getData(), ReportUtil.Mode.CSV)
out -> writeFlatProfileDiffCsv(appCtx(), out, diff.getData(), ReportUtil.Mode.CSV)
));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ protected void initializeHandlers()
appCtx(),
exportButton.getScene().getWindow(),
"flat_profile.csv",
out -> writeFlatProfileCsv(out, flatProfile, ReportUtil.Mode.CSV)
out -> writeFlatProfileCsv(appCtx(), out, flatProfile, ReportUtil.Mode.CSV)
));
}

Expand Down Expand Up @@ -241,7 +241,7 @@ protected void initializeTable()
method.setCellFactory(col -> new MethodNameTableCell<Entry>());

selfTimeGraphical.setCellValueFactory(new PropertyValueFactory<>("selfCntPct"));
selfTimeGraphical.setCellFactory(col -> new GraphicalShareTableCell<>());
selfTimeGraphical.setCellFactory(col -> new GraphicalShareTableCell<>(appCtx()));

// The column configuration methods should (for now) be called in the same order as the columns are declared in
// the FXML.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
import java.util.List;
import java.util.Map;

import com.insightfullogic.honest_profiler.core.aggregation.AggregationProfile;
import com.insightfullogic.honest_profiler.ports.javafx.ViewType;
import com.insightfullogic.honest_profiler.ports.javafx.model.ApplicationContext;
import com.insightfullogic.honest_profiler.ports.javafx.model.ProfileContext;
Expand Down Expand Up @@ -178,20 +179,16 @@ public void setProfileContext(ProfileContext prCtx)
flameController.setAllowedFrameGroupings(BY_FQMN, BY_FQMN_LINENR, BY_BCI, BY_METHOD_ID);
flameController.bind(prCtx.profileProperty(), treeExtractor(flameController));

// Bind the profile sample count display
prCtx.profileProperty().addListener(
(property, oldValue, newValue) -> profileSampleCount.setText(
newValue == null ? null : getText(
CONTENT_LABEL_PROFILESAMPLECOUNT,
newValue.getGlobalData().getTotalCnt())));
// Bind the profile sample count display so it changes when new Profiles come in
prCtx.profileProperty()
.addListener((property, oldValue, newValue) -> updateSampleCount(newValue));

if (prCtx.getProfile() != null)
{
profileSampleCount.setText(
getText(
CONTENT_LABEL_PROFILESAMPLECOUNT,
prCtx.getProfile().getGlobalData().getTotalCnt()));
}
// Bind the profile sample count display so it changes when the display preferences change
appCtx().getConfiguration()
.addListener((property, oldValue, newValue) -> updateSampleCount(prCtx));

// Display the initial sample count
updateSampleCount(prCtx);

// Configure the View choice
viewChoice.setConverter(getStringConverterForType(ViewType.class));
Expand All @@ -203,6 +200,37 @@ public void setProfileContext(ProfileContext prCtx)
freezeButton.setDisable(prCtx.getMode() != LIVE);
}

// Sample Count Display

/**
* Update the sample count based on the {@link ProfileContext}.
*
* @param profileContext the {@link ProfileContext}
*/
private void updateSampleCount(ProfileContext profileContext)
{
updateSampleCount(profileContext == null ? null : profileContext.getProfile());
}

/**
* Update the sample count for the {@link AggregationProfile}.
*
* @param profile the {@link AggregationProfile}
*/
private void updateSampleCount(AggregationProfile profile)
{

if (profile == null)
{
profileSampleCount.setText(null);
return;
}

profileSampleCount.setText(getText(
CONTENT_LABEL_PROFILESAMPLECOUNT,
appCtx().displayIntegral(profile.getGlobalData().getTotalCnt())));
}

// View Methods

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.insightfullogic.honest_profiler.ports.javafx.controller;

import static com.insightfullogic.honest_profiler.ports.javafx.model.ProfileContext.ProfileMode.LOG;
import static com.insightfullogic.honest_profiler.ports.javafx.model.configuration.Configuration.DEFAULT_CONFIGURATION;
import static com.insightfullogic.honest_profiler.ports.javafx.util.DialogUtil.selectLogFile;
import static com.insightfullogic.honest_profiler.ports.javafx.util.DialogUtil.showErrorDialog;
import static com.insightfullogic.honest_profiler.ports.javafx.util.DialogUtil.showExceptionDialog;
Expand Down Expand Up @@ -35,6 +36,7 @@
import com.insightfullogic.honest_profiler.core.MachineListener;
import com.insightfullogic.honest_profiler.core.sources.VirtualMachine;
import com.insightfullogic.honest_profiler.ports.javafx.UserInterfaceConfigurationException;
import com.insightfullogic.honest_profiler.ports.javafx.controller.configuration.ConfigurationDialogController;
import com.insightfullogic.honest_profiler.ports.javafx.model.ApplicationContext;
import com.insightfullogic.honest_profiler.ports.javafx.model.ProfileContext;
import com.insightfullogic.honest_profiler.ports.javafx.model.ProfileContext.ProfileMode;
Expand Down Expand Up @@ -68,13 +70,17 @@ public class RootController extends AbstractController implements MachineListene
@FXML
private MenuItem openLiveItem;
@FXML
private MenuItem preferencesItem;
@FXML
private MenuItem quitItem;
@FXML
private Menu monitorMenu;
@FXML
private TabPane profileTabs;
@FXML
private Label info;
@FXML
private ConfigurationDialogController configurationController;

private LocalMachineSource machineSource;

Expand All @@ -94,6 +100,9 @@ public void initialize()
// Monitor running VMs on the local machine.
machineSource = new LocalMachineSource(getLogger(getClass()), this);
machineSource.start();

appCtx().setConfiguration(DEFAULT_CONFIGURATION);
configurationController.readConfiguration(DEFAULT_CONFIGURATION);
}

// MachineListener Implementation
Expand Down Expand Up @@ -367,6 +376,8 @@ protected void initializeHandlers()
{
openLogItem.setOnAction(event -> doWithFile(file -> createNewProfile(file, false)));
openLiveItem.setOnAction(event -> doWithFile(file -> createNewProfile(file, true)));
preferencesItem.setOnAction(
event -> appCtx().setConfiguration(configurationController.showAndWait().get()));
quitItem.setOnAction(event -> exit());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ protected void initializeTable()
methodColumn.setCellValueFactory(new TreeItemPropertyValueFactory<>("key"));

percentColumn.setCellValueFactory(new TreeItemPropertyValueFactory<>("totalCntPct"));
percentColumn.setCellFactory(param -> new GraphicalShareTreeTableCell());
percentColumn.setCellFactory(param -> new GraphicalShareTreeTableCell(appCtx()));

// The column configuration methods should (for now) be called in the same order as the columns are declared in
// the FXML.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
package com.insightfullogic.honest_profiler.ports.javafx.controller.configuration;

import com.insightfullogic.honest_profiler.ports.javafx.controller.dialog.AbstractDialogController;
import com.insightfullogic.honest_profiler.ports.javafx.model.configuration.Configuration;

import javafx.fxml.FXML;
import javafx.scene.control.ButtonType;
import javafx.scene.control.Dialog;
import javafx.util.Callback;

public class ConfigurationDialogController extends AbstractDialogController<Configuration>
{
// Instance Properties
@FXML
private Dialog<Configuration> dialog;

@FXML
private FormattingConfigurationController displayFormattingController;
@FXML
private FormattingConfigurationController exportFormattingController;

// FXML Implementation

@Override
@FXML
public void initialize()
{
super.initialize(dialog);
}

// Configuration Management Methods

public void readConfiguration(Configuration configuration)
{
displayFormattingController
.readConfiguration(configuration.getDisplayFormattingConfiguration());
exportFormattingController
.readConfiguration(configuration.getExportFormattingConfiguration());
}

// AbstractDialogController Implementation

@Override
public Callback<ButtonType, Configuration> createResultHandler()
{
return button -> new Configuration(
displayFormattingController.getConfiguration(),
exportFormattingController.getConfiguration());
}

@Override
public void reset()
{
// NOOP
}

@Override
protected void initializeInfoText()
{
// NOOP
}

@Override
protected void initializeHandlers()
{
// NOOP
}
}
Loading