public QueryEditorResultsExporter(TableModel model) {

    super(GUIUtilities.getParentFrame(), "Export Query Results", true);
    this.model = model;
    init();

    pack();
    this.setLocation(GUIUtilities.getLocationForDialog(this.getSize()));
    setVisible(true);
  }
示例#2
0
 /**
  * Executes the cut command on the <code>TextEditor</code>.
  *
  * @param the originating event
  */
 public void execute(ActionEvent e) {
   TextEditor textFunction = GUIUtilities.getTextEditorInFocus();
   if (textFunction != null) {
     textFunction.cut();
   }
   textFunction = null;
 }
  private Object handleError(Throwable e) {

    String message = "Error writing to file:\n\n" + e.getMessage();
    GUIUtilities.displayExceptionErrorDialog(message, e);

    return "failed";
  }
  public void browse(ActionEvent e) {

    FileChooserDialog fileChooser = new FileChooserDialog();
    fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
    fileChooser.setMultiSelectionEnabled(false);

    fileChooser.setDialogTitle("Select Export File Path");
    fileChooser.setDialogType(JFileChooser.OPEN_DIALOG);

    int result = fileChooser.showDialog(GUIUtilities.getInFocusDialogOrWindow(), "Select");
    if (result == JFileChooser.CANCEL_OPTION) {

      return;
    }

    String suffix = null;
    File file = fileChooser.getSelectedFile();
    String path = file.getAbsolutePath();

    int exportFormatType = getExportFormatType();
    if (exportFormatType == ImportExportProcess.EXCEL) {

      suffix = ".xls";

    } else if (exportFormatType == ImportExportProcess.XML) {

      suffix = ".xml";
    }

    path = appendToPath(path, suffix);
    fileNameField.setText(path);
  }
  public boolean usesJavaSplitPane() {

    LookAndFeelType lookAndFeelType = GUIUtilities.getLookAndFeel();
    return lookAndFeelType == LookAndFeelType.PLUGIN
        || lookAndFeelType == LookAndFeelType.NATIVE
        || lookAndFeelType == LookAndFeelType.GTK;
  }
  public void export(ActionEvent e) {
    String value = fileNameField.getText();
    if (MiscUtils.isNull(value)) {
      GUIUtilities.displayErrorMessage("You must specify a file to export to.");
      return;
    }

    // check if it exists
    if (FileUtils.fileExists(value)) {
      int confirm = GUIUtilities.displayConfirmCancelDialog("Overwrite existing file?");
      if (confirm == JOptionPane.CANCEL_OPTION) {
        return;
      } else if (confirm == JOptionPane.NO_OPTION) {
        fileNameField.selectAll();
        fileNameField.requestFocus();
        return;
      }
    }

    if (getExportFormatType() == ImportExportProcess.DELIMITED
        && delimCombo.getSelectedIndex() == 4) {

      value = customDelimField.getText();
      if (MiscUtils.isNull(value)) {

        GUIUtilities.displayErrorMessage("You must enter a custom delimeter");
        return;
      }
    }

    SwingWorker worker =
        new SwingWorker() {
          public Object construct() {

            return doExport();
          }

          public void finished() {

            GUIUtilities.displayInformationMessage("Result set export complete.");
            dispose();
          }
        };
    worker.start();
  }
  public void reset(ActionEvent e) {

    String message = "Are you sure you want to reset the system activity log?";
    if (GUIUtilities.displayConfirmDialog(message) == JOptionPane.YES_OPTION) {

      LogRepository logRepository =
          (LogRepository) RepositoryCache.load(LogRepository.REPOSITORY_ID);
      logRepository.reset(LogRepository.ACTIVITY);
      clear(e);
    }
  }
  private ResultsProgressDialog progressDialog(int rowCount) {

    ResultsProgressDialog progressDialog;
    progressDialog = new ResultsProgressDialog(rowCount);
    setVisible(false);
    progressDialog.pack();

    progressDialog.setLocation(GUIUtilities.getLocationForDialog(progressDialog.getSize()));
    progressDialog.setVisible(true);

    return progressDialog;
  }
    public ResultsProgressDialog(int recordCount) {
      super(GUIUtilities.getParentFrame(), "Exporting Query Results", false);
      progressBar = new JProgressBar(JProgressBar.HORIZONTAL, 0, recordCount);

      JPanel base = new JPanel(new GridBagLayout());
      GridBagConstraints gbc = new GridBagConstraints();

      gbc.insets = new Insets(5, 5, 5, 5);
      gbc.anchor = GridBagConstraints.NORTHWEST;
      gbc.fill = GridBagConstraints.HORIZONTAL;
      base.add(new JLabel("Exporting result set..."), gbc);
      gbc.gridy = 1;
      gbc.weightx = 1.0;
      gbc.weighty = 1.0;
      gbc.insets.top = 0;
      gbc.ipadx = 180;
      gbc.insets.bottom = 10;
      gbc.fill = GridBagConstraints.BOTH;
      base.add(progressBar, gbc);

      base.setBorder(BorderFactory.createEtchedBorder());
      Container c = this.getContentPane();
      c.setLayout(new GridBagLayout());
      c.add(
          base,
          new GridBagConstraints(
              1,
              1,
              1,
              1,
              1.0,
              1.0,
              GridBagConstraints.SOUTHEAST,
              GridBagConstraints.BOTH,
              new Insets(5, 5, 5, 5),
              0,
              0));

      setResizable(false);
      setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
    }