当前位置: 首页>>代码示例>>Java>>正文


Java NextChartUtil类代码示例

本文整理汇总了Java中ro.nextreports.engine.util.NextChartUtil的典型用法代码示例。如果您正苦于以下问题:Java NextChartUtil类的具体用法?Java NextChartUtil怎么用?Java NextChartUtil使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


NextChartUtil类属于ro.nextreports.engine.util包,在下文中一共展示了NextChartUtil类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: loadDemoChart

import ro.nextreports.engine.util.NextChartUtil; //导入依赖的package包/类
public static Chart loadDemoChart() throws FileNotFoundException {
	String location = NEXTREPORTS_HOME + File.separator + "output" +
            File.separator + def.getDatabaseName() + File.separator + "Charts";
	
    String file = location + File.separator + def.getChartName();
    return NextChartUtil.loadChart(new FileInputStream(file));     
}
 
开发者ID:nextreports,项目名称:nextreports-engine,代码行数:8,代码来源:DemoUtil.java

示例2: downloadChart

import ro.nextreports.engine.util.NextChartUtil; //导入依赖的package包/类
public static void downloadChart(String chartPath, WebServiceClient client, UIActivator activator)
		throws Exception {
	ChartMetaData chartMetaData = client.getChart(chartPath);
	XStream xstream = XStreamFactory.createXStream();
	Chart chart = (Chart) xstream.fromXML(new String(chartMetaData.getMainFile().getFileContent(), "UTF-8"));

	byte status = NextChartUtil.isValidChartVersion(chart);
	if (NextChartUtil.CHART_INVALID_NEWER == status) {
		Show.error(I18NSupport.getString("chart.version.invalid.newer", ReleaseInfoAdapter.getVersionNumber()));
		return;
	}

	// save the chart
	String existingPath = Globals.getCurrentChartAbsolutePath();

	String chartAbsolutePath = chartMetaData.getPath();
	chartAbsolutePath = chartAbsolutePath.replaceFirst("/charts", "");
	String chartName = null;
	try {
		chartName = chartAbsolutePath.substring(chartAbsolutePath.lastIndexOf("/") + 1);
		chartAbsolutePath = chartAbsolutePath.substring(0, chartAbsolutePath.lastIndexOf("/"));
	} catch (Exception e) {
		chartName = chartAbsolutePath.substring(chartAbsolutePath.lastIndexOf("\\"));
		chartAbsolutePath = chartAbsolutePath.substring(0, chartAbsolutePath.lastIndexOf("/"));
	}

	File chartsGlobalFolderPathFile = new File(FileReportPersistence.getChartsRelativePath());
	if (!chartsGlobalFolderPathFile.exists()) {
		chartsGlobalFolderPathFile.mkdirs();
	}

	chartAbsolutePath = FileReportPersistence.getChartsRelativePath() + File.separator + chartAbsolutePath;
	File chartFolderPath = new File(chartAbsolutePath);

	String name = null;
	// if the path exists ask for a new name for the
	// report
	if (!chartFolderPath.exists()) {
		chartFolderPath.mkdirs();
	}

	File chartFullPathFile = new File(chartFolderPath.getAbsolutePath() + File.separator + chartName
			+ (chartName.endsWith(ChartUtil.CHART_EXTENSION) ? ""
					: ChartUtil.CHART_EXTENSION_SEPARATOR + ChartUtil.CHART_EXTENSION));
	// report name usually contains .report in it, charts it does not

	if (!chartFullPathFile.exists()) {
		Globals.setCurrentChartAbsolutePath(chartFolderPath.getAbsolutePath() + File.separator + chartName
				+ ChartUtil.CHART_EXTENSION_SEPARATOR + ChartUtil.CHART_EXTENSION);
		chart.setName(chartName + ChartUtil.CHART_EXTENSION_SEPARATOR + ChartUtil.CHART_EXTENSION);
		name = ChartUtil.saveChart(I18NSupport.getString("save.chart"), false, chart);
	} else {
		chart.setName(chartName);
		name = ChartUtil.saveChart(I18NSupport.getString("save.chart"), true, chart);
	}

	if (name != null) {
		String path = Globals.getCurrentChartAbsolutePath();
		Globals.getMainFrame().getQueryBuilderPanel().addChart(name, path);
		Globals.getReportUndoManager().discardAllEdits();
	}
	Globals.setCurrentChartAbsolutePath(existingPath);

	if (activator != null) {
		activator.updateProgress();
	}
}
 
