Java Code Examples for org.eclipse.swt.widgets.FileDialog#getFileNames()

The following examples show how to use org.eclipse.swt.widgets.FileDialog#getFileNames() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: HiveTab.java    From neoscada with Eclipse Public License 1.0 6 votes vote down vote up
protected void chooseFile ()
{
    final FileDialog dlg = new FileDialog ( getShell (), SWT.OPEN | SWT.MULTI );
    dlg.setFilterExtensions ( new String[] { "*.xml", "*.*" } );
    dlg.setFilterNames ( new String[] { "Eclipse NeoSCADA Exporter Files", "All files" } );
    final String result = dlg.open ();
    if ( result != null )
    {
        final File base = new File ( dlg.getFilterPath () );

        for ( final String name : dlg.getFileNames () )
        {
            this.fileText.setText ( new File ( base, name ).getAbsolutePath () );
        }
        makeDirty ();
    }
}
 
Example 2
Source File: XMLAnalysesManagerPreferencePage.java    From tracecompass with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * Import new analysis.
 */
private void importAnalysis() {
    FileDialog dialog = TmfFileDialogFactory.create(Display.getCurrent().getActiveShell(), SWT.OPEN | SWT.MULTI);
    dialog.setText(Messages.ManageXMLAnalysisDialog_SelectFilesImport);
    dialog.setFilterNames(new String[] { Messages.ManageXMLAnalysisDialog_ImportXmlFile + " (" + XML_FILTER_EXTENSION + ")" }); //$NON-NLS-1$ //$NON-NLS-2$
    dialog.setFilterExtensions(new String[] { XML_FILTER_EXTENSION });
    dialog.open();
    String directoryPath = dialog.getFilterPath();
    if (!directoryPath.isEmpty()) {
        File directory = new File(directoryPath);
        String[] files = dialog.getFileNames();
        Collection<String> filesToProcess = Lists.newArrayList();
        for (String fileName : files) {
            File file = new File(directory, fileName);
            if (loadXmlFile(file, true)) {
                filesToProcess.add(file.getName());
            }
        }
        if (!filesToProcess.isEmpty()) {
            fillAnalysesTable();
            Collection<TmfCommonProjectElement> elements = deleteSupplementaryFiles(filesToProcess);
            XmlAnalysisModuleSource.notifyModuleChange();
            refreshProject(elements);
        }
    }
}
 
Example 3
Source File: DFSActionImpl.java    From RDFS with Apache License 2.0 6 votes vote down vote up
/**
 * Implement the import action (upload files from the current machine to
 * HDFS)
 * 
 * @param object
 * @throws SftpException
 * @throws JSchException
 * @throws InvocationTargetException
 * @throws InterruptedException
 */
private void uploadFilesToDFS(IStructuredSelection selection)
    throws InvocationTargetException, InterruptedException {

  // Ask the user which files to upload
  FileDialog dialog =
      new FileDialog(Display.getCurrent().getActiveShell(), SWT.OPEN
          | SWT.MULTI);
  dialog.setText("Select the local files to upload");
  dialog.open();

  List<File> files = new ArrayList<File>();
  for (String fname : dialog.getFileNames())
    files.add(new File(dialog.getFilterPath() + File.separator + fname));

  // TODO enable upload command only when selection is exactly one folder
  List<DFSFolder> folders = filterSelection(DFSFolder.class, selection);
  if (folders.size() >= 1)
    uploadToDFS(folders.get(0), files);
}
 
Example 4
Source File: ImportFileAction.java    From ice with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * This operation runs the action.
 */
@Override
public void run() {

	// Get the Client
	IClient client = ClientHolder.getClient();

	// Create the dialog and get the files
	FileDialog fileDialog = new FileDialog(workbenchWindow.getShell(),
			SWT.MULTI);
	fileDialog.setText("Select a file to import into ICE");
	fileDialog.open();

	// Import the files
	String filterPath = fileDialog.getFilterPath();
	for (String name : fileDialog.getFileNames()) {
		File importedFile = new File(filterPath, name);
		client.importFile(importedFile.toURI());
	}

	return;
}
 
Example 5
Source File: DFSActionImpl.java    From hadoop-gpu with Apache License 2.0 6 votes vote down vote up
/**
 * Implement the import action (upload files from the current machine to
 * HDFS)
 * 
 * @param object
 * @throws SftpException
 * @throws JSchException
 * @throws InvocationTargetException
 * @throws InterruptedException
 */
private void uploadFilesToDFS(IStructuredSelection selection)
    throws InvocationTargetException, InterruptedException {

  // Ask the user which files to upload
  FileDialog dialog =
      new FileDialog(Display.getCurrent().getActiveShell(), SWT.OPEN
          | SWT.MULTI);
  dialog.setText("Select the local files to upload");
  dialog.open();

  List<File> files = new ArrayList<File>();
  for (String fname : dialog.getFileNames())
    files.add(new File(dialog.getFilterPath() + File.separator + fname));

  // TODO enable upload command only when selection is exactly one folder
  List<DFSFolder> folders = filterSelection(DFSFolder.class, selection);
  if (folders.size() >= 1)
    uploadToDFS(folders.get(0), files);
}
 
Example 6
Source File: TmxConvert2FileDialog.java    From tmxeditor8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * (non-Javadoc)
 * @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent)
 */
@Override
public void widgetSelected(SelectionEvent e) {

	FileDialog fDialog = new FileDialog(getShell(), SWT.MULTI);
	fDialog.setFilterExtensions(new String[] { "*.tmx" });
	fDialog.open();
	String filterPath = fDialog.getFilterPath();
	String[] fileNames = fDialog.getFileNames();
	if (fileNames == null || fileNames.length == 0) {
		return;
	}
	String absolutePath = null;
	for (String fileName : fileNames) {
		absolutePath = new File(filterPath + File.separator + fileName).getAbsolutePath();
		if (Arrays.asList(tmxList.getItems()).contains(absolutePath)) {
			continue;
		}
		tmxList.add(absolutePath);
	}
	setOkState();
}
 
Example 7
Source File: MultiFileFieldEditor.java    From ermasterr with Apache License 2.0 5 votes vote down vote up
private File[] getFile(final File startingDirectory) {

        int style = SWT.OPEN;
        if (multiple) {
            style |= SWT.MULTI;
        }

        final FileDialog dialog = new FileDialog(getShell(), style);
        if (startingDirectory != null) {
            dialog.setFileName(startingDirectory.getPath());
        }
        if (extensions != null) {
            dialog.setFilterExtensions(extensions);
        }
        dialog.open();
        final String[] fileNames = dialog.getFileNames();

        if (fileNames.length > 0) {
            final File[] files = new File[fileNames.length];

            for (int i = 0; i < fileNames.length; i++) {
                files[i] = new File(dialog.getFilterPath(), fileNames[i]);
            }

            return files;
        }

        return null;
    }
 
Example 8
Source File: TreeWithAddRemove.java    From Pydev with Eclipse Public License 1.0 5 votes vote down vote up
public void addItemWithDialog(FileDialog dialog) {
    dialog.setFilterPath(lastFileDialogPath);
    dialog.open();
    String[] fileNames = dialog.getFileNames();
    String parent = dialog.getFilterPath();
    if (fileNames != null && fileNames.length > 0) {
        for (String s : fileNames) {
            addTreeItem(FileUtils.getFileAbsolutePath(new File(parent, s)));
        }
    }
}
 
Example 9
Source File: ScriptMainTab.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
private File chooseReportDesign( )
{
	if ( lastUsedPath == null )
	{
		lastUsedPath = ""; //$NON-NLS-1$
	}
	FileDialog dialog = new FileDialog( getShell( ), SWT.SINGLE );
	dialog.setText( Messages.getString( "ScriptMainTab.msg.select.report.file" ) ); //$NON-NLS-1$

	if ( bRender.getSelection( ) )
	{
		dialog.setFilterExtensions( new String[]{
			"*." + DOCUMENT_FILE_EXT} ); //$NON-NLS-1$
	}
	else
	{
		dialog.setFilterExtensions( new String[]{
			"*." + IReportElementConstants.DESIGN_FILE_EXTENSION} ); //$NON-NLS-1$
	}

	dialog.setFilterPath( lastUsedPath );
	String res = dialog.open( );
	if ( res == null )
	{
		return null;
	}
	String[] fileNames = dialog.getFileNames( );

	IPath filterPath = new Path( dialog.getFilterPath( ) );
	lastUsedPath = dialog.getFilterPath( );

	IPath path = null;
	for ( int i = 0; i < 1; i++ )
	{
		path = filterPath.append( fileNames[i] ).makeAbsolute( );
		return path.toFile( );
	}
	return null;
}
 
Example 10
Source File: ClassPathBlock.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
public static IPath[] chooseExternalJAREntries( Shell shell )
{
	if ( lastUsedPath == null )
	{
		lastUsedPath = ""; //$NON-NLS-1$
	}
	FileDialog dialog = new FileDialog( shell, SWT.MULTI );
	dialog.setText( Messages.getString( "ClassPathBlock_FileDialog.jar.text" ) ); //$NON-NLS-1$
	dialog.setFilterExtensions( ALL_ARCHIVES_FILTER_EXTENSIONS );
	dialog.setFilterPath( lastUsedPath );

	String res = dialog.open( );
	if ( res == null )
	{
		return null;
	}
	String[] fileNames = dialog.getFileNames( );
	int nChosen = fileNames.length;

	IPath filterPath = Path.fromOSString( dialog.getFilterPath( ) );
	IPath[] elems = new IPath[nChosen];
	for ( int i = 0; i < nChosen; i++ )
	{
		elems[i] = filterPath.append( fileNames[i] ).makeAbsolute( );
	}
	lastUsedPath = dialog.getFilterPath( );

	return elems;
}
 
Example 11
Source File: RTFCleanerDialog.java    From tmxeditor8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 处理 RTF 文件 ;
 */
private void handleFile() {
	FileDialog dialog = new FileDialog(getShell(), SWT.MULTI);
	dialog.setText(Messages.getString("dialog.RTFCleanerDialog.dialogTitle"));
	String[] extensions = { "*.rtf", "*" };
	String[] filters = { Messages.getString("dialog.RTFCleanerDialog.filters1"),
			Messages.getString("dialog.RTFCleanerDialog.filters2") };
	dialog.setFilterExtensions(extensions);
	dialog.setFilterNames(filters);
	dialog.setFilterPath(System.getProperty("user.home"));
	dialog.open();
	String[] arrSource = dialog.getFileNames();
	if (arrSource == null || arrSource.length == 0) {
		return;
	}
	int errors = 0;
	for (int i = 0; i < arrSource.length; i++) {
		File f = new File(dialog.getFilterPath() + System.getProperty("file.separator") + arrSource[i]); //$NON-NLS-1$
		Hashtable<String, String> params = new Hashtable<String, String>();
		params.put("source", f.getAbsolutePath()); //$NON-NLS-1$
		params.put("output", f.getAbsolutePath()); //$NON-NLS-1$

		Vector<String> result = RTFCleaner.run(params);

		if (!"0".equals(result.get(0))) { //$NON-NLS-1$
			String msg = MessageFormat.format(Messages.getString("dialog.RTFCleanerDialog.msg1"), arrSource[i])
					+ (String) result.get(1);
			MessageDialog.openInformation(getShell(), Messages.getString("dialog.RTFCleanerDialog.msgTitle"), msg);
			errors++;
		}
	}
	if (errors < arrSource.length) {
		MessageDialog.openInformation(getShell(), Messages.getString("dialog.RTFCleanerDialog.msgTitle"),
				Messages.getString("dialog.RTFCleanerDialog.msg2"));
	}
}
 
Example 12
Source File: AddJarsHandler.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
@Override
public Object execute(final ExecutionEvent event) throws ExecutionException {

    final FileDialog fd = new FileDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), SWT.OPEN | SWT.MULTI);
    fd.setFilterExtensions(new String[] { "*.jar;*.zip" });
    if (filenames != null) {
        fd.setFilterNames(filenames);
    }
    if (fd.open() != null) {
        final DependencyRepositoryStore libStore = RepositoryManager.getInstance().getRepositoryStore(DependencyRepositoryStore.class);
        final String[] jars = fd.getFileNames();
        final IProgressService progressManager = PlatformUI.getWorkbench().getProgressService();
        final IRunnableWithProgress runnable = new ImportLibsOperation(libStore, jars, fd.getFilterPath());

        try {

            progressManager.run(true, false, runnable);
            progressManager.run(true, false, new IRunnableWithProgress() {

                @Override
                public void run(final IProgressMonitor monitor) throws InvocationTargetException,
                        InterruptedException {
                    RepositoryManager.getInstance().getCurrentRepository().build(monitor);
                }
            });
        } catch (final InvocationTargetException e1) {
            BonitaStudioLog.error(e1);
            if (e1.getCause() != null && e1.getCause().getMessage() != null) {
                MessageDialog.openError(Display.getDefault().getActiveShell(), org.bonitasoft.studio.dependencies.i18n.Messages.importJar, e1.getCause()
                        .getMessage());
            }
        } catch (final InterruptedException e2) {
            BonitaStudioLog.error(e2);
        }

    }
    return fd.getFileNames();
}
 
