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
  public void test_ConstructorLorg_eclipse_swt_widgets_ShellI() {
    // Test FileDialog(Shell, int)
    FileDialog fd;
    fd = new FileDialog(shell, SWT.NULL);
    int style = fd.getStyle();
    style &= ~SWT.LEFT_TO_RIGHT;
    style &= ~SWT.RIGHT_TO_LEFT;
    assertTrue(style == SWT.APPLICATION_MODAL);

    fd = new FileDialog(shell, SWT.APPLICATION_MODAL);
    style = fd.getStyle();
    style &= ~SWT.LEFT_TO_RIGHT;
    style &= ~SWT.RIGHT_TO_LEFT;
    assertTrue(style == SWT.APPLICATION_MODAL);

    fd = new FileDialog(shell, SWT.PRIMARY_MODAL);
    style = fd.getStyle();
    style &= ~SWT.LEFT_TO_RIGHT;
    style &= ~SWT.RIGHT_TO_LEFT;
    assertTrue(style == SWT.PRIMARY_MODAL);

    fd = new FileDialog(shell, SWT.SYSTEM_MODAL);
    style = fd.getStyle();
    style &= ~SWT.LEFT_TO_RIGHT;
    style &= ~SWT.RIGHT_TO_LEFT;
    assertTrue(style == SWT.SYSTEM_MODAL);
  }
示例#3
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();
      }
    }
  }
  @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();
      }
    }
  }
  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.");
    }
  }
示例#6
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");
   }
 }
  @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;
  }
  @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;
  }
示例#9
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);
 }
示例#10
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);
 }
 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;
 }
示例#12
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);
   }
 }
 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();
 }
示例#14
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 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);
 }
  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 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();
   }
 }
示例#19
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);
 }
示例#20
0
 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;
 }
示例#21
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);
   }
 }
  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);
  }
示例#23
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);
    }
  }
 /**
  * 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);
   }
 }
示例#25
0
 private void export() {
   FileDialog fd = new FileDialog(getShell(), SWT.SAVE);
   String[] filterExt = {"*.csv"};
   fd.setFilterExtensions(filterExt);
   String selected = fd.open();
   if (null != selected) {
     try {
       CsvExport.export(selected, selectedSetData);
     } catch (IOException e) {
       throw new KeyException("Ошибка при экспорте", e);
     }
   }
 }
示例#26
0
 /** Open a resource chooser to select a PDA program */
 protected void browseLispExeFiles() {
   FileDialog fd = new FileDialog(getShell());
   fd.setFileName(fProgramText.getText());
   if (exename != null && exename != "") {
     fd.setFilterNames(new String[] {exename});
   } else if (System.getProperty("os.name").toLowerCase().contains("windows")) {
     fd.setFilterExtensions(new String[] {"*.exe"});
   }
   String fileName = fd.open();
   if (fileName != null) {
     fProgramText.setText(fileName);
   }
 }
 private void performExport() {
   FileDialog dialog = new FileDialog(this.fDialog.getShell(), SWT.SAVE);
   dialog.setText("Export environment variables to file");
   String file = dialog.open();
   if (file != null) {
     EnvironmentVariable[] variables = this.fEnvironmentVariablesContentProvider.getVariables();
     try {
       EnvironmentVariablesFileUtils.save(variables, file);
     } catch (Exception e) {
       // String text = "Failed to save environment variables";
       showErrorMessage("Environment export", e.getMessage());
     }
   }
 }
示例#28
0
  void openValidationConjectures() {
    FileDialog fDlg = new FileDialog(getSite().getShell());
    String valFileName = fDlg.open();

    ValidationConjecturesView v = getValidationConjecturesView();
    if (v != null) {
      conjectureData.clear();
      try {
        v.initializeLink(new FileReader(valFileName), this);
      } catch (FileNotFoundException e) {
        TracefileViewerPlugin.log(e);
      }
      updateOverviewPage();
    }
  }
 /** Writes a string corresponding to Kettle log in a log file */
 public void write(String text) {
   FileDialog fd = new FileDialog(new Shell());
   fd.setText("Choose a log file");
   String filePath = fd.open();
   try {
     FileWriter fw = new FileWriter(filePath, true);
     BufferedWriter output = new BufferedWriter(fw);
     output.write(text);
     output.flush();
     output.close();
   } catch (IOException ioe) {
     loadDataUI.displayMessage("File error: " + ioe.getLocalizedMessage());
     ioe.printStackTrace();
   }
 }
 private void browsePressed() {
   nameList.deselectAll();
   FileDialog subDlg = new FileDialog(getShell(), SWT.OPEN);
   selectedPath = subDlg.open();
   if (selectedPath != null) {
     try {
       selectedText = getFileContents(this.selectedPath);
       testTextField.setText(this.selectedText.getText());
       testTextField.redraw();
     } catch (Exception e) {
       messageLabel.setText(e.getMessage());
       messageLabel.redraw();
     }
   }
 }