开发者ID:nextreports,项目名称:nextreports-designer,代码行数:68,代码来源:DownloadHelper.java

示例3: actionPerformed

import ro.nextreports.engine.util.NextChartUtil; //导入依赖的package包/类
public void actionPerformed(ActionEvent e) {

        if (!LicenseUtil.allowToAddAnotherReport()) {
            return;
        }

        DataSourceManager manager = DefaultDataSourceManager.getInstance();
        DataSource ds = manager.getConnectedDataSource();
        if(ds == null) {
            Show.info(I18NSupport.getString("no.data.source.connected"));
            return;
        }
        String name = FileReportPersistence.getChartsRelativePath();
        File destFolder;
        if (destinationPath == null) {
            destFolder = new File(name);
        } else {
            destFolder = new File(destinationPath);
        }

        JFileChooser fc = new JFileChooser();
        fc.setDialogTitle(I18NSupport.getString("import.chart.title", ds.getName()));
        fc.setAcceptAllFileFilterUsed(false);
        fc.addChoosableFileFilter(new ChartFilter());
        String importPath = ReporterPreferencesManager.getInstance().loadParameter(ReporterPreferencesManager.NEXT_REPORT_IMPORT_PATH);
        if (importPath == null) {
            importPath = FileReportPersistence.CONNECTIONS_DIR;
        }
        fc.setCurrentDirectory(new File(importPath));
        int returnVal = fc.showSaveDialog(Globals.getMainFrame());
        if (returnVal == JFileChooser.APPROVE_OPTION) {
            File f = fc.getSelectedFile();
            if (f != null) {
                try {
                    byte status = NextChartUtil.isValidChartVersion(f.getAbsolutePath());
                    if (NextChartUtil.CHART_INVALID_NEWER == status) {
                        Show.error(I18NSupport.getString("chart.version.invalid.newer", ReleaseInfoAdapter.getVersionNumber()));
                        return;
                    }
                    File destFile = new File(destFolder.getAbsolutePath() + File.separator + f.getName());
                    boolean copy= false;
                    if (destFile.exists()) {
                        int option = JOptionPane.showConfirmDialog(Globals.getMainFrame(), I18NSupport.getString("import.chart.exists", f.getName()), "", JOptionPane.YES_NO_OPTION);
                        if (option == JOptionPane.YES_OPTION) {
                            copy = true;
                        }
                    } else {
                        copy = true;
                    }
                    if (copy) {
                        FileUtil.copyToDir(f, destFolder, true);
                        TreeUtil.refreshCharts();
                        ReporterPreferencesManager.getInstance().storeParameter(
                            ReporterPreferencesManager.NEXT_REPORT_IMPORT_PATH ,f.getParentFile().getAbsolutePath());
                        Show.info(I18NSupport.getString("import.chart.success"));
                    }
                } catch (Exception ex) {
                    Show.error(ex);
                }
            }
        }

    }
 
开发者ID:nextreports,项目名称:nextreports-designer,代码行数:64,代码来源:ImportChartAction.java

示例4: getChart

import ro.nextreports.engine.util.NextChartUtil; //导入依赖的package包/类
public static Chart getChart(ChartContent chartContent) {
    byte[] bytes = chartContent.getChartFile().getDataProvider().getBytes();
    return NextChartUtil.loadChart(new ByteArrayInputStream(bytes));
}
 
开发者ID:nextreports,项目名称:nextreports-server,代码行数:5,代码来源:NextUtil.java


注:本文中的ro.nextreports.engine.util.NextChartUtil类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。