| 47 | } |
| 48 | |
| 49 | void PartStack::PartStackDropResult::Drop() |
| 50 | { |
| 51 | // If we're dragging a pane over itself do nothing |
| 52 | //if (dropResult.getInsertionPoint() == pane.getPresentablePart()) { return; }; |
| 53 | |
| 54 | Object::Pointer cookie; |
| 55 | if (dropResult != 0) |
| 56 | { |
| 57 | cookie = dropResult->GetCookie(); |
| 58 | } |
| 59 | |
| 60 | PartPane::Pointer pane(this->pane); |
| 61 | PartStack::Pointer stack(this->stack); |
| 62 | // Handle cross window drops by opening a new editor |
| 63 | if (pane->GetPartReference().Cast<IEditorReference> () != 0) |
| 64 | { |
| 65 | IEditorReference::Pointer editorRef = pane->GetPartReference().Cast< |
| 66 | IEditorReference> (); |
| 67 | if (pane->GetWorkbenchWindow() != stack->GetWorkbenchWindow()) |
| 68 | { |
| 69 | try |
| 70 | { |
| 71 | IEditorInput::Pointer input = editorRef->GetEditorInput(); |
| 72 | |
| 73 | // Close the old editor and capture the actual closed state incase of a 'cancel' |
| 74 | bool editorClosed = pane->GetPage()->CloseEditor(editorRef, true); |
| 75 | |
| 76 | // Only open open the new editor if the old one closed |
| 77 | if (editorClosed) |
| 78 | stack->GetPage()->OpenEditor(input, editorRef->GetId()); |
| 79 | return; |
| 80 | } |
| 81 | catch (const PartInitException& e) |
| 82 | { |
| 83 | //e.printStackTrace(); |
| 84 | BERRY_ERROR << e.what(); |
| 85 | } |
| 86 | |
| 87 | } |
| 88 | } |
| 89 | |
| 90 | if (pane->GetContainer() != stack) |
| 91 | { |
| 92 | // Moving from another stack |
| 93 | stack->DerefPart(pane); |
| 94 | pane->Reparent(stack->GetParent()); |
| 95 | stack->Add(pane, cookie); |
| 96 | stack->SetSelection(pane); |
| 97 | pane->SetFocus(); |
| 98 | } |
| 99 | else if (cookie != 0) |
| 100 | { |
| 101 | // Rearranging within this stack |
| 102 | stack->GetPresentation()->MovePart(stack->GetPresentablePart(pane), cookie); |
| 103 | } |
| 104 | } |
| 105 | |
| 106 | CursorType PartStack::PartStackDropResult::GetCursor() |
no test coverage detected