@Override
  public Object execute(ExecutionEvent event) throws ExecutionException {
    IWorkbenchWindow workbenchWindow = HandlerUtil.getActiveWorkbenchWindowChecked(event);
    FileDialog dialog = new FileDialog(workbenchWindow.getShell(), SWT.OPEN);
    dialog.setFilterExtensions(new String[] {"*.xlsx", "*.xls"});
    dialog.setText("Select the Excel file to upload");
    final String filePath = dialog.open();
    final String fileName = dialog.getFileName();

    if (filePath != null) {
      ImportWindow importWindow = new ImportWindow();
      String importMode = importWindow.open();

      if (importMode != null) {
        MenuCommand cmd =
            new MenuCommand() {
              @Override
              public void execute(IProject project, IFile file) throws Exception {
                importExcelAndGenerateFiles(project, filePath, fileName, importMode);
              }
            };
        MenuCommandWindow window =
            new MenuCommandWindow(workbenchWindow.getShell(), cmd, true, null);
        window.open();
      }
    }
    return null;
  }
  public OutputStream getOutputStream(Shell shell) {
    FileDialog dialog = new FileDialog(shell, SWT.SAVE);

    String filterPath;
    String relativeFileName;

    int lastIndexOfFileSeparator = defaultFileName.lastIndexOf(File.separator);
    if (lastIndexOfFileSeparator >= 0) {
      filterPath = defaultFileName.substring(0, lastIndexOfFileSeparator);
      relativeFileName = defaultFileName.substring(lastIndexOfFileSeparator + 1);
    } else {
      filterPath = "/"; // $NON-NLS-1$
      relativeFileName = defaultFileName;
    }

    dialog.setFilterPath(filterPath);
    dialog.setOverwrite(true);

    dialog.setFileName(relativeFileName);
    dialog.setFilterNames(defaultFilterNames);
    dialog.setFilterExtensions(defaultFilterExtensions);
    String fileName = dialog.open();
    if (fileName == null) {
      return null;
    }

    try {
      return new PrintStream(fileName);
    } catch (FileNotFoundException e) {
      e.printStackTrace();
      return null;
    }
  }
 public void selectOutputFile() {
   FileDialog dlg = new FileDialog(getParentShell(), SWT.SAVE);
   ArrayList<String> extensionList = new ArrayList<String>();
   if (chosenOutputFormat != null && chosenOutputFormat.getFileSuffix() != null) {
     extensionList.add("*." + chosenOutputFormat.getFileSuffix()); // $NON-NLS-1$
   }
   extensionList.add("*.*"); // $NON-NLS-1$
   dlg.setFilterExtensions(extensionList.toArray(new String[extensionList.size()]));
   dlg.setFileName(getDefaultOutputFilename());
   dlg.setOverwrite(true);
   String path;
   if (isFilePath()) {
     path = getOldFolderPath();
   } else {
     path = defaultFolder;
   }
   if (LOG.isDebugEnabled()) {
     LOG.debug("File dialog path set to: " + path); // $NON-NLS-1$
   }
   dlg.setFilterPath(path);
   String fn = dlg.open();
   if (fn != null) {
     textFile.setText(fn);
     getButton(IDialogConstants.OK_ID).setEnabled(true);
   }
 }
 /**
  * Allows user to select file and loads it as a model.
  *
  * @generated
  */
 public static Resource openModel(
     Shell shell, String description, TransactionalEditingDomain editingDomain) {
   FileDialog fileDialog = new FileDialog(shell, SWT.OPEN);
   if (description != null) {
     fileDialog.setText(description);
   }
   fileDialog.open();
   String fileName = fileDialog.getFileName();
   if (fileName == null || fileName.length() == 0) {
     return null;
   }
   if (fileDialog.getFilterPath() != null) {
     fileName = fileDialog.getFilterPath() + File.separator + fileName;
   }
   URI uri = URI.createFileURI(fileName);
   Resource resource = null;
   try {
     resource = editingDomain.getResourceSet().getResource(uri, true);
   } catch (WrappedException we) {
     RoxgtDiagramEditorPlugin.getInstance()
         .logError("Unable to load resource: " + uri, we); // $NON-NLS-1$
     MessageDialog.openError(
         shell,
         Messages.RoxgtDiagramEditorUtil_OpenModelResourceErrorDialogTitle,
         NLS.bind(Messages.RoxgtDiagramEditorUtil_OpenModelResourceErrorDialogMessage, fileName));
   }
   return resource;
 }
  public void run(IAction action) {

    FileDialog fileDialog = new FileDialog(Display.getDefault().getActiveShell(), SWT.SAVE);
    fileDialog.setFilterPath(fileDirectory);
    fileDialog.setFilterNames(filterName);
    fileDialog.setFilterExtensions(filterExtension);

    if (action.isChecked()) {
      String filename = fileDialog.open();
      // check if file Exists. Gaelle 16/03/2009

      if (filename != null && recordInThisFile(filename)) {

        FableJep.record(true);
        try {
          FableJep.getFableJep().setScriptFileName(filename);
        } catch (Throwable e) {
          e.printStackTrace();
        }
        // action.setText("Stop Recording Script");
        action.setToolTipText("Stop recording python actions.");
      } else {
        action.setChecked(false);
        FableJep.record(false);
        // action.setText("Record Script");
        action.setToolTipText("Record python actions in a script.");
      }
    } else {
      FableJep.record(false);
      // action.setText("Record Script");
      action.setToolTipText("Record python actions in a script.");
    }
  }
Example #6
0
  private boolean saveAs() {

    FileDialog saveDialog = new FileDialog(shell, SWT.SAVE);
    saveDialog.setFilterExtensions(new String[] {"*.adr;", "*.*"});
    saveDialog.setFilterNames(new String[] {"Address Books (*.adr)", "All Files "});

    saveDialog.open();
    String name = saveDialog.getFileName();

    if (name.equals("")) return false;

    if (name.indexOf(".adr") != name.length() - 4) {
      name += ".adr";
    }

    File file = new File(saveDialog.getFilterPath(), name);
    if (file.exists()) {
      MessageBox box = new MessageBox(shell, SWT.ICON_WARNING | SWT.YES | SWT.NO);
      box.setText(resAddressBook.getString("Save_as_title"));
      box.setMessage(
          resAddressBook.getString("File")
              + file.getName()
              + " "
              + resAddressBook.getString("Query_overwrite"));
      if (box.open() != SWT.YES) {
        return false;
      }
    }
    this.file = file;
    return save();
  }
Example #7
0
  public void save_Event() {
    FileDialog fd = new FileDialog(ZestDebuggerView.this.getSite().getShell(), SWT.SAVE);
    fd.setText("Save");
    fd.setFilterPath("C:/");
    String[] filterExt = {"*.jpg"};
    fd.setFilterExtensions(filterExt);
    String selected = fd.open();
    System.out.println(selected);

    if (selected != null) {
      GC gc = new GC(viewer.getControl());
      org.eclipse.swt.graphics.Rectangle bounds = viewer.getControl().getBounds();

      Image image = new Image(viewer.getControl().getDisplay(), bounds);
      try {
        gc.copyArea(image, 0, 0);
        ImageLoader imageLoader = new ImageLoader();
        imageLoader.data = new ImageData[] {image.getImageData()};
        imageLoader.save(selected, SWT.IMAGE_JPEG);
        MessageDialog.openInformation(
            ZestDebuggerView.this.getSite().getShell(),
            "Success",
            "The image has been saved successfully");
      } catch (Exception e) {
        e.printStackTrace();
        MessageDialog.openError(
            ZestDebuggerView.this.getSite().getShell(), "Failure", "The image can't be saved");
      } finally {
        image.dispose();
        gc.dispose();
      }
    }
  }
 private void performImport() {
   FileDialog dialog = new FileDialog(this.fDialog.getShell(), SWT.OPEN);
   dialog.setText("Export environment variables to file");
   String file = dialog.open();
   if (file != null) {
     File handle = new File(file);
     if (!handle.exists()) {
       String text = "Selected file not exists.";
       showErrorMessage("Environment import", text);
       return;
     }
     EnvironmentVariable[] vars = null;
     try {
       vars = EnvironmentVariablesFileUtils.load(file);
     } catch (Exception e) {
       showErrorMessage("Environment import", e.getMessage());
     }
     if (vars != null) {
       EnvironmentVariable[] variables = this.fEnvironmentVariablesContentProvider.getVariables();
       Set nvars = new HashSet();
       nvars.addAll(Arrays.asList(vars));
       nvars.addAll(Arrays.asList(variables));
       this.fEnvironmentVariablesContentProvider.setVariables(
           (EnvironmentVariable[]) nvars.toArray(new EnvironmentVariable[nvars.size()]));
     }
   }
 }
  @Override
  /**
   * When the 'export to XML' button is clicked, this method is called. It creates a new {@link
   * FileDialog}, in which the user can find the location to save the XML file to and enter its
   * name, followed by the .xml extension. If the user completes these steps, the method will export
   * the current configuration to an XML file.
   */
  public void mouseUp(MouseEvent m) {
    FileDialog fd = new FileDialog(((Button) m.getSource()).getShell(), SWT.SAVE);
    fd.setText("Export configuration");
    String[] ext = new String[1];
    ext[0] = "*.xml";
    fd.setFilterExtensions(ext);

    String selected = fd.open();
    if (selected != null) {
      try {
        GUIBridge.synchronizeModulesFrontToBack();
        new ExportModuleConfiguration().exportModuleConfiguration(selected);
      } catch (Exception e) {
        // TODO proper visual errors
        e.printStackTrace();
      }
    }
  }
  @Override
  public Object execute(ExecutionEvent event) throws ExecutionException {
    IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindow(event);
    IWorkbenchPage page = window.getActivePage();
    View view = (View) page.findView(View.ID);
    view.getViewer().refresh();

    // open dialog to get path
    FileDialog filedlg = new FileDialog(window.getShell(), SWT.SAVE);
    filedlg.setText("Create Sequence Diagram File");
    filedlg.setFilterPath("SystemRoot");
    filedlg.setFilterExtensions(new String[] {"di"});
    String selected = filedlg.open();

    // create & initial the sequence diagram
    MyCreater myCreater = new MyCreater();
    myCreater.init(window.getWorkbench(), new StructuredSelection()); // fixed bug
    IFile iFile = myCreater.create(selected);

    // create the model
    SequenceDiagram sdDiagram = new SequenceDiagram();
    sdDiagram.setiFile(iFile);
    sdDiagram.setFilePath(
        new Path(selected).removeFileExtension().addFileExtension("uml").toOSString());
    ModelManager.getInstance().AddModel(sdDiagram);

    // open the editor
    myCreater.open(iFile);

    // refresh the model viewer
    view.getViewer().refresh();

    return null;
  }