Example 13
Source File: MultiFileFieldEditor.java    From ermaster-b with Apache License 2.0 5 votes vote down vote up
private File[] getFile(File startingDirectory) {

		int style = SWT.OPEN;
		if (multiple) {
			style |= SWT.MULTI;
		}

		FileDialog dialog = new FileDialog(getShell(), style);
		if (startingDirectory != null) {
			dialog.setFileName(startingDirectory.getPath());
		}
		if (extensions != null) {
			dialog.setFilterExtensions(extensions);
		}
		dialog.open();
		String[] fileNames = dialog.getFileNames();

		if (fileNames.length > 0) {
			File[] files = new File[fileNames.length];

			for (int i = 0; i < fileNames.length; i++) {
				files[i] = new File(dialog.getFilterPath(), fileNames[i]);
			}

			return files;
		}

		return null;
	}
 
Example 14
Source File: DialogOpenBTAction.java    From jbt with Apache License 2.0 4 votes vote down vote up
/**
 * 
 * @see org.eclipse.jface.action.Action#run()
 */
public void run() {
	/*
	 * Open dialog for asking the user to enter some file names.
	 */
	FileDialog dialog = new FileDialog(this.window.getShell(), SWT.MULTI);
	String[] individualFilters = Extensions
			.getFiltersFromExtensions(Extensions.getBTFileExtensions());
	String[] unifiedFilter = new String[] { Extensions
			.getUnifiedFilterFromExtensions(Extensions
					.getBTFileExtensions()) };
	String[] filtersToUse = Extensions.joinArrays(individualFilters,
			unifiedFilter);
	dialog.setFilterExtensions(filtersToUse);
	dialog.setText("Open BT");

	/*
	 * If the user has selected at least one file name, we must open it.
	 * Note that the user may select several files.
	 */
	if (dialog.open() != null) {
		/* Get the name of the files (NOT absolute path). */
		String[] singleNames = dialog.getFileNames();

		/*
		 * This vector will store the absolute path of every single selected
		 * file.
		 */
		Vector<String> absolutePath = new Vector<String>();

		for (int i = 0, n = singleNames.length; i < n; i++) {
			StringBuffer buffer = new StringBuffer(dialog.getFilterPath());
			if (buffer.charAt(buffer.length() - 1) != File.separatorChar)
				buffer.append(File.separatorChar);
			buffer.append(singleNames[i]);
			absolutePath.add(buffer.toString());
		}

		new OpenBTAction(absolutePath).run();
	}
}
 
Example 15
Source File: OpenFileAction.java    From birt with Eclipse Public License 1.0 4 votes vote down vote up
public void run( )
{
	FileDialog dialog = new FileDialog( fWindow.getShell( ), SWT.OPEN
			| SWT.MULTI );
	dialog.setText( DesignerWorkbenchMessages.Dialog_openFile );
	dialog.setFilterExtensions( filterExtensions );
	dialog.setFilterPath( ResourcesPlugin.getWorkspace( )
			.getRoot( )
			.getProjectRelativePath( )
			.toOSString( ) );
	dialog.open( );
	String[] names = dialog.getFileNames( );

	if ( names != null )
	{
		String fFilterPath = dialog.getFilterPath( );

		int numberOfFilesNotFound = 0;
		StringBuffer notFound = new StringBuffer( );
		for ( int i = 0; i < names.length; i++ )
		{
			File file = new File( fFilterPath + File.separator + names[i] );
			if ( file.exists( ) )
			{
				IWorkbenchPage page = fWindow.getActivePage( );
				IEditorInput input = new ReportEditorInput( file );
				IEditorDescriptor editorDesc = getEditorDescriptor( input,
						OpenStrategy.activateOnOpen( ) );
				try
				{
					page.openEditor( input, editorDesc.getId( ) );
				}
				catch ( Exception e )
				{
					ExceptionUtil.handle( e );
				}
			}
			else
			{
				if ( ++numberOfFilesNotFound > 1 )
					notFound.append( '\n' );
				notFound.append( file.getName( ) );
			}
		}
		if ( numberOfFilesNotFound > 0 )
		{
			// String msgFmt= numberOfFilesNotFound == 1 ?
			// TextEditorMessages.OpenExternalFileAction_message_fileNotFound
			// :
			// TextEditorMessages.OpenExternalFileAction_message_filesNotFound;
			// String msg= MessageFormat.format(msgFmt, new Object[] {
			// notFound.toString() });
			// MessageDialog.openError(fWindow.getShell(),
			// TextEditorMessages.OpenExternalFileAction_title, msg);
		}
	}
}
 
