Refactored demo section to single app layout.
This commit is contained in:
parent
b3635cf64d
commit
4bd244f4e5
337 changed files with 1630 additions and 1883 deletions
|
|
@ -0,0 +1,340 @@
|
|||
/*
|
||||
* Copyright 2007-2012 forwardfire.net All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
|
||||
* that the following conditions are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright notice, this list of conditions and the
|
||||
* following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
|
||||
* the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
|
||||
* THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
|
||||
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
package net.forwardfire.vasc.demo.client.swing;
|
||||
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.GridLayout;
|
||||
import java.awt.event.MouseAdapter;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
import javax.swing.BorderFactory;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JScrollPane;
|
||||
import javax.swing.JSplitPane;
|
||||
import javax.swing.JTabbedPane;
|
||||
import javax.swing.JTree;
|
||||
import javax.swing.ScrollPaneConstants;
|
||||
import javax.swing.SwingUtilities;
|
||||
import javax.swing.event.TreeModelListener;
|
||||
import javax.swing.tree.DefaultMutableTreeNode;
|
||||
import javax.swing.tree.DefaultTreeModel;
|
||||
import javax.swing.tree.TreeNode;
|
||||
|
||||
import net.forwardfire.vasc.backend.VascBackend;
|
||||
import net.forwardfire.vasc.backend.VascBackendControllerLocal;
|
||||
import net.forwardfire.vasc.core.VascController;
|
||||
import net.forwardfire.vasc.core.VascEntryConfigControllerLocal;
|
||||
import net.forwardfire.vasc.core.VascEntryControllerLocal;
|
||||
import net.forwardfire.vasc.core.VascEntryLocal;
|
||||
import net.forwardfire.vasc.core.VascException;
|
||||
import net.forwardfire.vasc.demo.tech.domain.menu.VascMenuController;
|
||||
import net.forwardfire.vasc.demo.tech.domain.menu.model.VascMenu;
|
||||
import net.forwardfire.vasc.demo.tech.domain.menu.model.VascMenuGroup;
|
||||
import net.forwardfire.vasc.ejb3.VascServiceManager;
|
||||
import net.forwardfire.vasc.ejb3.VascServiceRemoteBackend;
|
||||
import net.forwardfire.vasc.frontend.swing.SwingPanelIntegration;
|
||||
import net.forwardfire.vasc.frontend.swing.SwingPanelTabbed;
|
||||
import net.forwardfire.vasc.impl.DefaultVascFactory;
|
||||
import net.forwardfire.vasc.lib.i18n.bundle.RootApplicationBundle;
|
||||
|
||||
/**
|
||||
* JMainPanel is the main panel/window of this demo.
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 May 12, 2012
|
||||
*/
|
||||
public class JMainPanel extends JPanel {
|
||||
|
||||
private static final long serialVersionUID = 5834715323973411147L;
|
||||
private VascController vc = null;
|
||||
private VascMenuController vmc = null;
|
||||
private VascServiceManager vsm = null;
|
||||
private SwingPanelIntegration spi = null;
|
||||
private JTabbedPane tabPane = null;
|
||||
private JTree vascTree = null;
|
||||
private JSplitPane treeSplitPane = null;
|
||||
|
||||
|
||||
public JMainPanel(VascServiceManager vsm,VascMenuController vmc) {
|
||||
this.vsm = vsm;
|
||||
this.vmc = vmc;
|
||||
setLayout(new BorderLayout());
|
||||
add(createTreeSplit(), BorderLayout.CENTER);
|
||||
|
||||
vc = createVascController(vsm);
|
||||
rebuildTree();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the vascController
|
||||
*/
|
||||
public VascController createVascController(VascServiceManager vsm) {
|
||||
try {
|
||||
// VascUserInfo vui = getVascUserInfo();
|
||||
|
||||
|
||||
// get local jvm plugging controller
|
||||
VascController c = DefaultVascFactory.getDefaultVascController();
|
||||
|
||||
((VascEntryConfigControllerLocal)c.getVascEntryConfigController()).setResourceBundle(RootApplicationBundle.class.getName());
|
||||
/*
|
||||
DefaultVascEntryController con = new DefaultVascEntryController() {
|
||||
public VascEntry getVascEntryById(String id) {
|
||||
VascEntry ve = super.getVascEntryById(id);
|
||||
// add global listener to make sure we have all LAZY properties of a bean before we goto edit mode.
|
||||
ve.addVascEntryEventListener(VascEventType.DATA_SELECT, new RefreshObjectForLazyPropertiesListener());
|
||||
return ve;
|
||||
}
|
||||
};
|
||||
((DefaultVascController)c).setVascEntryController(con);
|
||||
*/
|
||||
|
||||
|
||||
VascServiceManager vascManager = vsm;
|
||||
List<String> entryIds = vascManager.getVascEntryIds();
|
||||
|
||||
VascEntryControllerLocal localEntryController = (VascEntryControllerLocal)c.getVascEntryController();
|
||||
VascBackendControllerLocal localBackendController = (VascBackendControllerLocal)c.getVascBackendController();
|
||||
for (String id:entryIds) {
|
||||
VascEntryLocal ve = (VascEntryLocal)vascManager.getVascEntry(id);
|
||||
String backendId = ve.getBackendId();
|
||||
VascBackend vb = new VascServiceRemoteBackend(vascManager,backendId);
|
||||
|
||||
/*
|
||||
for (String key:ve.getEntryParameterKeys()) {
|
||||
Object value = ve.getEntryParameter(key);
|
||||
if (value instanceof String==false) {
|
||||
continue;
|
||||
}
|
||||
String paraValue = (String)value;
|
||||
if (paraValue.startsWith("userPara")==false) {
|
||||
continue;
|
||||
}
|
||||
String[] ps = paraValue.split(":");
|
||||
String type = ps[1];
|
||||
String paraTypeValue = ps[2];
|
||||
|
||||
SetParameterBackendListener listener = new SetParameterBackendListener(vui.userId,vui.username);
|
||||
listener.setName(key);
|
||||
listener.setType(type);
|
||||
listener.setValue(paraTypeValue);
|
||||
|
||||
VascBackendProxyEventExecutor localUserProxy = new VascBackendProxyEventExecutor();
|
||||
localUserProxy.addVascEntryBackendEventListener(listener);
|
||||
vb = localUserProxy;
|
||||
}
|
||||
*/
|
||||
localBackendController.addVascBackend(vb);
|
||||
localEntryController.addVascEntry(ve);
|
||||
|
||||
c.getVascEntryConfigController().configVascEntry(c, ve);
|
||||
}
|
||||
return c;
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException("Could not create remote based vasc controller; "+e.getMessage(),e);
|
||||
}
|
||||
}
|
||||
|
||||
private JSplitPane createTreeSplit() {
|
||||
JScrollPane sp0 = createTreePane();
|
||||
JScrollPane sp1 = createContentPane();
|
||||
treeSplitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT,sp0,sp1);
|
||||
treeSplitPane.setOneTouchExpandable(true);
|
||||
treeSplitPane.setResizeWeight(0.2);
|
||||
treeSplitPane.setDividerLocation(170);
|
||||
sp0.setMinimumSize(new Dimension(200, 400));
|
||||
sp1.setMinimumSize(new Dimension(400, 400));
|
||||
return treeSplitPane;
|
||||
}
|
||||
|
||||
class VascTreeModel extends DefaultTreeModel {
|
||||
public VascTreeModel(TreeNode root) {
|
||||
super(root);
|
||||
}
|
||||
|
||||
private static final long serialVersionUID = -7436681803506994277L;
|
||||
|
||||
@Override
|
||||
public void addTreeModelListener(TreeModelListener l) {
|
||||
super.addTreeModelListener(l);
|
||||
}
|
||||
}
|
||||
|
||||
public void openVascEntry(String vascId) throws VascException {
|
||||
VascEntryLocal ee = (VascEntryLocal)vsm.getVascEntry(vascId);
|
||||
vc.getVascEntryConfigController().configVascFrontendController(vc, ee);
|
||||
spi.createNewVascView(ee);
|
||||
}
|
||||
|
||||
private JScrollPane createTreePane() {
|
||||
|
||||
DefaultMutableTreeNode root = new DefaultMutableTreeNode(new VascTreeNode(VascTreeNodeType.ROOT,"Menu"));
|
||||
|
||||
vascTree = new JTree(new VascTreeModel(root));
|
||||
vascTree.addMouseListener(new MouseAdapter() {
|
||||
@Override
|
||||
public void mouseClicked(MouseEvent e) {
|
||||
super.mouseClicked(e);
|
||||
if (e.getClickCount() == 2 && vascTree.getSelectionModel().isSelectionEmpty()==false) {
|
||||
try {
|
||||
DefaultMutableTreeNode node = (DefaultMutableTreeNode)vascTree.getSelectionModel().getSelectionPath().getLastPathComponent();
|
||||
if (node.getUserObject() instanceof String) {
|
||||
return;
|
||||
}
|
||||
VascTreeNode vascNode = (VascTreeNode)node.getUserObject();
|
||||
if (vascNode != null && vsm!=null) {
|
||||
if (vascNode.type == VascTreeNodeType.ENTRY) {
|
||||
openVascEntry(vascNode.id);
|
||||
}
|
||||
}
|
||||
} catch (Exception ee) {
|
||||
ee.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
JPanel treePanel = new JPanel();
|
||||
treePanel.setLayout(new GridLayout(1,0));
|
||||
JScrollPane p = createJScrollPane(treePanel);
|
||||
p.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
|
||||
p.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED);
|
||||
treePanel.add(vascTree);
|
||||
|
||||
rebuildTree();
|
||||
return p;
|
||||
}
|
||||
|
||||
private JScrollPane createContentPane() {
|
||||
JPanel contentPane = new JPanel();
|
||||
contentPane.setLayout(new GridLayout(1,0));
|
||||
JScrollPane p = createJScrollPane(contentPane);
|
||||
|
||||
tabPane = new JTabbedPane();
|
||||
spi = new SwingPanelTabbed(tabPane);
|
||||
contentPane.add(tabPane);
|
||||
|
||||
return p;
|
||||
}
|
||||
|
||||
private JScrollPane createJScrollPane(JPanel innerPanel) {
|
||||
JScrollPane scrollPane = new JScrollPane(innerPanel);
|
||||
scrollPane.setBorder(BorderFactory.createEmptyBorder());
|
||||
scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
|
||||
scrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
|
||||
scrollPane.getVerticalScrollBar().setUnitIncrement(10);
|
||||
scrollPane.getHorizontalScrollBar().setUnitIncrement(10);
|
||||
//innerPanel.setParentScrollPane(scrollPane);
|
||||
return scrollPane;
|
||||
}
|
||||
|
||||
class VascTreeNode implements Serializable {
|
||||
private static final long serialVersionUID = -1177727401194030822L;
|
||||
public VascTreeNode() {}
|
||||
public VascTreeNode(VascTreeNodeType type,String id) { this.type=type;this.id=id; }
|
||||
public VascTreeNode(VascTreeNodeType type,String id,String entryId) { this.type=type;this.id=id;this.entryId=entryId; }
|
||||
VascTreeNodeType type;
|
||||
String id;
|
||||
String entryId;
|
||||
@Override
|
||||
public String toString() {
|
||||
return id;
|
||||
}
|
||||
|
||||
}
|
||||
enum VascTreeNodeType {
|
||||
ROOT,
|
||||
GROUP,
|
||||
ENTRY
|
||||
}
|
||||
|
||||
public void rebuildTree() {
|
||||
|
||||
|
||||
if (vsm==null) {
|
||||
return;
|
||||
}
|
||||
|
||||
DefaultMutableTreeNode root = (DefaultMutableTreeNode)vascTree.getModel().getRoot();
|
||||
root.removeAllChildren();
|
||||
|
||||
List<VascMenuGroup> groups = vmc.getFilteredMenuGroup();
|
||||
for (VascMenuGroup group:groups) {
|
||||
|
||||
DefaultMutableTreeNode groupNode = new DefaultMutableTreeNode(new VascTreeNode(VascTreeNodeType.GROUP,VascDemoSwingClient.getInstance().i18n(group.getTitleKey())));
|
||||
for (VascMenu vm:group.getMenus()) {
|
||||
DefaultMutableTreeNode entryNode = new DefaultMutableTreeNode(new VascTreeNode(VascTreeNodeType.ENTRY,VascDemoSwingClient.getInstance().i18n(vm.getTitleKey())));
|
||||
groupNode.add(entryNode);
|
||||
}
|
||||
root.add(groupNode);
|
||||
}
|
||||
|
||||
SwingUtilities.updateComponentTreeUI(vascTree);
|
||||
|
||||
/*
|
||||
// todo move
|
||||
Map<String,String> keys = new HashMap<String,String>(300);
|
||||
VascBundleCheckEntryKeys checker = new VascBundleCheckEntryKeys(ResourceBundle.getBundle("net.forwardfire.vasc.lib.i18n.bundle.RootApplicationBundle"));
|
||||
for (String veId:vascManager.getVascController().getVascEntryController().getVascEntryIds()) {
|
||||
VascEntry ve = vascManager.getVascController().getVascEntryController().getVascEntryById(veId);
|
||||
keys.putAll(checker.generateMissingKeys(ve));
|
||||
}
|
||||
if (keys.isEmpty()==false) {
|
||||
Properties p = new Properties();
|
||||
File dataDir = new File("data");
|
||||
|
||||
if (dataDir.exists()==false) {
|
||||
dataDir.mkdirs();
|
||||
}
|
||||
File resourceFile = new File("data/vasc-bundle.properties");
|
||||
if (resourceFile.exists()) {
|
||||
readPropertiesFile(p,resourceFile);
|
||||
}
|
||||
for (String key:keys.keySet()) {
|
||||
if (key==null) {
|
||||
continue;
|
||||
}
|
||||
if (keys.get(key)==null) {
|
||||
continue;
|
||||
}
|
||||
p.put(key, keys.get(key));
|
||||
}
|
||||
writePropertiesFile(p,resourceFile);
|
||||
|
||||
ResourceBundle.clearCache();
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
public JTabbedPane getTabPane() {
|
||||
return tabPane;
|
||||
}
|
||||
|
||||
public void changeEvent() {
|
||||
rebuildTree();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,131 @@
|
|||
/*
|
||||
* Copyright 2007-2012 forwardfire.net All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
|
||||
* that the following conditions are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright notice, this list of conditions and the
|
||||
* following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
|
||||
* the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
|
||||
* THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
|
||||
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
package net.forwardfire.vasc.demo.client.swing;
|
||||
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
|
||||
import javax.swing.JMenu;
|
||||
import javax.swing.JMenuBar;
|
||||
import javax.swing.JMenuItem;
|
||||
import javax.swing.JTabbedPane;
|
||||
|
||||
import net.forwardfire.vasc.core.VascException;
|
||||
import net.forwardfire.vasc.demo.tech.domain.menu.VascMenuController;
|
||||
|
||||
/**
|
||||
* JMainPanelMenuBar Adds all menu bar items.
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 May 12, 2012
|
||||
*/
|
||||
public class JMainPanelMenuBar extends JMenuBar implements ActionListener {
|
||||
|
||||
private static final long serialVersionUID = -2828428804621352725L;
|
||||
private JMainPanel mainPanel = null;
|
||||
//private List<JMenu> vascMenus = null;
|
||||
private JMenu clientFileMenu = null;
|
||||
private JMenu clientTabMenu = null;
|
||||
|
||||
public JMainPanelMenuBar(VascMenuController vmc,JMainPanel mainPanel) {
|
||||
this.mainPanel=mainPanel;
|
||||
|
||||
clientFileMenu = new JMenu("File");
|
||||
add(clientFileMenu);
|
||||
|
||||
JMenuItem logoutItem = new JMenuItem("Logout");
|
||||
logoutItem.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
try {
|
||||
VascDemoSwingClient.getInstance().logout();
|
||||
} catch (Exception e1) {
|
||||
e1.printStackTrace();
|
||||
}
|
||||
}
|
||||
});
|
||||
clientFileMenu.add(logoutItem);
|
||||
clientFileMenu.addSeparator();
|
||||
JMenuItem exitItem = new JMenuItem("Exit");
|
||||
exitItem.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
VascDemoSwingClient.getInstance().exit();
|
||||
}
|
||||
});
|
||||
clientFileMenu.add(exitItem);
|
||||
|
||||
/*
|
||||
List<VascMenuGroup> groups = vmc.getFilteredMenuGroup();
|
||||
for (VascMenuGroup group:groups) {
|
||||
JMenu menu = new JMenu(group.getTitleKey());
|
||||
for (VascMenu vm:group.getMenus()) {
|
||||
JMenuItem item = new JMenuItem(vm.getTitleKey());
|
||||
item.putClientProperty("vascEntryId", vm.getVascEntryId());
|
||||
item.addActionListener(this);
|
||||
menu.add(item);
|
||||
}
|
||||
add(menu);
|
||||
}
|
||||
*/
|
||||
|
||||
clientTabMenu = new JMenu("Tabs");
|
||||
add(clientTabMenu);
|
||||
JMenuItem item = new JMenuItem("Close tab");
|
||||
item.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
JTabbedPane tabPane = getTabPane();
|
||||
if (tabPane.getSelectedIndex()>=0) {
|
||||
tabPane.removeTabAt(tabPane.getSelectedIndex()); // todo release vasc frontend
|
||||
}
|
||||
}
|
||||
});
|
||||
clientTabMenu.add(item);
|
||||
JMenuItem itemAll = new JMenuItem("Close All tabs");
|
||||
itemAll.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
JTabbedPane tabPane = getTabPane();
|
||||
for (int i=tabPane.getTabCount();i>0;i--) {
|
||||
tabPane.removeTabAt(i-1); // todo release vasc frontend
|
||||
}
|
||||
}
|
||||
});
|
||||
clientTabMenu.add(itemAll);
|
||||
}
|
||||
|
||||
public JTabbedPane getTabPane() {
|
||||
return mainPanel.getTabPane();
|
||||
}
|
||||
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
if (e.getSource() instanceof JMenuItem) {
|
||||
JMenuItem item = (JMenuItem)e.getSource();
|
||||
String vascId = (String)item.getClientProperty("vascEntryId");
|
||||
try {
|
||||
mainPanel.openVascEntry(vascId);
|
||||
} catch (VascException e1) {
|
||||
// TODO Auto-generated catch block
|
||||
e1.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,291 @@
|
|||
/*
|
||||
* Copyright 2007-2012 forwardfire.net All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
|
||||
* that the following conditions are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright notice, this list of conditions and the
|
||||
* following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
|
||||
* the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
|
||||
* THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
|
||||
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
package net.forwardfire.vasc.demo.client.swing;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Font;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.text.MessageFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.MissingResourceException;
|
||||
import java.util.Properties;
|
||||
import java.util.ResourceBundle;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import javax.naming.CommunicationException;
|
||||
import javax.naming.Context;
|
||||
import javax.naming.InitialContext;
|
||||
import javax.security.auth.login.LoginContext;
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JOptionPane;
|
||||
import javax.swing.UIManager;
|
||||
|
||||
import net.forwardfire.vasc.demo.tech.domain.menu.VascMenuController;
|
||||
import net.forwardfire.vasc.demo.tech.domain.user.ClientUserController;
|
||||
import net.forwardfire.vasc.ejb3.VascServiceManager;
|
||||
import net.forwardfire.vasc.lib.i18n.bundle.RootApplicationBundle;
|
||||
|
||||
import org.jdesktop.application.Application;
|
||||
import org.jdesktop.application.FrameView;
|
||||
import org.jdesktop.application.SingleFrameApplication;
|
||||
|
||||
/**
|
||||
* VascDemoSwingClient is the main swing remote client.
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 Nov 10, 2012
|
||||
*/
|
||||
public class VascDemoSwingClient extends SingleFrameApplication {
|
||||
|
||||
static protected Context context = null;
|
||||
static protected LoginContext loginContext = null;
|
||||
private Logger logger = null;
|
||||
|
||||
static public void main(String[] args) {
|
||||
Application.launch(VascDemoSwingClient.class, new String[] {});
|
||||
}
|
||||
|
||||
static public VascDemoSwingClient getInstance() {
|
||||
return (VascDemoSwingClient)SingleFrameApplication.getInstance();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void startup() {
|
||||
|
||||
logger = Logger.getLogger(VascDemoSwingClient.class.getName());
|
||||
installColorsLaF();
|
||||
doLogin();
|
||||
|
||||
VascServiceManager vc = null;
|
||||
ClientUserController cuc = null;
|
||||
VascMenuController vmc = null;
|
||||
try {
|
||||
vc = (VascServiceManager)context.lookup("vascServiceManagerRemote");
|
||||
System.out.println("ob: "+vc);
|
||||
|
||||
cuc = (ClientUserController)context.lookup("clientUserControllerRemote");
|
||||
System.out.println("fll: "+cuc.doClientLogin());
|
||||
|
||||
// i18n fixme !!
|
||||
RootApplicationBundle bundle = (RootApplicationBundle)ResourceBundle.getBundle(RootApplicationBundle.class.getName());
|
||||
bundle.addBundleData(cuc.getResourceBundle(bundle.getLocale()));
|
||||
|
||||
vmc = (VascMenuController)context.lookup("vascMenuControllerRemote");
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
JMainPanel mainPanel = new JMainPanel(vc,vmc);
|
||||
SingleFrameApplication a = (VascDemoSwingClient)getInstance(); // BIG NOTE because of 'launch' for auto conf swing.
|
||||
FrameView mainView = a.getMainView();
|
||||
mainView.getFrame().setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
mainView.setComponent(mainPanel);
|
||||
mainView.setMenuBar(new JMainPanelMenuBar(vmc,mainPanel));
|
||||
mainView.getFrame().setSize(1000, 600);
|
||||
mainView.getFrame().setVisible(true);
|
||||
}
|
||||
|
||||
public void logout() {
|
||||
SingleFrameApplication a = (VascDemoSwingClient)getInstance(); // BIG NOTE because of 'launch' for auto conf swing.
|
||||
FrameView mainView = a.getMainView();
|
||||
mainView.getFrame().setVisible(false);
|
||||
|
||||
startup(); // ugly ..
|
||||
}
|
||||
|
||||
/**
|
||||
* Do an login on the server
|
||||
*/
|
||||
private void doLogin() {
|
||||
VascDemoUserLoginDialog loginHandler = new VascDemoUserLoginDialog();
|
||||
loginHandler.setConnectUrl("http://localhost:8899/demo");
|
||||
/*
|
||||
try {
|
||||
loginContext = new LoginContext("vasc-auth-client", loginHandler);
|
||||
loginContext.login();
|
||||
} catch(Exception e) {
|
||||
JOptionPane.showMessageDialog(null, i18n(this,"dialogNoLoginContext"),i18n(this,"dialogTitle"), JOptionPane.WARNING_MESSAGE);
|
||||
System.exit(1);
|
||||
}
|
||||
*/
|
||||
|
||||
try {
|
||||
loginHandler.handle();
|
||||
if(doLoginContext(loginHandler)) {
|
||||
return;
|
||||
}
|
||||
loginHandler.handle();
|
||||
if(doLoginContext(loginHandler)) {
|
||||
return;
|
||||
}
|
||||
loginHandler.handle();
|
||||
if(doLoginContext(loginHandler)) {
|
||||
return;
|
||||
}
|
||||
|
||||
JOptionPane.showMessageDialog(null, i18n(this,"dialogUserLoginFailure"),i18n(this,"dialogTitle"), JOptionPane.WARNING_MESSAGE);
|
||||
System.exit(1);
|
||||
} catch (CommunicationException e) {
|
||||
List<String> messages = new ArrayList<String>(3);
|
||||
messages.add("Could not connect to Vasc Tech Client Swing server, please try again.");
|
||||
messages.add("If the problem persists please contact your systems administrator.");
|
||||
String connectionError = "Could not obtain connection to any of these urls: ";
|
||||
Integer connectionErrorLen = connectionError.length();
|
||||
String emsg = e.getMessage();
|
||||
if (emsg!=null && emsg.startsWith(connectionError)) {
|
||||
Integer urlEndIdx = emsg.substring(connectionErrorLen).indexOf(':');
|
||||
if (urlEndIdx>=0) {
|
||||
messages.add("Server unreachable at: "+emsg.substring(connectionErrorLen, connectionErrorLen+urlEndIdx));
|
||||
}
|
||||
}
|
||||
JOptionPane.showMessageDialog(null, messages.toArray(), "Vasc Tech Client Swing", JOptionPane.WARNING_MESSAGE);
|
||||
System.exit(1);
|
||||
} catch (Exception e) {
|
||||
//logger.log(Level.WARNING,e.getMessage(),e);
|
||||
JOptionPane.showMessageDialog(null, "Failure on login test.", "Vasc Tech Client Swing", JOptionPane.WARNING_MESSAGE);
|
||||
System.exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create naming context and check if we have 'login' role on server.
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
private boolean doLoginContext(VascDemoUserLoginDialog loginHandler) throws Exception {
|
||||
Properties props = new Properties();
|
||||
String connectUrl = loginHandler.getConnectUrl()+"/ejb";
|
||||
logger.info("Connecting to: "+connectUrl);
|
||||
props.put(Context.PROVIDER_URL, connectUrl );
|
||||
props.put("openejb.authentication.realmName", "vasc-auth-server");
|
||||
props.put(Context.SECURITY_PRINCIPAL,loginHandler.getUsername());
|
||||
props.put(Context.SECURITY_CREDENTIALS,loginHandler.getPassword());
|
||||
props.put(Context.INITIAL_CONTEXT_FACTORY, "org.apache.openejb.client.RemoteInitialContextFactory");
|
||||
try {
|
||||
context = new InitialContext(props);
|
||||
ClientUserController loginManager = (ClientUserController)context.lookup("clientUserControllerRemote");
|
||||
loginManager.doClientLogin();
|
||||
return true;
|
||||
} catch (javax.naming.NameNotFoundException e) {
|
||||
JOptionPane.showMessageDialog(null, "Server is not deployed.\nPlease wait a couple of minuts and try again.");
|
||||
return false;
|
||||
} catch (Exception e) {
|
||||
JOptionPane.showMessageDialog(null, "Server error: "+e.getMessage());
|
||||
//e.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private String installColorsLaF() {
|
||||
UIManager.put("TabbedPane.font", Font.decode("SansSerif-BOLD-12"));
|
||||
UIManager.put("TitledBorder.font", Font.decode("SansSerif-BOLD-16"));
|
||||
UIManager.put("FireDial.font", Font.decode("SansSerif-9"));
|
||||
|
||||
String colorName = "laf-colors";
|
||||
ClassLoader cl = Thread.currentThread().getContextClassLoader();
|
||||
if (cl==null) {
|
||||
cl = this.getClass().getClassLoader();
|
||||
}
|
||||
InputStream in = cl.getResourceAsStream("net/forwardfire/vasc/demo/client/swing/resources/"+colorName+".properties");
|
||||
if (in==null) {
|
||||
logger.warning("Color schema not found: "+colorName);
|
||||
return "unknown";
|
||||
}
|
||||
try {
|
||||
Properties p = new Properties();
|
||||
p.load(in);
|
||||
for (Object key:p.keySet()) {
|
||||
String value = p.getProperty(key.toString());
|
||||
Color colorValue = Color.decode(value);
|
||||
UIManager.put(key,colorValue);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
logger.warning("Could not load color schema: "+colorName+" error: "+e.getMessage());
|
||||
} finally {
|
||||
try {
|
||||
in.close();
|
||||
} catch (IOException e) {
|
||||
}
|
||||
}
|
||||
|
||||
// Invert focus painters
|
||||
List<Object> keys = new ArrayList<Object>(UIManager.getLookAndFeelDefaults().keySet());
|
||||
for (Object keyObj:keys) {
|
||||
if ((keyObj instanceof String)==false) {
|
||||
continue;
|
||||
}
|
||||
String key = (String)keyObj;
|
||||
|
||||
if (key.endsWith("[Focused].backgroundPainter")==false & key.endsWith("[Focused].iconPainter")==false) {
|
||||
continue;
|
||||
}
|
||||
String preKey = key.substring(0,key.indexOf("["));
|
||||
String postKey = "backgroundPainter";
|
||||
if (key.contains("iconPainter")) {
|
||||
postKey = "iconPainter";
|
||||
}
|
||||
|
||||
logger.finer("Flipping painters of key: "+preKey);
|
||||
|
||||
Object focusPainter = UIManager.getLookAndFeelDefaults().get(preKey+"[Focused]."+postKey);
|
||||
Object mouseOverPainter = UIManager.getLookAndFeelDefaults().get(preKey+"[MouseOver]."+postKey);
|
||||
UIManager.getLookAndFeelDefaults().put(preKey+"[Focused]."+postKey,mouseOverPainter);
|
||||
UIManager.getLookAndFeelDefaults().put(preKey+"[MouseOver]."+postKey,focusPainter);
|
||||
|
||||
if (key.contains("iconPainter")) {
|
||||
Object focusPainterSelected = UIManager.getLookAndFeelDefaults().get(preKey+"[Focused+Selected]."+postKey);
|
||||
Object mouseOverPainterSelected = UIManager.getLookAndFeelDefaults().get(preKey+"[MouseOver+Selected]."+postKey);
|
||||
UIManager.getLookAndFeelDefaults().put(preKey+"[Focused+Selected]."+postKey,mouseOverPainterSelected);
|
||||
UIManager.getLookAndFeelDefaults().put(preKey+"[MouseOver+Selected]."+postKey,focusPainterSelected);
|
||||
}
|
||||
}
|
||||
|
||||
return colorName;
|
||||
}
|
||||
|
||||
public String i18n(Object obj,String key,Object...params) {
|
||||
if(obj==null) { throw new NullPointerException("Can't get key of null obj"); }
|
||||
if (key==null) { throw new NullPointerException("key may not be null"); }
|
||||
if(obj instanceof Class) {
|
||||
key=((Class<?>)obj).getName()+"."+key;
|
||||
} else {
|
||||
key=obj.getClass().getName()+"."+key;
|
||||
}
|
||||
return i18n(key,params);
|
||||
}
|
||||
|
||||
public String i18n(String key,Object...params) {
|
||||
try {
|
||||
String text = ResourceBundle.getBundle(RootApplicationBundle.class.getName()).getString(key);
|
||||
if (params != null) {
|
||||
MessageFormat mf = new MessageFormat(text);
|
||||
text = mf.format(params, new StringBuffer(), null).toString();
|
||||
}
|
||||
return text;
|
||||
} catch(MissingResourceException e){
|
||||
return key;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,268 @@
|
|||
/*
|
||||
* Copyright 2007-2012 forwardfire.net All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
|
||||
* that the following conditions are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright notice, this list of conditions and the
|
||||
* following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
|
||||
* the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
|
||||
* THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
|
||||
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
package net.forwardfire.vasc.demo.client.swing;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Font;
|
||||
import java.awt.Graphics;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.GridLayout;
|
||||
import java.awt.Image;
|
||||
import java.awt.RenderingHints;
|
||||
import java.awt.Toolkit;
|
||||
import java.awt.event.WindowEvent;
|
||||
import java.awt.event.WindowFocusListener;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Timer;
|
||||
import java.util.TimerTask;
|
||||
|
||||
import javax.swing.BorderFactory;
|
||||
import javax.swing.Box;
|
||||
import javax.swing.BoxLayout;
|
||||
import javax.swing.JComponent;
|
||||
import javax.swing.JDialog;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JOptionPane;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JPasswordField;
|
||||
import javax.swing.JTextField;
|
||||
|
||||
/**
|
||||
* VascDemoUserLoginDialog used be be true jaas auth module but now only dialog.
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 Nov 10, 2012
|
||||
*/
|
||||
public class VascDemoUserLoginDialog {
|
||||
|
||||
private static final int JPasswordFieldLen = 8;
|
||||
private int loginTry = 0;
|
||||
private String connectUrl = null;
|
||||
private String username = null;
|
||||
private String password = null;
|
||||
|
||||
/**
|
||||
* An interface for recording actions to carry out if the user clicks OK for
|
||||
* the dialog.
|
||||
*/
|
||||
private static interface Action {
|
||||
void perform();
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles the login dialog
|
||||
*/
|
||||
public void handle() {
|
||||
this.loginTry++;
|
||||
final JPanel loginDesign = new JPanel();
|
||||
loginDesign.setLayout(new BoxLayout(loginDesign, BoxLayout.PAGE_AXIS));
|
||||
final Image logoImage = Toolkit.getDefaultToolkit().createImage(getClass().getResource("/net/forwardfire/vasc/demo/client/swing/resources/logo.png"));
|
||||
final JPanel logoPanel = new JPanel() {
|
||||
private static final long serialVersionUID = 10l;
|
||||
protected void paintComponent(Graphics g) {
|
||||
Graphics2D g2d = (Graphics2D)g;
|
||||
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,RenderingHints.VALUE_ANTIALIAS_ON);
|
||||
g2d.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING,RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
|
||||
g2d.setRenderingHint(RenderingHints.KEY_RENDERING,RenderingHints.VALUE_RENDER_QUALITY);
|
||||
|
||||
// Paint the default look of the panel.
|
||||
super.paintComponent(g2d);
|
||||
|
||||
g2d.setColor(Color.BLACK);
|
||||
g2d.fillRect(0,0,getWidth(),getHeight());
|
||||
g2d.setColor(new Color(238,212,1));
|
||||
|
||||
int w = (getWidth()/2)-(logoImage.getWidth(null)/2);
|
||||
int h = (getHeight()/2)-(logoImage.getHeight(null)/2);
|
||||
g2d.drawImage(logoImage, w, h, this);
|
||||
}
|
||||
};
|
||||
logoPanel.setPreferredSize(new Dimension(200, 170));
|
||||
logoPanel.setBorder(BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.LOWERED));
|
||||
loginDesign.add(logoPanel);
|
||||
loginDesign.add(Box.createVerticalStrut(5));
|
||||
JPanel namePanel = new JPanel();
|
||||
JLabel nameLabel = new JLabel("Vasc Demo Client");
|
||||
nameLabel.setFont(new Font("Lucida Sans", Font.BOLD, 24));
|
||||
namePanel.add(nameLabel);
|
||||
loginDesign.add(namePanel);
|
||||
loginDesign.add(Box.createVerticalStrut(5));
|
||||
|
||||
final List<Action> okActions = new ArrayList<Action>(2);
|
||||
final GridLayout messagesLayout = new GridLayout(3,2);
|
||||
final JPanel messages = new JPanel();
|
||||
messages.setLayout(messagesLayout);
|
||||
|
||||
// Add server field
|
||||
JLabel serverName = new JLabel("Server:");
|
||||
final JTextField serverField = new JTextField(getConnectUrl());
|
||||
messages.add(serverName);
|
||||
messages.add(serverField);
|
||||
okActions.add(new Action() {
|
||||
public void perform() {
|
||||
connectUrl = serverField.getText();
|
||||
}
|
||||
});
|
||||
|
||||
// hackje for focus
|
||||
final JTextField name = new JTextField();
|
||||
final JPasswordField pass = new JPasswordField(JPasswordFieldLen);
|
||||
|
||||
JLabel prompt = new JLabel("Username:");
|
||||
String defaultName = null;
|
||||
|
||||
// if (check some property)
|
||||
defaultName = "";
|
||||
if (defaultName != null) {
|
||||
name.setText(defaultName);
|
||||
}
|
||||
// default to last user name
|
||||
if (username !=null ) {
|
||||
name.setText(username);
|
||||
}
|
||||
messages.add(prompt);
|
||||
messages.add(name);
|
||||
|
||||
/* Store the name back into the callback if OK */
|
||||
okActions.add(new Action() {
|
||||
public void perform() {
|
||||
username = name.getText();
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
prompt = new JLabel("Password:");
|
||||
|
||||
//if (!pc.isEchoOn()) {
|
||||
pass.setEchoChar('*');
|
||||
//}
|
||||
messages.add(prompt);
|
||||
messages.add(pass);
|
||||
|
||||
okActions.add(new Action() {
|
||||
public void perform() {
|
||||
password = new String(pass.getPassword());
|
||||
}
|
||||
});
|
||||
|
||||
if (this.loginTry>1) {
|
||||
JPanel messagesPanel = new JPanel();
|
||||
messagesPanel.setBorder(BorderFactory.createEtchedBorder());
|
||||
JLabel iup = new JLabel("Invalid Username and Password:");
|
||||
iup.setForeground(Color.RED);
|
||||
messagesPanel.add(iup);
|
||||
loginDesign.add(messagesPanel);
|
||||
loginDesign.add(Box.createVerticalStrut(5));
|
||||
}
|
||||
|
||||
JPanel messagesPanel = new JPanel();
|
||||
messagesPanel.setBorder(BorderFactory.createEtchedBorder());
|
||||
messagesPanel.add(messages);
|
||||
loginDesign.add(messagesPanel);
|
||||
/* Display the dialog */
|
||||
|
||||
Object[] options = null;
|
||||
/// JOptionPane(Object message, int messageType, int optionType, Icon icon, Object[] options, Object initialValue)
|
||||
JOptionPane jop = new JOptionPane(loginDesign, JOptionPane.PLAIN_MESSAGE,JOptionPane.OK_CANCEL_OPTION,null,options,name);
|
||||
|
||||
JComponent parentComponent = null;
|
||||
JDialog dialog = jop.createDialog(parentComponent,"Vasc Demo Login");
|
||||
|
||||
// We alway request focus after the windows gets focus
|
||||
dialog.addWindowFocusListener(new WindowFocusListener() {
|
||||
public void windowGainedFocus(WindowEvent arg0) {
|
||||
name.requestFocus();
|
||||
}
|
||||
public void windowLostFocus(WindowEvent arg0) {
|
||||
}
|
||||
});
|
||||
|
||||
// HACK, EVEN the listener above doesn't work 100% so just request focus request
|
||||
// until we have focus, then cancel task, see println output
|
||||
final Timer lTimer = new Timer();
|
||||
lTimer.schedule(new TimerTask() {
|
||||
public void run() {
|
||||
if(name.hasFocus()==false) {
|
||||
//System.out.println("request focus timer task");
|
||||
name.requestFocus();
|
||||
} else {
|
||||
cancel();
|
||||
}
|
||||
}
|
||||
}, 10, 5);
|
||||
// wait 10ms
|
||||
// execute every 5ms
|
||||
|
||||
dialog.setAlwaysOnTop(true);
|
||||
dialog.setVisible(true);
|
||||
Integer result = (Integer)jop.getValue();
|
||||
dialog.dispose();
|
||||
|
||||
if (result==null) {
|
||||
// is null when escaping by window closing
|
||||
result = JOptionPane.CANCEL_OPTION;
|
||||
}
|
||||
|
||||
/* Perform the OK actions */
|
||||
if (result == JOptionPane.OK_OPTION || result == JOptionPane.YES_OPTION) {
|
||||
Iterator<Action> iterator = okActions.iterator();
|
||||
while (iterator.hasNext()) {
|
||||
iterator.next().perform();
|
||||
}
|
||||
} else if (result == JOptionPane.CANCEL_OPTION || result == JOptionPane.NO_OPTION) {
|
||||
System.exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return the username
|
||||
*/
|
||||
public String getUsername() {
|
||||
return username;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the password
|
||||
*/
|
||||
public String getPassword() {
|
||||
return password;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the connectUrl
|
||||
*/
|
||||
public String getConnectUrl() {
|
||||
return connectUrl;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param connectUrl the connectUrl to set
|
||||
*/
|
||||
public void setConnectUrl(String connectUrl) {
|
||||
this.connectUrl = connectUrl;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
|
||||
config.charset=UTF-8
|
||||
config.bundles=bundle1
|
||||
#,bundle2
|
||||
|
||||
# bundle list to merge and load
|
||||
bundle1.uri=net.forwardfire.vasc.demo.client.swing.resources.VascDemoSwingClient
|
||||
|
||||
#bundle2.uri=data/vasc-bundle.properties
|
||||
#bundle2.type=FILE
|
||||
#bundle2.optional=true
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,33 @@
|
|||
#
|
||||
# Copyright (c) 2011, Willem Cazander
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without modification, are permitted provided
|
||||
# that the following conditions are met:
|
||||
#
|
||||
# * Redistributions of source code must retain the above copyright notice, this list of conditions and the
|
||||
# following disclaimer.
|
||||
# * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
|
||||
# the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
|
||||
# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
|
||||
# THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||
# OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
|
||||
# TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
|
||||
# Application's properties
|
||||
Application.name = Vasc Demo Tech
|
||||
Application.title = VascDemoTech
|
||||
Application.vendor = Willem Cazander
|
||||
Application.homepage = http://vasc.forwardfire.org/
|
||||
Application.vendorId = vasc
|
||||
Application.id = vascdemotech
|
||||
Application.lookAndFeel = com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel
|
||||
Application.icon = icon.png
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 264 B |
|
|
@ -0,0 +1,18 @@
|
|||
|
||||
#
|
||||
# yellow-purple color schema from pulsefire.
|
||||
#
|
||||
text=#FF9900
|
||||
info=#9F3B00
|
||||
control=#5B084C
|
||||
nimbusBase=#3A0053
|
||||
nimbusDisabledText=#3A0053
|
||||
nimbusFocus=#FF6600
|
||||
nimbusLightBackground=#47184D
|
||||
nimbusSelectedText=#47184D
|
||||
nimbusBlueGrey=#661C7D
|
||||
nimbusGreen=#D2C122
|
||||
nimbusBorder=#A018D8
|
||||
nimbusSelectionBackground=#BF6204
|
||||
ComboBox.background=#380030
|
||||
TabbedPane.background=#380030
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 12 KiB |
Loading…
Add table
Add a link
Reference in a new issue