本文整理汇总了Java中org.eclipse.gef.EditPartViewer类的典型用法代码示例。如果您正苦于以下问题:Java EditPartViewer类的具体用法?Java EditPartViewer怎么用?Java EditPartViewer使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
EditPartViewer类属于org.eclipse.gef包,在下文中一共展示了EditPartViewer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: performCreation
import org.eclipse.gef.EditPartViewer; //导入依赖的package包/类
@Override protected void performCreation(int button) {
super.performCreation(button);
EditPartViewer viewer = getCurrentViewer();
final Object model = getCreateRequest().getNewObject();
if (model == null || viewer == null) {
return;
}
final Object o = getCurrentViewer().getEditPartRegistry().get(model);
if(o instanceof EditPart) {
Display.getCurrent().asyncExec(new Runnable() {
@Override public void run() {
EditPart part = (EditPart)o;
Request request = new DirectEditRequest();
part.performRequest(request);
}
});
}
}
示例2: getAdapter
import org.eclipse.gef.EditPartViewer; //导入依赖的package包/类
public Object getAdapter(Class adapter) {
if (adapter == GraphicalViewer.class || adapter == EditPartViewer.class)
return getGraphicalViewer();
else if (adapter == CommandStack.class)
return getCommandStack();
else if (adapter == EditDomain.class)
return getEditDomain();
else if (adapter == ActionRegistry.class)
return getActionRegistry();
else if (adapter == IPropertySheetPage.class)
return new PropertiesView(true);
else if (adapter == IContentOutlinePage.class) {
return new GW4EOutlinePage();
} else if (adapter == ZoomManager.class)
return ((ScalableRootEditPart) getGraphicalViewer().getRootEditPart()).getZoomManager();
return super.getAdapter(adapter);
}
示例3: createChangeConstraintCommand
import org.eclipse.gef.EditPartViewer; //导入依赖的package包/类
/**
* @see nexcore.tool.uml.ui.core.diagram.edit.policy.DiagramLayoutEditPolicy#createChangeConstraintCommand(org.eclipse.gef.EditPart,
* java.lang.Object)
*/
protected Command createChangeConstraintCommand(EditPart child, Object constraint) {
ChangeNodeConstraintCommand command = new ChangeNodeConstraintCommand(child, constraint);
List<EditPartViewer> editPartList = child.getViewer().getSelectedEditParts();
EditPart editPart;
boolean isLabel = false;
boolean isNotLabel = false;
for (int i = 0; i < editPartList.size(); i++) {
editPart = (EditPart) editPartList.get(i);
if (editPart instanceof LabelNodeEditPart || editPart instanceof CompartmentLabelNodeEditPart) {
isLabel = true;
} else if (!(editPart instanceof LabelNodeEditPart)) {
isNotLabel = true;
}
if (isLabel && isNotLabel) {
command.setCommandIsFalse(false);
}
}
return command;
}
示例4: keyUp
import org.eclipse.gef.EditPartViewer; //导入依赖的package包/类
/**
* @see org.eclipse.gef.tools.AbstractTool#keyUp(org.eclipse.swt.events.KeyEvent,
* org.eclipse.gef.EditPartViewer)
*/
@Override
public void keyUp(KeyEvent evt, EditPartViewer viewer) {
if ((evt.stateMask & SWT.SHIFT) == SWT.SHIFT) {
isShiftKeyPressed = false;
}
super.keyUp(evt, viewer);
}
开发者ID:SK-HOLDINGS-CC,项目名称:NEXCORE-UML-Modeler,代码行数:12,代码来源:LifeLineCreationToolWithAdditionalInformation.java
示例5: getTargetingConditional
import org.eclipse.gef.EditPartViewer; //导入依赖的package包/类
/**
* @see org.eclipse.gef.tools.SelectionTool#getTargetingConditional()
*/
@Override
protected Conditional getTargetingConditional() {
return new EditPartViewer.Conditional() {
public boolean evaluate(EditPart editpart) {
if(editpart instanceof LifeLineEditPart) {
if(getLocation().y >= FigureConstant.FIGURE_LIFELINE_TOP_MARGIN + FigureConstant.FIGURE_LIFELINE_HEAD_HEIGHT) {
Rectangle bounds = ((LifeLineEditPart) editpart).getFigure().getBounds();
if(bounds.x + bounds.width/2 - LineEditPart.LINE_SELECTABLE_WIDTH/2 <= getLocation().x
&& bounds.x + bounds.width/2 + LineEditPart.LINE_SELECTABLE_WIDTH/2 >= getLocation().x) {
return editpart.isSelectable();
} else {
return false;
}
} else {
return editpart.isSelectable();
}
} else {
return editpart.isSelectable();
}
}
};
}
示例6: mouseDrag
import org.eclipse.gef.EditPartViewer; //导入依赖的package包/类
/**
* @see org.eclipse.gef.tools.SelectionTool#mouseDrag(org.eclipse.swt.events.MouseEvent,
* org.eclipse.gef.EditPartViewer)
*/
@Override
public void mouseDrag(MouseEvent e, EditPartViewer viewer) {
// System.out.println(this.getTargetEditPart());
// DragTracker dragTacker = this.getDragTracker();
// if(getTargetEditPart() instanceof UseCaseEditPart){
// int i=0;
// }
// if (dragTacker instanceof ConnectionEndpointTracker) {
// ConnectionEndpointTracker c = (ConnectionEndpointTracker)dragTacker;
// Object obj =
// ((StructuredSelection)this.getCurrentViewer().getSelection()).getFirstElement();
// Command command = getTargetEditPart().getCommand(getTargetRequest());
// if (!(command instanceof UnexecutableCommand)) {
// int i = 0;
// }
// }
super.mouseDrag(e, viewer);
}
示例7: createResizeHandle
import org.eclipse.gef.EditPartViewer; //导入依赖的package包/类
@Override
@SuppressWarnings({ "rawtypes", "unchecked" })
protected void createResizeHandle(List handles, final int direction) {
handles.add(new ResizeHandle(getHost(), direction) {
@Override
protected DragTracker createDragTracker() {
return new ResizeTracker(getHost(), direction) {
@Override
public void mouseDrag(MouseEvent event, EditPartViewer viewer) {
event.stateMask |= SWT.SHIFT;
super.mouseDrag(event, viewer);
}
};
};
});
}
示例8: keyPressed
import org.eclipse.gef.EditPartViewer; //导入依赖的package包/类
@Override
public boolean keyPressed(KeyEvent event) {
if (UIUtil.isArrowKey(event.keyCode)) {
EditPartViewer viewer = getViewer();
if (viewer instanceof GraphicalViewer) {
JSSCompoundCommand ccmd = new JSSCompoundCommand(null);
for(Object selectedEditPart : getViewer().getSelectedEditParts()) {
if (selectedEditPart instanceof GraphicalEditPart) {
Object modelObj = ((EditPart) selectedEditPart).getModel();
if(modelObj instanceof MGraphicElement) {
MGraphicElement node = (MGraphicElement) modelObj;
ccmd.add(getNewXYCommand(event.keyCode,node));
}
}
}
if(!ccmd.isEmpty()) {
getViewer().getEditDomain().getCommandStack().execute(ccmd);
return true;
}
}
}
return super.keyPressed(event);
}
示例9: handleKeyDown
import org.eclipse.gef.EditPartViewer; //导入依赖的package包/类
@Override
protected boolean handleKeyDown(KeyEvent e) {
if (isInState(STATE_INITIAL) && UIUtil.isArrowKey(e.keyCode)) {
EditPartViewer viewer = getCurrentViewer();
if (viewer instanceof GraphicalViewer) {
JSSCompoundCommand ccmd = new JSSCompoundCommand(null);
for(Object selectedEditPart : getCurrentViewer().getSelectedEditParts()) {
if (selectedEditPart instanceof GraphicalEditPart) {
Object modelObj = ((EditPart) selectedEditPart).getModel();
if(modelObj instanceof MGraphicElement) {
MGraphicElement node = (MGraphicElement) modelObj;
ccmd.add(getNewXYCommand(e.keyCode,node));
}
}
}
if(!ccmd.isEmpty()) {
getDomain().getCommandStack().execute(ccmd);
return true;
}
}
}
return super.handleKeyDown(e);
}
示例10: mouseDown
import org.eclipse.gef.EditPartViewer; //导入依赖的package包/类
@Override
public void mouseDown(MouseEvent e, EditPartViewer viewer) {
if (viewer.getContents() instanceof AbstractModelEditPart) {
// マウスポインタがクリックされた位置を記録する。コピーしたオブジェクトの貼り付け位置として使う、等。
final AbstractModelEditPart editPart = (AbstractModelEditPart) viewer.getContents();
final IERDiagram diagram = (IERDiagram) editPart.getModel();
diagram.setMousePoint(new Point(e.x, e.y));
editPart.getFigure().translateToRelative(diagram.getMousePoint());
final ERFluteMultiPageEditor multiPageEditor = diagram.getEditor();
final int QUICK_OUTLINE_OPEN_BUTTON = 2;
if (e.button == QUICK_OUTLINE_OPEN_BUTTON && multiPageEditor != null) {
final MainDiagramEditor mainDiagramEditor = (MainDiagramEditor) multiPageEditor.getActiveEditor();
mainDiagramEditor.runERDiagramQuickOutlineAction();
}
}
super.mouseDown(e, viewer);
}
示例11: getTargetEditPart
import org.eclipse.gef.EditPartViewer; //导入依赖的package包/类
protected EditPart getTargetEditPart( )
{
if ( targetPart == null )
{
EditPartViewer viewer = UIUtil.getLayoutEditPartViewer( );
if ( viewer == null )
{
return null;
}
IStructuredSelection targets = (IStructuredSelection) viewer.getSelection( );
if ( targets.isEmpty( ) && targets.size( ) > 1 )
return null;
targetPart = (EditPart) targets.getFirstElement( );
}
return targetPart;
}
示例12: handleDrop
import org.eclipse.gef.EditPartViewer; //导入依赖的package包/类
/**
* Overriden for debug purposes.
* Note: the drop is actually performed in the DropEditPolicy.
*/
@Override
protected void handleDrop() {
trace.debug("handleDrop");
updateTargetRequest();
updateTargetEditPart();
if (getTargetEditPart() != null) {
final Command command = getCommand();
if (command != null && command.canExecute()) {
EditPartViewer viewer = getViewer();
final CommandStack commandStack = viewer.getEditDomain().getCommandStack();
WidgetUtils.runLaterInDisplayThread(viewer.getControl(), new Runnable() {
@Override
public void run() {
commandStack.execute(command);
}
});
} else {
getCurrentEvent().detail = DND.DROP_NONE;
}
} else {
getCurrentEvent().detail = DND.DROP_NONE;
}
}
示例13: performCreation
import org.eclipse.gef.EditPartViewer; //导入依赖的package包/类
/**
* After the creation of a {@link NamedElement} through a pallet entry this method is called. This method
* send a {@link DirectEditRequest} to the edit part of the just created {@link NamedElement}. Through the
* request can the user edit the name of the NamedElement direct after the creation of the NamedElement.
*
* */
@Override
protected void performCreation(final int button) {
super.performCreation(button);
final EditPartViewer viewer = getCurrentViewer();
final Object model = getCreateRequest().getNewObject();
if (model == null || viewer == null) {
return;
}
final Object o = getCurrentViewer().getEditPartRegistry().get(model);
if (o instanceof EditPart) {
Display.getCurrent().asyncExec(new Runnable() {
@Override
public void run() {
final EditPart part = (EditPart) o;
final Request request = new DirectEditRequest();
part.performRequest(request);
}
});
}
}
示例14: validateFixedColumnWidth
import org.eclipse.gef.EditPartViewer; //导入依赖的package包/类
public static void validateFixedColumnWidth(ExtendedItemHandle handle)
{
EditPartViewer viewer = UIUtil.getLayoutEditPartViewer( );
Object obj = viewer.getEditPartRegistry( ).get( handle );
if (!(obj instanceof CrosstabTableEditPart))
{
return;
}
CrosstabTableEditPart part = (CrosstabTableEditPart)obj;
Dimension tableSize = part.getFigure( ).getSize( );
part.getCrosstabHandleAdapter( )
.setWidth( converPixToDefaultUnit( tableSize.width, part),
getDefaultUnits(part ) );
adjustOthersColumn( new ArrayList( ), part, getAdjustValue( part ));
}
示例15: buildContextMenu
import org.eclipse.gef.EditPartViewer; //导入依赖的package包/类
@Override
public void buildContextMenu(final IMenuManager manager)
{
final EditPartViewer viewer = getViewer();
final IStructuredSelection selection = (IStructuredSelection) viewer.getSelection();
if (!selection.isEmpty())
{
final EditPart part = (EditPart) selection.getFirstElement();
if (part instanceof ContourEditPart)
{
if (part.getModel() instanceof IContour)
{
buildContextMenuFor((IContour) part.getModel(), manager);
}
}
}
manager.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));
}