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


Java DirectoryDialog類代碼示例

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


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

示例1: chooseTestClassesDirectory

import org.eclipse.swt.widgets.DirectoryDialog; //導入依賴的package包/類
/**
    * Open the dialog to chose a directory for the test case classes.
    */
protected void chooseTestClassesDirectory() {
	// Initialize the dialog.
	DirectoryDialog dialog = new DirectoryDialog(this.shell);
	dialog.setMessage("Please chose a directory for the test case classes.");
	// Check if the test cases directory exists.
	File file = new File(this.testClassesDirectoryText.getText());
	if (file.exists() && file.isDirectory()) {
		// Set as the start directory.
		dialog.setFilterPath(this.testClassesDirectoryText.getText());
	}

	// Open the dialog and process its result.
	String path = dialog.open();
	if (path != null) {
		// First of all replace double backslashes against slashes.
		path = path.replace("\\\\", "\\");

		// Convert backslashes to slashes.
		path = path.replace("\\", "/");

		// Set it as the text.
		this.testClassesDirectoryText.setText(path);
	}
}
 
開發者ID:wwu-pi,項目名稱:tap17-muggl-javaee,代碼行數:28,代碼來源:OptionsComposite.java

示例2: createContents

import org.eclipse.swt.widgets.DirectoryDialog; //導入依賴的package包/類
private void createContents() {
	GridLayoutFactory.swtDefaults().numColumns(2).applyTo(this);

	text = new Text(this, SWT.NONE);
	GridDataFactory.fillDefaults().grab(true, false).applyTo(text);

	Button button = new Button(this, SWT.PUSH);
	button.setText("Browse...");
	button.addSelectionListener(new SelectionAdapter() {
		@Override
		public void widgetSelected(SelectionEvent e) {
			DirectoryDialog fileDialog = new DirectoryDialog(getShell());
			// Set the text
			fileDialog.setText("Select directory");
			// Set filter on .txt files
			String selection = fileDialog.open();
			if (selection != null)
				text.setText(selection);
		}
	});
}
 
開發者ID:termsuite,項目名稱:termsuite-ui,代碼行數:22,代碼來源:BrowseDirText.java

示例3: promptForLocation

import org.eclipse.swt.widgets.DirectoryDialog; //導入依賴的package包/類
private File promptForLocation(final String dropPath) {
    final DirectoryDialog dialog = new DirectoryDialog(getShell());

    final String directoryPath = dialog.open();
    if (directoryPath != null) {
        final File targetFile = new File(directoryPath, dropPath);
        if (targetFile.exists()) {
            final String title = Messages.getString("BuildDropDownload.ConfirmOverwriteDialogTitle"); //$NON-NLS-1$
            final String messageFormat = Messages.getString("BuildDropDownload.ConfirmOverwriteDialogTextFormat"); //$NON-NLS-1$
            final String message = MessageFormat.format(messageFormat, targetFile.getAbsolutePath());

            if (!MessageBoxHelpers.dialogConfirmPrompt(getShell(), title, message)) {
                return null;
            }
        }
        return targetFile;
    }
    return null;

}
 
開發者ID:Microsoft,項目名稱:team-explorer-everywhere,代碼行數:21,代碼來源:OpenDropFolderAction.java

示例4: getNewDir

import org.eclipse.swt.widgets.DirectoryDialog; //導入依賴的package包/類
/**
 * @return
 */
protected String getNewDir() {
    final DirectoryDialog dialog = new DirectoryDialog(this.addDirButton.getShell());
    if ((this.lastPath != null) && new File(this.lastPath).exists()) {
        dialog.setFilterPath(this.lastPath);
    }
    String dir = dialog.open();
    if (dir != null) {
        dir = dir.trim();
        if (dir.length() == 0) {
            return null;
        }
        this.lastPath = dir;
    }
    return dir;
}
 
開發者ID:rajendarreddyj,項目名稱:eclipse-weblogic-plugin,代碼行數:19,代碼來源:ClasspathFieldEditor.java

