@Override public Home createHome() { Home h = new Home(); h.image = "monster-home.gif"; h.defense = 70; h.attack = 100; return h; }
@Override public void saveHome(Home home) { if (!homes.containsKey(home.getOwner().toLowerCase())) { homes.put(home.getOwner().toLowerCase(), new HashMap<String, Home>()); } homes.get(home.getOwner().toLowerCase()).put(home.getName().toLowerCase(), home); plugin.getDatabase().save(home); }
@Override public void delHome(Home home) { Home h = null; try { h = homes.get(home.getOwner().toLowerCase()).remove(home.getName().toLowerCase()); } catch (NullPointerException ex) { } if (h != null) { plugin.getDatabase().delete(h); } }
@Override public void reloadData() { try { int rowCount = plugin.getDatabase().find(Home.class).findRowCount(); } catch (PersistenceException ex) { plugin.initDB(); } for (Home home : plugin.getDatabase().find(Home.class).findList()) { if (!homes.containsKey(home.getOwner().toLowerCase())) { homes.put(home.getOwner().toLowerCase(), new HashMap<String, Home>()); } homes.get(home.getOwner().toLowerCase()).put(home.getName().toLowerCase(), home); } plugin.debug("Loaded " + homes.size() + " player homes."); }
// ---------------------------------------------------------------------------------------------------------------- // Methods to resolve model by id // ---------------------------------------------------------------------------------------------------------------- private Home getResolveHome(String homeId) { Home home = null; for (Iterator<Machine> hostItor = getMachines().iterator(); hostItor.hasNext(); ) { Machine currHost = hostItor.next(); for (Iterator<Home> homeItor = currHost.getHomes().iterator(); homeItor.hasNext(); ) { Home currHome = homeItor.next(); if (currHome.getId().equals(homeId)) { home = currHome; break; } } if (home != null) { break; } } return home; }
@Override public void mouseClicked(MouseEvent me) { String pass = new String(tfPassword.getPassword()); String user = tfUsername.getText(); if (user.length() != 0 && pass.length() != 0 && (tmp = database.checkLogin(user, pass)) != 0) { dispose(); Home home = new Home(); home.setVisible(true); home.setLocationRelativeTo(null); } else { // lValid.setForeground(Color.red); lValid.setText("Invalid Credentials"); java.awt.Toolkit.getDefaultToolkit().beep(); tfUsername.setText(""); tfPassword.setText(""); } }
public UI(Composite parent, int style) { super(parent, style); home = new Home("myHome.xml"); // Add main components of the UI initGUI(); // Add this home's comHomeComponente UI { Vector<HomeComponent> hvacComponents = home.getComponents("hvac"); for (int i = 0; i < hvacComponents.size(); i++) hvacComponents.get(i).add(this.mainContentContainer, new Point(44, 179 + 220 * i)); } { Vector<HomeComponent> lightingComponents = home.getComponents("lighting"); for (int i = 0; i < lightingComponents.size(); i++) lightingComponents.get(i).add(this.mainContentContainer, new Point(44, 179 + 220 * i)); } { Vector<HomeComponent> electronicComponents = home.getComponents("electronic"); for (int i = 0; i < electronicComponents.size(); i++) electronicComponents.get(i).add(this.mainContentContainer, new Point(44, 179 + 220 * i)); } { Vector<HomeComponent> securityComponents = home.getComponents("security"); for (int i = 0; i < securityComponents.size(); i++) securityComponents.get(i).add(this.mainContentContainer, new Point(44, 179 + 220 * i)); } this.pack(); Event hvacSelection = new Event(); hvacSelection.widget = this.mainNavigation.getItem(0); this.navigation.widgetDefaultSelected(new SelectionEvent(hvacSelection)); }
public boolean deleteProject(User u, JFrame frame) { if (!Methodes.testConnectie()) { JFrame[] frames = {frame}; Methodes.Disconnect(frames, "Connectie verloren, terug naar login scherm"); } boolean check = false; DefaultHttpClient client = u.getClient(); HttpPost post = new HttpPost("http://" + Methodes.getIp() + "/webservice/deleteProject"); try { StringEntity delete = new StringEntity("{\"pid\":\"" + id + "\"}"); delete.setContentType("application/json"); post.setEntity(delete); HttpResponse response = client.execute(post); BufferedReader rd = new BufferedReader(new InputStreamReader(response.getEntity().getContent())); String line = ""; while ((line = rd.readLine()) != null) { System.out.println(line); check = true; } } catch (IOException e) { e.printStackTrace(); } finally { if (check) { Home.main(null, u); frame.dispose(); } client.getConnectionManager().shutdown(); } return check; }
private void logoutButton_actionPerformed(ActionEvent e) { this.setVisible(false); Home logout = new Home(); logout.setVisible(true); }
@Override public Home createHome( String player, String name, String world, double x, double y, double z, float yaw, float pitch) { Home home = plugin.getDatabase().createEntityBean(Home.class); home.setPlayerHomeName(new PlayerHomeName(player, name)); home.setWorld(world); home.setX(x); home.setY(y); home.setZ(z); home.setYaw(yaw); home.setPitch(pitch); if (!homes.containsKey(home.getOwner().toLowerCase())) { homes.put(home.getOwner().toLowerCase(), new HashMap<String, Home>()); } homes.get(home.getOwner().toLowerCase()).put(home.getName().toLowerCase(), home); return home; }
/** @param home */ public AnimalChild(Home home) { super(home.getPosition()); this.setHome(home); }
private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) { Home home = new Home(); home.setVisible(true); dispose(); }
public void updateLoginState() { homeParent.updateLoginState(); }
/** Initializes the GUI. */ private void initGUI() { try { this.setBackground(SWTResourceManager.getColor(192, 192, 192)); FormLayout thisLayout = new FormLayout(); this.setLayout(thisLayout); this.layout(); this.setSize(1024, 768); // Set up the header and the close button that goes on the header { FormData composite1LData = new FormData(); composite1LData.width = 1024; composite1LData.height = 120; composite1LData.left = new FormAttachment(0, 1000, 0); composite1LData.top = new FormAttachment(0, 1000, 0); headerContainer = new Composite(this, SWT.NONE); headerContainer.setLayout(null); headerContainer.setLayoutData(composite1LData); headerContainer.setBackgroundImage( ImageLoader.load(this.getDisplay(), "resources/header.png")); { closeButton = new Label(headerContainer, SWT.PUSH | SWT.CENTER); closeButton.setLocation(new org.eclipse.swt.graphics.Point(100, 0)); closeButton.setBounds(958, -2, 66, 33); closeButton.setImage(ImageLoader.load(this.getDisplay(), "resources/closeIcon.png")); closeButton.addMouseListener( new MouseAdapter() { public void mouseDown(MouseEvent evt) { closeButtonMouseDown(evt); } }); } } { FormData mainContentContainerLData = new FormData(); mainContentContainerLData.width = 834; mainContentContainerLData.height = 648; mainContentContainerLData.left = new FormAttachment(0, 1000, 190); mainContentContainerLData.top = new FormAttachment(0, 1000, 120); mainContentContainer = new Composite(this, SWT.NONE); mainContentContainer.setLayout(null); mainContentContainer.setLayoutData(mainContentContainerLData); mainContentContainer.setBackground(SWTResourceManager.getColor(255, 255, 255)); { mainNavigation = new ToolBar(mainContentContainer, SWT.FLAT | SWT.WRAP); mainNavigation.setBounds(0, 0, 835, 85); mainNavigation.setLayoutData(new FillLayout()); mainNavigation.setBackground(SWTResourceManager.getColor(239, 239, 239)); // Create the navigation tab bar { navigation = new NavigationBar(this.getDisplay(), this.mainContentContainer); navigation.createNavigationElement( home.getComponents("hvac"), mainNavigation, "resources/navigationIcons/hvac_active.png", "resources/navigationIcons/hvac_inactive.png"); navigation.createNavigationElement( home.getComponents("lighting"), mainNavigation, "resources/navigationIcons/lighting_active.png", "resources/navigationIcons/lighting_inactive.png"); navigation.createNavigationElement( home.getComponents("entertainment"), mainNavigation, "resources/navigationIcons/entertainment_active.png", "resources/navigationIcons/entertainment_inactive.png"); navigation.createNavigationElement( home.getComponents("security"), mainNavigation, "resources/navigationIcons/security_active.png", "resources/navigationIcons/security_inactive.png"); navigation.createNavigationElement( home.getComponents("other"), mainNavigation, "resources/navigationIcons/appliances_active.png", "resources/navigationIcons/appliances_inactive.png"); } mainNavigation.pack(); } { ambientTemperatureLabel = new Label(mainContentContainer, SWT.NONE); ambientTemperatureLabel.setText("Ambient Temperature: 0" + degreeSymbol); ambientTemperatureLabel.setBounds(176, 117, 385, 39); ambientTemperatureLabel.setBackground(SWTResourceManager.getColor(32, 32, 32)); ambientTemperatureLabel.setForeground(SWTResourceManager.getColor(255, 255, 255)); ambientTemperatureLabel.setFont( SWTResourceManager.getFont("Gill Sans MT", 18, 1, false, false)); ambientTemperatureLabel.setAlignment(SWT.CENTER); } } // Set up the sidebar { // Make it look pretty FormData sideBarContainerLData = new FormData(); sideBarContainerLData.width = 190; sideBarContainerLData.height = 647; sideBarContainerLData.left = new FormAttachment(0, 1000, 0); sideBarContainerLData.top = new FormAttachment(0, 1000, 120); sideBarContainer = new Composite(this, SWT.NONE); sideBarContainer.setLayout(null); sideBarContainer.setLayoutData(sideBarContainerLData); sideBarContainer.setBackgroundImage( ImageLoader.load(this.getDisplay(), "resources/sidebar.png")); // Current weather section { currentWeatherLabel = new Label(sideBarContainer, SWT.NONE); currentWeatherLabel.setText("Current Weather"); currentWeatherLabel.setFont( SWTResourceManager.getFont("Gill Sans MT", 13, 1, false, false)); currentWeatherLabel.setBounds(13, 24, 161, 25); currentWeatherLabel.setForeground(SWTResourceManager.getColor(51, 51, 51)); currentWeatherLabel.setAlignment(SWT.CENTER); } { currentWeatherIcon = new Label(sideBarContainer, SWT.NONE); currentWeatherIcon.setBounds(43, 61, 100, 100); currentWeatherIcon.setSize(93, 93); } { currentWeatherTemperature = new Label(sideBarContainer, SWT.NONE); currentWeatherTemperature.setBounds(17, 160, 160, 43); currentWeatherTemperature.setFont( SWTResourceManager.getFont("Gill Sans MT", 24, 1, false, false)); currentWeatherTemperature.setForeground(SWTResourceManager.getColor(51, 51, 51)); currentWeatherTemperature.setAlignment(SWT.CENTER); } { currentWeatherAdditional = new Label(sideBarContainer, SWT.NONE); currentWeatherAdditional.setFont( SWTResourceManager.getFont("Gill Sans MT", 8, 1, false, false)); currentWeatherAdditional.setForeground(SWTResourceManager.getColor(51, 51, 51)); currentWeatherAdditional.setBounds(11, 202, 166, 47); currentWeatherAdditional.setAlignment(SWT.CENTER); } LocalWeather localWeather = new LocalWeather(home.getLocation().getZipcode()); currentWeatherTemperature.setText("" + localWeather.getTemperature() + degreeSymbol + "F"); currentWeatherIcon.setImage(localWeather.getCurrentImage(this.getDisplay())); currentWeatherAdditional.setText( "Today's High: " + localWeather.getHighTemperature() + "\nPrecipitation: " + localWeather.getPrecipitation() + "%"); } } catch (Exception e) { e.printStackTrace(); } }
public void update() { float ambientTemperature = ((ClimateComponent) home.getComponents("hvac").get(0)).getAmbientTemperature(); this.ambientTemperatureLabel.setText("Ambient Temperature: " + ambientTemperature); }