![]() |
![]() |
org.eclipse.e4.ui.workbench.addons.swt_0.10.3.v20130124-18562216:43:02.132 INFO jd.cli.Main - Decompiling org.eclipse.e4.ui.workbench.addons.swt_0.10.3.v20130124-185622.jar package org.eclipse.e4.ui.workbench.addons.cleanupaddon; import java.util.List; import org.eclipse.e4.ui.model.application.ui.MElementContainer; import org.eclipse.e4.ui.model.application.ui.MUIElement; import org.eclipse.e4.ui.model.application.ui.advanced.MPerspective; import org.eclipse.e4.ui.model.application.ui.basic.MPartSashContainer; import org.eclipse.e4.ui.model.application.ui.basic.MWindow; import org.eclipse.e4.ui.workbench.modeling.EModelService; import org.eclipse.e4.ui.workbench.renderers.swt.SashLayout; import org.eclipse.emf.ecore.EObject; import org.eclipse.swt.widgets.Composite; class CleanupAddon$1$1 implements Runnable { CleanupAddon$1$1(CleanupAddon.1 param1, MElementContainer paramMElementContainer) {} public void run() { int tbrCount = access$0this$1).modelService.toBeRenderedCount(val$container); boolean lastStack = CleanupAddon.1.access$0(this$1).isLastEditorStack(val$container); if ((tbrCount == 0) && (!lastStack)) { val$container.setToBeRendered(false); } MElementContainer<?> lclContainer = val$container; if (lclContainer.getChildren().size() == 0) { MElementContainer<MUIElement> parent = val$container.getParent(); if ((parent != null) && (!lastStack)) { val$container.setToBeRendered(false); parent.getChildren().remove(val$container); } else if ((val$container instanceof MWindow)) { MUIElement eParent = (MUIElement)((EObject)val$container) .eContainer(); if ((eParent instanceof MPerspective)) { ((MPerspective)eParent).getWindows().remove(val$container); } else if ((eParent instanceof MWindow)) { ((MWindow)eParent).getWindows().remove(val$container); } } } else if ((val$container.getChildren().size() == 1) && ((val$container instanceof MPartSashContainer))) { MUIElement theChild = (MUIElement)val$container.getChildren().get(0); MElementContainer<MUIElement> parentContainer = val$container .getParent(); if (parentContainer != null) { int index = parentContainer.getChildren().indexOf(val$container); if (((theChild instanceof MPartSashContainer)) && ((val$container.getWidget() instanceof Composite))) { Composite theComp = (Composite)val$container.getWidget(); Object tmp = theChild.getWidget(); theChild.setWidget(theComp); theComp.setLayout(new SashLayout(theComp, theChild)); theComp.setData("modelElement", theChild); val$container.setWidget(tmp); } theChild.setContainerData(val$container.getContainerData()); val$container.getChildren().remove(theChild); parentContainer.getChildren().add(index, theChild); val$container.setToBeRendered(false); parentContainer.getChildren().remove(val$container); } } } } /* Location: * Qualified Name: org.eclipse.e4.ui.workbench.addons.cleanupaddon.CleanupAddon.1.1 * Java Class Version: 5 (49.0) * JD-Core Version: 0.7.1 */ package org.eclipse.e4.ui.workbench.addons.cleanupaddon; import java.util.List; import org.eclipse.e4.ui.model.application.MApplication; import org.eclipse.e4.ui.model.application.ui.MElementContainer; import org.eclipse.e4.ui.model.application.ui.MUIElement; import org.eclipse.e4.ui.model.application.ui.advanced.MArea; import org.eclipse.e4.ui.model.application.ui.advanced.MPerspective; import org.eclipse.e4.ui.model.application.ui.advanced.MPerspectiveStack; import org.eclipse.e4.ui.model.application.ui.basic.MPartSashContainer; import org.eclipse.e4.ui.model.application.ui.basic.MTrimBar; import org.eclipse.e4.ui.model.application.ui.basic.MWindow; import org.eclipse.e4.ui.model.application.ui.menu.MMenuElement; import org.eclipse.e4.ui.model.application.ui.menu.MToolBar; import org.eclipse.e4.ui.workbench.modeling.EModelService; import org.eclipse.e4.ui.workbench.renderers.swt.SashLayout; import org.eclipse.emf.ecore.EObject; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Display; import org.osgi.service.event.Event; import org.osgi.service.event.EventHandler; class CleanupAddon$1 implements EventHandler { CleanupAddon$1(CleanupAddon paramCleanupAddon) {} public void handleEvent(Event event) { Object changedObj = event.getProperty("ChangedElement"); String eventType = (String)event.getProperty("EventType"); if ("REMOVE".equals(eventType)) { final MElementContainer<?> container = (MElementContainer)changedObj; MUIElement containerParent = container.getParent(); if (((container instanceof MApplication)) || ((container instanceof MPerspectiveStack)) || ((container instanceof MMenuElement)) || ((container instanceof MTrimBar)) || ((container instanceof MToolBar)) || ((container instanceof MArea)) || (container.getTags().contains("NoAutoCollapse"))) { return; } if (((container instanceof MWindow)) && ((containerParent instanceof MApplication))) { return; } Display display = Display.getCurrent(); if (display != null) { Display.getCurrent().asyncExec(new Runnable() { public void run() { int tbrCount = this$0.modelService.toBeRenderedCount(container); boolean lastStack = this$0.isLastEditorStack(container); if ((tbrCount == 0) && (!lastStack)) { container.setToBeRendered(false); } MElementContainer<?> lclContainer = container; if (lclContainer.getChildren().size() == 0) { MElementContainer<MUIElement> parent = container.getParent(); if ((parent != null) && (!lastStack)) { container.setToBeRendered(false); parent.getChildren().remove(container); } else if ((container instanceof MWindow)) { MUIElement eParent = (MUIElement)((EObject)container) .eContainer(); if ((eParent instanceof MPerspective)) { ((MPerspective)eParent).getWindows().remove(container); } else if ((eParent instanceof MWindow)) { ((MWindow)eParent).getWindows().remove(container); } } } else if ((container.getChildren().size() == 1) && ((container instanceof MPartSashContainer))) { MUIElement theChild = (MUIElement)container.getChildren().get(0); MElementContainer<MUIElement> parentContainer = container .getParent(); if (parentContainer != null) { int index = parentContainer.getChildren().indexOf(container); if (((theChild instanceof MPartSashContainer)) && ((container.getWidget() instanceof Composite))) { Composite theComp = (Composite)container.getWidget(); Object tmp = theChild.getWidget(); theChild.setWidget(theComp); theComp.setLayout(new SashLayout(theComp, theChild)); theComp.setData("modelElement", theChild); container.setWidget(tmp); } theChild.setContainerData(container.getContainerData()); container.getChildren().remove(theChild); parentContainer.getChildren().add(index, theChild); container.setToBeRendered(false); parentContainer.getChildren().remove(container); } } } }); } } } } /* Location: * Qualified Name: org.eclipse.e4.ui.workbench.addons.cleanupaddon.CleanupAddon.1 * Java Class Version: 5 (49.0) * JD-Core Version: 0.7.1 */ package org.eclipse.e4.ui.workbench.addons.cleanupaddon; import org.eclipse.e4.core.contexts.IEclipseContext; import org.eclipse.e4.ui.internal.workbench.swt.AbstractPartRenderer; import org.eclipse.e4.ui.model.application.MApplication; import org.eclipse.e4.ui.model.application.ui.MElementContainer; import org.eclipse.e4.ui.model.application.ui.MUIElement; import org.eclipse.e4.ui.model.application.ui.basic.MTrimBar; import org.eclipse.e4.ui.model.application.ui.basic.MWindow; import org.eclipse.e4.ui.model.application.ui.menu.MToolBar; import org.eclipse.swt.graphics.Rectangle; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Control; import org.eclipse.swt.widgets.Shell; import org.osgi.service.event.Event; import org.osgi.service.event.EventHandler; class CleanupAddon$2 implements EventHandler { CleanupAddon$2(CleanupAddon paramCleanupAddon) {} public void handleEvent(Event event) { MUIElement changedObj = (MUIElement)event.getProperty("ChangedElement"); if (((changedObj instanceof MTrimBar)) || ((changedObj.getParent() instanceof MToolBar))) { return; } if ((changedObj.getWidget() instanceof Shell)) { ((Shell)changedObj.getWidget()).setVisible(changedObj.isVisible()); } else if ((changedObj.getWidget() instanceof Rectangle)) { if (changedObj.isVisible()) { MUIElement parent = changedObj.getParent(); if (!parent.isVisible()) { parent.setVisible(true); } } else { MElementContainer<MUIElement> parent = changedObj.getParent(); boolean makeInvisible = true; for (MUIElement kid : parent.getChildren()) { if ((kid.isToBeRendered()) && (kid.isVisible())) { makeInvisible = false; break; } } if (makeInvisible) { parent.setVisible(false); } } } else if ((changedObj.getWidget() instanceof Control)) { Control ctrl = (Control)changedObj.getWidget(); MElementContainer<MUIElement> parent = changedObj.getParent(); if ((parent == null) || ((parent instanceof MToolBar))) { return; } if (changedObj.isVisible()) { if (parent.getRenderer() != null) { Object myParent = ((AbstractPartRenderer)parent.getRenderer()) .getUIContainer(changedObj); if ((myParent instanceof Composite)) { Composite parentComp = (Composite)myParent; ctrl.setParent(parentComp); Control prevControl = null; for (MUIElement childME : parent.getChildren()) { if (childME == changedObj) { break; } if (((childME.getWidget() instanceof Control)) && (childME.isVisible())) { prevControl = (Control)childME.getWidget(); } } if (prevControl != null) { ctrl.moveBelow(prevControl); } else { ctrl.moveAbove(null); } ctrl.getShell().layout(new Control[] { ctrl }, 4); } if (!parent.isVisible()) { parent.setVisible(true); } } } else { Shell limbo = (Shell)this$0.app.getContext().get("limbo"); Composite curParent = ctrl.getParent(); ctrl.setParent(limbo); curParent.layout(true); if (curParent.getShell() != curParent) { curParent.getShell().layout(new Control[] { curParent }, 4); } if ((parent instanceof MWindow)) { return; } boolean makeParentInvisible = true; for (MUIElement kid : parent.getChildren()) { if ((kid.isToBeRendered()) && (kid.isVisible())) { makeParentInvisible = false; break; } } if (makeParentInvisible) { parent.setVisible(false); } } } } } /* Location: * Qualified Name: org.eclipse.e4.ui.workbench.addons.cleanupaddon.CleanupAddon.2 * Java Class Version: 5 (49.0) * JD-Core Version: 0.7.1 */ package org.eclipse.e4.ui.workbench.addons.cleanupaddon; import org.eclipse.e4.ui.model.application.ui.MElementContainer; class CleanupAddon$3$1 implements Runnable { CleanupAddon$3$1(CleanupAddon.3 param3, MElementContainer paramMElementContainer) {} public void run() { if (!CleanupAddon.3.access$0(this$1).isLastEditorStack(val$theContainer)) { val$theContainer.setToBeRendered(false); } } } /* Location: * Qualified Name: org.eclipse.e4.ui.workbench.addons.cleanupaddon.CleanupAddon.3.1 * Java Class Version: 5 (49.0) * JD-Core Version: 0.7.1 */ package org.eclipse.e4.ui.workbench.addons.cleanupaddon; import java.util.List; import org.eclipse.e4.ui.model.application.ui.MElementContainer; import org.eclipse.e4.ui.model.application.ui.MUIElement; import org.eclipse.e4.ui.model.application.ui.advanced.MPerspective; import org.eclipse.e4.ui.model.application.ui.advanced.MPerspectiveStack; import org.eclipse.e4.ui.model.application.ui.advanced.MPlaceholder; import org.eclipse.e4.ui.model.application.ui.basic.MWindow; import org.eclipse.e4.ui.workbench.modeling.EModelService; import org.eclipse.swt.widgets.Display; import org.osgi.service.event.Event; import org.osgi.service.event.EventHandler; class CleanupAddon$3 implements EventHandler { CleanupAddon$3(CleanupAddon paramCleanupAddon) {} public void handleEvent(Event event) { MUIElement changedObj = (MUIElement)event.getProperty("ChangedElement"); MElementContainer<MUIElement> container = null; if (changedObj.getCurSharedRef() != null) { container = changedObj.getCurSharedRef().getParent(); } else { container = changedObj.getParent(); } if (container == null) { return; } MUIElement containerElement = container; if (((containerElement instanceof MWindow)) && (containerElement.getParent() != null)) { return; } if ((this$0.isLastEditorStack(containerElement)) || ((containerElement instanceof MPerspective)) || ((containerElement instanceof MPerspectiveStack))) { return; } Boolean toBeRendered = (Boolean)event.getProperty("NewValue"); if (toBeRendered.booleanValue()) { if (!container.isToBeRendered()) { container.setToBeRendered(true); } } else { if (container.getTags().contains("NoAutoCollapse")) { return; } int visCount = this$0.modelService.countRenderableChildren(container); final MElementContainer<MUIElement> theContainer = container; if (visCount == 0) { Display.getCurrent().asyncExec(new Runnable() { public void run() { if (!this$0.isLastEditorStack(theContainer)) { theContainer.setToBeRendered(false); } } }); } else { boolean makeInvisible = true; for (MUIElement kid : container.getChildren()) { if (kid.isToBeRendered()) { if (kid.isVisible()) { makeInvisible = false; break; } } } if (makeInvisible) { container.setVisible(false); } } } } } /* Location: * Qualified Name: org.eclipse.e4.ui.workbench.addons.cleanupaddon.CleanupAddon.3 * Java Class Version: 5 (49.0) * JD-Core Version: 0.7.1 */ package org.eclipse.e4.ui.workbench.addons.cleanupaddon; import java.util.List; import javax.annotation.PostConstruct; import javax.annotation.PreDestroy; import javax.inject.Inject; import org.eclipse.e4.core.contexts.IEclipseContext; import org.eclipse.e4.core.services.events.IEventBroker; import org.eclipse.e4.ui.internal.workbench.swt.AbstractPartRenderer; import org.eclipse.e4.ui.model.application.MApplication; import org.eclipse.e4.ui.model.application.ui.MElementContainer; import org.eclipse.e4.ui.model.application.ui.MUIElement; import org.eclipse.e4.ui.model.application.ui.advanced.MArea; import org.eclipse.e4.ui.model.application.ui.advanced.MPerspective; import org.eclipse.e4.ui.model.application.ui.advanced.MPerspectiveStack; import org.eclipse.e4.ui.model.application.ui.advanced.MPlaceholder; import org.eclipse.e4.ui.model.application.ui.basic.MPartSashContainer; import org.eclipse.e4.ui.model.application.ui.basic.MTrimBar; import org.eclipse.e4.ui.model.application.ui.basic.MWindow; import org.eclipse.e4.ui.model.application.ui.menu.MMenuElement; import org.eclipse.e4.ui.model.application.ui.menu.MToolBar; import org.eclipse.e4.ui.workbench.modeling.EModelService; import org.eclipse.e4.ui.workbench.renderers.swt.SashLayout; import org.eclipse.emf.ecore.EObject; import org.eclipse.swt.graphics.Rectangle; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Control; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Shell; import org.osgi.service.event.Event; import org.osgi.service.event.EventHandler; public class CleanupAddon { @Inject IEventBroker eventBroker; @Inject EModelService modelService; @Inject MApplication app; private EventHandler childrenHandler = new EventHandler() { public void handleEvent(Event event) { Object changedObj = event.getProperty("ChangedElement"); String eventType = (String)event.getProperty("EventType"); if ("REMOVE".equals(eventType)) { final MElementContainer<?> container = (MElementContainer)changedObj; MUIElement containerParent = container.getParent(); if (((container instanceof MApplication)) || ((container instanceof MPerspectiveStack)) || ((container instanceof MMenuElement)) || ((container instanceof MTrimBar)) || ((container instanceof MToolBar)) || ((container instanceof MArea)) || (container.getTags().contains("NoAutoCollapse"))) { return; } if (((container instanceof MWindow)) && ((containerParent instanceof MApplication))) { return; } Display display = Display.getCurrent(); if (display != null) { Display.getCurrent().asyncExec(new Runnable() { public void run() { int tbrCount = modelService.toBeRenderedCount(container); boolean lastStack = isLastEditorStack(container); if ((tbrCount == 0) && (!lastStack)) { container.setToBeRendered(false); } MElementContainer<?> lclContainer = container; if (lclContainer.getChildren().size() == 0) { MElementContainer<MUIElement> parent = container.getParent(); if ((parent != null) && (!lastStack)) { container.setToBeRendered(false); parent.getChildren().remove(container); } else if ((container instanceof MWindow)) { MUIElement eParent = (MUIElement)((EObject)container) .eContainer(); if ((eParent instanceof MPerspective)) { ((MPerspective)eParent).getWindows().remove(container); } else if ((eParent instanceof MWindow)) { ((MWindow)eParent).getWindows().remove(container); } } } else if ((container.getChildren().size() == 1) && ((container instanceof MPartSashContainer))) { MUIElement theChild = (MUIElement)container.getChildren().get(0); MElementContainer<MUIElement> parentContainer = container .getParent(); if (parentContainer != null) { int index = parentContainer.getChildren().indexOf(container); if (((theChild instanceof MPartSashContainer)) && ((container.getWidget() instanceof Composite))) { Composite theComp = (Composite)container.getWidget(); Object tmp = theChild.getWidget(); theChild.setWidget(theComp); theComp.setLayout(new SashLayout(theComp, theChild)); theComp.setData("modelElement", theChild); container.setWidget(tmp); } theChild.setContainerData(container.getContainerData()); container.getChildren().remove(theChild); parentContainer.getChildren().add(index, theChild); container.setToBeRendered(false); parentContainer.getChildren().remove(container); } } } }); } } } }; private EventHandler visibilityChangeHandler = new EventHandler() { public void handleEvent(Event event) { MUIElement changedObj = (MUIElement)event.getProperty("ChangedElement"); if (((changedObj instanceof MTrimBar)) || ((changedObj.getParent() instanceof MToolBar))) { return; } if ((changedObj.getWidget() instanceof Shell)) { ((Shell)changedObj.getWidget()).setVisible(changedObj.isVisible()); } else if ((changedObj.getWidget() instanceof Rectangle)) { if (changedObj.isVisible()) { MUIElement parent = changedObj.getParent(); if (!parent.isVisible()) { parent.setVisible(true); } } else { MElementContainer<MUIElement> parent = changedObj.getParent(); boolean makeInvisible = true; for (MUIElement kid : parent.getChildren()) { if ((kid.isToBeRendered()) && (kid.isVisible())) { makeInvisible = false; break; } } if (makeInvisible) { parent.setVisible(false); } } } else if ((changedObj.getWidget() instanceof Control)) { Control ctrl = (Control)changedObj.getWidget(); MElementContainer<MUIElement> parent = changedObj.getParent(); if ((parent == null) || ((parent instanceof MToolBar))) { return; } if (changedObj.isVisible()) { if (parent.getRenderer() != null) { Object myParent = ((AbstractPartRenderer)parent.getRenderer()) .getUIContainer(changedObj); if ((myParent instanceof Composite)) { Composite parentComp = (Composite)myParent; ctrl.setParent(parentComp); Control prevControl = null; for (MUIElement childME : parent.getChildren()) { if (childME == changedObj) { break; } if (((childME.getWidget() instanceof Control)) && (childME.isVisible())) { prevControl = (Control)childME.getWidget(); } } if (prevControl != null) { ctrl.moveBelow(prevControl); } else { ctrl.moveAbove(null); } ctrl.getShell().layout(new Control[] { ctrl }, 4); } if (!parent.isVisible()) { parent.setVisible(true); } } } else { Shell limbo = (Shell)app.getContext().get("limbo"); Composite curParent = ctrl.getParent(); ctrl.setParent(limbo); curParent.layout(true); if (curParent.getShell() != curParent) { curParent.getShell().layout(new Control[] { curParent }, 4); } if ((parent instanceof MWindow)) { return; } boolean makeParentInvisible = true; for (MUIElement kid : parent.getChildren()) { if ((kid.isToBeRendered()) && (kid.isVisible())) { makeParentInvisible = false; break; } } if (makeParentInvisible) { parent.setVisible(false); } } } } }; private EventHandler renderingChangeHandler = new EventHandler() { public void handleEvent(Event event) { MUIElement changedObj = (MUIElement)event.getProperty("ChangedElement"); MElementContainer<MUIElement> container = null; if (changedObj.getCurSharedRef() != null) { container = changedObj.getCurSharedRef().getParent(); } else { container = changedObj.getParent(); } if (container == null) { return; } MUIElement containerElement = container; if (((containerElement instanceof MWindow)) && (containerElement.getParent() != null)) { return; } if ((isLastEditorStack(containerElement)) || ((containerElement instanceof MPerspective)) || ((containerElement instanceof MPerspectiveStack))) { return; } Boolean toBeRendered = (Boolean)event.getProperty("NewValue"); if (toBeRendered.booleanValue()) { if (!container.isToBeRendered()) { container.setToBeRendered(true); } } else { if (container.getTags().contains("NoAutoCollapse")) { return; } int visCount = modelService.countRenderableChildren(container); final MElementContainer<MUIElement> theContainer = container; if (visCount == 0) { Display.getCurrent().asyncExec(new Runnable() { public void run() { if (!isLastEditorStack(theContainer)) { theContainer.setToBeRendered(false); } } }); } else { boolean makeInvisible = true; for (MUIElement kid : container.getChildren()) { if (kid.isToBeRendered()) { if (kid.isVisible()) { makeInvisible = false; break; } } } if (makeInvisible) { container.setVisible(false); } } } } }; @PostConstruct void init(IEclipseContext context) { eventBroker.subscribe("org/eclipse/e4/ui/model/ui/ElementContainer/children/*", childrenHandler); eventBroker.subscribe("org/eclipse/e4/ui/model/ui/UIElement/toBeRendered/*", renderingChangeHandler); eventBroker.subscribe("org/eclipse/e4/ui/model/ui/UIElement/visible/*", visibilityChangeHandler); } @PreDestroy void removeListeners() { eventBroker.unsubscribe(childrenHandler); eventBroker.unsubscribe(renderingChangeHandler); eventBroker.unsubscribe(visibilityChangeHandler); } boolean isLastEditorStack(MUIElement element) { return modelService.isLastEditorStack(element); } } /* Location: * Qualified Name: org.eclipse.e4.ui.workbench.addons.cleanupaddon.CleanupAddon * Java Class Version: 5 (49.0) * JD-Core Version: 0.7.1 */ package org.eclipse.e4.ui.workbench.addons.dndaddon; import org.eclipse.e4.ui.model.application.ui.MUIElement; import org.eclipse.e4.ui.model.application.ui.advanced.MPlaceholder; import org.eclipse.e4.ui.model.application.ui.basic.MPart; import org.eclipse.e4.ui.model.application.ui.basic.MPartSashContainerElement; import org.eclipse.e4.ui.model.application.ui.basic.MPartStack; import org.eclipse.e4.ui.workbench.modeling.EModelService; import org.eclipse.swt.graphics.Point; import org.eclipse.swt.graphics.Rectangle; import org.eclipse.swt.widgets.Control; import org.eclipse.swt.widgets.Display; public class DetachedDropAgent extends DropAgent { DnDManager manager; private EModelService modelService; private Rectangle curRect; public DetachedDropAgent(DnDManager manager) { super(manager); this.manager = manager; modelService = manager.getModelService(); } public boolean canDrop(MUIElement dragElement, DnDInfo info) { if (curElement != null) { return false; } if (((dragElement instanceof MPart)) || ((dragElement instanceof MPlaceholder)) || ((dragElement instanceof MPartStack))) { return true; } return false; } public boolean drop(MUIElement dragElement, DnDInfo info) { if (dragElement.getCurSharedRef() != null) { dragElement = dragElement.getCurSharedRef(); } modelService.detach((MPartSashContainerElement)dragElement, curRect.x, curRect.y, curRect.width, curRect.height); return true; } public Rectangle getRectangle(MUIElement dragElement, DnDInfo info) { if (dragElement.getCurSharedRef() != null) { dragElement = dragElement.getCurSharedRef(); } if ((dragElement instanceof MPartStack)) { Control ctrl = (Control)dragElement.getWidget(); curRect = ctrl.getBounds(); } else { MUIElement parentME = dragElement.getParent(); Control ctrl = (Control)parentME.getWidget(); curRect = ctrl.getBounds(); curRect.width += 10; curRect.height += 22; } Point cp = Display.getCurrent().getCursorLocation(); curRect.x = (x - 15); curRect.y = (y - 15); return curRect; } public boolean track(MUIElement dragElement, DnDInfo info) { if (curElement != null) { return false; } manager.frameRect(getRectangle(dragElement, info)); return true; } public void dragEnter(MUIElement dragElement, DnDInfo info) { super.dragEnter(dragElement, info); dndManager.setCursor(Display.getCurrent().getSystemCursor(21)); } public void dragLeave(MUIElement dragElement, DnDInfo info) { manager.clearOverlay(); dndManager.setCursor(Display.getCurrent().getSystemCursor(20)); super.dragLeave(dragElement, info); } } /* Location: * Qualified Name: org.eclipse.e4.ui.workbench.addons.dndaddon.DetachedDropAgent * Java Class Version: 5 (49.0) * JD-Core Version: 0.7.1 */ package org.eclipse.e4.ui.workbench.addons.dndaddon; import org.eclipse.e4.ui.model.application.ui.MUIElement; import org.eclipse.e4.ui.model.application.ui.basic.MWindow; import org.eclipse.swt.widgets.Shell; import org.eclipse.swt.widgets.Widget; import org.osgi.service.event.Event; import org.osgi.service.event.EventHandler; class DnDAddon$1 implements EventHandler { DnDAddon$1(DnDAddon paramDnDAddon) {} public void handleEvent(Event event) { MUIElement changedElement = (MUIElement)event.getProperty("ChangedElement"); if (!(changedElement instanceof MWindow)) { return; } Widget widget = (Widget)event.getProperty("NewValue"); if (((widget instanceof Shell)) && (!widget.isDisposed())) { DnDManager theManager = (DnDManager)widget.getData("DnDManager"); if (theManager == null) { theManager = new DnDManager((MWindow)changedElement); widget.setData("DnDManager", theManager); } } } } /* Location: * Qualified Name: org.eclipse.e4.ui.workbench.addons.dndaddon.DnDAddon.1 * Java Class Version: 5 (49.0) * JD-Core Version: 0.7.1 */ package org.eclipse.e4.ui.workbench.addons.dndaddon; import javax.annotation.PostConstruct; import javax.annotation.PreDestroy; import javax.inject.Inject; import org.eclipse.e4.core.services.events.IEventBroker; import org.eclipse.e4.ui.model.application.ui.MUIElement; import org.eclipse.e4.ui.model.application.ui.basic.MWindow; import org.eclipse.swt.widgets.Shell; import org.eclipse.swt.widgets.Widget; import org.osgi.service.event.Event; import org.osgi.service.event.EventHandler; public class DnDAddon { @Inject IEventBroker eventBroker; private EventHandler installHook = new EventHandler() { public void handleEvent(Event event) { MUIElement changedElement = (MUIElement)event.getProperty("ChangedElement"); if (!(changedElement instanceof MWindow)) { return; } Widget widget = (Widget)event.getProperty("NewValue"); if (((widget instanceof Shell)) && (!widget.isDisposed())) { DnDManager theManager = (DnDManager)widget.getData("DnDManager"); if (theManager == null) { theManager = new DnDManager((MWindow)changedElement); widget.setData("DnDManager", theManager); } } } }; @PostConstruct void hookListeners() { String topic = "org/eclipse/e4/ui/model/ui/UIElement/widget/*"; eventBroker.subscribe(topic, null, installHook, false); } @PreDestroy void unhookListeners() { eventBroker.unsubscribe(installHook); } } /* Location: * Qualified Name: org.eclipse.e4.ui.workbench.addons.dndaddon.DnDAddon * Java Class Version: 5 (49.0) * JD-Core Version: 0.7.1 */ package org.eclipse.e4.ui.workbench.addons.dndaddon; import org.eclipse.e4.core.contexts.IEclipseContext; import org.eclipse.e4.ui.model.application.ui.MUIElement; import org.eclipse.e4.ui.model.application.ui.basic.MWindow; import org.eclipse.e4.ui.workbench.modeling.EModelService; import org.eclipse.swt.custom.CTabFolder; import org.eclipse.swt.custom.CTabItem; import org.eclipse.swt.events.DragDetectEvent; import org.eclipse.swt.graphics.Point; import org.eclipse.swt.graphics.Rectangle; import org.eclipse.swt.graphics.Region; import org.eclipse.swt.widgets.Control; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Item; import org.eclipse.swt.widgets.Shell; import org.eclipse.swt.widgets.ToolBar; import org.eclipse.swt.widgets.ToolItem; class DnDInfo { Point cursorPos; Control curCtrl; Item curItem; MUIElement curElement; MUIElement itemElement; int itemIndex; Rectangle itemRect; Shell dragHost = null; int offsetX = 0; int offsetY = 0; Rectangle dragHostBounds = null; Point initialHostSize; MWindow topLevelWindow; Display display; EModelService modelService; public DnDInfo(MWindow topWin) { topLevelWindow = topWin; display = ((Control)topWin.getWidget()).getDisplay(); modelService = ((EModelService)topWin.getContext().get(EModelService.class)); update(); } public void setDragHost(Shell hostingShell, int xOffset, int yOffset) { dragHost = hostingShell; offsetX = xOffset; offsetY = yOffset; dragHostBounds = null; if (dragHost == null) { return; } Region rgn = dragHost.getRegion(); Rectangle bounds = dragHost.getBounds(); rgn.add(0, 0, width, height); rgn.subtract(offsetX, offsetY, 1, 1); dragHost.setRegion(rgn); initialHostSize = dragHost.getSize(); Point curLoc = dragHost.getDisplay().getCursorLocation(); dragHost.setLocation(x - offsetX, y - offsetY); dragHost.layout(true); } public void setDragHostBounds(Rectangle displayRect) { if (dragHost == null) { return; } dragHostBounds = displayRect; if (dragHostBounds == null) { dragHost.setSize(initialHostSize); setDragHost(dragHost, offsetX, offsetY); return; } dragHost.setAlpha(200); dragHost.setBounds(dragHostBounds); Point cursorLoc = display.getCursorLocation(); cursorLoc = display.map(null, dragHost, cursorLoc); Region rgn = dragHost.getRegion(); Rectangle bounds = dragHost.getBounds(); rgn.add(0, 0, width, height); rgn.subtract(x, y, 1, 1); display.update(); } private void reset() { cursorPos = null; curCtrl = null; curItem = null; curElement = null; itemElement = null; itemIndex = -1; itemRect = null; } private void setItemInfo() { if (curElement == null) { return; } Control ctrl = (Control)curElement.getWidget(); if ((ctrl instanceof CTabFolder)) { CTabFolder ctf = (CTabFolder)ctrl; Point localPos = display.map(null, ctf, cursorPos); this.curItem = ctf.getItem(localPos); if (this.curItem != null) { itemElement = ((MUIElement)this.curItem.getData("modelElement")); if (itemElement != null) { itemIndex = ctf.indexOf((CTabItem)this.curItem); itemRect = display.map(ctf, ctf.getShell(), ((CTabItem)this.curItem).getBounds()); } } } else if ((ctrl instanceof ToolBar)) { ToolBar tb = (ToolBar)ctrl; Point localPos = display.map(null, tb, cursorPos); ToolItem curItem = tb.getItem(localPos); if (curItem != null) { itemElement = ((MUIElement)curItem.getData("modelElement")); if (itemElement != null) { itemIndex = tb.indexOf(curItem); itemRect = display.map(tb, tb.getShell(), curItem.getBounds()); } } } } private MUIElement getModelElement(Control ctrl) { if (ctrl == null) { return null; } MUIElement element = (MUIElement)ctrl.getData("modelElement"); if (element != null) { if (modelService.getTopLevelWindowFor(element) == topLevelWindow) { return element; } return null; } return getModelElement(ctrl.getParent()); } public void update() { Display display = Display.getCurrent(); if (display == null) { return; } reset(); cursorPos = display.getCursorLocation(); if ((dragHost != null) && (!dragHost.isDisposed()) && (dragHost.getVisible())) { if (dragHostBounds == null) { dragHost.setLocation(cursorPos.x - offsetX, cursorPos.y - offsetY); } else { Point cursorLoc = display.getCursorLocation(); cursorLoc = display.map(null, dragHost, cursorLoc); Region rgn = dragHost.getRegion(); Rectangle bounds = dragHost.getBounds(); rgn.add(0, 0, width, height); rgn.subtract(x, y, 1, 1); } } curCtrl = display.getCursorControl(); if (curCtrl == null) { return; } curElement = getModelElement(curCtrl); setItemInfo(); } public void update(DragDetectEvent e) { reset(); if (!(widget instanceof Control)) { return; } curCtrl = ((Control)widget); cursorPos = new Point(x, y); cursorPos = curCtrl.getDisplay().map(curCtrl, null, cursorPos); curElement = getModelElement(curCtrl); setItemInfo(); } } /* Location: * Qualified Name: org.eclipse.e4.ui.workbench.addons.dndaddon.DnDInfo * Java Class Version: 5 (49.0) * JD-Core Version: 0.7.1 */ package org.eclipse.e4.ui.workbench.addons.dndaddon; import org.eclipse.swt.events.DragDetectListener; class DnDManager$1 implements DragDetectListener { DnDManager$1(DnDManager paramDnDManager) {} /* Error */ public void dragDetected(org.eclipse.swt.events.DragDetectEvent e) { // Byte code: // 0: aload_0 // 1: getfield 63 org/eclipse/e4/ui/workbench/addons/dndaddon/DnDManager$1:this$0 Lorg/eclipse/e4/ui/workbench/addons/dndaddon/DnDManager; // 4: getfield 59 org/eclipse/e4/ui/workbench/addons/dndaddon/DnDManager:dragging Z // 7: ifne +13 -> 20 // 10: aload_1 // 11: getfield 66 org/eclipse/swt/events/DragDetectEvent:widget Lorg/eclipse/swt/widgets/Widget; // 14: invokevirtual 71 org/eclipse/swt/widgets/Widget:isDisposed ()Z // 17: ifeq +4 -> 21 // 20: return // 21: aload_0 // 22: getfield 63 org/eclipse/e4/ui/workbench/addons/dndaddon/DnDManager$1:this$0 Lorg/eclipse/e4/ui/workbench/addons/dndaddon/DnDManager; Further reading...For more information on Java 1.5 Tiger, you may find Java 1.5 Tiger, A developer's Notebook by D. Flanagan and B. McLaughlin from O'Reilly of interest.New!JAR listings
|