本文整理汇总了Java中org.eclipse.emf.common.ui.URIEditorInput类的典型用法代码示例。如果您正苦于以下问题:Java URIEditorInput类的具体用法?Java URIEditorInput怎么用?Java URIEditorInput使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
URIEditorInput类属于org.eclipse.emf.common.ui包,在下文中一共展示了URIEditorInput类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getEditorID
import org.eclipse.emf.common.ui.URIEditorInput; //导入依赖的package包/类
/**
* Gets the default editor ID for the given {@link IEditorInput} and element.
*
* @param input
* the {@link IEditorInput}
* @param element
* the element
* @return the default editor ID for the given {@link IEditorInput} and element if any, <code>null</code>
* otherwise
*/
public static String getEditorID(IEditorInput input, Object element) {
final String res;
if (input instanceof URIEditorInput) {
res = PlatformUI.getWorkbench().getEditorRegistry().getDefaultEditor(
((URIEditorInput)input).getURI().lastSegment()).getId();
} else if (input instanceof IFileEditorInput) {
IEditorDescriptor defaultEditor = PlatformUI.getWorkbench().getEditorRegistry().getDefaultEditor(
((IFileEditorInput)input).getFile().getName());
if (defaultEditor != null) {
res = defaultEditor.getId();
} else {
res = "org.eclipse.emf.ecore.presentation.ReflectiveEditorID";
}
} else {
res = null;
}
return res;
}
示例2: openEditor
import org.eclipse.emf.common.ui.URIEditorInput; //导入依赖的package包/类
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
*
* @generated
*/
public static boolean openEditor(IWorkbench workbench, URI uri) {
IWorkbenchWindow workbenchWindow = workbench.getActiveWorkbenchWindow();
IWorkbenchPage page = workbenchWindow.getActivePage();
IEditorDescriptor editorDescriptor = EditUIUtil.getDefaultEditor(uri, null);
if (editorDescriptor == null) {
MessageDialog.openError(workbenchWindow.getShell(), getString("_UI_Error_title"), getString("_WARN_No_Editor", uri.lastSegment()));
return false;
} else {
try {
page.openEditor(new URIEditorInput(uri), editorDescriptor.getId());
} catch (PartInitException exception) {
MessageDialog.openError(workbenchWindow.getShell(), getString("_UI_OpenEditorError_label"), exception.getMessage());
return false;
}
}
return true;
}
示例3: matches
import org.eclipse.emf.common.ui.URIEditorInput; //导入依赖的package包/类
/**
* @generated
*/
public boolean matches(IEditorReference editorRef, IEditorInput input) {
IEditorInput editorInput;
try {
editorInput = editorRef.getEditorInput();
} catch (PartInitException e) {
return false;
}
if (editorInput.equals(input)) {
return true;
}
if (editorInput instanceof URIEditorInput
&& input instanceof URIEditorInput) {
return ((URIEditorInput) editorInput).getURI().equals(
((URIEditorInput) input).getURI());
}
return false;
}
示例4: createElementInfo
import org.eclipse.emf.common.ui.URIEditorInput; //导入依赖的package包/类
/**
* @generated
*/
protected ElementInfo createElementInfo(Object element)
throws CoreException {
if (false == element instanceof FileEditorInput
&& false == element instanceof URIEditorInput) {
throw new CoreException(
new Status(
IStatus.ERROR,
StatemachineDiagramEditorPlugin.ID,
0,
NLS.bind(
Messages.StatemachineDocumentProvider_IncorrectInputError,
new Object[] {
element,
"org.eclipse.ui.part.FileEditorInput", "org.eclipse.emf.common.ui.URIEditorInput" }), //$NON-NLS-1$ //$NON-NLS-2$
null));
}
IEditorInput editorInput = (IEditorInput) element;
IDiagramDocument document = (IDiagramDocument) createDocument(editorInput);
ResourceSetInfo info = new ResourceSetInfo(document, editorInput);
info.setModificationStamp(computeModificationStamp(info));
info.fStatus = null;
return info;
}
示例5: createDocument
import org.eclipse.emf.common.ui.URIEditorInput; //导入依赖的package包/类
/**
* @generated
*/
protected IDocument createDocument(Object element) throws CoreException {
if (false == element instanceof FileEditorInput
&& false == element instanceof URIEditorInput) {
throw new CoreException(
new Status(
IStatus.ERROR,
StatemachineDiagramEditorPlugin.ID,
0,
NLS.bind(
Messages.StatemachineDocumentProvider_IncorrectInputError,
new Object[] {
element,
"org.eclipse.ui.part.FileEditorInput", "org.eclipse.emf.common.ui.URIEditorInput" }), //$NON-NLS-1$ //$NON-NLS-2$
null));
}
IDocument document = createEmptyDocument();
setDocumentContent(document, (IEditorInput) element);
setupDocument(element, document);
return document;
}
示例6: isModifiable
import org.eclipse.emf.common.ui.URIEditorInput; //导入依赖的package包/类
/**
* @generated
*/
public boolean isModifiable(Object element) {
if (!isStateValidated(element)) {
if (element instanceof FileEditorInput
|| element instanceof URIEditorInput) {
return true;
}
}
ResourceSetInfo info = getResourceSetInfo(element);
if (info != null) {
if (info.isUpdateCache()) {
try {
updateCache(element);
} catch (CoreException ex) {
StatemachineDiagramEditorPlugin.getInstance().logError(
Messages.StatemachineDocumentProvider_isModifiable,
ex);
// Error message to log was initially taken from org.eclipse.gmf.runtime.diagram.ui.resources.editor.ide.internal.l10n.EditorMessages.StorageDocumentProvider_isModifiable
}
}
return info.isModifiable();
}
return super.isModifiable(element);
}
示例7: handleElementMoved
import org.eclipse.emf.common.ui.URIEditorInput; //导入依赖的package包/类
/**
* @generated
*/
protected void handleElementMoved(IEditorInput input, URI uri) {
if (input instanceof FileEditorInput) {
IFile newFile = ResourcesPlugin
.getWorkspace()
.getRoot()
.getFile(
new Path(URI.decode(uri.path()))
.removeFirstSegments(1));
fireElementMoved(input, newFile == null ? null
: new FileEditorInput(newFile));
return;
}
// TODO: append suffix to the URI! (use diagram as a parameter)
fireElementMoved(input, new URIEditorInput(uri));
}
示例8: getEditorInput
import org.eclipse.emf.common.ui.URIEditorInput; //导入依赖的package包/类
/**
* @generated
*/
private static IEditorInput getEditorInput(Diagram diagram) {
Resource diagramResource = diagram.eResource();
for (EObject nextEObject : diagramResource.getContents()) {
if (nextEObject == diagram) {
return new FileEditorInput(
WorkspaceSynchronizer.getFile(diagramResource));
}
if (nextEObject instanceof Diagram) {
break;
}
}
URI uri = EcoreUtil.getURI(diagram);
String editorName = uri.lastSegment() + '#'
+ diagram.eResource().getContents().indexOf(diagram);
IEditorInput editorInput = new URIEditorInput(uri, editorName);
return editorInput;
}
示例9: getLastActiveEditorProject
import org.eclipse.emf.common.ui.URIEditorInput; //导入依赖的package包/类
/**
* @return The project which contains the file that is open in the last
* active editor in the current workbench page.
*/
public static IProject getLastActiveEditorProject() {
final IEditorPart editor = getLastActiveEditor();
if (editor == null)
return null;
final IEditorInput editorInput = editor.getEditorInput();
if (editorInput instanceof IFileEditorInput) {
final IFileEditorInput input = (IFileEditorInput) editorInput;
return input.getFile().getProject();
} else if (editorInput instanceof URIEditorInput) {
final URI uri = ((URIEditorInput) editorInput).getURI();
if (uri.isPlatformResource()) {
final String platformString = uri.toPlatformString(true);
return ResourcesPlugin.getWorkspace().getRoot().findMember(platformString).getProject();
}
}
return null;
}
示例10: getEditorInput
import org.eclipse.emf.common.ui.URIEditorInput; //导入依赖的package包/类
private IEditorInput getEditorInput() {
for (EObject nextEObject : myDiagram.eResource().getContents()) {
if (nextEObject == myDiagram) {
return new FileEditorInput(
WorkspaceSynchronizer.getFile(myDiagram.eResource()));
}
if (nextEObject instanceof Diagram) {
break;
}
}
URI uri = EcoreUtil.getURI(myDiagram);
String editorName = uri.lastSegment()
+ "#" + myDiagram.eResource().getContents().indexOf(myDiagram); //$NON-NLS-1$
IEditorInput editorInput = new URIEditorInput(uri, editorName);
return editorInput;
}
示例11: getEditorInput
import org.eclipse.emf.common.ui.URIEditorInput; //导入依赖的package包/类
private static IEditorInput getEditorInput(Diagram diagram) {
Resource diagramResource = diagram.eResource();
for (Iterator<EObject> it = diagramResource.getContents().iterator(); it
.hasNext();) {
EObject nextEObject = (EObject) it.next();
if (nextEObject == diagram) {
return new FileEditorInput(
WorkspaceSynchronizer.getFile(diagramResource));
}
if (nextEObject instanceof Diagram) {
break;
}
}
URI uri = EcoreUtil.getURI(diagram);
String editorName = uri.lastSegment() + "#"
+ diagram.eResource().getContents().indexOf(diagram);
IEditorInput editorInput = new URIEditorInput(uri, editorName);
return editorInput;
}
示例12: doSaveAs
import org.eclipse.emf.common.ui.URIEditorInput; //导入依赖的package包/类
/**
* This also changes the editor's input. <!-- begin-user-doc --> <!--
* end-user-doc -->
*
* @generated
*/
@Override
public void doSaveAs() {
new ResourceDialog(getSite().getShell(), null, SWT.NONE) {
@Override
protected boolean isSave() {
return true;
}
@Override
protected boolean processResources() {
List<URI> uris = getURIs();
if (uris.size() > 0) {
URI uri = uris.get(0);
doSaveAs(uri, new URIEditorInput(uri));
return true;
} else {
return false;
}
}
}.open();
}
示例13: createModel
import org.eclipse.emf.common.ui.URIEditorInput; //导入依赖的package包/类
protected void createModel(IEditorInput input) {
URI uri = EditUIUtil.getURI(input);
Resource resource = null;
try {
resource = getEditingDomain().getResourceSet().getResource(uri, true);
} catch (Exception e) {
resource = getEditingDomain().getResourceSet().getResource(uri, true);
}
timelineModel = getTimelineModel(resource);
if (timelineModel.getContents().isEmpty()) {
if (input instanceof URIEditorInput) {
populateTimelineFromFragment((URIEditorInput) input, resource);
} else {
final List<Section> sections = createDefaultSections(resource);
gov.nasa.ensemble.emf.transaction.TransactionUtils.writing(timelineModel, new Runnable() {
@Override
public void run() {
timelineModel.getContents().addAll(sections);
}
});
}
}
refreshPage();
}
示例14: getPlanEditorModel
import org.eclipse.emf.common.ui.URIEditorInput; //导入依赖的package包/类
/**
* Method to get the current plan editor model for this editor. This editor
* is using a very simple plan editor model. The model just contains an almost
* empty plan (just has the model that is being edited in this editor).
* @return a model that just has the template plan element to be edited by this
* editor.
*/
public PlanEditorModel getPlanEditorModel() {
// use a temporary input for the temporary model
URIEditorInput editorInput = getAlteredURIEditorInput();
PlanEditorModel planEditorModel = PlanEditorModelRegistry.getPlanEditorModel(editorInput);
if(planEditorModel == null) {
EPlan tempPlan = getTemporaryEPlan();
planEditorModel = new PlanEditorModel(tempPlan);
planEditorModel.addDirtyListener(dirtyListener);
try {
PlanEditorModelRegistry.registerPlanEditorModel(editorInput, planEditorModel);
lastRegistered = editorInput;
PlanEditorModelRegistry.registerEditor(planEditorModel, this);
} catch (RegistrationException e) {
LogUtil.error(e);
}
}
return planEditorModel;
}
示例15: partActivated
import org.eclipse.emf.common.ui.URIEditorInput; //导入依赖的package包/类
@Override
public void partActivated(IWorkbenchPart part) {
if (part instanceof EditorPart) {
EditorPart editorPart = (EditorPart) part;
if (editorPart.getEditorInput() instanceof URIEditorInput) {
URIEditorInput input = (URIEditorInput) editorPart.getEditorInput();
updateView(input.getURI());
if(txtMessage != null){
txtMessage.setEnabled(true);
}
} else {
if(txtMessage != null){
txtMessage.setEnabled(false);
}
txtMessagePool.setText("Message Pool");
}
}
}