Example #11
0
 public void save(boolean forcenew) {
   String filename = "";
   if ((m_filename.length() == 0) || forcenew) {
     FileDialog dialog = new FileDialog(new Shell(), SWT.SAVE);
     if (dialog.open() == null) {
       return;
     }
     filename = dialog.getFilterPath() + "/" + dialog.getFileName();
   } else {
     filename = m_filename;
   }
   FileOutputStream fileoutputstream;
   try {
     fileoutputstream = new FileOutputStream(filename);
     writeToStream(fileoutputstream);
     m_filename = filename;
     Element element = new Element("com.metaaps.eoclipse.workflow.filename");
     element.setAttribute("filename", m_filename);
     Util.setConfiguration(element, "filename");
   } catch (FileNotFoundException e) {
     e.printStackTrace();
     Util.errorMessage("Could not access file");
   } catch (IOException e) {
     e.printStackTrace();
     Util.errorMessage("Could not save file");
   }
 }
  public void get() {
    try {

      // As the user for a file to use as a reference
      //
      FileDialog dialog = new FileDialog(shell, SWT.OPEN);
      dialog.setFilterExtensions(new String[] {"*.sas7bdat;*.SAS7BDAT", "*.*"});
      dialog.setFilterNames(
          new String[] {
            BaseMessages.getString(PKG, "SASInputDialog.FileType.SAS7BAT")
                + ", "
                + BaseMessages.getString(PKG, "System.FileType.TextFiles"),
            BaseMessages.getString(PKG, "System.FileType.CSVFiles"),
            BaseMessages.getString(PKG, "System.FileType.TextFiles"),
            BaseMessages.getString(PKG, "System.FileType.AllFiles")
          });
      if (dialog.open() != null) {
        String filename =
            dialog.getFilterPath() + System.getProperty("file.separator") + dialog.getFileName();
        SasInputHelper helper = new SasInputHelper(filename);
        BaseStepDialog.getFieldsFromPrevious(
            helper.getRowMeta(), wFields, 1, new int[] {1}, new int[] {3}, 4, 5, null);
      }

    } catch (Exception e) {
      new ErrorDialog(shell, "Error", "Error reading information from file", e);
    }
  }
Example #13
0
  /** Export the selected values from the table to a csv file */
  private void export() {

    FileDialog dialog = new FileDialog(shell, SWT.SAVE);
    String[] filterNames = new String[] {"CSV Files", "All Files (*)"};
    String[] filterExtensions = new String[] {"*.csv;", "*"};
    String filterPath = "/";
    String platform = SWT.getPlatform();
    if (platform.equals("win32") || platform.equals("wpf")) {
      filterNames = new String[] {"CSV Files", "All Files (*.*)"};
      filterExtensions = new String[] {"*.csv", "*.*"};
      filterPath = "c:\\";
    }
    dialog.setFilterNames(filterNames);
    dialog.setFilterExtensions(filterExtensions);
    dialog.setFilterPath(filterPath);
    try {
      dialog.setFileName(this.getCurrentKey() + ".csv");
    } catch (Exception e) {
      dialog.setFileName("export.csv");
    }
    String fileName = dialog.open();

    FileOutputStream fos;
    OutputStreamWriter out;
    try {
      fos = new FileOutputStream(fileName);
      out = new OutputStreamWriter(fos, "UTF-8");
    } catch (Exception e) {
      MessageBox messageBox = new MessageBox(shell, SWT.OK | SWT.ICON_ERROR);
      messageBox.setMessage("Error creating export file " + fileName + " : " + e.getMessage());
      messageBox.open();
      return;
    }

    Vector<TableItem> sel = new Vector<TableItem>(this.dataTable.getSelection().length);

    sel.addAll(Arrays.asList(this.dataTable.getSelection()));
    Collections.reverse(sel);

    for (TableItem item : sel) {
      String date = item.getText(0);
      String value = item.getText(1);
      try {
        out.write(date + ";" + value + "\n");
      } catch (IOException e) {
        continue;
      }
    }

    try {
      out.close();
      fos.close();
    } catch (IOException e) {
      MessageBox messageBox = new MessageBox(shell, SWT.OK | SWT.ICON_ERROR);
      messageBox.setMessage("Error writing export file " + fileName + " : " + e.getMessage());
      messageBox.open();
      e.printStackTrace();
    }
  }
Example #14
0
 void openFile() {
   if (fileDialog == null) {
     fileDialog = new org.eclipse.swt.widgets.FileDialog(shell, SWT.OPEN);
   }
   fileDialog.setFilterExtensions(new java.lang.String[] {"*.java", "*.*"});
   java.lang.String name = fileDialog.open();
   open(name);
 }
 private String browseForSourceFile(String[] extensions) {
   FileDialog dialog = new FileDialog(getShell(), SWT.OPEN);
   String wkspRoot = ResourcesPlugin.getWorkspace().getRoot().getLocation().toString();
   dialog.setFileName(wkspRoot);
   dialog.setFilterExtensions(extensions);
   String result = dialog.open();
   return result;
 }
Example #16
0
 public void widgetSelected(SelectionEvent e) {
   FileDialog dialog = new FileDialog(getShell(), SWT.OPEN);
   dialog.setFileName(fileText.getText());
   String text = dialog.open();
   if (text != null) {
     fileText.setText(text);
   }
 }
Example #17
0
 public void run() {
   FileDialog dialog =
       new FileDialog(
           GenerationGraph.getInstance().getMainView().getSite().getWorkbenchWindow().getShell(),
           SWT.OPEN);
   String fileName = dialog.open();
   GenerationGraph.getInstance().getMainView().loadGraph(fileName);
 }
