Runtime

org.eclipse.gmf.runtime.diagram.ui.commands
Class PromptForConnectionAndEndCommand

java.lang.Object
  extended byorg.eclipse.core.commands.operations.AbstractOperation
      extended byorg.eclipse.gmf.runtime.common.core.command.AbstractCommand
          extended byorg.eclipse.gmf.runtime.diagram.ui.commands.PopupMenuCommand
              extended byorg.eclipse.gmf.runtime.diagram.ui.commands.PromptForConnectionAndEndCommand
All Implemented Interfaces:
ICommand, org.eclipse.gmf.runtime.common.core.internal.command.ICommandWithSettableResult, IUndoableOperation

public class PromptForConnectionAndEndCommand
extends PopupMenuCommand

A command that pops up a menu which can allow the user to select the type of connection to be created and whether they want to create a new type or select an existing element for the other end of the connection.

The getRelationshipTypeAdapter() method returns an adaptable to the relationship type result.

The getEndAdapter() method returns an adaptable to the end type result.


Nested Class Summary
protected  class PromptForConnectionAndEndCommand.ConnectionAndEndLabelProvider
          Label provider of the first and only popup for the type of the other end when there is only one connection type (e.g. a single relationship type palette tool is used).
protected  class PromptForConnectionAndEndCommand.ConnectionLabelProvider
          Label provider of the first popup menu with the relationship types.
protected  class PromptForConnectionAndEndCommand.EndLabelProvider
          Label provider of the second popup (submenus) for the type of the other end.
 
Field Summary
 
Fields inherited from class org.eclipse.gmf.runtime.diagram.ui.commands.PopupMenuCommand
POPUP_DIALOG, POPUP_MENU
 
Constructor Summary
PromptForConnectionAndEndCommand(CreateConnectionRequest request, IGraphicalEditPart containerEP)
          Creates a new PromptForConnectionAndEndCommand.
 
Method Summary
 boolean canExecute()
           
protected  PopupMenu createPopupMenu()
          Gets the content to be used in the popup menu from the Modeling Assistant Service and creates the popup menu.
protected  CommandResult doExecuteWithResult(IProgressMonitor progressMonitor, IAdaptable info)
          Pops up the dialog with the content provided.
 ObjectAdapter getConnectionAdapter()
          Gets the connectionAdapter.
protected  ILabelProvider getConnectionAndEndLabelProvider(java.lang.Object connectionItem)
          Gets the label provider that is to be used when there is only one option for the connection type so the popup menu consists of a single menu identifying the connection type to be created and options for the other end of which the user must choose
protected  ILabelProvider getConnectionLabelProvider()
          Gets the label provider that is to be used in the first menu of the popup where the user is to choose the connection to be created.
protected  java.util.List getConnectionMenuContent()
          Gets a list of all the connection items that will represent the connection choices and will appear in the first part of the popup menu.
 IAdaptable getEndAdapter()
          Gets the endAdapter.
protected  ILabelProvider getEndLabelProvider()
          Gets the label provider that is to be used in the second menu of the popup where the user is to choose the end (could be source or target) to be created.
protected  java.util.List getEndMenuContent(java.lang.Object connectionItem)
          Gets a list of all the end items that will represent the other end choices and will appear in the submenu popup of the given connection item.
protected  boolean isDirectionReversed()
          Returns true if the request is a reversed CreateUnspecifiedTypeConnectionRequest.
 
Methods inherited from class org.eclipse.gmf.runtime.diagram.ui.commands.PopupMenuCommand
canRedo, canUndo, doRedoWithResult, doUndoWithResult, getParentShell, getPopupDialog, getPopupMenu, setParentShell, setPopupDialog, setPopupMenu
 
Methods inherited from class org.eclipse.gmf.runtime.common.core.command.AbstractCommand
compose, dispose, execute, getAffectedFiles, getCommandResult, internalSetResult, redo, reduce, setResult, undo
 
Methods inherited from class org.eclipse.core.commands.operations.AbstractOperation
addContext, getContexts, getLabel, hasContext, removeContext, setLabel, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.eclipse.core.commands.operations.IUndoableOperation
addContext, getContexts, getLabel, hasContext, removeContext
 

Constructor Detail

PromptForConnectionAndEndCommand

public PromptForConnectionAndEndCommand(CreateConnectionRequest request,
                                        IGraphicalEditPart containerEP)
Creates a new PromptForConnectionAndEndCommand.

Parameters:
request - The request to create a connection. It may contain the connection type or it may be a CreateUnspecifiedTypeConnectionRequest.
containerEP - The container edit part, where the view and element request to create the other end is sent. This is used only for testing that a type is valid for the other end.
Method Detail

getConnectionMenuContent

protected java.util.List getConnectionMenuContent()
Gets a list of all the connection items that will represent the connection choices and will appear in the first part of the popup menu.

If the objects in this are not IElementTypes or they require a special label provider, then PromptForConnectionAndEndCommand.getConnectionLabelProvider() should be overridden to provide this.

When this command has executed, the connection adapter result (PromptForConnectionAndEndCommand.getConnectionAdapter()) will be populated with the connection item chosen.

Returns:
the list of connection items to appear in the popup menu

getEndMenuContent

protected java.util.List getEndMenuContent(java.lang.Object connectionItem)
Gets a list of all the end items that will represent the other end choices and will appear in the submenu popup of the given connection item.

If the objects in this are not IElementTypes or they require a special label provider, then PromptForConnectionAndEndCommand.getEndLabelProvider() should be overridden to provide this.

When this command has executed, the end adapter result (PromptForConnectionAndEndCommand.getEndAdapter()) will be populated with the end item chosen.

Parameters:
connectionItem - the connection item for which this will be a submenu
Returns:
the list of end items to appear in the popup menu

createPopupMenu

protected PopupMenu createPopupMenu()
Gets the content to be used in the popup menu from the Modeling Assistant Service and creates the popup menu.

Returns:
the top-level popup menu

canExecute

public boolean canExecute()

doExecuteWithResult

protected CommandResult doExecuteWithResult(IProgressMonitor progressMonitor,
                                            IAdaptable info)
                                     throws ExecutionException
Pops up the dialog with the content provided. If the user selects 'select existing', then the select elements dialog also appears.

Overrides:
doExecuteWithResult in class PopupMenuCommand
Throws:
ExecutionException

getConnectionAdapter

public ObjectAdapter getConnectionAdapter()
Gets the connectionAdapter.

Returns:
Returns the connectionAdapter.

getEndAdapter

public IAdaptable getEndAdapter()
Gets the endAdapter.

Returns:
Returns the endAdapter.

isDirectionReversed

protected boolean isDirectionReversed()
Returns true if the request is a reversed CreateUnspecifiedTypeConnectionRequest.

Returns:
Returns true if the request is a reversed CreateUnspecifiedTypeConnectionRequest; false otherwise

getConnectionLabelProvider

protected ILabelProvider getConnectionLabelProvider()
Gets the label provider that is to be used in the first menu of the popup where the user is to choose the connection to be created.

Returns:
the connection label provider

getEndLabelProvider

protected ILabelProvider getEndLabelProvider()
Gets the label provider that is to be used in the second menu of the popup where the user is to choose the end (could be source or target) to be created.

Returns:
the end label provider

getConnectionAndEndLabelProvider

protected ILabelProvider getConnectionAndEndLabelProvider(java.lang.Object connectionItem)
Gets the label provider that is to be used when there is only one option for the connection type so the popup menu consists of a single menu identifying the connection type to be created and options for the other end of which the user must choose

Parameters:
connectionItem - the single known connection item
Returns:
the label provider

Runtime

Guidelines for using Eclipse APIs.

Copyright (c) IBM Corp., Borland Software Corp., and others 2005,2006. All rights reserved.