use of org.eclipse.scout.rt.client.ui.dnd.TransferObject in project scout.rt by eclipse.
the class TableEventBuffer method identicalEventHashCode.
/**
* Computes a hash value for identical table events. This method must be kept in sync with
* {@link #isIdenticalEvent(TableEvent, TableEvent)}.
*/
protected int identicalEventHashCode(TableEvent event) {
final int prime = 31;
int result = 1;
result = prime * result + event.getType();
result = prime * result + (event.isConsumed() ? 1231 : 1237);
result = prime * result + (event.isSortInMemoryAllowed() ? 1231 : 1237);
List<ITableRow> rows = event.getRows();
result = prime * result + ((rows == null) ? 0 : rows.hashCode());
List<IMenu> popupMenus = event.getPopupMenus();
result = prime * result + ((popupMenus == null) ? 0 : popupMenus.hashCode());
TransferObject dragObject = event.getDragObject();
result = prime * result + ((dragObject == null) ? 0 : dragObject.hashCode());
TransferObject dropObject = event.getDropObject();
result = prime * result + ((dropObject == null) ? 0 : dropObject.hashCode());
TransferObject copyObject = event.getCopyObject();
result = prime * result + ((copyObject == null) ? 0 : copyObject.hashCode());
Collection<IColumn<?>> columns = event.getColumns();
result = prime * result + ((columns == null) ? 0 : columns.hashCode());
return result;
}
use of org.eclipse.scout.rt.client.ui.dnd.TransferObject in project scout.rt by eclipse.
the class OutlineMediator method mediateTreeNodesDragRequest.
public void mediateTreeNodesDragRequest(TreeEvent e, IPageWithTable<? extends ITable> pageWithTable) {
List<ITableRow> rows = pageWithTable.getTableRowsFor(e.getNodes());
ITable table = pageWithTable.getTable();
table.getUIFacade().setSelectedRowsFromUI(rows);
TransferObject t = table.getUIFacade().fireRowsDragRequestFromUI();
if (t != null) {
e.setDragObject(t);
}
}
use of org.eclipse.scout.rt.client.ui.dnd.TransferObject in project scout.rt by eclipse.
the class AbstractTree method initConfig.
protected void initConfig() {
// default enabled
m_enabled = NamedBitMaskHelper.ALL_BITS_SET;
m_eventHistory = createEventHistory();
m_eventBuffer = createEventBuffer();
m_uiFacade = BEANS.get(ModelContextProxy.class).newProxy(createUIFacade(), ModelContext.copyCurrent());
m_contributionHolder = new ContributionComposite(this);
setEnabled(true);
setTitle(getConfiguredTitle());
setIconId(getConfiguredIconId());
setDefaultIconId(getConfiguredDefaultIconId());
setCssClass(getConfiguredCssClass());
setAutoTitle(getConfiguredAutoTitle());
setCheckable(getConfiguredCheckable());
setNodeHeightHint(getConfiguredNodeHeightHint());
setMultiCheck(getConfiguredMultiCheck());
setMultiSelect(getConfiguredMultiSelect());
setAutoDiscardOnDelete(getConfiguredAutoDiscardOnDelete());
setDragEnabled(getConfiguredDragEnabled());
setDragType(getConfiguredDragType());
setDropType(getConfiguredDropType());
setDropMaximumSize(getConfiguredDropMaximumSize());
setRootNodeVisible(getConfiguredRootNodeVisible());
setRootHandlesVisible(getConfiguredRootHandlesVisible());
setScrollToSelection(getConfiguredScrollToSelection());
setSaveAndRestoreScrollbars(getConfiguredSaveAndRestoreScrollbars());
setAutoCheckChildNodes(getConfiguredAutoCheckChildNodes());
setLazyExpandingEnabled(getConfiguredLazyExpandingEnabled());
setDisplayStyle(getConfiguredDisplayStyle());
setToggleBreadcrumbStyleEnabled(getConfiguredToggleBreadcrumbStyleEnabled());
setRootNode(new AbstractTreeNode() {
});
// add Convenience observer for drag & drop callbacks and event history
addTreeListener(new TreeAdapter() {
@Override
public void treeChanged(TreeEvent e) {
// event history
IEventHistory<TreeEvent> h = getEventHistory();
if (h != null) {
h.notifyEvent(e);
}
// dnd
switch(e.getType()) {
case TreeEvent.TYPE_NODES_DRAG_REQUEST:
{
m_lastSeenDropNode = null;
if (e.getDragObject() == null) {
try {
TransferObject transferObject = interceptDrag(e.getNode());
if (transferObject == null) {
transferObject = interceptDrag(e.getNodes());
}
e.setDragObject(transferObject);
} catch (Exception t) {
LOG.error("Drag", t);
}
}
break;
}
case TreeEvent.TYPE_NODE_DROP_ACTION:
{
m_lastSeenDropNode = null;
if (e.getDropObject() != null) {
try {
interceptDrop(e.getNode(), e.getDropObject());
} catch (Exception t) {
LOG.error("Drop", t);
}
}
break;
}
case TreeEvent.TYPE_NODES_SELECTED:
{
rebuildKeyStrokesInternal();
break;
}
case TreeEvent.TYPE_NODES_CHECKED:
{
try {
interceptNodesChecked(CollectionUtility.arrayList(e.getNodes()));
} catch (RuntimeException ex) {
BEANS.get(ExceptionHandler.class).handle(ex);
}
break;
}
case TreeEvent.TYPE_NODE_DROP_TARGET_CHANGED:
{
try {
if (m_lastSeenDropNode == null || m_lastSeenDropNode != e.getNode()) {
m_lastSeenDropNode = e.getNode();
interceptDropTargetChanged(e.getNode());
}
} catch (RuntimeException ex) {
LOG.error("DropTargetChanged", ex);
}
break;
}
case TreeEvent.TYPE_DRAG_FINISHED:
{
m_lastSeenDropNode = null;
}
}
}
});
// key shortcuts
List<Class<? extends IKeyStroke>> configuredKeyStrokes = getConfiguredKeyStrokes();
List<IKeyStroke> ksList = new ArrayList<IKeyStroke>(configuredKeyStrokes.size());
for (Class<? extends IKeyStroke> keystrokeClazz : configuredKeyStrokes) {
ksList.add(ConfigurationUtility.newInnerInstance(this, keystrokeClazz));
}
// ticket 87370: add ENTER key stroke when execNodeAction has an override
if (ConfigurationUtility.isMethodOverwrite(AbstractTree.class, "execNodeAction", new Class[] { ITreeNode.class }, this.getClass())) {
ksList.add(new KeyStroke("ENTER") {
@Override
protected void execAction() {
fireNodeAction(getSelectedNode());
}
});
}
List<IKeyStroke> contributedKeyStrokes = m_contributionHolder.getContributionsByClass(IKeyStroke.class);
contributedKeyStrokes.addAll(contributedKeyStrokes);
m_baseKeyStrokes = ksList;
setKeyStrokesInternal(m_baseKeyStrokes);
// menus
List<Class<? extends IMenu>> declaredMenus = getDeclaredMenus();
List<IMenu> contributedMenus = m_contributionHolder.getContributionsByClass(IMenu.class);
OrderedCollection<IMenu> menus = new OrderedCollection<IMenu>();
for (Class<? extends IMenu> menuClazz : declaredMenus) {
IMenu menu = ConfigurationUtility.newInnerInstance(this, menuClazz);
menus.addOrdered(menu);
}
try {
injectMenusInternal(menus);
} catch (Exception e) {
LOG.error("Error occured while dynamically contributing menus.", e);
}
menus.addAllOrdered(contributedMenus);
new MoveActionNodesHandler<IMenu>(menus).moveModelObjects();
TreeContextMenu contextMenu = new TreeContextMenu(this, menus.getOrderedList());
setContextMenuInternal(contextMenu);
}
Aggregations