List of usage examples for javax.swing JFileChooser getAccessory
public JComponent getAccessory()
From source file:Main.java
public static void main(String[] argv) throws Exception { JFileChooser chooser = new JFileChooser(); File f = new File(new File(".").getCanonicalPath()); chooser.setCurrentDirectory(f);//from w w w. j a v a 2 s. c om chooser.setCurrentDirectory(null); chooser.showOpenDialog(null); JComponent obj = chooser.getAccessory(); }
From source file:at.tuwien.ifs.somtoolbox.apps.viewer.fileutils.ExportUtils.java
public static void saveMapPaneAsImage(Container container, JFileChooser fileChooser, GenericPNodeScrollPane mapPane, String title) { JFileChooser fc = ExportUtils.getFileChooser(container, fileChooser, new JCheckBox("Crop", true)); int returnVal = fc.showDialog(container, title); File filePath = null;//from w ww . j a va2 s. c om if (returnVal == JFileChooser.APPROVE_OPTION) { filePath = fc.getSelectedFile(); } if (filePath != null) { try { ExportUtils.saveMapPaneAsImage(mapPane, filePath.getAbsolutePath(), ((JCheckBox) fc.getAccessory()).isSelected()); JOptionPane.showMessageDialog(container, "Export to file finished!"); } catch (SOMToolboxException ex) { ex.printStackTrace(); JOptionPane.showMessageDialog(container, ex.getMessage(), "Error saving", JOptionPane.ERROR_MESSAGE); } } }
From source file:com.mgmtp.perfload.loadprofiles.ui.AppFrame.java
/** * Exports the events file for perfLoad tests. This method is registered on the {@link EventBus} * and called when the specified event is posted. * /*from w ww . j av a 2s .co m*/ * @param e * the event that triggers calling of this method when posted on the event bus */ @Subscribe public void exportEventListForPerfLoad(final ToolsExportEventListAction.Event e) throws IOException { if (checkLoadProfileEntityDirty() && checkLoadProfilePropertiesDirty()) { File dir = loadProfileEventsFile != null ? loadProfileEventsFile : loadProfileConfigFile.getParentFile(); JFileChooser fc = SwingUtils.createFileChooser(dir, "Load Profile BaseLoadProfileEvent Files (*.perfload)", "perfload"); fc.setAccessory(new SaveAccessoryPanel()); if (loadProfileEventsFile == null) { loadProfileEventsFile = new File( FilenameUtils.removeExtension(loadProfileConfigFile.getAbsolutePath()) + ".perfload"); } File file = showSaveDialog(fc, loadProfileEventsFile, "perfload"); if (file != null) { loadProfileEventsFile = file; LoadProfileConfig lpc = createLoadProfileConfig(); LoadTestConfiguration ltc = loadProfilesController.createLoadTestConfiguration(lpc, getSelectedTargets(), getSelectedClients()); List<LoadCurveAssignment> loadCurveAssignments = ltc.getLoadCurveAssignments(); Set<Operation> operations = newHashSet(); int caCount = loadCurveAssignments.size(); double maxTime = 0; // max time for histogram creation List<LoadCurve> loadCurves = newArrayListWithCapacity(caCount); for (LoadCurveAssignment loadCurveAssignment : loadCurveAssignments) { LoadCurve loadCurve = loadCurveAssignment.getLoadCurve(); loadCurves.add(loadCurve); operations.add(loadCurveAssignment.getOperation()); double[] timeValues = loadCurve.getTimeValues(); maxTime = max(maxTime, timeValues[timeValues.length - 1]); } EventDistributor.addScaledLoadCurvesToAssignments(ltc, loadCurves); List<LoadEvent> clientEventList = EventDistributor.createClientEventList(ltc); List<BaseLoadProfileEvent> events = newArrayListWithExpectedSize(clientEventList.size()); // One time and marker events are added separately for (OneTime oneTime : getOneTimes()) { double startTimeInHours = oneTime.t0 / 60d; // We must add one event per target for (Target target : oneTime.targets) { LoadEvent event = new LoadEvent(startTimeInHours, oneTime.getOperation()); event.setProcessId(0); // 1 added later to make it zero-based event.setDaemonId(1); event.setTarget(target); clientEventList.add(event); } } events.addAll(clientEventList); for (Marker marker : getMarkers()) { double time = marker.left / 60d; MarkerEvent event = new MarkerEvent(marker.name, time, MarkerEvent.Type.left); events.add(event); time = marker.right / 60d; event = new MarkerEvent(marker.name, time, MarkerEvent.Type.right); events.add(event); } Collections.sort(events, new LoadEventComparator()); StrBuilder sb = new StrBuilder(); sb.appendln("# Created: " + new Date()); sb.appendln("# Load Profile Config File: " + loadProfileConfigFile.getName()); sb.append("# Load Profile Name: " + txtName.getText()); EventDistributor.writeEventListForPerfLoadClientsToFile(file, sb.toString(), events); // Create additional histogram file if selected dir = file.getParentFile(); final String baseName = FilenameUtils.getBaseName(file.getName()); int numClients = ltc.getClients().size(); SaveAccessoryPanel sap = (SaveAccessoryPanel) fc.getAccessory(); Collection<LoadEvent> loadEvents = transform(filter(clientEventList, new IsLoadEventPredicate()), new EventToLoadEventFunction()); if (sap.isEventDistriChecked()) { for (int i = 0; i < numClients; ++i) { for (LoadCurve loadCurve : loadCurves) { File f = new File(dir, baseName + "-event-distri-client-" + i + "-" + loadCurve.getName() + ".csv"); PlotFileCreator.createPlot(f, loadEvents, loadCurve, i, LoadCurveCalculator.timeUnit_minute); } } } if (sap.isOperationHistogramChecked()) { for (Operation operation : operations) { String opName = operation.getName(); File f = new File(dir, baseName + "-histogram-operation-" + opName + ".csv"); PlotFileCreator.createOperationHistogram(f, loadEvents, opName, (int) maxTime * 2, 0., maxTime, LoadCurveCalculator.timeUnit_minute); } } if (sap.isClientLoadHistrogramChecked()) { for (int i = 0; i < numClients; i++) { File f = new File(dir, baseName + "-histogram-client-load-" + i + ".csv"); PlotFileCreator.createClientHistogram(f, loadEvents, i, (int) maxTime * 2, 0., maxTime, LoadCurveCalculator.timeUnit_minute); } } } } }