📄 extlibraryeditor.java
字号:
return contentOutlinePage;
}
/**
* This accesses a cached version of the property sheet.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public IPropertySheetPage getPropertySheetPage()
{
if (propertySheetPage == null)
{
propertySheetPage =
new ExtendedPropertySheetPage(editingDomain)
{
public void setSelectionToViewer(List selection)
{
EXTLibraryEditor.this.setSelectionToViewer(selection);
EXTLibraryEditor.this.setFocus();
}
public void setActionBars(IActionBars actionBars)
{
super.setActionBars(actionBars);
getActionBarContributor().shareGlobalActions(this, actionBars);
}
};
propertySheetPage.setPropertySourceProvider(new AdapterFactoryContentProvider(adapterFactory));
}
return propertySheetPage;
}
/**
* This deals with how we want selection in the outliner to affect the other views.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void handleContentOutlineSelection(ISelection selection)
{
if (currentViewerPane != null && !selection.isEmpty() && selection instanceof IStructuredSelection)
{
Iterator selectedElements = ((IStructuredSelection)selection).iterator();
if (selectedElements.hasNext())
{
// Get the first selected element.
//
Object selectedElement = selectedElements.next();
// If it's the selection viewer, then we want it to select the same selection as this selection.
//
if (currentViewerPane.getViewer() == selectionViewer)
{
ArrayList selectionList = new ArrayList();
selectionList.add(selectedElement);
while (selectedElements.hasNext())
{
selectionList.add(selectedElements.next());
}
// Set the selection to the widget.
//
selectionViewer.setSelection(new StructuredSelection(selectionList));
}
else
{
// Set the input to the widget.
//
if (currentViewerPane.getViewer().getInput() != selectedElement)
{
currentViewerPane.getViewer().setInput(selectedElement);
currentViewerPane.setTitle(selectedElement);
}
}
}
}
}
/**
* This is for implementing {@link IEditorPart} and simply tests the command stack.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public boolean isDirty()
{
return ((BasicCommandStack)editingDomain.getCommandStack()).isSaveNeeded();
}
/**
* This is for implementing {@link IEditorPart} and simply saves the model file.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void doSave(IProgressMonitor progressMonitor)
{
// Do the work within an operation because this is a long running activity that modifies the workbench.
//
WorkspaceModifyOperation operation =
new WorkspaceModifyOperation()
{
// This is the method that gets invoked when the operation runs.
//
public void execute(IProgressMonitor monitor)
{
// Save the resources to the file system.
//
boolean first = true;
for (Iterator i = editingDomain.getResourceSet().getResources().iterator(); i.hasNext(); )
{
Resource resource = (Resource)i.next();
if ((first || !resource.getContents().isEmpty() || isPersisted(resource)) && !editingDomain.isReadOnly(resource))
{
try
{
savedResources.add(resource);
resource.save(Collections.EMPTY_MAP);
}
catch (Exception exception)
{
resourceToDiagnosticMap.put(resource, analyzeResourceProblems(resource, exception));
}
first = false;
}
}
}
};
updateProblemIndication = false;
try
{
// This runs the options, and shows progress.
//
new ProgressMonitorDialog(getSite().getShell()).run(true, false, operation);
// Refresh the necessary state.
//
((BasicCommandStack)editingDomain.getCommandStack()).saveIsDone();
firePropertyChange(IEditorPart.PROP_DIRTY);
}
catch (Exception exception)
{
// Something went wrong that shouldn't.
//
EXTLibraryEditorPlugin.INSTANCE.log(exception);
}
updateProblemIndication = true;
updateProblemIndication();
}
/**
* This returns wether something has been persisted to the URI of the specified resource.
* The implementation uses the URI converter from the editor's resource set to try to open an input stream.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected boolean isPersisted(Resource resource)
{
boolean result = false;
try
{
InputStream stream = editingDomain.getResourceSet().getURIConverter().createInputStream(resource.getURI());
if (stream != null)
{
result = true;
stream.close();
}
}
catch (IOException e)
{
}
return result;
}
/**
* This always returns true because it is not currently supported.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public boolean isSaveAsAllowed()
{
return true;
}
/**
* This also changes the editor's input.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void doSaveAs()
{
SaveAsDialog saveAsDialog= new SaveAsDialog(getSite().getShell());
saveAsDialog.open();
IPath path= saveAsDialog.getResult();
if (path != null)
{
IFile file = ResourcesPlugin.getWorkspace().getRoot().getFile(path);
if (file != null)
{
doSaveAs(URI.createPlatformResourceURI(file.getFullPath().toString()), new FileEditorInput(file));
}
}
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected void doSaveAs(URI uri, IEditorInput editorInput)
{
((Resource)editingDomain.getResourceSet().getResources().get(0)).setURI(uri);
setInputWithNotify(editorInput);
setPartName(editorInput.getName());
IProgressMonitor progressMonitor =
getActionBars().getStatusLineManager() != null ?
getActionBars().getStatusLineManager().getProgressMonitor() :
new NullProgressMonitor();
doSave(progressMonitor);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void gotoMarker(IMarker marker)
{
try
{
if (marker.getType().equals(EValidator.MARKER))
{
String uriAttribute = marker.getAttribute(EValidator.URI_ATTRIBUTE, null);
if (uriAttribute != null)
{
URI uri = URI.createURI(uriAttribute);
EObject eObject = editingDomain.getResourceSet().getEObject(uri, true);
if (eObject != null)
{
setSelectionToViewer(Collections.singleton(editingDomain.getWrapper(eObject)));
}
}
}
}
catch (CoreException exception)
{
EXTLibraryEditorPlugin.INSTANCE.log(exception);
}
}
/**
* This is called during startup.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void init(IEditorSite site, IEditorInput editorInput)
{
setSite(site);
setInputWithNotify(editorInput);
setPartName(editorInput.getName());
site.setSelectionProvider(this);
site.getPage().addPartListener(partListener);
ResourcesPlugin.getWorkspace().addResourceChangeListener(resourceChangeListener, IResourceChangeEvent.POST_CHANGE);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void setFocus()
{
if (currentViewerPane != null)
{
currentViewerPane.setFocus();
}
else
{
getControl(getActivePage()).setFocus();
}
}
/**
* This implements {@link org.eclipse.jface.viewers.ISelectionProvider}.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void addSelectionChangedListener(ISelectionChangedListener listener)
{
selectionChangedListeners.add(listener);
}
/**
* This implements {@link org.eclipse.jface.viewers.ISelectionProvider}.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void removeSelectionChangedListener(ISelectionChangedListener listener)
{
selectionChangedListeners.remove(listener);
}
/**
* This implements {@link org.eclipse.jface.viewers.ISelectionProvider} to return this editor's overall selection.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public ISelection getSelection()
{
return editorSelection;
}
/**
* This implements {@link org.eclipse.jface.viewers.ISelectionProvider} to set this editor's overall selection.
* Calling this result will notify the listeners.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void setSelection(ISelection selection)
{
editorSelection = selection;
for (Iterator listeners = selectionChangedListeners.iterator(); listeners.hasNext(); )
{
ISelectionChangedListener listener = (ISelectionChangedListener)listeners.next();
listener.selectionChanged(new SelectionChangedEvent(this, selection));
}
setStatusLineManager(selection);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void setStatusLineManager(ISelection selection)
{
IStatusLineManager statusLineManager = currentViewer != null && currentViewer == contentOutlineViewer ?
contentOutlineStatusLineManager : getActionBars().getStatusLineManager();
if (statusLineManager != null)
{
if (selection instanceof IStructuredSelection)
{
Collection collection = ((IStructuredSelection)selection).toList();
switch (collection.size())
{
case 0:
{
statusLineManager.setMessage(getString("_UI_NoObjectSelected")); //$NON-NLS-1$
break;
}
case 1:
{
String text = new AdapterFactoryItemDelegator(adapterFactory).getText(collection.iterator().next());
statusLineManager.setMessage(getString("_UI_SingleObjectSelected", text)); //$NON-NLS-1$
break;
}
default:
{
statusLineManager.setMessage(getString("_UI_MultiObjectSelected", Integer.toString(collection.size()))); //$NON-NLS-1$
break;
}
}
}
else
{
statusLineManager.setMessage(""); //$NON-NLS-1$
}
}
}
/**
* This looks up a string in the plugin's plugin.properties file.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
private static String getString(String key)
{
return EXTLibraryEditorPlugin.INSTANCE.getString(key);
}
/**
* This looks up a string in plugin.properties, making a substitution.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
private static String getString(String key, Object s1)
{
return EXTLibraryEditorPlugin.INSTANCE.getString(key, new Object [] { s1 });
}
/**
* This implements {@link org.eclipse.jface.action.IMenuListener} to help fill the context menus with contributions from the Edit menu.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void menuAboutToShow(IMenuManager menuManager)
{
((IMenuListener)getEditorSite().getActionBarContributor()).menuAboutToShow(menuManager);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public EditingDomainActionBarContributor getActionBarContributor()
{
return (EditingDomainActionBarContributor)getEditorSite().getActionBarContributor();
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public IActionBars getActionBars()
{
return getActionBarContributor().getActionBars();
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public AdapterFactory getAdapterFactory()
{
return adapterFactory;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void dispose()
{
updateProblemIndication = false;
ResourcesPlugin.getWorkspace().removeResourceChangeListener(resourceChangeListener);
getSite().getPage().removePartListener(partListener);
adapterFactory.dispose();
if (getActionBarContributor().getActiveEditor() == this)
{
getActionBarContributor().setActiveEditor(null);
}
if (propertySheetPage != null)
{
propertySheetPage.dispose();
}
if (contentOutlinePage != null)
{
contentOutlinePage.dispose();
}
super.dispose();
}
/**
* Returns whether the outline view should be presented to the user.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected boolean showOutlineView()
{
return true;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -