本文整理汇总了Java中org.eclipse.ui.dialogs.SaveAsDialog.setOriginalFile方法的典型用法代码示例。如果您正苦于以下问题:Java SaveAsDialog.setOriginalFile方法的具体用法?Java SaveAsDialog.setOriginalFile怎么用?Java SaveAsDialog.setOriginalFile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.ui.dialogs.SaveAsDialog
的用法示例。
在下文中一共展示了SaveAsDialog.setOriginalFile方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: validateLengthOfJobName
import org.eclipse.ui.dialogs.SaveAsDialog; //导入方法依赖的package包/类
/**
*
* Validates length of job name
*
* @param {@link SaveAsDialog}
*/
public void validateLengthOfJobName(SaveAsDialog saveAsDialog) {
String jobName=saveAsDialog.getResult().removeFileExtension().lastSegment();
while(jobName.length()>50)
{
jobName=saveAsDialog.getResult().removeFileExtension().lastSegment();
if(jobName.length()>50)
{
MessageBox messageBox = new MessageBox(new Shell(), SWT.ICON_ERROR | SWT.OK);
messageBox.setText("Error");
messageBox.setMessage("File Name Too Long");
if(messageBox.open()==SWT.OK)
{
saveAsDialog.setOriginalName(jobName+".job");
IFile file = ResourcesPlugin.getWorkspace().getRoot().getFile(saveAsDialog.getResult());
saveAsDialog.setOriginalFile(file);
saveAsDialog.open();
if(saveAsDialog.getReturnCode()==1)
break;
}
}
}
}
示例2: doSaveAs
import org.eclipse.ui.dialogs.SaveAsDialog; //导入方法依赖的package包/类
@Override
public void doSaveAs() {
SaveAsDialog saveas = new SaveAsDialog(getSite().getShell());
IFile saveAs = getSaveAsFile();
saveas.setOriginalFile(saveAs);
saveas.setOriginalName(saveAs.getName());
if (saveas.open() != SaveAsDialog.OK) {
return;
}
// get the file relatively to the workspace.
IFile saveFile = calcViewFile(saveas.getResult());
// TODO: set up a progress monitor
saveFile(saveFile, null, "saveAs");
baseName = buildFileInputBaseName(saveFile);
setPartName(saveFile.getName());
FileEditorInput effInput = new FileEditorInput(saveFile);
setInputWithNotify(effInput);
}
示例3: doSaveAs
import org.eclipse.ui.dialogs.SaveAsDialog; //导入方法依赖的package包/类
@Override
public void doSaveAs() {
SaveAsDialog saveas = new SaveAsDialog(getSite().getShell());
saveas.setOriginalFile(file);
saveas.setOriginalName(propInfo.getName());
if (saveas.open() != SaveAsDialog.OK) {
return;
}
// get the file relatively to the workspace.
IFile saveFile = WorkspaceTools.calcViewFile(
saveas.getResult(), RelationSetResources.EXTENSION);
// TODO: set up a progress monitor
file = saveFile;
handleDocumentChange();
persistDocument(null);
}
示例4: doSaveAs
import org.eclipse.ui.dialogs.SaveAsDialog; //导入方法依赖的package包/类
@Override
public void doSaveAs() {
SaveAsDialog saveas = new SaveAsDialog(getSite().getShell());
saveas.setOriginalFile(file);
saveas.setOriginalName(matcherInfo.getName());
if (saveas.open() != SaveAsDialog.OK) {
return;
}
// get the file relatively to the workspace.
IFile saveFile = WorkspaceTools.calcViewFile(
saveas.getResult(), GraphEdgeMatcherResources.EXTENSION);
// TODO: set up a progress monitor
file = saveFile;
handleDocumentChange();
persistDocument(null);
}
示例5: doSaveAs
import org.eclipse.ui.dialogs.SaveAsDialog; //导入方法依赖的package包/类
@Override
public void doSaveAs() {
SaveAsDialog saveas = new SaveAsDialog(getSite().getShell());
saveas.setOriginalFile(file);
saveas.setOriginalName(relSetInfo.getName());
if (saveas.open() != SaveAsDialog.OK) {
return;
}
// get the file relatively to the workspace.
IFile saveFile = WorkspaceTools.calcViewFile(
saveas.getResult(), RelationSetResources.EXTENSION);
// TODO: set up a progress monitor
file = saveFile;
handleDocumentChange();
persistDocument(null);
}
示例6: doSaveAs
import org.eclipse.ui.dialogs.SaveAsDialog; //导入方法依赖的package包/类
@Override
public void doSaveAs() {
SaveAsDialog saveAsDialog = new SaveAsDialog(getSite().getShell());
saveAsDialog.setOriginalFile(((FileEditorInput) getEditorInput()).getFile());
saveAsDialog.open();
IPath path = saveAsDialog.getResult();
if (path != null) {
IFile file = ResourcesPlugin.getWorkspace().getRoot().getFile(path);
if (file != null) {
IFileEditorInput modelFile = new FileEditorInput(file);
setInputWithNotify(modelFile);
setInput(modelFile);
setPartName(file.getName());
IProgressMonitor progressMonitor = getEditorSite().getActionBars().getStatusLineManager().getProgressMonitor();
doSave(progressMonitor);
}
}
}
示例7: doSaveAs
import org.eclipse.ui.dialogs.SaveAsDialog; //导入方法依赖的package包/类
@Override
public void doSaveAs() {
URI chartURI = getChartURI(true);
SaveAsDialog dlg = new SaveAsDialog(getSite().getShell());
dlg.setOriginalFile(EMFUtils.getFile(chartURI));
if (dlg.open() == Window.OK) {
IPath path = dlg.getResult();
URI newChartURI = EMFUtils.getURI(path);
try {
Resource resource = timelineModel.eResource();
resource.setURI(newChartURI);
resource.save(null);
dirtyMonitor.resetDirty();
setChartURI(newChartURI);
setInput(new FileEditorInput(EMFUtils.getFile(newChartURI)));
setPartName(newChartURI.lastSegment());
} catch (IOException e) {
LogUtil.error(e);
}
}
}
示例8: doSaveAs
import org.eclipse.ui.dialogs.SaveAsDialog; //导入方法依赖的package包/类
/**
*
*/
@Override
public void doSaveAs()
{
SaveAsDialog dialog = new SaveAsDialog(getSite().getShell());
dialog.setOriginalFile(((IFileEditorInput) getEditorInput()).getFile());
dialog.open();
IPath path = dialog.getResult();
if (path == null) // user clicked cancel
return;
IFile file = ResourcesPlugin.getWorkspace().getRoot().getFile(path);
super.setInput(new FileEditorInput(file));
doSave(null);
setPartName(file.getName());
}
示例9: doSaveAs
import org.eclipse.ui.dialogs.SaveAsDialog; //导入方法依赖的package包/类
@Override
public void doSaveAs()
{
SaveAsDialog dialog = new SaveAsDialog(getEditorSite().getShell());
dialog.setOriginalFile(file);
dialog.setTitle("Speichern unter");
int result = dialog.open();
if (result == Dialog.OK) try
{
SerializationManager.save(map, ResourcesPlugin.getWorkspace().getRoot().getFile(dialog.getResult()));
setDirty(false);
}
catch(ResourceException e)
{
showError("Datei konnte nicht gespeichert werden.", e);
}
}
示例10: handleProjectJarnameBrowse
import org.eclipse.ui.dialogs.SaveAsDialog; //导入方法依赖的package包/类
/**
* Uses the standard container selection dialog to choose the new value for
* the container field.
*/
private void handleProjectJarnameBrowse() {
String jarname = getJarname();
SaveAsDialog dialog = new SaveAsDialog(getShell());
String name = jarname;
if (name == null) {
name = "fatjar_output.jar";
}
IProject project = jproject.getProject();
IFile iFile = project.getFile(name);
dialog.setOriginalFile(iFile);
dialog.setTitle("Select Output Jar-Name"); //$NON-NLS-1$
if (dialog.open() == SaveAsDialog.OK) {
IPath saveFile = dialog.getResult();
if (saveFile != null) {
String path = saveFile.toString();
String projectName = jproject.getElementName();
if (!path.startsWith("/" + projectName + "/")) {
MessageDialog.openInformation(getShell(), "Fat Jar Select Output",
"output must be stored in project " + projectName);
} else {
if (!"jar".equals(saveFile.getFileExtension().toLowerCase()))
saveFile = saveFile.addFileExtension("jar");
saveFile = saveFile.removeFirstSegments(1).removeTrailingSeparator();
jarnameText.setText(saveFile.toOSString());
}
}
}
}
示例11: handleProjectJarnameBrowse
import org.eclipse.ui.dialogs.SaveAsDialog; //导入方法依赖的package包/类
/**
* Uses the standard container selection dialog to
* choose the new value for the container field.
*/
private void handleProjectJarnameBrowse() {
String jarname = getJarname();
SaveAsDialog dialog = new SaveAsDialog(getShell());
String name = jarname;
if (name == null) {
name = "fatjar_output.jar";
}
IFile iFile = jproject.getIFile(name);
dialog.setOriginalFile(iFile);
dialog.setTitle("Select Output Jar-Name"); //$NON-NLS-1$
if (dialog.open() == SaveAsDialog.OK) {
IPath saveFile= dialog.getResult();
if (saveFile != null) {
String path = saveFile.toString();
String projectName = jproject.getJproject().getElementName();
if (!path.startsWith("/" + projectName + "/")) {
MessageDialog.openInformation(getShell(), "Fat Jar Select Output", "output must be stored in project " + projectName);
}
else {
if (!"jar".equals(saveFile.getFileExtension().toLowerCase()))
saveFile = saveFile.addFileExtension("jar");
saveFile = saveFile.removeFirstSegments(1).removeTrailingSeparator();
jarnameText.setText(saveFile.toOSString());
}
}
}
}
示例12: handleSaveSettings
import org.eclipse.ui.dialogs.SaveAsDialog; //导入方法依赖的package包/类
private void handleSaveSettings() {
SaveAsDialog dialog = new SaveAsDialog(getShell());
String name = BuildFatJar.absPropertiesFilename;
if (name == null) {
name = "settings.fatjar";
}
int pos = name.lastIndexOf(File.separatorChar);
if (pos != -1) {
name = name.substring(pos+1);
}
IProject project = jproject.getJproject().getProject();
IFile iFile = project.getFile(name);
dialog.setOriginalFile(iFile);
// dialog.setOriginalName(name);
dialog.setTitle("Save FatJar Settings"); //$NON-NLS-1$
if (dialog.open() == SaveAsDialog.OK) {
IPath saveFile= dialog.getResult();
if (saveFile != null) {
String path = saveFile.toString();
String projectName = jproject.getJproject().getElementName();
if (!path.startsWith("/" + projectName + "/")) {
MessageDialog.openInformation(getShell(), "Fat Jar Save Settings", "settings must be stored in project " + projectName);
}
else {
if (!"fatjar".equals(saveFile.getFileExtension()))
saveFile = saveFile.addFileExtension("fatjar");
BuildProperties buildProps = fjew.getBuildProperties();
if (buildProps != null) {
saveConfig(saveFile, buildProps.toProperties());
}
}
}
}
}
示例13: handleExportANT
import org.eclipse.ui.dialogs.SaveAsDialog; //导入方法依赖的package包/类
private void handleExportANT() {
SaveAsDialog dialog = new SaveAsDialog(getShell());
String name = "build.xml";
IProject project = jproject.getJproject().getProject();
IFile iFile = project.getFile(name);
dialog.setOriginalFile(iFile);
// dialog.setOriginalName(name);
dialog.setTitle("Export ANT build file"); //$NON-NLS-1$
if (dialog.open() == SaveAsDialog.OK) {
IPath saveFile= dialog.getResult();
if (saveFile != null) {
String path = saveFile.toString();
String projectName = jproject.getJproject().getElementName();
if (!"xml".equals(saveFile.getFileExtension()))
saveFile = saveFile.addFileExtension("xml");
boolean ok = true;
IFile buildFile = project.getWorkspace().getRoot().getFile(saveFile);
if (buildFile != null) {
IStatus status = AguiPlugin.askFileWriteAccess(buildFile);
if ((status != null) && !status.isOK()) {
ok = false;
Shell shell = new Shell();
MessageDialog.openError(shell, "Fat Jar Plug-In Error", "Export ANT, write access denied: " + status.toString());
}
}
if (ok) {
SourceInfo[] sourceInfo = getANTBuildInfo();
exportANTBuild(saveFile, sourceInfo);
}
}
}
}
示例14: doSaveAsDialog
import org.eclipse.ui.dialogs.SaveAsDialog; //导入方法依赖的package包/类
private IFile doSaveAsDialog() {
SaveAsDialog saveas = new SaveAsDialog(getSite().getShell());
IFile saveAs = getSaveAsFile();
saveas.setOriginalFile(saveAs);
saveas.setOriginalName(saveAs.getName());
if (saveas.open() != SaveAsDialog.OK) {
return null;
}
// get the file relatively to the workspace.
IFile saveFile = WorkspaceTools.calcViewFile(
saveas.getResult(), NodeListDocument.EXTENSION);
return saveFile;
}
示例15: doSaveAs
import org.eclipse.ui.dialogs.SaveAsDialog; //导入方法依赖的package包/类
/**
* @see org.eclipse.ui.ISaveablePart#doSaveAs()
*/
public void doSaveAs() {
// Retrieves the file input.
IEditorInput editorInput = this.getEditorInput();
IFile ifile = null;
if (editorInput instanceof IFileEditorInput) {
ifile = ((IFileEditorInput) editorInput).getFile();
}
// ask user for file
SaveAsDialog saveAsDialog = new SaveAsDialog(getSite().getShell());
if (ifile != null) {
saveAsDialog.setOriginalFile(ifile);
}
saveAsDialog.open();
IPath path = saveAsDialog.getResult();
if (path != null) {
IFile ifileNew = ResourcesPlugin.getWorkspace().getRoot().getFile(path);
if (ifileNew != null) {
IProgressMonitor progressMonitor = getEditorSite().getActionBars().getStatusLineManager()
.getProgressMonitor();
// save now
doSave(progressMonitor, ifileNew, null);
// refresh editor to new file
setInput(new FileEditorInput(ifileNew));
}
}
}