-
Notifications
You must be signed in to change notification settings - Fork 621
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added config to include unassigned category in pie charts on dashboard
- Loading branch information
Showing
3 changed files
with
58 additions
and
2 deletions.
There are no files selected for viewing
52 changes: 52 additions & 0 deletions
52
...src/name/abuchen/portfolio/ui/views/dashboard/charts/IncludeUnassignedCategoryConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
package name.abuchen.portfolio.ui.views.dashboard.charts; | ||
|
||
import org.eclipse.jface.action.IMenuManager; | ||
|
||
import name.abuchen.portfolio.model.Dashboard; | ||
import name.abuchen.portfolio.ui.Messages; | ||
import name.abuchen.portfolio.ui.util.SimpleAction; | ||
import name.abuchen.portfolio.ui.views.dashboard.WidgetConfig; | ||
import name.abuchen.portfolio.ui.views.dashboard.WidgetDelegate; | ||
|
||
public class IncludeUnassignedCategoryConfig implements WidgetConfig | ||
{ | ||
private final WidgetDelegate<?> delegate; | ||
private boolean isUnassignedIncluded = false; | ||
|
||
public IncludeUnassignedCategoryConfig(WidgetDelegate<?> delegate, boolean defaultValue) | ||
{ | ||
this.delegate = delegate; | ||
|
||
String code = delegate.getWidget().getConfiguration().get(Dashboard.Config.FLAG_INCLUDE_UNASSIGNED.name()); | ||
this.isUnassignedIncluded = code != null ? Boolean.parseBoolean(code) : defaultValue; | ||
} | ||
|
||
@Override | ||
public void menuAboutToShow(IMenuManager manager) | ||
{ | ||
SimpleAction action = new SimpleAction(Messages.LabelIncludeUnassignedCategoryInCharts, a -> { | ||
this.isUnassignedIncluded = !this.isUnassignedIncluded; | ||
|
||
delegate.getWidget().getConfiguration().put(Dashboard.Config.FLAG_INCLUDE_UNASSIGNED.name(), | ||
String.valueOf(this.isUnassignedIncluded)); | ||
|
||
delegate.update(); | ||
delegate.getClient().touch(); | ||
}); | ||
|
||
action.setChecked(this.isUnassignedIncluded); | ||
manager.add(action); | ||
} | ||
|
||
@Override | ||
public String getLabel() | ||
{ | ||
return Messages.LabelIncludeUnassignedCategoryInCharts + ": " //$NON-NLS-1$ | ||
+ (this.isUnassignedIncluded ? Messages.LabelYes : Messages.LabelNo); | ||
} | ||
|
||
public boolean isUnassignedCategoryIncluded() | ||
{ | ||
return this.isUnassignedIncluded; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters