當前位置: 首頁>>代碼示例>>Java>>正文


Java FileDialog.setFilterExtensions方法代碼示例

本文整理匯總了Java中org.eclipse.swt.widgets.FileDialog.setFilterExtensions方法的典型用法代碼示例。如果您正苦於以下問題:Java FileDialog.setFilterExtensions方法的具體用法?Java FileDialog.setFilterExtensions怎麽用?Java FileDialog.setFilterExtensions使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.eclipse.swt.widgets.FileDialog的用法示例。


在下文中一共展示了FileDialog.setFilterExtensions方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: updateFile

import org.eclipse.swt.widgets.FileDialog; //導入方法依賴的package包/類
protected void updateFile ()
{
    final FileDialog dlg = new FileDialog ( getShell (), SWT.APPLICATION_MODAL | SWT.SAVE );

    dlg.setFilterExtensions ( new String[] { Messages.FileSelectionPage_FilterExtension } );
    dlg.setFilterNames ( new String[] { Messages.FileSelectionPage_FilterName } );
    dlg.setOverwrite ( true );
    dlg.setText ( Messages.FileSelectionPage_FileDialog_Text );

    final String fileName = dlg.open ();
    if ( fileName == null )
    {
        setFile ( null );
        update ();
    }
    else
    {
        setFile ( new File ( fileName ) );
        update ();
    }
}
 
開發者ID:eclipse,項目名稱:neoscada,代碼行數:22,代碼來源:FileSelectionPage.java

示例2: openNewAudio

import org.eclipse.swt.widgets.FileDialog; //導入方法依賴的package包/類
protected void openNewAudio() {
	FileDialog fd = new FileDialog(shell, SWT.OPEN);
	fd.setText("Select the audio file");
	String[] filterExt = { "*.wav;*.WAV;*.mp3;*.MP3", "*.*" };
	String[] filterNames = { "WAV and MP3 files", "All files" };
	fd.setFilterExtensions(filterExt);
	fd.setFilterNames(filterNames);
	String lastPath = Config.getInstance().getString(Config.LAST_OPEN_AUDIO_PATH);
	if (lastPath != null && lastPath.isEmpty())
		fd.setFileName(lastPath);
	String selected = fd.open();
	if (selected != null) {
		closePlayer();
		openAudioFile(new File(selected));
		Config.getInstance().putValue(Config.LAST_OPEN_AUDIO_PATH, selected);
		try {
			Config.getInstance().save();
		} catch (IOException e) {
			// The user do not NEED to know about this...
		}
	}
}
 
開發者ID:juanerasmoe,項目名稱:pmTrans,代碼行數:23,代碼來源:PmTrans.java

示例3: openTranscription

import org.eclipse.swt.widgets.FileDialog; //導入方法依賴的package包/類
public void openTranscription() {
	if (!textEditor.isDisposed()) {
		FileDialog fd = new FileDialog(shell, SWT.OPEN);
		fd.setText("Select the transcription file");
		String[] filterExt = { "*.xpmt;*.XPMT" };
		String[] filterNames = { "pmTrans transcription files" };
		fd.setFilterExtensions(filterExt);
		fd.setFilterNames(filterNames);
		String lastPath = Config.getInstance().getString(Config.LAST_OPEN_TEXT_PATH);
		if (lastPath != null && !lastPath.isEmpty())
			fd.setFileName(lastPath);
		String selected = fd.open();
		if (selected != null) {
			openTranscriptionFile(new File(selected));
			Config.getInstance().putValue(Config.LAST_OPEN_TEXT_PATH, selected);
			try {
				Config.getInstance().save();
			} catch (IOException e) {
				// The user do not NEED to know about this...
			}
		}
	}
}
 
開發者ID:juanerasmoe,項目名稱:pmTrans,代碼行數:24,代碼來源:PmTrans.java

示例4: importTextFile

import org.eclipse.swt.widgets.FileDialog; //導入方法依賴的package包/類
protected void importTextFile(File f) {
	if (!textEditor.isDisposed()) {
		FileDialog fd = new FileDialog(shell, SWT.OPEN);
		fd.setText("Import text");
		fd.setFilterExtensions(new String[] { "*.txt;*.TXT" });
		fd.setFilterNames(new String[] { "Plain text files (*.txt)" });
		String selected = fd.open();
		if (selected != null) {
			try {
				textEditor.importText(new File(selected));
			} catch (IOException e) {
				e.printStackTrace();
				MessageBox diag = new MessageBox(shell, SWT.ICON_WARNING | SWT.OK);
				diag.setMessage("Unable to open file " + transcriptionFile.getPath());
				diag.open();
			}
		}
	}
}
 
開發者ID:juanerasmoe,項目名稱:pmTrans,代碼行數:20,代碼來源:PmTrans.java

示例5: changeImage

import org.eclipse.swt.widgets.FileDialog; //導入方法依賴的package包/類
private void changeImage(boolean big){
	NodeImageConfig currentNodeConfig=this.getCurrentNodeConfig();
	if(currentNodeConfig==null)return;
	FileDialog dialog=new FileDialog(getShell());
	if(big){
		dialog.setText("請選擇一張22*22px大小的png格式圖標!");
	}else{
		dialog.setText("請選擇一張16*16px大小的png格式圖標!");			
	}
	dialog.setFilterExtensions(new String[]{"*.png"});
	String fileName=dialog.open();
	if(fileName==null){
		return;
	}
	Image img=Activator.getImageFromLocal(fileName);
	if(big){
		currentNodeConfig.setCustomImage(img);
		currentNodeConfig.setCustomImagePath(fileName);
	}else{
		currentNodeConfig.setCustomSmallImage(img);
		currentNodeConfig.setCustomSmallImagePath(fileName);
	}
	tableViewer.refresh();
}
 
開發者ID:bsteker,項目名稱:bdf2,代碼行數:25,代碼來源:DesignerPreferencePage.java

示例6: handleSelectFile

import org.eclipse.swt.widgets.FileDialog; //導入方法依賴的package包/類
protected void handleSelectFile ()
{
    final FileDialog dlg = new FileDialog ( getShell (), SWT.SAVE );
    dlg.setFilterExtensions ( new String[] { "*.oscar", "*.*" } ); //$NON-NLS-1$ //$NON-NLS-2$ 
    dlg.setFilterNames ( new String[] { Messages.FileNamePage_OSCARFileType, Messages.FileNamePage_AllTypes } );

    if ( this.fileName.getText ().length () > 0 )
    {
        dlg.setFileName ( this.fileName.getText () );
    }
    dlg.setFilterIndex ( 0 );

    final String file = dlg.open ();
    if ( file != null )
    {
        this.fileName.setText ( file );
        getWizard ().getDialogSettings ().put ( "fileNamePage.file", file ); //$NON-NLS-1$
    }
}
 
開發者ID:eclipse,項目名稱:neoscada,代碼行數:20,代碼來源:FileNamePage.java

示例7: openFileDirectly

import org.eclipse.swt.widgets.FileDialog; //導入方法依賴的package包/類
/**
 * Open the file dialog for the direct opening of a file. If a file is returned,
 * expand the directory tree accordingly.
 */
public void openFileDirectly() {
	FileDialog fileDialog = new FileDialog(this.shell, SWT.OPEN);
	String[] extensions = {"*.class", "*.jar", "*.war", "*.ear"};
	String[] names = {"Class file (*.class)", "Jar archive (*.jar)", "War archive (*.war)", "Ear archive (*.ear)"};
	fileDialog.setFilterExtensions(extensions);
	fileDialog.setFilterNames(names);
	String path = fileDialog.open();
	if (path != null) {
		// First of all replace double backslashes against slashes.
		path = path.replace("\\\\", "\\");

		// different handling of class and jar files
		if (JarFileEntry.isArchive(path) || (path.length() > 6 && path.substring(path.length() - 6).equals(".class")))
		{
			// Browse through the directory tree.
			browseTroughTheDirectoryTree(path, null);
		} else {
			StaticGuiSupport.showMessageBox(FileSelectionComposite.this.shell, "Information", "This file cannot be processed.", SWT.OK | SWT.ICON_WARNING);
		}
	}
}
 
開發者ID:wwu-pi,項目名稱:tap17-muggl-javaee,代碼行數:26,代碼來源:FileSelectionComposite.java

示例8: exportBookList

import org.eclipse.swt.widgets.FileDialog; //導入方法依賴的package包/類
public void exportBookList() {
    try {
        String ext = "*.csv";
        String name = "CSV (Excel) File";
        FileDialog dialog = new FileDialog(shell, SWT.SAVE);
        dialog.setFilterNames(new String[]{name});
        dialog.setFilterExtensions(new String[]{ext});
        dialog.setFileName("books.csv");
        String path = dialog.open();
        if (path != null) {
            File f = new File(path);
            audibleGUI.audible.export(f);
            if (f.exists())
                logger.info("exported books to: "+f.getAbsolutePath());
        }

    } catch (Exception e) {
        MessageBoxFactory.showError(shell, e.getMessage());
    }

}
 
開發者ID:openaudible,項目名稱:openaudible,代碼行數:22,代碼來源:Application.java

示例9: getSaveFilePath

import org.eclipse.swt.widgets.FileDialog; //導入方法依賴的package包/類
private static String getSaveFilePath(IEditorPart editorPart, GraphicalViewer viewer, int format) {
	FileDialog fileDialog = new FileDialog(editorPart.getEditorSite().getShell(), SWT.SAVE);
	String[] filterExtensions = new String[] { "*.jpeg",
			"*.bmp"/*
					 * , "*.ico" , "*.png", "*.gif"
					 */ };
	if (format == SWT.IMAGE_BMP)
		filterExtensions = new String[] { "*.bmp" };
	else if (format == SWT.IMAGE_JPEG)
		filterExtensions = new String[] { "*.jpeg" };
	// else if (format == SWT.IMAGE_ICO)
	// filterExtensions = new String[] { "*.ico" };
	fileDialog.setFilterExtensions(filterExtensions);

	return fileDialog.open();
}
 
開發者ID:dstl,項目名稱:Open_Source_ECOA_Toolset_AS5,代碼行數:17,代碼來源:ImageSaveUtil.java

示例10: promptForExportFile

import org.eclipse.swt.widgets.FileDialog; //導入方法依賴的package包/類
public static String promptForExportFile(final Shell shell) {
    final FileDialog dlg = new FileDialog(shell, SWT.SAVE);
    dlg.setFilterNames(new String[] {
        "*.zip" //$NON-NLS-1$
    });
    dlg.setFilterExtensions(new String[] {
        "*.zip" //$NON-NLS-1$
    });

    final SupportProvider supportProvider =
        SupportManager.getInstance().getSupportProviderCache().getSupportProvider();
    if (supportProvider == null) {
        throw new IllegalStateException();
    }
    final SimpleDateFormat dateFormat = new SimpleDateFormat(EXPORT_FILE_DATE_FORMAT);
    final String name = supportProvider.getExportFilenamePrefix() + dateFormat.format(new Date()) + ".zip"; //$NON-NLS-1$

    dlg.setFileName(name);
    dlg.setText(Messages.getString("InternalSupportUtils.DialogTitle")); //$NON-NLS-1$
    return dlg.open();
}
 
開發者ID:Microsoft,項目名稱:team-explorer-everywhere,代碼行數:22,代碼來源:InternalSupportUtils.java

示例11: widgetSelected

import org.eclipse.swt.widgets.FileDialog; //導入方法依賴的package包/類
public void widgetSelected( SelectionEvent event){
   FileDialog fd = new FileDialog(st.getShell(), SWT.OPEN);
   fd.setText("Add File Parameter");
   fd.setFilterExtensions(CoreConstants.FILE_FILTER_EXT);
   String file = fd.open();

   if (file != null) {
      if (manager.isMultipart()) {
         st.setText(st.getText() + CoreConstants.FILE_PREFIX + file);
      } else {
         try {
            st.setText(readFileAsString(file));
         } catch (IOException e) {
            // ignore
         }
      }
      // model.fireExecute(new ModelEvent(ModelEvent.BODY_FOCUS_LOST,
      // model));
      // // force body to refresh itself
      // model.fireExecute(new ModelEvent(ModelEvent.PARAMS_FOCUS_LOST,
      // model));
   }
}
 
開發者ID:nextinterfaces,項目名稱:http4e,代碼行數:24,代碼來源:ParamsAttachManager.java

示例12: run

import org.eclipse.swt.widgets.FileDialog; //導入方法依賴的package包/類
public void run(){

      try {

         FileDialog fileDialog = new FileDialog(view.getSite().getShell(), SWT.SAVE);

         fileDialog.setFileName("http4e.jmx");
         fileDialog.setFilterNames(new String[] { "JMeter File *.jmx (Run the script with \"jmeter-t.cmd\")" });
         fileDialog.setFilterExtensions(new String[] { "*.jmx" });
         fileDialog.setText("Save As JMeter script (Run the script with \"jmeter-t.cmd\")");
         fileDialog.setFilterPath(getUserHomeDir());

         String path = fileDialog.open();
         if (path != null) {
            HdViewPart hdView = (HdViewPart) view;
            BaseUtils.writeJMX(path, hdView.getFolderView().getModel());
            updateUserHomeDir(path);
         }

      } catch (Exception e) {
         ExceptionHandler.handle(e);
      }
   }
 
