Remove non eclipse.org Swtchart.
It has been deprecated in previous version and with this being major
version it's time to remove it.
Change-Id: I28981062f38b7092e6857db13f8e24d2191ced99
Signed-off-by: Alexander Kurtakov <akurtako@redhat.com>
Reviewed-on: https://git.eclipse.org/r/c/linuxtools/org.eclipse.linuxtools/+/166015
Tested-by: Linux Tools Bot <linuxtools-bot@eclipse.org>
diff --git a/gcov/org.eclipse.linuxtools.gcov.core/src/org/eclipse/linuxtools/internal/gcov/view/CovView.java b/gcov/org.eclipse.linuxtools.gcov.core/src/org/eclipse/linuxtools/internal/gcov/view/CovView.java
index c4bea89..9a516b9 100644
--- a/gcov/org.eclipse.linuxtools.gcov.core/src/org/eclipse/linuxtools/internal/gcov/view/CovView.java
+++ b/gcov/org.eclipse.linuxtools.gcov.core/src/org/eclipse/linuxtools/internal/gcov/view/CovView.java
@@ -84,7 +84,7 @@
manager.add(fileAction);
manager.add(functionAction);
manager.add(new Separator());
- manager.add(new ChartAction(getViewSite().getShell(), getSTViewer(), true));
+ manager.add(new ChartAction(getViewSite().getShell(), getSTViewer()));
}
@Override
diff --git a/gprof/org.eclipse.linuxtools.gprof/src/org/eclipse/linuxtools/internal/gprof/view/GmonView.java b/gprof/org.eclipse.linuxtools.gprof/src/org/eclipse/linuxtools/internal/gprof/view/GmonView.java
index 8b5cfd7..c1b3331 100644
--- a/gprof/org.eclipse.linuxtools.gprof/src/org/eclipse/linuxtools/internal/gprof/view/GmonView.java
+++ b/gprof/org.eclipse.linuxtools.gprof/src/org/eclipse/linuxtools/internal/gprof/view/GmonView.java
@@ -132,7 +132,7 @@
manager.add(new Separator());
manager.add(switchSampleTime);
manager.add(new Separator());
- manager.add(new ChartAction(getViewSite().getShell(), getSTViewer(), true));
+ manager.add(new ChartAction(getViewSite().getShell(), getSTViewer()));
}
@Override
diff --git a/profiling/org.eclipse.linuxtools.dataviewers-feature/feature.xml b/profiling/org.eclipse.linuxtools.dataviewers-feature/feature.xml
index 73cf7ad..10085a3 100644
--- a/profiling/org.eclipse.linuxtools.dataviewers-feature/feature.xml
+++ b/profiling/org.eclipse.linuxtools.dataviewers-feature/feature.xml
@@ -35,7 +35,6 @@
<import plugin="org.eclipse.cdt.ui"/>
<import plugin="org.eclipse.cdt.core"/>
<import plugin="org.eclipse.core.resources" version="3.4.2" match="greaterOrEqual"/>
- <import plugin="org.swtchart"/>
<import plugin="org.eclipse.swtchart"/>
</requires>
diff --git a/profiling/org.eclipse.linuxtools.dataviewers.charts/.settings/org.eclipse.jdt.ui.prefs b/profiling/org.eclipse.linuxtools.dataviewers.charts/.settings/org.eclipse.jdt.ui.prefs
new file mode 100644
index 0000000..ea88167
--- /dev/null
+++ b/profiling/org.eclipse.linuxtools.dataviewers.charts/.settings/org.eclipse.jdt.ui.prefs
@@ -0,0 +1,72 @@
+eclipse.preferences.version=1
+editor_save_participant_org.eclipse.jdt.ui.postsavelistener.cleanup=true
+sp_cleanup.add_default_serial_version_id=true
+sp_cleanup.add_generated_serial_version_id=false
+sp_cleanup.add_missing_annotations=true
+sp_cleanup.add_missing_deprecated_annotations=true
+sp_cleanup.add_missing_methods=false
+sp_cleanup.add_missing_nls_tags=false
+sp_cleanup.add_missing_override_annotations=true
+sp_cleanup.add_missing_override_annotations_interface_methods=true
+sp_cleanup.add_serial_version_id=false
+sp_cleanup.always_use_blocks=true
+sp_cleanup.always_use_parentheses_in_expressions=false
+sp_cleanup.always_use_this_for_non_static_field_access=false
+sp_cleanup.always_use_this_for_non_static_method_access=false
+sp_cleanup.convert_functional_interfaces=true
+sp_cleanup.convert_to_enhanced_for_loop=true
+sp_cleanup.convert_to_enhanced_for_loop_if_loop_var_used=false
+sp_cleanup.correct_indentation=false
+sp_cleanup.format_source_code=true
+sp_cleanup.format_source_code_changes_only=true
+sp_cleanup.insert_inferred_type_arguments=false
+sp_cleanup.lazy_logical_operator=false
+sp_cleanup.make_local_variable_final=true
+sp_cleanup.make_parameters_final=false
+sp_cleanup.make_private_fields_final=true
+sp_cleanup.make_type_abstract_if_missing_method=false
+sp_cleanup.make_variable_declarations_final=false
+sp_cleanup.merge_conditional_blocks=false
+sp_cleanup.never_use_blocks=false
+sp_cleanup.never_use_parentheses_in_expressions=true
+sp_cleanup.number_suffix=false
+sp_cleanup.on_save_use_additional_actions=true
+sp_cleanup.organize_imports=true
+sp_cleanup.push_down_negation=false
+sp_cleanup.qualify_static_field_accesses_with_declaring_class=false
+sp_cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true
+sp_cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true
+sp_cleanup.qualify_static_member_accesses_with_declaring_class=false
+sp_cleanup.qualify_static_method_accesses_with_declaring_class=false
+sp_cleanup.remove_private_constructors=true
+sp_cleanup.remove_redundant_modifiers=true
+sp_cleanup.remove_redundant_semicolons=true
+sp_cleanup.remove_redundant_type_arguments=true
+sp_cleanup.remove_trailing_whitespaces=true
+sp_cleanup.remove_trailing_whitespaces_all=true
+sp_cleanup.remove_trailing_whitespaces_ignore_empty=false
+sp_cleanup.remove_unnecessary_array_creation=true
+sp_cleanup.remove_unnecessary_casts=true
+sp_cleanup.remove_unnecessary_nls_tags=true
+sp_cleanup.remove_unused_imports=false
+sp_cleanup.remove_unused_local_variables=false
+sp_cleanup.remove_unused_private_fields=true
+sp_cleanup.remove_unused_private_members=false
+sp_cleanup.remove_unused_private_methods=true
+sp_cleanup.remove_unused_private_types=true
+sp_cleanup.simplify_lambda_expression_and_method_ref=true
+sp_cleanup.sort_members=false
+sp_cleanup.sort_members_all=false
+sp_cleanup.use_anonymous_class_creation=false
+sp_cleanup.use_autoboxing=false
+sp_cleanup.use_blocks=false
+sp_cleanup.use_blocks_only_for_return_and_throw=false
+sp_cleanup.use_directly_map_method=false
+sp_cleanup.use_lambda=true
+sp_cleanup.use_parentheses_in_expressions=false
+sp_cleanup.use_this_for_non_static_field_access=false
+sp_cleanup.use_this_for_non_static_field_access_only_if_necessary=true
+sp_cleanup.use_this_for_non_static_method_access=false
+sp_cleanup.use_this_for_non_static_method_access_only_if_necessary=true
+sp_cleanup.use_unboxing=false
+sp_cleanup.use_var=false
diff --git a/profiling/org.eclipse.linuxtools.dataviewers.charts/META-INF/MANIFEST.MF b/profiling/org.eclipse.linuxtools.dataviewers.charts/META-INF/MANIFEST.MF
index d79c313..18deb5a 100755
--- a/profiling/org.eclipse.linuxtools.dataviewers.charts/META-INF/MANIFEST.MF
+++ b/profiling/org.eclipse.linuxtools.dataviewers.charts/META-INF/MANIFEST.MF
@@ -2,7 +2,7 @@
Bundle-ManifestVersion: 2
Bundle-Name: %bundleName
Bundle-SymbolicName: org.eclipse.linuxtools.dataviewers.charts;singleton:=true
-Bundle-Version: 6.1.0.qualifier
+Bundle-Version: 7.0.0.qualifier
Bundle-Activator: org.eclipse.linuxtools.internal.dataviewers.charts.Activator
Bundle-Vendor: %bundleProvider
Require-Bundle: org.eclipse.ui,
@@ -15,7 +15,6 @@
Import-Package: org.eclipse.linuxtools.dataviewers.piechart,
org.eclipse.linuxtools.internal.dataviewers.piechart,
org.eclipse.swtchart,
- org.eclipse.swtchart.extensions.charts,
- org.swtchart
+ org.eclipse.swtchart.extensions.charts
Bundle-Localization: plugin
Automatic-Module-Name: org.eclipse.linuxtools.dataviewers.charts
diff --git a/profiling/org.eclipse.linuxtools.dataviewers.charts/pom.xml b/profiling/org.eclipse.linuxtools.dataviewers.charts/pom.xml
index db6862b..e8f9bbb 100644
--- a/profiling/org.eclipse.linuxtools.dataviewers.charts/pom.xml
+++ b/profiling/org.eclipse.linuxtools.dataviewers.charts/pom.xml
@@ -19,7 +19,7 @@
</parent>
<artifactId>org.eclipse.linuxtools.dataviewers.charts</artifactId>
- <version>6.1.0-SNAPSHOT</version>
+ <version>7.0.0-SNAPSHOT</version>
<packaging>eclipse-plugin</packaging>
<name>Linux Tools Data Viewers Charts Plug-in</name>
diff --git a/profiling/org.eclipse.linuxtools.dataviewers.charts/src/org/eclipse/linuxtools/dataviewers/charts/actions/ChartAction.java b/profiling/org.eclipse.linuxtools.dataviewers.charts/src/org/eclipse/linuxtools/dataviewers/charts/actions/ChartAction.java
index 081090b..c1fe979 100755
--- a/profiling/org.eclipse.linuxtools.dataviewers.charts/src/org/eclipse/linuxtools/dataviewers/charts/actions/ChartAction.java
+++ b/profiling/org.eclipse.linuxtools.dataviewers.charts/src/org/eclipse/linuxtools/dataviewers/charts/actions/ChartAction.java
@@ -1,6 +1,6 @@
/*******************************************************************************
* Copyright (c) 2009, 2018 STMicroelectronics and others.
- *
+ *
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
* which is available at https://www.eclipse.org/legal/epl-2.0/
@@ -17,11 +17,9 @@
import org.eclipse.linuxtools.dataviewers.abstractviewers.AbstractSTViewer;
import org.eclipse.linuxtools.internal.dataviewers.charts.Activator;
import org.eclipse.linuxtools.internal.dataviewers.charts.Messages;
-import org.eclipse.linuxtools.internal.dataviewers.charts.dialogs.ChartDialog;
import org.eclipse.linuxtools.internal.dataviewers.charts.dialogs.ChartDialog2;
import org.eclipse.linuxtools.internal.dataviewers.charts.view.ChartView;
import org.eclipse.swt.widgets.Shell;
-import org.swtchart.Chart;
/**
* An action that open a chart dialog from an <code>AbstractSTViewer</code>.
@@ -34,7 +32,6 @@
/** The dialog */
private final Dialog dialog;
- private final boolean useEclipseSwtChart;
/**
* The constructor.
@@ -46,38 +43,14 @@
*/
public ChartAction(Shell shell, AbstractSTViewer viewer) {
super(Messages.ChartConstants_CREATE_CHART, Activator.getImageDescriptor("icons/chart_icon.png")); //$NON-NLS-1$
- dialog = new ChartDialog(shell, viewer);
+ dialog = new ChartDialog2(shell, viewer);
setEnabled(!viewer.getViewer().getSelection().isEmpty());
viewer.getViewer().addSelectionChangedListener(event -> setEnabled(!event.getSelection().isEmpty()));
- this.useEclipseSwtChart=false;
- }
-
- /**
- * The constructor.
- *
- * @param shell
- * the shell used by the dialog
- * @param viewer
- * the viewer inputed to the disalog
- * @param useEclipseSwtchart Whether Eclipse.org SWTChart to be used or the old Sourceforge library
- * @since 6.1
- */
- public ChartAction(Shell shell, AbstractSTViewer viewer, boolean useEclipseSwtchart) {
- super(Messages.ChartConstants_CREATE_CHART, Activator.getImageDescriptor("icons/chart_icon.png")); //$NON-NLS-1$
- dialog = new ChartDialog2(shell, viewer);
- setEnabled(!viewer.getViewer().getSelection().isEmpty());
- viewer.getViewer().addSelectionChangedListener(event -> setEnabled(!event.getSelection().isEmpty()));
- this.useEclipseSwtChart = useEclipseSwtchart;
}
@Override
public void run() {
dialog.open();
- if (!useEclipseSwtChart) {
- Chart chart = ((ChartDialog)dialog).getValue();
- ChartView.createChartView(chart);
- } else {
- ChartView.createChartView();
- }
+ ChartView.createChartView();
}
}
diff --git a/profiling/org.eclipse.linuxtools.dataviewers.charts/src/org/eclipse/linuxtools/dataviewers/charts/actions/SaveChartAction.java b/profiling/org.eclipse.linuxtools.dataviewers.charts/src/org/eclipse/linuxtools/dataviewers/charts/actions/SaveChartAction.java
deleted file mode 100755
index 35c77a9..0000000
--- a/profiling/org.eclipse.linuxtools.dataviewers.charts/src/org/eclipse/linuxtools/dataviewers/charts/actions/SaveChartAction.java
+++ /dev/null
@@ -1,230 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2014, 2018 Red Hat, Inc. and others.
- *
- * This program and the accompanying materials are made
- * available under the terms of the Eclipse Public License 2.0
- * which is available at https://www.eclipse.org/legal/epl-2.0/
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * Marzia Maugeri <marzia.maugeri@st.com> - initial API and implementation
- * Red Hat (various) - ongoing maintenance
- *******************************************************************************/
-package org.eclipse.linuxtools.dataviewers.charts.actions;
-
-import java.io.File;
-import java.text.MessageFormat;
-import java.util.HashMap;
-import java.util.Map;
-
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.jface.action.Action;
-import org.eclipse.jface.dialogs.ErrorDialog;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.linuxtools.internal.dataviewers.charts.Activator;
-import org.eclipse.linuxtools.internal.dataviewers.charts.Messages;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.GC;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.graphics.ImageData;
-import org.eclipse.swt.graphics.ImageLoader;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.FileDialog;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.PlatformUI;
-import org.swtchart.Chart;
-
-/**
- * An action to save any {@link Composite} (typically a {@link Chart}) as an image (jpeg/jpg, bmp, png).
- *
- * @since 6.0
- * @deprecated Use org.eclipse.swtchart.extensions.charts.InteractiveChart and its builtin safe functionality.
- */
-@Deprecated
-public class SaveChartAction extends Action {
-
- private static final String[] EXTENSIONS =
- { "*.png", "*.bmp", "*.jpg", "*.jpeg", "*.*" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
- private static final String DEFAULT_EXT = "png"; //$NON-NLS-1$
- private static final String DEFAULT_TITLE = "newChart"; //$NON-NLS-1$
- private static final Map<String, Integer> EXTENSION_MAP = new HashMap<>();
-
- private Composite contents = null;
- private String title = null;
-
- static {
- EXTENSION_MAP.put("png", SWT.IMAGE_PNG); //$NON-NLS-1$
- EXTENSION_MAP.put("bmp", SWT.IMAGE_BMP); //$NON-NLS-1$
- EXTENSION_MAP.put("jpeg", SWT.IMAGE_JPEG); //$NON-NLS-1$
- EXTENSION_MAP.put("jpg", SWT.IMAGE_JPEG); //$NON-NLS-1$
- }
-
- public SaveChartAction() {
- super(Messages.ChartConstants_SAVE_CHART_AS, Activator.getImageDescriptor("icons/chart-save.png")); //$NON-NLS-1$
- this.setEnabled(false);
- }
-
- /**
- * Sets the image plugin on the contents and enables the action if contents are not null.
- * Also, a default title for the file to be saved is generated.
- * @param contents The image contents to be saved.
- */
- public void setChart(Composite contents) {
- setChart(contents, null);
- }
-
- /**
- * The same as {@link #setChart(Composite)}, but allows specification of a custom default
- * title for the image file to be saved.
- * @param contents The image contents to be saved.
- * @param title The default title of the image file when it is saved. Set this to <code>null</code>
- * if a title should be generated from the {@link #contents}.
- */
- public void setChart(Composite contents, String title) {
- this.contents = contents;
- if (contents != null) {
- this.title = title != null ? title : getDefaultName();
- setEnabled(true);
- } else {
- setEnabled(false);
- }
- }
-
- private String getDefaultName() {
- if (contents instanceof Chart) {
- return ((Chart) contents).getTitle().getText().replaceAll(" ", "_"); //$NON-NLS-1$ //$NON-NLS-2$
- } else {
- return DEFAULT_TITLE;
- }
- }
-
- /**
- * Open a dialog with which to save the contents at a user-specified path.
- */
- @Override
- public void run() {
- if (problemExists()) {
- return;
- }
- File file = askForAndPrepareFile();
- if (file == null) {
- return; // Cancelled
- }
- generateImageFile(file);
- }
-
- /**
- * Save the previously-set contents as an image without the need for user input.
- * @param path The path to save the image to.
- */
- public void run(String path) {
- if (problemExists()) {
- return;
- }
- File file = new File(makePathWithVerifiedExt(path));
- if (shouldOverwrite(file, null)) {
- generateImageFile(new File(path));
- }
- }
-
- private boolean problemExists() {
- IStatus status = null;
- if (!isEnabled()) {
- status = new Status(IStatus.ERROR, Activator.PLUGIN_ID,
- Messages.ChartConstants_ERROR_CHART_CLOSED);
- } else if (contents.isDisposed()) {
- status = new Status(IStatus.ERROR, Activator.PLUGIN_ID,
- Messages.ChartConstants_ERROR_CHART_DISPOSED);
- }
-
- if (status != null) {
- ErrorDialog.openError(getWorkbenchShell(),
- Messages.ChartConstants_ERROR_SAVING_CHART,
- Messages.ChartConstants_ERROR_SAVING_CHART_MESSAGE, status);
- return true;
- }
- return false;
- }
-
- /**
- * Ask the user for the path to save the file at, and check if this path overwrites any existing file.
- * (Note that using dialog.setOverwrite(true) is insufficient, as the path name may be appended with a
- * file extension after the standard overwrite checks occur.)
- * @return A file with the specified pathname, appended with an appropriate extension.
- */
- private File askForAndPrepareFile() {
- final Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
- final FileDialog dialog = new FileDialog(shell, SWT.SAVE);
- dialog.setFilterExtensions(EXTENSIONS);
- dialog.setText(Messages.ChartConstants_SAVE_CHART_DIALOG_TEXT);
- dialog.setFileName(title);
-
- do {
- String path = dialog.open();
- if (path == null) {
- return null; // Cancelled
- }
-
- path = makePathWithVerifiedExt(path);
-
- File file = new File(path);
- if (shouldOverwrite(file, shell)) {
- return file;
- }
- // If not overwriting, bring up dialog again (loop)
- dialog.setFileName(file.getName());
- } while (true);
- }
-
- private boolean shouldOverwrite(File file, Shell shell) {
- if (!file.exists()) {
- return true;
- }
- if (MessageDialog.openQuestion(shell != null ? shell :
- PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),
- Messages.ChartConstants_CONFIRM_OVERWRITE_TITLE,
- MessageFormat.format(Messages.ChartConstants_CONFIRM_OVERWRITE_MSG, file))) {
- file.delete();
- return true;
- }
- return false;
- }
-
- /**
- * Checks if the provided path has a valid file extension supported by {@link ImageLoader#save(String, int)}.
- * If not, a copy of the path is returned, with its extension replaced with a default one.
- */
- private String makePathWithVerifiedExt(String path) {
- String pathExt = Path.fromOSString(path).getFileExtension();
- if (pathExt == null) {
- return path.concat('.' + DEFAULT_EXT);
- }
- if (EXTENSION_MAP.containsKey(pathExt)) {
- return path;
- }
- return path.replaceAll(pathExt.concat("$"), DEFAULT_EXT); //$NON-NLS-1$
- }
-
- private void generateImageFile(File file) {
- // Extension is chosen based on the file name, not the dialog filter selection.
- int extension = EXTENSION_MAP.get(Path.fromOSString(file.getName()).getFileExtension());
-
- Display dsp = Display.getCurrent();
- GC gc = new GC(contents);
- Image img = new Image(dsp, contents.getSize().x, contents.getSize().y);
- gc.copyArea(img, 0, 0);
- gc.dispose();
- ImageLoader imageLoader = new ImageLoader();
- imageLoader.data = new ImageData[] { img.getImageData() };
- imageLoader.save(file.getAbsolutePath(), extension);
- }
-
- private Shell getWorkbenchShell() {
- return PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
- }
-
-}
diff --git a/profiling/org.eclipse.linuxtools.dataviewers.charts/src/org/eclipse/linuxtools/dataviewers/charts/provider/ChartFactory.java b/profiling/org.eclipse.linuxtools.dataviewers.charts/src/org/eclipse/linuxtools/dataviewers/charts/provider/ChartFactory.java
index 3e7150a..8e7eb90 100755
--- a/profiling/org.eclipse.linuxtools.dataviewers.charts/src/org/eclipse/linuxtools/dataviewers/charts/provider/ChartFactory.java
+++ b/profiling/org.eclipse.linuxtools.dataviewers.charts/src/org/eclipse/linuxtools/dataviewers/charts/provider/ChartFactory.java
@@ -15,21 +15,20 @@
import java.util.List;
import org.eclipse.linuxtools.dataviewers.abstractviewers.ISTDataViewersField;
-import org.eclipse.linuxtools.dataviewers.piechart.PieChart;
import org.eclipse.linuxtools.internal.dataviewers.charts.Activator;
import org.eclipse.linuxtools.internal.dataviewers.charts.view.ChartView;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.widgets.Display;
+import org.eclipse.swtchart.Chart;
+import org.eclipse.swtchart.IAxis;
+import org.eclipse.swtchart.IBarSeries;
+import org.eclipse.swtchart.ISeries.SeriesType;
+import org.eclipse.swtchart.ITitle;
+import org.eclipse.swtchart.LineStyle;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.PartInitException;
import org.eclipse.ui.PlatformUI;
-import org.swtchart.Chart;
-import org.swtchart.IAxis;
-import org.swtchart.IBarSeries;
-import org.swtchart.ISeries.SeriesType;
-import org.swtchart.ITitle;
-import org.swtchart.LineStyle;
/**
* A utility class that handles the charts creation (pie chart and bar chart)
@@ -42,68 +41,6 @@
private ChartFactory() {}
/**
- * Produces a pie chart from the input objects.
- *
- * @param objects
- * the input data
- * @param nameField
- * the field used to get the labels of the objects (colored parts in the pie).
- * @param valFields
- * the field providing the values for the pie parts.
- * @param title Title of the chart.
- * @return a new pie chart
- */
- public static Chart producePieChart(Object[] objects, ISTDataViewersField nameField,
- List<IChartField> valFields, String title) {
-
- ChartView view;
- try {
- final Color WHITE = PlatformUI.getWorkbench().getDisplay().getSystemColor(SWT.COLOR_WHITE);
- final Color BLACK = PlatformUI.getWorkbench().getDisplay().getSystemColor(SWT.COLOR_BLACK);
- final Color GRAD = PlatformUI.getWorkbench().getDisplay().getSystemColor(SWT.COLOR_WIDGET_BACKGROUND);
-
- view = (ChartView) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage()
- .showView(ChartView.VIEW_ID, String.valueOf(ChartView.getSecId()), IWorkbenchPage.VIEW_ACTIVATE);
- PieChart chart = new PieChart(view.getParent(), SWT.NONE);
-
- chart.setBackground(WHITE);
- chart.setBackgroundInPlotArea(GRAD);
-
- chart.getTitle().setText(title);
- chart.getTitle().setForeground(BLACK);
-
- chart.getLegend().setPosition(SWT.RIGHT);
-
- String[] valueLabels = new String[objects.length];
- for (int i = 0; i < objects.length; i++) {
- valueLabels[i] = nameField.getValue(objects[i]);
- }
-
- // pie chart data is grouped by columns
- // row size is the number of pie charts
- // column size is the number of data per pie chart
- double[][] doubleValues = new double[objects.length][valFields.size()];
-
- // data
- for (int i = 0; i < valFields.size(); i++) {
- for (int j = 0; j < objects.length; j++) {
- Number num = valFields.get(i).getNumber(objects[j]);
- double longVal = num.doubleValue();
- doubleValues[j][i] = longVal + 1;
- }
- }
-
- chart.addPieChartSeries(valueLabels, doubleValues);
- chart.getAxisSet().adjustRange();
-
- return chart;
- } catch (PartInitException e) {
- Activator.getDefault().getLog().log(e.getStatus());
- }
- return null;
- }
-
- /**
* Produces a 2D bar chart from the input objects.
*
* @param objects
diff --git a/profiling/org.eclipse.linuxtools.dataviewers.charts/src/org/eclipse/linuxtools/internal/dataviewers/charts/dialogs/ChartDialog.java b/profiling/org.eclipse.linuxtools.dataviewers.charts/src/org/eclipse/linuxtools/internal/dataviewers/charts/dialogs/ChartDialog.java
deleted file mode 100755
index b344d3a..0000000
--- a/profiling/org.eclipse.linuxtools.dataviewers.charts/src/org/eclipse/linuxtools/internal/dataviewers/charts/dialogs/ChartDialog.java
+++ /dev/null
@@ -1,391 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2018 STMicroelectronics and others.
- *
- * This program and the accompanying materials are made
- * available under the terms of the Eclipse Public License 2.0
- * which is available at https://www.eclipse.org/legal/epl-2.0/
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * Marzia Maugeri <marzia.maugeri@st.com> - initial API and implementation
- *******************************************************************************/
-package org.eclipse.linuxtools.internal.dataviewers.charts.dialogs;
-
-import java.util.ArrayList;
-import java.util.LinkedList;
-import java.util.List;
-
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.jface.dialogs.IDialogConstants;
-import org.eclipse.jface.dialogs.IDialogSettings;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.linuxtools.dataviewers.abstractviewers.AbstractSTViewer;
-import org.eclipse.linuxtools.dataviewers.abstractviewers.ISTDataViewersField;
-import org.eclipse.linuxtools.dataviewers.charts.provider.ChartFactory;
-import org.eclipse.linuxtools.dataviewers.charts.provider.IChartField;
-import org.eclipse.linuxtools.internal.dataviewers.charts.Activator;
-import org.eclipse.linuxtools.internal.dataviewers.charts.Messages;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.events.SelectionListener;
-import org.eclipse.swt.layout.FillLayout;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.layout.RowLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Group;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.Text;
-import org.swtchart.Chart;
-
-/**
- * The dialog used to customize the chart before creating it.
- */
-public class ChartDialog extends Dialog {
-
- /** The section name of the viewer's dialog settings where the chart dialog save its state */
- private static final String TAG_SECTION_CHARTS_STATE = "charts_section"; //$NON-NLS-1$
- /**
- * The key used by the column buttons to save their state. For example the button i will use the key
- * <code>TAG_COLUMN_BUTTON_+i</code>
- */
- private static final String TAG_COLUMN_BUTTON_ = "COLUMN_BUTTON_"; //$NON-NLS-1$
- /** The key used by the bar graph button to save its state */
- private static final String TAG_BAR_GRAPH_BUTTON = "BAR_GRAPH_BUTTON"; //$NON-NLS-1$
- /** The key used by the vertical bars button to save its state */
- private static final String TAG_VERTICAL_BARS_BUTTON = "VERTICAL_BARS_BUTTON"; //$NON-NLS-1$
-
- /** The default value of the column buttons */
- private static final boolean DEFAULT_COLUMN_BUTTON = true;
- /** The default value of the bar graph button */
- private static final boolean DEFAULT_BAR_GRAPH_BUTTON = true;
- /** The default value of the vertical bars button */
- private static final boolean DEFAULT_VERTICAL_BARS_BUTTON = false;
-
- private final AbstractSTViewer stViewer;
- private Chart chart;
-
- private Text errorMessageText;
- private Button verticalBarsButton;
- private Button pieChartButton;
- private Button barGraphButton;
- private Button okButton;
- private List<Button> columnButtons;
-
- /**
- * The constructor.
- *
- * @param shell Parent shell.
- * @param stViewer The viewer this dialog fetch data from.
- */
- public ChartDialog(Shell shell, AbstractSTViewer stViewer) {
- super(shell);
- this.stViewer = stViewer;
- }
-
- /**
- * Restores the state of this dialog
- */
- private void restoreState() {
- IDialogSettings settings = stViewer.getViewerSettings().getSection(TAG_SECTION_CHARTS_STATE);
- if (settings == null) {
- stViewer.getViewerSettings().addNewSection(TAG_SECTION_CHARTS_STATE);
- return;
- }
-
- for (int i = 0; i < columnButtons.size(); i++) {
- boolean selected = Boolean.parseBoolean(settings.get(TAG_COLUMN_BUTTON_ + i));
- columnButtons.get(i).setSelection(selected);
- }
-
- boolean barGraph = Boolean.parseBoolean(settings.get(TAG_BAR_GRAPH_BUTTON));
- barGraphButton.setSelection(barGraph);
- pieChartButton.setSelection(!barGraph);
-
- boolean vBars = Boolean.parseBoolean(settings.get(TAG_VERTICAL_BARS_BUTTON));
- verticalBarsButton.setSelection(vBars);
- verticalBarsButton.setEnabled(barGraph);
- }
-
- /**
- * Saves the state of this dialog
- */
- private void saveState() {
- IDialogSettings settings = stViewer.getViewerSettings().getSection(TAG_SECTION_CHARTS_STATE);
- if (settings == null) {
- stViewer.getViewerSettings().addNewSection(TAG_SECTION_CHARTS_STATE);
- }
-
- for (int i = 0; i < columnButtons.size(); i++) {
- boolean selected = columnButtons.get(i).getSelection();
- settings.put(TAG_COLUMN_BUTTON_ + i, selected);
- }
-
- boolean barGraph = barGraphButton.getSelection();
- settings.put(TAG_BAR_GRAPH_BUTTON, barGraph);
-
- boolean vBars = verticalBarsButton.getSelection();
- settings.put(TAG_VERTICAL_BARS_BUTTON, vBars);
- }
-
- @Override
- protected void configureShell(Shell newShell) {
- super.configureShell(newShell);
- newShell.setText(Messages.ChartConstants_CREATE_NEW_CHART_FROM_SELECTION);
- }
-
- @Override
- protected void buttonPressed(int buttonId) {
- if (buttonId == IDialogConstants.OK_ID) {
- chart = produceChart();
- saveState();
- } else {
- chart = null;
- }
- super.buttonPressed(buttonId);
- }
-
- @Override
- protected void createButtonsForButtonBar(Composite parent) {
- // create OK and Cancel buttons by default
- okButton = createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, true);
- createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false);
- }
-
- @Override
- protected Control createContents(Composite parent) {
- Control c = super.createContents(parent);
- this.validateInput();
- return c;
- }
-
- @Override
- protected Control createDialogArea(Composite parent) {
- Composite composite = (Composite) super.createDialogArea(parent);
-
- Composite titleComp = new Composite(composite, SWT.NONE);
- titleComp.setLayout(new RowLayout(SWT.HORIZONTAL));
-
- Label icon = new Label(titleComp, SWT.NONE);
- icon.setImage(Activator.getImage("icons/chart_icon.png")); //$NON-NLS-1$
-
- Label label = new Label(titleComp, SWT.WRAP);
- label.setText(Messages.ChartConstants_CHART_BUILDER);
- GridData data = new GridData(GridData.GRAB_HORIZONTAL | GridData.GRAB_VERTICAL | GridData.HORIZONTAL_ALIGN_FILL
- | GridData.VERTICAL_ALIGN_CENTER);
- data.widthHint = convertHorizontalDLUsToPixels(IDialogConstants.MINIMUM_MESSAGE_AREA_WIDTH);
- titleComp.setLayoutData(data);
-
- Group chartTypeGroup = new Group(composite, SWT.NONE);
- data = new GridData(GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL);
- chartTypeGroup.setLayoutData(data);
- chartTypeGroup.setLayout(new GridLayout(2, false));
- chartTypeGroup.setText(Messages.ChartConstants_SELECT_YOUR_CHART_TYPE);
-
- SelectionListener listener = SelectionListener.widgetSelectedAdapter(e -> validateInput());
-
- barGraphButton = new Button(chartTypeGroup, SWT.RADIO);
- barGraphButton.setText(Messages.ChartConstants_BAR_GRAPH);
- barGraphButton.addSelectionListener(listener);
- barGraphButton.addSelectionListener(SelectionListener
- .widgetSelectedAdapter(e -> verticalBarsButton.setEnabled(barGraphButton.getSelection())));
- data = new GridData();
- barGraphButton.setLayoutData(data);
-
- verticalBarsButton = new Button(chartTypeGroup, SWT.CHECK);
- verticalBarsButton.setText(Messages.ChartConstants_VERTICAL_BARS);
- data = new GridData();
- verticalBarsButton.setLayoutData(data);
-
- pieChartButton = new Button(chartTypeGroup, SWT.RADIO);
- pieChartButton.setText(Messages.ChartConstants_PIE_CHART);
- pieChartButton.addSelectionListener(listener);
- data = new GridData();
- data.horizontalSpan = 2;
- pieChartButton.setLayoutData(data);
-
- Group chartColumnGroup = new Group(composite, SWT.NONE);
- chartColumnGroup.setLayout(new GridLayout(1, true));
- data = new GridData(GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL);
- chartColumnGroup.setLayoutData(data);
- chartColumnGroup.setText(Messages.ChartConstants_SELECT_COLUMNS_TO_SHOW);
-
- addColumnButtons(chartColumnGroup, listener);
-
- errorMessageText = new Text(composite, SWT.READ_ONLY);
- errorMessageText.setLayoutData(new GridData(GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL));
- errorMessageText.setBackground(errorMessageText.getDisplay().getSystemColor(SWT.COLOR_WIDGET_BACKGROUND));
-
- applyDialogFont(composite);
-
- setWidgetsValues();
-
- return composite;
- }
-
- /**
- * Sets the widgets values
- */
- private void setWidgetsValues() {
- // set default values
- barGraphButton.setSelection(DEFAULT_BAR_GRAPH_BUTTON);
- verticalBarsButton.setEnabled(barGraphButton.getSelection());
- verticalBarsButton.setSelection(DEFAULT_VERTICAL_BARS_BUTTON);
- for (Button button : columnButtons) {
- button.setSelection(DEFAULT_COLUMN_BUTTON);
- }
-
- // restore state if there is one saved
- restoreState();
- }
-
- /**
- * Adds one check button for each column implementing the IChartField interface.
- *
- * @see IChartField
- * @param comp
- * @param listener
- */
- private void addColumnButtons(Composite comp, SelectionListener listener) {
- columnButtons = new LinkedList<>();
- for (ISTDataViewersField field : stViewer.getAllFields()) {
- if (field instanceof IChartField) {
- IChartField cField = (IChartField) field;
- Button b = new Button(comp, SWT.CHECK);
- b.setText(cField.getColumnHeaderText());
- b.setData(cField);
- b.addSelectionListener(listener);
- GridData dt = new GridData();
- b.setLayoutData(dt);
- columnButtons.add(b);
- }
- }
-
- Label sep = new Label(comp, SWT.SEPARATOR | SWT.HORIZONTAL);
- GridData data = new GridData(GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL);
- sep.setLayoutData(data);
- Composite buttonComposite = new Composite(comp, SWT.NONE);
- data = new GridData();
- buttonComposite.setLayoutData(data);
- FillLayout l = new FillLayout();
- l.spacing = 5;
- buttonComposite.setLayout(l);
-
- final Button b1 = new Button(buttonComposite, SWT.PUSH);
- b1.setText(Messages.ChartConstants_SELECT_ALL);
- final Button b2 = new Button(buttonComposite, SWT.PUSH);
- b2.setText(Messages.ChartConstants_DESELECT_ALL);
- SelectionListener sl = new SelectionListener() {
- @Override
- public void widgetDefaultSelected(SelectionEvent e) {
- widgetSelected(e);
- }
-
- @Override
- public void widgetSelected(SelectionEvent e) {
- boolean b = (e.getSource() == b1);
- for (Button button : columnButtons) {
- button.setSelection(b);
- }
- validateInput();
- }
- };
- b1.addSelectionListener(sl);
- b2.addSelectionListener(sl);
- }
-
- /**
- * Returns the Chart built by this dialog
- *
- * @return the chart
- */
- public Chart getValue() {
- return chart;
- }
-
- /**
- * Validates the input.
- * <p>
- * The default implementation of this framework method delegates the request to the supplied input validator object;
- * if it finds the input invalid, the error message is displayed in the dialog's message line. This hook method is
- * called whenever the text changes in the input field.
- * </p>
- */
- private void validateInput() {
- String errorMessage = null;
-
- int selectedNum = 0;
- for (Button button : columnButtons) {
- if (button.getSelection())
- selectedNum++;
- }
-
- if (selectedNum == 0) {
- errorMessage = Messages.ChartConstants_NO_COLUMN_SELECTED;
- }
- /*
- * else if (pieChartButton.getSelection() && selectedNum != 1) { errorMessage =
- * "PieChart: Please select only one column"; }
- */
-
- // Bug 16256: important not to treat "" (blank error) the same as null
- // (no error)
- setErrorMessage(errorMessage);
- }
-
- /**
- * Sets or clears the error message. If not <code>null</code>, the OK button is disabled.
- *
- * @param errorMessage
- * the error message, or <code>null</code> to clear
- * @since 3.0
- */
- private void setErrorMessage(String errorMessage) {
- errorMessageText.setText(errorMessage == null ? "" : errorMessage); //$NON-NLS-1$
- okButton.setEnabled(errorMessage == null);
- errorMessageText.getParent().update();
- }
-
- /**
- * Build the chart from configuration
- *
- * @return a new chart
- */
- private Chart produceChart() {
- IStructuredSelection selection = stViewer.getViewer().getStructuredSelection();
- if (selection == StructuredSelection.EMPTY)
- return null;
- Object[] objects = selection.toArray();
-
- ISTDataViewersField labelField = getLabelField(stViewer);
-
- List<IChartField> selectedFields = new ArrayList<>();
- for (Button button : columnButtons) {
- if (button.getSelection()) {
- selectedFields.add((IChartField) button.getData());
- }
- }
- boolean barChartType = barGraphButton.getSelection();
- boolean horizontalBars = !verticalBarsButton.getSelection();
-
- if (barChartType) {
- return ChartFactory
- .produceBarChart(objects, labelField, selectedFields, Messages.ChartConstants_BAR_GRAPH, horizontalBars);
- } else {
- return ChartFactory.producePieChart(objects, labelField, selectedFields, Messages.ChartConstants_PIE_CHART);
- }
- }
-
- /**
- * @param viewer
- * @return the field used to provide the labels to the series
- */
- private ISTDataViewersField getLabelField(AbstractSTViewer viewer) {
- return viewer.getAllFields()[0];
- }
-}
\ No newline at end of file
diff --git a/profiling/org.eclipse.linuxtools.dataviewers.charts/src/org/eclipse/linuxtools/internal/dataviewers/charts/view/ChartView.java b/profiling/org.eclipse.linuxtools.dataviewers.charts/src/org/eclipse/linuxtools/internal/dataviewers/charts/view/ChartView.java
index 2bd45f9..29c5578 100755
--- a/profiling/org.eclipse.linuxtools.dataviewers.charts/src/org/eclipse/linuxtools/internal/dataviewers/charts/view/ChartView.java
+++ b/profiling/org.eclipse.linuxtools.dataviewers.charts/src/org/eclipse/linuxtools/internal/dataviewers/charts/view/ChartView.java
@@ -1,6 +1,6 @@
/*******************************************************************************
* Copyright (c) 2009, 2018 STMicroelectronics and others.
- *
+ *
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
* which is available at https://www.eclipse.org/legal/epl-2.0/
@@ -15,16 +15,12 @@
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
-import org.eclipse.jface.action.IToolBarManager;
-import org.eclipse.linuxtools.dataviewers.charts.actions.SaveChartAction;
import org.eclipse.linuxtools.internal.dataviewers.charts.Activator;
import org.eclipse.swt.widgets.Composite;
-import org.eclipse.ui.IActionBars;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.PartInitException;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.part.ViewPart;
-import org.swtchart.Chart;
/**
* The chart view.
@@ -47,34 +43,6 @@
private Composite parent;
- private SaveChartAction saveChartAction;
-
- /**
- * Create and open a new chart view <br/>
- * <br/>
- * <u><b>Note</b></u>: this method uses the UI thread to open the view and then it sets the input chart. The UI
- * thread execution is synchronized on internal Integer SEC_ID which is the secondary id of the chart view. Each new
- * chart view has a secondary id equal to SEC_ID++.
- *
- * @param chart The chart to create view for.
- */
- public static void createChartView(final Chart chart) {
- PlatformUI.getWorkbench().getDisplay().syncExec(() -> {
- try {
- synchronized (lock) {
- ChartView view = (ChartView) PlatformUI.getWorkbench().getActiveWorkbenchWindow()
- .getActivePage().showView(VIEW_ID, String.valueOf(SEC_ID++), IWorkbenchPage.VIEW_ACTIVATE);
- view.setChart(chart);
-
- }
- } catch (PartInitException e) {
- Status s = new Status(IStatus.ERROR, Activator.PLUGIN_ID, IStatus.ERROR, e.getMessage(), e);
- Activator.getDefault().getLog().log(s);
- }
- });
-
- }
-
/**
* Create and open a new chart view <br/>
* <br/>
@@ -102,18 +70,6 @@
@Override
public void createPartControl(Composite parent) {
this.parent = parent;
- createActions();
- IActionBars actionBars = getViewSite().getActionBars();
- initToolBar(actionBars.getToolBarManager());
- }
-
- private void createActions() {
- saveChartAction = new SaveChartAction();
- }
-
- protected void initToolBar(IToolBarManager manager) {
- manager.add(saveChartAction);
- manager.update(true);
}
@Override
@@ -123,15 +79,6 @@
}
}
- /**
- * Set the chart in this view
- *
- * @param chart
- */
- private void setChart(Chart chart) {
- saveChartAction.setChart(chart);
- }
-
public Composite getParent() {
return parent;
}
diff --git a/profiling/org.eclipse.linuxtools.dataviewers.piechart/META-INF/MANIFEST.MF b/profiling/org.eclipse.linuxtools.dataviewers.piechart/META-INF/MANIFEST.MF
index 583b93d..4e0a804 100644
--- a/profiling/org.eclipse.linuxtools.dataviewers.piechart/META-INF/MANIFEST.MF
+++ b/profiling/org.eclipse.linuxtools.dataviewers.piechart/META-INF/MANIFEST.MF
@@ -2,11 +2,10 @@
Bundle-ManifestVersion: 2
Bundle-Name: %bundleName
Bundle-SymbolicName: org.eclipse.linuxtools.dataviewers.piechart
-Bundle-Version: 2.0.1.qualifier
+Bundle-Version: 3.0.0.qualifier
Bundle-Vendor: %bundleProvider
Bundle-Localization: plugin
Require-Bundle: org.eclipse.ui,
- org.swtchart,
org.eclipse.swtchart
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Bundle-ActivationPolicy: lazy
diff --git a/profiling/org.eclipse.linuxtools.dataviewers.piechart/pom.xml b/profiling/org.eclipse.linuxtools.dataviewers.piechart/pom.xml
index 65656f2..639af36 100644
--- a/profiling/org.eclipse.linuxtools.dataviewers.piechart/pom.xml
+++ b/profiling/org.eclipse.linuxtools.dataviewers.piechart/pom.xml
@@ -19,7 +19,7 @@
</parent>
<artifactId>org.eclipse.linuxtools.dataviewers.piechart</artifactId>
- <version>2.0.1-SNAPSHOT</version>
+ <version>3.0.0-SNAPSHOT</version>
<packaging>eclipse-plugin</packaging>
<name>Linux Tools PieChart plug-in</name>
diff --git a/profiling/org.eclipse.linuxtools.dataviewers.piechart/src/org/eclipse/linuxtools/dataviewers/piechart/PieChart.java b/profiling/org.eclipse.linuxtools.dataviewers.piechart/src/org/eclipse/linuxtools/dataviewers/piechart/PieChart.java
deleted file mode 100644
index 061023e..0000000
--- a/profiling/org.eclipse.linuxtools.dataviewers.piechart/src/org/eclipse/linuxtools/dataviewers/piechart/PieChart.java
+++ /dev/null
@@ -1,172 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2012, 2018 IBM Corporation and others.
- *
- * This program and the accompanying materials are made
- * available under the terms of the Eclipse Public License 2.0
- * which is available at https://www.eclipse.org/legal/epl-2.0/
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * IBM Corporation - Renato Stoffalette Joao <rsjoao@br.ibm.com>
- *******************************************************************************/
-package org.eclipse.linuxtools.dataviewers.piechart;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.swt.events.PaintListener;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.RGB;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.swtchart.Chart;
-import org.swtchart.IAxis;
-import org.swtchart.IBarSeries;
-import org.swtchart.ISeries;
-import org.swtchart.ITitle;
-
-/**
- * @deprecated To be contributed to Eclipse.org SWTChart and removed in Linux Tools major release once in swtchart proper.
- *
- * @see <a href="https://github.com/eclipse/swtchart/issues/114">https://github.com/eclipse/swtchart/issues/114</a>
- */
-@Deprecated
-public class PieChart extends Chart {
-
- protected List<RGB> colorList = new ArrayList<>();
- private Color[] customColors = null;
- private PieChartPaintListener pieChartPaintListener;
-
- public PieChart(Composite parent, int style) {
- super(parent, style);
- // Hide all original axes and plot area
- for (IAxis axis : getAxisSet().getAxes()) {
- axis.getTitle().setVisible(false);
- }
- getPlotArea().setVisible(false);
- // Make the title draw after the pie-chart itself so we can modify the title
- // to center over the pie-chart area
- ITitle title = getTitle();
- // Underlying SWT Chart implementation changes from the title being a Control to just
- // a PaintListener. In the Control class case, we can move it's location to
- // center over a PieChart, but in the latter case, we need to alter the title
- // with blanks in the PieChartPaintListener and have the title paint after it
- // once the title has been altered.
- if (title instanceof Control) {
- addPaintListener(pieChartPaintListener = new PieChartPaintListener(this));
- } else {
- removePaintListener((PaintListener)title);
- addPaintListener(pieChartPaintListener = new PieChartPaintListener(this));
- addPaintListener((PaintListener)title);
- }
- IAxis xAxis = getAxisSet().getXAxis(0);
- xAxis.enableCategory(true);
- xAxis.setCategorySeries(new String[]{""}); //$NON-NLS-1$
- }
-
- @Override
- public void addPaintListener(PaintListener listener) {
- if (!listener.getClass().getName().startsWith("org.swtchart.internal.axis")) { //$NON-NLS-1$
- super.addPaintListener(listener);
- }
- }
-
- /**
- * Sets the custom colors to use.
- * @param customColors The custom colors to use.
- * @since 2.0
- */
- public void setCustomColors(Color[] customColors) {
- this.customColors = customColors.clone();
- }
-
- /**
- * Add data to this Pie Chart. We'll build one pie chart for each value in the array provided. The val matrix must
- * have an array of an array of values. Ex. labels = {'a', 'b'} val = {{1,2,3}, {4,5,6}} This will create 3 pie
- * charts. For the first one, 'a' will be 1 and 'b' will be 4. For the second chart 'a' will be 2 and 'b' will be 5.
- * For the third 'a' will be 3 and 'b' will be 6.
- * @param labels The titles of each series. (These are not the same as titles given to pies.)
- * @param val New values.
- */
- public void addPieChartSeries(String labels[], double val[][]) {
- setSeriesNames(val[0].length);
- for (ISeries s : this.getSeriesSet().getSeries()) {
- this.getSeriesSet().deleteSeries(s.getId());
- }
-
- int size = Math.min(labels.length, val.length);
- for (int i = 0; i < size; i++) {
- IBarSeries s = (IBarSeries) this.getSeriesSet().createSeries(ISeries.SeriesType.BAR, labels[i]);
- double d[] = new double[val[i].length];
- for (int j = 0; j < val[i].length; j++) {
- d[j] = val[i][j];
- }
- s.setXSeries(d);
- if (customColors != null) {
- s.setBarColor(customColors[i % customColors.length]);
- } else {
- s.setBarColor(new Color(this.getDisplay(), sliceColor(i)));
- }
- }
- }
-
- /**
- * Sets this chart's category names such that the number of names
- * is equal to the number of pies. This method will only make changes
- * to category series if they are not already properly set.
- * @param numExpected The number of pies / the expected number of category names.
- */
- private void setSeriesNames(int numExpected) {
- IAxis xAxis = getAxisSet().getXAxis(0);
- if (xAxis.getCategorySeries().length != numExpected) {
- String[] seriesNames = new String[numExpected];
- for (int i = 0, n = Math.min(xAxis.getCategorySeries().length, numExpected); i < n; i++) {
- seriesNames[i] = xAxis.getCategorySeries()[i];
- }
- for (int i = xAxis.getCategorySeries().length; i < numExpected; i++) {
- seriesNames[i] = ""; //$NON-NLS-1$
- }
- xAxis.setCategorySeries(seriesNames);
- }
- }
-
- protected RGB sliceColor(int i) {
- if (colorList.size() > i) {
- return colorList.get(i);
- }
-
- RGB next = IColorsConstants.COLORS[i % IColorsConstants.COLORS.length];
- colorList.add(next);
- return next;
- }
-
- /**
- * Given a set of 2D pixel coordinates (typically those of a mouse cursor), return the
- * index of the given pie's slice that those coordinates reside in.
- * @param pieIndex The index of the pie to get the slice of.
- * @param x The x-coordinate to test.
- * @param y The y-coordinate to test.
- * @return The slice that contains the point with coordinates (x,y).
- * @since 2.0
- */
- public int getSliceIndexFromPosition(int pieIndex, int x, int y) {
- return pieChartPaintListener.getSliceIndexFromPosition(pieIndex, x, y);
- }
-
- /**
- * Given a pie and one of its slices, returns the size of the slice as a percentage of the pie.
- * @param pieIndex The index of the pie to check.
- * @param sliceIndex The slice of the pie to get the percentage of.
- * @return The percentage of the entire pie taken up by the slice.
- * @since 2.0
- */
- public double getSlicePercent(int pieIndex, int sliceIndex) {
- double max = 0;
- ISeries series[] = getSeriesSet().getSeries();
- for (int i = 0; i < series.length; i++) {
- max += series[i].getXSeries()[pieIndex];
- }
- return series[sliceIndex].getXSeries()[pieIndex] / max * 100;
- }
-}
diff --git a/profiling/org.eclipse.linuxtools.dataviewers.piechart/src/org/eclipse/linuxtools/dataviewers/piechart/PieChartPaintListener.java b/profiling/org.eclipse.linuxtools.dataviewers.piechart/src/org/eclipse/linuxtools/dataviewers/piechart/PieChartPaintListener.java
deleted file mode 100644
index 4cf3976..0000000
--- a/profiling/org.eclipse.linuxtools.dataviewers.piechart/src/org/eclipse/linuxtools/dataviewers/piechart/PieChartPaintListener.java
+++ /dev/null
@@ -1,272 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2012, 2018 IBM Corporation and others.
- *
- * This program and the accompanying materials are made
- * available under the terms of the Eclipse Public License 2.0
- * which is available at https://www.eclipse.org/legal/epl-2.0/
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * IBM Corporation - Renato Stoffalette Joao <rsjoao@br.ibm.com>
- *******************************************************************************/
-package org.eclipse.linuxtools.dataviewers.piechart;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.PaintEvent;
-import org.eclipse.swt.events.PaintListener;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.Font;
-import org.eclipse.swt.graphics.GC;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.graphics.Rectangle;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Display;
-import org.swtchart.IBarSeries;
-import org.swtchart.ISeries;
-import org.swtchart.ITitle;
-import org.swtchart.Range;
-
-/**
- * @deprecated To be contributed to Eclipse.org SWTChart and removed in Linux Tools major release once in swtchart proper.
- *
- * @see <a href="https://github.com/eclipse/swtchart/issues/114">https://github.com/eclipse/swtchart/issues/114</a>
- */
-@Deprecated
-public class PieChartPaintListener implements PaintListener {
-
- private PieChart chart;
- private Control plotArea;
- private double[][] seriesValues;
- private String[] seriesNames;
- private static final int X_GAP = 10;
-
- private static final Color WHITE = Display.getDefault().getSystemColor(SWT.COLOR_WHITE);
- private static final Color BLACK = Display.getDefault().getSystemColor(SWT.COLOR_BLACK);
- private static final String FONT = "Arial"; //$NON-NLS-1$
-
- private Point[] pieCenters;
- private int[][] pieSliceAngles;
- private int pieWidth;
-
- private String origTitleText;
-
- /**
- * Handles drawing and updating of a PieChart, with titles given to its legend and
- * to each of its pies. Pies will be drawn in the given chart's plot area.
- * @param chart The PieChart to draw and update.
- * @since 2.0
- */
- public PieChartPaintListener(PieChart chart) {
- this.chart = chart;
- this.plotArea = chart.getPlotArea();
- }
-
- @Override
- public void paintControl(PaintEvent e) {
- GC gc = e.gc;
- Rectangle bounds;
- this.getPieSeriesArray();
- pieCenters = new Point[seriesValues.length];
- pieSliceAngles = new int[seriesValues.length][];
- if (seriesValues.length == 0) {
- bounds = gc.getClipping();
- Font oldFont = gc.getFont();
- Font font = new Font(Display.getDefault(), FONT, 15, SWT.BOLD);
- gc.setForeground(BLACK);
- gc.setFont(font);
- String text = "No data"; //$NON-NLS-1$
- Point textSize = e.gc.textExtent(text);
- gc.drawText(text, (bounds.width - textSize.x) / 2, (bounds.height - textSize.y) / 2);
- gc.setFont(oldFont);
- font.dispose();
- return;
- }
- bounds = plotArea.getBounds();
- // Adjust the title so it centers in the plot area
- if (origTitleText == null) {
- origTitleText = chart.getTitle().getText();
- }
-
- // We want to center the title in the plot area rather than the entire view which includes
- // the legend. To force this, we have two algorithms depending on what level of the
- // underlying SWT Chart software we are using. If the title is an SWT Control, we simply
- // set the title's location manually. If the title is just a PaintListener, we center it
- // by adding a number of trailing spaces which we calculate.
- if (chart.getTitle() instanceof Control) {
- setTitleBounds(bounds);
- } else {
- adjustTitle(e);
- }
- int width = bounds.width / seriesValues.length;
- int x = bounds.x;
-
- if (chart.getLegend().isVisible()) {
- Rectangle legendBounds = ((Control) chart.getLegend()).getBounds();
- Font oldFont = gc.getFont();
- Font font = new Font(Display.getDefault(), FONT, 10, SWT.BOLD);
- gc.setForeground(BLACK);
- gc.setFont(font);
- String text = chart.getAxisSet().getXAxis(0).getTitle().getText();
- Point textSize = e.gc.textExtent(text);
- gc.drawText(text, legendBounds.x + (legendBounds.width - textSize.x) / 2, legendBounds.y - textSize.y);
- gc.setFont(oldFont);
- font.dispose();
- }
-
- pieWidth = Math.min(width - X_GAP, bounds.height);
- for (int i = 0; i < seriesValues.length; i++) {
- drawPieChart(e, i, new Rectangle(x, bounds.y, width, bounds.height));
- x += width;
- }
- }
-
- // For a title which is a Control, position it appropriately to center in the plot area.
- private void setTitleBounds(Rectangle bounds) {
- Control title = (Control) chart.getTitle();
- Rectangle titleBounds = title.getBounds();
- title.setLocation(new Point(bounds.x + (bounds.width - titleBounds.width) / 2, title.getLocation().y));
- }
-
- // Adjust the title with trailing blanks so it centers in the plot area
- // rather than for the entire chart view which looks odd when not
- // centered above the pie-charts themselves.
- private void adjustTitle(PaintEvent pe) {
- ITitle title = chart.getTitle();
- Font font = title.getFont();
- Font oldFont = pe.gc.getFont();
- pe.gc.setFont(font);
- Control legend = (Control)chart.getLegend();
- Rectangle legendBounds = legend.getBounds();
- int adjustment = legendBounds.width - 15;
- Point blankSize = pe.gc.textExtent(" "); //$NON-NLS-1$
- int numBlanks = ((adjustment / blankSize.x) >> 1) << 1;
- String text = origTitleText;
- for (int i = 0; i < numBlanks; ++i)
- text += " "; //$NON-NLS-1$
- pe.gc.setFont(oldFont);
- title.setText(text);
- }
-
- private void drawPieChart(PaintEvent e, int chartnum, Rectangle bounds) {
- double series[] = seriesValues[chartnum];
- int nelemSeries = series.length;
- double sumTotal = 0;
-
- pieSliceAngles[chartnum] = new int[nelemSeries - 1]; // Don't need first angle; it's always 0
- for (int i = 0; i < nelemSeries; i++) {
- sumTotal += series[i];
- }
-
- GC gc = e.gc;
- Font oldFont = gc.getFont();
- gc.setLineWidth(1);
-
- int pieX = bounds.x + (bounds.width - pieWidth) / 2;
- int pieY = bounds.y + (bounds.height - pieWidth) / 2;
- pieCenters[chartnum] = new Point(pieX + pieWidth / 2, pieY + pieWidth / 2);
- if (sumTotal == 0) {
- gc.drawOval(pieX, pieY, pieWidth, pieWidth);
- } else {
- double factor = 100 / sumTotal;
- int sweepAngle = 0;
- int incrementAngle = 0;
- int initialAngle = 90;
- for (int i = 0; i < nelemSeries; i++) {
- // Stored angles increase in clockwise direction from 0 degrees at 12:00
- if (i > 0) {
- pieSliceAngles[chartnum][i - 1] = 90 - initialAngle;
- }
-
- gc.setBackground(((IBarSeries) chart.getSeriesSet().getSeries()[i]).getBarColor());
-
- if (i == (nelemSeries - 1)) {
- sweepAngle = 360 - incrementAngle;
- } else {
- double angle = series[i] * factor * 3.6;
- sweepAngle = (int) Math.round(angle);
- }
- gc.fillArc(pieX, pieY, pieWidth, pieWidth, initialAngle, (-sweepAngle));
- gc.drawArc(pieX, pieY, pieWidth, pieWidth, initialAngle, (-sweepAngle));
- incrementAngle += sweepAngle;
- initialAngle += (-sweepAngle);
- }
- gc.drawLine(pieCenters[chartnum].x, pieCenters[chartnum].y, pieCenters[chartnum].x, pieCenters[chartnum].y - pieWidth / 2);
- }
-
- Font font = new Font(Display.getDefault(), FONT, 12, SWT.BOLD);
- gc.setForeground(BLACK);
- gc.setBackground(WHITE);
- gc.setFont(font);
- String text = seriesNames[chartnum];
- Point textSize = e.gc.textExtent(text);
- gc.drawText(text, pieX + (pieWidth - textSize.x) / 2, pieY + pieWidth + textSize.y);
- gc.setFont(oldFont);
- font.dispose();
- }
-
- private void getPieSeriesArray() {
- ISeries series[] = this.chart.getSeriesSet().getSeries();
- if (series == null || series.length == 0) {
- seriesValues = new double[0][0];
- seriesNames = new String[0];
- return;
- }
- String names[] = this.chart.getAxisSet().getXAxis(0).getCategorySeries();
- Range range = chart.getAxisSet().getXAxis(0).getRange();
- int itemRange = (int) range.upper - (int) range.lower + 1;
- int itemOffset = (int) range.lower;
- seriesValues = new double[itemRange][series.length];
- seriesNames = new String[itemRange];
-
- for (int i = 0; i < seriesValues.length; i++) {
- seriesNames[i] = names[i + itemOffset];
- for (int j = 0; j < seriesValues[i].length; j++) {
- double d[] = series[j].getXSeries();
- if (d != null && d.length > 0) {
- seriesValues[i][j] = d[i + itemOffset];
- } else {
- seriesValues[i][j] = 0;
- }
- }
- }
-
- return;
- }
-
- /**
- * Given a set of 2D pixel coordinates (typically those of a mouse cursor), return the
- * index of the given pie's slice that those coordinates reside in.
- * @param chartnum The id of the chart.
- * @param x The x-coordinate to test.
- * @param y The y-coordinate to test.
- * @return The slice that contains the point with coordinates (x,y).
- * @since 2.0
- */
- public int getSliceIndexFromPosition(int chartnum, int x, int y) {
- Range range = chart.getAxisSet().getXAxis(0).getRange();
- chartnum -= (int) range.lower;
- if (chartnum >= pieCenters.length || chartnum < 0) {
- return -1;
- }
- // Only continue if the point is inside the pie circle
- double rad = Math.sqrt(Math.pow(pieCenters[chartnum].x - x, 2) + Math.pow(pieCenters[chartnum].y - y, 2));
- if (2 * rad > pieWidth) {
- return -1;
- }
- // Angle is relative to 12:00 position, increases clockwise
- double angle = Math.acos((pieCenters[chartnum].y - y) / rad) / Math.PI * 180.0;
- if (x - pieCenters[chartnum].x < 0) {
- angle = 360 - angle;
- }
- if (pieSliceAngles[chartnum].length == 0 || angle < pieSliceAngles[chartnum][0]) {
- return 0;
- }
- for (int s = 0; s < pieSliceAngles[chartnum].length - 1; s++) {
- if (pieSliceAngles[chartnum][s] <= angle && angle < pieSliceAngles[chartnum][s+1]) {
- return s + 1;
- }
- }
- return pieSliceAngles[chartnum].length;
- }
-}
diff --git a/releng/org.eclipse.linuxtools.releng-site/category.xml b/releng/org.eclipse.linuxtools.releng-site/category.xml
index 0891415..a8b8f89 100644
--- a/releng/org.eclipse.linuxtools.releng-site/category.xml
+++ b/releng/org.eclipse.linuxtools.releng-site/category.xml
@@ -71,9 +71,6 @@
<iu id="org.eclipse.swtchart.extensions" version="0.0.0">
<category name="Linux Tools"/>
</iu>
- <iu id="org.swtchart" version="0.0.0">
- <category name="Linux Tools"/>
- </iu>
<iu id="org.cyberneko.html" version="0.0.0">
<category name="Linux Tools"/>
</iu>
diff --git a/releng/org.eclipse.linuxtools.target/linuxtools-e4.16.target b/releng/org.eclipse.linuxtools.target/linuxtools-e4.16.target
index a9a76e2..425b89e 100644
--- a/releng/org.eclipse.linuxtools.target/linuxtools-e4.16.target
+++ b/releng/org.eclipse.linuxtools.target/linuxtools-e4.16.target
@@ -55,7 +55,6 @@
<unit id="org.objectweb.asm.tree" version="8.0.1.v20200420-1007"/>
<unit id="org.objectweb.asm.util" version="8.0.1.v20200420-1007"/>
<unit id="org.slf4j.api" version="1.7.30.v20200204-2150"/>
-<unit id="org.swtchart" version="0.10.0.v201605200358"/>
<repository location="https://download.eclipse.org/tools/orbit/S-builds/S20200526004052/repository"/>
</location>
<location includeAllPlatforms="false" includeConfigurePhase="false" includeMode="planner" includeSource="true" type="InstallableUnit">
diff --git a/systemtap/org.eclipse.linuxtools.systemtap.graphing.ui/plugin.xml b/systemtap/org.eclipse.linuxtools.systemtap.graphing.ui/plugin.xml
index dbffe79..4a62c22 100644
--- a/systemtap/org.eclipse.linuxtools.systemtap.graphing.ui/plugin.xml
+++ b/systemtap/org.eclipse.linuxtools.systemtap.graphing.ui/plugin.xml
@@ -26,43 +26,6 @@
</extension>
<extension
- point="org.eclipse.ui.commands">
- <category
- name="%category.file.name"
- description="%category.file.desc"
- id="org.eclipse.linuxtools.systemtap.graphing.ui.category.file"/>
- <command
- name="%command.save.name"
- description="%command.save.desc"
- categoryId="org.eclipse.linuxtools.systemtap.graphing.ui.category.file"
- id="org.eclipse.linuxtools.systemtap.graphing.ui.commands.SaveGraphImage"/>
- </extension>
-
- <extension
- point="org.eclipse.ui.menus">
- <menuContribution
- locationURI="toolbar:org.eclipse.linuxtools.systemtap.ui.ide.toolbar?after=chartGroup">
- <command
- commandId="org.eclipse.linuxtools.systemtap.graphing.ui.commands.SaveGraphImage"
- label="%command.save.name"
- icon="icons/actions/chart-save.png">
- <visibleWhen checkEnabled="true"/>
- </command>
- </menuContribution>
- </extension>
-
- <extension
- point="org.eclipse.ui.handlers">
- <handler
- class="org.eclipse.linuxtools.internal.systemtap.graphing.ui.handlers.SaveGraphImageHandler"
- commandId="org.eclipse.linuxtools.systemtap.graphing.ui.commands.SaveGraphImage">
- <activeWhen>
- <reference definitionId="org.eclipse.linuxtools.systemtap.graphing.ui.graphEditorEnablement"/>
- </activeWhen>
- </handler>
- </extension>
-
- <extension
point="org.eclipse.ui.editors">
<editor
class="org.eclipse.linuxtools.systemtap.graphing.ui.views.GraphSelectorEditor"
diff --git a/systemtap/org.eclipse.linuxtools.systemtap.graphing.ui/src/org/eclipse/linuxtools/internal/systemtap/graphing/ui/handlers/SaveGraphImageHandler.java b/systemtap/org.eclipse.linuxtools.systemtap.graphing.ui/src/org/eclipse/linuxtools/internal/systemtap/graphing/ui/handlers/SaveGraphImageHandler.java
deleted file mode 100644
index 10dac2f..0000000
--- a/systemtap/org.eclipse.linuxtools.systemtap.graphing.ui/src/org/eclipse/linuxtools/internal/systemtap/graphing/ui/handlers/SaveGraphImageHandler.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2014, 2019 Red Hat, Inc.
- *
- * This program and the accompanying materials are made
- * available under the terms of the Eclipse Public License 2.0
- * which is available at https://www.eclipse.org/legal/epl-2.0/
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * IBM Corporation - initial API and Action implementation
- * Red Hat - conversion to Handler implementation
- *******************************************************************************/
-
-package org.eclipse.linuxtools.internal.systemtap.graphing.ui.handlers;
-
-import org.eclipse.core.commands.AbstractHandler;
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.linuxtools.dataviewers.charts.actions.SaveChartAction;
-import org.eclipse.linuxtools.systemtap.graphing.ui.GraphDisplaySet;
-import org.eclipse.linuxtools.systemtap.graphing.ui.charts.AbstractChartBuilder;
-import org.eclipse.linuxtools.systemtap.graphing.ui.views.GraphSelectorEditor;
-import org.eclipse.swtchart.Chart;
-import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.PlatformUI;
-
-/**
- * This action is designed to allow for saving of the graph in the active window.
- * It will let the user select the location to save the image, and then save it as
- * a jpg image.
- * @author Ryan Morse
- * @since 3.0 Migrated from .ui.graphing package.
- */
-public class SaveGraphImageHandler extends AbstractHandler {
-
- private SaveChartAction saveChartAction = new SaveChartAction();
-
- /**
- * This is the main method of the action. It handles getting the active graph,
- * prompting the user for a location to save the image to, and then actually doing
- * the save.
- */
- @Override
- public Object execute(ExecutionEvent event) {
- saveChartAction.setChart(getActiveChart());
- saveChartAction.run();
- return null;
- }
-
- private GraphSelectorEditor getActiveGraphEditor() {
- IEditorPart editor = PlatformUI.getWorkbench().getActiveWorkbenchWindow().
- getActivePage().getActiveEditor();
- return editor instanceof GraphSelectorEditor ? (GraphSelectorEditor) editor : null;
- }
-
- private AbstractChartBuilder getActiveGraph() {
- GraphSelectorEditor graphEditor = getActiveGraphEditor();
- if (graphEditor == null) {
- return null;
- }
- GraphDisplaySet gds = graphEditor.getActiveDisplaySet();
- return gds == null ? null : gds.getActiveGraph();
- }
-
- private Chart getActiveChart() {
- AbstractChartBuilder abs = getActiveGraph();
- return abs == null ? null : abs.getChart();
- }
-
-}