Example 16
Source File: UserLibraryPreferencePage.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 4 votes vote down vote up
private CPListElement[] doOpenExternalJarFileDialog(CPListElement existing, Object parent) {
	String lastUsedPath;
	if (existing != null) {
		lastUsedPath= existing.getPath().removeLastSegments(1).toOSString();
	} else {
		lastUsedPath= fDialogSettings.get(IUIConstants.DIALOGSTORE_LASTEXTJAR);
		if (lastUsedPath == null) {
			lastUsedPath= ""; //$NON-NLS-1$
		}
	}
	String title= (existing == null) ? PreferencesMessages.UserLibraryPreferencePage_browsejar_new_title : PreferencesMessages.UserLibraryPreferencePage_browsejar_edit_title;

	FileDialog dialog= new FileDialog(getShell(), existing == null ? SWT.MULTI : SWT.SINGLE);
	dialog.setText(title);
	dialog.setFilterExtensions(ArchiveFileFilter.ALL_ARCHIVES_FILTER_EXTENSIONS);
	dialog.setFilterPath(lastUsedPath);
	if (existing != null) {
		dialog.setFileName(existing.getPath().lastSegment());
	}

	String res= dialog.open();
	if (res == null) {
		return null;
	}
	String[] fileNames= dialog.getFileNames();
	int nChosen= fileNames.length;

	IWorkspaceRoot root= ResourcesPlugin.getWorkspace().getRoot();

	IPath filterPath= Path.fromOSString(dialog.getFilterPath());
	CPListElement[] elems= new CPListElement[nChosen];
	for (int i= 0; i < nChosen; i++) {
		IPath path= filterPath.append(fileNames[i]).makeAbsolute();

		IFile file= root.getFileForLocation(path); // support internal JARs: bug 133191
		if (file != null) {
			path= file.getFullPath();
		}

		CPListElement curr= new CPListElement(parent, null, IClasspathEntry.CPE_LIBRARY, path, file);
		curr.setAttribute(CPListElement.SOURCEATTACHMENT, BuildPathSupport.guessSourceAttachment(curr));
		curr.setAttribute(CPListElement.JAVADOC, BuildPathSupport.guessJavadocLocation(curr));
		elems[i]= curr;
	}
	fDialogSettings.put(IUIConstants.DIALOGSTORE_LASTEXTJAR, dialog.getFilterPath());

	return elems;
}
 
Example 17
Source File: ImportFileWizardHandler.java    From ice with Eclipse Public License 1.0 4 votes vote down vote up
/**
 * Opens a new {@link FileDialog} and imports any selected files into the
 * ICE project space.
 */
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {

	// Get the window and the shell.
	IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindow(event);
	Shell shell = window.getShell();

	// Get the IProject instance if we can
	IProject project = null;
	ISelection selection = HandlerUtil.getCurrentSelection(event);
	if (selection instanceof IStructuredSelection) {
		Object element = ((IStructuredSelection) selection).getFirstElement();
		if (element instanceof IResource) {
			project = ((IResource) element).getProject();
		}
	}

	// Get the Client
	IClient client = null;
	try {
		client = IClient.getClient();
	} catch (CoreException e) {
		logger.error("Could not get a valid IClient reference.", e);
	}

	// Make sure we got a valid IClient
	if (client != null) {
		// Create the dialog and get the files
		FileDialog fileDialog = new FileDialog(shell, SWT.MULTI);
		fileDialog.setText("Select a file to import into ICE");
		fileDialog.open();

		// Import the files
		String filterPath = fileDialog.getFilterPath();
		for (String name : fileDialog.getFileNames()) {
			File importedFile = new File(filterPath, name);
			if (project == null) {
				client.importFile(importedFile.toURI());
			} else {
				client.importFile(importedFile.toURI(), project);
			}
		}
	} else {
		logger.error("Could not find a valid IClient.");
	}
	
	return null;
}
 
