org.eclipse.swt.widgets.FileDialog#setText ( )源码实例Demo

下面列出了org.eclipse.swt.widgets.FileDialog#setText ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: elexis-3-core   文件: BlockExporter.java
public void finalizeExport() throws XChangeException{
	FileDialog fd = new FileDialog(UiDesk.getTopShell(), SWT.SAVE);
	fd.setText(Messages.BlockContainer_Blockbeschreibung);
	fd.setFilterExtensions(new String[] {
		"*.xchange" //$NON-NLS-1$
	});
	fd.setFilterNames(new String[] {
		Messages.BlockContainer_xchangefiles
	});
	String filename = fd.open();
	if (filename != null) {
		Format format = Format.getPrettyFormat();
		format.setEncoding("utf-8"); //$NON-NLS-1$
		XMLOutputter xmlo = new XMLOutputter(format);
		String xmlAspect = xmlo.outputString(getDocument());
		try {
			FileOutputStream fos = new FileOutputStream(filename);
			fos.write(xmlAspect.getBytes());
			fos.close();
		} catch (Exception ex) {
			ExHandler.handle(ex);
			throw new XChangeException("Output failed " + ex.getMessage());
		}
	}
	
}
 
源代码2 项目: pmTrans   文件: PmTrans.java
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...
		}
	}
}
 
public void changeControlPressed(DialogField field) {
	String label= isSave() ? PreferencesMessages.UserLibraryPreferencePage_LoadSaveDialog_filedialog_save_title : PreferencesMessages.UserLibraryPreferencePage_LoadSaveDialog_filedialog_load_title;
	FileDialog dialog= new FileDialog(getShell(), isSave() ? SWT.SAVE : SWT.OPEN);
	dialog.setText(label);
	dialog.setFilterExtensions(new String[] {"*.userlibraries", "*.*"}); //$NON-NLS-1$ //$NON-NLS-2$
	String lastPath= fLocationField.getText();
	if (lastPath.length() == 0 || !new File(lastPath).exists()) {
		lastPath= fSettings.get(PREF_LASTPATH);
	}
	if (lastPath != null) {
		dialog.setFileName(lastPath);
	}
	String fileName= dialog.open();
	if (fileName != null) {
		fSettings.put(PREF_LASTPATH, fileName);
		fLocationField.setText(fileName);
	}
}
 
/**
 * 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);
        }
    }
}
 
private String chooseArchive() {
	if (fWorkspaceRadio.isSelected()) {
		return chooseWorkspaceArchive();
	}

	IPath currPath= new Path(fArchiveField.getText());
	if (ArchiveFileFilter.isArchivePath(currPath, true)) {
		currPath= currPath.removeLastSegments(1);
	}

	FileDialog dialog= new FileDialog(fShell, SWT.OPEN);
	dialog.setFilterExtensions(ArchiveFileFilter.JAR_ZIP_FILTER_EXTENSIONS);
	dialog.setText(PreferencesMessages.JavadocConfigurationBlock_zipImportSource_title);
	dialog.setFilterPath(currPath.toOSString());

	return dialog.open();
}
 
/**
 * 打开文件对话框
 * @param txt
 *            显示路径文本框
 * @param style
 *            对话框样式
 * @param title
 *            对话框标题
 * @param extensions
 * @param filterNames
 *            ;
 */
private void openFileDialog(Text txt, int style, String title, String[] extensions, String[] filterNames) {
	FileDialog dialog = new FileDialog(getShell(), style);
	dialog.setText(title);
	dialog.setFilterExtensions(extensions);
	dialog.setFilterNames(filterNames);
	String fileSep = System.getProperty("file.separator");
	if (txt.getText() != null && !txt.getText().trim().equals("")) {
		dialog.setFilterPath(txt.getText().substring(0, txt.getText().lastIndexOf(fileSep)));
		dialog.setFileName(txt.getText().substring(txt.getText().lastIndexOf(fileSep) + 1));
	} else {
		dialog.setFilterPath(System.getProperty("user.home"));
	}
	String path = dialog.open();
	if (path != null) {
		txt.setText(path);
	}
}
 
源代码7 项目: xtext-eclipse   文件: ExportToFileAction.java
@Override
public void run() {
	IFigure contents = railroadView.getContents();
	if (contents != null) {
		FileDialog fileDialog = new FileDialog(this.railroadView.getSite().getShell(), SWT.SAVE);
		fileDialog.setFilterExtensions(new String[] { "*.png" });
		fileDialog.setText("Choose diagram file");
		String fileName = fileDialog.open();
		if (fileName == null) {
			return;
		}
		Dimension preferredSize = contents.getPreferredSize();
		Image image = new Image(Display.getDefault(), preferredSize.width + 2 * PADDING, preferredSize.height + 2
				* PADDING);
		GC gc = new GC(image);
		SWTGraphics graphics = new SWTGraphics(gc);
		graphics.translate(PADDING, PADDING);
		graphics.translate(contents.getBounds().getLocation().getNegated());
		contents.paint(graphics);
		ImageData imageData = image.getImageData();
		ImageLoader imageLoader = new ImageLoader();
		imageLoader.data = new ImageData[] { imageData };
		imageLoader.save(fileName, SWT.IMAGE_PNG);
	}
}
 
源代码8 项目: JDeodorant   文件: LongMethod.java
private void saveResults() {
	FileDialog fd = new FileDialog(getSite().getWorkbenchWindow().getShell(), SWT.SAVE);
	fd.setText("Save Results");
       String[] filterExt = { "*.txt" };
       fd.setFilterExtensions(filterExt);
       String selected = fd.open();
       if(selected != null) {
       	try {
       		BufferedWriter out = new BufferedWriter(new FileWriter(selected));
       		Tree tree = treeViewer.getTree();
       		/*TreeColumn[] columns = tree.getColumns();
       		for(int i=0; i<columns.length; i++) {
       			if(i == columns.length-1)
       				out.write(columns[i].getText());
       			else
       				out.write(columns[i].getText() + "\t");
       		}
       		out.newLine();*/
       		for(int i=0; i<tree.getItemCount(); i++) {
				TreeItem treeItem = tree.getItem(i);
				ASTSliceGroup group = (ASTSliceGroup)treeItem.getData();
				for(ASTSlice candidate : group.getCandidates()) {
					out.write(candidate.toString());
					out.newLine();
				}
			}
       		out.close();
       	} catch (IOException e) {
       		e.printStackTrace();
       	}
       }
}
 
源代码9 项目: tmxeditor8   文件: RTFCleanerDialog.java
/**
 * 处理 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"));
	}
}
 
源代码10 项目: tmxeditor8   文件: ImportProjectWizardPage2.java
protected void handleBrowseBtnPressed() {
	FileDialog dialog = new FileDialog(filePathTxt.getShell(), SWT.SHEET);
	dialog.setFilterExtensions(FILE_IMPORT_MASK);
	dialog.setText(Messages.getString("importProjectWizardPage.SelectArchiveDialogTitle"));

	String fileName = filePathTxt.getText().trim();
	if (fileName.length() == 0) {
		fileName = previouslyBrowsedPath;
	}

	if (fileName.length() == 0) {
		// IDEWorkbenchPlugin.getPluginWorkspace()
		dialog.setFilterPath(ResourcesPlugin.getWorkspace().getRoot().getLocation().toOSString());
	} else {
		File path = new File(fileName).getParentFile();
		if (path != null && path.exists()) {
			dialog.setFilterPath(path.toString());
		}
	}

	String selectedArchive = dialog.open();
	if (selectedArchive != null) {
		previouslyBrowsedPath = selectedArchive;
		filePathTxt.setText(previouslyBrowsedPath);
		
		// 先择新的项目包时,清除重复树中的所有内容
		checkedRepeatElementMap.clear();
		repeatElementTree.refresh(true);
		
		updateProjectsList(selectedArchive);
		// 初始化时全部初始化
		selectElementTree.expandAll();
		selectElementTreeBtnSelectFunction(true);
	}
}
 
源代码11 项目: gama   文件: ImportProjectWizardPage.java
/**
 * The browse button has been selected. Select the location.
 */
protected void handleLocationArchiveButtonPressed() {

	final FileDialog dialog = new FileDialog(archivePathField.getShell(), SWT.SHEET);
	dialog.setFilterExtensions(FILE_IMPORT_MASK);
	dialog.setText(DataTransferMessages.WizardProjectsImportPage_SelectArchiveDialogTitle);

	String fileName = archivePathField.getText().trim();
	if (fileName.length() == 0) {
		fileName = previouslyBrowsedArchive;
	}

	if (fileName.length() == 0) {
		dialog.setFilterPath(IDEWorkbenchPlugin.getPluginWorkspace().getRoot().getLocation().toOSString());
	} else {
		final File path = new File(fileName).getParentFile();
		if (path != null && path.exists()) {
			dialog.setFilterPath(path.toString());
		}
	}

	final String selectedArchive = dialog.open();
	if (selectedArchive != null) {
		previouslyBrowsedArchive = selectedArchive;
		archivePathField.setText(previouslyBrowsedArchive);
		updateProjectsList(selectedArchive);
	}

}
 
protected String openFileDialog(Shell shell) {
    final FileDialog fd = new FileDialog(shell, SWT.OPEN | SWT.SINGLE);
    fd.setText(Messages.importProcessTitle);
    fd.setFilterPath(getLastPath());
    fd.setFilterExtensions(new String[] { BOS_EXTENSION });
    return fd.open();
}
 
源代码13 项目: http4e   文件: AttachManager.java
public void widgetSelected( SelectionEvent event){
      FileDialog fd = new FileDialog(parent.getShell(), SWT.OPEN);
      fd.setText("Add File Content to Body");
      // fd.setFilterPath("C:/");
      fd.setFilterExtensions(CoreConstants.FILE_FILTER_EXT);
      String file = fd.open();
      
      if (file != null) {
         parent.setText(CoreConstants.FILE_PREFIX + file);
         model.fireExecute(new ModelEvent(ModelEvent.BODY_FOCUS_LOST, model));
//       force body to refresh itself
         model.fireExecute(new ModelEvent(ModelEvent.PARAMS_FOCUS_LOST, model)); 
      }
   }
 
源代码14 项目: XPagesExtensionLibrary   文件: BluemixUtil.java
public static String launchChooseFileDialog(String file, String[] filterExts, String[] filterNames) {
    FileDialog dlg = new FileDialog(Display.getCurrent().getActiveShell());
    dlg.setFileName(file);
    dlg.setText("Choose file"); // $NLX-BluemixUtil.Choosefile-1$
    dlg.setFilterExtensions(filterExts);
    dlg.setFilterNames(filterNames);
    return dlg.open();
}
 
源代码15 项目: gef   文件: LoadStopWordsAction.java
@Override
public void run(IAction action) {
	FileDialog dialog = new FileDialog(getShell(), SWT.OPEN);
	dialog.setText("Select a stopword file, containing one word per line...");
	String sourceFile = dialog.open();
	if (sourceFile == null)
		return;
	TypeCollector.setStopwords(sourceFile);
}
 
源代码16 项目: cppcheclipse   文件: TableEditor.java
protected File openExternalFile(String title) {
	Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow()
			.getShell();
	FileDialog fileDialog = new FileDialog(shell);
	fileDialog.setText(title);
	String file = fileDialog.open();
	if (file != null) {
		return new File(file);
	}
	return null;
}
 
源代码17 项目: mappwidget   文件: FileChooser.java
public String openFile()
{
	FileDialog dlg = new FileDialog(button.getShell(), SWT.OPEN);
	dlg.setFileName(text.getText());
	dlg.setFilterExtensions(new String[] { "*.gif; *.jpg; *.png; *.ico; *.bmp" });

	dlg.setText(OPEN);
	String path = dlg.open();

	return path;
}
 
源代码18 项目: birt   文件: ScriptMainTab.java
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;
}
 
源代码19 项目: bonita-studio   文件: AbstractExportAction.java
protected Optional<String> getPath(Shell shell, IRepositoryFileStore fStore) {
    final FileDialog fd = new FileDialog(shell, SWT.SAVE | SWT.SHEET);
    fd.setFileName(fStore.getName());
    fd.setFilterExtensions(new String[] { "*.xml" });
    fd.setText(getExportTitle());
    return Optional.ofNullable(fd.open());
}
 
源代码20 项目: spotbugs   文件: FilterFilesTab.java
@Override
protected void configureDialog(FileDialog dialog) {
    dialog.setFilterExtensions(new String[] { "*.xml" });
    dialog.setText(FindbugsPlugin.getDefault().getMessage(kind.propertyName) + ": select xml file(s) containing filters");
}