Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
Copyright (c) 2011 Michael Ruflin, Andr´┐Ż Locher, Claudia von Bastian. This file is part of Tatool. Tatool is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Tatool is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with Tatool. If not, see <http://www.gnu.org/licenses/>. /
 
 package ch.tatool.core.display.swing;
 
 import java.awt.Color;
 import java.util.List;
 import java.util.Map;
 
 
 
Display implementation usable for task execution.

Author(s):
Michael Ruflin
 
 public class SwingExecutionFrame extends javax.swing.JFrame implements
 
 	private static final long serialVersionUID = 5488252067183749247L;
 
 	private static String OS = System.getProperty("os.name").toLowerCase();
 
 	private static String JAVA = System.getProperty("java.version")
 
 	Logger logger = LoggerFactory.getLogger(SwingExecutionFrame.class);

Default background color of the frame.
 
 	private static final Color DEFAULT_BACKGROUND_COLOR = .;

Should the view be displayed in full-screen mode?
 
 	private boolean fullScreenModeEnabled;
 	private boolean screenModeInitialized = false// whether the screen mode
 													// has been initialized yet
 
Holds the panels added to the screen.
 
Overlay component
 
Card Layout used to manage the cards.
 
 	private CardLayout cardLayout;
 
 	private Executor executor;

Creates new form SwingExecutionFrame
 
 	public SwingExecutionFrame() {
 
 		// initialize the ui components of this frame
 
 		// layeredPane resize handler - we need to resize the overlay if the
 		// layeredpane size changes
 			public void componentResized(ComponentEvent e) {
			}
		});
	}
	// Window displaying
Set the full screen mode. Note that this is only possible before the frame is being displayed for the first time!
	public void setFullScreenModeEnabled(boolean fullScreenModeEnabled) {
		this. = fullScreenModeEnabled;
	}

Get whether the fullscreen mode is enabled.
	public boolean isFullScreenModeEnabled() {
	}

Initializes the full screen mode of the frame.
	private void initFullScreenMode() {
		this.setResizable(false);
		if (!this.isDisplayable()) {
			this.setUndecorated(true);
		}
	}

Displays this frame in full screen mode.
	private void showFrameInFullScreen() {
		GraphicsDevice gd = GraphicsEnvironment.getLocalGraphicsEnvironment()
		// TODO: remove workaround for mac/java7 bug as soon as Oracle fixes issue
		if ((.indexOf("mac") >= 0) && .indexOf("1.7") >= 0) {
			.warn("Opening SwingExecutionFrame with workaround for Mac OS X and Java 7 Bug.");
			this.setVisible(false);
			this.setVisible(true);
else {
			.info("Opening SwingExecutionFrame without workaround for Mac OS X and Java 7 Bug.");
			this.setVisible(true);
		}
	}

Returns to non-full-screen mode and hides this window.
	private void removeFrameFromScreen() {
		GraphicsDevice gd = GraphicsEnvironment.getLocalGraphicsEnvironment()
		setVisible(false);
	}

Shows the window.
	public void showWindow() {
		// check whether we have to initialize the screen mode
			}
		}
else {
			setSize(800, 600);
		}
	}

Hides the window.
	public void hideWindow() {
		this.getRootPane().getActionMap().put("doSomething"null);
else {
			setVisible(false);
		}
	}

Hides the window and completely disposed uses resources.
	public void disposeWindow() {
		this.dispose();
	}
	// SwingExecutionDisplay
Add a card to this display
	public void addCard(String cardIdComponent component) {
		removeCard(cardId);
		.put(cardIdcomponent);
		.add(componentcardId);
	}

Display a previously added card.
	public void showCard(String cardId) {
	}

Removes a card from the display.
	public void removeCard(String cardId) {
		Component component = .get(cardId);
		if (component != null) {
			.remove(component);
		}
	}

Remove all added cards.
	public void removeAllCards() {
		for (Component component : .values()) {
			.remove(component);
		}
	}

Display an empty card.
	public void displayEmptyCard() {
	}

Get the currently displayed card.
		return null;
	}

Set the overlay component to be displayed.

Parameters:
component the overlay component to display, null to remove any displayed component
	public void setOverlay(Component component) {
		JLayeredPane layeredPane = getLayeredPane();
		if ( != null) {
		}
		 = component;
		if ( != null) {
		}
	}

Resizes the overlayComponent according to the layeredPane size.
	private void resizeOverlayComponent() {
		if ( != null) {
		}
	}

Get the background color of this frame.
	}

Set the background color of this frame.
	public void setBackgroundColor(Color color) {
		if (color != null) {
else {
		}
	}
	public void setExecutor(Executor executor) {
		this. = executor;
	}

Initialise key bindings for available KeyEventHandlers
	public void setupKeyEvents() {
		List<ObjectkeyEventHandlers = (List<Object>) ElementUtils.findHandlersInStackByType(.getExecutionContext(), KeyEventHandler.class);
		for (Object handler : keyEventHandlers) {
			final KeyEventHandler keyHandler = (KeyEventHandlerhandler;
			Action keyAction = new AbstractAction() {
				private static final long serialVersionUID = 1L;
				public void actionPerformed(ActionEvent e) {
					if ( != null) {
						.info("Key event triggered with code: " + KeyEvent.getKeyText(keyHandler.getKeyEvent()));
					}
				}
			};
			this.getRootPane().getInputMap(.).put(KeyStroke.getKeyStroke(keyHandler.getKeyEvent(), 0),"keyEvent_" + keyHandler.getKeyEvent());
			this.getRootPane().getActionMap().put("keyEvent_" + keyHandler.getKeyEvent(), keyAction);
		}
	}
	public void processExecutionPhase(ExecutionContext context) {
		}
	}

This method is called from within the constructor to initialize the form. WARNING: Do NOT modify this code. The content of this method is always regenerated by the Form Editor.
	// @SuppressWarnings("unchecked")
	// <editor-fold defaultstate="collapsed"
	// desc="Generated Code">//GEN-BEGIN:initComponents
	private void initComponents() {
		.setBackground(new java.awt.Color(255, 255, 255));
		.setBackground(new java.awt.Color(255, 255, 255));
		.add("emptyCard");
	}// </editor-fold>//GEN-END:initComponents
	// Variables declaration - do not modify//GEN-BEGIN:variables
	// End of variables declaration//GEN-END:variables
New to GrepCode? Check out our FAQ X