示例5: saveAllAsText

import org.eclipse.swt.widgets.DirectoryDialog; //導入依賴的package包/類
public void saveAllAsText() {
	if (b.fileindex.size() == 0)
		return;
	String dir = b.projectFile.getParentFile().getAbsolutePath() + "\\Files\\";
	DirectoryDialog getdir = new DirectoryDialog(b);
	getdir.setText("ѡ�����Ŀ¼");
	String dirpath = getdir.open();
	if (dirpath != null && b.fileindex.size() > 0) {
		Iterator<String> it = b.fileindex.iterator();
		while (it.hasNext()) {
			String filename = it.next();
			File file = new File(dir + filename);
			if (file.exists()) {
				String outputname = getShowNameByRealName(filename);
				File output = new File(dirpath + "\\" + outputname + ".txt");
				ioThread io = new ioThread(b);
				String text = io.readBlackFile(file, null).get();
				if (!io.writeTextFile(output, text, "utf-8"))
					getMessageBox("ת���ļ�", "ת��" + outputname + "ʱʧ�ܣ�");
			}
		}
		getMessageBox("ת���ļ�", "�ѽ���Ŀ�е������ļ�ת������ѡ��Ŀ¼��");
		showinExplorer(dirpath, false);
	}
}
 
開發者ID:piiiiq,項目名稱:Black,代碼行數:26,代碼來源:blackAction.java

示例6: showDirectoryDialog

import org.eclipse.swt.widgets.DirectoryDialog; //導入依賴的package包/類
public static String showDirectoryDialog(String filePath, String message) {
	String fileName = null;

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

	DirectoryDialog dialog = new DirectoryDialog(PlatformUI.getWorkbench()
			.getActiveWorkbenchWindow().getShell(), SWT.NONE);

	dialog.setMessage(ResourceString.getResourceString(message));

	dialog.setFilterPath(fileName);

	return dialog.open();
}
 
開發者ID:kozake,項目名稱:ermaster-k,代碼行數:18,代碼來源:ERDiagramActivator.java

示例7: uploadDirectoryToDFS

import org.eclipse.swt.widgets.DirectoryDialog; //導入依賴的package包/類
/**
 * Implement the import action (upload directory from the current machine
 * to HDFS)
 * 
 * @param object
 * @throws SftpException
 * @throws JSchException
 * @throws InvocationTargetException
 * @throws InterruptedException
 */
private void uploadDirectoryToDFS(IStructuredSelection selection)
    throws InvocationTargetException, InterruptedException {

  // Ask the user which local directory to upload
  DirectoryDialog dialog =
      new DirectoryDialog(Display.getCurrent().getActiveShell(), SWT.OPEN
          | SWT.MULTI);
  dialog.setText("Select the local file or directory to upload");

  String dirName = dialog.open();
  final File dir = new File(dirName);
  List<File> files = new ArrayList<File>();
  files.add(dir);

  // TODO enable upload command only when selection is exactly one folder
  final List<DFSFolder> folders =
      filterSelection(DFSFolder.class, selection);
  if (folders.size() >= 1)
    uploadToDFS(folders.get(0), files);

}
 
開發者ID:Nextzero,項目名稱:hadoop-2.6.0-cdh5.4.3,代碼行數:32,代碼來源:DFSActionImpl.java

示例8: widgetSelected

import org.eclipse.swt.widgets.DirectoryDialog; //導入依賴的package包/類
@Override
public void widgetSelected(SelectionEvent e) {
	DirectoryDialog dialog = new DirectoryDialog(getShell(), SWT.OPEN | SWT.SHEET);
	if (TextUtils.isNullorEmpty(sdkLocationText.getText())) {
		dialog.setText(sdkLocationText.getText());
	} 
	String path = dialog.open();
	if (path != null) {
		sdkLocationText.setText(path);
		if (new File(path).exists()) {
			setSdkLocation(path);
		} else {
			cleanTable();
			AguiPlugin.displayError("Error", "Xml format is wrong");	
		}
	} else {
		cleanTable();
	}
}
 
開發者ID:thahn0720,項目名稱:agui_eclipse_plugin,代碼行數:20,代碼來源:AguiPreferencePage.java

示例9: run

import org.eclipse.swt.widgets.DirectoryDialog; //導入依賴的package包/類
@Override
public void run() {
	Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
	DirectoryDialog dialog = new DirectoryDialog(shell, SWT.OPEN);
	dialog.setMessage("Select the configuration folder of the openHAB runtime");
	String selection = dialog.open();
	if(selection!=null) {
		try {
			File file = new File(selection);
			if(isValidConfigurationFolder(file)) {
				ConfigurationFolderProvider.saveFolderToPreferences(selection);
				ConfigurationFolderProvider.setRootConfigurationFolder(new File(selection));
				viewer.setInput(ConfigurationFolderProvider.getRootConfigurationFolder());
			} else {
				MessageDialog.openError(shell, "No valid configuration directory", "The chosen directory is not a valid openHAB configuration" +
						" directory. Please choose a different one.");
			}
		} catch (CoreException e) {
			IStatus status = new Status(IStatus.ERROR, UIActivator.PLUGIN_ID,  "An error occurred while opening the configuration folder", e);
			ErrorDialog.openError(shell, "Cannot open configuration folder!", null, status);
		}
	}
}
 
開發者ID:andrey-desman,項目名稱:openhab-hdl,代碼行數:24,代碼來源:SelectConfigFolderAction.java

示例10: getDirectory

import org.eclipse.swt.widgets.DirectoryDialog; //導入依賴的package包/類
protected File getDirectory(final File startingDirectory) {
	final DirectoryDialog fileDialog = new DirectoryDialog(getShell(), SWT.OPEN | SWT.SHEET);
	if (dialogMessage != null && dialogMessage.get() != null) {
		fileDialog.setMessage(dialogMessage.get());
	}
	if (startingDirectory != null) {
		fileDialog.setFilterPath(startingDirectory.getPath());
	}
	else if (filterPath != null) {
		fileDialog.setFilterPath(filterPath.getPath());
	}
	String dir = fileDialog.open();
	if (dir != null) {
		dir = dir.trim();
		if (dir.length() > 0) {
			return new File(dir);
		}
	}
	return null;
}
 
開發者ID:Albertus82,項目名稱:JFaceUtils,代碼行數:21,代碼來源:EnhancedDirectoryFieldEditor.java

示例11: getNewInputObject

import org.eclipse.swt.widgets.DirectoryDialog; //導入依賴的package包/類
@Override
protected String getNewInputObject() {
	final DirectoryDialog dialog = new DirectoryDialog(getShell(), SWT.SHEET);
	if (dirChooserLabelText != null && dirChooserLabelText.get() != null) {
		dialog.setMessage(dirChooserLabelText.get());
	}
	if (lastPath != null && new File(lastPath).exists()) {
		dialog.setFilterPath(lastPath);
	}
	String dir = dialog.open();
	if (dir != null) {
		dir = dir.trim();
		if (dir.length() == 0) {
			return null;
		}
		lastPath = dir;
	}
	return dir;
}
 
開發者ID:Albertus82,項目名稱:JFaceUtils,代碼行數:20,代碼來源:LocalizedPathEditor.java

示例12: getDataDirectory

import org.eclipse.swt.widgets.DirectoryDialog; //導入依賴的package包/類
public static Path getDataDirectory() {
	String url = Activator.getCMakePath();
	if (url == null)
	{
		// create a dialog with ok and cancel buttons and a question icon
		DirectoryDialog dialog = new DirectoryDialog(Display.getDefault().getActiveShell(), SWT.ICON_QUESTION | SWT.OK| SWT.CANCEL);
		dialog.setText("Unable to find CMakeEnvironment");
		dialog.setMessage("Please specify path to the CMakeEnvironment");

		// open dialog and await user selection
		String returnCode = dialog.open();
		if(returnCode != null)
		{
			Activator.getDefault().getPreferenceStore().setValue("USE_CMAKE_PATH", returnCode);
		}
	}
		
	return new File(url).toPath();
}
 
開發者ID:USESystemEngineeringBV,項目名稱:cmake-eclipse-helper,代碼行數:20,代碼來源:PluginDataIO.java

示例13: getDirectory

import org.eclipse.swt.widgets.DirectoryDialog; //導入依賴的package包/類
/**
   * Helper that opens the directory chooser dialog.
   * @param startingDirectory The directory the dialog will open in.
   * @return File File or <code>null</code>.
   * 
   */
  private File getDirectory(File startingDirectory) {

      DirectoryDialog fileDialog = new DirectoryDialog(getShell(), SWT.OPEN | SWT.SHEET);
      if (startingDirectory != null) {
	fileDialog.setFilterPath(startingDirectory.getPath());
}
      else if (filterPath != null) {
      	fileDialog.setFilterPath(filterPath.getPath());
      }
      String dir = fileDialog.open();
      if (dir != null) {
          dir = dir.trim();
          if (dir.length() > 0) {
		return new File(dir);
	}
      }

      return null;
  }
 
開發者ID:nasa,項目名稱:OpenSPIFe,代碼行數:26,代碼來源:DirectoryFieldEditor.java

示例14: chooseExternalClassFolderEntries

import org.eclipse.swt.widgets.DirectoryDialog; //導入依賴的package包/類
/**
 * Shows the UI to select new external class folder entries.
 * The dialog returns the selected entry paths 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.
 * @return Returns the new external class folder path or <code>null</code> if the dialog has
 * been canceled by the user.
 *
 * @since 3.4
 */
public static IPath[] chooseExternalClassFolderEntries(Shell shell) {
	String lastUsedPath= JavaPlugin.getDefault().getDialogSettings().get(IUIConstants.DIALOGSTORE_LASTEXTJARFOLDER);
	if (lastUsedPath == null) {
		lastUsedPath= ""; //$NON-NLS-1$
	}
	DirectoryDialog dialog= new DirectoryDialog(shell, SWT.MULTI);
	dialog.setText(NewWizardMessages.BuildPathDialogAccess_ExtClassFolderDialog_new_title);
	dialog.setMessage(NewWizardMessages.BuildPathDialogAccess_ExtClassFolderDialog_new_description);
	dialog.setFilterPath(lastUsedPath);

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

	File file= new File(res);
	if (file.isDirectory())
		return new IPath[] { new Path(file.getAbsolutePath()) };

	return null;
}
 
開發者ID:trylimits,項目名稱:Eclipse-Postfix-Code-Completion,代碼行數:33,代碼來源:BuildPathDialogAccess.java

示例15: configureExternalClassFolderEntries

import org.eclipse.swt.widgets.DirectoryDialog; //導入依賴的package包/類
/**
 * Shows the UI to configure an external class folder.
 * 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 class folder path or <code>null</code> if the dialog has
 * been canceled by the user.
 *
 * @since 3.4
 */
public static IPath configureExternalClassFolderEntries(Shell shell, IPath initialEntry) {
	DirectoryDialog dialog= new DirectoryDialog(shell, SWT.SINGLE);
	dialog.setText(NewWizardMessages.BuildPathDialogAccess_ExtClassFolderDialog_edit_title);
	dialog.setMessage(NewWizardMessages.BuildPathDialogAccess_ExtClassFolderDialog_edit_description);
	dialog.setFilterPath(initialEntry.toString());

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

	File file= new File(res);
	if (file.isDirectory())
		return new Path(file.getAbsolutePath());

	return null;
}
 
開發者ID:trylimits,項目名稱:Eclipse-Postfix-Code-Completion,代碼行數:30,代碼來源:BuildPathDialogAccess.java


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