Small refactor for comming converters
This commit is contained in:
parent
75b3d5e0a0
commit
1c308a684a
178 changed files with 5865 additions and 1531 deletions
|
|
@ -0,0 +1,154 @@
|
|||
/*
|
||||
* 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.swt;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.forwardfire.vasc.backend.VascBackendPageNumber;
|
||||
import net.forwardfire.vasc.core.VascEntry;
|
||||
import net.forwardfire.vasc.core.actions.GlobalVascAction;
|
||||
import net.forwardfire.vasc.core.entry.VascEntryFrontendEventListener;
|
||||
import net.forwardfire.vasc.core.ui.VascSelectItem;
|
||||
|
||||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.events.ModifyEvent;
|
||||
import org.eclipse.swt.events.ModifyListener;
|
||||
import org.eclipse.swt.events.SelectionAdapter;
|
||||
import org.eclipse.swt.events.SelectionEvent;
|
||||
import org.eclipse.swt.events.SelectionListener;
|
||||
import org.eclipse.swt.layout.GridData;
|
||||
import org.eclipse.swt.layout.GridLayout;
|
||||
import org.eclipse.swt.widgets.Combo;
|
||||
import org.eclipse.swt.widgets.Composite;
|
||||
import org.eclipse.swt.widgets.Label;
|
||||
import org.eclipse.swt.widgets.Text;
|
||||
|
||||
/**
|
||||
* SwtActionPanel renders action bar
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 May 13, 2009
|
||||
*/
|
||||
public class SwtActionPanel implements VascEntryFrontendEventListener {
|
||||
|
||||
private static final long serialVersionUID = 3747573488962487970L;
|
||||
private VascEntry entry = null;
|
||||
private Text rowNumberField = null;
|
||||
private Combo pageBox = null;
|
||||
private Combo downloadBox = null;
|
||||
private Label resultLabel = null;
|
||||
private boolean vascEvent = false;
|
||||
|
||||
public SwtActionPanel(VascEntry entry) {
|
||||
this.entry=entry;
|
||||
entry.getVascFrontendData().addVascEntryFrontendEventListener(this);
|
||||
}
|
||||
|
||||
public void createComposite(Composite parent) {
|
||||
Composite actionRow = new Composite(parent, SWT.NONE);
|
||||
GridLayout bodyLayout = new GridLayout();
|
||||
bodyLayout.numColumns = 8;
|
||||
actionRow.setLayout(bodyLayout);
|
||||
actionRow.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
|
||||
//actionRow.setBackground(c);
|
||||
|
||||
Label l = new Label(actionRow, SWT.CENTER);
|
||||
l.setText("Row Numbers");
|
||||
rowNumberField = new Text(actionRow, SWT.NONE | SWT.BORDER);
|
||||
rowNumberField.setText(""+entry.getVascFrontendData().getVascEntryState().getVascBackendState().getPageSize()+" ");
|
||||
rowNumberField.addModifyListener(new ModifyListener() {
|
||||
public void modifyText(ModifyEvent arg0) {
|
||||
if (vascEvent) {
|
||||
return;
|
||||
}
|
||||
int pageSize = new Integer(rowNumberField.getText());
|
||||
entry.getVascFrontendData().getVascEntryState().getVascBackendState().setPageSize(pageSize);
|
||||
entry.getVascFrontendData().getVascFrontendActions().refreshData();
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
l = new Label(actionRow, SWT.CENTER);
|
||||
l.setText("Goto: ");
|
||||
pageBox = new Combo(actionRow,SWT.SINGLE | SWT.BORDER);
|
||||
pageBox.addSelectionListener(new SelectionAdapter() {
|
||||
public void widgetSelected(SelectionEvent e) {
|
||||
entry.getVascFrontendData().getVascFrontendActions().pageAction(pageBox.getSelectionIndex()-1);
|
||||
pageBox.select(0);
|
||||
}
|
||||
});
|
||||
|
||||
l = new Label(actionRow, SWT.CENTER);
|
||||
l.setText("Download: ");
|
||||
downloadBox = new Combo(actionRow,SWT.SINGLE | SWT.BORDER);
|
||||
downloadBox.add("...");
|
||||
for (GlobalVascAction a:entry.getGlobalActions()) {
|
||||
if (a.getId().contains("xport")) {
|
||||
downloadBox.add(a.getName());
|
||||
}
|
||||
}
|
||||
downloadBox.addSelectionListener(new SelectionAdapter() {
|
||||
public void widgetSelected(SelectionEvent e) {
|
||||
|
||||
downloadBox.select(0);
|
||||
}
|
||||
});
|
||||
|
||||
resultLabel = new Label(actionRow, SWT.CENTER);
|
||||
resultLabel.setText("Result......................................");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @see net.forwardfire.vasc.core.entry.VascEntryFrontendEventListener#getEventTypes()
|
||||
*/
|
||||
public VascFrontendEventType[] getEventTypes() {
|
||||
VascFrontendEventType[] result = {VascEntryFrontendEventListener.VascFrontendEventType.POST_READ};
|
||||
return result;
|
||||
}
|
||||
|
||||
public void vascEvent(VascEntry entry,Object dataNotUsed) {
|
||||
vascEvent = true;
|
||||
|
||||
long pageSize = entry.getVascFrontendData().getVascFrontendPager().getPageSize();
|
||||
long pageStart = entry.getVascFrontendData().getVascFrontendPager().getPageStartCount();
|
||||
long pageStop = entry.getVascFrontendData().getVascFrontendPager().getPageStopCount();
|
||||
long pageTotalCount = entry.getVascFrontendData().getVascFrontendPager().getPageTotalRecordCount();
|
||||
String format = "Results %1$d-%2$d from %3$d rows";
|
||||
resultLabel.setText(String.format(format, pageStart, pageStop, pageTotalCount));
|
||||
resultLabel.redraw();
|
||||
rowNumberField.setText(""+pageSize);
|
||||
rowNumberField.redraw();
|
||||
|
||||
pageBox.removeAll();
|
||||
pageBox.add("Goto...");
|
||||
List<VascBackendPageNumber> pages = entry.getVascFrontendData().getVascFrontendPager().getTablePagesFromBackend();
|
||||
int i=0;
|
||||
for (VascBackendPageNumber page:pages) {
|
||||
pageBox.add("page: "+page.getPageNumber()+" "+(i*pageSize)+"-"+((i*pageSize)+pageSize));
|
||||
i++;
|
||||
}
|
||||
|
||||
vascEvent = false;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,82 @@
|
|||
/*
|
||||
* 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.swt;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.forwardfire.vasc.backend.VascBackendPageNumber;
|
||||
import net.forwardfire.vasc.core.VascEntry;
|
||||
import net.forwardfire.vasc.core.actions.GlobalVascAction;
|
||||
import net.forwardfire.vasc.core.entry.VascEntryFrontendEventListener;
|
||||
import net.forwardfire.vasc.core.entry.VascEntryFrontendEventListener.VascFrontendEventType;
|
||||
|
||||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.layout.GridData;
|
||||
import org.eclipse.swt.layout.GridLayout;
|
||||
import org.eclipse.swt.widgets.Combo;
|
||||
import org.eclipse.swt.widgets.Composite;
|
||||
import org.eclipse.swt.widgets.Label;
|
||||
import org.eclipse.swt.widgets.Layout;
|
||||
import org.eclipse.swt.widgets.Text;
|
||||
|
||||
/**
|
||||
* SwtPagerPanel renders pager bar
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 May 13, 2009
|
||||
*/
|
||||
public class SwtPagerPanel implements VascEntryFrontendEventListener {
|
||||
|
||||
private static final long serialVersionUID = 3747573488962487970L;
|
||||
private VascEntry entry = null;
|
||||
|
||||
public SwtPagerPanel(VascEntry entry) {
|
||||
this.entry=entry;
|
||||
entry.getVascFrontendData().addVascEntryFrontendEventListener(this);
|
||||
}
|
||||
|
||||
public void createComposite(Composite parent) {
|
||||
Composite actionRow = new Composite(parent, SWT.NONE);
|
||||
GridLayout bodyLayout = new GridLayout();
|
||||
bodyLayout.numColumns = 1;
|
||||
actionRow.setLayout(bodyLayout);
|
||||
actionRow.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
|
||||
//actionRow.setBackground(c);
|
||||
|
||||
Label l = new Label(actionRow, SWT.CENTER);
|
||||
l.setText("Pagers");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @see net.forwardfire.vasc.core.entry.VascEntryFrontendEventListener#getEventTypes()
|
||||
*/
|
||||
public VascFrontendEventType[] getEventTypes() {
|
||||
VascFrontendEventType[] result = {VascEntryFrontendEventListener.VascFrontendEventType.POST_READ};
|
||||
return result;
|
||||
}
|
||||
|
||||
public void vascEvent(VascEntry entry,Object dataNotUsed) {
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -47,6 +47,7 @@ import org.eclipse.swt.widgets.Shell;
|
|||
|
||||
|
||||
/**
|
||||
* SwtVascEditDialog renders swt edit dialog
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 May 13, 2009
|
||||
|
|
@ -206,7 +207,7 @@ public class SwtVascEditDialog extends Dialog {
|
|||
if (error) {
|
||||
return;
|
||||
}
|
||||
entry.getVascFrontendData().getVascFrontendHelper().mergeObject(entry);
|
||||
entry.getVascFrontendData().getVascFrontendActions().mergeObject();
|
||||
shell.dispose();
|
||||
} catch (Exception ee) {
|
||||
ee.printStackTrace();
|
||||
|
|
|
|||
|
|
@ -27,20 +27,19 @@ import java.io.OutputStream;
|
|||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import net.forwardfire.vasc.core.AbstractVascFrontend;
|
||||
import net.forwardfire.vasc.core.VascEntry;
|
||||
import net.forwardfire.vasc.core.VascEntryField;
|
||||
import net.forwardfire.vasc.core.VascException;
|
||||
import net.forwardfire.vasc.core.VascFrontendData;
|
||||
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.entry.VascEntryFrontendEventListener;
|
||||
import net.forwardfire.vasc.core.entry.VascEntryFrontendEventListener.VascFrontendEventType;
|
||||
import net.forwardfire.vasc.core.ui.VascOptionValueModelListener;
|
||||
import net.forwardfire.vasc.core.ui.VascUIComponent;
|
||||
import net.forwardfire.vasc.core.ui.VascValueModel;
|
||||
import net.forwardfire.vasc.core.ui.VascValueModelListener;
|
||||
import net.forwardfire.vasc.frontend.AbstractVascFrontend;
|
||||
import net.forwardfire.vasc.frontend.VascFrontendData;
|
||||
import net.forwardfire.vasc.frontends.swt.ui.SwtBoolean;
|
||||
import net.forwardfire.vasc.frontends.swt.ui.SwtButton;
|
||||
import net.forwardfire.vasc.frontends.swt.ui.SwtLabel;
|
||||
|
|
@ -86,6 +85,7 @@ import org.eclipse.swt.widgets.ToolItem;
|
|||
|
||||
|
||||
/**
|
||||
* SwtVascFrontend Vasc swt frontend.
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 Mar 21, 2007
|
||||
|
|
@ -95,6 +95,7 @@ public class SwtVascFrontend extends AbstractVascFrontend {
|
|||
private Logger logger = null;
|
||||
private Composite parent = null;
|
||||
private boolean renderGlobalActions = true;
|
||||
private boolean initOnce = false;
|
||||
|
||||
public SwtVascFrontend(Composite parent) {
|
||||
logger = Logger.getLogger(SwtVascFrontend.class.getName());
|
||||
|
|
@ -102,7 +103,7 @@ public class SwtVascFrontend extends AbstractVascFrontend {
|
|||
}
|
||||
|
||||
/**
|
||||
* @see net.forwardfire.vasc.core.VascFrontend#getFrontendType()
|
||||
* @see net.forwardfire.vasc.frontend.VascFrontend#getFrontendType()
|
||||
*/
|
||||
public String getFrontendType() {
|
||||
return "swt";
|
||||
|
|
@ -193,7 +194,7 @@ public class SwtVascFrontend extends AbstractVascFrontend {
|
|||
return;
|
||||
}
|
||||
// yes
|
||||
entry.getVascFrontendData().getVascFrontendHelper().deleteObject(entry);
|
||||
entry.getVascFrontendData().getVascFrontendActions().deleteObject();
|
||||
}
|
||||
|
||||
private boolean askDelete(Shell shell) {
|
||||
|
|
@ -209,6 +210,10 @@ public class SwtVascFrontend extends AbstractVascFrontend {
|
|||
}
|
||||
|
||||
public void renderView() throws Exception {
|
||||
if (initOnce) {
|
||||
return;
|
||||
}
|
||||
|
||||
GridLayout layout = new GridLayout();
|
||||
layout.marginHeight = 0;
|
||||
layout.marginWidth = 0;
|
||||
|
|
@ -235,6 +240,8 @@ public class SwtVascFrontend extends AbstractVascFrontend {
|
|||
createHeader(header);
|
||||
createBody(body);
|
||||
createFooter(footer);
|
||||
|
||||
initOnce = true;
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -325,7 +332,7 @@ public class SwtVascFrontend extends AbstractVascFrontend {
|
|||
model.setValue(null);
|
||||
model.addListener(new VascValueModelListener() {
|
||||
public void valueUpdate(VascValueModel model) throws VascException {
|
||||
entry.getVascFrontendData().getVascFrontendHelper().refreshData(entry);// mm
|
||||
entry.getVascFrontendData().getVascFrontendActions().refreshData();// mm
|
||||
}
|
||||
});
|
||||
Object edit = editor.createComponent(entry,option,model,headerOptions);
|
||||
|
|
@ -351,15 +358,21 @@ public class SwtVascFrontend extends AbstractVascFrontend {
|
|||
public void modifyText(ModifyEvent e) {
|
||||
String value = text.getText();
|
||||
try {
|
||||
entry.getVascFrontendData().getVascFrontendHelper().searchAction(entry, value);
|
||||
entry.getVascFrontendData().getVascFrontendActions().searchAction(value);
|
||||
} catch (Exception ee) {
|
||||
entry.getVascFrontendData().getVascFrontendHelper().handleException(entry,ee);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
SwtPagerPanel pagerBar = new SwtPagerPanel(entry);
|
||||
pagerBar.createComposite(header);
|
||||
|
||||
SwtActionPanel actionBar = new SwtActionPanel(entry);
|
||||
actionBar.createComposite(header);
|
||||
|
||||
entry.getVascFrontendData().getVascFrontendHelper().headerOptionsCreatedFillData(entry);
|
||||
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
|
@ -440,7 +453,7 @@ public class SwtVascFrontend extends AbstractVascFrontend {
|
|||
}
|
||||
table2.setSortDirection(dir);
|
||||
VascEntryField field = (VascEntryField)currentColumn.getData();
|
||||
entry.getVascFrontendData().getVascFrontendHelper().sortAction(entry, field);
|
||||
entry.getVascFrontendData().getVascFrontendActions().sortAction(field);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
@ -529,6 +542,13 @@ public class SwtVascFrontend extends AbstractVascFrontend {
|
|||
|
||||
public void createFooter(Composite footer) {
|
||||
logger.finest("Creating footer");
|
||||
|
||||
SwtActionPanel p = new SwtActionPanel(entry);
|
||||
p.createComposite(footer);
|
||||
|
||||
SwtPagerPanel pagerBar = new SwtPagerPanel(entry);
|
||||
pagerBar.createComposite(footer);
|
||||
|
||||
for( RowVascAction action:entry.getRowActions()) {
|
||||
if (entry.getVascFrontendData().getVascFrontendHelper().renderRowVascAction(action)==false) {
|
||||
continue;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue