类org.eclipse.swt.widgets.FileDialog源码实例Demo

下面列出了怎么用org.eclipse.swt.widgets.FileDialog的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: hop   文件: SasInputDialog.java
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 );
      BaseTransformDialog.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 );
  }
}
 
/**
 * 打开文件对话框
 * @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);
	}
}
 
源代码3 项目: tmxeditor8   文件: XSLTransformationDialog.java
/**
 * 打开文件对话框
 * @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);
	}
}
 
源代码4 项目: astor   文件: ChartComposite.java
/**
 * Opens a file chooser and gives the user an opportunity to save the chart
 * in PNG format.
 *
 * @throws IOException if there is an I/O error.
 */
public void doSaveAs() throws IOException {
    FileDialog fileDialog = new FileDialog(this.canvas.getShell(), 
            SWT.SAVE);
    String[] extensions = { "*.png" };
    fileDialog.setFilterExtensions(extensions);
    String filename = fileDialog.open();
    if (filename != null) {
        if (isEnforceFileExtensions()) {
            if (!filename.endsWith(".png")) {
                filename = filename + ".png";
            }
        }
        //TODO replace getSize by getBounds ?
        ChartUtilities.saveChartAsPNG(new File(filename), this.chart, 
                this.canvas.getSize().x, this.canvas.getSize().y);
    }
}
 
源代码5 项目: tracecompass   文件: FilterView.java
@Override
public void run() {
    try {
        FileDialog dlg = TmfFileDialogFactory.create(new Shell(), SWT.SAVE);
        dlg.setFilterNames(new String[] { Messages.FilterView_FileDialogFilterName + " (*.xml)" }); //$NON-NLS-1$
        dlg.setFilterExtensions(new String[] { "*.xml" }); //$NON-NLS-1$

        String fn = dlg.open();
        if (fn != null) {
            TmfFilterXMLWriter writerXML = new TmfFilterXMLWriter(fRoot);
            writerXML.saveTree(fn);
        }

    } catch (ParserConfigurationException e) {
        Activator.getDefault().logError("Error parsing filter xml file", e); //$NON-NLS-1$
    }
}
 
源代码6 项目: pmTrans   文件: PmTrans.java
protected void importText() {
	if (!textEditor.isDisposed()) {
		FileDialog fd = new FileDialog(shell, SWT.OPEN);
		fd.setText("Open");
		String[] filterExt = { "*.txt;*.TXT" };
		String[] filterNames = { "TXT 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) {
			importTextFile(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...
			}
		}
	}
}
 
源代码7 项目: birt   文件: ClassPathBlock.java
public static IPath configureExternalJAREntry( Shell shell,
		IPath initialEntry )
{
	if ( initialEntry == null )
	{
		throw new IllegalArgumentException( );
	}

	String lastUsedPath = initialEntry.removeLastSegments( 1 ).toOSString( );

	FileDialog dialog = new FileDialog( shell, SWT.SINGLE );
	dialog.setText( Messages.getString( "ClassPathBlock_FileDialog.edit.text" ) ); //$NON-NLS-1$
	dialog.setFilterExtensions( JAR_ZIP_FILTER_EXTENSIONS );
	dialog.setFilterPath( lastUsedPath );
	dialog.setFileName( initialEntry.lastSegment( ) );

	String res = dialog.open( );
	if ( res == null )
	{
		return null;
	}
	//lastUsedPath = dialog.getFilterPath( );

	return Path.fromOSString( res ).makeAbsolute( );
}
 
源代码8 项目: neoscada   文件: HiveTab.java
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 ();
    }
}
 
源代码9 项目: ECG-Viewer   文件: ChartComposite.java
/**
 * Opens a file chooser and gives the user an opportunity to save the chart
 * in PNG format.
 *
 * @throws IOException if there is an I/O error.
 */
public void doSaveAs() throws IOException {
    FileDialog fileDialog = new FileDialog(this.canvas.getShell(),
            SWT.SAVE);
    String[] extensions = {"*.png"};
    fileDialog.setFilterExtensions(extensions);
    String filename = fileDialog.open();
    if (filename != null) {
        if (isEnforceFileExtensions()) {
            if (!filename.endsWith(".png")) {
                filename = filename + ".png";
            }
        }
        //TODO replace getSize by getBounds ?
        ChartUtilities.saveChartAsPNG(new File(filename), this.chart,
                this.canvas.getSize().x, this.canvas.getSize().y);
    }
}
 
/**
 * 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);
        }
    }
}
 
源代码11 项目: http4e   文件: ParamsAttachManager.java
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));
   }
}
 
源代码12 项目: astor   文件: ChartComposite.java
/**
 * Opens a file chooser and gives the user an opportunity to save the chart
 * in PNG format.
 *
 * @throws IOException if there is an I/O error.
 */
public void doSaveAs() throws IOException {
    FileDialog fileDialog = new FileDialog(this.canvas.getShell(),
            SWT.SAVE);
    String[] extensions = {"*.png"};
    fileDialog.setFilterExtensions(extensions);
    String filename = fileDialog.open();
    if (filename != null) {
        if (isEnforceFileExtensions()) {
            if (!filename.endsWith(".png")) {
                filename = filename + ".png";
            }
        }
        //TODO replace getSize by getBounds ?
        ChartUtilities.saveChartAsPNG(new File(filename), this.chart,
                this.canvas.getSize().x, this.canvas.getSize().y);
    }
}
 
源代码13 项目: http4e   文件: ExportHTTP4eAction.java
public void run(){

      try {

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

         fileDialog.setFileName("sessions.http4e");
         fileDialog.setFilterNames(new String[] { "HTTP4e File *.http4e (HTTP4e all tab sessions)" });
         fileDialog.setFilterExtensions(new String[] { "*.http4e" });
         fileDialog.setText("Save As HTTP4e replay script");
         fileDialog.setFilterPath(getUserHomeDir());

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

      } catch (Exception e) {
         ExceptionHandler.handle(e);
      }
   }
 
源代码14 项目: tracecompass   文件: ExportToTextCommandHandler.java
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
    List<TmfEventTableColumn> columns = getColumns(event.getApplicationContext());
    ITmfTrace trace = TmfTraceManager.getInstance().getActiveTrace();
    ITmfFilter filter = TmfTraceManager.getInstance().getCurrentTraceContext().getFilter();
    if (trace != null) {
        FileDialog fd = TmfFileDialogFactory.create(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), SWT.SAVE);
        fd.setFilterExtensions(new String[] { "*.csv", "*.*", "*" }); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
        fd.setOverwrite(true);
        final String s = fd.open();
        if (s != null) {
            Job j = new ExportToTextJob(trace, filter, columns, s);
            j.setUser(true);
            j.schedule();
        }
    }
    return null;
}
 
源代码15 项目: olca-app   文件: FileChooser.java
private static String openFileDialog(Shell shell, String extension,
		String defaultName, String filterPath, int swtFlag) {
	FileDialog dialog = new FileDialog(shell, swtFlag);
	dialog.setText(getDialogText(swtFlag));
	String ext = null;
	if (extension != null) {
		ext = extension.trim();
		if (ext.contains("|"))
			ext = ext.substring(0, ext.indexOf("|")).trim();
		dialog.setFilterExtensions(new String[] { ext });
	}
	dialog.setFileName(defaultName);
	if (filterPath != null)
		dialog.setFilterPath(filterPath);
	if (extension != null) {
		if (extension.contains("|")) {
			String label = extension.substring(extension.indexOf("|") + 1);
			label += " (" + ext + ")";
			dialog.setFilterNames(new String[] { label });
		}
	}
	return dialog.open();
}
 
源代码16 项目: ermaster-b   文件: Activator.java
/**
 * �ۑ��_�C�A���O��\�����܂�
 *
 * @param filePath
 *            �f�t�H���g�̃t�@�C���p�X
 * @param filterExtensions
 *            �g���q
 * @return �ۑ��_�C�A���O�őI�����ꂽ�t�@�C���̃p�X
 */
public static String showSaveDialog(String filePath,
		String[] filterExtensions) {
	String dir = null;
	String fileName = null;

	if (filePath != null && !"".equals(filePath.trim())) {
		File file = new File(filePath.trim());

		dir = file.getParent();
		fileName = file.getName();
	}

	FileDialog fileDialog = new FileDialog(PlatformUI.getWorkbench()
			.getActiveWorkbenchWindow().getShell(), SWT.SAVE);

	fileDialog.setFilterPath(dir);
	fileDialog.setFileName(fileName);

	fileDialog.setFilterExtensions(filterExtensions);

	return fileDialog.open();
}
 
源代码17 项目: SIMVA-SoS   文件: ChartComposite.java
/**
 * Opens a file chooser and gives the user an opportunity to save the chart
 * in PNG format.
 *
 * @throws IOException if there is an I/O error.
 */
public void doSaveAs() throws IOException {
    FileDialog fileDialog = new FileDialog(this.canvas.getShell(),
            SWT.SAVE);
    String[] extensions = {"*.png"};
    fileDialog.setFilterExtensions(extensions);
    String filename = fileDialog.open();
    if (filename != null) {
        if (isEnforceFileExtensions()) {
            if (!filename.endsWith(".png")) {
                filename = filename + ".png";
            }
        }
        //TODO replace getSize by getBounds ?
        ChartUtilities.saveChartAsPNG(new File(filename), this.chart,
                this.canvas.getSize().x, this.canvas.getSize().y);
    }
}
 
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);
	}
}
 
/**
 * Shows the UI to configure an external JAR or ZIP archive.
 * The dialog returns the configured or <code>null</code> if the dialog has
 * been canceled. The dialog does not apply any changes.
 *
 * @param shell The parent shell for the dialog.
 * @param initialEntry The path of the initial archive entry.
 * @return Returns the configured external JAR path or <code>null</code> if the dialog has
 * been canceled by the user.
 */
public static IPath configureExternalJAREntry(Shell shell, IPath initialEntry) {
	if (initialEntry == null) {
		throw new IllegalArgumentException();
	}

	String lastUsedPath= initialEntry.removeLastSegments(1).toOSString();

	FileDialog dialog= new FileDialog(shell, SWT.SINGLE);
	dialog.setText(NewWizardMessages.BuildPathDialogAccess_ExtJARArchiveDialog_edit_title);
	dialog.setFilterExtensions(ArchiveFileFilter.JAR_ZIP_FILTER_EXTENSIONS);
	dialog.setFilterPath(lastUsedPath);
	dialog.setFileName(initialEntry.lastSegment());

	String res= dialog.open();
	if (res == null) {
		return null;
	}
	JavaPlugin.getDefault().getDialogSettings().put(IUIConstants.DIALOGSTORE_LASTEXTJAR, dialog.getFilterPath());

	return Path.fromOSString(res).makeAbsolute();
}
 
源代码20 项目: birt   文件: JdbcDriverManagerDialog.java
/**
 * actions after add button is click in jarPage
 */
private void addJars( )
{
	jarChanged=true;
	FileDialog dlg = new FileDialog( getShell( ), SWT.MULTI );
	dlg.setFilterExtensions( new String[]{
		"*.jar", "*.zip" //$NON-NLS-1$, $NON-NLS-2$
		} );

	if ( dlg.open( ) != null )
	{
		String jarNames[] = dlg.getFileNames( );
		String folder = dlg.getFilterPath( ) + File.separator;
		for( int i = 0; i < jarNames.length; i++ )
		{
			addSingleJar( folder + jarNames[i], jarNames[i] );
		}
		refreshJarViewer( );

		updateJarButtons( );
	}
}
 
源代码21 项目: tmxeditor8   文件: PluginConfigManageDialog.java
/**
 * 选择文件
 * @param title
 * @param extensions
 * @param names
 * @return ;
 */
private String browseFile(String title, String[] extensions, String[] names) {
	FileDialog fd = new FileDialog(getShell(), SWT.OPEN);
	fd.setText(title);
	if (extensions != null) {
		fd.setFilterExtensions(extensions);
	}
	if (names != null) {
		fd.setFilterNames(names);
	}
	return fd.open();
}
 
源代码22 项目: 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);
	}

}
 
源代码23 项目: 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;
}
 
源代码24 项目: nebula   文件: AbstractPictureControl.java
/**
 * Configure the {@link FileDialog} to set the file extension, the text,
 * etc. This method can be override to custome the configuration.
 *
 * @param fd
 */
protected void configure(FileDialog fd) {
	fd.setText(resources.getString(PICTURE_CONTROL_FILEDIALOG_TEXT));
	if (extensions != null) {
		fd.setFilterExtensions(extensions);
	}
}
 
源代码25 项目: APICloud-Studio   文件: FormatterModifyDialog.java
private void saveButtonPressed()
{
	// IProfileStore store = formatterFactory.getProfileStore();
	IProfileStore store = ProfileManager.getInstance().getProfileStore();
	IProfile selected = manager.create(dialogOwner.getProject(), ProfileKind.TEMPORARY,
			fProfileNameField.getText(), getPreferences(), profile.getVersion());

	final FileDialog dialog = new FileDialog(getShell(), SWT.SAVE);
	dialog.setText(FormatterMessages.FormatterModifyDialog_exportProfile);
	dialog.setFilterExtensions(new String[] { "*.xml" }); //$NON-NLS-1$

	final String path = dialog.open();
	if (path == null)
		return;

	final File file = new File(path);
	String message = NLS.bind(FormatterMessages.FormatterModifyDialog_replaceFileQuestion, file.getAbsolutePath());
	if (file.exists()
			&& !MessageDialog.openQuestion(getShell(), FormatterMessages.FormatterModifyDialog_exportProfile,
					message))
	{
		return;
	}

	final Collection<IProfile> profiles = new ArrayList<IProfile>();
	profiles.add(selected);
	try
	{
		// TODO - WRITE ALL PROFILES
		store.writeProfilesToFile(profiles, file);
	}
	catch (CoreException e)
	{
		final String title = FormatterMessages.FormatterModifyDialog_exportProfile;
		message = FormatterMessages.FormatterModifyDialog_exportProblem;
		ExceptionHandler.handle(e, getShell(), title, message);
	}
}
 
源代码26 项目: elexis-3-core   文件: PerspektiveExportHandler.java
@Override
public Object execute(ExecutionEvent event) throws ExecutionException{
	FileDialog dialog = new FileDialog(UiDesk.getTopShell(), SWT.SAVE);
	dialog.setFilterNames(new String[] {
		"XMI"
	});
	dialog.setFilterExtensions(new String[] {
		"*.xmi"
	});
	
	dialog.setFilterPath(CoreHub.getWritableUserDir().getAbsolutePath());
	dialog.setFileName("perspective_export.xmi");
	
	String path = dialog.open();
	if (path != null) {
		try {
			perspectiveExportService.exportPerspective(path, null, null);
			MessageDialog.openInformation(UiDesk.getDisplay().getActiveShell(), "Export",
				"Die aktuelle Perspektive wurde erfolgreich exportiert.");
		} catch (IOException e) {
			MessageDialog.openError(UiDesk.getDisplay().getActiveShell(), "Export",
				"Die aktuelle Perspektive kann nicht exportiert werden.");
			LoggerFactory.getLogger(PerspektiveExportHandler.class).error("export error", e);
		}
	}
	return null;
}
 
源代码27 项目: tmxeditor8   文件: ExportToExcelCommandHandler.java
/**
 * Override this to plugin custom OutputStream.
 */
protected OutputStream getOutputStream(ExportToExcelCommand command) throws IOException {
	FileDialog dialog = new FileDialog (command.getShell(), SWT.SAVE);
	dialog.setFilterPath ("/");
	dialog.setOverwrite(true);

	dialog.setFileName ("table_export.xls");
	dialog.setFilterExtensions(new String [] {"Microsoft Office Excel Workbook(.xls)"});
	String fileName = dialog.open();
	if(fileName == null){
		return null;
	}
	return new PrintStream(fileName);
}
 
源代码28 项目: birt   文件: ImageDialog.java
private void createLocalBrowseButton( Composite innerComp )
{
	browseButton = new Button( innerComp, SWT.PUSH );
	browseButton.setText( Messages.getString( "ImageDialog.label.Browse" ) ); //$NON-NLS-1$
	browseButton.setLayoutData( new GridData( GridData.HORIZONTAL_ALIGN_END ) );
	browseButton.addSelectionListener( new SelectionAdapter( ) {

		@Override
		public void widgetSelected( SelectionEvent event )
		{
			FileDialog fileChooser = new FileDialog( getShell( ),
					SWT.OPEN );
			fileChooser.setText( Messages.getString( "ImageDialog.label.SelectFile" ) ); //$NON-NLS-1$
			fileChooser.setFilterExtensions( new String[]{
					"*.gif", "*.jpg", "*.png" //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
			} );
			try
			{
				String fullPath = fileChooser.open( );
				if ( fullPath != null )
				{
					String fileName = fileChooser.getFileName( );
					if ( fileName != null )
					{
						imageData = null;
						fullPath = new StringBuffer( "file:///" ).append( fullPath ).toString( ); //$NON-NLS-1$
						uriEditor.setText( fullPath );
					}
				}
			}
			catch ( Throwable e )
			{
				e.printStackTrace( );
			}
		}
	} );
}
 
private void saveButtonPressed() {
	Profile selected= new CustomProfile(fProfileNameField.getText(), new HashMap<String, String>(fWorkingValues), fProfile.getVersion(), fProfileManager.getProfileVersioner().getProfileKind());

	final FileDialog dialog= new FileDialog(getShell(), SWT.SAVE);
	dialog.setText(FormatterMessages.CodingStyleConfigurationBlock_save_profile_dialog_title);
	dialog.setFilterExtensions(new String [] {"*.xml"}); //$NON-NLS-1$

	final String lastPath= JavaPlugin.getDefault().getDialogSettings().get(fLastSaveLoadPathKey + ".savepath"); //$NON-NLS-1$
	if (lastPath != null) {
		dialog.setFilterPath(lastPath);
	}
	final String path= dialog.open();
	if (path == null)
		return;

	JavaPlugin.getDefault().getDialogSettings().put(fLastSaveLoadPathKey + ".savepath", dialog.getFilterPath()); //$NON-NLS-1$

	final File file= new File(path);
	if (file.exists() && !MessageDialog.openQuestion(getShell(), FormatterMessages.CodingStyleConfigurationBlock_save_profile_overwrite_title, Messages.format(FormatterMessages.CodingStyleConfigurationBlock_save_profile_overwrite_message, BasicElementLabels.getPathLabel(file)))) {
		return;
	}
	String encoding= ProfileStore.ENCODING;
	final IContentType type= Platform.getContentTypeManager().getContentType("org.eclipse.core.runtime.xml"); //$NON-NLS-1$
	if (type != null)
		encoding= type.getDefaultCharset();
	final Collection<Profile> profiles= new ArrayList<Profile>();
	profiles.add(selected);
	try {
		fProfileStore.writeProfilesToFile(profiles, file, encoding);
	} catch (CoreException e) {
		final String title= FormatterMessages.CodingStyleConfigurationBlock_save_profile_error_title;
		final String message= FormatterMessages.CodingStyleConfigurationBlock_save_profile_error_message;
		ExceptionHandler.handle(e, getShell(), title, message);
	}
}
 
源代码30 项目: tmxeditor8   文件: TMXValidatorDialog.java
/**
 * 打开文件
 */
private void openFile() {
	FileDialog fd = new FileDialog(getShell(), SWT.OPEN);
	String[] extensions = { "*.tmx", "*.*" }; //$NON-NLS-1$ //$NON-NLS-2$
	fd.setFilterExtensions(extensions);
	String[] names = { Messages.getString("dialog.TMXValidatorDialog.names1"),
			Messages.getString("dialog.TMXValidatorDialog.names2") };
	fd.setFilterNames(names);
	String name = fd.open();
	if (name != null) {
		validate(name);
	}
}
 
 类所在包
 同包方法