1 19 20 21 package org.netbeans.core.windows.view; 22 23 24 import org.netbeans.core.windows.WindowManagerImpl; 25 import org.netbeans.core.windows.view.dnd.WindowDnDManager; 26 import org.netbeans.core.windows.view.ui.DefaultSeparateContainer; 27 import org.netbeans.core.windows.view.ui.DefaultSplitContainer; 28 import org.netbeans.core.windows.WindowManagerImpl; 29 import org.netbeans.core.windows.view.ui.slides.SlideBarContainer; 30 import org.openide.windows.TopComponent; 31 32 import java.awt.*; 33 import java.util.ArrayList ; 34 import java.util.Arrays ; 35 import java.util.List ; 36 import javax.swing.JComponent ; 37 38 39 44 public class ModeView extends ViewElement { 45 protected ModeContainer container; 47 48 private int frameState; 51 52 public ModeView(Controller controller, WindowDnDManager windowDnDManager, 55 double resizeWeight, int kind, TopComponent[] topComponents, TopComponent selectedTopComponent) { 56 super(controller, resizeWeight); 57 58 container = new DefaultSplitContainer(this, windowDnDManager, kind); 59 60 setTopComponents(topComponents, selectedTopComponent); 61 } 62 63 public ModeView(Controller controller, WindowDnDManager windowDnDManager, Rectangle bounds, int kind, int frameState, 65 TopComponent[] topComponents, TopComponent selectedTopComponent) { 66 super(controller, 0D); 67 68 this.frameState = frameState; 69 70 container = new DefaultSeparateContainer(this, windowDnDManager, bounds, kind); 71 72 setTopComponents(topComponents, selectedTopComponent); 73 } 74 75 77 protected ModeView(Controller controller) { 78 super(controller, 0D); 79 82 } 84 85 86 public void setFrameState(int frameState) { 87 this.frameState = frameState; 89 Component comp = container.getComponent(); 90 if(comp instanceof Frame) { 91 if ((frameState & Frame.ICONIFIED) == Frame.ICONIFIED) { 92 timeStamp = System.currentTimeMillis(); 93 } else { 94 timeStamp = 0; 95 } 96 } 97 } 98 99 100 107 public void removeTopComponent(TopComponent tc) { 108 if(!getTopComponents().contains(tc)) { 109 return; 110 } 111 container.removeTopComponent(tc); 112 } 113 114 public void setTopComponents(TopComponent[] tcs, TopComponent select) { 115 container.setTopComponents(tcs, select); 116 } 117 118 122 public TopComponent getSelectedTopComponent() { 123 return container.getSelectedTopComponent(); 124 } 125 126 public void setActive(boolean active) { 127 container.setActive(active); 128 } 129 130 public boolean isActive() { 131 return container.isActive(); 132 } 133 134 public List <TopComponent> getTopComponents() { 135 return new ArrayList <TopComponent>(Arrays.asList(container.getTopComponents())); 136 } 137 138 public void focusSelectedTopComponent() { 139 container.focusSelectedTopComponent(); 140 } 141 142 public Component getComponent() { 143 return container.getComponent(); 144 } 145 146 public void updateName(TopComponent tc) { 147 container.updateName(tc); 148 } 149 150 public void updateToolTip(TopComponent tc) { 151 container.updateToolTip(tc); 152 } 153 154 public void updateIcon(TopComponent tc) { 155 container.updateIcon(tc); 156 } 157 158 public void requestAttention (TopComponent tc) { 159 container.requestAttention(tc); 160 } 161 162 public void cancelRequestAttention (TopComponent tc) { 163 container.cancelRequestAttention(tc); 164 } 165 166 public void updateFrameState() { 168 Component comp = container.getComponent(); 169 if(comp instanceof Frame) { 170 ((Frame)comp).setExtendedState(frameState); 171 } 172 } 173 174 private long timeStamp = 0; 175 176 public void setUserStamp(long stamp) { 177 timeStamp = stamp; 178 } 179 180 public long getUserStamp() { 181 return timeStamp; 182 } 183 184 private long mainWindowStamp = 0; 185 186 public void setMainWindowStamp(long stamp) { 187 mainWindowStamp = stamp; 188 } 189 190 public long getMainWindowStamp() { 191 return mainWindowStamp; 192 } 193 194 public String toString() { 195 TopComponent selected = container.getSelectedTopComponent(); 196 return super.toString() + " [selected=" + (selected == null ? null : WindowManagerImpl.getInstance().getTopComponentDisplayName(selected)) + "]"; } 199 200 public boolean updateAWTHierarchy(Dimension availableSpace) { 201 Component comp = container.getComponent(); 204 boolean result = false; 205 if (comp instanceof JComponent ) { 206 Dimension d = (Dimension) ((JComponent ) comp).getClientProperty ("lastAvailableSpace"); Dimension currDim = comp.getPreferredSize(); 211 if (!availableSpace.equals(d) || !availableSpace.equals(currDim)) { 212 ((JComponent )comp).setPreferredSize(availableSpace); 214 ((JComponent )comp).putClientProperty("lastAvailableSpace", availableSpace); result = true; 216 } 217 } 218 return result; 219 } 220 221 222 } 223 224 | Popular Tags |