📄 gvsunspot.java
字号:
/* * Copyright (c) 2007 Sun Microsystems, Inc. All rights reserved. * * Sun Microsystems, Inc. has intellectual property rights relating to technology embodied in the product that is * described in this document. In particular, and without limitation, these intellectual property rights may * include one or more of the U.S. patents listed at http://www.sun.com/patents and one or more additional patents * or pending patent applications in the U.S. and in other countries. * * U.S. Government Rights - Commercial software. Government users are subject to the Sun Microsystems, Inc. * standard license agreement and applicable provisions of the FAR and its supplements. * * Use is subject to license terms. * * This distribution may include materials developed by third parties. Sun, Sun Microsystems, the Sun logo and * Java are trademarks or registered trademarks of Sun Microsystems, Inc. in the U.S. and other countries. * * Copyright (c) 2006 Sun Microsystems, Inc. Tous droits r?serv?s. * * Sun Microsystems, Inc. d?tient les droits de propri?t? intellectuels relatifs ? la technologie incorpor?e dans * le produit qui est d?crit dans ce document. En particulier, et ce sans limitation, ces droits de propri?t? * intellectuelle peuvent inclure un ou plus des brevets am?ricains list?s ? l'adresse http://www.sun.com/patents * et un ou les brevets suppl?mentaires ou les applications de brevet en attente aux Etats - Unis et dans les * autres pays. * * L'utilisation est soumise aux termes du contrat de licence. * * Cette distribution peut comprendre des composants d?velopp?s par des tierces parties. * Sun, Sun Microsystems, le logo Sun et Java sont des marques de fabrique ou des marques d?pos?es de Sun * Microsystems, Inc. aux Etats-Unis et dans d'autres pays. */package com.sun.spot.spotworld.gridview;import com.sun.spot.spotworld.CodingManager;import com.sun.spot.spotworld.gridview.GVSquawkHost;import com.sun.spot.spotworld.gui.DeploymentOptionsUI;import com.sun.spot.spotworld.gui.SunSPOTDeploymentProgressUI;import com.sun.spot.spotworld.participants.SunSPOT;import java.io.FileNotFoundException;import java.io.IOException;import java.util.Vector;import javax.swing.JFrame;import javax.swing.JLabel;import javax.swing.JMenu;import javax.swing.JMenuItem;import javax.swing.JOptionPane;import javax.swing.SwingUtilities;/** * Like a SquawkHost, but has a name and has a menu of operations. * * @author randy */public class GVSunSPOT extends GVSquawkHost { protected GVJLabelHolder nameLabel; public SunSPOT getSpot(){ return (SunSPOT) getVirtualObject(); } public Vector<JMenuItem> getMenuItems() { if (getSpot() == null) return new Vector<JMenuItem>(); Vector<JMenuItem> menuItems = super.getMenuItems(); menuItems.addAll(menuHelper(getSpot().getSpotMethods())); JMenu availableAppsMI = new JMenu("Available Apps"); Vector<JMenuItem> jmis = getAvailableAppsMenuItems(); for(JMenuItem it : jmis){ availableAppsMI.add(it); } menuItems.add(availableAppsMI); return menuItems; } synchronized public void updateNameLabel() { if(nameLabel == null ) { createAndSetNameLabel(); } else { String lblName = nameLabel.getJLabel().getText(); String actualName = ((SunSPOT) getVirtualObject()).getName(); if(! lblName.equals(actualName)){ nameLabel.setText(actualName); nameLabel.recenterAbove(this); } } } public void createAndSetNameLabel() { nameLabel = new GVJLabelHolder(); nameLabel.setText(((SunSPOT) getVirtualObject()).getName()); JLabel lbl = nameLabel.getJLabel(); addLoosePiece(nameLabel); if(getView() != null){ nameLabel.addToView(getView()); } nameLabel.recenterAbove(this); } public void addToView(final GridView gv){ GVSunSPOT.super.addToView(gv); SwingUtilities.invokeLater(new Runnable(){ public void run(){ updateNameLabel(); } } ); } public void noteState(final Object obj) { SwingUtilities.invokeLater(new Runnable(){ public void run(){ updateNameLabel(); GVSunSPOT.super.noteState(obj); } } ); } public void doDeployment(){ String msg = "Check that SPOT is UN-plugged from USB"; msg = msg + "\n(This is for over the air deployment.)"; JOptionPane.showMessageDialog(this, msg, "", JOptionPane.WARNING_MESSAGE ); JFrame myFrame = (JFrame) ((GridView)getView()).getRootPane().getParent(); DeploymentOptionsUI options = DeploymentOptionsUI.openNew(myFrame); if(! options.isUserOK()) return; getSpot().exitAllApplications(); boolean doClean = options.isCleanSelected(); boolean doCompile = options.isCompiledSelected(); boolean doDeploy = options.isDeploySelected(); try { SunSPOTDeploymentProgressUI ssp = new SunSPOTDeploymentProgressUI(); ssp.setSunspot(getSpot()); ssp.doTasksAndMonitor(this, CodingManager.getInstance().getCurrentProjDir(), getSpot().getAddress(), doClean, doCompile, doDeploy); } catch (FileNotFoundException ex) { ex.printStackTrace(); } catch (IOException ex) { ex.printStackTrace(); } }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -