001: /*
002: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003: *
004: * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
005: *
006: * The contents of this file are subject to the terms of either the GNU
007: * General Public License Version 2 only ("GPL") or the Common
008: * Development and Distribution License("CDDL") (collectively, the
009: * "License"). You may not use this file except in compliance with the
010: * License. You can obtain a copy of the License at
011: * http://www.netbeans.org/cddl-gplv2.html
012: * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
013: * specific language governing permissions and limitations under the
014: * License. When distributing the software, include this License Header
015: * Notice in each file and include the License file at
016: * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
017: * particular file as subject to the "Classpath" exception as provided
018: * by Sun in the GPL Version 2 section of the License file that
019: * accompanied this code. If applicable, add the following below the
020: * License Header, with the fields enclosed by brackets [] replaced by
021: * your own identifying information:
022: * "Portions Copyrighted [year] [name of copyright owner]"
023: *
024: * Contributor(s):
025: *
026: * The Original Software is NetBeans. The Initial Developer of the Original
027: * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
028: * Microsystems, Inc. All Rights Reserved.
029: *
030: * If you wish your version of this file to be governed by only the CDDL
031: * or only the GPL Version 2, indicate your decision by adding
032: * "[Contributor] elects to include this software in this distribution
033: * under the [CDDL or GPL Version 2] license." If you do not indicate a
034: * single choice of license, a recipient has the option to distribute
035: * your version of this file under either the CDDL, the GPL Version 2 or
036: * to extend the choice of license to its licensees as provided above.
037: * However, if you add GPL Version 2 code and therefore, elected the GPL
038: * Version 2 license, then the option applies only if the new code is
039: * made subject to such option by the copyright holder.
040: */
041: package org.netbeans.modules.vmd.screen;
042:
043: import org.netbeans.modules.vmd.api.model.DesignComponent;
044: import org.netbeans.modules.vmd.api.model.DesignDocument;
045: import org.netbeans.modules.vmd.screen.device.DevicePanel;
046: import org.netbeans.modules.vmd.screen.resource.ResourcePanel;
047: import org.openide.util.NbBundle;
048:
049: import javax.swing.*;
050: import java.awt.*;
051: import java.awt.event.MouseAdapter;
052: import java.awt.event.MouseEvent;
053: import java.util.Collections;
054:
055: /**
056: *
057: * @author David Kaspar
058: */
059: public class MainPanel extends JPanel {
060:
061: public static final Color BACKGROUND_COLOR = new Color(0xFBF9F3);
062:
063: public static final Color SELECT_COLOR = new Color(0xFF8500);
064: public static final Color HOVER_COLOR = new Color(0x5B67B0);
065:
066: private static final Font LABEL_FONT = new Font("Dialog",
067: Font.BOLD, 16); // NOI18N
068: private static final Color LABEL_COLOR = new Color(0x88A3CF);
069:
070: private DevicePanel devicePanel;
071:
072: public MainPanel(DevicePanel devicePanel,
073: ResourcePanel resourcePanel) {
074: this .devicePanel = devicePanel;
075: addMouseListener(new SelectionListener());
076:
077: setLayout(new GridBagLayout());
078: setBackground(BACKGROUND_COLOR);
079:
080: GridBagConstraints constraints = new GridBagConstraints();
081: constraints.weightx = 0.0;
082: constraints.weighty = 0.0;
083: constraints.insets = new Insets(12, 12, 6, 6);
084: constraints.fill = GridBagConstraints.BOTH;
085: constraints.gridx = 0;
086: constraints.gridy = 0;
087: constraints.anchor = GridBagConstraints.NORTHWEST;
088: JLabel devLabel = new JLabel(NbBundle.getMessage(
089: MainPanel.class, "DISP_DeviceScreen")); // NOI18N
090: devLabel.setForeground(LABEL_COLOR);
091: devLabel.setHorizontalAlignment(JLabel.CENTER);
092: devLabel.setFont(LABEL_FONT);
093: add(devLabel, constraints);
094:
095: constraints.insets = new Insets(6, 12, 12, 6);
096: constraints.gridy = 1;
097: constraints.weighty = 0.0;
098: add(devicePanel, constraints);
099:
100: constraints.gridx = 1;
101: constraints.gridy = 0;
102: constraints.weighty = 0.0;
103: constraints.insets = new Insets(12, 6, 6, 12);
104: JLabel resLabel = new JLabel(NbBundle.getMessage(
105: MainPanel.class, "DISP_AssignedResources")); // NOI18N
106: resLabel.setForeground(LABEL_COLOR);
107: resLabel.setHorizontalAlignment(JLabel.CENTER);
108: resLabel.setFont(LABEL_FONT);
109: add(resLabel, constraints);
110:
111: constraints.gridy = 1;
112: constraints.insets = new Insets(6, 6, 12, 12);
113: constraints.weightx = 0.0;
114: constraints.weighty = 0.0;
115: add(resourcePanel, constraints);
116:
117: constraints.gridx = 2;
118: constraints.gridy = 2;
119: constraints.weightx = 1.0;
120: constraints.weighty = 1.0;
121: JPanel filler = new JPanel();
122: filler.setBackground(BACKGROUND_COLOR);
123: add(filler, constraints);
124:
125: // vlv: print
126: putClientProperty(java.awt.print.Printable.class, ""); // NOI18N
127: }
128:
129: private class SelectionListener extends MouseAdapter implements
130: Runnable {
131: private DesignDocument document;
132:
133: public void mouseClicked(MouseEvent e) {
134: document = devicePanel.getController().getDocument();
135: document.getTransactionManager().writeAccess(this );
136: }
137:
138: public void run() {
139: if (document == null) {
140: return;
141: }
142: document.setSelectedComponents(
143: ScreenViewController.SCREEN_ID, Collections
144: .<DesignComponent> emptySet());
145: }
146: }
147: }
|