1 19 20 21 package org.netbeans.core.windows.view.ui; 22 23 24 import org.netbeans.core.windows.Constants; 25 import org.netbeans.core.windows.WindowManagerImpl; 26 import org.netbeans.core.windows.view.ModeView; 27 import org.netbeans.core.windows.view.ViewElement; 28 import org.netbeans.core.windows.view.dnd.TopComponentDroppable; 29 import org.netbeans.core.windows.view.dnd.WindowDnDManager; 30 import org.netbeans.core.windows.view.ui.tabcontrol.TabbedAdapter; 31 import org.openide.windows.TopComponent; 32 33 import javax.swing.*; 34 import java.awt.*; 35 36 37 42 public final class DefaultSplitContainer extends AbstractModeContainer { 43 44 45 46 private final JPanel panel; 47 48 49 50 public DefaultSplitContainer(ModeView modeView, WindowDnDManager windowDnDManager, int kind) { 51 super(modeView, windowDnDManager, kind); 52 53 panel = new ModePanel(this); 54 55 panel.add(this.tabbedHandler.getComponent(), BorderLayout.CENTER); 56 57 panel.setMinimumSize(new Dimension(1, 1)); 59 } 60 61 public void requestAttention (TopComponent tc) { 62 tabbedHandler.requestAttention(tc); 63 } 64 65 public void cancelRequestAttention (TopComponent tc) { 66 tabbedHandler.cancelRequestAttention(tc); 67 } 68 69 70 protected Component getModeComponent() { 71 return panel; 72 } 73 74 protected Tabbed createTabbed() { 75 Tabbed tabbed; 76 if(getKind() == Constants.MODE_KIND_EDITOR) { 77 tabbed = new TabbedAdapter(Constants.MODE_KIND_EDITOR); 78 } else { 79 tabbed = new TabbedAdapter(Constants.MODE_KIND_VIEW); 80 } 81 return tabbed; 82 } 83 84 protected void updateTitle(String title) { 85 } 87 88 protected void updateActive(boolean active) { 89 if(active) { 90 Window window = SwingUtilities.getWindowAncestor(panel); 91 if(window != null && !window.isActive() && WindowManagerImpl.getInstance().getEditorAreaState() == Constants.EDITOR_AREA_SEPARATED) { 92 window.toFront(); 94 } 95 } 96 } 97 98 public boolean isActive() { 99 Window window = SwingUtilities.getWindowAncestor(panel); 100 return window != null ? window.isActive() : false; 103 } 104 105 protected boolean isAttachingPossible() { 106 return true; 107 } 108 109 protected TopComponentDroppable getModeDroppable() { 110 return (ModePanel)panel; 111 } 112 113 114 115 private static class ModePanel extends JPanel 116 implements ModeComponent, TopComponentDroppable { 117 118 private final AbstractModeContainer abstractModeContainer; 119 120 public ModePanel(AbstractModeContainer abstractModeContainer) { 121 super(new BorderLayout()); 122 this.abstractModeContainer = abstractModeContainer; 123 enableEvents(java.awt.AWTEvent.MOUSE_EVENT_MASK); 125 } 128 129 public ModeView getModeView() { 130 return abstractModeContainer.getModeView(); 131 } 132 133 public int getKind() { 134 return abstractModeContainer.getKind(); 135 } 136 137 public Shape getIndicationForLocation(Point location) { 139 return abstractModeContainer.getIndicationForLocation(location); 140 } 141 142 public Object getConstraintForLocation(Point location) { 143 return abstractModeContainer.getConstraintForLocation(location); 144 } 145 146 public Component getDropComponent() { 147 return abstractModeContainer.getDropComponent(); 148 } 149 150 public ViewElement getDropViewElement() { 151 return abstractModeContainer.getDropModeView(); 152 } 153 154 public boolean canDrop(TopComponent transfer, Point location) { 155 return abstractModeContainer.canDrop(transfer); 156 } 157 158 public boolean supportsKind(int kind, TopComponent transfer) { 159 if(Constants.SWITCH_MODE_ADD_NO_RESTRICT 160 || WindowManagerImpl.getInstance().isTopComponentAllowedToMoveAnywhere(transfer)) { 161 return true; 162 } 163 164 boolean isNonEditor = kind == Constants.MODE_KIND_VIEW || kind == Constants.MODE_KIND_SLIDING; 165 boolean thisIsNonEditor = getKind() == Constants.MODE_KIND_VIEW || getKind() == Constants.MODE_KIND_SLIDING; 166 167 return (isNonEditor == thisIsNonEditor); 168 169 } 170 } } 173 174 | Popular Tags |