本文整理汇总了Java中org.eclipse.gef.ui.parts.ScrollingGraphicalViewer类的典型用法代码示例。如果您正苦于以下问题:Java ScrollingGraphicalViewer类的具体用法?Java ScrollingGraphicalViewer怎么用?Java ScrollingGraphicalViewer使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ScrollingGraphicalViewer类属于org.eclipse.gef.ui.parts包,在下文中一共展示了ScrollingGraphicalViewer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createPartControl
import org.eclipse.gef.ui.parts.ScrollingGraphicalViewer; //导入依赖的package包/类
public void createPartControl(Composite parent) {
// Create the viewer
viewer = new ScrollingGraphicalViewer();
viewer.setEditDomain(new UrnEditDomain(null));
viewer.createControl(parent);
// viewer.addSelectionChangedListener(this);
// -- getSite().setSelectionProvider(viewer);
getSite().getPage().addPartListener(this);
getSite().getPage().addSelectionListener(this);
// Set root editpart
root = new ScalableFreeformRootEditPart();
viewer.setRootEditPart(root);
// Register the view
DisplayPreferences.getInstance().registerListener(this);
}
示例2: createEditor
import org.eclipse.gef.ui.parts.ScrollingGraphicalViewer; //导入依赖的package包/类
/**
* Overrides the underlying editor widget to add the date slider to it.
* @param parent
*/
public void createEditor(Composite parent){
GraphicalViewer viewer = new ScrollingGraphicalViewer();
Control control = viewer.createControl(parent);
if(parent.getLayout() instanceof GridLayout){
GridData gridData = new GridData();
gridData.horizontalSpan = 2;
gridData.horizontalAlignment = SWT.FILL;
gridData.grabExcessHorizontalSpace = true;
gridData.verticalAlignment = SWT.FILL;
gridData.grabExcessVerticalSpace = true;
control.setLayoutData(gridData);
}
setGraphicalViewer(viewer);
configureGraphicalViewer();
hookGraphicalViewer();
initializeGraphicalViewer();
}
示例3: construct
import org.eclipse.gef.ui.parts.ScrollingGraphicalViewer; //导入依赖的package包/类
@Override
public Control construct(Composite parent) {
Composite content = new Composite(parent, SWT.NONE);
GridDataFactory.fillDefaults().grab(true, true).applyTo(content);
GridLayoutFactory.fillDefaults().applyTo(content);
ScrollingGraphicalViewer viewer = new ScrollingGraphicalViewer();
viewer.createControl(content);
viewer.setRootEditPart(new FreeformGraphicalRootEditPart());
viewer.setEditPartFactory(new CustomEditPartFactory());
ContainerModel container = new ContainerModel("container-01");
ComponentModel component1 = new ComponentModel("component-01", 0, 0);
ComponentModel component2 = new ComponentModel("component-02", 200, 0);
container.components.add(component1);
container.components.add(component2);
viewer.setContents(container);
return content;
}
示例4: configureGraphicalViewer
import org.eclipse.gef.ui.parts.ScrollingGraphicalViewer; //导入依赖的package包/类
/**
* Configure the graphical viewer before it receives contents.
* <p>
* This is the place to choose an appropriate RootEditPart and EditPartFactory for your editor. The RootEditPart determines the behavior of the editor's
* "work-area". For example, GEF includes zoomable and scrollable root edit parts. The EditPartFactory maps model elements to edit parts (controllers).
* </p>
*
* @see org.eclipse.gef.ui.parts.GraphicalEditor#configureGraphicalViewer()
*/
protected void configureGraphicalViewer() {
super.configureGraphicalViewer();
ScrollingGraphicalViewer viewer = (ScrollingGraphicalViewer) getGraphicalViewer();
root = new UCMConnectionOnBottomRootEditPart(getParent());
// zoom management is delegated to us from our parent.
List zoomLevels = new ArrayList(3);
zoomLevels.add(ZoomManager.FIT_ALL);
zoomLevels.add(ZoomManager.FIT_WIDTH);
zoomLevels.add(ZoomManager.FIT_HEIGHT);
root.getZoomManager().setZoomLevelContributions(zoomLevels);
viewer.setRootEditPart(root);
registerContextMenuProvider(viewer);
viewer.setEditPartFactory(new GraphicalEditPartFactory((UCMmap) getModel()));
KeyHandler handler = new GraphicalViewerKeyHandler(viewer).setParent(getCommonKeyHandler());
viewer.setKeyHandler(handler);
getEditDomain().getPaletteViewer().setKeyHandler(handler);
}
示例5: configureGraphicalViewer
import org.eclipse.gef.ui.parts.ScrollingGraphicalViewer; //导入依赖的package包/类
/**
* Configure the graphical viewer before it receives contents.
* <p>
* This is the place to choose an appropriate RootEditPart and EditPartFactory for your editor. The RootEditPart determines the behavior of the editor's
* "work-area". For example, GEF includes zoomable and scrollable root edit parts. The EditPartFactory maps model elements to edit parts (controllers).
* </p>
*
* @see org.eclipse.gef.ui.parts.GraphicalEditor#configureGraphicalViewer()
*/
protected void configureGraphicalViewer() {
super.configureGraphicalViewer();
ScrollingGraphicalViewer viewer = (ScrollingGraphicalViewer) getGraphicalViewer();
// Root editpart that include a zoom manager
root = new GrlConnectionOnBottomRootEditPart(getParent());
// zoom management is delegated to us from our parent.
List zoomLevels = new ArrayList(3);
zoomLevels.add(ZoomManager.FIT_ALL);
zoomLevels.add(ZoomManager.FIT_WIDTH);
zoomLevels.add(ZoomManager.FIT_HEIGHT);
root.getZoomManager().setZoomLevelContributions(zoomLevels);
viewer.setRootEditPart(root);
registerContextMenuProvider(viewer);
viewer.setEditPartFactory(new GrlGraphicalEditPartFactory((GRLGraph) getModel()));
KeyHandler handler = new GraphicalViewerKeyHandler(viewer).setParent(getCommonKeyHandler());
viewer.setKeyHandler(handler);
getEditDomain().getPaletteViewer().setKeyHandler(handler);
}
示例6: run
import org.eclipse.gef.ui.parts.ScrollingGraphicalViewer; //导入依赖的package包/类
private static void run(final Display display, final int x) {
final Shell shell = new Shell(display);
shell.setBounds(0, 0, 350, 350);
shell.setLayout(new FillLayout(SWT.VERTICAL));
// display.syncExec(new Runnable() {
// public void run() {
final ERDiagramEditPartFactory editPartFactory = new ERDiagramEditPartFactory();
final GraphicalViewer viewer = new ScrollingGraphicalViewer();
viewer.setControl(new FigureCanvas(shell));
final ScalableFreeformRootEditPart rootEditPart = new PagableFreeformRootEditPart(diagram);
viewer.setRootEditPart(rootEditPart);
viewer.setEditPartFactory(editPartFactory);
viewer.setContents(diagram);
viewer.getContents().refresh();
// }
// });
shell.pack();
shell.open();
int count = 0;
while (count < x) {
if (!display.readAndDispatch()) {
try {
Thread.sleep(1000);
count++;
} catch (final InterruptedException e) {
e.printStackTrace();
}
}
}
viewer.getContents().deactivate();
// display.dispose();
}
示例7: StackedchartsEditControl
import org.eclipse.gef.ui.parts.ScrollingGraphicalViewer; //导入依赖的package包/类
public StackedchartsEditControl(Composite parent)
{
super(parent, SWT.NONE);
setLayout(new FillLayout());
editDomain = new EditDomain();
viewer = new ScrollingGraphicalViewer();
// connect external Drop support
// add Dataset to Axis
viewer.addDropTargetListener(new ProxyDropTargetListener(
new DatasetToAxisDropTargetListener(viewer),
new DatasetToAxisLandingDropTargetListener(viewer),
new ScatterSetToScatterSetContainerTargetListener(viewer),
new DatasetToChartDropTargetListener(viewer)
));
viewer.createControl(this);
editDomain.addViewer(viewer);
viewer.getControl().setBackground(ColorConstants.listBackground);
viewer.setEditPartFactory(new StackedChartsEditPartFactory());
// emf edit domain
adapterFactory =
new ComposedAdapterFactory(
ComposedAdapterFactory.Descriptor.Registry.INSTANCE);
BasicCommandStack commandStack = new BasicCommandStack();
adapterFactory.addAdapterFactory(new ResourceItemProviderAdapterFactory());
adapterFactory.addAdapterFactory(new EcoreItemProviderAdapterFactory());
adapterFactory
.addAdapterFactory(new ReflectiveItemProviderAdapterFactory());
emfEditingDomain =
new AdapterFactoryEditingDomain(adapterFactory, commandStack);
}
示例8: construct
import org.eclipse.gef.ui.parts.ScrollingGraphicalViewer; //导入依赖的package包/类
@Override
public Control construct(Composite parent) {
Composite content = new Composite(parent, SWT.NONE);
GridDataFactory.fillDefaults().grab(true, true).applyTo(content);
Canvas cv = new Canvas(content, SWT.BORDER);
GridDataFactory.fillDefaults().grab(true, false).hint(SWT.DEFAULT, 20).applyTo(cv);
GridLayoutFactory.fillDefaults().applyTo(content);
GraphicalViewer gv = new GraphicalViewerImpl() {
@Override
protected void createDefaultRoot() {
setRootFigure(new CheckBox("Foo bar baz"));
}
};
gv.createControl(content);
GridDataFactory.fillDefaults().grab(true, true).applyTo(gv.getControl());
GraphicalViewer gv2 = new ScrollingGraphicalViewer() {
@Override
protected void createDefaultRoot() {
setRootFigure(new CheckBox("Foo2 bar2 baz2"));
}
};
gv2.createControl(content);
GridDataFactory.fillDefaults().grab(true, true).applyTo(gv2.getControl());
return content;
}
示例9: construct
import org.eclipse.gef.ui.parts.ScrollingGraphicalViewer; //导入依赖的package包/类
@Override
public Control construct(Composite parent) {
Composite content = new Composite(parent, SWT.NONE);
GridDataFactory.fillDefaults().grab(true, true).applyTo(content);
GridLayoutFactory.fillDefaults().applyTo(content);
ScrollingGraphicalViewer viewer = new ScrollingGraphicalViewer();
viewer.createControl(content);
viewer.setRootEditPart(new FreeformGraphicalRootEditPart());
viewer.setEditPartFactory(new SimplePartFactory());
viewer.setContents(new SimpleModel());
return content;
}
示例10: registerContextMenuProvider
import org.eclipse.gef.ui.parts.ScrollingGraphicalViewer; //导入依赖的package包/类
protected void registerContextMenuProvider(ScrollingGraphicalViewer viewer) {
ContextMenuProvider provider = new UrnContextMenuProvider(viewer, getActionRegistry());
viewer.setContextMenu(provider);
// Bug 381: 3.1: remove extra items from contextual menus
// getSite().registerContextMenu("seg.jUCMNav.editors.actionContributors.UrnContextMenuProvider", provider, viewer); //$NON-NLS-1$
menuExtenders = new ArrayList(1);
PartSite.registerContextMenu("seg.jUCMNav.editors.actionContributors.UrnContextMenuProvider", provider, viewer, true, //$NON-NLS-1$
this, menuExtenders);
// bug 531
if (menuExtenders.get(0) != null) {
provider.removeMenuListener((IMenuListener) menuExtenders.get(0));
}
}
示例11: createViewer
import org.eclipse.gef.ui.parts.ScrollingGraphicalViewer; //导入依赖的package包/类
/**
* Creates the viewer for the relations pane.
*
* @param inParent
* Composite
* @return GraphicalViewer
*/
public GraphicalViewer createViewer(final Composite inParent) {
final GraphicalViewer outViewer = new ScrollingGraphicalViewer();
outViewer.createControl(inParent);
// configure the viewer
outViewer.getControl().setBackground(BG_COLOR);
rootPart = new RelationsRootEditPart();
outViewer.setRootEditPart(rootPart);
final KeyHandler lKeyHandler = new BrowserKeyHandler(outViewer);
lKeyHandler.put(KeyStroke.getPressed(SWT.CONTROL, SWT.NONE), new Action() {
@Override
public void run() {
rootPart.makeMousOverPartClickable(true);
}
});
lKeyHandler.put(KeyStroke.getReleased(SWT.CONTROL, SWT.CONTROL), new Action() {
@Override
public void run() {
rootPart.makeMousOverPartClickable(false);
}
});
outViewer.setKeyHandler(lKeyHandler);
outViewer.setEditPartFactory(getEditPartFactory());
return outViewer;
}
示例12: run
import org.eclipse.gef.ui.parts.ScrollingGraphicalViewer; //导入依赖的package包/类
private static void run(Display display, int x) {
Shell shell = new Shell(display);
shell.setBounds(0, 0, 350, 350);
shell.setLayout(new FillLayout(SWT.VERTICAL));
// display.syncExec(new Runnable() {
// public void run() {
ERDiagramEditPartFactory editPartFactory = new ERDiagramEditPartFactory();
GraphicalViewer viewer = new ScrollingGraphicalViewer();
viewer.setControl(new FigureCanvas(shell));
ScalableFreeformRootEditPart rootEditPart = new PagableFreeformRootEditPart(
diagram);
viewer.setRootEditPart(rootEditPart);
viewer.setEditPartFactory(editPartFactory);
viewer.setContents(diagram);
viewer.getContents().refresh();
// }
// });
shell.pack();
shell.open();
int count = 0;
while (count < x) {
if (!display.readAndDispatch()) {
try {
Thread.sleep(1000);
count++;
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
viewer.getContents().deactivate();
// display.dispose();
}
示例13: run
import org.eclipse.gef.ui.parts.ScrollingGraphicalViewer; //导入依赖的package包/类
/**
* @see org.eclipse.jface.action.Action#run()
*/
public void run() {
if (getSelectedObjects().size() < 1)
return;
Object obj = getSelectedObjects().get(0);
if (!(obj instanceof EditPart))
return;
ScalableFreeformRootEditPart root = (ScalableFreeformRootEditPart) ((EditPart) obj).getRoot();
;
ScrollingGraphicalViewer viewer = (ScrollingGraphicalViewer) root.getViewer();
FileDialog dlg = new FileDialog(viewer.getControl().getShell(), SWT.SAVE);
dlg.setFilterNames(new String[] { "JPEG Files (*.jpg)", "PNG Files (*.png)", "Bitmap Files (*.bmp)" });
dlg.setFilterExtensions(new String[] { "*.jpg", "*.png", "*.bmp" });
String fileName = dlg.open();
if (fileName == null)
return;
LayerManager lm = (LayerManager) viewer.getEditPartRegistry().get(LayerManager.ID);
IFigure figure = lm.getLayer(LayerConstants.PRINTABLE_LAYERS);
// IFigure backgroundfigure = lm.getLayer(LayerConstants.FEEDBACK_LAYER);
// Display display = getWorkbenchPart().getSite().getWorkbenchWindow().getWorkbench().getDisplay();
// Image img = new Image(display, figure.getSize().width, figure.getSize().height);
// GC gc = new GC(img);
// SWTGraphics graphics = new SWTGraphics(gc);
//
// figure.setLocation(new Point(0, 0));
// backgroundfigure.setLocation(new Point(0, 0));
// try {
// root.getZoomManager().setZoom(0.001);
// figure.paint(graphics);
// backgroundfigure.paint(graphics);
// } finally {
// root.getZoomManager().setZoom(1);
// figure.paint(graphics);
// gc.dispose();
// graphics.dispose();
// }
Diagram diagram = (Diagram) ((EditPart) obj).getModel();
DiagramImageUtil diagramUtil = new DiagramImageUtil(diagram);
Display.getDefault().syncExec(diagramUtil);
Image img = diagramUtil.getDiagramImage();
ImageLoader loader = new ImageLoader();
if (img == null) {
img = new Image(null, figure.getSize().width, figure.getSize().height);
}
loader.data = new ImageData[] { img.getImageData() };
if (fileName.toLowerCase().endsWith("jpg")) {
loader.save(fileName, SWT.IMAGE_JPEG);
} else if (fileName.toLowerCase().endsWith("png")) {
loader.save(fileName, SWT.IMAGE_PNG);
} else {
loader.save(fileName, SWT.IMAGE_BMP);
}
}
示例14: configureGraphicalViewer
import org.eclipse.gef.ui.parts.ScrollingGraphicalViewer; //导入依赖的package包/类
/**
* Override this to enforce that connections can also be selected with a mouse drag marquee selection.
*/
@Override
protected void configureGraphicalViewer() {
ScrollingGraphicalViewer viewer = (ScrollingGraphicalViewer) getDiagramContainer().getGraphicalViewer();
ScalableRootEditPartAnimated rootEditPart = new ScalableRootEditPartAnimated(viewer, getConfigurationProvider()) {
@Override
protected GridLayer createGridLayer() {
return new org.eclipse.graphiti.ui.internal.util.draw2d.GridLayer((IConfigurationProviderInternal) getConfigurationProvider());
}
@Override
public DragTracker getDragTracker(Request req) {
GFMarqueeDragTracker trckr = new GFMarqueeDragTracker(this);
trckr.setMarqueeBehavior(GFMarqueeSelectionTool.BEHAVIOR_NODES_AND_CONNECTIONS);
return trckr;
}
};
// configure ZoomManager
viewer.setRootEditPart(rootEditPart); // support
// animation of the zoom
ZoomManager zoomManager = rootEditPart.getZoomManager();
List<String> zoomLevels = new ArrayList<>(3);
zoomLevels.add(ZoomManager.FIT_ALL);
zoomLevels.add(ZoomManager.FIT_WIDTH);
zoomLevels.add(ZoomManager.FIT_HEIGHT);
zoomManager.setZoomLevelContributions(zoomLevels);
IToolBehaviorProvider toolBehaviorProvider = getConfigurationProvider().getDiagramTypeProvider().getCurrentToolBehaviorProvider();
zoomManager.setZoomLevels(toolBehaviorProvider.getZoomLevels());
this.initActionRegistry(zoomManager);
// set the keyhandler.
viewer.setKeyHandler((new GraphicalViewerKeyHandler(viewer)).setParent(getCommonKeyHandler()));
// settings for grid and guides
Diagram diagram = getConfigurationProvider().getDiagram();
boolean snapToGrid = diagram.isSnapToGrid();
int horizontalGridUnit = diagram.getGridUnit();
int verticalGridUnit = diagram.getVerticalGridUnit();
if (verticalGridUnit == -1) {
// No vertical grid unit set (or old diagram before 0.8): use
// vertical grid unit
verticalGridUnit = horizontalGridUnit;
}
boolean gridVisisble = (horizontalGridUnit > 0) && (verticalGridUnit > 0);
viewer.setProperty(SnapToGrid.PROPERTY_GRID_VISIBLE, new Boolean(gridVisisble));
viewer.setProperty(SnapToGrid.PROPERTY_GRID_ENABLED, new Boolean(snapToGrid));
viewer.setProperty(SnapToGrid.PROPERTY_GRID_SPACING, new Dimension(horizontalGridUnit, verticalGridUnit));
viewer.setProperty(SnapToGeometry.PROPERTY_SNAP_ENABLED, toolBehaviorProvider.isShowGuides());
// context button manager
IConfigurationProviderInternal configurationProvider = (IConfigurationProviderInternal) this.getConfigurationProvider();
configurationProvider.setContextButtonManager(new ContextButtonManagerForPad(this, configurationProvider.getResourceRegistry()));
}
示例15: getViewer
import org.eclipse.gef.ui.parts.ScrollingGraphicalViewer; //导入依赖的package包/类
public ScrollingGraphicalViewer getViewer() {
return viewer;
}