Example #18
0
 private File getFile() {
   FileDialog fileDialog = new FileDialog(textArea.getShell(), SWT.SAVE);
   String path = fileDialog.open();
   if (path == null || path.length() < 1) {
     return null;
   }
   return new File(path);
 }
 private static String saveAs(Shell parent) {
   FileDialog fd = new FileDialog(parent, SWT.SAVE);
   fd.setText(Messages.Screenshots_SaveAsDialog);
   String[] filterExt = {"*" + EXTENSION}; // $NON-NLS-1$
   fd.setFilterExtensions(filterExt);
   fd.setFileName(getDefaultFilename());
   return fd.open();
 }
  public String askUserForOutputFilename() {
    Shell shell = UiPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getShell();
    FileDialog dlg = new FileDialog(shell, SWT.SAVE);
    dlg.setFilterExtensions(new String[] {"*.txt", "*.*"}); // $NON-NLS-1$ //$NON-NLS-2$
    dlg.setText(UiConstants.Util.getString(EXPORT_SQL_DIALOG_TITLE));
    dlg.setFileName(UiConstants.Util.getString(EXPORT_DEFAULT_FILENAME));

    return dlg.open();
  }
 private void browseButtonSelected(String title, Text text) {
   FileDialog dialog = new FileDialog(getShell(), SWT.NONE);
   dialog.setText(title);
   String str = text.getText().trim();
   int lastSeparatorIndex = str.lastIndexOf(File.separator);
   if (lastSeparatorIndex != -1) dialog.setFilterPath(str.substring(0, lastSeparatorIndex));
   str = dialog.open();
   if (str != null) text.setText(str);
 }
 private void browseForFile(Text fileField, String dialogTitle) {
   FileDialog fileDialog = new FileDialog(getShell(), SWT.OPEN);
   fileDialog.setText(dialogTitle);
   String filePath = fileDialog.open();
   if (filePath != null) {
     fileField.setText(filePath);
     broadcastChanges();
   }
 }
 private void handleTruststoreBrowse() {
   FileDialog fileDialog = new FileDialog(getShell(), SWT.OPEN);
   fileDialog.setFilterPath(getTruststore());
   final String filepath = fileDialog.open();
   if (filepath != null) {
     txtTruststore.setText(filepath);
     dialogChanged();
   }
 }
 /** @generated */
 public void run(IAction action) {
   FileDialog fileDialog = new FileDialog(getWindow().getShell(), SWT.OPEN);
   fileDialog.open();
   if (fileDialog.getFileName() != null && fileDialog.getFileName().length() > 0) {
     openEditor(
         getWindow().getWorkbench(),
         URI.createFileURI(
             fileDialog.getFilterPath() + File.separator + fileDialog.getFileName()));
   }
 }
 protected String getImportFile(ExecutionEvent event) throws ExecutionException {
   final IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindowChecked(event);
   final FileDialog fileDialog = new FileDialog(window.getShell(), SWT.OPEN);
   fileDialog.setFilterExtensions(
       new String[] {
         "*.csv",
       });
   final String importFileName = fileDialog.open();
   return importFileName;
 }
Example #26
0
 /**
  * Opens a modal dialogue to select a file from the file system. If the file selection is
  * cancelled, null is returned.
  *
  * @return the file, or null at dialogue cancel
  */
 protected File openFileSelectionDialogue() {
   FileDialog fd = new FileDialog(btnDatei.getShell(), SWT.OPEN);
   fd.setText(Messages.TranspTextWizardPage_windowsfiledialogtitle);
   fd.setFilterPath(null);
   String[] filterExt = {"*.*"}; // $NON-NLS-1$
   fd.setFilterExtensions(filterExt);
   String selected = fd.open();
   if (selected == null) return null;
   return new File(selected);
 }
Example #27
0
 public void addManifestation() {
   final FileDialog fileDialog = new FileDialog(getSite().getShell(), SWT.OPEN);
   fileDialog.setFilterExtensions(new String[] {"*.xml;*.raid", "*.raid"});
   fileDialog.setFilterNames(
       new String[] {"Fichiers chronosRAID (*.xml,*.raid)", "Projet ChronosRAID (*.raid)"});
   final String fileName = fileDialog.open();
   if (fileName != null) {
     ProjectManager.openProject(fileName);
   }
 }
Example #28
0
  private void browse() {
    FileDialog dialog = new FileDialog(base.getShell(), SWT.SAVE);
    String file = getFile();
    if (file != null) {
      dialog.setFileName(file);
    }

    String selection = dialog.open();
    if (selection != null) {
      setFile(selection);
    }
  }
  private void openAddressBook() {
    FileDialog fileDialog = new FileDialog(shell, SWT.OPEN);

    fileDialog.setFilterExtensions(new String[] {"*.messages;", "*.*"});
    fileDialog.setFilterNames(
        new String[] {
          resMessages.getString("Book_filter_name") + " (*.messages)",
          resMessages.getString("All_filter_name") + " (*.*)"
        });
    String name = fileDialog.open();
    openAddressBook(name);
  }
 /**
  * Browse button for application file selection using file system. Only JAR, WAR and EAR files can
  * be selected.
  */
 private void browseBtnListener() {
   FileDialog dialog = new FileDialog(this.getShell());
   String[] extensions = new String[3];
   extensions[0] = "*.WAR";
   extensions[1] = "*.JAR";
   extensions[2] = "*.EAR";
   dialog.setFilterExtensions(extensions);
   String file = dialog.open();
   if (file != null) {
     fileTxt.setText(file);
   }
 }