本文整理汇总了Java中org.eclipse.gef.GraphicalViewer.getRootEditPart方法的典型用法代码示例。如果您正苦于以下问题:Java GraphicalViewer.getRootEditPart方法的具体用法?Java GraphicalViewer.getRootEditPart怎么用?Java GraphicalViewer.getRootEditPart使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.gef.GraphicalViewer
的用法示例。
在下文中一共展示了GraphicalViewer.getRootEditPart方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getDiagramEditPart
import org.eclipse.gef.GraphicalViewer; //导入方法依赖的package包/类
/**
*
* platformUi에서 다이어그램 EditPart를 가져온다.
*
* @return EditPart
*/
public static EditPart getDiagramEditPart() {
IWorkbench workbench = PlatformUI.getWorkbench();
if (!checkNull(workbench)) {
return null;
}
IWorkbenchWindow workbenchWindow = workbench.getActiveWorkbenchWindow();
if (!checkNull(workbenchWindow)) {
return null;
}
IWorkbenchPage workbenchPage = workbenchWindow.getActivePage();
if (!checkNull(workbenchPage)) {
return null;
}
IEditorPart editorPart = workbenchPage.getActiveEditor();
if (!checkNull(editorPart)) {
return null;
}
if (!(editorPart instanceof AbstractDiagramEditor)) {
return null;
}
GraphicalViewer graphicalViewer = ((AbstractDiagramEditor) editorPart).getDiagramGraphicalViewer();
if (!checkNull(graphicalViewer)) {
return null;
}
RootEditPart rootEditPart = graphicalViewer.getRootEditPart();
if (!checkNull(rootEditPart)) {
return null;
}
EditPart editPart = rootEditPart.getContents();
if (!checkNull(editPart)) {
return null;
}
return editPart;
}
示例2: initializeGraphicalViewer
import org.eclipse.gef.GraphicalViewer; //导入方法依赖的package包/类
/**
* @see nexcore.tool.uml.ui.core.diagram.editor.AbstractDiagramEditor#initializeGraphicalViewer()
*/
@Override
protected void initializeGraphicalViewer() {
super.initializeGraphicalViewer();
GraphicalViewer viewer = getGraphicalViewer();
// ManhattanConnectionRouter 설정
if ("true".equals(PreferenceUtil.INSTANCE.getValueOfStringFieldEditor(ManagerConstant.PREFERENCE_ACTIVITYDIAGRAM_CONNECTION_ROUTER_USE))) {
ScalableFreeformRootEditPart root = (ScalableFreeformRootEditPart) viewer.getRootEditPart();
ConnectionLayer connLayer = (ConnectionLayer) root.getLayer(LayerConstants.CONNECTION_LAYER);
connLayer.setConnectionRouter(new ManhattanConnectionRouter());
}
}
示例3: createImage
import org.eclipse.gef.GraphicalViewer; //导入方法依赖的package包/类
public static ImageInfo createImage(final GraphicalViewer viewer, final int format, final String path) {
GC figureCanvasGC = null;
GC imageGC = null;
try {
final ScalableFreeformRootEditPart rootEditPart = (ScalableFreeformRootEditPart) viewer.getRootEditPart();
rootEditPart.refresh();
final IFigure rootFigure = ((LayerManager) rootEditPart).getLayer(LayerConstants.PRINTABLE_LAYERS);
final EditPart editPart = viewer.getContents();
editPart.refresh();
final ERDiagram diagram = (ERDiagram) editPart.getModel();
final Rectangle rootFigureBounds = getBounds(diagram, rootEditPart, rootFigure.getBounds());
final Control figureCanvas = viewer.getControl();
figureCanvasGC = new GC(figureCanvas);
final Image img = new Image(Display.getCurrent(), rootFigureBounds.width + 20, rootFigureBounds.height + 20);
imageGC = new GC(img);
imageGC.setBackground(figureCanvasGC.getBackground());
imageGC.setForeground(figureCanvasGC.getForeground());
imageGC.setFont(figureCanvasGC.getFont());
imageGC.setLineStyle(figureCanvasGC.getLineStyle());
imageGC.setLineWidth(figureCanvasGC.getLineWidth());
imageGC.setAntialias(SWT.OFF);
// imageGC.setInterpolation(SWT.HIGH);
final Graphics imgGraphics = new SWTGraphics(imageGC);
imgGraphics.setBackgroundColor(figureCanvas.getBackground());
imgGraphics.fillRectangle(0, 0, rootFigureBounds.width + 20, rootFigureBounds.height + 20);
final int translateX = translateX(rootFigureBounds.x);
final int translateY = translateY(rootFigureBounds.y);
imgGraphics.translate(translateX, translateY);
rootFigure.paint(imgGraphics);
final Map<TableView, Location> tableLoacationMap = getTableLocationMap(rootEditPart, translateX, translateY, diagram);
final ImageInfo imageInfo = new ImageInfo(img, tableLoacationMap);
imageInfo.setFormat(format);
imageInfo.setPath(path);
return imageInfo;
} finally {
if (figureCanvasGC != null) {
figureCanvasGC.dispose();
}
if (imageGC != null) {
imageGC.dispose();
}
}
}
示例4: createImage
import org.eclipse.gef.GraphicalViewer; //导入方法依赖的package包/类
public static ImageInfo createImage(GraphicalViewer viewer, int format,
String path) {
GC figureCanvasGC = null;
GC imageGC = null;
try {
ScalableFreeformRootEditPart rootEditPart = (ScalableFreeformRootEditPart) viewer
.getRootEditPart();
rootEditPart.refresh();
IFigure rootFigure = ((LayerManager) rootEditPart)
.getLayer(LayerConstants.PRINTABLE_LAYERS);
EditPart editPart = viewer.getContents();
editPart.refresh();
ERDiagram diagram = (ERDiagram) editPart.getModel();
Rectangle rootFigureBounds = getBounds(diagram, rootEditPart,
rootFigure.getBounds());
Control figureCanvas = viewer.getControl();
figureCanvasGC = new GC(figureCanvas);
Image img = new Image(Display.getCurrent(),
rootFigureBounds.width + 20, rootFigureBounds.height + 20);
imageGC = new GC(img);
imageGC.setBackground(figureCanvasGC.getBackground());
imageGC.setForeground(figureCanvasGC.getForeground());
imageGC.setFont(figureCanvasGC.getFont());
imageGC.setLineStyle(figureCanvasGC.getLineStyle());
imageGC.setLineWidth(figureCanvasGC.getLineWidth());
imageGC.setAntialias(SWT.OFF);
// imageGC.setInterpolation(SWT.HIGH);
Graphics imgGraphics = new SWTGraphics(imageGC);
imgGraphics.setBackgroundColor(figureCanvas.getBackground());
imgGraphics.fillRectangle(0, 0, rootFigureBounds.width + 20,
rootFigureBounds.height + 20);
int translateX = translateX(rootFigureBounds.x);
int translateY = translateY(rootFigureBounds.y);
imgGraphics.translate(translateX, translateY);
rootFigure.paint(imgGraphics);
Map<TableView, Location> tableLoacationMap = getTableLocationMap(
rootEditPart, translateX, translateY, diagram);
ImageInfo imageInfo = new ImageInfo(img, tableLoacationMap);
imageInfo.setFormat(format);
imageInfo.setPath(path);
return imageInfo;
} finally {
if (figureCanvasGC != null) {
figureCanvasGC.dispose();
}
if (imageGC != null) {
imageGC.dispose();
}
}
}
示例5: removeLabelViewAndEditPart
import org.eclipse.gef.GraphicalViewer; //导入方法依赖的package包/类
/**
*
* 값이 없는 경우 뷰모델과 에디트파트를 지워준다
*
* @param node
* @param labelType
* void
*/
public static void removeLabelViewAndEditPart(final NotationNode node, NodeType nodeType) {
NotationNode removeTarget = null;
for (int i = 0; i < node.getCompartmentList().size(); i++) {
AbstractNode label = node.getCompartmentList().get(i);
if (label.getNodeType().equals(nodeType)) {
removeTarget = (NotationNode) label;
break;
}
}
final NotationNode removeElement;
if (removeTarget != null) {
removeElement = removeTarget;
if (node.getCompartmentList().contains(removeElement)) {
// DomainUtil.run(new TransactionalAction() {
// /**
// * @see
// nexcore.tool.uml.manager.transaction.TransactionalAction#doExecute()
// */
// @Override
// public void doExecute() {
IEditorPart[] editors = UiCorePlugin.getActiveWorkbench()
.getActiveWorkbenchWindow()
.getActivePage()
.getEditors();
for (int i = 0; i < editors.length; i++) {
IEditorPart editorPart = editors[i];
if (editorPart instanceof AbstractDiagramEditor
&& DiagramType.COMPONENT_DIAGRAM.equals(((AbstractDiagramEditor) editorPart).getDiagram()
.getType())) {
AbstractDiagramEditor editor = (AbstractDiagramEditor) editorPart;
GraphicalViewer viewer = editor.getDiagramGraphicalViewer();
ScalableFreeformRootEditPart root = (ScalableFreeformRootEditPart) viewer.getRootEditPart();
List<EditPart> diagramEditParts = root.getChildren();
EditPart targetEditPart = findTargetEditPart(diagramEditParts, removeElement);
if (targetEditPart != null) {
// System.out.println(removeEditPart(targetEditPart,
// diagramEditParts));
}
}
}
// 에디트파트를 찾아서 지운다.
// List<EditPart> children = getChildren();
// EditPart removeChild = null;
// for (EditPart child : children) {
// if (child.getModel().equals(removeElement)) {
// removeChild = (child);
// }
// }
// if(getChildren().contains(removeChild)) {
// getFigure().remove(
// ((GraphicalEditPart)removeChild).getFigure() );
// getChildren().remove(removeChild);
//
node.setHeight(node.getHeight() - removeElement.getHeight());
// }
node.getCompartmentList().remove(removeElement);
}
// });
// }
}
}