Made unittest data backend for frontends and improved swing frontend.
Worked on metamodel backend and some other fixes.
This commit is contained in:
parent
1c308a684a
commit
a25e98f5d5
65 changed files with 2820 additions and 499 deletions
|
|
@ -49,12 +49,7 @@ public class SwingPagerPanel extends JPanel implements VascEntryFrontendEventLis
|
|||
|
||||
public SwingPagerPanel(VascEntry vascEntry) {
|
||||
this.vascEntry=vascEntry;
|
||||
//result = this;
|
||||
result = new JPanel();
|
||||
// result.setBackground(Color.green);
|
||||
//result.setBorder(BorderFactory.createLineBorder(Color.BLACK, 1));
|
||||
|
||||
|
||||
add(result);
|
||||
vascEntry.getVascFrontendData().addVascEntryFrontendEventListener(this);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,137 @@
|
|||
/*
|
||||
* 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.frontends.swing;
|
||||
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JMenu;
|
||||
import javax.swing.JMenuBar;
|
||||
import javax.swing.JMenuItem;
|
||||
import javax.swing.JPanel;
|
||||
|
||||
import net.forwardfire.vasc.core.VascEntry;
|
||||
import net.forwardfire.vasc.core.entry.VascEntryFrontendEventListener;
|
||||
import net.forwardfire.vasc.impl.DefaultVascFactory;
|
||||
|
||||
/**
|
||||
* SwingPanelFrame to render into frames.
|
||||
*
|
||||
*
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 Feb 6, 2012
|
||||
*/
|
||||
public class SwingPanelFrame implements SwingPanelIntegration {
|
||||
|
||||
Map<JPanel,JFrame> panels = new HashMap<JPanel,JFrame>(5);
|
||||
boolean addVascMenu = true;
|
||||
|
||||
public SwingPanelFrame() {
|
||||
this(true);
|
||||
}
|
||||
public SwingPanelFrame(boolean addVascMenu) {
|
||||
this.addVascMenu=addVascMenu;
|
||||
}
|
||||
|
||||
public void createNewVascView(VascEntry entry) throws Exception {
|
||||
// define redering
|
||||
JPanel panel = initVascView();
|
||||
SwingVascFrontend render = new SwingVascFrontend(panel,this);
|
||||
|
||||
// render
|
||||
render.initEntry(entry);
|
||||
render.renderView();
|
||||
|
||||
entry.getVascFrontendData().addVascEntryFrontendEventListener(new VascEntryFrontendEventListener() {
|
||||
private static final long serialVersionUID = -6801954395965101748L;
|
||||
public void vascEvent(VascEntry entry, Object data) {
|
||||
if (data instanceof Exception) {
|
||||
Exception e = (Exception)data;
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
public VascFrontendEventType[] getEventTypes() {
|
||||
return new VascFrontendEventType[] {VascFrontendEventType.EXCEPTION};
|
||||
}
|
||||
});
|
||||
|
||||
// get data
|
||||
entry.getVascFrontendData().getVascFrontendActions().refreshData();
|
||||
openVascView(panel, entry);
|
||||
}
|
||||
|
||||
public JPanel initVascView() {
|
||||
return new JPanel();
|
||||
}
|
||||
|
||||
public void openVascView(JPanel pane,final VascEntry entry) {
|
||||
JFrame frame = new JFrame();
|
||||
frame.setTitle("Vasc Edit - Swing - "+entry.getName());
|
||||
frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
|
||||
frame.setLocationRelativeTo(null);
|
||||
|
||||
JMenuBar menubar = new JMenuBar();
|
||||
JMenu vascMenu = new JMenu("Vasc Entries");
|
||||
|
||||
if (addVascMenu) {
|
||||
for (final String id:entry.getVascFrontendData().getVascController().getVascEntryController().getVascEntryIds()) {
|
||||
JMenuItem item = new JMenuItem(id);
|
||||
item.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
try {
|
||||
VascEntry ee = entry.getVascFrontendData().getVascController().getVascEntryController().getVascEntryById(id).clone();
|
||||
//TestModelEntry.fill(ee,entry.getVascFrontendData().getVascController());
|
||||
DefaultVascFactory.fillVascEntryFrontend(ee, entry.getVascFrontendData().getVascController(), DefaultVascFactory.getDefaultVascFrontendData(null));
|
||||
createNewVascView(ee);
|
||||
} catch (Exception e1) {
|
||||
e1.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
vascMenu.add(item);
|
||||
}
|
||||
menubar.add(vascMenu);
|
||||
frame.setJMenuBar(menubar);
|
||||
}
|
||||
|
||||
frame.add(pane);
|
||||
|
||||
// view
|
||||
frame.pack();
|
||||
frame.setVisible(true);
|
||||
|
||||
panels.put(pane,frame);
|
||||
}
|
||||
|
||||
public void closeVascView(JPanel pane,VascEntry entry) {
|
||||
JFrame frame = panels.get(pane);
|
||||
if (frame!=null) {
|
||||
frame.setVisible(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
package net.forwardfire.vasc.frontends.swing;
|
||||
|
||||
import javax.swing.JPanel;
|
||||
|
||||
import net.forwardfire.vasc.core.VascEntry;
|
||||
|
||||
/**
|
||||
* SwingPanelIntegration provides the JPanels to vasc to integrate into application panel handing.
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 Feb 6, 2012
|
||||
*/
|
||||
public interface SwingPanelIntegration {
|
||||
|
||||
public void createNewVascView(VascEntry entry) throws Exception;
|
||||
public JPanel initVascView();
|
||||
public void openVascView(JPanel pane,VascEntry entry);
|
||||
public void closeVascView(JPanel pane,VascEntry entry);
|
||||
}
|
||||
|
|
@ -0,0 +1,92 @@
|
|||
/*
|
||||
* 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.frontends.swing;
|
||||
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JTabbedPane;
|
||||
|
||||
import net.forwardfire.vasc.core.VascEntry;
|
||||
import net.forwardfire.vasc.core.entry.VascEntryFrontendEventListener;
|
||||
|
||||
/**
|
||||
* SwingPanelTabbed to render into tabs.
|
||||
*
|
||||
*
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 Feb 6, 2012
|
||||
*/
|
||||
public class SwingPanelTabbed implements SwingPanelIntegration {
|
||||
|
||||
JTabbedPane tabbedPane = null;
|
||||
|
||||
public SwingPanelTabbed(JTabbedPane tabbedPane) {
|
||||
this.tabbedPane=tabbedPane;
|
||||
}
|
||||
|
||||
public void createNewVascView(VascEntry entry) throws Exception {
|
||||
// define redering
|
||||
JPanel panel = initVascView();
|
||||
SwingVascFrontend render = new SwingVascFrontend(panel,this);
|
||||
|
||||
// render
|
||||
render.initEntry(entry);
|
||||
render.renderView();
|
||||
|
||||
entry.getVascFrontendData().addVascEntryFrontendEventListener(new VascEntryFrontendEventListener() {
|
||||
private static final long serialVersionUID = -6801954395965101748L;
|
||||
public void vascEvent(VascEntry entry, Object data) {
|
||||
if (data instanceof Exception) {
|
||||
Exception e = (Exception)data;
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
public VascFrontendEventType[] getEventTypes() {
|
||||
return new VascFrontendEventType[] {VascFrontendEventType.EXCEPTION};
|
||||
}
|
||||
});
|
||||
|
||||
// get data
|
||||
entry.getVascFrontendData().getVascFrontendActions().refreshData();
|
||||
openVascView(panel, entry);
|
||||
}
|
||||
|
||||
public JPanel initVascView() {
|
||||
return new JPanel();
|
||||
}
|
||||
|
||||
public void openVascView(JPanel pane,final VascEntry entry) {
|
||||
tabbedPane.addTab(entry.getName(), pane);
|
||||
tabbedPane.setSelectedIndex(tabbedPane.getTabCount()-1);
|
||||
}
|
||||
|
||||
public void closeVascView(JPanel pane,VascEntry entry) {
|
||||
for (int i=0;i<tabbedPane.getTabCount();i++) {
|
||||
Object tab = tabbedPane.getComponentAt(i);
|
||||
if (pane==tab) {
|
||||
tabbedPane.removeTabAt(i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -28,17 +28,18 @@ import java.awt.event.ActionEvent;
|
|||
import java.awt.event.ActionListener;
|
||||
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JComponent;
|
||||
import javax.swing.JDialog;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.SpringLayout;
|
||||
|
||||
import net.forwardfire.vasc.core.VascController;
|
||||
import net.forwardfire.vasc.core.VascEntry;
|
||||
import net.forwardfire.vasc.core.VascEntryField;
|
||||
import net.forwardfire.vasc.core.VascLinkEntry;
|
||||
import net.forwardfire.vasc.core.ui.VascColumnValueModelListener;
|
||||
import net.forwardfire.vasc.core.ui.VascUIComponent;
|
||||
import net.forwardfire.vasc.core.ui.VascValueModel;
|
||||
import net.forwardfire.vasc.impl.DefaultVascFactory;
|
||||
|
||||
/**
|
||||
* SwingVascEditDialog renders vasc entry edit dialog
|
||||
|
|
@ -46,7 +47,7 @@ import net.forwardfire.vasc.core.ui.VascValueModel;
|
|||
* @author Willem Cazander
|
||||
* @version 1.0 Mar 21, 2007
|
||||
*/
|
||||
public class SwingVascEditDialog extends JDialog {
|
||||
public class SwingVascEditDialog extends JPanel {
|
||||
|
||||
private static final long serialVersionUID = 10L;
|
||||
private String headerText = null;
|
||||
|
|
@ -55,70 +56,102 @@ public class SwingVascEditDialog extends JDialog {
|
|||
private Object bean = null;
|
||||
private VascEntry entry = null;
|
||||
private SwingVascFrontend swingFrontend = null;
|
||||
private SwingPanelIntegration panels = null;
|
||||
private JPanel editView = null;
|
||||
|
||||
public SwingVascEditDialog(SwingVascFrontend swingFrontend,JComponent parent,VascEntry entry,Object bean,String beanValue) throws Exception {
|
||||
public SwingVascEditDialog(SwingVascFrontend swingFrontend,JPanel editView,VascEntry entry,Object bean,String beanValue,SwingPanelIntegration panels) throws Exception {
|
||||
super();
|
||||
this.headerText = "vasc.dialog.edit.message";
|
||||
this.headerTextValue = beanValue;
|
||||
this.bean = bean;
|
||||
this.entry = entry;
|
||||
this.swingFrontend=swingFrontend;
|
||||
this.panels=panels;
|
||||
this.editView=editView;
|
||||
|
||||
setTitle(swingFrontend.i18n("vasc.dialog.edit.title"));
|
||||
setModal(true);
|
||||
|
||||
JPanel pane = new JPanel();
|
||||
pane.setLayout(new BorderLayout());
|
||||
setLayout(new BorderLayout());
|
||||
add(createHeader(), BorderLayout.NORTH);
|
||||
add(createBody(), BorderLayout.CENTER);
|
||||
add(createFooter(), BorderLayout.SOUTH);
|
||||
|
||||
editView.add(this);
|
||||
}
|
||||
|
||||
protected JPanel createHeader() {
|
||||
JPanel header = new JPanel();
|
||||
createHeader(header);
|
||||
pane.add(header,BorderLayout.NORTH);
|
||||
|
||||
JPanel body = new JPanel();
|
||||
createBody(body);
|
||||
pane.add(body,BorderLayout.CENTER);
|
||||
|
||||
JPanel footer = new JPanel();
|
||||
createFooter(footer);
|
||||
pane.add(footer,BorderLayout.SOUTH);
|
||||
|
||||
add(pane);
|
||||
setDefaultCloseOperation(DISPOSE_ON_CLOSE);
|
||||
|
||||
//Ensure the text field always gets the first focus.
|
||||
//addComponentListener(new ComponentAdapter() {
|
||||
// public void componentShown(ComponentEvent ce) {
|
||||
// textField.requestFocusInWindow();
|
||||
// }
|
||||
/// });
|
||||
|
||||
pack();
|
||||
setLocationRelativeTo(parent);
|
||||
setResizable(false);
|
||||
}
|
||||
|
||||
|
||||
public Object openDialog() {
|
||||
setVisible(true);
|
||||
return result;
|
||||
}
|
||||
|
||||
public void createHeader(JPanel header) {
|
||||
JLabel l = new JLabel();
|
||||
l.setText(swingFrontend.i18n(headerText,headerTextValue));
|
||||
l.setFont(new Font(null,Font.BOLD, 14));
|
||||
//l.setToolTipText(i18n(headerText));
|
||||
header.add(l);
|
||||
|
||||
for (final VascLinkEntry vle:entry.getVascLinkEntries()) {
|
||||
JButton but = new JButton(vle.getName());
|
||||
but.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
try {
|
||||
VascController vc = entry.getVascFrontendData().getVascController();
|
||||
VascEntry ee = vc.getVascEntryController().getVascEntryById(vle.getVascEntryId()).clone();
|
||||
DefaultVascFactory.fillVascEntryFrontend(ee, vc, DefaultVascFactory.getDefaultVascFrontendData(null));
|
||||
|
||||
// Set parameters
|
||||
try {
|
||||
Object selected = bean;
|
||||
for (String parameterName:vle.getEntryParameterFieldIdKeys()) {
|
||||
String fieldId = vle.getEntryParameterFieldId(parameterName);
|
||||
VascEntryField v = ee.getVascEntryFieldById(fieldId);
|
||||
if (v==null) {
|
||||
System.out.println("Could nog get VascEntryField for fieldID: "+fieldId);
|
||||
continue;
|
||||
}
|
||||
if (v.getVascEntryFieldValue()==null) {
|
||||
System.out.println("Could not get VascEntryFieldValue for fieldID: "+fieldId);
|
||||
continue;
|
||||
}
|
||||
Object selectedValue = v.getVascEntryFieldValue().getValue(v, selected);
|
||||
|
||||
// set data parameter on new vasc entry
|
||||
ee.getVascFrontendData().getVascEntryState().getVascBackendState().setDataParameter(parameterName, selectedValue);
|
||||
System.out.println("Setting link parameter: "+parameterName+" with: "+selectedValue);
|
||||
}
|
||||
|
||||
for (String fieldId:vle.getEntryCreateFieldValueKeys()) {
|
||||
String selectedfieldId = vle.getEntryParameterFieldId(fieldId);
|
||||
Object selectedValue = selected;
|
||||
if (selectedfieldId!=null) {
|
||||
VascEntryField v = ee.getVascEntryFieldById(selectedfieldId);
|
||||
selectedValue = v.getVascEntryFieldValue().getValue(v, selected);
|
||||
}
|
||||
|
||||
// create listener for new objects
|
||||
//entry.getVascFrontendData().addVascEntryFrontendEventListener(new CreateEntryFieldValuesListener2(fieldId,selectedValue));
|
||||
}
|
||||
} catch (Exception eee) {
|
||||
throw new RuntimeException("error: "+eee.getMessage(),eee);
|
||||
}
|
||||
|
||||
|
||||
|
||||
panels.createNewVascView(ee);
|
||||
} catch (Exception eee) {
|
||||
eee.printStackTrace();
|
||||
}
|
||||
}
|
||||
});
|
||||
header.add(but);
|
||||
}
|
||||
|
||||
return header;
|
||||
}
|
||||
|
||||
public void createBody(JPanel body) throws Exception {
|
||||
protected JPanel createBody() throws Exception {
|
||||
JPanel body = new JPanel();
|
||||
body.setLayout(new SpringLayout());
|
||||
int column = 0;
|
||||
int column = 0;
|
||||
for (VascEntryField c:entry.getVascEntryFields()) {
|
||||
if (c.getEdit()==false) {
|
||||
continue;
|
||||
}
|
||||
|
||||
//if (c.isEditReadOnly()==true) {
|
||||
|
||||
for (int i=0;i<c.getVascEntryFieldType().getUIComponentCount(c);i++) {
|
||||
|
|
@ -142,10 +175,10 @@ public class SwingVascEditDialog extends JDialog {
|
|||
}
|
||||
//JComponent, rows, cols, initX, initY ,xPad, yPad
|
||||
SpringUtilities.makeCompactGrid(body, column,2, 6,6, 6,6);
|
||||
|
||||
return body;
|
||||
}
|
||||
public void createFooter(JPanel footer) {
|
||||
|
||||
public JPanel createFooter() {
|
||||
JPanel footer = new JPanel();
|
||||
JButton saveButton = new JButton();
|
||||
saveButton.setIcon(swingFrontend.getImageIcon("vasc.dialog.save.image"));
|
||||
saveButton.setText(swingFrontend.i18n("vasc.dialog.save.name"));
|
||||
|
|
@ -155,8 +188,15 @@ public class SwingVascEditDialog extends JDialog {
|
|||
//if(entry.getVascFrontendData().getVascFrontendHelper().validateObject(entry, bean)) {
|
||||
// return;
|
||||
//}
|
||||
|
||||
|
||||
result = bean;
|
||||
setVisible(false);
|
||||
|
||||
entry.getVascFrontendData().getVascEntryState().setEntryDataObject(result);
|
||||
entry.getVascFrontendData().getVascFrontendActions().mergeObject();
|
||||
|
||||
panels.closeVascView(editView, SwingVascEditDialog.this.entry);
|
||||
//setVisible(false);
|
||||
}
|
||||
});
|
||||
footer.add(saveButton);
|
||||
|
|
@ -168,9 +208,11 @@ public class SwingVascEditDialog extends JDialog {
|
|||
cancelButton.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent event) {
|
||||
result = null;
|
||||
setVisible(false);
|
||||
panels.closeVascView(editView, SwingVascEditDialog.this.entry);
|
||||
//setVisible(false);
|
||||
}
|
||||
});
|
||||
footer.add(cancelButton);
|
||||
return footer;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -32,6 +32,8 @@ import java.awt.event.MouseAdapter;
|
|||
import java.awt.event.MouseEvent;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import javax.swing.BorderFactory;
|
||||
|
|
@ -63,6 +65,7 @@ import net.forwardfire.vasc.core.VascException;
|
|||
import net.forwardfire.vasc.core.actions.GlobalVascAction;
|
||||
import net.forwardfire.vasc.core.actions.RowVascAction;
|
||||
import net.forwardfire.vasc.core.entry.VascEntryExporter;
|
||||
import net.forwardfire.vasc.core.ui.VascOptionValueModelListener;
|
||||
import net.forwardfire.vasc.core.ui.VascUIComponent;
|
||||
import net.forwardfire.vasc.core.ui.VascValueModel;
|
||||
|
||||
|
|
@ -87,10 +90,14 @@ public class SwingVascFrontend extends AbstractVascFrontend {
|
|||
private Logger logger = null;
|
||||
private JComponent parent = null;
|
||||
private boolean initOnce = true;
|
||||
private Map<RowVascAction,JButton> rowActions = null;
|
||||
private SwingPanelIntegration panels = null;
|
||||
|
||||
public SwingVascFrontend(JComponent parent) {
|
||||
public SwingVascFrontend(JComponent parent,SwingPanelIntegration panels) {
|
||||
logger = Logger.getLogger(SwingVascFrontend.class.getName());
|
||||
this.parent=parent;
|
||||
this.panels=panels;
|
||||
rowActions = new HashMap<RowVascAction,JButton>(5);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -159,14 +166,10 @@ public class SwingVascFrontend extends AbstractVascFrontend {
|
|||
beanValue=beanValue.substring(0, 30);
|
||||
}
|
||||
}
|
||||
SwingVascEditDialog dialog = new SwingVascEditDialog(this,parent,entry,rowBean,beanValue);
|
||||
Object result = dialog.openDialog();
|
||||
logger.finest("OPEN closed : "+result);
|
||||
if(result==null) {
|
||||
return;
|
||||
}
|
||||
entry.getVascFrontendData().getVascEntryState().setEntryDataObject(result);
|
||||
entry.getVascFrontendData().getVascFrontendActions().mergeObject();
|
||||
JPanel editPanel = panels.initVascView();
|
||||
SwingVascEditDialog dialog = new SwingVascEditDialog(this,editPanel,entry,rowBean,beanValue,panels);
|
||||
|
||||
panels.openVascView(editPanel,entry);
|
||||
}
|
||||
|
||||
public void renderDelete() throws Exception {
|
||||
|
|
@ -309,8 +312,8 @@ public class SwingVascFrontend extends AbstractVascFrontend {
|
|||
|
||||
VascUIComponent editor = c.getVascEntryFieldType().provideEditorUIComponent(i,c);
|
||||
model = new VascValueModel(c.getVascEntryFieldType().provideEditorVascValueModel(i,c));
|
||||
model.addListener(new VascOptionValueModelListener(c));
|
||||
model.setValue(c.getDefaultValue());
|
||||
//model.addListener(new VascColumnValueModelListener(c,bean));
|
||||
Object g = editor.createComponent(entry,c,model,body);
|
||||
|
||||
column++;
|
||||
|
|
@ -320,6 +323,7 @@ public class SwingVascFrontend extends AbstractVascFrontend {
|
|||
body.add(new JLabel()); // fill :(
|
||||
}
|
||||
}
|
||||
entry.getVascFrontendData().getVascFrontendHelper().headerOptionsCreatedFillData(entry);
|
||||
|
||||
// add search
|
||||
column++;
|
||||
|
|
@ -327,10 +331,17 @@ public class SwingVascFrontend extends AbstractVascFrontend {
|
|||
body.add(searchLabel);
|
||||
final JTextField searchField = new JTextField();
|
||||
body.add(searchField);
|
||||
searchField.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent arg0) {
|
||||
String searchText = searchField.getText();
|
||||
entry.getVascFrontendData().getVascFrontendActions().searchAction(searchText);
|
||||
}
|
||||
});
|
||||
JButton searchButton = new JButton("Search");
|
||||
searchButton.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent arg0) {
|
||||
entry.getVascFrontendData().getVascFrontendActions().searchAction(searchField.getText());
|
||||
String searchText = searchField.getText();
|
||||
entry.getVascFrontendData().getVascFrontendActions().searchAction(searchText);
|
||||
}
|
||||
});
|
||||
body.add(searchButton);
|
||||
|
|
@ -396,7 +407,7 @@ public class SwingVascFrontend extends AbstractVascFrontend {
|
|||
counter++;
|
||||
}
|
||||
table.getSelectionModel().addListSelectionListener(new EntrySectionListener(table));
|
||||
table.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION);
|
||||
table.getSelectionModel().setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
|
||||
table.addMouseListener(new MouseAdapter() {
|
||||
public void mousePressed(MouseEvent e) {
|
||||
if (e.getClickCount() == 2) {
|
||||
|
|
@ -428,40 +439,16 @@ public class SwingVascFrontend extends AbstractVascFrontend {
|
|||
public void mouseClicked(MouseEvent e) {
|
||||
TableColumnModel colModel = table.getColumnModel();
|
||||
int columnModelIndex = colModel.getColumnIndexAtX(e.getX());
|
||||
//int modelIndex = colModel.getColumn(columnModelIndex).getModelIndex();
|
||||
/*
|
||||
if (modelIndex < 0)
|
||||
return;
|
||||
if (sortCol == modelIndex)
|
||||
isSortAsc = !isSortAsc;
|
||||
else
|
||||
sortCol = modelIndex;
|
||||
|
||||
for (int i = 0; i < columnsCount; i++) {
|
||||
TableColumn column = colModel.getColumn(i);
|
||||
column.setHeaderValue(getColumnName(column.getModelIndex()));
|
||||
}
|
||||
table.getTableHeader().repaint();
|
||||
*/
|
||||
|
||||
TableColumn tc = colModel.getColumn(columnModelIndex);
|
||||
VascEntryField field = (VascEntryField)tc.getHeaderValue();
|
||||
//VascEntry entry = comp.getVascEntry();
|
||||
//VascEntryField field = entry.getVascEntryFieldById(fieldIdString);
|
||||
|
||||
entry.getVascFrontendData().getVascFrontendActions().sortAction(field);
|
||||
|
||||
sortOrder = entry.getVascFrontendData().getVascEntryState().getVascBackendState().isSortAscending();
|
||||
sortField = field.getId();
|
||||
|
||||
try {
|
||||
entry.getVascFrontendData().getVascFrontend().renderView();
|
||||
} catch (Exception ee) {
|
||||
entry.getVascFrontendData().getVascFrontendHelper().handleException(entry, ee);
|
||||
}
|
||||
|
||||
//Collections.sort(vector,new MyComparator(isSortAsc));
|
||||
//table.tableChanged(new TableModelEvent(MyTableModel.this));
|
||||
entry.getVascFrontendData().getVascFrontendActions().sortAction(field);
|
||||
sortOrder = entry.getVascFrontendData().getVascEntryState().getVascBackendState().isSortAscending();
|
||||
sortField = field.getId();
|
||||
try {
|
||||
entry.getVascFrontendData().getVascFrontend().renderView();
|
||||
} catch (Exception ee) {
|
||||
entry.getVascFrontendData().getVascFrontendHelper().handleException(entry, ee);
|
||||
}
|
||||
table.repaint();
|
||||
}
|
||||
}
|
||||
|
|
@ -474,7 +461,33 @@ public class SwingVascFrontend extends AbstractVascFrontend {
|
|||
if (e.getValueIsAdjusting()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (table.getSelectedRowCount()==0) {
|
||||
for (RowVascAction action:rowActions.keySet()) {
|
||||
JButton but = rowActions.get(action);
|
||||
if (action.getId().contains("add")==false) {
|
||||
but.setEnabled(false);
|
||||
}
|
||||
}
|
||||
} else if (table.getSelectedRowCount()==1) {
|
||||
for (JButton but:rowActions.values()) {
|
||||
but.setEnabled(true);
|
||||
}
|
||||
} else {
|
||||
for (RowVascAction action:rowActions.keySet()) {
|
||||
JButton but = rowActions.get(action);
|
||||
if (action.isMultiRowAction()) {
|
||||
but.setEnabled(true);
|
||||
} else {
|
||||
if (action.getId().contains("add")==false) {
|
||||
but.setEnabled(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int rowIndex = table.getSelectedRow();
|
||||
|
||||
if (rowIndex!=-1) {
|
||||
// temp; gets index by sorter
|
||||
//rowIndex = tableSorter.modelIndex(rowIndex);
|
||||
|
|
@ -529,6 +542,10 @@ public class SwingVascFrontend extends AbstractVascFrontend {
|
|||
but.setToolTipText(i18n(action.getDescription()));
|
||||
but.setIcon(getImageIcon(action.getImage()));
|
||||
but.addActionListener(new RowActionListener(action));
|
||||
if (action.getId().contains("add")==false) {
|
||||
but.setEnabled(false);
|
||||
}
|
||||
rowActions.put(action, but);
|
||||
panel.add(but);
|
||||
}
|
||||
bottomPanel.add(panel,BorderLayout.SOUTH);
|
||||
|
|
|
|||
|
|
@ -104,7 +104,7 @@ public class SwingVascTableModel extends AbstractTableModel implements VascEntry
|
|||
}
|
||||
|
||||
public VascFrontendEventType[] getEventTypes() {
|
||||
VascFrontendEventType[] result = {VascFrontendEventType.POST_UPDATE,VascFrontendEventType.POST_READ};
|
||||
VascFrontendEventType[] result = {VascFrontendEventType.POST_UPDATE,VascFrontendEventType.POST_READ,VascFrontendEventType.POST_DELETE};
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -52,7 +52,9 @@ public class SwingBoolean implements VascUIComponent {
|
|||
public Object createComponent(VascEntry table,VascEntryField entryField,VascValueModel model,Object gui) throws VascException {
|
||||
checkBox = new JCheckBox();
|
||||
orgBackgroundColor = checkBox.getBackground();
|
||||
checkBox.setSelected(new Boolean(model.getValue().toString()));
|
||||
if (model.getValue()!=null) {
|
||||
checkBox.setSelected(new Boolean(model.getValue().toString()));
|
||||
}
|
||||
((JComponent)gui).add(checkBox);
|
||||
checkBox.addActionListener(new SelectActionListener(model,table));
|
||||
return checkBox;
|
||||
|
|
|
|||
|
|
@ -22,53 +22,30 @@
|
|||
|
||||
package net.forwardfire.vasc;
|
||||
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JMenu;
|
||||
import javax.swing.JMenuBar;
|
||||
import javax.swing.JMenuItem;
|
||||
import javax.swing.JPanel;
|
||||
|
||||
import net.forwardfire.vasc.core.VascController;
|
||||
import net.forwardfire.vasc.core.VascEntry;
|
||||
import net.forwardfire.vasc.core.VascEntryControllerLocal;
|
||||
import net.forwardfire.vasc.frontends.swing.SwingVascFrontend;
|
||||
import net.forwardfire.vasc.frontends.swing.SwingPanelFrame;
|
||||
import net.forwardfire.vasc.frontends.swing.SwingPanelIntegration;
|
||||
import net.forwardfire.vasc.impl.DefaultVascFactory;
|
||||
import net.forwardfire.vasc.test.frontend.data.TestModelEntry;
|
||||
|
||||
|
||||
import net.forwardfire.vasc.test.frontend.data.TestModelData;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
/**
|
||||
* Tests a simple x4o xml language.
|
||||
* SwingTestTabbed shows interfaces in frames.
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 Jul 24, 2006
|
||||
*/
|
||||
public class SwingTest extends TestCase {
|
||||
|
||||
private TestModelEntry entry = null;
|
||||
|
||||
public void setUp() throws Exception {
|
||||
// enable all logs
|
||||
//InputStream loggingProperties = this.getClass().getResourceAsStream("META-INF/logging.properties");
|
||||
//LogManager.getLogManager().readConfiguration( loggingProperties );
|
||||
//loggingProperties.close();
|
||||
}
|
||||
|
||||
public void tearDown() throws Exception {
|
||||
}
|
||||
|
||||
public void testNull() throws Exception {
|
||||
assertEquals(true, true);
|
||||
//main(new String[] {});
|
||||
}
|
||||
|
||||
public static void main(String[] argu){
|
||||
JFrame.setDefaultLookAndFeelDecorated(false);
|
||||
public static void main(String[] argu){
|
||||
SwingTest s = new SwingTest();
|
||||
try {
|
||||
s.open();
|
||||
|
|
@ -78,69 +55,13 @@ public class SwingTest extends TestCase {
|
|||
}
|
||||
|
||||
public void open() throws Exception {
|
||||
SwingPanelIntegration spi = new SwingPanelFrame();
|
||||
TestModelData testData = new TestModelData();
|
||||
VascController vc = testData.getTestVascController();
|
||||
testData.createVascEntries(vc,(VascEntryControllerLocal)vc.getVascEntryController());
|
||||
|
||||
entry = new TestModelEntry();
|
||||
VascController vc = entry.getTestVascController();
|
||||
|
||||
VascEntry ve = entry.createVascEntry(vc);
|
||||
|
||||
((VascEntryControllerLocal)vc.getVascEntryController()).addVascEntry(ve,vc);
|
||||
DefaultVascFactory.fillVascControllerLocalEntries((VascEntryControllerLocal) vc.getVascEntryController(), vc);
|
||||
|
||||
VascEntry ve = testData.getTestEntry(vc);
|
||||
DefaultVascFactory.fillVascEntryFrontend(ve, vc, DefaultVascFactory.getDefaultVascFrontendData(null));
|
||||
|
||||
JFrame frame = viewEntry(ve);
|
||||
|
||||
while (frame.isVisible()) {
|
||||
Thread.sleep(1000);
|
||||
}
|
||||
}
|
||||
|
||||
public JFrame viewEntry(final VascEntry entry) throws Exception {
|
||||
// get GUI
|
||||
JFrame frame = new JFrame();
|
||||
frame.setTitle("Vasc Test - Swing - "+entry.getName());
|
||||
frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
|
||||
frame.setLocationRelativeTo(null);
|
||||
|
||||
JMenuBar menubar = new JMenuBar();
|
||||
JMenu vascMenu = new JMenu("Vasc Entries");
|
||||
|
||||
for (final String id:entry.getVascFrontendData().getVascController().getVascEntryController().getVascEntryIds()) {
|
||||
JMenuItem item = new JMenuItem(id);
|
||||
item.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
try {
|
||||
VascEntry ee = entry.getVascFrontendData().getVascController().getVascEntryController().getVascEntryById(id);
|
||||
//TestModelEntry.fill(ee,entry.getVascFrontendData().getVascController());
|
||||
viewEntry(ee);
|
||||
} catch (Exception e1) {
|
||||
e1.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
vascMenu.add(item);
|
||||
}
|
||||
menubar.add(vascMenu);
|
||||
frame.setJMenuBar(menubar);
|
||||
|
||||
// define redering
|
||||
JPanel panel = new JPanel();
|
||||
SwingVascFrontend render = new SwingVascFrontend(panel);
|
||||
frame.add(panel);
|
||||
|
||||
// render
|
||||
render.initEntry(entry);
|
||||
render.renderView();
|
||||
|
||||
// get data
|
||||
entry.getVascFrontendData().getVascFrontendActions().refreshData();
|
||||
|
||||
// view
|
||||
frame.pack();
|
||||
frame.setVisible(true);
|
||||
|
||||
return frame;
|
||||
spi.createNewVascView(ve);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,121 @@
|
|||
/*
|
||||
* 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;
|
||||
|
||||
import java.awt.Dimension;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JMenu;
|
||||
import javax.swing.JMenuBar;
|
||||
import javax.swing.JMenuItem;
|
||||
import javax.swing.JTabbedPane;
|
||||
|
||||
import net.forwardfire.vasc.core.VascController;
|
||||
import net.forwardfire.vasc.core.VascEntry;
|
||||
import net.forwardfire.vasc.core.VascEntryControllerLocal;
|
||||
import net.forwardfire.vasc.frontends.swing.SwingPanelIntegration;
|
||||
import net.forwardfire.vasc.frontends.swing.SwingPanelTabbed;
|
||||
import net.forwardfire.vasc.impl.DefaultVascFactory;
|
||||
import net.forwardfire.vasc.test.frontend.data.TestModelData;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
/**
|
||||
* SwingTestTabbed shows interfaces in tabs.
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 Feb 06, 2012
|
||||
*/
|
||||
public class SwingTestTabbed extends TestCase {
|
||||
|
||||
public void testNull() throws Exception {
|
||||
assertEquals(true, true);
|
||||
//main(new String[] {});
|
||||
}
|
||||
|
||||
public static void main(String[] argu){
|
||||
SwingTestTabbed s = new SwingTestTabbed();
|
||||
try {
|
||||
s.open();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void open() throws Exception {
|
||||
TestModelData testData = new TestModelData();
|
||||
final VascController vc = testData.getTestVascController();
|
||||
testData.createVascEntries(vc,(VascEntryControllerLocal)vc.getVascEntryController());
|
||||
|
||||
JFrame frame = new JFrame();
|
||||
frame.setTitle("Vasc Tabbed Test");
|
||||
frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
|
||||
frame.setLocationRelativeTo(null);
|
||||
|
||||
final JTabbedPane pane = new JTabbedPane();
|
||||
final SwingPanelIntegration spi = new SwingPanelTabbed(pane);
|
||||
frame.add(pane);
|
||||
|
||||
JMenuBar menubar = new JMenuBar();
|
||||
JMenu vascMenu = new JMenu("Entries");
|
||||
for (final String id:vc.getVascEntryController().getVascEntryIds()) {
|
||||
JMenuItem item = new JMenuItem(id);
|
||||
item.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
try {
|
||||
VascEntry ee = vc.getVascEntryController().getVascEntryById(id).clone();
|
||||
DefaultVascFactory.fillVascEntryFrontend(ee, vc, DefaultVascFactory.getDefaultVascFrontendData(null));
|
||||
spi.createNewVascView(ee);
|
||||
} catch (Exception e1) {
|
||||
e1.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
vascMenu.add(item);
|
||||
}
|
||||
JMenuItem item = new JMenuItem("Close tab.");
|
||||
item.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
if (pane.getSelectedIndex()>=0) {
|
||||
pane.removeTabAt(pane.getSelectedIndex()); // todo release vasc frontend
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
vascMenu.add(item);
|
||||
menubar.add(vascMenu);
|
||||
frame.setJMenuBar(menubar);
|
||||
|
||||
// view
|
||||
frame.setMinimumSize(new Dimension(800,600));
|
||||
frame.pack();
|
||||
frame.setVisible(true);
|
||||
|
||||
VascEntry ve = testData.getTestEntry(vc);
|
||||
DefaultVascFactory.fillVascEntryFrontend(ve, vc, DefaultVascFactory.getDefaultVascFrontendData(null));
|
||||
spi.createNewVascView(ve);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,74 @@
|
|||
package net.forwardfire.vasc;
|
||||
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
|
||||
import javax.swing.ImageIcon;
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JOptionPane;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JTabbedPane;
|
||||
|
||||
public class Test implements ActionListener {
|
||||
|
||||
JFrame frame;
|
||||
JTabbedPane tabPane;
|
||||
JButton addTab;
|
||||
ImageIcon close;
|
||||
Dimension size;
|
||||
int tabCounter = 0;
|
||||
|
||||
public static void main(String[] args) {
|
||||
Test jtab = new Test();
|
||||
}
|
||||
|
||||
public Test() {
|
||||
frame = new JFrame();
|
||||
tabPane = new JTabbedPane();
|
||||
addTab = new JButton("Add Tab");
|
||||
addTab.addActionListener(this);
|
||||
close = new ImageIcon("/home/willemc/door_out.png");
|
||||
size = new Dimension(close.getIconWidth()+1,close.getIconHeight()+1);
|
||||
frame.add(tabPane,BorderLayout.CENTER);
|
||||
frame.add(addTab, BorderLayout.NORTH);
|
||||
frame.setSize(300, 300);
|
||||
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
frame.setVisible(true);
|
||||
}
|
||||
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
JLabel label = null;
|
||||
final JPanel panel = new JPanel();
|
||||
JPanel tab = new JPanel();
|
||||
tab.setOpaque(false);
|
||||
try{
|
||||
String str = JOptionPane.showInputDialog(null, "Enter Tab Name : ", "JavaJazzUp", 1);
|
||||
|
||||
if (str.length() == 0){
|
||||
JOptionPane.showMessageDialog(null,"Please Enter the Tab Name : ", "JavaJazzUp",1);
|
||||
} else if (str != null){
|
||||
label = new JLabel(str);
|
||||
panel.add(new JLabel("test"+str));
|
||||
} else {
|
||||
JOptionPane.showMessageDialog(null,"You pressed cancel button.", "JavaJazzUp",1);
|
||||
}
|
||||
JButton tabClose = new JButton(close);
|
||||
tabClose.setPreferredSize(size);
|
||||
tabClose.addActionListener(new ActionListener() {
|
||||
public void
|
||||
actionPerformed(ActionEvent e) {
|
||||
int tNum = tabPane.indexOfComponent(panel);
|
||||
tabPane.removeTabAt(tNum);
|
||||
}
|
||||
});
|
||||
tab.add(label, BorderLayout.WEST);
|
||||
tab.add(tabClose, BorderLayout.EAST);
|
||||
tabPane.addTab(null, panel);
|
||||
tabPane.setTabComponentAt(tabPane.getTabCount()-1, tab);
|
||||
} catch(Exception ex){}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue