本文整理汇总了Java中org.eclipse.emf.common.ui.dialogs.WorkspaceResourceDialog类的典型用法代码示例。如果您正苦于以下问题:Java WorkspaceResourceDialog类的具体用法?Java WorkspaceResourceDialog怎么用?Java WorkspaceResourceDialog使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
WorkspaceResourceDialog类属于org.eclipse.emf.common.ui.dialogs包,在下文中一共展示了WorkspaceResourceDialog类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: getFileFromDialog
import org.eclipse.emf.common.ui.dialogs.WorkspaceResourceDialog; //导入依赖的package包/类
private IFile getFileFromDialog(WorkspaceResourceDialog dialog) {
String fileName = dialog.getFileText();
IContainer container = null;
IFile[] files = dialog.getSelectedFiles();
if (files.length != 0) {
IFile file = files[0];
if (fileName.isEmpty() || file.getName().equals(fileName)) {
return file;
}
container = file.getParent();
} else {
IContainer[] containers = dialog.getSelectedContainers();
if (containers.length != 0) {
container = containers[0];
}
}
if (container != null && !fileName.isEmpty()) {
return container.getFile(new Path(fileName));
}
return null;
}
开发者ID:nasa,项目名称:OpenSPIFe,代码行数:22,代码来源:IFileFieldEditor.java
示例2: getDirectory
import org.eclipse.emf.common.ui.dialogs.WorkspaceResourceDialog; //导入依赖的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 IContainer getDirectory(Object resource) {
String project = (baseURI != null ? baseURI.segment(1) : null);
Shell shell = getShell();
WorkspaceLabelProvider labelProvider = new WorkspaceLabelProvider();
WorkbenchContentProvider contentProvider = new WorkbenchContentProvider();
WorkspaceResourceDialog dialog = new WorkspaceResourceDialog(shell, labelProvider, contentProvider);
dialog.setAllowMultiple(false);
String decodedProject = CommonUtils.decodeUTF8(project);
dialog.setTitle(project != null ? decodedProject : CommonUIPlugin.INSTANCE.getString("_UI_FileSelection_title"));
//$NON-NLS-1$
dialog.setMessage(null);
dialog.setShowNewFolderControl(true);
dialog.addFilter(dialog.createDefaultViewerFilter(false));
dialog.addFilter(new DirectoryPatternFilter());
IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
Object input = (project != null ? root.getProject(decodedProject) : null);
if (input == null) {
input = root;
}
dialog.setInput(input);
dialog.setInitialSelection(resource);
if (dialog.open() == Window.OK) {
IContainer[] containers = dialog.getSelectedContainers();
if (containers.length != 0) {
IContainer container = containers[0];
getTextControl().setFocus();
return container;
}
}
return null;
}
开发者ID:nasa,项目名称:OpenSPIFe,代码行数:41,代码来源:IDirectoryFieldEditor.java
示例3: askForNewResource
import org.eclipse.emf.common.ui.dialogs.WorkspaceResourceDialog; //导入依赖的package包/类
public static URI askForNewResource(String message) {
final URI resourceURI = toURI(
WorkspaceResourceDialog.openNewFile(getShell(), "Select new resource", message, null, null));
return resourceURI;
}
开发者ID:vitruv-tools,项目名称:Vitruv,代码行数:6,代码来源:EclipseUIBridge.java
示例4: createOptions
import org.eclipse.emf.common.ui.dialogs.WorkspaceResourceDialog; //导入依赖的package包/类
private void createOptions() {
addOption(KEY_PACKAGE_NAME, MelangeTemplateMessages.SimpleMTTemplate_packageName,
MelangeTemplateMessages.SimpleMTTemplate_packageNameToolTip,
(String) null, 0);
addOption(KEY_MELANGE_FILE_NAME, MelangeTemplateMessages.SimpleMTTemplate_melangeFileName,
MelangeTemplateMessages.SimpleMTTemplate_melangeFileNameTooltip,
MELANGE_FILE_NAME, 0);
addOption(KEY_METAMODEL_NAME, MelangeTemplateMessages.SimpleMTTemplate_melangeMetamodelName,
MelangeTemplateMessages.SimpleMTTemplate_melangeMetamodelNameToolTip,
METAMODEL_NAME, 0);
TemplateOption ecoreLocationOption = new AbstractStringWithButtonOption(this, KEY_ECOREFILE_PATH,
MelangeTemplateMessages.SimpleMTTemplate_ecoreFileLocation,
MelangeTemplateMessages.SimpleMTTemplate_ecoreFileLocationTooltip) {
@Override
public String doSelectButton() {
final IWorkbenchWindow workbenchWindow = PlatformUI
.getWorkbench().getActiveWorkbenchWindow();
Object selection = null;
if (workbenchWindow.getSelectionService().getSelection() instanceof IStructuredSelection) {
selection = ((IStructuredSelection) workbenchWindow
.getSelectionService().getSelection())
.getFirstElement();
}
final IFile selectedEcoreFile = selection != null
&& selection instanceof IFile
&& FILE_EXTENSIONS.contains(((IFile) selection)
.getFileExtension()) ? (IFile) selection : null;
ViewerFilter viewerFilter = new ViewerFilter() {
@Override
public boolean select(Viewer viewer, Object parentElement,
Object element) {
if (element instanceof IFile) {
IFile file = (IFile) element;
return FILE_EXTENSIONS.contains(file
.getFileExtension())
&& (selectedEcoreFile == null || !selectedEcoreFile
.getFullPath().equals(
file.getFullPath()));
}
return true;
}
};
final IFile[] files = WorkspaceResourceDialog
.openFileSelection(workbenchWindow.getShell(), null,
"Select ecore", true, null,
Collections.singletonList(viewerFilter));
if (files.length > 0) {
SimpleMTTemplate.this.ecoreIFile = files[0];
//txtPathEcore.setText(files[i].getFullPath().toOSString());
SimpleMTTemplate.this.ecoreProjectPath = files[0].getProject().getFullPath().toString();
String ecorePath = files[0].getFullPath().toString();
if(ecorePath.charAt(0) == '/')
ecorePath = ecorePath.substring(1);
return ecorePath;
}
return null;
}
};
ecoreLocationOption.setRequired(false);
registerOption(ecoreLocationOption, (String) null, 0);
}
开发者ID:diverse-project,项目名称:melange,代码行数:63,代码来源:SimpleMTTemplate.java
示例5: getFile
import org.eclipse.emf.common.ui.dialogs.WorkspaceResourceDialog; //导入依赖的package包/类
/**
* Helper to open the file chooser dialog.
*
* @param startingDirectory
* the directory to open the dialog on.
* @return File The File the user selected or <code>null</code> if they do not.
*/
private IFile getFile(IResource resource) {
String project = (baseURI != null ? baseURI.segment(1) : null);
Shell shell = getShell();
WorkspaceLabelProvider labelProvider = new WorkspaceLabelProvider();
WorkbenchContentProvider contentProvider = new WorkbenchContentProvider();
final WorkspaceResourceDialog dialog = new WorkspaceResourceDialog(shell, labelProvider, contentProvider) {
@Override
protected void fileTextModified(String text) {
super.fileTextModified(text);
updateOKStatus();
}
};
dialog.setAllowMultiple(false);
String decodedProject = CommonUtils.decodeUTF8(project);
dialog.setTitle(project != null ? decodedProject : CommonUIPlugin.INSTANCE.getString("_UI_FileSelection_title"));//$NON-NLS-1$
dialog.setMessage(null);
dialog.setShowNewFolderControl(true);
if (style == SWT.SAVE) {
dialog.setShowFileControl(true);
}
dialog.addFilter(dialog.createDefaultViewerFilter(true));
dialog.addFilter(new FilePatternFilter());
IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
Object input = (project != null ? root.getProject(decodedProject) : null);
if (input == null) {
input = root;
}
dialog.setValidator(new ISelectionStatusValidator() {
@Override
public IStatus validate(Object[] selection) {
if (selection.length == 0) {
return new Status(IStatus.ERROR, Activator.PLUGIN_ID, MUST_SELECT_AN_OUTPUT_FOLDER);
} else if (selection.length > 0) {
Object s = selection[0];
if (s instanceof IFile) {
return hasValidExtension(((IFile) s).getName());
}
}
return hasValidExtension(dialog.getFileText());
}
});
dialog.setInput(input);
dialog.setInitialSelection(resource);
if (dialog.open() == Window.OK) {
IFile file = getFileFromDialog(dialog);
if (file != null) {
getTextControl().setFocus();
return file;
}
}
return null;
}
开发者ID:nasa,项目名称:OpenSPIFe,代码行数:63,代码来源:IFileFieldEditor.java
示例6: createOptions
import org.eclipse.emf.common.ui.dialogs.WorkspaceResourceDialog; //导入依赖的package包/类
protected void createOptions() {
//addOption(KEY_PACKAGE_NAME, K3TemplateMessages.UserEcoreBasicAspectTemplate_packageName, (String) null, 0);
addBlankField(0).setLabel(K3TemplateMessages.UserEcoreBasicAspectTemplate_desc_complement_part1);
addBlankField(0).setLabel(K3TemplateMessages.UserEcoreBasicAspectTemplate_desc_complement_part2);
addOption(KEY_ASPECTBASEPACKAGE_NAME, K3TemplateMessages.UserEcoreBasicAspectTemplate_aspectBasePackageName,
K3TemplateMessages.UserEcoreBasicAspectTemplate_aspectBasePackageNameToolTip,
ASPECTBASEPACKAGE_NAME, 0).setRequired(false);
addOption(KEY_ASPECTPACKAGE_POSTFIX, K3TemplateMessages.UserEcoreBasicAspectTemplate_aspectPackagePostfix,
K3TemplateMessages.UserEcoreBasicAspectTemplate_aspectPackagePostfixToolTip,
ASPECTPACKAGE_POSTFIX, 0).setRequired(false);
addOption(KEY_ASPECTFILE_NAME, K3TemplateMessages.UserEcoreBasicAspectTemplate_aspectFileName,
K3TemplateMessages.UserEcoreBasicAspectTemplate_aspectFileNameToolTip,
ASPECTFILE_NAME, 0);
addOption(KEY_ASPECTCLASS_POSTFIX, K3TemplateMessages.UserEcoreBasicAspectTemplate_aspectClassPostfix,
K3TemplateMessages.UserEcoreBasicAspectTemplate_aspectClassPostfixToolTip,
ASPECTCLASS_POSTFIX, 0);
addBlankField(0);
addOption(KEY_ECOREBASEPACKAGE_NAME, K3TemplateMessages.UserEcoreBasicAspectTemplate_ecoreBasePackageName,
K3TemplateMessages.UserEcoreBasicAspectTemplate_ecoreBasePackageNameToolTip,
null, 0).setRequired(false);
//addOption(KEY_ECOREFILE_LOCATION, K3TemplateMessages.UserEcoreBasicAspectTemplate_ecoreFileLocation, (String) null, 0);
TemplateOption ecoreLocationOption = new AbstractStringWithButtonOption(this, KEY_ECOREFILE_PATH, K3TemplateMessages.UserEcoreBasicAspectTemplate_ecoreFilePath) {
@Override
public String doSelectButton() {
final IWorkbenchWindow workbenchWindow = PlatformUI
.getWorkbench().getActiveWorkbenchWindow();
Object selection = null;
if (workbenchWindow.getSelectionService().getSelection() instanceof IStructuredSelection) {
selection = ((IStructuredSelection) workbenchWindow
.getSelectionService().getSelection())
.getFirstElement();
}
final IFile selectedEcoreFile = selection != null
&& selection instanceof IFile
&& FILE_EXTENSIONS.contains(((IFile) selection)
.getFileExtension()) ? (IFile) selection : null;
ViewerFilter viewerFilter = new ViewerFilter() {
@Override
public boolean select(Viewer viewer, Object parentElement,
Object element) {
if (element instanceof IFile) {
IFile file = (IFile) element;
return FILE_EXTENSIONS.contains(file
.getFileExtension())
&& (selectedEcoreFile == null || !selectedEcoreFile
.getFullPath().equals(
file.getFullPath()));
}
return true;
}
};
final IFile[] files = WorkspaceResourceDialog
.openFileSelection(workbenchWindow.getShell(), null,
"Select ecore", true, null,
Collections.singletonList(viewerFilter));
if (files.length > 0) {
UserEcoreBasicAspectTemplate.this._data.ecoreIFile = files[0];
//txtPathEcore.setText(files[i].getFullPath().toOSString());
//UserEcoreBasicAspectTemplate.this._data.ecoreProjectPath = files[0].getProject().getFullPath().toOSString();
return files[0].getFullPath().toOSString();
}
return null;
}
};
registerOption(ecoreLocationOption, (String) null, 0);
}
开发者ID:diverse-project,项目名称:k3,代码行数:68,代码来源:UserEcoreBasicAspectTemplate.java
注:本文中的org.eclipse.emf.common.ui.dialogs.WorkspaceResourceDialog类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论