Example 18
Source File: FileOpenViewActionDelegate.java    From LogViewer with Eclipse Public License 2.0 4 votes vote down vote up
public void run(LogViewer view, Shell shell) {

		fileOpened = false;

		// log file type
		String typeStr = null;
		String nameStr = null;
		type = LogFileType.LOGFILE_SYSTEM_FILE;

		/*
		String conStr = "Console: ";
	    LogFileTypeDialog typeDialog = new LogFileTypeDialog(shell);
	    typeDialog.setBlockOnOpen(true);
		int retval = typeDialog.open();
		if(retval == EncodingDialog.OK) {
			typeStr = typeDialog.getValue();
			if (typeStr.indexOf(conStr) == 0) {
				type = LogFileType.LOGFILE_ECLIPSE_CONSOLE;
				typeStr = typeStr.substring(conStr.length());
			}
		} else {
			return;
		}
		*/

		if (type == LogFileType.LOGFILE_SYSTEM_FILE) {
		    // load filter extensions
			String filterExtensions = LogViewerPlugin.getDefault().getPreferenceStore().getString(ILogViewerConstants.PREF_FILTER_EXTENSIONS);
			// opening file(s) in log view
		    FileDialog dialog = new FileDialog(shell,SWT.OPEN|SWT.MULTI);
		    String[] extensions = {
		    		filterExtensions,
		    		"*.*"
		    };

	    	//
		    if (parentPath == null) {
		    	Object[] file_list = FileHistoryTracker.getInstance().getFiles().toArray();
		    	if (file_list.length >= 1)
		    	{
		    		HistoryFile history_file = (HistoryFile)(file_list[file_list.length - 1]);
		    		File file = new File(history_file.getPath());
		    		if (file.isDirectory()) {
		    			parentPath = file.toString();
		    		} else {
		    			parentPath = file.getParent();
		    		}
		    	}
		    }
		    dialog.setFilterPath(parentPath);
		    dialog.setFilterExtensions(extensions);
		    dialog.setFilterIndex(0);
		    String path = dialog.open();
		    if (path != null) {
		    	File tempFile = new File(path);
		    	path = tempFile.isDirectory() ? tempFile.toString() : tempFile.getParent();
		    	String selectedFiles[] = dialog.getFileNames();
		    	for (int i=0;i<selectedFiles.length;i++) {
		    		String fileStr = path.endsWith(File.separator) ? path + selectedFiles[i] : path + File.separator + selectedFiles[i];
		    		if (!view.checkAndOpenFile(type,fileStr, null, true))
		    	        fileOpened = true;
		    	}
		    }
		} else if (type == LogFileType.LOGFILE_ECLIPSE_CONSOLE) {
    		if (!view.checkAndOpenFile(type, typeStr, nameStr, true))
    	        fileOpened = true;
		}
	}
 
Example 19
Source File: PathsProvider.java    From spotbugs with GNU Lesser General Public License v2.1 4 votes vote down vote up
protected String[] getFileNames(FileDialog dialog) {
    return dialog.getFileNames();
}
 
Example 20
Source File: RepositoryExplorerDialog.java    From pentaho-kettle with Apache License 2.0 4 votes vote down vote up
public void importAll() {
  FileDialog dialog = new FileDialog( shell, SWT.OPEN | SWT.MULTI );
  if ( dialog.open() != null ) {
    // Ask for a destination in the repository...
    //
    SelectDirectoryDialog sdd = new SelectDirectoryDialog( shell, SWT.NONE, rep );
    RepositoryDirectoryInterface baseDirectory = sdd.open();

    if ( baseDirectory != null ) {
      // Finally before importing, ask for a version comment (if applicable)
      //
      String versionComment = null;
      boolean versionOk = false;
      while ( !versionOk ) {
        versionComment =
          RepositorySecurityUI.getVersionComment( shell, rep, "Import of files into ["
            + baseDirectory.getPath() + "]", "", true );

        // if the version comment is null, the user hit cancel, exit.
        if ( rep != null
          && rep.getSecurityProvider() != null && versionComment == null ) {
          return;
        }
        if ( Utils.isEmpty( versionComment ) && rep.getSecurityProvider().isVersionCommentMandatory() ) {
          if ( !RepositorySecurityUI.showVersionCommentMandatoryDialog( shell ) ) {
            versionOk = true;
          }
        } else {
          versionOk = true;
        }
      }

      String[] filenames = dialog.getFileNames();
      if ( filenames.length > 0 ) {
        RepositoryImportProgressDialog ripd =
          new RepositoryImportProgressDialog(
            shell, SWT.NONE, rep, dialog.getFilterPath(), filenames, baseDirectory, versionComment );
        ripd.open();

        refreshTree();
      }

    }
  }
}