開發者ID:nextinterfaces,項目名稱:http4e,代碼行數:24,代碼來源:ExportJMeterAction.java

示例13: menuOpenFile

import org.eclipse.swt.widgets.FileDialog; //導入方法依賴的package包/類
void menuOpenFile() {
	// Get the user to choose an image file.
	FileDialog fileChooser = new FileDialog(getShell(), SWT.OPEN);
	if (lastPath != null) {
		fileChooser.setFilterPath(lastPath);
	}
	fileChooser.setFilterExtensions(new String[] { "*.bmp; *.gif; *.ico; *.jpg; *.pcx; *.png; *.tif", "*.bmp",
	        "*.gif", "*.ico", "*.jpg", "*.pcx", "*.png", "*.tif" });
	fileChooser.setFilterNames(new String[] {
	        ImageAnalyzer.bundle.getString("All_images") + " (bmp, gif, ico, jpg, pcx, png, tif)", "BMP (*.bmp)",
	        "GIF (*.gif)", "ICO (*.ico)", "JPEG (*.jpg)", "PCX (*.pcx)", "PNG (*.png)", "TIFF (*.tif)" });
	String filename = fileChooser.open();
	lastPath = fileChooser.getFilterPath();
	if (filename == null) {
		return;
	}

	menuOpenFile(filename);
}
 
開發者ID:aroog,項目名稱:code,代碼行數:20,代碼來源:ImageAnalyzer.java

示例14: hdlExportCsv

import org.eclipse.swt.widgets.FileDialog; //導入方法依賴的package包/類
public void hdlExportCsv() {
	if (model.resultData.getValue() == null || model.resultData.getValue().getRowCount() == 0)
		logging.Info("No data to export");
	else {
		String delim = preferenceStore.getString(FtcPreferenceStore.KEY_CSV_DELIMITER);
		String quote = preferenceStore.getString(FtcPreferenceStore.KEY_CSV_QUOTECHAR);

		FileDialog dialog = new FileDialog(WorkbenchUtil.getShell(), SWT.SAVE);

		dialog.setFilterPath(preferenceStore.getString(FtcPreferenceStore.KEY_LAST_EXPORT_PATH));
		dialog.setFilterNames(new String[] { "csv files", "All Files (*.*)" });
		dialog.setFilterExtensions(new String[] { "*.csv", "*.*" });
		String fullPath = dialog.open();

		if (fullPath != null) {
			createCsv(delim, quote).write(model.resultData.getValue(), fullPath);
			preferenceStore.setValue(FtcPreferenceStore.KEY_LAST_EXPORT_PATH, new File(fullPath).getPath());
		}
	}
}
 
開發者ID:curiosag,項目名稱:ftc,代碼行數:21,代碼來源:EclipseClientController.java

示例15: onImportMP

import org.eclipse.swt.widgets.FileDialog; //導入方法依賴的package包/類
private void onImportMP() {

		final FileDialog dialog = new FileDialog(getShell(), SWT.OPEN);

		dialog.setText(Messages.Pref_Map_Dialog_Import_Title);
		dialog.setFilterPath(_prefStore.getString(IMPORT_FILE_PATH));

		dialog.setFilterExtensions(new String[] { "*.*", "xml" });//$NON-NLS-1$ //$NON-NLS-2$
		dialog.setFilterNames(new String[] {
				Messages.PrefPageMapProviders_Pref_Map_FileDialog_AllFiles,
				Messages.PrefPageMapProviders_Pref_Map_FileDialog_XmlFiles });

		dialog.setFileName(_selectedMapProvider.getId() + XML_EXTENSION);

		final String selectedFilePath = dialog.open();

		if (selectedFilePath == null) {
			// dialog is canceled
			return;
		}

		// keep path
		_prefStore.setValue(IMPORT_FILE_PATH, selectedFilePath);

		doImportMP(selectedFilePath);
	}
 
開發者ID:wolfgang-ch,項目名稱:mytourbook,代碼行數:27,代碼來源:PrefPageMapProviders.java


注:本文中的org.eclipse.swt.widgets.FileDialog.setFilterExtensions方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。