本文整理汇总了Java中org.eclipse.gmf.runtime.notation.Diagram类的典型用法代码示例。如果您正苦于以下问题:Java Diagram类的具体用法?Java Diagram怎么用?Java Diagram使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Diagram类属于org.eclipse.gmf.runtime.notation包,在下文中一共展示了Diagram类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getCrossReferencingViews
import org.eclipse.gmf.runtime.notation.Diagram; //导入依赖的package包/类
public static Set<View> getCrossReferencingViews(EObject referencedObject) {
Set<View> referencingObjects = new HashSet<>();
CrossReferenceAdapter crossReferenceAdapter = getCrossReferenceAdapter(referencedObject);
if (crossReferenceAdapter != null) {
// Retrieve all views referencing the referencedObject
Iterator<?> views = crossReferenceAdapter.getInverseReferencers(referencedObject,
NotationPackage.eINSTANCE.getView_Element(), NotationPackage.eINSTANCE.getView()).iterator();
while (views.hasNext()) {
View view = (View) views.next();
if (!(view instanceof Diagram)) {
referencingObjects.add(view);
}
}
}
return referencingObjects;
}
示例2: getNavigatorSelection
import org.eclipse.gmf.runtime.notation.Diagram; //导入依赖的package包/类
/**
* @generated
*/
private ISelection getNavigatorSelection() {
IDiagramDocument document = getDiagramDocument();
if (document == null) {
return StructuredSelection.EMPTY;
}
Diagram diagram = document.getDiagram();
if (diagram == null || diagram.eResource() == null) {
return StructuredSelection.EMPTY;
}
IFile file = WorkspaceSynchronizer.getFile(diagram.eResource());
if (file != null) {
StatemachineNavigatorItem item = new StatemachineNavigatorItem(
diagram, file, false);
return new StructuredSelection(item);
}
return StructuredSelection.EMPTY;
}
示例3: arrangeElementsOfDiagram
import org.eclipse.gmf.runtime.notation.Diagram; //导入依赖的package包/类
@Override
protected void arrangeElementsOfDiagram(Diagram diagram, IProgressMonitor monitor) throws ArrangeException{
IDiagramElementsArranger diagramElementsArranger;
DiagramEditPart diagep = diagramManager.getActiveDiagramEditPart();
if(diagram.getType().equals("PapyrusUMLClassDiagram")){
diagramElementsArranger = new ClassDiagramElementsGmfArranger(diagep);
}else if(diagram.getType().equals("PapyrusUMLActivityDiagram")){
diagramElementsArranger = new ActivityDiagramElementsGmfArranger(diagep);
}else if(diagram.getType().equals("PapyrusUMLStateMachineDiagram")){
diagramElementsArranger = new StateMachineDiagramElementsGmfArranger(diagep);
}else{
return;
}
diagramElementsArranger.arrange(monitor);
}
示例4: selectExistingElement
import org.eclipse.gmf.runtime.notation.Diagram; //导入依赖的package包/类
/**
* @generated
*/
protected EObject selectExistingElement(IAdaptable host, Collection types) {
if (types.isEmpty()) {
return null;
}
IGraphicalEditPart editPart = (IGraphicalEditPart) host
.getAdapter(IGraphicalEditPart.class);
if (editPart == null) {
return null;
}
Diagram diagram = (Diagram) editPart.getRoot().getContents().getModel();
HashSet<EObject> elements = new HashSet<EObject>();
for (Iterator<EObject> it = diagram.getElement().eAllContents(); it
.hasNext();) {
EObject element = it.next();
if (isApplicableElement(element, types)) {
elements.add(element);
}
}
if (elements.isEmpty()) {
return null;
}
return selectElement((EObject[]) elements.toArray(new EObject[elements
.size()]));
}
示例5: getEditorInput
import org.eclipse.gmf.runtime.notation.Diagram; //导入依赖的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;
}
示例6: findSelection
import org.eclipse.gmf.runtime.notation.Diagram; //导入依赖的package包/类
/**
* @generated
*/
public IStructuredSelection findSelection(IEditorInput anInput) {
IDiagramDocument document = StatemachineDiagramEditorPlugin
.getInstance().getDocumentProvider()
.getDiagramDocument(anInput);
if (document == null) {
return StructuredSelection.EMPTY;
}
Diagram diagram = document.getDiagram();
if (diagram == null || diagram.eResource() == null) {
return StructuredSelection.EMPTY;
}
IFile file = WorkspaceSynchronizer.getFile(diagram.eResource());
if (file != null) {
StatemachineNavigatorItem item = new StatemachineNavigatorItem(
diagram, file, false);
return new StructuredSelection(item);
}
return StructuredSelection.EMPTY;
}
示例7: getDiagramContaining
import org.eclipse.gmf.runtime.notation.Diagram; //导入依赖的package包/类
/**
* Returns the {@link Diagram} that contains a given semantic element.
*/
public static Diagram getDiagramContaining(EObject element) {
Assert.isNotNull(element);
Resource eResource = element.eResource();
Collection<Diagram> objects = EcoreUtil.getObjectsByType(eResource.getContents(),
NotationPackage.Literals.DIAGRAM);
for (Diagram diagram : objects) {
TreeIterator<EObject> eAllContents = diagram.eAllContents();
while (eAllContents.hasNext()) {
EObject next = eAllContents.next();
if (next instanceof View) {
if (EcoreUtil.equals(((View) next).getElement(), element)) {
return ((View) next).getDiagram();
}
}
}
}
return null;
}
示例8: openEditor
import org.eclipse.gmf.runtime.notation.Diagram; //导入依赖的package包/类
/**
* Opens a subdiagram for a given {@link Diagram}
*/
public static IEditorPart openEditor(Diagram diagramToOpen) {
IFile file = WorkspaceSynchronizer.getFile(diagramToOpen.eResource());
try {
IEditorDescriptor desc = PlatformUI.getWorkbench().getEditorRegistry().getDefaultEditor(file.getName());
final IWorkbenchPage wbPage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
if (diagramToOpen.getElement() instanceof Statechart) {
return wbPage.openEditor(new FileEditorInput(file), desc.getId());
} else if (diagramToOpen.getElement() instanceof State) {
return wbPage.openEditor(new DiagramEditorInput(diagramToOpen), desc.getId());
}
} catch (PartInitException e) {
e.printStackTrace();
}
return null;
}
示例9: findNotationView
import org.eclipse.gmf.runtime.notation.Diagram; //导入依赖的package包/类
public static View findNotationView(EObject semanticElement) {
Collection<Diagram> objects = EcoreUtil.getObjectsByType(semanticElement.eResource().getContents(),
NotationPackage.Literals.DIAGRAM);
for (Diagram diagram : objects) {
TreeIterator<EObject> eAllContents = diagram.eAllContents();
while (eAllContents.hasNext()) {
EObject next = eAllContents.next();
if (next instanceof View) {
if (((View) next).getElement() == semanticElement) {
return ((View) next);
}
}
}
}
return null;
}
示例10: createElement
import org.eclipse.gmf.runtime.notation.Diagram; //导入依赖的package包/类
public IAdaptable createElement(IMemento memento) {
String uriStr = memento.getString(EMF_URI);
if (uriStr == null) {
return null;
}
URI uri = URI.createURI(uriStr);
ResourceSet resourceSet = DiagramPartitioningUtil.getSharedDomain().getResourceSet();
Resource resource = resourceSet.getResource(uri, false);
if (resource == null)
resource = resourceSet.createResource(uri);
try {
resource.load(Collections.emptyMap());
} catch (IOException e) {
e.printStackTrace();
}
Diagram diagram = (Diagram) resource.getEObject(uri.fragment());
return new DiagramEditorInput(diagram);
}
示例11: getProjectStatechartInput
import org.eclipse.gmf.runtime.notation.Diagram; //导入依赖的package包/类
protected Set<IFile> getProjectStatechartInput(Diagram diagram) {
final IFile file = WorkspaceSynchronizer.getFile(diagram.eResource());
final IProject project = file.getProject();
final Set<IFile> result = new HashSet<IFile>();
try {
project.accept(new IResourceVisitor() {
public boolean visit(IResource resource) throws CoreException {
// TODO check for package explorer filters here
if (resource.isHidden()) {
return false;
}
if (resource instanceof IFile) {
if (file.getFileExtension().equals(resource.getFileExtension()))
result.add((IFile) resource);
}
return true;
}
});
} catch (CoreException e) {
e.printStackTrace();
}
return result;
}
示例12: doExecuteWithResult
import org.eclipse.gmf.runtime.notation.Diagram; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Override
protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info)
throws ExecutionException {
BooleanValueStyle inlineStyle = DiagramPartitioningUtil.getInlineStyle(node);
if (inlineStyle != null) {
inlineStyle.setBooleanValue(false);
} else {
inlineStyle = DiagramPartitioningUtil.createInlineStyle();
inlineStyle.setBooleanValue(false);
node.getStyles().add(inlineStyle);
}
Diagram subdiagram = ViewService.createDiagram(node.getElement(), StatechartDiagramEditor.ID,
DiagramActivator.DIAGRAM_PREFERENCES_HINT);
node.eResource().getContents().add(subdiagram);
return CommandResult.newOKCommandResult();
}
示例13: addElementsToDiagram
import org.eclipse.gmf.runtime.notation.Diagram; //导入依赖的package包/类
@Override
protected void addElementsToDiagram(Diagram diagram, IProgressMonitor monitor) {
Element container = diagramManager.getDiagramContainer(diagram);
AbstractDiagramElementsManager diagramElementsManager;
DiagramEditPart diagep = diagramManager.getActiveDiagramEditPart();
if(diagram.getType().equals("PapyrusUMLClassDiagram")){
diagramElementsManager = new ClassDiagramElementsManager(diagep);
}else if(diagram.getType().equals("PapyrusUMLActivityDiagram")){
diagramElementsManager = new ActivityDiagramElementsManager(diagep);
}else if(diagram.getType().equals("PapyrusUMLStateMachineDiagram")){
diagramElementsManager = new StateMachineDiagramElementsManager(diagep);
}else{
return;
}
List<Element> baseElements = modelManager.getAllChildrenOfPackage(container);
diagramElementsManager.addElementsToDiagram(baseElements);
}
示例14: getAllSubDiagrams
import org.eclipse.gmf.runtime.notation.Diagram; //导入依赖的package包/类
protected Collection<? extends Diagram> getAllSubDiagrams(State semanticState) {
List<Diagram> subDiagrams = new ArrayList<>();
addSubDiagram(semanticState, subDiagrams);
TreeIterator<EObject> iter = semanticState.eAllContents();
while (iter.hasNext()) {
EObject next = iter.next();
if (next instanceof State) {
State subState = (State) next;
if (subState.isComposite()) {
addSubDiagram(subState, subDiagrams);
} else {
iter.prune();
}
}
}
return subDiagrams;
}
示例15: getOverrideChildPasteOperation
import org.eclipse.gmf.runtime.notation.Diagram; //导入依赖的package包/类
/**
* By default, don't provide any child paste override behaviour.
*
* @return <code>null</code>, always
*/
public OverridePasteChildOperation getOverrideChildPasteOperation(
PasteChildOperation overriddenChildPasteOperation) {
if (shouldAllowPaste(overriddenChildPasteOperation)) {
EObject eObject = overriddenChildPasteOperation.getEObject();
if (eObject instanceof org.eclipse.gmf.runtime.notation.Node) {
org.eclipse.gmf.runtime.notation.Node node = (org.eclipse.gmf.runtime.notation.Node) eObject;
EObject element = node.getElement();
if ((element != null)) {
return new PositionalGeneralViewPasteOperation(overriddenChildPasteOperation, true);
} else {
return new PositionalGeneralViewPasteOperation(overriddenChildPasteOperation, false);
}
} else if (eObject instanceof Edge) {
return new ConnectorViewPasteOperation(overriddenChildPasteOperation);
} else if (eObject instanceof Diagram) {
return new DiagramPasteOperation(overriddenChildPasteOperation);
}
}
return null;
}