diff --git a/org.adempiere.report.jasper.swing/.classpath b/org.adempiere.report.jasper.swing/.classpath deleted file mode 100644 index 423c974870..0000000000 --- a/org.adempiere.report.jasper.swing/.classpath +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - - - diff --git a/org.adempiere.report.jasper.swing/.project b/org.adempiere.report.jasper.swing/.project deleted file mode 100644 index 77b952c3a4..0000000000 --- a/org.adempiere.report.jasper.swing/.project +++ /dev/null @@ -1,39 +0,0 @@ - - - org.adempiere.report.jasper.swing - - - - - - org.eclipse.jdt.core.javabuilder - - - - - org.eclipse.pde.ManifestBuilder - - - - - org.eclipse.pde.SchemaBuilder - - - - - org.eclipse.pde.ds.core.builder - - - - - org.eclipse.m2e.core.maven2Builder - - - - - - org.eclipse.m2e.core.maven2Nature - org.eclipse.pde.PluginNature - org.eclipse.jdt.core.javanature - - diff --git a/org.adempiere.report.jasper.swing/.settings/org.eclipse.core.resources.prefs b/org.adempiere.report.jasper.swing/.settings/org.eclipse.core.resources.prefs deleted file mode 100644 index 99f26c0203..0000000000 --- a/org.adempiere.report.jasper.swing/.settings/org.eclipse.core.resources.prefs +++ /dev/null @@ -1,2 +0,0 @@ -eclipse.preferences.version=1 -encoding/=UTF-8 diff --git a/org.adempiere.report.jasper.swing/.settings/org.eclipse.jdt.core.prefs b/org.adempiere.report.jasper.swing/.settings/org.eclipse.jdt.core.prefs deleted file mode 100644 index b5eacefd65..0000000000 --- a/org.adempiere.report.jasper.swing/.settings/org.eclipse.jdt.core.prefs +++ /dev/null @@ -1,8 +0,0 @@ -eclipse.preferences.version=1 -org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled -org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate -org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve -org.eclipse.jdt.core.compiler.debug.lineNumber=generate -org.eclipse.jdt.core.compiler.debug.localVariable=generate -org.eclipse.jdt.core.compiler.debug.sourceFile=generate -org.eclipse.jdt.core.compiler.release=enabled diff --git a/org.adempiere.report.jasper.swing/.settings/org.eclipse.m2e.core.prefs b/org.adempiere.report.jasper.swing/.settings/org.eclipse.m2e.core.prefs deleted file mode 100644 index f897a7f1cb..0000000000 --- a/org.adempiere.report.jasper.swing/.settings/org.eclipse.m2e.core.prefs +++ /dev/null @@ -1,4 +0,0 @@ -activeProfiles= -eclipse.preferences.version=1 -resolveWorkspaceProjects=true -version=1 diff --git a/org.adempiere.report.jasper.swing/.settings/org.eclipse.pde.core.prefs b/org.adempiere.report.jasper.swing/.settings/org.eclipse.pde.core.prefs deleted file mode 100644 index 0f8fd9b2cd..0000000000 --- a/org.adempiere.report.jasper.swing/.settings/org.eclipse.pde.core.prefs +++ /dev/null @@ -1,4 +0,0 @@ -#Mon Aug 23 13:20:48 MYT 2010 -eclipse.preferences.version=1 -pluginProject.extensions=true -resolve.requirebundle=false diff --git a/org.adempiere.report.jasper.swing/META-INF/MANIFEST.MF b/org.adempiere.report.jasper.swing/META-INF/MANIFEST.MF deleted file mode 100644 index 90c0c4dbaf..0000000000 --- a/org.adempiere.report.jasper.swing/META-INF/MANIFEST.MF +++ /dev/null @@ -1,21 +0,0 @@ -Manifest-Version: 1.0 -Bundle-ManifestVersion: 2 -Bundle-Name: JasperReports Swing Client -Bundle-SymbolicName: org.adempiere.report.jasper.swing;singleton:=true -Bundle-Version: 7.1.0.qualifier -Bundle-RequiredExecutionEnvironment: JavaSE-11 -Require-Capability: osgi.ee;filter:="(&(osgi.ee=JavaSE)(version>=11))" -Require-Bundle: org.adempiere.base;bundle-version="0.0.0", - org.adempiere.ui.swing;bundle-version="0.0.0", - org.adempiere.report.jasper;bundle-version="0.0.0" -Import-Package: net.sf.jasperreports.engine, - net.sf.jasperreports.engine.export, - net.sf.jasperreports.swing, - net.sf.jasperreports.view, - org.adempiere.report.jasper, - org.osgi.framework -Service-Component: OSGI-INF/*.xml -Bundle-ActivationPolicy: lazy -Bundle-ClassPath: . -Automatic-Module-Name: org.adempiere.report.jasper.swing -Bundle-Vendor: iDempiere Community diff --git a/org.adempiere.report.jasper.swing/OSGI-INF/jrviewerprovider.xml b/org.adempiere.report.jasper.swing/OSGI-INF/jrviewerprovider.xml deleted file mode 100644 index 1e7305e452..0000000000 --- a/org.adempiere.report.jasper.swing/OSGI-INF/jrviewerprovider.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - diff --git a/org.adempiere.report.jasper.swing/build.properties b/org.adempiere.report.jasper.swing/build.properties deleted file mode 100644 index 9741b55bc5..0000000000 --- a/org.adempiere.report.jasper.swing/build.properties +++ /dev/null @@ -1,6 +0,0 @@ -bin.includes = META-INF/,\ - OSGI-INF/jrviewerprovider.xml,\ - OSGI-INF/,\ - . -output.. = target/classes/ -source.. = src/ diff --git a/org.adempiere.report.jasper.swing/pom.xml b/org.adempiere.report.jasper.swing/pom.xml deleted file mode 100644 index 2a8404c590..0000000000 --- a/org.adempiere.report.jasper.swing/pom.xml +++ /dev/null @@ -1,12 +0,0 @@ - - 4.0.0 - - org.idempiere - org.idempiere.parent - 7.1.0-SNAPSHOT - ../org.idempiere.parent/pom.xml - - org.adempiere.report.jasper.swing - eclipse-plugin - \ No newline at end of file diff --git a/org.adempiere.report.jasper.swing/src/org/compiere/report/JasperReportViewer.java b/org.adempiere.report.jasper.swing/src/org/compiere/report/JasperReportViewer.java deleted file mode 100644 index 56f4202bdd..0000000000 --- a/org.adempiere.report.jasper.swing/src/org/compiere/report/JasperReportViewer.java +++ /dev/null @@ -1,172 +0,0 @@ -/* - * Class JRViewer. - */ -package org.compiere.report; - -import java.awt.Graphics2D; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.io.File; -import java.util.logging.Level; - -import javax.swing.JButton; -import javax.swing.JComboBox; -import javax.swing.JFileChooser; -import javax.swing.JFrame; -import javax.swing.JSeparator; -import javax.swing.SwingConstants; - -import net.sf.jasperreports.engine.JRException; -import net.sf.jasperreports.engine.JRExporterParameter; -import net.sf.jasperreports.engine.JasperExportManager; -import net.sf.jasperreports.engine.JasperPrint; -import net.sf.jasperreports.engine.JasperReport; -import net.sf.jasperreports.engine.export.JRXlsExporter; -import net.sf.jasperreports.swing.JRViewer; - -import org.compiere.apps.EMailDialog; -import org.compiere.model.MUser; -import org.compiere.tools.FileUtil; -import org.compiere.util.CLogger; -import org.compiere.util.Env; -import org.compiere.util.Msg; - -public class JasperReportViewer extends JRViewer { - - private static final long serialVersionUID = -7988455595896562947L; - - /** Logger */ - @SuppressWarnings("unused") - private static CLogger log = CLogger.getCLogger(JasperReportViewer.class); - - @SuppressWarnings("unused") - private JasperViewer jasperViewer; - private JasperPrint jasperPrint; - private JComboBox comboBox; - - public JasperReportViewer(final JasperViewer jasperViewer, final JasperPrint jasperPrint) throws JRException { - super( jasperPrint); - this.jasperViewer = jasperViewer; - this.jasperPrint = jasperPrint; - - tlbToolBar.add(new JSeparator(SwingConstants.VERTICAL)); - JButton btnSendByEmail = new JButton(); - btnSendByEmail.setToolTipText(Msg.getMsg(Env.getCtx(), "SendMail")); - btnSendByEmail.setText(Msg.getMsg(Env.getCtx(), "SendMail")); - btnSendByEmail.setPreferredSize(new java.awt.Dimension(85, 23)); - btnSendByEmail.setMaximumSize(new java.awt.Dimension(85, 23)); - btnSendByEmail.setMinimumSize(new java.awt.Dimension(85, 23)); - btnSendByEmail.addActionListener( new SendByEmailListener(jasperViewer, this)); - tlbToolBar.add(btnSendByEmail); - tlbToolBar.add(new JSeparator(SwingConstants.VERTICAL)); - - JButton btnExport = new JButton(); - btnExport.setToolTipText(Msg.getMsg(Env.getCtx(), "Export")); - btnExport.setText(Msg.getMsg(Env.getCtx(), "Export")); - btnExport.setPreferredSize(new java.awt.Dimension(85, 23)); - btnExport.setMaximumSize(new java.awt.Dimension(85, 23)); - btnExport.setMinimumSize(new java.awt.Dimension(85, 23)); - btnExport.addActionListener( new ExportListener( this)); - tlbToolBar.add(btnExport); - - comboBox = new JComboBox( new String[] {"PDF","HTML", "XLS"}); - comboBox.setPreferredSize(new java.awt.Dimension(80, 23)); - comboBox.setMaximumSize(new java.awt.Dimension(80, 23)); - comboBox.setMinimumSize(new java.awt.Dimension(80, 23)); - tlbToolBar.add(comboBox); - - // Set default viewer zoom level - //btnFitPage.setSelected(true); - //setZooms(); - } - - public JasperPrint getJasperPrint() { - return jasperPrint; - } - - public String getFormat() { - return (String) comboBox.getSelectedItem(); - } - - - //@Override - protected void paintPage(Graphics2D grx) { - ClassLoader cl = Thread.currentThread().getContextClassLoader(); - try { - Thread.currentThread().setContextClassLoader(JasperReport.class.getClassLoader()); - //super.paintPage(grx); - } finally { - Thread.currentThread().setContextClassLoader(cl); - } - } - - - -} - -class ExportListener implements ActionListener { - private JasperReportViewer viewer; - - public ExportListener(JasperReportViewer viewer) { - this.viewer = viewer; - } - - public void actionPerformed(ActionEvent event) { - JFileChooser fileChooser = new JFileChooser(); - fileChooser.setSelectedFile(new File(viewer.getJasperPrint().getName() + - "." + viewer.getFormat().toLowerCase())); - if (fileChooser.showSaveDialog( viewer)==JFileChooser.APPROVE_OPTION) { - File file = fileChooser.getSelectedFile(); - try { - if (viewer.getFormat().equals("PDF")) { - JasperExportManager.exportReportToPdfFile( viewer.getJasperPrint(), file.getAbsolutePath()); - } else if (viewer.getFormat().equals("HTML")) { - JasperExportManager.exportReportToHtmlFile( viewer.getJasperPrint(), file.getAbsolutePath()); - } else if (viewer.getFormat().equals("XLS")) { - JRXlsExporter exporter = new net.sf.jasperreports.engine.export.JRXlsExporter(); - exporter.setParameter(JRExporterParameter.OUTPUT_FILE_NAME, file.getAbsolutePath()); - exporter.setParameter(JRExporterParameter.JASPER_PRINT, viewer.getJasperPrint()); - exporter.exportReport(); - } - } catch (JRException e) { - e.printStackTrace(); - } - } - } -} - -class SendByEmailListener implements ActionListener { - /** Logger */ - private static CLogger log = CLogger.getCLogger(SendByEmailListener.class); - - private JasperViewer jasperViewer; - private JasperReportViewer viewer; - - public SendByEmailListener(JasperViewer jasperViewer, JasperReportViewer viewer) { - this.jasperViewer = jasperViewer; - this.viewer = viewer; - } - - public void actionPerformed(ActionEvent event) { - String to = ""; - MUser from = MUser.get(Env.getCtx(), Env.getAD_User_ID(Env.getCtx())); - String subject = viewer.getJasperPrint().getName(); - String message = ""; - File attachment = null; - - try - { - attachment = new File(FileUtil.getTempMailName(subject, ".pdf")); - JasperExportManager.exportReportToPdfFile(viewer.getJasperPrint(), attachment.getAbsolutePath()); - } - catch (Exception e) - { - log.log(Level.SEVERE, "", e); - } - - @SuppressWarnings("unused") - EMailDialog emd = new EMailDialog ((JFrame)jasperViewer, - Msg.getMsg(Env.getCtx(), "SendMail"), - from, to, subject, message, attachment); - } -} diff --git a/org.adempiere.report.jasper.swing/src/org/compiere/report/JasperReportsClientActivator.java b/org.adempiere.report.jasper.swing/src/org/compiere/report/JasperReportsClientActivator.java deleted file mode 100644 index 434a3cda50..0000000000 --- a/org.adempiere.report.jasper.swing/src/org/compiere/report/JasperReportsClientActivator.java +++ /dev/null @@ -1,30 +0,0 @@ -/** - * - */ -package org.compiere.report; - -import org.osgi.framework.BundleActivator; -import org.osgi.framework.BundleContext; - -/** - * @author hengsin - * - */ -public class JasperReportsClientActivator implements BundleActivator { - - /** - * default constructor - */ - public JasperReportsClientActivator() { - super(); - } - - @Override - public void start(BundleContext arg0) throws Exception { - } - - @Override - public void stop(BundleContext arg0) throws Exception { - } - -} diff --git a/org.adempiere.report.jasper.swing/src/org/compiere/report/JasperViewer.java b/org.adempiere.report.jasper.swing/src/org/compiere/report/JasperViewer.java deleted file mode 100644 index 9ff7892c35..0000000000 --- a/org.adempiere.report.jasper.swing/src/org/compiere/report/JasperViewer.java +++ /dev/null @@ -1,144 +0,0 @@ -/* - * Class JasperViewer. - */ -package org.compiere.report; - -import java.awt.BorderLayout; -import java.awt.event.KeyAdapter; -import java.awt.event.KeyEvent; -import java.sql.Connection; -import java.sql.DriverManager; -import java.sql.SQLException; -import java.util.HashMap; - -import net.sf.jasperreports.engine.JRException; -import net.sf.jasperreports.engine.JasperCompileManager; -import net.sf.jasperreports.engine.JasperFillManager; -import net.sf.jasperreports.engine.JasperPrint; -import net.sf.jasperreports.engine.JasperReport; - -import org.compiere.db.CConnection; -import org.compiere.model.PrintInfo; - -public class JasperViewer extends javax.swing.JFrame { - - private static final long serialVersionUID = 1192807883081180999L; - - private String m_title; - private PrintInfo m_printInfo; - - /** Creates new form JasperViewer */ - /** - * @param jasperPrint report to display - * @param frameTitle Title to be displayed - * @throws JRException - */ - protected JasperViewer(JasperPrint jasperPrint,String frameTitle, PrintInfo printInfo) throws JRException { - this.m_title = frameTitle; - initComponents(); - JasperReportViewer viewer = new JasperReportViewer(this, jasperPrint); - this.pnlMain.add(viewer, BorderLayout.CENTER); - m_printInfo = printInfo; - } - - - /** This method is called from within the constructor to - * initialize the form. - * WARNING: Do NOT modify this code. The content of this method is - * always regenerated by the Form Editor. - */ - private void initComponents()//GEN-BEGIN:initComponents - { - pnlMain = new javax.swing.JPanel(); - - setTitle(m_title); - addWindowListener(new java.awt.event.WindowAdapter() { - public void windowClosing(java.awt.event.WindowEvent evt) { - exitForm(); - } - }); - addKeyListener( new KeyAdapter() { - public void keyPressed(KeyEvent event) { - if (event.getKeyCode() == KeyEvent.VK_ESCAPE) exitForm(); - } - - public void keyTyped(KeyEvent event) { - super.keyTyped(event); - } - }); - - pnlMain.setLayout(new java.awt.BorderLayout()); - - getContentPane().add(pnlMain, java.awt.BorderLayout.CENTER); - - pack(); - java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize(); - setSize(new java.awt.Dimension(750, 550)); - setLocation((screenSize.width - 750) / 2, (screenSize.height - 550) / 2); - }//GEN-END:initComponents - - /** Exit the Application */ - private void exitForm() {//GEN-FIRST:event_exitForm - setVisible(false); - dispose(); - }//GEN-LAST:event_exitForm - - - /** - * - */ - public static void viewReport(JasperPrint jasperPrint, PrintInfo printInfo) throws JRException { - JasperViewer jasperViewer = new JasperViewer(jasperPrint,"JasperReport", printInfo); - jasperViewer.setVisible(true); - } - public static void viewReport(JasperPrint jasperPrint,String frameTitle, PrintInfo printInfo) throws JRException { - JasperViewer jasperViewer = new JasperViewer(jasperPrint,frameTitle, printInfo); - jasperViewer.setVisible(true); - } - - // Variables declaration - do not modify//GEN-BEGIN:variables - private javax.swing.JPanel pnlMain; - // End of variables declaration//GEN-END:variables - - /** - * @param args the command line arguments - */ - public static void main(String args[]) { - try { - JasperReport myjasperReport = (JasperReport) JasperCompileManager.compileReport(args[0] ); - JasperPrint myjasperPrint = JasperFillManager.fillReport( myjasperReport, new HashMap(), getConnection()); - JasperViewer.viewReport(myjasperPrint, null); - } - catch (Exception e) { - e.printStackTrace(); - } - } - - public static Connection getConnection(String args[]) - { - CConnection compiereConnection = CConnection.get(); - - try { - DriverManager.registerDriver(compiereConnection.getDatabase().getDriver()); - - //this is for test only - return DriverManager.getConnection(args[1], args[2], args[3]); - } catch (SQLException e) { - e.printStackTrace(); - return null; - } - } - - public static Connection getConnection() { - CConnection compiereConnection = CConnection.get(); - try { - DriverManager.registerDriver(compiereConnection.getDatabase().getDriver()); - //this is for test only prefer testingby calling org.compiere.report.JaserViewer JDBC_CONNECTION JDBC_USER JDBC_PASS - return DriverManager.getConnection("jdbc:oracle:thin:@abalone.lesmuids.com:1521:abalone", "adempiere", "adempiere"); - } catch (SQLException e) { - e.printStackTrace(); - return null; - } - } - -} diff --git a/org.adempiere.report.jasper.swing/src/org/compiere/report/SwingJRViewerProvider.java b/org.adempiere.report.jasper.swing/src/org/compiere/report/SwingJRViewerProvider.java deleted file mode 100644 index 2d0a4820d2..0000000000 --- a/org.adempiere.report.jasper.swing/src/org/compiere/report/SwingJRViewerProvider.java +++ /dev/null @@ -1,17 +0,0 @@ -package org.compiere.report; - -import org.adempiere.report.jasper.JRViewerProvider; -import org.compiere.model.PrintInfo; - -import net.sf.jasperreports.engine.JRException; -import net.sf.jasperreports.engine.JasperPrint; - -public class SwingJRViewerProvider implements JRViewerProvider { - - public void openViewer(JasperPrint jasperPrint, String title, PrintInfo printInfo) throws JRException { - JasperViewer jasperViewer = new JasperViewer( jasperPrint, title, printInfo); - jasperViewer.setExtendedState(jasperViewer.getExtendedState() | javax.swing.JFrame.MAXIMIZED_BOTH); - jasperViewer.setVisible(true); - } - -} diff --git a/org.adempiere.ui.swing-feature/.project b/org.adempiere.ui.swing-feature/.project deleted file mode 100644 index 880abdd4ce..0000000000 --- a/org.adempiere.ui.swing-feature/.project +++ /dev/null @@ -1,23 +0,0 @@ - - - org.adempiere.ui.swing-feature - - - - - - org.eclipse.pde.FeatureBuilder - - - - - org.eclipse.m2e.core.maven2Builder - - - - - - org.eclipse.m2e.core.maven2Nature - org.eclipse.pde.FeatureNature - - diff --git a/org.adempiere.ui.swing-feature/.settings/org.eclipse.core.resources.prefs b/org.adempiere.ui.swing-feature/.settings/org.eclipse.core.resources.prefs deleted file mode 100644 index 99f26c0203..0000000000 --- a/org.adempiere.ui.swing-feature/.settings/org.eclipse.core.resources.prefs +++ /dev/null @@ -1,2 +0,0 @@ -eclipse.preferences.version=1 -encoding/=UTF-8 diff --git a/org.adempiere.ui.swing-feature/.settings/org.eclipse.m2e.core.prefs b/org.adempiere.ui.swing-feature/.settings/org.eclipse.m2e.core.prefs deleted file mode 100644 index f897a7f1cb..0000000000 --- a/org.adempiere.ui.swing-feature/.settings/org.eclipse.m2e.core.prefs +++ /dev/null @@ -1,4 +0,0 @@ -activeProfiles= -eclipse.preferences.version=1 -resolveWorkspaceProjects=true -version=1 diff --git a/org.adempiere.ui.swing-feature/adempiere-client.bat b/org.adempiere.ui.swing-feature/adempiere-client.bat deleted file mode 100644 index 7dcda7188f..0000000000 --- a/org.adempiere.ui.swing-feature/adempiere-client.bat +++ /dev/null @@ -1,20 +0,0 @@ -@Echo off - - -@if not "%JAVA_HOME%" == "" goto JAVA_HOME_OK -@Set JAVA=java -@Echo JAVA_HOME is not set. -@Echo You may not be able to start the server -@Echo Set JAVA_HOME to the directory of your local 1.6 JDK. -goto START - -:JAVA_HOME_OK -@Set JAVA=%JAVA_HOME%\bin\java - - -:START -@Echo ======================================= -@Echo Starting Adempiere Client ... -@Echo ======================================= - -@"%JAVA%" -Dosgi.noShutdown=true -Dosgi.framework.activeThreadType=normal -Dosgi.compatibility.bootdelegation=true -XX:MaxPermSize=192m -jar plugins/org.eclipse.equinox.launcher_1.*.jar -application org.adempiere.ui.swing.client diff --git a/org.adempiere.ui.swing-feature/adempiere-client.sh b/org.adempiere.ui.swing-feature/adempiere-client.sh deleted file mode 100644 index 7d67eb2586..0000000000 --- a/org.adempiere.ui.swing-feature/adempiere-client.sh +++ /dev/null @@ -1,20 +0,0 @@ -#!/bin/sh -# -# script parameters are used as VM args. e.g.: -# ./adempiere-client.sh -DPropertyFile=/home/tbayen/idempiere-conf2.properties -# -- tbayen - -if [ $JAVA_HOME ]; then - JAVA=$JAVA_HOME/bin/java -else - JAVA=java - echo JAVA_HOME is not set. - echo You may not be able to start the server - echo Set JAVA_HOME to the directory of your local JDK. -fi - -echo =================================== -echo Starting Adempiere Client -echo =================================== - -$JAVA -Dosgi.noShutdown=true -Dosgi.framework.activeThreadType=normal -Dosgi.compatibility.bootdelegation=true $@ -XX:MaxPermSize=192m -jar plugins/org.eclipse.equinox.launcher_1.*.jar -application org.adempiere.ui.swing.client diff --git a/org.adempiere.ui.swing-feature/build.properties b/org.adempiere.ui.swing-feature/build.properties deleted file mode 100644 index 88c0d7fb8d..0000000000 --- a/org.adempiere.ui.swing-feature/build.properties +++ /dev/null @@ -1,10 +0,0 @@ -bin.includes = feature.xml -root.linux.gtk.x86=file:adempiere-client.sh -root.linux.gtk.x86.permissions.755=*.sh,**/*.sh -root.linux.gtk.x86_64=file:adempiere-client.sh -root.linux.gtk.x86_64.permissions.755=*.sh,**/*.sh -root.macosx.cocoa.x86=file:adempiere-client.sh -root.macosx.cocoa.x86.permissions.755=*.sh,**/*.sh -root.win32.win32.x86=file:adempiere-client.bat -root.solaris.gtk.x86=file:adempiere-client.sh -root.solaris.gtk.x86.permissions.755=*.sh,**/*.sh \ No newline at end of file diff --git a/org.adempiere.ui.swing-feature/feature.xml b/org.adempiere.ui.swing-feature/feature.xml deleted file mode 100644 index d06a8d0983..0000000000 --- a/org.adempiere.ui.swing-feature/feature.xml +++ /dev/null @@ -1,44 +0,0 @@ - - - - - [Enter Feature Description here.] - - - - [Enter Copyright Description here.] - - - - [Enter License Description here.] - - - - - - - - - - - - - diff --git a/org.adempiere.ui.swing-feature/pom.xml b/org.adempiere.ui.swing-feature/pom.xml deleted file mode 100644 index 2608546450..0000000000 --- a/org.adempiere.ui.swing-feature/pom.xml +++ /dev/null @@ -1,12 +0,0 @@ - - 4.0.0 - - org.idempiere - org.idempiere.parent - 7.1.0-SNAPSHOT - ../org.idempiere.parent/pom.xml - - org.adempiere.ui.swing.feature - eclipse-feature - \ No newline at end of file diff --git a/org.adempiere.ui.swing-feature/swingclient.product b/org.adempiere.ui.swing-feature/swingclient.product deleted file mode 100644 index 1acf5c3489..0000000000 --- a/org.adempiere.ui.swing-feature/swingclient.product +++ /dev/null @@ -1,47 +0,0 @@ - - - - - - - - - - --launcher.XXMaxPermSize 192m - - -Dosgi.noShutdown=true -Dosgi.framework.activeThreadType=normal -Dosgi.compatibility.bootdelegation=true - - -XstartOnFirstThread -Dorg.eclipse.swt.internal.carbon.smallFonts - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/org.adempiere.ui.swing-feature/swingclient.product.launch b/org.adempiere.ui.swing-feature/swingclient.product.launch deleted file mode 100644 index cb6b9cfd31..0000000000 --- a/org.adempiere.ui.swing-feature/swingclient.product.launch +++ /dev/null @@ -1,421 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/org.adempiere.ui.swing.pluginlist/.classpath b/org.adempiere.ui.swing.pluginlist/.classpath deleted file mode 100644 index 1fa3e6803d..0000000000 --- a/org.adempiere.ui.swing.pluginlist/.classpath +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - diff --git a/org.adempiere.ui.swing.pluginlist/.project b/org.adempiere.ui.swing.pluginlist/.project deleted file mode 100644 index 4daab55d00..0000000000 --- a/org.adempiere.ui.swing.pluginlist/.project +++ /dev/null @@ -1,28 +0,0 @@ - - - org.adempiere.ui.swing.pluginlist - - - - - - org.eclipse.jdt.core.javabuilder - - - - - org.eclipse.pde.ManifestBuilder - - - - - org.eclipse.pde.SchemaBuilder - - - - - - org.eclipse.pde.PluginNature - org.eclipse.jdt.core.javanature - - diff --git a/org.adempiere.ui.swing.pluginlist/.settings/org.eclipse.pde.core.prefs b/org.adempiere.ui.swing.pluginlist/.settings/org.eclipse.pde.core.prefs deleted file mode 100644 index b83250f900..0000000000 --- a/org.adempiere.ui.swing.pluginlist/.settings/org.eclipse.pde.core.prefs +++ /dev/null @@ -1,4 +0,0 @@ -#Wed Mar 17 17:21:50 CET 2010 -eclipse.preferences.version=1 -pluginProject.extensions=true -resolve.requirebundle=false diff --git a/org.adempiere.ui.swing.pluginlist/META-INF/MANIFEST.MF b/org.adempiere.ui.swing.pluginlist/META-INF/MANIFEST.MF deleted file mode 100644 index b6fc150e76..0000000000 --- a/org.adempiere.ui.swing.pluginlist/META-INF/MANIFEST.MF +++ /dev/null @@ -1,13 +0,0 @@ -Manifest-Version: 1.0 -Bundle-ManifestVersion: 2 -Bundle-Name: PluginList -Bundle-SymbolicName: org.adempiere.ui.swing.pluginlist;singleton:=true -Bundle-Version: 1.0.0.qualifier -Bundle-Activator: org.adempiere.plugin.list.Activator -Bundle-ActivationPolicy: lazy -Bundle-RequiredExecutionEnvironment: JavaSE-1.8 -Eclipse-LazyStart: true -Import-Package: org.osgi.framework;version="1.3.0" -Require-Bundle: org.adempiere.base;bundle-version="0.0.0", - org.adempiere.ui.swing;bundle-version="0.0.0", - org.adempiere.plugin.utils;bundle-version="0.0.0" diff --git a/org.adempiere.ui.swing.pluginlist/META-INF/PackOut.xml b/org.adempiere.ui.swing.pluginlist/META-INF/PackOut.xml deleted file mode 100644 index 333bcac9c3..0000000000 --- a/org.adempiere.ui.swing.pluginlist/META-INF/PackOut.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - -
-
-
diff --git a/org.adempiere.ui.swing.pluginlist/build.properties b/org.adempiere.ui.swing.pluginlist/build.properties deleted file mode 100644 index e9863e281e..0000000000 --- a/org.adempiere.ui.swing.pluginlist/build.properties +++ /dev/null @@ -1,5 +0,0 @@ -source.. = src/ -output.. = bin/ -bin.includes = META-INF/,\ - .,\ - plugin.xml diff --git a/org.adempiere.ui.swing.pluginlist/plugin.xml b/org.adempiere.ui.swing.pluginlist/plugin.xml deleted file mode 100644 index 1393adbd45..0000000000 --- a/org.adempiere.ui.swing.pluginlist/plugin.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - diff --git a/org.adempiere.ui.swing.pluginlist/src/org/adempiere/plugin/list/Activator.java b/org.adempiere.ui.swing.pluginlist/src/org/adempiere/plugin/list/Activator.java deleted file mode 100644 index 0ccbe00ba0..0000000000 --- a/org.adempiere.ui.swing.pluginlist/src/org/adempiere/plugin/list/Activator.java +++ /dev/null @@ -1,19 +0,0 @@ -package org.adempiere.plugin.list; - -import org.adempiere.plugin.utils.AdempiereActivator; -import org.osgi.framework.BundleActivator; -import org.osgi.framework.BundleContext; - -public class Activator extends AdempiereActivator implements BundleActivator { - - static private BundleContext ctx; - - @Override - public void start() { - ctx = getContext(); - } - - public static BundleContext getPluginContext() { - return ctx; - } -} diff --git a/org.adempiere.ui.swing.pluginlist/src/org/adempiere/plugin/list/PluginList.java b/org.adempiere.ui.swing.pluginlist/src/org/adempiere/plugin/list/PluginList.java deleted file mode 100644 index 65edec6c9f..0000000000 --- a/org.adempiere.ui.swing.pluginlist/src/org/adempiere/plugin/list/PluginList.java +++ /dev/null @@ -1,141 +0,0 @@ -package org.adempiere.plugin.list; - -import java.awt.BorderLayout; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.util.Vector; -import java.util.logging.Level; - -import javax.swing.JButton; -import javax.swing.JScrollPane; -import javax.swing.table.DefaultTableModel; - -import org.compiere.apps.form.FormFrame; -import org.compiere.apps.form.FormPanel; -import org.compiere.minigrid.MiniTable; -import org.compiere.swing.CPanel; -import org.compiere.util.CLogger; -import org.osgi.framework.Bundle; -import org.osgi.framework.BundleContext; -import org.osgi.framework.BundleException; - -public class PluginList implements FormPanel, ActionListener { - - private static CLogger log = CLogger.getCLogger(PluginList.class); - @SuppressWarnings("unused") - private int m_WindowNo; - private FormFrame m_frame; - private CPanel northPanel = new CPanel(); - private CPanel centerPanel = new CPanel(); - private CPanel confirmPanel = new CPanel(); - private MiniTable pluginTable = new MiniTable(); - private JScrollPane centerScrollPane = new JScrollPane(); - private JButton refreshButton = new JButton(); - - @Override - public void dispose() { - if (m_frame != null) - m_frame.dispose(); - m_frame = null; - } - - @Override - public void init(int WindowNo, FormFrame frame) { - log.info(""); - m_WindowNo = WindowNo; - m_frame = frame; - try - { - jbInit(); - frame.getContentPane().add(northPanel, BorderLayout.NORTH); - frame.getContentPane().add(centerPanel, BorderLayout.CENTER); - frame.getContentPane().add(confirmPanel, BorderLayout.SOUTH); - } - catch(Exception e) - { - log.log(Level.SEVERE, "init", e); - } - } - - private void jbInit() { - centerPanel.add(centerScrollPane, BorderLayout.CENTER); - centerScrollPane.getViewport().add(pluginTable, null); - updatePlugins(); - - refreshButton.setText("Refresh"); - refreshButton.addActionListener(this); - confirmPanel.add(refreshButton); - } - - private void updatePlugins() { - DefaultTableModel dataModel = new DefaultTableModel(getData(), getColumnNames()); - pluginTable.setModel(dataModel); - pluginTable.autoSize(); - } - - private Vector> getData() { - BundleContext ctx = getContext(); - Vector> result = new Vector>(); - for (Bundle bundle : ctx.getBundles()) { - Vector col = new Vector(); - col.add(bundle.getBundleId()); - col.add(state(bundle.getState())); - col.add(bundle.getSymbolicName()); - col.add(bundle.getVersion()); - result.add(col); - } - return result; - } - - private BundleContext getContext() { - return Activator.getPluginContext(); - } - - private String state(int state) { - switch (state) { - case Bundle.ACTIVE: - return "ACTIVE"; - case Bundle.INSTALLED: - return "INSTALLED"; - case Bundle.RESOLVED: - return "RESOLVED"; - case Bundle.STARTING: - return "STARTING"; - case Bundle.STOPPING: - return "STOPPING"; - case Bundle.UNINSTALLED: - return "UNINSTALLED"; - default: - return "UNKNOWN"; - } - } - - private Vector getColumnNames() { - Vector result = new Vector(); - result.add("Id"); - result.add("State"); - result.add("Name"); - result.add("Version"); - return result; - } - - @Override - public void actionPerformed(ActionEvent e) { - if (e.getSource().equals(refreshButton)) - refreshClicked(e); - } - - private void refreshClicked(ActionEvent e) { - int row = pluginTable.getSelectedRow(); - if (row==-1) - return; - long id = (Long) pluginTable.getValueAt(row, 0); - Bundle bundle = getContext().getBundle(id); - try { - bundle.update(); - } catch (BundleException ex) { - log.log(Level.SEVERE, "refresh", ex); - } - } - -} diff --git a/org.adempiere.ui.swing/.classpath b/org.adempiere.ui.swing/.classpath deleted file mode 100644 index 83e1df1e99..0000000000 --- a/org.adempiere.ui.swing/.classpath +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - - - - - - - - - - - diff --git a/org.adempiere.ui.swing/.project b/org.adempiere.ui.swing/.project deleted file mode 100644 index 75bed072bd..0000000000 --- a/org.adempiere.ui.swing/.project +++ /dev/null @@ -1,34 +0,0 @@ - - - org.adempiere.ui.swing - - - - - - org.eclipse.jdt.core.javabuilder - - - - - org.eclipse.pde.ManifestBuilder - - - - - org.eclipse.pde.SchemaBuilder - - - - - org.eclipse.m2e.core.maven2Builder - - - - - - org.eclipse.m2e.core.maven2Nature - org.eclipse.pde.PluginNature - org.eclipse.jdt.core.javanature - - diff --git a/org.adempiere.ui.swing/.settings/org.eclipse.core.resources.prefs b/org.adempiere.ui.swing/.settings/org.eclipse.core.resources.prefs deleted file mode 100644 index 99f26c0203..0000000000 --- a/org.adempiere.ui.swing/.settings/org.eclipse.core.resources.prefs +++ /dev/null @@ -1,2 +0,0 @@ -eclipse.preferences.version=1 -encoding/=UTF-8 diff --git a/org.adempiere.ui.swing/.settings/org.eclipse.jdt.core.prefs b/org.adempiere.ui.swing/.settings/org.eclipse.jdt.core.prefs deleted file mode 100644 index 05b5a63067..0000000000 --- a/org.adempiere.ui.swing/.settings/org.eclipse.jdt.core.prefs +++ /dev/null @@ -1,102 +0,0 @@ -eclipse.preferences.version=1 -org.eclipse.jdt.core.compiler.annotation.inheritNullAnnotations=disabled -org.eclipse.jdt.core.compiler.annotation.missingNonNullByDefaultAnnotation=ignore -org.eclipse.jdt.core.compiler.annotation.nonnull=org.eclipse.jdt.annotation.NonNull -org.eclipse.jdt.core.compiler.annotation.nonnull.secondary= -org.eclipse.jdt.core.compiler.annotation.nonnullbydefault=org.eclipse.jdt.annotation.NonNullByDefault -org.eclipse.jdt.core.compiler.annotation.nonnullbydefault.secondary= -org.eclipse.jdt.core.compiler.annotation.nullable=org.eclipse.jdt.annotation.Nullable -org.eclipse.jdt.core.compiler.annotation.nullable.secondary= -org.eclipse.jdt.core.compiler.annotation.nullanalysis=disabled -org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled -org.eclipse.jdt.core.compiler.problem.APILeak=warning -org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning -org.eclipse.jdt.core.compiler.problem.autoboxing=ignore -org.eclipse.jdt.core.compiler.problem.comparingIdentical=warning -org.eclipse.jdt.core.compiler.problem.deadCode=warning -org.eclipse.jdt.core.compiler.problem.deprecation=warning -org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled -org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled -org.eclipse.jdt.core.compiler.problem.discouragedReference=warning -org.eclipse.jdt.core.compiler.problem.emptyStatement=ignore -org.eclipse.jdt.core.compiler.problem.explicitlyClosedAutoCloseable=ignore -org.eclipse.jdt.core.compiler.problem.fallthroughCase=ignore -org.eclipse.jdt.core.compiler.problem.fatalOptionalError=disabled -org.eclipse.jdt.core.compiler.problem.fieldHiding=ignore -org.eclipse.jdt.core.compiler.problem.finalParameterBound=warning -org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning -org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning -org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning -org.eclipse.jdt.core.compiler.problem.includeNullInfoFromAsserts=disabled -org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning -org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=warning -org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=ignore -org.eclipse.jdt.core.compiler.problem.localVariableHiding=ignore -org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning -org.eclipse.jdt.core.compiler.problem.missingDefaultCase=ignore -org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=ignore -org.eclipse.jdt.core.compiler.problem.missingEnumCaseDespiteDefault=disabled -org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=ignore -org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=ignore -org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotationForInterfaceMethodImplementation=enabled -org.eclipse.jdt.core.compiler.problem.missingSerialVersion=warning -org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod=ignore -org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning -org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning -org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=ignore -org.eclipse.jdt.core.compiler.problem.nonnullParameterAnnotationDropped=warning -org.eclipse.jdt.core.compiler.problem.nonnullTypeVariableFromLegacyInvocation=warning -org.eclipse.jdt.core.compiler.problem.nullAnnotationInferenceConflict=error -org.eclipse.jdt.core.compiler.problem.nullReference=warning -org.eclipse.jdt.core.compiler.problem.nullSpecViolation=error -org.eclipse.jdt.core.compiler.problem.nullUncheckedConversion=warning -org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning -org.eclipse.jdt.core.compiler.problem.parameterAssignment=ignore -org.eclipse.jdt.core.compiler.problem.pessimisticNullAnalysisForFreeTypeVariables=warning -org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=ignore -org.eclipse.jdt.core.compiler.problem.potentialNullReference=ignore -org.eclipse.jdt.core.compiler.problem.potentiallyUnclosedCloseable=ignore -org.eclipse.jdt.core.compiler.problem.rawTypeReference=warning -org.eclipse.jdt.core.compiler.problem.redundantNullAnnotation=warning -org.eclipse.jdt.core.compiler.problem.redundantNullCheck=ignore -org.eclipse.jdt.core.compiler.problem.redundantSpecificationOfTypeArguments=ignore -org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=ignore -org.eclipse.jdt.core.compiler.problem.reportMethodCanBePotentiallyStatic=ignore -org.eclipse.jdt.core.compiler.problem.reportMethodCanBeStatic=ignore -org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled -org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning -org.eclipse.jdt.core.compiler.problem.suppressOptionalErrors=disabled -org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled -org.eclipse.jdt.core.compiler.problem.syntacticNullAnalysisForFields=disabled -org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignore -org.eclipse.jdt.core.compiler.problem.terminalDeprecation=warning -org.eclipse.jdt.core.compiler.problem.typeParameterHiding=warning -org.eclipse.jdt.core.compiler.problem.unavoidableGenericTypeProblems=enabled -org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning -org.eclipse.jdt.core.compiler.problem.unclosedCloseable=warning -org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore -org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning -org.eclipse.jdt.core.compiler.problem.unlikelyCollectionMethodArgumentType=warning -org.eclipse.jdt.core.compiler.problem.unlikelyCollectionMethodArgumentTypeStrict=disabled -org.eclipse.jdt.core.compiler.problem.unlikelyEqualsArgumentType=info -org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore -org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=ignore -org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore -org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=ignore -org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionExemptExceptionAndThrowable=enabled -org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionIncludeDocCommentReference=enabled -org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled -org.eclipse.jdt.core.compiler.problem.unusedExceptionParameter=ignore -org.eclipse.jdt.core.compiler.problem.unusedImport=warning -org.eclipse.jdt.core.compiler.problem.unusedLabel=warning -org.eclipse.jdt.core.compiler.problem.unusedLocal=warning -org.eclipse.jdt.core.compiler.problem.unusedObjectAllocation=ignore -org.eclipse.jdt.core.compiler.problem.unusedParameter=ignore -org.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference=enabled -org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled -org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled -org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning -org.eclipse.jdt.core.compiler.problem.unusedTypeParameter=ignore -org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning -org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning -org.eclipse.jdt.core.compiler.release=enabled diff --git a/org.adempiere.ui.swing/.settings/org.eclipse.m2e.core.prefs b/org.adempiere.ui.swing/.settings/org.eclipse.m2e.core.prefs deleted file mode 100644 index f897a7f1cb..0000000000 --- a/org.adempiere.ui.swing/.settings/org.eclipse.m2e.core.prefs +++ /dev/null @@ -1,4 +0,0 @@ -activeProfiles= -eclipse.preferences.version=1 -resolveWorkspaceProjects=true -version=1 diff --git a/org.adempiere.ui.swing/META-INF/MANIFEST.MF b/org.adempiere.ui.swing/META-INF/MANIFEST.MF deleted file mode 100644 index be74ae4112..0000000000 --- a/org.adempiere.ui.swing/META-INF/MANIFEST.MF +++ /dev/null @@ -1,122 +0,0 @@ -Manifest-Version: 1.0 -Bundle-ManifestVersion: 2 -Bundle-Name: iDempiere Swing Client -Bundle-SymbolicName: org.adempiere.ui.swing;singleton:=true -Bundle-Version: 7.1.0.qualifier -Bundle-ClassPath: ., - lib/jpedal.jar, - lib/looks.jar, - lib/miglayout.jar, - lib/swingx.jar -Export-Package: com.jgoodies.looks, - com.jgoodies.looks.common, - com.jgoodies.looks.plastic, - com.jgoodies.looks.plastic.theme, - com.jgoodies.looks.windows, - de.schaeffer.compiere.tools, - net.miginfocom.layout, - net.miginfocom.swing, - org.adempiere.apps.graph, - org.adempiere.pdf.viewer, - org.adempiere.plaf, - org.adempiere.ui.swing.factory, - org.compiere, - org.compiere.acct, - org.compiere.apps, - org.compiere.apps.form, - org.compiere.apps.search, - org.compiere.apps.wf, - org.compiere.grid, - org.compiere.grid.ed, - org.compiere.grid.tree, - org.compiere.images, - org.compiere.install, - org.compiere.minigrid, - org.compiere.plaf, - org.compiere.pos, - org.compiere.print, - org.compiere.swing, - org.eevolution.form, - org.jdesktop.beans, - org.jdesktop.swingx, - org.jdesktop.swingx.action, - org.jdesktop.swingx.auth, - org.jdesktop.swingx.autocomplete, - org.jdesktop.swingx.border, - org.jdesktop.swingx.calendar, - org.jdesktop.swingx.color, - org.jdesktop.swingx.combobox, - org.jdesktop.swingx.decorator, - org.jdesktop.swingx.error, - org.jdesktop.swingx.event, - org.jdesktop.swingx.geom, - org.jdesktop.swingx.graphics, - org.jdesktop.swingx.hyperlink, - org.jdesktop.swingx.icon, - org.jdesktop.swingx.image, - org.jdesktop.swingx.multislider, - org.jdesktop.swingx.multisplitpane, - org.jdesktop.swingx.painter, - org.jdesktop.swingx.painter.effects, - org.jdesktop.swingx.plaf, - org.jdesktop.swingx.renderer, - org.jdesktop.swingx.rollover, - org.jdesktop.swingx.search, - org.jdesktop.swingx.sort, - org.jdesktop.swingx.table, - org.jdesktop.swingx.tips, - org.jdesktop.swingx.tree, - org.jdesktop.swingx.treetable, - org.jdesktop.swingx.util -Require-Bundle: org.adempiere.base;bundle-version="0.0.0", - org.adempiere.ui;bundle-version="0.0.0", - org.jfree.chart;bundle-version="1.0.19", - org.jfree.jcommon;bundle-version="1.0.23" -Eclipse-ExtensibleAPI: true -Eclipse-RegisterBuddy: org.adempiere.base -Bundle-RequiredExecutionEnvironment: JavaSE-11 -Require-Capability: osgi.ee;filter:="(&(osgi.ee=JavaSE)(version>=11))" -Import-Package: groovy.beans;version="2.5.3", - groovy.cli;version="2.5.3", - groovy.grape;version="2.5.3", - groovy.inspect;version="2.5.3", - groovy.inspect.swingui;version="2.5.3", - groovy.io;version="2.5.3", - groovy.json;version="2.5.3", - groovy.lang;version="2.5.3", - groovy.model;version="2.5.3", - groovy.security;version="2.5.3", - groovy.sql;version="2.5.3", - groovy.swing;version="2.5.3", - groovy.swing.binding;version="2.5.3", - groovy.swing.factory;version="2.5.3", - groovy.swing.impl;version="2.5.3", - groovy.time;version="2.5.3", - groovy.transform;version="2.5.3", - groovy.transform.builder;version="2.5.3", - groovy.transform.options;version="2.5.3", - groovy.transform.stc;version="2.5.3", - groovy.ui;version="2.5.3", - groovy.ui.icons;version="2.5.3", - groovy.ui.text;version="2.5.3", - groovy.ui.view;version="2.5.3", - groovy.util;version="2.5.3", - groovy.util.logging;version="2.5.3", - groovy.util.slurpersupport;version="2.5.3", - groovy.xml;version="2.5.3", - groovy.xml.dom;version="2.5.3", - groovy.xml.jaxb;version="2.5.3", - groovy.xml.streamingmarkupsupport;version="2.5.3", - javax.net.ssl, - net.sf.jasperreports.engine, - org.apache.ecs, - org.apache.ecs.xhtml, - org.apache.poi.hssf.usermodel, - org.compiere.css, - org.eclipse.core.runtime;version="3.4.0", - org.eclipse.equinox.app, - org.osgi.framework;version="1.5.0" -Service-Component: OSGI-INF/*.xml -Bundle-ActivationPolicy: lazy -Automatic-Module-Name: org.adempiere.ui.swing -Bundle-Vendor: iDempiere Community diff --git a/org.adempiere.ui.swing/OSGI-INF/defaultcreatefromfactory.xml b/org.adempiere.ui.swing/OSGI-INF/defaultcreatefromfactory.xml deleted file mode 100644 index a8e8a3eab7..0000000000 --- a/org.adempiere.ui.swing/OSGI-INF/defaultcreatefromfactory.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - diff --git a/org.adempiere.ui.swing/OSGI-INF/defaulteditorfactory.xml b/org.adempiere.ui.swing/OSGI-INF/defaulteditorfactory.xml deleted file mode 100644 index b5b667baba..0000000000 --- a/org.adempiere.ui.swing/OSGI-INF/defaulteditorfactory.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - diff --git a/org.adempiere.ui.swing/OSGI-INF/defaultformfactory.xml b/org.adempiere.ui.swing/OSGI-INF/defaultformfactory.xml deleted file mode 100644 index ecfac158fa..0000000000 --- a/org.adempiere.ui.swing/OSGI-INF/defaultformfactory.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - diff --git a/org.adempiere.ui.swing/OSGI-INF/defaultinfofactory.xml b/org.adempiere.ui.swing/OSGI-INF/defaultinfofactory.xml deleted file mode 100644 index 4b7475506b..0000000000 --- a/org.adempiere.ui.swing/OSGI-INF/defaultinfofactory.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - diff --git a/org.adempiere.ui.swing/OSGI-INF/defaultpaymentformfactory.xml b/org.adempiere.ui.swing/OSGI-INF/defaultpaymentformfactory.xml deleted file mode 100644 index e987a82e55..0000000000 --- a/org.adempiere.ui.swing/OSGI-INF/defaultpaymentformfactory.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - diff --git a/org.adempiere.ui.swing/OSGI-INF/defaultprintshippinglabel.xml b/org.adempiere.ui.swing/OSGI-INF/defaultprintshippinglabel.xml deleted file mode 100644 index 2b14a97e99..0000000000 --- a/org.adempiere.ui.swing/OSGI-INF/defaultprintshippinglabel.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - diff --git a/org.adempiere.ui.swing/OSGI-INF/reportviewerprovider.xml b/org.adempiere.ui.swing/OSGI-INF/reportviewerprovider.xml deleted file mode 100644 index ff537236c1..0000000000 --- a/org.adempiere.ui.swing/OSGI-INF/reportviewerprovider.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - diff --git a/org.adempiere.ui.swing/OSGI-INF/resourcefinder.xml b/org.adempiere.ui.swing/OSGI-INF/resourcefinder.xml deleted file mode 100644 index 52e76f4703..0000000000 --- a/org.adempiere.ui.swing/OSGI-INF/resourcefinder.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - diff --git a/org.adempiere.ui.swing/RUN_build.bat b/org.adempiere.ui.swing/RUN_build.bat deleted file mode 100644 index 2fc71c0800..0000000000 --- a/org.adempiere.ui.swing/RUN_build.bat +++ /dev/null @@ -1,19 +0,0 @@ -@Title Build Client -@Rem $Header: /cvsroot/adempiere/client/RUN_build.bat,v 1.13 2005/09/16 00:48:35 jjanke Exp $ - -@CALL ..\utils_dev\myDevEnv.bat -@IF NOT %ADEMPIERE_ENV%==Y GOTO NOBUILD - -@echo Cleanup ... -@"%JAVA_HOME%\bin\java" -Dant.home="." %ANT_PROPERTIES% org.apache.tools.ant.Main clean - -@echo Building ... -@"%JAVA_HOME%\bin\java" -Dant.home="." %ANT_PROPERTIES% org.apache.tools.ant.Main clientDistribute - -@Echo Done ... -@sleep 60 -@exit - -:NOBUILD -@Echo Check myDevEnv.bat (copy from myDevEnvTemplate.bat) -@Pause \ No newline at end of file diff --git a/org.adempiere.ui.swing/RUN_build.sh b/org.adempiere.ui.swing/RUN_build.sh deleted file mode 100644 index 5f80633c60..0000000000 --- a/org.adempiere.ui.swing/RUN_build.sh +++ /dev/null @@ -1,18 +0,0 @@ -# Module compiling script -# Ported from Windows script Marek Mosiewicz - - -SAVED_DIR=`pwd` #save current dir -cd `dirname $0`/../utils_dev #change dir to place where script resides - doesn not work with sym links -UTILS_DEV=`pwd` #this is adempiere source -cd $SAVED_DIR #back to the saved directory - -. $UTILS_DEV/myDevEnv.sh #call environment -echo done -if [ ! $ADEMPIERE_ENV==Y ] ; then - echo "Can't set developemeent environemnt - check myDevEnv.sh" - exit 1 -fi - -echo running Ant -$JAVA_HOME/bin/java -Dant.home="." $ANT_PROPERTIES org.apache.tools.ant.Main diff --git a/org.adempiere.ui.swing/Swingset.bat b/org.adempiere.ui.swing/Swingset.bat deleted file mode 100644 index 1bc80a928c..0000000000 --- a/org.adempiere.ui.swing/Swingset.bat +++ /dev/null @@ -1,11 +0,0 @@ -@Title Swingset - -@Rem $Id: Swingset.bat,v 1.1 2002/03/17 02:29:49 jjanke Exp $ -@Rem Put the swing.properties file in the \rje\lib directory -@set JAVA_HOME=D:\j2sdk1.4.0 - -@Rem -%JAVA_HOME%\jre\bin\java -jar %JAVA_HOME%\demo\jfc\SwingSet2\SwingSet2.jar - -@Echo done ... -@Sleep 10 \ No newline at end of file diff --git a/org.adempiere.ui.swing/build.properties b/org.adempiere.ui.swing/build.properties deleted file mode 100644 index 1fa0422790..0000000000 --- a/org.adempiere.ui.swing/build.properties +++ /dev/null @@ -1,10 +0,0 @@ -bin.includes = META-INF/,\ - plugin.xml,\ - OSGI-INF/,\ - .,\ - lib/jpedal.jar,\ - lib/looks.jar,\ - lib/miglayout.jar,\ - lib/swingx.jar -source.. = src/ -output.. = target/classes/ diff --git a/org.adempiere.ui.swing/documentation.bat b/org.adempiere.ui.swing/documentation.bat deleted file mode 100644 index 659c934f80..0000000000 --- a/org.adempiere.ui.swing/documentation.bat +++ /dev/null @@ -1,5 +0,0 @@ -@Rem API Documentation for Base - -call ..\doc\documentation.bat src doc -private - -@pause \ No newline at end of file diff --git a/org.adempiere.ui.swing/packages.txt b/org.adempiere.ui.swing/packages.txt deleted file mode 100644 index e66e569bf2..0000000000 --- a/org.adempiere.ui.swing/packages.txt +++ /dev/null @@ -1,11 +0,0 @@ -org.compiere.acct -org.compiere.apps -org.compiere.apps.form -org.compiere.apps.search -org.compiere.grid -org.compiere.grid.ed -org.compiere.grid.tree -org.compiere.images -org.compiere.install -org.compiere.minigrid -org.compiere.print \ No newline at end of file diff --git a/org.adempiere.ui.swing/plugin.xml b/org.adempiere.ui.swing/plugin.xml deleted file mode 100644 index 84669800d9..0000000000 --- a/org.adempiere.ui.swing/plugin.xml +++ /dev/null @@ -1,26 +0,0 @@ - - - - - - - - - - - - - - - - - diff --git a/org.adempiere.ui.swing/pom.xml b/org.adempiere.ui.swing/pom.xml deleted file mode 100644 index f38e5e95d5..0000000000 --- a/org.adempiere.ui.swing/pom.xml +++ /dev/null @@ -1,82 +0,0 @@ - - 4.0.0 - - org.idempiere - org.idempiere.parent - 7.1.0-SNAPSHOT - ../org.idempiere.parent/pom.xml - - org.adempiere.ui.swing - eclipse-plugin - - - - - org.eclipse.tycho - tycho-compiler-plugin - - - - -warn:+forbidden - --add-exports - java.desktop/sun.awt=ALL-UNNAMED - - - - - org.apache.maven.plugins - maven-dependency-plugin - - - validate - - copy - - - - - org.swinglabs - swingx - 1.6 - - - com.jgoodies - looks - 2.0.4 - - - com.miglayout - miglayout - 3.7.1 - - - lib - true - true - true - - - - - - com.googlecode.maven-download-plugin - download-maven-plugin - - - validate - - wget - - - ${url.file.srv}/extra.jar/jpedal.jar - false - lib - 5 - - - - - - - \ No newline at end of file diff --git a/org.adempiere.ui.swing/schema/org.adempiere.apps.Form.exsd b/org.adempiere.ui.swing/schema/org.adempiere.apps.Form.exsd deleted file mode 100644 index 0811f445d6..0000000000 --- a/org.adempiere.ui.swing/schema/org.adempiere.apps.Form.exsd +++ /dev/null @@ -1,133 +0,0 @@ - - - - - - - - - Extension point to provide FormPanel instance. Use the {extension id} syntax in AD_Form.ClassName to reference the extension that will provide the FormPanel instance ( replace {extension id} with your actual extension id ). - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Implementation class name for the org.compiere.apps.form.FormPanel interface - - - - - - - - - - numeric priority value, higher value is of higher priority - - - - - - - - - - - - 1.0.0 - - - - - - - - - <pre> -<extension - id="org.adempiere.extend.myForm" - name="My Form" - point="org.adempiere.apps.Form"> - <process - class="org.adempiere.ui.swing.extend.MyForm"> - </process> -</extension> - -AD_Form.ClassName="org.adempiere.extend.myForm" -</pre> - - - - - - - - - The class attribute must represent an implementor of org.compiere.apps.form.FormPanel - - - - - - - - - - This file is part of Adempiere ERP Bazaar http://www.adempiere.org. - - Copyright (C) Heng Sin Low. - Copyright (C) Contributors. - - This program is free software; you can redistribute it and/or modify it - under the terms version 2 of the GNU General Public License as published - by the Free Software Foundation. This program is distributed in the hope - that it will be useful, but WITHOUT ANY WARRANTY; without even the implied - warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - See the GNU General Public License for more details. - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. - - - - diff --git a/org.adempiere.ui.swing/src/de/schaeffer/compiere/tools/DocumentSearch.java b/org.adempiere.ui.swing/src/de/schaeffer/compiere/tools/DocumentSearch.java deleted file mode 100644 index 5d84e6645f..0000000000 --- a/org.adempiere.ui.swing/src/de/schaeffer/compiere/tools/DocumentSearch.java +++ /dev/null @@ -1,62 +0,0 @@ -/********************************************************************** -* This file is part of Adempiere ERP Bazaar * -* http://www.adempiere.org * -* * -* Copyright (C) Jan Roessler - Schaeffer * -* Copyright (C) Contributors * -* * -* This program is free software; you can redistribute it and/or * -* modify it under the terms of the GNU General Public License * -* as published by the Free Software Foundation; either version 2 * -* of the License, or (at your option) any later version. * -* * -* This program is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU General Public License for more details. * -* * -* You should have received a copy of the GNU General Public License * -* along with this program; if not, write to the Free Software * -* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, * -* MA 02110-1301, USA. * -* * -* Contributors: * -* - Jan Roessler * -* - Heng Sin Low * -* * -* Sponsors: * -* - Schaeffer * -**********************************************************************/ - -package de.schaeffer.compiere.tools; - -import org.adempiere.util.AbstractDocumentSearch; -import org.compiere.apps.AEnv; -import org.compiere.apps.AWindow; -import org.compiere.model.MQuery; -import org.compiere.util.CLogger; - -/** - * Executes search and opens windows for defined transaction codes - * - * @author Jan Roessler, jr@schaeffer-ag.de - * - */ -public class DocumentSearch extends AbstractDocumentSearch { - - /** the logger */ - @SuppressWarnings("unused") - private static CLogger log = CLogger.getCLogger(DocumentSearch.class); - - @Override - protected boolean openWindow(int windowId, MQuery query) { - final AWindow frame = new AWindow(null); - AEnv.addToWindowManager(frame); - if (frame.initWindow(windowId, query)) { - frame.pack(); - AEnv.showCenterScreen(frame); - } - return true; - } - -} diff --git a/org.adempiere.ui.swing/src/org/adempiere/apps/graph/FCHtmlEditorKit.java b/org.adempiere.ui.swing/src/org/adempiere/apps/graph/FCHtmlEditorKit.java deleted file mode 100644 index 643f506906..0000000000 --- a/org.adempiere.ui.swing/src/org/adempiere/apps/graph/FCHtmlEditorKit.java +++ /dev/null @@ -1,98 +0,0 @@ -package org.adempiere.apps.graph; - -import java.awt.Image; -import java.awt.Toolkit; -import java.net.URL; - -import javax.swing.ImageIcon; -import javax.swing.text.Element; -import javax.swing.text.View; -import javax.swing.text.ViewFactory; -import javax.swing.text.html.HTML; -import javax.swing.text.html.HTMLEditorKit; -import javax.swing.text.html.ImageView; - -public class FCHtmlEditorKit extends HTMLEditorKit { - /** - * - */ - private static final long serialVersionUID = -3371176452691681668L; - - public ViewFactory getViewFactory() { - if (defaultFactory == null) { - defaultFactory = new FCHtmlFactory(super.getViewFactory()); - } - return defaultFactory; - } - - private static class FCHtmlFactory implements ViewFactory { - public FCHtmlFactory(ViewFactory factory) { - oldFactory = factory; - } - public View create(Element elem) { - View result; - result = oldFactory.create(elem); - if (result instanceof ImageView) { - String src = (String)elem.getAttributes(). - getAttribute(HTML.Attribute.SRC); - if ("res:".equals(src.substring(0, 4))) { - result = new NewImageView(elem); - } - } - return result; - } - private static class NewImageView extends ImageView { - Element elem; - public NewImageView(Element elem) { - super(elem); - this.elem=elem; - } - public Image getImage() { - //return smile image - //java.awt.Toolkit.getDefaultToolkit().getImage(getImageURL()).flush(); - //if (smileImage == null) { - String src = (String)elem.getAttributes(). - getAttribute(HTML.Attribute.SRC); - //System.out.println("img load: " + src.substring(4)); - URL url = getClass().getClassLoader(). - getResource(src.substring(4)); - //getResource("at/freecom/apps/images/freecom.gif"); - //getResource("javax/swing/text/html/icons/image-delayed.gif"); - if (url == null) return null; - smileImage = Toolkit.getDefaultToolkit().getImage(url); - if (smileImage==null) return null; - //forcing image to load synchronously - ImageIcon ii = new ImageIcon(); - ii.setImage(smileImage); - //} - return smileImage; - } - public URL getImageURL() { - // here we return url to some image. It might be any - // existing image. we need to move ImageView to the - // state where it thinks that image was loaded. - // ImageView is calling getImage to get image for - // measurement and painting when image was loaded - /*if (false) { - return getClass().getClassLoader(). - getResource("javax/swing/text/html/icons/image-delayed.gif"); - } else {*/ - String src = (String)elem.getAttributes(). - getAttribute(HTML.Attribute.SRC); - //System.out.println("img load: " + src.substring(4)); - URL url = getClass().getClassLoader(). - getResource(src.substring(4)); - if (url != null) { - // System.out.println("load image: " + url); - return url; - } - //} - return null; - } - private static Image smileImage = null; - } - - private ViewFactory oldFactory; - } - private static ViewFactory defaultFactory = null; -} \ No newline at end of file diff --git a/org.adempiere.ui.swing/src/org/adempiere/apps/graph/Graph.java b/org.adempiere.ui.swing/src/org/adempiere/apps/graph/Graph.java deleted file mode 100644 index db561fbcdd..0000000000 --- a/org.adempiere.ui.swing/src/org/adempiere/apps/graph/Graph.java +++ /dev/null @@ -1,313 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ -package org.adempiere.apps.graph; - -import java.awt.BorderLayout; -import java.awt.Cursor; -import java.awt.Dimension; -import java.awt.Point; -import java.beans.PropertyChangeEvent; -import java.beans.PropertyVetoException; -import java.beans.VetoableChangeListener; -import java.util.ArrayList; - -import org.compiere.apps.AEnv; -import org.compiere.grid.ed.VLookup; -import org.compiere.model.MGoal; -import org.compiere.model.MLookup; -import org.compiere.model.MLookupFactory; -import org.compiere.model.MLookupInfo; -import org.compiere.model.MQuery; -import org.compiere.swing.CPanel; -import org.compiere.util.CLogger; -import org.compiere.util.DB; -import org.compiere.util.Env; -import org.jfree.chart.ChartMouseEvent; -import org.jfree.chart.ChartMouseListener; -import org.jfree.chart.ChartPanel; -import org.jfree.chart.JFreeChart; -import org.jfree.chart.entity.CategoryItemEntity; -import org.jfree.chart.entity.ChartEntity; -import org.jfree.chart.entity.PieSectionEntity; - -/** - * Graph - * - * @author Jorg Janke - * @version $Id: BarGraph.java,v 1.2 2006/07/30 00:51:28 jjanke Exp $ - * - * @author Teo Sarca, www.arhipac.ro - *
  • BF [ 2507325 ] BarGraph zoom not working - * @author hengsin - *
  • Add support for other type of graph - */ -public class Graph extends CPanel implements ChartMouseListener -{ - /** - * - */ - private static final long serialVersionUID = -4150122585550132822L; - - /** - * Constructor - */ - public Graph() - { - super(); - this.setLayout(new BorderLayout()); - builder = new GraphBuilder(); - } // BarGraph - - /** - * Constructor - * @param goal goal - */ - public Graph(MGoal goal) - { - this(goal, false); - } - - /** - * Constructor - * @param goal goal - */ - public Graph(MGoal goal, boolean userSelection) - { - this(); - builder = new GraphBuilder(); - builder.setMGoal(goal); - builder.setYAxisLabel(goal.getName()); - builder.setXAxisLabel(goal.getXAxisText()); - m_userSelection = userSelection; - loadData(); - //addComponentListener(this); - } // BarGraph - - - /** Graph Size */ - //private Dimension m_size = null; - /** Zero/Zero Coordinate point */ - private Point m_point0_0 = null; -// /** Layout */ -// private BarGraphLayout m_layout = new BarGraphLayout(this); - - /** Logger */ - private static CLogger log = CLogger.getCLogger (Graph.class); - - - /** Y Axis Target Line */ - @SuppressWarnings("unused") - private double m_Y_Target = 0; - /** Y Axis Target Line Label */ - private String m_Y_TargetLabel = null; - private static Dimension paneldimension = new Dimension(180, 150); - - private GraphBuilder builder; - - /** - * Load Performance Data - */ - ArrayList list = new ArrayList(); - private boolean m_userSelection; - - - private void loadData() - { - - list = builder.loadData(); - JFreeChart chart = builder.createChart(builder.getMGoal().getChartType()); - if (chartPanel != null) - remove(chartPanel); - - chartPanel = new ChartPanel(chart); - chartPanel.setSize(getSize()); - chartPanel.addChartMouseListener(this); - add(chartPanel,BorderLayout.CENTER); - - if (m_userSelection) - { - int AD_Reference_Value_ID = DB.getSQLValue(null, "SELECT AD_Reference_ID FROM AD_Reference WHERE Name = ?", "PA_Goal ChartType"); - MLookupInfo info = MLookupFactory.getLookup_List(Env.getLanguage(Env.getCtx()), AD_Reference_Value_ID); - MLookup mLookup = new MLookup(info, 0); - VLookup lookup = new VLookup("ChartType", false, false, true, - mLookup); - lookup.addVetoableChangeListener(new VetoableChangeListener() { - - public void vetoableChange(PropertyChangeEvent evt) - throws PropertyVetoException { - Object value = evt.getNewValue(); - if (value == null) return; - JFreeChart chart = null; - chart = builder.createChart(value.toString()); - - if (chart != null) - { - if (chartPanel != null) - remove(chartPanel); - - chartPanel = new ChartPanel(chart); - chartPanel.setSize(getSize()); - chartPanel.addChartMouseListener(Graph.this); - add(chartPanel,BorderLayout.CENTER); - getParent().validate(); - - } - } - - }); - add(lookup, BorderLayout.NORTH); - } - this.setMinimumSize(paneldimension); - } // loadData - - private ChartPanel chartPanel; - /** - * Get Point 0_0 - * @return point - */ - public Point getPoint0_0() - { - return m_point0_0; - } // getPoint0_0 - - - /** - * @return Returns the x_AxisLabel. - */ - public String getX_AxisLabel () - { - return builder.getXAxisLabel(); - } // getX_AxisLabel - - /** - * @param axisLabel The x_AxisLabel to set. - */ - public void setX_AxisLabel (String axisLabel) - { - builder.setXAxisLabel(axisLabel); - } // setX_AxisLabel - - /** - * @return Returns the y_AxisLabel. - */ - public String getY_AxisLabel () - { - return builder.getYAxisLabel(); - } // getY_AxisLabel - - /** - * @param axisLabel The y_AxisLabel to set. - */ - public void setY_AxisLabel (String axisLabel) - { - builder.setYAxisLabel(axisLabel); - } // setY_AxisLabel - - /** - * @return Returns the y_TargetLabel. - */ - public String getY_TargetLabel () - { - return m_Y_TargetLabel; - } // getY_TargetLabel - - /** - * @param targetLabel The y_TargetLabel to set. - */ - public void setY_TargetLabel (String targetLabel, double target) - { - m_Y_TargetLabel = targetLabel; - m_Y_Target = target; - } // setY_TargetLabel - - - /** - * Get BarGraphColumn for ChartEntity - * @param event - * @return BarGraphColumn or null if not found - */ - private GraphColumn getGraphColumn(ChartMouseEvent event) - { - ChartEntity entity = event.getEntity(); - String key = null; - if (entity instanceof CategoryItemEntity) - { - Comparable colKey = ((CategoryItemEntity)entity).getColumnKey(); - if (colKey != null) - { - key = colKey.toString(); - } - } - else if (entity instanceof PieSectionEntity) - { - Comparable sectionKey = ((PieSectionEntity)entity).getSectionKey(); - if (sectionKey != null) - { - key = sectionKey.toString(); - } - } - if (key == null) - { - return null; - } - for (int i = 0; i < list.size(); i++) - { - final String label = list.get(i).getLabel(); - if (key.equals(label)) - { - return list.get(i); - } - } - // - return null; - } - - public void chartMouseClicked(ChartMouseEvent event) - { - if ((event.getEntity()!=null) && (event.getTrigger().getClickCount() > 1)) - { - setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); - try - { - GraphColumn bgc = getGraphColumn(event); - if (bgc == null) - { - return; - } - - MQuery query = bgc.getMQuery(builder.getMGoal()); - if (query != null) - AEnv.zoom(query); - else - log.warning("Nothing to zoom to - " + bgc); - } - finally - { - setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); - } - } - } - - public void chartMouseMoved(ChartMouseEvent event) - { - } - - public GraphColumn[] getGraphColumnList() - { - return list.toArray(new GraphColumn[list.size()]); - } -} // BarGraph diff --git a/org.adempiere.ui.swing/src/org/adempiere/apps/graph/GraphUtil.java b/org.adempiere.ui.swing/src/org/adempiere/apps/graph/GraphUtil.java deleted file mode 100644 index c9830b23b6..0000000000 --- a/org.adempiere.ui.swing/src/org/adempiere/apps/graph/GraphUtil.java +++ /dev/null @@ -1,170 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ -package org.adempiere.apps.graph; - -import java.awt.Color; -import java.util.ArrayList; - -import org.compiere.util.CLogger; - -/** - * Graphic Utilities - * - * @author Jorg Janke - * @version $Id: GraphUtil.java,v 1.3 2006/07/30 00:51:28 jjanke Exp $ - */ -public class GraphUtil -{ - /** Logger */ - @SuppressWarnings("unused") - private static CLogger log = CLogger.getCLogger (GraphUtil.class); - - /** - * Get Foreground for back - * @param background back - * @return while or black - */ - public static Color getForeground (Color background) - { - if (background != null && isDark(background)) - return Color.white; - return Color.black; - } // getForeground - - /** - * Get Column Background - * @param index index - * @return random color - */ - public static Color getBackground (int index) - { - while (s_colors.size() <= index) - { - int rr = (index+1) * 47; - int gg = 100; - while (rr > 255) - { - rr -= 255; - gg += 50; - } - while (gg > 255) - gg -= 255; - s_colors.add(new Color(255-rr, gg, rr)); - } - return s_colors.get(index); - } // getBackGround - - /** List of Colors */ - private static ArrayList s_colors = new ArrayList(); - - - /** - * Is the Color dark? - * @param color color - * @return true if dark - */ - public static boolean isDark (Color color) - { - float r = color.getRed() / 255.0f; - float g = color.getGreen() / 255.0f; - float b = color.getBlue() / 255.0f; - double whiteDistance = colorDistance (r, g, b, 1.0, 1.0, 1.0); - double blackDistance = colorDistance (r, g, b, 0.0, 0.0, 0.0); - boolean dark = blackDistance < whiteDistance; - if (r+g+b == 1.0) - dark = false; - // log.info("r=" + r + ",g=" + g + ",b=" + b + " - black=" + blackDistance - // + (dark ? " ") + "white=" + whiteDistance - // + " - Alpha=" + color.getAlpha() + ", Trans=" + color.getTransparency()); - return dark; - } // isDark - - /** - * Is Color more white or black? - * @param r red - * @param g green - * @param b blue - * @return true if dark - */ - public static boolean isDark (double r, double g, double b) - { - double whiteDistance = colorDistance (r, g, b, 1.0, 1.0, 1.0); - double blackDistance = colorDistance (r, g, b, 0.0, 0.0, 0.0); - boolean dark = blackDistance < whiteDistance; - // log.finest("r=" + r + ",g=" + g + ",b=" + b + " - white=" + whiteDistance + ",black=" + blackDistance); - return dark; - } // isDark - - /** - * Simple Color Distance. - * (3d point distance) - * @param r1 first red - * @param g1 first green - * @param b1 first blue - * @param r2 second red - * @param g2 second green - * @param b2 second blue - * @return 3d distance for relative comparison - */ - public static double colorDistance (double r1, double g1, double b1, - double r2, double g2, double b2) - { - double a = (r2 - r1) + 0.1; - double b = (g2 - g1) + 0.1; - double c = (b2 - b1) + 0.1; - return Math.sqrt (a*a + b*b + c*c); - } // colorDistance - - - /** - * Get darker color - * @param color color - * @param factor factor 0..1 (AWT 0.7) the smaller, the darker - * @return darker color - */ - public static Color darker(Color color, double factor) - { - if (factor < 0.0) - factor = 0.7; - else if (factor > 1.0) - factor = 0.7; - return new Color( - Math.max((int)(color.getRed() * factor), 0), - Math.max((int)(color.getGreen() * factor), 0), - Math.max((int)(color.getBlue() * factor), 0)); - } // darker - - /** - * Get brighter color - * @param color color - * @param factor factor 0..1 (AWT 0.7) the smaller, the lighter - * @return brighter color - */ - public static Color brighter (Color color, double factor) - { - if (factor < 0.0) - factor = 0.7; - else if (factor > 1.0) - factor = 0.7; - - return new Color( - Math.min((int)(color.getRed() / factor), 255), - Math.min((int)(color.getGreen() / factor), 255), - Math.min((int)(color.getBlue() / factor), 255)); - } // brighter - -} // GraphUtil diff --git a/org.adempiere.ui.swing/src/org/adempiere/apps/graph/HtmlDashboard.java b/org.adempiere.ui.swing/src/org/adempiere/apps/graph/HtmlDashboard.java deleted file mode 100644 index 7126843026..0000000000 --- a/org.adempiere.ui.swing/src/org/adempiere/apps/graph/HtmlDashboard.java +++ /dev/null @@ -1,504 +0,0 @@ -/** - * - */ -package org.adempiere.apps.graph; - -import java.awt.BorderLayout; -import java.awt.Component; -import java.awt.Container; -import java.awt.Cursor; -import java.awt.Dimension; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.awt.event.MouseEvent; -import java.awt.event.MouseListener; -import java.io.BufferedReader; -import java.io.IOException; -import java.io.InputStreamReader; -import java.net.MalformedURLException; -import java.net.URL; -import java.util.ArrayList; -import java.util.logging.Level; - -import javax.swing.JEditorPane; -import javax.swing.JPanel; -import javax.swing.JPopupMenu; -import javax.swing.JScrollPane; -import javax.swing.SwingUtilities; -import javax.swing.event.HyperlinkEvent; -import javax.swing.event.HyperlinkListener; -import javax.swing.text.Document; - -import org.compiere.apps.AEnv; -import org.compiere.apps.AWindow; -import org.compiere.model.MAchievement; -import org.compiere.model.MDashboardContent; -import org.compiere.model.MDashboardPreference; -import org.compiere.model.MGoal; -import org.compiere.model.MMeasureCalc; -import org.compiere.model.MProjectType; -import org.compiere.model.MQuery; -import org.compiere.model.MRequestType; -import org.compiere.model.MRole; -import org.compiere.swing.CMenuItem; -import org.compiere.util.CLogger; -import org.compiere.util.Env; -import org.compiere.util.Ini; -import org.compiere.util.Msg; -import org.compiere.util.Util; - -/** - * @author fcsku - * - */ -public class HtmlDashboard extends JPanel implements MouseListener, - ActionListener, HyperlinkListener { - - /** - * - */ - private static final long serialVersionUID = 8125801717324723271L; - private static Dimension paneldimensionMin = new Dimension(80, 80); - private JEditorPane html; - private enum PAGE_TYPE {PAGE_HOME, PAGE_PERFORMANCE, PAGE_LOGO}; - private static CLogger log = CLogger.getCLogger (HtmlDashboard.class); - MGoal[] m_goals = null; - JPopupMenu popupMenu = new JPopupMenu(); - private CMenuItem mRefresh = new CMenuItem(Msg.getMsg(Env.getCtx(), "Refresh"), Env.getImageIcon("Refresh16.gif")); - URL lastUrl = null; - - - /** - * Constructor - */ - public HtmlDashboard(String url, MGoal[] m_goals, boolean scrolling) - { - super(); - //+param VTreePanel treePanel, - //this.treePanel = treePanel; - setName("test title"); - this.setLayout( new BorderLayout() ); - this.m_goals = m_goals; - // Create an HTML viewer - JEditorPane.registerEditorKitForContentType("text/html", "org.adempiere.apps.graph.FCHtmlEditorKit"); - html = new JEditorPane(); - html.setContentType("text/html"); - html.setEditable( false ); - htmlUpdate(url); - JScrollPane scrollPane = null; - if (scrolling) - scrollPane = new JScrollPane(); - else - scrollPane = new JScrollPane(JScrollPane.VERTICAL_SCROLLBAR_NEVER, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); - scrollPane.getViewport().add( html, BorderLayout.CENTER ); - this.add( scrollPane, BorderLayout.CENTER ); - this.setMinimumSize(paneldimensionMin); - addMouseListener(this); - html.addHyperlinkListener( this ); - mRefresh.addActionListener(this); - popupMenu.add(mRefresh); - html.addMouseListener(this); - html.setBackground(getBackground()); - } - - public HtmlDashboard(String url) - { - new HtmlDashboard(url, null, true); - } - - private String createHTML(PAGE_TYPE requestPage){ - - StringBuilder result = new StringBuilder(""); - - // READ CSS - URL url = getClass().getClassLoader(). - getResource("org/compiere/css/PAPanel.css"); - InputStreamReader ins; - BufferedReader bufferedReader = null; - try { - ins = new InputStreamReader(url.openStream()); - bufferedReader = new BufferedReader( ins ); - String cssLine; - result.append(""); - } catch (IOException e1) { - log.log(Level.SEVERE, e1.getLocalizedMessage(), e1); - } - finally{ - if (bufferedReader != null) { - try { - bufferedReader.close(); - } catch (Exception e) {} - bufferedReader = null; - } - } - //System.out.println(result); - switch (requestPage) { - case PAGE_LOGO: - - result.append("") - .append("
    ") - .append("") - .append("") - .append("
    ") - .append(""); - break; - - case PAGE_HOME: //************************************************************** - - result.append("
    \n");// "" - queryZoom = null; - queryZoom = new ArrayList(); - String appendToHome = null; - try - { - int AD_User_ID = Env.getAD_User_ID(Env.getCtx()); - int AD_Role_ID = Env.getAD_Role_ID(Env.getCtx()); - - MDashboardPreference[] dps = MDashboardPreference.getForSession(AD_User_ID, AD_Role_ID); - if (dps.length == 0) - createDashboardPreference(); - - dps = MDashboardPreference.getForSession(true, AD_User_ID, AD_Role_ID); // based on user and role - - for (final MDashboardPreference dp : dps) - { - MDashboardContent dc = new MDashboardContent(dp.getCtx(), dp.getPA_DashboardContent_ID(), dp.get_TrxName()); - - if (!Util.isEmpty(dc.getZulFilePath(), true)) - continue; - // - appendToHome = dc.get_Translation(MDashboardContent.COLUMNNAME_HTML); - String descriptionTrl = dp.get_Translation(MDashboardContent.COLUMNNAME_Description); - if (appendToHome != null) { - if (descriptionTrl != null) - result.append("

    ").append(descriptionTrl).append("

    \n"); - result.append(stripHtml(appendToHome, false)).append("
    \n"); - } - - if (dc.getAD_Menu_ID() > 0) { - result.append(""); - result.append(descriptionTrl.toString()); - result.append("
    \n"); - - } - result.append("
    \n"); - //result += "table id: " + rs.getInt("AD_TABLE_ID"); - if (dc.getPA_Goal_ID() > 0) - result.append(goalsDetail(dc.getPA_Goal_ID())); - } - } - catch (Exception e) - { - log.log(Level.SEVERE, e.getLocalizedMessage(), e); - } - finally - { - } - result.append("


    \n") - .append("
    \n\n\n"); - break; - default: //************************************************************** - log.warning("Unknown option - "+requestPage); - } - return result.toString(); - } - - private void createDashboardPreference() - { - if (Env.getAD_User_ID(Env.getCtx()) == 0 && Env.getAD_Role_ID(Env.getCtx()) == 0) - return; - - MDashboardContent[] dcs = MDashboardContent.getForSession(0, 0); - for (MDashboardContent dc : dcs) - { - MDashboardPreference preference = new MDashboardPreference(Env.getCtx(), 0, null); - preference.setAD_Org_ID(Env.getAD_Org_ID(Env.getCtx())); - preference.setAD_Role_ID(Env.getAD_Role_ID(Env.getCtx())); - preference.setAD_User_ID(Env.getAD_User_ID(Env.getCtx())); - preference.setColumnNo(dc.getColumnNo()); - preference.setIsCollapsedByDefault(dc.isCollapsedByDefault()); - preference.setIsShowInDashboard(dc.isShowInDashboard()); - preference.setLine(dc.getLine()); - preference.setPA_DashboardContent_ID(dc.getPA_DashboardContent_ID()); - - if (!preference.save()){ - StringBuilder msglog = new StringBuilder("Failed to create dashboard preference ").append(preference.toString()); - log.log(Level.SEVERE, msglog.toString()); - } - } - } - - ArrayList queryZoom = null; //new ArrayList(); - - private String goalsDetail(int AD_Table_ID) { //TODO link to goals - StringBuilder output = new StringBuilder(); - if (m_goals==null) return output.toString(); - for (int i = 0; i < m_goals.length; i++) { - MMeasureCalc mc = MMeasureCalc.get(Env.getCtx(), m_goals[i].getMeasure().getPA_MeasureCalc_ID()); - if (AD_Table_ID == m_goals[i].getPA_Goal_ID()){// mc.getAD_Table_ID()) { - output.append("\n\n"); - output.append("\n"); - output.append("\n"); - - //if (mc.getTableName()!=null) output += "table: " + mc.getAD_Table_ID() + "
    \n"; - Graph barPanel = new Graph(m_goals[i]); - GraphColumn[] bList = barPanel.getGraphColumnList(); - MQuery query = null; - output.append("\n"); - for (int k=0; k0) output.append(""); - if (bgc.getAchievement() != null) // Single Achievement - { - MAchievement a = bgc.getAchievement(); - query = MQuery.getEqualQuery("PA_Measure_ID", a.getPA_Measure_ID()); - } - else if (bgc.getGoal() != null) // Multiple Achievements - { - MGoal goal = bgc.getGoal(); - query = MQuery.getEqualQuery("PA_Measure_ID", goal.getPA_Measure_ID()); - } - else if (bgc.getMeasureCalc() != null) // Document - { - mc = bgc.getMeasureCalc(); - query = mc.getQuery(m_goals[i].getRestrictions(false), - bgc.getMeasureDisplay(), bgc.getDate(), - MRole.getDefault()); // logged in role - } - else if (bgc.getProjectType() != null) // Document - { - MProjectType pt = bgc.getProjectType(); - query = pt.getQuery(m_goals[i].getRestrictions(false), - bgc.getMeasureDisplay(), bgc.getDate(), bgc.getID(), - MRole.getDefault()); // logged in role - } - else if (bgc.getRequestType() != null) // Document - { - MRequestType rt = bgc.getRequestType(); - query = rt.getQuery(m_goals[i].getRestrictions(false), - bgc.getMeasureDisplay(), bgc.getDate(), bgc.getID(), - MRole.getDefault()); // logged in role - } - output.append(""); - } - output.append("") - .append("") - .append("
    ").append(m_goals[i].getName()).append("
    Target").append(m_goals[i].getMeasureTarget()).append("
    Actual").append(m_goals[i].getMeasureActual()).append("
    ").append(m_goals[i].getXAxisText()).append("
    ").append(bgc.getLabel()).append(""); - if (query != null) { - output.append("") - .append(bgc.getValue()) - .append("
    \n"); - queryZoom.add(query); - } - else { - if (log.isLoggable(Level.INFO)) log.info("Nothing to zoom to - " + bgc); - output.append(bgc.getValue()); - } - output.append("
    ") - .append(m_goals[i].getDescription()) - .append("
    ") - .append(stripHtml(m_goals[i].getColorSchema().getDescription(), true)) - .append("
    \n"); - bList = null; - barPanel = null; - } - } - return output.toString(); - } - - private String stripHtml(String htmlString, boolean all) { - htmlString = htmlString - .replace("", "") - .replace("", "") - .replace("", "") - .replace("", "") - .replace("", "") - .replace("", ""); - - if (all) - htmlString = htmlString - .replace(">", ">") - .replace("<", "<"); - return htmlString; - } - private void htmlUpdate(String url) { - try { - htmlUpdate( new URL( url ) ); - } catch( MalformedURLException e ) { - log.warning("Malformed URL: " + e ); - } - } - - private void htmlUpdate(URL url) { - if ((url==null) || (url.getPath().equals("/local/home"))){ - html.setText(createHTML(PAGE_TYPE.PAGE_HOME)); - html.setCaretPosition(0); - lastUrl = url; - } - else if (url.getPath().equals("/local/logo")){ - html.setText(createHTML(PAGE_TYPE.PAGE_LOGO)); - html.setCaretPosition(0); - lastUrl = url; - } - else if (url.getPath().equals("/local/performance")){ - html.setText(createHTML(PAGE_TYPE.PAGE_PERFORMANCE)); - } - else if (url.getPath().equals("/window/node")){ - /* fcsku 3.7.07 - CButton button = new CButton(""); // Create the button - button.setActionCommand(String.valueOf(url.getRef())); //getNode_ID() - button.addActionListener(treePanel); //VTreePanel - //AEnv.zoom(130, 0); - html.setCursor(Cursor.getPredefinedCursor( Cursor.WAIT_CURSOR )); - button.doClick(); - html.setCursor(Cursor.getPredefinedCursor( Cursor.DEFAULT_CURSOR )); - */ - int AD_Window_ID=Integer.parseInt(url.getRef()); - AWindow frame = new AWindow(getGraphicsConfiguration()); - if (!frame.initWindow(AD_Window_ID, null))//MQuery.getEqualQuery(TableName + "_ID", Record_ID))) - return; - AEnv.addToWindowManager(frame); - if (Ini.isPropertyBool(Ini.P_OPEN_WINDOW_MAXIMIZED)) - { - AEnv.showMaximized(frame); - } - else - { - AEnv.showCenterScreen(frame); - } - frame = null; - html.setCursor(Cursor.getPredefinedCursor( Cursor.DEFAULT_CURSOR )); - } - else if (url.getPath().equals("/window/zoom")){ - int index = Integer.parseInt(String.valueOf(url.getRef())); - if ((index >= 0) && (index < queryZoom.size())) { - html.setCursor(Cursor.getPredefinedCursor( Cursor.WAIT_CURSOR )); - AEnv.zoom(queryZoom.get(index)); - html.setCursor(Cursor.getPredefinedCursor( Cursor.DEFAULT_CURSOR )); - } - } - else if (url != null){ - // Load some cursors - Cursor cursor = html.getCursor(); - html.setCursor( Cursor.getPredefinedCursor( Cursor.WAIT_CURSOR ) ); - SwingUtilities.invokeLater( new PageLoader( html, url, cursor ) ); - lastUrl = url; - } - } - - - public void hyperlinkUpdate( HyperlinkEvent event ) - { - if( event.getEventType() == HyperlinkEvent.EventType.ACTIVATED ) - { - //System.out.println("parsed url: " + event.getURL());// +" from: " +event.getDescription()); - htmlUpdate(event.getURL()); - } - } - - /* (non-Javadoc) - * @see java.awt.event.MouseListener#mouseClicked(java.awt.event.MouseEvent) - */ - public void mouseClicked(MouseEvent e) { - if (SwingUtilities.isRightMouseButton(e)) - popupMenu.show((Component)e.getSource(), e.getX(), e.getY()); - } - - /* (non-Javadoc) - * @see java.awt.event.MouseListener#mouseEntered(java.awt.event.MouseEvent) - */ - public void mouseEntered(MouseEvent e) { - } - - /* (non-Javadoc) - * @see java.awt.event.MouseListener#mouseExited(java.awt.event.MouseEvent) - */ - public void mouseExited(MouseEvent e) { - } - - /* (non-Javadoc) - * @see java.awt.event.MouseListener#mousePressed(java.awt.event.MouseEvent) - */ - public void mousePressed(MouseEvent e) { - } - - /* (non-Javadoc) - * @see java.awt.event.MouseListener#mouseReleased(java.awt.event.MouseEvent) - */ - public void mouseReleased(MouseEvent e) { - } - - /* (non-Javadoc) - * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent) - */ - public void actionPerformed(ActionEvent e) { - if (e.getSource() == mRefresh) - { - if (m_goals != null) - for (int i=0; i < m_goals.length; i++) - m_goals[i].updateGoal(true); - htmlUpdate(lastUrl); - Container parent = getParent(); - if (parent != null) - parent.invalidate(); - invalidate(); - if (parent != null) - parent.repaint(); - else - repaint(); - } - } - - static class PageLoader implements Runnable - { - private JEditorPane html; - private URL url; - private Cursor cursor; - - PageLoader( JEditorPane html, URL url, Cursor cursor ) - { - this.html = html; - this.url = url; - this.cursor = cursor; - } - - public void run() - { - if( url == null ) - { - // restore the original cursor - html.setCursor( cursor ); - - // PENDING(prinz) remove this hack when - // automatic validation is activated. - Container parent = html.getParent(); - parent.repaint(); - } - else - { - Document doc = html.getDocument(); - try { - html.setPage( url ); - } - catch( IOException ioe ) - { - html.setDocument( doc ); - } - finally - { - // schedule the cursor to revert after - // the paint has happended. - url = null; - SwingUtilities.invokeLater( this ); - } - } - } - } -} diff --git a/org.adempiere.ui.swing/src/org/adempiere/apps/graph/PAPanel.java b/org.adempiere.ui.swing/src/org/adempiere/apps/graph/PAPanel.java deleted file mode 100644 index 00505157b2..0000000000 --- a/org.adempiere.ui.swing/src/org/adempiere/apps/graph/PAPanel.java +++ /dev/null @@ -1,185 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ -package org.adempiere.apps.graph; - -import java.awt.BorderLayout; -import java.awt.Dimension; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.util.logging.Level; - -import javax.swing.Box; -import javax.swing.JScrollPane; -import javax.swing.ScrollPaneConstants; - -import org.compiere.model.MGoal; -import org.compiere.swing.CPanel; -import org.compiere.util.CLogger; -import org.compiere.util.Env; - -/** - * Performance Analysis Panel. - * Key Performace Indicators - * - * @author Jorg Janke - * @version $Id: PAPanel.java,v 1.2 2006/07/30 00:51:28 jjanke Exp $ - */ -public class PAPanel extends CPanel implements ActionListener -{ - /** - * - */ - private static final long serialVersionUID = 4937417260772233929L; - - /** - * Get Panel if User has Perfpormance Goals - * @return panel pr null - */ - public static PAPanel get() - { - int AD_User_ID = Env.getAD_User_ID(Env.getCtx()); - MGoal[] goals = MGoal.getUserGoals(Env.getCtx(), AD_User_ID); - if (goals.length == 0) - return null; - return new PAPanel(goals); - } // get - - - /************************************************************************** - * Constructor - * @param goals - */ - private PAPanel (MGoal[] goals) - { - super (); - m_goals = goals; - init(); - } // PAPanel - - /** Goals */ - private MGoal[] m_goals = null; - - /** Logger */ - private static CLogger log = CLogger.getCLogger (PAPanel.class); - - /** - * Static/Dynamic Init - */ - private void init() - { - /* BOXES: - * - * boxV Header - * ******** - * boxH - * - * boxH * * * - * * boxV1 * boxV2 * - * * * * - * - * boxV1 dial1 - * ******** - * dial2 - * - * boxV2 HTML - * ******** - * boxH1 - * - * boxH1 * * * - * * bar1 * bar2 * - * * * * - * - * - * V1 + HTML in scrollpane - */ - - this.setLayout(new BorderLayout()); - - // HEADER - Box boxV = Box.createVerticalBox(); - // DIALS/HTML+Bars - Box boxH = Box.createHorizontalBox(); - // DIALS - Box boxV1 = Box.createVerticalBox(); - // HTML/Bars - Box boxV2 = Box.createVerticalBox(); - // barChart - Box boxH1 = Box.createHorizontalBox(); - //boxH_V.setPreferredSize(new Dimension(180, 1500)); - //boxH1.setPreferredSize(new Dimension(400, 180)); - boxV2.setPreferredSize(new Dimension(120, 120)); - - // DIALS below HEADER, LEFT - for (int i = 0; i < m_goals.length; i++) - { - PerformanceIndicator pi = new PerformanceIndicator(m_goals[i]); - pi.addActionListener(this); - boxV1.add (pi, BorderLayout.NORTH); - } - boxV1.add(Box.createVerticalGlue(), BorderLayout.CENTER); - JScrollPane scrollPane = new JScrollPane(); - scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); - scrollPane.getViewport().add(boxV1, BorderLayout.CENTER ); - scrollPane.setMinimumSize(new Dimension(190, 180)); - - // RIGHT, HTML + Bars - HtmlDashboard contentHtml = new HtmlDashboard("http:///local/home", m_goals, true); - boxV2.add(contentHtml, BorderLayout.CENTER); - - for (int i = 0; i < java.lang.Math.min(2, m_goals.length); i++) - { - if (m_goals[i].getMeasure() != null) //MGoal goal = pi.getGoal(); - boxH1.add ( new Graph(m_goals[i]), BorderLayout.SOUTH); - } - boxV2.add(boxH1, BorderLayout.SOUTH); - - // below HEADER - boxH.add(scrollPane, BorderLayout.WEST ); - boxH.add(Box.createHorizontalStrut(5)); //space - boxH.add(boxV2, BorderLayout.CENTER); - - // HEADER + below - HtmlDashboard t = new HtmlDashboard("http:///local/logo", null, false); - t.setMaximumSize(new Dimension(2000,80)); - //t.setPreferredSize(new Dimension(200,10)); - //t.setMaximumSize(new Dimension(2000,10)); - boxV.add(t, BorderLayout.NORTH); - boxV.add(Box.createVerticalStrut(5)); //space - boxV.add(boxH, BorderLayout.CENTER); - boxV.add(Box.createVerticalGlue()); - - // WINDOW - add(boxV, BorderLayout.CENTER); - } // init - - /** - * Action Listener for Drill Down - * @param e event - */ - public void actionPerformed (ActionEvent e) - { - if (e.getSource() instanceof PerformanceIndicator) - { - PerformanceIndicator pi = (PerformanceIndicator)e.getSource(); - if (log.isLoggable(Level.INFO)) log.info(pi.getName()); - MGoal goal = pi.getGoal(); - if (goal.getMeasure() != null) - new PerformanceDetail(goal); - } - } // actionPerformed - -} // PAPanel diff --git a/org.adempiere.ui.swing/src/org/adempiere/apps/graph/PerformanceDetail.java b/org.adempiere.ui.swing/src/org/adempiere/apps/graph/PerformanceDetail.java deleted file mode 100644 index 44bde9b2dc..0000000000 --- a/org.adempiere.ui.swing/src/org/adempiere/apps/graph/PerformanceDetail.java +++ /dev/null @@ -1,83 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ -package org.adempiere.apps.graph; - -import java.awt.BorderLayout; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; - -import org.compiere.Adempiere; -import org.compiere.apps.AEnv; -import org.compiere.apps.ConfirmPanel; -import org.compiere.model.MGoal; -import org.compiere.swing.CFrame; - - -/** - * Performance Detail Frame. - * BarPanel for Drill-Down - * - * @author Jorg Janke - * @version $Id: PerformanceDetail.java,v 1.2 2006/07/30 00:51:28 jjanke Exp $ - */ -public class PerformanceDetail extends CFrame - implements ActionListener -{ - /** - * - */ - private static final long serialVersionUID = -5994488373513922522L; - - /** - * Constructor. - * Called from PAPanel, ViewPI (Performance Indicator) - * @param goal goal - */ - public PerformanceDetail (MGoal goal) - { - super (goal.getName()); - setIconImage(Adempiere.getImage16()); - barPanel = new Graph(goal, true); - init(); - AEnv.addToWindowManager(this); - AEnv.showCenterScreen(this); - } // PerformanceDetail - - Graph barPanel = null; - ConfirmPanel confirmPanel = new ConfirmPanel(); - - /** - * Static init - */ - private void init() - { - getContentPane().add(barPanel, BorderLayout.CENTER); - getContentPane().add(confirmPanel, BorderLayout.SOUTH); - confirmPanel.addActionListener(this); - } // init - - /** - * Action Listener - * @param e event - */ - public void actionPerformed (ActionEvent e) - { - if (e.getActionCommand().equals(ConfirmPanel.A_OK)) - dispose(); - } // actionPerformed - -} // PerformanceDetail diff --git a/org.adempiere.ui.swing/src/org/adempiere/apps/graph/PerformanceIndicator.java b/org.adempiere.ui.swing/src/org/adempiere/apps/graph/PerformanceIndicator.java deleted file mode 100644 index eb7d8b2161..0000000000 --- a/org.adempiere.ui.swing/src/org/adempiere/apps/graph/PerformanceIndicator.java +++ /dev/null @@ -1,363 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ -package org.adempiere.apps.graph; - -import java.awt.BasicStroke; -import java.awt.BorderLayout; -import java.awt.Color; -import java.awt.Component; -import java.awt.Container; -import java.awt.Dimension; -import java.awt.Font; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.awt.event.MouseEvent; -import java.awt.event.MouseListener; -import java.text.DecimalFormat; - -import javax.swing.BorderFactory; -import javax.swing.JPanel; -import javax.swing.JPopupMenu; -import javax.swing.SwingUtilities; -import javax.swing.border.BevelBorder; -import javax.swing.event.EventListenerList; - -import org.compiere.model.MColorSchema; -import org.compiere.model.MGoal; -import org.compiere.swing.CMenuItem; -import org.compiere.util.DisplayType; -import org.compiere.util.Env; -import org.compiere.util.Msg; -import org.jfree.chart.ChartPanel; -import org.jfree.chart.JFreeChart; -import org.jfree.chart.plot.DialShape; -import org.jfree.chart.plot.MeterInterval; -import org.jfree.chart.plot.MeterPlot; -import org.jfree.data.Range; -import org.jfree.data.general.DefaultValueDataset; -import org.jfree.ui.RectangleInsets; - -/** - * Performance Indicator - * - * @author Jorg Janke - * @version $Id: PerformanceIndicator.java,v 1.2 2006/07/30 00:51:28 jjanke Exp $ - */ -//vpj-cd e-evolution public class PerformanceIndicator extends JComponent -public class PerformanceIndicator extends JPanel - implements MouseListener, ActionListener -{ - /** - * - */ - private static final long serialVersionUID = 2267850468607341211L; - - /** - * Constructor - * @param goal goal model - */ - public PerformanceIndicator(MGoal goal) - { - super(); - m_goal = goal; - setName(m_goal.getName()); - //vpj-cd e-evolution getPreferredSize(); // calculate size - init(); - // - setBorder(BorderFactory.createBevelBorder(BevelBorder.RAISED)); - setOpaque(true); - //vpj-cd e-evolution updateDisplay(); - - // - mRefresh.addActionListener(this); - popupMenu.add(mRefresh); - // - addMouseListener(this); - } // PerformanceIndicator - - private MGoal m_goal = null; - /** The Performance Name */ - private String m_text = null; - /** Performance Line */ - @SuppressWarnings("unused") - private double m_line = 0; - - /** Height */ - //private static double s_height = 45; - /** 100% width */ - private static double s_width100 = 150; - /** Max width */ - //private static double s_widthMax = 250; - /** Integer Number Format */ - private static DecimalFormat s_format = DisplayType.getNumberFormat(DisplayType.Integer); - - JPopupMenu popupMenu = new JPopupMenu(); - private CMenuItem mRefresh = new CMenuItem(Msg.getMsg(Env.getCtx(), "Refresh"), Env.getImageIcon("Refresh16.gif")); - - //Insert Pie Graph Kinamo (pelgrim) - //private static Color colorOK = Color.magenta; - //private static Color colorNotOK = Color.lightGray; - private static Dimension indicatordimension = new Dimension(170,120); - private static Dimension paneldimension = new Dimension(180, 150); - ChartPanel chartPanel; - //private static Dimension - - /** - * Get Goal - * @return goal - */ - public MGoal getGoal() - { - return m_goal; - } // getGoal - - - private JFreeChart createChart(){ - JFreeChart chart = null; - - // Set Text - StringBuilder text = new StringBuilder(m_goal.getName()); - if (m_goal.isTarget()) - text.append(": ").append(m_goal.getPercent()).append("%"); - else - text.append(": ").append(s_format.format(m_goal.getMeasureActual())); - - m_text = text.toString(); - - // ToolTip - text = new StringBuilder(); - if (m_goal.getDescription() != null) - text.append(m_goal.getDescription()).append(": "); - text.append(s_format.format(m_goal.getMeasureActual())); - if (m_goal.isTarget()) - text.append(" ").append(Msg.getMsg(Env.getCtx(), "of")).append(" ") - .append(s_format.format(m_goal.getMeasureTarget())); - setToolTipText(text.toString()); - // - //setBackground(m_goal.getColor()); - setForeground(GraphUtil.getForeground(getBackground())); - // Performance Line - int percent = m_goal.getPercent(); - if (percent > 100) // draw 100% line - m_line = s_width100; - else // draw Performance Line - m_line = s_width100 * m_goal.getGoalPerformanceDouble(); - - DefaultValueDataset data = new DefaultValueDataset((float)m_goal.getPercent()); - MeterPlot plot = new MeterPlot(data); - - MColorSchema colorSchema = m_goal.getColorSchema(); - int rangeLo = 0; int rangeHi=0; - for (int i=1; i<=4; i++){ - switch (i) { - case 1: rangeHi = colorSchema.getMark1Percent(); break; - case 2: rangeHi = colorSchema.getMark2Percent(); break; - case 3: rangeHi = colorSchema.getMark3Percent(); break; - case 4: rangeHi = colorSchema.getMark4Percent(); break; - } - if (rangeHi==9999) - rangeHi = (int) Math.floor(rangeLo*1.5); - if (rangeLo < rangeHi) { - plot.addInterval(new MeterInterval("Normal", //label - new Range(rangeLo, rangeHi), //range - colorSchema.getColor(rangeHi), - new BasicStroke(7.0f), - //Color.lightGray - new Color(-13091716) - //Color.gray - )); - rangeLo = rangeHi; - } - } - plot.setRange(new Range(0,rangeLo)); - - plot.setDialBackgroundPaint(new Color(-13091716));//Color.GRAY); - plot.setUnits(m_goal.getName()); - plot.setDialShape(DialShape.CHORD);//CIRCLE); - //plot.setDialBackgroundPaint(new GradientPaint(0, 0, m_goal.getColor(), 0, 1000, Color.black)); - plot.setNeedlePaint(Color.white); - plot.setTickSize(2000); - plot.setTickLabelFont(new Font("SansSerif", Font.BOLD, 12)); - plot.setTickLabelPaint(Color.white); - plot.setInsets(new RectangleInsets(1.0, 2.0, 3.0, 4.0)); - - chart = new JFreeChart( m_text, new Font("SansSerif", Font.BOLD, 15), plot,false); - - return chart; - } - /** - * Init Graph Display - * Kinamo (pelgrim) - */ - private void init() { - chartPanel = new ChartPanel(createChart(), //chart - false, //boolean properties - false, // boolean save - false, //boolean print - false, //boolean zoom - true //boolean tooltips - ); - chartPanel.setPreferredSize(indicatordimension); - - chartPanel.addChartMouseListener( new org.jfree.chart.ChartMouseListener() - { - public void chartMouseClicked(org.jfree.chart.ChartMouseEvent e) - { - //plot p = (MeterPlot) e.getSource(); - MouseEvent me = e.getTrigger(); - if (SwingUtilities.isLeftMouseButton(me) && me.getClickCount() > 1) - fireActionPerformed(me); - if (SwingUtilities.isRightMouseButton(me)) - popupMenu.show((Component)me.getSource(), me.getX(), me.getY()); - } - public void chartMouseMoved(org.jfree.chart.ChartMouseEvent e) - { - - } - }); - - this.add(chartPanel, BorderLayout.NORTH); - this.setMinimumSize(paneldimension); - this.setMaximumSize(paneldimension); - //--------------------------------------------- - - invalidate(); - } - - - /** - * Update Display Data - */ - protected void updateDisplay() - { - chartPanel.setChart(createChart()); - invalidate(); - - } // updateData - - /************************************************************************** - * Adds an ActionListener to the indicator. - * @param l the ActionListener to be added - */ - public void addActionListener(ActionListener l) - { - if (l != null) - listenerList.add(ActionListener.class, l); - } // addActionListener - - /** - * Removes an ActionListener from the indicator. - * @param l the listener to be removed - */ - public void removeActionListener(ActionListener l) - { - if (l != null) - listenerList.remove(ActionListener.class, l); - } // removeActionListener - - /** - * Returns an array of all the ActionListeners added - * to this indicator with addActionListener(). - * - * @return all of the ActionListeners added or an empty - * array if no listeners have been added - */ - public ActionListener[] getActionListeners() - { - return (ActionListener[])(listenerList.getListeners(ActionListener.class)); - } // getActionListeners - - /** - * Notifies all listeners that have registered interest for - * notification on this event type. The event instance - * is lazily created using the event - * parameter. - * - * @param event the ActionEvent object - * @see EventListenerList - */ - protected void fireActionPerformed(MouseEvent event) - { - // Guaranteed to return a non-null array - ActionListener[] listeners = getActionListeners(); - ActionEvent e = null; - // Process the listeners first to last - for (int i = 0; i < listeners.length; i++) - { - // Lazily create the event: - if (e == null) - e = new ActionEvent(this, ActionEvent.ACTION_PERFORMED, - "pi", event.getWhen(), event.getModifiersEx()); - listeners[i].actionPerformed(e); - } - } // fireActionPerformed - - - /************************************************************************** - * Mouse Clicked - * @param e mouse event - */ - public void mouseClicked (MouseEvent e) - { - if (SwingUtilities.isLeftMouseButton(e) && e.getClickCount() > 1) - fireActionPerformed(e); - if (SwingUtilities.isRightMouseButton(e)) - popupMenu.show((Component)e.getSource(), e.getX(), e.getY()); - } // mouseClicked - - public void mousePressed (MouseEvent e) - { - } - - public void mouseReleased (MouseEvent e) - { - } - - public void mouseEntered (MouseEvent e) - { - } - - public void mouseExited (MouseEvent e) - { - } - - /** - * Action Listener. - * Update Display - * @param e event - */ - public void actionPerformed (ActionEvent e) - { - if (e.getSource() == mRefresh) - { - m_goal.updateGoal(true); - updateDisplay(); - // - Container parent = getParent(); - if (parent != null) - parent.invalidate(); - invalidate(); - if (parent != null) - parent.repaint(); - else - repaint(); - } - } // actionPerformed - - - -} // PerformanceIndicator diff --git a/org.adempiere.ui.swing/src/org/adempiere/apps/graph/ViewPI.java b/org.adempiere.ui.swing/src/org/adempiere/apps/graph/ViewPI.java deleted file mode 100644 index 958fe5b9d1..0000000000 --- a/org.adempiere.ui.swing/src/org/adempiere/apps/graph/ViewPI.java +++ /dev/null @@ -1,148 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ -package org.adempiere.apps.graph; - -import java.awt.BorderLayout; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.util.logging.Level; - -import javax.swing.BoxLayout; - -import org.compiere.apps.ConfirmPanel; -import org.compiere.apps.form.FormFrame; -import org.compiere.apps.form.FormPanel; -import org.compiere.model.MGoal; -import org.compiere.swing.CPanel; -import org.compiere.swing.CScrollPane; -import org.compiere.util.CLogger; -import org.compiere.util.Env; - -/** - * View Performance Indicators - * - * @author Jorg Janke - * @version $Id: ViewPI.java,v 1.2 2006/07/30 00:51:28 jjanke Exp $ - */ -public class ViewPI extends CPanel -implements FormPanel, ActionListener -{ - /** - * - */ - private static final long serialVersionUID = 8022906851004145960L; - - - /** - * Init - * @param WindowNo - * @param frame - */ - public void init (int WindowNo, FormFrame frame) - { - log.fine(""); - m_WindowNo = WindowNo; - m_frame = frame; - try - { - // Top Selection Panel - // m_frame.getContentPane().add(selectionPanel, BorderLayout.NORTH); - // Center - initPanel(); - CScrollPane scroll = new CScrollPane (this); - m_frame.getContentPane().add(scroll, BorderLayout.CENTER); - // South - confirmPanel.addActionListener(this); - m_frame.getContentPane().add(confirmPanel, BorderLayout.SOUTH); - } - catch(Exception e) - { - log.log(Level.SEVERE, "", e); - } - sizeIt(); - } // init - - /** - * Size Window - */ - private void sizeIt() - { - // Frame - m_frame.pack(); - // Dimension size = m_frame.getPreferredSize(); - // size.width = WINDOW_WIDTH; - // m_frame.setSize(size); - } // size - - /** - * Dispose - */ - public void dispose() - { - if (m_frame != null) - m_frame.dispose(); - m_frame = null; - removeAll(); - } // dispose - - /** Window No */ - @SuppressWarnings("unused") - private int m_WindowNo = 0; - /** FormFrame */ - private FormFrame m_frame; - /** Logger */ - private static CLogger log = CLogger.getCLogger (ViewPI.class); - /** Confirmation Panel */ - private ConfirmPanel confirmPanel = new ConfirmPanel(); - - - /** - * Init Panel - */ - private void initPanel() - { - @SuppressWarnings("unused") - BoxLayout layout = new BoxLayout(this, BoxLayout.PAGE_AXIS); - MGoal[] goals = MGoal.getGoals(Env.getCtx()); - for (int i = 0; i < goals.length; i++) - { - PerformanceIndicator pi = new PerformanceIndicator(goals[i]); - pi.addActionListener(this); - add (pi); - } - } // initPanel - - - /** - * Action Listener for Drill Down - * @param e event - */ - public void actionPerformed (ActionEvent e) - { - if (e.getActionCommand().equals(ConfirmPanel.A_OK)) - dispose(); - else if (e.getSource() instanceof PerformanceIndicator) - { - PerformanceIndicator pi = (PerformanceIndicator)e.getSource(); - if (log.isLoggable(Level.INFO)) log.info(pi.getName()); - MGoal goal = pi.getGoal(); - if (goal.getMeasure() != null) - new PerformanceDetail(goal); - } - } // actionPerformed - -} // ViewPI diff --git a/org.adempiere.ui.swing/src/org/adempiere/client/Application.java b/org.adempiere.ui.swing/src/org/adempiere/client/Application.java deleted file mode 100644 index 951e3c24fc..0000000000 --- a/org.adempiere.ui.swing/src/org/adempiere/client/Application.java +++ /dev/null @@ -1,23 +0,0 @@ -package org.adempiere.client; - -import org.compiere.Adempiere; -import org.compiere.util.CLogger; -import org.eclipse.equinox.app.IApplication; -import org.eclipse.equinox.app.IApplicationContext; - -public class Application implements IApplication { - private static CLogger log = CLogger.getCLogger(Application.class); - - public Object start(IApplicationContext ctx) throws Exception { - log.info("Starting client"); - - // - Adempiere.startup(true); - org.compiere.AdempiereClient.main(new String[]{}); - return IApplication.EXIT_OK; - } - - public void stop() { - } - -} diff --git a/org.adempiere.ui.swing/src/org/adempiere/client/Client.java b/org.adempiere.ui.swing/src/org/adempiere/client/Client.java deleted file mode 100644 index 28ccc0ec37..0000000000 --- a/org.adempiere.ui.swing/src/org/adempiere/client/Client.java +++ /dev/null @@ -1,52 +0,0 @@ -/****************************************************************************** - * This file is part of Adempiere ERP Bazaar * - * http://www.adempiere.org * - * * - * Copyright (C) Jorg Viola * - * Copyright (C) Contributors * - * * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * * - * Contributors: * - * - Heng Sin Low * - *****************************************************************************/ -package org.adempiere.client; - -import java.util.List; - -import org.adempiere.base.Service; -import org.adempiere.ui.swing.factory.IFormFactory; -import org.compiere.apps.form.FormPanel; - -/** - * - * @author viola - * @author hengsin - */ -public class Client { - - /** - * @param formId - * @return new form instance - */ - public static FormPanel getFormPanel(String formId) { - List factories = Service.locator().list(IFormFactory.class).getServices(); - if (factories != null) { - for(IFormFactory factory : factories) { - FormPanel form = factory.newFormInstance(formId); - if (form != null) - return form; - } - } - return null; - } - -} diff --git a/org.adempiere.ui.swing/src/org/adempiere/client/ClientCredentialDialog.java b/org.adempiere.ui.swing/src/org/adempiere/client/ClientCredentialDialog.java deleted file mode 100644 index f1dd0ec164..0000000000 --- a/org.adempiere.ui.swing/src/org/adempiere/client/ClientCredentialDialog.java +++ /dev/null @@ -1,222 +0,0 @@ -/****************************************************************************** - * Copyright (C) 2010 Low Heng Sin All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - *****************************************************************************/ -package org.adempiere.client; - -import java.awt.BorderLayout; -import java.awt.Cursor; -import java.awt.Dialog; -import java.awt.GridBagConstraints; -import java.awt.GridBagLayout; -import java.awt.Insets; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.awt.event.WindowEvent; -import java.util.ResourceBundle; - -import javax.swing.JPasswordField; -import javax.swing.SwingConstants; - -import org.compiere.Adempiere; -import org.compiere.apps.ConfirmPanel; -import org.compiere.swing.CDialog; -import org.compiere.swing.CLabel; -import org.compiere.swing.CPanel; -import org.compiere.swing.CTextField; -import org.compiere.util.CLogger; -import org.compiere.util.Ini; - -/** - * - * @author hengsin - * - */ -public final class ClientCredentialDialog extends CDialog - implements ActionListener -{ - - /** - * generated serial version Id - */ - private static final long serialVersionUID = 2728290476926236505L; - - - /** - * Construct the dialog. - * Need to call initLogin for dynamic start - * @param parent parent - */ - public ClientCredentialDialog (Dialog parent) - { - super (parent, "Login", true); // Modal - log.finer(""); - setDefaultCloseOperation(DISPOSE_ON_CLOSE); - res = ResourceBundle.getBundle(RESOURCE); - // - try - { - jbInit(); - initLogin(); - } - catch(Exception e) - { - log.severe(e.toString()); - } - // Focus to OK - this.getRootPane().setDefaultButton(confirmPanel.getOKButton()); - parent.setIconImage(Adempiere.getImage16()); - } // ALogin - - - protected static final String RESOURCE = "org.compiere.apps.ALoginRes"; - private static ResourceBundle res = ResourceBundle.getBundle(RESOURCE); - /** Logger */ - private static CLogger log = CLogger.getCLogger(ClientCredentialDialog.class); - - private CPanel mainPanel = new CPanel(new BorderLayout()); - private CLabel userLabel = new CLabel(); - private CTextField userTextField = new CTextField(); - private CLabel passwordLabel = new CLabel(); - private JPasswordField passwordField = new JPasswordField(); - private GridBagLayout loginLayout = new GridBagLayout(); - private CPanel loginPanel = new CPanel(loginLayout); - private CPanel southPanel = new CPanel(); - private BorderLayout southLayout = new BorderLayout(); - private ConfirmPanel confirmPanel = new ConfirmPanel(true, false, false, false, false, false, false); - /** Combo Active */ - private boolean m_okPressed = false; - - - /************************************************************************** - * Component initialization - * @throws Exception - */ - private void jbInit() throws Exception - { - this.setName("Login"); - userLabel.setRequestFocusEnabled(false); - userLabel.setLabelFor(userTextField); - passwordLabel.setRequestFocusEnabled(false); - passwordLabel.setLabelFor(passwordField); - southPanel.setLayout(southLayout); - - userLabel.setHorizontalAlignment(SwingConstants.RIGHT); - userLabel.setText(res.getString("User")); - userLabel.setLabelFor(userTextField); - loginPanel.add(userLabel, new GridBagConstraints(0, 3, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 12, 5, 5), 0, 0)); - userTextField.setText("System"); // default - loginPanel.add(userTextField, new GridBagConstraints(1, 3, 3, 1, 1.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 0, 5, 12), 0, 0)); - passwordLabel.setHorizontalAlignment(SwingConstants.RIGHT); - passwordLabel.setText(res.getString("Password")); - passwordLabel.setLabelFor(passwordField); - loginPanel.add(passwordLabel, new GridBagConstraints(0, 4, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 12, 5, 5), 0, 0)); - passwordField.setText("System"); // default - loginPanel.add(passwordField, new GridBagConstraints(1, 4, 3, 1, 1.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 5, 12), 0, 0)); - - // - this.getContentPane().add(mainPanel); - mainPanel.add(loginPanel, BorderLayout.CENTER); - mainPanel.setName("loginMainPanel"); - mainPanel.add(southPanel, BorderLayout.SOUTH); - // - southPanel.add(confirmPanel, BorderLayout.NORTH); - confirmPanel.addActionListener(this); - } // jbInit - - /** - * Set Initial & Ini Parameters - * Optional Automatic login - * @return true, if connected & parameters set - */ - public boolean initLogin() - { - // Application/PWD - userTextField.setText(Ini.getProperty(Ini.P_UID)); - if (Ini.isPropertyBool(Ini.P_STORE_PWD)) - passwordField.setText(Ini.getProperty(Ini.P_PWD)); - else - passwordField.setText(""); - - return false; - } // initLogin - - /** - * Window Events - requestFocus - * @param e event - */ - protected void processWindowEvent(WindowEvent e) - { - super.processWindowEvent(e); - if (e.getID() == WindowEvent.WINDOW_OPENED) - { - this.toFront(); - confirmPanel.getOKButton().requestFocusInWindow(); - } - } // processWindowEvent - - /************************************************************************* - * Exit action performed - */ - private void appExit() - { - dispose(); - } // appExit_actionPerformed - - - /** - * Did the user press OK - * @return true if user pressed final OK button - */ - public boolean isOKpressed() - { - return m_okPressed; - } // isOKpressed - - /************************************************************************** - * Action Event handler - * @param e event - */ - public void actionPerformed(ActionEvent e) - { - if (e.getActionCommand().equals(ConfirmPanel.A_OK)) - { - setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); - m_okPressed = true; - appExit(); - } - else if (e.getActionCommand().equals(ConfirmPanel.A_CANCEL)) - { - m_okPressed = false; - appExit(); - } - } // actionPerformed - - /** - * @return user id - */ - public String getUserId() - { - return userTextField.getText(); - } - - /** - * @return password - */ - public char[] getPassword() - { - return passwordField.getPassword(); - } -} diff --git a/org.adempiere.ui.swing/src/org/adempiere/client/InfoManager.java b/org.adempiere.ui.swing/src/org/adempiere/client/InfoManager.java deleted file mode 100644 index eaa1eeac34..0000000000 --- a/org.adempiere.ui.swing/src/org/adempiere/client/InfoManager.java +++ /dev/null @@ -1,91 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 2010 Heng Sin Low * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - *****************************************************************************/ -package org.adempiere.client; - -import java.awt.Frame; -import java.util.List; - -import org.adempiere.base.Service; -import org.adempiere.ui.swing.factory.IInfoFactory; -import org.compiere.apps.search.Info; -import org.compiere.model.GridField; -import org.compiere.model.Lookup; - -/** - * - * @author hengsin - * - */ -public class InfoManager -{ - /** - * Factory Constructor - * @param frame parent frame - * @param modal new window is modal - * @param lookup Lookup - * @param field Grid field - * @param tableName table name of the search - * @param keyColumn key column of the search - * @param value query value - * @param multiSelection allow to select more than one row - * @param whereClause fully qualified where clause for the search - * @return special or general Info Window - */ - public static Info create(Frame frame, boolean modal, Lookup lookup, - GridField field, String tableName, String keyColumn, String queryValue, - boolean multiSelection, String whereClause) - { - Info info = null; - List factoryList = Service.locator().list(IInfoFactory.class).getServices(); - for(IInfoFactory factory : factoryList) - { - info = factory.create(frame, true, lookup, field, tableName, keyColumn, - queryValue, multiSelection, whereClause); - if (info != null) - break; - } - return info; - } - - /** - * Factory Constructor - * @param frame parent frame - * @param modal new window is modal - * @param WindowNo window no - * @param tableName table name of the search - * @param keyColumn key column of the search - * @param value query value - * @param multiSelection allow to select more than one row - * @param whereClause fully qualified where clause for the search - * @param lookup - * @return special or general Info Window - */ - public static Info create(Frame frame, boolean modal, int WindowNo, - String tableName, String keyColumn, String value, - boolean multiSelection, String whereClause, boolean lookup) - { - Info info = null; - - List factoryList = Service.locator().list(IInfoFactory.class).getServices(); - for(IInfoFactory factory : factoryList) - { - info = factory.create(frame, modal, WindowNo, tableName, keyColumn, value, - multiSelection, whereClause, lookup); - if (info != null) - break; - } - // - return info; - } -} diff --git a/org.adempiere.ui.swing/src/org/adempiere/pdf/viewer/22x22/document-print.png b/org.adempiere.ui.swing/src/org/adempiere/pdf/viewer/22x22/document-print.png deleted file mode 100644 index fdfe1c1c48..0000000000 Binary files a/org.adempiere.ui.swing/src/org/adempiere/pdf/viewer/22x22/document-print.png and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/adempiere/pdf/viewer/22x22/document-save.png b/org.adempiere.ui.swing/src/org/adempiere/pdf/viewer/22x22/document-save.png deleted file mode 100644 index a94e0eab97..0000000000 Binary files a/org.adempiere.ui.swing/src/org/adempiere/pdf/viewer/22x22/document-save.png and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/adempiere/pdf/viewer/22x22/go-first.png b/org.adempiere.ui.swing/src/org/adempiere/pdf/viewer/22x22/go-first.png deleted file mode 100644 index 77e517006b..0000000000 Binary files a/org.adempiere.ui.swing/src/org/adempiere/pdf/viewer/22x22/go-first.png and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/adempiere/pdf/viewer/22x22/go-last.png b/org.adempiere.ui.swing/src/org/adempiere/pdf/viewer/22x22/go-last.png deleted file mode 100644 index 67884eacd6..0000000000 Binary files a/org.adempiere.ui.swing/src/org/adempiere/pdf/viewer/22x22/go-last.png and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/adempiere/pdf/viewer/22x22/go-next.png b/org.adempiere.ui.swing/src/org/adempiere/pdf/viewer/22x22/go-next.png deleted file mode 100644 index cf93647658..0000000000 Binary files a/org.adempiere.ui.swing/src/org/adempiere/pdf/viewer/22x22/go-next.png and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/adempiere/pdf/viewer/22x22/go-previous.png b/org.adempiere.ui.swing/src/org/adempiere/pdf/viewer/22x22/go-previous.png deleted file mode 100644 index 8f9020a38a..0000000000 Binary files a/org.adempiere.ui.swing/src/org/adempiere/pdf/viewer/22x22/go-previous.png and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/adempiere/pdf/viewer/22x22/rotate-cclock.png b/org.adempiere.ui.swing/src/org/adempiere/pdf/viewer/22x22/rotate-cclock.png deleted file mode 100644 index 6ec6465656..0000000000 Binary files a/org.adempiere.ui.swing/src/org/adempiere/pdf/viewer/22x22/rotate-cclock.png and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/adempiere/pdf/viewer/22x22/rotate-clock.png b/org.adempiere.ui.swing/src/org/adempiere/pdf/viewer/22x22/rotate-clock.png deleted file mode 100644 index e2c2626353..0000000000 Binary files a/org.adempiere.ui.swing/src/org/adempiere/pdf/viewer/22x22/rotate-clock.png and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/adempiere/pdf/viewer/22x22/rotate.png b/org.adempiere.ui.swing/src/org/adempiere/pdf/viewer/22x22/rotate.png deleted file mode 100644 index 138b44d428..0000000000 Binary files a/org.adempiere.ui.swing/src/org/adempiere/pdf/viewer/22x22/rotate.png and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/adempiere/pdf/viewer/22x22/system-search.png b/org.adempiere.ui.swing/src/org/adempiere/pdf/viewer/22x22/system-search.png deleted file mode 100644 index 4e522b23d8..0000000000 Binary files a/org.adempiere.ui.swing/src/org/adempiere/pdf/viewer/22x22/system-search.png and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/adempiere/pdf/viewer/22x22/zoom-in.png b/org.adempiere.ui.swing/src/org/adempiere/pdf/viewer/22x22/zoom-in.png deleted file mode 100644 index 3518ce5815..0000000000 Binary files a/org.adempiere.ui.swing/src/org/adempiere/pdf/viewer/22x22/zoom-in.png and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/adempiere/pdf/viewer/22x22/zoom-out.png b/org.adempiere.ui.swing/src/org/adempiere/pdf/viewer/22x22/zoom-out.png deleted file mode 100644 index b5a30c469b..0000000000 Binary files a/org.adempiere.ui.swing/src/org/adempiere/pdf/viewer/22x22/zoom-out.png and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/adempiere/pdf/viewer/48x48/document-print.png b/org.adempiere.ui.swing/src/org/adempiere/pdf/viewer/48x48/document-print.png deleted file mode 100644 index 30b6348d9a..0000000000 Binary files a/org.adempiere.ui.swing/src/org/adempiere/pdf/viewer/48x48/document-print.png and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/adempiere/pdf/viewer/48x48/document-save.png b/org.adempiere.ui.swing/src/org/adempiere/pdf/viewer/48x48/document-save.png deleted file mode 100644 index 55c77941ab..0000000000 Binary files a/org.adempiere.ui.swing/src/org/adempiere/pdf/viewer/48x48/document-save.png and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/adempiere/pdf/viewer/48x48/go-first.png b/org.adempiere.ui.swing/src/org/adempiere/pdf/viewer/48x48/go-first.png deleted file mode 100644 index c5509811e7..0000000000 Binary files a/org.adempiere.ui.swing/src/org/adempiere/pdf/viewer/48x48/go-first.png and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/adempiere/pdf/viewer/48x48/go-last.png b/org.adempiere.ui.swing/src/org/adempiere/pdf/viewer/48x48/go-last.png deleted file mode 100644 index e9f976bc54..0000000000 Binary files a/org.adempiere.ui.swing/src/org/adempiere/pdf/viewer/48x48/go-last.png and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/adempiere/pdf/viewer/48x48/go-next.png b/org.adempiere.ui.swing/src/org/adempiere/pdf/viewer/48x48/go-next.png deleted file mode 100644 index 5fae27b3d2..0000000000 Binary files a/org.adempiere.ui.swing/src/org/adempiere/pdf/viewer/48x48/go-next.png and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/adempiere/pdf/viewer/48x48/go-previous.png b/org.adempiere.ui.swing/src/org/adempiere/pdf/viewer/48x48/go-previous.png deleted file mode 100644 index 6e719b144f..0000000000 Binary files a/org.adempiere.ui.swing/src/org/adempiere/pdf/viewer/48x48/go-previous.png and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/adempiere/pdf/viewer/48x48/system-search.png b/org.adempiere.ui.swing/src/org/adempiere/pdf/viewer/48x48/system-search.png deleted file mode 100644 index dbd8d4e019..0000000000 Binary files a/org.adempiere.ui.swing/src/org/adempiere/pdf/viewer/48x48/system-search.png and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/adempiere/pdf/viewer/PDFViewerBean.java b/org.adempiere.ui.swing/src/org/adempiere/pdf/viewer/PDFViewerBean.java deleted file mode 100644 index f7e81e2534..0000000000 --- a/org.adempiere.ui.swing/src/org/adempiere/pdf/viewer/PDFViewerBean.java +++ /dev/null @@ -1,614 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 Adempiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - *****************************************************************************/ -package org.adempiere.pdf.viewer; - -import java.awt.BorderLayout; -import java.awt.Cursor; -import java.awt.Dimension; -import java.awt.GridBagLayout; -import java.awt.Toolkit; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.awt.event.FocusAdapter; -import java.awt.event.FocusEvent; -import java.awt.event.MouseAdapter; -import java.awt.event.MouseEvent; -import java.awt.image.FilteredImageSource; -import java.awt.image.RGBImageFilter; -import java.awt.print.PageFormat; -import java.awt.print.PrinterException; -import java.awt.print.PrinterJob; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; - -import javax.swing.AbstractAction; -import javax.swing.Action; -import javax.swing.ImageIcon; -import javax.swing.JButton; -import javax.swing.JComboBox; -import javax.swing.JComponent; -import javax.swing.JFileChooser; -import javax.swing.JLabel; -import javax.swing.JOptionPane; -import javax.swing.JPanel; -import javax.swing.JScrollPane; -import javax.swing.JTextField; -import javax.swing.JToolBar; -import javax.swing.SwingConstants; -import javax.swing.filechooser.FileFilter; - -import org.jpedal.PdfDecoder; - -/** - * PDF Viewer using jpedal - * @author Low Heng Sin - * - */ -public class PDFViewerBean extends JPanel { - /** - * - */ - private static final long serialVersionUID = -365936659584244L; - - private final PdfDecoder decoder = new PdfDecoder(); - private final JScrollPane center = new JScrollPane(decoder); - private final JTextField pageField = new JTextField(2); - private final JLabel pageCountLabel = new JLabel("00"); - private final JComboBox rotationSelect = new JComboBox(new String[] { - "0", "90", "180", "270"}); - private final JComboBox zoomSelect; - private final float[] zoomFactors = new float[] { - 0.25f, 0.33f, 0.50f, 0.75f, 1.00f, 1.50f, 2.00f, 4.00f, 8.00f}; - - private final Action printAction = new AbstractAction() { - /** - * - */ - private static final long serialVersionUID = -4038401603459821668L; - - public void actionPerformed(ActionEvent e) { - print(); - } - }; - - private final Action saveAction = new AbstractAction() { - /** - * - */ - private static final long serialVersionUID = 2556454917786013951L; - - public void actionPerformed(ActionEvent e) { - save(); - } - }; - - private final Action goFirstAction = new AbstractAction() { - /** - * - */ - private static final long serialVersionUID = 3012006964079877706L; - - public void actionPerformed(ActionEvent e) { - goFirst(); - } - }; - - private final Action goPreviousAction = new AbstractAction() { - /** - * - */ - private static final long serialVersionUID = 7146121058674779580L; - - public void actionPerformed(ActionEvent e) { - goPrevious(); - } - }; - - private final Action goNextAction = new AbstractAction() { - /** - * - */ - private static final long serialVersionUID = -535856649012053593L; - - public void actionPerformed(ActionEvent e) { - goNext(); - } - }; - - private final Action goLastAction = new AbstractAction() { - /** - * - */ - private static final long serialVersionUID = -9129162509234933692L; - - public void actionPerformed(ActionEvent e) { - goLast(); - } - }; - - private final Action zoomInAction = new AbstractAction() { - /** - * - */ - private static final long serialVersionUID = 8712227061870874820L; - - public void actionPerformed(ActionEvent e) { - zoomIn(); - } - }; - - private final Action zoomOutAction = new AbstractAction() { - /** - * - */ - private static final long serialVersionUID = -796771923722993041L; - - public void actionPerformed(ActionEvent e) { - zoomOut(); - } - }; - - private final Action rotateCClockAction = new AbstractAction() { - /** - * - */ - private static final long serialVersionUID = -5323310183497748731L; - - public void actionPerformed(ActionEvent e) { - rotateCClock(); - } - }; - - private final Action rotateClockAction = new AbstractAction() { - /** - * - */ - private static final long serialVersionUID = 7048804716310413300L; - - public void actionPerformed(ActionEvent e) { - rotateClock(); - } - }; - - private String filename; - private int currentPage = 1; - private int scaleStep = 3; - private int rotation = 0; - - private File tmpFile = null; - - public PDFViewerBean() { - final String[] zoomLabels = new String[zoomFactors.length]; - for (int i = 0; i < zoomFactors.length; i++) { - zoomLabels[i] = Integer.toString((int) (zoomFactors[i] * 100)); - } - zoomSelect = new JComboBox(zoomLabels); - - zoomSelect.addActionListener(new ActionListener() { - private boolean isAdjusting = false; - public void actionPerformed(ActionEvent e) { - if (isAdjusting) { - return; - } - isAdjusting = true; - try { - setScaleStep(zoomSelect.getSelectedIndex()); - } finally { - isAdjusting = false; - } - } - }); - - rotationSelect.addActionListener(new ActionListener() { - private boolean isAdjusting = false; - public void actionPerformed(ActionEvent e) { - if (isAdjusting) { - return; - } - isAdjusting = true; - try { - setRotation(rotationSelect.getSelectedIndex() * 90); - } finally { - isAdjusting = false; - } - } - }); - - setLayout(new BorderLayout()); - createToolBar(); - add(BorderLayout.CENTER, center); - pageField.addFocusListener(new FocusAdapter() { - public void focusGained(FocusEvent e) { - pageField.selectAll(); - } - }); - pageField.setHorizontalAlignment(SwingConstants.TRAILING); - pageField.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - setCurrentPage(Integer.parseInt(pageField.getText())); - } - }); - - setPreferredSize(new Dimension(480, 0)); - } - - public void setRotation(int rotation) { - this.rotation = rotation; - rotationSelect.setSelectedIndex(rotation / 90); - updateZoomRotate(); - } - - public void goFirst() { - setCurrentPage(1); - } - - public void goPrevious() { - setCurrentPage(currentPage - 1); - } - - public void goNext() { - setCurrentPage(currentPage + 1); - } - - public void goLast() { - setCurrentPage(decoder.getPageCount()); - } - - public void setCurrentPage(int page) { - if (page < 1 || page > decoder.getPageCount()) { - return; - } - - final Cursor oldCursor = getCursor(); - try { - setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); - decoder.setPageParameters(zoomFactors[scaleStep], page); - decoder.decodePage(page); - setRotation(decoder.getPdfPageData().getRotation(page)); - currentPage = page; - } catch (Exception e) { - e.printStackTrace(); - return; - } finally { - setCursor(oldCursor); - } - - goFirstAction.setEnabled(currentPage > 1); - goPreviousAction.setEnabled(currentPage > 1); - goNextAction.setEnabled(currentPage < decoder.getPageCount()); - goLastAction.setEnabled(currentPage < decoder.getPageCount()); - - pageField.setText(Integer.toString(currentPage)); - } - - public void zoomIn() { - setScaleStep(scaleStep + 1); - } - - public void zoomOut() { - setScaleStep(scaleStep - 1); - } - - public void rotateCClock() { - rotationSelect.setSelectedIndex( - (rotationSelect.getSelectedIndex() + 3) % 4); - } - - public void rotateClock() { - rotationSelect.setSelectedIndex( - (rotationSelect.getSelectedIndex() + 1) % 4); - } - - public void save() { - final JFileChooser fc = new JFileChooser(); - fc.setFileFilter(new FileFilter() { - - public String getDescription() { - return "PDF File"; - } - - public boolean accept(File f) { - return f.isDirectory() - || f.getName().toLowerCase().endsWith(".pdf"); - } - - }); - - if (fc.showSaveDialog(this) != JFileChooser.APPROVE_OPTION) { - return; - } - - File targetFile = fc.getSelectedFile(); - if (!targetFile.getName().toLowerCase().endsWith(".pdf")) { - targetFile = - new File(targetFile.getParentFile(), targetFile.getName() + ".pdf"); - } - if (targetFile.exists()) { - if (JOptionPane.showConfirmDialog(this, - "Do you want to overwrite the file?") - != JOptionPane.YES_OPTION) { - return; - } - } - - try { - final InputStream is = new FileInputStream(filename); - try { - final OutputStream os = new FileOutputStream(targetFile); - try { - final byte[] buffer = new byte[32768]; - for (int read; (read = is.read(buffer)) != -1; ) { - os.write(buffer, 0, read); - } - } finally { - os.close(); - } - } finally { - is.close(); - } - } catch (IOException e) { - e.printStackTrace(); - } - } - - public void print() { - PrinterJob printJob = PrinterJob.getPrinterJob(); - //decoder.enableScaledPrinting(false); - printJob.setPageable(decoder); - final PageFormat pf = printJob.defaultPage(); - decoder.setPageFormat(pf); - decoder.setTextPrint(PdfDecoder.TEXTGLYPHPRINT); - printJob.setPrintable(decoder, pf); - if (printJob.printDialog()) { - final Cursor oldCursor = getCursor(); - try { - setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); - printJob.print(); - } catch (PrinterException e) { - e.printStackTrace(); - } finally { - setCursor(oldCursor); - } - } - } - - protected void createToolBar() { - final JToolBar bar = new JToolBar(); - - bar.add(createActionButton(printAction, - null, - "22x22/document-print.png", - "Print document")); - bar.add(createActionButton(saveAction, - null, - "22x22/document-save.png", - "Save document")); - - //bar.addSeparator(new Dimension(10,0)); - - bar.add(createActionButton(goFirstAction, - null, - "22x22/go-first.png", - "First page")); - bar.add(createActionButton(goPreviousAction, - null, - "22x22/go-previous.png", - "Previos page")); - final JPanel pagePanel = createToolbarItemPanel(pageField); - - bar.add(pagePanel); - //bar.add(new JLabel("/")); - //bar.add(pageCountLabel); - bar.add(createActionButton(goNextAction, - null, - "22x22/go-next.png", - "Next page")); - bar.add(createActionButton(goLastAction, - null, - "22x22/go-last.png", - "Last page")); - - //bar.addSeparator(new Dimension(10,0)); - - bar.add(createActionButton(zoomOutAction, - null, - "22x22/zoom-out.png", - "Next page")); - bar.add(createToolbarItemPanel(zoomSelect)); - bar.add(createActionButton(zoomInAction, - null, - "22x22/zoom-in.png", - "Next page")); - - //bar.addSeparator(new Dimension(10,0)); - - bar.add(createActionButton(rotateCClockAction, - null, - "22x22/rotate-cclock.png", - "Next page")); - bar.add(createToolbarItemPanel(rotationSelect)); - bar.add(createActionButton(rotateClockAction, - null, - "22x22/rotate-clock.png", - "Next page")); - - bar.setFloatable(false); - add(BorderLayout.NORTH, bar); - } - - protected JPanel createToolbarItemPanel(JComponent component) { - final JPanel pagePanel = new JPanel(new GridBagLayout()); - pagePanel.add(component); - pagePanel.setMaximumSize(pagePanel.getPreferredSize()); - return pagePanel; - } - - public void loadPDF(String filename) { - this.filename = filename; - try { - decoder.closePdfFile(); - decoder.openPdfFile(filename); - pageCountLabel.setText(decoder.getPageCount() + " "); - setCurrentPage(1); - } catch (Exception e) { - e.printStackTrace(); - } - } - - protected JButton createActionButton(Action action, - String text, - String image, - String tooltip) { - final ImageIcon icon = - new ImageIcon(getClass().getResource(image)); - final double colorFactor = 0.9; - - final RGBImageFilter filter = new RGBImageFilter() { - public int filterRGB(int x, int y, int rgb) { - final int alpha = (rgb >> 24) & 0xff; - final int red = (rgb >> 16) & 0xff; - final int green = (rgb >> 8) & 0xff; - final int blue = (rgb ) & 0xff; - return ((int) (alpha * colorFactor) << 24) - | ((int) (red * colorFactor) << 16) - | ((int) (green * colorFactor) << 8) - | ((int) (blue * colorFactor)); - } - }; - - final ImageIcon darkerIcon = new ImageIcon( - Toolkit.getDefaultToolkit().createImage( - new FilteredImageSource(icon.getImage().getSource(), - filter))); - final JButton result = new JButton(); - result.setAction(action); - result.setText(text); - result.setIcon(darkerIcon); - result.setBorderPainted(false); - result.setHorizontalTextPosition(SwingConstants.CENTER); - result.setVerticalTextPosition(SwingConstants.BOTTOM); - result.setMnemonic(0); - result.setToolTipText(tooltip); - - final Dimension dim = result.getPreferredSize(); - result.setMaximumSize(new Dimension(32, dim.height)); - - result.addMouseListener(new MouseAdapter() { - public void mouseEntered(MouseEvent me) { - result.setBorderPainted(true); - result.setIcon(icon); - } - public void mouseExited(MouseEvent me) { - result.setBorderPainted(false); - result.setIcon(darkerIcon); - } - }); - - result.setBorderPainted(false); - result.setFocusPainted(false); - - return result; - } - - public int getCurrentPage() { - return currentPage; - } - - public void clearDocument() { - decoder.closePdfFile(); - if (tmpFile != null) { - tmpFile.delete(); - tmpFile = null; - } - } - - public void setScaleStep(int scaleStep) { - if (scaleStep < 0 || zoomFactors.length <= scaleStep) { - return; - } - - this.scaleStep = scaleStep; - zoomSelect.setSelectedIndex(scaleStep); - updateZoomRotate(); - } - - protected void updateZoomRotate() { - final Cursor oldCursor = getCursor(); - try { - setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); - decoder.setPageParameters(zoomFactors[scaleStep], - currentPage, - rotation); - decoder.invalidate(); - decoder.repaint(); - zoomInAction.setEnabled(scaleStep < zoomFactors.length - 1); - zoomOutAction.setEnabled(scaleStep > 0); - } finally { - setCursor(oldCursor); - } - } - - public void setScale(int percent) { - int step; - for (step = 0; step < zoomFactors.length - 1; step++) { - if (zoomFactors[step] * 100 >= percent) { - break; - } - } - setScaleStep(step); - } - - public void loadPDF(InputStream is) { - if (tmpFile != null) { - tmpFile.delete(); - } - - try { - tmpFile = File.createTempFile("adempiere", ".pdf"); - tmpFile.deleteOnExit(); - } catch (IOException e) { - e.printStackTrace(); - return; - } - - try { - final OutputStream os = new FileOutputStream(tmpFile); - try { - final byte[] buffer = new byte[32768]; - for (int read; (read = is.read(buffer)) != -1; ) { - os.write(buffer, 0, read); - } - } catch (IOException e) { - e.printStackTrace(); - } finally { - os.close(); - } - } catch (IOException e) { - e.printStackTrace(); - } - - loadPDF(tmpFile.getAbsolutePath()); - } - - protected void finalize() throws Throwable { - if (tmpFile != null) { - tmpFile.delete(); - } - decoder.closePdfFile(); - } -} diff --git a/org.adempiere.ui.swing/src/org/adempiere/plaf/AdempiereButtonListener.java b/org.adempiere.ui.swing/src/org/adempiere/plaf/AdempiereButtonListener.java deleted file mode 100644 index edee8a5f21..0000000000 --- a/org.adempiere.ui.swing/src/org/adempiere/plaf/AdempiereButtonListener.java +++ /dev/null @@ -1,102 +0,0 @@ -/****************************************************************************** - * The contents of this file are subject to the Compiere License Version 1.1 - * ("License"); You may not use this file except in compliance with the License - * You may obtain a copy of the License at http://www.compiere.org/license.html - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for - * the specific language governing rights and limitations under the License. - * The Original Code is Compiere ERP & CRM Smart Business Solution. The Initial - * Developer of the Original Code is Jorg Janke. Portions created by Jorg Janke - * are Copyright (C) 1999-2005 Jorg Janke. - * All parts are Copyright (C) 1999-2005 ComPiere, Inc. All Rights Reserved. - * Contributor(s): ______________________________________. - *****************************************************************************/ -package org.adempiere.plaf; - -import java.awt.event.ActionEvent; -import java.beans.PropertyChangeEvent; - -import javax.swing.AbstractButton; -import javax.swing.InputMap; -import javax.swing.JCheckBox; -import javax.swing.JComponent; -import javax.swing.KeyStroke; -import javax.swing.SwingUtilities; -import javax.swing.plaf.ComponentInputMapUIResource; -import javax.swing.plaf.basic.BasicButtonListener; - -/** - * Button Listener - * - * @author Jorg Janke - * @version $Id: CompiereButtonListener.java,v 1.1 2005/12/05 02:38:28 jjanke Exp $ - */ -public class AdempiereButtonListener extends BasicButtonListener -{ - /** - * Adempiere Button Listener - * @param b button - */ - public AdempiereButtonListener (AbstractButton b) - { - super (b); - } // AdempiereButtonListener - - /** - * Install Keyboard Actions - * @param c component - */ - public void installKeyboardActions (JComponent c) - { - super.installKeyboardActions (c); - updateMnemonicBindingX ((AbstractButton)c); - } // installKeyboardActions - - /** - * Property Change - * @param e event - */ - public void propertyChange (PropertyChangeEvent e) - { - String prop = e.getPropertyName(); - if (prop.equals(AbstractButton.MNEMONIC_CHANGED_PROPERTY)) - updateMnemonicBindingX ((AbstractButton)e.getSource()); - else - super.propertyChange (e); - } // propertyChange - - /** - * Update Mnemonic Binding - * @param b button - */ - void updateMnemonicBindingX (AbstractButton b) - { - int m = b.getMnemonic(); - if (m != 0) - { - InputMap map = SwingUtilities.getUIInputMap(b, JComponent.WHEN_IN_FOCUSED_WINDOW); - - if (map == null) - { - map = new ComponentInputMapUIResource(b); - SwingUtilities.replaceUIInputMap(b, JComponent.WHEN_IN_FOCUSED_WINDOW, map); - } - map.clear(); - String className = b.getClass().getName(); - int mask = ActionEvent.ALT_MASK; // Default Buttons - if (b instanceof JCheckBox // In Tab - || className.indexOf("VButton") != -1) - mask = ActionEvent.SHIFT_MASK + ActionEvent.CTRL_MASK; - map.put(KeyStroke.getKeyStroke(m, mask, false), "pressed"); - map.put(KeyStroke.getKeyStroke(m, mask, true), "released"); - map.put(KeyStroke.getKeyStroke(m, 0, true), "released"); - } - else - { - InputMap map = SwingUtilities.getUIInputMap(b, JComponent.WHEN_IN_FOCUSED_WINDOW); - if (map != null) - map.clear(); - } - } // updateMnemonicBindingX - -} // AdempiereButtonListener diff --git a/org.adempiere.ui.swing/src/org/adempiere/plaf/AdempiereComboBoxUI.java b/org.adempiere.ui.swing/src/org/adempiere/plaf/AdempiereComboBoxUI.java deleted file mode 100644 index 0ebb0ee66b..0000000000 --- a/org.adempiere.ui.swing/src/org/adempiere/plaf/AdempiereComboBoxUI.java +++ /dev/null @@ -1,109 +0,0 @@ -/****************************************************************************** - * The contents of this file are subject to the Compiere License Version 1.1 - * ("License"); You may not use this file except in compliance with the License - * You may obtain a copy of the License at http://www.compiere.org/license.html - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for - * the specific language governing rights and limitations under the License. - * The Original Code is Compiere ERP & CRM Smart Business Solution. The Initial - * Developer of the Original Code is Jorg Janke. Portions created by Jorg Janke - * are Copyright (C) 1999-2005 Jorg Janke. - * All parts are Copyright (C) 1999-2005 ComPiere, Inc. All Rights Reserved. - * Contributor(s): ______________________________________. - *****************************************************************************/ -package org.adempiere.plaf; - -import java.awt.event.MouseListener; - -import javax.swing.Icon; -import javax.swing.JButton; -import javax.swing.JComponent; -import javax.swing.plaf.ComponentUI; -import javax.swing.plaf.basic.ComboPopup; -import javax.swing.plaf.metal.MetalComboBoxButton; - -import com.jgoodies.looks.plastic.PlasticComboBoxUI; - -/** - * Compiere ComboBox UI. - * The ComboBox is opaque - with opaque arrow button and textfield background - * - * @author Jorg Janke - * @version $Id: CompiereComboBoxUI.java,v 1.10 2005/10/09 19:01:37 jjanke Exp $ - */ -public class AdempiereComboBoxUI extends PlasticComboBoxUI -{ - /** - * Create UI - * @param c - * @return new instance of CompiereComboBoxUI - */ - public static ComponentUI createUI(JComponent c) - { - return new AdempiereComboBoxUI(); - } // CreateUI - - /*************************************************************************/ - - static int s_no = 0; - /** - * Install UI - Set ComboBox opaque. - * Bug in Metal: arrowButton gets Mouse Events, so add the JComboBox - * MouseListeners to the arrowButton - * @see org.compiere.swing.CComboBox#addMouseListener(MouseListener) - * @param c componrnt - */ - public void installUI (JComponent c) - { - MouseListener[] ml = c.getMouseListeners(); - super.installUI(c); - //c.setOpaque(false); - // - for (int i = 0; i < ml.length; i++) - { - // System.out.println("adding " + c.getClass().getName()); - arrowButton.addMouseListener(ml[i]); - } - - } // installUI - - /*************************************************************************/ - - /** - * Create opaque button - * @return opaque button - */ - protected JButton createArrowButton() - { - JButton button = super.createArrowButton(); - return button; - } // createArrowButton - - public JButton getArrowButton() - { - return arrowButton; - } - - /** - * Set Icon of arrow button - * @param defaultIcon - */ - public void setIcon(Icon defaultIcon) - { - ((MetalComboBoxButton)arrowButton).setComboIcon(defaultIcon); - } // setIcon - - /*************************************************************************/ - - /** - * Create Popup - * @return AdempiereComboPopup - */ - protected ComboPopup createPopup() - { - AdempiereComboPopup newPopup = new AdempiereComboPopup( comboBox ); - newPopup.getAccessibleContext().setAccessibleParent(comboBox); - return newPopup; - } // createPopup - -} // AdempiereComboBoxUI diff --git a/org.adempiere.ui.swing/src/org/adempiere/plaf/AdempiereComboPopup.java b/org.adempiere.ui.swing/src/org/adempiere/plaf/AdempiereComboPopup.java deleted file mode 100644 index c9f6e18802..0000000000 --- a/org.adempiere.ui.swing/src/org/adempiere/plaf/AdempiereComboPopup.java +++ /dev/null @@ -1,97 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ -package org.adempiere.plaf; - -import javax.swing.JComboBox; -import javax.swing.plaf.basic.BasicComboPopup; - -import org.compiere.swing.CComboBox; -import org.compiere.swing.CField; - -/** - * Adempiere Combo Popup - allows to prevent the display of the popup - * - * @author Jorg Janke - * @version $Id: AdempiereComboPopup.java,v 1.2 2006/07/30 00:52:24 jjanke Exp $ - */ -public class AdempiereComboPopup extends BasicComboPopup -{ - /** - * - */ - private static final long serialVersionUID = 274215317393292721L; - - - /** - * Constructor - * @param combo - */ - public AdempiereComboPopup(JComboBox combo) - { - super(combo); - } // AdempiereComboPopup - - /** - * Conditionally show the Popup. - * If the combo is a CComboBox/CField, the return value of the - * method displayPopup determines if the popup is actually displayed - * @see CComboBox#displayPopup() - * @see CField#displayPopup() - */ - public void show() - { - // Check ComboBox if popup should be displayed - if (comboBox instanceof CComboBox && !((CComboBox)comboBox).displayPopup()) - return; - // Check Field if popup should be displayed - if (comboBox instanceof CField && !((CField)comboBox).displayPopup()) - return; - super.show(); - } // show - - - /** - * Inform CComboBox and CField that Popup was hidden - * @see CComboBox.hidingPopup - * @see CField.hidingPopup - * - public void hide() - { - super.hide(); - // Inform ComboBox that popup was hidden - if (comboBox instanceof CComboBox) - (CComboBox)comboBox).hidingPopup(); - else if (comboBox instanceof CComboBox) - (CComboBox)comboBox).hidingPopup(); - } // hided - /**/ - - /** - * @see javax.swing.plaf.basic.BasicComboPopup#getPopupHeightForRowCount(int) - **/ - @Override - protected int getPopupHeightForRowCount(int maxRowCount) - { - // ensure the combo box sized for the amount of data to be displayed - int rows = comboBox.getItemCount() < comboBox.getMaximumRowCount() - ? comboBox.getItemCount() - : comboBox.getMaximumRowCount() ; - - if (rows <= 0 ) rows = 1; - return super.getPopupHeightForRowCount(1) * rows; - } -} // AdempiereComboPopup diff --git a/org.adempiere.ui.swing/src/org/adempiere/plaf/AdempiereLabelUI.java b/org.adempiere.ui.swing/src/org/adempiere/plaf/AdempiereLabelUI.java deleted file mode 100644 index ac8de8ebb4..0000000000 --- a/org.adempiere.ui.swing/src/org/adempiere/plaf/AdempiereLabelUI.java +++ /dev/null @@ -1,161 +0,0 @@ -/****************************************************************************** - * The contents of this file are subject to the Compiere License Version 1.1 - * ("License"); You may not use this file except in compliance with the License - * You may obtain a copy of the License at http://www.compiere.org/license.html - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for - * the specific language governing rights and limitations under the License. - * The Original Code is Compiere ERP & CRM Smart Business Solution. The Initial - * Developer of the Original Code is Jorg Janke. Portions created by Jorg Janke - * are Copyright (C) 1999-2005 Jorg Janke. - * All parts are Copyright (C) 1999-2005 ComPiere, Inc. All Rights Reserved. - * Contributor(s): ______________________________________. - *****************************************************************************/ -package org.adempiere.plaf; - -import java.awt.Component; -import java.awt.Container; -import java.awt.FocusTraversalPolicy; -import java.awt.event.ActionEvent; - -import javax.swing.ActionMap; -import javax.swing.InputMap; -import javax.swing.JComponent; -import javax.swing.JLabel; -import javax.swing.KeyStroke; -import javax.swing.SwingUtilities; -import javax.swing.plaf.ComponentInputMapUIResource; -import javax.swing.plaf.metal.MetalLabelUI; - -import org.jdesktop.swingx.UIAction; - -/** - * Adempiere Label UI - * - * @author Jorg Janke - * @version $Id: CompiereLabelUI.java,v 1.2 2005/12/05 02:38:28 jjanke Exp $ - */ -public class AdempiereLabelUI extends MetalLabelUI -{ - /** Singleton */ - protected static AdempiereLabelUI adempiereLabelUI = new AdempiereLabelUI(); - - /** - * Create UI - * @param c component - * @return singleton - */ - public static AdempiereLabelUI createUI(JComponent c) - { - return adempiereLabelUI; - } // createUI - - /** - * Install Keyboard Actions - * @param l label - */ - protected void installKeyboardActions (JLabel l) - { - // super.installKeyboardActions(l); - int dka = l.getDisplayedMnemonic(); - if (dka != 0) - { - Component lf = l.getLabelFor(); - if (lf != null) - { - ActionMap actionMap = l.getActionMap(); - actionMap.put(PRESS, ACTION_PRESS); - InputMap inputMap = SwingUtilities.getUIInputMap (l, JComponent.WHEN_IN_FOCUSED_WINDOW); - if (inputMap == null) - { - inputMap = new ComponentInputMapUIResource (l); - SwingUtilities.replaceUIInputMap (l, JComponent.WHEN_IN_FOCUSED_WINDOW, inputMap); - } - inputMap.clear (); - inputMap.put (KeyStroke.getKeyStroke (dka, - ActionEvent.SHIFT_MASK+ActionEvent.CTRL_MASK, false), PRESS); - } - } - } // installKeyboardActions - - - /** Action Name */ - private static final String PRESS = "press"; - /** Press Action */ - private static PressAction ACTION_PRESS = new PressAction(); - - /** - * Compiere Label UI Actions - */ - private static class PressAction extends UIAction - { - - PressAction () - { - super (PRESS); - } - - public void actionPerformed (ActionEvent e) - { - JLabel label = (JLabel)e.getSource (); - String key = getName (); - if (key.equals(PRESS)) - { - doPress (label); - } - } // actionPerformed - - /** - * Do Press - Focus the Field - * @param label label - */ - private void doPress (JLabel label) - { - Component labelFor = label.getLabelFor (); - if (labelFor != null && labelFor.isEnabled ()) - { - Component owner = label.getLabelFor (); - if (owner instanceof Container - && ((Container)owner).isFocusCycleRoot ()) - { - owner.requestFocus (); - } - else - { - if (owner instanceof Container) - { - Container container = (Container)owner; - if (container.isFocusCycleRoot()) - { - FocusTraversalPolicy policy = container.getFocusTraversalPolicy(); - Component comp = policy.getDefaultComponent(container); - if (comp != null) - { - comp.requestFocus(); - return; - } - } - Container rootAncestor = container.getFocusCycleRootAncestor(); - if (rootAncestor != null) - { - FocusTraversalPolicy policy = rootAncestor.getFocusTraversalPolicy(); - Component comp = policy.getComponentAfter(rootAncestor, container); - if (comp != null && SwingUtilities.isDescendingFrom(comp, container)) - { - comp.requestFocus(); - return; - } - } - } - if (owner.isFocusable()) - { - owner.requestFocus(); - return; - } - // No Forcus - } - } - } // doPress - } // PressAction - -} // AdempiereLabelUI diff --git a/org.adempiere.ui.swing/src/org/adempiere/plaf/AdempiereLookAndFeel.java b/org.adempiere.ui.swing/src/org/adempiere/plaf/AdempiereLookAndFeel.java deleted file mode 100644 index 6808d8145b..0000000000 --- a/org.adempiere.ui.swing/src/org/adempiere/plaf/AdempiereLookAndFeel.java +++ /dev/null @@ -1,218 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 Adempiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - *****************************************************************************/ -package org.adempiere.plaf; - -import java.awt.Color; -import java.awt.Component; - -import javax.swing.UIDefaults; - -import com.jgoodies.looks.plastic.PlasticLookAndFeel; -import com.jgoodies.looks.plastic.PlasticTheme; - -/** - * Adempiere Look & Feel, based on JGoodies look and feel - * @author vpj-cd, Low Heng Sin - */ -public class AdempiereLookAndFeel extends com.jgoodies.looks.plastic.Plastic3DLookAndFeel -{ - /** - * - */ - private static final long serialVersionUID = 5681571518701552477L; - - /** - * Constructor - */ - public AdempiereLookAndFeel() - { - super(); - // System.setProperty("awt.visualbell", "true"); - } // CompiereLookAndFeel - - /** The name */ - public static final String NAME = "Adempiere"; - - /** The Theme */ - private static PlasticTheme s_adempiereTheme = new org.adempiere.plaf.AdempiereTheme(); - private static PlasticTheme s_theme = s_adempiereTheme; - - /** Paint Round Corners */ - protected static boolean ROUND = false; - - public static final String TABLEVEL = "TabLevel"; - - public static final String HIDE_IF_ONE_TAB = "adempiere.hideIfOneTab"; - - /** - * The Name - * @return Name - */ - public String getName() - { - return NAME; - } // getName - - /** - * The ID - * @return Name - */ - public String getID() - { - return NAME; - } // getID - - /** - * The Description - * @return description - */ - public String getDescription() - { - return "Adempiere Look & Feel - (c) 2001-2005 Victor Perez"; - } // getDescription - - - /************************************************************************** - * Get/Create Defaults - * @return UI Defaults - */ - public UIDefaults getDefaults() - { - //com.jgoodies.looks.plastic.PlasticLookAndFeel.setCurrentTheme(s_theme); - UIDefaults defaults = super.getDefaults(); // calls init..Defaults - return defaults; - } // getDefaults - - /** - * Creates the mapping from UI class IDs to ComponentUI classes, - * putting the ID-ComponentUI pairs in the passed-in defaults table. - * Each JComponent class specifies its own UI class ID string. - * - * @param table UI Defaults - */ - protected void initClassDefaults(UIDefaults table) - { - //System.out.println("AdempiereLookAndFeel.initClassDefaults"); - super.initClassDefaults( table); - // Overwrite - putDefault (table, "ComboBoxUI"); - putDefault (table, "LabelUI"); - putDefault (table, "TabbedPaneUI"); - - } // initClassDefaults - - /** - * Put "uiKey - ClassName" pair in UIDefaults - * @param table - * @param uiKey - */ - private void putDefault (UIDefaults table, String uiKey) - { - try - { - String className = "org.adempiere.plaf.Adempiere" + uiKey; - table.put(uiKey, className); - } - catch (Exception ex) - { - ex.printStackTrace(); - } - } // putDefault - - /** - * For overwriting Component defaults - * @param table - */ - protected void initSystemColorDefaults (UIDefaults table) - { - super.initSystemColorDefaults( table); - } // initSystemColorDefaults - - /** - * For overwriting Component defaults - * @param table - */ - protected void initComponentDefaults (UIDefaults table) - { - super.initComponentDefaults( table); - - // ComboBox defaults - Color c = table.getColor("TextField.background"); - table.put("ComboBox.background", c); - table.put("ComboBox.listBackground", c); - - // globalqss - Class lf = com.jgoodies.looks.plastic.PlasticLookAndFeel.class; - table.put("Tree.openIcon", makeIcon(lf, "icons/TreeOpen.gif")); - table.put("Tree.closedIcon", makeIcon(lf, "icons/TreeClosed.gif")); - table.put("Tree.leafIcon", makeIcon(lf, "icons/TreeLeaf.gif")); - - } // initComponentDefaults - - - /** - * Set Current Theme - * @param theme metal theme - */ - public static void setCurrentTheme (PlasticTheme theme) - { - if (theme != null) { - s_theme = theme; - PlasticLookAndFeel.setCurrentTheme(s_theme); - } - } // setCurrentTheme - - /** - * Get Current Theme - * @return Metal Theme - */ - public static PlasticTheme getCurrentTheme() - { - return s_theme; - } // getCurrentTheme - - /** - * Get default adempiere theme - * @return Metal Theme - */ - public static PlasticTheme getDefaultTheme() - { - return s_adempiereTheme; - } // getCurrentTheme - - /** - * Error Feedback. - *

    - * Invoked when the user attempts an invalid operation, - * such as pasting into an uneditable JTextField - * that has focus. - *

    - *

    - * If the user has enabled visual error indication on - * the desktop, this method will flash the caption bar - * of the active window. The user can also set the - * property awt.visualbell=true to achieve the same - * results. - *

    - * @param component Component the error occured in, may be - * null indicating the error condition is - * not directly associated with a - * Component. - */ - public void provideErrorFeedback (Component component) - { - super.provideErrorFeedback (component); - } // provideErrorFeedback - -} // AdempiereLookAndFeel diff --git a/org.adempiere.ui.swing/src/org/adempiere/plaf/AdempiereLookAndFeelAddons.java b/org.adempiere.ui.swing/src/org/adempiere/plaf/AdempiereLookAndFeelAddons.java deleted file mode 100644 index fd27e2dc6b..0000000000 --- a/org.adempiere.ui.swing/src/org/adempiere/plaf/AdempiereLookAndFeelAddons.java +++ /dev/null @@ -1,24 +0,0 @@ -package org.adempiere.plaf; - -import org.jdesktop.swingx.plaf.basic.BasicLookAndFeelAddons; - -public class AdempiereLookAndFeelAddons extends BasicLookAndFeelAddons { - public void initialize() { - super.initialize(); - loadDefaults(getDefaults()); - } - - public void uninitialize() { - super.uninitialize(); - unloadDefaults(getDefaults()); - } - - private Object[] getDefaults() { - Object[] defaults = - new Object[] { -// "DirectoryChooserUI", -// "org.jdesktop.jdnc.swing.plaf.windows.WindowsDirectoryChooserUI", - }; - return defaults; - } -} diff --git a/org.adempiere.ui.swing/src/org/adempiere/plaf/AdempierePLAF.java b/org.adempiere.ui.swing/src/org/adempiere/plaf/AdempierePLAF.java deleted file mode 100644 index 43b03a89a3..0000000000 --- a/org.adempiere.ui.swing/src/org/adempiere/plaf/AdempierePLAF.java +++ /dev/null @@ -1,736 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ -package org.adempiere.plaf; - -import java.awt.Color; -import java.awt.Dimension; -import java.awt.Font; -import java.awt.Insets; -import java.awt.Toolkit; -import java.awt.Window; -import java.lang.reflect.Method; -import java.lang.reflect.Modifier; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import java.util.ResourceBundle; -import java.util.logging.Level; -import java.util.logging.Logger; - -import javax.swing.ImageIcon; -import javax.swing.JOptionPane; -import javax.swing.LookAndFeel; -import javax.swing.SwingUtilities; -import javax.swing.UIManager; -import javax.swing.plaf.metal.MetalLookAndFeel; -import javax.swing.plaf.metal.MetalTheme; - -import org.compiere.plaf.CompiereLookAndFeel; -import org.compiere.plaf.CompiereThemeBlueMetal; -import org.compiere.plaf.CompiereThemeIce; -import org.compiere.swing.CButton; -import org.compiere.swing.ColorBlind; -import org.compiere.swing.ExtendedTheme; -import org.compiere.util.Ini; -import org.compiere.util.ValueNamePair; - -import com.jgoodies.looks.plastic.PlasticTheme; - -/** - * Variable Pluggable Look And Feel. - * Provides an easy access to the required currently active PLAF information - * - * @author Jorg Janke - * @version $Id: AdempierePLAF.java,v 1.3 2006/07/30 00:52:23 jjanke Exp $ - * - * @author Low Heng Sin - * @version 2006-11-27 - */ -public final class AdempierePLAF -{ - /** Logger */ - private static Logger log = Logger.getLogger(AdempierePLAF.class.getName()); - - /****** Background *******************************************************/ - - /** - * Return Normal field background color "text". - * Windows = white - * @return Color - */ - public static Color getFieldBackground_Normal() - { - // window => white - return ColorBlind.getDichromatColor(UIManager.getColor("text")); - } // getFieldBackground_Normal - - /** - * Return Error field background - * @return Color - */ - public static Color getFieldBackground_Error() - { - Color c = UIManager.getColor(ExtendedTheme.ERROR_BG_KEY); - if (c == null) - c = ExtendedTheme.DEFAULT_ERROR_BG; - return ColorBlind.getDichromatColor(c); - } // getFieldBackground_Error - - /** - * Return Mandatory field background color - * @return Color - */ - public static Color getFieldBackground_Mandatory() - { - Color c = UIManager.getColor(ExtendedTheme.MANDATORY_BG_KEY); - if (c == null) - c = ExtendedTheme.DEFAULT_MANDATORY_BG; - return ColorBlind.getDichromatColor(c); - } // getFieldBackground_Mandatory - - /** - * Return Inactive field background color - * @return Color - */ - public static Color getFieldBackground_Inactive() - { - Color c = UIManager.getColor(ExtendedTheme.INACTIVE_BG_KEY); - if ( c != null ) - return ColorBlind.getDichromatColor(c); - else - return getFieldBackground_Normal(); - } // getFieldBackground_Inactive - - /** - * Return Selected field background color - * @return Color - */ - public static Color getFieldBackground_Selected() - { - Color c = UIManager.getColor(ExtendedTheme.SELECTED_BG_KEY); - if (c == null) - c = ExtendedTheme.DEFAULT_SELECTED_BG; - return ColorBlind.getDichromatColor(c); - } // getFieldBackground_Selected - - /** - * Return ReadOnly field background color - * @return Color - */ - public static Color getFieldBackground_ReadOnly() - { - Color c = UIManager.getColor(ExtendedTheme.READONLY_BG_KEY); - if (c == null) - c = ExtendedTheme.DEFAULT_READONLY_BG; - return ColorBlind.getDichromatColor(c); - } // getFieldBackground_ReadOnly - - /** - * Return form background color "control". - * Windows = lightGray - * @return Color - */ - public static Color getFormBackground() - { - return ColorBlind.getDichromatColor(UIManager.getColor("control")); - } // getFormBackground - - /** - * Info Background Color "info" - * Windows = info (light yellow) - * @return Color - */ - public static Color getInfoBackground() - { - Color c = UIManager.getColor(ExtendedTheme.INFO_BG_KEY); - if (c == null) - c = UIManager.getColor("info"); - return ColorBlind.getDichromatColor(c); - } // getInfoBackground - - - /****** Text *************************************************************/ - - /** - * Normal field text foreground color "textText" - * Windows = black - * @return Color - */ - public static Color getTextColor_Normal() - { - return ColorBlind.getDichromatColor(UIManager.getColor("textText")); - } // getText_Normal - - /** - * OK Text Foreground Color (Theme) - * @return Color - */ - public static Color getTextColor_OK() - { - return getTextColor_Normal(); - } // getText_OK - - /** - * Issue Text Foreground Color (Theme) - * @return Color - */ - public static Color getTextColor_Issue() - { - Color c = UIManager.getColor(ExtendedTheme.ERROR_FG_KEY); - if (c == null) - c = ExtendedTheme.DEFAULT_ERROR_FG; - return ColorBlind.getDichromatColor(c); - } // getText_Issue - - /** - * Label Text foreground Color "controlText" - * Windows = black - * @return Color - */ - public static Color getTextColor_Label() - { - return ColorBlind.getDichromatColor(UIManager.getColor("controlText")); - } // getTextColor_Label - - /** - * Get Primary1 - * @return primary 1 - */ - public static Color getPrimary1() - { - return ColorBlind.getDichromatColor(MetalLookAndFeel.getCurrentTheme().getPrimaryControlDarkShadow()); - } - /** - * Get Primary2 - * @return primary 2 - */ - public static Color getPrimary2() - { - return ColorBlind.getDichromatColor(MetalLookAndFeel.getCurrentTheme().getPrimaryControlShadow()); - } - /** - * Get Primary3 - * @return primary 3 - */ - public static Color getPrimary3() - { - return ColorBlind.getDichromatColor(MetalLookAndFeel.getCurrentTheme().getPrimaryControl()); - } - /** - * Get Secondary 1 - * @return secondary 1 - */ - public static Color getSecondary1() - { - return ColorBlind.getDichromatColor(MetalLookAndFeel.getCurrentTheme().getControlDarkShadow()); - } - /** - * Get Secondary 2 - * @return secondary 2 - */ - public static Color getSecondary2() - { - return ColorBlind.getDichromatColor(MetalLookAndFeel.getCurrentTheme().getControlShadow()); - } - /** - * Get Secondary 3 - * @return secondary 3 - */ - public static Color getSecondary3() - { - return ColorBlind.getDichromatColor(MetalLookAndFeel.getCurrentTheme().getControl()); - } - - - /****** Fonts ************************************************************/ - - /** - * Get Header Font (window title font) - * @return font - */ - public static Font getFont_Header() - { - return MetalLookAndFeel.getWindowTitleFont(); - } // getFont_Header - - /** - * Get Field Font - * @return font - */ - public static Font getFont_Field() - { - return UIManager.getFont("TextField.font"); - } // getFont_Field - - /** - * Get Label Font - * @return font - */ - public static Font getFont_Label() - { - return UIManager.getFont("Label.font"); - } // setFont_Label - - /** - * Get Small (report) Font - * @return font - */ - public static Font getFont_Small() - { - return MetalLookAndFeel.getSubTextFont(); - } // setFont_Small - - /****** Available L&F ****************************************************/ - - /** Available Looks */ - private static ValueNamePair[] s_looks = null; - /** Default PLAF */ - private static ValueNamePair s_defaultPLAF = null; - /** Available Themes */ - private static ValueNamePair[] s_metalThemes = null; - private static ValueNamePair[] s_plasticThemes = null; - - //default theme - private static ValueNamePair s_vp_compiereTheme = null; - private static ValueNamePair s_vp_metalTheme = null; - //e-evolution vpj-cd 19102006 - private static ValueNamePair s_vp_adempiereTheme = null; - //e-evolution vpj-cd 1910200sky - - /** - * Static Initializer. - * - Fill available PLAFs and Themes - */ - static - { - ArrayList plafList = new ArrayList(); - //e-evolution vpj-cd 19102006 - ValueNamePair vp = null; - ArrayList metalThemes = new ArrayList(); - ArrayList plasticThemes = new ArrayList(); - - try - { - Class.forName("com.jgoodies.looks.plastic.Plastic3DLookAndFeel"); - vp = new ValueNamePair("org.adempiere.plaf.AdempiereLookAndFeel", org.adempiere.plaf.AdempiereLookAndFeel.NAME); - plafList.add(vp); - s_vp_adempiereTheme = new ValueNamePair("org.adempiere.plaf.AdempiereTheme", AdempiereThemeInnova.NAME); - plasticThemes.add (s_vp_adempiereTheme); - - List installedThemes = AdempiereLookAndFeel.getInstalledThemes(); - for(Object t : installedThemes) { - MetalTheme theme = (MetalTheme)t; - vp = new ValueNamePair(theme.getClass().getName(), theme.getName()); - plasticThemes.add(vp); - } - } - catch (Exception e) - { - log.severe("Plastic look and feel not found"); - } - //e-evolution vpj-cd 19102006 - vp = new ValueNamePair("org.compiere.plaf.CompiereLookAndFeel", CompiereLookAndFeel.NAME); - plafList.add (vp); - - //Metal - s_vp_compiereTheme = new ValueNamePair("org.compiere.plaf.CompiereThemeBlueMetal", CompiereThemeBlueMetal.NAME); - metalThemes.add (s_vp_compiereTheme); - metalThemes.add (new ValueNamePair("org.compiere.plaf.CompiereThemeIce", CompiereThemeIce.NAME)); - s_vp_metalTheme = new ValueNamePair("javax.swing.plaf.metal.OceanTheme", "Ocean"); - metalThemes.add (s_vp_metalTheme); - metalThemes.add (new ValueNamePair("javax.swing.plaf.metal.DefaultMetalTheme", "Steel")); - metalThemes.add (new ValueNamePair("org.compiere.plaf.AquaTheme", "Aqua")); - metalThemes.add (new ValueNamePair("org.compiere.plaf.CharcoalTheme", "Charcoal")); - metalThemes.add (new ValueNamePair("org.compiere.plaf.ContrastTheme", "Contrast")); - metalThemes.add (new ValueNamePair("org.compiere.plaf.EmeraldTheme", "Emerald")); - metalThemes.add (new ValueNamePair("org.compiere.plaf.RubyTheme", "Ruby")); - - // Install discovered PLAFs - for (int i = 0; i < plafList.size(); i++) - { - vp = plafList.get(i); - UIManager.installLookAndFeel(vp.getName(), vp.getValue()); - } - - // Fill Available PLAFs - plafList = new ArrayList(); - UIManager.LookAndFeelInfo[] lfInfo = UIManager.getInstalledLookAndFeels(); - for (int i = 0; i < lfInfo.length; i++) - { - vp = new ValueNamePair (lfInfo[i].getClassName(), lfInfo[i].getName()); - plafList.add(vp); - if (lfInfo[i].getName().equals(org.adempiere.plaf.AdempiereLookAndFeel.NAME)) - { - s_defaultPLAF = vp; - if (log.isLoggable(Level.FINEST)) log.finest(vp.getName() + " (default)"); - } - else - if (log.isLoggable(Level.FINEST)) log.finest(vp.getName()); - } - s_looks = new ValueNamePair[plafList.size()]; - plafList.toArray(s_looks); - - // Fill Available Themes - s_metalThemes = new ValueNamePair[metalThemes.size()]; - metalThemes.toArray(s_metalThemes); - - s_plasticThemes = new ValueNamePair[plasticThemes.size()]; - plasticThemes.toArray(s_plasticThemes); - // - // printPLAFDefaults(); - } // static Initializer - - - /** - * Get available Look And Feels - * @return Array of ValueNamePair with name and class of Look and Feel - */ - public static ValueNamePair[] getPLAFs() - { - return s_looks; - } // getPLAFs - - /** - * Get the list of available Metal or Plastic Themes. - * @return Array of Strings with Names of Metal Themes - */ - public static ValueNamePair[] getThemes () - { - LookAndFeel l = UIManager.getLookAndFeel(); - if ( l instanceof AdempiereLookAndFeel) - return s_plasticThemes; - else if ( l instanceof MetalLookAndFeel) - return s_metalThemes; - return new ValueNamePair[0]; - } // getThemes - - - /************************************************************************** - * Set PLAF based on Ini Properties - */ - public static void setPLAF () - { - String look = Ini.getProperty(Ini.P_UI_LOOK); - String lookTheme = Ini.getProperty(Ini.P_UI_THEME); - // Search for PLAF - ValueNamePair plaf = null; - for (int i = 0; i < s_looks.length; i++) - { - if (s_looks[i].getName().equals(look)) - { - plaf = s_looks[i]; - break; - } - } - // Search for Theme - ValueNamePair theme = null; - for (int i = 0; i < s_metalThemes.length; i++) - { - if (s_metalThemes[i].getName().equals(lookTheme)) - { - theme = s_metalThemes[i]; - break; - } - } - - if (theme == null) - { - for (int i = 0; i < s_plasticThemes.length; i++) - { - if (s_plasticThemes[i].getName().equals(lookTheme)) - { - theme = s_plasticThemes[i]; - break; - } - } - } - // Set PLAF - setPLAF (plaf == null ? s_defaultPLAF : plaf, theme, true); - } // setPLAF - - /** - * Set PLAF and update Ini - * - * @param plaf ValueNamePair of the PLAF to be set - * @param theme Optional Theme name - * @param upateIni Update setting to INI - */ - public static void setPLAF (ValueNamePair plaf, ValueNamePair theme, boolean updateIni) - { - if (plaf == null) - return; - if (log.isLoggable(Level.CONFIG)) log.config(plaf + (theme == null ? "" : (" - " + theme))); - - // Look & Feel - Class lafClass = null; - try { - lafClass = Class.forName(plaf.getValue()); - } - catch (Exception e) - { - log.severe(e.getMessage()); - return; - } - - if ( updateIni ) { - Ini.setProperty(Ini.P_UI_LOOK, plaf.getName()); - // Optional Theme - Ini.setProperty(Ini.P_UI_THEME, ""); - } - - // Default Theme - boolean metal = MetalLookAndFeel.class.isAssignableFrom(lafClass); - boolean adempiere = AdempiereLookAndFeel.class.isAssignableFrom(lafClass); - boolean compiere = CompiereLookAndFeel.class.isAssignableFrom(lafClass); - if (theme == null && metal) - { - if (compiere) - theme = s_vp_compiereTheme; - else if (adempiere) - theme = s_vp_adempiereTheme; - else - theme = s_vp_metalTheme; - } - if (theme != null && metal && theme.getValue().length() > 0) - { - try - { - Class c = Class.forName(theme.getValue()); - MetalTheme t = (MetalTheme)c.newInstance(); - if (compiere) - CompiereLookAndFeel.setCurrentTheme(t); - else if (adempiere && t instanceof PlasticTheme) - AdempiereLookAndFeel.setCurrentTheme((PlasticTheme)t); - else - MetalLookAndFeel.setCurrentTheme(t); - // - if (updateIni) - Ini.setProperty(Ini.P_UI_THEME, theme.getName()); - } - catch (Exception e) - { - log.severe("Theme - " + e.getMessage()); - } - } - try - { - UIManager.setLookAndFeel((LookAndFeel)lafClass.newInstance()); - } - catch (Exception e) - { - log.severe(e.getMessage()); - } - if (log.isLoggable(Level.CONFIG)) log.config(plaf + " - " + theme); - // printPLAFDefaults(); - } // setPLAF - - /** - * Update UI of this and parent Windows - * @param win window - */ - public static void updateUI (Window win) - { - if (win == null) - return; - Window c = win; - do - { - SwingUtilities.updateComponentTreeUI(c); - c.invalidate(); - c.pack(); - c.validate(); - c.repaint(); - c = c.getOwner(); - } - while (c != null); - } // updateUI - - /** - * Reset PLAF Settings - */ - public static void reset () - { - // Clean Theme Properties - AdempierePLAF.setPLAF (); - } // reset - - /** - * Print current UIDefaults - */ - public static void printPLAFDefaults () - { - System.out.println(UIManager.getLookAndFeel()); - Object[] keys = UIManager.getLookAndFeelDefaults().keySet().toArray(); - Arrays.sort(keys); - char lastStart = ' '; - for (int i = 0; i < keys.length; i++) - { - StringBuffer sb = new StringBuffer(); - sb.append(keys[i]).append(" = ").append(UIManager.get(keys[i])); - if (keys[i].toString().charAt(0) != lastStart) - { - System.out.println(); - lastStart = keys[i].toString().charAt(0); - } - System.out.println(sb); - } - } // printPLAFDefaults - - /** - * Is AdempiereL&F the active L&F - * @return true if L&F is Adempiere - */ - public static boolean isActive() - { - return UIManager.getLookAndFeel() instanceof AdempiereLookAndFeel; - } // isActive - - /*************************************************************************/ - - static ResourceBundle s_res = ResourceBundle.getBundle("org.compiere.plaf.PlafRes"); - - /** - * Create OK Button - * @return OK button - */ - public static CButton getOKButton() - { - CButton b = new CButton(); - b.setIcon(new ImageIcon(AdempierePLAF.class.getResource("icons/Ok24.gif"))); - b.setMargin(new Insets(0,10,0,10)); - b.setToolTipText (s_res.getString("OK")); - return b; - } // getOKButton - - /** - * Create Cancel Button - * @return Cancel button - */ - public static CButton getCancelButton() - { - CButton b = new CButton(); - b.setIcon(new ImageIcon(AdempierePLAF.class.getResource("icons/Cancel24.gif"))); - b.setMargin(new Insets(0,10,0,10)); - b.setToolTipText (s_res.getString("Cancel")); - return b; - } // getCancelButton - - /** - * Center Window on Screen and show it - * @param window window - */ - public static void showCenterScreen (Window window) - { - window.pack(); - Dimension sSize = Toolkit.getDefaultToolkit().getScreenSize(); - Dimension wSize = window.getSize(); - window.setLocation(((sSize.width-wSize.width)/2), ((sSize.height-wSize.height)/2)); - window.toFront(); - window.setVisible(true); - } // showCenterScreen - - /** - * Invoke the correct method to set current metal based theme. - * Supported look and feel are Metal, Plastic and Compiere. - * @param laf Metal based look and feel - * @param theme Metal based theme - */ - public static void setCurrentMetalTheme(MetalLookAndFeel laf, MetalTheme theme) - { - if (laf instanceof CompiereLookAndFeel) - CompiereLookAndFeel.setCurrentTheme(theme); - else if (laf instanceof AdempiereLookAndFeel && theme instanceof PlasticTheme) - AdempiereLookAndFeel.setCurrentTheme((PlasticTheme)theme); - else - MetalLookAndFeel.setCurrentTheme(theme); - } - - /************************************************************************** - * Start Class With Adempiere Look - * @param args first parameter is class to start, if none start PLAF Editor - */ - public static void main (String[] args) - { - String jVersion = System.getProperty("java.version"); - if (!(jVersion.startsWith("1.5"))) - { - JOptionPane.showMessageDialog (null, - "Require Java Version 1.5 or up - Not " + jVersion, - "AdempierePLAF - Version Conflict", - JOptionPane.ERROR_MESSAGE); - System.exit(1); - } - - // set the defined PLAF - Ini.loadProperties (true); - setPLAF (); - // - if (args.length == 0) - { - return; - } - - String className = args[0]; - // find class - Class startClass = null; - try - { - startClass = Class.forName(className); - } - catch (Exception e) - { - log.severe("Did not find: " + className); - e.printStackTrace(); - System.exit(1); - } - - // try static main method - try - { - Method[] methods = startClass.getMethods(); - if (methods.length > 0) - { - if (Modifier.isStatic(methods[0].getModifiers()) && methods[0].getName().equals("main")) - { - String[] startArgs = new String[args.length-1]; - for (int ii = 1; ii < args.length; ii++) - startArgs[ii] = args[ii]; - methods[0].invoke(null, new Object[] {startArgs}); - } - return; - } - } - catch (Exception ee) - { - log.severe("Problems invoking main"); - ee.printStackTrace(); - } - - // start the class - try - { - startClass.newInstance(); - } - catch (Exception e) - { - log.severe("Cannot start: " + className); - e.printStackTrace(); - System.exit(1); - } - } // main - -} // AdempierePLAF diff --git a/org.adempiere.ui.swing/src/org/adempiere/plaf/AdempiereTabbedPaneUI.java b/org.adempiere.ui.swing/src/org/adempiere/plaf/AdempiereTabbedPaneUI.java deleted file mode 100644 index 895d17a4a6..0000000000 --- a/org.adempiere.ui.swing/src/org/adempiere/plaf/AdempiereTabbedPaneUI.java +++ /dev/null @@ -1,3236 +0,0 @@ -/* - * Copyright (c) 2001-2006 JGoodies Karsten Lentzsch. All Rights Reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * o Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * o 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. - * - * o Neither the name of JGoodies Karsten Lentzsch nor the names of - * its contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * 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 OWNER 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 org.adempiere.plaf; - -import java.awt.Color; -import java.awt.Component; -import java.awt.Container; -import java.awt.Dimension; -import java.awt.Font; -import java.awt.FontMetrics; -import java.awt.Graphics; -import java.awt.Graphics2D; -import java.awt.Insets; -import java.awt.LayoutManager; -import java.awt.Point; -import java.awt.Polygon; -import java.awt.Rectangle; -import java.awt.Shape; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.awt.event.MouseEvent; -import java.beans.PropertyChangeEvent; -import java.beans.PropertyChangeListener; - -import javax.swing.AbstractAction; -import javax.swing.Action; -import javax.swing.ActionMap; -import javax.swing.Icon; -import javax.swing.JButton; -import javax.swing.JComponent; -import javax.swing.JPanel; -import javax.swing.JTabbedPane; -import javax.swing.JViewport; -import javax.swing.SwingConstants; -import javax.swing.SwingUtilities; -import javax.swing.UIManager; -import javax.swing.event.ChangeEvent; -import javax.swing.event.ChangeListener; -import javax.swing.plaf.ComponentUI; -import javax.swing.plaf.UIResource; -import javax.swing.plaf.basic.BasicTabbedPaneUI; -import javax.swing.plaf.metal.MetalTabbedPaneUI; -import javax.swing.text.View; - -import com.jgoodies.looks.LookUtils; -import com.jgoodies.looks.Options; -import com.jgoodies.looks.plastic.PlasticLookAndFeel; - -/** - * The JGoodies Plastic Look&Feel implementation of - * TabbedPaneUI. It differs from its superclass - * MetalTabbedPaneUI in that it paints new tab shapes, - * provides two options, and supports ClearLook. - *

    - * You can enable or disable icons in tabs globally via - * com.jgoodies.looks.Options.setTabIconsEnabled(boolean). - *

    - * To disable the content border set - *

    - * JTabbedPane tabbedPane = new JTabbedPane();
    - * tabbedPane.putClientProperty(Option.NO_CONTENT_BORDER_KEY, Boolean.TRUE);
    - * 
    - * To paint embedded tabs use - *
    - * JTabbedPane tabbedPane = new JTabbedPane();
    - * tabbedPane.putClientProperty(Option.EMBEDDED_TABS_KEY, Boolean.TRUE);
    - * 
    - *

    - * There's a special mode that helps you detect content borders in - * heavily wrapped component hierarchies - such as the NetBeans IDE. - * In this marked mode the content border is painted as a Magenta line. - * You can enable this mode by setting the System property - * markContentBorders to true; in a command line: - *

    - * java -DmarkContentBorders=true
    - * 
    - * - * @author Karsten Lentzsch - * @author Torge Husfeldt - * @author Andrej Golovnin - * @version $Revision: 1.4 $ - * - * @see Options - */ -public final class AdempiereTabbedPaneUI extends MetalTabbedPaneUI { - - - // State ****************************************************************** - - /** - * Describes if tabs are painted with or without icons. - */ - private static boolean isTabIconsEnabled = Options.isTabIconsEnabled(); - - /** - * Describes if we paint no content border or not; is false by default. - * You can disable the content border by setting the client property - * Options.NO_CONTENT_BORDER_KEY to Boolean.TRUE; - */ - private Boolean noContentBorder; - - /** - * Describes if we paint tabs in an embedded style that is with - * less decoration; this is false by default. - * You can enable the embedded tabs style by setting the client property - * Options.EMBEDDED_TABS_KEY to Boolean.TRUE. - */ - private Boolean embeddedTabs; - - /** - * Holds the renderer that is used to render the tabs. - */ - private AbstractRenderer renderer; - - - /** For use when tabLayoutPolicy == SCROLL_TAB_LAYOUT. */ - private ScrollableTabSupport tabScroller; - - private Boolean hideIfOneTab; - - /** - * Creates the PlasticTabbedPaneUI. - * - * @see javax.swing.plaf.ComponentUI#createUI(JComponent) - */ - public static ComponentUI createUI(JComponent tabPane) { - return new AdempiereTabbedPaneUI(); - } - - /** - * Installs the UI. - * - * @see javax.swing.plaf.ComponentUI#installUI(JComponent) - */ - public void installUI(JComponent c) { - super.installUI(c); - embeddedTabs = (Boolean) c.getClientProperty(Options.EMBEDDED_TABS_KEY); - noContentBorder = (Boolean) c.getClientProperty(Options.NO_CONTENT_BORDER_KEY); - hideIfOneTab = (Boolean) c.getClientProperty(AdempiereLookAndFeel.HIDE_IF_ONE_TAB); - renderer = createRenderer(tabPane); - } - - /** - * Uninstalls the UI. - * @see javax.swing.plaf.ComponentUI#uninstallUI(JComponent) - */ - public void uninstallUI(JComponent c) { - renderer = null; - super.uninstallUI(c); - } - - /** - * Creates and installs any required subcomponents for the JTabbedPane. - * Invoked by installUI. - * @see javax.swing.plaf.basic.BasicTabbedPaneUI#installComponents() - */ - protected void installComponents() { - if (scrollableTabLayoutEnabled()) { - if (tabScroller == null) { - tabScroller = new ScrollableTabSupport(tabPane.getTabPlacement()); - tabPane.add(tabScroller.viewport); - } - } - } - - /** - * Removes any installed subcomponents from the JTabbedPane. - * Invoked by uninstallUI. - * @see javax.swing.plaf.basic.BasicTabbedPaneUI#uninstallComponents() - */ - protected void uninstallComponents() { - if (scrollableTabLayoutEnabled()) { - tabPane.remove(tabScroller.viewport); - tabPane.remove(tabScroller.scrollForwardButton); - tabPane.remove(tabScroller.scrollBackwardButton); - tabScroller = null; - } - } - - protected void installListeners() { - super.installListeners(); - // if the layout policy is the SCROLL_TAB_LAYOUT, the super class - // will install the mouse listener on tabPane instead of - // tabScroller#tabPanel and there is no way to prevent this. - // That's why the mouse listener must be removed from tabPane and - // added to tabScroller#tabPanel when the scroll tab layout is enabled. - // This applies only to JDK 1.4!!! - if ((mouseListener != null) && (LookUtils.IS_JAVA_1_4)) { - if (scrollableTabLayoutEnabled()) { - tabPane.removeMouseListener(mouseListener); - tabScroller.tabPanel.addMouseListener(mouseListener); - } - } - } - - protected void uninstallListeners() { - if ((mouseListener != null) && (LookUtils.IS_JAVA_1_4)) { - if (scrollableTabLayoutEnabled()) { // SCROLL_TAB_LAYOUT - tabScroller.tabPanel.removeMouseListener(mouseListener); - } else { // WRAP_TAB_LAYOUT - tabPane.removeMouseListener(mouseListener); - } - mouseListener = null; - } - super.uninstallListeners(); - } - - protected void installKeyboardActions() { - super.installKeyboardActions(); - // if the layout policy is the SCROLL_TAB_LAYOUT, then replace - // the forward and backward actions, installed in the action map - // in the supper class, by our own. - if (scrollableTabLayoutEnabled()) { - Action forwardAction = new ScrollTabsForwardAction(); - Action backwardAction = new ScrollTabsBackwardAction(); - ActionMap am = SwingUtilities.getUIActionMap(tabPane); - am.put("scrollTabsForwardAction", forwardAction); - am.put("scrollTabsBackwardAction", backwardAction); - tabScroller.scrollForwardButton.setAction(forwardAction); - tabScroller.scrollBackwardButton.setAction(backwardAction); - } - } - - /** - * Checks and answers if content border will be painted. - * This is controlled by the component's client property - * Options.NO_CONTENT_BORDER or Options.EMBEDDED. - */ - private boolean hasNoContentBorder() { - return Boolean.TRUE.equals(noContentBorder); - } - - /** - * Checks and answers if tabs are painted with minimal decoration. - */ - private boolean hasEmbeddedTabs() { - return Boolean.TRUE.equals(embeddedTabs); - } - - private boolean isHideIfOneTab() { - return Boolean.TRUE.equals(hideIfOneTab); - } - - /** - * Creates the renderer used to lay out and paint the tabs. - * @param tabbedPane the UIs component - * @return AbstractRenderer the renderer that will be used to paint - */ - private AbstractRenderer createRenderer(JTabbedPane tabbedPane) { - return hasEmbeddedTabs() - ? AbstractRenderer.createEmbeddedRenderer(tabbedPane) - : AbstractRenderer.createRenderer(tabPane); - } - - /** - * Creates and answer a handler that listens to property changes. - * Unlike the superclass BasicTabbedPane, the PlasticTabbedPaneUI - * uses an extended Handler. - */ - protected PropertyChangeListener createPropertyChangeListener() { - return new MyPropertyChangeHandler(); - } - - protected ChangeListener createChangeListener() { - return new TabSelectionHandler(); - } - - /* - * Private helper method for the next three methods. - */ - private void doLayout() { - tabPane.revalidate(); - tabPane.repaint(); - } - - /** - * Updates the renderer and layout. This message is sent by - * my PropertyChangeHandler whenever the tab placement changes. - */ - private void tabPlacementChanged() { - renderer = createRenderer(tabPane); - if (scrollableTabLayoutEnabled()) { - tabScroller.createButtons(); - } - doLayout(); - } - - /** - * Updates the embedded tabs property. This message is sent by - * my PropertyChangeHandler whenever the embedded tabs property changes. - */ - private void embeddedTabsPropertyChanged(Boolean newValue) { - embeddedTabs = newValue; - renderer = createRenderer(tabPane); - doLayout(); - } - - /** - * Updates the no content border property. This message is sent - * by my PropertyChangeHandler whenever the noContentBorder - * property changes. - */ - private void noContentBorderPropertyChanged(Boolean newValue) { - noContentBorder = newValue; - tabPane.repaint(); - } - - public void paint(Graphics g, JComponent c) { - int selectedIndex = tabPane.getSelectedIndex(); - int tabPlacement = tabPane.getTabPlacement(); - - ensureCurrentLayout(); - - // Paint tab area - // If scrollable tabs are enabled, the tab area will be - // painted by the scrollable tab panel instead. - // - if (!scrollableTabLayoutEnabled()) { // WRAP_TAB_LAYOUT - paintTabArea(g, tabPlacement, selectedIndex); - } - - // Paint content border - paintContentBorder(g, tabPlacement, selectedIndex); - } - - protected void paintTab(Graphics g, int tabPlacement, Rectangle[] rects, - int tabIndex, Rectangle iconRect, Rectangle textRect) { - Rectangle tabRect = rects[tabIndex]; - int selectedIndex = tabPane.getSelectedIndex(); - boolean isSelected = selectedIndex == tabIndex; - Graphics2D g2 = null; - Polygon cropShape = null; - Shape save = null; - int cropx = 0; - int cropy = 0; - - if (scrollableTabLayoutEnabled()) { - if (g instanceof Graphics2D) { - g2 = (Graphics2D) g; - - // Render visual for cropped tab edge... - Rectangle viewRect = tabScroller.viewport.getViewRect(); - int cropline; - switch (tabPlacement) { - case LEFT: - case RIGHT: - cropline = viewRect.y + viewRect.height; - if ((tabRect.y < cropline) - && (tabRect.y + tabRect.height > cropline)) { - cropShape = createCroppedTabClip(tabPlacement, tabRect, - cropline); - cropx = tabRect.x; - cropy = cropline - 1; - } - break; - case TOP: - case BOTTOM: - default: - cropline = viewRect.x + viewRect.width; - if ((tabRect.x < cropline) - && (tabRect.x + tabRect.width > cropline)) { - cropShape = createCroppedTabClip(tabPlacement, tabRect, - cropline); - cropx = cropline - 1; - cropy = tabRect.y; - } - } - if (cropShape != null) { - save = g.getClip(); - g2.clip(cropShape); - } - } - } - - paintTabBackground(g, tabPlacement, tabIndex, tabRect.x, tabRect.y, - tabRect.width, tabRect.height, isSelected); - - paintTabBorder(g, tabPlacement, tabIndex, tabRect.x, tabRect.y, - tabRect.width, tabRect.height, isSelected); - - String title = tabPane.getTitleAt(tabIndex); - Font font = tabPane.getFont(); - FontMetrics metrics = g.getFontMetrics(font); - Icon icon = getIconForTab(tabIndex); - - layoutLabel(tabPlacement, metrics, tabIndex, title, icon, tabRect, - iconRect, textRect, isSelected); - - paintText(g, tabPlacement, font, metrics, tabIndex, title, textRect, - isSelected); - - paintIcon(g, tabPlacement, tabIndex, icon, iconRect, isSelected); - - paintFocusIndicator(g, tabPlacement, rects, tabIndex, iconRect, - textRect, isSelected); - - if (cropShape != null) { - paintCroppedTabEdge(g, tabPlacement, tabIndex, isSelected, cropx, - cropy); - g.setClip(save); - } - } - - /* - * This method will create and return a polygon shape for the given tab - * rectangle which has been cropped at the specified cropline with a torn - * edge visual. e.g. A "File" tab which has cropped been cropped just after - * the "i": - * ------------- - * | ..... | - * | . | - * | ... . | - * | . . | - * | . . | - * | . . | - * -------------- - * - * The x, y arrays below define the pattern used to create a "torn" edge - * segment which is repeated to fill the edge of the tab. For tabs placed on - * TOP and BOTTOM, this righthand torn edge is created by line segments - * which are defined by coordinates obtained by subtracting xCropLen[i] from - * (tab.x + tab.width) and adding yCroplen[i] to (tab.y). For tabs placed on - * LEFT or RIGHT, the bottom torn edge is created by subtracting xCropLen[i] - * from (tab.y + tab.height) and adding yCropLen[i] to (tab.x). - */ - private int[] xCropLen = { 1, 1, 0, 0, 1, 1, 2, 2 }; - - private int[] yCropLen = { 0, 3, 3, 6, 6, 9, 9, 12 }; - - private static final int CROP_SEGMENT = 12; - - private Polygon createCroppedTabClip(int tabPlacement, Rectangle tabRect, - int cropline) { - int rlen = 0; - int start = 0; - int end = 0; - int ostart = 0; - - switch (tabPlacement) { - case LEFT: - case RIGHT: - rlen = tabRect.width; - start = tabRect.x; - end = tabRect.x + tabRect.width; - ostart = tabRect.y; - break; - case TOP: - case BOTTOM: - default: - rlen = tabRect.height; - start = tabRect.y; - end = tabRect.y + tabRect.height; - ostart = tabRect.x; - } - int rcnt = rlen / CROP_SEGMENT; - if (rlen % CROP_SEGMENT > 0) { - rcnt++; - } - int npts = 2 + (rcnt * 8); - int[] xp = new int[npts]; - int[] yp = new int[npts]; - int pcnt = 0; - - xp[pcnt] = ostart; - yp[pcnt++] = end; - xp[pcnt] = ostart; - yp[pcnt++] = start; - for (int i = 0; i < rcnt; i++) { - for (int j = 0; j < xCropLen.length; j++) { - xp[pcnt] = cropline - xCropLen[j]; - yp[pcnt] = start + (i * CROP_SEGMENT) + yCropLen[j]; - if (yp[pcnt] >= end) { - yp[pcnt] = end; - pcnt++; - break; - } - pcnt++; - } - } - if (tabPlacement == SwingConstants.TOP - || tabPlacement == SwingConstants.BOTTOM) { - return new Polygon(xp, yp, pcnt); - - } - //LEFT or RIGHT - return new Polygon(yp, xp, pcnt); - } - - /* If tabLayoutPolicy == SCROLL_TAB_LAYOUT, this method will paint an edge - * indicating the tab is cropped in the viewport display - */ - private void paintCroppedTabEdge(Graphics g, int tabPlacement, - int tabIndex, boolean isSelected, int x, int y) { - switch (tabPlacement) { - case LEFT: - case RIGHT: - int xx = x; - g.setColor(shadow); - while (xx <= x + rects[tabIndex].width) { - for (int i = 0; i < xCropLen.length; i += 2) { - g.drawLine(xx + yCropLen[i], y - xCropLen[i], xx - + yCropLen[i + 1] - 1, y - xCropLen[i + 1]); - } - xx += CROP_SEGMENT; - } - break; - case TOP: - case BOTTOM: - default: - int yy = y; - g.setColor(shadow); - while (yy <= y + rects[tabIndex].height) { - for (int i = 0; i < xCropLen.length; i += 2) { - g.drawLine(x - xCropLen[i], yy + yCropLen[i], x - - xCropLen[i + 1], yy + yCropLen[i + 1] - 1); - } - yy += CROP_SEGMENT; - } - } - } - - private void ensureCurrentLayout() { - if (!tabPane.isValid()) { - tabPane.validate(); - } - /* If tabPane doesn't have a peer yet, the validate() call will - * silently fail. We handle that by forcing a layout if tabPane - * is still invalid. See bug 4237677. - */ - if (!tabPane.isValid()) { - TabbedPaneLayout layout = (TabbedPaneLayout) tabPane.getLayout(); - layout.calculateLayoutInfo(); - } - } - - /** - * Returns the tab index which intersects the specified point - * in the JTabbedPane's coordinate space. - */ - public int tabForCoordinate(JTabbedPane pane, int x, int y) { - ensureCurrentLayout(); - Point p = new Point(x, y); - - if (scrollableTabLayoutEnabled()) { - translatePointToTabPanel(x, y, p); - Rectangle viewRect = tabScroller.viewport.getViewRect(); - if (!viewRect.contains(p)) { - return -1; - } - } - int tabCount = tabPane.getTabCount(); - for (int i = 0; i < tabCount; i++) { - if (rects[i].contains(p.x, p.y)) { - return i; - } - } - return -1; - } - - protected Rectangle getTabBounds(int tabIndex, Rectangle dest) { - dest.width = rects[tabIndex].width; - dest.height = rects[tabIndex].height; - if (scrollableTabLayoutEnabled()) { // SCROLL_TAB_LAYOUT - // Need to translate coordinates based on viewport location & - // view position - Point vpp = tabScroller.viewport.getLocation(); - Point viewp = tabScroller.viewport.getViewPosition(); - dest.x = rects[tabIndex].x + vpp.x - viewp.x; - dest.y = rects[tabIndex].y + vpp.y - viewp.y; - } else { // WRAP_TAB_LAYOUT - dest.x = rects[tabIndex].x; - dest.y = rects[tabIndex].y; - } - return dest; - } - - /** - * Returns the index of the tab closest to the passed in location, note - * that the returned tab may not contain the location x,y. - */ - private int getClosestTab(int x, int y) { - int min = 0; - int tabCount = Math.min(rects.length, tabPane.getTabCount()); - int max = tabCount; - int tabPlacement = tabPane.getTabPlacement(); - boolean useX = (tabPlacement == TOP || tabPlacement == BOTTOM); - int want = (useX) ? x : y; - - while (min != max) { - int current = (max + min) / 2; - int minLoc; - int maxLoc; - - if (useX) { - minLoc = rects[current].x; - maxLoc = minLoc + rects[current].width; - } else { - minLoc = rects[current].y; - maxLoc = minLoc + rects[current].height; - } - if (want < minLoc) { - max = current; - if (min == max) { - return Math.max(0, current - 1); - } - } else if (want >= maxLoc) { - min = current; - if (max - min <= 1) { - return Math.max(current + 1, tabCount - 1); - } - } else { - return current; - } - } - return min; - } - - /** - * Returns a point which is translated from the specified point in the - * JTabbedPane's coordinate space to the coordinate space of the - * ScrollableTabPanel. This is used for SCROLL_TAB_LAYOUT ONLY. - */ - private Point translatePointToTabPanel(int srcx, int srcy, Point dest) { - Point vpp = tabScroller.viewport.getLocation(); - Point viewp = tabScroller.viewport.getViewPosition(); - dest.x = srcx - vpp.x + viewp.x; - dest.y = srcy - vpp.y + viewp.y; - return dest; - } - - protected void paintTabArea(Graphics g, int tabPlacement, int selectedIndex) { - int tabCount = tabPane.getTabCount(); - - Rectangle iconRect = new Rectangle(), - textRect = new Rectangle(); - Rectangle clipRect = g.getClipBounds(); - - // Paint tabRuns of tabs from back to front - for (int i = runCount - 1; i >= 0; i--) { - int start = tabRuns[i]; - int next = tabRuns[(i == runCount - 1) ? 0 : i + 1]; - int end = (next != 0 ? next - 1 : tabCount - 1); - for (int j = end; j >= start; j--) { - if (j != selectedIndex && rects[j].intersects(clipRect)) { - paintTab(g, tabPlacement, rects, j, iconRect, textRect); - } - } - } - - // Paint selected tab if its in the front run - // since it may overlap other tabs - if (selectedIndex >= 0 && rects[selectedIndex].intersects(clipRect)) { - paintTab(g, tabPlacement, rects, selectedIndex, iconRect, textRect); - } - } - - /* - * Copied here from super(super)class to avoid labels being centered on - * vertical tab runs if they consist of icon and text - */ - protected void layoutLabel( - int tabPlacement, - FontMetrics metrics, - int tabIndex, - String title, - Icon icon, - Rectangle tabRect, - Rectangle iconRect, - Rectangle textRect, - boolean isSelected) { - textRect.x = textRect.y = iconRect.x = iconRect.y = 0; - //fix of issue #4 - View v = getTextViewForTab(tabIndex); - if (v != null) { - tabPane.putClientProperty("html", v); - } - - Rectangle calcRectangle = new Rectangle(tabRect); - if (isSelected) { - Insets calcInsets = getSelectedTabPadInsets(tabPlacement); - calcRectangle.x += calcInsets.left; - calcRectangle.y += calcInsets.top; - calcRectangle.width -= calcInsets.left + calcInsets.right; - calcRectangle.height -= calcInsets.bottom + calcInsets.top; - } - int xNudge = getTabLabelShiftX(tabPlacement, tabIndex, isSelected); - int yNudge = getTabLabelShiftY(tabPlacement, tabIndex, isSelected); - if ((tabPlacement == RIGHT || tabPlacement == LEFT) && icon != null && title != null && !title.equals("")) { - SwingUtilities.layoutCompoundLabel( - tabPane, - metrics, - title, - icon, - SwingConstants.CENTER, - SwingConstants.LEFT, - SwingConstants.CENTER, - SwingConstants.TRAILING, - calcRectangle, - iconRect, - textRect, - textIconGap); - xNudge += 4; - } else { - SwingUtilities.layoutCompoundLabel( - tabPane, - metrics, - title, - icon, - SwingConstants.CENTER, - SwingConstants.CENTER, - SwingConstants.CENTER, - SwingConstants.TRAILING, - calcRectangle, - iconRect, - textRect, - textIconGap); - iconRect.y += calcRectangle.height % 2; - } - - //fix of issue #4 - tabPane.putClientProperty("html", null); - - iconRect.x += xNudge; - iconRect.y += yNudge; - textRect.x += xNudge; - textRect.y += yNudge; - } - - /** - * Answers the icon for the tab with the specified index. - * In case, we have globally switched of the use tab icons, - * we answer null if and only if we have a title. - */ - protected Icon getIconForTab(int tabIndex) { - String title = tabPane.getTitleAt(tabIndex); - boolean hasTitle = (title != null) && (title.length() > 0); - return !isTabIconsEnabled && hasTitle - ? null - : super.getIconForTab(tabIndex); - } - - /** - * Creates the layout manager used to set the tab's bounds. - */ - protected LayoutManager createLayoutManager() { - if (tabPane.getTabLayoutPolicy() == JTabbedPane.SCROLL_TAB_LAYOUT) { - return new TabbedPaneScrollLayout(); - } - /* WRAP_TAB_LAYOUT */ - return new TabbedPaneLayout(); - } - - /* In an attempt to preserve backward compatibility for programs - * which have extended BasicTabbedPaneUI to do their own layout, the - * UI uses the installed layoutManager (and not tabLayoutPolicy) to - * determine if scrollTabLayout is enabled. - */ - private boolean scrollableTabLayoutEnabled() { - return tabPane.getLayout() instanceof TabbedPaneScrollLayout; - } - - protected boolean isTabInFirstRun(int tabIndex) { - return getRunForTab(tabPane.getTabCount(), tabIndex) == 0; - } - - protected void paintContentBorder(Graphics g, int tabPlacement, int selectedIndex) { - int width = tabPane.getWidth(); - int height = tabPane.getHeight(); - Insets insets = tabPane.getInsets(); - - int x = insets.left; - int y = insets.top; - int w = width - insets.right - insets.left; - int h = height - insets.top - insets.bottom; - - switch (tabPlacement) { - case LEFT : - x += calculateTabAreaWidth(tabPlacement, runCount, maxTabWidth); - w -= (x - insets.left); - break; - case RIGHT : - w -= calculateTabAreaWidth(tabPlacement, runCount, maxTabWidth); - break; - case BOTTOM : - h -= calculateTabAreaHeight(tabPlacement, runCount, maxTabHeight); - break; - case TOP : - default : - y += calculateTabAreaHeight(tabPlacement, runCount, maxTabHeight); - h -= (y - insets.top); - } - // Fill region behind content area - g.setColor(selectColor == null - ? tabPane.getBackground() - : selectColor); - g.fillRect(x, y, w, h); - - Rectangle selRect; - selRect = (selectedIndex < 0) ? null : getTabBounds(selectedIndex, calcRect); - boolean drawBroken = selectedIndex >= 0 && isTabInFirstRun(selectedIndex); - boolean isContentBorderPainted = !hasNoContentBorder(); - // It sounds a bit odd to call paintContentBorder with - // a parameter isContentBorderPainted set to false. - // But in this case the part of the border touching the tab - // area will still be painted so best let the renderer decide. - renderer.paintContentBorderTopEdge (g, x, y, w, h, drawBroken, selRect, isContentBorderPainted); - renderer.paintContentBorderLeftEdge (g, x, y, w, h, drawBroken, selRect, isContentBorderPainted); - renderer.paintContentBorderBottomEdge(g, x, y, w, h, drawBroken, selRect, isContentBorderPainted); - renderer.paintContentBorderRightEdge (g, x, y, w, h, drawBroken, selRect, isContentBorderPainted); - } - - // - // Here comes a number of methods that are just delegated to the - // appropriate renderer - // - /** - * Returns the insets (i.e. the width) of the content Border. - */ - protected Insets getContentBorderInsets(int tabPlacement) { - return renderer.getContentBorderInsets(super.getContentBorderInsets(tabPlacement)); - } - - /** - * Returns the amount by which the Tab Area is inset. - */ - protected Insets getTabAreaInsets(int tabPlacement) { - return renderer.getTabAreaInsets(super.getTabAreaInsets(tabPlacement)); - } - - /** - * Returns the amount by which the label should be shifted horizontally. - */ - protected int getTabLabelShiftX(int tabPlacement, int tabIndex, boolean isSelected) { - return renderer.getTabLabelShiftX(tabIndex, isSelected); - } - - /** - * Returns the amount by which the label should be shifted vertically. - */ - protected int getTabLabelShiftY(int tabPlacement, int tabIndex, boolean isSelected) { - return renderer.getTabLabelShiftY(tabIndex, isSelected); - } - - /** - * Returns the amount (in pixels) by which two runs should overlap. - */ - protected int getTabRunOverlay(int tabPlacement) { - return renderer.getTabRunOverlay(tabRunOverlay); - } - - /** - * This boolean controls wheather the given run should be padded to - * use up as much space as the others (with more tabs in them). - */ - protected boolean shouldPadTabRun(int tabPlacement, int run) { - return renderer.shouldPadTabRun(run, super.shouldPadTabRun(tabPlacement, run)); - } - - /** - * Returns the amount by which the run number run - * should be indented. Add six pixels for every run to make - * diagonal lines align. - */ - protected int getTabRunIndent(int tabPlacement, int run) { - return renderer.getTabRunIndent(run); - } - - /** - * Returns the insets for this tab. - */ - protected Insets getTabInsets(int tabPlacement, int tabIndex) { - Insets insets = renderer.getTabInsets(tabIndex, tabInsets); - //adempiere hierarchical tab - int level = 0; - Component comp = tabPane.getComponentAt(tabIndex); - if (comp instanceof JComponent) - { - JComponent jc = (JComponent)comp; - try - { - Integer ll = (Integer)jc.getClientProperty(AdempiereLookAndFeel.TABLEVEL); - if (ll != null) - level = ll.intValue(); - } - catch (Exception e) - { - System.err.println("AdempiereTabbedPaneUI - ClientProperty: " + e.getMessage()); - } - } - if (level != 0) - { - if (tabPlacement == LEFT) - insets.left += level * 10; - } - return insets; - } - - /** - * Returns the insets for selected tab. - */ - protected Insets getSelectedTabPadInsets(int tabPlacement) { - return renderer.getSelectedTabPadInsets(); - } - - /** - * Draws the rectancle around the Tab label which indicates keyboard focus. - */ - protected void paintFocusIndicator( - Graphics g, - int tabPlacement, - Rectangle[] rectangles, - int tabIndex, - Rectangle iconRect, - Rectangle textRect, - boolean isSelected) { - renderer.paintFocusIndicator(g, rectangles, tabIndex, iconRect, textRect, isSelected); - } - - /** - * Fills the background of the given tab to make sure overlap of - * tabs is handled correctly. - * Note: that tab backgrounds seem to be painted somewhere else, too. - */ - protected void paintTabBackground(Graphics g, int tabPlacement, int tabIndex, int x, int y, int w, int h, boolean isSelected) { - renderer.paintTabBackground(g, tabIndex, x, y, w, h, isSelected); - } - - /** - * Paints the border for one tab. Gets the bounds of the tab as parameters. - * Note that the result is not clipped so you can paint outside that - * rectangle. Tabs painted later on have a chance to overwrite though. - */ - protected void paintTabBorder(Graphics g, int tabPlacement, int tabIndex, int x, int y, int w, int h, boolean isSelected) { - renderer.paintTabBorder(g, tabIndex, x, y, w, h, isSelected); - } - - /** - * Answers wheather tab runs should be rotated. If true, the layout mechanism - * will move the run containing the selected tab so that it touches - * the content pane. - */ - protected boolean shouldRotateTabRuns(int tabPlacement) { - return false; - } - - private class TabSelectionHandler implements ChangeListener { - - private Rectangle rect = new Rectangle(); - - public void stateChanged(ChangeEvent e) { - JTabbedPane tabPane = (JTabbedPane) e.getSource(); - tabPane.revalidate(); - tabPane.repaint(); - - if (tabPane.getTabLayoutPolicy() == JTabbedPane.SCROLL_TAB_LAYOUT) { - int index = tabPane.getSelectedIndex(); - if (index < rects.length && index != -1) { - rect.setBounds(rects[index]); - Point viewPosition = tabScroller.viewport.getViewPosition(); - if (rect.x < viewPosition.x) { - rect.x -= renderer.getTabsOverlay(); - } else { - rect.x += renderer.getTabsOverlay(); - } - tabScroller.tabPanel.scrollRectToVisible(rect); - } - } - } - } - - /** - * Catches and handles property change events. In addition to the super - * class behavior we listen to changes of the ancestor, tab placement, - * and JGoodies options for content border, and embedded tabs. - */ - private class MyPropertyChangeHandler - extends BasicTabbedPaneUI.PropertyChangeHandler { - public void propertyChange(PropertyChangeEvent e) { - String pName = e.getPropertyName(); - - if (null == pName) { - return; - } - - super.propertyChange(e); - - if (pName.equals("tabPlacement")) { - tabPlacementChanged(); - return; - } - if (pName.equals(Options.EMBEDDED_TABS_KEY)) { - embeddedTabsPropertyChanged((Boolean) e.getNewValue()); - return; - } - if (pName.equals(Options.NO_CONTENT_BORDER_KEY)) { - noContentBorderPropertyChanged((Boolean) e.getNewValue()); - return; - } - - if (pName.equals(AdempiereLookAndFeel.HIDE_IF_ONE_TAB)) { - hideIfOneTab = (Boolean)e.getNewValue(); - } - } - } - - /** - * Does all the layout work. The result is stored in the container - * class's instance variables. Mainly the rects[] vector. - */ - private class TabbedPaneLayout extends BasicTabbedPaneUI.TabbedPaneLayout implements LayoutManager { - - protected void calculateTabRects(int tabPlacement, int tabCount) { - FontMetrics metrics = getFontMetrics(); - Dimension size = tabPane.getSize(); - Insets insets = tabPane.getInsets(); - Insets theTabAreaInsets = getTabAreaInsets(tabPlacement); - int fontHeight = metrics.getHeight(); - int selectedIndex = tabPane.getSelectedIndex(); - int theTabRunOverlay; - int i, j; - int x, y; - int returnAt; - boolean verticalTabRuns = (tabPlacement == LEFT || tabPlacement == RIGHT); - boolean leftToRight = tabPane.getComponentOrientation().isLeftToRight(); - - // - // Calculate bounds within which a tab run must fit - // - switch (tabPlacement) { - case LEFT : - maxTabWidth = calculateMaxTabWidth(tabPlacement); - x = insets.left + theTabAreaInsets.left; - y = insets.top + theTabAreaInsets.top; - returnAt = size.height - (insets.bottom + theTabAreaInsets.bottom); - break; - case RIGHT : - maxTabWidth = calculateMaxTabWidth(tabPlacement); - x = size.width - insets.right - theTabAreaInsets.right - maxTabWidth; - y = insets.top + theTabAreaInsets.top; - returnAt = size.height - (insets.bottom + theTabAreaInsets.bottom); - break; - case BOTTOM : - maxTabHeight = calculateMaxTabHeight(tabPlacement); - x = insets.left + theTabAreaInsets.left; - y = size.height - insets.bottom - theTabAreaInsets.bottom - maxTabHeight; - returnAt = size.width - (insets.right + theTabAreaInsets.right); - break; - case TOP : - default : - maxTabHeight = calculateMaxTabHeight(tabPlacement); - x = insets.left + theTabAreaInsets.left; - y = insets.top + theTabAreaInsets.top; - returnAt = size.width - (insets.right + theTabAreaInsets.right); - break; - } - - theTabRunOverlay = getTabRunOverlay(tabPlacement); - - runCount = 0; - selectedRun = -1; - //keeps track of where we are in the current run. - //this helps not to rely on fragile positioning - //informaion to find out wheter the active Tab - //is the first in run - int tabInRun = -1; - // make a copy of returnAt for the current run and modify - // that so returnAt may still be used later on - int runReturnAt = returnAt; - - if (tabCount == 0) { - return; - } - - if (tabCount == 1 && isHideIfOneTab()) { - rects[0].height = 0; - rects[0].width = 0; - rects[0].x = 0; - rects[0].y = 0; - return; - } - - // Run through tabs and partition them into runs - Rectangle rect; - for (i = 0; i < tabCount; i++) { - rect = rects[i]; - tabInRun++; - - if (!verticalTabRuns) { - // Tabs on TOP or BOTTOM.... - if (i > 0) { - rect.x = rects[i - 1].x + rects[i - 1].width; - } else { - tabRuns[0] = 0; - runCount = 1; - maxTabWidth = 0; - rect.x = x; - // tabInRun = 0; - } - rect.width = calculateTabWidth(tabPlacement, i, metrics); - maxTabWidth = Math.max(maxTabWidth, rect.width); - - // Never move a TAB down a run if it is the first in run. - // Even if there isn't enough room, moving it to a fresh - // line won't help. - // if (rect.x != 2 + insets.left && rect.x + rect.width > returnAt) { - // Never rely on phisical position information to determine - // logical position (if you can avoid it) - if (tabInRun != 0 && rect.x + rect.width > runReturnAt) { - if (runCount > tabRuns.length - 1) { - expandTabRunsArray(); - } - // just created a new run, adjust some counters - tabInRun = 0; - tabRuns[runCount] = i; - runCount++; - rect.x = x; - runReturnAt = runReturnAt - 2 * getTabRunIndent(tabPlacement, runCount); - } - // Initialize y position in case there's just one run - rect.y = y; - rect.height = maxTabHeight /* - 2*/; - - } else { - // Tabs on LEFT or RIGHT... - if (i > 0) { - rect.y = rects[i - 1].y + rects[i - 1].height; - } else { - tabRuns[0] = 0; - runCount = 1; - maxTabHeight = 0; - rect.y = y; - // tabInRun = 0; - } - rect.height = calculateTabHeight(tabPlacement, i, fontHeight); - maxTabHeight = Math.max(maxTabHeight, rect.height); - - // Never move a TAB over a run if it is the first in run. - // Even if there isn't enough room, moving it to a fresh - // run won't help. - // if (rect.y != 2 + insets.top && rect.y + rect.height > returnAt) { - if (tabInRun != 0 && rect.y + rect.height > runReturnAt) { - if (runCount > tabRuns.length - 1) { - expandTabRunsArray(); - } - tabRuns[runCount] = i; - runCount++; - rect.y = y; - tabInRun = 0; - runReturnAt -= 2 * getTabRunIndent(tabPlacement, runCount); - } - // Initialize x position in case there's just one column - rect.x = x; - rect.width = maxTabWidth /* - 2*/; - - } - - //adempiere hierarchical tab - int level = 0; - Component comp = tabPane.getComponentAt(i); - if (comp instanceof JComponent) - { - JComponent jc = (JComponent)comp; - try - { - Integer ll = (Integer)jc.getClientProperty(AdempiereLookAndFeel.TABLEVEL); - if (ll != null) - level = ll.intValue(); - } - catch (Exception e) - { - System.err.println("AdempiereTabbedPaneUI - ClientProperty: " + e.getMessage()); - } - } - if (level != 0) - { - if (tabPlacement == LEFT) - rect.x += level * 10; - rect.width -= level * 10; - } - - if (i == selectedIndex) { - selectedRun = runCount - 1; - } - } - - if (runCount > 1) { - // Re-distribute tabs in case last run has leftover space - //last line flush left is OK - // normalizeTabRuns(tabPlacement, tabCount, verticalTabRuns? y : x, returnAt); - //don't need to recalculate selectedRun if not changed - // selectedRun = getRunForTab(tabCount, selectedIndex); - - // Rotate run array so that selected run is first - if (shouldRotateTabRuns(tabPlacement)) { - rotateTabRuns(tabPlacement, selectedRun); - } - } - - // Step through runs from back to front to calculate - // tab y locations and to pad runs appropriately - for (i = runCount - 1; i >= 0; i--) { - int start = tabRuns[i]; - int next = tabRuns[i == (runCount - 1) ? 0 : i + 1]; - int end = (next != 0 ? next - 1 : tabCount - 1); - int indent = getTabRunIndent(tabPlacement, i); - if (!verticalTabRuns) { - for (j = start; j <= end; j++) { - rect = rects[j]; - rect.y = y; - rect.x += indent; - // try to make tabRunIndent symmetric - // rect.width -= 2* indent + 20; - } - if (shouldPadTabRun(tabPlacement, i)) { - padTabRun(tabPlacement, start, end, returnAt - 2 * indent); - } - if (tabPlacement == BOTTOM) { - y -= (maxTabHeight - theTabRunOverlay); - } else { - y += (maxTabHeight - theTabRunOverlay); - } - } else { - for (j = start; j <= end; j++) { - rect = rects[j]; - rect.x = x; - rect.y += indent; - } - if (shouldPadTabRun(tabPlacement, i)) { - padTabRun(tabPlacement, start, end, returnAt - 2 * indent); - } - if (tabPlacement == RIGHT) { - x -= (maxTabWidth - theTabRunOverlay); - } else { - x += (maxTabWidth - theTabRunOverlay); - } - } - } - - // Pad the selected tab so that it appears raised in front - padSelectedTab(tabPlacement, selectedIndex); - - // if right to left and tab placement on the top or - // the bottom, flip x positions and adjust by widths - if (!leftToRight && !verticalTabRuns) { - int rightMargin = size.width - (insets.right + theTabAreaInsets.right); - for (i = 0; i < tabCount; i++) { - rects[i].x = rightMargin - rects[i].x - rects[i].width - + renderer.getTabsOverlay(); - } - } - } - - /** - * Overridden to insure the same behavior in JDK 6.0 as in JDK 5.0. - */ - protected void padSelectedTab(int tabPlacement, int selectedIndex) { - if (selectedIndex >= 0) { - Rectangle selRect = rects[selectedIndex]; - Insets padInsets = getSelectedTabPadInsets(tabPlacement); - selRect.x -= padInsets.left; - selRect.width += (padInsets.left + padInsets.right); - selRect.y -= padInsets.top; - selRect.height += (padInsets.top + padInsets.bottom); - } - } - - } - - - private boolean requestFocusForVisibleComponentX() { - Component visibleComponent = getVisibleComponent(); - if (visibleComponent.isFocusable()) { - visibleComponent.requestFocus(); - return true; - } - if (visibleComponent instanceof JComponent) { - if (((JComponent) visibleComponent).requestDefaultFocus()) { - return true; - } - } - return false; - } - - private static class ScrollTabsForwardAction extends AbstractAction { - - /** - * - */ - private static final long serialVersionUID = -270810699887568982L; - - public void actionPerformed(ActionEvent e) { - JTabbedPane pane = null; - Object src = e.getSource(); - if (src instanceof JTabbedPane) { - pane = (JTabbedPane) src; - } else if (src != null - && src.getClass().getName().equals("com.jgoodies.looks.plastic.com.jgoodies.looks.plastic")) { - pane = (JTabbedPane) ((Component) src).getParent(); - } else { - return; // shouldn't happen - } - AdempiereTabbedPaneUI ui = (AdempiereTabbedPaneUI) pane.getUI(); - - if (ui.scrollableTabLayoutEnabled()) { - ui.tabScroller.scrollForward(pane.getTabPlacement()); - } - } - } - - private static class ScrollTabsBackwardAction extends AbstractAction { - - /** - * - */ - private static final long serialVersionUID = -3249390793846061809L; - - public void actionPerformed(ActionEvent e) { - JTabbedPane pane = null; - Object src = e.getSource(); - if (src instanceof JTabbedPane) { - pane = (JTabbedPane) src; - } else if (src != null - && src.getClass().getName().equals("com.jgoodies.looks.plastic.com.jgoodies.looks.plastic")) { - pane = (JTabbedPane) ((Component) src).getParent(); - } else { - return; // shouldn't happen - } - AdempiereTabbedPaneUI ui = (AdempiereTabbedPaneUI) pane.getUI(); - - if (ui.scrollableTabLayoutEnabled()) { - ui.tabScroller.scrollBackward(pane.getTabPlacement()); - } - } - } - - private class TabbedPaneScrollLayout extends TabbedPaneLayout { - - protected int preferredTabAreaHeight(int tabPlacement, int width) { - return calculateMaxTabHeight(tabPlacement); - } - - protected int preferredTabAreaWidth(int tabPlacement, int height) { - return calculateMaxTabWidth(tabPlacement); - } - - public void layoutContainer(Container parent) { - int tabPlacement = tabPane.getTabPlacement(); - int tabCount = tabPane.getTabCount(); - Insets insets = tabPane.getInsets(); - int selectedIndex = tabPane.getSelectedIndex(); - Component visibleComponent = getVisibleComponent(); - - calculateLayoutInfo(); - - if (selectedIndex < 0) { - if (visibleComponent != null) { - // The last tab was removed, so remove the component - setVisibleComponent(null); - } - } else { - Component selectedComponent = tabPane.getComponentAt(selectedIndex); - boolean shouldChangeFocus = false; - - // In order to allow programs to use a single component - // as the display for multiple tabs, we will not change - // the visible compnent if the currently selected tab - // has a null component. This is a bit dicey, as we don't - // explicitly state we support this in the spec, but since - // programs are now depending on this, we're making it work. - // - if (selectedComponent != null) { - if (selectedComponent != visibleComponent && - visibleComponent != null) { - if (SwingUtilities.findFocusOwner(visibleComponent) != null) { - shouldChangeFocus = true; - } - } - setVisibleComponent(selectedComponent); - } - int tx, ty, tw, th; // tab area bounds - int cx, cy, cw, ch; // content area bounds - Insets contentInsets = getContentBorderInsets(tabPlacement); - Rectangle bounds = tabPane.getBounds(); - int numChildren = tabPane.getComponentCount(); - - if (numChildren > 0) { - switch (tabPlacement) { - case LEFT: - // calculate tab area bounds - tw = calculateTabAreaWidth(tabPlacement, runCount, - maxTabWidth); - th = bounds.height - insets.top - insets.bottom; - tx = insets.left; - ty = insets.top; - - // calculate content area bounds - cx = tx + tw + contentInsets.left; - cy = ty + contentInsets.top; - cw = bounds.width - insets.left - insets.right - tw - - contentInsets.left - contentInsets.right; - ch = bounds.height - insets.top - insets.bottom - - contentInsets.top - contentInsets.bottom; - break; - case RIGHT: - // calculate tab area bounds - tw = calculateTabAreaWidth(tabPlacement, runCount, - maxTabWidth); - th = bounds.height - insets.top - insets.bottom; - tx = bounds.width - insets.right - tw; - ty = insets.top; - - // calculate content area bounds - cx = insets.left + contentInsets.left; - cy = insets.top + contentInsets.top; - cw = bounds.width - insets.left - insets.right - tw - - contentInsets.left - contentInsets.right; - ch = bounds.height - insets.top - insets.bottom - - contentInsets.top - contentInsets.bottom; - break; - case BOTTOM: - // calculate tab area bounds - tw = bounds.width - insets.left - insets.right; - th = calculateTabAreaHeight(tabPlacement, runCount, - maxTabHeight); - tx = insets.left; - ty = bounds.height - insets.bottom - th; - - // calculate content area bounds - cx = insets.left + contentInsets.left; - cy = insets.top + contentInsets.top; - cw = bounds.width - insets.left - insets.right - - contentInsets.left - contentInsets.right; - ch = bounds.height - insets.top - insets.bottom - th - - contentInsets.top - contentInsets.bottom; - break; - case TOP: - default: - // calculate tab area bounds - tw = bounds.width - insets.left - insets.right; - th = calculateTabAreaHeight(tabPlacement, runCount, - maxTabHeight); - tx = insets.left; - ty = insets.top; - - // calculate content area bounds - cx = tx + contentInsets.left; - cy = ty + th + contentInsets.top; - cw = bounds.width - insets.left - insets.right - - contentInsets.left - contentInsets.right; - ch = bounds.height - insets.top - insets.bottom - th - - contentInsets.top - contentInsets.bottom; - } - - for (int i = 0; i < numChildren; i++) { - Component child = tabPane.getComponent(i); - - if (tabScroller != null && child == tabScroller.viewport) { - JViewport viewport = (JViewport) child; - Rectangle viewRect = viewport.getViewRect(); - int vw = tw; - int vh = th; - Dimension butSize = tabScroller.scrollForwardButton.getPreferredSize(); - switch (tabPlacement) { - case LEFT: - case RIGHT: - int totalTabHeight = rects[tabCount - 1].y - + rects[tabCount - 1].height; - if (totalTabHeight > th) { - // Allow space for scrollbuttons - vh = (th > 2 * butSize.height) ? th - 2 - * butSize.height : 0; - if (totalTabHeight - viewRect.y <= vh) { - // Scrolled to the end, so ensure the - // viewport size is - // such that the scroll offset aligns - // with a tab - vh = totalTabHeight - viewRect.y; - } - } - break; - case BOTTOM: - case TOP: - default: - int totalTabWidth = rects[tabCount - 1].x - + rects[tabCount - 1].width + renderer.getTabsOverlay(); - if (totalTabWidth > tw) { - // Need to allow space for scrollbuttons - vw = (tw > 2 * butSize.width) ? tw - 2 - * butSize.width : 0; - if (totalTabWidth - viewRect.x <= vw) { - // Scrolled to the end, so ensure the - // viewport size is - // such that the scroll offset aligns - // with a tab - vw = totalTabWidth - viewRect.x; - } - } - } - child.setBounds(tx, ty, vw, vh); - - } else if (tabScroller != null && - (child == tabScroller.scrollForwardButton || - child == tabScroller.scrollBackwardButton)) { - Component scrollbutton = child; - Dimension bsize = scrollbutton.getPreferredSize(); - int bx = 0; - int by = 0; - int bw = bsize.width; - int bh = bsize.height; - boolean visible = false; - - switch (tabPlacement) { - case LEFT: - case RIGHT: - int totalTabHeight = rects[tabCount - 1].y - + rects[tabCount - 1].height; - if (totalTabHeight > th) { - visible = true; - bx = (tabPlacement == LEFT ? tx + tw - - bsize.width : tx); - by = (child == tabScroller.scrollForwardButton) ? bounds.height - - insets.bottom - bsize.height - : bounds.height - insets.bottom - 2 - * bsize.height; - } - break; - - case BOTTOM: - case TOP: - default: - int totalTabWidth = rects[tabCount - 1].x - + rects[tabCount - 1].width; - - if (totalTabWidth > tw) { - visible = true; - bx = (child == tabScroller.scrollForwardButton) ? bounds.width - - insets.left - bsize.width - : bounds.width - insets.left - 2 - * bsize.width; - by = (tabPlacement == TOP ? ty + th - - bsize.height : ty); - } - } - child.setVisible(visible); - if (visible) { - child.setBounds(bx, by, bw, bh); - } - - } else { - // All content children... - child.setBounds(cx, cy, cw, ch); - } - } - if (shouldChangeFocus) { - if (!requestFocusForVisibleComponentX()) { - tabPane.requestFocus(); - } - } - } - } - } - - protected void calculateTabRects(int tabPlacement, int tabCount) { - FontMetrics metrics = getFontMetrics(); - Dimension size = tabPane.getSize(); - Insets insets = tabPane.getInsets(); - Insets tabAreaInsets = getTabAreaInsets(tabPlacement); - int fontHeight = metrics.getHeight(); - int selectedIndex = tabPane.getSelectedIndex(); - boolean verticalTabRuns = (tabPlacement == LEFT || tabPlacement == RIGHT); - boolean leftToRight = tabPane.getComponentOrientation().isLeftToRight(); - int x = tabAreaInsets.left; - int y = tabAreaInsets.top; - int totalWidth = 0; - int totalHeight = 0; - - // - // Calculate bounds within which a tab run must fit - // - switch(tabPlacement) { - case LEFT: - case RIGHT: - maxTabWidth = calculateMaxTabWidth(tabPlacement); - break; - case BOTTOM: - case TOP: - default: - maxTabHeight = calculateMaxTabHeight(tabPlacement); - } - - runCount = 0; - selectedRun = -1; - - if (tabCount == 0) { - return; - } - - if (tabCount == 1 && isHideIfOneTab()) { - rects[0].height = 0; - rects[0].width = 0; - rects[0].x = 0; - rects[0].y = 0; - return; - } - - selectedRun = 0; - runCount = 1; - - // Run through tabs and lay them out in a single run - Rectangle rect; - for (int i = 0; i < tabCount; i++) { - rect = rects[i]; - - if (!verticalTabRuns) { - // Tabs on TOP or BOTTOM.... - if (i > 0) { - rect.x = rects[i-1].x + rects[i-1].width; - } else { - tabRuns[0] = 0; - maxTabWidth = 0; - totalHeight += maxTabHeight; - rect.x = x; - } - rect.width = calculateTabWidth(tabPlacement, i, metrics); - totalWidth = rect.x + rect.width + renderer.getTabsOverlay(); - maxTabWidth = Math.max(maxTabWidth, rect.width); - - rect.y = y; - rect.height = maxTabHeight/* - 2*/; - - } else { - // Tabs on LEFT or RIGHT... - if (i > 0) { - rect.y = rects[i-1].y + rects[i-1].height; - } else { - tabRuns[0] = 0; - maxTabHeight = 0; - totalWidth = maxTabWidth; - rect.y = y; - } - rect.height = calculateTabHeight(tabPlacement, i, fontHeight); - totalHeight = rect.y + rect.height; - maxTabHeight = Math.max(maxTabHeight, rect.height); - - rect.x = x; - rect.width = maxTabWidth/* - 2*/; - - } - - //adempiere hierarchical tab - int level = 0; - Component comp = tabPane.getComponentAt(i); - if (comp instanceof JComponent) - { - JComponent jc = (JComponent)comp; - try - { - Integer ll = (Integer)jc.getClientProperty(AdempiereLookAndFeel.TABLEVEL); - if (ll != null) - level = ll.intValue(); - } - catch (Exception e) - { - System.err.println("AdempiereTabbedPaneUI - ClientProperty: " + e.getMessage()); - } - } - if (level != 0) - { - if (tabPlacement == LEFT) - rect.x += level * 10; - rect.width -= level * 10; - } - } - - // Pad the selected tab so that it appears raised in front - padSelectedTab(tabPlacement, selectedIndex); - - // if right to left and tab placement on the top or - // the bottom, flip x positions and adjust by widths - if (!leftToRight && !verticalTabRuns) { - int rightMargin = size.width - - (insets.right + tabAreaInsets.right); - for (int i = 0; i < tabCount; i++) { - rects[i].x = rightMargin - rects[i].x - rects[i].width; - } - } - tabScroller.tabPanel.setPreferredSize(new Dimension(totalWidth, totalHeight)); - } - } - - private class ScrollableTabSupport implements ActionListener, - ChangeListener { - - public ScrollableTabViewport viewport; - public ScrollableTabPanel tabPanel; - public JButton scrollForwardButton; - public JButton scrollBackwardButton; - public int leadingTabIndex; - private Point tabViewPosition = new Point(0, 0); - - ScrollableTabSupport(int tabPlacement) { - viewport = new ScrollableTabViewport(); - tabPanel = new ScrollableTabPanel(); - viewport.setView(tabPanel); - viewport.addChangeListener(this); - createButtons(); - } - - /** - * Recreates the scroll buttons and adds them to the TabbedPane. - */ - void createButtons() { - if (scrollForwardButton != null) { - tabPane.remove(scrollForwardButton); - scrollForwardButton.removeActionListener(this); - tabPane.remove(scrollBackwardButton); - scrollBackwardButton.removeActionListener(this); - } - int tabPlacement = tabPane.getTabPlacement(); - int width = UIManager.getInt("ScrollBar.width"); - if (tabPlacement == TOP || tabPlacement == BOTTOM) { - scrollForwardButton = new ArrowButton(EAST, width); - scrollBackwardButton = new ArrowButton(WEST, width); - } else { // tabPlacement = LEFT || RIGHT - scrollForwardButton = new ArrowButton(SOUTH, width); - scrollBackwardButton = new ArrowButton(NORTH, width); - } - scrollForwardButton.addActionListener(this); - scrollBackwardButton.addActionListener(this); - tabPane.add(scrollForwardButton); - tabPane.add(scrollBackwardButton); - } - - public void scrollForward(int tabPlacement) { - Dimension viewSize = viewport.getViewSize(); - Rectangle viewRect = viewport.getViewRect(); - - if (tabPlacement == TOP || tabPlacement == BOTTOM) { - if (viewRect.width >= viewSize.width - viewRect.x) { - return; // no room left to scroll - } - } else { // tabPlacement == LEFT || tabPlacement == RIGHT - if (viewRect.height >= viewSize.height - viewRect.y) { - return; - } - } - setLeadingTabIndex(tabPlacement, leadingTabIndex + 1); - } - - public void scrollBackward(int tabPlacement) { - if (leadingTabIndex == 0) { - return; // no room left to scroll - } - setLeadingTabIndex(tabPlacement, leadingTabIndex - 1); - } - - public void setLeadingTabIndex(int tabPlacement, int index) { - leadingTabIndex = index; - Dimension viewSize = viewport.getViewSize(); - Rectangle viewRect = viewport.getViewRect(); - - switch (tabPlacement) { - case TOP: - case BOTTOM: - tabViewPosition.x = leadingTabIndex == 0 ? 0 - : rects[leadingTabIndex].x - renderer.getTabsOverlay(); - - if ((viewSize.width - tabViewPosition.x) < viewRect.width) { - // We've scrolled to the end, so adjust the viewport size - // to ensure the view position remains aligned on a tab - // boundary - Dimension extentSize = new Dimension(viewSize.width - - tabViewPosition.x, viewRect.height); - viewport.setExtentSize(extentSize); - } - break; - case LEFT: - case RIGHT: - tabViewPosition.y = leadingTabIndex == 0 ? 0 - : rects[leadingTabIndex].y; - - if ((viewSize.height - tabViewPosition.y) < viewRect.height) { - // We've scrolled to the end, so adjust the viewport size - // to ensure the view position remains aligned on a tab - // boundary - Dimension extentSize = new Dimension(viewRect.width, - viewSize.height - tabViewPosition.y); - viewport.setExtentSize(extentSize); - } - } - viewport.setViewPosition(tabViewPosition); - } - - public void stateChanged(ChangeEvent e) { - JViewport viewport = (JViewport) e.getSource(); - int tabPlacement = tabPane.getTabPlacement(); - int tabCount = tabPane.getTabCount(); - Rectangle vpRect = viewport.getBounds(); - Dimension viewSize = viewport.getViewSize(); - Rectangle viewRect = viewport.getViewRect(); - - leadingTabIndex = getClosestTab(viewRect.x, viewRect.y); - - // If the tab isn't right aligned, adjust it. - if (leadingTabIndex + 1 < tabCount) { - switch (tabPlacement) { - case TOP: - case BOTTOM: - if (rects[leadingTabIndex].x < viewRect.x) { - leadingTabIndex++; - } - break; - case LEFT: - case RIGHT: - if (rects[leadingTabIndex].y < viewRect.y) { - leadingTabIndex++; - } - break; - } - } - Insets contentInsets = getContentBorderInsets(tabPlacement); - switch (tabPlacement) { - case LEFT: - tabPane.repaint(vpRect.x + vpRect.width, vpRect.y, - contentInsets.left, vpRect.height); - scrollBackwardButton.setEnabled(viewRect.y > 0 - && leadingTabIndex > 0); - scrollForwardButton.setEnabled(leadingTabIndex < tabCount - 1 - && viewSize.height - viewRect.y > viewRect.height); - break; - case RIGHT: - tabPane.repaint(vpRect.x - contentInsets.right, vpRect.y, - contentInsets.right, vpRect.height); - scrollBackwardButton.setEnabled(viewRect.y > 0 - && leadingTabIndex > 0); - scrollForwardButton.setEnabled(leadingTabIndex < tabCount - 1 - && viewSize.height - viewRect.y > viewRect.height); - break; - case BOTTOM: - tabPane.repaint(vpRect.x, vpRect.y - contentInsets.bottom, - vpRect.width, contentInsets.bottom); - scrollBackwardButton.setEnabled(viewRect.x > 0 - && leadingTabIndex > 0); - scrollForwardButton.setEnabled(leadingTabIndex < tabCount - 1 - && viewSize.width - viewRect.x > viewRect.width); - break; - case TOP: - default: - tabPane.repaint(vpRect.x, vpRect.y + vpRect.height, - vpRect.width, contentInsets.top); - scrollBackwardButton.setEnabled(viewRect.x > 0 - && leadingTabIndex > 0); - scrollForwardButton.setEnabled(leadingTabIndex < tabCount - 1 - && viewSize.width - viewRect.x > viewRect.width); - } - } - - /** - * ActionListener for the scroll buttons. - */ - public void actionPerformed(ActionEvent e) { - ActionMap map = tabPane.getActionMap(); - - if (map != null) { - String actionKey; - - if (e.getSource() == scrollForwardButton) { - actionKey = "scrollTabsForwardAction"; - } else { - actionKey = "scrollTabsBackwardAction"; - } - Action action = map.get(actionKey); - - if (action != null && action.isEnabled()) { - action.actionPerformed(new ActionEvent(tabPane, - ActionEvent.ACTION_PERFORMED, null, e.getWhen(), e - .getModifiers())); - } - } - } - - } - - private class ScrollableTabViewport extends JViewport implements UIResource { - - /** - * - */ - private static final long serialVersionUID = 327251688467352279L; - - public ScrollableTabViewport() { - super(); - setName("TabbedPane.scrollableViewport"); - setScrollMode(SIMPLE_SCROLL_MODE); - setOpaque(tabPane.isOpaque()); - Color bgColor = UIManager.getColor("TabbedPane.tabAreaBackground"); - if (bgColor == null) { - bgColor = tabPane.getBackground(); - } - setBackground(bgColor); - } - } - - private class ScrollableTabPanel extends JPanel implements UIResource { - - /** - * - */ - private static final long serialVersionUID = -7751954262914422261L; - - public ScrollableTabPanel() { - super(null); - setOpaque(tabPane.isOpaque()); - Color bgColor = UIManager.getColor("TabbedPane.tabAreaBackground"); - if (bgColor == null) { - bgColor = tabPane.getBackground(); - } - setBackground(bgColor); - } - - public void paintComponent(Graphics g) { - super.paintComponent(g); - AdempiereTabbedPaneUI.this.paintTabArea(g, tabPane.getTabPlacement(), - tabPane.getSelectedIndex()); - - } - } - - private static class ArrowButton extends JButton implements UIResource { - - /** - * - */ - private static final long serialVersionUID = 2076478876425671827L; - private final int buttonWidth; - private final int direction; - private boolean mouseIsOver; - - ArrowButton(int direction, int buttonWidth) { - this.direction = direction; - this.buttonWidth = buttonWidth; - setRequestFocusEnabled(false); - } - - protected void processMouseEvent(MouseEvent e) { - super.processMouseEvent(e); - switch (e.getID()) { - case MouseEvent.MOUSE_ENTERED: - mouseIsOver = true; - revalidate(); - repaint(); - break; - case MouseEvent.MOUSE_EXITED: - mouseIsOver = false; - revalidate(); - repaint(); - break; - } - } - - protected void paintBorder(Graphics g) { - if (mouseIsOver && isEnabled()) { - super.paintBorder(g); - } - } - - protected void paintComponent(Graphics g) { - if (mouseIsOver) { - super.paintComponent(g); - } else { - g.setColor(getBackground()); - g.fillRect(0, 0, getWidth(), getHeight()); - } - paintArrow(g); - } - - private void paintArrow(Graphics g) { - Color oldColor = g.getColor(); - - boolean isEnabled = isEnabled(); - g.setColor(isEnabled ? PlasticLookAndFeel.getControlInfo() - : PlasticLookAndFeel.getControlDisabled()); - - int arrowWidth, arrowHeight; - switch (direction) { - case NORTH: - case SOUTH: - arrowWidth = 9; - arrowHeight = 5; - break; - case WEST: - case EAST: - default: - arrowWidth = 5; - arrowHeight = 9; - break; - } - int x = (getWidth() - arrowWidth ) / 2; - int y = (getHeight() - arrowHeight) / 2; - g.translate(x, y); - - boolean paintShadow = !mouseIsOver || !isEnabled; - Color shadow = isEnabled ? PlasticLookAndFeel.getControlShadow() - : UIManager.getColor("ScrollBar.highlight"); - - switch (direction) { - case NORTH: - g.fillRect(0, 4, 9, 1); - g.fillRect(1, 3, 7, 1); - g.fillRect(2, 2, 5, 1); - g.fillRect(3, 1, 3, 1); - g.fillRect(4, 0, 1, 1); - if (paintShadow) { - g.setColor(shadow); - g.fillRect(1, 5, 9, 1); - } - break; - case SOUTH: - g.fillRect(0, 0, 9, 1); - g.fillRect(1, 1, 7, 1); - g.fillRect(2, 2, 5, 1); - g.fillRect(3, 3, 3, 1); - g.fillRect(4, 4, 1, 1); - if (paintShadow) { - g.setColor(shadow); - g.drawLine(5, 4, 8, 1); - g.drawLine(5, 5, 9, 1); - } - break; - case WEST: - g.fillRect(0, 4, 1, 1); - g.fillRect(1, 3, 1, 3); - g.fillRect(2, 2, 1, 5); - g.fillRect(3, 1, 1, 7); - g.fillRect(4, 0, 1, 9); - if (paintShadow) { - g.setColor(shadow); - g.fillRect(5, 1, 1, 9); - } - break; - case EAST: - g.fillRect(0, 0, 1, 9); - g.fillRect(1, 1, 1, 7); - g.fillRect(2, 2, 1, 5); - g.fillRect(3, 3, 1, 3); - g.fillRect(4, 4, 1, 1); - if (paintShadow) { - g.setColor(shadow); - g.drawLine(1, 8, 4, 5); - g.drawLine(1, 9, 5, 5); - } - break; - } - - g.translate(-x, -y); - g.setColor(oldColor); - } - - public Dimension getPreferredSize() { - return new Dimension(buttonWidth, buttonWidth); - } - - public Dimension getMinimumSize() { - return getPreferredSize(); - } - - public Dimension getMaximumSize() { - return new Dimension(Integer.MAX_VALUE, Integer.MAX_VALUE); - } - } - - /** - * This is the abstract superclass for all TabbedPane renderers. - * Those will be defined in the rest of this file - */ - private abstract static class AbstractRenderer { - - protected static final Insets EMPTY_INSETS = new Insets(0, 0, 0, 0); - protected static final Insets NORTH_INSETS = new Insets(1, 0, 0, 0); - protected static final Insets WEST_INSETS = new Insets(0, 1, 0, 0); - protected static final Insets SOUTH_INSETS = new Insets(0, 0, 1, 0); - protected static final Insets EAST_INSETS = new Insets(0, 0, 0, 1); - - protected final JTabbedPane tabPane; - @SuppressWarnings("unused") - protected final int tabPlacement; - protected Color shadowColor; - protected Color darkShadow; - protected Color selectColor; - protected Color selectLight; - protected Color selectHighlight; - @SuppressWarnings("unused") - protected Color lightHighlight; - protected Color focus; - - private AbstractRenderer(JTabbedPane tabPane) { - initColors(); - this.tabPane = tabPane; - this.tabPlacement = tabPane.getTabPlacement(); - } - - private static AbstractRenderer createRenderer(JTabbedPane tabPane) { - switch (tabPane.getTabPlacement()) { - case SwingConstants.TOP : - return new TopRenderer(tabPane); - case SwingConstants.BOTTOM : - return new BottomRenderer(tabPane); - case SwingConstants.LEFT : - return new LeftRenderer(tabPane); - case SwingConstants.RIGHT : - return new RightRenderer(tabPane); - default : - return new TopRenderer(tabPane); - } - } - - private static AbstractRenderer createEmbeddedRenderer(JTabbedPane tabPane) { - switch (tabPane.getTabPlacement()) { - case SwingConstants.TOP : - return new TopEmbeddedRenderer(tabPane); - case SwingConstants.BOTTOM : - return new BottomEmbeddedRenderer(tabPane); - case SwingConstants.LEFT : - return new LeftEmbeddedRenderer(tabPane); - case SwingConstants.RIGHT : - return new RightEmbeddedRenderer(tabPane); - default : - return new TopEmbeddedRenderer(tabPane); - } - } - - private void initColors() { - shadowColor = UIManager.getColor("TabbedPane.shadow"); - darkShadow = UIManager.getColor("TabbedPane.darkShadow"); - selectColor = UIManager.getColor("TabbedPane.selected"); - focus = UIManager.getColor("TabbedPane.focus"); - selectHighlight = UIManager.getColor("TabbedPane.selectHighlight"); - lightHighlight = UIManager.getColor("TabbedPane.highlight"); - selectLight = - new Color( - (2 * selectColor.getRed() + selectHighlight.getRed()) / 3, - (2 * selectColor.getGreen() + selectHighlight.getGreen()) / 3, - (2 * selectColor.getBlue() + selectHighlight.getBlue()) / 3); - } - - protected boolean isFirstDisplayedTab(int tabIndex, int position, int paneBorder) { - return tabIndex == 0; -// return (position - paneBorder) < 8; - } - - protected Insets getTabAreaInsets(Insets defaultInsets) { - return defaultInsets; - } - - protected Insets getContentBorderInsets(Insets defaultInsets) { - return defaultInsets; - } - - /** - * Returns the amount by which the label should be shifted horizontally. - */ - protected int getTabLabelShiftX(int tabIndex, boolean isSelected) { - return 0; - } - - /** - * Returns the amount by which the label should be shifted vertically. - */ - protected int getTabLabelShiftY(int tabIndex, boolean isSelected) { - return 0; - } - - /** - * Returns the amount of overlap for two Runs. - */ - protected int getTabRunOverlay(int tabRunOverlay) { - return tabRunOverlay; - } - - /** - * Returns if a run should be padded with empty space - * to take up as much room as the others. - */ - protected boolean shouldPadTabRun(int run, boolean aPriori) { - return aPriori; - } - - /** - * Returns the amount by which the run number run - * should be indented. Add a few pixels for every run to make - * diagonal lines align. - */ - protected int getTabRunIndent(int run) { - return 0; - } - - /** - * Returns the insets for the given tab. - */ - protected abstract Insets getTabInsets(int tabIndex, Insets tabInsets); - - /** - * Draws the rectancle around the Tab label which indicates keyboard focus. - */ - protected abstract void paintFocusIndicator( - Graphics g, - Rectangle[] rects, - int tabIndex, - Rectangle iconRect, - Rectangle textRect, - boolean isSelected); - - /** - * Fills the background of the given tab to make sure overlap of - * tabs is handled correctly. - */ - protected abstract void paintTabBackground(Graphics g, int tabIndex, int x, int y, int w, int h, boolean isSelected); - - /** - * Paints the border around the given tab. - */ - protected abstract void paintTabBorder(Graphics g, int tabIndex, int x, int y, int w, int h, boolean isSelected); - - /** - * Returns additional the insets for the selected tab. This allows to "raise" - * The selected tab over the others - */ - protected Insets getSelectedTabPadInsets() { - return EMPTY_INSETS; - } - - /** - * Draws the top edge of the border around the content area. - * Draw unbroken line for tabs are not on TOP - * override where appropriate. - */ - protected void paintContentBorderTopEdge( - Graphics g, - int x, - int y, - int w, - int h, - boolean drawBroken, - Rectangle selRect, - boolean isContentBorderPainted) { - if (isContentBorderPainted) { - g.setColor(selectHighlight); - g.fillRect(x, y, w - 1, 1); - } - } - - /** - * Draws the bottom edge of the Border around the content area. - * Draw broken line if selected tab is visible and adjacent to content - * and TabPlacement is same as painted edge. - */ - protected void paintContentBorderBottomEdge( - Graphics g, - int x, - int y, - int w, - int h, - boolean drawBroken, - Rectangle selRect, - boolean isContentBorderPainted) { - if (isContentBorderPainted) { - g.setColor(darkShadow); - g.fillRect(x, y + h - 1, w - 1, 1); - } - } - - /** - * Draws the left edge of the Border around the content area. - * Draw broken line if selected tab is visible and adjacent to content - * and TabPlacement is same as painted edge - */ - protected void paintContentBorderLeftEdge( - Graphics g, - int x, - int y, - int w, - int h, - boolean drawBroken, - Rectangle selRect, - boolean isContentBorderPainted) { - if (isContentBorderPainted) { - g.setColor(selectHighlight); - g.fillRect(x, y, 1, h - 1); - } - } - - /** - * Draws the right edge of the Border around the content area. - * Draw broken line if selected tab is visible and adjacent to content - * and TabPlacement is same as painted edge - */ - protected void paintContentBorderRightEdge( - Graphics g, - int x, - int y, - int w, - int h, - boolean drawBroken, - Rectangle selRect, - boolean isContentBorderPainted) { - if (isContentBorderPainted) { - g.setColor(darkShadow); - g.fillRect(x + w - 1, y, 1, h); - } - } - - /** - * Returns the amount of overlap for two tabs. - */ - protected int getTabsOverlay() { - return 0; - } - } - - /** - * The renderer for the case where tabs are displayed below the contents - * and with minimal decoration. - */ - private static final class BottomEmbeddedRenderer extends AbstractRenderer { - - private BottomEmbeddedRenderer(JTabbedPane tabPane) { - super(tabPane); - } - - protected Insets getTabAreaInsets(Insets insets) { - return EMPTY_INSETS; - } - - protected Insets getContentBorderInsets(Insets defaultInsets) { - return SOUTH_INSETS; - } - - protected Insets getSelectedTabPadInsets() { - return EMPTY_INSETS; - } - - protected Insets getTabInsets(int tabIndex, Insets tabInsets) { - return new Insets(tabInsets.top, tabInsets.left, tabInsets.bottom, tabInsets.right); - } - - /** - * Paints no focus: minimal decoration is really minimal. - */ - protected void paintFocusIndicator( - Graphics g, - Rectangle[] rects, - int tabIndex, - Rectangle iconRect, - Rectangle textRect, - boolean isSelected) { - // Embedded tabs paint no focus. - } - - protected void paintTabBackground(Graphics g, int tabIndex, int x, int y, int w, int h, boolean isSelected) { - - g.setColor(selectColor); - g.fillRect(x, y, w + 1, h); - } - - protected void paintTabBorder(Graphics g, int tabIndex, int x, int y, int w, int h, boolean isSelected) { - - int bottom = h; - int right = w + 1; - - g.translate(x, y); - if (isFirstDisplayedTab(tabIndex, x, tabPane.getBounds().x)) { - if (isSelected) { - // selected and first in line - g.setColor(shadowColor); - g.fillRect(right, 0, 1, bottom - 1); - g.fillRect(right - 1, bottom - 1, 1, 1); - // it is open to discussion if the outer border of the tab - // should be painted because in the primary case it won't - // be visible anyway. uncomment the following two lines if wanted - // g.fillRect(0,bottom, right, 1); - // g.fillRect(-1,0,1,bottom; - g.setColor(selectHighlight); - g.fillRect(0, 0, 1, bottom); - g.fillRect(right - 1, 0, 1, bottom - 1); - g.fillRect(1, bottom - 1, right - 2, 1); - } else { - //not selected and first in line - } - } else { - if (isSelected) { - //selected and not first in line - g.setColor(shadowColor); - g.fillRect(0, 0, 1, bottom - 1); - g.fillRect(1, bottom - 1, 1, 1); - g.fillRect(right, 0, 1, bottom - 1); - g.fillRect(right - 1, bottom - 1, 1, 1); - // outside line: - // g.fillRect(2,bottom, right-3, 1); - g.setColor(selectHighlight); - g.fillRect(1, 0, 1, bottom - 1); - g.fillRect(right - 1, 0, 1, bottom - 1); - g.fillRect(2, bottom - 1, right - 3, 1); - } else { - g.setColor(shadowColor); - g.fillRect(1, h / 2, 1, h - (h / 2)); - } - } - g.translate(-x, -y); - } - - protected void paintContentBorderBottomEdge( - Graphics g, - int x, - int y, - int w, - int h, - boolean drawBroken, - Rectangle selRect, - boolean isContentBorderPainted) { - - g.setColor(shadowColor); - g.fillRect(x, y + h - 1, w, 1); - } - - } - - /** - * The renderer for the case where Tabs are below the content and - * decoration is standard. - */ - private static final class BottomRenderer extends AbstractRenderer { - - private BottomRenderer(JTabbedPane tabPane) { - super(tabPane); - } - - protected Insets getTabAreaInsets(Insets defaultInsets) { - return new Insets(defaultInsets.top, defaultInsets.left + 5, defaultInsets.bottom, defaultInsets.right); - } - - protected int getTabLabelShiftY(int tabIndex, boolean isSelected) { - return isSelected ? 0 : -1; - } - - protected int getTabRunOverlay(int tabRunOverlay) { - return tabRunOverlay - 2; - } - - protected int getTabRunIndent(int run) { - return 6 * run; - } - - protected Insets getSelectedTabPadInsets() { - return SOUTH_INSETS; - } - - protected Insets getTabInsets(int tabIndex, Insets tabInsets) { - return new Insets(tabInsets.top, tabInsets.left - 2, tabInsets.bottom, tabInsets.right - 2); - } - - protected void paintFocusIndicator( - Graphics g, - Rectangle[] rects, - int tabIndex, - Rectangle iconRect, - Rectangle textRect, - boolean isSelected) { - - if (!tabPane.hasFocus() || !isSelected) - return; - Rectangle tabRect = rects[tabIndex]; - int top = tabRect.y; - int left = tabRect.x + 6; - int height = tabRect.height - 3; - int width = tabRect.width - 12; - g.setColor(focus); - g.drawRect(left, top, width, height); - } - - protected void paintTabBackground(Graphics g, int tabIndex, int x, int y, int w, int h, boolean isSelected) { - - g.setColor(selectColor); - g.fillRect(x, y, w, h); - } - - protected void paintTabBorder(Graphics g, int tabIndex, int x, int y, int w, int h, boolean isSelected) { - - int bottom = h - 1; - int right = w + 4; - - g.translate(x - 3, y); - - // Paint Border - g.setColor(selectHighlight); - - // Paint left - g.fillRect(0, 0, 1, 2); - g.drawLine(0, 2, 4, bottom - 4); - g.fillRect(5, bottom - 3, 1, 2); - g.fillRect(6, bottom - 1, 1, 1); - - // Paint bootom - g.fillRect(7, bottom, 1, 1); - g.setColor(darkShadow); - g.fillRect(8, bottom, right - 13, 1); - - // Paint right - g.drawLine(right + 1, 0, right - 3, bottom - 4); - g.fillRect(right - 4, bottom - 3, 1, 2); - g.fillRect(right - 5, bottom - 1, 1, 1); - - g.translate(-x + 3, -y); - } - - protected void paintContentBorderBottomEdge( - Graphics g, - int x, - int y, - int w, - int h, - boolean drawBroken, - Rectangle selRect, - boolean isContentBorderPainted) { - int bottom = y + h - 1; - int right = x + w - 1; - g.translate(x, bottom); - if (drawBroken && selRect.x >= x && selRect.x <= x + w) { - // Break line to show visual connection to selected tab - g.setColor(darkShadow); - g.fillRect(0, 0, selRect.x - x - 2, 1); - if (selRect.x + selRect.width < x + w - 2) { - g.setColor(darkShadow); - g.fillRect(selRect.x + selRect.width + 2 - x, 0, right - selRect.x - selRect.width - 2, 1); - } - } else { - g.setColor(darkShadow); - g.fillRect(0, 0, w - 1, 1); - } - g.translate(-x, -bottom); - } - - protected int getTabsOverlay() { - return 4; - } - - } - - /** - * The renderer for tabs on the left with minimal decoration. - */ - private static final class LeftEmbeddedRenderer extends AbstractRenderer { - - private LeftEmbeddedRenderer(JTabbedPane tabPane) { - super(tabPane); - } - - protected Insets getTabAreaInsets(Insets insets) { - return EMPTY_INSETS; - } - - protected Insets getContentBorderInsets(Insets defaultInsets) { - return WEST_INSETS; - } - - protected int getTabRunOverlay(int tabRunOverlay) { - return 0; - } - - protected boolean shouldPadTabRun(int run, boolean aPriori) { - return false; - } - - protected Insets getTabInsets(int tabIndex, Insets tabInsets) { - return new Insets(tabInsets.top, tabInsets.left, tabInsets.bottom, tabInsets.right); - } - - protected Insets getSelectedTabPadInsets() { - return EMPTY_INSETS; - } - - /** - * minimal decoration is really minimal: no focus. - */ - protected void paintFocusIndicator( - Graphics g, - Rectangle[] rects, - int tabIndex, - Rectangle iconRect, - Rectangle textRect, - boolean isSelected) { - // Embedded tabs paint no focus. - } - - protected void paintTabBackground(Graphics g, int tabIndex, int x, int y, int w, int h, boolean isSelected) { - g.setColor(selectColor); - g.fillRect(x, y, w, h); - } - - protected void paintTabBorder(Graphics g, int tabIndex, int x, int y, int w, int h, boolean isSelected) { - - int bottom = h; - int right = w; - - g.translate(x, y); - - if (isFirstDisplayedTab(tabIndex, y, tabPane.getBounds().y)) { - if (isSelected) { - //selected and first in line - g.setColor(selectHighlight); - g.fillRect(0, 0, right, 1); - g.fillRect(0, 0, 1, bottom - 1); - g.fillRect(1, bottom - 1, right - 1, 1); - g.setColor(shadowColor); - g.fillRect(0, bottom - 1, 1, 1); - g.fillRect(1, bottom, right - 1, 1); - // outside line: - // g.fillRect(-1,0,1,bottom-1) - } else { - //not selected but first in line - } - } else { - if (isSelected) { - //selected but not first in line - g.setColor(selectHighlight); - g.fillRect(1, 1, right - 1, 1); - g.fillRect(0, 2, 1, bottom - 2); - g.fillRect(1, bottom - 1, right - 1, 1); - g.setColor(shadowColor); - g.fillRect(1, 0, right - 1, 1); - g.fillRect(0, 1, 1, 1); - g.fillRect(0, bottom - 1, 1, 1); - g.fillRect(1, bottom, right - 1, 1); - // outside line: - // g.fillRect(-1,2,1,bottom-3) - } else { - g.setColor(shadowColor); - g.fillRect(0, 0, right / 3, 1); - } - } - - g.translate(-x, -y); - } - - protected void paintContentBorderLeftEdge( - Graphics g, - int x, - int y, - int w, - int h, - boolean drawBroken, - Rectangle selRect, - boolean isContentBorderPainted) { - g.setColor(shadowColor); - g.fillRect(x, y, 1, h); - } - } - - /** - * Renderer for tabs on the left with normal decoration. - */ - private static final class LeftRenderer extends AbstractRenderer { - - private LeftRenderer(JTabbedPane tabPane) { - super(tabPane); - } - - protected Insets getTabAreaInsets(Insets defaultInsets) { - return new Insets(defaultInsets.top + 4, defaultInsets.left, defaultInsets.bottom, defaultInsets.right); - } - - protected int getTabLabelShiftX(int tabIndex, boolean isSelected) { - return 1; - } - - protected int getTabRunOverlay(int tabRunOverlay) { - return 1; - } - - protected boolean shouldPadTabRun(int run, boolean aPriori) { - return false; - } - - protected Insets getTabInsets(int tabIndex, Insets tabInsets) { - return new Insets(tabInsets.top, tabInsets.left - 5, tabInsets.bottom + 1, tabInsets.right - 5); - } - - protected Insets getSelectedTabPadInsets() { - return WEST_INSETS; - } - - protected void paintFocusIndicator( - Graphics g, - Rectangle[] rects, - int tabIndex, - Rectangle iconRect, - Rectangle textRect, - boolean isSelected) { - - if (!tabPane.hasFocus() || !isSelected) - return; - Rectangle tabRect = rects[tabIndex]; - int top = tabRect.y + 2; - int left = tabRect.x + 3; - int height = tabRect.height - 5; - int width = tabRect.width - 6; - g.setColor(focus); - g.drawRect(left, top, width, height); - } - - protected void paintTabBackground(Graphics g, int tabIndex, int x, int y, int w, int h, boolean isSelected) { - if (!isSelected) { - g.setColor(selectLight); - g.fillRect(x + 1, y + 1, w - 1, h - 2); - } else { - g.setColor(selectColor); - g.fillRect(x + 1, y + 1, w - 3, h - 2); - } - } - - protected void paintTabBorder(Graphics g, int tabIndex, int x, int y, int w, int h, boolean isSelected) { - - int bottom = h - 1; - int left = 0; - g.translate(x, y); - - // Paint Border - g.setColor(selectHighlight); - // Paint top - g.fillRect(left + 2, 0, w - 2 - left, 1); - - // Paint left - g.fillRect(left + 1, 1, 1, 1); - g.fillRect(left, 2, 1, bottom - 3); - g.setColor(darkShadow); - g.fillRect(left + 1, bottom - 1, 1, 1); - - // Paint bottom - g.fillRect(left + 2, bottom, w - 2 - left, 1); - - g.translate(-x, -y); - } - - protected void paintContentBorderLeftEdge( - Graphics g, - int x, - int y, - int w, - int h, - boolean drawBroken, - Rectangle selRect, - boolean isContentBorderPainted) { - g.setColor(selectHighlight); - if (drawBroken && selRect.y >= y && selRect.y <= y + h) { - // Break line to show visual connection to selected tab - g.fillRect(x, y, 1, selRect.y + 1 - y); - if (selRect.y + selRect.height < y + h - 2) { - g.fillRect(x, selRect.y + selRect.height - 1, 1, y + h - selRect.y - selRect.height); - } - } else { - g.fillRect(x, y, 1, h - 1); - } - } - - } - - /** - * The renderer for tabs on the right with minimal decoration. - */ - private static final class RightEmbeddedRenderer extends AbstractRenderer { - - private RightEmbeddedRenderer(JTabbedPane tabPane) { - super(tabPane); - } - - protected Insets getTabAreaInsets(Insets insets) { - return EMPTY_INSETS; - } - - protected Insets getContentBorderInsets(Insets defaultInsets) { - return EAST_INSETS; - } - - protected int getTabRunIndent(int run) { - return 4 * run; - } - - protected int getTabRunOverlay(int tabRunOverlay) { - return 0; - } - - protected boolean shouldPadTabRun(int run, boolean aPriori) { - return false; - } - - protected Insets getTabInsets(int tabIndex, Insets tabInsets) { - return new Insets(tabInsets.top, tabInsets.left, tabInsets.bottom, tabInsets.right); - } - - protected Insets getSelectedTabPadInsets() { - return EMPTY_INSETS; - } - - /** - * Minimal decoration: no focus. - */ - protected void paintFocusIndicator( - Graphics g, - Rectangle[] rects, - int tabIndex, - Rectangle iconRect, - Rectangle textRect, - boolean isSelected) { - // Embedded tabs paint no focus. - } - - protected void paintTabBackground(Graphics g, int tabIndex, int x, int y, int w, int h, boolean isSelected) { - - g.setColor(selectColor); - g.fillRect(x, y, w, h); - } - - protected void paintTabBorder(Graphics g, int tabIndex, int x, int y, int w, int h, boolean isSelected) { - - int bottom = h; - int right = w - 1; - - g.translate(x + 1, y); - - if (isFirstDisplayedTab(tabIndex, y, tabPane.getBounds().y)) { - if (isSelected) { - //selected and first in line - g.setColor(shadowColor); - //outside lines: - // g.fillRect(0,-1,right,1); - // g.fillRect(right,-1,1,bottom); - g.fillRect(right - 1, bottom - 1, 1, 1); - g.fillRect(0, bottom, right - 1, 1); - g.setColor(selectHighlight); - g.fillRect(0, 0, right - 1, 1); - g.fillRect(right - 1, 0, 1, bottom - 1); - g.fillRect(0, bottom - 1, right - 1, 1); - } - } else { - if (isSelected) { - //selected but not first in line - g.setColor(shadowColor); - g.fillRect(0, -1, right - 1, 1); - g.fillRect(right - 1, 0, 1, 1); - //outside line: - // g.fillRect(right,0,1,bottom); - g.fillRect(right - 1, bottom - 1, 1, 1); - g.fillRect(0, bottom, right - 1, 1); - g.setColor(selectHighlight); - g.fillRect(0, 0, right - 1, 1); - g.fillRect(right - 1, 1, 1, bottom - 2); - g.fillRect(0, bottom - 1, right - 1, 1); - } else { - //not selected and not first in line - g.setColor(shadowColor); - g.fillRect(2 * right / 3, 0, right / 3, 1); - } - } - g.translate(-x - 1, -y); - } - - protected void paintContentBorderRightEdge( - Graphics g, - int x, - int y, - int w, - int h, - boolean drawBroken, - Rectangle selRect, - boolean isContentBorderPainted) { - g.setColor(shadowColor); - g.fillRect(x + w - 1, y, 1, h); - } - - } - - /** - * Renderer for tabs on the right with normal decoration. - */ - private static final class RightRenderer extends AbstractRenderer { - - private RightRenderer(JTabbedPane tabPane) { - super(tabPane); - } - - protected int getTabLabelShiftX(int tabIndex, boolean isSelected) { - return 1; - } - - protected int getTabRunOverlay(int tabRunOverlay) { - return 1; - } - - protected boolean shouldPadTabRun(int run, boolean aPriori) { - return false; - } - - protected Insets getTabInsets(int tabIndex, Insets tabInsets) { - return new Insets(tabInsets.top, tabInsets.left - 5, tabInsets.bottom + 1, tabInsets.right - 5); - } - - protected Insets getSelectedTabPadInsets() { - return EAST_INSETS; - } - - protected void paintFocusIndicator( - Graphics g, - Rectangle[] rects, - int tabIndex, - Rectangle iconRect, - Rectangle textRect, - boolean isSelected) { - - if (!tabPane.hasFocus() || !isSelected) - return; - Rectangle tabRect = rects[tabIndex]; - int top = tabRect.y + 2; - int left = tabRect.x + 3; - int height = tabRect.height - 5; - int width = tabRect.width - 6; - g.setColor(focus); - g.drawRect(left, top, width, height); - } - - protected void paintTabBackground(Graphics g, int tabIndex, int x, int y, int w, int h, boolean isSelected) { - if (!isSelected) { - g.setColor(selectLight); - g.fillRect(x, y, w, h); - } else { - g.setColor(selectColor); - g.fillRect(x + 2, y, w - 2, h); - } - } - - protected void paintTabBorder(Graphics g, int tabIndex, int x, int y, int w, int h, boolean isSelected) { - - int bottom = h - 1; - int right = w; - - g.translate(x, y); - - // Paint Border - - g.setColor(selectHighlight); - g.fillRect(0, 0, right - 1, 1); - // Paint right - g.setColor(darkShadow); - g.fillRect(right - 1, 1, 1, 1); - g.fillRect(right, 2, 1, bottom - 3); - // Paint bottom - g.fillRect(right - 1, bottom - 1, 1, 1); - g.fillRect(0, bottom, right - 1, 1); - - g.translate(-x, -y); - } - - protected void paintContentBorderRightEdge( - Graphics g, - int x, - int y, - int w, - int h, - boolean drawBroken, - Rectangle selRect, - boolean isContentBorderPainted) { - g.setColor(darkShadow); - if (drawBroken && selRect.y >= y && selRect.y <= y + h) { - // Break line to show visual connection to selected tab - g.fillRect(x + w - 1, y, 1, selRect.y - y); - if (selRect.y + selRect.height < y + h - 2) { - g.fillRect(x + w - 1, selRect.y + selRect.height, 1, y + h - selRect.y - selRect.height); - } - } else { - g.fillRect(x + w - 1, y, 1, h - 1); - } - } - } - - /** - * Renderer for tabs on top with minimal decoration. - */ - private static final class TopEmbeddedRenderer extends AbstractRenderer { - - private TopEmbeddedRenderer(JTabbedPane tabPane) { - super(tabPane); - } - - protected Insets getTabAreaInsets(Insets insets) { - return EMPTY_INSETS; - } - - protected Insets getContentBorderInsets(Insets defaultInsets) { - return NORTH_INSETS; - } - - protected Insets getTabInsets(int tabIndex, Insets tabInsets) { - return new Insets(tabInsets.top, tabInsets.left + 1, tabInsets.bottom, tabInsets.right); - } - - protected Insets getSelectedTabPadInsets() { - return EMPTY_INSETS; - } - - /** - * Minimal decoration: no focus. - */ - protected void paintFocusIndicator( - Graphics g, - Rectangle[] rects, - int tabIndex, - Rectangle iconRect, - Rectangle textRect, - boolean isSelected) { - // Embedded tabs paint no focus. - } - - protected void paintTabBackground(Graphics g, int tabIndex, int x, int y, int w, int h, boolean isSelected) { - - g.setColor(selectColor); - g.fillRect(x, y, w, h); - } - - protected void paintTabBorder(Graphics g, int tabIndex, int x, int y, int w, int h, boolean isSelected) { - - g.translate(x, y); - - int right = w; - int bottom = h; - - if (isFirstDisplayedTab(tabIndex, x, tabPane.getBounds().x)) { - if (isSelected) { - g.setColor(selectHighlight); - //left - g.fillRect(0, 0, 1, bottom); - //top - g.fillRect(0, 0, right - 1, 1); - //right - g.fillRect(right - 1, 0, 1, bottom); - g.setColor(shadowColor); - //topright corner - g.fillRect(right - 1, 0, 1, 1); - //right - g.fillRect(right, 1, 1, bottom); - } - } else { - if (isSelected) { - g.setColor(selectHighlight); - //left - g.fillRect(1, 1, 1, bottom - 1); - //top - g.fillRect(2, 0, right - 3, 1); - //right - g.fillRect(right - 1, 1, 1, bottom - 1); - g.setColor(shadowColor); - //left - g.fillRect(0, 1, 1, bottom - 1); - //topleft corner - g.fillRect(1, 0, 1, 1); - //topright corner - g.fillRect(right - 1, 0, 1, 1); - //right - g.fillRect(right, 1, 1, bottom); - } else { - g.setColor(shadowColor); - g.fillRect(0, 0, 1, bottom +2 - bottom / 2); - } - } - g.translate(-x, -y); - } - - protected void paintContentBorderTopEdge( - Graphics g, - int x, - int y, - int w, - int h, - boolean drawBroken, - Rectangle selRect, - boolean isContentBorderPainted) { - g.setColor(shadowColor); - g.fillRect(x, y, w, 1); - } - - } - - /** - * Renderer for tabs on top with normal decoration. - */ - private static final class TopRenderer extends AbstractRenderer { - - private TopRenderer(JTabbedPane tabPane) { - super(tabPane); - } - - protected Insets getTabAreaInsets(Insets defaultInsets) { - return new Insets(defaultInsets.top, defaultInsets.left + 4, defaultInsets.bottom, defaultInsets.right); - } - - protected int getTabLabelShiftY(int tabIndex, boolean isSelected) { - return isSelected ? -1 : 0; - } - - protected int getTabRunOverlay(int tabRunOverlay) { - return tabRunOverlay - 2; - } - - protected int getTabRunIndent(int run) { - return 6 * run; - } - - protected Insets getSelectedTabPadInsets() { - return NORTH_INSETS; - } - - protected Insets getTabInsets(int tabIndex, Insets tabInsets) { - return new Insets(tabInsets.top-1, tabInsets.left - 4, tabInsets.bottom, tabInsets.right - 4); - } - - protected void paintFocusIndicator( - Graphics g, - Rectangle[] rects, - int tabIndex, - Rectangle iconRect, - Rectangle textRect, - boolean isSelected) { - - if (!tabPane.hasFocus() || !isSelected) - return; - Rectangle tabRect = rects[tabIndex]; - int top = tabRect.y +1 ; - int left = tabRect.x + 4; - int height = tabRect.height - 3; - int width = tabRect.width - 9; - g.setColor(focus); - g.drawRect(left, top, width, height); - } - - protected void paintTabBackground(Graphics g, int tabIndex, int x, int y, int w, int h, boolean isSelected) { - - int sel = (isSelected) ? 0 : 1; - g.setColor(selectColor); - g.fillRect(x, y + sel, w, h / 2); - g.fillRect(x - 1, y + sel + h / 2, w + 2, h - h / 2); - } - - protected void paintTabBorder(Graphics g, int tabIndex, int x, int y, int w, int h, boolean isSelected) { - - g.translate(x - 4, y); - - int top = 0; - int right = w + 6; - - // Paint Border - g.setColor(selectHighlight); - - // Paint left - g.drawLine(1, h - 1, 4, top + 4); - g.fillRect(5, top + 2, 1, 2); - g.fillRect(6, top + 1, 1, 1); - - // Paint top - g.fillRect(7, top, right - 12, 1); - - // Paint right - g.setColor(darkShadow); - g.drawLine(right, h - 1, right - 3, top + 4); - g.fillRect(right - 4, top + 2, 1, 2); - g.fillRect(right - 5, top + 1, 1, 1); - - g.translate(-x + 4, -y); - } - - protected void paintContentBorderTopEdge( - Graphics g, - int x, - int y, - int w, - int h, - boolean drawBroken, - Rectangle selRect, - boolean isContentBorderPainted) { - int right = x + w - 1; - int top = y; - g.setColor(selectHighlight); - - if (drawBroken && selRect.x >= x && selRect.x <= x + w) { - // Break line to show visual connection to selected tab - g.fillRect(x, top, selRect.x - 2 - x, 1); - if (selRect.x + selRect.width < x + w - 2) { - g.fillRect(selRect.x + selRect.width + 2, top, right - 2 - selRect.x - selRect.width, 1); - } else { - g.fillRect(x + w - 2, top, 1, 1); - } - } else { - g.fillRect(x, top, w - 1, 1); - } - } - - protected int getTabsOverlay() { - return 6; - } - } - -} \ No newline at end of file diff --git a/org.adempiere.ui.swing/src/org/adempiere/plaf/AdempiereTaskPaneUI.java b/org.adempiere.ui.swing/src/org/adempiere/plaf/AdempiereTaskPaneUI.java deleted file mode 100644 index 55250dba9d..0000000000 --- a/org.adempiere.ui.swing/src/org/adempiere/plaf/AdempiereTaskPaneUI.java +++ /dev/null @@ -1,109 +0,0 @@ -package org.adempiere.plaf; - -import java.awt.GradientPaint; -import java.awt.Graphics; -import java.awt.Graphics2D; -import java.awt.Paint; -import java.awt.Rectangle; -import java.awt.RenderingHints; - -import javax.swing.JComponent; -import javax.swing.border.Border; -import javax.swing.plaf.ColorUIResource; -import javax.swing.plaf.ComponentUI; - -import org.jdesktop.swingx.JXTaskPane; -import org.jdesktop.swingx.plaf.basic.BasicTaskPaneUI; - -public class AdempiereTaskPaneUI extends BasicTaskPaneUI { - public static ComponentUI createUI(JComponent c) { - return new AdempiereTaskPaneUI(); - } - - protected Border createPaneBorder() { - return new AdempierePaneBorder(); - } - - /** - * Overriden to paint the background of the component but keeping the - * rounded corners. - */ - public void update(Graphics g, JComponent c) { - if (c.isOpaque()) { - g.setColor(new ColorUIResource(251, 248, 241)); - g.fillRect(0, 0, c.getWidth(), c.getHeight()); - g.setColor(new ColorUIResource(251, 248, 241)); - g.fillRect(0, getRoundHeight(), c.getWidth(), c.getHeight() - - getRoundHeight()); - } - paint(g, c); - } - - /** - * The border of the taskpane group paints the "text", the "icon", the - * "expanded" status and the "special" type. - * - */ - class AdempierePaneBorder extends PaneBorder { - - protected void paintTitleBackground(JXTaskPane group, Graphics g) { - if (group.isSpecial()) { - g.setColor(new ColorUIResource(251, 248, 241)); - g.fillRoundRect(0, 0, group.getWidth(), getRoundHeight() * 2, - getRoundHeight(), getRoundHeight()); - g.fillRect(0, getRoundHeight(), group.getWidth(), getTitleHeight(group) - - getRoundHeight()); - } else { - Paint oldPaint = ((Graphics2D) g).getPaint(); - GradientPaint gradient = new GradientPaint(0f, 0f, // group.getWidth() - // / 2, - new ColorUIResource(241, 239, 222), 0f, // group.getWidth(), - getTitleHeight(group), new ColorUIResource(251, 248, 241)); - - ((Graphics2D) g).setRenderingHint( - RenderingHints.KEY_COLOR_RENDERING, - RenderingHints.VALUE_COLOR_RENDER_QUALITY); - ((Graphics2D) g).setRenderingHint( - RenderingHints.KEY_INTERPOLATION, - RenderingHints.VALUE_INTERPOLATION_BILINEAR); - ((Graphics2D) g).setRenderingHint(RenderingHints.KEY_RENDERING, - RenderingHints.VALUE_RENDER_QUALITY); - ((Graphics2D) g).setPaint(gradient); - - g.fillRoundRect(0, 0, group.getWidth(), getRoundHeight() * 2, - getRoundHeight(), getRoundHeight()); - g.fillRect(0, getRoundHeight(), group.getWidth(), getTitleHeight(group) - - getRoundHeight()); - ((Graphics2D) g).setPaint(oldPaint); - } - - Rectangle oldRect = g.getClipBounds(); - g.setClip(0, 0, group.getWidth(), getTitleHeight(group)); - g.setColor(borderColor); - g.drawRoundRect(0, 0, group.getWidth() - 1, getTitleHeight(group) - + getRoundHeight(), getRoundHeight(), getRoundHeight()); - g.drawLine(0, getTitleHeight(group) - 1, group.getWidth(), getTitleHeight(group) - 1); - g.setClip(oldRect); - } - - protected void paintExpandedControls(JXTaskPane group, Graphics g, - int x, int y, int width, int height) { - ((Graphics2D) g).setRenderingHint(RenderingHints.KEY_ANTIALIASING, - RenderingHints.VALUE_ANTIALIAS_ON); - - paintOvalAroundControls(group, g, x, y, width, height); - g.setColor(getPaintColor(group)); - paintChevronControls(group, g, x, y, width, height); - - ((Graphics2D) g).setRenderingHint(RenderingHints.KEY_ANTIALIASING, - RenderingHints.VALUE_ANTIALIAS_OFF); - } - - @Override - protected boolean isMouseOverBorder() { - return true; - } - - } - -} diff --git a/org.adempiere.ui.swing/src/org/adempiere/plaf/AdempiereTheme.java b/org.adempiere.ui.swing/src/org/adempiere/plaf/AdempiereTheme.java deleted file mode 100644 index d6135f0e71..0000000000 --- a/org.adempiere.ui.swing/src/org/adempiere/plaf/AdempiereTheme.java +++ /dev/null @@ -1,425 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 Adempiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - *****************************************************************************/ -package org.adempiere.plaf; - - -import java.awt.Color; -import java.awt.Dimension; -import java.awt.Font; -import java.awt.SystemColor; -import java.awt.Toolkit; -import java.util.logging.Logger; - -import javax.swing.UIDefaults; -import javax.swing.plaf.ColorUIResource; -import javax.swing.plaf.FontUIResource; - -import org.compiere.swing.ColorBlind; -import org.compiere.swing.ExtendedTheme; - -import com.jgoodies.looks.plastic.PlasticScrollBarUI; - - -/** - * A theme based on GTK2-Gilouche and tango project iconset. - * It has been optimized to work with Suse SLED 10 default desktop settings. - * - * - * @author vpj-cd - * @version $Revision: 1.0 $ - * @author Low Heng Sin - * - Fixed invisible disactive component issue - * - Use red instead of green as background for error field - */ -public class AdempiereTheme extends com.jgoodies.looks.plastic.PlasticTheme { - - - /** - * Return Theme Name - * @return Theme Name - */ - public String getName() - { - return s_name; - } // getName - - - /** - * String Representation - * @return info - */ - public String toString () - { - return getName(); - } // toString - - - - /** Static Initializer */ - static - { - s_theme = new org.adempiere.plaf.AdempiereTheme(); - } - - //------------------------------------------------- - /** Theme Name */ - protected static String s_name = "Adempiere Theme"; - - public static final String NAME = s_name; - /** Logger */ - protected static Logger log = Logger.getLogger(org.adempiere.plaf.AdempiereTheme.class.getName()); - /** Active Theme */ - protected static AdempiereTheme s_theme = null; - - /** Blue 51,51,102 */ - public static ColorUIResource primary0 = new ColorUIResource(103, 152, 203); - /** Blue 102, 102, 153 */ - //protected static ColorUIResource primary1; - public static ColorUIResource primary1 = new ColorUIResource( 101, 138, 187); - /** Blue 153, 153, 204 */ - public static ColorUIResource primary2 = new ColorUIResource(103, 152, 203); - /** Blue 204, 204, 255 */ - public static ColorUIResource primary3= new ColorUIResource(233, 238, 245); // - - /** Black */ - public final ColorUIResource secondary0 = new ColorUIResource(0, 0, 0); - /** Gray 102, 102, 102 */ - public static ColorUIResource secondary1= new ColorUIResource(190, 179, 153); - /** Gray 153, 153, 153 */ - public static ColorUIResource secondary2= new ColorUIResource(196, 189, 174); - /** BlueGray 214, 224, 234 - background */ - public static ColorUIResource secondary3= new ColorUIResource(251, 248, 241); - /** White */ - public final ColorUIResource secondary4 = new ColorUIResource(255, 255, 255); - - /** Black */ - public static ColorUIResource black = BLACK; - /** White */ - public static ColorUIResource white = WHITE; - - /** Background for mandatory fields */ - //public static ColorUIResource mandatory = new ColorUIResource(233, 238, 245); // blueish - public static ColorUIResource mandatory = new ColorUIResource(205, 225, 245); // BF[ 1640919 ] Adempiere Theme aspect problem - - /** Background for fields in error */ - //Gree for error is confusing new ColorUIResource(220, 241, 203); // green ; - public static ColorUIResource error = new ColorUIResource(255, 204, 204); // red-isch - /** Background for inactive fields */ - public static ColorUIResource inactive = new ColorUIResource(241,239,222); //234, 234, 234); - /** Background for info fields */ - public static ColorUIResource info = new ColorUIResource(251, 248, 251); // somewhat white - - /** Foreground Text OK */ - public static ColorUIResource txt_ok =new ColorUIResource(0, 153, 255); // blue ; - /** Foreground Text Error */ - public static ColorUIResource txt_error = new ColorUIResource(255, 0, 51); // red ; - - /** Control font */ - public static FontUIResource controlFont; - /** System font */ - public static FontUIResource systemFont; - /** User font */ - public static FontUIResource userFont; - /** Small font */ - public static FontUIResource smallFont; - /** Window Title font */ - public static FontUIResource windowFont; - /** Menu font */ - public static FontUIResource menuFont; - - /** Default Font */ - public static final String FONT_DEFAULT = "Dialog"; - /** Default Font Size */ - public static int FONT_SIZE = 12; - - static { - //set font size base on screen resolution - try { - Dimension size = Toolkit.getDefaultToolkit().getScreenSize(); - if (size.width <= 800) - FONT_SIZE = 9; - else if (size.width <= 1024) - FONT_SIZE = 10; - else if (size.width <= 1280) - FONT_SIZE = 11; - else if (size.width <= 1400) - FONT_SIZE = 12; - else if (size.width <= 1600) - FONT_SIZE = 13; - else - FONT_SIZE = 14; - } catch (Throwable t) {} - } - - /************************************************************************** - * Get Primary 1 (blue in default Metal Theme) - * @return color - */ - public ColorUIResource getPrimary1() - { - return ColorBlind.getDichromatColorUIResource(primary1); - } - public ColorUIResource getPrimary2() - { - return ColorBlind.getDichromatColorUIResource(primary2); - } - public ColorUIResource getPrimary3() - { - return ColorBlind.getDichromatColorUIResource(primary3); - } - - /** - * Get Secondary 1 (gray in default Metal Theme) - * @return color - */ - public ColorUIResource getSecondary0() - { - return ColorBlind.getDichromatColorUIResource(secondary0); - } - public ColorUIResource getSecondary1() - { - return ColorBlind.getDichromatColorUIResource(secondary1); - } - public ColorUIResource getSecondary2() - { - return ColorBlind.getDichromatColorUIResource(secondary2); - } - public ColorUIResource getSecondary3() - { - return ColorBlind.getDichromatColorUIResource(secondary3); - } - public ColorUIResource getSecondary4() - { - return ColorBlind.getDichromatColorUIResource(secondary4); - } - - public ColorUIResource getBlack() - { - return ColorBlind.getDichromatColorUIResource(black); - } - public ColorUIResource getWhite() - { - return ColorBlind.getDichromatColorUIResource(white); - } - - /** - * Control Font (plain) - * @return font - */ - protected static FontUIResource _getControlTextFont() - { - if (controlFont == null) - { - try - { - controlFont = new FontUIResource(Font.getFont("swing.plaf.metal.controlFont", - new Font(FONT_DEFAULT, Font.PLAIN, FONT_SIZE))); - } - catch (Exception e) - { - controlFont = new FontUIResource(FONT_DEFAULT, Font.PLAIN, FONT_SIZE); - } - } - return controlFont; - } - public FontUIResource getControlTextFont() {return _getControlTextFont();} - - /** - * System Font - * @return font - */ - protected static FontUIResource _getSystemTextFont() - { - if (systemFont == null) - { - try - { - systemFont = new FontUIResource(Font.getFont("swing.plaf.metal.systemFont", - new Font(FONT_DEFAULT, Font.PLAIN, FONT_SIZE))); - } - catch (Exception e) - { - systemFont = new FontUIResource(FONT_DEFAULT, Font.PLAIN, FONT_SIZE); - } - } - return systemFont; - } - public FontUIResource getSystemTextFont() {return _getSystemTextFont();} - - /** - * User Font - * @return font - */ - protected static FontUIResource _getUserTextFont() - { - if (userFont == null) - { - try - { - userFont = new FontUIResource(Font.getFont("swing.plaf.metal.userFont", - new Font(FONT_DEFAULT, Font.PLAIN, FONT_SIZE))); - } - catch (Exception e) - { - userFont = new FontUIResource(FONT_DEFAULT, Font.PLAIN, FONT_SIZE); - } - } - return userFont; - } - public FontUIResource getUserTextFont() {return _getUserTextFont();} - - /** - * Menu - * @return font - */ - protected static FontUIResource _getMenuTextFont() - { - if (menuFont == null) - { - try - { - menuFont = new FontUIResource(Font.getFont("swing.plaf.metal.menuFont", - new Font(FONT_DEFAULT, Font.PLAIN, FONT_SIZE))); - } - catch (Exception e) - { - menuFont = new FontUIResource(FONT_DEFAULT, Font.PLAIN, FONT_SIZE); - } - } - return menuFont; - } - public FontUIResource getMenuTextFont() {return _getMenuTextFont();} - - /** - * Window Title - * @return font - */ - protected static FontUIResource _getWindowTitleFont() - { - if (windowFont == null) - { - try - { - windowFont = new FontUIResource(Font.getFont("swing.plaf.metal.windowFont", - new Font(FONT_DEFAULT, Font.BOLD, FONT_SIZE+2))); - } - catch (Exception e) - { - windowFont = new FontUIResource(FONT_DEFAULT, Font.BOLD, FONT_SIZE+2); - } - } - return windowFont; - } - public FontUIResource getWindowTitleFont() {return _getWindowTitleFont();} - - /** - * Sub Text - * @return font - */ - protected static FontUIResource _getSubTextFont() - { - if (smallFont == null) - { - try - { - smallFont = new FontUIResource(Font.getFont("swing.plaf.metal.smallFont", - new Font(FONT_DEFAULT, Font.PLAIN, FONT_SIZE-2))); - } - catch (Exception e) - { - smallFont = new FontUIResource(FONT_DEFAULT, Font.PLAIN, FONT_SIZE-2); - } - } - return smallFont; - } - public FontUIResource getSubTextFont() {return _getSubTextFont();} - - /** - * Parses Color into String representation. - * Required as SystemColors and Alpha Colors have different formats - * @param c Color - * @return [r=102,g=102,b=153,a=255] - * @see #parseColor - */ - public static String getColorAsString (Color c) - { - if (c == null) - c = SystemColor.control; - StringBuffer sb = new StringBuffer("[r=").append(c.getRed()) - .append(",g=").append(c.getGreen()) - .append(",b=").append(c.getBlue()) - .append(",a=").append(c.getAlpha()) - .append("]"); - // System.out.println(sb.toString()); - return sb.toString(); - } // getColorAsString - - /** - * Set Default Colors - */ - public void setDefault() - { - } // setDefault - - //----------------------------------------------------- - - - public ColorUIResource getFocusColor() { - return getPrimary2(); - } - - public ColorUIResource getPrimaryControlShadow() { - return getPrimary3(); - } - - public ColorUIResource getMenuSelectedBackground() { - return getPrimary1(); - } - public ColorUIResource getMenuSelectedForeground() { - return WHITE; - } - - public ColorUIResource getMenuItemBackground() { - return WHITE; - } - - public ColorUIResource getToggleButtonCheckColor() { - return new ColorUIResource( 220, 241, 203); - } - - public void addCustomEntriesToTable(UIDefaults table) { - super.addCustomEntriesToTable(table); - Object[] uiDefaults = - { - "ScrollBar.thumbHighlight", - getPrimaryControlHighlight(), - PlasticScrollBarUI.MAX_BUMPS_WIDTH_KEY, - Integer.valueOf(22), - PlasticScrollBarUI.MAX_BUMPS_WIDTH_KEY, Integer.valueOf(30), - //"TabbedPane.selected", getWhite(), - "TabbedPane.selectHighlight", new ColorUIResource(231, 218, 188), - ExtendedTheme.ERROR_BG_KEY, - error, - ExtendedTheme.ERROR_FG_KEY, - txt_error, - ExtendedTheme.INACTIVE_BG_KEY, - inactive, - ExtendedTheme.INFO_BG_KEY, - info, - ExtendedTheme.MANDATORY_BG_KEY, - mandatory - }; - table.putDefaults(uiDefaults); - } -} diff --git a/org.adempiere.ui.swing/src/org/adempiere/plaf/AdempiereThemeInnova.java b/org.adempiere.ui.swing/src/org/adempiere/plaf/AdempiereThemeInnova.java deleted file mode 100644 index fdf15f7308..0000000000 --- a/org.adempiere.ui.swing/src/org/adempiere/plaf/AdempiereThemeInnova.java +++ /dev/null @@ -1,111 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 Adempiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - *****************************************************************************/ -package org.adempiere.plaf; - -import javax.swing.plaf.ColorUIResource; - -/** - * Adempiere default Blue Metal Color Theme - * - * @author Jorg Janke, Adam Michau - * @version $Id: AdempiereThemeBlueMetal.java,v 1.2 2006/07/30 00:52:24 jjanke Exp $ - */ -public class AdempiereThemeInnova extends org.adempiere.plaf.AdempiereTheme -{ - /** - * Adempiere default Theme Blue Metal - */ - public AdempiereThemeInnova() - { - setDefault(); - s_theme = this; - s_name = NAME; - } // AdempiereThemeBlueMetal - - /** Name */ - public static final String NAME = "Adempiere Theme"; - - /** - * Set Defaults - */ - public void setDefault() - { - - - /** Blue 51,51,102 */ - primary0 = new ColorUIResource(103, 152, 203); - /** Blue 102, 102, 153 */ - //protected static ColorUIResource primary1; - primary1 = new ColorUIResource( 101, 138, 187); - /** Blue 153, 153, 204 */ - primary2 = new ColorUIResource(103, 152, 203); - /** Blue 204, 204, 255 */ - primary3= new ColorUIResource(233, 238, 245); // - - /** Black */ - //secondary0 = new ColorUIResource(0, 0, 0); - /** Gray 102, 102, 102 */ - //protected static ColorUIResource secondary1; - secondary1= new ColorUIResource(190, 179, 153); - /** Gray 153, 153, 153 */ - //protected static ColorUIResource secondary2; - secondary2= new ColorUIResource(246, 239, 224); - /** BlueGray 214, 224, 234 - background */ - //protected static ColorUIResource secondary3; - secondary3= new ColorUIResource(251, 248, 241); - /** White */ - //secondary4 = new ColorUIResource(255, 255, 255); - - /** Black */ - black = BLACK; - /** White */ - white = WHITE; - - /** Background for mandatory fields */ - mandatory = new ColorUIResource(233, 238, 245); // blueish - /** Background for fields in error 180,220,143 */ - error = new ColorUIResource(220, 241, 203); // green ; - /** Background for inactive fields */ - inactive = new ColorUIResource(241,239,222);//241,239,222 - /** Background for info fields */ - info = new ColorUIResource(251, 248, 251); // somewhat white - - /** Foreground Text OK */ - txt_ok =new ColorUIResource(0, 153, 255); // blue ; - /** Foreground Text Error */ - txt_error = new ColorUIResource(255, 0, 51); // red ; - - /** Black */ - // secondary0 = new ColorUIResource(0, 0, 0); - /** Control font */ - controlFont = null; - _getControlTextFont(); - /** System font */ - systemFont = null; - _getSystemTextFont(); - /** User font */ - userFont = null; - _getUserTextFont(); - /** Small font */ - smallFont = null; - _getSubTextFont(); - /** Window Title font */ - windowFont = null; - _getWindowTitleFont(); - /** Menu font */ - menuFont = null; - _getMenuTextFont(); - } // setDefault - -} // AdempiereThemeBlueMetal diff --git a/org.adempiere.ui.swing/src/org/adempiere/plaf/PLAFEditor.java b/org.adempiere.ui.swing/src/org/adempiere/plaf/PLAFEditor.java deleted file mode 100644 index 951d2ca914..0000000000 --- a/org.adempiere.ui.swing/src/org/adempiere/plaf/PLAFEditor.java +++ /dev/null @@ -1,611 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ -package org.adempiere.plaf; - -import java.awt.BorderLayout; -import java.awt.Color; -import java.awt.Cursor; -import java.awt.Dialog; -import java.awt.Dimension; -import java.awt.FlowLayout; -import java.awt.Frame; -import java.awt.GridBagConstraints; -import java.awt.GridBagLayout; -import java.awt.Insets; -import java.awt.Toolkit; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.util.ResourceBundle; -import java.util.logging.Level; -import java.util.logging.Logger; - -import javax.swing.DefaultComboBoxModel; -import javax.swing.JButton; -import javax.swing.JCheckBox; -import javax.swing.JComboBox; -import javax.swing.JDialog; -import javax.swing.JEditorPane; -import javax.swing.JLabel; -import javax.swing.JList; -import javax.swing.JOptionPane; -import javax.swing.JPasswordField; -import javax.swing.JRadioButton; -import javax.swing.JScrollPane; -import javax.swing.JSplitPane; -import javax.swing.JTable; -import javax.swing.JTextArea; -import javax.swing.JTextField; -import javax.swing.JTextPane; -import javax.swing.JTree; -import javax.swing.LookAndFeel; -import javax.swing.UIManager; -import javax.swing.WindowConstants; -import javax.swing.border.TitledBorder; -import javax.swing.plaf.metal.MetalLookAndFeel; -import javax.swing.plaf.metal.MetalTheme; - -import org.compiere.plaf.CompiereColor; -import org.compiere.plaf.CompiereLookAndFeel; -import org.compiere.swing.CButton; -import org.compiere.swing.CCheckBox; -import org.compiere.swing.CComboBox; -import org.compiere.swing.CLabel; -import org.compiere.swing.CPanel; -import org.compiere.swing.CTabbedPane; -import org.compiere.swing.CTextField; -import org.compiere.swing.CToggleButton; -import org.compiere.swing.ColorBlind; -import org.compiere.util.Ini; -import org.compiere.util.MiniBrowser; -import org.compiere.util.ValueNamePair; - -import sun.awt.AppContext; - -/** - * Adempiere PLAF Editor. - *

    - * start with new AdempierePLAFEditor() - * - * @author Jorg Janke - * @version $Id: AdempierePLAFEditor.java,v 1.3 2006/07/30 00:52:24 jjanke Exp $ - */ -public class PLAFEditor extends JDialog - implements ActionListener -{ - /** - * - */ - private static final long serialVersionUID = -6010229234801706748L; - - - /** - * Default Constructor - * Don't Show Example - */ - public PLAFEditor() - { - super(); - init(false); - } // PLAFEditor - - /** - * Constructor - * @param showExample if true, show Example - */ - public PLAFEditor (boolean showExample) - { - super(); - init(true); - } // PLAFEditor - - /** - * Modal Dialog Constructor - * @param owner - * @param showExample if true, show Example - */ - public PLAFEditor(Dialog owner, boolean showExample) - { - super(owner, "", true); - init(true); - } // PLAFEditor - - /** - * Modal Frame Constructor - * @param owner - * @param showExample if true, show Example - */ - public PLAFEditor(Frame owner, boolean showExample) - { - super(owner, "", true); - init(true); - } // PLAFEditor - - /** Logger */ - private static Logger log = Logger.getLogger(PLAFEditor.class.getName()); - - - /************************************************************************** - * Init Editor - * @param showExample if true, show Example - */ - private void init (boolean showExample) - { - try - { - jbInit(); - dynInit(); - - // Display - example.setVisible(showExample); - blindLabel.setVisible(showExample); - blindField.setVisible(showExample); - AdempierePLAF.showCenterScreen(this); - } - catch(Exception e) - { - log.log(Level.SEVERE, "", e); - } - } // PLAFEditor - - /** Diable Theme Field */ - private boolean m_setting = false; - /** We did test for true color */ - private boolean m_colorTest = false; - - static ResourceBundle s_res = ResourceBundle.getBundle("org.compiere.plaf.PlafRes"); - static Object[] s_columns = new Object[] {"-0-", "-1-", "-2-", "-3-", "-O-", "-l-"}; - static Object[][] s_data = new Object[][] { - {"-00-", "-01-", "-02-", "-03-", "-0O-", "-0l-"}, - {"-10-", "-11-", "-12-", "-13-", "-1O-", "-1l-"}, - {"-20-", "-21-", "-22-", "-23-", "-2O-", "-2l-"}, - {"-30-", "-31-", "-32-", "-33-", "-3O-", "-3l-"}, - {"-O0-", "-O1-", "-O2-", "-O3-", "-OO-", "-Ol-"}, - {"-l0-", "-l1-", "-l2-", "-l3-", "-lO-", "-ll-"}}; - static Object[] s_pos = new Object[] {"Top", "Left", "Bottom", "Right"}; - - private CPanel mainPanel = new CPanel(new BorderLayout()); - private CPanel northPanel = new CPanel(); - private CPanel southPanel = new CPanel(); - private CButton bOK = AdempierePLAF.getOKButton(); - private CButton bCancel = AdempierePLAF.getCancelButton(); - private CButton bHelp = new CButton(); /** @todo Help Button */ - private GridBagLayout northLayout = new GridBagLayout(); - private CLabel lfLabel = new CLabel(); - private CComboBoxlfField = new CComboBox(AdempierePLAF.getPLAFs()); - private CLabel themeLabel = new CLabel(); - private CComboBoxthemeField = new CComboBox(AdempierePLAF.getThemes()); - private FlowLayout southLayout = new FlowLayout(); - private CButton rButton = new CButton(); - private CComboBoxblindField = new CComboBox(ColorBlind.COLORBLIND_TYPE); - private CLabel blindLabel = new CLabel(); - private BorderLayout mainLayout = new BorderLayout(); - // - private CTabbedPane example = new CTabbedPane(); - private CPanel jPanel1 = new CPanel(); - private TitledBorder exampleBorder; - private CPanel jPanel2 = new CPanel(); - private JLabel jLabel1 = new JLabel(); - private JTextField jTextField1 = new JTextField(); - private JCheckBox jCheckBox1 = new JCheckBox(); - private JRadioButton jRadioButton1 = new JRadioButton(); - private CButton jButton1 = new CButton(); - private CToggleButton jToggleButton1 = new CToggleButton(); - private CComboBoxjComboBox1 = new CComboBox(s_columns); - private JTextArea jTextArea1 = new JTextArea(); - private JTextPane jTextPane1 = new JTextPane(); - private JEditorPane jEditorPane1 = new JEditorPane(); - private JPasswordField jPasswordField1 = new JPasswordField(); - private JList jList1 = new JList(s_columns); - private JSplitPane jSplitPane1 = new JSplitPane(); - private BorderLayout borderLayout1 = new BorderLayout(); - private JScrollPane jScrollPane1 = new JScrollPane(); - private JTree jTree1 = new JTree(); - private JScrollPane jScrollPane2 = new JScrollPane(); - private JTable jTable1 = new JTable(s_data, s_columns); - private GridBagLayout gridBagLayout1 = new GridBagLayout(); - private CPanel jPanelFlat = new CPanel(new CompiereColor(new Color(255,205,255), true)); - private CPanel jPanelGradient = new CPanel(new CompiereColor(new Color(233,210,210), new Color(217,210,233))); - private CPanel jPanelTexture = new CPanel(new CompiereColor(CompiereColor.class.getResource("vincent.jpg"), Color.lightGray, 0.7f)); - private CPanel jPanelLines = new CPanel(new CompiereColor(new Color(178,181,205), new Color(193,193,205), 1.0f, 5)); - private JButton jButtonFlat = new JButton(); - private CButton jButtonGardient = new CButton(); - private JButton jButtonTexture = new JButton(); - private CButton jButtonLines = new CButton(); - private JComboBox jComboBoxFlat = new JComboBox(s_pos); - private JTextField jTextFieldFlat = new JTextField(); - private JLabel jLabelFlat = new JLabel(); - private CComboBoxjComboBoxGradient = new CComboBox(s_pos); - private CTextField jTextFieldGradient = new CTextField(); - private CLabel jLabelGradient = new CLabel(); - private JComboBox jComboBoxTexture = new JComboBox(s_pos); - private JTextField jTextFieldTexture = new JTextField(); - private JLabel jLabelTexture = new JLabel(); - private CComboBoxjComboBoxLines = new CComboBox(s_pos); - private CTextField jTextFieldLines = new CTextField(); - private CLabel jLabelLines = new CLabel(); - private CCheckBox jCheckBoxLines = new CCheckBox(); - private JCheckBox jCheckBoxTexture = new JCheckBox(); - private CCheckBox jCheckBoxGradient = new CCheckBox(); - private JCheckBox jCheckBoxFlat = new JCheckBox(); - - /** - * Static Layout - * @throws Exception - */ - private void jbInit() throws Exception - { - this.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); - this.setTitle(s_res.getString("LookAndFeelEditor")); - mainPanel.setLayout(mainLayout); - mainLayout.setHgap(5); - mainLayout.setVgap(5); - jTextFieldFlat.setColumns(10); - jTextFieldGradient.setColumns(10); - jTextFieldTexture.setColumns(10); - jTextFieldLines.setColumns(10); - jCheckBoxLines.setText("jCheckBox"); - jCheckBoxTexture.setText("jCheckBox"); - jCheckBoxGradient.setText("jCheckBox"); - jCheckBoxFlat.setText("jCheckBox"); - jPanelGradient.setToolTipText("Indented Level 1"); - jPanelTexture.setToolTipText("Indented Level 2"); - jPanelLines.setToolTipText("Indented Level 1"); - this.getContentPane().add(mainPanel, BorderLayout.CENTER); - // - lfLabel.setText(s_res.getString("LookAndFeel")); - lfField.addActionListener(this); - themeLabel.setText(s_res.getString("Theme")); - themeField.addActionListener(this); - rButton.setText(s_res.getString("Reset")); - rButton.addActionListener(this); - blindLabel.setText(s_res.getString("ColorBlind")); - blindField.addActionListener(this); - // - bOK.addActionListener(this); - bCancel.addActionListener(this); - bHelp.addActionListener(this); - // - northPanel.setLayout(northLayout); - southPanel.setLayout(southLayout); - southLayout.setAlignment(FlowLayout.RIGHT); - // - exampleBorder = new TitledBorder(s_res.getString("Example")); - example.setBorder(exampleBorder); - - jLabel1.setText("jLabel"); - jTextField1.setText("jTextField"); - jCheckBox1.setText("jCheckBox"); - jRadioButton1.setText("jRadioButton"); - jButton1.setText("jButton"); - jToggleButton1.setText("jToggleButton"); - jTextArea1.setText("jTextArea"); - jTextPane1.setText("jTextPane"); - jEditorPane1.setText("jEditorPane"); - jPasswordField1.setText("jPasswordField"); - jPanel2.setLayout(borderLayout1); - jPanel1.setLayout(gridBagLayout1); - jScrollPane1.setPreferredSize(new Dimension(100, 200)); - jScrollPane2.setPreferredSize(new Dimension(100, 200)); - jButtonFlat.setText("Confirm"); - jButtonGardient.setText("Input"); - jButtonTexture.setText("Message"); - jButtonLines.setText("Error"); - jTextFieldFlat.setText("jTextField"); - jLabelFlat.setText("jLabel"); - jTextFieldGradient.setText("jTextField"); - jLabelGradient.setText("jLabel"); - jTextFieldTexture.setText("jTextField"); - jLabelTexture.setText("jLabel"); - jTextFieldLines.setText("jTextField"); - jLabelLines.setText("jLabel"); - mainPanel.add(northPanel, BorderLayout.NORTH); - northPanel.add(lfLabel, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(12, 12, 5, 5), 0, 0)); - northPanel.add(lfField, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(12, 0, 5, 12), 0, 0)); - northPanel.add(themeLabel, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 12, 5, 5), 0, 0)); - northPanel.add(themeField, new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 5, 12), 0, 0)); - northPanel.add(rButton, new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 12, 5, 5), 0, 0)); - northPanel.add(blindLabel, new GridBagConstraints(0, 5, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 12, 5, 5), 0, 0)); - northPanel.add(blindField, new GridBagConstraints(1, 5, 1, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 0, 5, 12), 0, 0)); - mainPanel.add(southPanel, BorderLayout.SOUTH); - southPanel.add(bCancel, null); - southPanel.add(bOK, null); - mainPanel.add(example, BorderLayout.CENTER); - example.add(jPanel1, "JPanel"); - jPanel1.add(jTextPane1, new GridBagConstraints(2, 3, 1, 1, 0.0, 0.2 - ,GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(5, 5, 5, 5), 0, 0)); - jPanel1.add(jEditorPane1, new GridBagConstraints(1, 3, 1, 1, 0.0, 0.2 - ,GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(5, 5, 5, 5), 0, 0)); - jPanel1.add(jList1, new GridBagConstraints(1, 2, 1, 1, 0.0, 0.2 - ,GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(5, 5, 5, 5), 0, 0)); - jPanel1.add(jLabel1, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0 - ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); - jPanel1.add(jTextField1, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0 - ,GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5), 0, 0)); - jPanel1.add(jCheckBox1, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0 - ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(1, 1, 1, 1), 0, 0)); - jPanel1.add(jRadioButton1, new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0 - ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); - jPanel1.add(jButton1, new GridBagConstraints(2, 0, 1, 1, 0.0, 0.1 - ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); - jPanel1.add(jToggleButton1, new GridBagConstraints(2, 1, 1, 1, 0.0, 0.1 - ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); - jPanel1.add(jTextArea1, new GridBagConstraints(0, 3, 1, 1, 0.0, 0.2 - ,GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(5, 5, 5, 5), 0, 0)); - jPanel1.add(jComboBox1, new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0 - ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); - jPanel1.add(jPasswordField1, new GridBagConstraints(2, 2, 1, 1, 0.0, 0.0 - ,GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5), 0, 0)); - example.add(jPanel2, "JPanel"); - jPanel2.add(jSplitPane1, BorderLayout.CENTER); - jSplitPane1.add(jScrollPane1, JSplitPane.LEFT); - jSplitPane1.add(jScrollPane2, JSplitPane.RIGHT); - jPanelFlat.setName("FlatP"); - jPanelGradient.setName("GradientP"); - jPanelTexture.setName("TextureP"); - jPanelLines.setName("LineP"); - example.add(jPanelFlat, "jPanel Flat"); - jPanelFlat.add(jButtonFlat, null); - jPanelFlat.add(jComboBoxFlat, null); - example.add(jPanelGradient, "jPanel Gradient 1"); - jPanelGradient.add(jButtonGardient, null); - jPanelGradient.add(jComboBoxGradient, null); - jPanelGradient.add(jLabelGradient, null); - jPanelGradient.add(jTextFieldGradient, null); - example.add(jPanelTexture, "jPanel Texture 2"); - jPanelTexture.add(jButtonTexture, null); - jPanelTexture.add(jComboBoxTexture, null); - jPanelTexture.add(jLabelTexture, null); - jPanelTexture.add(jTextFieldTexture, null); - example.add(jPanelLines, "jPanel Lines 1"); - jPanelLines.add(jButtonLines, null); - jPanelLines.add(jComboBoxLines, null); - jPanelLines.add(jLabelLines, null); - jPanelLines.add(jTextFieldLines, null); - jScrollPane2.getViewport().add(jTable1, null); - jScrollPane1.getViewport().add(jTree1, null); - jPanelFlat.add(jLabelFlat, null); - jPanelFlat.add(jTextFieldFlat, null); - jPanelLines.add(jCheckBoxLines, null); - jPanelTexture.add(jCheckBoxTexture, null); - jPanelGradient.add(jCheckBoxGradient, null); - jPanelFlat.add(jCheckBoxFlat, null); - } // jbInit - - /** - * Dynamic Init - */ - private void dynInit() - { - setLFSelection(); - // - jPanelGradient.setTabLevel(1); - jPanelTexture.setTabLevel(2); - jPanelLines.setTabLevel(1); - // - jComboBoxFlat.addActionListener(this); - jComboBoxGradient.addActionListener(this); - jComboBoxTexture.addActionListener(this); - jComboBoxLines.addActionListener(this); - // - jButton1.addActionListener(this); - jButtonFlat.addActionListener(this); - jButtonGardient.addActionListener(this); - jButtonTexture.addActionListener(this); - jButtonLines.addActionListener(this); - // - } // dynInit - - /** - * Set Picks From Environment - */ - private void setLFSelection() - { - m_setting = true; - // Search for PLAF - ValueNamePair plaf = null; - LookAndFeel lookFeel = UIManager.getLookAndFeel(); - String look = lookFeel.getClass().getName(); - for (int i = 0; i < AdempierePLAF.getPLAFs().length; i++) - { - ValueNamePair vp = AdempierePLAF.getPLAFs()[i]; - if (vp.getValue().equals(look)) - { - plaf = vp; - break; - } - } - if (plaf != null) - lfField.setSelectedItem(plaf); - - - // Search for Theme - MetalTheme metalTheme = null; - ValueNamePair theme = null; - boolean metal = UIManager.getLookAndFeel() instanceof MetalLookAndFeel; - themeField.setModel(new DefaultComboBoxModel(AdempierePLAF.getThemes())); - if (metal) - { - theme = null; - AppContext context = AppContext.getAppContext(); - metalTheme = (MetalTheme)context.get("currentMetalTheme"); - if (metalTheme != null) - { - String lookTheme = metalTheme.getName(); - for (int i = 0; i < AdempierePLAF.getThemes().length; i++) - { - ValueNamePair vp = AdempierePLAF.getThemes()[i]; - if (vp.getName().equals(lookTheme)) - { - theme = vp; - break; - } - } - } - if (theme != null) - themeField.setSelectedItem(theme); - } - m_setting = false; - if (log.isLoggable(Level.INFO)) log.info(lookFeel + " - " + metalTheme); - } // setLFSelection - - - /************************************************************************** - * ActionListener - * @param e - */ - public void actionPerformed(ActionEvent e) - { - setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); - - // OK - Save & Finish - if (e.getSource() == bOK) - { - Ini.saveProperties(true); - dispose(); - } - // Cancel - Finish - else if (e.getSource() == bCancel) - { - dispose(); - } - else if (e.getSource() == bHelp) - { - new MiniBrowser("http://www.adempiere.com/wiki/index.php/LooksHelp"); - } - - // Look & Feel changed - else if (e.getSource() == lfField && !m_setting) - { - m_setting = true; // disable Theme setting - // set new theme - AdempierePLAF.setPLAF((ValueNamePair)lfField.getSelectedItem(), null, true); - AdempierePLAF.updateUI(this); - setLFSelection(); - m_setting = false; // enable Theme setting - } - // Theme Field Changed - else if (e.getSource() == themeField && !m_setting) - { - Ini.setProperty(Ini.P_UI_THEME, themeField.getSelectedItem().toString()); - AdempierePLAF.setPLAF((ValueNamePair)lfField.getSelectedItem(), (ValueNamePair)themeField.getSelectedItem(),true); - AdempierePLAF.updateUI(this); - } - - // Reset PLAFs - else if (e.getSource() == rButton) - { - AdempierePLAF.reset(); - AdempierePLAF.updateUI(this); - setLFSelection(); - ColorBlind.setColorType(ColorBlind.NORMAL); - } - - // ColorBlind - else if (e.getSource() == blindField) - { - int sel = blindField.getSelectedIndex(); - if (sel != ColorBlind.getColorType()) - { - // Test for True color - if (!m_colorTest) - { - m_colorTest = true; - int size = Toolkit.getDefaultToolkit().getColorModel().getPixelSize(); - if (size < 24) - JOptionPane.showMessageDialog(this, - "Your environment has only a pixel size of " + size - + ".\nTo see the effect, you need to have a pixel size of 24 (true color)", - "Insufficient Color Capabilities", - JOptionPane.ERROR_MESSAGE); - } - ColorBlind.setColorType(sel); - AdempierePLAF.updateUI(this); - } - } - - - // Change Tab Pacement - else if (e.getSource() == jComboBoxFlat || e.getSource() == jComboBoxGradient - || e.getSource() == jComboBoxTexture || e.getSource() == jComboBoxLines) - { - if (!m_setting) - { - m_setting = true; - int index = ((JComboBox)e.getSource()).getSelectedIndex(); - example.setTabPlacement(index+1); - jComboBoxFlat.setSelectedIndex(index); - jComboBoxGradient.setSelectedIndex(index); - jComboBoxTexture.setSelectedIndex(index); - jComboBoxLines.setSelectedIndex(index); - m_setting = false; - } - } - // Display Options - else if (e.getSource() == jButtonFlat) - JOptionPane.showConfirmDialog(this, "Confirm Dialog"); - else if (e.getSource() == jButtonGardient) - JOptionPane.showInputDialog(this, "Input Dialog"); - else if (e.getSource() == jButtonTexture) - JOptionPane.showMessageDialog(this, "Message Dialog"); - else if (e.getSource() == jButtonLines) - JOptionPane.showMessageDialog(this, "Message Dialog - Error", "Error", JOptionPane.ERROR_MESSAGE); - - // Test - else if (e.getSource() == jButton1) - { - } - - /********************/ - - // Metal - boolean metal = UIManager.getLookAndFeel() instanceof MetalLookAndFeel; - themeField.setEnabled(metal); - themeLabel.setEnabled(metal); - boolean adempiere = UIManager.getLookAndFeel() instanceof CompiereLookAndFeel; - - // ColorBlind - only with Adempiere L&F & Theme - boolean enableBlind = adempiere - && themeField.getSelectedItem() != null - && themeField.getSelectedItem().toString().indexOf("Adempiere") != -1; - blindField.setEnabled(enableBlind); - blindLabel.setEnabled(enableBlind); - if (e.getSource() != blindField && !enableBlind) - blindField.setSelectedIndex(0); - - // done - setCursor(Cursor.getDefaultCursor()); - } // actionPerformed - - /** - * Dispose - * Exit, if there is no real owning parent (not modal) - shortcut - */ - public void dispose() - { - super.dispose(); - if (!isModal()) - System.exit(0); - } // dispose - -} // AdempierePLAFEditor diff --git a/org.adempiere.ui.swing/src/org/adempiere/plaf/PLAFEditorPanel.java b/org.adempiere.ui.swing/src/org/adempiere/plaf/PLAFEditorPanel.java deleted file mode 100644 index d88977579f..0000000000 --- a/org.adempiere.ui.swing/src/org/adempiere/plaf/PLAFEditorPanel.java +++ /dev/null @@ -1,446 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 Adempiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - *****************************************************************************/ -package org.adempiere.plaf; - -import java.awt.BorderLayout; -import java.awt.Cursor; -import java.awt.Font; -import java.awt.Graphics; -import java.awt.GridBagConstraints; -import java.awt.GridBagLayout; -import java.awt.GridLayout; -import java.awt.Insets; -import java.awt.event.FocusAdapter; -import java.awt.event.KeyAdapter; -import java.awt.event.MouseAdapter; -import java.awt.image.BufferedImage; -import java.util.ResourceBundle; -import java.util.logging.Level; -import java.util.logging.Logger; - -import javax.swing.BorderFactory; -import javax.swing.BoxLayout; -import javax.swing.DefaultComboBoxModel; -import javax.swing.JComponent; -import javax.swing.JLabel; -import javax.swing.JList; -import javax.swing.JRadioButton; -import javax.swing.JRootPane; -import javax.swing.JScrollPane; -import javax.swing.JTable; -import javax.swing.JTree; -import javax.swing.LookAndFeel; -import javax.swing.SwingUtilities; -import javax.swing.UIManager; -import javax.swing.UnsupportedLookAndFeelException; -import javax.swing.event.ListSelectionEvent; -import javax.swing.event.ListSelectionListener; -import javax.swing.plaf.metal.MetalLookAndFeel; -import javax.swing.plaf.metal.MetalTheme; - -import org.compiere.swing.CButton; -import org.compiere.swing.CCheckBox; -import org.compiere.swing.CComboBox; -import org.compiere.swing.CLabel; -import org.compiere.swing.CPanel; -import org.compiere.swing.CTabbedPane; -import org.compiere.swing.CTextField; -import org.compiere.util.ValueNamePair; - -import sun.awt.AppContext; - -/** - * Look and feel selection panel. - * @author Low Heng Sin - * @version 2006-11-27 - */ -public class PLAFEditorPanel extends CPanel { - /** - * - */ - private static final long serialVersionUID = 3991197818429424319L; - - /** Logger */ - private static Logger log = Logger.getLogger(PLAFEditor.class.getName()); - - static ResourceBundle s_res = ResourceBundle.getBundle("org.compiere.plaf.PlafRes"); - static Object[] s_columns = new Object[] {"-0-", "-1-"}; - static Object[][] s_data = new Object[][] { - {"-00-", "-01-"}, - {"-10-", "-11-"}, - {"-20-", "-21-"}, - {"-30-", "-31-"}, - {"-O0-", "-O1-"}, - {"-l0-", "-l1-"}}; - - private PreviewPanel previewPanel = new PreviewPanel(); - private JList lookList = new JList(AdempierePLAF.getPLAFs()); - private JList themeList = new JList(); - - /** - * Instance variable to disable list event handling when updating list with value - * from UIManager - */ - private boolean m_setting; - - //preview components - private CTextField error = new CTextField(s_res.getString("Error")); - private CTextField mandatory = new CTextField(s_res.getString("Mandatory")); - CButton button = new CButton("Button"); - CPanel tabPage1 = new CPanel(); - - public PLAFEditorPanel() { - init(); - } - - private void init() { - setupUI(); - setupPreview(); - setLFSelection(); - } - - /** - * Create and layout UI components - */ - private void setupUI() { - this.setLayout(new BorderLayout()); - - CPanel selectionPanel = new CPanel(); - CPanel previewPart = new CPanel(); - add(selectionPanel, BorderLayout.CENTER); - add(previewPart, BorderLayout.SOUTH); - - //setup look and theme selection component - selectionPanel.setLayout(new GridBagLayout()); - CLabel label = new CLabel(s_res.getString("LookAndFeel")); - label.setForeground(AdempierePLAF.getPrimary1()); - label.setFont(label.getFont().deriveFont(Font.BOLD)); - selectionPanel.add(label, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, - GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 0, 0), 0, 0)); - label = new CLabel(s_res.getString("Theme")); - label.setForeground(AdempierePLAF.getPrimary1()); - label.setFont(label.getFont().deriveFont(Font.BOLD)); - selectionPanel.add(label, new GridBagConstraints(1, 0, 1, 1, 1.0, 0.0, - GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 0, 0, 0), 0, 0)); - - lookList.setVisibleRowCount(12); - JScrollPane scrollPane = new JScrollPane(lookList); - scrollPane.setBorder(BorderFactory.createLineBorder(AdempierePLAF.getSecondary1(), 1)); - selectionPanel.add(scrollPane, new GridBagConstraints(0, 1, 1, 1, 0.0, 1.0, - GridBagConstraints.NORTHWEST, GridBagConstraints.VERTICAL, new Insets(0, 5, 2, 2), 100, 0)); - - themeList.setVisibleRowCount(12); - scrollPane = new JScrollPane(themeList); - scrollPane.setBorder(BorderFactory.createLineBorder(AdempierePLAF.getSecondary1(), 1)); - selectionPanel.add(scrollPane, new GridBagConstraints(1, 1, 1, 1, 1.0, 1.0, - GridBagConstraints.NORTHWEST, GridBagConstraints.BOTH, new Insets(0, 2, 2, 5), 0, 0)); - - previewPart.setBorder(BorderFactory.createEmptyBorder()); - previewPart.setLayout(new GridBagLayout()); - label = new CLabel(s_res.getString("Preview")); - label.setForeground(AdempierePLAF.getPrimary1()); - label.setFont(label.getFont().deriveFont(Font.BOLD)); - previewPart.add(label, new GridBagConstraints(0, 0, 1, 1, 1.0, 0.0, - GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 0, 0), 0, 0)); - previewPart.add(previewPanel, new GridBagConstraints(0, 1, 2, 1, 1.0, 1.0, - GridBagConstraints.NORTHWEST, GridBagConstraints.BOTH, new Insets(0, 5, 5, 5), 0, 0)); - - lookList.addListSelectionListener(new ListSelectionListener() { - public void valueChanged(ListSelectionEvent e) { - lookAndFeelSelectionChanged(e); - } - - }); - themeList.addListSelectionListener(new ListSelectionListener() { - public void valueChanged(ListSelectionEvent e) { - themeSelectionChanged(e); - } - - }); - } - - /** - * Handle theme selection changed - * @param e - */ - protected void themeSelectionChanged(ListSelectionEvent e) { - if (m_setting) return; - setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); - ValueNamePair laf = (ValueNamePair)lookList.getSelectedValue(); - ValueNamePair theme = (ValueNamePair)themeList.getSelectedValue(); - LookAndFeel currentLaf = UIManager.getLookAndFeel(); - MetalTheme currentTheme = MetalLookAndFeel.getCurrentTheme(); - AdempierePLAF.setPLAF(laf, theme, false); - previewPanel.refresh(currentLaf,currentTheme); - SwingUtilities.updateComponentTreeUI(previewPanel); - updatePreviewComponents(); - setLFSelection(); - setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); - this.repaint(); - } - - /** - * Handle look and feel selection changed - * @param e - */ - protected void lookAndFeelSelectionChanged(ListSelectionEvent e) { - if (m_setting) return; - setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); - ValueNamePair laf = (ValueNamePair)lookList.getSelectedValue(); - LookAndFeel currentLaf = UIManager.getLookAndFeel(); - MetalTheme currentTheme = MetalLookAndFeel.getCurrentTheme(); - AdempierePLAF.setPLAF(laf, null, false); - previewPanel.refresh(currentLaf,currentTheme); - SwingUtilities.updateComponentTreeUI(previewPanel); - updatePreviewComponents(); - setLFSelection(); - setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); - this.repaint(); - } - - private void updatePreviewComponents() { - error.setBackground(true); - mandatory.setMandatory(true); - button.setOpaque(true); - tabPage1.setOpaque(false); - } - - /** - * Create the preview UI components - */ - private void setupPreview() { - JRootPane rootPane = new JRootPane(); - previewPanel.setLayout(new BorderLayout()); - previewPanel.add(rootPane, BorderLayout.CENTER); - previewPanel.setBorder(BorderFactory.createLineBorder(AdempierePLAF.getSecondary1(), 1)); - GridLayout gridLayout = new GridLayout(1, 3); - gridLayout.setHgap(4); - rootPane.getContentPane().setLayout(gridLayout); - rootPane.setGlassPane(new GlassPane()); - rootPane.getGlassPane().setVisible(true); - CPanel column1 = new CPanel(); - rootPane.getContentPane().add(column1); - CPanel column2 = new CPanel(); - rootPane.getContentPane().add(column2); - CPanel column3 = new CPanel(); - rootPane.getContentPane().add(column3); - - column1.setLayout(new GridBagLayout()); - JTree jtree = new JTree(); - jtree.setFocusable(false); - jtree.setBorder(BorderFactory.createLineBorder(AdempierePLAF.getSecondary1(), 1)); - column1.add(jtree, new GridBagConstraints(0, 0, 2, 1, 1.0, 1.0, - GridBagConstraints.WEST, GridBagConstraints.BOTH, new Insets(5,5,2,2),0,0)); - CTextField normal = new CTextField("Text Field"); - normal.setFocusable(false); - column1.add(normal, new GridBagConstraints(0, 1, 1, 1, 1.0, 0.0, - GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(2,5,5,2),0,0)); - error.setBackground(true); - error.setFocusable(false); - column1.add(error, new GridBagConstraints(1, 1, 1, 1, 1.0, 0.0, - GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(2,2,5,2),0,0)); - - column2.setLayout(new GridBagLayout()); - JTable jtable = new JTable(s_data, s_columns); - JScrollPane scrollPane = new JScrollPane(jtable); - jtable.setFocusable(false); - scrollPane.setPreferredSize(jtable.getPreferredSize()); - column2.add(scrollPane, new GridBagConstraints(0, 0, 2, 1, 1.0, 1.0, - GridBagConstraints.WEST, GridBagConstraints.BOTH, new Insets(5,2,2,2),0,0)); - mandatory.setMandatory(true); - mandatory.setFocusable(false); - column2.add(mandatory, new GridBagConstraints(0, 1, 1, 1, 1.0, 0.0, - GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(2,2,5,2),0,0)); - CTextField inactive = new CTextField(s_res.getString("Inactive")); - inactive.setEnabled(false); - column2.add(inactive, new GridBagConstraints(1, 1, 1, 1, 1.0, 0.0, - GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(2,2,5,2),0,0)); - - column3.setLayout(new GridBagLayout()); - CTabbedPane tab = new CTabbedPane(); - column3.add(tab, new GridBagConstraints(0, 0, 2, 1, 1.0, 1.0, - GridBagConstraints.WEST, GridBagConstraints.BOTH, new Insets(5,2,2,5),0,0)); - CComboBox editable = new CComboBox(new Object[]{"Editable"}); - editable.setEditable(true); - editable.setFocusable(false); - column3.add(editable, new GridBagConstraints(0, 1, 1, 1, 1.0, 0.0, - GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(2,2,5,2),0,0)); - CComboBox choice = new CComboBox(new Object[]{"Choice"}); - choice.setEditable(false); - choice.setFocusable(false); - column3.add(choice, new GridBagConstraints(1, 1, 1, 1, 1.0, 0.0, - GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(2,2,5,5),0,0)); - - tabPage1.setLayout(new BoxLayout(tabPage1, BoxLayout.Y_AXIS)); - JRadioButton radio = new JRadioButton("Radio"); - radio.setSelected(true); - radio.setMargin(new Insets(5,5,5,5)); - radio.setFocusable(false); - radio.setOpaque(false); - tabPage1.add(radio); - CCheckBox checkBox = new CCheckBox("Checkbox"); - checkBox.setSelected(true); - checkBox.setMargin(new Insets(5,5,5,5)); - checkBox.setFocusable(false); - tabPage1.add(checkBox); - CLabel label = new CLabel("Label"); - label.setHorizontalAlignment(JLabel.LEFT); - label.setBorder(BorderFactory.createEmptyBorder(5,5,5,5)); - tabPage1.add(label); - button.setMargin(new Insets(5,5,5,5)); - button.setFocusable(false); - tabPage1.add(button); - tab.add(tabPage1, "tab1"); - tab.add(new CPanel(), "tab2"); - } - - /** - * Update the look list and theme list to show the current selection - */ - private void setLFSelection() - { - m_setting = true; - // Search for PLAF - ValueNamePair plaf = null; - LookAndFeel lookFeel = UIManager.getLookAndFeel(); - String look = lookFeel.getClass().getName(); - for (int i = 0; i < AdempierePLAF.getPLAFs().length; i++) - { - ValueNamePair vp = AdempierePLAF.getPLAFs()[i]; - if (vp.getValue().equals(look)) - { - plaf = vp; - break; - } - } - if (plaf != null) - lookList.setSelectedValue(plaf, true); - - - // Search for Theme - MetalTheme metalTheme = null; - ValueNamePair theme = null; - boolean metal = UIManager.getLookAndFeel() instanceof MetalLookAndFeel; - themeList.setModel(new DefaultComboBoxModel(AdempierePLAF.getThemes())); - if (metal) - { - theme = null; - AppContext context = AppContext.getAppContext(); - metalTheme = (MetalTheme)context.get("currentMetalTheme"); - if (metalTheme != null) - { - String lookTheme = metalTheme.getName(); - for (int i = 0; i < AdempierePLAF.getThemes().length; i++) - { - ValueNamePair vp = AdempierePLAF.getThemes()[i]; - if (vp.getName().equals(lookTheme)) - { - theme = vp; - break; - } - } - } - if (theme != null) - themeList.setSelectedValue(theme, true); - } - m_setting = false; - if (log.isLoggable(Level.INFO)) log.info(lookFeel + " - " + metalTheme); - } // setLFSelection - - /** - * Get look and feel selected by user - * @return selected look and feel - */ - public ValueNamePair getSelectedLook() { - return (ValueNamePair)lookList.getSelectedValue(); - } - - /** - * Get theme selected by user - * @return selected theme - */ - public ValueNamePair getSelectedTheme() { - return (ValueNamePair)themeList.getSelectedValue(); - } -} - -/** - * Glass pane to block input and mouse event from the preview components - * @author Low Heng Sin - */ -class GlassPane extends JComponent { - /** - * - */ - private static final long serialVersionUID = -4416920279272513L; - - GlassPane() { - addMouseListener(new MouseAdapter() {}); - addKeyListener(new KeyAdapter() {}); - addFocusListener(new FocusAdapter() {}); - } -} - -/** - * A custom panel, only repaint when look and feel or theme changed. - * @author Low Heng Sin - */ -class PreviewPanel extends CPanel { - /** - * - */ - private static final long serialVersionUID = 6028614986952449622L; - private boolean capture = true; - private LookAndFeel laf = null; - private MetalTheme theme = null; - private BufferedImage image; - - @Override - public void paint(Graphics g) { - if (capture) { - //capture preview image - image = (BufferedImage)createImage(this.getWidth(),this.getHeight()); - super.paint(image.createGraphics()); - g.drawImage(image, 0, 0, null); - capture = false; - if (laf != null) { - //reset to origianl setting - if (laf instanceof MetalLookAndFeel) - AdempierePLAF.setCurrentMetalTheme((MetalLookAndFeel)laf, theme); - try { - UIManager.setLookAndFeel(laf); - } catch (UnsupportedLookAndFeelException e) { - } - laf = null; - theme = null; - } - } else { - //draw captured preview image - if (image != null) - g.drawImage(image, 0, 0, null); - } - } - - /** - * Refresh look and feel preview, reset to original setting after - * refresh. - * @param currentLaf Current Look and feel - * @param currentTheme Current Theme - */ - public void refresh(LookAndFeel currentLaf, MetalTheme currentTheme) { - this.laf = currentLaf; - this.theme = currentTheme; - capture = true; - } -} \ No newline at end of file diff --git a/org.adempiere.ui.swing/src/org/adempiere/plaf/icons/CL16.gif b/org.adempiere.ui.swing/src/org/adempiere/plaf/icons/CL16.gif deleted file mode 100644 index 27d903c3e2..0000000000 Binary files a/org.adempiere.ui.swing/src/org/adempiere/plaf/icons/CL16.gif and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/adempiere/plaf/icons/CL32.gif b/org.adempiere.ui.swing/src/org/adempiere/plaf/icons/CL32.gif deleted file mode 100644 index c83d267cbd..0000000000 Binary files a/org.adempiere.ui.swing/src/org/adempiere/plaf/icons/CL32.gif and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/adempiere/plaf/icons/Cancel24.gif b/org.adempiere.ui.swing/src/org/adempiere/plaf/icons/Cancel24.gif deleted file mode 100644 index d91a52dc0c..0000000000 Binary files a/org.adempiere.ui.swing/src/org/adempiere/plaf/icons/Cancel24.gif and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/adempiere/plaf/icons/Computer.gif b/org.adempiere.ui.swing/src/org/adempiere/plaf/icons/Computer.gif deleted file mode 100644 index c9cc93eff9..0000000000 Binary files a/org.adempiere.ui.swing/src/org/adempiere/plaf/icons/Computer.gif and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/adempiere/plaf/icons/Error.gif b/org.adempiere.ui.swing/src/org/adempiere/plaf/icons/Error.gif deleted file mode 100644 index b2ac9f57b4..0000000000 Binary files a/org.adempiere.ui.swing/src/org/adempiere/plaf/icons/Error.gif and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/adempiere/plaf/icons/File.gif b/org.adempiere.ui.swing/src/org/adempiere/plaf/icons/File.gif deleted file mode 100644 index 2d7f2d6017..0000000000 Binary files a/org.adempiere.ui.swing/src/org/adempiere/plaf/icons/File.gif and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/adempiere/plaf/icons/FloppyDrive.gif b/org.adempiere.ui.swing/src/org/adempiere/plaf/icons/FloppyDrive.gif deleted file mode 100644 index f1d7a19859..0000000000 Binary files a/org.adempiere.ui.swing/src/org/adempiere/plaf/icons/FloppyDrive.gif and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/adempiere/plaf/icons/HardDrive.gif b/org.adempiere.ui.swing/src/org/adempiere/plaf/icons/HardDrive.gif deleted file mode 100644 index 5c3b8587f4..0000000000 Binary files a/org.adempiere.ui.swing/src/org/adempiere/plaf/icons/HardDrive.gif and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/adempiere/plaf/icons/HomeFolder.gif b/org.adempiere.ui.swing/src/org/adempiere/plaf/icons/HomeFolder.gif deleted file mode 100644 index 13d2c00d08..0000000000 Binary files a/org.adempiere.ui.swing/src/org/adempiere/plaf/icons/HomeFolder.gif and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/adempiere/plaf/icons/Inform.gif b/org.adempiere.ui.swing/src/org/adempiere/plaf/icons/Inform.gif deleted file mode 100644 index 2ac57475c3..0000000000 Binary files a/org.adempiere.ui.swing/src/org/adempiere/plaf/icons/Inform.gif and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/adempiere/plaf/icons/NewFolder.gif b/org.adempiere.ui.swing/src/org/adempiere/plaf/icons/NewFolder.gif deleted file mode 100644 index 628f4d50ff..0000000000 Binary files a/org.adempiere.ui.swing/src/org/adempiere/plaf/icons/NewFolder.gif and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/adempiere/plaf/icons/Ok24.gif b/org.adempiere.ui.swing/src/org/adempiere/plaf/icons/Ok24.gif deleted file mode 100644 index 027d18f531..0000000000 Binary files a/org.adempiere.ui.swing/src/org/adempiere/plaf/icons/Ok24.gif and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/adempiere/plaf/icons/Question.gif b/org.adempiere.ui.swing/src/org/adempiere/plaf/icons/Question.gif deleted file mode 100644 index dc19aa1706..0000000000 Binary files a/org.adempiere.ui.swing/src/org/adempiere/plaf/icons/Question.gif and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/adempiere/plaf/icons/TreeClosed.gif b/org.adempiere.ui.swing/src/org/adempiere/plaf/icons/TreeClosed.gif deleted file mode 100644 index 901edc9624..0000000000 Binary files a/org.adempiere.ui.swing/src/org/adempiere/plaf/icons/TreeClosed.gif and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/adempiere/plaf/icons/TreeLeaf.gif b/org.adempiere.ui.swing/src/org/adempiere/plaf/icons/TreeLeaf.gif deleted file mode 100644 index 63042304b1..0000000000 Binary files a/org.adempiere.ui.swing/src/org/adempiere/plaf/icons/TreeLeaf.gif and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/adempiere/plaf/icons/TreeOpen.gif b/org.adempiere.ui.swing/src/org/adempiere/plaf/icons/TreeOpen.gif deleted file mode 100644 index 1e074cd024..0000000000 Binary files a/org.adempiere.ui.swing/src/org/adempiere/plaf/icons/TreeOpen.gif and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/adempiere/plaf/icons/UpFolder.gif b/org.adempiere.ui.swing/src/org/adempiere/plaf/icons/UpFolder.gif deleted file mode 100644 index fa9a7d71b5..0000000000 Binary files a/org.adempiere.ui.swing/src/org/adempiere/plaf/icons/UpFolder.gif and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/adempiere/plaf/icons/Warn.gif b/org.adempiere.ui.swing/src/org/adempiere/plaf/icons/Warn.gif deleted file mode 100644 index a05e160c20..0000000000 Binary files a/org.adempiere.ui.swing/src/org/adempiere/plaf/icons/Warn.gif and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/adempiere/process/DefaultPrintShippingLabel.java b/org.adempiere.ui.swing/src/org/adempiere/process/DefaultPrintShippingLabel.java deleted file mode 100644 index 9465abe782..0000000000 --- a/org.adempiere.ui.swing/src/org/adempiere/process/DefaultPrintShippingLabel.java +++ /dev/null @@ -1,164 +0,0 @@ -/****************************************************************************** - * Copyright (C) 2012 Elaine Tan * - * Copyright (C) 2012 Trek Global - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - *****************************************************************************/ -package org.adempiere.process; - -import java.awt.Graphics; -import java.awt.Graphics2D; -import java.awt.geom.AffineTransform; -import java.awt.image.BufferedImage; -import java.awt.print.Book; -import java.awt.print.PageFormat; -import java.awt.print.Paper; -import java.awt.print.Printable; -import java.awt.print.PrinterException; -import java.awt.print.PrinterJob; -import java.math.BigDecimal; -import java.util.ArrayList; -import java.util.List; - -import javax.imageio.ImageIO; -import javax.print.Doc; -import javax.print.DocFlavor; -import javax.print.DocPrintJob; -import javax.print.PrintService; -import javax.print.SimpleDoc; -import javax.print.attribute.HashDocAttributeSet; -import javax.print.attribute.standard.DocumentName; - -import org.compiere.model.MAttachment; -import org.compiere.model.MAttachmentEntry; -import org.compiere.model.MShipperLabels; - -/** - * - * @author Elaine - * - */ -public class DefaultPrintShippingLabel implements IPrintShippingLabel -{ - @Override - public String printToLabelPrinter(MAttachment attachment, MShipperLabels labelType) throws Exception - { - MAttachmentEntry[] entries = attachment.getEntries(); - List list = new ArrayList(); - if (entries != null && entries.length > 0) - { - for (MAttachmentEntry entry : entries) - { - if (entry.getName().startsWith("shipping_label")) - list.add(entry); - } - if (list.size() > 0) - { - // Create Print Job - PrinterJob pjob = PrinterJob.getPrinterJob(); - if (pjob.printDialog()) - { - PrintService service = pjob.getPrintService(); - DocFlavor flavor = DocFlavor.BYTE_ARRAY.AUTOSENSE; - for (MAttachmentEntry entry : list) - { - DocPrintJob job = service.createPrintJob(); - HashDocAttributeSet as = new HashDocAttributeSet(); - as.add(new DocumentName(entry.getName(), null)); - Doc doc = new SimpleDoc(entry.getData(), flavor, as); - job.print(doc, null); - } - } - } - } - return list.size() + " labels printed."; - } - - @Override - public String printImageLabel(MAttachment attachment, MShipperLabels labelType, String title) throws Exception - { - MAttachmentEntry[] entries = attachment.getEntries(); - List list = new ArrayList(); - if (entries != null && entries.length > 0) - { - for (MAttachmentEntry entry : entries) - { - if (entry.getName().startsWith("shipping_label") && entry.isGraphic()) - { - BufferedImage image = ImageIO.read(entry.getInputStream()); - if (image != null) - list.add(image); - } - } - - if (list.size() > 0) - { - // Create Print Job - Book book = new Book(); - PrinterJob pjob = PrinterJob.getPrinterJob(); - pjob.setJobName(title); - - if (pjob.printDialog()) - { - PageFormat pf = pjob.pageDialog(pjob.defaultPage()); - Paper p = pf.getPaper(); - BigDecimal width = labelType.getWidth(); - BigDecimal height = labelType.getHeight(); - - if (width != null && width.compareTo(BigDecimal.ZERO) > 0 && height != null && height.compareTo(BigDecimal.ZERO) > 0) - { - BigDecimal factor = new BigDecimal(72); - width = width.multiply(factor); - height = height.multiply(factor); - p.setImageableArea(p.getImageableX(), p.getImageableY(), width.doubleValue(), height.doubleValue()); - pf.setPaper(p); - } - - for (BufferedImage image : list) - book.append(new ImagePrintable(image), pf); - - pjob.setPageable(book); - pjob.print(); - } - } - } - return list.size() + " labels printed."; - } - - final static class ImagePrintable implements Printable - { - private BufferedImage image; - - protected ImagePrintable(BufferedImage image) - { - this.image = image; - } - - public int print(Graphics graphics, PageFormat pageFormat, int pageIndex) throws PrinterException - { - if (pageIndex > 0) - return Printable.NO_SUCH_PAGE; - - Graphics2D g2d = (Graphics2D) graphics; - // Set us to the upper left corner - g2d.translate(pageFormat.getImageableX(), pageFormat.getImageableY()); - AffineTransform at = new AffineTransform(); - at.translate(0, 0); - - // We need to scale the image properly so that it fits on one page. - double xScale = pageFormat.getImageableWidth() / image.getWidth(); - double yScale = pageFormat.getImageableHeight() / image.getHeight(); - - at.scale(xScale, yScale); - g2d.drawRenderedImage(image, at); - return Printable.PAGE_EXISTS; - } - } -} diff --git a/org.adempiere.ui.swing/src/org/adempiere/ui/swing/factory/DefaultEditorFactory.java b/org.adempiere.ui.swing/src/org/adempiere/ui/swing/factory/DefaultEditorFactory.java deleted file mode 100644 index 315eec57cd..0000000000 --- a/org.adempiere.ui.swing/src/org/adempiere/ui/swing/factory/DefaultEditorFactory.java +++ /dev/null @@ -1,308 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 2010 Heng Sin Low * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - *****************************************************************************/ -package org.adempiere.ui.swing.factory; - -import org.compiere.grid.ed.ADempiereAutoCompleteDecorator; -import org.compiere.grid.ed.VAccount; -import org.compiere.grid.ed.VAssignment; -import org.compiere.grid.ed.VBinary; -import org.compiere.grid.ed.VButton; -import org.compiere.grid.ed.VChart; -import org.compiere.grid.ed.VCheckBox; -import org.compiere.grid.ed.VColor; -import org.compiere.grid.ed.VDate; -import org.compiere.grid.ed.VEditor; -import org.compiere.grid.ed.VFile; -import org.compiere.grid.ed.VImage; -import org.compiere.grid.ed.VLocation; -import org.compiere.grid.ed.VLocator; -import org.compiere.grid.ed.VLookup; -import org.compiere.grid.ed.VMemo; -import org.compiere.grid.ed.VNumber; -import org.compiere.grid.ed.VPAttribute; -import org.compiere.grid.ed.VPassword; -import org.compiere.grid.ed.VPaymentEditor; -import org.compiere.grid.ed.VString; -import org.compiere.grid.ed.VText; -import org.compiere.grid.ed.VTextLong; -import org.compiere.grid.ed.VURL; -import org.compiere.model.GridField; -import org.compiere.model.GridTab; -import org.compiere.model.MAccountLookup; -import org.compiere.model.MLocationLookup; -import org.compiere.model.MLocatorLookup; -import org.compiere.model.MPAttributeLookup; -import org.compiere.model.MPaymentLookup; -import org.compiere.util.DisplayType; - -/** - * - * @author hengsin - * - */ -public class DefaultEditorFactory implements IEditorFactory { - - @Override - public VEditor getEditor(GridTab mTab, GridField mField, boolean tableEditor) { - if (mField == null) - return null; - - VEditor editor = null; - int displayType = mField.getDisplayType(); - String columnName = mField.getColumnName(); - boolean mandatory = mField.isMandatory(false); // no context check - boolean readOnly = mField.isReadOnly(); - boolean updateable = mField.isUpdateable(); - int WindowNo = mField.getWindowNo(); - - // Not a Field - if (mField.isHeading()) - return null; - - // String (clear/password) - if (displayType == DisplayType.String - || displayType == DisplayType.PrinterName - || (tableEditor && (displayType == DisplayType.Text || displayType == DisplayType.TextLong)) ) - { - if (mField.isEncryptedField()) - { - VPassword vs = new VPassword (columnName, mandatory, readOnly, updateable, - mField.getDisplayLength(), mField.getFieldLength(), mField.getVFormat()); - vs.setName (columnName); - vs.setField (mField); - editor = vs; - } - else - { - VString vs = new VString (columnName, mandatory, readOnly, updateable, - mField.getDisplayLength(), mField.getFieldLength(), - mField.getVFormat(), mField.getObscureType()); - vs.setName (columnName); - vs.setField (mField); - if (mField.isAutocomplete()) { - ADempiereAutoCompleteDecorator.decorate(vs, mField.getEntries(), false); - } - editor = vs; - } - } - // URL - else if (displayType == DisplayType.URL) - { - VURL vs = new VURL (columnName, mandatory, readOnly, updateable, - mField.getDisplayLength(), mField.getFieldLength()); - vs.setName (columnName); - vs.setField (mField); - editor = vs; - } - - /** Printer Name - else if (displayType == DisplayType.PrinterName) - { - VPrinterName vs = new VPrinterName (columnName, mandatory, readOnly, updateable, - mField.getDisplayLength(), mField.getFieldLength(), mField.getVFormat()); - vs.setName (columnName); - vs.setField (mField); - editor = vs; - } **/ - - // File Path / Name - else if (displayType == DisplayType.FilePath || displayType == DisplayType.FileName) - { - VFile file = new VFile (columnName, mandatory, readOnly, updateable, - mField.getFieldLength(), displayType == DisplayType.FileName); - file.setName(columnName); - file.setField(mField); - editor = file; - } - - // Lookup - else if (DisplayType.isLookup(displayType) || displayType == DisplayType.ID) - { - VLookup vl = new VLookup(columnName, mandatory, readOnly, updateable, - mField.getLookup()); - vl.setName(columnName); - vl.setField (mField); - editor = vl; - } - - // Number - else if (DisplayType.isNumeric(displayType)) - { - VNumber vn = new VNumber(columnName, mandatory, readOnly, updateable, - displayType, mField.getHeader()); - vn.setRange(mField.getValueMin(), mField.getValueMax()); - vn.setName(columnName); - vn.setField (mField); - editor = vn; - } - - // YesNo - else if (displayType == DisplayType.YesNo) - { - VCheckBox vc = new VCheckBox(columnName, mandatory, readOnly, updateable, - mField.getHeader(), mField.getDescription(), tableEditor); - vc.setName(columnName); - vc.setField (mField); - editor = vc; - } - - // Text (single row) - else if (displayType == DisplayType.Text) - { - VText vt = new VText(columnName, mandatory, readOnly, updateable, - mField.getDisplayLength(), mField.getFieldLength()); - vt.setName(columnName); - vt.setField (mField); - editor = vt; - } - - // Memo (single row) - else if (displayType == DisplayType.Memo) - { - VMemo vt = new VMemo(columnName, mandatory, readOnly, updateable, - mField.getDisplayLength(), mField.getFieldLength()); - vt.setName(columnName); - vt.setField (mField); - editor = vt; - } - - // Date - else if (DisplayType.isDate(displayType)) - { - if (displayType == DisplayType.DateTime) - readOnly = true; - VDate vd = new VDate(columnName, mandatory, readOnly, updateable, - displayType, mField.getHeader()); - vd.setName(columnName); - vd.setField (mField); - editor = vd; - } - - // Location - else if (displayType == DisplayType.Location) - { - VLocation loc = new VLocation (mTab, columnName, mandatory, readOnly, updateable, - (MLocationLookup)mField.getLookup()); - loc.setName(columnName); - loc.setField (mField); - editor = loc; - } - - // Locator - else if (displayType == DisplayType.Locator) - { - VLocator loc = new VLocator (columnName, mandatory, readOnly, updateable, - (MLocatorLookup)mField.getLookup(), WindowNo); - loc.setName(columnName); - loc.setField (mField); - editor = loc; - } - - // Account - else if (displayType == DisplayType.Account) - { - //hengsin: bug [ 1711795 ] Combination copied itself in Grid mode - /* - VAccount acct = new VAccount (columnName, mandatory, readOnly, updateable, - (MAccountLookup)mField.getLookup(), mField.getHeader());*/ - VAccount acct = new VAccount (columnName, mandatory, readOnly, updateable, - new MAccountLookup (mField.getVO().ctx, mField.getWindowNo()), mField.getHeader()); - acct.setName(columnName); - acct.setField (mField); - editor = acct; - } - - // Button - else if (displayType == DisplayType.Button) - { - VButton button = new VButton(columnName, mandatory, readOnly, updateable, - mField.getHeader(), mField.getDescription(), mField.getHelp(), mField.getAD_Process_ID()); - button.setName(columnName); - button.setField (mField); - editor = button; - } - - // Assignment - else if (displayType == DisplayType.Assignment) - { - VAssignment assign = new VAssignment (mandatory, readOnly, updateable); - assign.setName(columnName); - assign.setField (mField); - editor = assign; - } - - // Color - else if (displayType == DisplayType.Color) - { - VColor color = new VColor (mTab, mandatory, readOnly); - color.setName(columnName); - color.setField (mField); - editor = color; - } - - // Image - else if (displayType == DisplayType.Image) - { - VImage image = new VImage (columnName, WindowNo); - image.setName(columnName); - image.setField (mField); - editor = image; - } - - // PAttribute - else if (displayType == DisplayType.PAttribute) - { - VPAttribute attrib = new VPAttribute (mTab, mandatory, readOnly, updateable, WindowNo, - (MPAttributeLookup)mField.getLookup()); - attrib.setName(columnName); - attrib.setField (mField); - editor = attrib; - } - - // Long Text (CLob) - else if (displayType == DisplayType.TextLong) - { - VTextLong vt = new VTextLong (columnName, mandatory, readOnly, updateable, - mField.getDisplayLength(), mField.getFieldLength()); - vt.setName(columnName); - vt.setField (mField); - editor = vt; - } - - // Binary (BLob) - else if (displayType == DisplayType.Binary) - { - VBinary bin = new VBinary (columnName, WindowNo); - bin.setName(columnName); - bin.setField (mField); - editor = bin; - } - - else if (displayType == DisplayType.Payment) - { - VPaymentEditor p = new VPaymentEditor (mField, columnName, mandatory, readOnly, updateable, (MPaymentLookup) mField.getLookup()); - editor = p; - } - - // Chart - else if (displayType == DisplayType.Chart ) - { - VChart chart = new VChart(mField.getAD_Chart_ID(), WindowNo); - editor = chart; - } - - return editor; - } - -} diff --git a/org.adempiere.ui.swing/src/org/adempiere/ui/swing/factory/DefaultFormFactory.java b/org.adempiere.ui.swing/src/org/adempiere/ui/swing/factory/DefaultFormFactory.java deleted file mode 100644 index 855b99e767..0000000000 --- a/org.adempiere.ui.swing/src/org/adempiere/ui/swing/factory/DefaultFormFactory.java +++ /dev/null @@ -1,77 +0,0 @@ -/****************************************************************************** - * Copyright (C) 2013 Heng Sin Low * - * Copyright (C) 2013 Trek Global * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - *****************************************************************************/ -package org.adempiere.ui.swing.factory; - -import java.util.logging.Level; - -import org.adempiere.base.equinox.EquinoxExtensionLocator; -import org.compiere.apps.form.FormPanel; -import org.compiere.util.CLogger; - -/** - * @author hengsin - * - */ -public class DefaultFormFactory implements IFormFactory { - - private final static CLogger log = CLogger.getCLogger(DefaultFormFactory.class); - - /** - * default constructor - */ - public DefaultFormFactory() { - } - - /* (non-Javadoc) - * @see org.adempiere.ui.swing.factory.IFormFactory#newFormInstance(java.lang.String) - */ - @Override - public FormPanel newFormInstance(String formName) { - FormPanel form = EquinoxExtensionLocator.instance().locate(FormPanel.class, "org.adempiere.apps.Form", formName, null).getExtension(); - if (form == null) { - ClassLoader loader = Thread.currentThread().getContextClassLoader(); - Class clazz = null; - if (loader != null) { - try { - clazz = loader.loadClass(formName); - } catch (Exception e) { - if (log.isLoggable(Level.INFO)) { - log.log(Level.INFO, e.getLocalizedMessage(), e); - } - } - } - if (clazz == null) { - loader = this.getClass().getClassLoader(); - try { - clazz = loader.loadClass(formName); - } catch (Exception e) { - if (log.isLoggable(Level.INFO)) { - log.log(Level.INFO, e.getLocalizedMessage(), e); - } - } - } - if (clazz != null) { - try { - form = (FormPanel) clazz.newInstance(); - } catch (Exception e) { - if (log.isLoggable(Level.WARNING)) { - log.log(Level.WARNING, e.getLocalizedMessage(), e); - } - } - } - } - return form; - } - -} diff --git a/org.adempiere.ui.swing/src/org/adempiere/ui/swing/factory/DefaultInfoFactory.java b/org.adempiere.ui.swing/src/org/adempiere/ui/swing/factory/DefaultInfoFactory.java deleted file mode 100644 index 31b30f5d96..0000000000 --- a/org.adempiere.ui.swing/src/org/adempiere/ui/swing/factory/DefaultInfoFactory.java +++ /dev/null @@ -1,136 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 2010 Heng Sin Low * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - *****************************************************************************/ -package org.adempiere.ui.swing.factory; - -import java.awt.Frame; - -import org.compiere.apps.search.Info; -import org.compiere.apps.search.InfoAsset; -import org.compiere.apps.search.InfoAssignment; -import org.compiere.apps.search.InfoBPartner; -import org.compiere.apps.search.InfoCashLine; -import org.compiere.apps.search.InfoGeneral; -import org.compiere.apps.search.InfoInOut; -import org.compiere.apps.search.InfoInvoice; -import org.compiere.apps.search.InfoOrder; -import org.compiere.apps.search.InfoPayment; -import org.compiere.apps.search.InfoProduct; -import org.compiere.model.GridField; -import org.compiere.model.Lookup; -import org.compiere.model.MColumn; -import org.compiere.model.MInvoiceLine; -import org.compiere.model.MOrderLine; -import org.compiere.model.MProductPrice; -import org.compiere.util.CLogger; -import org.compiere.util.Env; -import org.eevolution.model.I_PP_Product_BOMLine; - -/** - * - * @author hengsin - * - */ -public class DefaultInfoFactory implements IInfoFactory { - - @SuppressWarnings("unused") - private final static CLogger log = CLogger.getCLogger(DefaultInfoFactory.class); - - @Override - public Info create(Frame frame, boolean modal, Lookup lookup, - GridField field, String tableName, String keyColumn, String queryValue, - boolean multiSelection, String whereClause) { - Info info = null; - String col = lookup.getColumnName(); // fully qualified name - if (col.indexOf('.') != -1) - col = col.substring(col.indexOf('.')+1); - boolean multipleSelection = false; - if (col.equals("M_Product_ID")) - { - int M_Warehouse_ID = Env.getContextAsInt(Env.getCtx(), lookup.getWindowNo(), "M_Warehouse_ID"); - int M_PriceList_ID = Env.getContextAsInt(Env.getCtx(), lookup.getWindowNo(), "M_PriceList_ID"); - - if(field != null) - { - int AD_Table_ID = MColumn.getTable_ID(Env.getCtx(), field.getAD_Column_ID(), null); - multipleSelection = (MOrderLine.Table_ID == AD_Table_ID) || (MInvoiceLine.Table_ID == AD_Table_ID) || (I_PP_Product_BOMLine.Table_ID == AD_Table_ID) || (MProductPrice.Table_ID == AD_Table_ID); - } - // Show Info - info = new InfoProduct (frame, true, lookup.getWindowNo(), - M_Warehouse_ID, M_PriceList_ID, queryValue, multipleSelection, whereClause); - } - else if (col.equals("C_BPartner_ID")) - { - boolean isSOTrx = true; // default - if (Env.getContext(Env.getCtx(), lookup.getWindowNo(), "IsSOTrx").equals("N")) - isSOTrx = false; - info = new InfoBPartner (frame, true, lookup.getWindowNo(), - queryValue, isSOTrx, multipleSelection, whereClause); - } - else // General Info - { - info = create (frame, true, lookup.getWindowNo(), - tableName, keyColumn, queryValue, multipleSelection, whereClause, true); - } - return info; - } - - @Override - public Info create(Frame frame, boolean modal, int WindowNo, - String tableName, String keyColumn, String value, - boolean multiSelection, String whereClause, boolean lookup) { - Info info = null; - - if (tableName.equals("C_BPartner")) - info = new InfoBPartner (frame, modal, WindowNo, value, !Env.getContext(Env.getCtx(),"IsSOTrx").equals("N"), - multiSelection, whereClause, lookup); - else if (tableName.equals("M_Product")) - info = new InfoProduct (frame, modal, WindowNo, - Env.getContextAsInt(Env.getCtx(), WindowNo, "M_Warehouse_ID"), - Env.getContextAsInt(Env.getCtx(), WindowNo, "M_PriceList_ID"), - value, multiSelection, whereClause, lookup); - else if (tableName.equals("C_Invoice")) - info = new InfoInvoice (frame, modal, WindowNo, value, - multiSelection, whereClause, lookup); - else if (tableName.equals("A_Asset")) - info = new InfoAsset (frame, modal, WindowNo, 0, value, - multiSelection, whereClause, lookup); - else if (tableName.equals("C_Order")) - info = new InfoOrder (frame, modal, WindowNo, value, - multiSelection, whereClause, lookup); - else if (tableName.equals("M_InOut")) - info = new InfoInOut (frame, modal, WindowNo, value, - multiSelection, whereClause, lookup); - else if (tableName.equals("C_Payment")) - info = new InfoPayment (frame, modal, WindowNo, value, - multiSelection, whereClause, lookup); - else if (tableName.equals("C_CashLine")) - info = new InfoCashLine (frame, modal, WindowNo, value, - multiSelection, whereClause); - else if (tableName.equals("S_ResourceAssigment")) - info = new InfoAssignment (frame, modal, WindowNo, value, - multiSelection, whereClause, lookup); - else { - info = new InfoGeneral (frame, modal, WindowNo, value, - tableName, keyColumn, - multiSelection, whereClause, lookup); - if (!info.loadedOK()) { - info.dispose(false); - info = null; - } - } - // - return info; - } - -} diff --git a/org.adempiere.ui.swing/src/org/adempiere/ui/swing/factory/IEditorFactory.java b/org.adempiere.ui.swing/src/org/adempiere/ui/swing/factory/IEditorFactory.java deleted file mode 100644 index df1dc595a8..0000000000 --- a/org.adempiere.ui.swing/src/org/adempiere/ui/swing/factory/IEditorFactory.java +++ /dev/null @@ -1,36 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 2010 Heng Sin Low * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - *****************************************************************************/ -package org.adempiere.ui.swing.factory; - -import org.compiere.grid.ed.VEditor; -import org.compiere.model.GridField; -import org.compiere.model.GridTab; - -/** - * - * @author hengsin - * - */ -public interface IEditorFactory { - - /** - * Create Editor for MField. - * The Name is set to the column name for dynamic display management - * @param mTab MTab - * @param mField MField - * @param tableEditor true if table editor - * @return grid editor - */ - public VEditor getEditor (GridTab mTab, GridField mField, boolean tableEditor); -} diff --git a/org.adempiere.ui.swing/src/org/adempiere/ui/swing/factory/IFormFactory.java b/org.adempiere.ui.swing/src/org/adempiere/ui/swing/factory/IFormFactory.java deleted file mode 100644 index 90613f53e1..0000000000 --- a/org.adempiere.ui.swing/src/org/adempiere/ui/swing/factory/IFormFactory.java +++ /dev/null @@ -1,30 +0,0 @@ -/****************************************************************************** - * Copyright (C) 2013 Heng Sin Low * - * Copyright (C) 2013 Trek Global * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - *****************************************************************************/ -package org.adempiere.ui.swing.factory; - -import org.compiere.apps.form.FormPanel; - -/** - * - * @author hengsin - * - */ -public interface IFormFactory { - - /** - * @param formName - * @return new form instance - */ - public FormPanel newFormInstance(String formName); -} diff --git a/org.adempiere.ui.swing/src/org/adempiere/ui/swing/factory/IInfoFactory.java b/org.adempiere.ui.swing/src/org/adempiere/ui/swing/factory/IInfoFactory.java deleted file mode 100644 index 87f0cda4b4..0000000000 --- a/org.adempiere.ui.swing/src/org/adempiere/ui/swing/factory/IInfoFactory.java +++ /dev/null @@ -1,62 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 2010 Heng Sin Low * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - *****************************************************************************/ -package org.adempiere.ui.swing.factory; - -import java.awt.Frame; - -import org.compiere.apps.search.Info; -import org.compiere.model.GridField; -import org.compiere.model.Lookup; - -/** - * - * @author hengsin - * - */ -public interface IInfoFactory { - - /** - * Factory Constructor - * @param frame parent frame - * @param modal new window is modal - * @param lookup Lookup - * @param field Grid field - * @param tableName table name of the search - * @param keyColumn key column of the search - * @param value query value - * @param multiSelection allow to select more than one row - * @param whereClause fully qualified where clause for the search - * @return special or general Info Window - */ - public Info create (Frame frame, boolean modal, Lookup lookup, GridField field, - String tableName, String keyColumn, String value, - boolean multiSelection, String whereClause); - - /** - * Factory Constructor - * @param frame parent frame - * @param modal new window is modal - * @param WindowNo window no - * @param tableName table name of the search - * @param keyColumn key column of the search - * @param value query value - * @param multiSelection allow to select more than one row - * @param whereClause fully qualified where clause for the search - * @param lookup - * @return special or general Info Window - */ - public Info create (Frame frame, boolean modal, int WindowNo, - String tableName, String keyColumn, String value, - boolean multiSelection, String whereClause, boolean lookup); -} diff --git a/org.adempiere.ui.swing/src/org/compiere/AdempiereClient.java b/org.adempiere.ui.swing/src/org/compiere/AdempiereClient.java deleted file mode 100644 index 6480138ef2..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/AdempiereClient.java +++ /dev/null @@ -1,205 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ -package org.compiere; - -import java.util.logging.Level; - -import org.compiere.db.CConnection; -import org.compiere.model.MClient; -import org.compiere.model.MSystem; -import org.compiere.model.ModelValidationEngine; -import org.compiere.util.CLogFile; -import org.compiere.util.CLogMgt; -import org.compiere.util.CLogger; -import org.compiere.util.DB; -import org.compiere.util.Env; -import org.compiere.util.Ini; -import org.compiere.util.Login; -import org.compiere.util.SecureEngine; -import org.compiere.util.SecureInterface; -import org.compiere.util.Splash; - -/** - * Adempiere Control Class - * - * @author Jorg Janke - * @version $Id: Adempiere.java,v 1.8 2006/08/11 02:58:14 jjanke Exp $ - * - */ -public final class AdempiereClient -{ - /** Logging */ - private static CLogger log = null; - - /************************************************************************* - * Startup Client. - * - Print greeting, - * - Check Java version and - * - load ini parameters - * If it is a client, load/set PLAF and exit if error. - * If Client, you need to call startupEnvironment explicitly! - * For testing call method startupEnvironment - * @param isClient true for client - * @return successful startup - */ - public static synchronized boolean startup (boolean isClient) - { - // Already started - if (log != null) - return true; - - // Check Version - if (!Login.isJavaOK(isClient) && isClient) - System.exit(1); - - CLogMgt.initialize(isClient); - Ini.setClient (isClient); // Ini requires Logging - // Init Log - log = CLogger.getCLogger(AdempiereClient.class); - // Greeting - if (log.isLoggable(Level.INFO)) log.info(Adempiere.getSummaryAscii()); - // log.info(getAdempiereHome() + " - " + getJavaInfo() + " - " + getOSInfo()); - - // Load System environment - // EnvLoader.load(Ini.ENV_PREFIX); - - // System properties - Ini.loadProperties (false); - - // Set up Log - CLogMgt.setLevel(Ini.getProperty(Ini.P_TRACELEVEL)); - if (isClient && Ini.isPropertyBool(Ini.P_TRACEFILE)) - CLogMgt.addHandler(new CLogFile(Ini.findAdempiereHome(), true, isClient)); - - // Set UI - if (isClient) - { - if (CLogMgt.isLevelAll()) - log.log(Level.FINEST, System.getProperties().toString()); - } - - // Set Default Database Connection from Ini - DB.setDBTarget(CConnection.get()); - - if (isClient) // don't test connection - return false; // need to call - - return startupEnvironment(isClient); - } // startup - - /** - * Startup Adempiere Environment. - * Automatically called for Server connections - * For testing call this method. - * @param isClient true if client connection - * @return successful startup - */ - public static boolean startupEnvironment (boolean isClient) - { - startup(isClient); // returns if already initiated - if (!DB.isConnected()) - { - log.severe ("No Database"); - return false; - } - MSystem system = MSystem.get(Env.getCtx()); // Initializes Base Context too - if (system == null) - return false; - - // Initialize main cached Singletons - ModelValidationEngine.get(); - try - { - String className = system.getEncryptionKey(); - if (className == null || className.length() == 0) - { - className = System.getProperty(SecureInterface.ADEMPIERE_SECURE); - if (className != null && className.length() > 0 - && !className.equals(SecureInterface.ADEMPIERE_SECURE_DEFAULT)) - { - SecureEngine.init(className); // test it - system.setEncryptionKey(className); - system.saveEx(); - } - } - SecureEngine.init(className); - - // - if (isClient) - MClient.get(Env.getCtx(),0); // Login Client loaded later - else - MClient.getAll(Env.getCtx()); - } - catch (Exception e) - { - log.warning("Environment problems: " + e.toString()); - } - - // Start Workflow Document Manager (in other package) for PO - String className = null; - try - { - className = "org.compiere.wf.DocWorkflowManager"; - Class.forName(className); - // Initialize Archive Engine - className = "org.compiere.print.ArchiveEngine"; - Class.forName(className); - } - catch (Exception e) - { - log.warning("Not started: " + className + " - " + e.getMessage()); - } - - if (!isClient) - DB.updateMail(); - return true; - } // startupEnvironment - - - /** - * Main Method - * - * @param args optional start class - */ - public static void main (String[] args) - { - Splash.getSplash(); - startup(true); // error exit and initUI - - // Start with class as argument - or if nothing provided with Client - String className = "org.compiere.apps.AMenu"; - for (int i = 0; i < args.length; i++) - { - if (!args[i].equals("-debug")) // ignore -debug - { - className = args[i]; - break; - } - } - // - try - { - Class startClass = Class.forName(className); - startClass.newInstance(); - } - catch (Exception e) - { - System.err.println("ADempiere starting: " + className + " - " + e.toString()); - e.printStackTrace(); - } - } // main -} // Adempiere diff --git a/org.adempiere.ui.swing/src/org/compiere/acct/AcctViewer.java b/org.adempiere.ui.swing/src/org/compiere/acct/AcctViewer.java deleted file mode 100644 index b2f326b873..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/acct/AcctViewer.java +++ /dev/null @@ -1,819 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ -package org.compiere.acct; - -import java.awt.BorderLayout; -import java.awt.Color; -import java.awt.Cursor; -import java.awt.FlowLayout; -import java.awt.GridBagConstraints; -import java.awt.GridBagLayout; -import java.awt.Insets; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.sql.Timestamp; -import java.util.Iterator; -import java.util.logging.Level; - -import javax.swing.BorderFactory; -import javax.swing.ImageIcon; -import javax.swing.border.TitledBorder; -import javax.swing.event.ChangeEvent; -import javax.swing.event.ChangeListener; - -import org.compiere.apps.ADialog; -import org.compiere.apps.AEnv; -import org.compiere.apps.PrintScreenPainter; -import org.compiere.apps.search.Info; -import org.compiere.grid.ed.VDate; -import org.compiere.model.MAcctSchema; -import org.compiere.model.MAcctSchemaElement; -import org.compiere.model.MColumn; -import org.compiere.model.MPeriod; -import org.compiere.model.X_C_AcctSchema_Element; -import org.compiere.report.core.RModel; -import org.compiere.report.core.RModelExcelExporter; -import org.compiere.report.core.ResultTable; -import org.compiere.swing.CButton; -import org.compiere.swing.CCheckBox; -import org.compiere.swing.CComboBox; -import org.compiere.swing.CFrame; -import org.compiere.swing.CLabel; -import org.compiere.swing.CPanel; -import org.compiere.swing.CScrollPane; -import org.compiere.swing.CTabbedPane; -import org.compiere.util.CLogMgt; -import org.compiere.util.CLogger; -import org.compiere.util.DisplayType; -import org.compiere.util.Env; -import org.compiere.util.KeyNamePair; -import org.compiere.util.Msg; -import org.compiere.util.ValueNamePair; - -/** - * Account Viewer - * - * @author Jorg Janke - * @version $Id: AcctViewer.java,v 1.3 2006/08/10 01:00:27 jjanke Exp $ - * - * @author Teo Sarca, SC ARHIPAC SERVICE SRL - * BF [ 1778534 ] Info Account: can't find product - * @author Colin Rooney (croo) - * BF [ 2006668 ] Selection of Product in the Accounting Viewer - */ -public class AcctViewer extends CFrame - implements ActionListener, ChangeListener -{ - /** - * - */ - private static final long serialVersionUID = -6160970582569467185L; - - /** - * Default constructor - */ - public AcctViewer() - { - this (0, 0, 0); - } // AcctViewer - - /** - * Detail Constructor - * - * @param AD_Client_ID Client - * @param AD_Table_ID Table - * @param Record_ID Record - */ - public AcctViewer(int AD_Client_ID, int AD_Table_ID, int Record_ID) - { - super (Msg.getMsg(Env.getCtx(), "AcctViewer")); - if (log.isLoggable(Level.INFO)) log.info("AD_Table_ID=" + AD_Table_ID + ", Record_ID=" + Record_ID); - setDefaultCloseOperation(DISPOSE_ON_CLOSE); - m_data = new AcctViewerData (Env.getCtx(), AEnv.createWindowNo(this), - AD_Client_ID, AD_Table_ID); - AEnv.addToWindowManager(this); - // - try - { - jbInit(); - dynInit (AD_Table_ID, Record_ID); - AEnv.showCenterScreen(this); - } - catch(Exception e) - { - log.log(Level.SEVERE, "", e); - dispose(); - } - } // AcctViewer - - /** State Info */ - private AcctViewerData m_data = null; - /** Image Icon */ - private ImageIcon m_iFind = new ImageIcon(org.compiere.Adempiere.getResource("images/Find16.gif")); - - /** Logger */ - private static CLogger log = CLogger.getCLogger(AcctViewer.class); - - /** @todo Display Record Info & Zoom */ - - // - private CPanel mainPanel = new CPanel(); - private CTabbedPane tabbedPane = new CTabbedPane(); - private CPanel query = new CPanel(); - private BorderLayout mainLayout = new BorderLayout(); - private CScrollPane result = new CScrollPane(); - private ResultTable table = new ResultTable(); - private CPanel southPanel = new CPanel(); - private CButton bQuery = new CButton(); - private CButton bPrint = new CButton(); - private CButton bExport = new CButton(); - private CLabel statusLine = new CLabel(); - private BorderLayout southLayout = new BorderLayout(); - private BorderLayout queryLayout = new BorderLayout(); - private CPanel selectionPanel = new CPanel(); - private CPanel displayPanel = new CPanel(); - private TitledBorder displayBorder; - private TitledBorder selectionBorder; - private GridBagLayout displayLayout = new GridBagLayout(); - private CCheckBox displayQty = new CCheckBox(); - private CCheckBox displaySourceAmt = new CCheckBox(); -// private CPanel graphPanel = new CPanel(); - private CCheckBox displayDocumentInfo = new CCheckBox(); - private CLabel lSort = new CLabel(); - private CComboBox sortBy1 = new CComboBox(); - private CComboBox sortBy2 = new CComboBox(); - private CComboBox sortBy3 = new CComboBox(); - private CCheckBox group1 = new CCheckBox(); - private CCheckBox group2 = new CCheckBox(); - private CCheckBox group3 = new CCheckBox(); - private CLabel lGroup = new CLabel(); - private GridBagLayout selectionLayout = new GridBagLayout(); - private CComboBox selAcctSchema = new CComboBox(); - private CComboBox selPostingType = new CComboBox(); - private CCheckBox selDocument = new CCheckBox(); - private CComboBox selTable = new CComboBox(); - private CButton selRecord = new CButton(); - private CLabel lOrg = new CLabel(); - private CComboBox selOrg = new CComboBox(); - private CLabel lAcct = new CLabel(); - private CButton selAcct = new CButton(); - private CLabel lDate = new CLabel(); - private CLabel lacctSchema = new CLabel(); - private CLabel lpostingType = new CLabel(); - private VDate selDateFrom = new VDate("DateFrom", false, false, true, DisplayType.Date, Msg.translate(Env.getCtx(), "DateFrom")); - private VDate selDateTo = new VDate("DateTo", false, false, true, DisplayType.Date, Msg.translate(Env.getCtx(), "DateTo")); - private CLabel lsel1 = new CLabel(); - private CLabel lsel2 = new CLabel(); - private CLabel lsel3 = new CLabel(); - private CLabel lsel4 = new CLabel(); - private CLabel lsel5 = new CLabel(); - private CLabel lsel6 = new CLabel(); - private CLabel lsel7 = new CLabel(); - private CLabel lsel8 = new CLabel(); - private CButton sel1 = new CButton(); - private CButton sel2 = new CButton(); - private CButton sel3 = new CButton(); - private CButton sel4 = new CButton(); - private CButton sel5 = new CButton(); - private CButton sel6 = new CButton(); - private CButton sel7 = new CButton(); - private CButton sel8 = new CButton(); - // - private CButton bRePost = new CButton(); - private CCheckBox forcePost = new CCheckBox(); - private CComboBox sortBy4 = new CComboBox(); - private CCheckBox group4 = new CCheckBox(); - - /** - * Static Init. - *
    -	 *  - mainPanel
    -	 *      - tabbedPane
    -	 *          - query
    -	 *          - result
    -	 *          - graphPanel
    -	 *  
    - * @throws Exception - */ - private void jbInit() throws Exception - { - ImageIcon ii = new ImageIcon(org.compiere.Adempiere.getResource("images/InfoAccount16.gif")); - setIconImage(ii.getImage()); - // - mainLayout.setHgap(5); - mainLayout.setVgap(5); - mainPanel.setLayout(mainLayout); - selectionPanel.setLayout(selectionLayout); - this.getContentPane().add(mainPanel, BorderLayout.CENTER); - mainPanel.add(tabbedPane, BorderLayout.CENTER); - // Selection - selectionBorder = new TitledBorder(BorderFactory.createEtchedBorder( - Color.white,new Color(148, 145, 140)), Msg.getMsg(Env.getCtx(),"Selection")); - selectionPanel.setBorder(selectionBorder); - lacctSchema.setLabelFor(selAcctSchema); - lacctSchema.setText(Msg.translate(Env.getCtx(), "C_AcctSchema_ID")); - lpostingType.setLabelFor(selPostingType); - lpostingType.setText(Msg.translate(Env.getCtx(), "PostingType")); - selDocument.setText(Msg.getMsg(Env.getCtx(), "SelectDocument")); - selDocument.addActionListener(this); - - lOrg.setLabelFor(selOrg); - lOrg.setText(Msg.translate(Env.getCtx(), "AD_Org_ID")); - lAcct.setLabelFor(selAcct); - lAcct.setText(Msg.translate(Env.getCtx(), "Account_ID")); - lDate.setLabelFor(selDateFrom); - lDate.setText(Msg.translate(Env.getCtx(), "DateAcct")); - lsel1.setLabelFor(sel1); - lsel2.setLabelFor(sel2); - lsel3.setLabelFor(sel3); - lsel4.setLabelFor(sel4); - lsel5.setLabelFor(sel5); - lsel6.setLabelFor(sel6); - lsel7.setLabelFor(sel7); - lsel8.setLabelFor(sel8); - - // Display - displayBorder = new TitledBorder(BorderFactory.createEtchedBorder( - Color.white,new Color(148, 145, 140)), Msg.getMsg(Env.getCtx(),"Display")); - displayPanel.setBorder(displayBorder); - displayPanel.setLayout(displayLayout); - displayQty.setText(Msg.getMsg(Env.getCtx(), "DisplayQty")); - displaySourceAmt.setText(Msg.getMsg(Env.getCtx(), "DisplaySourceInfo")); - displayDocumentInfo.setText(Msg.getMsg(Env.getCtx(), "DisplayDocumentInfo")); - lSort.setText(Msg.getMsg(Env.getCtx(), "SortBy")); - lGroup.setText(Msg.getMsg(Env.getCtx(), "GroupBy")); - // - displayPanel.add(displaySourceAmt, new GridBagConstraints(0, 1, 2, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 0, 5), 0, 0)); - displayPanel.add(displayDocumentInfo, new GridBagConstraints(0, 0, 2, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 0, 5), 0, 0)); - displayPanel.add(lSort, new GridBagConstraints(0, 4, 1, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 0, 5), 0, 0)); - displayPanel.add(sortBy1, new GridBagConstraints(0, 5, 1, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 0, 5), 0, 0)); - displayPanel.add(sortBy2, new GridBagConstraints(0, 6, 1, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 0, 5), 0, 0)); - displayPanel.add(group1, new GridBagConstraints(1, 5, 1, 1, 0.0, 0.0 - ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(5, 5, 0, 5), 0, 0)); - displayPanel.add(group2, new GridBagConstraints(1, 6, 1, 1, 0.0, 0.0 - ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(5, 5, 0, 5), 0, 0)); - displayPanel.add(lGroup, new GridBagConstraints(1, 4, 1, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 0, 5), 0, 0)); - displayPanel.add(displayQty, new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); - displayPanel.add(sortBy3, new GridBagConstraints(0, 7, 1, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 0, 5), 0, 0)); - displayPanel.add(group3, new GridBagConstraints(1, 7, 1, 1, 0.0, 0.0 - ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(5, 5, 0, 5), 0, 0)); - displayPanel.add(sortBy4, new GridBagConstraints(0, 8, 1, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 0, 5), 0, 0)); - displayPanel.add(group4, new GridBagConstraints(1, 8, 1, 1, 0.0, 0.0 - ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(5, 5, 0, 5), 0, 0)); - // - selectionPanel.add(lacctSchema, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); - selectionPanel.add(selAcctSchema, new GridBagConstraints(1, 0, 2, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); - - selectionPanel.add(selDocument, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(10, 5, 10, 5), 0, 0)); - selectionPanel.add(selTable, new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(10, 5, 10, 5), 0, 0)); - selectionPanel.add(selRecord, new GridBagConstraints(2, 1, 2, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(10, 5, 10, 5), 0, 0)); - - selectionPanel.add(lpostingType, new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 5, 0, 5), 0, 0)); - selectionPanel.add(selPostingType, new GridBagConstraints(1, 2, 2, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 0, 5), 0, 0)); - selectionPanel.add(lDate, new GridBagConstraints(0, 3, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 5, 0, 5), 0, 0)); - selectionPanel.add(selDateFrom, new GridBagConstraints(1, 3, 1, 1, 0.0, 0.0 - ,GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 0, 5), 0, 0)); - selectionPanel.add(selDateTo, new GridBagConstraints(2, 3, 1, 1, 0.0, 0.0 - ,GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 0, 5), 0, 0)); - selectionPanel.add(lOrg, new GridBagConstraints(0, 4, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 0, 0, 5), 0, 0)); - selectionPanel.add(selOrg, new GridBagConstraints(1, 4, 2, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 0, 5), 0, 0)); - selectionPanel.add(lAcct, new GridBagConstraints(0, 5, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 5, 0, 5), 0, 0)); - selectionPanel.add(selAcct, new GridBagConstraints(1, 5, 2, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 0, 5), 0, 0)); - selectionPanel.add(lsel1, new GridBagConstraints(0, 6, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 5, 0, 5), 0, 0)); - selectionPanel.add(lsel2, new GridBagConstraints(0, 7, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 5, 0, 5), 0, 0)); - selectionPanel.add(lsel3, new GridBagConstraints(0, 8, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 5, 0, 5), 0, 0)); - selectionPanel.add(sel1, new GridBagConstraints(1, 6, 2, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 0, 5), 0, 0)); - selectionPanel.add(sel2, new GridBagConstraints(1, 7, 2, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 0, 5), 0, 0)); - selectionPanel.add(sel3, new GridBagConstraints(1, 8, 2, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 0, 5), 0, 0)); - selectionPanel.add(lsel4, new GridBagConstraints(0, 9, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 5, 0, 5), 0, 0)); - selectionPanel.add(sel4, new GridBagConstraints(1, 9, 2, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 0, 5), 0, 0)); - - selectionPanel.add(lsel5, new GridBagConstraints(0, 10, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 5, 0, 5), 0, 0)); - selectionPanel.add(sel5, new GridBagConstraints(1, 10, 2, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 0, 5), 0, 0)); - selectionPanel.add(lsel6, new GridBagConstraints(0, 11, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 5, 0, 5), 0, 0)); - selectionPanel.add(sel6, new GridBagConstraints(1, 11, 2, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 0, 5), 0, 0)); - selectionPanel.add(lsel7, new GridBagConstraints(0, 12, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 5, 0, 5), 0, 0)); - selectionPanel.add(sel7, new GridBagConstraints(1, 12, 2, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 0, 5), 0, 0)); - selectionPanel.add(lsel8, new GridBagConstraints(0, 13, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 5, 0, 5), 0, 0)); - selectionPanel.add(sel8, new GridBagConstraints(1, 13, 2, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 0, 5), 0, 0)); - // - queryLayout.setHgap(5); - queryLayout.setVgap(5); - query.setLayout(queryLayout); - query.add(selectionPanel, BorderLayout.CENTER); - query.add(displayPanel, BorderLayout.EAST); - // - tabbedPane.add(query, Msg.getMsg(Env.getCtx(), "ViewerQuery")); - tabbedPane.add(result, Msg.getMsg(Env.getCtx(), "ViewerResult")); -// tabbedPane.add(graphPanel, Msg.getMsg(Env.getCtx(), "ViewerGraph")); - tabbedPane.addChangeListener(this); - result.getViewport().add(table, null); - // South - southLayout.setHgap(5); - southLayout.setVgap(5); - southPanel.setLayout(southLayout); - statusLine.setForeground(Color.blue); - statusLine.setBorder(BorderFactory.createLoweredBevelBorder()); - southPanel.add(statusLine, BorderLayout.CENTER); - bRePost.setText(Msg.getMsg(Env.getCtx(), "RePost")); - bRePost.setToolTipText(Msg.getMsg(Env.getCtx(), "RePostInfo")); - bRePost.addActionListener(this); - bRePost.setVisible(false); - forcePost.setText(Msg.getMsg(Env.getCtx(), "Force")); - forcePost.setToolTipText(Msg.getMsg(Env.getCtx(), "ForceInfo")); - forcePost.setVisible(false); - CPanel leftSide = new CPanel(new FlowLayout(FlowLayout.LEADING, 0, 0)); - leftSide.add(bRePost); - leftSide.add(forcePost); - southPanel.add(leftSide, BorderLayout.WEST); - // - bQuery.setIcon(Env.getImageIcon("Refresh16.gif")); - bQuery.setToolTipText(Msg.getMsg(Env.getCtx(), "Refresh")); - bQuery.addActionListener(this); - bPrint.setIcon(Env.getImageIcon("Print16.gif")); - bPrint.setToolTipText(Msg.getMsg(Env.getCtx(), "Print")); - bPrint.addActionListener(this); - bExport.setIcon(Env.getImageIcon("Export16.gif")); - bExport.setToolTipText(Msg.getMsg(Env.getCtx(), "Export")); - bExport.setVisible(tabbedPane.getSelectedIndex() == 1); - bExport.addActionListener(this); - CPanel rightSide = new CPanel(new FlowLayout(FlowLayout.TRAILING, 0, 0)); - rightSide.add(bExport); - rightSide.add(bPrint); - rightSide.add(bQuery); - southPanel.add(rightSide, BorderLayout.EAST); - this.getContentPane().add(southPanel, BorderLayout.SOUTH); - // - } // jbInit - - /** - * Dynamic Init - * - * @param AD_Table_ID table - * @param Record_ID record - */ - private void dynInit (int AD_Table_ID, int Record_ID) - { - m_data.fillAcctSchema(selAcctSchema); - selAcctSchema.addActionListener(this); - actionAcctSchema(); - // - m_data.fillTable(selTable); - selTable.addActionListener(this); - selRecord.setIcon(m_iFind); - selRecord.addActionListener(this); - selRecord.setText(""); - // - m_data.fillPostingType (selPostingType); - - // Mandatory Elements - m_data.fillOrg(selOrg); - selAcct.setActionCommand("Account_ID"); - selAcct.addActionListener(this); - selAcct.setText(""); - selAcct.setIcon(m_iFind); - - // Document Select - boolean haveDoc = AD_Table_ID != 0 && Record_ID != 0; - selDocument.setSelected (haveDoc); - actionDocument(); - actionTable(); - statusLine.setText(" " + Msg.getMsg(Env.getCtx(), "ViewerOptions")); - - // Initial Query - if (haveDoc) - { - m_data.AD_Table_ID = AD_Table_ID; - m_data.Record_ID = Record_ID; - actionQuery(); - } - } // dynInit - - /** - * Dispose - */ - public void dispose() - { - if (m_data != null) - m_data.dispose(); - m_data = null; - super.dispose(); - } // dispose; - - /************************************************************************** - * Tab Changed - * @param e ChangeEvent - */ - public void stateChanged(ChangeEvent e) - { - // if (log.isLoggable(Level.INFO)) log.info( "AcctViewer.stateChanged"); - boolean visible = m_data.documentQuery && tabbedPane.getSelectedIndex() == 1; - bRePost.setVisible(visible); - bExport.setVisible(tabbedPane.getSelectedIndex() == 1); - forcePost.setVisible(visible); - } // stateChanged - - - /** - * Action Performed (Action Listener) - * @param e ActionEvent - */ - public void actionPerformed(ActionEvent e) - { - // log.info(e.getActionCommand()); - Object source = e.getSource(); - if (source == selAcctSchema) - actionAcctSchema(); - else if (source == bQuery) - actionQuery(); - else if (source == selDocument) - actionDocument(); - else if (source == selTable) - actionTable(); - else if (source == bRePost) - actionRePost(); - else if (source == bPrint) - PrintScreenPainter.printScreen(this); - else if (source == bExport) - exportExcel(); - // InfoButtons - else if (source instanceof CButton) - actionButton((CButton)source); - } // actionPerformed - - /** - * New Acct Schema - */ - private void actionAcctSchema() - { - KeyNamePair kp = (KeyNamePair)selAcctSchema.getSelectedItem(); - if (kp == null) - return; - m_data.C_AcctSchema_ID = kp.getKey(); - m_data.ASchema = MAcctSchema.get(Env.getCtx(), m_data.C_AcctSchema_ID); - if (log.isLoggable(Level.INFO)) log.info(m_data.ASchema.toString()); - // - // Sort Options - sortBy1.removeAllItems(); - sortBy2.removeAllItems(); - sortBy3.removeAllItems(); - sortBy4.removeAllItems(); - sortAddItem(new ValueNamePair("","")); - sortAddItem(new ValueNamePair("DateAcct", Msg.translate(Env.getCtx(), "DateAcct"))); - sortAddItem(new ValueNamePair("DateTrx", Msg.translate(Env.getCtx(), "DateTrx"))); - sortAddItem(new ValueNamePair("C_Period_ID", Msg.translate(Env.getCtx(), "C_Period_ID"))); - // - CLabel[] labels = new CLabel[] {lsel1, lsel2, lsel3, lsel4, lsel5, lsel6, lsel7, lsel8}; - CButton[] buttons = new CButton[] {sel1, sel2, sel3, sel4, sel5, sel6, sel7, sel8}; - int selectionIndex = 0; - MAcctSchemaElement[] elements = m_data.ASchema.getAcctSchemaElements(); - for (int i = 0; i < elements.length && selectionIndex < labels.length; i++) - { - MAcctSchemaElement ase = elements[i]; - String columnName = ase.getColumnName(); - String displayColumnName = ase.getDisplayColumnName(); - // Add Sort Option - sortAddItem(new ValueNamePair(columnName, Msg.translate(Env.getCtx(), displayColumnName))); - // Additional Elements - if (!ase.isElementType(X_C_AcctSchema_Element.ELEMENTTYPE_Organization) - && !ase.isElementType(X_C_AcctSchema_Element.ELEMENTTYPE_Account)) - { - labels[selectionIndex].setText(Msg.translate(Env.getCtx(), displayColumnName)); - labels[selectionIndex].setVisible(true); - buttons[selectionIndex].setActionCommand(columnName); - buttons[selectionIndex].addActionListener(this); - buttons[selectionIndex].setIcon(m_iFind); - buttons[selectionIndex].setText(""); - buttons[selectionIndex].setVisible(true); - selectionIndex++; - } - } - // don't show remaining - while (selectionIndex < labels.length) - { - labels[selectionIndex].setVisible(false); - buttons[selectionIndex++].setVisible(false); - } - } // actionAcctSchema - - /** - * Add to Sort - * @param vn name pair - */ - private void sortAddItem(ValueNamePair vn) - { - sortBy1.addItem(vn); - sortBy2.addItem(vn); - sortBy3.addItem(vn); - sortBy4.addItem(vn); - } // sortAddItem - - /** - * Query - */ - private void actionQuery() - { - // Parameter Info - StringBuilder para = new StringBuilder(); - // Reset Selection Data - m_data.C_AcctSchema_ID = 0; - m_data.AD_Org_ID = 0; - - // Save Selection Choices - KeyNamePair kp = (KeyNamePair)selAcctSchema.getSelectedItem(); - if (kp != null) - m_data.C_AcctSchema_ID = kp.getKey(); - para.append("C_AcctSchema_ID=").append(m_data.C_AcctSchema_ID); - // - ValueNamePair vp = (ValueNamePair)selPostingType.getSelectedItem(); - m_data.PostingType = vp.getValue(); - para.append(", PostingType=").append(m_data.PostingType); - - // Document - m_data.documentQuery = selDocument.isSelected(); - para.append(", DocumentQuery=").append(m_data.documentQuery); - if (selDocument.isSelected()) - { - if (m_data.AD_Table_ID == 0 || m_data.Record_ID == 0) - return; - para.append(", AD_Table_ID=").append(m_data.AD_Table_ID) - .append(", Record_ID=").append(m_data.Record_ID); - } - else - { - m_data.DateFrom = (Timestamp)selDateFrom.getValue(); - para.append(", DateFrom=").append(m_data.DateFrom); - m_data.DateTo = (Timestamp)selDateTo.getValue(); - para.append(", DateTo=").append(m_data.DateTo); - kp = (KeyNamePair)selOrg.getSelectedItem(); - if (kp != null) - m_data.AD_Org_ID = kp.getKey(); - para.append(", AD_Org_ID=").append(m_data.AD_Org_ID); - // - Iterator it = m_data.whereInfo.values().iterator(); - while (it.hasNext()) - para.append(", ").append(it.next()); - } - - // Save Display Choices - m_data.displayQty = displayQty.isSelected(); - para.append(" - Display Qty=").append(m_data.displayQty); - m_data.displaySourceAmt = displaySourceAmt.isSelected(); - para.append(", Source=").append(m_data.displaySourceAmt); - m_data.displayDocumentInfo = displayDocumentInfo.isSelected(); - para.append(", Doc=").append(m_data.displayDocumentInfo); - // - m_data.sortBy1 = ((ValueNamePair)sortBy1.getSelectedItem()).getValue(); - m_data.group1 = group1.isSelected(); - para.append(" - Sorting: ").append(m_data.sortBy1).append("/").append(m_data.group1); - m_data.sortBy2 = ((ValueNamePair)sortBy2.getSelectedItem()).getValue(); - m_data.group2 = group2.isSelected(); - para.append(", ").append(m_data.sortBy2).append("/").append(m_data.group2); - m_data.sortBy3 = ((ValueNamePair)sortBy3.getSelectedItem()).getValue(); - m_data.group3 = group3.isSelected(); - para.append(", ").append(m_data.sortBy3).append("/").append(m_data.group3); - m_data.sortBy4 = ((ValueNamePair)sortBy4.getSelectedItem()).getValue(); - m_data.group4 = group4.isSelected(); - para.append(", ").append(m_data.sortBy4).append("/").append(m_data.group4); - - bQuery.setEnabled(false); - statusLine.setText(" " + Msg.getMsg(Env.getCtx(), "Processing")); - - if (log.isLoggable(Level.CONFIG)) log.config(para.toString()); - Thread.yield(); - - // Switch to Result pane - tabbedPane.setSelectedIndex(1); - - // Set TableModel with Query - table.setModel(m_data.query()); - - bQuery.setEnabled(true); - statusLine.setText(" " + Msg.getMsg(Env.getCtx(), "ViewerOptions")); - } // actionQuery - - /** - * Document selection - */ - private void actionDocument() - { - boolean doc = selDocument.isSelected(); - selTable.setEnabled(doc); - selRecord.setEnabled(doc); - // - selDateFrom.setReadWrite(!doc); - selDateTo.setReadWrite(!doc); - selOrg.setEnabled(!doc); - selAcct.setEnabled(!doc); - sel1.setEnabled(!doc); - sel2.setEnabled(!doc); - sel3.setEnabled(!doc); - sel4.setEnabled(!doc); - sel5.setEnabled(!doc); - sel6.setEnabled(!doc); - sel7.setEnabled(!doc); - sel8.setEnabled(!doc); - } // actionDocument - - /** - * Save Table selection (reset Record selection) - */ - private void actionTable() - { - ValueNamePair vp = (ValueNamePair)selTable.getSelectedItem(); - m_data.AD_Table_ID = ((Integer)m_data.tableInfo.get(vp.getValue())).intValue(); - if (log.isLoggable(Level.CONFIG)) log.config(vp.getValue() + " = " + m_data.AD_Table_ID); - // Reset Record - m_data.Record_ID = 0; - selRecord.setText(""); - selRecord.setActionCommand(vp.getValue() + "_ID"); - } // actionTable - - /** - * Action Button - * - * @param button pressed button - * @return ID - */ - private int actionButton(CButton button) - { - String keyColumn = button.getActionCommand(); - log.info(keyColumn); - String whereClause = "(IsSummary='N' OR IsSummary IS NULL)"; - String lookupColumn = keyColumn; - if (keyColumn.equals("Account_ID")) - { - lookupColumn = "C_ElementValue_ID"; - MAcctSchemaElement ase = m_data.ASchema - .getAcctSchemaElement(X_C_AcctSchema_Element.ELEMENTTYPE_Account); - if (ase != null) - whereClause += " AND C_Element_ID=" + ase.getC_Element_ID(); - } - else if (keyColumn.equals("User1_ID")) - { - lookupColumn = "C_ElementValue_ID"; - MAcctSchemaElement ase = m_data.ASchema - .getAcctSchemaElement(X_C_AcctSchema_Element.ELEMENTTYPE_UserElementList1); - if (ase != null) - whereClause += " AND C_Element_ID=" + ase.getC_Element_ID(); - } - else if (keyColumn.equals("User2_ID")) - { - lookupColumn = "C_ElementValue_ID"; - MAcctSchemaElement ase = m_data.ASchema - .getAcctSchemaElement(X_C_AcctSchema_Element.ELEMENTTYPE_UserElementList2); - if (ase != null) - whereClause += " AND C_Element_ID=" + ase.getC_Element_ID(); - } - else if (keyColumn.equals("AD_OrgTrx_ID")) - { - lookupColumn = "AD_Org_ID"; - } - else if (keyColumn.equals("UserElement1_ID")) // KTU - { - MAcctSchemaElement ase = m_data.ASchema.getAcctSchemaElement(X_C_AcctSchema_Element.ELEMENTTYPE_UserColumn1); - lookupColumn = MColumn.getColumnName(Env.getCtx(), ase.getAD_Column_ID()); - whereClause = ""; - } - else if (keyColumn.equals("UserElement2_ID")) // KTU - { - MAcctSchemaElement ase = m_data.ASchema.getAcctSchemaElement(X_C_AcctSchema_Element.ELEMENTTYPE_UserColumn2); - lookupColumn = MColumn.getColumnName(Env.getCtx(), ase.getAD_Column_ID()); - whereClause = ""; - } - else if (keyColumn.equals("M_Product_ID")) - { - whereClause = ""; - } - else if (selDocument.isSelected()) - whereClause = ""; - String tableName = lookupColumn.substring(0, lookupColumn.length()-3); - Info info = Info.create(this, true, m_data.WindowNo, tableName, lookupColumn, "", false, whereClause); - if (!info.loadedOK()) - { - info.dispose(); - info = null; - button.setText(""); - m_data.whereInfo.put(keyColumn, ""); - return 0; - } - info.setVisible(true); - String selectSQL = info.getSelectedSQL(); // C_Project_ID=100 or "" - Integer key = (Integer)info.getSelectedKey(); - info = null; - if (selectSQL == null || selectSQL.length() == 0 || key == null) - { - button.setText(""); - m_data.whereInfo.put(keyColumn, ""); // no query - return 0; - } - - // Save for query - if (log.isLoggable(Level.CONFIG)) log.config(keyColumn + " - " + key); - if (button == selRecord) // Record_ID - m_data.Record_ID = key.intValue(); - else - m_data.whereInfo.put(keyColumn, keyColumn + "=" + key.intValue()); - - // Display Selection and resize - button.setText(m_data.getButtonText(tableName, lookupColumn, selectSQL)); - pack(); - return key.intValue(); - } // actionButton - - /** - * RePost Record - */ - private void actionRePost() - { - if (m_data.documentQuery - && m_data.AD_Table_ID != 0 && m_data.Record_ID != 0) - { - // IDEMPIERE-2392 - if (! MPeriod.isOpen(Env.getCtx(), m_data.AD_Table_ID, m_data.Record_ID, null)) { - ADialog.error(0, this, "Error", Msg.getMsg(Env.getCtx(), "PeriodClosed")); - return; - } - - if (ADialog.ask(m_data.WindowNo, this, "PostImmediate?")) { - setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); - boolean force = forcePost.isSelected(); - String error = AEnv.postImmediate (m_data.WindowNo, m_data.AD_Client_ID, - m_data.AD_Table_ID, m_data.Record_ID, force); - setCursor(Cursor.getDefaultCursor()); - if (error != null) - ADialog.error(0, this, "PostingError-N", error); - actionQuery(); - } - } - } // actionRePost - - /** - * Export to Excel - */ - private void exportExcel() { - RModel model = table.getRModel(); - if (model == null) { - return; - } - try { - RModelExcelExporter exporter = new RModelExcelExporter((RModel)model); - exporter.export(null, null); - } - catch (Exception e) { - ADialog.error(0, this, "Error", e.getLocalizedMessage()); - if (CLogMgt.isLevelFinest()) e.printStackTrace(); - } - } -} // AcctViewer diff --git a/org.adempiere.ui.swing/src/org/compiere/acct/AcctViewerData.java b/org.adempiere.ui.swing/src/org/compiere/acct/AcctViewerData.java deleted file mode 100644 index 0d7826e0aa..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/acct/AcctViewerData.java +++ /dev/null @@ -1,550 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ -package org.compiere.acct; - -import java.sql.PreparedStatement; -import java.sql.ResultSet; -import java.sql.SQLException; -import java.sql.Statement; -import java.sql.Timestamp; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Iterator; -import java.util.Properties; -import java.util.logging.Level; - -import javax.swing.JComboBox; - -import static org.compiere.model.SystemIDs.*; -import org.compiere.model.MAcctSchema; -import org.compiere.model.MAcctSchemaElement; -import org.compiere.model.MFactAcct; -import org.compiere.model.MLookupFactory; -import org.compiere.model.MRefList; -import org.compiere.report.core.RColumn; -import org.compiere.report.core.RModel; -import org.compiere.util.CLogger; -import org.compiere.util.DB; -import org.compiere.util.DisplayType; -import org.compiere.util.Env; -import org.compiere.util.KeyNamePair; -import org.compiere.util.Language; -import org.compiere.util.Msg; -import org.compiere.util.ValueNamePair; - - -/** - * Account Viewer State - maintains State information for the Account Viewer - * - * @author Jorg Janke - * @version $Id: AcctViewerData.java,v 1.3 2006/08/10 01:00:27 jjanke Exp $ - * - * @author Teo Sarca, SC ARHIPAC SERVICE SRL - *
  • BF [ 1748449 ] Info Account - Posting Type is not translated - *
  • BF [ 1778373 ] AcctViewer: data is not sorted proper - */ -class AcctViewerData -{ - /** - * Constructor - * @param ctx context - * @param windowNo window no - * @param ad_Client_ID client - * @param ad_Table_ID table - */ - public AcctViewerData (Properties ctx, int windowNo, int ad_Client_ID, int ad_Table_ID) - { - WindowNo = windowNo; - AD_Client_ID = ad_Client_ID; - if (AD_Client_ID == 0) - AD_Client_ID = Env.getContextAsInt(Env.getCtx(), WindowNo, "AD_Client_ID"); - if (AD_Client_ID == 0) - AD_Client_ID = Env.getContextAsInt(Env.getCtx(), "AD_Client_ID"); - AD_Table_ID = ad_Table_ID; - // - ASchemas = MAcctSchema.getClientAcctSchema(ctx, AD_Client_ID); - ASchema = ASchemas[0]; - } // AcctViewerData - - /** Window */ - public int WindowNo; - /** Client */ - public int AD_Client_ID; - /** All Acct Schema */ - public MAcctSchema[] ASchemas = null; - /** This Acct Schema */ - public MAcctSchema ASchema = null; - - // Selection Info - /** Document Query */ - public boolean documentQuery = false; - /** Acct Schema */ - public int C_AcctSchema_ID = 0; - /** Posting Type */ - public String PostingType = ""; - /** Organization */ - public int AD_Org_ID = 0; - /** Date From */ - public Timestamp DateFrom = null; - /** Date To */ - public Timestamp DateTo = null; - - // Document Table Selection Info - /** Table ID */ - public int AD_Table_ID; - /** Record */ - public int Record_ID; - - /** Containing Column and Query */ - public HashMap whereInfo = new HashMap(); - /** Containing TableName and AD_Table_ID */ - public HashMap tableInfo = new HashMap(); - - // Display Info - /** Display Qty */ - boolean displayQty = false; - /** Display Source Currency */ - boolean displaySourceAmt = false; - /** Display Document info */ - boolean displayDocumentInfo = false; - // - String sortBy1 = ""; - String sortBy2 = ""; - String sortBy3 = ""; - String sortBy4 = ""; - // - boolean group1 = false; - boolean group2 = false; - boolean group3 = false; - boolean group4 = false; - - /** Leasing Columns */ - private int m_leadingColumns = 0; - /** UserElement1 Reference */ - private String m_ref1 = null; - /** UserElement2 Reference */ - private String m_ref2 = null; - /** Logger */ - private static CLogger log = CLogger.getCLogger(AcctViewerData.class); - - /** - * Dispose - */ - public void dispose() - { - ASchemas = null; - ASchema = null; - // - whereInfo.clear(); - whereInfo = null; - // - Env.clearWinContext(WindowNo); - } // dispose - - - /************************************************************************** - * Fill Accounting Schema - * @param cb JComboBox to be filled - */ - protected void fillAcctSchema (JComboBox cb) - { - for (int i = 0; i < ASchemas.length; i++) - cb.addItem(new KeyNamePair(ASchemas[i].getC_AcctSchema_ID(), - ASchemas[i].getName())); - } // fillAcctSchema - - /** - * Fill Posting Type - * @param cb JComboBox to be filled - */ - protected void fillPostingType (JComboBox cb) - { - int AD_Reference_ID = REFERENCE_POSTING_TYPE; - ValueNamePair[] pt = MRefList.getList(Env.getCtx(), AD_Reference_ID, true); - for (int i = 0; i < pt.length; i++) - cb.addItem(pt[i]); - } // fillPostingType - - /** - * Fill Table with - * ValueNamePair (TableName, translatedKeyColumnName) - * and tableInfo with (TableName, AD_Table_ID) - * and select the entry for AD_Table_ID - * - * @param cb JComboBox to be filled - */ - protected void fillTable (JComboBox cb) - { - ValueNamePair select = null; - // - String sql = "SELECT AD_Table_ID, TableName FROM AD_Table t " - + "WHERE EXISTS (SELECT * FROM AD_Column c" - + " WHERE t.AD_Table_ID=c.AD_Table_ID AND c.ColumnName='Posted')" - + " AND IsView='N'"; - PreparedStatement pstmt = null; - ResultSet rs = null; - try - { - pstmt = DB.prepareStatement(sql, null); - rs = pstmt.executeQuery(); - while (rs.next()) - { - int id = rs.getInt(1); - String tableName = rs.getString(2); - String name = Msg.translate(Env.getCtx(), tableName+"_ID"); - // - ValueNamePair pp = new ValueNamePair(tableName, name); - cb.addItem(pp); - tableInfo.put (tableName, Integer.valueOf(id)); - if (id == AD_Table_ID) - select = pp; - } - } - catch (SQLException e) - { - log.log(Level.SEVERE, sql, e); - } - finally - { - DB.close(rs, pstmt); - rs = null; - pstmt = null; - } - if (select != null) - cb.setSelectedItem(select); - } // fillTable - - /** - * Fill Org - * - * @param cb JComboBox to be filled - */ - protected void fillOrg (JComboBox cb) - { - KeyNamePair pp = new KeyNamePair(0, ""); - cb.addItem(pp); - String sql = "SELECT AD_Org_ID, Name FROM AD_Org WHERE AD_Client_ID=? ORDER BY Value"; - PreparedStatement pstmt = null; - ResultSet rs = null; - try - { - pstmt = DB.prepareStatement(sql, null); - pstmt.setInt(1, AD_Client_ID); - rs = pstmt.executeQuery(); - while (rs.next()) - cb.addItem(new KeyNamePair(rs.getInt(1), rs.getString(2))); - } - catch (SQLException e) - { - log.log(Level.SEVERE, sql, e); - } - finally - { - DB.close(rs,pstmt); - rs = null; - pstmt = null; - } - } // fillOrg - - /** - * Get Button Text - * - * @param tableName table - * @param columnName column - * @param selectSQL sql - * @return Text on button - */ - protected String getButtonText (String tableName, String columnName, String selectSQL) - { - // SELECT () FROM tableName avd WHERE avd. - StringBuilder sql = new StringBuilder ("SELECT ("); - Language language = Env.getLanguage(Env.getCtx()); - sql.append(MLookupFactory.getLookup_TableDirEmbed(language, columnName, "avd")) - .append(") FROM ").append(tableName).append(" avd WHERE avd.").append(selectSQL); - String retValue = "<" + selectSQL + ">"; - Statement stmt = null; - ResultSet rs = null; - try - { - stmt = DB.createStatement(); - rs = stmt.executeQuery(sql.toString()); - if (rs.next()) - retValue = rs.getString(1); - } - catch (SQLException e) - { - log.log(Level.SEVERE, sql.toString(), e); - } - finally - { - DB.close(rs, stmt); - rs = null; - stmt = null; - } - return retValue; - } // getButtonText - - /************************************************************************** - - /** - * Create Query and submit - * @return Report Model - */ - protected RModel query() - { - // Set Where Clause - StringBuilder whereClause = new StringBuilder(); - // Add Organization - if (C_AcctSchema_ID != 0) - whereClause.append(RModel.TABLE_ALIAS) - .append(".C_AcctSchema_ID=").append(C_AcctSchema_ID); - - // Posting Type Selected - if (PostingType != null && PostingType.length() > 0) - { - if (whereClause.length() > 0) - whereClause.append(" AND "); - whereClause.append(RModel.TABLE_ALIAS) - .append(".PostingType='").append(PostingType).append("'"); - } - - // - if (documentQuery) - { - if (whereClause.length() > 0) - whereClause.append(" AND "); - whereClause.append(RModel.TABLE_ALIAS).append(".AD_Table_ID=").append(AD_Table_ID) - .append(" AND ").append(RModel.TABLE_ALIAS).append(".Record_ID=").append(Record_ID); - } - else - { - // get values (Queries) - Iterator it = whereInfo.values().iterator(); - while (it.hasNext()) - { - String where = (String)it.next(); - if (where != null && where.length() > 0) // add only if not empty - { - if (whereClause.length() > 0) - whereClause.append(" AND "); - whereClause.append(RModel.TABLE_ALIAS).append(".").append(where); - } - } - if (DateFrom != null || DateTo != null) - { - if (whereClause.length() > 0) - whereClause.append(" AND "); - if (DateFrom != null && DateTo != null) - whereClause.append("TRUNC(").append(RModel.TABLE_ALIAS).append(".DateAcct) BETWEEN ") - .append(DB.TO_DATE(DateFrom)).append(" AND ").append(DB.TO_DATE(DateTo)); - else if (DateFrom != null) - whereClause.append("TRUNC(").append(RModel.TABLE_ALIAS).append(".DateAcct) >= ") - .append(DB.TO_DATE(DateFrom)); - else // DateTo != null - whereClause.append("TRUNC(").append(RModel.TABLE_ALIAS).append(".DateAcct) <= ") - .append(DB.TO_DATE(DateTo)); - } - // Add Organization - if (AD_Org_ID != 0) - { - if (whereClause.length() > 0) - whereClause.append(" AND "); - whereClause.append(RModel.TABLE_ALIAS).append(".AD_Org_ID=").append(AD_Org_ID); - } - } - - RModel rm = getRModel(); - - // Set Order By Clause - StringBuilder orderClause = new StringBuilder(); - if (sortBy1.length() > 0) - { - RColumn col = rm.getRColumn(sortBy1); - if (col != null) - orderClause.append(col.getDisplaySQL()); - else - orderClause.append(RModel.TABLE_ALIAS).append(".").append(sortBy1); - } - if (sortBy2.length() > 0) - { - if (orderClause.length() > 0) - orderClause.append(","); - RColumn col = rm.getRColumn(sortBy2); - if (col != null) - orderClause.append(col.getDisplaySQL()); - else - orderClause.append(RModel.TABLE_ALIAS).append(".").append(sortBy2); - } - if (sortBy3.length() > 0) - { - if (orderClause.length() > 0) - orderClause.append(","); - RColumn col = rm.getRColumn(sortBy3); - if (col != null) - orderClause.append(col.getDisplaySQL()); - else - orderClause.append(RModel.TABLE_ALIAS).append(".").append(sortBy3); - } - if (sortBy4.length() > 0) - { - if (orderClause.length() > 0) - orderClause.append(","); - RColumn col = rm.getRColumn(sortBy4); - if (col != null) - orderClause.append(col.getDisplaySQL()); - else - orderClause.append(RModel.TABLE_ALIAS).append(".").append(sortBy4); - } - if (orderClause.length() == 0) - orderClause.append(RModel.TABLE_ALIAS).append(".Fact_Acct_ID"); - - // Groups - if (group1 && sortBy1.length() > 0) - rm.setGroup(sortBy1); - if (group2 && sortBy2.length() > 0) - rm.setGroup(sortBy2); - if (group3 && sortBy3.length() > 0) - rm.setGroup(sortBy3); - if (group4 && sortBy4.length() > 0) - rm.setGroup(sortBy4); - - // Totals - rm.setFunction("AmtAcctDr", RModel.FUNCTION_SUM); - rm.setFunction("AmtAcctCr", RModel.FUNCTION_SUM); - - rm.query (Env.getCtx(), whereClause.toString(), orderClause.toString()); - - return rm; - } // query - - /** - * Create Report Model (Columns) - * @return Report Model - */ - private RModel getRModel() - { - Properties ctx = Env.getCtx(); - RModel rm = new RModel("Fact_Acct"); - // Add Key (Lookups) - ArrayList keys = createKeyColumns(); - int max = m_leadingColumns; - if (max == 0) - max = keys.size(); - for (int i = 0; i < max; i++) - { - String column = (String)keys.get(i); - if (column != null && column.startsWith("Date")) - rm.addColumn(new RColumn(ctx, column, DisplayType.Date)); - else if (column != null && column.endsWith("_ID")) - rm.addColumn(new RColumn(ctx, column, DisplayType.TableDir)); - } - // Main Info - rm.addColumn(new RColumn(ctx, "AmtAcctDr", DisplayType.Amount)); - rm.addColumn(new RColumn(ctx, "AmtAcctCr", DisplayType.Amount)); - if (displaySourceAmt) - { - if (!keys.contains("DateTrx")) - rm.addColumn(new RColumn(ctx, "DateTrx", DisplayType.Date)); - rm.addColumn(new RColumn(ctx, "C_Currency_ID", DisplayType.TableDir)); - rm.addColumn(new RColumn(ctx, "AmtSourceDr", DisplayType.Amount)); - rm.addColumn(new RColumn(ctx, "AmtSourceCr", DisplayType.Amount)); - rm.addColumn(new RColumn(ctx, "Rate", DisplayType.Amount, - "CASE WHEN (AmtSourceDr + AmtSourceCr) = 0 THEN 0" - + " ELSE (AmtAcctDr + AmtAcctCr) / (AmtSourceDr + AmtSourceCr) END")); - } - // Remaining Keys - for (int i = max; i < keys.size(); i++) - { - String column = (String)keys.get(i); - if (column != null && column.startsWith("Date")) - rm.addColumn(new RColumn(ctx, column, DisplayType.Date)); - else if (column.startsWith("UserElement")) - { - if (column.indexOf('1') != -1) - rm.addColumn(new RColumn(ctx, column, DisplayType.TableDir, null, 0, m_ref1)); - else - rm.addColumn(new RColumn(ctx, column, DisplayType.TableDir, null, 0, m_ref2)); - } - else if (column != null && column.endsWith("_ID")) - rm.addColumn(new RColumn(ctx, column, DisplayType.TableDir)); - } - // Info - if (!keys.contains("DateAcct")) - rm.addColumn(new RColumn(ctx, "DateAcct", DisplayType.Date)); - if (!keys.contains("C_Period_ID")) - rm.addColumn(new RColumn(ctx, "C_Period_ID", DisplayType.TableDir)); - if (displayQty) - { - rm.addColumn(new RColumn(ctx, "C_UOM_ID", DisplayType.TableDir)); - rm.addColumn(new RColumn(ctx, "Qty", DisplayType.Quantity)); - } - if (displayDocumentInfo) - { - rm.addColumn(new RColumn(ctx, "AD_Table_ID", DisplayType.TableDir)); - rm.addColumn(new RColumn(ctx, "Record_ID", DisplayType.ID)); - rm.addColumn(new RColumn(ctx, "Description", DisplayType.String)); - } - if (PostingType == null || PostingType.length() == 0) - rm.addColumn(new RColumn(ctx, "PostingType", DisplayType.List, // teo_sarca, [ 1664208 ] - RModel.TABLE_ALIAS+".PostingType", - MFactAcct.POSTINGTYPE_AD_Reference_ID, - null)); - return rm; - } // createRModel - - /** - * Create the key columns in sequence - * @return List of Key Columns - */ - private ArrayList createKeyColumns() - { - ArrayList columns = new ArrayList(); - m_leadingColumns = 0; - // Sorting Fields - columns.add(sortBy1); // may add "" - if (!columns.contains(sortBy2)) - columns.add(sortBy2); - if (!columns.contains(sortBy3)) - columns.add(sortBy3); - if (!columns.contains(sortBy4)) - columns.add(sortBy4); - - // Add Account Segments - MAcctSchemaElement[] elements = ASchema.getAcctSchemaElements(); - for (int i = 0; i < elements.length; i++) - { - if (m_leadingColumns == 0 && columns.contains("AD_Org_ID") && columns.contains("Account_ID")) - m_leadingColumns = columns.size(); - // - MAcctSchemaElement ase = elements[i]; - String columnName = ase.getColumnName(); - if (columnName.startsWith("UserElement")) - { - if (columnName.indexOf('1') != -1) - m_ref1 = ase.getDisplayColumnName(); - else - m_ref2 = ase.getDisplayColumnName(); - } - if (!columns.contains(columnName)) - columns.add(columnName); - } - if (m_leadingColumns == 0 && columns.contains("AD_Org_ID") && columns.contains("Account_ID")) - m_leadingColumns = columns.size(); - return columns; - } // createKeyColumns - -} // AcctViewerData diff --git a/org.adempiere.ui.swing/src/org/compiere/acct/package.html b/org.adempiere.ui.swing/src/org/compiere/acct/package.html deleted file mode 100644 index 9f32648211..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/acct/package.html +++ /dev/null @@ -1,30 +0,0 @@ - - - - - - - -

    Package org.compiere.acct

    - -Provide viewer for the viewing of account posting records. - -

    Related Documentation

    - -For overviews, tutorials, examples, guides, and tool documentation, please see: - - - - - - diff --git a/org.adempiere.ui.swing/src/org/compiere/apps/AArchive.java b/org.adempiere.ui.swing/src/org/compiere/apps/AArchive.java deleted file mode 100644 index eeaa5b368f..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/apps/AArchive.java +++ /dev/null @@ -1,187 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ -package org.compiere.apps; - -import java.awt.GraphicsConfiguration; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.sql.PreparedStatement; -import java.sql.ResultSet; -import java.util.logging.Level; - -import javax.swing.JComponent; -import javax.swing.JPopupMenu; - -import org.compiere.apps.form.ArchiveViewer; -import org.compiere.apps.form.FormFrame; -import org.compiere.model.MBPartner; -import static org.compiere.model.SystemIDs.*; -import org.compiere.swing.CMenuItem; -import org.compiere.util.CLogger; -import org.compiere.util.DB; -import org.compiere.util.Env; -import org.compiere.util.Msg; - - -/** - * Archive Button Consequences. - * Popup Menu - * - * @author Jorg Janke - * @version $Id: AArchive.java,v 1.2 2006/07/30 00:51:27 jjanke Exp $ - */ -public class AArchive implements ActionListener -{ - /** - * Constructor - * @param invoker button - * @param AD_Table_ID table - * @param Record_ID record - */ - public AArchive (JComponent invoker, int AD_Table_ID, int Record_ID) - { - super (); - if (log.isLoggable(Level.CONFIG)) log.config("AD_Table_ID=" + AD_Table_ID + ", Record_ID=" + Record_ID); - m_AD_Table_ID = AD_Table_ID; - m_Record_ID = Record_ID; - getArchives(invoker); - } // AArchive - - /** The Table */ - private int m_AD_Table_ID; - /** The Record */ - private int m_Record_ID; - - /** The Popup */ - private JPopupMenu m_popup = new JPopupMenu("ArchiveMenu"); - private CMenuItem m_reports = null; - private CMenuItem m_reportsAll = null; - private CMenuItem m_documents = null; - /** Where Clause */ - StringBuffer m_where = null; - private GraphicsConfiguration m_graphicsconfig = null; - - /** Logger */ - private static CLogger log = CLogger.getCLogger (AArchive.class); - - /** - * Display Request Options - New/Existing. - * @param invoker button - */ - private void getArchives (JComponent invoker) - { - int reportCount = 0; - int documentCount = 0; - - m_where = new StringBuffer(); - m_where.append("(AD_Table_ID=").append(m_AD_Table_ID) - .append(" AND Record_ID=").append(m_Record_ID) - .append(")"); - // Get all for BP - if (m_AD_Table_ID == MBPartner.Table_ID) - m_where.append(" OR C_BPartner_ID=").append(m_Record_ID); - // - StringBuffer sql = new StringBuffer("SELECT IsReport, COUNT(*) FROM AD_Archive ") - .append("WHERE (AD_Table_ID=? AND Record_ID=?) "); - if (m_AD_Table_ID == MBPartner.Table_ID) - sql.append(" OR C_BPartner_ID=?"); - sql.append(" GROUP BY IsReport"); - PreparedStatement pstmt = null; - ResultSet rs = null; - try - { - pstmt = DB.prepareStatement (sql.toString(), null); - pstmt.setInt(1, m_AD_Table_ID); - pstmt.setInt(2, m_Record_ID); - if (m_AD_Table_ID == MBPartner.Table_ID) - pstmt.setInt(3, m_Record_ID); - rs = pstmt.executeQuery (); - while (rs.next ()) - { - if ("Y".equals(rs.getString(1))) - reportCount += rs.getInt(2); - else - documentCount += rs.getInt(2); - } - } - catch (Exception e) - { - log.log(Level.SEVERE, sql.toString(), e); - } - finally - { - DB.close(rs, pstmt); - rs = null; pstmt = null; - } - - // - if (documentCount > 0) - { - m_documents = new CMenuItem(Msg.getMsg(Env.getCtx(), "ArchivedDocuments") - + " (" + documentCount + ")"); - m_popup.add(m_documents).addActionListener(this); - } - if (reportCount > 0) - { - m_reports = new CMenuItem(Msg.getMsg(Env.getCtx(), "ArchivedReports") - + " (" + reportCount + ")"); - m_popup.add(m_reports).addActionListener(this); - } - // All Reports - String sql1 = "SELECT COUNT(*) FROM AD_Archive WHERE AD_Table_ID=? AND IsReport='Y'"; - int allReports = DB.getSQLValue(null, sql1, m_AD_Table_ID); - if (allReports > 0) - { - m_reportsAll = new CMenuItem(Msg.getMsg(Env.getCtx(), "ArchivedReportsAll") - + " (" + reportCount + ")"); - m_popup.add(m_reportsAll).addActionListener(this); - } - - if (documentCount == 0 && reportCount == 0 && allReports == 0) - m_popup.add(Msg.getMsg(Env.getCtx(), "ArchivedNone")); - - m_graphicsconfig = invoker.getGraphicsConfiguration(); - // - if (invoker.isShowing()) - m_popup.show(invoker, 0, invoker.getHeight()); // below button - } // getZoomTargets - - /** - * Listner - * @param e event - */ - public void actionPerformed (ActionEvent e) - { - int AD_Form_ID = FORM_ARCHIVEVIEWER; // ArchiveViewer - FormFrame ff = new FormFrame(m_graphicsconfig); - ff.openForm(AD_Form_ID); - ArchiveViewer av = (ArchiveViewer)ff.getFormPanel(); - // - if (e.getSource() == m_documents) - av.query(false, m_AD_Table_ID, m_Record_ID); - else if (e.getSource() == m_reports) - av.query(true, m_AD_Table_ID, m_Record_ID); - else // all Reports - av.query(true, m_AD_Table_ID, 0); - // - AEnv.addToWindowManager(ff); - ff.pack(); - AEnv.showCenterScreen(ff); - ff = null; - } // actionPerformed - -} // AArchive diff --git a/org.adempiere.ui.swing/src/org/compiere/apps/AChat.java b/org.adempiere.ui.swing/src/org/compiere/apps/AChat.java deleted file mode 100644 index 636b4e36e7..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/apps/AChat.java +++ /dev/null @@ -1,169 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ -package org.compiere.apps; - -import java.awt.BorderLayout; -import java.awt.Dimension; -import java.awt.Frame; -import java.awt.Insets; -import java.awt.event.ActionEvent; -import java.util.logging.Level; - -import javax.swing.JSplitPane; - -import org.compiere.model.MChat; -import org.compiere.model.MChatEntry; -import org.compiere.swing.CDialog; -import org.compiere.swing.CPanel; -import org.compiere.swing.CTextArea; -import org.compiere.swing.CTextPane; -import org.compiere.util.CLogger; -import org.compiere.util.Env; -import org.compiere.util.Msg; - -/** - * Application Chat - * - * @author Jorg Janke - * @version $Id: AChat.java,v 1.3 2006/07/30 00:51:27 jjanke Exp $ - */ -public class AChat extends CDialog -{ - /** - * - */ - private static final long serialVersionUID = -8555071848521981730L; - - /** - * Constructor. - * loads Chat, if ID <> 0 - * @param frame frame - * @param WindowNo window no - * @param CM_Chat_ID chat - * @param AD_Table_ID table - * @param Record_ID record key - * @param Description description - * @param trxName transaction - */ - public AChat (Frame frame, int WindowNo, int CM_Chat_ID, - int AD_Table_ID, int Record_ID, String Description, - String trxName) - { - super (frame, Msg.getMsg(Env.getCtx(), "Chat") + " " + Description, true); - // needs to be modal otherwise APanel does not recongize change. - if (log.isLoggable(Level.CONFIG)) log.config("ID=" + CM_Chat_ID - + ", Table=" + AD_Table_ID + ", Record=" + Record_ID); - // - m_WindowNo = WindowNo; - // - try - { - staticInit(); - } - catch (Exception ex) - { - log.log(Level.SEVERE, "", ex); - } - // Create Model - if (CM_Chat_ID > 0) - m_chat = new MChat (Env.getCtx(), CM_Chat_ID, trxName); - else - m_chat = new MChat (Env.getCtx(), AD_Table_ID, Record_ID, Description, trxName); - loadChat(); - // - try - { - AEnv.showCenterWindow(frame, this); - } - catch (Exception e) - { - } - newText.requestFocus(); - } // Attachment - - /** Window No */ - @SuppressWarnings("unused") - private int m_WindowNo; - /** Attachment */ - private MChat m_chat; - /** Change */ - //private boolean m_change = false; - /** Logger */ - private static CLogger log = CLogger.getCLogger(AChat.class); - - private CPanel mainPanel = new CPanel(new BorderLayout(5,5)); - private CTextPane historyText = new CTextPane(); - private CTextArea newText = new CTextArea(); - private ConfirmPanel confirmPanel = new ConfirmPanel(true); - - /** - * Static Init. - * @throws Exception - */ - private void staticInit () throws Exception - { - this.getContentPane().add(mainPanel); - // - historyText.setPreferredSize(new Dimension(350,300)); - historyText.setReadWrite(false); - historyText.setMargin(new Insets(2,2,2,2)); - newText.setPreferredSize(new Dimension(350,200)); - newText.setMargin(new Insets(2,2,2,2)); - // - JSplitPane textPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, true, - historyText, newText); - mainPanel.add(textPane, BorderLayout.CENTER); - - //TODO Confidentiality - - // South - mainPanel.add(confirmPanel, BorderLayout.SOUTH); - confirmPanel.addActionListener(this); - } // staticInit - - /** - * Load Chat - */ - private void loadChat() - { - String text = m_chat.getHistory(MChat.CONFIDENTIALTYPE_Internal).toString(); - historyText.setText(text); - } // loadChat - - - /** - * Action Performed - * @param e event - */ - public void actionPerformed (ActionEvent e) - { - if (e.getActionCommand().equals(ConfirmPanel.A_OK)) - { - String data = newText.getText(); - if (data != null && data.length() > 0) - { - log.config(data); - if (m_chat.get_ID() == 0) - m_chat.saveEx(); - MChatEntry entry = new MChatEntry(m_chat, data); - entry.saveEx(); - } // data to be saved - } - dispose(); - } // actionPerformed - -} // AChat diff --git a/org.adempiere.ui.swing/src/org/compiere/apps/ADialog.java b/org.adempiere.ui.swing/src/org/compiere/apps/ADialog.java deleted file mode 100644 index fc5a7356a9..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/apps/ADialog.java +++ /dev/null @@ -1,485 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ -package org.compiere.apps; - -import java.awt.Container; -import java.awt.Dialog; -import java.awt.Frame; -import java.awt.Toolkit; -import java.awt.Window; -import java.util.Properties; -import java.util.logging.Level; - -import javax.swing.JDialog; -import javax.swing.JFrame; -import javax.swing.JOptionPane; - -import org.compiere.Adempiere; -import org.compiere.model.MUser; -import org.compiere.model.ModelValidationEngine; -import org.compiere.util.CLogMgt; -import org.compiere.util.CLogger; -import org.compiere.util.Env; -import org.compiere.util.Msg; -import org.compiere.util.Trace; -import org.compiere.util.Util; - -/** - * Info Dialog Management - * - * @author Jorg Janke - * @version $Id: ADialog.java,v 1.2 2006/07/30 00:51:27 jjanke Exp $ - */ - -public final class ADialog -{ - /** Show ADialogADialog - if false use JOptionPane */ - public static boolean showDialog = true; - /** Logger */ - private static CLogger log = CLogger.getCLogger(ADialog.class); - - /** - * Show plain message - * @param WindowNo Number of Window - * @param c Container (owner) - * @param clearHeading Translated Title of window - * @param clearMessage Translated message - * @param clearText Additional message - */ - public static void info (int WindowNo, Container c, String clearHeading, String clearMessage, String clearText) - { - if (log.isLoggable(Level.INFO)) log.info(clearHeading - + ": " + clearMessage + " " + clearText); - String out = clearMessage; - if (clearText != null && !clearText.equals("")) - out += "\n" + clearText; - // - Window parent = Env.getParent(c); - if (parent == null) - parent = AEnv.getWindow(WindowNo); - // - if (showDialog && parent != null) - { - if (parent instanceof JFrame) - new ADialogDialog ((JFrame)parent, - clearHeading, - out, - JOptionPane.INFORMATION_MESSAGE); - else - new ADialogDialog ((JDialog)parent, - clearHeading, - out, - JOptionPane.INFORMATION_MESSAGE); - } - else - JOptionPane.showMessageDialog(parent, - out + "\n", // message - clearHeading, // title - JOptionPane.INFORMATION_MESSAGE); - } // info - - /** - * Show message with info icon - * @param WindowNo Number of Window - * @param c Container (owner) - * @param AD_Message Message to be translated - * @param msg Additional message - */ - public static void info (int WindowNo, Container c, String AD_Message, String msg) - { - if (log.isLoggable(Level.INFO)) log.info(AD_Message + " - " + msg); - Properties ctx = Env.getCtx(); - StringBuilder out = new StringBuilder(); - if (AD_Message != null && !AD_Message.equals("")) - out.append(Msg.getMsg(ctx, AD_Message)); - if (msg != null && msg.length() > 0) - out.append("\n").append(msg); - // - Window parent = Env.getParent(c); - if (parent == null) - parent = AEnv.getWindow(WindowNo); - // - if (showDialog && parent != null) - { - if (parent instanceof JFrame) - new ADialogDialog ((JFrame)parent, - Env.getHeader(ctx, WindowNo), - out.toString(), - JOptionPane.INFORMATION_MESSAGE); - else - new ADialogDialog ((JDialog)parent, - Env.getHeader(ctx, WindowNo), - out.toString(), - JOptionPane.INFORMATION_MESSAGE); - } - else - JOptionPane.showMessageDialog(parent, - out.toString() + "\n", // message - Env.getHeader(ctx, WindowNo), // title - JOptionPane.INFORMATION_MESSAGE); - } // info - - /** - * Show message with info icon - * @param WindowNo Number of Window - * @param c Container (owner) - * @param AD_Message Message to be translated - */ - public static void info (int WindowNo, Container c, String AD_Message) - { - info (WindowNo, c, AD_Message, null); - } // info - - - /************************************************************************** - * Display warning with warning icon - * @param WindowNo Number of Window - * @param c Container (owner) - * @param AD_Message Message to be translated - * @param msg Additional message - */ - public static void warn (int WindowNo, Container c, String AD_Message, String msg) - { - if (log.isLoggable(Level.INFO)) log.info(AD_Message + " - " + msg); - Properties ctx = Env.getCtx(); - StringBuilder out = new StringBuilder(); - if (AD_Message != null && !AD_Message.equals("")) - out.append(Msg.getMsg(ctx, AD_Message)); - if (msg != null && msg.length() > 0) - out.append("\n").append(msg); - // - Window parent = Env.getParent(c); - if (parent == null) - parent = AEnv.getWindow(WindowNo); - // - if (showDialog && parent != null) - { - if (parent instanceof JFrame) - new ADialogDialog ((JFrame)parent, - Env.getHeader(ctx, WindowNo), - out.toString(), - JOptionPane.WARNING_MESSAGE); - else - new ADialogDialog ((JDialog)parent, - Env.getHeader(ctx, WindowNo), - out.toString(), - JOptionPane.WARNING_MESSAGE); - } - else - JOptionPane.showMessageDialog(parent, - out.toString() + "\n", // message - Env.getHeader(ctx, WindowNo), // title - JOptionPane.WARNING_MESSAGE); - } // warn (int, String) - - /** - * Display warning with warning icon - * @param WindowNo Number of Window - * @param c Container (owner) - * @param AD_Message Message to be translated - */ - public static void warn (int WindowNo, Container c, String AD_Message) - { - warn (WindowNo, c, AD_Message, null); - } // warn (int, String) - - - /************************************************************************** - * Display error with error icon - * @param WindowNo Number of Window - * @param c Container (owner) - * @param AD_Message Message to be translated - * @param msg Additional message - */ - public static void error (int WindowNo, Container c, String AD_Message, String msg) - { - if (log.isLoggable(Level.INFO)) log.info(AD_Message + " - " + msg); - if (CLogMgt.isLevelFinest()) - Trace.printStack(); - Properties ctx = Env.getCtx(); - StringBuilder out = new StringBuilder(); - if (AD_Message != null && !AD_Message.equals("")) - out.append(Msg.getMsg(ctx, AD_Message)); - if (msg != null && msg.length() > 0) - out.append("\n").append(msg); - // - Window parent = Env.getParent(c); - if (parent == null) - parent = AEnv.getWindow(WindowNo); - // - if (showDialog && parent != null) - { - if (parent instanceof JFrame) - new ADialogDialog ((JFrame)parent, - Env.getHeader(ctx, WindowNo), - out.toString(), - JOptionPane.ERROR_MESSAGE); - else if (parent instanceof JDialog) - new ADialogDialog ((JDialog)parent, - Env.getHeader(ctx, WindowNo), - out.toString(), - JOptionPane.ERROR_MESSAGE); - } - else - JOptionPane.showMessageDialog(AEnv.getWindow(WindowNo), - out.toString() + "\n", // message - Env.getHeader(ctx, WindowNo), // title - JOptionPane.ERROR_MESSAGE); - } // error (int, String) - - /** - * Display error with error icon - * @param WindowNo Number of Window - * @param c Container (owner) - * @param AD_Message Message to be translated - */ - public static void error (int WindowNo, Container c, String AD_Message) - { - error (WindowNo, c, AD_Message, null); - } // error (int, String) - - - /************************************************************************** - * Ask Question with question icon and (OK) (Cancel) buttons - * @param WindowNo Number of Window - * @param c Container (owner) - * @param AD_Message Message to be translated - * @param msg Additional clear text message - * @return true, if OK - */ - public static boolean ask (int WindowNo, Container c, String AD_Message, String msg) - { - if (log.isLoggable(Level.INFO)) log.info(AD_Message + " - " + msg); - Properties ctx = Env.getCtx(); - StringBuilder out = new StringBuilder(); - if (AD_Message != null && !AD_Message.equals("")) - out.append(Msg.getMsg(ctx, AD_Message)); - if (msg != null && msg.length() > 0) - out.append("\n").append(msg); - // - Window parent = Env.getParent(c); - if (parent == null) - parent = AEnv.getWindow(WindowNo); - - boolean retValue = false; - if (showDialog && parent != null) - { - if (parent instanceof JFrame) - { - ADialogDialog d = new ADialogDialog ((JFrame)parent, - Env.getHeader(ctx, WindowNo), - out.toString(), - JOptionPane.QUESTION_MESSAGE); - retValue = d.getReturnCode() == ADialogDialog.A_OK; - } - else - { - ADialogDialog d = new ADialogDialog ((JDialog)parent, - Env.getHeader(ctx, WindowNo), - out.toString(), - JOptionPane.QUESTION_MESSAGE); - retValue = d.getReturnCode() == ADialogDialog.A_OK; - } - } - else - { - Object[] optionsOC = {Util.cleanAmp(Msg.getMsg(ctx, "OK")), Util.cleanAmp(Msg.getMsg(ctx, "Cancel"))}; - int i = JOptionPane.showOptionDialog(parent, - out.toString() + "\n", // message - Env.getHeader(ctx, WindowNo), // title - JOptionPane.DEFAULT_OPTION, - JOptionPane.QUESTION_MESSAGE, - null, - optionsOC, - optionsOC[0]); - retValue = i == JOptionPane.YES_OPTION; - } - return retValue; - } // ask - - /** - * Ask Question with question icon and (OK) (Cancel) buttons - * @param WindowNo Number of Window - * @param c Container (owner) - * @param AD_Message Message to be translated - * @return true, if OK - */ - public static boolean ask (int WindowNo, Container c, String AD_Message) - { - return ask (WindowNo, c, AD_Message, null); - } // ask - - public static String askForInput(int WindowNo, Container c, String AD_Message) { - if (log.isLoggable(Level.INFO)) log.info(AD_Message); - Properties ctx = Env.getCtx(); - StringBuilder out = new StringBuilder(); - if (AD_Message != null && !AD_Message.equals("")) - out.append(Msg.getMsg(ctx, AD_Message)); - - // - Window parent = Env.getParent(c); - if (parent == null) - parent = AEnv.getWindow(WindowNo); - - String retValue = null; - if (parent != null) - { - if (parent instanceof JFrame) - { - ADialogDialog d = new ADialogDialog ((JFrame)parent, - Env.getHeader(ctx, WindowNo), - out.toString(), - ADialogDialog.INPUT_MESSAGE); - retValue = d.getReturnMsg(); - } - else - { - ADialogDialog d = new ADialogDialog ((JDialog)parent, - Env.getHeader(ctx, WindowNo), - out.toString(), - ADialogDialog.INPUT_MESSAGE); - retValue = d.getReturnMsg(); - } - } - return retValue; - } - - /************************************************************************** - * Display parsed development info Message string - * @param WindowNo Number of parent window (if zero, no parent window) - * @param c Container (owner) - * @param ParseString String to be parsed - */ - public static void clear (int WindowNo, Container c, String ParseString) - { - if (log.isLoggable(Level.INFO)) log.info( "Dialog.clear: " + ParseString); - Properties ctx = Env.getCtx(); - String parse = Env.parseContext(ctx, WindowNo, ParseString, false); - if (parse.length() == 0) - parse = "ERROR parsing: " + ParseString; - // - Window parent = Env.getParent(c); - if (parent == null) - parent = AEnv.getWindow(WindowNo); - // - if (showDialog && parent != null) - { - if (parent instanceof JFrame) - new ADialogDialog ((JFrame)parent, - Env.getHeader(ctx, WindowNo), - "=> " + parse, - JOptionPane.INFORMATION_MESSAGE); - else - new ADialogDialog ((JDialog)parent, - Env.getHeader(ctx, WindowNo), - "=> " + parse, - JOptionPane.INFORMATION_MESSAGE); - } - else - JOptionPane.showMessageDialog(parent, - "=> " + parse + "\n", // message - Env.getHeader(ctx, WindowNo), // title - JOptionPane.INFORMATION_MESSAGE); - } // clear - - - /** - * Display parsed development info Message string if condition is true - * @param WindowNo Number of parent window (if zero, no parent window) - * @param c Container (owner) - * @param ParseString Parsed Message - * @param condition to print must be true and debugging enabled - */ - public static void clear (int WindowNo, Container c, String ParseString, boolean condition) - { - if (!condition) - return; - clear(WindowNo, c, ParseString); - if (WindowNo == 0) - log.log(Level.SEVERE, "WIndowNo == 0"); - } // clear - - /** - * Display parsed development info Message string - * @param ParseString String to be parsed - * @deprecated - */ - public static void clear (String ParseString) - { - clear(0, null, ParseString); - } // clear - - /************************************************************************* - - /** - * Create Support EMail - * @param owner owner - * @param subject subkect - * @param message message - */ - public static void createSupportEMail(Dialog owner, String subject, String message) - { - log.config( "ADialog.createSupportEMail"); - String to = Adempiere.getSupportEMail(); - MUser from = MUser.get(Env.getCtx(), Env.getAD_User_ID(Env.getCtx())); - // - StringBuffer myMessage = new StringBuffer(message); - myMessage.append("\n"); - CLogMgt.getInfo(myMessage); - CLogMgt.getInfoDetail(myMessage, Env.getCtx()); - ModelValidationEngine.get().getInfoDetail(myMessage, Env.getCtx()); // teo_sarca - FR [ 1724662 ] - - @SuppressWarnings("unused") - EMailDialog emd = new EMailDialog(owner, - Msg.getMsg(Env.getCtx(), "EMailSupport"), - from, to, "Support: " + subject, myMessage.toString(), null); - } // createEmail - - /** - * Create Support EMail - * @param owner owner - * @param subject subkect - * @param message message - */ - public static void createSupportEMail(Frame owner, String subject, String message) - { - log.config( "ADialog.createSupportEMail"); - String to = Adempiere.getSupportEMail(); - MUser from = MUser.get(Env.getCtx(), Env.getAD_User_ID(Env.getCtx())); - // - StringBuffer myMessage = new StringBuffer(message); - myMessage.append("\n"); - CLogMgt.getInfo(myMessage); - CLogMgt.getInfoDetail(myMessage, Env.getCtx()); - ModelValidationEngine.get().getInfoDetail(myMessage, Env.getCtx()); // teo_sarca - FR [ 1724662 ] - - @SuppressWarnings("unused") - EMailDialog emd = new EMailDialog(owner, - Msg.getMsg(Env.getCtx(), "EMailSupport"), - from, to, "Support: " + subject, myMessage.toString(), null); - } // createEmail - - - /************************************************************************** - * Beep - */ - public static void beep() - { - Toolkit.getDefaultToolkit().beep(); - } // beep - -} // Dialog diff --git a/org.adempiere.ui.swing/src/org/compiere/apps/ADialogDialog.java b/org.adempiere.ui.swing/src/org/compiere/apps/ADialogDialog.java deleted file mode 100644 index 0900121fc7..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/apps/ADialogDialog.java +++ /dev/null @@ -1,359 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ -package org.compiere.apps; - -import java.awt.BorderLayout; -import java.awt.Dialog; -import java.awt.Dimension; -import java.awt.Frame; -import java.awt.GridBagConstraints; -import java.awt.GridBagLayout; -import java.awt.Insets; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.awt.event.KeyEvent; -import java.awt.event.WindowEvent; -import java.util.logging.Level; - -import javax.swing.Icon; -import javax.swing.JMenu; -import javax.swing.JMenuBar; -import javax.swing.JOptionPane; -import javax.swing.KeyStroke; - -import org.compiere.model.MRole; -import org.compiere.swing.CDialog; -import org.compiere.swing.CLabel; -import org.compiere.swing.CMenuItem; -import org.compiere.swing.CPanel; -import org.compiere.swing.CTextField; -import org.compiere.swing.CTextPane; -import org.compiere.util.CLogger; -import org.compiere.util.Env; -import org.compiere.util.Msg; -import org.compiere.util.Util; - -/** - * Dialog Windows - * - * @author Jorg Janke - * @version $Id: ADialogDialog.java,v 1.2 2006/07/30 00:51:27 jjanke Exp $ - */ -public final class ADialogDialog extends CDialog implements ActionListener -{ - /** - * - */ - private static final long serialVersionUID = 5670261006862936363L; - - public static final int INPUT_MESSAGE = 4; - /** - * Create Dialog Window for Frame - * - * @param frame - * @param title - * @param message - * @param messageType - */ - public ADialogDialog(Frame frame, String title, String message, int messageType) - { - super (frame, title, frame != null); - common (message, messageType); - AEnv.showCenterWindow(frame, this); - } // ADialogDialog - - /** - * Create Dialog Window for Dialog - * - * @param dialog - * @param title - * @param message - * @param messageType - */ - public ADialogDialog(Dialog dialog, String title, String message, int messageType) - { - super (dialog, title, dialog != null); - common (message, messageType); - AEnv.showCenterWindow(dialog, this); - } // ADialogDialog - - /** - * Common Init - * @param message - * @param messageType - */ - private void common (String message, int messageType) - { - try - { - setInfoMessage (message); - jbInit(messageType); - setInfoIcon (messageType); - } - catch(Exception ex) - { - log.log(Level.SEVERE, "ADialogDialog.common - " + ex.getMessage()); - } - // Default Button - this.getRootPane().setDefaultButton(confirmPanel.getOKButton()); - } // common - - /** - * Window Events - requestFocus - * @param e - */ - protected void processWindowEvent(WindowEvent e) - { - super.processWindowEvent(e); - if (e.getID() == WindowEvent.WINDOW_OPENED) - confirmPanel.getOKButton().requestFocusInWindow(); - } // processWindowEvent - - /** Answer OK (0) */ - public static int A_OK = 0; - /** Answer Cancel (1) */ - public static int A_CANCEL = 1; - /** Answer Close (-1) - Default */ - public static int A_CLOSE = -1; - /** Answer */ - private int m_returnCode = A_CLOSE; - /** Logger */ - private static CLogger log = CLogger.getCLogger(ADialogDialog.class); - - private static Icon i_inform = Env.getImageIcon("Inform32.gif"); - private static Icon i_warn = Env.getImageIcon("Warn32.gif"); - private static Icon i_question = Env.getImageIcon("Question32.gif"); - private static Icon i_error = Env.getImageIcon("Error32.gif"); - - private JMenuBar menuBar = new JMenuBar(); - private JMenu mFile = AEnv.getMenu("File"); - private CMenuItem mEMail = new CMenuItem(); - private CMenuItem mPrintScreen = new CMenuItem(); - private CMenuItem mScreenShot = new CMenuItem(); - private CMenuItem mEnd = new CMenuItem(); - private CMenuItem mPreference = new CMenuItem(); - private ConfirmPanel confirmPanel = new ConfirmPanel(true); - private CPanel westPanel = new CPanel(); - private CLabel iconLabel = new CLabel(); - private GridBagLayout westLayout = new GridBagLayout(); - private CTextPane info = new CTextPane (); - private CTextField input = new CTextField(); - private GridBagLayout infoLayout = new GridBagLayout(); - private CPanel infoPanel = new CPanel(); - - /** - * Static Constructor - * @throws Exception - */ - private void jbInit(int messageType) throws Exception - { - this.setJMenuBar(menuBar); - // - mEMail.setIcon(Env.getImageIcon("EMailSupport16.gif")); - mEMail.setText(Msg.getMsg(Env.getCtx(), "EMailSupport")); - mEMail.addActionListener(this); - mPrintScreen.setIcon(Env.getImageIcon("PrintScreen16.gif")); - mPrintScreen.setText(Msg.getMsg(Env.getCtx(), "PrintScreen")); - mPrintScreen.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_PRINTSCREEN, 0)); - mPrintScreen.addActionListener(this); - mScreenShot.setIcon(Env.getImageIcon("ScreenShot16.gif")); - mScreenShot.setText(Msg.getMsg(Env.getCtx(), "ScreenShot")); - mScreenShot.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_PRINTSCREEN, ActionEvent.SHIFT_MASK)); - mScreenShot.addActionListener(this); - mPreference.setIcon(Env.getImageIcon("Preference16.gif")); - mPreference.setText(Msg.getMsg(Env.getCtx(), "Preference")); - mPreference.addActionListener(this); - mEnd.setIcon(Env.getImageIcon("End16.gif")); - mEnd.setText(Msg.getMsg(Env.getCtx(), "End")); - mEnd.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_X, ActionEvent.ALT_MASK)); - mEnd.addActionListener(this); - // - westPanel.setLayout(westLayout); - westPanel.setName("westPanel"); - westPanel.setRequestFocusEnabled(false); - infoPanel.setLayout(infoLayout); - infoPanel.setName("infoPanel"); - infoPanel.setRequestFocusEnabled(false); - this.getContentPane().add(confirmPanel, BorderLayout.SOUTH); - this.getContentPane().add(westPanel, BorderLayout.WEST); - westPanel.add(iconLabel, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0 - ,GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(10, 10, 10, 10), 0, 0)); - this.getContentPane().add(infoPanel, BorderLayout.CENTER); - infoPanel.add(info, new GridBagConstraints(0, 1, 1, 1, 1.0, 1.0 - ,GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(10, 10, 10, 10), 0, 0)); - if(messageType == ADialogDialog.INPUT_MESSAGE) - infoPanel.add(input, new GridBagConstraints(0, 2, 1, 1, 1.0, 1.0 - ,GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(10, 10, 10, 10), 0, 0)); - // - menuBar.add(mFile); - mFile.add(mPrintScreen); - mFile.add(mScreenShot); - mFile.addSeparator(); - mFile.add(mEMail); - if (MRole.getDefault().isShowPreference()) - mFile.add(mPreference); - mFile.addSeparator(); - mFile.add(mEnd); - // - confirmPanel.addActionListener(this); - } // jbinit - - - /** - * Convert to HTML and Calculate Size - * @param message message - */ - private void setInfoMessage(String message) - { - StringBuilder sb = new StringBuilder (message.length()+20); - sb.append(""); - String html = Util.maskHTML(message); - char[] chars = html.toCharArray(); - boolean first = true; - int paras = 0; - for (int i = 0; i < chars.length; i++) - { - char c = chars[i]; - if (c == '\n') - { - if (first) - { - sb.append(""); - first = false; - } - if (paras > 1) - sb.append("
    "); - else - sb.append("

    "); - paras++; - } - else - sb.append(c); - } - info.setText(sb.toString()); - Dimension size = info.getPreferredSize(); - size.width = 450; - size.height = (Math.max(paras, message.length()/60)+1) * 30; - size.height = Math.min(size.height, 600); - info.setPreferredSize(size); - // Log.print("Para=" + paras + " - " + info.getPreferredSize()); - - info.setRequestFocusEnabled(false); - info.setReadWrite(false); - info.setOpaque(false); - info.setBorder(null); - // - info.setCaretPosition(0); - } // calculateSize - - - /************************************************************************** - * Set Info - * @param messageType - */ - private void setInfoIcon (int messageType) - { - confirmPanel.getCancelButton().setVisible(false); - // - switch (messageType) - { - case JOptionPane.ERROR_MESSAGE: - iconLabel.setIcon(i_error); - break; - case JOptionPane.INFORMATION_MESSAGE: - iconLabel.setIcon(i_inform); - break; - case JOptionPane.QUESTION_MESSAGE: - confirmPanel.getCancelButton().setVisible(true); - iconLabel.setIcon(i_question); - break; - case JOptionPane.WARNING_MESSAGE: - iconLabel.setIcon(i_warn); - break; - case ADialogDialog.INPUT_MESSAGE: - confirmPanel.getCancelButton().setVisible(false); - iconLabel.setIcon(i_question); - break; - case JOptionPane.PLAIN_MESSAGE: - default: - break; - } // switch - } // setInfo - - - /************************************************************************** - * ActionListener - * @param e - */ - public void actionPerformed (ActionEvent e) - { - // log.finest( "ADialogDialog.actionPerformed - " + e); - if (e.getActionCommand().equals(ConfirmPanel.A_OK)) - { - m_returnCode = A_OK; - dispose(); - } - else if (e.getActionCommand().equals(ConfirmPanel.A_CANCEL) || e.getSource() == mEnd) - { - m_returnCode = A_CANCEL; - dispose(); - } - else if (e.getSource() == mPrintScreen) - printScreen(); - else if (e.getSource() == mEMail) - { - String title = getTitle(); - String text = info.getText(); - dispose(); // otherwise locking - ADialog.createSupportEMail(this, title, text); - } - else if (e.getSource() == mPreference) - { - if (MRole.getDefault().isShowPreference()) - { - Preference p = new Preference (null, 0); - p.setVisible(true); - } - } - } // actionPerformed - - /** - * Get Return Code - * @return return code - */ - public int getReturnCode() - { - return m_returnCode; - } // getReturnCode - - /** - * PrintScreen - */ - private void printScreen() - { - PrintScreenPainter.printScreen(this); - } // printScreen - - /** - * Get entered message if dialog is a askForInput-Dialog - * @return - */ - public String getReturnMsg() { - return input.getText(); - } - -} // ADialogDialog diff --git a/org.adempiere.ui.swing/src/org/compiere/apps/AEnv.java b/org.adempiere.ui.swing/src/org/compiere/apps/AEnv.java deleted file mode 100644 index 1b102e809b..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/apps/AEnv.java +++ /dev/null @@ -1,1091 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ -package org.compiere.apps; - -import static org.compiere.model.SystemIDs.TABLE_AD_WF_ACTIVITY; -import static org.compiere.model.SystemIDs.TABLE_AD_WF_PROCESS; - -import java.awt.Component; -import java.awt.Container; -import java.awt.Dimension; -import java.awt.Frame; -import java.awt.GraphicsConfiguration; -import java.awt.Insets; -import java.awt.Rectangle; -import java.awt.Toolkit; -import java.awt.Window; -import java.awt.event.ActionListener; -import java.sql.PreparedStatement; -import java.sql.ResultSet; -import java.util.ArrayList; -import java.util.HashSet; -import java.util.Set; -import java.util.logging.Level; - -import javax.swing.ImageIcon; -import javax.swing.JButton; -import javax.swing.JComponent; -import javax.swing.JFrame; -import javax.swing.JMenu; -import javax.swing.JMenuItem; -import javax.swing.KeyStroke; -import javax.swing.RepaintManager; -import javax.swing.SwingConstants; -import javax.swing.SwingUtilities; - -import org.compiere.acct.Doc; -import org.compiere.db.CConnection; -import org.compiere.grid.ed.Calculator; -import org.compiere.interfaces.Server; -import org.compiere.model.MMenu; -import org.compiere.model.MQuery; -import org.compiere.model.MRole; -import org.compiere.model.MTable; -import org.compiere.swing.CButton; -import org.compiere.swing.CFrame; -import org.compiere.swing.CMenuItem; -import org.compiere.util.CLogger; -import org.compiere.util.DB; -import org.compiere.util.Env; -import org.compiere.util.Ini; -import org.compiere.util.Msg; -import org.compiere.util.Splash; - -/** - * Windows Application Environment and utilities - * - * @author Jorg Janke - * @version $Id: AEnv.java,v 1.2 2006/07/30 00:51:27 jjanke Exp $ - * - * @author Colin Rooney (croo) & kstan_79 RFE#1670185 - * @author victor.perez@e-evolution.com - * @see FR [ 1966328 ] New Window Info to MRP and CRP into View http://sourceforge.net/tracker/index.php?func=detail&aid=1966328&group_id=176962&atid=879335 - * - */ -public final class AEnv -{ - // Array of active Windows - private static ArrayList s_windows = new ArrayList(20); - - /** Array of hidden Windows */ - private static ArrayList s_hiddenWindows = new ArrayList(); - - /** Closing Window Indicator */ - private static boolean s_closingWindows = false; - - /** - * Hide Window - * @param window window - * @return true if window is hidden, otherwise close it - */ - static public boolean hideWindow(CFrame window) - { - if (!Ini.isCacheWindow() || s_closingWindows) - return false; - for (int i = 0; i < s_hiddenWindows.size(); i++) - { - CFrame hidden = s_hiddenWindows.get(i); - if (log.isLoggable(Level.INFO)) log.info(i + ": " + hidden); - if (hidden.getAD_Window_ID() == window.getAD_Window_ID()) - return false; // already there - } - if (window.getAD_Window_ID() != 0) // workbench - { - if (s_hiddenWindows.add(window)) - { - window.setVisible(false); - if (log.isLoggable(Level.INFO)) log.info(window.toString()); - // window.dispatchEvent(new WindowEvent(window, WindowEvent.WINDOW_ICONIFIED)); - if (s_hiddenWindows.size() > 10) { - CFrame toClose = s_hiddenWindows.remove(0); // sort of lru - try { - s_closingWindows = true; - toClose.dispose(); - } finally { - s_closingWindows = false; - } - } - return true; - } - } - return false; - } // hideWindow - - /** - * Show Window - * @param AD_Window_ID window - * @return true if window re-displayed - */ - static public CFrame showWindow (int AD_Window_ID) - { - for (int i = 0; i < s_hiddenWindows.size(); i++) - { - CFrame hidden = s_hiddenWindows.get(i); - if (hidden.getAD_Window_ID() == AD_Window_ID) - { - s_hiddenWindows.remove(i); - if (log.isLoggable(Level.INFO)) log.info(hidden.toString()); - hidden.setVisible(true); - // De-iconify window - teo_sarca [ 1707221 ] - int state = hidden.getExtendedState(); - if ((state & CFrame.ICONIFIED) > 0) - hidden.setExtendedState(state & ~CFrame.ICONIFIED); - // - hidden.toFront(); - return hidden; - } - } - return null; - } // showWindow - - /** - * Clode Windows. - */ - static void closeWindows () - { - s_closingWindows = true; - for (int i = 0; i < s_hiddenWindows.size(); i++) - { - CFrame hidden = s_hiddenWindows.get(i); - hidden.dispose(); - } - s_hiddenWindows.clear(); - s_closingWindows = false; - } // closeWindows - - /** - * Show window: de-iconify and bring it to front - * @author teo_sarca [ 1707221 ] - */ - public static void showWindow(Window window) { - window.setVisible(true); - if (window instanceof Frame) { - Frame f = (Frame)window; - int state = f.getExtendedState(); - if ((state & Frame.ICONIFIED) > 0) - f.setExtendedState(state & ~Frame.ICONIFIED); - } - window.toFront(); - } - - /** - * Show in the center of the screen. - * (pack, set location and set visibility) - * @param window Window to position - */ - public static void showCenterScreen(Window window) - { - positionCenterScreen(window); - showWindow(window); - } // showCenterScreen - - /** - * Show frame as maximized. - * @param frame - */ - public static void showMaximized(Frame frame) - { - frame.pack(); - frame.setExtendedState(Frame.MAXIMIZED_BOTH); - frame.setVisible(true); - frame.toFront(); - } - - /** - * Position window in center of the screen - * @param window Window to position - */ - public static void positionCenterScreen(Window window) - { - positionScreen (window, SwingConstants.CENTER); - } // positionCenterScreen - - /** - * Show in the center of the screen. - * (pack, set location and set visibility) - * @param window Window to position - * @param position SwingConstants - */ - public static void showScreen(Window window, int position) - { - positionScreen(window, position); - showWindow(window); - } // showScreen - - - /** - * Position window in center of the screen - * @param window Window to position - * @param position SwingConstants - */ - public static void positionScreen (Window window, int position) - { - window.pack(); - // take into account task bar and other adornments - GraphicsConfiguration config = window.getGraphicsConfiguration(); - Rectangle bounds = config.getBounds(); - Dimension sSize = bounds.getSize(); - Insets insets = Toolkit.getDefaultToolkit().getScreenInsets(config); - sSize.width -= (insets.left + insets.right); - sSize.height -= (insets.top + insets.bottom); - - Dimension wSize = window.getSize(); - // fit on window - if (wSize.height > sSize.height) - wSize.height = sSize.height; - if (wSize.width > sSize.width) - wSize.width = sSize.width; - window.setSize(wSize); - // Center - int x = (sSize.width - wSize.width) / 2; - int y = (sSize.height - wSize.height) / 2; - if (position == SwingConstants.CENTER) - ; - else if (position == SwingConstants.NORTH_WEST) - { - x = 0; - y = 0; - } - else if (position == SwingConstants.NORTH) - { - y = 0; - } - else if (position == SwingConstants.NORTH_EAST) - { - x = (sSize.width - wSize.width); - y = 0; - } - else if (position == SwingConstants.WEST) - { - x = 0; - } - else if (position == SwingConstants.EAST) - { - x = (sSize.width - wSize.width); - } - else if (position == SwingConstants.SOUTH) - { - y = (sSize.height - wSize.height); - } - else if (position == SwingConstants.SOUTH_WEST) - { - x = 0; - y = (sSize.height - wSize.height); - } - else if (position == SwingConstants.SOUTH_EAST) - { - x = (sSize.width - wSize.width); - y = (sSize.height - wSize.height); - } - // - window.setLocation(bounds.x + x + insets.left, bounds.y + y + insets.top); - } // positionScreen - - /** - * Position in center of the parent window. - * (pack, set location and set visibility) - * @param parent Parent Window - * @param window Window to position - */ - public static void showCenterWindow(Window parent, Window window) - { - positionCenterWindow(parent, window); - showWindow(window); - } // showCenterWindow - - /** - * Position in center of the parent window - * - * @param parent Parent Window - * @param window Window to position - */ - public static void positionCenterWindow(Window parent, Window window) - { - if (parent == null) - { - positionCenterScreen(window); - return; - } - window.pack(); - // - Dimension sSize = Toolkit.getDefaultToolkit().getScreenSize(); - // take into account task bar and other adornments - GraphicsConfiguration config = window.getGraphicsConfiguration(); - Insets insets = Toolkit.getDefaultToolkit().getScreenInsets(config); - sSize.width -= (insets.left + insets.right); - sSize.height -= (insets.top + insets.bottom); - - Dimension wSize = window.getSize(); - // fit on window - if (wSize.height > sSize.height) - wSize.height = sSize.height; - if (wSize.width > sSize.width) - wSize.width = sSize.width; - window.setSize(wSize); - // center in parent - Rectangle pBounds = parent.getBounds(); - // Parent is in upper left corner - if (pBounds.x == pBounds.y && pBounds.x == 0) - { - positionCenterScreen(window); - return; - } - // Find middle - int x = pBounds.x + ((pBounds.width-wSize.width)/2); - if (x < 0) - x = 0; - int y = pBounds.y + ((pBounds.height-wSize.height)/2); - if (y < 0) - y = 0; - - // Is it on Screen? - if (x + wSize.width > sSize.width) - x = sSize.width - wSize.width; - if (y + wSize.height > sSize.height) - y = sSize.height - wSize.height; - // - // System.out.println("Position: x=" + x + " y=" + y + " w=" + wSize.getWidth() + " h=" + wSize.getHeight() - // + " - Parent loc x=" + pLoc.x + " y=" + y + " w=" + pSize.getWidth() + " h=" + pSize.getHeight()); - window.setLocation(x + insets.left, y + insets.top); - } // positionCenterScreen - - - /************************************************************************* - * Get Button - * @param iconName - * @return button - */ - public static CButton getButton (String iconName) - { - CButton button = new CButton(Env.getImageIcon(iconName + "16.gif")); - button.setMargin(new Insets (0, 0, 0, 0)); - button.setToolTipText(Msg.getMsg(Env.getCtx(), iconName)); - button.setDefaultCapable(false); - return button; - } // getButton - - - /** - * Create Menu Title (translate it and set Mnemonics). - * Based on MS notation of &Help => H is Mnemonics - * - * @param AD_Message message - * @return JMenu - */ - public static JMenu getMenu (String AD_Message) - { - JMenu menu = new JMenu(); - String text = Msg.getMsg(Env.getCtx(), AD_Message); - int pos = text.indexOf('&'); - if (pos != -1 && text.length() > pos) // We have a nemonic - { - char ch = text.toUpperCase().charAt(pos+1); - if (ch != ' ') - { - text = text.substring(0, pos) + text.substring(pos+1); - menu.setMnemonic(ch); - } - } - menu.setText(text); - return menu; - } // getMenu - - /** - * Create Menu Item. - * @param actionName action command - * @param iconName optional name of the icon, defaults to action if null - * @param ks optional key stroke - * @param menu menu to add menu item to - * @param al action listener to register - * @return MenuItem - */ - public static JMenuItem addMenuItem (String actionName, String iconName, KeyStroke ks, - JMenu menu, ActionListener al) - { - if (iconName == null) - iconName = actionName; - String text = Msg.getMsg(Env.getCtx(), actionName); - ImageIcon icon = Env.getImageIcon2(iconName + "16"); - CMenuItem mi = new CMenuItem(text, icon); - mi.setActionCommand(actionName); - if (ks != null) - mi.setAccelerator(ks); - if (menu != null) - menu.add(mi); - if (al != null) - mi.addActionListener(al); - return mi; - } // addMenuItem - - /** - * Perform action command for common menu items. - * Created in AMenu.createMenu(), APanel.createMenu(), FormFrame.createMenu() - * @param actionCommand known action command - * @param WindowNo window no - * @param c Container parent - * @return true if actionCommand was found and performed - */ - public static boolean actionPerformed (String actionCommand, int WindowNo, Container c) - { - MRole role = MRole.getDefault(); - // File Menu ------------------------ - if (actionCommand.equals("PrintScreen")) - { - PrintScreenPainter.printScreen (getFrame(c)); - } - else if (actionCommand.equals("ScreenShot")) - { - ScreenShot.createJPEG(getFrame(c), null); - } - // else if (actionCommand.equals("Report")) - // { - // AEnv.showCenterScreen (new ProcessStart()); - // } - else if (actionCommand.equals("Exit")) - { - if (ADialog.ask(WindowNo, c, "ExitApplication?")) - { - AMenu aMenu = (AMenu)getWindow(0); - aMenu.dispose() ; - } - } - else if (actionCommand.equals("Logout")) - { - AMenu aMenu = (AMenu)getWindow(0); - aMenu.logout(); - } - - // View Menu ------------------------ - else if (actionCommand.equals("InfoProduct") && AEnv.canAccessInfo("PRODUCT")) - { - org.compiere.apps.search.Info.showProduct (getFrame(c), WindowNo); - } - else if (actionCommand.equals("InfoBPartner") && AEnv.canAccessInfo("BPARTNER")) - { - org.compiere.apps.search.Info.showBPartner (getFrame(c), WindowNo); - } - else if (actionCommand.equals("InfoAsset") && AEnv.canAccessInfo("ASSET")) - { - org.compiere.apps.search.Info.showAsset (getFrame(c), WindowNo); - } - else if (actionCommand.equals("InfoAccount") && - MRole.getDefault().isShowAcct() && - AEnv.canAccessInfo("ACCOUNT")) - { - new org.compiere.acct.AcctViewer(); - } - else if (actionCommand.equals("InfoSchedule") && AEnv.canAccessInfo("SCHEDULE")) - { - new org.compiere.apps.search.InfoSchedule (getFrame(c), null, false); - } - //FR [ 1966328 ] - else if (actionCommand.equals("InfoMRP") && AEnv.canAccessInfo("MRP")) - { - CFrame frame = (CFrame) getFrame(c); - int m_menu_id = MMenu.getMenu_ID("MRP Info"); - AMenu menu = AEnv.getAMenu(frame); - AMenuStartItem form = new AMenuStartItem (m_menu_id, true, Msg.translate(Env.getCtx(), "MRP Info"), menu); // async load - form.start(); - } - else if (actionCommand.equals("InfoCRP") && AEnv.canAccessInfo("CRP")) - { - CFrame frame = (CFrame) getFrame(c); - int m_menu_id = MMenu.getMenu_ID("CRP Info"); - AMenu menu = AEnv.getAMenu(frame); - AMenuStartItem form = new AMenuStartItem (m_menu_id, true, Msg.translate(Env.getCtx(), "CRP Info"), menu); // async load - form.start(); - } - else if (actionCommand.equals("InfoOrder") && AEnv.canAccessInfo("ORDER")) - { - org.compiere.apps.search.Info.showOrder (getFrame(c), WindowNo, ""); - } - else if (actionCommand.equals("InfoInvoice") && AEnv.canAccessInfo("INVOICE")) - { - org.compiere.apps.search.Info.showInvoice (getFrame(c), WindowNo, ""); - } - else if (actionCommand.equals("InfoInOut") && AEnv.canAccessInfo("INOUT")) - { - org.compiere.apps.search.Info.showInOut (getFrame(c), WindowNo, ""); - } - else if (actionCommand.equals("InfoPayment") && AEnv.canAccessInfo("PAYMENT")) - { - org.compiere.apps.search.Info.showPayment (getFrame(c), WindowNo, ""); - } - else if (actionCommand.equals("InfoCashLine") && AEnv.canAccessInfo("CASHJOURNAL")) - { - org.compiere.apps.search.Info.showCashLine (getFrame(c), WindowNo, ""); - } - else if (actionCommand.equals("InfoAssignment") && AEnv.canAccessInfo("RESOURCE")) - { - org.compiere.apps.search.Info.showAssignment (getFrame(c), WindowNo, ""); - } - - - // Go Menu ------------------------ - else if (actionCommand.equals("WorkFlow")) - { - startWorkflowProcess(0,0); - } - else if (actionCommand.equals("Home")) - { - showWindow(getWindow(0)); - } - - // Tools Menu ------------------------ - else if (actionCommand.equals("Calculator")) - { - Calculator calc = new org.compiere.grid.ed.Calculator(getFrame(c)); - calc.setDisposeOnEqual(false); - AEnv.showCenterScreen (calc); - } - else if (actionCommand.equals("Calendar")) - { - AEnv.showCenterScreen (new org.compiere.grid.ed.Calendar(getFrame(c))); - } - else if (actionCommand.equals("Editor")) - { - AEnv.showCenterScreen (new org.compiere.grid.ed.Editor(getFrame(c))); - } - else if (actionCommand.equals("Script")) - { - new BeanShellEditor(getFrame(c)); - } - else if (actionCommand.equals("Preference")) - { - if (role.isShowPreference()) { - AEnv.showCenterScreen(new Preference (getFrame(c), WindowNo)); - } - } - - // Help Menu ------------------------ - else if (actionCommand.equals("Online")) - { - Env.startBrowser(org.compiere.Adempiere.getOnlineHelpURL()); - } - else if (actionCommand.equals("EMailSupport")) - { - ADialog.createSupportEMail(getFrame(c), getFrame(c).getTitle(), "\n\n"); - } - else if (actionCommand.equals("About")) - { - AEnv.showCenterScreen(new AboutBox(getFrame(c))); - } - else - return false; - // - return true; - } // actionPerformed - - /** - * Set Text and Mnemonic for Button. - * Create Mnemonics of text containing '&'. - * Based on MS notation of &Help => H is Mnemonics - * @param b The button - * @param text The text with optional Mnemonics - */ - public static void setTextMnemonic (JButton b, String text) - { - if (text == null || b == null) - return; - int pos = text.indexOf('&'); - if (pos != -1) // We have a nemonic - { - char ch = text.charAt(pos+1); - b.setMnemonic(ch); - b.setText(text.substring(0, pos) + text.substring(pos+1)); - } - b.setText(text); - } // setTextMnemonic - - /** - * Get Mnemonic character from text. - * @param text text with '&' - * @return Mnemonic or 0 - */ - public static char getMnemonic (String text) - { - int pos = text.indexOf('&'); - if (pos != -1) // We have a nemonic - return text.charAt(pos+1); - return 0; - } // getMnemonic - - - /************************************************************************* - * Zoom - * @param AD_Table_ID - * @param Record_ID - */ - public static void zoom (int AD_Table_ID, int Record_ID) - { - int AD_Window_ID = Env.getZoomWindowID(AD_Table_ID, Record_ID); - // Nothing to Zoom to - if (AD_Window_ID == 0) - return; - - MTable table = MTable.get(Env.getCtx(), AD_Table_ID); - - AWindow frame = new AWindow(null); - if (!frame.initWindow(AD_Window_ID, MQuery.getEqualQuery(table.getTableName() + "_ID", Record_ID))) - return; - addToWindowManager(frame); - if (Ini.isPropertyBool(Ini.P_OPEN_WINDOW_MAXIMIZED)) - { - AEnv.showMaximized(frame); - } - else - { - AEnv.showCenterScreen(frame); - } - frame = null; - } // zoom - - /** - * Zoom - * @param query query - */ - public static void zoom (MQuery query) - { - if (query == null || query.getTableName() == null || query.getTableName().length() == 0) - return; - - int AD_Window_ID = Env.getZoomWindowID(query); - // Nothing to Zoom to - if (AD_Window_ID == 0) - return; - - AWindow frame = new AWindow(null); - if (!frame.initWindow(AD_Window_ID, query)) - return; - addToWindowManager(frame); - if (Ini.isPropertyBool(Ini.P_OPEN_WINDOW_MAXIMIZED)) - { - AEnv.showMaximized(frame); - } - else - { - AEnv.showCenterScreen(frame); - } - frame = null; - } // zoom - - /** - * Track open frame in window manager - * @param frame - */ - public static void addToWindowManager(CFrame frame) - { - JFrame top = getWindow(0); - if (top instanceof AMenu) - { - ((AMenu)top).getWindowManager().add(frame); - } - } - - /** - * FR [ 1966328 ] - * get AMenu - * @param frame - */ - public static AMenu getAMenu(CFrame frame) - { - JFrame top = getWindow(0); - if (top instanceof AMenu) - { - return (AMenu)top; - } - return null; - } - /** - * Exit System - * @param status System exit status (usually 0 for no error) - */ - public static void exit (int status) - { - Env.exitEnv(status); - } // exit - - public static void logout() - { - Env.logout(); - - Splash.getSplash().setVisible(true); - - //reload - new AMenu(); - } - - /** - * Is Workflow Process view enabled. - * @return true if enabled - */ - public static boolean isWorkflowProcess () - { - if (s_workflow == null) - { - s_workflow = Boolean.FALSE; - int AD_Table_ID = TABLE_AD_WF_PROCESS; // AD_WF_Process - if (MRole.getDefault().isTableAccess (AD_Table_ID, true)) // RO - s_workflow = Boolean.TRUE; - else - { - AD_Table_ID = TABLE_AD_WF_ACTIVITY; // AD_WF_Activity - if (MRole.getDefault().isTableAccess (AD_Table_ID, true)) // RO - s_workflow = Boolean.TRUE; - else - if (log.isLoggable(Level.CONFIG)) log.config(s_workflow.toString()); - } - // Get Window - if (s_workflow.booleanValue()) - { - s_workflow_Window_ID = DB.getSQLValue (null, - "SELECT AD_Window_ID FROM AD_Table WHERE AD_Table_ID=?", AD_Table_ID); - if (s_workflow_Window_ID == 0) - s_workflow_Window_ID = 297; // fallback HARDCODED - // s_workflow = Boolean.FALSE; - if (log.isLoggable(Level.CONFIG)) log.config(s_workflow + ", Window=" + s_workflow_Window_ID); - } - } - return s_workflow.booleanValue(); - } // isWorkflowProcess - - - /** - * Start Workflow Process Window - * @param AD_Table_ID optional table - * @param Record_ID optional record - */ - public static void startWorkflowProcess (int AD_Table_ID, int Record_ID) - { - if (s_workflow_Window_ID == 0) - return; - // - MQuery query = null; - if (AD_Table_ID != 0 && Record_ID != 0) - { - query = new MQuery("AD_WF_Process"); - query.addRestriction("AD_Table_ID", MQuery.EQUAL, AD_Table_ID); - query.addRestriction("Record_ID", MQuery.EQUAL, Record_ID); - } - // - AWindow frame = new AWindow(null); - if (!frame.initWindow(s_workflow_Window_ID, query)) - return; - addToWindowManager(frame); - if (Ini.isPropertyBool(Ini.P_OPEN_WINDOW_MAXIMIZED) ) { - frame.pack(); - frame.setExtendedState(Frame.MAXIMIZED_BOTH); - frame.setVisible(true); - frame.toFront(); - } else - AEnv.showCenterScreen(frame); - frame = null; - } // startWorkflowProcess - - - /*************************************************************************/ - - /** Workflow Menu */ - private static Boolean s_workflow = null; - /** Workflow Menu */ - private static int s_workflow_Window_ID = 0; - - /** Logger */ - private static CLogger log = CLogger.getCLogger(AEnv.class); - - /** - * Get Server Version - * @return Apps Server Version - * @see ALogin#checkVersion - */ - public static String getServerVersion () - { - return CConnection.get().getServerVersion(); - } // getServerVersion - - /** - * Post Immediate - * @param WindowNo window - * @param AD_Table_ID Table ID of Document - * @param AD_Client_ID Client ID of Document - * @param Record_ID Record ID of this document - * @param force force posting - * @return null if success, otherwise error - */ - public static String postImmediate (int WindowNo, int AD_Client_ID, - int AD_Table_ID, int Record_ID, boolean force) - { - if (log.isLoggable(Level.CONFIG)) log.config("Window=" + WindowNo - + ", AD_Table_ID=" + AD_Table_ID + "/" + Record_ID - + ", Force=" + force); - - return Doc.manualPosting(WindowNo, AD_Client_ID, AD_Table_ID, Record_ID, force); - } // postImmediate - - /** - * Cache Reset - * @param tableName table name - * @param Record_ID record id - */ - public static void cacheReset (String tableName, int Record_ID) - { - if (log.isLoggable(Level.CONFIG)) log.config("TableName=" + tableName + ", Record_ID=" + Record_ID); - - try - { - Server server = CConnection.get().getServer(); - if (server != null) - { - server.cacheReset(Env.getRemoteCallCtx(Env.getCtx()), tableName, Record_ID); - } - } - catch (Exception e) - { - log.log(Level.SEVERE, "ex", e); - } - } // cacheReset - - /** - * Update all windows after look and feel changes. - * @since 2006-11-27 - */ - public static void updateUI() - { - Set updated = updateUI0(); - JFrame top = getWindow(0); - if (top instanceof AMenu) - { - CFrame[] frames = ((AMenu)top).getWindowManager().getWindows(); - for (CFrame f : frames) - { - if (updated.contains(f)) continue; - SwingUtilities.updateComponentTreeUI(f); - f.validate(); - RepaintManager mgr = RepaintManager.currentManager(f); - Component childs[] = f.getComponents(); - for (Component c : childs) { - if (c instanceof JComponent) - mgr.markCompletelyDirty((JComponent)c); - } - f.repaint(); - updated.add(f); - } - } - } - - /** - * Validate permissions to access Info queries on the view menu - * @author kstan_79 - * @return true if access is allowed - */ - - public static boolean canAccessInfo(String infoWindowName) - { - boolean result=false; - int roleid= Env.getAD_Role_ID(Env.getCtx()); - String sqlRolePermission="Select COUNT(AD_ROLE_ID) AS ROWCOUNT FROM AD_ROLE WHERE AD_ROLE_ID=" + roleid - + " AND ALLOW_INFO_" + infoWindowName + "='Y'"; - - log.config(sqlRolePermission); - PreparedStatement prolestmt = null; - ResultSet rs = null; - try - { - prolestmt = DB.prepareStatement (sqlRolePermission, null); - - rs = prolestmt.executeQuery (); - - rs.next(); - - if (rs.getInt("ROWCOUNT")>0) - { - result=true; - } - else - { - return false; - } - } - catch (Exception e) - { - System.out.println(e); - log.log(Level.SEVERE, "(1)", e); - } - finally - { - DB.close(rs, prolestmt); - rs = null; prolestmt = null; - } - - return result; - } // canAccessInfo - - /** - * Update all windows after look and feel changes. - * @since 2006-11-27 - */ - public static SetupdateUI0() - { - Set updated = new HashSet(); - for (Container c : s_windows) - { - Window w = getFrame(c); - if (w == null) continue; - if (updated.contains(w)) continue; - SwingUtilities.updateComponentTreeUI(w); - w.validate(); - RepaintManager mgr = RepaintManager.currentManager(w); - Component childs[] = w.getComponents(); - for (Component child : childs) { - if (child instanceof JComponent) - mgr.markCompletelyDirty((JComponent)child); - } - w.repaint(); - updated.add(w); - } - for (Window w : s_hiddenWindows) - { - if (updated.contains(w)) continue; - SwingUtilities.updateComponentTreeUI(w); - w.validate(); - RepaintManager mgr = RepaintManager.currentManager(w); - Component childs[] = w.getComponents(); - for (Component child : childs) { - if (child instanceof JComponent) - mgr.markCompletelyDirty((JComponent)child); - } - w.repaint(); - updated.add(w); - } - return updated; - } - - /** - * Add Container and return WindowNo. - * The container is a APanel, AWindow or JFrame/JDialog - * @param win window - * @return WindowNo used for context - */ - public static int createWindowNo(Container win) - { - int retValue = s_windows.size(); - s_windows.add(win); - return retValue; - } // createWindowNo - - /** - * Search Window by comparing the Frames - * @param container container - * @return WindowNo of container or 0 - */ - public static int getWindowNo (Container container) - { - if (container == null) - return 0; - JFrame winFrame = getFrame(container); - if (winFrame == null) - return 0; - - // loop through windows - for (int i = 0; i < s_windows.size(); i++) - { - Container cmp = (Container)s_windows.get(i); - if (cmp != null) - { - JFrame cmpFrame = getFrame(cmp); - if (winFrame.equals(cmpFrame)) - return i; - } - } - return 0; - } // getWindowNo - - /** - * Return the JFrame pointer of WindowNo - or null - * @param WindowNo window - * @return JFrame of WindowNo - */ - public static JFrame getWindow (int WindowNo) - { - JFrame retValue = null; - try - { - retValue = getFrame ((Container)s_windows.get(WindowNo)); - } - catch (Exception e) - { - log.log(Level.SEVERE, e.toString()); - } - return retValue; - } // getWindow - - /** - * Remove window from active list - * @param WindowNo window - */ - public static void removeWindow (int WindowNo) - { - if (WindowNo>=0 && WindowNo < s_windows.size()) - s_windows.set(WindowNo, null); - } // removeWindow - - /************************************************************************** - * Get Frame of Window - * @param container Container - * @return JFrame of container or null - */ - public static JFrame getFrame (Container container) - { - Container element = container; - while (element != null) - { - if (element instanceof JFrame) - return (JFrame)element; - element = element.getParent(); - } - return null; - } // getFrame - - public static void reset(boolean finalCall) - { - closeWindows(); - - // Dismantle windows - /** - for (int i = 0; i < s_windows.size(); i++) - { - Container win = (Container)s_windows.get(i); - if (win.getClass().getName().endsWith("AMenu")) // Null pointer - ; - else if (win instanceof Window) - ((Window)win).dispose(); - else - win.removeAll(); - } - **/ - //bug [ 1574630 ] - if (s_windows.size() > 0) { - if (!finalCall) { - Container c = s_windows.get(0); - s_windows.clear(); - createWindowNo(c); - } else { - s_windows.clear(); - } - } - } -} // AEnv diff --git a/org.adempiere.ui.swing/src/org/compiere/apps/AExport.java b/org.adempiere.ui.swing/src/org/compiere/apps/AExport.java deleted file mode 100644 index 972b69db93..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/apps/AExport.java +++ /dev/null @@ -1,165 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 2008 SC ARHIPAC SERVICE SRL. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - *****************************************************************************/ -package org.compiere.apps; - -import java.awt.Component; -import java.awt.Cursor; -import java.io.File; -import java.io.IOException; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.logging.Level; - -import javax.swing.JFileChooser; - -import org.adempiere.base.IGridTabExporter; -import org.adempiere.base.equinox.EquinoxExtensionLocator; -import org.compiere.grid.GridController; -import org.compiere.grid.VTabbedPane; -import org.compiere.model.GridTab; -import org.compiere.util.CLogMgt; -import org.compiere.util.CLogger; -import org.compiere.util.ExtensionFileFilter; - -/** - * Export button consequences - * @author Teo Sarca, www.arhipac.ro - *

  • FR [ 1943731 ] Window data export functionality - */ -public class AExport -{ - private CLogger log = CLogger.getCLogger(getClass()); - private int m_WindowNo = 0; - private Map exporterMap = null; - private Map extensionMap = null; - private APanel parent; - - public AExport(APanel parent) - { - m_WindowNo = parent.getWindowNo(); - // - exporterMap = new HashMap(); - extensionMap = new HashMap(); - List exporterList = EquinoxExtensionLocator.instance().list(IGridTabExporter.class).getExtensions(); - for(IGridTabExporter exporter : exporterList) - { - String extension = exporter.getFileExtension(); - if (!extensionMap.containsKey(extension)) - { - extensionMap.put(extension, exporter.getFileExtensionLabel()); - exporterMap.put(extension, exporter); - } - } - JFileChooser chooser = new JFileChooser(); - for(Map.Entry entry : extensionMap.entrySet()) - { - chooser.addChoosableFileFilter(new ExtensionFileFilter(entry.getKey(), entry.getValue())); - } - - if (chooser.showSaveDialog(parent) != JFileChooser.APPROVE_OPTION) - return; - - // Create File - File outFile = ExtensionFileFilter.getFile(chooser.getSelectedFile(), chooser.getFileFilter()); - try - { - outFile.createNewFile(); - } - catch (IOException e) - { - log.log(Level.SEVERE, "", e); - ADialog.error(m_WindowNo, parent, "FileCannotCreate", e.getLocalizedMessage()); - return; - } - - String ext = outFile.getPath(); - // no extension - if (ext.lastIndexOf('.') == -1) - { - ADialog.error(m_WindowNo, parent, "FileInvalidExtension"); - return; - } - ext = ext.substring(ext.lastIndexOf('.')+1).toLowerCase(); - if (log.isLoggable(Level.CONFIG)) log.config( "File=" + outFile.getPath() + "; Type=" + ext); - - parent.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); - this.parent = parent; - try - { - if (extensionMap.containsKey(ext)) - { - export(outFile, parent.getCurrentTab(), ext); - } - else - { - ADialog.error(m_WindowNo, parent, "FileInvalidExtension"); - } - } - catch (Exception e) - { - ADialog.error(m_WindowNo, parent, "Error", e.getLocalizedMessage()); - if (CLogMgt.isLevelFinest()) - e.printStackTrace(); - } - finally - { - parent.setCursor(Cursor.getDefaultCursor()); - } - } - - private void export(File outFile, GridTab tab, String extension) - throws Exception - { - boolean currentRowOnly = ADialog.ask(m_WindowNo, parent, "ExportCurrentRowOnly"); - - IGridTabExporter exporter = exporterMap.get(extension); - Set tables = new HashSet(); - List childs = new ArrayList(); - List includedList = tab.getIncludedTabs(); - for(GridTab included : includedList) - { - String tableName = included.getTableName(); - if (tables.contains(tableName)) - continue; - tables.add(tableName); - childs.add(included); - } - - int selected = parent.getSelectedTabIndex(); - VTabbedPane tabbedPane = (VTabbedPane) parent.getCurrentTabbedPane(); - for(int i = selected+1; i < tabbedPane.getTabCount(); i++) - { - Component c = tabbedPane.getComponentAt(i); - if (!(c instanceof GridController)) - continue; - - GridController gc = (GridController) c; - if (gc.getMTab() == null) - continue; - if (gc.getMTab().getTabLevel() <= tab.getTabLevel()) - break; - String tableName = gc.getMTab().getTableName(); - if (tables.contains(tableName)) - continue; - tables.add(tableName); - childs.add(gc.getMTab()); - } - - exporter.export(tab, childs, currentRowOnly, outFile,0); - } -} diff --git a/org.adempiere.ui.swing/src/org/compiere/apps/AFocusTraversalPolicy.java b/org.adempiere.ui.swing/src/org/compiere/apps/AFocusTraversalPolicy.java deleted file mode 100644 index 1b2e38d4f9..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/apps/AFocusTraversalPolicy.java +++ /dev/null @@ -1,179 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ -package org.compiere.apps; - -import java.awt.Component; -import java.awt.Container; - -import javax.swing.JTabbedPane; -import javax.swing.JToolBar; -import javax.swing.LayoutFocusTraversalPolicy; - -import org.compiere.grid.VPanel; -import org.compiere.grid.ed.VEditor; -import org.compiere.swing.CEditor; - - -/** - * Adempiere Application Focus Traversal Policy - * - * @author Jorg Janke - * @version $Id: AFocusTraversalPolicy.java,v 1.2 2006/07/30 00:51:27 jjanke Exp $ - */ -public class AFocusTraversalPolicy extends LayoutFocusTraversalPolicy -{ - /** - * - */ - private static final long serialVersionUID = 6803932792562494878L; - - /** - * Get singleton - * @return AFocusTraversalPolicy - */ - public static AFocusTraversalPolicy get() - { - if (s_policy == null) - s_policy = new AFocusTraversalPolicy(); - return s_policy; - } // get - - /** Default Policy */ - private static AFocusTraversalPolicy s_policy = new AFocusTraversalPolicy(); - - /************************************************************************** - * Constructor - */ - public AFocusTraversalPolicy () - { - super(); - } // AFocusTraversalPolicy - - boolean m_default = false; - - /** - * Get Default Component - * @param aContainer container - * @return default or null - */ - public Component getDefaultComponent (Container aContainer) - { - // info ("Root: ", aContainer); - m_default = true; - Component c = super.getDefaultComponent (aContainer); - // info (" Default: ", c); - m_default = false; - return c; - } // getDefaultComponent - - /** - * Get First Component - * @param aContainer container - * @return first component to focus - */ - @Override - public Component getFirstComponent(Container aContainer) - { - Component c = null; - if (aContainer instanceof VPanel) - { - VEditor editor = ((VPanel)aContainer).getDefaultFocus(); - if (editor != null && editor.isReadWrite()) - c = editor.getFocusableComponent(); - if (c != null) - return c; - } - return super.getFirstComponent(aContainer); - } // getFirstComponent - - /** - * Determines whether the specified Component - * is an acceptable choice as the new focus owner. - * This method performs the following sequence of operations: - *
      - *
    1. Checks whether aComponent is visible, displayable, - * enabled, and focusable. If any of these properties is - * false, this method returns false. - *
    2. If aComponent is an instance of JTable, - * returns true. - *
    3. If aComponent is an instance of JComboBox, - * then returns the value of - * aComponent.getUI().isFocusTraversable(aComponent). - *
    4. If aComponent is a JComponent - * with a JComponent.WHEN_FOCUSED - * InputMap that is neither null - * nor empty, returns true. - *
    5. Returns the value of - * DefaultFocusTraversalPolicy.accept(aComponent). - *
    - * - * @param aComponent the Component whose fitness - * as a focus owner is to be tested - * @see java.awt.Component#isVisible - * @see java.awt.Component#isDisplayable - * @see java.awt.Component#isEnabled - * @see java.awt.Component#isFocusable - * @see javax.swing.plaf.ComboBoxUI#isFocusTraversable - * @see javax.swing.JComponent#getInputMap() - * @see java.awt.DefaultFocusTraversalPolicy#accept - * @return true if aComponent is a valid choice - * for a focus owner; - * otherwise false - */ - protected boolean accept(Component aComponent) - { - if (!super.accept(aComponent)) - return false; - - // TabbedPane - if (aComponent instanceof JTabbedPane) - return false; - // R/O Editors - if (aComponent instanceof CEditor) - { - CEditor ed = (CEditor)aComponent; - if (!ed.isReadWrite()) - return false; - if (m_default // get Default Focus - && ("AD_Client_ID".equals(aComponent.getName()) || "AD_Org_ID".equals(aComponent.getName()) )) - return false; - } - // Toolbar Buttons - if (aComponent.getParent() instanceof JToolBar) - return false; - // - return true; - } // accept - - /************************************************************************** - * Dump info - * @param title - * @param c - */ - /*private void info (String title, Component c) - { - System.out.print (title); - if (c == null) - System.out.println (" - null"); - else - { - System.out.print (c.getClass().getName()); - System.out.println (" - " + c.getName()); - } - } // info*/ - -} // AFocusTraversalPolicy diff --git a/org.adempiere.ui.swing/src/org/compiere/apps/AGlassPane.java b/org.adempiere.ui.swing/src/org/compiere/apps/AGlassPane.java deleted file mode 100644 index 63df3b5356..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/apps/AGlassPane.java +++ /dev/null @@ -1,268 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ -package org.compiere.apps; - -import java.awt.Color; -import java.awt.Dimension; -import java.awt.Font; -import java.awt.FontMetrics; -import java.awt.Graphics; -import java.awt.Image; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.awt.event.MouseEvent; -import java.awt.event.MouseListener; -import java.util.logging.Level; - -import javax.swing.JPanel; -import javax.swing.Timer; - -import org.adempiere.plaf.AdempierePLAF; -import org.compiere.util.CLogger; -import org.compiere.util.Env; -import org.compiere.util.Msg; - -/** - * Glass Pane to display "waiting" and capture events while processing. - * - * @author Jorg Janke - * @version $Id: AGlassPane.java,v 1.2 2006/07/30 00:51:27 jjanke Exp $ - */ -public class AGlassPane extends JPanel implements MouseListener, ActionListener -{ - /** - * - */ - private static final long serialVersionUID = 618724937492933184L; - - /** - * Constructor - */ - public AGlassPane() - { - this.setOpaque(false); - this.setVisible(false); - this.addMouseListener(this); - } // AGlassPane - - /** The Image */ - public static Image s_image = Env.getImage("iD10030.png"); - /** The Message Font */ - public static Font s_font = new Font("Dialog", 3, 14); - /** The Message Color */ - public static Color s_color = AdempierePLAF.getTextColor_OK(); - - /** Gap between components */ - private static final int GAP = 4; - - /** The Message */ - private String m_message = Msg.getMsg(Env.getCtx(), "Processing"); - - /** Timer */ - private Timer m_timer; - /** Value of timer */ - private int m_timervalue = 0; - private int m_timermax = 0; - /** Logger */ - private static CLogger log = CLogger.getCLogger(AGlassPane.class); - - /** - * Set Message - * @param AD_Message to be translated - null resets to default message - */ - public void setMessage(String AD_Message) - { - if (AD_Message == null) - m_message = Msg.getMsg(Env.getCtx(), "Processing"); - else if (AD_Message.length() == 0) - m_message = AD_Message; // nothing - else - m_message = Msg.getMsg(Env.getCtx(), AD_Message); - if (isVisible()) - repaint(); - } // setMessage - - /** - * Get Message - * @return displayed message - */ - public String getMessage() - { - return m_message; - } // getMessage - - - /************************************************************************** - * Set and start Busy Counter if over 2 seconds - * @param time in seconds - */ - public void setBusyTimer (int time) - { - if (log.isLoggable(Level.CONFIG)) log.config("Time=" + time); - // should we display a progress bar? - if (time < 2 ) - { - m_timermax = 0; - if (isVisible()) - repaint(); - return; - } - - m_timermax = time; - m_timervalue = 0; - - // Start Timer - if(m_timer == null) - { - m_timer = new Timer (1000, this); // every second - } - m_timer.start(); - - if (!isVisible()) - setVisible(true); - repaint(); - } // setBusyTimer - - @Override - public void setVisible(boolean flag) { - if(!flag && m_timer != null) - { - m_timer.stop(); - } - super.setVisible(flag); - } - /** - * ActionListener - * @param e event - */ - public void actionPerformed (ActionEvent e) - { - if (m_timermax > 0) - { - m_timervalue++; - if (m_timervalue > m_timermax) - m_timervalue = 0; - repaint(); - } - } // actionPerformed - - - /************************************************************************** - * Paint Component. - *
    -	 *      image
    -	 *      message
    -	 *      progressBar
    -	 *  
    - * @param g - */ - public void paintComponent (Graphics g) - { - Dimension panelSize = getSize(); - g.setColor(new Color(1f,1f,1f, 0.4f)); // .5 is a bit too light - g.fillRect(0,0, panelSize.width, panelSize.height); - // - g.setFont(s_font); - g.setColor(s_color); - FontMetrics fm = g.getFontMetrics(); - Dimension messageSize = new Dimension (fm.stringWidth(m_message), fm.getAscent() + fm.getDescent()); - Dimension imageSize = new Dimension (s_image.getWidth(this), s_image.getHeight(this)); - Dimension progressSize = new Dimension(150, 15); - // System.out.println("Panel=" + panelSize + " - Message=" + messageSize + " - Image=" + imageSize + " - Progress=" + progressSize); - - // Horizontal layout - int height = imageSize.height + GAP + messageSize.height + GAP + progressSize.height; - if (height > panelSize.height) - { - log.log(Level.SEVERE, "Panel too small - height=" + panelSize.height); - return; - } - int yImage = (panelSize.height/2) - (height/2); - int yMessage = yImage + imageSize.height + GAP + fm.getAscent(); - int yProgress = yMessage + fm.getDescent() + GAP; - // System.out.println("yImage=" + yImage + " - yMessage=" + yMessage); - - // Vertical layout - if (imageSize.width > panelSize.width || messageSize.width > panelSize.width) - { - log.log(Level.SEVERE, "Panel too small - width=" + panelSize.width); - return; - } - int xImage = (panelSize.width/2) - (imageSize.width/2); - int xMessage = (panelSize.width/2) - (messageSize.width/2); - int xProgress = (panelSize.width/2) - (progressSize.width/2); - - g.drawImage(s_image, xImage, yImage, this); - g.drawString(m_message, xMessage, yMessage); - if (m_timermax > 0) - { - int pWidth = progressSize.width / m_timermax * m_timervalue; - g.setColor(AdempierePLAF.getPrimary3()); - g.fill3DRect(xProgress, yProgress, pWidth, progressSize.height, true); - g.setColor(AdempierePLAF.getPrimary2()); - g.draw3DRect(xProgress, yProgress, progressSize.width, progressSize.height, true); - } - } // paintComponent - - - /************************************************************************** - * Mouse Listener - * @param e - */ - public void mouseClicked(MouseEvent e) - { - if (isVisible()) - e.consume(); - } - /** - * Mouse Listener - * @param e - */ - public void mousePressed(MouseEvent e) - { - if (isVisible()) - e.consume(); - } - /** - * Mouse Listener - * @param e - */ - public void mouseReleased(MouseEvent e) - { - if (isVisible()) - e.consume(); - } - /** - * Mouse Listener - * @param e - */ - public void mouseEntered(MouseEvent e) - { - if (isVisible()) - e.consume(); - } - /** - * Mouse Listener - * @param e - */ - public void mouseExited(MouseEvent e) - { - if (isVisible()) - e.consume(); - } - -} // AGlassPane diff --git a/org.adempiere.ui.swing/src/org/compiere/apps/AKeyboardFocusManager.java b/org.adempiere.ui.swing/src/org/compiere/apps/AKeyboardFocusManager.java deleted file mode 100644 index 0d62480d6a..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/apps/AKeyboardFocusManager.java +++ /dev/null @@ -1,52 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ -package org.compiere.apps; - -import java.awt.DefaultKeyboardFocusManager; - -/** - * Apps Keyboard Focus Manager - * - * @author Jorg Janke - * @version $Id: AKeyboardFocusManager.java,v 1.2 2006/07/30 00:51:27 jjanke Exp $ - */ -public class AKeyboardFocusManager extends DefaultKeyboardFocusManager -{ - /** - * Get default Keyboard Focus Mgr - * @return focus manager - */ - public static AKeyboardFocusManager get() - { - if (s_kfm == null) - s_kfm = new AKeyboardFocusManager(); - return s_kfm; - } // get - - /** Default Focus Manager */ - private static AKeyboardFocusManager s_kfm = new AKeyboardFocusManager(); - - /** - * Constructor - */ - public AKeyboardFocusManager () - { - super (); - setDefaultFocusTraversalPolicy(AFocusTraversalPolicy.get()); - } // AKeyboardFocusManager - -} // AKeyboardFocusManager diff --git a/org.adempiere.ui.swing/src/org/compiere/apps/ALayout.java b/org.adempiere.ui.swing/src/org/compiere/apps/ALayout.java deleted file mode 100644 index 3b6ba7bf87..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/apps/ALayout.java +++ /dev/null @@ -1,418 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ -package org.compiere.apps; - -import java.awt.Component; -import java.awt.Container; -import java.awt.Dimension; -import java.awt.Insets; -import java.awt.LayoutManager; -import java.awt.LayoutManager2; -import java.util.Arrays; -import java.util.Iterator; - -/** - * Application Layout Manager. - * - * panel.setLayout(new ALayout()); - * panel.add(field11, new ALayoutConstraint(0,0)); - * panel.add(field12, null); - * panel.add(field13, null); - * panel.add(field14, null); - * panel.add(field21, new ALayoutConstraint(1,0)); - * - * - * @author Jorg Janke - * @version $Id: ALayout.java,v 1.2 2006/07/30 00:51:27 jjanke Exp $ - */ -public class ALayout implements LayoutManager2 -{ - /** - * Default Constructor with spacing of 2 and columns filled - */ - public ALayout() - { - this (2,4, true); - } // ALayout - - /** - * Detail Contructor - * @param spaceH horizontal space (top, between rows, button) - * @param spaceV vertical space (left, between columns, right) - * @param colFill fields are fully filled (rather then preferred size) - */ - public ALayout(int spaceH, int spaceV, boolean colFill) - { - setSpaceH(spaceH); - setSpaceV(spaceV); - m_colFill = colFill; - } // ALayout - - /** Data Storage */ - private ALayoutCollection m_data = new ALayoutCollection(); - /** Horizontal Space */ - private int m_spaceH; - /** Vertical Space */ - private int m_spaceV; - /** Column Fill */ - private boolean m_colFill; - - /** - * Add To Layout with NULL constraint - * - * @param name the string to be associated with the component - ignored - * @param comp the component to be added - */ - public void addLayoutComponent(String name, Component comp) - { - addLayoutComponent (comp, null); - } // addLayoutComponent - - /** - * Adds the specified component to the layout, using the specified - * constraint object. If the constraint is not a ALayoutConstraint - * the component is added with a NULL constraint. - *

    - * Components with a NULL constraint are added as the next column to the last row - * - * @param component the component to be added - * @param constraint where/how the component is added to the layout. - * @see ALayoutConstraint - */ - public void addLayoutComponent(Component component, Object constraint) - { - ALayoutConstraint con = null; - if (constraint instanceof ALayoutConstraint) - con = (ALayoutConstraint)constraint; - // - m_data.put(con, component); - } // addLayoutComponent - - /** - * Removes the specified component from the layout. - * @param comp the component to be removed - */ - public void removeLayoutComponent(Component comp) - { - if (!m_data.containsValue(comp)) - return; - Iterator it = m_data.keySet().iterator(); - while (it.hasNext()) - { - Object key = it.next(); - if (m_data.get(key).equals(comp)) - { - m_data.remove(key); - return; - } - } - } // removeLayoutComponent - - /** - * Calculates the preferred size dimensions for the specified - * container, given the components it contains. - * @param parent the container to be laid out - * @return Size - * @see #minimumLayoutSize - */ - public Dimension preferredLayoutSize(Container parent) - { - return calculateLayoutSize (parent, 'P'); - } // preferredLayoutSize - - /** - * Calculates the minimum size dimensions for the specified - * container, given the components it contains. - * @param parent the component to be laid out - * @return Size - * @see #preferredLayoutSize - */ - public Dimension minimumLayoutSize(Container parent) - { - return calculateLayoutSize (parent, 'm'); - } // minimumLayoutSize - - /** - * Calculates the maximum size dimensions for the specified container, - * given the components it contains. - * @param parent Parent Container - * @return Size - * @see java.awt.Component#getMaximumSize - * @see LayoutManager - */ - public Dimension maximumLayoutSize(Container parent) - { - return calculateLayoutSize (parent, 'M'); - } // maximumLayoutSize - - /** - * Calculate Layout Size - * @param parent Parent Container - * @param how P=Preferred - M=Maximum = m=Mimimum - * @return Size - */ - private Dimension calculateLayoutSize(Container parent, char how) - { - checkComponents(parent); - // -- Create 2D Dimension Array - int rows = getRowCount(); - int cols = getColCount(); - Dimension[][] dim = new Dimension[rows][cols]; - // - Object[] keys = m_data.keySet().toArray(); - Arrays.sort(keys); - for (int i = 0; i < keys.length; i++) - { - ALayoutConstraint constraint = (ALayoutConstraint)keys[i]; - Component component = (Component)m_data.get(keys[i]); - Dimension d = null; - if (how == 'P') - d = component.getPreferredSize(); - else if (how == 'M') - d = component.getMaximumSize(); - else - d = component.getMinimumSize(); - if (component.isVisible()) - dim [constraint.getRow()][constraint.getCol()] = d; - else - dim [constraint.getRow()][constraint.getCol()] = null; - } - - // -- Calculate 2D Dimension Size - Insets insets = parent.getInsets(); - Dimension retValue = new Dimension (insets.left+insets.right, insets.top+insets.bottom); - retValue.height += m_spaceH; - retValue.width += m_spaceV; - int maxWidth = 0; - for (int r = 0; r < rows; r++) - { - int height = 0; - int width = 0; - for (int c = 0; c < cols; c++) - { - Dimension d = dim[r][c]; - if (d != null) - { - width += d.width; - height = Math.max(height, d.height); - } - width += m_spaceV; - } // for all columns - retValue.height += height + m_spaceH; - maxWidth += Math.max(maxWidth, width); - } // for all rows - retValue.width += maxWidth; - // Log.trace(this,Log.l6_Database, "ALayout.calculateLayoutSize", retValue.toString()); - return retValue; - } // calculateLayoutSize - - /** - * Lays out the specified container. - * @param parent the container to be laid out - */ - public void layoutContainer(Container parent) - { - checkComponents(parent); - // -- Create 2D Component Array - int rows = getRowCount(); - int cols = getColCount(); - Component[][] com = new Component[rows][cols]; - // - Object[] keys = m_data.keySet().toArray(); - Arrays.sort(keys); - for (int i = 0; i < keys.length; i++) - { - ALayoutConstraint constraint = (ALayoutConstraint)keys[i]; - Component component = (Component)m_data.get(keys[i]); - if (component.isVisible()) - com [constraint.getRow()][constraint.getCol()] = component; - else - com [constraint.getRow()][constraint.getCol()] = null; - } - - // -- Calculate Column Size - int[] colWidth = new int[cols]; - int[] rowHeight = new int[rows]; - int columnWidth = m_spaceV; - for (int c = 0; c < cols; c++) - { - int width = 0; - for (int r = 0; r < rows; r++) - { - Component component = com[r][c]; - if (component != null) - { - width = Math.max (width, component.getPreferredSize().width); - rowHeight[r] = Math.max (rowHeight[r], component.getPreferredSize().height); - } - } - colWidth[c] = width; - columnWidth += width + m_spaceV; - } - - // -- Stretch/Squeeze Columns to fit target width - int parentWidth = parent.getSize().width; - double multiplier = (double)parentWidth / (double)columnWidth; - if (multiplier < .5) // limit sqeezing - multiplier = .5; - for (int c = 0; c < cols; c++) - colWidth[c] = (int) (colWidth[c] * multiplier); - int spaceV = (int)(m_spaceV * multiplier); - // -// log.fine( "ALayout.layoutContainer", -// "ParentWidth=" + parentWidth + ", ColumnWidth=" + columnWidth + ", SpaceV=" + spaceV + ", Multiplier=" + multiplier); - - // -- Lay out components - Insets insets = parent.getInsets(); - int posH = insets.top + m_spaceH; - for (int r = 0; r < rows; r++) - { - int posV = insets.left + spaceV; - int height = 0; - for (int c = 0; c < cols; c++) - { - Component component = com[r][c]; - if (component != null) - { - Dimension ps = component.getPreferredSize(); - int w = ps.width; - if (m_colFill || w > colWidth[c]) // limit or stretch - w = colWidth[c]; - int h = ps.height; - int topSpace = 0; - if (h < rowHeight[r]) // push a little bit lower - topSpace = (rowHeight[r] - h) / 3; - height = Math.max(height, h); - component.setBounds(posV, posH+topSpace, w, h); -// log.fine( "ALayout.layoutContainer", -// "Row=" + r + ", Col=" + c + ", PosV=" + posV + ", PosH=" + posH + "/" + topSpace + ", width=" + w + ", height=" + h); - } - posV += colWidth[c] + spaceV; - } // for all columns - posH += height + m_spaceH; - } // for all rows - } // layoutContainer - - /** - * Returns the alignment along the x axis. This specifies how - * the component would like to be aligned relative to other - * components. The value should be a number between 0 and 1 - * where 0 represents alignment along the origin, 1 is aligned - * the furthest away from the origin, 0.5 is centered, etc. - * @param target target - * @return 0f - */ - public float getLayoutAlignmentX(Container target) - { - return 0f; - } // getLayoutAlignmentX - - /** - * Returns the alignment along the y axis. This specifies how - * the component would like to be aligned relative to other - * components. The value should be a number between 0 and 1 - * where 0 represents alignment along the origin, 1 is aligned - * the furthest away from the origin, 0.5 is centered, etc. - * @param target target - * @return 0f - */ - public float getLayoutAlignmentY(Container target) - { - return 0f; - } // getLayoutAlignmentY - - /** - * Invalidates the layout, indicating that if the layout manager - * has cached information it should be discarded. - * @param target target - */ - public void invalidateLayout(Container target) - { - } // invalidateLayout - - /*************************************************************************/ - - /** - * Check target components and add components, which don't have no constraints - * @param target target - */ - private void checkComponents (Container target) - { - int size = target.getComponentCount(); - for (int i = 0; i < size; i++) - { - Component comp = target.getComponent(i); - if (!m_data.containsValue(comp)) - m_data.put(null, comp); - } - } // checkComponents - - /** - * Get Number of Rows - * @return no pf rows - */ - public int getRowCount() - { - return m_data.getMaxRow()+1; - } // getRowCount - - /** - * Get Number of Columns - * @return no of cols - */ - public int getColCount() - { - return m_data.getMaxCol()+1; - } // getColCount - - /** - * Set Horizontal Space (top, between rows, button) - * @param spaceH horizontal space (top, between rows, button) - */ - public void setSpaceH (int spaceH) - { - m_spaceH = spaceH; - } // setSpaceH - - /** - * Get Horizontal Space (top, between rows, button) - * @return spaceH horizontal space (top, between rows, button) - */ - public int getSpaceH() - { - return m_spaceH; - } // getSpaceH - - /** - * Set Vertical Space (left, between columns, right) - * @param spaceV vertical space (left, between columns, right) - */ - public void setSpaceV(int spaceV) - { - m_spaceV = spaceV; - } // setSpaceV - - /** - * Get Vertical Space (left, between columns, right) - * @return spaceV vertical space (left, between columns, right) - */ - public int getSpaceV() - { - return m_spaceV; - } // getSpaceV - -} // ALayout diff --git a/org.adempiere.ui.swing/src/org/compiere/apps/ALayoutCollection.java b/org.adempiere.ui.swing/src/org/compiere/apps/ALayoutCollection.java deleted file mode 100644 index bf660142f9..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/apps/ALayoutCollection.java +++ /dev/null @@ -1,135 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ -package org.compiere.apps; - -import java.awt.Component; -import java.util.HashMap; -import java.util.Iterator; - -/** - * Collection of Components ordered based on ALayoutConstraint - * - * @author Jorg Janke - * @version $Id: ALayoutCollection.java,v 1.2 2006/07/30 00:51:27 jjanke Exp $ - */ -class ALayoutCollection extends HashMap -{ - /** - * - */ - private static final long serialVersionUID = -2906536401026546141L; - - /** - * Create Collection - */ - public ALayoutCollection() - { - super(); - } // ALayoutCollection - - /** - * Add a Component. - * If constraint is null, it is added to the last row as additional column - * @param constraint - * @param component - * @return component - * @throws IllegalArgumentException if component is not a Component - */ - public Object put (Object constraint, Object component) - { - if (!(component instanceof Component)) - throw new IllegalArgumentException ("ALayoutCollection can only add Component values"); - - if (constraint != null - && !containsKey(constraint) - && constraint instanceof ALayoutConstraint) - { - // Log.trace(this,Log.l6_Database, "ALayoutCollection.put", constraint.toString()); - return super.put (constraint, component); - } - - // We need to create constraint - if (super.size() == 0) - { - // Log.trace(this,Log.l6_Database, "ALayoutCollection.put - first"); - return super.put(new ALayoutConstraint(0,0), component); - } - - // Add to end of list - int row = getMaxRow(); - if (row == -1) - row = 0; - int col = getMaxCol(row) + 1; - ALayoutConstraint next = new ALayoutConstraint(row, col); - // Log.trace(this,Log.l6_Database, "ALayoutCollection.put - addEnd", next.toString()); - return super.put(next, component); - } // put - - /** - * Get Maximum Row Number - * @return max row no - or -1 if no row - */ - public int getMaxRow () - { - int maxRow = -1; - // - Iterator i = keySet().iterator(); - while (i.hasNext()) - { - ALayoutConstraint c = (ALayoutConstraint)i.next(); - maxRow = Math.max(maxRow, c.getRow()); - } - return maxRow; - } // getMaxRow - - /** - * Get Maximum Column Number - * @return max col no - or -1 if no column - */ - public int getMaxCol () - { - int maxCol = -1; - // - Iterator i = keySet().iterator(); - while (i.hasNext()) - { - ALayoutConstraint c = (ALayoutConstraint)i.next(); - maxCol = Math.max(maxCol, c.getCol()); - } - return maxCol; - } // getMaxCol - - /** - * Get Maximum Column Number for Row - * @param row - * @return max col no for row - or -1 if no col in row - */ - public int getMaxCol (int row) - { - int maxCol = -1; - // - Iterator i = keySet().iterator(); - while (i.hasNext()) - { - ALayoutConstraint c = (ALayoutConstraint)i.next(); - if (c.getRow() == row) - maxCol = Math.max(maxCol, c.getCol()); - } - return maxCol; - } // getMaxCol - -} // ALayoutCollection diff --git a/org.adempiere.ui.swing/src/org/compiere/apps/ALayoutConstraint.java b/org.adempiere.ui.swing/src/org/compiere/apps/ALayoutConstraint.java deleted file mode 100644 index 718fce2006..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/apps/ALayoutConstraint.java +++ /dev/null @@ -1,122 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ -package org.compiere.apps; - - -/** - * Application Layout Constraint to indicate grid position (immutable) - * - * @author Jorg Janke - * @version $Id: ALayoutConstraint.java,v 1.2 2006/07/30 00:51:27 jjanke Exp $ - */ -public class ALayoutConstraint implements Comparable -{ - /** - * Layout Constraint to indicate grid position - * @param row row 0..x - * @param col column 0..x - */ - public ALayoutConstraint(int row, int col) - { - m_row = row; - m_col = col; - } // ALayoutConstraint - - /** - * Create Next in Row - * @return ALayoutConstraint for additional column in same row - */ - public ALayoutConstraint createNext() - { - return new ALayoutConstraint(m_row, m_col+1); - } // createNext - - private int m_row; - private int m_col; - - /** - * Get Row - * @return roe no - */ - public int getRow() - { - return m_row; - } // getRow - - /** - * Get Column - * @return col no - */ - public int getCol() - { - return m_col; - } // getCol - - /** - * Compares this object with the specified object for order. Returns a - * negative integer, zero, or a positive integer as this object is less - * than, equal to, or greater than the specified object.

    - * - * @param o the Object to be compared. - * @return a negative integer if this object is less than the specified object, - * zero if equal, - * or a positive integer if this object is greater than the specified object. - */ - public int compareTo(Object o) - { - ALayoutConstraint comp = null; - if (o instanceof ALayoutConstraint) - comp = (ALayoutConstraint)o; - if (comp == null) - return +111; - - // Row compare - int rowComp = m_row - comp.getRow(); - if (rowComp != 0) - return rowComp; - // Column compare - return m_col - comp.getCol(); - } // compareTo - - /** - * Is Object Equal - * @param o - * @return true if equal - */ - public boolean equals(Object o) - { - if (o instanceof ALayoutConstraint) - return compareTo(o) == 0; - return false; - } // equal - - public int hashCode() - { - assert false : "hashCode not designed"; - return 42; // any arbitrary constant will do - } - - /** - * To String - * @return info - */ - public String toString() - { - return "ALayoutConstraint [Row=" + m_row + ", Col=" + m_col + "]"; - } // toString - -} // ALayoutConstraint diff --git a/org.adempiere.ui.swing/src/org/compiere/apps/ALogin.java b/org.adempiere.ui.swing/src/org/compiere/apps/ALogin.java deleted file mode 100644 index 1e720e6f11..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/apps/ALogin.java +++ /dev/null @@ -1,1235 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ -package org.compiere.apps; - -import java.awt.BorderLayout; -import java.awt.Color; -import java.awt.Cursor; -import java.awt.Frame; -import java.awt.GridBagConstraints; -import java.awt.GridBagLayout; -import java.awt.Insets; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.awt.event.WindowEvent; -import java.rmi.AccessException; -import java.sql.Timestamp; -import java.util.Locale; -import java.util.Properties; -import java.util.ResourceBundle; -import java.util.logging.Level; - -import javax.swing.JOptionPane; -import javax.swing.JPasswordField; -import javax.swing.SwingConstants; -import javax.swing.event.ChangeEvent; -import javax.swing.event.ChangeListener; - -import org.adempiere.plaf.AdempierePLAF; -import org.compiere.Adempiere; -import org.compiere.db.CConnection; -import org.compiere.db.CConnectionEditor; -import org.compiere.grid.ed.VComboBox; -import org.compiere.grid.ed.VDate; -import org.compiere.model.MSysConfig; -import org.compiere.model.MSystem; -import org.compiere.model.MUser; -import org.compiere.print.CPrinter; -import org.compiere.swing.CButton; -import org.compiere.swing.CDialog; -import org.compiere.swing.CLabel; -import org.compiere.swing.CPanel; -import org.compiere.swing.CTabbedPane; -import org.compiere.swing.CTextField; -import org.compiere.util.CLogger; -import org.compiere.util.DB; -import org.compiere.util.DisplayType; -import org.compiere.util.Env; -import org.compiere.util.Ini; -import org.compiere.util.KeyNamePair; -import org.compiere.util.Language; -import org.compiere.util.Login; -import org.compiere.util.Msg; -import org.compiere.util.Trx; -import org.compiere.util.Util; -import org.compiere.util.ValueNamePair; - -/** - * Application Login Window - * - * @author Jorg Janke - * @version $Id: ALogin.java,v 1.2 2006/07/30 00:51:27 jjanke Exp $ - */ -public final class ALogin extends CDialog - implements ActionListener, ChangeListener -{ - /** - * - */ - private static final long serialVersionUID = -4397663968578607998L; - - /** - * Construct the dialog. - * Need to call initLogin for dynamic start - * @param parent parent - */ - public ALogin (Frame parent) - { - super (parent, "Login", true); // Modal - log.finer(""); - setDefaultCloseOperation(DISPOSE_ON_CLOSE); - m_WindowNo = AEnv.createWindowNo (null); - res = ResourceBundle.getBundle(RESOURCE); - // - try - { - jbInit(); - } - catch(Exception e) - { - log.severe(e.toString()); - } - // Focus to OK - this.getRootPane().setDefaultButton(confirmPanel.getOKButton()); - parent.setIconImage(Adempiere.getImage16()); - } // ALogin - - - public static final String ROLE_TYPES_SWING = "NULL,SW,SS"; //swing,support+null - protected static final String RESOURCE = "org.compiere.apps.ALoginRes"; - private static ResourceBundle res = ResourceBundle.getBundle(RESOURCE); - /** Logger */ - private static CLogger log = CLogger.getCLogger(ALogin.class); - - private static final int TAB_CONNECTION = 0; - private static final int TAB_DEFAULTS = 1; - private static final int TAB_CHANGE_PASSWORD = 2; - - private static final int NOT_CONNECTED = -1; - private static final int CONNECTED_OK = 0; - private static final int CONNECTED_OK_WITH_PASSWORD_EXPIRED = 1; - - private static final int NO_OF_SECURITY_QUESTION = 5; - private static final String SECURITY_QUESTION_PREFIX = "SecurityQuestion_"; - - private CPanel mainPanel = new CPanel(new BorderLayout()); - private CTabbedPane loginTabPane = new CTabbedPane(); - private CPanel connectionPanel = new CPanel(); - private CLabel hostLabel = new CLabel(); - private CConnectionEditor hostField = new CConnectionEditor(); - private CLabel userLabel = new CLabel(); - private CTextField userTextField = new CTextField(); - private CLabel passwordLabel = new CLabel(); - private JPasswordField passwordField = new JPasswordField(); - private CPanel defaultPanel = new CPanel(); - private CLabel clientLabel = new CLabel(); - private CLabel orgLabel = new CLabel(); - private CLabel dateLabel = new CLabel(); - private VDate dateField = new VDate(DisplayType.Date); - private VComboBox orgCombo = new VComboBox(); - private VComboBox clientCombo = new VComboBox(); - private CLabel warehouseLabel = new CLabel(); - private VComboBox warehouseCombo = new VComboBox(); - private CLabel printerLabel = new CLabel(); - private CPrinter printerField = new CPrinter(); - private CLabel roleLabel = new CLabel(); - private VComboBox roleCombo = new VComboBox(); - private CLabel copy0Label = new CLabel(); - private CLabel titleLabel = new CLabel(); - private CLabel versionLabel = new CLabel(); - private CLabel copy1Label = new CLabel(); - private GridBagLayout connectionLayout = new GridBagLayout(); - private GridBagLayout defaultPanelLayout = new GridBagLayout(); - private CLabel languageLabel = new CLabel(); - private VComboBox languageCombo = null; - private CLabel compileDate = new CLabel(); - private CPanel southPanel = new CPanel(); - private BorderLayout southLayout = new BorderLayout(); - private StatusBar statusBar = new StatusBar(); - private ConfirmPanel confirmPanel = new ConfirmPanel(true, false, false, false, false, false, false); - - // IDEMPIERE-373 Implement User Locking - private CPanel changePasswordPanel = new CPanel(); - private GridBagLayout changePasswordPanelLayout = new GridBagLayout(); - private CLabel lblOldPassword = new CLabel(); - private CLabel lblNewPassword = new CLabel(); - private CLabel lblRetypeNewPassword = new CLabel(); - private JPasswordField txtOldPassword = new JPasswordField(); - private JPasswordField txtNewPassword = new JPasswordField(); - private JPasswordField txtRetypeNewPassword = new JPasswordField(); - // - private CLabel lblSecurityQuestion = new CLabel(); - private CLabel lblAnswer = new CLabel(); - private VComboBox lstSecurityQuestion = new VComboBox(); - private CTextField txtAnswer = new CTextField(); - - /** Server Connection */ - private CConnection m_cc; - /** Application User */ - private String m_user; - /** Application Password */ - private char[] m_pwd = new char[0]; - - /** Combo Active */ - private boolean m_comboActive = false; - /** Combo Active */ - private boolean m_okPressed = false; - /** Connection OK */ - private int m_connectionOK = -1; - /** Window No */ - private int m_WindowNo; - /** Context */ - private Properties m_ctx = Env.getCtx(); - - private Login m_login = null; - - - /************************************************************************** - * Component initialization - * @throws Exception - */ - private void jbInit() throws Exception - { - this.setName("Login"); - //red1 - giving names to input fields for UISpec4J calling during tests - orgCombo.setName("orgCombo"); - clientCombo.setName("clientCombo"); - userTextField.setName("userTextField"); - passwordField.setName("passwordField"); - - if (DB.isConnected()) - Env.getLoginLanguages(); // to fill the s_language array on Language - languageCombo = new VComboBox(Language.getNames()); - - //red1 - end - - titleLabel.setFont(new java.awt.Font("Serif", 2, 10)); - titleLabel.setForeground(Color.blue); - titleLabel.setRequestFocusEnabled(false); - titleLabel.setToolTipText(Adempiere.getURL()); - titleLabel.setHorizontalTextPosition(SwingConstants.CENTER); - titleLabel.setIcon(Adempiere.getImageIconLogo()); - titleLabel.setText(Adempiere.getSubtitle()); - titleLabel.setVerticalTextPosition(SwingConstants.BOTTOM); - versionLabel.setRequestFocusEnabled(false); - versionLabel.setHorizontalAlignment(SwingConstants.RIGHT); - versionLabel.setHorizontalTextPosition(SwingConstants.RIGHT); - hostLabel.setRequestFocusEnabled(false); - hostLabel.setLabelFor(hostField); - hostField.addActionListener(this); - userLabel.setRequestFocusEnabled(false); - userLabel.setLabelFor(userTextField); - passwordLabel.setRequestFocusEnabled(false); - passwordLabel.setLabelFor(passwordField); - languageLabel.setLabelFor(languageCombo); - copy0Label.setFont(new java.awt.Font("Serif", 2, 10)); - copy0Label.setForeground(Color.blue); - copy0Label.setRequestFocusEnabled(false); - copy1Label.setRequestFocusEnabled(false); - roleLabel.setRequestFocusEnabled(false); - roleLabel.setLabelFor(roleCombo); - clientLabel.setRequestFocusEnabled(false); - orgLabel.setRequestFocusEnabled(false); - dateLabel.setRequestFocusEnabled(false); - warehouseLabel.setRequestFocusEnabled(false); - printerLabel.setRequestFocusEnabled(false); - compileDate.setHorizontalAlignment(SwingConstants.RIGHT); - compileDate.setHorizontalTextPosition(SwingConstants.RIGHT); - compileDate.setText(Adempiere.DATE_VERSION); - compileDate.setToolTipText(Adempiere.getImplementationVendor()); - southPanel.setLayout(southLayout); - loginTabPane.addChangeListener(this); - - // ConnectionTab - connectionPanel.setLayout(connectionLayout); - // - titleLabel.setHorizontalAlignment(SwingConstants.CENTER); - versionLabel.setText(Adempiere.MAIN_VERSION); - versionLabel.setToolTipText(Adempiere.getImplementationVersion()); - hostLabel.setHorizontalAlignment(SwingConstants.RIGHT); - hostLabel.setText("Host"); - hostLabel.setLabelFor(hostField); - connectionPanel.add(hostLabel, new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 12, 5, 5), 0, 0)); - connectionPanel.add(hostField, new GridBagConstraints(1, 2, 3, 1, 1.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 0, 5, 12), 0, 0)); - userLabel.setHorizontalAlignment(SwingConstants.RIGHT); - userLabel.setText("User"); - userLabel.setLabelFor(userTextField); - connectionPanel.add(userLabel, new GridBagConstraints(0, 3, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 12, 5, 5), 0, 0)); - userTextField.setText("System"); // default - connectionPanel.add(userTextField, new GridBagConstraints(1, 3, 3, 1, 1.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 0, 5, 12), 0, 0)); - passwordLabel.setHorizontalAlignment(SwingConstants.RIGHT); - passwordLabel.setText("Password"); - passwordLabel.setLabelFor(passwordField); - connectionPanel.add(passwordLabel, new GridBagConstraints(0, 4, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 12, 5, 5), 0, 0)); - passwordField.setText("System"); // default - connectionPanel.add(passwordField, new GridBagConstraints(1, 4, 3, 1, 1.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 5, 12), 0, 0)); - languageLabel.setHorizontalAlignment(SwingConstants.RIGHT); - languageLabel.setText("Language"); - languageLabel.setLabelFor(languageCombo); - languageCombo.addActionListener(this); - // @Trifon - begin - connectionPanel.add(languageLabel, new GridBagConstraints(0, 5, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 12, 5, 5), 0, 0)); - connectionPanel.add(languageCombo, new GridBagConstraints(1, 5, 3, 1, 1.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 0, 5, 12), 0, 0)); - // @Trifon - end - copy0Label.setHorizontalAlignment(SwingConstants.RIGHT); - connectionPanel.add(copy0Label, new GridBagConstraints(0, 6, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); - - copy1Label.setText(Adempiere.COPYRIGHT); - connectionPanel.add(copy1Label, new GridBagConstraints(1, 6, 2, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 12, 12), 0, 0)); - connectionPanel.add(compileDate, new GridBagConstraints(2, 1, 2, 1, 0.0, 0.0 - ,GridBagConstraints.NORTHEAST, GridBagConstraints.NONE, new Insets(2, 0, 0, 12), 0, 0)); - connectionPanel.add(titleLabel, new GridBagConstraints(0, 0, 2, 2, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(12, 12, 5, 5), 0, 0)); - connectionPanel.add(versionLabel, new GridBagConstraints(2, 0, 2, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(12, 5, 0, 12), 0, 0)); - - loginTabPane.add(connectionPanel, res.getString("Connection")); - - // DefaultTab - defaultPanel.setLayout(defaultPanelLayout); - // - clientLabel.setText("Client"); - clientLabel.setHorizontalAlignment(SwingConstants.RIGHT); - clientLabel.setLabelFor(clientCombo); - clientCombo.addActionListener(this); - defaultPanel.add(clientLabel, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(12, 12, 5, 5), 0, 0)); - defaultPanel.add(clientCombo, new GridBagConstraints(1, 0, 1, 1, 1.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(12, 0, 5, 12), 0, 0)); - roleLabel.setText("Role"); - roleLabel.setHorizontalAlignment(SwingConstants.RIGHT); - roleLabel.setLabelFor(roleCombo); - roleCombo.addActionListener(this); - defaultPanel.add(roleLabel, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 12, 5, 5), 0, 0)); - defaultPanel.add(roleCombo, new GridBagConstraints(1, 1, 1, 1, 1.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 0, 5, 12), 0, 0)); - orgLabel.setText("Organization"); - orgLabel.setHorizontalAlignment(SwingConstants.RIGHT); - orgLabel.setLabelFor(orgCombo); - defaultPanel.add(orgLabel, new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 12, 5, 5), 0, 0)); - orgCombo.addActionListener(this); - defaultPanel.add(orgCombo, new GridBagConstraints(1, 2, 1, 1, 1.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 5, 12), 0, 0)); - dateLabel.setText("Date"); - dateLabel.setHorizontalAlignment(SwingConstants.RIGHT); - dateLabel.setLabelFor(dateField); - defaultPanel.add(dateLabel, new GridBagConstraints(0, 4, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 12, 5, 5), 0, 0)); - defaultPanel.add(dateField, new GridBagConstraints(1, 4, 1, 1, 1.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 0, 5, 12), 0, 0)); - // - warehouseLabel.setText("Warehouse"); - warehouseLabel.setHorizontalAlignment(SwingConstants.RIGHT); - warehouseLabel.setLabelFor(warehouseCombo); - printerLabel.setText("Printer"); - printerLabel.setHorizontalAlignment(SwingConstants.RIGHT); - printerLabel.setLabelFor(printerField); - - defaultPanel.add(printerLabel, new GridBagConstraints(0, 5, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 12, 12, 5), 0, 0)); - defaultPanel.add(printerField, new GridBagConstraints(1, 5, 1, 1, 1.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 12, 12), 0, 0)); - - defaultPanel.add(warehouseLabel, new GridBagConstraints(0, 3, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 12, 5, 5), 0, 0)); - defaultPanel.add(warehouseCombo, new GridBagConstraints(1, 3, 1, 1, 1.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 0, 5, 12), 0, 0)); - - // @Trifon - begin -/* - defaultPanel.add(languageLabel, new GridBagConstraints(0, 6, 1, 1, 0.0, 0.0 - , GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 12, 5, 5), 0, 0)); - defaultPanel.add(languageCombo, new GridBagConstraints(1, 6, 3, 1, 1.0, 0.0 - , GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 0, 5, 12), 0, 0)); -*/ - // @Trifon - end - // - loginTabPane.add(defaultPanel, res.getString("Defaults")); - - // IDEMPIERE-373 Implement User Locking - txtOldPassword.setName("txtOldPassword"); - lblOldPassword.setRequestFocusEnabled(false); - lblOldPassword.setLabelFor(txtOldPassword); - lblOldPassword.setHorizontalAlignment(SwingConstants.RIGHT); - lblOldPassword.setText(Msg.getMsg(m_ctx, "Old Password")); - - txtNewPassword.setName("txtNewPassword"); - lblNewPassword.setRequestFocusEnabled(false); - lblNewPassword.setLabelFor(txtNewPassword); - lblNewPassword.setHorizontalAlignment(SwingConstants.RIGHT); - lblNewPassword.setText(Msg.getMsg(m_ctx, "New Password")); - - txtRetypeNewPassword.setName("txtRetypeNewPassword"); - lblRetypeNewPassword.setRequestFocusEnabled(false); - lblRetypeNewPassword.setLabelFor(txtRetypeNewPassword); - lblRetypeNewPassword.setHorizontalAlignment(SwingConstants.RIGHT); - lblRetypeNewPassword.setText(Msg.getMsg(m_ctx, "New Password Confirm")); - - lstSecurityQuestion.setName("lstSecurityQuestion"); - lblSecurityQuestion.setRequestFocusEnabled(false); - lblSecurityQuestion.setLabelFor(lstSecurityQuestion); - lblSecurityQuestion.setHorizontalAlignment(SwingConstants.RIGHT); - lblSecurityQuestion.setText(Msg.getMsg(m_ctx, "SecurityQuestion")); - - lstSecurityQuestion.removeAllItems(); - for (int i = 1; i <= NO_OF_SECURITY_QUESTION; i++) - lstSecurityQuestion.addItem(new ValueNamePair(SECURITY_QUESTION_PREFIX + i, Msg.getMsg(m_ctx, SECURITY_QUESTION_PREFIX + i))); - - txtAnswer.setName("txtAnswer"); - lblAnswer.setRequestFocusEnabled(false); - lblAnswer.setLabelFor(txtAnswer); - lblAnswer.setHorizontalAlignment(SwingConstants.RIGHT); - lblAnswer.setText(Msg.getMsg(m_ctx, "Answer")); - - changePasswordPanel.setLayout(changePasswordPanelLayout); - - changePasswordPanel.add(lblOldPassword, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(12, 12, 5, 5), 0, 0)); - changePasswordPanel.add(txtOldPassword, new GridBagConstraints(1, 0, 1, 1, 1.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(12, 0, 5, 12), 0, 0)); - changePasswordPanel.add(lblNewPassword, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(12, 12, 5, 5), 0, 0)); - changePasswordPanel.add(txtNewPassword, new GridBagConstraints(1, 1, 1, 1, 1.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(12, 0, 5, 12), 0, 0)); - changePasswordPanel.add(lblRetypeNewPassword, new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(12, 12, 5, 5), 0, 0)); - changePasswordPanel.add(txtRetypeNewPassword, new GridBagConstraints(1, 2, 1, 1, 1.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(12, 0, 5, 12), 0, 0)); - changePasswordPanel.add(lblSecurityQuestion, new GridBagConstraints(0, 3, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(12, 12, 5, 5), 0, 0)); - changePasswordPanel.add(lstSecurityQuestion, new GridBagConstraints(1, 3, 1, 1, 1.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(12, 0, 5, 12), 0, 0)); - changePasswordPanel.add(lblAnswer, new GridBagConstraints(0, 4, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(12, 12, 5, 5), 0, 0)); - changePasswordPanel.add(txtAnswer, new GridBagConstraints(1, 4, 1, 1, 1.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(12, 0, 5, 12), 0, 0)); - loginTabPane.add(changePasswordPanel, res.getString("ChangePassword")); - loginTabPane.setEnabledAt(TAB_CHANGE_PASSWORD, false); - // - - // Help - /* - helpPanel.setLayout(helpLayout); - helpPanel.setPreferredSize(new Dimension (100,100)); - helpPanel.add(helpScollPane, BorderLayout.CENTER); - loginTabPane.add(helpPanel, "?");*/ - // - this.getContentPane().add(mainPanel); - mainPanel.add(loginTabPane, BorderLayout.CENTER); - mainPanel.setName("loginMainPanel"); - mainPanel.add(southPanel, BorderLayout.SOUTH); - // - southPanel.add(confirmPanel, BorderLayout.NORTH); - southPanel.add(statusBar, BorderLayout.SOUTH); - //helpScollPane.getViewport().add(onlineHelp, null); - confirmPanel.addActionListener(this); - - CButton helpBtn = new CButton(Env.getImageIcon2("Help24")); - helpBtn.setActionCommand("onlineLoginHelp"); - helpBtn.addActionListener(this); - helpBtn.setToolTipText(res.getString("Help")); - confirmPanel.addComponent(helpBtn); - - statusBar.setStatusDB(null); - } // jbInit - - /** - * Set Initial & Ini Parameters - * Optional Automatic login - * @return true, if connected & parameters set - */ - public boolean initLogin() - { - m_cc = CConnection.get(); - hostField.setValue(m_cc); - - if ( Ini.isPropertyBool(Ini.P_VALIDATE_CONNECTION_ON_STARTUP)) { - validateConnection(); - } - - // Application/PWD - userTextField.setText(Ini.getProperty(Ini.P_UID)); - if (Ini.isPropertyBool(Ini.P_STORE_PWD)) - passwordField.setText(Ini.getProperty(Ini.P_PWD)); - else - passwordField.setText(""); - // - languageCombo.setSelectedItem(Ini.getProperty(Ini.P_LANGUAGE)); - - // AutoLogin - assumes that connection is OK - if (Ini.isPropertyBool(Ini.P_A_LOGIN)) - { - connectionOK (); - defaultsOK (); - if (m_connectionOK >= 0) // simulate - m_okPressed = true; - return m_connectionOK >= 0; - } - return false; - } // initLogin - - /** - * Window Events - requestFocus - * @param e event - */ - protected void processWindowEvent(WindowEvent e) - { - super.processWindowEvent(e); - if (e.getID() == WindowEvent.WINDOW_OPENED) - { - this.toFront(); - confirmPanel.getOKButton().requestFocusInWindow(); - } - } // processWindowEvent - - private void connectToDatabase() { - //Check connection - DB.setDBTarget(m_cc); - - //direct - DB.connect(); - } - - /** - * Validate Connection - */ - private void validateConnection() - { - m_connectionOK = -1; - - //make sure connecting to new database - DB.closeTarget(); - connectToDatabase(); - // - hostField.setDisplay(); - } // validateConnection - - - /************************************************************************* - * Exit action performed - */ - private void appExit() - { - m_connectionOK = -1; - dispose(); - } // appExit_actionPerformed - - - /** - * Return true, if logged in - * @return true if connected - */ - public boolean isConnected() - { - return m_connectionOK >= -1; - } // isConnected - - /** - * Did the user press OK - * @return true if user pressed final OK button - */ - public boolean isOKpressed() - { - return m_okPressed; - } // isOKpressed - - /************************************************************************** - * Action Event handler - * @param e event - */ - public void actionPerformed(ActionEvent e) - { - if (e.getActionCommand().equals(ConfirmPanel.A_OK)) - { - confirmPanel.getOKButton().setEnabled(false); - - if (loginTabPane.getSelectedIndex() == TAB_CONNECTION) { - connectionOK(); // first ok - printerField.refresh(); - } - else if (loginTabPane.getSelectedIndex() == TAB_CHANGE_PASSWORD) - { - validateChangePassword(); - } - else - { - setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); - m_okPressed = true; - // Dispose if OK - teo_sarca [ 1674663 ] - if(!defaultsOK()) - m_okPressed = false; - setCursor(Cursor.getDefaultCursor()); - } - - confirmPanel.getOKButton().setEnabled(true); - } - else if (e.getActionCommand().equals(ConfirmPanel.A_CANCEL)) - appExit(); - // - else if (e.getSource() == hostField) { - validateConnection(); - languageComboChanged(); - } - else if (e.getSource() == languageCombo) - languageComboChanged(); - // - else if (e.getSource() == clientCombo) - clientComboChanged(); - else if (e.getSource() == roleCombo) - roleComboChanged(); - else if (e.getSource() == orgCombo) - orgComboChanged(); - else if ("onlineLoginHelp".equals(e.getActionCommand())) - OnlineHelp.openInDefaultBrowser(); - } // actionPerformed - - - /************************************************************************** - * Connection OK pressed - */ - private void connectionOK () - { - log.info(""); - // - setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); - confirmPanel.getOKButton().setEnabled(false); - - m_connectionOK = tryConnection(); - - if (m_connectionOK >= 0) - { - // Verify Language & Load Msg - Language l = Language.getLoginLanguage(); - Env.verifyLanguage (m_ctx, l); - Env.setContext(m_ctx, Env.LANGUAGE, l.getAD_Language()); - Msg.getMsg(m_ctx, "0"); - - // Migration - MSystem system = MSystem.get(m_ctx); - if (system.isJustMigrated()) - { - statusBar.setStatusLine("Running: After Migration ....", true); - ADialog.info (m_WindowNo, this, "AfterMigration"); - Thread.yield(); - DB.afterMigration(m_ctx); - } - // Set Defaults - printerField.setValue(Ini.getProperty(Ini.P_PRINTER)); - - if (m_connectionOK == CONNECTED_OK_WITH_PASSWORD_EXPIRED) - loginTabPane.setSelectedIndex(TAB_CHANGE_PASSWORD); - else // Change Tab to Default - loginTabPane.setSelectedIndex(TAB_DEFAULTS); - } - - confirmPanel.getOKButton().setEnabled(true); - setCursor(Cursor.getDefaultCursor()); - } // connectionOK - - private void validateChangePassword() - { - String oldPassword = new String(txtOldPassword.getPassword()); - String newPassword = new String(txtNewPassword.getPassword()); - String retypeNewPassword = new String(txtRetypeNewPassword.getPassword()); - - String securityQuestion = null; - if (lstSecurityQuestion.getSelectedItem() != null) - securityQuestion = ((ValueNamePair) lstSecurityQuestion.getSelectedItem()).getName(); - String answer = txtAnswer.getText(); - - if (Util.isEmpty(oldPassword)) - { - statusBar.setStatusLine(Msg.getMsg(m_ctx, "OldPasswordMandatory"), true); - return; - } - - if (Util.isEmpty(retypeNewPassword)) - { - statusBar.setStatusLine(Msg.getMsg(m_ctx, "NewPasswordConfirmMandatory"), true); - return; - } - - if (!newPassword.equals(retypeNewPassword)) - { - statusBar.setStatusLine(Msg.getMsg(m_ctx, "PasswordNotMatch"), true); - return; - } - - if (Util.isEmpty(securityQuestion)) - { - statusBar.setStatusLine(Msg.getMsg(m_ctx, "SecurityQuestionMandatory"), true); - return; - } - - if (Util.isEmpty(answer)) - { - statusBar.setStatusLine(Msg.getMsg(m_ctx, "AnswerMandatory"), true); - return; - } - - String m_userPassword = new String(m_pwd); - if (!oldPassword.equals(m_userPassword)) - { - statusBar.setStatusLine(Msg.getMsg(m_ctx, "OldPasswordNoMatch"), true); - return; - } - - if (MSysConfig.getBooleanValue(MSysConfig.CHANGE_PASSWORD_MUST_DIFFER, true)) - { - if (oldPassword.equals(newPassword)) - { - statusBar.setStatusLine(Msg.getMsg(m_ctx, "NewPasswordMustDiffer"), true); - return; - } - } - - Trx trx = null; - try - { - String trxName = Trx.createTrxName("ChangePasswordTrx"); - trx = Trx.get(trxName, true); - - for (int index = 0; index < clientCombo.getItemCount(); index++) - { - KeyNamePair clientKNPair = (KeyNamePair) clientCombo.getItemAt(index); - int clientId = clientKNPair.getKey(); - Env.setContext(m_ctx, "#AD_Client_ID", clientId); - MUser user = MUser.get(m_ctx, m_user); - if (user == null) - { - trx.rollback(); - log.severe("Could not find user '" + m_user + "'"); - statusBar.setStatusLine("Could not find user '" + m_user + "'", true); - return; - } - - user.setPassword(newPassword); - user.setIsExpired(false); - user.setSecurityQuestion(securityQuestion); - user.setAnswer(answer); - if (!user.save(trx.getTrxName())) - { - trx.rollback(); - statusBar.setStatusLine("Could not update user", true); - return; - } - } - - trx.commit(); - } - catch (Exception e) - { - if (trx != null) - trx.rollback(); - } - finally - { - if (trx != null) - trx.close(); - } - - passwordField.setText(newPassword); - m_pwd = newPassword.toCharArray(); - m_connectionOK = CONNECTED_OK; - loginTabPane.setSelectedIndex(TAB_DEFAULTS); - } - - /** - * Change of tab <-> - * @param e event - */ - public void stateChanged(ChangeEvent e) - { -// if (loginTabPane.getSelectedIndex() == 3) // allow access to help -// return; - - if (!(String.valueOf(passwordField.getPassword()).equals(String.valueOf(m_pwd)) - && userTextField.getText().equals(m_user))) - m_connectionOK = -1; - // - if (m_connectionOK == CONNECTED_OK_WITH_PASSWORD_EXPIRED) - { - statusBar.setStatusLine(txt_PasswordExpired); - loginTabPane.setSelectedIndex(TAB_CHANGE_PASSWORD); - } - else if (m_connectionOK == CONNECTED_OK) - statusBar.setStatusLine(txt_LoggedIn); - else - { - statusBar.setStatusLine(txt_NotConnected, true); - loginTabPane.setSelectedIndex(TAB_CONNECTION); - } - confirmPanel.getOKButton().requestFocus(); - } // loginTabPane - - - /************************************************************************** - * Defaults OK pressed - * @return true if ok - */ - private boolean defaultsOK () - { - log.info(""); - - KeyNamePair org = (KeyNamePair)orgCombo.getSelectedItem(); - if (org == null) - return false; - - // Set Properties - Ini.setProperty(Ini.P_CONNECTION, CConnection.get().toStringLong()); - Ini.setProperty(Ini.P_LANGUAGE, (String)languageCombo.getSelectedItem()); - - String error = m_login.validateLogin(org); - if (error != null && error.length() > 0) - { - ADialog.info(m_WindowNo, this, error); - appExit(); - return false; - } - - // Load Properties and save Ini values - statusBar.setStatusLine("Loading Preferences"); - String msg = m_login.loadPreferences (org, - (KeyNamePair)warehouseCombo.getSelectedItem(), - dateField.getTimestamp(), printerField.getDisplay()); - if (msg.length() > 0) - ADialog.info(m_WindowNo, this, msg); - - // Check Apps Server - DB Checked in Menu - checkVersion(); // exits if conflict - - // Close - we are done - if (m_connectionOK >= 0) - this.dispose(); - return m_connectionOK >= 0; - } // defaultsOK - - - /************************************************************************** - * Try to connect. - * - Get Connection - * - Compare User info - * @return true if connected - */ - private int tryConnection() - { - m_user = userTextField.getText(); - m_pwd = passwordField.getPassword(); - - // Establish connection - if (!DB.isConnected(false)) - validateConnection(); - - if (!DB.isConnected(false)) - { - statusBar.setStatusLine(txt_NoDatabase, true); - hostField.setBackground(AdempierePLAF.getFieldBackground_Error()); - return NOT_CONNECTED; - } - - // Reference check - Ini.setProperty(Ini.P_ADEMPIERESYS, "Reference".equalsIgnoreCase(CConnection.get().getDbUid())); - - // Reference check - Ini.setProperty(Ini.P_LOGMIGRATIONSCRIPT, "Reference".equalsIgnoreCase(CConnection.get().getDbUid())); - - // Get Clients - m_login = new Login(m_ctx); - KeyNamePair[] clients = null; - try - { - clients = m_login.getClients(m_user, new String(m_pwd), ROLE_TYPES_SWING); - if (clients == null || clients.length == 0) - { - String loginErrMsg = m_login.getLoginErrMsg(); - if (loginErrMsg != null && loginErrMsg.length() > 0) - statusBar.setStatusLine(loginErrMsg, true); - else - statusBar.setStatusLine(txt_UserPwdError, true); - - userTextField.setBackground(AdempierePLAF.getFieldBackground_Error()); - passwordField.setBackground(AdempierePLAF.getFieldBackground_Error()); - return NOT_CONNECTED; - } - } - catch (Throwable e) - { - if (e.getCause() instanceof AccessException) - { - statusBar.setStatusLine(txt_UserPwdError, true); - userTextField.setBackground(AdempierePLAF.getFieldBackground_Error()); - passwordField.setBackground(AdempierePLAF.getFieldBackground_Error()); - return NOT_CONNECTED; - } - else - { - log.log(Level.SEVERE, CLogger.getRootCause(e).getLocalizedMessage(), CLogger.getRootCause(e)); - statusBar.setStatusLine(CLogger.getRootCause(e).getLocalizedMessage(), true); - return NOT_CONNECTED; - } - } - - // Delete existing role items - m_comboActive = true; - if (clientCombo.getItemCount() > 0) - clientCombo.removeAllItems(); - - // Initial role - KeyNamePair iniValue = null; - String iniDefault = Ini.getProperty(Ini.P_CLIENT); - - // fill roles - for (int i = 0; i < clients.length; i++) - { - clientCombo.addItem(clients[i]); - if (clients[i].getName().equals(iniDefault)) - iniValue = clients[i]; - } - if (iniValue != null){ - clientCombo.setSelectedItem(iniValue); - } else { - clientCombo.setSelectedItem(clients[0]); - } - - - if (clientCombo.getItemCount() == 1) - { - clientCombo.setSelectedIndex(0); - clientCombo.setVisible(false); - clientLabel.setVisible(false); - } - else - { - clientLabel.setVisible(true); - clientCombo.setVisible(true); - } - - userTextField.setBackground(AdempierePLAF.getFieldBackground_Normal()); - passwordField.setBackground(AdempierePLAF.getFieldBackground_Normal()); - // - this.setTitle(hostField.getDisplay()); - m_comboActive = false; - clientComboChanged(); - - if (m_login.isPasswordExpired()) - { - statusBar.setStatusLine(txt_PasswordExpired); - return CONNECTED_OK_WITH_PASSWORD_EXPIRED; - } - else - { - statusBar.setStatusLine(txt_LoggedIn); - return CONNECTED_OK; - } - } // tryConnection - - /** - * Client changed - fill Role List - */ - private void clientComboChanged () - { - KeyNamePair client = (KeyNamePair)clientCombo.getSelectedItem(); - if (client == null || m_comboActive) - return; - if (log.isLoggable(Level.CONFIG)) log.config(": " + client); - m_comboActive = true; - // @Trifon - Set Proper "#AD_Client_ID", #AD_User_ID and "#SalesRep_ID" - // https://sourceforge.net/tracker/?func=detail&aid=2957215&group_id=176962&atid=879332 - Env.setContext(m_ctx, "#AD_Client_ID", client.getKey()); - MUser user = MUser.get (m_ctx, userTextField.getText()); - if (user != null) { - Env.setContext(m_ctx, "#AD_User_Name", userTextField.getText()); - Env.setContext(m_ctx, "#AD_User_ID", user.getAD_User_ID()); - Env.setContext(m_ctx, "#SalesRep_ID", user.getAD_User_ID()); - } - // - KeyNamePair[] roles = m_login.getRoles(userTextField.getText(), client, ROLE_TYPES_SWING); - // Make role Combo visible - roleCombo.setVisible(true); - roleLabel.setVisible(true); - - // delete existing rol/org items - if (roleCombo.getItemCount() > 0) - roleCombo.removeAllItems(); - if (orgCombo.getItemCount() > 0) - orgCombo.removeAllItems(); - // No Clients - if (roles == null || roles.length == 0) - { - statusBar.setStatusLine(txt_RoleError, true); - m_comboActive = false; - return; - } - // initial rol - KeyNamePair iniValue = null; - String iniDefault = Ini.getProperty(Ini.P_ROLE); - - // fill roles - for (int i = 0; i < roles.length; i++) - { - roleCombo.addItem(roles[i]); - if (roles[i].getName().equals(iniDefault)) - iniValue = roles[i]; - } - // fini - if (iniValue != null) - roleCombo.setSelectedItem(iniValue); - // - // If we have only one role, we can hide the combobox - metas-2009_0021_AP1_G94 - if(roleCombo.getItemCount()==1 && ! MSysConfig.getBooleanValue(MSysConfig.ALogin_ShowOneRole, true)) - { - roleCombo.setSelectedIndex(0); - roleCombo.setVisible(false); - roleLabel.setVisible(false); - - } - - m_comboActive = false; - roleComboChanged(); - } // roleComboChanged - - - /** - * role changed - fill Org & Warehouse List - */ - private void roleComboChanged() - { - KeyNamePair rol = (KeyNamePair)roleCombo.getSelectedItem(); - if (rol == null || m_comboActive) - return; - if (log.isLoggable(Level.CONFIG)) log.config(": " + rol); - m_comboActive = true; - - if( Env.getContextAsInt(m_ctx, "#AD_Client_ID") > 0 ) - { - MUser user = MUser.get (m_ctx, userTextField.getText()); - if (user != null) { - Env.setContext(m_ctx, "#AD_User_ID", user.getAD_User_ID() ); - Env.setContext(m_ctx, "#SalesRep_ID", user.getAD_User_ID() ); - } - } - - // - KeyNamePair[] orgs = m_login.getOrgs(rol); - // delete existing cleint items - if (orgCombo.getItemCount() > 0) - orgCombo.removeAllItems(); - - // No Orgs - if (orgs == null || orgs.length == 0) - { - statusBar.setStatusLine(txt_RoleError, true); - m_comboActive = false; - return; - } - // initial client - KeyNamePair orgValue = null; - KeyNamePair orgValue2 = null; - String iniDefault = Ini.getProperty(Ini.P_ORG); - - // fill orgs - for (int i = 0; i < orgs.length; i++) - { - orgCombo.addItem(orgs[i]); - if (orgs[i].getName().equals(iniDefault)) - orgValue = orgs[i]; - if (orgValue2 == null && orgs[i].getKey() != 0) - orgValue2 = orgs[i]; // first non-0 org - } - // Non-0 Org exists and last login was with 0 - if (orgValue2 != null && orgValue != null && orgValue.getKey() == 0) - orgValue = orgValue2; - // Last Org - if (orgValue != null) - orgCombo.setSelectedItem(orgValue); - // Get first Org - else - orgValue = (KeyNamePair)orgCombo.getSelectedItem(); - // - m_comboActive = false; - orgComboChanged(); - } // clientComboChanged - - /** - * Org changed - fill Warehouse List - */ - private void orgComboChanged() - { - KeyNamePair org = (KeyNamePair)orgCombo.getSelectedItem(); - if (org == null || m_comboActive) - return; - if (log.isLoggable(Level.CONFIG)) log.config(": " + org); - m_comboActive = true; - // - KeyNamePair[] whs = m_login.getWarehouses(org); - // Delete existing warehouse items - if (warehouseCombo.getItemCount() > 0) - warehouseCombo.removeAllItems(); - - // fill warehouses - if (whs != null) - { - // initial warehouse - KeyNamePair iniValue = null; - String iniDefault = Ini.getProperty(Ini.P_WAREHOUSE); - for (int i = 0; i < whs.length; i++) - { - warehouseCombo.addItem(whs[i]); - if (whs[i].getName().equals(iniDefault)) - iniValue = whs[i]; - } - if (iniValue != null) - warehouseCombo.setSelectedItem(iniValue); - } - m_comboActive = false; - } // orgComboChanged - - - /** - * Check Version - * @return true if version is OK and - * false if version could not be checked or is not the same - * @see AEnv#getServerVersion - */ - private boolean checkVersion() - { - boolean retValue = false; - try - { - String version = AEnv.getServerVersion(); - if (Adempiere.DATE_VERSION.equals(version)) - { - if (log.isLoggable(Level.CONFIG)) log.config("Server = Client - " + version); - retValue = true; - } - else if (version != null) - { - StringBuilder msg = new StringBuilder (">>\n"); - msg.append(res.getString("VersionConflict")).append("\n") - .append(res.getString("VersionInfo")).append("\n"); - msg.append(version == null ? "null" : version).append(" <> ") - .append(Adempiere.DATE_VERSION).append("\n"); - msg.append(res.getString("PleaseUpgrade")).append("\n<<"); - JOptionPane.showMessageDialog(null, msg.toString(), - Adempiere.getName() + " - " + res.getString("VersionConflict"), - JOptionPane.ERROR_MESSAGE); - AEnv.exit(1); - } - } - catch (Exception e) - { - log.severe("Contact Server failed - " - + e.getClass().toString() + ": " + e.getMessage()); - } - return retValue; - } // checkVersion - - - /************************************************************************** - * Language issues - */ - private String // txt_Connected, - txt_NotConnected, txt_NoDatabase, - txt_UserPwdError, txt_RoleError, txt_LoggedIn, - txt_PasswordExpired; - - /** - * Change Language - */ - private void languageComboChanged () - { - String langName = (String)languageCombo.getSelectedItem(); - // log.info( "Language: " + langName); - Language language = Language.getLanguage(langName); - Language.setLoginLanguage(language); - Env.setContext(m_ctx, Env.LANGUAGE, language.getAD_Language()); - - // Locales - Locale loc = language.getLocale(); - Locale.setDefault(loc); - this.setLocale(loc); - res = ResourceBundle.getBundle(RESOURCE, loc); - // - this.setTitle(res.getString("Login")); - hostLabel.setText(res.getString("Host")); - boolean email_login = (DB.isConnected() && MSysConfig.getBooleanValue(MSysConfig.USE_EMAIL_FOR_LOGIN, false)); - if (email_login) - userLabel.setText(res.getString("EMail")); - else - userLabel.setText(res.getString("User")); - userLabel.setToolTipText(res.getString("EnterUser")); - passwordLabel.setText(res.getString("Password")); - passwordLabel.setToolTipText(res.getString("EnterPassword")); - languageLabel.setText(res.getString("Language")); - languageLabel.setToolTipText(res.getString("SelectLanguage")); - // - roleLabel.setText(res.getString("Role")); - clientLabel.setText(res.getString("Client")); - orgLabel.setText(res.getString("Organization")); - dateLabel.setText(res.getString("Date")); - warehouseLabel.setText(res.getString("Warehouse")); - printerLabel.setText(res.getString("Printer")); - defaultPanel.setToolTipText(res.getString("Defaults")); - connectionPanel.setToolTipText(res.getString("Connection")); - // - // txt_Connected = res.getString("Connected"); - txt_NotConnected = res.getString("NotConnected"); - txt_NoDatabase = res.getString("DatabaseNotFound"); - txt_UserPwdError = res.getString("UserPwdError"); - txt_RoleError = res.getString("RoleNotFound"); - txt_LoggedIn = res.getString("Authorized"); - txt_PasswordExpired = res.getString("PasswordExpired"); - // - loginTabPane.setTitleAt(0, res.getString("Connection")); - if (loginTabPane.getTabCount() > 1) - loginTabPane.setTitleAt(1, res.getString("Defaults")); - confirmPanel.getOKButton().setToolTipText(res.getString("Ok")); - confirmPanel.getCancelButton().setToolTipText(res.getString("Cancel")); - - // DateField with new format - dateField.setFormat(); - dateField.setValue(new Timestamp(System.currentTimeMillis())); - // - if (m_connectionOK == CONNECTED_OK) - { - this.setTitle(hostField.getDisplay()); - statusBar.setStatusLine(txt_LoggedIn); - } - else if (m_connectionOK == CONNECTED_OK_WITH_PASSWORD_EXPIRED) - { - this.setTitle(hostField.getDisplay()); - statusBar.setStatusLine(txt_PasswordExpired); - } - else - { - this.setTitle(res.getString("Login")); - statusBar.setStatusLine(txt_NotConnected, true); - } - } // languageCombo_actionPerformed - -} // ALogin diff --git a/org.adempiere.ui.swing/src/org/compiere/apps/ALoginTest.java b/org.adempiere.ui.swing/src/org/compiere/apps/ALoginTest.java deleted file mode 100644 index 43d93eb20e..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/apps/ALoginTest.java +++ /dev/null @@ -1,441 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ -package org.compiere.apps; - -import java.awt.BorderLayout; -import java.awt.Dialog; -import java.awt.Dimension; -import java.awt.FlowLayout; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.io.IOException; -import java.net.InetAddress; -import java.net.Socket; -import java.net.UnknownHostException; -import java.sql.Connection; -import java.sql.DatabaseMetaData; -import java.sql.DriverManager; -import java.sql.ResultSet; -import java.sql.SQLException; -import java.sql.Statement; - -import javax.swing.JButton; -import javax.swing.JDialog; -import javax.swing.JScrollPane; -import javax.swing.JTextArea; - -import org.adempiere.plaf.AdempierePLAF; -import org.compiere.swing.CDialog; -import org.compiere.swing.CPanel; - -/** - * Connection Test - * ** Not Translated ** - * - * @author Jorg Janke - * @version $Id: ALoginTest.java,v 1.2 2006/07/30 00:51:27 jjanke Exp $ - */ -public class ALoginTest extends CDialog - implements ActionListener, Runnable -{ - /** - * - */ - private static final long serialVersionUID = 23728881908041435L; - - /** - * Consatructor - */ - public ALoginTest (Dialog frame, String host, String dbName, String port, String uid, String pwd) - { - super (frame, "Connect Test: " + host, true); - m_host = host; - m_dbName = dbName; - m_port = port; - m_uid = uid; - m_pwd = pwd; - try - { - jbInit(); - pack(); - } - catch(Exception ex) - { - inform ("Internal Error = " + ex.getMessage()); - } - // Start Tests - try - { - m_worker = new Thread(this); - m_worker.start(); - } - catch (Exception e1) - { - inform ("Internal Error = " + e1); - } - AEnv.showCenterScreen(this); - } // ALoginTest - - private String m_host; - private String m_port; - private String m_dbName; - private String m_uid; - private String m_pwd; - private Thread m_worker; - - private CPanel mainPanel = new CPanel(); - private BorderLayout mainLayout = new BorderLayout(); - private CPanel southPanel = new CPanel(); - private JButton bOK = new JButton(); - private JScrollPane infoPane = new JScrollPane(); - private JTextArea info = new JTextArea(); - private FlowLayout southLayout = new FlowLayout(); - - /** - * Static Layout - */ - void jbInit() throws Exception - { - setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE); - mainPanel.setLayout(mainLayout); - bOK.setText("Exit"); - bOK.addActionListener(this); - info.setBackground(AdempierePLAF.getFieldBackground_Inactive()); - southPanel.setLayout(southLayout); - southLayout.setAlignment(FlowLayout.RIGHT); - infoPane.setPreferredSize(new Dimension(400, 400)); - getContentPane().add(mainPanel); - mainPanel.add(southPanel, BorderLayout.SOUTH); - southPanel.add(bOK, null); - mainPanel.add(infoPane, BorderLayout.CENTER); - infoPane.getViewport().add(info, null); - } // jbInit - - /** - * Inform - */ - private void inform (String text) - { - System.out.println(text); - info.append(text); - info.append("\n"); - info.setCaretPosition(info.getText().length()); - } // inform - - /** - * Action Listener - */ - public void actionPerformed (ActionEvent e) - { - if (e.getSource() == bOK) - { - while (m_worker != null && m_worker.isAlive()) - m_worker.interrupt(); - dispose(); - } - } // actionEvent - - /** - * Run individual tests - */ - public void run () - { - String vmName = System.getProperty("java.vm.name"); - String vmVersion = System.getProperty("java.vm.version"); - inform ("Using Java=" + vmName + " " + vmVersion); - inform (""); - // - boolean found = false; - boolean foundJDBC = false; - inform("*** Testing connection to Server: " + m_host + " ***"); - if (m_host == null || m_host.length() == 0) - { - inform ("ERROR: invalid host name"); - return; - } - String host = m_host; - inform("Trying Echo - Port 7"); - found = testHostPort(host, 7); - - inform("Trying FTP - Port 21"); - if (testHostPort (host, 21) && !found) - found = true; - - inform("Trying HTTP - Port 80"); - if (testHostPort (host, 80) && !found) - found = true; - - inform("Trying Kerberos - Port 88"); - if (testHostPort (host, 88) && !found) - found = true; - - inform("Trying NetBios Session - Port 139"); - if (testHostPort (host, 139) && !found) - found = true; - - inform("Trying RMI - Port 1099"); - if (testHostPort (host, 1099) && !found) - found = true; - - inform("Trying Oracle Connection Manager - Port 1630"); - if (testHostPort (host, 1630) && !found) - found = true; - - inform("Trying Oracle JDBC - TCP Port 1521"); - foundJDBC = testHostPort (host, 1521); - - int jdbcPort = 0; - try - { - jdbcPort = Integer.parseInt(m_port); - } - catch (Exception e) - { - inform ("ERROR: Cannot parse port=" + m_port); - inform (e.getMessage()); - return; - } - if (jdbcPort != 1521) - { - inform("Trying Oracle JDBC - TCP Port " + jdbcPort); - if (testHostPort (host, jdbcPort) && !foundJDBC) - foundJDBC = true; - } - - // Test Interrupt - if (m_worker != null && m_worker.isInterrupted()) - return; - - /** Info */ - - if (found && foundJDBC) - { - inform ("*** Server found: " + host + " ***"); - inform (""); - } - else if (!found && foundJDBC) - { - inform ("*** Server found: " + host + " (JDBC only) ***"); - inform (""); - } - else if (found && !foundJDBC) - { - inform ("ERROR: Server found: " + host + " - but no JDBC ***"); - inform ("Make sure that the Oracle Listener process is active"); - return; - } - else - { - inform ("ERROR: Server NOT found: " + host + "***"); - inform ("End Test: Make sure that you can ping the Server"); - return; - } - - /*********************************************************************/ - - inform ("Connect to DB: " + m_dbName); - - inform ("Connect with entered parameters"); - if (!testJDBC(host, jdbcPort, m_dbName, m_uid, m_pwd)) - { - if (m_worker != null && m_worker.isInterrupted()) - return; - - if (jdbcPort != 1521) - { - inform ("Connect with standard JDBC port 1521"); - if (testJDBC(host, 1521, m_dbName, m_uid, m_pwd)) - { - inform ("Please set port to 1521"); - return; - } - if (m_worker != null && m_worker.isInterrupted()) - return; - } - - inform ("Connect with user system/manager"); - if (testJDBC(host, 1521, m_dbName, "system", "manager")) - { - inform ("Please check ADEMPIERE user id and password"); - inform (".... and please change SYSTEM password"); - return; - } - } - - inform ("*** Adempiere database found: " + host + ":" + jdbcPort + "/" + m_dbName + " ***"); - if (m_worker != null && m_worker.isInterrupted()) - return; - - /*********************************************************************/ - - inform (""); - inform ("Testing available application users:"); - testAdempiereUsers(host, jdbcPort); - - inform (""); - inform ("*** Test complete **"); - } // run - - /** - * Test Host Port - */ - private boolean testHostPort (String host, int port) - { - Socket pingSocket = null; - try - { - /* Resolve address. */ - InetAddress server = InetAddress.getByName(host); - /* Establish socket. */ - pingSocket = new Socket(server, port); - } - catch (UnknownHostException e) - { - inform (" Unknown Host: " + e ); - } - catch (IOException io ) - { - inform (" IO Exception: " + io ); - } - - if (pingSocket != null) - { - try - { - pingSocket.close(); - } - catch (IOException e) - { - inform (" IO close exception: " + e ); - } - inform (" *** success ***"); - return true; - } - else - { - return false; - } - } // testHostPort - - /** - * Test JDBC - */ - private boolean testJDBC (String host, int port, String sid, String uid, String pwd) - { - /** - try - { - inform (" Registering Driver: oracle.jdbc.driver.OracleDriver"); - DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver()); - inform (" - driver registered"); - DriverManager.setLoginTimeout(5); - DriverManager.setLogWriter(new PrintWriter(System.out)); - inform (" - driver initialized"); - } - catch (SQLException e) - { - inform ("ERROR: " + e.getMessage()); - return false; - } - **/ - - boolean ok = false; - - String urlC = "jdbc:oracle:thin:@//" + host + ":" + port + "/" + sid; - try - { - inform (" Trying Client connection URL=" + urlC + ", User=" + uid); - Connection con = DriverManager.getConnection(urlC, uid, pwd); - inform (" - connected"); - // - DatabaseMetaData conMD = con.getMetaData(); - inform(" - Driver Name:\t" + conMD.getDriverName()); - inform(" - Driver Version:\t" + conMD.getDriverVersion()); - inform(" - DB Name:\t" + conMD.getDatabaseProductName()); - inform(" - DB Version:\t" + conMD.getDatabaseProductVersion()); - // - con.close(); - inform (" *** success ***"); - ok = true; - } - catch (SQLException e) - { - inform (" ERROR: " + e.getMessage()); - } - - String urlS = "jdbc:oracle:oci8:@"; - try - { - inform (" Trying Server connection URL=" + urlS + ", User=" + uid); - Connection con = DriverManager.getConnection(urlS, uid, pwd); - inform (" - connected"); - // - DatabaseMetaData conMD = con.getMetaData(); - inform(" - Driver Name:\t" + conMD.getDriverName()); - inform(" - Driver Version:\t" + conMD.getDriverVersion()); - inform(" - DB Name:\t" + conMD.getDatabaseProductName()); - inform(" - DB Version:\t" + conMD.getDatabaseProductVersion()); - // - con.close(); - inform (" *** success ***"); - } - catch (SQLException e) - { - inform (" ERROR: " + e.getMessage()); - } - - return ok; - } // testJDBC - - /** - * Test Adempiere Users - */ - private void testAdempiereUsers(String host, int port) - { - String sql = "SELECT Name, Password FROM AD_User WHERE IsActive='Y'"; - String urlC = "jdbc:oracle:thin:@//" + host + ":" + port + "/" + m_dbName; - try - { - inform (" - Client connection URL=" + urlC + ", User=" + m_uid); - Connection con = DriverManager.getConnection(urlC, m_uid, m_pwd); - inform (" - connected"); - Statement stmt = con.createStatement(); - inform (" - statement created"); - ResultSet rs = stmt.executeQuery(sql); - inform (" - query executed listing active application users:"); - while (rs.next()) - { - String user = rs.getString(1); - String password = rs.getString(2); - String answer = ">> User = " + user; - if ((user.equals("System") || user.equals("SuperUser")) && password.equals("System")) - answer += " with standard password (should be changed)"; - inform (answer); - } - rs.close(); - inform (" - query closed"); - stmt.close(); - inform (" - statement closed"); - con.close(); - inform (" - connection closed"); - } - catch (SQLException e) - { - inform (" ERROR: " + e.getMessage()); - } - } // testAdempiereUsers -} // ALoginTest diff --git a/org.adempiere.ui.swing/src/org/compiere/apps/AMenu.java b/org.adempiere.ui.swing/src/org/compiere/apps/AMenu.java deleted file mode 100644 index b0ea2a3932..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/apps/AMenu.java +++ /dev/null @@ -1,839 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ -package org.compiere.apps; - -import java.awt.BorderLayout; -import java.awt.Cursor; -import java.awt.Dimension; -import java.awt.Frame; -import java.awt.GridLayout; -import java.awt.Insets; -import java.awt.KeyboardFocusManager; -import java.awt.Point; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.awt.event.KeyEvent; -import java.awt.event.MouseAdapter; -import java.awt.event.MouseEvent; -import java.awt.event.WindowEvent; -import java.awt.event.WindowListener; -import java.beans.PropertyChangeEvent; -import java.beans.PropertyChangeListener; -import java.math.BigDecimal; -import java.text.MessageFormat; -import java.util.Properties; -import java.util.UUID; -import java.util.logging.Level; - -import javax.swing.BorderFactory; -import javax.swing.Box; -import javax.swing.JComponent; -import javax.swing.JFrame; -import javax.swing.JMenu; -import javax.swing.JMenuBar; -import javax.swing.JProgressBar; -import javax.swing.KeyStroke; -import javax.swing.UIManager; -import javax.swing.event.ChangeEvent; -import javax.swing.event.ChangeListener; - -import org.adempiere.apps.graph.PAPanel; -import org.adempiere.plaf.AdempierePLAF; -import org.compiere.Adempiere; -import org.compiere.apps.wf.WFActivity; -import org.compiere.apps.wf.WFPanel; -import org.compiere.grid.tree.VTreePanel; -import org.compiere.model.MRole; -import org.compiere.model.MSession; -import org.compiere.model.MSysConfig; -import org.compiere.model.MSystem; -import org.compiere.model.MTreeNode; -import org.compiere.model.MUser; -import static org.compiere.model.SystemIDs.*; -import org.compiere.swing.CButton; -import org.compiere.swing.CFrame; -import org.compiere.swing.CPanel; -import org.compiere.swing.CScrollPane; -import org.compiere.swing.CTabbedPane; -import org.compiere.util.CLogger; -import org.compiere.util.DB; -import org.compiere.util.Env; -import org.compiere.util.IEnvEventListener; -import org.compiere.util.Ini; -import org.compiere.util.Language; -import org.compiere.util.Msg; -import org.compiere.util.Splash; -/** - * Application Menu Controller - * - * @author Jorg Janke - * @version $Id: AMenu.java,v 1.2 2006/07/30 00:51:27 jjanke Exp $ - * - * @author Colin Rooney (croo) RFE#1670185 restrict access to info queries - * @author victor.perez@e-evolution.com - *

  • FR [ 1966328 ] New Window Info to MRP and CRP into View - *
  • http://sourceforge.net/tracker/index.php?func=detail&aid=1966328&group_id=176962&atid=879335 - *
  • BF[2992649] Issue in Workflow Activities when the records are ordered - *
  • https://sourceforge.net/tracker/?func=detail&aid=2992649&group_id=176962&atid=879332 - * - */ -public final class AMenu extends CFrame - implements ActionListener, PropertyChangeListener, ChangeListener, IEnvEventListener -{ - /** - * generated serialVersionUID - */ - private static final long serialVersionUID = 5255914306969824011L; - - static { - AdempierePLAF.setPLAF (); - } - - /** - * Application Start and Menu - */ - public AMenu () - { - super(); - - UIManager.put( "ClassLoader", this.getClass().getClassLoader()); - - Splash splash = Splash.getSplash(); - // - m_WindowNo = AEnv.createWindowNo(this); - // Login - initSystem (splash); // login - splash.setText(Msg.getMsg(m_ctx, "Loading")); - splash.toFront(); - splash.paint(splash.getGraphics()); - - // - if (!Adempiere.startupEnvironment(true)) // Load Environment - System.exit(1); - MSession session = MSession.get (Env.getCtx(), true); // Start Session - session.setWebSession(UUID.randomUUID().toString()); - session.setDescription(session.getDescription() + " " + "Swing Client"); - session.saveEx(); - - // Setting close operation/listener - teo_sarca [ 1684168 ] - setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE); - addWindowListener(new WindowListener() { - public void windowClosing(WindowEvent e) { - if (!ADialog.ask(0, null, "ExitApplication?")) - return; - dispose(); - } - public void windowActivated(WindowEvent e) {} - public void windowClosed(WindowEvent e) {} - public void windowDeactivated(WindowEvent e) {} - public void windowDeiconified(WindowEvent e) {} - public void windowIconified(WindowEvent e) {} - public void windowOpened(WindowEvent e) {} - }); - - // Preparation - wfActivity = new WFActivity(this); - wfPanel = new WFPanel(this); - treePanel = new VTreePanel (m_WindowNo, true, false); // !editable & hasBar - - try - { - jbInit(); - createMenu(); - } - catch(Exception ex) - { - log.log(Level.SEVERE, "AMenu", ex); - } - - // initialize & load tree - int AD_Role_ID = Env.getAD_Role_ID(Env.getCtx()); - int AD_Tree_ID = DB.getSQLValue(null, - "SELECT COALESCE(r.AD_Tree_Menu_ID, ci.AD_Tree_Menu_ID)" - + "FROM AD_ClientInfo ci" - + " INNER JOIN AD_Role r ON (ci.AD_Client_ID=r.AD_Client_ID) " - + "WHERE AD_Role_ID=?", AD_Role_ID); - if (AD_Tree_ID <= 0) - AD_Tree_ID = TREE_MENUPRIMARY; // Menu - treePanel.initTree(AD_Tree_ID); - - // Translate - Env.setContext(m_ctx, m_WindowNo, "_WinInfo_WindowName", Msg.getMsg(m_ctx, "Menu")); - setTitle(Env.getHeader(m_ctx, m_WindowNo)); - - progressBar.setString(Msg.getMsg(m_ctx, "SelectProgram")); - - // Finish UI - Point loc = Ini.getWindowLocation(0); - if (loc == null) - loc = new Point(0,0); - this.setLocation(loc); - this.pack(); - this.setVisible(true); - if (Ini.isPropertyBool(Ini.P_OPEN_WINDOW_MAXIMIZED)) - this.setExtendedState(Frame.MAXIMIZED_BOTH); - else - this.setState(Frame.NORMAL); - this.validate(); - m_AD_User_ID = Env.getContextAsInt(m_ctx, "#AD_User_ID"); - m_AD_Role_ID = Env.getContextAsInt(m_ctx, "#AD_Role_ID"); - updateInfo(); - // - infoUpdater = new InfoUpdater(); - infoUpdaterThread = new Thread(infoUpdater, "InfoUpdater"); - infoUpdaterThread.start(); - - // Auto Expand Tree - nmicoud IDEMPIERE 195 - if (MUser.get(m_ctx).isMenuAutoExpand()) - treePanel.expandTree(true); - // Auto Expand Tree - nmicoud IDEMPIERE 195 - - Env.setContext(Env.getCtx(), "#UIClient", "swing"); - - // - Env.addEventListener(this); - // -// ReportCtl.setReportViewerProvider(new SwingViewerProvider()); - // - splash.dispose(); - splash = null; - } // AMenu - - private int m_WindowNo; - private Properties m_ctx = Env.getCtx(); - private boolean m_startingItem = false; - /** The User */ - private int m_AD_User_ID; - /** The Role */ - private int m_AD_Role_ID; - - /** Center Tabbed Pane index: Menu */ - @SuppressWarnings("unused") - private int m_tabMenu = 0; - /** Center Tabbed Pane index: Activities */ - private int m_tabActivities = 1; - /** Center Tabbed Pane index: Workflow */ - private int m_tabWorkflow = 2; - - // Links - private int m_request_Menu_ID = 0; - private int m_note_Menu_ID = 0; - private String m_requestSQL = null; -// private DecimalFormat m_memoryFormat = DisplayType.getNumberFormat(DisplayType.Integer); - /** Logger */ - private static CLogger log = CLogger.getCLogger(AMenu.class); - - /** The Info Update instance **/ - private InfoUpdater infoUpdater = null; - /** The Info Update thread **/ - private Thread infoUpdaterThread = null; - - private WindowManager windowManager = new WindowManager(); - - - /************************************************************************** - * Init System. - * -- do not get Msg as environment not initialized yet -- - *
    -	 *	- Login - in not successful, exit
    -	 *  
    - * @param splash splash window - */ - private void initSystem (Splash splash) - { - // Default Image - this.setIconImage(Adempiere.getImage16()); - - // Focus Traversal - KeyboardFocusManager.setCurrentKeyboardFocusManager(AKeyboardFocusManager.get()); - // FocusManager.getCurrentManager().setDefaultFocusTraversalPolicy(AFocusTraversalPolicy.get()); - // this.setFocusTraversalPolicy(AFocusTraversalPolicy.get()); - - /** - * Show Login Screen - if not successful - exit - */ - log.finer("Login"); - - ALogin login = new ALogin(splash); - if (!login.initLogin()) // no automatic login - { - // Center the window - try - { - AEnv.showCenterScreen(login); // HTML load errors - } - catch (Exception ex) - { - log.severe(ex.toString()); - } - if (!login.isConnected() || !login.isOKpressed()) - AEnv.exit(1); - } - } // initSystem - - // UI - private CPanel mainPanel = new CPanel(); - private BorderLayout mainLayout = new BorderLayout(); - private CTabbedPane centerPane = new CTabbedPane(); - private CPanel southPanel = new CPanel(); - private BorderLayout southLayout = new BorderLayout(); - private JMenuBar menuBar = new JMenuBar(); - protected JProgressBar progressBar = new JProgressBar(0,100); - private CPanel infoPanel = new CPanel(); - private CButton bNotes = new CButton(); - private CButton bRequests = new CButton(); - private GridLayout infoLayout = new GridLayout(); - private JProgressBar memoryBar = new JProgressBar(); - // Tabs - private PAPanel paPanel = null; - private VTreePanel treePanel = null; - private WFActivity wfActivity = null; - private WFPanel wfPanel = null; - private WindowMenu m_WindowMenu; - - /** - * Static Init. - *
    -	 *  - mainPanel
    -	 * 		- centerPane
    -	 *      	- treePanel
    -	 * 			- wfActivity
    -	 * 			- wfPanel
    -	 *      - southPanel
    -	 *          - infoPanel
    -	 *              - bNotes
    -	 *              - bTask
    -	 *              - memoryBar
    -	 *          - wfPanel
    -	 *          - progressBar
    -	 *  
    - * @throws Exception - */ - void jbInit() throws Exception - { - this.setName("Menu"); - this.setLocale(Language.getLoginLanguage().getLocale()); - this.setJMenuBar(menuBar); - // - mainPanel.setLayout(mainLayout); - mainLayout.setHgap(0); - mainLayout.setVgap(2); - // - treePanel.addPropertyChangeListener(VTreePanel.NODE_SELECTION, this); - // - infoPanel.setLayout(infoLayout); - infoLayout.setColumns(2); - infoLayout.setHgap(4); - infoLayout.setVgap(0); - // bNotes.setRequestFocusEnabled(false); - bNotes.setToolTipText(""); - bNotes.setActionCommand("Notes"); - bNotes.addActionListener(this); - bNotes.setIcon(Env.getImageIcon("GetMail24.gif")); - bNotes.setMargin(new Insets(0, 0, 0, 0)); - // bRequests.setRequestFocusEnabled(false); - bRequests.setActionCommand("Requests"); - bRequests.addActionListener(this); - bRequests.setIcon(Env.getImageIcon("Request24.gif")); - bRequests.setMargin(new Insets(0, 0, 0, 0)); - // - southLayout.setHgap(0); - southLayout.setVgap(1); - // - memoryBar.setStringPainted(true); - memoryBar.setOpaque(false); - memoryBar.setBorderPainted(false); - memoryBar.addMouseListener(new AMenu_MouseAdapter()); - // - progressBar.setStringPainted(true); - progressBar.setOpaque(false); - // - getContentPane().add(mainPanel); - mainPanel.add(centerPane, BorderLayout.CENTER); - mainPanel.add(southPanel, BorderLayout.SOUTH); - mainPanel.add(Box.createHorizontalStrut(3), BorderLayout.EAST); - mainPanel.add(Box.createHorizontalStrut(3), BorderLayout.WEST); - - // Tabs - centerPane.setFont(centerPane.getFont().deriveFont(centerPane.getFont().getSize2D()+1)); - paPanel = PAPanel.get(); - if (paPanel != null) - { - //centerPane.add(paPanel, Msg.getMsg(m_ctx, "PAPanel")); - centerPane.addTab(Msg.getMsg(m_ctx, "PAPanel"), Env.getImageIcon2("InfoAccount16"), paPanel); - m_tabMenu++; - m_tabActivities++; - m_tabWorkflow++; - } - treePanel.setBorder(BorderFactory.createEmptyBorder(2,3,2,3)); - //centerPane.add(treePanel, Msg.getMsg(m_ctx, "Menu")); - centerPane.addTab(Msg.getMsg(m_ctx, "Menu"), Env.getImageIcon2("Home16"), treePanel); - //centerPane.add(new CScrollPane(wfActivity), Msg.getMsg (m_ctx, "WorkflowActivities") + ": 0"); - centerPane.addTab(Msg.getMsg (m_ctx, "WorkflowActivities") + ": 0", Env.getImageIcon2("Assignment16"), new CScrollPane(wfActivity)); - //centerPane.add(new CScrollPane(wfPanel), Msg.getMsg (m_ctx, "WorkflowPanel")); - centerPane.addTab(Msg.getMsg (m_ctx, "WorkflowPanel"), Env.getImageIcon2("WorkFlow16"), new CScrollPane(wfPanel)); - centerPane.addChangeListener (this); - // - southPanel.setLayout(southLayout); - southPanel.add(infoPanel, BorderLayout.NORTH); - southPanel.add(progressBar, BorderLayout.SOUTH); - // - infoPanel.add(bNotes, null); - infoPanel.add(bRequests, null); - infoPanel.add(memoryBar, null); - // - int loc = Ini.getDividerLocation(); - if (loc > 0) - treePanel.setDividerLocation(loc); - } // jbInit - - /** - * Get Preferred Size - * @return preferred Size - */ - public Dimension getPreferredSize() - { - Dimension dim = Ini.getWindowDimension(0); - if (dim == null) - dim = new Dimension (350, 500); - return dim; - } // getPreferredSize - - - /** - * Create Menu - */ - private void createMenu() - { - // File - JMenu mFile = AEnv.getMenu("File"); - menuBar.add(mFile); - AEnv.addMenuItem("PrintScreen", null, KeyStroke.getKeyStroke(KeyEvent.VK_PRINTSCREEN, 0), mFile, this); - AEnv.addMenuItem("ScreenShot", null, KeyStroke.getKeyStroke(KeyEvent.VK_PRINTSCREEN, ActionEvent.SHIFT_MASK), mFile, this); - mFile.addSeparator(); - AEnv.addMenuItem("Logout", null, KeyStroke.getKeyStroke(KeyEvent.VK_L, ActionEvent.SHIFT_MASK + ActionEvent.ALT_MASK), mFile, this); - AEnv.addMenuItem("Exit", null, KeyStroke.getKeyStroke(KeyEvent.VK_X, ActionEvent.SHIFT_MASK+ActionEvent.ALT_MASK), mFile, this); - - // View - JMenu mView = AEnv.getMenu("View"); - menuBar.add(mView); - - if (MRole.getDefault().isAllow_Info_Product()) - { - AEnv.addMenuItem("InfoProduct", null, KeyStroke.getKeyStroke(KeyEvent.VK_I, ActionEvent.ALT_MASK), mView, this); - } - if (MRole.getDefault().isAllow_Info_BPartner()) - { - AEnv.addMenuItem("InfoBPartner", null, KeyStroke.getKeyStroke(KeyEvent.VK_I, ActionEvent.ALT_MASK+ActionEvent.CTRL_MASK), mView, this); - } - if (MRole.getDefault().isShowAcct() && MRole.getDefault().isAllow_Info_Account()) - { - AEnv.addMenuItem("InfoAccount", null, KeyStroke.getKeyStroke(KeyEvent.VK_I, ActionEvent.ALT_MASK+ActionEvent.CTRL_MASK), mView, this); - } - if (MRole.getDefault().isAllow_Info_Schedule()) - { - AEnv.addMenuItem("InfoSchedule", null, null, mView, this); - } - //FR [ 1966328 ] -// if (MRole.getDefault().isAllow_Info_MRP()) -// { -// AEnv.addMenuItem("InfoMRP", "Info", null, mView, this); -// } -// if (MRole.getDefault().isAllow_Info_CRP()) -// { -// AEnv.addMenuItem("InfoCRP", "Info", null, mView, this); -// } - mView.addSeparator(); - if (MRole.getDefault().isAllow_Info_Order()) - { - AEnv.addMenuItem("InfoOrder", "Info", null, mView, this); - } - if (MRole.getDefault().isAllow_Info_Invoice()) - { - AEnv.addMenuItem("InfoInvoice", "Info", null, mView, this); - } - if (MRole.getDefault().isAllow_Info_InOut()) - { - AEnv.addMenuItem("InfoInOut", "Info", null, mView, this); - } - if (MRole.getDefault().isAllow_Info_Payment()) - { - AEnv.addMenuItem("InfoPayment", "Info", null, mView, this); - } -// if (MRole.getDefault().isAllow_Info_CashJournal()) -// { -// AEnv.addMenuItem("InfoCashLine", "Info", null, mView, this); -// } - if (MRole.getDefault().isAllow_Info_Resource()) - { - AEnv.addMenuItem("InfoAssignment", "Info", null, mView, this); - } - if (MRole.getDefault().isAllow_Info_Asset()) - { - AEnv.addMenuItem("InfoAsset", "Info", null, mView, this); - } - - // Tools - JMenu mTools = AEnv.getMenu("Tools"); - menuBar.add(mTools); - AEnv.addMenuItem("Calculator", null, null, mTools, this); - AEnv.addMenuItem("Calendar", null, null, mTools, this); - AEnv.addMenuItem("Editor", null, null, mTools, this); - MUser user = MUser.get(Env.getCtx()); - if (user.isAdministrator()) - AEnv.addMenuItem("Script", null, null, mTools, this); - if (AEnv.isWorkflowProcess()) - AEnv.addMenuItem("WorkFlow", null, null, mTools, this); - if (MRole.getDefault().isShowPreference()) - { - mTools.addSeparator(); - AEnv.addMenuItem("Preference", null, null, mTools, this); - } - - //Window Menu - m_WindowMenu = new WindowMenu(windowManager, this); - menuBar.add(m_WindowMenu); - KeyStroke ks = KeyStroke.getKeyStroke(KeyEvent.VK_W, ActionEvent.CTRL_MASK); - this.getRootPane().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(ks, "ShowAllWindow"); - AppsAction action = new AppsAction("ShowAllWindow", ks, false); - this.getRootPane().getActionMap().put("ShowAllWindow", action); - action.setDelegate(this); - - // Help - JMenu mHelp = AEnv.getMenu("Help"); - menuBar.add(mHelp); - AEnv.addMenuItem("Online", null, null, mHelp, this); - AEnv.addMenuItem("EMailSupport", null, null, mHelp, this); - AEnv.addMenuItem("About", null, null, mHelp, this); - } // createMenu - - /** - * Dispose - end system - */ - public void dispose() - { - preDispose(); - // - super.dispose(); - AEnv.exit(0); - } // dispose - - private void preDispose() { - // clean up - save window state - Ini.setWindowDimension(0, getSize()); - Ini.setDividerLocation(treePanel.getDividerLocation()); - Ini.setWindowLocation(0, getLocation()); - Ini.saveProperties(true); - // - infoUpdater.stop = true; - try { - infoUpdaterThread.join(50); - } catch(InterruptedException ire) { - } finally { - infoUpdaterThread = null; - infoUpdater = null; - } - } - - public void logout() - { - windowManager.close(); - preDispose(); - super.dispose(); - AEnv.logout(); - } - - /** - * Window Events - requestFocus - * @param e event - */ - protected void processWindowEvent(WindowEvent e) - { - super.processWindowEvent(e); - if (e.getID() == WindowEvent.WINDOW_OPENED) - { - treePanel.getSearchField().requestFocusInWindow(); - // this.toFront(); - } - } // processWindowEvent - - /** - * Set Busy - * @param value true if buzy - */ - protected void setBusy (boolean value) - { - m_startingItem = value; - if (value) - setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); - else - setCursor(Cursor.getDefaultCursor()); - // setEnabled (!value); // causes flicker - } // setBusy - - /** - * Selection in tree - launch Application - * @param e PropertyChangeEvent - */ - public void propertyChange(PropertyChangeEvent e) - { - - MTreeNode nd = (MTreeNode)e.getNewValue(); - if (log.isLoggable(Level.INFO)) log.info(nd.getNode_ID() + " - " + nd.toString()); - - // ignore summary items & when loading - if (m_startingItem || nd.isSummary()) - return; - - String sta = nd.toString(); - progressBar.setString(sta); - int cmd = nd.getNode_ID(); - - (new AMenuStartItem(cmd, true, sta, this)).start(); // async load - //hengsin, updateInfo is call again in AMenuStartItem - //updateInfo(); - } // propertyChange - - - /************************************************************************** - * ActionListener - * @param e ActionEvent - */ - public void actionPerformed(ActionEvent e) - { - // Buttons - if (e.getSource() == bNotes) - gotoNotes(); - else if (e.getSource() == bRequests) - gotoRequests(); - else if (e.getActionCommand().equals("ShowAllWindow")) - m_WindowMenu.expose(); - else if (!AEnv.actionPerformed(e.getActionCommand(), m_WindowNo, this)) - log.log(Level.SEVERE, "unknown action=" + e.getActionCommand()); - //updateInfo(); - } // actionPerformed - - /** - * Get number of open Notes - * @return number of notes - */ - private int getNotes() - { - String sql = "SELECT COUNT(1) FROM AD_Note " - + "WHERE AD_Client_ID=? AND AD_User_ID IN (0,?)" - + " AND Processed='N'"; - int retValue = DB.getSQLValue(null, sql, Env.getAD_Client_ID(Env.getCtx()), m_AD_User_ID); - return retValue; - } // getNotes - - /** - * Open Note Window - */ - private void gotoNotes() - { - // AD_Table_ID for AD_Note = 389 HARDCODED - if (m_note_Menu_ID == 0) - m_note_Menu_ID = DB.getSQLValue(null, "SELECT AD_Menu_ID " - + "FROM AD_Menu m" - + " INNER JOIN AD_TABLE t ON (t.AD_Window_ID=m.AD_Window_ID) " - + "WHERE t.AD_Table_ID=?", 389); - if (m_note_Menu_ID == 0) - m_note_Menu_ID = MENU_NOTICE; // fallback HARDCODED - (new AMenuStartItem (m_note_Menu_ID, true, Msg.translate(m_ctx, "AD_Note_ID"), this)).start(); // async load - } // gotoMessage - - /** - * Ger Number of open Requests - * @return number of requests - */ - private int getRequests() - { - if (m_requestSQL == null) - m_requestSQL = MRole.getDefault().addAccessSQL ("SELECT COUNT(1) FROM R_Request " - + "WHERE (SalesRep_ID=? OR AD_Role_ID=?) AND Processed='N'" - + " AND (DateNextAction IS NULL OR TRUNC(DateNextAction) <= TRUNC(SysDate))" - + " AND (R_Status_ID IS NULL OR R_Status_ID IN (SELECT R_Status_ID FROM R_Status WHERE IsClosed='N'))", - "R_Request", false, true); // not qualified - RW - int retValue = DB.getSQLValue(null, m_requestSQL, m_AD_User_ID, m_AD_Role_ID); - return retValue; - } // getRequests - - /** - * Open Request Window - */ - private void gotoRequests() - { - // AD_Table_ID for R_Request = 417 HARDCODED - // if (m_request_Menu_ID == 0) // Goes to Request (all) - // m_request_Menu_ID = DB.getSQLValue (null, "SELECT AD_Menu_ID " - // + "FROM AD_Menu m" - // + " INNER JOIN AD_TABLE t ON (t.AD_Window_ID=m.AD_Window_ID) " - // + "WHERE t.AD_Table_ID=?", 417); - if (m_request_Menu_ID == 0) - m_request_Menu_ID = WINDOW_MY_REQUESTS; // My Requests - (new AMenuStartItem (m_request_Menu_ID, true, Msg.translate(m_ctx, "R_Request_ID"), this)).start(); // async load - } // gotoRequests - - /** - * Show Memory Info - run GC if required - Update Requests/Memos/Activities - */ - public void updateInfo() - { - double total = Runtime.getRuntime().totalMemory() / 1024; - double free = Runtime.getRuntime().freeMemory() / 1024; - double used = total - free; - double percent = used * 100 / total; - // - memoryBar.setMaximum((int)total); - memoryBar.setValue((int)used); - String msg = MessageFormat.format("{0,number,integer} MB - {1,number,integer}%", - new Object[] {BigDecimal.valueOf(total / 1024), BigDecimal.valueOf(percent)}); - memoryBar.setString(msg); - // - // msg = MessageFormat.format("Total Memory {0,number,integer} kB - Free {1,number,integer} kB", - msg = Msg.getMsg(m_ctx, "MemoryInfo", - new Object[] {BigDecimal.valueOf(total), BigDecimal.valueOf(free)}); - memoryBar.setToolTipText(msg); - // progressBar.repaint(); - - // CarlosRuiz - globalqss - [ 1881285 ] Remove unnecessary calls to System.gc - // if (percent > 50) - // System.gc(); - - if (DB.isConnected()) - { - // Requests - int requests = getRequests(); - bRequests.setText(Msg.translate(m_ctx, "R_Request_ID") + ": " + requests); - // Memo - int notes = getNotes(); - bNotes.setText(Msg.translate(m_ctx, "AD_Note_ID") + ": " + notes); - // Activities - int activities = wfActivity.getActivitiesCount(); - centerPane.setTitleAt(m_tabActivities, Msg.getMsg (m_ctx, "WorkflowActivities") + ": " + activities); - /* - log.config(msg - + ", Processors=" + Runtime.getRuntime().availableProcessors() - + ", Requests=" + requests + ", Notes=" + notes + ", Activities=" + activities - + "," + CConnection.get().getStatus() - ); - */ - MSystem.get(m_ctx).info(); - } - } // updateInfo - - - /** - * Update Activities Label - */ - public void updateActivities(int act_length) - { - centerPane.setTitleAt(m_tabActivities, Msg.getMsg (m_ctx, "WorkflowActivities") + ": " + act_length); - } // updateInfo - - /************************************************************************* - * Start Workflow Activity - * @param AD_Workflow_ID id - */ - protected void startWorkFlow (int AD_Workflow_ID) - { - centerPane.setSelectedIndex(m_tabWorkflow); // switch - wfPanel.load(AD_Workflow_ID, false); - } // startWorkFlow - - - /** - * Change Listener (tab) - * @see javax.swing.event.ChangeListener#stateChanged(javax.swing.event.ChangeEvent) - * @param e event - */ - public void stateChanged (ChangeEvent e) - { - //updateInfo(); - // show activities - if (centerPane.getSelectedIndex() == m_tabActivities) - { - wfActivity.loadActivities(); - } - } // stateChanged - - public WindowManager getWindowManager() { - return windowManager; - } - - /************************************************************************** - * Mouse Listener - */ - class AMenu_MouseAdapter extends MouseAdapter - { - /** - * Invoked when the mouse has been clicked on a component. - * @param e event - */ - public void mouseClicked(MouseEvent e) - { - if (e.getClickCount() > 1) - { - updateInfo(); - System.gc(); - //updateInfo(); - } - } - } // AMenu_MouseAdapter - - - /************************************************************************** - * OS Start - * @param args Array of String arguments (ignored) - */ - public static void main(String[] args) - { - Splash.getSplash(); - Adempiere.startup(true); // needs to be here for UI - new AMenu(); - } // main - - class InfoUpdater implements Runnable - { - boolean stop = false; - - public void run() - { - int sleep = MSysConfig.getIntValue(MSysConfig.MENU_INFOUPDATER_SLEEP_MS, 60000, Env.getAD_Client_ID(Env.getCtx())); - while(stop == false) - { - updateInfo(); - - try { - Thread.sleep(sleep); - } catch(InterruptedException ire) { } - } - } - } - - - @Override - public void onClearWindowContext(int windowNo) { - AEnv.removeWindow(windowNo); - } - - @Override - public void onReset(boolean finalCall) { - AEnv.reset(finalCall); - } - -} // AMenu diff --git a/org.adempiere.ui.swing/src/org/compiere/apps/AMenuStartItem.java b/org.adempiere.ui.swing/src/org/compiere/apps/AMenuStartItem.java deleted file mode 100644 index 7f6640c7e1..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/apps/AMenuStartItem.java +++ /dev/null @@ -1,354 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ -package org.compiere.apps; - -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.sql.PreparedStatement; -import java.sql.ResultSet; -import java.util.logging.Level; - -import javax.swing.SwingUtilities; -import javax.swing.Timer; - -import org.compiere.apps.form.FormFrame; -import org.compiere.model.MTask; -import org.compiere.util.CLogger; -import org.compiere.util.DB; -import org.compiere.util.Env; -import org.compiere.util.Ini; -import org.compiere.util.Msg; - - -/** - * Start application action ( process, workflow, window, form, task ) - * of a menu item ( ad_menu ) or workflow node ( ad_wf_node ). - * - * @author Jorg Janke - * @version $Id: AMenuStartItem.java,v 1.2 2006/07/30 00:51:27 jjanke Exp $ - */ -public class AMenuStartItem extends Thread implements ActionListener -{ - /** - * Start Menu Item - * - * @param ID ID - * @param isMenu false if Workflow - * @param name Name - * @param menu Menu - */ - public AMenuStartItem (int ID, boolean isMenu, String name, AMenu menu) - { - m_ID = ID; - m_isMenu = isMenu; - m_name = name; - m_menu = menu; - if (menu != null) - m_increment = (menu.progressBar.getMaximum()-menu.progressBar.getMinimum()) / 5; - } // UpdateProgress - - /** The ID */ - private int m_ID = 0; - private boolean m_isMenu = false; - private String m_name; - private AMenu m_menu; - /** Logger */ - private static CLogger log = CLogger.getCLogger(AMenuStartItem.class); - - // Reset Progress Bar - private Runnable m_resetPB = new Runnable() - { - public void run() - { - m_value = 0; - if (m_menu != null) - m_menu.progressBar.setValue(0); - } - }; - // Progress Bar tick - private Runnable m_tickPB = new Runnable() - { - public void run() - { - if (m_menu == null) - return; - // 100/5 => 20 ticks - every .5 sec => 10 seconds loadtime - final int tick = 5; - if (m_menu.progressBar.getValue() < (m_menu.progressBar.getMaximum() - tick)) - m_menu.progressBar.setValue(m_menu.progressBar.getValue() + tick); - } - }; - // Progress Bar max state - private Runnable m_updatePB = new Runnable() - { - public void run() - { - if (m_menu == null) - return; - m_value += m_increment; - if (m_menu.progressBar.getValue() > m_value) // max value - m_menu.progressBar.setValue(m_value); - } - }; - /** Value */ - int m_value = 0; - /** Increment */ - int m_increment = 20; - /** Timer */ - private Timer m_timer = new Timer(500, this); // every 1/2 second - - /** - * Start Menu Item - */ - public void run() - { - if (m_menu != null) - m_menu.setBusy (true); - SwingUtilities.invokeLater(m_resetPB); - m_timer.start(); - SwingUtilities.invokeLater(m_updatePB); - PreparedStatement pstmt = null; - ResultSet rs = null; - String errmsg = null; - try - { - String sql = "SELECT * FROM AD_Menu WHERE AD_Menu_ID=?"; - if (!m_isMenu) - sql = "SELECT * FROM AD_WF_Node WHERE AD_WF_Node_ID=?"; - pstmt = DB.prepareStatement(sql, null); - pstmt.setInt(1, m_ID); - rs = pstmt.executeQuery(); - - SwingUtilities.invokeLater(m_updatePB); - if (rs.next()) // should only be one - { - String Action = rs.getString("Action"); - String IsSOTrx = "Y"; - if (m_isMenu) - IsSOTrx = rs.getString("IsSOTrx"); - int cmd; - if (Action.equals("W")) // Window - { - cmd = rs.getInt("AD_Window_ID"); - startWindow(0, cmd); - } - else if (Action.equals("P") || Action.equals("R")) // Process & Report - { - cmd = rs.getInt("AD_Process_ID"); - startProcess(cmd, IsSOTrx); - } - else if (Action.equals("B")) // Workbench - { - cmd = rs.getInt("AD_Workbench_ID"); - startWindow (cmd, 0); - } - else if (Action.equals("F")) // WorkFlow - { - if (m_isMenu) - cmd = rs.getInt("AD_Workflow_ID"); - else - cmd = rs.getInt("Workflow_ID"); - if (m_menu != null) - m_menu.startWorkFlow(cmd); - } - else if (Action.equals("T")) // Task - { - cmd = rs.getInt("AD_Task_ID"); - startTask(cmd); - } - else if (Action.equals("X")) // Form - { - cmd = rs.getInt("AD_Form_ID"); - startForm(cmd); - } - else - log.log(Level.SEVERE, "No valid Action in ID=" + m_ID); - } // for all records - - SwingUtilities.invokeLater(m_updatePB); - } - catch (Exception e) - { - log.log(Level.SEVERE, "ID=" + m_ID, e); - errmsg = Msg.parseTranslation(Env.getCtx(), e.getMessage()); - } - finally - { - DB.close(rs, pstmt); - rs = null; pstmt = null; - } - // Show error if any - if (errmsg != null) - ADialog.error(0, null, "Error", errmsg); - - try {Thread.sleep(1000);} // 1 sec - catch (InterruptedException ie) {} - - // ready for next - m_timer.stop(); - SwingUtilities.invokeLater(m_resetPB); - if (m_menu != null) - { - //m_menu.updateInfo(); - m_menu.setBusy(false); - } - } // run - - - /** - * Actlion Listener for Timer - * @param e event - */ - public void actionPerformed (ActionEvent e) - { - SwingUtilities.invokeLater(m_tickPB); - } // actionPerformed - - /** - * Start Window - * - * @param AD_Workbench_ID workbench - * @param AD_Window_ID window - */ - private void startWindow(int AD_Workbench_ID, int AD_Window_ID) - { - AWindow frame = (AWindow)AEnv.showWindow(AD_Window_ID); - if (frame != null) { - m_menu.getWindowManager().add(frame); - return; - } - - if (Ini.isPropertyBool(Ini.P_SINGLE_INSTANCE_PER_WINDOW)) { - frame = m_menu.getWindowManager().find(AD_Window_ID); - if ( frame != null ) { - frame.toFront(); - return; - } - } - - SwingUtilities.invokeLater(m_updatePB); // 1 - frame = new AWindow(m_menu.getGraphicsConfiguration()); - boolean OK = false; - if (AD_Workbench_ID != 0) - OK = frame.initWorkbench(AD_Workbench_ID); - else - OK = frame.initWindow(AD_Window_ID, null); // No Query Value - if (!OK) - return; - - SwingUtilities.invokeLater(m_updatePB); // 2 - if (Ini.isPropertyBool(Ini.P_OPEN_WINDOW_MAXIMIZED) ) - { - AEnv.showMaximized(frame); - } - - // Center the window - SwingUtilities.invokeLater(m_updatePB); // 3 - if (!(Ini.isPropertyBool(Ini.P_OPEN_WINDOW_MAXIMIZED)) ) - { - frame.validate(); - AEnv.showCenterScreen(frame); - } - - m_menu.getWindowManager().add(frame); - -// if (wfPanel.isVisible()) -// m_WF_Window = frame; // maintain one reference - frame = null; - } // startWindow - - /** - * Start Process. - * Start/show Process Dialog which calls ProcessCtl - * @param AD_Process_ID process - * @param IsSOTrx is SO trx - */ - private void startProcess (int AD_Process_ID, String IsSOTrx) - { - SwingUtilities.invokeLater(m_updatePB); // 1 - boolean isSO = false; - if (IsSOTrx != null && IsSOTrx.equals("Y")) - isSO = true; - m_timer.stop(); - ProcessDialog pd = new ProcessDialog (m_menu.getGraphicsConfiguration(), AD_Process_ID, isSO); - if (!pd.init()) - return; - m_timer.start(); - m_menu.getWindowManager().add(pd); - - SwingUtilities.invokeLater(m_updatePB); // 2 - pd.getContentPane().invalidate(); - pd.getContentPane().validate(); - pd.pack(); - // Center the window - SwingUtilities.invokeLater(m_updatePB); // 3 - AEnv.showCenterScreen(pd); - } // startProcess - - /** - * Start OS Task - * @param AD_Task_ID task - */ - private void startTask (int AD_Task_ID) - { - SwingUtilities.invokeLater(m_updatePB); // 1 - // Get Command - MTask task = null; - if (AD_Task_ID > 0) - task = new MTask(Env.getCtx(), AD_Task_ID, null); - if (task.get_ID() != AD_Task_ID) - task = null; - if (task == null) - return; - SwingUtilities.invokeLater(m_updatePB); // 2 - m_menu.getWindowManager().add(new ATask(m_name, task)); - // ATask.start(m_name, task); - } // startTask - - /** - * Start Form - * @param AD_Form_ID form - */ - private void startForm (int AD_Form_ID) - { - FormFrame ff = null; - if (Ini.isPropertyBool(Ini.P_SINGLE_INSTANCE_PER_WINDOW)) { - ff = m_menu.getWindowManager().findForm(AD_Form_ID); - if ( ff != null ) { - ff.toFront(); - return; - } - } - ff = new FormFrame(m_menu.getGraphicsConfiguration()); - SwingUtilities.invokeLater(m_updatePB); // 1 - boolean ok = ff.openForm(AD_Form_ID); - if (!ok) { - ff.dispose(); - return; - } - m_menu.getWindowManager().add(ff); - SwingUtilities.invokeLater(m_updatePB); // 2 - - // Center the window - SwingUtilities.invokeLater(m_updatePB); // 3 - if (Ini.isPropertyBool(Ini.P_OPEN_WINDOW_MAXIMIZED) ) { - AEnv.showMaximized(ff); - } else - AEnv.showCenterScreen(ff); - } // startForm - -} // StartItem diff --git a/org.adempiere.ui.swing/src/org/compiere/apps/APanel.java b/org.adempiere.ui.swing/src/org/compiere/apps/APanel.java deleted file mode 100644 index a73a42c411..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/apps/APanel.java +++ /dev/null @@ -1,3191 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - * @contributor Victor Perez , e-Evolution.SC FR [ 1757088 ] * - *****************************************************************************/ -package org.compiere.apps; - -import static org.compiere.model.SystemIDs.PROCESS_AD_CHANGELOG_REDO; -import static org.compiere.model.SystemIDs.PROCESS_AD_CHANGELOG_UNDO; -import static org.compiere.model.SystemIDs.REFERENCE_DOCUMENTACTION; -import static org.compiere.model.SystemIDs.REFERENCE_PAYMENTRULE; -import static org.compiere.model.SystemIDs.REFERENCE_POSTED; - -import java.awt.BorderLayout; -import java.awt.Color; -import java.awt.Component; -import java.awt.Cursor; -import java.awt.Dimension; -import java.awt.FlowLayout; -import java.awt.Image; -import java.awt.Point; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.awt.event.KeyEvent; -import java.io.File; -import java.sql.PreparedStatement; -import java.sql.ResultSet; -import java.sql.SQLException; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.Properties; -import java.util.TreeMap; -import java.util.Vector; -import java.util.logging.Level; - -import javax.swing.AbstractAction; -import javax.swing.Action; -import javax.swing.BorderFactory; -import javax.swing.ImageIcon; -import javax.swing.JDialog; -import javax.swing.JFrame; -import javax.swing.JList; -import javax.swing.JMenu; -import javax.swing.JMenuBar; -import javax.swing.JMenuItem; -import javax.swing.JOptionPane; -import javax.swing.JPanel; -import javax.swing.JPopupMenu; -import javax.swing.JScrollPane; -import javax.swing.JTabbedPane; -import javax.swing.JTable; -import javax.swing.JToolBar; -import javax.swing.KeyStroke; -import javax.swing.ListSelectionModel; -import javax.swing.SwingUtilities; -import javax.swing.event.ChangeEvent; -import javax.swing.event.ChangeListener; -import javax.swing.event.PopupMenuEvent; -import javax.swing.event.PopupMenuListener; - -import org.adempiere.util.Callback; -import org.adempiere.util.IProcessUI; -import org.compiere.apps.form.FormFrame; -import org.compiere.apps.search.Find; -import org.compiere.grid.APanelTab; -import org.compiere.grid.GridController; -import org.compiere.grid.GridSynchronizer; -import org.compiere.grid.ICreateFrom; -import org.compiere.grid.RecordAccessDialog; -import org.compiere.grid.VCreateFromFactory; -import org.compiere.grid.VOnlyCurrentDays; -import org.compiere.grid.VSortTab; -import org.compiere.grid.VTabbedPane; -import org.compiere.grid.ed.VButton; -import org.compiere.grid.ed.VDocAction; -import org.compiere.grid.ed.VPostIt; -import org.compiere.model.DataStatusEvent; -import org.compiere.model.DataStatusListener; -import org.compiere.model.GridField; -import org.compiere.model.GridTab; -import org.compiere.model.GridTable; -import org.compiere.model.GridWindow; -import org.compiere.model.GridWindowVO; -import org.compiere.model.GridWorkbench; -import org.compiere.model.Lookup; -import org.compiere.model.MLookupFactory; -import org.compiere.model.MProcess; -import org.compiere.model.MProjectIssue; -import org.compiere.model.MQuery; -import org.compiere.model.MRole; -import org.compiere.model.MToolBarButtonRestrict; -import org.compiere.model.MUser; -import org.compiere.model.MWindow; -import org.compiere.model.X_AD_ToolBarButton; -import org.compiere.plaf.CompiereColor; -import org.compiere.print.AReport; -import org.compiere.process.DocAction; -import org.compiere.process.ProcessInfo; -import org.compiere.process.ProcessInfoUtil; -import org.compiere.swing.CPanel; -import org.compiere.util.CLogMgt; -import org.compiere.util.CLogger; -import org.compiere.util.DB; -import org.compiere.util.DisplayType; -import org.compiere.util.Env; -import org.compiere.util.Language; -import org.compiere.util.Msg; -import org.compiere.util.Util; - -/** - * Main Panel of application window. - *
    - *  Structure:
    - *      (MenuBar) -> to be added to owning window
    - *		northPanel  (ToolBar)
    - *		tabPanel
    - *		southPanel  (StatusBar)
    - *  
    - * - * @author Jorg Janke - * @version $Id: APanel.java,v 1.4 2006/07/30 00:51:27 jjanke Exp $ - * - * Colin Rooney 2007/03/20 RFE#1670185 & related BUG#1684142 - Extend Sec to Info Queries - * @contributor Victor Perez , e-Evolution.SC FR [ 1757088 ] - * @contributor fer_luck@centuryon.com , FR [ 1757088 ] - * @author Teo Sarca, SC ARHIPAC SERVICE SRL - *
  • BF [ 1824621 ] History button can't be canceled - *
  • BF [ 1941271 ] VTreePanel is modifying even if is save wasn't successfull - *
  • FR [ 1943731 ] Window data export functionality - *
  • FR [ 1974354 ] VCreateFrom.create should be more flexible - *
  • BF [ 1996056 ] Report error message is not displayed - *
  • BF [ 1998575 ] Document Print is discarding any error - * @author Teo Sarca, teo.sarca@gmail.com - *
  • BF [ 2876892 ] Save included tab before calling button action - * https://sourceforge.net/tracker/?func=detail&aid=2876892&group_id=176962&atid=879332 - * @author victor.perez@e-evolution.com - * @see FR [ 1966328 ] New Window Info to MRP and CRP into View http://sourceforge.net/tracker/index.php?func=detail&aid=1966328&group_id=176962&atid=879335 - * @autor tobi42, metas GmBH - *
  • BF [ 2799362 ] You can press New button a lot of times - * @author Cristina Ghita, www.arhipac.ro - * @see FR [ 2877111 ] See identifiers columns when delete records https://sourceforge.net/tracker/?func=detail&atid=879335&aid=2877111&group_id=176962 - * - * @author hengsin, hengsin.low@idalica.com - * @see FR [2887701] https://sourceforge.net/tracker/?func=detail&atid=879335&aid=2887701&group_id=176962 - * @sponsor www.metas.de - */ -public final class APanel extends CPanel - implements DataStatusListener, ChangeListener, ActionListener, IProcessUI -{ - /** - * - */ - private static final long serialVersionUID = 8668865618093531311L; - - private boolean isNested = false; - private boolean ToolBarMenuRestictionLoaded = false; - - /** - * Constructs a new instance. - * Need to call initPanel for dynamic initialization - */ - //FR [ 1757088 ] - public APanel(GridController gc, int windowNo){ - super(); - isNested = true; - m_ctx = Env.getCtx(); - try{ - m_curGC = gc; - gc.addDataStatusListener(this); - m_curTab = gc.getMTab(); - - Component tabElement = null; - tabElement = gc; - VTabbedPane tabPane = new VTabbedPane(false); - tabPane.addTab(m_curTab.getName().toString(), m_curTab, tabElement); - m_curWinTab = tabPane; - m_curWindowNo = windowNo; - jbInit(); - initSwitchLineAction(); - } - catch(Exception e){ - log.log(Level.SEVERE, "", e); - } - - createMenu(); - - MRole role = MRole.getDefault(); - m_curGC.query (m_onlyCurrentRows, m_onlyCurrentDays, role.getMaxQueryRecords()); - m_curTab.navigateCurrent(); // updates counter - m_curGC.dynamicDisplay(0); - } - - public APanel(AWindow window) - { - super(); - m_window = window; - - m_ctx = Env.getCtx(); - // - try - { - jbInit(); - } - catch (Exception e) - { - log.log(Level.SEVERE, "", e); - } - createMenu(); - } // APanel - - /** Logger */ - private static CLogger log = CLogger.getCLogger(APanel.class); - - private AWindow m_window; - private boolean isCancel = false; //Goodwill - - /** - * Dispose - */ - public void dispose() - { - // log.config(""); - // ignore changes - m_disposing = true; - // - if (m_curAPanelTab != null) - { - m_curAPanelTab.unregisterPanel(); - m_curAPanelTab = null; - } - // close panels - tabPanel.dispose(this); - tabPanel = null; - // All Workbenches - for (int i = 0; i < m_mWorkbench.getWindowCount(); i++) - { - m_curWindowNo = m_mWorkbench.getWindowNo(i); - if (log.isLoggable(Level.INFO)) log.info("#" + m_curWindowNo); - Env.setAutoCommit(m_ctx, m_curWindowNo, false); - m_mWorkbench.dispose(i); - Env.clearWinContext(m_ctx, m_curWindowNo); - } // all Workbenchens - - // Get rid of remaining model - if (m_mWorkbench != null) - m_mWorkbench.dispose(); - m_mWorkbench = null; - // MenuBar - if (menuBar != null) - menuBar.removeAll(); - menuBar = null; - // ToolBar - if (toolBar != null) - toolBar.removeAll(); - toolBar = null; - // Prepare GC - this.removeAll(); - } // dispose - - /** - * The Layout. - */ - private BorderLayout mainLayout = new BorderLayout(); - private VTabbedPane tabPanel = new VTabbedPane(true); - private StatusBar statusBar = new StatusBar(); - private CPanel northPanel = new CPanel(); - private JToolBar toolBar = new JToolBar(); - private JMenuBar menuBar = new JMenuBar(); - private FlowLayout northLayout = new FlowLayout(); - - /** - * Initializes the state of this instance. - * @throws Exception - */ - private void jbInit() throws Exception - { - this.setLocale(Language.getLoginLanguage().getLocale()); - this.setLayout(mainLayout); - - // tabPanel - mainLayout.setHgap(2); - mainLayout.setVgap(2); - if (isNested) - this.add(m_curGC, BorderLayout.CENTER); - else - { - CPanel dummy = new CPanel(); - dummy.setLayout(new BorderLayout()); - dummy.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 2)); - dummy.add(tabPanel, BorderLayout.CENTER); - this.add(dummy, BorderLayout.CENTER); - } - // southPanel - this.add(statusBar, BorderLayout.SOUTH); - // northPanel - this.add(northPanel, BorderLayout.NORTH); - northPanel.setLayout(northLayout); - northLayout.setAlignment(FlowLayout.LEFT); - toolBar.putClientProperty("JToolBar.isRollover", Boolean.TRUE); - toolBar.setBorderPainted(false); - toolBar.setFloatable(false); // teo_sarca, [ 1666591 ] Toolbar should not be floatable - northPanel.add(toolBar, null); - } // jbInit - - private AppsAction aPrevious, aNext, aParent, aDetail, aFirst, aLast, - aNew, aCopy, aDelete, aPrint, aPrintPreview, - aExport = null, - aRefresh, aHistory, aAttachment, aChat, aMulti, aFind, - aWorkflow, aZoomAcross, aRequest, aWinSize, aArchive, - aProcess; - /** Ignore Button */ - public AppsAction aIgnore; - /** Save Button */ - public AppsAction aSave; - /** Save & Create Button*/ - public AppsAction aSaveAndCreate; - /** Private Lock Button */ - public AppsAction aLock; - // Local (added to toolbar) - @SuppressWarnings("unused") - private AppsAction aReport, aEnd, aHome, aHelp, aProduct, aLogout, - aAccount, aCalculator, aCalendar, aEditor, aPreference, aScript, - aOnline, aMailSupport, aAbout, aPrintScr, aScrShot, aExit, aBPartner, - aDeleteSelection, aShowAllWindow, aPostIt; - - private SwitchAction aSwitchLinesDownAction, aSwitchLinesUpAction; - - private WindowMenu m_WindowMenu; - /************************************************************************** - * Create Menu and Toolbar and registers keyboard actions. - * - started from constructor - */ - private void createMenu() - { - /** - * Menu - */ - // menuBar.setHelpMenu(); - // File - JMenu mFile = AEnv.getMenu("File"); - menuBar.add(mFile); - aPrintScr = addAction("PrintScreen", mFile, KeyStroke.getKeyStroke(KeyEvent.VK_PRINTSCREEN, 0), false); - aScrShot = addAction("ScreenShot", mFile, KeyStroke.getKeyStroke(KeyEvent.VK_PRINTSCREEN, ActionEvent.SHIFT_MASK), false); - aReport = addAction("Report", mFile, KeyStroke.getKeyStroke(KeyEvent.VK_F11, 0), false); - aPrint = addAction("Print", mFile, KeyStroke.getKeyStroke(KeyEvent.VK_F12, 0), false); - aPrintPreview = addAction("PrintPreview", mFile, KeyStroke.getKeyStroke(KeyEvent.VK_P, ActionEvent.SHIFT_MASK+ActionEvent.ALT_MASK), false); - if (MRole.getDefault().isCanExport()) - { - aExport = addAction("Export", mFile, null, false); - } - mFile.addSeparator(); - aEnd = addAction("End", mFile, KeyStroke.getKeyStroke(KeyEvent.VK_X, ActionEvent.ALT_MASK), false); - aLogout = addAction("Logout", mFile, KeyStroke.getKeyStroke(KeyEvent.VK_L, ActionEvent.SHIFT_MASK+ActionEvent.ALT_MASK), false); - aExit = addAction("Exit", mFile, KeyStroke.getKeyStroke(KeyEvent.VK_X, ActionEvent.SHIFT_MASK+ActionEvent.ALT_MASK), false); - // Edit - JMenu mEdit = AEnv.getMenu("Edit"); - menuBar.add(mEdit); - aNew = addAction("New", mEdit, KeyStroke.getKeyStroke(KeyEvent.VK_F2, 0), false); - aSave = addAction("Save", mEdit, KeyStroke.getKeyStroke(KeyEvent.VK_F4, 0), false); - aSaveAndCreate = addAction("SaveCreate", mEdit, KeyStroke.getKeyStroke(KeyEvent.VK_Q, ActionEvent.CTRL_MASK), false); - mEdit.addSeparator(); - aCopy = addAction("Copy", mEdit, KeyStroke.getKeyStroke(KeyEvent.VK_F2, ActionEvent.SHIFT_MASK), false); - aDelete = addAction("Delete", mEdit, KeyStroke.getKeyStroke(KeyEvent.VK_F3, 0), false); - aDeleteSelection = addAction("DeleteSelection", mEdit, KeyStroke.getKeyStroke(KeyEvent.VK_D, ActionEvent.CTRL_MASK), false); - aIgnore = addAction("Ignore", mEdit, KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), false); - aRefresh = addAction("Refresh", mEdit, KeyStroke.getKeyStroke(KeyEvent.VK_F5, 0), false); - mEdit.addSeparator(); - aFind = addAction("Find", mEdit, KeyStroke.getKeyStroke(KeyEvent.VK_F6, 0), true); // toggle - if (m_isPersonalLock) - aLock = addAction("Lock", mEdit, null, true); // toggle - // View - JMenu mView = AEnv.getMenu("View"); - menuBar.add(mView); - if (MRole.getDefault().isAllow_Info_Product()) - { - aProduct = addAction("InfoProduct", mView, KeyStroke.getKeyStroke(KeyEvent.VK_I, ActionEvent.ALT_MASK), false); - } - if (MRole.getDefault().isAllow_Info_BPartner()) - { - aBPartner = addAction("InfoBPartner", mView, KeyStroke.getKeyStroke(KeyEvent.VK_I, ActionEvent.SHIFT_MASK+ActionEvent.ALT_MASK), false); - } - if (MRole.getDefault().isShowAcct() && MRole.getDefault().isAllow_Info_Account()) - { - aAccount = addAction("InfoAccount",mView, KeyStroke.getKeyStroke(KeyEvent.VK_I, ActionEvent.ALT_MASK+ActionEvent.CTRL_MASK), false); - } - if (MRole.getDefault().isAllow_Info_Schedule()) - { - AEnv.addMenuItem("InfoSchedule", null, null, mView, this); - } - //FR [ 1966328 ] -// if (MRole.getDefault().isAllow_Info_MRP()) -// { -// AEnv.addMenuItem("InfoMRP", "Info", null, mView, this); -// } -// if (MRole.getDefault().isAllow_Info_CRP()) -// { -// AEnv.addMenuItem("InfoCRP", "Info", null, mView, this); -// } - mView.addSeparator(); - if (MRole.getDefault().isAllow_Info_Order()) - { - AEnv.addMenuItem("InfoOrder", "Info", null, mView, this); - } - if (MRole.getDefault().isAllow_Info_Invoice()) - { - AEnv.addMenuItem("InfoInvoice", "Info", null, mView, this); - } - if (MRole.getDefault().isAllow_Info_InOut()) - { - AEnv.addMenuItem("InfoInOut", "Info", null, mView, this); - } - if (MRole.getDefault().isAllow_Info_Payment()) - { - AEnv.addMenuItem("InfoPayment", "Info", null, mView, this); - } -// if (MRole.getDefault().isAllow_Info_CashJournal()) -// { -// AEnv.addMenuItem("InfoCashLine", "Info", null, mView, this); -// } - if (MRole.getDefault().isAllow_Info_Resource()) - { - AEnv.addMenuItem("InfoAssignment", "Info", null, mView, this); - } - if (MRole.getDefault().isAllow_Info_Asset()) - { - AEnv.addMenuItem("InfoAsset", "Info", null, mView, this); - } - - - - mView.addSeparator(); - aAttachment = addAction("Attachment", mView, KeyStroke.getKeyStroke(KeyEvent.VK_F7, 0), true); // toggle - aPostIt = addAction("PostIt", mView, null, true); - aChat = addAction("Chat", mView, null, true); // toggle - aHistory = addAction("History", mView, KeyStroke.getKeyStroke(KeyEvent.VK_F9, 0), true); // toggle - mView.addSeparator(); - aMulti = addAction("Multi", mView, KeyStroke.getKeyStroke(KeyEvent.VK_F8, 0), true); // toggle - // Go - JMenu mGo = AEnv.getMenu("Go"); - menuBar.add(mGo); - aFirst = addAction("First", mGo, KeyStroke.getKeyStroke(KeyEvent.VK_PAGE_UP, ActionEvent.ALT_MASK), false); - aPrevious = addAction("Previous", mGo, KeyStroke.getKeyStroke(KeyEvent.VK_UP, ActionEvent.ALT_MASK), false); - aNext = addAction("Next", mGo, KeyStroke.getKeyStroke(KeyEvent.VK_DOWN, ActionEvent.ALT_MASK), false); - aLast = addAction("Last", mGo, KeyStroke.getKeyStroke(KeyEvent.VK_PAGE_DOWN, ActionEvent.ALT_MASK), false); - mGo.addSeparator(); - aParent = addAction("Parent", mGo, KeyStroke.getKeyStroke(KeyEvent.VK_LEFT, ActionEvent.ALT_MASK), false); - aDetail = addAction("Detail", mGo, KeyStroke.getKeyStroke(KeyEvent.VK_RIGHT, ActionEvent.ALT_MASK), false); - mGo.addSeparator(); - aZoomAcross = addAction("ZoomAcross", mGo, null, false); - aRequest = addAction("Request", mGo, null, false); - aArchive = addAction("Archive", mGo, null, false); - aHome = addAction("Home", mGo, null, false); - // Tools - JMenu mTools = AEnv.getMenu("Tools"); - menuBar.add(mTools); - aCalculator = addAction("Calculator", mTools, null, false); - aCalendar = addAction("Calendar", mTools, null, false); - aEditor = addAction("Editor", mTools, null, false); - MUser user = MUser.get(Env.getCtx()); - if (user.isAdministrator()) - aScript = addAction("Script", mTools, null, false); - if ("Y".equals(Env.getContext(m_ctx, "#SysAdmin"))) // set in DB.loginDB - aWinSize = addAction("WinSize", mTools, null, false); - if (AEnv.isWorkflowProcess()) - aWorkflow = addAction("WorkFlow", mTools, null, false); - if (MRole.getDefault().isShowPreference()) - { - mTools.addSeparator(); - aPreference = addAction("Preference", mTools, null, false); - } - - //Window - AMenu aMenu = (AMenu)AEnv.getWindow(0); - m_WindowMenu = new WindowMenu(aMenu.getWindowManager(), m_window); - menuBar.add(m_WindowMenu); - aShowAllWindow = addAction("ShowAllWindow", null, KeyStroke.getKeyStroke(KeyEvent.VK_W, ActionEvent.CTRL_MASK), false); - - // Help - JMenu mHelp = AEnv.getMenu("Help"); - menuBar.add(mHelp); - aHelp = addAction("Help", mHelp, KeyStroke.getKeyStroke(KeyEvent.VK_F1, 0), false); - aOnline = addAction("Online", mHelp, null, false); - aMailSupport = addAction("EMailSupport", mHelp, null, false); - aAbout = addAction("About", mHelp, null, false); - - // - aProcess=addAction("Process",null,null,false); - - /** - * ToolBar - */ - toolBar.add(aIgnore.getButton()); // ESC - toolBar.addSeparator(); - toolBar.add(aHelp.getButton()); // F1 - toolBar.add(aNew.getButton()); - toolBar.add(aCopy.getButton()); - toolBar.add(aDelete.getButton()); - toolBar.add(aDeleteSelection.getButton()); - toolBar.add(aSave.getButton()); - toolBar.add(aSaveAndCreate.getButton()); - toolBar.add(aProcess.getButton()); - toolBar.addSeparator(); - toolBar.add(aRefresh.getButton()); // F5 - toolBar.add(aFind.getButton()); - toolBar.add(aAttachment.getButton()); - toolBar.add(aPostIt.getButton()); - toolBar.add(aChat.getButton()); - toolBar.add(aMulti.getButton()); - toolBar.addSeparator(); - //FR [ 1757088 ] - if((m_curGC == null) || (m_curGC != null && !m_curGC.isDetailGrid())){ - toolBar.add(aHistory.getButton()); // F9 - toolBar.add(aHome.getButton()); // F10 is Windows Menu Key - toolBar.add(aParent.getButton()); - toolBar.add(aDetail.getButton()); - toolBar.addSeparator(); - } - - toolBar.add(aFirst.getButton()); - toolBar.add(aPrevious.getButton()); - toolBar.add(aNext.getButton()); - toolBar.add(aLast.getButton()); - toolBar.addSeparator(); - toolBar.add(aReport.getButton()); - toolBar.add(aArchive.getButton()); - toolBar.add(aPrintPreview.getButton()); - toolBar.add(aPrint.getButton()); - // FR [ 1757088 ] - if((m_curGC == null) || (m_curGC != null && !m_curGC.isDetailGrid())){ - toolBar.addSeparator(); - if (m_isPersonalLock) - toolBar.add(aLock.getButton()); - toolBar.add(aZoomAcross.getButton()); - if (aWorkflow != null) - toolBar.add(aWorkflow.getButton()); - toolBar.add(aRequest.getButton()); - if (MRole.getDefault().isAllow_Info_Product()) - { - toolBar.add(aProduct.getButton()); - } - toolBar.addSeparator(); - toolBar.add(aEnd.getButton()); - } - - // - if (CLogMgt.isLevelAll()) - Util.printActionInputMap(this); - } // createMenu - - - /** - * Add (Toggle) Action to Toolbar and Menu - * @param actionName action name - * @param menu manu - * @param accelerator accelerator - * @param toggle toggle button - * @return AppsAction - */ - private AppsAction addAction (String actionName, JMenu menu, KeyStroke accelerator, boolean toggle) - { - AppsAction action = new AppsAction(actionName, accelerator, toggle); - if (menu != null) - menu.add(action.getMenuItem()); - action.setDelegate(this); - // AbstractButton b = action.getButton(); - // String s = null; - // if (b != null) - // s = b.getToolTipText(); - - // Key Strokes - if (accelerator != null) - { - getInputMap(WHEN_IN_FOCUSED_WINDOW).put(accelerator, actionName); - getActionMap().put(actionName, action); - } - // - return action; - } // addAction - - /** - * Return MenuBar - * @return JMenuBar - */ - public JMenuBar getMenuBar() - { - return menuBar; - } // getMenuBar - - /** - * Get Title of Window - * @return String with Title - */ - public String getTitle() - { - if (m_mWorkbench != null && m_mWorkbench.getWindowCount() > 1) - { - StringBuilder sb = new StringBuilder(); - sb.append(m_mWorkbench.getName()).append(" ") - .append(Env.getContext(m_ctx, "#AD_User_Name")).append("@") - .append(Env.getContext(m_ctx, "#AD_Client_Name")).append(".") - .append(Env.getContext(m_ctx, "#AD_Org_Name")).append(" [") - .append(Env.getContext(m_ctx, "#DB_UID")).append("]"); - return sb.toString(); - } - return Env.getHeader(m_ctx, m_curWindowNo); - } // getTitle - - - private Properties m_ctx; - - /** Workbench Model */ - private GridWorkbench m_mWorkbench; - /** Current MTab */ - private GridTab m_curTab; - /** Current GridController */ - private GridController m_curGC; - /** Current Window Panel */ - private JTabbedPane m_curWinTab = null; - /** Current Window No */ - private int m_curWindowNo; - /** Current Window Panel Index */ - private int m_curTabIndex = -1; - /** Current Tab Order */ - private APanelTab m_curAPanelTab = null; - - /** Dispose active */ - private boolean m_disposing = false; - /** Save Error Message indicator */ - private boolean m_errorDisplayed = false; - /** Only current row flag */ - private boolean m_onlyCurrentRows = true; - /** Number of days to show 0=all */ - private int m_onlyCurrentDays = 0; - /** Process Info */ - private boolean m_isLocked = false; - /** Show Personal Lock */ - private boolean m_isPersonalLock = MRole.getDefault().isPersonalLock(); - /** Last Modifier of Action Event */ - private int m_lastModifiers; - - private HashMap includedMap; - - - /************************************************************************** - * Dynamic Panel Initialization - either single window or workbench. - *
    -	 *  either
    -	 *  - Workbench tabPanel    (VTabbedPane)
    -	 *      - Tab               (GridController)
    -	 *  or
    -	 *  - Workbench tabPanel    (VTabbedPane)
    -	 *      - Window            (VTabbedPane)
    -	 *          - Tab           (GridController)
    -	 *  
    - * tabPanel - * @param AD_Workbench_ID if > 0 this is a workbench, AD_Window_ID ignored - * @param AD_Window_ID if not a workbench, Window ID - * @param query if not a Workbench, Zoom Query - additional SQL where clause - * @return true if Panel is initialized successfully - */ - public boolean initPanel (int AD_Workbench_ID, int AD_Window_ID, MQuery query) - { - if (log.isLoggable(Level.INFO)) log.info("WB=" + AD_Workbench_ID + ", Win=" + AD_Window_ID + ", Query=" + query); - this.setName("APanel" + AD_Window_ID); - - // Single Window - if (AD_Workbench_ID == 0) - m_mWorkbench = new GridWorkbench(m_ctx, AD_Window_ID); - else - // Workbench - { - // m_mWorkbench = new MWorkbench(m_ctx); - // if (!m_mWorkbench.initWorkbench (AD_Workbench_ID)) - // { - // log.log(Level.SEVERE, "APanel.initWindow - No Workbench Model"); - // return false; - // } - // tabPanel.setWorkbench(true); - // tabPanel.addChangeListener(this); - ADialog.warn(0, this, "","Not implemented yet"); - return false; - } - - Dimension windowSize = m_mWorkbench.getWindowSize(); - - MQuery detailQuery = null; - /** - * WorkBench Loop - */ - for (int wb = 0; wb < m_mWorkbench.getWindowCount(); wb++) - { - // Get/set WindowNo - m_curWindowNo = AEnv.createWindowNo (this); // Timing: ca. 1.5 sec - m_mWorkbench.setWindowNo(wb, m_curWindowNo); - // Set AutoCommit for this Window - Env.setAutoCommit(m_ctx, m_curWindowNo, Env.isAutoCommit(m_ctx)); - boolean autoNew = Env.isAutoNew(m_ctx); - Env.setAutoNew(m_ctx, m_curWindowNo, autoNew); - - // Workbench Window - VTabbedPane window = null; - // just one window - if (m_mWorkbench.getWindowCount() == 1) - { - window = tabPanel; - window.setWorkbench(false); - } - else - { - VTabbedPane tp = new VTabbedPane(false); - window = tp; - } - // Window Init - window.addChangeListener(this); - - /** - * Init Model - */ - int wbType = m_mWorkbench.getWindowType(wb); - - /** - * Window - */ - if (wbType == GridWorkbench.TYPE_WINDOW) - { - includedMap = new HashMap(4); - // - GridWindowVO wVO = Env.getMWindowVO(m_curWindowNo, m_mWorkbench.getWindowID(wb), 0); - if (wVO == null) - { - ADialog.error(0, null, "AccessTableNoView", "(No Window Model Info)"); - return false; - } - GridWindow mWindow = new GridWindow (wVO, true); // Timing: ca. 0.3-1 sec - // Set SO/AutoNew for Window - Env.setContext(m_ctx, m_curWindowNo, "IsSOTrx", mWindow.isSOTrx()); - if (!autoNew && mWindow.isTransaction()) - Env.setAutoNew(m_ctx, m_curWindowNo, true); - m_mWorkbench.setMWindow(wb, mWindow); - if (wb == 0) - m_onlyCurrentRows = mWindow.isTransaction(); // default = only current - if (windowSize == null) - windowSize = mWindow.getWindowSize(); - - /** - * Window Tabs - */ - int tabSize = mWindow.getTabCount(); - boolean goSingleRow = query != null; // Zoom Query - for (int tab = 0; tab < tabSize; tab++) - { - boolean included = false; - // MTab - if (tab == 0) mWindow.initTab(0); - GridTab gTab = mWindow.getTab(tab); - Env.setContext(m_ctx, m_curWindowNo, tab, GridTab.CTX_TabLevel, Integer.toString(gTab.getTabLevel())); - // Query first tab - if (tab == 0) - { - // initial user query for single workbench tab - if (m_mWorkbench.getWindowCount() == 1) - { - if (query != null && query.getZoomTableName() != null && query.getZoomColumnName() != null - && query.getZoomValue() instanceof Integer && (Integer)query.getZoomValue() > 0) - { - if (!query.getZoomTableName().equalsIgnoreCase(gTab.getTableName())) - { - detailQuery = query; - query = new MQuery(); - query.addRestriction("1=2"); - } - } - isCancel = false; //Goodwill - query = initialQuery (query, gTab); - if (isCancel) return false; //Cancel opening window - if (query != null && query.getRecordCount() <= 1) - goSingleRow = true; - } - else if (wb != 0) - // workbench dynamic query for dependent windows - { - query = m_mWorkbench.getQuery(); - } - // Set initial Query on first tab - if (query != null) - { - m_onlyCurrentRows = false; // Query might involve history - gTab.setQuery(query); - } - if (wb == 0) - m_curTab = gTab; - } // query on first tab - - Component tabElement = null; - // GridController - if (gTab.isSortTab()) - { - VSortTab st = new VSortTab(m_curWindowNo, gTab.getAD_Table_ID(), - gTab.getAD_ColumnSortOrder_ID(), gTab.getAD_ColumnSortYesNo_ID()); - st.setTabLevel(gTab.getTabLevel()); - tabElement = st; - } - else // normal tab - { - GridController gc = new GridController(); // Timing: ca. .1 sec - CompiereColor cc = CompiereColor.getCompiereColor(mWindow.getColor()); - if (cc != null) - gc.setBackgroundColor(cc); // set color on Window level - gc.initGrid(gTab, false, m_curWindowNo, this, mWindow, (tab != 0)); // will set color on Tab level - // Timing: ca. 6-7 sec for first .2 for next - gc.addDataStatusListener(this); - gc.registerESCAction(aIgnore); // register Escape Key - // Set First Tab - if (wb == 0 && tab == 0) - { - m_curGC = gc; - Dimension size = gc.getPreferredSize(); // Screen Sizing - size.width += 4; - size.height += 4; - gc.setPreferredSize(size); - } - tabElement = gc; - // If we have a zoom query, switch to single row - if (tab == 0 && goSingleRow) - gc.switchSingleRow(); - - // FR [ 1757088 ] - GridField[] fields = gc.getMTab().getFields(); - int m_tab_id = 0; - for(int f =0 ; f < fields.length ; f ++) - { - m_tab_id = fields[f].getIncluded_Tab_ID(); - if ( m_tab_id != 0) - { - includedMap.put(m_tab_id, gc); - } - } - - // Is this tab included? - if (includedMap.size() > 0) - { - GridController parent = (GridController)includedMap.get(Integer.valueOf(gTab.getAD_Tab_ID())); - if (parent != null) - { - // FR [ 1757088 ] - gc.removeDataStatusListener(this); - GridSynchronizer synchronizer = new GridSynchronizer(mWindow, parent, gc); - if (parent == m_curGC) - synchronizer.activateChild(); - included = parent.includeTab(gc,this,synchronizer); - } - } - initSwitchLineAction(); - } // normal tab - - if (!included) // Add to TabbedPane - { - StringBuilder tabName = new StringBuilder (); - tabName.append (""); - if (gTab.isReadOnly()) - tabName.append(""); - int pos = gTab.getName ().indexOf (" "); - if (pos == -1) - tabName.append (gTab.getName ()).append ("
     "); - else - { - tabName.append (gTab.getName().substring (0, pos)) - .append ("
    ") - .append (gTab.getName().substring(pos + 1)); - } - if (gTab.isReadOnly()) - tabName.append("
    "); - // Carlos Ruiz - globalqss - IDEMPIERE-38 Tabs from a same window can't be translated the same way - tabName.append(""); - tabName.append (""); - // Add Tab - sets ALT- and Shift-ALT- - window.addTab (tabName.toString(), gTab, tabElement); - } - } // Tab Loop - // Tab background - // window.setBackgroundColor(new AdempiereColor(Color.magenta, Color.green)); - } // Type-MWindow - - // Single Workbench Window Tab - if (m_mWorkbench.getWindowCount() == 1) - { - window.setToolTipText(m_mWorkbench.getDescription(wb)); - } - else - // Add Workbench Window Tab - { - tabPanel.addTab(m_mWorkbench.getName(wb), m_mWorkbench.getIcon(wb), window, m_mWorkbench.getDescription(wb)); - } - // Used for Env.getHeader - Env.setContext(m_ctx, m_curWindowNo, "_WinInfo_WindowName", m_mWorkbench.getName(wb)); - - } // Workbench Loop - - // stateChanged (<->) triggered - toolBar.setName(getTitle()); - m_curTab.getTableModel().setChanged(false); - // Set Detail Button - aDetail.setEnabled(0 != m_curWinTab.getTabCount()-1); - - // Enable/Disable Tabs dynamically - if (m_curWinTab instanceof VTabbedPane) - ((VTabbedPane)m_curWinTab).evaluate(null); - // Size - if (windowSize != null) - setPreferredSize(windowSize); - else - revalidate(); - - if (detailQuery != null && zoomToDetailTab(detailQuery)) { - return true; - } - - Dimension size = getPreferredSize(); - if (log.isLoggable(Level.INFO)) log.info( "fini - " + size); - m_curWinTab.requestFocusInWindow(); - return true; - } // initPanel - - private boolean zoomToDetailTab(MQuery query) { - if (query != null && query.getZoomTableName() != null && query.getZoomColumnName() != null) - { - GridTab gTab = m_mWorkbench.getMWindow(0).getTab(0); - if (!query.getZoomTableName().equalsIgnoreCase(gTab.getTableName())) - { - int tabSize = m_mWorkbench.getMWindow(0).getTabCount(); - - for (int tab = 0; tab < tabSize; tab++) - { - gTab = m_mWorkbench.getMWindow(0).getTab(tab); - if (gTab.isSortTab()) - continue; - - if (gTab.getTableName().equalsIgnoreCase(query.getZoomTableName())) - { - if (doZoomToDetail(gTab, query, tab)) { - return true; - } - } - } - } - } - return false; - } - - private boolean doZoomToDetail(GridTab gTab, MQuery query, int tabIndex) { - GridField[] fields = gTab.getFields(); - for (GridField field : fields) - { - if (field.getColumnName().equalsIgnoreCase(query.getZoomColumnName())) - { - m_mWorkbench.getMWindow(0).initTab(tabIndex); - int parentId = DB.getSQLValue(null, "SELECT " + gTab.getLinkColumnName() + " FROM " + gTab.getTableName() + " WHERE " + query.getWhereClause()); - if (parentId > 0) - { - MapparentMap = new TreeMap(); - int index = tabIndex; - int oldpid = parentId; - GridTab currentTab = gTab; - while (index > 0) - { - index--; - GridTab pTab = m_mWorkbench.getMWindow(0).getTab(index); - if (pTab.getTabLevel() < currentTab.getTabLevel()) - { - m_mWorkbench.getMWindow(0).initTab(index); - if (index > 0) - { - if (pTab.getLinkColumnName() != null && pTab.getLinkColumnName().trim().length() > 0) - { - int pid = DB.getSQLValue(null, "SELECT " + pTab.getLinkColumnName() + " FROM " + pTab.getTableName() + " WHERE " + currentTab.getLinkColumnName() + " = ?", oldpid); - if (pid > 0) - { - parentMap.put(index, new Object[]{currentTab.getLinkColumnName(), oldpid}); - oldpid = pid; - currentTab = pTab; - } - else - { - parentMap.clear(); - break; - } - } - } - else - { - parentMap.put(index, new Object[]{currentTab.getLinkColumnName(), oldpid}); - } - } - } - for(Map.Entry entry : parentMap.entrySet()) - { - GridTab pTab = m_mWorkbench.getMWindow(0).getTab(entry.getKey()); - Object[] value = entry.getValue(); - MQuery pquery = new MQuery(pTab.getAD_Table_ID()); - pquery.addRestriction((String)value[0], "=", value[1]); - pTab.setQuery(pquery); - GridController gc = (GridController) tabPanel.getComponentAt(entry.getKey()); - gc.activate(); - gc.query(false, 0, 0); - } - - - MQuery targetQuery = new MQuery(gTab.getAD_Table_ID()); - targetQuery.addRestriction(gTab.getLinkColumnName(), "=", parentId); - gTab.setQuery(targetQuery); - GridController gc = null; - if (!includedMap.containsKey(gTab.getAD_Tab_ID())) - { - int target = tabPanel.findTabindex(gTab); - gc = (GridController) tabPanel.getComponentAt(target); - } - else - { - GridController parent = includedMap.get(gTab.getAD_Tab_ID()); - gc = parent.findChild(gTab); - } - gc.activate(); - gc.query(false, 0, 0); - - GridTable table = gTab.getTableModel(); - int count = table.getRowCount(); - for(int i = 0; i < count; i++) - { - int id = table.getKeyID(i); - if (id == ((Integer)query.getZoomValue()).intValue()) - { - if (!includedMap.containsKey(gTab.getAD_Tab_ID())) - { - tabPanel.setSelectedIndex(tabPanel.findTabindex(gTab)); - } - else - { - GridController parent = includedMap.get(gTab.getAD_Tab_ID()); - int pindex = tabPanel.findTabindex(parent.getMTab()); - if (pindex >= 0) - tabPanel.setSelectedIndex(pindex); - } - gTab.navigate(i); - return true; - } - } - } - } - } - return false; - } - - /** - * Get Current Window No - * @return win no - */ - public int getWindowNo() - { - return m_curWindowNo; - } // getWindowNo - - /** - * Initial Query - * @param query initial query - * @param mTab tab - * @return query or null - */ - private MQuery initialQuery (MQuery query, GridTab mTab) - { - MRole role = MRole.getDefault(m_ctx, false); - // We have a (Zoom) query - if (query != null && query.isActive() && !role.isQueryMax(query.getRecordCount())) - return query; - // - StringBuffer where = new StringBuffer(Env.parseContext(m_ctx, m_curWindowNo, mTab.getWhereExtended(), false)); - // Query automatically if high volume and no query - boolean require = mTab.isHighVolume(); - if (!require && !m_onlyCurrentRows) // No Trx Window - { - /* Where Extended already appended above, check for variables */ - if (query != null) - { - String wh2 = query.getWhereClause(); - if (wh2.length() > 0) - { - if (where.length() > 0) - where.append (" AND "); - where.append(wh2); - } - } - // - StringBuffer sql = new StringBuffer("SELECT COUNT(*) FROM ") - .append(mTab.getTableName()); - if (where.length() > 0) - sql.append(" WHERE ").append(where); - // Does not consider security - int no = DB.getSQLValue(null, sql.toString()); - // - require = MRole.getDefault().isQueryRequire(no); - } - // Show Query - if (require) - { - GridField[] findFields = mTab.getFields(); - Find find = new Find (AEnv.getFrame(this), m_curWindowNo, mTab.getName(), - mTab.getAD_Tab_ID(), mTab.getAD_Table_ID(), mTab.getTableName(), - where.toString(), findFields, 10); // no query below 10 - query = find.getQuery(); - isCancel = (query == null);//Goodwill - find.dispose(); - find = null; - } - return query; - } // initialQuery - - - /** - * Get Window Index - * @return Window Index - */ - private int getWindowIndex() - { - // only one window - if (m_mWorkbench.getWindowCount() == 1) - return 0; - // workbench - return tabPanel.getSelectedIndex(); - } // getWindowIndex - - /** - * Is first Tab (on Window) - * @return true if the panel displays the first tab - */ - private boolean isFirstTab() - { - return m_curWinTab.getSelectedIndex() == 0; - } // isFirstTab - - /** - * Get Window Image - * @return image or null - */ - public Image getImage() - { - return m_mWorkbench.getImage(getWindowIndex()); - } // getImage - - - /************************************************************************** - * Data Status Listener (row change) ^ | v - * @param e event - */ - public void dataStatusChanged (DataStatusEvent e) - { - if (m_disposing) - return; - if (log.isLoggable(Level.INFO)) log.info(e.getMessage()); - String dbInfo = e.getMessage(); - if (m_curTab != null && m_curTab.isQueryActive()) - dbInfo = "[ " + dbInfo + " ]"; - statusBar.setStatusDB(dbInfo, e); - if (!isNested) - m_window.setTitle(getTitle()); - - // Set Message / Info - if (e.getAD_Message() != null || e.getInfo() != null) - { - StringBuilder sb = new StringBuilder(); - String msg = e.getMessage(); - if (msg != null && msg.length() > 0) - sb.append(Msg.getMsg(m_ctx, e.getAD_Message())); - String info = e.getInfo(); - if (info != null && info.length() > 0) - { - if (sb.length() > 0 && !sb.toString().trim().endsWith(":")) - sb.append(": "); - sb.append(info); - } - if (sb.length() > 0) - { - int pos = sb.indexOf("\n"); - if (pos != -1) // replace CR/NL - sb.replace(pos, pos+1, " - "); - setStatusLine (sb.toString (), e.isError ()); - } - } - - // Confirm Error - if (e.isError() && !e.isConfirmed()) - { - ADialog.error(m_curWindowNo, this, e.getAD_Message(), e.getInfo()); - e.setConfirmed(true); // show just once - if MTable.setCurrentRow is involved the status event is re-issued - m_errorDisplayed = true; - } - // Confirm Warning - else if (e.isWarning() && !e.isConfirmed()) - { - ADialog.warn(m_curWindowNo, this, e.getAD_Message(), e.getInfo()); - e.setConfirmed(true); // show just once - if MTable.setCurrentRow is involved the status event is re-issued - } - - // update Navigation - boolean firstRow = e.isFirstRow(); - aFirst.setEnabled(!firstRow); - aPrevious.setEnabled(!firstRow); - boolean lastRow = e.isLastRow(); - aNext.setEnabled(!lastRow); - aLast.setEnabled(!lastRow); - - // update Change - - boolean changed = e.isChanged() || e.isInserting(); - //int changedColumn = e.getChangedColumn(); - //boolean inserting = e.isInserting(); - - if(e.getAD_Message() != null && e.getAD_Message().equals("Saved")) - changed = false; - boolean readOnly = m_curTab.isReadOnly(); - boolean insertRecord = !readOnly; - boolean deleteRecord = !readOnly; - if (insertRecord) - insertRecord = m_curTab.isInsertRecord(); - aNew.setEnabled(!changed && insertRecord); - aCopy.setEnabled(!changed && insertRecord); - aRefresh.setEnabled(!changed); - if (deleteRecord) - deleteRecord = m_curTab.isDeleteRecord(); - aDelete.setEnabled(!changed && deleteRecord); - aDeleteSelection.setEnabled(!changed && !readOnly); - // - if (readOnly && m_curTab.isAlwaysUpdateField()) - readOnly = false; - aIgnore.setEnabled(changed && !readOnly); - aSave.setEnabled(changed && !readOnly); - aSaveAndCreate.setEnabled(changed && !readOnly); - // - // No Rows - if (e.getTotalRows() == 0 && insertRecord) { - aNew.setEnabled(true); - aDelete.setEnabled(false); - aDeleteSelection.setEnabled(false); - } - - // Single-Multi - aMulti.setPressed(!m_curGC.isSingleRow()); - - // History (on first Tab only) - if (isFirstTab()) - aHistory.setPressed(!m_curTab.isOnlyCurrentRows()); - - // Transaction info - String trxInfo = m_curTab.getStatusLine(); - if (trxInfo != null) - statusBar.setInfo(trxInfo); - - // Check Attachment - boolean canHaveAttachment = m_curTab.canHaveAttachment(); // not single _ID column - // - if (canHaveAttachment && e.isLoading() && m_curTab.getCurrentRow() > e.getLoadedRows()) - canHaveAttachment = false; - if (canHaveAttachment && m_curTab.getRecord_ID() == -1) // No Key - canHaveAttachment = false; - if (canHaveAttachment) - { - aAttachment.setEnabled(true); - aAttachment.setPressed(m_curTab.hasAttachment()); - aPostIt.setEnabled(true); - aPostIt.setPressed(m_curTab.hasPostIt()); - aChat.setEnabled(true); - aChat.setPressed(m_curTab.hasChat()); - } - else - { - aAttachment.setEnabled(false); - aPostIt.setEnabled(false); - aChat.setEnabled(false); - } - // Lock Indicator - if (m_isPersonalLock) - aLock.setPressed(m_curTab.isLocked()); - - if (m_curWinTab instanceof VTabbedPane) - ((VTabbedPane)m_curWinTab).evaluate(e); - // log.info("- fini", e.getMessage()); - } // dataStatusChanged - - /** - * Set Status Line to text - * @param text clear text - * @param error error flag - */ - public void setStatusLine (String text, boolean error) - { - if (log.isLoggable(Level.FINE)) log.fine(text); - statusBar.setStatusLine(text, error); - } // setStatusLine - - /** - * Indicate Busy - * @param busy busy - * @param focus request focus - */ - private void setBusy (boolean busy, boolean focus) - { - m_isLocked = busy; - // - JFrame frame = AEnv.getFrame(this); - if (frame == null) // during init - return; - if (frame instanceof AWindow) - ((AWindow)frame).setBusy(busy); - // String processing = Msg.getMsg(m_ctx, "Processing"); - if (busy) - { - // setStatusLine(processing); - this.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); - frame.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); - } - else - { - this.setCursor(Cursor.getDefaultCursor()); - frame.setCursor(Cursor.getDefaultCursor()); - if (focus) - m_curGC.requestFocus(); - // if (statusBar.getStatusLine().equals(processing)) - // statusBar.setStatusLine(""); - } - } // set Busy - - - /************************************************************************** - * Change Listener - (tab change) <-> - * @param e event - */ - public void stateChanged (ChangeEvent e) - { - if (m_disposing) - return; - if (log.isLoggable(Level.INFO)) log.info(e.toString()); - setBusy(true, true); - - VTabbedPane tp = (VTabbedPane)e.getSource(); - boolean back = false; - boolean isAPanelTab = false; - - //int previousIndex = 0; - - // Workbench Tab Change - if (tp.isWorkbench()) - { - int WBIndex = tabPanel.getSelectedIndex(); - m_curWindowNo = m_mWorkbench.getWindowNo(WBIndex); - // Window Change - if (log.isLoggable(Level.INFO)) log.info("curWin=" + m_curWindowNo + " - Win=" + tp); - if (tp.getSelectedComponent() instanceof JTabbedPane) - m_curWinTab = (JTabbedPane)tp.getSelectedComponent(); - else - throw new java.lang.IllegalArgumentException("Window does not contain Tabs"); - if (m_curWinTab.getSelectedComponent() instanceof GridController) { - m_curGC = (GridController)m_curWinTab.getSelectedComponent(); - initSwitchLineAction(); - } - // else if (m_curWinTab.getSelectedComponent() instanceof APanelTab) - // isAPanelTab = true; - else - throw new java.lang.IllegalArgumentException("Window-Tab does not contain GridControler"); - // change pointers - m_curTabIndex = m_curWinTab.getSelectedIndex(); - } - else - { - // Just a Tab Change - if (log.isLoggable(Level.INFO)) log.info("Tab=" + tp); - m_curWinTab = tp; - int tpIndex = m_curWinTab.getSelectedIndex(); - // detect no tab change - if (tpIndex == m_curTabIndex) return; - back = tpIndex < m_curTabIndex; - GridController gc = null; - if (m_curWinTab.getSelectedComponent() instanceof GridController) - gc = (GridController)m_curWinTab.getSelectedComponent(); - else if (m_curWinTab.getSelectedComponent() instanceof APanelTab) - isAPanelTab = true; - else - throw new java.lang.IllegalArgumentException("Tab does not contain GridControler"); - // Save old Tab - if (m_curGC != null) - { - m_curGC.stopEditor(true); - // has anything changed? - if (m_curTab.needSave(true, false)) - { // do we have real change - if (m_curTab.needSave(true, true)) - { - // Automatic Save - if (Env.isAutoCommit(m_ctx, m_curWindowNo)) - { - if (!m_curTab.dataSave(true)) - { // there is a problem, so we go back - showLastError(); - m_curWinTab.setSelectedIndex(m_curTabIndex); - setBusy(false, true); - return; - } - } - // explicitly ask when changing tabs - else if (ADialog.ask(m_curWindowNo, this, "SaveChanges?", m_curTab.getCommitWarning())) - { // yes we want to save - if (!m_curTab.dataSave(true)) - { // there is a problem, so we go back - showLastError(); - m_curWinTab.setSelectedIndex(m_curTabIndex); - setBusy(false, true); - return; - } - } - else // Don't save - { - int newRecord= m_curTab.getTableModel().getNewRow(); //VOSS COM - - if( newRecord == -1) - m_curTab.dataIgnore(); - else - { - m_curWinTab.setSelectedIndex(m_curTabIndex); - setBusy(false, true); - return; - } - } - } - - else // new record, but nothing changed - m_curTab.dataIgnore(); - } // there is a change - } - if (m_curAPanelTab != null) - { - m_curAPanelTab.saveData(); - m_curAPanelTab.unregisterPanel(); - m_curAPanelTab = null; - } - - // new tab - // if (m_curTabIndex >= 0) - // m_curWinTab.setForegroundAt(m_curTabIndex, AdempierePLAF.getTextColor_Normal()); - // m_curWinTab.setForegroundAt(tpIndex, AdempierePLAF.getTextColor_OK()); - // previousIndex = m_curTabIndex; - m_curTabIndex = tpIndex; - if (!isAPanelTab) { - m_curGC = gc; - initSwitchLineAction(); - } - } - - // Sort Tab Handling - if (isAPanelTab) - { - m_curAPanelTab = (APanelTab)m_curWinTab.getSelectedComponent(); - m_curAPanelTab.registerAPanel(this); - m_curAPanelTab.loadData(); - // Consider that APanelTab (e.g. VSortTab) is not navigable - teo_sarca [ 1705444 ] - aFirst.setEnabled(false); - aPrevious.setEnabled(false); - aNext.setEnabled(false); - aLast.setEnabled(false); - } - else // Cur Tab Setting - { - int gwTabIndex = m_mWorkbench.getMWindow(0).getTabIndex(m_curGC.getMTab()); - //boolean needValidate = false; - if (m_mWorkbench.getMWindow(0).isTabInitialized(gwTabIndex) == false) - { - m_mWorkbench.getMWindow(0).initTab(gwTabIndex); - //needValidate = true; - } - m_curGC.activate(); - m_curTab = m_curGC.getMTab(); - - // Refresh only current row when tab is current - if (back && m_curTab.isCurrent()) - m_curTab.dataRefresh(); - else // Requery & autoSize - { - MRole role = MRole.getDefault(); - m_curGC.query (m_onlyCurrentRows, m_onlyCurrentDays, role.getMaxQueryRecords()); - /* - if (m_curGC.isNeedToSaveParent()) - { - // there is a problem, so we go back - ADialog.error(m_curWindowNo, this, "SaveParentFirst"); - m_curWinTab.setSelectedIndex(previousIndex); - setBusy(false, true); - return; - }*/ - } - // Set initial record - if (m_curTab.getRowCount() == 0) - { - // Automatically create New Record, if none & tab not RO - if (!m_curTab.isReadOnly() - && (Env.isAutoNew(m_ctx, m_curWindowNo) || m_curTab.isQueryNewRecord())) - { - if (log.isLoggable(Level.CONFIG)) log.config("No record - New - AutoNew=" + Env.isAutoNew(m_ctx, m_curWindowNo) - + " - QueryNew=" + m_curTab.isQueryNewRecord()); - m_curTab.dataNew(false); - } - else // No Records found - { - aSave.setEnabled(false); - aSaveAndCreate.setEnabled(false); - aDelete.setEnabled(false); - aDeleteSelection.setEnabled(false); - } - m_curTab.navigateCurrent(); // updates counter - m_curGC.dynamicDisplay(0); - } - /* - if (needValidate) - { - JFrame frame = Env.getFrame(APanel.this); - if (frame != null) - { - //not sure why, the following lines is needed to make dynamic resize work - //tested on jdk1.5, 1.6 using jgoodies look and feel - frame.getPreferredSize(); - - if (frame.getExtendedState() != JFrame.MAXIMIZED_BOTH) - { - frame.setMinimumSize(frame.getSize()); - revalidate(); - SwingUtilities.invokeLater(new Runnable() { - - public void run() { - JFrame frame = Env.getFrame(APanel.this); - frame.validate(); - AEnv.showCenterScreen(frame); - frame.setMinimumSize(null); - } - - }); - } - } - }*/ - // else ##CHANGE - // m_curTab.navigateCurrent(); - } - - // Update <-> Navigation - aDetail.setEnabled(m_curTabIndex != m_curWinTab.getTabCount()-1); - aParent.setEnabled(m_curTabIndex != 0 && m_curWinTab.getTabCount() > 1); - - // History (on first tab only) - if (m_mWorkbench.getMWindow(getWindowIndex()).isTransaction()) - aHistory.setEnabled(isFirstTab()); - else - { - aHistory.setPressed(false); - aHistory.setEnabled(false); - } - // Document Print - aPrint.setEnabled(m_curTab.isPrinted()); - aPrintPreview.setEnabled(m_curTab.isPrinted()); - // Query - aFind.setPressed(m_curTab.isQueryActive()); - - // Order Tab - if (isAPanelTab) - { - aMulti.setPressed(false); - aMulti.setEnabled(false); - aNew.setEnabled(false); - aDelete.setEnabled(false); - aDeleteSelection.setEnabled(false); - aFind.setEnabled(false); - aRefresh.setEnabled(false); - aAttachment.setEnabled(false); - aPostIt.setEnabled(false); - aChat.setEnabled(false); - } - else // Grid Tab - { - aMulti.setEnabled(true); - aMulti.setPressed(!m_curGC.isSingleRow()); - aFind.setEnabled(true); - aRefresh.setEnabled(true); - aAttachment.setEnabled(true); - aPostIt.setEnabled(true); - aChat.setEnabled(true); - - // IDEMPIERE-587 - Swing: Toolbar Button to start Process from button fields - // tbayen - 2013-01-22 - GridField[] fields = m_curGC.getMTab().getFields(); - boolean processEnabled=false; - for(GridField field:fields){ - if (field.isToolbarButton() && field.isDisplayed()){ - processEnabled=true; - break; - } - } - aProcess.setEnabled(processEnabled); - } - - // - m_curWinTab.requestFocusInWindow(); - setBusy(false, true); - - if (!ToolBarMenuRestictionLoaded) - { - updateToolBarAndMenuWithRestriction(); - ToolBarMenuRestictionLoaded = true; - } - - log.config( "fini"); - } // stateChanged - - /** - * Navigate to Detail Tab -> - */ - private void cmd_detail() - { - int index = m_curWinTab.getSelectedIndex(); - if (index == m_curWinTab.getTabCount()-1) - return; - //hengsin, bug [ 1637763 ] - if (m_curWinTab instanceof VTabbedPane) - { - VTabbedPane tabPane = (VTabbedPane)m_curWinTab; - index++; - while ( index < tabPane.getTabCount() ) - { - if (tabPane.isEnabledAt(index)) - { - m_curGC.getTable().removeEditor(); - m_curGC.acceptEditorChanges(); - tabPane.setSelectedIndex(index); - break; - } - else - index++; - } - } - else - { - m_curGC.getTable().removeEditor(); - m_curGC.acceptEditorChanges(); - m_curWinTab.setSelectedIndex(index+1); - } - - } // navigateDetail - - /** - * Navigate to Parent Tab <- - */ - private void cmd_parent() - { - int index = m_curWinTab.getSelectedIndex(); - if (index == 0) - return; - //hengsin, bug [ 1637763 ] - if (m_curWinTab instanceof VTabbedPane) - { - VTabbedPane tabPane = (VTabbedPane)m_curWinTab; - index--; - while ( index >= 0 ) - { - if (tabPane.isEnabledAt(index)) - { - m_curGC.getTable().removeEditor(); - m_curGC.acceptEditorChanges(); - tabPane.setSelectedIndex(index); - break; - } - else - index--; - } - } - else - { - m_curGC.getTable().removeEditor(); - m_curGC.acceptEditorChanges(); - m_curWinTab.setSelectedIndex(index-1); - } - } // navigateParent - - - /************************************************************************** - * Action Listener - * @param e event - */ - public void actionPerformed (ActionEvent e) - { - if (log.isLoggable(Level.INFO)) log.info(e.getActionCommand() + " - " + e.getModifiers()); - // + " - " + new Timestamp(e.getWhen()) + " " + isUILocked()); - if (m_disposing || isUILocked()) - return; - - m_lastModifiers = e.getModifiers(); - String cmd = e.getActionCommand(); - // Do ScreenShot w/o busy - if (cmd.equals("ScreenShot")) - { - AEnv.actionPerformed (e.getActionCommand(), m_curWindowNo, this); - return; - } - - // Problem: doubleClick detection - can't disable button as clicking button may change button status - if (!cmd.equals(aShowAllWindow.getName())) - setBusy (true, true); - // Command Buttons - if (e.getSource() instanceof VButton) - { - setStatusLine(processButtonCallout((VButton)e.getSource()), true); - actionButton((VButton)e.getSource()); - setBusy(false, true); - return; - } - - try - { - // File - if (cmd.equals(aReport.getName())) - cmd_report(); - else if (cmd.equals(aPrint.getName())) - cmd_print(); - else if (cmd.equals(aPrintPreview.getName())) - cmd_print(true); - else if (aExport != null && cmd.equals(aExport.getName())) - cmd_export(); - else if (cmd.equals(aEnd.getName())) - cmd_end(false); - else if (cmd.equals(aExit.getName())) - cmd_end(true); - // Edit - else if (cmd.equals(aNew.getName())) - cmd_new(false); - else if (cmd.equals(aSave.getName())) - cmd_save(true); - else if (cmd.equals(aSaveAndCreate.getName())) - cmd_saveAndCreate(true); - else if (cmd.equals(aCopy.getName())) - cmd_new(true); - else if (cmd.equals(aDelete.getName())) - cmd_delete(); - else if (cmd.equals(aDeleteSelection.getName())) - cmd_deleteSelection(); - else if (cmd.equals(aIgnore.getName())) - cmd_ignore(); - else if (cmd.equals(aRefresh.getName())) - cmd_refresh(); - else if (cmd.equals(aFind.getName())) - cmd_find(); - else if (m_isPersonalLock && cmd.equals(aLock.getName())) - cmd_lock(); - else if (cmd.equals(aProcess.getName())) - cmd_process(); - // View - else if (cmd.equals(aAttachment.getName())) - cmd_attachment(); - else if (cmd.equals(aPostIt.getName())) - cmd_postIt(); - else if (cmd.equals(aChat.getName())) - cmd_chat(); - else if (cmd.equals(aHistory.getName())) - cmd_history(); - else if (cmd.equals(aMulti.getName())) - m_curGC.switchRowPresentation(); - // Go - else if (cmd.equals(aHome.getName())) { - // show main menu - teo_sarca [ 1706409, 1707221 ] - setBusy(false, false); - AEnv.showWindow(AEnv.getWindow(0)); - return; - } - else if (cmd.equals(aFirst.getName())) - { /*cmd_save(false);*/ - m_curGC.getTable().removeEditor(); - m_curGC.acceptEditorChanges(); - m_curTab.navigate(0); - } - else if (cmd.equals(aSwitchLinesUpAction.getName())) - { - //up-key + shift - m_curGC.getTable().removeEditor(); - m_curTab.switchRows(m_curTab.getCurrentRow(), m_curTab.getCurrentRow() - 1, m_curGC.getTable().getSortColumn(), m_curGC.getTable().isSortAscending()); - m_curGC.getTable().requestFocus(); - } - else if (cmd.equals(aPrevious.getName())) - { /* cmd_save(false); */ - //up-image + shift - m_curGC.getTable().removeEditor(); - m_curGC.acceptEditorChanges(); - if ((e.getModifiers() & ActionEvent.SHIFT_MASK) != 0) { - m_curTab.switchRows(m_curTab.getCurrentRow(), m_curTab.getCurrentRow() - 1, m_curGC.getTable().getSortColumn(), m_curGC.getTable().isSortAscending()); - } else { - m_curTab.navigateRelative(-1); - } - } - else if (cmd.equals(aSwitchLinesDownAction.getName())) - { - //down-key + shift - m_curGC.getTable().removeEditor(); - m_curTab.switchRows(m_curTab.getCurrentRow(), m_curTab.getCurrentRow() + 1, m_curGC.getTable().getSortColumn(), m_curGC.getTable().isSortAscending()); - m_curGC.getTable().requestFocus(); - } - else if (cmd.equals(aNext.getName())) - { /* cmd_save(false); */ - //down-image + shift - m_curGC.getTable().removeEditor(); - m_curGC.acceptEditorChanges(); - if ((e.getModifiers() & ActionEvent.SHIFT_MASK) != 0) { - m_curTab.switchRows(m_curTab.getCurrentRow(), m_curTab.getCurrentRow() + 1, m_curGC.getTable().getSortColumn(), m_curGC.getTable().isSortAscending()); - } else { - m_curTab.navigateRelative(+1); - } - } - else if (cmd.equals(aLast.getName())) - { /*cmd_save(false);*/ - m_curGC.getTable().removeEditor(); - m_curGC.acceptEditorChanges(); - m_curTab.navigate(m_curTab.getRowCount()-1); - } - else if (cmd.equals(aParent.getName())) - cmd_parent(); - else if (cmd.equals(aDetail.getName())) - cmd_detail(); - else if (cmd.equals(aZoomAcross.getName())) - cmd_zoomAcross(); - else if (cmd.equals(aRequest.getName())) - cmd_request(); - else if (cmd.equals(aArchive.getName())) - cmd_archive(); - // Tools - else if (aWorkflow != null && cmd.equals(aWorkflow.getName())) - { - if (m_curTab.getRecord_ID() <= 0) - ; - else if (m_curTab.getTabNo() == 0 && m_mWorkbench.getMWindow(getWindowIndex()).isTransaction()) - AEnv.startWorkflowProcess(m_curTab.getAD_Table_ID(), m_curTab.getRecord_ID()); - else - AEnv.startWorkflowProcess(m_curTab.getAD_Table_ID(), m_curTab.getRecord_ID()); - } - else if (aWinSize != null && cmd.equals(aWinSize.getName())) - cmd_winSize(); - // Help - else if (cmd.equals(aHelp.getName())) - cmd_help(); - // General Commands (Environment) - else if (cmd.equals(aLogout.getName())) - cmd_logout(); - else if (cmd.equals(aShowAllWindow.getName())) - m_WindowMenu.expose(); - else if (!AEnv.actionPerformed (e.getActionCommand(), m_curWindowNo, this)) - log.log(Level.SEVERE, "No action for: " + cmd); - } - catch (Exception ex) - { - log.log(Level.SEVERE, cmd, ex); - String msg = ex.getMessage(); - if (msg == null || msg.length() == 0) - msg = ex.toString(); - msg = Msg.parseTranslation(m_ctx, msg); - ADialog.error(m_curWindowNo, this, "Error", msg); - } - // - m_curWinTab.requestFocusInWindow(); - setBusy(false, true); - } // actionPerformed - - private void cmd_logout() { - JFrame top = AEnv.getWindow(0); - if (top instanceof AMenu) { - ((AMenu)top).logout(); - } - - } - - /************************************************************************** - * Process Callout(s). - *

    - * The Callout is in the string of - * "class.method;class.method;" - * If there is no class name, i.e. only a method name, the class is regarded - * as CalloutSystem. - * The class needs to comply with the Interface Callout. - * - * @param field field - * @return error message or "" - * @see org.compiere.model.Callout - */ - private String processButtonCallout (VButton button) - { - GridField field = m_curTab.getField(button.getColumnName()); - return m_curTab.processCallout(field); - } // processButtonCallout - - /** - * Create New Record - * @param copy true if current record is to be copied - */ - private void cmd_new (boolean copy) - { - if (log.isLoggable(Level.CONFIG)) log.config("copy=" + copy); - if (!m_curTab.isInsertRecord()) - { - log.warning("Insert Record disabled for Tab"); - return; - } - - m_curGC.stopEditor(true); - m_curGC.acceptEditorChanges(); - - // BF [ 2799362 ] attempt to save if save action is enabled. Using - // m_curTab.needSave instead might miss unfilled mandatory fields. - if(aSave.isEnabled()){ - // Automatic Save - if (Env.isAutoCommit(m_ctx, m_curWindowNo)) - { - if (!cmd_save(true)) - { - return; - } - } - // explicitly ask when changing tabs - else if (ADialog.ask(m_curWindowNo, this, "SaveChanges?", m_curTab.getCommitWarning())) - { // yes we want to save - if (!cmd_save(true)) - { - return; - } - } - else // Don't save - m_curTab.dataIgnore(); - } - if (copy && m_curTab.getCurrentRow() < 0) - copy = false; - m_curTab.dataNew (copy); - m_curGC.dynamicDisplay(0); - // m_curTab.getTableModel().setChanged(false); - } // cmd_new - - /** - * Confirm & delete record - */ - private void cmd_delete() - { - if (m_curTab.isReadOnly()) - return; - int keyID = m_curTab.getRecord_ID(); - if (ADialog.ask(m_curWindowNo, this, "DeleteRecord?")) - if (m_curTab.dataDelete()) - m_curGC.rowChanged(false, keyID); - m_curGC.dynamicDisplay(0); - } // cmd_delete - - /** - * Show a list to select one or more items to delete. - */ - private void cmd_deleteSelection(){ - if (m_curTab.isReadOnly()) - return; - //show table with deletion rows -> by identifiers columns - JPanel messagePanel = new JPanel(); - JList list = new JList(); - JScrollPane scrollPane = new JScrollPane(list); - Vector data = new Vector(); - // FR [ 2877111 ] - final String keyColumnName = m_curTab.getKeyColumnName(); - String sql = null; - if (! "".equals(keyColumnName)) { - sql = MLookupFactory.getLookup_TableDirEmbed(Env.getLanguage(m_ctx), keyColumnName, "[?","?]") - .replace("[?.?]", "?"); - } - int noOfRows = m_curTab.getRowCount(); - for(int i = 0; i < noOfRows; i++) - { - StringBuffer displayValue = new StringBuffer(); - if ("".equals(keyColumnName)) - { - ArrayList parentColumnNames = m_curTab.getParentColumnNames(); - for (Iterator iter = parentColumnNames.iterator(); iter.hasNext();) - { - String columnName = iter.next(); - GridField field = m_curTab.getField(columnName); - if(field.isLookup()){ - Lookup lookup = field.getLookup(); - if (lookup != null){ - displayValue = displayValue.append(lookup.getDisplay(m_curTab.getValue(i,columnName))).append(" | "); - } else { - displayValue = displayValue.append(m_curTab.getValue(i,columnName)).append(" | "); - } - } else { - displayValue = displayValue.append(m_curTab.getValue(i,columnName)).append(" | "); - } - } - } else { - final int id = m_curTab.getKeyID(i); - String value = DB.getSQLValueStringEx(null, sql, id); - if (value != null) - value = value.replace(" - ", " | "); - displayValue.append(value); - // Append ID - if (displayValue.length() == 0 || CLogMgt.isLevelFine()) - { - if (displayValue.length() > 0) - displayValue.append(" | "); - displayValue.append("<").append(id).append(">"); - } - } - // - data.add(displayValue.toString()); - } - // FR [ 2877111 ] - list.setListData(data); - - list.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); - messagePanel.add(scrollPane); - - final JOptionPane pane = new JOptionPane( - messagePanel, // message - JOptionPane.QUESTION_MESSAGE, // messageType - JOptionPane.OK_CANCEL_OPTION); // optionType - final JDialog deleteDialog = pane.createDialog(this.getParent(), Msg.getMsg(m_ctx, "DeleteSelection")); - deleteDialog.setVisible(true); - Integer okCancel = (Integer) pane.getValue(); - if(okCancel != null && okCancel == JOptionPane.OK_OPTION) - { - log.fine("ok"); - List selectedValues = list.getSelectedValuesList(); - for (int i = 0; i < selectedValues.size(); i++) - { - if (log.isLoggable(Level.FINE)) log.fine(selectedValues.get(i).toString()); - } - int[] indices = list.getSelectedIndices(); - Arrays.sort(indices); - int offset = 0; - for (int i = 0; i < indices.length; i++) - { - //m_curTab.setCurrentRow(indices[i]-offset); - m_curTab.navigate(indices[i]-offset); - int keyID = m_curTab.getRecord_ID(); - if (m_curTab.dataDelete()) - { - m_curGC.rowChanged(false, keyID); - offset++; - } - } - m_curGC.dynamicDisplay(0); - } - else - { - log.fine("cancel"); - } - }//cmd_deleteSelection - - /** - * If required ask if you want to save and save it - * @param manualCmd true if invoked manually (i.e. force) - * @return true if saved - */ - public boolean cmd_save (boolean manualCmd) - { - if (m_curAPanelTab != null) - manualCmd = false; - if (log.isLoggable(Level.CONFIG)) log.config("Manual=" + manualCmd); - m_errorDisplayed = false; - m_curGC.stopEditor(true); - m_curGC.acceptEditorChanges(); - - if (m_curAPanelTab != null) - { - m_curAPanelTab.saveData(); - aSave.setEnabled(false); // set explicitly - aSaveAndCreate.setEnabled(false); - } - - if (m_curTab.getCommitWarning().length() > 0 && m_curTab.needSave(true, false)) - if (!ADialog.ask(m_curWindowNo, this, "SaveChanges?", m_curTab.getCommitWarning())) - return false; - - // manually initiated - boolean retValue = m_curTab.dataSave(manualCmd); - // if there is no previous error - if (manualCmd && !retValue && !m_errorDisplayed) - { - showLastError(); - } - if (retValue) - m_curGC.rowChanged(true, m_curTab.getRecord_ID()); - if (manualCmd) { - m_curGC.dynamicDisplay(0); - if (!isNested) - m_window.setTitle(getTitle()); - } - - //BEGIN - [FR 1953734] - if(m_curGC.isDetailGrid() && retValue){ - m_curGC.getGCParent().refreshMTab(m_curGC); - } - //END - [FR 1953734] - - return retValue; - } // cmd_save - - private void showLastError() { - String msg = CLogger.retrieveErrorString(null); - if (msg != null) - ADialog.error(m_curWindowNo, this, null, msg); - else - ADialog.error(m_curWindowNo, this, "SaveIgnored"); - setStatusLine(Msg.getMsg(m_ctx, "SaveIgnored"), true); - } - - public boolean cmd_saveAndCreate(boolean manualCmd) - { - boolean retValue = cmd_save(manualCmd); - if(retValue) - cmd_new(false); - return retValue; - } - - private long m_popup_closingtime=0; - - /** - * opens a pulldown menu to start processes from "Button" type fields. - */ - // IDEMPIERE-587 - Swing: Toolbar Button to start Process from button fields - // tbayen - 2013-01-22 - public void cmd_process() { - if(System.currentTimeMillis()-m_popup_closingtime<200) - return; // closed through the same click - user has clicked to close the menu - GridField[] fields = m_curGC.getMTab().getFields(); - final ArrayList processFields = new ArrayList(); - for (GridField field : fields) { - if (field.isToolbarButton() && field.isDisplayed()) { - processFields.add(field); - } - } - JPopupMenu popup = new JPopupMenu(); - popup.addPopupMenuListener(new PopupMenuListener() { - @Override - public void popupMenuWillBecomeInvisible(PopupMenuEvent e) { - m_popup_closingtime=System.currentTimeMillis(); - } - - @Override public void popupMenuWillBecomeVisible(PopupMenuEvent e) {} - @Override public void popupMenuCanceled(PopupMenuEvent e) {} - }); - - for (GridField field : processFields) { - if (field.isDisplayed(true)) { - ImageIcon icon = Env.getImageIcon2("Process16"); - String text = field.getHeader(); - Color color = null; - // Record_ID for Zoom Buttons (see - // http://www.adempiere.com/Entering_Data_-_Fields_and_Buttons#Button) - if (field.getColumnName().endsWith("_ID") - && !field.getColumnName().equals("Record_ID")) { - MLookupFactory.get(Env.getCtx(), - field.getWindowNo(), 0, field.getAD_Column_ID(), - DisplayType.Search); - } else if (field.getAD_Reference_Value_ID() != 0) { - // Assuming List - MLookupFactory.get(Env.getCtx(), - field.getWindowNo(), 0, field.getAD_Column_ID(), - DisplayType.List); - } - - // Special Buttons - int AD_Reference_ID = -1; - String columnName = field.getColumnName(); - if (columnName.equals("PaymentRule")) { - AD_Reference_ID = REFERENCE_PAYMENTRULE; - color = Color.blue; - icon = Env.getImageIcon("Payment16.gif"); // 29*14 - } else if (columnName.equals("DocAction")) { - AD_Reference_ID = REFERENCE_DOCUMENTACTION; - color = Color.blue; - icon = Env.getImageIcon("Process16.gif"); // 16*16 - } else if (columnName.equals("CreateFrom")) { - icon = Env.getImageIcon("Copy16.gif"); // 16*16 - } else if (columnName.equals("Record_ID")) { - icon = Env.getImageIcon("Zoom16.gif"); // 16*16 - text = Msg.getMsg(Env.getCtx(), "ZoomDocument"); - } else if (columnName.equals("Posted")) { - AD_Reference_ID = REFERENCE_POSTED; - color = Color.magenta; - icon = Env.getImageIcon("InfoAccount16.gif"); // 16*16 - } - - Map values = null; - if (AD_Reference_ID > 0) { - values = new HashMap(); - String SQL; - if (Env.isBaseLanguage(Env.getCtx(), "AD_Ref_List")) - SQL = "SELECT Value, Name FROM AD_Ref_List WHERE AD_Reference_ID=?"; - else - SQL = "SELECT l.Value, t.Name FROM AD_Ref_List l, AD_Ref_List_Trl t " - + "WHERE l.AD_Ref_List_ID=t.AD_Ref_List_ID" - + " AND t.AD_Language='" - + Env.getAD_Language(Env.getCtx()) - + "'" - + " AND l.AD_Reference_ID=?"; - PreparedStatement pstmt = null; - ResultSet rs = null; - try { - pstmt = DB.prepareStatement(SQL, null); - pstmt.setInt(1, AD_Reference_ID); - rs = pstmt.executeQuery(); - while (rs.next()) { - String value = rs.getString(1); - String name = rs.getString(2); - values.put(value, name); - } - } catch (SQLException e) { - log.log(Level.SEVERE, SQL, e); - } - finally{ - DB.close(rs, pstmt); - rs = null; - pstmt = null; - } - - // Nothing to show or Record_ID - if (field.getValue() == null - || field.getColumnName().equals("Record_ID")) - ; - else if (values != null) - text = (String) values.get(field.getValue()); - // Display it - } // setValue - - JMenuItem item = new JMenuItem(text, icon); - item.setForeground(color); - item.setName(field.getColumnName()); - popup.add(item); - item.addActionListener(new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - JMenuItem menuItem = ((JMenuItem)e.getSource()); - String columnName=menuItem.getName(); - GridField callingField = m_curTab.getField(columnName); - // - setStatusLine(m_curTab.processCallout(callingField), true); - actionButtonCleanUp(menuItem.getName(), - callingField.getAD_Process_ID(), callingField.getHeader()); - } - }); - } - } - popup.show(aProcess.getButton(), -1, aProcess.getButton().getHeight()); - } - - /** - * Ignore - */ - private void cmd_ignore() - { - m_curGC.stopEditor(false); - // Ignore changes in APanelTab (e.g. VSortTab) - teo_sarca [ 1705429 ] - if (m_curAPanelTab != null) - { - m_curAPanelTab.loadData(); - } - m_curTab.dataIgnore(); - m_curTab.dataRefresh(true); - m_curGC.dynamicDisplay(0); - - } // cmd_ignore - - /** - * Refresh - */ - private void cmd_refresh() - { - cmd_save(false); - m_curTab.dataRefreshAll(); - m_curGC.dynamicDisplay(0); - } // cmd_refresh - - /** - * Print standard Report - */ - private void cmd_report () - { - log.info(""); - if (!MRole.getDefault().isCanReport(m_curTab.getAD_Table_ID())) - { - ADialog.error(m_curWindowNo, this, "AccessCannotReport"); - return; - } - - cmd_save(false); - - // Query - MQuery query = new MQuery(m_curTab.getTableName()); - // Link for detail records - String queryColumn = m_curTab.getLinkColumnName(); - // Current row otherwise - if (queryColumn.length() == 0) - queryColumn = m_curTab.getKeyColumnName(); - // Find display - String infoName = null; - String infoDisplay = null; - for (int i = 0; i < m_curTab.getFieldCount(); i++) - { - GridField field = m_curTab.getField(i); - if (field.isKey()) - infoName = field.getHeader(); - if ((field.getColumnName().equals("Name") || field.getColumnName().equals("DocumentNo") ) - && field.getValue() != null) - infoDisplay = field.getValue().toString(); - if (infoName != null && infoDisplay != null) - break; - } - if (queryColumn.length() != 0) - { - if (queryColumn.endsWith("_ID")) - query.addRestriction(queryColumn, MQuery.EQUAL, - Integer.valueOf(Env.getContextAsInt(m_ctx, m_curWindowNo, queryColumn)), - infoName, infoDisplay); - else - query.addRestriction(queryColumn, MQuery.EQUAL, - Env.getContext(m_ctx, m_curWindowNo, queryColumn), - infoName, infoDisplay); - } - - new AReport (m_curTab.getAD_Table_ID(), aReport.getButton(), query, this, m_curWindowNo, m_curTab.getWhereExtended()); - } // cmd_report - - - /** - * Zoom Across Menu - */ - private void cmd_zoomAcross() - { - int record_ID = m_curTab.getRecord_ID(); - if (log.isLoggable(Level.INFO)) log.info("ID=" + record_ID); - if (record_ID <= 0) - return; - - // Query - MQuery query = new MQuery(); - // Current row - String link = m_curTab.getKeyColumnName(); - // Link for detail records - if (link.length() == 0) - link = m_curTab.getLinkColumnName(); - if (link.length() != 0) - { - if (link.endsWith("_ID")) - query.addRestriction(link, MQuery.EQUAL, - Integer.valueOf(Env.getContextAsInt(m_ctx, m_curWindowNo, link))); - else - query.addRestriction(link, MQuery.EQUAL, - Env.getContext(m_ctx, m_curWindowNo, link)); - } - new AZoomAcross(aZoomAcross.getButton(), m_curTab.getTableName(), - m_curTab.getAD_Window_ID(), query); - } // cmd_zoom - - /** - * Open/View Request - */ - private void cmd_request() - { - int record_ID = m_curTab.getRecord_ID(); - if (log.isLoggable(Level.INFO)) log.info("ID=" + record_ID); - if (record_ID <= 0) - return; - - int AD_Table_ID = m_curTab.getAD_Table_ID(); - int C_BPartner_ID = 0; - Object BPartner_ID = m_curTab.getValue("C_BPartner_ID"); - if (BPartner_ID != null) - C_BPartner_ID = ((Integer)BPartner_ID).intValue(); - new ARequest (aRequest.getButton(), AD_Table_ID, record_ID, C_BPartner_ID); - } // cmd_request - - /** - * Open/View Archive - */ - private void cmd_archive() - { - int record_ID = m_curTab.getRecord_ID(); - if (log.isLoggable(Level.INFO)) log.info("ID=" + record_ID); - if (record_ID <= 0) - return; - - int AD_Table_ID = m_curTab.getAD_Table_ID(); - new AArchive (aArchive.getButton(), AD_Table_ID, record_ID); - } // cmd_archive - - /** - * Print specific Report - or start default Report - */ - private void cmd_print() - { - cmd_print(false); - } - - /** - * Print specific Report - or start default Report - */ - private void cmd_print(boolean printPreview) - { - // Get process defined for this tab - int AD_Process_ID = m_curTab.getAD_Process_ID(); - if (log.isLoggable(Level.INFO)) log.info("ID=" + AD_Process_ID); - - // No report defined - if (AD_Process_ID == 0) - { - cmd_report(); - return; - } - - cmd_save(false); - // - int table_ID = m_curTab.getAD_Table_ID(); - int record_ID = m_curTab.getRecord_ID(); - ProcessInfo pi = new ProcessInfo (getTitle(), AD_Process_ID, table_ID, record_ID); - pi.setAD_User_ID (Env.getAD_User_ID(m_ctx)); - pi.setAD_Client_ID (Env.getAD_Client_ID(m_ctx)); - pi.setPrintPreview(printPreview); - pi.setAD_Process_UU(m_curTab.getAD_Process_UU()); - - ClientProcessCtrl.process(this, m_curWindowNo, pi, null); // calls lockUI, unlockUI - statusBar.setStatusLine(pi.getSummary(), pi.isError()); - } // cmd_print - - /** - * Find - Set Query - */ - private void cmd_find() - { - if (m_curTab == null) - return; - cmd_save(false); - // Gets Fields from AD_Field_v - GridField[] findFields = GridField.createFields(m_ctx, m_curWindowNo, 0, m_curTab.getAD_Tab_ID()); - Find find = new Find (AEnv.getFrame(this), m_curWindowNo, m_curTab.getName(), - m_curTab.getAD_Tab_ID(), m_curTab.getAD_Table_ID(), m_curTab.getTableName(), - m_curTab.getWhereExtended(), findFields, 1); - MQuery query = find.getQuery(); - find.dispose(); - find = null; - - // Confirmed query - if (query != null) - { - m_onlyCurrentRows = false; // search history too - m_curTab.setQuery(query); - m_curGC.query(m_onlyCurrentRows, m_onlyCurrentDays, 0); // autoSize - } - aFind.setPressed(m_curTab.isQueryActive()); - } // cmd_find - - /** - * Attachment - */ - private void cmd_attachment() - { - int record_ID = m_curTab.getRecord_ID(); - if (log.isLoggable(Level.INFO)) log.info("Record_ID=" + record_ID); - if (record_ID == -1) // No Key - { - aAttachment.setEnabled(false); - return; - } - - @SuppressWarnings("unused") - Attachment va = new Attachment (AEnv.getFrame(this), m_curWindowNo, - m_curTab.getAD_AttachmentID(), m_curTab.getAD_Table_ID(), record_ID, null); - // - aAttachment.setPressed(m_curTab.hasAttachment()); - } // attachment - - /** - * Chat - */ - private void cmd_chat() - { - int record_ID = m_curTab.getRecord_ID(); - if (log.isLoggable(Level.INFO)) log.info("Record_ID=" + record_ID); - if (record_ID == -1) // No Key - { - aChat.setEnabled(false); - return; - } - // Find display - String infoName = null; - String infoDisplay = null; - for (int i = 0; i < m_curTab.getFieldCount(); i++) - { - GridField field = m_curTab.getField(i); - if (field.isKey()) - infoName = field.getHeader(); - if ((field.getColumnName().equals("Name") || field.getColumnName().equals("DocumentNo") ) - && field.getValue() != null) - infoDisplay = field.getValue().toString(); - if (infoName != null && infoDisplay != null) - break; - } - String description = infoName + ": " + infoDisplay; - // - // AChat va = - new AChat (AEnv.getFrame(this), m_curWindowNo, - m_curTab.getCM_ChatID(), m_curTab.getAD_Table_ID(), record_ID, - description, null); - // - aChat.setPressed(m_curTab.hasChat()); - } // chat - - /** - * Lock - */ - private void cmd_lock() - { - if (log.isLoggable(Level.INFO)) log.info("Modifiers=" + m_lastModifiers); - if (!m_isPersonalLock) - return; - int record_ID = m_curTab.getRecord_ID(); - if (record_ID == -1) // No Key - return; - // Control Pressed - if ((m_lastModifiers & ActionEvent.CTRL_MASK) != 0) - { - new RecordAccessDialog(AEnv.getFrame(this), m_curTab.getAD_Table_ID(), record_ID); - } - else - { - m_curTab.lock (Env.getCtx(), record_ID, aLock.getButton().isSelected()); - } - aLock.setPressed(m_curTab.isLocked()); - } // lock - - /** - * Toggle History - */ - private void cmd_history() - { - if (log.isLoggable(Level.INFO)) log.info(""); - if (m_mWorkbench.getMWindow(getWindowIndex()).isTransaction()) - { - if (m_curTab.needSave(true, true) && !cmd_save(false)) - return; - - Point pt = new Point (0, aHistory.getButton().getBounds().height); - SwingUtilities.convertPointToScreen(pt, aHistory.getButton()); - VOnlyCurrentDays ocd = new VOnlyCurrentDays(AEnv.getFrame(this), pt); - if (!ocd.isCancel()) { - m_onlyCurrentDays = ocd.getCurrentDays(); - if (m_onlyCurrentDays == 1) // Day - { - m_onlyCurrentRows = true; - m_onlyCurrentDays = 0; // no Created restriction - } - else - m_onlyCurrentRows = false; - // - m_curTab.setQuery(null); // reset previous queries - MRole role = MRole.getDefault(); - int maxRows = role.getMaxQueryRecords(); - // - if (log.isLoggable(Level.CONFIG)) log.config("OnlyCurrent=" + m_onlyCurrentRows - + ", Days=" + m_onlyCurrentDays - + ", MaxRows=" + maxRows); - m_curGC.query(m_onlyCurrentRows, m_onlyCurrentDays, maxRows ); // autoSize - } - // Restore history button's pressed status - else { - if (isFirstTab()) - aHistory.setPressed(!m_curTab.isOnlyCurrentRows()); - } - } - } // cmd_history - - /** - * Help - */ - private void cmd_help() - { - log.info(""); - Help hlp = new Help (AEnv.getFrame(this), this.getTitle(), m_mWorkbench.getMWindow(getWindowIndex())); - hlp.setVisible(true); - } // cmd_help - - /** - * Close this screen - after save - * @param exit ask if user wants to exit application - */ - private void cmd_end (boolean exit) - { - boolean exitSystem = false; - if (!cmd_save(false)) - return; - if (exit && ADialog.ask(m_curWindowNo, this, "ExitApplication?")) - exitSystem = true; - - AEnv.getFrame(this).dispose(); // calls this dispose - - if (exitSystem) - AEnv.exit(0); - } // cmd_end - - /** - * Set Window Size - */ - private void cmd_winSize() - { - Dimension size = getSize(); - if (!ADialog.ask(m_curWindowNo, this, "WinSizeSet", - "x=" + size.width + " - y=" + size.height)) - { - setPreferredSize(null); - SwingUtilities.getWindowAncestor(this).pack(); - size = new Dimension (0,0); - } - // - MWindow win = MWindow.get(m_ctx, m_curTab.getAD_Window_ID()); - win.setWindowSize(size); - win.saveEx(); - } // cmdWinSize - - private void cmd_export() - { - new AExport(this); - } - - private void cmd_postIt() - { - int record_ID = m_curTab.getRecord_ID(); - if (log.isLoggable(Level.INFO)) log.info("Record_ID=" + record_ID); - if (record_ID == -1) // No Key - { - aChat.setEnabled(false); - return; - } - // Find display - String infoName = null; - String infoDisplay = null; - for (int i = 0; i < m_curTab.getFieldCount(); i++) - { - GridField field = m_curTab.getField(i); - if (field.isKey()) - infoName = field.getHeader(); - if ((field.getColumnName().equals("Name") || field.getColumnName().equals("DocumentNo") ) - && field.getValue() != null) - infoDisplay = field.getValue().toString(); - if (infoName != null && infoDisplay != null) - break; - } - String header = infoName + ": " + infoDisplay; - // - - new VPostIt (AEnv.getFrame(this), header, m_curTab.getAD_PostIt_ID(), m_curTab.getAD_Table_ID(), record_ID, null); - aPostIt.setPressed(m_curTab.hasPostIt()); - } // cmd_postIt - - /************************************************************************** - * Start Button Process - * @param vButton button - */ - private void actionButton (VButton vButton){ - if (log.isLoggable(Level.INFO)) log.info(vButton.toString()); - String title = vButton.getDescription(); - if (title == null || title.length() == 0) - title = vButton.getName(); - actionButtonCleanUp(vButton.getColumnName(), vButton.getProcess_ID(), title); - } - - private void actionButtonCleanUp(String columnName, int processID, String title) - { - - if (m_curTab.hasChangedCurrentTabAndParents()) { - String msg = CLogger.retrieveErrorString("Please ReQuery Window"); - ADialog.error(m_curWindowNo, this, null, msg); - return; - } - - boolean startWOasking = false; -// boolean batch = false; - String col = columnName; - - // Zoom - if (col.equals("Record_ID")) - { - int AD_Table_ID = Env.getContextAsInt (m_ctx, m_curWindowNo, "AD_Table_ID"); - int Record_ID = Env.getContextAsInt (m_ctx, m_curWindowNo, "Record_ID"); - AEnv.zoom(AD_Table_ID, Record_ID); - return; - } // Zoom - - // save first --------------- - if (m_curTab.needSave(true, false)) - if (!cmd_save(true)) - return; - // Save included tabs if necessary - teo_sarca BF [ 2876892 ] - for (GridTab includedTab : m_curTab.getIncludedTabs()) - { - if (includedTab.needSave(true, false)) - if(!includedTab.dataSave(true)) - return; - } - // - int table_ID = m_curTab.getAD_Table_ID(); - // Record_ID - int record_ID = m_curTab.getRecord_ID(); - // Record_ID - Language Handling - if (record_ID == -1 && m_curTab.getKeyColumnName().equals("AD_Language")) - record_ID = Env.getContextAsInt (m_ctx, m_curWindowNo, "AD_Language_ID"); - // Record_ID - Change Log ID - if (record_ID == -1 - && (processID == PROCESS_AD_CHANGELOG_UNDO || processID == PROCESS_AD_CHANGELOG_REDO)) - { - Integer id = (Integer)m_curTab.getValue("AD_ChangeLog_ID"); - record_ID = id.intValue(); - } - // Ensure it's saved - if (record_ID == -1 && m_curTab.getKeyColumnName().endsWith("_ID")) - { - ADialog.error(m_curWindowNo, this, "SaveErrorRowNotFound"); - return; - } - - boolean isProcessMandatory = false; - // Pop up Document Action (Workflow) - if (col.equals("DocAction")) - { - isProcessMandatory = true; - VDocAction vda = new VDocAction(m_curWindowNo, m_curTab, null, record_ID); - // Something to select from? - if (vda.getNumberOfOptions() == 0) - { - vda.dispose (); - log.info("DocAction - No Options"); - return; - } - else - { - vda.setVisible(true); - if (!vda.isStartProcess()) - return; -// batch = vda.isBatch(); - startWOasking = true; - vda.dispose(); - } - } // DocAction - - // Pop up Create From - else if (col.equals("CreateFrom")) - { - // Run form only if the button has no process defined - teo_sarca [ 1974354 ] - if (processID <= 0) - { - ICreateFrom cf = VCreateFromFactory.create(m_curTab); - if(cf != null) - { - if(cf.isInitOK()) - { - cf.showWindow(); - cf.closeWindow(); - m_curTab.dataRefresh(); - } - else - cf.closeWindow(); - return; - } - // else may start process - } - } // CreateFrom - - // Posting ----- - else if (col.equals("Posted") && MRole.getDefault().isShowAcct()) - { - // Check Doc Status - String processed = Env.getContext(m_ctx, m_curWindowNo, "Processed"); - if (!processed.equals("Y")) - { - String docStatus = Env.getContext(m_ctx, m_curWindowNo, "DocStatus"); - if (DocAction.STATUS_Completed.equals(docStatus) - || DocAction.STATUS_Closed.equals(docStatus) - || DocAction.STATUS_Reversed.equals(docStatus) - || DocAction.STATUS_Voided.equals(docStatus) - || table_ID == MProjectIssue.Table_ID) // document without status - ; - else - { - ADialog.error(m_curWindowNo, this, "PostDocNotComplete"); - return; - } - } - - // try to get table and record id from context data (eg for unposted view) - // otherwise use current table/record - int tableId = Env.getContextAsInt(m_ctx, m_curWindowNo, "AD_Table_ID", true); - int recordId = Env.getContextAsInt(m_ctx, m_curWindowNo, "Record_ID", true); - if ( tableId == 0 || recordId == 0 ) - { - tableId = m_curTab.getAD_Table_ID(); - recordId = m_curTab.getRecord_ID(); - } - - // Check Post Status - Object ps = m_curTab.getValue("Posted"); - if (ps != null && ps.equals("Y")) - { - new org.compiere.acct.AcctViewer (Env.getContextAsInt (m_ctx, m_curWindowNo, "AD_Client_ID"), - tableId, recordId); - } - else - { - if (ADialog.ask(m_curWindowNo, this, "PostImmediate?")) - { - boolean force = ps != null && !ps.equals ("N"); // force when problems - String error = AEnv.postImmediate (m_curWindowNo, Env.getAD_Client_ID(m_ctx), - tableId, recordId, force); - if (error != null) - ADialog.error(m_curWindowNo, this, "PostingError-N", error); - cmd_refresh(); - } - } - return; - } // Posted - - /** - * Start Process ---- - * or invoke user form - */ - - if (log.isLoggable(Level.CONFIG)) log.config("Process_ID=" + processID + ", Record_ID=" + record_ID); - if (processID == 0) - { - if (isProcessMandatory) - { - ADialog.error(m_curWindowNo, this, null, Msg.parseTranslation(m_ctx, "@NotFound@ @AD_Process_ID@")); - } - return; - } - // Save item changed - if (m_curTab.needSave(true, false)) - if (!cmd_save(true)) - return; - - // call form - MProcess pr = new MProcess(m_ctx, processID, null); - int form_ID = pr.getAD_Form_ID(); - if (form_ID != 0 ) - { - - if (m_curTab.needSave(true, false)) - if (!cmd_save(true)) - return; - - FormFrame ff = new FormFrame(getGraphicsConfiguration()); - ProcessInfo pi = new ProcessInfo (title, processID, table_ID, record_ID); - pi.setAD_User_ID (Env.getAD_User_ID(m_ctx)); - pi.setAD_Client_ID (Env.getAD_Client_ID(m_ctx)); - pi.setAD_Process_UU(pr.getAD_Process_UU()); - ff.setProcessInfo(pi); - ff.openForm(form_ID, m_curTab); - ff.pack(); - AEnv.showCenterScreen(ff); - return; - } - else { - ProcessModalDialog dialog = new ProcessModalDialog(m_ctx, AEnv.getWindow(m_curWindowNo), Env.getHeader(m_ctx, m_curWindowNo), - this, m_curWindowNo, processID, table_ID, - record_ID, startWOasking); - if (dialog.isValidDialog()) - { - dialog.validate(); - dialog.pack(); - AEnv.showCenterWindow(AEnv.getWindow(m_curWindowNo), dialog); - } - } - } // actionButton - - - /************************************************************************** - * Lock User Interface. - * Called from the Worker before processing - * @param pi process info - */ - public void lockUI (ProcessInfo pi) - { - // log.fine("" + pi); - setBusy(true, false); - } // lockUI - - /** - * Unlock User Interface. - * Called from the Worker when processing is done - * @param pi of execute ASync call - */ - public void unlockUI (ProcessInfo pi) - { - // log.fine("" + pi); - boolean notPrint = pi != null - && pi.getAD_Process_ID() != m_curTab.getAD_Process_ID() - && pi.isReportingProcess() == false; - // - setBusy(false, notPrint); - // Process Result - if (notPrint) // refresh if not print - { - // Refresh data - m_curTab.dataRefresh(); - // Timeout - if (pi.isTimeout()) // set temporarily to R/O - Env.setContext(m_ctx, m_curWindowNo, "Processed", "Y"); - m_curGC.dynamicDisplay(0); - // Update Status Line - setStatusLine(pi.getSummary(), pi.isError()); - if ( pi.isError() ) - ADialog.error(m_curWindowNo, this, null, pi.getSummary()); - // Get Log Info - ProcessInfoUtil.setLogFromDB(pi); - String logInfo = pi.getLogInfo(); - if (logInfo.length() > 0) - ADialog.info(m_curWindowNo, this, Env.getHeader(m_ctx, m_curWindowNo), - pi.getTitle(), logInfo); // clear text - } - else - { - // Update Status Line - setStatusLine(pi.getSummary(), pi.isError()); - if ( pi.isError() ) - ADialog.error(m_curWindowNo, this, null, pi.getSummary()); - } - } // unlockUI - - /** - * Is the UI locked (Internal method) - * @return true, if UI is locked - */ - public boolean isUILocked() - { - return m_isLocked; - } // isLoacked - - /** - * Method to be executed async. - * Called from the ASyncProcess worker - * @param pi process info - */ - public void executeASync (ProcessInfo pi) - { - log.config("-"); - } // executeASync - - /** - * Get Current Tab - * @return current tab - */ - public GridTab getCurrentTab() - { - return m_curTab; - } // getCurrentTab - - /** - * Get the number of tabs in the panels JTabbedPane. - * @return no of tabs in the JTabbedPane of the panel - */ - public int noOfTabs() { - return m_curWinTab.getTabCount(); - } - - /** - * Get the selected tab index of the panels JTabbedPane. - * @return selected index of JTabbedPane - */ - public int getSelectedTabIndex() { - return m_curWinTab.getSelectedIndex(); - } - - /** - * Set the tab index of the panels JTabbedPane. - */ - public void setSelectedTabIndex(int index) { - m_curWinTab.setSelectedIndex(index); - } - - /** - * Get the name of the selected tab in the panels JTabbedPane. - * @return name of selected tab - */ - public String getSelectedTabName() { - String title = m_curWinTab.getTitleAt(m_curWinTab.getSelectedIndex()); - title = title.substring(title.indexOf("")+6); - title = title.substring(0,title.indexOf('<')); - return title; - } - - /** - * String representation - * @return String representation - */ - public String toString() - { - String s = "APanel[curWindowNo=" + m_curWindowNo; - if (m_mWorkbench != null) - s += ",WB=" + m_mWorkbench.toString(); - s += "]"; - return s; - } // toString - - /** - * Simple action class for the resort of tablelines (switch line no). Delegates actionPerformed - * to APanel. - * - * @author Karsten Thiemann, kthiemann@adempiere.org - * - */ - class SwitchAction extends AbstractAction { - /** - * - */ - private static final long serialVersionUID = 3837712049468116744L; - - /** the action listener - APanel */ - private ActionListener al; - - /** action name */ - private String name; - - /** - * Constructor. - * @param name - * @param accelerator - * @param al - */ - SwitchAction(String name, KeyStroke accelerator, ActionListener al) { - super(name); - putValue(Action.NAME, name); // Display - putValue(Action.SHORT_DESCRIPTION, name); // Tooltip - putValue(Action.ACCELERATOR_KEY, accelerator); // KeyStroke - putValue(Action.ACTION_COMMAND_KEY, name); // ActionCammand - this.al = al; - this.name = name; - } - - public void actionPerformed(ActionEvent e) { - al.actionPerformed(e); - } // actionPerformed - - public String getName() { - return name; - } - } - - /** - * Removes the default KeyStroke action for the up/down keys and adds switch - * line actions. - */ - private void initSwitchLineAction() { - aSwitchLinesDownAction = new SwitchAction("switchLinesDown", KeyStroke.getKeyStroke( - KeyEvent.VK_DOWN, ActionEvent.SHIFT_MASK), this); - aSwitchLinesUpAction = new SwitchAction("switchLinesUp", KeyStroke.getKeyStroke( - KeyEvent.VK_UP, ActionEvent.SHIFT_MASK), this); - - JTable table = m_curGC.getTable(); - table.getInputMap(CPanel.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put( - KeyStroke.getKeyStroke(KeyEvent.VK_DOWN, ActionEvent.SHIFT_MASK), "none"); - table.getInputMap(CPanel.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put( - KeyStroke.getKeyStroke(KeyEvent.VK_UP, ActionEvent.SHIFT_MASK), "none"); - table.getInputMap(CPanel.WHEN_FOCUSED).put( - KeyStroke.getKeyStroke(KeyEvent.VK_DOWN, ActionEvent.SHIFT_MASK), "none"); - table.getInputMap(CPanel.WHEN_FOCUSED).put( - KeyStroke.getKeyStroke(KeyEvent.VK_UP, ActionEvent.SHIFT_MASK), "none"); - - getInputMap(CPanel.WHEN_IN_FOCUSED_WINDOW).put( - KeyStroke.getKeyStroke(KeyEvent.VK_DOWN, ActionEvent.SHIFT_MASK), - aSwitchLinesDownAction.getName()); - getActionMap().put(aSwitchLinesDownAction.getName(), aSwitchLinesDownAction); - getInputMap(CPanel.WHEN_IN_FOCUSED_WINDOW).put( - KeyStroke.getKeyStroke(KeyEvent.VK_UP, ActionEvent.SHIFT_MASK), - aSwitchLinesUpAction.getName()); - getActionMap().put(aSwitchLinesUpAction.getName(), aSwitchLinesUpAction); - } - - /** - * @return boolean - */ - public boolean isNested() { - return isNested; - } - - /** - * @return JTabbedPane - */ - public JTabbedPane getCurrentTabbedPane() { - return m_curWinTab; - } - - @Override - public void statusUpdate(String message) { - JFrame frame = AEnv.getFrame(this); - if (frame == null) // during init - return; - if (frame instanceof AWindow) - ((AWindow)frame).setBusyMessage(message); - } - - private void updateToolBarAndMenuWithRestriction() - { - int ToolBarButton_ID = 0; - - int[] restrictionList = MToolBarButtonRestrict.getOfWindow(m_ctx, MRole.getDefault().getAD_Role_ID(), m_window.getAD_Window_ID(), false, null); - if (log.isLoggable(Level.INFO)) log.info("restrictionList="+restrictionList.toString()); - - for (int i = 0; i < restrictionList.length; i++) - { - ToolBarButton_ID= restrictionList[i]; - - X_AD_ToolBarButton tbt = new X_AD_ToolBarButton(m_ctx, ToolBarButton_ID, null); - String restrictName = tbt.getComponentName(); - if (log.isLoggable(Level.CONFIG)) log.config("tbt="+tbt.getAD_ToolBarButton_ID() + " / " + restrictName); - boolean found=false; - - // remove from ToolBar - for (int t = 0; t < toolBar.getComponentCount() && !found; t++) - { - if (toolBar.getComponent(t).getName()==null) // separator - continue; - - if (toolBar.getComponent(t).getName().equals(restrictName)) - { - toolBar.remove(t); - found=true; - } - } - - // Remove from Menu - found=false; - for (int m1 = 0; m1 < menuBar.getComponentCount() && !found; m1++) - { - JMenu menu = menuBar.getMenu(m1); // File, Edit, View... - - for (int m2 = 0; m2 < menu.getItemCount() && !found; m2++) // New, Copy, Save... - { - if (menu.getItem(m2)==null) // separator - continue; - - if (menu.getItem(m2).getActionCommand().equals(restrictName)) - { - menu.remove(m2); - found=true; - } - } // menuItems - } // Menu (File, Edit, View, ...) - } // All restrictions - - } // updateToolBarAndMenuWithRestriction - - @Override - public void ask(String message, Callback callback) { - boolean b = ADialog.ask(m_curWindowNo, this, message); - if (callback != null) { - callback.onCallback(b); - } - } - - @Override - public void download(File file) { - } - - @Override - public void askForInput(String message, Callback callback) { - String s = ADialog.askForInput(m_curWindowNo, this, message); - if(callback != null) - callback.onCallback(s); - } - -} // APanel diff --git a/org.adempiere.ui.swing/src/org/compiere/apps/ARequest.java b/org.adempiere.ui.swing/src/org/compiere/apps/ARequest.java deleted file mode 100644 index 65a1c01faf..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/apps/ARequest.java +++ /dev/null @@ -1,271 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ -package org.compiere.apps; - -import java.awt.GraphicsConfiguration; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.sql.PreparedStatement; -import java.sql.ResultSet; -import java.util.logging.Level; - -import javax.swing.JComponent; -import javax.swing.JPopupMenu; - -import org.compiere.model.GridTab; -import org.compiere.model.MAsset; -import org.compiere.model.MBPartner; -import org.compiere.model.MCampaign; -import org.compiere.model.MInOut; -import org.compiere.model.MInvoice; -import org.compiere.model.MOrder; -import org.compiere.model.MOrderLine; -import org.compiere.model.MPayment; -import org.compiere.model.MProduct; -import org.compiere.model.MProject; -import org.compiere.model.MQuery; -import org.compiere.model.MRMA; -import org.compiere.model.MRequest; -import org.compiere.model.MUser; -import static org.compiere.model.SystemIDs.*; -import org.compiere.swing.CMenuItem; -import org.compiere.util.CLogger; -import org.compiere.util.DB; -import org.compiere.util.Env; -import org.compiere.util.Msg; - - -/** - * Request Button Action. - * Popup Menu - * - * @author Jorg Janke - * @version $Id: ARequest.java,v 1.2 2006/07/30 00:51:27 jjanke Exp $ - * - * @author Teo Sarca, SC ARHIPAC SERVICE SRL - *
  • BF [ 1904928 ] Request: Related Request field not filled - */ -public class ARequest implements ActionListener -{ - /** - * Constructor - * @param invoker invoker button - * @param AD_Table_ID table - * @param Record_ID record - * @param C_BPartner_ID optional bp - */ - public ARequest (JComponent invoker, int AD_Table_ID, int Record_ID, - int C_BPartner_ID) - { - super (); - if (log.isLoggable(Level.CONFIG)) log.config("AD_Table_ID=" + AD_Table_ID + ", Record_ID=" + Record_ID); - m_AD_Table_ID = AD_Table_ID; - m_Record_ID = Record_ID; - m_C_BPartner_ID = C_BPartner_ID; - getRequests(invoker); - } // ARequest - - /** The Table */ - private int m_AD_Table_ID; - /** The Record */ - private int m_Record_ID; - /** BPartner */ - private int m_C_BPartner_ID; - - /** The Popup */ - private JPopupMenu m_popup = new JPopupMenu("RequestMenu"); - private CMenuItem m_new = null; - private CMenuItem m_active = null; - private CMenuItem m_all = null; - private GraphicsConfiguration m_graphicsconfig = null; - /** Where Clause */ - StringBuffer m_where = null; - - - /** Logger */ - private static CLogger log = CLogger.getCLogger (ARequest.class); - - /** - * Display Request Options - New/Existing. - * @param invoker button - */ - private void getRequests (JComponent invoker) - { - m_new = new CMenuItem(Msg.getMsg(Env.getCtx(), "RequestNew")); - m_new.setIcon(Env.getImageIcon("New16.gif")); - m_popup.add(m_new).addActionListener(this); - m_graphicsconfig = invoker.getGraphicsConfiguration(); - // - int activeCount = 0; - int inactiveCount = 0; - m_where = new StringBuffer(); - m_where.append("(AD_Table_ID=").append(m_AD_Table_ID) - .append(" AND Record_ID=").append(m_Record_ID) - .append(")"); - // - if (m_AD_Table_ID == MUser.Table_ID) - m_where.append(" OR AD_User_ID=").append(m_Record_ID) - .append(" OR SalesRep_ID=").append(m_Record_ID); - else if (m_AD_Table_ID == MBPartner.Table_ID) - m_where.append(" OR C_BPartner_ID=").append(m_Record_ID); - else if (m_AD_Table_ID == MOrder.Table_ID) - m_where.append(" OR C_Order_ID=").append(m_Record_ID); - else if (m_AD_Table_ID == MInvoice.Table_ID) - m_where.append(" OR C_Invoice_ID=").append(m_Record_ID); - else if (m_AD_Table_ID == MPayment.Table_ID) - m_where.append(" OR C_Payment_ID=").append(m_Record_ID); - else if (m_AD_Table_ID == MProduct.Table_ID) - m_where.append(" OR M_Product_ID=").append(m_Record_ID); - else if (m_AD_Table_ID == MProject.Table_ID) - m_where.append(" OR C_Project_ID=").append(m_Record_ID); - else if (m_AD_Table_ID == MCampaign.Table_ID) - m_where.append(" OR C_Campaign_ID=").append(m_Record_ID); - else if (m_AD_Table_ID == MAsset.Table_ID) - m_where.append(" OR A_Asset_ID=").append(m_Record_ID); - // - String sql = "SELECT Processed, COUNT(*) " - + "FROM R_Request WHERE " + m_where - + " GROUP BY Processed " - + "ORDER BY Processed DESC"; - PreparedStatement pstmt = null; - ResultSet rs = null; - try - { - pstmt = DB.prepareStatement (sql, null); - rs = pstmt.executeQuery (); - while (rs.next ()) - { - if ("Y".equals(rs.getString(1))) - inactiveCount = rs.getInt(2); - else - activeCount += rs.getInt(2); - } - } - catch (Exception e) - { - log.log(Level.SEVERE, sql, e); - } - finally - { - DB.close(rs, pstmt); - rs = null; - pstmt = null; - } - // - if (activeCount > 0) - { - m_active = new CMenuItem(Msg.getMsg(Env.getCtx(), "RequestActive") - + " (" + activeCount + ")"); - m_popup.add(m_active).addActionListener(this); - } - if (inactiveCount > 0) - { - m_all = new CMenuItem(Msg.getMsg(Env.getCtx(), "RequestAll") - + " (" + (activeCount + inactiveCount) + ")"); - m_popup.add(m_all).addActionListener(this); - } - // - if (invoker.isShowing()) - m_popup.show(invoker, 0, invoker.getHeight()); // below button - } // getZoomTargets - - /** - * Listner - * @param e event - */ - public void actionPerformed (ActionEvent e) - { - MQuery query = null; - if (e.getSource() == m_active) - { - query = new MQuery(""); - String where = "(" + m_where + ") AND Processed='N'"; - query.addRestriction(where); - query.setRecordCount(0); - } - else if (e.getSource() == m_all) - { - query = new MQuery(""); - query.addRestriction(m_where.toString()); - query.setRecordCount(0); - } - else if (e.getSource() == m_new) - { - query = new MQuery(""); - query.addRestriction("1=2"); - query.setRecordCount(0); - } - // - int AD_Window_ID = WINDOW_REQUESTS_ALL; // 232=all - 201=my - AWindow frame = new AWindow(m_graphicsconfig); - if (!frame.initWindow(AD_Window_ID, query)) - return; - AEnv.addToWindowManager(frame); - // New - set Table/Record - if (e.getSource() == m_new) - { - GridTab tab = frame.getAPanel().getCurrentTab(); - tab.dataNew (false); - tab.setValue("AD_Table_ID", Integer.valueOf(m_AD_Table_ID)); - tab.setValue("Record_ID", Integer.valueOf(m_Record_ID)); - // - if (m_C_BPartner_ID != 0) - tab.setValue("C_BPartner_ID", Integer.valueOf(m_C_BPartner_ID)); - // - if (m_AD_Table_ID == MBPartner.Table_ID) - tab.setValue("C_BPartner_ID", Integer.valueOf(m_Record_ID)); - else if (m_AD_Table_ID == MUser.Table_ID) - tab.setValue("AD_User_ID", Integer.valueOf(m_Record_ID)); - // - else if (m_AD_Table_ID == MProject.Table_ID) - tab.setValue("C_Project_ID", Integer.valueOf(m_Record_ID)); - else if (m_AD_Table_ID == MAsset.Table_ID) - tab.setValue("A_Asset_ID", Integer.valueOf(m_Record_ID)); - // - else if (m_AD_Table_ID == MOrder.Table_ID) - tab.setValue("C_Order_ID", Integer.valueOf(m_Record_ID)); - else if (m_AD_Table_ID == MInvoice.Table_ID) - tab.setValue("C_Invoice_ID", Integer.valueOf(m_Record_ID)); - // - else if (m_AD_Table_ID == MProduct.Table_ID) - tab.setValue("M_Product_ID", Integer.valueOf(m_Record_ID)); - else if (m_AD_Table_ID == MPayment.Table_ID) - tab.setValue("C_Payment_ID", Integer.valueOf(m_Record_ID)); - // - else if (m_AD_Table_ID == MInOut.Table_ID) - tab.setValue("M_InOut_ID", Integer.valueOf(m_Record_ID)); - else if (m_AD_Table_ID == MRMA.Table_ID) - tab.setValue("M_RMA_ID", Integer.valueOf(m_Record_ID)); - // - else if (m_AD_Table_ID == MCampaign.Table_ID) - tab.setValue("C_Campaign_ID", Integer.valueOf(m_Record_ID)); - // - else if (m_AD_Table_ID == MRequest.Table_ID) - tab.setValue(MRequest.COLUMNNAME_R_RequestRelated_ID, Integer.valueOf(m_Record_ID)); - // FR [2842165] - Order Ref link from SO line creating new request - else if (m_AD_Table_ID == MOrderLine.Table_ID) { - MOrderLine oLine = new MOrderLine(Env.getCtx(), m_Record_ID, null); - if (oLine != null) { - tab.setValue(MOrderLine.COLUMNNAME_C_Order_ID, Integer.valueOf(oLine.getC_Order_ID())); - } - } - } - AEnv.showCenterScreen(frame); - frame = null; - } // actionPerformed - -} // ARequest diff --git a/org.adempiere.ui.swing/src/org/compiere/apps/ATask.java b/org.adempiere.ui.swing/src/org/compiere/apps/ATask.java deleted file mode 100644 index d63566287f..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/apps/ATask.java +++ /dev/null @@ -1,132 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ -package org.compiere.apps; - -import java.awt.BorderLayout; -import java.awt.Dimension; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.util.logging.Level; - -import javax.swing.JScrollPane; -import javax.swing.JTextArea; - -import org.adempiere.plaf.AdempierePLAF; -import org.compiere.Adempiere; -import org.compiere.model.MTask; -import org.compiere.swing.CFrame; -import org.compiere.util.CLogger; -import org.compiere.util.Task; - - -/** - * Application Task - * - * @author Jorg Janke - * @version $Id: ATask.java,v 1.2 2006/07/30 00:51:27 jjanke Exp $ - */ -public class ATask extends CFrame - implements ActionListener -{ - /** - * - */ - private static final long serialVersionUID = -8998998120736876682L; - - /** - * Start Application Task - * @param task task model - */ - static public void start (final String title, final MTask task) - { - new Thread() - { - public void run() - { - new ATask(title, task); - } - }.start(); - } // start - - - /************************************************************************** - * Full Constructor - * @param title title - * @param task task - */ - public ATask (String title, MTask task) - { - super (title); - this.setIconImage(Adempiere.getImage16()); - try - { - jbInit(); - AEnv.showCenterScreen(this); - // - if (task.isServerProcess()) - info.setText("Executing on Server ..."); - else - info.setText("Executing locally ..."); - String result = task.execute(); - info.setText(result); - confirmPanel.getCancelButton().setEnabled(false); - confirmPanel.getOKButton().setEnabled(true); - } - catch(Exception e) - { - log.log(Level.SEVERE, task.toString(), e); - } - } // ATask - - private Task m_task = null; - /** Logger */ - private static CLogger log = CLogger.getCLogger(ATask.class); - - private ConfirmPanel confirmPanel = new ConfirmPanel(true); - private JScrollPane infoScrollPane = new JScrollPane(); - private JTextArea info = new JTextArea(); - - /** - * Static Layout - * @throws Exception - */ - private void jbInit() throws Exception - { - info.setEditable(false); - info.setBackground(AdempierePLAF.getFieldBackground_Inactive()); - infoScrollPane.getViewport().add(info, null); - infoScrollPane.setPreferredSize(new Dimension(500,300)); - this.getContentPane().add(infoScrollPane, BorderLayout.CENTER); - this.getContentPane().add(confirmPanel, BorderLayout.SOUTH); - // - confirmPanel.addActionListener(this); - confirmPanel.getOKButton().setEnabled(false); - } // jbInit - - - /** - * Action Listener - * @param e - */ - public void actionPerformed (ActionEvent e) - { - if (m_task != null && m_task.isAlive()) - m_task.interrupt(); - dispose(); - } // actionPerformed - -} // ATask diff --git a/org.adempiere.ui.swing/src/org/compiere/apps/AWindow.java b/org.adempiere.ui.swing/src/org/compiere/apps/AWindow.java deleted file mode 100644 index aa5a68b86d..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/apps/AWindow.java +++ /dev/null @@ -1,215 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ -package org.compiere.apps; - -import java.awt.BorderLayout; -import java.awt.GraphicsConfiguration; -import java.awt.Image; -import java.awt.event.WindowEvent; -import java.util.logging.Level; - -import org.compiere.model.MQuery; -import org.compiere.swing.CFrame; -import org.compiere.util.CLogger; -import org.compiere.util.Env; - -/** - * Main Application Window. - * - Constructs, initializes and positions JFrame - * - Gets content, menu, title from APanel - * - * @author Jorg Janke - * @version $Id: AWindow.java,v 1.2 2006/07/30 00:51:27 jjanke Exp $ - * - * @author Teo Sarca, www.arhipac.ro - *
  • BF [ 1836908 ] Report customize NPE when no window access - */ -public class AWindow extends CFrame -{ - /** - * - */ - private static final long serialVersionUID = -1925388774073536474L; - - /** - * @deprecated - * Standard Constructor - requires initWindow - */ - public AWindow () - { - this(null); - } // AWindow - - /** - * Standard Constructor - requires initWindow - * @param gc - */ - public AWindow (GraphicsConfiguration gc) - { - super(gc); - // Set UI Components - this.setIconImage(Env.getImage("mWindow.png")); - this.getContentPane().add(m_APanel, BorderLayout.CENTER); - this.setGlassPane(m_glassPane); - } // AWindow - - /** The GlassPane */ - private AGlassPane m_glassPane = new AGlassPane(); - /** Application Window */ - private APanel m_APanel = new APanel(this); - - /** Logger */ - private static CLogger log = CLogger.getCLogger(AWindow.class); - - /** - * Dynamic Initialization Workbench - * @param AD_Workbench_ID workbench - * @return true if loaded OK - */ - protected boolean initWorkbench (int AD_Workbench_ID) - { - this.setName("AWindow_WB_" + AD_Workbench_ID); - boolean loadedOK = m_APanel.initPanel (AD_Workbench_ID, 0, null); - // - commonInit(); - return loadedOK; - } // initWorkbench - - /** - * Dynamic Initialization Single Window - * @param AD_Window_ID window - * @param query query - * @return true if loaded OK - */ - public boolean initWindow (int AD_Window_ID, MQuery query) - { - this.setName("AWindow_" + AD_Window_ID); - setAD_Window_ID(AD_Window_ID); - // - boolean loadedOK = m_APanel.initPanel (0, AD_Window_ID, query); - if (loadedOK) - { - commonInit(); - } - return loadedOK; - } // initWindow - - /** - * Common Init. - * After APanel loaded - */ - private void commonInit() - { - this.setJMenuBar(m_APanel.getMenuBar()); - this.setTitle(m_APanel.getTitle()); - // - Image image = m_APanel.getImage(); - if (image != null) - setIconImage(image); - } // commonInit - - - /************************************************************************* - * Set Window Busy - * @param busy busy - */ - public void setBusy (boolean busy) - { - if (busy == m_glassPane.isVisible()) - return; - if (log.isLoggable(Level.CONFIG)) log.config(getName() + " - " + busy); - m_glassPane.setMessage(null); - m_glassPane.setVisible(busy); - if (busy) - m_glassPane.requestFocus(); - } // setBusy - - /** - * Set Busy Message - * @param AD_Message message - */ - public void setBusyMessage (String AD_Message) - { - m_glassPane.setMessage(AD_Message); - } // setBusyMessage - - /** - * Set and start Busy Counter - * @param time in seconds - */ - public void setBusyTimer (int time) - { - m_glassPane.setBusyTimer (time); - } // setBusyTimer - - /** - * Window Events - * @param e event - */ - protected void processWindowEvent(WindowEvent e) - { - super.processWindowEvent(e); -// System.out.println(">> Apps WE_" + e.getID() // + " Frames=" + getFrames().length -// + " " + e); - } // processWindowEvent - - /** - * Get Application Panel - * @return application panel - */ - public APanel getAPanel() - { - return m_APanel; - } // getAPanel - - /** - * Dispose - */ - public void dispose() - { - if (AEnv.hideWindow(this)) - return; - if (log.isLoggable(Level.INFO)) log.info(toString()); - if (m_APanel != null) - m_APanel.dispose(); - m_APanel = null; - this.removeAll(); - super.dispose(); - // System.gc(); - } // dispose - - /** - * Get Window No of Panel - * @return window no - */ - public int getWindowNo() - { - if (m_APanel != null) - return m_APanel.getWindowNo(); - return 0; - } // getWindowNo - - /** - * String Representation - * @return Name - */ - public String toString() - { - return getName() + "_" + getWindowNo(); - } // toString - -} // AWindow \ No newline at end of file diff --git a/org.adempiere.ui.swing/src/org/compiere/apps/AWindowListener.java b/org.adempiere.ui.swing/src/org/compiere/apps/AWindowListener.java deleted file mode 100644 index a993779225..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/apps/AWindowListener.java +++ /dev/null @@ -1,69 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ -package org.compiere.apps; - -import java.awt.Window; -import java.awt.event.WindowAdapter; -import java.awt.event.WindowEvent; -import java.awt.event.WindowStateListener; - -/** - * Convenience Class to tunnel Events. - * - * Forwards Window Events like windowClosed to the WindowState listener. - * Usually, a WindowStateListener gets only state events (minimized,..) - * This allows implementing a single method (windowStateChanged) - * to receive potentially all window events. - *

    - * Implemented: - * e.getID() == WindowEvent.WINDOW_CLOSED - * - * @author Jorg Janke - * @version $Id: AWindowListener.java,v 1.2 2006/07/30 00:51:27 jjanke Exp $ - */ -public class AWindowListener extends WindowAdapter -{ - /** - * Constructor - * - * @param win Window - * @param l Listener - */ - public AWindowListener (Window win, WindowStateListener l) - { - m_window = win; - m_listener = l; - win.addWindowListener(this); - } // AWindowListener - - /** The Window */ - @SuppressWarnings("unused") - private Window m_window; - /** The Listener */ - private WindowStateListener m_listener; - - /** - * Invoked when a window has been closed. - * Forwarded. - * @param e event to be forwarded - */ - public void windowClosed(WindowEvent e) - { - m_listener.windowStateChanged(e); - } // windowClosed - -} // AWindowListenr diff --git a/org.adempiere.ui.swing/src/org/compiere/apps/AZoomAcross.java b/org.adempiere.ui.swing/src/org/compiere/apps/AZoomAcross.java deleted file mode 100644 index 5300f6d493..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/apps/AZoomAcross.java +++ /dev/null @@ -1,137 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ -package org.compiere.apps; - -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.util.ArrayList; -import java.util.List; -import java.util.logging.Level; - -import javax.swing.JComponent; -import javax.swing.JPopupMenu; - -import org.adempiere.model.ZoomInfoFactory; -import org.compiere.model.MQuery; -import org.compiere.model.PO; -import org.compiere.model.Query; -import org.compiere.util.CLogger; -import org.compiere.util.Env; -import org.compiere.util.Ini; -import org.compiere.util.Msg; - -/** - * Application Zoom Across Launcher. - * Called from APanel; Queries available Zoom Targets for Table. - * - * @author Jorg Janke - * @version $Id: AZoomAcross.java,v 1.2 2006/07/30 00:51:27 jjanke Exp $ - * - * @author Teo Sarca, SC ARHIPAC SERVICE SRL - FR [ 1762465 ] - * @author afalcone - Bug Fix [ 1659420 ] Usability: zoom across - * @author Tobias Schoeneberg, www.metas.de - FR [ 2897194 ] Advanced Zoom and RelationTypes - */ -public class AZoomAcross -{ - /** - * Constructor - * @param invoker component to display popup (optional) - * @param tableName zoom source table (i.e. the table we start from) - * @param query query that specifies the zoom source PO (i.e. the PO we start from) - */ - public AZoomAcross (JComponent invoker, String tableName, final int windowID, MQuery query) - { - this(invoker, new Query(Env.getCtx(), tableName, - query.getWhereClause(), null).first(), windowID); - } - - public AZoomAcross(JComponent invoker, PO po, final int windowID) { - - if (logger.isLoggable(Level.CONFIG)) logger.config("PO=" + po+", WindowID="+windowID); - - mkZoomTargets(po, windowID); - - for (final ZoomInfoFactory.ZoomInfo zoomInfo : zoomInfos) { - - final String label = zoomInfo.destinationDisplay + " (#" - + zoomInfo.query.getRecordCount() + ")"; - - m_popup.add(label).addActionListener(new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - launchZoom(zoomInfo); - } - }); - } - - if (zoomInfos.isEmpty()) { - m_popup.add(Msg.getMsg(Env.getCtx(), "NoZoomTarget")); // Added - } - if (invoker.isShowing()) { - m_popup.show(invoker, 0, invoker.getHeight()); - } - } - - private final JPopupMenu m_popup = new JPopupMenu("ZoomMenu"); - - private static final CLogger logger = CLogger.getCLogger(AZoomAcross.class); - - private final List zoomInfos = new ArrayList(); - - private void mkZoomTargets(final PO po, final int windowID) { - - for (final ZoomInfoFactory.ZoomInfo zoomInfo : ZoomInfoFactory.retrieveZoomInfos(po, - windowID)) { - - if (zoomInfo.query.getRecordCount() == 0) { - if (logger.isLoggable(Level.FINE)) logger.fine("No target records for destination " - + zoomInfo.destinationDisplay); - continue; - } - zoomInfos.add(zoomInfo); - } - } - - - /** - * Launch Zoom - * @param pp KeyPair - */ - private void launchZoom (final ZoomInfoFactory.ZoomInfo zoomInfo) - { - final int AD_Window_ID = zoomInfo.windowId; - final MQuery query = zoomInfo.query; - - if (logger.isLoggable(Level.INFO)) logger.info("AD_Window_ID=" + AD_Window_ID - + " - " + query); - - AWindow frame = new AWindow(null); - if (!frame.initWindow(AD_Window_ID, query)) - return; - AEnv.addToWindowManager(frame); - if (Ini.isPropertyBool(Ini.P_OPEN_WINDOW_MAXIMIZED) ) - { - AEnv.showMaximized(frame); - } - else - { - AEnv.showCenterScreen(frame); - } - frame = null; - } // launchZoom - -} // AZoom diff --git a/org.adempiere.ui.swing/src/org/compiere/apps/AboutBox.java b/org.adempiere.ui.swing/src/org/compiere/apps/AboutBox.java deleted file mode 100644 index 46ae0a4a1f..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/apps/AboutBox.java +++ /dev/null @@ -1,165 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ -package org.compiere.apps; - -import java.awt.BorderLayout; -import java.awt.Color; -import java.awt.Dimension; -import java.awt.GridLayout; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; - -import javax.swing.JFrame; -import javax.swing.JLabel; -import javax.swing.SwingConstants; - -import org.compiere.Adempiere; -import org.compiere.swing.CDialog; -import org.compiere.swing.CPanel; -import org.compiere.swing.CTextArea; -import org.compiere.util.CLogMgt; -import org.compiere.util.Env; -import org.compiere.util.Msg; - -/** - * About Dialog - * - * @author Jorg Janke - * @version $Id: AboutBox.java,v 1.2 2006/07/30 00:51:27 jjanke Exp $ - */ -public final class AboutBox extends CDialog implements ActionListener -{ - /** - * - */ - private static final long serialVersionUID = -5126987147443121045L; - - /** - * Constructor for modal about dialog - * @param parent parent - */ - public AboutBox(JFrame parent) - { - super (parent, true); - try - { - jbInit(); - } - catch(Exception e) - { - System.out.println(e.getMessage()); - } - // - labelVersion.setText(Adempiere.getVersion()); - labelCopyright.setText(Adempiere.COPYRIGHT); - infoArea.setText(CLogMgt.getInfo(null).toString()); - // create 5 pt border - Dimension d = imageControl.getPreferredSize(); - imageControl.setPreferredSize(new Dimension(d.width+10, d.height+10)); - // - AEnv.positionCenterWindow(parent, this); - } // AWindow_AboutBox - - private CPanel panel = new CPanel(); - private CPanel mainPanel = new CPanel(); - private JLabel imageControl = new JLabel(); - private JLabel labelHeading = new JLabel(); - private JLabel labelVersion = new JLabel(); - private JLabel labelCopyright = new JLabel(); - private JLabel labelDescription = new JLabel(); - private BorderLayout panelLayout = new BorderLayout(); - private BorderLayout mainLayout = new BorderLayout(); - private CPanel northPanel = new CPanel(); - private CPanel headerPanel = new CPanel(); - private GridLayout headerLayout = new GridLayout(); - private CTextArea infoArea = new CTextArea(); - private BorderLayout northLayout = new BorderLayout(); - private ConfirmPanel confirmPanel = new ConfirmPanel(false); - - /** - * Init - * @throws Exception - */ - private void jbInit() throws Exception - { - this.setTitle(Msg.translate(Env.getCtx(), "About")); - // - setResizable(false); - labelHeading.setFont(new java.awt.Font("Dialog", 1, 14)); - labelHeading.setHorizontalAlignment(SwingConstants.CENTER); - labelHeading.setHorizontalTextPosition(SwingConstants.CENTER); - labelHeading.setText(" Smart ERP & CRM Business Solution "); - labelVersion.setHorizontalAlignment(SwingConstants.CENTER); - labelVersion.setHorizontalTextPosition(SwingConstants.CENTER); - labelVersion.setText("."); - labelCopyright.setHorizontalAlignment(SwingConstants.CENTER); - labelCopyright.setHorizontalTextPosition(SwingConstants.CENTER); - labelCopyright.setText("."); - labelDescription.setForeground(Color.blue); - labelDescription.setHorizontalAlignment(SwingConstants.CENTER); - labelDescription.setHorizontalTextPosition(SwingConstants.CENTER); - labelDescription.setText(Adempiere.getURL()); - // - imageControl.setFont(new java.awt.Font("Serif", 2, 10)); - imageControl.setForeground(Color.blue); - imageControl.setAlignmentX((float) 0.5); - imageControl.setHorizontalAlignment(SwingConstants.CENTER); - imageControl.setHorizontalTextPosition(SwingConstants.CENTER); - imageControl.setIcon(Adempiere.getImageIconLogo()); - imageControl.setText(Adempiere.getSubtitle()); - imageControl.setVerticalTextPosition(SwingConstants.BOTTOM); - // - mainPanel.setLayout(mainLayout); - mainLayout.setHgap(10); - mainLayout.setVgap(10); - northPanel.setLayout(northLayout); - northLayout.setHgap(10); - northLayout.setVgap(10); - panel.setLayout(panelLayout); - panelLayout.setHgap(10); - panelLayout.setVgap(10); - headerPanel.setLayout(headerLayout); - headerLayout.setColumns(1); - headerLayout.setRows(4); - // - infoArea.setReadWrite(false); - - this.getContentPane().add(panel, null); - panel.add(northPanel, BorderLayout.NORTH); - northPanel.add(imageControl, BorderLayout.WEST); - northPanel.add(headerPanel, BorderLayout.CENTER); - headerPanel.add(labelHeading, null); - headerPanel.add(labelCopyright, null); - headerPanel.add(labelVersion, null); - headerPanel.add(labelDescription, null); - panel.add(mainPanel, BorderLayout.CENTER); - mainPanel.add(infoArea, BorderLayout.CENTER); - mainPanel.add(confirmPanel, BorderLayout.SOUTH); - confirmPanel.addActionListener(this); - } // jbInit - - - /** - * ActionListener - * @param e event - */ - public void actionPerformed(ActionEvent e) - { - if(e.getActionCommand().equals(ConfirmPanel.A_OK)) - dispose(); - } // actionPerformed -} // AboutBox diff --git a/org.adempiere.ui.swing/src/org/compiere/apps/AppsAction.java b/org.adempiere.ui.swing/src/org/compiere/apps/AppsAction.java deleted file mode 100644 index 55f8a3ea98..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/apps/AppsAction.java +++ /dev/null @@ -1,316 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ -package org.compiere.apps; - -import java.awt.Dimension; -import java.awt.Insets; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; - -import javax.swing.AbstractAction; -import javax.swing.AbstractButton; -import javax.swing.Action; -import javax.swing.Icon; -import javax.swing.ImageIcon; -import javax.swing.JComponent; -import javax.swing.JMenuItem; -import javax.swing.KeyStroke; - -import org.compiere.swing.CButton; -import org.compiere.swing.CCheckBoxMenuItem; -import org.compiere.swing.CMenuItem; -import org.compiere.swing.CToggleButton; -import org.compiere.util.Env; -import org.compiere.util.Msg; - -/** - * Application Action. - * Creates Action with MenuItem and Button, delegate execution of action to an attached ActionListener instance - * The ActionCommand is translated for display - * If translated text contains &, the next character is the Mnemonic - * - * @author Jorg Janke - * @version $Id: AppsAction.java,v 1.2 2006/07/30 00:51:27 jjanke Exp $ - */ -public final class AppsAction extends AbstractAction -{ - /** - * - */ - private static final long serialVersionUID = 8522301377339185496L; - - /** - * Application Action - * - * @param action base action command - used as AD_Message for Text and Icon name - * @param accelerator optional keystroke for accelerator - * @param toggle is toggle action (maintains state) - */ - public AppsAction (String action, KeyStroke accelerator, boolean toggle) - { - this (action, accelerator, null, toggle); - } - /** - * Application Action - * - * @param action base action command - used as AD_Message for Text and Icon name - * @param accelerator optional keystroke for accelerator - * @param text text, if null defered from action - */ - public AppsAction (String action, KeyStroke accelerator, String text) - { - this (action, accelerator, text, false); - } // AppsAction - - /** - * Application Action - * - * @param action base action command - used as AD_Message for Text and Icon name - * @param accelerator optional keystroke for accelerator - * @param toolTipText text, if null defered from action - * @param toggle is toggle action (maintains state) - */ - public AppsAction (String action, KeyStroke accelerator, String toolTipText, boolean toggle) - { - super(); - m_action = action; - m_accelerator = accelerator; - m_toggle = toggle; - - // Data - if (toolTipText == null) - toolTipText = Msg.getMsg(Env.getCtx(), action); - int pos = toolTipText.indexOf('&'); - if (pos != -1 && toolTipText.length() > pos) // We have a nemonic - creates ALT-_ - { - Character ch = Character.valueOf(toolTipText.toUpperCase().charAt(pos+1)); - if (ch != ' ') - { - toolTipText = toolTipText.substring(0, pos) + toolTipText.substring(pos+1); - putValue(Action.MNEMONIC_KEY, Integer.valueOf(ch.hashCode())); - } - } - // - Icon small = getIcon(action, true); - Icon large = getIcon(action, false); - Icon largePressed = null; - - // ToggleIcons have the pressed name with X - if (m_toggle) - { - m_smallPressed = getIcon(action+"X", true); - if (m_smallPressed == null) - m_smallPressed = small; - largePressed = getIcon(action+"X", false); - if (largePressed == null) - largePressed = large; - } - - // Attributes - putValue(Action.NAME, toolTipText); // Display - putValue(Action.SMALL_ICON, small); // Icon - putValue(Action.SHORT_DESCRIPTION, toolTipText); // Tooltip - putValue(Action.ACTION_COMMAND_KEY, m_action); // ActionCammand - putValue(Action.ACCELERATOR_KEY, accelerator); // KeyStroke - // putValue(Action.MNEMONIC_KEY, Integer.valueOf(0)); // Mnemonic - // putValue(Action.DEFAULT, text); // Not Used - - // Create Button - if (toggle) - { - m_button = new CToggleButton(this); - m_button.setSelectedIcon(largePressed); - } - else - m_button = new CButton(this); - m_button.setName(action); - // Correcting Action items - if (large != null) - { - m_button.setIcon(large); - m_button.setText(null); - } - m_button.setActionCommand(m_action); - m_button.setMargin(BUTTON_INSETS); - m_button.setSize(BUTTON_SIZE); - // - if (accelerator != null) - { - m_button.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(accelerator, action); - m_button.getActionMap().put(action, this); - } - } // Action - - /** Button Size */ - public static final Dimension BUTTON_SIZE = new Dimension(28,28); - /** Button Insets */ - public static final Insets BUTTON_INSETS = new Insets(0, 0, 0, 0); - /** CButton or CToggelButton */ - private AbstractButton m_button; - /** Menu */ - private JMenuItem m_menu; - - private String m_action = null; - private KeyStroke m_accelerator = null; - private Icon m_smallPressed = null; - private ActionListener m_delegate = null; - private boolean m_toggle = false; - private boolean m_pressed = false; - - /** - * Get Icon with name action - * @param name name - * @param small small - * @return Icon - */ - private ImageIcon getIcon(String name, boolean small) - { - String fullName = name + (small ? "16" : "24"); - return Env.getImageIcon2(fullName); - } // getIcon - - /** - * Get Name/ActionCommand - * @return ActionName - */ - public String getName() - { - return m_action; - } // getName - - /** - * Return Button - * @return Button - */ - public AbstractButton getButton() - { - return m_button; - } // getButton - - /** - * Return MenuItem - * @return MenuItem - */ - public JMenuItem getMenuItem() - { - if (m_menu == null) - { - if (m_toggle) - { - m_menu = new CCheckBoxMenuItem(this); - m_menu.setSelectedIcon(m_smallPressed); - } - else - m_menu = new CMenuItem(this); - m_menu.setAccelerator(m_accelerator); - m_menu.setActionCommand(m_action); - } - return m_menu; - } // getMenuItem - - /** - * Set Delegate to receive the actionPerformed calls - * @param al listener - */ - public void setDelegate(ActionListener al) - { - m_delegate = al; - } // setDelegate - - /** - * Toggle - * @param pressed pressed - */ - public void setPressed (boolean pressed) - { - if (!m_toggle) - return; - m_pressed = pressed; - - // Set Button - if (m_button != null) - m_button.setSelected(pressed); - - // Set Menu - if (m_menu != null) - m_menu.setSelected(pressed); - } // setPressed - - /** - * IsPressed - * @return true if pressed - */ - public boolean isPressed() - { - return m_pressed; - } // isPressed - - /** - * Get Mnemonic character - * @return character - */ - public Character getMnemonic() - { - Object oo = getValue(Action.MNEMONIC_KEY); - if (oo instanceof Integer) - return (char)((Integer)oo).intValue(); - return null; - } // getMnemonic - - /** - * ActionListener - * @param e Event - */ - public void actionPerformed(ActionEvent e) - { - // log.info( "AppsAction.actionPerformed", e.getActionCommand()); - // Toggle Items - if (m_toggle) - setPressed(!m_pressed); - // Inform - if (m_delegate != null) - m_delegate.actionPerformed(e); - } // actionPerformed - - /** - * Dispose - */ - public void dispose() - { - m_button = null; - m_menu = null; - } // dispose - - /** - * String Info - * @return String Representation - */ - public String toString() - { - StringBuilder sb = new StringBuilder("AppsAction["); - sb.append(m_action); - Object oo = getValue(Action.ACCELERATOR_KEY); - if (oo != null) - sb.append(",Accelerator=").append(oo); - oo = getMnemonic(); - if (oo != null) - sb.append(",MnemonicKey=").append(oo); - sb.append("]"); - return sb.toString(); - } // toString - -} // AppsAction diff --git a/org.adempiere.ui.swing/src/org/compiere/apps/Attachment.java b/org.adempiere.ui.swing/src/org/compiere/apps/Attachment.java deleted file mode 100644 index 4d51941f3a..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/apps/Attachment.java +++ /dev/null @@ -1,669 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ -package org.compiere.apps; - -import java.awt.BorderLayout; -import java.awt.Desktop; -import java.awt.Dimension; -import java.awt.FlowLayout; -import java.awt.Frame; -import java.awt.Graphics; -import java.awt.Image; -import java.awt.Insets; -import java.awt.MediaTracker; -import java.awt.Toolkit; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.io.File; -import java.io.IOException; -import java.util.logging.Level; - -import javax.swing.JFileChooser; -import javax.swing.JPanel; -import javax.swing.JScrollPane; -import javax.swing.JSplitPane; - -import org.adempiere.pdf.viewer.PDFViewerBean; -import org.adempiere.plaf.AdempierePLAF; -import org.compiere.model.MAttachment; -import org.compiere.model.MAttachmentEntry; -import org.compiere.swing.CButton; -import org.compiere.swing.CComboBox; -import org.compiere.swing.CDialog; -import org.compiere.swing.CPanel; -import org.compiere.swing.CTextArea; -import org.compiere.util.CLogger; -import org.compiere.util.Env; -import org.compiere.util.Msg; - -/** - * Attachment Viewer - * - * @author Jorg Janke - * @version $Id: Attachment.java,v 1.4 2006/08/10 01:00:27 jjanke Exp $ - */ -public final class Attachment extends CDialog - implements ActionListener -{ - /** - * - */ - private static final long serialVersionUID = 2497487523050526742L; - - /** - * Save the last path selected - */ - private static String lastPath = null; - - /** - * Constructor. - * loads Attachment, if ID <> 0 - * @param frame frame - * @param WindowNo window no - * @param AD_Attachment_ID attachment - * @param AD_Table_ID table - * @param Record_ID record key - * @param trxName transaction - */ - public Attachment(Frame frame, int WindowNo, int AD_Attachment_ID, - int AD_Table_ID, int Record_ID, String trxName) - { - super (frame, Msg.getMsg(Env.getCtx(), "Attachment"), true); - // needs to be modal otherwise APanel does not recognize change. - if (log.isLoggable(Level.CONFIG)) log.config("ID=" + AD_Attachment_ID - + ", Table=" + AD_Table_ID + ", Record=" + Record_ID); - // - m_WindowNo = WindowNo; - // - try - { - staticInit(); - } - catch (Exception ex) - { - log.log(Level.SEVERE, "", ex); - } - // Create Model - if (AD_Attachment_ID > 0) - m_attachment = new MAttachment (Env.getCtx(), AD_Attachment_ID, trxName); - else - m_attachment = new MAttachment (Env.getCtx(), AD_Table_ID, Record_ID, trxName); - loadAttachments(); - // - try - { - AEnv.showCenterWindow(frame, this); - } - catch (Exception e) - { - } - text.requestFocus(); - } // Attachment - - /** Window No */ - private int m_WindowNo; - /** Attachment */ - private MAttachment m_attachment = null; - /** Change */ - private boolean m_change = false; - /** Logger */ - private static CLogger log = CLogger.getCLogger(Attachment.class); - - // - private CPanel mainPanel = new CPanel(); - private BorderLayout mainLayout = new BorderLayout(); - private CTextArea text = new CTextArea(); - private CButton bOpen = new CButton(); - private CButton bSave = new CButton(); - private CPanel northPanel = new CPanel(); - private CButton bLoad = new CButton(); - private BorderLayout northLayout = new BorderLayout(); - private ConfirmPanel confirmPanel = new ConfirmPanel(true); - private CPanel toolBar = new CPanel(new FlowLayout(FlowLayout.LEADING, 5,5)); - private CButton bDelete = new CButton(); - private CButton bDeleteAll = null; - private CComboBox cbContent = new CComboBox(); - private JSplitPane centerPane = new JSplitPane(); - // - private CPanel graphPanel = new CPanel(new BorderLayout()); - private GImage gifPanel = new GImage(); - private JScrollPane gifScroll = new JScrollPane (gifPanel); - private PDFViewerBean pdfViewer = new PDFViewerBean(); - private CTextArea info = new CTextArea(); - - /** - * Static setup. - *
    -	 *  - northPanel
    -	 *      - toolBar
    -	 *      - title
    -	 *  - centerPane [split]
    -	 * 		- graphPanel (left)
    -	 *		  	- gifScroll - gifPanel
    -	 *			- pdfViewer
    -	 *  	- text (right)
    -	 *  - confirmPanel
    -	 *  
    - * @throws Exception - */ - void staticInit() throws Exception - { - mainPanel.setLayout(mainLayout); - mainLayout.setHgap(5); - mainLayout.setVgap(5); - this.getContentPane().add(mainPanel); - - northPanel.setLayout(northLayout); - northPanel.add(toolBar, BorderLayout.CENTER); - toolBar.add(bLoad); - toolBar.add(bDelete); - toolBar.add(bSave); - toolBar.add(bOpen); - toolBar.add(cbContent); - mainPanel.add(northPanel, BorderLayout.NORTH); - - // - bOpen.setEnabled(false); - bOpen.setIcon(Env.getImageIcon("Editor24.gif")); - bOpen.setMargin(new Insets(0, 2, 0, 2)); - bOpen.setToolTipText(Msg.getMsg(Env.getCtx(), "Open")); - bOpen.addActionListener(this); - // - bSave.setEnabled(false); - bSave.setIcon(Env.getImageIcon("Export24.gif")); - bSave.setMargin(new Insets(0, 2, 0, 2)); - bSave.setToolTipText(Msg.getMsg(Env.getCtx(), "AttachmentSave")); - bSave.addActionListener(this); - // - bLoad.setIcon(Env.getImageIcon("Import24.gif")); - bLoad.setMargin(new Insets(0, 2, 0, 2)); - bLoad.setToolTipText(Msg.getMsg(Env.getCtx(), "Load")); - bLoad.addActionListener(this); - // - bDelete.setIcon(Env.getImageIcon("Delete24.gif")); - bDelete.setMargin(new Insets(0, 2, 0, 2)); - bDelete.setToolTipText(Msg.getMsg(Env.getCtx(), "Delete")); - bDelete.addActionListener(this); - // - Dimension size = cbContent.getPreferredSize(); - size.width = 200; - cbContent.setPreferredSize(size); - // cbContent.setToolTipText(text); - cbContent.addActionListener(this); - cbContent.setLightWeightPopupEnabled(false); // Acrobat Panel is heavy - // - text.setBackground(AdempierePLAF.getInfoBackground()); - text.setPreferredSize(new Dimension(200, 200)); - // - mainPanel.add(confirmPanel, BorderLayout.SOUTH); - confirmPanel.addActionListener(this); - bDeleteAll = ConfirmPanel.createDeleteButton(true); - confirmPanel.addButton(bDeleteAll); - bDeleteAll.addActionListener(this); - // - info.setText("-"); - info.setReadWrite(false); - graphPanel.add(info, BorderLayout.CENTER); - // - mainPanel.add(centerPane, BorderLayout.CENTER); - centerPane.add(graphPanel, JSplitPane.LEFT); - centerPane.add(text, JSplitPane.RIGHT); - centerPane.setResizeWeight(.75); // more to graph - } // jbInit - - - /** - * Dispose - */ - public void dispose () - { - pdfViewer = null; - super.dispose (); - } // dispose - - /** - * Load Attachments - */ - private void loadAttachments() - { - log.config(""); - // Set Text/Description - String sText = m_attachment.getTextMsg(); - if (sText == null) - text.setText(""); - else - text.setText(sText); - - // Set Combo - int size = m_attachment.getEntryCount(); - for (int i = 0; i < size; i++) - cbContent.addItem(m_attachment.getEntryName(i)); - if (size > 0) - cbContent.setSelectedIndex(0); - else - displayData(0); - } // loadAttachment - - /** - * Display gif or jpg in gifPanel - * @param index index - */ - private void displayData (int index) - { - MAttachmentEntry entry = m_attachment.getEntry(index); - if (log.isLoggable(Level.CONFIG)) log.config("Index=" + index + " - " + entry); - - // Reset UI - gifPanel.setImage(null); - graphPanel.removeAll(); - // - bDelete.setEnabled(false); - bOpen.setEnabled(false); - bSave.setEnabled(false); - - Dimension size = null; - // no attachment - if (entry == null || entry.getData() == null) - { - info.setText("-"); - } - else - { - bOpen.setEnabled(true); - bSave.setEnabled(true); - bDelete.setEnabled(true); - if (log.isLoggable(Level.CONFIG)) log.config(entry.toStringX()); - // - info.setText(entry.toStringX()); - if (entry.isPDF() && pdfViewer != null) - { - try - { - pdfViewer.loadPDF(entry.getInputStream()); - pdfViewer.setScale(50); - size = pdfViewer.getPreferredSize(); - // size.width = Math.min(size.width, 400); - // size.height = Math.min(size.height, 400); - // - graphPanel.add(pdfViewer, BorderLayout.CENTER); - } - catch (Exception e) - { - log.log(Level.SEVERE, "(pdf)", e); - } - } - else if (entry.isGraphic()) - { - // Can we display it - Image image = Toolkit.getDefaultToolkit().createImage(entry.getData()); - if (image != null) - { - gifPanel.setImage(image); - size = gifPanel.getPreferredSize(); - if (size.width == -1 && size.height == -1) - { - log.log(Level.SEVERE, "Invalid Image"); - } - else - { - // size.width += 40; - // size.height += 40; - graphPanel.add(gifScroll, BorderLayout.CENTER); - } - } - else - log.log(Level.SEVERE, "Could not create image"); - } - } - if (graphPanel.getComponentCount() == 0) - { - graphPanel.add(info, BorderLayout.CENTER); - } - - if (log.isLoggable(Level.CONFIG)) log.config("Size=" + size); - // graphPanel.setPreferredSize(size); - // centerPane.setDividerLocation(size.width+30); - // size.width += 100; - // size.height += 100; - // centerPane.setPreferredSize(size); - pack(); - } // displayData - - - /** - * Get File Name with index - * @param index index - * @return file name or null - */ - private String getFileName (int index) - { - String fileName = null; - if (cbContent.getItemCount() > index) - fileName = (String)cbContent.getItemAt(index); - return fileName; - } // getFileName - - /** - * Action Listener - * @param e event - */ - public void actionPerformed(ActionEvent e) - { - // log.config(e.getActionCommand()); - // Save and Close - if (e.getActionCommand().equals(ConfirmPanel.A_OK)) - { - String newText = text.getText(); - if (newText == null) - newText = ""; - String oldText = m_attachment.getTextMsg(); - if (oldText == null) - oldText = ""; - if (!m_change) - m_change = !newText.equals(oldText); - if (newText.length() > 0 || m_attachment.getEntryCount() > 0) - { - if (m_change) - { - m_attachment.setBinaryData(new byte[0]); // ATTENTION! HEAVY HACK HERE... Else it will not save :( - m_attachment.setTextMsg(text.getText()); - m_attachment.saveEx(); - } - } - else - { - m_attachment.delete(true); - m_attachment = null; - } - dispose(); - } - // Cancel - else if (e.getActionCommand().equals(ConfirmPanel.A_CANCEL)) - { - dispose(); - } - // Delete Attachment - else if (e.getSource() == bDeleteAll) - { - deleteAttachment(); - dispose(); - } - // Delete individual entry and Return - else if (e.getSource() == bDelete) - deleteAttachmentEntry(); - // Show Data - else if (e.getSource() == cbContent) - displayData (cbContent.getSelectedIndex()); - // Load Attachment - else if (e.getSource() == bLoad) - loadFile(); - // Open Attachment - else if (e.getSource() == bSave) - saveAttachmentToFile(); - // Open Attachment - else if (e.getSource() == bOpen) - { - if (!openAttachment()) - saveAttachmentToFile(); - } - } // actionPerformed - - - /************************************************************************** - * Load file for attachment - */ - private void loadFile() - { - log.info(""); - JFileChooser chooser = new JFileChooser(lastPath); - - chooser.setDialogType(JFileChooser.OPEN_DIALOG); - chooser.setDialogTitle(Msg.getMsg(Env.getCtx(), "AttachmentNew")); - chooser.setMultiSelectionEnabled(true); - int returnVal = chooser.showOpenDialog(this); - if (returnVal != JFileChooser.APPROVE_OPTION) - return; - // - File[] files = chooser.getSelectedFiles(); - for (File file : files) { - int cnt = m_attachment.getEntryCount(); - - //update - boolean add = true; - for (int i = 0; i < cnt; i++) - { - if (m_attachment.getEntryName(i).equals(file.getName())) - { - if (m_attachment.updateEntry(i, file)) - { - cbContent.setSelectedItem(file.getName()); - m_change = true; - } - add = false; - break; - } - } - - if (add) - { - //new - if (m_attachment.addEntry(file)) - { - cbContent.addItem(file.getName()); - cbContent.setSelectedIndex(cbContent.getItemCount()-1); - m_change = true; - } - } - } - // Save path of file - if (files.length>0) { - lastPath = files[0].getParentFile().getAbsolutePath(); - } - } // getFileName - - /** - * Delete entire Attachment - */ - private void deleteAttachment() - { - log.info(""); - if (ADialog.ask(m_WindowNo, this, "AttachmentDelete?")) { - m_attachment.delete(true); - m_attachment = null; - } - } // deleteAttachment - - /** - * Delete Attachment Entry - */ - private void deleteAttachmentEntry() - { - log.info(""); - int index = cbContent.getSelectedIndex(); - String fileName = getFileName(index); - if (fileName == null) - return; - // - if (ADialog.ask(m_WindowNo, this, "AttachmentDeleteEntry?", fileName)) - { - if (m_attachment.deleteEntry(index)) - cbContent.removeItemAt(index); - m_change = true; - } - } // deleteAttachment - - - /** - * Save Attachment to File - */ - private void saveAttachmentToFile() - { - int index = cbContent.getSelectedIndex(); - if (log.isLoggable(Level.INFO)) log.info("index=" + index); - if (m_attachment.getEntryCount() < index) - return; - - String fileName = getFileName(index); - String ext = fileName.substring (fileName.lastIndexOf('.')); - if (log.isLoggable(Level.CONFIG)) log.config( "Ext=" + ext); - - JFileChooser chooser = new JFileChooser(); - chooser.setDialogType(JFileChooser.SAVE_DIALOG); - chooser.setDialogTitle(Msg.getMsg(Env.getCtx(), "AttachmentSave")); - File f = new File(fileName); - chooser.setSelectedFile(f); - // Show dialog - int returnVal = chooser.showSaveDialog(this); - if (returnVal != JFileChooser.APPROVE_OPTION) - return; - File saveFile = chooser.getSelectedFile(); - if (saveFile == null) - return; - - if (log.isLoggable(Level.CONFIG)) log.config("Save to " + saveFile.getAbsolutePath()); - m_attachment.getEntryFile(index, saveFile); - } // saveAttachmentToFile - - /** - * Open the temporary file with the application associated with the extension in the file name - * @return true if file was opened with third party application - */ - private boolean openAttachment () - { - int index = cbContent.getSelectedIndex(); - byte[] data = m_attachment.getEntryData(index); - if (data == null) - return false; - - try - { - String fileName = System.getProperty("java.io.tmpdir") + - System.getProperty("file.separator") + - m_attachment.getEntryName(index); - File tempFile = new File(fileName); - m_attachment.getEntryFile(index, tempFile); - - if (Env.isWindows()) - { - // Runtime.getRuntime().exec ("rundll32 url.dll,FileProtocolHandler " + url); - @SuppressWarnings("unused") - Process p = Runtime.getRuntime().exec("rundll32 SHELL32.DLL,ShellExec_RunDLL \"" + tempFile + "\""); - // p.waitFor(); - return true; - } - else if (Env.isMac()) - { - String [] cmdArray = new String [] {"open", tempFile.getAbsolutePath()}; - @SuppressWarnings("unused") - Process p = Runtime.getRuntime ().exec (cmdArray); - // p.waitFor(); - return true; - } - else // other OS. originally nothing here. add the following codes - { - try { - Desktop desktop = null; - if (Desktop.isDesktopSupported()) { - desktop = Desktop.getDesktop(); - File file = new File(tempFile.getAbsolutePath()); - desktop.open(file); - return true; - } - } catch (IOException e) { - e.printStackTrace(); - } - } - } - catch (Exception e) - { - log.log(Level.SEVERE, "", e); - } - return false; - } // openFile - - - /************************************************************************** - * Graphic Image Panel - */ - class GImage extends JPanel - { - /** - * - */ - private static final long serialVersionUID = 4991225210651641722L; - - /** - * Graphic Image - */ - public GImage() - { - super(); - } // GImage - - /** The Image */ - private Image m_image = null; - - /** - * Set Image - * @param image image - */ - public void setImage (Image image) - { - m_image = image; - if (m_image == null) - return; - - MediaTracker mt = new MediaTracker(this); - mt.addImage(m_image, 0); - try { - mt.waitForID(0); - } catch (Exception e) {} - Dimension dim = new Dimension(m_image.getWidth(this), m_image.getHeight(this)); - this.setPreferredSize(dim); - } // setImage - - /** - * Paint - * @param g graphics - */ - public void paint (Graphics g) - { - Insets in = getInsets(); - if (m_image != null) - g.drawImage(m_image, in.left, in.top, this); - } // paint - - /** - * Update - * @param g graphics - */ - public void update (Graphics g) - { - paint(g); - } // update - } // GImage - - - /** - * Test PDF Viewer - * @param args ignored - */ - public static void main (String[] args) - { - } // main - -} // Attachment diff --git a/org.adempiere.ui.swing/src/org/compiere/apps/BeanShellEditor.java b/org.adempiere.ui.swing/src/org/compiere/apps/BeanShellEditor.java deleted file mode 100644 index 0884b2601f..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/apps/BeanShellEditor.java +++ /dev/null @@ -1,404 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ -package org.compiere.apps; - -import java.awt.BorderLayout; -import java.awt.Color; -import java.awt.Dimension; -import java.awt.FlowLayout; -import java.awt.Frame; -import java.awt.GridBagConstraints; -import java.awt.GridBagLayout; -import java.awt.Insets; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.sql.Timestamp; -import java.util.Arrays; -import java.util.HashMap; -import java.util.logging.Level; - -import javax.swing.BorderFactory; -import javax.swing.JButton; -import javax.swing.JFrame; -import javax.swing.JLabel; -import javax.swing.JScrollPane; -import javax.swing.JSplitPane; -import javax.swing.JTextArea; -import javax.swing.JTextField; -import javax.swing.JTextPane; -import javax.swing.border.TitledBorder; - -import org.compiere.model.MUser; -import org.compiere.model.Scriptlet; -import org.compiere.swing.CDialog; -import org.compiere.swing.CPanel; -import org.compiere.util.CLogger; -import org.compiere.util.Env; -import org.compiere.util.Msg; - -import bsh.ParseException; - -/** - * Bean Shell Editor - * - * @author Jorg Janke - * @version $Id: ScriptEditor.java,v 1.2 2006/07/30 00:51:27 jjanke Exp $ - */ -public class BeanShellEditor extends CDialog implements ActionListener -{ - /** - * - */ - private static final long serialVersionUID = -5134274235147001140L; - @SuppressWarnings("unused") - private Frame m_owner; - - /** - * Minimum Constructor - */ - public BeanShellEditor() - { - this (Msg.getMsg(Env.getCtx(), "Script"), null, 0); - } // ScriptEditor - - /** - * Minimum Constructor - */ - public BeanShellEditor(Frame owner) - { - this (owner, Msg.getMsg(Env.getCtx(), "Script"), null, 0); - } // ScriptEditor - - /** - * Constructor - * - * @param title Field Name - * @param script The Script - */ - public BeanShellEditor (String title, Scriptlet script, int WindowNo) - { - this(null, title, script, WindowNo); - } - - /** - * Constructor - * - * @param owner Owner frame - * @param title Field Name - * @param script The Script - */ - public BeanShellEditor (Frame owner, String title, Scriptlet script, int WindowNo) - { - super(owner); - setTitle(title); - if (owner != null) - { - setModal(true); - } - m_owner = owner; - m_WindowNo = WindowNo; - if (m_WindowNo == 0) - m_WindowNo = AEnv.createWindowNo(this); - if (log.isLoggable(Level.INFO)) log.info("Window=" + m_WindowNo); - try - { - jbInit(); - setScript (script); - dynInit(); - AEnv.showCenterScreen(this); - toFront(); - } - catch(Exception ex) - { - log.log(Level.SEVERE, "", ex); - } - } // ScriptEditor - - /** The Script */ - private Scriptlet m_script; - /** WindowNo */ - private int m_WindowNo; - /** Original Script */ - private String m_origScript; - /** Logger */ - private static CLogger log = CLogger.getCLogger(BeanShellEditor.class); - // -- - - private CPanel mainPanel = new CPanel(); - private BorderLayout borderLayout1 = new BorderLayout(); - private JScrollPane editorPane = new JScrollPane(); - private JTextArea editor = new JTextArea(); - private JScrollPane variablesPane = new JScrollPane(); - private JTextPane variables = new JTextPane(); - private TitledBorder titledBorder1; - private TitledBorder titledBorder2; - private CPanel northPanel = new CPanel(); - private CPanel southPanel = new CPanel(); - private BorderLayout southLayout = new BorderLayout(); - private CPanel okPanel = new CPanel(); - private JButton bOK = ConfirmPanel.createOKButton(true); - private JButton bCancel = ConfirmPanel.createCancelButton(true); - private CPanel resultPanel = new CPanel(); - private JButton bProcess = ConfirmPanel.createProcessButton(true); - private JButton bValidate = ConfirmPanel.createCustomizeButton("Validate"); - private JLabel lResult = new JLabel(); - private JTextField fResult = new JTextField(); - private CPanel resultVariablePanel = new CPanel(); - private BorderLayout northLayout = new BorderLayout(); - private JLabel lResultVariable = new JLabel(); - private JTextField fResultVariable = new JTextField(); - private CPanel helpPanel = new CPanel(); - private JButton bHelp = ConfirmPanel.createHelpButton(true); - private GridBagLayout resultVariableLayout = new GridBagLayout(); - private FlowLayout okLayout = new FlowLayout(); - private GridBagLayout resultLayout = new GridBagLayout(); - private JSplitPane centerPane = new JSplitPane(); - - /** - * Static Layout - * @throws Exception - */ - void jbInit() throws Exception - { - this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); - titledBorder1 = new TitledBorder(BorderFactory.createEtchedBorder(Color.white,new Color(148, 145, 140)), - Msg.getMsg(Env.getCtx(), "ScriptVariables")); - titledBorder2 = new TitledBorder(BorderFactory.createEtchedBorder(Color.white,new Color(148, 145, 140)), - Msg.getMsg(Env.getCtx(), "ScriptEditor")); - mainPanel.setLayout(borderLayout1); - editor.setLineWrap(true); - editor.setTabSize(4); - editor.setWrapStyleWord(true); - bOK.addActionListener(this); - bCancel.addActionListener(this); - bHelp.addActionListener(this); - bProcess.addActionListener(this); - bValidate.addActionListener(this); - variables.setBackground(Color.lightGray); - variables.setEditable(false); - variables.setContentType("text/html"); - variablesPane.setBorder(titledBorder1); - editorPane.setBorder(titledBorder2); - centerPane.setPreferredSize(new Dimension(500, 500)); - centerPane.setLeftComponent(editorPane); - centerPane.setRightComponent(variablesPane); - southPanel.setLayout(southLayout); - resultPanel.setLayout(resultLayout); - lResult.setText(Msg.getMsg(Env.getCtx(), "ScriptResult")); - fResult.setBackground(Color.lightGray); - fResult.setEditable(false); - fResult.setText(""); - northPanel.setLayout(northLayout); - lResultVariable.setText(Msg.getMsg(Env.getCtx(), "ScriptResultVariable")); - fResultVariable.setBackground(Color.lightGray); - fResultVariable.setEditable(false); - resultVariablePanel.setLayout(resultVariableLayout); - okPanel.setLayout(okLayout); - northPanel.add(resultVariablePanel, BorderLayout.CENTER); - getContentPane().add(mainPanel); - editorPane.getViewport().add(editor, null); - variablesPane.getViewport().add(variables, null); - mainPanel.add(northPanel, BorderLayout.NORTH); - mainPanel.add(southPanel, BorderLayout.SOUTH); - southPanel.add(okPanel, BorderLayout.EAST); - okPanel.add(bCancel, null); - okPanel.add(bOK, null); - southPanel.add(resultPanel, BorderLayout.CENTER); - resultPanel.add(bValidate, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); - resultPanel.add(bProcess, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); - resultPanel.add(lResult, new GridBagConstraints(2, 0, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); - resultPanel.add(fResult, new GridBagConstraints(3, 0, 1, 1, 1.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5), 0, 0)); - mainPanel.add(centerPane, BorderLayout.CENTER); - resultVariablePanel.add(lResultVariable, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); - resultVariablePanel.add(fResultVariable, new GridBagConstraints(1, 0, 1, 1, 1.0, 0.0 - ,GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5), 0, 0)); - northPanel.add(helpPanel, BorderLayout.EAST); - helpPanel.add(bHelp, null); - centerPane.setDividerLocation(350); - } // jbInit - - /** - * Set Script - * @param script The Script - */ - public void setScript (Scriptlet script) - { - if (script == null) - m_script = new Scriptlet (Scriptlet.VARIABLE, ";", Env.getCtx(), m_WindowNo); - else - m_script = script; - // - fResultVariable.setText(m_script.getVariable()); - m_origScript = m_script.getScript(); - editor.setText(m_script.getScript()); - // - StringBuilder sb = new StringBuilder(""); - HashMap ctx = m_script.getEnvironment(); - String[] pp = new String[ctx.size()]; - ctx.keySet().toArray(pp); - Arrays.sort(pp); - for (int i = 0; i < pp.length; i++) - { - String key = pp[i].toString(); - Object value = ctx.get(key); - sb.append("") - .append(key) - .append(" (") - .append(value) - .append(")
    "); - } - sb.append(""); - variables.setText(sb.toString()); - variables.setCaretPosition(0); - } // setScript - - /** - * Get Color Code - * @param value the object - * @return HTML color code - */ - private String getColor (Object value) - { - if (value instanceof String) - return "#009900"; // "green"; - else if (value instanceof Integer) - return "#0000FF"; // "blue"; - else if (value instanceof Double) - return "#00FFFF"; // "cyan"; - else if (value instanceof Timestamp) - return "#FF00FF"; // "magenta"; - else if (value instanceof Boolean) - return "#FF9900"; // "orange"; - return "#FF0000"; // "red"; - } // getColor - - /** - * Dynamic Init - */ - private void dynInit() - { - - } // dynInit - - - /** - * Action Listener - * @param e - */ - public void actionPerformed(ActionEvent e) - { - if (e.getSource() == bOK) - { - m_script.setScript(editor.getText()); - dispose(); - } - else if (e.getSource() == bCancel) - { - m_script.setScript(m_origScript); - dispose(); - } - - else if (e.getSource() == bProcess) - actionProcess(); - else if (e.getSource() == bValidate) - actionValidate(); - else if (e.getSource() == bHelp) - { - Help h = new Help (this , - Msg.getMsg(Env.getCtx(), "ScriptHelp"), - getClass().getResource("Script.html")); - h.setVisible(true); - } - } // actionPerformed - - /** - * Process Script - */ - private void actionProcess() - { - /** Example: - import org.compiere.util.DB; - import java.sql.*; - PreparedStatement pstmt =DB.prepareStatement("select Name, Password from AD_User where Name like 'Super%'"); - ResultSet rs = pstmt.executeQuery(); - if (rs.next()) - { - result = rs.getString("Name") + "; password= " + rs.getString("Password"); - } - **/ - - MUser user = MUser.get(Env.getCtx()); - if (!user.isAdministrator()) - { - fResult.setText("Not Administrator"); - return; - } - // - m_script.setScript(editor.getText()); - Exception e = m_script.execute(); - if (e != null) - ADialog.error(m_WindowNo, this, "ScriptError", e.toString()); - Object result = m_script.getResult(false); - fResult.setText(result == null ? "" : result.toString()); - } // actionProcess - - /** - * Validate Script - */ - private void actionValidate() - { - /** Example: - import org.compiere.util.DB; - import java.sql.*; - PreparedStatement pstmt =DB.prepareStatement("select Name, Password from AD_User where Name like 'Super%'"); - ResultSet rs = pstmt.executeQuery(); - if (rs.next()) - { - result = rs.getString("Name") + "; password= " + rs.getString("Password"); - } - **/ - - MUser user = MUser.get(Env.getCtx()); - if (!user.isAdministrator()) - { - fResult.setText("Not Administrator"); - return; - } - // - m_script.setScript(editor.getText()); - Exception e = null; - try { - m_script.validate(); - } catch (ParseException e1) { - e = e1; - } - if (e != null) - { - ADialog.error(m_WindowNo, this, "ScriptError", e.toString()); - fResult.setText("Syntax errors detected."); - } - else - fResult.setText("No syntax errors detected."); - } // actionValidate - - /*************************************************************************/ -} // ScriptEditor diff --git a/org.adempiere.ui.swing/src/org/compiere/apps/ClientProcessCtrl.java b/org.adempiere.ui.swing/src/org/compiere/apps/ClientProcessCtrl.java deleted file mode 100644 index 79e925a324..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/apps/ClientProcessCtrl.java +++ /dev/null @@ -1,96 +0,0 @@ -package org.compiere.apps; - -import java.awt.Container; -import java.util.logging.Level; - -import org.adempiere.util.IProcessUI; -import org.compiere.model.MPInstance; -import org.compiere.process.ProcessInfo; -import org.compiere.util.CLogger; -import org.compiere.util.Env; -import org.compiere.util.Msg; -import org.compiere.util.Trx; - -public class ClientProcessCtrl { - - /** Static Logger */ - private static CLogger log = CLogger.getCLogger (ClientProcessCtrl.class); - - /** - * Process Control - * - * - Get Instance ID - * - Get Parameters - * - execute (lock - start process - unlock) - * - * Creates a ProcessCtl instance, which calls - * lockUI and unlockUI if parent is a ASyncProcess - *
    - * Called from APanel.cmd_print, APanel.actionButton and - * VPaySelect.cmd_generate - * - * @param parent ASyncProcess & Container - * @param WindowNo window no - * @param pi ProcessInfo process info - * @param trx Transaction - * @return worker started ProcessCtl instance or null for workflow - */ - public static ProcessCtl process (IProcessUI parent, int WindowNo, ProcessInfo pi, Trx trx) - { - if (log.isLoggable(Level.FINE)) log.fine("WindowNo=" + WindowNo + " - " + pi); - - MPInstance instance = null; - try - { - instance = new MPInstance(Env.getCtx(), pi.getAD_Process_ID(), pi.getRecord_ID()); - } - catch (Exception e) - { - pi.setSummary (e.getLocalizedMessage()); - pi.setError (true); - log.warning(pi.toString()); - return null; - } - catch (Error e) - { - pi.setSummary (e.getLocalizedMessage()); - pi.setError (true); - log.warning(pi.toString()); - return null; - } - if (!instance.save()) - { - pi.setSummary (Msg.getMsg(Env.getCtx(), "ProcessNoInstance")); - pi.setError (true); - return null; - } - pi.setAD_PInstance_ID (instance.getAD_PInstance_ID()); - - // Get Parameters (Dialog) - ProcessParameter para = new ProcessParameter (AEnv.getFrame((Container)parent), WindowNo, pi); - if (para.initDialog()) - { - para.setVisible(true); - if (!para.isOK()) - { - pi.setSummary (Msg.getMsg(Env.getCtx(), "ProcessCancelled")); - pi.setError (true); - return null; - } - } - - // execute - ProcessCtl worker = new ProcessCtl(parent, WindowNo, pi, trx); - if (parent != null) - { - //asynchrous - worker.start(); - } - else - { - //synchrous - worker.run(); - } - return worker; - } // execute -} diff --git a/org.adempiere.ui.swing/src/org/compiere/apps/ConfirmPanel.java b/org.adempiere.ui.swing/src/org/compiere/apps/ConfirmPanel.java deleted file mode 100644 index d46a86b3b3..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/apps/ConfirmPanel.java +++ /dev/null @@ -1,741 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ -package org.compiere.apps; - -import java.awt.BorderLayout; -import java.awt.Component; -import java.awt.FlowLayout; -import java.awt.Insets; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.awt.event.KeyEvent; - -import javax.swing.Icon; -import javax.swing.JButton; -import javax.swing.JDialog; -import javax.swing.JFrame; -import javax.swing.JRootPane; -import javax.swing.KeyStroke; - -import org.compiere.swing.CButton; -import org.compiere.swing.CPanel; -import org.compiere.util.Env; -import org.compiere.util.Msg; - -/** - * Application Confirm Panel. - * - * if (e.getActionCommand().equals(ConfirmPanel.A_OK)) - * - * @author Jorg Janke - * @version $Id: ConfirmPanel.java,v 1.2 2006/07/30 00:51:27 jjanke Exp $ - */ -public final class ConfirmPanel extends CPanel -{ - /** - * - */ - private static final long serialVersionUID = 6041019802043360966L; - - - /** - * Create OK Button with label text and F4 Shortcut - * @param text text - * @return OK Button - */ - public static final CButton createOKButton (String text) - { - AppsAction aa = new AppsAction (A_OK, KeyStroke.getKeyStroke(KeyEvent.VK_F4, 0), text); - CButton button = (CButton)aa.getButton(); - button.setMargin(s_insets); - button.setDefaultCapable(true); - return button; - } // createOKButton - - /** - * Create OK Button with Standard text - * @param withText with text - * @return OK Button - */ - public static final CButton createOKButton (boolean withText) - { - if (withText) - return createOKButton(Msg.getMsg(Env.getCtx(), A_OK)); - return createOKButton(""); - } // createOKButton - - /** - * Create Cancel Button wlth label text and register ESC as KeyStroke - * @param text text - * @return Cancel Button - */ - public static final CButton createCancelButton (String text) - { - AppsAction aa = new AppsAction (A_CANCEL, KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), text); - CButton button = (CButton)aa.getButton(); - button.setMargin(s_insets); - return button; - } // createCancelButton - - /** - * Create Cancel Button wlth Standard text - * @param withText with text - * @return Button - */ - public static final CButton createCancelButton(boolean withText) - { - if (withText) - return createCancelButton(Msg.getMsg(Env.getCtx(), A_CANCEL)); - return createCancelButton(""); - } // createCancelButton - - - /************************ - * Create Refresh Button wlth label text and F5 - * @param text text - * @return button - */ - public static final CButton createRefreshButton (String text) - { - AppsAction aa = new AppsAction (A_REFRESH, KeyStroke.getKeyStroke(KeyEvent.VK_F5, 0), text); - CButton button = (CButton)aa.getButton(); - button.setMargin(s_insets); - return button; - } // createRefreshButton - - /** - * Create Refresh Button wlth Standard text - * @param withText with text - * @return Button - */ - public static final CButton createRefreshButton (boolean withText) - { - if (withText) - return createRefreshButton(Msg.getMsg(Env.getCtx(), A_REFRESH)); - return createRefreshButton(""); - } // createRefreshButton - - - /************************ - * Create Reset Button wlth label text - * @param text text - * @return button - */ - public static final CButton createResetButton (String text) - { - AppsAction aa = new AppsAction (A_RESET, null, text); - CButton button = (CButton)aa.getButton(); - button.setMargin(s_insets); - return button; - } // createResetButton - - /** - * Create Reset Button wlth Standard text - * @param withText with text - * @return Button - */ - public static final CButton createResetButton (boolean withText) - { - if (withText) - return createResetButton(Msg.getMsg(Env.getCtx(), A_RESET)); - return createResetButton(null); - } // createRefreshButton - - /************************ - * Create Customize Button wlth label text - * @param text text - * @return button - */ - public static final CButton createCustomizeButton (String text) - { - AppsAction aa = new AppsAction (A_CUSTOMIZE, null, text); - CButton button = (CButton)aa.getButton(); - button.setMargin(s_insets); - return button; - // Env.getImageIcon("Preference24.gif")); - } // createCustomizeButton - - /** - * Create Customize Button wlth Standard text - * @param withText with text - * @return Button - */ - public static final CButton createCustomizeButton (boolean withText) - { - if (withText) - return createCustomizeButton(Msg.getMsg(Env.getCtx(), A_CUSTOMIZE)); - return createCustomizeButton(null); - } // createCustomizeButton - - - /************************ - * Create History Button wlth label text - * @param text text - * @return button - */ - public static final CButton createHistoryButton (String text) - { - AppsAction aa = new AppsAction (A_HISTORY, KeyStroke.getKeyStroke(KeyEvent.VK_F9, 0), text); - CButton button = (CButton)aa.getButton(); - button.setMargin(s_insets); - return button; - // Env.getImageIcon("HistoryX24.gif")); - } // createHistoryButton - - /** - * Create History Button wlth Standard text - * @param withText with text - * @return Button - */ - public static final CButton createHistoryButton (boolean withText) - { - if (withText) - return createHistoryButton(Msg.getMsg(Env.getCtx(), A_HISTORY)); - return createHistoryButton(null); - } // createHistoryButton - - - /************************ - * Create Zoom Button wlth label text - * @param text text - * @return button - */ - public static final CButton createZoomButton (String text) - { - AppsAction aa = new AppsAction (A_ZOOM, null, text); - CButton button = (CButton)aa.getButton(); - button.setMargin(s_insets); - return button; - } // createZoomButton - - /** - * Create Zoom Button wlth Standard text - * @param withText with text - * @return Button - */ - public static final CButton createZoomButton (boolean withText) - { - if (withText) - return createZoomButton(Msg.getMsg(Env.getCtx(), A_ZOOM)); - return createZoomButton(null); - } // createZoomButton - - - /************************ - * Create Process Button wlth label text Shift-F4 - * @param text text - * @return button - */ - public static final CButton createProcessButton (String text) - { - AppsAction aa = new AppsAction (A_PROCESS, - KeyStroke.getKeyStroke(KeyEvent.VK_F4, ActionEvent.SHIFT_MASK), text); - CButton button = (CButton)aa.getButton(); - button.setMargin(s_insets); - return button; - } // createProcessButton - - /** - * Create Process Button wlth Standard text - * @param withText with text - * @return Button - */ - public static final CButton createProcessButton (boolean withText) - { - if (withText) - return createProcessButton(Msg.getMsg(Env.getCtx(), A_PROCESS)); - return createProcessButton(null); - } // createProcessButton - - - /************************ - * Create Print Button wlth label text - * @param text text - * @return button - */ - public static final CButton createPrintButton (String text) - { - AppsAction aa = new AppsAction (A_PRINT, KeyStroke.getKeyStroke(KeyEvent.VK_F12, 0), text); - CButton button = (CButton)aa.getButton(); - button.setMargin(s_insets); - return button; - } // createPrintButton - - /** - * Create Print Button wlth Standard text - * @param withText with text - * @return Button - */ - public static final CButton createPrintButton (boolean withText) - { - if (withText) - return createPrintButton(Msg.getMsg(Env.getCtx(), A_PRINT)); - return createPrintButton(null); - } // createPrintButton - - - /************************ - * Create Help Button wlth label text - * @param text text - * @return Button - */ - public static final CButton createHelpButton (String text) - { - AppsAction aa = new AppsAction (A_HELP, KeyStroke.getKeyStroke(KeyEvent.VK_F1, 0), text); - CButton button = (CButton)aa.getButton(); - button.setMargin(s_insets); - return button; - } // createHelpButton - - /** - * Create Help Button wlth Standard text - * @param withText with text - * @return Button - */ - public static final CButton createHelpButton (boolean withText) - { - if (withText) - return createHelpButton(Msg.getMsg(Env.getCtx(), A_HELP)); - return createHelpButton(null); - } // createHelpButton - - - /************************ - * Create Export Button wlth label text - * @param text text - * @return Button - */ - public static final CButton createExportButton (String text) - { - AppsAction aa = new AppsAction (A_EXPORT, null, text); - CButton button = (CButton)aa.getButton(); - button.setMargin(s_insets); - return button; - } // createExportButton - - /** - * Create Export Button wlth Standard text - * @param withText with text - * @return Button - */ - public static final CButton createExportButton (boolean withText) - { - if (withText) - return createExportButton(Msg.getMsg(Env.getCtx(), A_EXPORT)); - return createExportButton(null); - } // createExportButton - - - /************************ - * Create Delete Button with label text - F3 - * @param text text - * @return Delete Button - */ - public static final CButton createDeleteButton (String text) - { - AppsAction aa = new AppsAction (A_DELETE, KeyStroke.getKeyStroke(KeyEvent.VK_F3, 0), text); - CButton button = (CButton)aa.getButton(); - button.setMargin(s_insets); - return button; - } // createDeleteButton - - /** - * Create Delete Button with Standard text - * @param withText with text - * @return Delete Button - */ - public static final CButton createDeleteButton (boolean withText) - { - if (withText) - return createDeleteButton(Msg.getMsg(Env.getCtx(), A_DELETE)); - return createDeleteButton(null); - } // createDeleteButton - - - /************************ - * Create Product Attribute Button with Standard text - * @param withText with text - * @return Product Attribute Button - */ - public static final CButton createPAttributeButton (boolean withText) - { - if (withText) - return createPAttributeButton(Msg.getMsg(Env.getCtx(), A_PATTRIBUTE)); - return createPAttributeButton(null); - } // createPAttributeButton - - /** - * Create Product Attribute Button with label text - * @param text text - * @return Product Attribute Button - */ - public static final CButton createPAttributeButton (String text) - { - AppsAction aa = new AppsAction (A_PATTRIBUTE, null, text); - CButton button = (CButton)aa.getButton(); - button.setMargin(s_insets); - return button; - } // createPAttributeButton - - - /************************ - * Create New Button with Standard text - * @param withText with text - * @return New Button - */ - public static final CButton createNewButton (boolean withText) - { - if (withText) - return createNewButton(Msg.getMsg(Env.getCtx(), A_NEW)); - return createNewButton(null); - } // createNewButton - - /** - * Create New Button with label text - F2 - * @param text text - * @return Product Attribute Button - */ - public static final CButton createNewButton (String text) - { - AppsAction aa = new AppsAction (A_NEW, KeyStroke.getKeyStroke(KeyEvent.VK_F2, 0), text); - CButton button = (CButton)aa.getButton(); - button.setMargin(s_insets); - return button; - } // createNewButton - - - /*************************************************************************/ - - /** Action String OK */ - public static final String A_OK = "Ok"; - /** Action String Cancel */ - public static final String A_CANCEL = "Cancel"; - /** Action String Refresh */ - public static final String A_REFRESH = "Refresh"; - /** Action String Reset */ - public static final String A_RESET = "Reset"; - /** Action String Customize */ - public static final String A_CUSTOMIZE = "Customize"; - /** Action String History */ - public static final String A_HISTORY = "History"; - /** Action String Zoom */ - public static final String A_ZOOM = "Zoom"; - - /** Action String Process */ - public static final String A_PROCESS = "Process"; - /** Action String Print */ - public static final String A_PRINT = "Print"; - /** Action String Export */ - public static final String A_EXPORT = "Export"; - /** Action String Help */ - public static final String A_HELP = "Help"; - /** Action String Delete */ - public static final String A_DELETE = "Delete"; - /** Action String PAttribute */ - public static final String A_PATTRIBUTE = "PAttribute"; - /** Action String New */ - public static final String A_NEW = "New"; - - /** Standard Insets used */ - public static Insets s_insets = new Insets (0, 10, 0, 10); - - - /************************************************************************** - * Create Confirmation Panel with OK Button - */ - public ConfirmPanel() - { - this (false, false, false, false, false, false, true); - } // ConfirmPanel - - /** - * Create Confirmation Panel with OK and Cancel Button - * @param withCancelButton with cancel - */ - public ConfirmPanel(boolean withCancelButton) - { - this (withCancelButton, false, false, false, false, false, true); - } // ConfirmPanel - - /** - * Create Confirmation Panel with different buttons - * @param withCancelButton with cancel - * @param withRefreshButton with refresh - * @param withResetButton with reset - * @param withCustomizeButton with customize - * @param withHistoryButton with history - * @param withZoomButton with zoom - * @param withText with text - */ - public ConfirmPanel(boolean withCancelButton, - boolean withRefreshButton, - boolean withResetButton, - boolean withCustomizeButton, - boolean withHistoryButton, - boolean withZoomButton, - boolean withText) - { - super(); - BorderLayout mainLayout = new BorderLayout(); - this.setLayout(mainLayout); - this.setName("confirmPanel"); - // - CPanel okCancel = new CPanel(new FlowLayout(FlowLayout.RIGHT)); - okCancel.setOpaque(false); - bCancel = createCancelButton(withText); - okCancel.add(bCancel); - bOK = createOKButton(withText); - okCancel.add(bOK); - setCancelVisible(withCancelButton); - this.add(okCancel, BorderLayout.EAST); - // - if (withRefreshButton) - { - bRefresh = createRefreshButton(withText); - addComponent(bRefresh); - } - if (withResetButton) - { - bReset = createResetButton(withText); - addComponent(bReset); - } - if (withCustomizeButton) - { - bCustomize = createCustomizeButton(withText); - addComponent(bCustomize); - } - if (withHistoryButton) - { - bHistory = createHistoryButton(withText); - addComponent(bHistory); - } - if (withZoomButton) - { - bZoom = createZoomButton(withText); - addComponent(bZoom); - } - } // ConfirmPanel - - /** Additional Buttons Panel */ - private CPanel m_addlButtons = null; - - private CButton bOK; - private CButton bCancel; - // - private CButton bRefresh; - private CButton bReset; - private CButton bCustomize; - private CButton bHistory; - private CButton bZoom; - - /** - * Add Button to left side of confirmPanel - * @param button button - */ - public void addComponent (Component button) - { - if (m_addlButtons == null) - { - m_addlButtons = new CPanel(new FlowLayout(FlowLayout.LEFT)); - this.add(m_addlButtons, BorderLayout.WEST); - } - m_addlButtons.add(button); - } // addButton - - /** - * Add Button to left side of confirmPanel - * @param action action command - * @param toolTipText tool tip text - * @param icon icon - * @return JButton - */ - public CButton addButton (String action, String toolTipText, Icon icon) - { - AppsAction aa = new AppsAction(action, null, toolTipText); - CButton b = (CButton)aa.getButton(); -// new DialogButton (action, toolTipText, icon); - addComponent (b); - return b; - } // addButton - - /** - * Add Button to left side of confirmPanel - * @param button button - * @return JButton - */ - public JButton addButton (JButton button) - { - addComponent (button); - return button; - } // addButton - - /** - * Get OK Button - * @return OK Button - */ - public CButton getOKButton() - { - return bOK; - } // getOKButton - - /** - * Get Cancel Button - * @return Cancel Button - */ - public CButton getCancelButton() - { - return bCancel; - } // getCancelButton - - /** - * Show OK button - * @param value true for visible - */ - public void setOKVisible (boolean value) - { - bOK.setVisible(value); - bOK.setEnabled(value); - } // setOKVisible - - /** - * Is OK Visible - * @return true of OK visisble - */ - public boolean isOKVisible() - { - return bOK.isVisible(); - } // isOKVisible - - /** - * Show Cancel button - * @param value trie for visible - */ - public void setCancelVisible (boolean value) - { - bCancel.setVisible(value); - bCancel.setEnabled(value); - } // setCancelVisible - - /** - * Is Cancel Visible - * @return true if Canvel is visible - */ - public boolean isCancelVisible() - { - return bCancel.isVisible(); - } // isCancelVisible - - /** - * Get Reset Button - * @return Button - */ - public CButton getResetButton() - { - return bReset; - } // getResetButton - - /** - * Get Customize Button - * @return Button - */ - public CButton getCustomizeButton() - { - return bCustomize; - } // getCustomizeButton - - /** - * Get History Button - * @return Button - */ - public CButton getHistoryButton() - { - return bHistory; - } // getHistoryButton - - /** - * Get Zoom Button - * @return Button - */ - public CButton getZoomButton() - { - return bZoom; - } // getZoomyButton - - /** - * Get Refresh Button - * @return Button - */ - public CButton getRefreshButton() - { - return bRefresh; - } // getRefreshButton - - - /************************************************************************** - * Add Action Listener - * - * if (e.getActionCommand().equals(ConfirmPanel.A_OK)) - * - * @param al listener - */ - public void addActionListener(ActionListener al) - { - ((AppsAction)bOK.getAction()).setDelegate(al); - ((AppsAction)bCancel.getAction()).setDelegate(al); - // - if (bRefresh != null) - ((AppsAction)bRefresh.getAction()).setDelegate(al); - if (bReset != null) - ((AppsAction)bReset.getAction()).setDelegate(al); - if (bCustomize != null) - ((AppsAction)bCustomize.getAction()).setDelegate(al); - if (bHistory != null) - ((AppsAction)bHistory.getAction()).setDelegate(al); - if (bZoom != null) - ((AppsAction)bZoom.getAction()).setDelegate(al); - - // Set OK as default Button - JRootPane rootpane = null; - if (al instanceof JDialog) - rootpane = ((JDialog)al).getRootPane(); - else if (al instanceof JFrame) - rootpane = ((JFrame)al).getRootPane(); - if (rootpane != null) - rootpane.setDefaultButton(bOK); - } // addActionListener - - /** - * Enable all components - * @param enabled trie if enabled - */ - public void setEnabled (boolean enabled) - { - super.setEnabled(enabled); - bOK.setEnabled(enabled); - bCancel.setEnabled(enabled); - // - if (bRefresh != null) - bRefresh.setEnabled(enabled); - if (bCustomize != null) - bCustomize.setEnabled(enabled); - if (bHistory != null) - bHistory.setEnabled(enabled); - if (bZoom != null) - bZoom.setEnabled(enabled); - } // setEnabled - -} // ConfirmPanel diff --git a/org.adempiere.ui.swing/src/org/compiere/apps/EMailDialog.java b/org.adempiere.ui.swing/src/org/compiere/apps/EMailDialog.java deleted file mode 100644 index 0be289d9df..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/apps/EMailDialog.java +++ /dev/null @@ -1,474 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - * Contributor(s): * - *****************************************************************************/ -package org.compiere.apps; - -import java.awt.BorderLayout; -import java.awt.Cursor; -import java.awt.Dialog; -import java.awt.Dimension; -import java.awt.Frame; -import java.awt.GridBagConstraints; -import java.awt.GridBagLayout; -import java.awt.Insets; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.beans.PropertyChangeEvent; -import java.beans.PropertyVetoException; -import java.beans.VetoableChangeListener; -import java.io.File; -import java.util.StringTokenizer; -import java.util.logging.Level; - -import org.compiere.grid.ed.VLookup; -import org.compiere.model.Lookup; -import org.compiere.model.MClient; -import org.compiere.model.MLookupFactory; -import org.compiere.model.MUser; -import org.compiere.model.MUserMail; -import org.compiere.swing.CDialog; -import org.compiere.swing.CLabel; -import org.compiere.swing.CPanel; -import org.compiere.swing.CTextArea; -import org.compiere.swing.CTextField; -import org.compiere.util.CLogger; -import org.compiere.util.DisplayType; -import org.compiere.util.EMail; -import org.compiere.util.Env; -import org.compiere.util.Msg; - -/** - * EMail Dialog - * - * @author Jorg Janke - * @version $Id: EMailDialog.java,v 1.2 2006/07/30 00:51:27 jjanke Exp $ - * - * globalqss: integrate phib fixing bug reported here - * http://sourceforge.net/tracker/index.php?func=detail&aid=1568765&group_id=176962&atid=879332 - * - * phib - fixing bug [ 1568765 ] Close email dialog button broken - * - * globalqss - Carlos Ruiz - implement CC - FR [ 1754879 ] Enhancements on sending e-mail - * - */ -public class EMailDialog extends CDialog - implements ActionListener, VetoableChangeListener -{ - /** - * - */ - private static final long serialVersionUID = -6850428309037475213L; - - /** - * EMail Dialog - * @param owner calling window - * @param title title - * @param from from - * @param to to - * @param subject subject - * @param message message - * @param attachment optional attachment - */ - public EMailDialog (Dialog owner, String title, MUser from, String to, - String subject, String message, File attachment) - { - super (owner, title, true); - commonInit(from, to, subject, message, attachment); - } // EmailDialog - - /** - * EMail Dialog - * @param owner calling window - * @param title title - * @param from from - * @param to to - * @param subject subject - * @param message message - * @param attachment optional attachment - */ - public EMailDialog (Frame owner, String title, MUser from, String to, - String subject, String message, File attachment) - { - super (owner, title, true); - commonInit(from, to, subject, message, attachment); - } // EmailDialog - - /** - * Common Init - * @param from from - * @param to to - * @param subject subject - * @param message message - * @param attachment optional attachment - */ - private void commonInit (MUser from, String to, - String subject, String message, File attachment) - { - m_client = MClient.get(Env.getCtx()); - try - { - int WindowNo = 0; - int AD_Column_ID = 0; - Lookup lookup = MLookupFactory.get (Env.getCtx(), WindowNo, - AD_Column_ID, DisplayType.Search, - Env.getLanguage(Env.getCtx()), "AD_User_ID", 0, false, - "EMail IS NOT NULL"); - fUser = new VLookup ("AD_User_ID", false, false, true, lookup); - fUser.addVetoableChangeListener(this); - fCcUser = new VLookup ("AD_User_ID", false, false, true, lookup); - fCcUser.addVetoableChangeListener(this); - jbInit(); - } - catch(Exception ex) - { - log.log(Level.SEVERE, "EMailDialog", ex); - } - set(from, to, subject, message); - setAttachment(attachment); - AEnv.showCenterScreen(this); - } // commonInit - - - /** Client */ - private MClient m_client = null; - /** Sender */ - private MUser m_from = null; - /** Primary Recipient */ - private MUser m_user = null; - /** Cc Recipient */ - private MUser m_ccuser = null; - // - private String m_to; - private String m_cc; - private String m_subject; - private String m_message; - /** File to be optionally attached */ - private File m_attachFile; - /** Logger */ - private static CLogger log = CLogger.getCLogger(EMailDialog.class); - - private CPanel mainPanel = new CPanel(); - private BorderLayout mainLayout = new BorderLayout(); - private CPanel headerPanel = new CPanel(); - private GridBagLayout headerLayout = new GridBagLayout(); - private CTextField fFrom = new CTextField(20); - private CTextField fTo = new CTextField(20); - private CTextField fCc = new CTextField(20); - private VLookup fUser = null; - private VLookup fCcUser = null; - private CTextField fSubject = new CTextField(40); - private CLabel lFrom = new CLabel(); - private CLabel lTo = new CLabel(); - private CLabel lCc = new CLabel(); - private CLabel lSubject = new CLabel(); - private CLabel lAttachment = new CLabel(); - private CTextField fAttachment = new CTextField(40); - private CTextArea fMessage = new CTextArea(); - private ConfirmPanel confirmPanel = new ConfirmPanel(true); - private StatusBar statusBar = new StatusBar(); - - /** - * Static Init - */ - void jbInit() throws Exception - { - lFrom.setText(Msg.getMsg(Env.getCtx(), "From") + ":"); - lTo.setText(Msg.getMsg(Env.getCtx(), "To") + ":"); - lCc.setText(Msg.getMsg(Env.getCtx(), "Cc") + ":"); - lSubject.setText(Msg.getMsg(Env.getCtx(), "Subject") + ":"); - lAttachment.setText(Msg.getMsg(Env.getCtx(), "Attachment") + ":"); - fFrom.setReadWrite(false); - // - mainPanel.setLayout(mainLayout); - headerPanel.setLayout(headerLayout); - mainLayout.setHgap(5); - mainLayout.setVgap(5); - fMessage.setPreferredSize(new Dimension(150, 150)); - getContentPane().add(mainPanel); - mainPanel.add(headerPanel, BorderLayout.NORTH); - - headerPanel.add(lFrom, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 10, 0, 5), 0, 0)); - headerPanel.add(fFrom, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 0, 5, 10), 0, 0)); - - headerPanel.add(lTo, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 10, 0, 5), 0, 0)); - headerPanel.add(fUser, new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 10), 0, 0)); - headerPanel.add(fTo, new GridBagConstraints(1, 2, 1, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 10), 0, 0)); - headerPanel.add(lCc, new GridBagConstraints(0, 3, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 10, 0, 5), 0, 0)); - headerPanel.add(fCcUser, new GridBagConstraints(1, 3, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 10), 0, 0)); - headerPanel.add(fCc, new GridBagConstraints(1, 4, 1, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 10), 0, 0)); - - headerPanel.add(lSubject, new GridBagConstraints(0, 6, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 10, 0, 5), 0, 0)); - headerPanel.add(fSubject, new GridBagConstraints(1, 6, 1, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 0, 0, 10), 1, 0)); - - headerPanel.add(lAttachment, new GridBagConstraints(0, 7, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 10, 0, 5), 0, 0)); - headerPanel.add(fAttachment, new GridBagConstraints(1, 7, 1, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 0, 0, 10), 1, 0)); - - mainPanel.add(fMessage, BorderLayout.CENTER); - // - mainPanel.add (confirmPanel, BorderLayout.SOUTH); - this.getContentPane().add(statusBar, BorderLayout.SOUTH); - confirmPanel.addActionListener(this); - statusBar.setStatusDB(null); - } // jbInit - - /** - * Set all properties - */ - public void set (MUser from, String to, String subject, String message) - { - // Content - setFrom(from); - setTo(to); - setSubject(subject); - setMessage(message); - // - statusBar.setStatusLine(m_client.getSMTPHost()); - } // set - - /** - * Set Address - */ - public void setTo(String newTo) - { - m_to = newTo; - fTo.setText(m_to); - } // setTo - - /** - * Set CC Address - */ - public void setCc(String newCc) - { - m_cc = newCc; - fCc.setText(m_cc); - } // setCc - - /** - * Get Address - */ - public String getTo() - { - m_to = fTo.getText(); - return m_to; - } // getTo - - /** - * Get CC Address - */ - public String getCc() - { - m_cc = fCc.getText(); - return m_cc; - } // getCc - - /** - * Set Sender - */ - public void setFrom(MUser newFrom) - { - m_from = newFrom; - if (newFrom == null - || !newFrom.isEMailValid() - || !newFrom.isCanSendEMail()) - { - confirmPanel.getOKButton().setEnabled(false); - fFrom.setText("**Invalid**"); - } - else - fFrom.setText(m_from.getEMail()); - } // setFrom - - /** - * Get Sender - */ - public MUser getFrom() - { - return m_from; - } // getFrom - - /** - * Set Subject - */ - public void setSubject(String newSubject) - { - m_subject = newSubject; - fSubject.setText(m_subject); - } // setSubject - - /** - * Get Subject - */ - public String getSubject() - { - m_subject = fSubject.getText(); - return m_subject; - } // getSubject - - /** - * Set Message - */ - public void setMessage(String newMessage) - { - m_message = newMessage; - fMessage.setText(m_message); - fMessage.setCaretPosition(0); - } // setMessage - - /** - * Get Message - */ - public String getMessage() - { - m_message = fMessage.getText(); - return m_message; - } // getMessage - - /** - * Set Attachment - */ - public void setAttachment (File attachment) - { - m_attachFile = attachment; - if (attachment == null) - { - lAttachment.setVisible(false); - fAttachment.setVisible(false); - } - else - { - lAttachment.setVisible(true); - fAttachment.setVisible(true); - fAttachment.setText(attachment.getName()); - fAttachment.setReadWrite(false); - } - } // setAttachment - - /** - * Get Attachment - */ - public File getAttachment() - { - return m_attachFile; - } // getAttachment - - /************************************************************************** - * Action Listener - Send email - */ - public void actionPerformed(ActionEvent e) - { - if (e.getActionCommand().equals(ConfirmPanel.A_CANCEL)) - dispose(); - - if (getTo() == null || getTo().length() == 0) - { - return; - } - // Send - if (e.getActionCommand().equals(ConfirmPanel.A_OK)) - { - setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); - confirmPanel.getOKButton().setEnabled(false); - - StringTokenizer st = new StringTokenizer(getTo(), " ,;", false); - String to = st.nextToken(); - EMail email = m_client.createEMail(getFrom(), to, getSubject(), getMessage()); - String status = "Check Setup"; - if (email != null) - { - while (st.hasMoreTokens()) - email.addTo(st.nextToken()); - // cc - StringTokenizer stcc = new StringTokenizer(getCc(), " ,;", false); - while (stcc.hasMoreTokens()) - { - String cc = stcc.nextToken(); - if (cc != null && cc.length() > 0) - email.addCc(cc); - } - // Attachment - if (m_attachFile != null && m_attachFile.exists()) - email.addAttachment(m_attachFile); - status = email.send(); - // - if (m_user != null) - new MUserMail(m_user, m_user.getAD_User_ID(), email).saveEx(); - if (email.isSentOK()) - { - ADialog.info(0, this, "MessageSent"); - dispose(); - } - else - ADialog.error(0, this, "MessageNotSent", status); - } - else - ADialog.error(0, this, "MessageNotSent", status); - // - confirmPanel.getOKButton().setEnabled(false); - setCursor(Cursor.getDefaultCursor()); - } - else if (e.getActionCommand().equals(ConfirmPanel.A_CANCEL)) - dispose(); - - } // actionPerformed - - /** - * Vetoable Change - User selected - * @param evt - * @throws PropertyVetoException - */ - public void vetoableChange (PropertyChangeEvent evt) - throws PropertyVetoException - { - VLookup source = (VLookup) evt.getSource(); - Object value = evt.getNewValue(); - if (log.isLoggable(Level.INFO)) log.info("Value=" + value); - if (source.equals(fUser)) { - // fUser - if (value == null) - fTo.setText(""); - if (value instanceof Integer) - { - int AD_User_ID = ((Integer)value).intValue(); - m_user = MUser.get(Env.getCtx(), AD_User_ID); - fTo.setValue(m_user.getEMail()); - } - } else { - // fCcUser - if (value == null) - fCc.setText(""); - if (value instanceof Integer) - { - int AD_User_ID = ((Integer)value).intValue(); - m_ccuser = MUser.get(Env.getCtx(), AD_User_ID); - fCc.setValue(m_ccuser.getEMail()); - } - } - } // vetoableChange - -} // VEMailDialog \ No newline at end of file diff --git a/org.adempiere.ui.swing/src/org/compiere/apps/FieldRecordInfo.java b/org.adempiere.ui.swing/src/org/compiere/apps/FieldRecordInfo.java deleted file mode 100644 index d5723d555b..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/apps/FieldRecordInfo.java +++ /dev/null @@ -1,362 +0,0 @@ -/****************************************************************************** - * Copyright (C) 2009 Low Heng Sin * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * * - * @sponsor www.metas.de * - *****************************************************************************/ -package org.compiere.apps; - -import java.awt.BorderLayout; -import java.awt.Dimension; -import java.awt.Frame; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.math.BigDecimal; -import java.sql.PreparedStatement; -import java.sql.ResultSet; -import java.sql.Timestamp; -import java.text.DecimalFormat; -import java.text.SimpleDateFormat; -import java.util.Vector; -import java.util.logging.Level; - -import javax.swing.Icon; -import javax.swing.ImageIcon; -import javax.swing.JPopupMenu; -import javax.swing.table.DefaultTableModel; - -import org.compiere.grid.VTable; -import org.compiere.model.GridField; -import org.compiere.model.MChangeLog; -import org.compiere.model.MColumn; -import org.compiere.model.MLookup; -import org.compiere.model.MLookupFactory; -import org.compiere.model.MRole; -import org.compiere.model.MTable; -import org.compiere.model.MUser; -import org.compiere.swing.CDialog; -import org.compiere.swing.CMenuItem; -import org.compiere.swing.CPanel; -import org.compiere.swing.CScrollPane; -import org.compiere.util.CLogger; -import org.compiere.util.DB; -import org.compiere.util.DisplayType; -import org.compiere.util.Env; -import org.compiere.util.Msg; -import org.compiere.util.NamePair; - -/** - * Change History for field - * @author Heng Sin Low - */ -public class FieldRecordInfo extends CDialog -{ - private static final long serialVersionUID = -2860082302140462690L; - - public static final String CHANGE_LOG_COMMAND = "ChangeLog"; - /** The Menu Icon */ - private static Icon s_icon = new ImageIcon(org.compiere.Adempiere.getResource("images/ChangeLog16.png")); - - private int AD_Table_ID; - private int AD_Column_ID; - private int Record_ID; - - /** - * Record Info - * @param owner owner - * @param title title - * @param AD_Table_ID - * @param AD_Column_ID - * @param Record_ID - */ - public FieldRecordInfo (Frame owner, String title, int AD_Table_ID, int AD_Column_ID, int Record_ID) - { - super (owner, title, true); - - this.AD_Table_ID = AD_Table_ID; - this.AD_Column_ID = AD_Column_ID; - this.Record_ID = Record_ID; - - try - { - jbInit ( dynInit(title) ); - } - catch (Exception e) - { - log.log(Level.SEVERE, "", e); - } - this.setPreferredSize(new Dimension(640, 480)); - AEnv.positionCenterWindow (owner, this); - AEnv.showCenterScreen(this); - } // FieldRecordInfo - - - private CPanel mainPanel = new CPanel (new BorderLayout(0,0)); - private CScrollPane scrollPane = new CScrollPane (); - private VTable table = new VTable (); - private ConfirmPanel confirmPanel = new ConfirmPanel (false); - - /** Logger */ - protected CLogger log = CLogger.getCLogger(getClass()); - /** The Data */ - private Vector> m_data = new Vector>(); - - /** Date Time Format */ - private SimpleDateFormat m_dateTimeFormat = DisplayType.getDateFormat - (DisplayType.DateTime, Env.getLanguage(Env.getCtx())); - /** Date Format */ - private SimpleDateFormat m_dateFormat = DisplayType.getDateFormat - (DisplayType.DateTime, Env.getLanguage(Env.getCtx())); - /** Number Format */ - private DecimalFormat m_numberFormat = DisplayType.getNumberFormat - (DisplayType.Number, Env.getLanguage(Env.getCtx())); - /** Amount Format */ - private DecimalFormat m_amtFormat = DisplayType.getNumberFormat - (DisplayType.Amount, Env.getLanguage(Env.getCtx())); - /** Number Format */ - private DecimalFormat m_intFormat = DisplayType.getNumberFormat - (DisplayType.Integer, Env.getLanguage(Env.getCtx())); - - /** - * Static Layout - * @throws Exception - */ - private void jbInit (boolean showTable) throws Exception - { - getContentPane().add(mainPanel); - // - if (showTable) - { - mainPanel.add (scrollPane, BorderLayout.CENTER); - scrollPane.getViewport().add(table); - scrollPane.setPreferredSize(new Dimension(500,100)); - } - // - mainPanel.add (confirmPanel, BorderLayout.SOUTH); - confirmPanel.addActionListener(this); - } // jbInit - - - /** - * Dynamic Init - * @param title title - * @return true if table initialized - */ - private boolean dynInit(String title) - { - // Title - if (AD_Table_ID != 0) - { - MTable table1 = MTable.get (Env.getCtx(), AD_Table_ID); - setTitle(title + " - " + table1.getName()); - } - - // Only Client Preference can view Change Log - if (!MRole.PREFERENCETYPE_Client.equals(MRole.getDefault().getPreferenceType())) - return false; - - if (Record_ID == 0) - return false; - - // Data - String sql = "SELECT AD_Column_ID, Updated, UpdatedBy, OldValue, NewValue " - + "FROM AD_ChangeLog " - + "WHERE AD_Table_ID=? AND Record_ID=? AND AD_Column_ID=?" - + "ORDER BY Updated DESC"; - PreparedStatement pstmt = null; - ResultSet rs = null; - try - { - pstmt = DB.prepareStatement (sql, null); - pstmt.setInt (1, AD_Table_ID); - pstmt.setInt (2, Record_ID); - pstmt.setInt (3, AD_Column_ID); - rs = pstmt.executeQuery (); - while (rs.next ()) - { - addLine (rs.getInt(1), rs.getTimestamp(2), rs.getInt(3), - rs.getString(4), rs.getString(5)); - } - } - catch (Exception e) - { - log.log(Level.SEVERE, sql, e); - } - finally - { - DB.close(rs, pstmt); - } - - // - Vector columnNames = new Vector(); - columnNames.add(Msg.translate(Env.getCtx(), "NewValue")); - columnNames.add(Msg.translate(Env.getCtx(), "OldValue")); - columnNames.add(Msg.translate(Env.getCtx(), "UpdatedBy")); - columnNames.add(Msg.translate(Env.getCtx(), "Updated")); - DefaultTableModel model = new DefaultTableModel(m_data, columnNames); - table.setModel(model); - table.autoSize(false); - return true; - } // dynInit - - /** - * Add Line - * @param AD_Column_ID column - * @param Updated updated - * @param UpdatedBy user - * @param OldValue old - * @param NewValue new - */ - private void addLine (int AD_Column_ID, Timestamp Updated, int UpdatedBy, - String OldValue, String NewValue) - { - Vector line = new Vector(); - // Column - MColumn column = MColumn.get (Env.getCtx(), AD_Column_ID); - // - if (OldValue != null && OldValue.equals(MChangeLog.NULL)) - OldValue = null; - String showOldValue = OldValue; - if (NewValue != null && NewValue.equals(MChangeLog.NULL)) - NewValue = null; - String showNewValue = NewValue; - // - try - { - if (DisplayType.isText (column.getAD_Reference_ID ())) - ; - else if (column.getAD_Reference_ID() == DisplayType.YesNo) - { - if (OldValue != null) - { - boolean yes = OldValue.equals("true") || OldValue.equals("Y"); - showOldValue = Msg.getMsg(Env.getCtx(), yes ? "Y" : "N"); - } - if (NewValue != null) - { - boolean yes = NewValue.equals("true") || NewValue.equals("Y"); - showNewValue = Msg.getMsg(Env.getCtx(), yes ? "Y" : "N"); - } - } - else if (column.getAD_Reference_ID() == DisplayType.Amount) - { - if (OldValue != null) - showOldValue = m_amtFormat - .format (new BigDecimal (OldValue)); - if (NewValue != null) - showNewValue = m_amtFormat - .format (new BigDecimal (NewValue)); - } - else if (column.getAD_Reference_ID() == DisplayType.Integer) - { - if (OldValue != null) - showOldValue = m_intFormat.format (Integer.valueOf(OldValue)); - if (NewValue != null) - showNewValue = m_intFormat.format (Integer.valueOf(NewValue)); - } - else if (DisplayType.isNumeric (column.getAD_Reference_ID ())) - { - if (OldValue != null) - showOldValue = m_numberFormat.format (new BigDecimal (OldValue)); - if (NewValue != null) - showNewValue = m_numberFormat.format (new BigDecimal (NewValue)); - } - else if (column.getAD_Reference_ID() == DisplayType.Date) - { - if (OldValue != null) - showOldValue = m_dateFormat.format (Timestamp.valueOf (OldValue)); - if (NewValue != null) - showNewValue = m_dateFormat.format (Timestamp.valueOf (NewValue)); - } - else if (column.getAD_Reference_ID() == DisplayType.DateTime) - { - if (OldValue != null) - showOldValue = m_dateTimeFormat.format (Timestamp.valueOf (OldValue)); - if (NewValue != null) - showNewValue = m_dateTimeFormat.format (Timestamp.valueOf (NewValue)); - } - else if (DisplayType.isLookup(column.getAD_Reference_ID ())) - { - MLookup lookup = MLookupFactory.get (Env.getCtx(), 0, - AD_Column_ID, column.getAD_Reference_ID(), - Env.getLanguage(Env.getCtx()), column.getColumnName(), - column.getAD_Reference_Value_ID(), - column.isParent(), null); - if (OldValue != null) - { - Object key = OldValue; - NamePair pp = lookup.get(key); - if (pp != null) - showOldValue = pp.getName(); - } - if (NewValue != null) - { - Object key = NewValue; - NamePair pp = lookup.get(key); - if (pp != null) - showNewValue = pp.getName(); - } - } - else if (DisplayType.isLOB (column.getAD_Reference_ID ())) - ; - } - catch (Exception e) - { - log.log(Level.WARNING, OldValue + "->" + NewValue, e); - } - // - line.add(showNewValue); - line.add(showOldValue); - // UpdatedBy - MUser user = MUser.get(Env.getCtx(), UpdatedBy); - line.add(user.getName()); - // Updated - line.add(m_dateFormat.format(Updated)); - - m_data.add(line); - } // addLine - - - /** - * ActionListener - * @param e event - */ - public void actionPerformed(ActionEvent e) - { - dispose(); - } // actionPerformed - - /** - * Add change log menu item - * @param l - * @param popupMenu - * @return CMenuItem - */ - public static CMenuItem addMenu (ActionListener l, JPopupMenu popupMenu) - { - CMenuItem mi = new CMenuItem (Msg.getElement(Env.getCtx(), "AD_ChangeLog_ID"), s_icon); - mi.setActionCommand(CHANGE_LOG_COMMAND); - mi.addActionListener(l); - popupMenu.add(mi); - return mi; - } // addMenu - - /** - * Open field record info dialog - * @param mField - */ - public static void start(GridField mField) { - int WindowNo = mField.getWindowNo(); - Frame frame = AEnv.getWindow(WindowNo); - new FieldRecordInfo(frame, mField.getColumnName(), mField.getGridTab().getAD_Table_ID(), - mField.getAD_Column_ID(), mField.getGridTab().getRecord_ID()); - } -} // FieldRecordInfo diff --git a/org.adempiere.ui.swing/src/org/compiere/apps/GroovyEditor.java b/org.adempiere.ui.swing/src/org/compiere/apps/GroovyEditor.java deleted file mode 100644 index d3c81c9a5c..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/apps/GroovyEditor.java +++ /dev/null @@ -1,295 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 2008 Low Heng Sin. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - *****************************************************************************/ -package org.compiere.apps; - -import groovy.lang.GroovyShell; -import groovy.ui.ConsoleTextEditor; - -import java.awt.BorderLayout; -import java.awt.Color; -import java.awt.Dimension; -import java.awt.FlowLayout; -import java.awt.Frame; -import java.awt.GridBagConstraints; -import java.awt.GridBagLayout; -import java.awt.Insets; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.util.logging.Level; - -import javax.swing.BorderFactory; -import javax.swing.JButton; -import javax.swing.JFrame; -import javax.swing.JLabel; -import javax.swing.JScrollPane; -import javax.swing.JTextField; -import javax.swing.border.TitledBorder; - -import org.compiere.model.MUser; -import org.compiere.swing.CDialog; -import org.compiere.swing.CPanel; -import org.compiere.util.CLogger; -import org.compiere.util.Env; -import org.compiere.util.Msg; - -/** - * Groovy script Editor - * - * @author Low Heng Sin - */ -public class GroovyEditor extends CDialog implements ActionListener -{ - /** - * - */ - private static final long serialVersionUID = 2941209813417292930L; - @SuppressWarnings("unused") - private Frame m_owner; - - /** - * Minimum Constructor - */ - public GroovyEditor() - { - this (Msg.getMsg(Env.getCtx(), "Script"), null, 0); - } // ScriptEditor - - /** - * Minimum Constructor - */ - public GroovyEditor(Frame owner) - { - this (owner, Msg.getMsg(Env.getCtx(), "Script"), null, 0); - } // ScriptEditor - - /** - * Constructor - * - * @param title Field Name - * @param script The Script - */ - public GroovyEditor (String title, String script, int WindowNo) - { - this(null, title, script, WindowNo); - } - - /** - * Constructor - * - * @param owner Owner frame - * @param title Field Name - * @param script The Script - */ - public GroovyEditor (Frame owner, String title, String script, int WindowNo) - { - super(owner); - setTitle(title); - if (owner != null) - { - setModal(true); - } - m_owner = owner; - m_WindowNo = WindowNo; - if (m_WindowNo == 0) - m_WindowNo = AEnv.createWindowNo(this); - if (log.isLoggable(Level.INFO)) log.info("Window=" + m_WindowNo); - try - { - jbInit(); - setScript (script); - dynInit(); - AEnv.showCenterScreen(this); - toFront(); - } - catch(Exception ex) - { - log.log(Level.SEVERE, "", ex); - } - } // ScriptEditor - - /** The Script */ - private String m_script; - /** WindowNo */ - private int m_WindowNo; - /** Original Script */ - private String m_origScript; - /** Logger */ - private static CLogger log = CLogger.getCLogger(GroovyEditor.class); - // -- - - private CPanel mainPanel = new CPanel(); - private BorderLayout borderLayout1 = new BorderLayout(); - private JScrollPane editorPane = new JScrollPane(); - private ConsoleTextEditor editor = new ConsoleTextEditor(); - private TitledBorder titledBorder2; - private CPanel southPanel = new CPanel(); - private BorderLayout southLayout = new BorderLayout(); - private CPanel okPanel = new CPanel(); - private JButton bOK = ConfirmPanel.createOKButton(true); - private JButton bCancel = ConfirmPanel.createCancelButton(true); - private CPanel resultPanel = new CPanel(); - private JButton bProcess = ConfirmPanel.createProcessButton(true); - private JButton bHelp = ConfirmPanel.createHelpButton(true); - private JLabel lResult = new JLabel(); - private JTextField fResult = new JTextField(); - private FlowLayout okLayout = new FlowLayout(); - private GridBagLayout resultLayout = new GridBagLayout(); - - /** - * Static Layout - * @throws Exception - */ - void jbInit() throws Exception - { - this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); - titledBorder2 = new TitledBorder(BorderFactory.createEtchedBorder(Color.white,new Color(148, 145, 140)), - Msg.getMsg(Env.getCtx(), "ScriptEditor")); - mainPanel.setLayout(borderLayout1); - bOK.addActionListener(this); - bCancel.addActionListener(this); - bProcess.addActionListener(this); - bHelp.addActionListener(this); - editorPane.setBorder(titledBorder2); - editorPane.setPreferredSize(new Dimension(500, 500)); - southPanel.setLayout(southLayout); - resultPanel.setLayout(resultLayout); - lResult.setText(Msg.getMsg(Env.getCtx(), "ScriptResult")); - fResult.setBackground(Color.lightGray); - fResult.setEditable(false); - fResult.setText(""); - okPanel.setLayout(okLayout); - getContentPane().add(mainPanel); - editorPane.getViewport().add(editor, null); - mainPanel.add(southPanel, BorderLayout.SOUTH); - southPanel.add(okPanel, BorderLayout.EAST); - okPanel.add(bCancel, null); - okPanel.add(bOK, null); - southPanel.add(resultPanel, BorderLayout.CENTER); - resultPanel.add(bProcess, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); - resultPanel.add(lResult, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); - resultPanel.add(fResult, new GridBagConstraints(2, 0, 1, 1, 1.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5), 0, 0)); - resultPanel.add(bHelp, new GridBagConstraints(3, 0, 1, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); - mainPanel.add(editorPane, BorderLayout.CENTER); - } // jbInit - - /** - * Set Script - * @param script The Script - */ - public void setScript (String script) - { - if (script == null) - m_script = ""; - else - m_script = script; - // - m_origScript = m_script; - editor.getTextEditor().setText(m_script); - } // setScript - - /** - * Dynamic Init - */ - private void dynInit() - { - - } // dynInit - - - /** - * Action Listener - * @param e - */ - public void actionPerformed(ActionEvent e) - { - if (e.getSource() == bOK) - { - m_script = editor.getTextEditor().getText(); - dispose(); - } - else if (e.getSource() == bCancel) - { - m_script = m_origScript; - dispose(); - } - - else if (e.getSource() == bProcess) - actionProcess(); - else if (e.getSource() == bHelp) - { - Help h = new Help (this , - Msg.getMsg(Env.getCtx(), "ScriptHelp"), - getClass().getResource("Script.html")); - h.setVisible(true); - } - } // actionPerformed - - /** - * Process Script - */ - private void actionProcess() - { - MUser user = MUser.get(Env.getCtx()); - if (!user.isAdministrator()) - { - fResult.setText("Not Administrator"); - return; - } - // - GroovyShell sh = new GroovyShell(); - Exception e = null; - try { - sh.parse(editor.getTextEditor().getText()); - } catch (Exception e1) { - e = e1; - } - if (e != null) - { - ADialog.error(m_WindowNo, this, "ScriptError", e.toString()); - fResult.setText("Syntax errors detected."); - } - else - fResult.setText("No syntax errors detected."); - } // actionProcess - - /*************************************************************************/ - - /** - * Start ScriptEditor - * - * @param owner - * @param header Title - * @param script ScriptCode - * @param editable - * @return updated Script - */ - public static String start (Frame owner, String header, String script, boolean editable, int WindowNo) - { - GroovyEditor se = new GroovyEditor (owner, header, script, WindowNo); - return se.getScript(); - } // start - - /*** - * - * @return string - */ - public String getScript() { - return m_script; - } - -} // ScriptEditor diff --git a/org.adempiere.ui.swing/src/org/compiere/apps/Help.java b/org.adempiere.ui.swing/src/org/compiere/apps/Help.java deleted file mode 100644 index 12d638de3b..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/apps/Help.java +++ /dev/null @@ -1,200 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ -package org.compiere.apps; - -import java.awt.BorderLayout; -import java.awt.Dimension; -import java.awt.Frame; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.net.URL; -import java.util.logging.Level; - -import javax.swing.BorderFactory; -import javax.swing.JDialog; -import javax.swing.JScrollPane; -import javax.swing.text.html.HTMLDocument; - -import org.adempiere.plaf.AdempierePLAF; -import org.compiere.model.GridWindow; -import org.compiere.swing.CDialog; -import org.compiere.swing.CPanel; -import org.compiere.util.CLogger; -import org.compiere.util.WebDoc; - -/** - * Help and HTML Window - * - * @author Jorg Janke - * @version $Id: Help.java,v 1.3 2006/07/30 00:51:27 jjanke Exp $ - * - * @author Teo Sarca - BF [ 1747741 ] - */ -public class Help extends CDialog - implements ActionListener -{ - /** - * - */ - private static final long serialVersionUID = 2840473201179240876L; - - /** - * Help System for Window Help - * - * @param frame Parent - * @param title Title - * @param mWindow Window Model - */ - public Help (Frame frame, String title, GridWindow mWindow) - { - super(frame, title, false); - try - { - jbInit(); - loadInfo(mWindow); - } - catch(Exception ex) - { - log.log(Level.SEVERE, "", ex); - } - AEnv.positionCenterWindow(frame, this); - } // Help - - /** - * Help System - * - * @param frame Parent - * @param title Window - * @param url URL to display - */ - public Help (Frame frame, String title, URL url) - { - super(frame, title, false); - try - { - jbInit(); - info.setPage(url); - } - catch(Exception ex) - { - log.log(Level.SEVERE, "", ex); - } - AEnv.positionCenterWindow(frame, this); - } // Help - - /** - * Help System - * - * @param dialog Parent - * @param title Window - * @param url URL to display - */ - public Help (JDialog dialog, String title, URL url) - { - super(dialog, title, false); - try - { - jbInit(); - info.setPage(url); - } - catch(Exception ex) - { - log.log(Level.SEVERE, "", ex); - } - AEnv.positionCenterWindow(dialog, this); - } // Help - - /** - * Help System - * - * @param frame Parent - * @param title Window - * @param helpHtml Helptext - */ - public Help (Frame frame, String title, String helpHtml) - { - super(frame, title, false); - try - { - jbInit(); - info.setContentType("text/html"); - info.setEditable(false); - info.setBackground(AdempierePLAF.getFieldBackground_Inactive()); - info.setText(helpHtml); - } - catch(Exception ex) - { - log.log(Level.SEVERE, "Help", ex); - } - AEnv.positionCenterWindow(frame, this); - } // Help - - /** Logger */ - private static CLogger log = CLogger.getCLogger(Help.class); - - private CPanel mainPanel = new CPanel(); - private BorderLayout mainLayout = new BorderLayout(); - private OnlineHelp info = new OnlineHelp(); - private JScrollPane infoPane = new JScrollPane(); - private ConfirmPanel confirmPanel = new ConfirmPanel(); - - /** - * Static Init - * - * @throws Exception - */ - void jbInit() throws Exception - { - mainPanel.setLayout(mainLayout); - mainLayout.setHgap(2); - mainLayout.setVgap(2); - infoPane.setBorder(BorderFactory.createLoweredBevelBorder()); - infoPane.setPreferredSize(new Dimension(500, 400)); - getContentPane().add(mainPanel); - mainPanel.add(infoPane, BorderLayout.CENTER); - mainPanel.add(confirmPanel, BorderLayout.SOUTH); - infoPane.getViewport().add(info, null); - confirmPanel.addActionListener(this); - } // jbInit - - - /************************************************************************* - * Load Info - Windows Help - * @param mWindow window model - */ - private void loadInfo(GridWindow mWindow) - { - WebDoc doc = mWindow.getHelpDoc(true); - HTMLDocument htmlDoc = (HTMLDocument)info.getEditorKit().createDefaultDocument(); - htmlDoc.getDocumentProperties().put("IgnoreCharsetDirective", true); - info.setDocument(htmlDoc); - info.setText(doc.toString()); - } // loadInfo - - - /************************************************************************** - * Action Listener - * @param e event - */ - public void actionPerformed(ActionEvent e) - { - if (e.getActionCommand().equals(ConfirmPanel.A_OK)) - dispose(); - } // actionPerformed - -} // Help - diff --git a/org.adempiere.ui.swing/src/org/compiere/apps/OnlineHelp.java b/org.adempiere.ui.swing/src/org/compiere/apps/OnlineHelp.java deleted file mode 100644 index 7d25c265c7..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/apps/OnlineHelp.java +++ /dev/null @@ -1,358 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - * Contributor: Carlos Ruiz - globalqss * - *****************************************************************************/ -package org.compiere.apps; - -import java.awt.Color; -import java.awt.Cursor; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.net.ConnectException; -import java.net.URL; -import java.net.URLConnection; -import java.net.UnknownHostException; -import java.util.Enumeration; -import java.util.HashMap; - -import javax.swing.JEditorPane; -import javax.swing.event.HyperlinkEvent; -import javax.swing.event.HyperlinkListener; -import javax.swing.text.AttributeSet; -import javax.swing.text.html.HTML; -import javax.swing.text.html.HTMLDocument; -import javax.swing.text.html.HTMLEditorKit; -import javax.swing.text.html.HTMLFrameHyperlinkEvent; - -import org.adempiere.plaf.AdempierePLAF; -import org.compiere.util.Env; - -/** - * Online Help Browser & Link. - * - * @author Jorg Janke - * @version $Id: OnlineHelp.java,v 1.2 2006/07/30 00:51:27 jjanke Exp $ - * - * globalqss: fix error about null pointer in OnlineHelp.Worker.run - * change the URL for online help for connection - */ -public class OnlineHelp extends JEditorPane implements HyperlinkListener -{ - /** - * - */ - private static final long serialVersionUID = -7201158578463954623L; - - /** - * Default Constructor - */ - public OnlineHelp() - { - super (); - setEditable (false); - setContentType ("text/html"); - addHyperlinkListener (this); - } // OnlineHelp - - /** - * Constructor - * @param url URL to load - */ - public OnlineHelp (String url) - { - this(); - try - { - if (url != null && url.length() > 0) - setPage(url); - } - catch (Exception e) - { - System.err.println("OnlineHelp URL=" + url + " - " + e); - } - } // OnlineHelp - - /** - * Constructor - * @param loadOnline load online URL - */ - public OnlineHelp (boolean loadOnline) - { - this (loadOnline ? BASE_URL : null); - } // OnlineHelp - - /** Base of Online Help System */ - protected static final String BASE_URL = "http://www.adempiere.com/wiki/index.php/OnlineLoginHelp"; - - public static void openInDefaultBrowser() - { - Env.startBrowser(BASE_URL); - } - - /************************************************************************** - * Hyperlink Listener - * @param e event - */ - public void hyperlinkUpdate (HyperlinkEvent e) - { - // System.out.println("OnlineHelp.hyperlinkUpdate - " + e.getDescription() + " " + e.getURL()); - if (e.getEventType() != HyperlinkEvent.EventType.ACTIVATED) - return; - - this.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); - // - if (e instanceof HTMLFrameHyperlinkEvent) - { - HTMLFrameHyperlinkEvent evt = (HTMLFrameHyperlinkEvent)e; - HTMLDocument doc = (HTMLDocument)getDocument(); - doc.processHTMLFrameHyperlinkEvent(evt); - } - else if (e.getURL() == null) - // remove # of the reference - scrollToReference(e.getDescription().substring(1)); - else - { - try - { - setPage(e.getURL()); - } - catch (Throwable t) - { - System.err.println("Help.hyperlinkUpdate - " + t.toString()); - displayError("Error", e.getURL(), t); - } - } - this.setCursor(Cursor.getDefaultCursor()); - } // hyperlinkUpdate - - /** - * Set Text - * @param text text - */ - public void setText (String text) - { - setBackground (AdempierePLAF.getInfoBackground()); - super.setText(text); - setCaretPosition(0); // scroll to top - } // setText - - /** - * Load URL async - * @param url url - */ - public void setPage (final URL url) - { - setBackground (Color.white); - Runnable pgm = new Runnable() - { - public void run() - { - loadPage(url); - } - }; - new Thread(pgm).start(); - } // setPage - - /** - * Load Page Async - * @param url url - */ - private void loadPage (URL url) - { - try - { - super.setPage(url); - } - catch (Exception e) - { - displayError("Error: URL not found", url, e); - } - } // loadPage - - /** - * Display Error message - * @param header header - * @param url url - * @param exception exception - */ - protected void displayError (String header, Object url, Object exception) - { - StringBuilder msg = new StringBuilder (""); - msg.append("

    ").append(header).append("

    ") - .append("

    URL=").append(url).append("

    ") - .append("

    Error=").append(exception).append("

    ") - .append("

    © Adempiere   ") - .append("Online Help

    ") - .append(""); - setText(msg.toString()); - } // displayError - - /*************************************************************************/ - - /** Online links. - * Key=AD_Window_ID (as String) - Value=URL - */ - private static HashMap s_links = new HashMap(); - static - { - new Worker (BASE_URL, s_links).start(); - } - - /** - * Is Online Help available. - * @return true if available - */ - public static boolean isAvailable() - { - return s_links.size() != 0; - } // isAvailable - -} // OnlineHelp - -/** - * Online Help Worker - */ -class Worker extends Thread -{ - /** - * Worker Constructor - * @param urlString url - * @param links links - */ - Worker (String urlString, HashMap links) - { - m_urlString = urlString; - m_links = links; - setPriority(Thread.MIN_PRIORITY); - } // Worker - - private String m_urlString = null; - private HashMap m_links = null; - - /** - * Worker: Read available Online Help Pages - */ - public void run() - { - if (m_links == null) - return; - URL url = null; - try - { - url = new URL (m_urlString); - } - catch (Exception e) - { - System.err.println("OnlineHelp.Worker.run (url) - " + e); - } - if (url == null) - return; - - // Read Reference Page - try - { - URLConnection conn = url.openConnection(); - InputStream is = conn.getInputStream(); - HTMLEditorKit kit = new HTMLEditorKit(); - HTMLDocument doc = (HTMLDocument)kit.createDefaultDocument(); - doc.putProperty("IgnoreCharsetDirective", Boolean.TRUE); - kit.read (new InputStreamReader(is), doc, 0); - - // Get The Links to the Help Pages - HTMLDocument.Iterator it = doc.getIterator(HTML.Tag.A); - Object target = null; - Object href = null; - while (it != null && it.isValid()) - { - AttributeSet as = it.getAttributes(); - // ~ href=/help/100/index.html target=Online title=My Test - // System.out.println("~ " + as); - - // key keys - if (target == null || href == null) - { - Enumeration en = as.getAttributeNames(); - while (en.hasMoreElements()) - { - Object o = en.nextElement(); - if (target == null && o.toString().equals("target")) - target = o; // javax.swing.text.html.HTML$Attribute - else if (href == null && o.toString().equals("href")) - href = o; - } - } - - if (target != null && "Online".equals(as.getAttribute(target))) - { - // Format: /help//index.html - String hrefString = (String)as.getAttribute(href); - if (hrefString != null) - { - try - { - // System.err.println(hrefString); - String AD_Window_ID = hrefString.substring(hrefString.indexOf('/',1), hrefString.lastIndexOf('/')); - m_links.put(AD_Window_ID, hrefString); - } - catch (Exception e) - { - System.err.println("OnlineHelp.Worker.run (help) - " + e); - } - } - } - it.next(); - } - is.close(); - } - catch (ConnectException e) - { - // System.err.println("OnlineHelp.Worker.run URL=" + url + " - " + e); - } - catch (UnknownHostException uhe) - { - // System.err.println("OnlineHelp.Worker.run " + uhe); - } - catch (Exception e) - { - System.err.println("OnlineHelp.Worker.run (e) " + e); - // e.printStackTrace(); - } - catch (Throwable t) - { - System.err.println("OnlineHelp.Worker.run (t) " + t); - // t.printStackTrace(); - } - // System.out.println("OnlineHelp - Links=" + m_links.size()); - } // run - - /** - * Diagnostics - * @param doc html document - * @param tag html tag - */ - /*private void dumpTags (HTMLDocument doc, HTML.Tag tag) - { - System.out.println("Doc=" + doc.getBase() + ", Tag=" + tag); - HTMLDocument.Iterator it = doc.getIterator(tag); - while (it != null && it.isValid()) - { - AttributeSet as = it.getAttributes(); - System.out.println("~ " + as); - it.next(); - } - } // printTags*/ - -} // Worker diff --git a/org.adempiere.ui.swing/src/org/compiere/apps/Preference.java b/org.adempiere.ui.swing/src/org/compiere/apps/Preference.java deleted file mode 100644 index 2c29ad7916..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/apps/Preference.java +++ /dev/null @@ -1,701 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ -package org.compiere.apps; - -import java.awt.BorderLayout; -import java.awt.Dimension; -import java.awt.FlowLayout; -import java.awt.Frame; -import java.awt.GridBagConstraints; -import java.awt.GridBagLayout; -import java.awt.GridLayout; -import java.awt.Insets; -import java.awt.SystemColor; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.io.File; -import java.io.FileWriter; -import java.nio.charset.Charset; -import java.util.Arrays; -import java.util.Vector; -import java.util.logging.Level; - -import javax.swing.BorderFactory; -import javax.swing.JFileChooser; -import javax.swing.JList; -import javax.swing.JScrollPane; -import javax.swing.ListSelectionModel; -import javax.swing.UIManager; -import javax.swing.border.Border; -import javax.swing.event.ListSelectionEvent; -import javax.swing.event.ListSelectionListener; -import javax.swing.plaf.metal.MetalLookAndFeel; -import javax.swing.plaf.metal.MetalTheme; -import javax.swing.table.DefaultTableModel; - -import org.adempiere.plaf.AdempierePLAF; -import org.adempiere.plaf.PLAFEditorPanel; -import org.compiere.grid.ed.VDate; -import org.compiere.minigrid.MiniTable; -import org.compiere.model.MRole; -import org.compiere.model.MSystem; -import org.compiere.model.MUser; -import org.compiere.print.CPrinter; -import org.compiere.swing.CButton; -import org.compiere.swing.CCheckBox; -import org.compiere.swing.CComboBox; -import org.compiere.swing.CDialog; -import org.compiere.swing.CLabel; -import org.compiere.swing.CPanel; -import org.compiere.swing.CTabbedPane; -import org.compiere.swing.CTextArea; -import org.compiere.swing.CToggleButton; -import org.compiere.util.CLogErrorBuffer; -import org.compiere.util.CLogMgt; -import org.compiere.util.CLogger; -import org.compiere.util.Env; -import org.compiere.util.Ini; -import org.compiere.util.Msg; -import org.compiere.util.ValueNamePair; - -/** - * Customize settings like L&F, AutoCommit, etc. & Diagnostics - *

    - * Change log: - *

      - *
    • 2007-02-12 - teo_sarca - [ 1658127 ] Select charset encoding on import - *
    - * - * @author Jorg Janke - * @version $Id: Preference.java,v 1.2 2006/07/30 00:51:27 jjanke Exp $ - * - * @author Low Heng Sin - * @version 2006-11-27 - */ -public final class Preference extends CDialog - implements ActionListener, ListSelectionListener -{ - /** - * - */ - private static final long serialVersionUID = -4691368295400769754L; - - /** - * Standard Constructor - * @param frame frame - * @param WindowNo window - */ - public Preference(Frame frame, int WindowNo) - { - super(frame, Msg.getMsg(Env.getCtx(), "Preference"), true); - log.config("Preference"); - try - { - jbInit(); - } - catch(Exception ex) - { - log.log(Level.SEVERE, ex.getMessage()); - } - load(); - // - StringBuilder sta = new StringBuilder("#"); - sta.append(Env.getCtx().size()).append(" - ") - .append(Msg.translate(Env.getCtx(), "AD_Window_ID")) - .append("=").append(WindowNo); - statusBar.setStatusLine(sta.toString()); - statusBar.setStatusDB(""); - AEnv.positionCenterWindow(frame, this); - } // Preference - - /** Logger */ - private static CLogger log = CLogger.getCLogger(Preference.class); - - private CPanel panel = new CPanel(); - private BorderLayout panelLayout = new BorderLayout(); - private CTabbedPane tabPane = new CTabbedPane(); - private CPanel customizePane = new CPanel(); - private CPanel contextPane = new CPanel(); - private GridBagLayout customizeLayout = new GridBagLayout(); - private CCheckBox autoCommit = new CCheckBox(); - private CCheckBox autoNew = new CCheckBox(); - private CCheckBox printPreview = new CCheckBox(); - private CCheckBox validateConnectionOnStartup = new CCheckBox(); - private CCheckBox singleInstancePerWindow = new CCheckBox(); - private CCheckBox openWindowMaximized = new CCheckBox(); - private CPanel southPanel = new CPanel(); - private BorderLayout southLayout = new BorderLayout(); - private BorderLayout icontextLayout = new BorderLayout(); - private JList infoList = new JList(); - private JScrollPane contextListScrollPane = new JScrollPane(infoList); - private CPanel contextSouthPanel = new CPanel(); - private CTextArea contextHeader = new CTextArea(4,15); - private CTextArea contextDetail = new CTextArea(4,35); - private CTextArea infoArea = new CTextArea(5, 30); - private BorderLayout contextSouthLayout = new BorderLayout(); - private StatusBar statusBar = new StatusBar(); - private ConfirmPanel confirm = new ConfirmPanel(true); - private CComboBoxtraceLevel = new CComboBox(CLogMgt.LEVELS); - private CLabel traceLabel = new CLabel(); - private CCheckBox traceFile = new CCheckBox(); - private CCheckBox autoLogin = new CCheckBox(); - private CCheckBox adempiereSys = new CCheckBox(); - private CCheckBox logMigrationScript = new CCheckBox(); - private CCheckBox storePassword = new CCheckBox(); - private CCheckBox showTrl = new CCheckBox(); - private CCheckBox showAcct = new CCheckBox(); - private CCheckBox cacheWindow = new CCheckBox(); - private CLabel lPrinter = new CLabel(); - private CPrinter fPrinter = new CPrinter(); - private CLabel lDate = new CLabel(); - private VDate fDate = new VDate(); - private CPanel errorPane = new CPanel(); - private BorderLayout errorLayout = new BorderLayout(); - private JScrollPane errorScrollPane = new JScrollPane(); - private MiniTable errorTable = new MiniTable(); - private CPanel errorPanel = new CPanel(new FlowLayout(FlowLayout.TRAILING)); - private CToggleButton bErrorsOnly = new CToggleButton(Msg.getMsg(Env.getCtx(), "ErrorsOnly")); - private CButton bErrorReset = new CButton(Msg.getMsg(Env.getCtx(), "Reset")); - private CButton bErrorEMail = new CButton(Msg.getMsg(Env.getCtx(), "SendEMail")); - private CButton bErrorSave = new CButton(Msg.getMsg(Env.getCtx(), "SaveFile")); - private CButton bRoleInfo = new CButton(Msg.translate(Env.getCtx(), "AD_Role_ID")); - // Charset: - private CLabel lCharset = new CLabel(); - private CComboBoxfCharset = new CComboBox(Ini.getAvailableCharsets()); - - private CPanel configPanel = new CPanel(); - - private PLAFEditorPanel plafEditor = new PLAFEditorPanel(); - - /** - * Static Init. - *
    -	 *  - panel
    -	 *      - tabPane
    -	 *          - customizePane
    -	 *              - infoArea
    -	 *              - fields ...
    -	 *          - contextPane
    -	 *              - contextList
    -	 *              - contextSouthPanel
    -	 *                  - contextHeader
    -	 *                  - contextDetail
    -	 * 			- errorPane
    -	 * 				- errorScollPane
    -	 * 					- errorTable
    -	 *      - southPanel
    -	 *  
    - * @throws Exception - */ - void jbInit() throws Exception - { - traceLabel.setRequestFocusEnabled(false); - traceLabel.setText(Msg.getMsg(Env.getCtx(), "TraceLevel", true)); - traceLabel.setToolTipText(Msg.getMsg(Env.getCtx(), "TraceLevel", false)); - traceFile.setText(Msg.getMsg(Env.getCtx(), "TraceFile", true)); - traceFile.setToolTipText(Msg.getMsg(Env.getCtx(), "TraceFile", false)); - - autoCommit.setText(Msg.getMsg(Env.getCtx(), "AutoCommit", true)); - autoCommit.setToolTipText(Msg.getMsg(Env.getCtx(), "AutoCommit", false)); - autoNew.setText(Msg.getMsg(Env.getCtx(), "AutoNew", true)); - autoNew.setToolTipText(Msg.getMsg(Env.getCtx(), "AutoNew", false)); - adempiereSys.setText(Msg.getMsg(Env.getCtx(), "AdempiereSys", true)); - adempiereSys.setToolTipText(Msg.getMsg(Env.getCtx(), "AdempiereSys", false)); - logMigrationScript.setText(Msg.getMsg(Env.getCtx(), "LogMigrationScript", true)); - logMigrationScript.setToolTipText(Msg.getMsg(Env.getCtx(), "LogMigrationScript", false)); - printPreview.setText(Msg.getMsg(Env.getCtx(), "AlwaysPrintPreview", true)); - printPreview.setToolTipText(Msg.getMsg(Env.getCtx(), "AlwaysPrintPreview", false)); - validateConnectionOnStartup.setText(Msg.getMsg(Env.getCtx(), "ValidateConnectionOnStartup", true)); - validateConnectionOnStartup.setToolTipText(Msg.getMsg(Env.getCtx(), "ValidateConnectionOnStartup", false)); - singleInstancePerWindow.setText(Msg.getMsg(Env.getCtx(), "SingleInstancePerWindow", true)); - singleInstancePerWindow.setToolTipText(Msg.getMsg(Env.getCtx(), "SingleInstancePerWindow", false)); - openWindowMaximized.setText(Msg.getMsg(Env.getCtx(), "OpenWindowMaximized", true)); - openWindowMaximized.setToolTipText(Msg.getMsg(Env.getCtx(), "OpenWindowMaximized", false)); - autoLogin.setText(Msg.getMsg(Env.getCtx(), "AutoLogin", true)); - autoLogin.setToolTipText(Msg.getMsg(Env.getCtx(), "AutoLogin", false)); - storePassword.setText(Msg.getMsg(Env.getCtx(), "StorePassword", true)); - storePassword.setToolTipText(Msg.getMsg(Env.getCtx(), "StorePassword", false)); - showTrl.setText(Msg.getMsg(Env.getCtx(), "ShowTrlTab", true)); - showTrl.setToolTipText(Msg.getMsg(Env.getCtx(), "ShowTrlTab", false)); - showAcct.setText(Msg.getMsg(Env.getCtx(), "ShowAcctTab", true)); - showAcct.setToolTipText(Msg.getMsg(Env.getCtx(), "ShowAcctTab", false)); - cacheWindow.setText(Msg.getMsg(Env.getCtx(), "CacheWindow", true)); - cacheWindow.setToolTipText(Msg.getMsg(Env.getCtx(), "CacheWindow", false)); - lPrinter.setText(Msg.getMsg(Env.getCtx(), "Printer")); - lDate.setText(Msg.getMsg(Env.getCtx(), "Date")); - infoArea.setReadWrite(false); - // Charset: - lCharset.setText(Msg.getMsg(Env.getCtx(), "Charset", true)); - lCharset.setToolTipText(Msg.getMsg(Env.getCtx(), "Charset", false)); - - getContentPane().add(panel); - panel.setLayout(panelLayout); - panel.add(tabPane, BorderLayout.CENTER); - // Customize - tabPane.add(customizePane, Msg.getMsg(Env.getCtx(), "Preference")); - customizePane.setLayout(customizeLayout); - customizePane.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); - - Border insetBorder = BorderFactory.createEmptyBorder(2, 2, 2, 0); - if (MSystem.isSwingRememberPasswordAllowed()) { - CPanel loginPanel = new CPanel(); - loginPanel.setBorder(BorderFactory.createTitledBorder(Msg.getMsg(Env.getCtx(), "Login"))); - loginPanel.setLayout(new GridLayout(1, 2)); - autoLogin.setBorder(insetBorder); - storePassword.setBorder(insetBorder); - loginPanel.add(autoLogin); - loginPanel.add(storePassword); - - customizePane.add(loginPanel, new GridBagConstraints(0, 0, 1, 1, 1.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(2, 0, 2, 0), 0, 0)); - } - - CPanel windowPanel = new CPanel(); - windowPanel.setBorder(BorderFactory.createTitledBorder(Msg.getMsg(Env.getCtx(), "Window"))); - windowPanel.setLayout(new GridLayout(4, 2)); - windowPanel.add(showAcct);showAcct.setBorder(insetBorder); - windowPanel.add(showTrl);showTrl.setBorder(insetBorder); - windowPanel.add(autoCommit);autoCommit.setBorder(insetBorder); - windowPanel.add(autoNew);autoNew.setBorder(insetBorder); - windowPanel.add(cacheWindow);cacheWindow.setBorder(insetBorder); - windowPanel.add(openWindowMaximized);openWindowMaximized.setBorder(insetBorder); - windowPanel.add(singleInstancePerWindow);singleInstancePerWindow.setBorder(insetBorder); - customizePane.add(windowPanel, new GridBagConstraints(0, 1, 1, 1, 1.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(2, 0, 2, 0), 0, 0)); - - CPanel connPanel = new CPanel(); - connPanel.setBorder(BorderFactory.createTitledBorder(Msg.getMsg(Env.getCtx(), "Connection"))); - connPanel.setLayout(new GridBagLayout()); - connPanel.add(validateConnectionOnStartup, new GridBagConstraints(0, 1, 2, 1, 1.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(2, 2, 2, 0), 0, 0)); - customizePane.add(connPanel, new GridBagConstraints(0, 2, 1, 1, 1.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(2, 0, 2, 0), 0, 0)); - - CPanel tracePanel = new CPanel(); - tracePanel.setBorder(BorderFactory.createTitledBorder(Msg.getMsg(Env.getCtx(), "TraceInfo"))); - tracePanel.setLayout(new GridBagLayout()); - tracePanel.add(traceLabel, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(2, 2, 2, 0), 0, 0)); - tracePanel.add(traceLevel, new GridBagConstraints(1, 0, 1, 1, 1.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(2, 2, 2, 0), 0, 0)); - tracePanel.add(traceFile, new GridBagConstraints(0, 1, 2, 1, 1.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(2, 2, 2, 0), 0, 0)); - customizePane.add(tracePanel, new GridBagConstraints(0, 3, 1, 1, 1.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(2, 0, 2, 0), 0, 0)); - - CPanel printPanel = new CPanel(); - printPanel.setBorder(BorderFactory.createTitledBorder(Msg.getMsg(Env.getCtx(), "Printing"))); - printPanel.setLayout(new GridBagLayout()); - printPanel.add(lPrinter, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(2, 2, 2, 0), 0, 0)); - printPanel.add(fPrinter, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(2, 2, 2, 0), 0, 0)); - printPanel.add(printPreview, new GridBagConstraints(0, 1, 2, 1, 1.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(2, 2, 2, 0), 0, 0)); - customizePane.add(printPanel, new GridBagConstraints(0, 4, 1, 1, 1.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(2, 0, 2, 0), 0, 0)); - - CPanel otherPanel = new CPanel(); - otherPanel.setBorder(BorderFactory.createEmptyBorder()); - otherPanel.setLayout(new GridLayout()); - CPanel datePanel = new CPanel(); - datePanel.setLayout(new FlowLayout()); - ((FlowLayout)datePanel.getLayout()).setAlignment(FlowLayout.LEFT); - datePanel.add(lDate); - datePanel.add(fDate); - otherPanel.add(datePanel);datePanel.setBorder(insetBorder); - otherPanel.add(adempiereSys);adempiereSys.setBorder(insetBorder); - otherPanel.add(logMigrationScript);logMigrationScript.setBorder(insetBorder); - customizePane.add(otherPanel, new GridBagConstraints(0, 5, 1, 1, 1.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(2, 0, 2, 0), 0, 0)); - - // Charset: - CPanel charsetPanel = new CPanel(); - charsetPanel.setBorder(BorderFactory.createEmptyBorder()); - charsetPanel.setLayout(new FlowLayout()); - ((FlowLayout)charsetPanel.getLayout()).setAlignment(FlowLayout.LEFT); - charsetPanel.add(lCharset); - charsetPanel.add(fCharset); - customizePane.add(charsetPanel, new GridBagConstraints(0, 6, 1, 1, 1.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(2, 0, 2, 0), 0, 0)); - - CPanel themePanel = new CPanel(); - themePanel.setLayout(new GridLayout(1, 1)); - - themePanel.add(plafEditor); - tabPane.add(themePanel, Msg.getMsg(Env.getCtx(), "UITheme", true)); - - configPanel.setLayout(new BorderLayout()); - configPanel.add(infoArea, BorderLayout.CENTER); - CPanel configSouth = new CPanel(); - configSouth.setLayout(new FlowLayout()); - ((FlowLayout)configSouth.getLayout()).setAlignment(FlowLayout.RIGHT); - configSouth.add(bRoleInfo); - configPanel.add(configSouth, BorderLayout.SOUTH); - tabPane.add(configPanel, Msg.getMsg(Env.getCtx(), "Info")); - - // Info - tabPane.add(contextPane, Msg.getMsg(Env.getCtx(), "Context")); - contextPane.setLayout(icontextLayout); - contextPane.add(contextListScrollPane, BorderLayout.CENTER); - contextListScrollPane.setPreferredSize(new Dimension(200, 300)); - infoList.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION); - infoList.setBackground(AdempierePLAF.getFieldBackground_Inactive()); - infoList.addListSelectionListener(this); - infoList.setFixedCellWidth(30); - contextPane.add(contextSouthPanel, BorderLayout.SOUTH); - contextSouthPanel.setLayout(contextSouthLayout); - contextSouthPanel.add(contextHeader, BorderLayout.WEST); - contextHeader.setBackground(SystemColor.info); - contextHeader.setReadWrite(false); - contextHeader.setLineWrap(true); - contextHeader.setWrapStyleWord(true); - contextHeader.setBorder(BorderFactory.createLoweredBevelBorder()); - contextSouthPanel.add(contextDetail, BorderLayout.CENTER); - contextDetail.setBackground(SystemColor.info); - contextDetail.setReadWrite(false); - contextDetail.setLineWrap(true); - contextDetail.setWrapStyleWord(true); - contextDetail.setBorder(BorderFactory.createLoweredBevelBorder()); - // Error Pane - errorPane.setLayout(errorLayout); -// tabPane.add(errorPane, Msg.getMsg(Env.getCtx(), "Errors")); - tabPane.add(errorPane, "Errors"); - errorPane.add(errorScrollPane, BorderLayout.CENTER); - errorScrollPane.getViewport().add(errorTable, null); - // - errorPanel.add(bErrorsOnly); - errorPanel.add(bErrorReset); - errorPanel.add(bErrorEMail); - errorPanel.add(bErrorSave); - errorPane.add(errorPanel, BorderLayout.SOUTH); - // South - panel.add(southPanel, BorderLayout.SOUTH); - southPanel.setLayout(southLayout); - southPanel.add(statusBar, BorderLayout.SOUTH); - southPanel.add(confirm, BorderLayout.CENTER); - // - bRoleInfo.addActionListener(this); - confirm.addActionListener(this); - } // jbInit - - - /** - * List Selection Listener - show info in header/detail fields - * @param e evant - */ - public void valueChanged(ListSelectionEvent e) - { - if (e.getValueIsAdjusting()) - return; - - String value = (String)infoList.getSelectedValue(); - if (value == null) - return; - int pos = value.indexOf("=="); - if (pos == -1) - { - contextHeader.setText(""); - contextDetail.setText(value); - } - else - { - contextHeader.setText(value.substring(0, pos).replace('|','\n')); - contextDetail.setText(value.substring(pos+3)); - } - } // valueChanged - - - /** - * ActionListener - * @param e event - */ - public void actionPerformed(ActionEvent e) - { - if (e.getActionCommand().equals(ConfirmPanel.A_CANCEL)) - dispose(); - else if (e.getActionCommand().equals(ConfirmPanel.A_OK)) - cmd_save(); - // - else if (e.getSource() == bErrorsOnly) - cmd_displayErrors(); - else if (e.getSource() == bErrorReset) - cmd_errorReset(); - else if (e.getSource() == bErrorEMail) - cmd_errorEMail(); - else if (e.getSource() == bErrorSave) - cmd_errorSave(); - // - else if (e.getSource() == bRoleInfo) - ADialog.info(0, this, "RoleInfo", MRole.getDefault().toStringX(Env.getCtx())); - } // actionPerformed - - - /** - * Load Settings - and Context - */ - private void load() - { - log.config(""); - infoArea.setText(CLogMgt.getInfo(null).toString()); - infoArea.setCaretPosition(0); - - // -- Load Settings -- - // AutoCommit - autoCommit.setSelected(Env.isAutoCommit(Env.getCtx())); - autoNew.setSelected(Env.isAutoNew(Env.getCtx())); - // AdempiereSys - adempiereSys.setSelected(Ini.isPropertyBool(Ini.P_ADEMPIERESYS)); - // LogMigrationScript - logMigrationScript.setSelected(Ini.isPropertyBool(Ini.P_LOGMIGRATIONSCRIPT)); - if (Env.getAD_Client_ID(Env.getCtx()) > 20) - { - adempiereSys.setSelected(false); - adempiereSys.setEnabled(false); - if (Env.getAD_User_ID(Env.getCtx()) > 100) { - // disable log migration scripts on clients non-GW for non-SuperUser - logMigrationScript.setSelected(false); - logMigrationScript.setEnabled(false); - } - } - if (MSystem.isSwingRememberPasswordAllowed()) { - // AutoLogin - autoLogin.setSelected(Ini.isPropertyBool(Ini.P_A_LOGIN)); - // Save Password - storePassword.setSelected(Ini.isPropertyBool(Ini.P_STORE_PWD)); - } else { - autoLogin.setSelected(false); - storePassword.setSelected(false); - } - // Show Acct Tab - if (MRole.getDefault().isShowAcct()) - showAcct.setSelected(Ini.isPropertyBool(Ini.P_SHOW_ACCT)); - else - { - showAcct.setSelected(false); - showAcct.setReadWrite(false); - } - // Show Trl/Advanced Tab - showTrl.setSelected(Ini.isPropertyBool(Ini.P_SHOW_TRL)); - - cacheWindow.setSelected(Ini.isCacheWindow()); - - // Print Preview - printPreview.setSelected(Ini.isPropertyBool(Ini.P_PRINTPREVIEW)); - - // Validate Connection on Startup - validateConnectionOnStartup.setSelected(Ini.isPropertyBool(Ini.P_VALIDATE_CONNECTION_ON_STARTUP)); - - // Single Instance per Window - singleInstancePerWindow.setSelected(Ini.isPropertyBool(Ini.P_SINGLE_INSTANCE_PER_WINDOW)); - - // Open Window Maximized - openWindowMaximized.setSelected(Ini.isPropertyBool(Ini.P_OPEN_WINDOW_MAXIMIZED)); - - // TraceLevel - traceLevel.setSelectedItem(CLogMgt.getLevel()); - traceFile.setSelected(Ini.isPropertyBool(Ini.P_TRACEFILE)); - // Printer - fPrinter.setValue(Env.getContext(Env.getCtx(), "#Printer")); - // Date - fDate.setValue(Env.getContextAsDate(Env.getCtx(), "#Date")); - // Charset - fCharset.setSelectedItem(Ini.getCharset()); - - // -- Load and sort Context -- - String[] context = Env.getEntireContext(Env.getCtx()); - Arrays.sort(context); - infoList.setListData(context); - - // Load Errors - // CLogMgt mgt = new CLogMgt(); // creates test trace - bErrorsOnly.setSelected(true); - errorTable.setCellSelectionEnabled(true); - cmd_displayErrors(); - // for (int i = 2; i < 6; i++) - // errorTable.setColumnReadOnly(i, false); - // - bErrorsOnly.addActionListener(this); - bErrorReset.addActionListener(this); - bErrorSave.addActionListener(this); - bErrorEMail.addActionListener(this); - } // load - - /** - * Save Settings - */ - private void cmd_save() - { - log.config(""); - // UI - // AutoCommit - Ini.setProperty(Ini.P_A_COMMIT, (autoCommit.isSelected())); - Env.setAutoCommit(Env.getCtx(), autoCommit.isSelected()); - Ini.setProperty(Ini.P_A_NEW, (autoNew.isSelected())); - Env.setAutoNew(Env.getCtx(), autoNew.isSelected()); - // AdempiereSys - Ini.setProperty(Ini.P_ADEMPIERESYS, adempiereSys.isSelected()); - // LogMigrationScript - Ini.setProperty(Ini.P_LOGMIGRATIONSCRIPT, logMigrationScript.isSelected()); - if (MSystem.isSwingRememberPasswordAllowed()) { - // AutoLogin - Ini.setProperty(Ini.P_A_LOGIN, (autoLogin.isSelected())); - // Save Password - Ini.setProperty(Ini.P_STORE_PWD, (storePassword.isSelected())); - } else { - Ini.setProperty(Ini.P_A_LOGIN, false); - Ini.setProperty(Ini.P_STORE_PWD, false); - } - // Show Acct Tab - Ini.setProperty(Ini.P_SHOW_ACCT, (showAcct.isSelected())); - Env.setContext(Env.getCtx(), "#ShowAcct", (showAcct.isSelected())); - // Show Trl Tab - Ini.setProperty(Ini.P_SHOW_TRL, (showTrl.isSelected())); - Env.setContext(Env.getCtx(), "#ShowTrl", (showTrl.isSelected())); - - Ini.setProperty(Ini.P_CACHE_WINDOW, cacheWindow.isSelected()); - - // Print Preview - Ini.setProperty(Ini.P_PRINTPREVIEW, (printPreview.isSelected())); - // Validate Connection on Startup - Ini.setProperty(Ini.P_VALIDATE_CONNECTION_ON_STARTUP, (validateConnectionOnStartup.isSelected())); - // Single Instance per Window - Ini.setProperty(Ini.P_SINGLE_INSTANCE_PER_WINDOW, (singleInstancePerWindow.isSelected())); - // Open Window Maximized - Ini.setProperty(Ini.P_OPEN_WINDOW_MAXIMIZED, (openWindowMaximized.isSelected())); - // TraceLevel/File - Level level = (Level)traceLevel.getSelectedItem(); - CLogMgt.setLevel(level); - Ini.setProperty(Ini.P_TRACELEVEL, level.getName()); - Ini.setProperty(Ini.P_TRACEFILE, traceFile.isSelected()); - // Printer - String printer = (String)fPrinter.getSelectedItem(); - Env.setContext(Env.getCtx(), "#Printer", printer); - Ini.setProperty(Ini.P_PRINTER, printer); - // Date (remove seconds) - java.sql.Timestamp ts = (java.sql.Timestamp)fDate.getValue(); - if (ts != null) - Env.setContext(Env.getCtx(), "#Date", ts); - // Charset - Charset charset = (Charset)fCharset.getSelectedItem(); - Ini.setProperty(Ini.P_CHARSET, charset.name()); - - //UI - ValueNamePair laf = plafEditor.getSelectedLook(); - ValueNamePair theme = plafEditor.getSelectedTheme(); - if ( laf != null ) { - String clazz = laf.getValue(); - String currentLaf = UIManager.getLookAndFeel().getClass().getName(); - if (clazz != null && clazz.length() > 0 && !currentLaf.equals(clazz)) - { - //laf changed - AdempierePLAF.setPLAF(laf, theme, true); - AEnv.updateUI(); - } - else - { - if (UIManager.getLookAndFeel() instanceof MetalLookAndFeel) - { - MetalTheme currentTheme = MetalLookAndFeel.getCurrentTheme(); - String themeClass = currentTheme.getClass().getName(); - String sTheme = theme.getValue(); - if (sTheme != null && sTheme.length() > 0 && !sTheme.equals(themeClass)) - { - ValueNamePair plaf = new ValueNamePair( - UIManager.getLookAndFeel().getClass().getName(), - UIManager.getLookAndFeel().getName()); - AdempierePLAF.setPLAF(plaf, theme, true); - AEnv.updateUI(); - } - } - } - } - - Ini.saveProperties(Ini.isClient()); - dispose(); - } // cmd_save - - /** - * (Re)Display Errors - */ - private void cmd_displayErrors() - { - Vector> data = CLogErrorBuffer.get(true).getLogData(bErrorsOnly.isSelected()); - Vector columnNames = CLogErrorBuffer.get(true).getColumnNames(Env.getCtx()); - DefaultTableModel model = new DefaultTableModel(data, columnNames); - errorTable.setModel(model); - // - if (bErrorsOnly.isSelected()) - tabPane.setTitleAt(4, Msg.getMsg(Env.getCtx(), "Errors") + " (" + data.size() + ")"); - else - tabPane.setTitleAt(4, Msg.getMsg(Env.getCtx(), "TraceInfo") + " (" + data.size() + ")"); - errorTable.autoSize(); - } // cmd_errorsOnly - - /** - * Reset Errors - */ - private void cmd_errorReset() - { - CLogErrorBuffer.get(true).resetBuffer(bErrorsOnly.isSelected()); - cmd_displayErrors(); - } // cmd_errorReset - - /** - * EMail Errors - */ - private void cmd_errorEMail() - { - @SuppressWarnings("unused") - EMailDialog emd = new EMailDialog(this, - "EMail Trace", - MUser.get(Env.getCtx()), - "", // to - "Adempiere Trace Info", - CLogErrorBuffer.get(true).getErrorInfo(Env.getCtx(), bErrorsOnly.isSelected()), - null); - - } // cmd_errorEMail - - /** - * Save Error to File - */ - private void cmd_errorSave() - { - JFileChooser chooser = new JFileChooser(); - chooser.setDialogType(JFileChooser.SAVE_DIALOG); - chooser.setDialogTitle("Adempiere Trace File"); - chooser.setFileSelectionMode(JFileChooser.FILES_ONLY); - chooser.setSelectedFile(new File ("traceInfo.log")); - int returnVal = chooser.showSaveDialog(this); - if(returnVal != JFileChooser.APPROVE_OPTION) - return; - try - { - File file = chooser.getSelectedFile(); - FileWriter writer = new FileWriter(file); - writer.write(CLogErrorBuffer.get(true).getErrorInfo(Env.getCtx(), bErrorsOnly.isSelected())); - writer.flush(); - writer.close(); - } - catch (Exception e) - { - log.log(Level.SEVERE, "", e); - } - } // cmd_errorSave - -} // Preference diff --git a/org.adempiere.ui.swing/src/org/compiere/apps/PrintScreenPainter.java b/org.adempiere.ui.swing/src/org/compiere/apps/PrintScreenPainter.java deleted file mode 100644 index 609ff7ea5f..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/apps/PrintScreenPainter.java +++ /dev/null @@ -1,135 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ -package org.compiere.apps; - -import java.awt.Graphics; -import java.awt.Graphics2D; -import java.awt.Window; -import java.awt.print.PageFormat; -import java.awt.print.Pageable; -import java.awt.print.Printable; -import java.awt.print.PrinterException; -import java.util.Date; - -import org.compiere.print.CPaper; -import org.compiere.print.PrintUtil; -import org.compiere.util.DisplayType; -import org.compiere.util.Env; -import org.compiere.util.Msg; - -/** - * PrintScreen Painter - * - * @author Jorg Janke - * @version $Id: PrintScreenPainter.java,v 1.2 2006/07/30 00:51:27 jjanke Exp $ - */ -public class PrintScreenPainter implements Pageable, Printable -{ - /** - * PrintScreen Painter - * @param element Window to print - */ - public PrintScreenPainter (Window element) - { - m_element = element; - } // PrintScreenPainter - - /** Element */ - private Window m_element; - - /** - * Get Number of pages - * @return 1 - */ - public int getNumberOfPages() - { - return 1; - } // getNumberOfPages - - /** - * Get Printable - * @param pageIndex page index - * @return this - * @throws java.lang.IndexOutOfBoundsException - */ - public Printable getPrintable(int pageIndex) throws java.lang.IndexOutOfBoundsException - { - return this; - } // getPrintable - - /** - * Get Page Format - * @param pageIndex page index - * @return Portrait - * @throws java.lang.IndexOutOfBoundsException - */ - public PageFormat getPageFormat(int pageIndex) throws java.lang.IndexOutOfBoundsException - { - CPaper paper = new CPaper(false); - return paper.getPageFormat(); - } // getPageFormat - - /** - * Print - * @param graphics graphics - * @param pageFormat page format - * @param pageIndex page index - * @return NO_SUCH_PAGE or PAGE_EXISTS - * @throws PrinterException - */ - public int print (Graphics graphics, PageFormat pageFormat, int pageIndex) throws PrinterException - { - // log.config( "PrintScreenPainter.print " + pageIndex, "ClipBounds=" + graphics.getClipBounds()); - if (pageIndex > 0) - return Printable.NO_SUCH_PAGE; - // - Graphics2D g2 = (Graphics2D) graphics; - - // Start position - top of page - g2.translate (pageFormat.getImageableX(), pageFormat.getImageableY()); - - // Print Header - String header = Msg.getMsg(Env.getCtx(), "PrintScreen") + " - " - + DisplayType.getDateFormat(DisplayType.DateTime).format(new Date()); - int y = g2.getFontMetrics().getHeight(); // leading + ascent + descent - g2.drawString(header, 0, y); - // Leave one row free - g2.translate (0, 2*y); - - double xRatio = pageFormat.getImageableWidth() / m_element.getSize().width; - double yRatio = (pageFormat.getImageableHeight() - 2*y) / m_element.getSize().height; - // Sacle evenly, but don't inflate - double ratio = Math.min(Math.min(xRatio, yRatio), 1.0); - g2.scale (ratio, ratio); - // Print Element - m_element.printAll (g2); - - return Printable.PAGE_EXISTS; - } // print - - /*************************************************************************/ - - /** - * Static print start - * @param element window - */ - public static void printScreen (Window element) - { - PrintUtil.print(new PrintScreenPainter(element), null, "PrintScreen", 1, false); - } // printScreen - -} // PrintScreenPainter diff --git a/org.adempiere.ui.swing/src/org/compiere/apps/ProcessCtl.java b/org.adempiere.ui.swing/src/org/compiere/apps/ProcessCtl.java deleted file mode 100644 index 35ead7f7e3..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/apps/ProcessCtl.java +++ /dev/null @@ -1,339 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ -package org.compiere.apps; - -import java.awt.Container; -import java.util.logging.Level; - -import javax.swing.JFrame; -import javax.swing.SwingUtilities; - -import org.adempiere.util.IProcessUI; -import org.compiere.model.MPInstance; -import org.compiere.process.ProcessInfo; -import org.compiere.util.CLogger; -import org.compiere.util.DB; -import org.compiere.util.Env; -import org.compiere.util.Msg; -import org.compiere.util.Trx; - -/** - * Process Interface Controller. - * - * @author Jorg Janke - * @version $Id: ProcessCtl.java,v 1.2 2006/07/30 00:51:27 jjanke Exp $ - * @author Low Heng Sin - * - Added support for having description and parameter in one dialog - * - Added support to run db process remotely on server - * - * @author Teo Sarca, SC ARHIPAC SERVICE SRL - *
  • BF [ 1757523 ] Server Processes are using Server's context - *
  • FR [ 1807922 ] Pocess threads should have a better name - *
  • BF [ 1960523 ] Server Process functionality not working - */ -public class ProcessCtl extends AbstractProcessCtl -{ - /** - * Process Control - * - * - Get Instance ID - * - Get Parameters - * - execute (lock - start process - unlock) - * - * Creates a ProcessCtl instance, which calls - * lockUI and unlockUI if parent is a ASyncProcess - *
    - * Called from APanel.cmd_print, APanel.actionButton and - * VPaySelect.cmd_generate - * - * @param parent ASyncProcess & Container - * @param WindowNo window no - * @param pi ProcessInfo process info - * @param trx Transaction - * @return worker started ProcessCtl instance or null for workflow - */ - public static ProcessCtl process (IProcessUI parent, int WindowNo, ProcessInfo pi, Trx trx) - { - if (log.isLoggable(Level.FINE)) log.fine("WindowNo=" + WindowNo + " - " + pi); - - MPInstance instance = null; - try - { - instance = new MPInstance(Env.getCtx(), pi.getAD_Process_ID(), pi.getRecord_ID()); - } - catch (Exception e) - { - pi.setSummary (e.getLocalizedMessage()); - pi.setError (true); - log.warning(pi.toString()); - return null; - } - catch (Error e) - { - pi.setSummary (e.getLocalizedMessage()); - pi.setError (true); - log.warning(pi.toString()); - return null; - } - if (!instance.save()) - { - pi.setSummary (Msg.getMsg(Env.getCtx(), "ProcessNoInstance")); - pi.setError (true); - return null; - } - pi.setAD_PInstance_ID (instance.getAD_PInstance_ID()); - - // Get Parameters (Dialog) - ProcessParameter para = new ProcessParameter (AEnv.getFrame((Container)parent), WindowNo, pi); - if (para.initDialog()) - { - para.setVisible(true); - if (!para.isOK()) - { - pi.setSummary (Msg.getMsg(Env.getCtx(), "ProcessCancelled")); - pi.setError (true); - return null; - } - } - - // execute - ProcessCtl worker = new ProcessCtl(parent, WindowNo, pi, trx); - if (parent != null) - { - //asynchrous - worker.start(); - } - else - { - //synchrous - worker.run(); - } - return worker; - } // execute - - /** - * Async Process - Do it all. - * - * - Get Instance ID - * - Get Parameters - * - execute (lock - start process - unlock) - * - * Creates a ProcessCtl instance, which calls - * lockUI and unlockUI if parent is a ASyncProcess - *
    - * Called from ProcessDialog.actionPerformed - * - * @param parent ASyncProcess & Container - * @param WindowNo window no - * @param paraPanel Process Parameter Panel - * @param pi ProcessInfo process info - * @param trx Transaction - * @return worker started ProcessCtl instance or null for workflow - */ - public static ProcessCtl process(IProcessUI parent, int WindowNo, IProcessParameter parameter, ProcessInfo pi, Trx trx) - { - if (log.isLoggable(Level.FINE)) log.fine("WindowNo=" + WindowNo + " - " + pi); - - MPInstance instance = null; - try - { - instance = new MPInstance(Env.getCtx(), pi.getAD_Process_ID(), pi.getRecord_ID()); - } - catch (Exception e) - { - pi.setSummary (e.getLocalizedMessage()); - pi.setError (true); - log.warning(pi.toString()); - return null; - } - catch (Error e) - { - pi.setSummary (e.getLocalizedMessage()); - pi.setError (true); - log.warning(pi.toString()); - return null; - } - if (!instance.save()) - { - pi.setSummary (Msg.getMsg(Env.getCtx(), "ProcessNoInstance")); - pi.setError (true); - return null; - } - pi.setAD_PInstance_ID (instance.getAD_PInstance_ID()); - - // Get Parameters - if (parameter != null) { - if (!parameter.saveParameters()) - { - pi.setSummary (Msg.getMsg(Env.getCtx(), "ProcessCancelled")); - pi.setError (true); - return null; - } - } - - if (pi.getRecord_IDs() != null && pi.getRecord_IDs().size() > 0) - { - DB.createT_Selection(pi.getAD_PInstance_ID(), pi.getRecord_IDs(), null); - } - - // execute - ProcessCtl worker = new ProcessCtl(parent, WindowNo, pi, trx); - if (parent != null) - { - worker.start(); - } - else - { - //synchrous - worker.run(); - } - return worker; - } // execute - - - - /************************************************************************** - * Constructor - * @param parent Container & ASyncProcess - * @param pi Process info - * @param trx Transaction - * Created in process(), VInvoiceGen.generateInvoices - */ - public ProcessCtl (IProcessUI parent, int WindowNo, ProcessInfo pi, Trx trx) - { - super(parent, WindowNo, pi, trx); - } // ProcessCtl - - private Waiting m_waiting; - - /** Static Logger */ - private static CLogger log = CLogger.getCLogger (ProcessCtl.class); - - /** - * Lock UI & show Waiting - */ - protected void lock () - { - // log.info("..."); - //m_parent is null for synchrous execution - if (getProcessMonitor() != null) - { - if (getProcessMonitor() instanceof Container) - { - //swing client - JFrame frame = AEnv.getFrame((Container)getProcessMonitor()); - if (frame instanceof AWindow) - ((AWindow)frame).setBusyTimer(getProcessInfo().getEstSeconds()); - else - m_waiting = new Waiting (frame, Msg.getMsg(Env.getCtx(), "Processing"), false, getProcessInfo().getEstSeconds()); - ProcessUpdateRunnable runnable = new ProcessUpdateRunnable() { - @Override - public void run() - { - if (m_waiting != null) - { - m_waiting.toFront(); - m_waiting.setVisible(true); - } - - log.finer("lock"); - parent.lockUI(pi); - } - }; - runnable.setParent(getProcessMonitor()); - runnable.setProcessInfo(getProcessInfo()); - SwingUtilities.invokeLater(runnable); - } - else - { - //other client - log.finer("lock"); - getProcessMonitor().lockUI(getProcessInfo()); - } - } - } // lock - - /** - * Unlock UI & dispose Waiting. - * Called from run() - */ - protected void unlock () - { - // log.info("..."); - if (getProcessInfo().isBatch()) - getProcessInfo().setIsTimeout(true); - if (getParent() != null) - { - if (getParent() instanceof Container) - { - ProcessUpdateRunnable runnable = new ProcessUpdateRunnable() - { - @Override - public void run() - { - // Remove Waiting/Processing Indicator - if (m_waiting != null) - m_waiting.dispose(); - m_waiting = null; - - String summary = pi.getSummary(); - if (log.isLoggable(Level.FINER)) log.finer("unlock - " + summary); - if (summary != null && summary.indexOf('@') != -1) - pi.setSummary(Msg.parseTranslation(Env.getCtx(), summary)); - parent.unlockUI(pi); - } - }; - runnable.setParent(getParent()); - runnable.setProcessInfo(getProcessInfo()); - SwingUtilities.invokeLater(runnable); - } - else - { - //other client - getParent().unlockUI(getProcessInfo()); - } - } - } // unlock - - @Override - protected void updateProgressWindowTimerEstimate(int estSeconds) { - if (m_waiting != null) - m_waiting.setTimerEstimate(getProcessInfo().getEstSeconds()); - } - - @Override - protected void updateProgressWindowTitle(String title) { - if (m_waiting != null) - m_waiting.setTitle(getProcessInfo().getTitle()); - } - - abstract class ProcessUpdateRunnable implements Runnable - { - protected ProcessInfo pi = null; - protected IProcessUI parent = null; - - public void setProcessInfo(ProcessInfo pi) - { - this.pi = pi; - } - - public void setParent(IProcessUI parent) - { - this.parent = parent; - } - } -} // ProcessCtl diff --git a/org.adempiere.ui.swing/src/org/compiere/apps/ProcessDialog.java b/org.adempiere.ui.swing/src/org/compiere/apps/ProcessDialog.java deleted file mode 100644 index 5216988bac..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/apps/ProcessDialog.java +++ /dev/null @@ -1,688 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ -package org.compiere.apps; - -import static org.compiere.model.SystemIDs.PROCESS_C_INVOICE_GENERATE; -import static org.compiere.model.SystemIDs.PROCESS_M_INOUT_GENERATE; - -import java.awt.AWTEvent; -import java.awt.BorderLayout; -import java.awt.Color; -import java.awt.Dimension; -import java.awt.FlowLayout; -import java.awt.GraphicsConfiguration; -import java.awt.Insets; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.io.File; -import java.sql.PreparedStatement; -import java.sql.ResultSet; -import java.sql.SQLException; -import java.util.List; -import java.util.logging.Level; - -import javax.swing.DefaultComboBoxModel; -import javax.swing.ImageIcon; -import javax.swing.JEditorPane; -import javax.swing.JOptionPane; -import javax.swing.JScrollPane; -import javax.swing.JSeparator; - -import org.adempiere.exceptions.AdempiereException; -import org.adempiere.exceptions.DBException; -import org.adempiere.util.Callback; -import org.adempiere.util.IProcessUI; -import org.compiere.model.MPInstance; -import org.compiere.model.MPInstancePara; -import org.compiere.model.MProcess; -import org.compiere.print.ReportCtl; -import org.compiere.print.ReportEngine; -import org.compiere.process.ProcessInfo; -import org.compiere.process.ProcessInfoUtil; -import org.compiere.swing.CButton; -import org.compiere.swing.CComboBox; -import org.compiere.swing.CFrame; -import org.compiere.swing.CLabel; -import org.compiere.swing.CPanel; -import org.compiere.util.AdempiereSystemError; -import org.compiere.util.CLogger; -import org.compiere.util.DB; -import org.compiere.util.Env; -import org.compiere.util.Msg; -import org.compiere.util.Util; - -/** - * Dialog to Start process. - * Displays information about the process - * and lets the user decide to start it - * and displays results (optionally print them). - * Calls ProcessCtl to execute. - * - * @author Jorg Janke - * @version $Id: ProcessDialog.java,v 1.2 2006/07/30 00:51:27 jjanke Exp $ - * @author Low Heng Sin - * - Merge process parameter dialog into process dialog. - * @author arboleda - globalqss - * - Implement ShowHelp option on processes and reports - * @author Teo Sarca, SC ARHIPAC SERVICE SRL - *
  • BF [ 1893525 ] ProcessDialog: Cannot select the text from text field - *
  • BF [ 1963128 ] Running a process w/o trl should display an error - */ -public class ProcessDialog extends CFrame - implements ActionListener, IProcessUI -{ - /** - * - */ - private static final long serialVersionUID = 2435351857958558386L; - - /** - * @deprecated - * Dialog to start Process - * - * @param AD_Process_ID process - * @param isSOTrx is sales trx - */ - public ProcessDialog (int AD_Process_ID, boolean isSOTrx) - { - this(null, AD_Process_ID, isSOTrx); - - } // ProcessDialog - - /** - * Dialog to start Process - * - * @param gc - * @param AD_Process_ID process - * @param isSOTrx is sales trx - */ - public ProcessDialog (GraphicsConfiguration gc, int AD_Process_ID, boolean isSOTrx) - { - super(gc); - if (log.isLoggable(Level.INFO)) log.info("Process=" + AD_Process_ID + "; SOTrx=" + isSOTrx); - enableEvents(AWTEvent.WINDOW_EVENT_MASK); - m_AD_Process_ID = AD_Process_ID; - m_WindowNo = AEnv.createWindowNo (this); - Env.setContext(Env.getCtx(), m_WindowNo, "IsSOTrx", isSOTrx ? "Y" : "N"); - try - { - jbInit(); - } - catch(Exception ex) - { - log.log(Level.SEVERE, "", ex); - } - } // ProcessDialog - - private int m_AD_Process_ID; - private int m_WindowNo; - private String m_Name = null; - private boolean m_IsReport = false; - private int[] m_ids = null; - private boolean m_isLocked = false; - private StringBuffer m_messageText = new StringBuffer(); - private String m_ShowHelp = null; // Determine if a Help Process Window is shown - /** Logger */ - private static CLogger log = CLogger.getCLogger(ProcessDialog.class); - // - - private CPanel dialog = new CPanel() - { - /** - * - */ - private static final long serialVersionUID = 428410337428677817L; - - public Dimension getPreferredSize() { - Dimension d = super.getPreferredSize(); - Dimension m = getMinimumSize(); - if ( d.height < m.height || d.width < m.width ) { - Dimension d1 = new Dimension(); - d1.height = Math.max(d.height, m.height); - d1.width = Math.max(d.width, m.width); - return d1; - } else - return d; - } - }; - private BorderLayout mainLayout = new BorderLayout(); - private CPanel southPanel = new CPanel(); - private CButton bOK = ConfirmPanel.createOKButton(true); - private FlowLayout southLayout = new FlowLayout(); - private JEditorPane message = new JEditorPane() - { - /** - * - */ - private static final long serialVersionUID = -2271852928089812014L; - - public Dimension getPreferredSize() { - Dimension d = super.getPreferredSize(); - Dimension m = getMaximumSize(); - if ( d.height > m.height || d.width > m.width ) { - Dimension d1 = new Dimension(); - d1.height = Math.min(d.height, m.height); - d1.width = Math.min(d.width, m.width); - return d1; - } else - return d; - } - }; - private JScrollPane messagePane = new JScrollPane(message) - { - /** - * - */ - private static final long serialVersionUID = 3605316311642118445L; - - public Dimension getPreferredSize() { - Dimension d = super.getPreferredSize(); - Dimension m = getMaximumSize(); - if ( d.height > m.height || d.width > m.width ) { - Dimension d1 = new Dimension(); - d1.height = Math.min(d.height, m.height); - d1.width = Math.min(d.width, m.width); - return d1; - } else - return d; - } - }; - private CButton bPrint = ConfirmPanel.createPrintButton(true); - - private CPanel centerPanel = null; - private ProcessParameterPanel parameterPanel = null; - private JSeparator separator = new JSeparator(); - private ProcessInfo m_pi = null; - private CComboBoxfSavedName = new CComboBox(); - private CButton bSave = new CButton(); - private CButton bDelete = new CButton(); - private List savedParams; - private CLabel lSaved = new CLabel(Msg.getMsg(Env.getCtx(), "SavedParameter")); - - /** - * Static Layout - * @throws Exception - */ - private void jbInit() throws Exception - { - setIconImage(Env.getImage("mProcess.png")); - // - dialog.setLayout(mainLayout); - dialog.setMinimumSize(new Dimension(500, 200)); - bOK.addActionListener(this); - bPrint.addActionListener(this); - fSavedName.setToolTipText (Msg.getMsg(Env.getCtx(),"SavedParameter")); - fSavedName.setEditable(true); - fSavedName.addActionListener(this); - bSave.setIcon(new ImageIcon(org.compiere.Adempiere.class.getResource("images/Save24.gif"))); - bSave.setMargin(new Insets(2, 2, 2, 2)); - bSave.setToolTipText(Msg.getMsg(Env.getCtx(),"Save")); - bSave.addActionListener(this); - bSave.setEnabled(false); - bDelete.setIcon(new ImageIcon(org.compiere.Adempiere.class.getResource("images/Delete24.gif"))); - bDelete.setMargin(new Insets(2, 2, 2, 2)); - bDelete.setToolTipText(Msg.getMsg(Env.getCtx(),"Delete")); - bDelete.addActionListener(this); - bDelete.setEnabled(false); - // - southPanel.setLayout(southLayout); - southLayout.setAlignment(FlowLayout.RIGHT); - message.setContentType("text/html"); - message.setEditable(false); - message.setBackground(Color.white); - message.setFocusable(true); - getContentPane().add(dialog); - dialog.add(southPanel, BorderLayout.SOUTH); - - southPanel.add(lSaved,"wrap"); - southPanel.add(fSavedName, "w :200:"); - southPanel.add(bSave, null); - southPanel.add(bDelete, null); - southPanel.add(bPrint, "span, split 2, align right, pushx"); - southPanel.add(bOK, null); - dialog.add(messagePane, BorderLayout.NORTH); - messagePane.setBorder(null); - messagePane.setMaximumSize(new Dimension(600, 300)); - centerPanel = new CPanel(); - centerPanel.setBorder(null); - centerPanel.setLayout(new BorderLayout()); - dialog.add(centerPanel, BorderLayout.CENTER); - mainLayout.setVgap(2); - // - this.getRootPane().setDefaultButton(bOK); - } // jbInit - - /** - * Set Visible - * (set focus to OK if visible) - * @param visible true if visible - */ - public void setVisible (boolean visible) - { - super.setVisible(visible); - if (visible) { - bOK.requestFocus(); - } - } // setVisible - - /** - * Dispose - */ - public void dispose() - { - Env.clearWinContext(m_WindowNo); - super.dispose(); - } // dispose - - - /** - * Dynamic Init - * @return true, if there is something to process (start from menu) - */ - public boolean init() - { - log.config(""); - // - boolean trl = !Env.isBaseLanguage(Env.getCtx(), "AD_Process"); - String sql = "SELECT Name, Description, Help, IsReport, ShowHelp " - + "FROM AD_Process " - + "WHERE AD_Process_ID=?"; - if (trl) - sql = "SELECT t.Name, t.Description, t.Help, p.IsReport, p.ShowHelp " - + "FROM AD_Process p, AD_Process_Trl t " - + "WHERE p.AD_Process_ID=t.AD_Process_ID" - + " AND p.AD_Process_ID=? AND t.AD_Language=?"; - PreparedStatement pstmt = null; - ResultSet rs = null; - try - { - pstmt = DB.prepareStatement(sql, null); - pstmt.setInt(1, m_AD_Process_ID); - if (trl) - pstmt.setString(2, Env.getAD_Language(Env.getCtx())); - rs = pstmt.executeQuery(); - if (rs.next()) - { - m_Name = rs.getString(1); - m_IsReport = rs.getString(4).equals("Y"); - m_ShowHelp = rs.getString(5); - // - m_messageText.append(""); - String s = rs.getString(2); // Description - if (rs.wasNull()) - m_messageText.append(Msg.getMsg(Env.getCtx(), "StartProcess?")); - else - m_messageText.append(s); - m_messageText.append(""); - s = rs.getString(3); // Help - if (!rs.wasNull()) - m_messageText.append("

    ").append(s).append("

    "); - } - } - catch (SQLException e) - { - throw new DBException(e, sql); - } - finally - { - DB.close(rs, pstmt); - rs = null; pstmt = null; - } - - if (m_Name == null) { - throw new AdempiereException("@NotFound@ @AD_Process_ID@="+m_AD_Process_ID+". @CheckMissingTrl@"); - } - // - this.setTitle(m_Name); - message.setText(m_messageText.toString()); - bOK.setText(Msg.getMsg(Env.getCtx(), "Start")); - - // Similar to APanel.actionButton - m_pi = new ProcessInfo(m_Name, m_AD_Process_ID); - m_pi.setAD_User_ID (Env.getAD_User_ID(Env.getCtx())); - m_pi.setAD_Client_ID(Env.getAD_Client_ID(Env.getCtx())); - parameterPanel = new ProcessParameterPanel(m_WindowNo, m_pi); - parameterPanel.setWindow(this); - centerPanel.removeAll(); - if (parameterPanel.init()) { - // hasfields - centerPanel.add(separator, BorderLayout.NORTH); - centerPanel.add(parameterPanel, BorderLayout.CENTER); - } else { - if (m_ShowHelp != null && MProcess.SHOWHELP_DonTShowHelp.equals(m_ShowHelp)) { - bOK.doClick(); // don't ask first click - // anyway show resulting window - } - } - - // Check if the process is a silent one - if(m_ShowHelp != null && MProcess.SHOWHELP_RunSilently_TakeDefaults.equals(m_ShowHelp)) - bOK.doClick(); - - querySaved(); - - dialog.revalidate(); - return true; - } // init - - private void querySaved() { - //user query - savedParams = MPInstance.get(Env.getCtx(), m_AD_Process_ID, Env.getContextAsInt(Env.getCtx(), "#AD_User_ID")); - String[] queries = new String[savedParams.size()+1]; - int i = 0; - queries[i++] = ""; - for (MPInstance instance : savedParams) - { - queries[i++] = instance.getName(); - } - fSavedName.setModel(new DefaultComboBoxModel(queries)); - fSavedName.setValue(""); - } - - /** - * ActionListener (Start) - * @param e ActionEvent - */ - public void actionPerformed (ActionEvent e) - { - - String saveName = null; - if (fSavedName.getSelectedItem() != null) - saveName = fSavedName.getSelectedItem().toString(); - - boolean lastRun = ("** " + Msg.getMsg(Env.getCtx(), "LastRun") + " **").equals(saveName); - - if (e.getSource() == bOK) - { - if (bOK.getText().length() == 0) - dispose(); - else - { - // Trx trx = Trx.get(Trx.createTrxName("ProcessDialog"), true); - ProcessCtl.process(this, m_WindowNo, parameterPanel, m_pi, null); - } - } - else if (e.getSource() == fSavedName) - { - if (savedParams != null && saveName != null) - { - for (int i = 0; i < savedParams.size(); i++) - { - if (savedParams.get(i).getName().equals(saveName)) - { - loadSavedParams(savedParams.get(i)); - } - } - } - boolean enabled = !Util.isEmpty(saveName); - bSave.setEnabled(enabled && !lastRun); - bDelete.setEnabled(enabled && fSavedName.getSelectedIndex() > -1 && !lastRun); - } - else if (e.getSource() == bSave && fSavedName != null && !lastRun) - { - // Update existing - if (fSavedName.getSelectedIndex() > -1 && savedParams != null) - { - for (int i = 0; i < savedParams.size(); i++) - { - if (savedParams.get(i).getName().equals(saveName)) - { - m_pi.setAD_PInstance_ID(savedParams.get(i).getAD_PInstance_ID()); - for (MPInstancePara para : savedParams.get(i).getParameters()) - { - para.deleteEx(true); - } - parameterPanel.saveParameters(); - } - } - } - // create new - else { - MPInstance instance = null; - try - { - instance = new MPInstance(Env.getCtx(), m_pi.getAD_Process_ID(), m_pi.getRecord_ID()); - instance.setName(saveName); - instance.saveEx(); - - m_pi.setAD_PInstance_ID(instance.getAD_PInstance_ID()); - // Get Parameters - if (parameterPanel != null) { - if (!parameterPanel.saveParameters()) - { - throw new AdempiereSystemError(Msg.getMsg(Env.getCtx(), "SaveParameterError")); - } - } - } - catch (Exception ex) - { - ADialog.warn(m_WindowNo, this, ex.getLocalizedMessage()); - } - } - querySaved(); - fSavedName.setSelectedItem(saveName); - } - else if (e.getSource() == bDelete && fSavedName != null && !lastRun ) - { - Object o = fSavedName.getSelectedItem(); - if (savedParams != null && o != null) - { - String selected = o.toString(); - for (int i = 0; i < savedParams.size(); i++) - { - if (savedParams.get(i).getName().equals(selected)) - { - savedParams.get(i).deleteEx(true); - } - } - } - querySaved(); - } - - else if (e.getSource() == bPrint) - printScreen(); - } // actionPerformed - - - private void loadSavedParams(MPInstance instance) { - parameterPanel.loadParameters(instance); - } - - /** - * Lock User Interface - * Called from the Worker before processing - * @param pi process info - */ - public void lockUI (ProcessInfo pi) - { - bOK.setText(""); - bOK.setEnabled(false); - this.setEnabled(false); - m_isLocked = true; - } // lockUI - - /** - * Unlock User Interface. - * Called from the Worker when processing is done - * @param pi process info - */ - public void unlockUI (ProcessInfo pi) - { - ProcessInfoUtil.setLogFromDB(pi); - m_messageText.append("

    ** ") - .append(pi.getSummary()) - .append("

    "); - m_messageText.append(pi.getLogInfo(true)); - message.setText(m_messageText.toString()); - message.setCaretPosition(message.getDocument().getLength()); // scroll down - m_ids = pi.getIDs(); - // - bOK.setEnabled(true); - this.setEnabled(true); - m_isLocked = false; - - //no longer needed, hide to give more space to display log - dialog.remove(centerPanel); - messagePane.setMaximumSize(null); - dialog.remove(messagePane); - dialog.add(messagePane, BorderLayout.CENTER); - - this.validate(); - AEnv.showCenterScreen(this); - // - afterProcessTask(); - // Close automatically - if (m_IsReport && !pi.isError()) - bOK.doClick(); - - // If the process is a silent one and no errors occurred, close the dialog - if(m_ShowHelp != null && MProcess.SHOWHELP_RunSilently_TakeDefaults.equals(m_ShowHelp)) - bOK.doClick(); - } // unlockUI - - /** - * Is the UI locked (Internal method) - * @return true, if UI is locked - */ - public boolean isUILocked() - { - return m_isLocked; - } // isUILocked - - /** - * Method to be executed async. - * Called from the ASyncProcess worker - * @param pi process info - */ - public void executeASync (ProcessInfo pi) - { - log.config("-"); - } // executeASync - - - /************************************************************************** - * Optional Processing Task - */ - private void afterProcessTask() - { - // something to do? - if (m_ids != null && m_ids.length > 0) - { - log.config(""); - // Print invoices - if (m_AD_Process_ID == PROCESS_C_INVOICE_GENERATE) - printInvoices(); - else if (m_AD_Process_ID == PROCESS_M_INOUT_GENERATE) - printShipments(); - } - - } // afterProcessTask - - - /************************************************************************** - * Print Shipments - */ - private void printShipments() - { - if (m_ids == null) - return; - if (!ADialog.ask(m_WindowNo, this, "PrintShipments")) - return; - m_messageText.append("

    ").append(Msg.getMsg(Env.getCtx(), "PrintShipments")).append("

    "); - message.setText(m_messageText.toString()); - int retValue = ADialogDialog.A_CANCEL; - do - { - // Loop through all items - for (int i = 0; i < m_ids.length; i++) - { - int M_InOut_ID = m_ids[i]; - ReportCtl.startDocumentPrint(ReportEngine.SHIPMENT, M_InOut_ID, this, AEnv.getWindowNo(this), true); - } - ADialogDialog d = new ADialogDialog (this, - Env.getHeader(Env.getCtx(), m_WindowNo), - Msg.getMsg(Env.getCtx(), "PrintoutOK?"), - JOptionPane.QUESTION_MESSAGE); - retValue = d.getReturnCode(); - } - while (retValue == ADialogDialog.A_CANCEL); - } // printInvoices - - /** - * Print Invoices - */ - private void printInvoices() - { - if (m_ids == null) - return; - if (!ADialog.ask(m_WindowNo, this, "PrintInvoices")) - return; - m_messageText.append("

    ").append(Msg.getMsg(Env.getCtx(), "PrintInvoices")).append("

    "); - message.setText(m_messageText.toString()); - int retValue = ADialogDialog.A_CANCEL; - do - { - // Loop through all items - for (int i = 0; i < m_ids.length; i++) - { - int AD_Invoice_ID = m_ids[i]; - ReportCtl.startDocumentPrint(ReportEngine.INVOICE, AD_Invoice_ID, this, AEnv.getWindowNo(this), true); - } - ADialogDialog d = new ADialogDialog (this, - Env.getHeader(Env.getCtx(), m_WindowNo), - Msg.getMsg(Env.getCtx(), "PrintoutOK?"), - JOptionPane.QUESTION_MESSAGE); - retValue = d.getReturnCode(); - } - while (retValue == ADialogDialog.A_CANCEL); - } // printInvoices - - /** - * Print Screen - */ - private void printScreen() - { - PrintScreenPainter.printScreen (this); - } // printScreen - - @Override - public void statusUpdate(String status) { - message.setText(status); - } - - @Override - public void ask(String message, Callback callback) { - boolean b = ADialog.ask(m_WindowNo, this, message); - if (callback != null) { - callback.onCallback(b); - } - } - - @Override - public void download(File file) { - // TODO Auto-generated method stub - - } - - @Override - public void askForInput(String message, Callback callback) { - String s = ADialog.askForInput(m_WindowNo, this, message); - if(callback != null) - callback.onCallback(s); - } - -} // ProcessDialog diff --git a/org.adempiere.ui.swing/src/org/compiere/apps/ProcessModalDialog.java b/org.adempiere.ui.swing/src/org/compiere/apps/ProcessModalDialog.java deleted file mode 100644 index d215a0c35e..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/apps/ProcessModalDialog.java +++ /dev/null @@ -1,349 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 2007 Low Heng Sin * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - *****************************************************************************/ -package org.compiere.apps; - -import java.awt.BorderLayout; -import java.awt.Color; -import java.awt.Dimension; -import java.awt.Frame; -import java.awt.Insets; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.sql.PreparedStatement; -import java.sql.ResultSet; -import java.sql.SQLException; -import java.util.Properties; -import java.util.logging.Level; - -import javax.swing.JEditorPane; -import javax.swing.JScrollPane; -import javax.swing.JSeparator; - -import org.adempiere.exceptions.DBException; -import org.adempiere.util.IProcessUI; -import org.compiere.model.MProcess; -import org.compiere.process.ProcessInfo; -import org.compiere.swing.CButton; -import org.compiere.swing.CDialog; -import org.compiere.swing.CPanel; -import org.compiere.util.CLogger; -import org.compiere.util.DB; -import org.compiere.util.Env; -import org.compiere.util.Msg; - -/** - * [ 1639242 ] Inconsistent appearance of Process/Report Dialog - * - * Modal Dialog to Start process. - * Displays information about the process - * and lets the user decide to start it - * and displays results (optionally print them). - * Calls ProcessCtl to execute. - * @author Low Heng Sin - * @author arboleda - globalqss - * - Implement ShowHelp option on processes and reports - */ -public class ProcessModalDialog extends CDialog - implements ActionListener -{ - - /** - * - */ - private static final long serialVersionUID = -1573751323319156081L; - - /** - * Dialog to start a process/report - * @param ctx - * @param parent - * @param title - * @param aProcess - * @param WindowNo - * @param AD_Process_ID - * @param tableId - * @param recordId - * @param autoStart - */ - public ProcessModalDialog (Properties ctx, Frame parent, String title, - IProcessUI aProcess, int WindowNo, int AD_Process_ID, - int tableId, int recordId, boolean autoStart) - { - super(parent, title, true); - if (log.isLoggable(Level.INFO)) log.info("Process=" + AD_Process_ID ); - m_ctx = ctx; - m_processUI = aProcess; - m_WindowNo = WindowNo; - m_AD_Process_ID = AD_Process_ID; - m_tableId = tableId; - m_recordId = recordId; - m_autoStart = autoStart; - try - { - jbInit(); - init(); - } - catch(Exception ex) - { - log.log(Level.SEVERE, "", ex); - } - } // ProcessDialog - - private IProcessUI m_processUI; - private int m_WindowNo; - private Properties m_ctx; - private int m_tableId; - private int m_recordId; - private boolean m_autoStart; - private int m_AD_Process_ID; - private String m_Name = null; - private StringBuffer m_messageText = new StringBuffer(); - private String m_ShowHelp = null; // Determine if a Help Process Window is shown - private boolean m_valid = true; - private String m_AD_Process_UU; - - /** Logger */ - private static CLogger log = CLogger.getCLogger(ProcessDialog.class); - // - - private CPanel dialog = new CPanel() - { - /** - * - */ - private static final long serialVersionUID = -8093428846912456722L; - - public Dimension getPreferredSize() { - Dimension d = super.getPreferredSize(); - Dimension m = getMinimumSize(); - if ( d.height < m.height || d.width < m.width ) { - Dimension d1 = new Dimension(); - d1.height = Math.max(d.height, m.height); - d1.width = Math.max(d.width, m.width); - return d1; - } else - return d; - } - }; - private BorderLayout mainLayout = new BorderLayout(); - private ConfirmPanel southPanel = new ConfirmPanel(true); - private CButton bOK = null; - private JEditorPane message = new JEditorPane() - { - /** - * - */ - private static final long serialVersionUID = 1218214722657165651L; - - public Dimension getPreferredSize() { - Dimension d = super.getPreferredSize(); - Dimension m = getMaximumSize(); - if ( d.height > m.height || d.width > m.width ) { - Dimension d1 = new Dimension(); - d1.height = Math.min(d.height, m.height); - d1.width = Math.min(d.width, m.width); - return d1; - } else - return d; - } - }; - private JScrollPane messagePane = new JScrollPane(message) - { - /** - * - */ - private static final long serialVersionUID = 8653555758412012675L; - - public Dimension getPreferredSize() { - Dimension d = super.getPreferredSize(); - Dimension m = getMaximumSize(); - if ( d.height > m.height || d.width > m.width ) { - Dimension d1 = new Dimension(); - d1.height = Math.min(d.height, m.height); - d1.width = Math.min(d.width, m.width); - return d1; - } else - return d; - } - }; - - private CPanel centerPanel = null; - private ProcessParameterPanel parameterPanel = null; - private JSeparator separator = new JSeparator(); - private ProcessInfo m_pi = null; - - /** - * Static Layout - * @throws Exception - */ - private void jbInit() throws Exception - { - dialog.setLayout(mainLayout); - dialog.setMinimumSize(new Dimension(500, 200)); - southPanel.addActionListener(this); - bOK = southPanel.getOKButton(); - // - message.setContentType("text/html"); - message.setEditable(false); - message.setBackground(Color.white); - message.setFocusable(false); - getContentPane().add(dialog); - dialog.add(southPanel, BorderLayout.SOUTH); - dialog.add(messagePane, BorderLayout.NORTH); - messagePane.setBorder(null); - messagePane.setMaximumSize(new Dimension(600, 300)); - centerPanel = new CPanel(); - centerPanel.setBorder(null); - centerPanel.setLayout(new BorderLayout()); - dialog.add(centerPanel, BorderLayout.CENTER); - // - this.getRootPane().setDefaultButton(bOK); - } // jbInit - - /** - * Set Visible - * (set focus to OK if visible) - * @param visible true if visible - */ - public void setVisible (boolean visible) - { - super.setVisible(visible); - if (visible) { - bOK.requestFocus(); - } - } // setVisible - - /** - * Dispose - */ - public void dispose() - { - m_valid = false; - parameterPanel.restoreContext(); // teo_sarca [ 1699826 ] - super.dispose(); - } // dispose - - public boolean isValidDialog() - { - return m_valid; - } - - /** - * Dynamic Init - * @return true, if there is something to process (start from menu) - */ - public boolean init() - { - log.config(""); - // - boolean trl = !Env.isBaseLanguage(m_ctx, "AD_Process"); - String sql = "SELECT Name, Description, Help, IsReport, ShowHelp, AD_Process_UU " - + "FROM AD_Process " - + "WHERE AD_Process_ID=?"; - if (trl) - sql = "SELECT t.Name, t.Description, t.Help, p.IsReport, p.ShowHelp, AD_Process_UU " - + "FROM AD_Process p, AD_Process_Trl t " - + "WHERE p.AD_Process_ID=t.AD_Process_ID" - + " AND p.AD_Process_ID=? AND t.AD_Language=?"; - PreparedStatement pstmt = null; - ResultSet rs = null; - try - { - pstmt = DB.prepareStatement(sql, null); - pstmt.setInt(1, m_AD_Process_ID); - if (trl) - pstmt.setString(2, Env.getAD_Language(m_ctx)); - rs = pstmt.executeQuery(); - if (rs.next()) - { - m_Name = rs.getString(1); - m_ShowHelp = rs.getString(5); - // - m_messageText.append(""); - String s = rs.getString(2); // Description - if (rs.wasNull()) - m_messageText.append(Msg.getMsg(m_ctx, "StartProcess?")); - else - m_messageText.append(s); - m_messageText.append(""); - - s = rs.getString(3); // Help - if (!rs.wasNull()) - m_messageText.append("

    ").append(s).append("

    "); - - m_AD_Process_UU = rs.getString(6); - } - } - catch (SQLException e) - { - throw new DBException(e, sql); - } - finally - { - DB.close(rs, pstmt); - rs = null; pstmt = null; - } - - if (m_Name == null) - return false; - // - this.setTitle(m_Name); - message.setMargin(new Insets(10,10,10,10)); - message.setText(m_messageText.toString()); - - // Move from APanel.actionButton - m_pi = new ProcessInfo(m_Name, m_AD_Process_ID, m_tableId, m_recordId); - m_pi.setAD_Process_UU(m_AD_Process_UU); - m_pi.setAD_User_ID (Env.getAD_User_ID(Env.getCtx())); - m_pi.setAD_Client_ID(Env.getAD_Client_ID(Env.getCtx())); - parameterPanel = new ProcessParameterPanel(m_WindowNo, m_pi); - parameterPanel.setWindow(this); - centerPanel.removeAll(); - if (parameterPanel.init()) { - // hasfields - centerPanel.add(separator, BorderLayout.NORTH); - centerPanel.add(parameterPanel, BorderLayout.CENTER); - } else { - if (m_ShowHelp != null && MProcess.SHOWHELP_DonTShowHelp.equals(m_ShowHelp)) { - m_autoStart = true; - } - if (m_autoStart) - bOK.doClick(); // don't ask first click - } - - // Check if the process is a silent one - if(m_ShowHelp != null && MProcess.SHOWHELP_RunSilently_TakeDefaults.equals(m_ShowHelp)) - bOK.doClick(); - - dialog.revalidate(); - return true; - } // init - - /** - * ActionListener (Start) - * @param e ActionEvent - */ - public void actionPerformed (ActionEvent e) - { - if (e.getSource() == bOK) - { - ProcessCtl.process(m_processUI, m_WindowNo, parameterPanel, m_pi, null); - dispose(); - } - - else if (e.getSource() == southPanel.getCancelButton()) - dispose(); - } // actionPerformed - -} // ProcessDialog diff --git a/org.adempiere.ui.swing/src/org/compiere/apps/ProcessParameter.java b/org.adempiere.ui.swing/src/org/compiere/apps/ProcessParameter.java deleted file mode 100644 index d2ed7d0e9d..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/apps/ProcessParameter.java +++ /dev/null @@ -1,573 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ -package org.compiere.apps; - -import java.awt.BorderLayout; -import java.awt.Component; -import java.awt.Frame; -import java.awt.GridBagConstraints; -import java.awt.GridBagLayout; -import java.awt.Insets; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.beans.PropertyChangeEvent; -import java.beans.PropertyVetoException; -import java.beans.VetoableChangeListener; -import java.math.BigDecimal; -import java.sql.PreparedStatement; -import java.sql.ResultSet; -import java.sql.SQLException; -import java.sql.Timestamp; -import java.util.ArrayList; -import java.util.logging.Level; - -import javax.swing.Box; -import javax.swing.JLabel; - -import org.compiere.grid.ed.VEditor; -import org.compiere.grid.ed.VEditorFactory; -import org.compiere.model.GridField; -import org.compiere.model.GridFieldVO; -import org.compiere.model.MClient; -import org.compiere.model.MPInstancePara; -import org.compiere.model.MProcess; -import org.compiere.process.ProcessInfo; -import org.compiere.swing.CDialog; -import org.compiere.swing.CPanel; -import org.compiere.util.CLogger; -import org.compiere.util.DB; -import org.compiere.util.Env; - -/** - * Parameter Dialog. - * - called from ProcessCtl - * - checks, if parameters exist and inquires and saves them - * - * @author Jorg Janke - * @version $Id: ProcessParameter.java,v 1.2 2006/07/30 00:51:27 jjanke Exp $ - */ -public class ProcessParameter extends CDialog - implements ActionListener, VetoableChangeListener -{ - /** - * - */ - private static final long serialVersionUID = 5813968036015697042L; - - /** - * Dynamic generated Parameter Dialog screen. - * Called from ProcessCtl.process - * - * @param frame frame - * @param WindowNo window - * @param pi process info - */ - public ProcessParameter (Frame frame, int WindowNo, ProcessInfo pi) - { - super(frame, pi.getTitle(), true); - m_frame = frame; - try - { - jbInit(); - } - catch(Exception ex) - { - log.log(Level.SEVERE, ex.getMessage()); - } - // - m_WindowNo = WindowNo; - m_processInfo = pi; - - // TODO: set m_AD_Window_ID, is AD_Window_ID of window below this dialog - // - } // ProcessParameter - - private Frame m_frame; - private int m_WindowNo; - // AD_Window of window below this dialog in case show parameter dialog panel - private int m_AD_Window_ID; - private ProcessInfo m_processInfo; - private boolean m_isOK = false; - /** Logger */ - private static CLogger log = CLogger.getCLogger(ProcessParameter.class); - // - private GridBagConstraints gbc = new GridBagConstraints(); - private Insets nullInset = new Insets(0,0,0,0); - private Insets labelInset = new Insets(2,12,2,0); // top,left,bottom,right - private Insets fieldInset = new Insets(2,5,2,0); // top,left,bottom,right - private Insets fieldInsetRight = new Insets(2,5,2,12); // top,left,bottom,right - private int m_line = 0; - // - private ArrayList m_vEditors = new ArrayList(); - private ArrayList m_vEditors2 = new ArrayList(); // for ranges - private ArrayList m_mFields = new ArrayList(); - private ArrayList m_mFields2 = new ArrayList(); - // - private CPanel mainPanel = new CPanel(); - private BorderLayout mainLayout = new BorderLayout(); - private CPanel centerPanel = new CPanel(); - private GridBagLayout centerLayout = new GridBagLayout(); - private ConfirmPanel confirmPanel = new ConfirmPanel(true); - - /** - * Static Layout - * @throws Exception - */ - void jbInit() throws Exception - { - mainPanel.setLayout(mainLayout); - centerPanel.setLayout(centerLayout); - this.getContentPane().add(mainPanel); - mainPanel.add(centerPanel, BorderLayout.CENTER); - mainPanel.add(confirmPanel, BorderLayout.SOUTH); - confirmPanel.addActionListener(this); - } // jbInit - - /** - * Dispose - */ - public void dispose() - { - m_vEditors.clear(); - m_vEditors2.clear(); - m_mFields.clear(); - m_mFields2.clear(); - this.removeAll(); - super.dispose(); - } // dispose - - /** - * Read Fields to display - * @return true if loaded OK - */ - public boolean initDialog() - { - log.config(""); - - // Prepare panel - gbc.anchor = GridBagConstraints.NORTHWEST; - gbc.weightx = 0; - gbc.weighty = 0; - gbc.gridy = m_line++; - gbc.gridx = 0; - gbc.gridwidth = 1; - gbc.insets = nullInset; - gbc.fill = GridBagConstraints.HORIZONTAL; - centerPanel.add(Box.createVerticalStrut(10), gbc); // top gap 10+2=12 - - // ASP - MClient client = MClient.get(Env.getCtx()); - String ASPFilter = ""; - if (client.isUseASP()) - ASPFilter = - " AND ( p.AD_Process_Para_ID IN ( " - // Just ASP subscribed process parameters for client " - + " SELECT pp.AD_Process_Para_ID " - + " FROM ASP_Process_Para pp, ASP_Process p, ASP_Level l, ASP_ClientLevel cl " - + " WHERE p.ASP_Level_ID = l.ASP_Level_ID " - + " AND cl.AD_Client_ID = " + client.getAD_Client_ID() - + " AND cl.ASP_Level_ID = l.ASP_Level_ID " - + " AND pp.ASP_Process_ID = p.ASP_Process_ID " - + " AND pp.IsActive = 'Y' " - + " AND p.IsActive = 'Y' " - + " AND l.IsActive = 'Y' " - + " AND cl.IsActive = 'Y' " - + " AND pp.ASP_Status = 'S') " // Show - + " OR p.AD_Process_Para_ID IN ( " - // + show ASP exceptions for client - + " SELECT AD_Process_Para_ID " - + " FROM ASP_ClientException ce " - + " WHERE ce.AD_Client_ID = " + client.getAD_Client_ID() - + " AND ce.IsActive = 'Y' " - + " AND ce.AD_Process_Para_ID IS NOT NULL " - + " AND ce.AD_Tab_ID IS NULL " - + " AND ce.AD_Field_ID IS NULL " - + " AND ce.ASP_Status = 'S') " // Show - + " ) " - + " AND p.AD_Process_Para_ID NOT IN ( " - // minus hide ASP exceptions for client - + " SELECT AD_Process_Para_ID " - + " FROM ASP_ClientException ce " - + " WHERE ce.AD_Client_ID = " + client.getAD_Client_ID() - + " AND ce.IsActive = 'Y' " - + " AND ce.AD_Process_Para_ID IS NOT NULL " - + " AND ce.AD_Tab_ID IS NULL " - + " AND ce.AD_Field_ID IS NULL " - + " AND ce.ASP_Status = 'H')"; // Hide - // - String sql = null; - if (Env.isBaseLanguage(Env.getCtx(), "AD_Process_Para")) - sql = "SELECT p.Name, p.Description, p.Help, " - + "p.AD_Reference_ID, p.AD_Process_Para_ID, " - + "p.FieldLength, p.IsMandatory, p.IsRange, p.ColumnName, p.ReadOnlyLogic, p.DisplayLogic, p.IsEncrypted, " - + "p.DefaultValue, p.DefaultValue2, p.VFormat, p.ValueMin, p.ValueMax, " - + "p.SeqNo, p.AD_Reference_Value_ID, vr.Code AS ValidationCode " - + "FROM AD_Process_Para p" - + " LEFT OUTER JOIN AD_Val_Rule vr ON (p.AD_Val_Rule_ID=vr.AD_Val_Rule_ID) " - + "WHERE p.AD_Process_ID=?" // 1 - + " AND p.IsActive='Y' " - + ASPFilter + " ORDER BY SeqNo"; - else - sql = "SELECT t.Name, t.Description, t.Help, " - + "p.AD_Reference_ID, p.AD_Process_Para_ID, " - + "p.FieldLength, p.IsMandatory, p.IsRange, p.ColumnName, p.ReadOnlyLogic, p.DisplayLogic, p.IsEncrypted, " - + "p.DefaultValue, p.DefaultValue2, p.VFormat, p.ValueMin, p.ValueMax, " - + "p.SeqNo, p.AD_Reference_Value_ID, vr.Code AS ValidationCode " - + "FROM AD_Process_Para p" - + " INNER JOIN AD_Process_Para_Trl t ON (p.AD_Process_Para_ID=t.AD_Process_Para_ID)" - + " LEFT OUTER JOIN AD_Val_Rule vr ON (p.AD_Val_Rule_ID=vr.AD_Val_Rule_ID) " - + "WHERE p.AD_Process_ID=?" // 1 - + " AND t.AD_Language='" + Env.getAD_Language(Env.getCtx()) + "'" - + " AND p.IsActive='Y' " - + ASPFilter + " ORDER BY SeqNo"; - - // Create Fields - boolean hasFields = false; - PreparedStatement pstmt = null; - ResultSet rs = null; - try - { - pstmt = DB.prepareStatement(sql, null); - pstmt.setInt(1, m_processInfo.getAD_Process_ID()); - rs = pstmt.executeQuery(); - while (rs.next()) - { - hasFields = true; - createField (rs); - } - } - catch(SQLException e) - { - log.log(Level.SEVERE, sql, e); - } - finally - { - DB.close(rs, pstmt); - rs = null; - pstmt = null; - } - - // both vectors the same? - if (m_mFields.size() != m_mFields2.size() - || m_mFields.size() != m_vEditors.size() - || m_mFields2.size() != m_vEditors2.size()) - log.log(Level.SEVERE, "View & Model vector size is different"); - - // clean up - if (hasFields) - { - gbc.gridy = m_line++; - centerPanel.add(Box.createVerticalStrut(10), gbc); // bottom gap - gbc.gridx = 3; - centerPanel.add(Box.createHorizontalStrut(12), gbc); // right gap - AEnv.positionCenterWindow(m_frame, this); - } - else - dispose(); - return hasFields; - } // initDialog - - - /** - * Create Field. - * - creates Fields and adds it to m_mFields list - * - creates Editor and adds it to m_vEditors list - * Handeles Ranges by adding additional mField/vEditor. - *

    - * mFields are used for default value and mandatory checking; - * vEditors are used to retrieve the value (no data binding) - * - * @param rs result set - */ - private void createField (ResultSet rs) - { - // Create Field - GridFieldVO voF = GridFieldVO.createParameter(Env.getCtx(), m_WindowNo, m_processInfo.getAD_Process_ID(), m_AD_Window_ID, 0, rs); - GridField mField = new GridField (voF); - m_mFields.add(mField); // add to Fields - - // Label Preparation - gbc.gridy = m_line++; - gbc.gridwidth = 1; - gbc.fill = GridBagConstraints.HORIZONTAL; // required for right justified - gbc.gridx = 0; - gbc.weightx = 0; - JLabel label = VEditorFactory.getLabel(mField); - if (label == null) - { - gbc.insets = nullInset; - centerPanel.add(Box.createHorizontalStrut(12), gbc); // left gap - } - else - { - gbc.insets = labelInset; - centerPanel.add(label, gbc); - } - - // Field Preparation - gbc.insets = fieldInset; - gbc.fill = GridBagConstraints.HORIZONTAL; - gbc.gridwidth = 1; - gbc.gridx = 1; - gbc.weightx = 1; - - // The Editor - VEditor vEditor = VEditorFactory.getEditor(mField, false); - vEditor.addVetoableChangeListener(this); - // MField => VEditor - New Field value to be updated to editor - mField.addPropertyChangeListener(vEditor); - // Set Default - Object defaultObject = mField.getDefaultForPanel(); - mField.setValue (defaultObject, true); - // - centerPanel.add ((Component)vEditor, gbc); - m_vEditors.add (vEditor); // add to Editors - // - if (voF.isRange) - { - // To Label - gbc.gridx = 2; - gbc.weightx = 0; - gbc.fill = GridBagConstraints.NONE; - centerPanel.add (new JLabel(" - "), gbc); - // To Field - gbc.gridx = 3; - gbc.insets = fieldInsetRight; - gbc.weightx = 1; - gbc.fill = GridBagConstraints.HORIZONTAL; - gbc.anchor = GridBagConstraints.WEST; - - // - GridFieldVO voF2 = GridFieldVO.createParameter(voF); - GridField mField2 = new GridField (voF2); - m_mFields2.add (mField2); - // The Editor - VEditor vEditor2 = VEditorFactory.getEditor(mField2, false); - // New Field value to be updated to editor - mField2.addPropertyChangeListener(vEditor2); - // Set Default - Object defaultObject2 = mField2.getDefaultForPanel(); - mField2.setValue (defaultObject2, true); - // - centerPanel.add ((Component)vEditor2, gbc); - m_vEditors2.add (vEditor2); - } - else - { - m_mFields2.add (null); - m_vEditors2.add (null); - } - } // createField - - /** - * Action Listener - * @param e event - */ - public void actionPerformed(ActionEvent e) - { - m_isOK = false; - if (e.getActionCommand().equals(ConfirmPanel.A_OK)) - { - // check if saving parameters is complete - if (saveParameters()) - { - m_isOK = true; - dispose(); - } - } - else if (e.getActionCommand().equals(ConfirmPanel.A_CANCEL)) - dispose(); - } // actionPerformed - - /** - * Editor Listener - * @param evt Event - * @exception PropertyVetoException if the recipient wishes to roll back. - */ - public void vetoableChange(PropertyChangeEvent evt) throws PropertyVetoException - { - // log.fine( "ProcessParameter.vetoableChange"); - String value = evt.getNewValue() == null ? "" : evt.getNewValue().toString(); - Env.setContext(Env.getCtx(), m_WindowNo, evt.getPropertyName(), value); - } // vetoableChange - - /** - * Save Parameter values - * @return true if parameters saved - */ - private boolean saveParameters() - { - log.config(""); - - /** - * Mandatory fields - * see - MTable.getMandatory - */ - StringBuilder sb = new StringBuilder(); - int size = m_mFields.size(); - for (int i = 0; i < size; i++) - { - GridField field = (GridField)m_mFields.get(i); - if (field.isMandatory(true)) // check context - { - VEditor vEditor = (VEditor)m_vEditors.get(i); - Object data = vEditor.getValue(); - if (data == null || data.toString().length() == 0) - { - field.setInserting (true); // set editable (i.e. updateable) otherwise deadlock - field.setError(true); - if (sb.length() > 0) - sb.append(", "); - sb.append(field.getHeader()); - } - else - field.setError(false); - // Check for Range - VEditor vEditor2 = (VEditor)m_vEditors2.get(i); - if (vEditor2 != null) - { - Object data2 = vEditor.getValue(); - GridField field2 = (GridField)m_mFields2.get(i); - if (data2 == null || data2.toString().length() == 0) - { - field.setInserting (true); // set editable (i.e. updateable) otherwise deadlock - field2.setError(true); - if (sb.length() > 0) - sb.append(", "); - sb.append(field.getHeader()); - } - else - field2.setError(false); - } // range field - } // mandatory - } // field loop - - - if (sb.length() != 0) - { - ADialog.error(m_WindowNo, this, "FillMandatory", sb.toString()); - return false; - } - - /********************************************************************** - * Save Now - */ - for (int i = 0; i < m_mFields.size(); i++) - { - // Get Values - VEditor editor = (VEditor)m_vEditors.get(i); - VEditor editor2 = (VEditor)m_vEditors2.get(i); - Object result = editor.getValue(); - Object result2 = null; - if (editor2 != null) - result2 = editor2.getValue(); - - // Don't save NULL values - if (result == null && result2 == null) - continue; - - // Create Parameter - MPInstancePara para = new MPInstancePara (Env.getCtx(), m_processInfo.getAD_PInstance_ID(), i); - GridField mField = (GridField)m_mFields.get(i); - para.setParameterName(mField.getColumnName()); - - // Date - if (result instanceof Timestamp || result2 instanceof Timestamp) - { - para.setP_Date((Timestamp)result); - if (editor2 != null && result2 != null) - para.setP_Date_To((Timestamp)result2); - } - // Integer - else if (result instanceof Integer || result2 instanceof Integer) - { - if (result != null) - { - Integer ii = (Integer)result; - para.setP_Number(ii.intValue()); - } - if (editor2 != null && result2 != null) - { - Integer ii = (Integer)result2; - para.setP_Number_To(ii.intValue()); - } - } - // BigDecimal - else if (result instanceof BigDecimal || result2 instanceof BigDecimal) - { - para.setP_Number ((BigDecimal)result); - if (editor2 != null && result2 != null) - para.setP_Number_To ((BigDecimal)result2); - } - // Boolean - else if (result instanceof Boolean) - { - Boolean bb = (Boolean)result; - String value = bb.booleanValue() ? "Y" : "N"; - para.setP_String (value); - // to does not make sense - } - // String - else - { - if (result != null) - para.setP_String (result.toString()); - if (editor2 != null && result2 != null) - para.setP_String_To (result2.toString()); - } - - // Info - para.setInfo (editor.getDisplay()); - if (editor2 != null) - para.setInfo_To (editor2.getDisplay()); - // - para.saveEx(); - if (log.isLoggable(Level.FINE)) log.fine(para.toString()); - } // for every parameter - - return true; - } // saveParameters - - /** - * Is everything OK? - * @return true if parameters saved correctly - */ - public boolean isOK() - { - return m_isOK; - } // isOK - - public void setVisible(boolean b) - { - MProcess m_process = new MProcess(Env.getCtx(), - m_processInfo.getAD_Process_ID(), null); - if(m_process.getShowHelp() != null && MProcess.SHOWHELP_RunSilently_TakeDefaults.equals(m_process.getShowHelp())) - { - // It is defined as a silent process - if(saveParameters()) - { - m_isOK = true; - dispose(); - } - } - else - { - // Not a silent process - super.setVisible(b); - } - } -} // ProcessParameter diff --git a/org.adempiere.ui.swing/src/org/compiere/apps/ProcessParameterPanel.java b/org.adempiere.ui.swing/src/org/compiere/apps/ProcessParameterPanel.java deleted file mode 100644 index f23308b744..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/apps/ProcessParameterPanel.java +++ /dev/null @@ -1,723 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 Adempiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - *****************************************************************************/ -package org.compiere.apps; - -import java.awt.BorderLayout; -import java.awt.Component; -import java.awt.GridBagConstraints; -import java.awt.GridBagLayout; -import java.awt.Insets; -import java.awt.Window; -import java.beans.PropertyChangeEvent; -import java.beans.PropertyVetoException; -import java.beans.VetoableChangeListener; -import java.math.BigDecimal; -import java.sql.PreparedStatement; -import java.sql.ResultSet; -import java.sql.SQLException; -import java.sql.Timestamp; -import java.util.ArrayList; -import java.util.logging.Level; - -import javax.swing.Box; -import javax.swing.JLabel; - -import org.adempiere.exceptions.DBException; -import org.compiere.grid.ed.VEditor; -import org.compiere.grid.ed.VEditorFactory; -import org.compiere.model.GridField; -import org.compiere.model.GridFieldVO; -import org.compiere.model.MClient; -import org.compiere.model.MLookup; -import org.compiere.model.MPInstance; -import org.compiere.model.MPInstancePara; -import org.compiere.process.ProcessInfo; -import org.compiere.swing.CLabel; -import org.compiere.swing.CPanel; -import org.compiere.util.CLogger; -import org.compiere.util.DB; -import org.compiere.util.Env; -import org.compiere.util.Msg; - -/** - * Process Parameter Panel, based on existing ProcessParameter dialog. - * - Embedded in ProcessDialog - * - checks, if parameters exist and inquires and saves them - * - * @author Low Heng Sin - * @author Juan David Arboleda (arboleda), GlobalQSS, [ 1795398 ] Process - * Parameter: add display and readonly logic - * @author Teo Sarca, www.arhipac.ro - *

  • BF [ 2548216 ] Process Param Panel is not showing any parameter if error - * @version 2006-12-01 - */ -public class ProcessParameterPanel extends CPanel implements VetoableChangeListener, IProcessParameter { - - /** - * - */ - private static final long serialVersionUID = -8583999032745045111L; - - /** - * Dynamic generated Parameter panel. - * @param WindowNo window - * @param pi process info - */ - public ProcessParameterPanel(int WindowNo, ProcessInfo pi) - { - try - { - jbInit(); - } - catch(Exception ex) - { - log.log(Level.SEVERE, ex.getMessage()); - } - // - m_WindowNo = WindowNo; - m_processInfo = pi; - // TODO: set m_AD_Window_ID, is AD_Window_ID of window below this dialog - // - } // ProcessParameterPanel - - private int m_WindowNo; - private ProcessInfo m_processInfo; - // AD_Window of window below this dialog in case show parameter dialog panel - private int m_AD_Window_ID; - /** Logger */ - private static CLogger log = CLogger.getCLogger(ProcessParameterPanel.class); - // - private GridBagConstraints gbc = new GridBagConstraints(); - private Insets nullInset = new Insets(0,0,0,0); - private Insets labelInset = new Insets(2,12,2,0); // top,left,bottom,right - private Insets fieldInset = new Insets(2,5,2,0); // top,left,bottom,right - private Insets fieldInsetRight = new Insets(2,5,2,12); // top,left,bottom,right - private int m_line = 0; - // - private ArrayList m_vEditors = new ArrayList(); - private ArrayList m_vEditors2 = new ArrayList(); // for ranges - private ArrayList m_mFields = new ArrayList(); - private ArrayList m_mFields2 = new ArrayList(); - private ArrayList m_separators = new ArrayList(); - private ArrayList m_labels = new ArrayList(); - // - private BorderLayout mainLayout = new BorderLayout(); - private CPanel centerPanel = new CPanel(); - private GridBagLayout centerLayout = new GridBagLayout(); - private Window m_win = null; - - /** - * Static Layout - * @throws Exception - */ - void jbInit() throws Exception - { - this.setLayout(mainLayout); - centerPanel.setLayout(centerLayout); - this.add(centerPanel, BorderLayout.CENTER); - } // jbInit - - /** - * Dispose - */ - public void dispose() - { - m_vEditors.clear(); - m_vEditors2.clear(); - m_mFields.clear(); - m_mFields2.clear(); - m_separators.clear(); - m_labels.clear(); - this.removeAll(); - } // dispose - - /** - * Read Fields to display - * @return true if loaded OK - */ - public boolean init() - { - log.config(""); - - // Prepare panel - gbc.anchor = GridBagConstraints.NORTHWEST; - gbc.weightx = 0; - gbc.weighty = 0; - gbc.gridy = m_line++; - gbc.gridx = 0; - gbc.gridwidth = 1; - gbc.insets = nullInset; - gbc.fill = GridBagConstraints.HORIZONTAL; - centerPanel.add(Box.createVerticalStrut(10), gbc); // top gap 10+2=12 - - // ASP - MClient client = MClient.get(Env.getCtx()); - String ASPFilter = ""; - if (client.isUseASP()) - ASPFilter = - " AND ( p.AD_Process_Para_ID IN ( " - // Just ASP subscribed process parameters for client " - + " SELECT pp.AD_Process_Para_ID " - + " FROM ASP_Process_Para pp, ASP_Process p, ASP_Level l, ASP_ClientLevel cl " - + " WHERE p.ASP_Level_ID = l.ASP_Level_ID " - + " AND cl.AD_Client_ID = " + client.getAD_Client_ID() - + " AND cl.ASP_Level_ID = l.ASP_Level_ID " - + " AND pp.ASP_Process_ID = p.ASP_Process_ID " - + " AND pp.IsActive = 'Y' " - + " AND p.IsActive = 'Y' " - + " AND l.IsActive = 'Y' " - + " AND cl.IsActive = 'Y' " - + " AND pp.ASP_Status = 'S') " // Show - + " OR p.AD_Process_Para_ID IN ( " - // + show ASP exceptions for client - + " SELECT AD_Process_Para_ID " - + " FROM ASP_ClientException ce " - + " WHERE ce.AD_Client_ID = " + client.getAD_Client_ID() - + " AND ce.IsActive = 'Y' " - + " AND ce.AD_Process_Para_ID IS NOT NULL " - + " AND ce.AD_Tab_ID IS NULL " - + " AND ce.AD_Field_ID IS NULL " - + " AND ce.ASP_Status = 'S') " // Show - + " ) " - + " AND p.AD_Process_Para_ID NOT IN ( " - // minus hide ASP exceptions for client - + " SELECT AD_Process_Para_ID " - + " FROM ASP_ClientException ce " - + " WHERE ce.AD_Client_ID = " + client.getAD_Client_ID() - + " AND ce.IsActive = 'Y' " - + " AND ce.AD_Process_Para_ID IS NOT NULL " - + " AND ce.AD_Tab_ID IS NULL " - + " AND ce.AD_Field_ID IS NULL " - + " AND ce.ASP_Status = 'H')"; // Hide - // - String sql = null; - if (Env.isBaseLanguage(Env.getCtx(), "AD_Process_Para")) - sql = "SELECT p.Name, p.Description, p.Help, " - + "p.AD_Reference_ID, p.AD_Process_Para_ID, " - + "p.FieldLength, p.IsMandatory, p.IsRange, p.ColumnName, " - + "p.DefaultValue, p.DefaultValue2, p.VFormat, p.ValueMin, p.ValueMax, " - + "p.SeqNo, p.AD_Reference_Value_ID, vr.Code AS ValidationCode, p.ReadOnlyLogic, p.DisplayLogic, p.IsEncrypted, NULL AS FormatPattern, p.MandatoryLogic, p.Placeholder, p.Placeholder2 " - + "FROM AD_Process_Para p" - + " LEFT OUTER JOIN AD_Val_Rule vr ON (p.AD_Val_Rule_ID=vr.AD_Val_Rule_ID) " - + "WHERE p.AD_Process_ID=?" // 1 - + " AND p.IsActive='Y' " - + ASPFilter + " ORDER BY SeqNo"; - else - sql = "SELECT t.Name, t.Description, t.Help, " - + "p.AD_Reference_ID, p.AD_Process_Para_ID, " - + "p.FieldLength, p.IsMandatory, p.IsRange, p.ColumnName, " - + "p.DefaultValue, p.DefaultValue2, p.VFormat, p.ValueMin, p.ValueMax, " - + "p.SeqNo, p.AD_Reference_Value_ID, vr.Code AS ValidationCode, p.ReadOnlyLogic, p.DisplayLogic, p.IsEncrypted, NULL AS FormatPattern, p.MandatoryLogic, t.Placeholder, p.Placeholder2 " - + "FROM AD_Process_Para p" - + " INNER JOIN AD_Process_Para_Trl t ON (p.AD_Process_Para_ID=t.AD_Process_Para_ID)" - + " LEFT OUTER JOIN AD_Val_Rule vr ON (p.AD_Val_Rule_ID=vr.AD_Val_Rule_ID) " - + "WHERE p.AD_Process_ID=?" // 1 - + " AND t.AD_Language='" + Env.getAD_Language(Env.getCtx()) + "'" - + " AND p.IsActive='Y' " - + ASPFilter + " ORDER BY SeqNo"; - - // Create Fields - boolean hasFields = false; - PreparedStatement pstmt = null; - ResultSet rs = null; - try - { - pstmt = DB.prepareStatement(sql, null); - pstmt.setInt(1, m_processInfo.getAD_Process_ID()); - rs = pstmt.executeQuery(); - while (rs.next()) - { - hasFields = true; - createField (rs); - } - } - catch(SQLException e) - { - throw new DBException(e, sql); - } - finally - { - DB.close(rs, pstmt); - rs = null; - pstmt = null; - } - - // both vectors the same? - if (m_mFields.size() != m_mFields2.size() - || m_mFields.size() != m_vEditors.size() - || m_mFields2.size() != m_vEditors2.size()) - log.log(Level.SEVERE, "View & Model vector size is different"); - - // clean up - if (hasFields) - { - gbc.gridy = m_line++; - centerPanel.add(Box.createVerticalStrut(10), gbc); // bottom gap - gbc.gridx = 3; - centerPanel.add(Box.createHorizontalStrut(12), gbc); // right gap - dynamicDisplay(); - } - else - dispose(); - return hasFields; - } // init - - /** - * Create Field. - * - creates Fields and adds it to m_mFields list - * - creates Editor and adds it to m_vEditors list - * Handles Ranges by adding additional mField/vEditor. - *

    - * mFields are used for default value and mandatory checking; - * vEditors are used to retrieve the value (no data binding) - * - * @param rs result set - */ - private void createField (ResultSet rs) - { - // Create Field - GridFieldVO voF = GridFieldVO.createParameter(Env.getCtx(), m_WindowNo, m_processInfo.getAD_Process_ID(), m_AD_Window_ID, m_processInfo.getAD_InfoWindow_ID(),rs); - GridField mField = new GridField (voF); - m_mFields.add(mField); // add to Fields - - // Label Preparation - gbc.gridy = m_line++; - gbc.gridwidth = 1; - gbc.fill = GridBagConstraints.HORIZONTAL; // required for right justified - gbc.gridx = 0; - gbc.weightx = 0; - JLabel label = VEditorFactory.getLabel(mField); - if (label == null) - { - gbc.insets = nullInset; - centerPanel.add(Box.createHorizontalStrut(12), gbc); // left gap - } - else - { - gbc.insets = labelInset; - centerPanel.add(label, gbc); - } - m_labels.add(label); - - // Field Preparation - gbc.insets = fieldInset; - gbc.fill = GridBagConstraints.HORIZONTAL; - gbc.gridwidth = 1; - gbc.gridx = 1; - gbc.weightx = 1; - - // The Editor - VEditor vEditor = VEditorFactory.getEditor(mField, false); - vEditor.addVetoableChangeListener(this); - // MField => VEditor - New Field value to be updated to editor - mField.addPropertyChangeListener(vEditor); - // - centerPanel.add ((Component)vEditor, gbc); - m_vEditors.add (vEditor); // add to Editors - // Set Default - Object defaultObject = mField.getDefaultForPanel(); - mField.setValue (defaultObject, true); - // - if (voF.isRange) - { - // To Label - gbc.gridx = 2; - gbc.weightx = 0; - gbc.fill = GridBagConstraints.NONE; - JLabel dash = new JLabel(" - "); - centerPanel.add (dash, gbc); - m_separators.add(dash); - // To Field - gbc.gridx = 3; - gbc.insets = fieldInsetRight; - gbc.weightx = 1; - gbc.fill = GridBagConstraints.HORIZONTAL; - gbc.anchor = GridBagConstraints.WEST; - // - GridFieldVO voF2 = GridFieldVO.createParameter(voF); - GridField mField2 = new GridField (voF2); - m_mFields2.add (mField2); - // The Editor - VEditor vEditor2 = VEditorFactory.getEditor(mField2, false); - // New Field value to be updated to editor - mField2.addPropertyChangeListener(vEditor2); - // - centerPanel.add ((Component)vEditor2, gbc); - m_vEditors2.add (vEditor2); - // Set Default - Object defaultObject2 = mField2.getDefaultForPanel(); - mField2.setValue (defaultObject2, true); - } - else - { - m_separators.add(null); - m_mFields2.add (null); - m_vEditors2.add (null); - } - } // createField - - /** - * Editor Listener - * @param evt Event - * @exception PropertyVetoException if the recipient wishes to roll back. - */ - public void vetoableChange(PropertyChangeEvent evt) throws PropertyVetoException - { - // log.fine( "ProcessParameterPanel.vetoableChange"); - if (evt.getSource() instanceof VEditor) { - GridField changedField = ((VEditor) evt.getSource()).getField(); - if (changedField != null) { - processDependencies (changedField); - // future processCallout (changedField); - } - } - processNewValue(evt.getNewValue(), evt.getPropertyName()); - } // vetoableChange - - /** - * Evaluate Dependencies - * @param changedField changed field - */ - private void processDependencies (GridField changedField) - { - String columnName = changedField.getColumnName(); - - for (GridField field : m_mFields) { - if (field == null || field == changedField) - continue; - verifyChangedField(field, columnName); - } - for (GridField field : m_mFields2) { - if (field == null || field == changedField) - continue; - verifyChangedField(field, columnName); - } - } // processDependencies - - private void verifyChangedField(GridField field, String columnName) { - ArrayList list = field.getDependentOn(); - if (list.contains(columnName)) { - if (field.getLookup() instanceof MLookup) - { - MLookup mLookup = (MLookup)field.getLookup(); - // if the lookup is dynamic (i.e. contains this columnName as variable) - if (mLookup.getValidation().indexOf("@"+columnName+"@") != -1) - { - if (log.isLoggable(Level.FINE)) log.fine(columnName + " changed - " - + field.getColumnName() + " set to null"); - // invalidate current selection - field.setValue(null, true); - } - } - } - } - - private void processNewValue(Object value, String name) { - if (value == null) - value = new String(""); - - if (value instanceof String) - Env.setContext(Env.getCtx(), m_WindowNo, name, (String) value); - else if (value instanceof Integer) - Env.setContext(Env.getCtx(), m_WindowNo, name, ((Integer) value) - .intValue()); - else if (value instanceof Boolean) - Env.setContext(Env.getCtx(), m_WindowNo, name, ((Boolean) value) - .booleanValue()); - else if (value instanceof Timestamp) - Env.setContext(Env.getCtx(), m_WindowNo, name, (Timestamp) value); - else - Env.setContext(Env.getCtx(), m_WindowNo, name, value.toString()); - - dynamicDisplay(); - } - - /** - * Dynamic Display. - * - **/ - public void dynamicDisplay() { - Component[] comps = centerPanel.getComponents(); - boolean changedSize = false; - for (int i = 0; i < comps.length; i++) { - Component comp = comps[i]; - if (comp instanceof CLabel) - continue; - String columnName = comp.getName(); - - if (columnName != null && columnName.length() > 0) { - int index = getIndex(columnName); - if (m_mFields.get(index) != null) { - if (m_mFields.get(index).isDisplayed(true)) { // check - // context - if (!comp.isVisible()) { - changedSize = true; - comp.setVisible(true); // visibility - if (m_labels.get(index) != null) - m_labels.get(index).setVisible(true); - if (m_mFields.get(index).getVO().isRange) - m_separators.get(index).setText(" - "); - } - boolean rw = m_mFields.get(index).isEditablePara(true); // r/w - check if field is Editable - m_vEditors.get(index).setReadWrite(rw); - if (m_mFields.get(index).getVO().isRange) - m_vEditors2.get(index).setReadWrite(rw); - } else { - if (comp.isVisible()) { - changedSize = true; - comp.setVisible(false); - if (m_labels.get(index) != null) - m_labels.get(index).setVisible(false); - if (m_mFields.get(index).getVO().isRange) - m_separators.get(index).setText(""); - } - } - } - } - } - if (m_win != null && changedSize) { - m_win.pack(); - m_win.setLocationRelativeTo(null); - } - } // Dynamic Display. - - /** - * getIndex. Get m_mFields index from columnName - * - * @param columnName - * @return int - **/ - private int getIndex(String columnName) { - - for (int i = 0; i < m_mFields.size(); i++) { - if (m_mFields.get(i).getColumnName().equals(columnName)) { - return i; - } - } - return 0; - } // getIndex - - /* (non-Javadoc) - * @see org.compiere.apps.ProcessParameters#saveParameters() - */ - public boolean saveParameters() - { - log.config(""); - - /** - * Mandatory fields - * see - MTable.getMandatory - */ - StringBuilder sb = new StringBuilder(); - int size = m_mFields.size(); - for (int i = 0; i < size; i++) - { - GridField field = (GridField)m_mFields.get(i); - if (field.isMandatory(true)) // check context - { - VEditor vEditor = (VEditor)m_vEditors.get(i); - Object data = vEditor.getValue(); - if (data == null || data.toString().length() == 0) - { - field.setInserting (true); // set editable (i.e. updateable) otherwise deadlock - field.setError(true); - if (sb.length() > 0) - sb.append(", "); - sb.append(field.getHeader()); - if (m_vEditors2.get(i) != null) // is a range - sb.append(" (").append(Msg.getMsg(Env.getCtx(), "From")).append(")"); - } - else - field.setError(false); - // Check for Range - VEditor vEditor2 = (VEditor)m_vEditors2.get(i); - if (vEditor2 != null) - { - Object data2 = vEditor2.getValue(); - GridField field2 = (GridField)m_mFields2.get(i); - if (data2 == null || data2.toString().length() == 0) - { - field2.setInserting (true); // set editable (i.e. updateable) otherwise deadlock - field2.setError(true); - if (sb.length() > 0) - sb.append(", "); - sb.append(field2.getHeader()); - sb.append(" (").append(Msg.getMsg(Env.getCtx(), "To")).append(")"); - } - else - field2.setError(false); - } // range field - } // mandatory - } // field loop - - - if (sb.length() != 0) - { - ADialog.error(m_WindowNo, this, "FillMandatory", sb.toString()); - return false; - } - - /********************************************************************** - * Save Now - */ - for (int i = 0; i < m_mFields.size(); i++) - { - // Get Values - VEditor editor = (VEditor)m_vEditors.get(i); - VEditor editor2 = (VEditor)m_vEditors2.get(i); - Object result = editor.getValue(); - Object result2 = null; - if (editor2 != null) - result2 = editor2.getValue(); - - // Create Parameter - MPInstancePara para = new MPInstancePara (Env.getCtx(), m_processInfo.getAD_PInstance_ID(), i); - GridField mField = (GridField)m_mFields.get(i); - para.setParameterName(mField.getColumnName()); - - // Date - if (result instanceof Timestamp || result2 instanceof Timestamp) - { - para.setP_Date((Timestamp)result); - if (editor2 != null && result2 != null) - para.setP_Date_To((Timestamp)result2); - } - // Integer - else if (result instanceof Integer || result2 instanceof Integer) - { - if (result != null) - { - Integer ii = (Integer)result; - para.setP_Number(ii.intValue()); - } - if (editor2 != null && result2 != null) - { - Integer ii = (Integer)result2; - para.setP_Number_To(ii.intValue()); - } - } - // BigDecimal - else if (result instanceof BigDecimal || result2 instanceof BigDecimal) - { - para.setP_Number ((BigDecimal)result); - if (editor2 != null && result2 != null) - para.setP_Number_To ((BigDecimal)result2); - } - // Boolean - else if (result instanceof Boolean) - { - Boolean bb = (Boolean)result; - String value = bb.booleanValue() ? "Y" : "N"; - para.setP_String (value); - // to does not make sense - } - // String - else - { - if (result != null) - para.setP_String (result.toString()); - if (editor2 != null && result2 != null) - para.setP_String_To (result2.toString()); - } - - // Info - para.setInfo (editor.getDisplay()); - if (editor2 != null) - para.setInfo_To (editor2.getDisplay()); - // - para.saveEx(); - if (log.isLoggable(Level.FINE)) log.fine(para.toString()); - } // for every parameter - - return true; - } // saveParameters - - /* - * load parameters from saved instance - */ - public boolean loadParameters(MPInstance instance) - { - log.config(""); - - MPInstancePara[] params = instance.getParameters(); - for (int j = 0; j < m_mFields.size(); j++) - { - GridField mField = (GridField)m_mFields.get(j); - - // Get Values - VEditor editor = (VEditor)m_vEditors.get(j); - VEditor editor2 = (VEditor)m_vEditors2.get(j); - - editor.setValue(null); - if (editor2 != null) - editor2.setValue(null); - - for ( int i = 0; i - * Change log: - *

      - *
    • 2007-02-26 - teo_sarca - [ 1666598 ] RecordInfo shows ColumnName instead of name - *
    - * - * @author Jorg Janke - * @version $Id: RecordInfo.java,v 1.2 2006/07/30 00:51:27 jjanke Exp $ - */ -public class RecordInfo extends CDialog -{ - /** - * - */ - private static final long serialVersionUID = 8984246906639442417L; - - /** - * Record Info - * @param owner owner - * @param title title - * @param dse data status event - */ - public RecordInfo (Frame owner, String title, DataStatusEvent dse) - { - super (owner, title, true); - try - { - jbInit ( dynInit(dse, title) ); - } - catch (Exception e) - { - log.log(Level.SEVERE, "", e); - } - AEnv.positionCenterWindow (owner, this); - } // RecordInfo - - - private CPanel mainPanel = new CPanel (new BorderLayout(0,0)); - @SuppressWarnings("unused") - private CPanel northPanel = new CPanel (); - private CScrollPane scrollPane = new CScrollPane (); - private VTable table = new VTable (); - private ConfirmPanel confirmPanel = new ConfirmPanel (false); - - /** Logger */ - protected CLogger log = CLogger.getCLogger(getClass()); - /** The Data */ - private Vector> m_data = new Vector>(); - /** Info */ - private StringBuffer m_info = new StringBuffer(); - - - - /** Date Time Format */ - private SimpleDateFormat m_dateTimeFormat = DisplayType.getDateFormat - (DisplayType.DateTime, Env.getLanguage(Env.getCtx())); - /** Date Format */ - private SimpleDateFormat m_dateFormat = DisplayType.getDateFormat - (DisplayType.DateTime, Env.getLanguage(Env.getCtx())); - /** Number Format */ - private DecimalFormat m_numberFormat = DisplayType.getNumberFormat - (DisplayType.Number, Env.getLanguage(Env.getCtx())); - /** Amount Format */ - private DecimalFormat m_amtFormat = DisplayType.getNumberFormat - (DisplayType.Amount, Env.getLanguage(Env.getCtx())); - /** Number Format */ - private DecimalFormat m_intFormat = DisplayType.getNumberFormat - (DisplayType.Integer, Env.getLanguage(Env.getCtx())); - - /** - * Static Layout - * @throws Exception - */ - private void jbInit (boolean showTable) throws Exception - { - getContentPane().add(mainPanel); - CTextArea info = new CTextArea(m_info.toString()); - info.setReadWrite(false); - info.setOpaque(false); // transparent - info.setForeground(Color.blue); - info.setBorder(null); - // - if (showTable) - { - mainPanel.add (info, BorderLayout.NORTH); - mainPanel.add (scrollPane, BorderLayout.CENTER); - scrollPane.getViewport().add(table); - scrollPane.setPreferredSize(new Dimension(500,100)); - } - else - { - info.setPreferredSize(new Dimension(400,75)); - mainPanel.add (info, BorderLayout.CENTER); - } - // - mainPanel.add (confirmPanel, BorderLayout.SOUTH); - confirmPanel.addActionListener(this); - } // jbInit - - - /** - * Dynamic Init - * @param dse data status event - * @param title title - * @return true if table initialized - */ - private boolean dynInit(DataStatusEvent dse, String title) - { - if (dse.CreatedBy == null) - return false; - // Info - MUser user = MUser.get(Env.getCtx(), dse.CreatedBy.intValue()); - m_info.append(" ") - .append(Msg.translate(Env.getCtx(), "CreatedBy")) - .append(": ").append(user.getName()) - .append(" - ").append(m_dateTimeFormat.format(dse.Created)).append("\n"); - - if (!dse.Created.equals(dse.Updated) - || !dse.CreatedBy.equals(dse.UpdatedBy)) - { - if (!dse.CreatedBy.equals(dse.UpdatedBy)) - user = MUser.get(Env.getCtx(), dse.UpdatedBy.intValue()); - m_info.append(" ") - .append(Msg.translate(Env.getCtx(), "UpdatedBy")) - .append(": ").append(user.getName()) - .append(" - ").append(m_dateTimeFormat.format(dse.Updated)).append("\n"); - } - if (dse.Info != null && dse.Info.length() > 0) - m_info.append("\n ").append(dse.Info).append(""); - - //get uuid - GridTable gridTable = null; - if (dse.getSource() instanceof GridTab) - { - GridTab gridTab = (GridTab) dse.getSource(); - gridTable = gridTab.getTableModel(); - } - else if (dse.getSource() instanceof GridTable) - { - gridTable = (GridTable) dse.getSource(); - } - if (gridTable != null && dse.getCurrentRow() >= 0 && dse.getCurrentRow() < gridTable.getRowCount()) - { - PO po = gridTable.getPO(dse.getCurrentRow()); - if (po != null) { - String uuidcol = po.getUUIDColumnName(); - String uuid = po.get_ValueAsString(uuidcol); - if (!Util.isEmpty(uuid)) - m_info.append("\n ").append(uuidcol).append("=").append(uuid); - } - } - - // Title - if (dse.AD_Table_ID != 0) - { - MTable table1 = MTable.get (Env.getCtx(), dse.AD_Table_ID); - setTitle(title + " - " + table1.getName()); - } - - // Only Client Preference can view Change Log - if (!MRole.PREFERENCETYPE_Client.equals(MRole.getDefault().getPreferenceType())) - return false; - - int Record_ID = 0; - if (dse.Record_ID instanceof Integer) - Record_ID = ((Integer)dse.Record_ID).intValue(); - else - if (log.isLoggable(Level.INFO)) log.info("dynInit - Invalid Record_ID=" + dse.Record_ID); - if (Record_ID == 0) - return false; - - // Data - String sql = "SELECT AD_Column_ID, Updated, UpdatedBy, OldValue, NewValue " - + "FROM AD_ChangeLog " - + "WHERE AD_Table_ID=? AND Record_ID=? " - + "ORDER BY Updated DESC"; - PreparedStatement pstmt = null; - ResultSet rs = null; - try - { - pstmt = DB.prepareStatement (sql, null); - pstmt.setInt (1, dse.AD_Table_ID); - pstmt.setInt (2, Record_ID); - rs = pstmt.executeQuery (); - while (rs.next ()) - { - addLine (rs.getInt(1), rs.getTimestamp(2), rs.getInt(3), - rs.getString(4), rs.getString(5)); - } - } - catch (Exception e) - { - log.log(Level.SEVERE, sql, e); - } - finally - { - DB.close(rs, pstmt); - rs = null; - pstmt = null; - } - - // - Vector columnNames = new Vector(); - columnNames.add(Msg.translate(Env.getCtx(), "Name")); - columnNames.add(Msg.translate(Env.getCtx(), "NewValue")); - columnNames.add(Msg.translate(Env.getCtx(), "OldValue")); - columnNames.add(Msg.translate(Env.getCtx(), "UpdatedBy")); - columnNames.add(Msg.translate(Env.getCtx(), "Updated")); - columnNames.add(Msg.translate(Env.getCtx(), "AD_Column_ID")); - DefaultTableModel model = new DefaultTableModel(m_data, columnNames); - table.setModel(model); - table.autoSize(false); - return true; - } // dynInit - - /** - * Add Line - * @param AD_Column_ID column - * @param Updated updated - * @param UpdatedBy user - * @param OldValue old - * @param NewValue new - */ - private void addLine (int AD_Column_ID, Timestamp Updated, int UpdatedBy, - String OldValue, String NewValue) - { - Vector line = new Vector(); - // Column - MColumn column = MColumn.get (Env.getCtx(), AD_Column_ID); - line.add(Msg.translate(Env.getCtx(), column.getColumnName())); - // - if (OldValue != null && OldValue.equals(MChangeLog.NULL)) - OldValue = null; - String showOldValue = OldValue; - if (NewValue != null && NewValue.equals(MChangeLog.NULL)) - NewValue = null; - String showNewValue = NewValue; - // - try - { - if (DisplayType.isText (column.getAD_Reference_ID ())) - ; - else if (column.getAD_Reference_ID() == DisplayType.YesNo) - { - if (OldValue != null) - { - boolean yes = OldValue.equals("true") || OldValue.equals("Y"); - showOldValue = Msg.getMsg(Env.getCtx(), yes ? "Y" : "N"); - } - if (NewValue != null) - { - boolean yes = NewValue.equals("true") || NewValue.equals("Y"); - showNewValue = Msg.getMsg(Env.getCtx(), yes ? "Y" : "N"); - } - } - else if (column.getAD_Reference_ID() == DisplayType.Amount) - { - if (OldValue != null) - showOldValue = m_amtFormat - .format (new BigDecimal (OldValue)); - if (NewValue != null) - showNewValue = m_amtFormat - .format (new BigDecimal (NewValue)); - } - else if (column.getAD_Reference_ID() == DisplayType.Integer) - { - if (OldValue != null) - showOldValue = m_intFormat.format (Integer.valueOf(OldValue)); - if (NewValue != null) - showNewValue = m_intFormat.format (Integer.valueOf(NewValue)); - } - else if (DisplayType.isNumeric (column.getAD_Reference_ID ())) - { - if (OldValue != null) - showOldValue = m_numberFormat.format (new BigDecimal (OldValue)); - if (NewValue != null) - showNewValue = m_numberFormat.format (new BigDecimal (NewValue)); - } - else if (column.getAD_Reference_ID() == DisplayType.Date) - { - if (OldValue != null) - showOldValue = m_dateFormat.format (Timestamp.valueOf (OldValue)); - if (NewValue != null) - showNewValue = m_dateFormat.format (Timestamp.valueOf (NewValue)); - } - else if (column.getAD_Reference_ID() == DisplayType.DateTime) - { - if (OldValue != null) - showOldValue = m_dateTimeFormat.format (Timestamp.valueOf (OldValue)); - if (NewValue != null) - showNewValue = m_dateTimeFormat.format (Timestamp.valueOf (NewValue)); - } - else if (DisplayType.isLookup(column.getAD_Reference_ID ())) - { - MLookup lookup = MLookupFactory.get (Env.getCtx(), 0, - AD_Column_ID, column.getAD_Reference_ID(), - Env.getLanguage(Env.getCtx()), column.getColumnName(), - column.getAD_Reference_Value_ID(), - column.isParent(), null); - if (OldValue != null) - { - Object key = OldValue; - NamePair pp = lookup.get(key); - if (pp != null) - showOldValue = pp.getName(); - } - if (NewValue != null) - { - Object key = NewValue; - NamePair pp = lookup.get(key); - if (pp != null) - showNewValue = pp.getName(); - } - } - else if (DisplayType.isLOB (column.getAD_Reference_ID ())) - ; - } - catch (Exception e) - { - log.log(Level.WARNING, OldValue + "->" + NewValue, e); - } - // - line.add(showNewValue); - line.add(showOldValue); - // UpdatedBy - MUser user = MUser.get(Env.getCtx(), UpdatedBy); - line.add(user.getName()); - // Updated - line.add(m_dateFormat.format(Updated)); - // Column Name - line.add(column.getColumnName()); - - m_data.add(line); - } // addLine - - - /** - * ActionListener - * @param e event - */ - public void actionPerformed(ActionEvent e) - { - dispose(); - } // actionPerformed - -} // RecordInfo diff --git a/org.adempiere.ui.swing/src/org/compiere/apps/ScreenShot.java b/org.adempiere.ui.swing/src/org/compiere/apps/ScreenShot.java deleted file mode 100644 index 4d26553f0c..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/apps/ScreenShot.java +++ /dev/null @@ -1,145 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - *****************************************************************************/ -package org.compiere.apps; - -import javax.imageio.ImageIO; -import javax.imageio.ImageWriter; -import javax.imageio.stream.ImageOutputStream; -import javax.swing.JFileChooser; - -import java.awt.AWTException; -import java.awt.Component; -import java.awt.Robot; -import java.awt.Window; -import java.awt.image.BufferedImage; -import java.io.File; -import java.io.IOException; -import java.util.Iterator; -import java.util.logging.Level; - -import org.compiere.util.CLogger; -import org.compiere.util.Env; -import org.compiere.util.ExtensionFileFilter; -import org.compiere.util.Msg; - -/** - * JPEG File Utility - * - * @author Jorg Janke - * @version $Id: ScreenShot.java,v 1.2 2006/07/30 00:51:27 jjanke Exp $ - * - * @author jmpiloq, evenos GmbH - * @version $Id - * @see BF [ 3073316 ] - */ -public class ScreenShot -{ - /** - * Create JPEG file from window - * @param window window - * @param fileName optional file name - * @return true if created - */ - public static boolean createJPEG (Window window, String fileName) - { - BufferedImage bi = null; - - if (window == null || fileName == null) - new IllegalArgumentException("ScreenShot.createJPEG Window os NULL"); - - // Get File - File file = getJPGFile (window); - if (file == null) - return false; - if (log.isLoggable(Level.CONFIG)) log.config("File=" + file); - if (file.exists()) - file.delete(); - - // Get Writer - Iterator writers = ImageIO.getImageWritersByFormatName("jpg"); - ImageWriter writer = writers.next(); - if (writer == null) - { - log.log(Level.SEVERE, "no ImageWriter"); - return false; - } - - // Get Image - try { - Thread.sleep(1000); - bi = getImage(window); - } catch (InterruptedException ex) { - log.log(Level.SEVERE, "ex", ex); - } - - // Write Image - try - { - ImageOutputStream ios = ImageIO.createImageOutputStream (file); - writer.setOutput(ios); - writer.write(bi); - ios.flush(); - ios.close(); - - } - catch (IOException ex) - { - log.log(Level.SEVERE, "ex", ex); - return false; - } - return true; - } // createJPEG - - - /** - * Get JPEG File - * @param parent parent - * @return file - */ - protected static File getJPGFile (Component parent) - { - JFileChooser fc = new JFileChooser(); - fc.addChoosableFileFilter(new ExtensionFileFilter("jpg", Msg.getMsg(Env.getCtx(), "FileJPEG"))); - if (fc.showSaveDialog(parent) != JFileChooser.APPROVE_OPTION) - return null; - File file = fc.getSelectedFile(); - if (file == null) - return null; - String fileName = file.getAbsolutePath(); - if (!(fileName.toUpperCase().equals(".JPG") || fileName.toUpperCase().equals(".JPEG"))) - fileName += ".jpg"; - fc.setVisible(false); - return new File (fileName); - } // getFile - - /** - * Get Image of Window - * @param window window - * @return image - */ - protected static BufferedImage getImage (Window window) - { - BufferedImage bi = null; - try { - bi = new Robot().createScreenCapture(window.getBounds()); - window.paintAll(bi.createGraphics()); - } catch (AWTException ex) { - log.log(Level.SEVERE, "ex", ex); - } - return bi; - } // getImage - - /** Logger */ - private static CLogger log = CLogger.getCLogger(ScreenShot.class); -} // ScreenShot diff --git a/org.adempiere.ui.swing/src/org/compiere/apps/Script.html b/org.adempiere.ui.swing/src/org/compiere/apps/Script.html deleted file mode 100644 index ec27d9afe3..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/apps/Script.html +++ /dev/null @@ -1,69 +0,0 @@ - - -Adempiere Scripting Help - - - -

    Adempiere Scripting Help

    -

    Context Variables

    -

    Window context variables start with a W_ prefix.
    -Login context variables start with G_ prefix.

    - -

    Event Variables

    -
    -

    Callout:

    -
    -
      -
    • A_WindowNo
    • -
    • A_Tab
    • -
    • A_Field
    • -
    • A_Value
    • -
    • A_OldValue
    • -
    • A_Ctx
    • -
    -
    -

    Process:

    -
    -
      -
    • Process Parameters for the process start with P_ prefix, for example P_Name. If the parameter is a range then the - parameters will be P_Name1 and P_Name2
    • -
    • A_Ctx - the context
    • -
    • A_Trx - the transaction
    • -
    • A_TrxName
    • -
    • A_Record_ID
    • -
    • A_AD_Client_ID
    • -
    • A_AD_User_ID
    • -
    • A_AD_PInstance_ID
    • -
    • A_Table_ID
    • -
    -
    -

    Login validator:

    -
    -
      -
    • A_Ctx
    • -
    • A_AD_Client_ID
    • -
    • A_AD_Org_ID
    • -
    • A_AD_Role_ID
    • -
    • A_AD_User_ID
    • -
    -
    -

    Table and document model validator:

    -
    -
      -
    • A_Ctx
    • -
    • A_PO
    • -
    • A_Type
    • -
    • A_Event
    • -
    -
    -
    - -Wiki Reference: - - - diff --git a/org.adempiere.ui.swing/src/org/compiere/apps/ScriptEditor.java b/org.adempiere.ui.swing/src/org/compiere/apps/ScriptEditor.java deleted file mode 100644 index 6bc964757f..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/apps/ScriptEditor.java +++ /dev/null @@ -1,71 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ -package org.compiere.apps; - -import java.awt.Frame; - -import org.compiere.model.Scriptlet; -import org.compiere.util.Env; - -/** - * ScriptEditor - */ -public class ScriptEditor -{ - /** - * Start ScriptEditor - * - * @param header Title - * @param script ScriptCode - * @param editable - * @return updated Script - * - * @deprecated since 3.3.1 - */ - public static String start (String header, String script, boolean editable, int WindowNo) - { - return start(null, header, script, editable, WindowNo); - } - - /** - * Start ScriptEditor - * - * @param owner - * @param header Title - * @param script ScriptCode - * @param editable - * @return updated Script - */ - public static String start (Frame owner, String header, String script, boolean editable, int WindowNo) - { - Scriptlet scr = new Scriptlet (Scriptlet.VARIABLE, script, Env.getCtx(), WindowNo); - String value = Env.getContext(Env.getCtx(), WindowNo, "Value"); - //TODO: generic editor for jsr223 script - if (value != null && value.startsWith("groovy:")) - { - GroovyEditor gv = new GroovyEditor (owner, header, script, WindowNo); - return gv.getScript(); - } - else - { - @SuppressWarnings("unused") - BeanShellEditor se = new BeanShellEditor (owner, header, scr, WindowNo); - return scr.getScript(); - } - } // start - -} // ScriptEditor diff --git a/org.adempiere.ui.swing/src/org/compiere/apps/StatusBar.java b/org.adempiere.ui.swing/src/org/compiere/apps/StatusBar.java deleted file mode 100644 index 725ed7b007..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/apps/StatusBar.java +++ /dev/null @@ -1,269 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ -package org.compiere.apps; - -import java.awt.BorderLayout; -import java.awt.Color; -import java.awt.event.MouseEvent; - -import javax.swing.BorderFactory; -import javax.swing.JComponent; -import javax.swing.JLabel; -import javax.swing.SwingConstants; - -import org.adempiere.plaf.AdempierePLAF; -import org.compiere.model.DataStatusEvent; -import org.compiere.model.MRole; -import org.compiere.swing.CPanel; -import org.compiere.util.Env; -import org.compiere.util.Msg; - -/** - * Status Bar - * - * @author Jorg Janke - * @version $Id: StatusBar.java,v 1.2 2006/07/30 00:51:27 jjanke Exp $ - */ -public class StatusBar extends CPanel implements IStatusBar -{ - - /****************************************************************************** - * Mouse Adapter for Status Bar (statusDB) - */ - static class StatusBar_mouseAdapter extends java.awt.event.MouseAdapter - { - private StatusBar adaptee; - - /** - * Constructor - * @param adaptee adaptee - */ - StatusBar_mouseAdapter(StatusBar adaptee) - { - this.adaptee = adaptee; - } - - /** - * Click - * @param e event - */ - public void mouseClicked(MouseEvent e) - { - adaptee.mouseClicked(e); - } - } // StatusBar_mouseAdapter - - /** - * - */ - private static final long serialVersionUID = 1465783013058042860L; - - /** - * Standard Status Bar - */ - public StatusBar() - { - this(false); - } // StatusBar - - /** - * Status Bar with additional info - * @param withInfo with info - */ - public StatusBar (boolean withInfo) - { - super(); - try - { - jbInit(); - } - catch (Exception e) - {} - this.setName("statusBar"); - if (!withInfo) - infoLine.setVisible(false); - } // StatusBar - - private BorderLayout mainLayout = new BorderLayout(); - private JLabel statusLine = new JLabel(); - private JLabel statusDB = new JLabel(); - private JLabel infoLine = new JLabel(); - // - private boolean mt_error; - private String mt_text; - // - private String m_text; - private DataStatusEvent m_dse = null; - - /** - * Static Init - * @throws Exception - */ - private void jbInit() throws Exception - { - statusLine.setBorder(BorderFactory.createEtchedBorder()); - statusLine.setText("statusLine"); - statusLine.setOpaque(false); - statusDB.setForeground(Color.blue); - statusDB.setBorder(BorderFactory.createEtchedBorder()); - statusDB.setText("#"); - statusDB.setOpaque(false); - statusDB.addMouseListener(new StatusBar_mouseAdapter(this)); - this.setLayout(mainLayout); - infoLine.setFont(AdempierePLAF.getFont_Label()); - infoLine.setBorder(BorderFactory.createLineBorder(AdempierePLAF.getSecondary2())); - infoLine.setHorizontalAlignment(SwingConstants.CENTER); - infoLine.setHorizontalTextPosition(SwingConstants.CENTER); - infoLine.setText("info"); - mainLayout.setHgap(2); - mainLayout.setVgap(2); - this.add(statusLine, BorderLayout.CENTER); - this.add(statusDB, BorderLayout.EAST); - this.add(infoLine, BorderLayout.NORTH); - } // jbInit - - - /************************************************************************** - * Set Standard Status Line (non error) - * @param text text - */ - public void setStatusLine (String text) - { - if (text == null) - setStatusLine("", false); - else - setStatusLine(text, false); - } // setStatusLine - - /** - * Set Status Line - * @param text text - * @param error error - */ - public void setStatusLine (String text, boolean error) - { - mt_error = error; - mt_text = text; - if (mt_error) - statusLine.setForeground(AdempierePLAF.getTextColor_Issue()); - else - statusLine.setForeground(AdempierePLAF.getTextColor_OK()); - statusLine.setText(" " + mt_text); - // - Thread.yield(); - } // setStatusLine - - /** - * Get Status Line text - * @return StatusLine text - */ - public String getStatusLine () - { - return statusLine.getText().trim(); - } // setStatusLine - - /** - * Set ToolTip of StatusLine - * @param tip tip - */ - public void setStatusToolTip (String tip) - { - statusLine.setToolTipText(tip); - } // setStatusToolTip - - /** - * Set Status DB Info - * @param text text - * @param dse data status event - */ - public void setStatusDB (String text, DataStatusEvent dse) - { - // log.config( "StatusBar.setStatusDB - " + text + " - " + created + "/" + createdBy); - if (text == null || text.length() == 0) - { - statusDB.setText(""); - statusDB.setVisible(false); - } - else - { - StringBuilder sb = new StringBuilder (" "); - sb.append(text).append(" "); - statusDB.setText(sb.toString()); - if (!statusDB.isVisible()) - statusDB.setVisible(true); - } - - // Save - m_text = text; - m_dse = dse; - } // setStatusDB - - /** - * Set Status DB Info - * @param text text - */ - public void setStatusDB (String text) - { - setStatusDB (text, null); - } // setStatusDB - - /** - * Set Status DB Info - * @param no no - */ - public void setStatusDB (int no) - { - setStatusDB (String.valueOf(no), null); - } // setStatusDB - - /** - * Set Info Line - * @param text text - */ - public void setInfo (String text) - { - if (!infoLine.isVisible()) - infoLine.setVisible(true); - infoLine.setText(text); - } // setInfo - - /** - * Add Component to East of StatusBar - * @param component component - */ - public void addStatusComponent (JComponent component) - { - this.add(component, BorderLayout.EAST); - } // addStatusComponent - - /** - * Show WHO - * @param e event - */ - void mouseClicked(MouseEvent e) - { - if (m_dse == null - || m_dse.CreatedBy == null - || !MRole.getDefault().isShowPreference()) - return; - // - String title = Msg.getMsg(Env.getCtx(), "Who") + m_text; - RecordInfo info = new RecordInfo (AEnv.getFrame(this), title, m_dse); - AEnv.showCenterScreen(info); - } // addStatusComponent - -} // StatusBar diff --git a/org.adempiere.ui.swing/src/org/compiere/apps/SwingWorker.java b/org.adempiere.ui.swing/src/org/compiere/apps/SwingWorker.java deleted file mode 100644 index 057ab4cfde..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/apps/SwingWorker.java +++ /dev/null @@ -1,221 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ -package org.compiere.apps; - -import javax.swing.SwingUtilities; - -/** - * SwingWorker (based on SwingWorker 3). - * To use the SwingWorker class, you create a subclass of it. - * In the subclass, you must implement the construct() method contains - * the code to perform your lengthy operation. - * You invoke start() on your SwingWorker object to start the thread, - * which then calls your construct() method. - * When you need the object returned by the construct() method, - * you call the SwingWorker's get() method. - *
    - *      SwingWorker worker = new SwingWorker()
    - *      {
    - *          public Object construct()
    - *          {
    - *              return new expensiveOperation();
    - *          }
    - *      };
    - *      worker.start();
    - *      //  do something
    - *      //  when you need the result:
    - *      x = worker.get();   //  this blocks the UI !!
    - *  
    - */ -public abstract class SwingWorker -{ - /** - * Start a thread that will call the construct method - * and then exit. - */ - public SwingWorker() - { - /** Finish Runnable */ - final Runnable doFinished = new Runnable() - { - public void run() - { - finished(); - } - }; - - /** Worker Runnable */ - Runnable doConstruct = new Runnable() - { - public void run() - { - try - { - setValue(construct()); - } - finally - { - m_threadVar.clear(); - } - SwingUtilities.invokeLater(doFinished); - } - }; - - Thread t = new Thread (doConstruct); - m_threadVar = new ThreadVar(t); - } // SwingWorker - - /** Worker Thread */ - private ThreadVar m_threadVar; - /** Return value */ - private Object m_value; // see getValue(), setValue() - - /** - * Compute the value to be returned by the get method. - * @return value - */ - public abstract Object construct(); - - /** - * Called on the event dispatching thread (not on the worker thread) - * after the construct method has returned. - */ - public void finished() - { - } // finished - - /** - * Get the value produced by the worker thread, - * or null if it hasn't been constructed yet. - * @return value of worker - */ - protected synchronized Object getValue() - { - return m_value; - } // getValue - - /** - * Set the value produced by worker thread - * @param x worker value - */ - private synchronized void setValue(Object x) - { - m_value = x; - } // setValue - - - /************************************************************************* - * Start the worker thread. - */ - public void start() - { - Thread t = m_threadVar.get(); - if (t != null) - t.start(); - } // start - - /** - * Return the value created by the construct method. - * Returns null if either the constructing thread or the current - * thread was interrupted before a value was produced. - * (Blocks UI) - * @return the value created by the construct method - */ - public Object get() - { - while (true) - { - Thread t = m_threadVar.get(); - if (t == null) - { - return getValue(); - } - try - { - t.join(); - } - catch (InterruptedException e) - { - Thread.currentThread().interrupt(); // propagate - return null; - } - } - } // get - - /** - * A new method that interrupts the worker thread. Call this method - * to force the worker to stop what it's doing. - */ - public void interrupt() - { - Thread t = m_threadVar.get(); - if (t != null) - { - t.interrupt(); - } - m_threadVar.clear(); - } // interrupt - - /** - * Is worker Alive - * @return true if alive - */ - public boolean isAlive() - { - Thread t = m_threadVar.get(); - if (t == null) - return false; - return t.isAlive(); - } // isAlive - - - /************************************************************************** - * Class to maintain reference to current worker thread - * under separate synchronization control. - */ - private static class ThreadVar - { - /** - * Constructor - * @param t sync thread - */ - ThreadVar(Thread t) - { - thread = t; - } - /** The Sync Thread */ - private Thread thread; - - /** - * Get Sync Thread - * @return thread - */ - synchronized Thread get() - { - return thread; - } // get - - /** - * Clear Sync thread - */ - synchronized void clear() - { - thread = null; - } // clear - } // ThreadVar - -} // SwingWorker diff --git a/org.adempiere.ui.swing/src/org/compiere/apps/TabSwitcher.java b/org.adempiere.ui.swing/src/org/compiere/apps/TabSwitcher.java deleted file mode 100644 index bcb7f6bb7a..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/apps/TabSwitcher.java +++ /dev/null @@ -1,125 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * Copyright (C) 2003-2007 e-Evolution,SC. All Rights Reserved. * - * @contributor Victor Perez , e-Evolution.SC FR [ 1757088 ] * - *****************************************************************************/ - - -package org.compiere.apps; - -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.awt.event.FocusAdapter; -import java.awt.event.FocusEvent; -import java.awt.event.KeyAdapter; -import java.awt.event.KeyEvent; - -import javax.swing.AbstractButton; -import javax.swing.JComponent; -import javax.swing.JTable; -import javax.swing.event.ListSelectionEvent; -import javax.swing.event.ListSelectionListener; -import javax.swing.text.JTextComponent; - -import org.compiere.grid.GridController; - -/** - * - * @author Gunther Hoppe, 21.08.2005 - * - */ -public class TabSwitcher extends FocusAdapter implements ActionListener, ListSelectionListener{ - - @SuppressWarnings("unused") - private APanel panel; - private GridController gc; - - public TabSwitcher(GridController g, APanel p) { - - panel = p; - gc = g; - } - - public void valueChanged(ListSelectionEvent e) { - if(!e.getValueIsAdjusting()) { - - performSwitch(); - } - }; - - public void actionPerformed(ActionEvent e) { - if(!(e.getSource() instanceof JTextComponent)) { - if(gc.getMTab().getRecord_ID() != -1) - performSwitch(); - } - } - - public void focusGained(FocusEvent e) { - performSwitch(); - } - - private void performSwitch() { - //gc.transferFocus(); - //panel.dispatchTabSwitch(gc); - } - - public void addTabSwitchingSupport(JComponent c) { - - if(c instanceof JTable) { - - ((JTable)c).getSelectionModel().addListSelectionListener(this); - return; - } - else if( //c instanceof org.compiere.grid.ed.VEditor || - c instanceof JTextComponent || - //c instanceof ItemSelectable || - c instanceof org.compiere.grid.ed.VCheckBox || - //c instanceof org.compiere.grid.ed.VLookup || - //c instanceof org.compiere.swing.CLabel || - c instanceof AbstractButton) - { - c.addFocusListener(this); - //c.addKeyListener(new MovementAdapter()); - return; - } - else if(c instanceof org.compiere.grid.ed.VDate) - { - org.compiere.grid.ed.VDate d = ((org.compiere.grid.ed.VDate)c); - //d.addFocusListener(this); - d.addActionListener(this); - //d.addKeyListener(new MovementAdapter()); - return; - } - else if(c instanceof org.compiere.grid.ed.VLookup) - { - org.compiere.grid.ed.VLookup l = ((org.compiere.grid.ed.VLookup)c); - //l.addFocusListener(this); - l.addActionListener(this); - //l.addKeyListener(new MovementAdapter()); - return; - } - } - - class MovementAdapter extends KeyAdapter - { - public void keyPressed(KeyEvent event) - { - // look for tab keys - if(event.getKeyCode() == KeyEvent.VK_TAB - || event.getKeyCode() == KeyEvent.VK_ENTER) - { - ((JComponent)event.getSource()).transferFocus(); - } - } - } -} diff --git a/org.adempiere.ui.swing/src/org/compiere/apps/Waiting.java b/org.adempiere.ui.swing/src/org/compiere/apps/Waiting.java deleted file mode 100644 index 28c390c6b0..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/apps/Waiting.java +++ /dev/null @@ -1,215 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ -package org.compiere.apps; - -import java.awt.BorderLayout; -import java.awt.Cursor; -import java.awt.Dialog; -import java.awt.Frame; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.util.logging.Level; - -import javax.swing.Box; -import javax.swing.JProgressBar; -import javax.swing.SwingConstants; -import javax.swing.Timer; -import javax.swing.WindowConstants; - -import org.compiere.swing.CButton; -import org.compiere.swing.CDialog; -import org.compiere.swing.CLabel; -import org.compiere.swing.CPanel; -import org.compiere.util.CLogger; -import org.compiere.util.Env; -import org.compiere.util.Msg; - -/** - * Waiting Dialog - * - * @author Jorg Janke - * @version $Id: Waiting.java,v 1.2 2006/07/30 00:51:27 jjanke Exp $ - */ -public class Waiting extends CDialog - implements ActionListener -{ - /** - * - */ - private static final long serialVersionUID = -2078889004176093095L; - - /** - * Constructor - non nodal as otherwise process is blocked - * @param owner - * @param text Message to be displayed - * @param canNotWait user can continue with other work - * @param timer timer ticks (seconds) - if 0 then 10 - */ - public Waiting (Frame owner, String text, boolean canNotWait, int timer) - { - super(owner, Msg.getMsg(Env.getCtx(), "Processing")); - init (text, canNotWait, timer); - } // Waiting - - /** - * Constructor - non modal as otherwise process is blocked - * @param owner - * @param text Message to be displayed - * @param canNotWait user can continue with other work - * @param timer timer ticks (seconds) - if 0 then 10 - */ - public Waiting (Dialog owner, String text, boolean canNotWait, int timer) - { - super(owner, Msg.getMsg(Env.getCtx(), "Processing")); - init (text, canNotWait, timer); - } // Waiting - - /** - * Common Initialize routine - does not create if timer == 1 - * @param text Message to be displayed - * @param canNotWait user can continue with other work - * @param timer timer ticks (seconds) - if less than 5 then 10 - */ - private void init (String text, boolean canNotWait, int timer) - { - if (log.isLoggable(Level.FINE)) log.fine(text + " - Sec=" + timer); - // don't show if 1 sec average - if (timer == 1) - return; - - try - { - jbInit(); - setText (text); - if (!canNotWait) - bDoNotWait.setVisible(false); - } - catch(Exception e) - { - log.log(Level.SEVERE, "Waiting", e); - } - // set progress Bar - progressBar.setMinimum(0); - progressBar.setMaximum(timer < 5 ? 10 : timer); // min 2 seconds - - // Timer - m_timer = new Timer (1000, this); // every second - m_timer.start(); - AEnv.showCenterWindow(getOwner(), this); - } // init - - private int m_timervalue = 0; - private Timer m_timer; - /** Logger */ - private static CLogger log = CLogger.getCLogger(Waiting.class); - - @SuppressWarnings("unused") - private CPanel southPanel = new CPanel(); - private CButton bDoNotWait = new CButton(); - private CLabel infoLabel = new CLabel(); - //private FlowLayout southLayout = new FlowLayout(); - private CPanel mainPanel = new CPanel(); - private JProgressBar progressBar = new JProgressBar(); - - /** - * Static Layout - * @throws Exception - */ - private void jbInit() throws Exception - { - this.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE); - this.setResizable(false); - this.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); - - this.getContentPane().add(Box.createVerticalStrut(8), BorderLayout.NORTH); - this.getContentPane().add(Box.createHorizontalStrut(8), BorderLayout.WEST); - this.getContentPane().add(Box.createVerticalStrut(8), BorderLayout.SOUTH); - this.getContentPane().add(Box.createHorizontalStrut(8), BorderLayout.EAST); - mainPanel.setLayout(new BorderLayout(5,5)); - this.getContentPane().add(mainPanel, BorderLayout.CENTER); - // - infoLabel.setFont(new java.awt.Font("Dialog", 3, 14)); - infoLabel.setHorizontalAlignment(SwingConstants.CENTER); - infoLabel.setHorizontalTextPosition(SwingConstants.RIGHT); - infoLabel.setIcon(Env.getImageIcon("iD10030.png")); - infoLabel.setIconTextGap(10); - mainPanel.add(infoLabel, BorderLayout.NORTH); - mainPanel.add(progressBar, BorderLayout.CENTER); - // -// bDoNotWait.setText(Msg.getMsg(Env.getCtx(), "DoNotWait")); -// bDoNotWait.setToolTipText(Msg.getMsg(Env.getCtx(), "DoNotWaitInfo")); -// bDoNotWait.addActionListener(this); -// southPanel.setLayout(southLayout); -// southPanel.add(bDoNotWait, null); -// mainPanel.add(southPanel, BorderLayout.SOUTH); - } // jbInit - - /** - * Set Info Text - * @param text - */ - public void setText (String text) - { - infoLabel.setText(text); - } // setText - - /** - * ActionListener - * @param e - */ - public void actionPerformed (ActionEvent e) - { - if (e.getSource() == bDoNotWait) - doNotWait(); - // - progressBar.setValue(m_timervalue++); - if (m_timervalue > progressBar.getMaximum()) - m_timervalue = progressBar.getMinimum(); - // progressBar.setString(progressBar.getPercentComplete()); - } // actionPerformed - - /** - * Set Timer Estimate - * @param max Seconds - */ - public void setTimerEstimate (int max) - { - progressBar.setMaximum(max); - } // setMaximum - - /** - * User does not want to wait for result and continue with other worg - * Callback & dispose - */ - public void doNotWait() - { - /** @todo callback */ - dispose(); - } // doNotWait - - /** - * Dispose - */ - public void dispose() - { - if (m_timer != null) - m_timer.stop(); - m_timer = null; - super.dispose(); - } // dispose - -} // Waiting diff --git a/org.adempiere.ui.swing/src/org/compiere/apps/WindowManager.java b/org.adempiere.ui.swing/src/org/compiere/apps/WindowManager.java deleted file mode 100644 index 7e524cb4c1..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/apps/WindowManager.java +++ /dev/null @@ -1,182 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 Adempiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - *****************************************************************************/ -package org.compiere.apps; - -import java.awt.Component; -import java.awt.Window; -import java.awt.event.ComponentEvent; -import java.awt.event.ComponentListener; -import java.awt.event.WindowEvent; -import java.awt.event.WindowListener; -import java.util.ArrayList; -import java.util.List; - -import org.compiere.apps.form.FormFrame; -import org.compiere.swing.CFrame; - -/** - * Managed a list of window. - * @author Low Heng Sin - * @version 2006/11/20 - */ -public class WindowManager { - public WindowManager() {} - private List windows = new ArrayList(); - private WindowEventListener eventListener = new WindowEventListener(this); - - /** - * Add window - * @param window - */ - public void add(CFrame window) { - windows.add(window); - window.addComponentListener(eventListener); - window.addWindowListener(eventListener); - } - - /** - * Close all windows managed by this window manager. - */ - public void close() { - for ( CFrame w : windows ) { - w.removeComponentListener(eventListener); - w.removeWindowListener(eventListener); - w.dispose(); - } - windows = new ArrayList(); - } - - /** - * Close all except one window. - * @param window - */ - public void closeOthers(CFrame window) { - for ( CFrame w : windows ) { - w.removeComponentListener(eventListener); - w.removeWindowListener(eventListener); - if ( !w.equals(window)) { - w.dispose(); - } - } - windows = new ArrayList(); - add(window); - } - - /** - * Remove window - * @param window - */ - public void remove(CFrame window) { - if ( windows.remove(window) ) { - window.removeComponentListener(eventListener); - window.removeWindowListener(eventListener); - } - } - - /** - * Get list of windows managed by this window manager - * @return Array of windows - */ - public CFrame[] getWindows() { - CFrame[] a = new CFrame[windows.size()]; - return windows.toArray(a); - } - - /** - * @return Number of windows managed by this window manager - */ - public int getWindowCount() { - return windows.size(); - } - - /** - * Find window by ID - * @param AD_Window_ID - * @return AWindow reference, null if not found - */ - public AWindow find(int AD_Window_ID) { - for ( CFrame w : windows ) { - if ( w instanceof AWindow ) { - AWindow a = (AWindow)w; - if ( a.getAD_Window_ID() == AD_Window_ID ) - return a; - } - } - return null; - } - - public FormFrame findForm(int AD_FORM_ID) { - for ( CFrame w : windows ) { - if ( w instanceof FormFrame ) { - FormFrame ff = (FormFrame)w; - if ( ff.getAD_Form_ID() == AD_FORM_ID ) - return ff; - } - } - return null; - } -} - -class WindowEventListener implements ComponentListener, WindowListener { - WindowManager windowManager; - - protected WindowEventListener(WindowManager windowManager) { - this.windowManager = windowManager; - } - - public void componentHidden(ComponentEvent e) { - Component c = e.getComponent(); - if ( c instanceof CFrame ) { - c.removeComponentListener(this); - ((CFrame)c).removeWindowListener(this); - windowManager.remove((CFrame)c); - } - } - - public void componentMoved(ComponentEvent e) { - } - - public void componentResized(ComponentEvent e) { - } - - public void componentShown(ComponentEvent e) { - } - - public void windowActivated(WindowEvent e) { - } - - public void windowClosed(WindowEvent e) { - Window w = e.getWindow(); - if ( w instanceof CFrame ) { - w.removeComponentListener(this); - w.removeWindowListener(this); - windowManager.remove((CFrame)w); - } - } - - public void windowClosing(WindowEvent e) { - } - - public void windowDeactivated(WindowEvent e) { - } - - public void windowDeiconified(WindowEvent e) { - } - - public void windowIconified(WindowEvent e) { - } - - public void windowOpened(WindowEvent e) { - } -} \ No newline at end of file diff --git a/org.adempiere.ui.swing/src/org/compiere/apps/WindowMenu.java b/org.adempiere.ui.swing/src/org/compiere/apps/WindowMenu.java deleted file mode 100644 index 2134a701a7..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/apps/WindowMenu.java +++ /dev/null @@ -1,424 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 Adempiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - *****************************************************************************/ -package org.compiere.apps; - -import java.awt.BorderLayout; -import java.awt.CardLayout; -import java.awt.Container; -import java.awt.Cursor; -import java.awt.Dimension; -import java.awt.GridLayout; -import java.awt.Image; -import java.awt.Toolkit; -import java.awt.Window; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.awt.event.FocusAdapter; -import java.awt.event.FocusEvent; -import java.awt.event.KeyEvent; -import java.awt.event.MouseAdapter; -import java.awt.event.MouseEvent; -import java.awt.event.WindowEvent; -import java.awt.event.WindowFocusListener; -import java.awt.image.BufferedImage; - -import javax.swing.Box; -import javax.swing.JCheckBoxMenuItem; -import javax.swing.JComponent; -import javax.swing.JDialog; -import javax.swing.JFrame; -import javax.swing.JMenu; -import javax.swing.JMenuItem; -import javax.swing.JPanel; -import javax.swing.JRootPane; -import javax.swing.KeyStroke; -import javax.swing.SwingUtilities; -import javax.swing.event.MenuEvent; -import javax.swing.event.MenuListener; - -import org.compiere.swing.CFrame; -import org.compiere.util.Env; -import org.compiere.util.Msg; -import org.jdesktop.swingx.JXButton; -import org.jdesktop.swingx.JXImageView; -import org.jdesktop.swingx.JXPanel; -import org.jdesktop.swingx.JXTitledPanel; -import org.jdesktop.swingx.painter.Painter; - -/** - * Menu component that handles the functionality expected of a standard - * "Windows" menu for MDI or MDI-like applications. - * - * @author Low Heng Sin - * @version 2006/11/20 - * - * @author Teo Sarca, SC ARHIPAC SERVICE SRL - *
  • BF [ 1808617 ] Close Windows from "Viewer" (report) is not working - */ -public class WindowMenu extends JMenu { - /** - * - */ - private static final long serialVersionUID = 381665816099431316L; - private WindowManager windowManager; - private JFrame frame; - private JMenuItem closeAll=new JMenuItem("Close All Windows"); - private JMenuItem closeOthers = new JMenuItem("Close Other Windows"); - private JMenuItem expose = new JMenuItem("Show All"); - private JXTitledPanel firstBox; - - private void setEnvText(JMenu menu, String msg) { - String text = Msg.getMsg(Env.getCtx(), msg); - int pos = text.indexOf('&'); - if (pos != -1 && text.length() > pos) // We have a nemonic - { - char ch = text.toUpperCase().charAt(pos+1); - if (ch != ' ') - { - text = text.substring(0, pos) + text.substring(pos+1); - menu.setMnemonic(ch); - } - } - menu.setText(text); - } - - private void setEnvText(JMenuItem menu, String msg) { - String text = Msg.getMsg(Env.getCtx(), msg); - int pos = text.indexOf('&'); - if (pos != -1 && text.length() > pos) // We have a nemonic - { - char ch = text.toUpperCase().charAt(pos+1); - if (ch != ' ') - { - text = text.substring(0, pos) + text.substring(pos+1); - menu.setMnemonic(ch); - } - } - menu.setText(text); - } - - public WindowMenu(WindowManager windowManager, JFrame frame) { - this.windowManager = windowManager; - this.frame = frame; - setEnvText(this, "Window"); - closeAll.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent ae) { - WindowMenu.this.windowManager.close(); - } - }); - setEnvText(closeAll, "CloseAllWindows"); - closeOthers.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent ae) { - WindowMenu.this.windowManager.closeOthers((CFrame)WindowMenu.this.frame); - } - }); - expose.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent ae) { - SwingUtilities.invokeLater(new Runnable() { - - public void run() { - expose(); - } - }); - } - }); - setEnvText(expose, "ShowAllWindow"); - expose.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_W, ActionEvent.CTRL_MASK)); - setEnvText(closeOthers, "CloseOtherWindows"); - addMenuListener(new MenuListener() { - public void menuCanceled (MenuEvent e) {} - - public void menuDeselected (MenuEvent e) { - removeAll(); - } - - public void menuSelected (MenuEvent e) { - buildChildMenus(); - } - }); - } - - private JXPanel createSelectionPanel() { - - GridLayout l = new GridLayout(3, 3); - l.setHgap(5); - l.setVgap(5); - - JXPanel p = new JXPanel(); - p.setLayout(l); - - return p; - } - - public void expose() { - - final JDialog dialog = new JDialog(); - dialog.setSize(Toolkit.getDefaultToolkit().getScreenSize()); - dialog.setUndecorated(true); - dialog.setModal(true); - - //add escape to close - ActionListener actionListener = new ActionListener() { - public void actionPerformed(ActionEvent actionEvent) { - dialog.setVisible(false); - } - }; - JRootPane jr = dialog.getRootPane(); - KeyStroke stroke = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0); - jr.registerKeyboardAction(actionListener, stroke, JComponent.WHEN_IN_FOCUSED_WINDOW); - - //new Thread(new Loader(dialog)).start(); - SwingUtilities.invokeLater(new Loader(dialog)); - - dialog.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); - dialog.setVisible(true); - } - - private JXTitledPanel createImageBox(JPanel p, JDialog dialog, - int width, int height, CFrame window) { - BufferedImage bi = new BufferedImage (window.getWidth(), window.getHeight(), - BufferedImage.TYPE_INT_RGB); // TYPE_INT_ARGB is tinted red - window.paintAll(bi.createGraphics()); - - Image image = bi.getScaledInstance(width, height, Image.SCALE_SMOOTH); - - final JXTitledPanel box = new JXTitledPanel(); - final Painter painter = box.getTitlePainter(); - box.setTitlePainter(null); - box.setFocusable(true); - box.setTitle(window.getTitle()); - final JXImageView imageView = new JXImageView(); - imageView.setImage(image); - imageView.setEditable(false); - box.setContentContainer(imageView); - box.setPreferredSize(new Dimension(width,height)); - box.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); - box.addMouseListener(new MouseAdapter() { - @Override - public void mouseEntered(MouseEvent e) { - box.requestFocus(); - } - }); - imageView.addMouseListener(new MouseAdapter() { - @Override - public void mouseEntered(MouseEvent e) { - box.requestFocus(); - } - }); - - PreviewMouseAdapter adapter = new PreviewMouseAdapter(dialog, window); - box.addMouseListener(adapter); - imageView.addMouseListener(adapter); - - imageView.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); - box.addFocusListener(new FocusAdapter(){ - - @Override - public void focusGained(FocusEvent e) { - box.setTitlePainter(painter); - } - - @Override - public void focusLost(FocusEvent e) { - box.setTitlePainter(null); - } - - }); - return box; - } - - /* Sets up the children menus depending on the current desktop state */ - private void buildChildMenus() { - this.removeAll(); - int i; - ChildMenuItem menu; - CFrame[] array = windowManager.getWindows(); - - add(expose); - - if ( !(frame instanceof AMenu) ) - add(closeOthers); - add(closeAll); - - if (array.length > 0) { - expose.setEnabled(true); - closeAll.setEnabled(true); - if ( array.length > 1 ) - closeOthers.setEnabled(true); - else - closeOthers.setEnabled(false); - addSeparator(); - } else { - closeAll.setEnabled(false); - closeOthers.setEnabled(false); - expose.setEnabled(false); - } - - if ( !(frame instanceof AMenu) ) { - JFrame frame = AEnv.getWindow(0); - if (frame != null && frame instanceof AMenu) { - menu = new ChildMenuItem((AMenu)frame); - menu.setState(false); - menu.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent ae) { - CFrame frame = ((ChildMenuItem)ae.getSource()).getWindow(); - AEnv.showWindow(frame); - } - }); - add(menu); - addSeparator(); - } - } - - for (i = 0; i < array.length; i++) { - menu = new ChildMenuItem(array[i]); - menu.setState(array[i].equals(frame)); - menu.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent ae) { - CFrame frame = ((ChildMenuItem)ae.getSource()).getWindow(); - AEnv.showWindow(frame); - } - }); - //menu.setIcon(array[i].getIconImage()); - add(menu); - } - } - - /* This JCheckBoxMenuItem descendant is used to track the child frame that corresponds - to a give menu. */ - class ChildMenuItem extends JCheckBoxMenuItem { - /** - * - */ - private static final long serialVersionUID = 2258141282389818588L; - private CFrame window; - - public ChildMenuItem(CFrame window) { - super(window.getTitle()); - this.window=window; - } - - public CFrame getWindow() { - return window; - } - } - - class Loader implements Runnable { - private JDialog dialog; - - Loader(JDialog d) { - dialog = d; - } - - public void run() { - CFrame[] w = windowManager.getWindows(); - Container dialogContent = dialog.getContentPane(); - dialogContent.setLayout(new BorderLayout()); - - final CardLayout card = new CardLayout(); - final JXPanel cardContainer = new JXPanel(card); - - dialogContent.add(cardContainer, BorderLayout.CENTER); - - JXPanel p = createSelectionPanel(); - cardContainer.add(p, "page1"); - - Dimension s = Toolkit.getDefaultToolkit().getScreenSize(); - int width = ( s.width - 30 ) / 3; - int height = ( s.height - 30 ) / 3; - int count = 0; - JFrame frame = AEnv.getWindow(0); - if (frame != null && frame instanceof AMenu) { - JXTitledPanel box = createImageBox(p, dialog, width, height, - (CFrame)frame); - p.add(box); - count ++; - firstBox = box; - } - int page = 1; - for(int i = 0; i < w.length; i++) { - count ++; - CFrame window = w[i]; - JXTitledPanel box = createImageBox(p, dialog, width, height, - window); - p.add(box); - if (i == 0 && firstBox == null) firstBox = box; - if ( count == 9) { - count = 0; - page++; - p = createSelectionPanel(); - cardContainer.add(p, "page" + page); - } - } - for ( int i = count; i < 9; i++ ) { - p.add(Box.createGlue()); - } - dialog.addWindowFocusListener(new WindowFocusListener() { - - public void windowGainedFocus(WindowEvent e) { - if (firstBox != null) - firstBox.requestFocus(); - } - - public void windowLostFocus(WindowEvent e) { - } - - }); - card.first(cardContainer); - if (page > 1) { - JXPanel ctrl = new JXPanel(); - JXButton previous = new JXButton("<"); - JXButton next = new JXButton(">"); - previous.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - card.previous(cardContainer); - } - - }); - next.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - card.next(cardContainer); - } - }); - ctrl.add(previous); - ctrl.add(next); - dialogContent.add(ctrl, BorderLayout.NORTH); - } - dialog.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); - } - - } - - class PreviewMouseAdapter extends MouseAdapter { - private JDialog dialog; - private Window window; - - PreviewMouseAdapter(JDialog d, Window w) { - dialog = d; - window = w; - } - - @Override - public void mouseClicked(MouseEvent e) { - dialog.dispose(); - SwingUtilities.invokeLater(new Runnable() { - public void run() { - AEnv.showWindow(window); - } - }); - } - } -} - - \ No newline at end of file diff --git a/org.adempiere.ui.swing/src/org/compiere/apps/form/ArchiveViewer.java b/org.adempiere.ui.swing/src/org/compiere/apps/form/ArchiveViewer.java deleted file mode 100644 index ad42a05bdd..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/apps/form/ArchiveViewer.java +++ /dev/null @@ -1,456 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ -package org.compiere.apps.form; - -import java.awt.BorderLayout; -import java.awt.Dimension; -import java.awt.GridBagConstraints; -import java.awt.GridBagLayout; -import java.awt.Insets; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.beans.PropertyChangeEvent; -import java.beans.PropertyVetoException; -import java.beans.VetoableChangeListener; -import java.io.InputStream; -import java.sql.Timestamp; -import java.util.logging.Level; - -import javax.swing.JSplitPane; - -import org.adempiere.pdf.viewer.PDFViewerBean; -import org.compiere.apps.ConfirmPanel; -import org.compiere.grid.ed.VDate; -import org.compiere.grid.ed.VLookup; -import org.compiere.grid.ed.VString; -import org.compiere.grid.ed.VText; -import org.compiere.model.MArchive; -import org.compiere.swing.CButton; -import org.compiere.swing.CCheckBox; -import org.compiere.swing.CComboBox; -import org.compiere.swing.CLabel; -import org.compiere.swing.CPanel; -import org.compiere.swing.CTabbedPane; -import org.compiere.swing.CTextField; -import org.compiere.util.Env; -import org.compiere.util.KeyNamePair; -import org.compiere.util.Msg; - - -/** - * Arvhive Viewer - *

    Change log - *

      - *
    • 2007-03-01 - teo_sarca - [ 1671899 ] Archive Viewer: table, process are not translated - *
    • 2007-03-01 - teo_sarca - [ 1671900 ] Archive Viewer: second tab has no split pane - *
    - * - * @author Jorg Janke - * @version $Id: ArchiveViewer.java,v 1.2 2006/07/30 00:51:28 jjanke Exp $ - */ -public class ArchiveViewer extends Archive - implements FormPanel, ActionListener, VetoableChangeListener -{ - private CTabbedPane panel = new CTabbedPane(); - - - /** - * Initialize Panel - * @param WindowNo window - * @param frame parent frame - */ - public void init (int WindowNo, FormFrame frame) - { - log.info(""); - m_WindowNo = WindowNo; - m_frame = frame; - try - { - dynInit(); - jbInit(); - frame.getContentPane().add(panel, BorderLayout.CENTER); - frame.getContentPane().add(confirmPanel, BorderLayout.SOUTH); - // - m_frame.setIconImage(Env.getImage("Archive16.gif")); - } - catch(Exception e) - { - log.log(Level.SEVERE, "init", e); - } - } // init - - /** FormFrame */ - private FormFrame m_frame; - - private CPanel queryPanel = new CPanel(new GridBagLayout()); - private CCheckBox reportField = new CCheckBox(Msg.translate(Env.getCtx(), "IsReport")); - private CLabel processLabel = new CLabel(Msg.translate(Env.getCtx(), "AD_Process_ID")); - private CComboBox processField = null; - private CLabel tableLabel = new CLabel(Msg.translate(Env.getCtx(), "AD_Table_ID")); - private CComboBox tableField = null; - private CLabel bPartnerLabel = new CLabel(Msg.translate(Env.getCtx(), "C_BPartner_ID")); - private VLookup bPartnerField = null; - private CLabel nameQLabel = new CLabel(Msg.translate(Env.getCtx(), "Name")); - private CTextField nameQField = new CTextField(15); - private CLabel descriptionQLabel = new CLabel(Msg.translate(Env.getCtx(), "Description")); - private CTextField descriptionQField = new CTextField(15); - private CLabel helpQLabel = new CLabel(Msg.translate(Env.getCtx(), "Help")); - private CTextField helpQField = new CTextField(15); - private CLabel createdByQLabel = new CLabel(Msg.translate(Env.getCtx(), "CreatedBy")); - private CComboBox createdByQField = null; - private CLabel createdQLabel = new CLabel(Msg.translate(Env.getCtx(), "Created")); - private VDate createdQFrom = new VDate(); - private VDate createdQTo = new VDate(); - // - private CPanel viewPanel = new CPanel(new BorderLayout(5,5)); - private JSplitPane viewPanelSplit = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT); - private PDFViewerBean pdfViewer = new PDFViewerBean(); - private CPanel viewEnterPanel = new CPanel(new GridBagLayout()); - private CButton bBack = new CButton(Env.getImageIcon("wfBack24.gif")); - private CButton bNext = new CButton(Env.getImageIcon("wfNext24.gif")); - private CLabel positionInfo = new CLabel("."); - private CLabel createdByLabel = new CLabel(Msg.translate(Env.getCtx(), "CreatedBy")); - private CTextField createdByField = new CTextField(20); -// private CLabel createdLabel = new CLabel(Msg.translate(Env.getCtx(), "Created")); - private VDate createdField = new VDate(); - // - private CLabel nameLabel = new CLabel(Msg.translate(Env.getCtx(), "Name")); - private VString nameField = new VString("Name", true, false, true, 20, 60, null, null); - private CLabel descriptionLabel = new CLabel(Msg.translate(Env.getCtx(), "Description")); - private VText descriptionField = new VText("Description", false, false, true, 20, 255); - private CLabel helpLabel = new CLabel(Msg.translate(Env.getCtx(), "Help")); - private VText helpField = new VText("Help", false, false, true, 20, 2000); - private CButton updateArchive = ConfirmPanel.createOKButton(Msg.getMsg(Env.getCtx(), "Update")); - private ConfirmPanel confirmPanel = new ConfirmPanel(true); - - - /** - * Dynamic Init - */ - private void dynInit() - { - processField = new CComboBox(getProcessData()); - tableField = new CComboBox(getTableData()); - createdByQField = new CComboBox(getUserData()); - // - bPartnerField = VLookup.createBPartner(m_WindowNo); - } // dynInit - - /** - * Static Init - * @throws Exception - */ - private void jbInit() throws Exception - { - int line = 0; - queryPanel.add(reportField, new GridBagConstraints(0, line, - 3, 1, 0, 0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0,0,0,0), 0, 0)); - reportField.addActionListener(this); - // - queryPanel.add(processLabel, new GridBagConstraints(0, ++line, - 1, 1, 0, 0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5,0,0,5), 0, 0)); - queryPanel.add(processField, new GridBagConstraints(1, line, - 2, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5,0,0,0), 0, 0)); - queryPanel.add(bPartnerLabel, new GridBagConstraints(0, ++line, - 1, 1, 0, 0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5,0,0,5), 0, 0)); - queryPanel.add(bPartnerField, new GridBagConstraints(1, line, - 2, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5,0,0,0), 0, 0)); - queryPanel.add(tableLabel, new GridBagConstraints(0, ++line, - 1, 1, 0, 0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5,0,0,5), 0, 0)); - queryPanel.add(tableField,new GridBagConstraints(1, line, - 2, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5,0,0,0), 0, 0)); - // - queryPanel.add(nameQLabel, new GridBagConstraints(0, ++line, - 1, 1, 0, 0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(10,0,0,5), 0, 0)); - queryPanel.add(nameQField, new GridBagConstraints(1, line, - 2, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(10,0,0,0), 0, 0)); - queryPanel.add(descriptionQLabel, new GridBagConstraints(0, ++line, - 1, 1, 0, 0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5,0,0,5), 0, 0)); - queryPanel.add(descriptionQField, new GridBagConstraints(1, line, - 2, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5,0,0,0), 0, 0)); - queryPanel.add(helpQLabel, new GridBagConstraints(0, ++line, - 1, 1, 0, 0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5,0,0,5), 0, 0)); - queryPanel.add(helpQField, new GridBagConstraints(1, line, - 2, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5,0,0,0), 0, 0)); - // - queryPanel.add(createdByQLabel, new GridBagConstraints(0, ++line, - 1, 1, 0, 0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(10,0,0,5), 0, 0)); - queryPanel.add(createdByQField, new GridBagConstraints(1, line, - 2, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(10,0,0,0), 0, 0)); - queryPanel.add(createdQLabel, new GridBagConstraints(0, ++line, - 1, 1, 0, 0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5,0,0,5), 0, 0)); - queryPanel.add(createdQFrom, new GridBagConstraints(1, line, - 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5,0,0,0), 0, 0)); - queryPanel.add(createdQTo, new GridBagConstraints(2, line, - 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5,0,0,0), 0, 0)); - panel.add(queryPanel, Msg.getMsg(Env.getCtx(), "ViewerQuery")); - // - // - line = 0; - viewPanel.add(viewPanelSplit, BorderLayout.CENTER); - viewPanelSplit.setLeftComponent(pdfViewer); - // - bBack.addActionListener(this); - bNext.addActionListener(this); - positionInfo.setFontBold(true); - positionInfo.setHorizontalAlignment(CLabel.CENTER); - viewEnterPanel.add(bBack, new GridBagConstraints(0, line, - 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0,0,0,0), 0, 0)); - viewEnterPanel.add(positionInfo, new GridBagConstraints(1, line, - 1, 1, 0, 0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0,5,0,5), 0, 0)); - viewEnterPanel.add(bNext, new GridBagConstraints(2, line, - 1, 1, 0, 0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0,0,0,5), 0, 0)); - // - createdByField.setReadWrite(false); - createdField.setReadWrite(false); - nameField.addVetoableChangeListener(this); - descriptionField.addVetoableChangeListener(this); - helpField.addVetoableChangeListener(this); - viewEnterPanel.add(createdByLabel, new GridBagConstraints(0, ++line, - 3, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5,0,0,5), 0, 0)); - viewEnterPanel.add(createdByField, new GridBagConstraints(0, ++line, - 3, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(2,0,0,5), 0, 0)); - // viewEnterPanel.add(createdLabel, new ALayoutConstraint(line++,0)); - viewEnterPanel.add(createdField, new GridBagConstraints(0, ++line, - 3, 1, 0, 0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(2,0,0,5), 0, 0)); - // - viewEnterPanel.add(nameLabel, new GridBagConstraints(0, ++line, - 3, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5,0,0,5), 0, 0)); - viewEnterPanel.add(nameField, new GridBagConstraints(0, ++line, - 3, 1, 1, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(2,0,0,5), 0, 0)); - // - viewEnterPanel.add(descriptionLabel, new GridBagConstraints(0, ++line, - 3, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5,0,0,5), 0, 0)); - viewEnterPanel.add(descriptionField,new GridBagConstraints(0, ++line, - 3, 1, 1, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(2,0,0,5), 0, 0)); - // - viewEnterPanel.add(helpLabel, new GridBagConstraints(0, ++line, - 3, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5,0,0,5), 0, 0)); - viewEnterPanel.add(helpField, new GridBagConstraints(0, ++line, - 3, 1, 1, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(2,0,0,5), 0, 0)); - // - viewEnterPanel.add(updateArchive, new GridBagConstraints(0, ++line, - 3, 1, 0, 0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5,0,0,5), 0, 0)); - // - viewEnterPanel.setPreferredSize(new Dimension(220,500)); - updateArchive.addActionListener(this); - viewPanelSplit.setRightComponent(viewEnterPanel); - panel.add(viewPanel, Msg.getMsg(Env.getCtx(), "ViewerResult")); - // - confirmPanel.addActionListener(this); - updateQDisplay(); - // - panel.setPreferredSize(new Dimension (720,500)); - } // jbInit - - /** - * Dispose - */ - public void dispose() - { - if (m_frame != null) - m_frame.dispose(); - m_frame = null; - } // dispose - - /** - * Action Listener - * @param e event - */ - public void actionPerformed (ActionEvent e) - { - if (log.isLoggable(Level.INFO)) log.info(e.getActionCommand()); - // - if (e.getSource() == updateArchive) - cmd_updateArchive(); - else if (e.getActionCommand().equals(ConfirmPanel.A_CANCEL)) - dispose(); - else if (e.getActionCommand().equals(ConfirmPanel.A_OK)) - { - if (panel.getSelectedIndex() == 1) - dispose(); - else - cmd_query(); - } - else if (e.getSource() == reportField) - updateQDisplay(); - else if (e.getSource() == bBack) - updateVDisplay(false); - else if (e.getSource() == bNext) - updateVDisplay(true); - } // actionPerformed - - /** - * Field Listener - * @param evt event - * @throws PropertyVetoException - */ - public void vetoableChange(PropertyChangeEvent evt) throws PropertyVetoException - { - if (m_archives.length > 0) - updateArchive.setEnabled(true); - } // vetableChange - - /** - * Update Query Display - */ - private void updateQDisplay() - { - boolean reports = reportField.isSelected(); - if (log.isLoggable(Level.CONFIG)) log.config("Reports=" + reports); - // Show - processLabel.setVisible(reports); - processField.setVisible(reports); - // Hide - bPartnerLabel.setVisible(!reports); - bPartnerField.setVisible(!reports); - } // updateQDisplay - - /** - * Update View Display - * @param next show next Archive - */ - private void updateVDisplay (boolean next) - { - if (m_archives == null) - m_archives = new MArchive[0]; - if (next) - m_index++; - else - m_index--; - if (m_index >= m_archives.length-1) - m_index = m_archives.length-1; - if (m_index < 0) - m_index = 0; - bBack.setEnabled(m_index > 0); - bNext.setEnabled(m_index < m_archives.length-1); - updateArchive.setEnabled(false); - // - if (log.isLoggable(Level.INFO)) log.info("Index=" + m_index + ", Length=" + m_archives.length); - if (m_archives.length == 0) - { - positionInfo.setText("No Record Found"); - createdByField.setText(""); - createdField.setValue(null); - nameField.setText(""); - descriptionField.setText(""); - helpField.setText(""); - pdfViewer.clearDocument(); - return; - } - // - positionInfo.setText(m_index+1 + " " + Msg.getMsg(Env.getCtx(), "of") + " " + m_archives.length); - MArchive ar = m_archives[m_index]; - createdByField.setText(ar.getCreatedByName()); - createdField.setValue(ar.getCreated()); - nameField.setText(ar.getName()); - descriptionField.setText(ar.getDescription()); - helpField.setText(ar.getHelp()); - // - try - { - InputStream in = ar.getInputStream(); - pdfViewer.setScale(reportField.isSelected() ? 50 : 75); - if (in != null) - pdfViewer.loadPDF(in); - else - pdfViewer.clearDocument(); - } - catch (Exception e) - { - log.log(Level.SEVERE, "pdf", e); - pdfViewer.clearDocument(); - } - } // updateVDisplay - - /** - * Update Archive Info - */ - private void cmd_updateArchive() - { - MArchive ar = m_archives[m_index]; - boolean update = false; - if (!isSame(nameField.getText(), ar.getName())) - { - String newText = nameField.getText(); - if (newText != null && newText.length() > 0) - { - ar.setName(newText); - update = true; - } - } - if (!isSame(descriptionField.getText(), ar.getDescription())) - { - ar.setDescription(descriptionField.getText()); - update = true; - } - if (!isSame(helpField.getText(), ar.getHelp())) - { - ar.setHelp(helpField.getText()); - update = true; - } - if (log.isLoggable(Level.INFO)) log.info("Update=" + update); - if (update) - ar.saveEx(); - // - m_index++; - updateVDisplay(false); - } // cmd_updateArchive - - /** - * Query Directly - * @param isReport report - * @param AD_Table_ID table - * @param Record_ID tecord - */ - public void query (boolean isReport, int AD_Table_ID, int Record_ID) - { - if (log.isLoggable(Level.CONFIG)) log.config("Report=" + isReport + ", AD_Table_ID=" + AD_Table_ID + ",Record_ID=" + Record_ID); - reportField.setSelected(isReport); - m_AD_Table_ID = AD_Table_ID; - m_Record_ID = Record_ID; - cmd_query(); - } // query - - - /************************************************************************** - * Create Query - */ - private void cmd_query() - { - boolean reports = reportField.isSelected(); - KeyNamePair process = (KeyNamePair)processField.getSelectedItem(); - KeyNamePair table = (KeyNamePair)tableField.getSelectedItem(); - Integer C_BPartner_ID = (Integer)bPartnerField.getValue(); - String name = nameQField.getText(); - String description = descriptionQField.getText(); - String help = helpQField.getText(); - KeyNamePair createdBy = (KeyNamePair)createdByQField.getSelectedItem(); - Timestamp createdFrom = createdQFrom.getTimestamp(); - Timestamp createdTo = createdQTo.getTimestamp(); - - cmd_query(reports, process, table, C_BPartner_ID, name, description, help, - createdBy, createdFrom, createdTo); - - // Display - panel.setSelectedIndex(1); - m_index = 1; - updateVDisplay(false); - } // cmd_query - - -} // ArchiveViewer diff --git a/org.adempiere.ui.swing/src/org/compiere/apps/form/FormFrame.java b/org.adempiere.ui.swing/src/org/compiere/apps/form/FormFrame.java deleted file mode 100644 index dd880d8502..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/apps/form/FormFrame.java +++ /dev/null @@ -1,500 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ -package org.compiere.apps.form; - -import java.awt.Cursor; -import java.awt.GraphicsConfiguration; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.awt.event.KeyEvent; -import java.sql.PreparedStatement; -import java.sql.ResultSet; -import java.sql.SQLException; -import java.util.Properties; -import java.util.logging.Level; - -import javax.swing.JFrame; -import javax.swing.JMenu; -import javax.swing.JMenuBar; -import javax.swing.KeyStroke; - -import org.adempiere.client.Client; -import org.compiere.apps.AEnv; -import org.compiere.apps.AGlassPane; -import org.compiere.apps.AMenu; -import org.compiere.apps.Help; -import org.compiere.apps.WindowMenu; -import org.compiere.model.GridTab; -import org.compiere.model.MRole; -import org.compiere.model.MUser; -import org.compiere.process.ProcessInfo; -import org.compiere.swing.CFrame; -import org.compiere.util.CLogger; -import org.compiere.util.DB; -import org.compiere.util.Env; -import org.compiere.util.Trace; - - -/** - * Form Framework - * - * @author Jorg Janke - * @version $Id: FormFrame.java,v 1.2 2006/07/30 00:51:28 jjanke Exp $ - * - * Colin Rooney 2007/03/20 RFE#1670185 & BUG#1684142 - * Extend security to Info Queries - */ -public class FormFrame extends CFrame - implements ActionListener -{ - /** - * - */ - private static final long serialVersionUID = 2559005548469735515L; - - /** - * @deprecated - * Create Form. - * Need to call openForm - */ - public FormFrame () - { - this(null); - } // FormFrame - - /** - * Create Form. - * Need to call openForm - * @param gc - */ - public FormFrame (GraphicsConfiguration gc) - { - super(gc); - addWindowListener(new java.awt.event.WindowAdapter() - { - public void windowOpened(java.awt.event.WindowEvent evt) - { - formWindowOpened(evt); - } - }); - - m_WindowNo = AEnv.createWindowNo (this); - setGlassPane(m_glassPane); - try - { - jbInit(); - createMenu(); - } - catch(Exception e) - { - log.log(Level.SEVERE, "", e); - } - } // FormFrame - - private ProcessInfo m_pi; - - /** WindowNo */ - private int m_WindowNo; - /** The GlassPane */ - private AGlassPane m_glassPane = new AGlassPane(); - /** Description */ - private String m_Description = null; - /** Help */ - private String m_Help = null; - /** Menu Bar */ - private JMenuBar menuBar = new JMenuBar(); - /** The Panel to be displayed */ - private FormPanel m_panel = null; - /** Maximize Window */ - public boolean m_maximize = false; - /** Logger */ - private static CLogger log = CLogger.getCLogger(FormFrame.class); - - /** Form ID */ - private int p_AD_Form_ID = 0; - - /** - * Static Init - * @throws Exception - */ - private void jbInit() throws Exception - { - this.setIconImage(org.compiere.Adempiere.getImage16()); - this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); - this.setJMenuBar(menuBar); - } // jbInit - - /** - * Create Menu - */ - private void createMenu() - { - // File - JMenu mFile = AEnv.getMenu("File"); - menuBar.add(mFile); - AEnv.addMenuItem("PrintScreen", null, KeyStroke.getKeyStroke(KeyEvent.VK_PRINTSCREEN, 0), mFile, this); - AEnv.addMenuItem("ScreenShot", null, KeyStroke.getKeyStroke(KeyEvent.VK_PRINTSCREEN, ActionEvent.SHIFT_MASK), mFile, this); - AEnv.addMenuItem("Report", null, KeyStroke.getKeyStroke(KeyEvent.VK_P, ActionEvent.ALT_MASK), mFile, this); - mFile.addSeparator(); - AEnv.addMenuItem("End", null, KeyStroke.getKeyStroke(KeyEvent.VK_X, ActionEvent.ALT_MASK), mFile, this); - AEnv.addMenuItem("Exit", null, KeyStroke.getKeyStroke(KeyEvent.VK_X, ActionEvent.SHIFT_MASK+ActionEvent.ALT_MASK), mFile, this); - - // View - JMenu mView = AEnv.getMenu("View"); - menuBar.add(mView); - - if (MRole.getDefault().isAllow_Info_Product()) - { - AEnv.addMenuItem("InfoProduct", null, KeyStroke.getKeyStroke(KeyEvent.VK_I, ActionEvent.ALT_MASK), mView, this); - } - if (MRole.getDefault().isAllow_Info_BPartner()) - { - AEnv.addMenuItem("InfoBPartner", null, KeyStroke.getKeyStroke(KeyEvent.VK_I, ActionEvent.ALT_MASK+ActionEvent.CTRL_MASK), mView, this); - } - if (MRole.getDefault().isShowAcct() && MRole.getDefault().isAllow_Info_Account()) - { - AEnv.addMenuItem("InfoAccount", null, KeyStroke.getKeyStroke(KeyEvent.VK_I, ActionEvent.ALT_MASK+ActionEvent.CTRL_MASK), mView, this); - } - if (MRole.getDefault().isAllow_Info_Schedule()) - { - AEnv.addMenuItem("InfoSchedule", null, null, mView, this); - } - mView.addSeparator(); - if (MRole.getDefault().isAllow_Info_Order()) - { - AEnv.addMenuItem("InfoOrder", "Info", null, mView, this); - } - if (MRole.getDefault().isAllow_Info_Invoice()) - { - AEnv.addMenuItem("InfoInvoice", "Info", null, mView, this); - } - if (MRole.getDefault().isAllow_Info_InOut()) - { - AEnv.addMenuItem("InfoInOut", "Info", null, mView, this); - } - if (MRole.getDefault().isAllow_Info_Payment()) - { - AEnv.addMenuItem("InfoPayment", "Info", null, mView, this); - } -// if (MRole.getDefault().isAllow_Info_CashJournal()) -// { -// AEnv.addMenuItem("InfoCashLine", "Info", null, mView, this); -// } - if (MRole.getDefault().isAllow_Info_Resource()) - { - AEnv.addMenuItem("InfoAssignment", "Info", null, mView, this); - } - if (MRole.getDefault().isAllow_Info_Asset()) - { - AEnv.addMenuItem("InfoAsset", "Info", null, mView, this); - } - // Tools - JMenu mTools = AEnv.getMenu("Tools"); - menuBar.add(mTools); - AEnv.addMenuItem("Calculator", null, null, mTools, this); - AEnv.addMenuItem("Calendar", null, null, mTools, this); - AEnv.addMenuItem("Editor", null, null, mTools, this); - MUser user = MUser.get(Env.getCtx()); - if (user.isAdministrator()) - AEnv.addMenuItem("Script", null, null, mTools, this); - if (MRole.getDefault().isShowPreference()) - { - mTools.addSeparator(); - AEnv.addMenuItem("Preference", null, null, mTools, this); - } - - // Window - AMenu aMenu = (AMenu)AEnv.getWindow(0); - JMenu mWindow = new WindowMenu(aMenu.getWindowManager(), this); - menuBar.add(mWindow); - - // Help - JMenu mHelp = AEnv.getMenu("Help"); - menuBar.add(mHelp); - AEnv.addMenuItem("Help", "Help", KeyStroke.getKeyStroke(KeyEvent.VK_F1, 0), mHelp, this); - AEnv.addMenuItem("Online", null, null, mHelp, this); - AEnv.addMenuItem("EMailSupport", null, null, mHelp, this); - AEnv.addMenuItem("About", null, null, mHelp, this); - } // createMenu - - /** - * Dispose - */ - public void dispose() - { - log.config(""); - // recursive calls - if (Trace.isCalledFrom("JFrame") && m_panel != null) // [x] close window pressed - m_panel.dispose(); - m_panel = null; - Env.clearWinContext(m_WindowNo); - super.dispose(); - } // dispose - - /** - * Open Form - * @param AD_Form_ID form - * @return true if form opened - */ - public boolean openForm (int AD_Form_ID) - { - return openForm(AD_Form_ID, null); - } - - public boolean openForm (int AD_Form_ID, GridTab gridTab) - { - Properties ctx = Env.getCtx(); - // - String name = null; - String className = null; - String sql = "SELECT Name, Description, ClassName, Help FROM AD_Form WHERE AD_Form_ID=?"; - boolean trl = !Env.isBaseLanguage(ctx, "AD_Form"); - if (trl) - sql = "SELECT t.Name, t.Description, f.ClassName, t.Help " - + "FROM AD_Form f INNER JOIN AD_Form_Trl t" - + " ON (f.AD_Form_ID=t.AD_Form_ID AND AD_Language=?)" - + "WHERE f.AD_Form_ID=?"; - PreparedStatement pstmt = null; - ResultSet rs = null; - try - { - pstmt = DB.prepareStatement (sql, null); - if (trl) - { - pstmt.setString(1, Env.getAD_Language(ctx)); - pstmt.setInt(2, AD_Form_ID); - } - else - pstmt.setInt(1, AD_Form_ID); - rs = pstmt.executeQuery(); - if (rs.next()) - { - name = rs.getString(1); - m_Description = rs.getString(2); - className = rs.getString(3); - m_Help = rs.getString(4); - } - } - catch (SQLException e) - { - log.log(Level.SEVERE, sql, e); - } - finally - { - DB.close(rs, pstmt); - rs = null; pstmt = null; - } - if (className == null) - return false; - // - return openForm(AD_Form_ID, className, name, gridTab); - } // openForm - - /** - * Open Form - * @param AD_Form_ID Form - * @param className class name - * @param name title - * @return true if started - */ - protected boolean openForm (int AD_Form_ID, String className, String name) - { - return openForm(AD_Form_ID, className, name, null); - } - - protected boolean openForm (int AD_Form_ID, String className, String name, GridTab gridTab) - { - if (log.isLoggable(Level.INFO)) log.info("AD_Form_ID=" + AD_Form_ID + " - Class=" + className); - Properties ctx = Env.getCtx(); - Env.setContext(ctx, m_WindowNo, "_WinInfo_WindowName", name); - setTitle(Env.getHeader(ctx, m_WindowNo)); - this.gridTab = gridTab; - - try - { - // Create instance w/o parameters - // Try equinox extension then java classpath - m_panel = Client.getFormPanel(className); - } - catch (Exception e) - { - log.log(Level.SEVERE, "Class=" + className + ", AD_Form_ID=" + AD_Form_ID, e); - return false; - } - // - m_panel.init(m_WindowNo, this); - p_AD_Form_ID = AD_Form_ID; - return true; - } // openForm - - /** - * Get Form Panel - * @return form panel - */ - public FormPanel getFormPanel() - { - return m_panel; - } // getFormPanel - - /** - * Action Listener - * @param e event - */ - public void actionPerformed(ActionEvent e) - { - String cmd = e.getActionCommand(); - if (cmd.equals("End")) - dispose(); - else if (cmd.equals("Help")) - actionHelp(); - else if (!AEnv.actionPerformed(cmd, m_WindowNo, this)) - log.log(Level.SEVERE, "Not handeled=" + cmd); - } // actionPerformed - - /** - * Show Help - */ - private void actionHelp() - { - StringBuilder sb = new StringBuilder(); - if (m_Description != null && m_Description.length() > 0) - sb.append("

    ").append(m_Description).append("

    "); - if (m_Help != null && m_Help.length() > 0) - sb.append("

    ").append(m_Help); - Help hlp = new Help (AEnv.getFrame(this), this.getTitle(), sb.toString()); - hlp.setVisible(true); - } // actionHelp - - - /************************************************************************* - * Set Window Busy - * @param busy busy - */ - public void setBusy (boolean busy) - { - if (busy == m_glassPane.isVisible()) - return; - if (log.isLoggable(Level.INFO)) log.info("Busy=" + busy); - if (busy) - setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); - else - setCursor(Cursor.getDefaultCursor()); - m_glassPane.setMessage(null); - m_glassPane.setVisible(busy); - m_glassPane.requestFocus(); - } // setBusy - - /** - * Set Busy Message - * @param AD_Message message - */ - public void setBusyMessage (String AD_Message) - { - m_glassPane.setMessage(AD_Message); - } // setBusyMessage - - /** - * Set and start Busy Counter - * @param time in seconds - */ - public void setBusyTimer (int time) - { - m_glassPane.setBusyTimer (time); - } // setBusyTimer - - - /** - * Set Maximize Window - * @param max maximize - */ - public void setMaximize (boolean max) - { - m_maximize = max; - } // setMaximize - - - /** - * Form Window Opened. - * Maximize window if required - * @param evt event - */ - private void formWindowOpened(java.awt.event.WindowEvent evt) - { - if (m_maximize == true) - { - super.setVisible(true); - super.setExtendedState(JFrame.MAXIMIZED_BOTH); - } - } // formWindowOpened - -// Add window and tab no called from - - public void setProcessInfo(ProcessInfo pi) - { - m_pi = pi; - - } - - public ProcessInfo getProcessInfo() - { - return m_pi; - } - - // End - - /** - * Start Batch - * @param process - * @return running thread - */ - public Thread startBatch (final Runnable process) - { - Thread worker = new Thread() - { - public void run() - { - setBusy(true); - process.run(); - setBusy(false); - } - }; - worker.start(); - return worker; - } // startBatch - - /** - * @return Returns the AD_Form_ID. - */ - public int getAD_Form_ID () - { - return p_AD_Form_ID; - } // getAD_Window_ID - /** - * @return Returns the manuBar - */ - public JMenuBar getMenu() - { - return menuBar; - } - - private GridTab gridTab; - - public GridTab getGridTab() - { - return gridTab; - } -} // FormFrame diff --git a/org.adempiere.ui.swing/src/org/compiere/apps/form/FormPanel.java b/org.adempiere.ui.swing/src/org/compiere/apps/form/FormPanel.java deleted file mode 100644 index dae1ca1b5d..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/apps/form/FormPanel.java +++ /dev/null @@ -1,40 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ -package org.compiere.apps.form; - - -/** - * Form Panel Interface. - * for communicating between FormFrame and JPanel - * @author Jorg Janke - * @version $Id: FormPanel.java,v 1.2 2006/07/30 00:51:28 jjanke Exp $ - */ -public interface FormPanel -{ - /** - * Initialize Panel - * @param WindowNo window - * @param frame parent frame - */ - public void init (int WindowNo, FormFrame frame); - - /** - * Dispose - Free Resources - */ - public void dispose(); - -} // FormPanel diff --git a/org.adempiere.ui.swing/src/org/compiere/apps/form/VAllocation.java b/org.adempiere.ui.swing/src/org/compiere/apps/form/VAllocation.java deleted file mode 100644 index 514b1cfe41..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/apps/form/VAllocation.java +++ /dev/null @@ -1,499 +0,0 @@ -/****************************************************************************** - * Copyright (C) 2009 Low Heng Sin * - * Copyright (C) 2009 Idalica Corporation * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - *****************************************************************************/ -package org.compiere.apps.form; - -import static org.compiere.model.SystemIDs.COLUMN_C_INVOICE_C_BPARTNER_ID; -import static org.compiere.model.SystemIDs.COLUMN_C_INVOICE_C_CURRENCY_ID; -import static org.compiere.model.SystemIDs.COLUMN_C_PERIOD_AD_ORG_ID; - -import java.awt.BorderLayout; -import java.awt.Dimension; -import java.awt.GridBagConstraints; -import java.awt.GridBagLayout; -import java.awt.Insets; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.beans.PropertyChangeEvent; -import java.beans.VetoableChangeListener; -import java.util.Vector; -import java.util.logging.Level; - -import javax.swing.BorderFactory; -import javax.swing.JButton; -import javax.swing.JCheckBox; -import javax.swing.JLabel; -import javax.swing.JScrollPane; -import javax.swing.JSplitPane; -import javax.swing.SwingConstants; -import javax.swing.event.TableModelEvent; -import javax.swing.event.TableModelListener; -import javax.swing.table.DefaultTableModel; - -import org.adempiere.plaf.AdempierePLAF; -import org.compiere.apps.ADialog; -import org.compiere.apps.StatusBar; -import org.compiere.grid.ed.VDate; -import org.compiere.grid.ed.VLookup; -import org.compiere.minigrid.MiniTable; -import org.compiere.model.MAllocationHdr; -import org.compiere.model.MLookup; -import org.compiere.model.MLookupFactory; -import org.compiere.plaf.CompiereColor; -import org.compiere.swing.CPanel; -import org.compiere.swing.CTextField; -import org.compiere.util.DisplayType; -import org.compiere.util.Env; -import org.compiere.util.Msg; -import org.compiere.util.Trx; -import org.compiere.util.TrxRunnable; - -public class VAllocation extends Allocation - implements FormPanel, ActionListener, TableModelListener, VetoableChangeListener -{ - private CPanel panel = new CPanel(); - - /** - * Initialize Panel - * @param WindowNo window - * @param frame frame - */ - public void init (int WindowNo, FormFrame frame) - { - m_WindowNo = WindowNo; - m_frame = frame; - Env.setContext(Env.getCtx(), m_WindowNo, "IsSOTrx", "Y"); // defaults to no - try - { - super.dynInit(); - dynInit(); - jbInit(); - calculate(); - frame.getContentPane().add(mainPanel, BorderLayout.CENTER); - frame.getContentPane().add(statusBar, BorderLayout.SOUTH); - } - catch(Exception e) - { - log.log(Level.SEVERE, "", e); - } - } // init - - /** Window No */ - private int m_WindowNo = 0; - /** FormFrame */ - private FormFrame m_frame; - - private CPanel mainPanel = new CPanel(); - private BorderLayout mainLayout = new BorderLayout(); - private CPanel parameterPanel = new CPanel(); - private CPanel allocationPanel = new CPanel(); - private GridBagLayout parameterLayout = new GridBagLayout(); - private JLabel bpartnerLabel = new JLabel(); - private VLookup bpartnerSearch = null; - private MiniTable invoiceTable = new MiniTable(); - private MiniTable paymentTable = new MiniTable(); - private JSplitPane infoPanel = new JSplitPane(); - private CPanel paymentPanel = new CPanel(); - private CPanel invoicePanel = new CPanel(); - private JLabel paymentLabel = new JLabel(); - private JLabel invoiceLabel = new JLabel(); - private BorderLayout paymentLayout = new BorderLayout(); - private BorderLayout invoiceLayout = new BorderLayout(); - private JLabel paymentInfo = new JLabel(); - private JLabel invoiceInfo = new JLabel(); - private JScrollPane paymentScrollPane = new JScrollPane(); - private JScrollPane invoiceScrollPane = new JScrollPane(); - private GridBagLayout allocationLayout = new GridBagLayout(); - private JLabel differenceLabel = new JLabel(); - private CTextField differenceField = new CTextField(); - private JButton allocateButton = new JButton(); - private JLabel currencyLabel = new JLabel(); - private VLookup currencyPick = null; - private JLabel chargeLabel = new JLabel(); - private VLookup chargePick = null; - private JCheckBox multiCurrency = new JCheckBox(); - private JLabel allocCurrencyLabel = new JLabel(); - private StatusBar statusBar = new StatusBar(); - private JLabel dateLabel = new JLabel(); - private VDate dateField = new VDate(); - private JCheckBox autoWriteOff = new JCheckBox(); - private JLabel organizationLabel = new JLabel(); - private VLookup organizationPick = null; - - /** - * Static Init - * @throws Exception - */ - private void jbInit() throws Exception - { - CompiereColor.setBackground(panel); - // - mainPanel.setLayout(mainLayout); - dateLabel.setText(Msg.getMsg(Env.getCtx(), "Date")); - dateLabel.setToolTipText(Msg.getMsg(Env.getCtx(), "AllocDate", false)); - autoWriteOff.setSelected(false); - autoWriteOff.setText(Msg.getMsg(Env.getCtx(), "AutoWriteOff", true)); - autoWriteOff.setToolTipText(Msg.getMsg(Env.getCtx(), "AutoWriteOff", false)); - // - parameterPanel.setLayout(parameterLayout); - allocationPanel.setLayout(allocationLayout); - bpartnerLabel.setText(Msg.translate(Env.getCtx(), "C_BPartner_ID")); - paymentLabel.setRequestFocusEnabled(false); - paymentLabel.setText(" " + Msg.translate(Env.getCtx(), "C_Payment_ID")); - invoiceLabel.setRequestFocusEnabled(false); - invoiceLabel.setText(" " + Msg.translate(Env.getCtx(), "C_Invoice_ID")); - paymentPanel.setLayout(paymentLayout); - invoicePanel.setLayout(invoiceLayout); - invoiceInfo.setHorizontalAlignment(SwingConstants.RIGHT); - invoiceInfo.setHorizontalTextPosition(SwingConstants.RIGHT); - invoiceInfo.setText("."); - paymentInfo.setHorizontalAlignment(SwingConstants.RIGHT); - paymentInfo.setHorizontalTextPosition(SwingConstants.RIGHT); - paymentInfo.setText("."); - chargeLabel.setText(Msg.translate(Env.getCtx(), "C_Charge_ID")); - chargeLabel.setToolTipText(Msg.getMsg(Env.getCtx(), "ChargeDifference", false)); - differenceLabel.setText(Msg.getMsg(Env.getCtx(), "Difference")); - differenceField.setBackground(AdempierePLAF.getFieldBackground_Inactive()); - differenceField.setEditable(false); - differenceField.setText("0"); - differenceField.setColumns(8); - differenceField.setHorizontalAlignment(SwingConstants.RIGHT); - allocateButton.setText(Msg.getMsg(Env.getCtx(), "Process")); - allocateButton.addActionListener(this); - currencyLabel.setText(Msg.translate(Env.getCtx(), "C_Currency_ID")); - multiCurrency.setText(Msg.getMsg(Env.getCtx(), "MultiCurrency")); - multiCurrency.addActionListener(this); - allocCurrencyLabel.setText("."); - invoiceScrollPane.setPreferredSize(new Dimension(200, 200)); - paymentScrollPane.setPreferredSize(new Dimension(200, 200)); - mainPanel.add(parameterPanel, BorderLayout.NORTH); - - //org filter - organizationLabel.setText(Msg.translate(Env.getCtx(), "AD_Org_ID")); - parameterPanel.add(organizationLabel, new GridBagConstraints(4, 0, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5,5,5,5), 0, 0)); - parameterPanel.add(organizationPick, new GridBagConstraints(5, 0, 1, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5,5,5,5), 0, 0)); - - parameterPanel.add(bpartnerLabel, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); - parameterPanel.add(bpartnerSearch, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 0, 5, 5), 0, 0)); - parameterPanel.add(dateLabel, new GridBagConstraints(2, 0, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); - parameterPanel.add(dateField, new GridBagConstraints(3, 0, 1, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 0, 5, 5), 0, 0)); - parameterPanel.add(currencyLabel, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); - parameterPanel.add(currencyPick, new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 0, 5, 5), 0, 0)); - parameterPanel.add(multiCurrency, new GridBagConstraints(3, 1, 1, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 0, 5, 5), 0, 0)); - parameterPanel.add(autoWriteOff, new GridBagConstraints(1, 2, 1, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); - mainPanel.add(allocationPanel, BorderLayout.SOUTH); - allocationPanel.add(differenceLabel, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 5, 5, 0), 0, 0)); - allocationPanel.add(differenceField, new GridBagConstraints(2, 0, 1, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 0, 5, 5), 0, 0)); - allocationPanel.add(chargeLabel, new GridBagConstraints(3, 0, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); - allocationPanel.add(chargePick, new GridBagConstraints(4, 0, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); - allocationPanel.add(allocateButton, new GridBagConstraints(5, 0, 1, 1, 0.0, 0.0 - ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(5, 0, 5, 5), 0, 0)); - allocationPanel.add(allocCurrencyLabel, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0 - ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); - paymentPanel.add(paymentLabel, BorderLayout.NORTH); - paymentPanel.add(paymentInfo, BorderLayout.SOUTH); - paymentPanel.add(paymentScrollPane, BorderLayout.CENTER); - paymentScrollPane.getViewport().add(paymentTable, null); - invoicePanel.add(invoiceLabel, BorderLayout.NORTH); - invoicePanel.add(invoiceInfo, BorderLayout.SOUTH); - invoicePanel.add(invoiceScrollPane, BorderLayout.CENTER); - invoiceScrollPane.getViewport().add(invoiceTable, null); - // - mainPanel.add(infoPanel, BorderLayout.CENTER); - infoPanel.setOrientation(JSplitPane.VERTICAL_SPLIT); - infoPanel.setBorder(BorderFactory.createEtchedBorder()); - infoPanel.setTopComponent(paymentPanel); - infoPanel.setBottomComponent(invoicePanel); - infoPanel.add(paymentPanel, JSplitPane.TOP); - infoPanel.add(invoicePanel, JSplitPane.BOTTOM); - infoPanel.setContinuousLayout(true); - infoPanel.setPreferredSize(new Dimension(800,250)); - infoPanel.setDividerLocation(110); - } // jbInit - - /** - * Dispose - */ - public void dispose() - { - if (m_frame != null) - m_frame.dispose(); - m_frame = null; - } // dispose - - /** - * Dynamic Init (prepare dynamic fields) - * @throws Exception if Lookups cannot be initialized - */ - public void dynInit() throws Exception - { - // Currency - int AD_Column_ID = COLUMN_C_INVOICE_C_CURRENCY_ID; // C_Invoice.C_Currency_ID - MLookup lookupCur = MLookupFactory.get (Env.getCtx(), m_WindowNo, 0, AD_Column_ID, DisplayType.TableDir); - currencyPick = new VLookup("C_Currency_ID", true, false, true, lookupCur); - currencyPick.setValue(Integer.valueOf(m_C_Currency_ID)); - currencyPick.addVetoableChangeListener(this); - - // Organization filter selection - AD_Column_ID = COLUMN_C_PERIOD_AD_ORG_ID; //C_Period.AD_Org_ID (needed to allow org 0) - MLookup lookupOrg = MLookupFactory.get(Env.getCtx(), m_WindowNo, 0, AD_Column_ID, DisplayType.TableDir); - organizationPick = new VLookup("AD_Org_ID", true, false, true, lookupOrg); - organizationPick.setValue(Env.getAD_Org_ID(Env.getCtx())); - organizationPick.addVetoableChangeListener(this); - - // BPartner - AD_Column_ID = COLUMN_C_INVOICE_C_BPARTNER_ID; // C_Invoice.C_BPartner_ID - MLookup lookupBP = MLookupFactory.get (Env.getCtx(), m_WindowNo, 0, AD_Column_ID, DisplayType.Search); - bpartnerSearch = new VLookup("C_BPartner_ID", true, false, true, lookupBP); - bpartnerSearch.addVetoableChangeListener(this); - - // Translation - statusBar.setStatusLine(Msg.getMsg(Env.getCtx(), "AllocateStatus")); - statusBar.setStatusDB(""); - - // Date set to Login Date - dateField.setValue(Env.getContextAsDate(Env.getCtx(), "#Date")); - dateField.addVetoableChangeListener(this); - - // Charge - AD_Column_ID = 61804; // C_AllocationLine.C_Charge_ID - MLookup lookupCharge = MLookupFactory.get (Env.getCtx(), m_WindowNo, 0, AD_Column_ID, DisplayType.TableDir); - chargePick = new VLookup("C_Charge_ID", false, false, true, lookupCharge); - chargePick.setValue(Integer.valueOf(m_C_Charge_ID)); - chargePick.addVetoableChangeListener(this); - } // dynInit - - /************************************************************************** - * Action Listener. - * - MultiCurrency - * - Allocate - * @param e event - */ - public void actionPerformed(ActionEvent e) - { - log.config(""); - if (e.getSource().equals(multiCurrency)) - loadBPartner(); - // Allocate - else if (e.getSource().equals(allocateButton)) - { - allocateButton.setEnabled(false); - saveData(); - loadBPartner(); - allocateButton.setEnabled(true); - } - } // actionPerformed - - /** - * Table Model Listener. - * - Recalculate Totals - * @param e event - */ - public void tableChanged(TableModelEvent e) - { - boolean isUpdate = (e.getType() == TableModelEvent.UPDATE); - // Not a table update - if (!isUpdate) - { - calculate(); - return; - } - - int row = e.getFirstRow(); - int col = e.getColumn(); - - if (row < 0) - return; - - boolean isInvoice = (e.getSource().equals(invoiceTable.getModel())); - boolean isAutoWriteOff = autoWriteOff.isSelected(); - - String msg = writeOff(row, col, isInvoice, paymentTable, invoiceTable, isAutoWriteOff); - - //render row - @SuppressWarnings("unused") - DefaultTableModel model = (DefaultTableModel) (isInvoice ? invoiceTable.getModel() : paymentTable.getModel()); - //model.fireTableRowsUpdated(row, row); - - if(msg != null && msg.length() > 0) - ADialog.warn(m_WindowNo, panel, "AllocationWriteOffWarn"); - - calculate(); - } // tableChanged - - /** - * Vetoable Change Listener. - * - Business Partner - * - Currency - * - Date - * @param e event - */ - public void vetoableChange (PropertyChangeEvent e) - { - String name = e.getPropertyName(); - Object value = e.getNewValue(); - if (log.isLoggable(Level.CONFIG)) log.config(name + "=" + value); - - if (value == null) - return; - - // Organization - if (name.equals("AD_Org_ID")) - { - m_AD_Org_ID = ((Integer) value).intValue(); - - loadBPartner(); - } -// Charge - else if (name.equals("C_Charge_ID") ) - { - m_C_Charge_ID = ((Integer) value).intValue(); - - setAllocateButton(); - } - - // BPartner - if (name.equals("C_BPartner_ID")) - { - bpartnerSearch.setValue(value); - m_C_BPartner_ID = ((Integer)value).intValue(); - loadBPartner(); - } - // Currency - else if (name.equals("C_Currency_ID")) - { - m_C_Currency_ID = ((Integer)value).intValue(); - loadBPartner(); - } - // Date for Multi-Currency - else if (name.equals("Date") && multiCurrency.isSelected()) - loadBPartner(); - } // vetoableChange - - - private void setAllocateButton() { - if (totalDiff.signum() == 0 ^ m_C_Charge_ID > 0 ) - { - allocateButton.setEnabled(true); - // chargePick.setValue(m_C_Charge_ID); - } - else - { - allocateButton.setEnabled(false); - } - - if ( totalDiff.signum() == 0 ) - { - chargePick.setValue(null); - m_C_Charge_ID = 0; - } - } - - public void loadBPartner() - { - checkBPartner(); - - Vector> data = getPaymentData(multiCurrency.isSelected(), dateField.getValue(), paymentTable); - Vector columnNames = getPaymentColumnNames(multiCurrency.isSelected()); - - // Remove previous listeners - paymentTable.getModel().removeTableModelListener(this); - - // Set Model - DefaultTableModel modelP = new DefaultTableModel(data, columnNames); - modelP.addTableModelListener(this); - paymentTable.setModel(modelP); - setPaymentColumnClass(paymentTable, multiCurrency.isSelected()); - // - - data = getInvoiceData(multiCurrency.isSelected(), dateField.getValue(), invoiceTable); - columnNames = getInvoiceColumnNames(multiCurrency.isSelected()); - - // Remove previous listeners - invoiceTable.getModel().removeTableModelListener(this); - - // Set Model - DefaultTableModel modelI = new DefaultTableModel(data, columnNames); - modelI.addTableModelListener(this); - invoiceTable.setModel(modelI); - setInvoiceColumnClass(invoiceTable, multiCurrency.isSelected()); - // - - calculate(multiCurrency.isSelected()); - - // Calculate Totals - calculate(); - } - - public void calculate() - { - allocDate = null; - - paymentInfo.setText(calculatePayment(paymentTable, multiCurrency.isSelected())); - invoiceInfo.setText(calculateInvoice(invoiceTable, multiCurrency.isSelected())); - - // Set AllocationDate - if (allocDate != null) - dateField.setValue(allocDate); - // Set Allocation Currency - allocCurrencyLabel.setText(currencyPick.getDisplay()); - // Difference - totalDiff = totalPay.subtract(totalInv); - differenceField.setText(format.format(totalDiff)); - - setAllocateButton(); - - } - - /************************************************************************** - * Save Data - */ - public void saveData() - { - if (m_AD_Org_ID > 0) - Env.setContext(Env.getCtx(), m_WindowNo, "AD_Org_ID", m_AD_Org_ID); - else - Env.setContext(Env.getCtx(), m_WindowNo, "AD_Org_ID", ""); - try - { - Trx.run(new TrxRunnable() - { - public void run(String trxName) - { - MAllocationHdr allocation = saveData(m_WindowNo, dateField.getValue(), paymentTable, invoiceTable, trxName); - if (allocation != null) - statusBar.setStatusLine(allocation.getDocumentNo()); - } - }); - } - catch (Exception e) - { - ADialog.error(m_WindowNo, panel, "Error", e.getLocalizedMessage()); - return; - } - } // saveData -} \ No newline at end of file diff --git a/org.adempiere.ui.swing/src/org/compiere/apps/form/VAttributeGrid.java b/org.adempiere.ui.swing/src/org/compiere/apps/form/VAttributeGrid.java deleted file mode 100644 index 2e9f6d364e..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/apps/form/VAttributeGrid.java +++ /dev/null @@ -1,550 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ -package org.compiere.apps.form; - -import java.awt.BorderLayout; -import java.awt.Color; -import java.awt.Dimension; -import java.awt.GridBagConstraints; -import java.awt.GridBagLayout; -import java.awt.GridLayout; -import java.awt.Insets; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.math.BigDecimal; -import java.sql.PreparedStatement; -import java.sql.ResultSet; -import java.sql.SQLException; -import java.text.DecimalFormat; -import java.util.Vector; -import java.util.logging.Level; - -import javax.swing.BorderFactory; -import javax.swing.BoxLayout; -import javax.swing.JLabel; -import javax.swing.event.ChangeEvent; -import javax.swing.event.ChangeListener; - -import org.compiere.Adempiere; -import org.compiere.apps.AEnv; -import org.compiere.apps.ALayout; -import org.compiere.apps.ALayoutConstraint; -import org.compiere.apps.ConfirmPanel; -import org.compiere.grid.ed.VComboBox; -import org.compiere.model.MAttribute; -import org.compiere.model.MAttributeValue; -import org.compiere.model.MProduct; -import org.compiere.model.MProductPrice; -import org.compiere.model.MRole; -import org.compiere.model.MStorageReservation; -import org.compiere.swing.CComboBox; -import org.compiere.swing.CLabel; -import org.compiere.swing.CPanel; -import org.compiere.swing.CScrollPane; -import org.compiere.swing.CTabbedPane; -import org.compiere.util.CLogger; -import org.compiere.util.DB; -import org.compiere.util.DisplayType; -import org.compiere.util.Env; -import org.compiere.util.KeyNamePair; -import org.compiere.util.Msg; - - -/** - * Product Attribute Table. - * Select one or two attributes for view/etc. - * - * @author Jorg Janke - * @version $Id: VAttributeGrid.java,v 1.2 2006/07/30 00:51:28 jjanke Exp $ - */ -public class VAttributeGrid extends CPanel - implements FormPanel, ChangeListener, ActionListener -{ - /** - * - */ - private static final long serialVersionUID = 3207678550566202041L; - - /** - * Init - * @param WindowNo - * @param frame - */ - public void init (int WindowNo, FormFrame frame) - { - m_WindowNo = WindowNo; - m_frame = frame; - // Layout - frame.getContentPane().add(this, BorderLayout.CENTER); - this.setLayout(new BorderLayout()); - this.add(tabbedPane, BorderLayout.CENTER); - this.add(confirmPanel, BorderLayout.SOUTH); - tabbedPane.addChangeListener(this); - confirmPanel.addActionListener(this); - // - tabbedPane.add(selectPanel, Msg.getMsg(Env.getCtx(), "Selection")); - selectPanel.add(attributeLabel1, new ALayoutConstraint(0,0)); - m_attributes = MAttribute.getOfClient(Env.getCtx(), true, true); - Vector vector = new Vector(); - vector.add(new KeyNamePair(0,"")); - for (int i = 0; i < m_attributes.length; i++) - vector.add(m_attributes[i].getKeyNamePair()); - attributeCombo1 = new CComboBox(vector); - selectPanel.add(attributeCombo1, null); - selectPanel.add(attributeLabel2, new ALayoutConstraint(1,0)); - attributeCombo2 = new CComboBox(vector); - selectPanel.add(attributeCombo2, null); - // - fillPicks(); - selectPanel.add(labelPriceList, new ALayoutConstraint(2,0)); - selectPanel.add(pickPriceList); - selectPanel.add(labelWarehouse, new ALayoutConstraint(3,0)); - selectPanel.add(pickWarehouse); - // - selectPanel.setPreferredSize(new Dimension (300,200)); - // - // Grid - tabbedPane.add(gridPanel, "AttributeGrid"); - modePanel.add(modeLabel); - modePanel.add(modeCombo); - modeCombo.addActionListener(this); - } // init - - /** Window No */ - @SuppressWarnings("unused") - private int m_WindowNo = 0; - /** FormFrame */ - private FormFrame m_frame; - /** Product Attributes */ - private MAttribute[] m_attributes = null; - /** Setting Grid */ - private boolean m_setting = false; - /** Logger */ - private static CLogger log = CLogger.getCLogger (VAttributeGrid.class); - - /** Modes */ - private static String[] MODES = new String[]{ - Msg.getMsg(Env.getCtx(), "ModeView") - // ,Msg.getMsg(Env.getCtx(), "ModePO") - // ,Msg.getMsg(Env.getCtx(), "ModePrice") - }; - private static final int MODE_VIEW = 0; - private static final int MODE_PO = 0; - private static final int MODE_PRICE = 0; - - /** Price List Version */ - private int m_M_PriceList_Version_ID = 0; - private DecimalFormat m_price = DisplayType.getNumberFormat(DisplayType.CostPrice); - /** Warehouse */ - private int m_M_Warehouse_ID = 0; - private DecimalFormat m_qty = DisplayType.getNumberFormat(DisplayType.Quantity); - - /** UI **/ - private CTabbedPane tabbedPane = new CTabbedPane(); - private CPanel selectPanel = new CPanel(new ALayout()); - private CLabel attributeLabel1 = new CLabel(Msg.getElement(Env.getCtx(), "M_Attribute_ID") + " 1"); - private CComboBox attributeCombo1 = null; - private CLabel attributeLabel2 = new CLabel(Msg.getElement(Env.getCtx(), "M_Attribute_ID") + " 2"); - private CComboBox attributeCombo2 = null; - private CLabel labelPriceList = new CLabel(Msg.getElement(Env.getCtx(), "M_PriceList_ID")); - private VComboBox pickPriceList = new VComboBox(); - private CLabel labelWarehouse = new CLabel(Msg.getElement(Env.getCtx(), "M_Warehouse_ID")); - private VComboBox pickWarehouse = new VComboBox(); - private ConfirmPanel confirmPanel = new ConfirmPanel(true); - // - private CPanel gridPanel = new CPanel(new BorderLayout()); - private CPanel modePanel = new CPanel(); - private CLabel modeLabel = new CLabel(Msg.getMsg(Env.getCtx(), "Mode")); - private CComboBox modeCombo = new CComboBox(MODES); - - /** - * Dispose - */ - public void dispose () - { - if (m_frame != null) - m_frame.dispose(); - m_frame = null; - } // dispose - - /** - * Fill Picks with values - */ - private void fillPicks () - { - // Price List - String sql = "SELECT M_PriceList_Version.M_PriceList_Version_ID," - + " M_PriceList_Version.Name || ' (' || c.Iso_Code || ')' AS ValueName " - + "FROM M_PriceList_Version, M_PriceList pl, C_Currency c " - + "WHERE M_PriceList_Version.M_PriceList_ID=pl.M_PriceList_ID" - + " AND pl.C_Currency_ID=c.C_Currency_ID" - + " AND M_PriceList_Version.IsActive='Y' AND pl.IsActive='Y'"; - // Add Access & Order - sql = MRole.getDefault().addAccessSQL (sql, "M_PriceList_Version", true, false) // fully qualidfied - RO - + " ORDER BY M_PriceList_Version.Name"; - PreparedStatement pstmt = null; - ResultSet rs = null; - try - { - pickPriceList.addItem(new KeyNamePair (0, "")); - pstmt = DB.prepareStatement(sql, null); - rs = pstmt.executeQuery(); - while (rs.next()) - { - KeyNamePair kn = new KeyNamePair (rs.getInt(1), rs.getString(2)); - pickPriceList.addItem(kn); - } - DB.close(rs, pstmt); - rs = null;pstmt = null; - - // Warehouse - sql = "SELECT M_Warehouse_ID, Value || ' - ' || Name AS ValueName " - + "FROM M_Warehouse " - + "WHERE IsActive='Y'"; - sql = MRole.getDefault().addAccessSQL (sql, - "M_Warehouse", MRole.SQL_NOTQUALIFIED, MRole.SQL_RO) - + " ORDER BY Value"; - pickWarehouse.addItem(new KeyNamePair (0, "")); - pstmt = DB.prepareStatement(sql, null); - rs = pstmt.executeQuery(); - while (rs.next()) - { - KeyNamePair kn = new KeyNamePair - (rs.getInt("M_Warehouse_ID"), rs.getString("ValueName")); - pickWarehouse.addItem(kn); - } - } - catch (SQLException e) - { - log.log(Level.SEVERE, sql, e); - } - finally - { - DB.close(rs, pstmt); - rs = null; - pstmt = null; - } - } // fillPicks - - - /** - * Change Listener - * @param e event - */ - public void stateChanged (ChangeEvent e) - { - if (e.getSource() != tabbedPane) - return; - if (tabbedPane.getSelectedIndex() == 1) - createGrid(); - } // stateChanged - - /** - * Action Performed - * @param e event - */ - public void actionPerformed (ActionEvent e) - { - // log.fine(e.toString()); - if (e.getSource() == modeCombo) - createGrid(); - else if (e.getActionCommand().equals(ConfirmPanel.A_OK)) - { - if (tabbedPane.getSelectedIndex() == 0) - createGrid(); - else - gridOK(); - } - else if (e.getActionCommand().equals(ConfirmPanel.A_CANCEL)) - m_frame.dispose(); - } // actionPerformed - - - private void gridOK() - { - int mode = modeCombo.getSelectedIndex(); - // Create PO - if (mode == MODE_PO) - { - createPO(); - modeCombo.setSelectedIndex(MODE_VIEW); - return; - } - // Update Prices - else if (mode == MODE_PRICE) - { - updatePrices(); - modeCombo.setSelectedIndex(MODE_VIEW); - return; - } - else if (mode == MODE_VIEW) - ; - m_frame.dispose(); - } // gridOK - - private void createPO() - { - - } - private void updatePrices() - { - - } - /** - * Create Grid - */ - private void createGrid() - { - if (attributeCombo1 == null || m_setting) - return; // init - int indexAttr1 = attributeCombo1.getSelectedIndex(); - int indexAttr2 = attributeCombo2.getSelectedIndex(); - if (indexAttr1 == indexAttr2) - { - log.warning("Same Attribute Selected"); - tabbedPane.setSelectedIndex(0); - return; - } - m_setting = true; - m_M_PriceList_Version_ID = 0; - KeyNamePair pl = (KeyNamePair)pickPriceList.getSelectedItem(); - if (pl != null) - m_M_PriceList_Version_ID = pl.getKey(); - m_M_Warehouse_ID = 0; - KeyNamePair wh = (KeyNamePair)pickWarehouse.getSelectedItem(); - if (wh != null) - m_M_Warehouse_ID = wh.getKey(); - - // x dimension - int cols = 2; - MAttributeValue[] xValues = null; - if (indexAttr1 > 0) - xValues = m_attributes[indexAttr1-1].getMAttributeValues(); - if (xValues != null) - { - cols = xValues.length + 1; - if (log.isLoggable(Level.INFO)) log.info("X - " + m_attributes[indexAttr1-1].getName() + " #" + xValues.length); - } - - // y dimension - int rows = 2; - MAttributeValue[] yValues = null; - if (indexAttr2 > 0) - yValues = m_attributes[indexAttr2-1].getMAttributeValues(); - if (yValues != null) - { - rows = yValues.length + 1; - if (log.isLoggable(Level.INFO)) log.info("Y - " + m_attributes[indexAttr2-1].getName() + " #" + yValues.length); - } - - // - gridPanel.removeAll(); - CPanel grid = new CPanel(new GridLayout(rows, cols, 5,5)); - gridPanel.add(modePanel, BorderLayout.NORTH); - gridPanel.add(new CScrollPane(grid), BorderLayout.CENTER); - // - if (log.isLoggable(Level.INFO)) log.info("Rows=" + rows + " - Cols=" + cols); - for (int row = 0; row < rows; row++) - { - for (int col = 0; col < cols; col++) - { - MAttributeValue xValue = null; - if (xValues != null && col > 0) - xValue = xValues[col - 1]; - MAttributeValue yValue = null; - if (yValues != null && row > 0) - yValue = yValues[row - 1]; - // log.fine("Row=" + row + " - Col=" + col); - // - if (row == 0 && col == 0) - { - CPanel descr = new CPanel(new GridLayout(2,1,0,0)); - if (xValues != null) - descr.add(new JLabel(m_attributes[indexAttr1-1].getName(),JLabel.TRAILING)); - if (yValues != null) - descr.add(new JLabel(m_attributes[indexAttr2-1].getName())); - grid.add(descr); - } - else if (row == 0) // column labels - { - if (xValue != null) - { - grid.add(new JLabel(xValue.getName(), JLabel.TRAILING)); - } - else - grid.add(new JLabel()); - } - else if (col == 0) // row labels - { - if (yValue != null) - grid.add(new JLabel(yValue.getName())); - else - grid.add(new JLabel()); - } - else - { - grid.add(getGridElement (xValue, yValue)); - } - } - } - // - tabbedPane.setSelectedIndex(1); - m_setting = false; - m_frame.pack(); - } // createGrid - - /** - * Get Grid Element - * @param xValue X value - * @param yValue Y value - * @return Panel with Info - */ - private CPanel getGridElement (MAttributeValue xValue, MAttributeValue yValue) - { - CPanel element = new CPanel(); - element.setBorder(BorderFactory.createLineBorder(Color.BLACK, 2)); - element.setLayout(new BoxLayout(element, BoxLayout.Y_AXIS)); - - String sql = "SELECT * FROM M_Product WHERE IsActive='Y'"; - // Product Attributes - if (xValue != null) - sql += " AND M_AttributeSetInstance_ID IN " - + "(SELECT M_AttributeSetInstance_ID " - + "FROM M_AttributeInstance " - + "WHERE M_Attribute_ID=" + xValue.getM_Attribute_ID() - + " AND M_AttributeValue_ID=" + xValue.getM_AttributeValue_ID() + ")"; - if (yValue != null) - sql += " AND M_AttributeSetInstance_ID IN " - + "(SELECT M_AttributeSetInstance_ID " - + "FROM M_AttributeInstance " - + "WHERE M_Attribute_ID=" + yValue.getM_Attribute_ID() - + " AND M_AttributeValue_ID=" + yValue.getM_AttributeValue_ID() + ")"; - sql = MRole.getDefault().addAccessSQL(sql, "M_Product", - MRole.SQL_NOTQUALIFIED, MRole.SQL_RO); - PreparedStatement pstmt = null; - ResultSet rs = null; - int noProducts = 0; - try - { - pstmt = DB.prepareStatement (sql, null); - rs = pstmt.executeQuery (); - while (rs.next ()) - { - MProduct product = new MProduct(Env.getCtx(), rs, null); - addProduct (element, product); - noProducts++; - } - } - catch (Exception e) - { - log.log (Level.SEVERE, sql, e); - } - finally - { - DB.close(rs, pstmt); - rs = null; - pstmt = null; - } - - int mode = modeCombo.getSelectedIndex(); - // No Products - if (noProducts == 0 && mode == MODE_VIEW) - { - // CButton button = ConfirmPanel.createNewButton(true); - // button.addActionListener(this); - // element.add(button); - } - else // Additional Elements - { - if (mode == MODE_PRICE) - { - // Price Field - } - else if (mode == MODE_PO) - { - // Qty Field - } - } - return element; - } // getGridElement - - /** - * Add Product - * @param element panel - * @param product product - */ - private void addProduct(CPanel element, MProduct product) - { - Insets ii = new Insets(2,4,2,4); - int M_Product_ID = product.getM_Product_ID(); - CPanel pe = new CPanel(); - pe.setBorder(BorderFactory.createLineBorder(Color.BLUE, 1)); - pe.setLayout(new GridBagLayout()); - - // Product Value - Price - pe.add(new JLabel(product.getValue()), new GridBagConstraints(0,0, 1,1, 0,0, - GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, ii, 0,0)); - String formatted = ""; - if (m_M_PriceList_Version_ID != 0) - { - MProductPrice pp = MProductPrice.get(Env.getCtx(), m_M_PriceList_Version_ID, M_Product_ID, null); - if (pp != null) - { - BigDecimal price = pp.getPriceStd(); - formatted = m_price.format(price); - } - else - formatted = "-"; - } - pe.add(new JLabel(formatted, JLabel.RIGHT), new GridBagConstraints(1,0, 1,1, .5,0, - GridBagConstraints.EAST, GridBagConstraints.HORIZONTAL, ii, 0,0)); - - // Product Name - Qty - pe.add(new JLabel(product.getName()), new GridBagConstraints(0,1, 1,1, 0,0, - GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, ii, 0,0)); - formatted = ""; - if (m_M_Warehouse_ID != 0) - { - BigDecimal qty = MStorageReservation.getQtyAvailable(m_M_Warehouse_ID, M_Product_ID, 0, null); - if (qty == null) - formatted = "-"; - else - formatted = m_qty.format(qty); - } - pe.add(new JLabel(formatted, JLabel.RIGHT), new GridBagConstraints(1,1, 1,1, .5,0, - GridBagConstraints.EAST, GridBagConstraints.HORIZONTAL, ii, 0,0)); - // - element.add(pe); - } // addProduct - - - /************************************************************************* - * Test - * @param args ignored - */ - public static void main (String[] args) - { - Adempiere.startup(true); - Env.setContext(Env.getCtx(), "#AD_Client_ID", 11); - FormFrame ff = new FormFrame(null); - ff.openForm(1111, "org.compiere.apps.form.VAttributeGrid", "Attribute Table"); - ff.pack(); - AEnv.showCenterScreen(ff); - } // main - - -} // VAttributeTable diff --git a/org.adempiere.ui.swing/src/org/compiere/apps/form/VBOMDrop.java b/org.adempiere.ui.swing/src/org/compiere/apps/form/VBOMDrop.java deleted file mode 100644 index 7da35141d1..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/apps/form/VBOMDrop.java +++ /dev/null @@ -1,738 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ -package org.compiere.apps.form; - -import java.awt.BorderLayout; -import java.awt.Dimension; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.math.BigDecimal; -import java.util.ArrayList; -import java.util.Enumeration; -import java.util.HashMap; -import java.util.Iterator; -import java.util.logging.Level; - -import javax.swing.AbstractButton; -import javax.swing.ButtonGroup; -import javax.swing.JCheckBox; -import javax.swing.JRadioButton; -import javax.swing.JToggleButton; -import javax.swing.border.TitledBorder; - -import org.compiere.apps.ALayout; -import org.compiere.apps.ALayoutConstraint; -import org.compiere.apps.ConfirmPanel; -import org.compiere.grid.ed.VNumber; -import org.compiere.model.MInvoice; -import org.compiere.model.MInvoiceLine; -import org.compiere.model.MOrder; -import org.compiere.model.MOrderLine; -import org.compiere.model.MProduct; -import org.compiere.model.MProject; -import org.compiere.model.MProjectLine; -import org.compiere.model.MRole; -import org.compiere.swing.CComboBox; -import org.compiere.swing.CLabel; -import org.compiere.swing.CPanel; -import org.compiere.swing.CScrollPane; -import org.compiere.util.CLogger; -import org.compiere.util.DB; -import org.compiere.util.DisplayType; -import org.compiere.util.Env; -import org.compiere.util.KeyNamePair; -import org.compiere.util.Msg; -import org.eevolution.model.MPPProductBOM; -import org.eevolution.model.MPPProductBOMLine; - -/** - * Drop BOM - * - * @author Jorg Janke - * @version $Id: VBOMDrop.java,v 1.3 2006/07/30 00:51:28 jjanke Exp $ - */ -public class VBOMDrop extends CPanel - implements FormPanel, ActionListener -{ - /** - * - */ - private static final long serialVersionUID = 3135475369002895149L; - - - /** - * Initialize Panel - * @param WindowNo window - * @param frame parent frame - */ - public void init (int WindowNo, FormFrame frame) - { - log.info(""); - m_WindowNo = WindowNo; - m_frame = frame; - try - { - // Top Selection Panel - createSelectionPanel(true, true, true); - m_frame.getContentPane().add(selectionPanel, BorderLayout.NORTH); - // Center - createMainPanel(); - CScrollPane scroll = new CScrollPane (this); - m_frame.getContentPane().add(scroll, BorderLayout.CENTER); - confirmPanel.addActionListener(this); - // South - m_frame.getContentPane().add(confirmPanel, BorderLayout.SOUTH); - } - catch(Exception e) - { - log.log(Level.SEVERE, "", e); - } - sizeIt(); - } // init - - /** - * Size Window - */ - private void sizeIt() - { - // Frame - m_frame.pack(); - Dimension size = m_frame.getPreferredSize(); - size.width = WINDOW_WIDTH; - m_frame.setSize(size); - } // size - - /** - * Dispose - */ - public void dispose() - { - if (m_frame != null) - m_frame.dispose(); - m_frame = null; - removeAll(); - if (selectionPanel != null) - selectionPanel.removeAll(); - selectionPanel = null; - if (m_selectionList != null) - m_selectionList.clear(); - m_selectionList = null; - if (m_productList != null) - m_productList.clear(); - m_productList = null; - if (m_qtyList != null) - m_qtyList.clear(); - m_qtyList = null; - if (m_buttonGroups != null) - m_buttonGroups.clear(); - m_buttonGroups = null; - } // dispose - - /** Window No */ - @SuppressWarnings("unused") - private int m_WindowNo = 0; - /** FormFrame */ - private FormFrame m_frame; - /** Product to create BOMs from */ - private MProduct m_product; - /** BOM Qty */ - private BigDecimal m_qty = Env.ONE; - /** Line Counter */ - private int m_bomLine = 0; - /** Logger */ - private static CLogger log = CLogger.getCLogger(VBOMDrop.class); - - /** List of all selectors */ - private ArrayList m_selectionList = new ArrayList(); - /** List of all quantities */ - private ArrayList m_qtyList = new ArrayList(); - /** List of all products */ - private ArrayList m_productList = new ArrayList(); - /** Alternative Group Lists */ - private HashMap m_buttonGroups = new HashMap(); - - private static final int WINDOW_WIDTH = 600; // width of the window - // - private ConfirmPanel confirmPanel = new ConfirmPanel (true); - private CPanel selectionPanel = new CPanel(new ALayout()); - private CComboBoxproductField; - private VNumber productQty = new VNumber("Qty", true, false, true, DisplayType.Quantity, Msg.translate(Env.getCtx(), "Qty")); - private CComboBoxorderField; - private CComboBoxinvoiceField; - private CComboBoxprojectField; - - - /************************************************************************** - * Create Selection Panel - * @param order - * @param invoice - * @param project - */ - private void createSelectionPanel (boolean order, boolean invoice, boolean project) - { - int row = 0; - selectionPanel.setBorder(new TitledBorder(Msg.translate(Env.getCtx(), "Selection"))); - productField = new CComboBox(getProducts()); - CLabel label = new CLabel(Msg.translate(Env.getCtx(), "M_Product_ID")); - label.setLabelFor(productField); - selectionPanel.add(label, new ALayoutConstraint(row++, 0)); - selectionPanel.add(productField); - productField.addActionListener(this); - // Qty - label = new CLabel (productQty.getTitle()); - label.setLabelFor(productQty); - selectionPanel.add(label); - selectionPanel.add(productQty); - productQty.setValue(Env.ONE); - productQty.addActionListener(this); - - if (order) - { - orderField = new CComboBox(getOrders()); - label = new CLabel (Msg.translate(Env.getCtx(), "C_Order_ID")); - label.setLabelFor(orderField); - selectionPanel.add(label, new ALayoutConstraint(row++, 0)); - selectionPanel.add(orderField); - orderField.addActionListener(this); - } - if (invoice) - { - invoiceField = new CComboBox(getInvoices()); - label = new CLabel (Msg.translate(Env.getCtx(), "C_Invoice_ID")); - label.setLabelFor(invoiceField); - selectionPanel.add(label, new ALayoutConstraint(row++, 0)); - selectionPanel.add(invoiceField); - invoiceField.addActionListener(this); - } - if (project) - { - projectField = new CComboBox(getProjects()); - label = new CLabel (Msg.translate(Env.getCtx(), "C_Project_ID")); - label.setLabelFor(projectField); - selectionPanel.add(label, new ALayoutConstraint(row++, 0)); - selectionPanel.add(projectField); - projectField.addActionListener(this); - } - // Enabled in ActionPerformed - confirmPanel.getOKButton().setEnabled(false); - // Size - Dimension size = selectionPanel.getPreferredSize(); - size.width = WINDOW_WIDTH; - selectionPanel.setPreferredSize(size); - } // createSelectionPanel - - /** - * Get Array of BOM Products - * @return products - */ - private KeyNamePair[] getProducts() - { - String sql = "SELECT M_Product_ID, Name " - + "FROM M_Product " - + "WHERE IsBOM='Y' AND IsVerified='Y' AND IsActive='Y' " - + "ORDER BY Name"; - return DB.getKeyNamePairs(MRole.getDefault().addAccessSQL( - sql, "M_Product", MRole.SQL_NOTQUALIFIED, MRole.SQL_RO), true); - } // getProducts - - /** - * Get Array of open Orders - * @return orders - */ - private KeyNamePair[] getOrders() - { - String sql = "SELECT C_Order_ID, DocumentNo || '_' || GrandTotal " - + "FROM C_Order " - + "WHERE Processed='N' AND DocStatus='DR' " - + "ORDER BY DocumentNo"; - return DB.getKeyNamePairs(MRole.getDefault().addAccessSQL( - sql, "C_Order", MRole.SQL_NOTQUALIFIED, MRole.SQL_RO), true); - } // getOrders - - /** - * Get Array of open non service Projects - * @return orders - */ - private KeyNamePair[] getProjects() - { - String sql = "SELECT C_Project_ID, Name " - + "FROM C_Project " - + "WHERE Processed='N' AND IsSummary='N' AND IsActive='Y'" - + " AND ProjectCategory<>'S' " - + "ORDER BY Name"; - return DB.getKeyNamePairs(MRole.getDefault().addAccessSQL( - sql, "C_Project", MRole.SQL_NOTQUALIFIED, MRole.SQL_RO), true); - } // getProjects - - /** - * Get Array of open Invoices - * @return invoices - */ - private KeyNamePair[] getInvoices() - { - String sql = "SELECT C_Invoice_ID, DocumentNo || '_' || GrandTotal " - + "FROM C_Invoice " - + "WHERE Processed='N' AND DocStatus='DR' " - + "ORDER BY DocumentNo"; - return DB.getKeyNamePairs(MRole.getDefault().addAccessSQL( - sql, "C_Invoice", MRole.SQL_NOTQUALIFIED, MRole.SQL_RO), true); - } // getInvoices - - - /************************************************************************** - * Create Main Panel. - * Called when changing Product - */ - private void createMainPanel () - { - if (log.isLoggable(Level.CONFIG)) log.config(": " + m_product); - this.removeAll(); - this.setPreferredSize(null); - this.invalidate(); - this.setBorder(null); - // - m_selectionList.clear(); - m_productList.clear(); - m_qtyList.clear(); - m_buttonGroups.clear(); - // - this.setLayout (new ALayout()); - String title = Msg.getMsg(Env.getCtx(), "SelectProduct"); - if (m_product != null && m_product.get_ID() > 0) - { - title = m_product.getName(); - if (m_product.getDescription() != null && m_product.getDescription().length() > 0) - this.setToolTipText(m_product.getDescription()); - m_bomLine = 0; - addBOMLines(m_product, m_qty); - } - this.setBorder (new TitledBorder(title)); - } // createMainPanel - - /** - * Add BOM Lines to this. - * Called recursively - * @param product product - * @param qty quantity - */ - private void addBOMLines (MProduct product, BigDecimal qty) - { - MPPProductBOM bom = MPPProductBOM.getDefault(product, null); - MPPProductBOMLine[] bomLines = bom.getLines(true); - for (int i = 0; i < bomLines.length; i++) - addBOMLine (bomLines[i], qty); - if (log.isLoggable(Level.FINE)) log.fine("#" + bomLines.length); - } - - /** - * Add BOM Line to this. - * Calls addBOMLines if added product is a BOM - * @param line BOM Line - * @param qty quantity - */ - private void addBOMLine (MPPProductBOMLine line, BigDecimal qty) - { - if (log.isLoggable(Level.FINE)) log.fine(line.toString()); - String bomType = line.getComponentType(); - if (bomType == null) - bomType = MPPProductBOMLine.COMPONENTTYPE_Component; - // - BigDecimal lineQty = line.getQty(); - MProduct product = line.getProduct(); - if (product == null) - return; - if (product.isBOM() && product.isVerified()) - addBOMLines (product, lineQty); // recursive - else - addDisplay (line.getM_Product_ID(), - product.getM_Product_ID(), bomType, product.getName(), line.getFeature(), lineQty); - } // addBOMLine - - - /** - * Add Line to Display - * @param parentM_Product_ID parent product - * @param M_Product_ID product - * @param bomType bom type - * @param name name - * @param lineQty qty - */ - private void addDisplay (int parentM_Product_ID, - int M_Product_ID, String bomType, String name, String feature , BigDecimal lineQty) - { - if (log.isLoggable(Level.FINE)) log.fine("M_Product_ID=" + M_Product_ID + ",Type=" + bomType + ",Name=" + name + ",feature=" + feature + ",Qty=" + lineQty); - // - boolean selected = true; - if (MPPProductBOMLine.COMPONENTTYPE_Component.equals(bomType)) - { - String title = ""; - JCheckBox cb = new JCheckBox(title); - cb.setSelected(true); - cb.setEnabled(false); - // cb.addActionListener(this); // will not change - m_selectionList.add(cb); - this.add(cb, new ALayoutConstraint(m_bomLine++, 0)); - } - else if (MPPProductBOMLine.COMPONENTTYPE_Option.equals(bomType)) - { - //String title = Msg.getMsg(Env.getCtx(), "Optional"); - JCheckBox cb = new JCheckBox(feature); - cb.setSelected(false); - selected = false; - cb.addActionListener(this); - m_selectionList.add(cb); - this.add(cb, new ALayoutConstraint(m_bomLine++, 0)); - } - else if (MPPProductBOMLine.COMPONENTTYPE_Variant.equals(bomType)) - { - //String title = Msg.getMsg(Env.getCtx(), "Variant") + " " + bomType; - JRadioButton b = new JRadioButton(feature); - String groupName = feature + "_" + String.valueOf(parentM_Product_ID) + "_" + bomType; - ButtonGroup group = (ButtonGroup)m_buttonGroups.get(groupName); - if (group == null) - { - if (log.isLoggable(Level.FINE)) log.fine("ButtonGroup=" + groupName); - group = new ButtonGroup(); - m_buttonGroups.put(groupName, group); - group.add(b); - b.setSelected(true); // select first one - } - else - { - group.add(b); - b.setSelected(false); - selected = false; - } - b.addActionListener(this); - m_selectionList.add(b); - this.add(b, new ALayoutConstraint(m_bomLine++, 0)); - } - // Add to List & display - m_productList.add (Integer.valueOf(M_Product_ID)); - VNumber qty = new VNumber ("Qty", true, false, true, DisplayType.Quantity, name); - qty.setValue(lineQty); - qty.setReadWrite(selected); - m_qtyList.add(qty); - CLabel label = new CLabel (name); - label.setLabelFor(qty); - this.add(label); - this.add(qty); - } // addDisplay - - - /** - * Get Preferred Size - * @return size - */ - public Dimension getPreferredSize () - { - Dimension size = super.getPreferredSize (); - if (size.width > WINDOW_WIDTH) - size.width = WINDOW_WIDTH - 30; - return size; - } // getPreferredSize - - - /************************************************************************** - * Action Listener - * @param e event - */ - public void actionPerformed (ActionEvent e) - { - if (log.isLoggable(Level.CONFIG)) log.config(e.getActionCommand()); - - Object source = e.getSource(); - - // Toggle Qty Enabled - if (source instanceof JCheckBox || source instanceof JRadioButton) - { - cmd_selection (source); - // need to de-select the others in group - if (source instanceof JRadioButton) - { - // find Button Group - Iterator it = m_buttonGroups.values().iterator(); - while (it.hasNext()) - { - ButtonGroup group = it.next(); - Enumeration en = group.getElements(); - while (en.hasMoreElements()) - { - // We found the group - if (source == en.nextElement()) - { - Enumeration info = group.getElements(); - while (info.hasMoreElements()) - { - Object infoObj = info.nextElement(); - if (source != infoObj) - cmd_selection(infoObj); - } - } - } - } - } - } // JCheckBox or JRadioButton - - // Product / Qty - else if (source == productField || source == productQty) - { - m_qty = (BigDecimal)productQty.getValue(); - KeyNamePair pp = (KeyNamePair)productField.getSelectedItem(); - m_product = MProduct.get (Env.getCtx(), pp.getKey()); - createMainPanel(); - sizeIt(); - } - - // Order - else if (source == orderField) - { - KeyNamePair pp = (KeyNamePair)orderField.getSelectedItem(); - boolean valid = (pp != null && pp.getKey() > 0); - // - if (invoiceField != null) - invoiceField.setReadWrite(!valid); - if (projectField != null) - projectField.setReadWrite(!valid); - } - // Invoice - else if (source == invoiceField) - { - KeyNamePair pp = (KeyNamePair)invoiceField.getSelectedItem(); - boolean valid = (pp != null && pp.getKey() > 0); - // - if (orderField != null) - orderField.setReadWrite(!valid); - if (projectField != null) - projectField.setReadWrite(!valid); - } - // Project - else if (source == projectField) - { - KeyNamePair pp = (KeyNamePair)projectField.getSelectedItem(); - boolean valid = (pp != null && pp.getKey() > 0); - // - if (orderField != null) - orderField.setReadWrite(!valid); - if (invoiceField != null) - invoiceField.setReadWrite(!valid); - } - - // OK - else if (e.getActionCommand().equals(ConfirmPanel.A_OK)) - { - if (cmd_save()) - dispose(); - } - else if (e.getActionCommand().equals(ConfirmPanel.A_CANCEL)) - dispose(); - - // Enable OK - boolean OK = m_product != null; - if (OK) - { - KeyNamePair pp = null; - if (orderField != null) - pp = (KeyNamePair)orderField.getSelectedItem(); - if ((pp == null || pp.getKey() <= 0) && invoiceField != null) - pp = (KeyNamePair)invoiceField.getSelectedItem(); - if ((pp == null || pp.getKey() <= 0) && projectField != null) - pp = (KeyNamePair)projectField.getSelectedItem(); - OK = (pp != null && pp.getKey() > 0); - } - confirmPanel.getOKButton().setEnabled(OK); - } // actionPerformed - - /** - * Enable/disable qty based on selection - * @param source JCheckBox or JRadioButton - */ - private void cmd_selection (Object source) - { - for (int i = 0; i < m_selectionList.size(); i++) - { - if (source == m_selectionList.get(i)) - { - boolean selected = isSelectionSelected(source); - VNumber qty = (VNumber)m_qtyList.get(i); - qty.setReadWrite(selected); - return; - } - } - log.log(Level.SEVERE, "not found - " + source); - } // cmd_selection - - /** - * Is Selection Selected - * @param source CheckBox or RadioButton - * @return true if selected - */ - private boolean isSelectionSelected (Object source) - { - boolean retValue = false; - if (source instanceof JCheckBox) - retValue = ((JCheckBox)source).isSelected(); - else if (source instanceof JRadioButton) - retValue = ((JRadioButton)source).isSelected(); - else - log.log(Level.SEVERE, "Not valid - " + source); - return retValue; - } // isSelected - - - /************************************************************************** - * Save Selection - * @return true if saved - */ - private boolean cmd_save() - { - KeyNamePair pp = (KeyNamePair)orderField.getSelectedItem(); - if (pp != null && pp.getKey() > 0) - return cmd_saveOrder (pp.getKey()); - // - pp = (KeyNamePair)invoiceField.getSelectedItem(); - if (pp != null && pp.getKey() > 0) - return cmd_saveInvoice (pp.getKey()); - // - pp = (KeyNamePair)projectField.getSelectedItem(); - if (pp != null && pp.getKey() > 0) - return cmd_saveProject (pp.getKey()); - // - log.log(Level.SEVERE, "Nothing selected"); - return false; - } // cmd_save - - /** - * Save to Order - * @param C_Order_ID id - * @return true if saved - */ - private boolean cmd_saveOrder (int C_Order_ID) - { - if (log.isLoggable(Level.CONFIG)) log.config("C_Order_ID=" + C_Order_ID); - MOrder order = new MOrder (Env.getCtx(), C_Order_ID, null); - if (order.get_ID() == 0) - { - log.log(Level.SEVERE, "Not found - C_Order_ID=" + C_Order_ID); - return false; - } - int lineCount = 0; - - // for all bom lines - for (int i = 0; i < m_selectionList.size(); i++) - { - if (isSelectionSelected(m_selectionList.get(i))) - { - BigDecimal qty = (BigDecimal)((VNumber)m_qtyList.get(i)).getValue(); - int M_Product_ID = ((Integer)m_productList.get(i)).intValue(); - // Create Line - MOrderLine ol = new MOrderLine (order); - ol.setM_Product_ID(M_Product_ID, true); - ol.setQty(qty); - ol.setPrice(); - ol.setTax(); - if (ol.save()) - lineCount++; - else - log.log(Level.SEVERE, "Line not saved"); - } // line selected - } // for all bom lines - - if (log.isLoggable(Level.CONFIG)) log.config("#" + lineCount); - return true; - } // cmd_saveOrder - - /** - * Save to Invoice - * @param C_Invoice_ID id - * @return true if saved - */ - private boolean cmd_saveInvoice (int C_Invoice_ID) - { - if (log.isLoggable(Level.CONFIG)) log.config("C_Invoice_ID=" + C_Invoice_ID); - MInvoice invoice = new MInvoice (Env.getCtx(), C_Invoice_ID, null); - if (invoice.get_ID() == 0) - { - log.log(Level.SEVERE, "Not found - C_Invoice_ID=" + C_Invoice_ID); - return false; - } - int lineCount = 0; - - // for all bom lines - for (int i = 0; i < m_selectionList.size(); i++) - { - if (isSelectionSelected(m_selectionList.get(i))) - { - BigDecimal qty = (BigDecimal)((VNumber)m_qtyList.get(i)).getValue(); - int M_Product_ID = ((Integer)m_productList.get(i)).intValue(); - // Create Line - MInvoiceLine il = new MInvoiceLine (invoice); - il.setM_Product_ID(M_Product_ID, true); - il.setQty(qty); - il.setPrice(); - il.setTax(); - if (il.save()) - lineCount++; - else - log.log(Level.SEVERE, "Line not saved"); - } // line selected - } // for all bom lines - - if (log.isLoggable(Level.CONFIG)) log.config("#" + lineCount); - return true; - } // cmd_saveInvoice - - /** - * Save to Project - * @param C_Project_ID id - * @return true if saved - */ - private boolean cmd_saveProject (int C_Project_ID) - { - if (log.isLoggable(Level.CONFIG)) log.config("C_Project_ID=" + C_Project_ID); - MProject project = new MProject (Env.getCtx(), C_Project_ID, null); - if (project.get_ID() == 0) - { - log.log(Level.SEVERE, "Not found - C_Project_ID=" + C_Project_ID); - return false; - } - int lineCount = 0; - - // for all bom lines - for (int i = 0; i < m_selectionList.size(); i++) - { - if (isSelectionSelected(m_selectionList.get(i))) - { - BigDecimal qty = (BigDecimal)((VNumber)m_qtyList.get(i)).getValue(); - int M_Product_ID = ((Integer)m_productList.get(i)).intValue(); - // Create Line - MProjectLine pl = new MProjectLine (project); - pl.setM_Product_ID(M_Product_ID); - pl.setPlannedQty(qty); - // pl.setPlannedPrice(); - if (pl.save()) - lineCount++; - else - log.log(Level.SEVERE, "Line not saved"); - } // line selected - } // for all bom lines - - if (log.isLoggable(Level.CONFIG)) log.config("#" + lineCount); - return true; - } // cmd_saveProject - -} // VBOMDrop diff --git a/org.adempiere.ui.swing/src/org/compiere/apps/form/VCharge.java b/org.adempiere.ui.swing/src/org/compiere/apps/form/VCharge.java deleted file mode 100644 index 2d0237a842..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/apps/form/VCharge.java +++ /dev/null @@ -1,245 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ -package org.compiere.apps.form; - -import java.awt.BorderLayout; -import java.awt.FlowLayout; -import java.awt.GridBagConstraints; -import java.awt.GridBagLayout; -import java.awt.Insets; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.util.logging.Level; - -import javax.swing.JButton; -import javax.swing.JCheckBox; -import javax.swing.JLabel; -import javax.swing.JScrollPane; -import javax.swing.JTextField; -import javax.swing.border.TitledBorder; -import javax.swing.table.DefaultTableModel; - -import org.adempiere.plaf.AdempierePLAF; -import org.compiere.apps.ADialog; -import org.compiere.apps.ConfirmPanel; -import org.compiere.minigrid.MiniTable; -import org.compiere.plaf.CompiereColor; -import org.compiere.swing.CPanel; -import org.compiere.util.Env; -import org.compiere.util.Msg; -import org.compiere.util.Util; - -/** - * Create Charge from Accounts - * - * @author Jorg Janke - * @version $Id: VCharge.java,v 1.3 2006/07/30 00:51:28 jjanke Exp $ - */ -public class VCharge extends Charge - implements FormPanel, ActionListener -{ - private CPanel panel = new CPanel(); - /** - * Initialize Panel - * @param WindowNo window - * @param frame parent frame - */ - public void init (int WindowNo, FormFrame frame) - { - log.info(""); - m_WindowNo = WindowNo; - m_frame = frame; - try - { - jbInit(); - dynInit(); - - frame.getContentPane().add(mainPanel, BorderLayout.CENTER); - frame.getContentPane().add(confirmPanel, BorderLayout.SOUTH); - } - catch(Exception e) - { - log.log(Level.SEVERE, "", e); - } - } // init - - /** FormFrame */ - private FormFrame m_frame; - - // - private CPanel mainPanel = new CPanel(); - private BorderLayout mainLayout = new BorderLayout(); - private CPanel newPanel = new CPanel(); - private TitledBorder newBorder; - private GridBagLayout newLayout = new GridBagLayout(); - private JLabel valueLabel = new JLabel(); - private JTextField valueField = new JTextField(); - private JCheckBox isExpense = new JCheckBox(); - private JLabel nameLabel = new JLabel(); - private JTextField nameField = new JTextField(); - private JButton newButton = new JButton(); - private CPanel accountPanel = new CPanel(); - private TitledBorder accountBorder; - private BorderLayout accountLayout = new BorderLayout(); - private CPanel accountOKPanel = new CPanel(); - private JButton accountButton = new JButton(); - private FlowLayout accountOKLayout = new FlowLayout(); - private JScrollPane dataPane = new JScrollPane(); - private MiniTable dataTable = new MiniTable(); - private ConfirmPanel confirmPanel = new ConfirmPanel(); - - /** - * Static Init - * @throws Exception - */ - private void jbInit() throws Exception - { - CompiereColor.setBackground(panel); - newBorder = new TitledBorder(""); - accountBorder = new TitledBorder(""); - mainPanel.setLayout(mainLayout); - newPanel.setBorder(newBorder); - newPanel.setLayout(newLayout); - newBorder.setTitle(Msg.getMsg(Env.getCtx(), "ChargeNewAccount")); - valueLabel.setText(Msg.translate(Env.getCtx(), "Value")); - isExpense.setSelected(true); - isExpense.setText(Msg.getMsg(Env.getCtx(), "Expense")); - nameLabel.setText(Msg.translate(Env.getCtx(), "Name")); - nameField.setColumns(20); - valueField.setColumns(10); - newButton.setText(Msg.getMsg(Env.getCtx(), "Create") + " " + Util.cleanAmp(Msg.getMsg(Env.getCtx(), "New"))); - newButton.addActionListener(this); - accountPanel.setBorder(accountBorder); - accountPanel.setLayout(accountLayout); - accountBorder.setTitle(Msg.getMsg(Env.getCtx(), "ChargeFromAccount")); - accountButton.setText(Msg.getMsg(Env.getCtx(), "Create") + " " + Msg.getMsg(Env.getCtx(), "From") + " " + Msg.getElement(Env.getCtx(), "Account_ID")); - accountButton.addActionListener(this); - accountOKPanel.setLayout(accountOKLayout); - accountOKLayout.setAlignment(FlowLayout.RIGHT); - confirmPanel.addActionListener(this); - // - mainPanel.add(newPanel, BorderLayout.NORTH); - newPanel.add(valueLabel, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); - newPanel.add(valueField, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 0, 5, 5), 0, 0)); - newPanel.add(nameLabel, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); - newPanel.add(nameField, new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 0, 5, 5), 0, 0)); - newPanel.add(isExpense, new GridBagConstraints(2, 0, 1, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); - newPanel.add(newButton, new GridBagConstraints(2, 1, 1, 1, 0.0, 0.0 - ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); - mainPanel.add(accountPanel, BorderLayout.CENTER); - accountPanel.add(accountOKPanel, BorderLayout.SOUTH); - accountOKPanel.add(accountButton, null); - accountPanel.add(dataPane, BorderLayout.CENTER); - dataPane.getViewport().add(dataTable, null); - } // jbInit - - /** - * Dispose - */ - public void dispose() - { - if (m_frame != null) - m_frame.dispose(); - m_frame = null; - } // dispose - - /** - * Action Listener - * @param e event - */ - public void actionPerformed (ActionEvent e) - { - if (log.isLoggable(Level.INFO)) log.info(e.getActionCommand()); - // - if (e.getActionCommand().equals(ConfirmPanel.A_OK) || m_C_Element_ID == 0) - dispose(); - // new Account - else if (e.getSource().equals(newButton)) - createNew(); - else if (e.getSource().equals(accountButton)) - createAccount(); - } // actionPerformed - - /** - * Create new Account and Charge - */ - private void createNew() - { - log.config(""); - // Get Input - String value = valueField.getText(); - if (value.length() == 0) - { - valueField.setBackground(AdempierePLAF.getFieldBackground_Error()); - return; - } - String name = nameField.getText(); - if (name.length() == 0) - { - nameField.setBackground(AdempierePLAF.getFieldBackground_Error()); - return; - } - // Create Element - int C_ElementValue_ID = createElementValue (value, name, isExpense.isSelected()); - if (C_ElementValue_ID == 0) - { - ADialog.error(m_WindowNo, panel, "ChargeNotCreated", name); - return; - } - // Create Charge - int C_Charge_ID = createCharge(name, C_ElementValue_ID); - if (C_Charge_ID == 0) - { - ADialog.error(m_WindowNo, panel, "ChargeNotCreated", name); - return; - } - ADialog.info(m_WindowNo, panel, "ChargeCreated", name); - } // createNew - - /** - * Create Charges from Accounts - */ - private void createAccount() - { - createAccount(dataTable); - - if (listCreated.length() > 0) - ADialog.info(m_WindowNo, panel, "ChargeCreated", listCreated.toString()); - if (listRejected.length() > 0) - ADialog.error(m_WindowNo, panel, "ChargeNotCreated", listRejected.toString()); - } // createAccount - - /** - * Dynamic Init - * - Get defaults for primary AcctSchema - * - Create Table with Accounts - */ - private void dynInit() - { - findChargeElementID(); - DefaultTableModel model = new DefaultTableModel(getData(), getColumnNames()); - dataTable.setModel(model); - setColumnClass(dataTable); - findTaxCategoryID(); - } - -} // VCharge diff --git a/org.adempiere.ui.swing/src/org/compiere/apps/form/VCreateFromForm.java b/org.adempiere.ui.swing/src/org/compiere/apps/form/VCreateFromForm.java deleted file mode 100644 index 426c54e778..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/apps/form/VCreateFromForm.java +++ /dev/null @@ -1,237 +0,0 @@ -/****************************************************************************** - * Copyright (C) 2013 Elaine Tan * - * Copyright (C) 2013 Trek Global - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - *****************************************************************************/ -package org.compiere.apps.form; - -import java.awt.BorderLayout; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; - -import javax.swing.JScrollPane; -import javax.swing.event.TableModelEvent; -import javax.swing.event.TableModelListener; -import javax.swing.table.TableModel; - -import org.compiere.apps.ADialog; -import org.compiere.apps.AppsAction; -import org.compiere.apps.ConfirmPanel; -import org.compiere.apps.StatusBar; -import org.compiere.minigrid.MiniTable; -import org.compiere.swing.CPanel; -import org.compiere.swing.CToggleButton; -import org.compiere.util.Env; -import org.compiere.util.Msg; -import org.compiere.util.Trx; -import org.compiere.util.TrxRunnable; - -/** - * - * @author Elaine - * - */ -public class VCreateFromForm extends CPanel implements ActionListener, TableModelListener -{ - - /** - * - */ - private static final long serialVersionUID = -8242250391030501785L; - private CreateFromForm form; - private int windowNo; - /** FormFrame */ - private FormFrame m_frame; - - private CPanel parameterPanel = new CPanel(); - private ConfirmPanel confirmPanel = new ConfirmPanel(true); - private StatusBar statusBar = new StatusBar(); - private MiniTable dataTable = new MiniTable(); - - private static final String SELECT_DESELECT_ALL = "SelectAll"; - protected AppsAction selectDeselectAllAction = new AppsAction (SELECT_DESELECT_ALL, null, Msg.getMsg(Env.getCtx(), SELECT_DESELECT_ALL), true); - - public VCreateFromForm(CreateFromForm createFrom, FormFrame frame) - { - super(); - this.form = createFrom; - this.m_frame = frame; - - try - { - jbInit(); - confirmPanel.addActionListener(this); - - statusBar.setStatusDB(""); - tableChanged(null); - } - catch(Exception e) - { - - } - } - - protected void jbInit() throws Exception - { - m_frame.getContentPane().add(parameterPanel, BorderLayout.NORTH); - - JScrollPane dataPane = new JScrollPane(); - m_frame.getContentPane().add(dataPane, BorderLayout.CENTER); - dataPane.getViewport().add(dataTable, null); - - CToggleButton selectAllButton = (CToggleButton)selectDeselectAllAction.getButton(); - selectAllButton.setMargin(ConfirmPanel.s_insets); - selectAllButton.addActionListener(this); - confirmPanel.addComponent(selectAllButton); - - CPanel southPanel = new CPanel(); - m_frame.getContentPane().add(southPanel, BorderLayout.SOUTH); - BorderLayout southLayout = new BorderLayout(); - southPanel.setLayout(southLayout); - southPanel.add(confirmPanel, BorderLayout.CENTER); - southPanel.add(statusBar, BorderLayout.SOUTH); - } - - public void actionPerformed(ActionEvent e) - { - if (e.getActionCommand().equals(ConfirmPanel.A_OK)) - { - try - { - Trx.run(new TrxRunnable() - { - public void run(String trxName) - { - if (save(trxName)) - { - dispose(); - } - } - }); - } - catch (Exception ex) - { - ADialog.error(windowNo, this, "Error", ex.getLocalizedMessage()); - } - } - // Cancel - else if (e.getActionCommand().equals(ConfirmPanel.A_CANCEL)) - { - dispose(); - } - // Select All - // Trifon - else if (e.getActionCommand().equals(SELECT_DESELECT_ALL)) - { - TableModel model = dataTable.getModel(); - model.removeTableModelListener(this); - - // select or deselect all as required - int rows = model.getRowCount(); - Boolean selectAll = selectDeselectAllAction.isPressed() ? Boolean.FALSE : Boolean.TRUE; - for (int i = 0; i < rows; i++) - model.setValueAt(selectAll, i, 0); - - model.addTableModelListener(this); - - info(); - } - } - - public boolean save(String trxName) - { - dataTable.stopEditor(true); - - TableModel model = dataTable.getModel(); - int rows = model.getRowCount(); - if (rows == 0) - return false; - - return form.save(dataTable, trxName, m_frame.getGridTab()); - } - - public void tableChanged (TableModelEvent e) - { - int type = -1; - if (e != null) - { - type = e.getType(); - if (type != TableModelEvent.UPDATE) - return; - - if (e.getColumn() == 0) - { - TableModel model = dataTable.getModel(); - Boolean isPressed = (Boolean)model.getValueAt(0, 0); - int rows = model.getRowCount(); - boolean equals = true; - for (int i = 1; equals && i < rows; i++) - { - equals = isPressed.equals(model.getValueAt(i, 0)); - } - - if (equals) { - selectDeselectAllAction.setPressed(isPressed); - } - } - } - info(); - dataTable.repaint(); - } - - public void info() - { - TableModel model = dataTable.getModel(); - int rows = model.getRowCount(); - int count = 0; - for (int i = 0; i < rows; i++) - { - if (((Boolean)model.getValueAt(i, 0)).booleanValue()) - count++; - } - setStatusLine(count, null); - - form.info(dataTable, statusBar); - } - - public void setStatusLine(int selectedRowCount, String text) - { - StringBuilder sb = new StringBuilder(String.valueOf(selectedRowCount)); - if (text != null && text.trim().length() > 0) { - sb.append(" - ").append(text); - } - statusBar.setStatusLine(sb.toString()); - // - confirmPanel.getOKButton().setEnabled(selectedRowCount > 0); - } - - public MiniTable getMiniTable() - { - return dataTable; - } - - public CPanel getParameterPanel() - { - return parameterPanel; - } - - public ConfirmPanel getConfirmPanel() - { - return confirmPanel; - } - - public void dispose() - { - if (m_frame != null) - m_frame.dispose(); - m_frame = null; - } -} \ No newline at end of file diff --git a/org.adempiere.ui.swing/src/org/compiere/apps/form/VFactReconcile.java b/org.adempiere.ui.swing/src/org/compiere/apps/form/VFactReconcile.java deleted file mode 100644 index bd4cd398d1..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/apps/form/VFactReconcile.java +++ /dev/null @@ -1,481 +0,0 @@ -package org.compiere.apps.form; - -import java.awt.BorderLayout; -import java.awt.Dimension; -import java.awt.FlowLayout; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.beans.PropertyChangeEvent; -import java.beans.PropertyVetoException; -import java.beans.VetoableChangeListener; -import java.math.BigDecimal; -import java.sql.Timestamp; -import java.text.DecimalFormat; -import java.text.SimpleDateFormat; -import java.util.Calendar; -import java.util.Properties; -import java.util.Vector; -import java.util.logging.Level; - -import javax.swing.JButton; -import javax.swing.JLabel; -import javax.swing.JScrollPane; -import javax.swing.SwingConstants; -import javax.swing.event.TableModelEvent; -import javax.swing.event.TableModelListener; -import javax.swing.table.DefaultTableModel; - -import net.miginfocom.swing.MigLayout; - -import org.adempiere.plaf.AdempierePLAF; -import org.compiere.apps.AEnv; -import org.compiere.apps.ConfirmPanel; -import org.compiere.grid.ed.AutoCompletion; -import org.compiere.grid.ed.VCheckBox; -import org.compiere.grid.ed.VComboBox; -import org.compiere.grid.ed.VDate; -import org.compiere.grid.ed.VLookup; -import org.compiere.minigrid.MiniTable; -import org.compiere.model.MClient; -import org.compiere.model.MLookup; -import org.compiere.model.MLookupFactory; -import org.compiere.swing.CLabel; -import org.compiere.swing.CPanel; -import org.compiere.swing.CTextField; -import org.compiere.util.CLogger; -import org.compiere.util.DisplayType; -import org.compiere.util.Env; -import org.compiere.util.KeyNamePair; -import org.compiere.util.Msg; - -public class VFactReconcile extends FactReconcile -implements FormPanel, ActionListener, TableModelListener, VetoableChangeListener { - - /** Window No */ - private int m_WindowNo = 0; - /** FormFrame */ - private FormFrame m_frame; - - /** Format */ - private DecimalFormat m_format = DisplayType.getNumberFormat(DisplayType.Amount); - /** Number of selected rows */ - private int m_noSelected = 0; - /** Logger */ - private static CLogger log = CLogger.getCLogger(VFactReconcile.class); - - /** - * Initialize Panel - * @param WindowNo window - * @param frame frame - */ - public void init (int WindowNo, FormFrame frame) - { - log.info(""); - m_WindowNo = WindowNo; - m_frame = frame; - try - { - dynInit(); - jbInit(); - - frame.getContentPane().add(commandPanel, BorderLayout.SOUTH); - frame.getContentPane().add(mainPanel, BorderLayout.CENTER); - } - catch(Exception e) - { - log.log(Level.SEVERE, "", e); - } - } // init - - // - private CPanel mainPanel = new CPanel(); - private BorderLayout mainLayout = new BorderLayout(); - private CPanel parameterPanel = new CPanel(); - private CLabel labelAcctSchema = new CLabel(); - private VLookup fieldAcctSchema = null; - private MigLayout parameterLayout = null; - private CLabel labelOrg = new CLabel(); - private VLookup fieldOrg = null; - private VCheckBox isReconciled = new VCheckBox(); - private CLabel labelAccount = new CLabel(); - private VComboBox fieldAccount = new VComboBox(); - private CLabel labelBPartner = new CLabel(); - private VLookup fieldBPartner = null; - - private JLabel dataStatus = new JLabel(); - private JScrollPane dataPane = new JScrollPane(); - private MiniTable miniTable = new MiniTable(); - private CPanel commandPanel = new CPanel(); - private JButton bCancel = ConfirmPanel.createCancelButton(true); - private JButton bGenerate = ConfirmPanel.createProcessButton(true); - private JButton bReset = ConfirmPanel.createResetButton(true); - private JButton bZoom = ConfirmPanel.createZoomButton(true); - private FlowLayout commandLayout = new FlowLayout(); - private JButton bRefresh = ConfirmPanel.createRefreshButton(true); - private CLabel labelDateAcct = new CLabel(); - private VDate fieldDateAcct = new VDate(); - private CLabel labelDateAcct2 = new CLabel(); - private VDate fieldDateAcct2 = new VDate(); - - private CLabel labelProduct = new CLabel(); - private VLookup fieldProduct = null; - private boolean loading = false; - private CLabel differenceLabel = new CLabel(); - private CTextField differenceField = new CTextField(); - - /** - * Static Init - * @throws Exception - */ - private void jbInit() throws Exception - { - //CompiereColor.setBackground(this); - // - mainPanel.setLayout(mainLayout); - parameterLayout = new MigLayout("fillx, wrap 4, hidemode 0", " [150:150][250:250][100:100][200:200]"); - parameterPanel.setLayout(parameterLayout); - bRefresh.addActionListener(this); - bReset.addActionListener(this); - bZoom.addActionListener(this); - bGenerate.setEnabled(false); - bReset.setEnabled(false); - //bRefresh.setText(Msg.getMsg(Env.getCtx(), "Query")); - bGenerate.setText(Msg.getMsg(Env.getCtx(),"Process")); - bReset.setText(Msg.getMsg(Env.getCtx(),"Reset")); - bZoom.setText(Msg.translate(Env.getCtx(), "Fact_Acct_ID")); - - // - labelAcctSchema.setText(Msg.translate(Env.getCtx(), "C_AcctSchema_ID")); - labelAccount.setText(Msg.translate(Env.getCtx(), "Account_ID")); - labelBPartner.setText(Msg.translate(Env.getCtx(), "C_BPartner_ID")); - labelDateAcct.setText(Msg.translate(Env.getCtx(), "DateAcct")); - labelDateAcct2.setText("-"); - labelProduct.setText(Msg.translate(Env.getCtx(), "M_Product_ID")); - // - labelOrg.setText(Msg.translate(Env.getCtx(), "AD_Org_ID")); - isReconciled.setText(Msg.translate(Env.getCtx(), "IsReconciled")); - dataStatus.setText(" "); - - - differenceLabel.setText(Msg.getMsg(Env.getCtx(), "Difference")); - differenceField.setBackground(AdempierePLAF.getFieldBackground_Inactive()); - differenceField.setEditable(false); - differenceField.setText("0"); - differenceField.setColumns(8); - differenceField.setHorizontalAlignment(SwingConstants.RIGHT); - // - bGenerate.addActionListener(this); - bCancel.addActionListener(this); - // - mainPanel.add(parameterPanel, BorderLayout.NORTH); - parameterPanel.add(labelAcctSchema, ""); - parameterPanel.add(fieldAcctSchema, "growx"); - - parameterPanel.add(labelOrg, ""); - parameterPanel.add(fieldOrg, "growx"); - - parameterPanel.add(labelAccount, ""); - parameterPanel.add(fieldAccount, "wmax 250"); - - parameterPanel.add(isReconciled, "skip 1"); - - parameterPanel.add(labelBPartner, ""); - parameterPanel.add(fieldBPartner, "growx"); - - parameterPanel.add(labelProduct, ""); - parameterPanel.add(fieldProduct, "growx"); - - parameterPanel.add(labelDateAcct, ""); - parameterPanel.add(fieldDateAcct, "growx"); - - parameterPanel.add(labelDateAcct2, ""); - parameterPanel.add(fieldDateAcct2, "growx"); - - parameterPanel.add(bRefresh, "growx"); - - - mainPanel.add(dataStatus, BorderLayout.SOUTH); - mainPanel.add(dataPane, BorderLayout.CENTER); - dataPane.getViewport().add(miniTable, null); - // - commandPanel.setLayout(commandLayout); - commandLayout.setAlignment(FlowLayout.RIGHT); - commandLayout.setHgap(10); - commandPanel.add(bZoom, null); - commandPanel.add(differenceLabel, null); - commandPanel.add(differenceField, null); - commandPanel.add(bGenerate, null); - commandPanel.add(bReset, null); - commandPanel.add(bCancel, null); - } // jbInit - - /** - * Dynamic Init. - * - Load Bank Info - * - Load BPartner - * - Load Document Type - * - Init Table - */ - public void dynInit() - { - Properties ctx = Env.getCtx(); - // - m_AD_Client_ID = Env.getAD_Client_ID(Env.getCtx()); - - - int AD_Column_ID = FactReconcile.col_C_AcctSchema_ID; // Fact_Acct.C_AcctSchema_ID - MLookup lookupAS = MLookupFactory.get (ctx, m_WindowNo, 0, AD_Column_ID, DisplayType.TableDir); - fieldAcctSchema = new VLookup("C_AcctSchema_ID", true, false, true, lookupAS); - fieldAcctSchema.addActionListener(this); - - fieldAcctSchema.setValue(MClient.get(ctx).getAcctSchema().getC_AcctSchema_ID()); - - Dimension dim = fieldAcctSchema.getPreferredSize(); - dim.width = 300; - fieldAcctSchema.setPreferredSize(dim); - - // Organization filter selection - AD_Column_ID = FactReconcile.col_AD_Org_ID; //C_Period.AD_Org_ID (needed to allow org 0) - MLookup lookupOrg = MLookupFactory.get(ctx, m_WindowNo, 0, AD_Column_ID, DisplayType.TableDir); - fieldOrg = new VLookup("AD_Org_ID", true, false, true, lookupOrg); - if (lookupOrg.containsKey(0)) - fieldOrg.setValue(0); - else - fieldOrg.setValue(Env.getAD_Org_ID(ctx)); - - - dim = fieldOrg.getPreferredSize(); - dim.width = 300; - fieldOrg.setPreferredSize(dim); - - // BPartner - AD_Column_ID = FactReconcile.col_C_BPartner_ID; // C_Invoice.C_BPartner_ID - MLookup lookupBP = MLookupFactory.get (ctx, m_WindowNo, 0, AD_Column_ID, DisplayType.Search); - fieldBPartner = new VLookup("C_BPartner_ID", false, false, true, lookupBP); - - // Product - AD_Column_ID = FactReconcile.col_M_Product_ID; // Fact_Acct.M_Product_ID - MLookup lookupProduct = MLookupFactory.get (ctx, m_WindowNo, 0, AD_Column_ID, DisplayType.Search); - fieldProduct = new VLookup("M_Product_ID", false, false, true, lookupProduct); - - - // Account - Vector vector = getAccount(); - for(int i=0;i> data = getData(); - Vector columnNames = getColumnNames(); - - // Remove Previous Listeners - miniTable.getModel().removeTableModelListener(this); - - DefaultTableModel modelI = new DefaultTableModel(data, columnNames); - modelI.addTableModelListener(this); - miniTable.setModel(modelI); - setColumnClass(miniTable); - //miniTable.setColumnVisibility(miniTable.getColumnModel().getColumn(1), false); - miniTable.setColorColumn(amtColIndex); - } - - /** - * Calculate selected rows. - * - add up selected rows - */ - public void calculateSelection() - { - m_noSelected = 0; - BigDecimal selectedAmt = Env.ZERO; - - int rows = miniTable.getRowCount(); - for (int i = 0; i < rows; i++) - { - boolean isSelected = (Boolean)miniTable.getModel().getValueAt(i, selectedColIndex); - if (isSelected) - { - BigDecimal amt = (BigDecimal)miniTable.getModel().getValueAt(i, amtColIndex); - if (amt != null) - selectedAmt = selectedAmt.add(amt); - m_noSelected++; - } - } - - // Information - StringBuilder info = new StringBuilder(); - info.append(m_noSelected).append(" ").append(Msg.getMsg(Env.getCtx(), "Selected")).append(" / ").append(miniTable.getRowCount()); - - differenceField.setText(m_format.format(selectedAmt)); - dataStatus.setText(info.toString()); - // - bGenerate.setEnabled(m_noSelected != 0 && Env.ZERO.compareTo(selectedAmt) == 0 && !isReconciled.isSelected()); - bReset.setEnabled(m_noSelected > 0 && isReconciled.isSelected()); - } // calculateSelection - - @Override - public void vetoableChange(PropertyChangeEvent evt) - throws PropertyVetoException { - // TODO Auto-generated method stub - - } - - @Override - public void tableChanged(TableModelEvent e) { - if (! loading ) - calculateSelection(); - } // valueChanged - - @Override - public void actionPerformed(ActionEvent e) { - // Generate Reconciliation - if (e.getSource() == bGenerate) - { - generateReconciliation(); - } - - else if (e.getSource() == bReset) - { - resetReconciliation(); - } - else if (e.getSource() == bZoom) - { - zoom(); - } - - else if (e.getSource() == bCancel) - dispose(); - - // Update - else if (e.getSource() == bRefresh) - loadData(); - } - - private void generateReconciliation() { - log.info(""); - // - miniTable.stopEditor(true); - if (miniTable.getRowCount() == 0) - return; - miniTable.setRowSelectionInterval(0,0); - calculateSelection(); - if (m_noSelected == 0) - return; - - - String format = "yyyy-MM-dd HH:mm:ss.SSS"; - Calendar cal = Calendar.getInstance(); - SimpleDateFormat sdf = new SimpleDateFormat(format); - String time = sdf.format(cal.getTime()); - - for ( int r = 0; r < miniTable.getModel().getRowCount(); r++ ) - { - boolean isSelected = (Boolean)miniTable.getModel().getValueAt(r, selectedColIndex); - - if (isSelected) - { - KeyNamePair pp = (KeyNamePair)miniTable.getModel().getValueAt(r, idColIndex); - - int factId = pp.getKey(); - - boolean result = generate(factId, time); - if(!result) - continue; - - ((DefaultTableModel) miniTable.getModel()).removeRow(r--); - } - } - } - - /** - * Zoom to target - * @param AD_Window_ID window id - * @param zoomQuery zoom query - */ - protected void zoom () - { - log.info(""); - - int selected = miniTable.getSelectedRow(); - - if ( selected == -1 ) - return; - - KeyNamePair pp = (KeyNamePair)miniTable.getModel().getValueAt(selected, idColIndex); - - int factId = pp.getKey(); - - AEnv.zoom(270, factId); - } // zoom - - private void resetReconciliation() { - log.info(""); - // - miniTable.stopEditor(true); - if (miniTable.getRowCount() == 0) - return; - miniTable.setRowSelectionInterval(0,0); - calculateSelection(); - if (m_noSelected == 0) - return; - - for ( int r = 0; r < miniTable.getModel().getRowCount(); r++ ) - { - boolean isSelected = (Boolean)miniTable.getModel().getValueAt(r, selectedColIndex); - - if (isSelected) - { - KeyNamePair pp = (KeyNamePair)miniTable.getModel().getValueAt(r, idColIndex); - - int factId = pp.getKey(); - - boolean result = reset(factId); - if(!result) - continue; - - ((DefaultTableModel) miniTable.getModel()).removeRow(r--); - } - } - } - - @Override - public void dispose() { - if (m_frame != null) - m_frame.dispose(); - m_frame = null; - } // dispose - -} diff --git a/org.adempiere.ui.swing/src/org/compiere/apps/form/VFileImport.java b/org.adempiere.ui.swing/src/org/compiere/apps/form/VFileImport.java deleted file mode 100644 index 7f889b10fa..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/apps/form/VFileImport.java +++ /dev/null @@ -1,473 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ -package org.compiere.apps.form; - -import java.awt.BorderLayout; -import java.awt.Cursor; -import java.awt.Dimension; -import java.awt.GridBagConstraints; -import java.awt.GridBagLayout; -import java.awt.Insets; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.io.BufferedReader; -import java.io.File; -import java.io.FileInputStream; -import java.io.InputStreamReader; -import java.nio.charset.Charset; -import java.sql.PreparedStatement; -import java.sql.ResultSet; -import java.sql.SQLException; -import java.util.ArrayList; -import java.util.logging.Level; - -import javax.swing.BorderFactory; -import javax.swing.JButton; -import javax.swing.JComboBox; -import javax.swing.JFileChooser; -import javax.swing.JLabel; -import javax.swing.JScrollPane; -import javax.swing.JTextArea; -import javax.swing.JTextField; - -import org.compiere.apps.ADialog; -import org.compiere.apps.ConfirmPanel; -import org.compiere.impexp.ImpFormat; -import org.compiere.impexp.ImpFormatRow; -import org.compiere.model.MRole; -import org.compiere.plaf.CompiereColor; -import org.compiere.swing.CComboBox; -import org.compiere.swing.CPanel; -import org.compiere.util.CLogger; -import org.compiere.util.DB; -import org.compiere.util.Env; -import org.compiere.util.Ini; -import org.compiere.util.KeyNamePair; -import org.compiere.util.Msg; -import org.compiere.util.Util; - - -/** - * Fixed length file import - * - * @author Jorg Janke - * @version $Id: VFileImport.java,v 1.2 2006/07/30 00:51:28 jjanke Exp $ - * - * @author Teo Sarca, SC ARHIPAC SERVICE SRL - *
  • FR [ 1658127 ] Select charset encoding on import - *
  • BF [ 1619158 ] Import is not working with UTF-8 - *
  • BF [ 1738641 ] Import Formats are accessible for all tenants - *
  • BF [ 1778356 ] VFileImport: IndexOfBound exp if the file is not loaded - */ -public class VFileImport extends CPanel - implements FormPanel, ActionListener -{ - /** - * - */ - private static final long serialVersionUID = 3996535986364873964L; - private static final int MAX_LOADED_LINES = 100; - private static final int MAX_SHOWN_LINES = 10; - private static String lastPath = null; - - /** - * Initialize Panel - * @param WindowNo window - * @param frame frame - */ - public void init (int WindowNo, FormFrame frame) - { - log.info(""); - m_WindowNo = WindowNo; - m_frame = frame; - try - { - jbInit(); - dynInit(); - frame.getContentPane().add(northPanel, BorderLayout.NORTH); - frame.getContentPane().add(centerPanel, BorderLayout.CENTER); - frame.getContentPane().add(confirmPanel, BorderLayout.SOUTH); - } - catch(Exception e) - { - log.log(Level.SEVERE, "init", e); - } - } // init - - /** Window No */ - private int m_WindowNo = 0; - /** FormFrame */ - private FormFrame m_frame; - - private ArrayList m_data = new ArrayList(); - private ImpFormat m_format; - private JLabel[] m_labels; - private JTextField[] m_fields; - private int m_record = -1; - /** Current selected file */ - private File m_file = null; - /** Logger */ - private static CLogger log = CLogger.getCLogger(VFileImport.class); - // - private static final String s_none = "----"; // no format indicator - // - private CPanel northPanel = new CPanel(); - private JButton bFile = new JButton(); - private JComboBox pickFormat = new JComboBox(); - private CPanel centerPanel = new CPanel(); - private BorderLayout centerLayout = new BorderLayout(); - private JScrollPane rawDataPane = new JScrollPane(); - private JTextArea rawData = new JTextArea(); - private JScrollPane previewPane = new JScrollPane(); - private CPanel previewPanel = new CPanel(); - private ConfirmPanel confirmPanel = new ConfirmPanel(true); - private JLabel info = new JLabel(); - private JLabel labelFormat = new JLabel(); - private GridBagLayout previewLayout = new GridBagLayout(); - private JButton bNext = new JButton(); - private JButton bPrevious = new JButton(); - private JLabel record = new JLabel(); - private CComboBoxfCharset = new CComboBox(Ini.getAvailableCharsets()); - - /** - * Static Init - * @throws Exception - */ - private void jbInit() throws Exception - { - CompiereColor.setBackground(this); - bFile.setText(Msg.getMsg(Env.getCtx(), "FileImportFile")); - bFile.setToolTipText(Msg.getMsg(Env.getCtx(), "FileImportFileInfo")); - bFile.addActionListener(this); - fCharset.setToolTipText(Msg.getMsg(Env.getCtx(), "Charset", false)); - info.setText(" "); - labelFormat.setText(Msg.translate(Env.getCtx(), "AD_ImpFormat_ID")); - // - bNext.setToolTipText(Msg.getMsg(Env.getCtx(), "Next")); - bNext.setMargin(new Insets(2, 2, 2, 2)); - bNext.setText(">"); - bNext.addActionListener(this); - record.setText("------"); - bPrevious.setToolTipText(Msg.getMsg(Env.getCtx(), "Previous")); - bPrevious.setMargin(new Insets(2, 2, 2, 2)); - bPrevious.setText("<"); - bPrevious.addActionListener(this); - // - northPanel.setBorder(BorderFactory.createEtchedBorder()); - northPanel.add(bFile, null); - northPanel.add(fCharset); - northPanel.add(info, null); - northPanel.add(labelFormat, null); - northPanel.add(pickFormat, null); - northPanel.add(bPrevious, null); - northPanel.add(record, null); - northPanel.add(bNext, null); - // - centerPanel.setLayout(centerLayout); - rawData.setFont(new java.awt.Font("Monospaced", 0, 10)); - rawData.setColumns(80); - rawData.setRows(MAX_SHOWN_LINES); - rawDataPane.getViewport().add(rawData, null); - centerPanel.add(rawDataPane, BorderLayout.CENTER); - centerPanel.add(previewPane, BorderLayout.SOUTH); - // - previewPanel.setLayout(previewLayout); - previewPane.getViewport().add(previewPanel, null); - previewPane.setPreferredSize(new Dimension(700,80)); - // - confirmPanel.addActionListener(this); - } // jbInit - - /** - * Dispose - */ - public void dispose() - { - if (m_frame != null) - m_frame.dispose(); - m_frame = null; - } // dispose - - /** - * Dynamic Init - */ - private void dynInit() - { - // Load Formats - pickFormat.addItem(new KeyNamePair(-1,s_none)); - String sql = MRole.getDefault().addAccessSQL("SELECT AD_Impformat_ID,Name FROM AD_ImpFormat WHERE isactive='Y'", "AD_ImpFormat", - MRole.SQL_FULLYQUALIFIED, MRole.SQL_RO); - PreparedStatement pstmt = null; - ResultSet rs = null; - try - { - pstmt = DB.prepareStatement(sql, null); - rs = pstmt.executeQuery(); - while (rs.next()) - pickFormat.addItem(new KeyNamePair(rs.getInt(1),rs.getString(2))); - } - catch (SQLException e) - { - log.log(Level.SEVERE, sql, e); - } - finally - { - DB.close(rs, pstmt); - rs = null; - pstmt = null; - } - pickFormat.setSelectedIndex(0); - pickFormat.addActionListener(this); - // - fCharset.setSelectedItem(Ini.getCharset()); - fCharset.addActionListener(this); - // - confirmPanel.getOKButton().setEnabled(false); - } // dynInit - - - /************************************************************************** - * Action Listener - * @param e event - */ - public void actionPerformed (ActionEvent e) - { - if (e.getSource() == bFile) - { - cmd_loadFile(); - invalidate(); - m_frame.pack(); - } - else if (e.getSource() == fCharset) { - int record = m_record; - cmd_reloadFile(); - m_record = record - 1; - cmd_applyFormat(true); - } - else if (e.getSource() == pickFormat) - { - cmd_loadFormat(); - invalidate(); - m_frame.pack(); - } - else if (e.getSource() == bNext) - cmd_applyFormat(true); - else if (e.getSource() == bPrevious) - cmd_applyFormat(false); - - else if (e.getActionCommand().equals(ConfirmPanel.A_OK)) - { - m_frame.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); - confirmPanel.setEnabled(false); - m_frame.setBusy(true); - // - org.compiere.apps.SwingWorker worker = new org.compiere.apps.SwingWorker() - { - public Object construct() - { - cmd_process(); - return Boolean.TRUE; - } - }; - worker.start(); - // when you need the result: - // x = worker.get(); // this blocks the UI !! - } - else if (e.getActionCommand().equals(ConfirmPanel.A_CANCEL)) - dispose(); - - if (m_data != null && m_data.size() > 0 // file loaded - && m_format != null && m_format.getRowCount() > 0) // format loaded - confirmPanel.getOKButton().setEnabled(true); - else - confirmPanel.getOKButton().setEnabled(false); - } // actionPerformed - - - /************************************************************************** - * Load File - */ - private void cmd_loadFile() - { - String directory = org.compiere.Adempiere.getAdempiereHome() - + File.separator + "data" - + File.separator + "import"; - if (!Util.isEmpty(lastPath)) - directory = lastPath; - log.config(directory); - // - JFileChooser chooser = new JFileChooser(directory); - chooser.setFileSelectionMode(JFileChooser.FILES_ONLY); - chooser.setMultiSelectionEnabled(false); - chooser.setDialogTitle(Msg.getMsg(Env.getCtx(), "FileImportFileInfo")); - if (chooser.showOpenDialog(this) != JFileChooser.APPROVE_OPTION) - return; - m_file = chooser.getSelectedFile(); - if (log.isLoggable(Level.CONFIG)) log.config(m_file.getName()); - lastPath = m_file.getParentFile().getAbsolutePath(); - bFile.setText(m_file.getName()); - cmd_reloadFile(); - } - - /** - * Reload/Load file - */ - private void cmd_reloadFile() - { - if (m_file == null) - return; - - setCursor (Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); - m_data.clear(); - rawData.setText(""); - try - { - // see NaturalAccountMap - Charset charset = (Charset)fCharset.getSelectedItem(); - BufferedReader in = new BufferedReader(new InputStreamReader(new FileInputStream(m_file), charset), 10240); - // not safe see p108 Network pgm - String s = null; - while ((s = in.readLine()) != null) - { - m_data.add(s); - if (m_data.size() <= MAX_LOADED_LINES) - { - rawData.append(s); - rawData.append("\n"); - } - } - in.close(); - rawData.setCaretPosition(0); - } - catch (Exception e) - { - log.log(Level.SEVERE, "", e); - bFile.setText(Msg.getMsg(Env.getCtx(), "FileImportFile")); - } - int index = 1; // second line as first may be heading - if (m_data.size() == 1) - index = 0; - int length = 0; - if (m_data.size() > 0) - length = m_data.get(index).toString().length(); - info.setText(Msg.getMsg(Env.getCtx(), "Records") + "=" + m_data.size() - + ", " + Msg.getMsg(Env.getCtx(), "Length") + "=" + length + " "); - setCursor (Cursor.getDefaultCursor()); - if (log.isLoggable(Level.CONFIG)) log.config("Records=" + m_data.size() - + ", Length=" + length); - } // cmd_loadFile - - /** - * Load Format - */ - private void cmd_loadFormat() - { - // clear panel - previewPanel.removeAll(); - // - KeyNamePair pickFormatKNPair = (KeyNamePair)pickFormat.getSelectedItem(); - if (pickFormatKNPair.getName().equals(s_none)) - return; - m_format = ImpFormat.load (pickFormatKNPair.getKey()); - if (m_format == null) - { - ADialog.error(m_WindowNo, this, "FileImportNoFormat", pickFormatKNPair.getName()); - return; - } - - // pointers - int size = m_format.getRowCount(); - m_labels = new JLabel[size]; - m_fields = new JTextField[size]; - for (int i = 0; i < size; i++) - { - ImpFormatRow row = m_format.getRow(i); - m_labels[i] = new JLabel (row.getName()); - previewPanel.add(m_labels[i], new GridBagConstraints(i, 0, 1, 1, 1.0, 1.0, - GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(2, 2, 2, 2), 0, 0)); - // - int length = row.getEndNo() - row.getStartNo(); - if (length <= 5) - length = 5; - else if (length > 20) - length = 20; - m_fields[i] = new JTextField (length); - previewPanel.add(m_fields[i], new GridBagConstraints(i, 1, 1, 1, 1.0, 1.0, - GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(2, 2, 2, 2), 0, 0)); - } - m_record = -1; - record.setText("------"); - previewPanel.invalidate(); - previewPanel.repaint(); - } // cmd_format - - /** - * Apply Current Pattern - * @param next next - */ - private void cmd_applyFormat (boolean next) - { - if (m_format == null || m_data.size() == 0) - return; - - // set position - if (next) - m_record++; - else - m_record--; - if (m_record < 0) - m_record = 0; - else if (m_record >= m_data.size()) - m_record = m_data.size() - 1; - record.setText(" " + String.valueOf(m_record+1) + " "); - // Line Info - String[] lInfo = m_format.parseLine(m_data.get(m_record).toString(), false, true, false); // no label, trace, no ignore - int size = m_format.getRowCount(); - if (lInfo.length != size) - log.log(Level.SEVERE, "FormatElements=" + size + " != Fields=" + lInfo.length); - for (int i = 0; i < size; i++) - { - m_fields[i].setText(lInfo[i]); - m_fields[i].setCaretPosition(0); - } - } // cmd_applyFormat - - - /************************************************************************** - * Process File - */ - private void cmd_process() - { - if (m_format == null) - { - ADialog.error(m_WindowNo, this, "FileImportNoFormat"); - return; - } - if (log.isLoggable(Level.CONFIG)) log.config(m_format.getName()); - - // For all rows - update/insert DB table - int row = 0; - int imported = 0; - for (row = 0; row < m_data.size(); row++) - if (m_format.updateDB(Env.getCtx(), m_data.get(row).toString(), null)) - imported++; - // - ADialog.info(m_WindowNo, this, "FileImportR/I", row + " / " + imported + "#"); - dispose(); - } // cmd_process - -} // FileImport diff --git a/org.adempiere.ui.swing/src/org/compiere/apps/form/VGenPanel.java b/org.adempiere.ui.swing/src/org/compiere/apps/form/VGenPanel.java deleted file mode 100644 index 281a7789c4..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/apps/form/VGenPanel.java +++ /dev/null @@ -1,411 +0,0 @@ -/****************************************************************************** - * Copyright (C) 2009 Low Heng Sin * - * Copyright (C) 2009 Idalica Corporation * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - *****************************************************************************/ -package org.compiere.apps.form; - -import java.awt.BorderLayout; -import java.awt.Cursor; -import java.awt.FlowLayout; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.io.File; -import java.util.logging.Level; - -import javax.swing.JOptionPane; -import javax.swing.JScrollPane; -import javax.swing.event.ChangeEvent; -import javax.swing.event.ChangeListener; -import javax.swing.event.TableModelEvent; -import javax.swing.event.TableModelListener; - -import org.adempiere.plaf.AdempierePLAF; -import org.adempiere.util.Callback; -import org.adempiere.util.IProcessUI; -import org.compiere.apps.ADialog; -import org.compiere.apps.ADialogDialog; -import org.compiere.apps.AEnv; -import org.compiere.apps.ConfirmPanel; -import org.compiere.apps.ProcessCtl; -import org.compiere.apps.StatusBar; -import org.compiere.minigrid.IDColumn; -import org.compiere.minigrid.MiniTable; -import org.compiere.model.MQuery; -import org.compiere.model.MTable; -import org.compiere.model.PrintInfo; -import org.compiere.plaf.CompiereColor; -import org.compiere.print.MPrintFormat; -import org.compiere.print.ReportCtl; -import org.compiere.print.ReportEngine; -import org.compiere.print.Viewer; -import org.compiere.process.ProcessInfo; -import org.compiere.process.ProcessInfoUtil; -import org.compiere.swing.CPanel; -import org.compiere.swing.CTabbedPane; -import org.compiere.swing.CTextPane; -import org.compiere.util.CLogger; -import org.compiere.util.Env; -import org.compiere.util.Msg; - -/** - * Generate custom form panel - * - */ -public class VGenPanel extends CPanel implements ActionListener, ChangeListener, TableModelListener, IProcessUI -{ - /** - * - */ - private static final long serialVersionUID = 8154208229173738517L; - - private GenForm genForm; - - /** Window No */ - private int m_WindowNo = 0; - /** FormFrame */ - private FormFrame m_frame; - - /** Logger */ - private static CLogger log = CLogger.getCLogger(VGenPanel.class); - // - - private CTabbedPane tabbedPane = new CTabbedPane(); - private CPanel selPanel = new CPanel(); - private CPanel selNorthPanel = new CPanel(); - private BorderLayout selPanelLayout = new BorderLayout(); - - private FlowLayout northPanelLayout = new FlowLayout(); - private ConfirmPanel confirmPanelSel = new ConfirmPanel(true); - private ConfirmPanel confirmPanelGen = new ConfirmPanel(false, true, false, false, false, false, true); - private StatusBar statusBar = new StatusBar(); - private CPanel genPanel = new CPanel(); - private BorderLayout genLayout = new BorderLayout(); - private CTextPane info = new CTextPane(); - private JScrollPane scrollPane = new JScrollPane(); - private MiniTable miniTable = new MiniTable(); - - public VGenPanel(GenForm genForm, int WindowNo, FormFrame frame) - { - log.info(""); - this.genForm = genForm; - m_WindowNo = WindowNo; - m_frame = frame; - - try - { - jbInit(); - dynInit(); - frame.getContentPane().add(tabbedPane, BorderLayout.CENTER); - frame.getContentPane().add(statusBar, BorderLayout.SOUTH); - } - catch(Exception ex) - { - log.log(Level.SEVERE, "init", ex); - } - } // init - - /** - * Static Init. - *
    -	 *  selPanel (tabbed)
    -	 *      fOrg, fBPartner
    -	 *      scrollPane & miniTable
    -	 *  genPanel
    -	 *      info
    -	 *  
    - * @throws Exception - */ - void jbInit() throws Exception - { - CompiereColor.setBackground(this); - // - selPanel.setLayout(selPanelLayout); - - selNorthPanel.setLayout(northPanelLayout); - northPanelLayout.setAlignment(FlowLayout.LEFT); - tabbedPane.add(selPanel, Msg.getMsg(Env.getCtx(), "Select")); - selPanel.add(selNorthPanel, BorderLayout.NORTH); - selPanel.setName("selPanel"); - selPanel.add(confirmPanelSel, BorderLayout.SOUTH); - selPanel.add(scrollPane, BorderLayout.CENTER); - scrollPane.getViewport().add(miniTable, null); - confirmPanelSel.addActionListener(this); - // - tabbedPane.add(genPanel, Msg.getMsg(Env.getCtx(), "Generate")); - genPanel.setLayout(genLayout); - genPanel.add(info, BorderLayout.CENTER); - genPanel.setEnabled(false); - info.setBackground(AdempierePLAF.getFieldBackground_Inactive()); - info.setEditable(false); - genPanel.add(confirmPanelGen, BorderLayout.SOUTH); - confirmPanelGen.addActionListener(this); - } // jbInit - - /** - * Dynamic Init. - * - Create GridController & Panel - * - AD_Column_ID from C_Order - */ - private void dynInit() - { - genForm.configureMiniTable(miniTable); - - miniTable.setRowSelectionAllowed(true); - - miniTable.getModel().addTableModelListener(this); - // Info - statusBar.setStatusDB(" "); - // Tabbed Pane Listener - tabbedPane.addChangeListener(this); - } // dynInit - - /** - * Dispose - */ - public void dispose() - { - if (m_frame != null) - m_frame.dispose(); - m_frame = null; - } // dispose - - /** - * Action Listener - * @param e event - */ - public void actionPerformed (ActionEvent e) - { - if (log.isLoggable(Level.INFO)) log.info("Cmd=" + e.getActionCommand()); - // - if (e.getActionCommand().equals(ConfirmPanel.A_CANCEL)) - { - dispose(); - return; - } - - try - { - genForm.validate(); - } - catch (Exception ex) - { - ADialog.error(m_WindowNo, this, "Error", ex.getLocalizedMessage()); - } - } // actionPerformed - - /** - * Change Listener (Tab changed) - * @param e event - */ - public void stateChanged (ChangeEvent e) - { - int index = tabbedPane.getSelectedIndex(); - genForm.setSelectionActive(index == 0); - } // stateChanged - - /** - * Table Model Listener - * @param e event - */ - public void tableChanged(TableModelEvent e) - { - int rowsSelected = 0; - int rows = miniTable.getRowCount(); - for (int i = 0; i < rows; i++) - { - IDColumn id = (IDColumn)miniTable.getValueAt(i, 0); // ID in column 0 - if (id != null && id.isSelected()) - rowsSelected++; - } - statusBar.setStatusDB(" " + rowsSelected + " "); - } // tableChanged - - /** - * Save Selection & return selecion Query or "" - * @return where clause like C_Order_ID IN (...) - */ - public void saveSelection() - { - // ID selection may be pending - miniTable.editingStopped(new ChangeEvent(this)); - genForm.saveSelection(miniTable); - } // saveSelection - - /************************************************************************** - * Generate Shipments/Invoices - */ - public void generate() - { - info.setText(genForm.generate()); - ProcessCtl worker = new ProcessCtl(this, AEnv.getWindowNo(this), genForm.getProcessInfo(), genForm.getTrx()); - worker.start(); - // - } - - /** - * Complete generating shipments/invoices. - * Called from Unlock UI - * @param pi process info - */ - public void generateComplete(ProcessInfo pi) - { - // Switch Tabs - tabbedPane.setSelectedIndex(1); - // - ProcessInfoUtil.setLogFromDB(pi); - StringBuilder iText = new StringBuilder(); - iText.append("").append(pi.getSummary()) - .append("
    (") - .append(Msg.getMsg(Env.getCtx(), genForm.getTitle())) - // Shipments are generated depending on the Delivery Rule selection in the Order - .append(")
    ") - .append(pi.getLogInfo(true)); - info.setText(iText.toString()); - - // Reset Selection - /* - String sql = "UPDATE C_Order SET IsSelected='N' WHERE " + m_whereClause; - int no = DB.executeUpdate(sql, null); - log.config("Reset=" + no);*/ - - // Get results - int[] ids = pi.getIDs(); - if (ids == null || ids.length == 0) - return; - if (log.isLoggable(Level.CONFIG)) log.config("PrintItems=" + ids.length); - - confirmPanelGen.getOKButton().setEnabled(false); - // OK to print - if (ADialog.ask(m_WindowNo, this, genForm.getAskPrintMsg())) - { - this.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); - int retValue = ADialogDialog.A_CANCEL; // see also ProcessDialog.printShipments/Invoices - do - { - // Loop through all items - for (int i = 0; i < ids.length; i++) - { - int Record_ID = ids[i]; - - if(genForm.getPrintFormat() != null) - { - MPrintFormat format = genForm.getPrintFormat(); - MTable table = MTable.get(Env.getCtx(),format.getAD_Table_ID()); - MQuery query = new MQuery(table.getTableName()); - query.addRestriction(table.getTableName() + "_ID", MQuery.EQUAL, Record_ID); - // Engine - PrintInfo info = new PrintInfo(table.getTableName(),table.get_Table_ID(), Record_ID); - ReportEngine re = new ReportEngine(Env.getCtx(), format, query, info); - re.print(); - new Viewer(m_frame.getGraphicsConfiguration(), re); - } - else - ReportCtl.startDocumentPrint(genForm.getReportEngineType(), Record_ID, this, AEnv.getWindowNo(this), true); - - } - ADialogDialog d = new ADialogDialog (m_frame, - Env.getHeader(Env.getCtx(), m_WindowNo), - Msg.getMsg(Env.getCtx(), "PrintoutOK?"), - JOptionPane.QUESTION_MESSAGE); - retValue = d.getReturnCode(); - } - while (retValue == ADialogDialog.A_CANCEL); - this.setCursor(Cursor.getDefaultCursor()); - } // OK to print - - // - confirmPanelGen.getOKButton().setEnabled(true); - } - - /************************************************************************** - * Lock User Interface. - * Called from the Worker before processing - * @param pi process info - */ - public void lockUI (ProcessInfo pi) - { - setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); - setEnabled(false); - } // lockUI - - /** - * Unlock User Interface. - * Called from the Worker when processing is done - * @param pi result of execute ASync call - */ - public void unlockUI (ProcessInfo pi) - { - setEnabled(true); - setCursor(Cursor.getDefaultCursor()); - // - generateComplete(pi); - } // unlockUI - - /** - * Is the UI locked (Internal method) - * @return true, if UI is locked - */ - public boolean isUILocked() - { - return isEnabled(); - } // isUILocked - - /** - * Method to be executed async. - * Called from the Worker - * @param pi ProcessInfo - */ - public void executeASync (ProcessInfo pi) - { - } // executeASync - - public CPanel getParameterPanel() - { - return selNorthPanel; - } - - public MiniTable getMiniTable() - { - return miniTable; - } - - public StatusBar getStatusBar() - { - return statusBar; - } - - @Override - public void statusUpdate(String message) { - statusBar.setStatusLine(message); - } - - @Override - public void ask(String message, Callback callback) { - boolean b = ADialog.ask(m_WindowNo, this, message); - if (callback != null) { - callback.onCallback(b); - } - } - - @Override - public void download(File file) { - // TODO Auto-generated method stub - - } - - @Override - public void askForInput(String message, Callback callback) { - String s = ADialog.askForInput(m_WindowNo, this, message); - if(callback != null) - callback.onCallback(s); - } -} \ No newline at end of file diff --git a/org.adempiere.ui.swing/src/org/compiere/apps/form/VInOutGen.java b/org.adempiere.ui.swing/src/org/compiere/apps/form/VInOutGen.java deleted file mode 100644 index 5fbf1bb72f..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/apps/form/VInOutGen.java +++ /dev/null @@ -1,239 +0,0 @@ -/****************************************************************************** - * Copyright (C) 2009 Low Heng Sin * - * Copyright (C) 2009 Idalica Corporation * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - *****************************************************************************/ -package org.compiere.apps.form; - -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.beans.PropertyChangeEvent; -import java.beans.VetoableChangeListener; -import java.util.ArrayList; -import java.util.logging.Level; - -import org.adempiere.exceptions.FillMandatoryException; -import org.compiere.apps.ADialog; -import org.compiere.grid.ed.VComboBox; -import org.compiere.grid.ed.VLookup; -import org.compiere.model.MLookup; -import org.compiere.model.MLookupFactory; -import org.compiere.model.MOrder; -import org.compiere.model.MRMA; -import org.compiere.swing.CLabel; -import org.compiere.util.CLogger; -import org.compiere.util.DisplayType; -import org.compiere.util.Env; -import org.compiere.util.KeyNamePair; -import org.compiere.util.Msg; - -/** - * Generate Shipment (manual) view class - * - */ -public class VInOutGen extends InOutGen implements FormPanel, ActionListener, VetoableChangeListener -{ - private VGenPanel panel; - - /** Window No */ - private int m_WindowNo = 0; - /** FormFrame */ - private FormFrame m_frame; - - /** Logger */ - private static CLogger log = CLogger.getCLogger(VInOutGen.class); - // - - private CLabel lWarehouse = new CLabel(); - private VLookup fWarehouse; - private CLabel lBPartner = new CLabel(); - private VLookup fBPartner; - private CLabel lDocType = new CLabel(); - private VComboBox cmbDocType = new VComboBox(); - private CLabel lDocAction = new CLabel(); - private VLookup docAction; - - /** - * Initialize Panel - * @param WindowNo window - * @param frame frame - */ - public void init (int WindowNo, FormFrame frame) - { - log.info(""); - m_WindowNo = WindowNo; - m_frame = frame; - Env.setContext(Env.getCtx(), m_WindowNo, "IsSOTrx", "Y"); - - panel = new VGenPanel(this, WindowNo, frame); - - try - { - super.dynInit(); - dynInit(); - jbInit(); - } - catch(Exception ex) - { - log.log(Level.SEVERE, "init", ex); - } - } // init - - /** - * Dispose - */ - public void dispose() - { - if (m_frame != null) - m_frame.dispose(); - m_frame = null; - } // dispose - - /** - * Static Init. - *
    -	 *  selPanel (tabbed)
    -	 *      fOrg, fBPartner
    -	 *      scrollPane & miniTable
    -	 *  genPanel
    -	 *      info
    -	 *  
    - * @throws Exception - */ - void jbInit() throws Exception - { - lWarehouse.setLabelFor(fWarehouse); - lBPartner.setLabelFor(fBPartner); - lBPartner.setText(Msg.translate(Env.getCtx(), "C_BPartner_ID")); - lDocAction.setLabelFor(docAction); - lDocAction.setText(Msg.translate(Env.getCtx(), "DocAction")); - lDocType.setLabelFor(cmbDocType); - - panel.getParameterPanel().add(lWarehouse, null); - panel.getParameterPanel().add(fWarehouse, null); - panel.getParameterPanel().add(lBPartner, null); - panel.getParameterPanel().add(fBPartner, null); - panel.getParameterPanel().add(lDocType, null); - panel.getParameterPanel().add(cmbDocType, null); - panel.getParameterPanel().add(lDocAction, null); - panel.getParameterPanel().add(docAction, null); - } // jbInit - - /** - * Fill Picks. - * Column_ID from C_Order - * @throws Exception if Lookups cannot be initialized - */ - public void dynInit() throws Exception - { - // C_OrderLine.M_Warehouse_ID - MLookup orgL = MLookupFactory.get (Env.getCtx(), m_WindowNo, 0, 2223, DisplayType.TableDir); - fWarehouse = new VLookup ("M_Warehouse_ID", true, false, true, orgL); - lWarehouse.setText(Msg.translate(Env.getCtx(), "M_Warehouse_ID")); - fWarehouse.addVetoableChangeListener(this); - setM_Warehouse_ID(fWarehouse.getValue()); - // Document Action Prepared/ Completed - MLookup docActionL = MLookupFactory.get(Env.getCtx(), m_WindowNo, 4324 /* M_InOut.DocStatus */, - DisplayType.List, Env.getLanguage(Env.getCtx()), "DocAction", 135 /* _Document Action */, - false, "AD_Ref_List.Value IN ('CO','PR','--')"); - docAction = new VLookup("DocAction", true, false, true,docActionL); - docAction.addVetoableChangeListener(this); - // C_Order.C_BPartner_ID - MLookup bpL = MLookupFactory.get (Env.getCtx(), m_WindowNo, 0, 2762, DisplayType.Search); - fBPartner = new VLookup ("C_BPartner_ID", false, false, true, bpL); - lBPartner.setText(Msg.translate(Env.getCtx(), "C_BPartner_ID")); - fBPartner.addVetoableChangeListener(this); - //Document Type Sales Order/Vendor RMA - lDocType.setText(Msg.translate(Env.getCtx(), "C_DocType_ID")); - cmbDocType.addItem(new KeyNamePair(MOrder.Table_ID, Msg.translate(Env.getCtx(), "Order"))); - cmbDocType.addItem(new KeyNamePair(MRMA.Table_ID, Msg.translate(Env.getCtx(), "VendorRMA"))); - cmbDocType.addActionListener(this); - - panel.getStatusBar().setStatusLine(Msg.getMsg(Env.getCtx(), "InOutGenerateSel"));//@@ - } // fillPicks - - public void executeQuery() - { - KeyNamePair docTypeKNPair = (KeyNamePair)cmbDocType.getSelectedItem(); - executeQuery(docTypeKNPair, panel.getMiniTable()); - } // executeQuery - - /** - * Action Listener - * @param e event - */ - public void actionPerformed(ActionEvent e) - { - if (cmbDocType.equals(e.getSource())) - { - executeQuery(); - return; - } - - try - { - validate(); - } - catch(Exception ex) - { - ADialog.error(m_WindowNo, this.panel, "Error", ex.getLocalizedMessage()); - } - } // actionPerformed - - public void validate() - { - panel.saveSelection(); - - if (getM_Warehouse_ID() <= 0) - { - throw new FillMandatoryException("M_Warehouse_ID"); - } - - ArrayList selection = getSelection(); - if (selection != null - && selection.size() > 0 - && isSelectionActive()) // on selection tab - { - panel.generate(); - } - else - { - panel.dispose(); - } - } - - /** - * Vetoable Change Listener - requery - * @param e event - */ - public void vetoableChange(PropertyChangeEvent e) - { - if (log.isLoggable(Level.INFO)) log.info(e.getPropertyName() + "=" + e.getNewValue()); - if (e.getPropertyName().equals("M_Warehouse_ID")) - setM_Warehouse_ID(e.getNewValue()); - if (e.getPropertyName().equals("C_BPartner_ID")) - { - m_C_BPartner_ID = e.getNewValue(); - fBPartner.setValue(m_C_BPartner_ID); // display value - } - executeQuery(); - } // vetoableChange - - /************************************************************************** - * Generate Shipments - */ - public String generate() - { - KeyNamePair docTypeKNPair = (KeyNamePair)cmbDocType.getSelectedItem(); - String docActionSelected = (String)docAction.getValue(); - return generate(panel.getStatusBar(), docTypeKNPair, docActionSelected); - } // generateShipments -} diff --git a/org.adempiere.ui.swing/src/org/compiere/apps/form/VInvoiceGen.java b/org.adempiere.ui.swing/src/org/compiere/apps/form/VInvoiceGen.java deleted file mode 100644 index fbb40e0279..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/apps/form/VInvoiceGen.java +++ /dev/null @@ -1,221 +0,0 @@ -/****************************************************************************** - * Copyright (C) 2009 Low Heng Sin * - * Copyright (C) 2009 Idalica Corporation * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - *****************************************************************************/ -package org.compiere.apps.form; - -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.beans.PropertyChangeEvent; -import java.beans.VetoableChangeListener; -import java.util.ArrayList; -import java.util.logging.Level; - -import org.compiere.grid.ed.VComboBox; -import org.compiere.grid.ed.VLookup; -import org.compiere.model.MLookup; -import org.compiere.model.MLookupFactory; -import org.compiere.model.MOrder; -import org.compiere.model.MRMA; -import org.compiere.swing.CLabel; -import org.compiere.util.CLogger; -import org.compiere.util.DisplayType; -import org.compiere.util.Env; -import org.compiere.util.KeyNamePair; -import org.compiere.util.Msg; - -/** - * Generate Invoice (manual) view class - * - */ -public class VInvoiceGen extends InvoiceGen implements FormPanel, ActionListener, VetoableChangeListener -{ - private VGenPanel panel; - - /** Window No */ - private int m_WindowNo = 0; - /** FormFrame */ - private FormFrame m_frame; - - /** Logger */ - private static CLogger log = CLogger.getCLogger(VInvoiceGen.class); - // - - private CLabel lOrg = new CLabel(); - private VLookup fOrg; - private CLabel lBPartner = new CLabel(); - private VLookup fBPartner; - private CLabel lDocType = new CLabel(); - private VComboBox cmbDocType = new VComboBox(); - private CLabel lDocAction = new CLabel(); - private VLookup docAction; - - /** - * Initialize Panel - * @param WindowNo window - * @param frame frame - */ - public void init (int WindowNo, FormFrame frame) - { - log.info(""); - m_WindowNo = WindowNo; - m_frame = frame; - Env.setContext(Env.getCtx(), m_WindowNo, "IsSOTrx", "Y"); - - panel = new VGenPanel(this, WindowNo, frame); - - try - { - super.dynInit(); - dynInit(); - jbInit(); - } - catch(Exception ex) - { - log.log(Level.SEVERE, "init", ex); - } - } // init - - /** - * Dispose - */ - public void dispose() - { - if (m_frame != null) - m_frame.dispose(); - m_frame = null; - } // dispose - - /** - * Static Init. - *
    -	 *  selPanel (tabbed)
    -	 *      fOrg, fBPartner
    -	 *      scrollPane & miniTable
    -	 *  genPanel
    -	 *      info
    -	 *  
    - * @throws Exception - */ - void jbInit() throws Exception - { - lOrg.setLabelFor(fOrg); - lOrg.setText(Msg.translate(Env.getCtx(), "AD_Org_ID")); - lBPartner.setLabelFor(fBPartner); - lBPartner.setText(Msg.translate(Env.getCtx(), "C_BPartner_ID")); - lDocAction.setLabelFor(docAction); - lDocAction.setText(Msg.translate(Env.getCtx(), "DocAction")); - lDocType.setLabelFor(cmbDocType); - - panel.getParameterPanel().add(lOrg, null); - panel.getParameterPanel().add(fOrg, null); - panel.getParameterPanel().add(lBPartner, null); - panel.getParameterPanel().add(fBPartner, null); - panel.getParameterPanel().add(lDocType, null); - panel.getParameterPanel().add(cmbDocType, null); - panel.getParameterPanel().add(lDocAction, null); - panel.getParameterPanel().add(docAction, null); - } // jbInit - - /** - * Fill Picks. - * Column_ID from C_Order - * @throws Exception if Lookups cannot be initialized - */ - public void dynInit() throws Exception - { - MLookup orgL = MLookupFactory.get (Env.getCtx(), m_WindowNo, 0, 2163, DisplayType.TableDir); - fOrg = new VLookup ("AD_Org_ID", false, false, true, orgL); - // lOrg.setText(Msg.translate(Env.getCtx(), "AD_Org_ID")); - fOrg.addVetoableChangeListener(this); - - MLookup docActionL = MLookupFactory.get(Env.getCtx(), m_WindowNo, 3494 /* C_Invoice.DocStatus */, - DisplayType.List, Env.getLanguage(Env.getCtx()), "DocAction", 135 /* _Document Action */, - false, "AD_Ref_List.Value IN ('CO','PR')"); - docAction = new VLookup("DocAction", true, false, true,docActionL); - // lDcoACtion.setText((Msg.translate(Env.getCtx(), "DocAction"));); - docAction.addVetoableChangeListener(this); - - // - MLookup bpL = MLookupFactory.get (Env.getCtx(), m_WindowNo, 0, 2762, DisplayType.Search); - fBPartner = new VLookup ("C_BPartner_ID", false, false, true, bpL); - // lBPartner.setText(Msg.translate(Env.getCtx(), "C_BPartner_ID")); - fBPartner.addVetoableChangeListener(this); - - //Document Type Sales Order/Vendor RMA - lDocType.setText(Msg.translate(Env.getCtx(), "C_DocType_ID")); - cmbDocType.addItem(new KeyNamePair(MOrder.Table_ID, Msg.translate(Env.getCtx(), "Order"))); - cmbDocType.addItem(new KeyNamePair(MRMA.Table_ID, Msg.translate(Env.getCtx(), "CustomerRMA"))); - cmbDocType.addActionListener(this); - - panel.getStatusBar().setStatusLine(Msg.getMsg(Env.getCtx(), "InvGenerateSel"));//@@ - } // fillPicks - - public void executeQuery() - { - KeyNamePair docTypeKNPair = (KeyNamePair)cmbDocType.getSelectedItem(); - executeQuery(docTypeKNPair, panel.getMiniTable()); - } // executeQuery - - /** - * Action Listener - * @param e event - */ - public void actionPerformed(ActionEvent e) - { - if (cmbDocType.equals(e.getSource())) - { - executeQuery(); - return; - } - - validate(); - } // actionPerformed - - public void validate() - { - panel.saveSelection(); - - ArrayList selection = getSelection(); - if (selection != null && selection.size() > 0 && isSelectionActive()) - panel.generate(); - else - panel.dispose(); - } - - /** - * Vetoable Change Listener - requery - * @param e event - */ - public void vetoableChange(PropertyChangeEvent e) - { - if (log.isLoggable(Level.INFO)) log.info(e.getPropertyName() + "=" + e.getNewValue()); - if (e.getPropertyName().equals("AD_Org_ID")) - m_AD_Org_ID = e.getNewValue(); - if (e.getPropertyName().equals("C_BPartner_ID")) - { - m_C_BPartner_ID = e.getNewValue(); - fBPartner.setValue(m_C_BPartner_ID); // display value - } - executeQuery(); - } // vetoableChange - - /************************************************************************** - * Generate Shipments - */ - public String generate() - { - KeyNamePair docTypeKNPair = (KeyNamePair)cmbDocType.getSelectedItem(); - String docActionSelected = (String)docAction.getValue(); - return generate(panel.getStatusBar(), docTypeKNPair, docActionSelected); - } // generateShipments -} diff --git a/org.adempiere.ui.swing/src/org/compiere/apps/form/VMatch.java b/org.adempiere.ui.swing/src/org/compiere/apps/form/VMatch.java deleted file mode 100644 index 91899439d1..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/apps/form/VMatch.java +++ /dev/null @@ -1,506 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ -package org.compiere.apps.form; - -import java.awt.BorderLayout; -import java.awt.Cursor; -import java.awt.Dimension; -import java.awt.FlowLayout; -import java.awt.GridBagConstraints; -import java.awt.GridBagLayout; -import java.awt.Insets; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.math.BigDecimal; -import java.sql.Timestamp; -import java.util.logging.Level; -import javax.swing.DefaultComboBoxModel; -import javax.swing.JCheckBox; -import javax.swing.JScrollPane; -import javax.swing.border.TitledBorder; -import javax.swing.event.ListSelectionEvent; -import javax.swing.event.ListSelectionListener; -import javax.swing.event.TableModelEvent; -import javax.swing.event.TableModelListener; -import org.compiere.apps.StatusBar; -import org.compiere.grid.ed.VDate; -import org.compiere.grid.ed.VLookup; -import org.compiere.grid.ed.VNumber; -import org.compiere.minigrid.ColumnInfo; -import org.compiere.minigrid.IDColumn; -import org.compiere.minigrid.MiniTable; -import org.compiere.model.MMatchPO; -import org.compiere.plaf.CompiereColor; -import org.compiere.swing.CButton; -import org.compiere.swing.CComboBox; -import org.compiere.swing.CLabel; -import org.compiere.swing.CPanel; -import org.compiere.util.CLogger; -import org.compiere.util.DisplayType; -import org.compiere.util.Env; -import org.compiere.util.KeyNamePair; -import org.compiere.util.Msg; - -/** - * Manual Matching - * - * @author Jorg Janke - * @version $Id: VMatch.java,v 1.2 2006/07/30 00:51:28 jjanke Exp $ - */ -public class VMatch extends Match - implements FormPanel, ActionListener, TableModelListener, ListSelectionListener -{ - private CPanel panel = new CPanel(); - - /** - * Initialize Panel - * @param WindowNo window - * @param frame frame - */ - public void init (int WindowNo, FormFrame frame) - { - m_WindowNo = WindowNo; - m_frame = frame; - if (log.isLoggable(Level.INFO)) log.info("WinNo=" + m_WindowNo - + " - AD_Client_ID=" + m_AD_Client_ID + ", AD_Org_ID=" + m_AD_Org_ID + ", By=" + m_by); - Env.setContext(Env.getCtx(), m_WindowNo, "IsSOTrx", "N"); - - try - { - // UI - onlyVendor = VLookup.createBPartner(m_WindowNo); - onlyProduct = VLookup.createProduct(m_WindowNo); - jbInit(); - // - dynInit(); - frame.getContentPane().add(panel, BorderLayout.CENTER); - frame.getContentPane().add(statusBar, BorderLayout.SOUTH); - // - new Thread() - { - public void run() - { - log.info("Starting ..."); - MMatchPO.consolidate(Env.getCtx()); - log.info("... Done"); - } - }.start(); - } - catch(Exception e) - { - log.log(Level.SEVERE, "", e); - } - } // init - - /** Window No */ - private int m_WindowNo = 0; - /** FormFrame */ - private FormFrame m_frame; - /** Logger */ - private static CLogger log = CLogger.getCLogger(VMatch.class); - - private int m_AD_Client_ID = Env.getAD_Client_ID(Env.getCtx()); - private int m_AD_Org_ID = Env.getAD_Org_ID(Env.getCtx()); - private int m_by = Env.getAD_User_ID(Env.getCtx()); - - /** Match Options */ - private String[] m_matchOptions = new String[] { - Msg.getElement(Env.getCtx(), "C_Invoice_ID", false), - Msg.getElement(Env.getCtx(), "M_InOut_ID", false), - Msg.getElement(Env.getCtx(), "C_Order_ID", false) }; - - /** Match Mode */ - private String[] m_matchMode = new String[] { - Msg.translate(Env.getCtx(), "NotMatched"), - Msg.translate(Env.getCtx(), "Matched")}; - private static final int MODE_NOTMATCHED = 0; - private static final int MODE_MATCHED = 1; - - /** Indexes in Table */ - private static final int I_QTY = 6; - private static final int I_MATCHED = 7; - - private BigDecimal m_xMatched = Env.ZERO; - private BigDecimal m_xMatchedTo = Env.ZERO; - - // - private StatusBar statusBar = new StatusBar(); - private BorderLayout mainLayout = new BorderLayout(); - private CPanel northPanel = new CPanel(); - private GridBagLayout northLayout = new GridBagLayout(); - private CLabel matchFromLabel = new CLabel(); - private CComboBoxmatchFrom = new CComboBox(m_matchOptions); - private CLabel matchToLabel = new CLabel(); - private CComboBoxmatchTo = new CComboBox(); - private CLabel matchModeLabel = new CLabel(); - private CComboBoxmatchMode = new CComboBox(m_matchMode); - private VLookup onlyVendor = null; - private VLookup onlyProduct = null; - private CLabel onlyVendorLabel = new CLabel(); - private CLabel onlyProductLabel = new CLabel(); - private CLabel dateFromLabel = new CLabel(); - private CLabel dateToLabel = new CLabel(); - private VDate dateFrom = new VDate("DateFrom", false, false, true, DisplayType.Date, "DateFrom"); - private VDate dateTo = new VDate("DateTo", false, false, true, DisplayType.Date, "DateTo"); - private CButton bSearch = new CButton(); - private CPanel southPanel = new CPanel(); - private GridBagLayout southLayout = new GridBagLayout(); - private CLabel xMatchedLabel = new CLabel(); - private CLabel xMatchedToLabel = new CLabel(); - private CLabel differenceLabel = new CLabel(); - private VNumber xMatched = new VNumber("xMatched", false, true, false, DisplayType.Quantity, "xMatched"); - private VNumber xMatchedTo = new VNumber("xMatchedTo", false, true, false, DisplayType.Quantity, "xMatchedTo"); - private VNumber difference = new VNumber("Difference", false, true, false, DisplayType.Quantity, "Difference"); - private CButton bProcess = new CButton(); - private CPanel centerPanel = new CPanel(); - private BorderLayout centerLayout = new BorderLayout(5,5); - private JScrollPane xMatchedScrollPane = new JScrollPane(); - private TitledBorder xMatchedBorder = new TitledBorder("xMatched"); - private MiniTable xMatchedTable = new MiniTable(); - private JScrollPane xMatchedToScrollPane = new JScrollPane(); - private TitledBorder xMatchedToBorder = new TitledBorder("xMatchedTo"); - private MiniTable xMatchedToTable = new MiniTable(); - private CPanel xPanel = new CPanel(); - private JCheckBox sameProduct = new JCheckBox(); - private JCheckBox sameBPartner = new JCheckBox(); - private JCheckBox sameQty = new JCheckBox(); - private FlowLayout xLayout = new FlowLayout(FlowLayout.CENTER, 10, 0); - - /** - * Static Init. - *
    -	 *  mainPanel
    -	 *      northPanel
    -	 *      centerPanel
    -	 *          xMatched
    -	 *          xPanel
    -	 *          xMathedTo
    -	 *      southPanel
    -	 *  
    - * @throws Exception - */ - private void jbInit() throws Exception - { - panel.setLayout(mainLayout); - northPanel.setLayout(northLayout); - matchFromLabel.setText(Msg.translate(Env.getCtx(), "MatchFrom")); - matchToLabel.setText(Msg.translate(Env.getCtx(), "MatchTo")); - matchModeLabel.setText(Msg.translate(Env.getCtx(), "MatchMode")); - onlyVendorLabel.setText(Msg.translate(Env.getCtx(), "C_BPartner_ID")); - onlyProductLabel.setText(Msg.translate(Env.getCtx(), "M_Product_ID")); - dateFromLabel.setText(Msg.translate(Env.getCtx(), "DateFrom")); - dateToLabel.setText(Msg.translate(Env.getCtx(), "DateTo")); - bSearch.setText(Msg.translate(Env.getCtx(), "Search")); - southPanel.setLayout(southLayout); - xMatchedLabel.setText(Msg.translate(Env.getCtx(), "ToBeMatched")); - xMatchedToLabel.setText(Msg.translate(Env.getCtx(), "Matching")); - differenceLabel.setText(Msg.translate(Env.getCtx(), "Difference")); - bProcess.setText(Msg.translate(Env.getCtx(), "Process")); - centerPanel.setLayout(centerLayout); - xMatchedScrollPane.setBorder(xMatchedBorder); - xMatchedScrollPane.setPreferredSize(new Dimension(450, 200)); - xMatchedToScrollPane.setBorder(xMatchedToBorder); - xMatchedToScrollPane.setPreferredSize(new Dimension(450, 200)); - sameProduct.setSelected(true); - sameProduct.setText(Msg.translate(Env.getCtx(), "SameProduct")); - sameBPartner.setSelected(true); - sameBPartner.setText(Msg.translate(Env.getCtx(), "SameBPartner")); - sameQty.setSelected(false); - sameQty.setText(Msg.translate(Env.getCtx(), "SameQty")); - xPanel.setLayout(xLayout); - panel.add(northPanel, BorderLayout.NORTH); - northPanel.add(matchFromLabel, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(12, 12, 5, 5), 0, 0)); - northPanel.add(matchFrom, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(12, 0, 5, 0), 0, 0)); - northPanel.add(matchToLabel, new GridBagConstraints(2, 0, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(12, 5, 5, 5), 0, 0)); - northPanel.add(matchTo, new GridBagConstraints(3, 0, 1, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(12, 0, 5, 0), 0, 0)); - northPanel.add(matchModeLabel, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 12, 5, 5), 0, 0)); - northPanel.add(matchMode, new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 5, 0), 0, 0)); - northPanel.add(onlyVendor, new GridBagConstraints(1, 2, 1, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 0, 5, 0), 0, 0)); - northPanel.add(onlyProduct, new GridBagConstraints(3, 2, 1, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 0, 5, 0), 0, 0)); - northPanel.add(onlyVendorLabel, new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 12, 5, 5), 0, 0)); - northPanel.add(onlyProductLabel, new GridBagConstraints(2, 2, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); - northPanel.add(dateFromLabel, new GridBagConstraints(0, 3, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 12, 5, 5), 0, 0)); - northPanel.add(dateToLabel, new GridBagConstraints(2, 3, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 5, 5), 0, 0)); - northPanel.add(dateFrom, new GridBagConstraints(1, 3, 1, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 5, 0), 0, 0)); - northPanel.add(dateTo, new GridBagConstraints(3, 3, 1, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 5, 0), 0, 0)); - northPanel.add(bSearch, new GridBagConstraints(4, 3, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 12, 5, 12), 0, 0)); - panel.add(southPanel, BorderLayout.SOUTH); - southPanel.add(xMatchedLabel, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 12, 5, 5), 0, 0)); - southPanel.add(xMatched, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 0, 5, 0), 0, 0)); - southPanel.add(xMatchedToLabel, new GridBagConstraints(2, 0, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 10, 5, 5), 0, 0)); - southPanel.add(bProcess, new GridBagConstraints(6, 0, 1, 1, 0.0, 0.0 - ,GridBagConstraints.NORTHEAST, GridBagConstraints.NONE, new Insets(5, 12, 5, 12), 0, 0)); - southPanel.add(differenceLabel, new GridBagConstraints(4, 0, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 10, 5, 5), 0, 0)); - panel.add(centerPanel, BorderLayout.CENTER); - centerPanel.add(xMatchedScrollPane, BorderLayout.NORTH); - xMatchedScrollPane.getViewport().add(xMatchedTable, null); - centerPanel.add(xMatchedToScrollPane, BorderLayout.SOUTH); - centerPanel.add(xPanel, BorderLayout.CENTER); - xPanel.add(sameBPartner, null); - xPanel.add(sameProduct, null); - xPanel.add(sameQty, null); - xMatchedToScrollPane.getViewport().add(xMatchedToTable, null); - southPanel.add(difference, new GridBagConstraints(5, 0, 1, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 0, 5, 0), 0, 0)); - southPanel.add(xMatchedTo, new GridBagConstraints(3, 0, 1, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 0, 5, 0), 0, 0)); - } // jbInit - - /** - * Dynamic Init. - * Table Layout, Visual, Listener - */ - private void dynInit() - { - ColumnInfo[] layout = new ColumnInfo[] { - new ColumnInfo(" ", ".", IDColumn.class, false, false, ""), - new ColumnInfo(Msg.translate(Env.getCtx(), "DocumentNo"), ".", String.class), // 1 - new ColumnInfo(Msg.translate(Env.getCtx(), "Date"), ".", Timestamp.class), - new ColumnInfo(Msg.translate(Env.getCtx(), "C_BPartner_ID"),".", KeyNamePair.class, "."), // 3 - new ColumnInfo(Msg.translate(Env.getCtx(), "Line"), ".", KeyNamePair.class, "."), - new ColumnInfo(Msg.translate(Env.getCtx(), "M_Product_ID"), ".", KeyNamePair.class, "."), // 5 - new ColumnInfo(Msg.translate(Env.getCtx(), "Qty"), ".", Double.class), - new ColumnInfo(Msg.translate(Env.getCtx(), "Matched"), ".", Double.class), - new ColumnInfo(Msg.translate(Env.getCtx(), "AD_Org_ID"), ".", KeyNamePair.class, ".") //JAVIER - }; - - xMatchedTable.prepareTable(layout, "", "", false, ""); - xMatchedToTable.prepareTable(layout, "", "", true, ""); - - // Visual - CompiereColor.setBackground (panel); - - // Listener - matchFrom.addActionListener(this); - matchTo.addActionListener(this); - bSearch.addActionListener(this); - xMatchedTable.getSelectionModel().addListSelectionListener(this); - xMatchedToTable.getModel().addTableModelListener(this); - bProcess.addActionListener(this); - sameBPartner.addActionListener(this); - sameProduct.addActionListener(this); - sameQty.addActionListener(this); - // Init - matchTo.setModel(new DefaultComboBoxModel(cmd_matchFrom((String)matchFrom.getSelectedItem()))); - // Set Title - xMatchedBorder.setTitle((String)matchFrom.getSelectedItem()); - xMatchedScrollPane.repaint(); - // Reset Table - xMatchedTable.setRowCount(0); - - cmd_matchTo(); - statusBar.setStatusLine(""); - statusBar.setStatusDB(0); - } // dynInit - - /** - * Dispose - */ - public void dispose() - { - if (m_frame != null) - m_frame.dispose(); - m_frame = null; - } // dispose - - - /************************************************************************** - * Action Listener - * @param e event - */ - public void actionPerformed (ActionEvent e) - { - panel.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); - Integer product = onlyProduct.getValue()!=null?(Integer)onlyProduct.getValue():null; - Integer vendor = onlyVendor.getValue()!=null?(Integer)onlyVendor.getValue():null; - Timestamp from = dateFrom.getValue()!=null?(Timestamp)dateFrom.getValue():null; - Timestamp to = dateTo.getValue()!=null?(Timestamp)dateTo.getValue():null; - if (e.getSource() == matchFrom) { - String selection = (String)matchFrom.getSelectedItem(); - matchTo.setModel(new DefaultComboBoxModel(cmd_matchFrom(selection))); - // Set Title - xMatchedBorder.setTitle(selection); - xMatchedScrollPane.repaint(); - // Reset Table - xMatchedTable.setRowCount(0); - // sync To - cmd_matchTo(); - - } - else if (e.getSource() == matchTo) - cmd_matchTo(); - else if (e.getSource() == bSearch) { - xMatchedTable = (MiniTable) cmd_search(xMatchedTable, matchFrom.getSelectedIndex(), (String)matchTo.getSelectedItem(), product, vendor, from, to, matchMode.getSelectedIndex() == MODE_MATCHED); - xMatched.setValue(Env.ZERO); - // Status Info - statusBar.setStatusLine(matchFrom.getSelectedItem().toString() - + "# = " + xMatchedTable.getRowCount(), - xMatchedTable.getRowCount() == 0); - statusBar.setStatusDB(0); - } - else if (e.getSource() == bProcess) { - cmd_process(xMatchedTable, xMatchedToTable, matchMode.getSelectedIndex(), matchFrom.getSelectedIndex(), matchTo.getSelectedItem(), m_xMatched); - xMatchedTable = (MiniTable) cmd_search(xMatchedTable, matchFrom.getSelectedIndex(), (String)matchTo.getSelectedItem(), product, vendor, from, to, matchMode.getSelectedIndex() == MODE_MATCHED); - xMatched.setValue(Env.ZERO); - // Status Info - statusBar.setStatusLine(matchFrom.getSelectedItem().toString() - + "# = " + xMatchedTable.getRowCount(), - xMatchedTable.getRowCount() == 0); - statusBar.setStatusDB(0); - } - else if (e.getSource() == sameBPartner - || e.getSource() == sameProduct - || e.getSource() == sameQty) - xMatchedTable = (MiniTable) cmd_search(xMatchedTable, matchFrom.getSelectedIndex(), (String)matchTo.getSelectedItem(), product, vendor, from, to, matchMode.getSelectedIndex() == MODE_MATCHED); - panel.setCursor(Cursor.getDefaultCursor()); - } // actionPerformed - - - /** - * Match To Changed - set Title - */ - private void cmd_matchTo() - { - // log.fine( "VMatch.cmd_matchTo"); - String selection = (String)matchTo.getSelectedItem(); - xMatchedToBorder.setTitle(selection); - xMatchedToScrollPane.repaint(); - // Reset Table - xMatchedToTable.setRowCount(0); - } // cmd_matchTo - - - /************************************************************************** - * List Selection Listener - get Info and fill xMatchedTo - * @param e event - */ - public void valueChanged (ListSelectionEvent e) - { - if (e.getValueIsAdjusting()) - return; - // log.config( "VMatch.valueChanged"); - panel.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); - cmd_searchTo(); - panel.setCursor(Cursor.getDefaultCursor()); - } // valueChanged - - /** - * Fill xMatchedTo - */ - private void cmd_searchTo() - { - int row = xMatchedTable.getSelectedRow(); - if (log.isLoggable(Level.CONFIG)) log.config("Row=" + row); - - double qty = 0.0; - if (row < 0) - { - xMatchedToTable.setRowCount(0); - } - else - { - // ** Create SQL ** - String displayString = (String)matchTo.getSelectedItem(); - int matchToType = matchFrom.getSelectedIndex(); - double docQty = ((Double)xMatchedTable.getValueAt(row, I_QTY)).doubleValue(); - double matchedQty = ((Double)xMatchedTable.getValueAt(row, I_MATCHED)).doubleValue(); - qty = docQty - matchedQty; - xMatchedToTable = (MiniTable)cmd_searchTo(xMatchedTable, xMatchedToTable, displayString, matchToType, sameBPartner.isSelected(), sameProduct.isSelected(), sameQty.isSelected(), matchMode.getSelectedIndex() == MODE_MATCHED); - - } - // Display To be Matched Qty - m_xMatched = BigDecimal.valueOf(qty); - xMatched.setValue(m_xMatched); - xMatchedTo.setValue(Env.ZERO); - difference.setValue(m_xMatched); - // Status Info - statusBar.setStatusLine(matchFrom.getSelectedItem().toString() - + "# = " + xMatchedTable.getRowCount() + " - " - + matchTo.getSelectedItem().toString() - + "# = " + xMatchedToTable.getRowCount(), - xMatchedToTable.getRowCount() == 0); - statusBar.setStatusDB(0); - } // cmd_searchTo - - /*************************************************************************** - * Table Model Listener - calculate matched Qty - * @param e event - */ - public void tableChanged (TableModelEvent e) - { - if (e.getColumn() != 0) - return; - if (log.isLoggable(Level.CONFIG)) log.config("Row=" + e.getFirstRow() + "-" + e.getLastRow() + ", Col=" + e.getColumn() - + ", Type=" + e.getType()); - panel.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); - - // Matched From - int matchedRow = xMatchedTable.getSelectedRow(); - KeyNamePair Product = (KeyNamePair)xMatchedTable.getValueAt(matchedRow, 5); - - // Matched To - double qty = 0.0; - int noRows = 0; - for (int row = 0; row < xMatchedToTable.getRowCount(); row++) - { - IDColumn id = (IDColumn)xMatchedToTable.getValueAt(row, 0); - if (id != null && id.isSelected()) - { - KeyNamePair ProductCompare = (KeyNamePair)xMatchedToTable.getValueAt(row, 5); - if (Product.getKey() != ProductCompare.getKey()) - { - id.setSelected(false); - } - else - { - if (matchMode.getSelectedIndex() == MODE_NOTMATCHED) - qty += ((Double)xMatchedToTable.getValueAt(row, I_QTY)).doubleValue(); // doc - qty -= ((Double)xMatchedToTable.getValueAt(row, I_MATCHED)).doubleValue(); // matched - noRows++; - } - } - } - // update quantities - m_xMatchedTo = BigDecimal.valueOf(qty); - xMatchedTo.setValue(m_xMatchedTo); - difference.setValue(m_xMatched.subtract(m_xMatchedTo)); - bProcess.setEnabled(noRows != 0); - panel.setCursor(Cursor.getDefaultCursor()); - // Status - statusBar.setStatusDB(noRows); - } // tableChanged - -} // VMatch diff --git a/org.adempiere.ui.swing/src/org/compiere/apps/form/VMerge.java b/org.adempiere.ui.swing/src/org/compiere/apps/form/VMerge.java deleted file mode 100644 index 83f4b6592f..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/apps/form/VMerge.java +++ /dev/null @@ -1,245 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ -package org.compiere.apps.form; - -import java.awt.BorderLayout; -import java.awt.Cursor; -import java.awt.Font; -import java.awt.GridLayout; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.util.logging.Level; - -import org.compiere.apps.ADialog; -import org.compiere.apps.ConfirmPanel; -import org.compiere.grid.ed.VLookup; -import org.compiere.model.MLookupFactory; -import org.compiere.swing.CLabel; -import org.compiere.swing.CPanel; -import org.compiere.util.DisplayType; -import org.compiere.util.Env; -import org.compiere.util.Msg; - -/** - * Merge Dialog. - * Restriction - fails for Accounting - * - * @author Jorg Janke - * @version $Id: VMerge.java,v 1.2 2006/07/30 00:51:28 jjanke Exp $ - */ -public class VMerge extends Merge implements FormPanel, ActionListener -{ - private CPanel panel = new CPanel(); - - /** FormFrame */ - private FormFrame m_frame; - - private CLabel[] m_label = null; - private VLookup[] m_from = null; - private VLookup[] m_to = null; - - private BorderLayout mainLayout = new BorderLayout(); - private CPanel CenterPanel = new CPanel(); - private GridLayout centerLayout = new GridLayout(); - private CLabel mergeFromLabel = new CLabel(); - private CLabel mergeToLabel = new CLabel(); - private ConfirmPanel confirmPanel = new ConfirmPanel(true); - - /** - * Initialize Panel - * @param WindowNo window - * @param frame frame - */ - public void init (int WindowNo, FormFrame frame) - { - m_WindowNo = WindowNo; - m_frame = frame; - if (log.isLoggable(Level.INFO)) log.info( "VMerge.init - WinNo=" + m_WindowNo); - try - { - preInit(); - jbInit (); - frame.getContentPane().add(panel, BorderLayout.CENTER); - // frame.getContentPane().add(statusBar, BorderLayout.SOUTH); - } - catch (Exception ex) - { - log.log(Level.SEVERE, "", ex); - } - } // init - - /** - * Pre Init - */ - public void preInit() - { - int count = 4; // ** Update ** - m_columnName = new String[count]; - m_label = new CLabel[count]; - m_from = new VLookup[count]; - m_to = new VLookup[count]; - - // ** Update ** - preInit (0, 2163, DisplayType.TableDir, AD_ORG_ID); // C_Order.AD_Org_ID - preInit (1, 2762, DisplayType.Search, C_BPARTNER_ID); // C_Order.C_BPartner_ID - preInit (2, 971, DisplayType.Search, AD_USER_ID); // AD_User_Roles.AD_User_ID - preInit (3, 2221, DisplayType.Search, M_PRODUCT_ID); // C_OrderLine.M_Product_ID - } // preInit - - /** - * Pre Init Line - * @param index index - * @param AD_Column_ID id - * @param displayType display type - * @param ColumnName column name - */ - private void preInit (int index, int AD_Column_ID, int displayType, String ColumnName) - { - m_columnName[index] = ColumnName; - String what = Msg.translate(Env.getCtx(), ColumnName); - m_label[index] = new CLabel(what); - m_from[index] = new VLookup (ColumnName, false, false, true, - MLookupFactory.get (Env.getCtx(), m_WindowNo, 0, AD_Column_ID, displayType)); - m_to[index] = new VLookup (ColumnName, false, false, true, - MLookupFactory.get (Env.getCtx(), m_WindowNo, 0, AD_Column_ID, displayType)); - } // preInit - - /** - * Static init - * @throws java.lang.Exception - */ - void jbInit () throws Exception - { - panel.setLayout (mainLayout); - mainLayout.setHgap (5); - mainLayout.setVgap (5); - // - panel.add (confirmPanel, BorderLayout.SOUTH); - confirmPanel.addActionListener(this); - // - centerLayout.setHgap (5); - centerLayout.setVgap (5); - centerLayout.setColumns (3); - centerLayout.setRows (m_label.length+1); - // - CenterPanel.setLayout (centerLayout); - panel.add (CenterPanel, BorderLayout.CENTER); - CenterPanel.add (new CLabel(), null); - CenterPanel.add (mergeFromLabel, null); - CenterPanel.add (mergeToLabel, null); - // - Font heading = mergeFromLabel.getFont(); - heading = new Font(heading.getName(), Font.BOLD, heading.getSize()); - mergeFromLabel.setFont (heading); - mergeFromLabel.setRequestFocusEnabled (false); - mergeFromLabel.setText (Msg.getMsg(Env.getCtx(), "MergeFrom")); - mergeToLabel.setFont (heading); - mergeToLabel.setText (Msg.getMsg(Env.getCtx(), "MergeTo")); - // - for (int i = 0; i < m_label.length; i++) - { - CenterPanel.add (m_label[i], null); - CenterPanel.add (m_from[i], null); - CenterPanel.add (m_to[i], null); - } - } // jbInit - - /** - * Dispose - */ - public void dispose() - { - if (m_frame != null) - m_frame.dispose(); - m_frame = null; - } // dispose - - /** - * Action Listener - * @param e event - */ - public void actionPerformed (ActionEvent e) - { - if (e.getActionCommand().equals(ConfirmPanel.A_CANCEL)) - { - dispose(); - return; - } - - String columnName = null; - String from_Info = null; - String to_Info = null; - int from_ID = 0; - int to_ID = 0; - - // get first merge pair - for (int i = 0; (i < m_columnName.length && from_ID == 0 && to_ID == 0); i++) - { - Object value = m_from[i].getValue(); - if (value != null) - { - if (value instanceof Integer) - from_ID = ((Integer)value).intValue(); - else - continue; - value = m_to[i].getValue(); - if (value != null && value instanceof Integer) - to_ID = ((Integer)value).intValue(); - else - from_ID = 0; - if (from_ID != 0) - { - columnName = m_columnName[i]; - from_Info = m_from[i].getDisplay (); - to_Info = m_to[i].getDisplay (); - } - } - } // get first merge pair - - if (from_ID == 0 || from_ID == to_ID) - return; - - String msg = Msg.getMsg(Env.getCtx(), "MergeFrom") + " = " + from_Info - + "\n" + Msg.getMsg(Env.getCtx(), "MergeTo") + " = " + to_Info; - if (!ADialog.ask(m_WindowNo, panel, "MergeQuestion", msg)) - return; - - updateDeleteTable(columnName); - - panel.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); - confirmPanel.getOKButton().setEnabled(false); - // - boolean success = merge (columnName, from_ID, to_ID); - postMerge(columnName, to_ID); - // - confirmPanel.getOKButton().setEnabled(true); - panel.setCursor(Cursor.getDefaultCursor()); - // - if (success) - { - ADialog.info (m_WindowNo, panel, "MergeSuccess", - msg + " #" + m_totalCount); - } - else - { - ADialog.error(m_WindowNo, panel, "MergeError", - m_errorLog.toString()); - return; - } - dispose(); - } // actionPerformed -} // VMerge diff --git a/org.adempiere.ui.swing/src/org/compiere/apps/form/VPayPrint.java b/org.adempiere.ui.swing/src/org/compiere/apps/form/VPayPrint.java deleted file mode 100644 index 8c3535ceb5..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/apps/form/VPayPrint.java +++ /dev/null @@ -1,567 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ -package org.compiere.apps.form; - -import java.awt.BorderLayout; -import java.awt.Cursor; -import java.awt.FlowLayout; -import java.awt.GridBagConstraints; -import java.awt.GridBagLayout; -import java.awt.Insets; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.beans.PropertyChangeEvent; -import java.beans.PropertyVetoException; -import java.beans.VetoableChangeListener; -import java.util.ArrayList; -import java.util.logging.Level; - -import javax.swing.JButton; -import javax.swing.JFileChooser; - -import org.compiere.apps.ADialog; -import org.compiere.apps.AEnv; -import org.compiere.apps.ConfirmPanel; -import org.compiere.grid.ed.VLookup; -import org.compiere.grid.ed.VNumber; -import org.compiere.model.MLookup; -import org.compiere.model.MLookupFactory; -import org.compiere.model.MPaySelectionCheck; -import org.compiere.model.MPaymentBatch; -import static org.compiere.model.SystemIDs.*; -import org.compiere.plaf.CompiereColor; -import org.compiere.print.ReportCtl; -import org.compiere.print.ReportEngine; -import org.compiere.swing.CCheckBox; -import org.compiere.swing.CComboBox; -import org.compiere.swing.CLabel; -import org.compiere.swing.CPanel; -import org.compiere.util.DB; -import org.compiere.util.DisplayType; -import org.compiere.util.Env; -import org.compiere.util.Ini; -import org.compiere.util.Msg; -import org.compiere.util.ValueNamePair; - -/** - * Payment Print & Export - * - * @author Jorg Janke - * @version $Id: VPayPrint.java,v 1.2 2006/07/30 00:51:28 jjanke Exp $ - * - * Contributors: - * Carlos Ruiz - GlobalQSS - FR 3132033 - Make payment export class configurable per bank - * Markus Bozem: IDEMPIERE-1546 / IDEMPIERE-3286 - */ -public class VPayPrint extends PayPrint implements FormPanel, ActionListener, VetoableChangeListener -{ - private CPanel panel = new CPanel(); - - /** - * Initialize Panel - * @param WindowNo window - * @param frame frame - */ - public void init (int WindowNo, FormFrame frame) - { - log.info(""); - m_WindowNo = WindowNo; - m_frame = frame; - try - { - dynInit(); - jbInit(); - frame.getContentPane().add(centerPanel, BorderLayout.CENTER); - frame.getContentPane().add(southPanel, BorderLayout.SOUTH); - } - catch(Exception e) - { - log.log(Level.SEVERE, "", e); - } - } // init - - - /** FormFrame */ - private FormFrame m_frame; - - // Static Variables - private CPanel centerPanel = new CPanel(); - private CPanel southPanel = new CPanel(); - private FlowLayout southLayout = new FlowLayout(); - private GridBagLayout centerLayout = new GridBagLayout(); - private JButton bPrint = ConfirmPanel.createPrintButton(true); - private JButton bExport = ConfirmPanel.createExportButton(true); - private JButton bCancel = ConfirmPanel.createCancelButton(true); - private JButton bProcess = ConfirmPanel.createProcessButton(Msg.getMsg(Env.getCtx(), "VPayPrintProcess")); - private CLabel lPaySelect = new CLabel(); - private VLookup paySelectSearch = null; - private CLabel lBank = new CLabel(); - private CLabel fBank = new CLabel(); - private CLabel lPaymentRule = new CLabel(); - private CComboBoxfPaymentRule = new CComboBox(); - private CLabel lDocumentNo = new CLabel(); - private VNumber fDocumentNo = new VNumber(); - private CLabel lNoPayments = new CLabel(); - private CLabel fNoPayments = new CLabel(); - private CLabel lBalance = new CLabel(); - private VNumber fBalance = new VNumber(); - private CLabel lCurrency = new CLabel(); - private CLabel fCurrency = new CLabel(); - private CLabel lDepositBatch = new CLabel(); - private CCheckBox fDepositBatch = new CCheckBox(); - private CLabel lSumPayments = new CLabel(); - private VNumber fSumPayments = new VNumber(); - /** - * Static Init - * @throws Exception - */ - private void jbInit() throws Exception - { - CompiereColor.setBackground(panel); - // - southPanel.setLayout(southLayout); - southLayout.setAlignment(FlowLayout.RIGHT); - centerPanel.setLayout(centerLayout); - // - bPrint.setEnabled(false); - bExport.setEnabled(false); - bPrint.addActionListener(this); - bExport.addActionListener(this); - bCancel.addActionListener(this); - // - bProcess.setText(Msg.getMsg(Env.getCtx(), "EFT")); - bProcess.setEnabled(false); - bProcess.addActionListener(this); - // - lPaySelect.setText(Msg.translate(Env.getCtx(), "C_PaySelection_ID")); - // - lBank.setText(Msg.translate(Env.getCtx(), "C_BankAccount_ID")); - // - lPaymentRule.setText(Msg.translate(Env.getCtx(), "PaymentRule")); - fPaymentRule.addActionListener(this); - // - lDocumentNo.setText(Msg.translate(Env.getCtx(), "DocumentNo")); - fDocumentNo.setDisplayType(DisplayType.Integer); - lNoPayments.setText(Msg.getMsg(Env.getCtx(), "NoOfPayments")); - fNoPayments.setText("0"); - lBalance.setText(Msg.translate(Env.getCtx(), "CurrentBalance")); - fBalance.setReadWrite(false); - fBalance.setDisplayType(DisplayType.Amount); - lCurrency.setText(Msg.translate(Env.getCtx(), "C_Currency_ID")); - lDepositBatch.setText(Msg.translate(Env.getCtx(), "C_DepositBatch_ID")); - lSumPayments.setText(Msg.getMsg(Env.getCtx(), "Sum")); - fSumPayments.setReadWrite(false); - fSumPayments.setDisplayType(DisplayType.Amount); - // - southPanel.add(bCancel, null); - southPanel.add(bExport, null); - southPanel.add(bPrint, null); - southPanel.add(bProcess, null); - // - centerPanel.add(lPaySelect, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(12, 12, 5, 5), 0, 0)); - centerPanel.add(paySelectSearch, new GridBagConstraints(1, 0, 3, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(12, 0, 5, 12), 0, 0)); - centerPanel.add(lBank, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 12, 5, 5), 0, 0)); - centerPanel.add(fBank, new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 5, 12), 0, 0)); - centerPanel.add(lPaymentRule, new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 12, 5, 5), 0, 0)); - centerPanel.add(fPaymentRule, new GridBagConstraints(1, 2, 1, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 5, 12), 0, 0)); - centerPanel.add(lDocumentNo, new GridBagConstraints(0, 3, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 12, 5, 5), 0, 0)); - centerPanel.add(fDocumentNo, new GridBagConstraints(1, 3, 1, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 5, 12), 0, 0)); - centerPanel.add(lNoPayments, new GridBagConstraints(2, 3, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 12, 5, 5), 0, 0)); - centerPanel.add(fNoPayments, new GridBagConstraints(3, 3, 1, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 5, 12), 0, 0)); - centerPanel.add(lBalance, new GridBagConstraints(2, 1, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 12, 5, 5), 0, 0)); - centerPanel.add(fBalance, new GridBagConstraints(3, 1, 1, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 5, 12), 0, 0)); - centerPanel.add(lCurrency, new GridBagConstraints(2, 2, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 12, 12, 5), 0, 0)); - centerPanel.add(fCurrency, new GridBagConstraints(3, 2, 1, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 12, 12), 0, 0)); - - centerPanel.add(lDepositBatch, new GridBagConstraints(0, 4, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 12, 5, 5), 0, 0)); - centerPanel.add(fDepositBatch, new GridBagConstraints(1, 4, 1, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 5, 12), 0, 0)); - centerPanel.add(lSumPayments, new GridBagConstraints(2, 4, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 12, 5, 5), 0, 0)); - centerPanel.add(fSumPayments, new GridBagConstraints(3, 4, 1, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 5, 12), 0, 0)); - } // VPayPrint - - /** - * Dynamic Init - */ - private void dynInit() - { - - // C_PaySelection_ID - int AD_Column_ID = COLUMN_C_PAYSELECTIONCHECK_C_PAYSELECTION_ID; // C_PaySelectionCheck.C_PaySelection_ID - MLookup lookupPS = MLookupFactory.get (Env.getCtx(), m_WindowNo, 0, AD_Column_ID, DisplayType.Search); - paySelectSearch = new VLookup("C_PaySelection_ID", true, false, true, lookupPS); - paySelectSearch.addVetoableChangeListener(this); - - } // dynInit - - /** - * Dispose - */ - public void dispose() - { - if (m_frame != null) - m_frame.dispose(); - m_frame = null; - } // dispose - - /** - * Set Payment Selection - * @param C_PaySelection_ID id - */ - public void setPaySelection (int C_PaySelection_ID) - { - if (C_PaySelection_ID == 0) - return; - - m_C_PaySelection_ID = C_PaySelection_ID; - paySelectSearch.setValue(Integer.valueOf(m_C_PaySelection_ID)); - loadPaySelectInfo(); - } // setsetPaySelection - - /************************************************************************** - * Action Listener - * @param e event - */ - public void actionPerformed(ActionEvent e) - { - // log.config( "VPayPrint.actionPerformed" + e.toString()); - if (e.getSource() == bCancel) - dispose(); - else if (m_C_PaySelection_ID <= 0) - return; - else if (e.getSource() == fPaymentRule) - loadPaymentRuleInfo(); - else if (e.getSource() == bExport) - cmd_export(); - else if (e.getSource() == bProcess) - cmd_EFT(); - else if (e.getSource() == bPrint) - cmd_print(); - } // actionPerformed - - /** - * PaySelect changed - load Bank - */ - private void loadPaySelectInfo() - { - log.info( "VPayPrint.loadPaySelectInfo"); - if (m_C_PaySelection_ID <= 0) - return; - - loadPaySelectInfo(m_C_PaySelection_ID); - - fBank.setText(bank); - fCurrency.setText(currency); - fBalance.setValue(balance); - - m_frame.pack(); - - loadPaymentRule(); - } // loadPaySelectInfo - - /** - * Bank changed - load PaymentRule - */ - private void loadPaymentRule() - { - log.info(""); - if (m_C_BankAccount_ID == -1) - return; - - fPaymentRule.removeAllItems(); - - ArrayList data = loadPaymentRule(m_C_PaySelection_ID); - for(ValueNamePair pp : data) - fPaymentRule.addItem(pp); - - if (fPaymentRule.getItemCount() > 0) - fPaymentRule.setSelectedIndex(0); - - loadPaymentRuleInfo(); - } // loadPaymentRule - - /** - * PaymentRule changed - load DocumentNo, NoPayments, - * enable/disable EFT, Print - */ - private void loadPaymentRuleInfo() - { - ValueNamePair pp = (ValueNamePair)fPaymentRule.getSelectedItem(); - if (pp == null) - return; - String PaymentRule = pp.getValue(); - - if (log.isLoggable(Level.INFO)) log.info("PaymentRule=" + PaymentRule); - fNoPayments.setText(" "); - - String msg = loadPaymentRuleInfo(m_C_PaySelection_ID, PaymentRule); - - if(noPayments != null) - fNoPayments.setText(noPayments); - - if(sumPayments != null) - fSumPayments.setValue(sumPayments); - - bProcess.setEnabled(PaymentRule.equals("T")); - - if(documentNo != null) - fDocumentNo.setValue(documentNo); - - if(msg != null && msg.length() > 0) - ADialog.error(m_WindowNo, panel, msg); - - getPluginFeatures(); - } // loadPaymentRuleInfo - - protected void getPluginFeatures() - { - if (m_C_PaySelection_ID!=0) - { - if (loadPaymentExportClass (null)>=0) - { - bExport.setEnabled(true); - - fDepositBatch.setValue(m_PaymentExport.getDefaultDepositBatch()); - if (m_PaymentExport.supportsDepositBatch() && m_PaymentExport.supportsSeparateBooking()) - { - fDepositBatch.setReadWrite(true); - } - else - { - fDepositBatch.setReadWrite(false); - } - } - else - { - bExport.setEnabled(false); - } - if (printFormatId!=null && printFormatId!=0) - { - bPrint.setEnabled(true); - } - else - { - bPrint.setEnabled(false); - } - } - - } // getPluginFeatures - - /************************************************************************** - * Export payments to file - */ - private void cmd_export() - { - ValueNamePair pp = (ValueNamePair)fPaymentRule.getSelectedItem(); - if (pp == null) - return; - String PaymentRule = pp.getValue(); - log.info(PaymentRule); - if (!getChecks(PaymentRule)) - return; - - // Get File Info - JFileChooser fc = new JFileChooser(); - fc.setDialogTitle(Msg.getMsg(Env.getCtx(), "Export")); - fc.setFileSelectionMode(JFileChooser.FILES_ONLY); - fc.setMultiSelectionEnabled(false); - String filename = m_PaymentExport.getFilenamePrefix() + m_PaymentExport.getFilenameSuffix(); - fc.setSelectedFile(new java.io.File(filename)); - if (fc.showSaveDialog(panel) != JFileChooser.APPROVE_OPTION) - return; - - // Create File - int no = 0; - StringBuffer err = new StringBuffer(""); - if (m_PaymentExportClass == null || m_PaymentExportClass.trim().length() == 0) { - m_PaymentExportClass = "org.compiere.util.GenericPaymentExport"; - } - - no = loadPaymentExportClass(err) ; - - if (no >= 0) - { - no = m_PaymentExport.exportToFile(m_checks,(Boolean) fDepositBatch.getValue(),PaymentRule, fc.getSelectedFile(), err); - } - - if (no >= 0) { - ADialog.info(m_WindowNo, panel, "Saved", - fc.getSelectedFile().getAbsolutePath() + "\n" - + Msg.getMsg(Env.getCtx(), "NoOfLines") + "=" + no); - - if (ADialog.ask(m_WindowNo, panel, "VPayPrintSuccess?")) - { - // int lastDocumentNo = - MPaySelectionCheck.confirmPrint (m_checks, m_batch, (Boolean) fDepositBatch.getValue()); - // document No not updated - } - } else { - ADialog.error(m_WindowNo, panel, "Error", err.toString()); - } - dispose(); - } // cmd_export - - /** - * Create EFT payment - */ - private void cmd_EFT() - { - ValueNamePair pp = (ValueNamePair)fPaymentRule.getSelectedItem(); - if (pp == null) - return; - String PaymentRule = pp.getValue(); - log.info(PaymentRule); - if (!getChecks(PaymentRule)) - return; - dispose(); - } // cmd_EFT - - /** - * Print Checks and/or Remittance - */ - private void cmd_print() - { - ValueNamePair pp = (ValueNamePair)fPaymentRule.getSelectedItem(); - if (pp == null) - return; - String PaymentRule = pp.getValue(); - log.info(PaymentRule); - if (!getChecks(PaymentRule)) - return; - - panel.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); - - boolean somethingPrinted = false; - boolean directPrint = !Ini.isPropertyBool(Ini.P_PRINTPREVIEW); - // for all checks - for (int i = 0; i < m_checks.length; i++) - { - MPaySelectionCheck check = m_checks[i]; - // ReportCtrl will check BankAccountDoc for PrintFormat - boolean ok = ReportCtl.startDocumentPrint(ReportEngine.CHECK, check.get_ID(), null, AEnv.getWindowNo(panel), directPrint); - if (!somethingPrinted && ok) - somethingPrinted = true; - } - - // Confirm Print and Update BankAccountDoc - if (somethingPrinted && ADialog.ask(m_WindowNo, panel, "VPayPrintSuccess?")) - { - int lastDocumentNo = MPaySelectionCheck.confirmPrint (m_checks, m_batch); - if (lastDocumentNo != 0) - { - StringBuilder sb = new StringBuilder(); - sb.append("UPDATE C_BankAccountDoc SET CurrentNext=").append(++lastDocumentNo) - .append(" WHERE C_BankAccount_ID=").append(m_C_BankAccount_ID) - .append(" AND PaymentRule='").append(PaymentRule).append("'"); - DB.executeUpdate(sb.toString(), null); - } - } // confirm - - if (ADialog.ask(m_WindowNo, panel, "VPayPrintPrintRemittance")) - { - for (int i = 0; i < m_checks.length; i++) - { - MPaySelectionCheck check = m_checks[i]; - ReportCtl.startDocumentPrint(ReportEngine.REMITTANCE, check.get_ID(), null, AEnv.getWindowNo(panel), directPrint); - } - } // remittance - - panel.setCursor(Cursor.getDefaultCursor()); - dispose(); - } // cmd_print - - - /************************************************************************** - * Get Checks - * @param PaymentRule Payment Rule - * @return true if payments were created - */ - private boolean getChecks(String PaymentRule) - { - // do we have values - if (m_C_PaySelection_ID <= 0 || m_C_BankAccount_ID == -1 - || fPaymentRule.getSelectedIndex() == -1 || fDocumentNo.getValue() == null) - { - ADialog.error(m_WindowNo, panel, "VPayPrintNoRecords", - "(" + Msg.translate(Env.getCtx(), "C_PaySelectionLine_ID") + "=0)"); - return false; - } - - // get data - int startDocumentNo = ((Number)fDocumentNo.getValue()).intValue(); - - if (log.isLoggable(Level.CONFIG)) log.config("C_PaySelection_ID=" + m_C_PaySelection_ID + ", PaymentRule=" + PaymentRule + ", DocumentNo=" + startDocumentNo); - // - panel.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); - - // get Selections - m_checks = MPaySelectionCheck.get(m_C_PaySelection_ID, PaymentRule, startDocumentNo, null); - - panel.setCursor(Cursor.getDefaultCursor()); - // - if (m_checks == null || m_checks.length == 0) - { - ADialog.error(m_WindowNo, panel, "VPayPrintNoRecords", - "(" + Msg.translate(Env.getCtx(), "C_PaySelectionLine_ID") + " #0"); - return false; - } - m_batch = MPaymentBatch.getForPaySelection (Env.getCtx(), m_C_PaySelection_ID, null); - return true; - } // getChecks - - /** - * Vetoable Change Listener. - * - Payment Selection - * @param evt event - */ - @Override - public void vetoableChange(PropertyChangeEvent e) - throws PropertyVetoException { - String name = e.getPropertyName(); - Object value = e.getNewValue(); - if (log.isLoggable(Level.CONFIG)) log.config(name + "=" + value); - - if (value == null) - return; - - // Payment Selection - if (name.equals("C_PaySelection_ID")) - { - paySelectSearch.setValue(value); - m_C_PaySelection_ID = ((Integer)value).intValue(); - loadPaySelectInfo(); - } - } - -} // PayPrint diff --git a/org.adempiere.ui.swing/src/org/compiere/apps/form/VPaySelect.java b/org.adempiere.ui.swing/src/org/compiere/apps/form/VPaySelect.java deleted file mode 100644 index 3ab400e066..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/apps/form/VPaySelect.java +++ /dev/null @@ -1,473 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - * Contributors: * - * Colin Rooney (croo) Patch 1605368 Fixed Payment Terms & Only due * - *****************************************************************************/ -package org.compiere.apps.form; - -import java.awt.BorderLayout; -import java.awt.FlowLayout; -import java.awt.GridBagConstraints; -import java.awt.GridBagLayout; -import java.awt.Insets; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.io.File; -import java.sql.Timestamp; -import java.util.ArrayList; -import java.util.logging.Level; - -import javax.swing.JButton; -import javax.swing.JLabel; -import javax.swing.JScrollPane; -import javax.swing.event.TableModelEvent; -import javax.swing.event.TableModelListener; - -import org.adempiere.util.Callback; -import org.adempiere.util.IProcessUI; -import org.compiere.apps.ADialog; -import org.compiere.apps.AEnv; -import org.compiere.apps.ConfirmPanel; -import org.compiere.apps.IProcessParameter; -import org.compiere.apps.ProcessCtl; -import org.compiere.apps.ProcessParameterPanel; -import org.compiere.grid.ed.VCheckBox; -import org.compiere.grid.ed.VComboBox; -import org.compiere.grid.ed.VDate; -import org.compiere.minigrid.MiniTable; -import static org.compiere.model.SystemIDs.*; - -import org.compiere.model.MProcess; -import org.compiere.model.X_C_PaySelection; -import org.compiere.plaf.CompiereColor; -import org.compiere.process.ProcessInfo; -import org.compiere.swing.CLabel; -import org.compiere.swing.CPanel; -import org.compiere.util.Env; -import org.compiere.util.KeyNamePair; -import org.compiere.util.Msg; -import org.compiere.util.ValueNamePair; - -/** - * Create Manual Payments From (AP) Invoices or (AR) Credit Memos. - * Allows user to select Invoices for payment. - * When Processed, PaySelection is created - * and optionally posted/generated and printed - * - * @author Jorg Janke - * @version $Id: VPaySelect.java,v 1.2 2008/07/11 08:20:12 cruiz Exp $ - */ -public class VPaySelect extends PaySelect implements FormPanel, ActionListener, TableModelListener, IProcessUI -{ - /** @todo withholding */ - private CPanel panel = new CPanel(); - - /** - * Initialize Panel - * @param WindowNo window - * @param frame frame - */ - public void init (int WindowNo, FormFrame frame) - { - log.info(""); - m_WindowNo = WindowNo; - m_frame = frame; - try - { - jbInit(); - dynInit(); - frame.getContentPane().add(commandPanel, BorderLayout.SOUTH); - frame.getContentPane().add(mainPanel, BorderLayout.CENTER); - } - catch(Exception e) - { - log.log(Level.SEVERE, "", e); - } - } // init - - /** FormFrame */ - private FormFrame m_frame; - - // - private CPanel mainPanel = new CPanel(); - private BorderLayout mainLayout = new BorderLayout(); - private CPanel parameterPanel = new CPanel(); - private CLabel labelBankAccount = new CLabel(); - private VComboBox fieldBankAccount = new VComboBox(); - private GridBagLayout parameterLayout = new GridBagLayout(); - private CLabel labelBankBalance = new CLabel(); - private CLabel labelCurrency = new CLabel(); - private CLabel labelBalance = new CLabel(); - private VCheckBox onlyDue = new VCheckBox(); - private CLabel labelBPartner = new CLabel(); - private VComboBox fieldBPartner = new VComboBox(); - private CLabel labelDtype = new CLabel(); - private VComboBox fieldDtype = new VComboBox(); - - private JLabel dataStatus = new JLabel(); - private JScrollPane dataPane = new JScrollPane(); - private MiniTable miniTable = new MiniTable(); - private CPanel commandPanel = new CPanel(); - private JButton bCancel = ConfirmPanel.createCancelButton(true); - private JButton bGenerate = ConfirmPanel.createProcessButton(true); - private FlowLayout commandLayout = new FlowLayout(); - private JButton bRefresh = ConfirmPanel.createRefreshButton(true); - private CLabel labelPayDate = new CLabel(); - private VDate fieldPayDate = new VDate(); - private CLabel labelPaymentRule = new CLabel(); - private VComboBox fieldPaymentRule = new VComboBox(); - - /** - * Static Init - * @throws Exception - */ - private void jbInit() throws Exception - { - CompiereColor.setBackground(panel); - // - mainPanel.setLayout(mainLayout); - parameterPanel.setLayout(parameterLayout); - // - labelBankAccount.setText(Msg.translate(Env.getCtx(), "C_BankAccount_ID")); - fieldBankAccount.addActionListener(this); - labelBPartner.setText(Msg.translate(Env.getCtx(), "C_BPartner_ID")); - fieldBPartner.addActionListener(this); - bRefresh.addActionListener(this); - labelDtype.setText(Msg.translate(Env.getCtx(), "C_DocType_ID")); - fieldDtype.addActionListener(this); - labelPayDate.setText(Msg.translate(Env.getCtx(), "PayDate")); - labelPaymentRule.setText(Msg.translate(Env.getCtx(), "PaymentRule")); - fieldPaymentRule.addActionListener(this); - // - labelBankBalance.setText(Msg.translate(Env.getCtx(), "CurrentBalance")); - labelBalance.setText("0"); - onlyDue.setText(Msg.getMsg(Env.getCtx(), "OnlyDue")); - dataStatus.setText(" "); - // - bGenerate.addActionListener(this); - bCancel.addActionListener(this); - // - mainPanel.add(parameterPanel, BorderLayout.NORTH); - parameterPanel.add(labelBankAccount, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); - parameterPanel.add(fieldBankAccount, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5), 0, 0)); - - parameterPanel.add(labelBankBalance, new GridBagConstraints(2, 0, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); - parameterPanel.add(labelCurrency, new GridBagConstraints(4, 0, 1, 1, 0.0, 0.0 - ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(5, 0, 5, 5), 0, 0)); - - parameterPanel.add(labelBalance, new GridBagConstraints(3, 0, 1, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); - - parameterPanel.add(labelBPartner, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); - parameterPanel.add(fieldBPartner, new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5), 0, 0)); - - parameterPanel.add(labelDtype, new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); - parameterPanel.add(fieldDtype, new GridBagConstraints(1, 2, 1, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5), 0, 0)); - - parameterPanel.add(bRefresh, new GridBagConstraints(4, 3, 1, 1, 0.0, 0.0 - ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); - - parameterPanel.add(labelPayDate, new GridBagConstraints(0, 3, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); - parameterPanel.add(fieldPayDate, new GridBagConstraints(1, 3, 1, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5), 0, 0)); - - parameterPanel.add(labelPaymentRule, new GridBagConstraints(2, 3, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); - parameterPanel.add(fieldPaymentRule, new GridBagConstraints(3, 3, 1, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); - - parameterPanel.add(onlyDue, new GridBagConstraints(3, 1, 1, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); - mainPanel.add(dataStatus, BorderLayout.SOUTH); - mainPanel.add(dataPane, BorderLayout.CENTER); - dataPane.getViewport().add(miniTable, null); - // - commandPanel.setLayout(commandLayout); - commandLayout.setAlignment(FlowLayout.RIGHT); - commandLayout.setHgap(10); - commandPanel.add(bCancel, null); - commandPanel.add(bGenerate, null); - } // jbInit - - /** - * Dynamic Init. - * - Load Bank Info - * - Load BPartner - * - Load Document Type - * - Init Table - */ - private void dynInit() - { - ArrayList bankAccountData = getBankAccountData(); - for(BankInfo bi : bankAccountData) - fieldBankAccount.addItem(bi); - - if (fieldBankAccount.getItemCount() == 0) - ADialog.error(m_WindowNo, panel, "VPaySelectNoBank"); - else - fieldBankAccount.setSelectedIndex(0); - - ArrayList bpartnerData = getBPartnerData(); - for(KeyNamePair pp : bpartnerData) - fieldBPartner.addItem(pp); - fieldBPartner.setSelectedIndex(0); - - ArrayList docTypeData = getDocTypeData(); - for(KeyNamePair pp : docTypeData) - fieldDtype.addItem(pp); - - prepareTable(miniTable); - - miniTable.getModel().addTableModelListener(this); - // - fieldPayDate.setMandatory(true); - fieldPayDate.setValue(new Timestamp(System.currentTimeMillis())); - } // dynInit - - /** - * Load Bank Info - Load Info from Bank Account and valid Documents (PaymentRule) - */ - private void loadBankInfo() - { - BankInfo bi = (BankInfo)fieldBankAccount.getSelectedItem(); - if (bi == null) - return; - labelCurrency.setText(bi.Currency); - labelBalance.setText(m_format.format(bi.Balance)); - - // PaymentRule - fieldPaymentRule.removeAllItems(); - - ArrayList paymentRuleData = getPaymentRuleData(bi); - for(ValueNamePair vp : paymentRuleData) - fieldPaymentRule.addItem(vp); - fieldPaymentRule.setSelectedIndex(0); - } // loadBankInfo - - /** - * Query and create TableInfo - */ - private void loadTableInfo() - { - Timestamp payDate = (Timestamp)fieldPayDate.getValue(); - miniTable.setColorCompare(payDate); - if (log.isLoggable(Level.CONFIG)) log.config("PayDate=" + payDate); - - BankInfo bi = (BankInfo)fieldBankAccount.getSelectedItem(); - - ValueNamePair paymentRule = (ValueNamePair)fieldPaymentRule.getSelectedItem(); - KeyNamePair bpartner = (KeyNamePair)fieldBPartner.getSelectedItem(); - KeyNamePair docType = (KeyNamePair)fieldDtype.getSelectedItem(); - - loadTableInfo(bi, payDate, paymentRule, onlyDue.isSelected(), false, bpartner, docType, miniTable); - - calculateSelection(); - } // loadTableInfo - - /** - * Dispose - */ - public void dispose() - { - if (m_frame != null) - m_frame.dispose(); - m_frame = null; - } // dispose - - - /************************************************************************** - * ActionListener - * @param e event - */ - public void actionPerformed (ActionEvent e) - { - // Update Bank Info - if (e.getSource() == fieldBankAccount) - loadBankInfo(); - - // Generate PaySelection - else if (e.getSource() == bGenerate) - { - generatePaySelect(); - dispose(); - } - - else if (e.getSource() == bCancel) - dispose(); - - // Update Open Invoices - else if (e.getSource() == fieldBPartner || e.getSource() == bRefresh || e.getSource() == fieldDtype) - loadTableInfo(); - - } // actionPerformed - - /** - * Table Model Listener - * @param e event - */ - public void tableChanged(TableModelEvent e) - { - if (e.getColumn() == 0) - calculateSelection(); - } // valueChanged - - /** - * Calculate selected rows. - * - add up selected rows - */ - public void calculateSelection() - { - dataStatus.setText(calculateSelection(miniTable)); - // - bGenerate.setEnabled(m_noSelected != 0); - } // calculateSelection - - /** - * Generate PaySelection - */ - private void generatePaySelect() - { - miniTable.stopEditor(true); - if (miniTable.getRowCount() == 0) - return; - miniTable.setRowSelectionInterval(0,0); - calculateSelection(); - if (m_noSelected == 0) - return; - - String msg = generatePaySelect(miniTable, (ValueNamePair) fieldPaymentRule.getSelectedItem(), - fieldPayDate.getTimestamp(), (BankInfo)fieldBankAccount.getSelectedItem()); - - if(msg != null && msg.length() > 0) - { - ADialog.error(m_WindowNo, panel, "SaveError", msg); - return; - } - - // Ask to Post it - if (!ADialog.ask(m_WindowNo, panel, "VPaySelectGenerate?", "(" + m_ps.getName() + ")")) - return; - - // Prepare Process - int AD_Proces_ID = PROCESS_C_PAYSELECTION_CREATEPAYMENT; // C_PaySelection_CreatePayment - ProcessInfo pi = new ProcessInfo (m_frame.getTitle(), AD_Proces_ID, - X_C_PaySelection.Table_ID, m_ps.getC_PaySelection_ID()); - pi.setAD_User_ID (Env.getAD_User_ID(Env.getCtx())); - pi.setAD_Client_ID(Env.getAD_Client_ID(Env.getCtx())); - pi.setAD_Process_UU(new MProcess(Env.getCtx(), AD_Proces_ID, null).getAD_Process_UU()); - - ProcessParameterPanel pp = new ProcessParameterPanel(m_WindowNo, pi); - // Execute Process - ProcessCtl.process(this, m_WindowNo, (IProcessParameter) pp, pi, trx); - // ProcessCtl worker = new ProcessCtl(this, pi, trx); - // worker.start(); // complete tasks in unlockUI - } // generatePaySelect - - /** - * Lock User Interface - * Called from the Worker before processing - * @param pi process info - */ - public void lockUI (ProcessInfo pi) - { - panel.setEnabled(false); - m_isLocked = true; - } // lockUI - - /** - * Unlock User Interface. - * Called from the Worker when processing is done - * @param pi process info - */ - public void unlockUI (ProcessInfo pi) - { - // this.setEnabled(true); - // m_isLocked = false; - // Ask to Print it // Window is disposed - if (!ADialog.ask(0, panel, "VPaySelectPrint?", "(" + pi.getSummary() + ")")) - return; - - // Start PayPrint - int AD_Form_ID = FORM_PAYMENT_PRINT_EXPORT; // Payment Print/Export - FormFrame ff = new FormFrame(null); - ff.openForm (AD_Form_ID); - // Set Parameter - if (m_ps != null) - { - VPayPrint pp = (VPayPrint)ff.getFormPanel(); - pp.setPaySelection(m_ps.getC_PaySelection_ID()); - } - // - ff.pack(); - panel.setVisible(false); - AEnv.addToWindowManager(ff); - AEnv.showCenterScreen(ff); - this.dispose(); - } // unlockUI - - /** - * Is the UI locked (Internal method) - * @return true, if UI is locked - */ - public boolean isUILocked() - { - return m_isLocked; - } // isLoacked - - /** - * Method to be executed async. - * Called from the ASyncProcess worker - * @param pi process info - */ - public void executeASync (ProcessInfo pi) - { - log.config("-"); - } // executeASync - - @Override - public void statusUpdate(String message) { - dataStatus.setText(message); - } - - @Override - public void ask(String message, Callback callback) { - boolean b = ADialog.ask(m_WindowNo, null, message); - if (callback != null) { - callback.onCallback(b); - } - } - - @Override - public void download(File file) { - // TODO Auto-generated method stub - - } - - @Override - public void askForInput(String message, Callback callback) { - String s = ADialog.askForInput(m_WindowNo, null, message); - if(callback != null) - callback.onCallback(s); - } -} // VPaySelect diff --git a/org.adempiere.ui.swing/src/org/compiere/apps/form/VResetPassword.java b/org.adempiere.ui.swing/src/org/compiere/apps/form/VResetPassword.java deleted file mode 100644 index 2348e37059..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/apps/form/VResetPassword.java +++ /dev/null @@ -1,344 +0,0 @@ -package org.compiere.apps.form; - -import java.awt.BorderLayout; -import java.awt.GridBagConstraints; -import java.awt.GridBagLayout; -import java.awt.Insets; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.beans.PropertyChangeEvent; -import java.beans.PropertyVetoException; -import java.beans.VetoableChangeListener; -import java.util.logging.Level; - -import javax.swing.JPasswordField; -import javax.swing.JTextField; -import javax.swing.SwingConstants; - -import org.compiere.apps.ADialog; -import org.compiere.apps.ConfirmPanel; -import org.compiere.grid.ed.VLookup; -import org.compiere.model.MLookup; -import org.compiere.model.MLookupFactory; -import org.compiere.model.MSysConfig; -import org.compiere.model.MUser; -import org.compiere.swing.CLabel; -import org.compiere.swing.CPanel; -import org.compiere.util.CLogger; -import org.compiere.util.DisplayType; -import org.compiere.util.Env; -import org.compiere.util.Msg; -import org.compiere.util.Util; - -public class VResetPassword implements FormPanel, ActionListener, VetoableChangeListener { - - private static CLogger log = CLogger.getCLogger(VResetPassword.class); - - private FormFrame frame; - private CPanel mainPanel; - private ConfirmPanel confirmPanel; - - private CLabel lblUser; - private CLabel lblOldPassword; - private CLabel lblNewPassword; - private CLabel lblRetypeNewPassword; - private CLabel lblNewEMail; - private CLabel lblRetypeNewEMail; - private CLabel lblNewEMailUser; - private CLabel lblNewEMailUserPW; - - private VLookup fUser; - private JPasswordField txtOldPassword; - private JPasswordField txtNewPassword; - private JPasswordField txtRetypeNewPassword; - private JTextField txtNewEMail; - private JTextField txtRetypeNewEMail; - private JTextField txtNewEMailUser; - private JTextField txtNewEMailUserPW; - - public int windowNo = 0; - - @Override - public void init(int WindowNo, FormFrame frame) - { - this.windowNo = WindowNo; - this.frame = frame; - - try - { - dynInit(); - jbInit(); - - frame.getContentPane().add(mainPanel, BorderLayout.CENTER); - frame.getContentPane().add(confirmPanel, BorderLayout.SOUTH); - confirmPanel.addActionListener(this); - } - catch(Exception e) - { - log.log(Level.SEVERE, "init", e); - } - } - - private void jbInit() throws Exception - { - GridBagLayout panelLayout = new GridBagLayout(); - mainPanel.setLayout(panelLayout); - - mainPanel.add(lblUser, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(12, 12, 5, 5), 0, 0)); - mainPanel.add(fUser, new GridBagConstraints(1, 0, 1, 1, 1.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(12, 0, 5, 12), 0, 0)); - mainPanel.add(lblOldPassword, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(12, 12, 5, 5), 0, 0)); - mainPanel.add(txtOldPassword, new GridBagConstraints(1, 1, 1, 1, 1.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(12, 0, 5, 12), 0, 0)); - mainPanel.add(lblNewPassword, new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(12, 12, 5, 5), 0, 0)); - mainPanel.add(txtNewPassword, new GridBagConstraints(1, 2, 1, 1, 1.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(12, 0, 5, 12), 0, 0)); - mainPanel.add(lblRetypeNewPassword, new GridBagConstraints(0, 3, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(12, 12, 5, 5), 0, 0)); - mainPanel.add(txtRetypeNewPassword, new GridBagConstraints(1, 3, 1, 1, 1.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(12, 0, 5, 12), 0, 0)); - mainPanel.add(lblNewEMail, new GridBagConstraints(0, 4, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(12, 12, 5, 5), 0, 0)); - mainPanel.add(txtNewEMail, new GridBagConstraints(1, 4, 1, 1, 1.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(12, 0, 5, 12), 0, 0)); - mainPanel.add(lblRetypeNewEMail, new GridBagConstraints(0, 5, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(12, 12, 5, 5), 0, 0)); - mainPanel.add(txtRetypeNewEMail, new GridBagConstraints(1, 5, 1, 1, 1.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(12, 0, 5, 12), 0, 0)); - mainPanel.add(lblNewEMailUser, new GridBagConstraints(0, 6, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(12, 12, 5, 5), 0, 0)); - mainPanel.add(txtNewEMailUser, new GridBagConstraints(1, 6, 1, 1, 1.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(12, 0, 5, 12), 0, 0)); - mainPanel.add(lblNewEMailUserPW, new GridBagConstraints(0, 7, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(12, 12, 5, 5), 0, 0)); - mainPanel.add(txtNewEMailUserPW, new GridBagConstraints(1, 7, 1, 1, 1.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(12, 0, 5, 12), 0, 0)); - - fUser.addVetoableChangeListener(this); - } - - private void dynInit() - { - mainPanel = new CPanel(); - - // AD_User.AD_User_ID - MLookup userLkp = MLookupFactory.get (Env.getCtx(), windowNo, 0, 212, DisplayType.Search); - fUser = new VLookup("AD_User_ID", false, false, true, userLkp); - - txtOldPassword = new JPasswordField(); - txtOldPassword.setName("txtOldPassword"); - - txtNewPassword = new JPasswordField(); - txtNewPassword.setName("txtNewPassword"); - - txtRetypeNewPassword = new JPasswordField(); - txtRetypeNewPassword.setName("txtRetypeNewPassword"); - - txtNewEMail = new JTextField(); - txtNewEMail.setName("txtNewEMail"); - - txtRetypeNewEMail = new JTextField(); - txtRetypeNewEMail.setName("txtRetypeNewEMail"); - - txtNewEMailUser = new JTextField(); - txtNewEMailUser.setName("txtNewEMailUser"); - - txtNewEMailUserPW = new JTextField(); - txtNewEMailUserPW.setName("txtNewEMailUserPW"); - - lblUser = new CLabel(Msg.translate(Env.getCtx(), "AD_User_ID")); - lblUser.setRequestFocusEnabled(false); - lblUser.setLabelFor(fUser); - lblUser.setHorizontalAlignment(SwingConstants.RIGHT); - - lblOldPassword = new CLabel(Msg.getMsg(Env.getCtx(), "Old Password")); - lblOldPassword.setRequestFocusEnabled(false); - lblOldPassword.setLabelFor(txtOldPassword); - lblOldPassword.setHorizontalAlignment(SwingConstants.RIGHT); - - lblNewPassword = new CLabel(Msg.getMsg(Env.getCtx(), "New Password")); - lblNewPassword.setRequestFocusEnabled(false); - lblNewPassword.setLabelFor(txtNewPassword); - lblNewPassword.setHorizontalAlignment(SwingConstants.RIGHT); - - lblRetypeNewPassword = new CLabel(Msg.getMsg(Env.getCtx(), "New Password Confirm")); - lblRetypeNewPassword.setRequestFocusEnabled(false); - lblRetypeNewPassword.setLabelFor(txtRetypeNewPassword); - lblRetypeNewPassword.setHorizontalAlignment(SwingConstants.RIGHT); - - lblNewEMail = new CLabel(Msg.getMsg(Env.getCtx(), "New EMail")); - lblNewEMail.setRequestFocusEnabled(false); - lblNewEMail.setLabelFor(txtNewEMail); - lblNewEMail.setHorizontalAlignment(SwingConstants.RIGHT); - - lblRetypeNewEMail = new CLabel(Msg.getMsg(Env.getCtx(), "New EMail Confirm")); - lblRetypeNewEMail.setRequestFocusEnabled(false); - lblRetypeNewEMail.setLabelFor(txtRetypeNewEMail); - lblRetypeNewEMail.setHorizontalAlignment(SwingConstants.RIGHT); - - lblNewEMailUser = new CLabel(Msg.getMsg(Env.getCtx(), "New EMail User")); - lblNewEMailUser.setRequestFocusEnabled(false); - lblNewEMailUser.setLabelFor(txtNewEMailUser); - lblNewEMailUser.setHorizontalAlignment(SwingConstants.RIGHT); - - lblNewEMailUserPW = new CLabel(Msg.getMsg(Env.getCtx(), "New EMail User Password")); - lblNewEMailUserPW.setRequestFocusEnabled(false); - lblNewEMailUserPW.setLabelFor(txtNewEMailUserPW); - lblNewEMailUserPW.setHorizontalAlignment(SwingConstants.RIGHT); - - confirmPanel = new ConfirmPanel(); - } - - @Override - public void vetoableChange(PropertyChangeEvent e) throws PropertyVetoException - { - if (log.isLoggable(Level.INFO)) log.info(e.getPropertyName() + "=" + e.getNewValue()); - if (e.getPropertyName().equals("AD_User_ID")) - fUser.setValue(e.getNewValue()); - } - - @Override - public void actionPerformed(ActionEvent e) - { - if (e.getActionCommand().equals(ConfirmPanel.A_CANCEL)) - { - dispose(); - return; - } - else if (e.getActionCommand().equals(ConfirmPanel.A_OK)) - { - validateChangePassword(); - } - } - - private void validateChangePassword() - { - int p_AD_User_ID = -1; - if (fUser.getValue() != null) - p_AD_User_ID = Integer.parseInt(fUser.getValue().toString()); - if (p_AD_User_ID < 0) - { - ADialog.error(windowNo, frame, "UserMandatory"); - return; - } - - String p_OldPassword = new String(txtOldPassword.getPassword()); - String p_NewPassword = new String(txtNewPassword.getPassword()); - String p_NewPasswordConfirm = new String(txtRetypeNewPassword.getPassword()); - String p_NewEMail = txtNewEMail.getText(); - String p_NewEMailConfirm = txtRetypeNewEMail.getText(); - String p_NewEMailUser = txtNewEMailUser.getText(); - String p_NewEMailUserPW = txtNewEMailUserPW.getText(); - - MUser user = MUser.get(Env.getCtx(), p_AD_User_ID); - if (log.isLoggable(Level.FINE)) log.fine("User=" + user); - - // Do we need a password ? - if (Util.isEmpty(p_OldPassword)) // Password required - { - MUser operator = MUser.get(Env.getCtx(), Env.getAD_User_ID(Env.getCtx())); - if (log.isLoggable(Level.FINE)) log.fine("Operator=" + operator); - - if (p_AD_User_ID == 0 // change of System - || p_AD_User_ID == 100 // change of SuperUser - || !operator.isAdministrator()) - { - ADialog.error(windowNo, frame, "OldPasswordMandatory"); - return; - } - } else { - // is entered Password correct ? - boolean hash_password = MSysConfig.getBooleanValue(MSysConfig.USER_PASSWORD_HASH, false); - if (hash_password) { - if (!user.authenticateHash(p_OldPassword)) - { - ADialog.error(windowNo, frame, "OldPasswordNoMatch"); - return; - } - } else { - if (!p_OldPassword.equals(user.getPassword())) - { - ADialog.error(windowNo, frame, "OldPasswordNoMatch"); - return; - } - } - if (MSysConfig.getBooleanValue(MSysConfig.CHANGE_PASSWORD_MUST_DIFFER, true)) - { - if (p_OldPassword.equals(p_NewPassword)) { - ADialog.error(windowNo, frame, "NewPasswordMustDiffer"); - return; - } - } - } - - // new password confirm -// if (!Util.isEmpty(p_NewPassword)) { - if (Util.isEmpty(p_NewPasswordConfirm)) { - ADialog.error(windowNo, frame, "NewPasswordConfirmMandatory"); - return; - } else { - if (!p_NewPassword.equals(p_NewPasswordConfirm)) { - ADialog.error(windowNo, frame, "PasswordNotMatch"); - return; - } - } -// } - - if (!Util.isEmpty(p_NewEMailUserPW)) { - if (Util.isEmpty(p_NewEMailConfirm)) { - ADialog.error(windowNo, frame, "NewEmailConfirmMandatory"); - return; - } else { - if (!p_NewEMailUserPW.equals(p_NewEMailConfirm)) { - ADialog.error(windowNo, frame, "NewEmailNotMatch"); - return; - } - } - } - - if (!Util.isEmpty(p_NewPassword)) - user.set_ValueOfColumn("Password", p_NewPassword); // will be hashed and validate on saveEx - if (!Util.isEmpty(p_NewEMail)) - user.setEMail(p_NewEMail); - if (!Util.isEmpty(p_NewEMailUser)) - user.setEMailUser(p_NewEMailUser); - if (!Util.isEmpty(p_NewEMailUserPW)) - user.setEMailUserPW(p_NewEMailUserPW); - - try { - user.saveEx(); - } - catch(Exception e) - { - ADialog.error(windowNo, frame, e.getLocalizedMessage()); - user.load(user.get_TrxName()); - return; - } - clearForm(); - ADialog.info(windowNo, frame, "RecordSaved"); - return; - } - - private void clearForm() - { - fUser.setValue(null); - txtOldPassword.setText(null); - txtNewPassword.setText(null); - txtRetypeNewPassword.setText(null); - txtNewEMail.setText(null); - txtRetypeNewEMail.setText(null); - txtNewEMailUser.setText(null); - txtNewEMailUserPW.setText(null); - } - - @Override - public void dispose() - { - if (frame != null) - frame.dispose(); - frame = null; - } -} \ No newline at end of file diff --git a/org.adempiere.ui.swing/src/org/compiere/apps/form/VSQLProcess.java b/org.adempiere.ui.swing/src/org/compiere/apps/form/VSQLProcess.java deleted file mode 100644 index 9d299c35ef..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/apps/form/VSQLProcess.java +++ /dev/null @@ -1,255 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ -package org.compiere.apps.form; - -import java.awt.BorderLayout; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.sql.Connection; -import java.sql.SQLException; -import java.sql.Statement; -import java.util.StringTokenizer; -import java.util.logging.Level; - -import org.compiere.apps.ConfirmPanel; -import org.compiere.grid.ed.VText; -import org.compiere.swing.CButton; -import org.compiere.swing.CLabel; -import org.compiere.swing.CPanel; -import org.compiere.swing.CTextArea; -import org.compiere.util.CLogger; -import org.compiere.util.DB; -import org.compiere.util.Env; - -/** - * Process SQL Commands - * - * @author Jorg Janke - * @version $Id: VSQLProcess.java,v 1.2 2006/07/30 00:51:28 jjanke Exp $ - */ -public class VSQLProcess extends CPanel - implements FormPanel, ActionListener -{ - /** - * - */ - private static final long serialVersionUID = -8445688937366388495L; - - /** - * Initialize Panel - * @param WindowNo window - * @param frame frame - */ - public void init (int WindowNo, FormFrame frame) - { - log.info( "VSQLProcess.init"); - m_WindowNo = WindowNo; - m_frame = frame; - try - { - jbInit(); - frame.getContentPane().add(this, BorderLayout.CENTER); - // frame.getContentPane().add(confirmPanel, BorderLayout.SOUTH); - } - catch(Exception e) - { - log.log(Level.SEVERE, "VSQLProcess.init", e); - } - } // init - - /** - * Dispose - Free Resources - */ - public void dispose() - { - if (m_frame != null) - m_frame.dispose(); - m_frame = null; - } // dispose - - /** Window No */ - @SuppressWarnings("unused") - private int m_WindowNo = 0; - /** FormFrame */ - private FormFrame m_frame; - - /** Log */ - private static CLogger log = CLogger.getCLogger(VSQLProcess.class); - - /** DML Statement */ - private static final String[] DML_KEYWORDS = new String[]{ - "SELECT", "UPDATE", "DELETE", "TRUNCATE" - }; - - private BorderLayout mainLayout = new BorderLayout(); - private CPanel northPanel = new CPanel(); - private CLabel sqlLabel = new CLabel("SQL"); - private VText sqlField = new VText("SQL", false, false, true, 3000, 9000); - private CPanel centerPanel = new CPanel(); - private BorderLayout centerLayout = new BorderLayout(); - private BorderLayout northLayout = new BorderLayout(); - private CTextArea resultField = new CTextArea(20,60); - private CButton sqlButton = ConfirmPanel.createProcessButton(true); - - /** - * Static Init - * @throws Exception - */ - void jbInit() throws Exception - { - this.setLayout(mainLayout); - mainLayout.setHgap(5); - mainLayout.setVgap(5); - // - this.add(northPanel, BorderLayout.NORTH); - northLayout.setHgap(5); - northLayout.setVgap(5); - northPanel.setLayout(northLayout); - sqlLabel.setText("SQL"); - northPanel.add(sqlLabel, BorderLayout.WEST); - // - northPanel.add(sqlField, BorderLayout.CENTER); - sqlButton.addActionListener(this); - northPanel.add(sqlButton, BorderLayout.EAST); - // - this.add(centerPanel, BorderLayout.CENTER); - centerPanel.setLayout(centerLayout); - centerLayout.setHgap(0); - resultField.setReadWrite(false); - centerPanel.add(resultField, BorderLayout.CENTER); - } // jbInit - - /** - * Action Listener - * @param e event - */ - public void actionPerformed(ActionEvent e) - { - resultField.setText(processStatements (sqlField.getText(), false)); - } // actionedPerformed - - /** - * Process SQL Statements - * @param sqlStatements one or more statements separated by ; - * @param allowDML allow DML statements - * @return result - */ - public static String processStatements (String sqlStatements, boolean allowDML) - { - if (sqlStatements == null || sqlStatements.length() == 0) - return ""; - StringBuilder result = new StringBuilder(); - // - StringTokenizer st = new StringTokenizer(sqlStatements, ";", false); - while (st.hasMoreTokens()) - { - result.append(processStatement(st.nextToken(), allowDML)); - result.append(Env.NL); - } - // - return result.toString(); - } // processStatements - - /** - * Process SQL Statements - * @param sqlStatement one statement - * @param allowDML allow DML statements - * @return result - */ - public static String processStatement (String sqlStatement, boolean allowDML) - { - if (sqlStatement == null) - return ""; - StringBuilder sb = new StringBuilder(); - char[] chars = sqlStatement.toCharArray(); - for (int i = 0; i < chars.length; i++) - { - char c = chars[i]; - if (Character.isWhitespace(c)) - sb.append(' '); - else - sb.append(c); - } - String sql = sb.toString().trim(); - if (sql.length() == 0) - return ""; - // - StringBuffer result = new StringBuffer("SQL> ") - .append(sql) - .append(Env.NL); - if (!allowDML) - { - boolean error = false; - String SQL = sql.toUpperCase(); - for (int i = 0; i < DML_KEYWORDS.length; i++) - { - if (SQL.startsWith(DML_KEYWORDS[i] + " ") - || SQL.indexOf(" " + DML_KEYWORDS[i] + " ") != -1 - || SQL.indexOf("(" + DML_KEYWORDS[i] + " ") != -1) - { - result.append("===> ERROR: Not Allowed Keyword ") - .append(DML_KEYWORDS[i]) - .append(Env.NL); - error = true; - } - } - if (error) - return result.toString(); - } // !allowDML - - // Process - Connection conn = DB.createConnection(true, Connection.TRANSACTION_READ_COMMITTED); - Statement stmt = null; - try - { - stmt = conn.createStatement(); - @SuppressWarnings("unused") - boolean OK = stmt.execute(sql); - int count = stmt.getUpdateCount(); - if (count == -1) - { - result.append("---> ResultSet"); - } - else - result.append("---> Result=").append(count); - } - catch (SQLException e) - { - log.log(Level.SEVERE, "process statement: " + sql + " - " + e.toString()); - result.append("===> ").append(e.toString()); - } - finally - { - DB.close(stmt); - stmt = null; - try - { - conn.close(); - } - catch (SQLException e2) - { - log.log(Level.SEVERE, "processStatement - close connection", e2); - } - conn = null; - } - - // - result.append(Env.NL); - return result.toString(); - } // processStatement - -} // VSQLProcess diff --git a/org.adempiere.ui.swing/src/org/compiere/apps/form/VSetup.java b/org.adempiere.ui.swing/src/org/compiere/apps/form/VSetup.java deleted file mode 100644 index b7f0c7c56d..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/apps/form/VSetup.java +++ /dev/null @@ -1,508 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ -package org.compiere.apps.form; - -import java.awt.BorderLayout; -import java.awt.GridBagConstraints; -import java.awt.GridBagLayout; -import java.awt.Insets; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.io.File; -import java.sql.ResultSet; -import java.sql.SQLException; -import java.sql.Statement; -import java.util.Currency; -import java.util.Locale; -import java.util.logging.Level; - -import javax.swing.JButton; -import javax.swing.JCheckBox; -import javax.swing.JComboBox; -import javax.swing.JFileChooser; -import javax.swing.JLabel; -import javax.swing.JScrollPane; -import javax.swing.JTextField; - -import org.adempiere.plaf.AdempierePLAF; -import org.compiere.apps.ADialog; -import org.compiere.apps.ConfirmPanel; -import org.compiere.model.MSetup; -import org.compiere.plaf.CompiereColor; -import org.compiere.print.PrintUtil; -import org.compiere.swing.CPanel; -import org.compiere.util.CLogger; -import org.compiere.util.DB; -import org.compiere.util.Env; -import org.compiere.util.ExtensionFileFilter; -import org.compiere.util.KeyNamePair; -import org.compiere.util.Msg; - -/** - * Setup System - * - * @author Jorg Janke - * @version $Id: VSetup.java,v 1.2 2006/07/30 00:51:28 jjanke Exp $ - * @deprecated - */ -public class VSetup extends CPanel - implements FormPanel, ActionListener, Runnable -{ - /** - * - */ - private static final long serialVersionUID = 3255776374935155456L; - - /** - * Initialize Panel - * @param WindowNo window - * @param frame frame - */ - public void init (int WindowNo, FormFrame frame) - { - log.info( "VSetup.init"); - m_WindowNo = WindowNo; - m_frame = frame; - try - { - jbInit(); - dynInit(); - frame.getContentPane().add(centerPane, BorderLayout.CENTER); - frame.getContentPane().add(confirmPanel, BorderLayout.SOUTH); - } - catch(Exception e) - { - log.log(Level.SEVERE, "VSetup.init", e); - } - } // init - - /** Window No */ - private int m_WindowNo = 0; - /** FormFrame */ - private FormFrame m_frame; - - /* Natural Account file */ - private File m_file = null; - /** Logger */ - private static CLogger log = CLogger.getCLogger(VSetup.class); - - // - private JScrollPane centerPane = new JScrollPane(); - private ConfirmPanel confirmPanel = new ConfirmPanel(true); - private CPanel centerPanel = new CPanel(); - private GridBagLayout centerLayout = new GridBagLayout(); - private JLabel lClientName = new JLabel(); - private JTextField fClientName = new JTextField(); - private JLabel lOrgName = new JLabel(); - private JTextField fOrgName = new JTextField(); - private JTextField fOrgValue = new JTextField(); - private JLabel lCurrency = new JLabel(); - private JComboBox fCurrency = new JComboBox(); - private JLabel lUserClient = new JLabel(); - private JTextField fUserClient = new JTextField(); - private JLabel lUserOrg = new JLabel(); - private JTextField fUserOrg = new JTextField(); - private JCheckBox fProject = new JCheckBox(); - private JCheckBox fProduct = new JCheckBox(); - private JCheckBox fBPartner = new JCheckBox(); - private JLabel lAccountSeg = new JLabel(); - private JCheckBox fMCampaign = new JCheckBox(); - private JCheckBox fSRegion = new JCheckBox(); - private JButton buttonLoadAcct = new JButton(); - private JLabel lCountry = new JLabel(); - private JLabel lCity = new JLabel(); - private JComboBox fCountry = new JComboBox(); - private JTextField fCity = new JTextField(); - private JLabel lRegion = new JLabel(); - private JComboBox fRegion = new JComboBox(); - - /** - * Static Init - * @throws Exception - */ - private void jbInit() throws Exception - { - CompiereColor.setBackground(this); - centerPanel.setLayout(centerLayout); - String optional = Msg.translate(Env.getCtx(), "Optional"); - // - lClientName.setLabelFor(fClientName); - lClientName.setText(Msg.translate(Env.getCtx(), "AD_Client_ID")); - // lClientName.setToolTipText(""); - fClientName.setText("client"); - fClientName.setColumns(20); - // - lOrgName.setLabelFor(fOrgName); - lOrgName.setText(Msg.translate(Env.getCtx(), "AD_Org_ID")); - fOrgName.setText("org"); - fOrgName.setColumns(20); - // - lCurrency.setLabelFor(fCurrency); - lCurrency.setText(Msg.translate(Env.getCtx(), "C_Currency_ID")); - // lCurrency.setToolTipText(""); - // - lUserClient.setLabelFor(fUserClient); - lUserClient.setText(Msg.parseTranslation(Env.getCtx(), "@AD_User_ID@ @AD_Client_ID@")); - // lUserClient.setToolTipText("User name for client level access"); - fUserClient.setText("clientAdmin"); - fUserClient.setColumns(20); - // - lUserOrg.setLabelFor(fUserOrg); - lUserOrg.setText(Msg.parseTranslation(Env.getCtx(), "@AD_User_ID@ @AD_Org_ID@")); - // lUserOrg.setToolTipText(""); - fUserOrg.setText("clientUser"); - fUserOrg.setColumns(20); - // - lCountry.setLabelFor(fCountry); - lCountry.setText(Msg.translate(Env.getCtx(), "C_Country_ID")); - lCity.setLabelFor(fCity); - lCity.setText(Msg.translate(Env.getCtx(), "C_City_ID")); - fCity.setText("city"); - fCity.setColumns(20); - lRegion.setLabelFor(fRegion); - lRegion.setText(Msg.translate(Env.getCtx(), "C_Region_ID")); - lRegion.setToolTipText(optional); - // - lAccountSeg.setText(optional); - fBPartner.setSelected(true); - fBPartner.setText(Msg.translate(Env.getCtx(), "C_BPartner_ID")); - fProduct.setSelected(true); - fProduct.setText(Msg.translate(Env.getCtx(), "M_Product_ID")); - fProject.setText(Msg.translate(Env.getCtx(), "C_Project_ID")); - fMCampaign.setText(Msg.translate(Env.getCtx(), "C_Campaign_ID")); - fSRegion.setText(Msg.translate(Env.getCtx(), "C_SalesRegion_ID")); - // - buttonLoadAcct.setText(Msg.getMsg(Env.getCtx(), "LoadAccountingValues")); - - centerPane.getViewport().add(centerPanel, null); - centerPanel.add(lClientName, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); - centerPanel.add(fClientName, new GridBagConstraints(1, 0, 4, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 0, 5, 5), 0, 0)); - centerPanel.add(lOrgName, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 5, 5, 5), 0, 0)); - centerPanel.add(fOrgName, new GridBagConstraints(1, 1, 4, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 5, 5), 0, 0)); - centerPanel.add(lUserClient, new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 5, 5, 5), 0, 0)); - centerPanel.add(fUserClient, new GridBagConstraints(1, 2, 4, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 5, 5), 0, 0)); - centerPanel.add(lUserOrg, new GridBagConstraints(0, 3, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 5, 5, 5), 0, 0)); - centerPanel.add(fUserOrg, new GridBagConstraints(1, 3, 2, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 5, 5), 0, 0)); - centerPanel.add(lAccountSeg, new GridBagConstraints(0, 8, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 5, 5, 5), 0, 0)); - centerPanel.add(fProject, new GridBagConstraints(1, 9, 3, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 5, 5), 0, 0)); - centerPanel.add(fBPartner, new GridBagConstraints(1, 8, 1, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 5, 5), 0, 0)); - centerPanel.add(fMCampaign, new GridBagConstraints(1, 10, 1, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 5, 5), 0, 0)); - centerPanel.add(fCurrency, new GridBagConstraints(1, 4, 2, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 5, 5), 0, 0)); - centerPanel.add(lCurrency, new GridBagConstraints(0, 4, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 5, 5, 5), 0, 0)); - centerPanel.add(buttonLoadAcct, new GridBagConstraints(1, 11, 2, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 0, 5, 5), 0, 0)); - centerPanel.add(lCountry, new GridBagConstraints(0, 5, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 5, 5, 5), 0, 0)); - centerPanel.add(lCity, new GridBagConstraints(0, 6, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 5, 5, 5), 0, 0)); - centerPanel.add(fCountry, new GridBagConstraints(1, 5, 3, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 5, 5), 0, 0)); - centerPanel.add(fCity, new GridBagConstraints(1, 6, 3, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 5, 5), 0, 0)); - centerPanel.add(fProduct, new GridBagConstraints(2, 8, 1, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 5, 0), 0, 0)); - centerPanel.add(fSRegion, new GridBagConstraints(2, 10, 1, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 5, 5), 0, 0)); - centerPanel.add(lRegion, new GridBagConstraints(0, 7, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 5, 5, 5), 0, 0)); - centerPanel.add(fRegion, new GridBagConstraints(1, 7, 2, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 5, 5), 0, 0)); - } // jbInit - - /** - * Dynamic Init - */ - private void dynInit() - { - // Using current locale for default values - teo_sarca [ 1691388 ] - Locale locale = Locale.getDefault(); - Currency currency = Currency.getInstance(locale); - // Currency - String sql = "SELECT C_Currency_ID, Description, ISO_Code FROM C_Currency ORDER BY 2"; // teo_sarca [ 1691388 ] - Statement stmt = null; - ResultSet rs = null; - try - { - stmt = DB.createStatement(); - rs = stmt.executeQuery(sql); - while (rs.next()) { - fCurrency.addItem(new KeyNamePair(rs.getInt(1) , rs.getString(2))); - // Currency from locale will be the default currency - teo_sarca [ 1691388 ] - if (currency != null && currency.getCurrencyCode().equals(rs.getString(3))) - fCurrency.setSelectedIndex(fCurrency.getItemCount() - 1); - } - } - catch (SQLException e1) - { - log.log(Level.SEVERE, "VSetup.dynInit -currency", e1); - } - finally - { - DB.close(rs, stmt); - rs = null; stmt = null; - } - - // Country - int C_Country_ID = 0; - sql = "SELECT C_Country_ID, Name, CountryCode FROM C_Country ORDER BY 2"; // teo_sarca [ 1691388 ] - try - { - stmt = DB.createStatement(); - rs = stmt.executeQuery(sql); - while (rs.next()) { - fCountry.addItem(new KeyNamePair(rs.getInt(1) , rs.getString(2))); - // Country from locale will be the default country - teo_sarca [ 1691388 ] - if (locale.getCountry().equals(rs.getString(3))) { - fCountry.setSelectedIndex(fCountry.getItemCount() - 1); - C_Country_ID = rs.getInt(1); - } - } - } - catch (SQLException e1) - { - log.log(Level.SEVERE, "VSetup.dynInit -country", e1); - } - finally - { - DB.close(rs, stmt); - rs = null; stmt = null; - } - - // Region (optional) - sql = "SELECT C_Region_ID, Name, C_Country_ID FROM C_Region ORDER BY C_Country_ID, Name"; - boolean isSelected = false; - try - { - fRegion.addItem(new KeyNamePair(0, " ")); - stmt = DB.createStatement(); - rs = stmt.executeQuery(sql); - while (rs.next()) { - fRegion.addItem(new KeyNamePair(rs.getInt(1) , rs.getString(2))); - // First region for selected country will be the default - teo_sarca [ 1691388 ] - if (!isSelected && rs.getInt(3) == C_Country_ID) { - fRegion.setSelectedIndex(fRegion.getItemCount() - 1); - isSelected = true; - } - } - } - catch (SQLException e1) - { - log.log(Level.SEVERE, "VSetup.dynInit -region", e1); - } - finally - { - DB.close(rs, stmt); - rs = null; stmt = null; - } - - // General Listeners - confirmPanel.addActionListener(this); - buttonLoadAcct.addActionListener(this); - confirmPanel.getOKButton().setEnabled(false); - } // dynInit - - /** - * Dispose - */ - public void dispose() - { - if (m_frame != null) - m_frame.dispose(); - m_frame = null; - } // dispose - - /** - * ActionListener - * @param e event - */ - public void actionPerformed (ActionEvent e) - { - // load file - if (e.getSource().equals(buttonLoadAcct)) - m_file = getFile(); - // OK - else if (e.getActionCommand().equals(ConfirmPanel.A_OK) && m_file != null) - { - confirmPanel.getCancelButton().setEnabled(false); - confirmPanel.getOKButton().setEnabled(false); - if (createSetup()) - m_frame.startBatch(this); - else - { - confirmPanel.getCancelButton().setEnabled(true); - confirmPanel.getOKButton().setEnabled(true); - } - } - // Cancel - else if (e.getActionCommand().equals(ConfirmPanel.A_CANCEL)) - dispose(); - } // actionPerformed - - /** - * Get File for CoA - * @return File - */ - private File getFile() - { - File file = null; - String dirName = org.compiere.Adempiere.getAdempiereHome() + File.separator + "data" + File.separator + "import"; - log.config(dirName); - JFileChooser chooser = new JFileChooser(dirName); - chooser.setFileSelectionMode(JFileChooser.FILES_ONLY); - chooser.setMultiSelectionEnabled(false); - chooser.setDialogTitle(Msg.translate(Env.getCtx(), "LoadAccountingValues")); - chooser.addChoosableFileFilter(new ExtensionFileFilter("csv", Msg.getMsg(Env.getCtx(), "FileCSV"))); - // Try selecting file - file = new File(dirName + File.pathSeparator + "AccountingUS.csv"); - if (file.exists()) - chooser.setSelectedFile(file); - - // Show it - if (chooser.showOpenDialog(this.getParent()) == JFileChooser.APPROVE_OPTION) - file = chooser.getSelectedFile(); - else - file = null; - chooser = null; - - if (file == null) - buttonLoadAcct.setText(Msg.translate(Env.getCtx(), "LoadAccountingValues")); - else - buttonLoadAcct.setText(file.getAbsolutePath()); - confirmPanel.getOKButton().setEnabled(file != null); - m_frame.pack(); - return file; - } // getFile - - - /************************************************************************** - * Create Setup - * @return true if created - */ - private boolean createSetup() - { - // Change critical characters ' => " \ => / - fClientName.setText(fClientName.getText().replace('\'','"')); - fClientName.setText(fClientName.getText().replace('\\','/')); - fOrgName.setText(fOrgName.getText().replace('\'','"')); - fOrgName.setText(fOrgName.getText().replace('\\','/')); - fUserClient.setText(fUserClient.getText().replace('\'','"')); - fUserClient.setText(fUserClient.getText().replace('\\','/')); - fUserOrg.setText(fUserOrg.getText().replace('\'','"')); - fUserOrg.setText(fUserOrg.getText().replace('\\','/')); - - // Unique Client Name - String SQL = "UPDATE AD_CLient SET CreatedBy=0 WHERE Name='" + fClientName.getText() + "'"; - if (DB.executeUpdate(SQL, null) != 0) - { - fClientName.setBackground(AdempierePLAF.getFieldBackground_Error()); - ADialog.error(m_WindowNo, this, "NotUnique", lClientName.getText()); - fClientName.requestFocus(); - return false; - } - fClientName.setBackground(AdempierePLAF.getFieldBackground_Normal()); - -/** - // Unique Org Name - SQL = "UPDATE AD_Org SET CreatedBy=0 WHERE Value='" + fOrgName.getText() + "'"; - if (DB.executeUpdate(SQL) != 0) - { - fOrgName.setBackground(AdempierePLAF.getFieldBackground_Error()); - ADialog.error(m_WindowNo, this, "NotUnique", lOrgName.getText()); - return false; - } - fOrgName.setBackground(AdempierePLAF.getFieldBackground_Normal()); -**/ - - // Unique User Name - SQL = "UPDATE AD_User SET CreatedBy=0 WHERE Name='" + fUserClient.getText() + "'"; - if (DB.executeUpdate(SQL, null) != 0) - { - fUserClient.setBackground(AdempierePLAF.getFieldBackground_Error()); - ADialog.error(m_WindowNo, this, "NotUnique", lUserClient.getText()); - fUserClient.requestFocus(); - return false; - } - fUserClient.setBackground(AdempierePLAF.getFieldBackground_Normal()); - SQL = "UPDATE AD_User SET CreatedBy=0 WHERE Name='" + fUserOrg.getText() + "'"; - if (DB.executeUpdate(SQL, null) != 0 || fUserClient.getText().equals(fUserOrg.getText())) - { - fUserOrg.setBackground(AdempierePLAF.getFieldBackground_Error()); - ADialog.error(m_WindowNo, this, "NotUnique", lUserOrg.getText()); - fUserOrg.requestFocus(); - return false; - } - fUserOrg.setBackground(AdempierePLAF.getFieldBackground_Normal()); - - return true; - } // createSetup - - /** - * Create Setup Batch Part. - * if done - disposes window - */ - public void run() - { - MSetup ms = new MSetup(Env.getCtx(), m_WindowNo); - m_frame.setBusyTimer(45); - // Step 1 - boolean ok = ms.createClient(fClientName.getText(), fOrgValue.getText(), fOrgName.getText(), - fUserClient.getText(), fUserOrg.getText(), null, null, null, null, null, null, null, true); // this form is not used - String info = ms.getInfo(); - - if (ok) - { - // Generate Accounting - KeyNamePair currency = (KeyNamePair)fCurrency.getSelectedItem(); - if (!ms.createAccounting(currency, - fProduct.isSelected(), fBPartner.isSelected(), fProject.isSelected(), - fMCampaign.isSelected(), fSRegion.isSelected(), - m_file)) - { - ADialog.error(m_WindowNo, this, "AccountSetupError"); - dispose(); - } else { - // Generate Entities - KeyNamePair p = (KeyNamePair)fCountry.getSelectedItem(); - int C_Country_ID = p.getKey(); - p = (KeyNamePair)fRegion.getSelectedItem(); - int C_Region_ID = p.getKey(); - ms.createEntities(C_Country_ID, fCity.getText(), C_Region_ID, currency.getKey(), null, null); - info += ms.getInfo(); - // Create Print Documents - PrintUtil.setupPrintForm(ms.getAD_Client_ID()); - } - } - - ADialog.info(m_WindowNo, this, "VSetup", info); - dispose(); - } // run - -} // VSetup diff --git a/org.adempiere.ui.swing/src/org/compiere/apps/form/VStatementCreateFromBatch.java b/org.adempiere.ui.swing/src/org/compiere/apps/form/VStatementCreateFromBatch.java deleted file mode 100644 index 5eb8579999..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/apps/form/VStatementCreateFromBatch.java +++ /dev/null @@ -1,324 +0,0 @@ -/****************************************************************************** - * Copyright (C) 2013 Elaine Tan * - * Copyright (C) 2013 Trek Global - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - *****************************************************************************/ -package org.compiere.apps.form; - -import static org.compiere.model.SystemIDs.COLUMN_C_BANKSTATEMENT_C_BANKACCOUNT_ID; - -import java.awt.BorderLayout; -import java.awt.Cursor; -import java.awt.GridBagConstraints; -import java.awt.GridBagLayout; -import java.awt.Insets; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.sql.Timestamp; -import java.util.Vector; -import java.util.logging.Level; - -import javax.swing.JLabel; -import javax.swing.table.DefaultTableModel; - -import org.compiere.apps.ADialog; -import org.compiere.apps.ConfirmPanel; -import org.compiere.grid.ed.VDate; -import org.compiere.grid.ed.VLookup; -import org.compiere.grid.ed.VNumber; -import org.compiere.grid.ed.VString; -import org.compiere.model.MBankStatement; -import org.compiere.model.MColumn; -import org.compiere.model.MLookup; -import org.compiere.model.MLookupFactory; -import org.compiere.model.MPayment; -import org.compiere.swing.CButton; -import org.compiere.swing.CLabel; -import org.compiere.swing.CPanel; -import org.compiere.swing.CTextField; -import org.compiere.util.CLogger; -import org.compiere.util.DisplayType; -import org.compiere.util.Env; -import org.compiere.util.Msg; - -/** - * - * @author Elaine - * - */ -public class VStatementCreateFromBatch extends StatementCreateFromBatch implements ActionListener, FormPanel -{ - private VCreateFromForm form; - private FormFrame m_frame; - - public void init (int WindowNo, FormFrame frame) - { - form = new VCreateFromForm(this, frame); - p_WindowNo = frame.getGridTab().getWindowNo();; - m_frame = frame; - initForm(); - } - - @Override - public void initForm() - { - try - { - if (!dynInit()) - return; - jbInit(); - } - catch(Exception e) - { - log.log(Level.SEVERE, "init", e); - } - } - - /** Window No */ - private int p_WindowNo; - - /** Logger */ - private CLogger log = CLogger.getCLogger(getClass()); - - private JLabel bankAccountLabel = new JLabel(); - protected VLookup bankAccountField; - - private CLabel documentNoLabel = new CLabel(Msg.translate(Env.getCtx(), "DocumentNo")); - protected CTextField documentNoField = new CTextField(10); - - private JLabel documentTypeLabel = new JLabel(); - protected VLookup documentTypeField; - - private JLabel authorizationLabel = new JLabel(); - protected VString authorizationField = new VString(); - - private JLabel tenderTypeLabel = new JLabel(); - protected VLookup tenderTypeField; - - private CLabel amtFromLabel = new CLabel(Msg.translate(Env.getCtx(), "PayAmt")); - protected VNumber amtFromField = new VNumber("AmtFrom", false, false, true, DisplayType.Amount, Msg.translate(Env.getCtx(), "AmtFrom")); - private CLabel amtToLabel = new CLabel("-"); - protected VNumber amtToField = new VNumber("AmtTo", false, false, true, DisplayType.Amount, Msg.translate(Env.getCtx(), "AmtTo")); - - protected CLabel BPartner_idLabel = new CLabel(Msg.translate(Env.getCtx(), "BPartner")); - protected VLookup bPartnerLookup; - - private CLabel dateFromLabel = new CLabel(Msg.translate(Env.getCtx(), "DateTrx")); - protected VDate dateFromField = new VDate("DateFrom", false, false, true, DisplayType.Date, Msg.translate(Env.getCtx(), "DateFrom")); - private CLabel dateToLabel = new CLabel("-"); - protected VDate dateToField = new VDate("DateTo", false, false, true, DisplayType.Date, Msg.translate(Env.getCtx(), "DateTo")); - - - /** - * Dynamic Init - * @throws Exception if Lookups cannot be initialized - * @return true if initialized - */ - public boolean dynInit() throws Exception - { - super.dynInit(); - - log.config(""); - - //Refresh button - CButton refreshButton = ConfirmPanel.createRefreshButton(false); - refreshButton.setMargin(new Insets (1, 10, 0, 10)); - refreshButton.setDefaultCapable(true); - refreshButton.addActionListener(this); - form.getConfirmPanel().addButton(refreshButton); -// form.getRootPane().setDefaultButton(refreshButton); - - if (m_frame.getGridTab() != null && m_frame.getGridTab().getValue("C_BankStatement_ID") == null) - { - ADialog.error(0, form, "SaveErrorRowNotFound"); - return false; - } - - m_frame.setTitle(getTitle()); - - int AD_Column_ID = COLUMN_C_BANKSTATEMENT_C_BANKACCOUNT_ID; // C_BankStatement.C_BankAccount_ID - MLookup lookup = MLookupFactory.get (Env.getCtx(), p_WindowNo, 0, AD_Column_ID, DisplayType.TableDir); - bankAccountField = new VLookup ("C_BankAccount_ID", true, true, true, lookup); - // Set Default - int C_BankAccount_ID = Env.getContextAsInt(Env.getCtx(), p_WindowNo, "C_BankAccount_ID"); - bankAccountField.setValue(Integer.valueOf(C_BankAccount_ID)); - bankAccountField.addActionListener(this); - // initial Loading - authorizationField = new VString ("authorization", false, false, true, 10, 30, null, null); - authorizationField.addActionListener(this); - - MLookup lookupDocument = MLookupFactory.get (Env.getCtx(), p_WindowNo, 0, MColumn.getColumn_ID(MPayment.Table_Name, MPayment.COLUMNNAME_C_DocType_ID), DisplayType.TableDir); - documentTypeField = new VLookup (MPayment.COLUMNNAME_C_DocType_ID,false,false,true,lookupDocument); - documentTypeField.addActionListener(this); - - MLookup lookupTender = MLookupFactory.get (Env.getCtx(), p_WindowNo, 0, MColumn.getColumn_ID(MPayment.Table_Name, MPayment.COLUMNNAME_TenderType), DisplayType.List); - tenderTypeField = new VLookup (MPayment.COLUMNNAME_TenderType,false,false,true,lookupTender); - tenderTypeField.addActionListener(this); - - bPartnerLookup = new VLookup("C_BPartner_ID", false, false, true, - MLookupFactory.get (Env.getCtx(), p_WindowNo, 0, 3499, DisplayType.Search)); - BPartner_idLabel.setLabelFor(bPartnerLookup); - bPartnerLookup.addActionListener(this); - - Timestamp date = Env.getContextAsDate(Env.getCtx(), p_WindowNo, MBankStatement.COLUMNNAME_StatementDate); - dateToField.setValue(date); - - documentNoField.addActionListener(this); - dateFromField.addActionListener(this); - dateToField.addActionListener(this); - amtFromField.addActionListener(this); - amtToField.addActionListener(this); - - executeQuery(); - - return true; - } // dynInit - - /** - * Static Init. - *
    -	 *  parameterPanel
    -	 *      parameterBankPanel
    -	 *      parameterStdPanel
    -	 *          bPartner/order/invoice/shopment/licator Label/Field
    -	 *  dataPane
    -	 *  southPanel
    -	 *      confirmPanel
    -	 *      statusBar
    -	 *  
    - * @throws Exception - */ - private void jbInit() throws Exception - { - bankAccountLabel.setText(Msg.translate(Env.getCtx(), "C_BankAccount_ID")); - authorizationLabel.setText(Msg.translate(Env.getCtx(), "R_AuthCode")); - - documentTypeLabel.setText(Msg.translate(Env.getCtx(), "C_DocType_ID")); - tenderTypeLabel.setText(Msg.translate(Env.getCtx(), "TenderType")); - - documentNoLabel.setLabelFor(documentNoField); - dateFromLabel.setLabelFor(dateFromField); - dateFromField.setToolTipText(Msg.translate(Env.getCtx(), "DateFrom")); - dateToLabel.setLabelFor(dateToField); - dateToField.setToolTipText(Msg.translate(Env.getCtx(), "DateTo")); - amtFromLabel.setLabelFor(amtFromField); - amtFromField.setToolTipText(Msg.translate(Env.getCtx(), "AmtFrom")); - amtToLabel.setLabelFor(amtToField); - amtToField.setToolTipText(Msg.translate(Env.getCtx(), "AmtTo")); - - CPanel parameterPanel = form.getParameterPanel(); - parameterPanel.setLayout(new BorderLayout()); - - CPanel parameterBankPanel = new CPanel(); - parameterBankPanel.setLayout(new GridBagLayout()); - parameterPanel.add(parameterBankPanel, BorderLayout.CENTER); - - parameterBankPanel.add(bankAccountLabel, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); - if (bankAccountField != null) - parameterBankPanel.add(bankAccountField, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 0, 5, 5), 0, 0)); - - parameterBankPanel.add(documentTypeLabel, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); - if(documentTypeField!= null) - parameterBankPanel.add(documentTypeField, new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 0, 5, 5), 0, 0)); - - parameterBankPanel.add(tenderTypeLabel, new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); - if(tenderTypeField!=null) - parameterBankPanel.add(tenderTypeField, new GridBagConstraints(1, 2, 1, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 0, 5, 5), 0, 0)); - - parameterBankPanel.add(BPartner_idLabel, new GridBagConstraints(0, 3, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); - parameterBankPanel.add(bPartnerLookup, new GridBagConstraints(1, 3, 1, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 0, 5, 5), 0, 0)); - - parameterBankPanel.add(documentNoLabel, new GridBagConstraints(2, 0, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); - parameterBankPanel.add(documentNoField, new GridBagConstraints(3, 0, 1, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 0, 5, 5), 0, 0)); - - parameterBankPanel.add(authorizationLabel, new GridBagConstraints(2, 1, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); - parameterBankPanel.add(authorizationField, new GridBagConstraints(3, 1, 1, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 0, 5, 5), 0, 0)); - - parameterBankPanel.add(amtFromLabel, new GridBagConstraints(2, 2, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); - parameterBankPanel.add(amtFromField, new GridBagConstraints(3, 2, 1, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 0, 5, 5), 0, 0)); - parameterBankPanel.add(amtToLabel, new GridBagConstraints(4, 2, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); - parameterBankPanel.add(amtToField, new GridBagConstraints(5, 2, 1, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 0, 5, 5), 0, 0)); - - parameterBankPanel.add(dateFromLabel, new GridBagConstraints(2, 3, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); - parameterBankPanel.add(dateFromField, new GridBagConstraints(3, 3, 1, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 0, 5, 5), 0, 0)); - parameterBankPanel.add(dateToLabel, new GridBagConstraints(4, 3, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); - parameterBankPanel.add(dateToField, new GridBagConstraints(5, 3, 1, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 0, 5, 5), 0, 0)); - - } // jbInit - - /*************************************************************************/ - - /** - * Action Listener - * @param e event - */ - public void actionPerformed(ActionEvent e) - { - if (log.isLoggable(Level.CONFIG)) log.config("Action=" + e.getActionCommand()); -// Object source = e.getSource(); - if(e.getActionCommand().equals(ConfirmPanel.A_REFRESH)) - { - Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR); - executeQuery(); - form.tableChanged(null); - Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR); - } - } // actionPerformed - - public void executeQuery() - { - loadTableOIS(getBankAccountData(bankAccountField.getValue(), bPartnerLookup.getValue(), - documentNoField.getText(), dateFromField.getValue(), dateToField.getValue(), - amtFromField.getValue(), amtToField.getValue(), - documentTypeField.getValue(), tenderTypeField.getValue(), authorizationField.getText(), - m_frame.getGridTab())); - } - - protected void loadTableOIS (Vector data) - { - // Remove previous listeners - form.getMiniTable().getModel().removeTableModelListener(form); - // Set Model - DefaultTableModel model = new DefaultTableModel(data, getOISColumnNames()); - model.addTableModelListener(form); - form.getMiniTable().setModel(model); - // - - configureMiniTable(form.getMiniTable()); - } - - public void dispose() - { - if (m_frame != null) - m_frame.dispose(); - m_frame = null; - } -} \ No newline at end of file diff --git a/org.adempiere.ui.swing/src/org/compiere/apps/form/VTreeBOM.java b/org.adempiere.ui.swing/src/org/compiere/apps/form/VTreeBOM.java deleted file mode 100644 index e361690041..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/apps/form/VTreeBOM.java +++ /dev/null @@ -1,726 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ -package org.compiere.apps.form; - -import java.awt.BorderLayout; -import java.awt.Component; -import java.awt.Cursor; -import java.awt.Dimension; -import java.awt.FlowLayout; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.awt.event.KeyEvent; -import java.awt.event.KeyListener; -import java.awt.event.MouseEvent; -import java.awt.event.MouseListener; -import java.math.BigDecimal; -import java.math.RoundingMode; -import java.util.Enumeration; -import java.util.List; -import java.util.Properties; -import java.util.Vector; -import java.util.logging.Level; - -import javax.swing.JCheckBox; -import javax.swing.JPopupMenu; -import javax.swing.JScrollPane; -import javax.swing.JSplitPane; -import javax.swing.JTree; -import javax.swing.SwingUtilities; -import javax.swing.event.TreeSelectionEvent; -import javax.swing.event.TreeSelectionListener; -import javax.swing.table.DefaultTableModel; -import javax.swing.tree.DefaultMutableTreeNode; -import javax.swing.tree.TreePath; - -import org.adempiere.plaf.AdempierePLAF; -import org.compiere.apps.ADialog; -import org.compiere.apps.ConfirmPanel; -import org.compiere.apps.StatusBar; -import org.compiere.apps.form.FormFrame; -import org.compiere.apps.form.FormPanel; -import org.compiere.grid.ed.VLookup; -import org.compiere.minigrid.MiniTable; -import org.compiere.model.MColumn; -import org.compiere.model.MLookup; -import org.compiere.model.MLookupFactory; -import org.compiere.model.MProduct; -import org.compiere.model.MProductBOM; -import org.compiere.model.MUOM; -import org.compiere.model.Query; -import org.compiere.swing.CCheckBox; -import org.compiere.swing.CLabel; -import org.compiere.swing.CMenuItem; -import org.compiere.swing.CPanel; -import org.compiere.swing.CTextField; -import org.compiere.util.CLogger; -import org.compiere.util.DisplayType; -import org.compiere.util.Env; -import org.compiere.util.KeyNamePair; -import org.compiere.util.Language; -import org.compiere.util.Msg; - -/** - * BOM Tree Maintenance - * - * @author Victor Perez,Sergio Ramazzinag - * @version $Id: VTreeMaintenance.java,v 1.1 2004/03/20 04:35:51 jjanke Exp $ - * - * 4Layers - MODIFICATIONS -------------------------------------------------------- - * 2005/04/12 Various improvements to the standard form (Sergio Ramazzina) - * 4Layers -------------------------------------------------------------------- end - * - * @author Teo Sarca, SC ARHIPAC SERVICE SRL - * @author Paul Bowden, adaxa modified for manufacturing light - * @author Tony Snook, enhancements search, right-click bom, where-used - * - */ -public class VTreeBOM extends CPanel implements FormPanel, ActionListener, TreeSelectionListener -{ - - /** - * - */ - private static final long serialVersionUID = -4045195906352692040L; - - /***************************************************************************** - * Mouse Listener for Popup Menu - */ - final class VTreeBOM_mouseAdapter extends java.awt.event.MouseAdapter - { - /** - * Constructor - * @param adaptee adaptee - */ - VTreeBOM_mouseAdapter(VTreeBOM adaptee) - { - m_adaptee = adaptee; - } - - private VTreeBOM m_adaptee; - - /** - * Mouse Listener - * @param e MouseEvent - */ - public void mouseClicked(MouseEvent e) - { - // popup menu - if (SwingUtilities.isRightMouseButton(e)) - m_adaptee.popupMenu.show((Component)e.getSource(), e.getX(), e.getY()); - // Hide the popup if not right click - teo_sarca [ 1734802 ] - else - m_adaptee.popupMenu.setVisible(false); - } // mouse Clicked - - } // VTreeBOM_mouseAdapter - - /** - * Key Pressed - */ - class VTreeBOM_keyAdapter extends java.awt.event.KeyAdapter - { - VTreeBOM m_adaptee; - - /** - * VTreePanel_keyAdapter - * @param adaptee - */ - VTreeBOM_keyAdapter(VTreeBOM adaptee) - { - m_adaptee = adaptee; - } - - /** - * Key Pressed - * @param e - */ - public void keyPressed(KeyEvent e) - { - if (e.getKeyCode() == KeyEvent.VK_ENTER) - m_adaptee.keyPressed(e); - } - } // VTreeBOM_keyAdapter - - - /** - * Tree Maintenance - */ - - /** Window No */ - private int m_WindowNo = 0; - /** FormFrame */ - private FormFrame m_frame; - /** Active Tree */ - private myJTree m_tree; - - private static CLogger log = CLogger.getCLogger(VTreeBOM.class); - - private BorderLayout mainLayout = new BorderLayout (); - private CPanel northPanel = new CPanel (); - - private FlowLayout northLayout = new FlowLayout (FlowLayout.RIGHT,20,5); - private CPanel southPanel = new CPanel(); - private CPanel southPanel2 = new CPanel (); - private BorderLayout southLayout = new BorderLayout(); - private FlowLayout southLayout2 = new FlowLayout (); - - private CLabel labelProduct = new CLabel (); - private VLookup fieldProduct; - private CCheckBox implosion = new CCheckBox (); - private CLabel treeInfo = new CLabel (); - private CLabel spacer = new CLabel (); - // - private JSplitPane splitPane = new JSplitPane (); - private JScrollPane dataPane = new JScrollPane(); - private JScrollPane treePane = new JScrollPane(); - private CCheckBox treeExpand = new CCheckBox(); - private CTextField treeSearch = new CTextField(10); - private CLabel treeSearchLabel = new CLabel(); - private String m_search = ""; - private Enumeration m_nodeEn; - private DefaultMutableTreeNode m_selectedNode; // the selected model node - private int m_selected_id = 0; - private MouseListener mouseListener = new VTreeBOM_mouseAdapter(this); - private KeyListener keyListener = new VTreeBOM_keyAdapter(this); - private DefaultMutableTreeNode m_root = null; - - private ConfirmPanel confirmPanel = new ConfirmPanel(true); - protected StatusBar statusBar = new StatusBar(); - - private MiniTable tableBOM = new MiniTable(); - private Vector> dataBOM = new Vector>(); - private Vector columnNames; - - private final int DIVIDER_LOCATION = 300; - private boolean reload = false; - private Language language = Language.getLoginLanguage(); // Base Language - - JPopupMenu popupMenu = new JPopupMenu(); - private CMenuItem mBOM; - private CMenuItem mImplosion; - private MLookup m_fieldProduct; - - - public Properties getCtx() { - return Env.getCtx(); - } - - /** - * Initialize Panel - * @param WindowNo window - * @param frame frame - */ - public void init (int WindowNo, FormFrame frame) - { - m_WindowNo = WindowNo; - m_frame = frame; - if (log.isLoggable(Level.INFO)) log.info( "VTreeBOM.init - WinNo=" + m_WindowNo); - try - { - preInit(); - jbInit (); - - frame.getContentPane().add(this, BorderLayout.CENTER); - } - catch (Exception ex) - { - log.log(Level.SEVERE,"VTreeMaintenance.init", ex); - } - } // init - - /** - * preInit() - Fill Tree Combo - */ - private void preInit() throws Exception - { - m_fieldProduct = MLookupFactory.get(getCtx(), m_WindowNo, - MColumn.getColumn_ID(MProduct.Table_Name, "M_Product_ID"), - DisplayType.Search, language, MProduct.COLUMNNAME_M_Product_ID, 0, false, - " M_Product.IsSummary = 'N'"); - fieldProduct = new VLookup ("M_Product_ID", false, false, true, m_fieldProduct) { - - /** - * - */ - private static final long serialVersionUID = 1084743143950828526L; - - public void setValue(Object value) { - super.setValue(value); - } - }; - - implosion.addActionListener(this); - splitPane.add (dataPane, JSplitPane.RIGHT); - splitPane.add (treePane, JSplitPane.LEFT); - } // preInit - - /** - * loadTableBOM - * - * - */ - private void loadTableBOM() - { - // Header Info - columnNames = new Vector(10); - - columnNames.add(Msg.getElement(getCtx(), "IsActive")); // 0 - columnNames.add(Msg.getElement(getCtx(), "Line")); // 1 - columnNames.add(Msg.getElement(getCtx(), "M_Product_ID")); // 2 - columnNames.add(Msg.getElement(getCtx(), "C_UOM_ID")); // 3 - columnNames.add(Msg.getElement(getCtx(), "QtyBOM")); // 4 - - DefaultTableModel model = new DefaultTableModel(dataBOM, columnNames); - tableBOM.setModel(model); - - tableBOM.setColumnClass( 0, Boolean.class, true); // 0 IsActive - tableBOM.setColumnClass( 1, String.class,true); // 1 Line (as string) - tableBOM.setColumnClass( 2, KeyNamePair.class,true); // 2 M_Product_ID - tableBOM.setColumnClass( 3, KeyNamePair.class,true); // 3 C_UOM_ID - tableBOM.setColumnClass( 4, BigDecimal.class,true); // 4 QtyBOM - - tableBOM.setMultiSelection(false); - tableBOM.autoSize(); - - } // loadTableBOM - - - /** - * jbInit - * - */ - private void jbInit () - { - this.setLayout (mainLayout); - - // 4Layers - Set initial window dimension - this.setPreferredSize(new Dimension(640, 480)); - - labelProduct.setText (Msg.getElement(getCtx(), "M_Product_ID")); - implosion.setText (Msg.getElement(getCtx(), "Implosion")); - treeInfo.setText ("Selected Product: "); - spacer.setText(" "); - northPanel.setLayout (northLayout); - northLayout.setAlignment (FlowLayout.LEFT); - - // - this.add (northPanel, BorderLayout.NORTH); - - northPanel.add (labelProduct, null); - northPanel.add (fieldProduct, null); - northPanel.add (implosion, null); - northPanel.add (spacer, null); - northPanel.add (spacer, null); - northPanel.add (treeInfo, null); - - treeExpand.setText(Msg.getMsg(Env.getCtx(), "ExpandTree")); - treeExpand.setActionCommand("Expand"); - treeExpand.addMouseListener(mouseListener); - treeExpand.addActionListener(this); - // - treeSearchLabel.setText(Msg.getMsg(Env.getCtx(), "TreeSearch") + " "); - treeSearchLabel.setLabelFor(treeSearch); - treeSearchLabel.setToolTipText(Msg.getMsg(Env.getCtx(), "TreeSearchText")); - treeSearch.setBackground(AdempierePLAF.getInfoBackground()); - treeSearch.addKeyListener(keyListener); - - this.add(southPanel, BorderLayout.SOUTH); - southPanel.setLayout(southLayout); - confirmPanel.addActionListener(this); - southPanel.add(confirmPanel, BorderLayout.SOUTH); - - southPanel2.setLayout(southLayout2); - southLayout2.setAlignment (FlowLayout.LEFT); - - southPanel.add(southPanel2, BorderLayout.NORTH); - southPanel2.add(treeExpand, null);//BorderLayout.EAST); - southPanel2.add(spacer, null); - southPanel2.add(treeSearchLabel, null);//BorderLayout.WEST); - southPanel2.add(treeSearch, null);//BorderLayout.CENTER); - - this.add (splitPane, BorderLayout.CENTER); - - // 4Layers - Set divider location - splitPane.setDividerLocation(DIVIDER_LOCATION); - - mBOM = new CMenuItem(Msg.getMsg(Env.getCtx(), "BOM"), Env.getImageIcon("Detail16.gif")); - mBOM.addActionListener(this); - popupMenu.add(mBOM); - - mImplosion = new CMenuItem(Msg.getMsg(Env.getCtx(), "Implosion"), Env.getImageIcon("Parent16.gif")); - mImplosion.addActionListener(this); - popupMenu.add(mImplosion); - - } // jbInit - - /** - * Enter Key - * @param e event - */ - protected void keyPressed(KeyEvent e) - { - // *** treeSearch *** - if (e.getSource() == treeSearch) - { - String search = treeSearch.getText(); - boolean found = false; - - // at the end - try from top - if (m_nodeEn != null && !m_nodeEn.hasMoreElements()) - m_search = ""; - - // this is the first time - if (!search.equals(m_search)) - { - // get enumeration of all nodes - m_nodeEn = m_root.preorderEnumeration(); - m_search = search; - } - - // search the nodes - while(!found && m_nodeEn != null && m_nodeEn.hasMoreElements()) - { - DefaultMutableTreeNode nd = (DefaultMutableTreeNode)m_nodeEn.nextElement(); - Vector nodeInfo = (Vector )(nd.getUserObject()); - String uoName = ((KeyNamePair)nodeInfo.elementAt(2)).getName() ; - // compare in upper case - if (uoName.toUpperCase().indexOf(search.toUpperCase()) != -1) - { - found = true; - TreePath treePath = new TreePath(nd.getPath()); - m_tree.setSelectionPath(treePath); - m_tree.makeVisible(treePath); // expand it - m_tree.scrollPathToVisible(treePath); - } - } - if (!found) - ADialog.beep(); - } // treeSearch - - } // keyPressed - - /** - * Dispose - */ - public void dispose() - { - if (m_frame != null) - m_frame.dispose(); - m_frame = null; - } // dispose - - /** - * Action Listener - * @param e event - */ - public void actionPerformed (ActionEvent e) - { - if (e.getSource() == mBOM) - { - fieldProduct.setValue(m_selected_id); - if (implosion.isSelected()) - implosion.doClick(); - action_loadBOM(); - } - if (e.getSource() == mImplosion) - { - fieldProduct.setValue(m_selected_id); - if (!implosion.isSelected()) - implosion.doClick(); - action_loadBOM(); - } - - if (e.getActionCommand().equals(ConfirmPanel.A_OK)) - { - if(m_selected_id > 0 || getM_Product_ID() > 0) action_loadBOM(); - } - - if (e.getActionCommand().equals(ConfirmPanel.A_CANCEL)) - { - dispose(); - } - else if (e.getSource() instanceof JCheckBox) - { - if (e.getActionCommand().equals("Expand")) - expandTree(); - } - - } // actionPerformed - - /** - * Action: Fill Tree with all nodes - */ - private void action_loadBOM() - { - m_frame.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); - - reload = false; - - int M_Product_ID = getM_Product_ID(); - if (M_Product_ID == 0) - return; - MProduct M_Product = MProduct.get(getCtx(), M_Product_ID); - treeInfo.setText ("Selected Product: "+M_Product.getValue()); - - Vector line = new Vector(10); - line.add( Boolean.valueOf(M_Product.isActive())); // 0 IsActive - line.add( Integer.valueOf(0).toString()); // 1 Line - KeyNamePair pp = new KeyNamePair(M_Product.getM_Product_ID(),M_Product.getValue().concat("_").concat(M_Product.getName())); - line.add(pp); // 2 M_Product_ID - MUOM u = new MUOM(M_Product.getCtx(), M_Product.getC_UOM_ID(), M_Product.get_TrxName()); - KeyNamePair uom = new KeyNamePair(u.get_ID(), u.getUOMSymbol()); - line.add(uom); // 3 C_UOM_ID - line.add(Env.ONE); // 4 QtyBOM - - DefaultMutableTreeNode parent = new DefaultMutableTreeNode(line); - m_root = (DefaultMutableTreeNode)parent.getRoot(); - dataBOM.clear(); - - if (isImplosion()) - { - for (MProductBOM bomline : getParentBOMs(M_Product_ID)) - { - addParent(bomline, parent); - } - m_tree = new myJTree(parent); - m_tree.addMouseListener(mouseListener); - } - else - { - for (MProductBOM bom : getChildBOMs(M_Product_ID, true)) - { - addChild(bom, parent); - } - m_tree = new myJTree(parent); - m_tree.addMouseListener(mouseListener); - } - - m_tree.addTreeSelectionListener(this); - treePane.getViewport().add (m_tree, null); - loadTableBOM(); - - dataPane.getViewport().add(tableBOM, null); - splitPane.setDividerLocation(DIVIDER_LOCATION); - - m_frame.setCursor(Cursor.getDefaultCursor()); - } // action_loadBOM - - private void action_reloadBOM() - { - m_frame.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); - reload = true; - int M_Product_ID = m_selected_id; - - if (M_Product_ID == 0) - return; - MProduct M_Product = MProduct.get(getCtx(), M_Product_ID); - treeInfo.setText ("Selected Product: "+M_Product.getValue()); - - DefaultMutableTreeNode parent = new DefaultMutableTreeNode(productSummary(M_Product, false)); - dataBOM.clear(); - - if (isImplosion()) - { - for (MProductBOM bomline : getParentBOMs(M_Product_ID)) - { - addParent(bomline, parent); - } - - } - else - { - for (MProductBOM bom : getChildBOMs(M_Product_ID, true)) - { - addChild(bom, parent); - } - } - - loadTableBOM(); - - m_frame.setCursor(Cursor.getDefaultCursor()); - } // action_reloadBOM - - public void addChild(MProductBOM bomline, DefaultMutableTreeNode parent) - { - - MProduct M_Product = MProduct.get(getCtx(), bomline.getM_ProductBOM_ID()); - - Vector line = new Vector(10); - line.add( Boolean.valueOf(bomline.isActive())); // 0 IsActive - line.add( Integer.valueOf(bomline.getLine()).toString()); // 1 Line - KeyNamePair pp = new KeyNamePair(M_Product.getM_Product_ID(),M_Product.getValue().concat("_").concat(M_Product.getName())); - line.add(pp); // 2 M_Product_ID - MUOM u = new MUOM(M_Product.getCtx(), M_Product.getC_UOM_ID(), M_Product.get_TrxName()); - KeyNamePair uom = new KeyNamePair(u.get_ID(), u.getUOMSymbol()); - line.add(uom); // 3 C_UOM_ID - line.add((BigDecimal) ((bomline.getBOMQty()!=null) ? bomline.getBOMQty() : Env.ZERO)); // 4 QtyBOM - - DefaultMutableTreeNode child = new DefaultMutableTreeNode(line); - parent.add(child); - - if(m_selected_id == bomline.getM_Product_ID() || getM_Product_ID() == bomline.getM_Product_ID()) - dataBOM.add(line); - - if(reload) return; - - for (MProductBOM bom : getChildBOMs(bomline.getM_ProductBOM_ID(), false)) - { - addChild(bom, child); - } - } - - public void addParent(MProductBOM bom, DefaultMutableTreeNode parent) - { - MProduct M_Product = MProduct.get(getCtx(), bom.getM_Product_ID()); - - Vector line = new Vector(10); - line.add( Boolean.valueOf(M_Product.isActive())); // 0 IsActive - line.add( Integer.valueOf(bom.getLine()).toString()); // 1 Line - KeyNamePair pp = new KeyNamePair(M_Product.getM_Product_ID(),M_Product.getValue().concat("_").concat(M_Product.getName())); - line.add(pp); // 2 M_Product_ID - MUOM u = new MUOM(M_Product.getCtx(), M_Product.getC_UOM_ID(), M_Product.get_TrxName()); - KeyNamePair uom = new KeyNamePair(u.get_ID(),u.getUOMSymbol()); - line.add(uom); // 3 C_UOM_ID - line.add((BigDecimal) ((bom.getBOMQty()!=null) ? bom.getBOMQty() : Env.ZERO)); // 4 QtyBOM - - if(m_selected_id == bom.getM_ProductBOM_ID() || getM_Product_ID() == bom.getM_ProductBOM_ID()) - dataBOM.add(line); - - DefaultMutableTreeNode child = new DefaultMutableTreeNode(line); - parent.add(child); - - if(reload) return; - - for (MProductBOM bomline : getParentBOMs(bom.getM_Product_ID())) - { - addParent(bomline, child); - } - - } - - public void valueChanged(TreeSelectionEvent event) - { - m_selectedNode = (DefaultMutableTreeNode)m_tree.getLastSelectedPathComponent(); - - /* if nothing is selected */ - if (m_selectedNode == null) return; - - Vector nodeInfo = (Vector )(m_selectedNode.getUserObject()); - - m_selected_id = ((KeyNamePair)nodeInfo.elementAt(2)).getKey() ; - - action_reloadBOM(); - - } - - /** - * Clicked on Expand All - */ - private void expandTree() - { - if (treeExpand.isSelected()) - { - for (int row = 0; row < m_tree.getRowCount(); row++) - m_tree.expandRow(row); - } - else - { -// patch: 1654055 +jgubo Changed direction of collapsing the tree nodes - for (int row = m_tree.getRowCount(); row > 0; row--) - m_tree.collapseRow(row); - } - } // expandTree - - public String productSummary(MProduct product, boolean isLeaf) { - MUOM uom = MUOM.get(getCtx(), product.getC_UOM_ID()); - String value = product.getValue(); - String name = product.get_Translation(MProduct.COLUMNNAME_Name); - // - StringBuilder sb = new StringBuilder(value); - if (name != null && !value.equals(name)) - sb.append("_").append(product.getName()); - sb.append(" [").append(uom.get_Translation(MUOM.COLUMNNAME_UOMSymbol)).append("]"); - // - return sb.toString(); - } - - private boolean isImplosion() { - return implosion.isSelected(); - } - - private int getM_Product_ID() { - Integer Product = (Integer)fieldProduct.getValue(); - if (Product == null) - return 0; - return Product.intValue(); - } - - private List getChildBOMs(int M_Product_ID, boolean onlyActiveRecords) - { - String filter = MProductBOM.COLUMNNAME_M_Product_ID+"=?" - +(onlyActiveRecords ? " AND IsActive='Y'" : ""); - return new Query(getCtx(), MProductBOM.Table_Name, filter, null) - .setParameters(new Object[]{M_Product_ID}) - .setOrderBy(MProductBOM.COLUMNNAME_Line) - .list(); - } - - private List getParentBOMs(int M_Product_ID) - { - String filter = MProductBOM.COLUMNNAME_M_ProductBOM_ID+"=?"; - return new Query(getCtx(), MProductBOM.Table_Name, filter, null) - .setParameters(new Object[]{M_Product_ID}) - .setOrderBy(MProductBOM.COLUMNNAME_M_Product_ID+","+MProductBOM.COLUMNNAME_Line) - .list(); - } -} // VTreeBOM - - -/************************************************************************** - * myJTree - extends convertValueToText method of JTree - */ -class myJTree extends JTree -{ - - /** - * - */ - private static final long serialVersionUID = -5831338565562378100L; - - public myJTree(DefaultMutableTreeNode parent) { - - super(parent); - } - - @Override - public String convertValueToText(Object value, boolean selected, boolean expanded, boolean leaf, int row, boolean hasFocus) { - - DefaultMutableTreeNode nd = (DefaultMutableTreeNode)value; - - Vector userObject = (Vector )nd.getUserObject(); - //Product - StringBuilder sb = new StringBuilder(((KeyNamePair)userObject.elementAt(2)).getName()); - //UOM - sb.append(" ["+((KeyNamePair) userObject.elementAt(3)).getName().trim()+"]"); - //BOMQty - BigDecimal BOMQty = (BigDecimal)(userObject.elementAt(4)); - sb.append("x"+BOMQty.setScale(2, RoundingMode.HALF_UP).stripTrailingZeros()); - - return sb.toString(); - } -} diff --git a/org.adempiere.ui.swing/src/org/compiere/apps/form/VTreeMaintenance.java b/org.adempiere.ui.swing/src/org/compiere/apps/form/VTreeMaintenance.java deleted file mode 100644 index cad54f91d7..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/apps/form/VTreeMaintenance.java +++ /dev/null @@ -1,332 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ -package org.compiere.apps.form; - -import java.awt.BorderLayout; -import java.awt.FlowLayout; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.beans.PropertyChangeEvent; -import java.beans.PropertyChangeListener; -import java.util.ArrayList; -import java.util.logging.Level; - -import javax.swing.DefaultListModel; -import javax.swing.JList; -import javax.swing.JScrollPane; -import javax.swing.JSplitPane; -import javax.swing.ListModel; -import javax.swing.ListSelectionModel; -import javax.swing.event.ListSelectionEvent; -import javax.swing.event.ListSelectionListener; - -import org.compiere.apps.ADialog; -import org.compiere.grid.tree.VTreePanel; -import org.compiere.model.MTree; -import org.compiere.model.MTreeNode; -import org.compiere.swing.CButton; -import org.compiere.swing.CCheckBox; -import org.compiere.swing.CComboBox; -import org.compiere.swing.CLabel; -import org.compiere.swing.CPanel; -import org.compiere.util.Env; -import org.compiere.util.KeyNamePair; -import org.compiere.util.Msg; - -/** - * Tree Maintenance - * - * @author Jorg Janke - * @version $Id: VTreeMaintenance.java,v 1.3 2006/07/30 00:51:28 jjanke Exp $ - */ -public class VTreeMaintenance extends TreeMaintenance - implements FormPanel, ActionListener, ListSelectionListener, PropertyChangeListener -{ - private CPanel panel = new CPanel(); - - /** FormFrame */ - private FormFrame m_frame; - - private BorderLayout mainLayout = new BorderLayout (); - private CPanel northPanel = new CPanel (); - private FlowLayout northLayout = new FlowLayout (); - private CLabel treeLabel = new CLabel (); - private CComboBox treeField; - private CButton bAddAll = new CButton (Env.getImageIcon("FastBack24.gif")); - private CButton bAdd = new CButton (Env.getImageIcon("StepBack24.gif")); - private CButton bDelete = new CButton (Env.getImageIcon("StepForward24.gif")); - private CButton bDeleteAll = new CButton (Env.getImageIcon("FastForward24.gif")); - private CCheckBox cbAllNodes = new CCheckBox (); - private CLabel treeInfo = new CLabel (); - // - private JSplitPane splitPane = new JSplitPane (); - private VTreePanel centerTree; - private JList centerList = new JList (); - - - /** - * Initialize Panel - * @param WindowNo window - * @param frame frame - */ - public void init (int WindowNo, FormFrame frame) - { - m_WindowNo = WindowNo; - m_frame = frame; - if (log.isLoggable(Level.INFO)) log.info( "VMerge.init - WinNo=" + m_WindowNo); - try - { - preInit(); - jbInit (); - frame.getContentPane().add(panel, BorderLayout.CENTER); - // frame.getContentPane().add(statusBar, BorderLayout.SOUTH); - action_loadTree(); - } - catch (Exception ex) - { - log.log(Level.SEVERE, "VTreeMaintenance.init", ex); - } - } // init - - /** - * Fill Tree Combo - */ - private void preInit() - { - treeField = new CComboBox(getTreeData()); - treeField.addActionListener(this); - // - centerTree = new VTreePanel (m_WindowNo, false, true); - centerTree.addPropertyChangeListener(VTreePanel.NODE_SELECTION, this); - } // preInit - - /** - * Static init - * @throws Exception - */ - private void jbInit () throws Exception - { - panel.setLayout (mainLayout); - treeLabel.setText (Msg.translate(Env.getCtx(), "AD_Tree_ID")); - cbAllNodes.setEnabled (false); - cbAllNodes.setText (Msg.translate(Env.getCtx(), "IsAllNodes")); - treeInfo.setText (" "); - bAdd.setToolTipText(Msg.getMsg(Env.getCtx(), "AddToTree")); - bAddAll.setToolTipText(Msg.getMsg(Env.getCtx(), "AddAllToTree")); - bDelete.setToolTipText(Msg.getMsg(Env.getCtx(), "DeleteFromTree")); - bDeleteAll.setToolTipText(Msg.getMsg(Env.getCtx(), "DeleteAllFromTree")); - bAdd.addActionListener(this); - bAddAll.addActionListener(this); - bDelete.addActionListener(this); - bDeleteAll.addActionListener(this); - northPanel.setLayout (northLayout); - northLayout.setAlignment (FlowLayout.LEFT); - // - panel.add (northPanel, BorderLayout.NORTH); - northPanel.add (treeLabel, null); - northPanel.add (treeField, null); - northPanel.add (cbAllNodes, null); - northPanel.add (treeInfo, null); - northPanel.add (bAddAll, null); - northPanel.add (bAdd, null); - northPanel.add (bDelete, null); - northPanel.add (bDeleteAll, null); - // - panel.add (splitPane, BorderLayout.CENTER); - splitPane.add (centerTree, JSplitPane.LEFT); - splitPane.add (new JScrollPane(centerList), JSplitPane.RIGHT); - centerList.setSelectionMode (ListSelectionModel.SINGLE_SELECTION); - centerList.addListSelectionListener(this); - } // jbInit - - /** - * Dispose - */ - public void dispose() - { - if (m_frame != null) - m_frame.dispose(); - m_frame = null; - } // dispose - - /** - * Action Listener - * @param e event - */ - public void actionPerformed (ActionEvent e) - { - if (e.getSource() == treeField) - action_loadTree(); - else if (e.getSource() == bAddAll) - action_treeAddAll(); - else if (e.getSource() == bAdd) - action_treeAdd((ListItem)centerList.getSelectedValue()); - else if (e.getSource() == bDelete) - action_treeDelete((ListItem)centerList.getSelectedValue()); - else if (e.getSource() == bDeleteAll) - action_treeDeleteAll(); - } // actionPerformed - - - /** - * Action: Fill Tree with all nodes - */ - private void action_loadTree() - { - KeyNamePair tree = (KeyNamePair)treeField.getSelectedItem(); - if (log.isLoggable(Level.INFO)) log.info("Tree=" + tree); - if (tree.getKey() <= 0) - { - centerList.setModel(new DefaultListModel()); - return; - } - // Tree - m_tree = new MTree (Env.getCtx(), tree.getKey(), null); - cbAllNodes.setSelected(m_tree.isAllNodes()); - bAddAll.setEnabled(!m_tree.isAllNodes()); - bAdd.setEnabled(!m_tree.isAllNodes()); - bDelete.setEnabled(!m_tree.isAllNodes()); - bDeleteAll.setEnabled(!m_tree.isAllNodes()); - // - - // List - DefaultListModel model = new DefaultListModel(); - ArrayList items = getTreeItemData(); - for(ListItem item : items) - model.addElement(item); - - // List - if (log.isLoggable(Level.CONFIG)) log.config("#" + model.getSize()); - centerList.setModel(model); - // Tree - centerTree.initTree(m_tree.getAD_Tree_ID()); - } // action_fillTree - - /** - * List Selection Listener - * @param e event - */ - public void valueChanged (ListSelectionEvent e) - { - if (e.getValueIsAdjusting()) - return; - ListItem selected = null; - try - { // throws a ArrayIndexOutOfBoundsException if root is selected - selected = (ListItem)centerList.getSelectedValue(); - } - catch (Exception ex) - { - } - if (log.isLoggable(Level.INFO)) log.info("Selected=" + selected); - if (selected != null) // allow add if not in tree - bAdd.setEnabled(!centerTree.setSelectedNode(selected.id)); - } // valueChanged - - /** - * VTreePanel Changed - * @param e event - */ - public void propertyChange (PropertyChangeEvent e) - { - MTreeNode tn = (MTreeNode)e.getNewValue(); - if (tn == null) - return; - if (log.isLoggable(Level.INFO)) log.info(tn.toString()); - ListModel model = centerList.getModel(); - int size = model.getSize(); - int index = -1; - for (index = 0; index < size; index++) - { - ListItem item = (ListItem)model.getElementAt(index); - if (item.id == tn.getNode_ID()) - break; - } - centerList.setSelectedIndex(index); - } // propertyChange - - /** - * Action: Add Node to Tree - * @param item item - */ - private void action_treeAdd(ListItem item) - { - if (log.isLoggable(Level.INFO)) log.info("Item=" + item); - if (item != null) - { - centerTree.nodeChanged(true, item.id, item.name, - item.description, item.isSummary, item.imageIndicator); - - // May cause Error if in tree - addNode(item); - } - } // action_treeAdd - - /** - * Action: Delete Node from Tree - * @param item item - */ - private void action_treeDelete(ListItem item) - { - if (log.isLoggable(Level.INFO)) log.info("Item=" + item); - if (item != null) - { - centerTree.nodeChanged(false, item.id, item.name, - item.description, item.isSummary, item.imageIndicator); - - deleteNode(item); - } - } // action_treeDelete - - - /** - * Action: Add All Nodes to Tree - */ - private void action_treeAddAll() - { - if (ADialog.ask(m_WindowNo, null, "TreeAddAllItems")) { // idempiere-85 - log.info(""); - ListModel model = centerList.getModel(); - int size = model.getSize(); - int index = -1; - for (index = 0; index < size; index++) - { - ListItem item = (ListItem)model.getElementAt(index); - action_treeAdd(item); - } - } - } // action_treeAddAll - - /** - * Action: Delete All Nodes from Tree - */ - private void action_treeDeleteAll() - { - if (ADialog.ask(m_WindowNo, null, "TreeRemoveAllItems")) { // idempiere-85 - log.info(""); - ListModel model = centerList.getModel(); - int size = model.getSize(); - int index = -1; - for (index = 0; index < size; index++) - { - ListItem item = (ListItem)model.getElementAt(index); - action_treeDelete(item); - } - } - } // action_treeDeleteAll - -} // VTreeMaintenance diff --git a/org.adempiere.ui.swing/src/org/compiere/apps/form/VTrxMaterial.java b/org.adempiere.ui.swing/src/org/compiere/apps/form/VTrxMaterial.java deleted file mode 100644 index b74a761279..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/apps/form/VTrxMaterial.java +++ /dev/null @@ -1,290 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ -package org.compiere.apps.form; - -import java.awt.BorderLayout; -import java.awt.Cursor; -import java.awt.GridBagConstraints; -import java.awt.GridBagLayout; -import java.awt.Insets; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.beans.PropertyChangeEvent; -import java.beans.VetoableChangeListener; -import java.sql.Timestamp; -import java.util.Properties; -import java.util.logging.Level; - -import javax.swing.JLabel; - -import org.compiere.apps.AEnv; -import org.compiere.apps.ConfirmPanel; -import org.compiere.apps.StatusBar; -import org.compiere.grid.GridController; -import org.compiere.grid.ed.VDate; -import org.compiere.grid.ed.VLocator; -import org.compiere.grid.ed.VLookup; -import org.compiere.model.MLocatorLookup; -import org.compiere.model.MLookup; -import org.compiere.model.MLookupFactory; -import org.compiere.plaf.CompiereColor; -import org.compiere.swing.CPanel; -import org.compiere.util.DisplayType; -import org.compiere.util.Env; -import org.compiere.util.Msg; - -/** - * Material Transaction History - * - * @author Jorg Janke - * @version $Id: VTrxMaterial.java,v 1.3 2006/07/30 00:51:28 jjanke Exp $ - */ -public class VTrxMaterial extends TrxMaterial - implements FormPanel, ActionListener, VetoableChangeListener -{ - private CPanel panel = new CPanel(); - - /** FormFrame */ - private FormFrame m_frame; - /** Grid Controller */ - private GridController m_gridController; - - // - private CPanel mainPanel = new CPanel(); - private BorderLayout mainLayout = new BorderLayout(); - private CPanel parameterPanel = new CPanel(); - private JLabel orgLabel = new JLabel(); - private VLookup orgField; - private JLabel locatorLabel = new JLabel(); - private VLocator locatorField; - private JLabel productLabel = new JLabel(); - private VLookup productField; - private JLabel dateFLabel = new JLabel(); - private VDate dateFField; - private JLabel dateTLabel = new JLabel(); - private VDate dateTField; - private JLabel mtypeLabel = new JLabel(); - private VLookup mtypeField; - private GridBagLayout parameterLayout = new GridBagLayout(); - private CPanel southPanel = new CPanel(); - private BorderLayout southLayout = new BorderLayout(); - private ConfirmPanel confirmPanel = new ConfirmPanel(true, true, false, false, false, true, true); - private StatusBar statusBar = new StatusBar(); - - - /** - * Initialize Panel - * @param WindowNo window - * @param frame frame - */ - public void init (int WindowNo, FormFrame frame) - { - log.info(""); - m_WindowNo = WindowNo; - m_frame = frame; - try - { - dynParameter(); - jbInit(); - dynInit(); - frame.getContentPane().add(mainPanel, BorderLayout.CENTER); - frame.getContentPane().add(statusBar, BorderLayout.SOUTH); - } - catch(Exception ex) - { - log.log(Level.SEVERE, "", ex); - } - } // init - - - /** - * Static Init - * @throws Exception - */ - void jbInit() throws Exception - { - CompiereColor.setBackground(panel); - mainPanel.setLayout(mainLayout); - mainLayout.setVgap(10); - parameterPanel.setLayout(parameterLayout); - // - orgLabel.setText(Msg.translate(Env.getCtx(), "AD_Org_ID")); - locatorLabel.setText(Msg.translate(Env.getCtx(), "M_Locator_ID")); - productLabel.setText(Msg.translate(Env.getCtx(), "Product")); - dateFLabel.setText(Msg.translate(Env.getCtx(), "DateFrom")); - dateTLabel.setText(Msg.translate(Env.getCtx(), "DateTo")); - mtypeLabel.setText(Msg.translate(Env.getCtx(), "MovementType")); - // - mainPanel.add(parameterPanel, BorderLayout.NORTH); - parameterPanel.add(orgLabel, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 5, 0, 5), 0, 0)); - parameterPanel.add(orgField, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 0, 0, 5), 0, 0)); - parameterPanel.add(mtypeLabel, new GridBagConstraints(2, 0, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 5, 0, 5), 0, 0)); - parameterPanel.add(mtypeField, new GridBagConstraints(3, 0, 1, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 0, 0, 5), 0, 0)); - parameterPanel.add(dateFLabel, new GridBagConstraints(4, 0, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 5, 0, 5), 0, 0)); - parameterPanel.add(dateFField, new GridBagConstraints(5, 0, 1, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 0, 0, 5), 0, 0)); - - parameterPanel.add(locatorLabel, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 5, 0, 5), 0, 0)); - parameterPanel.add(locatorField, new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 0, 0, 5), 0, 0)); - parameterPanel.add(productLabel, new GridBagConstraints(2, 1, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 5, 0, 5), 0, 0)); - parameterPanel.add(productField, new GridBagConstraints(3, 1, 1, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 0, 0, 5), 0, 0)); - parameterPanel.add(dateTLabel, new GridBagConstraints(4, 1, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 5, 0, 5), 0, 0)); - parameterPanel.add(dateTField, new GridBagConstraints(5, 1, 1, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 0, 0, 5), 0, 0)); - // - southPanel.setLayout(southLayout); - southPanel.add(confirmPanel, BorderLayout.NORTH); - southPanel.add(statusBar, BorderLayout.SOUTH); - mainPanel.add(southPanel, BorderLayout.SOUTH); - } // jbInit - - /** - * Initialize Parameter fields - * @throws Exception if Lookups cannot be initialized - */ - private void dynParameter() throws Exception - { - Properties ctx = Env.getCtx(); - // Organization - MLookup orgLookup = MLookupFactory.get (ctx, m_WindowNo, 0, 3660, DisplayType.TableDir); - orgField = new VLookup("AD_Org_ID", false, false, true, orgLookup); - // orgField.addVetoableChangeListener(this); - // Locator - MLocatorLookup locatorLookup = new MLocatorLookup(ctx, m_WindowNo); - locatorField = new VLocator ("M_Locator_ID", false, false, true, locatorLookup, m_WindowNo); - // locatorField.addVetoableChangeListener(this); - // Product - MLookup productLookup = MLookupFactory.get (ctx, m_WindowNo, 0, 3668, DisplayType.Search); - productField = new VLookup("M_Product_ID", false, false, true, productLookup); - productField.addVetoableChangeListener(this); - // Movement Type - MLookup mtypeLookup = MLookupFactory.get (ctx, m_WindowNo, 0, 3666, DisplayType.List); - mtypeField = new VLookup("MovementType", false, false, true, mtypeLookup); - // Dates - dateFField = new VDate("DateFrom", false, false, true, DisplayType.Date, Msg.getMsg(Env.getCtx(), "DateFrom")); - dateTField = new VDate("DateTo", false, false, true, DisplayType.Date, Msg.getMsg(Env.getCtx(), "DateTo")); - // - confirmPanel.addActionListener(this); - statusBar.setStatusLine(""); - } // dynParameter - - /** - * Dynamic Layout (Grid). - * Based on AD_Window: Material Transactions - */ - private void dynInit() - { - super.dynInit(statusBar); - m_gridController = new GridController(); - m_gridController.initGrid(m_mTab, true, m_WindowNo, null, null); - mainPanel.add(m_gridController, BorderLayout.CENTER); - } // dynInit - - - /** - * Dispose - */ - public void dispose() - { - if (m_gridController != null) - m_gridController.dispose(); - m_gridController = null; - m_mTab = null; - if (m_mWindow != null) - m_mWindow.dispose(); - m_mWindow = null; - - orgField = null; - locatorField = null; - productField = null; - mtypeField = null; - dateFField = null; - dateTField = null; - // - if (m_frame != null) - m_frame.dispose(); - m_frame = null; - } // dispose - - - /************************************************************************** - * Action Listener - * @param e event - */ - public void actionPerformed (ActionEvent e) - { - if (e.getActionCommand().equals(ConfirmPanel.A_CANCEL)) - dispose(); - else if (e.getActionCommand().equals(ConfirmPanel.A_REFRESH) - || e.getActionCommand().equals(ConfirmPanel.A_OK)) - refresh(); - else if (e.getActionCommand().equals(ConfirmPanel.A_ZOOM)) - zoom(); - } // actionPerformed - - - /************************************************************************** - * Property Listener - * @param e event - */ - public void vetoableChange (PropertyChangeEvent e) - { - if (e.getPropertyName().equals("M_Product_ID")) - productField.setValue(e.getNewValue()); - } // vetoableChange - - - - /************************************************************************** - * Refresh - Create Query and refresh grid - */ - private void refresh() - { - Object organization = orgField.getValue(); - Object locator = locatorField.getValue(); - Object product = productField.getValue(); - Object movementType = mtypeField.getValue(); - Timestamp movementDateFrom = (Timestamp)dateFField.getValue(); - Timestamp movementDateTo = (Timestamp)dateTField.getValue(); - - panel.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); - refresh(organization, locator, product, movementType, movementDateFrom, movementDateTo, statusBar); - panel.setCursor(Cursor.getDefaultCursor()); - } // refresh - - /** - * Zoom - */ - public void zoom() - { - super.zoom(); - - // Zoom - AEnv.zoom(AD_Table_ID, Record_ID); - } // zoom - -} // VTrxMaterial diff --git a/org.adempiere.ui.swing/src/org/compiere/apps/form/package.html b/org.adempiere.ui.swing/src/org/compiere/apps/form/package.html deleted file mode 100644 index d61f1f577a..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/apps/form/package.html +++ /dev/null @@ -1,30 +0,0 @@ - - - - - - - -

    Package org.compiere.apps.form

    - -Custom application form classes and archive viewer - -

    Related Documentation

    - -For overviews, tutorials, examples, guides, and tool documentation, please see: - - - - - - diff --git a/org.adempiere.ui.swing/src/org/compiere/apps/package.html b/org.adempiere.ui.swing/src/org/compiere/apps/package.html deleted file mode 100644 index 0924cbb19d..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/apps/package.html +++ /dev/null @@ -1,30 +0,0 @@ - - - - - - - -

    Package org.compiere.apps

    - -Contains classes that implement high level application user interface component. - -

    Related Documentation

    - -For overviews, tutorials, examples, guides, and tool documentation, please see: - - - - - - diff --git a/org.adempiere.ui.swing/src/org/compiere/apps/search/Find.java b/org.adempiere.ui.swing/src/org/compiere/apps/search/Find.java deleted file mode 100644 index 9677d7b428..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/apps/search/Find.java +++ /dev/null @@ -1,1750 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ -package org.compiere.apps.search; - -import java.awt.BorderLayout; -import java.awt.Component; -import java.awt.Dimension; -import java.awt.Frame; -import java.awt.GridBagConstraints; -import java.awt.GridBagLayout; -import java.awt.Insets; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.awt.event.KeyEvent; -import java.awt.event.WindowAdapter; -import java.awt.event.WindowEvent; -import java.math.BigDecimal; -import java.sql.PreparedStatement; -import java.sql.ResultSet; -import java.sql.SQLException; -import java.sql.Statement; -import java.sql.Timestamp; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Hashtable; -import java.util.Iterator; -import java.util.Vector; -import java.util.logging.Level; -import java.util.regex.Pattern; - -import javax.swing.AbstractAction; -import javax.swing.Action; -import javax.swing.Box; -import javax.swing.DefaultComboBoxModel; -import javax.swing.ImageIcon; -import javax.swing.InputMap; -import javax.swing.JButton; -import javax.swing.JScrollPane; -import javax.swing.JTable; -import javax.swing.JTextField; -import javax.swing.JToolBar; -import javax.swing.KeyStroke; -import javax.swing.ListSelectionModel; -import javax.swing.event.CellEditorListener; -import javax.swing.event.ChangeEvent; -import javax.swing.event.ChangeListener; -import javax.swing.event.TableColumnModelEvent; -import javax.swing.table.DefaultTableModel; -import javax.swing.table.TableCellRenderer; -import javax.swing.table.TableColumn; - -import org.compiere.apps.ADialog; -import org.compiere.apps.AEnv; -import org.compiere.apps.ConfirmPanel; -import org.compiere.apps.StatusBar; -import org.compiere.grid.ed.VEditor; -import org.compiere.grid.ed.VEditorFactory; -import org.compiere.grid.ed.VLookup; -import org.compiere.model.DataStatusEvent; -import org.compiere.model.DataStatusListener; -import org.compiere.model.GridField; -import org.compiere.model.GridFieldVO; -import org.compiere.model.GridTab; -import org.compiere.model.MColumn; -import org.compiere.model.MLookupFactory; -import org.compiere.model.MProduct; -import org.compiere.model.MQuery; -import org.compiere.model.MRole; -import org.compiere.model.MTable; -import org.compiere.model.MUserQuery; - -import static org.compiere.model.SystemIDs.*; - -import org.compiere.model.X_AD_Column; -import org.compiere.swing.CButton; -import org.compiere.swing.CComboBox; -import org.compiere.swing.CComboBoxEditable; -import org.compiere.swing.CDialog; -import org.compiere.swing.CLabel; -import org.compiere.swing.CPanel; -import org.compiere.swing.CTabbedPane; -import org.compiere.swing.CTable; -import org.compiere.swing.CTextField; -import org.compiere.util.AdempiereSystemError; -import org.compiere.util.CLogger; -import org.compiere.util.DB; -import org.compiere.util.DisplayType; -import org.compiere.util.Env; -import org.compiere.util.Msg; -import org.compiere.util.Util; -import org.compiere.util.ValueNamePair; - -/** - * Find/Search Records. - * Based on AD_Find for persistency, query is build to restrict info - * - * @author Jorg Janke - * @version $Id: Find.java,v 1.3 2006/07/30 00:51:27 jjanke Exp $ - * - * @author Teo Sarca, www.arhipac.ro - *
  • BF [ 2564070 ] Saving user queries can produce unnecessary db errors - */ -public final class Find extends CDialog - implements ActionListener, ChangeListener, DataStatusListener -{ - /** - * - */ - private static final long serialVersionUID = -8546399473944170334L; - private int m_AD_Tab_ID; - - /** - * Find Constructor - * @param owner Frame Dialog Owner - * @param targetWindowNo WindowNo of target window - * @param title - * @param AD_Table_ID - * @param tableName - * @param whereExtended - * @param findFields - * @param minRecords number of minimum records - */ - public Find (Frame owner, int targetWindowNo, String title, int AD_Tab_ID, - int AD_Table_ID, String tableName, String whereExtended, - GridField[] findFields, int minRecords) - { - super(owner, Msg.getMsg(Env.getCtx(), "Find") + ": " + title, true); - log.info(title); - // - m_targetWindowNo = targetWindowNo; - m_AD_Tab_ID = AD_Tab_ID; //red1 new field for UserQuery [ 1798539 ] - m_AD_Table_ID = AD_Table_ID; - m_tableName = tableName; - m_whereExtended = whereExtended; - m_findFields = findFields; - // - m_query = new MQuery (tableName); - m_query.addRestriction(Env.parseContext(Env.getCtx(), m_targetWindowNo, whereExtended, false)); - // Required for Column Validation - Env.setContext(Env.getCtx(), m_targetWindowNo, "Find_Table_ID", m_AD_Table_ID); - // - try - { - jbInit(); - initFind(); - if (m_total < minRecords) - { - dispose(); - return; - } - } - catch(Exception e) - { - log.log(Level.SEVERE, "Find", e); - } - // - this.getRootPane().setDefaultButton(confirmPanelS.getOKButton()); - AEnv.showCenterWindow(owner, this); - } // Find - - /** Target Window No */ - private int m_targetWindowNo; - /** Table ID */ - private int m_AD_Table_ID; - /** Table Name */ - private String m_tableName; - /** Where */ - private String m_whereExtended; - /** Search Fields */ - private GridField[] m_findFields; - /** Resulting query */ - private MQuery m_query = null; - /** Is cancel ? */ - private boolean m_isCancel = false; // teo_sarca [ 1708717 ] - /** Logger */ - private static CLogger log = CLogger.getCLogger(Find.class); - - /** Number of records */ - private int m_total; - private PreparedStatement m_pstmt; - // - private boolean hasValue = false; - private boolean hasDocNo = false; - private boolean hasName = false; - private boolean hasDescription = false; - /** Line in Simple Content */ - private int m_sLine = 6; - - /** List of VEditors */ - private ArrayList m_sEditors = new ArrayList(); - /** Target Fields with AD_Column_ID as key */ - private Hashtable m_targetFields = new Hashtable(); - - /** For Grid Controller */ - public static final int TABNO = 99; - /** Length of Fields on first tab */ - public static final int FIELDLENGTH = 20; - /** Reference ID for Yes/No */ - public static final int AD_REFERENCE_ID_YESNO = REFERENCE_YESNO; - - - // - private CPanel southPanel = new CPanel(); - private BorderLayout southLayout = new BorderLayout(); - private StatusBar statusBar = new StatusBar(); - private CTabbedPane tabbedPane = new CTabbedPane(); - private CPanel advancedPanel = new CPanel(); - private BorderLayout advancedLayout = new BorderLayout(); - private ConfirmPanel confirmPanelA = new ConfirmPanel(true, true, false, false, false, false, true); - private CButton bIgnore = new CButton(); - private JToolBar toolBar = new JToolBar(); - private CComboBoxEditable fQueryName = new CComboBoxEditable(); - private CButton bSave = new CButton(); - private CButton bNew = new CButton(); - private CButton bDelete = new CButton(); - private ConfirmPanel confirmPanelS = new ConfirmPanel(true); - private BorderLayout simpleLayout = new BorderLayout(); - private CPanel scontentPanel = new CPanel(); - private GridBagLayout scontentLayout = new GridBagLayout(); - private CPanel simplePanel = new CPanel(); - private CLabel valueLabel = new CLabel(); - private CLabel nameLabel = new CLabel(); - private CLabel descriptionLabel = new CLabel(); - private CTextField valueField = new CTextField(); - private CTextField nameField = new CTextField(); - private CTextField descriptionField = new CTextField(); - private CLabel docNoLabel = new CLabel(); - private CTextField docNoField = new CTextField(); - private Component spaceE; - private Component spaceN; - private Component spaceW; - private Component spaceS; - private JScrollPane advancedScrollPane = new JScrollPane(); - private CTable advancedTable = new CTable() { - - private static final long serialVersionUID = -6201749159307529032L; - - public boolean isCellEditable(int row, int column) - { - boolean editable = ( column == INDEX_COLUMNNAME - || column == INDEX_OPERATOR - || column == INDEX_ANDOR - || column == INDEX_LEFTBRACKET - || column == INDEX_RIGHTBRACKET ); - if (!editable && row >= 0) - { - String columnName = null; - Object value = - getModel().getValueAt(row, INDEX_COLUMNNAME); - if (value != null) - { - if (value instanceof ValueNamePair) - columnName = ((ValueNamePair)value).getValue(); - else - columnName = value.toString(); - } - - // Create Editor - editable = getTargetMField(columnName) != null; - } - - if ( column == INDEX_ANDOR && row == 0 ) - editable = false; - - return editable; - } - - public void columnMoved(TableColumnModelEvent e) { - if (isEditing()) { - cellEditor.stopCellEditing(); - } - super.columnMoved(e); - } - - public void columnMarginChanged(ChangeEvent e) { - if (isEditing()) { - cellEditor.stopCellEditing(); - } - super.columnMarginChanged(e); - } - - }; - - - /** Index AndOr = 0 */ - public static final int INDEX_ANDOR = 0; - /** Index LeftBracket = 1 */ - public static final int INDEX_LEFTBRACKET = 1; - /** Index ColumnName = 2 */ - public static final int INDEX_COLUMNNAME = 2; - /** Index Operator = 3 */ - public static final int INDEX_OPERATOR = 3; - /** Index Value = 4 */ - public static final int INDEX_VALUE = 4; - /** Index Value2 = 5 */ - public static final int INDEX_VALUE2 = 5; - /** Index RightBracket = 6 */ - public static final int INDEX_RIGHTBRACKET = 6; - - /** Advanced Search Column */ - /** Advanced Search Operators */ - public CComboBox columns = null; - public CComboBox operators = null; - private MUserQuery[] userQueries; - private ValueNamePair[] columnValueNamePairs; - - private CComboBox leftBrackets; - - private CComboBox rightBrackets; - - private CComboBox andOr; - - private static final String FIELD_SEPARATOR = "<^>"; - private static final String SEGMENT_SEPARATOR = "<~>"; - - /** - * Static Init. - *
    -	 *  tabbedPane
    -	 *      simplePanel
    -	 *          scontentPanel
    -	 *          confirmPanelS
    -	 *      advancedPanel
    -	 *          toolBar
    -	 *          GC
    -	 *          confirmPanelA
    -	 *  southPanel
    -	 *      statusBar
    -	 *  
    - * @throws Exception - */ - private void jbInit() throws Exception - { - spaceE = Box.createHorizontalStrut(8); - spaceN = Box.createVerticalStrut(8); - spaceW = Box.createHorizontalStrut(8); - spaceS = Box.createVerticalStrut(8); - bIgnore.setIcon(new ImageIcon(org.compiere.Adempiere.getResource("images/Ignore24.gif"))); - bIgnore.setMargin(new Insets(2, 2, 2, 2)); - bIgnore.setToolTipText(Msg.getMsg(Env.getCtx(),"Ignore")); - bIgnore.addActionListener(this); - fQueryName.setToolTipText (Msg.getMsg(Env.getCtx(),"QueryName")); - fQueryName.setEditable(true); - fQueryName.addActionListener(this); - bSave.setIcon(new ImageIcon(org.compiere.Adempiere.getResource("images/Save24.gif"))); - bSave.setMargin(new Insets(2, 2, 2, 2)); - bSave.setToolTipText(Msg.getMsg(Env.getCtx(),"Save")); - bSave.addActionListener(this); - bNew.setIcon(new ImageIcon(org.compiere.Adempiere.getResource("images/New24.gif"))); - bNew.setMargin(new Insets(2, 2, 2, 2)); - bNew.setToolTipText(Msg.getMsg(Env.getCtx(),"New")); - bNew.addActionListener(this); - bDelete.setIcon(new ImageIcon(org.compiere.Adempiere.getResource("images/Delete24.gif"))); - bDelete.setMargin(new Insets(2, 2, 2, 2)); - bDelete.setToolTipText(Msg.getMsg(Env.getCtx(),"Delete")); - bDelete.addActionListener(this); - // - southPanel.setLayout(southLayout); - valueLabel.setLabelFor(valueField); - valueLabel.setText(Msg.translate(Env.getCtx(),"Value")); - nameLabel.setLabelFor(nameField); - nameLabel.setText(Msg.translate(Env.getCtx(),"Name")); - descriptionLabel.setLabelFor(descriptionField); - descriptionLabel.setText(Msg.translate(Env.getCtx(),"Description")); - valueField.setText("%"); - valueField.setColumns(FIELDLENGTH); - nameField.setText("%"); - nameField.setColumns(FIELDLENGTH); - descriptionField.setText("%"); - descriptionField.setColumns(FIELDLENGTH); - scontentPanel.setToolTipText(Msg.getMsg(Env.getCtx(),"FindTip")); - docNoLabel.setLabelFor(docNoField); - docNoLabel.setText(Msg.translate(Env.getCtx(),"DocumentNo")); - docNoField.setText("%"); - docNoField.setColumns(FIELDLENGTH); - advancedScrollPane.setPreferredSize(new Dimension(540, 410)); - southPanel.add(statusBar, BorderLayout.SOUTH); - this.getContentPane().add(southPanel, BorderLayout.SOUTH); - // - scontentPanel.setLayout(scontentLayout); - simplePanel.setLayout(simpleLayout); - simplePanel.add(confirmPanelS, BorderLayout.SOUTH); - simplePanel.add(scontentPanel, BorderLayout.CENTER); - scontentPanel.add(valueLabel, new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0 - ,GridBagConstraints.NORTHEAST, GridBagConstraints.NONE, new Insets(7, 5, 0, 5), 0, 0)); - scontentPanel.add(nameLabel, new GridBagConstraints(1, 3, 1, 1, 0.0, 0.0 - ,GridBagConstraints.NORTHEAST, GridBagConstraints.NONE, new Insets(7, 5, 0, 5), 0, 0)); - scontentPanel.add(descriptionLabel, new GridBagConstraints(1, 4, 1, 1, 0.0, 0.0 - ,GridBagConstraints.NORTHEAST, GridBagConstraints.NONE, new Insets(7, 5, 5, 5), 0, 0)); - scontentPanel.add(valueField, new GridBagConstraints(2, 1, 1, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 0, 0, 5), 0, 0)); - scontentPanel.add(descriptionField, new GridBagConstraints(2, 4, 1, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 0, 5, 5), 0, 0)); - scontentPanel.add(docNoLabel, new GridBagConstraints(1, 2, 1, 1, 0.0, 0.0 - ,GridBagConstraints.NORTHEAST, GridBagConstraints.NONE, new Insets(7, 5, 0, 5), 0, 0)); - scontentPanel.add(nameField, new GridBagConstraints(2, 3, 1, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 0, 0, 5), 0, 0)); - scontentPanel.add(docNoField, new GridBagConstraints(2, 2, 1, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 0, 0, 5), 0, 0)); - // - scontentPanel.add(spaceE, new GridBagConstraints(3, 3, 1, 1, 0.0, 0.0 - ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(10, 10, 10, 10), 0, 0)); - scontentPanel.add(spaceN, new GridBagConstraints(2, 0, 1, 1, 0.0, 0.0 - ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(10, 10, 10, 10), 0, 0)); - scontentPanel.add(spaceW, new GridBagConstraints(0, 3, 1, 1, 0.0, 0.0 - ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(10, 10, 10, 10), 0, 0)); - scontentPanel.add(spaceS, new GridBagConstraints(2, 15, 1, 1, 0.0, 0.0 - ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(10, 10, 10, 10), 0, 0)); - // - // tabbedPane.add(simplePanel, Msg.getMsg(Env.getCtx(),"Find")); - tabbedPane.add(simplePanel, Msg.getMsg(Env.getCtx(),"Find")); - // - toolBar.add(bIgnore, null); - toolBar.addSeparator(); - toolBar.add(bNew, null); - toolBar.add(bDelete, null); - toolBar.add(fQueryName, null); - toolBar.add(bSave, null); - advancedPanel.setLayout(advancedLayout); - advancedPanel.add(toolBar, BorderLayout.NORTH); - advancedPanel.add(confirmPanelA, BorderLayout.SOUTH); - advancedPanel.add(advancedScrollPane, BorderLayout.CENTER); - advancedScrollPane.getViewport().add(advancedTable, null); - // tabbedPane.add(advancedPanel, Msg.getMsg(Env.getCtx(),"Advanced")); - tabbedPane.add(advancedPanel, Msg.getMsg(Env.getCtx(),"Advanced")); - // - this.getContentPane().add(tabbedPane, BorderLayout.CENTER); - // - confirmPanelA.addActionListener(this); - confirmPanelS.addActionListener(this); - // - JButton b = ConfirmPanel.createNewButton(true); - confirmPanelS.addComponent (b); - b.addActionListener(this); - // teo_sarca, [ 1670847 ] Find dialog: closing and canceling need same functionality - addWindowListener(new WindowAdapter() { - @Override - public void windowClosing(WindowEvent e) { - cmd_cancel(); - } - }); - - } // jbInit - - /** - * Dynamic Init.6 - * Set up GridController - */ - private void initFind() - { - log.config(""); - - // Get Info from target Tab - for (int i = 0; i < m_findFields.length; i++) - { - GridField mField = m_findFields[i]; - - // Make Yes-No searchable as list - if (mField.getVO().displayType == DisplayType.YesNo) - { - GridFieldVO vo = mField.getVO(); - GridFieldVO ynvo = vo.clone(vo.ctx, vo.WindowNo, vo.TabNo, vo.AD_Window_ID, vo.AD_Tab_ID, vo.tabReadOnly); - ynvo.IsDisplayed = true; - ynvo.displayType = DisplayType.List; - ynvo.AD_Reference_Value_ID = AD_REFERENCE_ID_YESNO; - - ynvo.lookupInfo = MLookupFactory.getLookupInfo (ynvo.ctx, ynvo.WindowNo, ynvo.AD_Column_ID, ynvo.displayType, - Env.getLanguage(ynvo.ctx), ynvo.ColumnName, ynvo.AD_Reference_Value_ID, - ynvo.IsParent, ynvo.ValidationCode); - - GridField ynfield = new GridField(ynvo); - - // replace the original field by the YN List field - m_findFields[i] = ynfield; - mField = ynfield; - } - - // Make Buttons searchable - if ( mField.getVO().displayType == DisplayType.Button ) - { - GridFieldVO vo = mField.getVO(); - if ( vo.AD_Reference_Value_ID > 0 ) - { - GridFieldVO postedvo = vo.clone(vo.ctx, vo.WindowNo, vo.TabNo, vo.AD_Window_ID, vo.AD_Tab_ID, vo.tabReadOnly); - postedvo.IsDisplayed = true; - postedvo.displayType = DisplayType.List; - - postedvo.lookupInfo = MLookupFactory.getLookupInfo (postedvo.ctx, postedvo.WindowNo, postedvo.AD_Column_ID, postedvo.displayType, - Env.getLanguage(postedvo.ctx), postedvo.ColumnName, postedvo.AD_Reference_Value_ID, - postedvo.IsParent, postedvo.ValidationCode); - - GridField postedfield = new GridField(postedvo); - - // replace the original field by the Posted List field - m_findFields[i] = postedfield; - mField = postedfield; - } - } - - /** metas: teo_sarca: Specify exactly which are the search fields - http://sourceforge.net/projects/adempiere/forums/forum/610548/topic/3736214 - if (columnName.equals("Value")) - hasValue = true; - else if (columnName.equals("Name")) - hasName = true; - else if (columnName.equals("DocumentNo")) - hasDocNo = true; - else if (columnName.equals("Description")) - hasDescription = true; - else - /**/ - if (mField.isSelectionColumn()) - addSelectionColumn (mField); - /** metas: teo_sarca: Specify exactly which are the search fields - http://sourceforge.net/projects/adempiere/forums/forum/610548/topic/3736214 - else if (columnName.indexOf("Name") != -1) - addSelectionColumn (mField); - /**/ - - // TargetFields - m_targetFields.put (Integer.valueOf(mField.getAD_Column_ID()), mField); - } // for all target tab fields - - // Disable simple query fields - valueLabel.setVisible(hasValue); - valueField.setVisible(hasValue); - if (hasValue) - valueField.addActionListener(this); - docNoLabel.setVisible(hasDocNo); - docNoField.setVisible(hasDocNo); - if (hasDocNo) - docNoField.addActionListener(this); - nameLabel.setVisible(hasName); - nameField.setVisible(hasName); - if (hasName) - nameField.addActionListener(this); - descriptionLabel.setVisible(hasDescription); - descriptionField.setVisible(hasDescription); - if (hasDescription) - descriptionField.addActionListener(this); - - // Get Total - m_total = getNoOfRecords(null, false); - setStatusDB (m_total); - statusBar.setStatusLine(""); - - tabbedPane.addChangeListener(this); - - // Better Labels for OK/Cancel - confirmPanelA.getOKButton().setToolTipText(Msg.getMsg(Env.getCtx(),"QueryEnter")); - confirmPanelA.getCancelButton().setToolTipText(Msg.getMsg(Env.getCtx(),"QueryCancel")); - confirmPanelS.getOKButton().setToolTipText(Msg.getMsg(Env.getCtx(),"QueryEnter")); - confirmPanelS.getCancelButton().setToolTipText(Msg.getMsg(Env.getCtx(),"QueryCancel")); - } // initFind - - /** - * Add Selection Column to first Tab - * @param mField field - */ - private void addSelectionColumn (GridField mField) - { - if (log.isLoggable(Level.CONFIG)) log.config(mField.getHeader()); - int displayLength = mField.getDisplayLength(); - if (displayLength > FIELDLENGTH) - mField.setDisplayLength(FIELDLENGTH); - else - displayLength = 0; - - // Editor - VEditor editor = null; - if (mField.isLookup()) - { - VLookup vl = new VLookup(mField.getColumnName(), false, false, true, - mField.getLookup()); - //setting mField to avoid NPE - vl.setField(mField); - - vl.setName(mField.getColumnName()); - editor = vl; - } - else - { - editor = VEditorFactory.getEditor(mField, false); - editor.setMandatory(false); - editor.setReadWrite(true); - } - // Add action listener to custom text fields - teo_sarca [ 1709292 ] - if (editor instanceof CTextField) { - ((CTextField)editor).addActionListener(this); - } - CLabel label = VEditorFactory.getLabel(mField); - // - if (displayLength > 0) // set it back - mField.setDisplayLength(displayLength); - // - m_sLine++; - if (label != null) // may be null for Y/N - scontentPanel.add(label, new GridBagConstraints(1, m_sLine, 1, 1, 0.0, 0.0 - ,GridBagConstraints.NORTHEAST, GridBagConstraints.NONE, new Insets(7, 5, 5, 5), 0, 0)); - scontentPanel.add((Component)editor, new GridBagConstraints(2, m_sLine, 1, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 0, 5, 5), 0, 0)); - m_sEditors.add(editor); - } // addSelectionColumn - - - /** - * Init Find GridController - */ - private void initFindAdvanced() - { - log.config(""); - advancedTable.setModel(new DefaultTableModel(0, 7)); - advancedTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); - advancedTable.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS); - advancedTable.putClientProperty("terminateEditOnFocusLost", Boolean.TRUE); - - TableCellRenderer renderer = new ProxyRenderer(advancedTable.getDefaultRenderer(Object.class)); - advancedTable.setDefaultRenderer(Object.class, renderer); - - InputMap im = advancedTable.getInputMap(JTable.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT); - KeyStroke tab = KeyStroke.getKeyStroke(KeyEvent.VK_TAB, 0); - final Action tabAction = advancedTable.getActionMap().get(im.get(tab)); - Action tabActionWrapper = new AbstractAction() - { - private static final long serialVersionUID = -6868476640719619801L; - - public void actionPerformed(ActionEvent e) - { - tabAction.actionPerformed(e); - - JTable table = (JTable)e.getSource(); - table.requestFocusInWindow(); - } - }; - advancedTable.getActionMap().put(im.get(tab), tabActionWrapper); - KeyStroke shiftTab = KeyStroke.getKeyStroke(KeyEvent.VK_TAB, ActionEvent.SHIFT_MASK); - final Action shiftTabAction = advancedTable.getActionMap().get(im.get(shiftTab)); - Action shiftTabActionWrapper = new AbstractAction() - { - private static final long serialVersionUID = 5493691483070046620L; - - public void actionPerformed(ActionEvent e) - { - shiftTabAction.actionPerformed(e); - - JTable table = (JTable)e.getSource(); - table.requestFocusInWindow(); - } - }; - advancedTable.getActionMap().put(im.get(shiftTab), shiftTabActionWrapper); - - // 0 = Columns - ArrayList items = new ArrayList(); - for (int c = 0; c < m_findFields.length; c++) - { - GridField field = m_findFields[c]; - String columnName = field.getColumnName(); - String header = field.getHeader(); - if (header == null || header.length() == 0) - { - header = Msg.translate(Env.getCtx(), columnName); - if (header == null || header.length() == 0) - continue; - } - if (field.isKey()) - header += (" (ID)"); - ValueNamePair pp = new ValueNamePair(columnName, header); - // System.out.println(pp + " = " + field); - items.add(pp); - } - columnValueNamePairs = new ValueNamePair[items.size()]; - items.toArray(columnValueNamePairs); - Arrays.sort(columnValueNamePairs); // sort alpha - columns = new CComboBox(columnValueNamePairs); - columns.addActionListener(this); - TableColumn tc = advancedTable.getColumnModel().getColumn(INDEX_COLUMNNAME); - tc.setPreferredWidth(120); - FindCellEditor dce = new FindCellEditor(columns); - - dce.addCellEditorListener(new CellEditorListener() - { - public void editingCanceled(ChangeEvent ce) - { - } - - public void editingStopped(ChangeEvent ce) - { - int col = advancedTable.getSelectedColumn(); - int row = advancedTable.getSelectedRow(); - if (col == INDEX_COLUMNNAME && row >= 0) - { - advancedTable.setValueAt(null, row, INDEX_VALUE); - advancedTable.setValueAt(null, row, INDEX_VALUE2); - } - } - }); - tc.setCellEditor(dce); - tc.setHeaderValue(Msg.translate(Env.getCtx(), "AD_Column_ID")); - - - // 0 = And/Or - andOr = new CComboBox(new String[] {"",Msg.getMsg(Env.getCtx(),"AND"),Msg.getMsg(Env.getCtx(), "OR")}); - tc = advancedTable.getColumnModel().getColumn(INDEX_ANDOR); - tc.setPreferredWidth(45); - dce = new FindCellEditor(andOr); - tc.setCellEditor(dce); - tc.setHeaderValue(Msg.getMsg(Env.getCtx(), "And/Or")); - - // 1 = Left Bracket - leftBrackets = new CComboBox(new String[] {"","(","((","((("}); - tc = advancedTable.getColumnModel().getColumn(INDEX_LEFTBRACKET); - tc.setPreferredWidth(25); - dce = new FindCellEditor(leftBrackets); - tc.setCellEditor(dce); - tc.setHeaderValue("("); - - // 3 = Operators - operators = new CComboBox(MQuery.OPERATORS); - tc = advancedTable.getColumnModel().getColumn(INDEX_OPERATOR); - tc.setPreferredWidth(55); - dce = new FindCellEditor(operators); - tc.setCellEditor(dce); - tc.setHeaderValue(Msg.getMsg(Env.getCtx(), "Operator")); - - // 4 = QueryValue - tc = advancedTable.getColumnModel().getColumn(INDEX_VALUE); - FindValueEditor fve = new FindValueEditor(this, false); - tc.setCellEditor(fve); - tc.setPreferredWidth(120); - tc.setCellRenderer(new ProxyRenderer(new FindValueRenderer(this, false))); - tc.setHeaderValue(Msg.getMsg(Env.getCtx(), "QueryValue")); - - // 5 = QueryValue2 - tc = advancedTable.getColumnModel().getColumn(INDEX_VALUE2); - tc.setPreferredWidth(120); - fve = new FindValueEditor(this, true); - tc.setCellEditor(fve); - tc.setCellRenderer(new ProxyRenderer(new FindValueRenderer(this, false))); - tc.setHeaderValue(Msg.getMsg(Env.getCtx(), "QueryValue2")); - - // 6 = Right Bracket - rightBrackets = new CComboBox(new String[] {"",")","))",")))"}); - tc = advancedTable.getColumnModel().getColumn(INDEX_RIGHTBRACKET); - tc.setPreferredWidth(25); - dce = new FindCellEditor(rightBrackets); - tc.setCellEditor(dce); - tc.setHeaderValue(")"); - - // phib: disabled auto-completion as it causes date fields to have to be entered twice - //AutoCompletion.enable(columns); - //AutoCompletion.enable(operators); - - //user query - userQueries = MUserQuery.get(Env.getCtx(), m_AD_Tab_ID); - String[] queries = new String[userQueries.length]; - for (int i = 0; i < userQueries.length; i++) - queries[i] = userQueries[i].getName(); - fQueryName.setModel(new DefaultComboBoxModel(queries)); - fQueryName.setValue(""); - - // No Row - Create one - cmd_new(); - } // initFindAdvanced - - /** - * Dispose window - */ - public void dispose() - { - log.config(""); - DB.close(m_pstmt); - m_pstmt = null; - - // Remove action listener from custom fields - teo_sarca [ 1709292 ] - for (VEditor editor : m_sEditors) { - if (editor instanceof CTextField) - ((CTextField)editor).removeActionListener(this); - } - // TargetFields - if (m_targetFields != null) - m_targetFields.clear(); - m_targetFields = null; - // - removeAll(); - super.dispose(); - } // dispose - - - /************************************************************************** - * Action Listener - * @param e ActionEvent - */ - public void actionPerformed (ActionEvent e) - { - if (log.isLoggable(Level.INFO)) log.info(e.getActionCommand()); - // - if (e.getActionCommand().equals(ConfirmPanel.A_CANCEL)) - cmd_cancel(); - else if (e.getActionCommand().equals(ConfirmPanel.A_REFRESH)) - cmd_refresh(); - // - else if (e.getActionCommand().equals(ConfirmPanel.A_NEW)) - { - m_query = MQuery.getNoRecordQuery(m_tableName, true); - m_total = 0; - dispose(); - } - // - else if (e.getSource() == bIgnore) - cmd_ignore(); - else if (e.getSource() == bNew) - cmd_new(); - else if (e.getSource() == bSave) - cmd_save(true); - else if (e.getSource() == bDelete) - cmd_delete(); - // - else if (e.getSource() == columns) - { - String columnName = null; - Object selected = columns.getSelectedItem(); - if (selected != null) - { - if (selected instanceof ValueNamePair) - { - ValueNamePair column = (ValueNamePair)selected; - columnName = column.getValue(); - } - else - { - columnName = selected.toString(); - } - } - - if (columnName != null) - { - if (log.isLoggable(Level.CONFIG)) log.config("Column: " + columnName); - int referenceType = -1; - MTable table = MTable.get(Env.getCtx(), m_tableName); - MColumn col = table.getColumn(columnName); - referenceType = col.getAD_Reference_ID(); - if (DisplayType.isLookup(referenceType) - || DisplayType.YesNo == referenceType - || DisplayType.Button == referenceType) - { - operators.setModel(new DefaultComboBoxModel(MQuery.OPERATORS_LOOKUP)); - } - else if (DisplayType.isNumeric(referenceType) - || DisplayType.isDate(referenceType) - || DisplayType.isID(referenceType)) // Note that lookups were filtered above - { - operators.setModel(new DefaultComboBoxModel(MQuery.OPERATORS_NUMBERS)); - } - else // DisplayType.isText - { - operators.setModel(new DefaultComboBoxModel(MQuery.OPERATORS)); - } - } - } - else if (e.getSource() == fQueryName) - { - Object o = fQueryName.getSelectedItem(); - if (userQueries != null && o != null) - { - String selected = o.toString(); - for (int i = 0; i < userQueries.length; i++) - { - if (userQueries[i].getName().equals(selected)) - { - parseUserQuery(userQueries[i]); - return; - } - } - } - } - else // ConfirmPanel.A_OK and enter in fields - { - if (e.getSource() == confirmPanelA.getOKButton()) - cmd_ok_Advanced(); - else if (e.getSource() == confirmPanelS.getOKButton()) - cmd_ok_Simple(); - else if (e.getSource() instanceof JTextField && - tabbedPane.getSelectedIndex() == 0) - cmd_ok_Simple(); - } - } // actionPerformed - - /** - * Parse delimited string into user query - * Old field sequence: column, operator, value, value to - * New field sequence: column, operator, value, value to, and/or, left brackets, right brackets - * @param userQuery - */ - private void parseUserQuery(MUserQuery userQuery) { - String code = userQuery.getCode(); - if (log.isLoggable(Level.FINE)) log.fine("Parse user query: " + code); - String[] segments = code.split(Pattern.quote(SEGMENT_SEPARATOR),-1); - advancedTable.stopEditor(true); - DefaultTableModel model = (DefaultTableModel)advancedTable.getModel(); - int cnt = model.getRowCount(); - for (int i = cnt - 1; i >=0; i--) - model.removeRow(i); - - for (int i = 0; i < segments.length; i++) - { - String[] fields = segments[i].split(Pattern.quote(FIELD_SEPARATOR)); - model.addRow(new Object[] {"","", null, MQuery.OPERATORS[MQuery.EQUAL_INDEX], null, null, ""}); - String columnName = null; - for (int j = 0; j < fields.length; j++) - { - // column - if (j == 0 ) - { - for (ValueNamePair vnp : columnValueNamePairs) - { - if (vnp.getValue().equals(fields[j])) - { - model.setValueAt(vnp, i, INDEX_COLUMNNAME); - columnName = fields[j]; - break; - } - } - } - // operator - else if (j == 1) - { - for (ValueNamePair vnp : MQuery.OPERATORS) - { - if (vnp.getValue().equals(fields[j])) - { - model.setValueAt(vnp, i, INDEX_OPERATOR); - break; - } - } - } - // value - else if ( j == 2 && fields[j].length() > 0 ) - { - GridField field = getTargetMField(columnName); - Object value = parseString(field, fields[j]); - model.setValueAt(value, i, INDEX_VALUE); - } - // value 2 - else if ( j == 3 && fields[j].length() > 0 ) - { - GridField field = getTargetMField(columnName); - Object value = parseString(field, fields[j]); - model.setValueAt(value, i, INDEX_VALUE2); - } - // and/or - else if (j == 4 && fields[j].length() > 0 ) - { - if ( i != 0 ) - model.setValueAt(fields[j], i, INDEX_ANDOR); - } - else if ( j == 5 && fields[j].length() > 0 ) - { - model.setValueAt(fields[j], i, INDEX_LEFTBRACKET); - } - else if ( j == 6 && fields[j].length() > 0 ) - { - model.setValueAt(fields[j], i, INDEX_RIGHTBRACKET); - } - } - } - advancedTable.invalidate(); - } - - /** - * Change Listener (tab change) - * @param e ChangeEbent - */ - public void stateChanged(ChangeEvent e) - { - // log.info( "Find.stateChanged"); - if (tabbedPane.getSelectedIndex() == 0) - this.getRootPane().setDefaultButton(confirmPanelS.getOKButton()); - else - { - initFindAdvanced(); - this.getRootPane().setDefaultButton(confirmPanelA.getOKButton()); - advancedTable.requestFocusInWindow(); - } - } // stateChanged - - /** - * Simple OK Button pressed - */ - private void cmd_ok_Simple() - { - // Create Query String - StringBuilder msglog; - - m_query = new MQuery(m_tableName); - m_query.addRestriction(Env.parseContext(Env.getCtx(), m_targetWindowNo, m_whereExtended, false)); - if (hasValue && !valueField.getText().equals("%") && valueField.getText().length() != 0) - { - String value = valueField.getText().toUpperCase(); - - if (!value.endsWith("%")) - value += "%"; - m_query.addRestriction("UPPER(Value)", MQuery.LIKE, value, valueLabel.getText(), value); - } - // - if (hasDocNo && !docNoField.getText().equals("%") && docNoField.getText().length() != 0) - { - String value = docNoField.getText().toUpperCase(); - - if (!value.endsWith("%")) - value += "%"; - m_query.addRestriction("UPPER(DocumentNo)", MQuery.LIKE, value, docNoLabel.getText(), value); - } - // - if ((hasName) && !nameField.getText().equals("%") && nameField.getText().length() != 0) - { - String value = nameField.getText().toUpperCase(); - - if (!value.endsWith("%")) - value += "%"; - m_query.addRestriction("UPPER(Name)", MQuery.LIKE, value, nameLabel.getText(), value); - } - // - if (hasDescription && !descriptionField.getText().equals("%") && descriptionField.getText().length() != 0) - { - String value = descriptionField.getText().toUpperCase(); - if (!value.endsWith("%")) - value += "%"; - m_query.addRestriction("UPPER(Description)", MQuery.LIKE, value, descriptionLabel.getText(), value); - } - // Special Editors - for (int i = 0; i < m_sEditors.size(); i++) - { - VEditor ved = (VEditor)m_sEditors.get(i); - Object value = ved.getValue(); - if (value != null && value.toString().length() > 0) - { - String ColumnName = ((Component)ved).getName (); - msglog = new StringBuilder().append(ColumnName).append("=").append(value); - if (log.isLoggable(Level.FINE)) log.fine(msglog.toString()); - - // globalqss - Carlos Ruiz - 20060711 - // fix a bug with virtualColumn + isSelectionColumn not yielding results - GridField field = getTargetMField(ColumnName.toString()); - if (field.isVirtualUIColumn()) - continue; - boolean isProductCategoryField = isProductCategoryField(field.getAD_Column_ID()); - StringBuilder ColumnSQL = new StringBuilder().append(field.getColumnSQL(false)); - // - // Be more permissive for String columns - if (isSearchLike(field)) - { - StringBuilder valueStr = new StringBuilder(value.toString().toUpperCase()); - if (!valueStr.toString().endsWith("%")) - valueStr.append("%"); - // - ColumnSQL = new StringBuilder("UPPER(").append(ColumnSQL).append(")"); - value = valueStr.toString(); - } - // - if (value.toString().indexOf('%') != -1) - m_query.addRestriction(ColumnSQL.toString(), MQuery.LIKE, value, ColumnName, ved.getDisplay()); - else if (isProductCategoryField && value instanceof Integer) - m_query.addRestriction(getSubCategoryWhereClause(((Integer) value).intValue())); - else - m_query.addRestriction(ColumnSQL.toString(), MQuery.EQUAL, value, ColumnName, ved.getDisplay()); - /* - if (value.toString().indexOf('%') != -1) - m_query.addRestriction(ColumnName, MQuery.LIKE, value, ColumnName, ved.getDisplay()); - else - m_query.addRestriction(ColumnName, MQuery.EQUAL, value, ColumnName, ved.getDisplay()); - */ - // end globalqss patch - } - } // editors - - m_isCancel = false; // teo_sarca [ 1708717 ] - // Test for no records - if (getNoOfRecords(m_query, true) != 0) - dispose(); - } // cmd_ok_Simple - - - /** - * Advanced OK Button pressed - */ - private void cmd_ok_Advanced() - { - m_isCancel = false; // teo_sarca [ 1708717 ] - // save pending - if (bSave.isEnabled()) - cmd_save(false); - if (getNoOfRecords(m_query, true) != 0) - dispose(); - } // cmd_ok_Advanced - - /** - * Cancel Button pressed - */ - private void cmd_cancel() - { - advancedTable.stopEditor(false); - log.info(""); - m_query = null; - m_total = 999999; - m_isCancel = true; // teo_sarca [ 1708717 ] - dispose(); - } // cmd_ok - - /** - * Ignore - */ - private void cmd_ignore() - { - log.info(""); - } // cmd_ignore - - /** - * New record - */ - private void cmd_new() - { - advancedTable.stopEditor(true); - DefaultTableModel model = (DefaultTableModel)advancedTable.getModel(); - int rows = model.getRowCount(); - model.addRow(new Object[] {rows == 0 ? "" : "AND","", null, MQuery.OPERATORS[MQuery.EQUAL_INDEX], null, null,""}); - advancedTable.requestFocusInWindow(); - } // cmd_new - - /** - * Save (Advanced) - */ - private void cmd_save(boolean saveQuery) - { - advancedTable.stopEditor(true); - // - m_query = new MQuery(m_tableName); - m_query.addRestriction(Env.parseContext(Env.getCtx(), m_targetWindowNo, m_whereExtended, false)); - StringBuilder code = new StringBuilder(); - int openBrackets = 0; - for (int row = 0; row < advancedTable.getRowCount(); row++) - { - // Column - Object column = advancedTable.getValueAt(row, INDEX_COLUMNNAME); - if (column == null) - continue; - String ColumnName = column instanceof ValueNamePair ? - ((ValueNamePair)column).getValue() : column.toString(); - String infoName = column.toString(); - // - GridField field = getTargetMField(ColumnName.toString()); - if (field == null || field.isVirtualUIColumn()) - continue; - boolean isProductCategoryField = isProductCategoryField(field.getAD_Column_ID()); - String ColumnSQL = field.getColumnSQL(false); - - String lBrackets = (String) advancedTable.getValueAt(row, INDEX_LEFTBRACKET); - if ( lBrackets != null ) - openBrackets += lBrackets.length(); - String rBrackets = (String) advancedTable.getValueAt(row, INDEX_RIGHTBRACKET); - if ( rBrackets != null ) - openBrackets -= rBrackets.length(); - - boolean and = true; - if ( row > 0 ) - and = !"OR".equals((String) advancedTable.getValueAt(row, INDEX_ANDOR)); - // Op - Object op = advancedTable.getValueAt(row, INDEX_OPERATOR); - if (op == null) - continue; - String Operator = ((ValueNamePair)op).getValue(); - - // Value ****** - Object value = advancedTable.getValueAt(row, INDEX_VALUE); - if (value == null) - { - if ( MQuery.OPERATORS[MQuery.EQUAL_INDEX].equals(op) - || MQuery.OPERATORS[MQuery.NOT_EQUAL_INDEX].equals(op) ) - { - m_query.addRestriction(ColumnSQL, Operator, null, - infoName, null, and, openBrackets); - - if (code.length() > 0) - code.append(SEGMENT_SEPARATOR); - code.append(ColumnName) - .append(FIELD_SEPARATOR) - .append(Operator) - .append(FIELD_SEPARATOR) - .append("") - .append(FIELD_SEPARATOR) - .append("") - .append(FIELD_SEPARATOR) - .append( and ? "AND" : "OR") - .append(FIELD_SEPARATOR) - .append(lBrackets != null ? lBrackets : "") - .append(FIELD_SEPARATOR) - .append(rBrackets != null ? rBrackets : ""); - } - else - { - continue; - } - } - else - { - Object parsedValue = parseValue(field, value); - if (parsedValue == null) - continue; - String infoDisplay = value.toString(); - if (field.isLookup()) - infoDisplay = field.getLookup().getDisplay(value); - else if (field.getDisplayType() == DisplayType.YesNo) - infoDisplay = Msg.getMsg(Env.getCtx(), infoDisplay); - // Value2 ****** - Object value2 = null; - if (MQuery.OPERATORS[MQuery.BETWEEN_INDEX].equals(op)) - { - value2 = advancedTable.getValueAt(row, INDEX_VALUE2); - if (value2 == null) - continue; - Object parsedValue2 = parseValue(field, value2); - String infoDisplay_to = value2.toString(); - if (parsedValue2 == null) - continue; - m_query.addRangeRestriction(ColumnSQL, parsedValue, parsedValue2, - infoName, infoDisplay, infoDisplay_to, and, openBrackets); - } - else if (isProductCategoryField && MQuery.OPERATORS[MQuery.EQUAL_INDEX].equals(op)) { - if (!(parsedValue instanceof Integer)) { - continue; - } - m_query - - .addRestriction(getSubCategoryWhereClause(((Integer) parsedValue).intValue()), and, openBrackets); - } - else - m_query.addRestriction(ColumnSQL, Operator, parsedValue, - infoName, infoDisplay, and, openBrackets); - - if (code.length() > 0) - code.append(SEGMENT_SEPARATOR); - code.append(ColumnName.toString()) - .append(FIELD_SEPARATOR) - .append(Operator) - .append(FIELD_SEPARATOR) - .append(value.toString()) - .append(FIELD_SEPARATOR) - .append(value2 != null ? value2.toString() : "") - .append(FIELD_SEPARATOR) - .append( and ? "AND" : "OR") - .append(FIELD_SEPARATOR) - .append(lBrackets != null ? lBrackets : "") - .append(FIELD_SEPARATOR) - .append(rBrackets != null ? rBrackets : ""); - - } - } - Object selected = fQueryName.getSelectedItem(); - if (selected != null && saveQuery) { - String name = selected.toString(); - if (Util.isEmpty(name.toString(), true)) - { - ADialog.warn(m_targetWindowNo, this, "FillMandatory", Msg.translate(Env.getCtx(), "Name")); - return; - } - MUserQuery uq = MUserQuery.get(Env.getCtx(), m_AD_Tab_ID, name); - if (uq == null && code.length() > 0) - { - uq = new MUserQuery (Env.getCtx(), 0, null); - uq.setName (name); - uq.setAD_Tab_ID(m_AD_Tab_ID); //red1 UserQuery [ 1798539 ] taking in new field from Compiere - uq.setAD_User_ID(Env.getAD_User_ID(Env.getCtx())); //red1 - [ 1798539 ] missing in Compiere delayed source :-) - } - else if (uq != null && code.length() == 0) - { - if (uq.delete(true)) - { - ADialog.info (m_targetWindowNo, this, "Deleted", name); - refreshUserQueries(); - } - else - ADialog.warn (m_targetWindowNo, this, "DeleteError", name); - return; - } - - uq.setCode (code.toString()); - uq.setAD_Table_ID (m_AD_Table_ID); - // - if (uq.save()) - { - ADialog.info (m_targetWindowNo, this, "Saved", name); - refreshUserQueries(); - } - else - ADialog.warn (m_targetWindowNo, this, "SaveError", name); - } - } // cmd_save - - private void refreshUserQueries() - { - Object selected = fQueryName.getSelectedItem(); - userQueries = MUserQuery.get(Env.getCtx(), m_AD_Tab_ID); - String[] queries = new String[userQueries.length]; - for (int i = 0; i < userQueries.length; i++) - queries[i] = userQueries[i].getName(); - fQueryName.setModel(new DefaultComboBoxModel(queries)); - fQueryName.setSelectedItem(selected); - if (fQueryName.getSelectedIndex() < 0) - fQueryName.setValue(""); - } - - /** - * Checks the given column. - * @param columnId - * @return true if the column is a product category column - */ - private boolean isProductCategoryField(int columnId) { - X_AD_Column col = new X_AD_Column(Env.getCtx(), columnId, null); - if (col.get_ID() == 0) { - return false; // column not found... - } - return MProduct.COLUMNNAME_M_Product_Category_ID.equals(col.getColumnName()); - } - - /** - * Returns a sql where string with the given category id and all of its subcategory ids. - * It is used as restriction in MQuery. - * @param productCategoryId - * @return - */ - private String getSubCategoryWhereClause(int productCategoryId) { - //if a node with this id is found later in the search we have a loop in the tree - int subTreeRootParentId = 0; - StringBuilder retString = new StringBuilder(" M_Product_Category_ID IN ("); - String sql = " SELECT M_Product_Category_ID, M_Product_Category_Parent_ID FROM M_Product_Category"; - final Vector categories = new Vector(100); - Statement stmt = null; - ResultSet rs = null; - try { - stmt = DB.createStatement(); - rs = stmt.executeQuery(sql); - while (rs.next()) { - if(rs.getInt(1)==productCategoryId) { - subTreeRootParentId = rs.getInt(2); - } - categories.add(new SimpleTreeNode(rs.getInt(1), rs.getInt(2))); - } - retString.append(getSubCategoriesString(productCategoryId, categories, subTreeRootParentId)); - retString.append(") "); - } catch (SQLException e) { - log.log(Level.SEVERE, sql, e); - retString = new StringBuilder(); - } catch (AdempiereSystemError e) { - log.log(Level.SEVERE, sql, e); - retString = new StringBuilder(); - } - finally { - DB.close(rs, stmt); - rs = null; stmt = null; - } - return retString.toString(); - } - - /** - * Recursive search for subcategories with loop detection. - * @param productCategoryId - * @param categories - * @param loopIndicatorId - * @return comma seperated list of category ids - * @throws AdempiereSystemError if a loop is detected - */ - private String getSubCategoriesString(int productCategoryId, Vector categories, int loopIndicatorId) throws AdempiereSystemError { - StringBuilder ret = new StringBuilder(); - final Iterator iter = categories.iterator(); - while (iter.hasNext()) { - SimpleTreeNode node = (SimpleTreeNode) iter.next(); - if (node.getParentId() == productCategoryId) { - if (node.getNodeId() == loopIndicatorId) { - throw new AdempiereSystemError("The product category tree contains a loop on categoryId: " + loopIndicatorId); - } - ret.append(getSubCategoriesString(node.getNodeId(), categories, loopIndicatorId)).append(","); - } - } - if (log.isLoggable(Level.FINE)) log.fine(ret.toString()); - StringBuilder msgreturn = new StringBuilder(ret.toString()).append(productCategoryId); - return msgreturn.toString(); - } - - /** - * Simple tree node class for product category tree search. - * @author Karsten Thiemann, kthiemann@adempiere.org - * - */ - private static class SimpleTreeNode { - - private int nodeId; - - private int parentId; - - public SimpleTreeNode(int nodeId, int parentId) { - this.nodeId = nodeId; - this.parentId = parentId; - } - - public int getNodeId() { - return nodeId; - } - - public int getParentId() { - return parentId; - } - } - - - /** - * Parse Value - * @param field column - * @param in value - * @return data type corrected value - */ - private Object parseValue (GridField field, Object in) - { - if (in == null) - return null; - int dt = field.getDisplayType(); - try - { - // Return Integer - if (dt == DisplayType.Integer - || (DisplayType.isID(dt) && field.getColumnName().endsWith("_ID"))) - { - if (in instanceof Integer) - return in; - int i = Integer.parseInt(in.toString()); - return Integer.valueOf(i); - } - // Return BigDecimal - else if (DisplayType.isNumeric(dt)) - { - if (in instanceof BigDecimal) - return in; - return DisplayType.getNumberFormat(dt).parse(in.toString()); - } - // Return Timestamp - else if (DisplayType.isDate(dt)) - { - if (in instanceof Timestamp) - return in; - long time = 0; - try - { - time = DisplayType.getDateFormat_JDBC().parse(in.toString()).getTime(); - return new Timestamp(time); - } - catch (Exception e) - { - StringBuilder msglog = new StringBuilder().append(in.toString()).append("(").append(in.getClass()).append(")").append(e); - log.log(Level.SEVERE, msglog.toString()); - time = DisplayType.getDateFormat(dt).parse(in.toString()).getTime(); - } - return new Timestamp(time); - } - // Return Y/N for Boolean - else if (in instanceof Boolean) - return ((Boolean)in).booleanValue() ? "Y" : "N"; - } - catch (Exception ex) - { - log.log(Level.SEVERE, "Object=" + in, ex); - String error = ex.getLocalizedMessage(); - if (error == null || error.length() == 0) - error = ex.toString(); - StringBuilder errMsg = new StringBuilder(); - errMsg.append(field.getColumnName()).append(" = ").append(in).append(" - ").append(error); - // - ADialog.error(0, this, "ValidationError", errMsg.toString()); - return null; - } - - return in; - } // parseValue - - /** - * Parse String - * @param field column - * @param in value - * @return data type corrected value - */ - private Object parseString(GridField field, String in) - { - StringBuilder msglog = new StringBuilder("Parse: ").append(field).append(":").append(in); - if (log.isLoggable(Level.FINE))log.log(Level.FINE, msglog.toString()); - if (in == null) - return null; - int dt = field.getDisplayType(); - try - { - // Return Integer - if (dt == DisplayType.Integer - || (DisplayType.isID(dt) && field.getColumnName().endsWith("_ID"))) - { - int i = Integer.parseInt(in); - return Integer.valueOf(i); - } - // Return BigDecimal - else if (DisplayType.isNumeric(dt)) - { - return DisplayType.getNumberFormat(dt).parse(in); - } - // Return Timestamp - else if (DisplayType.isDate(dt)) - { - long time = 0; - try - { - time = DisplayType.getDateFormat_JDBC().parse(in).getTime(); - return new Timestamp(time); - } - catch (Exception e) - { - msglog = new StringBuilder(in.toString()).append("(").append(in.getClass()).append(")").append(e); - log.log(Level.SEVERE,msglog.toString()); - time = DisplayType.getDateFormat(dt).parse(in).getTime(); - } - return new Timestamp(time); - } - else if (dt == DisplayType.YesNo) - return Boolean.valueOf(in); - else - return in; - } - catch (Exception ex) - { - log.log(Level.SEVERE, "Object=" + in, ex); - return null; - } - - } // parseValue - /** - * Delete - */ - private void cmd_delete() - { - advancedTable.stopEditor(false); - DefaultTableModel model = (DefaultTableModel)advancedTable.getModel(); - int row = advancedTable.getSelectedRow(); - if (row >= 0) - model.removeRow(row); - cmd_refresh(); - advancedTable.requestFocusInWindow(); - } // cmd_delete - - /** - * Refresh - */ - private void cmd_refresh() - { - advancedTable.stopEditor(false); - int records = getNoOfRecords(m_query, true); - setStatusDB (records); - statusBar.setStatusLine(""); - } // cmd_refresh - - - /************************************************************************** - * Get Query - Retrieve result - * @return String representation of query - */ - public MQuery getQuery() - { - MRole role = MRole.getDefault(); - if (role.isQueryMax(getTotalRecords()) && !m_isCancel) - { - m_query = MQuery.getNoRecordQuery (m_tableName, false); - m_total = 0; - log.warning("Query - over max"); - } - else - if (log.isLoggable(Level.INFO)) log.info("Query=" + m_query); - return m_query; - } // getQuery - - /** - * Get Total Records - * @return no of records - */ - public int getTotalRecords() - { - return m_total; - } // getTotalRecords - - /** - * Get the number of records of target tab - * @param query where clause for target tab - * @param alertZeroRecords show dialog if there are no records - * @return number of selected records; - * if the results are more then allowed this method will return 0 - */ - private int getNoOfRecords (MQuery query, boolean alertZeroRecords) - { - if (log.isLoggable(Level.CONFIG)) log.config("" + query); - StringBuilder sql = new StringBuilder("SELECT COUNT(*) FROM "); - sql.append(m_tableName); - boolean hasWhere = false; - if (m_whereExtended != null && m_whereExtended.length() > 0) - { - sql.append(" WHERE ").append(m_whereExtended); - hasWhere = true; - } - if (query != null && query.isActive()) - { - if (hasWhere) - sql.append(" AND "); - else - sql.append(" WHERE "); - sql.append(query.getWhereClause()); - } - // Add Access - String finalSQL = MRole.getDefault().addAccessSQL(sql.toString(), - m_tableName, MRole.SQL_NOTQUALIFIED, MRole.SQL_RO); - finalSQL = Env.parseContext(Env.getCtx(), m_targetWindowNo, finalSQL, false); - Env.setContext(Env.getCtx(), m_targetWindowNo, TABNO, GridTab.CTX_FindSQL, finalSQL); - - // Execute Qusery - m_total = 999999; - Statement stmt = null; - ResultSet rs = null; - try - { - stmt = DB.createStatement(); - rs = stmt.executeQuery(finalSQL); - if (rs.next()) - m_total = rs.getInt(1); - } - catch (SQLException e) - { - log.log(Level.SEVERE, finalSQL, e); - } - finally { - DB.close(rs, stmt); - rs = null; stmt = null; - } - MRole role = MRole.getDefault(); - // No Records - if (m_total == 0 && alertZeroRecords) - ADialog.info(m_targetWindowNo, this, "FindZeroRecords"); - // More then allowed - else if (query != null && role.isQueryMax(m_total)) - { - ADialog.error(m_targetWindowNo, this, "FindOverMax", - m_total + " > " + role.getMaxQueryRecords()); - m_total = 0; // return 0 if more then allowed - teo_sarca [ 1708717 ] - } - else - if (log.isLoggable(Level.CONFIG)) log.config("#" + m_total); - // - if (query != null) - statusBar.setStatusToolTip (query.getWhereClause()); - return m_total; - } // getNoOfRecords - - /** - * Display current count - * @param currentCount String representation of current/total - */ - private void setStatusDB (int currentCount) - { - StringBuilder text = new StringBuilder(" ").append(currentCount).append(" / ").append(m_total).append(" "); - statusBar.setStatusDB(text.toString()); - } // setDtatusDB - - - /************************************************************************** - * Grid Status Changed. - * @param e DataStatueEvent - */ - public void dataStatusChanged (DataStatusEvent e) - { - if (log.isLoggable(Level.CONFIG)) log.config(e.getMessage()); - // Action control - boolean changed = e.isChanged(); - bIgnore.setEnabled(changed); - bNew.setEnabled(!changed); - bSave.setEnabled(changed); - bDelete.setEnabled(!changed); - } // statusChanged - - /** - * Get Target MField - * @param columnName column name - * @return MField - */ - public GridField getTargetMField (String columnName) - { - if (columnName == null) - return null; - for (int c = 0; c < m_findFields.length; c++) - { - GridField field = m_findFields[c]; - if (columnName.equals(field.getColumnName())) - return field; - } - return null; - } // getTargetMField - - private boolean isSearchLike(GridField field) - { - return DisplayType.isText(field.getDisplayType()) - && MColumn.isSuggestSelectionColumn(field.getColumnName(), true); - } - - private static class ProxyRenderer implements TableCellRenderer - { - /** - * Creates a Find.ProxyRenderer. - */ - public ProxyRenderer(TableCellRenderer renderer) - { - this.m_renderer = renderer; - } - - /** The renderer. */ - private TableCellRenderer m_renderer; - - /** - * @see javax.swing.table.TableCellRenderer#getTableCellRendererComponent(javax.swing.JTable, java.lang.Object, boolean, boolean, int, int) - */ - public Component getTableCellRendererComponent(final JTable table, - Object value, boolean isSelected, boolean hasFocus, final int row, final int col) - { - Component comp = m_renderer.getTableCellRendererComponent(table, - value, isSelected, hasFocus, row, col); - if (hasFocus && table.isCellEditable(row, col)) - table.editCellAt(row, col); - return comp; - } - } // ProxyRenderer - -} // Find diff --git a/org.adempiere.ui.swing/src/org/compiere/apps/search/FindCellEditor.java b/org.adempiere.ui.swing/src/org/compiere/apps/search/FindCellEditor.java deleted file mode 100644 index 7002c66109..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/apps/search/FindCellEditor.java +++ /dev/null @@ -1,166 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ -package org.compiere.apps.search; - -import java.awt.Component; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.util.EventObject; - -import javax.swing.AbstractCellEditor; -import javax.swing.BorderFactory; -import javax.swing.JComboBox; -import javax.swing.JComponent; -import javax.swing.JTable; -import javax.swing.UIManager; -import javax.swing.table.TableCellEditor; - -import org.adempiere.plaf.AdempierePLAF; -import org.compiere.swing.CEditor; -import org.compiere.util.CLogger; - -/** - * Cell Editor. - *
    - *		Sequence of events:
    - *			isCellEditable
    - *			getTableCellEditor
    - *			shouldSelectCell
    - *			getCellEditorValue
    - *  
    - * A new Editor is created for editable columns. - * @author Jorg Janke - * @version $Id: VCellEditor.java,v 1.2 2006/07/30 00:51:28 jjanke Exp $ - */ -public final class FindCellEditor extends AbstractCellEditor - implements TableCellEditor, ActionListener -{ - /** - * - */ - private static final long serialVersionUID = -6542861196427426178L; - - - /** - * Constructor for Grid - * @param mField - */ - public FindCellEditor (CEditor component) - { - super(); - m_editor = component; - //m_editor.addActionListener(this); - // Click - } // FindCellEditor - - /** The Table Editor */ - private CEditor m_editor = null; - /** Table */ - @SuppressWarnings("unused") - private JTable m_table = null; - /** ClickCount */ - //private static int CLICK_TO_START = 1; - /** Logger */ - @SuppressWarnings("unused") - private static CLogger log = CLogger.getCLogger(FindCellEditor.class); - - - /** - * @param anEvent event - * @return true if editable - */ - public boolean isCellEditable (EventObject anEvent) - { - return true; - } // isCellEditable - - /** - * Sets an initial value for the editor. This will cause the editor to - * stopEditing and lose any partially edited value if the editor is editing - * when this method is called. - * Returns the component that should be added to the client's Component hierarchy. - * Once installed in the client's hierarchy this component - * will then be able to draw and receive user input. - * - * @param table - * @param value - * @param isSelected - * @param row - * @param col - * @return component - */ - public Component getTableCellEditorComponent (JTable table, Object value, boolean isSelected, int row, int col) - { - if (row >= 0) - table.setRowSelectionInterval(row,row); // force moving to new row - - m_table = table; - - // Set Value - m_editor.setValue(value); - - // Set Background/Foreground to "normal" (unselected) colors - ((JComponent)m_editor).setForeground(AdempierePLAF.getTextColor_Normal()); - - // Other UI - ((JComponent)m_editor).setFont(table.getFont()); - if ( m_editor instanceof JComboBox) { - ((JComboBox)m_editor).setBorder(BorderFactory.createEmptyBorder()); - } else { - ((JComponent)m_editor).setBorder(UIManager.getBorder("Table.focusCellHighlightBorder")); - } - // - return (Component)m_editor; - } // getTableCellEditorComponent - - /** - * The editing cell should be selected or not - * @param e event - * @return true (constant) - */ - public boolean shouldSelectCell(EventObject e) - { - return true; - } // shouldSelectCell - - /** - * Returns the value contained in the editor - * @return value - */ - public Object getCellEditorValue() - { - return m_editor.getValue(); - } // getCellEditorValue - - /** - * Action Editor - Stop Editor - * @param e event - */ - public void actionPerformed (ActionEvent e) - { - } - - /** - * Dispose - */ - public void dispose() - { - m_editor = null; - m_table = null; - } // dispose - -} // FindCellEditor diff --git a/org.adempiere.ui.swing/src/org/compiere/apps/search/FindValueEditor.java b/org.adempiere.ui.swing/src/org/compiere/apps/search/FindValueEditor.java deleted file mode 100644 index 64680efeb8..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/apps/search/FindValueEditor.java +++ /dev/null @@ -1,174 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ -package org.compiere.apps.search; - -import java.awt.Component; -import java.util.EventObject; -import java.util.logging.Level; - -import javax.swing.AbstractCellEditor; -import javax.swing.JTable; -import javax.swing.table.TableCellEditor; - -import org.compiere.grid.ed.VEditor; -import org.compiere.grid.ed.VEditorFactory; -import org.compiere.grid.ed.VNumber; -import org.compiere.grid.ed.VString; -import org.compiere.model.GridField; -import org.compiere.model.MQuery; -import org.compiere.util.CLogger; -import org.compiere.util.DisplayType; -import org.compiere.util.ValueNamePair; - -/** - * Cell editor for Find Value field. - * Editor depends on Column setting - * Has to save entries how they are used in the query, i.e. '' for strings - * - * @author Jorg Janke - * @version $Id: FindValueEditor.java,v 1.2 2006/07/30 00:51:27 jjanke Exp $ - */ -public final class FindValueEditor extends AbstractCellEditor implements TableCellEditor -{ - /** - * - */ - private static final long serialVersionUID = -4819832280924881253L; - - /** - * Constructor - * @param find find - * @param valueTo true if it is the "to" value column - */ - public FindValueEditor (Find find, boolean valueTo) - { - super(); - m_find = find; - m_valueToColumn = valueTo; - } // FindValueEditor - - /** Find Window */ - private Find m_find; - /** Value 2(to) */ - private boolean m_valueToColumn; - /** Between selected */ - private boolean m_between = false; - /** Editor */ - private VEditor m_editor = null; - /** Logger */ - private static CLogger log = CLogger.getCLogger(FindValueEditor.class); - - /** - * Get Value - * Need to convert to String - * @return current value - */ - public Object getCellEditorValue() - { - if (m_editor == null) - return null; - Object obj = m_editor.getValue(); // returns Integer, BidDecimal, String - if (log.isLoggable(Level.CONFIG)) log.config("Obj=" + obj); - return obj; - /** - if (obj == null) - return null; - // - String retValue = obj.toString(); - log.config( "FindValueEditor.getCellEditorValue"); - return retValue; - **/ - } // getCellEditorValue - - /** - * Get Editor - * - * @param table Table - * @param value Value - * @param isSelected cell is selected - * @param row row - * @param col column - * @return Editor component - */ - public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int col) - { - // log.config( "FindValueEditor.getTableCellEditorComponent", "r=" + row + ", c=" + col); - // Between - enables valueToColumn - m_between = false; - Object betweenValue = table.getModel().getValueAt(row, Find.INDEX_OPERATOR); - if (m_valueToColumn && betweenValue != null - && betweenValue.equals(MQuery.OPERATORS[MQuery.BETWEEN_INDEX])) - m_between = true; - - boolean enabled = !m_valueToColumn || (m_valueToColumn && m_between); - if (log.isLoggable(Level.CONFIG)) log.config("(" + value + ") - Enabled=" + enabled); - - if ( enabled ) - { - String columnName = null; - Object column = table.getModel().getValueAt(row, Find.INDEX_COLUMNNAME); - if (column != null) - columnName = ((ValueNamePair)column).getValue(); - - // Create Editor - GridField field = m_find.getTargetMField(columnName); - // log.fine( "Field=" + field.toStringX()); - if (field.isKey()) - m_editor = new VNumber(columnName, false, false, true, DisplayType.Integer, columnName); - else - m_editor = VEditorFactory.getEditor(field, true); - if (m_editor == null) - m_editor = new VString(); - - m_editor.setValue(value); - m_editor.setReadWrite(enabled); - m_editor.setBorder(null); - } - else - { - m_editor = null; - } - // - return (Component)m_editor; - } // getTableCellEditorComponent - - /** - * Cell Editable. - * Called before getTableCellEditorComponent - * @param e event - * @return true if editable - */ - public boolean isCellEditable (EventObject e) - { - // log.config( "FindValueEditor.isCellEditable"); - return true; - } // isCellEditable - - /** - * Cell Selectable. - * Called after getTableCellEditorComponent - * @param e event - * @return true if selectable - */ - public boolean shouldSelectCell (EventObject e) - { - boolean retValue = !m_valueToColumn || (m_valueToColumn && m_between); - // log.config( "FindValueEditor.shouldSelectCell - " + retValue); - return retValue; - } // shouldSelectCell - -} // FindValueEditor diff --git a/org.adempiere.ui.swing/src/org/compiere/apps/search/FindValueRenderer.java b/org.adempiere.ui.swing/src/org/compiere/apps/search/FindValueRenderer.java deleted file mode 100644 index 6cb0b8f279..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/apps/search/FindValueRenderer.java +++ /dev/null @@ -1,247 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ -package org.compiere.apps.search; - -import java.awt.Component; -import java.awt.Insets; -import java.sql.Date; -import java.util.logging.Level; - -import javax.swing.JCheckBox; -import javax.swing.JLabel; -import javax.swing.JTable; -import javax.swing.table.DefaultTableCellRenderer; - -import org.adempiere.plaf.AdempierePLAF; -import org.compiere.model.GridField; -import org.compiere.model.Lookup; -import org.compiere.model.MQuery; -import org.compiere.util.CLogger; -import org.compiere.util.DisplayType; -import org.compiere.util.ValueNamePair; - -/** - * Renderer for Find 'Value' Column. - * The value is how it would be used in a query, i.e. with '' for strings - * - * @author Jorg Janke - * @version $Id: FindValueRenderer.java,v 1.2 2006/07/30 00:51:27 jjanke Exp $ - */ -public final class FindValueRenderer extends DefaultTableCellRenderer -{ - /** - * - */ - private static final long serialVersionUID = 5290173817551899865L; - - /** - * Constructor - * @param find find - * @param valueTo true if it is the "to" value column - */ - public FindValueRenderer (Find find, boolean valueTo) - { - super(); - m_find = find; - m_valueToColumn = valueTo; - } // FindValueRenderer - - /** Find Window */ - private Find m_find; - /** Value 2(to) */ - private boolean m_valueToColumn; - /** Between selected */ - private boolean m_between = false; - - /** Current Row */ - private volatile String m_columnName = null; - /** CheckBox */ - private JCheckBox m_check = null; - /** Logger */ - private static CLogger log = CLogger.getCLogger(FindValueRenderer.class); - - /** - * Get Check Box - * @return check box - */ - private JCheckBox getCheck() - { - if (m_check == null) - { - m_check = new JCheckBox(); - m_check.setMargin(new Insets(0,0,0,0)); - m_check.setHorizontalAlignment(JLabel.CENTER); - } - return m_check; - } // getCheck - - - /************************************************************************* - * Get TableCell RendererComponent - * @param table table - * @param value value - * @param isSelected selected - * @param hasFocus focus - * @param row row - * @param col col - * @return renderer component (Label or CheckBox) - */ - public Component getTableCellRendererComponent(JTable table, Object value, - boolean isSelected, boolean hasFocus, int row, int col) - { - // log.config( "FindValueRenderer.getTableCellRendererComponent", "r=" + row + ", c=" + col ); - // Column - m_columnName = null; - Object column = table.getModel().getValueAt(row, Find.INDEX_COLUMNNAME); - if (column != null) { - if (column instanceof ValueNamePair) - m_columnName = ((ValueNamePair)column).getValue(); - else - m_columnName = column.toString(); - } - - // Between - enables valueToColumn - m_between = false; - Object betweenValue = table.getModel().getValueAt(row, Find.INDEX_OPERATOR); - if (m_valueToColumn && betweenValue != null - && betweenValue.equals(MQuery.OPERATORS[MQuery.BETWEEN_INDEX])) - m_between = true; - boolean enabled = !m_valueToColumn || (m_valueToColumn && m_between); - - // set Background - if (enabled) - setBackground(AdempierePLAF.getFieldBackground_Normal()); - else - setBackground(AdempierePLAF.getFieldBackground_Inactive()); - - // log.config( "FindValueRenderer.getTableCellRendererComponent - (" + value + ") - Enabled=" + enabled); - - Component c = super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, col); - if (value == null || (m_valueToColumn && !m_between)) - return c; - // - GridField field = getMField(); - if (field != null && field.getDisplayType() == DisplayType.YesNo) - { - JCheckBox cb = getCheck(); - if (value instanceof Boolean) - cb.setSelected(((Boolean)value).booleanValue()); - else - cb.setSelected(value.toString().indexOf('Y') != -1); - return cb; - } - return c; - } // getTableCellRendererComponent - - - /************************************************************************** - * Format Display Value - * @param value value - */ - protected void setValue(Object value) - { - boolean enabled = !m_valueToColumn || (m_valueToColumn && m_between); - // Log.trace (Log.l4_Data, "FindValueRenderer.setValue (" + value + ") - Enabled=" + enabled); - if (value == null || !enabled) - { - super.setValue(null); - return; - } - - String retValue = null; - - // Strip ' ' - if (value != null) - { - String str = value.toString(); - if (str.startsWith("'") && str.endsWith("'")) - { - str = str.substring(1, str.length()-1); - value = str; - } - } - - int displayType = 0; - GridField field = getMField(); - if (field != null) - displayType = field.getDisplayType(); - else - log.log(Level.SEVERE, "FindValueRenderer.setValue (" + value + ") ColumnName=" + m_columnName + " No Target Column"); - - setHorizontalAlignment(JLabel.LEFT); - // Number - if (DisplayType.isNumeric(displayType)) - { - setHorizontalAlignment(JLabel.RIGHT); - retValue = DisplayType.getNumberFormat(displayType).format(value); - } - // Date - else if (DisplayType.isDate(displayType)) - { - if (value instanceof Date) - { - retValue = DisplayType.getDateFormat(displayType).format(value); - setHorizontalAlignment(JLabel.RIGHT); - } - else if (value instanceof String) // JDBC format - { - try - { - java.util.Date date = DisplayType.getDateFormat_JDBC().parse((String)value); - retValue = DisplayType.getDateFormat(displayType).format(date); - setHorizontalAlignment(JLabel.RIGHT); - } - catch (Exception e) - { - // log.log(Level.SEVERE, "FindValueRenderer.setValue", e); - retValue = value.toString(); - } - } - else - retValue = value.toString(); - } - // Row ID - else if (displayType == DisplayType.RowID) - retValue = ""; - // Lookup - else if (DisplayType.isLookup(displayType) && field != null) - { - Lookup lookup = field.getLookup(); - if (lookup != null) - retValue = lookup.getDisplay(value); - } - // other - else - { - super.setValue(value); - return; - } - // log.config( "FindValueRenderer.setValue (" + retValue + ") - DT=" + displayType); - super.setValue(retValue); - } // setValue - - /** - * Get MField - * @return field - */ - private GridField getMField () - { - return m_find.getTargetMField(m_columnName); - } // getMField - - -} // FindValueRenderer diff --git a/org.adempiere.ui.swing/src/org/compiere/apps/search/Info.java b/org.adempiere.ui.swing/src/org/compiere/apps/search/Info.java deleted file mode 100644 index 96d01c2d5f..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/apps/search/Info.java +++ /dev/null @@ -1,1292 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ -package org.compiere.apps.search; - -import java.awt.BorderLayout; -import java.awt.Cursor; -import java.awt.Dimension; -import java.awt.Frame; -import java.awt.Toolkit; -import java.awt.event.ActionEvent; -import java.awt.event.MouseEvent; -import java.math.BigDecimal; -import java.sql.PreparedStatement; -import java.sql.ResultSet; -import java.sql.SQLException; -import java.sql.Timestamp; -import java.util.ArrayList; -import java.util.logging.Level; - -import javax.swing.ImageIcon; -import javax.swing.JButton; -import javax.swing.JFrame; -import javax.swing.JPopupMenu; -import javax.swing.JScrollPane; -import javax.swing.SwingUtilities; -import javax.swing.event.ListSelectionEvent; -import javax.swing.event.ListSelectionListener; - -import org.adempiere.client.InfoManager; -import org.compiere.apps.ADialog; -import org.compiere.apps.AEnv; -import org.compiere.apps.AWindow; -import org.compiere.apps.ConfirmPanel; -import org.compiere.apps.PrintScreenPainter; -import org.compiere.apps.StatusBar; -import org.compiere.grid.ed.Calculator; -import org.compiere.minigrid.IDColumn; -import org.compiere.minigrid.MiniTable; -import org.compiere.model.I_A_Asset; -import org.compiere.model.I_C_BPartner; -import org.compiere.model.I_C_CashLine; -import org.compiere.model.I_C_Invoice; -import org.compiere.model.I_C_Order; -import org.compiere.model.I_C_Payment; -import org.compiere.model.I_M_InOut; -import org.compiere.model.I_M_Product; -import org.compiere.model.I_S_ResourceAssignment; -import org.compiere.model.MQuery; -import org.compiere.model.MRole; -import org.compiere.model.MSysConfig; -import org.compiere.swing.CDialog; -import org.compiere.swing.CMenuItem; -import org.compiere.swing.CPanel; -import org.compiere.util.CLogger; -import org.compiere.util.DB; -import org.compiere.util.Env; -import org.compiere.util.KeyNamePair; -import org.compiere.util.Msg; - -/** - * Search Information and return selection - Base Class. - *
    - *  Structure:
    - *      parameterPanel  (JPanel) - for subclasses to add parameter fields
    - *      scrollPame      (JScrollPane)
    - *          m_table     (MiniTable)
    - *      southPanel      (JPanel)
    - *          confirmPanel
    - *          statusPanel
    - *  
    - * - * @author Jorg Janke - * @version $Id: Info.java,v 1.2 2006/07/30 00:51:27 jjanke Exp $ - * - * @author Teo Sarca - *
  • FR [ 2846869 ] Info class - add more helper methods - * https://sourceforge.net/tracker/?func=detail&atid=879335&aid=2846869&group_id=176962 - *
  • FR [ 2847305 ] Info class improvements - * https://sourceforge.net/tracker/?func=detail&aid=2847305&group_id=176962&atid=879335 - *
  • BF [ 2860556 ] Info class throws false error - * https://sourceforge.net/tracker/?func=detail&aid=2860556&group_id=176962&atid=879332 - */ -public abstract class Info extends CDialog - implements ListSelectionListener -{ - /** - * - */ - private static final long serialVersionUID = -5606614040914295869L; - - - - /** - * Factory Constructor - * @param frame parent frame - * @param modal new window is modal - * @param WindowNo window no - * @param tableName table name of the search - * @param keyColumn key column of the search - * @param value query value - * @param multiSelection allow to select more than one row - * @param whereClause fully qualified where clause for the search - * @return special or general Info Window - */ - public static Info create (Frame frame, boolean modal, int WindowNo, - String tableName, String keyColumn, String value, - boolean multiSelection, String whereClause) - { - Info info = InfoManager.create(frame, modal, WindowNo, tableName, keyColumn, value, - multiSelection, whereClause, true); - // - AEnv.positionCenterWindow(frame, info); - return info; - } // create - - /** - * Show BPartner Info (non modal) - * @param frame Parent Frame - * @param WindowNo window no - */ - public static void showBPartner (Frame frame, int WindowNo) - { - Info info = InfoManager.create(frame, false, WindowNo, - I_C_BPartner.Table_Name, I_C_BPartner.COLUMNNAME_C_BPartner_ID, - "", false, "", false); - AEnv.showCenterWindow(frame, info); - } // showBPartner - - /** - * Show Asset Info (non modal) - * @param frame Parent Frame - * @param WindowNo window no - */ - public static void showAsset (Frame frame, int WindowNo) - { - Info info = InfoManager.create(frame, false, WindowNo, - I_A_Asset.Table_Name, I_A_Asset.COLUMNNAME_A_Asset_ID, - "", false, "", false); - AEnv.showCenterWindow(frame, info); - } // showBPartner - - /** - * Show Product Info (non modal) - * @param frame Parent Frame - * @param WindowNo window no - */ - public static void showProduct (Frame frame, int WindowNo) - { - Info info = InfoManager.create(frame, false, WindowNo, - I_M_Product.Table_Name, I_M_Product.COLUMNNAME_M_Product_ID, - "", false, "", false); - AEnv.showCenterWindow(frame, info); - } // showProduct - - /** - * Show Order Info (non modal) - * @param frame Parent Frame - * @param WindowNo window no - * @param value query value - */ - public static void showOrder (Frame frame, int WindowNo, String value) - { - Info info = InfoManager.create(frame, false, WindowNo, - I_C_Order.Table_Name, I_C_Order.COLUMNNAME_C_Order_ID, - "", false, "", false); - AEnv.showCenterWindow(frame, info); - } // showOrder - - /** - * Show Invoice Info (non modal) - * @param frame Parent Frame - * @param WindowNo window no - * @param value query value - */ - public static void showInvoice (Frame frame, int WindowNo, String value) - { - Info info = InfoManager.create(frame, false, WindowNo, - I_C_Invoice.Table_Name, I_C_Invoice.COLUMNNAME_C_Invoice_ID, - "", false, "", false); - AEnv.showCenterWindow(frame, info); - } // showInvoice - - /** - * Show Shipment Info (non modal) - * @param frame Parent Frame - * @param WindowNo window no - * @param value query value - */ - public static void showInOut (Frame frame, int WindowNo, String value) - { - Info info = InfoManager.create(frame, false, WindowNo, - I_M_InOut.Table_Name, I_M_InOut.COLUMNNAME_M_InOut_ID, - "", false, "", false); - AEnv.showCenterWindow(frame, info); - } // showInOut - - /** - * Show Payment Info (non modal) - * @param frame Parent Frame - * @param WindowNo window no - * @param value query value - */ - public static void showPayment (Frame frame, int WindowNo, String value) - { - Info info = InfoManager.create(frame, false, WindowNo, - I_C_Payment.Table_Name, I_C_Payment.COLUMNNAME_C_Payment_ID, - "", false, "", false); - AEnv.showCenterWindow(frame, info); - } // showPayment - - /** - * Show Cash Line Info (non modal) - * @param frame Parent Frame - * @param WindowNo window no - * @param value query value - */ - public static void showCashLine (Frame frame, int WindowNo, String value) - { - Info info = InfoManager.create(frame, false, WindowNo, - I_C_CashLine.Table_Name, I_C_CashLine.COLUMNNAME_C_CashLine_ID, - "", false, "", false); - AEnv.showCenterWindow(frame, info); - } // showCashLine - - /** - * Show Assignment Info (non modal) - * @param frame Parent Frame - * @param WindowNo window no - * @param value query value - */ - public static void showAssignment (Frame frame, int WindowNo, String value) - { - Info info = InfoManager.create(frame, false, WindowNo, - I_S_ResourceAssignment.Table_Name, I_S_ResourceAssignment.COLUMNNAME_S_ResourceAssignment_ID, - "", false, "", false); - AEnv.showCenterWindow(frame, info); - } // showAssignment - - /** Window Width */ - Toolkit toolkit = Toolkit.getDefaultToolkit(); - Dimension screensize = toolkit.getScreenSize(); - - protected final int INFO_WIDTH = screensize.width > 1500 ? 1500 : screensize.width - 100; - protected final int SCREEN_HEIGHT = screensize.height; - - private boolean p_lookup; - - /************************************************************************** - * Detail Constructor - * @param frame parent frame - * @param modal modal - * @param WindowNo window no - * @param tableName table name - * @param keyColumn key column name - * @param multiSelection multiple selection - * @param whereClause where clause - */ - protected Info (Frame frame, boolean modal, int WindowNo, - String tableName, String keyColumn, - boolean multiSelection, String whereClause) - { - this(frame,modal,WindowNo,tableName,keyColumn,multiSelection,whereClause,true); - } - - /************************************************************************** - * Detail Constructor - * @param frame parent frame - * @param modal modal - * @param WindowNo window no - * @param tableName table name - * @param keyColumn key column name - * @param multiSelection multiple selection - * @param whereClause where clause - * @param lookup - */ - protected Info (Frame frame, boolean modal, int WindowNo, - String tableName, String keyColumn, - boolean multiSelection, String whereClause, boolean lookup) - { - super (frame, modal); - if (log.isLoggable(Level.INFO)) log.info("WinNo=" + p_WindowNo + " " + whereClause); - p_WindowNo = WindowNo; - p_tableName = tableName; - p_keyColumn = keyColumn; - p_multiSelection = multiSelection; - p_lookup = lookup; - if (whereClause == null || whereClause.indexOf('@') == -1) - p_whereClause = whereClause; - else - { - p_whereClause = Env.parseContext(Env.getCtx(), p_WindowNo, whereClause, false, false); - if (p_whereClause.length() == 0) - log.log(Level.SEVERE, "Cannot parse context= " + whereClause); - } - - try - { - jbInit(); - } - catch(Exception ex) - { - log.log(Level.SEVERE, "Info", ex); - } - } // Info - - - /** Master (owning) Window */ - protected int p_WindowNo; - /** Table Name */ - protected String p_tableName; - /** Key Column Name */ - protected String p_keyColumn; - /** Enable more than one selection */ - protected boolean p_multiSelection; - /** Specify if the records should be checked(selected) by default (multi selection mode only) */ - private boolean p_isDefaultSelected = MSysConfig.getBooleanValue(MSysConfig.INFO_DEFAULTSELECTED, false, Env.getAD_Client_ID(Env.getCtx())); - /** True if double click on a row toggles if row is selected (multi selection mode only) */ - private boolean p_doubleClickTogglesSelection = MSysConfig.getBooleanValue(MSysConfig.INFO_DOUBLECLICKTOGGLESSELECTION, false, Env.getAD_Client_ID(Env.getCtx())); - /** Initial WHERE Clause */ - protected String p_whereClause = ""; - - /** Table */ - protected MiniTable p_table = new MiniTable(); - /** Model Index of Key Column */ - private int m_keyColumnIndex = -1; - /** OK pressed */ - private boolean m_ok = false; - /** Cancel pressed - need to differentiate between OK - Cancel - Exit */ - private boolean m_cancel = false; - /** Result IDs */ - private ArrayList m_results = new ArrayList(3); - - /** Layout of Grid */ - protected Info_Column[] p_layout; - /** Main SQL Statement */ - private String m_sqlMain; - /** Count SQL Statement */ - private String m_sqlCount; - /** Order By Clause */ - private String m_sqlOrder; - - /** Loading success indicator */ - protected boolean p_loadedOK = false; - /** SO Zoom Window */ - private int m_SO_Window_ID = -1; - /** PO Zoom Window */ - private int m_PO_Window_ID = -1; - - /** Worker */ - private Worker m_worker = null; - - /** Logger */ - protected CLogger log = CLogger.getCLogger(getClass()); - - /** Static Layout */ - private CPanel southPanel = new CPanel(); - private BorderLayout southLayout = new BorderLayout(); - protected ConfirmPanel confirmPanel = new ConfirmPanel(true, true, true, true, true, true, true); - //Begin - [FR 1823612 ] Product Info Screen Improvements - protected CPanel addonPanel = new CPanel(); - //End - [FR 1823612 ] Product Info Screen Improvements - protected StatusBar statusBar = new StatusBar(); - protected CPanel parameterPanel = new CPanel(); - private JScrollPane scrollPane = new JScrollPane(); - // - private JPopupMenu popup = new JPopupMenu(); - private CMenuItem calcMenu = new CMenuItem(); - - /** - * Static Init - * @throws Exception - */ - protected void jbInit() throws Exception - { - this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); - southPanel.setLayout(southLayout); - //Begin - [FR 1823612 ] Product Info Screen Improvements - southPanel.add(addonPanel, BorderLayout.NORTH); - //End - [FR 1823612 ] Product Info Screen Improvements - southPanel.add(confirmPanel, BorderLayout.CENTER); - southPanel.add(statusBar, BorderLayout.SOUTH); - getContentPane().add(southPanel, BorderLayout.SOUTH); - this.getContentPane().add(parameterPanel, BorderLayout.NORTH); - this.getContentPane().add(scrollPane, BorderLayout.CENTER); - scrollPane.getViewport().add(p_table, null); - // - confirmPanel.addActionListener(this); - confirmPanel.getResetButton().setVisible(hasReset()); - confirmPanel.getCustomizeButton().setVisible(hasCustomize()); - confirmPanel.getHistoryButton().setVisible(hasHistory()); - confirmPanel.getZoomButton().setVisible(hasZoom()); - // - JButton print = ConfirmPanel.createPrintButton(true); - print.addActionListener(this); - confirmPanel.addButton(print); - // - popup.add(calcMenu); - calcMenu.setText(Msg.getMsg(Env.getCtx(), "Calculator")); - calcMenu.setIcon(new ImageIcon(org.compiere.Adempiere.getResource("images/Calculator16.gif"))); - calcMenu.addActionListener(this); - // - p_table.getSelectionModel().addListSelectionListener(this); - enableButtons(); - } // jbInit - - /** - * Loaded correctly - * @return true if loaded OK - */ - public boolean loadedOK() - { - return p_loadedOK; - } // loadedOK - - /** - * Set Status Line - * @param text text - * @param error error - */ - public void setStatusLine (String text, boolean error) - { - statusBar.setStatusLine(text, error); - Thread.yield(); - } // setStatusLine - - /** - * Set Status DB - * @param text text - */ - public void setStatusDB (String text) - { - statusBar.setStatusDB(text); - } // setStatusDB - - - - /************************************************************************** - * Prepare Table, Construct SQL (m_m_sqlMain, m_sqlAdd) - * and size Window - * @param layout layout array - * @param from from clause - * @param staticWhere where clause - * @param orderBy order by clause - */ - protected void prepareTable (Info_Column[] layout, String from, String staticWhere, String orderBy) - { - p_layout = layout; - StringBuffer sql = new StringBuffer ("SELECT "); - // add columns & sql - for (int i = 0; i < layout.length; i++) - { - if (i > 0) - sql.append(", "); - sql.append(layout[i].getColSQL()); - // adding ID column - if (layout[i].isIDcol()) - sql.append(",").append(layout[i].getIDcolSQL()); - // add to model - p_table.addColumn(layout[i].getColHeader()); - if (layout[i].isColorColumn()) - p_table.setColorColumn(i); - if (layout[i].getColClass() == IDColumn.class) - m_keyColumnIndex = i; - } - - // Table Selection (Invoked before setting column class so that row selection is enabled) - p_table.setRowSelectionAllowed(true); - p_table.addMouseListener(this); - p_table.setMultiSelection(p_multiSelection); - p_table.setShowTotals(true); - - // set editors (two steps) - for (int i = 0; i < layout.length; i++) - p_table.setColumnClass(i, layout[i].getColClass(), layout[i].isReadOnly(), layout[i].getColHeader()); - - sql.append( " FROM ").append(from); - // - sql.append(" WHERE ").append(staticWhere); - m_sqlMain = sql.toString(); - m_sqlCount = "SELECT COUNT(*) FROM " + from + " WHERE " + staticWhere; - // - m_sqlOrder = ""; - if (orderBy != null && orderBy.length() > 0) - m_sqlOrder = " ORDER BY " + orderBy; - - if (m_keyColumnIndex == -1) - log.log(Level.SEVERE, "No KeyColumn - " + sql); - - // Window Sizing - parameterPanel.setPreferredSize(new Dimension (INFO_WIDTH, parameterPanel.getPreferredSize().height)); - //Begin - [FR 1823612 ] Product Info Screen Improvements - scrollPane.setPreferredSize(new Dimension(INFO_WIDTH, 300)); - //End - [FR 1823612 ] Product Info Screen Improvements - } // prepareTable - - - /************************************************************************** - * Execute Query - */ - protected void executeQuery() - { - // ignore when running - if (m_worker != null && m_worker.isAlive()) - return; - // - if (!testCount()) - return; - - setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); - setStatusLine(Msg.getMsg(Env.getCtx(), "StartSearch"), false); - m_worker = new Worker(); - m_worker.start(); - } // executeQuery - - /** - * Test Row Count - * @return true if display - */ - private boolean testCount() - { - long start = System.currentTimeMillis(); - String dynWhere = getSQLWhere(); - StringBuilder sql = new StringBuilder (m_sqlCount); - if (dynWhere.length() > 0) - sql.append(dynWhere); // includes first AND - String countSql = Msg.parseTranslation(Env.getCtx(), sql.toString()); // Variables - countSql = MRole.getDefault().addAccessSQL(countSql, getTableName(), - MRole.SQL_FULLYQUALIFIED, MRole.SQL_RO); - log.finer(countSql); - PreparedStatement pstmt = null; - ResultSet rs = null; - int no = -1; - try - { - pstmt = DB.prepareStatement(countSql, null); - setParameters (pstmt, true); - rs = pstmt.executeQuery(); - if (rs.next()) - no = rs.getInt(1); - } - catch (Exception e) - { - log.log(Level.SEVERE, countSql, e); - no = -2; - } - finally { - DB.close(rs, pstmt); - rs = null; pstmt = null; - } - if (log.isLoggable(Level.FINE)) log.fine("#" + no + " - " + (System.currentTimeMillis()-start) + "ms"); - //Armen: add role checking (Patch #1694788 ) - MRole role = MRole.getDefault(); - if (role.isQueryMax(no)) - return ADialog.ask(p_WindowNo, this, "InfoHighRecordCount", String.valueOf(no)); - return true; - } // testCount - - - /** - * Save Selection - Called by dispose - */ - protected void saveSelection () - { - // Already disposed - if (p_table == null) - return; - - if (log.isLoggable(Level.CONFIG)) log.config( "OK=" + m_ok); - if (!m_ok) // did not press OK - { - m_results.clear(); - p_table.removeAll(); - p_table = null; - return; - } - - // Multi Selection - if (p_multiSelection) - { - m_results.addAll(getSelectedRowKeys()); - } - else // singleSelection - { - Integer data = getSelectedRowKey(); - if (data != null) - m_results.add(data); - } - if (log.isLoggable(Level.CONFIG)) log.config(getSelectedSQL()); - - // Save Settings of detail info screens - saveSelectionDetail(); - // Clean-up - p_table.removeAll(); - p_table = null; - } // saveSelection - - /** - * Get the key of currently selected row - * @return selected key - */ - protected Integer getSelectedRowKey() - { - ArrayList selectedDataList = getSelectedRowKeys(); - if (selectedDataList.size() == 0) - { - return null; - } - else - { - return selectedDataList.get(0); - } - } // getSelectedRowKey - - /** - * Get the keys of selected row/s based on layout defined in prepareTable - * @return IDs if selection present - * @author ashley - */ - protected ArrayList getSelectedRowKeys() - { - ArrayList selectedDataList = new ArrayList(); - - if (m_keyColumnIndex == -1) - { - return selectedDataList; - } - - if (p_multiSelection) - { - int rows = p_table.getRowCount(); - for (int row = 0; row < rows; row++) - { - // If this is the Totals row (last row), we need to skip it - teo_sarca [ 2860556 ] - if (p_table.getShowTotals() && row == rows - 1) - { - continue; - } - Object data = p_table.getModel().getValueAt(row, m_keyColumnIndex); - if (data instanceof IDColumn) - { - IDColumn dataColumn = (IDColumn)data; - if (dataColumn.isSelected()) - { - selectedDataList.add(dataColumn.getRecord_ID()); - } - } - else - { - log.severe("For multiple selection, IDColumn should be key column for selection"); - } - } - } - - if (selectedDataList.size() == 0) - { - int row = p_table.getSelectedRow(); - if (row != -1 && m_keyColumnIndex != -1) - { - Object data = p_table.getModel().getValueAt(row, m_keyColumnIndex); - if (data instanceof IDColumn) - selectedDataList.add(((IDColumn)data).getRecord_ID()); - if (data instanceof Integer) - selectedDataList.add((Integer)data); - } - } - - return selectedDataList; - } // getSelectedRowKeys - - /** - * Get selected Keys - * @return selected keys (Integers) - */ - public Object[] getSelectedKeys() - { - if (!m_ok || m_results.size() == 0) - return null; - Integer values[] = new Integer[m_results.size()]; - m_results.toArray(values); - return values; - } // getSelectedKeys; - - /** - * Get (first) selected Key - * @return selected key - */ - public Object getSelectedKey() - { - if (!m_ok || m_results.size() == 0) - return null; - return m_results.get(0); - } // getSelectedKey - - /** - * Is cancelled? - * - if pressed Cancel = true - * - if pressed OK or window closed = false - * @return true if cancelled - */ - public boolean isCancelled() - { - return m_cancel; - } // isCancelled - - /** - * Get where clause for (first) selected key - * @return WHERE Clause - */ - public String getSelectedSQL() - { - // No results - Object[] keys = getSelectedKeys(); - if (keys == null || keys.length == 0) - { - if (log.isLoggable(Level.CONFIG)) log.config("No Results - OK=" - + m_ok + ", Cancel=" + m_cancel); - return ""; - } - // - StringBuilder sb = new StringBuilder(getKeyColumn()); - if (keys.length > 1) - sb.append(" IN ("); - else - sb.append("="); - - // Add elements - for (int i = 0; i < keys.length; i++) - { - if (getKeyColumn().endsWith("_ID")) - sb.append(keys[i].toString()).append(","); - else - sb.append("'").append(keys[i].toString()).append("',"); - } - - sb.replace(sb.length()-1, sb.length(), ""); - if (keys.length > 1) - sb.append(")"); - return sb.toString(); - } // getSelectedSQL; - - - /************************************************************************** - * (Button) Action Listener & Popup Menu - * @param e event - */ - public void actionPerformed(ActionEvent e) - { - // Popup => Calculator - if (e.getSource().equals(calcMenu)) - { - BigDecimal number = null; - Object data = p_table.getSelectedValue(); - try - { - if (data != null) - { - if (data instanceof BigDecimal) - number = (BigDecimal)data; - else - number = new BigDecimal(data.toString()); - } - } - catch (Exception ex) {} - Calculator c = new Calculator(null, number); - c.setVisible(true); - return; - } // popup - - // Confirm Panel - String cmd = e.getActionCommand(); - if (cmd.equals(ConfirmPanel.A_OK)) - { - dispose(true); - } - else if (cmd.equals(ConfirmPanel.A_CANCEL)) - { - m_cancel = true; - dispose(false); - } - // - else if (cmd.equals(ConfirmPanel.A_HISTORY)) - showHistory(); - else if (cmd.equals(ConfirmPanel.A_CUSTOMIZE)) - customize(); - else if (cmd.equals(ConfirmPanel.A_ZOOM)) - zoom(); - else if (cmd.equals(ConfirmPanel.A_RESET)) - doReset(); - else if (cmd.equals(ConfirmPanel.A_PRINT)) - PrintScreenPainter.printScreen(this); - // Default - else - executeQuery(); - } // actionPerformed - - /** - * Zoom to target - * @param AD_Window_ID window id - * @param zoomQuery zoom query - */ - protected void zoom (int AD_Window_ID, MQuery zoomQuery) - { - setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); - final AWindow frame = new AWindow(null); -// AD_Window_ID = AEnv.specialZoom (AD_Window_ID, -1, zoomQuery, ""); // ZoomCondition TODO - if (!frame.initWindow(AD_Window_ID, zoomQuery)) - return; - AEnv.addToWindowManager(frame); - // Modal Window causes UI lock - if (isModal()) - { - setModal(false); // remove modal option has no effect - dispose(); // VLookup.actionButton - Result = null (not cancelled) - } - else - setCursor(Cursor.getDefaultCursor()); - - // VLookup gets info after method finishes - new Thread() - { - public void run() - { - try - { - sleep(50); - } - catch (Exception e) - { - } - AEnv.showCenterScreen(frame); - } - }.start(); - } // zoom - - /** - * Dispose (not OK) - */ - public void dispose() - { - dispose(false); - } // dispose - - /** - * Dispose and save Selection - * @param ok OK pressed - */ - public void dispose(boolean ok) - { - if (log.isLoggable(Level.CONFIG)) log.config("OK=" + ok); - m_ok = ok; - - // End Worker - if (m_worker != null) - { - // worker continues, but it does not block UI - if (m_worker.isAlive()) - m_worker.interrupt(); - if (log.isLoggable(Level.CONFIG)) log.config("Worker alive=" + m_worker.isAlive()); - } - m_worker = null; - // - saveSelection(); - removeAll(); - super.dispose(); - } // dispose - - /** - * Get Table name Synonym - * @return table name - */ - protected String getTableName() - { - return p_tableName; - } // getTableName - - /** - * Get Key Column Name - * @return column name - */ - protected String getKeyColumn() - { - return p_keyColumn; - } // getKeyColumn - - - /************************************************************************** - * Table Selection Changed - * @param e event - */ - public void valueChanged(ListSelectionEvent e) - { - if (e.getValueIsAdjusting()) - return; - enableButtons(); - } // calueChanged - - /** - * Enable OK, History, Zoom if row/s selected - * --- - * Changes: Changed the logic for accomodating multiple selection - * @author ashley - */ - protected void enableButtons () - { - boolean enable = (p_table.getSelectedRowCount() == 1); - confirmPanel.getOKButton().setEnabled(p_table.getSelectedRowCount() > 0); - - if (hasHistory()) - confirmPanel.getHistoryButton().setEnabled(enable); - if (hasZoom()) - confirmPanel.getZoomButton().setEnabled(enable); - } // enableButtons - - - /************************************************************************** - * Get dynamic WHERE part of SQL - * To be overwritten by concrete classes - * @return WHERE clause - */ - protected abstract String getSQLWhere(); - - /** - * Set Parameters for Query - * To be overwritten by concrete classes - * @param pstmt statement - * @param forCount for counting records - * @throws SQLException - */ - protected abstract void setParameters (PreparedStatement pstmt, boolean forCount) - throws SQLException; - - /** - * Reset Parameters - * To be overwritten by concrete classes - */ - protected void doReset() {} - /** - * Has Reset (false) - * To be overwritten by concrete classes - * @return true if it has reset (default false) - */ - protected boolean hasReset() {return false;} - /** - * History dialog - * To be overwritten by concrete classes - */ - protected void showHistory() {} - /** - * Has History (false) - * To be overwritten by concrete classes - * @return true if it has history (default false) - */ - protected boolean hasHistory() {return false;} - /** - * Customize dialog - * To be overwritten by concrete classes - */ - protected void customize() {} - /** - * Has Customize (false) - * To be overwritten by concrete classes - * @return true if it has customize (default false) - */ - protected boolean hasCustomize() {return false;} - /** - * Zoom action - * To be overwritten by concrete classes - */ - protected void zoom() {} - /** - * Has Zoom (false) - * To be overwritten by concrete classes - * @return true if it has zoom (default false) - */ - protected boolean hasZoom() {return false;} - /** - * Save Selection Details - * To be overwritten by concrete classes - */ - protected void saveSelectionDetail() {} - - /** - * Get Zoom Window - * @param tableName table name - * @param isSOTrx sales trx - * @return AD_Window_ID - */ - protected int getAD_Window_ID (String tableName, boolean isSOTrx) - { - if (!isSOTrx && m_PO_Window_ID > 0) - return m_PO_Window_ID; - if (m_SO_Window_ID > 0) - return m_SO_Window_ID; - // - String sql = "SELECT AD_Window_ID, PO_Window_ID FROM AD_Table WHERE TableName=?"; - PreparedStatement pstmt = null; - ResultSet rs = null; - try - { - pstmt = DB.prepareStatement(sql, null); - pstmt.setString(1, tableName); - rs = pstmt.executeQuery(); - if (rs.next()) - { - m_SO_Window_ID = rs.getInt(1); - m_PO_Window_ID = rs.getInt(2); - } - } - catch (Exception e) - { - log.log(Level.SEVERE, sql, e); - } - finally { - DB.close(rs, pstmt); - rs = null; pstmt = null; - } - // - if (!isSOTrx && m_PO_Window_ID > 0) - return m_PO_Window_ID; - return m_SO_Window_ID; - } // getAD_Window_ID - - /** - * - * @return Index of Key Column - */ - protected int getKeyColumnIndex() - { - return m_keyColumnIndex; - } - - /** - * - * @return true if OK button was pressed - */ - public boolean isOkPressed() - { - return m_ok; - } - - /** - * - * @return true if Cancel button was pressed - */ - public boolean isCancelPressed() - { - return m_cancel; - } - - /** - * Specify if the records should be checked(selected) by default. - * (for multi-selection only) - * @param value - */ - public void setDefaultSelected(boolean value) - { - p_isDefaultSelected = value; - } - - /** - * (for multi-selection only) - * @return true if records are selected by default - */ - public boolean isDefaultSelected() - { - return p_isDefaultSelected; - } - - /** - * (for multi-selection only) - * @param value true if double click should toggle record selection - */ - public void setDoubleClickTogglesSelection(boolean value) - { - p_doubleClickTogglesSelection = value; - } - - /** - * (for multi-selection only) - * @return true if double click should toggle record selection - */ - public boolean isDoubleClickTogglesSelection() - { - return p_doubleClickTogglesSelection; - } - -// reset value so that is always treated as new entry - public boolean isResetValue() - { - return false; - } - - public boolean isLookup() - { - return p_lookup; - } - - /************************************************************************** - * Mouse Clicked - * @param e event - */ - public void mouseClicked(MouseEvent e) - { - // log.fine( "Info.mouseClicked", - // "ClickCount=" + e.getClickCount() + ", Right=" + SwingUtilities.isRightMouseButton(e) - // + ", r=" + m_table.getSelectedRow() + ", c=" + m_table.getSelectedColumn()); - - // Double click with selected row => exit/zoom - if (e.getClickCount() > 1 && p_table.getSelectedRow() != -1) - { - if (isLookup() && p_multiSelection && isDoubleClickTogglesSelection()) - { - if (m_keyColumnIndex >= 0) - { - Object data = p_table.getValueAt(p_table.getSelectedRow(), m_keyColumnIndex); - if (data instanceof IDColumn) - { - IDColumn id = (IDColumn)data; - id.setSelected(!id.isSelected()); - p_table.setValueAt(data, p_table.getSelectedRow(), m_keyColumnIndex); - } - } - } - else - { - if (isLookup()) - { - dispose(true); - } - else - { - zoom(); - } - - } - } - // Right Click => start Calculator - else if (SwingUtilities.isRightMouseButton(e)) - { - popup.show(e.getComponent(), e.getX(), e.getY()); - } - } // mouseClicked - - - /** - * Worker - */ - class Worker extends Thread - { - private PreparedStatement m_pstmt = null; - private ResultSet m_rs = null; - - /** - * Do Work (load data) - */ - public void run() - { - // setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); - // setStatusLine(Msg.getMsg(Env.getCtx(), "StartSearch"), false); - long start = System.currentTimeMillis(); - - // Clear Table - p_table.setRowCount(0); - // - String dynWhere = getSQLWhere(); - StringBuilder sql = new StringBuilder (m_sqlMain); - if (dynWhere.length() > 0) - sql.append(dynWhere); // includes first AND - sql.append(m_sqlOrder); - String dataSql = Msg.parseTranslation(Env.getCtx(), sql.toString()); // Variables - dataSql = MRole.getDefault().addAccessSQL(dataSql, getTableName(), - MRole.SQL_FULLYQUALIFIED, MRole.SQL_RO); - log.finer(dataSql); - - try - { - m_pstmt = DB.prepareStatement(dataSql, null); - setParameters (m_pstmt, false); // no count - if (log.isLoggable(Level.FINE)) log.fine("Start query - " + (System.currentTimeMillis()-start) + "ms"); - m_rs = m_pstmt.executeQuery(); - if (log.isLoggable(Level.FINE)) log.fine("End query - " + (System.currentTimeMillis()-start) + "ms"); - while (m_rs.next()) - { - if (this.isInterrupted()) { - log.finer("Interrupted"); - close(); - return; - } - int row = p_table.getRowCount(); - p_table.setRowCount(row+1); - int colOffset = 1; // columns start with 1 - for (int col = 0; col < p_layout.length; col++) - { - Object data = null; - Class c = p_layout[col].getColClass(); - int colIndex = col + colOffset; - if (c == IDColumn.class) - { - data = new IDColumn(m_rs.getInt(colIndex)); - if (p_multiSelection) - ((IDColumn)data).setSelected(isDefaultSelected()); - } - else if (c == Boolean.class) - data = Boolean.valueOf("Y".equals(m_rs.getString(colIndex))); - else if (c == Timestamp.class) - data = m_rs.getTimestamp(colIndex); - else if (c == BigDecimal.class) - data = m_rs.getBigDecimal(colIndex); - else if (c == Double.class) - data = Double.valueOf(m_rs.getDouble(colIndex)); - else if (c == Integer.class) - data = Integer.valueOf(m_rs.getInt(colIndex)); - else if (c == KeyNamePair.class) - { - String display = m_rs.getString(colIndex); - int key = m_rs.getInt(colIndex+1); - data = new KeyNamePair(key, display); - colOffset++; - } - else - data = m_rs.getString(colIndex); - // store - p_table.setValueAt(data, row, col); - // if (log.isLoggable(Level.FINE)) log.fine( "r=" + row + ", c=" + col + " " + m_layout[col].getColHeader(), - // "data=" + data.toString() + " " + data.getClass().getName() + " * " + m_table.getCellRenderer(row, col)); - } - } - } - catch (SQLException e) - { - log.log(Level.SEVERE, dataSql, e); - } - close(); - // - int no = p_table.getRowCount(); - if (log.isLoggable(Level.FINE)) log.fine("#" + no + " - " + (System.currentTimeMillis()-start) + "ms"); - if(p_table.getShowTotals()) - p_table.addTotals(p_layout); - p_table.autoSize(); - // - setCursor(Cursor.getDefaultCursor()); - setStatusLine(Integer.toString(no) + " " + Msg.getMsg(Env.getCtx(), "SearchRows_EnterQuery"), false); - setStatusDB(Integer.toString(no)); - if (no == 0) { - if (log.isLoggable(Level.FINE)) log.fine(dataSql); - } else { - p_table.getSelectionModel().setSelectionInterval(0, 0); - p_table.requestFocus(); - } - } // run - - /** - * Close ResultSet and Statement - */ - private void close() { - DB.close(m_rs, m_pstmt); - m_rs = null; - m_pstmt = null; - } - - /** - * Interrupt this thread - cancel the query if still in execution - * Carlos Ruiz - globalqss - [2826660] - Info product performance BIG problem - */ - public void interrupt() { - if (m_pstmt != null) { - try { - m_pstmt.cancel(); - close(); - } catch (SQLException e) { - log.log(Level.SEVERE, "Cannot cancel SQL statement", e); - } - } - super.interrupt(); - } - } // Worker - -} // Info diff --git a/org.adempiere.ui.swing/src/org/compiere/apps/search/InfoAsset.java b/org.adempiere.ui.swing/src/org/compiere/apps/search/InfoAsset.java deleted file mode 100644 index 068af00995..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/apps/search/InfoAsset.java +++ /dev/null @@ -1,332 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ -package org.compiere.apps.search; - -import java.awt.Frame; -import java.sql.PreparedStatement; -import java.sql.SQLException; -import java.sql.Timestamp; -import java.util.logging.Level; - -import org.adempiere.plaf.AdempierePLAF; -import org.compiere.apps.AEnv; -import org.compiere.apps.ALayout; -import org.compiere.apps.ALayoutConstraint; -import org.compiere.grid.ed.VLookup; -import org.compiere.minigrid.IDColumn; -import org.compiere.model.MLookupFactory; -import org.compiere.model.MQuery; -import org.compiere.swing.CLabel; -import org.compiere.swing.CTextField; -import org.compiere.util.DisplayType; -import org.compiere.util.Env; -import org.compiere.util.Msg; - -/** - * Asset Information - * - * @author Jorg Janke - * @version $Id: InfoAsset.java,v 1.2 2006/07/30 00:51:27 jjanke Exp $ - */ -public class InfoAsset extends Info -{ - /** - * - */ - private static final long serialVersionUID = 6014685562933753813L; - - /** - * Standard Constructor - * @param frame frame - * @param modal modal - * @param WindowNo window no - * @param A_Asset_ID asset - * @param value Query Value or Name if enclosed in @ - * @param multiSelection multiple selections - * @param whereClause where clause - */ - public InfoAsset (Frame frame, boolean modal, int WindowNo, - int A_Asset_ID, String value, - boolean multiSelection, String whereClause) - { - this(frame, modal, WindowNo, A_Asset_ID, value, multiSelection, whereClause, true); - } - - /** - * Standard Constructor - * @param frame frame - * @param modal modal - * @param WindowNo window no - * @param A_Asset_ID asset - * @param value Query Value or Name if enclosed in @ - * @param multiSelection multiple selections - * @param whereClause where clause - * @param lookup - */ - public InfoAsset (Frame frame, boolean modal, int WindowNo, - int A_Asset_ID, String value, - boolean multiSelection, String whereClause, boolean lookup) - { - super (frame, modal, WindowNo, "a", "A_Asset_ID", multiSelection, whereClause); - if (log.isLoggable(Level.INFO)) log.info(value + ", ID=" + A_Asset_ID + ", WHERE=" + whereClause); - setTitle(Msg.getMsg(Env.getCtx(), "InfoAsset")); - // - statInit(); - initInfo (value, A_Asset_ID, whereClause); - // - int no = p_table.getRowCount(); - setStatusLine(Integer.toString(no) + " " + Msg.getMsg(Env.getCtx(), "SearchRows_EnterQuery"), false); - setStatusDB(Integer.toString(no)); - // AutoQuery - if (value != null && value.length() > 0) - executeQuery(); - p_loadedOK = true; - // Focus - // fieldValue.requestFocus(); - - AEnv.positionCenterWindow(frame, this); - } // InfoProduct - - /** From Clause */ - private static String s_assetFROM = "A_ASSET a" - + " LEFT OUTER JOIN M_Product p ON (a.M_Product_ID=p.M_Product_ID)" - + " LEFT OUTER JOIN C_BPartner bp ON (a.C_BPartner_ID=bp.C_BPartner_ID)" - + " LEFT OUTER JOIN AD_User u ON (a.AD_User_ID=u.AD_User_ID)"; - - /** Array of Column Info */ - private static final Info_Column[] s_assetLayout = { - new Info_Column(" ", "a.A_Asset_ID", IDColumn.class), - new Info_Column(Msg.translate(Env.getCtx(), "Value"), "a.Value", String.class), - new Info_Column(Msg.translate(Env.getCtx(), "Name"), "a.Name", String.class), - new Info_Column(Msg.translate(Env.getCtx(), "M_Product_ID"), "p.Name", String.class), - new Info_Column(Msg.translate(Env.getCtx(), "C_BPartner_ID"), "bp.Name", String.class), - new Info_Column(Msg.translate(Env.getCtx(), "AD_User_ID"), "u.Name", String.class), - new Info_Column(Msg.translate(Env.getCtx(), "AssetServiceDate"), "a.AssetServiceDate", Timestamp.class), - new Info_Column(Msg.translate(Env.getCtx(), "GuaranteeDate"), "a.GuaranteeDate", Timestamp.class), - new Info_Column(Msg.translate(Env.getCtx(), "VersionNo"), "a.VersionNo", String.class) - }; - - // - private CLabel labelValue = new CLabel(); - private CTextField fieldValue = new CTextField(10); - private CLabel labelName = new CLabel(); - private CTextField fieldName = new CTextField(10); - // - private CLabel lBPartner_ID = new CLabel(Msg.translate(Env.getCtx(), "BPartner")); - private VLookup fBPartner_ID; - private CLabel lProduct_ID = new CLabel(Msg.translate(Env.getCtx(), "Product")); - private VLookup fProduct_ID; - - /** - * Static Setup - add fields to parameterPanel - */ - private void statInit() - { - labelValue.setText(Msg.getMsg(Env.getCtx(), "Value")); - fieldValue.setBackground(AdempierePLAF.getInfoBackground()); - fieldValue.addActionListener(this); - labelName.setText(Msg.getMsg(Env.getCtx(), "Name")); - fieldName.setBackground(AdempierePLAF.getInfoBackground()); - fieldName.addActionListener(this); - // From A_Asset. - fBPartner_ID = new VLookup("C_BPartner_ID", false, false, true, - MLookupFactory.get (Env.getCtx(), p_WindowNo, 0, 8065, DisplayType.Search)); - lBPartner_ID.setLabelFor(fBPartner_ID); - fBPartner_ID.setBackground(AdempierePLAF.getInfoBackground()); - fProduct_ID = new VLookup("M_Product_ID", false, false, true, - MLookupFactory.get (Env.getCtx(), p_WindowNo, 0, 8047, DisplayType.Search)); - lProduct_ID.setLabelFor(fProduct_ID); - fProduct_ID.setBackground(AdempierePLAF.getInfoBackground()); - // - parameterPanel.setLayout(new ALayout()); - // - parameterPanel.add(labelValue, new ALayoutConstraint(0,0)); - parameterPanel.add(fieldValue, null); - parameterPanel.add(lBPartner_ID, null); - parameterPanel.add(fBPartner_ID, null); - // - parameterPanel.add(labelName, new ALayoutConstraint(1,0)); - parameterPanel.add(fieldName, null); - parameterPanel.add(lProduct_ID, null); - parameterPanel.add(fProduct_ID, null); - } // statInit - - /** - * Dynamic Init - * @param value value - * @param whereClause where clause - */ - private void initInfo (String value, int A_Asset_ID, String whereClause) - { - // Create Grid - StringBuilder where = new StringBuilder(); - where.append("a.IsActive='Y'"); - if (whereClause != null && whereClause.length() > 0) - where.append(" AND ").append(whereClause); - // - prepareTable(s_assetLayout, s_assetFROM, - where.toString(), - "a.Value"); - - // Set Value - if (value == null) - value = "%"; - if (!value.endsWith("%")) - value += "%"; - fieldValue.setText(value); - } // initInfo - - /*************************************************************************/ - - /** - * Construct SQL Where Clause and define parameters. - * (setParameters needs to set parameters) - * Includes first AND - * @return WHERE clause - */ - protected String getSQLWhere() - { - StringBuilder sql = new StringBuilder(); - // => Value - String value = fieldValue.getText().toUpperCase(); - if (!(value.equals("") || value.equals("%"))) - sql.append(" AND UPPER(a.Value) LIKE ?"); - // => Name - String name = fieldName.getText().toUpperCase(); - if (!(name.equals("") || name.equals("%"))) - sql.append (" AND UPPER(a.Name) LIKE ?"); - // C_BPartner_ID - Integer C_BPartner_ID = (Integer)fBPartner_ID.getValue(); - if (C_BPartner_ID != null) - sql.append (" AND a.C_BPartner_ID=").append(C_BPartner_ID); - // M_Product_ID - Integer M_Product_ID = (Integer)fProduct_ID.getValue(); - if (M_Product_ID != null) - sql.append (" AND a.M_Product_ID=").append(M_Product_ID); - // - return sql.toString(); - } // getSQLWhere - - /** - * Set Parameters for Query - * (as defined in getSQLWhere) - * - * @param pstmt pstmt - * @param forCount for counting records - * @throws SQLException - */ - protected void setParameters(PreparedStatement pstmt, boolean forCount) throws SQLException - { - int index = 1; - // => Value - String value = fieldValue.getText().toUpperCase(); - if (!(value.equals("") || value.equals("%"))) - { - if (!value.endsWith("%")) - value += "%"; - pstmt.setString(index++, value); - if (log.isLoggable(Level.FINE)) log.fine("Value: " + value); - } - // => Name - String name = fieldName.getText().toUpperCase(); - if (!(name.equals("") || name.equals("%"))) - { - if (!name.endsWith("%")) - name += "%"; - pstmt.setString(index++, name); - if (log.isLoggable(Level.FINE)) log.fine("Name: " + name); - } - } // setParameters - - /** - * Save Selection Details - * Get Location/Partner Info - */ - public void saveSelectionDetail() - { - int row = p_table.getSelectedRow(); - if (row == -1) - return; - - // publish for Callout to read - Integer ID = getSelectedRowKey(); - Env.setContext(Env.getCtx(), p_WindowNo, Env.TAB_INFO, "A_Asset_ID", ID == null ? "0" : ID.toString()); - } // saveSelectionDetail - - - /*************************************************************************/ - - /** - * Show History - */ - protected void showHistory() - { - log.info( "InfoAsset.showHistory"); - } // showHistory - - /** - * Has History - * @return true - */ - protected boolean hasHistory() - { - return false; - } // hasHistory - - /** - * Zoom - */ - protected void zoom() - { - log.info( "InfoAsset.zoom"); - Integer A_Asset_ID = getSelectedRowKey(); - if (A_Asset_ID == null) - return; - MQuery query = new MQuery("A_Asset"); - query.addRestriction("A_Asset_ID", MQuery.EQUAL, A_Asset_ID); - query.setRecordCount(1); - int AD_WindowNo = getAD_Window_ID("A_Asset", true); - zoom (AD_WindowNo, query); - } // zoom - - /** - * Has Zoom - * @return true - */ - protected boolean hasZoom() - { - return true; - } // hasZoom - - /** - * Customize - */ - protected void customize() - { - log.info( "InfoAsset.customize"); - } // customize - - /** - * Has Customize - * @return false - */ - protected boolean hasCustomize() - { - return false; // for now - } // hasCustomize - -} // InfoAsset diff --git a/org.adempiere.ui.swing/src/org/compiere/apps/search/InfoAssignment.java b/org.adempiere.ui.swing/src/org/compiere/apps/search/InfoAssignment.java deleted file mode 100644 index e861bfb561..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/apps/search/InfoAssignment.java +++ /dev/null @@ -1,330 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ -package org.compiere.apps.search; - -import java.awt.Frame; -import java.awt.event.ActionEvent; -import java.sql.PreparedStatement; -import java.sql.SQLException; -import java.sql.Timestamp; -import java.util.logging.Level; - -import org.compiere.apps.AEnv; -import org.compiere.apps.ALayout; -import org.compiere.apps.ALayoutConstraint; -import org.compiere.grid.ed.VDate; -import org.compiere.grid.ed.VLookup; -import org.compiere.minigrid.IDColumn; -import org.compiere.model.Lookup; -import org.compiere.model.MLookupFactory; -import static org.compiere.model.SystemIDs.*; -import org.compiere.swing.CButton; -import org.compiere.swing.CLabel; -import org.compiere.util.DB; -import org.compiere.util.DisplayType; -import org.compiere.util.Env; -import org.compiere.util.Msg; - - -/** - * View Assignments and optionally create Resource Assigments - * - * @author Jorg Janke - * @version $Id: InfoAssignment.java,v 1.2 2006/07/30 00:51:27 jjanke Exp $ - */ -public class InfoAssignment extends Info -{ - /** - * - */ - private static final long serialVersionUID = 5017170699571459745L; - - /** - * Constructor - * @param frame frame - * @param modal modal - * @param WindowNo WindowNo - * @param value Query value Name or Value if contains numbers - * @param multiSelection multiple selection - * @param whereClause where clause - */ - public InfoAssignment (Frame frame, boolean modal, int WindowNo, - String value, boolean multiSelection, String whereClause) - { - this(frame, modal, WindowNo, value, multiSelection, whereClause, true); - } - - /** - * Constructor - * @param frame frame - * @param modal modal - * @param WindowNo WindowNo - * @param value Query value Name or Value if contains numbers - * @param multiSelection multiple selection - * @param whereClause where clause - * @param lookup - */ - public InfoAssignment (Frame frame, boolean modal, int WindowNo, - String value, boolean multiSelection, String whereClause, boolean lookup) - { - super (frame, modal, WindowNo, "ra", "S_ResourceAssigment_ID", - multiSelection, whereClause, lookup); - log.info(value); - setTitle(Msg.getMsg(Env.getCtx(), "InfoAssignment")); - // - if (!initLookups()) - return; - statInit(); - initInfo (value, whereClause); - // - int no = p_table.getRowCount(); - setStatusLine(Integer.toString(no) + " " + Msg.getMsg(Env.getCtx(), "SearchRows_EnterQuery"), false); - setStatusDB(Integer.toString(no)); - // AutoQuery - // if (value != null && value.length() > 0) - // executeQuery(); - p_loadedOK = true; - - AEnv.positionCenterWindow(frame, this); - } // InfoAssignment - - // - private CLabel labelResourceType = new CLabel(Msg.translate(Env.getCtx(), "S_ResourceType_ID")); - private VLookup fieldResourceType; - private CLabel labelResource = new CLabel(Msg.translate(Env.getCtx(), "S_Resource_ID")); - private VLookup fieldResource; - private CLabel labelFrom = new CLabel(Msg.translate(Env.getCtx(), "DateFrom")); - private VDate fieldFrom = new VDate(DisplayType.Date); - private CLabel labelTo = new CLabel(Msg.translate(Env.getCtx(), "DateTo")); - private VDate fieldTo = new VDate(DisplayType.Date); - private CButton bNew = new CButton(); - - /** - * Initialize Lookups - * @return true if OK - */ - private boolean initLookups() - { - try - { - int AD_Column_ID = COLUMN_S_RESOURCE_S_RESOURCETYPE_ID; // S_Resource.S_ResourceType_ID - Lookup lookup = MLookupFactory.get (Env.getCtx(), p_WindowNo, 0, AD_Column_ID, DisplayType.TableDir); - fieldResourceType = new VLookup ("S_ResourceType_ID", false, false, true, lookup); - AD_Column_ID = COLUMN_S_RESOURCEASSIGNMENT_S_RESOURCE_ID; // S_ResourceAssignment.S_Resource_ID - lookup = MLookupFactory.get (Env.getCtx(), p_WindowNo, 0, AD_Column_ID, DisplayType.TableDir); - fieldResource = new VLookup ("S_Resource_ID", false, false, true, lookup); - } - catch (Exception e) - { - log.log(Level.SEVERE, "InfoAssignment.initLookup"); - return false; - } - // - bNew.setIcon(Env.getImageIcon("New16.gif")); - return true; - } // initLookups - - /** - * Static Setup - add fields to parameterPanel. - *
    -	 * 		ResourceType	Resource	DateTimeFrom	DateTimeTo	New
    -	 *  
    - */ - private void statInit() - { - parameterPanel.setLayout(new ALayout()); - parameterPanel.add(labelResourceType, new ALayoutConstraint(0,0)); - parameterPanel.add(labelResource, null); - parameterPanel.add(labelFrom, null); - parameterPanel.add(labelTo, null); - // parameterPanel.add(labelPhone, null); - // parameterPanel.add(checkFuzzy, null); - // - parameterPanel.add(fieldResourceType, new ALayoutConstraint(1,0)); - parameterPanel.add(fieldResource, null); - parameterPanel.add(fieldFrom, null); - parameterPanel.add(fieldTo, null); - parameterPanel.add(bNew, null); - // parameterPanel.add(checkCustomer, null); - } // statInit - - /** -SELECT rt.Name, r.Name, ra.AssignDateFrom, ra.AssignDateTo, ra.Qty, uom.UOMSymbol, ra.IsConfirmed -FROM S_ResourceAssignment ra, S_ResourceType rt, S_Resource r, C_UOM uom -WHERE ra.IsActive='Y' -AND ra.S_Resource_ID=r.S_Resource_ID -AND r.S_ResourceType_ID=rt.S_ResourceType_ID -AND rt.C_UOM_ID=uom.C_UOM_ID - */ - - /** From Clause */ - private static String s_assignmentFROM = - "S_ResourceAssignment ra, S_ResourceType rt, S_Resource r, C_UOM uom"; - private static String s_assignmentWHERE = - "ra.IsActive='Y' AND ra.S_Resource_ID=r.S_Resource_ID " - + "AND r.S_ResourceType_ID=rt.S_ResourceType_ID AND rt.C_UOM_ID=uom.C_UOM_ID"; - - /** Array of Column Info */ - private static Info_Column[] s_assignmentLayout = { - new Info_Column(" ", "ra.S_ResourceAssignment_ID", IDColumn.class), - new Info_Column(Msg.translate(Env.getCtx(), "S_ResourceType_ID"), "rt.Name", String.class), - new Info_Column(Msg.translate(Env.getCtx(), "S_Resource_ID"), "r.Name", String.class), - new Info_Column(Msg.translate(Env.getCtx(), "AssignDateFrom"), "ra.AssignDateFrom", Timestamp.class), - new Info_Column(Msg.translate(Env.getCtx(), "Qty"), "ra.Qty", Double.class), - new Info_Column(Msg.translate(Env.getCtx(), "C_UOM_ID"), "uom.UOMSymbol", String.class), - new Info_Column(Msg.translate(Env.getCtx(), "AssignDateTo"), "ra.AssignDateTo", Timestamp.class), - new Info_Column(Msg.translate(Env.getCtx(), "IsConfirmed"), "ra.IsConfirmed", Boolean.class) - }; - - - /** - * Dynamic Init - * @param value value - * @param whereClause where clause - */ - private void initInfo(String value, String whereClause) - { - // C_BPartner bp, AD_User c, C_BPartner_Location l, C_Location a - - // Create Grid - StringBuilder where = new StringBuilder(s_assignmentWHERE); - if (whereClause != null && whereClause.length() > 0) - where.append(" AND ").append(whereClause); - // - prepareTable(s_assignmentLayout, s_assignmentFROM, - where.toString(), - "rt.Name,r.Name,ra.AssignDateFrom"); - } // initInfo - - /*************************************************************************/ - - /** - * Action Listner - * - * @param e event - */ - public void actionPerformed (ActionEvent e) - { - // don't requery if fieldValue and fieldName are empty - // return; - // - super.actionPerformed(e); - } // actionPerformed - - /*************************************************************************/ - - /** - * Get dynamic WHERE part of SQL - * To be overwritten by concrete classes - * @return WHERE clause - */ - protected String getSQLWhere() - { - StringBuilder sql = new StringBuilder(); - // - Integer S_ResourceType_ID = (Integer)fieldResourceType.getValue(); - if (S_ResourceType_ID != null) - sql.append(" AND rt.S_ResourceType_ID=").append(S_ResourceType_ID.intValue()); - // - Integer S_Resource_ID = (Integer)fieldResource.getValue(); - if (S_Resource_ID != null) - sql.append(" AND r.S_Resource_ID=").append(S_Resource_ID.intValue()); - // - Timestamp ts = fieldFrom.getTimestamp(); - if (ts != null) - sql.append(" AND TRUNC(ra.AssignDateFrom)>=").append(DB.TO_DATE(ts,false)); - // - ts = fieldTo.getTimestamp(); - if (ts != null) - sql.append(" AND TRUNC(ra.AssignDateTo)<=").append(DB.TO_DATE(ts,false)); - return sql.toString(); - } // getSQLWhere - - /** - * Set Parameters for Query - * To be overwritten by concrete classes - * @param pstmt pstmt - * @param forCount for counting records - * @throws SQLException - */ - protected void setParameters (PreparedStatement pstmt, boolean forCount) throws SQLException - { - } - - /** - * History dialog - * To be overwritten by concrete classes - */ - protected void showHistory() - { - } - - /** - * Has History (false) - * To be overwritten by concrete classes - * @return true if it has history (default false) - */ - protected boolean hasHistory() - { - return false; - } - - /** - * Customize dialog - * To be overwritten by concrete classes - */ - protected void customize() - { - } - - /** - * Has Customize (false) - * To be overwritten by concrete classes - * @return true if it has customize (default false) - */ - protected boolean hasCustomize() - { - return false; - } - - /** - * Zoom action - * To be overwritten by concrete classes - */ - protected void zoom() - { - } - - /** - * Has Zoom (false) - * To be overwritten by concrete classes - * @return true if it has zoom (default false) - */ - protected boolean hasZoom() - { - return false; - } - - /** - * Save Selection Details - * To be overwritten by concrete classes - */ - protected void saveSelectionDetail() - { - } - -} // InfoAssignment diff --git a/org.adempiere.ui.swing/src/org/compiere/apps/search/InfoBPartner.java b/org.adempiere.ui.swing/src/org/compiere/apps/search/InfoBPartner.java deleted file mode 100644 index 883e4ec07b..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/apps/search/InfoBPartner.java +++ /dev/null @@ -1,506 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ -package org.compiere.apps.search; - -import java.awt.Frame; -import java.math.BigDecimal; -import java.sql.PreparedStatement; -import java.sql.SQLException; -import java.util.ArrayList; -import java.util.logging.Level; - -import org.adempiere.plaf.AdempierePLAF; -import org.compiere.apps.AEnv; -import org.compiere.apps.ALayout; -import org.compiere.apps.ALayoutConstraint; -import org.compiere.grid.ed.VCheckBox; -import org.compiere.minigrid.IDColumn; -import org.compiere.model.MQuery; -import org.compiere.swing.CLabel; -import org.compiere.swing.CTextField; -import org.compiere.util.Env; -import org.compiere.util.KeyNamePair; -import org.compiere.util.Msg; - -/** - * Search Business Partner and return selection - * - * @author Jorg Janke - * @version $Id: InfoBPartner.java,v 1.3 2006/07/30 00:51:27 jjanke Exp $ - */ -public class InfoBPartner extends Info -{ - /** - * - */ - private static final long serialVersionUID = 5550733934685665946L; - - /** - * Standard Constructor - * @param frame frame - * @param modal modal - * @param WindowNo WindowNo - * @param value Query value Name or Value if contains numbers - * @param isSOTrx if false, query vendors only - * @param multiSelection multiple selection - * @param whereClause where clause - */ - public InfoBPartner(Frame frame, boolean modal, int WindowNo, - String value, boolean isSOTrx, - boolean multiSelection, String whereClause) - { - this(frame, modal, WindowNo, value, isSOTrx, multiSelection, whereClause, true); - } - - /** - * Standard Constructor - * @param frame frame - * @param modal modal - * @param WindowNo WindowNo - * @param value Query value Name or Value if contains numbers - * @param isSOTrx if false, query vendors only - * @param multiSelection multiple selection - * @param whereClause where clause - * @param lookup - */ - public InfoBPartner(Frame frame, boolean modal, int WindowNo, - String value, boolean isSOTrx, - boolean multiSelection, String whereClause, boolean lookup) - { - super (frame, modal, WindowNo, "C_BPartner", "C_BPartner_ID", multiSelection, whereClause, lookup); - log.info(value); - setTitle(Msg.getMsg(Env.getCtx(), "InfoBPartner")); - m_isSOTrx = isSOTrx; - // - statInit(); - initInfo (value, whereClause); - // - int no = p_table.getRowCount(); - setStatusLine(Integer.toString(no) + " " + Msg.getMsg(Env.getCtx(), "SearchRows_EnterQuery"), false); - setStatusDB(Integer.toString(no)); - // AutoQuery - if (value != null && value.length() > 0) - executeQuery(); - p_loadedOK = true; - // Focus - fieldValue.requestFocus(); - - AEnv.positionCenterWindow(frame, this); - } // InfoBPartner - - /** SalesOrder Trx */ - private boolean m_isSOTrx = false; - - private int m_AD_User_ID_index = -1; - private int m_C_BPartner_Location_ID_index = -1; - - /** From Clause */ - private static String s_partnerFROM = "C_BPartner" - + " LEFT OUTER JOIN C_BPartner_Location l ON (C_BPartner.C_BPartner_ID=l.C_BPartner_ID AND l.IsActive='Y')" - + " LEFT OUTER JOIN AD_User c ON (C_BPartner.C_BPartner_ID=c.C_BPartner_ID AND (c.C_BPartner_Location_ID IS NULL OR c.C_BPartner_Location_ID=l.C_BPartner_Location_ID) AND c.IsActive='Y')" - + " LEFT OUTER JOIN C_Location a ON (l.C_Location_ID=a.C_Location_ID)"; - - /** Array of Column Info */ - private static Info_Column[] s_partnerLayout = { - new Info_Column(" ", "C_BPartner.C_BPartner_ID", IDColumn.class), - new Info_Column(Msg.translate(Env.getCtx(), "Value"), "C_BPartner.Value", String.class), - new Info_Column(Msg.translate(Env.getCtx(), "Name"), "C_BPartner.Name", String.class), - new Info_Column(Msg.translate(Env.getCtx(), "Contact"), "c.Name AS Contact", KeyNamePair.class, "c.AD_User_ID"), - new Info_Column(Msg.translate(Env.getCtx(), "SO_CreditAvailable"), "C_BPartner.SO_CreditLimit-C_BPartner.SO_CreditUsed AS SO_CreditAvailable", BigDecimal.class, true, true, null), - new Info_Column(Msg.translate(Env.getCtx(), "SO_CreditUsed"), "C_BPartner.SO_CreditUsed", BigDecimal.class), - new Info_Column(Msg.translate(Env.getCtx(), "Phone"), "c.Phone", String.class), - new Info_Column(Msg.translate(Env.getCtx(), "Postal"), "a.Postal", KeyNamePair.class, "l.C_BPartner_Location_ID"), - new Info_Column(Msg.translate(Env.getCtx(), "City"), "a.City", String.class), - new Info_Column(Msg.translate(Env.getCtx(), "TotalOpenBalance"), "C_BPartner.TotalOpenBalance", BigDecimal.class), - new Info_Column(Msg.translate(Env.getCtx(), "Revenue"), "C_BPartner.ActualLifetimeValue", BigDecimal.class), - new Info_Column(Msg.translate(Env.getCtx(), "Address1"), "a.Address1", String.class), - new Info_Column(Msg.translate(Env.getCtx(), "IsShipTo"), "l.IsShipTo", Boolean.class), - new Info_Column(Msg.translate(Env.getCtx(), "IsBillTo"), "l.IsBillTo", Boolean.class) - }; - - // - private CLabel labelValue = new CLabel(); - private CTextField fieldValue = new CTextField(10); - private CLabel labelName = new CLabel(); - private CTextField fieldName = new CTextField(10); - private CLabel labelContact = new CLabel(); - private CTextField fieldContact = new CTextField(10); - private CLabel labelEMail = new CLabel(); - private CTextField fieldEMail = new CTextField(10); - private CLabel labelPostal = new CLabel(); - private CTextField fieldPostal = new CTextField(10); - private CLabel labelPhone = new CLabel(); - private CTextField fieldPhone = new CTextField(10); - private VCheckBox checkAND = new VCheckBox(); - private VCheckBox checkCustomer = new VCheckBox(); - - /** - * Static Setup - add fields to parameterPanel - */ - private void statInit() - { - labelValue.setText(Msg.getMsg(Env.getCtx(), "Value")); - fieldValue.setBackground(AdempierePLAF.getInfoBackground()); - fieldValue.addActionListener(this); - - labelName.setText(Msg.getMsg(Env.getCtx(), "Name")); - fieldName.setBackground(AdempierePLAF.getInfoBackground()); - fieldName.addActionListener(this); - - labelContact.setText(Msg.getMsg(Env.getCtx(), "Contact")); - fieldContact.setBackground(AdempierePLAF.getInfoBackground()); - fieldContact.addActionListener(this); - - labelEMail.setText(Msg.getMsg(Env.getCtx(), "EMail")); - fieldEMail.setBackground(AdempierePLAF.getInfoBackground()); - fieldEMail.addActionListener(this); - - labelPostal.setText(Msg.getMsg(Env.getCtx(), "Postal")); - fieldPostal.setBackground(AdempierePLAF.getInfoBackground()); - fieldPostal.addActionListener(this); - - labelPhone.setText(Msg.translate(Env.getCtx(), "Phone")); - fieldPhone.setBackground(AdempierePLAF.getInfoBackground()); - fieldPhone.addActionListener(this); - - checkAND.setText(Msg.getMsg(Env.getCtx(), "SearchAND", true)); - checkAND.setToolTipText(Msg.getMsg(Env.getCtx(), "SearchANDInfo")); - checkAND.setSelected(true); - checkAND.addActionListener(this); - if (m_isSOTrx) - checkCustomer.setText(Msg.getMsg(Env.getCtx(), "OnlyCustomers")); - else - checkCustomer.setText(Msg.getMsg(Env.getCtx(), "OnlyVendors")); - checkCustomer.setSelected(true); - checkCustomer.setFocusable(false); - checkCustomer.setRequestFocusEnabled(false); - checkCustomer.addActionListener(this); - // - parameterPanel.setLayout(new ALayout()); - // - parameterPanel.add(labelValue, new ALayoutConstraint(0,0)); - parameterPanel.add(fieldValue, null); - parameterPanel.add(labelContact, null); - parameterPanel.add(fieldContact, null); - parameterPanel.add(labelPhone, null); - parameterPanel.add(fieldPhone, null); - parameterPanel.add(checkCustomer, null); - // - parameterPanel.add(labelName, new ALayoutConstraint(1,0)); - parameterPanel.add(fieldName, null); - parameterPanel.add(labelEMail, null); - parameterPanel.add(fieldEMail, null); - parameterPanel.add(labelPostal, null); - parameterPanel.add(fieldPostal, null); - parameterPanel.add(checkAND, null); - } // statInit - - /** - * Dynamic Init - * @param value value - * @param whereClause where clause - */ - private void initInfo(String value, String whereClause) - { - /** From - C_BPartner - LEFT OUTER JOIN C_BPartner_Location l ON (C_BPartner.C_BPartner_ID=l.C_BPartner_ID AND l.IsActive='Y') - LEFT OUTER JOIN AD_User c ON (C_BPartner.C_BPartner_ID=c.C_BPartner_ID AND (c.C_BPartner_Location_ID IS NULL OR c.C_BPartner_Location_ID=l.C_BPartner_Location_ID) AND c.IsActive='Y') - LEFT OUTER JOIN C_Location a ON (l.C_Location_ID=a.C_Location_ID) - **/ - - // Create Grid - StringBuilder where = new StringBuilder(); - where.append("C_BPartner.IsSummary='N' AND C_BPartner.IsActive='Y'"); - if (whereClause != null && whereClause.length() > 0) - where.append(" AND ").append(whereClause); - // - prepareTable(s_partnerLayout, s_partnerFROM, - where.toString(), - "C_BPartner.Value"); - - // Get indexes - for (int i = 0; i < p_layout.length; i++) - { - if (p_layout[i].getIDcolSQL().indexOf("AD_User_ID") != -1) - m_AD_User_ID_index = i; - if (p_layout[i].getIDcolSQL().indexOf("C_BPartner_Location_ID") != -1) - m_C_BPartner_Location_ID_index = i; - } - - // Set Value - if (value == null) - value = "%"; - if (!value.endsWith("%")) - value += "%"; - - // Put query string in Name if not numeric - if (value.equals("%")) - fieldName.setText(value); - // No Numbers entered - else if ((value.indexOf('0')+value.indexOf('1')+value.indexOf('2')+value.indexOf('3')+value.indexOf('4') +value.indexOf('5') - +value.indexOf('6')+value.indexOf('7')+value.indexOf('8')+value.indexOf('9')) == -10) - { - if (value.startsWith("%")) - fieldName.setText(value); - else - fieldName.setText("%" + value); - } - // Number entered - else - fieldValue.setText(value); - } // initInfo - - /*************************************************************************/ - - /** - * Construct SQL Where Clause and define parameters. - * (setParameters needs to set parameters) - * Includes first AND - * @return WHERE clause - */ - protected String getSQLWhere() - { - ArrayList list = new ArrayList(); - // => Value - String value = fieldValue.getText().toUpperCase(); - if (!(value.equals("") || value.equals("%"))) - list.add ("UPPER(C_BPartner.Value) LIKE ?"); - // => Name - String name = fieldName.getText().toUpperCase(); - if (!(name.equals("") || name.equals("%"))) - list.add ("UPPER(C_BPartner.Name) LIKE ?"); - // => Contact - String contact = fieldContact.getText().toUpperCase(); - if (!(contact.equals("") || contact.equals("%"))) - list.add ("UPPER(c.Name) LIKE ?"); - // => EMail - String email = fieldEMail.getText().toUpperCase(); - if (!(email.equals("") || email.equals("%"))) - list.add ("UPPER(c.EMail) LIKE ?"); - // => Phone - String phone = fieldPhone.getText().toUpperCase(); - if (!(phone.equals("") || phone.equals("%"))) - list.add ("UPPER(c.Phone) LIKE ?"); - // => Postal - String postal = fieldPostal.getText().toUpperCase(); - if (!(postal.equals("") || postal.equals("%"))) - list.add ("UPPER(a.Postal) LIKE ?"); - - StringBuilder sql = new StringBuilder(); - int size = list.size(); - // Just one - if (size == 1) - sql.append(" AND ").append(list.get(0)); - else if (size > 1) - { - boolean AND = checkAND.isSelected(); - sql.append(" AND "); - if (!AND) - sql.append("("); - for (int i = 0; i < size; i++) - { - if (i > 0) - sql.append(AND ? " AND " : " OR "); - sql.append(list.get(i)); - } - if (!AND) - sql.append(")"); - } - - // Static SQL - if (checkCustomer.isSelected()) - { - sql.append(" AND "); - if (m_isSOTrx) - sql.append ("C_BPartner.IsCustomer='Y'"); - else - sql.append ("C_BPartner.IsVendor='Y'"); - } - return sql.toString(); - } // getSQLWhere - - /** - * Set Parameters for Query. - * (as defined in getSQLWhere) - * @param pstmt pstmt - * @param forCount for counting records - * @throws SQLException - */ - protected void setParameters(PreparedStatement pstmt, boolean forCount) throws SQLException - { - int index = 1; - // => Value - String value = fieldValue.getText().toUpperCase(); - if (!(value.equals("") || value.equals("%"))) - { - if (!value.endsWith("%")) - value += "%"; - pstmt.setString(index++, value); - if (log.isLoggable(Level.FINE)) log.fine("Value: " + value); - } - // => Name - String name = fieldName.getText().toUpperCase(); - if (!(name.equals("") || name.equals("%"))) - { - if (!name.endsWith("%")) - name += "%"; - pstmt.setString(index++, name); - if (log.isLoggable(Level.FINE)) log.fine("Name: " + name); - } - // => Contact - String contact = fieldContact.getText().toUpperCase(); - if (!(contact.equals("") || contact.equals("%"))) - { - if (!contact.endsWith("%")) - contact += "%"; - pstmt.setString(index++, contact); - if (log.isLoggable(Level.FINE)) log.fine("Contact: " + contact); - } - // => EMail - String email = fieldEMail.getText().toUpperCase(); - if (!(email.equals("") || email.equals("%"))) - { - if (!email.endsWith("%")) - email += "%"; - pstmt.setString(index++, email); - if (log.isLoggable(Level.FINE)) log.fine("EMail: " + email); - } - // => Phone - String phone = fieldPhone.getText().toUpperCase(); - if (!(phone.equals("") || phone.equals("%"))) - { - if (!phone.endsWith("%")) - phone += "%"; - pstmt.setString(index++, phone); - if (log.isLoggable(Level.FINE)) log.fine("Phone: " + phone); - } - // => Postal - String postal = fieldPostal.getText().toUpperCase(); - if (!(postal.equals("") || postal.equals("%"))) - { - if (!postal.endsWith("%")) - postal += "%"; - pstmt.setString(index++, postal); - if (log.isLoggable(Level.FINE)) log.fine("Postal: " + postal); - } - } // setParameters - - /*************************************************************************/ - - /** - * Save Selection Details - * Get Location/Partner Info - */ - public void saveSelectionDetail() - { - int row = p_table.getSelectedRow(); - if (row == -1) - return; - - int AD_User_ID = 0; - int C_BPartner_Location_ID = 0; - - if (m_AD_User_ID_index != -1) - { - Object data = p_table.getModel().getValueAt(row, m_AD_User_ID_index); - if (data instanceof KeyNamePair) - AD_User_ID = ((KeyNamePair)data).getKey(); - } - if (m_C_BPartner_Location_ID_index != -1) - { - Object data = p_table.getModel().getValueAt(row, m_C_BPartner_Location_ID_index); - if (data instanceof KeyNamePair) - C_BPartner_Location_ID = ((KeyNamePair)data).getKey(); - } - // publish for Callout to read - Integer ID = getSelectedRowKey(); - Env.setContext(Env.getCtx(), p_WindowNo, Env.TAB_INFO, "C_BPartner_ID", ID == null ? "0" : ID.toString()); - Env.setContext(Env.getCtx(), p_WindowNo, Env.TAB_INFO, "AD_User_ID", String.valueOf(AD_User_ID)); - Env.setContext(Env.getCtx(), p_WindowNo, Env.TAB_INFO, "C_BPartner_Location_ID", String.valueOf(C_BPartner_Location_ID)); - } // saveSelectionDetail - - - /************************************************************************** - * Show History - */ - protected void showHistory() - { - log.info(""); - Integer C_BPartner_ID = getSelectedRowKey(); - if (C_BPartner_ID == null) - return; - InvoiceHistory ih = new InvoiceHistory (this, C_BPartner_ID.intValue(), - 0, 0, 0); - ih.setVisible(true); - ih = null; - } // showHistory - - /** - * Has History - * @return true - */ - protected boolean hasHistory() - { - return true; - } // hasHistory - - /** - * Zoom - */ - protected void zoom() - { - log.info( "InfoBPartner.zoom"); - Integer C_BPartner_ID = getSelectedRowKey(); - if (C_BPartner_ID == null) - return; - // AEnv.zoom(MBPartner.Table_ID, C_BPartner_ID.intValue(), true); // SO - - MQuery query = new MQuery("C_BPartner"); - query.addRestriction("C_BPartner_ID", MQuery.EQUAL, C_BPartner_ID); - query.setRecordCount(1); - int AD_WindowNo = getAD_Window_ID("C_BPartner", true); // SO - zoom (AD_WindowNo, query); - } // zoom - - /** - * Has Zoom - * @return true - */ - protected boolean hasZoom() - { - return true; - } // hasZoom - - /** - * Customize - */ - protected void customize() - { - log.info( "InfoBPartner.customize"); - } // customize - - /** - * Has Customize - * @return false - */ - protected boolean hasCustomize() - { - return false; // for now - } // hasCustomize - -} // InfoBPartner diff --git a/org.adempiere.ui.swing/src/org/compiere/apps/search/InfoCashLine.java b/org.adempiere.ui.swing/src/org/compiere/apps/search/InfoCashLine.java deleted file mode 100644 index f22cb97439..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/apps/search/InfoCashLine.java +++ /dev/null @@ -1,398 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ -package org.compiere.apps.search; - -import java.awt.Frame; -import java.math.BigDecimal; -import java.sql.PreparedStatement; -import java.sql.SQLException; -import java.sql.Timestamp; -import java.util.logging.Level; - -import org.adempiere.plaf.AdempierePLAF; -import org.compiere.apps.ALayout; -import org.compiere.apps.ALayoutConstraint; -import org.compiere.grid.ed.VDate; -import org.compiere.grid.ed.VLookup; -import org.compiere.grid.ed.VNumber; -import org.compiere.minigrid.IDColumn; -import org.compiere.model.MCashLine; -import org.compiere.model.MColumn; -import org.compiere.model.MLookupFactory; -import org.compiere.swing.CCheckBox; -import org.compiere.swing.CLabel; -import org.compiere.swing.CTextField; -import org.compiere.util.DB; -import org.compiere.util.DisplayType; -import org.compiere.util.Env; -import org.compiere.util.Msg; -import org.compiere.util.Util; - -/** - * Info Payment - * - * @author Jorg Janke - * @version $Id: InfoCashLine.java,v 1.2 2006/07/30 00:51:27 jjanke Exp $ - * - * @author Teo Sarca, SC ARHIPAC SERVICE SRL - *
  • FR [ 1976044 ] Info Cash Line: search by Charge - */ -public class InfoCashLine extends Info -{ - /** - * - */ - private static final long serialVersionUID = -3315036454469996930L; - - /** - * Detail Protected Contructor - * @param frame parent frame - * @param modal modal - * @param WindowNo window no - * @param value query value - * @param multiSelection multiple selections - * @param whereClause whwre clause - */ - public InfoCashLine(Frame frame, boolean modal, int WindowNo, String value, - boolean multiSelection, String whereClause) - { - super (frame, modal, WindowNo, "cl", "C_CashLine_ID", multiSelection, whereClause); - log.info( "InfoCashLine"); - setTitle(Msg.getMsg(Env.getCtx(), "InfoCashLine")); - // - try - { - statInit(); - p_loadedOK = initInfo (); - } - catch (Exception e) - { - return; - } - // - int no = p_table.getRowCount(); - setStatusLine(Integer.toString(no) + " " + Msg.getMsg(Env.getCtx(), "SearchRows_EnterQuery"), false); - setStatusDB(Integer.toString(no)); - if (value != null && value.length() > 0) - { - fName.setValue(value); - executeQuery(); - } - // - pack(); - // Focus - fName.requestFocus(); - } // InfoCashLine - - - // Static Info - private CLabel lName = new CLabel(Msg.translate(Env.getCtx(), "Name")); - private CTextField fName = new CTextField(10); - private CLabel lCashBook_ID = new CLabel(Msg.translate(Env.getCtx(), "C_CashBook_ID")); - private VLookup fCashBook_ID; -// private CLabel lOrg_ID = new CLabel(Msg.translate(Env.getCtx(), "AD_Org_ID")); -// private VLookup fOrg_ID; - private CLabel lInvoice_ID = new CLabel(Msg.translate(Env.getCtx(), "C_Invoice_ID")); - private VLookup fInvoice_ID; - private CLabel lCharge_ID = new CLabel(Msg.translate(Env.getCtx(), "C_Charge_ID")); - private VLookup fCharge_ID; - private CLabel lBankAccount_ID = new CLabel(Msg.translate(Env.getCtx(), "C_BankAccount_ID")); - private VLookup fBankAccount_ID; - private CCheckBox cbAbsolute = new CCheckBox (Msg.translate(Env.getCtx(), "AbsoluteAmt")); - // - private CLabel lDateFrom = new CLabel(Msg.translate(Env.getCtx(), "StatementDate")); - private VDate fDateFrom = new VDate("DateFrom", false, false, true, DisplayType.Date, Msg.translate(Env.getCtx(), "DateFrom")); - private CLabel lDateTo = new CLabel("-"); - private VDate fDateTo = new VDate("DateTo", false, false, true, DisplayType.Date, Msg.translate(Env.getCtx(), "DateTo")); - private CLabel lAmtFrom = new CLabel(Msg.translate(Env.getCtx(), "Amount")); - private VNumber fAmtFrom = new VNumber("AmtFrom", false, false, true, DisplayType.Amount, Msg.translate(Env.getCtx(), "AmtFrom")); - private CLabel lAmtTo = new CLabel("-"); - private VNumber fAmtTo = new VNumber("AmtTo", false, false, true, DisplayType.Amount, Msg.translate(Env.getCtx(), "AmtTo")); - - /** Array of Column Info */ - private static final Info_Column[] s_cashLayout = { - new Info_Column(" ", "cl.C_CashLine_ID", IDColumn.class), - new Info_Column(Msg.translate(Env.getCtx(), "C_CashBook_ID"), - "(SELECT cb.Name FROM C_CashBook cb WHERE cb.C_CashBook_ID=c.C_CashBook_ID)", String.class), - new Info_Column(Msg.translate(Env.getCtx(), "Name"), - "c.Name", String.class), - new Info_Column(Msg.translate(Env.getCtx(), "StatementDate"), - "c.StatementDate", Timestamp.class), - new Info_Column(Msg.translate(Env.getCtx(), "Line"), - "cl.Line", Integer.class), - // new Info_Column(Msg.translate(Env.getCtx(), "C_Currency_ID"), - // "(SELECT ISO_Code FROM C_Currency c WHERE c.C_Currency_ID=cl.C_Currency_ID)", String.class), - new Info_Column(Msg.translate(Env.getCtx(), "Amount"), - "cl.Amount", BigDecimal.class, true, true, null), - // - new Info_Column(Msg.translate(Env.getCtx(), "C_Invoice_ID"), - "(SELECT i.DocumentNo||'_'||" + DB.TO_CHAR("i.DateInvoiced",DisplayType.Date,Env.getAD_Language(Env.getCtx())) - + "||'_'||" + DB.TO_CHAR("i.GrandTotal",DisplayType.Amount,Env.getAD_Language(Env.getCtx())) - + " FROM C_Invoice i WHERE i.C_Invoice_ID=cl.C_Invoice_ID)", String.class), - new Info_Column(Msg.translate(Env.getCtx(), "C_BankAccount_ID"), - "(SELECT b.Name||' '||ba.AccountNo FROM C_Bank b, C_BankAccount ba WHERE b.C_Bank_ID=ba.C_Bank_ID AND ba.C_BankAccount_ID=cl.C_BankAccount_ID)", String.class), - new Info_Column(Msg.translate(Env.getCtx(), "C_Charge_ID"), - "(SELECT ca.Name FROM C_Charge ca WHERE ca.C_Charge_ID=cl.C_Charge_ID)", String.class), - // - new Info_Column(Msg.translate(Env.getCtx(), "DiscountAmt"), - "cl.DiscountAmt", BigDecimal.class), - new Info_Column(Msg.translate(Env.getCtx(), "WriteOffAmt"), - "cl.WriteOffAmt", BigDecimal.class), - new Info_Column(Msg.translate(Env.getCtx(), "Description"), - "cl.Description", String.class) - }; - - /** - * Static Setup - add fields to parameterPanel - * @throws Exception if Lookups cannot be created - */ - private void statInit() throws Exception - { - lName.setLabelFor(fName); - fName.setBackground(AdempierePLAF.getInfoBackground()); - fName.addActionListener(this); - // - // 5249 - C_Cash.C_CashBook_ID - fCashBook_ID = new VLookup("C_CashBook_ID", false, false, true, - MLookupFactory.get (Env.getCtx(), p_WindowNo, 0, 5249, DisplayType.TableDir)); - lCashBook_ID.setLabelFor(fCashBook_ID); - fCashBook_ID.setBackground(AdempierePLAF.getInfoBackground()); - // 5354 - C_CashLine.C_Invoice_ID - fInvoice_ID = new VLookup("C_Invoice_ID", false, false, true, - MLookupFactory.get (Env.getCtx(), p_WindowNo, 0, 5354, DisplayType.Search)); - lInvoice_ID.setLabelFor(fInvoice_ID); - fInvoice_ID.setBackground(AdempierePLAF.getInfoBackground()); - // 5295 - C_CashLine.C_BankAccount_ID - fBankAccount_ID = new VLookup("C_BankAccount_ID", false, false, true, - MLookupFactory.get (Env.getCtx(), p_WindowNo, 0, 5295, DisplayType.TableDir)); - lBankAccount_ID.setLabelFor(fBankAccount_ID); - fBankAccount_ID.setBackground(AdempierePLAF.getInfoBackground()); - // 5296 - C_CashLine.C_Charge_ID - fCharge_ID = new VLookup(MCashLine.COLUMNNAME_C_Charge_ID, false, false, true, - MLookupFactory.get(Env.getCtx(), p_WindowNo, 0, - MColumn.getColumn_ID(MCashLine.Table_Name, MCashLine.COLUMNNAME_C_Charge_ID), - DisplayType.TableDir) ); - // 5291 - C_CashLine.C_Cash_ID - // - lDateFrom.setLabelFor(fDateFrom); - fDateFrom.setBackground(AdempierePLAF.getInfoBackground()); - fDateFrom.setToolTipText(Msg.translate(Env.getCtx(), "DateFrom")); - lDateTo.setLabelFor(fDateTo); - fDateTo.setBackground(AdempierePLAF.getInfoBackground()); - fDateTo.setToolTipText(Msg.translate(Env.getCtx(), "DateTo")); - lAmtFrom.setLabelFor(fAmtFrom); - fAmtFrom.setBackground(AdempierePLAF.getInfoBackground()); - fAmtFrom.setToolTipText(Msg.translate(Env.getCtx(), "AmtFrom")); - lAmtTo.setLabelFor(fAmtTo); - fAmtTo.setBackground(AdempierePLAF.getInfoBackground()); - fAmtTo.setToolTipText(Msg.translate(Env.getCtx(), "AmtTo")); - // - parameterPanel.setLayout(new ALayout()); - // First Row - parameterPanel.add(lCashBook_ID, new ALayoutConstraint(0,0)); - parameterPanel.add(fCashBook_ID, null); - parameterPanel.add(lName, null); - parameterPanel.add(fName, null); - parameterPanel.add(cbAbsolute, new ALayoutConstraint(0,5)); - // 2nd Row - parameterPanel.add(lInvoice_ID, new ALayoutConstraint(1,0)); - parameterPanel.add(fInvoice_ID, null); - parameterPanel.add(lDateFrom, null); - parameterPanel.add(fDateFrom, null); - parameterPanel.add(lDateTo, null); - parameterPanel.add(fDateTo, null); - // 3rd Row - parameterPanel.add(lBankAccount_ID, new ALayoutConstraint(2,0)); - parameterPanel.add(fBankAccount_ID, null); - parameterPanel.add(lAmtFrom, null); - parameterPanel.add(fAmtFrom, null); - parameterPanel.add(lAmtTo, null); - parameterPanel.add(fAmtTo, null); - // 4th Row - parameterPanel.add(lCharge_ID, new ALayoutConstraint(3,0)); - parameterPanel.add(fCharge_ID, null); - } // statInit - - /** - * General Init - * @return true, if success - */ - private boolean initInfo () - { - // prepare table - StringBuilder where = new StringBuilder("cl.IsActive='Y'"); - if (p_whereClause.length() > 0) - where.append(" AND ").append(Util.replace(p_whereClause, "C_CashLine.", "cl.")); - prepareTable (s_cashLayout, - "C_CashLine cl INNER JOIN C_Cash c ON (cl.C_Cash_ID=c.C_Cash_ID)", - where.toString(), - "2,3,cl.Line"); - - return true; - } // initInfo - - - /************************************************************************** - * Construct SQL Where Clause and define parameters - * (setParameters needs to set parameters) - * Includes first AND - * @return sql where clause - */ - protected String getSQLWhere() - { - StringBuilder sql = new StringBuilder(); - if (fName.getText().length() > 0) - sql.append(" AND UPPER(c.Name) LIKE ?"); - // - if (fCashBook_ID.getValue() != null) - sql.append(" AND c.C_CashBook_ID=?"); - // - if (fInvoice_ID.getValue() != null) - sql.append(" AND cl.C_Invoice_ID=?"); - // - if (fDateFrom.getValue() != null || fDateTo.getValue() != null) - { - Timestamp from = (Timestamp)fDateFrom.getValue(); - Timestamp to = (Timestamp)fDateTo.getValue(); - if (from == null && to != null) - sql.append(" AND TRUNC(c.StatementDate) <= ?"); - else if (from != null && to == null) - sql.append(" AND TRUNC(c.StatementDate) >= ?"); - else if (from != null && to != null) - sql.append(" AND TRUNC(c.StatementDate) BETWEEN ? AND ?"); - } - // - if (fAmtFrom.getValue() != null || fAmtTo.getValue() != null) - { - BigDecimal from = (BigDecimal)fAmtFrom.getValue(); - BigDecimal to = (BigDecimal)fAmtTo.getValue(); - if (cbAbsolute.isSelected()) - sql.append(" AND ABS(cl.Amount)"); - else - sql.append(" AND cl.Amount"); - // - if (from == null && to != null) - sql.append(" <=?"); - else if (from != null && to == null) - sql.append(" >=?"); - else if (from != null && to != null) - { - if (from.compareTo(to) == 0) - sql.append(" =?"); - else - sql.append(" BETWEEN ? AND ?"); - } - } - if (fCharge_ID.getValue() != null) { - sql.append(" AND cl.").append(MCashLine.COLUMNNAME_C_Charge_ID).append("=?"); - } - - if (log.isLoggable(Level.FINE)) log.fine(sql.toString()); - return sql.toString(); - } // getSQLWhere - - /** - * Set Parameters for Query. - * (as defined in getSQLWhere) - * @param pstmt statement - * @param forCount for counting records - * @throws SQLException - */ - protected void setParameters(PreparedStatement pstmt, boolean forCount) throws SQLException - { - int index = 1; - if (fName.getText().length() > 0) - pstmt.setString(index++, getSQLText(fName)); - // - if (fCashBook_ID.getValue() != null) - { - Integer cb = (Integer)fCashBook_ID.getValue(); - pstmt.setInt(index++, cb.intValue()); - if (log.isLoggable(Level.FINE)) log.fine("CashBook=" + cb); - } - // - if (fInvoice_ID.getValue() != null) - { - Integer i = (Integer)fInvoice_ID.getValue(); - pstmt.setInt(index++, i.intValue()); - if (log.isLoggable(Level.FINE)) log.fine("Invoice=" + i); - } - // - if (fDateFrom.getValue() != null || fDateTo.getValue() != null) - { - Timestamp from = (Timestamp)fDateFrom.getValue(); - Timestamp to = (Timestamp)fDateTo.getValue(); - if (log.isLoggable(Level.FINE)) log.fine("Date From=" + from + ", To=" + to); - if (from == null && to != null) - pstmt.setTimestamp(index++, to); - else if (from != null && to == null) - pstmt.setTimestamp(index++, from); - else if (from != null && to != null) - { - pstmt.setTimestamp(index++, from); - pstmt.setTimestamp(index++, to); - } - } - // - if (fAmtFrom.getValue() != null || fAmtTo.getValue() != null) - { - BigDecimal from = (BigDecimal)fAmtFrom.getValue(); - BigDecimal to = (BigDecimal)fAmtTo.getValue(); - if (cbAbsolute.isSelected()) - { - if (from != null) - from = from.abs(); - if (to != null) - to = to.abs(); - } - if (log.isLoggable(Level.FINE)) log.fine("Amt From=" + from + ", To=" + to + ", Absolute=" + cbAbsolute.isSelected()); - if (from == null && to != null) - pstmt.setBigDecimal(index++, to); - else if (from != null && to == null) - pstmt.setBigDecimal(index++, from); - else if (from != null && to != null) - { - if (from.compareTo(to) == 0) - pstmt.setBigDecimal(index++, from); - else - { - pstmt.setBigDecimal(index++, from); - pstmt.setBigDecimal(index++, to); - } - } - } - if (fCharge_ID.getValue() != null) { - Integer i = (Integer)fCharge_ID.getValue(); - pstmt.setInt(index++, i.intValue()); - if (log.isLoggable(Level.FINE)) log.fine("Charge=" + i); - } - } // setParameters - - /** - * Get SQL WHERE parameter - * @param f field - * @return Upper case text with % at the end - */ - private String getSQLText (CTextField f) - { - String s = f.getText().toUpperCase(); - if (!s.endsWith("%")) - s += "%"; - if (log.isLoggable(Level.FINE)) log.fine( "String=" + s); - return s; - } // getSQLText -} // InfoCashLine diff --git a/org.adempiere.ui.swing/src/org/compiere/apps/search/InfoFactory.java b/org.adempiere.ui.swing/src/org/compiere/apps/search/InfoFactory.java deleted file mode 100644 index 6f39dbbe1f..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/apps/search/InfoFactory.java +++ /dev/null @@ -1,22 +0,0 @@ -package org.compiere.apps.search; - -import java.awt.Frame; - -public interface InfoFactory { - - /** - * Factory Constructor - * @param frame parent frame - * @param modal new window is modal - * @param WindowNo window no - * @param tableName table name of the search - * @param keyColumn key column of the search - * @param value query value - * @param multiSelection allow to select more than one row - * @param whereClause fully qualified where clause for the search - * @return special or general Info Window - */ - public Info create (Frame frame, boolean modal, int WindowNo, - String tableName, String keyColumn, String value, - boolean multiSelection, String whereClause); -} diff --git a/org.adempiere.ui.swing/src/org/compiere/apps/search/InfoGeneral.java b/org.adempiere.ui.swing/src/org/compiere/apps/search/InfoGeneral.java deleted file mode 100644 index 6f2571bcbe..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/apps/search/InfoGeneral.java +++ /dev/null @@ -1,477 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ -package org.compiere.apps.search; - -import java.awt.Frame; -import java.math.BigDecimal; -import java.sql.PreparedStatement; -import java.sql.ResultSet; -import java.sql.SQLException; -import java.sql.Timestamp; -import java.util.ArrayList; -import java.util.logging.Level; - -import javax.swing.JLabel; - -import org.adempiere.plaf.AdempierePLAF; -import org.compiere.apps.ADialog; -import org.compiere.apps.AEnv; -import org.compiere.apps.ALayout; -import org.compiere.apps.ALayoutConstraint; -import org.compiere.minigrid.IDColumn; -import org.compiere.swing.CLabel; -import org.compiere.swing.CTextField; -import org.compiere.util.DB; -import org.compiere.util.DisplayType; -import org.compiere.util.Env; -import org.compiere.util.Msg; - -/** - * Generic Table Search - *

    - * Change log: - *

      - *
    • 2007-02-14 - teo_sarca - [ 1659737 ] InfoGeneral not working with virtual columns - *
    - * - * @author Jorg Janke - * @version $Id: InfoGeneral.java,v 1.3 2006/10/06 00:42:38 jjanke Exp $ - */ -public class InfoGeneral extends Info -{ - /** - * - */ - private static final long serialVersionUID = -7588425490485071820L; - - /** - * Detail Protected Constructor. - * - * @param frame parent - * @param modal modal - * @param WindowNo window no - * @param value QueryValue - * @param tableName table name - * @param keyColumn key column (ignored) - * @param multiSelection multiple selections - * @param whereClause where clause - */ - public InfoGeneral (Frame frame, boolean modal, int WindowNo, String value, - String tableName, String keyColumn, - boolean multiSelection, String whereClause) - { - this(frame, modal, WindowNo, value, tableName, keyColumn, multiSelection, whereClause, true); - } - - /** - * Detail Protected Constructor. - * - * @param frame parent - * @param modal modal - * @param WindowNo window no - * @param value QueryValue - * @param tableName table name - * @param keyColumn key column (ignored) - * @param multiSelection multiple selections - * @param whereClause where clause - * @param lookup - */ - public InfoGeneral (Frame frame, boolean modal, int WindowNo, String value, - String tableName, String keyColumn, - boolean multiSelection, String whereClause, boolean lookup) - { - super (frame, modal, WindowNo, tableName, keyColumn, multiSelection, whereClause, lookup); - if (log.isLoggable(Level.INFO)) log.info(tableName + " - " + keyColumn + " - " + whereClause); - setTitle(Msg.getMsg(Env.getCtx(), "Info")); - // - statInit(); - p_loadedOK = initInfo (); - if (!p_loadedOK) - return; - // - int no = p_table.getRowCount(); - setStatusLine(Integer.toString(no) + " " - + Msg.getMsg(Env.getCtx(), "SearchRows_EnterQuery"), false); - setStatusDB(Integer.toString(no)); - // Focus - textField1.setValue(value); - textField1.requestFocus(); - if (value != null && value.length() > 0) - executeQuery(); - p_loadedOK = true; - - AEnv.positionCenterWindow(frame, this); - } // InfoGeneral - - /** String Array of Column Info */ - private Info_Column[] m_generalLayout; - /** list of query columns */ - private ArrayList m_queryColumns = new ArrayList(); - /** list of query columns (SQL) */ - private ArrayList m_queryColumnsSql = new ArrayList(); - - // Static data - private CLabel label1 = new CLabel(); - private CTextField textField1 = new CTextField(10); - private CLabel label2 = new CLabel(); - private CTextField textField2 = new CTextField(10); - private CLabel label3 = new CLabel(); - private CTextField textField3 = new CTextField(10); - private CLabel label4 = new CLabel(); - private CTextField textField4 = new CTextField(10); - - /** - * Static Setup - add fields to parameterPanel (GridLayout) - */ - private void statInit() - { - label1.setLabelFor(textField1); - label1.setText("Label1"); - label1.setHorizontalAlignment(JLabel.LEADING); - textField1.setBackground(AdempierePLAF.getInfoBackground()); - label2.setLabelFor(textField2); - label2.setText("Label2"); - label2.setHorizontalAlignment(JLabel.LEADING); - textField2.setBackground(AdempierePLAF.getInfoBackground()); - label3.setLabelFor(textField3); - label3.setText("Label3"); - label3.setHorizontalAlignment(JLabel.LEADING); - textField3.setBackground(AdempierePLAF.getInfoBackground()); - label4.setLabelFor(textField4); - label4.setText("Label4"); - label4.setHorizontalAlignment(JLabel.LEADING); - textField4.setBackground(AdempierePLAF.getInfoBackground()); - // - parameterPanel.setLayout(new ALayout()); - parameterPanel.add(label1, new ALayoutConstraint(0,0)); - parameterPanel.add(label2, null); - parameterPanel.add(label3, null); - parameterPanel.add(label4, null); - // - parameterPanel.add(textField1, new ALayoutConstraint(1,0)); - parameterPanel.add(textField2, null); - parameterPanel.add(textField3, null); - parameterPanel.add(textField4, null); - } // statInit - - /** - * General Init - * @return true, if success - */ - private boolean initInfo () - { - if (!initInfoTable()) - return false; - - // prepare table - StringBuilder where = new StringBuilder("IsActive='Y'"); - if (p_whereClause.length() > 0) - where.append(" AND ").append(p_whereClause); - prepareTable(m_generalLayout, - p_tableName, - where.toString(), - "2"); - - // Set & enable Fields - label1.setText(Msg.translate(Env.getCtx(), m_queryColumns.get(0).toString())); - textField1.addActionListener(this); - if (m_queryColumns.size() > 1) - { - label2.setText(Msg.translate(Env.getCtx(), m_queryColumns.get(1).toString())); - textField2.addActionListener(this); - } - else - { - label2.setVisible(false); - textField2.setVisible(false); - } - if (m_queryColumns.size() > 2) - { - label3.setText(Msg.translate(Env.getCtx(), m_queryColumns.get(2).toString())); - textField3.addActionListener(this); - } - else - { - label3.setVisible(false); - textField3.setVisible(false); - } - if (m_queryColumns.size() > 3) - { - label4.setText(Msg.translate(Env.getCtx(), m_queryColumns.get(3).toString())); - textField4.addActionListener(this); - } - else - { - label4.setVisible(false); - textField4.setVisible(false); - } - return true; - } // initInfo - - - /** - * Init info with Table. - * - find QueryColumns (Value, Name, ..) - * - build gridController & columsn - * @return true if success - */ - private boolean initInfoTable () - { - // Get Query Columns ------------------------------------------------- - String sql = "SELECT c.ColumnName, t.AD_Table_ID, t.TableName, c.ColumnSql " - + "FROM AD_Table t" - + " INNER JOIN AD_Column c ON (t.AD_Table_ID=c.AD_Table_ID)" - + "WHERE c.AD_Reference_ID IN (10,14)" - + " AND t.TableName=?" // #1 - // Displayed in Window - + " AND EXISTS (SELECT * FROM AD_Field f " - + "WHERE f.AD_Column_ID=c.AD_Column_ID" - + " AND f.IsDisplayed='Y' AND f.IsEncrypted='N' AND f.ObscureType IS NULL) " - // - + "ORDER BY c.IsIdentifier DESC, c.AD_Reference_ID, c.SeqNo"; - int AD_Table_ID = 0; - String tableName = null; - PreparedStatement pstmt = null; - ResultSet rs = null; - try - { - pstmt = DB.prepareStatement(sql, null); - pstmt.setString(1, p_tableName); - rs = pstmt.executeQuery(); - while (rs.next()) - { - m_queryColumns.add(rs.getString(1)); - String columnSql = rs.getString(4); - if (columnSql != null && columnSql.length() > 0 && columnSql.contains("@")) - columnSql = "NULL"; - if (columnSql != null && columnSql.contains("@")) - columnSql = Env.parseContext(Env.getCtx(), -1, columnSql, false, true); - if (columnSql != null && columnSql.length() > 0) - m_queryColumnsSql.add(columnSql); - else - m_queryColumnsSql.add(rs.getString(1)); - - if (AD_Table_ID == 0) - { - AD_Table_ID = rs.getInt(2); - tableName = rs.getString(3); - } - } - } - catch (SQLException e) - { - log.log(Level.SEVERE, sql, e); - return false; - } - finally { - DB.close(rs, pstmt); - rs = null; pstmt = null; - } - // Miminum check - if (m_queryColumns.size() == 0) - { - ADialog.error(p_WindowNo, this, "Error", "No query columns found"); - log.log(Level.SEVERE, "No query columns found"); - return false; - } - if (log.isLoggable(Level.FINEST)) log.finest("Table " + tableName + ", ID=" + AD_Table_ID - + ", QueryColumns #" + m_queryColumns.size()); - // Only 4 Query Columns - while (m_queryColumns.size() > 4) { - m_queryColumns.remove(m_queryColumns.size()-1); - m_queryColumnsSql.remove(m_queryColumnsSql.size()-1); - } - // Set Title - String title = Msg.translate(Env.getCtx(), tableName + "_ID"); // best bet - if (title.endsWith("_ID")) - title = Msg.translate(Env.getCtx(), tableName); // second best bet - setTitle(getTitle() + " " + title); - - - // Get Display Columns ----------------------------------------------- - ArrayList list = new ArrayList(); - sql = "SELECT c.ColumnName, c.AD_Reference_ID, c.IsKey, f.IsDisplayed, c.AD_Reference_Value_ID, c.ColumnSql " - + "FROM AD_Column c" - + " INNER JOIN AD_Table t ON (c.AD_Table_ID=t.AD_Table_ID)" - + " INNER JOIN AD_Tab tab ON (t.AD_Window_ID=tab.AD_Window_ID)" - + " INNER JOIN AD_Field f ON (tab.AD_Tab_ID=f.AD_Tab_ID AND f.AD_Column_ID=c.AD_Column_ID) " - + "WHERE t.AD_Table_ID=? " - + " AND (c.IsKey='Y' OR " - // + " (f.IsDisplayed='Y' AND f.IsEncrypted='N' AND f.ObscureType IS NULL)) " - + " (f.IsEncrypted='N' AND f.ObscureType IS NULL)) " - + "ORDER BY c.IsKey DESC, f.SeqNo"; - - try - { - pstmt = DB.prepareStatement(sql, null); - pstmt.setInt(1, AD_Table_ID); - rs = pstmt.executeQuery(); - while (rs.next()) - { - String columnName = rs.getString(1); - int displayType = rs.getInt(2); - boolean isKey = rs.getString(3).equals("Y"); - boolean isDisplayed = rs.getString(4).equals("Y"); - int AD_Reference_Value_ID = rs.getInt(5); - // teo_sarca - String columnSql = rs.getString(6); - if (columnSql != null && columnSql.length() > 0 && columnSql.contains("@")) - columnSql = "NULL"; - if (columnSql != null && columnSql.contains("@")) - columnSql = Env.parseContext(Env.getCtx(), -1, columnSql, false, true); - if (columnSql == null || columnSql.length() == 0) - columnSql = columnName; - // Default - StringBuffer colSql = new StringBuffer(columnSql); - Class colClass = null; - // - if (isKey) - colClass = IDColumn.class; - else if (!isDisplayed) - ; - else if (displayType == DisplayType.YesNo) - colClass = Boolean.class; - else if (displayType == DisplayType.Amount) - colClass = BigDecimal.class; - else if (displayType == DisplayType.Number || displayType == DisplayType.Quantity) - colClass = Double.class; - else if (displayType == DisplayType.Integer) - colClass = Integer.class; - else if (displayType == DisplayType.String || displayType == DisplayType.Text || displayType == DisplayType.Memo) - colClass = String.class; - else if (DisplayType.isDate(displayType)) - colClass = Timestamp.class; - // ignore Binary, Button, ID, RowID - // else if (displayType == DisplayType.Account) - // else if (displayType == DisplayType.Location) - // else if (displayType == DisplayType.Locator) - else if (displayType == DisplayType.List) - { - if (Env.isBaseLanguage(Env.getCtx(), "AD_Ref_List")) - colSql = new StringBuffer("(SELECT l.Name FROM AD_Ref_List l WHERE l.AD_Reference_ID=") - .append(AD_Reference_Value_ID).append(" AND l.Value=").append(columnSql) - .append(") AS ").append(columnName); - else - colSql = new StringBuffer("(SELECT t.Name FROM AD_Ref_List l, AD_Ref_List_Trl t " - + "WHERE l.AD_Ref_List_ID=t.AD_Ref_List_ID AND l.AD_Reference_ID=") - .append(AD_Reference_Value_ID).append(" AND l.Value=").append(columnSql) - .append(" AND t.AD_Language='").append(Env.getAD_Language(Env.getCtx())) - .append("') AS ").append(columnName); - colClass = String.class; - } - // else if (displayType == DisplayType.Table) - // else if (displayType == DisplayType.TableDir || displayType == DisplayType.Search) - - if (colClass != null) - { - list.add(new Info_Column(Msg.translate(Env.getCtx(), columnName), colSql.toString(), colClass)); - if (log.isLoggable(Level.FINEST)) log.finest("Added Column=" + columnName); - } - else - if (log.isLoggable(Level.FINEST)) log.finest("Not Added Column=" + columnName); - } - } - catch (SQLException e) - { - log.log(Level.SEVERE, sql, e); - return false; - } - finally { - DB.close(rs, pstmt); - rs = null; pstmt = null; - } - if (list.size() == 0) - { - ADialog.error(p_WindowNo, this, "Error", "No Info Columns"); - log.log(Level.SEVERE, "No Info for AD_Table_ID=" + AD_Table_ID + " - " + sql); - return false; - } - if (log.isLoggable(Level.FINEST)) log.finest("InfoColumns #" + list.size()); - - // Convert ArrayList to Array - m_generalLayout = new Info_Column[list.size()]; - list.toArray(m_generalLayout); - return true; - } // initInfoTable - - - /************************************************************************** - * Construct SQL Where Clause and define parameters. - * (setParameters needs to set parameters) - * Includes first AND - * @return where clause - */ - protected String getSQLWhere() - { - StringBuffer sql = new StringBuffer(); - addSQLWhere (sql, 0, textField1.getText().toUpperCase()); - addSQLWhere (sql, 1, textField2.getText().toUpperCase()); - addSQLWhere (sql, 2, textField3.getText().toUpperCase()); - addSQLWhere (sql, 3, textField4.getText().toUpperCase()); - return sql.toString(); - } // getSQLWhere - - /** - * Add directly Query as Strings - * @param sql sql buffer - * @param index index - * @param value value - */ - private void addSQLWhere(StringBuffer sql, int index, String value) - { - if (!(value.equals("") || value.equals("%")) && index < m_queryColumns.size()) - { - // Angelo Dabala' (genied) nectosoft: [2893220] avoid to append string parameters directly because of special chars like quote(s) - sql.append(" AND UPPER(").append(m_queryColumnsSql.get(index).toString()).append(") LIKE ?"); - } - } // addSQLWhere - - /** - * Get SQL WHERE parameter - * @param f field - * @return sql part - */ - private String getSQLText (CTextField f) - { - String s = f.getText().toUpperCase(); - if (!s.endsWith("%")) - s += "%"; - if (log.isLoggable(Level.FINE)) log.fine( "String=" + s); - return s; - } // getSQLText - - /** - * Set Parameters for Query. - * (as defined in getSQLWhere) - * @param pstmt statement - * @param forCount for counting records - * @throws SQLException - */ - protected void setParameters(PreparedStatement pstmt, boolean forCount) throws SQLException - { - int index = 1; - if (textField1.getText().length() > 0) - pstmt.setString(index++, getSQLText(textField1)); - if (textField2.getText().length() > 0) - pstmt.setString(index++, getSQLText(textField2)); - if (textField3.getText().length() > 0) - pstmt.setString(index++, getSQLText(textField3)); - if (textField4.getText().length() > 0) - pstmt.setString(index++, getSQLText(textField4)); - } // setParameters - -} // InfoGeneral diff --git a/org.adempiere.ui.swing/src/org/compiere/apps/search/InfoInOut.java b/org.adempiere.ui.swing/src/org/compiere/apps/search/InfoInOut.java deleted file mode 100644 index a8acede1c1..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/apps/search/InfoInOut.java +++ /dev/null @@ -1,348 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ -package org.compiere.apps.search; - -import java.awt.Frame; -import java.sql.PreparedStatement; -import java.sql.SQLException; -import java.sql.Timestamp; -import java.util.logging.Level; - -import org.adempiere.plaf.AdempierePLAF; -import org.compiere.apps.ALayout; -import org.compiere.apps.ALayoutConstraint; -import org.compiere.grid.ed.VCheckBox; -import org.compiere.grid.ed.VDate; -import org.compiere.grid.ed.VLookup; -import org.compiere.minigrid.IDColumn; -import org.compiere.model.MLookupFactory; -import org.compiere.model.MQuery; -import org.compiere.swing.CLabel; -import org.compiere.swing.CTextField; -import org.compiere.util.DisplayType; -import org.compiere.util.Env; -import org.compiere.util.Msg; -import org.compiere.util.Util; - - -/** - * Info InOut - * - * @author Jorg Janke - * @version $Id: InfoInOut.java,v 1.2 2006/07/30 00:51:27 jjanke Exp $ - */ -public class InfoInOut extends Info -{ - /** - * - */ - private static final long serialVersionUID = -2066307179999903184L; - - /** - * Detail Protected Contructor - * @param frame parent frame - * @param modal modal - * @param WindowNo window no - * @param value query value - * @param multiSelection multiple selections - * @param whereClause where clause - */ - public InfoInOut(Frame frame, boolean modal, int WindowNo, String value, - boolean multiSelection, String whereClause) - { - this(frame, modal, WindowNo, value, multiSelection, whereClause, true); - } - - /** - * Detail Protected Contructor - * @param frame parent frame - * @param modal modal - * @param WindowNo window no - * @param value query value - * @param multiSelection multiple selections - * @param whereClause where clause - * @param lookup - */ - public InfoInOut(Frame frame, boolean modal, int WindowNo, String value, - boolean multiSelection, String whereClause, boolean lookup) - { - super (frame, modal, WindowNo, "i", "M_InOut_ID", multiSelection, whereClause, lookup); - log.info( "InfoInOut"); - setTitle(Msg.getMsg(Env.getCtx(), "InfoInOut")); - // - try - { - statInit(); - p_loadedOK = initInfo (); - } - catch (Exception e) - { - return; - } - // - int no = p_table.getRowCount(); - setStatusLine(Integer.toString(no) + " " + Msg.getMsg(Env.getCtx(), "SearchRows_EnterQuery"), false); - setStatusDB(Integer.toString(no)); - if (value != null && value.length() > 0) - { - fDocumentNo.setValue(value); - executeQuery(); - } - // - pack(); - // Focus - fDocumentNo.requestFocus(); - } // InfoInOut - - /** String Array of Column Info */ - //private Info_Column[] m_generalLayout; - /** list of query columns */ - //private ArrayList m_queryColumns = new ArrayList(); - /** Table Name */ - //private String m_tableName; - /** Key Column Name */ - //private String m_keyColumn; - - // Static Info - private CLabel lDocumentNo = new CLabel(Msg.translate(Env.getCtx(), "DocumentNo")); - private CTextField fDocumentNo = new CTextField(10); - private CLabel lDescription = new CLabel(Msg.translate(Env.getCtx(), "Description")); - private CTextField fDescription = new CTextField(10); - private CLabel lPOReference = new CLabel(Msg.translate(Env.getCtx(), "POReference")); - private CTextField fPOReference = new CTextField(10); - // -// private CLabel lOrg_ID = new CLabel(Msg.translate(Env.getCtx(), "AD_Org_ID")); -// private VLookup fOrg_ID; - private CLabel lBPartner_ID = new CLabel(Msg.translate(Env.getCtx(), "BPartner")); - private VLookup fBPartner_ID; - // - private CLabel lDateFrom = new CLabel(Msg.translate(Env.getCtx(), "MovementDate")); - private VDate fDateFrom = new VDate("DateFrom", false, false, true, DisplayType.Date, Msg.translate(Env.getCtx(), "DateFrom")); - private CLabel lDateTo = new CLabel("-"); - private VDate fDateTo = new VDate("DateTo", false, false, true, DisplayType.Date, Msg.translate(Env.getCtx(), "DateTo")); - private VCheckBox fIsSOTrx = new VCheckBox ("IsSOTrx", false, false, true, Msg.translate(Env.getCtx(), "IsSOTrx"), "", false); - - /** Array of Column Info */ - private static final Info_Column[] s_invoiceLayout = { - new Info_Column(" ", "i.M_InOut_ID", IDColumn.class), - new Info_Column(Msg.translate(Env.getCtx(), "C_BPartner_ID"), "(SELECT Name FROM C_BPartner bp WHERE bp.C_BPartner_ID=i.C_BPartner_ID)", String.class), - new Info_Column(Msg.translate(Env.getCtx(), "MovementDate"), "i.MovementDate", Timestamp.class), - new Info_Column(Msg.translate(Env.getCtx(), "DocumentNo"), "i.DocumentNo", String.class), - new Info_Column(Msg.translate(Env.getCtx(), "Description"), "i.Description", String.class), - new Info_Column(Msg.translate(Env.getCtx(), "POReference"), "i.POReference", String.class), - new Info_Column(Msg.translate(Env.getCtx(), "IsSOTrx"), "i.IsSOTrx", Boolean.class) - }; - - /** - * Static Setup - add fields to parameterPanel - * @throws Exception if Lookups cannot be initialized - */ - private void statInit() throws Exception - { - lDocumentNo.setLabelFor(fDocumentNo); - fDocumentNo.setBackground(AdempierePLAF.getInfoBackground()); - fDocumentNo.addActionListener(this); - lDescription.setLabelFor(fDescription); - fDescription.setBackground(AdempierePLAF.getInfoBackground()); - fDescription.addActionListener(this); - lPOReference.setLabelFor(fPOReference); - fPOReference.setBackground(AdempierePLAF.getInfoBackground()); - fPOReference.addActionListener(this); - fIsSOTrx.setSelected(!"N".equals(Env.getContext(Env.getCtx(), p_WindowNo, "IsSOTrx"))); - fIsSOTrx.addActionListener(this); - // - // fOrg_ID = new VLookup("AD_Org_ID", false, false, true, - // MLookupFactory.create(Env.getCtx(), 3486, m_WindowNo, DisplayType.TableDir, false), - // DisplayType.TableDir, m_WindowNo); - // lOrg_ID.setLabelFor(fOrg_ID); - // fOrg_ID.setBackground(AdempierePLAF.getInfoBackground()); - fBPartner_ID = new VLookup("C_BPartner_ID", false, false, true, - MLookupFactory.get (Env.getCtx(), p_WindowNo, 0, 3499, DisplayType.Search)); - lBPartner_ID.setLabelFor(fBPartner_ID); - fBPartner_ID.setBackground(AdempierePLAF.getInfoBackground()); - // - lDateFrom.setLabelFor(fDateFrom); - fDateFrom.setBackground(AdempierePLAF.getInfoBackground()); - fDateFrom.setToolTipText(Msg.translate(Env.getCtx(), "DateFrom")); - lDateTo.setLabelFor(fDateTo); - fDateTo.setBackground(AdempierePLAF.getInfoBackground()); - fDateTo.setToolTipText(Msg.translate(Env.getCtx(), "DateTo")); - // - parameterPanel.setLayout(new ALayout()); - // First Row - parameterPanel.add(lDocumentNo, new ALayoutConstraint(0,0)); - parameterPanel.add(fDocumentNo, null); - parameterPanel.add(lBPartner_ID, null); - parameterPanel.add(fBPartner_ID, null); - parameterPanel.add(fIsSOTrx, new ALayoutConstraint(0,5)); - // 2nd Row - parameterPanel.add(lDescription, new ALayoutConstraint(1,0)); - parameterPanel.add(fDescription, null); - parameterPanel.add(lDateFrom, null); - parameterPanel.add(fDateFrom, null); - parameterPanel.add(lDateTo, null); - parameterPanel.add(fDateTo, null); - // 3rd Row - parameterPanel.add(lPOReference, new ALayoutConstraint(2,0)); - parameterPanel.add(fPOReference, null); - // parameterPanel.add(lOrg_ID, null); - // parameterPanel.add(fOrg_ID, null); - } // statInit - - /** - * General Init - * @return true, if success - */ - private boolean initInfo () - { - // Set Defaults - String bp = Env.getContext(Env.getCtx(), p_WindowNo, "C_BPartner_ID"); - if (bp != null && bp.length() != 0) - fBPartner_ID.setValue(Integer.valueOf(bp)); - - // prepare table - StringBuilder where = new StringBuilder("i.IsActive='Y'"); - if (p_whereClause.length() > 0) - where.append(" AND ").append(Util.replace(p_whereClause, "M_InOut.", "i.")); - prepareTable(s_invoiceLayout, - " M_InOut i", - where.toString(), - "2,3,4"); - - return true; - } // initInfo - - /*************************************************************************/ - - /** - * Construct SQL Where Clause and define parameters. - * (setParameters needs to set parameters) - * Includes first AND - * @return where clause - */ - protected String getSQLWhere() - { - StringBuilder sql = new StringBuilder(); - if (fDocumentNo.getText().length() > 0) - sql.append(" AND UPPER(i.DocumentNo) LIKE ?"); - if (fDescription.getText().length() > 0) - sql.append(" AND UPPER(i.Description) LIKE ?"); - if (fPOReference.getText().length() > 0) - sql.append(" AND UPPER(i.POReference) LIKE ?"); - // - if (fBPartner_ID.getValue() != null) - sql.append(" AND i.C_BPartner_ID=?"); - // - if (fDateFrom.getValue() != null || fDateTo.getValue() != null) - { - Timestamp from = (Timestamp)fDateFrom.getValue(); - Timestamp to = (Timestamp)fDateTo.getValue(); - if (from == null && to != null) - sql.append(" AND TRUNC(i.MovementDate) <= ?"); - else if (from != null && to == null) - sql.append(" AND TRUNC(i.MovementDate) >= ?"); - else if (from != null && to != null) - sql.append(" AND TRUNC(i.MovementDate) BETWEEN ? AND ?"); - } - sql.append(" AND i.IsSOTrx=?"); - - // log.fine( "InfoInOut.setWhereClause", sql.toString()); - return sql.toString(); - } // getSQLWhere - - /** - * Set Parameters for Query. - * (as defined in getSQLWhere) - * @param pstmt statement - * @param forCount for counting records - * @throws SQLException - */ - protected void setParameters(PreparedStatement pstmt, boolean forCount) throws SQLException - { - int index = 1; - if (fDocumentNo.getText().length() > 0) - pstmt.setString(index++, getSQLText(fDocumentNo)); - if (fDescription.getText().length() > 0) - pstmt.setString(index++, getSQLText(fDescription)); - if (fPOReference.getText().length() > 0) - pstmt.setString(index++, getSQLText(fPOReference)); - // - if (fBPartner_ID.getValue() != null) - { - Integer bp = (Integer)fBPartner_ID.getValue(); - pstmt.setInt(index++, bp.intValue()); - if (log.isLoggable(Level.FINE)) log.fine("BPartner=" + bp); - } - // - if (fDateFrom.getValue() != null || fDateTo.getValue() != null) - { - Timestamp from = (Timestamp)fDateFrom.getValue(); - Timestamp to = (Timestamp)fDateTo.getValue(); - if (log.isLoggable(Level.FINE)) log.fine("Date From=" + from + ", To=" + to); - if (from == null && to != null) - pstmt.setTimestamp(index++, to); - else if (from != null && to == null) - pstmt.setTimestamp(index++, from); - else if (from != null && to != null) - { - pstmt.setTimestamp(index++, from); - pstmt.setTimestamp(index++, to); - } - } - pstmt.setString(index++, fIsSOTrx.isSelected() ? "Y" : "N"); - } // setParameters - - /** - * Get SQL WHERE parameter - * @param f field - * @return sql part - */ - private String getSQLText (CTextField f) - { - String s = f.getText().toUpperCase(); - if (!s.endsWith("%")) - s += "%"; - if (log.isLoggable(Level.FINE)) log.fine( "String=" + s); - return s; - } // getSQLText - - /** - * Zoom - */ - protected void zoom() - { - log.info( "InfoInOut.zoom"); - Integer M_InOut_ID = getSelectedRowKey(); - if (M_InOut_ID == null) - return; - MQuery query = new MQuery("M_InOut"); - query.addRestriction("M_InOut_ID", MQuery.EQUAL, M_InOut_ID); - query.setRecordCount(1); - int AD_WindowNo = getAD_Window_ID("M_InOut", fIsSOTrx.isSelected()); - zoom (AD_WindowNo, query); - } // zoom - - /** - * Has Zoom - * @return true - */ - protected boolean hasZoom() - { - return true; - } // hasZoom - -} // InfoInOut diff --git a/org.adempiere.ui.swing/src/org/compiere/apps/search/InfoInvoice.java b/org.adempiere.ui.swing/src/org/compiere/apps/search/InfoInvoice.java deleted file mode 100644 index 9e052da1a2..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/apps/search/InfoInvoice.java +++ /dev/null @@ -1,452 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ -package org.compiere.apps.search; - -import java.awt.Frame; -import java.math.BigDecimal; -import java.sql.PreparedStatement; -import java.sql.SQLException; -import java.sql.Timestamp; -import java.util.logging.Level; - -import org.adempiere.plaf.AdempierePLAF; -import org.compiere.apps.ALayout; -import org.compiere.apps.ALayoutConstraint; -import org.compiere.grid.ed.VCheckBox; -import org.compiere.grid.ed.VDate; -import org.compiere.grid.ed.VLookup; -import org.compiere.grid.ed.VNumber; -import org.compiere.minigrid.IDColumn; -import org.compiere.model.MLookupFactory; -import org.compiere.model.MQuery; -import org.compiere.swing.CLabel; -import org.compiere.swing.CTextField; -import org.compiere.util.DisplayType; -import org.compiere.util.Env; -import org.compiere.util.KeyNamePair; -import org.compiere.util.Msg; -import org.compiere.util.Util; - -/** - * Info Invoice - * - * @author Jorg Janke - * @version $Id: InfoInvoice.java,v 1.2 2006/07/30 00:51:27 jjanke Exp $ - * - * @author Teo Sarca, SC ARHIPAC SERVICE SRL - * FR [ 1926882 ] Info Invoice: display Due Date - */ -public class InfoInvoice extends Info -{ - /** - * - */ - private static final long serialVersionUID = 2119484421367033632L; - - /** - * Detail Protected Contructor - * - * @param frame parent frame - * @param modal modal - * @param WindowNo window no - * @param value query value - * @param multiSelection multiple selections - * @param whereClause where clause - */ - public InfoInvoice(Frame frame, boolean modal, int WindowNo, String value, - boolean multiSelection, String whereClause) - { - this(frame, modal, WindowNo, value, multiSelection, whereClause, true); - } - - /** - * Detail Protected Contructor - * - * @param frame parent frame - * @param modal modal - * @param WindowNo window no - * @param value query value - * @param multiSelection multiple selections - * @param whereClause where clause - * @param lookup - */ - public InfoInvoice(Frame frame, boolean modal, int WindowNo, String value, - boolean multiSelection, String whereClause, boolean lookup) - { - super (frame, modal, WindowNo, "i", "C_Invoice_ID", multiSelection, whereClause, lookup); - setTitle(Msg.getMsg(Env.getCtx(), "InfoInvoice")); - // - try - { - statInit(); - p_loadedOK = initInfo (); - } - catch (Exception e) - { - return; - } - // - int no = p_table.getRowCount(); - setStatusLine(Integer.toString(no) + " " + Msg.getMsg(Env.getCtx(), "SearchRows_EnterQuery"), false); - setStatusDB(Integer.toString(no)); - if (value != null && value.length() > 0) - { - fDocumentNo.setValue(value); - executeQuery(); - } - // - pack(); - // Focus - fDocumentNo.requestFocus(); - } // InfoInvoice - - /** String Array of Column Info */ - //private Info_Column[] m_generalLayout; - /** list of query columns */ - //private ArrayList m_queryColumns = new ArrayList(); - /** Table Name */ - //private String m_tableName; - /** Key Column Name */ - //private String m_keyColumn; - - // Static Info - private CLabel lDocumentNo = new CLabel(Msg.translate(Env.getCtx(), "DocumentNo")); - private CTextField fDocumentNo = new CTextField(10); - private CLabel lDescription = new CLabel(Msg.translate(Env.getCtx(), "Description")); - private CTextField fDescription = new CTextField(10); -// private CLabel lPOReference = new CLabel(Msg.translate(Env.getCtx(), "POReference")); -// private CTextField fPOReference = new CTextField(10); - // -// private CLabel lOrg_ID = new CLabel(Msg.translate(Env.getCtx(), "AD_Org_ID")); -// private VLookup fOrg_ID; - private CLabel lBPartner_ID = new CLabel(Msg.translate(Env.getCtx(), "BPartner")); - private VLookup fBPartner_ID; - private CLabel lOrder_ID = new CLabel(Msg.translate(Env.getCtx(), "C_Order_ID")); - private VLookup fOrder_ID; - private VCheckBox fIsPaid = new VCheckBox ("IsPaid", false, false, true, Msg.translate(Env.getCtx(), "IsPaid"), "", false); - private VCheckBox fIsSOTrx = new VCheckBox ("IsSOTrx", false, false, true, Msg.translate(Env.getCtx(), "IsSOTrx"), "", false); - // - private CLabel lDateFrom = new CLabel(Msg.translate(Env.getCtx(), "DateInvoiced")); - private VDate fDateFrom = new VDate("DateFrom", false, false, true, DisplayType.Date, Msg.translate(Env.getCtx(), "DateFrom")); - private CLabel lDateTo = new CLabel("-"); - private VDate fDateTo = new VDate("DateTo", false, false, true, DisplayType.Date, Msg.translate(Env.getCtx(), "DateTo")); - private CLabel lAmtFrom = new CLabel(Msg.translate(Env.getCtx(), "GrandTotal")); - private VNumber fAmtFrom = new VNumber("AmtFrom", false, false, true, DisplayType.Amount, Msg.translate(Env.getCtx(), "AmtFrom")); - private CLabel lAmtTo = new CLabel("-"); - private VNumber fAmtTo = new VNumber("AmtTo", false, false, true, DisplayType.Amount, Msg.translate(Env.getCtx(), "AmtTo")); - - /** Array of Column Info */ - private static final Info_Column[] s_invoiceLayout = { - new Info_Column(" ", "i.C_Invoice_ID", IDColumn.class), - new Info_Column(Msg.translate(Env.getCtx(), "C_BPartner_ID"), "(SELECT Name FROM C_BPartner bp WHERE bp.C_BPartner_ID=i.C_BPartner_ID)", String.class), - new Info_Column(Msg.translate(Env.getCtx(), "DateInvoiced"), "i.DateInvoiced", Timestamp.class), - new Info_Column(Msg.translate(Env.getCtx(), "DueDate"), "i.DueDate", Timestamp.class), - new Info_Column(Msg.translate(Env.getCtx(), "DocumentNo"), "i.DocumentNo", String.class), - new Info_Column(Msg.translate(Env.getCtx(), "C_Currency_ID"), "(SELECT ISO_Code FROM C_Currency c WHERE c.C_Currency_ID=i.C_Currency_ID)", String.class), - new Info_Column(Msg.translate(Env.getCtx(), "GrandTotal"), "i.GrandTotal", BigDecimal.class), - new Info_Column(Msg.translate(Env.getCtx(), "ConvertedAmount"), "currencyBase(i.GrandTotal, i.C_Currency_ID, i.DateAcct, i.AD_Client_ID, i.AD_Org_ID)", BigDecimal.class), - new Info_Column(Msg.translate(Env.getCtx(), "OpenAmt"), "invoiceOpen(C_Invoice_ID,C_InvoicePaySchedule_ID)", BigDecimal.class, true, true, null), - new Info_Column(Msg.translate(Env.getCtx(), "IsPaid"), "i.IsPaid", Boolean.class), - new Info_Column(Msg.translate(Env.getCtx(), "IsSOTrx"), "i.IsSOTrx", Boolean.class), - new Info_Column(Msg.translate(Env.getCtx(), "Description"), "i.Description", String.class), - new Info_Column(Msg.translate(Env.getCtx(), "POReference"), "i.POReference", String.class), - new Info_Column("", "''", KeyNamePair.class, "i.C_InvoicePaySchedule_ID") - }; - private static int INDEX_PAYSCHEDULE = s_invoiceLayout.length - 1; // last item - - /** - * Static Setup - add fields to parameterPanel - * @throws Exception - */ - private void statInit() throws Exception - { - lDocumentNo.setLabelFor(fDocumentNo); - fDocumentNo.setBackground(AdempierePLAF.getInfoBackground()); - fDocumentNo.addActionListener(this); - lDescription.setLabelFor(fDescription); - fDescription.setBackground(AdempierePLAF.getInfoBackground()); - fDescription.addActionListener(this); - // lPOReference.setLabelFor(lPOReference); - // fPOReference.setBackground(AdempierePLAF.getInfoBackground()); - // fPOReference.addActionListener(this); - fIsPaid.setSelected(false); - fIsPaid.addActionListener(this); - fIsSOTrx.setSelected(!"N".equals(Env.getContext(Env.getCtx(), p_WindowNo, "IsSOTrx"))); - fIsSOTrx.addActionListener(this); - // - // fOrg_ID = new VLookup("AD_Org_ID", false, false, true, - // MLookupFactory.create(Env.getCtx(), 3486, m_WindowNo, DisplayType.TableDir, false), - // DisplayType.TableDir, m_WindowNo); - // lOrg_ID.setLabelFor(fOrg_ID); - // fOrg_ID.setBackground(AdempierePLAF.getInfoBackground()); - // C_Invoice.C_BPartner_ID - fBPartner_ID = new VLookup("C_BPartner_ID", false, false, true, - MLookupFactory.get (Env.getCtx(), p_WindowNo, 0, 3499, DisplayType.Search)); - lBPartner_ID.setLabelFor(fBPartner_ID); - fBPartner_ID.setBackground(AdempierePLAF.getInfoBackground()); - // C_Invoice.C_Order_ID - fOrder_ID = new VLookup("C_Order_ID", false, false, true, - MLookupFactory.get (Env.getCtx(), p_WindowNo, 0, 4247, DisplayType.Search)); - lOrder_ID.setLabelFor(fOrder_ID); - fOrder_ID.setBackground(AdempierePLAF.getInfoBackground()); - // - lDateFrom.setLabelFor(fDateFrom); - fDateFrom.setBackground(AdempierePLAF.getInfoBackground()); - fDateFrom.setToolTipText(Msg.translate(Env.getCtx(), "DateFrom")); - lDateTo.setLabelFor(fDateTo); - fDateTo.setBackground(AdempierePLAF.getInfoBackground()); - fDateTo.setToolTipText(Msg.translate(Env.getCtx(), "DateTo")); - lAmtFrom.setLabelFor(fAmtFrom); - fAmtFrom.setBackground(AdempierePLAF.getInfoBackground()); - fAmtFrom.setToolTipText(Msg.translate(Env.getCtx(), "AmtFrom")); - lAmtTo.setLabelFor(fAmtTo); - fAmtTo.setBackground(AdempierePLAF.getInfoBackground()); - fAmtTo.setToolTipText(Msg.translate(Env.getCtx(), "AmtTo")); - // - parameterPanel.setLayout(new ALayout()); - // First Row - parameterPanel.add(lDocumentNo, new ALayoutConstraint(0,0)); - parameterPanel.add(fDocumentNo, null); - parameterPanel.add(lBPartner_ID, null); - parameterPanel.add(fBPartner_ID, null); - parameterPanel.add(fIsSOTrx, new ALayoutConstraint(0,5)); - parameterPanel.add(fIsPaid, null); - // 2nd Row - parameterPanel.add(lDescription, new ALayoutConstraint(1,0)); - parameterPanel.add(fDescription, null); - parameterPanel.add(lDateFrom, null); - parameterPanel.add(fDateFrom, null); - parameterPanel.add(lDateTo, null); - parameterPanel.add(fDateTo, null); - // 3rd Row - parameterPanel.add(lOrder_ID, new ALayoutConstraint(2,0)); - parameterPanel.add(fOrder_ID, null); - parameterPanel.add(lAmtFrom, null); - parameterPanel.add(fAmtFrom, null); - parameterPanel.add(lAmtTo, null); - parameterPanel.add(fAmtTo, null); - // parameterPanel.add(lOrg_ID, null); - // parameterPanel.add(fOrg_ID, null); - } // statInit - - /** - * General Init - * @return true, if success - */ - private boolean initInfo () - { - // Set Defaults - String bp = Env.getContext(Env.getCtx(), p_WindowNo, "C_BPartner_ID"); - if (bp != null && bp.length() != 0) - fBPartner_ID.setValue(Integer.valueOf(bp)); - - // prepare table - StringBuilder where = new StringBuilder("i.IsActive='Y'"); - if (p_whereClause.length() > 0) - where.append(" AND ").append(Util.replace(p_whereClause, "C_Invoice.", "i.")); - prepareTable(s_invoiceLayout, - " C_Invoice_v i", // corrected for CM - where.toString(), - "2,3,4,5"); - // - // MAllocationLine.setIsPaid(Env.getCtx(), 0, null); - return true; - } // initInfo - - - /************************************************************************** - * Construct SQL Where Clause and define parameters. - * (setParameters needs to set parameters) - * Includes first AND - * @return sql - */ - protected String getSQLWhere() - { - StringBuilder sql = new StringBuilder(); - if (fDocumentNo.getText().length() > 0) - sql.append(" AND UPPER(i.DocumentNo) LIKE ?"); - if (fDescription.getText().length() > 0) - sql.append(" AND UPPER(i.Description) LIKE ?"); - // if (fPOReference.getText().length() > 0) - // sql.append(" AND UPPER(i.POReference) LIKE ?"); - // - if (fBPartner_ID.getValue() != null) - sql.append(" AND i.C_BPartner_ID=?"); - // - if (fOrder_ID.getValue() != null) - sql.append(" AND i.C_Order_ID=?"); - // - if (fDateFrom.getValue() != null || fDateTo.getValue() != null) - { - Timestamp from = (Timestamp)fDateFrom.getValue(); - Timestamp to = (Timestamp)fDateTo.getValue(); - if (from == null && to != null) - sql.append(" AND TRUNC(i.DateInvoiced) <= ?"); - else if (from != null && to == null) - sql.append(" AND TRUNC(i.DateInvoiced) >= ?"); - else if (from != null && to != null) - sql.append(" AND TRUNC(i.DateInvoiced) BETWEEN ? AND ?"); - } - // - if (fAmtFrom.getValue() != null || fAmtTo.getValue() != null) - { - BigDecimal from = (BigDecimal)fAmtFrom.getValue(); - BigDecimal to = (BigDecimal)fAmtTo.getValue(); - if (from == null && to != null) - sql.append(" AND i.GrandTotal <= ?"); - else if (from != null && to == null) - sql.append(" AND i.GrandTotal >= ?"); - else if (from != null && to != null) - sql.append(" AND i.GrandTotal BETWEEN ? AND ?"); - } - // - sql.append(" AND i.IsPaid=? AND i.IsSOTrx=?"); - - // log.fine( "InfoInvoice.setWhereClause", sql.toString()); - return sql.toString(); - } // getSQLWhere - - /** - * Set Parameters for Query. - * (as defined in getSQLWhere) - * @param pstmt statement - * @param forCount for counting records - * @throws SQLException - */ - protected void setParameters(PreparedStatement pstmt, boolean forCount) throws SQLException - { - int index = 1; - if (fDocumentNo.getText().length() > 0) - pstmt.setString(index++, getSQLText(fDocumentNo)); - if (fDescription.getText().length() > 0) - pstmt.setString(index++, getSQLText(fDescription)); - // if (fPOReference.getText().length() > 0) - // pstmt.setString(index++, getSQLText(fPOReference)); - // - if (fBPartner_ID.getValue() != null) - { - Integer bp = (Integer)fBPartner_ID.getValue(); - pstmt.setInt(index++, bp.intValue()); - if (log.isLoggable(Level.FINE)) log.fine("BPartner=" + bp); - } - // - if (fOrder_ID.getValue() != null) - { - Integer order = (Integer)fOrder_ID.getValue(); - pstmt.setInt(index++, order.intValue()); - if (log.isLoggable(Level.FINE)) log.fine("Order=" + order); - } - // - if (fDateFrom.getValue() != null || fDateTo.getValue() != null) - { - Timestamp from = (Timestamp)fDateFrom.getValue(); - Timestamp to = (Timestamp)fDateTo.getValue(); - if (log.isLoggable(Level.FINE)) log.fine("Date From=" + from + ", To=" + to); - if (from == null && to != null) - pstmt.setTimestamp(index++, to); - else if (from != null && to == null) - pstmt.setTimestamp(index++, from); - else if (from != null && to != null) - { - pstmt.setTimestamp(index++, from); - pstmt.setTimestamp(index++, to); - } - } - // - if (fAmtFrom.getValue() != null || fAmtTo.getValue() != null) - { - BigDecimal from = (BigDecimal)fAmtFrom.getValue(); - BigDecimal to = (BigDecimal)fAmtTo.getValue(); - if (log.isLoggable(Level.FINE)) log.fine("Amt From=" + from + ", To=" + to); - if (from == null && to != null) - pstmt.setBigDecimal(index++, to); - else if (from != null && to == null) - pstmt.setBigDecimal(index++, from); - else if (from != null && to != null) - { - pstmt.setBigDecimal(index++, from); - pstmt.setBigDecimal(index++, to); - } - } - pstmt.setString(index++, fIsPaid.isSelected() ? "Y" : "N"); - pstmt.setString(index++, fIsSOTrx.isSelected() ? "Y" : "N"); - } // setParameters - - /** - * Get SQL WHERE parameter - * @param f field - * @return sql - */ - private String getSQLText (CTextField f) - { - String s = f.getText().toUpperCase(); - if (!s.endsWith("%")) - s += "%"; - if (log.isLoggable(Level.FINE)) log.fine( "String=" + s); - return s; - } // getSQLText - - /** - * Zoom - */ - protected void zoom() - { - log.info( "InfoInvoice.zoom"); - Integer C_Invoice_ID = getSelectedRowKey(); - if (C_Invoice_ID == null) - return; - MQuery query = new MQuery("C_Invoice"); - query.addRestriction("C_Invoice_ID", MQuery.EQUAL, C_Invoice_ID); - query.setRecordCount(1); - int AD_WindowNo = getAD_Window_ID("C_Invoice", fIsSOTrx.isSelected()); - zoom (AD_WindowNo, query); - } // zoom - - /** - * Has Zoom - * @return true - */ - protected boolean hasZoom() - { - return true; - } // hasZoom - - /** - * Save Selection Settings - */ - protected void saveSelectionDetail() - { - // publish for Callout to read - Integer ID = getSelectedRowKey(); - Env.setContext(Env.getCtx(), p_WindowNo, Env.TAB_INFO, "C_Invoice_ID", ID == null ? "0" : ID.toString()); - // - int C_InvoicePaySchedule_ID = 0; - int row = p_table.getSelectedRow(); - if (row >= 0) - { - Object value = p_table.getValueAt(row, INDEX_PAYSCHEDULE); - if (value != null && value instanceof KeyNamePair) - C_InvoicePaySchedule_ID = ((KeyNamePair)value).getKey(); - } - if (C_InvoicePaySchedule_ID <= 0) // not selected - Env.setContext(Env.getCtx(), p_WindowNo, Env.TAB_INFO, "C_InvoicePaySchedule_ID", "0"); - else - Env.setContext(Env.getCtx(), p_WindowNo, Env.TAB_INFO, "C_InvoicePaySchedule_ID", String.valueOf(C_InvoicePaySchedule_ID)); - } // saveSelectionDetail - - -} // InfoInvoice diff --git a/org.adempiere.ui.swing/src/org/compiere/apps/search/InfoOrder.java b/org.adempiere.ui.swing/src/org/compiere/apps/search/InfoOrder.java deleted file mode 100644 index fb000407aa..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/apps/search/InfoOrder.java +++ /dev/null @@ -1,394 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ -package org.compiere.apps.search; - -import java.awt.Frame; -import java.math.BigDecimal; -import java.sql.PreparedStatement; -import java.sql.SQLException; -import java.sql.Timestamp; -import java.util.logging.Level; - -import org.adempiere.plaf.AdempierePLAF; -import org.compiere.apps.ALayout; -import org.compiere.apps.ALayoutConstraint; -import org.compiere.grid.ed.VCheckBox; -import org.compiere.grid.ed.VDate; -import org.compiere.grid.ed.VLookup; -import org.compiere.grid.ed.VNumber; -import org.compiere.minigrid.IDColumn; -import org.compiere.model.MLookupFactory; -import org.compiere.model.MQuery; -import org.compiere.swing.CLabel; -import org.compiere.swing.CTextField; -import org.compiere.util.DisplayType; -import org.compiere.util.Env; -import org.compiere.util.Msg; -import org.compiere.util.Util; - -/** - * Info Order - * - * @author Jorg Janke - * @version $Id: InfoOrder.java,v 1.2 2006/07/30 00:51:27 jjanke Exp $ - */ -public class InfoOrder extends Info -{ - /** - * - */ - private static final long serialVersionUID = 2246871771555208114L; - - /** - * Detail Protected Contructor - * @param frame parent frame - * @param modal modal - * @param WindowNo window no - * @param value query value - * @param multiSelection multiple selections - * @param whereClause where clause - */ - public InfoOrder(Frame frame, boolean modal, int WindowNo, String value, - boolean multiSelection, String whereClause) - { - this(frame, modal, WindowNo, value, multiSelection, whereClause, true); - } - - /** - * Detail Protected Contructor - * @param frame parent frame - * @param modal modal - * @param WindowNo window no - * @param value query value - * @param multiSelection multiple selections - * @param whereClause where clause - * @param lookup - */ - public InfoOrder(Frame frame, boolean modal, int WindowNo, String value, - boolean multiSelection, String whereClause, boolean lookup) - { - super (frame, modal, WindowNo, "o", "C_Order_ID", multiSelection, whereClause, lookup); - log.info( "InfoOrder"); - setTitle(Msg.getMsg(Env.getCtx(), "InfoOrder")); - // - try - { - statInit(); - p_loadedOK = initInfo (); - } - catch (Exception e) - { - return; - } - // - int no = p_table.getRowCount(); - setStatusLine(Integer.toString(no) + " " + Msg.getMsg(Env.getCtx(), "SearchRows_EnterQuery"), false); - setStatusDB(Integer.toString(no)); - if (value != null && value.length() > 0) - { - fDocumentNo.setValue(value); - executeQuery(); - } - // - pack(); - // Focus - fDocumentNo.requestFocus(); - } // InfoOrder - - /** String Array of Column Info */ - //private Info_Column[] m_generalLayout; - /** list of query columns */ - //private ArrayList m_queryColumns = new ArrayList(); - /** Table Name */ - //private String m_tableName; - /** Key Column Name */ - //private String m_keyColumn; - - // Static Info - private CLabel lDocumentNo = new CLabel(Msg.translate(Env.getCtx(), "DocumentNo")); - private CTextField fDocumentNo = new CTextField(10); - private CLabel lDescription = new CLabel(Msg.translate(Env.getCtx(), "Description")); - private CTextField fDescription = new CTextField(10); - private CLabel lPOReference = new CLabel(Msg.translate(Env.getCtx(), "POReference")); - private CTextField fPOReference = new CTextField(10); - // -// private CLabel lOrg_ID = new CLabel(Msg.translate(Env.getCtx(), "AD_Org_ID")); -// private VLookup fOrg_ID; - private CLabel lBPartner_ID = new CLabel(Msg.translate(Env.getCtx(), "BPartner")); - private VLookup fBPartner_ID; - // - private CLabel lDateFrom = new CLabel(Msg.translate(Env.getCtx(), "DateOrdered")); - private VDate fDateFrom = new VDate("DateFrom", false, false, true, DisplayType.Date, Msg.translate(Env.getCtx(), "DateFrom")); - private CLabel lDateTo = new CLabel("-"); - private VDate fDateTo = new VDate("DateTo", false, false, true, DisplayType.Date, Msg.translate(Env.getCtx(), "DateTo")); - private CLabel lAmtFrom = new CLabel(Msg.translate(Env.getCtx(), "GrandTotal")); - private VNumber fAmtFrom = new VNumber("AmtFrom", false, false, true, DisplayType.Amount, Msg.translate(Env.getCtx(), "AmtFrom")); - private CLabel lAmtTo = new CLabel("-"); - private VNumber fAmtTo = new VNumber("AmtTo", false, false, true, DisplayType.Amount, Msg.translate(Env.getCtx(), "AmtTo")); - private VCheckBox fIsSOTrx = new VCheckBox ("IsSOTrx", false, false, true, Msg.translate(Env.getCtx(), "IsSOTrx"), "", false); - - /** Array of Column Info */ - private static final Info_Column[] s_invoiceLayout = { - new Info_Column(" ", "o.C_Order_ID", IDColumn.class), - new Info_Column(Msg.translate(Env.getCtx(), "C_BPartner_ID"), "(SELECT Name FROM C_BPartner bp WHERE bp.C_BPartner_ID=o.C_BPartner_ID)", String.class), - new Info_Column(Msg.translate(Env.getCtx(), "DateOrdered"), "o.DateOrdered", Timestamp.class), - new Info_Column(Msg.translate(Env.getCtx(), "DocumentNo"), "o.DocumentNo", String.class), - new Info_Column(Msg.translate(Env.getCtx(), "C_Currency_ID"), "(SELECT ISO_Code FROM C_Currency c WHERE c.C_Currency_ID=o.C_Currency_ID)", String.class), - new Info_Column(Msg.translate(Env.getCtx(), "GrandTotal"), "o.GrandTotal", BigDecimal.class), - new Info_Column(Msg.translate(Env.getCtx(), "ConvertedAmount"), "currencyBase(o.GrandTotal,o.C_Currency_ID,o.DateAcct, o.AD_Client_ID,o.AD_Org_ID)", BigDecimal.class), - new Info_Column(Msg.translate(Env.getCtx(), "IsSOTrx"), "o.IsSOTrx", Boolean.class), - new Info_Column(Msg.translate(Env.getCtx(), "Description"), "o.Description", String.class), - new Info_Column(Msg.translate(Env.getCtx(), "POReference"), "o.POReference", String.class) - }; - - /** - * Static Setup - add fields to parameterPanel - * @throws Exception if Lookups cannot be initialized - */ - private void statInit() throws Exception - { - lDocumentNo.setLabelFor(fDocumentNo); - fDocumentNo.setBackground(AdempierePLAF.getInfoBackground()); - fDocumentNo.addActionListener(this); - lDescription.setLabelFor(fDescription); - fDescription.setBackground(AdempierePLAF.getInfoBackground()); - fDescription.addActionListener(this); - lPOReference.setLabelFor(fPOReference); - fPOReference.setBackground(AdempierePLAF.getInfoBackground()); - fPOReference.addActionListener(this); - fIsSOTrx.setSelected(!"N".equals(Env.getContext(Env.getCtx(), p_WindowNo, "IsSOTrx"))); - fIsSOTrx.addActionListener(this); - // - // fOrg_ID = new VLookup("AD_Org_ID", false, false, true, - // MLookupFactory.create(Env.getCtx(), 3486, m_WindowNo, DisplayType.TableDir, false), - // DisplayType.TableDir, m_WindowNo); - // lOrg_ID.setLabelFor(fOrg_ID); - // fOrg_ID.setBackground(AdempierePLAF.getInfoBackground()); - fBPartner_ID = new VLookup("C_BPartner_ID", false, false, true, - MLookupFactory.get (Env.getCtx(), p_WindowNo, 0, 3499, DisplayType.Search)); - lBPartner_ID.setLabelFor(fBPartner_ID); - fBPartner_ID.setBackground(AdempierePLAF.getInfoBackground()); - // - lDateFrom.setLabelFor(fDateFrom); - fDateFrom.setBackground(AdempierePLAF.getInfoBackground()); - fDateFrom.setToolTipText(Msg.translate(Env.getCtx(), "DateFrom")); - lDateTo.setLabelFor(fDateTo); - fDateTo.setBackground(AdempierePLAF.getInfoBackground()); - fDateTo.setToolTipText(Msg.translate(Env.getCtx(), "DateTo")); - lAmtFrom.setLabelFor(fAmtFrom); - fAmtFrom.setBackground(AdempierePLAF.getInfoBackground()); - fAmtFrom.setToolTipText(Msg.translate(Env.getCtx(), "AmtFrom")); - lAmtTo.setLabelFor(fAmtTo); - fAmtTo.setBackground(AdempierePLAF.getInfoBackground()); - fAmtTo.setToolTipText(Msg.translate(Env.getCtx(), "AmtTo")); - // - parameterPanel.setLayout(new ALayout()); - // First Row - parameterPanel.add(lDocumentNo, new ALayoutConstraint(0,0)); - parameterPanel.add(fDocumentNo, null); - parameterPanel.add(lBPartner_ID, null); - parameterPanel.add(fBPartner_ID, null); - parameterPanel.add(fIsSOTrx, new ALayoutConstraint(0,5)); - // 2nd Row - parameterPanel.add(lDescription, new ALayoutConstraint(1,0)); - parameterPanel.add(fDescription, null); - parameterPanel.add(lDateFrom, null); - parameterPanel.add(fDateFrom, null); - parameterPanel.add(lDateTo, null); - parameterPanel.add(fDateTo, null); - // 3rd Row - parameterPanel.add(lPOReference, new ALayoutConstraint(2,0)); - parameterPanel.add(fPOReference, null); - parameterPanel.add(lAmtFrom, null); - parameterPanel.add(fAmtFrom, null); - parameterPanel.add(lAmtTo, null); - parameterPanel.add(fAmtTo, null); - // parameterPanel.add(lOrg_ID, null); - // parameterPanel.add(fOrg_ID, null); - } // statInit - - /** - * General Init - * @return true, if success - */ - private boolean initInfo () - { - // Set Defaults - String bp = Env.getContext(Env.getCtx(), p_WindowNo, "C_BPartner_ID"); - if (bp != null && bp.length() != 0) - fBPartner_ID.setValue(Integer.valueOf(bp)); - - // prepare table - StringBuilder where = new StringBuilder("o.IsActive='Y'"); - if (p_whereClause.length() > 0) - where.append(" AND ").append(Util.replace(p_whereClause, "C_Order.", "o.")); - prepareTable(s_invoiceLayout, - " C_Order o", - where.toString(), - "2,3,4"); - - return true; - } // initInfo - - - /************************************************************************** - * Construct SQL Where Clause and define parameters. - * (setParameters needs to set parameters) - * Includes first AND - * @return sql - */ - protected String getSQLWhere() - { - StringBuilder sql = new StringBuilder(); - if (fDocumentNo.getText().length() > 0) - sql.append(" AND UPPER(o.DocumentNo) LIKE ?"); - if (fDescription.getText().length() > 0) - sql.append(" AND UPPER(o.Description) LIKE ?"); - if (fPOReference.getText().length() > 0) - sql.append(" AND UPPER(o.POReference) LIKE ?"); - // - if (fBPartner_ID.getValue() != null) - sql.append(" AND o.C_BPartner_ID=?"); - // - if (fDateFrom.getValue() != null || fDateTo.getValue() != null) - { - Timestamp from = (Timestamp)fDateFrom.getValue(); - Timestamp to = (Timestamp)fDateTo.getValue(); - if (from == null && to != null) - sql.append(" AND TRUNC(o.DateOrdered) <= ?"); - else if (from != null && to == null) - sql.append(" AND TRUNC(o.DateOrdered) >= ?"); - else if (from != null && to != null) - sql.append(" AND TRUNC(o.DateOrdered) BETWEEN ? AND ?"); - } - // - if (fAmtFrom.getValue() != null || fAmtTo.getValue() != null) - { - BigDecimal from = (BigDecimal)fAmtFrom.getValue(); - BigDecimal to = (BigDecimal)fAmtTo.getValue(); - if (from == null && to != null) - sql.append(" AND o.GrandTotal <= ?"); - else if (from != null && to == null) - sql.append(" AND o.GrandTotal >= ?"); - else if (from != null && to != null) - sql.append(" AND o.GrandTotal BETWEEN ? AND ?"); - } - sql.append(" AND o.IsSOTrx=?"); - - if (log.isLoggable(Level.FINER)) log.finer(sql.toString()); - return sql.toString(); - } // getSQLWhere - - /** - * Set Parameters for Query. - * (as defined in getSQLWhere) - * @param pstmt statement - * @param forCount for counting records - * @throws SQLException - */ - protected void setParameters(PreparedStatement pstmt, boolean forCount) throws SQLException - { - int index = 1; - if (fDocumentNo.getText().length() > 0) - pstmt.setString(index++, getSQLText(fDocumentNo)); - if (fDescription.getText().length() > 0) - pstmt.setString(index++, getSQLText(fDescription)); - if (fPOReference.getText().length() > 0) - pstmt.setString(index++, getSQLText(fPOReference)); - // - if (fBPartner_ID.getValue() != null) - { - Integer bp = (Integer)fBPartner_ID.getValue(); - pstmt.setInt(index++, bp.intValue()); - if (log.isLoggable(Level.FINE)) log.fine("BPartner=" + bp); - } - // - if (fDateFrom.getValue() != null || fDateTo.getValue() != null) - { - Timestamp from = (Timestamp)fDateFrom.getValue(); - Timestamp to = (Timestamp)fDateTo.getValue(); - if (log.isLoggable(Level.FINE)) log.fine("Date From=" + from + ", To=" + to); - if (from == null && to != null) - pstmt.setTimestamp(index++, to); - else if (from != null && to == null) - pstmt.setTimestamp(index++, from); - else if (from != null && to != null) - { - pstmt.setTimestamp(index++, from); - pstmt.setTimestamp(index++, to); - } - } - // - if (fAmtFrom.getValue() != null || fAmtTo.getValue() != null) - { - BigDecimal from = (BigDecimal)fAmtFrom.getValue(); - BigDecimal to = (BigDecimal)fAmtTo.getValue(); - if (log.isLoggable(Level.FINE)) log.fine("Amt From=" + from + ", To=" + to); - if (from == null && to != null) - pstmt.setBigDecimal(index++, to); - else if (from != null && to == null) - pstmt.setBigDecimal(index++, from); - else if (from != null && to != null) - { - pstmt.setBigDecimal(index++, from); - pstmt.setBigDecimal(index++, to); - } - } - pstmt.setString(index++, fIsSOTrx.isSelected() ? "Y" : "N"); - } // setParameters - - /** - * Get SQL WHERE parameter - * @param f field - * @return sql - */ - private String getSQLText (CTextField f) - { - String s = f.getText().toUpperCase(); - if (!s.endsWith("%")) - s += "%"; - if (log.isLoggable(Level.FINE)) log.fine("String=" + s); - return s; - } // getSQLText - - - /** - * Zoom - */ - protected void zoom() - { - log.info(""); - Integer C_Order_ID = getSelectedRowKey(); - if (C_Order_ID == null) - return; - MQuery query = new MQuery("C_Order"); - query.addRestriction("C_Order_ID", MQuery.EQUAL, C_Order_ID); - query.setRecordCount(1); - int AD_WindowNo = getAD_Window_ID("C_Order", fIsSOTrx.isSelected()); - zoom (AD_WindowNo, query); - } // zoom - - /** - * Has Zoom - * @return true - */ - protected boolean hasZoom() - { - return true; - } // hasZoom - -} // InfoOrder diff --git a/org.adempiere.ui.swing/src/org/compiere/apps/search/InfoPAttribute.java b/org.adempiere.ui.swing/src/org/compiere/apps/search/InfoPAttribute.java deleted file mode 100644 index 08001591e4..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/apps/search/InfoPAttribute.java +++ /dev/null @@ -1,597 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ -package org.compiere.apps.search; - -import java.awt.BorderLayout; -import java.awt.Component; -import java.awt.Dimension; -import java.awt.event.ActionEvent; -import java.math.BigDecimal; -import java.sql.PreparedStatement; -import java.sql.ResultSet; -import java.sql.Timestamp; -import java.util.ArrayList; -import java.util.logging.Level; - -import javax.swing.Box; -import javax.swing.JDialog; - -import org.compiere.apps.AEnv; -import org.compiere.apps.ALayout; -import org.compiere.apps.ALayoutConstraint; -import org.compiere.apps.ConfirmPanel; -import org.compiere.grid.ed.VComboBox; -import org.compiere.grid.ed.VDate; -import org.compiere.grid.ed.VLine; -import org.compiere.grid.ed.VNumber; -import org.compiere.grid.ed.VString; -import org.compiere.model.MAttribute; -import org.compiere.model.MAttributeSet; -import org.compiere.model.MRole; -import org.compiere.swing.CDialog; -import org.compiere.swing.CLabel; -import org.compiere.swing.CPanel; -import org.compiere.util.CLogger; -import org.compiere.util.DB; -import org.compiere.util.DisplayType; -import org.compiere.util.Env; -import org.compiere.util.KeyNamePair; -import org.compiere.util.Msg; - -/** - * Search by Product Attribute. - * - * @author Jorg Janke - * @version $Id: InfoPAttribute.java,v 1.2 2006/07/30 00:51:27 jjanke Exp $ - */ -public class InfoPAttribute extends CDialog -{ - /** - * - */ - private static final long serialVersionUID = -4309055112258081495L; - - /* the attribute set selected on the InfoProduct window */ - private int p_M_AttributeSet_ID = 0; - - /** - * Constructor. - * Called from InfoProduct,cmd_InfoPAttribute - * @param parent - */ - public InfoPAttribute (JDialog parent) - { - super (parent, Msg.getMsg(Env.getCtx(), "InfoPAttribute"), true); - if (parent instanceof InfoProduct) { - p_M_AttributeSet_ID = ((InfoProduct)parent).getM_AttributeSet_ID(); - } - try - { - jbInit(); - dynInit(); - } - catch (Exception e) - { - log.log(Level.SEVERE, "InfoPAttribute", e); - } - AEnv.showCenterWindow(parent, this); - } // InfoPAttribute - - /** Resulting Query */ - private String m_query = ""; - /** Product Attribute Editors */ - private ArrayList m_productEditors = new ArrayList(); - private ArrayList m_productEditorsTo = new ArrayList(); - /** Instance Attribute Editors */ - private ArrayList m_instanceEditors = new ArrayList(); - private ArrayList m_instanceEditorsTo = new ArrayList(); - /** Logger */ - private static CLogger log = CLogger.getCLogger(InfoPAttribute.class); - - private CPanel mainPanel = new CPanel(); - private BorderLayout mainLayout = new BorderLayout(); - private CPanel centerPanel = new CPanel(); - private ConfirmPanel confirmPanel = new ConfirmPanel(true); - // - private CLabel serNoLabel = new CLabel(Msg.translate(Env.getCtx(), "SerNo")); - private VString serNoField = new VString("SerNo", false, false, true, 10, 20, null, null); - private CLabel lotLabel = new CLabel(Msg.translate(Env.getCtx(), "Lot")); - private VString lotField = new VString("Lot", false, false, true, 10, 20, null, null); - private VComboBox guaranteeDateSelection = null; - private VDate guaranteeDateField = new VDate ("GuaranteeDate", false, false, true, DisplayType.Date, Msg.translate(Env.getCtx(), "GuaranteeDate")); - private CLabel lotLabel2 = new CLabel(Msg.translate(Env.getCtx(), "M_Lot_ID")); - private VComboBox lotSelection = null; - // - - /** - * Static Init - * @throws Exception - */ - private void jbInit() throws Exception - { - this.getContentPane().add(mainPanel, BorderLayout.CENTER); - mainPanel.setLayout(mainLayout); - mainPanel.add(centerPanel, BorderLayout.CENTER); - centerPanel.setLayout(new ALayout()); - // ConfirmPanel - confirmPanel.addActionListener(this); - mainPanel.add(confirmPanel, BorderLayout.SOUTH); - } // jbInit - - /** - * Dynamic Init of the Center Panel - */ - private void dynInit() - { - int row = addAttributes(); - - boolean isGuarantee = true; - boolean isSerial = true; - boolean isLot = true; - if (p_M_AttributeSet_ID > 0) { - MAttributeSet as = new MAttributeSet(Env.getCtx(), p_M_AttributeSet_ID, null); - isGuarantee = as.isGuaranteeDate(); - isSerial = as.isSerNo(); - isLot = as.isLot(); - } - // - String s = Msg.translate(Env.getCtx(), "GuaranteeDate"); - guaranteeDateSelection = new VComboBox (new Object[] - {s + " <", s + " =", s + " >"}); - // guaranteeDateSelection.setPreferredSize(); - initLotSelection(); - // Fixed Instance Selection Fields - if (isSerial) { - centerPanel.add(serNoLabel, new ALayoutConstraint(row++, 0)); - centerPanel.add(serNoField, null); - } - if (isLot) { - centerPanel.add(lotLabel, new ALayoutConstraint(row++, 0)); - centerPanel.add(lotField, null); - centerPanel.add(lotLabel2, new ALayoutConstraint(row++, 0)); - centerPanel.add(lotSelection, null); - } - if (isGuarantee) { - centerPanel.add(guaranteeDateSelection, new ALayoutConstraint(row++, 0)); - centerPanel.add(guaranteeDateField, null); - } - // - Dimension d = centerPanel.getPreferredSize(); - d.width = 400; - centerPanel.setPreferredSize(d); - } // dynInit - - /** - * Add Attributes - * @return rows - */ - private int addAttributes() - { - int row = 0; - PreparedStatement pstmt = null; - ResultSet rs = null; - String whereAttributeSet; - if (p_M_AttributeSet_ID > 0) - whereAttributeSet = "AND M_Attribute_ID IN (SELECT M_Attribute_ID FROM M_AttributeUse WHERE M_AttributeSet_ID="+p_M_AttributeSet_ID+")"; - else - whereAttributeSet = ""; - String sql = MRole.getDefault().addAccessSQL( - "SELECT M_Attribute_ID, Name, Description, AttributeValueType, IsInstanceAttribute " - + "FROM M_Attribute " - + "WHERE IsActive='Y' " - + whereAttributeSet - + " ORDER BY IsInstanceAttribute, Name", - "M_Attribute", MRole.SQL_NOTQUALIFIED, MRole.SQL_RO); - boolean instanceLine = false; - try - { - pstmt = DB.prepareStatement(sql, null); - rs = pstmt.executeQuery(); - while (rs.next()) - { - int attribute_ID = rs.getInt(1); - String name = rs.getString(2); - String description = rs.getString(3); - String attributeValueType = rs.getString(4); - boolean isInstanceAttribute = "Y".equals(rs.getString(5)); - // Instance switch - if (!instanceLine && isInstanceAttribute) - { - CPanel group = new CPanel(); - group.setBorder(new VLine(Msg.translate(Env.getCtx(), "IsInstanceAttribute"))); - group.add(Box.createVerticalStrut(VLine.SPACE)); - centerPanel.add(group, new ALayoutConstraint(row++, 0)); - instanceLine = true; - } - // - CLabel label = new CLabel(name); - if (description != null && description.length() > 0) - label.setToolTipText(description); - centerPanel.add(label, new ALayoutConstraint(row++, 0)); - Component field = null; - if (MAttribute.ATTRIBUTEVALUETYPE_List.equals(attributeValueType)) - field = new VComboBox(getAttributeList(attribute_ID)); - else if (MAttribute.ATTRIBUTEVALUETYPE_Number.equals(attributeValueType)) - field = new VNumber(name, false, false, true, DisplayType.Number, name); - else - field = new VString(name, false, false, true, 10, 40, null, null); - label.setLabelFor(field); - centerPanel.add(field, null); - // - field.setName(String.valueOf(attribute_ID)); - if (isInstanceAttribute) - m_instanceEditors.add(field); - else - m_productEditors.add(field); - - // To (numbers) - Component fieldTo = null; - if (MAttribute.ATTRIBUTEVALUETYPE_Number.equals(attributeValueType)) - { - fieldTo = new VNumber(name, false, false, true, DisplayType.Number, name); - centerPanel.add(new CLabel("-"), null); - centerPanel.add(fieldTo, null); - } - if (isInstanceAttribute) - m_instanceEditorsTo.add(fieldTo); - else - m_productEditorsTo.add(fieldTo); - } - } - catch (Exception e) - { - log.log(Level.SEVERE, sql, e); - } - finally { - DB.close(rs, pstmt); - rs = null; pstmt = null; - } - - // print instance line if not printed - if (!instanceLine) { - boolean isGuarantee = true; - boolean isSerial = true; - boolean isLot = true; - if (p_M_AttributeSet_ID > 0) { - MAttributeSet as = new MAttributeSet(Env.getCtx(), p_M_AttributeSet_ID, null); - isGuarantee = as.isGuaranteeDate(); - isSerial = as.isSerNo(); - isLot = as.isLot(); - } - if (isGuarantee || isSerial || isLot) { - CPanel group = new CPanel(); - group.setBorder(new VLine(Msg.translate(Env.getCtx(), "IsInstanceAttribute"))); - group.add(Box.createVerticalStrut(VLine.SPACE)); - centerPanel.add(group, new ALayoutConstraint(row++, 0)); - instanceLine = true; - } - } - - return row; - } // addProductAttributes - - /** - * Get Attribute List - * @param M_Attribute_ID attribure - * @return array - */ - private KeyNamePair[] getAttributeList(int M_Attribute_ID) - { - ArrayList list = new ArrayList(); - list.add(new KeyNamePair(-1, "")); - - PreparedStatement pstmt = null; - ResultSet rs = null; - String sql = MRole.getDefault().addAccessSQL( - "SELECT M_AttributeValue_ID, Value, Name " - + "FROM M_AttributeValue " - + "WHERE M_Attribute_ID=? " - + "ORDER BY 2", - "M_AttributeValue", MRole.SQL_NOTQUALIFIED, MRole.SQL_RO); - try - { - pstmt = DB.prepareStatement(sql, null); - pstmt.setInt(1, M_Attribute_ID); - rs = pstmt.executeQuery(); - while (rs.next()) - list.add(new KeyNamePair(rs.getInt(1), rs.getString(3))); - } - catch (Exception e) - { - log.log(Level.SEVERE, sql, e); - } - finally { - DB.close(rs, pstmt); - rs = null; pstmt = null; - } - KeyNamePair[] retValue = new KeyNamePair[list.size()]; - list.toArray(retValue); - return retValue; - } // getAttributeList - - - /** - * Initialize Lot Selection - */ - private void initLotSelection() - { - ArrayList list = new ArrayList(); - list.add(new KeyNamePair(-1, "")); - - String whereAttributeSet; - if (p_M_AttributeSet_ID > 0) - whereAttributeSet = "AND M_Product_ID IN (SELECT M_Product_ID FROM M_Product WHERE M_AttributeSet_ID="+p_M_AttributeSet_ID+")"; - else - whereAttributeSet = ""; - String sql = MRole.getDefault().addAccessSQL( - "SELECT M_Lot_ID, Name FROM M_Lot WHERE IsActive='Y' " + whereAttributeSet + " ORDER BY 2", - "M_Lot", MRole.SQL_NOTQUALIFIED, MRole.SQL_RO); - PreparedStatement pstmt = null; - ResultSet rs = null; - try - { - pstmt = DB.prepareStatement(sql, null); - rs = pstmt.executeQuery(); - while (rs.next()) - list.add(new KeyNamePair(rs.getInt(1), rs.getString(2))); - } - catch (Exception e) - { - log.log(Level.SEVERE, sql, e); - } - finally { - DB.close(rs, pstmt); - rs = null; pstmt = null; - } - // Create List - KeyNamePair[] items = new KeyNamePair[list.size()]; - list.toArray(items); - lotSelection = new VComboBox(items); - } // initLotSelection - - - - /** - * Action Listener - * @param e event - */ - public void actionPerformed(ActionEvent e) - { - if (e.getActionCommand().equals(ConfirmPanel.A_OK)) - { - createQuery(); - dispose(); - } - else if (e.getActionCommand().equals(ConfirmPanel.A_CANCEL)) - { - m_query = null; - dispose(); - } - } // actionPerformed - - /** - * Create Query - * - * Available synonyms: - * M_Product p - * M_ProductPrice pr - * M_AttributeSet pa - * - * @return query - */ - private String createQuery() - { - /** Base Query - SELECT * - FROM M_Product p - INNER JOIN M_ProductPrice pr ON (p.M_Product_ID=pr.M_Product_ID) - LEFT OUTER JOIN M_AttributeSet pa ON (p.M_AttributeSet_ID=pa.M_AttributeSet_ID) - WHERE - **/ - - /*** Instance Attributes */ - StringBuilder sb = new StringBuilder(); - // Serial No - String s = serNoField.getText(); - if (s != null && s.length() > 0) - { - sb.append(" AND asi.SerNo"); - if (s.indexOf('%') == -1 && s.indexOf('_') == 1) - sb.append("="); - else - sb.append(" LIKE "); - sb.append(DB.TO_STRING(s)); - } - // Lot Number - s = lotField.getText(); - if (s != null && s.length() > 0) - { - sb.append(" AND asi.Lot"); - if (s.indexOf('%') == -1 && s.indexOf('_') == 1) - sb.append("="); - else - sb.append(" LIKE "); - sb.append(DB.TO_STRING(s)); - } - // Lot ID - KeyNamePair pp = (KeyNamePair)lotSelection.getSelectedItem(); - if (pp != null && pp.getKey() != -1) - { - int ID = pp.getKey(); - sb.append(" AND asi.M_Lot_ID=").append(ID); - } - - // Guarantee Date - Timestamp ts = (Timestamp)guaranteeDateField.getValue(); - if (ts != null) - { - sb.append(" AND TRUNC(asi.GuaranteeDate)"); - int index = guaranteeDateSelection.getSelectedIndex(); // < = > - if (index == 0) - sb.append("<"); - else if (index == 1) - sb.append("="); - else - sb.append(">"); - sb.append(DB.TO_DATE(ts,true)); - } - - // Instance Editors - for (int i = 0; i < m_instanceEditors.size(); i++) - { - StringBuffer iAttr = new StringBuffer(); - Component c = (Component)m_instanceEditors.get(i); - Component cTo = (Component)m_instanceEditorsTo.get(i); - int M_Attribute_ID = Integer.parseInt(c.getName()); - if (c instanceof VComboBox) - { - VComboBox field = (VComboBox)c; - pp = (KeyNamePair)field.getSelectedItem(); - if (pp != null && pp.getKey() != -1) - { - iAttr.append("M_Attribute_ID=").append(M_Attribute_ID) - .append(" AND M_AttributeValue_ID=").append(pp.getKey()); - } - } - else if (c instanceof VNumber) - { - VNumber field = (VNumber)c; - BigDecimal value = (BigDecimal)field.getValue(); - VNumber fieldTo = (VNumber)cTo; - BigDecimal valueTo = (BigDecimal)fieldTo.getValue(); - if (value != null || valueTo != null) - { - iAttr.append("M_Attribute_ID=").append(M_Attribute_ID) - .append(" AND ValueNumber"); - if (value != null && valueTo == null) - iAttr.append("=").append(value); - else if (value == null && valueTo != null) - iAttr.append("<=").append(valueTo); - else if (value != null && valueTo != null) - iAttr.append(" BETWEEN ").append(value) - .append(" AND ").append(valueTo); - } - } - else - { - VString field = (VString)c; - String value = field.getText(); - if (value != null && value.length() > 0) - { - iAttr.append("M_Attribute_ID=").append(M_Attribute_ID) - .append(" AND Value"); - if (value.indexOf('%') == -1 && value.indexOf('_') == -1) - iAttr.append("="); - else - iAttr.append(" LIKE "); - iAttr.append(DB.TO_STRING(value)); - } - } - // Add to where - if (iAttr.length() > 0) - sb.append(" AND asi.M_AttributeSetInstance_ID IN " - + "(SELECT M_AttributeSetInstance_ID FROM M_AttributeInstance " - + "WHERE ") - .append(iAttr).append(")"); - } - - // finish Instance Attributes - if (sb.length() > 0) - { - sb.insert(0, " AND EXISTS (SELECT * FROM M_Storage s" - + " INNER JOIN M_AttributeSetInstance asi ON (s.M_AttributeSetInstance_ID=asi.M_AttributeSetInstance_ID) " - + "WHERE s.M_Product_ID=p.M_Product_ID"); - sb.append(")"); - } - - - // Product Attributes - for (int i = 0; i < m_productEditors.size(); i++) - { - StringBuffer pAttr = new StringBuffer(); - Component c = (Component)m_productEditors.get(i); - Component cTo = (Component)m_productEditorsTo.get(i); - int M_Attribute_ID = Integer.parseInt(c.getName()); - if (c instanceof VComboBox) - { - VComboBox field = (VComboBox)c; - pp = (KeyNamePair)field.getSelectedItem(); - if (pp != null && pp.getKey() != -1) - { - pAttr.append("M_Attribute_ID=").append(M_Attribute_ID) - .append(" AND M_AttributeValue_ID=").append(pp.getKey()); - } - } - else if (c instanceof VNumber) - { - VNumber field = (VNumber)c; - BigDecimal value = (BigDecimal)field.getValue(); - VNumber fieldTo = (VNumber)cTo; - BigDecimal valueTo = (BigDecimal)fieldTo.getValue(); - if (value != null || valueTo != null) - { - pAttr.append("M_Attribute_ID=").append(M_Attribute_ID) - .append(" AND ValueNumber"); - if (value != null && valueTo == null) - pAttr.append("=").append(value); - else if (value == null && valueTo != null) - pAttr.append("<=").append(valueTo); - else if (value != null && valueTo != null) - pAttr.append(" BETWEEN ").append(value) - .append(" AND ").append(valueTo); - } - } - else - { - VString field = (VString)c; - String value = field.getText(); - if (value != null && value.length() > 0) - { - pAttr.append("M_Attribute_ID=").append(M_Attribute_ID) - .append(" AND Value"); - if (value.indexOf('%') == -1 && value.indexOf('_') == -1) - pAttr.append("="); - else - pAttr.append(" LIKE "); - pAttr.append(DB.TO_STRING(value)); - } - } - // Add to Where - if (pAttr.length() > 0) - sb.append(" AND p.M_AttributeSetInstance_ID IN " - + "(SELECT M_AttributeSetInstance_ID " - + "FROM M_AttributeInstance WHERE ") - .append(pAttr).append(")"); - } - // - m_query = null; - if (sb.length() > 0) - m_query = sb.toString(); - log.config(m_query); - return m_query; - } // createQuery - - /** - * Get resulting Query WHERE - * @return query or null - */ - public String getWhereClause() - { - return m_query; - } // getQuery - -} // InfoPAttribute diff --git a/org.adempiere.ui.swing/src/org/compiere/apps/search/InfoPayment.java b/org.adempiere.ui.swing/src/org/compiere/apps/search/InfoPayment.java deleted file mode 100644 index 87afc3e650..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/apps/search/InfoPayment.java +++ /dev/null @@ -1,385 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ -package org.compiere.apps.search; - -import java.awt.Frame; -import java.math.BigDecimal; -import java.sql.PreparedStatement; -import java.sql.SQLException; -import java.sql.Timestamp; -import java.util.logging.Level; - -import org.adempiere.plaf.AdempierePLAF; -import org.compiere.apps.ALayout; -import org.compiere.apps.ALayoutConstraint; -import org.compiere.grid.ed.VCheckBox; -import org.compiere.grid.ed.VDate; -import org.compiere.grid.ed.VLookup; -import org.compiere.grid.ed.VNumber; -import org.compiere.minigrid.IDColumn; -import org.compiere.model.MLookupFactory; -import org.compiere.model.MQuery; -import org.compiere.swing.CLabel; -import org.compiere.swing.CTextField; -import org.compiere.util.DisplayType; -import org.compiere.util.Env; -import org.compiere.util.Msg; -import org.compiere.util.Util; - -/** - * Info Payment - * - * @author Jorg Janke - * @version $Id: InfoPayment.java,v 1.2 2006/07/30 00:51:27 jjanke Exp $ - */ -public class InfoPayment extends Info -{ - /** - * - */ - private static final long serialVersionUID = -2917241055484901704L; - - /** - * Detail Protected Contructor - * @param frame parent frame - * @param modal modal - * @param WindowNo window no - * @param value query value - * @param multiSelection multiple selections - * @param whereClause whwre clause - */ - public InfoPayment(Frame frame, boolean modal, int WindowNo, String value, - boolean multiSelection, String whereClause) - { - this(frame, modal, WindowNo, value, multiSelection, whereClause, true); - } - - /** - * Detail Protected Contructor - * @param frame parent frame - * @param modal modal - * @param WindowNo window no - * @param value query value - * @param multiSelection multiple selections - * @param whereClause whwre clause - * @param lookup - */ - public InfoPayment(Frame frame, boolean modal, int WindowNo, String value, - boolean multiSelection, String whereClause, boolean lookup) - { - super (frame, modal, WindowNo, "p", "C_Payment_ID", multiSelection, whereClause, lookup); - log.info( "InfoPayment"); - setTitle(Msg.getMsg(Env.getCtx(), "InfoPayment")); - // - try - { - statInit(); - p_loadedOK = initInfo (); - } - catch (Exception e) - { - return; - } - // - int no = p_table.getRowCount(); - setStatusLine(Integer.toString(no) + " " + Msg.getMsg(Env.getCtx(), "SearchRows_EnterQuery"), false); - setStatusDB(Integer.toString(no)); - if (value != null && value.length() > 0) - { - fDocumentNo.setValue(value); - executeQuery(); - } - // - pack(); - // Focus - fDocumentNo.requestFocus(); - } // InfoPayment - - /** String Array of Column Info */ - //private Info_Column[] m_generalLayout; - /** list of query columns */ - //private ArrayList m_queryColumns = new ArrayList(); - /** Table Name */ - //private String m_tableName; - /** Key Column Name */ - //private String m_keyColumn; - - // Static Info - private CLabel lDocumentNo = new CLabel(Msg.translate(Env.getCtx(), "DocumentNo")); - private CTextField fDocumentNo = new CTextField(10); - // -// private CLabel lOrg_ID = new CLabel(Msg.translate(Env.getCtx(), "AD_Org_ID")); -// private VLookup fOrg_ID; - private CLabel lBPartner_ID = new CLabel(Msg.translate(Env.getCtx(), "BPartner")); - private VLookup fBPartner_ID; - // - private CLabel lDateFrom = new CLabel(Msg.translate(Env.getCtx(), "DateTrx")); - private VDate fDateFrom = new VDate("DateFrom", false, false, true, DisplayType.Date, Msg.translate(Env.getCtx(), "DateFrom")); - private CLabel lDateTo = new CLabel("-"); - private VDate fDateTo = new VDate("DateTo", false, false, true, DisplayType.Date, Msg.translate(Env.getCtx(), "DateTo")); - private CLabel lAmtFrom = new CLabel(Msg.translate(Env.getCtx(), "PayAmt")); - private VNumber fAmtFrom = new VNumber("AmtFrom", false, false, true, DisplayType.Amount, Msg.translate(Env.getCtx(), "AmtFrom")); - private CLabel lAmtTo = new CLabel("-"); - private VNumber fAmtTo = new VNumber("AmtTo", false, false, true, DisplayType.Amount, Msg.translate(Env.getCtx(), "AmtTo")); - private VCheckBox fIsReceipt = new VCheckBox ("IsReceipt", false, false, true, Msg.translate(Env.getCtx(), "IsReceipt"), "", false); - - /** Array of Column Info */ - private static final Info_Column[] s_paymentLayout = { - new Info_Column(" ", "p.C_Payment_ID", IDColumn.class), - new Info_Column(Msg.translate(Env.getCtx(), "C_BankAccount_ID"), - "(SELECT b.Name || ' ' || ba.AccountNo FROM C_Bank b, C_BankAccount ba WHERE b.C_Bank_ID=ba.C_Bank_ID AND ba.C_BankAccount_ID=p.C_BankAccount_ID)", String.class), - new Info_Column(Msg.translate(Env.getCtx(), "C_BPartner_ID"), - "(SELECT Name FROM C_BPartner bp WHERE bp.C_BPartner_ID=p.C_BPartner_ID)", String.class), - new Info_Column(Msg.translate(Env.getCtx(), "DateTrx"), - "p.DateTrx", Timestamp.class), - new Info_Column(Msg.translate(Env.getCtx(), "DocumentNo"), - "p.DocumentNo", String.class), - new Info_Column(Msg.translate(Env.getCtx(), "IsReceipt"), - "p.IsReceipt", Boolean.class), - new Info_Column(Msg.translate(Env.getCtx(), "C_Currency_ID"), - "(SELECT ISO_Code FROM C_Currency c WHERE c.C_Currency_ID=p.C_Currency_ID)", String.class), - new Info_Column(Msg.translate(Env.getCtx(), "PayAmt"), - "p.PayAmt", BigDecimal.class), - new Info_Column(Msg.translate(Env.getCtx(), "ConvertedAmount"), - "currencyBase(p.PayAmt,p.C_Currency_ID,p.DateTrx, p.AD_Client_ID,p.AD_Org_ID)", BigDecimal.class), - new Info_Column(Msg.translate(Env.getCtx(), "DiscountAmt"), - "p.DiscountAmt", BigDecimal.class), - new Info_Column(Msg.translate(Env.getCtx(), "WriteOffAmt"), - "p.WriteOffAmt", BigDecimal.class), - new Info_Column(Msg.translate(Env.getCtx(), "IsAllocated"), - "p.IsAllocated", Boolean.class) - }; - - /** - * Static Setup - add fields to parameterPanel - * @throws Exception if Lookups cannot be created - */ - private void statInit() throws Exception - { - lDocumentNo.setLabelFor(fDocumentNo); - fDocumentNo.setBackground(AdempierePLAF.getInfoBackground()); - fDocumentNo.addActionListener(this); - fIsReceipt.setSelected(!"N".equals(Env.getContext(Env.getCtx(), p_WindowNo, "IsSOTrx"))); - fIsReceipt.addActionListener(this); - // - // fOrg_ID = new VLookup("AD_Org_ID", false, false, true, - // MLookupFactory.create(Env.getCtx(), 3486, m_WindowNo, DisplayType.TableDir, false), - // DisplayType.TableDir, m_WindowNo); - // lOrg_ID.setLabelFor(fOrg_ID); - // fOrg_ID.setBackground(AdempierePLAF.getInfoBackground()); - fBPartner_ID = new VLookup("C_BPartner_ID", false, false, true, - MLookupFactory.get (Env.getCtx(), p_WindowNo, 0, 3499, DisplayType.Search)); - lBPartner_ID.setLabelFor(fBPartner_ID); - fBPartner_ID.setBackground(AdempierePLAF.getInfoBackground()); - // - lDateFrom.setLabelFor(fDateFrom); - fDateFrom.setBackground(AdempierePLAF.getInfoBackground()); - fDateFrom.setToolTipText(Msg.translate(Env.getCtx(), "DateFrom")); - lDateTo.setLabelFor(fDateTo); - fDateTo.setBackground(AdempierePLAF.getInfoBackground()); - fDateTo.setToolTipText(Msg.translate(Env.getCtx(), "DateTo")); - lAmtFrom.setLabelFor(fAmtFrom); - fAmtFrom.setBackground(AdempierePLAF.getInfoBackground()); - fAmtFrom.setToolTipText(Msg.translate(Env.getCtx(), "AmtFrom")); - lAmtTo.setLabelFor(fAmtTo); - fAmtTo.setBackground(AdempierePLAF.getInfoBackground()); - fAmtTo.setToolTipText(Msg.translate(Env.getCtx(), "AmtTo")); - // - parameterPanel.setLayout(new ALayout()); - // First Row - parameterPanel.add(lDocumentNo, new ALayoutConstraint(0,0)); - parameterPanel.add(fDocumentNo, null); - parameterPanel.add(lBPartner_ID, null); - parameterPanel.add(fBPartner_ID, null); - parameterPanel.add(fIsReceipt, new ALayoutConstraint(0,5)); - // 2nd Row - parameterPanel.add(lDateFrom, new ALayoutConstraint(1,2)); - parameterPanel.add(fDateFrom, null); - parameterPanel.add(lDateTo, null); - parameterPanel.add(fDateTo, null); - // 3rd Row - parameterPanel.add(lAmtFrom, new ALayoutConstraint(2,2)); - parameterPanel.add(fAmtFrom, null); - parameterPanel.add(lAmtTo, null); - parameterPanel.add(fAmtTo, null); - // parameterPanel.add(lOrg_ID, null); - // parameterPanel.add(fOrg_ID, null); - } // statInit - - /** - * General Init - * @return true, if success - */ - private boolean initInfo () - { - // Set Defaults - String bp = Env.getContext(Env.getCtx(), p_WindowNo, "C_BPartner_ID"); - if (bp != null && bp.length() != 0) - fBPartner_ID.setValue(Integer.valueOf(bp)); - - // prepare table - StringBuilder where = new StringBuilder("p.IsActive='Y'"); - if (p_whereClause.length() > 0) - where.append(" AND ").append(Util.replace(p_whereClause, "C_Payment.", "p.")); - prepareTable(s_paymentLayout, - " C_Payment_v p", - where.toString(), - "2,3,4"); - // - // MPayment.setIsAllocated(Env.getCtx(), 0, null); - return true; - } // initInfo - - - /************************************************************************** - * Construct SQL Where Clause and define parameters - * (setParameters needs to set parameters) - * Includes first AND - * @return sql where clause - */ - protected String getSQLWhere() - { - StringBuilder sql = new StringBuilder(); - if (fDocumentNo.getText().length() > 0) - sql.append(" AND UPPER(p.DocumentNo) LIKE ?"); - // - if (fBPartner_ID.getValue() != null) - sql.append(" AND p.C_BPartner_ID=?"); - // - if (fDateFrom.getValue() != null || fDateTo.getValue() != null) - { - Timestamp from = (Timestamp)fDateFrom.getValue(); - Timestamp to = (Timestamp)fDateTo.getValue(); - if (from == null && to != null) - sql.append(" AND TRUNC(p.DateTrx) <= ?"); - else if (from != null && to == null) - sql.append(" AND TRUNC(p.DateTrx) >= ?"); - else if (from != null && to != null) - sql.append(" AND TRUNC(p.DateTrx) BETWEEN ? AND ?"); - } - // - if (fAmtFrom.getValue() != null || fAmtTo.getValue() != null) - { - BigDecimal from = (BigDecimal)fAmtFrom.getValue(); - BigDecimal to = (BigDecimal)fAmtTo.getValue(); - if (from == null && to != null) - sql.append(" AND p.PayAmt <= ?"); - else if (from != null && to == null) - sql.append(" AND p.PayAmt >= ?"); - else if (from != null && to != null) - sql.append(" AND p.PayAmt BETWEEN ? AND ?"); - } - sql.append(" AND p.IsReceipt=?"); - - if (log.isLoggable(Level.FINE)) log.fine(sql.toString()); - return sql.toString(); - } // getSQLWhere - - /** - * Set Parameters for Query. - * (as defined in getSQLWhere) - * @param pstmt statement - * @param forCount for counting records - * @throws SQLException - */ - protected void setParameters(PreparedStatement pstmt, boolean forCount) throws SQLException - { - int index = 1; - if (fDocumentNo.getText().length() > 0) - pstmt.setString(index++, getSQLText(fDocumentNo)); - // - if (fBPartner_ID.getValue() != null) - { - Integer bp = (Integer)fBPartner_ID.getValue(); - pstmt.setInt(index++, bp.intValue()); - if (log.isLoggable(Level.FINE)) log.fine("BPartner=" + bp); - } - // - if (fDateFrom.getValue() != null || fDateTo.getValue() != null) - { - Timestamp from = (Timestamp)fDateFrom.getValue(); - Timestamp to = (Timestamp)fDateTo.getValue(); - if (log.isLoggable(Level.FINE)) log.fine("Date From=" + from + ", To=" + to); - if (from == null && to != null) - pstmt.setTimestamp(index++, to); - else if (from != null && to == null) - pstmt.setTimestamp(index++, from); - else if (from != null && to != null) - { - pstmt.setTimestamp(index++, from); - pstmt.setTimestamp(index++, to); - } - } - // - if (fAmtFrom.getValue() != null || fAmtTo.getValue() != null) - { - BigDecimal from = (BigDecimal)fAmtFrom.getValue(); - BigDecimal to = (BigDecimal)fAmtTo.getValue(); - if (log.isLoggable(Level.FINE)) log.fine("Amt From=" + from + ", To=" + to); - if (from == null && to != null) - pstmt.setBigDecimal(index++, to); - else if (from != null && to == null) - pstmt.setBigDecimal(index++, from); - else if (from != null && to != null) - { - pstmt.setBigDecimal(index++, from); - pstmt.setBigDecimal(index++, to); - } - } - pstmt.setString(index++, fIsReceipt.isSelected() ? "Y" : "N"); - } // setParameters - - /** - * Get SQL WHERE parameter - * @param f field - * @return Upper case text with % at the end - */ - private String getSQLText (CTextField f) - { - String s = f.getText().toUpperCase(); - if (!s.endsWith("%")) - s += "%"; - if (log.isLoggable(Level.FINE)) log.fine( "String=" + s); - return s; - } // getSQLText - - /** - * Zoom - */ - protected void zoom() - { - log.info( "InfoPayment.zoom"); - Integer C_Payment_ID = getSelectedRowKey(); - if (C_Payment_ID == null) - return; - MQuery query = new MQuery("C_Payment"); - query.addRestriction("C_Payment_ID", MQuery.EQUAL, C_Payment_ID); - query.setRecordCount(1); - int AD_WindowNo = getAD_Window_ID("C_Payment", fIsReceipt.isSelected()); - zoom (AD_WindowNo, query); - } // zoom - - /** - * Has Zoom - * @return true - */ - protected boolean hasZoom() - { - return true; - } // hasZoom - -} // InfoPayment diff --git a/org.adempiere.ui.swing/src/org/compiere/apps/search/InfoProduct.java b/org.adempiere.ui.swing/src/org/compiere/apps/search/InfoProduct.java deleted file mode 100644 index d9d600e5bd..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/apps/search/InfoProduct.java +++ /dev/null @@ -1,1412 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ -package org.compiere.apps.search; - -import java.awt.Dimension; -import java.awt.Frame; -import java.awt.Insets; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.awt.event.KeyAdapter; -import java.awt.event.KeyEvent; -import java.awt.event.MouseAdapter; -import java.awt.event.MouseEvent; -import java.math.BigDecimal; -import java.sql.PreparedStatement; -import java.sql.ResultSet; -import java.sql.SQLException; -import java.sql.Timestamp; -import java.util.ArrayList; -import java.util.Vector; -import java.util.logging.Level; - -import javax.swing.JScrollPane; -import javax.swing.event.ChangeEvent; -import javax.swing.event.ChangeListener; -import javax.swing.plaf.ColorUIResource; -import javax.swing.table.DefaultTableModel; - -import org.adempiere.plaf.AdempierePLAF; -import org.adempiere.plaf.AdempiereTaskPaneUI; -import org.compiere.apps.AEnv; -import org.compiere.apps.ALayout; -import org.compiere.apps.ALayoutConstraint; -import org.compiere.apps.ConfirmPanel; -import org.compiere.grid.ed.VComboBox; -import org.compiere.minigrid.ColumnInfo; -import org.compiere.minigrid.IDColumn; -import org.compiere.minigrid.MiniTable; -import org.compiere.model.MDocType; -import org.compiere.model.MQuery; -import org.compiere.model.MRole; -import org.compiere.swing.CButton; -import org.compiere.swing.CLabel; -import org.compiere.swing.CPanel; -import org.compiere.swing.CTabbedPane; -import org.compiere.swing.CTextArea; -import org.compiere.swing.CTextField; -import org.compiere.util.CLogMgt; -import org.compiere.util.DB; -import org.compiere.util.Env; -import org.compiere.util.KeyNamePair; -import org.compiere.util.Msg; -import org.compiere.util.Util; -import org.jdesktop.swingx.JXTaskPane; - - -/** - * Search Product and return selection - * - * @author Jorg Janke - * @version $Id: InfoProduct.java,v 1.4 2006/07/30 00:51:27 jjanke Exp $ - * - * @author Bogdan Ioan, SC ARHIPAC SERVICE SRL - *
  • FR [ 2012362 ] Info Product: Add Product Category - */ -public class InfoProduct extends Info implements ActionListener, ChangeListener -{ - /** - * - */ - private static final long serialVersionUID = -2119729271332154941L; - - /** - * Standard Constructor - * @param frame frame - * @param modal modal - * @param WindowNo window no - * @param M_Warehouse_ID warehouse - * @param M_PriceList_ID price list - * @param value Query Value or Name if enclosed in @ - * @param multiSelection multiple selections - * @param whereClause where clause - */ - public InfoProduct(Frame frame, boolean modal, int WindowNo, - int M_Warehouse_ID, int M_PriceList_ID, String value, - boolean multiSelection, String whereClause) - { - this(frame, modal, WindowNo, M_Warehouse_ID, M_PriceList_ID, value, multiSelection, whereClause, true); - } - - /** - * Standard Constructor - * @param frame frame - * @param modal modal - * @param WindowNo window no - * @param M_Warehouse_ID warehouse - * @param M_PriceList_ID price list - * @param value Query Value or Name if enclosed in @ - * @param multiSelection multiple selections - * @param whereClause where clause - */ - public InfoProduct(Frame frame, boolean modal, int WindowNo, - int M_Warehouse_ID, int M_PriceList_ID, String value, - boolean multiSelection, String whereClause, boolean lookup) - { - super (frame, modal, WindowNo, "p", "M_Product_ID", multiSelection, whereClause, lookup); - if (log.isLoggable(Level.INFO)) log.info(value + ", Wh=" + M_Warehouse_ID + ", PL=" + M_PriceList_ID + ", WHERE=" + whereClause); - setTitle(Msg.getMsg(Env.getCtx(), "InfoProduct")); - // - statInit(); - initInfo (value, M_Warehouse_ID, M_PriceList_ID); - m_C_BPartner_ID = Env.getContextAsInt(Env.getCtx(), WindowNo, "C_BPartner_ID"); - - // - int no = p_table.getRowCount(); - setStatusLine(Integer.toString(no) + " " + Msg.getMsg(Env.getCtx(), "SearchRows_EnterQuery"), false); - setStatusDB(Integer.toString(no)); - // AutoQuery - if (value != null && value.length() > 0) - executeQuery(); - p_loadedOK = true; - // Focus - fieldValue.requestFocus(); - - //Begin - fer_luck @ centuryon - mWindowNo = WindowNo; - //End - fer_luck @ centuryon - AEnv.positionCenterWindow(frame, this); - } // InfoProduct - - /** SQL From */ - private static final String s_productFrom = - "M_Product p" - + " LEFT OUTER JOIN M_ProductPrice pr ON (p.M_Product_ID=pr.M_Product_ID AND pr.IsActive='Y')" - + " LEFT OUTER JOIN M_AttributeSet pa ON (p.M_AttributeSet_ID=pa.M_AttributeSet_ID)" - + " LEFT OUTER JOIN M_Product_PO ppo ON (p.M_Product_ID=ppo.M_Product_ID and ppo.IsCurrentVendor='Y' and ppo.IsActive='Y')" - + " LEFT OUTER JOIN C_BPartner bp ON (ppo.C_BPartner_ID=bp.C_BPartner_ID)"; - - /** Array of Column Info */ - private static Info_Column[] s_productLayout = null; - private static int INDEX_NAME = 0; - private static int INDEX_PATTRIBUTE = 0; - - // - private CLabel labelValue = new CLabel(); - private CTextField fieldValue = new CTextField(10); - private CLabel labelName = new CLabel(); - private CTextField fieldName = new CTextField(10); - private CLabel labelUPC = new CLabel(); - private CTextField fieldUPC = new CTextField(10); - private CLabel labelSKU = new CLabel(); - private CTextField fieldSKU = new CTextField(10); - private CLabel labelPriceList = new CLabel(); - private VComboBox pickPriceList = new VComboBox(); - private CLabel labelWarehouse = new CLabel(); - private VComboBox pickWarehouse = new VComboBox(); - private CLabel labelVendor = new CLabel(); - private CTextField fieldVendor = new CTextField(10); - private CLabel labelProductCategory = new CLabel(); - private VComboBox pickProductCategory = new VComboBox(); - private CLabel labelAS = new CLabel(); // @Trifon - private VComboBox pickAS = new VComboBox(); // @Trifon - - //Begin - fer_luck @ centuryon - private CTextArea fieldDescription = new CTextArea(); - JXTaskPane warehouseStockPanel = new JXTaskPane(); - CPanel tablePanel = new CPanel(); - MiniTable warehouseTbl = new MiniTable(); - String m_sqlWarehouse; - MiniTable substituteTbl = new MiniTable(); - String m_sqlSubstitute; - MiniTable relatedTbl = new MiniTable(); - String m_sqlRelated; - //Available to Promise Tab - private MiniTable m_tableAtp = new MiniTable(); - private DefaultTableModel m_modelAtp = null; - private int m_M_Product_ID = 0; - int mWindowNo = 0; - //End - fer_luck @ centuryon - - //IDEMPIERE-339 - MiniTable productpriceTbl = new MiniTable(); - String m_sqlProductprice; - - /** Search Button */ - private CButton m_InfoPAttributeButton = new CButton(Env.getImageIcon("PAttribute16.gif")); - /** Instance Button */ - private CButton m_PAttributeButton = null; - /** ASI */ - private int m_M_AttributeSetInstance_ID = -1; - /** Locator */ - private int m_M_Locator_ID = 0; - - private String m_pAttributeWhere = null; - private int m_C_BPartner_ID = 0; - - /** - * Static Setup - add fields to parameterPanel - */ - private void statInit() - { - labelValue.setText(Msg.getMsg(Env.getCtx(), "Value")); - fieldValue.setBackground(AdempierePLAF.getInfoBackground()); - fieldValue.addActionListener(this); - - labelName.setText(Msg.getMsg(Env.getCtx(), "Name")); - fieldName.setBackground(AdempierePLAF.getInfoBackground()); - fieldName.addActionListener(this); - - labelUPC.setText(Msg.translate(Env.getCtx(), "UPC")); - fieldUPC.setBackground(AdempierePLAF.getInfoBackground()); - fieldUPC.addActionListener(this); - - labelSKU.setText(Msg.translate(Env.getCtx(), "SKU")); - fieldSKU.setBackground(AdempierePLAF.getInfoBackground()); - fieldSKU.addActionListener(this); - - labelWarehouse.setText(Msg.getMsg(Env.getCtx(), "Warehouse")); - pickWarehouse.setBackground(AdempierePLAF.getInfoBackground()); - - labelPriceList.setText(Msg.getMsg(Env.getCtx(), "PriceListVersion")); - pickPriceList.setBackground(AdempierePLAF.getInfoBackground()); - - labelProductCategory.setText(Msg.translate(Env.getCtx(), "M_Product_Category_ID")); - pickProductCategory.setBackground(AdempierePLAF.getInfoBackground()); - - // @Trifon - labelAS.setText(Msg.translate(Env.getCtx(), "M_AttributeSet_ID")); - pickAS.setBackground(AdempierePLAF.getInfoBackground()); - - m_InfoPAttributeButton.setMargin(new Insets(2,2,2,2)); - m_InfoPAttributeButton.setToolTipText(Msg.getMsg(Env.getCtx(), "InfoPAttribute")); - m_InfoPAttributeButton.addActionListener(this); - - labelVendor.setText(Msg.translate(Env.getCtx(), "Vendor")); - fieldVendor.setBackground(AdempierePLAF.getInfoBackground()); - fieldVendor.addActionListener(this); - - // Line 1 - parameterPanel.setLayout(new ALayout()); - parameterPanel.add(labelValue, new ALayoutConstraint(0,0)); - parameterPanel.add(fieldValue, null); - parameterPanel.add(labelUPC, null); - parameterPanel.add(fieldUPC, null); - parameterPanel.add(labelWarehouse, null); - parameterPanel.add(pickWarehouse, null); - parameterPanel.add(m_InfoPAttributeButton); - // Line 2 - parameterPanel.add(labelName, new ALayoutConstraint(1,0)); - parameterPanel.add(fieldName, null); - parameterPanel.add(labelSKU, null); - parameterPanel.add(fieldSKU, null); - parameterPanel.add(labelVendor, null); - parameterPanel.add(fieldVendor, null); - - // Line 3 - parameterPanel.add(labelPriceList, new ALayoutConstraint(2,0)); - parameterPanel.add(pickPriceList, null); - parameterPanel.add(labelProductCategory, null); - parameterPanel.add(pickProductCategory, null); - parameterPanel.add(labelAS, null); // @Trifon - parameterPanel.add(pickAS, null); // @Trifon - - // Product Attribute Instance - m_PAttributeButton = ConfirmPanel.createPAttributeButton(true); - confirmPanel.addButton(m_PAttributeButton); - m_PAttributeButton.addActionListener(this); - m_PAttributeButton.setEnabled(false); - - //Begin - fer_luck @ centuryon - //add taskpane - fieldDescription.setBackground(AdempierePLAF.getInfoBackground()); - fieldDescription.setEditable(false); - fieldDescription.setPreferredSize(new Dimension(INFO_WIDTH - 100, 100)); - - warehouseStockPanel.setTitle(Msg.translate(Env.getCtx(), "WarehouseStock")); - warehouseStockPanel.setUI(new AdempiereTaskPaneUI()); - warehouseStockPanel.getContentPane().setBackground(new ColorUIResource(251,248,241)); - warehouseStockPanel.getContentPane().setForeground(new ColorUIResource(251,0,0)); - - ColumnInfo[] s_layoutWarehouse = new ColumnInfo[]{ - new ColumnInfo(Msg.translate(Env.getCtx(), "Warehouse"), "Warehouse", String.class), - new ColumnInfo(Msg.translate(Env.getCtx(), "QtyAvailable"), "sum(QtyAvailable)", Double.class), - new ColumnInfo(Msg.translate(Env.getCtx(), "QtyOnHand"), "sum(QtyOnHand)", Double.class), - new ColumnInfo(Msg.translate(Env.getCtx(), "QtyReserved"), "sum(QtyReserved)", Double.class)}; - /** From Clause */ - String s_sqlFrom = " M_PRODUCT_STOCK_V "; - /** Where Clause */ - String s_sqlWhere = "Value = ?"; - m_sqlWarehouse = warehouseTbl.prepareTable(s_layoutWarehouse, s_sqlFrom, s_sqlWhere, false, "M_PRODUCT_STOCK_V"); - m_sqlWarehouse += " GROUP BY Warehouse"; - warehouseTbl.setRowSelectionAllowed(true); - warehouseTbl.setMultiSelection(false); - warehouseTbl.addMouseListener(this); - warehouseTbl.getSelectionModel().addListSelectionListener(this); - warehouseTbl.setShowTotals(true); - warehouseTbl.autoSize(); - - ColumnInfo[] s_layoutSubstitute = new ColumnInfo[]{ - new ColumnInfo(Msg.translate(Env.getCtx(), "Warehouse"), "orgname", String.class), - new ColumnInfo( - Msg.translate(Env.getCtx(), "Value"), - "(Select Value from M_Product p where p.M_Product_ID=M_PRODUCT_SUBSTITUTERELATED_V.Substitute_ID)", - String.class), - new ColumnInfo(Msg.translate(Env.getCtx(), "Name"), "Name", String.class), - new ColumnInfo(Msg.translate(Env.getCtx(), "QtyAvailable"), "QtyAvailable", Double.class), - new ColumnInfo(Msg.translate(Env.getCtx(), "QtyOnHand"), "QtyOnHand", Double.class), - new ColumnInfo(Msg.translate(Env.getCtx(), "QtyReserved"), "QtyReserved", Double.class), - new ColumnInfo(Msg.translate(Env.getCtx(), "PriceStd"), "PriceStd", Double.class)}; - s_sqlFrom = "M_PRODUCT_SUBSTITUTERELATED_V"; - s_sqlWhere = "M_Product_ID = ? AND M_PriceList_Version_ID = ? and RowType = 'S'"; - m_sqlSubstitute = substituteTbl.prepareTable(s_layoutSubstitute, s_sqlFrom, s_sqlWhere, false, "M_PRODUCT_SUBSTITUTERELATED_V"); - substituteTbl.setRowSelectionAllowed(false); - substituteTbl.setMultiSelection(false); - substituteTbl.addMouseListener(this); - substituteTbl.getSelectionModel().addListSelectionListener(this); - substituteTbl.autoSize(); - - ColumnInfo[] s_layoutRelated = new ColumnInfo[]{ - new ColumnInfo(Msg.translate(Env.getCtx(), "Warehouse"), "orgname", String.class), - new ColumnInfo( - Msg.translate(Env.getCtx(), "Value"), - "(Select Value from M_Product p where p.M_Product_ID=M_PRODUCT_SUBSTITUTERELATED_V.Substitute_ID)", - String.class), - new ColumnInfo(Msg.translate(Env.getCtx(), "Name"), "Name", String.class), - new ColumnInfo(Msg.translate(Env.getCtx(), "QtyAvailable"), "QtyAvailable", Double.class), - new ColumnInfo(Msg.translate(Env.getCtx(), "QtyOnHand"), "QtyOnHand", Double.class), - new ColumnInfo(Msg.translate(Env.getCtx(), "QtyReserved"), "QtyReserved", Double.class), - new ColumnInfo(Msg.translate(Env.getCtx(), "PriceStd"), "PriceStd", Double.class)}; - s_sqlFrom = "M_PRODUCT_SUBSTITUTERELATED_V"; - s_sqlWhere = "M_Product_ID = ? AND M_PriceList_Version_ID = ? and RowType = 'R'"; - m_sqlRelated = relatedTbl.prepareTable(s_layoutRelated, s_sqlFrom, s_sqlWhere, false, "M_PRODUCT_SUBSTITUTERELATED_V"); - relatedTbl.setRowSelectionAllowed(false); - relatedTbl.setMultiSelection(false); - relatedTbl.addMouseListener(this); - relatedTbl.getSelectionModel().addListSelectionListener(this); - relatedTbl.autoSize(); - - //Available to Promise Tab - m_tableAtp.setRowSelectionAllowed(false); - m_tableAtp.setMultiSelection(false); - - //IDEMPIERE-339 - ArrayList list = new ArrayList(); - list.add(new ColumnInfo(Msg.translate(Env.getCtx(), "PriceListVersion"), "plv.Name", String.class)); - list.add(new ColumnInfo(Msg.translate(Env.getCtx(), "ValidFrom"), "plv.ValidFrom", Timestamp.class)); - if (MRole.getDefault().isColumnAccess(251 /*M_ProductPrice*/, 3027/*PriceList*/, false)) - list.add(new ColumnInfo(Msg.translate(Env.getCtx(), "PriceList"), "bomPriceList(pp.M_Product_ID, pp.M_PriceList_Version_ID) AS PriceList", Double.class)); - if (MRole.getDefault().isColumnAccess(251 /*M_ProductPrice*/, 3028/*PriceStd*/, false)) - list.add(new ColumnInfo(Msg.translate(Env.getCtx(), "PriceStd"), "bomPriceStd(pp.M_Product_ID, pp.M_PriceList_Version_ID) AS PriceStd", Double.class)); - if (MRole.getDefault().isColumnAccess(251 /*M_ProductPrice*/, 3028/*PriceStd*/, false) && MRole.getDefault().isColumnAccess(251 /*M_ProductPrice*/, 3029/*PriceLimit*/, false)) - list.add(new ColumnInfo(Msg.translate(Env.getCtx(), "Margin"), "bomPriceStd(pp.M_Product_ID, pp.M_PriceList_Version_ID)-bomPriceLimit(pp.M_Product_ID, pp.M_PriceList_Version_ID) AS Margin", Double.class)); - if (MRole.getDefault().isColumnAccess(251 /*M_ProductPrice*/, 3029/*PriceLimit*/, false)) - list.add(new ColumnInfo(Msg.translate(Env.getCtx(), "PriceLimit"), "bomPriceLimit(pp.M_Product_ID, pp.M_PriceList_Version_ID) AS PriceLimit", Double.class)); - ColumnInfo[] s_layoutProductPrice = new ColumnInfo[list.size()]; - list.toArray(s_layoutProductPrice); - s_sqlFrom = "M_ProductPrice pp INNER JOIN M_PriceList_Version plv ON (pp.M_PriceList_Version_ID = plv.M_PriceList_Version_ID)"; - s_sqlWhere = "pp.M_Product_ID = ? AND plv.IsActive = 'Y' AND pp.IsActive = 'Y'"; - m_sqlProductprice = productpriceTbl.prepareTable(s_layoutProductPrice, s_sqlFrom, s_sqlWhere, false, "pp") + " ORDER BY plv.ValidFrom DESC"; - productpriceTbl.setRowSelectionAllowed(false); - productpriceTbl.setMultiSelection(false); - productpriceTbl.addMouseListener(this); - productpriceTbl.getSelectionModel().addListSelectionListener(this); - productpriceTbl.autoSize(); - - CTabbedPane jTab = new CTabbedPane(); - jTab.addTab(Msg.translate(Env.getCtx(), "Warehouse"), new JScrollPane(warehouseTbl)); - jTab.setPreferredSize(new Dimension(INFO_WIDTH, SCREEN_HEIGHT > 600 ? 250 : 105)); - jTab.addTab(Msg.translate(Env.getCtx(), "Description"), new JScrollPane(fieldDescription)); - jTab.addTab(Msg.translate(Env.getCtx(), "Substitute_ID"), new JScrollPane(substituteTbl)); - jTab.addTab(Msg.translate(Env.getCtx(), "RelatedProduct_ID"), new JScrollPane(relatedTbl)); - jTab.addTab(Msg.getMsg(Env.getCtx(), "ATP"), new JScrollPane(m_tableAtp)); - jTab.addTab(Msg.translate(Env.getCtx(), "Price"), new JScrollPane(productpriceTbl)); - jTab.addChangeListener(this); - tablePanel.setPreferredSize(new Dimension(INFO_WIDTH, SCREEN_HEIGHT > 600 ? 255 : 110)); - tablePanel.add(jTab); - - warehouseStockPanel.setCollapsed(true); - warehouseStockPanel.add(tablePanel); - this.addonPanel.add(warehouseStockPanel); - - this.p_table.addKeyListener(new KeyAdapter() { - public void keyReleased(KeyEvent ke){ - int row = ((MiniTable)ke.getSource()).getSelectedRow(); - refresh( - ((MiniTable)ke.getSource()).getValueAt(row,2), - new BigDecimal(pickWarehouse.getValue().toString()).intValue(), - new BigDecimal(pickPriceList.getValue().toString()).intValue() - ); - warehouseStockPanel.setCollapsed(false); - } - }); - - this.p_table.addMouseListener(new MouseAdapter() { - public void mouseClicked(MouseEvent me) { - int row = ((MiniTable)me.getSource()).getSelectedRow(); - refresh( - ((MiniTable)me.getSource()).getValueAt(row,2), - new BigDecimal(pickWarehouse.getValue().toString()).intValue(), - new BigDecimal(pickPriceList.getValue().toString()).intValue() - ); - warehouseStockPanel.setCollapsed(false); - } - }); - //End - fer_luck @ centuryon - } // statInit - - //Begin - fer_luck @ centuryon - /** - * Refresh Query - */ - private void refresh(Object obj, int M_Warehouse_ID, int M_PriceList_Version_ID) - { - //int M_Product_ID = 0; - String sql = m_sqlWarehouse; - log.finest(sql); - PreparedStatement pstmt = null; - ResultSet rs = null; - try - { - pstmt = DB.prepareStatement(sql, null); - pstmt.setString(1, (String)obj); - rs = pstmt.executeQuery(); - warehouseTbl.loadTable(rs); - } - catch (Exception e) - { - log.log(Level.WARNING, sql, e); - } - finally - { - DB.close(rs, pstmt); - rs = null; pstmt = null; - } - - m_M_Product_ID = getSelectedRowKey(); - sql = "SELECT DocumentNote FROM M_Product WHERE M_Product_ID=?"; - fieldDescription.setText(DB.getSQLValueString(null, sql, m_M_Product_ID)); - - sql = m_sqlSubstitute; - log.finest(sql); - try { - pstmt = DB.prepareStatement(sql, null); - pstmt.setInt(1, m_M_Product_ID); - pstmt.setInt(2, M_PriceList_Version_ID); - rs = pstmt.executeQuery(); - substituteTbl.loadTable(rs); - } catch (Exception e) { - log.log(Level.WARNING, sql, e); - } - finally - { - DB.close(rs, pstmt); - rs = null; pstmt = null; - } - - sql = m_sqlRelated; - log.finest(sql); - try { - pstmt = DB.prepareStatement(sql, null); - pstmt.setInt(1, m_M_Product_ID); - pstmt.setInt(2, M_PriceList_Version_ID); - rs = pstmt.executeQuery(); - relatedTbl.loadTable(rs); - } catch (Exception e) { - log.log(Level.WARNING, sql, e); - } - finally - { - DB.close(rs, pstmt); - rs = null; pstmt = null; - } - initAtpTab(M_Warehouse_ID); - - // IDEMPIERE-339 - sql = m_sqlProductprice; - log.finest(sql); - try { - pstmt = DB.prepareStatement(sql, null); - pstmt.setInt(1, m_M_Product_ID); - rs = pstmt.executeQuery(); - productpriceTbl.loadTable(rs); - } catch (Exception e) { - log.log(Level.WARNING, sql, e); - } - finally - { - DB.close(rs, pstmt); - rs = null; pstmt = null; - } - } // refresh - //End - fer_luck @ centuryon - - /** - * Dynamic Init - * - * @param value value - * @param M_Warehouse_ID warehouse - * @param M_PriceList_ID price list - */ - private void initInfo (String value, int M_Warehouse_ID, int M_PriceList_ID) - { - // Pick init - fillPicks(M_PriceList_ID); - int M_PriceList_Version_ID = findPLV (M_PriceList_ID); - // Set Value - if (value != null && value.length() > 0 && value.indexOf("_") > 0) { - String values[] = value.split("_"); - fieldValue.setText(values[0]); - } - else - fieldValue.setText(value); - // Set Warehouse - if (M_Warehouse_ID == 0) - M_Warehouse_ID = Env.getContextAsInt(Env.getCtx(), "#M_Warehouse_ID"); - if (M_Warehouse_ID != 0) - setWarehouse (M_Warehouse_ID); - // Set PriceList Version - if (M_PriceList_Version_ID != 0) - setPriceListVersion (M_PriceList_Version_ID); - - // Create Grid - String orderBy = null; - StringBuilder where = new StringBuilder(); - where.append("p.IsActive='Y'"); - if (M_Warehouse_ID != 0) - { - where.append(" AND p.IsSummary='N'"); - orderBy = "QtyAvailable DESC"; - } - - // dynamic Where Clause - if (p_whereClause != null && p_whereClause.length() > 0) - where.append(" AND ") // replace fully qualified name with alias - .append(Util.replace(p_whereClause, "M_Product.", "p.")); - // - prepareTable(getProductLayout(), - s_productFrom, - where.toString(), - orderBy); - p_table.setShowTotals(false); - // - pickWarehouse.addActionListener(this); - pickPriceList.addActionListener(this); - pickProductCategory.addActionListener(this); - pickAS.addActionListener(this); // @Trifon - } // initInfo - - /** - * Fill Picks with values - * - * @param M_PriceList_ID price list - */ - private void fillPicks (int M_PriceList_ID) - { - // Price List - String SQL = "SELECT M_PriceList_Version.M_PriceList_Version_ID," - + " M_PriceList_Version.Name || ' (' || c.Iso_Code || ')' AS ValueName " - + "FROM M_PriceList_Version, M_PriceList pl, C_Currency c " - + "WHERE M_PriceList_Version.M_PriceList_ID=pl.M_PriceList_ID" - + " AND pl.C_Currency_ID=c.C_Currency_ID" - + " AND M_PriceList_Version.IsActive='Y' AND pl.IsActive='Y'"; - // Same PL currency as original one - if (M_PriceList_ID != 0) - SQL += " AND EXISTS (SELECT * FROM M_PriceList xp WHERE xp.M_PriceList_ID=" + M_PriceList_ID - + " AND pl.C_Currency_ID=xp.C_Currency_ID)"; - // Add Access & Order - SQL = MRole.getDefault().addAccessSQL (SQL, "M_PriceList_Version", true, false) // fully qualified - RO - + " ORDER BY M_PriceList_Version.Name"; - PreparedStatement pstmt = null; - ResultSet rs = null; - try - { - pickPriceList.addItem(new KeyNamePair (0, "")); - pstmt = DB.prepareStatement(SQL, null); - rs = pstmt.executeQuery(); - while (rs.next()) - { - KeyNamePair kn = new KeyNamePair (rs.getInt(1), rs.getString(2)); - pickPriceList.addItem(kn); - } - DB.close(rs, pstmt); - rs = null; pstmt = null; - - // Warehouse - SQL = MRole.getDefault().addAccessSQL ( - "SELECT M_Warehouse_ID, Value || ' - ' || Name AS ValueName " - + "FROM M_Warehouse " - + "WHERE IsActive='Y'", - "M_Warehouse", MRole.SQL_NOTQUALIFIED, MRole.SQL_RO) - + " ORDER BY Value"; - pickWarehouse.addItem(new KeyNamePair (0, "")); - pstmt = DB.prepareStatement(SQL, null); - rs = pstmt.executeQuery(); - while (rs.next()) - { - KeyNamePair kn = new KeyNamePair - (rs.getInt("M_Warehouse_ID"), rs.getString("ValueName")); - pickWarehouse.addItem(kn); - } - DB.close(rs, pstmt); - rs = null; pstmt = null; - - // Product Category - SQL = MRole.getDefault().addAccessSQL ( - "SELECT M_Product_Category_ID, Value || ' - ' || Name FROM M_Product_Category WHERE IsActive='Y'", - "M_Product_Category", MRole.SQL_NOTQUALIFIED, MRole.SQL_RO) - + " ORDER BY Value"; - for (KeyNamePair kn : DB.getKeyNamePairs(SQL, true)) { - pickProductCategory.addItem(kn); - } - - // Attribute Set - @Trifon - SQL = MRole.getDefault().addAccessSQL ( - "SELECT M_AttributeSet_ID, Name FROM M_AttributeSet WHERE IsActive='Y'", - "M_AttributeSet", MRole.SQL_NOTQUALIFIED, MRole.SQL_RO) - + " ORDER BY Name"; - for (KeyNamePair kn : DB.getKeyNamePairs(SQL, true)) { - pickAS.addItem(kn); - } - } - catch (SQLException e) - { - log.log(Level.SEVERE, SQL, e); - setStatusLine(e.getLocalizedMessage(), true); - } - finally - { - DB.close(rs, pstmt); - rs = null; pstmt = null; - } - } // fillPicks - - /** - * Set Warehouse - * - * @param M_Warehouse_ID warehouse - */ - private void setWarehouse(int M_Warehouse_ID) - { - for (int i = 0; i < pickWarehouse.getItemCount(); i++) - { - KeyNamePair kn = (KeyNamePair)pickWarehouse.getItemAt(i); - if (kn.getKey() == M_Warehouse_ID) - { - pickWarehouse.setSelectedIndex(i); - return; - } - } - } // setWarehouse - - /** - * Set PriceList - * - * @param M_PriceList_Version_ID price list - */ - private void setPriceListVersion(int M_PriceList_Version_ID) - { - if (log.isLoggable(Level.CONFIG)) log.config("M_PriceList_Version_ID=" + M_PriceList_Version_ID); - for (int i = 0; i < pickPriceList.getItemCount(); i++) - { - KeyNamePair kn = (KeyNamePair)pickPriceList.getItemAt(i); - if (kn.getKey() == M_PriceList_Version_ID) - { - pickPriceList.setSelectedIndex(i); - return; - } - } - log.fine("NOT found"); - } // setPriceList - - /** - * Find Price List Version and update context - * - * @param M_PriceList_ID price list - * @return M_PriceList_Version_ID price list version - */ - private int findPLV (int M_PriceList_ID) - { - Timestamp priceDate = null; - // Sales Order Date - String dateStr = Env.getContext(Env.getCtx(), p_WindowNo, "DateOrdered"); - if (dateStr != null && dateStr.length() > 0) - priceDate = Env.getContextAsDate(Env.getCtx(), p_WindowNo, "DateOrdered"); - else // Invoice Date - { - dateStr = Env.getContext(Env.getCtx(), p_WindowNo, "DateInvoiced"); - if (dateStr != null && dateStr.length() > 0) - priceDate = Env.getContextAsDate(Env.getCtx(), p_WindowNo, "DateInvoiced"); - } - // Today - if (priceDate == null) - priceDate = new Timestamp(System.currentTimeMillis()); - // - if (log.isLoggable(Level.CONFIG)) log.config("M_PriceList_ID=" + M_PriceList_ID + " - " + priceDate); - int retValue = 0; - String sql = "SELECT plv.M_PriceList_Version_ID, plv.ValidFrom " - + "FROM M_PriceList pl, M_PriceList_Version plv " - + "WHERE pl.M_PriceList_ID=plv.M_PriceList_ID" - + " AND plv.IsActive='Y'" - + " AND pl.M_PriceList_ID=? " // 1 - + "ORDER BY plv.ValidFrom DESC"; - // find newest one - PreparedStatement pstmt = null; - ResultSet rs = null; - try - { - pstmt = DB.prepareStatement(sql, null); - pstmt.setInt(1, M_PriceList_ID); - rs = pstmt.executeQuery(); - while (rs.next() && retValue == 0) - { - Timestamp plDate = rs.getTimestamp(2); - if (!priceDate.before(plDate)) - retValue = rs.getInt(1); - } - } - catch (SQLException e) - { - log.log(Level.SEVERE, sql, e); - } - finally { - DB.close(rs, pstmt); - rs = null; pstmt = null; - } - Env.setContext(Env.getCtx(), p_WindowNo, "M_PriceList_Version_ID", retValue); - return retValue; - } // findPLV - - - /************************************************************************** - * Construct SQL Where Clause and define parameters - * (setParameters needs to set parameters) - * Includes first AND - * @return SQL WHERE clause - */ - protected String getSQLWhere() - { - StringBuilder where = new StringBuilder(); - - // Optional PLV - int M_PriceList_Version_ID = 0; - KeyNamePair pl = (KeyNamePair)pickPriceList.getSelectedItem(); - if (pl != null) - M_PriceList_Version_ID = pl.getKey(); - if (M_PriceList_Version_ID != 0) - where.append(" AND pr.M_PriceList_Version_ID=?"); - - // Optional Product Category - if (getM_Product_Category_ID() > 0) { - where.append(" AND p.M_Product_Category_ID=?"); - } - - // Optional Attribute Set - if (getM_AttributeSet_ID() > 0) { - where.append(" AND p.M_AttributeSet_ID=?"); - } - - // Product Attribute Search - if (m_pAttributeWhere != null) - { - where.append(m_pAttributeWhere); - return where.toString(); - } - - // => Value - String value = fieldValue.getText().toUpperCase(); - if (!(value.equals("") || value.equals("%"))) - where.append(" AND UPPER(p.Value) LIKE ?"); - - // => Name - String name = fieldName.getText().toUpperCase(); - if (!(name.equals("") || name.equals("%"))) - where.append(" AND UPPER(p.Name) LIKE ?"); - - // => UPC - String upc = fieldUPC.getText().toUpperCase(); - if (!(upc.equals("") || upc.equals("%"))) - where.append(" AND UPPER(p.UPC) LIKE ?"); - - // => SKU - String sku = fieldSKU.getText().toUpperCase(); - if (!(sku.equals("") || sku.equals("%"))) - where.append(" AND UPPER(p.SKU) LIKE ?"); - // => Vendor - String vendor = fieldVendor.getText().toUpperCase(); - if (!(vendor.equals("") || vendor.equals("%"))) - where.append(" AND UPPER(bp.Name) LIKE ? AND ppo.IsCurrentVendor='Y'"); - - return where.toString(); - } // getSQLWhere - - /** - * Set Parameters for Query - * (as defined in getSQLWhere) - * - * @param pstmt pstmt - * @param forCount for counting records - * @throws SQLException - */ - protected void setParameters(PreparedStatement pstmt, boolean forCount) throws SQLException - { - int index = 1; - - // => Warehouse - int M_Warehouse_ID = 0; - KeyNamePair wh = (KeyNamePair)pickWarehouse.getSelectedItem(); - if (wh != null) - M_Warehouse_ID = wh.getKey(); - if (!forCount) // parameters in select - { - for (int i = 0; i < p_layout.length; i++) - { - if (p_layout[i].getColSQL().indexOf('?') != -1) - pstmt.setInt(index++, M_Warehouse_ID); - } - } - if (log.isLoggable(Level.FINE)) log.fine("M_Warehouse_ID=" + M_Warehouse_ID + " (" + (index-1) + "*)"); - - // => PriceList - int M_PriceList_Version_ID = 0; - KeyNamePair pl = (KeyNamePair)pickPriceList.getSelectedItem(); - if (pl != null) - M_PriceList_Version_ID = pl.getKey(); - if (M_PriceList_Version_ID != 0) - { - pstmt.setInt(index++, M_PriceList_Version_ID); - if (log.isLoggable(Level.FINE)) log.fine("M_PriceList_Version_ID=" + M_PriceList_Version_ID); - } - // => Product Category - int M_Product_Category_ID = getM_Product_Category_ID(); - if (M_Product_Category_ID > 0) { - pstmt.setInt(index++, M_Product_Category_ID); - if (log.isLoggable(Level.FINE)) log.fine("M_Product_Category_ID=" + M_Product_Category_ID); - } - // => Attribute Set - @Trifon - int M_AttributeSet_ID = getM_AttributeSet_ID(); - if (M_AttributeSet_ID > 0) { - pstmt.setInt(index++, M_AttributeSet_ID); - if (log.isLoggable(Level.FINE)) log.fine("M_AttributeSet_ID=" + M_AttributeSet_ID); - } - // Rest of Parameter in Query for Attribute Search - if (m_pAttributeWhere != null) - return; - - // => Value - String value = fieldValue.getText().toUpperCase(); - if (!(value.equals("") || value.equals("%"))) - { - if (!value.endsWith("%")) - value += "%"; - pstmt.setString(index++, value); - if (log.isLoggable(Level.FINE)) log.fine("Value: " + value); - } - - // => Name - String name = fieldName.getText().toUpperCase(); - if (!(name.equals("") || name.equals("%"))) - { - if (!name.endsWith("%")) - name += "%"; - pstmt.setString(index++, name); - if (log.isLoggable(Level.FINE)) log.fine("Name: " + name); - } - - // => UPC - String upc = fieldUPC.getText().toUpperCase(); - if (!(upc.equals("") || upc.equals("%"))) - { - if (!upc.endsWith("%")) - upc += "%"; - pstmt.setString(index++, upc); - if (log.isLoggable(Level.FINE)) log.fine("UPC: " + upc); - } - - // => SKU - String sku = fieldSKU.getText().toUpperCase(); - if (!(sku.equals("") || sku.equals("%"))) - { - if (!sku.endsWith("%")) - sku += "%"; - pstmt.setString(index++, sku); - if (log.isLoggable(Level.FINE)) log.fine("SKU: " + sku); - } - - // => Vendor - String vendor = fieldVendor.getText().toUpperCase(); - if (!(vendor.equals("") || vendor.equals("%"))) - { - if (!vendor.endsWith("%")) - vendor += "%"; - pstmt.setString(index++, vendor); - if (log.isLoggable(Level.FINE)) log.fine("Vendor: " + vendor); - } - - } // setParameters - - - /************************************************************************** - * Action Listener - * @param e event - */ - public void actionPerformed (ActionEvent e) - { - // don't requery if fieldValue and fieldName are empty - if (e.getSource() == pickWarehouse || e.getSource() == pickPriceList) - { - // IDEMPIERE-337 - Improve Info Product Window - boolean execute = true; - if (fieldValue.getText().length() == 0 && fieldName.getText().length() == 0 && p_table.getRowCount() == 0) - execute = false; - p_table.setRowCount(0); - ((DefaultTableModel)p_table.getModel()).setColumnCount(0); - int M_Warehouse_ID = ((KeyNamePair)pickWarehouse.getSelectedItem()).getKey(); - // Create Grid - StringBuilder where = new StringBuilder(); - where.append("p.IsActive='Y'"); - if (M_Warehouse_ID != 0) - where.append(" AND p.IsSummary='N'"); - // dynamic Where Clause - if (p_whereClause != null && p_whereClause.length() > 0) - where.append(" AND ") // replace fully qualified name with alias - .append(Util.replace(p_whereClause, "M_Product.", "p.")); - // - p_table.removeMouseListener(this); - prepareTable(getProductLayout(), - s_productFrom, - where.toString(), - ""); - p_table.setShowTotals(false); - if (!execute) - return; - } - - // Product Attribute Search - if (e.getSource().equals(m_InfoPAttributeButton)) - { - cmd_InfoPAttribute(); - return; - } - m_pAttributeWhere = null; - - // Query Product Attribute Instance - int row = p_table.getSelectedRow(); - if (e.getSource().equals(m_PAttributeButton) && row != -1) - { - Integer productInteger = getSelectedRowKey(); - String productName = (String)p_table.getValueAt(row, INDEX_NAME); - KeyNamePair warehouse = (KeyNamePair)pickWarehouse.getSelectedItem(); - if (productInteger == null || productInteger.intValue() == 0 || warehouse == null) - return; - String title = warehouse.getName() + " - " + productName; - PAttributeInstance pai = new PAttributeInstance (this, title, - warehouse.getKey(), 0, productInteger.intValue(), m_C_BPartner_ID); - m_M_AttributeSetInstance_ID = pai.getM_AttributeSetInstance_ID(); - m_M_Locator_ID = pai.getM_Locator_ID(); - if (m_M_AttributeSetInstance_ID != -1) - dispose(true); - return; - } - // - super.actionPerformed(e); - } // actionPerformed - - /** - * Enable PAttribute if row selected/changed - */ - protected void enableButtons () - { - m_M_AttributeSetInstance_ID = -1; - if (m_PAttributeButton != null) - { - int row = p_table.getSelectedRow(); - boolean enabled = false; - if (row >= 0) - { - Object value = p_table.getValueAt(row, INDEX_PATTRIBUTE); - enabled = Boolean.TRUE.equals(value); - } - m_PAttributeButton.setEnabled(enabled); - } - super.enableButtons(); - } // enableButtons - - /** - * Query per Product Attribute. - * - * Available synonyms: - * M_Product p - * M_ProductPrice pr - * M_AttributeSet pa - * - */ - private void cmd_InfoPAttribute() - { - InfoPAttribute ia = new InfoPAttribute(this); - m_pAttributeWhere = ia.getWhereClause(); - if (m_pAttributeWhere != null) - executeQuery(); - } // cmdInfoAttribute - - /** - * Show History - */ - protected void showHistory() - { - log.info(""); - Integer M_Product_ID = getSelectedRowKey(); - if (M_Product_ID == null) - return; - KeyNamePair kn = (KeyNamePair)pickWarehouse.getSelectedItem(); - int M_Warehouse_ID = kn.getKey(); - int M_AttributeSetInstance_ID = m_M_AttributeSetInstance_ID; - if (m_M_AttributeSetInstance_ID < -1) // not selected - M_AttributeSetInstance_ID = 0; - // - InvoiceHistory ih = new InvoiceHistory (this, 0, - M_Product_ID.intValue(), M_Warehouse_ID, M_AttributeSetInstance_ID); - ih.setVisible(true); - ih = null; - } // showHistory - - /** - * Has History - * - * @return true (has history) - */ - protected boolean hasHistory() - { - return true; - } // hasHistory - - /** - * Zoom - */ - protected void zoom() - { - if (log.isLoggable(Level.INFO)) log.info(""); - Integer M_Product_ID = getSelectedRowKey(); - if (M_Product_ID == null) - return; - // AEnv.zoom(MProduct.Table_ID, M_Product_ID.intValue(), true); // SO - - MQuery query = new MQuery("M_Product"); - query.addRestriction("M_Product_ID", MQuery.EQUAL, M_Product_ID); - query.setRecordCount(1); - int AD_WindowNo = getAD_Window_ID("M_Product", true); // SO - zoom (AD_WindowNo, query); - } // zoom - - /** - * Has Zoom - * @return (has zoom) - */ - protected boolean hasZoom() - { - return true; - } // hasZoom - - /** - * Customize - */ - protected void customize() - { - log.info(""); - } // customize - - /** - * Has Customize - * @return false (no customize) - */ - protected boolean hasCustomize() - { - return false; // for now - } // hasCustomize - - /** - * Save Selection Settings for PriceList - */ - protected void saveSelectionDetail() - { - // publish for Callout to read - Integer ID = getSelectedRowKey(); - Env.setContext(Env.getCtx(), p_WindowNo, Env.TAB_INFO, "M_Product_ID", ID == null ? "0" : ID.toString()); - KeyNamePair kn = (KeyNamePair)pickPriceList.getSelectedItem(); - Env.setContext(Env.getCtx(), p_WindowNo, Env.TAB_INFO, "M_PriceList_Version_ID", kn.getID()); - kn = (KeyNamePair)pickWarehouse.getSelectedItem(); - Env.setContext(Env.getCtx(), p_WindowNo, Env.TAB_INFO, "M_Warehouse_ID", kn.getID()); - // - if (m_M_AttributeSetInstance_ID == -1) // not selected - { - Env.setContext(Env.getCtx(), p_WindowNo, Env.TAB_INFO, "M_AttributeSetInstance_ID", "0"); - Env.setContext(Env.getCtx(), p_WindowNo, Env.TAB_INFO, "M_Locator_ID", "0"); - } - else - { - Env.setContext(Env.getCtx(), p_WindowNo, Env.TAB_INFO, "M_AttributeSetInstance_ID", - String.valueOf(m_M_AttributeSetInstance_ID)); - Env.setContext(Env.getCtx(), p_WindowNo, Env.TAB_INFO, "M_Locator_ID", - String.valueOf(m_M_Locator_ID)); - } - } // saveSelectionDetail - - /** - * Get Product Layout - * - * @return array of Column_Info - */ - protected Info_Column[] getProductLayout() - { - // IDEMPIERE-337 - //if (s_productLayout != null && s_productLayoutRole == MRole.getDefault().getAD_Role_ID()) - // return s_productLayout; - // - s_productLayout = null; - // IDEMPIERE_337 - int M_Warehouse_ID = 0; - KeyNamePair warehouse = (KeyNamePair)pickWarehouse.getSelectedItem(); - M_Warehouse_ID = warehouse.getKey(); - int M_PriceList_ID = 0; - KeyNamePair pricelist = (KeyNamePair)pickPriceList.getSelectedItem(); - M_PriceList_ID = pricelist.getKey(); - - ArrayList list = new ArrayList(); - list.add(new Info_Column(" ", "DISTINCT p.M_Product_ID", IDColumn.class, !p_multiSelection)); - list.add(new Info_Column(Msg.translate(Env.getCtx(), "Discontinued").substring(0, 1), "p.Discontinued", Boolean.class)); - list.add(new Info_Column(Msg.translate(Env.getCtx(), "Value"), "p.Value", String.class)); - list.add(new Info_Column(Msg.translate(Env.getCtx(), "Name"), "p.Name", String.class)); - // IDEMPIERE-337 - if (M_Warehouse_ID != 0) - list.add(new Info_Column(Msg.translate(Env.getCtx(), "QtyAvailable"), "case when p.IsBOM='N' and (p.ProductType!='I' OR p.IsStocked='N') then to_number(get_Sysconfig('QTY_TO_SHOW_FOR_SERVICES', '99999', p.ad_client_id, 0), '99999999999') else bomQtyAvailable(p.M_Product_ID,?,0) end AS QtyAvailable", Double.class, true, true, null)); - if (MRole.getDefault().isColumnAccess(251 /*M_ProductPrice*/, 3027/*PriceList*/, false) && M_PriceList_ID != 0) - list.add(new Info_Column(Msg.translate(Env.getCtx(), "PriceList"), "bomPriceList(p.M_Product_ID, pr.M_PriceList_Version_ID) AS PriceList", BigDecimal.class)); - if (MRole.getDefault().isColumnAccess(251 /*M_ProductPrice*/, 3028/*PriceStd*/, false) && M_PriceList_ID !=0) - list.add(new Info_Column(Msg.translate(Env.getCtx(), "PriceStd"), "bomPriceStd(p.M_Product_ID, pr.M_PriceList_Version_ID) AS PriceStd", BigDecimal.class)); - if (M_Warehouse_ID != 0) - { - list.add(new Info_Column(Msg.translate(Env.getCtx(), "QtyOnHand"), "case when p.IsBOM='N' and (p.ProductType!='I' OR p.IsStocked='N') then to_number(get_Sysconfig('QTY_TO_SHOW_FOR_SERVICES', '99999', p.ad_client_id, 0), '99999999999') else bomQtyOnHand(p.M_Product_ID,?,0) end AS QtyOnHand", Double.class)); - list.add(new Info_Column(Msg.translate(Env.getCtx(), "QtyReserved"), "bomQtyReserved(p.M_Product_ID,?,0) AS QtyReserved", Double.class)); - list.add(new Info_Column(Msg.translate(Env.getCtx(), "QtyOrdered"), "bomQtyOrdered(p.M_Product_ID,?,0) AS QtyOrdered", Double.class)); - if (isUnconfirmed()) - { - list.add(new Info_Column(Msg.translate(Env.getCtx(), "QtyUnconfirmed"), "(SELECT SUM(c.TargetQty) FROM M_InOutLineConfirm c INNER JOIN M_InOutLine il ON (c.M_InOutLine_ID=il.M_InOutLine_ID) INNER JOIN M_InOut i ON (il.M_InOut_ID=i.M_InOut_ID) WHERE c.Processed='N' AND i.M_Warehouse_ID=? AND il.M_Product_ID=p.M_Product_ID) AS QtyUnconfirmed", Double.class)); - list.add(new Info_Column(Msg.translate(Env.getCtx(), "QtyUnconfirmedMove"), "(SELECT SUM(c.TargetQty) FROM M_MovementLineConfirm c INNER JOIN M_MovementLine ml ON (c.M_MovementLine_ID=ml.M_MovementLine_ID) INNER JOIN M_Locator l ON (ml.M_LocatorTo_ID=l.M_Locator_ID) WHERE c.Processed='N' AND l.M_Warehouse_ID=? AND ml.M_Product_ID=p.M_Product_ID) AS QtyUnconfirmedMove", Double.class)); - } - } - if (MRole.getDefault().isColumnAccess(251 /*M_ProductPrice*/, 3028/*PriceStd*/, false) && MRole.getDefault().isColumnAccess(251 /*M_ProductPrice*/, 3029/*PriceLimit*/, false) && M_PriceList_ID != 0) - list.add(new Info_Column(Msg.translate(Env.getCtx(), "Margin"), "bomPriceStd(p.M_Product_ID, pr.M_PriceList_Version_ID)-bomPriceLimit(p.M_Product_ID, pr.M_PriceList_Version_ID) AS Margin", BigDecimal.class)); - list.add(new Info_Column(Msg.translate(Env.getCtx(), "Vendor"), "bp.Name", String.class)); - if (MRole.getDefault().isColumnAccess(251 /*M_ProductPrice*/, 3029/*PriceLimit*/, false) && M_PriceList_ID != 0) - list.add(new Info_Column(Msg.translate(Env.getCtx(), "PriceLimit"), "bomPriceLimit(p.M_Product_ID, pr.M_PriceList_Version_ID) AS PriceLimit", BigDecimal.class)); - list.add(new Info_Column(Msg.translate(Env.getCtx(), "IsInstanceAttribute"), "pa.IsInstanceAttribute", Boolean.class)); - s_productLayout = new Info_Column[list.size()]; - list.toArray(s_productLayout); - INDEX_NAME = 3; - INDEX_PATTRIBUTE = s_productLayout.length - 1; // last item - - return s_productLayout; - } // getProductLayout - - /** - * System has Unconfirmed records - * @return true if unconfirmed - */ - private boolean isUnconfirmed() - { - int no = DB.getSQLValue(null, - "SELECT COUNT(*) FROM M_InOutLineConfirm WHERE AD_Client_ID=?", - Env.getAD_Client_ID(Env.getCtx())); - if (no > 0) - return true; - no = DB.getSQLValue(null, - "SELECT COUNT(*) FROM M_MovementLineConfirm WHERE AD_Client_ID=?", - Env.getAD_Client_ID(Env.getCtx())); - return no > 0; - } // isUnconfirmed - - - /** - * Tab Changed - * @param e event - */ - public void stateChanged(ChangeEvent e) - { - if(e.getSource() instanceof CTabbedPane) - { - CTabbedPane tab = (CTabbedPane) e.getSource(); - - if(tab.getSelectedIndex() == 4 && warehouseTbl.getRowCount() > 0) - { - // If no warehouse row is selected in the warehouse tab, use the first warehouse - // row to prevent array index out of bounds. BF 3051361 - int selectedRow = warehouseTbl.getSelectedRow(); - if (selectedRow<0) selectedRow = 0; - String value = (String)warehouseTbl.getValueAt(selectedRow,0); - int M_Warehouse_ID = DB.getSQLValue(null, "SELECT M_Warehouse_ID FROM M_Warehouse WHERE UPPER(Name) = UPPER(?) AND AD_Client_ID=?", new Object[] { value ,Env.getAD_Client_ID(Env.getCtx())}); - initAtpTab(M_Warehouse_ID); - } - } - - } // stateChanged - - /** - * Query ATP - */ - private void initAtpTab (int m_M_Warehouse_ID) - { - - // Header - Vector columnNames = new Vector(); - columnNames.add(Msg.translate(Env.getCtx(), "Date")); - columnNames.add(Msg.translate(Env.getCtx(), "QtyOnHand")); - columnNames.add(Msg.translate(Env.getCtx(), "C_BPartner_ID")); - columnNames.add(Msg.translate(Env.getCtx(), "QtyOrdered")); - columnNames.add(Msg.translate(Env.getCtx(), "QtyReserved")); - columnNames.add(Msg.translate(Env.getCtx(), "M_Locator_ID")); - columnNames.add(Msg.translate(Env.getCtx(), "M_AttributeSetInstance_ID")); - columnNames.add(Msg.translate(Env.getCtx(), "DocumentNo")); - columnNames.add(Msg.translate(Env.getCtx(), "M_Warehouse_ID")); - - // Fill Storage Data - boolean showDetail = CLogMgt.isLevelFine(); - String sql = "SELECT s.QtyOnHand, s.QtyReserved, s.QtyOrdered," - + " productAttribute(s.M_AttributeSetInstance_ID), s.M_AttributeSetInstance_ID,"; - if (!showDetail) - sql = "SELECT SUM(s.QtyOnHand), SUM(s.QtyReserved), SUM(s.QtyOrdered)," - + " productAttribute(s.M_AttributeSetInstance_ID), 0,"; - sql += " w.Name, l.Value " - + "FROM M_Storage s" - + " INNER JOIN M_Locator l ON (s.M_Locator_ID=l.M_Locator_ID)" - + " INNER JOIN M_Warehouse w ON (l.M_Warehouse_ID=w.M_Warehouse_ID) " - + "WHERE M_Product_ID=?"; - if (m_M_Warehouse_ID != 0) - sql += " AND l.M_Warehouse_ID=?"; - if (m_M_AttributeSetInstance_ID > 0) - sql += " AND s.M_AttributeSetInstance_ID=?"; - sql += " AND (s.QtyOnHand<>0 OR s.QtyReserved<>0 OR s.QtyOrdered<>0)"; - if (!showDetail) - sql += " GROUP BY productAttribute(s.M_AttributeSetInstance_ID), w.Name, l.Value"; - sql += " ORDER BY l.Value"; - - Vector> data = new Vector>(); - double qty = 0; - PreparedStatement pstmt = null; - ResultSet rs = null; - try - { - pstmt = DB.prepareStatement(sql, null); - pstmt.setInt(1, m_M_Product_ID); - if (m_M_Warehouse_ID != 0) - pstmt.setInt(2, m_M_Warehouse_ID); - if (m_M_AttributeSetInstance_ID > 0) - pstmt.setInt(3, m_M_AttributeSetInstance_ID); - rs = pstmt.executeQuery(); - while (rs.next()) - { - Vector line = new Vector(9); - line.add(null); // Date - double qtyOnHand = rs.getDouble(1); - qty += qtyOnHand; - line.add(Double.valueOf(qtyOnHand)); // Qty - line.add(null); // BPartner - line.add(Double.valueOf(rs.getDouble(3))); // QtyOrdered - line.add(Double.valueOf(rs.getDouble(2))); // QtyReserved - line.add(rs.getString(7)); // Locator - String asi = rs.getString(4); - if (showDetail && (asi == null || asi.length() == 0)) - asi = "{" + rs.getInt(5) + "}"; - line.add(asi); // ASI - line.add(null); // DocumentNo - line.add(rs.getString(6)); // Warehouse - data.add(line); - } - } - catch (SQLException e) - { - log.log(Level.SEVERE, sql, e); - } - finally { - DB.close(rs, pstmt); - rs = null; pstmt = null; - } - - // Orders - sql = "SELECT o.DatePromised, ol.QtyReserved," - + " productAttribute(ol.M_AttributeSetInstance_ID), ol.M_AttributeSetInstance_ID," - + " dt.DocBaseType, bp.Name," - + " dt.PrintName || ' ' || o.DocumentNo As DocumentNo, w.Name " - + "FROM C_Order o" - + " INNER JOIN C_OrderLine ol ON (o.C_Order_ID=ol.C_Order_ID)" - + " INNER JOIN C_DocType dt ON (o.C_DocType_ID=dt.C_DocType_ID)" - + " INNER JOIN M_Warehouse w ON (ol.M_Warehouse_ID=w.M_Warehouse_ID)" - + " INNER JOIN C_BPartner bp ON (o.C_BPartner_ID=bp.C_BPartner_ID) " - + "WHERE ol.QtyReserved<>0" - + " AND ol.M_Product_ID=?"; - if (m_M_Warehouse_ID != 0) - sql += " AND ol.M_Warehouse_ID=?"; - if (m_M_AttributeSetInstance_ID > 0) - sql += " AND ol.M_AttributeSetInstance_ID=?"; - sql += " ORDER BY o.DatePromised"; - try - { - pstmt = DB.prepareStatement(sql, null); - pstmt.setInt(1, m_M_Product_ID); - if (m_M_Warehouse_ID != 0) - pstmt.setInt(2, m_M_Warehouse_ID); - if (m_M_AttributeSetInstance_ID > 0) - pstmt.setInt(3, m_M_AttributeSetInstance_ID); - rs = pstmt.executeQuery(); - while (rs.next()) - { - Vector line = new Vector(9); - line.add(rs.getTimestamp(1)); // Date - double oq = rs.getDouble(2); - String DocBaseType = rs.getString(5); - Double qtyReserved = null; - Double qtyOrdered = null; - if (MDocType.DOCBASETYPE_PurchaseOrder.equals(DocBaseType)) - { - qtyOrdered = Double.valueOf(oq); - qty += oq; - } - else - { - qtyReserved = Double.valueOf(oq); - qty -= oq; - } - line.add(Double.valueOf(qty)); // Qty - line.add(rs.getString(6)); // BPartner - line.add(qtyOrdered); // QtyOrdered - line.add(qtyReserved); // QtyReserved - line.add(null); // Locator - String asi = rs.getString(3); - if (showDetail && (asi == null || asi.length() == 0)) - asi = "{" + rs.getInt(4) + "}"; - line.add(asi); // ASI - line.add(rs.getString(7)); // DocumentNo - line.add(rs.getString(8)); // Warehouse - data.add(line); - } - } - catch (SQLException e) - { - log.log(Level.SEVERE, sql, e); - } - finally { - DB.close(rs, pstmt); - rs = null; pstmt = null; - } - - // Table - MiniTable table = null; - m_modelAtp = new DefaultTableModel(data, columnNames); - m_tableAtp.setModel(m_modelAtp); - table = m_tableAtp; - // - table.setColumnClass(0, Timestamp.class, true); // Date - table.setColumnClass(1, Double.class, true); // Quantity - table.setColumnClass(2, String.class, true); // Partner - table.setColumnClass(3, Double.class, true); // Quantity - table.setColumnClass(4, Double.class, true); // Quantity - table.setColumnClass(5, String.class, true); // Locator - table.setColumnClass(6, String.class, true); // ASI - table.setColumnClass(7, String.class, true); // DocNo - table.setColumnClass(8, String.class, true); // Warehouse - // - table.autoSize(); - } // initAtpTab - - /** - * @return selected product category ID - */ - public int getM_Product_Category_ID() { - int M_Product_Category_ID = 0; - KeyNamePair pc = (KeyNamePair)pickProductCategory.getSelectedItem(); - if (pc != null) - M_Product_Category_ID = pc.getKey(); - return M_Product_Category_ID; - } - - /** - * @return selected Attribute Set ID - */ - public int getM_AttributeSet_ID() { - int M_AttributeSet_ID = 0; - KeyNamePair as = (KeyNamePair)pickAS.getSelectedItem(); - if (as != null) - M_AttributeSet_ID = as.getKey(); - return M_AttributeSet_ID; - } - - @Override - public boolean isResetValue() { - return true; - } - - -} // InfoProduct diff --git a/org.adempiere.ui.swing/src/org/compiere/apps/search/InfoSchedule.java b/org.adempiere.ui.swing/src/org/compiere/apps/search/InfoSchedule.java deleted file mode 100644 index 2b10d83153..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/apps/search/InfoSchedule.java +++ /dev/null @@ -1,451 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ -package org.compiere.apps.search; - -import java.awt.BorderLayout; -import java.awt.Cursor; -import java.awt.Frame; -import java.awt.GridBagConstraints; -import java.awt.GridBagLayout; -import java.awt.Insets; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.sql.PreparedStatement; -import java.sql.ResultSet; -import java.sql.SQLException; -import java.sql.Timestamp; -import java.util.GregorianCalendar; -import java.util.logging.Level; - -import javax.swing.JButton; -import javax.swing.JComboBox; -import javax.swing.JLabel; -import javax.swing.JScrollPane; -import javax.swing.JTabbedPane; -import javax.swing.SwingConstants; -import javax.swing.event.ChangeEvent; -import javax.swing.event.ChangeListener; - -import org.compiere.apps.AEnv; -import org.compiere.apps.ConfirmPanel; -import org.compiere.apps.StatusBar; -import org.compiere.grid.ed.VDate; -import org.compiere.model.MResourceAssignment; -import org.compiere.model.MRole; -import org.compiere.swing.CDialog; -import org.compiere.swing.CPanel; -import org.compiere.util.CLogger; -import org.compiere.util.DB; -import org.compiere.util.Env; -import org.compiere.util.KeyNamePair; -import org.compiere.util.Msg; - - -/** - * Schedule - Resource availability & assigment. - * - * @author Jorg Janke - * @version $Id: InfoSchedule.java,v 1.2 2006/07/30 00:51:27 jjanke Exp $ - */ -public class InfoSchedule extends CDialog - implements ActionListener, ChangeListener -{ - /** - * - */ - private static final long serialVersionUID = 7364837484557281167L; - - /** - * Constructor - * @param frame Parent - * @param mAssignment optional assignment - * @param createNew if true, allows to create new assignments - */ - public InfoSchedule (Frame frame, MResourceAssignment mAssignment, boolean createNew) - { - super(frame, Msg.getMsg(Env.getCtx(), "InfoSchedule"), frame != null && createNew); - if (mAssignment == null) - m_mAssignment = new MResourceAssignment(Env.getCtx(), 0, null); - else - m_mAssignment = mAssignment; - if (mAssignment != null) - if (log.isLoggable(Level.INFO)) log.info(mAssignment.toString()); - m_dateFrom = m_mAssignment.getAssignDateFrom(); - if (m_dateFrom == null) - m_dateFrom = new Timestamp(System.currentTimeMillis()); - m_createNew = createNew; - try - { - jbInit(); - dynInit(createNew); - } - catch(Exception ex) - { - log.log(Level.SEVERE, "InfoSchedule", ex); - } - AEnv.showCenterWindow(frame, this); - } // InfoSchedule - - /** - * IDE Constructor - */ - public InfoSchedule() - { - this (null, null, false); - } // InfoSchedule - - /** Resource */ - private MResourceAssignment m_mAssignment; - /** Date */ - private Timestamp m_dateFrom = null; - /** Loading */ - private boolean m_loading = false; - /** Ability to create new assignments */ - private boolean m_createNew; - /** Logger */ - private static CLogger log = CLogger.getCLogger(InfoSchedule.class); - - private CPanel mainPanel = new CPanel(); - private BorderLayout mainLayout = new BorderLayout(); - private CPanel parameterPanel = new CPanel(); - private GridBagLayout parameterLayout = new GridBagLayout(); - private JLabel labelResourceType = new JLabel(); - private JComboBox fieldResourceType = new JComboBox(); - private JLabel labelResource = new JLabel(); - private JComboBox fieldResource = new JComboBox(); - private JButton bPrevious = new JButton(); - private JLabel labelDate = new JLabel(); - private VDate fieldDate = new VDate(); - private JButton bNext = new JButton(); - private JTabbedPane timePane = new JTabbedPane(); - private VSchedule daySchedule = new VSchedule(this, VSchedule.TYPE_DAY); - private VSchedule weekSchedule = new VSchedule(this, VSchedule.TYPE_WEEK); - private VSchedule monthSchedule = new VSchedule(this, VSchedule.TYPE_MONTH); - private StatusBar statusBar = new StatusBar(); - private ConfirmPanel confirmPanel = new ConfirmPanel(true); - - /** - * Static Layout - * @throws Exception - */ - private void jbInit() throws Exception - { - mainPanel.setLayout(mainLayout); - parameterPanel.setLayout(parameterLayout); - labelResourceType.setHorizontalTextPosition(SwingConstants.LEADING); - labelResourceType.setText(Msg.translate(Env.getCtx(), "S_ResourceType_ID")); - labelResource.setHorizontalTextPosition(SwingConstants.LEADING); - labelResource.setText(Msg.translate(Env.getCtx(), "S_Resource_ID")); - bPrevious.setMargin(new Insets(0, 0, 0, 0)); - bPrevious.setText("<"); - labelDate.setText(Msg.translate(Env.getCtx(), "Date")); - bNext.setMargin(new Insets(0, 0, 0, 0)); - bNext.setText(">"); - getContentPane().add(mainPanel, BorderLayout.CENTER); - mainPanel.add(parameterPanel, BorderLayout.NORTH); - parameterPanel.add(labelResourceType, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(8, 8, 0, 0), 0, 0)); - parameterPanel.add(fieldResourceType, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0 - ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 8, 8, 4), 0, 0)); - parameterPanel.add(labelResource, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(8, 4, 0, 4), 0, 0)); - parameterPanel.add(fieldResource, new GridBagConstraints(1, 1, 1, 1, 0.5, 0.0 - ,GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 8, 4), 0, 0)); - parameterPanel.add(bPrevious, new GridBagConstraints(2, 1, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 8, 8, 0), 0, 0)); - parameterPanel.add(labelDate, new GridBagConstraints(3, 0, 1, 1, 0.0, 0.0 - ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(8, 0, 0, 0), 0, 0)); - parameterPanel.add(fieldDate, new GridBagConstraints(3, 1, 1, 1, 0.0, 0.0 - ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 8, 0), 0, 0)); - parameterPanel.add(bNext, new GridBagConstraints(4, 1, 1, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 8, 8), 0, 0)); - // - mainPanel.add(new JScrollPane(timePane), BorderLayout.CENTER); - timePane.add(daySchedule, Msg.getMsg(Env.getCtx(), "Day")); - timePane.add(weekSchedule, Msg.getMsg(Env.getCtx(), "Week")); - timePane.add(monthSchedule, Msg.getMsg(Env.getCtx(), "Month")); - // timePane.add(daySchedule, Msg.getMsg(Env.getCtx(), "Day")); - // timePane.add(weekSchedule, Msg.getMsg(Env.getCtx(), "Week")); - // timePane.add(monthSchedule, Msg.getMsg(Env.getCtx(), "Month")); - timePane.addChangeListener(this); - // - mainPanel.add(confirmPanel, BorderLayout.SOUTH); - // - this.getContentPane().add(statusBar, BorderLayout.SOUTH); - } // jbInit - - /** - * Dynamic Init - * @param createNew if true, allows to create new assignments - */ - private void dynInit (boolean createNew) - { - // Resource - fillResourceType(); - fillResource(); - fieldResourceType.addActionListener(this); - fieldResource.addActionListener(this); - - // Date - fieldDate.setValue(m_dateFrom); - fieldDate.addActionListener(this); - bPrevious.addActionListener(this); - bNext.addActionListener(this); - - // Set Init values - daySchedule.setCreateNew(createNew); - weekSchedule.setCreateNew(createNew); - monthSchedule.setCreateNew(createNew); - // - confirmPanel.addActionListener(this); - displayCalendar(); - } // dynInit - - /** - * Fill Resource Type (one time) - */ - private void fillResourceType() - { - // Get ResourceType of selected Resource - int S_ResourceType_ID = 0; - if (m_mAssignment.getS_Resource_ID() != 0) - { - String sql = "SELECT S_ResourceType_ID FROM S_Resource WHERE S_Resource_ID=?"; - S_ResourceType_ID = DB.getSQLValue(null, sql, m_mAssignment.getS_Resource_ID()); - } - - // Get Resource Types - String sql = MRole.getDefault().addAccessSQL( - "SELECT S_ResourceType_ID, Name FROM S_ResourceType WHERE IsActive='Y' ORDER BY 2", - "S_ResourceType", MRole.SQL_NOTQUALIFIED, MRole.SQL_RO); - KeyNamePair defaultValue = null; - PreparedStatement pstmt = null; - ResultSet rs = null; - try - { - pstmt = DB.prepareStatement(sql, null); - rs = pstmt.executeQuery(); - while (rs.next()) - { - KeyNamePair pp = new KeyNamePair(rs.getInt(1), rs.getString(2)); - if (S_ResourceType_ID == pp.getKey()) - defaultValue = pp; - fieldResourceType.addItem(pp); - } - } - catch (SQLException e) - { - log.log(Level.SEVERE, sql, e); - } - finally { - DB.close(rs, pstmt); - rs = null; pstmt = null; - } - if (defaultValue != null) - fieldResourceType.setSelectedItem(defaultValue); - } // fillResourceType - - /** - * Fill Resource Pick from Resource Type - */ - private void fillResource() - { - // Get Resource Type - KeyNamePair pp = (KeyNamePair)fieldResourceType.getSelectedItem(); - if (pp == null) - return; - int S_ResourceType_ID = pp.getKey(); - - KeyNamePair defaultValue = null; - - // Load Resources - m_loading = true; - fieldResource.removeAllItems(); - String sql = "SELECT S_Resource_ID, Name FROM S_Resource WHERE IsActive='Y' AND S_ResourceType_ID=? ORDER BY 2"; - PreparedStatement pstmt = null; - ResultSet rs = null; - try - { - pstmt = DB.prepareStatement(sql, null); - pstmt.setInt(1, S_ResourceType_ID); - rs = pstmt.executeQuery(); - while (rs.next()) - { - pp = new KeyNamePair(rs.getInt(1), rs.getString(2)); - if (m_mAssignment.getS_Resource_ID() == pp.getKey()) - defaultValue = pp; - fieldResource.addItem(pp); - } - } - catch (SQLException e) - { - log.log(Level.SEVERE, sql, e); - } - finally { - DB.close(rs, pstmt); - rs = null; pstmt = null; - } - if (defaultValue != null) - fieldResource.setSelectedItem(defaultValue); - - m_loading = false; - } // fillResource - - /** - * Display Calendar for selected Resource, Time(day/week/month) and Date - */ - private void displayCalendar () - { - // Get Values - KeyNamePair pp = (KeyNamePair)fieldResource.getSelectedItem(); - if (pp == null) - return; - int S_Resource_ID = pp.getKey(); - m_mAssignment.setS_Resource_ID(S_Resource_ID); - Timestamp date = fieldDate.getTimestamp(); - int index = timePane.getSelectedIndex(); - if (log.isLoggable(Level.CONFIG)) log.config("Index=" + index + ", ID=" + S_Resource_ID + " - " + date); - - // Set Info - m_loading = true; - if (index == 0) - daySchedule.recreate (S_Resource_ID, date); - else if (index == 1) - weekSchedule.recreate (S_Resource_ID, date); - else - monthSchedule.recreate (S_Resource_ID, date); - m_loading = false; - repaint(); - } // displayCalendar - - /************************************************************************** - * Dispose. - */ - public void dispose() - { - daySchedule.dispose(); - weekSchedule.dispose(); - monthSchedule.dispose(); - this.removeAll(); - super.dispose(); - } // dispose - - /** - * Action Listener - * @param e event - */ - public void actionPerformed(ActionEvent e) - { - if (m_loading) - return; - this.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); - - if (e.getActionCommand().equals(ConfirmPanel.A_OK)) - dispose(); - else if (e.getActionCommand().equals(ConfirmPanel.A_CANCEL)) - dispose(); - // - else if (e.getSource() == fieldResourceType) - { - fillResource(); - displayCalendar(); - } - // - else if (e.getSource() == fieldResource || e.getSource() == fieldDate) - displayCalendar(); - // - else if (e.getSource() == bPrevious) - adjustDate(-1); - else if (e.getSource() == bNext) - adjustDate(+1); - // - this.setCursor(Cursor.getDefaultCursor()); - } // actionPerformed - - /** - * Change Listener (Tab Pane) - * @param e event - */ - public void stateChanged (ChangeEvent e) - { - displayCalendar(); - } // stateChanged - - /** - * Adjust Date - * @param diff difference - */ - private void adjustDate (int diff) - { - Timestamp date = fieldDate.getTimestamp(); - GregorianCalendar cal = new GregorianCalendar(); - cal.setTime(date); - if (timePane.getSelectedIndex() == 0) - cal.add(java.util.Calendar.DAY_OF_YEAR, diff); - else if (timePane.getSelectedIndex() == 1) - cal.add(java.util.Calendar.WEEK_OF_YEAR, diff); - else - cal.add(java.util.Calendar.MONTH, diff); - // - fieldDate.setValue(new Timestamp(cal.getTimeInMillis())); - displayCalendar (); - } // adjustDate - - /*************************************************************************/ - - /** - * Callback. - * Called from VSchedulePanel after VAssignmentDialog finished - * @param assignment New/Changed Assignment - */ - public void mAssignmentCallback (MResourceAssignment assignment) - { - m_mAssignment = assignment; - if (m_createNew) - dispose(); - else - displayCalendar(); - } // mAssignmentCallback - - /** - * Get Assignment - * @return Assignment - */ - public MResourceAssignment getMResourceAssignment() - { - return m_mAssignment; - } // getMResourceAssignment - - - - /** -SELECT o.DocumentNo, ol.Line, ol.Description -FROM C_OrderLine ol, C_Order o -WHERE ol.S_ResourceAssignment_ID=1 - AND ol.C_Order_ID=o.C_Order_ID -UNION -SELECT i.DocumentNo, il.Line, il.Description -FROM C_InvoiceLine il, C_Invoice i -WHERE il.S_ResourceAssignment_ID=1 - AND il.C_Invoice_ID=i.C_Invoice_ID -UNION -SELECT e.DocumentNo, el.Line, el.Description -FROM S_TimeExpenseLine el, S_TimeExpense e -WHERE el.S_ResourceAssignment_ID=1 - AND el.S_TimeExpense_ID=el.S_TimeExpense_ID - */ -} // InfoSchedule diff --git a/org.adempiere.ui.swing/src/org/compiere/apps/search/Info_Column.java b/org.adempiere.ui.swing/src/org/compiere/apps/search/Info_Column.java deleted file mode 100644 index f08386f894..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/apps/search/Info_Column.java +++ /dev/null @@ -1,97 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ -package org.compiere.apps.search; - -import org.compiere.minigrid.ColumnInfo; - -/** - * Info Column Details - * - * @author Jorg Janke - * @version $Id: Info_Column.java,v 1.2 2006/07/30 00:51:27 jjanke Exp $ - * - * NOTE: Use {@link org.compiere.minigrid.ColumnInfo} instead - */ -public class Info_Column extends ColumnInfo -{ - /** - * Create Info Column (r/o and not color column) - * - * @param colHeader Column Header - * @param colSQL SQL select code for column - * @param colClass class of column - determines display - */ - public Info_Column (String colHeader, String colSQL, Class colClass) - { - super(colHeader, colSQL, colClass); - } // Info_Column - - /** - * Create Info Column (r/o and not color column) - * - * @param colHeader Column Header - * @param colSQL SQL select code for column - * @param colClass class of column - determines display - * @param IDcolSQL SQL select for the ID of the for the displayed column (KeyNamePair) - */ - public Info_Column (String colHeader, String colSQL, Class colClass, String IDcolSQL) - { - super(colHeader, colSQL, colClass, true, false, IDcolSQL); - } // Info_Column - - /** - * Create Info Column (not color column) - * - * @param colHeader Column Header - * @param colSQL SQL select code for column - * @param colClass class of column - determines display - * @param readOnly column is read only - * @author ashley - */ - public Info_Column (String colHeader, String colSQL, Class colClass, boolean readOnly) - { - super(colHeader, colSQL, colClass, readOnly, false, null); - } // Info_Column - - /** - * Create Info Column - * - * @param colHeader Column Header - * @param colSQL SQL select code for column - * @param colClass class of column - determines display - * @param readOnly column is read only - * @param colorColumn if true, value of column determines foreground color - * @param IDcolSQL SQL select for the ID of the for the displayed column - */ - public Info_Column (String colHeader, String colSQL, Class colClass, - boolean readOnly, boolean colorColumn, String IDcolSQL) - { - super(colHeader, colSQL, colClass, readOnly, colorColumn, IDcolSQL); - } // Info_Column - public void setIDcolSQL(String IDcolSQL) - { - super.setKeyPairColSQL(IDcolSQL); - } - public String getIDcolSQL() - { - return super.getKeyPairColSQL(); - } - public boolean isIDcol() - { - return super.isKeyPairCol(); - } -} // infoColumn diff --git a/org.adempiere.ui.swing/src/org/compiere/apps/search/InvoiceHistory.java b/org.adempiere.ui.swing/src/org/compiere/apps/search/InvoiceHistory.java deleted file mode 100644 index 7fdba6ab75..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/apps/search/InvoiceHistory.java +++ /dev/null @@ -1,710 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ -package org.compiere.apps.search; - -import java.awt.BorderLayout; -import java.awt.Dialog; -import java.awt.Dimension; -import java.awt.FlowLayout; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.math.BigDecimal; -import java.math.RoundingMode; -import java.sql.PreparedStatement; -import java.sql.ResultSet; -import java.sql.SQLException; -import java.sql.Timestamp; -import java.util.Vector; -import java.util.logging.Level; - -import javax.swing.JLabel; -import javax.swing.JScrollPane; -import javax.swing.JTabbedPane; -import javax.swing.WindowConstants; -import javax.swing.event.ChangeEvent; -import javax.swing.event.ChangeListener; -import javax.swing.table.DefaultTableModel; - -import org.compiere.apps.AEnv; -import org.compiere.apps.ConfirmPanel; -import org.compiere.minigrid.MiniTable; -import org.compiere.model.MDocType; -import org.compiere.model.MPriceList; -import org.compiere.swing.CDialog; -import org.compiere.swing.CPanel; -import org.compiere.util.CLogMgt; -import org.compiere.util.CLogger; -import org.compiere.util.DB; -import org.compiere.util.Env; -import org.compiere.util.Msg; - -/** - * Price History for BPartner/Product - * - * @author Jorg Janke - * @version $Id: InvoiceHistory.java,v 1.2 2006/07/30 00:51:27 jjanke Exp $ - */ -public class InvoiceHistory extends CDialog - implements ActionListener, ChangeListener -{ - /** - * - */ - private static final long serialVersionUID = 7886949815469558804L; - - /** - * Show History - * @param C_BPartner_ID partner - * @param M_Product_ID product - * @param M_Warehouse_ID warehouse - * @param M_AttributeSetInstance_ID ASI - */ - public InvoiceHistory (Dialog frame, - int C_BPartner_ID, int M_Product_ID, int M_Warehouse_ID, int M_AttributeSetInstance_ID) - { - super(frame, Msg.getMsg(Env.getCtx(), "PriceHistory"), true); - if (log.isLoggable(Level.CONFIG)) log.config("C_BPartner_ID=" + C_BPartner_ID - + ", M_Product_ID=" + M_Product_ID - + ", M_Warehouse_ID=" + M_Warehouse_ID - + ", M_AttributeSetInstance_ID=" + M_AttributeSetInstance_ID); - m_C_BPartner_ID = C_BPartner_ID; - m_M_Product_ID = M_Product_ID; - m_M_Warehouse_ID = M_Warehouse_ID; - m_M_AttributeSetInstance_ID = M_AttributeSetInstance_ID; - try - { - jbInit(); - dynInit(); - } - catch(Exception ex) - { - log.log(Level.SEVERE, "", ex); - } - mainPanel.setPreferredSize(new Dimension(700,400)); - AEnv.positionCenterWindow(frame, this); - } // InvoiceHistory - - private int m_C_BPartner_ID; - private int m_M_Product_ID; - private int m_M_Warehouse_ID; - private int m_M_AttributeSetInstance_ID; - - /** Logger */ - private static CLogger log = CLogger.getCLogger(InvoiceHistory.class); - - private CPanel mainPanel = new CPanel(); - private BorderLayout mainLayout = new BorderLayout(); - private CPanel northPanel = new CPanel(); - private JLabel label = new JLabel(); - private FlowLayout northLayout = new FlowLayout(); - // - private ConfirmPanel confirmPanel = new ConfirmPanel(); - private JTabbedPane centerTabbedPane = new JTabbedPane(); - // - private JScrollPane pricePane = new JScrollPane(); - private MiniTable m_tablePrice = new MiniTable(); - private DefaultTableModel m_modelPrice = null; - - private JScrollPane reservedPane = new JScrollPane(); - private MiniTable m_tableReserved = new MiniTable(); - private DefaultTableModel m_modelReserved = null; - - private JScrollPane orderedPane = new JScrollPane(); - private MiniTable m_tableOrdered = new MiniTable(); - private DefaultTableModel m_modelOrdered = null; - - private JScrollPane unconfirmedPane = new JScrollPane(); - private MiniTable m_tableUnconfirmed = new MiniTable(); - private DefaultTableModel m_modelUnconfirmed = null; - - private JScrollPane atpPane = new JScrollPane(); - private MiniTable m_tableAtp = new MiniTable(); - private DefaultTableModel m_modelAtp = null; - - /** - * Ststic Init - */ - void jbInit() throws Exception - { - this.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); - mainPanel.setLayout(mainLayout); - label.setText("Label"); - northPanel.setLayout(northLayout); - northLayout.setAlignment(FlowLayout.LEFT); - getContentPane().add(mainPanel); - mainPanel.add(northPanel, BorderLayout.NORTH); - northPanel.add(label, null); - mainPanel.add(confirmPanel, BorderLayout.SOUTH); - mainPanel.add(centerTabbedPane, BorderLayout.CENTER); - centerTabbedPane.addChangeListener(this); - centerTabbedPane.add(pricePane, Msg.getMsg(Env.getCtx(), "PriceHistory")); - centerTabbedPane.add(reservedPane, Msg.translate(Env.getCtx(), "QtyReserved")); - centerTabbedPane.add(orderedPane, Msg.translate(Env.getCtx(), "QtyOrdered")); - centerTabbedPane.add(unconfirmedPane, Msg.getMsg(Env.getCtx(), "QtyUnconfirmed")); - if (m_M_Product_ID != 0) - centerTabbedPane.add(atpPane, Msg.getMsg(Env.getCtx(), "ATP")); - // - pricePane.getViewport().add(m_tablePrice, null); - reservedPane.getViewport().add(m_tableReserved, null); - orderedPane.getViewport().add(m_tableOrdered, null); - unconfirmedPane.getViewport().add(m_tableUnconfirmed, null); - if (m_M_Product_ID != 0) - atpPane.getViewport().add(m_tableAtp, null); - // - confirmPanel.addActionListener(this); - } // jbInit - - /** - * Dynamic Init for Price Tab - */ - private boolean dynInit() - { - // Header - Vector columnNames = new Vector(); - columnNames.add(Msg.translate(Env.getCtx(), m_C_BPartner_ID == 0 ? "C_BPartner_ID" : "M_Product_ID")); - columnNames.add(Msg.translate(Env.getCtx(), "PriceActual")); - columnNames.add(Msg.translate(Env.getCtx(), "QtyInvoiced")); - columnNames.add(Msg.translate(Env.getCtx(), "Discount")); - columnNames.add(Msg.translate(Env.getCtx(), "DocumentNo")); - columnNames.add(Msg.translate(Env.getCtx(), "DateInvoiced")); - columnNames.add(Msg.translate(Env.getCtx(), "AD_Org_ID")); - - // Fill Data - Vector> data = null; - if (m_C_BPartner_ID == 0) - data = queryBPartner(); // BPartner of Product - else - data = queryProduct(); // Product of BPartner - - // Table - m_modelPrice = new DefaultTableModel(data, columnNames); - m_tablePrice.setModel(m_modelPrice); - // - m_tablePrice.setColumnClass(0, String.class, true); // Product/Partner - m_tablePrice.setColumnClass(1, Double.class, true); // Price - m_tablePrice.setColumnClass(2, Double.class, true); // Quantity - m_tablePrice.setColumnClass(3, BigDecimal.class, true); // Discount (%) to limit precision - m_tablePrice.setColumnClass(4, String.class, true); // DocNo - m_tablePrice.setColumnClass(5, Timestamp.class, true); // Date - m_tablePrice.setColumnClass(6, String.class, true); // Org - // - m_tablePrice.autoSize(); - // - return data.size() != 0; - } // dynInit - - - /** - * Get Info for Product for given Business Parner - */ - private Vector> queryProduct () - { - String sql = "SELECT p.Name,l.PriceActual,l.PriceList,l.QtyInvoiced," // 1,2,3,4 - + "i.DateInvoiced,dt.PrintName || ' ' || i.DocumentNo As DocumentNo," // 5,6 - + "o.Name, " // 7 - + "NULL, i.M_PriceList_ID " // 8,9 - + "FROM C_Invoice i" - + " INNER JOIN C_InvoiceLine l ON (i.C_Invoice_ID=l.C_Invoice_ID)" - + " INNER JOIN C_DocType dt ON (i.C_DocType_ID=dt.C_DocType_ID)" - + " INNER JOIN AD_Org o ON (i.AD_Org_ID=o.AD_Org_ID)" - + " INNER JOIN M_Product p ON (l.M_Product_ID=p.M_Product_ID) " - + "WHERE i.C_BPartner_ID=? " - + "ORDER BY i.DateInvoiced DESC"; - - Vector> data = fillTable (sql, m_C_BPartner_ID); - - sql = "SELECT Name from C_BPartner WHERE C_BPartner_ID=?"; - fillLabel (sql, m_C_BPartner_ID); - return data; - } // queryProduct - - /** - * Get Info for Business Partners for given Product - */ - private Vector> queryBPartner () - { - String sql = "SELECT bp.Name,l.PriceActual,l.PriceList,l.QtyInvoiced," // 1,2,3,4 - + "i.DateInvoiced,dt.PrintName || ' ' || i.DocumentNo As DocumentNo," // 5,6 - + "o.Name," // 7 - + "NULL, i.M_PriceList_ID" // 8,9 - + " FROM C_Invoice i" - + " INNER JOIN C_InvoiceLine l ON (i.C_Invoice_ID=l.C_Invoice_ID)" - + " INNER JOIN C_DocType dt ON (i.C_DocType_ID=dt.C_DocType_ID)" - + " INNER JOIN AD_Org o ON (i.AD_Org_ID=o.AD_Org_ID)" - + " INNER JOIN C_BPartner bp ON (i.C_BPartner_ID=bp.C_BPartner_ID) " - + "WHERE l.M_Product_ID=? " - + "ORDER BY i.DateInvoiced DESC"; - - Vector> data = fillTable (sql, m_M_Product_ID); - - sql = "SELECT Name from M_Product WHERE M_Product_ID=?"; - fillLabel (sql, m_M_Product_ID); - return data; - } // qyeryBPartner - - /** - * Fill Table - */ - private Vector> fillTable (String sql, int parameter) - { - if (log.isLoggable(Level.FINE)) log.fine(sql + "; Parameter=" + parameter); - Vector> data = new Vector>(); - PreparedStatement pstmt = null; - ResultSet rs = null; - try - { - pstmt = DB.prepareStatement(sql, null); - pstmt.setInt(1, parameter); - rs = pstmt.executeQuery(); - while (rs.next()) - { - Vector line = new Vector(6); - // 0-Name, 1-PriceActual, 2-QtyInvoiced, 3-Discount, 4-DocumentNo, 5-DateInvoiced - line.add(rs.getString(1)); // Name - line.add(rs.getBigDecimal(2)); // Price - line.add(Double.valueOf(rs.getDouble(4))); // Qty - BigDecimal discountBD = rs.getBigDecimal(8); - if (discountBD == null) { - double priceList = rs.getDouble(3); - double priceActual = rs.getDouble(2); - if (priceList != 0) { - discountBD = BigDecimal.valueOf((priceList - priceActual)/priceList * 100); - // Rounding: - int precision = MPriceList.getStandardPrecision(Env.getCtx(), rs.getInt(9)); - if (discountBD.scale() > precision) - discountBD = discountBD.setScale(precision, RoundingMode.HALF_UP); - } - else - discountBD = Env.ZERO; - } - line.add(discountBD); // Discount - line.add(rs.getString(6)); // DocNo - line.add(rs.getTimestamp(5)); // Date - line.add(rs.getString(7)); // Org/Warehouse - data.add(line); - } - } - catch (SQLException e) - { - log.log(Level.SEVERE, sql, e); - } - finally { - DB.close(rs, pstmt); - rs = null; pstmt = null; - } - if (log.isLoggable(Level.FINE)) log.fine("#" + data.size()); - return data; - } // fillTable - - /** - * Set Label - * to product or bp name - */ - private void fillLabel (String sql, int parameter) - { - if (log.isLoggable(Level.FINE)) log.fine(sql + "; Parameter=" + parameter); - String retValue = DB.getSQLValueString(null, sql, parameter); - if (retValue != null) - label.setText(retValue); - } // fillLabel - - - /** - * Action Listener - */ - public void actionPerformed(ActionEvent e) - { - if (e.getActionCommand().equals(ConfirmPanel.A_OK)) - dispose(); - } // actionPerformed - - - /** - * Tab Changed - * @param e event - */ - public void stateChanged(ChangeEvent e) - { - if (centerTabbedPane.getSelectedIndex() == 1) - initReservedOrderedTab(true); - else if (centerTabbedPane.getSelectedIndex() == 2) - initReservedOrderedTab(false); - else if (centerTabbedPane.getSelectedIndex() == 3) - initUnconfirmedTab(); - else if (centerTabbedPane.getSelectedIndex() == 4) - initAtpTab(); - } // stateChanged - - /** - * Query Reserved/Ordered - * @param reserved po/so - */ - private void initReservedOrderedTab (boolean reserved) - { - // Done already - if (reserved && m_modelReserved != null) - return; - if (!reserved && m_modelOrdered != null) - return; - - // Header - Vector columnNames = new Vector(); - columnNames.add(Msg.translate(Env.getCtx(), m_C_BPartner_ID == 0 ? "C_BPartner_ID" : "M_Product_ID")); - columnNames.add(Msg.translate(Env.getCtx(), "PriceActual")); - columnNames.add(Msg.translate(Env.getCtx(), reserved ? "QtyReserved" : "QtyOrdered")); - columnNames.add(Msg.translate(Env.getCtx(), "Discount")); - columnNames.add(Msg.translate(Env.getCtx(), "DocumentNo")); - columnNames.add(Msg.translate(Env.getCtx(), "DateOrdered")); - columnNames.add(Msg.translate(Env.getCtx(), "M_Warehouse_ID")); - - // Fill Data - Vector> data = null; - if (m_C_BPartner_ID == 0) - { - String sql = "SELECT bp.Name, ol.PriceActual,ol.PriceList,ol.QtyReserved," - + "o.DateOrdered,dt.PrintName || ' ' || o.DocumentNo As DocumentNo, " - + "w.Name," - + "ol.Discount, 0 " // 8,9=M_PriceList_ID - + "FROM C_Order o" - + " INNER JOIN C_OrderLine ol ON (o.C_Order_ID=ol.C_Order_ID)" - + " INNER JOIN C_DocType dt ON (o.C_DocType_ID=dt.C_DocType_ID)" - + " INNER JOIN M_Warehouse w ON (ol.M_Warehouse_ID=w.M_Warehouse_ID)" - + " INNER JOIN C_BPartner bp ON (o.C_BPartner_ID=bp.C_BPartner_ID) " - + "WHERE ol.QtyReserved<>0" - + " AND ol.M_Product_ID=?" - + " AND o.IsSOTrx=" + (reserved ? "'Y'" : "'N'") - + " ORDER BY o.DateOrdered"; - data = fillTable (sql, m_M_Product_ID); // Product By BPartner - } - else - { - String sql = "SELECT p.Name, ol.PriceActual,ol.PriceList,ol.QtyReserved," - + "o.DateOrdered,dt.PrintName || ' ' || o.DocumentNo As DocumentNo, " - + "w.Name," - + "ol.Discount, 0 " // 8,9=M_PriceList_ID - + "FROM C_Order o" - + " INNER JOIN C_OrderLine ol ON (o.C_Order_ID=ol.C_Order_ID)" - + " INNER JOIN C_DocType dt ON (o.C_DocType_ID=dt.C_DocType_ID)" - + " INNER JOIN M_Warehouse w ON (ol.M_Warehouse_ID=w.M_Warehouse_ID)" - + " INNER JOIN M_Product p ON (ol.M_Product_ID=p.M_Product_ID) " - + "WHERE ol.QtyReserved<>0" - + " AND o.C_BPartner_ID=?" - + " AND o.IsSOTrx=" + (reserved ? "'Y'" : "'N'") - + " ORDER BY o.DateOrdered"; - data = fillTable (sql, m_C_BPartner_ID);// Product of BP - } - - // Table - MiniTable table = null; - if (reserved) - { - m_modelReserved = new DefaultTableModel(data, columnNames); - m_tableReserved.setModel(m_modelReserved); - table = m_tableReserved; - } - else - { - m_modelOrdered = new DefaultTableModel(data, columnNames); - m_tableOrdered.setModel(m_modelOrdered); - table = m_tableOrdered; - } - // - table.setColumnClass(0, String.class, true); // Product/Partner - table.setColumnClass(1, BigDecimal.class, true); // Price - table.setColumnClass(2, Double.class, true); // Quantity - table.setColumnClass(3, BigDecimal.class, true); // Discount (%) - table.setColumnClass(4, String.class, true); // DocNo - table.setColumnClass(5, Timestamp.class, true); // Date - table.setColumnClass(6, String.class, true); // Warehouse - // - table.autoSize(); - } // initReservedOrderedTab - - - /** - * Query Unconfirmed - */ - private void initUnconfirmedTab () - { - // Done already - if (m_modelUnconfirmed != null) - return; - - // Header - Vector columnNames = new Vector(); - columnNames.add(Msg.translate(Env.getCtx(), m_C_BPartner_ID == 0 ? "C_BPartner_ID" : "M_Product_ID")); - columnNames.add(Msg.translate(Env.getCtx(), "MovementQty")); - columnNames.add(Msg.translate(Env.getCtx(), "MovementDate")); - columnNames.add(Msg.translate(Env.getCtx(), "IsSOTrx")); - columnNames.add(Msg.translate(Env.getCtx(), "DocumentNo")); - columnNames.add(Msg.translate(Env.getCtx(), "M_Warehouse_ID")); - - // Fill Data - String sql = null; - int parameter = 0; - if (m_C_BPartner_ID == 0) - { - sql = "SELECT bp.Name," - + " CASE WHEN io.IsSOTrx='Y' THEN iol.MovementQty*-1 ELSE iol.MovementQty END AS MovementQty," - + " io.MovementDate,io.IsSOTrx," - + " dt.PrintName || ' ' || io.DocumentNo As DocumentNo," - + " w.Name " - + "FROM M_InOutLine iol" - + " INNER JOIN M_InOut io ON (iol.M_InOut_ID=io.M_InOut_ID)" - + " INNER JOIN C_BPartner bp ON (io.C_BPartner_ID=bp.C_BPartner_ID)" - + " INNER JOIN C_DocType dt ON (io.C_DocType_ID=dt.C_DocType_ID)" - + " INNER JOIN M_Warehouse w ON (io.M_Warehouse_ID=w.M_Warehouse_ID)" - + " INNER JOIN M_InOutLineConfirm lc ON (iol.M_InOutLine_ID=lc.M_InOutLine_ID) " - + "WHERE iol.M_Product_ID=?" - + " AND lc.Processed='N' " - + "ORDER BY io.MovementDate,io.IsSOTrx"; - parameter = m_M_Product_ID; - } - else - { - sql = "SELECT p.Name," - + " CASE WHEN io.IsSOTrx='Y' THEN iol.MovementQty*-1 ELSE iol.MovementQty END AS MovementQty," - + " io.MovementDate,io.IsSOTrx," - + " dt.PrintName || ' ' || io.DocumentNo As DocumentNo," - + " w.Name " - + "FROM M_InOutLine iol" - + " INNER JOIN M_InOut io ON (iol.M_InOut_ID=io.M_InOut_ID)" - + " INNER JOIN M_Product p ON (iol.M_Product_ID=p.M_Product_ID)" - + " INNER JOIN C_DocType dt ON (io.C_DocType_ID=dt.C_DocType_ID)" - + " INNER JOIN M_Warehouse w ON (io.M_Warehouse_ID=w.M_Warehouse_ID)" - + " INNER JOIN M_InOutLineConfirm lc ON (iol.M_InOutLine_ID=lc.M_InOutLine_ID) " - + "WHERE io.C_BPartner_ID=?" - + " AND lc.Processed='N' " - + "ORDER BY io.MovementDate,io.IsSOTrx"; - parameter = m_C_BPartner_ID; - } - Vector> data = new Vector>(); - PreparedStatement pstmt = null; - ResultSet rs = null; - try - { - pstmt = DB.prepareStatement(sql, null); - pstmt.setInt(1, parameter); - rs = pstmt.executeQuery(); - while (rs.next()) - { - Vector line = new Vector(6); - // 1-Name, 2-MovementQty, 3-MovementDate, 4-IsSOTrx, 5-DocumentNo - line.add(rs.getString(1)); // Name - line.add(Double.valueOf(rs.getDouble(2))); // Qty - line.add(rs.getTimestamp(3)); // Date - line.add(Boolean.valueOf("Y".equals(rs.getString(4)))); // IsSOTrx - line.add(rs.getString(5)); // DocNo - line.add(rs.getString(6)); // Warehouse - data.add(line); - } - } - catch (SQLException e) - { - log.log(Level.SEVERE, sql, e); - } - finally { - DB.close(rs, pstmt); - rs = null; pstmt = null; - } - if (log.isLoggable(Level.FINE)) log.fine("#" + data.size()); - - // Table - m_modelUnconfirmed = new DefaultTableModel(data, columnNames); - m_tableUnconfirmed.setModel(m_modelUnconfirmed); - MiniTable table = m_tableUnconfirmed; - // - table.setColumnClass(0, String.class, true); // Product/Partner - table.setColumnClass(1, Double.class, true); // MovementQty - table.setColumnClass(2, Timestamp.class, true); // MovementDate - table.setColumnClass(3, Boolean.class, true); // IsSOTrx - table.setColumnClass(4, String.class, true); // DocNo - // - table.autoSize(); - } // initUnconfirmedTab - - /** - * Query ATP - */ - private void initAtpTab () - { - // Done already - if (m_modelAtp != null) - return; - - // Header - Vector columnNames = new Vector(); - columnNames.add(Msg.translate(Env.getCtx(), "Date")); - columnNames.add(Msg.translate(Env.getCtx(), "QtyOnHand")); - columnNames.add(Msg.translate(Env.getCtx(), "C_BPartner_ID")); - columnNames.add(Msg.translate(Env.getCtx(), "QtyOrdered")); - columnNames.add(Msg.translate(Env.getCtx(), "QtyReserved")); - columnNames.add(Msg.translate(Env.getCtx(), "M_Locator_ID")); - columnNames.add(Msg.translate(Env.getCtx(), "M_AttributeSetInstance_ID")); - columnNames.add(Msg.translate(Env.getCtx(), "DocumentNo")); - columnNames.add(Msg.translate(Env.getCtx(), "M_Warehouse_ID")); - - // Fill Storage Data - boolean showDetail = CLogMgt.isLevelFine(); - String sql = "SELECT s.QtyOnHand, s.QtyReserved, s.QtyOrdered," - + " productAttribute(s.M_AttributeSetInstance_ID), s.M_AttributeSetInstance_ID,"; - if (!showDetail) - sql = "SELECT SUM(s.QtyOnHand), SUM(s.QtyReserved), SUM(s.QtyOrdered)," - + " productAttribute(s.M_AttributeSetInstance_ID), 0,"; - sql += " w.Name, l.Value " - + "FROM M_Storage s" - + " INNER JOIN M_Locator l ON (s.M_Locator_ID=l.M_Locator_ID)" - + " INNER JOIN M_Warehouse w ON (l.M_Warehouse_ID=w.M_Warehouse_ID) " - + "WHERE M_Product_ID=?"; - if (m_M_Warehouse_ID != 0) - sql += " AND l.M_Warehouse_ID=?"; - if (m_M_AttributeSetInstance_ID > 0) - sql += " AND s.M_AttributeSetInstance_ID=?"; - sql += " AND (s.QtyOnHand<>0 OR s.QtyReserved<>0 OR s.QtyOrdered<>0)"; - if (!showDetail) - sql += " GROUP BY productAttribute(s.M_AttributeSetInstance_ID), w.Name, l.Value"; - sql += " ORDER BY l.Value"; - - Vector> data = new Vector>(); - double qty = 0; - PreparedStatement pstmt = null; - ResultSet rs = null; - try - { - pstmt = DB.prepareStatement(sql, null); - pstmt.setInt(1, m_M_Product_ID); - if (m_M_Warehouse_ID != 0) - pstmt.setInt(2, m_M_Warehouse_ID); - if (m_M_AttributeSetInstance_ID > 0) - pstmt.setInt(3, m_M_AttributeSetInstance_ID); - rs = pstmt.executeQuery(); - while (rs.next()) - { - Vector line = new Vector(9); - line.add(null); // Date - double qtyOnHand = rs.getDouble(1); - qty += qtyOnHand; - line.add(Double.valueOf(qtyOnHand)); // Qty - line.add(null); // BPartner - line.add(Double.valueOf(rs.getDouble(3))); // QtyOrdered - line.add(Double.valueOf(rs.getDouble(2))); // QtyReserved - line.add(rs.getString(7)); // Locator - String asi = rs.getString(4); - if (showDetail && (asi == null || asi.length() == 0)) - asi = "{" + rs.getInt(5) + "}"; - line.add(asi); // ASI - line.add(null); // DocumentNo - line.add(rs.getString(6)); // Warehouse - data.add(line); - } - } - catch (SQLException e) - { - log.log(Level.SEVERE, sql, e); - } - finally { - DB.close(rs, pstmt); - rs = null; pstmt = null; - } - - // Orders - sql = "SELECT o.DatePromised, ol.QtyReserved," - + " productAttribute(ol.M_AttributeSetInstance_ID), ol.M_AttributeSetInstance_ID," - + " dt.DocBaseType, bp.Name," - + " dt.PrintName || ' ' || o.DocumentNo As DocumentNo, w.Name " - + "FROM C_Order o" - + " INNER JOIN C_OrderLine ol ON (o.C_Order_ID=ol.C_Order_ID)" - + " INNER JOIN C_DocType dt ON (o.C_DocType_ID=dt.C_DocType_ID)" - + " INNER JOIN M_Warehouse w ON (ol.M_Warehouse_ID=w.M_Warehouse_ID)" - + " INNER JOIN C_BPartner bp ON (o.C_BPartner_ID=bp.C_BPartner_ID) " - + "WHERE ol.QtyReserved<>0" - + " AND ol.M_Product_ID=?"; - if (m_M_Warehouse_ID != 0) - sql += " AND ol.M_Warehouse_ID=?"; - if (m_M_AttributeSetInstance_ID > 0) - sql += " AND ol.M_AttributeSetInstance_ID=?"; - sql += " ORDER BY o.DatePromised"; - try - { - pstmt = DB.prepareStatement(sql, null); - pstmt.setInt(1, m_M_Product_ID); - if (m_M_Warehouse_ID != 0) - pstmt.setInt(2, m_M_Warehouse_ID); - if (m_M_AttributeSetInstance_ID > 0) - pstmt.setInt(3, m_M_AttributeSetInstance_ID); - rs = pstmt.executeQuery(); - while (rs.next()) - { - Vector line = new Vector(9); - line.add(rs.getTimestamp(1)); // Date - double oq = rs.getDouble(2); - String DocBaseType = rs.getString(5); - Double qtyReserved = null; - Double qtyOrdered = null; - if (MDocType.DOCBASETYPE_PurchaseOrder.equals(DocBaseType)) - { - qtyOrdered = Double.valueOf(oq); - qty += oq; - } - else - { - qtyReserved = Double.valueOf(oq); - qty -= oq; - } - line.add(Double.valueOf(qty)); // Qty - line.add(rs.getString(6)); // BPartner - line.add(qtyOrdered); // QtyOrdered - line.add(qtyReserved); // QtyReserved - line.add(null); // Locator - String asi = rs.getString(3); - if (showDetail && (asi == null || asi.length() == 0)) - asi = "{" + rs.getInt(4) + "}"; - line.add(asi); // ASI - line.add(rs.getString(7)); // DocumentNo - line.add(rs.getString(8)); // Warehouse - data.add(line); - } - } - catch (SQLException e) - { - log.log(Level.SEVERE, sql, e); - } - finally { - DB.close(rs, pstmt); - rs = null; pstmt = null; - } - - // Table - MiniTable table = null; - m_modelAtp = new DefaultTableModel(data, columnNames); - m_tableAtp.setModel(m_modelAtp); - table = m_tableAtp; - // - table.setColumnClass(0, Timestamp.class, true); // Date - table.setColumnClass(1, Double.class, true); // Quantity - table.setColumnClass(2, String.class, true); // Partner - table.setColumnClass(3, Double.class, true); // Quantity - table.setColumnClass(4, Double.class, true); // Quantity - table.setColumnClass(5, String.class, true); // Locator - table.setColumnClass(6, String.class, true); // ASI - table.setColumnClass(7, String.class, true); // DocNo - table.setColumnClass(8, String.class, true); // Warehouse - // - table.autoSize(); - } // initAtpTab - -} // InvoiceHistory diff --git a/org.adempiere.ui.swing/src/org/compiere/apps/search/PAttributeInstance.java b/org.adempiere.ui.swing/src/org/compiere/apps/search/PAttributeInstance.java deleted file mode 100644 index 12cbeb8cc3..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/apps/search/PAttributeInstance.java +++ /dev/null @@ -1,401 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ -package org.compiere.apps.search; - -import java.awt.BorderLayout; -import java.awt.event.ActionEvent; -import java.awt.event.MouseEvent; -import java.sql.PreparedStatement; -import java.sql.ResultSet; -import java.sql.Timestamp; -import java.util.logging.Level; - -import javax.swing.JDialog; -import javax.swing.JFrame; -import javax.swing.JScrollPane; -import javax.swing.event.ListSelectionEvent; -import javax.swing.event.ListSelectionListener; - -import org.compiere.apps.AEnv; -import org.compiere.apps.ConfirmPanel; -import org.compiere.minigrid.ColumnInfo; -import org.compiere.minigrid.IDColumn; -import org.compiere.minigrid.MiniTable; -import org.compiere.swing.CCheckBox; -import org.compiere.swing.CDialog; -import org.compiere.swing.CPanel; -import org.compiere.util.CLogger; -import org.compiere.util.DB; -import org.compiere.util.Env; -import org.compiere.util.KeyNamePair; -import org.compiere.util.Msg; - - -/** - * Display Product Attribute Instance Info - * - * @author Jorg Janke - * @version $Id: PAttributeInstance.java,v 1.3 2006/07/30 00:51:27 jjanke Exp $ - */ -public class PAttributeInstance extends CDialog - implements ListSelectionListener -{ - /** - * - */ - private static final long serialVersionUID = -3743466565716139916L; - - /** - * Constructor - * @param parent frame parent - * @param title title - * @param M_Warehouse_ID warehouse key name pair - * @param M_Locator_ID locator - * @param M_Product_ID product key name pair - * @param C_BPartner_ID bp - */ - public PAttributeInstance(JFrame parent, String title, - int M_Warehouse_ID, int M_Locator_ID, int M_Product_ID, int C_BPartner_ID) - { - super (parent, Msg.getMsg(Env.getCtx(), "PAttributeInstance") + title, true); - init (M_Warehouse_ID, M_Locator_ID, M_Product_ID, C_BPartner_ID); - AEnv.showCenterWindow(parent, this); - } // PAttributeInstance - - /** - * Constructor - * @param parent dialog parent - * @param title title - * @param M_Warehouse_ID warehouse key name pair - * @param M_Locator_ID locator - * @param M_Product_ID product key name pair - * @param C_BPartner_ID bp - */ - public PAttributeInstance(JDialog parent, String title, - int M_Warehouse_ID, int M_Locator_ID, int M_Product_ID, int C_BPartner_ID) - { - super (parent, Msg.getMsg(Env.getCtx(), "PAttributeInstance") + title, true); - init (M_Warehouse_ID, M_Locator_ID, M_Product_ID, C_BPartner_ID); - AEnv.showCenterWindow(parent, this); - } // PAttributeInstance - - /** - * Initialization - * @param M_Warehouse_ID wh - * @param M_Locator_ID loc - * @param M_Product_ID product - * @param C_BPartner_ID partner - */ - private void init (int M_Warehouse_ID, int M_Locator_ID, int M_Product_ID, int C_BPartner_ID) - { - if (log.isLoggable(Level.INFO)) log.info("M_Warehouse_ID=" + M_Warehouse_ID - + ", M_Locator_ID=" + M_Locator_ID - + ", M_Product_ID=" + M_Product_ID); - m_M_Warehouse_ID = M_Warehouse_ID; - m_M_Locator_ID = M_Locator_ID; - m_M_Product_ID = M_Product_ID; - try - { - jbInit(); - dynInit(C_BPartner_ID); - } - catch (Exception e) - { - log.log(Level.SEVERE, "", e); - } - } // init - - private CPanel mainPanel = new CPanel(); - private BorderLayout mainLayout = new BorderLayout(); - private CPanel northPanel = new CPanel(); - private BorderLayout northLayout = new BorderLayout(); - private JScrollPane centerScrollPane = new JScrollPane(); - private ConfirmPanel confirmPanel = new ConfirmPanel (true); - private CCheckBox showAll = new CCheckBox (Msg.getMsg(Env.getCtx(), "ShowAll")); - // - private MiniTable m_table = new MiniTable(); - // Parameter - private int m_M_Warehouse_ID; - private int m_M_Locator_ID; - private int m_M_Product_ID; - // - private int m_M_AttributeSetInstance_ID = -1; - private String m_M_AttributeSetInstanceName = null; - private String m_sql; - /** Logger */ - private static CLogger log = CLogger.getCLogger(PAttributeInstance.class); - - /** - * Static Init - * @throws Exception - */ - private void jbInit() throws Exception - { - mainPanel.setLayout(mainLayout); - this.getContentPane().add(mainPanel, BorderLayout.CENTER); - // North - northPanel.setLayout(northLayout); - northPanel.add(showAll, BorderLayout.EAST); - showAll.addActionListener(this); - mainPanel.add(northPanel, BorderLayout.NORTH); - // Center - mainPanel.add(centerScrollPane, BorderLayout.CENTER); - centerScrollPane.getViewport().add(m_table, null); - // South - mainPanel.add(confirmPanel, BorderLayout.SOUTH); - confirmPanel.addActionListener(this); - } // jbInit - - /** Table Column Layout Info */ - private static ColumnInfo[] s_layout = new ColumnInfo[] - { - new ColumnInfo(" ", "s.M_AttributeSetInstance_ID", IDColumn.class), - new ColumnInfo(Msg.translate(Env.getCtx(), "Description"), "asi.Description", String.class), - new ColumnInfo(Msg.translate(Env.getCtx(), "Lot"), "asi.Lot", String.class), - new ColumnInfo(Msg.translate(Env.getCtx(), "SerNo"), "asi.SerNo", String.class), - new ColumnInfo(Msg.translate(Env.getCtx(), "GuaranteeDate"), "asi.GuaranteeDate", Timestamp.class), - new ColumnInfo(Msg.translate(Env.getCtx(), "M_Locator_ID"), "l.Value", KeyNamePair.class, "s.M_Locator_ID"), - new ColumnInfo(Msg.translate(Env.getCtx(), "QtyOnHand"), "s.QtyOnHand", Double.class), - new ColumnInfo(Msg.translate(Env.getCtx(), "QtyReserved"), "s.QtyReserved", Double.class), - new ColumnInfo(Msg.translate(Env.getCtx(), "QtyOrdered"), "s.QtyOrdered", Double.class), - // See RV_Storage - new ColumnInfo(Msg.translate(Env.getCtx(), "GoodForDays"), "(daysbetween(asi.GuaranteeDate, SYSDATE))-p.GuaranteeDaysMin", Integer.class, true, true, null), - new ColumnInfo(Msg.translate(Env.getCtx(), "ShelfLifeDays"), "daysbetween(asi.GuaranteeDate, SYSDATE)", Integer.class), - new ColumnInfo(Msg.translate(Env.getCtx(), "ShelfLifeRemainingPct"), "CASE WHEN p.GuaranteeDays > 0 THEN TRUNC(((daysbetween(asi.GuaranteeDate, SYSDATE))/p.GuaranteeDays)*100) ELSE 0 END", Integer.class), - }; - /** From Clause */ - private static String s_sqlFrom = "M_Storage s" - + " INNER JOIN M_Locator l ON (s.M_Locator_ID=l.M_Locator_ID)" - + " INNER JOIN M_Product p ON (s.M_Product_ID=p.M_Product_ID)" - + " LEFT OUTER JOIN M_AttributeSetInstance asi ON (s.M_AttributeSetInstance_ID=asi.M_AttributeSetInstance_ID)"; - /** Where Clause */ - private static String s_sqlWhere = "s.M_Product_ID=? AND l.M_Warehouse_ID=?"; - private static String s_sqlWhereWithoutWarehouse = " s.M_Product_ID=?"; - - private String m_sqlNonZero = " AND (s.QtyOnHand<>0 OR s.QtyReserved<>0 OR s.QtyOrdered<>0)"; - private String m_sqlMinLife = ""; - - /** - * Dynamic Init - * @param C_BPartner_ID BP - */ - private void dynInit(int C_BPartner_ID) - { - if (log.isLoggable(Level.CONFIG)) log.config("C_BPartner_ID=" + C_BPartner_ID); - if (C_BPartner_ID != 0) - { - int ShelfLifeMinPct = 0; - int ShelfLifeMinDays = 0; - String sql = "SELECT bp.ShelfLifeMinPct, bpp.ShelfLifeMinPct, bpp.ShelfLifeMinDays " - + "FROM C_BPartner bp " - + " LEFT OUTER JOIN C_BPartner_Product bpp" - + " ON (bp.C_BPartner_ID=bpp.C_BPartner_ID AND bpp.M_Product_ID=?) " - + "WHERE bp.C_BPartner_ID=?"; - PreparedStatement pstmt = null; - ResultSet rs = null; - try - { - pstmt = DB.prepareStatement(sql, null); - pstmt.setInt(1, m_M_Product_ID); - pstmt.setInt(2, C_BPartner_ID); - rs = pstmt.executeQuery(); - if (rs.next()) - { - ShelfLifeMinPct = rs.getInt(1); // BP - int pct = rs.getInt(2); // BP_P - if (pct > 0) // overwrite - ShelfLifeMinDays = pct; - ShelfLifeMinDays = rs.getInt(3); - } - } - catch (Exception e) - { - log.log(Level.SEVERE, sql, e); - } - finally { - DB.close(rs, pstmt); - rs = null; pstmt = null; - } - if (ShelfLifeMinPct > 0) - { - m_sqlMinLife = " AND COALESCE(TRUNC(((daysbetween(asi.GuaranteeDate, SYSDATE))/p.GuaranteeDays)*100),0)>=" + ShelfLifeMinPct; - if (log.isLoggable(Level.CONFIG)) log.config( "PAttributeInstance.dynInit - ShelfLifeMinPct=" + ShelfLifeMinPct); - } - if (ShelfLifeMinDays > 0) - { - m_sqlMinLife += " AND COALESCE((daysbetween(asi.GuaranteeDate, SYSDATE)),0)>=" + ShelfLifeMinDays; - if (log.isLoggable(Level.CONFIG)) log.config( "PAttributeInstance.dynInit - ShelfLifeMinDays=" + ShelfLifeMinDays); - } - } // BPartner != 0 - - m_sql = m_table.prepareTable (s_layout, s_sqlFrom, - m_M_Warehouse_ID == 0 ? s_sqlWhereWithoutWarehouse : s_sqlWhere, false, "s") - + " ORDER BY asi.GuaranteeDate, s.QtyOnHand"; // oldest, smallest first - // - m_table.setRowSelectionAllowed(true); - m_table.setMultiSelection(false); - m_table.addMouseListener(this); - m_table.getSelectionModel().addListSelectionListener(this); - // - refresh(); - } // dynInit - - /** - * Refresh Query - */ - private void refresh() - { - String sql = m_sql; - int pos = m_sql.lastIndexOf(" ORDER BY "); - if (!showAll.isSelected()) - { - sql = m_sql.substring(0, pos) - + m_sqlNonZero; - if (m_sqlMinLife.length() > 0) - sql += m_sqlMinLife; - sql += m_sql.substring(pos); - } - // - log.finest(sql); - PreparedStatement pstmt = null; - ResultSet rs = null; - try - { - pstmt = DB.prepareStatement(sql, null); - pstmt.setInt(1, m_M_Product_ID); - if (m_M_Warehouse_ID != 0) - pstmt.setInt(2, m_M_Warehouse_ID); - rs = pstmt.executeQuery(); - m_table.loadTable(rs); - } - catch (Exception e) - { - log.log(Level.SEVERE, sql, e); - } - finally { - DB.close(rs, pstmt); - rs = null; pstmt = null; - } - enableButtons(); - } // refresh - - /** - * Action Listener - * @param e event - */ - public void actionPerformed(ActionEvent e) - { - if (e.getActionCommand().equals(ConfirmPanel.A_OK)) - dispose(); - else if (e.getActionCommand().equals(ConfirmPanel.A_CANCEL)) - { - dispose(); - m_M_AttributeSetInstance_ID = -1; - m_M_AttributeSetInstanceName = null; - } - else if (e.getSource() == showAll) - { - refresh(); - } - } // actionPerformed - - /** - * Table selection changed - * @param e event - */ - public void valueChanged (ListSelectionEvent e) - { - if (e.getValueIsAdjusting()) - return; - enableButtons(); - } // valueChanged - - /** - * Enable/Set Buttons and set ID - */ - private void enableButtons() - { - m_M_AttributeSetInstance_ID = -1; - m_M_AttributeSetInstanceName = null; - m_M_Locator_ID = 0; - int row = m_table.getSelectedRow(); - boolean enabled = row != -1; - if (enabled) - { - Integer ID = m_table.getSelectedRowKey(); - if (ID != null) - { - m_M_AttributeSetInstance_ID = ID.intValue(); - m_M_AttributeSetInstanceName = (String)m_table.getValueAt(row, 1); - // - Object oo = m_table.getValueAt(row, 5); - if (oo instanceof KeyNamePair) - { - KeyNamePair pp = (KeyNamePair)oo; - m_M_Locator_ID = pp.getKey(); - } - } - } - confirmPanel.getOKButton().setEnabled(enabled); - if (log.isLoggable(Level.FINE)) log.fine("M_AttributeSetInstance_ID=" + m_M_AttributeSetInstance_ID - + " - " + m_M_AttributeSetInstanceName - + "; M_Locator_ID=" + m_M_Locator_ID); - } // enableButtons - - /** - * Mouse Clicked - * @param e event - */ - public void mouseClicked(MouseEvent e) - { - // Double click with selected row => exit - if (e.getClickCount() > 1 && m_table.getSelectedRow() != -1) - { - enableButtons(); - dispose(); - } - } // mouseClicked - - - /** - * Get Attribute Set Instance - * @return M_AttributeSetInstance_ID or -1 - */ - public int getM_AttributeSetInstance_ID() - { - return m_M_AttributeSetInstance_ID; - } // getM_AttributeSetInstance_ID - - /** - * Get Instance Name - * @return Instance Name - */ - public String getM_AttributeSetInstanceName() - { - return m_M_AttributeSetInstanceName; - } // getM_AttributeSetInstanceName - - /** - * Get Locator - * @return M_Locator_ID or 0 - */ - public int getM_Locator_ID() - { - return m_M_Locator_ID; - } // getM_Locator_ID - -} // PAttributeInstance \ No newline at end of file diff --git a/org.adempiere.ui.swing/src/org/compiere/apps/search/VSchedule.java b/org.adempiere.ui.swing/src/org/compiere/apps/search/VSchedule.java deleted file mode 100644 index 0dc972d3c8..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/apps/search/VSchedule.java +++ /dev/null @@ -1,180 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ -package org.compiere.apps.search; - -import java.awt.BorderLayout; -import java.awt.Dimension; -import java.sql.Timestamp; -import java.util.Calendar; -import java.util.GregorianCalendar; -import java.util.logging.Level; - -import javax.swing.JScrollPane; - -import org.compiere.model.MAssignmentSlot; -import org.compiere.model.ScheduleUtil; -import org.compiere.swing.CPanel; -import org.compiere.util.CLogger; -import org.compiere.util.Env; - -/** - * Visual and Control Part of Schedule. - * Contains Time and Schedule Panels - * - * @author Jorg Janke - * @version $Id: VSchedule.java,v 1.3 2006/07/30 00:51:27 jjanke Exp $ - */ -public class VSchedule extends CPanel -{ - /** - * - */ - private static final long serialVersionUID = 604084538933601239L; - - /** - * Constructor - * @param is InfoSchedule for call back - * @param type Type of schedule TYPE_... - */ - public VSchedule (InfoSchedule is, int type) - { - m_type = type; - m_model = new ScheduleUtil (Env.getCtx()); - schedulePanel.setType (m_type); - schedulePanel.setTimePanel (timePanel); - schedulePanel.setInfoSchedule (is); // for callback - try - { - jbInit(); - } - catch(Exception e) - { - log.log(Level.SEVERE, "VSchedule", e); - } - } // VSchedule - - /** Day Display */ - static public final int TYPE_DAY = Calendar.DAY_OF_MONTH; - /** Week Display */ - static public final int TYPE_WEEK = Calendar.WEEK_OF_YEAR; - /** Month Display */ - static public final int TYPE_MONTH = Calendar.MONTH; - - /** Type */ - private int m_type = TYPE_DAY; - /** Model */ - private ScheduleUtil m_model = null; - /** Start Date */ - private Timestamp m_startDate; - /** End Date */ - private Timestamp m_endDate; - /** Logger */ - private static CLogger log = CLogger.getCLogger(VSchedule.class); - - private BorderLayout mainLayout = new BorderLayout(); - private VScheduleTimePanel timePanel = new VScheduleTimePanel(); - private VSchedulePanel schedulePanel = new VSchedulePanel(); - private JScrollPane schedulePane = new JScrollPane(); - - /** - * Static init - *
    -	 * 	timePanel (West)
    -	 *  schedlePanel (in schedulePane - Center)
    -	 *  
    - * @throws Exception - */ - private void jbInit() throws Exception - { - this.setLayout(mainLayout); - this.add(timePanel, BorderLayout.WEST); - // - // schedulePane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS); - schedulePane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_NEVER); - schedulePane.getViewport().add(schedulePanel, null); - schedulePane.setPreferredSize(new Dimension(200, 200)); - schedulePane.setBorder(null); - this.add(schedulePane, BorderLayout.CENTER); - } // jbInit - - /** - * Recreate View - * @param S_Resource_ID Resource - * @param date Date - */ - public void recreate (int S_Resource_ID, Timestamp date) - { - // Calculate Start Day - GregorianCalendar cal = new GregorianCalendar(); - cal.setTime(date); - cal.set(Calendar.HOUR, 0); - cal.set(Calendar.MINUTE, 0); - cal.set(Calendar.SECOND, 0); - cal.set(Calendar.MILLISECOND, 0); - if (m_type == TYPE_WEEK) - cal.set(Calendar.DAY_OF_WEEK, cal.getFirstDayOfWeek()); - else if (m_type == TYPE_MONTH) - cal.set(Calendar.DAY_OF_MONTH, 1); - m_startDate = new Timestamp(cal.getTimeInMillis()); - // Calculate End Date - cal.add(m_type, 1); - m_endDate = new Timestamp (cal.getTimeInMillis()); - // - if (log.isLoggable(Level.CONFIG)) log.config("(" + m_type + ") Resource_ID=" + S_Resource_ID + ": " + m_startDate + "->" + m_endDate); - // Create Slots - MAssignmentSlot[] mas = m_model.getAssignmentSlots (S_Resource_ID, m_startDate, m_endDate, null, true, null); - MAssignmentSlot[] mts = m_model.getDayTimeSlots (); - // Set Panels - timePanel.setTimeSlots(mts); - schedulePanel.setAssignmentSlots(mas, S_Resource_ID, m_startDate, m_endDate); - // Set Height - schedulePanel.setHeight(timePanel.getPreferredSize().height); - // repaint(); - } // recreate - - /** - * Enable/disable to Create New Assignments - * @param createNew if true, allows to create new Assignments - */ - public void setCreateNew (boolean createNew) - { - schedulePanel.setCreateNew(createNew); - } // setCreateNew - - /** - * Dispose - */ - public void dispose() - { - m_model = null; - timePanel = null; - if (schedulePanel != null) - schedulePanel.dispose(); - schedulePanel = null; - this.removeAll(); - } // dispose - - /** - * Get Start Date - * @return start date - */ - public Timestamp getStartDate() - { - return m_startDate; - } // getStartDate - -} // VSchedule diff --git a/org.adempiere.ui.swing/src/org/compiere/apps/search/VSchedulePanel.java b/org.adempiere.ui.swing/src/org/compiere/apps/search/VSchedulePanel.java deleted file mode 100644 index f8fa7484d0..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/apps/search/VSchedulePanel.java +++ /dev/null @@ -1,426 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ -package org.compiere.apps.search; - -import java.awt.Color; -import java.awt.Dimension; -import java.awt.FontMetrics; -import java.awt.Graphics; -import java.awt.Graphics2D; -import java.awt.Rectangle; -import java.awt.event.MouseEvent; -import java.awt.event.MouseListener; -import java.awt.font.LineBreakMeasurer; -import java.awt.font.TextAttribute; -import java.awt.font.TextLayout; -import java.sql.Timestamp; -import java.text.AttributedCharacterIterator; -import java.text.AttributedString; -import java.text.DateFormat; -import java.text.SimpleDateFormat; -import java.util.GregorianCalendar; -import java.util.logging.Level; - -import javax.swing.JComponent; - -import org.compiere.apps.AEnv; -import org.compiere.grid.ed.VAssignmentDialog; -import org.compiere.model.MAssignmentSlot; -import org.compiere.model.MResourceAssignment; -import org.compiere.plaf.CompiereUtils; -import org.compiere.util.CLogger; -import org.compiere.util.Env; -import org.compiere.util.Language; -import org.compiere.util.TimeUtil; - -/** - * Schedule Panel - * - * @author Jorg Janke - * @version $Id: VSchedulePanel.java,v 1.2 2006/07/30 00:51:27 jjanke Exp $ - */ -public class VSchedulePanel extends JComponent implements MouseListener -{ - /** - * - */ - private static final long serialVersionUID = -7779310781236274016L; - - /** - * Constructor - */ - public VSchedulePanel () - { - setHeight(250); - addMouseListener(this); - } // VSchedulePanel - - - /** Number of Days */ - private int m_noDays = 1; - /** Height */ - private int m_height = 250; - - /** Day Slot Width */ - private int m_dayWidth = 170; - - /** TimePanel for layout info */ - private VScheduleTimePanel m_timePanel = null; - - /** Assignment Slots */ - private MAssignmentSlot[] m_slots = null; - /** Position of Slots */ - private Rectangle[] m_where = null; - /** Start Date */ - private Timestamp m_startDate = null; - /** If true creates new assignments */ - private boolean m_createNew = false; - /** Resource ID */ - private int m_S_Resource_ID = 0; - - private InfoSchedule m_infoSchedule = null; - - /** Text Margin */ - private static final int MARGIN = 2; - /** Logger */ - private static CLogger log = CLogger.getCLogger(VSchedulePanel.class); - - /** - * Set Type. - * Calculate number of days and set - * @param type schedule type - see VSchedule.TYPE_... - */ - public void setType (int type) - { - if (type == VSchedule.TYPE_MONTH) - m_noDays = 31; - else if (type == VSchedule.TYPE_WEEK) - m_noDays = 7; - else - m_noDays = 1; - setSize(); - } // setType - - /** - * Set InfoSchedule for callback - * @param is InfoSchedule - */ - public void setInfoSchedule (InfoSchedule is) - { - m_infoSchedule = is; - } - - /** - * Enable/disable to Create New Assignments - * @param createNew if true, allows to create new Assignments - */ - public void setCreateNew (boolean createNew) - { - m_createNew = createNew; - } // setCreateNew - - /** - * From height, Calculate & Set Size - * @param height height in pixels - */ - public void setHeight (int height) - { - m_height = height; - setSize(); - } // setHeight - - /** - * Set Size - */ - public void setSize () - { - // width - FontMetrics fm = null; - Graphics g = getGraphics(); - if (g == null) - g = Env.getGraphics(this); - if (g != null) - fm = g.getFontMetrics(g.getFont()); // the "correct" way - m_dayWidth = 0; - for (int i = 0; i < m_noDays; i++) - { - if (fm != null) - { - String string = getHeading(i); - int width = fm.stringWidth(string); - if (width > m_dayWidth) - m_dayWidth = width; - } - } - m_dayWidth += 20; - if (m_dayWidth < 180) // minimum width - m_dayWidth = 180; - - int w = m_noDays * m_dayWidth; - // - Dimension size = new Dimension(w, m_height); - setPreferredSize(size); - setMinimumSize(size); - setMaximumSize(size); - } // setHeight - - /** - * Set time Panel for info about tile slots - * @param timePanel time panel - */ - public void setTimePanel (VScheduleTimePanel timePanel) - { - m_timePanel = timePanel; - } // setTimePanel - - /************************************************************************** - * Set Slots - * @param mass Assignment Slots - * @param S_Resource_ID resource - * @param startDate start date - * @param endDate end date - */ - public void setAssignmentSlots (MAssignmentSlot[] mass, int S_Resource_ID, - Timestamp startDate, Timestamp endDate) - { - if (log.isLoggable(Level.FINE)) log.fine("S_Resource_ID=" + S_Resource_ID); - m_S_Resource_ID = S_Resource_ID; - m_noDays = TimeUtil.getDaysBetween (startDate, endDate); - m_startDate = startDate; - // - m_slots = mass; - m_where = new Rectangle[m_slots.length]; - // - // Calculate Assignments - for (int i = 0; m_slots != null && i < m_slots.length; i++) - { - MAssignmentSlot mas = m_slots[i]; - int dayIndex = TimeUtil.getDaysBetween (m_startDate, mas.getStartTime()); - if (dayIndex < 0 || dayIndex >= m_noDays) - System.out.println("Assignment " + i + " Invalid DateRange " + mas.getInfo()); - // - int xWidth = m_dayWidth / mas.getXMax(); - int xStart = dayIndex * m_dayWidth; // start day slot - xStart += mas.getXPos() * xWidth; // offset - - int yStart = m_timePanel.getSlotYStart(mas.getYStart()); - int yEnd = m_timePanel.getSlotYEnd(mas.getYEnd()); - // System.out.println("Assignment " + i + ", Xpos=" + mas.getXPos() + ", Xmax=" + mas.getXMax() - // + ", Ystart=" + mas.getYStart() + ", Yend=" + mas.getYEnd() + " " + mas.getInfo()); - m_where[i] = new Rectangle(xStart+1, yStart+1, xWidth-1, yEnd-yStart-1); - } // calculate assignments - - // - setSize(); - repaint(); - } // setAssignmentSlots - - /*************************************************************************/ - - /** - * Paint it - * @param g the Graphics object - */ - public void paint (Graphics g) - { - // log.fine( "VSchedulePanel.paint", g.getClip()); - Graphics2D g2D = (Graphics2D)g; - Dimension size = getPreferredSize(); - Rectangle clipBounds = g2D.getClipBounds(); - int w = size.width; - int h = size.height; - - // Paint Background - g2D.setPaint(Color.white); - g2D.fill3DRect(1, 1, w-2, h-2, true); - - if (m_timePanel == null) // required - return; - int headerHeight = m_timePanel.getHeaderHeight(); - - // horizontal lines - - g2D.setStroke(VScheduleTimePanel.getStroke(true)); - for (int i = 1; i < m_timePanel.getSlotCount(); i++) - { - g2D.setPaint(Color.gray); - int yy = m_timePanel.getSlotYStart(i); - g2D.drawLine(1, yy, w-2, yy); // top horiz line - } - - // heading and right vertical lines | - g2D.setStroke(VScheduleTimePanel.getStroke(false)); - for (int i = 0; i < m_noDays; i++) - { - Rectangle where = new Rectangle(i * m_dayWidth, 0, m_dayWidth, headerHeight); - if (!where.intersects(clipBounds)) - continue; - // Header Background - CompiereUtils.paint3Deffect(g2D, where, false, true); - g2D.setPaint(Color.blue); - TextLayout layout = new TextLayout (getHeading(i), g2D.getFont(), g2D.getFontRenderContext()); - float hh = layout.getAscent() + layout.getDescent(); - layout.draw (g2D, where.x + (m_dayWidth - layout.getAdvance())/2, // center - ((where.height - hh)/2) + layout.getAscent()); // center - // line - g2D.setPaint(Color.black); - int xEnd = (i+1) * m_dayWidth; - g2D.drawLine(xEnd, 1, xEnd, h-1); // right part - } - - // Paint Assignments - for (int i = 0; m_slots != null && i < m_slots.length; i++) - { - if (!m_where[i].intersects(clipBounds)) - continue; - - // Background - g2D.setColor(m_slots[i].getColor(true)); - g2D.fill(m_where[i]); - // Text - String string = m_slots[i].getInfoNameDescription(); - AttributedString as = new AttributedString (string); - as.addAttribute(TextAttribute.FONT, g2D.getFont()); - as.addAttribute(TextAttribute.FOREGROUND, m_slots[i].getColor(false)); - // Italics for Description - int startIt = string.indexOf('('); - int endIt = string.lastIndexOf(')'); - if (startIt != -1 && endIt != -1) - as.addAttribute(TextAttribute.POSTURE, TextAttribute.POSTURE_OBLIQUE, startIt, endIt); - // Paint multiple lines if required - AttributedCharacterIterator aci = as.getIterator(); - LineBreakMeasurer measurer = new LineBreakMeasurer (aci, g2D.getFontRenderContext()); - float wrappingWidth = m_where[i].width - (2*MARGIN); - float curY = m_where[i].y + MARGIN; - TextLayout layout = null; - int yEnd = m_where[i].y + m_where[i].height; - while (measurer.getPosition() < aci.getEndIndex() && curY < yEnd) - { - layout = measurer.nextLayout(wrappingWidth); - curY += layout.getAscent(); - if (curY < yEnd) - layout.draw(g2D, m_where[i].x + MARGIN, curY); - } - } // assignments - - // Paint Borders - g2D.setPaint(Color.black); - g2D.setStroke(VScheduleTimePanel.getStroke(false)); - g2D.drawLine(1, 1, 1, h-1); // left - g2D.drawLine(1, 1, w-1, 1); // top - // heading line - g2D.drawLine(1, headerHeight, w-1, headerHeight); - // Final lines - g2D.setStroke(VScheduleTimePanel.getStroke(false)); - g2D.drawLine(w-1, 1, w-1, h-1); // right - g2D.drawLine(1, h-1, w-1, h-1); // bottom line - } // paint - - /** - * Return heading for index - * @param index index - * @return heading - */ - private String getHeading (int index) - { - GregorianCalendar cal = new GregorianCalendar(); - if (m_startDate != null) - cal.setTime(m_startDate); - cal.add(java.util.Calendar.DAY_OF_YEAR, index); - // - SimpleDateFormat format = (SimpleDateFormat)DateFormat.getDateInstance - (DateFormat.FULL, Language.getLoginLanguage().getLocale()); - return format.format(cal.getTime()); - } // getHeading - - /** - * Mouse Clicked. Start AssignmentDialog - * @param e event - */ - public void mouseClicked(MouseEvent e) - { - if (e.getClickCount() < 2) - return; - - if (log.isLoggable(Level.FINER)) log.finer(e.toString()); - Rectangle hitRect = new Rectangle (e.getX()-1, e.getY()-1, 3, 3); - - // Day - int dayIndex = e.getX() / m_dayWidth; - if (dayIndex >= m_noDays) - dayIndex = m_noDays-1; - // System.out.println("DayIndex=" + dayIndex + ": " + TimeUtil.addDays(m_startDate, dayIndex)); - - // Time - int timeIndex = m_timePanel.getTimeSlotIndex(e.getY()); - // System.out.println("TimeIndex=" + timeIndex + ": " + m_timePanel.getTimeSlot(timeIndex)); - - // check if there is an existing assignment - for (int i = 0; i < m_slots.length; i++) - { - if (m_where[i].intersects(hitRect)) - { - MAssignmentSlot mas = m_slots[i]; - System.out.println("Existing=" + mas.getInfo()); - if (!mas.isAssignment()) - return; - // - VAssignmentDialog vad = new VAssignmentDialog (AEnv.getFrame(this), - m_slots[i].getMAssignment(), false, m_createNew); - m_infoSchedule.mAssignmentCallback(vad.getMResourceAssignment()); - return; - } - } - if (m_createNew) - { - MResourceAssignment ma = new MResourceAssignment(Env.getCtx(), 0, null); - ma.setS_Resource_ID(m_S_Resource_ID); - ma.setAssignDateFrom(TimeUtil.getDayTime(TimeUtil.addDays(m_startDate, dayIndex), - m_timePanel.getTimeSlot(timeIndex).getStartTime())); - ma.setQty(Env.ONE); - VAssignmentDialog vad = new VAssignmentDialog (AEnv.getFrame(this), ma, false, m_createNew); - m_infoSchedule.mAssignmentCallback(vad.getMResourceAssignment()); - return; - } - } // mouseClicked - - - public void mousePressed(MouseEvent e) - { - } - public void mouseReleased(MouseEvent e) - { - } - public void mouseEntered(MouseEvent e) - { - } - public void mouseExited(MouseEvent e) - { - } - - /** - * Dispose - */ - public void dispose() - { - m_infoSchedule = null; - m_timePanel = null; - m_where = null; - m_slots = null; - this.removeAll(); - } // dispose - -} // VSchedulePanel diff --git a/org.adempiere.ui.swing/src/org/compiere/apps/search/VScheduleTimePanel.java b/org.adempiere.ui.swing/src/org/compiere/apps/search/VScheduleTimePanel.java deleted file mode 100644 index de45de63cf..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/apps/search/VScheduleTimePanel.java +++ /dev/null @@ -1,310 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ -package org.compiere.apps.search; - -import java.awt.BasicStroke; -import java.awt.Color; -import java.awt.Dimension; -import java.awt.Font; -import java.awt.FontMetrics; -import java.awt.Graphics; -import java.awt.Graphics2D; -import java.awt.Rectangle; -import java.awt.Stroke; -import java.awt.font.TextLayout; -import java.sql.Timestamp; -import java.util.logging.Level; - -import javax.swing.JComponent; - -import org.compiere.model.MAssignmentSlot; -import org.compiere.plaf.CompiereUtils; -import org.compiere.util.CLogger; -import org.compiere.util.Env; - -/** - * Schedule Time Panel. - * Manages slot layout - * - * @author Jorg Janke - * @version $Id: VScheduleTimePanel.java,v 1.2 2006/07/30 00:51:27 jjanke Exp $ - */ -public class VScheduleTimePanel extends JComponent -{ - - /** - * - */ - private static final long serialVersionUID = 2498994787352243360L; - - public VScheduleTimePanel() - { - setOpaque(false); - setSize(); - } - - /** Time Slots */ - private MAssignmentSlot[] m_timeSlots = null; - private String[] m_lines = new String [] {""}; - - - /** Line Height */ - public static int LINE_HEIGHT = 35; - /** Heading Space */ - public static int HEADING = 25; - /** Used Font */ - private Font m_font = new Font("serif", Font.PLAIN, 12); - /** Line Width */ - private int m_width = 120; - /** Logger */ - private static CLogger log = CLogger.getCLogger(VScheduleTimePanel.class); - - /** - * Set Time Slots and calculate width - * @param timeSlots time slots - */ - public void setTimeSlots (MAssignmentSlot[] timeSlots) - { - log.fine( "VScheduleTimePanel.setTimeSlots"); - m_timeSlots = timeSlots; - m_lines = new String[m_timeSlots.length]; - // - FontMetrics fm = null; - Graphics g = getGraphics(); - if (g == null) - g = Env.getGraphics(this); - if (g != null) - fm = g.getFontMetrics(m_font); // the "correct" way - else - { - log.log(Level.SEVERE, "No Graphics"); - // fm = getToolkit().getFontMetrics(m_font); - } - m_width = 0; - for (int i = 0; i < m_lines.length; i++) - { - m_lines[i] = m_timeSlots[i].getInfoTimeFrom(); - int width = 0; - if (fm != null) - width = fm.stringWidth(m_lines[i]); - if (width > m_width) - m_width = width; - } - setSize(); - // repaint(); - } // setTimeSlots - - /** - * Calculate & Set Size - */ - private void setSize() - { - // Width - int width = m_width + 10; // slack - if (width <= 10) - width = 120; // default size - - // Height - int height = LINE_HEIGHT; - int lines = m_lines.length; - if (lines < 2) - height *= 10; // default - else - height *= lines; - height += HEADING; - // - Dimension size = new Dimension(width, height); - setPreferredSize(size); - setMinimumSize(size); - setMaximumSize(size); - } // setSize - - /** - * Get the height of the Header - * @return height of the header - */ - public int getHeaderHeight() - { - return HEADING; - } // getHeaderHeight - - /** - * Get the height of a slot - * @return height of a slot - */ - public int getSlotHeight() - { - int height = getPreferredSize().height; - int part = (height-HEADING) / m_lines.length; - return part; - } // getSlotHeight - - /** - * Get the height of a slot - * @return height of a slot - */ - public int getSlotCount() - { - return m_lines.length; - } // getSlotCount - - /** - * Get Y start position of Slot - * @param slot slot index - * @return y start position - */ - public int getSlotYStart (int slot) - { - int part = getSlotHeight(); - int y = HEADING + (slot * part); - return y; - } // getSlotYStart - - /** - * Get Y end position of Slot - * @param slot slot index - * @return y end position - */ - public int getSlotYEnd (int slot) - { - int part = getSlotHeight(); - int y = HEADING + ((slot+1) * part); - return y; - } // getSlotYEnd - - /** - * Return the Time Slot index for the time. - * Based on start time and not including end time - * @param time time (day is ignored) - * @param endTime if true, the end time is included - * @return slot index - */ - public int getTimeSlotIndex (Timestamp time, boolean endTime) - { - // Just one slot - if (m_timeSlots.length <= 1) - return 0; - // search for it - for (int i = 0; i < m_timeSlots.length; i++) - { - if (m_timeSlots[i].inSlot (time, endTime)) - return i; - } - log.log(Level.SEVERE, "VScheduleTimePanel.getSlotIndex - did not find Slot for " + time + " end=" + endTime); - return 0; - } // getTimeSlotIndex - - /** - * Get Time Slot - * @param index time index - * @return Assignment Slot - */ - public MAssignmentSlot getTimeSlot (int index) - { - if (index < 0 || index > m_timeSlots.length) - return null; - return m_timeSlots[index]; - } // getTimeSlot - - /** - * Get Time Slot Index - * @param yPos Y position - * @return Assignment Slot Index - */ - public int getTimeSlotIndex (int yPos) - { - int index = yPos - getHeaderHeight(); - index /= getSlotHeight(); - if (index < 0) - return 0; - if (index >= m_timeSlots.length) - return m_timeSlots.length-1; - return index; - } // getTimeSlotIndex - - /*************************************************************************/ - - /** - * Paint it - * @param g the Graphics object - */ - public void paint (Graphics g) - { - // log.fine( "VScheduleTimePanel.paint", g.getClip()); - Graphics2D g2D = (Graphics2D)g; - g2D.setFont(m_font); - Dimension size = getPreferredSize(); - int w = size.width; - int h = size.height; - - // Paint Background - g2D.setPaint(Color.white); - g2D.fill3DRect(1, 1, w-2, h-2, true); - - // Header Background - Rectangle where = new Rectangle(0, 0, w, getHeaderHeight()); - CompiereUtils.paint3Deffect(g2D, where, false, true); - - // heading - TextLayout layout = null; - // layout = new TextLayout ("Heading", m_font, g2D.getFontRenderContext()); - // float hh = layout.getAscent() + layout.getDescent(); - // layout.draw (g2D, (w - layout.getAdvance())/2, // center - // ((HEADING - hh)/2) + layout.getAscent()); // center - - // horizontal lines & text - g2D.setStroke(getStroke(true)); - for (int i = 0; i < m_lines.length; i++) - { - int yy = getSlotYStart(i); - if (m_lines[i] != null && m_lines[i].length() > 0) - { - layout = new TextLayout (m_lines[i], m_font, g2D.getFontRenderContext()); - g2D.setPaint(Color.blue); - layout.draw (g2D, w - layout.getAdvance() - 3, // right aligned with 2 pt space - yy + layout.getAscent() + layout.getLeading()); // top aligned with leading space - } - // - g2D.setPaint(Color.gray); - g2D.drawLine(2, yy, w-2, yy); // top horiz line - } - - // Paint Borders - g2D.setPaint(Color.black); - g2D.setStroke(getStroke(false)); - g2D.drawLine(1, 1, 1, h-1); // left - g2D.drawLine(w-1, 1, w-1, h-1); // right - g2D.drawLine(1, 1, w-1, 1); // top - g2D.drawLine(1, getHeaderHeight(), w-1, getHeaderHeight()); // header - g2D.drawLine(1, h-1, w-1, h-1); // bottom line - } // paintComponent - - /** - * Get Stroke - * @param slotLine if true return dashed line - * @return Stroke - */ - public static Stroke getStroke (boolean slotLine) - { - if (slotLine) - return new BasicStroke (1.0f, BasicStroke.CAP_BUTT, - BasicStroke.JOIN_MITER, 1.0f, - new float[] {2.0f, 0.5f}, 0.0f); - return new BasicStroke(1.0f); - } // getStroke - -} // VScheduleTimePanel diff --git a/org.adempiere.ui.swing/src/org/compiere/apps/search/package.html b/org.adempiere.ui.swing/src/org/compiere/apps/search/package.html deleted file mode 100644 index cb84430e67..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/apps/search/package.html +++ /dev/null @@ -1,30 +0,0 @@ - - - - - - - -

    Package org.compiere.apps.search

    - -Implement Search, Info Viewer, Lookup and Resource Schedule Viewer - -

    Related Documentation

    - -For overviews, tutorials, examples, guides, and tool documentation, please see: - - - - - - diff --git a/org.adempiere.ui.swing/src/org/compiere/apps/wf/NodeMenu.java b/org.adempiere.ui.swing/src/org/compiere/apps/wf/NodeMenu.java deleted file mode 100644 index ff633a6e8b..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/apps/wf/NodeMenu.java +++ /dev/null @@ -1,113 +0,0 @@ -/** - * - */ -package org.compiere.apps.wf; - -import java.awt.Point; - -import javax.swing.JPopupMenu; - -import org.compiere.util.Env; -import org.compiere.util.Msg; -import org.compiere.wf.MWFNode; -import org.compiere.wf.MWFNodeNext; -import org.compiere.wf.MWorkflow; -import org.netbeans.api.visual.action.PopupMenuProvider; -import org.netbeans.api.visual.widget.Widget; - -/** - * @author hengsin - * - */ -public class NodeMenu implements PopupMenuProvider { - - private WFContentPanel panel; - private MWorkflow m_wf; - - /** - * - */ - public NodeMenu(WFContentPanel panel, MWorkflow wf) { - this.panel = panel; - m_wf = wf; - } - - /* (non-Javadoc) - * @see org.netbeans.api.visual.action.PopupMenuProvider#getPopupMenu(org.netbeans.api.visual.widget.Widget, java.awt.Point) - */ - public JPopupMenu getPopupMenu(Widget w, Point p) { - WFNodeWidget widget = (WFNodeWidget) w; - MWFNode node = widget.getModel(); - JPopupMenu m_LinePopupMenu = new JPopupMenu(node.getName()); - if (node.getAD_Client_ID() == Env.getAD_Client_ID(Env.getCtx())) - { - String title = Msg.getMsg(Env.getCtx(), "DeleteNode") + - ": " + node.getName(); - addMenuItem(m_LinePopupMenu, title, node, -1); - m_LinePopupMenu.addSeparator(); - } - MWFNode[] nodes = m_wf.getNodes(true, Env.getAD_Client_ID(Env.getCtx())); - MWFNodeNext[] lines = node.getTransitions(Env.getAD_Client_ID(Env.getCtx())); - // Add New Line - for (int n = 0; n < nodes.length; n++) - { - MWFNode nn = nodes[n]; - if (nn.getAD_WF_Node_ID() == node.getAD_WF_Node_ID()) - continue; // same - boolean found = false; - for (int i = 0; i < lines.length; i++) - { - MWFNodeNext line = lines[i]; - if (nn.getAD_WF_Node_ID() == line.getAD_WF_Next_ID()) - { - found = true; - break; - } - } - if (!found) - { - String title = Msg.getMsg(Env.getCtx(), "AddLine") - + ": " + node.getName() + " -> " + nn.getName(); - addMenuItem(m_LinePopupMenu, title, node, nn.getAD_WF_Node_ID()); - } - } - m_LinePopupMenu.addSeparator(); - // Delete Lines - for (int i = 0; i < lines.length; i++) - { - MWFNodeNext line = lines[i]; - if (line.getAD_Client_ID() != Env.getAD_Client_ID(Env.getCtx())) - continue; - MWFNode next = MWFNode.get(Env.getCtx(), line.getAD_WF_Next_ID()); - String title = Msg.getMsg(Env.getCtx(), "DeleteLine") - + ": " + node.getName() + " -> " + next.getName(); - addMenuItem(m_LinePopupMenu, title, line); - } - return m_LinePopupMenu; - } - - /** - * Add Menu Item to - add new line to node - * @param menu base menu - * @param title title - */ - private void addMenuItem (JPopupMenu menu, String title, MWFNode node, int AD_WF_NodeTo_ID) - { - WFPopupItem item = new WFPopupItem (title, node, AD_WF_NodeTo_ID); - menu.add(item); - item.addActionListener(panel); - } // addMenuItem - - /** - * Add Menu Item to - delete line - * @param menu base menu - * @param title title - */ - private void addMenuItem (JPopupMenu menu, String title, MWFNodeNext line) - { - WFPopupItem item = new WFPopupItem (title, line); - menu.add(item); - item.addActionListener(panel); - } // addMenuItem - -} diff --git a/org.adempiere.ui.swing/src/org/compiere/apps/wf/SceneMainMenu.java b/org.adempiere.ui.swing/src/org/compiere/apps/wf/SceneMainMenu.java deleted file mode 100644 index be21c54f14..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/apps/wf/SceneMainMenu.java +++ /dev/null @@ -1,44 +0,0 @@ -/** - * - */ -package org.compiere.apps.wf; - -import java.awt.Point; - -import javax.swing.JPopupMenu; - -import org.compiere.swing.CMenuItem; -import org.compiere.util.Env; -import org.compiere.util.Msg; -import org.netbeans.api.visual.action.PopupMenuProvider; -import org.netbeans.api.visual.widget.Widget; - -/** - * @author hengsin - * - */ -public class SceneMainMenu implements PopupMenuProvider { - - private JPopupMenu m_NewPopupMenu = new JPopupMenu(); - private CMenuItem m_NewMenuNode = new CMenuItem(Msg.getMsg(Env.getCtx(), "CreateNewNode")); - - public static final String ADD_NEW_NODE_ACTION = "addNewNodeAction"; - - /** - * @param wfContentPanel - * - */ - public SceneMainMenu(WFContentPanel wfContentPanel) { - m_NewMenuNode.setActionCommand(ADD_NEW_NODE_ACTION); - m_NewMenuNode.addActionListener(wfContentPanel); - m_NewPopupMenu.add(m_NewMenuNode); - } - - /* (non-Javadoc) - * @see org.netbeans.api.visual.action.PopupMenuProvider#getPopupMenu(org.netbeans.api.visual.widget.Widget, java.awt.Point) - */ - public JPopupMenu getPopupMenu(Widget arg0, Point arg1) { - return m_NewPopupMenu; - } - -} diff --git a/org.adempiere.ui.swing/src/org/compiere/apps/wf/WFActivity.java b/org.adempiere.ui.swing/src/org/compiere/apps/wf/WFActivity.java deleted file mode 100644 index a0925a699c..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/apps/wf/WFActivity.java +++ /dev/null @@ -1,804 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ -package org.compiere.apps.wf; - -import java.awt.BorderLayout; -import java.awt.Cursor; -import java.awt.Dimension; -import java.awt.FlowLayout; -import java.awt.GridBagConstraints; -import java.awt.GridBagLayout; -import java.awt.Insets; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.awt.event.MouseAdapter; -import java.awt.event.MouseEvent; -import java.sql.PreparedStatement; -import java.sql.ResultSet; -import java.util.ArrayList; -import java.util.logging.Level; - -import javax.swing.DefaultComboBoxModel; -import javax.swing.event.ChangeEvent; -import javax.swing.event.ListSelectionEvent; -import javax.swing.event.ListSelectionListener; -import javax.swing.event.TableColumnModelEvent; -import javax.swing.event.TableColumnModelListener; -import javax.swing.table.DefaultTableModel; - -import org.compiere.apps.ADialog; -import org.compiere.apps.AEnv; -import org.compiere.apps.AMenu; -import org.compiere.apps.AWindow; -import org.compiere.apps.ConfirmPanel; -import org.compiere.apps.StatusBar; -import org.compiere.apps.form.FormFrame; -import org.compiere.apps.form.FormPanel; -import org.compiere.grid.ed.VLookup; -import org.compiere.minigrid.IDColumn; -import org.compiere.minigrid.MiniTable; -import org.compiere.model.MColumn; -import org.compiere.model.MQuery; -import org.compiere.model.MRefList; -import org.compiere.model.MRole; -import org.compiere.model.MSysConfig; -import org.compiere.swing.CButton; -import org.compiere.swing.CComboBox; -import org.compiere.swing.CLabel; -import org.compiere.swing.CPanel; -import org.compiere.swing.CScrollPane; -import org.compiere.swing.CTextArea; -import org.compiere.swing.CTextField; -import org.compiere.swing.CTextPane; -import org.compiere.util.CLogger; -import org.compiere.util.DB; -import org.compiere.util.DisplayType; -import org.compiere.util.Env; -import org.compiere.util.Msg; -import org.compiere.util.Trx; -import org.compiere.util.ValueNamePair; -import org.compiere.wf.MWFActivity; -import org.compiere.wf.MWFNode; - -/** - * WorkFlow Activities Panel - * - * @author Jorg Janke - * @version $Id: WFActivity.java,v 1.2 2006/07/30 00:51:28 jjanke Exp $ - * - * @author Teo Sarca, SC ARHIPAC SERVICE SRL - BF [ 1748449 ] - * @author victor.perez@e-evolution.com - *
  • BF[2992649] Issue in Workflow Activities when the records are ordered - *
  • https://sourceforge.net/tracker/?func=detail&aid=2992649&group_id=176962&atid=879332 - * @author Compiere - CarlosRuiz integrate code for table selection on workflow present at GPL version of Compiere 3.2.0 - */ -public class WFActivity extends CPanel - implements FormPanel, ActionListener, ListSelectionListener -{ - /** - * - */ - private static final long serialVersionUID = 3900449055030897013L; - - private static final int MAX_ACTIVITIES_IN_LIST = MSysConfig.getIntValue(MSysConfig.MAX_ACTIVITIES_IN_LIST, 200, Env.getAD_Client_ID(Env.getCtx())); - - /** - * WF Activity - */ - public WFActivity() - { - super (); - // needs to call init - } // WFActivity - - /** - * WF Activity - * @param menu AMenu - */ - public WFActivity (AMenu menu) - { - super (); - log.config(""); - try - { - dynInit(0); - jbInit(); - } - catch(Exception e) - { - log.log(Level.SEVERE, "", e); - } - m_menu = menu; - } // WFActivity - - - /** Window No */ - private int m_WindowNo = 0; - /** FormFrame */ - private FormFrame m_frame = null; - /** Menu */ - private AMenu m_menu = null; - /** Current Activity */ - private MWFActivity m_activity = null; - /** Set Column */ - private MColumn m_column = null; - - private int columnValue = -1; - private int columnNewValue = -1; - - /** Logger */ - private static CLogger log = CLogger.getCLogger(WFActivity.class); - - DefaultTableModel selTableModel = new DefaultTableModel( - new String[]{"ID", - Msg.translate(Env.getCtx(), "Priority"), - Msg.translate(Env.getCtx(), "AD_WF_Node_ID"), - Msg.translate(Env.getCtx(), "Summary")}, 0); - private MiniTable selTable = new MiniTable(); - private CScrollPane selPane = new CScrollPane(selTable); - // - private CPanel centerPanel = new CPanel(); - private GridBagLayout centerLayout = new GridBagLayout(); - private CLabel lNode = new CLabel(Msg.translate(Env.getCtx(), "AD_WF_Node_ID")); - private CTextField fNode = new CTextField(); - private CLabel lDesctiption = new CLabel(Msg.translate(Env.getCtx(), "Description")); - private CTextArea fDescription = new CTextArea(); - private CLabel lHelp = new CLabel(Msg.translate(Env.getCtx(), "Help")); - private CTextArea fHelp = new CTextArea(); - private CLabel lHistory = new CLabel(Msg.translate(Env.getCtx(), "History")); - private CTextPane fHistory = new CTextPane(); - private CLabel lAnswer = new CLabel(Msg.getMsg(Env.getCtx(), "Answer")); - private CPanel answers = new CPanel(new FlowLayout(FlowLayout.LEADING)); - private CTextField fAnswerText = new CTextField(); - private CComboBoxfAnswerList = new CComboBox(); - private CButton fAnswerButton = new CButton(); - // private CButton bPrevious = AEnv.getButton("Previous"); - // private CButton bNext = AEnv.getButton("Next"); - private CButton bZoom = AEnv.getButton("Zoom"); - private CLabel lTextMsg = new CLabel(Msg.getMsg(Env.getCtx(), "Messages")); - private CTextArea fTextMsg = new CTextArea(); - private CButton bOK = ConfirmPanel.createOKButton(true); - private VLookup fForward = null; // dynInit - private CLabel lForward = new CLabel(Msg.getMsg(Env.getCtx(), "Forward")); - private CLabel lOptional = new CLabel("(" + Msg.translate(Env.getCtx(), "Optional") + ")"); - private StatusBar statusBar = new StatusBar(); - - /** - * Dynamic Init. - * Called before Static Init - * @param WindowNo window - */ - private void dynInit(int WindowNo) - { - // Forward - fForward = VLookup.createUser(WindowNo); - loadActivities(); - } // dynInit - - /** - * Static Init. - * Called after Dynamic Init - * @throws Exception - */ - private void jbInit () throws Exception - { - int width = 150; - centerPanel.setLayout (centerLayout); - fNode.setReadWrite (false); - fDescription.setReadWrite (false); - fDescription.setPreferredSize(new Dimension (width,40)); - fHelp.setReadWrite (false); - fHelp.setPreferredSize(new Dimension (width,40)); - fHistory.setReadWrite (false); - fHistory.setPreferredSize(new Dimension (width,80)); - fTextMsg.setPreferredSize(new Dimension (width,40)); - // - // bPrevious.addActionListener(this); - // bNext.addActionListener(this); - selTable.setModel(selTableModel); - selTable.setColumnClass(0,IDColumn.class,false, " "); // 0-ID - selTable.setColumnClass(1, Integer.class, true); // 1-Priority - selTable.setColumnClass(2, String.class, true); // 2-AD_WF_Node_ID - selTable.setColumnClass(3, String.class, true); // 3-Summary - selTable.getSelectionModel().addListSelectionListener(this); - - // Listen the Column Move Event - selTable.getColumnModel().addColumnModelListener(new TableColumnModelListener() - { - - public void columnMoved(TableColumnModelEvent e) - { - if (columnValue == -1) - columnValue = e.getFromIndex(); - - columnNewValue = e.getToIndex(); - } - - @Override - public void columnAdded(TableColumnModelEvent e) { - } - - @Override - public void columnMarginChanged(ChangeEvent e) { - } - - @Override - public void columnRemoved(TableColumnModelEvent e) { - } - @Override - public void columnSelectionChanged(ListSelectionEvent e) { - } - }); - - //Listen the mouse released Moved - selTable.getTableHeader().addMouseListener(new MouseAdapter() - { - @Override - public void mouseReleased(MouseEvent e) - { - if (columnValue != -1 && (columnValue == 0 || columnNewValue == 0)) - selTable.moveColumn(columnNewValue, columnValue); - - columnValue = -1; - columnNewValue = -1; - } - }); - - bZoom.addActionListener(this); - bOK.addActionListener(this); - // - this.setLayout(new BorderLayout()); - this.add (centerPanel, BorderLayout.CENTER); - this.add (statusBar, BorderLayout.SOUTH); - // - // answers.setOpaque(false); - answers.add(fAnswerText); - answers.add(fAnswerList); - answers.add(fAnswerButton); - fAnswerButton.addActionListener(this); - // - int row = 0; - selPane.setPreferredSize(new Dimension(width, 60)); - selPane.setMinimumSize(new Dimension(100, 60)); - centerPanel.add (selPane, new GridBagConstraints (0, row, 4, 1, 0.3, 0.3, - GridBagConstraints.NORTHWEST, GridBagConstraints.BOTH, - new Insets (5, 10, 5, 10), 0, 0)); - - centerPanel.add (lNode, new GridBagConstraints (0, ++row, 1, 1, 0.0, 0.0, - GridBagConstraints.NORTHEAST, GridBagConstraints.NONE, - new Insets (5, 10, 5, 5), 0, 0)); - centerPanel.add (fNode, new GridBagConstraints (1, row, 3, 2, 0.5, 0.0, - GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, - new Insets (5, 0, 5, 10), 0, 0)); - - centerPanel.add (lDesctiption, new GridBagConstraints (0, ++row, 1, 1, 0.0, 0.0, - GridBagConstraints.NORTHEAST, GridBagConstraints.NONE, - new Insets (5, 10, 5, 5), 0, 0)); - centerPanel.add (fDescription, new GridBagConstraints (1, row, 3, 1, 0.0, 0.0, - GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, - new Insets (5, 0, 5, 10), 0, 0)); - - centerPanel.add (lHelp, new GridBagConstraints (0, ++row, 1, 1, 0.0, 0.0, - GridBagConstraints.NORTHEAST, GridBagConstraints.NONE, - new Insets (2, 10, 5, 5), 0, 0)); - centerPanel.add (fHelp, new GridBagConstraints (1, row, 3, 1, 0.0, 0.0, - GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, - new Insets (2, 0, 5, 10), 0, 0)); - - centerPanel.add (lHistory, new GridBagConstraints (0, ++row, 1, 1, 0.0, 0.0, - GridBagConstraints.NORTHEAST, GridBagConstraints.NONE, - new Insets (5, 10, 5, 5), 0, 0)); - centerPanel.add (fHistory, new GridBagConstraints (1, row, 3, 1, 0.5, 0.5, - GridBagConstraints.NORTHWEST, GridBagConstraints.BOTH, - new Insets (5, 0, 5, 10), 0, 0)); - - centerPanel.add (lAnswer, new GridBagConstraints (0, ++row, 1, 1, 0.0, 0.0, - GridBagConstraints.EAST, GridBagConstraints.NONE, - new Insets (10, 10, 5, 5), 0, 0)); - centerPanel.add (answers, new GridBagConstraints (1, row, 2, 1, 0.0, 0.0, - GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, - new Insets (10, 0, 5, 5), 0, 0)); - centerPanel.add (bZoom, new GridBagConstraints (3, row, 1, 1, 0.0, 0.0, - GridBagConstraints.EAST, GridBagConstraints.NONE, - new Insets (10, 0, 10, 10), 0, 0)); - - centerPanel.add (lTextMsg, new GridBagConstraints (0, ++row, 1, 1, 0.0, 0.0, - GridBagConstraints.NORTHEAST, GridBagConstraints.NONE, - new Insets (5, 10, 5, 5), 0, 0)); - centerPanel.add (fTextMsg, new GridBagConstraints (1, row, 3, 1, 0.5, 0.0, - GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, - new Insets (5, 0, 5, 10), 0, 0)); - - centerPanel.add (lForward, new GridBagConstraints (0, ++row, 1, 1, 0.0, 0.0, - GridBagConstraints.EAST, GridBagConstraints.NONE, - new Insets (10, 10, 5, 5), 0, 0)); - centerPanel.add (fForward, new GridBagConstraints (1, row, 1, 1, 0.0, 0.0, - GridBagConstraints.WEST, GridBagConstraints.NONE, - new Insets (10, 0, 5, 0), 0, 0)); - centerPanel.add (lOptional, new GridBagConstraints (2, row, 1, 1, 0.0, 0.0, - GridBagConstraints.WEST, GridBagConstraints.NONE, - new Insets (10, 5, 5, 5), 0, 0)); - centerPanel.add (bOK, new GridBagConstraints (3, row, 1, 1, 0.0, 0.0, - GridBagConstraints.EAST, GridBagConstraints.NONE, - new Insets (10, 5, 5, 10), 0, 0)); - } // jbInit - - /** - * Initialize Panel for FormPanel - * @param WindowNo window - * @param frame frame - * @see org.compiere.apps.form.FormPanel#init(int, FormFrame) - */ - public void init (int WindowNo, FormFrame frame) - { - m_WindowNo = WindowNo; - m_frame = frame; - // - log.info(""); - try - { - dynInit(WindowNo); - jbInit(); - // - // this.setPreferredSize(new Dimension (400,400)); - frame.getContentPane().add(this, BorderLayout.CENTER); - } - catch(Exception e) - { - log.log(Level.SEVERE, "", e); - } - } // init - - /** - * Dispose - * @see org.compiere.apps.form.FormPanel#dispose() - */ - public void dispose() - { - if (m_frame != null) - m_frame.dispose(); - m_frame = null; - } // dispose - - /** - * Get active activities count - * @return int - */ - public int getActivitiesCount() - { - int count = 0; - - String sql = "SELECT COUNT(*) FROM AD_WF_Activity a " - + "WHERE " + getWhereActivities(); - int AD_User_ID = Env.getAD_User_ID(Env.getCtx()); - int AD_Client_ID = Env.getAD_Client_ID(Env.getCtx()); - MRole role = MRole.get(Env.getCtx(), Env.getAD_Role_ID(Env.getCtx())); - sql = role.addAccessSQL(sql, "a", true, false); - PreparedStatement pstmt = null; - ResultSet rs = null; - try - { - pstmt = DB.prepareStatement (sql, null); - pstmt.setInt (1, AD_User_ID); - pstmt.setInt (2, AD_User_ID); - pstmt.setInt (3, AD_User_ID); - pstmt.setInt (4, AD_User_ID); - pstmt.setInt (5, AD_Client_ID); - rs = pstmt.executeQuery (); - if (rs.next ()) { - count = rs.getInt(1); - } - } - catch (Exception e) - { - log.log(Level.SEVERE, sql, e); - } - finally - { - DB.close(rs, pstmt); - rs = null; pstmt = null; - } - - return count; - - } - - /** - * Load Activities - * @return int - */ - public int loadActivities() - { - while (selTableModel.getRowCount() > 0) - selTableModel.removeRow(0); - long start = System.currentTimeMillis(); - ArrayList list = new ArrayList(); - String sql = "SELECT * FROM AD_WF_Activity a " - + "WHERE " + getWhereActivities() - + " ORDER BY a.Priority DESC, Created"; - int AD_User_ID = Env.getAD_User_ID(Env.getCtx()); - int AD_Client_ID = Env.getAD_Client_ID(Env.getCtx()); - MRole role = MRole.get(Env.getCtx(), Env.getAD_Role_ID(Env.getCtx())); - sql = role.addAccessSQL(sql, "a", true, false); - PreparedStatement pstmt = null; - ResultSet rs = null; - try - { - pstmt = DB.prepareStatement (sql, null); - pstmt.setInt (1, AD_User_ID); - pstmt.setInt (2, AD_User_ID); - pstmt.setInt (3, AD_User_ID); - pstmt.setInt (4, AD_User_ID); - pstmt.setInt (5, AD_Client_ID); - rs = pstmt.executeQuery (); - while (rs.next ()) - { - MWFActivity activity = new MWFActivity(Env.getCtx(), rs, null); - - Object[] rowData = new Object[4]; - rowData[0] = new IDColumn(activity.get_ID()); - rowData[1] = activity.getPriority(); - rowData[2] = activity.getNodeName(); - rowData[3] = activity.getSummary(); - - selTableModel.addRow(rowData); - if (list.size() > MAX_ACTIVITIES_IN_LIST) - { - log.warning("More than " + MAX_ACTIVITIES_IN_LIST + " Activities - ignored"); - break; - } - } - } - catch (Exception e) - { - log.log(Level.SEVERE, sql, e); - } - finally - { - DB.close(rs, pstmt); - rs = null; pstmt = null; - } - selTable.autoSize(false); - display(null); - - if (log.isLoggable(Level.FINE)) log.fine("#" + selTable.getModel().getRowCount() - + "(" + (System.currentTimeMillis()-start) + "ms)"); - return selTable.getModel().getRowCount(); - } // loadActivities - - private String getWhereActivities() { - final String where = - "a.Processed='N' AND a.WFState='OS' AND (" - // Owner of Activity - + " a.AD_User_ID=?" // #1 - // Invoker (if no invoker = all) - + " OR EXISTS (SELECT * FROM AD_WF_Responsible r WHERE a.AD_WF_Responsible_ID=r.AD_WF_Responsible_ID" - + " AND r.ResponsibleType='H' AND COALESCE(r.AD_User_ID,0)=0 AND COALESCE(r.AD_Role_ID,0)=0 AND (a.AD_User_ID=? OR a.AD_User_ID IS NULL))" // #2 - // Responsible User - + " OR EXISTS (SELECT * FROM AD_WF_Responsible r WHERE a.AD_WF_Responsible_ID=r.AD_WF_Responsible_ID" - + " AND r.ResponsibleType='H' AND r.AD_User_ID=?)" // #3 - // Responsible Role - + " OR EXISTS (SELECT * FROM AD_WF_Responsible r INNER JOIN AD_User_Roles ur ON (r.AD_Role_ID=ur.AD_Role_ID)" - + " WHERE a.AD_WF_Responsible_ID=r.AD_WF_Responsible_ID AND r.ResponsibleType='R' AND ur.AD_User_ID=?)" // #4 - // - + ") AND a.AD_Client_ID=?"; // #5 - return where; - } - - /** - * Display. - * @param index index of table - * Fill Editors - */ - public void display(IDColumn id) - { - if (log.isLoggable(Level.FINE)) log.fine("ID=" + id); - m_activity = resetDisplay(id); - // - if (m_menu != null) - { - m_menu.updateActivities(selTable.getModel().getRowCount()); - } - if (m_activity == null) - return; - - // Display Activity - fNode.setText (m_activity.getNodeName()); - fDescription.setText (m_activity.getNodeDescription()); - fHelp.setText (m_activity.getNodeHelp()); - // - fHistory.setText (m_activity.getHistoryHTML()); - - // User Actions - MWFNode node = m_activity.getNode(); - if (MWFNode.ACTION_UserChoice.equals(node.getAction())) - { - if (m_column == null) - m_column = node.getColumn(); - if (m_column != null && m_column.get_ID() != 0) - { - int dt = m_column.getAD_Reference_ID(); - if (dt == DisplayType.YesNo) - { - ValueNamePair[] values = MRefList.getList(Env.getCtx(), 319, false); // _YesNo - fAnswerList.setModel(new DefaultComboBoxModel(values)); - fAnswerList.setVisible(true); - } - else if (dt == DisplayType.List) - { - ValueNamePair[] values = MRefList.getList(Env.getCtx(), m_column.getAD_Reference_Value_ID(), false); - fAnswerList.setModel(new DefaultComboBoxModel(values)); - fAnswerList.setVisible(true); - } - else // other display types come here - { - fAnswerText.setText (""); - fAnswerText.setVisible(true); - } - } - } - // -- - else if (MWFNode.ACTION_UserWindow.equals(node.getAction()) - || MWFNode.ACTION_UserForm.equals(node.getAction())) - { - fAnswerButton.setText(node.getName()); - fAnswerButton.setToolTipText(node.getDescription()); - fAnswerButton.setVisible(true); - } - /* - else if (MWFNode.ACTION_UserWorkbench.equals(node.getAction())) - log.log(Level.SEVERE, "Workflow Action not implemented yet"); */ - else - log.log(Level.SEVERE, "Unknown Node Action: " + node.getAction()); - - statusBar.setStatusDB(String.valueOf(selTable.getSelectedRow()+1) + "/" + selTable.getRowCount()); - statusBar.setStatusLine(Msg.getMsg(Env.getCtx(), "WFActivities")); - } // display - - /** - * Reset Display - * @param selIndex select index - * @return selected activity - */ - private MWFActivity resetDisplay(IDColumn id) - { - fAnswerText.setVisible(false); - fAnswerList.setVisible(false); - fAnswerButton.setVisible(false); - fTextMsg.setReadWrite(id != null); - bZoom.setEnabled(id != null); - bOK.setEnabled(id != null); - fForward.setValue(null); - fForward.setEnabled(id != null); - // - statusBar.setStatusDB(String.valueOf(selTable.getSelectedRow()+1) + "/" + selTable.getRowCount()); - m_activity = null; - m_column = null; - - if (id != null) - m_activity = new MWFActivity(Env.getCtx(),id.getRecord_ID(),null); - - if (m_activity == null) - { - fNode.setText (""); - fDescription.setText (""); - fHelp.setText (""); - fHistory.setText (""); - statusBar.setStatusDB("0/0"); - statusBar.setStatusLine(Msg.getMsg(Env.getCtx(), "WFNoActivities")); - } - return m_activity; - } // resetDisplay - - - /** - * Selection Listener - * @param e event - */ - public void valueChanged(ListSelectionEvent e) - { - if(selTable.getSelectedRow()>=0) - { - IDColumn id = (IDColumn)selTable.getValueAt(selTable.getSelectedRow(),0); - if (id != null) - display(id); - } - } // valueChanged - - - /** - * Action Listener - * @param e event - * @see java.awt.event.ActionListener#actionPerformed(ActionEvent) - */ - public void actionPerformed (ActionEvent e) - { - this.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); - // - if (e.getSource() == bZoom) - cmd_zoom(); - else if (e.getSource() == bOK) { - bOK.setEnabled(false); - cmd_OK(); - bOK.setEnabled(true); - } - else if (e.getSource() == fAnswerButton) - cmd_button(); - // - this.setCursor(Cursor.getDefaultCursor()); - } // actionPerformed - - - /** - * Zoom - */ - private void cmd_zoom() - { - if (log.isLoggable(Level.CONFIG)) log.config("Activity=" + m_activity); - if (m_activity == null) - return; - AEnv.zoom(m_activity.getAD_Table_ID(), m_activity.getRecord_ID()); - } // cmd_zoom - - /** - * Answer Button - */ - private void cmd_button() - { - if (log.isLoggable(Level.CONFIG)) log.config("Activity=" + m_activity); - if (m_activity == null) - return; - // - MWFNode node = m_activity.getNode(); - if (MWFNode.ACTION_UserWindow.equals(node.getAction())) - { - int AD_Window_ID = node.getAD_Window_ID(); // Explicit Window - String ColumnName = m_activity.getPO().get_TableName() + "_ID"; - int Record_ID = m_activity.getRecord_ID(); - MQuery query = MQuery.getEqualQuery(ColumnName, Record_ID); - boolean IsSOTrx = m_activity.isSOTrx(); - // - if (log.isLoggable(Level.INFO)) log.info("Zoom to AD_Window_ID=" + AD_Window_ID - + " - " + query + " (IsSOTrx=" + IsSOTrx + ")"); - AWindow frame = new AWindow(null); - if (!frame.initWindow(AD_Window_ID, query)) - return; - AEnv.addToWindowManager(frame); - AEnv.showCenterScreen(frame); - frame = null; - } - else if (MWFNode.ACTION_UserForm.equals(node.getAction())) - { - int AD_Form_ID = node.getAD_Form_ID(); - FormFrame ff = new FormFrame(null); - ff.openForm(AD_Form_ID); - ff.pack(); - AEnv.addToWindowManager(ff); - AEnv.showCenterScreen(ff); - } - /* - else if (MWFNode.ACTION_UserWorkbench.equals(node.getAction())) - { - - }*/ - else - log.log(Level.SEVERE, "No User Action:" + node.getAction()); - } // cmd_button - - - /** - * Save - */ - private void cmd_OK() - { - if (log.isLoggable(Level.CONFIG)) log.config("Activity=" + m_activity); - if (m_activity == null) - return; - int AD_User_ID = Env.getAD_User_ID(Env.getCtx()); - String textMsg = fTextMsg.getText(); - // - MWFNode node = m_activity.getNode(); - - Object forward = fForward.getValue(); - - // ensure activity is ran within a transaction - [ 1953628 ] - Trx trx = Trx.get(Trx.createTrxName("FWFA"), true); - m_activity.set_TrxName(trx.getTrxName()); - - if (forward != null) - { - if (log.isLoggable(Level.CONFIG)) log.config("Forward to " + forward); - int fw = ((Integer)forward).intValue(); - if (fw == AD_User_ID || fw == 0) - { - log.log(Level.SEVERE, "Forward User=" + fw); - trx.rollback(); - trx.close(); - return; - } - if (!m_activity.forwardTo(fw, textMsg)) - { - ADialog.error(m_WindowNo, this, "CannotForward"); - trx.rollback(); - trx.close(); - return; - } - } - // User Choice - Answer - else if (MWFNode.ACTION_UserChoice.equals(node.getAction())) - { - if (m_column == null) - m_column = node.getColumn(); - // Do we have an answer? - int dt = m_column.getAD_Reference_ID(); - String value = fAnswerText.getText(); - if (dt == DisplayType.YesNo || dt == DisplayType.List) - { - ValueNamePair pp = (ValueNamePair)fAnswerList.getSelectedItem(); - value = pp.getValue(); - } - if (value == null || value.length() == 0) - { - ADialog.error(m_WindowNo, this, "FillMandatory", Msg.getMsg(Env.getCtx(), "Answer")); - trx.rollback(); - trx.close(); - return; - } - // - if (log.isLoggable(Level.CONFIG)) log.config("Answer=" + value + " - " + textMsg); - try - { - m_activity.setUserChoice(AD_User_ID, value, dt, textMsg); - } - catch (Exception e) - { - log.log(Level.SEVERE, node.getName(), e); - ADialog.error(m_WindowNo, this, "Error", e.toString()); - trx.rollback(); - trx.close(); - return; - } - } - // User Action - else - { - if (log.isLoggable(Level.CONFIG)) log.config("Action=" + node.getAction() + " - " + textMsg); - try - { - // ensure activity is ran within a transaction - m_activity.setUserConfirmation(AD_User_ID, textMsg); - } - catch (Exception e) - { - log.log(Level.SEVERE, node.getName(), e); - ADialog.error(m_WindowNo, this, "Error", e.toString()); - trx.rollback(); - trx.close(); - return; - } - - } - - trx.commit(); - trx.close(); - - // Next - loadActivities(); - } // cmd_OK - - -} // WFActivity diff --git a/org.adempiere.ui.swing/src/org/compiere/apps/wf/WFContentPanel.java b/org.adempiere.ui.swing/src/org/compiere/apps/wf/WFContentPanel.java deleted file mode 100644 index 0c135014f3..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/apps/wf/WFContentPanel.java +++ /dev/null @@ -1,221 +0,0 @@ -package org.compiere.apps.wf; - - -import java.awt.Point; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.util.HashMap; -import java.util.Map; - -import javax.swing.JOptionPane; - -import org.compiere.model.X_AD_Workflow; -import org.compiere.swing.CPanel; -import org.compiere.util.Env; -import org.compiere.util.Msg; -import org.compiere.util.Util; -import org.compiere.wf.MWFNode; -import org.compiere.wf.MWFNodeNext; -import org.compiere.wf.MWorkflow; -import org.netbeans.api.visual.action.ActionFactory; -import org.netbeans.api.visual.action.MoveProvider; -import org.netbeans.api.visual.action.WidgetAction; -import org.netbeans.api.visual.graph.layout.GraphLayout; -import org.netbeans.api.visual.layout.LayoutFactory; -import org.netbeans.api.visual.layout.SceneLayout; -import org.netbeans.api.visual.widget.Widget; - -public class WFContentPanel extends CPanel implements ActionListener, MoveProvider { - - /** - * - */ - private static final long serialVersionUID = 4589292821059374372L; - - private WidgetAction moveAction = ActionFactory.createMoveAction(new WFNodeMoveStrategy(), this); - - private WorkflowGraphScene graphScene = new WorkflowGraphScene(); - private WFPanel m_parent; - private int currentRow = 1; - private int currentColumn = 0; - private int noOfColumns = 4; - - private MWorkflow m_wf; - private boolean readWrite = false; - - public final static int NODE_WIDTH = 180; - public final static int NODE_HEIGHT = 120; - - private Map matrix = null; - - public WFContentPanel (WFPanel parent) { - super(); - m_parent = parent; - matrix = new HashMap(); - } - - public void setReadWrite(boolean readWrite) { - this.readWrite = readWrite; - } - - public void setWorkflow(MWorkflow mWf) { - m_wf = mWf; - } - - public void addNode(MWFNode node) { - int oldRow = currentRow; - int oldColumn = currentColumn; - if (node.getXPosition() > 0 && node.getYPosition() > 0) { - currentColumn = node.getXPosition(); - currentRow = node.getYPosition(); - if (currentColumn > noOfColumns) { - currentColumn = 1; - currentRow ++; - } - } else if (currentColumn == noOfColumns) { - currentColumn = 1; - if (m_wf.getWorkflowType().equals(X_AD_Workflow.WORKFLOWTYPE_General)) { - currentRow++; - } else { - currentRow = currentRow + 2; - } - } else { - if (m_wf.getWorkflowType().equals(X_AD_Workflow.WORKFLOWTYPE_General) || currentColumn == 0) { - currentColumn++; - } else { - currentColumn = currentColumn + 2; - if (currentColumn > noOfColumns) { - currentColumn = 1; - currentRow = currentRow + 2; - } - } - } - Integer[] nodes = matrix.get(currentRow); - if (nodes == null) { - nodes = new Integer[noOfColumns]; - matrix.put(currentRow, nodes); - } else { - //detect collision - while (nodes[currentColumn - 1] != null) { - if (nodes[currentColumn - 1] == node.getAD_WF_Node_ID()) { - break; - } else if (currentColumn == noOfColumns) { - currentColumn = 1; - currentRow ++; - nodes = matrix.get(currentRow); - if (nodes == null) { - nodes = new Integer[noOfColumns]; - matrix.put(currentRow, nodes); - } - } else { - currentColumn ++; - } - } - } - - WFNodeWidget w = (WFNodeWidget) graphScene.addNode(node.getAD_WF_Node_ID()); - w.setColumn(currentColumn); - w.setRow(currentRow); - - nodes[currentColumn - 1] = node.getAD_WF_Node_ID(); - - if (readWrite && node.getAD_Client_ID() == Env.getAD_Client_ID(Env.getCtx())) { - w.getActions().addAction(ActionFactory.createPopupMenuAction(new NodeMenu(this, m_wf))); - w.getActions().addAction(moveAction); - } - - if (currentRow < oldRow) { - currentRow = oldRow; - currentColumn = oldColumn; - } else if ( currentRow == oldRow && currentColumn < oldColumn) { - currentColumn = oldColumn; - } - } - - public void addEdge(MWFNodeNext edge) { - graphScene.addEdge(edge); - graphScene.setEdgeSource(edge, edge.getAD_WF_Node_ID()); - graphScene.setEdgeTarget(edge, edge.getAD_WF_Next_ID()); - } - - public void relayout() { - GraphLayout graphLayout = new WFGraphLayout(); - graphLayout.setAnimated(false); - SceneLayout sceneGraphLayout = LayoutFactory.createSceneGraphLayout (graphScene, graphLayout); - sceneGraphLayout.invokeLayout (); - - this.add(graphScene.createView()); - - if (readWrite) { - graphScene.getActions().addAction(ActionFactory.createPopupMenuAction(new SceneMainMenu(this))); - } - } - - @Override - public void removeAll() { - super.removeAll(); - graphScene = new WorkflowGraphScene(); - currentColumn = 0; - currentRow = 1; - matrix = new HashMap(); - } - - public WorkflowGraphScene getGraphScene() { - return graphScene; - } - - private void createNewNode() { - String nameLabel = Util.cleanAmp(Msg.getMsg(Env.getCtx(), "Name")); - String name = JOptionPane.showInputDialog(this, - nameLabel, // message - Msg.getMsg(Env.getCtx(), "CreateNewNode"), // title - JOptionPane.QUESTION_MESSAGE); - if (name != null && name.length() > 0) - { - int AD_Client_ID = Env.getAD_Client_ID(Env.getCtx()); - MWFNode node = new MWFNode(m_wf, name, name); - node.setClientOrg(AD_Client_ID, 0); - node.saveEx(); - m_parent.load(m_wf.getAD_Workflow_ID(), true); - } - } - - public void actionPerformed(ActionEvent e) { - if (e.getActionCommand().equals(SceneMainMenu.ADD_NEW_NODE_ACTION)) - { - createNewNode(); - } - //Add/Delete Line - else if (e.getSource() instanceof WFPopupItem) - { - WFPopupItem item = (WFPopupItem)e.getSource(); - item.execute(m_parent); - } - } - - public Point getOriginalLocation(Widget widget) { - return widget.getLocation(); - } - - public void movementFinished(Widget widget) { - WFNodeWidget nodeWidget = (WFNodeWidget) widget; - Point location = widget.getPreferredLocation(); - int x = location.x / WFGraphLayout.COLUMN_WIDTH + 1; - int y = location.y / WFGraphLayout.ROW_HEIGHT + 1; - Integer[] nodes = matrix.get(y); - if (nodes == null || nodes[x - 1] == null || - nodes[x - 1] == nodeWidget.getModel().getAD_WF_Node_ID()) { - nodeWidget.getModel().setXPosition(x); - nodeWidget.getModel().setYPosition(y); - nodeWidget.getModel().saveEx(); - } - m_parent.load(m_wf.getAD_Workflow_ID(), true); - } - - public void movementStarted(Widget widget) { - } - - public void setNewLocation(Widget widget, Point point) { - widget.setPreferredLocation(point); - } -} diff --git a/org.adempiere.ui.swing/src/org/compiere/apps/wf/WFNodeMoveStrategy.java b/org.adempiere.ui.swing/src/org/compiere/apps/wf/WFNodeMoveStrategy.java deleted file mode 100644 index 9679a2e872..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/apps/wf/WFNodeMoveStrategy.java +++ /dev/null @@ -1,15 +0,0 @@ -package org.compiere.apps.wf; - -import java.awt.Point; - -import org.netbeans.api.visual.action.MoveStrategy; -import org.netbeans.api.visual.widget.Widget; - -public class WFNodeMoveStrategy implements MoveStrategy { - - public Point locationSuggested(Widget widget, Point originalLocation, Point suggestedLocation) { - return new Point (suggestedLocation.x - suggestedLocation.x % WFGraphLayout.COLUMN_WIDTH , - suggestedLocation.y - suggestedLocation.y % WFGraphLayout.ROW_HEIGHT); - } - -} diff --git a/org.adempiere.ui.swing/src/org/compiere/apps/wf/WFPanel.java b/org.adempiere.ui.swing/src/org/compiere/apps/wf/WFPanel.java deleted file mode 100644 index 737c2b6974..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/apps/wf/WFPanel.java +++ /dev/null @@ -1,577 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ -package org.compiere.apps.wf; - -import java.awt.BorderLayout; -import java.awt.Color; -import java.awt.Component; -import java.awt.Cursor; -import java.awt.Dimension; -import java.awt.FlowLayout; -import java.awt.Insets; -import java.awt.Point; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.util.ArrayList; -import java.util.List; -import java.util.Properties; -import java.util.Set; -import java.util.logging.Level; - -import javax.swing.JButton; -import javax.swing.JFrame; -import javax.swing.JScrollPane; -import javax.swing.JTextPane; - -import org.adempiere.exceptions.AdempiereException; -import org.adempiere.plaf.AdempierePLAF; -import org.compiere.apps.AEnv; -import org.compiere.apps.AMenu; -import org.compiere.apps.AMenuStartItem; -import org.compiere.apps.AWindow; -import org.compiere.apps.form.FormFrame; -import org.compiere.apps.form.FormPanel; -import org.compiere.model.MQuery; -import org.compiere.model.MRole; -import org.compiere.model.MTable; -import org.compiere.plaf.CompiereColor; -import org.compiere.swing.CButton; -import org.compiere.swing.CComboBox; -import org.compiere.swing.CPanel; -import org.compiere.util.CLogger; -import org.compiere.util.DB; -import org.compiere.util.Env; -import org.compiere.util.KeyNamePair; -import org.compiere.util.Msg; -import org.compiere.util.Util; -import org.compiere.wf.MWFNode; -import org.compiere.wf.MWFNodeNext; -import org.compiere.wf.MWorkflow; -import org.netbeans.api.visual.model.ObjectSceneEvent; -import org.netbeans.api.visual.model.ObjectSceneEventType; -import org.netbeans.api.visual.model.ObjectSceneListener; -import org.netbeans.api.visual.model.ObjectState; -import org.netbeans.api.visual.widget.Widget; - -/** - * WorkFlow Panel - * - * @author Jorg Janke - * @version $Id: WFPanel.java,v 1.2 2006/07/30 00:51:28 jjanke Exp $ - * - * @author Teo Sarca, www.arhipac.ro - *
  • FR [ 2048081 ] Mf. Workflow editor should display only mf. workflows - */ -public class WFPanel extends CPanel - implements ActionListener, FormPanel, ObjectSceneListener -{ - /** - * - */ - private static final long serialVersionUID = 4478193785606693055L; - - - /** - * Create Workflow Panel. - * FormPanel - */ - public WFPanel() - { - this (null, null, -1); - } // WFPanel - - /** - * Create Workflow Panel - * @param menu menu - */ - public WFPanel (AMenu menu) - { - this(menu, null, -1); - } - - /** - * Create Workflow Panel - * @param menu menu - */ - public WFPanel (AMenu menu, String wfWhereClause, int wfWindow_ID) - { - m_menu = menu; - m_readWrite = (menu == null); - m_WF_whereClause = wfWhereClause; - m_WF_Window_ID = wfWindow_ID; - if (log.isLoggable(Level.INFO)) log.info("RW=" + m_readWrite); - try - { - jbInit(); - } - catch(Exception e) - { - log.log(Level.SEVERE, "WFPanel", e); - } - } // WFPanel - - /** Menu Link */ - private AMenu m_menu = null; - /** Window No */ - @SuppressWarnings("unused") - private int m_WindowNo = 0; - /** FormFrame */ - private FormFrame m_frame; - - - /** Workflow Model */ - private MWorkflow m_wf = null; - /** Context */ - private Properties m_ctx = Env.getCtx(); - /** Active Node */ - private MWFNode m_activeNode = null; - /** ReadWrite Mode (see WFNode) */ - private boolean m_readWrite = false; - - /** Workflows List Where Clause */ - private String m_WF_whereClause = null; - /** Workflow Window ID */ - private int m_WF_Window_ID = -1; - - /** Logger */ - private static CLogger log = CLogger.getCLogger(WFPanel.class); - - // UI - private BorderLayout mainLayout = new BorderLayout(); - private CPanel southPanel = new CPanel(); - private WFContentPanel centerPanel = new WFContentPanel(this); - private BorderLayout southLayout = new BorderLayout(); - private JScrollPane infoScrollPane = new JScrollPane(); - private JTextPane infoTextPane = new JTextPane(); - private CPanel buttonPanel = new CPanel(); - private JButton wfStart = new JButton(); - private JButton wfBack = new JButton(); - private JButton wfNext = new JButton(); - private JButton wfEnd = new JButton(); - // - private CPanel loadPanel = new CPanel(new FlowLayout(FlowLayout.LEADING)); - private CComboBoxworkflow = new CComboBox(); - private CButton bResetLayout = AEnv.getButton("Reset"); - private CButton bSaveLayout = AEnv.getButton ("Save"); - private CButton bZoom = AEnv.getButton("Zoom"); - private CButton bIgnore = AEnv.getButton("Ignore"); - private WFNodeWidget selectedWidget; - - - /** - * Static Init - *
    -	 * 		centerScrollPane
    -	 * 			centerPanel
    -	 * 		south Panel
    -	 * 			infoScrollPane
    -	 * 			buttonPanel
    -	 * 	
    - * @throws Exception - */ - private void jbInit() throws Exception - { - this.setLayout(mainLayout); - CompiereColor.setBackground(this); - southPanel.setLayout(southLayout); - // Center - this.add(new JScrollPane(centerPanel), BorderLayout.CENTER); - // Info - infoScrollPane.getViewport().add(infoTextPane, null); - infoScrollPane.setPreferredSize(new Dimension(200, 140)); - infoTextPane.setBackground(AdempierePLAF.getFieldBackground_Inactive()); - infoTextPane.setEditable(false); - infoTextPane.setRequestFocusEnabled(false); - infoTextPane.setContentType("text/html"); - // South - this.add(southPanel, BorderLayout.SOUTH); - southPanel.add(infoScrollPane, BorderLayout.CENTER); - southPanel.add(buttonPanel, BorderLayout.SOUTH); - // - wfStart.setIcon(Env.getImageIcon("wfStart24.gif")); - wfStart.setMargin(new Insets(0, 10, 0, 10)); - wfStart.setRequestFocusEnabled(false); - wfStart.addActionListener(this); - wfStart.setToolTipText(Msg.getMsg(m_ctx, "WFStart")); - wfBack.setIcon(Env.getImageIcon("wfBack24.gif")); - wfBack.setMargin(new Insets(0, 15, 0, 15)); - wfBack.setRequestFocusEnabled(false); - wfBack.addActionListener(this); - wfBack.setToolTipText(Msg.getMsg(m_ctx, "WFPrevious")); - wfNext.setIcon(Env.getImageIcon("wfNext24.gif")); - wfNext.setMargin(new Insets(0, 15, 0, 15)); - wfNext.setRequestFocusEnabled(false); - wfNext.addActionListener(this); - wfNext.setToolTipText(Msg.getMsg(m_ctx, "WFNext")); - wfEnd.setIcon(Env.getImageIcon("wfEnd24.gif")); - wfEnd.setMargin(new Insets(0, 10, 0, 10)); - wfEnd.setRequestFocusEnabled(false); - wfEnd.addActionListener(this); - wfEnd.setToolTipText(Msg.getMsg(m_ctx, "WFExit")); - buttonPanel.add(wfStart, null); - buttonPanel.add(wfBack, null); - buttonPanel.add(wfNext, null); - buttonPanel.add(wfEnd, null); - } // jbInit - - /** - * Initialize Panel for FormPanel - * @param WindowNo window - * @param frame frame - * @see org.compiere.apps.form.FormPanel#init(int, FormFrame) - */ - public void init (int WindowNo, FormFrame frame) - { - m_WindowNo = WindowNo; - m_frame = frame; - // - if (log.isLoggable(Level.FINE)) log.fine("WindowNo=" + WindowNo); - try - { - loadPanel(); - frame.getContentPane().add(loadPanel, BorderLayout.NORTH); - this.setPreferredSize(new Dimension (500,500)); - frame.getContentPane().add(this, BorderLayout.CENTER); - } - catch(Exception e) - { - log.log(Level.SEVERE, "init", e); - } - } // init - - /** - * Dispose - * @see org.compiere.apps.form.FormPanel#dispose() - */ - public void dispose() - { - if (m_frame != null) - m_frame.dispose(); - m_frame = null; - } // dispose - - /** - * Workflow Add & Load Panel - */ - private void loadPanel() - { - String sql = MRole.getDefault().addAccessSQL( - "SELECT AD_Workflow_ID, Name FROM AD_Workflow " - +(!Util.isEmpty(m_WF_whereClause, true) ? " WHERE "+m_WF_whereClause : "") - +" ORDER BY 2", - "AD_Workflow", MRole.SQL_NOTQUALIFIED, MRole.SQL_RO); // all - KeyNamePair[] pp = DB.getKeyNamePairs(sql, true); - // - workflow = new CComboBox(pp); - loadPanel.add(workflow); - workflow.addActionListener(this); - // - loadPanel.add(bIgnore); - bIgnore.addActionListener(this); - loadPanel.add(bResetLayout); - bResetLayout.addActionListener(this); - loadPanel.add(bSaveLayout); - bSaveLayout.addActionListener(this); - loadPanel.add(bZoom); - bZoom.addActionListener(this); - } // loadPanel - - - /************************************************************************** - * Load Workflow & Nodes - * @param readWrite if true, you can move nodes - */ - private void load (boolean readWrite) - { - KeyNamePair pp = (KeyNamePair)workflow.getSelectedItem(); - if (pp == null) - return; - load (pp.getKey(), readWrite); - } // load - - /** - * Load Workflow & Nodes - * @param AD_Workflow_ID ID - * @param readWrite if true nodes can be moved - */ - public void load (int AD_Workflow_ID, boolean readWrite) - { - if (log.isLoggable(Level.FINE)) log.fine("RW=" + readWrite + " - AD_Workflow_ID=" + AD_Workflow_ID); - if (AD_Workflow_ID == 0) - return; - int AD_Client_ID = Env.getAD_Client_ID(Env.getCtx()); - // Get Workflow - m_wf = new MWorkflow (Env.getCtx(), AD_Workflow_ID, null); - centerPanel.removeAll(); - centerPanel.setReadWrite(readWrite); - centerPanel.getGraphScene().addObjectSceneListener(this, ObjectSceneEventType.OBJECT_SELECTION_CHANGED); - centerPanel.setWorkflow(m_wf); - - // Add Nodes - MWFNode[] nodes = m_wf.getNodes(true, AD_Client_ID); - List added = new ArrayList(); - for (int i = 0; i < nodes.length; i++) - { - //boolean rw = readWrite // in editor mode & owned - // && (AD_Client_ID == nodes[i].getAD_Client_ID()); - if (!added.contains(nodes[i].getAD_WF_Node_ID())) - centerPanel.addNode(nodes[i]); - } - - // Add Lines - for (int i = 0; i < nodes.length; i++) - { - MWFNodeNext[] nexts = nodes[i].getTransitions(AD_Client_ID); - for (int j = 0; j < nexts.length; j++) - { - centerPanel.addEdge(nexts[j]); - } - } - - // Info Text - StringBuilder msg = new StringBuilder(""); - msg.append("

    ").append(m_wf.getName(true)).append("

    "); - String s = m_wf.getDescription(true); - if (s != null && s.length() > 0) - msg.append("").append(s).append(""); - s = m_wf.getHelp(true); - if (s != null && s.length() > 0) - msg.append("
    ").append(s); - msg.append(""); - infoTextPane.setText (msg.toString()); - infoTextPane.setCaretPosition(0); - - // Layout - centerPanel.relayout(); - validate(); - } // load - - /** - * Action Listener - * @param e event - * @see java.awt.event.ActionListener#actionPerformed(ActionEvent) - */ - public void actionPerformed (ActionEvent e) - { - if (m_wf == null && e.getSource() != workflow) - return; - - setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); - int AD_Client_ID = Env.getAD_Client_ID(Env.getCtx()); - // Editing - if (e.getSource() == bZoom) - zoom(); - else if (e.getSource() == bIgnore) - load(m_wf.getAD_Workflow_ID(), true); - else if (e.getSource() == workflow) - load(true); - else if (e.getSource() == bSaveLayout) - { - if (m_wf.getAD_Client_ID() == AD_Client_ID) - m_wf.saveEx(); - MWFNode[] nodes = m_wf.getNodes(false, AD_Client_ID); - for (int i = 0; i < nodes.length; i++) - { - if (nodes[i].getAD_Client_ID() == AD_Client_ID) - nodes[i].saveEx(); - } - } - else if (e.getSource() == bResetLayout) - resetLayout(); - // Buttons - else if (e.getSource() == wfStart || m_activeNode == null) - start (m_wf.getAD_WF_Node_ID()); - else if (e.getSource() == wfBack) - start (m_wf.getPrevious (m_activeNode.getAD_WF_Node_ID(), AD_Client_ID)); - else if (e.getSource() == wfNext) - start (m_wf.getNext (m_activeNode.getAD_WF_Node_ID(), AD_Client_ID)); - else if (e.getSource() == wfEnd) - start (m_wf.getLast (m_activeNode.getAD_WF_Node_ID(), AD_Client_ID)); - // - setCursor(Cursor.getDefaultCursor()); - } // actionPerformed - - - /************************************************************************** - * Start Node - * @param node node - */ - public void start (MWFNode node) - { - if (log.isLoggable(Level.FINE)) log.fine("Node=" + node); - // Info Text - StringBuilder msg = new StringBuilder(""); - msg.append("

    ").append(node.getName(true)).append("

    "); - String s = node.getDescription(true); - if (s != null && s.length() > 0) - msg.append("").append(s).append(""); - s = node.getHelp(true); - if (s != null && s.length() > 0) - msg.append("
    ").append(s); - msg.append(""); - infoTextPane.setText (msg.toString()); - infoTextPane.setCaretPosition(0); - - // Load Window - if (m_menu != null) - (new AMenuStartItem(node.getAD_WF_Node_ID(), false, node.getName(true), m_menu)).start(); // async load - // - m_activeNode = node; - // - int AD_Client_ID = Env.getAD_Client_ID(Env.getCtx()); - boolean first = m_wf.isFirst(m_activeNode.getAD_WF_Node_ID(), AD_Client_ID); - boolean last = m_wf.isLast(m_activeNode.getAD_WF_Node_ID(), AD_Client_ID); - wfStart.setEnabled(!first); - wfBack.setEnabled(!first); - wfNext.setEnabled(!last); - wfEnd.setEnabled(!last); - } // start - - /** - * Start Node - * @param AD_WF_Node_ID node id - */ - public void start (int AD_WF_Node_ID) - { - if (AD_WF_Node_ID == 0) - return; - // - Object object = centerPanel.getGraphScene().findWidget(AD_WF_Node_ID); - if (object != null) { - WFNodeWidget widget = (WFNodeWidget) object; - widget.setBackground (Color.CYAN); - if (selectedWidget != null) - selectedWidget.setBackground(Color.WHITE); - selectedWidget = widget; - start(widget.getModel()); - } - } // start - - /** - * Reset Layout - */ - public void resetLayout() - { - Point p0 = new Point (0,0); - for (int i = 0; i < centerPanel.getComponentCount(); i++) - { - Component comp = centerPanel.getComponent(i); - comp.setLocation(p0); - } - centerPanel.validate(); - } // resetLayout - - /** - * Zoom to WorkFlow - */ - private void zoom() - { - if (m_WF_Window_ID <= 0) { - m_WF_Window_ID = MTable.get(m_ctx, MWorkflow.Table_ID).getAD_Window_ID(); - } - if (m_WF_Window_ID <= 0) { - throw new AdempiereException("@NotFound@ @AD_Window_ID@"); - } - - MQuery query = null; - if (m_wf != null) - query = MQuery.getEqualQuery("AD_Workflow_ID", m_wf.getAD_Workflow_ID()); - AWindow frame = new AWindow(null); - if (!frame.initWindow (m_WF_Window_ID, query)) - return; - AEnv.addToWindowManager(frame); - AEnv.showCenterScreen(frame); - frame = null; - } // zoom - - /** - * String Representation - * @return info - */ - public String toString() - { - StringBuilder sb = new StringBuilder("WFPanel["); - if (m_wf != null) - sb.append(m_wf.getAD_Workflow_ID()); - sb.append("]"); - return sb.toString(); - } // toString - - /************************************************************************** - * Test - * @param args ignored - */ - public static void main (String[] args) - { - org.compiere.Adempiere.startupEnvironment(true); - JFrame jf = new JFrame ("WF"); - WFPanel pp = new WFPanel(null); - pp.load(101, true); - jf.getContentPane().add (pp); - jf.pack(); - jf.setVisible(true); - } // main - - - //ObjectSceneListener - public void focusChanged(ObjectSceneEvent arg0, Object arg1, Object arg2) { - // TODO Auto-generated method stub - - } - - public void highlightingChanged(ObjectSceneEvent arg0, Set arg1, - Set arg2) { - // TODO Auto-generated method stub - - } - - public void hoverChanged(ObjectSceneEvent arg0, Object arg1, Object arg2) { - // TODO Auto-generated method stub - - } - - public void objectAdded(ObjectSceneEvent arg0, Object arg1) { - // TODO Auto-generated method stub - - } - - public void objectRemoved(ObjectSceneEvent arg0, Object arg1) { - // TODO Auto-generated method stub - - } - - public void objectStateChanged(ObjectSceneEvent event, Object changedObject, - ObjectState previousState, ObjectState newState) { - Widget w = (Widget) changedObject; - System.out.println("location="+w.getLocation()); - } - - public void selectionChanged(ObjectSceneEvent event, Set prevSelection, - Set selection) { - if (selection != null && selection.size() > 0) { - Object selected = selection.toArray()[selection.size() - 1]; - WFNodeWidget widget = (WFNodeWidget) centerPanel.getGraphScene().findWidget(selected); - widget.setBackground (Color.CYAN); - if (selectedWidget != null) - selectedWidget.setBackground(Color.WHITE); - selectedWidget = widget; - start(widget.getModel()); - } - } - - -} // WFPanel diff --git a/org.adempiere.ui.swing/src/org/compiere/apps/wf/WFPopupItem.java b/org.adempiere.ui.swing/src/org/compiere/apps/wf/WFPopupItem.java deleted file mode 100644 index 77d6fab24d..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/apps/wf/WFPopupItem.java +++ /dev/null @@ -1,86 +0,0 @@ -package org.compiere.apps.wf; - -import java.util.logging.Level; - -import javax.swing.JMenuItem; - -import org.compiere.util.CLogger; -import org.compiere.util.Env; -import org.compiere.wf.MWFNode; -import org.compiere.wf.MWFNodeNext; - -public class WFPopupItem extends JMenuItem { - - /** - * - */ - private static final long serialVersionUID = 4634863991042969718L; - private int m_AD_Workflow_ID; - - private static final CLogger log = CLogger.getCLogger(WFPopupItem.class); - - /** - * Add Line Item - * @param title title - * @param node node - * @param AD_WF_NodeTo_ID line to - */ - public WFPopupItem (String title, MWFNode node, int AD_WF_NodeTo_ID) - { - super (title); - m_node = node; - m_AD_WF_NodeTo_ID = AD_WF_NodeTo_ID; - m_AD_Workflow_ID = node.getAD_Workflow_ID(); - } // WFPopupItem - - /** - * Delete Line Item - * @param title title - * @param line line to be deleted - */ - public WFPopupItem (String title, MWFNodeNext line) - { - super (title); - m_line = line; - } // WFPopupItem - - /** The Node */ - private MWFNode m_node; - /** The Line */ - private MWFNodeNext m_line; - /** The Next Node ID */ - private int m_AD_WF_NodeTo_ID; - - /** - * Execute - */ - public void execute(final WFPanel wfp) - { - // Add Line - if (m_node != null && m_AD_WF_NodeTo_ID > 0) - { - int AD_Client_ID = Env.getAD_Client_ID(Env.getCtx()); - MWFNodeNext newLine = new MWFNodeNext(m_node, m_AD_WF_NodeTo_ID); - newLine.setClientOrg(AD_Client_ID, 0); - newLine.saveEx(); - if (log.isLoggable(Level.INFO)) log.info("Add Line to " + m_node + " -> " + newLine); - wfp.load(m_AD_Workflow_ID, true); - } - // Delete Node - else if (m_node != null && m_AD_WF_NodeTo_ID == -1) - { - if (log.isLoggable(Level.INFO)) log.info("Delete Node: " + m_node); - m_node.delete(false); - wfp.load(m_AD_Workflow_ID, true); - } - // Delete Line - else if (m_line != null) - { - if (log.isLoggable(Level.INFO)) log.info("Delete Line: " + m_line); - m_line.delete(false); - wfp.load(m_AD_Workflow_ID, true); - } - else - log.warning("No Action??"); - } // execute -} diff --git a/org.adempiere.ui.swing/src/org/compiere/apps/wf/package.html b/org.adempiere.ui.swing/src/org/compiere/apps/wf/package.html deleted file mode 100644 index ac121c4ab5..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/apps/wf/package.html +++ /dev/null @@ -1,30 +0,0 @@ - - - - - - - -

    Package org.compiere.apps.wf

    - -Classes for Workflow UI - -

    Related Documentation

    - -For overviews, tutorials, examples, guides, and tool documentation, please see: - - - - - - diff --git a/org.adempiere.ui.swing/src/org/compiere/db/CConnectionDialog.java b/org.adempiere.ui.swing/src/org/compiere/db/CConnectionDialog.java deleted file mode 100644 index b6b3b0d842..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/db/CConnectionDialog.java +++ /dev/null @@ -1,429 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ -package org.compiere.db; - -import java.awt.BorderLayout; -import java.awt.Cursor; -import java.awt.FlowLayout; -import java.awt.Frame; -import java.awt.GridBagConstraints; -import java.awt.GridBagLayout; -import java.awt.Insets; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.util.ResourceBundle; -import java.util.logging.Level; - -import javax.swing.Icon; -import javax.swing.JLabel; -import javax.swing.JOptionPane; -import javax.swing.JPasswordField; - -import org.adempiere.plaf.AdempierePLAF; -import org.compiere.swing.CButton; -import org.compiere.swing.CCheckBox; -import org.compiere.swing.CComboBox; -import org.compiere.swing.CDialog; -import org.compiere.swing.CLabel; -import org.compiere.swing.CPanel; -import org.compiere.swing.CTextField; -import org.compiere.util.CLogger; - -/** - * Connection Dialog. - * - * @author Jorg Janke - * @author Marek Mosiewicz - support for RMI over HTTP - * @version $Id: CConnectionDialog.java,v 1.2 2006/07/30 00:55:13 jjanke Exp $ - */ -public class CConnectionDialog extends CDialog implements ActionListener -{ - /** - * - */ - private static final long serialVersionUID = 9132784527503780794L; - - /** - * Connection Dialog using current Connection - */ - public CConnectionDialog() - { - this (null); - } // CConnectionDialog - - /** - * Connection Dialog - * @param cc Adempiere Connection - */ - public CConnectionDialog(CConnection cc) - { - super((Frame)null, true); - try - { - jbInit(); - setConnection (cc); - } - catch(Exception e) - { - log.log(Level.SEVERE, "", e); - } - AdempierePLAF.showCenterScreen(this); - } // CConnection - - /** Resources */ - private static ResourceBundle res = ResourceBundle.getBundle("org.compiere.db.DBRes"); - - /** Default HTTP Port */ - public static final String APPS_PORT_HTTP = "80"; - /** Default SSL Port */ - public static final String APPS_PORT_SSL = "443"; - /** Connection */ - private CConnection m_cc = null; - private CConnection m_ccResult = null; - private boolean m_updating = false; - - /** Logger */ - private static CLogger log = CLogger.getCLogger (CConnectionDialog.class); - - private CPanel mainPanel = new CPanel(); - private BorderLayout mainLayout = new BorderLayout(); - private CPanel centerPanel = new CPanel(); - private CPanel southPanel = new CPanel(); - private CButton bOK = AdempierePLAF.getOKButton(); - private CButton bCancel = AdempierePLAF.getCancelButton(); - private FlowLayout southLayout = new FlowLayout(); - private GridBagLayout centerLayout = new GridBagLayout(); - private CLabel nameLabel = new CLabel(); - private CTextField nameField = new CTextField(); - private CLabel hostLabel = new CLabel(); - private CTextField hostField = new CTextField(); - private CLabel portLabel = new CLabel(); - private CTextField dbPortField = new CTextField(); - private CLabel sidLabel = new CLabel(); - private CTextField sidField = new CTextField(); - private CCheckBox cbFirewall = new CCheckBox(); - private CLabel fwHostLabel = new CLabel(); - private CTextField fwHostField = new CTextField(); - private CLabel fwPortLabel = new CLabel(); - private CTextField fwPortField = new CTextField(); - private CButton bTestDB = new CButton(); - private CLabel dbTypeLabel = new CLabel(); - private CComboBox dbTypeField = new CComboBox(Database.getDatabaseNames()); - private CCheckBox cbBequeath = new CCheckBox(); - private CLabel dbUidLabel = new CLabel(); - private CTextField dbUidField = new CTextField(); - private JPasswordField dbPwdField = new JPasswordField(); - - private boolean isCancel = true; - - /** - * Static Layout - * @throws Exception - */ - private void jbInit() throws Exception - { - this.setTitle(res.getString("CConnectionDialog")); - mainPanel.setLayout(mainLayout); - southPanel.setLayout(southLayout); - southLayout.setAlignment(FlowLayout.RIGHT); - centerPanel.setLayout(centerLayout); - nameLabel.setText(res.getString("Name")); - nameField.setColumns(30); - nameField.setReadWrite(false); - hostLabel.setText(res.getString("DBHost")); - hostField.setColumns(30); - portLabel.setText(res.getString("DBPort")); - dbPortField.setColumns(10); - sidLabel.setText(res.getString("DBName")); - cbFirewall.setToolTipText(""); - cbFirewall.setText(res.getString("ViaFirewall")); - fwHostLabel.setText(res.getString("FWHost")); - fwHostField.setColumns(30); - fwPortLabel.setText(res.getString("FWPort")); - bTestDB.setText(res.getString("TestConnection")); - bTestDB.setHorizontalAlignment(JLabel.LEFT); - dbTypeLabel.setText(res.getString("Type")); - sidField.setColumns(30); - fwPortField.setColumns(10); - cbBequeath.setText(res.getString("BequeathConnection")); - //cbOverwrite.setText(res.getString("Overwrite")); - dbUidLabel.setText(res.getString("DBUidPwd")); - dbUidField.setColumns(10); - this.getContentPane().add(mainPanel, BorderLayout.CENTER); - mainPanel.add(centerPanel, BorderLayout.CENTER); - mainPanel.add(southPanel, BorderLayout.SOUTH); - southPanel.add(bCancel, null); - southPanel.add(bOK, null); - // - centerPanel.add(nameLabel, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(12, 12, 5, 5), 0, 0)); - centerPanel.add(nameField, new GridBagConstraints(1, 0, 2, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(12, 0, 5, 12), 0, 0)); - // DB - centerPanel.add(dbTypeLabel, new GridBagConstraints(0, 4, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 12, 5, 5), 0, 0)); - centerPanel.add(dbTypeField, new GridBagConstraints(1, 4, 1, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 0, 5, 0), 0, 0)); - centerPanel.add(cbBequeath, new GridBagConstraints(2, 4, 1, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 12), 0, 0)); - centerPanel.add(hostLabel, new GridBagConstraints(0, 5, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 12, 5, 5), 0, 0)); - centerPanel.add(hostField, new GridBagConstraints(1, 5, 2, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 0, 5, 12), 0, 0)); - centerPanel.add(portLabel, new GridBagConstraints(0, 6, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 12, 5, 5), 0, 0)); - centerPanel.add(dbPortField, new GridBagConstraints(1, 6, 1, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 5, 0), 0, 0)); - centerPanel.add(sidLabel, new GridBagConstraints(0, 7, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 12, 5, 5), 0, 0)); - centerPanel.add(sidField, new GridBagConstraints(1, 7, 2, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 5, 12), 0, 0)); - centerPanel.add(dbUidLabel, new GridBagConstraints(0, 8, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 12, 5, 5), 0, 0)); - centerPanel.add(dbUidField, new GridBagConstraints(1, 8, 1, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 5, 0), 0, 0)); - centerPanel.add(dbPwdField, new GridBagConstraints(2, 8, 1, 1, 1.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 5, 5, 12), 0, 0)); - centerPanel.add(cbFirewall, new GridBagConstraints(1, 9, 2, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 12), 0, 0)); - centerPanel.add(fwHostLabel, new GridBagConstraints(0, 10, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 12, 5, 5), 0, 0)); - centerPanel.add(fwHostField, new GridBagConstraints(1, 10, 2, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 5, 12), 0, 0)); - centerPanel.add(fwPortLabel, new GridBagConstraints(0, 11, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 12, 5, 5), 0, 0)); - centerPanel.add(fwPortField, new GridBagConstraints(1, 11, 1, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 5, 0), 0, 0)); - centerPanel.add(bTestDB, new GridBagConstraints(1, 12, 1, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 0, 12, 0), 0, 0)); - // - nameField.addActionListener(this); - // - dbTypeField.addActionListener(this); - hostField.addActionListener(this); - dbPortField.addActionListener(this); - sidField.addActionListener(this); - cbBequeath.addActionListener(this); - cbFirewall.addActionListener(this); - fwHostField.addActionListener(this); - fwPortField.addActionListener(this); - bTestDB.addActionListener(this); - bOK.addActionListener(this); - bCancel.addActionListener(this); - } // jbInit - - /** - * Set Busy - lock UI - * @param busy busy - */ - private void setBusy (boolean busy) - { - if (busy) - this.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); - else - this.setCursor(Cursor.getDefaultCursor()); - m_updating = busy; - } // setBusy - - /** - * Set Connection - * @param cc - if null use current connection - */ - public void setConnection (CConnection cc) - { - m_cc = cc; - if (m_cc == null) - { - m_cc = CConnection.get(); - m_cc.setName(); - } - // Should copy values - try { - m_ccResult = (CConnection)m_cc.clone(); - } catch (CloneNotSupportedException e) { - // should not happen - e.printStackTrace(); - } - // - String type = m_cc.getType(); - if (type == null || type.length() == 0) - dbTypeField.setSelectedItem(null); - else - m_cc.setType(m_cc.getType()); // sets defaults - updateInfo(); - } // setConnection - - /** - * Get Connection - * @return CConnection - */ - public CConnection getConnection() - { - return m_ccResult; - } // getConnection; - - /** - * ActionListener - * @param e event - */ - public void actionPerformed(ActionEvent e) - { - if (m_updating) - return; - Object src = e.getSource(); - - if (src == bOK) - { - updateCConnection(); - m_cc.setName(); - m_ccResult = m_cc; - dispose(); - isCancel = false; - return; - } - else if (src == bCancel) - { - m_cc.setName(); - dispose(); - return; - } - else if (src == dbTypeField) - { - if (dbTypeField.getSelectedItem() == null) - return; - } - - - updateCConnection(); - // Database Selection Changed - if (src == dbTypeField) - { - m_cc.setType((String)dbTypeField.getSelectedItem()); - dbPortField.setText(String.valueOf(m_cc.getDbPort())); - cbBequeath.setSelected(m_cc.isBequeath()); - fwPortField.setText(String.valueOf(m_cc.getFwPort())); - } - // - else if (src == bTestDB) - cmd_testDB(); - - // Name - if (src == nameField) - m_cc.setName(nameField.getText()); - - updateInfo(); - } // actionPerformed - - private void updateCConnection() { - m_cc.setAppsHost("localhost"); - // - m_cc.setType((String)dbTypeField.getSelectedItem()); - m_cc.setDbHost(hostField.getText()); - m_cc.setDbPort(dbPortField.getText()); - m_cc.setDbName(sidField.getText()); - m_cc.setDbUid(dbUidField.getText()); - m_cc.setDbPwd(String.valueOf(dbPwdField.getPassword())); - m_cc.setBequeath(cbBequeath.isSelected()); - m_cc.setViaFirewall(cbFirewall.isSelected()); - m_cc.setFwHost(fwHostField.getText()); - m_cc.setFwPort(fwPortField.getText()); - } - - /** - * Update Fields from Connection - */ - private void updateInfo() - { - m_updating = true; - nameField.setText(m_cc.getName()); - // - boolean rw = true; - // - dbTypeLabel.setReadWrite(rw); - dbTypeField.setReadWrite(rw); - dbTypeField.setSelectedItem(m_cc.getType()); - // - hostLabel.setReadWrite(rw); - hostField.setReadWrite(rw); - hostField.setText(m_cc.getDbHost()); - portLabel.setReadWrite(rw); - dbPortField.setReadWrite(rw); - dbPortField.setText(String.valueOf(m_cc.getDbPort())); - sidLabel.setReadWrite(rw); - sidField.setReadWrite(rw); - sidField.setText(m_cc.getDbName()); - // - dbUidLabel.setReadWrite(rw); - dbUidField.setReadWrite(rw); - dbUidField.setText(m_cc.getDbUid()); - dbPwdField.setEditable(rw); - dbPwdField.setText(m_cc.getDbPwd()); - // - cbBequeath.setReadWrite(rw); - cbBequeath.setEnabled(m_cc.isOracle()); - cbBequeath.setSelected(m_cc.isBequeath()); - // - boolean fwEnabled = rw && m_cc.isViaFirewall() && m_cc.isOracle(); - cbFirewall.setReadWrite(rw && m_cc.isOracle()); - cbFirewall.setSelected(m_cc.isViaFirewall()); - fwHostLabel.setReadWrite(fwEnabled); - fwHostField.setReadWrite(fwEnabled); - fwHostField.setText(m_cc.getFwHost()); - fwPortLabel.setReadWrite(fwEnabled); - fwPortField.setReadWrite(fwEnabled); - fwPortField.setText(String.valueOf(m_cc.getFwPort())); - // - bTestDB.setToolTipText(m_cc.getConnectionURL()); - bTestDB.setIcon(getStatusIcon(m_cc.isDatabaseOK())); - m_updating = false; - } // updateInfo - - /** - * Get Status Icon - ok or not - * @param ok ok - * @return Icon - */ - private Icon getStatusIcon (boolean ok) - { - if (ok) - return bOK.getIcon(); - else - return bCancel.getIcon(); - } // getStatusIcon - - /** - * Test Database connection - */ - private void cmd_testDB() - { - setBusy (true); - Exception e = m_cc.testDatabase(true); - if (e != null) - { - JOptionPane.showMessageDialog(this, - e, // message - res.getString("ConnectionError") + ": " + m_cc.getConnectionURL(), - JOptionPane.ERROR_MESSAGE); - } - setBusy (false); - } // cmd_testDB - - public boolean isCancel() { - return isCancel; - } - -} // CConnectionDialog diff --git a/org.adempiere.ui.swing/src/org/compiere/db/CConnectionEditor.java b/org.adempiere.ui.swing/src/org/compiere/db/CConnectionEditor.java deleted file mode 100644 index f9c48710bf..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/db/CConnectionEditor.java +++ /dev/null @@ -1,298 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ -package org.compiere.db; - -import java.awt.BorderLayout; -import java.awt.Color; -import java.awt.Cursor; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.awt.event.MouseAdapter; -import java.awt.event.MouseEvent; - -import javax.swing.ImageIcon; -import javax.swing.JComponent; -import javax.swing.JFrame; -import javax.swing.JLabel; -import javax.swing.JTextField; -import javax.swing.LookAndFeel; - -import org.adempiere.plaf.AdempierePLAF; -import org.compiere.swing.CEditor; -import org.compiere.util.DB; - -/** - * Connection Editor. - * A combo box and a button - * - * @author Jorg Janke - * @version $Id: CConnectionEditor.java,v 1.2 2006/07/30 00:55:13 jjanke Exp $ - */ -public class CConnectionEditor extends JComponent - implements CEditor -{ - /** - * - */ - private static final long serialVersionUID = 259945316129032408L; - - /** - * Connection Editor creating new Connection - */ - public CConnectionEditor() - { - super(); - setName("ConnectionEditor"); - CConnectionEditor_MouseListener ml = new CConnectionEditor_MouseListener(); - // Layout - m_text.setEditable(false); - m_text.setBorder(null); - m_text.addMouseListener(ml); - m_db.setIcon(new ImageIcon(getClass().getResource("Database16.gif"))); - m_db.setFocusable(false); - m_db.setBorder(null); - m_db.setOpaque(true); - m_db.addMouseListener(ml); - LookAndFeel.installBorder(this, "TextField.border"); - // - setLayout(new BorderLayout(0,0)); - add(m_text, BorderLayout.CENTER); - add(m_db, BorderLayout.EAST); - } // CConnectionEditor - - /** Text Element */ - private JTextField m_text = new JTextField(10); - /** DB Button Element */ - private JLabel m_db = new JLabel (); - /** The Value */ - private CConnection m_value = null; - /** ReadWrite */ - private boolean m_rw = true; - /** Mandatory */ - private boolean m_mandatory = false; - - /** - * Enable Editor - * @param rw true, if you can enter/select data - */ - public void setReadWrite (boolean rw) - { - m_rw = rw; - setBackground(false); - } // setReadWrite - - /** - * Is it possible to edit - * @return true, if editable - */ - public boolean isReadWrite() - { - return m_rw; - } // isReadWrite - - /** - * Set Editor Mandatory - * @param mandatory true, if you have to enter data - */ - public void setMandatory (boolean mandatory) - { - m_mandatory = mandatory; - } // setMandatory - - /** - * Is Field mandatory - * @return true, if mandatory - */ - public boolean isMandatory() - { - return m_mandatory; - } // isMandatory - - /** - * Set Background based on editable / mandatory / error - * @param error if true, set background to error color, otherwise mandatory/editable - */ - public void setBackground (boolean error) - { - Color c = null; - if (error) - c = AdempierePLAF.getFieldBackground_Error(); - else if (!m_rw) - c = AdempierePLAF.getFieldBackground_Inactive(); - else if (m_mandatory) - c = AdempierePLAF.getFieldBackground_Mandatory(); - else - c = AdempierePLAF.getFieldBackground_Normal(); - setBackground(c); - } // setBackground - - /** - * Set Background color - * @param color - */ - public void setBackground (Color color) - { - m_text.setBackground(color); - m_db.setBackground(color); - } // setBackground - - /** - * Set Visible - * @param visible true if field is to be shown - */ - public void setVisible (boolean visible) - { - super.setVisible(visible); - } - - /** - * Set Editor to value - * @param value value of the editor - */ - public void setValue (Object value) - { - if (value != null && value instanceof CConnection) - m_value = (CConnection)value; - setDisplay(); - } // setValue - - /** - * Return Editor value - * @return current value - */ - public Object getValue() - { - return m_value; - } // getValue - - /** - * Return Display Value - * @return displayed String value - */ - public String getDisplay() - { - if (m_value == null) - return ""; - return m_value.getName(); - } // getDisplay - - /** - * Update Display with Connection info - */ - public void setDisplay() - { - m_text.setText(getDisplay()); - if (m_value == null) - return; - // Text - if (m_value.isDatabaseOK()) - { - m_text.setForeground(AdempierePLAF.getTextColor_OK()); - setBackground(false); - if (!m_value.isDatabaseOK()) - m_db.setBackground(AdempierePLAF.getFieldBackground_Error()); - } - else - { - m_text.setForeground(AdempierePLAF.getTextColor_Issue()); - setBackground(true); - } - } // setDisplay - - - /************************************************************************** - * Remove Action Listener - * @param l - */ - public synchronized void removeActionListener(ActionListener l) - { - listenerList.remove(ActionListener.class, l); - } // removeActionListener - - /** - * Add Action Listener - * @param l - */ - public synchronized void addActionListener(ActionListener l) - { - listenerList.add(ActionListener.class, l); - } // addActionListener - - /** - * Fire Action Performed - */ - private void fireActionPerformed() - { - ActionEvent e = null; - ActionListener[] listeners = listenerList.getListeners(ActionListener.class); - for (int i = 0; i < listeners.length; i++) - { - if (e == null) - e = new ActionEvent(this, ActionEvent.ACTION_PERFORMED, "actionPerformed"); - listeners[i].actionPerformed(e); - } - } // fireActionPerformed - - - /************************************************************************** - * Test Method - * @param args - */ - public static void main(String[] args) - { - // System.out.println("CConnectionEditor"); - JFrame frame = new JFrame("CConnectionEditor"); - frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); - frame.getRootPane().getContentPane().add(new CConnectionEditor()); - AdempierePLAF.showCenterScreen(frame); - } // main - - - /** - * MouseListener - */ - public class CConnectionEditor_MouseListener extends MouseAdapter - { - /** - * Mouse Clicked - Open Dialog - * @param e - */ - public void mouseClicked(MouseEvent e) - { - if (!isEnabled() || !m_rw || m_active) - return; - m_active = true; - setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); - // - CConnectionDialog cd = new CConnectionDialog(m_value); - setValue(cd.getConnection()); - if (!cd.isCancel()) - fireActionPerformed(); - else { - DB.closeTarget(); - DB.setDBTarget(m_value); - } - - // - setCursor(Cursor.getDefaultCursor()); - m_active = false; - } // mouseClicked - - private boolean m_active = false; - } // CConnectionExitor_MouseListener - -} // CConnectionEditor diff --git a/org.adempiere.ui.swing/src/org/compiere/dbPort/ConvertDialog.java b/org.adempiere.ui.swing/src/org/compiere/dbPort/ConvertDialog.java deleted file mode 100644 index 36147e74a8..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/dbPort/ConvertDialog.java +++ /dev/null @@ -1,360 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ -package org.compiere.dbPort; - -import java.awt.BorderLayout; -import java.awt.Color; -import java.awt.Component; -import java.awt.Cursor; -import java.awt.Dimension; -import java.awt.GridBagConstraints; -import java.awt.GridBagLayout; -import java.awt.Insets; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.io.BufferedReader; -import java.io.BufferedWriter; -import java.io.File; -import java.io.FileNotFoundException; -import java.io.FileReader; -import java.io.FileWriter; -import java.io.IOException; -import java.sql.Connection; - -import javax.swing.Box; -import javax.swing.JButton; -import javax.swing.JCheckBox; -import javax.swing.JComboBox; -import javax.swing.JFileChooser; -import javax.swing.JFrame; -import javax.swing.JLabel; -import javax.swing.JPanel; -import javax.swing.JScrollPane; -import javax.swing.JTextArea; - -import org.compiere.Adempiere; -import org.compiere.db.CConnection; -import org.compiere.db.CConnectionEditor; -import org.compiere.db.Database; -import org.compiere.swing.CFrame; - -/** - * Conversion Dialog - * - * @author Jorg Janke - * @version $Id: ConvertDialog.java,v 1.2 2006/07/30 00:55:04 jjanke Exp $ - */ -public class ConvertDialog extends CFrame implements ActionListener -{ - /** - * - */ - private static final long serialVersionUID = 4748833703849693696L; - - /** - * Convert Dialog - */ - public ConvertDialog() - { - try - { - jbInit(); - // - fSelectFile.addItem("D:\\adempiere\\db\\database\\create\\views.sql"); - fSelectFile.addItem("D:\\adempiere\\db\\database\\create\\temporary.sql"); - fSelectFile.addItem("D:\\adempiere\\db\\database\\create\\sequences.sql"); - fSelectFile.addItem("D:\\adempiere\\db\\database\\create\\adempiere.sql"); - // Set up environment - fConnect.setValue(CConnection.get(Database.DB_POSTGRESQL, - "linux", Database.DB_POSTGRESQL_DEFAULT_PORT, "adempiere")); - fTarget.setSelectedItem(Database.DB_POSTGRESQL); - fExecute.setSelected(true); - - cmd_execute(); // set UI - // - pack(); - setVisible(true); - } - catch(Exception e) - { - System.err.println(e); - } - } // ConvertDialog - - private JPanel parameterPanel = new JPanel(); - private GridBagLayout gridBagLayout1 = new GridBagLayout(); - private JLabel lSelectFile = new JLabel(); - private JComboBox fSelectFile = new JComboBox(); - private JButton bSelectFile = new JButton(); - private JCheckBox fExecute = new JCheckBox(); - private JLabel lConnect = new JLabel(); - private CConnectionEditor fConnect = new CConnectionEditor(); - private JButton bStart = new JButton(); - private JScrollPane scrollPane = new JScrollPane(); - private JTextArea infoPane = new JTextArea(); - private Component component1; - private Component component2; - private Component component3; - private Component component4; - private JLabel lTarget = new JLabel(); - private JComboBox fTarget = new JComboBox(Database.getDatabaseNames()); - private JCheckBox fVerbose = new JCheckBox(); - - /** - * Static Layout - * @throws Exception - */ - private void jbInit() throws Exception - { - component1 = Box.createHorizontalStrut(8); - component2 = Box.createHorizontalStrut(8); - component3 = Box.createVerticalStrut(8); - component4 = Box.createVerticalStrut(8); - this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); - this.setTitle("DB Convert Dialog"); - // - parameterPanel.setLayout(gridBagLayout1); - lSelectFile.setText("Select File"); - fSelectFile.setEditable(true); - bSelectFile.setText("add file"); - bSelectFile.addActionListener(this); - fExecute.setText("Execute Directly"); - fExecute.addActionListener(this); - lConnect.setText("Connection"); - bStart.setText("Start"); - bStart.addActionListener(this); - // - infoPane.setBackground(Color.lightGray); - infoPane.setEditable(false); - scrollPane.setPreferredSize(new Dimension(200, 200)); - lTarget.setText("Target"); - fVerbose.setText("Verbose"); - // - this.getContentPane().add(parameterPanel, BorderLayout.NORTH); - parameterPanel.add(lSelectFile, new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 5, 5, 5), 0, 0)); - parameterPanel.add(fSelectFile, new GridBagConstraints(2, 1, 1, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); - parameterPanel.add(bSelectFile, new GridBagConstraints(3, 1, 1, 1, 0.0, 0.0 - ,GridBagConstraints.SOUTHWEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); - parameterPanel.add(fExecute, new GridBagConstraints(2, 2, 1, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); - parameterPanel.add(lConnect, new GridBagConstraints(1, 4, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 5, 5, 5), 0, 0)); - parameterPanel.add(fConnect, new GridBagConstraints(2, 4, 1, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 5, 5, 5), 0, 0)); - parameterPanel.add(bStart, new GridBagConstraints(3, 4, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); - parameterPanel.add(component1, new GridBagConstraints(5, 0, 1, 2, 0.0, 0.0 - ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); - parameterPanel.add(component2, new GridBagConstraints(0, 0, 1, 2, 0.0, 0.0 - ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); - parameterPanel.add(component3, new GridBagConstraints(1, 6, 1, 1, 0.0, 0.0 - ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); - parameterPanel.add(component4, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0 - ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); - parameterPanel.add(lTarget, new GridBagConstraints(1, 3, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); - this.getContentPane().add(scrollPane, BorderLayout.CENTER); - scrollPane.getViewport().add(infoPane, null); - parameterPanel.add(fTarget, new GridBagConstraints(2, 3, 1, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); - parameterPanel.add(fVerbose, new GridBagConstraints(3, 2, 1, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); - } // jbInit - - /** - * Action Listener - * @param e event - */ - public void actionPerformed(ActionEvent e) - { - setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); - // - if (e.getSource() == bStart) - { - bStart.setEnabled(false); - cmd_start(); - bStart.setEnabled(true); - } - else if (e.getSource() == bSelectFile) - cmd_selectFile(); - - else if (e.getSource() == fExecute) - cmd_execute(); - // - setCursor(Cursor.getDefaultCursor()); - } // actionListener - - /** - * Execute toggle - */ - private void cmd_execute() - { - lConnect.setEnabled(fExecute.isSelected()); - fConnect.setReadWrite(fExecute.isSelected()); - lTarget.setEnabled(!fExecute.isSelected()); - fTarget.setEnabled(!fExecute.isSelected()); - } // cmd_execute - - /** - * Select File and add to selection - */ - private void cmd_selectFile() - { - JFileChooser fc = new JFileChooser(); - fc.setMultiSelectionEnabled(false); - if (fc.showOpenDialog(this) != JFileChooser.APPROVE_OPTION) - return; - File f = fc.getSelectedFile(); - if (f == null || !f.isFile()) - return; - String fileName = f.getAbsolutePath(); - // - fSelectFile.addItem(fileName); - fSelectFile.setSelectedItem(fileName); - } // cmd_selectFile - - - /************************************************************************** - * Start Pressed - */ - private void cmd_start() - { - // Open and read File - File file = new File ((String)fSelectFile.getSelectedItem()); - if (!file.exists() || file.isDirectory()) - { - infoPane.append("File does not exist or a directory: " + file + "\n"); - return; - } - infoPane.append("Opening file: " + file + "\n"); - StringBuilder sb = new StringBuilder (1000); - // - try - { - FileReader fr = new FileReader(file); - BufferedReader in = new BufferedReader(fr); - - String line = null; - int lines = 0; - while((line = in.readLine()) != null) - { - lines++; - sb.append(line).append('\n'); - } - in.close(); - fr.close(); - infoPane.append("- Read lines: " + lines + ", size: " + sb.length() + "\n"); - } - catch (FileNotFoundException fnf) - { - infoPane.append("Error: " + fnf + "\n"); - return; - } - catch (IOException ioe) - { - infoPane.append("Error: " + ioe + "\n"); - return; - } - - // Target system - if (fExecute.isSelected()) - { - CConnection cc = (CConnection)fConnect.getValue(); - Convert convert = cc.getDatabase().getConvert(); - convert.setVerbose(fVerbose.isSelected()); - // - Connection conn = cc.getConnection (true, Connection.TRANSACTION_READ_COMMITTED); - convert.execute(sb.toString(), conn); - if (convert.hasError()) - { - StringBuilder sbb = new StringBuilder ("- Error: "); - if (convert.getConversionError() != null) - sbb.append(convert.getConversionError()).append(' '); - if (convert.getException() != null) - { - sbb.append(convert.getException()); - convert.getException().printStackTrace(); - } - sbb.append("\n"); - infoPane.append(sbb.toString()); - } - else - infoPane.append("- OK\n"); - } - else - { - String target = (String)fTarget.getSelectedItem(); - if (Database.DB_ORACLE.equals(target)) - { - infoPane.append("No conversion needed.\n"); - return; - } - Convert convert = null; - try { - convert = Database.getDatabase(target).getConvert(); - } catch (Exception e) { - infoPane.append("Error: " + e + "\n"); - return; - } - // - String cc = convert.convertAll(sb.toString()); - - // Output file name - String fileName = file.getAbsolutePath(); - int pos = fileName.lastIndexOf('.'); - if (pos == -1) - fileName += target; - else - fileName = fileName.substring(0, pos) + target + fileName.substring(pos); - infoPane.append("Writing to: " + fileName + "\n"); - // Write to file - try - { - FileWriter fw = new FileWriter(fileName, false); - BufferedWriter out = new BufferedWriter (fw); - out.write("-- Adempiere dbPort - Convert Oracle to " + target); - out.newLine(); - out.write("-- " + Adempiere.getSummary()); - out.newLine(); - // - out.write(cc); - // - out.close(); - fw.close(); - } - catch (IOException ioe) - { - infoPane.append("Error: " + ioe + "\n"); - } - infoPane.append("- Written: " + cc.length() + "\n"); - } - } // cmd_start - - - /*************************************************************************/ - - /** - * Start Dialog - * @param args ignored - */ - public static void main(String[] args) - { - new ConvertDialog(); - } // main -} // ConvertDialog diff --git a/org.adempiere.ui.swing/src/org/compiere/grid/APanelTab.java b/org.adempiere.ui.swing/src/org/compiere/grid/APanelTab.java deleted file mode 100644 index dc0fc2f2ed..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/grid/APanelTab.java +++ /dev/null @@ -1,53 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ -package org.compiere.grid; - -import org.compiere.apps.APanel; - -/** - * Application Panel Tab Interface. - * Interface for CPanels displayed as a Tab in APanel - * - * @author Jorg Janke - * @version $Id: APanelTab.java,v 1.2 2006/07/30 00:51:28 jjanke Exp $ - */ -public interface APanelTab -{ - /** - * Load Data - * Called when tab is displayed. - */ - public void loadData(); - - /** - * Save Data - * Called when tab is swiched to another tab. - */ - public void saveData(); - - /** - * Register APanel - * @param panel panel - */ - public void registerAPanel (APanel panel); - - /** - * Unregister APanel - */ - public void unregisterPanel (); - -} // APanelTab diff --git a/org.adempiere.ui.swing/src/org/compiere/grid/DefaultCreateFromFactory.java b/org.adempiere.ui.swing/src/org/compiere/grid/DefaultCreateFromFactory.java deleted file mode 100644 index 9afa919b8b..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/grid/DefaultCreateFromFactory.java +++ /dev/null @@ -1,51 +0,0 @@ -/****************************************************************************** - * Copyright (C) 2013 Elaine Tan * - * Copyright (C) 2013 Trek Global - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - *****************************************************************************/ -package org.compiere.grid; - -import org.compiere.model.GridTab; -import org.compiere.model.I_C_BankStatement; -import org.compiere.model.I_C_Invoice; -import org.compiere.model.I_M_InOut; -import org.compiere.model.I_M_PackageMPS; -import org.compiere.model.I_M_RMA; -import org.compiere.model.I_C_DepositBatch; - -/** - * - * @author Elaine - * - */ -public class DefaultCreateFromFactory implements ICreateFromFactory -{ - - @Override - public ICreateFrom create(GridTab mTab) - { - String tableName = mTab.getTableName(); - if (tableName.equals(I_C_Invoice.Table_Name)) - return new VCreateFromInvoiceUI(mTab); - else if (tableName.equals(I_C_BankStatement.Table_Name)) - return new VCreateFromStatementUI(mTab); - else if (tableName.equals(I_M_InOut.Table_Name)) - return new VCreateFromShipmentUI(mTab); - else if (tableName.equals(I_M_RMA.Table_Name)) - return new VCreateFromRMAUI(mTab); - else if (tableName.equals(I_M_PackageMPS.Table_Name)) - return new VCreateFromPackageShipmentUI(mTab); - else if (tableName.equals(I_C_DepositBatch.Table_Name)) - return new VCreateFromDepositBatchUI(mTab); - return null; - } - -} diff --git a/org.adempiere.ui.swing/src/org/compiere/grid/DefaultPaymentFormFactory.java b/org.adempiere.ui.swing/src/org/compiere/grid/DefaultPaymentFormFactory.java deleted file mode 100644 index 02b0283a5e..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/grid/DefaultPaymentFormFactory.java +++ /dev/null @@ -1,44 +0,0 @@ -/****************************************************************************** - * Copyright (C) 2012 Elaine Tan * - * Copyright (C) 2012 Trek Global - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - *****************************************************************************/ -package org.compiere.grid; - -import org.compiere.model.GridTab; -import org.compiere.model.MInvoice; - -/** - * - * @author Elaine - * - */ -public class DefaultPaymentFormFactory implements IPaymentFormFactory { - - public IPaymentForm create(int windowNo, GridTab mTab, String paymentRule) - { - if (paymentRule.equals(MInvoice.PAYMENTRULE_Cash)) - return new VPaymentFormCash(windowNo, mTab); - else if (paymentRule.equals(MInvoice.PAYMENTRULE_Check)) - return new VPaymentFormCheck(windowNo, mTab); - else if (paymentRule.equals(MInvoice.PAYMENTRULE_CreditCard)) - return new VPaymentFormCreditCard(windowNo, mTab); - else if (paymentRule.equals(MInvoice.PAYMENTRULE_DirectDebit)) - return new VPaymentFormDirectDebit(windowNo, mTab); - else if (paymentRule.equals(MInvoice.PAYMENTRULE_DirectDeposit)) - return new VPaymentFormDirectDeposit(windowNo, mTab); - else if (paymentRule.equals(MInvoice.PAYMENTRULE_MixedPOSPayment)) - return new VPaymentFormMixedPOS(windowNo, mTab); - else if (paymentRule.equals(MInvoice.PAYMENTRULE_OnCredit)) - return new VPaymentFormOnCredit(windowNo, mTab); - return null; - } -} \ No newline at end of file diff --git a/org.adempiere.ui.swing/src/org/compiere/grid/GridController.java b/org.adempiere.ui.swing/src/org/compiere/grid/GridController.java deleted file mode 100644 index dd1af42d7c..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/grid/GridController.java +++ /dev/null @@ -1,1506 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - * @contributor Victor Perez , e-Evolution.SC FR [ 1757088 ] * - * @contributor fer_luck @ centuryon * - *****************************************************************************/ -package org.compiere.grid; - -import java.awt.AWTEvent; -import java.awt.BorderLayout; -import java.awt.CardLayout; -import java.awt.Component; -import java.awt.Dimension; -import java.awt.KeyboardFocusManager; -import java.awt.event.KeyEvent; -import java.awt.event.MouseEvent; -import java.awt.event.MouseListener; -import java.beans.PropertyChangeEvent; -import java.beans.PropertyChangeListener; -import java.beans.PropertyVetoException; -import java.beans.VetoableChangeListener; -import java.util.ArrayList; -import java.util.HashSet; -import java.util.List; -import java.util.Properties; -import java.util.Set; -import java.util.logging.Level; - -import javax.swing.BorderFactory; -import javax.swing.JButton; -import javax.swing.JScrollPane; -import javax.swing.JSplitPane; -import javax.swing.KeyStroke; -import javax.swing.event.ListSelectionEvent; -import javax.swing.event.ListSelectionListener; -import javax.swing.table.DefaultTableModel; -import javax.swing.table.TableColumn; -import javax.swing.table.TableColumnModel; - -import org.adempiere.base.Core; -import org.adempiere.base.IColumnCallout; -import org.adempiere.plaf.AdempiereLookAndFeel; -import org.adempiere.plaf.AdempierePLAF; -import org.compiere.apps.ADialog; -import org.compiere.apps.APanel; -import org.compiere.apps.AppsAction; -import org.compiere.grid.ed.VCellEditor; -import org.compiere.grid.ed.VCellRenderer; -import org.compiere.grid.ed.VChart; -import org.compiere.grid.ed.VEditor; -import org.compiere.grid.ed.VEditorFactory; -import org.compiere.grid.ed.VHeaderRenderer; -import org.compiere.grid.ed.VManagedEditor; -import org.compiere.grid.ed.VRowIDEditor; -import org.compiere.grid.ed.VRowIDRenderer; -import org.compiere.grid.ed.VString; -import org.compiere.grid.tree.VTreePanel; -import org.compiere.model.DataStatusEvent; -import org.compiere.model.DataStatusListener; -import org.compiere.model.GridField; -import org.compiere.model.GridTab; -import org.compiere.model.GridTable; -import org.compiere.model.GridWindow; -import org.compiere.model.MColumn; -import org.compiere.model.MTree; -import org.compiere.model.MTreeNode; -import org.compiere.swing.CPanel; -import org.compiere.swing.CScrollPane; -import org.compiere.swing.CollapsiblePanel; -import org.compiere.swing.TableCellNone; -import org.compiere.util.CLogger; -import org.compiere.util.DisplayType; -import org.compiere.util.Env; -import org.compiere.util.Evaluatee; -import org.compiere.util.Trx; - -/** - * The Grid Controller is the panel for single and multi-row presentation - * and links to the Model Tab. - * - *
    - *  UI Structure:
    - *  this    (BorderLayout)
    - *      splitPane (JSplitPane)
    - *          left
    - *              graphicPanel
    - *          right
    - *              cardPanel   JPanel  (CardLayout)
    - *                  srPane  JSplitPane
    - * 						vPane	JScrollPane
    - *              	        vPanel  VPanel (GridBagLayout)
    - * 						vIncludedGC	GridController
    - *                  mrPane  JScrollPane
    - *                      vTable  VTable
    - *
    - *  DataBinding:
    - *  - MultiRow - is automatic between VTable and MTable
    - *  - SingleRow
    - *		- from VEditors via fireVetoableChange(m_columnName, null, getText());
    - *			(vetoableChange)
    - *		- to VEditors via updateSingleRow -> Editor.setValue(object)
    - *
    - *  Event Chains
    - *  -- Navigation --
    - *  (VTable selection -> GridController.valueChanged)
    - *  (APanel selection)
    - *      + MTab.navivate
    - *          + MTab.setCurrentRow
    - *              + Update all MFields
    - *                  + MField.setValue
    - *                      + setContext
    - *                      + fire PropertyChange "Value"
    - *                          + VEditor.propertyChange
    - *                              + VEditor.setValue
    - *              + MTab.fireProperyChange "CurrentRow"
    - *                  + VTable.propertyChange (setRowSelectionInterval)
    - *                      + GridController.valueChange
    - *                          + GridController.dynamicDisplay(complete)
    - *              + MTab.fireDataStatusChanged
    - *                  + APanel.statusChanged
    - *
    - *  -- ValueChanges --
    - *  VEditor.fireVetoableChange
    - *      + (VCellEditor.vetoableChange/getCellEditorValue)   -- multi-row source
    - *      + (GridController.vetoableChange)                   -- single-row source
    - *          + MTable.setValueAt
    - *              + MField.setValue
    - *                  + setContext
    - *                  + fire PropertyChange "Value"
    - *                      + VEditor.setValue
    - *              + MTable.fireDataStatusChanged
    - *                  + MTab.dataStatusChanged
    - *                      + MTab.fireDataStatusChanged
    - *                          + APanel.statusChanged
    - *                  + GridController.dataStatusChanged
    - *                      + GridController.dynamicDisplay(selective)
    - *  
    - * @author Jorg Janke - * @version $Id: GridController.java,v 1.8 2006/09/25 00:59:52 jjanke Exp $ - * - * @author Teo Sarca - BF [ 1742159 ], BF [ 1707876 ] - * @contributor Victor Perez , e-Evolution.SC FR [ 1757088 ] - * @contributor fer_luck @ centuryon FR [ 1757088 ] - */ -public class GridController extends CPanel - implements DataStatusListener, ListSelectionListener, Evaluatee, - VetoableChangeListener, PropertyChangeListener, MouseListener -{ - /** - * - */ - private static final long serialVersionUID = -2830833057882006196L; - - /** - * Constructor - you need to call initGrid for instanciation - */ - public GridController() - { - try - { - jbInit(); - } - catch(Exception e) - { - log.log(Level.SEVERE, "", e); - } - } // GridController - - /** - * toString - * @return string representation - */ - public String toString() - { - return "GridController for " + m_mTab; - } // toString - - /** Logger */ - private static CLogger log = CLogger.getCLogger(GridController.class); - - /** - * The Layout - */ - private BorderLayout mainLayout = new BorderLayout(); - private JSplitPane splitPane = new JSplitPane(); - private CPanel graphPanel = new CPanel(); - private BorderLayout graphLayout = new BorderLayout(); - private CPanel cardPanel = new CPanel(); - private CardLayout cardLayout = new CardLayout(); - //private JSplitPane srPane = new JSplitPane(); - - private JScrollPane vPane = new JScrollPane(); - private CScrollPane mrPane = new CScrollPane(); - private CPanel xPanel = new CPanel(); - private BorderLayout xLayout = new BorderLayout(); - private VTable vTable = new VTable(); - //FR [ 1757088 ] - private VPanel vPanel = null; - private boolean detailGrid = false; - - /** - * Static Layout init - * @throws Exception - */ - private void jbInit() throws Exception - { - this.setLayout(mainLayout); - this.add(splitPane, BorderLayout.CENTER); - splitPane.setOpaque(false); - graphPanel.setLayout(graphLayout); - // - splitPane.add(graphPanel, JSplitPane.LEFT); - splitPane.add(cardPanel, JSplitPane.RIGHT); - splitPane.setBorder(null); - splitPane.setName("gc_splitPane"); - // - cardPanel.setLayout(cardLayout); - cardPanel.add(vPane, "vPane"); // Sequence Important! - cardPanel.add(mrPane, "mrPane"); - cardPanel.setBorder(null); - cardPanel.setName("gc_cardPanel"); - // single row (w/o xPane it would be centered) - /* - srPane.setBorder(null); - srPane.setName("gc_srPane"); - srPane.setOrientation(JSplitPane.VERTICAL_SPLIT); - srPane.add(vPane, JSplitPane.TOP); - srPane.setTopComponent(vPane); - srPane.setBottomComponent(null); // otherwise a button is created/displayed - */ - //FR [ 1757088 ] vPane.getViewport().add(xPanel, null); - //FR [ 1757088 ] xPanel.add(vPanel); - xPanel.setLayout(xLayout); - xPanel.setName("gc_xPanel"); - xPanel.setBorder(BorderFactory.createEmptyBorder()); - //xLayout.setAlignment(FlowLayout.LEFT); - xLayout.setHgap(0); - xLayout.setVgap(0); - // multi-row - mrPane.setBorder(null); - mrPane.getViewport().add(vTable, null); - mrPane.setName("gc_mrPane"); - // - graphPanel.setBorder(null); - graphPanel.setName("gc_graphPanel"); - //srPane.setDividerLocation(200); - - vPane.setBorder(BorderFactory.createEmptyBorder()); - } // jbInit - - /** - * Displose - */ - public void dispose() - { - if (log.isLoggable(Level.CONFIG)) log.config( "(" + m_mTab.toString() + ")"); - // clear info - stopEditor(false); - if (m_mTab.isLoadComplete()) - { - if (m_mTab.needSave(true, false)) - m_mTab.dataIgnore(); - } - //FR [ 1757088 ] vIncludedGC = null; - - // Listeners - if (m_mTab.isLoadComplete()) - { - m_mTab.getTableModel().removeDataStatusListener(this); - m_mTab.getTableModel().removeVetoableChangeListener(this); - } - vTable.getSelectionModel().removeListSelectionListener(this); - m_mTab.removePropertyChangeListener(vTable); - - // editors - Component[] comp = vPanel.getComponentsRecursive(); - for (int i = 0; i < comp.length; i++) - { - if (comp[i] instanceof VEditor) - { - VEditor vEditor = (VEditor)comp[i]; - vEditor.removeVetoableChangeListener(this); - String columnName = comp[i].getName(); - GridField mField = m_mTab.getField(columnName); - if (mField != null) - mField.removePropertyChangeListener(vEditor); - vEditor.dispose(); - } - } - /** @todo Remove APanel Button listeners */ - - vTable.removeAll(); - vTable.setModel(new DefaultTableModel()); // remove reference - vTable = null; - vPanel.removeAll(); - vPanel = null; - //srPane.removeAll(); - //srPane = null; - splitPane.removeAll(); - splitPane = null; - m_mTab = null; - m_tree = null; - this.removeAll(); - } // dispose - - /** Model Tab */ - private GridTab m_mTab = null; - /** Window */ - private int m_WindowNo; - /** Only Multi-Row exist */ - private boolean m_onlyMultiRow = false; - /** Single/Multi Row indicator */ - private boolean m_singleRow = true; - /** Veto Active */ - private boolean m_vetoActive = false; - /** Tree Panel (optional) */ - private VTreePanel m_tree; - - private APanel m_aPanel; - - private boolean init; - - private ArrayList synchronizerList = new ArrayList(); - - public boolean initGrid (GridTab mTab, boolean onlyMultiRow, - int WindowNo, APanel aPanel, GridWindow mWindow) - { - return initGrid(mTab, onlyMultiRow, WindowNo, aPanel, mWindow, false); - } - - /************************************************************************** - * Init Grid. - *
    -	 *  - Map table to model
    -	 *  - Update (multi-row) table info with renderers/editors
    -	 *  - build single-row panel
    -	 *  - initialize display
    -	 *  
    - * @param mTab tab - * @param onlyMultiRow only table - * @param WindowNo window no - * @param aPanel optional Application Panel for adding button listeners - * @param mWindow parent Window Model - * @return true if initialized - */ - public boolean initGrid (GridTab mTab, boolean onlyMultiRow, - int WindowNo, APanel aPanel, GridWindow mWindow, boolean lazy) - { - if (log.isLoggable(Level.CONFIG)) log.config( "(" + mTab.toString() + ")"); - m_mTab = mTab; - m_WindowNo = WindowNo; - m_onlyMultiRow = onlyMultiRow; - m_aPanel = aPanel; - setName("GC-" + mTab); - //FR [ 1757088 ] - vPanel = new VPanel(mTab.getName(), m_WindowNo); - vPanel.putClientProperty(AdempiereLookAndFeel.HIDE_IF_ONE_TAB, Boolean.TRUE); - if (this.isDetailGrid()) - { - vPanel.setBorder(BorderFactory.createLineBorder(AdempierePLAF.getPrimary2())); - } - vPane.getVerticalScrollBar().setUnitIncrement(16); // IDEMPIERE-572 - tbayen 2013-01-20 - vPane.getViewport().add(xPanel, null); - xPanel.add(vPanel, BorderLayout.CENTER); - - setTabLevel(m_mTab.getTabLevel()); - - if (!lazy) - init(); - else - { - //Load tab meta data, needed for includeTab to work - m_mTab.initTab(false); - } - - - // log.config( "GridController.dynInit (" + mTab.toString() + ") - fini"); - return true; - } // initGrid - - private void init() - { - // Set up Multi Row Table - vTable.setModel(m_mTab.getTableModel()); - - // Update Table Info ------------------------------------------------- - int size = setupVTable (m_aPanel, m_mTab, vTable); - - // Set Color on Tab Level - // this.setBackgroundColor (mTab.getColor()); - - // Single Row ------------------------------------------------------- - if (!m_onlyMultiRow) - { - // Set Softcoded Mnemonic &x - for (int i = 0; i < size; i++) - { - GridField mField = m_mTab.getField(i); - if (mField.isDisplayed()) - vPanel.setMnemonic(mField); - } // for all fields - - // Add Fields - for (int i = 0; i < size; i++) - { - GridField mField = m_mTab.getField(i); - if (mField.isDisplayed() - // IDEMPIERE-587 Swing: Toolbar Button to start Process from button fields - && !( - mField.getDisplayType()==DisplayType.Button - && mField.isToolbarOnlyButton()) - ) - { - VEditor vEditor = VEditorFactory.getEditor(m_mTab, mField, false); - if (vEditor == null) - { - log.warning("Editor not created for " + mField.getColumnName()); - continue; - } - // MField => VEditor - New Field value to be updated to editor - mField.addPropertyChangeListener(vEditor); - // VEditor => this - New Editor value to be updated here (MTable) - vEditor.addVetoableChangeListener(this); - // Add to VPanel - vPanel.addFieldBuffered(vEditor, mField); - // APanel Listen to buttons - if (mField.getDisplayType() == DisplayType.Button && m_aPanel != null) - ((JButton)vEditor).addActionListener (m_aPanel); - } - } // for all fields - vPanel.addFieldBuffered(null, null); // flush the last one through - - // No Included Grid Controller - /* - srPane.setResizeWeight(1); // top part gets all - srPane.setDividerSize (0); - srPane.setDividerLocation (9999); - */ - // Use SR to size MR - mrPane.setPreferredSize(vPanel.getPreferredSize()); - } // Single-Row - - // Tree Graphics Layout - int AD_Tree_ID = 0; - if (m_mTab.isTreeTab()) - AD_Tree_ID = MTree.getDefaultAD_Tree_ID ( - Env.getAD_Client_ID(Env.getCtx()), m_mTab.getKeyColumnName()); - if (m_mTab.isTreeTab() && AD_Tree_ID != 0) - { - m_tree = new VTreePanel(m_WindowNo, false, true); - if (m_mTab.getTabNo() == 0) // initialize other tabs later - m_tree.initTree(AD_Tree_ID); - m_tree.addPropertyChangeListener(VTreePanel.NODE_SELECTION, this); - graphPanel.add(m_tree, BorderLayout.CENTER); - splitPane.setDividerLocation(250); - // splitPane.resetToPreferredSizes(); - } - else // No Graphics - hide - { - graphPanel.setPreferredSize(new Dimension(0,0)); - splitPane.setDividerSize(0); - splitPane.setDividerLocation(0); - } - - // Receive DataStatusChanged info from MTab - m_mTab.addDataStatusListener(this); - // Receive vetoableChange info from MTable when saving - m_mTab.getTableModel().addVetoableChangeListener(this); - // Selection Listener -> valueChanged - vTable.getSelectionModel().addListSelectionListener(this); - // Navigation (RowChanged) - m_mTab.addPropertyChangeListener(vTable); - - // Update UI - vTable.autoSize(true); - - // Set initial presentation - if (m_onlyMultiRow || !m_mTab.isSingleRow()) - switchMultiRow(); - else - switchSingleRow(); - - init = true; - } - - /** - * - * @return boolean - */ - public boolean isInit() - { - return init; - } - - /** - * Include Tab - * @param gc grid controller to add - * @return GridSynchronizer - */ - - //FR [ 1757088 ] - public boolean includeTab (GridController gc , APanel aPanel, GridSynchronizer sync) - { - GridController detail = gc; - detail.setDetailGrid(true); - detail.addMouseListener(detail); - detail.enableEvents(AWTEvent.HIERARCHY_EVENT_MASK + AWTEvent.MOUSE_EVENT_MASK); - - vPanel.includeTab(detail); - //BEGIN - [FR 1953734] - gc.setGCParent(this); - //END - [FR 1953734] - gc.getGCParent().setPreferredSize(vPanel.getPreferredSize()); - synchronizerList.add(sync); - return true; - } // IncludeTab - - //FR [ 1757088 ] - public void setDetailGrid(boolean value){ - detailGrid = value; - if (detailGrid && vPanel != null) - vPanel.setBorder(BorderFactory.createLineBorder(AdempierePLAF.getPrimary2())); - } - - public boolean isDetailGrid(){ - return detailGrid; - } - /** - * Get Title - * @return title - */ - public String getTitle () - { - return m_mTab.getName(); - } // getTitle - - /** - * Setup Multi-Row Table (add fields) - * @param aPanel Panel - * @param mTab Model Tab - * @param table JTable - * @return size - */ - private int setupVTable (APanel aPanel, GridTab mTab, VTable table) - { - if (!mTab.isDisplayed()) - return 0; - int size = mTab.getFieldCount (); - TableColumnModel tcm = table.getColumnModel(); - if (size != tcm.getColumnCount()) - throw new IllegalStateException("TableColumn Size <> TableModel"); - - for (int i = 0; i < size; i++) - { - GridField mField = mTab.getField (i); - TableColumn tc = tcm.getColumn(i); - tc.setMinWidth(30); - // - if (mField.getColumnName().equals(tc.getIdentifier().toString())) - { - //don't show included tab field in grid - if (mField.getIncluded_Tab_ID() > 0) - { - TableCellNone tcn = new TableCellNone(mField.getColumnName()); - tc.setCellRenderer (tcn); - tc.setCellEditor (tcn); - tc.setHeaderValue (null); - tc.setMinWidth (0); - tc.setMaxWidth (0); - tc.setPreferredWidth (0); - } - else if (mField.getDisplayType () == DisplayType.RowID) - { - tc.setCellRenderer (new VRowIDRenderer (false)); - tc.setCellEditor (new VRowIDEditor (false)); - tc.setHeaderValue (""); - tc.setMaxWidth (2); - } - else - { - // need to set CellEditor explicitly as default editor based on class causes problem (YesNo-> Boolean) - if (mField.isDisplayedGrid()) - { - tc.setCellRenderer (new VCellRenderer (mField)); - VCellEditor ce = new VCellEditor (mField); - tc.setCellEditor (ce); - // - tc.setHeaderValue (mField.getHeader ()); - tc.setPreferredWidth (Math.max (mField.getDisplayLength (), 30)); - tc.setHeaderRenderer (new VHeaderRenderer (mField.getDisplayType ())); - - // Enable Button actions in grid - if (mField.getDisplayType () == DisplayType.Button) - { - ce.setActionListener(aPanel); - } - } - else // column not displayed - { - TableCellNone tcn = new TableCellNone(mField.getColumnName()); - tc.setCellRenderer (tcn); - tc.setCellEditor (tcn); - tc.setHeaderValue (null); - tc.setMinWidth (0); - tc.setMaxWidth (0); - tc.setPreferredWidth (0); - } - } - // System.out.println ("TableColumnID " + tc.getIdentifier () - // + " Renderer=" + tc.getCellRenderer () - // + mField.getHeader ()); - - } // found field - else - log.log(Level.SEVERE, "TableColumn " + tc.getIdentifier () - + " <> MField " + mField.getColumnName() + mField.getHeader()); - } // for all fields - return size; - } // setupVTable - - /** - * Activate Grid Controller. - * Called by APanel when GridController is displayed (foreground) - */ - public void activate () - { - if (!init) init(); - - // Tree to be initiated on second/.. tab - if (m_mTab.isTreeTab() && m_mTab.getTabNo() != 0) - { - String keyColumnName = m_mTab.getKeyColumnName(); - String treeName = "AD_Tree_ID"; - if (keyColumnName.startsWith("CM")) - { - if (keyColumnName.equals("CM_Container_ID")) - treeName = "AD_TreeCMC_ID"; - else if (keyColumnName.equals("CM_CStage_ID")) - treeName = "AD_TreeCMS_ID"; - else if (keyColumnName.equals("CM_Template_ID")) - treeName = "AD_TreeCMT_ID"; - else if (keyColumnName.equals("CM_Media_ID")) - treeName = "AD_TreeCMM_ID"; - } - int AD_Tree_ID = Env.getContextAsInt (Env.getCtx(), m_WindowNo, treeName, true); - if (log.isLoggable(Level.CONFIG)) log.config(keyColumnName + " -> " + treeName + " = " + AD_Tree_ID); - if (AD_Tree_ID == 0) - AD_Tree_ID = MTree.getDefaultAD_Tree_ID ( - Env.getAD_Client_ID(Env.getCtx()), m_mTab.getKeyColumnName()); - int linkColId = MTree.get(Env.getCtx(), AD_Tree_ID, null).getParent_Column_ID(); - String linkColName = null; - int linkID = 0; - if (linkColId > 0) { - linkColName = MColumn.getColumnName(Env.getCtx(), linkColId); - linkID = Env.getContextAsInt(Env.getCtx(), m_WindowNo, linkColName, true); - } - if (m_tree != null) - m_tree.initTree (AD_Tree_ID, linkColName, linkID); - } - - activateChilds(); - } // activate - - /** - * activate child grid controller ( included tab ) - */ - private void activateChilds() - { - for (GridSynchronizer s : synchronizerList ) - { - s.activateChild(); - } - } - - public GridController findChild(GridTab gTab) - { - GridController gc = null; - for (GridSynchronizer s : synchronizerList ) - { - if (s.getChild().getMTab().equals(gTab)) - { - gc = s.getChild(); - break; - } - } - return gc; - } - - /** - * Register ESC Actions - * - overwrite VTable's Keystrokes assignment for ESC - * @param aIgnore ignore - */ - public void registerESCAction (AppsAction aIgnore) - { - int c = VTable.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT; - vTable.getInputMap(c).put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), aIgnore.getName()); - vTable.getActionMap().put(aIgnore.getName(), aIgnore); - - // AEnv.printActionInputMap(vTable); - } // registerESCAction - - /** - * Query Tab and resize Table - * (called from APanel) - * @param onlyCurrentRows only current rows - * @param onlyCurrentDays how many days back - * @param maxRows maximim rows or 0 for all - */ - public void query (boolean onlyCurrentRows, int onlyCurrentDays, int maxRows) - { - // start loading while building screen - m_mTab.query(onlyCurrentRows, onlyCurrentDays, maxRows); - - //make sure value from previous query is clear from window context - if (m_mTab.getRowCount() == 0) - { - if (getGCParent() != null) - { - ArrayList parentColumnNames = new ArrayList(); - GridField[] parentFields = getGCParent().getMTab().getFields(); - for (GridField parentField : parentFields) - parentColumnNames.add(parentField.getColumnName()); - - GridField[] fields = m_mTab.getFields(); - for (GridField field : fields) - { - if (!parentColumnNames.contains(field.getColumnName())) - Env.setContext(Env.getCtx(), field.getWindowNo(), field.getColumnName(), ""); - } - } - } - // Update UI - if (!isSingleRow()) - vTable.autoSize(true); - activateChilds(); - } // query - - /* - public boolean isNeedToSaveParent() - { - return m_mTab.isNeedToSaveParent(); - }*/ - - /************************************************************************** - * Switch from single to multi & vice versa - */ - public void switchRowPresentation() - { - stopEditor(true); - if (m_singleRow) - switchMultiRow(); - else - switchSingleRow(); - } // switchRowPresentation - - /** - * Switch to SingleRow Presentation - */ - public void switchSingleRow() - { - if (m_onlyMultiRow) - return; - cardLayout.first(cardPanel); - m_singleRow = true; - dynamicDisplay(0); - // vPanel.requestFocus(); - } // switchSingleRow - - /** - * Switch to MultiRow Presentation - */ - public void switchMultiRow() - { - cardLayout.last(cardPanel); - m_singleRow = false; - vTable.autoSize(true); // resizes - // vTable.requestFocus(); - } // switchSingleRow - - /** - * Is Single Row presentation - * @return true if Single Row is displayed - */ - public boolean isSingleRow() - { - return m_singleRow; - } // isSingleRow - - - /************************************************************************** - * Remove Listener - pass on to MTab - * @param l listener - */ - public synchronized void removeDataStatusListener(DataStatusListener l) - { - m_mTab.removeDataStatusListener(l); - } // removeDataStatusListener - - /** - * Add Data Status Listener - pass on to MTab - * @param l listener - */ - public synchronized void addDataStatusListener(DataStatusListener l) - { - m_mTab.addDataStatusListener(l); - } - - /** - * Data Status Listener - for MTab events. - *

    - * Callouts are processed here for GUI changes - * - same as in MTab.setValue for batch changes - *

    - * calls dynamicDisplay - * @param e event - */ - public void dataStatusChanged(DataStatusEvent e) - { - // if (e.getChangedColumn() == 0) - // return; - int col = e.getChangedColumn(); - if (log.isLoggable(Level.CONFIG)) log.config("(" + m_mTab + ") Col=" + col + ": " + e.toString()); - - // Process Callout - GridField mField = m_mTab.getField(col); - if (mField != null) { - List callouts = Core.findCallout(m_mTab.getTableName(), mField.getColumnName()); - if (mField.getCallout().length() > 0 || callouts.size()>0 || m_mTab.hasDependants(mField.getColumnName())) - { - String msg = m_mTab.processFieldChange(mField); // Dependencies & Callout - if (msg.length() > 0) - ADialog.error(m_WindowNo, this, msg); - } - } - //if (col >= 0) - dynamicDisplay(col); - } // dataStatusChanged - - - /************************************************************************** - * List Selection Listener (VTable) - row changed - * @param e event - */ - public void valueChanged(ListSelectionEvent e) - { - // no rows - if (m_mTab.getRowCount() == 0) - return; - - // vTable.stopEditor(graphPanel); - int rowTable = vTable.getSelectedRow(); - int rowCurrent = m_mTab.getCurrentRow(); - if (log.isLoggable(Level.CONFIG)) log.config("(" + m_mTab.toString() + ") Row in Table=" + rowTable + ", in Model=" + rowCurrent); - /* BT [ 1972495 ] Multirow Automatic New Record loses context - // FR [ 1757088 ] - if(rowCurrent + 1 == vTable.getRowCount() && !isSingleRow() && Env.isAutoNew(Env.getCtx()) && m_mTab.getRecord_ID() != -1) - { - //stopEditor(true); - vTable.getSelectionModel().removeListSelectionListener(this); - m_mTab.dataNew(false); - dynamicDisplay(0); - vTable.getSelectionModel().addListSelectionListener(this); - return; - } */ - if (rowTable == -1) // nothing selected - { - if (rowCurrent >= 0) - { - vTable.setRowSelectionInterval(rowCurrent, rowCurrent); // causes this method to be called again - return; - } - } - else - { - if (rowTable != rowCurrent) { - //make sure table selection is consistent with model - int t = m_mTab.navigate(rowTable); - if (t != rowTable) { - rowTable = t; - vTable.setRowSelectionInterval(rowTable, rowTable); - } - } - dynamicDisplay(0); - } - - // TreeNavigation - Synchronize -- select node in tree - if (m_tree != null) - m_tree.setSelectedNode (m_mTab.getRecord_ID()); // ignores new (-1) - - // log.config( "GridController.valueChanged (" + m_mTab.toString() + ") - fini", - // "Row in Table=" + rowTable + ", in Model=" + rowCurrent); - - } // valueChanged - - /** - * PropertyChange Listener - Tree Panel - node selection - * @param e event - */ - public void propertyChange(PropertyChangeEvent e) - { - // System.out.println("propertyChange"); - // System.out.println(e); - if (e == null) - return; - Object value = e.getNewValue(); - if (value == null) - return; - if (log.isLoggable(Level.CONFIG)) log.config(e.getPropertyName() + "=" + value - + " - " + value.getClass().toString()); - if (!(value instanceof MTreeNode)) - return; - - // We Have a TreeNode - int nodeID = ((MTreeNode)value).getNode_ID(); - // root of tree selected - ignore - //if (nodeID == 0) - //return; - - // Search all rows for mode id - int size = m_mTab.getRowCount(); - int row = -1; - for (int i = 0; i < size; i++) - { - if (m_mTab.getKeyID(i) == nodeID) - { - row = i; - break; - } - } - if (row == -1) - { - if (nodeID > 0) - log.log(Level.WARNING, "Tab does not have ID with Node_ID=" + nodeID); - return; - } - - // Navigate to node row - m_mTab.navigate(row); - } // propertyChange - - /** - * Dynamic Display. - * - Single Row Screen layout and update of dynamic Lookups - *

    - * Single Row layout: - * the components's name is the ColumnName; if it matches, the - * MField.isDisplayed(true) is used to determine if it is visible - * if the component is a VEditor, setEnabled is set from the MField - *

    - * Multi Row layout is not changed: - * VCellRenderer calls JTable.isCellEditable -> checks MField.isEditable (Active, isDisplayed) - * VCellEditor.isCellEditable calls MField.isEditable(true)
    - * If a column is not displayed, the width is set to 0 in dynInit - *

    - * Dynamic update of data is handeled in VLookup.focusGained/Lost. - * When focus is gained the model is temporarily updated with the - * specific validated data, if lost, it is switched back to the - * unvalidated data (i.e. everything). This allows that the display - * methods have a lookup to display.
    - * Here: if the changed field has dependents and the dependent - * is a Lookup and this lookup has a dynamic dependence of the changed field, - * the value of that field is set to null (in MTab.processDependencies - - * otherwise it would show an invalid value). - * As Editors listen for value changed of their MField, the display is updated. - *

    - * Called from GridController.valueChanged/dataStatusChanged, APane;.stateChanged/unlock/cmd_... - * @param col selective column number or 0 if all - */ - public void dynamicDisplay (int col) - { - // log.config( "GridController.dynamicDisplay (" + m_mTab.toString() + ") SingleRow=" + isSingleRow() + ", OnlyMultiRow=" + m_onlyMultiRow); - // Don't update if multi-row - if (!isSingleRow() || m_onlyMultiRow) - return; - if (!m_mTab.isOpen()) - return; - // Selective - if (col > 0) - { - GridField changedField = m_mTab.getField(col); - String columnName = changedField.getColumnName(); - ArrayList dependants = m_mTab.getDependantFields(columnName); - if (log.isLoggable(Level.CONFIG)) log.config("(" + m_mTab.toString() + ") " - + columnName + " - Dependents=" + dependants.size()); - // No Dependents and no Callout - Set just Background - if ( ! ( dependants.size() > 0 - || changedField.getCallout().length() > 0 - || Core.findCallout(m_mTab.getTableName(), columnName).size() > 0)) { - Component[] comp = vPanel.getComponentsRecursive(); - for (int i = 0; i < comp.length; i++) - { - if (columnName.equals(comp[i].getName ()) && comp[i] instanceof VEditor) - { - VEditor ve = (VEditor)comp[i]; - boolean manMissing = false; - boolean noValue = changedField.getValue() == null || changedField.getValue().toString().length() == 0; - if (noValue && changedField.isEditable(true) && changedField.isMandatory(true)) // check context - manMissing = true; - ve.setBackground(manMissing || changedField.isError()); - break; - } - } - return; - } - } // selective - - - // complete single row re-display - boolean noData = m_mTab.getRowCount() == 0; - if (log.isLoggable(Level.CONFIG)) log.config(m_mTab.toString() + " - Rows=" + m_mTab.getRowCount()); - // All Components in vPanel (Single Row) - - Set hiddens = new HashSet(); - Component[] comps = vPanel.getComponentsRecursive(); - for (int i = 0; i < comps.length; i++) - { - Component comp = comps[i]; - String columnName = comp.getName(); - - if ( comp instanceof VChart && isSingleRow()) - { - ((VChart) comp).createChart(); - } - - if (columnName != null && columnName.length() > 0) - { - GridField mField = m_mTab.getField(columnName); - if (mField != null) - { - if (mField.isDisplayed(true)) // check context - { - if (!comp.isVisible()) - comp.setVisible(true); // visibility - /** - * Feature Request [1707462] - * Enable runtime change of VFormat - * @author fer_luck - */ - if (comp instanceof VString){ - VString vs = (VString)comp; - if ((vs.getVFormat() != null && vs.getVFormat().length() > 0 && mField.getVFormat() == null) - || (vs.getVFormat() == null && mField.getVFormat() != null && mField.getVFormat().length() > 0) - || (vs.getVFormat() != null && mField.getVFormat() != null && !vs.getVFormat().equals(mField.getVFormat()))) { - vs.setVFormat(mField.getVFormat()); - } - } - //End Feature Request [1707462] - if (comp instanceof VEditor) - { - VEditor ve = (VEditor)comp; - if (noData) - ve.setReadWrite(false); - else - { - boolean rw = mField.isEditable(true); // r/w - check Context - ve.setReadWrite(rw); - // log.log(Level.FINEST, "RW=" + rw + " " + mField); - boolean manMissing = false; - // least expensive operations first // missing mandatory - if (rw && mField.getValue() == null && mField.isMandatory(true)) // check context - manMissing = true; - ve.setBackground(manMissing || mField.isError()); - } - } - } - else - { - if (comp.isVisible()) - comp.setVisible(false); - hiddens.add(columnName); - } - } - } - } // all components - - // hide empty field group based on the environment - for (int i = 0; i < comps.length; i++) { - Component comp = comps[i]; - - if (comp instanceof CollapsiblePanel) - { - if (comp.getName() == null || comp.getName().startsWith("IncludedTab#")) - continue; - else - { - boolean hasVisible = false; - Component[] childs = ((CollapsiblePanel)comp).getCollapsiblePane().getContentPane().getComponents(); - for (int j = 0; j < childs.length; j++) { - if (childs[j].isVisible()) - { - String columnName = childs[j].getName(); - if (columnName != null && columnName.length() > 0) - { - GridField mField = m_mTab.getField(columnName); - if (mField != null) - { - hasVisible = true; - break; - } - } - } - } - if (comp.isVisible() != hasVisible) - comp.setVisible(hasVisible); - } - } - } - - // - - if (log.isLoggable(Level.CONFIG)) log.config(m_mTab.toString() + " - fini - " - + (col <= 0 ? "complete" : "seletive")); - } // dynamicDisplay - - /** - * Row Changed - synchronize with Tree - * - * @param save true the row was saved (changed/added), false if the row was deleted - * @param keyID the ID of the row changed - */ - public void rowChanged (boolean save, int keyID) - { - if (m_tree == null || keyID <= 0) - return; - String name = (String)m_mTab.getValue("Name"); - String description = (String)m_mTab.getValue("Description"); - Boolean IsSummary = (Boolean)m_mTab.getValue("IsSummary"); - boolean summary = IsSummary != null && IsSummary.booleanValue(); - String imageIndicator = (String)m_mTab.getValue("Action"); // Menu - Action - // - m_tree.nodeChanged(save, keyID, name, description, - summary, imageIndicator); - } // rowChanged - - - /************************************************************************** - * Save Multiple records - Clone a record and assign new values to each - * clone for a specific column. - * @param ctx context - * @param tableName Table Name - * @param columnName Column for which value need to be changed - * @param recordId Record to clone - * @param values Values to be assigned to clones for the specified column - * @param trxName Transaction - * @throws Exception If error is occured when loading the PO or saving clones - * - * @author ashley - */ - protected void saveMultipleRecords(Properties ctx, String tableName, - String columnName, int recordId, Integer[] values, - String trxName) throws Exception - { - if (values == null) - { - return ; - } - - int oldRow = m_mTab.getCurrentRow(); - GridField lineField = m_mTab.getField("Line"); - - for (int i = 0; i < values.length; i++) - { - if (!m_mTab.dataNew(true)) - { - throw new IllegalStateException("Could not clone tab"); - } - - m_mTab.setValue(columnName, values[i]); - - if (lineField != null) - { - m_mTab.setValue(lineField, 0); - } - - if (!m_mTab.dataSave(false)) - { - throw new IllegalStateException("Could not update tab"); - } - - m_mTab.setCurrentRow(oldRow); - } - } - - /************************************************************************** - * Vetoable Change Listener. - * Called from VEditor - *

    -	 *  - for Save Confirmation dialog
    -	 *  - for Single Row from VEditor: Update MTable
    -	 *  
    - * @param e event - * @throws PropertyVetoException - */ - public void vetoableChange(PropertyChangeEvent e) throws PropertyVetoException - { - if (m_mTab.isProcessed() || !m_mTab.isActive()) // only active records - { - Object source = e.getSource(); - if (source instanceof VEditor) - { - if (!((VEditor)source).isReadWrite()) - { - if (log.isLoggable(Level.CONFIG)) log.config("(" + m_mTab.toString() + ") " + e.getPropertyName()); - return; - } - } - else - { - if (log.isLoggable(Level.CONFIG)) log.config("(" + m_mTab.toString() + ") " + e.getPropertyName()); - return; - } - } // processed - if (log.isLoggable(Level.CONFIG)) log.config("(" + m_mTab.toString() + ") " - + e.getPropertyName() + "=" + e.getNewValue() + " (" + e.getOldValue() + ") " - + (e.getOldValue() == null ? "" : e.getOldValue().getClass().getName())); - - - // Save Confirmation dialog MTable-RowSave - if (e.getPropertyName().equals(GridTable.PROPERTY)) - { - // throw new PropertyVetoException will call this listener again to revert to old value - if (m_vetoActive) - { - //ignore - m_vetoActive = false; - return; - } - if (!Env.isAutoCommit(Env.getCtx(), m_WindowNo) || m_mTab.getCommitWarning().length() > 0) - { - if (!ADialog.ask(m_WindowNo, this, "SaveChanges?", m_mTab.getCommitWarning())) - { - m_vetoActive = true; - throw new PropertyVetoException ("UserDeniedSave", e); - } - } - return; - } // saveConfirmation - - - // Get Row/Col Info - GridTable mTable = m_mTab.getTableModel(); - int row = m_mTab.getCurrentRow(); - int col = mTable.findColumn(e.getPropertyName()); - // - if (e.getNewValue() == null && e.getOldValue() != null - && e.getOldValue().toString().length() > 0) { // some editors return "" instead of null - mTable.setChanged (true); - mTable.setValueAt (e.getNewValue(), row, col, true); - } - else - { - // mTable.setValueAt (e.getNewValue(), row, col, true); - /* - * Changes: Added the logic below to handle multiple values for a single field - * due to multiple selection in Lookup (Info). - * @author ashley - */ - Object newValue = e.getNewValue(); - Integer newValues[] = null; - - if (newValue instanceof Integer[]) - { - newValues = ((Integer[])newValue); - newValue = newValues[0]; - - if (newValues.length > 1) - { - Integer valuesCopy[] = new Integer[newValues.length - 1]; - System.arraycopy(newValues, 1, valuesCopy, 0, valuesCopy.length); - newValues = valuesCopy; - } - else - { - newValues = null; - } - } - else if (newValue instanceof Object[]) - { - log.severe("Multiple values can only be processed for IDs (Integer)"); - throw new PropertyVetoException("Multiple Selection values not available for this field", e); - } - - mTable.setValueAt (newValue, row, col); // -> dataStatusChanged -> dynamicDisplay - - // Force Callout - if (e.getPropertyName().equals("S_ResourceAssignment_ID")) - { - GridField mField = m_mTab.getField(col); - if (mField != null && (mField.getCallout().length() > 0 - || Core.findCallout(m_mTab.getTableName(), mField.getColumnName()).size()>0)) { - m_mTab.processFieldChange(mField); // Dependencies & Callout - } - } - - if (newValues != null && newValues.length > 0) - { - // Save data, since record need to be used for generating clones. - if (!m_mTab.dataSave(false)) - { - throw new PropertyVetoException("SaveError", e); - } - - // Retrieve the current record ID - int recordId = m_mTab.getKeyID(m_mTab.getCurrentRow()); - - Trx trx = Trx.get(Trx.createTrxName(), true); - trx.start(); - try - { - saveMultipleRecords(Env.getCtx(), mTable.getTableName(), e.getPropertyName(), recordId, newValues, trx.getTrxName()); - trx.commit(); - m_mTab.dataRefreshAll(); - } - catch(Exception ex) - { - trx.rollback(); - log.severe(ex.getMessage()); - throw new PropertyVetoException("SaveError", e); - } - finally - { - trx.close(); - } - } - } - - // log.config( "GridController.vetoableChange (" + m_mTab.toString() + ") - fini", e.getPropertyName() + "=" + e.getNewValue()); - } // vetoableChange - - - /************************************************************************** - * Get Model Tab - * @return Model Tab - */ - public GridTab getMTab() - { - return m_mTab; - } // getMTab - - /** - * Get Display Logic - * @return Display Logic - */ - public String getDisplayLogic() - { - return m_mTab.getDisplayLogic(); - } // getDisplayLogic - - /** - * Get VTable - * @return VTable - */ - public VTable getTable() - { - return vTable; - } // getTable - - - /** - * Set Window level Mnemonics - * @param set true if set otherwise unregiser - */ - public void setMnemonics (boolean set) - { - if (vPanel != null) - vPanel.setMnemonics(set); - } // setMnemonics - - /** - * Stop Table & SR Editors and move focus to graphPanel - * @param saveValue save value - */ - public void stopEditor (boolean saveValue) - { - if (log.isLoggable(Level.CONFIG)) log.config("(" + m_mTab.toString() + ") TableEditing=" + vTable.isEditing()); - - // MultiRow - remove editors - vTable.stopEditor(saveValue); - - // SingleRow - stop editors by changing focus - if (m_singleRow) - vPanel.transferFocus(); - // graphPanel.requestFocus(); - // - // log.config( "GridController.stopEditor (" + m_mTab.toString() + ") - fini", - // "Editing=" + vTable.isEditing()); - } // stopEditors - - /** - * Mouse Clicked - * @param e event - */ - public void mouseClicked(MouseEvent e) - { - if (log.isLoggable(Level.FINEST)) log.finest("" + this + " - " + e); - } - /** - * Mouse Pressed - * @param e event - */ - public void mousePressed(MouseEvent e) - { - if (log.isLoggable(Level.FINEST)) log.finest("" + this + " - " + e); - } - /** - * Mouse Released - * @param e event - */ - public void mouseReleased(MouseEvent e) - { - if (log.isLoggable(Level.FINEST)) log.finest("" + this + " - " + e); - } - /** - * Mouse Entered - * @param e event - */ - public void mouseEntered(MouseEvent e) - { - if (log.isLoggable(Level.FINEST)) log.finest("" + this + " - " + e); - } - /** - * Mouse Exited - * @param e event - */ - public void mouseExited(MouseEvent e) - { - if (log.isLoggable(Level.FINEST)) log.finest("" + this + " - " + e); - } - - /** - * Get Variable Value - * @param variableName name - * @return value - */ - public String get_ValueAsString (String variableName) - { - return Env.getContext(Env.getCtx(), m_WindowNo, variableName); - } // get_ValueAsString - - /** - * Is controller data not stale - * @return boolean - */ - public boolean isCurrent() - { - return m_mTab != null ? m_mTab.isCurrent() : false; - } - - //FR [ 1757088 ] - public VPanel getvPanel() - { - return vPanel; - } - - //BEGIN - [FR 1953734] - GridController m_Parent; - public void setGCParent(GridController gc){ - m_Parent = gc; - } - public GridController getGCParent(){ - return m_Parent; - } - public void refreshMTab(GridController includedTab){ - int m_CurrentRowBeforeSave = includedTab.m_mTab.getCurrentRow(); - m_mTab.dataRefresh(m_mTab.getCurrentRow()); - includedTab.m_mTab.setCurrentRow(m_CurrentRowBeforeSave); - } - //END - [FR 1953734] - - /** - * Accept pending editor changes. - */ - public void acceptEditorChanges() - { - if (isSingleRow()) - { - Component c = KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner(); - if (c != null && this.isAncestorOf(c)) - { - Component t = c; - while (t != null && t != this) - { - if (t instanceof VManagedEditor) - { - ((VManagedEditor)t).commitChanges(); - return; - } - t = t.getParent(); - } - } - } - } -} // GridController diff --git a/org.adempiere.ui.swing/src/org/compiere/grid/GridSynchronizer.java b/org.adempiere.ui.swing/src/org/compiere/grid/GridSynchronizer.java deleted file mode 100644 index 7ec5fef1f6..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/grid/GridSynchronizer.java +++ /dev/null @@ -1,80 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 2007 Adempiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - *****************************************************************************/ -package org.compiere.grid; - -import java.beans.PropertyChangeEvent; -import java.beans.PropertyChangeListener; - -import org.compiere.model.GridWindow; -import org.compiere.model.MRole; -import org.compiere.model.StateChangeEvent; -import org.compiere.model.StateChangeListener; - -/** - * - * @author Low Heng Sin - * - */ -public class GridSynchronizer implements PropertyChangeListener, StateChangeListener { - - @SuppressWarnings("unused") - private GridController parent; - private GridController child; - private GridWindow window; - - /** - * - * @param window - * @param parent - * @param child - */ - public GridSynchronizer(GridWindow window, GridController parent, GridController child) { - this.window = window; - this.parent = parent; - this.child = child; - - parent.getMTab().addPropertyChangeListener(this); - parent.getMTab().addStateChangeListener(this); - } - - /** - * @param evt - */ - public void propertyChange(PropertyChangeEvent evt) { - MRole role = MRole.getDefault(); - child.query (false, 0, role.getMaxQueryRecords()); - } - - /** - * @param event - */ - public void stateChange(StateChangeEvent event) { - MRole role = MRole.getDefault(); - child.query (false, 0, role.getMaxQueryRecords()); - } - - /** - * trigger when parent gc activate - */ - public void activateChild() { - window.initTab(window.getTabIndex(child.getMTab())); - child.activate(); - MRole role = MRole.getDefault(); - child.query (false, 0, role.getMaxQueryRecords()); - } - - public GridController getChild() { - return child; - } -} diff --git a/org.adempiere.ui.swing/src/org/compiere/grid/RecordAccessDialog.java b/org.adempiere.ui.swing/src/org/compiere/grid/RecordAccessDialog.java deleted file mode 100644 index ddc5047640..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/grid/RecordAccessDialog.java +++ /dev/null @@ -1,351 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ -package org.compiere.grid; - -import java.awt.BorderLayout; -import java.awt.Dimension; -import java.awt.event.ActionEvent; -import java.sql.PreparedStatement; -import java.sql.ResultSet; -import java.util.ArrayList; -import java.util.logging.Level; - -import javax.swing.JFrame; -import javax.swing.JLabel; - -import org.compiere.apps.AEnv; -import org.compiere.apps.ALayout; -import org.compiere.apps.ALayoutConstraint; -import org.compiere.apps.ConfirmPanel; -import org.compiere.model.MRecordAccess; -import org.compiere.model.MRole; -import org.compiere.swing.CButton; -import org.compiere.swing.CCheckBox; -import org.compiere.swing.CComboBox; -import org.compiere.swing.CDialog; -import org.compiere.swing.CLabel; -import org.compiere.swing.CPanel; -import org.compiere.util.CLogger; -import org.compiere.util.DB; -import org.compiere.util.Env; -import org.compiere.util.KeyNamePair; -import org.compiere.util.Msg; - - -/** - * Record Access Dialog - * - * @author Jorg Janke - * @version $Id: RecordAccessDialog.java,v 1.3 2006/07/30 00:51:28 jjanke Exp $ - */ -public class RecordAccessDialog extends CDialog -{ - /** - * - */ - private static final long serialVersionUID = -5208621373205009190L; - - /** - * Record Access Dialog - * @param owner owner - * @param AD_Table_ID table - * @param Record_ID record - */ - public RecordAccessDialog(JFrame owner, int AD_Table_ID, int Record_ID) - { - super(owner, Msg.translate(Env.getCtx(), "RecordAccessDialog")); - if (log.isLoggable(Level.INFO)) log.info("AD_Table_ID=" + AD_Table_ID + ", Record_ID=" + Record_ID); - m_AD_Table_ID = AD_Table_ID; - m_Record_ID = Record_ID; - try - { - dynInit(); - jbInit(); - } - catch (Exception e) - { - log.log(Level.SEVERE, "", e); - } - AEnv.showCenterWindow(owner, this); - } // RecordAccessDialog - - private int m_AD_Table_ID; - private int m_Record_ID; - private ArrayList m_recordAccesss = new ArrayList(); - private int m_currentRow = 0; - private MRecordAccess m_currentData = null; - private CLogger log = CLogger.getCLogger(getClass()); - - private CPanel centerPanel = new CPanel(new ALayout()); - private BorderLayout mainLayout = new BorderLayout(); - - private CLabel roleLabel = new CLabel(Msg.translate(Env.getCtx(), "AD_Role_ID")); - private CComboBoxroleField = null; - private CCheckBox cbActive = new CCheckBox(Msg.translate(Env.getCtx(), "IsActive")); - private CCheckBox cbExclude = new CCheckBox(Msg.translate(Env.getCtx(), "IsExclude")); - private CCheckBox cbReadOnly = new CCheckBox(Msg.translate(Env.getCtx(), "IsReadOnly")); - private CCheckBox cbDependent = new CCheckBox(Msg.translate(Env.getCtx(), "IsDependentEntities")); - private CButton bDelete = AEnv.getButton("Delete"); - private CButton bNew = AEnv.getButton("New"); - private JLabel rowNoLabel = new JLabel(); - - private CButton bUp = AEnv.getButton("Previous"); - private CButton bDown = AEnv.getButton("Next"); - - private ConfirmPanel confirmPanel = new ConfirmPanel(true); - - /** - * Dynamic Init - */ - private void dynInit() - { - // Load Roles - String sql = MRole.getDefault().addAccessSQL( - "SELECT AD_Role_ID, Name FROM AD_Role ORDER BY 2", - "AD_Role", MRole.SQL_NOTQUALIFIED, MRole.SQL_RO); - roleField = new CComboBox(DB.getKeyNamePairs(sql, false)); - - // Load Record Access for all roles - sql = "SELECT * FROM AD_Record_Access " - + "WHERE AD_Table_ID=? AND Record_ID=? AND AD_Client_ID=?"; - PreparedStatement pstmt = null; - ResultSet rs = null; - try - { - pstmt = DB.prepareStatement(sql, null); - pstmt.setInt(1, m_AD_Table_ID); - pstmt.setInt(2, m_Record_ID); - pstmt.setInt(3, Env.getAD_Client_ID(Env.getCtx())); - rs = pstmt.executeQuery(); - while (rs.next()) - m_recordAccesss.add(new MRecordAccess(Env.getCtx(), rs, null)); - } - catch (Exception e) - { - log.log(Level.SEVERE, sql, e); - } - finally - { - DB.close(rs, pstmt); - rs = null; - pstmt = null; - } - if (log.isLoggable(Level.FINE)) log.fine("#" + m_recordAccesss.size()); - setLine(0, false); - } // dynInit - - /** - * Static Init - * @throws Exception - */ - private void jbInit() throws Exception - { - this.getContentPane().setLayout(mainLayout); - this.getContentPane().add(centerPanel, BorderLayout.CENTER); - this.getContentPane().add(confirmPanel, BorderLayout.SOUTH); - // - centerPanel.add(bUp, new ALayoutConstraint(0,0)); - centerPanel.add(bNew, new ALayoutConstraint(0,6)); - centerPanel.add(roleLabel, new ALayoutConstraint(1,0)); - centerPanel.add(roleField, null); - centerPanel.add(cbActive, null); - centerPanel.add(cbExclude, null); - centerPanel.add(cbReadOnly, null); - centerPanel.add(cbDependent, null); - centerPanel.add(bDelete, null); - centerPanel.add(bDown, new ALayoutConstraint(2,0)); - centerPanel.add(rowNoLabel, new ALayoutConstraint(2,6)); - // - Dimension size = centerPanel.getPreferredSize(); - size.width = 600; - centerPanel.setPreferredSize(size); - // - bUp.addActionListener(this); - bDown.addActionListener(this); - bDelete.addActionListener(this); - bNew.addActionListener(this); - confirmPanel.addActionListener(this); - } // jbInit - - /** - * Set Line - * @param rowDelta delta to current row - * @param newRecord new - */ - private void setLine (int rowDelta, boolean newRecord) - { - if (log.isLoggable(Level.FINE)) log.fine("delta=" + rowDelta + ", new=" + newRecord - + " - currentRow=" + m_currentRow + ", size=" + m_recordAccesss.size()); - int maxIndex = 0; - // nothing defined - if (m_recordAccesss.size() == 0) - { - m_currentRow = 0; - maxIndex = 0; - newRecord = true; - setLine(null); - } - else if (newRecord) - { - m_currentRow = m_recordAccesss.size(); - maxIndex = m_currentRow; - setLine(null); - } - else - { - m_currentRow += rowDelta; - maxIndex = m_recordAccesss.size() - 1; - if (m_currentRow < 0) - m_currentRow = 0; - else if (m_currentRow > maxIndex) - m_currentRow = maxIndex; - // - MRecordAccess ra = (MRecordAccess)m_recordAccesss.get(m_currentRow); - setLine(ra); - } - // Label - StringBuilder txt = new StringBuilder(); - if (newRecord) - txt.append("+"); - txt.append(m_currentRow+1).append("/").append(maxIndex+1); - rowNoLabel.setText(txt.toString()); - // set up/down - bUp.setEnabled(m_currentRow > 0); - bDown.setEnabled(m_currentRow < maxIndex); - } // setLine - - /** - * Set Selection - * @param ra record access - */ - private void setLine (MRecordAccess ra) - { - int AD_Role_ID = 0; - boolean active = true; - boolean exclude = true; - boolean readonly = false; - boolean dependent = false; - // - if (ra != null) - { - AD_Role_ID = ra.getAD_Role_ID(); - active = ra.isActive(); - exclude = ra.isExclude(); - readonly = ra.isReadOnly(); - dependent = ra.isDependentEntities(); - } - cbActive.setSelected(active); - cbExclude.setSelected(exclude); - cbReadOnly.setSelected(readonly); - cbDependent.setSelected(dependent); - bDelete.setEnabled(ra != null); - // - KeyNamePair selection = null; - for (int i = 0; i < roleField.getItemCount(); i++) - { - KeyNamePair pp = (KeyNamePair)roleField.getItemAt(i); - if (pp.getKey() == AD_Role_ID) - selection = pp; - } - if (selection != null && ra != null) - { - roleField.setSelectedItem(selection); - m_currentData = ra; - if (log.isLoggable(Level.FINE)) log.fine("" + ra); - } - else - m_currentData = null; - } // setLine - - /** - * Action Listener - * @param e event - */ - public void actionPerformed(ActionEvent e) - { - if (e.getSource() == bUp) - setLine(-1, false); - else if (e.getSource() == bDown) - setLine(+1, false); - else if (e.getSource() == bNew) - setLine(0, true); - else - { - if (e.getSource() == bDelete) - cmd_delete(); - else if (e.getActionCommand().equals(ConfirmPanel.A_OK)) - { - if (!cmd_save()) - return; - } - dispose(); - } - } // actionPerformed - - /** - * Save Command - * @return true if saved - */ - private boolean cmd_save() - { - KeyNamePair pp = (KeyNamePair)roleField.getSelectedItem(); - roleField.setBackground(pp == null); - if (pp == null) - return false; - int AD_Role_ID = pp.getKey(); - // - boolean isActive = cbActive.isSelected(); - boolean isExclude = cbExclude.isSelected(); - boolean isReadOnly = cbReadOnly.isSelected(); - boolean isDependentEntities = cbDependent.isSelected(); - // - if (m_currentData == null) - { - m_currentData = new MRecordAccess (Env.getCtx(), AD_Role_ID, m_AD_Table_ID, m_Record_ID, null); - m_recordAccesss.add(m_currentData); - m_currentRow = m_recordAccesss.size()-1; - } - m_currentData.setIsActive(isActive); - m_currentData.setIsExclude(isExclude); - m_currentData.setIsReadOnly(isReadOnly); - m_currentData.setIsDependentEntities(isDependentEntities); - boolean success = m_currentData.save(); - // - if (log.isLoggable(Level.FINE)) log.fine("Success=" + success); - return success; - } // cmd_save - - /** - * Delete Command - * @return true if deleted - */ - private boolean cmd_delete() - { - boolean success = false; - if (m_currentData == null) - log.log(Level.SEVERE, "No data"); - else - { - success = m_currentData.delete(true); - m_currentData = null; - m_recordAccesss.remove(m_currentRow); - if (log.isLoggable(Level.FINE)) log.fine("Success=" + success); - } - return success; - } // cmd_delete - -} // RecordAccessDialog diff --git a/org.adempiere.ui.swing/src/org/compiere/grid/VCreateFromDepositBatchUI.java b/org.adempiere.ui.swing/src/org/compiere/grid/VCreateFromDepositBatchUI.java deleted file mode 100644 index 8f07f32ab6..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/grid/VCreateFromDepositBatchUI.java +++ /dev/null @@ -1,337 +0,0 @@ -/****************************************************************************** - * Copyright (C) 2013 Elaine Tan * - * Copyright (C) 2013 Trek Global - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - *****************************************************************************/ -package org.compiere.grid; - -import static org.compiere.model.SystemIDs.COLUMN_C_BANKSTATEMENT_C_BANKACCOUNT_ID; - -import java.awt.BorderLayout; -import java.awt.Cursor; -import java.awt.GridBagConstraints; -import java.awt.GridBagLayout; -import java.awt.Insets; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.sql.Timestamp; -import java.util.Vector; -import java.util.logging.Level; - -import javax.swing.JLabel; -import javax.swing.table.DefaultTableModel; - -import org.compiere.apps.ADialog; -import org.compiere.apps.AEnv; -import org.compiere.apps.ConfirmPanel; -import org.compiere.grid.ed.VDate; -import org.compiere.grid.ed.VLookup; -import org.compiere.grid.ed.VNumber; -import org.compiere.grid.ed.VString; -import org.compiere.model.GridTab; -import org.compiere.model.MBankStatement; -import org.compiere.model.MColumn; -import org.compiere.model.MLookup; -import org.compiere.model.MLookupFactory; -import org.compiere.model.MPayment; -import org.compiere.swing.CButton; -import org.compiere.swing.CLabel; -import org.compiere.swing.CPanel; -import org.compiere.swing.CTextField; -import org.compiere.util.CLogger; -import org.compiere.util.DisplayType; -import org.compiere.util.Env; -import org.compiere.util.Msg; - -/** - * - * @author Elaine - * - */ -public class VCreateFromDepositBatchUI extends CreateFromDepositBatch implements ActionListener -{ - private VCreateFromDialog dialog; - - public VCreateFromDepositBatchUI(GridTab mTab) - { - super(mTab); - if (log.isLoggable(Level.INFO)) log.info(getGridTab().toString()); - - dialog = new VCreateFromDialog(this, getGridTab().getWindowNo(), true); - - p_WindowNo = getGridTab().getWindowNo(); - - try - { - if (!dynInit()) - return; - jbInit(); - - setInitOK(true); - } - catch(Exception e) - { - log.log(Level.SEVERE, "", e); - setInitOK(false); - } - AEnv.positionCenterWindow(AEnv.getWindow(p_WindowNo), dialog); - } // VCreateFrom - - /** Window No */ - private int p_WindowNo; - - /** Logger */ - private CLogger log = CLogger.getCLogger(getClass()); - - private JLabel bankAccountLabel = new JLabel(); - protected VLookup bankAccountField; - - private CLabel documentNoLabel = new CLabel(Msg.translate(Env.getCtx(), "DocumentNo")); - protected CTextField documentNoField = new CTextField(10); - - private JLabel documentTypeLabel = new JLabel(); - protected VLookup documentTypeField; - - private JLabel authorizationLabel = new JLabel(); - protected VString authorizationField = new VString(); - - private JLabel tenderTypeLabel = new JLabel(); - protected VLookup tenderTypeField; - - private CLabel amtFromLabel = new CLabel(Msg.translate(Env.getCtx(), "PayAmt")); - protected VNumber amtFromField = new VNumber("AmtFrom", false, false, true, DisplayType.Amount, Msg.translate(Env.getCtx(), "AmtFrom")); - private CLabel amtToLabel = new CLabel("-"); - protected VNumber amtToField = new VNumber("AmtTo", false, false, true, DisplayType.Amount, Msg.translate(Env.getCtx(), "AmtTo")); - - protected CLabel BPartner_idLabel = new CLabel(Msg.translate(Env.getCtx(), "BPartner")); - protected VLookup bPartnerLookup; - - private CLabel dateFromLabel = new CLabel(Msg.translate(Env.getCtx(), "DateTrx")); - protected VDate dateFromField = new VDate("DateFrom", false, false, true, DisplayType.Date, Msg.translate(Env.getCtx(), "DateFrom")); - private CLabel dateToLabel = new CLabel("-"); - protected VDate dateToField = new VDate("DateTo", false, false, true, DisplayType.Date, Msg.translate(Env.getCtx(), "DateTo")); - - - /** - * Dynamic Init - * @throws Exception if Lookups cannot be initialized - * @return true if initialized - */ - public boolean dynInit() throws Exception - { - log.config(""); - - super.dynInit(); - - //Refresh button - CButton refreshButton = ConfirmPanel.createRefreshButton(false); - refreshButton.setMargin(new Insets (1, 10, 0, 10)); - refreshButton.setDefaultCapable(true); - refreshButton.addActionListener(this); - dialog.getConfirmPanel().addButton(refreshButton); - dialog.getRootPane().setDefaultButton(refreshButton); - - if (getGridTab().getValue("C_DepositBatch_ID") == null) - { - ADialog.error(0, dialog, "SaveErrorRowNotFound"); - return false; - } - - dialog.setTitle(getTitle()); - - int AD_Column_ID = COLUMN_C_BANKSTATEMENT_C_BANKACCOUNT_ID; // C_BankStatement.C_BankAccount_ID - MLookup lookup = MLookupFactory.get (Env.getCtx(), p_WindowNo, 0, AD_Column_ID, DisplayType.TableDir); - bankAccountField = new VLookup ("C_BankAccount_ID", true, true, true, lookup); - // Set Default - int C_BankAccount_ID = Env.getContextAsInt(Env.getCtx(), p_WindowNo, "C_BankAccount_ID"); - bankAccountField.setValue(Integer.valueOf(C_BankAccount_ID)); - bankAccountField.addActionListener(this); - // initial Loading - authorizationField = new VString ("authorization", false, false, true, 10, 30, null, null); - authorizationField.addActionListener(this); - - MLookup lookupDocument = MLookupFactory.get (Env.getCtx(), p_WindowNo, 0, MColumn.getColumn_ID(MPayment.Table_Name, MPayment.COLUMNNAME_C_DocType_ID), DisplayType.TableDir); - documentTypeField = new VLookup (MPayment.COLUMNNAME_C_DocType_ID,false,false,true,lookupDocument); - int C_DocType_ID = Env.getContextAsInt(Env.getCtx(), p_WindowNo, "C_DocType_ID"); - documentTypeField.setValue(Integer.valueOf(C_DocType_ID)); - documentTypeField.addActionListener(this); - - MLookup lookupTender = MLookupFactory.get (Env.getCtx(), p_WindowNo, 0, MColumn.getColumn_ID(MPayment.Table_Name, MPayment.COLUMNNAME_TenderType), DisplayType.List); - tenderTypeField = new VLookup (MPayment.COLUMNNAME_TenderType,false,false,true,lookupTender); - tenderTypeField.addActionListener(this); - - bPartnerLookup = new VLookup("C_BPartner_ID", false, false, true, - MLookupFactory.get (Env.getCtx(), p_WindowNo, 0, 3499, DisplayType.Search)); - BPartner_idLabel.setLabelFor(bPartnerLookup); - bPartnerLookup.addActionListener(this); - - Timestamp date = Env.getContextAsDate(Env.getCtx(), p_WindowNo, MBankStatement.COLUMNNAME_StatementDate); - dateToField.setValue(date); - - documentNoField.addActionListener(this); - dateFromField.addActionListener(this); - dateToField.addActionListener(this); - amtFromField.addActionListener(this); - amtToField.addActionListener(this); - - loadBankAccount(); - - return true; - } // dynInit - - /** - * Static Init. - *
    -	 *  parameterPanel
    -	 *      parameterBankPanel
    -	 *      parameterStdPanel
    -	 *          bPartner/order/invoice/shopment/licator Label/Field
    -	 *  dataPane
    -	 *  southPanel
    -	 *      confirmPanel
    -	 *      statusBar
    -	 *  
    - * @throws Exception - */ - private void jbInit() throws Exception - { - bankAccountLabel.setText(Msg.translate(Env.getCtx(), "C_BankAccount_ID")); - authorizationLabel.setText(Msg.translate(Env.getCtx(), "R_AuthCode")); - - documentTypeLabel.setText(Msg.translate(Env.getCtx(), "C_DocType_ID")); - tenderTypeLabel.setText(Msg.translate(Env.getCtx(), "TenderType")); - - documentNoLabel.setLabelFor(documentNoField); - dateFromLabel.setLabelFor(dateFromField); - dateFromField.setToolTipText(Msg.translate(Env.getCtx(), "DateFrom")); - dateToLabel.setLabelFor(dateToField); - dateToField.setToolTipText(Msg.translate(Env.getCtx(), "DateTo")); - amtFromLabel.setLabelFor(amtFromField); - amtFromField.setToolTipText(Msg.translate(Env.getCtx(), "AmtFrom")); - amtToLabel.setLabelFor(amtToField); - amtToField.setToolTipText(Msg.translate(Env.getCtx(), "AmtTo")); - - CPanel parameterPanel = dialog.getParameterPanel(); - parameterPanel.setLayout(new BorderLayout()); - - CPanel parameterBankPanel = new CPanel(); - parameterBankPanel.setLayout(new GridBagLayout()); - parameterPanel.add(parameterBankPanel, BorderLayout.CENTER); - - parameterBankPanel.add(bankAccountLabel, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); - if (bankAccountField != null) - parameterBankPanel.add(bankAccountField, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 0, 5, 5), 0, 0)); - - parameterBankPanel.add(documentTypeLabel, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); - if(documentTypeField!= null) - parameterBankPanel.add(documentTypeField, new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 0, 5, 5), 0, 0)); - - parameterBankPanel.add(tenderTypeLabel, new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); - if(tenderTypeField!=null) - parameterBankPanel.add(tenderTypeField, new GridBagConstraints(1, 2, 1, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 0, 5, 5), 0, 0)); - - parameterBankPanel.add(BPartner_idLabel, new GridBagConstraints(0, 3, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); - parameterBankPanel.add(bPartnerLookup, new GridBagConstraints(1, 3, 1, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 0, 5, 5), 0, 0)); - - parameterBankPanel.add(documentNoLabel, new GridBagConstraints(2, 0, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); - parameterBankPanel.add(documentNoField, new GridBagConstraints(3, 0, 1, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 0, 5, 5), 0, 0)); - - parameterBankPanel.add(authorizationLabel, new GridBagConstraints(2, 1, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); - parameterBankPanel.add(authorizationField, new GridBagConstraints(3, 1, 1, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 0, 5, 5), 0, 0)); - - parameterBankPanel.add(amtFromLabel, new GridBagConstraints(2, 2, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); - parameterBankPanel.add(amtFromField, new GridBagConstraints(3, 2, 1, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 0, 5, 5), 0, 0)); - parameterBankPanel.add(amtToLabel, new GridBagConstraints(4, 2, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); - parameterBankPanel.add(amtToField, new GridBagConstraints(5, 2, 1, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 0, 5, 5), 0, 0)); - - parameterBankPanel.add(dateFromLabel, new GridBagConstraints(2, 3, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); - parameterBankPanel.add(dateFromField, new GridBagConstraints(3, 3, 1, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 0, 5, 5), 0, 0)); - parameterBankPanel.add(dateToLabel, new GridBagConstraints(4, 3, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); - parameterBankPanel.add(dateToField, new GridBagConstraints(5, 3, 1, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 0, 5, 5), 0, 0)); - - } // jbInit - - /*************************************************************************/ - - /** - * Action Listener - * @param e event - */ - public void actionPerformed(ActionEvent e) - { - if (log.isLoggable(Level.CONFIG)) log.config("Action=" + e.getActionCommand()); -// Object source = e.getSource(); - if(e.getActionCommand().equals(ConfirmPanel.A_REFRESH)) - { - Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR); - loadBankAccount(); - dialog.tableChanged(null); - Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR); - } - } // actionPerformed - - protected void loadBankAccount() - { - loadTableOIS(getBankAccountData(bankAccountField.getValue(), bPartnerLookup.getValue(), - documentNoField.getText(), dateFromField.getValue(), dateToField.getValue(), - amtFromField.getValue(), amtToField.getValue(), - documentTypeField.getValue(), tenderTypeField.getValue(), authorizationField.getText())); - } - - protected void loadTableOIS (Vector data) - { - // Remove previous listeners - dialog.getMiniTable().getModel().removeTableModelListener(dialog); - // Set Model - DefaultTableModel model = new DefaultTableModel(data, getOISColumnNames()); - model.addTableModelListener(dialog); - dialog.getMiniTable().setModel(model); - // - - configureMiniTable(dialog.getMiniTable()); - } - - public void showWindow() - { - dialog.setVisible(true); - } - - public void closeWindow() - { - dialog.dispose(); - } - - @Override - public Object getWindow() - { - return dialog; - } -} diff --git a/org.adempiere.ui.swing/src/org/compiere/grid/VCreateFromDialog.java b/org.adempiere.ui.swing/src/org/compiere/grid/VCreateFromDialog.java deleted file mode 100644 index 73b8f42026..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/grid/VCreateFromDialog.java +++ /dev/null @@ -1,227 +0,0 @@ -/****************************************************************************** - * Copyright (C) 2009 Low Heng Sin * - * Copyright (C) 2009 Idalica Corporation * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - *****************************************************************************/ -package org.compiere.grid; - -import java.awt.BorderLayout; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; - -import javax.swing.JScrollPane; -import javax.swing.event.TableModelEvent; -import javax.swing.event.TableModelListener; -import javax.swing.table.TableModel; - -import org.compiere.apps.ADialog; -import org.compiere.apps.AEnv; -import org.compiere.apps.AppsAction; -import org.compiere.apps.ConfirmPanel; -import org.compiere.apps.StatusBar; -import org.compiere.minigrid.MiniTable; -import org.compiere.swing.CDialog; -import org.compiere.swing.CPanel; -import org.compiere.swing.CToggleButton; -import org.compiere.util.Env; -import org.compiere.util.Msg; -import org.compiere.util.Trx; -import org.compiere.util.TrxRunnable; - -public class VCreateFromDialog extends CDialog implements ActionListener, TableModelListener -{ - - /** - * - */ - private static final long serialVersionUID = -8242250391030501785L; - private CreateFrom createFrom; - private int windowNo; - - private CPanel parameterPanel = new CPanel(); - private ConfirmPanel confirmPanel = new ConfirmPanel(true); - private StatusBar statusBar = new StatusBar(); - private MiniTable dataTable = new MiniTable(); - - private static final String SELECT_DESELECT_ALL = "SelectAll"; - protected AppsAction selectDeselectAllAction = new AppsAction (SELECT_DESELECT_ALL, null, Msg.getMsg(Env.getCtx(), SELECT_DESELECT_ALL), true); - - public VCreateFromDialog(CreateFrom createFrom, int windowNo, boolean modal) - { - super(AEnv.getWindow(windowNo), modal); - - this.createFrom = createFrom; - this.windowNo = windowNo; - - try - { - jbInit(); - confirmPanel.addActionListener(this); - - statusBar.setStatusDB(""); - tableChanged(null); - createFrom.setInitOK(true); - } - catch(Exception e) - { - createFrom.setInitOK(false); - } - } - - protected void jbInit() throws Exception - { - getContentPane().add(parameterPanel, BorderLayout.NORTH); - - JScrollPane dataPane = new JScrollPane(); - getContentPane().add(dataPane, BorderLayout.CENTER); - dataPane.getViewport().add(dataTable, null); - - CToggleButton selectAllButton = (CToggleButton)selectDeselectAllAction.getButton(); - selectAllButton.setMargin(ConfirmPanel.s_insets); - selectAllButton.addActionListener(this); - confirmPanel.addComponent(selectAllButton); - - CPanel southPanel = new CPanel(); - getContentPane().add(southPanel, BorderLayout.SOUTH); - BorderLayout southLayout = new BorderLayout(); - southPanel.setLayout(southLayout); - southPanel.add(confirmPanel, BorderLayout.CENTER); - southPanel.add(statusBar, BorderLayout.SOUTH); - } - - public void actionPerformed(ActionEvent e) - { - if (e.getActionCommand().equals(ConfirmPanel.A_OK)) - { - try - { - Trx.run(new TrxRunnable() - { - public void run(String trxName) - { - if (save(trxName)) - { - dispose(); - } - } - }); - } - catch (Exception ex) - { - ADialog.error(windowNo, this, "Error", ex.getLocalizedMessage()); - } - } - // Cancel - else if (e.getActionCommand().equals(ConfirmPanel.A_CANCEL)) - { - dispose(); - } - // Select All - // Trifon - else if (e.getActionCommand().equals(SELECT_DESELECT_ALL)) - { - TableModel model = dataTable.getModel(); - model.removeTableModelListener(this); - - // select or deselect all as required - int rows = model.getRowCount(); - Boolean selectAll = selectDeselectAllAction.isPressed() ? Boolean.FALSE : Boolean.TRUE; - for (int i = 0; i < rows; i++) - model.setValueAt(selectAll, i, 0); - - model.addTableModelListener(this); - - info(); - } - } - - public boolean save(String trxName) - { - dataTable.stopEditor(true); - - TableModel model = dataTable.getModel(); - int rows = model.getRowCount(); - if (rows == 0) - return false; - - return createFrom.save(dataTable, trxName); - } - - public void tableChanged (TableModelEvent e) - { - int type = -1; - if (e != null) - { - type = e.getType(); - if (type != TableModelEvent.UPDATE) - return; - - if (e.getColumn() == 0) - { - TableModel model = dataTable.getModel(); - Boolean isPressed = (Boolean)model.getValueAt(0, 0); - int rows = model.getRowCount(); - boolean equals = true; - for (int i = 1; equals && i < rows; i++) - { - equals = isPressed.equals(model.getValueAt(i, 0)); - } - - if (equals) { - selectDeselectAllAction.setPressed(isPressed); - } - } - } - info(); - dataTable.repaint(); - } - - public void info() - { - TableModel model = dataTable.getModel(); - int rows = model.getRowCount(); - int count = 0; - for (int i = 0; i < rows; i++) - { - if (((Boolean)model.getValueAt(i, 0)).booleanValue()) - count++; - } - setStatusLine(count, null); - - createFrom.info(dataTable, statusBar); - } - - public void setStatusLine(int selectedRowCount, String text) - { - StringBuilder sb = new StringBuilder(String.valueOf(selectedRowCount)); - if (text != null && text.trim().length() > 0) { - sb.append(" - ").append(text); - } - statusBar.setStatusLine(sb.toString()); - // - confirmPanel.getOKButton().setEnabled(selectedRowCount > 0); - } - - public MiniTable getMiniTable() - { - return dataTable; - } - - public CPanel getParameterPanel() - { - return parameterPanel; - } - - public ConfirmPanel getConfirmPanel() - { - return confirmPanel; - } -} \ No newline at end of file diff --git a/org.adempiere.ui.swing/src/org/compiere/grid/VCreateFromFactory.java b/org.adempiere.ui.swing/src/org/compiere/grid/VCreateFromFactory.java deleted file mode 100644 index 2eb8f4e4f4..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/grid/VCreateFromFactory.java +++ /dev/null @@ -1,35 +0,0 @@ -/****************************************************************************** - * Copyright (C) 2009 Low Heng Sin * - * Copyright (C) 2009 Idalica Corporation * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - *****************************************************************************/ -package org.compiere.grid; - -import java.util.List; - -import org.adempiere.base.Service; -import org.compiere.model.GridTab; - -public class VCreateFromFactory -{ - public static ICreateFrom create (GridTab mTab) - { - ICreateFrom createFrom = null; - List factories = Service.locator().list(ICreateFromFactory.class).getServices(); - for (ICreateFromFactory factory : factories) - { - createFrom = factory.create(mTab); - if (createFrom != null) - break; - } - return createFrom; - } -} \ No newline at end of file diff --git a/org.adempiere.ui.swing/src/org/compiere/grid/VCreateFromInvoiceUI.java b/org.adempiere.ui.swing/src/org/compiere/grid/VCreateFromInvoiceUI.java deleted file mode 100644 index 71ee9e351b..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/grid/VCreateFromInvoiceUI.java +++ /dev/null @@ -1,396 +0,0 @@ -/****************************************************************************** - * Copyright (C) 2009 Low Heng Sin * - * Copyright (C) 2009 Idalica Corporation * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - *****************************************************************************/ -package org.compiere.grid; - -import java.awt.BorderLayout; -import java.awt.GridBagConstraints; -import java.awt.GridBagLayout; -import java.awt.Insets; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.beans.PropertyChangeEvent; -import java.beans.VetoableChangeListener; -import java.math.BigDecimal; -import java.util.ArrayList; -import java.util.Vector; -import java.util.logging.Level; - -import javax.swing.JComboBox; -import javax.swing.JLabel; -import javax.swing.table.DefaultTableModel; - -import org.compiere.apps.AEnv; -import org.compiere.grid.ed.VLookup; -import org.compiere.model.GridTab; -import org.compiere.model.MDocType; -import org.compiere.model.MLookup; -import org.compiere.model.MLookupFactory; -import static org.compiere.model.SystemIDs.*; -import org.compiere.swing.CPanel; -import org.compiere.util.CLogger; -import org.compiere.util.DisplayType; -import org.compiere.util.Env; -import org.compiere.util.KeyNamePair; -import org.compiere.util.Msg; - -public class VCreateFromInvoiceUI extends CreateFromInvoice implements ActionListener, VetoableChangeListener -{ - - private VCreateFromDialog dialog; - - public VCreateFromInvoiceUI(GridTab mTab) - { - super(mTab); - if (log.isLoggable(Level.INFO)) log.info(getGridTab().toString()); - - dialog = new VCreateFromDialog(this, getGridTab().getWindowNo(), true); - - p_WindowNo = getGridTab().getWindowNo(); - - try - { - if (!dynInit()) - return; - jbInit(); - - setInitOK(true); - } - catch(Exception e) - { - log.log(Level.SEVERE, "", e); - setInitOK(false); - } - AEnv.positionCenterWindow(AEnv.getWindow(p_WindowNo), dialog); - } // VCreateFrom - - /** Window No */ - private int p_WindowNo; - - /** Logger */ - private CLogger log = CLogger.getCLogger(getClass()); - - // - private JLabel bPartnerLabel = new JLabel(); - private VLookup bPartnerField; - - private JLabel orderLabel = new JLabel(); - private JComboBox orderField = new JComboBox(); - - private JLabel shipmentLabel = new JLabel(); - private JComboBox shipmentField = new JComboBox(); - - /** Label for the rma selection */ - private JLabel rmaLabel = new JLabel(); - /** Combo box for selecting RMA document */ - private JComboBox rmaField = new JComboBox(); - - private boolean isCreditMemo = false; - - /** - * Dynamic Init - * @throws Exception if Lookups cannot be initialized - * @return true if initialized - */ - public boolean dynInit() throws Exception - { - log.config(""); - - super.dynInit(); - - dialog.setTitle(getTitle()); - - // RMA Selection option should only be available for AP Credit Memo - Integer docTypeId = (Integer)getGridTab().getValue("C_DocTypeTarget_ID"); - MDocType docType = MDocType.get(Env.getCtx(), docTypeId); - if (!MDocType.DOCBASETYPE_APCreditMemo.equals(docType.getDocBaseType())) - { - rmaLabel.setVisible(false); - rmaField.setVisible(false); - } - - isCreditMemo = MDocType.DOCBASETYPE_APCreditMemo.equals(docType.getDocBaseType()) - || MDocType.DOCBASETYPE_ARCreditMemo.equals(docType.getDocBaseType()); - - initBPartner(true); - bPartnerField.addVetoableChangeListener(this); - - return true; - } // dynInit - - /** - * Static Init. - *
    -	 *  parameterPanel
    -	 *      parameterBankPanel
    -	 *      parameterStdPanel
    -	 *          bPartner/order/invoice/shopment/licator Label/Field
    -	 *  dataPane
    -	 *  southPanel
    -	 *      confirmPanel
    -	 *      statusBar
    -	 *  
    - * @throws Exception - */ - private void jbInit() throws Exception - { - bPartnerLabel.setText(Msg.getElement(Env.getCtx(), "C_BPartner_ID")); - orderLabel.setText(Msg.getElement(Env.getCtx(), "C_Order_ID", false)); - shipmentLabel.setText(Msg.getElement(Env.getCtx(), "M_InOut_ID", false)); - rmaLabel.setText(Msg.translate(Env.getCtx(), "M_RMA_ID")); - - CPanel parameterPanel = dialog.getParameterPanel(); - parameterPanel.setLayout(new BorderLayout()); - - CPanel parameterStdPanel = new CPanel(new GridBagLayout()); - - parameterPanel.add(parameterStdPanel, BorderLayout.CENTER); - - parameterStdPanel.add(bPartnerLabel, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); - if (bPartnerField != null) - parameterStdPanel.add(bPartnerField, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 0, 5, 5), 0, 0)); - - parameterStdPanel.add(orderLabel, new GridBagConstraints(2, 0, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); - parameterStdPanel.add(orderField, new GridBagConstraints(3, 0, 1, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 0, 5, 5), 0, 0)); - parameterStdPanel.add(shipmentLabel, new GridBagConstraints(2, 2, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); - parameterStdPanel.add(shipmentField, new GridBagConstraints(3, 2, 1, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 0, 5, 5), 0, 0)); - // Add RMA document selection to panel - parameterStdPanel.add(rmaLabel, new GridBagConstraints(2, 3, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); - parameterStdPanel.add(rmaField, new GridBagConstraints(3, 3, 1, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 0, 5, 5), 0, 0)); - } // jbInit - - /*************************************************************************/ - - private boolean m_actionActive = false; - - /** - * Action Listener - * @param e event - */ - public void actionPerformed(ActionEvent e) - { - if (log.isLoggable(Level.CONFIG)) log.config("Action=" + e.getActionCommand()); - - if (m_actionActive) - return; - m_actionActive = true; - if (log.isLoggable(Level.CONFIG)) log.config("Action=" + e.getActionCommand()); - // Order - if (e.getSource().equals(orderField)) - { - KeyNamePair pp = (KeyNamePair)orderField.getSelectedItem(); - int C_Order_ID = 0; - if (pp != null) - C_Order_ID = pp.getKey(); - // set Invoice, RMA and Shipment to Null - rmaField.setSelectedIndex(-1); - shipmentField.setSelectedIndex(-1); - loadOrder(C_Order_ID, true); - } - // Shipment - else if (e.getSource().equals(shipmentField)) - { - KeyNamePair pp = (KeyNamePair)shipmentField.getSelectedItem(); - int M_InOut_ID = 0; - if (pp != null) - M_InOut_ID = pp.getKey(); - // set Order, RMA and Invoice to Null - orderField.setSelectedIndex(-1); - rmaField.setSelectedIndex(-1); - loadShipment(M_InOut_ID); - } - // RMA - else if (e.getSource().equals(rmaField)) - { - KeyNamePair pp = (KeyNamePair)rmaField.getSelectedItem(); - int M_RMA_ID = 0; - if (pp != null) - M_RMA_ID = pp.getKey(); - // set Order and Invoice to Null - orderField.setSelectedIndex(-1); - shipmentField.setSelectedIndex(-1); - loadRMA(M_RMA_ID); - } - m_actionActive = false; - } // actionPerformed - - /** - * Change Listener - * @param e event - */ - public void vetoableChange (PropertyChangeEvent e) - { - if (log.isLoggable(Level.CONFIG)) log.config(e.getPropertyName() + "=" + e.getNewValue()); - - // BPartner - load Order/Invoice/Shipment - if (e.getPropertyName().equals("C_BPartner_ID")) - { - int C_BPartner_ID = ((Integer)e.getNewValue()).intValue(); - initBPOrderDetails (C_BPartner_ID, true); - } - dialog.tableChanged(null); - } // vetoableChange - - /************************************************************************** - * Load BPartner Field - * @param forInvoice true if Invoices are to be created, false receipts - * @throws Exception if Lookups cannot be initialized - */ - protected void initBPartner (boolean forInvoice) throws Exception - { - // load BPartner - int AD_Column_ID = COLUMN_C_INVOICE_C_BPARTNER_ID; // C_Invoice.C_BPartner_ID - MLookup lookup = MLookupFactory.get (Env.getCtx(), p_WindowNo, 0, AD_Column_ID, DisplayType.Search); - bPartnerField = new VLookup ("C_BPartner_ID", true, false, true, lookup); - // - int C_BPartner_ID = Env.getContextAsInt(Env.getCtx(), p_WindowNo, "C_BPartner_ID"); - bPartnerField.setValue(Integer.valueOf(C_BPartner_ID)); - - // initial loading - initBPOrderDetails(C_BPartner_ID, forInvoice); - } // initBPartner - - /** - * Load PBartner dependent Order/Invoice/Shipment Field. - * @param C_BPartner_ID BPartner - * @param forInvoice for invoice - */ - protected void initBPOrderDetails (int C_BPartner_ID, boolean forInvoice) - { - if (log.isLoggable(Level.CONFIG)) log.config("C_BPartner_ID=" + C_BPartner_ID); - KeyNamePair pp = new KeyNamePair(0,""); - // load PO Orders - Closed, Completed - orderField.removeActionListener(this); - orderField.removeAllItems(); - orderField.addItem(pp); - - ArrayList list = loadOrderData(C_BPartner_ID, forInvoice, false, isCreditMemo); - for(KeyNamePair knp : list) - orderField.addItem(knp); - - orderField.setSelectedIndex(0); - orderField.addActionListener(this); - dialog.pack(); - - initBPDetails(C_BPartner_ID); - } // initBPartnerOIS - - public void initBPDetails(int C_BPartner_ID) - { - initBPShipmentDetails(C_BPartner_ID); - initBPRMADetails(C_BPartner_ID); - } - - /** - * Load PBartner dependent Order/Invoice/Shipment Field. - * @param C_BPartner_ID - */ - private void initBPShipmentDetails(int C_BPartner_ID) - { - if (log.isLoggable(Level.CONFIG)) log.config("C_BPartner_ID" + C_BPartner_ID); - - // load Shipments (Receipts) - Completed, Closed - shipmentField.removeActionListener(this); - shipmentField.removeAllItems(); - // None - KeyNamePair pp = new KeyNamePair(0,""); - shipmentField.addItem(pp); - - ArrayList list = loadShipmentData(C_BPartner_ID); - for(KeyNamePair knp : list) - shipmentField.addItem(knp); - - shipmentField.setSelectedIndex(0); - shipmentField.addActionListener(this); - } - - /** - * Load RMA that are candidates for shipment - * @param C_BPartner_ID BPartner - */ - private void initBPRMADetails(int C_BPartner_ID) - { - rmaField.removeActionListener(this); - rmaField.removeAllItems(); - // None - KeyNamePair pp = new KeyNamePair(0,""); - rmaField.addItem(pp); - - ArrayList list = loadRMAData(C_BPartner_ID); - for(KeyNamePair knp : list) - rmaField.addItem(knp); - - rmaField.setSelectedIndex(0); - rmaField.addActionListener(this); - } - - /** - * Load Data - Order - * @param C_Order_ID Order - * @param forInvoice true if for invoice vs. delivery qty - */ - protected void loadOrder (int C_Order_ID, boolean forInvoice) - { - loadTableOIS(getOrderData(C_Order_ID, forInvoice, isCreditMemo)); - } // LoadOrder - - protected void loadRMA (int M_RMA_ID) - { - loadTableOIS(getRMAData(M_RMA_ID)); - } - - protected void loadShipment (int M_InOut_ID) - { - loadTableOIS(getShipmentData(M_InOut_ID)); - } - - /** - * Load Order/Invoice/Shipment data into Table - * @param data data - */ - protected void loadTableOIS (Vector data) - { - // Remove previous listeners - dialog.getMiniTable().getModel().removeTableModelListener(dialog); - // Set Model - DefaultTableModel model = new DefaultTableModel(data, getOISColumnNames()); - model.addTableModelListener(dialog); - dialog.getMiniTable().setModel(model); - // - - configureMiniTable(dialog.getMiniTable()); - } // loadOrder - - public void showWindow() - { - dialog.setVisible(true); - } - - public void closeWindow() - { - dialog.dispose(); - } - - @Override - public Object getWindow() { - return dialog; - } -} diff --git a/org.adempiere.ui.swing/src/org/compiere/grid/VCreateFromPackageShipmentUI.java b/org.adempiere.ui.swing/src/org/compiere/grid/VCreateFromPackageShipmentUI.java deleted file mode 100644 index 277aa3e9ca..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/grid/VCreateFromPackageShipmentUI.java +++ /dev/null @@ -1,111 +0,0 @@ -/****************************************************************************** - * Copyright (C) 2012 Elaine Tan * - * Copyright (C) 2012 Trek Global - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - *****************************************************************************/ -package org.compiere.grid; - -import java.util.Vector; -import java.util.logging.Level; - -import javax.swing.table.DefaultTableModel; - -import org.compiere.apps.AEnv; -import org.compiere.model.GridTab; -import org.compiere.model.MPackage; -import org.compiere.model.MPackageMPS; -import org.compiere.util.CLogger; -import org.compiere.util.Env; - -/** - * - * @author Elaine - * - */ -public class VCreateFromPackageShipmentUI extends CreateFromPackageShipment -{ - private VCreateFromDialog dialog; - - public VCreateFromPackageShipmentUI(GridTab mTab) - { - super(mTab); - if (log.isLoggable(Level.INFO)) log.info(mTab.toString()); - - dialog = new VCreateFromDialog(this, getGridTab().getWindowNo(), true); - - p_WindowNo = getGridTab().getWindowNo(); - - try - { - if (!dynInit()) - return; - - setInitOK(true); - } - catch(Exception e) - { - log.log(Level.SEVERE, "", e); - setInitOK(false); - } - AEnv.positionCenterWindow(AEnv.getWindow(p_WindowNo), dialog); - } - - /** Window No */ - private int p_WindowNo; - - /** Logger */ - private CLogger log = CLogger.getCLogger(getClass()); - - public boolean dynInit() throws Exception - { - log.config(""); - - super.dynInit(); - - dialog.setTitle(getTitle()); - - int M_PackageMPS_ID = (Integer) getGridTab().getValue(MPackageMPS.COLUMNNAME_M_PackageMPS_ID); - MPackageMPS packageMPS = new MPackageMPS(Env.getCtx(), M_PackageMPS_ID, null); - MPackage mPackage = new MPackage(Env.getCtx(), packageMPS.getM_Package_ID(), null); - loadTableOIS(getShipmentData(mPackage.getM_InOut_ID())); - - return true; - } - - protected void loadTableOIS (Vector data) - { - // Remove previous listeners - dialog.getMiniTable().getModel().removeTableModelListener(dialog); - // Set Model - DefaultTableModel model = new DefaultTableModel(data, getOISColumnNames()); - model.addTableModelListener(dialog); - dialog.getMiniTable().setModel(model); - // - - configureMiniTable(dialog.getMiniTable()); - } - - public void showWindow() - { - dialog.setVisible(true); - } - - public void closeWindow() - { - dialog.dispose(); - } - - @Override - public Object getWindow() - { - return dialog; - } -} diff --git a/org.adempiere.ui.swing/src/org/compiere/grid/VCreateFromRMAUI.java b/org.adempiere.ui.swing/src/org/compiere/grid/VCreateFromRMAUI.java deleted file mode 100644 index e489214b3d..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/grid/VCreateFromRMAUI.java +++ /dev/null @@ -1,202 +0,0 @@ -/****************************************************************************** - * Copyright (C) 2009 Low Heng Sin * - * Copyright (C) 2009 Idalica Corporation * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - *****************************************************************************/ -package org.compiere.grid; - -import java.awt.BorderLayout; -import java.awt.GridBagConstraints; -import java.awt.GridBagLayout; -import java.awt.Insets; -import java.beans.PropertyChangeEvent; -import java.beans.VetoableChangeListener; -import java.util.Vector; -import java.util.logging.Level; - -import javax.swing.JLabel; -import javax.swing.table.DefaultTableModel; - -import org.compiere.apps.AEnv; -import org.compiere.grid.ed.VLookup; -import org.compiere.model.GridTab; -import org.compiere.model.MLookup; -import org.compiere.model.MLookupFactory; -import static org.compiere.model.SystemIDs.*; -import org.compiere.swing.CPanel; -import org.compiere.util.CLogger; -import org.compiere.util.DisplayType; -import org.compiere.util.Env; -import org.compiere.util.Msg; - -public class VCreateFromRMAUI extends CreateFromRMA implements VetoableChangeListener -{ - - private VCreateFromDialog dialog; - - public VCreateFromRMAUI(GridTab mTab) - { - super(mTab); - if (log.isLoggable(Level.INFO)) log.info(getGridTab().toString()); - - dialog = new VCreateFromDialog(this, getGridTab().getWindowNo(), true); - - p_WindowNo = getGridTab().getWindowNo(); - - try - { - if (!dynInit()) - return; - jbInit(); - - setInitOK(true); - } - catch(Exception e) - { - log.log(Level.SEVERE, "", e); - setInitOK(false); - } - AEnv.positionCenterWindow(AEnv.getWindow(p_WindowNo), dialog); - } // VCreateFrom - - /** Window No */ - private int p_WindowNo; - - /** Logger */ - private CLogger log = CLogger.getCLogger(getClass()); - - // - private JLabel bPartnerLabel = new JLabel(); - private VLookup bPartnerField; - - /** - * Dynamic Init - * @throws Exception if Lookups cannot be initialized - * @return true if initialized - */ - public boolean dynInit() throws Exception - { - log.config(""); - - super.dynInit(); - - dialog.setTitle(getTitle()); - - initBPartner(true); - bPartnerField.addVetoableChangeListener(this); - - loadRMA(); - - return true; - } // dynInit - - /** - * Static Init. - *
    -	 *  parameterPanel
    -	 *      parameterBankPanel
    -	 *      parameterStdPanel
    -	 *          bPartner/order/invoice/shopment/licator Label/Field
    -	 *  dataPane
    -	 *  southPanel
    -	 *      confirmPanel
    -	 *      statusBar
    -	 *  
    - * @throws Exception - */ - private void jbInit() throws Exception - { - bPartnerLabel.setText(Msg.getElement(Env.getCtx(), "C_BPartner_ID")); - - CPanel parameterPanel = dialog.getParameterPanel(); - parameterPanel.setLayout(new BorderLayout()); - - CPanel parameterStdPanel = new CPanel(new GridBagLayout()); - - parameterPanel.add(parameterStdPanel, BorderLayout.CENTER); - - parameterStdPanel.add(bPartnerLabel, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); - if (bPartnerField != null) - parameterStdPanel.add(bPartnerField, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 0, 5, 5), 0, 0)); - } // jbInit - - /*************************************************************************/ - /** - * Change Listener - * @param e event - */ - public void vetoableChange (PropertyChangeEvent e) - { - if (log.isLoggable(Level.CONFIG)) log.config(e.getPropertyName() + "=" + e.getNewValue()); - - // BPartner - load Order/Invoice/Shipment - if (e.getPropertyName().equals("C_BPartner_ID")) - { - loadRMA(); - } - dialog.tableChanged(null); - } // vetoableChange - - /************************************************************************** - * Load BPartner Field - * @param forInvoice true if Invoices are to be created, false receipts - * @throws Exception if Lookups cannot be initialized - */ - protected void initBPartner (boolean forInvoice) throws Exception - { - // load BPartner - int AD_Column_ID = COLUMN_C_INVOICE_C_BPARTNER_ID; // C_Invoice.C_BPartner_ID - MLookup lookup = MLookupFactory.get (Env.getCtx(), p_WindowNo, 0, AD_Column_ID, DisplayType.Search); - bPartnerField = new VLookup ("C_BPartner_ID", true, false, true, lookup); - // - int C_BPartner_ID = Env.getContextAsInt(Env.getCtx(), p_WindowNo, "C_BPartner_ID"); - bPartnerField.setValue(Integer.valueOf(C_BPartner_ID)); - } // initBPartner - - protected void loadRMA() - { - loadTableOIS(getRMAData()); - } - - /** - * Load Order/Invoice/Shipment data into Table - * @param data data - */ - protected void loadTableOIS (Vector data) - { - // Remove previous listeners - dialog.getMiniTable().getModel().removeTableModelListener(dialog); - // Set Model - DefaultTableModel model = new DefaultTableModel(data, getOISColumnNames()); - model.addTableModelListener(dialog); - dialog.getMiniTable().setModel(model); - // - - configureMiniTable(dialog.getMiniTable()); - } // loadOrder - - public void showWindow() - { - dialog.setVisible(true); - } - - public void closeWindow() - { - dialog.dispose(); - } - - @Override - public Object getWindow() { - return dialog; - } -} diff --git a/org.adempiere.ui.swing/src/org/compiere/grid/VCreateFromShipmentUI.java b/org.adempiere.ui.swing/src/org/compiere/grid/VCreateFromShipmentUI.java deleted file mode 100644 index a5993a16d1..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/grid/VCreateFromShipmentUI.java +++ /dev/null @@ -1,555 +0,0 @@ -/****************************************************************************** - * Copyright (C) 2009 Low Heng Sin * - * Copyright (C) 2009 Idalica Corporation * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - *****************************************************************************/ - -package org.compiere.grid; - -import java.awt.BorderLayout; -import java.awt.Component; -import java.awt.GridBagConstraints; -import java.awt.GridBagLayout; -import java.awt.Insets; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.beans.PropertyChangeEvent; -import java.beans.VetoableChangeListener; -import java.math.BigDecimal; -import java.util.ArrayList; -import java.util.List; -import java.util.Vector; -import java.util.logging.Level; - -import javax.swing.AbstractCellEditor; -import javax.swing.JCheckBox; -import javax.swing.JComboBox; -import javax.swing.JLabel; -import javax.swing.JOptionPane; -import javax.swing.JTable; -import javax.swing.JTextField; -import javax.swing.table.DefaultTableModel; -import javax.swing.table.TableCellEditor; -import javax.swing.table.TableColumn; - -import org.compiere.apps.AEnv; -import org.compiere.grid.ed.VLocator; -import org.compiere.grid.ed.VLookup; -import org.compiere.minigrid.IMiniTable; -import org.compiere.minigrid.MiniTable; -import org.compiere.model.GridTab; -import org.compiere.model.MLocator; -import org.compiere.model.MLocatorLookup; -import org.compiere.model.MLookup; -import org.compiere.model.MLookupFactory; -import org.compiere.model.MProduct; -import org.compiere.model.Query; -import static org.compiere.model.SystemIDs.*; -import org.compiere.swing.CPanel; -import org.compiere.util.CLogger; -import org.compiere.util.DisplayType; -import org.compiere.util.Env; -import org.compiere.util.KeyNamePair; -import org.compiere.util.Msg; - -public class VCreateFromShipmentUI extends CreateFromShipment implements ActionListener, VetoableChangeListener -{ - - private VCreateFromDialog dialog; - - public VCreateFromShipmentUI(GridTab mTab) - { - super(mTab); - if (log.isLoggable(Level.INFO)) log.info(getGridTab().toString()); - - dialog = new VCreateFromDialog(this, getGridTab().getWindowNo(), true); - - p_WindowNo = getGridTab().getWindowNo(); - - try - { - if (!dynInit()) - return; - jbInit(); - - setInitOK(true); - } - catch(Exception e) - { - log.log(Level.SEVERE, "", e); - setInitOK(false); - } - AEnv.positionCenterWindow(AEnv.getWindow(p_WindowNo), dialog); - } // VCreateFrom - - /** Window No */ - private int p_WindowNo; - - /** Logger */ - private CLogger log = CLogger.getCLogger(getClass()); - - // - private JLabel bPartnerLabel = new JLabel(); - private VLookup bPartnerField; - - private JLabel orderLabel = new JLabel(); - private JComboBox orderField = new JComboBox(); - - private JLabel invoiceLabel = new JLabel(); - private JComboBox invoiceField = new JComboBox(); - - /** Label for the rma selection */ - private JLabel rmaLabel = new JLabel(); - /** Combo box for selecting RMA document */ - private JComboBox rmaField = new JComboBox(); - - private JLabel upcLabel = new JLabel(); - private JTextField upcField = new JTextField(); - - private JCheckBox sameWarehouseCb = new JCheckBox(); - private JLabel locatorLabel = new JLabel(); - private VLocator locatorField = new VLocator(); - - /** - * Dynamic Init - * @throws Exception if Lookups cannot be initialized - * @return true if initialized - */ - public boolean dynInit() throws Exception - { - log.config(""); - - super.dynInit(); - - dialog.setTitle(getTitle()); - - // load Locator - MLocatorLookup locator = new MLocatorLookup(Env.getCtx(), p_WindowNo); - locatorField = new VLocator ("M_Locator_ID", true, false, true, locator, p_WindowNo); - sameWarehouseCb.setSelected(true); - sameWarehouseCb.addActionListener(this); - - initBPartner(false); - bPartnerField.addVetoableChangeListener(this); - - return true; - } // dynInit - - /** - * Static Init. - *
    -	 *  parameterPanel
    -	 *      parameterBankPanel
    -	 *      parameterStdPanel
    -	 *          bPartner/order/invoice/shopment/licator Label/Field
    -	 *  dataPane
    -	 *  southPanel
    -	 *      confirmPanel
    -	 *      statusBar
    -	 *  
    - * @throws Exception - */ - private void jbInit() throws Exception - { - boolean isRMAWindow = ((getGridTab().getAD_Window_ID() == WINDOW_RETURNTOVENDOR) || (getGridTab().getAD_Window_ID() == WINDOW_CUSTOMERRETURN)); - - bPartnerLabel.setText(Msg.getElement(Env.getCtx(), "C_BPartner_ID")); - orderLabel.setText(Msg.getElement(Env.getCtx(), "C_Order_ID", false)); - locatorLabel.setText(Msg.translate(Env.getCtx(), "M_Locator_ID")); - invoiceLabel.setText(Msg.getElement(Env.getCtx(), "C_Invoice_ID", false)); - sameWarehouseCb.setText(Msg.getMsg(Env.getCtx(), "FromSameWarehouseOnly", true)); - sameWarehouseCb.setToolTipText(Msg.getMsg(Env.getCtx(), "FromSameWarehouseOnly", false)); - rmaLabel.setText(Msg.translate(Env.getCtx(), "M_RMA_ID")); - upcLabel.setText(Msg.getElement(Env.getCtx(), "UPC", false)); - - CPanel parameterPanel = dialog.getParameterPanel(); - parameterPanel.setLayout(new BorderLayout()); - CPanel parameterStdPanel = new CPanel(new GridBagLayout()); - parameterPanel.add(parameterStdPanel, BorderLayout.CENTER); - - parameterStdPanel.add(bPartnerLabel, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); - if (bPartnerField != null) - parameterStdPanel.add(bPartnerField, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 0, 5, 5), 0, 0)); - - if (! isRMAWindow) { - parameterStdPanel.add(orderLabel, new GridBagConstraints(2, 0, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); - parameterStdPanel.add(orderField, new GridBagConstraints(3, 0, 1, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 0, 5, 5), 0, 0)); - - parameterStdPanel.add(invoiceLabel, new GridBagConstraints(2, 1, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); - parameterStdPanel.add(invoiceField, new GridBagConstraints(3, 1, 1, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 0, 5, 5), 0, 0)); - } - - parameterStdPanel.add(locatorLabel, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); - parameterStdPanel.add(locatorField, new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 0, 5, 5), 0, 0)); - parameterStdPanel.add(sameWarehouseCb, new GridBagConstraints(1, 2, 1, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 0, 5, 5), 0, 0)); - parameterStdPanel.add(upcLabel, new GridBagConstraints(0, 3, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); - parameterStdPanel.add(upcField, new GridBagConstraints(1, 3, 1, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 0, 5, 5), 0, 0)); - - if (isRMAWindow) { - // Add RMA document selection to panel - parameterStdPanel.add(rmaLabel, new GridBagConstraints(2, 2, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); - parameterStdPanel.add(rmaField, new GridBagConstraints(3, 2, 1, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 0, 5, 5), 0, 0)); - } - } // jbInit - - /*************************************************************************/ - - private boolean m_actionActive = false; - - /** - * Action Listener - * @param e event - */ - public void actionPerformed(ActionEvent e) - { - if (log.isLoggable(Level.CONFIG)) log.config("Action=" + e.getActionCommand()); - - if (m_actionActive) - return; - m_actionActive = true; - if (log.isLoggable(Level.CONFIG)) log.config("Action=" + e.getActionCommand()); - // Order - if (e.getSource().equals(orderField)) - { - KeyNamePair pp = (KeyNamePair)orderField.getSelectedItem(); - int C_Order_ID = 0; - if (pp != null) - C_Order_ID = pp.getKey(); - // set Invoice, RMA and Shipment to Null - rmaField.setSelectedIndex(-1); - invoiceField.setSelectedIndex(-1); - loadOrder(C_Order_ID, false, locatorField.getValue()!=null?((Integer)locatorField.getValue()).intValue():0); - } - // Invoice - else if (e.getSource().equals(invoiceField)) - { - KeyNamePair pp = (KeyNamePair)invoiceField.getSelectedItem(); - int C_Invoice_ID = 0; - if (pp != null) - C_Invoice_ID = pp.getKey(); - // set Order, RMA to Null - orderField.setSelectedIndex(-1); - rmaField.setSelectedIndex(-1); - loadInvoice(C_Invoice_ID, locatorField.getValue()!=null?((Integer)locatorField.getValue()).intValue():0); - } - // RMA - else if (e.getSource().equals(rmaField)) - { - KeyNamePair pp = (KeyNamePair)rmaField.getSelectedItem(); - int M_RMA_ID = 0; - if (pp != null) - M_RMA_ID = pp.getKey(); - // set Order and Invoice to Null - orderField.setSelectedIndex(-1); - invoiceField.setSelectedIndex(-1); - loadRMA(M_RMA_ID, locatorField.getValue()!=null?((Integer)locatorField.getValue()).intValue():0); - } - //sameWarehouseCb - else if (e.getSource().equals(sameWarehouseCb)) - { - initBPOrderDetails(((Integer)bPartnerField.getValue()).intValue(), false); - } - else if (e.getSource().equals(upcField)) - { - checkProductUsingUPC(); - } - m_actionActive = false; - } // actionPerformed - - /** - * Change Listener - * @param e event - */ - public void vetoableChange (PropertyChangeEvent e) - { - if (log.isLoggable(Level.CONFIG)) log.config(e.getPropertyName() + "=" + e.getNewValue()); - - // BPartner - load Order/Invoice/Shipment - if (e.getPropertyName().equals("C_BPartner_ID")) - { - int C_BPartner_ID = ((Integer)e.getNewValue()).intValue(); - initBPOrderDetails (C_BPartner_ID, false); - } - dialog.tableChanged(null); - } // vetoableChange - - /************************************************************************** - * Load BPartner Field - * @param forInvoice true if Invoices are to be created, false receipts - * @throws Exception if Lookups cannot be initialized - */ - protected void initBPartner (boolean forInvoice) throws Exception - { - // load BPartner - int AD_Column_ID = COLUMN_C_INVOICE_C_BPARTNER_ID; // C_Invoice.C_BPartner_ID - MLookup lookup = MLookupFactory.get (Env.getCtx(), p_WindowNo, 0, AD_Column_ID, DisplayType.Search); - bPartnerField = new VLookup ("C_BPartner_ID", true, false, true, lookup); - // - int C_BPartner_ID = Env.getContextAsInt(Env.getCtx(), p_WindowNo, "C_BPartner_ID"); - bPartnerField.setValue(Integer.valueOf(C_BPartner_ID)); - - // initial loading - initBPOrderDetails(C_BPartner_ID, forInvoice); - } // initBPartner - - /** - * Load PBartner dependent Order/Invoice/Shipment Field. - * @param C_BPartner_ID BPartner - * @param forInvoice for invoice - */ - protected void initBPOrderDetails (int C_BPartner_ID, boolean forInvoice) - { - if (log.isLoggable(Level.CONFIG)) log.config("C_BPartner_ID=" + C_BPartner_ID); - KeyNamePair pp = new KeyNamePair(0,""); - // load PO Orders - Closed, Completed - orderField.removeActionListener(this); - orderField.removeAllItems(); - orderField.addItem(pp); - - ArrayList list = loadOrderData(C_BPartner_ID, forInvoice, sameWarehouseCb.isSelected()); - for(KeyNamePair knp : list) - orderField.addItem(knp); - - orderField.setSelectedIndex(0); - orderField.addActionListener(this); - dialog.pack(); - - initBPDetails(C_BPartner_ID); - } // initBPartnerOIS - - public void initBPDetails(int C_BPartner_ID) - { - initBPInvoiceDetails(C_BPartner_ID); - initBPRMADetails(C_BPartner_ID); - } - - /** - * Init Details - load invoices not shipped - * @param C_BPartner_ID BPartner - */ - private void initBPInvoiceDetails(int C_BPartner_ID) - { - if (log.isLoggable(Level.CONFIG)) log.config("C_BPartner_ID" + C_BPartner_ID); - - // load Shipments (Receipts) - Completed, Closed - invoiceField.removeActionListener(this); - invoiceField.removeAllItems(); - // None - KeyNamePair pp = new KeyNamePair(0,""); - invoiceField.addItem(pp); - - ArrayList list = loadInvoiceData(C_BPartner_ID); - for(KeyNamePair knp : list) - invoiceField.addItem(knp); - - invoiceField.setSelectedIndex(0); - invoiceField.addActionListener(this); - upcField.addActionListener(this); - } - - /** - * Load RMA that are candidates for shipment - * @param C_BPartner_ID BPartner - */ - private void initBPRMADetails(int C_BPartner_ID) - { - rmaField.removeActionListener(this); - rmaField.removeAllItems(); - // None - KeyNamePair pp = new KeyNamePair(0,""); - rmaField.addItem(pp); - - ArrayList list = loadRMAData(C_BPartner_ID); - for(KeyNamePair knp : list) - rmaField.addItem(knp); - - rmaField.setSelectedIndex(0); - rmaField.addActionListener(this); - } - - /** - * Load Data - Order - * @param C_Order_ID Order - * @param forInvoice true if for invoice vs. delivery qty - * @param M_Locator_ID - */ - protected void loadOrder (int C_Order_ID, boolean forInvoice, int M_Locator_ID) - { - loadTableOIS(getOrderData(C_Order_ID, forInvoice, M_Locator_ID)); - } // LoadOrder - - /** - * Load Data - RMA - * @param M_RMA_ID RMA - * @param M_Locator_ID - */ - protected void loadRMA (int M_RMA_ID, int M_Locator_ID) - { - loadTableOIS(getRMAData(M_RMA_ID, M_Locator_ID)); - } - - /** - * Load Data - Invoice - * @param C_Invoice_ID Invoice - * @param M_Locator_ID - */ - protected void loadInvoice (int C_Invoice_ID, int M_Locator_ID) - { - loadTableOIS(getInvoiceData(C_Invoice_ID, M_Locator_ID)); - } - - /** - * Load Order/Invoice/Shipment data into Table - * @param data data - */ - protected void loadTableOIS (Vector data) - { - // Remove previous listeners - dialog.getMiniTable().getModel().removeTableModelListener(dialog); - // Set Model - DefaultTableModel model = new DefaultTableModel(data, getOISColumnNames()); - model.addTableModelListener(dialog); - dialog.getMiniTable().setModel(model); - // - - configureMiniTable(dialog.getMiniTable()); - } // loadOrder - - public void showWindow() - { - dialog.setVisible(true); - } - - public void closeWindow() - { - dialog.dispose(); - } - - /** - * Checks the UPC value and checks if the UPC matches any of the products in the - * list. - */ - private void checkProductUsingUPC() - { - String upc = upcField.getText(); - DefaultTableModel model = (DefaultTableModel)dialog.getMiniTable().getModel(); - // Lookup UPC - List products = MProduct.getByUPC(Env.getCtx(), upc, null); - for (MProduct product : products) - { - int row = findProductRow(product.get_ID()); - if (row >= 0) - { - BigDecimal qty = (BigDecimal)model.getValueAt(row, 1); - model.setValueAt(qty, row, 1); - model.setValueAt(Boolean.TRUE, row, 0); - model.fireTableRowsUpdated(row, row); - } - } - upcField.setText(""); - upcField.requestFocusInWindow(); - } - - /** - * Finds the row where a given product is. If the product is not found - * in the table -1 is returned. - * @param M_Product_ID - * @return Row of the product or -1 if non existing. - * - */ - private int findProductRow(int M_Product_ID) - { - DefaultTableModel model = (DefaultTableModel)dialog.getMiniTable().getModel(); - KeyNamePair kp; - for (int i=0; i - * parameterPanel - * parameterBankPanel - * parameterStdPanel - * bPartner/order/invoice/shopment/licator Label/Field - * dataPane - * southPanel - * confirmPanel - * statusBar - * - * @throws Exception - */ - private void jbInit() throws Exception - { - bankAccountLabel.setText(Msg.translate(Env.getCtx(), "C_BankAccount_ID")); - authorizationLabel.setText(Msg.translate(Env.getCtx(), "R_AuthCode")); - - documentTypeLabel.setText(Msg.translate(Env.getCtx(), "C_DocType_ID")); - tenderTypeLabel.setText(Msg.translate(Env.getCtx(), "TenderType")); - - documentNoLabel.setLabelFor(documentNoField); - dateFromLabel.setLabelFor(dateFromField); - dateFromField.setToolTipText(Msg.translate(Env.getCtx(), "DateFrom")); - dateToLabel.setLabelFor(dateToField); - dateToField.setToolTipText(Msg.translate(Env.getCtx(), "DateTo")); - amtFromLabel.setLabelFor(amtFromField); - amtFromField.setToolTipText(Msg.translate(Env.getCtx(), "AmtFrom")); - amtToLabel.setLabelFor(amtToField); - amtToField.setToolTipText(Msg.translate(Env.getCtx(), "AmtTo")); - - CPanel parameterPanel = dialog.getParameterPanel(); - parameterPanel.setLayout(new BorderLayout()); - - CPanel parameterBankPanel = new CPanel(); - parameterBankPanel.setLayout(new GridBagLayout()); - parameterPanel.add(parameterBankPanel, BorderLayout.CENTER); - - parameterBankPanel.add(bankAccountLabel, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); - if (bankAccountField != null) - parameterBankPanel.add(bankAccountField, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 0, 5, 5), 0, 0)); - - parameterBankPanel.add(documentTypeLabel, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); - if(documentTypeField!= null) - parameterBankPanel.add(documentTypeField, new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 0, 5, 5), 0, 0)); - - parameterBankPanel.add(tenderTypeLabel, new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); - if(tenderTypeField!=null) - parameterBankPanel.add(tenderTypeField, new GridBagConstraints(1, 2, 1, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 0, 5, 5), 0, 0)); - - parameterBankPanel.add(BPartner_idLabel, new GridBagConstraints(0, 3, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); - parameterBankPanel.add(bPartnerLookup, new GridBagConstraints(1, 3, 1, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 0, 5, 5), 0, 0)); - - parameterBankPanel.add(documentNoLabel, new GridBagConstraints(2, 0, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); - parameterBankPanel.add(documentNoField, new GridBagConstraints(3, 0, 1, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 0, 5, 5), 0, 0)); - - parameterBankPanel.add(authorizationLabel, new GridBagConstraints(2, 1, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); - parameterBankPanel.add(authorizationField, new GridBagConstraints(3, 1, 1, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 0, 5, 5), 0, 0)); - - parameterBankPanel.add(amtFromLabel, new GridBagConstraints(2, 2, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); - parameterBankPanel.add(amtFromField, new GridBagConstraints(3, 2, 1, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 0, 5, 5), 0, 0)); - parameterBankPanel.add(amtToLabel, new GridBagConstraints(4, 2, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); - parameterBankPanel.add(amtToField, new GridBagConstraints(5, 2, 1, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 0, 5, 5), 0, 0)); - - parameterBankPanel.add(dateFromLabel, new GridBagConstraints(2, 3, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); - parameterBankPanel.add(dateFromField, new GridBagConstraints(3, 3, 1, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 0, 5, 5), 0, 0)); - parameterBankPanel.add(dateToLabel, new GridBagConstraints(4, 3, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); - parameterBankPanel.add(dateToField, new GridBagConstraints(5, 3, 1, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 0, 5, 5), 0, 0)); - - } // jbInit - - /*************************************************************************/ - - /** - * Action Listener - * @param e event - */ - public void actionPerformed(ActionEvent e) - { - if (log.isLoggable(Level.CONFIG)) log.config("Action=" + e.getActionCommand()); -// Object source = e.getSource(); - if(e.getActionCommand().equals(ConfirmPanel.A_REFRESH)) - { - Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR); - loadBankAccount(); - dialog.tableChanged(null); - Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR); - } - } // actionPerformed - - protected void loadBankAccount() - { - loadTableOIS(getBankAccountData(bankAccountField.getValue(), bPartnerLookup.getValue(), - documentNoField.getText(), dateFromField.getValue(), dateToField.getValue(), - amtFromField.getValue(), amtToField.getValue(), - documentTypeField.getValue(), tenderTypeField.getValue(), authorizationField.getText())); - } - - protected void loadTableOIS (Vector data) - { - // Remove previous listeners - dialog.getMiniTable().getModel().removeTableModelListener(dialog); - // Set Model - DefaultTableModel model = new DefaultTableModel(data, getOISColumnNames()); - model.addTableModelListener(dialog); - dialog.getMiniTable().setModel(model); - // - - configureMiniTable(dialog.getMiniTable()); - } - - public void showWindow() - { - dialog.setVisible(true); - } - - public void closeWindow() - { - dialog.dispose(); - } - - @Override - public Object getWindow() - { - return dialog; - } -} \ No newline at end of file diff --git a/org.adempiere.ui.swing/src/org/compiere/grid/VOnlyCurrentDays.java b/org.adempiere.ui.swing/src/org/compiere/grid/VOnlyCurrentDays.java deleted file mode 100644 index 86d9f06531..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/grid/VOnlyCurrentDays.java +++ /dev/null @@ -1,170 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ -package org.compiere.grid; - -import java.awt.BorderLayout; -import java.awt.Frame; -import java.awt.Insets; -import java.awt.Point; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.awt.event.WindowAdapter; -import java.awt.event.WindowEvent; -import java.util.logging.Level; - -import javax.swing.WindowConstants; - -import org.compiere.swing.CButton; -import org.compiere.swing.CDialog; -import org.compiere.swing.CPanel; -import org.compiere.util.CLogger; -import org.compiere.util.Env; -import org.compiere.util.Msg; - -/** - * Queries how many days back history is displayed as current - * - * @author Jorg Janke - * @version $Id: VOnlyCurrentDays.java,v 1.2 2006/07/30 00:51:28 jjanke Exp $ - * - * @author Teo Sarca, SC ARHIPAC SERVICE SRL - *
  • BF [ 1824621 ] History button can't be canceled - */ -public class VOnlyCurrentDays extends CDialog - implements ActionListener -{ - /** - * - */ - private static final long serialVersionUID = 2619306709535014989L; - - /** - * Constructor - * @param parent parent frame - * @param buttonLocation lower left corner of the button - */ - public VOnlyCurrentDays(Frame parent, Point buttonLocation) - { - // How long back in History? - super (parent, Msg.getMsg(Env.getCtx(), "VOnlyCurrentDays", true), true); - try - { - jbInit(); - } - catch(Exception e) - { - log.log(Level.SEVERE, "VOnlyCurrentDays", e); - } - this.pack(); - buttonLocation.x -= (int)getPreferredSize().getWidth()/2; - this.setLocation(buttonLocation); - this.setVisible(true); - } // VOnlyCurrentDays - - private CPanel mainPanel = new CPanel(); - private CButton bShowAll = new CButton(); - private CButton bShowMonth = new CButton(); - private CButton bShowWeek = new CButton(); - private CButton bShowDay = new CButton(); - private CButton bShowYear = new CButton(); - - /** Days (0=all) */ - private int m_days = 0; - /** Is cancel */ - private boolean m_isCancel = false; - /** Margin */ - private static Insets s_margin = new Insets (2, 2, 2, 2); - /** Logger */ - private static CLogger log = CLogger.getCLogger(VOnlyCurrentDays.class); - - /** - * Static Initializer - * @throws Exception - */ - private void jbInit() throws Exception - { - this.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); - bShowAll.setText(Msg.getMsg(Env.getCtx(), "All")); - bShowAll.addActionListener(this); - bShowAll.setMargin(s_margin); - bShowYear.setText(Msg.getMsg(Env.getCtx(), "Year")); - bShowYear.addActionListener(this); - bShowYear.setMargin(s_margin); - bShowMonth.setText(Msg.getMsg(Env.getCtx(), "Month")); - bShowMonth.addActionListener(this); - bShowMonth.setMargin(s_margin); - bShowWeek.setText(Msg.getMsg(Env.getCtx(), "Week")); - bShowWeek.addActionListener(this); - bShowWeek.setMargin(s_margin); - bShowDay.setText(Msg.getMsg(Env.getCtx(), "Day")); - bShowDay.addActionListener(this); - bShowDay.setMargin(s_margin); - bShowDay.setDefaultCapable(true); - // - mainPanel.add(bShowDay, null); - mainPanel.add(bShowWeek, null); - mainPanel.add(bShowMonth, null); - mainPanel.add(bShowYear, null); - mainPanel.add(bShowAll, null); - // - mainPanel.setToolTipText(Msg.getMsg(Env.getCtx(), "VOnlyCurrentDays", false)); - this.getContentPane().add(mainPanel, BorderLayout.CENTER); - this.getRootPane().setDefaultButton(bShowDay); - // - addWindowListener(new WindowAdapter() { - @Override - public void windowClosing(WindowEvent e) { - m_isCancel = true; - } - }); - } // jbInit - - /** - * Action Listener - * @param e evant - */ - public void actionPerformed(ActionEvent e) - { - if (e.getSource() == bShowDay) - m_days = 1; - else if (e.getSource() == bShowWeek) - m_days = 7; - else if (e.getSource() == bShowMonth) - m_days = 31; - else if (e.getSource() == bShowYear) - m_days = 365; - else - m_days = 0; // all - dispose(); - } // actionPerformed - - /** - * Get selected number of days - * @return days or -1 for all - */ - public int getCurrentDays() - { - return m_days; - } // getCurrentDays - - /** - * @return true if user has canceled this form - */ - public boolean isCancel() { - return m_isCancel; - } -} // VOnlyCurrentDays diff --git a/org.adempiere.ui.swing/src/org/compiere/grid/VPanel.java b/org.adempiere.ui.swing/src/org/compiere/grid/VPanel.java deleted file mode 100644 index fc12ae08e5..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/grid/VPanel.java +++ /dev/null @@ -1,770 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - * @contributor Victor Perez , e-Evolution.SC FR [ 1757088 ] - *****************************************************************************/ -package org.compiere.grid; - -import java.awt.BorderLayout; -import java.awt.Component; -import java.awt.FocusTraversalPolicy; -import java.awt.Font; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.logging.Level; - -import javax.swing.BorderFactory; -import javax.swing.Box; -import javax.swing.JPanel; -import javax.swing.JSeparator; - -import net.miginfocom.layout.BoundSize; -import net.miginfocom.layout.ComponentWrapper; -import net.miginfocom.layout.ConstraintParser; -import net.miginfocom.layout.LayoutCallback; -import net.miginfocom.swing.MigLayout; - -import org.adempiere.plaf.AdempierePLAF; -import org.compiere.apps.AFocusTraversalPolicy; -import org.compiere.apps.APanel; -import org.compiere.grid.ed.VButton; -import org.compiere.grid.ed.VCheckBox; -import org.compiere.grid.ed.VEditor; -import org.compiere.grid.ed.VEditorFactory; -import org.compiere.model.GridField; -import org.compiere.model.X_AD_FieldGroup; -import org.compiere.swing.CLabel; -import org.compiere.swing.CPanel; -import org.compiere.swing.CTabbedPane; -import org.compiere.swing.CollapsiblePanel; -import org.compiere.util.CLogger; -import org.compiere.util.DisplayType; -import org.compiere.util.Language; -import org.compiere.util.Util; -import org.jdesktop.swingx.JXCollapsiblePane; -import org.jdesktop.swingx.border.DropShadowBorder; - - -/** - * Single Row Panel. - * Called from GridController - * - * Uses MigLayout - * - * @author Jorg Janke - * @version $Id: VPanel.java,v 1.3 2006/07/30 00:51:28 jjanke Exp $ - * @contributor Victor Perez , e-Evolution.SC FR [ 1757088 ] - * Carlos Ruiz - globalqss / Fix bug 2307133 - Swing client hiding fields incorrectly - */ -public final class VPanel extends CTabbedPane -{ - - /** - * - */ - private static final long serialVersionUID = 8227080366665213627L; - - private int m_WindowNo; - // show layout grid - private boolean debug = false; - private String defaultLayoutConstraints; - private int labelMinWidth = 0; - private int fieldMinWidth = 0; - - public VPanel(String Name) - { - this(Name, 0); - } - - /** - * - * @param Name - * @param WindowNo - */ - public VPanel(String Name, int WindowNo) - { - m_WindowNo = WindowNo; - - defaultLayoutConstraints = "hidemode 3"; // hidden fields take no part in grid - defaultLayoutConstraints += debug ? ", debug" : ""; - - //[ 1757088 ] - m_main.setName(Name); - String constraints = defaultLayoutConstraints; - MigLayout mainLayout = new MigLayout(constraints); - mainLayout.addLayoutCallback(callback); - m_main.setLayout(mainLayout); - - m_tablist.put("main", m_main); - this.setBorder(marginBorder); - - CPanel dummy = new CPanel(); - dummy.setLayout(new BorderLayout()); - dummy.add(m_main, BorderLayout.NORTH); - dummy.setName(m_main.getName()); - this.add(dummy); - - } // VPanel - - /** Orientation */ - @SuppressWarnings("unused") - private final boolean m_leftToRight = Language.getLoginLanguage().isLeftToRight(); - /** Previous Field Group Header */ - private String m_oldFieldGroup = null; - /** Previous Field Group Type */ - private String m_oldFieldGroupType = null; - /** DefaultFocusField */ - private VEditor m_defaultFocusField = null; - /** Focus Traversal Policy */ - private static FocusTraversalPolicy s_focusPolicy = null; - //[ 1757088 ] - private java.util.Hashtable m_tablist = new java.util.Hashtable(); - private java.util.Hashtable m_tabincludelist = new java.util.Hashtable(); - private CPanel m_main = new CPanel(org.compiere.plaf.CompiereColor.getDefaultBackground()); - private DropShadowBorder marginBorder = new DropShadowBorder(); - - - /** - * Use layout callback to implement size groups across panels - * and to shrink hidden components vertically. - */ - private LayoutCallback callback = new LayoutCallback() { - - // Set the min and preferred sizes to match the largest component - public BoundSize[] getSize(ComponentWrapper comp) - { - if (comp.getComponent() instanceof CLabel) { - Component c = (Component) comp.getComponent(); - int w = labelMinWidth; - int h = c.getPreferredSize().height; - BoundSize width = ConstraintParser.parseBoundSize(w + ":" + w, false, true); // min:pref - BoundSize height = ConstraintParser.parseBoundSize(h + ":" + h, false, false); - - return new BoundSize[] {width, height}; - } - else - { - Component c = (Component) comp.getComponent(); - int w = fieldMinWidth; - int h = c.getPreferredSize().height; - BoundSize width = ConstraintParser.parseBoundSize(w + ":" + w, false, true); - BoundSize height = ConstraintParser.parseBoundSize(h + ":" + h, false, false); - - return new BoundSize[] {width, height}; - } - - }// - - public void correctBounds(ComponentWrapper comp) - { - } - }; - - private VEditor prevEditor = null; - private GridField prevField = null; - private boolean wrap = false; - - /** Logger */ - private static CLogger log = CLogger.getCLogger (VPanel.class); - - - /** - * Set Field Mnemonic - * @param mField field - */ - public void setMnemonic (GridField mField) - { - if (mField.isCreateMnemonic()) - return; - String text = mField.getHeader(); - int pos = text.indexOf('&'); - if (pos != -1 && text.length() > pos) // We have a mnemonic - creates Ctrl_Shift_ - { - char mnemonic = text.toUpperCase().charAt(pos+1); - if (mnemonic != ' ') - { - if (!m_mnemonics.contains(mnemonic)) - { - mField.setMnemonic(mnemonic); - m_mnemonics.add(mnemonic); - } - else - log.warning(mField.getColumnName() - + " - Conflict - Already exists: " + mnemonic + " (" + text + ")"); - } - } - } // setMnemonic - - /** - * Add Field and Label to buffer and push buffered field to Panel - * @param editor editor - * @param mField field model - */ - public void addFieldBuffered (VEditor editor, GridField mField) - { - wrap = mField != null ? !mField.isSameLine() : false; - - if ( prevEditor != null && prevField != null) - addField(prevEditor, prevField); - prevEditor = editor; - prevField = mField; - } - /** - * Add the previous Field and Label to Panel - * @param editor editor - * @param mField field model - * @param wrap move to next line after this field - */ - public void addField (VEditor editor, GridField mField) - { - //[ 1757088 ] - int AD_Tab_ID = mField.getIncluded_Tab_ID(); - if(AD_Tab_ID != 0 ) - { - CollapsiblePanel m_tab = new CollapsiblePanel(""); - m_tabincludelist.put(AD_Tab_ID, m_tab); - m_main.add(m_tab,"newline, spanx, growx"); - m_tab.setName("IncludedTab#"+AD_Tab_ID); - - if (includedTabList.containsKey(AD_Tab_ID)) - { - includeTab(includedTabList.get(AD_Tab_ID)); - } - return; - } - - CLabel label = VEditorFactory.getLabel(mField); - if (label == null && editor == null) - return; - - boolean sameLine = mField.isSameLine(); - - //[ 1757088 ] // sets top - String fieldGroup = mField.getFieldGroup(); - String fieldGroupType = mField.getFieldGroupType(); - if (Util.isEmpty(fieldGroup)) - { - fieldGroup = m_oldFieldGroup; - fieldGroupType = m_oldFieldGroupType; - } - - if (addGroup(fieldGroup, fieldGroupType)) // sets top - { - if (X_AD_FieldGroup.FIELDGROUPTYPE_Collapse.equals(fieldGroupType)) - { - CollapsiblePanel panel = (CollapsiblePanel) m_tablist.get(fieldGroup); - panel.getCollapsiblePane().setCollapsed(mField.getIsCollapsedByDefault()); - } - sameLine = false; - } - else - { - fieldGroup = m_oldFieldGroup; - fieldGroupType = m_oldFieldGroupType; - } - - // label constraints - String constraints = "align trailing"; - if ( !sameLine ) - { - constraints += ", newline"; - } - - // *** The Label *** - if ( label == null) - { - label = new CLabel(""); - label.setName(mField.getColumnName()); - } - // - if (mField.isCreateMnemonic()) - setMnemonic(label, mField.getMnemonic()); - - if (fieldGroupType.equals(X_AD_FieldGroup.FIELDGROUPTYPE_Tab)) - { - CPanel m_tab = (CPanel)m_tablist.get(fieldGroup); - m_tab.add(label, constraints); - } - else if (fieldGroupType.equals(X_AD_FieldGroup.FIELDGROUPTYPE_Collapse)) - { - CollapsiblePanel m_tab = (CollapsiblePanel) m_tablist.get(fieldGroup); - m_tab.getCollapsiblePane().getContentPane().add(label, constraints); - } - else // Label - { - m_main.add(label, constraints); - } - - int currentWidth = label.getPreferredSize().width; - labelMinWidth = currentWidth > labelMinWidth ? currentWidth : labelMinWidth; - - // *** The Field *** - if (editor != null) - { - Component field = (Component)editor; - // field constraints - // long fields span all remaining columns - constraints = "growx, pushx"; - if ( mField.isLongField() ) - { - constraints += mField.isLongField() ? ",spanx" : ""; - } - if ( wrap ) - { - // Vertical Spacing in Swing Client - // - https://sourceforge.net/tracker/?func=detail&aid=3073406&group_id=176962&atid=883808 - constraints += ", wrap 0"; - } - - // Add Field - //[ 1757088 ] - if (fieldGroupType.equals(X_AD_FieldGroup.FIELDGROUPTYPE_Tab)) - { - CPanel m_tab = (CPanel)m_tablist.get(fieldGroup); - m_tab.add(field, constraints); - } - else if (fieldGroupType.equals(X_AD_FieldGroup.FIELDGROUPTYPE_Collapse)) - { - CollapsiblePanel m_tab = (CollapsiblePanel) m_tablist.get(fieldGroup); - Component comp = (Component) editor; - comp.setMinimumSize(comp.getPreferredSize()); - if (mField.getDisplayType() == DisplayType.Text - || mField.getDisplayType() == DisplayType.Memo - ||mField.getDisplayType() == DisplayType.TextLong ) - { - Component component = (Component) editor; - component.setMinimumSize(component.getPreferredSize()); - } - if (!mField.isLongField()) - fieldMinWidth = field.getPreferredSize().width > fieldMinWidth ? field.getPreferredSize().width : fieldMinWidth; - m_tab.getCollapsiblePane().getContentPane().add(field, constraints); - } - else // Label or null - { - m_main.add(field, constraints); - if (!mField.isLongField()) - fieldMinWidth = field.getPreferredSize().width > fieldMinWidth ? field.getPreferredSize().width : fieldMinWidth; - } - // Link Label to Field - //if (label != null) - label.setLabelFor(field); - //else if (mField.isCreateMnemonic()) - //setMnemonic(editor, mField.getMnemonic()); - - // Default Focus - if (m_defaultFocusField == null && mField.isDefaultFocus()) - { - m_defaultFocusField = editor; - if (s_focusPolicy == null) - s_focusPolicy = new AFocusTraversalPolicy(); - setFocusTraversalPolicy(s_focusPolicy); - setFocusTraversalPolicyProvider(true); - } - } - } // addField - - /** - * Add Group - * @param fieldGroup field group - * @param fieldGroupType - * @return true if group added - */ - private boolean addGroup(String fieldGroup, String fieldGroupType) - { - // First time - add top - if (m_oldFieldGroup == null) - { - m_oldFieldGroup = ""; - m_oldFieldGroupType = ""; - } - - if (fieldGroup == null || fieldGroup.length() == 0 || fieldGroup.equals(m_oldFieldGroup)) - return false; - - //[ 1757088 ] - if (m_tablist.get(fieldGroup) != null) - { - return false; - } - - //[ 1757088 ] - if (fieldGroupType.equals(X_AD_FieldGroup.FIELDGROUPTYPE_Tab)) - { - - CPanel m_tab = new CPanel(); - m_tab.setBackground(AdempierePLAF.getFormBackground()); - String tpConstraints = defaultLayoutConstraints ; - MigLayout layout = new MigLayout(tpConstraints); - layout.addLayoutCallback(callback); - m_tab.setLayout(layout); - m_tab.setName(fieldGroup); - CPanel dummy = new CPanel(); - dummy.setLayout(new BorderLayout()); - dummy.add(m_tab, BorderLayout.NORTH); - dummy.setName(m_tab.getName()); - dummy.setBorder(BorderFactory.createEmptyBorder(10,12,0,12)); - this.add(dummy); - m_tablist.put(fieldGroup, m_tab); - } - else if (fieldGroupType.equals(X_AD_FieldGroup.FIELDGROUPTYPE_Collapse)) - { - CollapsiblePanel collapsibleSection = new CollapsiblePanel(fieldGroup); - JXCollapsiblePane m_tab = collapsibleSection.getCollapsiblePane(); - m_tab.setAnimated(false); - m_tab.getContentPane().setBackground(AdempierePLAF.getFormBackground()); - - String cpConstraints = defaultLayoutConstraints; - // 0 inset left and right as this is a nested panel - // 0 inset top because of the struts added below - cpConstraints += ", ins 0 0 n 0"; - - MigLayout layout = new MigLayout(cpConstraints); - layout.addLayoutCallback(callback); - - collapsibleSection.setName(fieldGroup); - m_main.add(collapsibleSection, "newline, spanx, growx"); - m_tab.setLayout(layout); - /* for compatibility with old layout, force collapsible field groups - * to have a minimum of two columns by inserting invisible components - */ - Component strut1 = Box.createVerticalStrut(1); - strut1.setName("vstrut1"+fieldGroup); - Component strut2 = Box.createVerticalStrut(1); - strut2.setName("vstrut2"+fieldGroup); - m_tab.add(new CLabel(""), "gap 0 0 0 0"); - m_tab.add(strut1, "pushx, growx, gap 0 0 0 0"); - m_tab.add(new CLabel(""), ""); - m_tab.add(strut2, "pushx, growx, gap 0 0 0 0, wrap"); - m_tablist.put(fieldGroup, collapsibleSection); - } - else // Label or null - { - CLabel label = new CLabel(fieldGroup, CLabel.LEADING); - label.setFont(AdempierePLAF.getFont_Label().deriveFont(Font.BOLD | Font.ITALIC, AdempierePLAF.getFont_Label().getSize2D())); - m_main.add(label, "newline, spanx, growx"); - m_main.add(new JSeparator(), "newline, spanx, growx"); - // reset - } - m_oldFieldGroup = fieldGroup; - m_oldFieldGroupType = fieldGroupType; - return true; - } // addGroup - - /** - * Set Mnemonic for Label CTRL_SHIFT_x - * @param label label - * @param predefinedMnemonic predefined Mnemonic - */ - private void setMnemonic (CLabel label, char predefinedMnemonic) - { - String text = label.getText(); - int pos = text.indexOf('&'); - if (pos != -1 && predefinedMnemonic != 0) - { - text = text.substring(0, pos) + text.substring(pos+1); - label.setText(text); - label.setSavedMnemonic(predefinedMnemonic); - m_fields.add(label); - if (log.isLoggable(Level.FINEST)) log.finest(predefinedMnemonic + " - " + label.getName()); - } - else - { - char mnemonic = getMnemonic(text, label); - if (mnemonic != 0) - label.setSavedMnemonic(mnemonic); - // label.setDisplayedMnemonic(mnemonic); - } - } // setMnemonic - - /** - * Set Mnemonic for Check Box or Button - * @param editor check box or button - other ignored - * @param predefinedMnemonic predefined Mnemonic - */ - /* - private void setMnemonic (VEditor editor, char predefinedMnemonic) - { - if (editor instanceof VCheckBox) - { - VCheckBox cb = (VCheckBox)editor; - String text = cb.getText(); - int pos = text.indexOf('&'); - if (pos != -1 && predefinedMnemonic != 0) - { - text = text.substring(0, pos) + text.substring(pos+1); - cb.setText(text); - cb.setSavedMnemonic(predefinedMnemonic); - m_fields.add(cb); - if (log.isLoggable(Level.FINEST)) log.finest(predefinedMnemonic + " - " + cb.getName()); - } - else - { - char mnemonic = getMnemonic(text, cb); - if (mnemonic != 0) - cb.setSavedMnemonic(mnemonic); - // cb.setMnemonic(mnemonic); - } - } - // Button - else if (editor instanceof VButton) - { - VButton b = (VButton)editor; - String text = b.getText(); - int pos = text.indexOf('&'); - if (pos != -1 && predefinedMnemonic != 0) - { - text = text.substring(0, pos) + text.substring(pos+1); - b.setText(text); - b.setSavedMnemonic(predefinedMnemonic); - m_fields.add(b); - if (log.isLoggable(Level.FINEST)) log.finest(predefinedMnemonic + " - " + b.getName()); - } - else if (b.getColumnName().equals("DocAction")) - { - b.getInputMap(WHEN_IN_FOCUSED_WINDOW) - .put(KeyStroke.getKeyStroke(KeyEvent.VK_F4, Event.SHIFT_MASK, false), "pressed"); - b.getInputMap(WHEN_IN_FOCUSED_WINDOW) - .put(KeyStroke.getKeyStroke(KeyEvent.VK_F4, Event.SHIFT_MASK, true), "released"); - // Util.printActionInputMap(b); - } - else if (b.getColumnName().equals("Posted")) - { - b.getInputMap(WHEN_IN_FOCUSED_WINDOW) - .put(KeyStroke.getKeyStroke(KeyEvent.VK_F5, Event.SHIFT_MASK, false), "pressed"); - b.getInputMap(WHEN_IN_FOCUSED_WINDOW) - .put(KeyStroke.getKeyStroke(KeyEvent.VK_F5, Event.SHIFT_MASK, true), "released"); - // Util.printActionInputMap(b); - } - else - { - char mnemonic = getMnemonic(text, b); - if (mnemonic != 0) - b.setSavedMnemonic(mnemonic); - } - } - } // setMnemonic - */ - - /** - * Get Mnemonic from text - * @param text text - * @param source component - * @return Mnemonic or 0 if not unique - */ - private char getMnemonic (String text, Component source) - { - if (text == null || text.length() == 0) - return 0; - String oText = text; - text = text.trim().toUpperCase(); - char mnemonic = text.charAt(0); - if (m_mnemonics.contains(mnemonic)) - { - mnemonic = 0; - // Beginning new word - int index = text.indexOf(' '); - while (index != -1 && text.length() > index) - { - char c = text.charAt(index+1); - if (Character.isLetterOrDigit(c) && !m_mnemonics.contains(c)) - { - mnemonic = c; - break; - } - index = text.indexOf(' ', index+1); - } - // Any character - if (mnemonic == 0) - { - for (int i = 1; i < text.length(); i++) - { - char c = text.charAt(i); - if (Character.isLetterOrDigit(c) && !m_mnemonics.contains(c)) - { - mnemonic = c; - break; - } - } - } - // Nothing found - if (mnemonic == 0) - { - if (log.isLoggable(Level.FINEST)) log.finest("None for: " + oText); - return 0; // if first char would be returned, the first occurrence is invalid. - } - } - m_mnemonics.add(mnemonic); - m_fields.add(source); - if (log.isLoggable(Level.FINEST)) log.finest(mnemonic + " - " + source.getName()); - return mnemonic; - } // getMnemonic - - /** Used Mnemonics */ - private ArrayList m_mnemonics = new ArrayList(30); - /** Mnemonic Fields */ - private ArrayList m_fields = new ArrayList(30); - - private HashMap includedTabList = new HashMap(); - - /** - * Set Window level Mnemonics - * @param set true if set otherwise unregister - */ - public void setMnemonics (boolean set) - { - int size = m_fields.size(); - for (int i = 0; i < size; i++) - { - Component c = m_fields.get(i); - if (c instanceof CLabel) - { - CLabel l = (CLabel)c; - if (set) - l.setDisplayedMnemonic(l.getSavedMnemonic()); - else - l.setDisplayedMnemonic(0); - } - else if (c instanceof VCheckBox) - { - VCheckBox cb = (VCheckBox)c; - if (set) - cb.setMnemonic(cb.getSavedMnemonic()); - else - cb.setMnemonic(0); - } - else if (c instanceof VButton) - { - VButton b = (VButton)c; - if (set) - b.setMnemonic(b.getSavedMnemonic()); - else - b.setMnemonic(0); - } - } - } // setMnemonics - - /************************************************************************** - * Set Background to AD_Color_ID (nop) - * @param AD_Color_ID Color - */ - public void setBackground (int AD_Color_ID) - { - } // setBackground - - - private void findChildComponents(CPanel container, List list) - { - Component[] comp = container.getComponents(); - for (int c = 0; c < comp.length; c++) - { - list.add(comp[c]); - if ( comp [c] instanceof CollapsiblePanel) - { - CollapsiblePanel collapsiblePanel = (CollapsiblePanel)comp [c]; - - Component[] nestedComps = collapsiblePanel.getCollapsiblePane() - .getContentPane().getComponents(); - - for (int y = 0; y < nestedComps.length; y++) - { - - if ( nestedComps [y] instanceof CPanel) - { - CPanel nestedPanel = (CPanel)nestedComps[y]; - Component[] nestedPanelComps = nestedPanel.getComponents(); - - for (int x = 0; x < nestedPanelComps.length; x++) - { - list.add(nestedPanelComps[x]); - } - } - else - { - list.add(nestedComps[y]); - } - } - } else if (comp[c] instanceof CPanel) - { - - findChildComponents((CPanel)comp[c], list); - } - } - } - - //[ 1757088 ] - public Component[] getComponentsRecursive() - { - java.util.ArrayList list = new java.util.ArrayList(); - - for (int i = 0; i < this.getTabCount(); i++) - { - list.add(this.getComponentAt(i)); - if (this.getComponentAt(i) instanceof CPanel) - { - CPanel panel = (CPanel)this.getComponentAt(i); - findChildComponents(panel, list); - } - } - - Component[] result = new Component[list.size ()]; - list.toArray (result); - return result; - } - - /** - * - * @param detail - */ - public void includeTab(GridController detail) { - CollapsiblePanel section = m_tabincludelist.get(detail.getMTab().getAD_Tab_ID()); - if(section != null) - { - APanel panel = new APanel(detail, m_WindowNo); - String name = detail.getMTab().getName() + ""; - section.setTitle(name); - section.getCollapsiblePane().getContentPane().setLayout(new BorderLayout()); - section.getCollapsiblePane().getContentPane().add(panel, BorderLayout.CENTER); - } - - //this can be call before addField - if (!includedTabList.containsKey(detail.getMTab().getAD_Tab_ID())) - includedTabList.put(detail.getMTab().getAD_Tab_ID(), detail); - } - - /** - * Get Default Focus Field - * @return field if defined - */ - public VEditor getDefaultFocus() - { - return m_defaultFocusField; - } // getDefaultFocus - - /** - * Request Focus In Window - * @return focus request - */ - @Override - public boolean requestFocusInWindow() - { - if (m_defaultFocusField != null) - { - if (m_defaultFocusField.isReadWrite()) - return m_defaultFocusField.getFocusableComponent().requestFocusInWindow(); - } - return super.requestFocusInWindow(); - } -} // VPanel diff --git a/org.adempiere.ui.swing/src/org/compiere/grid/VPaymentFormCash.java b/org.adempiere.ui.swing/src/org/compiere/grid/VPaymentFormCash.java deleted file mode 100644 index 8c7c75db74..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/grid/VPaymentFormCash.java +++ /dev/null @@ -1,250 +0,0 @@ -/****************************************************************************** - * Copyright (C) 2012 Elaine Tan * - * Copyright (C) 2012 Trek Global - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - *****************************************************************************/ -package org.compiere.grid; - -import java.awt.GridBagConstraints; -import java.awt.GridBagLayout; -import java.awt.Insets; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.math.BigDecimal; -import java.sql.Timestamp; -import java.util.ArrayList; -import java.util.Enumeration; - -import org.compiere.apps.ADialog; -import org.compiere.grid.ed.VDate; -import org.compiere.grid.ed.VNumber; -import org.compiere.model.GridTab; -import org.compiere.model.MConversionRate; -import org.compiere.model.MInvoice; -import org.compiere.swing.CComboBox; -import org.compiere.swing.CLabel; -import org.compiere.util.DisplayType; -import org.compiere.util.Env; -import org.compiere.util.KeyNamePair; -import org.compiere.util.Msg; - -/** - * - * @author Elaine - * - */ -public class VPaymentFormCash extends PaymentFormCash implements ActionListener { - - private VPaymentFormDialog dialog; - - private CLabel bBankAccountLabel = new CLabel(); - private CComboBoxbBankAccountCombo = new CComboBox(); - private CLabel bCashBookLabel = new CLabel(); - private CComboBoxbCashBookCombo = new CComboBox(); - private CLabel bCurrencyLabel = new CLabel(); - private CComboBoxbCurrencyCombo = new CComboBox(); - private VDate bDateField; - private CLabel bDateLabel = new CLabel(); - private CLabel bAmountLabel = new CLabel(); - private VNumber bAmountField = new VNumber(); - - public VPaymentFormCash(int windowNo, GridTab mTab) { - super(windowNo, mTab); - bDateField = new VDate("DateAcct", false, false, true, DisplayType.Date, "DateAcct"); - dialog = new VPaymentFormDialog(this, windowNo); - init(); - - //Bojana&Daniel - //If Invoice is Vendor invoice then Cash has to be created by negative amount - int C_Invoice_ID = Env.getContextAsInt(Env.getCtx(), windowNo, "C_Invoice_ID"); - MInvoice invoice_tmp = new MInvoice (Env.getCtx(), C_Invoice_ID, null); - if (! invoice_tmp.isSOTrx()) - { - bAmountField.setValue(m_Amount.negate()); - }else { - bAmountField.setValue(m_Amount); - } - invoice_tmp = null; - } - - public void init() { - GridBagLayout bPanelLayout = new GridBagLayout(); - bBankAccountLabel.setText(Msg.translate(Env.getCtx(), "C_BankAccount_ID")); - bCurrencyLabel.setText(Msg.translate(Env.getCtx(), "C_Currency_ID")); - dialog.getPanel().setLayout(bPanelLayout); - bAmountLabel.setText(Msg.getMsg(Env.getCtx(), "Amount")); - //bAmountField.setText(""); - bDateLabel.setText(Msg.translate(Env.getCtx(), "DateAcct")); - - if (m_Cash_As_Payment){ - dialog.getPanel().add(bBankAccountLabel, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(2, 0, 2, 0), 0, 0)); - dialog.getPanel().add(bBankAccountCombo, new GridBagConstraints(1, 0, 2, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(2, 5, 2, 5), 0, 0)); - - } else { - bCashBookLabel.setText(Msg.translate(Env.getCtx(), "C_CashBook_ID")); - dialog.getPanel().add(bCashBookLabel, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(2, 0, 2, 0), 0, 0)); - dialog.getPanel().add(bCashBookCombo, new GridBagConstraints(1, 0, 2, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(2, 5, 2, 5), 0, 0)); - - } - - dialog.getPanel().add(bCurrencyLabel, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(2, 0, 2, 0), 0, 0)); - dialog.getPanel().add(bCurrencyCombo, new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(2, 5, 2, 5), 0, 0)); - dialog.getPanel().add(bDateLabel, new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 0, 2, 0), 0, 0)); - dialog.getPanel().add(bDateField, new GridBagConstraints(1, 2, 2, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 2, 5), 0, 0)); - dialog.getPanel().add(bAmountLabel, new GridBagConstraints(0, 3, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 0, 2, 0), 0, 0)); - dialog.getPanel().add(bAmountField, new GridBagConstraints(1, 3, 1, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 2, 5), 0, 0)); - } - - @Override - public void loadData() { - super.loadData(); - - bAmountField.setValue(m_Amount); - - if (m_C_Payment_ID != 0) - bAmountField.setValue(m_mPayment.getPayAmt()); - - // Existing Cashbook entry - if (m_C_CashLine_ID != 0) - bAmountField.setValue(m_cashLine.getAmount()); - - // Accounting Date - bDateField.setValue(m_DateAcct); - - // Is the currency an EMU currency? - Integer C_Currency_ID = Integer.valueOf(m_C_Currency_ID); - if (s_Currencies.containsKey(C_Currency_ID)) { - Enumeration en = s_Currencies.keys(); - while (en.hasMoreElements()) { - Object key = en.nextElement(); - bCurrencyCombo.addItem(s_Currencies.get(key)); - } - bCurrencyCombo.addActionListener(this); - bCurrencyCombo.setSelectedItem(s_Currencies.get(C_Currency_ID)); - } - else // No EMU Currency - { - bCurrencyLabel.setVisible(false); // Cash - bCurrencyCombo.setVisible(false); - } - - ArrayList list = getBankAccountList(); - for (KeyNamePair pp : list) - bBankAccountCombo.addItem(pp); - - // Set Selection - if (selectedBankAccount != null) - bBankAccountCombo.setSelectedItem(selectedBankAccount); - - - list = getCashBookList(); - for (KeyNamePair pp : list) - bCashBookCombo.addItem(pp); - - // Set Selection - if (selectedCashBook != null) - bCashBookCombo.setSelectedItem(selectedCashBook); - } - - public void actionPerformed(ActionEvent e) - { - if (e.getSource() == bCurrencyCombo) - { - KeyNamePair pp = (KeyNamePair)bCurrencyCombo.getSelectedItem(); - BigDecimal amt = MConversionRate.convert(Env.getCtx(), - m_Amount, m_C_Currency_ID, pp.getKey(), m_AD_Client_ID, m_AD_Org_ID); - bAmountField.setValue(amt); - } - } - - @Override - public boolean checkMandatory() { - int C_BankAccount_ID = 0; - /*********************** - * Mandatory Data Check - */ - boolean dataOK = true; - if (m_Cash_As_Payment) - { - KeyNamePair kp = (KeyNamePair)bBankAccountCombo.getSelectedItem(); - if (kp != null) - C_BankAccount_ID = kp.getKey(); - } - - // find Bank Account if not qualified yet - if (m_Cash_As_Payment && C_BankAccount_ID == 0) - { - // Check & Cash (Payment) must have a bank account - if (C_BankAccount_ID == 0 && m_Cash_As_Payment) - { - ADialog.error(getWindowNo(), dialog, "FillMandatory", bBankAccountLabel.getText()); - dataOK = false; - } - } - - return dataOK; - } - - @Override - public boolean saveChangesInTrx(String trxName) { - int newC_CashBook_ID = m_C_CashBook_ID; - int newC_BankAccount_ID = 0; - if (m_Cash_As_Payment){ - // get bank account - KeyNamePair kp = (KeyNamePair)bBankAccountCombo.getSelectedItem(); - if (kp != null) - newC_BankAccount_ID = kp.getKey(); - } else { - // get cash book - KeyNamePair kp = (KeyNamePair)bCashBookCombo.getSelectedItem(); - if (kp != null) - newC_CashBook_ID = kp.getKey(); - } - - Timestamp newDateAcct = (Timestamp)bDateField.getValue(); - - boolean ok = save(newC_BankAccount_ID,newC_CashBook_ID, newDateAcct, (BigDecimal) bAmountField.getValue(), trxName); - - if (!ok) - ADialog.error(getWindowNo(), dialog, "PaymentError", processMsg); - else if (processMsg != null) - ADialog.info(getWindowNo(), dialog, "PaymentCreated", processMsg); - - return ok; - } - - @Override - public void showWindow() - { - dialog.setVisible(true); - } - - @Override - public void closeWindow() - { - dialog.dispose(); - } - - @Override - public Object getWindow() { - return dialog; - } -} diff --git a/org.adempiere.ui.swing/src/org/compiere/grid/VPaymentFormCheck.java b/org.adempiere.ui.swing/src/org/compiere/grid/VPaymentFormCheck.java deleted file mode 100644 index ed7400b1ea..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/grid/VPaymentFormCheck.java +++ /dev/null @@ -1,294 +0,0 @@ -/****************************************************************************** - * Copyright (C) 2012 Elaine Tan * - * Copyright (C) 2012 Trek Global - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - *****************************************************************************/ -package org.compiere.grid; - -import java.awt.Dimension; -import java.awt.GridBagConstraints; -import java.awt.GridBagLayout; -import java.awt.Insets; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.awt.event.FocusEvent; -import java.awt.event.FocusListener; -import java.math.BigDecimal; -import java.util.ArrayList; -import java.util.Enumeration; - -import org.adempiere.plaf.AdempierePLAF; -import org.compiere.apps.ADialog; -import org.compiere.grid.ed.VNumber; -import org.compiere.model.GridTab; -import org.compiere.model.MBankAccountProcessor; -import org.compiere.model.MConversionRate; -import org.compiere.model.MPaymentValidate; -import org.compiere.swing.CButton; -import org.compiere.swing.CComboBox; -import org.compiere.swing.CLabel; -import org.compiere.swing.CTextField; -import org.compiere.util.Env; -import org.compiere.util.KeyNamePair; -import org.compiere.util.Msg; - -/** - * - * @author Elaine - * - */ -public class VPaymentFormCheck extends PaymentFormCheck implements ActionListener, FocusListener { - - private VPaymentFormDialog dialog; - - private CLabel sBankAccountLabel = new CLabel(); - private CComboBoxsBankAccountCombo = new CComboBox(); - private CLabel sCurrencyLabel = new CLabel(); - private CComboBoxsCurrencyCombo = new CComboBox(); - private CLabel sAmountLabel = new CLabel(); - private VNumber sAmountField = new VNumber(); - private CLabel sRoutingLabel = new CLabel(); - private CTextField sRoutingField = new CTextField(); - private CLabel sNumberLabel = new CLabel(); - private CTextField sNumberField = new CTextField(); - private CLabel sCheckLabel = new CLabel(); - private CTextField sCheckField = new CTextField(); - private CButton sOnline = new CButton(); - private CLabel sStatus = new CLabel(); - - public VPaymentFormCheck(int windowNo, GridTab mTab) { - super(windowNo, mTab); - dialog = new VPaymentFormDialog(this, windowNo); - init(); - } - - public void init() { - GridBagLayout sPanelLayout = new GridBagLayout(); - dialog.getPanel().setLayout(sPanelLayout); - sBankAccountLabel.setText(Msg.translate(Env.getCtx(), "C_BankAccount_ID")); - sAmountLabel.setText(Msg.getMsg(Env.getCtx(), "Amount")); - //sAmountField.setText(""); - sRoutingLabel.setText(Msg.translate(Env.getCtx(), "RoutingNo")); - sNumberLabel.setText(Msg.translate(Env.getCtx(), "AccountNo")); - sCheckLabel.setText(Msg.translate(Env.getCtx(), "CheckNo")); - sCheckField.setColumns(8); - sCurrencyLabel.setText(Msg.translate(Env.getCtx(), "C_Currency_ID")); - sNumberField.setPreferredSize(new Dimension(100, 21)); - sRoutingField.setPreferredSize(new Dimension(70, 21)); - sOnline.setText(Msg.getMsg(Env.getCtx(), "Online")); - sOnline.addActionListener(this); - dialog.getPanel().add(sBankAccountLabel, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 0, 2, 0), 0, 0)); - dialog.getPanel().add(sBankAccountCombo, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 2, 5), 0, 0)); - dialog.getPanel().add(sCurrencyLabel, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(2, 0, 2, 0), 0, 0)); - dialog.getPanel().add(sCurrencyCombo, new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(2, 5, 2, 5), 0, 0)); - dialog.getPanel().add(sAmountLabel, new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(2, 0, 5, 0), 0, 0)); - dialog.getPanel().add(sAmountField, new GridBagConstraints(1, 2, 1, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(2, 5, 5, 5), 0, 0)); - sAmountField.addFocusListener(this); - dialog.getPanel().add(sRoutingLabel, new GridBagConstraints(0, 3, 1, 2, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 2, 0), 0, 0)); - dialog.getPanel().add(sRoutingField, new GridBagConstraints(1, 3, 2, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 5, 2, 0), 0, 0)); - dialog.getPanel().add(sNumberLabel, new GridBagConstraints(0, 5, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(2, 0, 2, 0), 0, 0)); - dialog.getPanel().add(sNumberField, new GridBagConstraints(1, 5, 2, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 5, 2, 0), 0, 0)); - dialog.getPanel().add(sCheckLabel, new GridBagConstraints(0, 6, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(2, 0, 2, 0), 0, 0)); - dialog.getPanel().add(sCheckField, new GridBagConstraints(1, 6, 1, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(2, 5, 2, 0), 0, 0)); - dialog.getPanel().add(sOnline, new GridBagConstraints(3, 6, 1, 1, 0.0, 0.0 - ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); - dialog.getPanel().add(sStatus, new GridBagConstraints(0, 7, 3, 1, 0.0, 0.0 - ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); - } - - @Override - public void loadData() { - super.loadData(); - - sAmountField.setValue(m_Amount); - - if (m_C_Payment_ID != 0) - { - sRoutingField.setText(m_mPayment.getRoutingNo()); - sNumberField.setText(m_mPayment.getAccountNo()); - sCheckField.setText(m_mPayment.getCheckNo()); - sStatus.setText(m_mPayment.getR_PnRef()); - sAmountField.setValue(m_mPayment.getPayAmt()); - } - - // Is the currency an EMU currency? - Integer C_Currency_ID = Integer.valueOf(m_C_Currency_ID); - if (s_Currencies.containsKey(C_Currency_ID)) - { - Enumeration en = s_Currencies.keys(); - while (en.hasMoreElements()) - { - Object key = en.nextElement(); - sCurrencyCombo.addItem(s_Currencies.get(key)); - } - sCurrencyCombo.addActionListener(this); - sCurrencyCombo.setSelectedItem(s_Currencies.get(C_Currency_ID)); - } - else // No EMU Currency - { - sCurrencyLabel.setVisible(false); // Check - sCurrencyCombo.setVisible(false); - } - - ArrayList list = getBankAccountList(); - for (KeyNamePair pp : list) - sBankAccountCombo.addItem(pp); - - // Set Selection - if (selectedBankAccount != null) - sBankAccountCombo.setSelectedItem(selectedBankAccount); - - boolean exist = isBankAccountProcessorExist(m_C_Currency_ID, (BigDecimal) sAmountField.getValue()); - sOnline.setVisible(exist); - - if (exist) - updateOnlineButton(); - } - - public void actionPerformed(ActionEvent e) - { - if (e.getSource() == sCurrencyCombo) - { - int C_Currency_ID = 0; - KeyNamePair pp = (KeyNamePair)sCurrencyCombo.getSelectedItem(); - if (pp != null) - C_Currency_ID = pp.getKey(); - - BigDecimal amt = MConversionRate.convert(Env.getCtx(), - m_Amount, m_C_Currency_ID, C_Currency_ID, m_AD_Client_ID, m_AD_Org_ID); - sAmountField.setValue(amt); - - updateOnlineButton(); - } - else if (e.getSource() == sOnline) - processOnline(); - } - - @Override - public void focusGained(FocusEvent e) { - } - - @Override - public void focusLost(FocusEvent e) { - if (e.getSource() == sAmountField) - updateOnlineButton(); - } - - private void updateOnlineButton() - { - int C_Currency_ID = 0; - KeyNamePair pp = (KeyNamePair)sCurrencyCombo.getSelectedItem(); - if (pp != null) - C_Currency_ID = pp.getKey(); - - BigDecimal PayAmt = (BigDecimal) sAmountField.getValue(); - - if (C_Currency_ID > 0 && PayAmt != null) - { - MBankAccountProcessor bankAccountProcessor = getBankAccountProcessor(C_Currency_ID, PayAmt); - sOnline.setEnabled(bankAccountProcessor != null); - setBankAccountProcessor(bankAccountProcessor); - } - else - { - sOnline.setEnabled(false); - setBankAccountProcessor(null); - } - } - - @Override - public boolean checkMandatory() { - int C_BankAccount_ID = 0; - /*********************** - * Mandatory Data Check - */ - boolean dataOK = true; - KeyNamePair kp = (KeyNamePair)sBankAccountCombo.getSelectedItem(); - if (kp != null) - C_BankAccount_ID = kp.getKey(); - String error = MPaymentValidate.validateRoutingNo(sRoutingField.getText()); - if (error.length() != 0) - { - sRoutingField.setBackground(AdempierePLAF.getFieldBackground_Error()); - ADialog.error(getWindowNo(), dialog, error); - dataOK = false; - } - error = MPaymentValidate.validateAccountNo(sNumberField.getText()); - if (error.length() != 0) - { - sNumberField.setBackground(AdempierePLAF.getFieldBackground_Error()); - ADialog.error(getWindowNo(), dialog, error); - dataOK = false; - } - error = MPaymentValidate.validateCheckNo(sCheckField.getText()); - if (error.length() != 0) - { - sCheckField.setBackground(AdempierePLAF.getFieldBackground_Error()); - ADialog.error(getWindowNo(), dialog, error); - dataOK = false; - } - - // Check & Cash (Payment) must have a bank account - if (C_BankAccount_ID == 0) - { - ADialog.error(getWindowNo(), dialog, "FillMandatory", sBankAccountLabel.getText()); - dataOK = false; - } - - return dataOK; - } - - @Override - public boolean saveChangesInTrx(String trxName) { - int newC_BankAccount_ID = 0; - KeyNamePair kp = (KeyNamePair)sBankAccountCombo.getSelectedItem(); - if (kp != null) - newC_BankAccount_ID = kp.getKey(); - - boolean ok = save(newC_BankAccount_ID, sRoutingField.getText(), sNumberField.getText(), - sCheckField.getText(), (BigDecimal) sAmountField.getValue(), trxName); - if (!ok) - ADialog.error(getWindowNo(), dialog, "PaymentError", processMsg); - else if (processMsg != null) - ADialog.info(getWindowNo(), dialog, "PaymentCreated", m_mPayment.getDocumentNo()); - - return ok; - } - - @Override - public void showWindow() - { - dialog.setVisible(true); - } - - @Override - public void closeWindow() - { - dialog.dispose(); - } - - @Override - public Object getWindow() { - return dialog; - } -} diff --git a/org.adempiere.ui.swing/src/org/compiere/grid/VPaymentFormCreditCard.java b/org.adempiere.ui.swing/src/org/compiere/grid/VPaymentFormCreditCard.java deleted file mode 100644 index acc8dcea2f..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/grid/VPaymentFormCreditCard.java +++ /dev/null @@ -1,304 +0,0 @@ -/****************************************************************************** - * Copyright (C) 2012 Elaine Tan * - * Copyright (C) 2012 Trek Global - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - *****************************************************************************/ -package org.compiere.grid; - -import java.awt.Dimension; -import java.awt.GridBagConstraints; -import java.awt.GridBagLayout; -import java.awt.Insets; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.awt.event.FocusEvent; -import java.awt.event.FocusListener; -import java.math.BigDecimal; - -import org.adempiere.util.PaymentUtil; -import org.compiere.apps.ADialog; -import org.compiere.grid.ed.VNumber; -import org.compiere.model.GridTab; -import org.compiere.model.MBankAccountProcessor; -import org.compiere.model.MInvoice; -import org.compiere.swing.CButton; -import org.compiere.swing.CComboBox; -import org.compiere.swing.CLabel; -import org.compiere.swing.CTextField; -import org.compiere.util.Env; -import org.compiere.util.Msg; -import org.compiere.util.ValueNamePair; - -/** - * - * @author Elaine - * - */ -public class VPaymentFormCreditCard extends PaymentFormCreditCard implements ActionListener, FocusListener { - - private VPaymentFormDialog dialog; - - private CLabel kTypeLabel = new CLabel(); - private CComboBoxkTypeCombo = new CComboBox(); - private CLabel kNumberLabel = new CLabel(); - private CTextField kNumberField = new CTextField(); - private CLabel kNameLabel = new CLabel(); - private CTextField kNameField = new CTextField(); - private CLabel kExpLabel = new CLabel(); - private CTextField kExpField = new CTextField(); - private CLabel kAmountLabel = new CLabel(); - private VNumber kAmountField = new VNumber(); - private CLabel kApprovalLabel = new CLabel(); - private CTextField kApprovalField = new CTextField(); - private CButton kOnline = new CButton(); - private CLabel kStatus = new CLabel(); - - - public VPaymentFormCreditCard(int windowNo, GridTab mTab) { - super(windowNo, mTab); - dialog = new VPaymentFormDialog(this, windowNo); - init(); - } - - public void init() { - GridBagLayout kLayout = new GridBagLayout(); - dialog.getPanel().setLayout(kLayout); - kNumberField.setPreferredSize(new Dimension(160, 21)); - kNameField.setPreferredSize(new Dimension(160, 21)); - kExpField.setPreferredSize(new Dimension(40, 21)); - kApprovalField.setPreferredSize(new Dimension(120, 21)); - kTypeLabel.setText(Msg.translate(Env.getCtx(), "CreditCardType")); - kNumberLabel.setText(Msg.translate(Env.getCtx(), "CreditCardNumber")); - kNameLabel.setText(Msg.translate(Env.getCtx(),"Name")); - kExpLabel.setText(Msg.getMsg(Env.getCtx(), "Expires")); - kApprovalLabel.setText(Msg.translate(Env.getCtx(), "VoiceAuthCode")); - kAmountLabel.setText(Msg.getMsg(Env.getCtx(), "Amount")); - kOnline.setText(Msg.getMsg(Env.getCtx(), "Online")); - kOnline.addActionListener(this); - dialog.getPanel().add(kTypeLabel, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(2, 0, 2, 0), 0, 0)); - dialog.getPanel().add(kTypeCombo, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(2, 5, 2, 5), 0, 0)); - kTypeCombo.addActionListener(this); - dialog.getPanel().add(kNumberLabel, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(2, 0, 2, 0), 0, 0)); - dialog.getPanel().add(kNumberField, new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.VERTICAL, new Insets(2, 5, 2, 5), 0, 0)); - dialog.getPanel().add(kNameLabel, new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(2, 0, 2, 0), 0, 0)); - dialog.getPanel().add(kNameField, new GridBagConstraints(1, 2, 1, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.VERTICAL, new Insets(2, 5, 2, 5), 0, 0)); - dialog.getPanel().add(kExpLabel, new GridBagConstraints(0, 3, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(2, 0, 2, 0), 0, 0)); - dialog.getPanel().add(kExpField, new GridBagConstraints(1, 3, 1, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(2, 5, 2, 5), 0, 0)); - dialog.getPanel().add(kAmountLabel, new GridBagConstraints(0, 4, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(2, 0, 5, 0), 0, 0)); - dialog.getPanel().add(kAmountField, new GridBagConstraints(1, 4, 1, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(2, 5, 5, 5), 0, 0)); - kAmountField.addFocusListener(this); - dialog.getPanel().add(kApprovalLabel, new GridBagConstraints(0, 5, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 5, 5, 0), 0, 0)); - dialog.getPanel().add(kApprovalField, new GridBagConstraints(1, 5, 1, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); - dialog.getPanel().add(kStatus, new GridBagConstraints(0, 6, 2, 1, 0.0, 0.0 - ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); - dialog.getPanel().add(kOnline, new GridBagConstraints(2, 5, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); - } - - @Override - public void loadData() { - super.loadData(); - - kAmountField.setValue(m_Amount); - - if (m_C_Payment_ID != 0) - { - m_CCType = m_mPayment.getCreditCardType(); - kNumberField.setText(m_mPayment.getCreditCardNumber()); - kNameField.setText(m_mPayment.getA_Name()); - kExpField.setText(m_mPayment.getCreditCardExp(null)); - kApprovalField.setText(m_mPayment.getVoiceAuthCode()); - kStatus.setText(m_mPayment.getR_PnRef()); - kAmountField.setValue(m_mPayment.getPayAmt()); - - // if approved/paid, don't let it change - kTypeCombo.setReadWrite(!(m_mPayment.isApproved() && m_DocStatus.equals(MInvoice.DOCSTATUS_Completed))); - kNumberField.setReadWrite(!(m_mPayment.isApproved() && m_DocStatus.equals(MInvoice.DOCSTATUS_Completed))); - kNameField.setReadWrite(!(m_mPayment.isApproved() && m_DocStatus.equals(MInvoice.DOCSTATUS_Completed))); - kExpField.setReadWrite(!(m_mPayment.isApproved() && m_DocStatus.equals(MInvoice.DOCSTATUS_Completed))); - kApprovalField.setReadWrite(!(m_mPayment.isApproved() && m_DocStatus.equals(MInvoice.DOCSTATUS_Completed))); - kOnline.setReadWrite(!(m_mPayment.isApproved() && m_DocStatus.equals(MInvoice.DOCSTATUS_Completed))); - kAmountField.setReadWrite(!(m_mPayment.isApproved() && m_DocStatus.equals(MInvoice.DOCSTATUS_Completed))); - } - else if (m_mPaymentTransaction != null) - { - m_CCType = m_mPaymentTransaction.getCreditCardType(); - kNumberField.setText(m_mPaymentTransaction.getCreditCardNumber()); - kNameField.setText(m_mPaymentTransaction.getA_Name()); - kExpField.setText(PaymentUtil.getCreditCardExp(m_mPaymentTransaction.getCreditCardExpMM(), m_mPaymentTransaction.getCreditCardExpYY(), null)); - kApprovalField.setText(m_mPaymentTransaction.getVoiceAuthCode()); - kStatus.setText(m_mPaymentTransaction.getR_PnRef()); - kAmountField.setValue(m_mPaymentTransaction.getPayAmt()); - - // if approved/paid, don't let it change - kTypeCombo.setReadWrite(!(m_mPaymentTransaction.isApproved() && m_DocStatus.equals(MInvoice.DOCSTATUS_Completed))); - kNumberField.setReadWrite(!(m_mPaymentTransaction.isApproved() && m_DocStatus.equals(MInvoice.DOCSTATUS_Completed))); - kNameField.setReadWrite(!(m_mPaymentTransaction.isApproved() && m_DocStatus.equals(MInvoice.DOCSTATUS_Completed))); - kExpField.setReadWrite(!(m_mPaymentTransaction.isApproved() && m_DocStatus.equals(MInvoice.DOCSTATUS_Completed))); - kApprovalField.setReadWrite(!(m_mPaymentTransaction.isApproved() && m_DocStatus.equals(MInvoice.DOCSTATUS_Completed))); - kOnline.setReadWrite(!(m_mPaymentTransaction.isApproved() && m_DocStatus.equals(MInvoice.DOCSTATUS_Completed))); - kAmountField.setReadWrite(!(m_mPaymentTransaction.isApproved() && m_DocStatus.equals(MInvoice.DOCSTATUS_Completed))); - } - - /** - * Load Credit Cards - */ - kTypeCombo.removeAllItems(); - - ValueNamePair[] ccs = getCreditCardList(); - for (int i = 0; i < ccs.length; i++) - kTypeCombo.addItem(ccs[i]); - - // Set Selection - if (selectedCreditCard != null) - kTypeCombo.setSelectedItem(selectedCreditCard); - - if (m_mPayment.isApproved() && m_DocStatus.equals(MInvoice.DOCSTATUS_Completed)) - { - kOnline.setVisible(m_mPayment.isOnline()); - kOnline.setEnabled(false); - - MBankAccountProcessor bankAccountProcessor = new MBankAccountProcessor(m_mPayment.getCtx(), m_mPayment.getC_BankAccount_ID(), m_mPayment.getC_PaymentProcessor_ID(), null); - setBankAccountProcessor(bankAccountProcessor); - } - else if (m_mPaymentTransaction != null) - { - kOnline.setVisible(m_mPaymentTransaction.isOnline()); - kOnline.setEnabled(false); - - MBankAccountProcessor bankAccountProcessor = new MBankAccountProcessor(m_mPaymentTransaction.getCtx(), m_mPaymentTransaction.getC_BankAccount_ID(), m_mPaymentTransaction.getC_PaymentProcessor_ID(), null); - setBankAccountProcessor(bankAccountProcessor); - } - else - { - boolean exist = isBankAccountProcessorExist("", (BigDecimal) kAmountField.getValue()); - kOnline.setVisible(exist); - - if (exist) - updateOnlineButton(); - } - } - - public void actionPerformed(ActionEvent e) - { - if (e.getSource() == kOnline) - processOnline(); - else if (e.getSource() == kTypeCombo) - updateOnlineButton(); - } - - @Override - public void focusGained(FocusEvent e) { - } - - @Override - public void focusLost(FocusEvent e) { - if (e.getSource() == kAmountField) - updateOnlineButton(); - } - - private void updateOnlineButton() - { - String CCType = null; - ValueNamePair vp = (ValueNamePair)kTypeCombo.getSelectedItem(); - if (vp != null) - CCType = vp.getValue(); - - BigDecimal PayAmt = (BigDecimal) kAmountField.getValue(); - - if (CCType != null && PayAmt != null) - { - MBankAccountProcessor bankAccountProcessor = getBankAccountProcessor(CCType, PayAmt); - kOnline.setEnabled(bankAccountProcessor != null); - setBankAccountProcessor(bankAccountProcessor); - - if (bankAccountProcessor != null) - kApprovalField.setReadWrite(bankAccountProcessor.isRequireVV()); - else - kApprovalField.setReadWrite(true); - } - else - { - kOnline.setEnabled(false); - setBankAccountProcessor(null); - } - } - - @Override - public boolean checkMandatory() { - return true; - } - - @Override - public boolean saveChangesInTrx(String trxName) { - String newCCType = m_CCType; - ValueNamePair vp = (ValueNamePair)kTypeCombo.getSelectedItem(); - if (vp != null) - newCCType = vp.getValue(); - - boolean ok = save(newCCType, kNumberField.getText(), kExpField.getText(), (BigDecimal) kAmountField.getValue(), trxName); - if(!ok) - ADialog.error(getWindowNo(), dialog, "PaymentError", processMsg); - else if (processMsg != null) - ADialog.info(getWindowNo(), dialog, "PaymentCreated", processMsg); - - return ok; - - } - - /************************************************************************** - * Process Online (sales only) - if approved - exit - */ - public void processOnline() - { - ValueNamePair vp = (ValueNamePair)kTypeCombo.getSelectedItem(); - String CCType = vp.getValue(); - - boolean ok = processOnline(CCType, kNumberField.getText(), kApprovalField.getText(), kExpField.getText()); - if (!ok) - ADialog.error(getWindowNo(), dialog, "PaymentError", processMsg); - else - { - loadData(); - if (processMsg != null) - ADialog.info(getWindowNo(), dialog, "PaymentProcessed", processMsg); - } - } // online - - @Override - public void showWindow() - { - dialog.setVisible(true); - } - - @Override - public void closeWindow() - { - dialog.dispose(); - } - - @Override - public Object getWindow() { - return dialog; - } -} diff --git a/org.adempiere.ui.swing/src/org/compiere/grid/VPaymentFormDialog.java b/org.adempiere.ui.swing/src/org/compiere/grid/VPaymentFormDialog.java deleted file mode 100644 index bcbc37b4c9..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/grid/VPaymentFormDialog.java +++ /dev/null @@ -1,115 +0,0 @@ -/****************************************************************************** - * Copyright (C) 2012 Elaine Tan * - * Copyright (C) 2012 Trek Global - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - *****************************************************************************/ -package org.compiere.grid; - -import java.awt.BorderLayout; -import java.awt.Dimension; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; - -import javax.swing.BorderFactory; - -import org.compiere.apps.ADialog; -import org.compiere.apps.AEnv; -import org.compiere.apps.ConfirmPanel; -import org.compiere.swing.CDialog; -import org.compiere.swing.CPanel; -import org.compiere.util.Env; -import org.compiere.util.Msg; - -/** - * - * @author Elaine - * - */ -public class VPaymentFormDialog extends CDialog implements ActionListener -{ - /** - * - */ - private static final long serialVersionUID = 6249016140530436885L; - private PaymentForm paymentForm; -// private int windowNo; - - private CPanel mainPanel = new CPanel(); - private BorderLayout mainLayout = new BorderLayout(); - private CPanel centerPanel = new CPanel(); - private ConfirmPanel confirmPanel = new ConfirmPanel(true); - - private boolean initOK = false; - - public VPaymentFormDialog(PaymentForm paymentForm, int windowNo) - { - super(AEnv.getWindow(windowNo), Msg.getMsg(Env.getCtx(), "Payment"), true); - - this.paymentForm = paymentForm; -// this.windowNo = windowNo; - - try { - jbInit(); - initOK = dynInit(); // Null Pointer if order/invoice not saved yet - } catch (Exception ex) { - ADialog.error(windowNo, this, ex.getMessage()); - initOK = false; - } - - setPreferredSize(new Dimension(500, 400)); - pack(); - } - - private void jbInit() throws Exception - { - getContentPane().add(mainPanel); - mainPanel.setLayout(mainLayout); - centerPanel.setBorder(BorderFactory.createRaisedBevelBorder()); - mainPanel.add(centerPanel, BorderLayout.CENTER); - mainPanel.add(confirmPanel, BorderLayout.SOUTH); - confirmPanel.addActionListener(this); - } - - private boolean dynInit() throws Exception - { - boolean isInitOK = paymentForm.dynInit(); - centerPanel.setVisible(!paymentForm.isOnlyRule()); - return isInitOK; - } - - public CPanel getPanel() { - return centerPanel; - } - - /************************************************************************** - * Action Listener - * @param e event - */ - public void actionPerformed(ActionEvent e) - { - // Finish - if (e.getActionCommand().equals(ConfirmPanel.A_OK)) - { - if (paymentForm.checkMandatory()) - { - paymentForm.saveChanges(); // cannot recover - dispose (); - } - } - else if (e.getActionCommand().equals(ConfirmPanel.A_CANCEL)) - dispose(); - } - - public boolean isInitOK() - { - return initOK; - } -} \ No newline at end of file diff --git a/org.adempiere.ui.swing/src/org/compiere/grid/VPaymentFormDirect.java b/org.adempiere.ui.swing/src/org/compiere/grid/VPaymentFormDirect.java deleted file mode 100644 index 7824e54231..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/grid/VPaymentFormDirect.java +++ /dev/null @@ -1,159 +0,0 @@ -/****************************************************************************** - * Copyright (C) 2012 Elaine Tan * - * Copyright (C) 2012 Trek Global - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - *****************************************************************************/ -package org.compiere.grid; - -import java.awt.GridBagConstraints; -import java.awt.GridBagLayout; -import java.awt.Insets; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.util.ArrayList; -import java.util.logging.Level; - -import org.adempiere.plaf.AdempierePLAF; -import org.compiere.apps.ADialog; -import org.compiere.model.GridTab; -import org.compiere.model.MBankAccountProcessor; -import org.compiere.swing.CButton; -import org.compiere.swing.CComboBox; -import org.compiere.swing.CLabel; -import org.compiere.swing.CTextField; -import org.compiere.util.Env; -import org.compiere.util.KeyNamePair; -import org.compiere.util.Msg; - -/** - * - * @author Elaine - * - */ -public abstract class VPaymentFormDirect extends PaymentFormDirect implements ActionListener { - - private VPaymentFormDialog dialog; - - private CLabel tAccountLabel = new CLabel(); - private CComboBoxtAccountCombo = new CComboBox(); - private CButton tOnline = new CButton(); - private CTextField tRoutingField = new CTextField(); - private CTextField tNumberField = new CTextField(); - private CLabel tStatus = new CLabel(); - private CLabel tRoutingText = new CLabel(); - private CLabel tNumberText = new CLabel(); - - public VPaymentFormDirect(int windowNo, GridTab mTab, boolean isDebit) { - super(windowNo, mTab, isDebit); - dialog = new VPaymentFormDialog(this, windowNo); - init(); - } - - public void init() { - GridBagLayout tPanelLayout = new GridBagLayout(); - dialog.getPanel().setLayout(tPanelLayout); - tAccountLabel.setText(Msg.translate(Env.getCtx(), "C_BP_BankAccount_ID")); - tRoutingField.setColumns(8); - tNumberField.setColumns(10); - tRoutingText.setText(Msg.translate(Env.getCtx(), "RoutingNo")); - tNumberText.setText(Msg.translate(Env.getCtx(), "AccountNo")); - tOnline.setText(Msg.getMsg(Env.getCtx(), "Online")); - tOnline.addActionListener(this); - dialog.getPanel().add(tAccountLabel, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 5, 5, 0), 0, 0)); - dialog.getPanel().add(tAccountCombo, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); - dialog.getPanel().add(tRoutingField, new GridBagConstraints(1, 1, 2, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 0, 5), 0, 0)); - dialog.getPanel().add(tNumberField, new GridBagConstraints(1, 2, 1, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 0, 5), 0, 0)); - dialog.getPanel().add(tStatus, new GridBagConstraints(0, 3, 2, 1, 0.0, 0.0 - ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); - dialog.getPanel().add(tRoutingText, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 5, 0, 0), 0, 0)); - dialog.getPanel().add(tNumberText, new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 5, 0, 0), 0, 0)); - dialog.getPanel().add(tOnline, new GridBagConstraints(3, 2, 1, 1, 0.0, 0.0 - ,GridBagConstraints.NORTHEAST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); - } - - @Override - public void loadData() { - if (m_C_Payment_ID != 0) - { - tRoutingField.setText(m_mPayment.getRoutingNo()); - tNumberField.setText(m_mPayment.getAccountNo()); - tStatus.setText(m_mPayment.getR_PnRef()); - } - - ArrayList list = getBPBankAccountList(); - for (KeyNamePair pp : list) - tAccountCombo.addItem(pp); - - boolean exist = isBankAccountProcessorExist(); - tOnline.setVisible(exist); - - MBankAccountProcessor bankAccountProcessor = getBankAccountProcessor(); - setBankAccountProcessor(bankAccountProcessor); - } - - public void actionPerformed(ActionEvent e) - { - if (e.getSource() == tOnline) - processOnline(); - } - - @Override - public boolean checkMandatory() { - /*********************** - * Mandatory Data Check - */ - boolean dataOK = true; - KeyNamePair bpba = (KeyNamePair)tAccountCombo.getSelectedItem(); - if (bpba == null) - { - tAccountCombo.setBackground(AdempierePLAF.getFieldBackground_Error()); - ADialog.error(getWindowNo(), dialog, "PaymentBPBankNotFound"); - dataOK = false; - } - // - if (log.isLoggable(Level.CONFIG)) log.config("OK=" + dataOK); - return dataOK; - } - - @Override - public boolean saveChangesInTrx(String trxName) { - boolean ok = save(0, tRoutingField.getText(), tNumberField.getText(), trxName); - if (!ok) - ADialog.error(getWindowNo(), dialog, "PaymentError", processMsg); - else if (processMsg != null) - ADialog.info(getWindowNo(), dialog, "PaymentCreated", m_mPayment.getDocumentNo()); - - return ok; - } - - @Override - public void showWindow() - { - dialog.setVisible(true); - } - - @Override - public void closeWindow() - { - dialog.dispose(); - } - - @Override - public Object getWindow() { - return dialog; - } -} diff --git a/org.adempiere.ui.swing/src/org/compiere/grid/VPaymentFormDirectDebit.java b/org.adempiere.ui.swing/src/org/compiere/grid/VPaymentFormDirectDebit.java deleted file mode 100644 index 0b537ad20f..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/grid/VPaymentFormDirectDebit.java +++ /dev/null @@ -1,30 +0,0 @@ -/****************************************************************************** - * Copyright (C) 2012 Elaine Tan * - * Copyright (C) 2012 Trek Global - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - *****************************************************************************/ -package org.compiere.grid; - -import org.compiere.model.GridTab; - - -/** - * - * @author Elaine - * - */ -public class VPaymentFormDirectDebit extends VPaymentFormDirect { - - public VPaymentFormDirectDebit(int windowNo, GridTab mTab) { - super(windowNo, mTab, true); - } - -} diff --git a/org.adempiere.ui.swing/src/org/compiere/grid/VPaymentFormDirectDeposit.java b/org.adempiere.ui.swing/src/org/compiere/grid/VPaymentFormDirectDeposit.java deleted file mode 100644 index 83d2e145e1..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/grid/VPaymentFormDirectDeposit.java +++ /dev/null @@ -1,29 +0,0 @@ -/****************************************************************************** - * Copyright (C) 2012 Elaine Tan * - * Copyright (C) 2012 Trek Global - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - *****************************************************************************/ -package org.compiere.grid; - -import org.compiere.model.GridTab; - - -/** - * - * @author Elaine - * - */ -public class VPaymentFormDirectDeposit extends VPaymentFormDirect { - - public VPaymentFormDirectDeposit(int windowNo, GridTab mTab) { - super(windowNo, mTab, false); - } -} diff --git a/org.adempiere.ui.swing/src/org/compiere/grid/VPaymentFormFactory.java b/org.adempiere.ui.swing/src/org/compiere/grid/VPaymentFormFactory.java deleted file mode 100644 index 2c0be9a692..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/grid/VPaymentFormFactory.java +++ /dev/null @@ -1,39 +0,0 @@ -/****************************************************************************** - * Copyright (C) 2012 Elaine Tan * - * Copyright (C) 2012 Trek Global - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - *****************************************************************************/ -package org.compiere.grid; - -import java.util.List; - -import org.adempiere.base.Service; -import org.compiere.model.GridTab; - -/** - * - * @author Elaine - * - */ -public class VPaymentFormFactory { - - public static IPaymentForm create(int windowNo, GridTab mTab, String paymentRule) - { - IPaymentForm paymentForm = null; - List factories = Service.locator().list(IPaymentFormFactory.class).getServices(); - for (IPaymentFormFactory factory : factories) { - paymentForm = factory.create(windowNo, mTab, paymentRule); - if (paymentForm != null) - break; - } - return paymentForm; - } -} diff --git a/org.adempiere.ui.swing/src/org/compiere/grid/VPaymentFormMixedPOS.java b/org.adempiere.ui.swing/src/org/compiere/grid/VPaymentFormMixedPOS.java deleted file mode 100644 index 7ad7c2a286..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/grid/VPaymentFormMixedPOS.java +++ /dev/null @@ -1,61 +0,0 @@ -/****************************************************************************** - * Copyright (C) 2012 Elaine Tan * - * Copyright (C) 2012 Trek Global - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - *****************************************************************************/ -package org.compiere.grid; - -import org.compiere.model.GridTab; - -/** - * - * @author Elaine - * - */ -public class VPaymentFormMixedPOS extends PaymentFormMixedPOS { - private VPaymentFormDialog dialog; - - public VPaymentFormMixedPOS(int windowNo, GridTab mTab) { - super(windowNo, mTab); - dialog = new VPaymentFormDialog(this, windowNo); - } - - @Override - public void loadData() { - } - - @Override - public boolean checkMandatory() { - return true; - } - - @Override - public boolean saveChangesInTrx(String trxName) { - return true; - } - - @Override - public void showWindow() - { - dialog.setVisible(true); - } - - @Override - public void closeWindow() - { - dialog.dispose(); - } - - @Override - public Object getWindow() { - return dialog; - } -} diff --git a/org.adempiere.ui.swing/src/org/compiere/grid/VPaymentFormOnCredit.java b/org.adempiere.ui.swing/src/org/compiere/grid/VPaymentFormOnCredit.java deleted file mode 100644 index 6fdf0cbcfb..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/grid/VPaymentFormOnCredit.java +++ /dev/null @@ -1,100 +0,0 @@ -/****************************************************************************** - * Copyright (C) 2012 Elaine Tan * - * Copyright (C) 2012 Trek Global - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - *****************************************************************************/ -package org.compiere.grid; - -import java.awt.GridBagConstraints; -import java.awt.GridBagLayout; -import java.awt.Insets; -import java.util.ArrayList; - -import org.compiere.model.GridTab; -import org.compiere.swing.CComboBox; -import org.compiere.swing.CLabel; -import org.compiere.util.Env; -import org.compiere.util.KeyNamePair; -import org.compiere.util.Msg; - -/** - * - * @author Elaine - * - */ -public class VPaymentFormOnCredit extends PaymentFormOnCredit { - - private VPaymentFormDialog dialog; - - private CLabel pTermLabel = new CLabel(); - private CComboBoxpTermCombo = new CComboBox(); - - public VPaymentFormOnCredit(int windowNo, GridTab mTab) { - super(windowNo, mTab); - dialog = new VPaymentFormDialog(this, windowNo); - init(); - } - - public void init() { - GridBagLayout pPanelLayout = new GridBagLayout(); - dialog.getPanel().setLayout(pPanelLayout); - pTermLabel.setText(Msg.translate(Env.getCtx(), "C_PaymentTerm_ID")); - dialog.getPanel().add(pTermLabel, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(2, 5, 2, 0), 0, 0)); - dialog.getPanel().add(pTermCombo, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(2, 5, 2, 5), 0, 0)); - } - - @Override - public void loadData() { - super.loadData(); - - ArrayList list = getPaymentTermList(); - for (KeyNamePair pp : list) - pTermCombo.addItem(pp); - - // Set Selection - if (selectedPaymentTerm != null) - pTermCombo.setSelectedItem(selectedPaymentTerm); - } - - @Override - public boolean checkMandatory() { - return true; - } - - @Override - public boolean saveChangesInTrx(String trxName) { - int newC_PaymentTerm_ID = 0; - KeyNamePair kp = (KeyNamePair)pTermCombo.getSelectedItem(); - if (kp != null) - newC_PaymentTerm_ID = kp.getKey(); - - return save(newC_PaymentTerm_ID); - } - - @Override - public void showWindow() - { - dialog.setVisible(true); - } - - @Override - public void closeWindow() - { - dialog.dispose(); - } - - @Override - public Object getWindow() { - return dialog; - } -} diff --git a/org.adempiere.ui.swing/src/org/compiere/grid/VSortTab.java b/org.adempiere.ui.swing/src/org/compiere/grid/VSortTab.java deleted file mode 100644 index b5702475b6..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/grid/VSortTab.java +++ /dev/null @@ -1,921 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ -package org.compiere.grid; - -import java.awt.AWTEvent; -import java.awt.Component; -import java.awt.Cursor; -import java.awt.Dimension; -import java.awt.Font; -import java.awt.GridBagConstraints; -import java.awt.GridBagLayout; -import java.awt.Image; -import java.awt.Insets; -import java.awt.Point; -import java.awt.Toolkit; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.awt.event.MouseAdapter; -import java.awt.event.MouseEvent; -import java.awt.event.MouseListener; -import java.awt.event.MouseMotionAdapter; -import java.awt.event.MouseMotionListener; -import java.net.URL; -import java.sql.PreparedStatement; -import java.sql.ResultSet; -import java.sql.SQLException; -import java.util.Arrays; -import java.util.List; -import java.util.logging.Level; - -import javax.swing.DefaultListCellRenderer; -import javax.swing.DefaultListModel; -import javax.swing.JList; -import javax.swing.JScrollPane; -import javax.swing.ListSelectionModel; -import javax.swing.SwingUtilities; -import javax.swing.event.MouseInputAdapter; -import javax.swing.event.MouseInputListener; - -import org.compiere.apps.ADialog; -import org.compiere.apps.APanel; -import org.compiere.model.MRole; -import org.compiere.swing.CButton; -import org.compiere.swing.CLabel; -import org.compiere.swing.CPanel; -import org.compiere.util.CLogger; -import org.compiere.util.DB; -import org.compiere.util.Env; -import org.compiere.util.Msg; -import org.compiere.util.NamePair; - -/** - * Tab to maintain Order/Sequence - * - * @author Jorg Janke - * @version $Id: VSortTab.java,v 1.2 2006/07/30 00:51:28 jjanke Exp $ - * - * @author Teo Sarca, SC ARHIPAC SERVICE SRL - * FR [ 1779410 ] VSortTab: display ID for not visible columns - * @author victor.perez@e-evolution.com, e-Evolution - * FR [ 2826406 ] The Tab Sort without parent column - *
  • https://sourceforge.net/tracker/?func=detail&atid=879335&aid=2826406&group_id=176962 - */ -public class VSortTab extends CPanel implements APanelTab -{ - /** - * - */ - private static final long serialVersionUID = -2133358506913610514L; - - /** - * Tab Order Constructor - * - * @param WindowNo Window No - * @param AD_Table_ID Table No - * @param AD_ColumnSortOrder_ID Sort Column - * @param AD_ColumnSortYesNo_ID YesNo Column - */ - public VSortTab(int WindowNo, int AD_Table_ID, int AD_ColumnSortOrder_ID, int AD_ColumnSortYesNo_ID) - { - if (log.isLoggable(Level.CONFIG)) log.config("SortOrder=" + AD_ColumnSortOrder_ID + ", SortYesNo=" + AD_ColumnSortYesNo_ID); - m_WindowNo = WindowNo; - - try - { - jbInit(); - dynInit (AD_Table_ID, AD_ColumnSortOrder_ID, AD_ColumnSortYesNo_ID); - } - catch(Exception e) - { - log.log(Level.SEVERE, "", e); - } - } // VSortTab - - /** Logger */ - static CLogger log = CLogger.getCLogger(VSortTab.class); - private int m_WindowNo; - private int m_AD_Table_ID; - private String m_TableName = null; - private String m_ColumnSortName= null; - private String m_ColumnYesNoName = null; - private String m_KeyColumnName = null; - private String m_IdentifierSql = null; - private boolean m_IdentifierTranslated = false; - - private String m_ParentColumnName = null; - private APanel m_aPanel = null; - - // UI variables - private GridBagLayout mainLayout = new GridBagLayout(); - private CLabel noLabel = new CLabel(); - private CLabel yesLabel = new CLabel(); - private CButton bAdd = new CButton(); - private CButton bRemove = new CButton(); - private CButton bUp = new CButton(); - private CButton bDown = new CButton(); - // - DefaultListModel noModel = new DefaultListModel() - { - /** - * - */ - private static final long serialVersionUID = 2171680655634744697L; - @Override - public void addElement(Object obj) { - Object[] elements = toArray(); - Arrays.sort(elements); - int index = Arrays.binarySearch(elements, obj); - if (index < 0) - index = -1 * index - 1; - if (index > elements.length) - super.addElement(obj); - else - super.add(index, obj); - } - @Override - public void add(int index, Object obj) { - addElement(obj); - } - }; - DefaultListModel yesModel = new DefaultListModel(); - DefaultListCellRenderer listRenderer = new DefaultListCellRenderer() { - /** - * - */ - private static final long serialVersionUID = -101524191283634472L; - - @Override - public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { - Component c = super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); - if (value != null && value instanceof ListItem && !((ListItem)value).isUpdateable()) { - Font f = c.getFont(); - c.setFont(f.deriveFont(f.getStyle() | Font.ITALIC)); - c.setFocusable(false); - } - return c; - } - - }; - JList noList = new JList(noModel); - JList yesList = new JList(yesModel); - private JScrollPane noPane = new JScrollPane(noList); - private JScrollPane yesPane = new JScrollPane(yesList); - - /** - * Dyanamic Init - * @param AD_Table_ID Table No - * @param AD_ColumnSortOrder_ID Sort Column - * @param AD_ColumnSortYesNo_ID YesNo Column - */ - private void dynInit (int AD_Table_ID, int AD_ColumnSortOrder_ID, int AD_ColumnSortYesNo_ID) - { - m_AD_Table_ID = AD_Table_ID; - int identifiersCount = 0; - StringBuilder identifierSql = new StringBuilder(); - String sql = "SELECT t.TableName, c.AD_Column_ID, c.ColumnName, e.Name," // 1..4 - + "c.IsParent, c.IsKey, c.IsIdentifier, c.IsTranslated " // 4..8 - + "FROM AD_Table t, AD_Column c, AD_Element e " - + "WHERE t.AD_Table_ID=?" // #1 - + " AND t.AD_Table_ID=c.AD_Table_ID" - + " AND (c.AD_Column_ID=? OR AD_Column_ID=?" // #2..3 - + " OR c.IsParent='Y' OR c.IsKey='Y' OR c.IsIdentifier='Y')" - + " AND c.AD_Element_ID=e.AD_Element_ID"; - boolean trl = !Env.isBaseLanguage(Env.getCtx(), "AD_Element"); - if (trl) - sql = "SELECT t.TableName, c.AD_Column_ID, c.ColumnName, et.Name," // 1..4 - + "c.IsParent, c.IsKey, c.IsIdentifier, c.IsTranslated " // 4..8 - + "FROM AD_Table t, AD_Column c, AD_Element_Trl et " - + "WHERE t.AD_Table_ID=?" // #1 - + " AND t.AD_Table_ID=c.AD_Table_ID" - + " AND (c.AD_Column_ID=? OR AD_Column_ID=?" // #2..3 - + " OR c.IsParent='Y' OR c.IsKey='Y' OR c.IsIdentifier='Y')" - + " AND c.AD_Element_ID=et.AD_Element_ID" - + " AND et.AD_Language=?"; // #4 - sql += " ORDER BY c.SeqNo"; - PreparedStatement pstmt = null; - ResultSet rs = null; - try - { - pstmt = DB.prepareStatement(sql, null); - pstmt.setInt(1, AD_Table_ID); - pstmt.setInt(2, AD_ColumnSortOrder_ID); - pstmt.setInt(3, AD_ColumnSortYesNo_ID); - if (trl) - pstmt.setString(4, Env.getAD_Language(Env.getCtx())); - rs = pstmt.executeQuery(); - while (rs.next()) - { - m_TableName = rs.getString(1); - // Sort Column - if (AD_ColumnSortOrder_ID == rs.getInt(2)) - { - if (log.isLoggable(Level.FINE)) log.fine("Sort=" + rs.getString(1) + "." + rs.getString(3)); - m_ColumnSortName = rs.getString(3); - yesLabel.setText(rs.getString(4)); - } - // Optional YesNo - else if (AD_ColumnSortYesNo_ID == rs.getInt(2)) - { - if (log.isLoggable(Level.FINE)) log.fine("YesNo=" + rs.getString(1) + "." + rs.getString(3)); - m_ColumnYesNoName = rs.getString(3); - } - // Parent2 - else if (rs.getString(5).equals("Y")) - { - if (log.isLoggable(Level.FINE)) log.fine("Parent=" + rs.getString(1) + "." + rs.getString(3)); - m_ParentColumnName = rs.getString(3); - } - // KeyColumn - else if (rs.getString(6).equals("Y")) - { - if (log.isLoggable(Level.FINE)) log.fine("Key=" + rs.getString(1) + "." + rs.getString(3)); - m_KeyColumnName = rs.getString(3); - } - // Identifier - else if (rs.getString(7).equals("Y")) - { - if (log.isLoggable(Level.FINE)) log.fine("Identifier=" + rs.getString(1) + "." + rs.getString(3)); - boolean isTranslated = trl && "Y".equals(rs.getString(8)); - if (identifierSql.length() > 0) - identifierSql.append(","); - identifierSql.append(isTranslated ? "tt." : "t.").append(rs.getString(3)); - identifiersCount++; -// m_IdentifierColumnName = rs.getString(3); - if (isTranslated) - m_IdentifierTranslated = true; - } - else - if (log.isLoggable(Level.FINE)) log.fine("??NotUsed??=" + rs.getString(1) + "." + rs.getString(3)); - } - } - catch (SQLException e) - { - log.log(Level.SEVERE, sql.toString(), e); - } - finally - { - DB.close(rs, pstmt); - rs = null; pstmt = null; - } - // - if (identifiersCount == 0) - m_IdentifierSql = "NULL"; - else if (identifiersCount == 1) - m_IdentifierSql = identifierSql.toString(); - else - m_IdentifierSql = identifierSql.insert(0, "COALESCE(").append(")").toString(); - // - noLabel.setText(Msg.getMsg(Env.getCtx(), "Available")); - log.fine(m_ColumnSortName); - } // dynInit - - /** - * Static Layout - * @throws Exception - */ - private void jbInit() throws Exception - { - this.setLayout(mainLayout); - // - noLabel.setText("No"); - yesLabel.setText("Yes"); - - for (MouseMotionListener mml : noList.getMouseMotionListeners()) - noList.removeMouseMotionListener(mml); - - for (MouseMotionListener mml : yesList.getMouseMotionListeners()) - yesList.removeMouseMotionListener(mml); - - MouseListener mouseListener = new MouseAdapter() - { - public void mouseClicked(MouseEvent me) - { - if (me.getClickCount() > 1) - { - JList list = (JList)me.getComponent(); - Point p = me.getPoint(); - int index = list.locationToIndex(p); - if (index > -1 && list.getCellBounds(index, index).contains(p)) - migrateValueAcrossLists(me); - } - } - }; - yesList.addMouseListener(mouseListener); - noList.addMouseListener(mouseListener); - // - yesList.setCellRenderer(listRenderer); - noList.setCellRenderer(listRenderer); - - ActionListener actionListener = new ActionListener() - { - public void actionPerformed(ActionEvent ae) - { - migrateValueAcrossLists(ae); - } - }; - - bAdd.setIcon(Env.getImageIcon("Detail24.gif")); - bAdd.setMargin(new Insets(2, 2, 2, 2)); - bAdd.addActionListener(actionListener); - - bRemove.setIcon(Env.getImageIcon("Parent24.gif")); - bRemove.setMargin(new Insets(2, 2, 2, 2)); - bRemove.addActionListener(actionListener); - - MouseInputListener crossListMouseListener = new DragListener(); - yesList.addMouseListener(crossListMouseListener); - yesList.addMouseMotionListener(crossListMouseListener); - noList.addMouseListener(crossListMouseListener); - noList.addMouseMotionListener(crossListMouseListener); - - actionListener = new ActionListener() - { - public void actionPerformed(ActionEvent ae) - { - migrateValueWithinYesList(ae); - } - }; - - bUp.setIcon(Env.getImageIcon("Previous24.gif")); - bUp.setMargin(new Insets(2, 2, 2, 2)); - bUp.addActionListener(actionListener); - - bDown.setIcon(Env.getImageIcon("Next24.gif")); - bDown.setMargin(new Insets(2, 2, 2, 2)); - bDown.addActionListener(actionListener); - - MouseMotionListener yesListMouseMotionListener = new MouseMotionAdapter() - { - public void mouseDragged(MouseEvent me) - { - JList list = (JList)me.getComponent(); - Point p = me.getPoint(); - int index = list.locationToIndex(p); - if (index > -1 && list.getCellBounds(index, index).contains(p)) - migrateValueWithinYesList(me); - } - }; - yesList.addMouseMotionListener(yesListMouseMotionListener); - - yesPane.setPreferredSize(new Dimension(200, 300)); - yesList.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); - - noPane.setPreferredSize(new Dimension(200, 300)); - noList.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); - - this.add(noLabel, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0 - ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); - this.add(yesLabel, new GridBagConstraints(2, 0, 1, 1, 0.0, 0.0 - ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); - this.add(bDown, new GridBagConstraints(3, 2, 1, 1, 0.0, 0.0 - ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(4, 4, 4, 4), 0, 0)); - this.add(noPane, new GridBagConstraints(0, 1, 1, 3, 0.0, 0.0 - ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(4, 4, 4, 4), 0, 0)); - this.add(yesPane, new GridBagConstraints(2, 1, 1, 3, 0.0, 0.0 - ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(4, 4, 4, 4), 0, 0)); - this.add(bUp, new GridBagConstraints(3, 1, 1, 1, 0.0, 0.0 - ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(4, 4, 4, 4), 0, 0)); - this.add(bAdd, new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0 - ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(4, 4, 4, 4), 0, 0)); - this.add(bRemove, new GridBagConstraints(1, 2, 1, 1, 0.0, 0.0 - ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(4, 4, 4, 4), 0, 0)); - } // jbInit - - /* (non-Javadoc) - * @see org.compiere.grid.APanelTab#loadData() - */ - public void loadData() - { - yesModel.removeAllElements(); - noModel.removeAllElements(); - - boolean isReadWrite = true; - // SELECT t.AD_Field_ID,t.Name,t.SeqNo,t.IsDisplayed FROM AD_Field t WHERE t.AD_Tab_ID=? ORDER BY 4 DESC,3,2 - // SELECT t.AD_PrintFormatItem_ID,t.Name,t.SeqNo,t.IsPrinted FROM AD_PrintFormatItem t WHERE t.AD_PrintFormat_ID=? ORDER BY 4 DESC,3,2 - // SELECT t.AD_PrintFormatItem_ID,t.Name,t.SortNo,t.IsOrderBy FROM AD_PrintFormatItem t WHERE t.AD_PrintFormat_ID=? ORDER BY 4 DESC,3,2 - StringBuilder sql = new StringBuilder(); - // Columns - sql.append("SELECT t.").append(m_KeyColumnName) // 1 - .append(",").append(m_IdentifierSql) // 2 - .append(",t.").append(m_ColumnSortName) // 3 - .append(", t.AD_Client_ID, t.AD_Org_ID"); // 4, 5 - if (m_ColumnYesNoName != null) - sql.append(",t.").append(m_ColumnYesNoName); // 6 - // Tables - sql.append(" FROM ").append(m_TableName).append( " t"); - if (m_IdentifierTranslated) - sql.append(", ").append(m_TableName).append("_Trl tt"); - // Where - //FR [ 2826406 ] - if(m_ParentColumnName != null) - { - sql.append(" WHERE t.").append(m_ParentColumnName).append("=?"); - } - else - { - sql.append(" WHERE 1=?"); - } - - int reportView_ID = Env.getContextAsInt(Env.getCtx(), m_WindowNo, "AD_ReportView_ID"); - if (reportView_ID > 0) - sql.append(" AND (t.AD_Column_ID IN (SELECT AD_Column_ID FROM AD_ReportView_Column WHERE AD_ReportView_ID=") - .append(reportView_ID).append(" AND IsActive='Y')") - .append(" OR ((SELECT COUNT(*) FROM AD_ReportView_Column WHERE AD_ReportView_ID=").append(reportView_ID).append(" AND IsActive='Y') = 0))"); - - if (m_IdentifierTranslated) - sql.append(" AND t.").append(m_KeyColumnName).append("=tt.").append(m_KeyColumnName) - .append(" AND tt.AD_Language=?"); - // Order - sql.append(" ORDER BY "); - if (m_ColumnYesNoName != null) - sql.append("6 DESC,"); // t.IsDisplayed DESC - sql.append("3,2"); // t.SeqNo, tt.Name - //FR [ 2826406 ] - int ID = 0; - if(m_ParentColumnName != null) - { - ID = Env.getContextAsInt(Env.getCtx(), m_WindowNo, m_ParentColumnName); - if (log.isLoggable(Level.FINE)) log.fine(sql.toString() + " - ID=" + ID); - } - else - { - ID = 1; - } - PreparedStatement pstmt = null; - ResultSet rs = null; - try - { - pstmt = DB.prepareStatement(sql.toString(), null); - pstmt.setInt(1, ID); - - if (m_IdentifierTranslated) - pstmt.setString(2, Env.getAD_Language(Env.getCtx())); - - rs = pstmt.executeQuery(); - while (rs.next()) - { - int key = rs.getInt(1); - String name = rs.getString(2); - int seq = rs.getInt(3); - boolean isYes = seq != 0; - int AD_Client_ID = rs.getInt(4); - int AD_Org_ID = rs.getInt(5); - if (m_ColumnYesNoName != null) - isYes = rs.getString(6).equals("Y"); - - // - ListItem pp = new ListItem(key, name, seq, isYes, AD_Client_ID, AD_Org_ID); - if (isYes) - yesModel.addElement(pp); - else - noModel.addElement(pp); - // If the one item from "Yes" list is readonly make entire tab readonly - if (isYes && !pp.isUpdateable()) { - isReadWrite = false; - } - } - } - catch (SQLException e) - { - log.log(Level.SEVERE, sql.toString(), e); - } - finally - { - DB.close(rs, pstmt); - rs = null; pstmt = null; - } - - setIsChanged(false); - bAdd.setEnabled(isReadWrite); - bRemove.setEnabled(isReadWrite); - bUp.setEnabled(isReadWrite); - bDown.setEnabled(isReadWrite); - yesList.setEnabled(isReadWrite); - noList.setEnabled(isReadWrite); - } // loadData - - /** - * Set tab change status. - * @param value - */ - private void setIsChanged(boolean value) { - if (m_aPanel != null) { - m_aPanel.aSave.setEnabled(value); - m_aPanel.aIgnore.setEnabled(value); - } - } - - /** - * @param event - */ - void migrateValueAcrossLists (AWTEvent event) - { - Object source = event.getSource(); - List selObjects = (source == bAdd || source == noList) ? - noList.getSelectedValuesList() : yesList.getSelectedValuesList(); - for (int i = 0; i < selObjects.size(); i++) - { - ListItem selObject = (ListItem)selObjects.get(i); - if (selObject == null || !selObject.isUpdateable()) - continue; - - DefaultListModel lmFrom = (source == bAdd || source == noList) ? - noModel : yesModel; - DefaultListModel lmTo = (lmFrom == yesModel) ? noModel : yesModel; - lmFrom.removeElement(selObject); - lmTo.addElement(selObject); - - JList list = (source == bAdd || source == noList) ? - yesList : noList; - list.setSelectedValue(selObject, true); - - // Enable explicit Save - setIsChanged(true); - } - } // migrateValueAcrossLists - - /** - * Move within Yes List - * @param event event - */ - void migrateValueWithinYesList (AWTEvent event) - { - List selObjects = yesList.getSelectedValuesList(); - if (selObjects == null) - return; - int length = selObjects.size(); - if (length == 0) - return; -// Object selObject = selObjects[0]; -// if (selObject == null) -// return; - // - int[] indices = yesList.getSelectedIndices(); - // - boolean change = false; - // - Object source = event.getSource(); - if (source == bUp) - { - for (int i = 0; i < length; i++) { - ListItem selObject = (ListItem)selObjects.get(i); - int index = indices[i]; - if (index == 0) - break; - ListItem newObject = (ListItem)yesModel.getElementAt(index - 1); - if (!selObject.isUpdateable() || !newObject.isUpdateable()) - break; - yesModel.setElementAt(newObject, index); - yesModel.setElementAt(selObject, index - 1); - indices[i] = index - 1; - change = true; - } - } // up - - else if (source == bDown) - { - for (int i = length - 1; i >= 0; i--) { - ListItem selObject = (ListItem)selObjects.get(i); - int index = indices[i]; - if (index >= yesModel.size () - 1) - break; - ListItem newObject = (ListItem)yesModel.getElementAt(index + 1); - if (!selObject.isUpdateable() || !newObject.isUpdateable()) - break; - yesModel.setElementAt(newObject, index); - yesModel.setElementAt(selObject, index + 1); - yesList.setSelectedIndex(index + 1); - indices[i] = index + 1; - change = true; - } - } // down - - else if (source == yesList) - { - // see org.compiere.grid.VSortTab.DragListener#mouseReleased(MouseEvent) - } - else - log.severe("Unknown source: " + source); - // - if (change) { - yesList.setSelectedIndices(indices); - setIsChanged(true); - } - } // migrateValueWithinYesList - - /* (non-Javadoc) - * @see org.compiere.grid.APanelTab#registerAPanel(APanel) - */ - public void registerAPanel (APanel panel) - { - m_aPanel = panel; - } // registerAPanel - - - /** (non-Javadoc) - * @see org.compiere.grid.APanelTab#saveData() - */ - public void saveData() - { - if (!m_aPanel.aSave.isEnabled()) - return; - log.fine(""); - boolean ok = true; - StringBuilder info = new StringBuilder(); - StringBuffer sql = null; - // noList - Set SortColumn to null and optional YesNo Column to 'N' - for (int i = 0; i < noModel.getSize(); i++) - { - ListItem pp = (ListItem)noModel.getElementAt(i); - if (!pp.isUpdateable()) - continue; - if(pp.getSortNo() == 0 && (m_ColumnYesNoName == null || !pp.isYes())) - continue; // no changes - // - sql = new StringBuffer(); - sql.append("UPDATE ").append(m_TableName) - .append(" SET ").append(m_ColumnSortName).append("=0"); - if (m_ColumnYesNoName != null) - sql.append(",").append(m_ColumnYesNoName).append("='N'"); - sql.append(" WHERE ").append(m_KeyColumnName).append("=").append(pp.getKey()); - if (DB.executeUpdate(sql.toString(), null) == 1) { - pp.setSortNo(0); - pp.setIsYes(false); - } - else { - ok = false; - if (info.length() > 0) - info.append(", "); - info.append(pp.getName()); - log.log(Level.SEVERE, "NoModel - Not updated: " + m_KeyColumnName + "=" + pp.getKey()); - } - } - // yesList - Set SortColumn to value and optional YesNo Column to 'Y' - int index = 0; - for (int i = 0; i < yesModel.getSize(); i++) - { - ListItem pp = (ListItem)yesModel.getElementAt(i); - if (!pp.isUpdateable()) - continue; - index += 10; - if(pp.getSortNo() == index && (m_ColumnYesNoName == null || pp.isYes())) - continue; // no changes - // - sql = new StringBuffer(); - sql.append("UPDATE ").append(m_TableName) - .append(" SET ").append(m_ColumnSortName).append("=").append(index); - if (m_ColumnYesNoName != null) - sql.append(",").append(m_ColumnYesNoName).append("='Y'"); - sql.append(" WHERE ").append(m_KeyColumnName).append("=").append(pp.getKey()); - if (DB.executeUpdate(sql.toString(), null) == 1) { - pp.setSortNo(index); - pp.setIsYes(true); - } - else { - ok = false; - if (info.length() > 0) - info.append(", "); - info.append(pp.getName()); - log.log(Level.SEVERE, "YesModel - Not updated: " + m_KeyColumnName + "=" + pp.getKey()); - } - } - // - if (ok) { - setIsChanged(false); - } - else { - ADialog.error(m_WindowNo, null, "SaveError", info.toString()); - } - } // saveData - - /* (non-Javadoc) - * @see org.compiere.grid.APanelTab#unregisterPanel() - */ - public void unregisterPanel () - { - saveData(); - m_aPanel = null; - } // dispoase - - /** - * List Item - * @author Teo Sarca - */ - private class ListItem extends NamePair { - /** - * - */ - private static final long serialVersionUID = 5399675004361331697L; - private int m_key; - private int m_AD_Client_ID; - private int m_AD_Org_ID; - /** Initial seq number */ - private int m_sortNo; - /** Initial selection flag */ - private boolean m_isYes; - private boolean m_updateable; - - public ListItem(int key, String name, int sortNo, boolean isYes, int AD_Client_ID, int AD_Org_ID) { - super(name); - this.m_key = key; - this.m_AD_Client_ID = AD_Client_ID; - this.m_AD_Org_ID = AD_Org_ID; - this.m_sortNo = sortNo; - this.m_isYes = isYes; - this.m_updateable = MRole.getDefault().canUpdate(m_AD_Client_ID, m_AD_Org_ID, m_AD_Table_ID, m_key, false); - } - public int getKey() { - return m_key; - } - public void setSortNo(int sortNo) { - m_sortNo = sortNo; - } - public int getSortNo() { - return m_sortNo; - } - public void setIsYes(boolean value) { - m_isYes = value; - } - public boolean isYes() { - return m_isYes; - } - public int getAD_Client_ID() { - return m_AD_Client_ID; - } - public int getAD_Org_ID() { - return m_AD_Org_ID; - } - public boolean isUpdateable() { - return m_updateable; - } - @Override - public String getID() { - return m_key != -1 ? String.valueOf(m_key) : null; - } - @Override - public int hashCode() { - return m_key; - } - @Override - public boolean equals(Object obj) - { - if (obj instanceof ListItem) - { - ListItem li = (ListItem)obj; - return - li.getKey() == m_key - && li.getName() != null - && li.getName().equals(getName()) - && li.getAD_Client_ID() == m_AD_Client_ID - && li.getAD_Org_ID() == m_AD_Org_ID; - } - return false; - } // equals - @Override - public String toString() { - String s = super.toString(); - if (s == null || s.trim().length() == 0) - s = "<" + getKey() + ">"; - return s; - } - } - - /** - * @author eslatis - * - */ - private class DragListener extends MouseInputAdapter - { - - /** - * Creates a VSortTab.DragListener. - */ - public DragListener() - { - URL url = VSortTab.class.getResource(cursorName); - Toolkit toolkit = Toolkit.getDefaultToolkit(); - Image image = toolkit.getImage(url); - customCursor = toolkit.createCustomCursor(image, new Point(0, 0), "Howdy"); - } - - /** The cursorName. */ - private String cursorName = "/org/compiere/images/DragCursor32.gif"; - - /** StartList */ - private JList startList = null; - - /** The startModel. */ - private DefaultListModel startModel = null; - - /** The selObject. */ - private Object selObject = null; - - private boolean moved = false; - - /** The customCursor. */ - private Cursor customCursor; - - /* (non-Javadoc) - * @see javax.swing.event.MouseInputAdapter#mousePressed(java.awt.event.MouseEvent) - */ - public void mousePressed(MouseEvent me) - { - JList list = (JList)me.getComponent(); - Point p = me.getPoint(); - int index = list.locationToIndex(p); - if (index > -1 && list.getCellBounds(index, index).contains(p)) - { - startList = list; - startModel = (list == noList) ? noModel : yesModel; - selObject = list.getModel().getElementAt(index); - } - if (list == noList) - yesList.clearSelection(); - else - noList.clearSelection(); - moved = false; - } // mousePressed - - /* (non-Javadoc) - * @see javax.swing.event.MouseInputAdapter#mouseDragged(java.awt.event.MouseEvent) - */ - public void mouseDragged(MouseEvent me) - { - if (selObject == null || !((ListItem)selObject).isUpdateable()) { - moved = false; - return; - } - moved = true; - if (getCursor() != customCursor) - setCursor(customCursor); - } // mouseDragged - - /* (non-Javadoc) - * @see javax.swing.event.MouseInputAdapter#mouseReleased(java.awt.event.MouseEvent) - */ - public void mouseReleased(MouseEvent me) - { - if (startModel != null && moved) - { - Point p = me.getPoint(); - - JList endList = yesList; - DefaultListModel endModel = yesModel; - - if (me.getComponent() == yesList) - { - if (!yesList.contains (p)) - { - endList = noList; - endModel = noModel; - } - } - else - { - if (noList.contains (p)) - { - setCursor(Cursor.getDefaultCursor()); - moved = false; - return; // move within noList - } - p = SwingUtilities.convertPoint (noList, p, yesList); - } - int index = endList.locationToIndex(p); - if (index > -1) // && endList.getCellBounds(index, index).contains(p)) - { - startModel.removeElement(selObject); - endModel.add(index, selObject); - // - startList.clearSelection(); - endList.clearSelection(); - endList.setSelectedValue(selObject, true); - // - setIsChanged(true); - } - } - - startList = null; - startModel = null; - selObject = null; - moved = false; - setCursor(Cursor.getDefaultCursor()); - } // mouseReleased - } - -} // VSortTab - diff --git a/org.adempiere.ui.swing/src/org/compiere/grid/VTabbedPane.java b/org.adempiere.ui.swing/src/org/compiere/grid/VTabbedPane.java deleted file mode 100644 index 7000a12fc4..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/grid/VTabbedPane.java +++ /dev/null @@ -1,367 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ -package org.compiere.grid; - -import java.awt.Component; -import java.util.ArrayList; -import java.util.logging.Level; - -import javax.swing.Icon; -import javax.swing.JTabbedPane; - -import org.compiere.apps.ADialog; -import org.compiere.apps.APanel; -import org.compiere.model.DataStatusEvent; -import org.compiere.model.GridTab; -import org.compiere.model.MTable; -import org.compiere.swing.CTabbedPane; -import org.compiere.util.CLogger; -import org.compiere.util.Env; -import org.compiere.util.Evaluator; -import org.compiere.util.Language; -import org.compiere.util.Util; - -/** - * Tabbed Pane - either Workbench or Window Tab - * - * @author Jorg Janke - * @version $Id: VTabbedPane.java,v 1.3 2006/07/30 00:51:28 jjanke Exp $ - */ -public class VTabbedPane extends CTabbedPane -{ - /** - * - */ - private static final long serialVersionUID = 716455372513747084L; - - /** - * Constructor - * @param isWorkbench is this a workbench tab (tabs on the left side) - */ - public VTabbedPane (boolean isWorkbench) - { - super(); - setTabLayoutPolicy (JTabbedPane.SCROLL_TAB_LAYOUT); - setWorkbench (isWorkbench); - setFocusable(false); - } // VTabbedPane - - /** Logger */ - private static CLogger log = CLogger.getCLogger (VTabbedPane.class); - /** Workbench */ - private boolean m_workbenchTab = false; - /** List of dependent Variables */ - private ArrayList m_dependents = new ArrayList(); - /** Disabled Icon */ - private static Icon s_disabledIcon = null; - - private ArrayList components = new ArrayList(); - private ArrayList gTabs = new ArrayList(); - private ArrayList tabNames = new ArrayList(); - - /** - * toString - * @return info - */ - public String toString() - { - return (m_workbenchTab ? "WorkbenchTab" : "WindowTab") - + " - selected " + getSelectedIndex() + " of " + getTabCount(); - } // toString - - /** - * Add Tab - * @param tabName name - * @param gTab grid tab model - * @param tabElement GridController or VSortTab - */ - public void addTab(String tabName, GridTab gTab, Component tabElement) - { - int index = getTabCount(); - tabNames.add(tabName); - gTabs.add(gTab); - components.add(tabElement); - - super.addTab (tabName, gTab.getIcon(), - tabElement, gTab.getDescription()); - - ArrayList dependents = gTab.getDependentOn(); - for (int i = 0; i < dependents.size(); i++) - { - String name = dependents.get(i); - if (!m_dependents.contains(name)) - m_dependents.add(name); - } - if (s_disabledIcon == null) - s_disabledIcon = Env.getImageIcon("Cancel10.gif"); - setDisabledIconAt(index, s_disabledIcon); - } // addTab - - private void hideTab(String tabName) { - - int tabIndex = indexOfTab(tabName); - - if ( tabIndex != -1 ) - removeTabAt(tabIndex); - } - - private void showTab(String tabName) { - int insertAt = 0; - - if ( indexOfTab(tabName) != -1 ) // already visible - return; - - for ( int i = 0; i < tabNames.size(); i++ ) - { - String name = tabNames.get(i); - if ( name.equals(tabName)) - { - insertTab (tabName, gTabs.get(i).getIcon(), - components.get(i), gTabs.get(i).getDescription(), insertAt); - break; - } - - if ( indexOfTab(name) != -1 ) // tab is visible, insert after - insertAt ++; - } - - } - - /** - * @param gridTab - * @return tab index or -1 if not found - */ - public int findTabindex(GridTab gridTab) - { - for (int i = 0; i < gTabs.size(); i++) - { - if (gTabs.get(i) == gridTab) - { - return indexOfTab(tabNames.get(i)); - } - } - return -1; - } - - /** - * Set Workbench - or Window - * @param isWorkbench - */ - public void setWorkbench (boolean isWorkbench) - { - m_workbenchTab = isWorkbench; - if (m_workbenchTab) - super.setTabPlacement(JTabbedPane.BOTTOM); - else - super.setTabPlacement(Language.getLoginLanguage().isLeftToRight() - ? JTabbedPane.LEFT : JTabbedPane.RIGHT); - } // setWorkbench - - /** - * Tab is Workbench (not Window) - * @return true if Workbench - */ - public boolean isWorkbench() - { - return m_workbenchTab; - } // toString - - /** - * Set Tab Placement. - * Do not use - set via setWorkBench - * @param notUsed - */ - public void setTabPlacement (int notUsed) - { - new java.lang.IllegalAccessError("Do not use VTabbedPane.setTabPlacement directly"); - } // setTabPlacement - - /** - * Dispose all contained VTabbedPanes and GridControllers - * @param aPanel - */ - public void dispose (APanel aPanel) - { - Component[] comp = getComponents(); - for (int i = 0; i < comp.length; i++) - { - if (comp[i] instanceof VTabbedPane) - { - VTabbedPane tp = (VTabbedPane)comp[i]; - tp.removeChangeListener(aPanel); - tp.dispose(aPanel); - } - else if (comp[i] instanceof GridController) - { - GridController gc = (GridController)comp[i]; - gc.removeDataStatusListener(aPanel); - gc.dispose(); - } - } - removeAll(); - } // dispose - - @Override - //hengsin, bug [ 1637763 ] - public boolean isEnabledAt(int index) { - boolean enabled = super.isEnabledAt(index); - if (!enabled) return enabled; - Component comp = getComponentAt(index); - GridController gc = null; - if (comp instanceof GridController) - gc = (GridController)comp; - // Display - if (gc != null) - { - enabled = isDisplay(gc); - } - return enabled; - } - - //hengsin, bug [ 1637763 ] - private boolean isDisplay(GridController gc) - { - String logic = gc.getDisplayLogic(); - if (logic != null && logic.length() > 0) - { - boolean display = Evaluator.evaluateLogic(gc, logic); - if (!display) - { - if (log.isLoggable(Level.INFO)) log.info("Not displayed - " + logic); - return false; - } - } - return true; - } - - /** - * Set Selected Index. - * Register/Unregister Mnemonics - * @param index index - */ - public void setSelectedIndex (int index) - { - Component newC = getComponentAt(index); - GridController newGC = null; - if (newC instanceof GridController) - newGC = (GridController)newC; - // Display - if (newGC != null) - { - //hengsin, bug [ 1637763 ] - if(isDisplay(newGC) == false) - return; - } - - // - int oldIndex = getSelectedIndex(); - if (newGC != null && oldIndex >= 0 && index != oldIndex) - { - Component oldC = getComponentAt(oldIndex); - if (oldC != null && oldC instanceof GridController) - { - GridController oldGC = (GridController)oldC; - int zeroValid = (MTable.isZeroIDTable(oldGC.getMTab().getTableName()) ? 1 : 0); - if ((newGC.getTabLevel() > oldGC.getTabLevel()+1) - || (newGC.getTabLevel() > oldGC.getTabLevel() && oldGC.getMTab().getRecord_ID()+zeroValid <=0)) // TabLevel increase and parent ID <=0 IDEMPIERE 382 - { - // validate - // Search for right tab - GridController rightGC = null; - //boolean canJump = true; - boolean canJump = oldGC.getMTab().getRecord_ID()+zeroValid <=0 ? false : true; // IDEMPIERE 382 - // IDEMPIERE-651 Allow navigating to a detail when parent doesn't have ID - if (! canJump && Util.isEmpty(oldGC.getMTab().getKeyColumnName())) - canJump = true; - int currentLevel = newGC.getTabLevel(); - for (int i = index-1; i >=0; i--) - { - Component rightC = getComponentAt(i); - if (rightC instanceof GridController) - { - GridController gc = (GridController)rightC; - //can only skip level if all parent data are not stale - if (gc.getTabLevel() < currentLevel) - { - if (gc.getTabLevel() == oldGC.getTabLevel()+1) - { - rightGC = gc; - } - if (!gc.isCurrent()) - canJump = false; - currentLevel = gc.getTabLevel(); - } - } - } - if (canJump == false) - { - if (rightGC != null ) - ADialog.warn(0, this, "TabSwitchJumpGo", rightGC.getTitle()); - else - ADialog.warn(0, this, "TabSwitchJump"); - return; - } - } - oldGC.setMnemonics(false); - } - } - // Switch - super.setSelectedIndex (index); - if (newGC != null) - newGC.setMnemonics(true); - } // setSelectedIndex - - /** - * Evaluate Tab Logic - * @param e event - */ - public void evaluate (DataStatusEvent e) - { - boolean process = e == null; - String columnName = null; - if (!process) - { - columnName = e.getColumnName(); - if (columnName != null) - process = m_dependents.contains(columnName); - else - process = true; - } - - if (process) - { - if (log.isLoggable(Level.CONFIG)) log.config(columnName == null ? "" : columnName); - for (int i = 0; i < components.size(); i++) - { - Component c = components.get(i); - if (c instanceof GridController) - { - GridController gc = (GridController)c; - if (!gc.isDetailGrid()) //ignore included tabs - { - boolean display = isDisplay(gc); - if ( display ) - showTab(tabNames.get(i)); - else - hideTab(tabNames.get(i)); - } - } - } - } - } // evaluate - -} // VTabbdPane diff --git a/org.adempiere.ui.swing/src/org/compiere/grid/VTable.java b/org.adempiere.ui.swing/src/org/compiere/grid/VTable.java deleted file mode 100644 index 18f4d98751..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/grid/VTable.java +++ /dev/null @@ -1,210 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ -package org.compiere.grid; - -import java.awt.Component; -import java.awt.Rectangle; -import java.beans.PropertyChangeEvent; -import java.beans.PropertyChangeListener; -import java.util.logging.Level; - -import javax.swing.Action; -import javax.swing.table.TableModel; - -import org.compiere.grid.ed.VCellEditor; -import org.compiere.grid.ed.VEditor; -import org.compiere.model.GridTab; -import org.compiere.model.GridTable; -import org.compiere.swing.CColumnControlButton; -import org.compiere.swing.CTable; -import org.compiere.util.CLogger; -import org.jdesktop.swingx.action.BoundAction; - -/** - * Table Grid based on CTable. - * Used in GridController - * - * @author Jorg Janke - * @version $Id: VTable.java,v 1.2 2006/07/30 00:51:28 jjanke Exp $ - * - * @author Teo Sarca, SC ARHIPAC SERVICE SRL - FR [ 1753943 ] - */ -public final class VTable extends CTable - implements PropertyChangeListener -{ - /** - * - */ - private static final long serialVersionUID = -3878986086328742243L; - - private final static String PACK_ALL_COMMAND = CColumnControlButton.COLUMN_CONTROL_MARKER + "packAll"; - - /** - * Default Constructor - */ - public VTable() - { - super(); - setAutoscrolls(true); - putClientProperty("terminateEditOnFocusLost", Boolean.TRUE); - new VTableExcelAdapter(this); // teo_sarca - FR [ 1753943 ] - - getActionMap().put(PACK_ALL_COMMAND, createPackAllAction()); - } // VTable - - - private Action createPackAllAction() - { - //TODO: localization - BoundAction action = new BoundAction("Size All Column", PACK_ALL_COMMAND); - action.setLongDescription("Size all column to fit content"); - action.registerCallback(this, "packAll"); - return action; - } - - /** - * Size all column to fit content. - */ - public void packAll() - { - autoSize(true); - } - - /** Logger */ - private static CLogger log = CLogger.getCLogger(VTable.class); - - /** - * Property Change Listener for CurrentRow. - * - Selects the current row if not already selected - * - Required when navigating via Buttons - * @param evt event - */ - public void propertyChange(PropertyChangeEvent evt) - { - // log.config(evt); - if (evt.getPropertyName().equals(GridTab.PROPERTY)) - { - int row = ((Integer)evt.getNewValue()).intValue(); - int selRow = getSelectedRow(); - if (row == selRow) - return; - if (log.isLoggable(Level.CONFIG)) log.config(GridTab.PROPERTY + "=" + row + " from " + selRow); - setRowSelectionInterval(row,row); - setColumnSelectionInterval(0, 0); - Rectangle cellRect = getCellRect(row, 0, false); - if (cellRect != null) - scrollRectToVisible(cellRect); - if (log.isLoggable(Level.CONFIG)) log.config(GridTab.PROPERTY + "=" + row + " from " + selRow); - } - } // propertyChange - - /** - * Get ColorCode for Row. - *
    -	 *	If numerical value in compare column is
    -	 *		negative = -1,
    -	 *      positive = 1,
    -	 *      otherwise = 0
    -	 *  
    - * @param row row - * @return color code - */ - public int getColorCode (int row) - { - return ((GridTable)getModel()).getColorCode(row); - } // getColorCode - - /** - * Sort Table - * @param modelColumnIndex model column sort index - */ - protected void sort (int modelColumnIndex) - { - int rows = getRowCount(); - if (rows == 0) - return; - // - TableModel model = getModel(); - if (!(model instanceof GridTable)) - { - super.sort(modelColumnIndex); - return; - } - - sorting = true; - // other sort column - if (modelColumnIndex != p_lastSortIndex) - p_asc = true; - else - p_asc = !p_asc; - - p_lastSortIndex = modelColumnIndex; - // - if (log.isLoggable(Level.CONFIG)) log.config("#" + modelColumnIndex - + " - rows=" + rows + ", asc=" + p_asc); - - ((GridTable)model).sort(modelColumnIndex, p_asc); - - sorting = false; - // table model fires "Sorted" DataStatus event which causes MTab to position to row 0 - } // sort - - /** - * Transfer focus explicitly to editor due to editors with multiple components - * - * @param row row - * @param column column - * @param e event - * @return true if cell is editing - */ - public boolean editCellAt (int row, int column, java.util.EventObject e) - { - if (!super.editCellAt(row, column, e)) - return false; - // log.fine( "VTable.editCellAt", "r=" + row + ", c=" + column); - - Object ed = getCellEditor(); - if (ed instanceof VEditor) - ((Component)ed).requestFocus(); - else if (ed instanceof VCellEditor) - { - ed = ((VCellEditor)ed).getEditor(); - ((Component)ed).requestFocus(); - } - return true; - } // editCellAt - - /** - * toString - * @return String representation - */ - public String toString() - { - return new StringBuffer("VTable[") - .append(getModel()).append("]").toString(); - } // toString - - /** - * Sets the row selection interval. If the index is out of bounds we decrement it before setting the JTables row selection interval - */ - @Override - public void setRowSelectionInterval(int index0, int index1) { - super.setRowSelectionInterval( index0 == getRowCount() && index0 > 0 ? --index0 : index0, - index1 == getRowCount() && index1 > 0 ? --index1 : index1); - } - -} // VTable diff --git a/org.adempiere.ui.swing/src/org/compiere/grid/VTableExcelAdapter.java b/org.adempiere.ui.swing/src/org/compiere/grid/VTableExcelAdapter.java deleted file mode 100644 index 1657215f78..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/grid/VTableExcelAdapter.java +++ /dev/null @@ -1,213 +0,0 @@ -/********************************************************************** -* This file is part of Adempiere ERP Bazaar * -* http://www.adempiere.org * -* * -* Copyright (C) Teo Sarca. * -* Copyright (C) Contributors * -* * -* This program is free software; you can redistribute it and/or * -* modify it under the terms of the GNU General Public License * -* as published by the Free Software Foundation; either version 2 * -* of the License, or (at your option) any later version. * -* * -* This program is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU General Public License for more details. * -* * -* You should have received a copy of the GNU General Public License * -* along with this program; if not, write to the Free Software * -* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, * -* MA 02110-1301, USA. * -* * -* Contributors: * -* - Teo Sarca (teo.sarca@gmail.com) * -* * -* Sponsors: * -* - SC ARHIPAC SERVICE SRL (http://www.arhipac.ro) * -***********************************************************************/ -package org.compiere.grid; - -import java.awt.Toolkit; -import java.awt.datatransfer.Clipboard; -import java.awt.datatransfer.StringSelection; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.awt.event.KeyEvent; -import java.math.BigDecimal; -import java.text.DateFormat; -import java.text.NumberFormat; -import java.util.Date; -import java.util.Locale; -import java.util.logging.Level; - -import javax.swing.JComponent; -import javax.swing.KeyStroke; - -import org.compiere.model.GridField; -import org.compiere.model.GridTable; -import org.compiere.model.Lookup; -import org.compiere.util.CLogger; -import org.compiere.util.Env; -import org.compiere.util.Msg; - -/** - * VTableExcelAdapter enables Copy Clipboard functionality on VTables. - * - * @author Teo Sarca, SC ARHIPAC SERVICE SRL - FR [ 1753943 ] - */ -public class VTableExcelAdapter - implements ActionListener -{ - public static final String CMD_Copy = "VTable.copyPaste"; - public static final String CMD_CopyWithHeaders = "VTable.copyPasteH"; - - private static KeyStroke KS_copy = KeyStroke.getKeyStroke(KeyEvent.VK_C,ActionEvent.CTRL_MASK,false); - private static KeyStroke KS_copyWithHeader = KeyStroke.getKeyStroke(KeyEvent.VK_C,ActionEvent.CTRL_MASK | ActionEvent.SHIFT_MASK,false); - - /** Logger */ - private CLogger log = CLogger.getCLogger(getClass()); - - /** System clipboard */ - private Clipboard system; - /** Source table */ - private VTable table; - - /** System locale */ - private static Locale sysLocale = new Locale( - System.getProperty("user.language"), - System.getProperty("user.country") - ); - /** System number formater */ - private static NumberFormat sysNumberFormat = NumberFormat.getNumberInstance(sysLocale); - /** System date formater */ - private static DateFormat sysDateFormat = DateFormat.getDateInstance(DateFormat.MEDIUM, sysLocale); - - /** - * The Excel Adapter is constructed with a - * VTable on which it enables Copy-Paste and acts - * as a Clipboard listener. - * - * @param table - */ - public VTableExcelAdapter(VTable table) - { - this.table = table; - table.registerKeyboardAction(this,CMD_Copy,KS_copy,JComponent.WHEN_FOCUSED); - table.registerKeyboardAction(this,CMD_CopyWithHeaders,KS_copyWithHeader,JComponent.WHEN_FOCUSED); - system = Toolkit.getDefaultToolkit().getSystemClipboard(); - } - - /** - * This method is activated on the Keystrokes we are listening to - * in this implementation. Here it listens for Copy and Paste ActionCommands. - * - * @param e event - */ - public void actionPerformed(ActionEvent e) - { - // Only GridTable model is supported - if (!(table.getModel() instanceof GridTable)) { - if (log.isLoggable(Level.FINE)) log.fine("Not supported - " + table.getModel()); - return; - } - - boolean isCopy = CMD_Copy.equals(e.getActionCommand()); - boolean isCopyWithHeaders = CMD_CopyWithHeaders.equals(e.getActionCommand()); - - if (isCopy || isCopyWithHeaders) - { - try { - int[] selectedRows = table.getSelectedRows(); - if (selectedRows == null || selectedRows.length == 0) { - return; - } - - int colscount = table.getColumnCount(); - StringBuilder sb = new StringBuilder(); - GridTable model = (GridTable)table.getModel(); - GridField[] fields = model.getFields(); - - // Header - if (isCopyWithHeaders) { - for (int col = 0; col < colscount; col++) { - String value = ""; - try { - GridField field = fields[col]; - if (!field.isDisplayed(false)) { - continue; - } - value = field.getHeader(); - } catch(Exception ex) { - log.log(Level.WARNING, "Copy-headers", ex); - } - value = fixString(value); - sb.append(value).append("\t"); - } - sb.append(Env.NL); - } - - // Selected rows - for (int row : selectedRows) { - for (int col = 0; col < colscount; col++) { - Lookup lookup = null; - String value = null; - Object key = null; - GridField field = null; - try { - key = table.getValueAt(row,col); - field = fields[col]; - if (!field.isDisplayed(false)) - continue; - if (field.isEncryptedColumn() || field.isEncryptedField()) { - value = "*"; - } - else if (key instanceof Boolean) { - value = Msg.getMsg(Env.getCtx(), ((Boolean)key).booleanValue() ? "Yes":"No"); - } - else if (key instanceof BigDecimal) { - try { - value = sysNumberFormat.format(key != null ? key : Env.ZERO); - } catch (Exception ex) {} - } - else if (key instanceof Date) { - try { - value = sysDateFormat.format(key); - } catch (Exception ex) {} - } - else { - lookup = (field != null ? field.getLookup() : null); - value = (lookup != null && key != null ? lookup.getDisplay(key) : null); - if (value == null && key != null) - value = key.toString(); - } - } catch(Exception ex) { - log.log(Level.WARNING, "Copy-rows", ex); - } - value = fixString(value); - sb.append(value).append("\t"); - if (log.isLoggable(Level.FINEST)) log.finest("col=" + col + ", row=" + row + ": key=" + key + " => value=" + value + ", " + field + ", " + lookup); - } - sb.append(Env.NL); - } - StringSelection stsel = new StringSelection(sb.toString()); - system = Toolkit.getDefaultToolkit().getSystemClipboard(); - system.setContents(stsel,stsel); - } catch (Exception ex) { - log.log(Level.WARNING, "Copy", ex); - } - } - } // actionPerformed - - /** - * Fix Cell String - * @param s string - * @return fixed string - */ - private String fixString(String s) { - if (s == null || s.length() == 0) - return ""; - String s2 = s.replaceAll("[\t\n\f\r]+", " "); - return s2; - } -} diff --git a/org.adempiere.ui.swing/src/org/compiere/grid/XLookup.java b/org.adempiere.ui.swing/src/org/compiere/grid/XLookup.java deleted file mode 100644 index c46a8cc952..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/grid/XLookup.java +++ /dev/null @@ -1,173 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ -package org.compiere.grid; - -import java.util.ArrayList; -import java.util.Collections; - -import org.compiere.model.Lookup; -import org.compiere.util.DisplayType; -import org.compiere.util.KeyNamePair; -import org.compiere.util.NamePair; -import org.compiere.util.ValueNamePair; - -/** - * Manual Lookup (Model)- loaded by the put method - * - * @author Jorg Janke - * @version $Id: XLookup.java,v 1.2 2006/07/30 00:51:28 jjanke Exp $ - */ -public class XLookup extends Lookup -{ - /** - * - */ - private static final long serialVersionUID = -1960941688071305272L; - - /** - * Manual Lookup - * @param keyColumn key Column - */ - public XLookup(String keyColumn) - { - super(DisplayType.TableDir, 0); - m_keyColumn = keyColumn; - } // XLookup - - - /** Key Column - as identifier */ - private String m_keyColumn; - - /** - * Get Display String of key value - * @param key key - * @return display - */ - public String getDisplay (Object key) - { - // linear search in m_data - for (int i = 0; i < p_data.size(); i++) - { - Object oo = p_data.get(i); - if (oo != null && oo instanceof NamePair) - { - NamePair pp = (NamePair)oo; - if (pp.getID().equals(key)) - return pp.getName(); - } - } - return "<" + key + ">"; - } // getDisplay - - /** - * The Lookup contains the key - * @param key key - * @return true if contains key - */ - public boolean containsKey (Object key) - { - // linear search in p_data - for (int i = 0; i < p_data.size(); i++) - { - Object oo = p_data.get(i); - if (oo != null && oo instanceof NamePair) - { - NamePair pp = (NamePair)oo; - if (pp.getID().equals(key)) - return true; - } - } - return false; - } // containsKey - - public boolean containsKeyNoDirect (Object key) - { - return containsKey(key); - } - - /** - * Get Object of Key Value - * @param key key - * @return Object or null - */ - public NamePair get (Object key) - { - // linear search in m_data - for (int i = 0; i < p_data.size(); i++) - { - Object oo = p_data.get(i); - if (oo != null && oo instanceof NamePair) - { - NamePair pp = (NamePair)oo; - if (pp.getID().equals(key)) - return pp; - } - } - return null; - } // get - - - /** - * Return data as sorted Array - * @param mandatory mandatory - * @param onlyValidated only validated - * @param onlyActive only active - * @param temporary force load for temporary display - * @return list of data - */ - public ArrayList getData (boolean mandatory, - boolean onlyValidated, boolean onlyActive, boolean temporary, boolean shortlist) // IDEMPIERE 90 - { - ArrayList list = new ArrayList(p_data); - - // Sort Data - if (m_keyColumn.endsWith("_ID")) - { - KeyNamePair p = new KeyNamePair (-1, ""); - if (!mandatory) - list.add (p); - Collections.sort (list, p); - } - else - { - ValueNamePair p = new ValueNamePair (null, ""); - if (!mandatory) - list.add (p); - Collections.sort (list, p); - } - return list; - } // getArray - - /** - * Refresh Values (nop) - * @return number of cache - */ - public int refresh() - { - return p_data.size(); - } // refresh - - /** - * Get underlying fully qualified Table.Column Name - * @return column name - */ - public String getColumnName() - { - return m_keyColumn; - } // getColumnName - -} // XLookup diff --git a/org.adempiere.ui.swing/src/org/compiere/grid/ed/ADempiereAutoCompleteDecorator.java b/org.adempiere.ui.swing/src/org/compiere/grid/ed/ADempiereAutoCompleteDecorator.java deleted file mode 100755 index 623286e20d..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/grid/ed/ADempiereAutoCompleteDecorator.java +++ /dev/null @@ -1,222 +0,0 @@ -/* - * $Id: AutoCompleteDecorator.java,v 1.9 2007/01/29 08:52:45 Bierhance Exp $ - * - * Copyright 2004 Sun Microsystems, Inc., 4150 Network Circle, - * Santa Clara, California 95054, U.S.A. All rights reserved. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ -package org.compiere.grid.ed; - -import java.awt.event.ActionEvent; -import java.awt.event.FocusAdapter; -import java.awt.event.FocusEvent; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; - -import javax.swing.Action; -import javax.swing.ActionMap; -import javax.swing.InputMap; -import javax.swing.KeyStroke; -import javax.swing.UIManager; -import javax.swing.text.DefaultEditorKit; -import javax.swing.text.JTextComponent; -import javax.swing.text.TextAction; - -import org.jdesktop.swingx.autocomplete.AbstractAutoCompleteAdaptor; -import org.jdesktop.swingx.autocomplete.AutoCompleteDecorator; -import org.jdesktop.swingx.autocomplete.AutoCompleteDocument; -import org.jdesktop.swingx.autocomplete.ObjectToStringConverter; -import org.jdesktop.swingx.autocomplete.TextComponentAdaptor; - -/** - * Adds Ctrl+Tab invoked action to run through all potential auto completion values. - */ -public class ADempiereAutoCompleteDecorator extends AutoCompleteDecorator{ - - /** - * Enables automatic completion for the given JTextComponent based on the - * items contained in the given List. - * @param textComponent the text component that will be used for automatic - * completion. - * @param items contains the items that are used for autocompletion - * @param strictMatching true, if only given items should be allowed to be entered - */ - public static void decorate(JTextComponent textComponent, List items, boolean strictMatching) { - decorate(textComponent, items, strictMatching, ObjectToStringConverter.DEFAULT_IMPLEMENTATION); - } - - /** - * Enables automatic completion for the given JTextComponent based on the - * items contained in the given List. - * @param items contains the items that are used for autocompletion - * @param textComponent the text component that will be used for automatic - * completion. - * @param strictMatching true, if only given items should be allowed to be entered - * @param stringConverter the converter used to transform items to strings - */ - public static void decorate(JTextComponent textComponent, List items, boolean strictMatching, ObjectToStringConverter stringConverter) { - AbstractAutoCompleteAdaptor adaptor = new TextComponentAdaptor(textComponent, items); - AutoCompleteDocument document = new AutoCompleteDocument(adaptor, strictMatching, stringConverter); - decorate(textComponent, document, adaptor); - } - - /** - * Decorates a given text component for automatic completion using the - * given AutoCompleteDocument and AbstractAutoCompleteAdaptor. - * - * - * @param textComponent a text component that should be decorated - * @param document the AutoCompleteDocument to be installed on the text component - * @param adaptor the AbstractAutoCompleteAdaptor to be used - */ - public static void decorate(JTextComponent textComponent, AutoCompleteDocument document, final AbstractAutoCompleteAdaptor adaptor) { - // install the document on the text component - textComponent.setDocument(document); - - // mark entire text when the text component gains focus - // otherwise the last mark would have been retained which is quiet confusing - textComponent.addFocusListener(new FocusAdapter() { - public void focusGained(FocusEvent e) { - @SuppressWarnings("unused") - JTextComponent textComponent = (JTextComponent) e.getSource(); - adaptor.markEntireText(); - } - }); - - // Tweak some key bindings - InputMap editorInputMap = textComponent.getInputMap(); - if (document.isStrictMatching()) { - // move the selection to the left on VK_BACK_SPACE - editorInputMap.put(KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_BACK_SPACE, 0), DefaultEditorKit.selectionBackwardAction); - // ignore VK_DELETE and CTRL+VK_X and beep instead when strict matching - editorInputMap.put(KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_DELETE, 0), errorFeedbackAction); - editorInputMap.put(KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_X, java.awt.event.InputEvent.CTRL_DOWN_MASK), errorFeedbackAction); - } else { - ActionMap editorActionMap = textComponent.getActionMap(); - // leave VK_DELETE and CTRL+VK_X as is - // VK_BACKSPACE will move the selection to the left if the selected item is in the list - // it will delete the previous character otherwise - editorInputMap.put(KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_BACK_SPACE, 0), "nonstrict-backspace"); - editorActionMap.put("nonstrict-backspace", new NonStrictBackspaceAction( - editorActionMap.get(DefaultEditorKit.deletePrevCharAction), - editorActionMap.get(DefaultEditorKit.selectionBackwardAction), - adaptor)); - editorInputMap.put(KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_TAB, java.awt.event.KeyEvent.CTRL_DOWN_MASK), "NextMatchAction"); - editorActionMap.put("NextMatchAction", new NextMatchAction(textComponent, document, adaptor)); - } - } - - static class NonStrictBackspaceAction extends TextAction { - /** - * - */ - private static final long serialVersionUID = 7260685268274438388L; - Action backspace; - Action selectionBackward; - AbstractAutoCompleteAdaptor adaptor; - - public NonStrictBackspaceAction(Action backspace, Action selectionBackward, AbstractAutoCompleteAdaptor adaptor) { - super("nonstrict-backspace"); - this.backspace = backspace; - this.selectionBackward = selectionBackward; - this.adaptor = adaptor; - } - - public void actionPerformed(ActionEvent e) { - if (adaptor.listContainsSelectedItem()) { - selectionBackward.actionPerformed(e); - } else { - backspace.actionPerformed(e); - } - } - } - - static class NextMatchAction extends TextAction { - /** - * - */ - private static final long serialVersionUID = 2987063701364646859L; - JTextComponent textComponent; - AutoCompleteDocument document; - final AbstractAutoCompleteAdaptor adaptor; - final List items; - int currentIndex = 0; - - public NextMatchAction(JTextComponent textComponent, AutoCompleteDocument document, final AbstractAutoCompleteAdaptor adaptor) { - super("NextMatchAction"); - this.textComponent = textComponent; - this.document = document; - this.adaptor = adaptor; - items = new ArrayList(adaptor.getItemCount()); - for (int i = 0; i < adaptor.getItemCount(); i++) { - Object o = adaptor.getItem(i); - items.add((o!=null)?(String) adaptor.getItem(i):""); - } - Collections.sort(items); - } - - private String getNextMatch(String start) { - for (int i = currentIndex; i < items.size(); i++) { - if(items.get(i).toLowerCase().startsWith(start.toLowerCase())) { - currentIndex = i+1; - return items.get(i); - } - } - currentIndex=0; - return start; - } - - /** - * Shows the next match. - * - * @param e the action event - */ - public void actionPerformed(ActionEvent e) { - JTextComponent target = getTextComponent(e); - if ((target != null) && (e != null)) { - if ((! target.isEditable()) || (! target.isEnabled())) { - UIManager.getLookAndFeel().provideErrorFeedback(target); - return; - } - String content = target.getText(); - if (content != null && target.getSelectionStart()>0) { - content = content.substring(0,target.getSelectionStart()); - } - if (content != null) { - target.setText(getNextMatch(content)); - adaptor.markText(content.length()); - } - } - } - } - - /** - * A TextAction that provides an error feedback for the text component that invoked - * the action. The error feedback is most likely a "beep". - */ - static Object errorFeedbackAction = new TextAction("provide-error-feedback") { - /** - * - */ - private static final long serialVersionUID = 6251452041316544686L; - - public void actionPerformed(ActionEvent e) { - UIManager.getLookAndFeel().provideErrorFeedback(getTextComponent(e)); - } - }; - -} diff --git a/org.adempiere.ui.swing/src/org/compiere/grid/ed/AutoCompleter.java b/org.adempiere.ui.swing/src/org/compiere/grid/ed/AutoCompleter.java deleted file mode 100644 index b5839fbfa7..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/grid/ed/AutoCompleter.java +++ /dev/null @@ -1,288 +0,0 @@ -package org.compiere.grid.ed; - -import java.awt.Color; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.awt.event.KeyEvent; -import java.awt.event.MouseListener; - -import javax.swing.AbstractAction; -import javax.swing.Action; -import javax.swing.BorderFactory; -import javax.swing.JComponent; -import javax.swing.JList; -import javax.swing.JPopupMenu; -import javax.swing.JScrollPane; -import javax.swing.JTextField; -import javax.swing.KeyStroke; -import javax.swing.ListModel; -import javax.swing.Timer; -import javax.swing.event.DocumentEvent; -import javax.swing.event.DocumentListener; -import javax.swing.event.PopupMenuEvent; -import javax.swing.event.PopupMenuListener; -import javax.swing.text.BadLocationException; -import javax.swing.text.JTextComponent; - -import org.compiere.util.CLogger; - -/** - * @author Santhosh Kumar T - santhosh@in.fiorano.com - *
  • Initial contribution - http://www.jroller.com/santhosh/date/20050620#file_path_autocompletion - * @author Teo Sarca , www.arhipac.ro - *
  • added timed triggering - *
  • refactored - * @author Cristina Ghita , www.arhipac.ro - *
  • refactored - */ -public abstract class AutoCompleter implements MouseListener -{ - private static final String AUTOCOMPLETER = "AUTOCOMPLETER"; //NOI18N - private static final int PopupDelayMillis = 500; - - protected final CLogger log = CLogger.getCLogger(getClass()); - - final JList listBox = new JList(); - final JTextComponent textBox; - final private JPopupMenu popup = new JPopupMenu(); - private boolean m_empty = false; - - private final Timer timer = new Timer(PopupDelayMillis, new ActionListener(){ - public void actionPerformed(ActionEvent e) - { - showPopup(); - } - }); - - public AutoCompleter(JTextComponent comp) - { - textBox = comp; - textBox.putClientProperty(AUTOCOMPLETER, this); - - JScrollPane scroll = new JScrollPane(listBox); - scroll.setBorder(null); - - listBox.setFocusable( false ); - listBox.addMouseListener(this); - scroll.getVerticalScrollBar().setFocusable( false ); - scroll.getHorizontalScrollBar().setFocusable( false ); - - popup.setBorder(BorderFactory.createLineBorder(Color.black)); - popup.add(scroll); - - if(textBox instanceof JTextField) - { - textBox.registerKeyboardAction(showAction, KeyStroke.getKeyStroke(KeyEvent.VK_DOWN, 0), JComponent.WHEN_FOCUSED); - textBox.getDocument().addDocumentListener(documentListener); - } - - textBox.registerKeyboardAction(upAction, KeyStroke.getKeyStroke(KeyEvent.VK_UP, 0), JComponent.WHEN_FOCUSED); - textBox.registerKeyboardAction(hidePopupAction, KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), JComponent.WHEN_FOCUSED); - popup.addPopupMenuListener(new PopupMenuListener() { - public void popupMenuWillBecomeVisible(PopupMenuEvent e) - { - } - public void popupMenuWillBecomeInvisible(PopupMenuEvent e) - { - textBox.unregisterKeyboardAction(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0)); - } - public void popupMenuCanceled(PopupMenuEvent e) - { - } - }); - listBox.setRequestFocusEnabled(false); - } - - public boolean isEmpty() - { - return m_empty; - } - - public void setEmpty(boolean empty) - { - m_empty = empty; - } - - private static final Action acceptAction = new AbstractAction() - { - private static final long serialVersionUID = -3950389799318995148L; - public void actionPerformed(ActionEvent e) - { - JComponent tf = (JComponent)e.getSource(); - AutoCompleter completer = (AutoCompleter)tf.getClientProperty(AUTOCOMPLETER); - completer.popup.setVisible(false); - if (completer.listBox.getSelectedValue() == null) - { - String txt = completer.textBox.getText(); - ListModel lm = completer.listBox.getModel(); - for (int index = 0; index < lm.getSize(); index++) - { - if (startsWithIgnoreCase(lm.getElementAt(index).toString(), txt)) - { - completer.acceptedListItem(lm.getElementAt(index)); - break; - } - } - } - else - { - completer.acceptedListItem(completer.listBox.getSelectedValue()); - } - } - }; - - private final DocumentListener documentListener = new DocumentListener() - { - public void insertUpdate(DocumentEvent e) - { - showPopupDelayed(); - } - public void removeUpdate(DocumentEvent e) - { - showPopupDelayed(); - } - public void changedUpdate(DocumentEvent e) - { - } - }; - - private void showPopupDelayed() - { - log.finest("showPopupDelayed.."); - timer.setRepeats(false); - timer.start(); - } - - private void showPopup() - { - log.finest("showPopup"); - popup.setVisible(false); - if (textBox.isEnabled() && updateListData() && listBox.getModel().getSize() != 0) - { - setEmpty(false); - if(!(textBox instanceof JTextField)) - { - textBox.getDocument().addDocumentListener(documentListener); - } - textBox.registerKeyboardAction(acceptAction, KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), JComponent.WHEN_FOCUSED); - int size = listBox.getModel().getSize(); - listBox.setVisibleRowCount(size<10 ? size : 10); - - int x = 0; - try{ - int pos = Math.min(textBox.getCaret().getDot(), textBox.getCaret().getMark()); - x = textBox.getUI().modelToView(textBox, pos).x; - } catch(BadLocationException e){ - // this should never happen!!! - e.printStackTrace(); - } - popup.show(textBox, x, textBox.getHeight()); - } - else - { - popup.setVisible(false); - setEmpty(true); - } - textBox.requestFocus(); - } - - static Action showAction = new AbstractAction() - { - private static final long serialVersionUID = 8868536979000734628L; - public void actionPerformed(ActionEvent e) - { - JComponent tf = (JComponent)e.getSource(); - AutoCompleter completer = (AutoCompleter)tf.getClientProperty(AUTOCOMPLETER); - if(tf.isEnabled()) - { - if(completer.popup.isVisible()) - completer.selectNextPossibleValue(); - else - completer.showPopup(); - } - } - }; - - private static final Action upAction = new AbstractAction() - { - private static final long serialVersionUID = 2200136359410394434L; - - public void actionPerformed(ActionEvent e) - { - JComponent tf = (JComponent)e.getSource(); - AutoCompleter completer = (AutoCompleter)tf.getClientProperty(AUTOCOMPLETER); - if(tf.isEnabled()) - { - if(completer.popup.isVisible()) - completer.selectPreviousPossibleValue(); - } - } - }; - - private static final Action hidePopupAction = new AbstractAction() - { - private static final long serialVersionUID = -5683983067872135654L; - - public void actionPerformed(ActionEvent e) - { - JComponent tf = (JComponent)e.getSource(); - AutoCompleter completer = (AutoCompleter)tf.getClientProperty(AUTOCOMPLETER); - if(tf.isEnabled()) - completer.popup.setVisible(false); - } - }; - - /** - * Selects the next item in the list. It won't change the selection if the - * currently selected item is already the last item. - */ - protected void selectNextPossibleValue() - { - int si = listBox.getSelectedIndex(); - - if(si < listBox.getModel().getSize() - 1){ - listBox.setSelectedIndex(si + 1); - listBox.ensureIndexIsVisible(si + 1); - } - } - - /** - * Selects the previous item in the list. It won't change the selection if the - * currently selected item is already the first item. - */ - protected void selectPreviousPossibleValue() - { - int si = listBox.getSelectedIndex(); - - if(si > 0){ - listBox.setSelectedIndex(si - 1); - listBox.ensureIndexIsVisible(si - 1); - } - } - - /** - * Checks if str1 starts with str2 (ignores case, trim whitespaces, strip diacritics) - * @param str1 - * @param str2 - * @return true if str1 starts with str2 - */ - protected static boolean startsWithIgnoreCase(String str1, String str2) - { - String s1 = org.compiere.util.Util.stripDiacritics(str1.toUpperCase()).trim(); - String s2 = org.compiere.util.Util.stripDiacritics(str2.toUpperCase()).trim(); - return s1.startsWith(s2); - } - - - /** - * Update list model depending on the data in textfield - * @return - */ - protected abstract boolean updateListData(); - - /** - * User has selected some item in the list. Update textfield accordingly... - * @param selected - */ - protected abstract void acceptedListItem(Object selected); -} \ No newline at end of file diff --git a/org.adempiere.ui.swing/src/org/compiere/grid/ed/AutoCompletion.java b/org.adempiere.ui.swing/src/org/compiere/grid/ed/AutoCompletion.java deleted file mode 100644 index 54e95c775f..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/grid/ed/AutoCompletion.java +++ /dev/null @@ -1,284 +0,0 @@ -/* This work is hereby released into the Public Domain. - * To view a copy of the public domain dedication, visit - * http://creativecommons.org/licenses/publicdomain/ - */ -package org.compiere.grid.ed; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.awt.event.FocusAdapter; -import java.awt.event.FocusEvent; -import java.awt.event.FocusListener; -import java.awt.event.KeyAdapter; -import java.awt.event.KeyEvent; -import java.awt.event.KeyListener; -import java.beans.PropertyChangeEvent; -import java.beans.PropertyChangeListener; - -import javax.swing.ComboBoxEditor; -import javax.swing.ComboBoxModel; -import javax.swing.UIManager; -import javax.swing.text.AttributeSet; -import javax.swing.text.BadLocationException; -import javax.swing.text.JTextComponent; -import javax.swing.text.PlainDocument; - -import org.compiere.swing.CComboBox; - -/** - * Auto completion behaviour for a combo box - * - * @author phib: this is from http://www.orbital-computer.de/JComboBox - * with some minor revisions for Adempiere - * @author Teo Sarca, SC ARHIPAC SERVICE SRL - *
  • BF [ 1735043 ] AutoCompletion: drop down box is showed even if i press Caps - *
  • FR [ 1820783 ] AutoCompletion: posibility to toggle strict mode - *
  • BF [ 1820778 ] ESC(cancel editing) key not working if you are on VComboBox - *
  • BF [ 1898001 ] AutoComplete: Exception when selecting a text - *
  • FR [ 2552854 ] Combobox AutoCompletion should ignore diacritics - * @author tobi42, www.metas.de - *
  • BF [ 2861223 ] AutoComplete: Ignoring Whitespace in Search String - */ -public class AutoCompletion extends PlainDocument { - /** - * - */ - private static final long serialVersionUID = 1449135613844313889L; - CComboBox comboBox; - ComboBoxModel model; - JTextComponent editor; - /** - * Flag to indicate if setSelectedItem has been called - * subsequent calls to remove/insertString should be ignored - */ - boolean selecting=false; - boolean hidePopupOnFocusLoss; - boolean hitBackspace=false; - boolean hitBackspaceOnSelection; - /** Strict mode */ - private boolean m_strictMode = true; - - KeyListener editorKeyListener; - FocusListener editorFocusListener; - - public AutoCompletion(final CComboBox comboBox) { - this.comboBox = comboBox; - model = comboBox.getModel(); - comboBox.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - if (!selecting) highlightCompletedText(0); - } - }); - comboBox.addPropertyChangeListener(new PropertyChangeListener() { - public void propertyChange(PropertyChangeEvent e) { - if (e.getPropertyName().equals("editor")) configureEditor((ComboBoxEditor) e.getNewValue()); - if (e.getPropertyName().equals("model")) model = (ComboBoxModel) e.getNewValue(); - } - }); - editorKeyListener = new KeyAdapter() { - public void keyPressed(KeyEvent e) { - // Ignore keys that do not alter the text - teo_sarca [ 1735043 ] - if (e.getKeyChar() == KeyEvent.CHAR_UNDEFINED) { - return; - } - // Ignore ESC key - teo_sarca BF [ 1820778 ] - if (e.getKeyCode() == KeyEvent.VK_ESCAPE) { - return; - } - - if (comboBox.isDisplayable()) - comboBox.setPopupVisible(true); - if(!m_strictMode) - return; - hitBackspace=false; - switch (e.getKeyCode()) { - // determine if the pressed key is backspace (needed by the remove method) - case KeyEvent.VK_BACK_SPACE : - hitBackspace=true; - hitBackspaceOnSelection=editor.getSelectionStart()!=editor.getSelectionEnd(); - break; - // ignore delete key - case KeyEvent.VK_DELETE : - e.consume(); - UIManager.getLookAndFeel().provideErrorFeedback(comboBox); - break; - } - } - }; - // Bug 5100422 on Java 1.5: Editable JComboBox won't hide popup when tabbing out - hidePopupOnFocusLoss=System.getProperty("java.version").startsWith("1.5"); - // Highlight whole text when gaining focus - editorFocusListener = new FocusAdapter() { - public void focusGained(FocusEvent e) { - highlightCompletedText(0); - } - public void focusLost(FocusEvent e) { - // Workaround for Bug 5100422 - Hide Popup on focus loss - if (hidePopupOnFocusLoss) comboBox.setPopupVisible(false); - } - }; - configureEditor(comboBox.getEditor()); - // Handle initially selected object - Object selected = comboBox.getSelectedItem(); - if (selected!=null) setText(selected.toString()); - highlightCompletedText(0); - } - - /** - * Enable auto completion for a combo box (strict mode) - * @param comboBox - */ - public static void enable(CComboBox comboBox) { - enable(comboBox, true); - } - - /** - * Enable auto completion for a combo box - * @param comboBox - * @param strictMode true if you want to set strict mode - */ - public static void enable(CComboBox comboBox, boolean strictMode) { - // has to be editable - comboBox.setEditable(true); - // change the editor's document - AutoCompletion ac = new AutoCompletion(comboBox); - // set strict mode - ac.setStrictMode(strictMode); - } - - void configureEditor(ComboBoxEditor newEditor) { - if (editor != null) { - editor.removeKeyListener(editorKeyListener); - editor.removeFocusListener(editorFocusListener); - } - - if (newEditor != null) { - editor = (JTextComponent) newEditor.getEditorComponent(); - editor.addKeyListener(editorKeyListener); - editor.addFocusListener(editorFocusListener); - editor.setDocument(this); - } - } - - @Override - public void remove(int offs, int len) throws BadLocationException { - // return immediately when selecting an item - if (selecting) return; - if (hitBackspace) { - // user hit backspace => move the selection backwards - // old item keeps being selected - if (offs>0) { - if (hitBackspaceOnSelection) offs--; - } else { - // User hit backspace with the cursor positioned on the start => beep - UIManager.getLookAndFeel().provideErrorFeedback(comboBox); - } - highlightCompletedText(offs); - } else { - super.remove(offs, len); - } - } - - @Override - public void insertString(int offs, String str, AttributeSet a) throws BadLocationException { - - if (selecting) return; - - super.insertString(offs, str, a); - - // lookup and select a matching item - Object item = lookupItem(getText(0, getLength())); - - if (item != null) { - setSelectedItem(item); - } else { - if (m_strictMode) { - if ( offs == 0 ) - setSelectedItem(null); //null is valid for non-mandatory fields - //so if cursor is at start of line allow it - // otherwise keep old item selected if there is no better match - else - item = comboBox.getSelectedItem(); - // undo the insertion as there isn't a valid match - offs = offs-str.length(); - UIManager.getLookAndFeel().provideErrorFeedback(comboBox); - } - else { - return; - } - } - - if (item != null) - setText(item.toString()); - else setText(""); - // select the completed part so it can be overwritten easily - highlightCompletedText(offs+str.length()); - } - - /** - * Set text - * @param text - */ - public void setText(String text) { - try { - // remove all text and insert the completed string - super.remove(0, getLength()); - super.insertString(0, text, null); - } catch (BadLocationException e) { - throw new RuntimeException(e.toString()); - } - } - - private void highlightCompletedText(int start) { - editor.setCaretPosition(getLength()); - if (getLength() < start) - start = getLength(); - editor.moveCaretPosition(start); - } - - private void setSelectedItem(Object item) { - selecting = true; - model.setSelectedItem(item); - selecting = false; - } - - private Object lookupItem(String pattern) { - Object selectedItem = model.getSelectedItem(); - // only search for a different item if the currently selected does not match - if (selectedItem != null && startsWithIgnoreCase(selectedItem.toString(), pattern)) { - return selectedItem; - } else { - // iterate over all items - for (int i=0, n=model.getSize(); i < n; i++) { - Object currentItem = model.getElementAt(i); - // current item starts with the pattern? - if (currentItem != null && startsWithIgnoreCase(currentItem.toString(), pattern)) { - return currentItem; - } - } - } - - return null; - } - - /** - * Set strict mode. If the strict mode is enabled, you can't enter any other values than the - * ones from combo box list. - * @param mode true if strict mode - */ - public void setStrictMode (boolean mode) { - m_strictMode = mode; - } - - /** - * Checks if str1 starts with str2 (ignores case, trim leading whitespaces, strip diacritics) - * @param str1 - * @param str2 - * @return true if str1 starts with str2 - */ - protected boolean startsWithIgnoreCase(String str1, String str2) { - String s1 = org.compiere.util.Util.stripDiacritics(str1.toUpperCase()).replaceAll("^\\s+", "");; - String s2 = org.compiere.util.Util.stripDiacritics(str2.toUpperCase()).replaceAll("^\\s+", "");; - return s1.startsWith(s2); - } - -} \ No newline at end of file diff --git a/org.adempiere.ui.swing/src/org/compiere/grid/ed/Calculator.java b/org.adempiere.ui.swing/src/org/compiere/grid/ed/Calculator.java deleted file mode 100644 index 24f70113ea..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/grid/ed/Calculator.java +++ /dev/null @@ -1,689 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ -package org.compiere.grid.ed; - -import java.awt.BorderLayout; -import java.awt.Color; -import java.awt.Component; -import java.awt.FlowLayout; -import java.awt.Frame; -import java.awt.GridLayout; -import java.awt.Insets; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.awt.event.KeyEvent; -import java.awt.event.KeyListener; -import java.math.BigDecimal; -import java.math.RoundingMode; -import java.sql.ResultSet; -import java.sql.SQLException; -import java.sql.Statement; -import java.text.DecimalFormat; -import java.text.ParseException; -import java.util.StringTokenizer; -import java.util.logging.Level; - -import javax.swing.BorderFactory; -import javax.swing.JButton; -import javax.swing.JComboBox; -import javax.swing.JDialog; -import javax.swing.JLabel; -import javax.swing.SwingConstants; - -import org.adempiere.plaf.AdempierePLAF; -import org.compiere.apps.ADialog; -import org.compiere.apps.AEnv; -import org.compiere.model.MConversionRate; -import org.compiere.swing.CDialog; -import org.compiere.swing.CPanel; -import org.compiere.util.CLogger; -import org.compiere.util.DB; -import org.compiere.util.DisplayType; -import org.compiere.util.Env; -import org.compiere.util.KeyNamePair; -import org.compiere.util.Msg; - -/** - * Calculator with currency conversion - * - * @author Jorg Janke - * @version $Id: Calculator.java,v 1.2 2006/07/30 00:51:27 jjanke Exp $ - */ -public final class Calculator extends CDialog - implements ActionListener, KeyListener -{ - /** - * - */ - private static final long serialVersionUID = 467225451773238663L; - - /** - * Create Calculator - * @param frame parent - * @param title title - * @param displayType date or datetime or time - * @param format display format - * @param number initial amount - */ - public Calculator(Frame frame, String title, int displayType, - DecimalFormat format, BigDecimal number) - { - super(frame, title, true); - setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE); - // Get WindowNo for Currency - m_WindowNo = AEnv.getWindowNo(frame); - // - m_DisplayType = displayType; - if (!DisplayType.isNumeric(m_DisplayType)) - m_DisplayType = DisplayType.Number; - // - m_format = format; - if (m_format == null) - m_format = DisplayType.getNumberFormat(m_DisplayType); - // - m_number = number; - if (m_number == null) - m_number = Env.ZERO; - // - try - { - jbInit(); - finishSetup(); - } - catch(Exception ex) - { - log.log(Level.SEVERE, "Calculator" + ex); - } - } // Calculator - - /** - * Abbreviated Constructor - * @param frame parent - */ - public Calculator(Frame frame) - { - this (frame, Msg.getMsg(Env.getCtx(), "Calculator"), DisplayType.Number, null, null); - } // Calculator - - /** - * Abbreviated Constructor - * @param frame parent - * @param number initial amount - */ - public Calculator(Frame frame, BigDecimal number) - { - this (frame, Msg.getMsg(Env.getCtx(), "Calculator"), DisplayType.Number, null, number); - } // Calculator - - private BigDecimal m_number; // the current number - private String m_display = ""; // what is displayed - private int m_DisplayType; - private DecimalFormat m_format; - private int m_WindowNo; - private boolean m_abort = true; - private boolean m_currencyOK = false; - private boolean p_disposeOnEqual = true; //teo_sarca, bug[ 1628773 ] - - private final static String OPERANDS = "/*-+%"; - private char m_decimal = '.'; - /** Logger */ - private static CLogger log = CLogger.getCLogger(Calculator.class); - // - private CPanel mainPanel = new CPanel(); - private CPanel displayPanel = new CPanel(); - private BorderLayout mainLayout = new BorderLayout(); - private CPanel keyPanel = new CPanel(); - private JLabel display = new JLabel(); - private BorderLayout displayLayout = new BorderLayout(); - private JButton b7 = new JButton(); - private JButton b8 = new JButton(); - private JButton b9 = new JButton(); - private JButton b4 = new JButton(); - private JButton b5 = new JButton(); - private JButton b6 = new JButton(); - private JButton b1 = new JButton(); - private JButton b2 = new JButton(); - private JButton b3 = new JButton(); - private GridLayout keyLayout = new GridLayout(); - private JButton bCur = new JButton(); - private JButton bC = new JButton(); - private JButton bDiv = new JButton(); - private JButton bM = new JButton(); - private JButton bMin = new JButton(); - private JButton bProc = new JButton(); - private JButton bAC = new JButton(); - private JButton bResult = new JButton(); - private JButton bDec = new JButton(); - private JButton b0 = new JButton(); - private JButton bPlus = new JButton(); - private CPanel bordPanel = new CPanel(); - private CPanel currencyPanel = new CPanel(); - private BorderLayout bordLayout = new BorderLayout(); - private JComboBox curFrom = new JComboBox(); - private JComboBox curTo = new JComboBox(); - private JLabel curLabel = new JLabel(); - private FlowLayout currencyLayout = new FlowLayout(); - - /** - * Static init - * @throws Exception - */ - void jbInit() throws Exception - { - mainPanel.setLayout(mainLayout); - displayPanel.setLayout(displayLayout); - keyPanel.setLayout(keyLayout); - mainLayout.setHgap(2); - mainLayout.setVgap(2); - mainPanel.setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2)); - - mainPanel.addKeyListener(this); - display.setBackground(Color.white); - display.setFont(new java.awt.Font("SansSerif", 0, 14)); - display.setBorder(BorderFactory.createCompoundBorder( - BorderFactory.createEmptyBorder(2, 0, 2, 1), - BorderFactory.createLineBorder(AdempierePLAF.getPrimary1()))); - display.setText("0"); - display.setHorizontalAlignment(SwingConstants.RIGHT); - - b7.setText("7"); - b8.setText("8"); - b9.setText("9"); - b4.setText("4"); - b5.setText("5"); - b6.setText("6"); - b1.setText("1"); - b2.setText("2"); - b3.setText("3"); - keyLayout.setColumns(5); - keyLayout.setHgap(3); - keyLayout.setRows(4); - keyLayout.setVgap(3); - bCur.setForeground(Color.yellow); - bCur.setToolTipText(Msg.getMsg(Env.getCtx(), "CurrencyConversion")); - bCur.setText("$"); - bC.setForeground(Color.red); - bC.setText("C"); - bDiv.setForeground(Color.blue); - bDiv.setText("/"); - bM.setForeground(Color.blue); - bM.setText("*"); - bMin.setForeground(Color.blue); - bMin.setText("-"); - bProc.setForeground(Color.blue); - bProc.setText("%"); - bAC.setForeground(Color.red); - bAC.setText("AC"); - bResult.setForeground(Color.green); - bResult.setText("="); - bDec.setText("."); - b0.setText("0"); - bPlus.setForeground(Color.blue); - bPlus.setText("+"); - bordPanel.setLayout(bordLayout); - curLabel.setHorizontalAlignment(SwingConstants.CENTER); - curLabel.setHorizontalTextPosition(SwingConstants.CENTER); - curLabel.setText(" >> "); - currencyPanel.setLayout(currencyLayout); - bordLayout.setHgap(2); - bordLayout.setVgap(2); - displayLayout.setHgap(2); - displayLayout.setVgap(2); - currencyLayout.setHgap(3); - currencyLayout.setVgap(2); - displayPanel.setBackground(Color.white); - getContentPane().add(mainPanel); - mainPanel.add(displayPanel, BorderLayout.NORTH); - displayPanel.add(display, BorderLayout.CENTER); - mainPanel.add(bordPanel, BorderLayout.CENTER); - bordPanel.add(currencyPanel, BorderLayout.NORTH); - currencyPanel.add(curFrom, null); - currencyPanel.add(curLabel, null); - currencyPanel.add(curTo, null); - bordPanel.add(keyPanel, BorderLayout.CENTER); - keyPanel.add(bAC, null); - keyPanel.add(b7, null); - keyPanel.add(b8, null); - keyPanel.add(b9, null); - keyPanel.add(bM, null); - keyPanel.add(bC, null); - keyPanel.add(b4, null); - keyPanel.add(b5, null); - keyPanel.add(b6, null); - keyPanel.add(bDiv, null); - keyPanel.add(bProc, null); - keyPanel.add(b1, null); - keyPanel.add(b2, null); - keyPanel.add(b3, null); - keyPanel.add(bMin, null); - keyPanel.add(bCur, null); - keyPanel.add(b0, null); - keyPanel.add(bDec, null); - keyPanel.add(bResult, null); - keyPanel.add(bPlus, null); - } // jbInit - - /** - * Finish Setup - */ - private void finishSetup() - { - Insets in = new Insets(2, 2, 2, 2); - - // For all buttons - Component[] comp = keyPanel.getComponents(); - for (int i = 0; i < comp.length; i++) - { - if (comp[i] instanceof JButton) - { - JButton b = (JButton)comp[i]; - b.setMargin(in); - b.addActionListener(this); - b.addKeyListener(this); - } - } - // Currency - toggleCurrency(); - - // Format setting - m_decimal = m_format.getDecimalFormatSymbols().getDecimalSeparator(); - - // display start number - if (m_number.doubleValue() != 0.00 ) - { - m_display = m_format.format(m_number); - display.setText(m_display); - } - } // finishSetup - - /** - * Action Listener - * @param e event - */ - public void actionPerformed(ActionEvent e) - { - // Handle Button input - if (e.getSource() instanceof JButton) - { - String cmd = e.getActionCommand(); - if (cmd != null && cmd.length() > 0) - handleInput(cmd.charAt(0)); - } - // Convert Amount - else if (e.getSource() == curTo) - { - KeyNamePair p = (KeyNamePair)curFrom.getSelectedItem(); - int curFromID = p.getKey(); - p = (KeyNamePair)curTo.getSelectedItem(); - int curToID = p.getKey(); - // convert - int AD_Client_ID = Env.getAD_Client_ID(Env.getCtx()); - int AD_Org_ID = Env.getAD_Org_ID(Env.getCtx()); - m_number = MConversionRate.convert(Env.getCtx(), - evaluate(), curFromID, curToID, AD_Client_ID, AD_Org_ID); - m_display = m_format.format(m_number); - display.setText(m_display); - curFrom.setSelectedItem(p); - } - } // actionPerformed - - /** - * handle input - * @param c input character - */ - public void handleInput(char c) - { - // System.out.println("Input: " + c); - switch (c) - { - // Number =============================== - case '0': case '1': case '2': - case '3': case '4': case '5': - case '6': case '7': case '8': - case '9': - m_display += c; - break; - - // Decimal =============================== - case '.': - case ',': - m_display += m_decimal; - break; - - // Commands =============================== - case '/': case '*': - case '-': case '+': - case '%': - if (m_display.length() > 0) - { - char last = m_display.charAt(m_display.length()-1); - if (OPERANDS.indexOf(last) == -1) - m_display += c; - else - m_display = m_display.substring(0, m_display.length()-1) + c; - } - m_display = m_format.format(evaluate()); - if (c != '%') - m_display += c; - break; - - // Clear last char - case 'C': - if (m_display.length() > 0) - m_display = m_display.substring(0, m_display.length()-1); - break; - - // Clear all - case 'A': - m_display = ""; - break; - - // Currency convert toggle - case '$': - m_display = m_format.format(evaluate()); - toggleCurrency(); - break; - - // fini - case '=': - m_display = m_format.format(evaluate()); - m_abort = false; - if (isDisposeOnEqual()) //teo_sarca, bug [ 1628773 ] - dispose(); - break; - - // Error =============================== - default: - ADialog.beep(); - break; - } // switch - - if (m_display.equals("")) - m_display = "0"; - - // Eliminate leading zeroes - if (m_display.length() > 1 && m_display.startsWith("0")) - if (m_display.charAt(1) != ',' && m_display.charAt(1) != '.') - m_display = m_display.substring(1); - - // Display it - display.setText(m_display); - } // handleInput - - /** - * Evaluate. - * - evaluate info in display and set number - * @return result - */ - private BigDecimal evaluate() - { - // nothing or zero - if (m_display == null || m_display.equals("") || m_display.equals("0")) - { - m_number = Env.ZERO; - return m_number; - } - - StringTokenizer st = new StringTokenizer(m_display, OPERANDS, true); - - // first token - String token = st.nextToken(); - // do we have a negative number ? - if (token.equals("-")) - { - if (st.hasMoreTokens()) - token += st.nextToken(); - else - { - m_number = Env.ZERO; - return m_number; - } - } - - // First Number - Number firstNumber; - try - { - firstNumber = m_format.parse(token); - } - catch (ParseException pe1) - { - log.log(Level.SEVERE, "Calculator.evaluate - token: " + token, pe1); - m_number = Env.ZERO; - return m_number; - } - BigDecimal firstNo = new BigDecimal(firstNumber.toString()); - - // intermediate result - m_number = firstNo; - - // only one number - if (!st.hasMoreTokens()) - return m_number; - - // now we should get an operand - token = st.nextToken(); - if (OPERANDS.indexOf(token) == -1) - { - log.log(Level.SEVERE, "Calculator.evaluate - Unknown token: " + token); - return m_number; - } - // get operand - char op = token.charAt(0); - - if (op == '%') { - firstNo = firstNo.divide(Env.ONEHUNDRED, m_format.getMaximumFractionDigits(), RoundingMode.HALF_UP); - m_number = firstNo; - } - - // no second number - if (!st.hasMoreTokens()) - return m_number; - - token = st.nextToken(); - Number secondNumber; - try - { - secondNumber = m_format.parse(token); - } - catch (ParseException pe2) - { - log.log(Level.SEVERE, "Calculator.evaluate - token: " + token, pe2); - m_number = Env.ZERO; - return m_number; - } - BigDecimal secondNo = new BigDecimal(secondNumber.toString()); - - // Check the next operand - char op2 = 0; - if (st.hasMoreTokens()) - { - token = st.nextToken(); - if (OPERANDS.indexOf(token) == -1) - { - log.log(Level.SEVERE, "Calculator.evaluate - Unknown token: " + token); - return m_number; - } - // get operand - op2 = token.charAt(0); - } - - // Percent operation - if (op2 == '%') - secondNo = secondNo.divide(Env.ONEHUNDRED, m_format.getMaximumFractionDigits(), RoundingMode.HALF_UP); - - switch (op) - { - case '/': - m_number = firstNo - .divide(secondNo, m_format.getMaximumFractionDigits(), RoundingMode.HALF_UP); - break; - case '*': - m_number = firstNo.multiply(secondNo); - break; - case '-': - m_number = firstNo.subtract(secondNo); - break; - case '+': - m_number = firstNo.add(secondNo); - break; - default: - break; - } - return m_number.setScale(m_format.getMaximumFractionDigits(), RoundingMode.HALF_UP); - } // evaluate - - - /** - * Display or don't display Currency - */ - private void toggleCurrency() - { - if (currencyPanel.isVisible()) - currencyPanel.setVisible(false); - else - { - if (!m_currencyOK) - loadCurrency(); - currencyPanel.setVisible(true); - } - pack(); - } // toggleCurrency - - /** - * Load Currency - */ - private void loadCurrency() - { - // Get Default - int C_Currency_ID = Env.getContextAsInt(Env.getCtx(), m_WindowNo, "C_Currency_ID"); - if (C_Currency_ID == 0) - C_Currency_ID = Env.getContextAsInt(Env.getCtx(), "$C_Currency_ID"); - - String sql = "SELECT C_Currency_ID, ISO_Code FROM C_Currency " - + "WHERE IsActive='Y' ORDER BY 2"; - KeyNamePair defaultValue = null; - Statement stmt = null; - ResultSet rs = null; - try - { - stmt = DB.createStatement(); - rs = stmt.executeQuery(sql); - while (rs.next()) - { - int id = rs.getInt("C_Currency_ID"); - String s = rs.getString("ISO_Code"); - KeyNamePair p = new KeyNamePair(id, s); - curFrom.addItem(p); - curTo.addItem(p); - // Default - if (id == C_Currency_ID) - defaultValue = p; - } - } - catch (SQLException e) - { - log.log(Level.SEVERE, "Calculator.loadCurrency", e); - } - finally - { - DB.close(rs, stmt); - rs = null; - stmt = null; - } - - // Set Defaults - if (defaultValue != null) - { - curFrom.setSelectedItem(defaultValue); - curTo.setSelectedItem(defaultValue); - } - // Set Listener - curTo.addActionListener(this); - m_currencyOK = true; - } // loadCurrency - - - /** - * Return Number - * @return result - */ - public BigDecimal getNumber() - { - if (m_abort) - return null; - - return m_number; - } // getNumber - - public boolean isDisposeOnEqual() - { - return p_disposeOnEqual; - } - - public void setDisposeOnEqual(boolean b) - { - p_disposeOnEqual = b; - } - - /*************************************************************************/ - - /** - * KeyPressed Listener - * @param e event - */ - public void keyPressed(KeyEvent e) - { - // sequence: pressed - typed(no KeyCode) - released - - char input = e.getKeyChar(); - int code = e.getKeyCode(); - - e.consume(); // does not work on JTextField - - if (code == KeyEvent.VK_DELETE) - input = 'A'; - else if (code == KeyEvent.VK_BACK_SPACE) - input = 'C'; - else if (code == KeyEvent.VK_ENTER) - input = '='; - else if (code == KeyEvent.VK_SHIFT) - // ignore - return; - // abort - else if (code == KeyEvent.VK_CANCEL || code == KeyEvent.VK_ESCAPE) - { - m_abort = true; - dispose(); - return; - } - handleInput(input); - } - - /** - * KeyTyped Listener (nop) - * @param e event - */ - public void keyTyped(KeyEvent e) {} - /** - * KeyReleased Listener (nop) - * @param e event - */ - public void keyReleased(KeyEvent e) {} - -} // Calculator - diff --git a/org.adempiere.ui.swing/src/org/compiere/grid/ed/Calendar.java b/org.adempiere.ui.swing/src/org/compiere/grid/ed/Calendar.java deleted file mode 100644 index 6b07cfcf67..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/grid/ed/Calendar.java +++ /dev/null @@ -1,906 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ -package org.compiere.grid.ed; - -import java.awt.BorderLayout; -import java.awt.Color; -import java.awt.Frame; -import java.awt.GridBagConstraints; -import java.awt.GridBagLayout; -import java.awt.GridLayout; -import java.awt.Insets; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.awt.event.KeyEvent; -import java.awt.event.KeyListener; -import java.awt.event.MouseEvent; -import java.awt.event.MouseListener; -import java.awt.event.WindowEvent; -import java.sql.Time; -import java.sql.Timestamp; -import java.text.DateFormat; -import java.text.SimpleDateFormat; -import java.util.Locale; -import java.util.TimeZone; -import java.util.logging.Level; - -import javax.swing.BorderFactory; -import javax.swing.JButton; -import javax.swing.JCheckBox; -import javax.swing.JDialog; -import javax.swing.JLabel; -import javax.swing.JSpinner; -import javax.swing.SpinnerNumberModel; -import javax.swing.SwingConstants; -import javax.swing.event.ChangeEvent; -import javax.swing.event.ChangeListener; - -import org.adempiere.plaf.AdempierePLAF; -import org.compiere.swing.CButton; -import org.compiere.swing.CComboBox; -import org.compiere.swing.CDialog; -import org.compiere.swing.CLabel; -import org.compiere.swing.CPanel; -import org.compiere.util.CLogger; -import org.compiere.util.DisplayType; -import org.compiere.util.Env; -import org.compiere.util.KeyNamePair; -import org.compiere.util.Language; -import org.compiere.util.Msg; - -/** - * Pop up Calendar & Time - * - * @author Jorg Janke - * @version $Id: Calendar.java,v 1.3 2006/07/30 00:51:27 jjanke Exp $ - */ -public class Calendar extends CDialog - implements ActionListener, MouseListener, ChangeListener, KeyListener -{ - /** - * - */ - private static final long serialVersionUID = 6482995795697809468L; - - /** - * Mimimum Constructor for Date editor - * @param frame frame - */ - public Calendar (Frame frame) - { - this (frame, Msg.getMsg(Env.getCtx(), "Calendar"), null, DisplayType.Date); - } // Calendar - - /** - * Constructor - * @param frame frame - * @param title title - * @param startTS start date/time - * @param displayType DisplayType (Date, DateTime, Time) - */ - public Calendar (Frame frame, String title, Timestamp startTS, int displayType) - { - super (frame, title, true); - if (log.isLoggable(Level.INFO)) log.info(startTS==null ? "null" : startTS.toString() + " - DT=" + displayType); - m_displayType = displayType; - // - try - { - jbInit(); - setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE); - } - catch(Exception ex) - { - log.log(Level.SEVERE, "Calendar", ex); - } - // - loadData(startTS); - } // Calendar - - /** Display Type */ - private int m_displayType; - /** The Date */ - // BUG:3075946KTU - fix Thai Date - //private GregorianCalendar m_calendar; - private java.util.Calendar m_calendar; - // KTU - /** Is there a PM format */ - private boolean m_hasAM_PM = false; - // - private CButton[] m_days; - private CButton m_today; - /** First Dat of week */ - private int m_firstDay; - // - private int m_currentDay; - private int m_currentMonth; - private int m_currentYear; - private int m_current24Hour = 0; - private int m_currentMinute = 0; - // - private boolean m_setting = true; - /** Abort = ignore */ - private boolean m_abort = true; - /** Cancel = set null */ - private boolean m_cancel = false; - /** Clear = set new Timestamp(-1) */ - private boolean m_clear = false; - // - private long m_lastClick = System.currentTimeMillis(); - private int m_lastDay = -1; - // - private static final Insets ZERO_INSETS = new Insets(0,0,0,0); - /** Logger */ - private static CLogger log = CLogger.getCLogger(Calendar.class); - // - private CPanel mainPanel = new CPanel(); - private CPanel monthPanel = new CPanel(); - private CComboBox cMonth = new CComboBox(); - // BUG:3075946 KTU - Fix Thai Date - //private JSpinner cYear = new JSpinner(new SpinnerNumberModel(2000, 1900,2100,1)); - private JSpinner cYear = new JSpinner(new SpinnerNumberModel(2000, 1900, 3000, 1)); - // KTU - private BorderLayout mainLayout = new BorderLayout(); - private CPanel dayPanel = new CPanel(); - private GridLayout dayLayout = new GridLayout(); - private GridBagLayout monthLayout = new GridBagLayout(); - private CButton bNext = new CButton(); - private CButton bBack = new CButton(); - private CPanel timePanel = new CPanel(); - private CComboBox fHour = new CComboBox(getHours()); - private CLabel lTimeSep = new CLabel(); - private JSpinner fMinute = new JSpinner(new MinuteModel(5)); // 5 minute snap size - private JCheckBox cbPM = new JCheckBox(); - private JLabel lTZ = new JLabel(); - private CButton bOK = new CButton(); - private GridBagLayout timeLayout = new GridBagLayout(); - private boolean userTime = true; - - /** - * Static init - * @throws Exception - */ - private void jbInit() throws Exception - { - this.addKeyListener(this); - // - mainPanel.setLayout(mainLayout); - mainLayout.setHgap(2); - mainLayout.setVgap(2); - //mainPanel.setBorder(BorderFactory.createLoweredBevelBorder()); - mainPanel.setBorder(BorderFactory.createEmptyBorder(4,4,4,2)); - getContentPane().add(mainPanel); - - // Month Panel - monthPanel.setLayout(monthLayout); - monthPanel.add(bBack, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); - monthPanel.add(cYear, new GridBagConstraints(3, 0, 1, 1, 1.0, 0.0 - ,GridBagConstraints.SOUTHEAST, GridBagConstraints.HORIZONTAL, new Insets(0, 5, 0, 0), 0, 0)); - monthPanel.add(bNext, new GridBagConstraints(2, 0, 1, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); - monthPanel.add(cMonth, new GridBagConstraints(1, 0, 1, 1, 1.0, 0.0 - ,GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); - monthPanel.setBorder(BorderFactory.createEmptyBorder(3, 0, 3, 0)); - - mainPanel.add(monthPanel, BorderLayout.NORTH); - cMonth.addActionListener(this); - cYear.addChangeListener(this); - bBack.setIcon(Env.getImageIcon("Parent16.gif")); // < - bBack.setMargin(new Insets(0,0,0,0)); - bBack.addActionListener(this); - bNext.setIcon(Env.getImageIcon("Detail16.gif")); // > - bNext.setMargin(new Insets(0,0,0,0)); - bNext.addActionListener(this); - - // Day Panel - dayPanel.setLayout(dayLayout); - dayLayout.setColumns(7); - dayLayout.setHgap(2); - dayLayout.setRows(7); - dayLayout.setVgap(2); - dayPanel.setBackground(Color.white); - dayPanel.setOpaque(true); - mainPanel.add(dayPanel, BorderLayout.CENTER); - - // Time Panel - timePanel.setLayout(timeLayout); - lTimeSep.setText(" : "); - timePanel.add(fHour, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.HORIZONTAL, new Insets(0, 6, 0, 0), 0, 0)); - timePanel.add(lTimeSep, new GridBagConstraints(1, 0, 1, 1, 0.0, 1.0 - ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); - timePanel.add(fMinute, new GridBagConstraints(2, 0, 1, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); - timePanel.add(cbPM, new GridBagConstraints(3, 0, 1, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 5, 0, 0), 0, 0)); - timePanel.add(lTZ, new GridBagConstraints(4, 0, 1, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 4, 0, 0), 0, 0)); - timePanel.add(bOK, new GridBagConstraints(5, 0, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 6, 0, 2), 0, 0)); - mainPanel.add(timePanel, BorderLayout.SOUTH); - fHour.addKeyListener(this); // Enter returns - // JSpinner ignores KeyListener - ((JSpinner.DefaultEditor)fMinute.getEditor()).getTextField().addKeyListener(this); - fMinute.addChangeListener(this); - cbPM.addActionListener(this); - cbPM.addKeyListener(this); - bOK.setIcon(Env.getImageIcon("Ok16.gif")); - bOK.setMargin(new Insets(0,1,0,1)); - bOK.addActionListener(this); - - AutoCompletion.enable(fHour); - - } // jbInit - - /** - * Window Events - requestFocus - * @param e event - */ - protected void processWindowEvent(WindowEvent e) - { - // log.config( "Calendar.processWindowEvent", e); - super.processWindowEvent(e); - if (e.getID() == WindowEvent.WINDOW_OPENED) - { - if (m_displayType == DisplayType.Time) - fHour.requestFocus(); - else if (m_today != null) - m_today.requestFocus(); - } - } // processWindowEvent - - - /************************************************************************** - * Load Data. - * - Years - * - Month names - * - Day Names - * @param startTS time stamp - */ - private void loadData (Timestamp startTS) - { - // BUG:3075946 KTU - Fix Thai Date - //m_calendar = new GregorianCalendar(Language.getLoginLanguage().getLocale()); - m_calendar = java.util.Calendar.getInstance(Language.getLoginLanguage().getLocale()); - // KTU - if (startTS == null) - m_calendar.setTimeInMillis(System.currentTimeMillis()); - else - m_calendar.setTime(startTS); - // [ 1948445 ] Time field problem on daylight - if (m_displayType == DisplayType.Time) - m_calendar.set(1970, 1, 1); - m_firstDay = m_calendar.getFirstDayOfWeek(); - // - Locale loc = Language.getLoginLanguage().getLocale(); - SimpleDateFormat formatDate = (SimpleDateFormat)DateFormat.getDateInstance(DateFormat.LONG, loc); - // Short: h:mm a - HH:mm Long: h:mm:ss a z - HH:mm:ss z - SimpleDateFormat formatTime = (SimpleDateFormat)DateFormat.getTimeInstance(DateFormat.SHORT, loc); - m_hasAM_PM = formatTime.toPattern().indexOf('a') != -1; - if (m_hasAM_PM) - cbPM.setText(formatTime.getDateFormatSymbols().getAmPmStrings()[1]); - else - cbPM.setVisible(false); - - // Years - m_currentYear = m_calendar.get(java.util.Calendar.YEAR); - cYear.setEditor(new JSpinner.NumberEditor(cYear, "0000")); - cYear.setValue(Integer.valueOf(m_currentYear)); - - // Months -> 0=Jan 12=_ - String[] months = formatDate.getDateFormatSymbols().getMonths(); - for (int i = 0; i < months.length; i++) - { - KeyNamePair p = new KeyNamePair(i+1, months[i]); - if (!months[i].equals("")) - cMonth.addItem(p); - } - m_currentMonth = m_calendar.get(java.util.Calendar.MONTH) + 1; // Jan=0 - cMonth.setSelectedIndex(m_currentMonth-1); - - // Week Days -> 0=_ 1=Su .. 7=Sa - String[] days = formatDate.getDateFormatSymbols().getShortWeekdays(); // 0 is blank, 1 is Sunday - for (int i = m_firstDay; i < 7 + m_firstDay; i++) - { - int index = i > 7 ? i -7 : i; - dayPanel.add(createWeekday(days[index]), null); - } - - // Days - m_days = new CButton[6*7]; - m_currentDay = m_calendar.get(java.util.Calendar.DATE); - for (int i = 0; i < 6; i++) // six weeks a month maximum - for (int j = 0; j < 7; j++) // seven days - { - int index = i*7 + j; - m_days[index] = createDay(); - dayPanel.add(m_days[index], null); - } - - // Today button - m_days[m_days.length-1].setBackground(Color.green); - m_days[m_days.length-1].setText("*"); - m_days[m_days.length-1].setToolTipText(Msg.getMsg(Env.getCtx(), "Today")); - // Cancel - m_days[m_days.length-2].setBackground(Color.red); - m_days[m_days.length-2].setText("x"); - m_days[m_days.length-2].setToolTipText(Msg.getMsg(Env.getCtx(), "Cancel")); - // Clear - m_days[m_days.length-3].setBackground(Color.yellow); - String keyClear = Msg.getMsg(Env.getCtx(), "Key_Clear"); - if ("Key_Clear".equals(keyClear)) - keyClear = "c"; - m_days[m_days.length-3].setText(keyClear); - m_days[m_days.length-3].setToolTipText(Msg.getMsg(Env.getCtx(), "Clear")); - - // Date/Time - m_current24Hour = m_calendar.get(java.util.Calendar.HOUR_OF_DAY); - m_currentMinute = m_calendar.get(java.util.Calendar.MINUTE); - - // What to show - timePanel.setVisible(m_displayType == DisplayType.DateTime || m_displayType == DisplayType.Time); - monthPanel.setVisible(m_displayType != DisplayType.Time); - dayPanel.setVisible(m_displayType != DisplayType.Time); - - // update UI from m_current... - m_setting = false; - setCalendar(); - userTime = false; - } // loadData - - /** - * Create Week Day Label - * @param title Weekday Title - * @return week day - */ - private JLabel createWeekday (String title) - { - JLabel label = new JLabel(title); - //label.setBorder(BorderFactory.createRaisedBevelBorder()); - label.setHorizontalAlignment(SwingConstants.CENTER); - label.setHorizontalTextPosition(SwingConstants.CENTER); - label.setRequestFocusEnabled(false); - label.setBackground(AdempierePLAF.getPrimary1()); - label.setForeground(Color.white); - label.setOpaque(true); - return label; - } // createWeekday - - /** - * Create Day Label - * @return button - */ - private CButton createDay() - { - CButton button = new CButton(); - //button.setBorder(BorderFactory.createLoweredBevelBorder()); - button.setBorder(BorderFactory.createEmptyBorder()); - button.setHorizontalTextPosition(SwingConstants.CENTER); - button.setMargin(ZERO_INSETS); - button.addActionListener(this); - button.addMouseListener(this); - button.addKeyListener(this); - button.setFocusPainted(false); - button.putClientProperty("Plastic.is3D", Boolean.FALSE); - return button; - } // createWeekday - - /** - * Create 12/25 hours - * @return Array with hours as String - */ - private Object[] getHours() - { - Locale loc = Language.getLoginLanguage().getLocale(); - // Short: h:mm a - HH:mm Long: h:mm:ss a z - HH:mm:ss z - SimpleDateFormat formatTime = (SimpleDateFormat)DateFormat.getTimeInstance(DateFormat.SHORT, loc); - m_hasAM_PM = formatTime.toPattern().indexOf('a') != -1; - // - Object[] retValue = new Object[m_hasAM_PM ? 12 : 24]; - if (m_hasAM_PM) - { - retValue[0] = "12"; - for (int i = 1; i < 10; i++) - retValue[i] = " " + String.valueOf(i); - for (int i = 10; i < 12; i++) - retValue[i] = String.valueOf(i); - } - else - { - for (int i = 0; i < 10; i++) - retValue[i] = "0" + String.valueOf(i); - for (int i = 10; i < 24; i++) - retValue[i] = String.valueOf(i); - } - return retValue; - } // getHours - - - /************************************************************************** - * Set Calendar from m_current variables and update UI - */ - private void setCalendar() - { - if (m_setting) - return; - // log.config( "Calendar.setCalendar"); - - // --- Set Month & Year - m_setting = true; - cMonth.setSelectedIndex(m_currentMonth-1); - cYear.setValue(Integer.valueOf(m_currentYear)); - m_setting = false; - - // --- Set Day - // what is the first day in the selected month? - m_calendar.set(m_currentYear, m_currentMonth-1, 1); // Month is zero based - int dayOne = m_calendar.get(java.util.Calendar.DAY_OF_WEEK); - int lastDate = m_calendar.getActualMaximum(java.util.Calendar.DATE); - - // convert to index - dayOne -= m_firstDay; - if (dayOne < 0) - dayOne += 7; - lastDate += dayOne - 1; - - // for all buttons but the last - int curDay = 1; - for (int i = 0; i < m_days.length-3; i++) - { - if (i >= dayOne && i <= lastDate) - { - if (m_currentDay == curDay) - { - m_days[i].setBackground(Color.blue); - m_days[i].setForeground(Color.yellow); - m_today = m_days[i]; - m_today.requestFocus(); - } - else - { - m_days[i].setBackground(Color.white); - m_days[i].setForeground(Color.black); - } - m_days[i].setText(String.valueOf(curDay++)); - m_days[i].setReadWrite(true); - } - else - { - m_days[i].setText(""); - m_days[i].setReadWrite(false); - m_days[i].setBackground(AdempierePLAF.getFieldBackground_Inactive()); - } - } - - if ( !userTime ) - { - m_current24Hour = 0; - m_currentMinute = 0; - } - - // Set Hour - boolean pm = m_current24Hour > 11; - int index = m_current24Hour; - if (pm && m_hasAM_PM) - index -= 12; - if (index < 0 || index >= fHour.getItemCount()) - index = 0; - fHour.setSelectedIndex(index); - // Set Minute - int m = m_currentMinute; - fMinute.setValue(Integer.valueOf(m)); - // Set PM - cbPM.setSelected(pm); - // Set TZ - TimeZone tz = m_calendar.getTimeZone(); - lTZ.setText(tz.getDisplayName(tz.inDaylightTime(m_calendar.getTime()), TimeZone.SHORT)); - - // Update Calendar - m_calendar.set(m_currentYear, m_currentMonth-1, m_currentDay, m_current24Hour, m_currentMinute, 0); - m_calendar.set(java.util.Calendar.MILLISECOND, 0); - } // setCalendar - - /** - * Set Current Time from UI. - * - set m_current.. variables - */ - private void setTime() - { - // Hour - int h = fHour.getSelectedIndex(); - if ( h != m_current24Hour ) - userTime = true; - - m_current24Hour = h; - if (m_hasAM_PM && cbPM.isSelected()) - m_current24Hour += 12; - if (m_current24Hour < 0 || m_current24Hour > 23) - m_current24Hour = 0; - - // Minute - Integer ii = (Integer)fMinute.getValue(); - if ( m_currentMinute != ii.intValue() ) - userTime = true; - - m_currentMinute = ii.intValue(); - if (m_currentMinute < 0 || m_currentMinute > 59) - m_currentMinute = 0; - } // setTime - - /** - * Return Time stamp - * @return date and time - */ - public Timestamp getTimestamp() - { - // log.config( "Calendar.getTimeStamp"); - // Set Calendar - m_calendar.set(m_currentYear, m_currentMonth-1, m_currentDay, m_current24Hour, m_currentMinute, 0); - m_calendar.set(java.util.Calendar.MILLISECOND, 0); - - // Return value - if (m_abort || m_cancel) - { - if (m_clear) - // 1970-01-01 04:59:59.999 - return new Timestamp(-1); - else - return null; - } - long time = m_calendar.getTimeInMillis(); - if (m_displayType == DisplayType.Date) - time = new java.sql.Date(time).getTime(); - else if (m_displayType == DisplayType.Time) - time = new Time(time).getTime(); // based on 1970-01-01 - return new Timestamp(time); - } // getTimestamp - - /** - * Cancel button pressed - * @return true if canceled - */ - public boolean isCancel() - { - return m_cancel; - } // isCancel - - /** - * Clear button pressed - * @return true if canceled - */ - public boolean isClear() - { - return m_clear; - } // isCancel - - /************************************************************************** - * Action Listener for Month/Year combo & date buttons. - * - Double clicking on a date closes it - * - set m_current... - * @param e Event - */ - public void actionPerformed (ActionEvent e) - { - if (m_setting) - return; - // log.config( "Calendar.actionPerformed"); - setTime(); - - if (e.getSource() == bOK) - { - m_abort = false; - dispose(); - return; - } - else if (e.getSource() == bBack) - { - if (--m_currentMonth < 1) - { - m_currentMonth = 12; - m_currentYear--; - } - m_lastDay = -1; - } - else if (e.getSource() == bNext) - { - if (++m_currentMonth > 12) - { - m_currentMonth = 1; - m_currentYear++; - } - m_lastDay = -1; - } - else if (e.getSource() instanceof JButton) - { - JButton b = (JButton)e.getSource(); - String text = b.getText(); - // Today - Set to today's date - if (text.equals("*")) - { - m_calendar.setTime(new Timestamp(System.currentTimeMillis())); - m_currentDay = m_calendar.get(java.util.Calendar.DATE); - m_currentMonth = m_calendar.get(java.util.Calendar.MONTH) + 1; - m_currentYear = m_calendar.get(java.util.Calendar.YEAR); - m_current24Hour = m_calendar.get(java.util.Calendar.HOUR_OF_DAY); - m_currentMinute = m_calendar.get(java.util.Calendar.MINUTE); - } - // Cancel - else if (text.equals("x")) - { - m_cancel = true; - dispose(); - return; - } - // Clear - else if (text.equals("c")) - { - m_clear = true; - dispose(); - return; - } - // we have a day - else if (text.length() > 0) - { - m_currentDay = Integer.parseInt(text); - long currentClick = System.currentTimeMillis(); - if (m_currentDay == m_lastDay - && currentClick-m_lastClick < 1000) // double click 1 second - { - m_abort = false; - dispose(); - return; - } - m_lastClick = currentClick; - m_lastDay = m_currentDay; - } - } - else if (e.getSource() == cbPM) - { - setTime(); - m_lastDay = -1; - } - else - { - // Set Month - m_currentMonth = cMonth.getSelectedIndex()+1; - m_lastDay = -1; - } - setCalendar(); - } // actionPerformed - - /** - * ChangeListener (Year/Minute Spinner) - * @param e Event - */ - public void stateChanged(ChangeEvent e) - { - if (m_setting) - return; - - // Set Minute - if (e.getSource() == fMinute) - { - setTime(); - return; - } - // Set Year - m_currentYear = ((Integer)cYear.getValue()).intValue(); - m_lastDay = -1; - setCalendar(); - } // stateChanged - - - /************************************************************************** - * Mouse Clicked - * @param e Evant - */ - public void mouseClicked(MouseEvent e) - { - if (e.getClickCount() == 2) - { - m_abort = false; - dispose(); - } - } // mouseClicked - - /** - * mousePressed - * @param e - */ - public void mousePressed(MouseEvent e) {} - /** - * mouseEntered - * @param e - */ - public void mouseEntered(MouseEvent e) {} - /** - * mouseExited - * @param e - */ - public void mouseExited(MouseEvent e) {} - /** - * mouseReleased - * @param e - */ - public void mouseReleased(MouseEvent e) {} - - - /************************************************************************** - * Key Released - Return on enter - * @param e event - */ - public void keyReleased(KeyEvent e) - { - // System.out.println("Released " + e); - // Day Buttons - if (e.getSource() instanceof JButton) - { - if (e.getKeyCode() == KeyEvent.VK_PAGE_DOWN) - { - if (++m_currentMonth > 12) - { - m_currentMonth = 1; - m_currentYear++; - } - setCalendar(); - return; - } - if (e.getKeyCode() == KeyEvent.VK_PAGE_UP) - { - if (--m_currentMonth < 1) - { - m_currentMonth = 12; - m_currentYear--; - } - setCalendar(); - return; - } - - // Arrows - int offset = 0; - if (e.getKeyCode() == KeyEvent.VK_RIGHT) - offset = 1; - else if (e.getKeyCode() == KeyEvent.VK_LEFT) - offset = -1; - else if (e.getKeyCode() == KeyEvent.VK_UP) - offset = -7; - else if (e.getKeyCode() == KeyEvent.VK_DOWN) - offset = 7; - if (offset != 0) - { - System.out.println(m_calendar.getTime() + " offset=" + offset); - m_calendar.add(java.util.Calendar.DAY_OF_YEAR, offset); - System.out.println(m_calendar.getTime()); - - m_currentDay = m_calendar.get(java.util.Calendar.DAY_OF_MONTH); - m_currentMonth = m_calendar.get(java.util.Calendar.MONTH) + 1; - m_currentYear = m_calendar.get(java.util.Calendar.YEAR); - setCalendar(); - return; - } - // something else - actionPerformed(new ActionEvent(e.getSource(), ActionEvent.ACTION_PERFORMED, "")); - } - - // Pressed Enter anywhere - if (e.getKeyCode() == KeyEvent.VK_ENTER) - { - m_abort = false; - setTime(); - dispose(); - return; - } - - // ESC = Cancel - teo_sarca, [ 1660164 ] - if (e.getKeyCode() == KeyEvent.VK_ESCAPE) - { - m_cancel = true; - dispose(); - return; - } - - // Modified Hour/Minute - setTime(); - m_lastDay = -1; - } // keyReleased - - /** - * keyTyped - * @param e - */ - public void keyTyped(KeyEvent e) - { - // System.out.println("Typed " + e); - } - /** - * keyPressed - * @param e - */ - public void keyPressed(KeyEvent e) - { - // System.out.println("Pressed " + e); - } - -} // Calendar - -/** - * Minute Spinner Model. - * Based on Number Model - uses snap size to determine next value. - * Allows to manually set any minute, but return even snap value - * when spinner buttons are used. - * - * @author Jorg Janke - * @version $Id: Calendar.java,v 1.3 2006/07/30 00:51:27 jjanke Exp $ - */ -class MinuteModel extends SpinnerNumberModel -{ - /** - * - */ - private static final long serialVersionUID = -7328155195096551848L; - - /** - * Constructor. - * Creates Integer Spinner with minimum=0, maximum=59, stepsize=1 - * @param snapSize snap size - */ - public MinuteModel(int snapSize) - { - super(0,0,59, 1); // Integer Model - m_snapSize = snapSize; - } // MinuteModel - - /** Snap size */ - private int m_snapSize; - - /** - * Return next full snap value - * @return next snap value - */ - public Object getNextValue() - { - int minutes = ((Integer)getValue()).intValue(); - minutes += m_snapSize; - if (minutes >= 60) - minutes -= 60; - // - int steps = minutes / m_snapSize; - return Integer.valueOf(steps * m_snapSize); - } // getNextValue - - - /** - * Return previous full step value - * @return previous snap value - */ - public Object getPreviousValue() - { - int minutes = ((Integer)getValue()).intValue(); - minutes -= m_snapSize; - if (minutes < 0) - minutes += 60; - // - int steps = minutes / m_snapSize; - if (minutes % m_snapSize != 0) - steps++; - if (steps * m_snapSize > 59) - steps = 0; - return Integer.valueOf(steps * m_snapSize); - } // getNextValue - -} // MinuteModel diff --git a/org.adempiere.ui.swing/src/org/compiere/grid/ed/CityAutoCompleter.java b/org.adempiere.ui.swing/src/org/compiere/grid/ed/CityAutoCompleter.java deleted file mode 100644 index d26ef437f5..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/grid/ed/CityAutoCompleter.java +++ /dev/null @@ -1,243 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 2009 SC ARHIPAC SERVICE SRL. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - *****************************************************************************/ -package org.compiere.grid.ed; - -import java.awt.Color; -import java.awt.event.MouseEvent; -import java.sql.PreparedStatement; -import java.sql.ResultSet; -import java.sql.SQLException; -import java.util.ArrayList; -import java.util.logging.Level; - -import javax.swing.text.JTextComponent; - -import org.adempiere.exceptions.DBException; -import org.compiere.model.MSysConfig; -import org.compiere.util.DB; -import org.compiere.util.Env; - -/** - * - * @author Cristina Ghita , www.arhipac.ro - * - */ -public class CityAutoCompleter extends AutoCompleter -{ - public static final CityVO ITEM_More = new CityVO(-1, "...", -1, ""); - private final int m_maxRows = MSysConfig.getIntValue(MSysConfig.LOCATION_MAX_CITY_ROWS, 7); - private CityVO m_city = null; - private final int m_windowNo; - private ArrayList list = new ArrayList(); - private ArrayList listShow = new ArrayList(); - - public CityAutoCompleter(JTextComponent comp, int windowNo) - { - super(comp); - this.m_windowNo = windowNo; - listBox.setVisibleRowCount(m_maxRows); - setCity(null); - } - - - @Override - protected void acceptedListItem(Object selected) - { - if (selected == null || selected == ITEM_More) - { - setCity(null); - return; - } - CityVO item = (CityVO) selected; - setCity(item); - Env.setContext(Env.getCtx(), m_windowNo, Env.TAB_INFO, "C_Region_ID", String.valueOf(item.C_Region_ID)); - textBox.setText(item.CityName); - } - - @Override - protected boolean updateListData() - { - String search = textBox.getText(); - if (m_city != null && m_city.CityName.compareTo(search) != 0) - { - setCity(null); - } - listShow.clear(); - boolean truncated = false; - search = search.toUpperCase(); - int i = 0; - for (CityVO vo : list) { - if (vo.CityName.toUpperCase().startsWith(search)) { - if (i > 0 && i == m_maxRows+1) - { - listShow.add(ITEM_More); - truncated = true; - break; - } - listShow.add(vo); - i++; - } - } - this.listBox.setListData(listShow.toArray()); - //if there is no city on the list return false, to not show the popup - if (listShow.isEmpty()) - { - return false; - } - else - { - CityVO city = (CityVO) listShow.get(0); - if (city.CityName.equalsIgnoreCase(search)) - { - m_city = city; - return true; - } - } - //if the list has only one item, but that item is not equals with m_city - //return false to not show any popup - if (!truncated && listShow.size() == 1 - && m_city != null && listShow.get(0).equals(this.m_city)) - { - log.finest("nothing to do 1"); - return false; - } - return true; - } - - public void fillList() - { - // Carlos Ruiz - globalqss - improve to avoid going to the database on every keystroke - list.clear(); - listShow.clear(); - ArrayList params = new ArrayList(); - final StringBuilder sql = new StringBuilder( - "SELECT cy.C_City_ID, cy.Name, cy.C_Region_ID, r.Name" - +" FROM C_City cy" - +" LEFT OUTER JOIN C_Region r ON (r.C_Region_ID=cy.C_Region_ID)" - +" WHERE cy.AD_Client_ID IN (0,?)"); - params.add(getAD_Client_ID()); - if (getC_Region_ID() > 0) - { - sql.append(" AND cy.C_Region_ID=?"); - params.add(getC_Region_ID()); - } - if (getC_Country_ID() > 0) - { - sql.append(" AND cy.C_Country_ID=?"); - params.add(getC_Country_ID()); - } - sql.append(" ORDER BY cy.Name, r.Name"); - PreparedStatement pstmt = null; - ResultSet rs = null; - try - { - pstmt = DB.prepareStatement(sql.toString(), null); - DB.setParameters(pstmt, params); - rs = pstmt.executeQuery(); - int i = 0; - while(rs.next()) - { - CityVO vo = new CityVO(rs.getInt(1), rs.getString(2), rs.getInt(3), rs.getString(4)); - list.add(vo); - if (i <= m_maxRows) { - listShow.add(vo); - } else if (i == m_maxRows + 1 && i > 0) { - listShow.add(ITEM_More); - } - i++; - } - } - catch (SQLException e) - { - throw new DBException(e, sql.toString()); - } - finally - { - DB.close(rs, pstmt); - rs = null; pstmt = null; - } - // - this.listBox.setListData(listShow.toArray()); - } - - private void setCity(CityVO vo) - { - m_city = vo; - if (log.isLoggable(Level.FINEST)) log.finest("C_City_ID="+m_city); - if (m_city == null) { - textBox.setBackground(new Color(230, 230, 255)); - } else { - textBox.setBackground(Color.WHITE); - } - } - public int getC_City_ID() - { - return m_city != null ? m_city.C_City_ID : -1; - } - public int getAD_Client_ID() - { - return Env.getAD_Client_ID(Env.getCtx()); - } - public int getC_Country_ID() - { - return Env.getContextAsInt(Env.getCtx(), m_windowNo, Env.TAB_INFO, "C_Country_ID"); - } - public int getC_Region_ID() - { - return Env.getContextAsInt(Env.getCtx(), m_windowNo, Env.TAB_INFO, "C_Region_ID"); - } - - public CityVO getCity() - { - return m_city; - } - - public void mouseEntered(MouseEvent e) - { - // nothing to do - - } - - public void mouseExited(MouseEvent e) - { - // nothing to do - - } - - public void mousePressed(MouseEvent e) - { - // nothing to do - - } - - public void mouseReleased(MouseEvent e) - { - // nothing to do - - } - - public void mouseClicked(MouseEvent e) - { - if (e == null || listBox == null || listBox.getSelectedValue() == null || listBox.getSelectedValue().equals(ITEM_More)) - { - setCity(null); - return; - } - - CityVO item = (CityVO)listBox.getSelectedValue(); - setCity(item); - Env.setContext(Env.getCtx(), m_windowNo, Env.TAB_INFO, "C_Region_ID", String.valueOf(item.C_Region_ID)); - textBox.setText(item.CityName); - } -} diff --git a/org.adempiere.ui.swing/src/org/compiere/grid/ed/ComboSelectionManager.java b/org.adempiere.ui.swing/src/org/compiere/grid/ed/ComboSelectionManager.java deleted file mode 100644 index ef32a350c2..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/grid/ed/ComboSelectionManager.java +++ /dev/null @@ -1,63 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ -package org.compiere.grid.ed; - -import java.util.logging.Level; - -import javax.swing.ComboBoxModel; -import javax.swing.JComboBox; - -import org.compiere.util.CLogger; - -/** - * ComboBox Selection Manager for AuroReduction - * - * @author Jorg Janke - * @version $Id: ComboSelectionManager.java,v 1.2 2006/07/30 00:51:27 jjanke Exp $ - */ -public class ComboSelectionManager implements JComboBox.KeySelectionManager -{ - /** - * - */ - public ComboSelectionManager() - { - } // ComboSelectionManager - - /** Logger */ - private static CLogger log = CLogger.getCLogger(ComboSelectionManager.class); - - /** - * Given aKey and the model, returns the row - * that should become selected. Return -1 if no match was - * found. - * - * @param key a char value, usually indicating a keyboard key that was pressed - * @param model a ComboBoxModel -- the component's data model, containing the list of selectable items - * @return an int equal to the selected row, where 0 is the first item and -1 is none - */ - public int selectionForKey (char key, @SuppressWarnings("rawtypes") ComboBoxModel model) - { - if (log.isLoggable(Level.FINE)) log.fine("Key=" + key); - // - //Object selectedItem = model.getSelectedItem(); - - return 0; - } // selectionForKey - - -} // ComboSelectionManager diff --git a/org.adempiere.ui.swing/src/org/compiere/grid/ed/Editor.java b/org.adempiere.ui.swing/src/org/compiere/grid/ed/Editor.java deleted file mode 100644 index c15e8dbe22..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/grid/ed/Editor.java +++ /dev/null @@ -1,342 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ -package org.compiere.grid.ed; - -import java.awt.BorderLayout; -import java.awt.Container; -import java.awt.Dimension; -import java.awt.Frame; -import java.awt.Toolkit; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.awt.event.KeyEvent; -import java.awt.event.KeyListener; -import java.io.BufferedWriter; -import java.io.FileInputStream; -import java.io.FileOutputStream; -import java.io.InputStreamReader; -import java.io.OutputStreamWriter; -import java.io.UnsupportedEncodingException; -import java.util.logging.Level; - -import javax.swing.JDialog; -import javax.swing.JFileChooser; -import javax.swing.JFrame; -import javax.swing.JMenu; -import javax.swing.JMenuBar; -import javax.swing.JTabbedPane; -import javax.swing.event.ChangeEvent; -import javax.swing.event.ChangeListener; - -import org.adempiere.plaf.AdempierePLAF; -import org.compiere.apps.AEnv; -import org.compiere.apps.ConfirmPanel; -import org.compiere.apps.StatusBar; -import org.compiere.swing.CDialog; -import org.compiere.swing.CMenuItem; -import org.compiere.swing.CPanel; -import org.compiere.swing.CTextArea; -import org.compiere.swing.CTextPane; -import org.compiere.util.CLogger; -import org.compiere.util.Env; -import org.compiere.util.Msg; - -/** - * Editor for Text (textArea) with HTML (textPane) View - * - * @author Jorg Janke - * @version $Id: Editor.java,v 1.2 2006/07/30 00:51:28 jjanke Exp $ - */ -public class Editor extends CDialog - implements ChangeListener, ActionListener, KeyListener -{ - /** - * - */ - private static final long serialVersionUID = -8314686583942866712L; - - /** - * Factory: Start Editor - * @param jc container to get parent frame - * @param header heading - * @param text initial text - * @param editable if false = r/o - * @param maxSize max size - * @return edited string - */ - public static String startEditor(Container jc, String header, String text, boolean editable, int maxSize) - { - // Find frame - JFrame frame = AEnv.getFrame(jc); - String hdr = header; - if (hdr == null || hdr.length() == 0) - hdr = Msg.getMsg(Env.getCtx(), "Editor"); - // Start it - Editor ed = new Editor(frame, hdr, text, editable, maxSize); - AEnv.showCenterWindow(frame, ed); - String s = ed.getText(); - ed = null; - return s; - } // startEditor - - /** - * Minimum constructor - * @param frame parent - */ - public Editor(Frame frame) - { - this (frame, Msg.getMsg(Env.getCtx(), "Editor"), "", true, 0); - } // Editor - - /** - * Standard constructor - * @param frame parent - * @param header heading - * @param text initial text - * @param editable if false = r/o - * @param maxSize max size; 0 = ignore - */ - public Editor(Frame frame, String header, String text, boolean editable, int maxSize) - { - super (frame, header, frame != null); - try - { - m_maxSize = maxSize; - jbInit(); - setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE); - } - catch(Exception ex) - { - log.log(Level.SEVERE, "", ex); - } - // Set Text - m_text = text; - textArea.setText(m_text); - textArea.setEditable(editable); - if (editable) - textArea.setBackground(AdempierePLAF.getFieldBackground_Normal()); - else - textArea.setBackground(AdempierePLAF.getFieldBackground_Inactive()); - textPane.setBackground(AdempierePLAF.getFieldBackground_Inactive()); - updateStatusBar(); - } // Editor - - /** The Text */ - private String m_text; - /** Maximum Size */ - private int m_maxSize = 0; - /** Logger */ - private static CLogger log = CLogger.getCLogger(Editor.class); - - private CPanel panel = new CPanel(); - private BorderLayout panelLayout = new BorderLayout(); - private JTabbedPane tabbedPane = new JTabbedPane(); - private CTextArea textArea = new CTextArea(); - private CTextPane textPane = new CTextPane(); - private JMenuBar menuBar = new JMenuBar(); - private JMenu mFile = new JMenu(); - private CMenuItem mImport = new CMenuItem(); - private CMenuItem mExport = new CMenuItem(); - private ConfirmPanel confirmPanel = new ConfirmPanel(); - private StatusBar statusBar = new StatusBar(false); - - /** - * Static Init - * @throws Exception - */ - private void jbInit() throws Exception - { - panel.setLayout(panelLayout); - this.setJMenuBar(menuBar); - // Text Tab - textArea.setPreferredSize(new Dimension(300, 300)); - textArea.setWrapStyleWord(true); - textArea.setLineWrap(true); - tabbedPane.add(textArea, "Text"); - textArea.addKeyListener(this); - // HTML Tab - textPane.setContentType("text/html"); - textPane.setEditable(false); - tabbedPane.add(textPane, "HTML"); - // - mFile.setText("File"); - mImport.setText("Import"); - mImport.addActionListener(this); - mExport.setText("Export"); - mExport.addActionListener(this); - tabbedPane.addChangeListener(this); - panel.add(tabbedPane, BorderLayout.CENTER); - confirmPanel.addActionListener(this); - panel.add(confirmPanel, BorderLayout.SOUTH); - this.getContentPane().add(panel, BorderLayout.CENTER); - this.getContentPane().add(statusBar, BorderLayout.SOUTH); - // - menuBar.add(mFile); - mFile.add(mImport); - mFile.add(mExport); - updateStatusBar(); - } // jbInit - - /** - * ActionListener - * @param e event - */ - public void actionPerformed(ActionEvent e) - { - if (e.getActionCommand().equals(ConfirmPanel.A_OK)) - { - m_text = textArea.getText(); - if (log.isLoggable(Level.FINE)) log.fine("OK - length=" + m_text.length()); - dispose(); - } - else if (e.getActionCommand().equals(ConfirmPanel.A_CANCEL)) - { - dispose(); - } - - else if (e.getSource() == mImport) - { - importText(); - } - else if (e.getSource() == mExport) - { - exportText(); - } - } // actionPerformed - - /** - * Update Status Bar - */ - private void updateStatusBar() - { - String str = textArea.getText(); - int length = str.length(); - statusBar.setStatusDB(length); - int size = length; - try - { - size = str.getBytes("UTF-8").length; - } - catch (UnsupportedEncodingException e) - { - log.log(Level.SEVERE, str, e); - } - - if (m_maxSize == 0) - statusBar.setStatusLine(String.valueOf(size)); - else if (size < m_maxSize) - statusBar.setStatusLine(size + " < " + m_maxSize, false); - else if (size == m_maxSize) - statusBar.setStatusLine(size + " = " + m_maxSize, false); - else - { - statusBar.setStatusLine(size + " > " + m_maxSize, true); - Toolkit.getDefaultToolkit().beep(); - } - } // updateStatusBar - - /** - * Get Text - * @return edited text - */ - public String getText() - { - return m_text; - } // getText - - /** - * Import Text from File - */ - private void importText() - { - JFileChooser jc = new JFileChooser(); - jc.setDialogTitle(Msg.getMsg(Env.getCtx(), "ImportText")); - jc.setDialogType(JFileChooser.OPEN_DIALOG); - jc.setFileSelectionMode(JFileChooser.FILES_ONLY); - // - if (jc.showOpenDialog(this) != JFileChooser.APPROVE_OPTION) - return; - - StringBuilder sb = new StringBuilder(); - try - { - InputStreamReader in = new InputStreamReader (new FileInputStream (jc.getSelectedFile())); - char[] cbuf = new char[1024]; - int count; - while ((count = in.read(cbuf)) > 0) - sb.append(cbuf, 0, count); - in.close(); - } - catch (Exception e) - { - log.log(Level.WARNING, e.getMessage()); - return; - } - textArea.setText(sb.toString()); - updateStatusBar(); - } // importText - - /** - * Export Text to File - */ - private void exportText() - { - JFileChooser jc = new JFileChooser(); - jc.setDialogTitle(Msg.getMsg(Env.getCtx(), "ExportText")); - jc.setDialogType(JFileChooser.SAVE_DIALOG); - jc.setFileSelectionMode(JFileChooser.FILES_ONLY); - // - if (jc.showSaveDialog(this) != JFileChooser.APPROVE_OPTION) - return; - - try - { - BufferedWriter bout = new BufferedWriter (new OutputStreamWriter (new FileOutputStream (jc.getSelectedFile()))); - bout.write(textArea.getText()); - bout.flush(); - bout.close(); - } - catch (Exception e) - { - log.log(Level.WARNING, e.getMessage()); - } - } // exportText - - /** - * ChangeListener for TabbedPane - * @param e event - */ - public void stateChanged(ChangeEvent e) - { - if (tabbedPane.getSelectedIndex() == 1) // switch to HTML - textPane.setText(textArea.getText()); - } // stateChanged - - public void keyTyped (KeyEvent e) - { - } - - public void keyPressed (KeyEvent e) - { - } - - public void keyReleased (KeyEvent e) - { - updateStatusBar(); - } - -} // Editor diff --git a/org.adempiere.ui.swing/src/org/compiere/grid/ed/HTMLEditor.java b/org.adempiere.ui.swing/src/org/compiere/grid/ed/HTMLEditor.java deleted file mode 100644 index c522129a78..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/grid/ed/HTMLEditor.java +++ /dev/null @@ -1,531 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ -package org.compiere.grid.ed; - -import java.awt.BorderLayout; -import java.awt.Dialog; -import java.awt.Dimension; -import java.awt.Frame; -import java.awt.Window; -import java.awt.event.ActionEvent; -import java.io.FileInputStream; -import java.io.FileOutputStream; -import java.io.InputStreamReader; -import java.io.OutputStreamWriter; -import java.util.Hashtable; -import java.util.logging.Level; - -import javax.swing.Action; -import javax.swing.JButton; -import javax.swing.JFileChooser; -import javax.swing.JFrame; -import javax.swing.JMenu; -import javax.swing.JMenuBar; -import javax.swing.JMenuItem; -import javax.swing.JScrollPane; -import javax.swing.JTextPane; -import javax.swing.JToolBar; -import javax.swing.text.EditorKit; -import javax.swing.text.html.HTML; -import javax.swing.text.html.HTMLEditorKit; - -import org.compiere.Adempiere; -import org.compiere.apps.AEnv; -import org.compiere.apps.ConfirmPanel; -import org.compiere.swing.CDialog; -import org.compiere.swing.CPanel; -import org.compiere.util.CLogger; -import org.compiere.util.Env; -import org.compiere.util.Msg; - -/** - * HTML Editor. - * (Thanks to Kim Topley "Core Swing Programming" for action menu organization) - * @author Jorg Janke - * @version $Id: HTMLEditor.java,v 1.2 2006/07/30 00:51:28 jjanke Exp $ - */ -public class HTMLEditor extends CDialog -{ - /** - * - */ - private static final long serialVersionUID = -7502050590234610482L; - - - /** - * HTML Editor - * @param owner owner - * @param htmlText text - */ - public HTMLEditor (Frame owner, String title, String htmlText, boolean editable) - { - super (owner, title == null ? Msg.getMsg(Env.getCtx(), "Editor") : title, true); - init(owner, htmlText, editable); - } // HTMLEditor - - - /** - * HTML Editor - * @param owner owner - * @param htmlText text - */ - public HTMLEditor (Dialog owner, String title, String htmlText, boolean editable) - { - super (owner, title == null ? Msg.getMsg(Env.getCtx(), "Editor") : title, true); - init(owner, htmlText, editable); - } // HTMLEditor - - /** - * Init - * @param owner owner - * @param htmlText text - */ - private void init (Window owner, String htmlText, boolean editable) - { - try - { - jbInit(); - } - catch (Exception e) - { - log.log(Level.SEVERE, "HTMLEditor", e); - } - setHtmlText(htmlText); - editorPane.setEditable(editable); - AEnv.showCenterWindow(owner, this); - } // init - - /** Logger */ - private CLogger log = CLogger.getCLogger(getClass()); - /** The HTML Text */ - private String m_text; - - // - private CPanel mainPanel = new CPanel(); - private BorderLayout mainLayout = new BorderLayout(); - // - private JScrollPane editorScrollPane = new JScrollPane(); - private JTextPane editorPane = new JTextPane(); - // - private ConfirmPanel confirmPanel = new ConfirmPanel (true); - - // Tool Bar - private JToolBar toolBar = new JToolBar(); - private JButton bImport = AEnv.getButton("Import"); - private JButton bExport = AEnv.getButton("Export"); - private JButton bBold = AEnv.getButton("Bold"); - private JButton bItalic = AEnv.getButton("Italic"); - private JButton bUnderline = AEnv.getButton("Underline"); - - // Menu Bar - private JMenuBar menuBar = new JMenuBar(); - - private static String NAME_SIZE = Msg.getMsg(Env.getCtx(),"Size"); - private static String NAME_HEADING = Msg.getMsg(Env.getCtx(), "Heading"); - // Font Size Sub-Menu - private static HTMLEditor_MenuAction[] sizeMenu = new HTMLEditor_MenuAction[] { - new HTMLEditor_MenuAction(NAME_SIZE + " 8", "font-size-8"), - new HTMLEditor_MenuAction(NAME_SIZE + " 10", "font-size-10"), - new HTMLEditor_MenuAction(NAME_SIZE + " 12", "font-size-12"), - new HTMLEditor_MenuAction(NAME_SIZE + " 14", "font-size-14"), - new HTMLEditor_MenuAction(NAME_SIZE + " 16", "font-size-16"), - new HTMLEditor_MenuAction(NAME_SIZE + " 18", "font-size-18"), - new HTMLEditor_MenuAction(NAME_SIZE + " 24", "font-size-24"), - new HTMLEditor_MenuAction(NAME_SIZE + " 36", "font-size-36"), - new HTMLEditor_MenuAction(NAME_SIZE + " 48", "font-size-48") - }; - // Font Family Sub-Menu - private static HTMLEditor_MenuAction[] familyMenu = new HTMLEditor_MenuAction[] { - new HTMLEditor_MenuAction("Sans Serif", "font-family-SansSerif"), - new HTMLEditor_MenuAction("Monospaced", "font-family-Monospaced"), - new HTMLEditor_MenuAction("Serif", "font-family-Serif") - }; - // Font Size Sub-Menu - private static HTMLEditor_MenuAction[] styleMenu = new HTMLEditor_MenuAction[] { - new HTMLEditor_MenuAction(Msg.getMsg(Env.getCtx(), "Bold"), "font-bold"), - new HTMLEditor_MenuAction(Msg.getMsg(Env.getCtx(), "Italic"), "font-italic"), - new HTMLEditor_MenuAction(Msg.getMsg(Env.getCtx(), "Underline"), "font-underline") - // default-typed? - }; - // Heading Sub-Menu - private static HTMLEditor_MenuAction[] headingMenu = new HTMLEditor_MenuAction[] { - new HTMLEditor_MenuAction(NAME_HEADING + " 1", "Heading 1"), - new HTMLEditor_MenuAction(NAME_HEADING + " 2", "Heading 2"), - new HTMLEditor_MenuAction(NAME_HEADING + " 3", "Heading 3"), - new HTMLEditor_MenuAction(NAME_HEADING + " 4", "Heading 4"), - new HTMLEditor_MenuAction(NAME_HEADING + " 5", "Heading 5") - }; - // Font Menu - private static HTMLEditor_MenuAction[] fontMenu = new HTMLEditor_MenuAction[] { - new HTMLEditor_MenuAction(NAME_SIZE, sizeMenu), - new HTMLEditor_MenuAction(Msg.getMsg(Env.getCtx(), "FontFamily"), familyMenu), - new HTMLEditor_MenuAction(Msg.getMsg(Env.getCtx(), "FontStyle"), styleMenu), - new HTMLEditor_MenuAction(NAME_HEADING, headingMenu) - }; - // Alignment Menu - private static HTMLEditor_MenuAction[] alignMenu = new HTMLEditor_MenuAction[] { - new HTMLEditor_MenuAction(Msg.getMsg(Env.getCtx(), "Left"), "left-justify"), - new HTMLEditor_MenuAction(Msg.getMsg(Env.getCtx(), "Center"), "center-justify"), - new HTMLEditor_MenuAction(Msg.getMsg(Env.getCtx(), "Right"), "right-justify") - }; - // Other HTML Menu - private static HTMLEditor_MenuAction[] htmlMenu = new HTMLEditor_MenuAction[] { - new HTMLEditor_MenuAction("Paragraph", "Paragraph"), - new HTMLEditor_MenuAction("Table", "InsertTable"), - new HTMLEditor_MenuAction("Table Row", "InsertTableRow"), - new HTMLEditor_MenuAction("Table Cell", "InsertTableDataCell"), - new HTMLEditor_MenuAction("Unordered List", "InsertUnorderedList"), - new HTMLEditor_MenuAction("Unordered List Item", "InsertUnorderedListItem"), - new HTMLEditor_MenuAction("Ordered List", "InsertOrderedList"), - new HTMLEditor_MenuAction("Ordered List Item", "InsertOrderedListItem"), - new HTMLEditor_MenuAction("Preformatted Paragraph", "InsertPre"), - new HTMLEditor_MenuAction("Horizontal Rule", "InsertHR") - }; - - // Insert HTML Actions - private static HTMLEditorKit.InsertHTMLTextAction[] extraActions = - new HTMLEditorKit.InsertHTMLTextAction[] - { - new HTMLEditorKit.InsertHTMLTextAction("Heading 1", "

    h1

    ", - HTML.Tag.BODY, HTML.Tag.H1), - new HTMLEditorKit.InsertHTMLTextAction("Heading 2", "

    h2

    ", - HTML.Tag.BODY, HTML.Tag.H2), - new HTMLEditorKit.InsertHTMLTextAction("Heading 3", "

    h3

    ", - HTML.Tag.BODY, HTML.Tag.H3), - new HTMLEditorKit.InsertHTMLTextAction("Heading 4", "

    h4

    ", - HTML.Tag.BODY, HTML.Tag.H4), - new HTMLEditorKit.InsertHTMLTextAction("Heading 5", "

    h5

    ", - HTML.Tag.BODY, HTML.Tag.H5), - // - new HTMLEditorKit.InsertHTMLTextAction("Paragraph", "

    p

    ", - HTML.Tag.BODY, HTML.Tag.P) - }; - - - /** - * Static Init - * @throws Exception - */ - private void jbInit() throws Exception - { - // ToolBar - bImport.setToolTipText(Msg.getMsg(Env.getCtx(), "Import")); - bImport.addActionListener(this); - bExport.setToolTipText(Msg.getMsg(Env.getCtx(), "Export")); - bExport.addActionListener(this); - // - bBold.setToolTipText(Msg.getMsg(Env.getCtx(), "Bold")); - bItalic.setToolTipText(Msg.getMsg(Env.getCtx(), "Italic")); - bUnderline.setToolTipText(Msg.getMsg(Env.getCtx(), "Underline")); - - toolBar.add(bImport, null); - toolBar.add(bExport, null); - toolBar.addSeparator(); - toolBar.add(bBold, null); - toolBar.add(bItalic, null); - toolBar.add(bUnderline, null); - toolBar.addSeparator(); - - // Editor - editorPane.setContentType("text/html"); - // Set Menu (content type must be set) - setJMenuBar(menuBar); - createMenuBar(); - - // General Layout - mainPanel.setLayout(mainLayout); - getContentPane().add(mainPanel, BorderLayout.CENTER); - mainPanel.add(toolBar, BorderLayout.NORTH); - mainPanel.add(editorScrollPane, BorderLayout.CENTER); - // Size 600x600 - editorScrollPane.setPreferredSize(new Dimension(600,600)); - editorScrollPane.getViewport().add(editorPane, null); - mainPanel.add(confirmPanel, BorderLayout.SOUTH); - confirmPanel.addActionListener(this); - } // setHTMLText - - /** - * Create Menu Bar - */ - private void createMenuBar() - { - // Build Lookup - Action[] actionArray = editorPane.getActions(); - Hashtable actions = new Hashtable(); - for (int i = 0; i < actionArray.length; i++) - { - Object name = actionArray[i].getValue(Action.NAME); - // System.out.println (name); - actions.put(name, actionArray[i]); - } - for (int i = 0; i < extraActions.length; i++) - { - Object name = extraActions[i].getValue(Action.NAME); - actions.put(name, extraActions[i]); - } - - // Add the font menu - JMenu menu = buildMenu(Msg.getMsg(Env.getCtx(), "Font"), fontMenu, actions); - if (menu != null) - menuBar.add(menu); - - // Add the alignment menu - menu = buildMenu(Msg.getMsg(Env.getCtx(), "Align"), alignMenu, actions); - if (menu != null) - menuBar.add(menu); - - // Add the HTML menu - menu = buildMenu("HTML", htmlMenu, actions); - if (menu != null) - menuBar.add(menu); - - // Add to Button Actions - Action targetAction = (Action)actions.get("font-bold"); - bBold.addActionListener(targetAction); - targetAction = (Action)actions.get("font-italic"); - bItalic.addActionListener(targetAction); - targetAction = (Action)actions.get("font-underline"); - bUnderline.addActionListener(targetAction); - - } // createMenuBar - - /** - * Build Menu - * @param name name - * @param menuActions menu structure - * @param actions lookup - * @return menu - */ - private JMenu buildMenu(String name, HTMLEditor_MenuAction[] menuActions, Hashtable actions) - { - JMenu menu = new JMenu(name); - for (int i = 0; i < menuActions.length; i++) - { - HTMLEditor_MenuAction item = menuActions[i]; - if (item.isSubMenu()) // Recurse to handle a sub menu - { - JMenu subMenu = buildMenu(item.getName(), item.getSubMenus(), actions); - if (subMenu != null) - menu.add(subMenu); - } - else if (item.isAction()) // direct action - { - menu.add(item.getAction()); - } - else // find it - { - String actionName = item.getActionName(); - Action targetAction = (Action)actions.get(actionName); - // Create the menu item - JMenuItem menuItem = menu.add(item.getName()); - if (targetAction != null) - menuItem.addActionListener(targetAction); - else // Action not known - disable the menu item - menuItem.setEnabled(false); - } - } // for all actions - - // Return null if nothing was added to the menu. - if (menu.getMenuComponentCount() == 0) - menu = null; - - return menu; - } // buildMenu - - /** - * Action Listener - * @param e event - */ - public void actionPerformed (ActionEvent e) - { - // log.fine("actionPerformed - Text:" + getHtmlText()); - // - - if (e.getSource() == bImport) - cmd_import(); - else if (e.getSource() == bExport) - cmd_export(); - // - else if (e.getActionCommand().equals(ConfirmPanel.A_OK)) - { - m_text = editorPane.getText(); - dispose(); - } - else if (e.getActionCommand().equals(ConfirmPanel.A_CANCEL)) - dispose(); - } // actionPerformed - - /** - * Import Text from File - */ - private void cmd_import() - { - JFileChooser jc = new JFileChooser(); - jc.setDialogTitle(Msg.getMsg(Env.getCtx(), "Import")); - jc.setDialogType(JFileChooser.OPEN_DIALOG); - jc.setFileSelectionMode(JFileChooser.FILES_ONLY); - // - if (jc.showOpenDialog(this) != JFileChooser.APPROVE_OPTION) - return; - - StringBuilder sb = new StringBuilder(); - try - { - InputStreamReader in = new InputStreamReader (new FileInputStream (jc.getSelectedFile())); - char[] cbuf = new char[1024]; - int count; - while ((count = in.read(cbuf)) > 0) - sb.append(cbuf, 0, count); - in.close(); - } - catch (Exception e) - { - log.log(Level.SEVERE, "HTMLEditor.import" + e.getMessage()); - return; - } - setHtmlText(sb.toString()); - } // cmd_import - - /** - * Export Text to File - */ - private void cmd_export() - { - JFileChooser jc = new JFileChooser(); - jc.setDialogTitle(Msg.getMsg(Env.getCtx(), "Export")); - jc.setDialogType(JFileChooser.SAVE_DIALOG); - jc.setFileSelectionMode(JFileChooser.FILES_ONLY); - // - if (jc.showSaveDialog(this) != JFileChooser.APPROVE_OPTION) - return; - - try - { - @SuppressWarnings("unused") - EditorKit kit = editorPane.getEditorKit(); - OutputStreamWriter writer = new OutputStreamWriter - (new FileOutputStream (jc.getSelectedFile())); - editorPane.write(writer); - writer.flush(); - writer.close(); - } - catch (Exception e) - { - log.log(Level.SEVERE, "HTMLEditor.export" + e.getMessage()); - } - } // cmd_export - - - /************************************************************************* - * Get Html Text - * @return text - */ - public String getHtmlText() - { - return m_text; - } // getHTMLText - - /** - * Set Html Text - * @param htmlText - */ - public void setHtmlText (String htmlText) - { - m_text = htmlText; - editorPane.setText(htmlText); - } // setHTMLText - - /************************************************************************** - * Test - * @param args ignored - */ - public static void main (String[] args) - { - Adempiere.startupEnvironment(true); - JFrame frame = new JFrame("test"); - frame.setVisible(true); - String text = "

    this is a line
    with bold info"; - int i = 0; - while (true) - { - HTMLEditor ed = new HTMLEditor (frame, "heading " + ++i, text, true); - text = ed.getHtmlText(); - } - } // main - -} // HTMLEditor - -/****************************************************************************** - * HTML Editor Menu Action - */ -class HTMLEditor_MenuAction -{ - public HTMLEditor_MenuAction(String name, HTMLEditor_MenuAction[] subMenus) - { - m_name = name; - m_subMenus = subMenus; - } - - public HTMLEditor_MenuAction(String name, String actionName) - { - m_name = name; - m_actionName = actionName; - } - - public HTMLEditor_MenuAction(String name, Action action) - { - m_name = name; - m_action = action; - } - - private String m_name; - private String m_actionName; - private Action m_action; - private HTMLEditor_MenuAction[] m_subMenus; - - - public boolean isSubMenu() - { - return m_subMenus != null; - } - - public boolean isAction() - { - return m_action != null; - } - - public String getName() - { - return m_name; - } - - public HTMLEditor_MenuAction[] getSubMenus() - { - return m_subMenus; - } - - public String getActionName() - { - return m_actionName; - } - - public Action getAction() - { - return m_action; - } - -} // MenuAction diff --git a/org.adempiere.ui.swing/src/org/compiere/grid/ed/MDocDate.java b/org.adempiere.ui.swing/src/org/compiere/grid/ed/MDocDate.java deleted file mode 100644 index 279ef458a6..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/grid/ed/MDocDate.java +++ /dev/null @@ -1,304 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ -package org.compiere.grid.ed; - -import java.sql.Timestamp; -import java.text.SimpleDateFormat; -import java.util.Date; -import java.util.logging.Level; - -import javax.swing.event.CaretEvent; -import javax.swing.event.CaretListener; -import javax.swing.text.AttributeSet; -import javax.swing.text.BadLocationException; -import javax.swing.text.JTextComponent; -import javax.swing.text.PlainDocument; - -import org.compiere.apps.ADialog; -import org.compiere.util.CLogger; - -/** - * Date Model. - * Validates input based on date pattern - * @see VDate - * - * @author Jorg Janke - * @version $Id: MDocDate.java,v 1.2 2006/07/30 00:51:28 jjanke Exp $ - */ -public final class MDocDate extends PlainDocument implements CaretListener -{ - /** - * - */ - private static final long serialVersionUID = 8453168098223574265L; - - /** - * Constructor - * @param displayType display type - * @param format format - * @param tc text component - * @param title title - */ - public MDocDate (int displayType, SimpleDateFormat format, - JTextComponent tc, String title) - { - super(); - m_displayType = displayType; - m_tc = tc; - m_tc.addCaretListener(this); - // - m_format = format; - if (m_format == null) - m_format = new SimpleDateFormat(); - m_format.setLenient(false); - - // Mark delimiters as '^' in Pattern - char[] pattern = m_format.toPattern().toCharArray(); - for (int i = 0; i < pattern.length; i++) - { - // do we have a delimiter? - if ("Mdy".indexOf(pattern[i]) == -1) - pattern[i] = DELIMITER; - } - m_mask = new String(pattern); - // - m_title = title; - if (m_title == null) - m_title = ""; - } // MDocDate - - private JTextComponent m_tc; - private SimpleDateFormat m_format; - private String m_mask; - private static final char DELIMITER = '^'; - // for Calendar - private String m_title; - private int m_displayType; - private int m_lastDot = 0; // last dot position - /** Logger */ - private static CLogger log = CLogger.getCLogger(MDocDate.class); - - /** - * Insert String - * @param offset offset - * @param string string - * @param attr attributes - * @throws BadLocationException - */ - @Override - public void insertString (int offset, String string, AttributeSet attr) - throws BadLocationException - { - if (log.isLoggable(Level.FINEST)) log.finest("Offset=" + offset + ",String=" + string + ",Attr=" + attr - + ",OldText=" + getText() + ",OldLength=" + getText().length()); - - // manual entry - // DBTextDataBinder.updateText sends stuff at once - length=8 - if (string != null && string.length() == 1) - { - // ignore if too long - if (offset >= m_mask.length()) - return; - - // is it an empty field? - int length = getText().length(); - if (offset == 0 && length == 0) - { - Date today = new Date(System.currentTimeMillis()); - String dateStr = m_format.format(today); - super.insertString(0, string + dateStr.substring(1), attr); - m_tc.setCaretPosition(1); - return; - } - - // is it a digit ? - try - { - Integer.parseInt(string); - } - catch (Exception pe) - { - //hengsin, [ 1660175 ] Date field - anoying popup - //startDateDialog(); - ADialog.beep(); - return; - } - - // try to get date in field, if invalid, get today's - /*try - { - char[] cc = getText().toCharArray(); - cc[offset] = string.charAt(0); - m_format.parse(new String(cc)); - } - catch (ParseException pe) - { - startDateDialog(); - return; - }*/ - - // positioned before the delimiter - jump over delimiter - if (offset != m_mask.length()-1 && m_mask.charAt(offset+1) == DELIMITER) - m_tc.setCaretPosition(offset+2); - - // positioned at the delimiter - if (m_mask.charAt(offset) == DELIMITER) - { - offset++; - m_tc.setCaretPosition(offset+1); - } - super.remove(offset, 1); // replace current position - } - - // Set new character - super.insertString(offset, string, attr); - // New value set Cursor - if (offset == 0 && string != null && string.length() > 1) - m_tc.setCaretPosition(0); - } // insertString - - /** - * Delete String - * @param offset offset - * @param length length - * @throws BadLocationException - */ - @Override - public void remove (int offset, int length) - throws BadLocationException - { - if (log.isLoggable(Level.FINEST)) log.finest("Offset=" + offset + ",Length=" + length); - - // begin of string - if (offset == 0 || length == 0) - { - // empty the field - // if the length is 0 or greater or equal with the mask length - teo_sarca, [ 1660595 ] Date field: incorrect functionality on paste - if (length >= m_mask.length() || length == 0) - super.remove(offset, length); - return; - } - - // one position behind delimiter - if (offset-1 >= 0 && offset-1 < m_mask.length() - && m_mask.charAt(offset-1) == DELIMITER) - { - if (offset-2 >= 0) - m_tc.setCaretPosition(offset-2); - else - return; - } - else - m_tc.setCaretPosition(offset-1); - } // deleteString - - /** - * Caret Listener - * @param e event - */ - public void caretUpdate(CaretEvent e) - { - if (log.isLoggable(Level.FINEST)) log.finest("Dot=" + e.getDot() + ",Last=" + m_lastDot - + ", Mark=" + e.getMark()); - // Selection - if (e.getDot() != e.getMark()) - { - m_lastDot = e.getDot(); - return; - } - // - - // Is the current position a fixed character? - if (e.getDot()+1 > m_mask.length() - || m_mask.charAt(e.getDot()) != DELIMITER) - { - m_lastDot = e.getDot(); - return; - } - - // Direction? - int newDot = -1; - if (m_lastDot > e.getDot()) // <- - newDot = e.getDot() - 1; - else // -> (or same) - newDot = e.getDot() + 1; - if (e.getDot() == 0) // first - newDot = 1; - else if (e.getDot() == m_mask.length()-1) // last - newDot = e.getDot() - 1; - // - if (log.isLoggable(Level.FINE)) log.fine("OnFixedChar=" + m_mask.charAt(e.getDot()) - + ", newDot=" + newDot + ", last=" + m_lastDot); - // - m_lastDot = e.getDot(); - if (newDot >= 0 && newDot < getText().length()) - m_tc.setCaretPosition(newDot); - } // caretUpdate - - /** - * Get Full Text - * @return text - */ - private String getText() - { - String str = ""; - try - { - str = getContent().getString(0, getContent().length()-1); // cr at end - } - catch (Exception e) - { - str = ""; - } - return str; - } // getString - - /** - * Call Calendar Dialog - */ - @SuppressWarnings("unused") - private void startDateDialog() - { - log.config(""); - - // Date Dialog - String result = getText(); - Timestamp ts = null; - try - { - ts = new Timestamp(m_format.parse(result).getTime()); - } - catch (Exception pe) - { - ts = new Timestamp(System.currentTimeMillis()); - } - ts = VDate.startCalendar(m_tc, ts, m_format, m_displayType, m_title); - result = m_format.format(ts); - - // move to field - try - { - super.remove(0, getText().length()); - super.insertString(0, result, null); - } - catch (BadLocationException ble) - { - log.log(Level.SEVERE, "", ble); - } - } // startDateDialog - -} // MDocDate diff --git a/org.adempiere.ui.swing/src/org/compiere/grid/ed/MDocNumber.java b/org.adempiere.ui.swing/src/org/compiere/grid/ed/MDocNumber.java deleted file mode 100644 index 4416b9afac..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/grid/ed/MDocNumber.java +++ /dev/null @@ -1,322 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ -package org.compiere.grid.ed; - -import java.math.BigDecimal; -import java.math.RoundingMode; -import java.text.DecimalFormat; -import java.text.DecimalFormatSymbols; -import java.text.ParseException; -import java.util.logging.Level; - -import javax.swing.text.AttributeSet; -import javax.swing.text.BadLocationException; -import javax.swing.text.JTextComponent; -import javax.swing.text.PlainDocument; - -import org.compiere.apps.ADialog; -import org.compiere.util.CLogger; -import org.compiere.util.DisplayType; -import org.compiere.util.Env; - -/** - * Number Document Model. - * Locale independent editing of numbers by removing thousands - * and treating ., as decimal separator. Final formatting in VNumber.setValue - * - * @see VNumber - * @author Jorg Janke - * @version $Id: MDocNumber.java,v 1.2 2006/07/30 00:51:28 jjanke Exp $ - * - * @author Teo Sarca, SC ARHIPAC SERVICE SRL - BF [ 1759655 ] - */ -public final class MDocNumber extends PlainDocument -{ - /** - * - */ - private static final long serialVersionUID = 2586631851842406102L; - - /** - * Constructor - * @param displayType - * @param format - * @param tc - * @param title - */ - public MDocNumber(int displayType, DecimalFormat format, - JTextComponent tc, String title) - { - super(); - if (format == null || tc == null || title == null) - throw new IllegalArgumentException("Invalid argument"); - // - m_displayType = displayType; - m_format = format; - m_tc = tc; - m_title = title; - // - DecimalFormatSymbols sym = m_format.getDecimalFormatSymbols(); - m_decimalSeparator = sym.getDecimalSeparator(); - m_groupingSeparator = sym.getGroupingSeparator(); - m_minusSign = sym.getMinusSign(); - // log.finest("Decimal=" + m_decimalSeparator + "(" + (int)m_decimalSeparator - // + ") - Group=" + m_groupingSeparator + "(" + (int)m_groupingSeparator +")"); - } // MDocNumber - - /** DisplayType used */ - private int m_displayType = 0; - /** Number Format */ - private DecimalFormat m_format = null; - /** The 'owning' component */ - private JTextComponent m_tc = null; - /** Title for calculator */ - private String m_title = null; - /** Decimal Separator */ - private char m_decimalSeparator = '.'; - /** Grouping Separator */ - private char m_groupingSeparator = ','; - /** Minus Sign */ - private char m_minusSign = '-'; - /** Percent Sign */ - private char m_percentSign = '%'; - /** Logger */ - private static CLogger log = CLogger.getCLogger (MDocNumber.class); - - /************************************************************************** - * Insert String - * @param origOffset - * @param string - * @param attr - * @throws BadLocationException - */ - @Override - public void insertString(int origOffset, String string, AttributeSet attr) - throws BadLocationException - { - if (log.isLoggable(Level.FINEST)) log.finest("Offset=" + origOffset + " String=" + string + " Length=" + string.length()); - if (origOffset < 0 || string == null) - throw new IllegalArgumentException("Invalid argument"); - - int offset = origOffset; - int length = string.length(); - // From DataBinder (assuming correct format) - if (length != 1) - { - super.insertString(offset, string, attr); - return; - } - - /** - * Manual Entry - */ - String content = getText(); - // remove all Thousands - if (content.indexOf(m_groupingSeparator) != -1) - { - StringBuilder result = new StringBuilder(); - for (int i = 0; i < content.length(); i++) - { - if (content.charAt(i) == m_groupingSeparator) - { - if (i < offset) - offset--; - } - else - result.append(content.charAt(i)); - } - super.remove(0, content.length()); - super.insertString(0, result.toString(), attr); - // - m_tc.setCaretPosition(offset); - // ADebug.trace(ADebug.l6_Database, "Clear Thousands (" + m_format.toPattern() + ")" + content + " -> " + result.toString()); - content = result.toString(); - } // remove Thousands - - /********************************************************************** - * Check Character entered - */ - char c = string.charAt(0); - if (Character.isDigit(c)) // c >= '0' && c <= '9') - { - // ADebug.trace(ADebug.l6_Database, "Digit=" + c); - super.insertString(offset, string, attr); - return; - } - - // Decimal - remove other decimals - // Thousand - treat as Decimal - else if (c == m_decimalSeparator || c == m_groupingSeparator || c == '.' || c == ',') - { - // log.info("Decimal=" + c + " (ds=" + m_decimalSeparator + "; gs=" + m_groupingSeparator + ")"); - // no decimals on integers - if (m_displayType == DisplayType.Integer) - return; - int pos = content.indexOf(m_decimalSeparator); - - // put decimal in - String decimal = String.valueOf(m_decimalSeparator); - super.insertString(offset, decimal, attr); - - // remove other decimals - if (pos != 0) - { - content = getText(); - StringBuilder result = new StringBuilder(); - int correction = 0; - for (int i = 0; i < content.length(); i++) - { - if (content.charAt(i) == m_decimalSeparator) - { - if (i == offset) - result.append(content.charAt(i)); - else if (i < offset) - correction++; - } - else - result.append(content.charAt(i)); - } - super.remove(0, content.length()); - super.insertString(0, result.toString(), attr); - m_tc.setCaretPosition(offset-correction+1); - } // remove other decimals - } // decimal or thousand - - // something else - else if (VNumber.AUTO_POPUP || "=+-/*%".indexOf(c) > -1) - { - - // Minus - put minus on start of string - if ( c == m_minusSign && offset == 0 ) - { - // no minus possible - if (m_displayType == DisplayType.Integer) - return; - // add at start of string - else - super.insertString(0, "-", attr); - } - else - { - if (log.isLoggable(Level.FINE)) log.fine("Input=" + c + " (" + (int)c + ")"); - - if (c == m_percentSign && offset > 0 ) { - // don't convert integers to percent. 1% = 0? - if (m_displayType == DisplayType.Integer) - return; - // divide by 100 - else - { - String value = getText(); - BigDecimal percentValue = Env.ZERO; - try - { - if (value != null && value.length() > 0) - { - Number number = m_format.parse(value); - percentValue = new BigDecimal (number.toString()); - percentValue = percentValue.divide(Env.ONEHUNDRED, m_format.getMaximumFractionDigits(), RoundingMode.HALF_UP); - m_tc.setText(m_format.format(percentValue)); - } - } - catch (ParseException pe) - { - if (log.isLoggable(Level.INFO)) log.info("InvalidEntry - " + pe.getMessage()); - } - - } - } - else - { - - String result = VNumber.startCalculator(m_tc, getText(), - m_format, m_displayType, m_title, c); - super.remove(0, content.length()); - - // insertString(0, result, attr); - m_tc.setText(result); - } - } - } - else - ADialog.beep(); - } // insertString - - - /************************************************************************** - * Delete String - * @param origOffset Offeset - * @param length length - * @throws BadLocationException - */ - @Override - public void remove (int origOffset, int length) - throws BadLocationException - { - if (log.isLoggable(Level.FINEST)) log.finest("Offset=" + origOffset + " Length=" + length); - if (origOffset < 0 || length < 0) - throw new IllegalArgumentException("MDocNumber.remove - invalid argument"); - - int offset = origOffset; - if (length != 1) - { - super.remove(offset, length); - return; - } - /** - * Manual Entry - */ - String content = getText(); - // remove all Thousands - if (content.indexOf(m_groupingSeparator) != -1) - { - StringBuilder result = new StringBuilder(); - for (int i = 0; i < content.length(); i++) - { - if (content.charAt(i) == m_groupingSeparator && i != origOffset) - { - if (i < offset) - offset--; - } - else - result.append(content.charAt(i)); - } - super.remove(0, content.length()); - super.insertString(0, result.toString(), null); - m_tc.setCaretPosition(offset); - } // remove Thousands - super.remove(offset, length); - } // remove - - /** - * Get Full Text - * @return text - */ - private String getText() - { - Content c = getContent(); - String str = ""; - try - { - str = c.getString(0, c.length()-1); // cr at end - } - catch (Exception e) - {} - return str; - } // getString - -} // MDocNumber diff --git a/org.adempiere.ui.swing/src/org/compiere/grid/ed/MDocString.java b/org.adempiere.ui.swing/src/org/compiere/grid/ed/MDocString.java deleted file mode 100644 index dcb30e01ac..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/grid/ed/MDocString.java +++ /dev/null @@ -1,401 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ -package org.compiere.grid.ed; - -import java.util.logging.Level; - -import javax.swing.event.CaretEvent; -import javax.swing.event.CaretListener; -import javax.swing.text.AttributeSet; -import javax.swing.text.BadLocationException; -import javax.swing.text.JTextComponent; -import javax.swing.text.PlainDocument; - -import org.compiere.util.CLogger; - -/** - * String Input Verification. - *

    - *	-	Length is set to length of VFormat or FieldLength if no format defined
    - *	Control Characters
    - *			(Space) any character
    - *		_	Space (fixed character)
    - *
    - *		l	any Letter a..Z NO space
    - *		L	any Letter a..Z NO space converted to upper case
    - *		o	any Letter a..Z or space
    - *		O	any Letter a..Z or space converted to upper case
    - *
    - *		0	Digits 0..9 NO space
    - *      9   Digits 0..9 or space
    - *
    - *		a	any Letters & Digits NO space
    - *		A	any Letters & Digits NO space converted to upper case
    - *		c	any Letters & Digits or space
    - *		C	any Letters & Digits or space converted to upper case
    - *		Z	any character converted to upper case
    - *  
    - * @see VString - * @author Jorg Janke - * @version $Id: MDocString.java,v 1.2 2006/07/30 00:51:27 jjanke Exp $ - */ -public final class MDocString extends PlainDocument implements CaretListener -{ - /** - * - */ - private static final long serialVersionUID = -1714284669663890694L; - - /** - * Constructor - * @param VFormat - * @param fieldLength - * @param tc VPassword or VString - */ - public MDocString(String VFormat, int fieldLength, JTextComponent tc) - { - super(); - m_fieldLength = fieldLength; - setFormat (VFormat); - m_tc = tc; - if (tc != null) - m_tc.addCaretListener(this); - } // MDocNumber - - private String m_VFormat; // Value Format String - private String m_mask; // Fixed Elements - private int m_fieldLength; - private int m_maxLength; - private JTextComponent m_tc; - private int m_lastDot = 0; // last dot position - // - private static final char SPACE = ' '; - private static final char SPACE_IND = '_'; - /** Logger */ - private static CLogger log = CLogger.getCLogger(MDocString.class); - - /** - * Set Format - * @param VFormat - */ - public final void setFormat (String VFormat) - { - m_VFormat = VFormat; - if (m_VFormat == null) - m_VFormat = ""; - m_mask = m_VFormat; - // Set Length - m_maxLength = m_fieldLength; - if (m_VFormat.length() == 0) - return; - // - log.fine(VFormat); - if (m_maxLength > m_VFormat.length()) - m_maxLength = m_VFormat.length(); - - // Create Mask - m_mask = m_mask.replace('c', SPACE); // c any Letter or Digit or space - m_mask = m_mask.replace('C', SPACE); // C any Letter or Digit or space converted to upper case - m_mask = m_mask.replace('a', SPACE); // a any Letters or Digits NO space - m_mask = m_mask.replace('A', SPACE); // A any Letters or Digits NO space converted to upper case - m_mask = m_mask.replace('l', SPACE); // l any Letter a..Z NO space - m_mask = m_mask.replace('L', SPACE); // L any Letter a..Z NO space converted to upper case - m_mask = m_mask.replace('o', SPACE); // o any Letter a..Z or space - m_mask = m_mask.replace('O', SPACE); // O any Letter a..Z or space converted to upper case - m_mask = m_mask.replace('0', SPACE); // 0 Digits 0..9 NO space - m_mask = m_mask.replace('9', SPACE); // 9 Digits 0..9 or space - /** - * Feature Request [1707462] - * Convert any to Uppercase - */ - m_mask = m_mask.replace('Z', SPACE); // Z any character converted to upper case - - // Check Caret - if (m_tc == null || m_tc.getCaret() instanceof VOvrCaret) - return; - else - m_tc.setCaret(new VOvrCaret()); - } // setFormat - - /** - * Insert String - * @param offset - * @param string - * @param attr - * @throws BadLocationException - */ - @Override - public void insertString(int offset, String string, AttributeSet attr) - throws BadLocationException - { - // Max Length - if (m_VFormat.length() == 0) { - // non formatted strings - // // @Trifon - [ 1718897 ] User can enter more characters than max size field - if (getLength() + string.length() > m_maxLength) - return; - } else { - // Formatted strings - // globalqss - Carlos Ruiz [ 1766180 ] Formatted Field input Bug - if (offset >= m_maxLength) - return; - } - - // We have no Format or inserted not manually (assuming correct Format) - if (m_VFormat.length() == 0 || string.length() != 1) - { - if (log.isLoggable(Level.FINEST)) log.finest("Offset=" + offset + " String=" + string); - super.insertString(offset, string, attr); - return; - } - - /** Formating required **/ - if (log.isLoggable(Level.FINEST)) log.finest("Offset=" + offset - + ", String=" + string + ", MaxLength=" + m_maxLength - + ", Format=" + m_VFormat + ", Mask=" + m_mask - + ", Text=" + getText() + ", Length=" + getText().length()); - /** **/ - String text = getText(); - - // Apply Mask, if not target length - if (m_VFormat.length() != text.length()) - { - char[] result = m_mask.toCharArray(); - for (int i = 0; i < result.length; i++) - { - if (result[i] == SPACE && text.length() > i) - result[i] = text.charAt(i); - else if (result[i] == SPACE_IND) - result[i] = SPACE; - } - // - super.remove(0, text.length()); - super.insertString(0, new String(result), attr); - m_tc.setCaretPosition(offset); - text = getText(); - } - - // positioned before a mask character - jump over it - if (offset+1 < text.length() && m_mask.charAt(offset+1) != SPACE) - if (offset+2 < getText().length()) - m_tc.setCaretPosition(offset+2); - - // positioned at the mask character - if (m_mask.charAt(offset) != SPACE) - { - if (offset+1 == m_mask.length()) - return; - offset++; - m_tc.setCaretPosition(offset+1); - } - - // Conversion - char c = string.charAt(0); - char cmd = m_VFormat.charAt(offset); - if (log.isLoggable(Level.FINE)) log.fine( "char=" + c + ", cmd=" + cmd); - switch (cmd) - { - case 'c': // c any Letter or Digits or space - if (Character.isLetter(c) || Character.isDigit(c) || Character.isSpaceChar(c)) - ; - else - return; - break; - // - case 'C': // C any Letter or Digits or space converted to upper case - if (Character.isLetter(c) || Character.isDigit(c) || Character.isSpaceChar(c)) - string = string.toUpperCase(); - else - return; - break; - // - case 'a': // a any Letter or Digits NO space - if (Character.isLetter(c) || Character.isDigit(c)) - ; - else - return; - break; - // - case 'A': // A any Letter or Digits NO space converted to upper case - if (Character.isLetter(c) || Character.isDigit(c)) - string = string.toUpperCase(); - else - return; - break; - // ---- - case 'l': // l any Letter a..Z NO space - if (!Character.isLetter(c)) - return; - break; - // - case 'L': // L any Letter a..Z NO space converted to upper case - if (!Character.isLetter(c)) - return; - string = string.toUpperCase(); - break; - // - case 'o': // o any Letter a..Z or space - if (Character.isLetter(c) || Character.isSpaceChar(c)) - ; - else - return; - break; - // - case 'O': // O any Letter a..Z or space converted to upper case - if (Character.isLetter(c) || Character.isSpaceChar(c)) - string = string.toUpperCase(); - else - return; - break; - // ---- - case '9': // 9 Digits 0..9 or space - if (Character.isDigit(c) || Character.isSpaceChar(c)) - ; - else - return; - break; - // - case '0': // 0 Digits 0..9 NO space - if (!Character.isDigit(c)) - return; - break; - // - case SPACE: // any character - break; - // - /** - * Feature Request [1707462] - * Convert any to Uppercase - */ - case 'Z': // Z any character converted to upper case - string = string.toUpperCase(); - break; - // ---- - default: // other - return; - } // switch - - super.remove(offset, 1); // replace current position - super.insertString(offset, string, attr); - } // insertString - - /** - * Delete String - * @param offset - * @param length - * @throws BadLocationException - */ - @Override - public void remove (int offset, int length) - throws BadLocationException - { - // No format or non manual entry - if (m_VFormat.length() == 0 || length != 1) - { - if (log.isLoggable(Level.FINEST)) log.finest("Offset=" + offset + " Length=" + length); - super.remove(offset, length); - return; - } - - - // begin of string - if (offset == 0) - { - // empty the field - if (length == m_mask.length()) - super.remove(offset, length); - return; - } - - // one position behind delimiter - if (offset-1 >= 0 && m_mask.charAt(offset-1) != SPACE) - { - if (offset-2 >= 0) - m_tc.setCaretPosition(offset-2); - else - return; - } - else - m_tc.setCaretPosition(offset-1); - } // deleteString - - /** - * Get Full Text - * @return text - */ - private String getText() - { - String str = ""; - try - { - str = getContent().getString(0, getContent().length()-1); // cr at end - } - catch (Exception e) - { - str = ""; - } - return str; - } // getString - - - /************************************************************************** - * Caret Listener - * @param e - */ - public void caretUpdate(CaretEvent e) - { - // No Format - if (m_VFormat.length() == 0 - // Format error - all fixed characters - || m_VFormat.equals(m_mask)) - return; - // Selection - if (e.getDot() != e.getMark()) - { - m_lastDot = e.getDot(); - return; - } - // - // log.fine( "MDocString.caretUpdate -" + m_VFormat + "-" + m_mask + "- dot=" + e.getDot() + ", mark=" + e.getMark()); - - // Is the current position a fixed character? - if (e.getDot()+1 > m_mask.length() || m_mask.charAt(e.getDot()) == SPACE) - { - m_lastDot = e.getDot(); - return; - } - - // Direction? - int newDot = -1; - if (m_lastDot > e.getDot()) // <- - newDot = e.getDot() - 1; - else // -> (or same) - newDot = e.getDot() + 1; - // - if (e.getDot() == 0) // first - newDot = 1; - else if (e.getDot() == m_mask.length()-1) // last - newDot = e.getDot() - 1; - // - // log.fine( "OnFixedChar=" + m_mask.charAt(e.getDot()) + ", newDot=" + newDot + ", last=" + m_lastDot); - - m_lastDot = e.getDot(); - if (newDot >= 0 && newDot < getText().length()) - m_tc.setCaretPosition(newDot); - } // caretUpdate - -} // MDocString diff --git a/org.adempiere.ui.swing/src/org/compiere/grid/ed/MDocTime.java b/org.adempiere.ui.swing/src/org/compiere/grid/ed/MDocTime.java deleted file mode 100644 index bd9f7cc236..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/grid/ed/MDocTime.java +++ /dev/null @@ -1,163 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ -package org.compiere.grid.ed; - -import java.util.logging.Level; - -import javax.swing.text.AttributeSet; -import javax.swing.text.BadLocationException; -import javax.swing.text.PlainDocument; - -import org.compiere.util.CLogger; - -/** - * Time Model. - * Validates input for hour or minute field - * @see VDate - * - * @author Jorg Janke - * @version $Id: MDocTime.java,v 1.2 2006/07/30 00:51:28 jjanke Exp $ - */ -public final class MDocTime extends PlainDocument -{ - /** - * - */ - private static final long serialVersionUID = 5359545674957190259L; - - /** - * Constructor - * @param isHour Hour field - * @param is12Hour 12 hour format - */ - public MDocTime(boolean isHour, boolean is12Hour) - { - super(); - m_isHour = isHour; - m_is12Hour = is12Hour; - } // MDocTime - - private boolean m_isHour; - private boolean m_is12Hour; - /** Logger */ - private static CLogger log = CLogger.getCLogger(MDocTime.class); - - /** - * Insert String - * @param offset offset - * @param string string - * @param attr attributes - * @throws BadLocationException - */ - public void insertString (int offset, String string, AttributeSet attr) - throws BadLocationException - { - // log.fine( "MDocTime.insertString - Offset=" + offset - // + ", String=" + string + ", Attr=" + attr + ", Text=" + getText() + ", Length=" + getText().length()); - - // manual entry - // DBTextDataBinder.updateText sends stuff at once - if (string != null && string.length() == 1) - { - // ignore if too long - if (offset > 2) - return; - - // is it a digit ? - if (!Character.isDigit(string.charAt(0))) - { - if (log.isLoggable(Level.CONFIG)) log.config("No Digit=" + string); - return; - } - - // resulting string - char[] cc = getText().toCharArray(); - cc[offset] = string.charAt(0); - String result = new String(cc); - - int i = 0; - try - { - i = Integer.parseInt(result.trim()); - } - catch (Exception e) - { - log.log(Level.SEVERE, e.toString()); - } - if (i < 0) - { - if (log.isLoggable(Level.CONFIG)) log.config("Invalid value: " + i); - return; - } - // Minutes - if (!m_isHour && i > 59) - { - if (log.isLoggable(Level.CONFIG)) log.config("Invalid minute value: " + i); - return; - } - // Hour - if (m_isHour && m_is12Hour && i > 12) - { - if (log.isLoggable(Level.CONFIG)) log.config("Invalid 12 hour value: " + i); - return; - } - if (m_isHour && !m_is12Hour && i > 24) - { - if (log.isLoggable(Level.CONFIG)) log.config("Invalid 24 hour value: " + i); - return; - } - // - // super.remove(offset, 1); // replace current position - } - // Set new character - super.insertString(offset, string, attr); - } // insertString - - /** - * Delete String - * @param offset offset - * @param length length - * @throws BadLocationException - */ - public void remove (int offset, int length) - throws BadLocationException - { - // log.fine( "MDocTime.remove - Offset=" + offset + ", Length=" + length); - - super.remove(offset, length); - } // deleteString - - /** - * Get Full Text (always two character) - * @return text - */ - private String getText() - { - StringBuilder sb = new StringBuilder(); - try - { - sb.append(getContent().getString(0, getContent().length()-1)); // cr at end - } - catch (Exception e) - { - } - while (sb.length() < 2) - sb.insert(0, ' '); - return sb.toString(); - } // getString - -} // MDocTime diff --git a/org.adempiere.ui.swing/src/org/compiere/grid/ed/VAccount.java b/org.adempiere.ui.swing/src/org/compiere/grid/ed/VAccount.java deleted file mode 100644 index 23c1725e2f..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/grid/ed/VAccount.java +++ /dev/null @@ -1,507 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ -package org.compiere.grid.ed; - -import java.awt.BorderLayout; -import java.awt.Color; -import java.awt.Component; -import java.awt.Cursor; -import java.awt.Dimension; -import java.awt.Insets; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.awt.event.FocusEvent; -import java.awt.event.FocusListener; -import java.awt.event.MouseAdapter; -import java.awt.event.MouseEvent; -import java.beans.PropertyChangeEvent; -import java.beans.PropertyVetoException; -import java.sql.PreparedStatement; -import java.sql.ResultSet; -import java.util.logging.Level; - -import javax.swing.JComponent; -import javax.swing.JPopupMenu; -import javax.swing.LookAndFeel; -import javax.swing.SwingUtilities; - -import org.adempiere.plaf.AdempierePLAF; -import org.compiere.apps.AEnv; -import org.compiere.apps.FieldRecordInfo; -import org.compiere.model.GridField; -import org.compiere.model.MAccountLookup; -import org.compiere.model.MRole; -import org.compiere.swing.CButton; -import org.compiere.swing.CTextField; -import org.compiere.util.CLogger; -import org.compiere.util.DB; -import org.compiere.util.Env; - -/** - * Account Control - Displays ValidCombination and launches Dialog - * - * @author Jorg Janke - * @version $Id: VAccount.java,v 1.2 2006/07/30 00:51:28 jjanke Exp $ - * - * @author Teo Sarca, SC ARHIPAC SERVICE SRL - *
  • BF [ 1830531 ] Process parameter with type Account not working - */ -public final class VAccount extends JComponent - implements VEditor, ActionListener, FocusListener -{ - /** - * - */ - private static final long serialVersionUID = 8918710495283801426L; - - /****************************************************************************** - * Mouse Listener - */ - final class VAccount_mouseAdapter extends MouseAdapter - { - /** - * Constructor - * @param adaptee adaptee - */ - VAccount_mouseAdapter(VAccount adaptee) - { - m_adaptee = adaptee; - } // VNumber_mouseAdapter - - private VAccount m_adaptee; - - /** - * Mouse Listener - * @param e event - */ - public void mouseClicked(MouseEvent e) - { - // popup menu - if (SwingUtilities.isRightMouseButton(e)) - m_adaptee.popupMenu.show((Component)e.getSource(), e.getX(), e.getY()); - } // mouseClicked - - } - - /** - * Constructor - * @param columnName - * @param mandatory - * @param isReadOnly - * @param isUpdateable - * @param mAccount - * @param title - */ - public VAccount(String columnName, boolean mandatory, boolean isReadOnly, boolean isUpdateable, - MAccountLookup mAccount, String title) - { - super(); - super.setName(columnName); - m_columnName = columnName; - m_mAccount = mAccount; - m_title = title; - // - LookAndFeel.installBorder(this, "TextField.border"); - this.setLayout(new BorderLayout()); - // Size - this.setPreferredSize(m_text.getPreferredSize()); // causes r/o to be the same length - int height = m_text.getPreferredSize().height; - - // *** Button & Text *** - m_text.setBorder(null); - m_text.addActionListener(this); - m_text.addFocusListener(this); - m_text.setFont(AdempierePLAF.getFont_Field()); - m_text.setForeground(AdempierePLAF.getTextColor_Normal()); - m_text.addMouseListener(new VAccount_mouseAdapter(this)); - this.add(m_text, BorderLayout.CENTER); - - m_button.setIcon(Env.getImageIcon("Account10.gif")); - m_button.setMargin(new Insets(0, 0, 0, 0)); - m_button.setPreferredSize(new Dimension(height, height)); - m_button.addActionListener(this); - m_button.setFocusable(false); - this.add(m_button, BorderLayout.EAST); - - // Editable - if (isReadOnly || !isUpdateable) - setReadWrite (false); - else - setReadWrite (true); - setMandatory (mandatory); - } // VAccount - - /** - * Dispose - */ - public void dispose() - { - m_text = null; - m_button = null; - m_mAccount = null; - } // dispose - - private CTextField m_text = new CTextField (VLookup.DISPLAY_LENGTH); - private CButton m_button = new CButton(); - private MAccountLookup m_mAccount; - private Object m_value; - private String m_title; - private int m_WindowNo; - - private String m_columnName; - // Popup - JPopupMenu popupMenu = new JPopupMenu(); - /** Logger */ - private static CLogger log = CLogger.getCLogger(VAccount.class); - - /** - * Enable/disable - * @param value - */ - public void setReadWrite(boolean value) - { - m_button.setReadWrite(value); - m_text.setReadWrite(value); - if (m_button.isVisible() != value) - m_button.setVisible(value); - setBackground(false); - } // setReadWrite - - /** - * IsReadWrite - * @return true if read write - */ - public boolean isReadWrite() - { - return m_button.isReadWrite(); - } // isReadWrite - - /** - * Set Mandatory (and back bolor) - * @param mandatory - */ - public void setMandatory (boolean mandatory) - { - m_button.setMandatory(mandatory); - setBackground(false); - } // setMandatory - - /** - * Is it mandatory - * @return mandatory - */ - public boolean isMandatory() - { - return m_button.isMandatory(); - } // isMandatory - - /** - * Set Background - * @param color - */ - public void setBackground (Color color) - { - // if (!color.equals(m_text.getBackground())) - m_text.setBackground(color); - } // setBackground - - /** - * Set Background based on editable / mandatory / error - * @param error if true, set background to error color, otherwise mandatory/editable - */ - public void setBackground (boolean error) - { - if (error) - setBackground(AdempierePLAF.getFieldBackground_Error()); - else if (!isReadWrite()) - setBackground(AdempierePLAF.getFieldBackground_Inactive()); - else if (isMandatory()) - setBackground(AdempierePLAF.getFieldBackground_Mandatory()); - else - setBackground(AdempierePLAF.getFieldBackground_Normal()); - } // setBackground - - /** - * Set Foreground - * @param fg - */ - public void setForeground(Color fg) - { - m_text.setForeground(fg); - } // setForeground - - /** - * Set Editor to value - * @param value - */ - public void setValue (Object value) - { - m_value = value; - m_text.setText(m_mAccount.getDisplay(value)); // loads value - m_text.setToolTipText(m_mAccount.getDescription()); - } // setValue - - /** - * Request Focus - */ - public void requestFocus () - { - m_text.requestFocus (); - } // requestFocus - - /** - * Request Focus In Window - * @return focus request - */ - @Override - public boolean requestFocusInWindow() - { - return m_text.requestFocusInWindow(); - } // requestFocusInWindow - - /** - * Get Focus Component - * @return component - */ - public Component getFocusableComponent() - { - return m_text; - } // getFocusComponent - - /** - * Property Change Listener - * @param evt - */ - public void propertyChange (PropertyChangeEvent evt) - { - if (evt.getPropertyName().equals(org.compiere.model.GridField.PROPERTY)) - setValue(evt.getNewValue()); - } // propertyChange - - /** - * Return Editor value - * @return value - */ - public Object getValue() - { - return Integer.valueOf(m_mAccount.C_ValidCombination_ID); - } // getValue - - /** - * Return Display Value - * @return String representation - */ - public String getDisplay() - { - return m_text.getText(); - } // getDisplay - - /** - * ActionListener - Button - Start Dialog - * @param e - */ - public void actionPerformed(ActionEvent e) - { - if (e.getActionCommand().equals(FieldRecordInfo.CHANGE_LOG_COMMAND)) - { - FieldRecordInfo.start(m_mField); - return; - } - - if (e.getSource() == m_text) - cmd_text(); - else - cmd_button(); - } // actionPerformed - - /** - * Button - Start Dialog - */ - public void cmd_button() - { - setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); - int C_AcctSchema_ID = Env.getContextAsInt(Env.getCtx(), m_WindowNo, "C_AcctSchema_ID", false); - // Try to get C_AcctSchema_ID from global context - teo_sarca BF [ 1830531 ] - if (C_AcctSchema_ID <= 0) - { - C_AcctSchema_ID = Env.getContextAsInt(Env.getCtx(), "$C_AcctSchema_ID"); - } - VAccountDialog ad = new VAccountDialog (AEnv.getFrame(this), m_title, - m_mAccount, C_AcctSchema_ID); - setCursor(Cursor.getDefaultCursor()); - // - Integer newValue = ad.getValue(); -// if (newValue == null) -// return; - - // set & redisplay - setValue(newValue); - - // Data Binding - try - { - fireVetoableChange(m_columnName, null, newValue); - } - catch (PropertyVetoException pve) - { - } - } // cmd_button - - private boolean m_cmdTextRunning = false; - private GridField m_mField; - /** - * Text - try to find Alias or start Dialog - */ - public void cmd_text() - { - if (m_cmdTextRunning) - return; - m_cmdTextRunning = true; - - String text = m_text.getText(); - if (log.isLoggable(Level.INFO)) log.info("Text=" + text); - if (text == null || text.length() == 0 || text.equals("%")) - { - cmd_button(); - m_cmdTextRunning = false; - return; - } - if (!text.endsWith("%")) - text += "%"; - // - String sql = "SELECT C_ValidCombination_ID FROM C_ValidCombination " - + "WHERE C_AcctSchema_ID=?" - + " AND (UPPER(Alias) LIKE ? OR UPPER(Combination) LIKE ?)"; - sql = MRole.getDefault().addAccessSQL(sql, - "C_ValidCombination", MRole.SQL_NOTQUALIFIED, MRole.SQL_RO); - int C_AcctSchema_ID = Env.getContextAsInt(Env.getCtx(), m_WindowNo, "C_AcctSchema_ID"); - // - int C_ValidCombination_ID = 0; - PreparedStatement pstmt = null; - ResultSet rs = null; - try - { - pstmt = DB.prepareStatement(sql, null); - pstmt.setInt(1, C_AcctSchema_ID); - pstmt.setString(2, text.toUpperCase()); - pstmt.setString(3, text.toUpperCase()); - rs = pstmt.executeQuery(); - if (rs.next()) - { - C_ValidCombination_ID = rs.getInt(1); - if (rs.next()) // only one - C_ValidCombination_ID = 0; - } - } - catch (Exception e) - { - log.log(Level.SEVERE, sql, e); - } - finally - { - DB.close(rs, pstmt); - rs = null; - pstmt = null; - } - // We have a Value - if (C_ValidCombination_ID > 0) - { - Integer newValue = Integer.valueOf(C_ValidCombination_ID); - - // set & redisplay - setValue(newValue); - - // Data Binding - try - { - fireVetoableChange(m_columnName, null, newValue); - } - catch (PropertyVetoException pve) - { - } - } - else - cmd_button(); - - m_cmdTextRunning = false; - } // actionPerformed - - - /** - * Action Listener Interface - * @param listener - */ - public void addActionListener(ActionListener listener) - { - m_text.addActionListener(listener); - } // addActionListener - - /** - * Set Field/WindowNo for ValuePreference (NOP) - * @param mField - */ - public void setField (org.compiere.model.GridField mField) - { - if (mField != null) - m_WindowNo = mField.getWindowNo(); - m_mField = mField; - if (m_mField != null) - FieldRecordInfo.addMenu(this, popupMenu); - - } // setField - - @Override - public GridField getField() { - return m_mField; - } - - /** - * String Representation - * @return info - */ - public String toString() - { - StringBuilder sb = new StringBuilder ("VAccount["); - sb.append (m_value).append ("]"); - return sb.toString (); - } // toString - - public void focusGained(FocusEvent e) - { - } - - public void focusLost(FocusEvent e) - { - if (m_text == null) return; // arhipac: teo_sarca: already disposed - // Test Case: Open a window, click on account field that is mandatory but not filled, close the window and you will get an NPE - // TODO: integrate to trunk - // New text - String newText = m_text.getText(); - if (newText == null) - newText = ""; - // Actual text - String actualText = m_mAccount.getDisplay(m_value); - if (actualText == null) - actualText = ""; - // If text was modified, try to resolve the valid combination - if (!newText.equals(actualText)) - { - cmd_text(); - } - } - -} // VAccount \ No newline at end of file diff --git a/org.adempiere.ui.swing/src/org/compiere/grid/ed/VAccountDialog.java b/org.adempiere.ui.swing/src/org/compiere/grid/ed/VAccountDialog.java deleted file mode 100644 index 15607409f2..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/grid/ed/VAccountDialog.java +++ /dev/null @@ -1,1145 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ -package org.compiere.grid.ed; - -import java.awt.BorderLayout; -import java.awt.Color; -import java.awt.Component; -import java.awt.Cursor; -import java.awt.Dimension; -import java.awt.Font; -import java.awt.Frame; -import java.awt.GridBagConstraints; -import java.awt.GridBagLayout; -import java.awt.Insets; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.awt.event.MouseEvent; -import java.beans.PropertyChangeEvent; -import java.beans.PropertyVetoException; -import java.beans.VetoableChangeListener; -import java.sql.PreparedStatement; -import java.sql.ResultSet; -import java.sql.SQLException; -import java.util.logging.Level; - -import javax.swing.BorderFactory; -import javax.swing.ImageIcon; -import javax.swing.JDialog; -import javax.swing.JLabel; -import javax.swing.JTable; -import javax.swing.JToolBar; -import javax.swing.border.TitledBorder; - -import org.compiere.apps.ADialog; -import org.compiere.apps.AEnv; -import org.compiere.apps.ConfirmPanel; -import org.compiere.apps.StatusBar; -import org.compiere.grid.GridController; -import org.compiere.model.DataStatusEvent; -import org.compiere.model.DataStatusListener; -import org.compiere.model.GridField; -import org.compiere.model.GridTab; -import org.compiere.model.GridWindow; -import org.compiere.model.GridWindowVO; -import org.compiere.model.MAccount; -import org.compiere.model.MAccountLookup; -import org.compiere.model.MAcctSchema; -import org.compiere.model.MAcctSchemaElement; -import org.compiere.model.MQuery; -import static org.compiere.model.SystemIDs.*; -import org.compiere.swing.CButton; -import org.compiere.swing.CDialog; -import org.compiere.swing.CPanel; -import org.compiere.util.CLogger; -import org.compiere.util.DB; -import org.compiere.util.Env; -import org.compiere.util.Msg; - -/** - * Dialog to enter Account Info - * - * @author Jorg Janke - * @version $Id: VAccountDialog.java,v 1.3 2006/07/30 00:51:28 jjanke Exp $ - */ -public final class VAccountDialog extends CDialog - implements ActionListener, DataStatusListener, VetoableChangeListener -{ - /** - * - */ - private static final long serialVersionUID = -1980622319541357651L; - - /** - * Mouse Listener - */ - class VAccountDialog_mouseAdapter extends java.awt.event.MouseAdapter - { - VAccountDialog_mouseAdapter(VAccountDialog adaptee) - { - this.adaptee = adaptee; - } - - VAccountDialog adaptee; - - public void mouseClicked(MouseEvent e) - { - // Table => select - if (e.getSource() instanceof JTable && e.getClickCount() > 1) - { - adaptee.m_changed = true; - adaptee.dispose(); - } - } - } // VAccountDialog_mouseListener - - /** - * Constructor - * @param frame frame - * @param title title - * @param mAccount account info - * @param C_AcctSchema_ID as - */ - public VAccountDialog (Frame frame, String title, - MAccountLookup mAccount, int C_AcctSchema_ID) - { - super (frame, title, true); - if (log.isLoggable(Level.CONFIG)) log.config("C_AcctSchema_ID=" + C_AcctSchema_ID - + ", C_ValidCombination_ID=" + mAccount.C_ValidCombination_ID); - m_mAccount = mAccount; - m_C_AcctSchema_ID = C_AcctSchema_ID; - m_WindowNo = AEnv.createWindowNo (this); - setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE); - try - { - jbInit(); - } - catch(Exception ex) - { - log.log(Level.SEVERE, ex.toString()); - } - if (initAccount()) - AEnv.showCenterWindow(frame, this); - else - dispose(); - } // VLocationDialog - - /** Window No */ - private int m_WindowNo; - /** Journal Entry * - private boolean m_onlyNonDocControlled = false; - /** Selection changed */ - protected boolean m_changed = false; - - /** Accounting Schema */ - private volatile static MAcctSchema s_AcctSchema = null; - /** MWindow for AccountCombination */ - private GridWindow m_mWindow = null; - /** MTab for AccountCombination */ - private GridTab m_mTab = null; - /** GridController */ - private GridController m_gridController = null; - - /** Account used */ - private MAccountLookup m_mAccount = null; - /** Result */ - private int m_C_ValidCombination_ID; - /** Acct Schema */ - private int m_C_AcctSchema_ID = 0; - /** Client */ - private int m_AD_Client_ID; - /** Where clause for combination search */ - private MQuery m_query; - /** Logger */ - private static CLogger log = CLogger.getCLogger(VAccountDialog.class); - - // Editors for Query - private VEditor f_Alias, f_Combination, - f_AD_Org_ID, f_Account_ID, f_SubAcct_ID, - f_M_Product_ID, f_C_BPartner_ID, f_C_Campaign_ID, f_C_LocFrom_ID, f_C_LocTo_ID, - f_C_Project_ID, f_C_SalesRegion_ID, f_AD_OrgTrx_ID, f_C_Activity_ID, - f_User1_ID, f_User2_ID; - // - private JLabel f_Description = new JLabel ("", JLabel.CENTER); - - private GridBagConstraints m_gbc = new GridBagConstraints(); - private Insets m_labelInsets = new Insets(2,15,2,0); // top,left,bottom,right - private Insets m_fieldInsets = new Insets(2,5,2,10); - private int m_line = 0; - private boolean m_newRow = true; - // - private CPanel panel = new CPanel(); - private BorderLayout panelLayout = new BorderLayout(); - private ConfirmPanel confirmPanel = new ConfirmPanel(true); - private TitledBorder titledBorder; - private StatusBar statusBar = new StatusBar(); - private CPanel northPanel = new CPanel(); - private CPanel parameterPanel = new CPanel(); - private GridBagLayout parameterLayout = new GridBagLayout(); - private BorderLayout northLayout = new BorderLayout(); - private JToolBar toolBar = new JToolBar(); - private CButton bRefresh = new CButton(); - private CButton bSave = new CButton(); - private CButton bIgnore = new CButton(); - - /** - * Static component init. - *
    -	 *  - panel
    -	 *      - northPanel
    -	 *          - parameterPanel
    -	 *          - toolBar
    -	 *      - gridController
    -	 *      - confirmPanel
    -	 *  - statusBar
    -	 *  
    - * @throws Exception - */ - void jbInit() throws Exception - { - // [ 1707303 ] Account Combination Form(VAccountDialog) translation issue - titledBorder = new TitledBorder(BorderFactory.createEtchedBorder(Color.white,new Color(134, 134, 134)), Msg.getMsg(Env.getCtx(),"Parameter")); - // - panelLayout.setHgap(5); - panelLayout.setVgap(5); - northLayout.setHgap(5); - northLayout.setVgap(5); - // - parameterPanel.setLayout(parameterLayout); - parameterPanel.setBorder(titledBorder); - northPanel.setLayout(northLayout); - toolBar.setOrientation(JToolBar.VERTICAL); - toolBar.setBorder(null); - toolBar.setRequestFocusEnabled(false); - toolBar.setBorderPainted(false); - toolBar.setMargin(new Insets(5, 5, 5, 5)); - bSave.setIcon(new ImageIcon(org.compiere.Adempiere.getResource("images/Save24.gif"))); - bSave.setMargin(new Insets(2, 2, 2, 2)); - bSave.setToolTipText(Msg.getMsg(Env.getCtx(),"AccountNewUpdate")); - bSave.addActionListener(this); - bRefresh.setIcon(new ImageIcon(org.compiere.Adempiere.getResource("images/Refresh24.gif"))); - bRefresh.setMargin(new Insets(2, 2, 2, 2)); - bRefresh.setToolTipText(Msg.getMsg(Env.getCtx(),"Refresh")); - bRefresh.addActionListener(this); - bIgnore.setIcon(new ImageIcon(org.compiere.Adempiere.getResource("images/Ignore24.gif"))); - bIgnore.setMargin(new Insets(2, 2, 2, 2)); - bIgnore.setToolTipText(Msg.getMsg(Env.getCtx(),"Ignore")); - bIgnore.addActionListener(this); - // - toolBar.addSeparator(); - toolBar.add(bRefresh, null); - toolBar.add(bIgnore, null); - toolBar.add(bSave, null); - // - getContentPane().add(panel); - panel.setLayout(panelLayout); - panel.add(confirmPanel, BorderLayout.SOUTH); - panel.add(northPanel, BorderLayout.NORTH); - northPanel.add(parameterPanel, BorderLayout.CENTER); - northPanel.add(toolBar, BorderLayout.EAST); - // - this.getContentPane().add(statusBar, BorderLayout.SOUTH); - confirmPanel.addActionListener(this); - } // jbInit - - /** - * Dyanmic Init. - * When a row is selected, the editor values are set - * (editors do not change grid) - * @return true if initialized - */ - private boolean initAccount() - { - m_AD_Client_ID = Env.getContextAsInt(Env.getCtx(), m_WindowNo, "AD_Client_ID"); - // Get AcctSchema Info - if (s_AcctSchema == null || s_AcctSchema.getC_AcctSchema_ID() != m_C_AcctSchema_ID) - s_AcctSchema = new MAcctSchema (Env.getCtx(), m_C_AcctSchema_ID, null); - if (log.isLoggable(Level.CONFIG)) log.config(s_AcctSchema.toString() - + ", #" + s_AcctSchema.getAcctSchemaElements().length); - Env.setContext(Env.getCtx(), m_WindowNo, "C_AcctSchema_ID", m_C_AcctSchema_ID); - - // Model - int AD_Window_ID = WINDOW_ACCOUNTCOMBINATION; // Maintain Account Combinations - GridWindowVO wVO = Env.getMWindowVO (m_WindowNo, AD_Window_ID, 0); - if (wVO == null) - return false; - m_mWindow = new GridWindow (wVO); - m_mTab = m_mWindow.getTab(0); - // Make sure is the tab is loaded - teo_sarca [ 1659124 ] - if (!m_mTab.isLoadComplete()) - m_mWindow.initTab(0); - - // ParameterPanel restrictions - m_mTab.getField("Alias").setDisplayLength(15); - m_mTab.getField("Combination").setDisplayLength(15); - // Grid restrictions - m_mTab.getField("AD_Client_ID").setDisplayed(false); - m_mTab.getField("C_AcctSchema_ID").setDisplayed(false); - m_mTab.getField("IsActive").setDisplayed(false); - m_mTab.getField("IsFullyQualified").setDisplayed(false); - // don't show fields not being displayed in this environment - for (int i = 0; i < m_mTab.getFieldCount(); i++) - { - GridField field = m_mTab.getField(i); - if (!field.isDisplayed (true)) // check context - field.setDisplayed (false); - } - - // GridController - m_gridController = new GridController(); - m_gridController.initGrid(m_mTab, true, m_WindowNo, null, null); - m_gridController.setPreferredSize(new Dimension(300,100)); - panel.add(m_gridController, BorderLayout.CENTER); - - // Prepare Parameter - m_gbc.anchor = GridBagConstraints.NORTHWEST; - m_gbc.gridy = 0; // line - m_gbc.gridx = 0; - m_gbc.gridwidth = 1; - m_gbc.insets = m_fieldInsets; - m_gbc.fill = GridBagConstraints.HORIZONTAL; - m_gbc.weightx = 0; - m_gbc.weighty = 0; - - // Alias - if (s_AcctSchema.isHasAlias()) - { - GridField alias = m_mTab.getField("Alias"); - f_Alias = VEditorFactory.getEditor(m_mTab, alias, false); - addLine(alias, f_Alias, false); - } // Alias - - // Combination - GridField combination = m_mTab.getField("Combination"); - f_Combination = VEditorFactory.getEditor(m_mTab, combination, false); - addLine(combination, f_Combination, false); - m_newRow = true; - - /** - * Create Fields in Element Order - */ - MAcctSchemaElement[] elements = s_AcctSchema.getAcctSchemaElements(); - for (int i = 0; i < elements.length; i++) - { - MAcctSchemaElement ase = elements[i]; - String type = ase.getElementType(); - boolean isMandatory = ase.isMandatory(); - // - if (type.equals(MAcctSchemaElement.ELEMENTTYPE_Organization)) - { - GridField field = m_mTab.getField("AD_Org_ID"); - f_AD_Org_ID = VEditorFactory.getEditor(m_mTab, field, false); - addLine(field, f_AD_Org_ID, isMandatory); - } - else if (type.equals(MAcctSchemaElement.ELEMENTTYPE_Account)) - { - GridField field = m_mTab.getField("Account_ID"); - f_Account_ID = VEditorFactory.getEditor(m_mTab, field, false); - // ((VLookup)f_Account_ID).setWidth(400); - addLine(field, f_Account_ID, isMandatory); - f_Account_ID.addVetoableChangeListener(this); - } - else if (type.equals(MAcctSchemaElement.ELEMENTTYPE_SubAccount)) - { - GridField field = m_mTab.getField("C_SubAcct_ID"); - f_SubAcct_ID = VEditorFactory.getEditor(m_mTab, field, false); - // ((VLookup)f_SubAcct_ID).setWidth(400); - addLine(field, f_SubAcct_ID, isMandatory); - } - else if (type.equals(MAcctSchemaElement.ELEMENTTYPE_Product)) - { - GridField field = m_mTab.getField("M_Product_ID"); - f_M_Product_ID = VEditorFactory.getEditor(m_mTab, field, false); - addLine(field, f_M_Product_ID, isMandatory); - } - else if (type.equals(MAcctSchemaElement.ELEMENTTYPE_BPartner)) - { - GridField field = m_mTab.getField("C_BPartner_ID"); - f_C_BPartner_ID = VEditorFactory.getEditor(m_mTab, field, false); - addLine(field, f_C_BPartner_ID, isMandatory); - } - else if (type.equals(MAcctSchemaElement.ELEMENTTYPE_Campaign)) - { - GridField field = m_mTab.getField("C_Campaign_ID"); - f_C_Campaign_ID = VEditorFactory.getEditor(m_mTab, field, false); - addLine(field, f_C_Campaign_ID, isMandatory); - } - else if (type.equals(MAcctSchemaElement.ELEMENTTYPE_LocationFrom)) - { - GridField field = m_mTab.getField("C_LocFrom_ID"); - f_C_LocFrom_ID = VEditorFactory.getEditor(m_mTab, field, false); - addLine(field, f_C_LocFrom_ID, isMandatory); - } - else if (type.equals(MAcctSchemaElement.ELEMENTTYPE_LocationTo)) - { - GridField field = m_mTab.getField("C_LocTo_ID"); - f_C_LocTo_ID = VEditorFactory.getEditor(m_mTab, field, false); - addLine(field, f_C_LocTo_ID, isMandatory); - } - else if (type.equals(MAcctSchemaElement.ELEMENTTYPE_Project)) - { - GridField field = m_mTab.getField("C_Project_ID"); - f_C_Project_ID = VEditorFactory.getEditor(m_mTab, field, false); - addLine(field, f_C_Project_ID, isMandatory); - } - else if (type.equals(MAcctSchemaElement.ELEMENTTYPE_SalesRegion)) - { - GridField field = m_mTab.getField("C_SalesRegion_ID"); - f_C_SalesRegion_ID = VEditorFactory.getEditor(m_mTab, field, false); - addLine(field, f_C_SalesRegion_ID, isMandatory); - } - else if (type.equals(MAcctSchemaElement.ELEMENTTYPE_OrgTrx)) - { - GridField field = m_mTab.getField("AD_OrgTrx_ID"); - f_AD_OrgTrx_ID = VEditorFactory.getEditor(m_mTab, field, false); - addLine(field, f_AD_OrgTrx_ID, isMandatory); - } - else if (type.equals(MAcctSchemaElement.ELEMENTTYPE_Activity)) - { - GridField field = m_mTab.getField("C_Activity_ID"); - f_C_Activity_ID = VEditorFactory.getEditor(m_mTab, field, false); - addLine(field, f_C_Activity_ID, isMandatory); - } - // User1 - else if (type.equals(MAcctSchemaElement.ELEMENTTYPE_UserElementList1)) - { - GridField field = m_mTab.getField("User1_ID"); - f_User1_ID = VEditorFactory.getEditor(m_mTab, field, false); - addLine(field, f_User1_ID, isMandatory); - } - else if (type.equals(MAcctSchemaElement.ELEMENTTYPE_UserElementList2)) - { - GridField field = m_mTab.getField("User2_ID"); - f_User2_ID = VEditorFactory.getEditor(m_mTab, field, false); - addLine(field, f_User2_ID, isMandatory); - } - } // Create Fields in Element Order - - // Add description - m_newRow = true; - m_gbc.gridy = m_line++; - m_gbc.gridx = 0; - m_gbc.gridwidth = 4; - m_gbc.insets = new Insets(5,15,2,0); // top,left,bottom,right - m_gbc.fill = GridBagConstraints.HORIZONTAL; - f_Description.setFont(f_Description.getFont().deriveFont(Font.ITALIC)); - parameterPanel.add(f_Description, m_gbc); - - // Finish - m_query = new MQuery(); - m_query.addRestriction("C_AcctSchema_ID", MQuery.EQUAL, m_C_AcctSchema_ID); - m_query.addRestriction("IsFullyQualified", MQuery.EQUAL, "Y"); - if (m_mAccount.C_ValidCombination_ID == 0) - m_mTab.setQuery(MQuery.getEqualQuery("1", "2")); - else - { - MQuery query = new MQuery(); - query.addRestriction("C_AcctSchema_ID", MQuery.EQUAL, m_C_AcctSchema_ID); - query.addRestriction("C_ValidCombination_ID", MQuery.EQUAL, m_mAccount.C_ValidCombination_ID); - m_mTab.setQuery(query); - } - m_mTab.query(false); - m_gridController.getTable().addMouseListener(new VAccountDialog_mouseAdapter(this)); - m_gridController.addDataStatusListener(this); - - statusBar.setStatusLine(s_AcctSchema.toString()); - statusBar.setStatusDB("?"); - - // Initial value - if (m_mAccount.C_ValidCombination_ID != 0) - m_mTab.navigate(0); - - log.config("fini"); - return true; - } // initAccount - - /** - * Add Editor to parameterPanel alernative right/left depending on m_newRow. - * Field Value changes update Editors - * @param field field - * @param editor editor - * @param mandatory mandatory - */ - private void addLine (GridField field, VEditor editor, boolean mandatory) - { - if (log.isLoggable(Level.FINE)) log.fine("Field=" + field); - JLabel label = VEditorFactory.getLabel(field); - label.setLabelFor((Component)editor); - editor.setReadWrite(true); - editor.setMandatory(mandatory); - // MField => VEditor - field.addPropertyChangeListener(editor); - - // label - if (m_newRow) - { - m_gbc.gridy = m_line++; - m_gbc.gridx = 0; - } - else - m_gbc.gridx = 2; - m_gbc.insets = m_labelInsets; - m_gbc.fill = GridBagConstraints.HORIZONTAL; - m_gbc.weightx = 0; - parameterPanel.add(label, m_gbc); - - // Field - if (m_newRow) - m_gbc.gridx = 1; - else - m_gbc.gridx = 3; - m_gbc.insets = m_fieldInsets; - m_gbc.fill = GridBagConstraints.HORIZONTAL; - m_gbc.weightx = 1; - parameterPanel.add((Component)editor, m_gbc); - // - m_newRow = !m_newRow; - } // addLine - - /** - * Load Information - * @param C_ValidCombination_ID valid combination - * @param C_AcctSchema_ID acct schema - */ - private void loadInfo (int C_ValidCombination_ID, int C_AcctSchema_ID) - { - if (log.isLoggable(Level.FINE)) log.fine("C_ValidCombination_ID=" + C_ValidCombination_ID); - String sql = "SELECT * FROM C_ValidCombination WHERE C_ValidCombination_ID=? AND C_AcctSchema_ID=?"; - PreparedStatement pstmt = null; - ResultSet rs = null; - try - { - pstmt = DB.prepareStatement(sql, null); - pstmt.setInt(1, C_ValidCombination_ID); - pstmt.setInt(2, C_AcctSchema_ID); - rs = pstmt.executeQuery(); - if (rs.next()) - { - if (f_Alias != null) - f_Alias.setValue(rs.getString("Alias")); - f_Combination.setValue(rs.getString("Combination")); - // - loadInfoOf (rs, f_AD_Org_ID, "AD_Org_ID"); - loadInfoOf (rs, f_Account_ID, "Account_ID"); - loadInfoOf (rs, f_SubAcct_ID, "C_SubAcct_ID"); - // - loadInfoOf (rs, f_M_Product_ID, "M_Product_ID"); - loadInfoOf (rs, f_C_BPartner_ID, "C_BPartner_ID"); - loadInfoOf (rs, f_C_Campaign_ID, "C_Campaign_ID"); - loadInfoOf (rs, f_C_LocFrom_ID, "C_LocFrom_ID"); - loadInfoOf (rs, f_C_LocTo_ID, "C_LocTo_ID"); - loadInfoOf (rs, f_C_Project_ID, "C_Project_ID"); - loadInfoOf (rs, f_C_SalesRegion_ID, "C_SalesRegion_ID"); - loadInfoOf (rs, f_AD_OrgTrx_ID, "AD_OrgTrx_ID"); - loadInfoOf (rs, f_C_Activity_ID, "C_Activity_ID"); - loadInfoOf (rs, f_User1_ID, "User1_ID"); - loadInfoOf (rs, f_User2_ID, "User2_ID"); - // - f_Description.setText (rs.getString("Description")); - } - } - catch (SQLException e) - { - log.log(Level.SEVERE, sql, e); - } - finally - { - DB.close(rs, pstmt); - rs = null; - pstmt = null; - } - } // loadInfo - - /** - * Set Value of Editor - * @param rs result set - * @param editor editor - * @param name name - * @throws SQLException - */ - private void loadInfoOf (ResultSet rs, VEditor editor, String name) throws SQLException - { - if (editor == null) - return; - int intValue = rs.getInt(name); - if (rs.wasNull()) - editor.setValue(null); - else - editor.setValue(Integer.valueOf(intValue)); - } // loadInfoOf - - - /** - * dispose - */ - public void dispose() - { - saveSelection(); - // GridController - if (m_gridController != null) - m_gridController.dispose(); - m_gridController = null; - // Model - m_mTab = null; - if (m_mWindow != null) - m_mWindow.dispose(); - m_mWindow = null; - - removeAll(); - Env.clearWinContext(m_WindowNo); - super.dispose(); - } // dispose - - /** - * Save Selection - */ - private void saveSelection() - { - if (m_changed && m_gridController != null) - { - int row = m_gridController.getTable().getSelectedRow(); - if (row >= 0) - m_C_ValidCombination_ID = ((Integer)m_mTab.getValue(row, "C_ValidCombination_ID")).intValue(); - if (log.isLoggable(Level.CONFIG)) log.config("(" + row + ") - " + m_C_ValidCombination_ID); - } - } // saveSelection - - /** - * ActionListener - * @param e event - */ - public void actionPerformed(ActionEvent e) - { - if (e.getActionCommand().equals(ConfirmPanel.A_OK)) - { - m_changed = true; - dispose(); - } - else if (e.getActionCommand().equals(ConfirmPanel.A_CANCEL)) - { - m_changed = false; - dispose(); - } - // - else if (e.getSource() == bSave) - action_Save(); - else if (e.getSource() == bIgnore) - action_Ignore(); - // all other - else - action_Find (true); - - } // actionPerformed - - - /** - * Status Change Listener - * @param e event - */ - public void dataStatusChanged (DataStatusEvent e) - { - if (log.isLoggable(Level.CONFIG)) log.config(e.toString()); - String info = (String)m_mTab.getValue("Description"); - f_Description.setText (info); - // - // log.info( ">> Field=" + m_mTab.getValue("AD_Org_ID"), - // "Editor=" + f_AD_Org_ID.getValue()); - // if (f_AD_Org_ID.getValue() == null) - // f_AD_Org_ID.setValue(m_mTab.getValue("AD_Org_ID")); - } // statusChanged - - - /** - * Action Find. - * - create where clause - * - query database - * @param includeAliasCombination include alias combination - */ - private void action_Find (boolean includeAliasCombination) - { - log.info(""); - setCursor (Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); - - // Create where Clause - MQuery query = null; - if (m_query != null) - query = m_query.deepCopy(); - else - query = new MQuery(); - // Alias - if (includeAliasCombination && f_Alias != null && f_Alias.getValue().toString().length() > 0) - { - String value = f_Alias.getValue().toString().toUpperCase(); - if (!value.endsWith("%")) - value += "%"; - query.addRestriction("UPPER(Alias)", MQuery.LIKE, value); - } - // Combination (mandatory) - if (includeAliasCombination && f_Combination.getValue().toString().length() > 0) - { - String value = f_Combination.getValue().toString().toUpperCase(); - if (!value.endsWith("%")) - value += "%"; - query.addRestriction("UPPER(Combination)", MQuery.LIKE, value); - } - // Org (mandatory) - if (f_AD_Org_ID != null && f_AD_Org_ID.getValue() != null) - query.addRestriction("AD_Org_ID", MQuery.EQUAL, f_AD_Org_ID.getValue()); - // Account (mandatory) - if (f_Account_ID != null && f_Account_ID.getValue() != null) - query.addRestriction("Account_ID", MQuery.EQUAL, f_Account_ID.getValue()); - if (f_SubAcct_ID != null && f_SubAcct_ID.getValue() != null) - query.addRestriction("C_SubAcct_ID", MQuery.EQUAL, f_SubAcct_ID.getValue()); - - // Product - if (f_M_Product_ID != null && f_M_Product_ID.getValue() != null) - query.addRestriction("M_Product_ID", MQuery.EQUAL, f_M_Product_ID.getValue()); - // BPartner - if (f_C_BPartner_ID != null && f_C_BPartner_ID.getValue() != null) - query.addRestriction("C_BPartner_ID", MQuery.EQUAL, f_C_BPartner_ID.getValue()); - // Campaign - if (f_C_Campaign_ID != null && f_C_Campaign_ID.getValue() != null) - query.addRestriction("C_Campaign_ID", MQuery.EQUAL, f_C_Campaign_ID.getValue()); - // Loc From - if (f_C_LocFrom_ID != null && f_C_LocFrom_ID.getValue() != null) - query.addRestriction("C_LocFrom_ID", MQuery.EQUAL, f_C_LocFrom_ID.getValue()); - // Loc To - if (f_C_LocTo_ID != null && f_C_LocTo_ID.getValue() != null) - query.addRestriction("C_LocTo_ID", MQuery.EQUAL, f_C_LocTo_ID.getValue()); - // Project - if (f_C_Project_ID != null && f_C_Project_ID.getValue() != null) - query.addRestriction("C_Project_ID", MQuery.EQUAL, f_C_Project_ID.getValue()); - // SRegion - if (f_C_SalesRegion_ID != null && f_C_SalesRegion_ID.getValue() != null) - query.addRestriction("C_SalesRegion_ID", MQuery.EQUAL, f_C_SalesRegion_ID.getValue()); - // Org Trx - if (f_AD_OrgTrx_ID != null && f_AD_OrgTrx_ID.getValue() != null) - query.addRestriction("AD_OrgTrx_ID", MQuery.EQUAL, f_AD_OrgTrx_ID.getValue()); - // Activity - if (f_C_Activity_ID != null && f_C_Activity_ID.getValue() != null) - query.addRestriction("C_Activity_ID", MQuery.EQUAL, f_C_Activity_ID.getValue()); - // User 1 - if (f_User1_ID != null && f_User1_ID.getValue() != null) - query.addRestriction("User1_ID", MQuery.EQUAL, f_User1_ID.getValue()); - // User 2 - if (f_User2_ID != null && f_User2_ID.getValue() != null) - query.addRestriction("User2_ID", MQuery.EQUAL, f_User2_ID.getValue()); - - // Query - m_mTab.setQuery(query); - m_mTab.query(false); - statusBar.setStatusDB(String.valueOf(m_mTab.getRowCount())); - setCursor (Cursor.getDefaultCursor()); - } // action_Find - - - /** - * Create/Save Account - */ - private void action_Save() - { - log.info(""); - /** - * Check completeness (mandatory fields) ... and for duplicates - */ - StringBuilder sb = new StringBuilder(); - StringBuilder sql = new StringBuilder ("SELECT C_ValidCombination_ID, Alias FROM C_ValidCombination WHERE "); - Object value = null; - if (s_AcctSchema.isHasAlias()) - { - value = f_Alias.getValue().toString(); - if (value == null) - sb.append(Msg.translate(Env.getCtx(), "Alias")).append(", "); - } - MAcctSchemaElement[] elements = s_AcctSchema.getAcctSchemaElements(); - for (int i = 0; i < elements.length; i++) - { - MAcctSchemaElement ase = elements[i]; - String type = ase.getElementType(); - // - if (type.equals(MAcctSchemaElement.ELEMENTTYPE_Organization)) - { - value = f_AD_Org_ID.getValue(); - sql.append("AD_Org_ID"); - if (value == null) - sql.append(" IS NULL AND "); - else - sql.append("=").append(value).append(" AND "); - } - else if (type.equals(MAcctSchemaElement.ELEMENTTYPE_Account)) - { - value = f_Account_ID.getValue(); - sql.append("Account_ID"); - if (value == null) - sql.append(" IS NULL AND "); - else - sql.append("=").append(value).append(" AND "); - } - else if (type.equals(MAcctSchemaElement.ELEMENTTYPE_SubAccount)) - { - value = f_SubAcct_ID.getValue(); - sql.append("C_SubAcct_ID"); - if (value == null) - sql.append(" IS NULL AND "); - else - sql.append("=").append(value).append(" AND "); - } - else if (type.equals(MAcctSchemaElement.ELEMENTTYPE_Product)) - { - value = f_M_Product_ID.getValue(); - sql.append("M_Product_ID"); - if (value == null) - sql.append(" IS NULL AND "); - else - sql.append("=").append(value).append(" AND "); - } - else if (type.equals(MAcctSchemaElement.ELEMENTTYPE_BPartner)) - { - value = f_C_BPartner_ID.getValue(); - sql.append("C_BPartner_ID"); - if (value == null) - sql.append(" IS NULL AND "); - else - sql.append("=").append(value).append(" AND "); - } - else if (type.equals(MAcctSchemaElement.ELEMENTTYPE_Campaign)) - { - value = f_C_Campaign_ID.getValue(); - sql.append("C_Campaign_ID"); - if (value == null) - sql.append(" IS NULL AND "); - else - sql.append("=").append(value).append(" AND "); - } - else if (type.equals(MAcctSchemaElement.ELEMENTTYPE_LocationFrom)) - { - value = f_C_LocFrom_ID.getValue(); - sql.append("C_LocFrom_ID"); - if (value == null) - sql.append(" IS NULL AND "); - else - sql.append("=").append(value).append(" AND "); - } - else if (type.equals(MAcctSchemaElement.ELEMENTTYPE_LocationTo)) - { - value = f_C_LocTo_ID.getValue(); - sql.append("C_LocTo_ID"); - if (value == null) - sql.append(" IS NULL AND "); - else - sql.append("=").append(value).append(" AND "); - } - else if (type.equals(MAcctSchemaElement.ELEMENTTYPE_Project)) - { - value = f_C_Project_ID.getValue(); - sql.append("C_Project_ID"); - if (value == null) - sql.append(" IS NULL AND "); - else - sql.append("=").append(value).append(" AND "); - } - else if (type.equals(MAcctSchemaElement.ELEMENTTYPE_SalesRegion)) - { - value = f_C_SalesRegion_ID.getValue(); - sql.append("C_SalesRegion_ID"); - if (value == null) - sql.append(" IS NULL AND "); - else - sql.append("=").append(value).append(" AND "); - } - else if (type.equals(MAcctSchemaElement.ELEMENTTYPE_OrgTrx)) - { - value = f_AD_OrgTrx_ID.getValue(); - sql.append("AD_OrgTrx_ID"); - if (value == null) - sql.append(" IS NULL AND "); - else - sql.append("=").append(value).append(" AND "); - } - else if (type.equals(MAcctSchemaElement.ELEMENTTYPE_Activity)) - { - value = f_C_Activity_ID.getValue(); - sql.append("C_Activity_ID"); - if (value == null) - sql.append(" IS NULL AND "); - else - sql.append("=").append(value).append(" AND "); - } - else if (type.equals(MAcctSchemaElement.ELEMENTTYPE_UserElementList1)) - { - value = f_User1_ID.getValue(); - sql.append("User1_ID"); - if (value == null) - sql.append(" IS NULL AND "); - else - sql.append("=").append(value).append(" AND "); - } - else if (type.equals(MAcctSchemaElement.ELEMENTTYPE_UserElementList2)) - { - value = f_User2_ID.getValue(); - sql.append("User2_ID"); - if (value == null) - sql.append(" IS NULL AND "); - else - sql.append("=").append(value).append(" AND "); - } - // - if (ase.isMandatory() && value == null) - sb.append(ase.getName()).append(", "); - } // Fields in Element Order - - if (sb.length() != 0) - { - ADialog.error(m_WindowNo, this, "FillMandatory", sb.substring(0, sb.length()-2)); - return; - } - if (f_AD_Org_ID == null || f_AD_Org_ID.getValue() == null) - { - ADialog.error(m_WindowNo, this, "FillMandatory", Msg.getElement(Env.getCtx(), "AD_Org_ID")); - return; - } - if (f_Account_ID == null || f_Account_ID.getValue() == null) - { - ADialog.error(m_WindowNo, this, "FillMandatory", Msg.getElement(Env.getCtx(), "Account_ID")); - return; - } - - - /** - * Check if already exists - */ - sql.append("AD_Client_ID=? AND C_AcctSchema_ID=?"); - if (log.isLoggable(Level.FINE)) log.fine("Check = " + sql.toString()); - int IDvalue = 0; - String Alias = null; - PreparedStatement pstmt = null; - ResultSet rs = null; - try - { - pstmt = DB.prepareStatement(sql.toString(), null); - pstmt.setInt(1, m_AD_Client_ID); - pstmt.setInt(2, s_AcctSchema.getC_AcctSchema_ID()); - rs = pstmt.executeQuery(); - if (rs.next()) - { - IDvalue = rs.getInt(1); - Alias = rs.getString(2); - } - } - catch (SQLException e) - { - log.log(Level.SEVERE, sql.toString(), e); - IDvalue = 0; - } - finally - { - DB.close(rs, pstmt); - rs = null; - pstmt = null; - } - - if (log.isLoggable(Level.FINE)) log.fine("ID=" + IDvalue + ", Alias=" + Alias); - - if (Alias == null) - Alias = ""; - - // We have an account like this already - check alias - if (IDvalue != 0 && s_AcctSchema.isHasAlias() - && !f_Alias.getValue().toString().equals(Alias)) - { - sql = new StringBuilder("UPDATE C_ValidCombination SET Alias="); - if (f_Alias.getValue().toString().length() == 0) - sql.append("NULL"); - else - sql.append("'").append(f_Alias.getValue()).append("'"); - sql.append(" WHERE C_ValidCombination_ID=").append(IDvalue); - int i = 0; - PreparedStatement stmt = null; - try - { - stmt = DB.prepareStatement(sql.toString(), - ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_UPDATABLE, null); - i = stmt.executeUpdate(); - } - catch (SQLException e) - { - log.log(Level.SEVERE, sql.toString(), e); - } - finally - { - DB.close(stmt); - stmt = null; - } - if (i == 0) - ADialog.error(m_WindowNo, this, "AccountNotUpdated"); - } - - // load and display - if (IDvalue != 0) - { - loadInfo (IDvalue, s_AcctSchema.getC_AcctSchema_ID()); - action_Find (false); - return; - } - - log.config("New"); - Alias = null; - if (f_Alias != null) - Alias = f_Alias.getValue().toString(); - int C_SubAcct_ID = 0; - if (f_SubAcct_ID != null && f_SubAcct_ID.getValue() != null) - C_SubAcct_ID = ((Integer)f_SubAcct_ID.getValue()).intValue(); - int M_Product_ID = 0; - if (f_M_Product_ID != null && f_M_Product_ID.getValue() != null) - M_Product_ID = ((Integer)f_M_Product_ID.getValue()).intValue(); - int C_BPartner_ID = 0; - if (f_C_BPartner_ID != null && f_C_BPartner_ID.getValue() != null) - C_BPartner_ID = ((Integer)f_C_BPartner_ID.getValue()).intValue(); - int AD_OrgTrx_ID = 0; - if (f_AD_OrgTrx_ID != null && f_AD_OrgTrx_ID.getValue() != null) - AD_OrgTrx_ID = ((Integer)f_AD_OrgTrx_ID.getValue()).intValue(); - int C_LocFrom_ID = 0; - if (f_C_LocFrom_ID != null && f_C_LocFrom_ID.getValue() != null) - C_LocFrom_ID = ((Integer)f_C_LocFrom_ID.getValue()).intValue(); - int C_LocTo_ID = 0; - if (f_C_LocTo_ID != null && f_C_LocTo_ID.getValue() != null) - C_LocTo_ID = ((Integer)f_C_LocTo_ID.getValue()).intValue(); - int C_SRegion_ID = 0; - if (f_C_SalesRegion_ID != null && f_C_SalesRegion_ID.getValue() != null) - C_SRegion_ID = ((Integer)f_C_SalesRegion_ID.getValue()).intValue(); - int C_Project_ID = 0; - if (f_C_Project_ID != null && f_C_Project_ID.getValue() != null) - C_Project_ID= ((Integer)f_C_Project_ID.getValue()).intValue(); - int C_Campaign_ID = 0; - if (f_C_Campaign_ID != null && f_C_Campaign_ID.getValue() != null) - C_Campaign_ID = ((Integer)f_C_Campaign_ID.getValue()).intValue(); - int C_Activity_ID = 0; - if (f_C_Activity_ID != null && f_C_Activity_ID.getValue() != null) - C_Activity_ID = ((Integer)f_C_Activity_ID.getValue()).intValue(); - int User1_ID = 0; - if (f_User1_ID != null && f_User1_ID.getValue() != null) - User1_ID = ((Integer)f_User1_ID.getValue()).intValue(); - int User2_ID = 0; - if (f_User2_ID != null && f_User2_ID.getValue() != null) - User2_ID = ((Integer)f_User2_ID.getValue()).intValue(); - - MAccount acct = MAccount.get (Env.getCtx(), m_AD_Client_ID, - ((Integer)f_AD_Org_ID.getValue()).intValue(), - s_AcctSchema.getC_AcctSchema_ID(), - ((Integer)f_Account_ID.getValue()).intValue(), C_SubAcct_ID, - M_Product_ID, C_BPartner_ID, AD_OrgTrx_ID, - C_LocFrom_ID, C_LocTo_ID, C_SRegion_ID, - C_Project_ID, C_Campaign_ID, C_Activity_ID, - User1_ID, User2_ID, 0, 0, null); - if (acct != null && acct.get_ID() == 0) - acct.saveEx(); - - // Show Info - if (acct == null || acct.get_ID() == 0) - loadInfo (0, 0); - else - { - // Update Account with optional Alias - if (Alias != null && Alias.length() > 0) - { - acct.setAlias(Alias); - acct.saveEx(); - } - loadInfo (acct.get_ID(), s_AcctSchema.getC_AcctSchema_ID()); - } - action_Find (false); - } // action_Save - - - /** - * Ignore - */ - private void action_Ignore() - { - if (f_Alias != null) - f_Alias.setValue(""); - f_Combination.setValue(""); - f_Description.setText(""); - // - // Org (mandatory) - f_AD_Org_ID.setValue(null); - // Account (mandatory) - f_Account_ID.setValue(null); - if (f_SubAcct_ID != null) - f_SubAcct_ID.setValue(null); - - // Product - if (f_M_Product_ID != null) - f_M_Product_ID.setValue(null); - // BPartner - if (f_C_BPartner_ID != null) - f_C_BPartner_ID.setValue(null); - // Campaign - if (f_C_Campaign_ID != null) - f_C_Campaign_ID.setValue(null); - // Loc From - if (f_C_LocFrom_ID != null) - f_C_LocFrom_ID.setValue(null); - // Loc To - if (f_C_LocTo_ID != null) - f_C_LocTo_ID.setValue(null); - // Project - if (f_C_Project_ID != null) - f_C_Project_ID.setValue(null); - // SRegion - if (f_C_SalesRegion_ID != null) - f_C_SalesRegion_ID.setValue(null); - // Org Trx - if (f_AD_OrgTrx_ID != null) - f_AD_OrgTrx_ID.setValue(null); - // Activity - if (f_C_Activity_ID != null) - f_C_Activity_ID.setValue(null); - // User 1 - if (f_User1_ID != null) - f_User1_ID.setValue(null); - // User 2 - if (f_User2_ID != null) - f_User2_ID.setValue(null); - } // action_Ignore - - /** - * Get selected account - * @return account - */ - public Integer getValue() - { - if (log.isLoggable(Level.CONFIG)) log.config("C_ValidCombination_ID=" + m_C_ValidCombination_ID + ", Changed=" + m_changed); - if (!m_changed || m_C_ValidCombination_ID == 0) - return null; - return Integer.valueOf(m_C_ValidCombination_ID); - } - - /** - * VetoableChange - Account Changed - * @param evt event - * @throws PropertyVetoException - */ - public void vetoableChange (PropertyChangeEvent evt) - throws PropertyVetoException - { - Object newValue = evt.getNewValue(); - if (newValue instanceof Integer) - Env.setContext(Env.getCtx(), m_WindowNo, "Account_ID", ((Integer)newValue).intValue()); - } // vetoableChange - -} // VAccountDialog diff --git a/org.adempiere.ui.swing/src/org/compiere/grid/ed/VAssignment.java b/org.adempiere.ui.swing/src/org/compiere/grid/ed/VAssignment.java deleted file mode 100644 index f5479221c1..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/grid/ed/VAssignment.java +++ /dev/null @@ -1,462 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ -package org.compiere.grid.ed; - -import java.awt.BorderLayout; -import java.awt.Color; -import java.awt.Component; -import java.awt.Dimension; -import java.awt.Insets; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.awt.event.MouseAdapter; -import java.awt.event.MouseEvent; -import java.beans.PropertyChangeEvent; -import java.beans.PropertyVetoException; -import java.sql.PreparedStatement; -import java.sql.ResultSet; -import java.text.DateFormat; -import java.text.NumberFormat; -import java.util.logging.Level; - -import javax.swing.JComponent; -import javax.swing.JPopupMenu; -import javax.swing.JTextField; -import javax.swing.LookAndFeel; -import javax.swing.SwingUtilities; - -import org.adempiere.plaf.AdempierePLAF; -import org.compiere.apps.AEnv; -import org.compiere.apps.FieldRecordInfo; -import org.compiere.apps.search.InfoSchedule; -import org.compiere.model.GridField; -import org.compiere.model.MResourceAssignment; -import org.compiere.swing.CButton; -import org.compiere.swing.CMenuItem; -import org.compiere.util.CLogger; -import org.compiere.util.DB; -import org.compiere.util.DisplayType; -import org.compiere.util.Env; -import org.compiere.util.Msg; - -/** - * Resource Assignment Entry - * - * @author Jorg Janke - * @version $Id: VAssignment.java,v 1.2 2006/07/30 00:51:28 jjanke Exp $ - */ -public class VAssignment extends JComponent - implements VEditor, ActionListener -{ - /** - * - */ - private static final long serialVersionUID = 4270887524258628077L; - - /** - * Mouse Listener - */ - final class VAssignment_mouseAdapter extends MouseAdapter - { - /** - * Constructor - * @param adaptee adaptee - */ - VAssignment_mouseAdapter(VAssignment adaptee) - { - this.adaptee = adaptee; - } // VAssignment_mouseAdapter - - private VAssignment adaptee; - - /** - * Mouse Listener - * @param e event - */ - public void mouseClicked(MouseEvent e) - { - // Double Click - if (e.getClickCount() > 1) - adaptee.actionPerformed(new ActionEvent(e.getSource(), e.getID(), "Mouse")); - // popup menu - if (SwingUtilities.isRightMouseButton(e)) - adaptee.popupMenu.show((Component)e.getSource(), e.getX(), e.getY()); - } // mouse Clicked - - } // VAssignment_mouseAdapter - - /** - * IDE Constructor - */ - public VAssignment() - { - this (false, false, true); - } // VAssigment - - /** - * Create Resource Assigment. - *
    -	 * 		Resource DateTimeFrom Qty UOM Button
    -	 *  
    - * @param mandatory mandatory - * @param isReadOnly read only - * @param isUpdateable updateable - */ - public VAssignment (boolean mandatory, boolean isReadOnly, boolean isUpdateable) - { - super(); - // super.setName(columnName); - LookAndFeel.installBorder(this, "TextField.border"); - this.setLayout(new BorderLayout()); - // Size - this.setPreferredSize(m_text.getPreferredSize()); - int height = m_text.getPreferredSize().height; - - // *** Text *** - m_text.setEditable(false); - m_text.setFocusable(false); - m_text.setBorder(null); - m_text.setHorizontalAlignment(JTextField.LEADING); - // Background - setMandatory(mandatory); - this.add(m_text, BorderLayout.CENTER); - - // *** Button *** - m_button.setIcon(Env.getImageIcon("Assignment10.gif")); - m_button.setMargin(new Insets(0, 0, 0, 0)); - m_button.setPreferredSize(new Dimension(height, height)); - m_button.addActionListener(this); - m_button.setFocusable(true); - this.add(m_button, BorderLayout.EAST); - - // Prefereed Size - this.setPreferredSize(this.getPreferredSize()); // causes r/o to be the same length - // ReadWrite - if (isReadOnly || !isUpdateable) - setReadWrite(false); - else - setReadWrite(true); - - // Popup - m_text.addMouseListener(new VAssignment_mouseAdapter(this)); - menuEditor = new CMenuItem(Msg.getMsg(Env.getCtx(), "InfoResource"), Env.getImageIcon("Zoom16.gif")); - menuEditor.addActionListener(this); - popupMenu.add(menuEditor); - } // VAssignment - - /** Data Value */ - private Object m_value = null; - /** Get Info */ - private PreparedStatement m_pstmt = null; - - /** The Text Field */ - private JTextField m_text = new JTextField (VLookup.DISPLAY_LENGTH); - /** The Button */ - private CButton m_button = new CButton(); - - JPopupMenu popupMenu = new JPopupMenu(); - private CMenuItem menuEditor; - - private boolean m_readWrite; - private boolean m_mandatory; - - /** The Format */ - private DateFormat m_dateFormat = DisplayType.getDateFormat(DisplayType.DateTime); - private NumberFormat m_qtyFormat = DisplayType.getNumberFormat(DisplayType.Quantity); - private GridField m_mField; - /** Logger */ - private static CLogger log = CLogger.getCLogger(VAssignment.class); - - /** - * Dispose resources - */ - public void dispose() - { - try - { - DB.close(m_pstmt); - m_pstmt = null; - } - catch (Exception e) - { - log.log(Level.SEVERE, "VAssignment.dispose"); - } - m_text = null; - m_button = null; - } // dispose - - /** - * Set Mandatory - * @param mandatory mandatory - */ - public void setMandatory (boolean mandatory) - { - m_mandatory = mandatory; - m_button.setMandatory(mandatory); - setBackground (false); - } // setMandatory - - /** - * Get Mandatory - * @return mandatory - */ - public boolean isMandatory() - { - return m_mandatory; - } // isMandatory - - /** - * Set ReadWrite - * @param rw read rwite - */ - public void setReadWrite (boolean rw) - { - m_readWrite = rw; - m_button.setReadWrite(rw); - setBackground (false); - } // setReadWrite - - /** - * Is Read Write - * @return read write - */ - public boolean isReadWrite() - { - return m_readWrite; - } // isReadWrite - - /** - * Set Foreground - * @param color color - */ - public void setForeground (Color color) - { - m_text.setForeground(color); - } // SetForeground - - /** - * Set Background - * @param error Error - */ - public void setBackground (boolean error) - { - if (error) - setBackground(AdempierePLAF.getFieldBackground_Error()); - else if (!m_readWrite) - setBackground(AdempierePLAF.getFieldBackground_Inactive()); - else if (m_mandatory) - setBackground(AdempierePLAF.getFieldBackground_Mandatory()); - else - setBackground(AdempierePLAF.getInfoBackground()); - } // setBackground - - /** - * Set Background - * @param color Color - */ - public void setBackground (Color color) - { - m_text.setBackground(color); - } // setBackground - - /** - * Request Focus - */ - public void requestFocus () - { - m_text.requestFocus (); - } // requestFocus - - /** - * Request Focus In Window - * @return focus request - */ - @Override - public boolean requestFocusInWindow() - { - return m_text.requestFocusInWindow(); - } // requestFocusInWindow - - /** - * Get Focus Component - * @return component - */ - public Component getFocusableComponent() - { - return m_text; - } // getFocusComponent - - /************************************************************************** - * Set/lookup Value - * @param value value - */ - public void setValue(Object value) - { - if (value == m_value) - return; - m_value = value; - int S_ResourceAssignment_ID = 0; - if (m_value != null && m_value instanceof Integer) - S_ResourceAssignment_ID = ((Integer)m_value).intValue(); - // Set Empty - if (S_ResourceAssignment_ID == 0) - { - m_text.setText(""); - return; - } - - // Statement - if (m_pstmt == null) - m_pstmt = DB.prepareStatement("SELECT r.Name,ra.AssignDateFrom,ra.Qty,uom.UOMSymbol " - + "FROM S_ResourceAssignment ra, S_Resource r, S_ResourceType rt, C_UOM uom " - + "WHERE ra.S_ResourceAssignment_ID=?" - + " AND ra.S_Resource_ID=r.S_Resource_ID" - + " AND r.S_ResourceType_ID=rt.S_ResourceType_ID" - + " and rt.C_UOM_ID=uom.C_UOM_ID", null); - // - ResultSet rs = null; - try - { - m_pstmt.setInt(1, S_ResourceAssignment_ID); - rs = m_pstmt.executeQuery(); - if (rs.next()) - { - StringBuilder sb = new StringBuilder(rs.getString(1)); - sb.append(" ").append(m_dateFormat.format(rs.getTimestamp(2))) - .append(" ").append(m_qtyFormat.format(rs.getBigDecimal(3))) - .append(" ").append(rs.getString(4).trim()); - m_text.setText(sb.toString()); - } - else - m_text.setText("<" + S_ResourceAssignment_ID + ">"); - } - catch (Exception e) - { - log.log(Level.SEVERE, "", e); - } - finally - { - DB.close(rs); - rs = null; - } - } // setValue - - /** - * Get Value - * @return value - */ - public Object getValue() - { - return m_value; - } // getValue - - /** - * Get Display Value - * @return info - */ - public String getDisplay() - { - return m_text.getText(); - } // getDisplay - - /*************************************************************************/ - - /** - * Set Field - NOP - * @param mField MField - */ - public void setField(GridField mField) - { - m_mField = mField; - if (m_mField != null) - FieldRecordInfo.addMenu(this, popupMenu); - } // setField - - @Override - public GridField getField() { - return m_mField; - } - - /** - * Action Listener Interface - * @param listener listener - */ - public void addActionListener(ActionListener listener) - { - // m_text.addActionListener(listener); - } // addActionListener - - /** - * Action Listener - start dialog - * @param e Event - */ - public void actionPerformed(ActionEvent e) - { - if (e.getActionCommand().equals(FieldRecordInfo.CHANGE_LOG_COMMAND)) - { - FieldRecordInfo.start(m_mField); - return; - } - if (!m_button.isEnabled()) - return; - m_button.setEnabled(false); - // - Integer oldValue = (Integer)getValue(); - int S_ResourceAssignment_ID = oldValue == null ? 0 : oldValue.intValue(); - MResourceAssignment ma = new MResourceAssignment(Env.getCtx(), S_ResourceAssignment_ID, null); - - // Start VAssignment Dialog - if (S_ResourceAssignment_ID != 0) - { - VAssignmentDialog vad = new VAssignmentDialog (AEnv.getFrame(this), ma, true, true); - ma = vad.getMResourceAssignment(); - } - // Start InfoSchedule directly - else - { - InfoSchedule is = new InfoSchedule(AEnv.getFrame(this), ma, true); - ma = is.getMResourceAssignment(); - } - - // Set Value - if (ma != null && ma.getS_ResourceAssignment_ID() != 0) - { - setValue(Integer.valueOf(ma.getS_ResourceAssignment_ID())); - try - { - fireVetoableChange(this.getName(), new Object(), getValue()); - } - catch (PropertyVetoException pve) - { - log.log(Level.SEVERE, "", pve); - } - } - m_button.setEnabled(true); - requestFocus(); - } // actionPerformed - - /** - * Property Change Listener - * @param evt event - */ - public void propertyChange (PropertyChangeEvent evt) - { - if (evt.getPropertyName().equals(org.compiere.model.GridField.PROPERTY)) - setValue(evt.getNewValue()); - } // propertyChange - -} // VAssignment diff --git a/org.adempiere.ui.swing/src/org/compiere/grid/ed/VAssignmentDialog.java b/org.adempiere.ui.swing/src/org/compiere/grid/ed/VAssignmentDialog.java deleted file mode 100644 index 10d1791073..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/grid/ed/VAssignmentDialog.java +++ /dev/null @@ -1,387 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ -package org.compiere.grid.ed; - -import java.awt.BorderLayout; -import java.awt.Frame; -import java.awt.GridBagConstraints; -import java.awt.GridBagLayout; -import java.awt.Insets; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.math.BigDecimal; -import java.sql.PreparedStatement; -import java.sql.ResultSet; -import java.sql.SQLException; -import java.sql.Timestamp; -import java.util.Arrays; -import java.util.HashMap; -import java.util.logging.Level; - -import javax.swing.JButton; -import javax.swing.WindowConstants; - -import org.compiere.apps.ADialog; -import org.compiere.apps.AEnv; -import org.compiere.apps.ConfirmPanel; -import org.compiere.apps.search.InfoSchedule; -import org.compiere.model.MResourceAssignment; -import org.compiere.model.MRole; -import org.compiere.model.MUOMConversion; -import org.compiere.swing.CDialog; -import org.compiere.swing.CLabel; -import org.compiere.swing.CPanel; -import org.compiere.swing.CTextField; -import org.compiere.util.CLogger; -import org.compiere.util.DB; -import org.compiere.util.DisplayType; -import org.compiere.util.Env; -import org.compiere.util.KeyNamePair; -import org.compiere.util.Msg; -import org.compiere.util.TimeUtil; - -/** - * Resource Assignment Dialog - * - * @author Jorg Janke - * @version $Id: VAssignmentDialog.java,v 1.2 2006/07/30 00:51:28 jjanke Exp $ - */ -public class VAssignmentDialog extends CDialog - implements ActionListener -{ - /** - * - */ - private static final long serialVersionUID = 4130085811212412204L; - - - /** - * Assignment Dialog. - *
    -	 * 		Creates a new assignment oor displays an assignment
    -	 * 		Create new:	(ID == 0)
    -	 * 			check availability & create assignment
    -	 * 			(confirmed when order/incoice/timeExpense is processed)
    -	 * 			alternatively let InfoResource do the assignment
    -	 * 			return ID
    -	 * 		Existing assignment: (ID != 0)
    -	 * 			if confirmed - no change.
    -	 * 			ability to delete or change assignment
    -	 * 			return ID
    -	 * 	
    - * @param frame parent - * @param mAssignment Assignment - * @param allowZoom allow to zoom to schedule - * @param allowDelete allow to delete recorde - */ - public VAssignmentDialog (Frame frame, MResourceAssignment mAssignment, - boolean allowZoom, boolean allowDelete) - { - super (frame, Msg.getMsg(Env.getCtx(), "VAssignmentDialog"), true); - if (log.isLoggable(Level.CONFIG)) log.config(mAssignment.toString()); - m_mAssignment = mAssignment; - m_frame = frame; - try - { - jbInit(); - if (!allowZoom) - confirmPanel.getZoomButton().setVisible(false); - delete.setVisible(allowDelete); - } - catch(Exception e) - { - log.log(Level.SEVERE, "", e); - } - setDisplay(); // from mAssignment - // - AEnv.showCenterScreen(this); - } // VAssignmentDialog - - /** Assignment */ - private MResourceAssignment m_mAssignment; - /** Parent frame */ - private Frame m_frame; - /** True if setting Value */ - private boolean m_setting = false; - /** Logger */ - private static CLogger log = CLogger.getCLogger(VAssignmentDialog.class); - /** Lookup with Resource & UOM */ - private HashMap m_lookup = new HashMap(); - - // - private CPanel mainPanel = new CPanel(); - private GridBagLayout mainLayout = new GridBagLayout(); - private CLabel lResource = new CLabel(Msg.translate(Env.getCtx(), "S_Resource_ID")); - private VComboBox fResource = new VComboBox(getResources()); - private CLabel lDate = new CLabel(Msg.translate(Env.getCtx(), "DateFrom")); - private VDate fDateFrom = new VDate(DisplayType.DateTime); - private CLabel lQty = new CLabel(Msg.translate(Env.getCtx(), "Qty")); - private VNumber fQty = new VNumber(); - private CLabel lUOM = new CLabel(); - private CLabel lName = new CLabel(Msg.translate(Env.getCtx(), "Name")); - private CLabel lDescription = new CLabel(Msg.translate(Env.getCtx(), "Description")); - private CTextField fName = new CTextField (30); - private CTextField fDescription = new CTextField(30); - private ConfirmPanel confirmPanel = new ConfirmPanel(true, false, false, false, false, true, true); - private JButton delete = ConfirmPanel.createDeleteButton(true); - - - /** - * Static Init - * @throws Exception - */ - private void jbInit() throws Exception - { - this.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); - fResource.addActionListener(this); - delete.addActionListener(this); - confirmPanel.addButton(delete); - confirmPanel.addActionListener(this); - // - mainPanel.setLayout(mainLayout); - mainPanel.add(lResource, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(8, 8, 4, 4), 0, 0)); - mainPanel.add(fResource, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(8, 0, 4, 4), 0, 0)); - mainPanel.add(lDate, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(2, 8, 4, 4), 0, 0)); - mainPanel.add(fDateFrom, new GridBagConstraints(1, 1, 2, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(2, 0, 4, 8), 100, 0)); - mainPanel.add(lQty, new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(2, 8, 4, 4), 0, 0)); - mainPanel.add(fQty, new GridBagConstraints(1, 2, 1, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(2, 0, 4, 4), 0, 0)); - mainPanel.add(lUOM, new GridBagConstraints(2, 2, 1, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(2, 4, 4, 8), 0, 0)); - mainPanel.add(lName, new GridBagConstraints(0, 3, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(2, 8, 4, 4), 0, 0)); - mainPanel.add(lDescription, new GridBagConstraints(0, 4, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(2, 8, 8, 4), 0, 0)); - mainPanel.add(fName, new GridBagConstraints(1, 3, 2, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(2, 0, 4, 8), 0, 0)); - mainPanel.add(fDescription, new GridBagConstraints(1, 4, 2, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(2, 0, 8, 8), 0, 0)); - // - this.getContentPane().add(mainPanel, BorderLayout.CENTER); - this.getContentPane().add(confirmPanel, BorderLayout.SOUTH); - } // jbInit - - /** - * Initialize component & values from m_mAssignment - */ - private void setDisplay() - { - m_setting = true; - - // Set Resource - int S_Resource_ID = m_mAssignment.getS_Resource_ID(); - KeyNamePair[] resources = new KeyNamePair[m_lookup.size()]; - m_lookup.keySet().toArray(resources); - for (int i = 0; i < resources.length; i++) - { - if (resources[i].getKey() == S_Resource_ID) - { - fResource.setSelectedItem(resources[i]); - break; - } - } - KeyNamePair check = (KeyNamePair)fResource.getSelectedItem(); - if (check == null || check.getKey() != S_Resource_ID) - { - if (m_mAssignment.getS_ResourceAssignment_ID() == 0) // new record select first - fResource.setSelectedItem(fResource.getSelectedItem()); // initiates UOM display - else - log.log(Level.SEVERE, "Resource not found ID=" + S_Resource_ID); - } - - // Set Date, Qty - fDateFrom.setValue(m_mAssignment.getAssignDateFrom()); - fQty.setValue(m_mAssignment.getQty()); - - // Name, Description - fName.setValue(m_mAssignment.getName()); - fDescription.setValue(m_mAssignment.getDescription()); - - // Set Editor to R/O if confirmed - boolean readWrite = true; - if (m_mAssignment.isConfirmed()) - readWrite = false; - confirmPanel.getCancelButton().setVisible(readWrite); - fResource.setReadWrite(readWrite); - fDateFrom.setReadWrite(readWrite); - fQty.setReadWrite(readWrite); - - m_setting = false; - } // dynInit - - /** - * Action Listener - * @param e event - */ - public void actionPerformed(ActionEvent e) - { - if (m_setting) - return; - // Update Assignment - KeyNamePair resource = (KeyNamePair)fResource.getSelectedItem(); - if (resource != null) - { - int S_Resource_ID = resource.getKey(); - m_mAssignment.setS_Resource_ID (S_Resource_ID); - } - Timestamp assignDateFrom = fDateFrom.getTimestamp(); - if (assignDateFrom != null) - m_mAssignment.setAssignDateFrom (assignDateFrom); - BigDecimal qty = (BigDecimal)fQty.getValue(); - if (qty != null) - m_mAssignment.setQty(qty); - m_mAssignment.setName((String)fName.getValue()); - m_mAssignment.setDescription((String)fDescription.getValue()); - - // Resource - Look up UOM - if (e.getSource() == fResource) - { - Object o = m_lookup.get(fResource.getSelectedItem()); - if (o == null) - lUOM.setText(" ? "); - else - lUOM.setText(o.toString()); - } - - // Zoom - InfoResource - else if (e.getActionCommand().equals(ConfirmPanel.A_ZOOM)) - { - InfoSchedule is = new InfoSchedule (m_frame, - m_mAssignment, true); - if (is.getMResourceAssignment() != null) - { - m_mAssignment = is.getMResourceAssignment(); - // setDisplay(); - dispose(); - } - is = null; - } - - // cancel - return - else if (e.getActionCommand().equals(ConfirmPanel.A_CANCEL)) - { - dispose(); - } - - // delete - delete and return - else if (e.getActionCommand().equals(ConfirmPanel.A_DELETE)) - { - if (m_mAssignment.delete(true)) - { - m_mAssignment = null; - dispose(); - } - else - ADialog.error(0, this, "ResourceAssignmentNotDeleted"); - } - - // OK - Save - else if (e.getActionCommand().equals(ConfirmPanel.A_OK)) - { - if (cmd_save()) - dispose(); - } - } // actionPerformed - - - /************************************************************************** - * Get Assignment - * @return Assignment - */ - public MResourceAssignment getMResourceAssignment() - { - return m_mAssignment; - } // getMResourceAssignment - - - /** - * Check availability and insert record - * @return true if saved/updated - */ - private boolean cmd_save() - { - log.config(""); - // Set AssignDateTo - Timestamp assignDateFrom = fDateFrom.getTimestamp(); - BigDecimal qty = (BigDecimal)fQty.getValue(); - KeyNamePair uom = (KeyNamePair)m_lookup.get(fResource.getSelectedItem()); - int minutes = MUOMConversion.convertToMinutes(Env.getCtx(), uom.getKey(), qty); - Timestamp assignDateTo = TimeUtil.addMinutess(assignDateFrom, minutes); - m_mAssignment.setAssignDateTo (assignDateTo); - // - // m_mAssignment.dump(); - return m_mAssignment.save(); - } // cmdSave - - - /************************************************************************** - * Load Resources. - * called from variable constructor - * @return Array with resources - */ - private KeyNamePair[] getResources() - { - if (m_lookup.size() == 0) - { - String sql = MRole.getDefault().addAccessSQL( - "SELECT r.S_Resource_ID, r.Name, r.IsActive," // 1..3 - + "uom.C_UOM_ID,uom.UOMSymbol " // 4..5 - + "FROM S_Resource r, S_ResourceType rt, C_UOM uom " - + "WHERE r.S_ResourceType_ID=rt.S_ResourceType_ID AND rt.C_UOM_ID=uom.C_UOM_ID", - "r", MRole.SQL_FULLYQUALIFIED, MRole.SQL_RO); - PreparedStatement pstmt = null; - ResultSet rs = null; - try - { - pstmt = DB.prepareStatement(sql, null); - rs = pstmt.executeQuery(); - while (rs.next()) - { - StringBuilder sb = new StringBuilder (rs.getString(2)); - if (!"Y".equals(rs.getString(3))) - sb.insert(0,'~').append('~'); // inactive marker - // Key S_Resource_ID/Name - KeyNamePair key = new KeyNamePair (rs.getInt(1), sb.toString()); - // Value C_UOM_ID/Name - KeyNamePair value = new KeyNamePair (rs.getInt(4), rs.getString(5).trim()); - m_lookup.put(key, value); - } - } - catch (SQLException e) - { - log.log(Level.SEVERE, sql, e); - } - finally - { - DB.close(rs, pstmt); - rs = null; - pstmt = null; - } - } - // Convert to Array - KeyNamePair[] retValue = new KeyNamePair[m_lookup.size()]; - m_lookup.keySet().toArray(retValue); - Arrays.sort(retValue); - return retValue; - } // getResources - -} // VAssignmentDialog diff --git a/org.adempiere.ui.swing/src/org/compiere/grid/ed/VBPartner.java b/org.adempiere.ui.swing/src/org/compiere/grid/ed/VBPartner.java deleted file mode 100644 index 669d72b9c7..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/grid/ed/VBPartner.java +++ /dev/null @@ -1,486 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ -package org.compiere.grid.ed; - -import java.awt.BorderLayout; -import java.awt.Frame; -import java.awt.GridBagConstraints; -import java.awt.GridBagLayout; -import java.awt.Insets; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.util.logging.Level; - -import javax.swing.Box; -import javax.swing.JComboBox; -import javax.swing.JComponent; - -import org.adempiere.plaf.AdempierePLAF; -import org.compiere.apps.ADialog; -import org.compiere.apps.AEnv; -import org.compiere.apps.ConfirmPanel; -import org.compiere.model.MBPartner; -import org.compiere.model.MBPartnerLocation; -import org.compiere.model.MLocation; -import org.compiere.model.MLocationLookup; -import org.compiere.model.MRole; -import org.compiere.model.MUser; -import org.compiere.swing.CDialog; -import org.compiere.swing.CLabel; -import org.compiere.swing.CPanel; -import org.compiere.util.CLogger; -import org.compiere.util.DB; -import org.compiere.util.Env; -import org.compiere.util.KeyNamePair; -import org.compiere.util.Msg; - -/** - * Business Partner Editor. - * Set BPartner: loadBPartner - * Get result: getC_BPartner_ID - * - * @author Jorg Janke - * @version $Id: VBPartner.java,v 1.2 2006/07/30 00:51:28 jjanke Exp $ - */ -public final class VBPartner extends CDialog implements ActionListener -{ - /** - * - */ - private static final long serialVersionUID = -4130643780412193122L; - - - /** - * Constructor. - * Requires call loadBPartner - * @param frame parent - * @param WindowNo Window No - */ - public VBPartner(Frame frame, int WindowNo) - { - super(frame, Msg.translate(Env.getCtx(), "C_BPartner_ID"), true); - m_WindowNo = WindowNo; - m_readOnly = !MRole.getDefault().canUpdate( - Env.getAD_Client_ID(Env.getCtx()), Env.getAD_Org_ID(Env.getCtx()), - MBPartner.Table_ID, 0, false); - if (log.isLoggable(Level.INFO)) log.info("R/O=" + m_readOnly); - try - { - jbInit(); - } - catch(Exception ex) - { - log.log(Level.SEVERE, ex.getMessage()); - } - initBPartner(); - // - AEnv.positionCenterWindow(frame, this); - } // VBPartner - - private int m_WindowNo; - /** The Partner */ - private MBPartner m_partner = null; - /** The Location */ - private MBPartnerLocation m_pLocation = null; - /** The User */ - private MUser m_user = null; - /** Read Only */ - private boolean m_readOnly = false; - - - private Insets m_labelInsets = new Insets(2,15,2,0); // top,left,bottom,right - private Insets m_fieldInsets = new Insets(2,5,2,10); // top,left,bottom,right - private GridBagConstraints m_gbc = new GridBagConstraints(); - private int m_line; - private Object[] m_greeting; - /** Logger */ - private static CLogger log = CLogger.getCLogger(VBPartner.class); - // - private VString fValue, fName, fName2, fContact, fTitle, fPhone, fFax, fPhone2, fEMail; - private VLocation fAddress; - private JComboBox fGreetingBP, fGreetingC; - // - private CPanel mainPanel = new CPanel(); - private BorderLayout mainLayout = new BorderLayout(); - private CPanel centerPanel = new CPanel(); - private CPanel southPanel = new CPanel(); - private GridBagLayout centerLayout = new GridBagLayout(); - private ConfirmPanel confirmPanel = new ConfirmPanel(true); - private BorderLayout southLayout = new BorderLayout(); - - - /** - * Static Init - * @throws Exception - */ - void jbInit() throws Exception - { - mainPanel.setLayout(mainLayout); - southPanel.setLayout(southLayout); - centerPanel.setLayout(centerLayout); - mainLayout.setVgap(5); - getContentPane().add(mainPanel); - mainPanel.add(centerPanel, BorderLayout.CENTER); - mainPanel.add(southPanel, BorderLayout.SOUTH); - southPanel.add(confirmPanel, BorderLayout.CENTER); - // - confirmPanel.addActionListener(this); - } // jbInit - - /** - * Dynamic Init - */ - private void initBPartner() - { - // Get Data - m_greeting = fillGreeting(); - - // Display - m_gbc.anchor = GridBagConstraints.NORTHWEST; - m_gbc.gridx = 0; - m_gbc.gridy = 0; - m_gbc.gridwidth = 1; - m_gbc.weightx = 0; - m_gbc.weighty = 0; - m_gbc.fill = GridBagConstraints.HORIZONTAL; - m_gbc.ipadx = 0; - m_gbc.ipady = 0; - m_line = 0; - - // Value - fValue = new VString("Value", true, false, true, 30, 60, "", null); - fValue.addActionListener(this); - createLine (fValue, "Value", true); - // Greeting Business Partner - fGreetingBP = new JComboBox (m_greeting); - createLine (fGreetingBP, "Greeting", false); - // Name - fName = new VString("Name", true, false, true, 30, 60, "", null); - fName.addActionListener(this); - createLine (fName, "Name", false).setFontBold(true); - // Name2 - fName2 = new VString("Name2", false, false, true, 30, 60, "", null); - createLine (fName2, "Name2", false); - - // Contact - fContact = new VString("Contact", false, false, true, 30, 60, "", null); - createLine (fContact, "Contact", true).setFontBold(true); - // Greeting Contact - fGreetingC = new JComboBox (m_greeting); - createLine (fGreetingC, "Greeting", false); - // Title - fTitle = new VString("Title", false, false, true, 30, 60, "", null); - createLine(fTitle, "Title", false); - // Email - fEMail = new VString("EMail", false, false, true, 30, 40, "", null); - createLine (fEMail, "EMail", false); - - // Location - boolean ro = m_readOnly; - if (!ro) - ro = !MRole.getDefault().canUpdate( - Env.getAD_Client_ID(Env.getCtx()), Env.getAD_Org_ID(Env.getCtx()), - MBPartnerLocation.Table_ID, 0, false); - if (!ro) - ro = !MRole.getDefault().canUpdate( - Env.getAD_Client_ID(Env.getCtx()), Env.getAD_Org_ID(Env.getCtx()), - MLocation.Table_ID, 0, false); - fAddress = new VLocation ("C_Location_ID", false, ro, true, new MLocationLookup (Env.getCtx(), m_WindowNo)); - fAddress.setValue (null); - createLine (fAddress, "C_Location_ID", true).setFontBold(true); - // Phone - fPhone = new VString("Phone", false, false, true, 30, 40, "", null); - createLine (fPhone, "Phone", true); - // Phone2 - fPhone2 = new VString("Phone2", false, false, true, 30, 40, "", null); - createLine (fPhone2, "Phone2", false); - // Fax - fFax = new VString("Fax", false, false, true, 30, 40, "", null); - createLine (fFax, "Fax", false); - // - fName.setBackground(AdempierePLAF.getFieldBackground_Mandatory()); - fAddress.setBackground(AdempierePLAF.getFieldBackground_Mandatory()); - } // initBPartner - - /** - * Create Line - * @param field field - * @param title label value - * @param addSpace add more space - * @return label - */ - private CLabel createLine (JComponent field, String title, boolean addSpace) - { - if (addSpace) - { - m_gbc.gridy = m_line++; - m_gbc.gridx = 1; - m_gbc.insets = m_fieldInsets; - centerPanel.add (Box.createHorizontalStrut(6), m_gbc); - } - - // Line - m_gbc.gridy = m_line++; - - // Label - m_gbc.gridx = 0; - m_gbc.insets = m_labelInsets; - m_gbc.fill = GridBagConstraints.HORIZONTAL; - CLabel label = new CLabel(Msg.translate(Env.getCtx(), title)); - centerPanel.add(label, m_gbc); - - // Field - m_gbc.gridx = 1; - m_gbc.insets = m_fieldInsets; - m_gbc.fill = GridBagConstraints.HORIZONTAL; - centerPanel.add(field, m_gbc); - if (m_readOnly) - field.setEnabled(false); - return label; - } // createLine - - /** - * Fill Greeting - * @return KeyNamePair Array of Greetings - */ - private Object[] fillGreeting() - { - String sql = "SELECT C_Greeting_ID, Name FROM C_Greeting WHERE IsActive='Y' ORDER BY 2"; - sql = MRole.getDefault().addAccessSQL(sql, "C_Greeting", MRole.SQL_NOTQUALIFIED, MRole.SQL_RO); - return DB.getKeyNamePairs(sql, true); - } // fillGreeting - - /** - * Search m_greeting for key - * @param key C_Greeting_ID - * @return Greeting - */ - private KeyNamePair getGreeting (int key) - { - for (int i = 0; i < m_greeting.length; i++) - { - KeyNamePair p = (KeyNamePair)m_greeting[i]; - if (p.getKey() == key) - return p; - } - return new KeyNamePair(-1, " "); - } // getGreeting - - /** - * Load BPartner - * @param C_BPartner_ID - existing BPartner or 0 for new - * @return true if loaded - */ - public boolean loadBPartner (int C_BPartner_ID) - { - if (log.isLoggable(Level.CONFIG)) log.config("C_BPartner_ID=" + C_BPartner_ID); - // New bpartner - if (C_BPartner_ID == 0) - { - m_partner = null; - m_pLocation = null; - m_user = null; - return true; - } - - m_partner = new MBPartner (Env.getCtx(), C_BPartner_ID, null); - if (m_partner.get_ID() == 0) - { - ADialog.error(m_WindowNo, this, "BPartnerNotFound"); - return false; - } - - // BPartner - Load values - fValue.setText(m_partner.getValue()); - fGreetingBP.setSelectedItem(getGreeting(m_partner.getC_Greeting_ID())); - fName.setText(m_partner.getName()); - fName2.setText(m_partner.getName2()); - - // Contact - Load values - m_pLocation = m_partner.getLocation( - Env.getContextAsInt(Env.getCtx(), m_WindowNo, "C_BPartner_Location_ID")); - if (m_pLocation != null) - { - int location = m_pLocation.getC_Location_ID(); - fAddress.setValue (Integer.valueOf(location)); - // - fPhone.setText(m_pLocation.getPhone()); - fPhone2.setText(m_pLocation.getPhone2()); - fFax.setText(m_pLocation.getFax()); - } - // User - Load values - m_user = m_partner.getContact( - Env.getContextAsInt(Env.getCtx(), m_WindowNo, "AD_User_ID")); - if (m_user != null) - { - fGreetingC.setSelectedItem(getGreeting(m_user.getC_Greeting_ID())); - fContact.setText(m_user.getName()); - fTitle.setText(m_user.getTitle()); - fEMail.setText(m_user.getEMail()); - // - fPhone.setText(m_user.getPhone()); - fPhone2.setText(m_user.getPhone2()); - fFax.setText(m_user.getFax()); - } - return true; - } // loadBPartner - - - /** - * Action Listener - * @param e event - */ - public void actionPerformed(ActionEvent e) - { - if (m_readOnly) - dispose(); - // copy value - else if (e.getSource() == fValue) - { - if (fName.getText() == null || fName.getText().length() == 0) - fName.setText(fValue.getText()); - } - else if (e.getSource() == fName) - { - if (fContact.getText() == null || fContact.getText().length() == 0) - fContact.setText(fName.getText()); - } - // OK pressed - else if (e.getActionCommand().equals(ConfirmPanel.A_OK) - && actionSave()) - dispose(); - // Cancel pressed - else if (e.getActionCommand().equals(ConfirmPanel.A_CANCEL)) - dispose(); - } // actionPerformed - - /** - * Save. - * Checks mandatory fields and saves Partner, Contact and Location - * @return true if saved - */ - private boolean actionSave() - { - log.config(""); - - // Check Mandatory fields - if (fName.getText().equals("")) - { - fName.setBackground(AdempierePLAF.getFieldBackground_Error()); - return false; - } - else - fName.setBackground(AdempierePLAF.getFieldBackground_Mandatory()); - if (fAddress.getC_Location_ID() == 0) - { - fAddress.setBackground(AdempierePLAF.getFieldBackground_Error()); - return false; - } - else - fAddress.setBackground(AdempierePLAF.getFieldBackground_Mandatory()); - - // ***** Business Partner ***** - if (m_partner == null) - { - int AD_Client_ID = Env.getAD_Client_ID(Env.getCtx()); - m_partner = MBPartner.getTemplate(Env.getCtx(), AD_Client_ID); - m_partner.setAD_Org_ID(Env.getAD_Org_ID(Env.getCtx())); // Elaine 2009/07/03 - boolean isSOTrx = !"N".equals(Env.getContext(Env.getCtx(), m_WindowNo, "IsSOTrx")); - m_partner.setIsCustomer (isSOTrx); - m_partner.setIsVendor (!isSOTrx); - } - // Check Value - String value = fValue.getText(); - if (value == null || value.length() == 0) - { - // get Table Documet No - value = DB.getDocumentNo (Env.getAD_Client_ID(Env.getCtx()), "C_BPartner", null, m_partner); - fValue.setText(value); - } - m_partner.setValue(fValue.getText()); - // - m_partner.setName(fName.getText()); - m_partner.setName2(fName2.getText()); - KeyNamePair p = (KeyNamePair)fGreetingBP.getSelectedItem(); - if (p != null && p.getKey() > 0) - m_partner.setC_Greeting_ID(p.getKey()); - else - m_partner.setC_Greeting_ID(0); - if (m_partner.save()) { - if (log.isLoggable(Level.FINE)) log.fine("C_BPartner_ID=" + m_partner.getC_BPartner_ID()); - } else { - ADialog.error(m_WindowNo, this, "BPartnerNotSaved"); - } - - // ***** Business Partner - Location ***** - if (m_pLocation == null) - m_pLocation = new MBPartnerLocation(m_partner); - m_pLocation.setC_Location_ID(fAddress.getC_Location_ID()); - // - m_pLocation.setPhone(fPhone.getText()); - m_pLocation.setPhone2(fPhone2.getText()); - m_pLocation.setFax(fFax.getText()); - if (m_pLocation.save()) { - if (log.isLoggable(Level.FINE)) log.fine("C_BPartner_Location_ID=" + m_pLocation.getC_BPartner_Location_ID()); - } else { - ADialog.error(m_WindowNo, this, "BPartnerNotSaved", Msg.translate(Env.getCtx(), "C_BPartner_Location_ID")); - } - - // ***** Business Partner - User ***** - String contact = fContact.getText(); - String email = fEMail.getText(); - if (m_user == null && (contact.length() > 0 || email.length() > 0)) - m_user = new MUser (m_partner); - if (m_user != null) - { - if (contact.length() == 0) - contact = fName.getText(); - m_user.setName(contact); - m_user.setEMail(email); - m_user.setTitle(fTitle.getText()); - p = (KeyNamePair)fGreetingC.getSelectedItem(); - if (p != null && p.getKey() > 0) - m_user.setC_Greeting_ID(p.getKey()); - else - m_user.setC_Greeting_ID(0); - // - m_user.setPhone(fPhone.getText()); - m_user.setPhone2(fPhone2.getText()); - m_user.setFax(fFax.getText()); - if (m_user.save()) { - if (log.isLoggable(Level.FINE)) log.fine("AD_User_ID=" + m_user.getAD_User_ID()); - } else { - ADialog.error(m_WindowNo, this, "BPartnerNotSaved", Msg.translate(Env.getCtx(), "AD_User_ID")); - } - } - return true; - } // actionSave - - - /** - * Returns BPartner ID - * @return C_BPartner_ID (0 = not saved) - */ - public int getC_BPartner_ID() - { - if (m_partner == null) - return 0; - return m_partner.getC_BPartner_ID(); - } // getBPartner_ID - -} // VBPartner - diff --git a/org.adempiere.ui.swing/src/org/compiere/grid/ed/VBinary.java b/org.adempiere.ui.swing/src/org/compiere/grid/ed/VBinary.java deleted file mode 100644 index 128a4e6212..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/grid/ed/VBinary.java +++ /dev/null @@ -1,287 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ -package org.compiere.grid.ed; - -import java.awt.Color; -import java.awt.Component; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.beans.PropertyChangeEvent; -import java.beans.PropertyVetoException; -import java.io.ByteArrayOutputStream; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileOutputStream; -import java.util.logging.Level; - -import javax.swing.JButton; -import javax.swing.JFileChooser; - -import org.compiere.model.GridField; -import org.compiere.util.CLogger; - -/** - * Binary Editor. - * Shows length of data. - * - * @author Jorg Janke - * @version $Id: VBinary.java,v 1.2 2006/07/30 00:51:28 jjanke Exp $ - */ -public class VBinary extends JButton - implements VEditor, ActionListener -{ - /** - * - */ - private static final long serialVersionUID = -1940719045449193395L; - - /** - * Binary Editor - * @param columnName column name - * @param WindowNo - */ - public VBinary (String columnName, int WindowNo) - { - super(""); - m_columnName = columnName; - m_WindowNo = WindowNo; - super.addActionListener(this); - } // VBinary - - /** - * Dispose - */ - public void dispose() - { - m_data = null; - } // dispose - - - /** Column Name */ - private String m_columnName; - /** WindowNo */ - @SuppressWarnings("unused") - private int m_WindowNo; - /** Data */ - private Object m_data = null; - - /** Logger */ - private static CLogger log = CLogger.getCLogger(VBinary.class); - - /** - * Set Value - * @param value - */ - public void setValue(Object value) - { - if (log.isLoggable(Level.CONFIG)) log.config("=" + value); - m_data = value; - if (m_data == null) - setText("-"); - else - { - String text = "?"; - if (m_data instanceof byte[]) - { - byte[] bb = (byte[])m_data; - text = "#" + bb.length; - } - else - { - text = m_data.getClass().getName(); - int index = text.lastIndexOf('.'); - if (index != -1) - text = text.substring(index+1); - } - setText(text); - } - } // setValue - - /** - * Get Value - * @return value - */ - public Object getValue() - { - return m_data; - } // getValue - - /** - * Get Display Value - * @return image name - */ - public String getDisplay() - { - return getText(); - } // getDisplay - - /** - * Set ReadWrite - * @param rw - */ - public void setReadWrite (boolean rw) - { - if (isEnabled() != rw) - setEnabled (rw); - } // setReadWrite - - /** - * Get ReadWrite - * @return true if rw - */ - public boolean isReadWrite() - { - return super.isEnabled(); - } // getReadWrite - - /** - * Set Mandatory - * @param mandatory NOP - */ - public void setMandatory (boolean mandatory) - { - } // setMandatory - - /** - * Get Mandatory - * @return false - */ - public boolean isMandatory() - { - return false; - } // isMandatory - - /** - * Set Background - nop - * @param color - */ - public void setBackground(Color color) - { - } // setBackground - - /** - * Set Background - nop - */ - public void setBackground() - { - } // setBackground - - /** - * Set Background - nop - * @param error - */ - public void setBackground(boolean error) - { - } // setBackground - - /** - * Property Change - * @param evt - */ - public void propertyChange(PropertyChangeEvent evt) - { - if (log.isLoggable(Level.INFO)) log.info(evt.toString()); - if (evt.getPropertyName().equals(org.compiere.model.GridField.PROPERTY)) - setValue(evt.getNewValue()); - } // propertyChange - - /** - * ActionListener - start dialog and set value - * @param e event - */ - public void actionPerformed (ActionEvent e) - { - JFileChooser fc = new JFileChooser(""); - fc.setMultiSelectionEnabled(false); - fc.setFileSelectionMode(JFileChooser.FILES_ONLY); - int option = 0; - boolean save = m_data != null; - if (save) - option = fc.showSaveDialog(this); - else - option = fc.showOpenDialog(this); - if (option != JFileChooser.APPROVE_OPTION) - return; - File file = fc.getSelectedFile(); - if (file == null) - return; - // - if (log.isLoggable(Level.INFO)) log.info(file.toString()); - try - { - if (save) - { - FileOutputStream os = new FileOutputStream(file); - byte[] buffer = (byte[])m_data; - os.write(buffer); - os.flush(); - os.close(); - if (log.isLoggable(Level.CONFIG)) log.config("Save to " + file + " #" + buffer.length); - } - else // load - { - FileInputStream is = new FileInputStream(file); - ByteArrayOutputStream os = new ByteArrayOutputStream(); - byte[] buffer = new byte[1024*8]; // 8kB - int length = -1; - while ((length = is.read(buffer)) != -1) - os.write(buffer, 0, length); - is.close(); - byte[] data = os.toByteArray(); - m_data = data; - if (log.isLoggable(Level.CONFIG)) log.config("Load from " + file + " #" + data.length); - os.close(); - } - } - catch (Exception ex) - { - log.log(Level.WARNING, "Save=" + save, ex); - } - - try - { - fireVetoableChange(m_columnName, null, m_data); - } - catch (PropertyVetoException pve) {} - } // actionPerformed - - // Field for Value Preference - private GridField m_mField = null; - /** - * Set Field/WindowNo for ValuePreference (NOP) - * @param mField - */ - public void setField (GridField mField) - { - m_mField = mField; - } // setField - - @Override - public GridField getField() { - return m_mField; - } - - /** - * Get Focus Component - * @return component - */ - public Component getFocusableComponent() - { - return this; - } // getFocusComponent - -} // VBinary diff --git a/org.adempiere.ui.swing/src/org/compiere/grid/ed/VButton.java b/org.adempiere.ui.swing/src/org/compiere/grid/ed/VButton.java deleted file mode 100644 index 7793762408..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/grid/ed/VButton.java +++ /dev/null @@ -1,403 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ -package org.compiere.grid.ed; - -import static org.compiere.model.SystemIDs.REFERENCE_DOCUMENTACTION; -import static org.compiere.model.SystemIDs.REFERENCE_PAYMENTRULE; -import static org.compiere.model.SystemIDs.REFERENCE_POSTED; - -import java.awt.Color; -import java.awt.Component; -import java.awt.event.ActionListener; -import java.beans.PropertyChangeEvent; -import java.sql.PreparedStatement; -import java.sql.ResultSet; -import java.sql.SQLException; -import java.util.HashMap; -import java.util.logging.Level; - -import org.compiere.model.GridField; -import org.compiere.model.MLookup; -import org.compiere.model.MLookupFactory; -import org.compiere.swing.CButton; -import org.compiere.util.CLogger; -import org.compiere.util.DB; -import org.compiere.util.DisplayType; -import org.compiere.util.Env; -import org.compiere.util.Msg; -import org.compiere.util.NamePair; - -/** - * General Button. - *
    - *  Special Buttons:
    - *      Payment,
    - *      Processing,
    - *      CreateFrom,
    - *      Record_ID       - Zoom
    - *  
    - * Maintains all values for display in m_values. - * see org.compiere.apps.APanel#actionButton(VButton) - * - * @author Jorg Janke - * @version $Id: VButton.java,v 1.2 2006/07/30 00:51:28 jjanke Exp $ - */ -public final class VButton extends CButton - implements VEditor -{ - /** - * - */ - private static final long serialVersionUID = 148906133238037062L; - - /** - * Constructor - * @param columnName column - * @param mandatory mandatory - * @param isReadOnly read only - * @param isUpdateable updateable - * @param text text - * @param description description - * @param help help - * @param AD_Process_ID process to start - */ - public VButton (String columnName, boolean mandatory, boolean isReadOnly, boolean isUpdateable, - String text, String description, String help, int AD_Process_ID) - { - super (text); - super.setName(columnName); - super.setActionCommand(columnName); - m_text = text; - m_columnName = columnName; - // - setMandatory (mandatory); - if (isReadOnly || !isUpdateable) - setReadWrite(false); - else - setReadWrite(true); - - // Special Buttons - if (columnName.equals("PaymentRule")) - { - readReference(REFERENCE_PAYMENTRULE); - this.setForeground(Color.blue); - setIcon(Env.getImageIcon("Payment16.gif")); // 29*14 - } - else if (columnName.equals("DocAction")) - { - readReference(REFERENCE_DOCUMENTACTION); - this.setForeground(Color.blue); - setIcon(Env.getImageIcon("Process16.gif")); // 16*16 - } - else if (columnName.equals("CreateFrom")) - { - setIcon(Env.getImageIcon("Copy16.gif")); // 16*16 - } - else if (columnName.equals("Record_ID")) - { - setIcon(Env.getImageIcon("Zoom16.gif")); // 16*16 - this.setText(Msg.getMsg(Env.getCtx(), "ZoomDocument")); - } - else if (columnName.equals("Posted")) - { - readReference(REFERENCE_POSTED); - this.setForeground(Color.magenta); - setIcon(Env.getImageIcon("InfoAccount16.gif")); // 16*16 - } - - // Deescription & Help - m_description = description; - if (description == null || description.length() == 0) - m_description = " "; - else - setToolTipText(m_description); - // - m_help = help; - if (help == null) - m_help = ""; - m_AD_Process_ID = AD_Process_ID; - } // VButton - - /** Mnemonic saved */ - private char m_savedMnemonic = 0; - - /** - * Dispose - */ - public void dispose() - { - m_actionListener = null; - if (m_values != null) - m_values.clear(); - m_values = null; - } // dispose - - private String m_columnName; - private String m_text; - private boolean m_mandatory; - private Object m_value; - @SuppressWarnings("unused") - private ActionListener m_actionListener; - /** List of Key/Name */ - private HashMap m_values = null; - /** Description as ToolTip */ - private String m_description = ""; - private String m_help; - private int m_AD_Process_ID; - private MLookup m_lookup; - /** Logger */ - private static CLogger log = CLogger.getCLogger(VButton.class); - - /** - * Set Value - * @param value value - */ - public void setValue(Object value) - { - m_value = value; - String text = m_text; - - // Nothing to show or Record_ID - if (value == null || m_columnName.equals("Record_ID")) - ; - else if (m_values != null) - text = (String)m_values.get(value); - else if (m_lookup != null) - { - NamePair pp = m_lookup.get (value); - if (pp != null) - text = pp.getName(); - } - // Display it - setText (text != null ? text : ""); - } // setValue - - /** - * Property Change Listener - * @param evt event - */ - public void propertyChange (PropertyChangeEvent evt) - { - if (evt.getPropertyName().equals(org.compiere.model.GridField.PROPERTY)) - setValue(evt.getNewValue()); - } // propertyChange - - /** - * Return Value - * @return value - */ - public Object getValue() - { - return m_value; - } // getValue - - /** - * Return Display Value - * @return String value - */ - public String getDisplay() - { - return m_value.toString(); - } // getDisplay - - /** - * Set Mandatory - NOP - * @param mandatory mandatory - */ - public void setMandatory (boolean mandatory) - { - m_mandatory = mandatory; - } // setMandatory - - /** - * Mandatory? - * @return true if mandatory - */ - public boolean isMandatory() - { - return m_mandatory; - } // isMandatory - - /** - * Set Background - NOP - * @param error error - */ - public void setBackground(boolean error) - { - } // setBackground - - /** - * Get ColumnName - * @return column name - */ - public String getColumnName() - { - return m_columnName; - } // getColumnName - - /** - * Get Description - * @return description string - */ - public String getDescription() - { - return m_description; - } // getDescription - - /** - * Get Help - * @return help string - */ - public String getHelp() - { - return m_help; - } // getHelp - - /** - * Get AD_Process_ID - * @return AD_Process_ID or 0 - */ - public int getProcess_ID() - { - return m_AD_Process_ID; - } // getProcess_ID - - /** - * Add ActionListener - * @param aListener listener - */ - public void addActionListener(ActionListener aListener) - { - m_actionListener = aListener; - super.addActionListener(aListener); - } // addActionListener - - /** - * String representation - * @return String representation - */ - public String toString() - { - StringBuilder sb = new StringBuilder ("VButton["); - sb.append(m_columnName); - sb.append("=").append(m_value).append("]"); - return sb.toString(); - } // toString - - /** - * Fill m_Values with Ref_List values - * @param AD_Reference_ID reference - */ - private void readReference( int AD_Reference_ID) - { - m_values = new HashMap(); - String SQL; - if (Env.isBaseLanguage(Env.getCtx(), "AD_Ref_List")) - SQL = "SELECT Value, Name FROM AD_Ref_List WHERE AD_Reference_ID=?"; - else - SQL = "SELECT l.Value, t.Name FROM AD_Ref_List l, AD_Ref_List_Trl t " - + "WHERE l.AD_Ref_List_ID=t.AD_Ref_List_ID" - + " AND t.AD_Language='" + Env.getAD_Language(Env.getCtx()) + "'" - + " AND l.AD_Reference_ID=?"; - PreparedStatement pstmt = null; - ResultSet rs = null; - try - { - pstmt = DB.prepareStatement(SQL, null); - pstmt.setInt(1, AD_Reference_ID); - rs = pstmt.executeQuery(); - while (rs.next()) - { - String value = rs.getString(1); - String name = rs.getString(2); - m_values.put(value, name); - } - } - catch (SQLException e) - { - log.log(Level.SEVERE, SQL, e); - } - finally - { - DB.close(rs, pstmt); - rs = null; - pstmt = null; - } - } // readReference - - /** - * Return value/name - * @return HashMap with Value/Names - */ - public HashMap getValues() - { - return m_values; - } // getValues - - // Field for Value Preference - private GridField m_mField = null; - /** - * Set Field/WindowNo for ValuePreference - * @param mField field model - */ - public void setField (GridField mField) - { - if (mField.getColumnName().endsWith("_ID") && !mField.getColumnName().equals("Record_ID")) - { - m_lookup = MLookupFactory.get(Env.getCtx(), mField.getWindowNo(), 0, - mField.getAD_Column_ID(), DisplayType.Search); - } - else if (mField.getAD_Reference_Value_ID() != 0) - { - // Assuming List - m_lookup = MLookupFactory.get(Env.getCtx(), mField.getWindowNo(), 0, - mField.getAD_Column_ID(), DisplayType.List); - } - m_mField = mField; - } // setField - - @Override - public GridField getField() { - return m_mField; - } - - /** - * @return Returns the savedMnemonic. - */ - public char getSavedMnemonic () - { - return m_savedMnemonic; - } // getSavedMnemonic - - /** - * @param savedMnemonic The savedMnemonic to set. - */ - public void setSavedMnemonic (char savedMnemonic) - { - m_savedMnemonic = savedMnemonic; - } // getSavedMnemonic - - /** - * Get Focus Component - * @return component - */ - public Component getFocusableComponent() - { - return this; - } // getFocusableComponent - -} // VButton diff --git a/org.adempiere.ui.swing/src/org/compiere/grid/ed/VCellEditor.java b/org.adempiere.ui.swing/src/org/compiere/grid/ed/VCellEditor.java deleted file mode 100644 index 1899ffcf59..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/grid/ed/VCellEditor.java +++ /dev/null @@ -1,266 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ -package org.compiere.grid.ed; - -import java.awt.Component; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.awt.event.MouseEvent; -import java.beans.PropertyChangeEvent; -import java.beans.VetoableChangeListener; -import java.util.EventObject; -import java.util.logging.Level; - -import javax.swing.AbstractCellEditor; -import javax.swing.BorderFactory; -import javax.swing.JComboBox; -import javax.swing.JTable; -import javax.swing.UIManager; -import javax.swing.table.TableCellEditor; - -import org.adempiere.plaf.AdempierePLAF; -import org.compiere.model.GridField; -import org.compiere.model.GridTable; -import org.compiere.util.CLogger; - -/** - * Cell Editor. - *
    - *		Sequence of events:
    - *			isCellEditable
    - *			getTableCellEditor
    - *			shouldSelectCell
    - *			getCellEditorValue
    - *  
    - * A new Editor is created for editable columns. - * @author Jorg Janke - * @version $Id: VCellEditor.java,v 1.2 2006/07/30 00:51:28 jjanke Exp $ - */ -public final class VCellEditor extends AbstractCellEditor - implements TableCellEditor, VetoableChangeListener, ActionListener -{ - - /** - * - */ - private static final long serialVersionUID = 1406944397509282968L; - - /** - * Constructor for Grid - * @param mField - */ - public VCellEditor (GridField mField) - { - super(); - m_mField = mField; - // Click - } // VCellEditor - - /** The Field */ - private GridField m_mField = null; - /** The Table Editor */ - private VEditor m_editor = null; - - /** Table */ - private JTable m_table = null; - //private ActionListener buttonListener; - private ActionListener actionListener; - - /** ClickCount */ - private static int CLICK_TO_START = 1; - /** Logger */ - private static CLogger log = CLogger.getCLogger(VCellEditor.class); - - /** - * Create Editor - */ - private void createEditor() - { - m_editor = VEditorFactory.getEditor(m_mField, true); - m_editor.addVetoableChangeListener(this); - m_editor.addActionListener(this); - - } // createEditor - - /** - * Ask the editor if it can start editing using anEvent. - * If editing can be started this method returns true. - * Previously called: MTable.isCellEditable - * @param anEvent event - * @return true if editable - */ - public boolean isCellEditable (EventObject anEvent) - { - if (!m_mField.isEditable (true)) // row data is in context - return false; - if (log.isLoggable(Level.FINE)) log.fine(m_mField.getHeader()); // event may be null if CellEdit - // not enough mouse clicks - if (anEvent instanceof MouseEvent - && ((MouseEvent)anEvent).getClickCount() < CLICK_TO_START) - return false; - - if (m_editor == null) - createEditor(); - return true; - } // isCellEditable - - /** - * Sets an initial value for the editor. This will cause the editor to - * stopEditing and lose any partially edited value if the editor is editing - * when this method is called. - * Returns the component that should be added to the client's Component hierarchy. - * Once installed in the client's hierarchy this component - * will then be able to draw and receive user input. - * - * @param table - * @param value - * @param isSelected - * @param row - * @param col - * @return component - */ - public Component getTableCellEditorComponent (JTable table, Object value, boolean isSelected, int row, int col) - { - if (log.isLoggable(Level.FINEST)) log.finest(m_mField.getColumnName() + ": Value=" + value + ", row=" + row + ", col=" + col); - if (row >= 0) - table.setRowSelectionInterval(row,row); // force moving to new row - if (m_editor == null ) - createEditor(); - - if ( m_editor instanceof VLookup) - { - ((VLookup)m_editor).setStopEditing(false); - } - - m_editor.setReadWrite(m_mField.isEditable (true)); - - m_table = table; - - // Set Value - m_editor.setValue(value); - - // Set Background/Foreground to "normal" (unselected) colors - m_editor.setBackground(m_mField.isError()); - m_editor.setForeground(AdempierePLAF.getTextColor_Normal()); - - // Other UI - m_editor.setFont(table.getFont()); - if ( m_editor instanceof VLookup) { - VLookup lookup = (VLookup)m_editor; - if (lookup.getComponents()[0] instanceof JComboBox) { - lookup.setBorder(BorderFactory.createEmptyBorder()); - } else { - lookup.setBorder(UIManager.getBorder("Table.focusCellHighlightBorder")); - } - } else { - m_editor.setBorder(UIManager.getBorder("Table.focusCellHighlightBorder")); - } - // - return (Component)m_editor; - } // getTableCellEditorComponent - - /** - * The editing cell should be selected or not - * @param e event - * @return true (constant) - */ - public boolean shouldSelectCell(EventObject e) - { - if (log.isLoggable(Level.FINEST)) log.finest(m_mField.getColumnName()); - return true; - } // shouldSelectCell - - /** - * Returns the value contained in the editor - * @return value - */ - public Object getCellEditorValue() - { - if (log.isLoggable(Level.FINEST)) log.finest(m_mField.getColumnName() + ": " + m_editor.getValue()); - return m_editor.getValue(); - } // getCellEditorValue - - /** - * VEditor Change Listener (property name is columnName). - * - indicate change (for String/Text/..)
    - * When editing is complete the value is retrieved via getCellEditorValue - * @param e event - */ - public void vetoableChange(PropertyChangeEvent e) - { - if (m_table == null) - return; - if (log.isLoggable(Level.FINE)) log.fine(e.getPropertyName() + "=" + e.getNewValue()); - // - ((GridTable)m_table.getModel()).setChanged(true); - } // vetoableChange - - /** - * Get Actual Editor. - * Called from GridController to add ActionListener to Button - * @return VEditor - */ - public VEditor getEditor() - { - return m_editor; - } // getEditor - - /** - * Action Editor - Stop Editor - * @param e event - */ - public void actionPerformed (ActionEvent e) - { - if (log.isLoggable(Level.FINER)) log.finer(m_mField.getColumnName() + ": Value=" + m_editor.getValue()); - if (e.getSource() == m_editor && actionListener != null) - actionListener.actionPerformed(e); - } // actionPerformed - - /** - * Dispose - */ - public void dispose() - { - m_editor = null; - m_mField = null; - m_table = null; - } // dispose - - @Override - public boolean stopCellEditing() { - if (super.stopCellEditing()) { - if (m_editor instanceof VLookup) { - ((VLookup)m_editor).setStopEditing(true); - } - return true; - } else { - return false; - } - } - - @Override - public void cancelCellEditing() { - super.cancelCellEditing(); - if (m_editor instanceof VLookup) { - ((VLookup)m_editor).setStopEditing(true); - } - } - - public void setActionListener(ActionListener listener) { - actionListener = listener; - } -} // VCellEditor diff --git a/org.adempiere.ui.swing/src/org/compiere/grid/ed/VCellRenderer.java b/org.adempiere.ui.swing/src/org/compiere/grid/ed/VCellRenderer.java deleted file mode 100644 index 74865147d4..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/grid/ed/VCellRenderer.java +++ /dev/null @@ -1,293 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ -package org.compiere.grid.ed; - -import java.awt.Color; -import java.awt.Component; -import java.awt.Insets; -import java.text.DecimalFormat; -import java.text.SimpleDateFormat; -import java.util.Date; -import java.util.logging.Level; - -import javax.swing.JCheckBox; -import javax.swing.JLabel; -import javax.swing.JTable; -import javax.swing.table.DefaultTableCellRenderer; - -import org.adempiere.plaf.AdempierePLAF; -import org.compiere.model.GridField; -import org.compiere.model.Lookup; -import org.compiere.util.CLogger; -import org.compiere.util.DisplayType; - -/** - * Table Cell Renderer based on DisplayType - * - * @author Jorg Janke - * @version $Id: VCellRenderer.java,v 1.4 2006/07/30 00:51:27 jjanke Exp $ - * - * @author Teo Sarca - *
  • FR [ 2866571 ] VCellRenderer: implement getters - * https://sourceforge.net/tracker/?func=detail&aid=2866571&group_id=176962&atid=879335 - */ -public final class VCellRenderer extends DefaultTableCellRenderer -{ - /** - * - */ - private static final long serialVersionUID = 3135422746697244864L; - - /** - * Constructor for Grid - * @param mField field model - */ - public VCellRenderer(GridField mField) - { - this (mField.getDisplayType()); - m_columnName = mField.getColumnName(); - this.setName(m_columnName); - m_lookup = mField.getLookup(); - m_password = mField.isEncryptedField(); - } // VCellRenderer - - /** - * Constructor for MiniGrid - * @param displayType Display Type - */ - public VCellRenderer (int displayType) - { - super(); - m_displayType = displayType; - // Number - if (DisplayType.isNumeric(m_displayType)) - { - m_numberFormat = DisplayType.getNumberFormat(m_displayType); - setHorizontalAlignment(JLabel.RIGHT); - } - // Date - else if (DisplayType.isDate(m_displayType)) - m_dateFormat = DisplayType.getDateFormat(m_displayType); - // - else if (m_displayType == DisplayType.YesNo) - { - m_check = new JCheckBox(); - m_check.setMargin(new Insets(0,0,0,0)); - m_check.setHorizontalAlignment(JLabel.CENTER); - m_check.setOpaque(true); - } - } // VCellRenderer - - private int m_displayType; - private String m_columnName = null; - private Lookup m_lookup = null; - private boolean m_password = false; - // - private SimpleDateFormat m_dateFormat = null; - private DecimalFormat m_numberFormat = null; - private JCheckBox m_check = null; - /** Logger */ - private static CLogger log = CLogger.getCLogger(VCellRenderer.class); - - /** - * Get TableCell RendererComponent. - * @param table table - * @param value value - * @param isSelected selected - * @param hasFocus focus - * @param row row - * @param col col - * @return component - */ - public Component getTableCellRendererComponent (JTable table, Object value, - boolean isSelected, boolean hasFocus, int row, int col) - { - // log.finest(m_columnName - // + ": Value=" + (value == null ? "null" : value.toString()) - // + ", Row=" + row + ", Col=" + col); - - Component c = null; - if (m_displayType == DisplayType.YesNo) - c = m_check; - else - { // returns JLabel - c = super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, col); - //c.setFont(AdempierePLAF.getFont_Field()); - c.setFont(table.getFont()); - } - - // Background & Foreground - Color bg = AdempierePLAF.getFieldBackground_Normal(); - Color fg = AdempierePLAF.getTextColor_Normal(); - // Inactive Background - boolean ro = !table.isCellEditable(row, col); - if (ro) - { - bg = AdempierePLAF.getFieldBackground_Inactive(); - if (isSelected && !hasFocus) - bg = bg.darker(); - } - - // Foreground - int cCode = 0; - // Grid - if (table instanceof org.compiere.grid.VTable) - cCode = ((org.compiere.grid.VTable)table).getColorCode (row); - // MiniGrid - else if (table instanceof org.compiere.minigrid.MiniTable) - cCode = ((org.compiere.minigrid.MiniTable)table).getColorCode (row); - // - if (cCode == 0) - ; // Black - else if (cCode < 0) - fg = AdempierePLAF.getTextColor_Issue(); // Red - else - fg = AdempierePLAF.getTextColor_OK(); // Blue - - // Highlighted row - if (isSelected) - { - // Windows is white on blue - bg = table.getSelectionBackground(); - fg = table.getSelectionForeground(); - if (hasFocus) - bg = org.adempiere.apps.graph.GraphUtil.brighter(bg, .9); - } - - // Set Color - c.setBackground(bg); - c.setForeground(fg); - // - // log.fine( "r=" + row + " c=" + col, // + " - " + c.getClass().getName(), - // "sel=" + isSelected + ", focus=" + hasFocus + ", edit=" + table.isCellEditable(row, col)); - // Log.trace(7, "BG=" + (bg.equals(Color.white) ? "white" : bg.toString()), "FG=" + (fg.equals(Color.black) ? "black" : fg.toString())); - - // Format it - setValue(value); - return c; - } // getTableCellRendererComponent - - - /** - * Format Display Value. - * Default is JLabel - * @param value (key)value - */ - protected void setValue (Object value) - { - String retValue = null; - try - { - // Checkbox - if (m_displayType == DisplayType.YesNo) - { - if (value instanceof Boolean) - m_check.setSelected(((Boolean)value).booleanValue()); - else - m_check.setSelected("Y".equals(value)); - return; - } - else if (value == null) - ; - // Number - else if (DisplayType.isNumeric(m_displayType)) - if (value instanceof Number) - retValue = m_numberFormat.format(value); - else - retValue = value.toString(); - // Date - else if (DisplayType.isDate(m_displayType)) - if (value instanceof Date) - retValue = m_dateFormat.format(value); - else - retValue = value.toString(); - // Row ID - else if (m_displayType == DisplayType.RowID) - retValue = ""; - // Lookup - else if (m_lookup != null && (DisplayType.isLookup(m_displayType) - || m_displayType == DisplayType.Location - || m_displayType == DisplayType.Account - || m_displayType == DisplayType.Locator - || m_displayType == DisplayType.PAttribute )) - retValue = m_lookup.getDisplay(value); - // Button - else if (m_displayType == DisplayType.Button) - { - if ("Record_ID".equals(m_columnName)) - retValue = "#" + value + "#"; - else - retValue = null; - } - // Password (fixed string) - else if (m_password) - retValue = "**********"; - // other (String ...) - else - { - super.setValue(value); - return; - } - } - catch (Exception e) - { - log.log(Level.SEVERE, "(" + value + ") " + value.getClass().getName() , e); - retValue = value.toString(); - } - super.setValue(retValue); - } // setValue - - /** - * to String - * @return String representation - */ - public String toString() - { - return "VCellRenderer[" + m_columnName - + ",DisplayType=" + m_displayType + " - " + m_lookup + "]"; - } // toString - - /** - * Dispose - */ - public void dispose() - { - if (m_lookup != null) - m_lookup.dispose(); - m_lookup = null; - } // dispose - - public String getColumnName() - { - return m_columnName; - } - - public Lookup getLookup() - { - return m_lookup; - } - - public int getDisplayType() - { - return m_displayType; - } - - public boolean isPassword() - { - return m_password; - } -} // VCellRenderer diff --git a/org.adempiere.ui.swing/src/org/compiere/grid/ed/VChart.java b/org.adempiere.ui.swing/src/org/compiere/grid/ed/VChart.java deleted file mode 100644 index af54e918c5..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/grid/ed/VChart.java +++ /dev/null @@ -1,192 +0,0 @@ -package org.compiere.grid.ed; - -import java.awt.BorderLayout; -import java.awt.Component; -import java.awt.Cursor; -import java.awt.Dimension; -import java.awt.event.ActionListener; -import java.beans.PropertyChangeEvent; -import java.beans.VetoableChangeListener; - -import org.adempiere.apps.graph.ChartBuilder; -import org.compiere.apps.AEnv; -import org.compiere.model.GridField; -import org.compiere.model.MChart; -import org.compiere.model.MQuery; -import org.compiere.swing.CPanel; -import org.compiere.util.Env; -import org.jfree.chart.ChartMouseEvent; -import org.jfree.chart.ChartMouseListener; -import org.jfree.chart.ChartPanel; -import org.jfree.chart.JFreeChart; -import org.jfree.chart.entity.CategoryItemEntity; -import org.jfree.chart.entity.ChartEntity; -import org.jfree.chart.entity.PieSectionEntity; -import org.jfree.chart.entity.XYItemEntity; -import org.jfree.data.time.TimeSeries; -import org.jfree.data.time.TimeSeriesCollection; -import org.jfree.data.time.TimeSeriesDataItem; - -public class VChart extends CPanel implements ChartMouseListener, VEditor { - /** - * - */ - private static final long serialVersionUID = 4089566607789995074L; - - ChartPanel chartPanel; - MChart chartModel; - private ChartBuilder chartBuilder; - /** - * Constructor - */ - public VChart() - { - super(); - this.setLayout(new BorderLayout()); - } // Chart - - public VChart(int AD_Chart_ID, int windowNo) { - this(); - chartModel = new MChart(Env.getCtx(), AD_Chart_ID, null); - chartModel.setWindowNo(windowNo); - //createChart(); - } - - public void createChart() - { - chartBuilder = new ChartBuilder(chartModel); - JFreeChart chart = chartBuilder.createChart(); - if (chartPanel != null) - remove(chartPanel); - - chartPanel = new ChartPanel(chart); - Dimension size = getSize(); - size.height= chartModel.getWinHeight(); - chartPanel.setPreferredSize(size); - chartPanel.addChartMouseListener(this); - add(chartPanel,BorderLayout.CENTER); - - this.setMinimumSize(size); - } // BarGraph - - - @Override - public void addActionListener(ActionListener listener) {} - - @Override - public void addVetoableChangeListener(VetoableChangeListener listener) {} - - @Override - public void dispose() {} - - @Override - public String getName() {return chartModel.get_Translation(MChart.COLUMNNAME_Name);} - - @Override - public void removeVetoableChangeListener(VetoableChangeListener listener) {} - - @Override - public void propertyChange(PropertyChangeEvent arg0) {} - - @Override - public void chartMouseClicked(ChartMouseEvent event) { - - if ((event.getEntity()!=null) && (event.getTrigger().getClickCount() > 1)) - { - setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); - try - { - ChartEntity entity = event.getEntity(); - String key = null; - String seriesName = null; - if (entity instanceof CategoryItemEntity) - { - CategoryItemEntity item = ((CategoryItemEntity)entity); - Comparable colKey = item.getColumnKey(); - Comparable rowKey = item.getRowKey(); - if (colKey != null && rowKey !=null) - { - key = colKey.toString(); - seriesName = rowKey.toString(); - } - } - else if (entity instanceof PieSectionEntity) - { - Comparable sectionKey = ((PieSectionEntity)entity).getSectionKey(); - if (sectionKey != null) - { - key = sectionKey.toString(); - } - } - if (entity instanceof XYItemEntity) - { - XYItemEntity item = ((XYItemEntity)entity); - if ( item.getDataset() instanceof TimeSeriesCollection ) - { - TimeSeriesCollection data = (TimeSeriesCollection) item.getDataset(); - TimeSeries series = data.getSeries(item.getSeriesIndex()); - TimeSeriesDataItem dataitem = series.getDataItem(item.getItem()); - seriesName = series.getKey().toString(); - key = dataitem.getPeriod().toString(); - } - } - - if ( key == null ) - return; - - MQuery query = chartBuilder.getQuery(seriesName == null ? key : seriesName+"__"+key); - - if (query != null) - AEnv.zoom(query); - - } - finally - { - setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); - } - } - } - - @Override - public void chartMouseMoved(ChartMouseEvent arg0) {} - - @Override - public void setField(GridField mField) {} - - @Override - public String getDisplay() {return null;} - - @Override - public Object getValue() {return null;} - - @Override - public boolean isMandatory() {return false;} - - @Override - public boolean isReadWrite() {return false;} - - @Override - public void setBackground(boolean error) {} - - @Override - public void setMandatory(boolean mandatory) {} - - @Override - public void setReadWrite(boolean rw) {} - - @Override - public void setValue(Object value) {} - - @Override - public GridField getField() { return null; } - - /** - * Get Focus Component - * @return component - */ - public Component getFocusableComponent() - { - return this; - } // getFocusComponent - -} diff --git a/org.adempiere.ui.swing/src/org/compiere/grid/ed/VCheckBox.java b/org.adempiere.ui.swing/src/org/compiere/grid/ed/VCheckBox.java deleted file mode 100644 index 6ee336b465..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/grid/ed/VCheckBox.java +++ /dev/null @@ -1,275 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ -package org.compiere.grid.ed; - -import java.awt.Component; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.awt.event.MouseAdapter; -import java.awt.event.MouseEvent; -import java.beans.PropertyChangeEvent; -import java.beans.PropertyVetoException; - -import javax.swing.JLabel; -import javax.swing.JPopupMenu; -import javax.swing.SwingUtilities; - -import org.compiere.apps.FieldRecordInfo; -import org.compiere.model.GridField; -import org.compiere.swing.CCheckBox; -import org.compiere.util.Env; -import org.compiere.util.Msg; - -/** - * Checkbox Control - * - * @author Jorg Janke - * @version $Id: VCheckBox.java,v 1.2 2006/07/30 00:51:28 jjanke Exp $ - */ -public class VCheckBox extends CCheckBox - implements VEditor, ActionListener -{ - /** - * - */ - private static final long serialVersionUID = -3840182999009176708L; - - /****************************************************************************** - * Mouse Listener - */ - final class VCheckBox_mouseAdapter extends MouseAdapter - { - /** - * Constructor - * @param adaptee adaptee - */ - VCheckBox_mouseAdapter(VCheckBox adaptee) - { - m_adaptee = adaptee; - } // VNumber_mouseAdapter - - private VCheckBox m_adaptee; - - /** - * Mouse Listener - * @param e event - */ - public void mouseClicked(MouseEvent e) - { - // popup menu - if (SwingUtilities.isRightMouseButton(e)) - m_adaptee.popupMenu.show((Component)e.getSource(), e.getX(), e.getY()); - } // mouseClicked - - } - - /** - * Default Constructor - */ - public VCheckBox() - { - this("", false, false, true, "", null, false); - } // VCheckBox - - /** - * Standard Constructor - * @param columnName - * @param mandatory - * @param isReadOnly - * @param isUpdateable - * @param title - * @param description - * @param tableEditor - */ - public VCheckBox(String columnName, boolean mandatory, boolean isReadOnly, boolean isUpdateable, - String title, String description, boolean tableEditor) - { - super(); - super.setName(columnName); - m_columnName = columnName; - setMandatory(mandatory); - // - if (isReadOnly || !isUpdateable) - setEditable(false); - else - setEditable(true); - - // Normal - if (!tableEditor) - { - setText(title); - if (description != null && description.length() > 0) - setToolTipText(description); - } - else - { - setHorizontalAlignment(JLabel.CENTER); - } - // - this.addActionListener(this); - addMouseListener(new VCheckBox_mouseAdapter(this)); - } // VCheckBox - - /** Mnemonic saved */ - private char m_savedMnemonic = 0; - - /** - * Dispose - */ - public void dispose() - { - } // dispose - - private String m_columnName; - private GridField m_mField; - // Popup - JPopupMenu popupMenu = new JPopupMenu(); - - /** - * Set Editable - * @param value - */ - public void setEditable (boolean value) - { - super.setReadWrite(value); - } // setEditable - - /** - * IsEditable - * @return true if editable - */ - public boolean isEditable() - { - return super.isReadWrite(); - } // isEditable - - /** - * Set Editor to value - * @param value - */ - public void setValue (Object value) - { - boolean sel = false; - if (value != null) - { - if (value instanceof Boolean) - sel = ((Boolean)value).booleanValue(); - else - sel = "Y".equals(value); - } - setSelected(sel); - } // setValue - - /** - * Property Change Listener - * @param evt - */ - public void propertyChange (PropertyChangeEvent evt) - { - if (evt.getPropertyName().equals(org.compiere.model.GridField.PROPERTY)) - setValue(evt.getNewValue()); - } // propertyChange - - /** - * Return Editor value - * @return value - */ - public Object getValue() - { - return Boolean.valueOf(isSelected()); - } // getValue - - /** - * Return Display Value - * @return value - */ - public String getDisplay() - { - String value = isSelected() ? "Y" : "N"; - return Msg.translate(Env.getCtx(), value); - } // getDisplay - - /** - * Set Background (nop) - */ - public void setBackground() - { - } // setBackground - - /** - * Action Listener - data binding - * @param e - */ - public void actionPerformed(ActionEvent e) - { - if (e.getActionCommand().equals(FieldRecordInfo.CHANGE_LOG_COMMAND)) - { - FieldRecordInfo.start(m_mField); - return; - } - // ADebug.info("VCheckBox.actionPerformed"); - try - { - fireVetoableChange(m_columnName, null, getValue()); - } - catch (PropertyVetoException pve) - { - } - } // actionPerformed - - /** - * Set Field/WindowNo for ValuePreference (NOP) - * @param mField - */ - public void setField (org.compiere.model.GridField mField) - { - m_mField = mField; - if (m_mField != null) - FieldRecordInfo.addMenu(this, popupMenu); - } // setField - - @Override - public GridField getField() { - return m_mField; - } - - /** - * @return Returns the savedMnemonic. - */ - public char getSavedMnemonic () - { - return m_savedMnemonic; - } // getSavedMnemonic - - /** - * @param savedMnemonic The savedMnemonic to set. - */ - public void setSavedMnemonic (char savedMnemonic) - { - m_savedMnemonic = savedMnemonic; - } // getSavedMnemonic - - /** - * Get Focus Component - * @return component - */ - public Component getFocusableComponent() - { - return this; - } // getFocusableComponent - -} // VCheckBox diff --git a/org.adempiere.ui.swing/src/org/compiere/grid/ed/VColor.java b/org.adempiere.ui.swing/src/org/compiere/grid/ed/VColor.java deleted file mode 100644 index a7e3d061cc..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/grid/ed/VColor.java +++ /dev/null @@ -1,371 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ -package org.compiere.grid.ed; - -import java.awt.Color; -import java.awt.Component; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.beans.PropertyChangeEvent; -import java.math.BigDecimal; -import java.sql.PreparedStatement; -import java.sql.ResultSet; -import java.sql.SQLException; -import java.util.logging.Level; - -import javax.swing.JFrame; - -import org.compiere.model.GridField; -import org.compiere.model.GridTab; -import org.compiere.plaf.CompiereColor; -import org.compiere.plaf.CompiereLookAndFeel; -import org.compiere.swing.CButton; -import org.compiere.swing.ColorEditor; -import org.compiere.util.CLogger; -import org.compiere.util.DB; -import org.compiere.util.Env; - -/** - * Color Editor. - * The editor stores/gets the attributes from the tab. - * - * @author Jorg Janke - * @version $Id: VColor.java,v 1.2 2006/07/30 00:51:28 jjanke Exp $ - */ -public class VColor extends CButton - implements VEditor, ActionListener -{ - /** - * - */ - private static final long serialVersionUID = -8272165162228993219L; - - /** - * Constructor - * @param mTab Tab - * @param mandatory mandatory - * @param isReadOnly read only - */ - public VColor (GridTab mTab, boolean mandatory, boolean isReadOnly) - { - m_mTab = mTab; - setMandatory(mandatory); - setReadWrite(!isReadOnly); - addActionListener(this); - } // VColor - - /** - * Dispose - */ - public void dispose() - { - m_mTab = null; - } // dispose - - private GridTab m_mTab; - private boolean m_mandatory; -// private int m_AD_Color_ID = 0; - private CompiereColor m_cc = null; - private Object m_value; - /** Logger */ - private static CLogger log = CLogger.getCLogger(VColor.class); - - /** - * Set Mandatory - * @param mandatory mandatory - */ - public void setMandatory (boolean mandatory) - { - m_mandatory = mandatory; - } // setMandatory - - /** - * Is Mandatory - * @return true if Mandatory - */ - public boolean isMandatory() - { - return m_mandatory; - } // isMandatory - - /** - * Set Background (nop) - * @param error error - */ - public void setBackground (boolean error) - { - } // setBackground - - /** - * Set Value - * @param value value - */ - public void setValue (Object value) - { - if (log.isLoggable(Level.CONFIG)) log.config("Value=" + value); - m_value = value; - m_cc = getAdempiereColor(); - - // Display It - setText(getDisplay()); - if (m_cc != null) - setBackgroundColor(m_cc); - else - { - setOpaque(false); - putClientProperty(CompiereLookAndFeel.BACKGROUND, null); - } - repaint(); - } // setValue - - /** - * GetValue - * @return value - */ - public Object getValue() - { - return m_value; - } // getValue - - /** - * Get Displayed Value - * @return String representation - */ - public String getDisplay() - { - if (m_cc == null) - return "-/-"; - return " "; - } // getDisplay - - /** - * Property Change Listener - * @param evt event - */ - public void propertyChange (PropertyChangeEvent evt) - { - // log.config( "VColor.propertyChange", evt); - if (evt.getPropertyName().equals(org.compiere.model.GridField.PROPERTY)) - { - setValue(evt.getNewValue()); - setBackground(false); - } - } // propertyChange - - // Field for Value Preference - private GridField m_mField = null; - /** - * Set Field/WindowNo for ValuePreference - * @param mField field - */ - public void setField (GridField mField) - { - mField.setValueNoFire(false); // fire every time - m_mField = mField; - } // setField - - @Override - public GridField getField() { - return m_mField; - } - - /*************************************************************************/ - - /** - * Load Color from Tab - * @return true if loaded - * @see org.compiere.model.MColor#getAdempiereColor - */ - private CompiereColor getAdempiereColor() - { - Integer AD_Color_ID = (Integer)m_mTab.getValue("AD_Color_ID"); - if (log.isLoggable(Level.FINE)) log.fine("AD_Color_ID=" + AD_Color_ID); - CompiereColor cc = null; - - // Color Type - String ColorType = (String)m_mTab.getValue("ColorType"); - if (ColorType == null) - { - log.fine("No ColorType"); - return null; - } - // - if (ColorType.equals(CompiereColor.TYPE_FLAT)) - { - cc = new CompiereColor(getColor(true), true); - } - else if (ColorType.equals(CompiereColor.TYPE_GRADIENT)) - { - Integer RepeatDistance = (Integer)m_mTab.getValue("RepeatDistance"); - String StartPoint = (String)m_mTab.getValue("StartPoint"); - int repeatDistance = RepeatDistance == null ? 0 : RepeatDistance.intValue(); - int startPoint = StartPoint == null ? 0 : Integer.parseInt(StartPoint); - cc = new CompiereColor(getColor(true), getColor(false), startPoint, repeatDistance); - } - else if (ColorType.equals(CompiereColor.TYPE_LINES)) - { - BigDecimal LineWidth = (BigDecimal)m_mTab.getValue("LineWidth"); - BigDecimal LineDistance = (BigDecimal)m_mTab.getValue("LineDistance"); - int lineWidth = LineWidth == null ? 0 : LineWidth.intValue(); - int lineDistance = LineDistance == null ? 0 : LineDistance.intValue(); - cc = new CompiereColor(getColor(false), getColor(true), lineWidth, lineDistance); - } - else if (ColorType.equals(CompiereColor.TYPE_TEXTURE)) - { - Integer AD_Image_ID = (Integer)m_mTab.getValue("AD_Image_ID"); - String url = getURL(AD_Image_ID); - if (url == null) - return null; - BigDecimal ImageAlpha = (BigDecimal)m_mTab.getValue("ImageAlpha"); - float compositeAlpha = ImageAlpha == null ? 0.7f : ImageAlpha.floatValue(); - cc = new CompiereColor(url, getColor(true), compositeAlpha); - } - else - return null; - - if (log.isLoggable(Level.FINE)) log.fine("AdempiereColor=" + cc); - return cc; - } // getAdempiereColor - - /** - * Get Color from Tab - * @param primary true if primary false if secondary - * @return Color - */ - private Color getColor (boolean primary) - { - String add = primary ? "" : "_1"; - // is either BD or Int - Integer Red = (Integer)m_mTab.getValue("Red" + add); - Integer Green = (Integer)m_mTab.getValue("Green" + add); - Integer Blue = (Integer)m_mTab.getValue("Blue" + add); - // - int red = Red == null ? 0 : Red.intValue(); - int green = Green == null ? 0 : Green.intValue(); - int blue = Blue == null ? 0 : Blue.intValue(); - // - return new Color (red, green, blue); - } // getColor - - /** - * Get URL from Image - * @param AD_Image_ID image - * @return URL as String or null - */ - private String getURL (Integer AD_Image_ID) - { - if (AD_Image_ID == null || AD_Image_ID.intValue() == 0) - return null; - // - String retValue = null; - String sql = "SELECT ImageURL FROM AD_Image WHERE AD_Image_ID=?"; - PreparedStatement pstmt = null; - ResultSet rs = null; - try - { - pstmt = DB.prepareStatement(sql, null); - pstmt.setInt (1, AD_Image_ID.intValue()); - rs = pstmt.executeQuery(); - if (rs.next()) - { - retValue = rs.getString(1); - } - } - catch (SQLException e) - { - log.log(Level.SEVERE, sql, e); - } - finally - { - DB.close(rs, pstmt); - rs = null; - pstmt = null; - } - return retValue; - } // getURL - - /*************************************************************************/ - - /** - * Action Listener - Open Dialog - * @param e event - */ - public void actionPerformed (ActionEvent e) - { - // Show Dialog - CompiereColor cc = ColorEditor.showDialog((JFrame)Env.getParent(this), m_cc); - if (cc == null) - { - log.info( "VColor.actionPerformed - no color"); - return; - } - setBackgroundColor(cc); // set Button - repaint(); - - // Update Values - m_mTab.setValue("ColorType", cc.getType()); - if (cc.isFlat()) - { - setColor (cc.getFlatColor(), true); - } - else if (cc.isGradient()) - { - setColor (cc.getGradientUpperColor(), true); - setColor (cc.getGradientLowerColor(), false); - m_mTab.setValue("RepeatDistance", new BigDecimal(cc.getGradientRepeatDistance())); - m_mTab.setValue("StartPoint", String.valueOf(cc.getGradientStartPoint())); - } - else if (cc.isLine()) - { - setColor (cc.getLineBackColor(), true); - setColor (cc.getLineColor(), false); - m_mTab.getValue("LineWidth"); - m_mTab.getValue("LineDistance"); - } - else if (cc.isTexture()) - { - setColor (cc.getTextureTaintColor(), true); - // URL url = cc.getTextureURL(); - // m_mTab.setValue("AD_Image_ID"); - m_mTab.setValue("ImageAlpha", BigDecimal.valueOf(cc.getTextureCompositeAlpha())); - } - m_cc = cc; - } // actionPerformed - - /** - * Set Color in Tab - * @param c Color - * @param primary true if primary false if secondary - */ - private void setColor (Color c, boolean primary) - { - String add = primary ? "" : "_1"; - m_mTab.setValue("Red" + add, new BigDecimal(c.getRed())); - m_mTab.setValue("Green" + add, new BigDecimal(c.getGreen())); - m_mTab.setValue("Blue" + add, new BigDecimal(c.getBlue())); - } // setColor - - /** - * Get Focus Component - * @return component - */ - public Component getFocusableComponent() - { - return this; - } // getFocusableComponent - -} // VColor diff --git a/org.adempiere.ui.swing/src/org/compiere/grid/ed/VComboBox.java b/org.adempiere.ui.swing/src/org/compiere/grid/ed/VComboBox.java deleted file mode 100644 index 94c1bc6fb5..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/grid/ed/VComboBox.java +++ /dev/null @@ -1,176 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ -package org.compiere.grid.ed; - -import java.util.logging.Level; - -import javax.swing.ComboBoxModel; - -import org.compiere.model.MLocator; -import org.compiere.swing.CComboBox; -import org.compiere.util.CLogger; -import org.compiere.util.KeyNamePair; -import org.compiere.util.NamePair; - -/** - * Combobox with KeyNamePair/ValueNamePair or Locator. - *

    - * It has the same hight as a TextField - * - * @author Jorg Janke - * @version $Id: VComboBox.java,v 1.2 2006/07/30 00:51:28 jjanke Exp $ - */ -public class VComboBox extends CComboBox -{ - /** - * - */ - private static final long serialVersionUID = 7632613004262943867L; - - /** - * Constructor - */ - public VComboBox() - { - super(); -// common_init(); - } - public VComboBox(Object[] items) - { - super(items); -// common_init(); - } - public VComboBox(ComboBoxModel model) - { - super(model); -// common_init(); - } // VComboBox - - /** Logger */ - private static CLogger log = CLogger.getCLogger(VComboBox.class); - - /** - * Common Setup - * - private void common_init() - { - LookAndFeel.installColorsAndFont(this, "TextField.background", "TextField.foreground", "TextField.font"); - setForeground(AdempierePLAF.getTextColor_Normal()); - setBackground(AdempierePLAF.getFieldBackground_Normal()); - setPreferredSize(s_text.getPreferredSize()); - // this.setKeySelectionManager(new ComboSelectionManager()); - } // common_init - - /** Reference Field * - private static JTextField s_text = new JTextField(VTextField.DISPLAY_SIZE); - - /** - * Set Selected Item to key. - * Find key value in list - * @param key - */ - public void setValue(Object key) - { - if (key == null) - { - this.setSelectedIndex(-1); - return; - } - - ComboBoxModel model = getModel(); - int size = model.getSize(); - for (int i = 0; i < size; i++) - { - Object element = model.getElementAt(i); - String ID = null; - if (element instanceof NamePair) - ID = ((NamePair)element).getID(); - else if (element instanceof MLocator) - ID = String.valueOf(((MLocator)element).getM_Locator_ID()); - else - log.log(Level.SEVERE, "Element not NamePair - " + element.getClass().toString()); - - if (key == null || ID == null) - { - if (key == null && ID == null) - { - setSelectedIndex(i); - return; - } - } - else if (ID.equals(key.toString())) - { - setSelectedIndex(i); - return; - } - } - setSelectedIndex(-1); - setSelectedItem(null); - } // setValue - - /** - * Set Selected item to key if exists - * @param key - */ - public void setValue (int key) - { - setValue(String.valueOf(key)); - } // setValue - - /** - * Get Value - * @return key as Integer or String value - */ - public Object getValue() - { - NamePair p = (NamePair)getSelectedItem(); - if (p == null) - return null; - // - if (p instanceof KeyNamePair) - { - if (p.getID() == null) // -1 return null - return null; - return Integer.valueOf(((KeyNamePair)p).getID()); - } - return p.getID(); - } // getValue - - /** - * Get Display - * @return displayed string - */ - public String getDisplay() - { - if (getSelectedItem() == null) - return ""; - // - NamePair p = (NamePair)getSelectedItem(); - if (p == null) - return ""; - return p.getName(); - } // getDisplay - - @Override - protected boolean isMatchingFilter(Object element) - { - if (element instanceof NamePair) - element = ((NamePair)element).getName(); - return super.isMatchingFilter(element); - } - -} // VComboBox diff --git a/org.adempiere.ui.swing/src/org/compiere/grid/ed/VDate.java b/org.adempiere.ui.swing/src/org/compiere/grid/ed/VDate.java deleted file mode 100644 index c13fe4913e..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/grid/ed/VDate.java +++ /dev/null @@ -1,648 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ -package org.compiere.grid.ed; - -import java.awt.BorderLayout; -import java.awt.Color; -import java.awt.Component; -import java.awt.Container; -import java.awt.Dimension; -import java.awt.Frame; -import java.awt.Insets; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.awt.event.FocusEvent; -import java.awt.event.FocusListener; -import java.awt.event.KeyEvent; -import java.awt.event.KeyListener; -import java.awt.event.MouseEvent; -import java.beans.PropertyChangeEvent; -import java.beans.PropertyVetoException; -import java.sql.Timestamp; -import java.text.ParseException; -import java.text.SimpleDateFormat; -import java.util.logging.Level; - -import javax.swing.JComponent; -import javax.swing.JPopupMenu; -import javax.swing.JTextField; -import javax.swing.LookAndFeel; -import javax.swing.SwingUtilities; -import javax.swing.text.Document; - -import org.adempiere.plaf.AdempierePLAF; -import org.compiere.apps.AEnv; -import org.compiere.apps.FieldRecordInfo; -import org.compiere.model.GridField; -import org.compiere.model.MRole; -import org.compiere.swing.CButton; -import org.compiere.swing.CTextField; -import org.compiere.util.CLogger; -import org.compiere.util.DisplayType; -import org.compiere.util.Env; - -/** - * Date Edit. - * Maintains data as Timestamp - * - * @author Jorg Janke - * @version $Id: VDate.java,v 1.2 2006/07/30 00:51:28 jjanke Exp $ - */ -public class VDate extends JComponent - implements VEditor, ActionListener, KeyListener, FocusListener -{ - /** - * - */ - private static final long serialVersionUID = 6876765074500243476L; - - /***************************************************************************** - * Mouse Listener for Popup Menu - */ - class VDate_mouseAdapter extends java.awt.event.MouseAdapter - { - /** - * Constructor - * @param adaptee adaptee - */ - VDate_mouseAdapter(VDate adaptee) - { - this.adaptee = adaptee; - } // VLookup_mouseAdapter - - private VDate adaptee; - - /** - * Mouse Listener - * @param e MouseEvent - */ - public void mouseClicked(MouseEvent e) - { - // System.out.println("mouseClicked " + e.getID() + " " + e.getSource().getClass().toString()); - // popup menu - if (SwingUtilities.isRightMouseButton(e)) - adaptee.popupMenu.show((Component)e.getSource(), e.getX(), e.getY()); - } // mouse Clicked - - } // VLookup_mouseAdapter - - /** - * IDE Bean Constructor - */ - public VDate() - { - this (DisplayType.Date); - } // VDate - - /** - * Simple Constructor - * @param displayType display Type - */ - public VDate (int displayType) - { - this("Date", false, false, true, displayType, "Date"); - } // VDate - - /** - * Create right aligned Date field - * @param columnName column name - * @param mandatory mandatory - * @param isReadOnly read only - * @param isUpdateable updateable - * @param displayType display type - * @param title title - */ - public VDate(String columnName, boolean mandatory, boolean isReadOnly, boolean isUpdateable, - int displayType, String title) - { - super(); - super.setName(columnName); - m_columnName = columnName; - m_title = title; - // - LookAndFeel.installBorder(this, "TextField.border"); - this.setLayout(new BorderLayout()); - this.setFocusable(false); - // Size - this.setPreferredSize(m_text.getPreferredSize()); - int height = m_text.getPreferredSize().height; - setMinimumSize(new Dimension (30,height)); - - VDate_mouseAdapter mouse = new VDate_mouseAdapter(this); // popup - m_text.addMouseListener(mouse); - - // *** Text *** - m_text.setBorder(null); - m_text.setHorizontalAlignment(JTextField.TRAILING); - if (m_displayType == DisplayType.Date) - { - m_text.addFocusListener(this); - m_text.addKeyListener(this); - m_text.setCaret(new VOvrCaret()); - } - else if (m_displayType == DisplayType.DateTime) - m_text.setColumns(20); - // Background - setMandatory(mandatory); - this.add(m_text, BorderLayout.CENTER); - // - if (displayType == DisplayType.DateTime || displayType == DisplayType.Time) - m_displayType = displayType; // default = Date - setFormat(); - - // *** Button *** - m_button.setIcon(Env.getImageIcon("Calendar10.gif")); - m_button.setMargin(new Insets(0, 0, 0, 0)); - m_button.setPreferredSize(new Dimension(height, height)); - m_button.addActionListener(this); - m_button.setFocusable(false); - this.add(m_button, BorderLayout.EAST); - - // Prefereed Size - this.setPreferredSize(this.getPreferredSize()); // causes r/o to be the same length - - // ReadWrite - if (isReadOnly || !isUpdateable) - setReadWrite(false); - else - setReadWrite(true); - } // VDate - - /** - * Dispose - */ - public void dispose() - { - m_text = null; - m_button = null; - m_mField = null; - } // dispose - - /** - * Set Document - * @param doc doc - */ - protected void setDocument(Document doc) - { - m_text.setDocument(doc); - } // getDocument - - private String m_columnName; - protected int m_displayType = DisplayType.Date; - private String m_title; - private boolean m_setting; - private String m_oldText; - private String m_initialText; - // - private SimpleDateFormat m_format; - // - private boolean m_readWrite; - private boolean m_mandatory; - - /** The Text Field */ - private CTextField m_text = new CTextField (12); - /** The Button */ - private CButton m_button = new CButton(); - - // Popup - JPopupMenu popupMenu = new JPopupMenu(); - // Field for Value Preference - private GridField m_mField = null; - /** Logger */ - private static CLogger log = CLogger.getCLogger(VDate.class); - - /** - * Set ReadWrite - field is always r/o for Time or DateTime - * @param value value - */ - public void setReadWrite (boolean value) - { - m_readWrite = value; - // this.setFocusable(value); - // editor - if (m_displayType == DisplayType.Date) - m_text.setReadWrite(value); // sets Background - else - { - m_text.setEditable(false); - m_text.setFocusable(false); - setBackground(false); - } - - // Don't show button if not ReadWrite - if (m_button.isVisible() != value) - m_button.setVisible(value); - if (m_button.isEnabled() != value) - m_button.setEnabled(value); - } // setReadWrite - - /** - * IsReadWrite - * @return true if rw - */ - public boolean isReadWrite() - { - return m_readWrite; - } // isReadWrite - - /** - * Set Mandatory (and back bolor) - * @param mandatory mandatory - */ - public void setMandatory (boolean mandatory) - { - m_mandatory = mandatory; - m_text.setMandatory(mandatory); - setBackground(false); - } // setMandatory - - /** - * Is it mandatory - * @return true if mandatory - */ - public boolean isMandatory() - { - return m_mandatory; - } // isMandatory - - /** - * Set Background based on ReadWrite / mandatory / error - * @param error if true, set background to error color, otherwise mandatory/ReadWrite - */ - public void setBackground (boolean error) - { - if (error) - m_text.setBackground(AdempierePLAF.getFieldBackground_Error()); - else if (!m_readWrite) - m_text.setBackground(AdempierePLAF.getFieldBackground_Inactive()); - else if (m_mandatory) - m_text.setBackground(AdempierePLAF.getFieldBackground_Mandatory()); - else - m_text.setBackground(AdempierePLAF.getFieldBackground_Normal()); - } // setBackground - - /** - * Set Foreground - * @param fg color - */ - public void setForeground(Color fg) - { - m_text.setForeground(fg); - } // setForeground - - /** - * Set Format - * Required when Format/Locale changed - */ - public void setFormat() - { - m_format = DisplayType.getDateFormat(m_displayType); - if (m_displayType == DisplayType.Date) - m_text.setDocument(new MDocDate(m_displayType, m_format, m_text, m_title)); - } // setFormat - - /** - * Request Focus - */ - public void requestFocus () - { - m_text.requestFocus (); - } // requestFocus - - /** - * Request Focus In Window - * @return focus request - */ - @Override - public boolean requestFocusInWindow() - { - return m_text.requestFocusInWindow(); - } // requestFocusInWindow - - /** - * Get Focus Component - * @return component - */ - public Component getFocusableComponent() - { - return m_text; - } // getFocusComponent - - /** - * Set Editor to value - * @param value timestamp/date or String to be parsed - */ - public void setValue (Object value) - { - if (log.isLoggable(Level.FINEST)) log.finest("Value=" + value); - m_oldText = ""; - if (value == null) - ; - else if (value instanceof java.util.Date) - m_oldText = m_format.format(value); - else - { - String strValue = value.toString(); - // String values - most likely in YYYY-MM-DD (JDBC format) - try - { - java.util.Date date = DisplayType.getDateFormat_JDBC().parse (strValue); - m_oldText = m_format.format(date); // convert to display value - } - catch (ParseException pe0) - { - // Try local string format - try - { - java.util.Date date = m_format.parse(strValue); - m_oldText = m_format.format(date); - } - catch (ParseException pe1) - { - log.log(Level.SEVERE, "setValue - " + pe1.getMessage()); - m_oldText = ""; - } - } - } - if (m_setting) - return; - m_text.setText(m_oldText); - m_initialText = m_oldText; - } // setValue - - /** - * Property Change Listener - * @param evt event - */ - public void propertyChange (PropertyChangeEvent evt) - { - if (evt.getPropertyName().equals(GridField.PROPERTY)) - setValue(evt.getNewValue()); - } // propertyChange - - /** - * Return Editor value - * @return value - */ - public Timestamp getTimestamp() - { - if (m_text == null) - return null; - String value = m_text.getText(); - if (value == null || value.length() == 0) - return null; - // - Timestamp ts = null; - try - { - java.util.Date date = m_format.parse(value); - ts = new Timestamp(date.getTime()); - } - catch (ParseException pe) - { - if (log.isLoggable(Level.FINE)) log.fine(pe.getMessage()); - } - return ts; - } // getValue - - /** - * Return Editor value (Timestamp) - * @return value - */ - public Object getValue() - { - return getTimestamp(); - } // getValue - - /** - * Return Display Value - * @return display value - */ - public String getDisplay() - { - return m_text.getText(); - } // getDisplay - - - /************************************************************************** - * Action Listener (Button) - * @param e event - */ - public void actionPerformed (ActionEvent e) - { - // Preference - if (e.getActionCommand().equals(ValuePreference.NAME)) - { - if (MRole.getDefault().isShowPreference() && !m_mField.isEncrypted() && !m_mField.isEncryptedColumn()) - ValuePreference.start (m_mField, getValue(), getDisplay()); - return; - } - else if (e.getActionCommand().equals(FieldRecordInfo.CHANGE_LOG_COMMAND)) - { - FieldRecordInfo.start(m_mField); - return; - } - if (e.getSource() == m_button) - { - m_button.setEnabled(false); - setValue(startCalendar(this, getTimestamp(), m_format, m_displayType, m_title)); - try - { - fireVetoableChange (m_columnName, m_oldText, getValue()); - } - catch (PropertyVetoException pve) {} - m_button.setEnabled(true); - m_text.requestFocus(); - } - } // actionPerformed - - /** - * Action Listener Interface (Text) - * @param listener listener - */// addActionListener - - /************************************************************************** - * Key Listener Interface - * @param e Event - */ - public void keyTyped(KeyEvent e) {} - public void keyPressed(KeyEvent e) {} - - /** - * Key Listener. - * - Escape - Restore old Text - * - firstChange - signal change - * @param e event - */ - public void keyReleased(KeyEvent e) - { - if (log.isLoggable(Level.FINEST)) log.finest("Key=" + e.getKeyCode() + " - " + e.getKeyChar() - + " -> " + m_text.getText()); - // ESC - if (e.getKeyCode() == KeyEvent.VK_ESCAPE) - m_text.setText(m_initialText); - } // keyReleased - - /** - * Focus Gained - Save for Escape - * @param e event - */ - public void focusGained (FocusEvent e) - { - } // focusGained - - /** - * Data Binding to to GridController. - * @param e event - */ - public void focusLost (FocusEvent e) - { - m_setting = true; - try - { - Timestamp ts = getTimestamp(); // getValue - if (ts == null) // format error - just indicate change - fireVetoableChange (m_columnName, m_oldText, null); - else - fireVetoableChange (m_columnName, m_oldText, ts); - } - catch (PropertyVetoException pve) {} - m_setting = false; - - // did not get Focus first - if (e.isTemporary()) - return; - // log.config( "VDate.focusLost"); - if (m_text == null || m_text.getText() == null) - return; - Object value = getValue(); - setValue(value); - } // focusLost - - /** - * Invalid Entry - Start Calendar - * @param jc parent - * @param value value - * @param format format - * @param displayType display type - * @param title title - * @return formatted Date - */ - public static Timestamp startCalendar(Container jc, Timestamp value, - SimpleDateFormat format, int displayType, String title) - { - if (log.isLoggable(Level.CONFIG)) log.config("Date=" + value); - - // Find frame - Frame frame = AEnv.getFrame(jc); - // Actual Call - Calendar cal = new Calendar(frame, title, value, displayType); - AEnv.showCenterWindow(frame, cal); - Timestamp result = cal.getTimestamp(); - if (log.isLoggable(Level.CONFIG)) log.config( "Result=" + result); - if (result == null) - result = value; // original - else if (result.compareTo(new Timestamp(-1))==0) - result = null; - cal = null; - return result; - } // startCalendar - - /** - * Set Field/WindowNo for ValuePreference - * @param mField MField - */ - public void setField (GridField mField) - { - m_mField = mField; - if (m_mField != null - && MRole.getDefault().isShowPreference() - && !mField.isEncrypted() && !mField.isEncryptedColumn()) - ValuePreference.addMenu (this, popupMenu); - if (m_mField != null) - FieldRecordInfo.addMenu(this, popupMenu); - } // setField - - @Override - public GridField getField() { - return m_mField; - } - - /** - * Set Enabled - * @param enabled enabled - */ - public void setEnabled (boolean enabled) - { - super.setEnabled(enabled); - m_text.setEnabled(enabled); - m_button.setEnabled(enabled); - if (enabled) - m_button.setReadWrite(m_readWrite); - } // setEnabled - - /************************************************************************** - * Remove Action Listner - * @param l Action Listener - */ - public void removeActionListener(ActionListener l) - { - listenerList.remove(ActionListener.class, l); - } // removeActionListener - - /** - * Add Action Listner - * @param l Action Listener - */ - public void addActionListener(ActionListener l) - { - listenerList.add(ActionListener.class, l); - } // addActionListener - - /** - * Fire Action Event to listeners - * - protected void fireActionPerformed() - { - int modifiers = 0; - AWTEvent currentEvent = EventQueue.getCurrentEvent(); - if (currentEvent instanceof InputEvent) - modifiers = ((InputEvent)currentEvent).getModifiers(); - else if (currentEvent instanceof ActionEvent) - modifiers = ((ActionEvent)currentEvent).getModifiers(); - ActionEvent ae = new ActionEvent (this, ActionEvent.ACTION_PERFORMED, - "VDate", EventQueue.getMostRecentEventTime(), modifiers); - - // Guaranteed to return a non-null array - Object[] listeners = listenerList.getListenerList(); - // Process the listeners last to first, notifying those that are interested in this event - for (int i = listeners.length-2; i>=0; i-=2) - { - if (listeners[i]==ActionListener.class) - { - ((ActionListener)listeners[i+1]).actionPerformed(ae); - } - } - } // fireActionPerformed - /**/ - - @Override - public void setBackground(Color bg) - { - m_text.setBackground(bg); - } -} // VDate \ No newline at end of file diff --git a/org.adempiere.ui.swing/src/org/compiere/grid/ed/VDocAction.java b/org.adempiere.ui.swing/src/org/compiere/grid/ed/VDocAction.java deleted file mode 100644 index 5b0e30b97e..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/grid/ed/VDocAction.java +++ /dev/null @@ -1,440 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ -package org.compiere.grid.ed; - -import java.awt.BorderLayout; -import java.awt.Dimension; -import java.awt.FlowLayout; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.util.ArrayList; -import java.util.logging.Level; - -import javax.swing.JButton; -import javax.swing.JLabel; -import javax.swing.JScrollPane; -import javax.swing.JTextArea; - -import org.adempiere.plaf.AdempierePLAF; -import org.compiere.apps.ADialog; -import org.compiere.apps.AEnv; -import org.compiere.apps.ConfirmPanel; -import org.compiere.model.GridTab; -import org.compiere.model.MAllocationHdr; -import org.compiere.model.MBankStatement; -import org.compiere.model.MDocType; -import org.compiere.model.MPeriod; -import org.compiere.model.MProduction; -import org.compiere.model.MTable; -import org.compiere.model.PO; -import org.compiere.process.DocAction; -import org.compiere.process.DocumentEngine; -import org.compiere.swing.CComboBox; -import org.compiere.swing.CDialog; -import org.compiere.swing.CPanel; -import org.compiere.util.CLogger; -import org.compiere.util.DB; -import org.compiere.util.Env; -import org.compiere.util.Msg; -import org.compiere.wf.MWFActivity; - -/** - * Displays valid Document Action Options based on context - * - * @author Jorg Janke - * @version $Id: VDocAction.java,v 1.2 2006/07/30 00:51:28 jjanke Exp $ - */ -public class VDocAction extends CDialog - implements ActionListener -{ - /** - * - */ - private static final long serialVersionUID = -7800828832602048052L; - - /** - * Constructor. - * Started from APanel. - * getNumberOfOptions()is used to determine to show the dialog - * @param WindowNo window no - * @param mTab tab - * @param Record_ID record id - * @param button button - */ - public VDocAction (int WindowNo, GridTab mTab, VButton button, int Record_ID) - { - super(AEnv.getWindow(WindowNo), Msg.translate(Env.getCtx(), "DocAction"), true); - log.config(""); - m_WindowNo = WindowNo; - m_mTab = mTab; - // - try - { - jbInit(); - } - catch(Exception ex) - { - log.log(Level.SEVERE, "", ex); - } - - // dynamic init preparation - m_AD_Table_ID = mTab.getAD_Table_ID(); - if (s_value == null) - readReference(); - // - dynInit(Record_ID); - // - AEnv.positionCenterWindow(AEnv.getWindow(WindowNo), this); - } // VDocAction - - // - private int m_WindowNo = 0; - private int m_AD_Table_ID; - private boolean m_OKpressed = false; - private boolean m_batch = false; - private GridTab m_mTab; - // - private static String[] s_value = null; - private static String[] s_name; - private static String[] s_description; - /** Logger */ - private static CLogger log = CLogger.getCLogger(VDocAction.class); - // - private CPanel mainPanel = new CPanel(); - private BorderLayout mainLayout = new BorderLayout(); - private CPanel northPanel = new CPanel(); - private CComboBoxactionCombo = new CComboBox(); - private JLabel actionLabel = new JLabel(); - private JScrollPane centerPane = new JScrollPane(); - private JTextArea message = new JTextArea(); - private FlowLayout northLayout = new FlowLayout(); - private ConfirmPanel confirmPanel = new ConfirmPanel(true); - private JButton batchButton = ConfirmPanel.createProcessButton( - Msg.getMsg(Env.getCtx(), "StartBackground")); - - /** - * Static Init - * @throws Exception - */ - void jbInit() throws Exception - { - mainPanel.setLayout(mainLayout); - actionLabel.setText(Msg.translate(Env.getCtx(), "DocAction")); - actionCombo.addActionListener(this); - message.setLineWrap(true); - message.setPreferredSize(new Dimension(350, 35)); - message.setWrapStyleWord(true); - message.setBackground(AdempierePLAF.getFieldBackground_Inactive()); - message.setEditable(false); - northPanel.setLayout(northLayout); - northLayout.setAlignment(FlowLayout.RIGHT); - getContentPane().add(mainPanel); - mainPanel.add(northPanel, BorderLayout.NORTH); - northPanel.add(actionLabel, null); - northPanel.add(actionCombo, null); - mainPanel.add(centerPane, BorderLayout.CENTER); - centerPane.getViewport().add(message, null); - // - mainPanel.add(confirmPanel, BorderLayout.SOUTH); - confirmPanel.addButton(batchButton); - confirmPanel.addActionListener(this); - batchButton.addActionListener(this); - } // jbInit - - /** - * Dynamic Init - determine valid DocActions based on DocStatus for the different documents. - *
    -	 *  DocStatus (131)
    -			??                         Unknown
    -			AP *                       Approved
    -			CH                         Changed
    -			CL *                       Closed
    -			CO *                       Completed
    -			DR                         Drafted
    -			IN                         Inactive
    -			NA                         Not Approved
    -			PE                         Posting Error
    -			PO *                       Posted
    -			PR *                       Printed
    -			RE                         Reversed
    -			TE                         Transfer Error
    -			TR *                       Transferred
    -			VO *                       Voided
    -			XX                         Being Processed
    -	 *
    -	 *   DocAction (135)
    -			--                         
    -			AP *                       Approve
    -			CL *                       Close
    -			CO *                       Complete
    -			PO *                       Post
    -			PR *                       Print
    -			RA                         Reverse - Accrual
    -			RC                         Reverse - Correction
    -			RE                         RE-activate
    -			RJ                         Reject
    -			TR *                       Transfer
    -			VO *                       Void
    -			XL                         Unlock
    -	 *  
    - * @param Record_ID id - */ - private void dynInit(int Record_ID) - { - String DocStatus = (String)m_mTab.getValue("DocStatus"); - String DocAction = (String)m_mTab.getValue("DocAction"); - // - Object Processing = m_mTab.getValue("Processing"); - String OrderType = Env.getContext(Env.getCtx(), m_WindowNo, "OrderType"); - String IsSOTrx = Env.getContext(Env.getCtx(), m_WindowNo, "IsSOTrx"); - - if (DocStatus == null) - { - message.setText("*** ERROR ***"); - return; - } - - if (log.isLoggable(Level.FINE)) log.fine("DocStatus=" + DocStatus - + ", DocAction=" + DocAction + ", OrderType=" + OrderType - + ", IsSOTrx=" + IsSOTrx + ", Processing=" + Processing - + ", AD_Table_ID=" + m_AD_Table_ID + ", Record_ID=" + Record_ID); - // - String[] options = new String[s_value.length]; - int index = 0; - - /** - * Check Existence of Workflow Activities - */ - String wfStatus = MWFActivity.getActiveInfo(Env.getCtx(), m_AD_Table_ID, Record_ID); - if (wfStatus != null) - { - ADialog.error(m_WindowNo, this, "WFActiveForRecord", wfStatus); - return; - } - - // Status Change - if (!checkStatus(m_mTab.getTableName(), Record_ID, DocStatus)) - { - ADialog.error(m_WindowNo, this, "DocumentStatusChanged"); - return; - } - - /******************* - * General Actions - */ - MTable table = MTable.get(Env.getCtx(), m_AD_Table_ID); - PO po = table.getPO(Record_ID, null); - boolean periodOpen = true; - if (po instanceof DocAction) - periodOpen = MPeriod.isOpen(Env.getCtx(), m_AD_Table_ID, Record_ID, null); - - String[] docActionHolder = new String[] {DocAction}; - index = DocumentEngine.getValidActions(DocStatus, Processing, OrderType, IsSOTrx, m_AD_Table_ID, - docActionHolder, options, periodOpen, po); - - Integer doctypeId = (Integer)m_mTab.getValue("C_DocType_ID"); - if(doctypeId==null || doctypeId.intValue()==0){ - doctypeId = (Integer)m_mTab.getValue("C_DocTypeTarget_ID"); - } - if (doctypeId == null && MAllocationHdr.Table_ID == m_AD_Table_ID) { - doctypeId = MDocType.getDocType(MDocType.DOCBASETYPE_PaymentAllocation); - } - if (doctypeId == null && MBankStatement.Table_ID == m_AD_Table_ID) { - doctypeId = MDocType.getDocType(MDocType.DOCBASETYPE_BankStatement); - } - if (doctypeId == null && MProduction.Table_ID == m_AD_Table_ID) { - doctypeId = MDocType.getDocType(MDocType.DOCBASETYPE_MaterialProduction); - } - if (log.isLoggable(Level.FINE)) log.fine("get doctype: " + doctypeId); - if (doctypeId != null) { - index = DocumentEngine.checkActionAccess(Env.getAD_Client_ID(Env.getCtx()), - Env.getAD_Role_ID(Env.getCtx()), - doctypeId, options, index); - } - - DocAction = docActionHolder[0]; - - /** - * Fill actionCombo - */ - for (int i = 0; i < index; i++) - { - // Search for option and add it - boolean added = false; - for (int j = 0; j < s_value.length && !added; j++) - if (options[i].equals(s_value[j])) - { - actionCombo.addItem(s_name[j]); - added = true; - } - } - - // setDefault - if (DocAction.equals("--")) // If None, suggest closing - DocAction = DocumentEngine.ACTION_Close; - String defaultV = ""; - for (int i = 0; i < s_value.length && defaultV.equals(""); i++) - if (DocAction.equals(s_value[i])) - defaultV = s_name[i]; - if (!defaultV.equals("")) - actionCombo.setSelectedItem(defaultV); - } // dynInit - - /** - * Check Status Change - * @param TableName table name - * @param Record_ID record - * @param DocStatus current doc status - * @return true if status not changed - */ - private boolean checkStatus (String TableName, int Record_ID, String DocStatus) - { - String sql = "SELECT 2 FROM " + TableName - + " WHERE " + TableName + "_ID=" + Record_ID - + " AND DocStatus='" + DocStatus + "'"; - int result = DB.getSQLValue(null, sql); - return result == 2; - } // checkStatusChange - - - /** - * Number of options available (to decide to display it) - * @return item count - */ - public int getNumberOfOptions() - { - return actionCombo.getItemCount(); - } // getNumberOfOptions - - /** - * Should the process be started? - * @return OK pressed - */ - public boolean isStartProcess() - { - return m_OKpressed; - } // isStartProcess - - /** - * Should the process be started in batch? - * @return batch - */ - public boolean isBatch() - { - return m_batch; - } // IsBatch - - /** - * Fill Vector with DocAction Ref_List(135) values - */ - private void readReference() - { - ArrayList v_value = new ArrayList(); - ArrayList v_name = new ArrayList(); - ArrayList v_description = new ArrayList(); - - DocumentEngine.readReferenceList(v_value, v_name, v_description); - - // convert to arrays - int size = v_value.size(); - s_value = new String[size]; - s_name = new String[size]; - s_description = new String[size]; - for (int i = 0; i < size; i++) - { - s_value[i] = (String)v_value.get(i); - s_name[i] = (String)v_name.get(i); - s_description[i] = (String)v_description.get(i); - } - } // readReference - - - /** - * ActionListener - * @param e event - */ - public void actionPerformed(ActionEvent e) - { - m_batch = e.getSource() == batchButton; - if (m_batch || e.getActionCommand().equals(ConfirmPanel.A_OK)) - { - if (save()) - { - dispose(); - m_OKpressed = true; - return; - } - } - else if (e.getActionCommand().equals(ConfirmPanel.A_CANCEL)) - { - dispose(); - return; - } - else if (e.getSource() != actionCombo) - return; - - /** - * ActionCombo: display the description for the selection - */ - int index = getSelectedIndex(); - // Display description - if (index != -1) - { - message.setText(s_description[index]); - // log.finer("DocAction=" + s_name[index] + " - " + s_value[index]); - } - } // actionPerformed - - - /** - * Get index of selected choice - * @return index or -a - */ - private int getSelectedIndex() - { - int index = -1; - - // get Selection - String sel = (String)actionCombo.getSelectedItem(); - if (sel == null) - return index; - - // find it in vector - for (int i = 0; i < s_name.length && index == -1; i++) - if (sel.equals(s_name[i])) - index = i; - // - return index; - } // getSelectedIndex - - /** - * Save to Database - * @return true if saved to Tab - */ - private boolean save() - { - int index = getSelectedIndex(); - if (index == -1) - return false; - - // Save Selection - if (log.isLoggable(Level.CONFIG)) log.config("DocAction=" + s_value[index]); - m_mTab.setValue("DocAction", s_value[index]); - return true; - } // save - -} // VDocAction \ No newline at end of file diff --git a/org.adempiere.ui.swing/src/org/compiere/grid/ed/VEditor.java b/org.adempiere.ui.swing/src/org/compiere/grid/ed/VEditor.java deleted file mode 100644 index 8f22367df8..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/grid/ed/VEditor.java +++ /dev/null @@ -1,113 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ -package org.compiere.grid.ed; - -import java.awt.Color; -import java.awt.Component; -import java.awt.Font; -import java.awt.event.ActionListener; -import java.beans.PropertyChangeListener; -import java.beans.VetoableChangeListener; - -import javax.swing.border.Border; - -import org.compiere.model.GridField; -import org.compiere.swing.CEditor; - -/** - * Editor Interface for single Row Editors (also used as TableCellEditors). - *

    - * Editors fire VetoableChange to inform about new entered values - * and listen to propertyChange (MField.PROPERTY) to receive new values - * or to (MField.ATTRIBUTE) in changes of Background or Editability - * - * @author Jorg Janke - * @version $Id: VEditor.java,v 1.2 2006/07/30 00:51:28 jjanke Exp $ - */ -public interface VEditor extends CEditor, PropertyChangeListener -{ - /** - * Get Column Name - * @return column name - */ - public String getName(); - - /** - * Set Column Name - * @patam columnName name - */ - public void setName(String columnName); - - /** - * Change Listener Interface - * @param listener - */ - public void addVetoableChangeListener(VetoableChangeListener listener); - /** - * Change Listener Interface - * @param listener - */ - public void removeVetoableChangeListener(VetoableChangeListener listener); - /** - * Action Listener - * @param listener - */ - public void addActionListener(ActionListener listener); -// public void removeActionListener(ActionListener listener); - - /** - * Used to set border for table editors - * @param border - */ - public void setBorder(Border border); - - /** - * Set Font - * @param font - */ - public void setFont(Font font); - - /** - * Set Foreground - * @param color - */ - public void setForeground(Color color); - - /** - * Set Field/WindowNo for ValuePreference - * @param mField - */ - public void setField (GridField mField); - - /** - * Get Field/WindowNo for ValuePreference - * @return mField - */ - public GridField getField (); - - /** - * Dispose - */ - public void dispose(); - - /** - * Get Focusable Component - * @return component - */ - public Component getFocusableComponent(); - -} // VEditor diff --git a/org.adempiere.ui.swing/src/org/compiere/grid/ed/VEditorFactory.java b/org.adempiere.ui.swing/src/org/compiere/grid/ed/VEditorFactory.java deleted file mode 100644 index 001638010f..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/grid/ed/VEditorFactory.java +++ /dev/null @@ -1,103 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ -package org.compiere.grid.ed; - -import java.util.List; - -import org.adempiere.base.Service; -import org.adempiere.ui.swing.factory.IEditorFactory; -import org.compiere.model.GridField; -import org.compiere.model.GridTab; -import org.compiere.swing.CLabel; -import org.compiere.util.CLogger; -import org.compiere.util.DisplayType; - -/** - * Factory for VEditor and its Label for single Row display and multi row-editor - * - * @see VCellRenderer for multi-row display - * @author Jorg Janked - * @version $Id: VEditorFactory.java,v 1.3 2006/07/30 00:51:28 jjanke Exp $ - */ -public class VEditorFactory -{ - /** - * Create Editor for MField. - * The Name is set to the column name for dynamic display management - * @param mField MField - * @param tableEditor true if table editor - * @return grid editor - */ - public static VEditor getEditor (GridField mField, boolean tableEditor) - { - return getEditor (null, mField, tableEditor); - } // getEditor - - /** - * Create Editor for MField. - * The Name is set to the column name for dynamic display management - * @param mTab MTab - * @param mField MField - * @param tableEditor true if table editor - * @return grid editor - */ - public static VEditor getEditor (GridTab mTab, GridField mField, boolean tableEditor) - { - VEditor editor = null; - List factoryList = Service.locator().list(IEditorFactory.class).getServices(); - for(IEditorFactory factory : factoryList) - { - editor = factory.getEditor(mTab, mField, tableEditor); - if (editor != null) - break; - } - return editor; - } // getEditor - - /** - * Create Label for MField. (null for YesNo/Button) - * The Name is set to the column name for dynamic display management - * - * @param mField MField - * @return Label - */ - public static CLabel getLabel (GridField mField) - { - if (mField == null) - return null; - - int displayType = mField.getDisplayType(); - - // No Label for FieldOnly, CheckBox, Button - if (mField.isFieldOnly() - || displayType == DisplayType.YesNo - || displayType == DisplayType.Button) - return null; - // - CLabel label = new CLabel(mField.getHeader(), mField.getDescription()); - label.setName(mField.getColumnName()); - // label.setFont(AdempierePLAF.getFont_Label()); - // label.setForeground(AdempierePLAF.getTextColor_Label()); - return label; - } // getLabel - - /** Logger */ - @SuppressWarnings("unused") - private static CLogger log = CLogger.getCLogger(VEditorFactory.class); - - -} // VEditorFactory diff --git a/org.adempiere.ui.swing/src/org/compiere/grid/ed/VFile.java b/org.adempiere.ui.swing/src/org/compiere/grid/ed/VFile.java deleted file mode 100644 index 6bd97eb14d..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/grid/ed/VFile.java +++ /dev/null @@ -1,459 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ -package org.compiere.grid.ed; - -import java.awt.BorderLayout; -import java.awt.Color; -import java.awt.Component; -import java.awt.Dimension; -import java.awt.Insets; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.awt.event.FocusEvent; -import java.awt.event.FocusListener; -import java.awt.event.KeyEvent; -import java.awt.event.KeyListener; -import java.awt.event.MouseEvent; -import java.beans.PropertyChangeEvent; -import java.beans.PropertyVetoException; -import java.io.File; -import java.util.logging.Level; - -import javax.swing.JComponent; -import javax.swing.JFileChooser; -import javax.swing.LookAndFeel; - -import org.adempiere.plaf.AdempierePLAF; -import org.compiere.model.GridField; -import org.compiere.swing.CButton; -import org.compiere.swing.CTextField; -import org.compiere.util.CLogger; -import org.compiere.util.Env; -import org.compiere.util.Msg; - -/** - * File/Path Selection - * - * @author Initial: Jirimuto - * @version $Id: VFile.java,v 1.2 2006/07/30 00:51:28 jjanke Exp $ - * - * @author Teo Sarca - */ -public class VFile extends JComponent - implements VEditor, ActionListener, KeyListener, FocusListener -{ - /** - * - */ - private static final long serialVersionUID = 1381828235230540932L; - - /****************************************************************************** - * Mouse Listener for Popup Menu - */ - final class VFile_mouseAdapter extends java.awt.event.MouseAdapter - { - /** - * Constructor - * @param adaptee adaptee - */ - VFile_mouseAdapter(VFile adaptee) - { - m_adaptee = adaptee; - } // VLookup_mouseAdapter - - @SuppressWarnings("unused") - private VFile m_adaptee; - - /** - * Mouse Listener - * @param e MouseEvent - */ - public void mouseClicked(MouseEvent e) - { - - } // mouse Clicked - - } // VFile_mouseAdapter - - /** - * Constructor - * - * @param columnName column name - * @param mandatory mandatory - * @param isReadOnly read only - * @param isUpdateable updateable - * @param files Files only if false Directory only - */ - public VFile(String columnName, boolean mandatory, - boolean isReadOnly, boolean isUpdateable, int fieldLength, boolean files) - { - super(); - super.setName(columnName); - m_columnName = columnName; - m_fieldLength = fieldLength; - if (files) // default Directories - m_selectionMode = JFileChooser.FILES_ONLY; - String col = columnName.toLowerCase(); - if (col.indexOf("open") != -1 || col.indexOf("load") != -1) - m_dialogType = JFileChooser.OPEN_DIALOG; - else if (col.indexOf("save") != -1) - m_dialogType = JFileChooser.SAVE_DIALOG; - // - LookAndFeel.installBorder(this, "TextField.border"); - this.setLayout(new BorderLayout()); - // Size - this.setPreferredSize(m_text.getPreferredSize()); // causes r/o to be the same length - int height = m_text.getPreferredSize().height; - - // Button - m_button.setIcon(Env.getImageIcon("Open16.gif")); - m_button.setMargin(new Insets(0,0,0,0)); - m_button.setPreferredSize(new Dimension(height, height)); - m_button.addActionListener(this); - this.add(m_button, BorderLayout.EAST); - // *** Button & Text *** - m_text.setBorder(null); - m_text.setEditable(true); - m_text.setFocusable(true); - m_text.setFont(AdempierePLAF.getFont_Field()); - m_text.setForeground(AdempierePLAF.getTextColor_Normal()); - m_text.addMouseListener(new VFile_mouseAdapter(this)); - m_text.addKeyListener(this); - m_text.addFocusListener(this); - this.add(m_text, BorderLayout.CENTER); - - // Editable - if (isReadOnly || !isUpdateable) - setReadWrite (false); - else - setReadWrite (true); - setMandatory (mandatory); - } // VFile - - /** - * Dispose - */ - public void dispose() - { - m_text = null; - m_button = null; - m_field = null; - } // dispose - - /** The Text Field */ - private CTextField m_text = new CTextField(VLookup.DISPLAY_LENGTH); - /** The Button */ - private CButton m_button = new CButton(); - /** Column Name */ - private String m_columnName; - private String m_oldText; - private String m_initialText; - /** Field Length */ - private int m_fieldLength; - /** Setting new value */ - private volatile boolean m_setting = false; - /** Selection Mode */ - private int m_selectionMode = JFileChooser.DIRECTORIES_ONLY; - /** Save/Open */ - private int m_dialogType = JFileChooser.CUSTOM_DIALOG; - /** Logger */ - private static CLogger log = CLogger.getCLogger(VFile.class); - - /** - * Enable/disable - * @param value true if ReadWrite - */ - public void setReadWrite (boolean value) - { - m_button.setReadWrite (value); - if (m_button.isVisible() != value) - m_button.setVisible (value); - m_text.setReadWrite(value); - setBackground(false); - } // setReadWrite - - /** - * IsReadWrite - * @return value true if ReadWrite - */ - public boolean isReadWrite() - { - return m_button.isReadWrite(); - } // isReadWrite - - /** - * Set Mandatory (and back bolor) - * @param mandatory true if mandatory - */ - public void setMandatory (boolean mandatory) - { - m_button.setMandatory(mandatory); - setBackground(false); - } // setMandatory - - /** - * Is it mandatory - * @return true if mandatory - */ - public boolean isMandatory() - { - return m_button.isMandatory(); - } // isMandatory - - /** - * Set Background - * @param color color - */ - public void setBackground (Color color) - { - if (!color.equals(m_text.getBackground())) - m_text.setBackground(color); - } // setBackground - - /** - * Set Background based on editable / mandatory / error - * @param error if true, set background to error color, otherwise mandatory/editable - */ - public void setBackground (boolean error) - { - if (error) - setBackground(AdempierePLAF.getFieldBackground_Error()); - else if (!isReadWrite()) - setBackground(AdempierePLAF.getFieldBackground_Inactive()); - else if (isMandatory()) - setBackground(AdempierePLAF.getFieldBackground_Mandatory()); - else - setBackground(AdempierePLAF.getFieldBackground_Normal()); - } // setBackground - - /** - * Set Foreground - * @param fg color - */ - public void setForeground(Color fg) - { - m_text.setForeground(fg); - } // setForeground - - /** - * Set Editor to value - * @param value value - */ - public void setValue(Object value) - { - if (value == null) - m_oldText = ""; - else - m_oldText = value.toString(); - // only set when not updated here - if (m_setting) - return; - m_text.setText (m_oldText); - m_initialText = m_oldText; - } // setValue - - /** - * Property Change Listener - * @param evt PropertyChangeEvent - */ - public void propertyChange (PropertyChangeEvent evt) - { - if (evt.getPropertyName().equals(org.compiere.model.GridField.PROPERTY)) - setValue(evt.getNewValue()); - } // propertyChange - - /** - * Return Editor value - * @return value - */ - public Object getValue() - { - return m_text.getText(); - } // getValue - - /** - * Return Display Value - * @return display value - */ - public String getDisplay() - { - return m_text.getText(); - } // getDisplay - - /** - * ActionListener - Button - Start Dialog - * @param e ActionEvent - */ - public void actionPerformed(ActionEvent e) - { - String m_value = m_text.getText(); - // - log.config(m_value); - // - String fieldName = null; - if (m_field != null) - fieldName = m_field.getHeader(); - else - fieldName = Msg.getElement(Env.getCtx(), m_columnName); - // - JFileChooser chooser = new JFileChooser(m_value); - chooser.setMultiSelectionEnabled(false); - chooser.setFileSelectionMode(m_selectionMode); - chooser.setDialogTitle(fieldName); - chooser.setDialogType(m_dialogType); - // - int returnVal = -1; - if (m_dialogType == JFileChooser.SAVE_DIALOG) - returnVal = chooser.showSaveDialog(this); - else if (m_dialogType == JFileChooser.OPEN_DIALOG) - returnVal = chooser.showOpenDialog(this); - else // if (m_dialogType == JFileChooser.CUSTOM_DIALOG) - returnVal= chooser.showDialog(this, fieldName); - if (returnVal != JFileChooser.APPROVE_OPTION) - return; - - File selectedFile = chooser.getSelectedFile(); - m_text.setText(selectedFile.getAbsolutePath() ); - // Data Binding - try - { - fireVetoableChange(m_columnName, m_oldText, m_text.getText()); - } - catch (PropertyVetoException pve) - { - } - - } // actionPerformed - - /** - * Action Listener Interface - * @param listener listener - */ - public void addActionListener(ActionListener listener) - { - m_text.addActionListener(listener); - } // addActionListener - - /** - * Action Listener Interface - * @param listener - */ - public void removeActionListener(ActionListener listener) - { - m_text.removeActionListener(listener); - } // removeActionListener - - /** - * Set Field/WindowNo - * @param mField field - */ - public void setField (GridField mField) - { - m_field = mField; - } // setField - - /** Grid Field */ - private GridField m_field = null; - - /** - * Get Field - * @return gridField - */ - public GridField getField() - { - return m_field; - } // getField - - /** - * Request Focus - */ - @Override - public void requestFocus() - { - m_text.requestFocus(); - } // requestFocus - - /** - * Request Focus In Window - * @return focus request - */ - @Override - public boolean requestFocusInWindow() - { - return m_text.requestFocusInWindow(); - } // requestFocusInWindow - - /** - * Get Focus Component - * @return component - */ - public Component getFocusableComponent() - { - return m_text; - } // getFocusComponent - - public void keyPressed(KeyEvent e) { - } - - public void keyTyped(KeyEvent e) { - } - - /** - * Key Released. - * if Escape Restore old Text - * @param e event - * @see java.awt.event.KeyListener#keyReleased(java.awt.event.KeyEvent) - */ - public void keyReleased(KeyEvent e) { - if (log.isLoggable(Level.FINEST)) log.finest("Key=" + e.getKeyCode() + " - " + e.getKeyChar() + " -> " + m_text.getText()); - // ESC - if (e.getKeyCode() == KeyEvent.VK_ESCAPE) - m_text.setText(m_initialText); - // Ignore keys that do not alter the text - else if (e.getKeyChar() == KeyEvent.CHAR_UNDEFINED) - return; - } - - /** - * Focus Gained - Save for Escape - * @param e event - */ - public void focusGained (FocusEvent e) - { - } // focusGained - - /** - * Data Binding to to GridController. - * @param e event - */ - public void focusLost (FocusEvent e) - { - m_setting = true; - try - { - String clear = m_text.getText(); - if (clear.length() > m_fieldLength) - clear = clear.substring(0, m_fieldLength); - fireVetoableChange (m_columnName, m_oldText, clear); - } - catch (PropertyVetoException pve) - { - } - m_setting = false; - } // focusLost - -} // VFile diff --git a/org.adempiere.ui.swing/src/org/compiere/grid/ed/VHeaderRenderer.java b/org.adempiere.ui.swing/src/org/compiere/grid/ed/VHeaderRenderer.java deleted file mode 100644 index a4d8bd4cc5..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/grid/ed/VHeaderRenderer.java +++ /dev/null @@ -1,130 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ -package org.compiere.grid.ed; - -import java.awt.Component; -import java.awt.Dimension; -import java.awt.Insets; - -import javax.swing.Icon; -import javax.swing.JComponent; -import javax.swing.JLabel; -import javax.swing.JTable; -import javax.swing.SwingConstants; -import javax.swing.UIManager; -import javax.swing.table.TableCellRenderer; - -import org.compiere.swing.CButton; -import org.compiere.swing.CTable; -import org.compiere.util.DisplayType; -import org.compiere.util.Env; - -/** - * Table Header Renderer based on Display Type for aligmnet - * - * @author Jorg Janke - * @version $Id: VHeaderRenderer.java,v 1.2 2006/07/30 00:51:28 jjanke Exp $ - */ -public final class VHeaderRenderer implements TableCellRenderer -{ - public VHeaderRenderer() - { - m_button = new CButton(); - m_button.setMargin(new Insets(0,0,0,0)); - m_button.putClientProperty("Plastic.is3D", Boolean.FALSE); - } - - /** - * Constructor - * @param displayType - */ - public VHeaderRenderer(int displayType) - { - super(); - // Alignment - if (DisplayType.isNumeric(displayType)) - m_alignment = JLabel.RIGHT; - else if (displayType == DisplayType.YesNo) - m_alignment = JLabel.CENTER; - else - m_alignment = JLabel.LEFT; - } // VHeaderRenderer - - // for 3D effect in Windows - private CButton m_button; - - private int m_alignment; - - /** - * Get TableCell RendererComponent - * @param table - * @param value - * @param isSelected - * @param hasFocus - * @param row - * @param column - * @return Button - */ - public Component getTableCellRendererComponent(JTable table, Object value, - boolean isSelected, boolean hasFocus, int row, int column) - { - // Log.trace(this,10, "VHeaderRenderer.getTableCellRendererComponent", value==null ? "null" : value.toString()); - // indicator for invisible column - Icon icon = null; - if (table instanceof CTable) - { - CTable cTable = (CTable)table; - if (cTable.getSortColumn() == table.convertColumnIndexToModel(column)) - { - icon = cTable.isSortAscending() - ? Env.getImageIcon2("uparrow") - : Env.getImageIcon2("downarrow"); - } - } - - TableCellRenderer headerRenderer = table.getTableHeader().getDefaultRenderer(); - Component headerComponent = headerRenderer == null ? null : - headerRenderer.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column); - if (headerComponent != null && headerComponent instanceof JComponent) { - if (headerComponent instanceof JLabel ) { - JLabel label = (JLabel)headerComponent; - label.setHorizontalAlignment(m_alignment); - if (value == null) - label.setPreferredSize(new Dimension(0,0)); - else - label.setText(value.toString()); - label.setIcon(icon); - label.setHorizontalTextPosition(SwingConstants.LEADING); - return label; - } - m_button.setBorder(((JComponent)headerComponent).getBorder()); - } else { - m_button.setBorder(UIManager.getBorder("TableHeader.cellBorder")); - } - - if (value == null) - { - m_button.setPreferredSize(new Dimension(0,0)); - return m_button; - } - m_button.setText(value.toString()); - m_button.setIcon(icon); - m_button.setHorizontalTextPosition(SwingConstants.LEADING); - return m_button; - } // getTableCellRendererComponent - -} // VHeaderRenderer diff --git a/org.adempiere.ui.swing/src/org/compiere/grid/ed/VImage.java b/org.adempiere.ui.swing/src/org/compiere/grid/ed/VImage.java deleted file mode 100644 index 35c3ee6673..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/grid/ed/VImage.java +++ /dev/null @@ -1,269 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ -package org.compiere.grid.ed; - -import java.awt.Color; -import java.awt.Component; -import java.awt.Image; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.beans.PropertyChangeEvent; -import java.beans.PropertyVetoException; -import java.util.logging.Level; - -import javax.swing.ImageIcon; -import javax.swing.JButton; - -import org.compiere.apps.AEnv; -import org.compiere.model.GridField; -import org.compiere.model.MImage; -import org.compiere.util.CLogger; -import org.compiere.util.Env; - -/** - * Image Display of AD_Iamge_ID - * - * @author Jorg Janke - * @version $Id: VImage.java,v 1.6 2006/07/30 00:51:28 jjanke Exp $ - */ -public class VImage extends JButton - implements VEditor, ActionListener -{ - /** - * - */ - private static final long serialVersionUID = 2061377580245794385L; - - /** - * Image Editor - * @param columnName column name - * @param WindowNo window no - */ - public VImage (String columnName, int WindowNo) - { - super("-"); - m_columnName = columnName; - m_WindowNo = WindowNo; - super.addActionListener(this); - } // VImage - - /** - * Dispose - */ - public void dispose() - { - m_mImage = null; - } // dispose - - /** WindowNo */ - private int m_WindowNo; - /** The Image Model */ - private MImage m_mImage = null; - /** Mandatory flag */ - private boolean m_mandatory = false; - /** Column Name */ - private String m_columnName = "AD_Image_ID"; - /** Logger */ - private static CLogger log = CLogger.getCLogger(VImage.class); - - /** - * Set Value - * @param value - */ - public void setValue(Object value) - { - final int COLUMNSIZE = 220; - - int newValue = 0; - if (value instanceof Integer) - newValue = ((Integer)value).intValue(); - if (newValue == 0) - { - m_mImage = null; - super.setText("-"); - super.setIcon(null); - super.setDisabledIcon(null); - super.setToolTipText(null); - return; - } - // Get/Create Image - if (m_mImage == null || newValue != m_mImage.get_ID()) - m_mImage = MImage.get (Env.getCtx(), newValue); - // - if (log.isLoggable(Level.FINE)) log.fine(m_mImage.toString()); - super.setText(null); - - if (m_mImage.getImage()==null) - return; - - ImageIcon image = new ImageIcon(m_mImage.getImage()); - if (image.getIconHeight() > COLUMNSIZE || image.getIconWidth() > COLUMNSIZE) { - if (image.getIconHeight() > image.getIconWidth()) { - super.setIcon(new ImageIcon(m_mImage.getImage().getScaledInstance(-1, COLUMNSIZE, Image.SCALE_DEFAULT))); - super.setDisabledIcon(new ImageIcon(m_mImage.getImage().getScaledInstance(-1, COLUMNSIZE, Image.SCALE_DEFAULT))); - } else { - super.setIcon(new ImageIcon(m_mImage.getImage().getScaledInstance(COLUMNSIZE, -1, Image.SCALE_DEFAULT))); - super.setDisabledIcon(new ImageIcon(m_mImage.getImage().getScaledInstance(COLUMNSIZE, -1, Image.SCALE_DEFAULT))); - } - } else { - // the image is smaller than the COLUMNSIZE - super.setIcon(m_mImage.getIcon()); - super.setDisabledIcon(m_mImage.getIcon()); - } - super.setToolTipText(m_mImage.getName()); - invalidate(); - } // setValue - - /** - * Get Value - * @return value - */ - public Object getValue() - { - if (m_mImage == null || m_mImage.get_ID() == 0) - return null; - return Integer.valueOf(m_mImage.get_ID()); - } // getValue - - /** - * Get Display Value - * @return image name - */ - public String getDisplay() - { - return m_mImage.getName(); - } // getDisplay - - /** - * Set ReadWrite - * @param rw - */ - public void setReadWrite (boolean rw) - { - if (isEnabled() != rw) - setEnabled (rw); - } // setReadWrite - - /** - * Get ReadWrite - * @return true if rw - */ - public boolean isReadWrite() - { - return super.isEnabled(); - } // getReadWrite - - /** - * Set Mandatory - * @param mandatory - */ - public void setMandatory (boolean mandatory) - { - m_mandatory = mandatory; - } // setMandatory - - /** - * Get Mandatory - * @return true if mandatory - */ - public boolean isMandatory() - { - return m_mandatory; - } // isMandatory - - /** - * Set Background - nop - * @param color - */ - public void setBackground(Color color) - { - } // setBackground - - /** - * Set Background - nop - */ - public void setBackground() - { - } // setBackground - - /** - * Set Background - nop - * @param error - */ - public void setBackground(boolean error) - { - } // setBackground - - /** - * Property Change - * @param evt - */ - public void propertyChange(PropertyChangeEvent evt) - { - if (evt.getPropertyName().equals(org.compiere.model.GridField.PROPERTY)) - setValue(evt.getNewValue()); - } // propertyChange - - /** - * ActionListener - start dialog and set value - * @param e - */ - public void actionPerformed (ActionEvent e) - { - VImageDialog vid = new VImageDialog(AEnv.getWindow(m_WindowNo), m_mImage); - vid.setVisible(true); - int AD_Image_ID = vid.getAD_Image_ID(); - Integer newValue = null; - if (AD_Image_ID != 0) - newValue = Integer.valueOf(AD_Image_ID); - // - m_mImage = null; // force reload - setValue(newValue); // set explicitly - // - try - { - fireVetoableChange(m_columnName, null, newValue); - } - catch (PropertyVetoException pve) {} - } // actionPerformed - - // Field for Value Preference - private GridField m_mField = null; - /** - * Set Field/WindowNo for ValuePreference (NOP) - * @param mField - */ - public void setField (GridField mField) - { - m_mField = mField; - } // setField - - @Override - public GridField getField() { - return m_mField; - } - - /** - * Get Focus Component - * @return component - */ - public Component getFocusableComponent() - { - return this; - } // getFocusableComponent - -} // VImage diff --git a/org.adempiere.ui.swing/src/org/compiere/grid/ed/VImageDialog.java b/org.adempiere.ui.swing/src/org/compiere/grid/ed/VImageDialog.java deleted file mode 100644 index e4f3828e20..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/grid/ed/VImageDialog.java +++ /dev/null @@ -1,255 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ -package org.compiere.grid.ed; - -import java.awt.BorderLayout; -import java.awt.Color; -import java.awt.Cursor; -import java.awt.Frame; -import java.awt.Image; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.awt.event.ComponentEvent; -import java.awt.event.ComponentListener; -import java.io.ByteArrayOutputStream; -import java.io.File; -import java.io.FileInputStream; -import java.util.logging.Level; - -import javax.swing.BorderFactory; -import javax.swing.ImageIcon; -import javax.swing.JFileChooser; -import javax.swing.JLabel; -import javax.swing.SwingConstants; - -import org.compiere.apps.AEnv; -import org.compiere.apps.ConfirmPanel; -import org.compiere.model.MImage; -import org.compiere.swing.CButton; -import org.compiere.swing.CDialog; -import org.compiere.swing.CLabel; -import org.compiere.swing.CPanel; -import org.compiere.util.CLogger; -import org.compiere.util.Env; -import org.compiere.util.Msg; - -/** - * Image Dialog - * - * @author Jorg Janke - * @version $Id: VImageDialog.java,v 1.4 2006/07/30 00:51:28 jjanke Exp $ - */ -public class VImageDialog extends CDialog - implements ActionListener -{ - /** - * - */ - private static final long serialVersionUID = -2630060904081520523L; - - /** - * Constructor - * @param owner - * @param mImage - */ - public VImageDialog (Frame owner, MImage mImage) - { - super (owner, Msg.translate(Env.getCtx(), "AD_Image_ID"), true); - if (log.isLoggable(Level.INFO)) log.info("MImage=" + mImage); - m_mImage = mImage; - try - { - jbInit(); - } - catch(Exception ex) - { - log.log(Level.SEVERE, "", ex); - } - // load data - if (m_mImage == null) - m_mImage = MImage.get (Env.getCtx(), 0); - fileButton.setText(m_mImage.getName()); - imageLabel.setIcon(m_mImage.getIcon()); - imageLabel.addComponentListener(new ComponentListener() { - - @Override - public void componentHidden(ComponentEvent e) {} - - @Override - public void componentMoved(ComponentEvent e) {} - - @Override - public void componentResized(ComponentEvent e) { - Image image = m_mImage.getImage(); - JLabel label = (JLabel) e.getComponent(); - - System.err.println("iamge:" + image + " M_mImage: " + m_mImage); - - if (image == null) - return; - - int imageheight = image.getWidth(null); - int imagewidth = image.getWidth(null); - int labelheight = label.getHeight(); - int labelwidth = label.getWidth(); - - if (labelheight == 0 || imageheight == 0) - return; - - // check which dimension we have to scale - if ((double) labelwidth / labelheight < (double) imagewidth / imageheight) { - // do not upscale images - if (imagewidth > labelwidth) - label.setIcon(new ImageIcon(m_mImage.getImage().getScaledInstance(label.getWidth(), -1, Image.SCALE_DEFAULT))); - } else { - if (imageheight > labelheight) - label.setIcon(new ImageIcon(m_mImage.getImage().getScaledInstance(-1, label.getHeight(), Image.SCALE_DEFAULT))); - } - } - - @Override - public void componentShown(ComponentEvent e) {} - }); - AEnv.positionCenterWindow(owner, this); - } // VImageDialog - - /** Image Model */ - private MImage m_mImage = null; - /** Logger */ - private static CLogger log = CLogger.getCLogger(VImageDialog.class); - - /** */ - private CPanel mainPanel = new CPanel(); - private BorderLayout mainLayout = new BorderLayout(); - private CPanel parameterPanel = new CPanel(); - private CLabel fileLabel = new CLabel(); - private CButton fileButton = new CButton(); - private CLabel imageLabel = new CLabel(); - private ConfirmPanel confirmPanel = new ConfirmPanel(true); - - /** - * Static Init - * @throws Exception - */ - void jbInit() throws Exception - { - mainPanel.setLayout(mainLayout); - fileLabel.setText(Msg.getMsg(Env.getCtx(), "SelectFile")); - fileButton.setText("-"); - imageLabel.setBackground(Color.white); - imageLabel.setBorder(BorderFactory.createRaisedBevelBorder()); - // imageLabel.setPreferredSize(new Dimension(50, 50)); - imageLabel.setHorizontalAlignment(SwingConstants.CENTER); - getContentPane().add(mainPanel); - mainPanel.add(parameterPanel, BorderLayout.NORTH); - parameterPanel.add(fileLabel, null); - parameterPanel.add(fileButton, null); - mainPanel.add(imageLabel, BorderLayout.CENTER); - mainPanel.add(confirmPanel, BorderLayout.SOUTH); - // - fileButton.addActionListener(this); - confirmPanel.addActionListener(this); - } // jbInit - - /** - * ActionListener - * @param e - */ - public void actionPerformed (ActionEvent e) - { - if (e.getSource() == fileButton) - cmd_file(); - - else if (e.getActionCommand().equals(ConfirmPanel.A_OK)) - { - setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); - if (m_mImage.save()) - dispose(); - else - setCursor(Cursor.getDefaultCursor()); - } - - else if (e.getActionCommand().equals(ConfirmPanel.A_CANCEL)) - { - m_mImage = null; // reset - dispose(); - } - } // actionPerformed - - /** - * Load file & display - */ - private void cmd_file() - { - // Show File Open Dialog - JFileChooser jfc = new JFileChooser(); - jfc.setMultiSelectionEnabled(false); - jfc.setFileSelectionMode(JFileChooser.FILES_ONLY); - jfc.showOpenDialog(this); - - // Get File Name - File imageFile = jfc.getSelectedFile(); - if (imageFile == null || imageFile.isDirectory() || !imageFile.exists()) - return; - - String fileName = imageFile.getAbsolutePath(); - byte[] data = null; - - // See if we can load & display it - try - { - FileInputStream fis = new FileInputStream(imageFile); - ByteArrayOutputStream os = new ByteArrayOutputStream(); - byte[] buffer = new byte[1024*8]; // 8kB - int length = -1; - while ((length = fis.read(buffer)) != -1) - os.write(buffer, 0, length); - fis.close(); - data = os.toByteArray(); - os.close(); - // - ImageIcon image = new ImageIcon (data, fileName); - imageLabel.setIcon(image); - } - catch (Exception e) - { - log.log(Level.WARNING, "load image", e); - return; - } - - // OK - fileButton.setText(imageFile.getAbsolutePath()); - pack(); - - // Save info - m_mImage.setName(fileName); - m_mImage.setImageURL(fileName); - m_mImage.setBinaryData(data); - } // cmd_file - - /** - * Get Image ID - * @return ID or 0 - */ - public int getAD_Image_ID() - { - if (m_mImage != null) - return m_mImage.getAD_Image_ID(); - return 0; - } // getAD_Image_ID - -} // VImageDialog diff --git a/org.adempiere.ui.swing/src/org/compiere/grid/ed/VLine.java b/org.adempiere.ui.swing/src/org/compiere/grid/ed/VLine.java deleted file mode 100644 index e7baf28b0c..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/grid/ed/VLine.java +++ /dev/null @@ -1,143 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ -package org.compiere.grid.ed; - -import java.awt.Color; -import java.awt.Component; -import java.awt.Font; -import java.awt.Graphics; - -import javax.swing.border.AbstractBorder; - -import org.adempiere.plaf.AdempierePLAF; -import org.compiere.util.Language; - -/** - * Horizontal Line with Text - * - * @author Jorg Janke - * @version $Id: VLine.java,v 1.2 2006/07/30 00:51:28 jjanke Exp $ - */ -public class VLine extends AbstractBorder -{ - /** - * - */ - private static final long serialVersionUID = -3510090015856709962L; - - /** - * IDE Bean Constructor - */ - public VLine() - { - this(""); - } // VLine - - /** - * Constructor - * @param header - */ - public VLine(String header) - { - super(); - setHeader(header); - } // VLine - - /** Header */ - private String m_header = ""; - - private Font m_font = AdempierePLAF.getFont_Label(); - private Color m_color = AdempierePLAF.getTextColor_Label(); - - /** Gap between element */ - public final static int GAP = 5; - /** space for characters below line (y) */ - public final static int SPACE = 4; // used in VPanel - - /** - * Paint Border - * @param c the component for which this border is being painted - * @param g the paint graphics - * @param x the x position of the painted border - * @param y the y position of the painted border - * @param w the width of the painted border - * @param h the height of the painted border - */ - public void paintBorder(Component c, Graphics g, int x, int y, int w, int h) - { - Graphics copy = g.create(); - if (copy != null) - { - try - { - copy.translate(x, y); - paintLine(c, copy, w, h); - } - finally - { - copy.dispose(); - } - } - } // paintBorder - - /** - * Paint Line with Header - * @param c - * @param g - * @param w - * @param h - */ - private void paintLine (Component c, Graphics g, int w, int h) - { - int y = h-SPACE; - // Line - g.setColor(Color.darkGray); - g.drawLine(GAP, y, w-GAP, y); - g.setColor(Color.white); - g.drawLine(GAP, y+1, w-GAP, y+1); // last part of line - - if (m_header == null || m_header.length() == 0) - return; - - // Header Text - g.setColor(m_color); - g.setFont(m_font); - if (!Language.getLoginLanguage().isLeftToRight()) - { - } - g.drawString(m_header, GAP, h-SPACE-1); - } // paintLine - - /** - * Set Header - * @param newHeader String - '_' are replaced by spaces - */ - public void setHeader(String newHeader) - { - m_header = newHeader.replace('_', ' '); - } // setHeader - - /** - * Get Header - * @return header string - */ - public String getHeader() - { - return m_header; - } // getHeader - -} // VLine diff --git a/org.adempiere.ui.swing/src/org/compiere/grid/ed/VLocation.java b/org.adempiere.ui.swing/src/org/compiere/grid/ed/VLocation.java deleted file mode 100644 index 7d085750b9..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/grid/ed/VLocation.java +++ /dev/null @@ -1,433 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ -package org.compiere.grid.ed; - -import java.awt.BorderLayout; -import java.awt.Color; -import java.awt.Component; -import java.awt.Dimension; -import java.awt.Insets; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.awt.event.MouseEvent; -import java.beans.PropertyChangeEvent; -import java.beans.PropertyVetoException; -import java.util.logging.Level; - -import javax.swing.JComponent; -import javax.swing.JPopupMenu; -import javax.swing.JTextField; -import javax.swing.LookAndFeel; -import javax.swing.SwingUtilities; - -import org.adempiere.plaf.AdempierePLAF; -import org.compiere.apps.AEnv; -import org.compiere.apps.FieldRecordInfo; -import org.compiere.model.GridField; -import org.compiere.model.GridTab; -import org.compiere.model.MLocation; -import org.compiere.model.MLocationLookup; -import org.compiere.swing.CButton; -import org.compiere.swing.CMenuItem; -import org.compiere.util.CLogger; -import org.compiere.util.Env; -import org.compiere.util.Msg; - -/** - * Location Control (Address) - * - * @author Jorg Janke - * @version $Id: VLocation.java,v 1.2 2006/07/30 00:51:28 jjanke Exp $ - */ -public class VLocation extends JComponent - implements VEditor, ActionListener -{ - /** - * - */ - private static final long serialVersionUID = -8952858645752621513L; - - /** - * Mouse Listener for Popup Menu - */ - final class VLocation_mouseAdapter extends java.awt.event.MouseAdapter - { - /** - * Constructor - * @param adaptee adaptee - */ - VLocation_mouseAdapter(VLocation adaptee) - { - this.adaptee = adaptee; - } // VLookup_mouseAdapter - - private VLocation adaptee; - - /** - * Mouse Listener - * @param e MouseEvent - */ - public void mouseClicked(MouseEvent e) - { - // popup menu - if (SwingUtilities.isRightMouseButton(e)) - adaptee.popupMenu.show((Component)e.getSource(), e.getX(), e.getY()); - } // mouse Clicked - - } // VLocation_mouseAdapter - - /** - * Constructor - * - * @param columnName column name - * @param mandatory mandatory - * @param isReadOnly read only - * @param isUpdateable updateable - * @param mLocation location model - */ - public VLocation(String columnName, boolean mandatory, boolean isReadOnly, boolean isUpdateable, - MLocationLookup mLocation) - { - this(null, columnName, mandatory, isReadOnly, isUpdateable, mLocation); - } - - /** - * Constructor - * - * @param gridTab - * @param columnName column name - * @param mandatory mandatory - * @param isReadOnly read only - * @param isUpdateable updateable - * @param mLocation location model - */ - public VLocation(GridTab gridTab, String columnName, boolean mandatory, boolean isReadOnly, boolean isUpdateable, - MLocationLookup mLocation) - { - super(); - super.setName(columnName); - m_GridTab = gridTab; - m_columnName = columnName; - m_mLocation = mLocation; - // - LookAndFeel.installBorder(this, "TextField.border"); - this.setLayout(new BorderLayout()); - // Size - this.setPreferredSize(m_text.getPreferredSize()); // causes r/o to be the same length - int height = m_text.getPreferredSize().height; - - // Button - m_button.setIcon(Env.getImageIcon("Location10.gif")); - m_button.setMargin(new Insets(0,0,0,0)); - m_button.setPreferredSize(new Dimension(height, height)); - m_button.addActionListener(this); - this.add(m_button, BorderLayout.EAST); - // *** Button & Text *** - m_text.setBorder(null); - m_text.setEditable(false); - m_text.setFocusable(false); - m_text.setFont(AdempierePLAF.getFont_Field()); - m_text.setForeground(AdempierePLAF.getTextColor_Normal()); - m_text.addMouseListener(new VLocation_mouseAdapter(this)); - this.add(m_text, BorderLayout.CENTER); - - // Editable - if (isReadOnly || !isUpdateable) - setReadWrite (false); - else - setReadWrite (true); - setMandatory (mandatory); - // - mDelete = new CMenuItem(Msg.getMsg(Env.getCtx(), "Delete"), Env.getImageIcon ("Delete16.gif")); - mDelete.addActionListener(this); - popupMenu.add(mDelete); - - } // VLocation - - /** - * Dispose - */ - public void dispose() - { - m_text = null; - m_button = null; - m_mLocation = null; - m_GridField = null; - m_GridTab = null; - } // dispose - - /** The Text Field */ - private JTextField m_text = new JTextField(VLookup.DISPLAY_LENGTH); - /** The Button */ - private CButton m_button = new CButton(); - - private MLocationLookup m_mLocation; - private MLocation m_value; - - private String m_columnName; - /** Logger */ - private static CLogger log = CLogger.getCLogger(VLocation.class); - - // Popup - JPopupMenu popupMenu = new JPopupMenu(); - private CMenuItem mDelete; - - /** The Grid Tab * */ - @SuppressWarnings("unused") - private GridTab m_GridTab; // added for processCallout - /** The Grid Field * */ - private GridField m_GridField; // added for processCallout - - /** - * Enable/disable - * @param value true if ReadWrite - */ - public void setReadWrite (boolean value) - { - m_button.setReadWrite (value); - if (m_button.isVisible() != value) - m_button.setVisible (value); - setBackground(false); - } // setReadWrite - - /** - * IsReadWrite - * @return value true if ReadWrite - */ - public boolean isReadWrite() - { - return m_button.isReadWrite(); - } // isReadWrite - - /** - * Set Mandatory (and back color) - * @param mandatory true if mandatory - */ - public void setMandatory (boolean mandatory) - { - m_button.setMandatory(mandatory); - setBackground(false); - } // setMandatory - - /** - * Is it mandatory - * @return true if mandatory - */ - public boolean isMandatory() - { - return m_button.isMandatory(); - } // isMandatory - - /** - * Set Background - * @param color color - */ - public void setBackground (Color color) - { - if (!color.equals(m_text.getBackground())) - m_text.setBackground(color); - } // setBackground - - /** - * Set Background based on editable / mandatory / error - * @param error if true, set background to error color, otherwise mandatory/editable - */ - public void setBackground (boolean error) - { - if (error) - setBackground(AdempierePLAF.getFieldBackground_Error()); - else if (!isReadWrite()) - setBackground(AdempierePLAF.getFieldBackground_Inactive()); - else if (isMandatory()) - setBackground(AdempierePLAF.getFieldBackground_Mandatory()); - else - setBackground(AdempierePLAF.getFieldBackground_Normal()); - } // setBackground - - /** - * Set Foreground - * @param fg color - */ - public void setForeground(Color fg) - { - m_text.setForeground(fg); - } // setForeground - - /** - * Set Editor to value - * @param value value - */ - public void setValue(Object value) - { - if (value == null) - { - m_value = null; - m_text.setText(null); - } - else - { - m_value = m_mLocation.getLocation(value, null); - if (m_value == null) - m_text.setText("<" + value + ">"); - else - m_text.setText(m_value.toString()); - } - } // setValue - - /** - * Request Focus - */ - public void requestFocus () - { - m_text.requestFocus (); - } // requestFocus - - /** - * Request Focus In Window - * @return focus request - */ - @Override - public boolean requestFocusInWindow() - { - return m_text.requestFocusInWindow(); - } // requestFocusInWindow - - /** - * Get Focus Component - * @return component - */ - public Component getFocusableComponent() - { - return m_text; - } // getFocusComponent - - /** - * Property Change Listener - * @param evt PropertyChangeEvent - */ - public void propertyChange (PropertyChangeEvent evt) - { - if (evt.getPropertyName().equals(org.compiere.model.GridField.PROPERTY)) - setValue(evt.getNewValue()); - } // propertyChange - - /** - * Return Editor value - * @return value - */ - public Object getValue() - { - if (m_value == null) - return null; - return Integer.valueOf(m_value.getC_Location_ID()); - } // getValue - - /** - * Return Editor value - * @return value - */ - public int getC_Location_ID() - { - if (m_value == null) - return 0; - return m_value.getC_Location_ID(); - } // getC_Location_ID - - /** - * Return Display Value - * @return display value - */ - public String getDisplay() - { - return m_text.getText(); - } // getDisplay - - /** - * ActionListener - Button - Start Dialog - * @param e ActionEvent - */ - public void actionPerformed(ActionEvent e) - { - if (e.getActionCommand().equals(FieldRecordInfo.CHANGE_LOG_COMMAND)) - { - FieldRecordInfo.start(m_GridField); - return; - } - - if (e.getSource() == mDelete) - m_value = null; // create new - // - if (log.isLoggable(Level.CONFIG)) log.config( "actionPerformed - " + m_value); - VLocationDialog ld = new VLocationDialog(AEnv.getFrame(this), - Msg.getMsg(Env.getCtx(), "Location"), m_value, m_GridField); - ld.setVisible(true); - Object oldValue = getValue(); - m_value = ld.getValue(); - // - if (e.getSource() == mDelete) - ; - else if (!ld.isChanged()) - return; - - // Data Binding - try - { - int C_Location_ID = 0; - if (m_value != null) - C_Location_ID = m_value.getC_Location_ID(); - Integer ii = Integer.valueOf(C_Location_ID); - - if (C_Location_ID != 0) - fireVetoableChange(m_columnName, oldValue, ii); - setValue(ii); - } - catch (PropertyVetoException pve) - { - log.log(Level.SEVERE, "VLocation.actionPerformed", pve); - } - } // actionPerformed - - /** - * Action Listener Interface - * @param listener listener - */ - public void addActionListener(ActionListener listener) - { - m_text.addActionListener(listener); - } // addActionListener - - // Field for Value Preference - private GridField m_mField = null; - /** - * Set Field/WindowNo for ValuePreference (NOP) - * @param mField Model Field - */ - public void setField (org.compiere.model.GridField mField) - { - m_GridField = mField; - if (m_GridField != null) - FieldRecordInfo.addMenu(this, popupMenu); - } // setField - - @Override - public GridField getField() { - return m_mField; - } - -} // VLocation - -/*****************************************************************************/ \ No newline at end of file diff --git a/org.adempiere.ui.swing/src/org/compiere/grid/ed/VLocationDialog.java b/org.adempiere.ui.swing/src/org/compiere/grid/ed/VLocationDialog.java deleted file mode 100644 index e9ef4a0999..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/grid/ed/VLocationDialog.java +++ /dev/null @@ -1,1010 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ -package org.compiere.grid.ed; - -import java.awt.BorderLayout; -import java.awt.Frame; -import java.awt.GridBagConstraints; -import java.awt.GridBagLayout; -import java.awt.Insets; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Iterator; -import java.util.Set; -import java.util.StringTokenizer; -import java.util.logging.Level; - -import javax.swing.Box; -import javax.swing.JButton; -import javax.swing.JComponent; -import javax.swing.JLabel; -import javax.swing.JOptionPane; -import javax.swing.SwingConstants; - -import org.compiere.apps.ADialog; -import org.compiere.apps.AEnv; -import org.compiere.apps.ConfirmPanel; -import org.compiere.model.GridField; -import org.compiere.model.MAddressValidation; -import org.compiere.model.MBPartnerLocation; -import org.compiere.model.MCountry; -import org.compiere.model.MLocation; -import org.compiere.model.MOrgInfo; -import org.compiere.model.MRegion; -import org.compiere.model.MSysConfig; -import org.compiere.swing.CButton; -import org.compiere.swing.CCheckBox; -import org.compiere.swing.CComboBoxEditable; -import org.compiere.swing.CDialog; -import org.compiere.swing.CLabel; -import org.compiere.swing.CPanel; -import org.compiere.swing.CTextArea; -import org.compiere.swing.CTextField; -import org.compiere.util.CLogger; -import org.compiere.util.DB; -import org.compiere.util.Env; -import org.compiere.util.Msg; -import org.compiere.util.Trx; - -import com.akunagroup.uk.postcode.AddressLookupInterface; -import com.akunagroup.uk.postcode.Postcode; - -/** - * Dialog to enter Location Info (Address) - * - * @author Jorg Janke - * @version $Id: VLocationDialog.java,v 1.2 2006/07/30 00:51:28 jjanke Exp $ - * - * @author Teo Sarca, SC ARHIPAC SERVICE SRL - *

  • BF [ 1831060 ] Location dialog should use Address1, Address2 ... elements - * @author Michael Judd, Akuna Ltd (UK) - *
  • FR [ 1741222 ] - Webservice connector for address lookups - * @author Cristina Ghita, www.arhipac.ro - *
  • FR [ 2794312 ] Location AutoComplete - * - * http://jira.idempiere.com/browse/IDEMPIERE-147 - Show GoogleMap on Location Dialog - * @author Fernando Lucktemberg (Faire, www.faire.com.br) - *
  • seeded the Map button - * @author Mario Grigioni (Kenos, www.kenos.com.br) - *
  • expanded to add Route button - * @author Alvaro Montenegro (Kenos, www.kenos.com.br) - *
  • BF: Check URL before open the Browser - */ -public class VLocationDialog extends CDialog - implements ActionListener -{ - /** - * - */ - private static final long serialVersionUID = -8325818864115049548L; - - /** Lookup result header */ - private Object[] header = null; - - private int m_WindowNo = 0; - - private GridField m_GridField = null; - - /** - * Constructor - * - * @param frame parent - * @param title title (field name) - * @param location Model Location - */ - public VLocationDialog (Frame frame, String title, MLocation location) - { - this(frame, title, location, null); - } // VLocationDialog - - public VLocationDialog(Frame frame, String title, MLocation location, GridField gridField) { - super(frame, title, true); - m_GridField = gridField; - //m_WindowNo = WindowNo; - try - { - jbInit(); - } - catch(Exception ex) - { - log.log(Level.SEVERE, ex.getMessage()); - } - m_location = location; - if (m_location == null) - m_location = new MLocation (Env.getCtx(), 0, null); - // Overwrite title - if (m_location.getC_Location_ID() == 0) - setTitle(Msg.getMsg(Env.getCtx(), "LocationNew")); - else - setTitle(Msg.getMsg(Env.getCtx(), "LocationUpdate")); - - // Reset TAB_INFO context - Env.setContext(Env.getCtx(), m_WindowNo, Env.TAB_INFO, "C_Region_ID", null); - Env.setContext(Env.getCtx(), m_WindowNo, Env.TAB_INFO, "C_Country_ID", null); - - // Current Country - fCountry = new CComboBoxEditable(MCountry.getCountries(Env.getCtx())); - fCountry.setSelectedItem(m_location.getCountry()); - m_origCountry_ID = m_location.getC_Country_ID(); - // Current Region - fRegion = new CComboBoxEditable(MRegion.getRegions(Env.getCtx(), m_origCountry_ID)); - if (m_location.getCountry().isHasRegion()) { - if ( m_location.getCountry().get_Translation(MCountry.COLUMNNAME_RegionName) != null - && m_location.getCountry().get_Translation(MCountry.COLUMNNAME_RegionName).trim().length() > 0) - lRegion.setText(m_location.getCountry().get_Translation(MCountry.COLUMNNAME_RegionName)); - else - lRegion.setText(Msg.getMsg(Env.getCtx(), "Region")); - } - fRegion.setSelectedItem(m_location.getRegion()); - // - fOnline.setText(Msg.getMsg(Env.getCtx(), "Online")); - initLocation(); - fCountry.addActionListener(this); - fOnline.addActionListener(this); - fRegion.addActionListener(this); - AEnv.positionCenterWindow(frame, this); - } - - private boolean m_change = false; - private MLocation m_location; - private int m_origCountry_ID; - private int s_oldCountry_ID = 0; - /** Logger */ - private static CLogger log = CLogger.getCLogger(VLocationDialog.class); - - private CPanel panel = new CPanel(); - private CPanel mainPanel = new CPanel(); - private CPanel southPanel = new CPanel(); - private BorderLayout panelLayout = new BorderLayout(); - private GridBagLayout gridBagLayout = new GridBagLayout(); - private ConfirmPanel confirmPanel = new ConfirmPanel(true); - private BorderLayout southLayout = new BorderLayout(); - // - private CLabel lAddress1 = new CLabel(Msg.getElement(Env.getCtx(), "Address1")); - private CLabel lAddress2 = new CLabel(Msg.getElement(Env.getCtx(), "Address2")); - private CLabel lAddress3 = new CLabel(Msg.getElement(Env.getCtx(), "Address3")); - private CLabel lAddress4 = new CLabel(Msg.getElement(Env.getCtx(), "Address4")); - private CLabel lAddress5 = new CLabel(Msg.getElement(Env.getCtx(), "Address5")); - private CLabel lComments = new CLabel(Msg.getElement(Env.getCtx(), "Comments")); - private CLabel lCity = new CLabel(Msg.getMsg(Env.getCtx(), "City")); - private CLabel lCountry = new CLabel(Msg.getMsg(Env.getCtx(), "Country")); - private CLabel lRegion = new CLabel(Msg.getMsg(Env.getCtx(), "Region")); - private CLabel lPostal = new CLabel(Msg.getMsg(Env.getCtx(), "Postal")); - private CLabel lPostalAdd = new CLabel(Msg.getMsg(Env.getCtx(), "PostalAdd")); - private CLabel lOnline = new CLabel(""); - private CTextField fAddress1 = new CTextField(20); // length=60 - private CTextField fAddress2 = new CTextField(20); // length=60 - private CTextField fAddress3 = new CTextField(20); // length=60 - private CTextField fAddress4 = new CTextField(20); // length=60 - private CTextField fAddress5 = new CTextField(20); // length=60 - private CTextField fComments = new CTextField(20); // length=2000 - private CTextField fCity = new CTextField(20); // length=60 - private CityAutoCompleter fCityAutoCompleter; - private CComboBoxEditable fCountry; - private CComboBoxEditable fRegion; - private CTextField fPostal = new CTextField(5); // length=10 - private CTextField fPostalAdd = new CTextField(5); // length=10 - private CButton fOnline = new CButton(); - // - private GridBagConstraints gbc = new GridBagConstraints(); - private Insets labelInsets = new Insets(2,15,2,0); // top,left,bottom,right - private Insets fieldInsets = new Insets(2,5,2,10); - - private boolean isCityMandatory = false; - private boolean isRegionMandatory = false; - private boolean isAddress1Mandatory = false; - private boolean isAddress2Mandatory = false; - private boolean isAddress3Mandatory = false; - private boolean isAddress4Mandatory = false; - private boolean isAddress5Mandatory = false; - private boolean isCommentsMandatory = false; - private boolean isPostalMandatory = false; - private boolean isPostalAddMandatory = false; - - private boolean inCountryAction; - private boolean inOKAction; - - private JButton toLink = new JButton(); - private JButton toRoute = new JButton(); - - private CComboBoxEditable lstAddressValidation = new CComboBoxEditable(); - private CButton btnOnline = new CButton(); - private CTextArea txtResult = new CTextArea(3, 30); - private CCheckBox cbxValid = new CCheckBox(); - private ArrayList enabledCountryList = new ArrayList(); - //END - - /** - * Static component init - * @throws Exception - */ - void jbInit() throws Exception - { - panel.setLayout(panelLayout); - southPanel.setLayout(southLayout); - mainPanel.setLayout(gridBagLayout); - panelLayout.setHgap(5); - panelLayout.setVgap(10); - getContentPane().add(panel); - panel.add(mainPanel, BorderLayout.CENTER); - panel.add(southPanel, BorderLayout.SOUTH); - southPanel.add(confirmPanel, BorderLayout.NORTH); - - //BEGIN fernandinho/ricardo - toLink.setText(Msg.getMsg(Env.getCtx(), "Map")); - toLink.addActionListener(this); - toLink.setMargin(ConfirmPanel.s_insets); - confirmPanel.addComponent(toLink); - if (MLocation.LOCATION_MAPS_URL_PREFIX == null) - toLink.setVisible(false); - - toRoute.setText(Msg.getMsg(Env.getCtx(), "Route")); - toRoute.addActionListener(this); - toRoute.setMargin(ConfirmPanel.s_insets); - confirmPanel.addComponent(toRoute); - if (MLocation.LOCATION_MAPS_ROUTE_PREFIX == null) - toRoute.setVisible(false); - //END - - btnOnline.setText(Msg.getElement(Env.getCtx(), "ValidateAddress")); - btnOnline.addActionListener(this); - - txtResult.setReadWrite(false); - cbxValid.setReadWrite(false); - - // - confirmPanel.addActionListener(this); - // - fCityAutoCompleter = new CityAutoCompleter(fCity, m_WindowNo); - } // jbInit - - /** - * Dynamic Init & fill fields - Called when Country changes! - */ - private void initLocation() - { - MCountry country = m_location.getCountry(); - if (log.isLoggable(Level.FINE)) log.fine(country.getName() + ", Region=" + country.isHasRegion() + " " + country.getCaptureSequence() - + ", C_Location_ID=" + m_location.getC_Location_ID()); - // new Country - if (country.getC_Country_ID() != s_oldCountry_ID) - { - fRegion.removeAllItems(); - if (country.isHasRegion()) { - for (MRegion region : MRegion.getRegions(Env.getCtx(), country.getC_Country_ID())) { - fRegion.addItem(region); - } - if ( m_location.getCountry().get_Translation(MCountry.COLUMNNAME_RegionName) != null - && m_location.getCountry().get_Translation(MCountry.COLUMNNAME_RegionName).trim().length() > 0) - lRegion.setText(m_location.getCountry().get_Translation(MCountry.COLUMNNAME_RegionName)); - else - lRegion.setText(Msg.getMsg(Env.getCtx(), "Region")); - } - s_oldCountry_ID = m_location.getC_Country_ID(); - } - - if (m_location.getC_Region_ID() > 0 && m_location.getC_Region().getC_Country_ID() == country.getC_Country_ID()) { - fRegion.setSelectedItem(m_location.getC_Region()); - } else { - fRegion.setSelectedItem(null); - m_location.setC_Region_ID(0); - } - - if (country.isHasRegion() && m_location.getC_Region_ID() > 0) - { - Env.setContext(Env.getCtx(), m_WindowNo, Env.TAB_INFO, "C_Region_ID", String.valueOf(m_location.getC_Region_ID())); - } else { - Env.setContext(Env.getCtx(), m_WindowNo, Env.TAB_INFO, "C_Region_ID", "0"); - } - Env.setContext(Env.getCtx(), m_WindowNo, Env.TAB_INFO, "C_Country_ID", String.valueOf(country.get_ID())); - - fCityAutoCompleter.fillList(); - - gbc.anchor = GridBagConstraints.NORTHWEST; - gbc.gridy = 0; // line - gbc.gridx = 0; - gbc.gridwidth = 1; - gbc.insets = fieldInsets; - gbc.fill = GridBagConstraints.HORIZONTAL; - gbc.weightx = 0; - gbc.weighty = 0; - - mainPanel.removeAll(); - - mainPanel.add(Box.createVerticalStrut(5), gbc); // top gap - - int line = 1; - // sequence of City Postal Region - @P@ @C@ - @C@, @R@ @P@ - String ds = country.getCaptureSequence(); - if (ds == null || ds.length() == 0) - { - log.log(Level.SEVERE, "CaptureSequence empty - " + country); - ds = ""; // @C@, @P@ - } - isCityMandatory = false; - isRegionMandatory = false; - isAddress1Mandatory = false; - isAddress2Mandatory = false; - isAddress3Mandatory = false; - isAddress4Mandatory = false; - isAddress5Mandatory = false; - isCommentsMandatory = false; - isPostalMandatory = false; - isPostalAddMandatory = false; - StringTokenizer st = new StringTokenizer(ds, "@", false); - while (st.hasMoreTokens()) - { - String s = st.nextToken(); - if (s.startsWith("CO")) { - // Country Last - addLine(line++, lCountry, fCountry); - // disable online if this country doesn't have post code lookup - if (m_location.getCountry().isPostcodeLookup()) { - addLine(line++, lOnline, fOnline); - } - } else if (s.startsWith("Com")) { - addLine(line++, lComments, fComments); - isCommentsMandatory = s.endsWith("!"); - } else if (s.startsWith("A1")) { - addLine(line++, lAddress1, fAddress1); - isAddress1Mandatory = s.endsWith("!"); - } else if (s.startsWith("A2")) { - addLine(line++, lAddress2, fAddress2); - isAddress2Mandatory = s.endsWith("!"); - } else if (s.startsWith("A3")) { - addLine(line++, lAddress3, fAddress3); - isAddress3Mandatory = s.endsWith("!"); - } else if (s.startsWith("A4")) { - addLine(line++, lAddress4, fAddress4); - isAddress4Mandatory = s.endsWith("!"); - } else if (s.startsWith("A5")) { - addLine(line++, lAddress5, fAddress5); - isAddress5Mandatory = s.endsWith("!"); - } else if (s.startsWith("C")) { - addLine(line++, lCity, fCity); - isCityMandatory = s.endsWith("!"); - } else if (s.startsWith("P")) { - addLine(line++, lPostal, fPostal); - isPostalMandatory = s.endsWith("!"); - } else if (s.startsWith("A")) { - addLine(line++, lPostalAdd, fPostalAdd); - isPostalAddMandatory = s.endsWith("!"); - } else if (s.startsWith("R") && m_location.getCountry().isHasRegion()) { - addLine(line++, lRegion, fRegion); - isRegionMandatory = s.endsWith("!"); - } - } - - // Fill it - if (m_location.getC_Location_ID() != 0) - { - fAddress1.setText(m_location.getAddress1()); - fAddress2.setText(m_location.getAddress2()); - fAddress3.setText(m_location.getAddress3()); - fAddress4.setText(m_location.getAddress4()); - fAddress5.setText(m_location.getAddress5()); - fComments.setText(m_location.getComments()); - fCity.setText(m_location.getCity()); - fPostal.setText(m_location.getPostal()); - fPostalAdd.setText(m_location.getPostal_Add()); - if (m_location.getCountry().isHasRegion()) - { - if ( m_location.getCountry().get_Translation(MCountry.COLUMNNAME_RegionName) != null - && m_location.getCountry().get_Translation(MCountry.COLUMNNAME_RegionName).trim().length() > 0) - lRegion.setText(m_location.getCountry().get_Translation(MCountry.COLUMNNAME_RegionName)); - else - lRegion.setText(Msg.getMsg(Env.getCtx(), "Region")); - fRegion.setSelectedItem(m_location.getRegion()); - } - - if (!fCountry.getSelectedItem().equals(country)) - fCountry.setSelectedItem(country); - } - - String addressValidation = MSysConfig.getValue(MSysConfig.ADDRESS_VALIDATION, null, Env.getAD_Client_ID(Env.getCtx())); - enabledCountryList.clear(); - if (addressValidation != null && addressValidation.trim().length() > 0) - { - st = new StringTokenizer(addressValidation, ";"); - while (st.hasMoreTokens()) - { - String token = st.nextToken().trim(); - enabledCountryList.add(token); - } - } - - if (enabledCountryList.size() > 0) - { - addLine(line++, new CLabel(Msg.getElement(Env.getCtx(), "C_AddressValidation_ID")), lstAddressValidation); - - MAddressValidation[] validations = MAddressValidation.getAddressValidation(Env.getCtx(), Env.getAD_Client_ID(Env.getCtx()), null); - for (MAddressValidation validation : validations) - { - lstAddressValidation.addItem(validation); - if (m_location.getC_AddressValidation_ID() == validation.getC_AddressValidation_ID()) - lstAddressValidation.setSelectedItem(validation); - } - - if (lstAddressValidation.getSelectedIndex() == -1 && lstAddressValidation.getItemCount() > 0) - lstAddressValidation.setSelectedIndex(0); - - addLine(line++, new CLabel(Msg.getElement(Env.getCtx(), "Result")), txtResult); - txtResult.setText(m_location.getResult()); - - addLine(line++, new CLabel(Msg.getElement(Env.getCtx(), "IsValid")), cbxValid); - cbxValid.setSelected(m_location.isValid()); - - addLine(line++, new JLabel(), btnOnline); - - if (!enabledCountryList.isEmpty()) - { - boolean isEnabled = false; - if (m_location.getCountry() != null) - { - for (String enabledCountry : enabledCountryList) - { - if (enabledCountry.equals(m_location.getCountry().getCountryCode().trim())) - { - isEnabled = true; - break; - } - } - } - btnOnline.setEnabled(isEnabled); - } - } - - // Update UI - pack(); - } // initLocation - - /** - * Add Line to screen - * - * @param line line number (zero based) - * @param label label - * @param field field - */ - private void addLine(int line, JLabel label, JComponent field) - { - gbc.gridy = line; - // label - gbc.insets = labelInsets; - gbc.gridx = 0; - gbc.weightx = 0.0; - gbc.fill = GridBagConstraints.HORIZONTAL; - label.setHorizontalAlignment(SwingConstants.RIGHT); - mainPanel.add(label, gbc); - // Field - gbc.insets = fieldInsets; - gbc.gridx = 1; - gbc.weightx = 1.0; - gbc.fill = GridBagConstraints.NONE; - gbc.insets = fieldInsets; - mainPanel.add(field, gbc); - - } // addLine - - @Override - public void dispose() - { - if (!m_change && m_location != null && !m_location.is_new()) - { - m_location = new MLocation(m_location.getCtx(), m_location.get_ID(), null); - } - super.dispose(); - } - - /** - * ActionListener - * @param e ActionEvent - */ - public void actionPerformed(ActionEvent e) - { - if (e.getActionCommand().equals(ConfirmPanel.A_OK)) - { - inOKAction = true; - - if (m_location.getCountry().isHasRegion() && fRegion.getSelectedItem() == null) { - if (fCityAutoCompleter.getC_Region_ID() > 0 && fCityAutoCompleter.getC_Region_ID() != m_location.getC_Region_ID()) { - fRegion.setSelectedItem(MRegion.get(Env.getCtx(), fCityAutoCompleter.getC_Region_ID())); - m_location.setRegion(MRegion.get(Env.getCtx(), fCityAutoCompleter.getC_Region_ID())); - } - } - - String msg = validate_OK(); - if (msg != null) { - ADialog.error(0, this, "FillMandatory", Msg.parseTranslation(Env.getCtx(), msg)); - inOKAction = false; - return; - } - - if (action_OK()) - { - m_change = true; - dispose(); - } - else - { - ADialog.error(m_WindowNo, this, "CityNotFound"); - } - inOKAction = false; - } - else if (e.getActionCommand().equals(ConfirmPanel.A_CANCEL)) - { - m_change = false; - dispose(); - } - - // Country Changed - display in new Format - else if (e.getSource() == fCountry) - { - inCountryAction = true; - // Modifier for Mouse selection is 16 - for any key selection 0 - MCountry c = (MCountry)fCountry.getSelectedItem(); - m_location.setCountry(c); - - initLocation(); - - if (!enabledCountryList.isEmpty()) - { - boolean isEnabled = false; - if (c != null) - { - for (String enabledCountry : enabledCountryList) - { - if (enabledCountry.equals(c.getCountryCode().trim())) - { - isEnabled = true; - break; - } - } - } - btnOnline.setEnabled(isEnabled); - } - - fCountry.requestFocus(); // allows to use Keyboard selection - inCountryAction = false; - } - // Region Changed - else if (e.getSource() == fRegion) - { - if (inCountryAction || inOKAction) - return; - MRegion r = (MRegion)fRegion.getSelectedItem(); - m_location.setRegion(r); - m_location.setC_City_ID(0); - m_location.setCity(null); - - initLocation(); - fRegion.requestFocus(); // allows to use Keyboard selection - } - //BEGIN fernandinho/ricardo - else if (e.getSource() == toLink) - { - String urlString = MLocation.LOCATION_MAPS_URL_PREFIX + getFullAdress(); - String message = null; - - try - { - Env.startBrowser(urlString); - } - catch (Exception ex) - { - message = ex.getMessage(); - ADialog.warn(0, this, "URLnotValid", message); - } - } - else if (e.getSource() == toRoute) - { - int AD_Org_ID = Env.getAD_Org_ID(Env.getCtx()); - if (AD_Org_ID != 0){ - MOrgInfo orgInfo = MOrgInfo.get(Env.getCtx(), AD_Org_ID,null); - MLocation orgLocation = new MLocation(Env.getCtx(),orgInfo.getC_Location_ID(),null); - - String urlString = MLocation.LOCATION_MAPS_ROUTE_PREFIX + - MLocation.LOCATION_MAPS_SOURCE_ADDRESS + orgLocation.getMapsLocation() + //org - MLocation.LOCATION_MAPS_DESTINATION_ADDRESS + getFullAdress(); //partner - String message = null; - try - { - Env.startBrowser(urlString); - } - catch (Exception ex) - { - message = ex.getMessage(); - ADialog.warn(0, this, "URLnotValid", message); - } - } - } - //END - else if (e.getSource() == btnOnline) - { - btnOnline.setEnabled(false); - - inOKAction = true; - - if (m_location.getCountry().isHasRegion() && fRegion.getSelectedItem() == null) { - if (fCityAutoCompleter.getC_Region_ID() > 0 && fCityAutoCompleter.getC_Region_ID() != m_location.getC_Region_ID()) { - fRegion.setSelectedItem(MRegion.get(Env.getCtx(), fCityAutoCompleter.getC_Region_ID())); - m_location.setRegion(MRegion.get(Env.getCtx(), fCityAutoCompleter.getC_Region_ID())); - } - } - - String msg = validate_OK(); - if (msg != null) { - ADialog.error(0, this, "FillMandatory", Msg.parseTranslation(Env.getCtx(), msg)); - inOKAction = false; - return; - } - - MLocation m_location = new MLocation(Env.getCtx(), 0, null); - m_location.setAddress1(fAddress1.getText()); - m_location.setAddress2(fAddress2.getText()); - m_location.setAddress3(fAddress3.getText()); - m_location.setAddress4(fAddress4.getText()); - m_location.setAddress5(fAddress5.getText()); - m_location.setComments(fComments.getText()); - m_location.setCity(fCity.getText()); - m_location.setC_City_ID(fCityAutoCompleter.getC_City_ID()); - m_location.setPostal(fPostal.getText()); - m_location.setPostal_Add(fPostalAdd.getText()); - // Country/Region - MCountry c = (MCountry)fCountry.getSelectedItem(); - m_location.setCountry(c); - if (m_location.getCountry().isHasRegion()) - { - MRegion r = (MRegion)fRegion.getSelectedItem(); - m_location.setRegion(r); - } - else - m_location.setC_Region_ID(0); - - MAddressValidation validation = (MAddressValidation) lstAddressValidation.getSelectedItem(); - if (validation == null && lstAddressValidation.getItemCount() > 0) - validation = (MAddressValidation) lstAddressValidation.getItemAt(0); - if (validation != null) - { - boolean ok = m_location.processOnline(validation.getC_AddressValidation_ID()); - - txtResult.setText(m_location.getResult()); - cbxValid.setSelected(m_location.isValid()); - lstAddressValidation.setSelectedItem(m_location.getC_AddressValidation()); - - if (!ok) - ADialog.error(0, this, "Error", m_location.getErrorMessage()); - } - - inOKAction = false; - - btnOnline.setEnabled(true); - } - else if (e.getSource() == fOnline) - { - - // check to see if we have a postcode lookup plugin for this country - MCountry c = (MCountry)fCountry.getSelectedItem(); - if (c.isPostcodeLookup()) - { - lookupPostcode(c, fPostal.getText()); - } - } - } // actionPerformed - - // LCO - address 1, region and city required - private String validate_OK() { - String fields = ""; - if (isAddress1Mandatory && fAddress1.getText().trim().length() == 0) { - fields = fields + " " + "@Address1@, "; - } - if (isAddress2Mandatory && fAddress2.getText().trim().length() == 0) { - fields = fields + " " + "@Address2@, "; - } - if (isAddress3Mandatory && fAddress3.getText().trim().length() == 0) { - fields = fields + " " + "@Address3@, "; - } - if (isAddress4Mandatory && fAddress4.getText().trim().length() == 0) { - fields = fields + " " + "@Address4@, "; - } - if (isAddress5Mandatory && fAddress5.getText().trim().length() == 0) { - fields = fields + " " + "@Address5@, "; - } - if (isCommentsMandatory && fComments.getText().trim().length() == 0) { - fields = fields + " " + "@Comments@, "; - } - if (isCityMandatory && fCity.getText().trim().length() == 0) { - fields = fields + " " + "@C_City_ID@, "; - } - if (isRegionMandatory && fRegion.getSelectedItem() == null) { - fields = fields + " " + "@C_Region_ID@, "; - } - if (isPostalMandatory && fPostal.getText().trim().length() == 0) { - fields = fields + " " + "@Postal@, "; - } - if (isPostalAddMandatory && fPostalAdd.getText().trim().length() == 0) { - fields = fields + " " + "@PostalAdd@, "; - } - - if (fields.trim().length() > 0) - return fields.substring(0, fields.length() -2); - - return null; - } - - /** - * OK - check for changes (save them) & Exit - */ - private boolean action_OK() - { - Trx trx = Trx.get(Trx.createTrxName("VLocationDialog"), true); - m_location.set_TrxName(trx.getTrxName()); - m_location.setAddress1(fAddress1.getText()); - m_location.setAddress2(fAddress2.getText()); - m_location.setAddress3(fAddress3.getText()); - m_location.setAddress4(fAddress4.getText()); - m_location.setAddress5(fAddress5.getText()); - m_location.setComments(fComments.getText()); - m_location.setCity(fCity.getText()); - m_location.setC_City_ID(fCityAutoCompleter.getC_City_ID()); - m_location.setPostal(fPostal.getText()); - m_location.setPostal_Add(fPostalAdd.getText()); - // Country/Region - MCountry c = (MCountry)fCountry.getSelectedItem(); - m_location.setCountry(c); - if (m_location.getCountry().isHasRegion()) - { - MRegion r = (MRegion)fRegion.getSelectedItem(); - m_location.setRegion(r); - } - else - m_location.setC_Region_ID(0); - - if (lstAddressValidation.getSelectedIndex() != -1) - { - MAddressValidation validation = (MAddressValidation) lstAddressValidation.getSelectedItem(); - m_location.setC_AddressValidation_ID(validation.getC_AddressValidation_ID()); - } - - // Save changes - boolean success = false; - if (m_location.save()) - { - // IDEMPIERE-417 Force Update BPLocation.Name - if (m_GridField != null && m_GridField.getGridTab() != null - && "C_BPartner_Location".equals(m_GridField.getGridTab().getTableName()) - && !m_GridField.getGridTab().getValueAsBoolean("IsPreserveCustomName")) - { - m_GridField.getGridTab().setValue("Name", "."); - success = true; - } else { - //Update BP_Location name IDEMPIERE 417 - int bplID = DB.getSQLValueEx(trx.getTrxName(), MLocation.updateBPLocName, m_location.getC_Location_ID()); - if (bplID>0) - { - MBPartnerLocation bpl = new MBPartnerLocation(Env.getCtx(), bplID, trx.getTrxName()); - bpl.setName(bpl.getBPLocName(m_location)); - if (bpl.save()) - success = true; - } else { - success = true; - } - } - } - if (success) { - trx.commit(); - } else { - trx.rollback(); - } - trx.close(); - - return success; - } // actionOK - - /** - * Get result - * @return true, if changed - */ - public boolean isChanged() - { - return m_change; - } // getChange - - /** - * Get edited Value (MLocation) - * @return location - */ - public MLocation getValue() - { - return m_location; - } // getValue - /** - * lookupPostcode - * - * - * @param country - * @param postcode - * @return - */ - private String lookupPostcode(MCountry country, String postcode) - { - // Initialize the lookup class. - AddressLookupInterface pcLookup = null; - try { - AddressLookupInterface pcLookupTmp = (AddressLookupInterface) Class - .forName(country.getLookupClassName()).newInstance(); - pcLookup = pcLookupTmp.newInstance(); - } catch (Exception e) { - e.printStackTrace(); - return "lookupAddress(): " + e.getMessage(); - } - - // remove any spaces from the postcode and convert to upper case - postcode = postcode.replaceAll(" ", "").toUpperCase(); - if (log.isLoggable(Level.FINE)) log.fine("Looking up postcode: " + postcode); - - // Lookup postcode on server. - pcLookup.setServerUrl(country.getLookupUrl()); - pcLookup.setClientID(country.getLookupClientID()); - pcLookup.setPassword(country.getLookupPassword()); - if (pcLookup.lookupPostcode(postcode)==1){ - // Success - fillLocation(pcLookup.getAddressData(), country); - fAddress1.requestFocusInWindow(); - } else - return "Postcode Lookup Error"; - - return ""; - } - - /** - * Fills the location field using the information retrieved from postcode - * servers. - * - * @param ctx - * Context - * @param pkeyData - * Lookup results - * @param windowNo - * Window No. - * @param tab - * Tab - * @param field - * Field - */ - private void fillLocation(HashMap postcodeData, MCountry country) { - - // If it's not empty warn the user. - if (fAddress1 != null - || fAddress2 != null - || fAddress3 != null - || fAddress4 != null - || fAddress5 != null - || fComments != null - || fCity != null) { - String warningMsg = "Existing address information will be overwritten. Proceed?"; - String warningTitle = "Warning"; - int response = JOptionPane.showConfirmDialog(null, warningMsg, - warningTitle, JOptionPane.YES_NO_OPTION); - if (response == JOptionPane.NO_OPTION) - return; - } - - - Set pcodeKeys = postcodeData.keySet(); - Iterator iterator = pcodeKeys.iterator(); - header = null; - - // Allocate the header array - header = new Object[pcodeKeys.size()]; - - String headerStr = null; - - // need to check how many records returned - // TODO - check number of records returns - size() method is incorrect - if (pcodeKeys.size() > 2) - { - // TODO: Implement ResultData Grid and get return (for premises level data) - System.out.println("Too many postcodes returned from Postcode Lookup - need to Implement ResultData"); - } else - { - for (int i = 0; (headerStr = (iterator.hasNext() ? iterator.next() : null)) != null - || iterator.hasNext(); i++) { - header[i] = headerStr; - Postcode values = (Postcode) postcodeData.get(headerStr); - - // Overwrite the values in location field. - fAddress1.setText(values.getStreet1()); - fAddress2.setText(values.getStreet2()); - fAddress3.setText(values.getStreet3()); - fAddress4.setText(values.getStreet4()); - fAddress5.setText(values.getStreet5()); - fComments.setText(values.getComments()); - fCity.setText(values.getCity()); - fPostal.setText(values.getPostcode()); - - // Do region lookup - if (country.isHasRegion()) - { - // get all regions for this country - MRegion[] regions = MRegion.getRegions(country.getCtx(), country.getC_Country_ID()); - - // If regions were loaded - if ( regions.length > 0) - { - // loop through regions array to attempt a region match - don't finish loop if region found - boolean found = false; - for (i = 0; i < regions.length && !found; i++) - { - - if (regions[i].getName().equals(values.getRegion()) ) - { - // found Region - fRegion.setSelectedItem(regions[i]); - if (log.isLoggable(Level.FINE)) log.fine("Found region: " + regions[i].getName()); - found = true; - } - } - if (!found) - { - // add new region - MRegion region = new MRegion(country, values.getRegion()); - if (region.save()) - { - if (log.isLoggable(Level.FINE)) log.fine("Added new region from web service: " + values.getRegion()); - //reload regions to combo box - fRegion = new CComboBoxEditable(MRegion.getRegions(Env.getCtx(), country.getC_Country_ID())); - // select region - fRegion.setSelectedItem(values); - } else - log.severe("Error saving new region: " + region.getName()); - - } - } else - log.severe("Region lookup failed for Country: " + country.getName()); - - } - } - } - - } - - /** returns a string that contains all fields of current form */ - String getFullAdress() - { - MRegion region = null; - - if (fRegion.getSelectedItem()!=null) - region = new MRegion(Env.getCtx(), ((MRegion)fRegion.getSelectedItem()).getC_Region_ID(), null); - - MCountry c = (MCountry)fCountry.getSelectedItem(); - - String address = ""; - address = address + (fAddress1.getText() != null ? fAddress1.getText() + ", " : ""); - address = address + (fAddress2.getText() != null ? fAddress2.getText() + ", " : ""); - address = address + (fAddress3.getText() != null ? fAddress3.getText() + ", " : ""); - address = address + (fAddress4.getText() != null ? fAddress4.getText() + ", " : ""); - address = address + (fCity.getText() != null ? fCity.getText() + ", " : ""); - if (region != null) - address = address + (region.getName() != null ? region.getName() + ", " : ""); - - address = address + (c.getName() != null ? c.getName() : ""); - return address.replace(" ", "+"); - } - -} // VLocationDialog diff --git a/org.adempiere.ui.swing/src/org/compiere/grid/ed/VLocator.java b/org.adempiere.ui.swing/src/org/compiere/grid/ed/VLocator.java deleted file mode 100644 index 06e3870a31..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/grid/ed/VLocator.java +++ /dev/null @@ -1,644 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ -package org.compiere.grid.ed; - -import java.awt.BorderLayout; -import java.awt.Color; -import java.awt.Component; -import java.awt.Cursor; -import java.awt.Dimension; -import java.awt.Insets; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.awt.event.MouseEvent; -import java.beans.PropertyChangeEvent; -import java.beans.PropertyVetoException; -import java.sql.PreparedStatement; -import java.sql.ResultSet; -import java.sql.SQLException; -import java.util.logging.Level; - -import javax.swing.ImageIcon; -import javax.swing.JComponent; -import javax.swing.JPopupMenu; -import javax.swing.JTextField; -import javax.swing.LookAndFeel; -import javax.swing.SwingUtilities; - -import org.adempiere.plaf.AdempierePLAF; -import org.compiere.apps.AEnv; -import org.compiere.apps.AWindow; -import org.compiere.apps.FieldRecordInfo; -import org.compiere.model.GridField; -import org.compiere.model.MLocator; -import org.compiere.model.MLocatorLookup; -import org.compiere.model.MQuery; -import org.compiere.model.MRole; -import org.compiere.model.MTable; -import org.compiere.model.MWarehouse; -import static org.compiere.model.SystemIDs.*; -import org.compiere.swing.CButton; -import org.compiere.swing.CMenuItem; -import org.compiere.util.CLogger; -import org.compiere.util.DB; -import org.compiere.util.Env; -import org.compiere.util.Msg; - -/** - * Warehouse Locator Control - * - * @author Jorg Janke - * @version $Id: VLocator.java,v 1.5 2006/07/30 00:51:27 jjanke Exp $ - */ -public class VLocator extends JComponent - implements VEditor, ActionListener -{ - /** - * - */ - private static final long serialVersionUID = -8164788185893073951L; - - /** - * Mouse Listener for Popup Menu - */ - final class VLocator_mouseAdapter extends java.awt.event.MouseAdapter - { - /** - * Constructor - * @param adaptee VLocator - */ - VLocator_mouseAdapter(VLocator adaptee) - { - m_adaptee = adaptee; - } // VLookup_mouseAdapter - - /** Adaptee */ - private VLocator m_adaptee; - - /** - * Mouse Listener - * @param e MouseEvent - */ - public void mouseClicked(MouseEvent e) - { - // popup menu - if (SwingUtilities.isRightMouseButton(e)) - m_adaptee.popupMenu.show((Component)e.getSource(), e.getX(), e.getY()); - } // mouse Clicked - - } // VLocator_mouseAdapter - - /** - * IDE Constructor - */ - public VLocator () - { - this("M_Locator_ID", false, false, true, null, 0); - } // VLocator - - /** - * Constructor - * - * @param columnName ColumnName - * @param mandatory mandatory - * @param isReadOnly read only - * @param isUpdateable updateable - * @param mLocator locator (lookup) model - * @param WindowNo window no - */ - public VLocator(String columnName, boolean mandatory, boolean isReadOnly, boolean isUpdateable, - MLocatorLookup mLocator, int WindowNo) - { - super(); - super.setName(columnName); - m_columnName = columnName; - m_mLocator = mLocator; - m_WindowNo = WindowNo; - // - LookAndFeel.installBorder(this, "TextField.border"); - this.setLayout(new BorderLayout()); - // Size - this.setPreferredSize(m_text.getPreferredSize()); // causes r/o to be the same length - int height = m_text.getPreferredSize().height; - - // *** Button & Text *** - m_text.setBorder(null); - m_text.setEditable(true); - m_text.setFocusable(true); - m_text.addMouseListener(new VLocator_mouseAdapter(this)); // popup - m_text.setFont(AdempierePLAF.getFont_Field()); - m_text.setForeground(AdempierePLAF.getTextColor_Normal()); - m_text.addActionListener(this); - this.add(m_text, BorderLayout.CENTER); - - m_button.setIcon(new ImageIcon(org.compiere.Adempiere.getResource("images/Locator10.gif"))); - m_button.setMargin(new Insets(0, 0, 0, 0)); - m_button.setPreferredSize(new Dimension(height, height)); - m_button.addActionListener(this); - this.add(m_button, BorderLayout.EAST); - - // Prefereed Size - this.setPreferredSize(this.getPreferredSize()); // causes r/o to be the same length - - // ReadWrite - if (isReadOnly || !isUpdateable) - setReadWrite (false); - else - setReadWrite (true); - setMandatory (mandatory); - // - mZoom = new CMenuItem(Msg.getMsg(Env.getCtx(), "Zoom"), Env.getImageIcon("Zoom16.gif")); - mZoom.addActionListener(this); - popupMenu.add(mZoom); - mRefresh = new CMenuItem(Msg.getMsg(Env.getCtx(), "Refresh"), Env.getImageIcon("Refresh16.gif")); - mRefresh.addActionListener(this); - popupMenu.add(mRefresh); - setDefault_Locator_ID(); // set default locator, teo_sarca [ 1661546 ] - } // VLocator - - /** - * Dispose - */ - public void dispose() - { - m_text = null; - m_button = null; - m_mLocator = null; - } // dispose - - private JTextField m_text = new JTextField (VLookup.DISPLAY_LENGTH); - private CButton m_button = new CButton(); - private MLocatorLookup m_mLocator; - private Object m_value; - // - private String m_columnName; - private int m_WindowNo; - /** Logger */ - private static CLogger log = CLogger.getCLogger(VLocator.class); - // Popup - JPopupMenu popupMenu = new JPopupMenu(); - private CMenuItem mZoom; - private CMenuItem mRefresh; - private GridField m_mField; - - /** - * Enable/disable - * @param value r/w - */ - public void setReadWrite (boolean value) - { - m_button.setReadWrite(value); - if (m_button.isVisible() != value) - m_button.setVisible(value); - setBackground(false); - } // setReadWrite - - /** - * IsReadWrite - * @return true if ReadWrite - */ - public boolean isReadWrite() - { - return m_button.isReadWrite(); - } // isReadWrite - - /** - * Set Mandatory (and back bolor) - * @param mandatory true if mandatory - */ - public void setMandatory (boolean mandatory) - { - m_button.setMandatory(mandatory); - setBackground(false); - } // setMandatory - - /** - * Is it mandatory - * @return true if mandatory - */ - public boolean isMandatory() - { - return m_button.isMandatory(); - } // isMandatory - - /** - * Set Background - * @param color color - */ - public void setBackground (Color color) - { - if (!color.equals(m_text.getBackground())) - m_text.setBackground(color); - } // setBackground - - /** - * Set Background based on editable / mandatory / error - * @param error if true, set background to error color, otherwise mandatory/editable - */ - public void setBackground (boolean error) - { - if (error) - setBackground(AdempierePLAF.getFieldBackground_Error()); - else if (!isReadWrite()) - setBackground(AdempierePLAF.getFieldBackground_Inactive()); - else if (isMandatory()) - setBackground(AdempierePLAF.getFieldBackground_Mandatory()); - else - setBackground(AdempierePLAF.getFieldBackground_Normal()); - } // setBackground - - /** - * Set Foreground - * @param fg color - */ - public void setForeground(Color fg) - { - m_text.setForeground(fg); - } // setForeground - - /** - * Request Focus - */ - public void requestFocus () - { - m_text.requestFocus (); - } // requestFocus - - /** - * Request Focus In Window - * @return focus request - */ - @Override - public boolean requestFocusInWindow() - { - return m_text.requestFocusInWindow(); - } // requestFocusInWindow - - /** - * Get Focus Component - * @return component - */ - public Component getFocusableComponent() - { - return m_text; - } // getFocusComponent - - /** - * Set Editor to value - * @param value Integer - */ - public void setValue(Object value) - { - setValue (value, false); - } // setValue - - /** - * Set Value - * @param value value - * @param fire data binding - */ - private void setValue (Object value, boolean fire) - { - if (m_mLocator == null) - { - return ; - } - - if (value != null) - { - m_mLocator.setOnly_Warehouse_ID (getOnly_Warehouse_ID ()); - m_mLocator.setOnly_Product_ID(getOnly_Product_ID()); - if (!m_mLocator.isValid(value)) - value = null; - } - // - m_value = value; - m_text.setText(m_mLocator.getDisplay(value)); // loads value - - // Data Binding - try - { - fireVetoableChange(m_columnName, null, value); - } - catch (PropertyVetoException pve) - { - } - } // setValue - - - /** - * Property Change Listener - * @param evt PropertyChangeEvent - */ - public void propertyChange (PropertyChangeEvent evt) - { - if (evt.getPropertyName().equals(org.compiere.model.GridField.PROPERTY)) - setValue(evt.getNewValue()); - } // propertyChange - - /** - * Return Editor value - * @return value - */ - public Object getValue() - { - if (getM_Locator_ID() == 0) - return null; - return m_value; - } // getValue - - /** - * Get M_Locator_ID - * @return id - */ - public int getM_Locator_ID() - { - if (m_value != null - && m_value instanceof Integer) - return ((Integer)m_value).intValue(); - return 0; - } // getM_Locator_ID - - /** - * Return Display Value - * @return display value - */ - public String getDisplay() - { - return m_text.getText(); - } // getDisplay - - /** - * ActionListener - * @param e ActionEvent - */ - public void actionPerformed(ActionEvent e) - { - if (e.getActionCommand().equals(FieldRecordInfo.CHANGE_LOG_COMMAND)) - { - FieldRecordInfo.start(m_mField); - return; - } - - // Refresh - if (e.getSource() == mRefresh) - { - m_mLocator.refresh(); - return; - } - - // Zoom to M_Warehouse - if (e.getSource() == mZoom) - { - actionZoom(); - return; - } - - // Warehouse/Product - int only_Warehouse_ID = getOnly_Warehouse_ID(); - int only_Product_ID = getOnly_Product_ID(); - if (log.isLoggable(Level.CONFIG)) log.config("Only Warehouse_ID=" + only_Warehouse_ID - + ", Product_ID=" + only_Product_ID); - - // Text Entry ok - if (e.getSource() == m_text - && actionText(only_Warehouse_ID, only_Product_ID)) - return; - - // Button - Start Dialog - int M_Locator_ID = 0; - if (m_value instanceof Integer) - M_Locator_ID = ((Integer)m_value).intValue(); - // - m_mLocator.setOnly_Warehouse_ID(only_Warehouse_ID); - m_mLocator.setOnly_Product_ID(getOnly_Product_ID()); - VLocatorDialog ld = new VLocatorDialog(AEnv.getFrame(this), - Msg.translate(Env.getCtx(), m_columnName), - m_mLocator, M_Locator_ID, isMandatory(), only_Warehouse_ID); - // display - ld.setVisible(true); - m_mLocator.setOnly_Warehouse_ID(0); - - // redisplay - if (!ld.isChanged()) - return; - setValue (ld.getValue(), true); - } // actionPerformed - - /** - * Hit Enter in Text Field - * @param only_Warehouse_ID if not 0 restrict warehouse - * @param only_Product_ID of not 0 restricted product - * @return true if found - */ - private boolean actionText (int only_Warehouse_ID, int only_Product_ID) - { - String text = m_text.getText(); - log.fine(text); - // Null - if (text == null || text.length() == 0) - { - if (isMandatory()) - return false; - else - { - setValue (null, true); - return true; - } - } - if (text.endsWith("%")) - text = text.toUpperCase(); - else - text = text.toUpperCase() + "%"; - - // Look up - see MLocatorLookup.run - StringBuffer sql = new StringBuffer("SELECT M_Locator_ID FROM M_Locator ") - .append(" WHERE IsActive='Y' AND UPPER(Value) LIKE ") - .append(DB.TO_STRING(text)); - if (getOnly_Warehouse_ID() != 0) - sql.append(" AND M_Warehouse_ID=?"); - if (getOnly_Product_ID() != 0) - sql.append(" AND (IsDefault='Y' ") // Default Locator - .append("OR EXISTS (SELECT * FROM M_Product p ") // Product Locator - .append("WHERE p.M_Locator_ID=M_Locator.M_Locator_ID AND p.M_Product_ID=?)") - .append("OR EXISTS (SELECT * FROM M_Storage s ") // Storage Locator - .append("WHERE s.M_Locator_ID=M_Locator.M_Locator_ID AND s.M_Product_ID=?))"); - String finalSql = MRole.getDefault(Env.getCtx(), false).addAccessSQL( - sql.toString(), "M_Locator", MRole.SQL_NOTQUALIFIED, MRole.SQL_RO); - // - int M_Locator_ID = 0; - PreparedStatement pstmt = null; - ResultSet rs = null; - try - { - pstmt = DB.prepareStatement(finalSql, null); - int index = 1; - if (only_Warehouse_ID != 0) - pstmt.setInt(index++, only_Warehouse_ID); - if (only_Product_ID != 0) - { - pstmt.setInt(index++, only_Product_ID); - pstmt.setInt(index++, only_Product_ID); - } - rs = pstmt.executeQuery(); - if (rs.next()) - { - M_Locator_ID = rs.getInt(1); - if (rs.next()) - M_Locator_ID = 0; // more than one - } - } - catch (SQLException ex) - { - log.log(Level.SEVERE, finalSql, ex); - } - finally - { - DB.close(rs, pstmt); - rs = null; - pstmt = null; - } - - if (M_Locator_ID == 0) - return false; - - setValue (Integer.valueOf(M_Locator_ID), true); - return true; - } // actionText - - /** - * Action Listener Interface - * @param listener listener - */ - public void addActionListener(ActionListener listener) - { - m_text.addActionListener(listener); - } // addActionListener - - - /** - * Action - Zoom - */ - private void actionZoom() - { - int AD_Window_ID = MTable.get(Env.getCtx(), MLocator.Table_ID).getAD_Window_ID(); - if (AD_Window_ID <= 0) - AD_Window_ID = WINDOW_WAREHOUSE_LOCATOR; // hardcoded window Warehouse & Locators - log.info(""); - // - setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); - AWindow frame = new AWindow(null); - - MQuery zoomQuery = new MQuery(); - zoomQuery.addRestriction(MLocator.COLUMNNAME_M_Locator_ID, MQuery.EQUAL, getValue()); - zoomQuery.setRecordCount(1); // guess - - if (!frame.initWindow(AD_Window_ID, zoomQuery)) - return; - AEnv.addToWindowManager(frame); - AEnv.showCenterScreen(frame); - frame = null; - setCursor(Cursor.getDefaultCursor()); - } // actionZoom - - /** - * Set Field/WindowNo for ValuePreference (NOP) - * @param mField Model Field - */ - public void setField (org.compiere.model.GridField mField) - { - m_mField = mField; - if (m_mField != null) - FieldRecordInfo.addMenu(this, popupMenu); - } // setField - - @Override - public GridField getField() { - return m_mField; - } - - /** - * Get Warehouse restriction if any. - * @return M_Warehouse_ID or 0 - */ - private int getOnly_Warehouse_ID() - { - String only_Warehouse = Env.getContext(Env.getCtx(), m_WindowNo, "M_Warehouse_ID", true); - int only_Warehouse_ID = 0; - try - { - if (only_Warehouse != null && only_Warehouse.length () > 0) - only_Warehouse_ID = Integer.parseInt (only_Warehouse); - } - catch (Exception ex) - { - } - return only_Warehouse_ID; - } // getOnly_Warehouse_ID - - /** - * Get Product restriction if any. - * @return M_Product_ID or 0 - */ - private int getOnly_Product_ID() - { - if (!Env.isSOTrx(Env.getCtx(), m_WindowNo)) - return 0; // No product restrictions for PO - // - String only_Product = Env.getContext(Env.getCtx(), m_WindowNo, "M_Product_ID", true); - int only_Product_ID = 0; - try - { - if (only_Product != null && only_Product.length () > 0) - only_Product_ID = Integer.parseInt (only_Product); - } - catch (Exception ex) - { - } - return only_Product_ID; - } // getOnly_Product_ID - - /** - * Set the default locator if this field is mandatory - * and we have a warehouse restriction. - * - * @since 3.1.4 - */ - private void setDefault_Locator_ID() - { - // teo_sarca, FR [ 1661546 ] Mandatory locator fields should use defaults - if (!isMandatory() || m_mLocator == null) { - return; - } - int M_Warehouse_ID = getOnly_Warehouse_ID(); - if (M_Warehouse_ID <= 0) { - return; - } - MWarehouse wh = MWarehouse.get(Env.getCtx(), M_Warehouse_ID); - if (wh == null || wh.get_ID() <= 0) { - return; - } - MLocator loc = wh.getDefaultLocator(); - if (loc == null || loc.get_ID() <= 0) { - return; - } - setValue(Integer.valueOf(loc.get_ID())); - } - -} // VLocator - -/*****************************************************************************/ \ No newline at end of file diff --git a/org.adempiere.ui.swing/src/org/compiere/grid/ed/VLocatorDialog.java b/org.adempiere.ui.swing/src/org/compiere/grid/ed/VLocatorDialog.java deleted file mode 100644 index e3431e730e..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/grid/ed/VLocatorDialog.java +++ /dev/null @@ -1,508 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ -package org.compiere.grid.ed; - -import java.awt.BorderLayout; -import java.awt.Frame; -import java.awt.GridBagConstraints; -import java.awt.GridBagLayout; -import java.awt.Insets; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.awt.event.KeyEvent; -import java.awt.event.KeyListener; -import java.sql.PreparedStatement; -import java.sql.ResultSet; -import java.sql.SQLException; -import java.util.logging.Level; - -import javax.swing.JCheckBox; -import javax.swing.JDialog; -import javax.swing.JLabel; - -import org.adempiere.plaf.AdempierePLAF; -import org.compiere.apps.ADialog; -import org.compiere.apps.AEnv; -import org.compiere.apps.ConfirmPanel; -import org.compiere.model.MLocator; -import org.compiere.model.MLocatorLookup; -import org.compiere.model.MRole; -import org.compiere.swing.CComboBox; -import org.compiere.swing.CDialog; -import org.compiere.swing.CPanel; -import org.compiere.swing.CTextField; -import org.compiere.util.CLogger; -import org.compiere.util.DB; -import org.compiere.util.Env; -import org.compiere.util.KeyNamePair; -import org.compiere.util.Msg; - -/** - * Dialog to enter Warehouse Locator Info - * - * @author Jorg Janke - * @version $Id: VLocatorDialog.java,v 1.2 2006/07/30 00:51:28 jjanke Exp $ - */ -public class VLocatorDialog extends CDialog - implements ActionListener, KeyListener -{ - /** - * - */ - private static final long serialVersionUID = 4727764506935600690L; - - /** - * Constructor - * @param frame frame - * @param title title - * @param mLocator locator - * @param M_Locator_ID locator id - * @param mandatory mandatory - * @param only_Warehouse_ID of not 0 restrict warehouse - */ - public VLocatorDialog (Frame frame, String title, MLocatorLookup mLocator, - int M_Locator_ID, boolean mandatory, int only_Warehouse_ID) - { - super (frame, title, true); - m_WindowNo = AEnv.getWindowNo(frame); - try - { - jbInit(); - setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE); - } - catch(Exception ex) - { - log.log(Level.SEVERE, "VLocatorDialog", ex); - } - // - m_mLocator = mLocator; - m_M_Locator_ID = M_Locator_ID; - m_mandatory = mandatory; - m_only_Warehouse_ID = only_Warehouse_ID; - // - initLocator(); - AEnv.positionCenterWindow(frame, this); - } // VLocatorDialog - - private int m_WindowNo; - private boolean m_change = false; - private MLocatorLookup m_mLocator; - private int m_M_Locator_ID; - private boolean m_mandatory = false; - private int m_only_Warehouse_ID = 0; - // - private int m_M_Warehouse_ID; - @SuppressWarnings("unused") - private String m_M_WarehouseName; - private String m_M_WarehouseValue; - private String m_Separator; - @SuppressWarnings("unused") - private int m_AD_Client_ID; - @SuppressWarnings("unused") - private int m_AD_Org_ID; - /** Logger */ - private static CLogger log = CLogger.getCLogger(VLocatorDialog.class); - // - private CPanel panel = new CPanel(); - private CPanel mainPanel = new CPanel(); - private CPanel southPanel = new CPanel(); - private BorderLayout panelLayout = new BorderLayout(); - private GridBagLayout gridBagLayout = new GridBagLayout(); - private ConfirmPanel confirmPanel = new ConfirmPanel(true); - private BorderLayout southLayout = new BorderLayout(); - // - private VComboBox fLocator = new VComboBox(); - private CComboBoxfWarehouse = new CComboBox(); - private JCheckBox fCreateNew = new JCheckBox(); - private CTextField fX = new CTextField(); - private CTextField fY = new CTextField(); - private CTextField fZ = new CTextField(); - private JLabel lLocator = new JLabel(); - private CTextField fWarehouseInfo = new CTextField(); - private CTextField fValue = new CTextField(); - private JLabel lWarehouseInfo = new JLabel(); - private JLabel lWarehouse = new JLabel(); - private JLabel lX = new JLabel(); - private JLabel lY = new JLabel(); - private JLabel lZ = new JLabel(); - private JLabel lValue = new JLabel(); - - /** - * Static component init - * @throws Exception - */ - private void jbInit() throws Exception - { - panel.setLayout(panelLayout); - southPanel.setLayout(southLayout); - mainPanel.setLayout(gridBagLayout); - panelLayout.setHgap(5); - panelLayout.setVgap(10); - fCreateNew.setText(Msg.getMsg(Env.getCtx(), "CreateNew")); - fX.setColumns(15); - fY.setColumns(15); - fZ.setColumns(15); - lLocator.setLabelFor(fLocator); - lLocator.setText(Msg.translate(Env.getCtx(), "M_Locator_ID")); - fWarehouseInfo.setBackground(AdempierePLAF.getFieldBackground_Inactive()); - fWarehouseInfo.setReadWrite(false); - fWarehouseInfo.setColumns(15); - fValue.setColumns(15); - lWarehouseInfo.setLabelFor(fWarehouseInfo); - lWarehouseInfo.setText(Msg.translate(Env.getCtx(), "M_Warehouse_ID")); - lWarehouse.setLabelFor(fWarehouse); - lWarehouse.setText(Msg.translate(Env.getCtx(), "M_Warehouse_ID")); - lX.setLabelFor(fX); - lX.setText(Msg.getElement(Env.getCtx(), "X")); - lY.setLabelFor(fY); - lY.setText(Msg.getElement(Env.getCtx(), "Y")); - lZ.setLabelFor(fZ); - lZ.setText(Msg.getElement(Env.getCtx(), "Z")); - lValue.setLabelFor(fValue); - lValue.setText(Msg.translate(Env.getCtx(), "Value")); - getContentPane().add(panel); - panel.add(mainPanel, BorderLayout.CENTER); - // - mainPanel.add(lLocator, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 5, 0, 5), 0, 0)); - mainPanel.add(fLocator, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 0, 0, 5), 0, 0)); - mainPanel.add(fCreateNew, new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(10, 0, 0, 5), 0, 0)); - mainPanel.add(lWarehouseInfo, new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 5, 0, 5), 0, 0)); - mainPanel.add(fWarehouseInfo, new GridBagConstraints(1, 2, 1, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 0, 0, 5), 0, 0)); - mainPanel.add(lWarehouse, new GridBagConstraints(0, 3, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 5, 0, 5), 0, 0)); - mainPanel.add(fWarehouse, new GridBagConstraints(1, 3, 1, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 0, 0, 5), 0, 0)); - mainPanel.add(lX, new GridBagConstraints(0, 4, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 5, 0, 5), 0, 0)); - mainPanel.add(fX, new GridBagConstraints(1, 4, 1, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 0, 0, 5), 0, 0)); - mainPanel.add(lY, new GridBagConstraints(0, 5, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 5, 0, 5), 0, 0)); - mainPanel.add(fY, new GridBagConstraints(1, 5, 1, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 0, 0, 5), 0, 0)); - mainPanel.add(lZ, new GridBagConstraints(0, 6, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 5, 0, 5), 0, 0)); - mainPanel.add(fZ, new GridBagConstraints(1, 6, 1, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 0, 0, 5), 0, 0)); - mainPanel.add(lValue, new GridBagConstraints(0, 7, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 5, 0, 5), 0, 0)); - mainPanel.add(fValue, new GridBagConstraints(1, 7, 1, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 0, 0, 5), 0, 0)); - // - panel.add(southPanel, BorderLayout.SOUTH); - southPanel.add(confirmPanel, BorderLayout.NORTH); - confirmPanel.addActionListener(this); - } // jbInit - - /** - * Dynanmic Init & fill fields - */ - private void initLocator() - { - log.fine(""); - - // Load Warehouse - String sql = "SELECT M_Warehouse_ID, Name FROM M_Warehouse"; - if (m_only_Warehouse_ID != 0) - sql += " WHERE M_Warehouse_ID=" + m_only_Warehouse_ID; - String SQL = MRole.getDefault().addAccessSQL( - sql, "M_Warehouse", MRole.SQL_NOTQUALIFIED, MRole.SQL_RO) - + " ORDER BY 2"; - PreparedStatement pstmt = null; - ResultSet rs = null; - try - { - pstmt = DB.prepareStatement(SQL, null); - rs = pstmt.executeQuery(); - while (rs.next()) - fWarehouse.addItem(new KeyNamePair(rs.getInt(1), rs.getString(2))); - } - catch (SQLException e) - { - log.log(Level.SEVERE, SQL, e); - } - finally - { - DB.close(rs, pstmt); - rs = null; - pstmt = null; - } - if (log.isLoggable(Level.FINE)) log.fine("Warehouses=" + fWarehouse.getItemCount()); - - // Load existing Locators - m_mLocator.fillComboBox(m_mandatory, true, true, false, false); // IDEMPIERE 90 - if (log.isLoggable(Level.FINE)) log.fine(m_mLocator.toString()); - fLocator.setModel(m_mLocator); - fLocator.setValue(m_M_Locator_ID); - fLocator.addActionListener(this); - displayLocator(); - // - fCreateNew.setSelected(false); - fCreateNew.addActionListener(this); - enableNew(); - // - fWarehouse.addActionListener(this); - fX.addKeyListener(this); - fY.addKeyListener(this); - fZ.addKeyListener(this); - - // Update UI - pack(); - } // initLocator - - - /*************************************************************************/ - - /** - * ActionListener - * @param e event - */ - public void actionPerformed(ActionEvent e) - { - Object source = e.getSource(); - // - if (e.getActionCommand().equals(ConfirmPanel.A_OK)) - { - actionOK(); - m_change = true; - dispose(); - } - else if (e.getActionCommand().equals(ConfirmPanel.A_CANCEL)) - { - m_change = false; - dispose(); - } - // Locator Change - else if (e.getSource() == fLocator) - displayLocator(); - - // New Value Change - else if (source == fCreateNew) - enableNew(); - - // Entered/Changed data for Value - else if (fCreateNew.isSelected() && source == fWarehouse) - createValue(); - - } // actionPerformed - - /** - * KeyListener - nop - * @param e event - */ - public void keyPressed(KeyEvent e) - {} - /** - * KeyListener - * @param e event - */ - public void keyReleased(KeyEvent e) - { - if (fCreateNew.isSelected()) - createValue(); - } - /** - * KeyListener - nop - * @param e event - */ - public void keyTyped(KeyEvent e) - {} - - /** - * Display value of current locator - */ - private void displayLocator() - { - MLocator l = (MLocator) fLocator.getSelectedItem(); - if (l == null) - return; - // - m_M_Locator_ID = l.getM_Locator_ID(); - fWarehouseInfo.setText(l.getWarehouseName()); - fX.setText(l.getX()); - fY.setText(l.getY()); - fZ.setText(l.getZ()); - fValue.setText(l.getValue()); - getWarehouseInfo(l.getM_Warehouse_ID()); - // Set Warehouse - int size = fWarehouse.getItemCount(); - for (int i = 0; i < size; i++) - { - KeyNamePair pp = (KeyNamePair)fWarehouse.getItemAt(i); - if (pp.getKey() == l.getM_Warehouse_ID()) - { - fWarehouse.setSelectedIndex(i); - continue; - } - } - } // displayLocator - - /** - * Enable/disable New data entry - */ - private void enableNew() - { - boolean sel = fCreateNew.isSelected(); - lWarehouse.setVisible(sel); - fWarehouse.setVisible(sel); - lWarehouseInfo.setVisible(!sel); - fWarehouseInfo.setVisible(!sel); - fX.setReadWrite(sel); - fY.setReadWrite(sel); - fZ.setReadWrite(sel); - fValue.setReadWrite(sel); - pack(); - } // enableNew - - /** - * Get Warehouse Info - * @param M_Warehouse_ID warehouse - */ - private void getWarehouseInfo (int M_Warehouse_ID) - { - if (M_Warehouse_ID == m_M_Warehouse_ID) - return; - // Defaults - m_M_Warehouse_ID = 0; - m_M_WarehouseName = ""; - m_M_WarehouseValue = ""; - m_Separator = "."; - m_AD_Client_ID = 0; - m_AD_Org_ID = 0; - // - String SQL = "SELECT M_Warehouse_ID, Value, Name, Separator, AD_Client_ID, AD_Org_ID " - + "FROM M_Warehouse WHERE M_Warehouse_ID=?"; - PreparedStatement pstmt = null; - ResultSet rs = null; - try - { - pstmt = DB.prepareStatement(SQL, null); - pstmt.setInt(1, M_Warehouse_ID); - rs = pstmt.executeQuery(); - if (rs.next()) - { - m_M_Warehouse_ID = rs.getInt(1); - m_M_WarehouseValue = rs.getString(2); - m_M_WarehouseName = rs.getString(3); - m_Separator = rs.getString(4); - m_AD_Client_ID = rs.getInt(5); - m_AD_Org_ID = rs.getInt(6); - } - } - catch (SQLException e) - { - log.log(Level.SEVERE, SQL, e); - } - finally - { - DB.close(rs, pstmt); - rs = null; - pstmt = null; - } - } // getWarehouseInfo - - /** - * Create Locator-Value - */ - private void createValue() - { - // Get Warehouse Info - KeyNamePair pp = (KeyNamePair)fWarehouse.getSelectedItem(); - if (pp == null) - return; - getWarehouseInfo(pp.getKey()); - // - StringBuilder buf = new StringBuilder(m_M_WarehouseValue); - buf.append(m_Separator).append(fX.getText()); - buf.append(m_Separator).append(fY.getText()); - buf.append(m_Separator).append(fZ.getText()); - fValue.setText(buf.toString()); - } // createValue - - /** - * OK - check for changes (save them) & Exit - */ - private void actionOK() - { - if (fCreateNew.isSelected()) - { - // Get Warehouse Info - KeyNamePair pp = (KeyNamePair)fWarehouse.getSelectedItem(); - if (pp != null) - getWarehouseInfo(pp.getKey()); - - // Check mandatory values - String mandatoryFields = ""; - if (m_M_Warehouse_ID == 0) - mandatoryFields += lWarehouse.getText() + " - "; - if (fValue.getText().length()==0) - mandatoryFields += lValue.getText() + " - "; - if (fX.getText().length()==0) - mandatoryFields += lX.getText() + " - "; - if (fY.getText().length()==0) - mandatoryFields += lY.getText() + " - "; - if (fZ.getText().length()==0) - mandatoryFields += lZ.getText() + " - "; - if (mandatoryFields.length() != 0) - { - ADialog.error(m_WindowNo, this, "FillMandatory", mandatoryFields.substring(0, mandatoryFields.length()-3)); - return; - } - - MLocator loc = MLocator.get(Env.getCtx(), m_M_Warehouse_ID, fValue.getText(), - fX.getText(), fY.getText(), fZ.getText()); - m_M_Locator_ID = loc.getM_Locator_ID(); - fLocator.addItem(loc); - fLocator.setSelectedItem(loc); - } // createNew - // - if (log.isLoggable(Level.CONFIG)) log.config("M_Locator_ID=" + m_M_Locator_ID); - } // actionOK - - /** - * Get Selected value - * @return value as Integer - */ - public Integer getValue() - { - MLocator l = (MLocator) fLocator.getSelectedItem(); - if (l != null && l.getM_Locator_ID() != 0) - return Integer.valueOf(l.getM_Locator_ID()); - return null; - } // getValue - - /** - * Get result - * @return true if changed - */ - public boolean isChanged() - { - if (m_change) - { - MLocator l = (MLocator) fLocator.getSelectedItem(); - if (l != null) - return l.getM_Locator_ID() == m_M_Locator_ID; - } - return m_change; - } // getChange - -} // VLocatorDialog diff --git a/org.adempiere.ui.swing/src/org/compiere/grid/ed/VLookup.java b/org.adempiere.ui.swing/src/org/compiere/grid/ed/VLookup.java deleted file mode 100644 index 79abb36910..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/grid/ed/VLookup.java +++ /dev/null @@ -1,1761 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ -package org.compiere.grid.ed; - -import static org.compiere.model.SystemIDs.COLUMN_AD_WF_ACTIVITY_AD_USER_ID; -import static org.compiere.model.SystemIDs.COLUMN_C_INVOICELINE_M_PRODUCT_ID; -import static org.compiere.model.SystemIDs.COLUMN_C_INVOICE_C_BPARTNER_ID; - -import java.awt.BorderLayout; -import java.awt.Color; -import java.awt.Component; -import java.awt.Cursor; -import java.awt.Dimension; -import java.awt.Frame; -import java.awt.Insets; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.awt.event.FocusEvent; -import java.awt.event.FocusListener; -import java.awt.event.KeyEvent; -import java.awt.event.MouseEvent; -import java.beans.PropertyChangeEvent; -import java.beans.PropertyVetoException; -import java.sql.PreparedStatement; -import java.sql.ResultSet; -import java.sql.SQLException; -import java.util.logging.Level; - -import javax.swing.AbstractAction; -import javax.swing.Action; -import javax.swing.ActionMap; -import javax.swing.DefaultComboBoxModel; -import javax.swing.InputMap; -import javax.swing.JComponent; -import javax.swing.JPopupMenu; -import javax.swing.KeyStroke; -import javax.swing.LookAndFeel; -import javax.swing.SwingUtilities; - -import org.adempiere.client.InfoManager; -import org.compiere.apps.ADialog; -import org.compiere.apps.AEnv; -import org.compiere.apps.AWindow; -import org.compiere.apps.FieldRecordInfo; -import org.compiere.apps.search.Info; -import org.compiere.model.GridField; -import org.compiere.model.Lookup; -import org.compiere.model.MBPartnerLocation; -import org.compiere.model.MLocation; -import org.compiere.model.MLookup; -import org.compiere.model.MLookupFactory; -import org.compiere.model.MQuery; -import org.compiere.model.MRole; -import org.compiere.model.MTable; -import org.compiere.model.MZoomCondition; -import org.compiere.swing.CButton; -import org.compiere.swing.CMenuItem; -import org.compiere.swing.CTextField; -import org.compiere.util.CLogger; -import org.compiere.util.DB; -import org.compiere.util.DisplayType; -import org.compiere.util.Env; -import org.compiere.util.Ini; -import org.compiere.util.Msg; -import org.compiere.util.NamePair; -import org.compiere.util.ValueNamePair; - -/** - * Lookup Visual Field. - *

    - * When r/o - display a Label - * When STABLE - display a ComboBox - * Otherwise show Selection Dialog - *

    - * Special handling of BPartner and Product - * - * @author Jorg Janke - * @version $Id: VLookup.java,v 1.5 2006/10/06 00:42:38 jjanke Exp $ - * - * @author Teo Sarca, SC ARHIPAC SERVICE SRL - *

  • BF [ 1740835 ] NPE when closing a window - *
  • BF [ 1817768 ] Isolate hardcoded table direct columns - *
  • BF [ 1834399 ] VLookup: pressing enter twice has a annoying behaviour - *
  • BF [ 1979213 ] VLookup.getDirectAccessSQL issue - *
  • BF [ 2552901 ] VLookup: TAB is not working OK - * @author Michael Judd (MultiSelect) - * - * @author hengsin, hengsin.low@idalica.com - * @see FR [2887701] https://sourceforge.net/tracker/?func=detail&atid=879335&aid=2887701&group_id=176962 - * @sponsor www.metas.de - */ -public class VLookup extends JComponent - implements VEditor, ActionListener, FocusListener -{ - /** - * - */ - private static final long serialVersionUID = 3156026335667188091L; - - /***************************************************************************** - * Mouse Listener for Popup Menu - */ - final class VLookup_mouseAdapter extends java.awt.event.MouseAdapter - { - /** - * Constructor - * @param adaptee adaptee - */ - VLookup_mouseAdapter(VLookup adaptee) - { - m_adaptee = adaptee; - } // VLookup_mouseAdapter - - private VLookup m_adaptee; - - /** - * Mouse Listener - * @param e MouseEvent - */ - public void mouseClicked(MouseEvent e) - { - // System.out.println("mouseClicked " + e.getID() + " " + e.getSource().getClass().toString()); - // popup menu - if (SwingUtilities.isRightMouseButton(e)) - m_adaptee.popupMenu.show((Component)e.getSource(), e.getX(), e.getY()); - // Hide the popup if not right click - teo_sarca [ 1734802 ] - else - m_adaptee.popupMenu.setVisible(false); - } // mouse Clicked - - } // VLookup_mouseAdapter - - - @Override - protected boolean processKeyBinding(KeyStroke ks, KeyEvent e, - int condition, boolean pressed) { - if (e.getSource() == m_combo || e.getSource() == m_text || e.getSource() == this) { - return super.processKeyBinding(ks, e, condition, pressed); - } - - JComponent editorComp = null; - if (m_lookup != null && m_lookup.getDisplayType() != DisplayType.Search) - editorComp = m_combo; - else - editorComp = m_text; - InputMap map = editorComp.getInputMap(condition); - ActionMap am = editorComp.getActionMap(); - - if(map!=null && am!=null && isEnabled()){ - Object binding = map.get(ks); - Action action = (binding==null) ? null : am.get(binding); - if(action!=null){ - return SwingUtilities.notifyAction(action, ks, e, editorComp, - e.getModifiersEx()); - } - } - return false; - } - - /** - * Create Optional BPartner Search Lookup - * @param WindowNo window - * @return VLookup - */ - public static VLookup createBPartner (int WindowNo) - { - int AD_Column_ID = COLUMN_C_INVOICE_C_BPARTNER_ID; // C_Invoice.C_BPartner_ID - try - { - Lookup lookup = MLookupFactory.get (Env.getCtx(), WindowNo, - 0, AD_Column_ID, DisplayType.Search); - return new VLookup ("C_BPartner_ID", false, false, true, lookup); - } - catch (Exception e) - { - log.log(Level.SEVERE, "", e); - } - return null; - } // createBPartner - - /** - * Create Optional Product Search Lookup - * @param WindowNo window - * @return VLookup - */ - public static VLookup createProduct (int WindowNo) - { - int AD_Column_ID = COLUMN_C_INVOICELINE_M_PRODUCT_ID; // C_InvoiceLine.M_Product_ID - try - { - Lookup lookup = MLookupFactory.get (Env.getCtx(), WindowNo, 0, - AD_Column_ID, DisplayType.Search); - return new VLookup ("M_Product_ID", false, false, true, lookup); - } - catch (Exception e) - { - log.log(Level.SEVERE, "", e); - } - return null; - } // createProduct - - /** - * Create Optional User Search Lookup - * @param WindowNo window - * @return VLookup - */ - public static VLookup createUser (int WindowNo) - { - int AD_Column_ID = COLUMN_AD_WF_ACTIVITY_AD_USER_ID; // AD_WF_Activity.AD_User_UD - try - { - Lookup lookup = MLookupFactory.get (Env.getCtx(), WindowNo, 0, - AD_Column_ID, DisplayType.Search); - return new VLookup ("AD_User_ID", false, false, true, lookup); - } - catch (Exception e) - { - log.log(Level.SEVERE, "", e); - } - return null; - } // createProduct - - - /************************************************************************* - * Detail Constructor - * - * @param columnName column - * @param mandatory mandatory - * @param isReadOnly read only - * @param isUpdateable updateable - * @param lookup lookup - */ - public VLookup (String columnName, boolean mandatory, boolean isReadOnly, boolean isUpdateable, - Lookup lookup) - { - super(); - super.setName(columnName); - m_combo.setName(columnName); - m_columnName = columnName; - setMandatory(mandatory); - m_lookup = lookup; - if (m_lookup != null) - m_lookup.setMandatory(mandatory); - // - setLayout(new BorderLayout()); - mouseAdapter = new VLookup_mouseAdapter(this); // popup - - // *** Text & Button *** - m_text.addActionListener(this); - m_text.addFocusListener(this); - m_text.addMouseListener(mouseAdapter); - // Button - m_button.addActionListener(this); - m_button.addMouseListener(mouseAdapter); - m_button.setFocusable(false); // don't focus when tabbing - m_button.setMargin(new Insets(0, 0, 0, 0)); - if (columnName.equals("C_BPartner_ID")) - m_button.setIcon(Env.getImageIcon("BPartner10.gif")); - else if (columnName.equals("M_Product_ID")) - m_button.setIcon(Env.getImageIcon("Product10.gif")); - else - m_button.setIcon(Env.getImageIcon("PickOpen10.gif")); - - // IDEMPIERE 90 - boolean isShortListAvailable = false; // Short List available for this lookup - if (m_lookup != null && (m_lookup.getDisplayType() == DisplayType.TableDir || m_lookup.getDisplayType() == DisplayType.Table)) // only for Table & TableDir - { - String tableName_temp = m_lookup.getColumnName(); // Returns AD_Org.AD_Org_ID - int posPoint = tableName_temp.indexOf("."); - String tableName = tableName_temp.substring(0, posPoint); - MTable table = MTable.get(Env.getCtx(), tableName); - isShortListAvailable = (table.getColumnIndex("IsShortList") >= 0); - if (isShortListAvailable) - { - setComboShortList(true); - m_lookup.setShortList(true); - - m_buttonSL.addActionListener(this); - m_buttonSL.addMouseListener(mouseAdapter); - m_buttonSL.setFocusable(false); // don't focus when tabbing - m_buttonSL.setMargin(new Insets(0, 0, 0, 0)); - m_buttonSL.setIcon(Env.getImageIcon("LockX16.gif")); - m_buttonSL.setToolTipText(Msg.getMsg(Env.getCtx(), "ShortListShortListItems")); - ActionMap am = m_combo.getActionMap(); - am.put("shortlist", new AbstractAction() { - /** - * - */ - private static final long serialVersionUID = 371998095806934367L; - - @Override - public void actionPerformed(ActionEvent e) { - actionShortList(); - } - }); - m_combo.getInputMap(WHEN_ANCESTOR_OF_FOCUSED_COMPONENT) - .put(KeyStroke.getKeyStroke(KeyEvent.VK_L, KeyEvent.CTRL_DOWN_MASK), "shortlist"); - } - } - // IDEMPIERE 90 - - // *** VComboBox *** - if (m_lookup != null && m_lookup.getDisplayType() != DisplayType.Search) // No Search - { - // Don't have to fill up combobox if it is readonly - if (!isReadOnly && isUpdateable) - m_lookup.fillComboBox (isMandatory(), true, true, false, isShortListAvailable); // IDEMPIERE 90 - m_combo.setModel(m_lookup); - // - // AutoCompletion.enable(m_combo); - m_combo.addActionListener(this); // Selection - m_combo.getEditor().getEditorComponent().addMouseListener(mouseAdapter); // popup - // FocusListener to refresh selection before opening - m_combo.addFocusListener(this); - m_combo.getEditor().getEditorComponent().addFocusListener(this); - } - - setUI (true); - // ReadWrite - decides what components to show - if (isReadOnly || !isUpdateable || m_lookup == null) - setReadWrite(false); - else - setReadWrite(true); - - // Popup - if (m_lookup != null) - { - if ((m_lookup.getDisplayType() == DisplayType.List && Env.getContextAsInt(Env.getCtx(), "#AD_Role_ID") == 0) - || m_lookup.getDisplayType() != DisplayType.List) // only system admins can change lists, so no need to zoom for others - { - mZoom = new CMenuItem(Msg.getMsg(Env.getCtx(), "Zoom"), Env.getImageIcon("Zoom16.gif")); - mZoom.addActionListener(this); - popupMenu.add(mZoom); - } - mRefresh = new CMenuItem(Msg.getMsg(Env.getCtx(), "Refresh"), Env.getImageIcon("Refresh16.gif")); - mRefresh.addActionListener(this); - popupMenu.add(mRefresh); - } - // VBPartner quick entry link - if (columnName.equals("C_BPartner_ID")) - { - mBPartnerNew = new CMenuItem (Msg.getMsg(Env.getCtx(), "New"), Env.getImageIcon("InfoBPartner16.gif")); - mBPartnerNew.addActionListener(this); - mBPartnerNew.setVisible(isReadWrite()); // visible only if the field is editable - teo_sarca [ 1721710 ] - popupMenu.add(mBPartnerNew); - mBPartnerUpd = new CMenuItem (Msg.getMsg(Env.getCtx(), "Update"), Env.getImageIcon("InfoBPartner16.gif")); - mBPartnerUpd.addActionListener(this); - popupMenu.add(mBPartnerUpd); - } - if ((columnName.toUpperCase().equals("C_BPARTNER_LOCATION_ID")) - || (columnName.toUpperCase().equals("BILL_LOCATION_ID")) - || (columnName.toUpperCase().equals("DROPSHIP_LOCATION_ID"))) - { - m_location = new CMenuItem (Msg.getMsg(Env.getCtx(), "ShowLocation"), Env.getImageIcon("InfoBPartner16.gif")); - m_location.addActionListener(this); - popupMenu.add(m_location); - } - // - if (m_lookup != null && m_lookup.getZoom() == 0) - mZoom.setEnabled(false); - } // VLookup - - /** - * Dispose - */ - public void dispose() - { - m_text = null; - m_button = null; - m_lookup = null; - m_mField = null; - m_buttonSL = null; // IDEMPIERE 90 - // - m_combo.getEditor().getEditorComponent().removeFocusListener(this); - m_combo.getEditor().getEditorComponent().removeMouseListener(mouseAdapter); - m_combo.removeFocusListener(this); - m_combo.removeActionListener(this); - m_combo.setModel(new DefaultComboBoxModel()); // remove reference - // m_combo.removeAllItems(); - m_combo = null; - } // dispose - - /** Display Length for Lookups (15) */ - public final static int DISPLAY_LENGTH = 15; - /** Field Height */ - public static int FIELD_HIGHT = 0; - - /** Search: The Editable Text Field */ - private CTextField m_text = new CTextField (DISPLAY_LENGTH); - /** Search: The Button to open Editor */ - private CButton m_button = new CButton(); - /** The Combo Box if not a Search Lookup */ - private VComboBox m_combo = new VComboBox(); - /** Indicator that value is being set */ - private volatile boolean m_settingValue = false; - /** Indicator that docus is being set */ - private volatile boolean m_settingFocus = false; - /** Indicator that Lookup has focus */ - private volatile boolean m_haveFocus = false; - /** Indicator - inserting new value */ - private volatile boolean m_inserting = false; - /** Last Display */ - private String m_lastDisplay = ""; - /** Column Name */ - private String m_columnName; - /** Lookup */ - private Lookup m_lookup; - /** Conbo Box Active */ - private boolean m_comboActive = true; - /** The Value */ - private Object m_value; - - private boolean m_stopediting = false; - - // Popup - JPopupMenu popupMenu = new JPopupMenu(); - private CMenuItem mZoom; - private CMenuItem mRefresh; - private CMenuItem mBPartnerNew; - private CMenuItem mBPartnerUpd; - private CMenuItem m_location; - // Mouse Listener - private VLookup_mouseAdapter mouseAdapter; - - /** ShortList button IDEMPIERE 90 */ - private CButton m_buttonSL = new CButton(); - - /** All items or only those of the short list ?*/ - boolean onlyShortListItems = false; - - // Field for Value Preference - private GridField m_mField = null; - /** Logger */ - private static CLogger log = CLogger.getCLogger(VLookup.class); - - /** - * Set Content and Size of Components - * @param initial if true, size and margins will be set - */ - private void setUI (boolean initial) - { - if (initial) - { - Dimension size = m_text.getPreferredSize(); - setPreferredSize(new Dimension(size)); // causes r/o to be the same length - m_combo.setPreferredSize(new Dimension(size)); - setMinimumSize(new Dimension (30, size.height)); - FIELD_HIGHT = size.height; - // - m_text.setBorder(null); - Dimension bSize = new Dimension(size.height, size.height); - m_button.setPreferredSize (bSize); - m_buttonSL.setPreferredSize (bSize); // IDEMPIERE 90 - } - - // What to show - this.remove(m_combo); - this.remove(m_button); - this.remove(m_buttonSL); // IDEMPIERE 90 - this.remove(m_text); - // - if (!isReadWrite()) // r/o - show text only - { - LookAndFeel.installBorder(this, "TextField.border"); - this.add(m_text, BorderLayout.CENTER); - m_text.setReadWrite(false); - m_combo.setReadWrite(false); - m_comboActive = false; - } - else if (m_lookup != null && m_lookup.getDisplayType() != DisplayType.Search) // show combo if not Search - { - this.setBorder(null); - this.add(m_combo, BorderLayout.CENTER); - m_comboActive = true; - // IDEMPIERE 90 - if (isComboShortList()) - this.add(m_buttonSL, BorderLayout.EAST); // add a button for short list items <-> all items - } - else // Search or unstable - show text & button - { - LookAndFeel.installBorder(this, "TextField.border"); - this.add(m_text, BorderLayout.CENTER); - this.add(m_button, BorderLayout.EAST); - m_text.setReadWrite (true); - m_comboActive = false; - } - } // setUI - - /** - * Set ReadWrite - * @param value ReadWrite - */ - public void setReadWrite (boolean value) - { - boolean rw = value; - if (m_lookup == null) - rw = false; - if (m_combo.isReadWrite() != value) - { - m_combo.setReadWrite(rw); - setUI (false); - if (value && m_comboActive) { - m_settingValue = true; // disable actions - refresh(); - m_settingValue = false; - } - if (m_comboActive) - setValue (m_value); - } - // If the field is readonly the BPartner new option should be hidden - teo_sarca [ 1721710 ] - if (mBPartnerNew != null) - mBPartnerNew.setVisible(value); - } // setReadWrite - - /** - * IsEditable - * @return is lookup ReadWrite - */ - public boolean isReadWrite() - { - if (m_combo != null) - return m_combo.isReadWrite(); - return true; - } // isReadWrite - - /** - * Set Mandatory (and back color) - * @param mandatory mandatory - */ - public void setMandatory (boolean mandatory) - { - m_combo.setMandatory(mandatory); - m_text.setMandatory(mandatory); - } // setMandatory - - /** - * Is it mandatory - * @return true if mandatory - */ - public boolean isMandatory() - { - return m_combo.isMandatory(); - } // isMandatory - - /** - * Set Background - * @param color color - */ - public void setBackground(Color color) - { - m_text.setBackground(color); - m_combo.setBackground(color); - } // setBackground - - /** - * Set Background - * @param error error - */ - public void setBackground (boolean error) - { - m_text.setBackground(error); - m_combo.setBackground(error); - } // setBackground - - /** - * Set Foreground - * @param fg Foreground color - */ - public void setForeground(Color fg) - { - m_text.setForeground(fg); - m_combo.setForeground(fg); - } // setForeground - - /** - * Request Focus - */ - public void requestFocus () - { - if (m_lookup != null && m_lookup.getDisplayType() != DisplayType.Search) - m_combo.requestFocus (); - else - m_text.requestFocus (); - } // requestFocus - - /** - * Request Focus In Window - * @return focus request - */ - @Override - public boolean requestFocusInWindow() - { - if (m_lookup != null && m_lookup.getDisplayType() != DisplayType.Search) - return m_combo.requestFocusInWindow(); - return m_text.requestFocusInWindow(); - } // requestFocusInWindow - - /** - * Get Focus Component - * @return component - */ - public Component getFocusableComponent() - { - if (m_lookup != null && m_lookup.getDisplayType() != DisplayType.Search) - return m_combo; - return m_text; - } // getFocusComponent - - /** - * Set Editor to value - * @param value new Value - */ - public void setValue (Object value) - { - if (log.isLoggable(Level.FINE)) log.fine(m_columnName + "=" + value); - m_settingValue = true; // disable actions - m_value = value; - - // Set both for switching - if (value == null) - { - m_combo.setValue (value); - m_text.setText (null); - m_lastDisplay = ""; - m_settingValue = false; - return; - } - if (m_lookup == null) - { - m_combo.setValue (value); - m_text.setText (value.toString()); - m_lastDisplay = value.toString(); - m_settingValue = false; - return; - } - - //must call m_combo.setvalue after m_lookup as - //loading of combo data might happen in m_lookup.getDisplay - m_lastDisplay = m_lookup.getDisplay(value); - m_combo.setValue (value); - - if (m_lastDisplay.equals("<-1>")) - { - m_lastDisplay = ""; - m_value = null; - } - boolean notFound = m_lastDisplay.startsWith("<") && m_lastDisplay.endsWith(">"); - m_text.setText (m_lastDisplay); - m_text.setCaretPosition (0); // show beginning - - // Nothing showing in Combo and should be showing - if (m_combo.getSelectedItem() == null - && (m_comboActive || (m_inserting && m_lookup.getDisplayType() != DisplayType.Search))) - { - // lookup found nothing too - if (notFound) - { - if (log.isLoggable(Level.FINEST)) log.finest(m_columnName + "=" + value + ": Not found - " + m_lastDisplay); - // we may have a new value - m_lookup.refresh(); - m_combo.setValue (value); - m_lastDisplay = m_lookup.getDisplay(value); - m_text.setText (m_lastDisplay); - m_text.setCaretPosition (0); // show beginning - notFound = m_lastDisplay.startsWith("<") && m_lastDisplay.endsWith(">"); - } - if (notFound && value instanceof Integer && m_lookup.getDisplayType() != DisplayType.ID) // for IDs is ok to be out of the list - { - m_value = null; - actionCombo (null); // data binding - if (log.isLoggable(Level.FINE)) log.fine(m_columnName + "=" + value + ": Not found"); - } - // we have lookup - else if (m_combo.getSelectedItem() == null) - { - NamePair pp = m_lookup.get(value); - if (pp != null) - { - if (log.isLoggable(Level.FINE)) log.fine(m_columnName + " added to combo - " + pp); - // Add to Combo - m_combo.addItem (pp); - m_combo.setValue (value); - } - } - // Not in Lookup - set to Null - if (m_combo.getSelectedItem() == null) - { - if (value instanceof Integer && m_lookup.getDisplayType() != DisplayType.ID) // for IDs is ok to be out of the list - { - if (log.isLoggable(Level.INFO)) log.info(m_columnName + "=" + value + ": not in Lookup - set to NULL"); - actionCombo (null); // data binding (calls setValue again) - m_value = null; - } - } - } - m_settingValue = false; - } // setValue - - /** - * Property Change Listener - * @param evt PropertyChangeEvent - */ - public void propertyChange (PropertyChangeEvent evt) - { - if (m_stopediting) - return; - - // log.fine( "VLookup.propertyChange", evt); - if (evt.getPropertyName().equals(GridField.PROPERTY)) - { - m_inserting = GridField.INSERTING.equals(evt.getOldValue()); // MField.setValue - setValue(evt.getNewValue()); - m_inserting = false; - } - } // propertyChange - - /** - * Return Editor value (Integer) - * @return value - */ - public Object getValue() - { - if (m_comboActive) - return m_combo.getValue (); - return m_value; - } // getValue - - /** - * Return editor display - * @return display value - */ - public String getDisplay() - { - String retValue = null; - if (m_comboActive) - retValue = m_combo.getDisplay(); - // check lookup - else if (m_lookup == null) - retValue = m_value == null ? null : m_value.toString(); - else - retValue = m_lookup.getDisplay(m_value); - // log.fine( "VLookup.getDisplay - " + retValue, "ComboActive=" + m_comboActive); - return retValue; - } // getDisplay - - /** - * Set Field/WindowNo for ValuePreference - * @param mField Model Field for Lookup - */ - public void setField (GridField mField) - { - m_mField = mField; - if (m_mField != null - && MRole.getDefault().isShowPreference() - && !mField.isEncrypted() && !mField.isEncryptedColumn()) - ValuePreference.addMenu (this, popupMenu); - - if (m_mField != null) - FieldRecordInfo.addMenu(this, popupMenu); - } // setField - - @Override - public GridField getField() { - return m_mField; - } - - /************************************************************************** - * Action Listener - data binding - * @param e ActionEvent - */ - public void actionPerformed (ActionEvent e) - { - if (m_settingValue || m_settingFocus || m_stopediting) - return; - if (log.isLoggable(Level.CONFIG)) log.config(m_columnName + " - " + e.getActionCommand() + ", ComboValue=" + m_combo.getSelectedItem()); - // log.fine("Hash=" + this.hashCode()); - - // Preference - if (e.getActionCommand().equals(ValuePreference.NAME)) - { - if (MRole.getDefault().isShowPreference() && !m_mField.isEncrypted() && !m_mField.isEncryptedColumn()) - ValuePreference.start (m_mField, getValue(), getDisplay()); - return; - } - else if (e.getActionCommand().equals(FieldRecordInfo.CHANGE_LOG_COMMAND)) - { - FieldRecordInfo.start(m_mField); - return; - } - - // Combo Selection - else if (e.getSource() == m_combo) - { - Object value = getValue(); - Object o = m_combo.getSelectedItem(); - if (o != null) - { - String s = o.toString(); - // don't allow selection of inactive - if (s.startsWith(MLookup.INACTIVE_S) && s.endsWith(MLookup.INACTIVE_E)) - { - if (log.isLoggable(Level.INFO)) log.info(m_columnName + " - selection inactive set to NULL"); - value = null; - } - } - actionCombo (value); // data binding - } - // Button pressed - else if (e.getSource() == m_button) - actionButton (""); - // Text entered - else if (e.getSource() == m_text) - actionText(); - - // Popup Menu - else if (e.getSource() == mZoom) - actionZoom(m_combo.getSelectedItem()); - else if (e.getSource() == mRefresh) - actionRefresh(); - else if (e.getSource() == mBPartnerNew) - actionBPartner(true); - else if (e.getSource() == mBPartnerUpd) - actionBPartner(false); - else if (e.getSource() == m_location) - actionLocation(); - else if (e.getSource() == m_buttonSL) // IDEMPIERE 90 - actionShortList(); - } // actionPerformed - - /** - * Action Listener Interface - * @param listener listener - */ - public void addActionListener(ActionListener listener) - { - m_combo.addActionListener(listener); - m_text.addActionListener(listener); - } // addActionListener - - /** - * Action - Combo. - *
    - * == dataBinding == inform of new value - *
    -	 *  VLookup.actionCombo
    -	 *      GridController.vetoableChange
    -	 *          MTable.setValueAt
    -	 *              MField.setValue
    -	 *                  VLookup.setValue
    -	 *          MTab.dataStatusChanged
    -	 *  
    - * @param value new value - */ - private void actionCombo (Object value) - { - if (log.isLoggable(Level.FINE)) log.fine("Value=" + value); - try - { - // -> GridController.vetoableChange - fireVetoableChange (m_columnName, null, value); - } - catch (PropertyVetoException pve) - { - log.log(Level.SEVERE, m_columnName, pve); - } - // is the value updated ? - boolean updated = false; - - Object updatedValue = value; - - if (updatedValue instanceof Object[] && ((Object[])updatedValue).length > 0) - { - updatedValue = ((Object[])updatedValue)[0]; - } - - if (updatedValue == null && m_value == null) - updated = true; - else if (updatedValue != null && value.equals(m_value)) - updated = true; - if (!updated) - { - // happens if VLookup is used outside of APanel/GridController (no property listener) - if (log.isLoggable(Level.FINE)) log.fine(m_columnName + " - Value explicitly set - new=" + updatedValue + ", old=" + m_value); - - // phib: the following check causes the update to fail on jre > 1.6.0_13 - // commenting out as it does not appear to be necessary - //if (getListeners(PropertyChangeListener.class).length <= 0) - setValue(updatedValue); - } - } // actionCombo - - - /** - * Action - Button. - * - Call Info - * @param queryValue initial query value - */ - private void actionButton (String queryValue) - { - m_button.setEnabled(false); // disable double click - if (m_lookup == null) - return; // leave button disabled - m_text.requestFocus(); // closes other editors - Frame frame = AEnv.getFrame(this); - - /** - * Three return options: - * - Value Selected & OK pressed => store result => result has value - * - Cancel pressed => store null => result == null && cancelled - * - Window closed -> ignore => result == null && !cancalled - */ - - Object result[] = null; - boolean cancelled = false; - boolean multipleSelection = false; - // - // Zoom / Validation - String whereClause = getWhereClause(); - // - if (log.isLoggable(Level.FINE)) log.fine(m_lookup.getColumnName() - + ", Zoom=" + m_lookup.getZoom() - + " (" + whereClause + ")"); - // - Info info = null; - - // Reset - resetTabInfo(); - if (m_tableName == null) // sets table name & key column - getDirectAccessSQL("*"); - - // Replace Value with name if no value exists - if (queryValue.length() == 0 && m_text.getText().length() > 0) - queryValue = m_text.getText(); - - info = InfoManager.create(frame, true, m_lookup, m_mField, m_tableName, m_keyColumnName, - queryValue, multipleSelection, whereClause); - - info.setVisible(true); - cancelled = info.isCancelled(); - result = info.getSelectedKeys(); - - // Result - if (result != null && result.length > 0) - { - if (log.isLoggable(Level.CONFIG)) log.config(m_columnName + " - Result = " + result.toString() + " (" + result.getClass().getName() + ")"); - // make sure that value is in cache - m_lookup.getDirect(result[0], false, true); - if (info.isResetValue()) - actionCombo (null); - // juddm added logic for multi-select handling - if (result.length > 1) - actionCombo (result); // data binding - else - actionCombo (result[0]); - - } - else if (cancelled) - { - if (log.isLoggable(Level.CONFIG)) log.config(m_columnName + " - Result = null (cancelled)"); - actionCombo(null); - } - else - { - if (log.isLoggable(Level.CONFIG)) log.config(m_columnName + " - Result = null (not cancelled)"); - setValue(m_value); // to re-display value - } - // - m_button.setEnabled(true); - m_text.requestFocus(); - } // actionButton - - /** - * Get Where Clause - * @return where clause or "" - */ - private String getWhereClause() - { - String whereClause = ""; - if (m_lookup == null) - return ""; - if (m_lookup.getZoomQuery() != null) - whereClause = m_lookup.getZoomQuery().getWhereClause(); - String validation = m_lookup.getValidation(); - if (validation == null) - validation = ""; - if (whereClause.length() == 0) - whereClause = validation; - else if (validation.length() > 0) - whereClause += " AND " + validation; - // log.finest("ZoomQuery=" + (m_lookup.getZoomQuery()==null ? "" : m_lookup.getZoomQuery().getWhereClause()) - // + ", Validation=" + m_lookup.getValidation()); - if (whereClause.indexOf('@') != -1) - { - String validated = Env.parseContext(Env.getCtx(), m_lookup.getWindowNo(), whereClause, false); - if (validated.length() == 0) - log.severe(m_columnName + " - Cannot Parse=" + whereClause); - else - { - if (log.isLoggable(Level.FINE)) log.fine(m_columnName + " - Parsed: " + validated); - return validated; - } - } - return whereClause; - } // getWhereClause - - /** - * - * - * - */ - /*private String getExtraWhereClause (String text) - { - StringBuilder sql = new StringBuilder(); - m_tableName = m_columnName.substring(0, m_columnName.length()-3); - m_keyColumnName = m_columnName; - // - if (m_columnName.equals("M_Product_ID")) - { - // Reset - resetTabInfo(); - // - sql.append(" AND (UPPER(p.Value) LIKE ") - .append(DB.TO_STRING(text)) - .append(" OR UPPER(p.Name) LIKE ").append(DB.TO_STRING(text)) - .append(" OR p.SKU LIKE ").append(DB.TO_STRING(text)).append(")"); - //.append(" OR p.SKU LIKE ").append(DB.TO_STRING(text)) - //.append(" OR p.UPC LIKE ").append(DB.TO_STRING(text)).append(")"); - } - // Predefined - - if (sql.length() > 0) - { - String wc = getWhereClause(); - if (wc != null && wc.length() > 0) - sql.append(" AND ").append(wc); - sql.append(" AND IsActive='Y'"); - // *** - if (log.isLoggable(Level.FINEST)) log.finest(m_columnName + " (predefined) " + sql.toString()); - return MRole.getDefault().addAccessSQL(sql.toString(), - m_tableName, MRole.SQL_NOTQUALIFIED, MRole.SQL_RO); - } - - return sql.toString(); - }*/ - /** - * Check, if data returns unique entry, otherwise involve Info via Button - */ - private void actionText() - { - String text = m_text.getText(); - // Nothing entered, just pressing enter again => ignore - teo_sarca BF [ 1834399 ] - if (text != null && text.length() > 0 && text.equals(m_lastDisplay)) - { - log.finest("Nothing entered [SKIP]"); - return; - } - // Nothing entered - if (text == null || text.length() == 0 || text.equals("%")) - { - actionButton(text); - return; - } - text = text.toUpperCase(); - if (log.isLoggable(Level.CONFIG)) log.config(m_columnName + " - " + text); - - // Exact first - PreparedStatement pstmt = null; - ResultSet rs = null; - String finalSQL = Msg.parseTranslation(Env.getCtx(), getDirectAccessSQL(text)); - int id = -3; - try - { - pstmt = DB.prepareStatement(finalSQL, null); - rs = pstmt.executeQuery(); - if (rs.next()) - { - id = rs.getInt(1); // first - if (rs.next()) - id = -1; // only if unique - } - } - catch (Exception e) - { - log.log(Level.SEVERE, finalSQL, e); - id = -2; - } - finally { - DB.close(rs, pstmt); - rs = null; pstmt = null; - } - // Try like - if (id == -3 && !text.endsWith("%")) - { - text += "%"; - finalSQL = Msg.parseTranslation(Env.getCtx(), getDirectAccessSQL(text)); - try - { - pstmt = DB.prepareStatement(finalSQL, null); - rs = pstmt.executeQuery(); - if (rs.next()) - { - id = rs.getInt(1); // first - if (rs.next()) - id = -1; // only if unique - } - } - catch (Exception e) - { - log.log(Level.SEVERE, finalSQL, e); - id = -2; - } - finally - { - DB.close(rs, pstmt); - rs = null; pstmt = null; - } - } - - // No (unique) result - if (id <= 0) - { - if (id == -3) { - if (log.isLoggable(Level.FINE)) log.fine(m_columnName + " - Not Found - " + finalSQL); - } else { - if (log.isLoggable(Level.FINE)) log.fine(m_columnName + " - Not Unique - " + finalSQL); - } - m_value = null; // force re-display - actionButton(m_text.getText()); - return; - } - if (log.isLoggable(Level.FINE)) log.fine(m_columnName + " - Unique ID=" + id); - m_value = null; // forces re-display if value is unchanged but text updated and still unique - resetTabInfo(); - actionCombo (Integer.valueOf(id)); // data binding - // - // Don't request focus if value was solved - teo_sarca [ 2552901 ] - if (id <= 0) - { - m_text.requestFocus(); - } - } // actionText - - - private String m_tableName = null; - private String m_keyColumnName = null; - - /** - * Generate Access SQL for Search. - * The SQL returns the ID of the value entered - * Also sets m_tableName and m_keyColumnName - * @param text uppercase text for LIKE comparison - * @return sql or "" - * Example - * SELECT C_Payment_ID FROM C_Payment WHERE UPPER(DocumentNo) LIKE x OR ... - */ - private String getDirectAccessSQL (String text) - { - StringBuffer sql = new StringBuffer(); - m_tableName = MQuery.getZoomTableName(m_columnName); - m_keyColumnName = MQuery.getZoomColumnName(m_columnName); - // - if (m_columnName.equals("M_Product_ID")) - { - // Reset - resetTabInfo(); - // - sql.append("SELECT M_Product_ID FROM M_Product WHERE (UPPER(Value) LIKE ") - .append(DB.TO_STRING(text)) - .append(" OR UPPER(Name) LIKE ").append(DB.TO_STRING(text)) - .append(" OR SKU LIKE ").append(DB.TO_STRING(text)) - .append(" OR UPC LIKE ").append(DB.TO_STRING(text)).append(")"); - } - else if (m_columnName.equals("C_BPartner_ID")) - { - sql.append("SELECT C_BPartner_ID FROM C_BPartner WHERE (UPPER(Value) LIKE ") - .append(DB.TO_STRING(text)) - .append(" OR UPPER(Name) LIKE ").append(DB.TO_STRING(text)).append(")"); - } - else if (m_columnName.equals("C_Order_ID")) - { - sql.append("SELECT C_Order_ID FROM C_Order WHERE UPPER(DocumentNo) LIKE ") - .append(DB.TO_STRING(text)); - } - else if (m_columnName.equals("C_Invoice_ID")) - { - sql.append("SELECT C_Invoice_ID FROM C_Invoice WHERE UPPER(DocumentNo) LIKE ") - .append(DB.TO_STRING(text)); - } - else if (m_columnName.equals("M_InOut_ID")) - { - sql.append("SELECT M_InOut_ID FROM M_InOut WHERE UPPER(DocumentNo) LIKE ") - .append(DB.TO_STRING(text)); - } - else if (m_columnName.equals("C_Payment_ID")) - { - sql.append("SELECT C_Payment_ID FROM C_Payment WHERE UPPER(DocumentNo) LIKE ") - .append(DB.TO_STRING(text)); - } - else if (m_columnName.equals("GL_JournalBatch_ID")) - { - sql.append("SELECT GL_JournalBatch_ID FROM GL_JournalBatch WHERE UPPER(DocumentNo) LIKE ") - .append(DB.TO_STRING(text)); - } - else if (m_columnName.equals("SalesRep_ID")) - { - sql.append("SELECT AD_User_ID FROM AD_User WHERE UPPER(Name) LIKE ") - .append(DB.TO_STRING(text)); - m_tableName = "AD_User"; - m_keyColumnName = "AD_User_ID"; - } - // Predefined - if (sql.length() > 0) - { - String wc = getWhereClause(); - if (wc != null && wc.length() > 0) - sql.append(" AND ").append(wc); - sql.append(" AND IsActive='Y'"); - // *** - if (log.isLoggable(Level.FINEST)) log.finest(m_columnName + " (predefined) " + sql.toString()); - return MRole.getDefault().addAccessSQL(sql.toString(), - m_tableName, MRole.SQL_NOTQUALIFIED, MRole.SQL_RO); - } - - // Check if it is a Table Reference - if (m_lookup != null && m_lookup instanceof MLookup) - { - int AD_Reference_ID = ((MLookup)m_lookup).getAD_Reference_Value_ID(); - if (AD_Reference_ID != 0) - { - String query = "SELECT kc.ColumnName, dc.ColumnName, t.TableName " - + "FROM AD_Ref_Table rt" - + " INNER JOIN AD_Column kc ON (rt.AD_Key=kc.AD_Column_ID)" - + " INNER JOIN AD_Column dc ON (rt.AD_Display=dc.AD_Column_ID)" - + " INNER JOIN AD_Table t ON (rt.AD_Table_ID=t.AD_Table_ID) " - + "WHERE rt.AD_Reference_ID=?"; - String displayColumnName = null; - PreparedStatement pstmt = null; - ResultSet rs = null; - try - { - pstmt = DB.prepareStatement(query, null); - pstmt.setInt(1, AD_Reference_ID); - rs = pstmt.executeQuery(); - if (rs.next()) - { - m_keyColumnName = rs.getString(1); - displayColumnName = rs.getString(2); - m_tableName = rs.getString(3); - } - } - catch (Exception e) - { - log.log(Level.SEVERE, query, e); - } - finally - { - DB.close(rs, pstmt); - rs = null; pstmt = null; - } - if (displayColumnName != null) - { - sql = new StringBuffer(); - sql.append("SELECT ").append(m_keyColumnName) - .append(" FROM ").append(m_tableName) - .append(" WHERE UPPER(").append(displayColumnName) - .append(") LIKE ").append(DB.TO_STRING(text)) - .append(" AND IsActive='Y'"); - String wc = getWhereClause(); - if (wc != null && wc.length() > 0) - sql.append(" AND ").append(wc); - // *** - if (log.isLoggable(Level.FINEST)) log.finest(m_columnName + " (Table) " + sql.toString()); - return MRole.getDefault().addAccessSQL(sql.toString(), - m_tableName, MRole.SQL_NOTQUALIFIED, MRole.SQL_RO); - } - } // Table Reference - } // MLookup - - /** Check Well Known Columns of Table - assumes TableDir **/ - String query = "SELECT t.TableName, c.ColumnName " - + "FROM AD_Column c " - + " INNER JOIN AD_Table t ON (c.AD_Table_ID=t.AD_Table_ID AND t.IsView='N') " - + "WHERE (c.ColumnName IN ('DocumentNo', 'Value', 'Name') OR c.IsIdentifier='Y')" - + " AND c.AD_Reference_ID IN (10,14)" - + " AND EXISTS (SELECT * FROM AD_Column cc WHERE cc.AD_Table_ID=t.AD_Table_ID" - + " AND cc.IsKey='Y' AND cc.ColumnName=?)"; - sql = new StringBuffer(); - PreparedStatement pstmt = null; - ResultSet rs = null; - try - { - pstmt = DB.prepareStatement(query, null); - pstmt.setString(1, m_keyColumnName); - rs = pstmt.executeQuery(); - while (rs.next()) - { - if (sql.length() != 0) - sql.append(" OR "); - m_tableName = rs.getString(1); - sql.append("UPPER(").append(rs.getString(2)).append(") LIKE ").append(DB.TO_STRING(text)); - } - } - catch (SQLException ex) - { - log.log(Level.SEVERE, query, ex); - } - finally - { - DB.close(rs, pstmt); - rs = null; pstmt = null; - } - // - if (sql.length() == 0) - { - log.log(Level.SEVERE, m_columnName + " (TableDir) - no standard/identifier columns"); - return ""; - } - // - StringBuffer retValue = new StringBuffer ("SELECT ") - .append(m_columnName).append(" FROM ").append(m_tableName) - .append(" WHERE (").append(sql).append(")") - .append(" AND IsActive='Y'"); - String wc = getWhereClause(); - if (wc != null && wc.length() > 0) - retValue.append(" AND ").append(wc); - // *** - if (log.isLoggable(Level.FINEST)) log.finest(m_columnName + " (TableDir) " + sql.toString()); - return MRole.getDefault().addAccessSQL(retValue.toString(), - m_tableName, MRole.SQL_NOTQUALIFIED, MRole.SQL_RO); - } // getDirectAccessSQL - - - /** - * Action - Special BPartner Screen - * @param newRecord true if new record should be created - */ - private void actionBPartner (boolean newRecord) - { - VBPartner vbp = new VBPartner (AEnv.getFrame(this), m_lookup.getWindowNo()); - int BPartner_ID = 0; - // if update, get current value - if (!newRecord) - { - if (m_value instanceof Integer) - BPartner_ID = ((Integer)m_value).intValue(); - else if (m_value != null) - BPartner_ID = Integer.parseInt(m_value.toString()); - } - - vbp.loadBPartner (BPartner_ID); - vbp.setVisible(true); - // get result - int result = vbp.getC_BPartner_ID(); - if (result == 0 // 0 = not saved - && result == BPartner_ID) // the same - return; - // Maybe new BPartner - put in cache - m_lookup.getDirect(Integer.valueOf(result), false, true); - - actionCombo (Integer.valueOf(result)); // data binding - } // actionBPartner - - private void actionLocation () - { - int BPLocation_ID = 0; - if (m_value instanceof Integer) - BPLocation_ID = ((Integer)m_value).intValue(); - else if (m_value != null) - BPLocation_ID = Integer.parseInt(m_value.toString()); - - if (BPLocation_ID>0) - { - MBPartnerLocation bpl = new MBPartnerLocation(Env.getCtx(), BPLocation_ID, null); - MLocation location= new MLocation(Env.getCtx(), bpl.getC_Location_ID(), null); - - VLocationDialog ld = new VLocationDialog(AEnv.getFrame(this), Msg.getMsg(Env.getCtx(), "Location"), location); - ld.setVisible(true); - } - } // actionBPartner - - /** - * Action - Zoom - * @param selectedItem item - */ - private void actionZoom (Object selectedItem) - { - if (m_lookup == null) - return; - // - MQuery zoomQuery = m_lookup.getZoomQuery(); - Object value = getValue(); - if (value == null) - value = selectedItem; - // still null means the field is empty or not selected item - if (value == null) - value = -1; - // If not already exist or exact value - if (zoomQuery == null || value != null) - { - zoomQuery = new MQuery(); // ColumnName might be changed in MTab.validateQuery - String keyTableName = null; - String keyColumnName = null; - // Check if it is a Table Reference - if (m_lookup != null && m_lookup instanceof MLookup) - { - int AD_Reference_ID = ((MLookup)m_lookup).getAD_Reference_Value_ID(); - if (DisplayType.List == m_lookup.getDisplayType()) { - keyColumnName = "AD_Ref_List_ID"; - keyTableName = "AD_Ref_List"; - value = DB.getSQLValue(null, "SELECT AD_Ref_List_ID FROM AD_Ref_List WHERE AD_Reference_ID=? AND Value=?", AD_Reference_ID, value); - } else { - if (AD_Reference_ID != 0) - { - String query = "SELECT kc.ColumnName, kt.TableName" - + " FROM AD_Ref_Table rt" - + " INNER JOIN AD_Column kc ON (rt.AD_Key=kc.AD_Column_ID)" - + " INNER JOIN AD_Table kt ON (rt.AD_Table_ID=kt.AD_Table_ID)" - + " WHERE rt.AD_Reference_ID=?"; - - PreparedStatement pstmt = null; - ResultSet rs = null; - try - { - pstmt = DB.prepareStatement(query, null); - pstmt.setInt(1, AD_Reference_ID); - rs = pstmt.executeQuery(); - if (rs.next()) - { - keyColumnName = rs.getString(1); - keyTableName = rs.getString(2); - } - } - catch (Exception e) - { - log.log(Level.SEVERE, query, e); - } - finally - { - DB.close(rs, pstmt); - rs = null; pstmt = null; - } - } // Table Reference - - } - } // MLookup - - if(keyColumnName != null && keyColumnName.length() !=0) - { - zoomQuery.addRestriction(keyColumnName, MQuery.EQUAL, value); - zoomQuery.setZoomColumnName(keyColumnName); - zoomQuery.setZoomTableName(keyTableName); - } - else - { - zoomQuery.addRestriction(m_columnName, MQuery.EQUAL, value); - if (m_columnName.indexOf(".") > 0) - { - zoomQuery.setZoomColumnName(m_columnName.substring(m_columnName.indexOf(".")+1)); - zoomQuery.setZoomTableName(m_columnName.substring(0, m_columnName.indexOf("."))); - } - else - { - zoomQuery.setZoomColumnName(m_columnName); - //remove _ID to get table name - zoomQuery.setZoomTableName(m_columnName.substring(0, m_columnName.length() - 3)); - } - } - zoomQuery.setZoomValue(value); - - zoomQuery.setRecordCount(1); // guess - } - - int AD_Window_ID = m_lookup.getZoom(zoomQuery); - - int zoomId = MZoomCondition.findZoomWindowByWindowId(AD_Window_ID, zoomQuery); - if (zoomId > 0) AD_Window_ID = zoomId; - - // - if (log.isLoggable(Level.INFO)) log.info(m_columnName + " - AD_Window_ID=" + AD_Window_ID - + " - Query=" + zoomQuery + " - Value=" + value); - // - setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); - // - AWindow frame = new AWindow(null); - if (!frame.initWindow(AD_Window_ID, zoomQuery)) - { - setCursor(Cursor.getDefaultCursor()); - ValueNamePair pp = CLogger.retrieveError(); - String msg = pp==null ? "AccessTableNoView" : pp.getValue(); - ADialog.error(m_lookup.getWindowNo(), this, msg, pp==null ? "" : pp.getName()); - } - else - { - AEnv.addToWindowManager(frame); - if (Ini.isPropertyBool(Ini.P_OPEN_WINDOW_MAXIMIZED)) - { - AEnv.showMaximized(frame); - } - else - { - AEnv.showCenterScreen(frame); - } - } - // async window - not able to get feedback - frame = null; - // - setCursor(Cursor.getDefaultCursor()); - } // actionZoom - - /** - * Action - Refresh - */ - private void actionRefresh() - { - if (m_lookup == null) - return; - // - setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); - // - Object obj = m_combo.getSelectedItem(); - if (log.isLoggable(Level.INFO)) log.info(m_columnName + " #" + m_lookup.getSize() + ", Selected=" + obj); - //no need to refresh readonly lookup, just remove direct cache - if (!isReadWrite()) - { - m_settingValue = true; // disable actions - m_lookup.removeAllElements(); - m_lastDisplay = m_lookup.getDisplay(m_value); - m_text.setText(m_lastDisplay); - m_text.setCaretPosition(0); - m_settingValue = false; - } - else - { - m_lookup.refresh(); - m_lookup.fillComboBox(isMandatory(), true, true, false, isComboShortList()); // IDEMPIERE 90 - m_combo.setSelectedItem(obj); - //m_combo.revalidate(); - } - // - setCursor(Cursor.getDefaultCursor()); - if (log.isLoggable(Level.INFO)) log.info(m_columnName + " #" + m_lookup.getSize() + ", Selected=" + m_combo.getSelectedItem()); - } // actionRefresh - - - /************************************************************************** - * Focus Listener for ComboBoxes with missing Validation or invalid entries - * - Requery listener for updated list - * @param e FocusEvent - */ - public void focusGained (FocusEvent e) - { - if (m_combo == null || m_combo.getEditor() == null) - return; - if ((e.getSource() != m_combo && e.getSource() != m_combo.getEditor().getEditorComponent()) - || e.isTemporary() || m_haveFocus || m_lookup == null) - return; - - //avoid repeated query - if (m_lookup.isValidated() && m_lookup.isLoaded()) - { - m_haveFocus = true; - return; - } - // - m_haveFocus = true; // prevents calling focus gained twice - m_settingFocus = true; // prevents actionPerformed - // - Object obj = m_lookup.getSelectedItem(); - if (log.isLoggable(Level.CONFIG)) log.config(m_columnName - + " - Start Count=" + m_combo.getItemCount() + ", Selected=" + obj); - // log.fine( "VLookupHash=" + this.hashCode()); - boolean popupVisible = m_combo.isPopupVisible(); - m_lookup.fillComboBox(isMandatory(), true, true, false, isComboShortList()); // only validated & active + IDEMPIERE 90 - if (popupVisible) - { - //refresh - m_combo.hidePopup(); - m_combo.showPopup(); - } - if (log.isLoggable(Level.CONFIG)) log.config(m_columnName - + " - Update Count=" + m_combo.getItemCount() + ", Selected=" + m_lookup.getSelectedItem()); - m_lookup.setSelectedItem(obj); - if (log.isLoggable(Level.CONFIG)) log.config(m_columnName - + " - Selected Count=" + m_combo.getItemCount() + ", Selected=" + m_lookup.getSelectedItem()); - // - m_settingFocus = false; - } // focusGained - - /** - * Reset Selection List - * @param e FocusEvent - */ - public void focusLost(FocusEvent e) - { - if (e.isTemporary() - || m_lookup == null - || !m_buttonSL.isEnabled() // IDEMPIERE 90 - || !m_button.isEnabled() ) // set by actionButton - return; - // Text Lost focus - if (e.getSource() == m_text) - { - String text = m_text.getText(); - if (log.isLoggable(Level.CONFIG)) log.config(m_columnName + " (Text) " + m_columnName + " = " + m_value + " - " + text); - m_haveFocus = false; - // Skip if empty - if ((m_value == null - && m_text.getText().length() == 0)) - return; - if (m_lastDisplay.equals(text)) - return; - // - actionText(); // re-display - return; - } - // Combo lost focus - if (e.getSource() != m_combo && e.getSource() != m_combo.getEditor().getEditorComponent()) - return; - if (m_lookup.isValidated() && !m_lookup.hasInactive()) - { - m_haveFocus = false; - return; - } - // - m_settingFocus = true; // prevents actionPerformed - // - if (log.isLoggable(Level.CONFIG)) log.config(m_columnName + " = " + m_combo.getSelectedItem()); - Object obj = m_combo.getSelectedItem(); - /* - // set original model - if (!m_lookup.isValidated()) - m_lookup.fillComboBox(true); // previous selection - */ - // Set value - if (obj != null) - { - m_combo.setSelectedItem(obj); - // original model may not have item - if (!m_combo.getSelectedItem().equals(obj)) - { - if (log.isLoggable(Level.FINE)) log.fine(m_columnName + " - added to combo - " + obj); - m_combo.addItem(obj); - m_combo.setSelectedItem(obj); - } - } - // actionCombo(getValue()); - m_settingFocus = false; - m_haveFocus = false; // can gain focus again - } // focusLost - - /** - * Set ToolTip - * @param text tool tip text - */ - public void setToolTipText(String text) - { - super.setToolTipText(text); - m_button.setToolTipText(text); - m_text.setToolTipText(text); - m_combo.setToolTipText(text); - } // setToolTipText - - /** - * Reset Env.TAB_INFO context variables - * @param columnName - */ - private void resetTabInfo() - { - if (this.m_lookup == null) - return; - String columnName = m_columnName; - // - // TODO : hardcoded - final String[] infoNames; - if ("M_Product_ID".equals(columnName)) - { - infoNames = new String[]{"M_Product_ID","M_AttributeSetInstance_ID","M_Locator_ID","M_Lookup_ID"}; - } - else - { - infoNames = new String[]{}; - } - for (String name : infoNames) - { - Env.setContext(Env.getCtx(), m_lookup.getWindowNo(), Env.TAB_INFO, name, null); - } - } - - /** - * Refresh Query - * @return count - */ - public int refresh() - { - if (m_lookup == null) - return -1; - - //no need to refresh readonly lookup, just remove direct cache - if (!isReadWrite()) { - m_lookup.removeAllElements(); - return 0; - } - - return m_lookup.refresh(); - } // refresh - - /** - * Use by vcelleditor to indicate editing is off and don't invoke databinding - * @param stopediting - */ - public void setStopEditing(boolean stopediting) { - m_stopediting = stopediting; - } - - // IDEMPIERE 90 - private void actionShortList () - { - if (onlyShortListItems) - { - onlyShortListItems = false; - m_lookup.setShortList(true); - refresh(); - m_lookup.fillComboBox(isMandatory(), true, true, false, isComboShortList()); - m_buttonSL.setIcon(Env.getImageIcon("LockX16.gif")); - m_buttonSL.setToolTipText(Msg.getMsg(Env.getCtx(), "ShortListOnlyShortListItems")); - }else{ - onlyShortListItems = true; - m_lookup.setShortList(false); - m_buttonSL.setIcon(Env.getImageIcon("Lock16.gif")); - m_buttonSL.setToolTipText(Msg.getMsg(Env.getCtx(), "ShortListAllItems")); - } - - actionRefresh(); - } // actionShortList - - public void setComboShortList (boolean shortList) - { - m_combo.setShortListSearch(shortList); - } // setComboShortList - - public boolean isComboShortList() - { - return m_combo.isShortListSearch(); - } // isComboShortList - // IDEMPIERE 90 - -} // VLookup \ No newline at end of file diff --git a/org.adempiere.ui.swing/src/org/compiere/grid/ed/VManagedEditor.java b/org.adempiere.ui.swing/src/org/compiere/grid/ed/VManagedEditor.java deleted file mode 100644 index 53b6308ca6..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/grid/ed/VManagedEditor.java +++ /dev/null @@ -1,37 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 2008 Low Heng Sin All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - *****************************************************************************/ -package org.compiere.grid.ed; - -/** - * Interface for editor with a commit and rollback lifecycle. - * @author Low Heng Sin - * - */ -public interface VManagedEditor { - /** - * Commit pending changes - */ - public void commitChanges(); - - /** - * Rollback pending changes - */ - public void rollbackChanges(); - - /** - * Are there any pending changes - * @return boolean - */ - public boolean isDirty(); -} diff --git a/org.adempiere.ui.swing/src/org/compiere/grid/ed/VMemo.java b/org.adempiere.ui.swing/src/org/compiere/grid/ed/VMemo.java deleted file mode 100644 index 4b62803468..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/grid/ed/VMemo.java +++ /dev/null @@ -1,336 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ -package org.compiere.grid.ed; - -import java.awt.Component; -import java.awt.Container; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.awt.event.FocusEvent; -import java.awt.event.FocusListener; -import java.awt.event.KeyEvent; -import java.awt.event.KeyListener; -import java.awt.event.MouseAdapter; -import java.awt.event.MouseEvent; -import java.beans.PropertyChangeEvent; -import java.beans.PropertyVetoException; -import java.util.logging.Level; - -import javax.swing.InputVerifier; -import javax.swing.JComponent; -import javax.swing.JPopupMenu; -import javax.swing.LookAndFeel; -import javax.swing.SwingUtilities; - -import org.adempiere.plaf.AdempierePLAF; -import org.compiere.apps.AEnv; -import org.compiere.apps.ScriptEditor; -import org.compiere.model.GridField; -import org.compiere.swing.CMenuItem; -import org.compiere.swing.CTextArea; -import org.compiere.util.CLogger; -import org.compiere.util.Env; -import org.compiere.util.Msg; - -/** - * Text Control (JTextArea embedded in JScrollPane) - * - * @author Jorg Janke - * @version $Id: VMemo.java,v 1.2 2006/07/30 00:51:27 jjanke Exp $ - */ -public class VMemo extends CTextArea - implements VEditor, KeyListener, FocusListener, ActionListener -{ - /** - * - */ - private static final long serialVersionUID = -1544247709358693141L; - - /** - * Mouse Listener - */ - final class VMemo_mouseAdapter extends MouseAdapter - { - /** - * Constructor - * @param adaptee - */ - VMemo_mouseAdapter(VMemo adaptee) - { - this.adaptee = adaptee; - } // VMemo_mouseAdapter - - private VMemo adaptee; - - /** - * Mouse Listener - * @param e - */ - public void mouseClicked(MouseEvent e) - { - // popup menu - if (SwingUtilities.isRightMouseButton(e)) - adaptee.popupMenu.show((Component)e.getSource(), e.getX(), e.getY()); - } // mouse Clicked - - - - } // VMemo_mouseAdapter - - - /** - * IDE Baan Constructor - */ - public VMemo() - { - this("", false, false, true, 60, 4000); - } // VMemo - - /** - * Standard Constructor - * @param columnName - * @param mandatory - * @param isReadOnly - * @param isUpdateable - * @param displayLength - * @param fieldLength - */ - public VMemo (String columnName, boolean mandatory, boolean isReadOnly, boolean isUpdateable, - int displayLength, int fieldLength) - { - super (fieldLength/80, 50); - super.setName(columnName); - LookAndFeel.installBorder(this, "TextField.border"); - this.addFocusListener(this); // to activate editor - - // Create Editor - setColumns(displayLength>VString.MAXDISPLAY_LENGTH ? VString.MAXDISPLAY_LENGTH : displayLength); // 46 - setForeground(AdempierePLAF.getTextColor_Normal()); - setBackground(AdempierePLAF.getFieldBackground_Normal()); - - setLineWrap(true); - setWrapStyleWord(true); - addFocusListener(this); - setInputVerifier(new CInputVerifier()); //Must be set AFTER addFocusListener in order to work - setMandatory(mandatory); - m_columnName = columnName; - m_fieldLength = fieldLength; - - if (isReadOnly || !isUpdateable) - setReadWrite(false); - addKeyListener(this); - - // Popup - addMouseListener(new VMemo_mouseAdapter(this)); - if (columnName.equals("Script")) - menuEditor = new CMenuItem(Msg.getMsg(Env.getCtx(), "Script"), Env.getImageIcon("Script16.gif")); - else - menuEditor = new CMenuItem(Msg.getMsg(Env.getCtx(), "Editor"), Env.getImageIcon("Editor16.gif")); - menuEditor.addActionListener(this); - popupMenu.add(menuEditor); - } // VMemo - - /** - * Dispose - */ - public void dispose() - { - } // dispose - - JPopupMenu popupMenu = new JPopupMenu(); - private CMenuItem menuEditor; - private int m_fieldLength; - - private String m_columnName; - private String m_oldText = ""; - private volatile boolean m_setting = false; - /** Logger */ - private static CLogger log = CLogger.getCLogger(VMemo.class); - - /** - * Set Editor to value - * @param value - */ - public void setValue(Object value) - { - super.setValue(value); - if (m_setting) - return; - // Always position Top - setCaretPosition(0); - } // setValue - - /** - * Property Change Listener - * @param evt - */ - public void propertyChange (PropertyChangeEvent evt) - { - if (evt.getPropertyName().equals(org.compiere.model.GridField.PROPERTY)) - setValue(evt.getNewValue()); - } // propertyChange - - /** - * ActionListener - * @param e - */ - public void actionPerformed(ActionEvent e) - { - if (e.getSource() == menuEditor) - { - menuEditor.setEnabled(false); - String s = null; - if (m_columnName.equals("Script") || m_columnName.endsWith("_Script")) - s = ScriptEditor.start ( - AEnv.getFrame(this.getParent()), - Msg.translate(Env.getCtx(), m_columnName), getText(), isEditable(), - findWindowNo()); - else - s = Editor.startEditor (this, Msg.translate(Env.getCtx(), m_columnName), - getText(), isEditable(), m_fieldLength); - menuEditor.setEnabled(true); - setValue(s); - try - { - fireVetoableChange(m_columnName, null, getText()); - m_oldText = getText(); - } - catch (PropertyVetoException pve) {} - } - } // actionPerformed - - private int findWindowNo() { - Container c = this.getParent(); - return c != null ? AEnv.getWindowNo(c) : 0; - } - - /** - * Action Listener Interface - NOP - * @param listener - */ - public void addActionListener(ActionListener listener) - { - } // addActionListener - - /************************************************************************** - * Key Listener Interface - * @param e - */ - public void keyTyped(KeyEvent e) {} - public void keyPressed(KeyEvent e) {} - - /** - * Escape - Restore old Text. - * Indicate Change - * @param e - */ - public void keyReleased(KeyEvent e) - { - // ESC - if (e.getKeyCode() == KeyEvent.VK_ESCAPE && !getText().equals(m_oldText)) - { - log.fine( "VMemo.keyReleased - ESC"); - setText(m_oldText); - return; - } - } // keyReleased - - /** - * Focus Gained - Save for Escape - * @param e - */ - public void focusGained (FocusEvent e) - { - if (log.isLoggable(Level.CONFIG)) log.config(e.paramString()); - if (e.getSource() instanceof VMemo) - requestFocus(); - else - m_oldText = getText(); - } // focusGained - - /** - * Data Binding to MTable (via GridController) - * @param e - */ - public void focusLost (FocusEvent e) - { - m_setting = true; - try - { - fireVetoableChange(m_columnName, m_oldText, getText()); - } - catch (PropertyVetoException pve) {} - m_setting = false; - } // focusLost - - /*************************************************************************/ - - // Field for Value Preference - private GridField m_mField = null; - /** - * Set Field/WindowNo for ValuePreference (NOP) - * @param mField - */ - public void setField (org.compiere.model.GridField mField) - { - m_mField = mField; - } // setField - - @Override - public GridField getField() { - return m_mField; - } - - /** - * Get Focus Component - * @return component - */ - public Component getFocusableComponent() - { - return this; - } // getFocusableComponent - - -private class CInputVerifier extends InputVerifier { - - public boolean verify(JComponent input) { - - - //NOTE: We return true no matter what since the InputVerifier is only introduced to fireVetoableChange in due time - if (getText() == null && m_oldText == null) - return true; - else if (getText().equals(m_oldText)) - return true; - // - try - { - String text = getText(); - fireVetoableChange(m_columnName, null, text); - m_oldText = text; - return true; - } - catch (PropertyVetoException pve) {} - return true; - - } // verify - - } // CInputVerifier - - - - -} // VMemo diff --git a/org.adempiere.ui.swing/src/org/compiere/grid/ed/VNumber.java b/org.adempiere.ui.swing/src/org/compiere/grid/ed/VNumber.java deleted file mode 100644 index 713871d31d..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/grid/ed/VNumber.java +++ /dev/null @@ -1,857 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ -package org.compiere.grid.ed; - -import java.awt.AWTEvent; -import java.awt.BorderLayout; -import java.awt.Color; -import java.awt.Component; -import java.awt.Container; -import java.awt.Dimension; -import java.awt.EventQueue; -import java.awt.Frame; -import java.awt.Insets; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.awt.event.FocusEvent; -import java.awt.event.FocusListener; -import java.awt.event.InputEvent; -import java.awt.event.KeyEvent; -import java.awt.event.KeyListener; -import java.awt.event.MouseAdapter; -import java.awt.event.MouseEvent; -import java.beans.PropertyChangeEvent; -import java.beans.PropertyVetoException; -import java.math.BigDecimal; -import java.math.RoundingMode; -import java.text.DecimalFormat; -import java.text.ParseException; -import java.util.logging.Level; - -import javax.swing.JComponent; -import javax.swing.JPopupMenu; -import javax.swing.JTextField; -import javax.swing.LookAndFeel; -import javax.swing.SwingUtilities; -import javax.swing.text.Document; - -import org.compiere.apps.AEnv; -import org.compiere.apps.FieldRecordInfo; -import org.compiere.model.GridField; -import org.compiere.model.MRole; -import org.compiere.swing.CButton; -import org.compiere.swing.CComboBox; -import org.compiere.swing.CTextField; -import org.compiere.util.CLogger; -import org.compiere.util.DisplayType; -import org.compiere.util.Env; - -/** - * Number Control - * - * @author Jorg Janke - * @version $Id: VNumber.java,v 1.2 2006/07/30 00:51:27 jjanke Exp $ - * - * @author Teo Sarca, SC ARHIPAC SERVICE SRL - *
  • BF [ 1739516 ] Warning on numeric field with range set - *
  • BF [ 1834393 ] VNumber.setFocusable not working - */ -public final class VNumber extends JComponent - implements VEditor, ActionListener, KeyListener, FocusListener, VManagedEditor -{ - /** - * - */ - private static final long serialVersionUID = -1826388236069159130L; - - /** Number of Columns (12) */ - public final static int SIZE = 12; - /** Automatically pop up calculator */ - public final static boolean AUTO_POPUP = false; - - JPopupMenu popupMenu = new JPopupMenu(); - - /****************************************************************************** - * Mouse Listener - */ - final class VNumber_mouseAdapter extends MouseAdapter - { - /** - * Constructor - * @param adaptee adaptee - */ - VNumber_mouseAdapter(VNumber adaptee) - { - m_adaptee = adaptee; - } // VNumber_mouseAdapter - - private VNumber m_adaptee; - - /** - * Mouse Listener - * @param e event - */ - public void mouseClicked(MouseEvent e) - { - // popup menu - if (SwingUtilities.isRightMouseButton(e)) - m_adaptee.popupMenu.show((Component)e.getSource(), e.getX(), e.getY()); - } // mouseClicked - - } - - /** - * IDE Bean Constructor - */ - public VNumber() - { - this("Number", false, false, true, DisplayType.Number, "Number"); - } // VNumber - - /** - * Create right aligned Number field. - * no popup, if WindowNo == 0 (for IDs) - * @param columnName column name - * @param mandatory mandatory - * @param isReadOnly read only - * @param isUpdateable updateable - * @param displayType display type - * @param title title - */ - public VNumber(String columnName, boolean mandatory, boolean isReadOnly, boolean isUpdateable, - int displayType, String title) - { - super(); - super.setName(columnName); - m_columnName = columnName; - m_title = title; - setDisplayType(displayType); - // - LookAndFeel.installBorder(this, "TextField.border"); - this.setLayout(new BorderLayout()); - - // *** Text *** - m_text.setBorder(null); - m_text.setHorizontalAlignment(JTextField.TRAILING); - m_text.addKeyListener(this); - m_text.addFocusListener(this); - // Background - setMandatory(mandatory); - this.add(m_text, BorderLayout.CENTER); - - // *** Button *** - m_button.setIcon(Env.getImageIcon("Calculator10.gif")); - m_button.setMargin(new Insets(0, 0, 0, 0)); - m_button.setFocusable(false); - m_button.addActionListener(this); - this.add (m_button, BorderLayout.EAST); - - // Size - setColumns(SIZE, 0); - // ReadWrite - if (isReadOnly || !isUpdateable) - setReadWrite(false); - else - setReadWrite(true); - - m_text.addMouseListener(new VNumber_mouseAdapter(this)); - } // VNumber - - /** - * Dispose - */ - public void dispose() - { - m_text = null; - m_button = null; - m_mField = null; - } // dispose - - /** - * Set Document - * @param doc document - */ - protected void setDocument(Document doc) - { - m_text.setDocument(doc); - } // getDocument - - private String m_columnName; - protected int m_displayType; // Currency / UoM via Context - private DecimalFormat m_format; - private String m_title; - private boolean m_setting; - private String m_oldText; - private String m_initialText; - - private boolean m_rangeSet = false; - private Double m_minValue; - private Double m_maxValue; - private boolean m_modified = false; - - /** The Field */ - private CTextField m_text = new CTextField(SIZE); // Standard - /** The Button */ - private CButton m_button = new CButton(); - - private GridField m_mField = null; - /** Logger */ - private static CLogger log = CLogger.getCLogger(VNumber.class); - - /** - * Select all the number text. - */ - public void selectAll() - { - m_text.selectAll(); - } - - /** - * Set no of Columns - * @param columns columns - * @param height 0 to use default - */ - public void setColumns (int columns, int height) - { - m_text.setPreferredSize(null); - m_text.setMinimumSize(null); - m_text.setColumns(columns); - if (height > 0) { - Dimension size = m_text.getPreferredSize(); - if (height > size.height) // default 16 - size.height = height; - if (CComboBox.FIELD_HIGHT-4 > size.height) - size.height = VLookup.FIELD_HIGHT-4; - m_text.setPreferredSize(size); - m_text.setMinimumSize(size); - } else { - StringBuilder s = new StringBuilder(); - for(int i = 0; i < SIZE; i++) { - s.append("0"); - } - CTextField f = new CTextField(s.toString()); - m_text.setPreferredSize(f.getPreferredSize()); - m_text.setMinimumSize(f.getMinimumSize()); - } - this.setPreferredSize(m_text.getPreferredSize()); // causes r/o to be the same length - this.setMinimumSize(m_text.getMinimumSize()); - int h = m_text.getPreferredSize().height; - m_button.setPreferredSize(new Dimension(h, h)); - } // setColumns - - /** - * Set Range with min & max - * @param minValue min value - * @param maxValue max value - * @return true, if accepted - */ - public boolean setRange(Double minValue, Double maxValue) - { - m_rangeSet = true; - m_minValue = minValue; - m_maxValue = maxValue; - return m_rangeSet; - } // setRange - - /** - * Set Range with min & max = parse US style number w/o Gouping - * @param minValue min value - * @param maxValue max value - * @return true if accepted - */ - public boolean setRange(String minValue, String maxValue) - { - if (minValue == null || maxValue == null) - return false; - try - { - m_minValue = Double.valueOf(minValue); - m_maxValue = Double.valueOf(maxValue); - } - catch (NumberFormatException nfe) - { - return false; - } - m_rangeSet = true; - return m_rangeSet; - } // setRange - - /** - * Set and check DisplayType - * @param displayType display type - */ - public void setDisplayType (int displayType) - { - m_displayType = displayType; - if (!DisplayType.isNumeric(displayType)) - m_displayType = DisplayType.Number; - m_format = DisplayType.getNumberFormat(displayType); - m_text.setDocument (new MDocNumber(displayType, m_format, m_text, m_title)); - } // setDisplayType - - /** - * Set ReadWrite - * @param value value - */ - public void setReadWrite (boolean value) - { - if (m_text.isReadWrite() != value) - m_text.setReadWrite(value); - if (m_button.isReadWrite() != value) - m_button.setReadWrite(value); - // Don't show button if not ReadWrite - if (m_button.isVisible() != value) - m_button.setVisible(value); - setFocusable(value == true); - } // setReadWrite - - /** - * IsReadWrite - * @return true if rw - */ - public boolean isReadWrite() - { - return m_text.isReadWrite(); - } // isReadWrite - - /** - * Set Mandatory (and back bolor) - * @param mandatory mandatory - */ - public void setMandatory (boolean mandatory) - { - m_text.setMandatory(mandatory); - } // setMandatory - - /** - * Is it mandatory - * @return true if mandatory - */ - public boolean isMandatory() - { - return m_text.isMandatory(); - } // isMandatory - - /** - * Set Background - * @param color color - */ - public void setBackground(Color color) - { - m_text.setBackground(color); - } // setBackground - - /** - * Set Background - * @param error error - */ - public void setBackground (boolean error) - { - m_text.setBackground(error); - } // setBackground - - /** - * Set Foreground - * @param fg foreground - */ - public void setForeground(Color fg) - { - m_text.setForeground(fg); - } // setForeground - - /** - * Set Editor to value - * @param value value - */ - public void setValue(Object value) - { - if (log.isLoggable(Level.FINEST)) log.finest("Value=" + value); - if (value == null) - m_oldText = ""; - else - m_oldText = m_format.format(value); - // only set when not updated here - if (m_setting) - return; - m_text.setText (m_oldText); - m_initialText = m_oldText; - m_modified = false; - } // setValue - - /** - * Request Focus - */ - public void requestFocus () - { - m_text.requestFocus (); - } // requestFocus - - /** - * Request Focus In Window - * @return focus request - */ - @Override - public boolean requestFocusInWindow() - { - return m_text.requestFocusInWindow(); - } // requestFocusInWindow - - /** - * Get Focus Component - * @return component - */ - public Component getFocusableComponent() - { - return m_text; - } // getFocusComponent - - /** - * Property Change Listener - * @param evt event - */ - public void propertyChange (PropertyChangeEvent evt) - { - if (evt.getPropertyName().equals(org.compiere.model.GridField.PROPERTY)) - setValue(evt.getNewValue()); - } // propertyChange - - /** - * Return Editor value - * @return value value (big decimal or integer) - */ - public Object getValue() - { - if (m_text == null || m_text.getText() == null || m_text.getText().length() == 0) - return null; - String value = m_text.getText(); - // return 0 if text deleted - if (value == null || value.length() == 0) - { - if (!m_modified) - return null; - if (m_displayType == DisplayType.Integer) - return Integer.valueOf(0); - return Env.ZERO; - } - if (value.equals(".") || value.equals(",") || value.equals("-")) - value = "0"; - // arboleda - solve bug [ 1759771 ] Parse exception when you enter ".." in a numeric field - if (value.equals("..")) { - value = "0"; - m_text.setText("."); - } - try - { - Number number = m_format.parse(value); - value = number.toString(); // converts it to US w/o thousands - BigDecimal bd = new BigDecimal(value); - if (m_displayType == DisplayType.Integer) - return Integer.valueOf(bd.intValue()); - if (bd.signum() == 0) - return bd; - return bd.setScale(m_format.getMaximumFractionDigits(), RoundingMode.HALF_UP); - } - catch (Exception e) - { - log.log(Level.SEVERE, "Value=" + value, e); - } - m_text.setText(m_format.format(0)); - if (m_displayType == DisplayType.Integer) - return Integer.valueOf(0); - return Env.ZERO; - } // getValue - - /** - * Return Display Value - * @return value - */ - public String getDisplay() - { - return m_text.getText(); - } // getDisplay - - /** - * Get Title - * @return title - */ - public String getTitle() - { - return m_title; - } // getTitle - - /** - * Plus - add one. - * Also sets Value - * @return new value - */ - public Object plus() - { - Object value = getValue(); - if (value == null) - { - if (m_displayType == DisplayType.Integer) - value = Integer.valueOf(0); - else - value = Env.ZERO; - } - // Add - if (value instanceof BigDecimal) - value = ((BigDecimal)value).add(Env.ONE); - else - value = Integer.valueOf(((Integer)value).intValue() + 1); - // - setValue(value); - return value; - } // plus - - /** - * Minus - subtract one, but not below minimum. - * Also sets Value - * @param minimum minimum - * @return new value - */ - public Object minus (int minimum) - { - Object value = getValue(); - if (value == null) - { - if (m_displayType == DisplayType.Integer) - value = Integer.valueOf(minimum); - else - value = new BigDecimal(minimum); - setValue(value); - return value; - } - - // Subtract - if (value instanceof BigDecimal) - { - BigDecimal bd = ((BigDecimal)value).subtract(Env.ONE); - BigDecimal min = new BigDecimal(minimum); - if (bd.compareTo(min) < 0) - value = min; - else - value = bd; - } - else - { - int i = ((Integer)value).intValue(); - i--; - if (i < minimum) - i = minimum; - value = Integer.valueOf(i); - } - // - setValue(value); - return value; - } // minus - - /************************************************************************** - * Action Listener - * @param e event - */ - public void actionPerformed (ActionEvent e) - { - if (log.isLoggable(Level.CONFIG)) log.config(e.getActionCommand()); - if (ValuePreference.NAME.equals(e.getActionCommand())) - { - if (MRole.getDefault().isShowPreference() && !m_mField.isEncrypted() && !m_mField.isEncryptedColumn()) - ValuePreference.start (m_mField, getValue()); - return; - } - else if (e.getActionCommand().equals(FieldRecordInfo.CHANGE_LOG_COMMAND)) - { - FieldRecordInfo.start(m_mField); - return; - } - - if (e.getSource() == m_button ) - { - m_button.setEnabled(false); - String str = startCalculator(this, m_text.getText(), m_format, m_displayType, m_title, ' '); - m_text.setText(str); - m_button.setEnabled(true); - try - { - fireVetoableChange (m_columnName, m_oldText, getValue()); - } - catch (PropertyVetoException pve) {} - m_text.requestFocus(); - } - } // actionPerformed - - /************************************************************************** - * Key Listener Interface - * @param e event - */ - public void keyTyped(KeyEvent e) {} - public void keyPressed(KeyEvent e) {} - - /** - * Key Listener. - * - Escape - Restore old Text - * - firstChange - signal change - * @param e event - */ - public void keyReleased(KeyEvent e) - { - if (log.isLoggable(Level.FINEST)) log.finest("Key=" + e.getKeyCode() + " - " + e.getKeyChar() - + " -> " + m_text.getText()); - - // ESC - if (e.getKeyCode() == KeyEvent.VK_ESCAPE) - m_text.setText(m_initialText); - - m_modified = true; - m_setting = true; - try - { - if (e.getKeyCode() == KeyEvent.VK_ENTER) // 10 - { - fireVetoableChange (m_columnName, m_oldText, getValue()); - fireActionPerformed(); - } - // else - // { - // indicate change - // fireVetoableChange (m_columnName, m_oldText, null); - // } - } - catch (PropertyVetoException pve) {} - m_setting = false; - } // keyReleased - - /** - * Focus Gained - * @param e event - */ - public void focusGained (FocusEvent e) - { - if (m_text != null) - m_text.selectAll(); - } // focusGained - - /** - * Data Binding to MTable (via GridController.vetoableChange). - * @param e event - */ - public void focusLost (FocusEvent e) - { - // APanel - Escape - // hengsin: bug [ 1890205 ] - /* - if (e.getOppositeComponent() instanceof AGlassPane) - { - m_text.setText(m_initialText); - return; - }*/ - commitChanges(); - } // focusLost - - public void commitChanges() { - Object oo = getValue(); - if (m_rangeSet) - { - String error = null; - if (oo instanceof Integer) - { - Integer ii = (Integer)oo; - if (ii < m_minValue) - { - error = oo + " < " + m_minValue; - oo = Integer.valueOf(m_minValue.intValue()); - } - else if (ii > m_maxValue) - { - error = oo + " > " + m_maxValue; - oo = Integer.valueOf(m_maxValue.intValue()); - } - } - else if (oo instanceof BigDecimal) - { - BigDecimal bd = (BigDecimal)oo; - if (bd.doubleValue() < m_minValue) - { - error = oo + " < " + m_minValue; - oo = BigDecimal.valueOf(m_minValue); - } - else if (bd.doubleValue() > m_maxValue) - { - error = oo + " > " + m_maxValue; - oo = BigDecimal.valueOf(m_maxValue); - } - } - if (error != null) - log.warning(error); - } - try - { - fireVetoableChange (m_columnName, m_initialText, oo); - fireActionPerformed(); - } - catch (PropertyVetoException pve) - {} - } - - /** - * Invalid Entry - Start Calculator - * @param jc parent - * @param value value - * @param format format - * @param displayType display type - * @param title title - * @return value - * @deprecated Use {@link #startCalculator(Container,String,DecimalFormat,int,String,char)} instead - */ - public static String startCalculator(Container jc, String value, - DecimalFormat format, int displayType, String title) - { - return startCalculator(jc, value, format, displayType, title, ' '); - } // startCalculator - - /** - * Invalid Entry - Start Calculator - * @param jc parent - * @param value value - * @param format format - * @param displayType display type - * @param title title - * @param operator optional math operator +-/* - * @return value - */ - public static String startCalculator(Container jc, String value, - DecimalFormat format, int displayType, String title, char operator) - { - if (log.isLoggable(Level.CONFIG)) log.config("Value=" + value); - BigDecimal startValue = Env.ZERO; - try - { - if (value != null && value.length() > 0) - { - Number number = format.parse(value); - startValue = new BigDecimal (number.toString()); - } - } - catch (ParseException pe) - { - if (log.isLoggable(Level.INFO)) log.info("InvalidEntry - " + pe.getMessage()); - } - - // Find frame - Frame frame = AEnv.getFrame(jc); - // Actual Call - Calculator calc = new Calculator(frame, title, - displayType, format, startValue); - if ( "*+-/%".indexOf(operator) > -1 ) - calc.handleInput(operator); - AEnv.showCenterWindow(frame, calc); - BigDecimal result = calc.getNumber(); - if (log.isLoggable(Level.CONFIG)) log.config( "Result=" + result); - // - calc = null; - if (result != null) - return format.format(result); - else - return value; // original value - } // startCalculator - - /** - * Set Field/WindowNo for ValuePreference - * @param mField field - */ - public void setField (GridField mField) - { - m_mField = mField; - - if (m_mField != null - && MRole.getDefault().isShowPreference() - && !mField.isEncrypted() && !mField.isEncryptedColumn()) - ValuePreference.addMenu (this, popupMenu); - - if (m_mField != null) - FieldRecordInfo.addMenu(this, popupMenu); - } // setField - - @Override - public GridField getField() { - return m_mField; - } - /* - * BF [ 1834393 ] VNumber.setFocusable not working - */ - @Override - public void setFocusable(boolean value) { - m_text.setFocusable(value); - } - - - /************************************************************************** - * Remove Action Listner - * @param l Action Listener - */ - public void removeActionListener(ActionListener l) - { - listenerList.remove(ActionListener.class, l); - } // removeActionListener - - /** - * Add Action Listner - * @param l Action Listener - */ - public void addActionListener(ActionListener l) - { - listenerList.add(ActionListener.class, l); - } // addActionListener - - /** - * Fire Action Event to listeners - */ - protected void fireActionPerformed() - { - int modifiers = 0; - AWTEvent currentEvent = EventQueue.getCurrentEvent(); - if (currentEvent instanceof InputEvent) - modifiers = ((InputEvent)currentEvent).getModifiersEx(); - else if (currentEvent instanceof ActionEvent) - modifiers = ((ActionEvent)currentEvent).getModifiers(); - ActionEvent ae = new ActionEvent (this, ActionEvent.ACTION_PERFORMED, - "VNumber", EventQueue.getMostRecentEventTime(), modifiers); - - // Guaranteed to return a non-null array - Object[] listeners = listenerList.getListenerList(); - // Process the listeners last to first, notifying those that are interested in this event - for (int i = listeners.length-2; i>=0; i-=2) - { - if (listeners[i]==ActionListener.class) - { - ((ActionListener)listeners[i+1]).actionPerformed(ae); - } - } - } // fireActionPerformed - /**/ - - public boolean isDirty() { - return m_modified; - } - - public void rollbackChanges() { - m_text.setText (m_oldText); - m_initialText = m_oldText; - m_modified = false; - } - -} // VNumber diff --git a/org.adempiere.ui.swing/src/org/compiere/grid/ed/VOvrCaret.java b/org.adempiere.ui.swing/src/org/compiere/grid/ed/VOvrCaret.java deleted file mode 100644 index d243603617..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/grid/ed/VOvrCaret.java +++ /dev/null @@ -1,111 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ -package org.compiere.grid.ed; - -import java.awt.Color; -import java.awt.Graphics; -import java.awt.Rectangle; - -import javax.swing.plaf.TextUI; -import javax.swing.text.BadLocationException; -import javax.swing.text.DefaultCaret; -import javax.swing.text.Position; - -/** - * Overwrite Caret - * - * @author Jorg Janke - * @version $Id: VOvrCaret.java,v 1.2 2006/07/30 00:51:28 jjanke Exp $ - */ -public class VOvrCaret extends DefaultCaret -{ - /** - * - */ - private static final long serialVersionUID = 1513269384035685427L; - - /** - * Constructor - */ - public VOvrCaret() - { - super(); - } // VOvrCaret - - /** - * Renders the caret as a top and button bracket. - * - * @param g the graphics context - * @see #damage - */ - public void paint(Graphics g) - { - Position.Bias dotBias = Position.Bias.Forward; - - // - if (isVisible()) - { - try - { - TextUI mapper = getComponent().getUI(); - Rectangle r = mapper.modelToView(getComponent(), getDot(), dotBias); - Rectangle e = mapper.modelToView(getComponent(), getDot()+1, dotBias); - // g.setColor(getComponent().getCaretColor()); - g.setColor(Color.blue); - // - int cWidth = e.x-r.x; - int cHeight = 4; - int cThick = 2; - // - g.fillRect(r.x-1, r.y, cWidth, cThick); // top - g.fillRect(r.x-1, r.y, cThick, cHeight); // | - g.fillRect(r.x-1+cWidth, r.y, cThick, cHeight); // | - // - int yStart = r.y+r.height; - g.fillRect(r.x-1, yStart-cThick, cWidth, cThick); // button - g.fillRect(r.x-1, yStart-cHeight, cThick, cHeight); // | - g.fillRect(r.x-1+cWidth, yStart-cHeight, cThick, cHeight); // | - } - catch (BadLocationException e) - { - // can't render - // System.err.println("Can't render cursor"); - } - } // isVisible - } // paint - - /** - * Damages the area surrounding the caret to cause - * it to be repainted in a new location. - * This method should update the caret bounds (x, y, width, and height). - * - * @param r the current location of the caret - * @see #paint - */ - protected synchronized void damage(Rectangle r) - { - if (r != null) - { - x = r.x - 4; // start 4 pixles before (one required) - y = r.y; - width = 18; // sufficent for standard font (18-4=14) - height = r.height; - repaint(); - } - } // damage - -} // VOvrCaret diff --git a/org.adempiere.ui.swing/src/org/compiere/grid/ed/VPAttribute.java b/org.adempiere.ui.swing/src/org/compiere/grid/ed/VPAttribute.java deleted file mode 100644 index 60bd77cb7c..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/grid/ed/VPAttribute.java +++ /dev/null @@ -1,524 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ -package org.compiere.grid.ed; - -import java.awt.BorderLayout; -import java.awt.Color; -import java.awt.Component; -import java.awt.Dimension; -import java.awt.Insets; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.awt.event.MouseAdapter; -import java.awt.event.MouseEvent; -import java.beans.PropertyChangeEvent; -import java.beans.PropertyVetoException; -import java.util.logging.Level; - -import javax.swing.JComponent; -import javax.swing.JPopupMenu; -import javax.swing.JTextField; -import javax.swing.LookAndFeel; -import javax.swing.SwingUtilities; - -import org.adempiere.plaf.AdempierePLAF; -import org.compiere.apps.AEnv; -import org.compiere.apps.FieldRecordInfo; -import org.compiere.model.GridField; -import org.compiere.model.GridTab; -import org.compiere.model.MAttributeSet; -import org.compiere.model.MPAttributeLookup; -import org.compiere.model.MProduct; -import static org.compiere.model.SystemIDs.*; -import org.compiere.swing.CButton; -import org.compiere.swing.CMenuItem; -import org.compiere.util.CLogger; -import org.compiere.util.Env; -import org.compiere.util.Msg; - -/** - * Product Attribute Set Instance Editor - * - * @author Jorg Janke - * @version $Id: VPAttribute.java,v 1.2 2006/07/30 00:51:27 jjanke Exp $ - * - * @author Teo Sarca, SC ARHIPAC SERVICE SRL - *
  • BF [ 1895041 ] NPE when move product with attribute set - *
  • BF [ 1770177 ] Inventory Move Locator Error - integrated MGrigioni bug fix - *
  • BF [ 2011222 ] ASI Dialog is reseting locator - */ -public class VPAttribute extends JComponent - implements VEditor, ActionListener -{ - /** - * - */ - private static final long serialVersionUID = 3632142379826093036L; - - /** - * Mouse Listener - */ - final class VPAttribute_mouseAdapter extends MouseAdapter - { - /** - * Constructor - * @param adaptee adaptee - */ - VPAttribute_mouseAdapter(VPAttribute adaptee) - { - m_adaptee = adaptee; - } // VPAttribute_mouseAdapter - - private VPAttribute m_adaptee; - - /** - * Mouse Listener - * @param e event - */ - public void mouseClicked(MouseEvent e) - { - // Double Click - if (e.getClickCount() > 1) - m_adaptee.actionPerformed(new ActionEvent(e.getSource(), e.getID(), "Mouse")); - // popup menu - if (SwingUtilities.isRightMouseButton(e)) - m_adaptee.popupMenu.show((Component)e.getSource(), e.getX(), e.getY()); - } // mouse Clicked - - } // VPAttribute_mouseAdapter - - /** - * IDE Constructor - */ - public VPAttribute() - { - this (null, false, false, true, 0, null); - } // VAssigment - - /** - * Create Product Attribute Set Instance Editor. - * @param mandatory mandatory - * @param isReadOnly read only - * @param isUpdateable updateable - * @param WindowNo WindowNo - * @param lookup Model Product Attribute - */ - public VPAttribute (boolean mandatory, boolean isReadOnly, boolean isUpdateable, - int WindowNo, MPAttributeLookup lookup) - { - this(null, mandatory, isReadOnly, isUpdateable, WindowNo, lookup); - } - - /** - * Create Product Attribute Set Instance Editor. - * @param gridTab - * @param mandatory mandatory - * @param isReadOnly read only - * @param isUpdateable updateable - * @param WindowNo WindowNo - * @param lookup Model Product Attribute - */ - public VPAttribute (GridTab gridTab, boolean mandatory, boolean isReadOnly, boolean isUpdateable, - int WindowNo, MPAttributeLookup lookup) - { - super.setName("M_AttributeSetInstance_ID"); - m_GridTab = gridTab; // added for processCallout - m_WindowNo = WindowNo; - m_mPAttribute = lookup; - m_C_BPartner_ID = Env.getContextAsInt(Env.getCtx(), WindowNo, "C_BPartner_ID"); - LookAndFeel.installBorder(this, "TextField.border"); - this.setLayout(new BorderLayout()); - // Size - this.setPreferredSize(m_text.getPreferredSize()); - int height = m_text.getPreferredSize().height; - - // *** Text *** - m_text.setEditable(false); - m_text.setFocusable(false); - m_text.setBorder(null); - m_text.setHorizontalAlignment(JTextField.LEADING); - // Background - setMandatory(mandatory); - this.add(m_text, BorderLayout.CENTER); - - // *** Button *** - m_button.setIcon(Env.getImageIcon("PAttribute10.gif")); - m_button.setMargin(new Insets(0, 0, 0, 0)); - m_button.setPreferredSize(new Dimension(height, height)); - m_button.addActionListener(this); - m_button.setFocusable(true); - this.add(m_button, BorderLayout.EAST); - - // Prefereed Size - this.setPreferredSize(this.getPreferredSize()); // causes r/o to be the same length - // ReadWrite - if (isReadOnly || !isUpdateable) - setReadWrite(false); - else - setReadWrite(true); - - // Popup - m_text.addMouseListener(new VPAttribute_mouseAdapter(this)); - menuEditor = new CMenuItem(Msg.getMsg(Env.getCtx(), "PAttribute"), Env.getImageIcon("Zoom16.gif")); - menuEditor.addActionListener(this); - popupMenu.add(menuEditor); - } // VPAttribute - - /** Data Value */ - private Object m_value = new Object(); - /** The Attribute Instance */ - private MPAttributeLookup m_mPAttribute; - - /** The Text Field */ - private JTextField m_text = new JTextField (VLookup.DISPLAY_LENGTH); - /** The Button */ - private CButton m_button = new CButton(); - - JPopupMenu popupMenu = new JPopupMenu(); - private CMenuItem menuEditor; - - private boolean m_readWrite; - private boolean m_mandatory; - private int m_WindowNo; - private int m_C_BPartner_ID; - /** The Grid Tab * */ - private GridTab m_GridTab; // added for processCallout - /** The Grid Field * */ - private GridField m_GridField; // added for processCallout - - /** Calling Window Info */ - private int m_AD_Column_ID = 0; - private GridField m_mField; - /** No Instance Key */ - private static Integer NO_INSTANCE = Integer.valueOf(0); - /** Logger */ - private static CLogger log = CLogger.getCLogger(VPAttribute.class); - - - /** - * Dispose resources - */ - public void dispose() - { - m_text = null; - m_button = null; - m_mPAttribute.dispose(); - m_mPAttribute = null; - m_GridField = null; - m_GridTab = null; - } // dispose - - /** - * Set Mandatory - * @param mandatory mandatory - */ - public void setMandatory (boolean mandatory) - { - m_mandatory = mandatory; - m_button.setMandatory(mandatory); - setBackground (false); - } // setMandatory - - /** - * Get Mandatory - * @return mandatory - */ - public boolean isMandatory() - { - return m_mandatory; - } // isMandatory - - /** - * Set ReadWrite - * @param rw read rwite - */ - public void setReadWrite (boolean rw) - { - m_readWrite = rw; - m_button.setReadWrite(rw); - setBackground (false); - } // setReadWrite - - /** - * Is Read Write - * @return read write - */ - public boolean isReadWrite() - { - return m_readWrite; - } // isReadWrite - - /** - * Set Foreground - * @param color color - */ - public void setForeground (Color color) - { - m_text.setForeground(color); - } // SetForeground - - /** - * Set Background - * @param error Error - */ - public void setBackground (boolean error) - { - if (error) - setBackground(AdempierePLAF.getFieldBackground_Error()); - else if (!m_readWrite) - setBackground(AdempierePLAF.getFieldBackground_Inactive()); - else if (m_mandatory) - setBackground(AdempierePLAF.getFieldBackground_Mandatory()); - else - setBackground(AdempierePLAF.getInfoBackground()); - } // setBackground - - /** - * Set Background - * @param color Color - */ - public void setBackground (Color color) - { - m_text.setBackground(color); - } // setBackground - - - /************************************************************************** - * Set/lookup Value - * @param value value - */ - public void setValue(Object value) - { - if (value == null || NO_INSTANCE.equals(value)) - { - m_text.setText(""); - m_value = value; - return; - } - - // The same - if (value.equals(m_value)) - return; - // new value - if (log.isLoggable(Level.FINE)) log.fine("Value=" + value); - m_value = value; - m_text.setText(m_mPAttribute.getDisplay(value)); // loads value - } // setValue - - /** - * Get Value - * @return value - */ - public Object getValue() - { - return m_value; - } // getValue - - /** - * Get Display Value - * @return info - */ - public String getDisplay() - { - return m_text.getText(); - } // getDisplay - - - /************************************************************************** - * Set Field - * @param mField MField - */ - public void setField(GridField mField) - { - // To determine behavior - m_AD_Column_ID = mField.getAD_Column_ID(); - m_GridField = mField; - - m_mField = mField; - if (m_mField != null) - FieldRecordInfo.addMenu(this, popupMenu); - } // setField - - @Override - public GridField getField() { - return m_mField; - } - - /** - * Action Listener Interface - * @param listener listener - */ - public void addActionListener(ActionListener listener) - { - } // addActionListener - - /** - * Action Listener - start dialog - * @param e Event - */ - public void actionPerformed(ActionEvent e) - { - if (e.getActionCommand().equals(FieldRecordInfo.CHANGE_LOG_COMMAND)) - { - FieldRecordInfo.start(m_mField); - return; - } - - if (!m_button.isEnabled ()) - return; - m_button.setEnabled (false); - // - Integer oldValue = (Integer)getValue (); - int oldValueInt = oldValue == null ? 0 : oldValue.intValue (); - int M_AttributeSetInstance_ID = oldValueInt; - int M_Product_ID = 0; - int M_ProductBOM_ID = 0; - if (m_GridTab != null) { - M_Product_ID = Env.getContextAsInt (Env.getCtx (), m_WindowNo, m_GridTab.getTabNo(), "M_Product_ID"); - M_ProductBOM_ID = Env.getContextAsInt (Env.getCtx (), m_WindowNo, m_GridTab.getTabNo(), "M_ProductBOM_ID"); - } else { - M_Product_ID = Env.getContextAsInt (Env.getCtx (), m_WindowNo, "M_Product_ID"); - M_ProductBOM_ID = Env.getContextAsInt (Env.getCtx (), m_WindowNo, "M_ProductBOM_ID"); - } - int M_Locator_ID = -1; - - if (log.isLoggable(Level.CONFIG)) log.config("M_Product_ID=" + M_Product_ID + "/" + M_ProductBOM_ID - + ",M_AttributeSetInstance_ID=" + M_AttributeSetInstance_ID - + ", AD_Column_ID=" + m_AD_Column_ID); - - // M_Product.M_AttributeSetInstance_ID = 8418 - boolean productWindow = m_AD_Column_ID == COLUMN_M_PRODUCT_M_ATTRIBUTESETINSTANCE_ID; // HARDCODED - - // Exclude ability to enter ASI - boolean exclude = true; - - if (M_Product_ID != 0) - { - MProduct product = MProduct.get(Env.getCtx(), M_Product_ID); - int M_AttributeSet_ID = product.getM_AttributeSet_ID(); - if (M_AttributeSet_ID != 0) - { - MAttributeSet mas = MAttributeSet.get(Env.getCtx(), M_AttributeSet_ID); - exclude = mas.excludeEntry(m_AD_Column_ID, Env.isSOTrx(Env.getCtx(), m_WindowNo)); - } - } - - boolean changed = false; - if (M_ProductBOM_ID != 0) // Use BOM Component - M_Product_ID = M_ProductBOM_ID; - // - if (!productWindow && (M_Product_ID == 0 || exclude)) - { - changed = true; - m_text.setText(null); - M_AttributeSetInstance_ID = 0; - } - else - { - VPAttributeDialog vad = new VPAttributeDialog (AEnv.getFrame (this), - M_AttributeSetInstance_ID, M_Product_ID, m_C_BPartner_ID, - productWindow, m_AD_Column_ID, m_WindowNo); - if (vad.isChanged()) - { - m_text.setText(vad.getM_AttributeSetInstanceName()); - M_AttributeSetInstance_ID = vad.getM_AttributeSetInstance_ID(); - if (!productWindow && vad.getM_Locator_ID() > 0) - { - M_Locator_ID = vad.getM_Locator_ID(); - } - changed = true; - } - } - - // Set Value - if (changed) - { - if (log.isLoggable(Level.FINEST)) log.finest("Changed M_AttributeSetInstance_ID=" + M_AttributeSetInstance_ID); - m_value = new Object(); // force re-query display - if (M_AttributeSetInstance_ID == 0) - setValue(null); - else - setValue(Integer.valueOf(M_AttributeSetInstance_ID)); - // Change Locator - if (m_GridTab != null && M_Locator_ID > 0) - { - if (log.isLoggable(Level.FINEST)) log.finest("Change M_Locator_ID="+M_Locator_ID); - m_GridTab.setValue("M_Locator_ID", M_Locator_ID); - } - // - try - { - String columnName = "M_AttributeSetInstance_ID"; - if (m_GridField != null) - { - columnName = m_GridField.getColumnName(); - } - fireVetoableChange(columnName, new Object(), getValue()); - } - catch (PropertyVetoException pve) - { - log.log(Level.SEVERE, "", pve); - } - if (M_AttributeSetInstance_ID == oldValueInt && m_GridTab != null && m_GridField != null) - { - // force Change - user does not realize that embedded object is already saved. - m_GridTab.processFieldChange(m_GridField); - } - } // change - m_button.setEnabled(true); - requestFocus(); - } // actionPerformed - - /** - * Property Change Listener - * @param evt event - */ - public void propertyChange (PropertyChangeEvent evt) - { - if (evt.getPropertyName().equals(org.compiere.model.GridField.PROPERTY)) - setValue(evt.getNewValue()); - } // propertyChange - - /** - * Request Focus - */ - @Override - public void requestFocus() - { - m_text.requestFocus(); - } // requestFocus - - /** - * Request Focus In Window - * @return focus request - */ - @Override - public boolean requestFocusInWindow() - { - return m_text.requestFocusInWindow(); - } // requestFocusInWindow - - /** - * Get Focus Component - * @return component - */ - public Component getFocusableComponent() - { - return m_text; - } // getFocusComponent - -} // VPAttribute diff --git a/org.adempiere.ui.swing/src/org/compiere/grid/ed/VPAttributeDialog.java b/org.adempiere.ui.swing/src/org/compiere/grid/ed/VPAttributeDialog.java deleted file mode 100644 index e68cb9016a..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/grid/ed/VPAttributeDialog.java +++ /dev/null @@ -1,842 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ -package org.compiere.grid.ed; - -import java.awt.BorderLayout; -import java.awt.Component; -import java.awt.Cursor; -import java.awt.Dimension; -import java.awt.Font; -import java.awt.Frame; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.awt.event.MouseEvent; -import java.math.BigDecimal; -import java.sql.PreparedStatement; -import java.sql.ResultSet; -import java.sql.Timestamp; -import java.util.ArrayList; -import java.util.logging.Level; - -import javax.swing.JPopupMenu; -import javax.swing.SwingConstants; -import javax.swing.SwingUtilities; - -import org.compiere.apps.ADialog; -import org.compiere.apps.AEnv; -import org.compiere.apps.ALayout; -import org.compiere.apps.ALayoutConstraint; -import org.compiere.apps.AWindow; -import org.compiere.apps.ConfirmPanel; -import org.compiere.apps.search.PAttributeInstance; -import org.compiere.model.MAttribute; -import org.compiere.model.MAttributeInstance; -import org.compiere.model.MAttributeSet; -import org.compiere.model.MAttributeSetInstance; -import org.compiere.model.MAttributeValue; -import org.compiere.model.MDocType; -import org.compiere.model.MLot; -import org.compiere.model.MLotCtl; -import org.compiere.model.MQuery; -import org.compiere.model.MRole; -import org.compiere.model.MSerNoCtl; -import static org.compiere.model.SystemIDs.*; -import org.compiere.model.X_M_MovementLine; -import org.compiere.swing.CButton; -import org.compiere.swing.CCheckBox; -import org.compiere.swing.CComboBox; -import org.compiere.swing.CDialog; -import org.compiere.swing.CEditor; -import org.compiere.swing.CLabel; -import org.compiere.swing.CMenuItem; -import org.compiere.swing.CPanel; -import org.compiere.swing.CTextField; -import org.compiere.util.CLogger; -import org.compiere.util.DB; -import org.compiere.util.DisplayType; -import org.compiere.util.Env; -import org.compiere.util.KeyNamePair; -import org.compiere.util.Msg; - -/** - * Product Attribute Set Product/Instance Dialog Editor. - * Called from VPAttribute.actionPerformed - * - * @author Jorg Janke - * @version $Id: VPAttributeDialog.java,v 1.4 2006/07/30 00:51:27 jjanke Exp $ - */ -public class VPAttributeDialog extends CDialog - implements ActionListener -{ - /** - * - */ - private static final long serialVersionUID = -1062346984681892620L; - - /***************************************************************************** - * Mouse Listener for Popup Menu - */ - final class VPAttributeDialog_mouseAdapter extends java.awt.event.MouseAdapter - { - /** - * Constructor - * @param adaptee adaptee - */ - VPAttributeDialog_mouseAdapter(VPAttributeDialog adaptee) - { - m_adaptee = adaptee; - } // VPAttributeDialog_mouseAdapter - - private VPAttributeDialog m_adaptee; - - /** - * Mouse Listener - * @param e MouseEvent - */ - public void mouseClicked(MouseEvent e) - { - // System.out.println("mouseClicked " + e.getID() + " " + e.getSource().getClass().toString()); - // popup menu - if (SwingUtilities.isRightMouseButton(e)) - m_adaptee.popupMenu.show((Component)e.getSource(), e.getX(), e.getY()); - } // mouse Clicked - - } // VPAttributeDialog_mouseAdapter - - /** - * Product Attribute Instance Dialog - * @param frame parent frame - * @param M_AttributeSetInstance_ID Product Attribute Set Instance id - * @param M_Product_ID Product id - * @param C_BPartner_ID b partner - * @param productWindow this is the product window (define Product Instance) - * @param AD_Column_ID column - * @param WindowNo window - */ - public VPAttributeDialog (Frame frame, int M_AttributeSetInstance_ID, - int M_Product_ID, int C_BPartner_ID, - boolean productWindow, int AD_Column_ID, int WindowNo) - { - super (frame, Msg.translate(Env.getCtx(), "M_AttributeSetInstance_ID") , true); - if (log.isLoggable(Level.CONFIG)) log.config("M_AttributeSetInstance_ID=" + M_AttributeSetInstance_ID - + ", M_Product_ID=" + M_Product_ID - + ", C_BPartner_ID=" + C_BPartner_ID - + ", ProductW=" + productWindow + ", Column=" + AD_Column_ID); - m_WindowNo = AEnv.createWindowNo (this); - m_M_AttributeSetInstance_ID = M_AttributeSetInstance_ID; - m_M_Product_ID = M_Product_ID; - m_C_BPartner_ID = C_BPartner_ID; - m_productWindow = productWindow; - m_AD_Column_ID = AD_Column_ID; - m_WindowNoParent = WindowNo; - - //get columnName from ad_column - m_columnName = DB.getSQLValueString(null, "SELECT ColumnName FROM AD_Column WHERE AD_Column_ID = ?", m_AD_Column_ID); - if (m_columnName == null || m_columnName.trim().length() == 0) - { - //fallback - m_columnName = "M_AttributeSetInstance_ID"; - } - - try - { - jbInit(); - } - catch(Exception ex) - { - log.log(Level.SEVERE, "VPAttributeDialog" + ex); - } - // Dynamic Init - if (!initAttributes ()) - { - dispose(); - return; - } - AEnv.showCenterWindow(frame, this); - } // VPAttributeDialog - - private int m_WindowNo; - private MAttributeSetInstance m_masi; - private int m_M_AttributeSetInstance_ID; - private int m_M_Locator_ID; - private String m_M_AttributeSetInstanceName; - private int m_M_Product_ID; - private int m_C_BPartner_ID; - private int m_AD_Column_ID; - private int m_WindowNoParent; - /** Enter Product Attributes */ - private boolean m_productWindow = false; - /** Change */ - private boolean m_changed = false; - - private CLogger log = CLogger.getCLogger(getClass()); - /** Row Counter */ - private int m_row = 0; - /** List of Editors */ - private ArrayList m_editors = new ArrayList(); - /** Length of Instance value (40) */ - private static final int INSTANCE_VALUE_LENGTH = 40; - - private CCheckBox cbNewEdit = new CCheckBox(); - private CButton bSelect = new CButton(Env.getImageIcon("PAttribute16.gif")); - // Lot - private VString fieldLotString = new VString ("Lot", false, false, true, 20, 20, null, null); - private CComboBoxfieldLot = null; - private CButton bLot = new CButton(Msg.getMsg (Env.getCtx(), "New")); - // Lot Popup - JPopupMenu popupMenu = new JPopupMenu(); - private CMenuItem mZoom; - // Ser No - private VString fieldSerNo = new VString ("SerNo", false, false, true, 20, 20, null, null); - private CButton bSerNo = new CButton(Msg.getMsg (Env.getCtx(), "New")); - // Date - private VDate fieldGuaranteeDate = new VDate ("GuaranteeDate", false, false, true, DisplayType.Date, Msg.translate(Env.getCtx(), "GuaranteeDate")); - // - private CTextField fieldDescription = new CTextField (20); - // - private BorderLayout mainLayout = new BorderLayout(); - private CPanel centerPanel = new CPanel(); - private ALayout centerLayout = new ALayout(5,5, true); - private ConfirmPanel confirmPanel = new ConfirmPanel (true); - - private String m_columnName = null; - - /** - * Layout - * @throws Exception - */ - private void jbInit () throws Exception - { - this.getContentPane().setLayout(mainLayout); - this.getContentPane().add(centerPanel, BorderLayout.CENTER); - this.getContentPane().add(confirmPanel, BorderLayout.SOUTH); - centerPanel.setLayout(centerLayout); - // - confirmPanel.addActionListener(this); - } // jbInit - - /** - * Dyanmic Init. - * @return true if initialized - */ - private boolean initAttributes () - { - if (m_M_Product_ID == 0 && !m_productWindow) - return false; - - MAttributeSet as = null; - - if (m_M_Product_ID != 0) - { - // Get Model - m_masi = MAttributeSetInstance.get(Env.getCtx(), m_M_AttributeSetInstance_ID, m_M_Product_ID); - if (m_masi == null) - { - log.severe ("No Model for M_AttributeSetInstance_ID=" + m_M_AttributeSetInstance_ID + ", M_Product_ID=" + m_M_Product_ID); - return false; - } - Env.setContext(Env.getCtx(), m_WindowNo, "M_AttributeSet_ID", m_masi.getM_AttributeSet_ID()); - - // Get Attribute Set - as = m_masi.getMAttributeSet(); - } - else - { - int M_AttributeSet_ID = Env.getContextAsInt(Env.getCtx(), m_WindowNoParent, "M_AttributeSet_ID"); - m_masi = new MAttributeSetInstance (Env.getCtx(), 0, M_AttributeSet_ID, null); - as = m_masi.getMAttributeSet(); - } - - // Product has no Attribute Set - if (as == null) - { - ADialog.error(m_WindowNo, this, "PAttributeNoAttributeSet"); - return false; - } - // Product has no Instance Attributes - if (!m_productWindow && !as.isInstanceAttribute()) - { - ADialog.error(m_WindowNo, this, "PAttributeNoInstanceAttribute"); - return false; - } - - // Show Product Attributes - if (m_productWindow) - { - MAttribute[] attributes = as.getMAttributes (false); - if (log.isLoggable(Level.FINE)) log.fine ("Product Attributes=" + attributes.length); - for (int i = 0; i < attributes.length; i++) - addAttributeLine (attributes[i], true, !m_productWindow); - } - else // Set Instance Attributes - { - // New/Edit - Selection - if (m_M_AttributeSetInstance_ID == 0) // new - cbNewEdit.setText(Msg.getMsg(Env.getCtx(), "NewRecord")); - else - cbNewEdit.setText(Msg.getMsg(Env.getCtx(), "EditRecord")); - cbNewEdit.addActionListener(this); - centerPanel.add(cbNewEdit, new ALayoutConstraint(m_row++,0)); - bSelect.setText(Msg.getMsg(Env.getCtx(), "SelectExisting")); - bSelect.addActionListener(this); - centerPanel.add(bSelect, null); - // All Attributes - MAttribute[] attributes = as.getMAttributes (true); - if (log.isLoggable(Level.FINE)) log.fine ("Instance Attributes=" + attributes.length); - for (int i = 0; i < attributes.length; i++) - addAttributeLine (attributes[i], false, false); - } - - // Lot - if (!m_productWindow && as.isLot()) - { - CLabel label = new CLabel (Msg.translate(Env.getCtx(), "Lot")); - label.setLabelFor (fieldLotString); - centerPanel.add(label, new ALayoutConstraint(m_row++,0)); - centerPanel.add(fieldLotString, null); - fieldLotString.setText (m_masi.getLot()); - // M_Lot_ID - // int AD_Column_ID = 9771; // M_AttributeSetInstance.M_Lot_ID - // fieldLot = new VLookup ("M_Lot_ID", false,false, true, - // MLookupFactory.get(Env.getCtx(), m_WindowNo, 0, AD_Column_ID, DisplayType.TableDir)); - String sql = "SELECT M_Lot_ID, Name " - + "FROM M_Lot l " - + "WHERE EXISTS (SELECT M_Product_ID FROM M_Product p " - + "WHERE p.M_AttributeSet_ID=" + m_masi.getM_AttributeSet_ID() - + " AND p.M_Product_ID=l.M_Product_ID)"; - fieldLot = new CComboBox(DB.getKeyNamePairs(sql, true)); - label = new CLabel (Msg.translate(Env.getCtx(), "M_Lot_ID")); - label.setLabelFor (fieldLot); - centerPanel.add(label, new ALayoutConstraint(m_row++,0)); - centerPanel.add(fieldLot, null); - if (m_masi.getM_Lot_ID() != 0) - { - for (int i = 1; i < fieldLot.getItemCount(); i++) - { - KeyNamePair pp = (KeyNamePair)fieldLot.getItemAt(i); - if (pp.getKey() == m_masi.getM_Lot_ID()) - { - fieldLot.setSelectedIndex(i); - fieldLotString.setEditable(false); - break; - } - } - } - fieldLot.addActionListener(this); - // New Lot Button - if (m_masi.getMAttributeSet().getM_LotCtl_ID() != 0) - { - if (MRole.getDefault().isTableAccess(MLot.Table_ID, false) - && MRole.getDefault().isTableAccess(MLotCtl.Table_ID, false) - && !m_masi.isExcludeLot(m_AD_Column_ID, Env.isSOTrx(Env.getCtx(), m_WindowNoParent))) - { - centerPanel.add(bLot, null); - bLot.addActionListener(this); - } - } - // Popup - fieldLot.addMouseListener(new VPAttributeDialog_mouseAdapter(this)); // popup - mZoom = new CMenuItem(Msg.getMsg(Env.getCtx(), "Zoom"), Env.getImageIcon("Zoom16.gif")); - mZoom.addActionListener(this); - popupMenu.add(mZoom); - } // Lot - - // SerNo - if (!m_productWindow && as.isSerNo()) - { - CLabel label = new CLabel (Msg.translate(Env.getCtx(), "SerNo")); - label.setLabelFor(fieldSerNo); - fieldSerNo.setText(m_masi.getSerNo()); - centerPanel.add(label, new ALayoutConstraint(m_row++,0)); - centerPanel.add(fieldSerNo, null); - // New SerNo Button - if (m_masi.getMAttributeSet().getM_SerNoCtl_ID() != 0) - { - if (MRole.getDefault().isTableAccess(MSerNoCtl.Table_ID, false) - && !m_masi.isExcludeSerNo(m_AD_Column_ID, Env.isSOTrx(Env.getCtx(), m_WindowNoParent))) - { - centerPanel.add(bSerNo, null); - bSerNo.addActionListener(this); - } - } - } // SerNo - - // GuaranteeDate - if (!m_productWindow && as.isGuaranteeDate()) - { - CLabel label = new CLabel (Msg.translate(Env.getCtx(), "GuaranteeDate")); - label.setLabelFor(fieldGuaranteeDate); - if (m_M_AttributeSetInstance_ID == 0) - fieldGuaranteeDate.setValue(m_masi.getGuaranteeDate(true)); - else - fieldGuaranteeDate.setValue(m_masi.getGuaranteeDate()); - centerPanel.add(label, new ALayoutConstraint(m_row++,0)); - centerPanel.add(fieldGuaranteeDate, null); - } // GuaranteeDate - - if (m_row == 0) - { - ADialog.error(m_WindowNo, this, "PAttributeNoInfo"); - return false; - } - - // New/Edit Window - if (!m_productWindow) - { - cbNewEdit.setSelected(m_M_AttributeSetInstance_ID == 0); - cmd_newEdit(); - } - - // Attribute Set Instance Description - CLabel label = new CLabel (Msg.translate(Env.getCtx(), "Description")); - label.setLabelFor(fieldDescription); - fieldDescription.setText(m_masi.getDescription()); - fieldDescription.setEditable(false); - centerPanel.add(label, new ALayoutConstraint(m_row++,0)); - centerPanel.add(fieldDescription, null); - - // Window usually to wide (??) - Dimension dd = centerPanel.getPreferredSize(); - dd.width = Math.min(500, dd.width); - centerPanel.setPreferredSize(dd); - return true; - } // initAttribute - - /** - * Add Attribute Line - * @param attribute attribute - * @param product product level attribute - * @param readOnly value is read only - */ - private void addAttributeLine (MAttribute attribute, boolean product, boolean readOnly) - { - if (log.isLoggable(Level.FINE)) log.fine(attribute + ", Product=" + product + ", R/O=" + readOnly); - CLabel label = new CLabel (attribute.getName()); - if (product) - label.setFont(new Font(label.getFont().getFontName(), Font.BOLD, label.getFont().getSize())); - if (attribute.getDescription() != null) - label.setToolTipText(attribute.getDescription()); - centerPanel.add(label, new ALayoutConstraint(m_row++,0)); - // - MAttributeInstance instance = attribute.getMAttributeInstance (m_M_AttributeSetInstance_ID); - if (MAttribute.ATTRIBUTEVALUETYPE_List.equals(attribute.getAttributeValueType())) - { - MAttributeValue[] values = attribute.getMAttributeValues(); // optional = null - CComboBox editor = new CComboBox(values); - boolean found = false; - if (instance != null) - { - for (int i = 0; i < values.length; i++) - { - if (values[i] != null && values[i].getM_AttributeValue_ID () == instance.getM_AttributeValue_ID ()) - { - editor.setSelectedIndex (i); - found = true; - break; - } - } - if (found) { - if (log.isLoggable(Level.FINE)) log.fine("Attribute=" + attribute.getName() + " #" + values.length + " - found: " + instance); - } else { - log.warning("Attribute=" + attribute.getName() + " #" + values.length + " - NOT found: " + instance); - } - } // setComboBox - else - if (log.isLoggable(Level.FINE)) log.fine("Attribute=" + attribute.getName() + " #" + values.length + " no instance"); - label.setLabelFor(editor); - centerPanel.add(editor, null); - if (readOnly) - editor.setEnabled(false); - else - m_editors.add (editor); - } - else if (MAttribute.ATTRIBUTEVALUETYPE_Number.equals(attribute.getAttributeValueType())) - { - VNumber editor = new VNumber(attribute.getName(), attribute.isMandatory(), - false, true, DisplayType.Number, attribute.getName()); - if (instance != null) - editor.setValue(instance.getValueNumber()); - else - editor.setValue(Env.ZERO); - label.setLabelFor(editor); - centerPanel.add(editor, null); - if (readOnly) - editor.setEnabled(false); - else - m_editors.add (editor); - } - else // Text Field - { - VString editor = new VString (attribute.getName(), attribute.isMandatory(), - false, true, 20, INSTANCE_VALUE_LENGTH, null, null); - if (instance != null) - editor.setText(instance.getValue()); - label.setLabelFor(editor); - centerPanel.add(editor, null); - if (readOnly) - editor.setEnabled(false); - else - m_editors.add (editor); - } - } // addAttributeLine - - /** - * dispose - */ - public void dispose() - { - removeAll(); - Env.clearWinContext(m_WindowNo); - // - Env.setContext(Env.getCtx(), m_WindowNo, Env.TAB_INFO, m_columnName, - String.valueOf(m_M_AttributeSetInstance_ID)); - Env.setContext(Env.getCtx(), m_WindowNo, Env.TAB_INFO, "M_Locator_ID", - String.valueOf(m_M_Locator_ID)); - // - super.dispose(); - } // dispose - - /** - * ActionListener - * @param e event - */ - public void actionPerformed(ActionEvent e) - { - // Select Instance - if (e.getSource() == bSelect) - { - if (cmd_select()) - dispose(); - } - // New/Edit - else if (e.getSource() == cbNewEdit) - { - cmd_newEdit(); - } - // Select Lot from existing - else if (e.getSource() == fieldLot) - { - KeyNamePair pp = (KeyNamePair)fieldLot.getSelectedItem(); - if (pp != null && pp.getKey() != -1) - { - fieldLotString.setText(pp.getName()); - fieldLotString.setEditable(false); - m_masi.setM_Lot_ID(pp.getKey()); - } - else - { - fieldLotString.setEditable(true); - m_masi.setM_Lot_ID(0); - } - } - // Create New Lot - else if (e.getSource() == bLot) - { - KeyNamePair pp = m_masi.createLot(m_M_Product_ID); - if (pp != null) - { - fieldLot.addItem(pp); - fieldLot.setSelectedItem(pp); - } - } - // Create New SerNo - else if (e.getSource() == bSerNo) - { - fieldSerNo.setText(m_masi.getSerNo(true)); - } - - // OK - else if (e.getActionCommand().equals(ConfirmPanel.A_OK)) - { - if (saveSelection()) - dispose(); - } - // Cancel - else if (e.getActionCommand().equals(ConfirmPanel.A_CANCEL)) - { - m_changed = false; - m_M_AttributeSetInstance_ID = 0; - m_M_Locator_ID = 0; - dispose(); - } - // Zoom M_Lot - else if (e.getSource() == mZoom) - { - cmd_zoom(); - } - else - log.log(Level.SEVERE, "not found - " + e); - } // actionPerformed - - /** - * Instance Selection Button - * @return true if selected - */ - private boolean cmd_select() - { - log.config(""); - - int M_Warehouse_ID = Env.getContextAsInt(Env.getCtx(), m_WindowNoParent, "M_Warehouse_ID"); - - int C_DocType_ID = Env.getContextAsInt(Env.getCtx(), m_WindowNoParent, "C_DocType_ID"); - if (C_DocType_ID > 0) { - MDocType doctype = new MDocType (Env.getCtx(), C_DocType_ID, null); - String docbase = doctype.getDocBaseType(); - if (docbase.equals(MDocType.DOCBASETYPE_MaterialReceipt)) - M_Warehouse_ID = 0; - } - - // teo_sarca [ 1564520 ] Inventory Move: can't select existing attributes - int M_Locator_ID = 0; - if (m_AD_Column_ID == COLUMN_M_MOVEMENTLINE_M_ATTRIBUTESETINSTANCE_ID) { // TODO: hardcoded: M_MovementLine[324].M_AttributeSetInstance_ID[8551] - M_Locator_ID = Env.getContextAsInt(Env.getCtx(), m_WindowNoParent, X_M_MovementLine.COLUMNNAME_M_Locator_ID, true); // only window - } - - String title = ""; - // Get Text - String sql = "SELECT p.Name, w.Name, w.M_Warehouse_ID FROM M_Product p, M_Warehouse w " - + "WHERE p.M_Product_ID=? AND w.M_Warehouse_ID" - + (M_Locator_ID <= 0 ? "=?" : " IN (SELECT M_Warehouse_ID FROM M_Locator where M_Locator_ID=?)"); // teo_sarca [ 1564520 ] - PreparedStatement pstmt = null; - ResultSet rs = null; - try - { - pstmt = DB.prepareStatement(sql, null); - pstmt.setInt(1, m_M_Product_ID); - pstmt.setInt(2, M_Locator_ID <= 0 ? M_Warehouse_ID : M_Locator_ID); - rs = pstmt.executeQuery(); - if (rs.next()) { - title = rs.getString(1) + " - " + rs.getString(2); - M_Warehouse_ID = rs.getInt(3); // fetch the actual warehouse - teo_sarca [ 1564520 ] - } - } - catch (Exception e) - { - log.log(Level.SEVERE, sql, e); - } - finally - { - DB.close(rs, pstmt); - rs = null; pstmt = null; - } - // - PAttributeInstance pai = new PAttributeInstance(this, title, - M_Warehouse_ID, M_Locator_ID, m_M_Product_ID, m_C_BPartner_ID); - if (pai.getM_AttributeSetInstance_ID() != -1) - { - m_M_AttributeSetInstance_ID = pai.getM_AttributeSetInstance_ID(); - m_M_AttributeSetInstanceName = pai.getM_AttributeSetInstanceName(); - m_M_Locator_ID = pai.getM_Locator_ID(); - m_changed = true; - return true; - } - return false; - } // cmd_select - - /** - * Instance New/Edit - */ - private void cmd_newEdit() - { - boolean rw = cbNewEdit.isSelected(); - if (log.isLoggable(Level.CONFIG)) log.config("R/W=" + rw + " " + m_masi); - // - fieldLotString.setEditable(rw && m_masi.getM_Lot_ID()==0); - if (fieldLot != null) - fieldLot.setReadWrite(rw); - bLot.setReadWrite(rw); - fieldSerNo.setReadWrite(rw); - bSerNo.setReadWrite(rw); - fieldGuaranteeDate.setReadWrite(rw); - // - for (int i = 0; i < m_editors.size(); i++) - { - CEditor editor = (CEditor)m_editors.get(i); - editor.setReadWrite(rw); - } - } // cmd_newEdit - - /** - * Zoom M_Lot - */ - private void cmd_zoom() - { - int M_Lot_ID = 0; - KeyNamePair pp = (KeyNamePair)fieldLot.getSelectedItem(); - if (pp != null) - M_Lot_ID = pp.getKey(); - MQuery zoomQuery = new MQuery("M_Lot"); - zoomQuery.addRestriction("M_Lot_ID", MQuery.EQUAL, M_Lot_ID); - if (log.isLoggable(Level.INFO)) log.info(zoomQuery.toString()); - // - setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); - // - int AD_Window_ID = WINDOW_LOT; // Lot - AWindow frame = new AWindow(null); - if (frame.initWindow(AD_Window_ID, zoomQuery)) - { - this.setVisible(false); - this.setModal (false); // otherwise blocked - this.setVisible(true); - AEnv.addToWindowManager(frame); - AEnv.showScreen(frame, SwingConstants.EAST); - } - // async window - not able to get feedback - frame = null; - // - setCursor(Cursor.getDefaultCursor()); - } // cmd_zoom - - /** - * Save Selection - * @return true if saved - */ - private boolean saveSelection() - { - log.info(""); - MAttributeSet as = m_masi.getMAttributeSet(); - if (as == null) - return true; - // - m_changed = false; - String mandatory = ""; - if (!m_productWindow && as.isLot()) - { - if (log.isLoggable(Level.FINE)) log.fine("Lot=" + fieldLotString.getText ()); - String text = fieldLotString.getText(); - m_masi.setLot (text); - if (as.isLotMandatory() && (text == null || text.length() == 0)) - mandatory += " - " + Msg.translate(Env.getCtx(), "Lot"); - m_changed = true; - } // Lot - if (!m_productWindow && as.isSerNo()) - { - if (log.isLoggable(Level.FINE)) log.fine("SerNo=" + fieldSerNo.getText()); - String text = fieldSerNo.getText(); - m_masi.setSerNo(text); - if (as.isSerNoMandatory() && (text == null || text.length() == 0)) - mandatory += " - " + Msg.translate(Env.getCtx(), "SerNo"); - m_changed = true; - } // SerNo - if (!m_productWindow && as.isGuaranteeDate()) - { - if (log.isLoggable(Level.FINE)) log.fine("GuaranteeDate=" + fieldGuaranteeDate.getValue()); - Timestamp ts = (Timestamp)fieldGuaranteeDate.getValue(); - m_masi.setGuaranteeDate(ts); - if (as.isGuaranteeDateMandatory() && ts == null) - mandatory += " - " + Msg.translate(Env.getCtx(), "GuaranteeDate"); - m_changed = true; - } // GuaranteeDate - - // *** Save Attributes *** - // New Instance - if (mandatory.isEmpty() && (m_changed || m_masi.getM_AttributeSetInstance_ID() == 0)) - { - m_masi.saveEx(); - m_M_AttributeSetInstance_ID = m_masi.getM_AttributeSetInstance_ID (); - m_M_AttributeSetInstanceName = m_masi.getDescription(); - } - - // Save Instance Attributes - MAttribute[] attributes = as.getMAttributes(!m_productWindow); - for (int i = 0; i < attributes.length; i++) - { - if (MAttribute.ATTRIBUTEVALUETYPE_List.equals(attributes[i].getAttributeValueType())) - { - CComboBox editor = (CComboBox)m_editors.get(i); - MAttributeValue value = (MAttributeValue)editor.getSelectedItem(); - if (log.isLoggable(Level.FINE)) log.fine(attributes[i].getName() + "=" + value); - if (attributes[i].isMandatory() && value == null) - mandatory += " - " + attributes[i].getName(); - attributes[i].setMAttributeInstance(m_M_AttributeSetInstance_ID, value); - } - else if (MAttribute.ATTRIBUTEVALUETYPE_Number.equals(attributes[i].getAttributeValueType())) - { - VNumber editor = (VNumber)m_editors.get(i); - BigDecimal value = (BigDecimal)editor.getValue(); - if (log.isLoggable(Level.FINE)) log.fine(attributes[i].getName() + "=" + value); - if (attributes[i].isMandatory() && value == null) - mandatory += " - " + attributes[i].getName(); - attributes[i].setMAttributeInstance(m_M_AttributeSetInstance_ID, value); - } - else - { - VString editor = (VString)m_editors.get(i); - String value = editor.getText(); - if (log.isLoggable(Level.FINE)) log.fine(attributes[i].getName() + "=" + value); - if (attributes[i].isMandatory() && (value == null || value.length() == 0)) - mandatory += " - " + attributes[i].getName(); - attributes[i].setMAttributeInstance(m_M_AttributeSetInstance_ID, value); - } - m_changed = true; - } // for all attributes - - if (mandatory.length() > 0) - { - ADialog.error(m_WindowNo, this, "FillMandatory", mandatory); - return false; - } - // Save Model - else if (m_changed) - { - m_masi.setDescription (); - m_masi.saveEx(); - } - m_M_AttributeSetInstance_ID = m_masi.getM_AttributeSetInstance_ID (); - m_M_AttributeSetInstanceName = m_masi.getDescription(); - // - return true; - } // saveSelection - - - /************************************************************************** - * Get Instance ID - * @return Instance ID - */ - public int getM_AttributeSetInstance_ID() - { - return m_M_AttributeSetInstance_ID; - } // getM_AttributeSetInstance_ID - - /** - * Get Instance Name - * @return Instance Name - */ - public String getM_AttributeSetInstanceName() - { - return m_M_AttributeSetInstanceName; - } // getM_AttributeSetInstanceName - - /** - * Get Locator ID - * @return M_Locator_ID - */ - public int getM_Locator_ID() - { - return m_M_Locator_ID; - } - - /** - * Value Changed - * @return true if changed - */ - public boolean isChanged() - { - return m_changed; - } // isChanged - -} // VPAttributeDialog diff --git a/org.adempiere.ui.swing/src/org/compiere/grid/ed/VPassword.java b/org.adempiere.ui.swing/src/org/compiere/grid/ed/VPassword.java deleted file mode 100644 index da1bae2c78..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/grid/ed/VPassword.java +++ /dev/null @@ -1,229 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ -package org.compiere.grid.ed; - -import java.awt.Component; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.awt.event.FocusEvent; -import java.awt.event.FocusListener; -import java.awt.event.KeyEvent; -import java.awt.event.KeyListener; -import java.beans.PropertyChangeEvent; -import java.beans.PropertyVetoException; - -import org.adempiere.plaf.AdempierePLAF; -import org.compiere.model.GridField; -import org.compiere.swing.CPassword; - -/** - * Data Binding: - * VEditors call fireVetoableChange(m_columnName, null, getText()); - * GridController (for Single-Row) and VCellExitor (for Multi-Row) - * listen to Vetoable Change Listener (vetoableChange) - * then set the value for that column in the current row in the table - * - * @author Jorg Janke - * @version $Id: VPassword.java,v 1.2 2006/07/30 00:51:28 jjanke Exp $ - */ -public final class VPassword extends CPassword - implements VEditor, KeyListener, ActionListener, FocusListener -{ - /** - * - */ - private static final long serialVersionUID = -5450930268559211811L; - - /** - * IDE Bean Constructor for 30 character updateable field - */ - public VPassword() - { - this("Password", false, false, true, 30, 30, ""); - } // VPassword - - /** - * Detail Constructor - * @param columnName column name - * @param mandatory mandatory - * @param isReadOnly read only - * @param isUpdateable updateable - * @param displayLength display length - * @param fieldLength field length - * @param VFormat format - */ - public VPassword (String columnName, boolean mandatory, boolean isReadOnly, boolean isUpdateable, - int displayLength, int fieldLength, String VFormat) - { - super (displayLength>VString.MAXDISPLAY_LENGTH ? VString.MAXDISPLAY_LENGTH : displayLength); - super.setName(columnName); - m_columnName = columnName; - if (VFormat == null) - VFormat = ""; - m_VFormat = VFormat; - m_fieldLength = fieldLength; - if (m_VFormat.length() != 0 || m_fieldLength != 0) - setDocument(new MDocString(m_VFormat, m_fieldLength, this)); - if (m_VFormat.length() != 0) - setCaret(new VOvrCaret()); - // - setMandatory(mandatory); - - // Editable - if (isReadOnly || !isUpdateable) - { - setEditable(false); - setBackground(AdempierePLAF.getFieldBackground_Inactive()); - } - - this.addKeyListener(this); - this.addFocusListener(this); - this.addActionListener(this); - - setForeground(AdempierePLAF.getTextColor_Normal()); - setBackground(AdempierePLAF.getFieldBackground_Normal()); - } // VPassword - - /** - * Dispose - */ - public void dispose() - { - m_mField = null; - } // dispose - - private GridField m_mField = null; - - private String m_columnName; - private String m_oldText; - private String m_VFormat; - private int m_fieldLength; - private volatile boolean m_setting = false; - - /** - * Set Editor to value - * @param value value - */ - public void setValue (Object value) - { - if (value == null) - m_oldText = ""; - else - m_oldText = value.toString(); - if (!m_setting) - setText (m_oldText); - } // setValue - - /** - * Property Change Listener - * @param evt event - */ - public void propertyChange (PropertyChangeEvent evt) - { - if (evt.getPropertyName().equals(org.compiere.model.GridField.PROPERTY)) - setValue(evt.getNewValue()); - } // propertyChange - - /** - * Return Editor value - * @return value - */ - public Object getValue() - { - return String.valueOf(getPassword()); - } // getValue - - /** - * Return Display Value - * @return value - */ - public String getDisplay() - { - return String.valueOf(getPassword()); - } // getDisplay - - /************************************************************************** - * Key Listener Interface - * @param e event - */ - public void keyTyped(KeyEvent e) {} - public void keyPressed(KeyEvent e) {} - - /** - * Key Listener. - * @param e event - */ - public void keyReleased(KeyEvent e) - { - } // keyReleased - - /** - * Data Binding to MTable (via GridController) - Enter pressed - * @param e event - */ - public void actionPerformed(ActionEvent e) - { - String newText = String.valueOf(getPassword()); - // Data Binding - try - { - fireVetoableChange(m_columnName, m_oldText, newText); - } - catch (PropertyVetoException pve) {} - } // actionPerformed - - /** - * Set Field/WindowNo for ValuePreference - * @param mField field - */ - public void setField (GridField mField) - { - m_mField = mField; - } // setField - - @Override - public GridField getField() { - return m_mField; - } - - /** - * Get Focus Component - * @return component - */ - public Component getFocusableComponent() - { - return this; - } // getFocusableComponent - - @Override - public void focusGained(FocusEvent e) { - } - - @Override - public void focusLost(FocusEvent e) { - String newText = String.valueOf(getPassword()); - m_setting = true; - try - { - fireVetoableChange(m_columnName, m_oldText, newText); - } - catch (PropertyVetoException pve) {} - m_setting = false; - } - -} // VPassword - diff --git a/org.adempiere.ui.swing/src/org/compiere/grid/ed/VPaymentEditor.java b/org.adempiere.ui.swing/src/org/compiere/grid/ed/VPaymentEditor.java deleted file mode 100644 index 30c929d418..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/grid/ed/VPaymentEditor.java +++ /dev/null @@ -1,580 +0,0 @@ -/****************************************************************************** - * Copyright (C) 2012 Elaine Tan * - * Copyright (C) 2012 Trek Global - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - *****************************************************************************/ -package org.compiere.grid.ed; - -import java.awt.BorderLayout; -import java.awt.Component; -import java.awt.Dimension; -import java.awt.Insets; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.awt.event.FocusEvent; -import java.awt.event.FocusListener; -import java.beans.PropertyChangeEvent; -import java.beans.PropertyVetoException; -import java.util.logging.Level; - -import javax.swing.DefaultComboBoxModel; -import javax.swing.JComponent; - -import org.compiere.grid.IPaymentForm; -import org.compiere.grid.VPaymentFormDialog; -import org.compiere.grid.VPaymentFormFactory; -import org.compiere.model.GridField; -import org.compiere.model.GridTab; -import org.compiere.model.MLookup; -import org.compiere.model.MPaymentLookup; -import org.compiere.swing.CButton; -import org.compiere.util.CLogger; -import org.compiere.util.DisplayType; -import org.compiere.util.Env; -import org.compiere.util.NamePair; - -/** - * - * @author Elaine - * - */ -public class VPaymentEditor extends JComponent implements VEditor, ActionListener, FocusListener { - - /** - * - */ - private static final long serialVersionUID = 8092151387928370770L; - - /** Logger */ - private static CLogger log = CLogger.getCLogger(VPaymentEditor.class); - /** Search: The Button to open Editor */ - private CButton m_button = new CButton(); - /** The Combo Box if not a Search Lookup */ - private VComboBox m_combo = new VComboBox(); - /** Column Name */ - private String m_columnName; - /** Lookup */ - private MPaymentLookup m_lookup; - /** The Value */ - private Object m_value; - - /** Indicator that value is being set */ - private volatile boolean m_settingValue = false; - /** Indicator that docus is being set */ - private volatile boolean m_settingFocus = false; - /** Indicator that Lookup has focus */ - private volatile boolean m_haveFocus = false; - /** Indicator - inserting new value */ - @SuppressWarnings("unused") - private volatile boolean m_inserting = false; - /** Last Display */ - private String m_lastDisplay = ""; - - private boolean m_stopediting = false; - - private GridField m_mField; - - public VPaymentEditor(GridField gridField, String columnName, boolean mandatory, boolean isReadOnly, boolean isUpdateable, MPaymentLookup lookup) { - super(); - m_mField = gridField; - super.setName(columnName); - m_combo.setName(columnName); - m_columnName = columnName; - setMandatory(mandatory); - m_lookup = lookup; - if (m_lookup != null) - m_lookup.setMandatory(mandatory); - // - setLayout(new BorderLayout()); - - // Button - m_button.addActionListener(this); - m_button.setFocusable(false); // don't focus when tabbing - m_button.setMargin(new Insets(0, 0, 0, 0)); - m_button.setIcon(Env.getImageIcon("Payment10.gif")); - - // *** VComboBox *** - if (m_lookup != null) - { - // Don't have to fill up combobox if it is readonly - if (!isReadOnly && isUpdateable) - m_lookup.fillComboBox (isMandatory(), true, true, false, false); // IDEMPIERE 90 - m_combo.setModel(m_lookup); - // - // AutoCompletion.enable(m_combo); - m_combo.addActionListener(this); // Selection - // FocusListener to refresh selection before opening - m_combo.addFocusListener(this); - } - - setUI (true); - // ReadWrite - decides what components to show - if (isReadOnly || !isUpdateable || m_lookup == null) - setReadWrite(false); - else - setReadWrite(true); - } - - @Override - public void dispose() { - m_button = null; - m_lookup = null; - m_mField = null; - // - m_combo.getEditor().getEditorComponent().removeFocusListener(this); - m_combo.removeFocusListener(this); - m_combo.removeActionListener(this); - m_combo.setModel(new DefaultComboBoxModel()); // remove reference - // m_combo.removeAllItems(); - m_combo = null; - } - - private void setUI (boolean initial) - { - if (initial) - { - Dimension size = m_combo.getPreferredSize(); - setPreferredSize(new Dimension(size)); // causes r/o to be the same length - setMinimumSize(new Dimension (30, size.height)); - // - Dimension bSize = new Dimension(size.height, size.height); - m_button.setPreferredSize (bSize); - } - - // What to show - this.remove(m_combo); - this.remove(m_button); - // - this.setBorder(null); - this.add(m_combo, BorderLayout.CENTER); - this.add(m_button, BorderLayout.EAST); - } - - @Override - public void setReadWrite(boolean value) { - setReadWrite0(value); - - GridTab m_mTab = m_mField.getGridTab(); - String m_DocStatus = (String) m_mTab.getValue("DocStatus"); - // DocStatus - if (m_DocStatus == null) - m_DocStatus = ""; - // Is the Trx closed? Reversed / Voided / Cloased - if (m_DocStatus.equals("RE") || m_DocStatus.equals("VO") || m_DocStatus.equals("CL")) - { - m_button.setVisible(false); - return; - } - - boolean m_onlyRule = false; - // Document is not complete - allow to change the Payment Rule only - if (m_DocStatus.equals("CO") || m_DocStatus.equals("WP")) - m_onlyRule = false; - else - m_onlyRule = true; - - boolean m_isSOTrx = "Y".equals(Env.getContext(Env.getCtx(), m_mField.getWindowNo(), "IsSOTrx")); - // PO only Rule - if (!m_onlyRule // Only order has Warehouse - && !m_isSOTrx && m_mTab.getValue("M_Warehouse_ID") != null) - m_onlyRule = true; - - m_button.setVisible(value && !m_onlyRule); - } - - private void setReadWrite0(boolean value) - { - boolean rw = value; - if (m_lookup == null) - rw = false; - if (m_combo.isReadWrite() != value) - { - m_combo.setReadWrite(rw); - setUI (false); - if (value) { - m_settingValue = true; // disable actions - refresh(); - m_settingValue = false; - } - setValue (m_value); - } - } - - @Override - public boolean isReadWrite() { - if (m_combo != null) - return m_combo.isReadWrite(); - return true; - } - - @Override - public void setMandatory(boolean mandatory) { - m_combo.setMandatory(mandatory); - } - - @Override - public boolean isMandatory() { - return m_combo.isMandatory(); - } - - @Override - public void setBackground(boolean error) { - m_combo.setBackground(error); - } - - @Override - public void requestFocus () - { - if (m_lookup != null) - m_combo.requestFocus (); - } - - /** - * Request Focus In Window - * @return focus request - */ - @Override - public boolean requestFocusInWindow() - { - return m_combo.requestFocusInWindow(); - } // requestFocusInWindow - - /** - * Get Focus Component - * @return component - */ - public Component getFocusableComponent() - { - return m_combo; - } // getFocusComponent - - @Override - public void setValue(Object value) { - if (log.isLoggable(Level.FINE)) log.fine(m_columnName + "=" + value); - m_settingValue = true; // disable actions - m_value = value; - - // Set both for switching - if (value == null) - { - m_combo.setValue (value); - m_lastDisplay = ""; - m_settingValue = false; - return; - } - if (m_lookup == null) - { - m_combo.setValue (value); - m_lastDisplay = value.toString(); - m_settingValue = false; - return; - } - - //must call m_combo.setvalue after m_lookup as - //loading of combo data might happen in m_lookup.getDisplay - m_lastDisplay = m_lookup.getDisplay(value); - m_combo.setValue (value); - - if (m_lastDisplay.equals("<-1>")) - { - m_lastDisplay = ""; - m_value = null; - } - boolean notFound = m_lastDisplay.startsWith("<") && m_lastDisplay.endsWith(">"); - - // Nothing showing in Combo and should be showing - if (m_combo.getSelectedItem() == null) - { - // lookup found nothing too - if (notFound) - { - if (log.isLoggable(Level.FINEST)) log.finest(m_columnName + "=" + value + ": Not found - " + m_lastDisplay); - // we may have a new value - m_lookup.refresh(); - m_combo.setValue (value); - m_lastDisplay = m_lookup.getDisplay(value); - notFound = m_lastDisplay.startsWith("<") && m_lastDisplay.endsWith(">"); - } - if (notFound && value instanceof Integer && m_lookup.getDisplayType() != DisplayType.ID) // for IDs is ok to be out of the list - { - m_value = null; - actionCombo (null); // data binding - if (log.isLoggable(Level.FINE)) log.fine(m_columnName + "=" + value + ": Not found"); - } - // we have lookup - else if (m_combo.getSelectedItem() == null) - { - NamePair pp = m_lookup.get(value); - if (pp != null) - { - if (log.isLoggable(Level.FINE)) log.fine(m_columnName + " added to combo - " + pp); - // Add to Combo - m_combo.addItem (pp); - m_combo.setValue (value); - } - } - // Not in Lookup - set to Null - if (m_combo.getSelectedItem() == null) - { - if (value instanceof Integer && m_lookup.getDisplayType() != DisplayType.ID) // for IDs is ok to be out of the list - { - if (log.isLoggable(Level.INFO)) log.info(m_columnName + "=" + value + ": not in Lookup - set to NULL"); - actionCombo (null); // data binding (calls setValue again) - m_value = null; - } - } - } - m_settingValue = false; - } - - @Override - public void propertyChange(PropertyChangeEvent evt) { - if (m_stopediting) - return; - - // log.fine( "VLookup.propertyChange", evt); - if (evt.getPropertyName().equals(GridField.PROPERTY)) - { - m_inserting = GridField.INSERTING.equals(evt.getOldValue()); // MField.setValue - setValue(evt.getNewValue()); - m_inserting = false; - } - } - - @Override - public Object getValue() { - return m_combo.getValue (); - } - - @Override - public String getDisplay() { - return m_combo.getDisplay(); - } - - @Override - public void setField(GridField mField) { - m_mField = mField; - } - - @Override - public GridField getField() { - return m_mField; - } - - @Override - public void actionPerformed(ActionEvent e) { - if (m_settingValue || m_settingFocus || m_stopediting) - return; - if (log.isLoggable(Level.CONFIG)) log.config(m_columnName + " - " + e.getActionCommand() + ", ComboValue=" + m_combo.getSelectedItem()); - - // Combo Selection - if (e.getSource() == m_combo) - { - Object value = getValue(); - Object o = m_combo.getSelectedItem(); - if (o != null) - { - String s = o.toString(); - // don't allow selection of inactive - if (s.startsWith(MLookup.INACTIVE_S) && s.endsWith(MLookup.INACTIVE_E)) - { - if (log.isLoggable(Level.INFO)) log.info(m_columnName + " - selection inactive set to NULL"); - value = null; - } - } - actionCombo (value); // data binding - } - // Button pressed - else if (e.getSource() == m_button) - actionButton (); - } - - @Override - public void addActionListener(ActionListener listener) { - m_combo.addActionListener(listener); - } - - private void actionCombo (Object value) - { - if (log.isLoggable(Level.FINE)) log.fine("Value=" + value); - try - { - // -> GridController.vetoableChange - fireVetoableChange (m_columnName, null, value); - } - catch (PropertyVetoException pve) - { - log.log(Level.SEVERE, m_columnName, pve); - } - // is the value updated ? - boolean updated = false; - - Object updatedValue = value; - - if (updatedValue instanceof Object[] && ((Object[])updatedValue).length > 0) - { - updatedValue = ((Object[])updatedValue)[0]; - } - - if (updatedValue == null && m_value == null) - updated = true; - else if (updatedValue != null && value.equals(m_value)) - updated = true; - if (!updated) - { - // happens if VLookup is used outside of APanel/GridController (no property listener) - if (log.isLoggable(Level.FINE)) log.fine(m_columnName + " - Value explicitly set - new=" + updatedValue + ", old=" + m_value); - - // phib: the following check causes the update to fail on jre > 1.6.0_13 - // commenting out as it does not appear to be necessary - //if (getListeners(PropertyChangeListener.class).length <= 0) - setValue(updatedValue); - } - } // actionCombo - - private void actionButton () - { - m_button.setEnabled(false); // disable double click - if (m_lookup == null) - return; // leave button disabled - m_combo.requestFocus(); // closes other editors - - int windowNo = m_lookup.getWindowNo(); - Object newValue = getValue(); - if (newValue != null) - { - IPaymentForm pf = VPaymentFormFactory.create(windowNo, getField().getGridTab(), (String) newValue); - if(pf != null) - { - VPaymentFormDialog dialog = (VPaymentFormDialog) pf.getWindow(); - if(dialog.isInitOK()) - { - dialog.setLocationRelativeTo(null); - pf.showWindow(); - pf.closeWindow(); - getField().getGridTab().dataRefresh(); - } - else - pf.closeWindow(); - } - } - - m_button.setEnabled(true); - m_combo.requestFocus(); - } // actionButton - - @Override - public void focusGained (FocusEvent e) - { - if (m_combo == null || m_combo.getEditor() == null) - return; - if ((e.getSource() != m_combo && e.getSource() != m_combo.getEditor().getEditorComponent()) - || e.isTemporary() || m_haveFocus || m_lookup == null) - return; - - //avoid repeated query - if (m_lookup.isValidated() && m_lookup.isLoaded()) - { - m_haveFocus = true; - return; - } - // - m_haveFocus = true; // prevents calling focus gained twice - m_settingFocus = true; // prevents actionPerformed - // - Object obj = m_lookup.getSelectedItem(); - if (log.isLoggable(Level.CONFIG)) log.config(m_columnName - + " - Start Count=" + m_combo.getItemCount() + ", Selected=" + obj); - // log.fine( "VLookupHash=" + this.hashCode()); - boolean popupVisible = m_combo.isPopupVisible(); - m_lookup.fillComboBox(isMandatory(), true, true, false, false); // only validated & active + IDEMPIERE 90 - if (popupVisible) - { - //refresh - m_combo.hidePopup(); - m_combo.showPopup(); - } - if (log.isLoggable(Level.CONFIG))log.config(m_columnName - + " - Update Count=" + m_combo.getItemCount() + ", Selected=" + m_lookup.getSelectedItem()); - m_lookup.setSelectedItem(obj); - if (log.isLoggable(Level.CONFIG))log.config(m_columnName - + " - Selected Count=" + m_combo.getItemCount() + ", Selected=" + m_lookup.getSelectedItem()); - // - m_settingFocus = false; - } // focusGained - - @Override - public void focusLost(FocusEvent e) - { - if (e.isTemporary() - || m_lookup == null - || !m_button.isEnabled() ) // set by actionButton - return; - // Combo lost focus - if (e.getSource() != m_combo && e.getSource() != m_combo.getEditor().getEditorComponent()) - return; - if (m_lookup.isValidated() && !m_lookup.hasInactive()) - { - m_haveFocus = false; - return; - } - // - m_settingFocus = true; // prevents actionPerformed - // - if (log.isLoggable(Level.CONFIG)) log.config(m_columnName + " = " + m_combo.getSelectedItem()); - Object obj = m_combo.getSelectedItem(); - /* - // set original model - if (!m_lookup.isValidated()) - m_lookup.fillComboBox(true); // previous selection - */ - // Set value - if (obj != null) - { - m_combo.setSelectedItem(obj); - // original model may not have item - if (!m_combo.getSelectedItem().equals(obj)) - { - if (log.isLoggable(Level.FINE)) log.fine(m_columnName + " - added to combo - " + obj); - m_combo.addItem(obj); - m_combo.setSelectedItem(obj); - } - } - // actionCombo(getValue()); - m_settingFocus = false; - m_haveFocus = false; // can gain focus again - } // focusLost - - public void setToolTipText(String text) - { - super.setToolTipText(text); - m_button.setToolTipText(text); - m_combo.setToolTipText(text); - } - - public int refresh() - { - if (m_lookup == null) - return -1; - - //no need to refresh readonly lookup, just remove direct cache - if (!isReadWrite()) { - m_lookup.removeAllElements(); - return 0; - } - - return m_lookup.refresh(); - } // refresh - - public void setStopEditing(boolean stopediting) { - m_stopediting = stopediting; - } -} diff --git a/org.adempiere.ui.swing/src/org/compiere/grid/ed/VPostIt.java b/org.adempiere.ui.swing/src/org/compiere/grid/ed/VPostIt.java deleted file mode 100644 index b3b55171d3..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/grid/ed/VPostIt.java +++ /dev/null @@ -1,325 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ -package org.compiere.grid.ed; - -import java.awt.BorderLayout; -import java.awt.Dimension; -import java.awt.Frame; -import java.awt.Toolkit; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.awt.event.KeyEvent; -import java.awt.event.KeyListener; -import java.io.BufferedWriter; -import java.io.FileInputStream; -import java.io.FileOutputStream; -import java.io.InputStreamReader; -import java.io.OutputStreamWriter; -import java.io.UnsupportedEncodingException; -import java.util.logging.Level; - -import javax.swing.JDialog; -import javax.swing.JFileChooser; -import javax.swing.JMenu; -import javax.swing.JMenuBar; -import javax.swing.JSplitPane; -import javax.swing.JTabbedPane; -import javax.swing.event.ChangeEvent; -import javax.swing.event.ChangeListener; - -import org.adempiere.plaf.AdempierePLAF; -import org.compiere.apps.AEnv; -import org.compiere.apps.ConfirmPanel; -import org.compiere.apps.StatusBar; -import org.compiere.model.MPostIt; -import org.compiere.swing.CDialog; -import org.compiere.swing.CMenuItem; -import org.compiere.swing.CPanel; -import org.compiere.swing.CTextArea; -import org.compiere.swing.CTextPane; -import org.compiere.util.CLogger; -import org.compiere.util.Env; -import org.compiere.util.Msg; - -/** - * Post-it, basïżœ sur Editor - * - * @author Nico - */ -public class VPostIt extends CDialog implements ChangeListener, ActionListener, KeyListener -{ - private static final long serialVersionUID = -8314686583942866712L; - - /** - * Standard constructor - * @param frame parent - * @param header heading - * @param postItID - * @param tableID - * @param recordID - * @param trxName - */ - public VPostIt(Frame frame, String header, int postItID, int tableID, int recordID, String trxName) - { - super (frame, header, frame != null); - try - { - jbInit(); - setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE); - } - catch(Exception ex) - { - log.log(Level.SEVERE, "", ex); - } - - if (postItID > 0) - m_postIt = new MPostIt (Env.getCtx(), postItID, trxName); - else - m_postIt = new MPostIt (Env.getCtx(), tableID, recordID, trxName); - - // Set Text - textArea.setText(m_postIt.getText()); - textArea.setEditable(true); - textArea.setBackground(AdempierePLAF.getFieldBackground_Normal()); - textPane.setBackground(AdempierePLAF.getFieldBackground_Inactive()); - - String createdupdated = null; - if (m_postIt.getAD_PostIt_ID() > 0) - createdupdated = m_postIt.getCreatedString(); - String updated = m_postIt.getUpdatedString(); - - if (!updated.equals("")) - createdupdated += "\n" + updated; - - modifText.setText(createdupdated); - modifText.setReadWrite(false); - - updateStatusBar(); - - try - { - AEnv.showCenterWindow(frame, this); - } - catch (Exception e) - { - } - modifText.requestFocus(); - } // Editor - - /** Maximum Size */ - private int m_maxSize = 2000; - /** Logger */ - private static CLogger log = CLogger.getCLogger(VPostIt.class); - - private CPanel panel = new CPanel(); - private BorderLayout panelLayout = new BorderLayout(); - private JTabbedPane tabbedPane = new JTabbedPane(); - private CTextArea textArea = new CTextArea(); - private CTextPane textPane = new CTextPane(); - private JMenuBar menuBar = new JMenuBar(); - private JMenu mFile = new JMenu(); - private CMenuItem mImport = new CMenuItem(); - private CMenuItem mExport = new CMenuItem(); - private ConfirmPanel confirmPanel = new ConfirmPanel(); - private StatusBar statusBar = new StatusBar(false); - private CTextArea modifText = new CTextArea(); - private MPostIt m_postIt = null; - - /** - * Static Init - * @throws Exception - */ - private void jbInit() throws Exception - { - panel.setLayout(panelLayout); - this.setJMenuBar(menuBar); - // Text Tab - textArea.setPreferredSize(new Dimension(500, 300)); - textArea.setWrapStyleWord(true); - textArea.setLineWrap(true); - tabbedPane.add(textArea, "Text"); - textArea.addKeyListener(this); - // HTML Tab - textPane.setContentType("text/html"); - textPane.setEditable(false); - tabbedPane.add(textPane, "HTML"); - // - // Traduction de File ïżœ partir du message File ; cf org.compiere.apps.AEnv.getMenu(String) - String textFile = Msg.getMsg(Env.getCtx(), "File"); - int pos = textFile.indexOf('&'); - if (pos != -1 && textFile.length() > pos) // We have a nemonic - { - char ch = textFile.toUpperCase().charAt(pos+1); - if (ch != ' ') - textFile = textFile.substring(0, pos) + textFile.substring(pos+1); - } - mFile.setText(textFile); - mImport.setText(Msg.getMsg(Env.getCtx(), "Import")); - mImport.addActionListener(this); - mExport.setText(Msg.getMsg(Env.getCtx(), "Export")); - mExport.addActionListener(this); - tabbedPane.addChangeListener(this); - - modifText.setPreferredSize(new Dimension(500,50)); - JSplitPane textPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, true, tabbedPane, modifText); - panel.add(textPane, BorderLayout.CENTER); - - confirmPanel.addActionListener(this); - panel.add(confirmPanel, BorderLayout.SOUTH); - this.getContentPane().add(panel, BorderLayout.CENTER); - this.getContentPane().add(statusBar, BorderLayout.SOUTH); - // - menuBar.add(mFile); - mFile.add(mImport); - mFile.add(mExport); - updateStatusBar(); - } // jbInit - - /** - * ActionListener - * @param e event - */ - public void actionPerformed(ActionEvent e) - { - if (e.getActionCommand().equals(ConfirmPanel.A_OK)) - { - m_postIt.setText(textArea.getText()); - m_postIt.saveEx(); - log.fine("OK - length=" + textArea.getText().length()); - dispose(); - } - else if (e.getActionCommand().equals(ConfirmPanel.A_CANCEL)) - dispose(); - else if (e.getSource() == mImport) - importText(); - else if (e.getSource() == mExport) - exportText(); - } // actionPerformed - - /** - * Update Status Bar - */ - private void updateStatusBar() - { - String str = textArea.getText(); - int length = str.length(); - statusBar.setStatusDB(length); - int size = length; - try - { - size = str.getBytes("UTF-8").length; - } - catch (UnsupportedEncodingException e) - { - log.log(Level.SEVERE, str, e); - } - - if (m_maxSize == 0) - statusBar.setStatusLine(String.valueOf(size)); - else if (size < m_maxSize) - statusBar.setStatusLine(size + " < " + m_maxSize, false); - else if (size == m_maxSize) - statusBar.setStatusLine(size + " = " + m_maxSize, false); - else - { - statusBar.setStatusLine(size + " > " + m_maxSize, true); - Toolkit.getDefaultToolkit().beep(); - } - } // updateStatusBar - - /** - * Import Text from File - */ - private void importText() - { - JFileChooser jc = new JFileChooser(); - jc.setDialogTitle(Msg.getMsg(Env.getCtx(), "ImportText")); - jc.setDialogType(JFileChooser.OPEN_DIALOG); - jc.setFileSelectionMode(JFileChooser.FILES_ONLY); - // - if (jc.showOpenDialog(this) != JFileChooser.APPROVE_OPTION) - return; - - StringBuffer sb = new StringBuffer(); - try - { - InputStreamReader in = new InputStreamReader (new FileInputStream (jc.getSelectedFile())); - char[] cbuf = new char[1024]; - int count; - while ((count = in.read(cbuf)) > 0) - sb.append(cbuf, 0, count); - in.close(); - } - catch (Exception e) - { - log.log(Level.WARNING, e.getMessage()); - return; - } - textArea.setText(sb.toString()); - updateStatusBar(); - } // importText - - /** - * Export Text to File - */ - private void exportText() - { - JFileChooser jc = new JFileChooser(); - jc.setDialogTitle(Msg.getMsg(Env.getCtx(), "ExportText")); - jc.setDialogType(JFileChooser.SAVE_DIALOG); - jc.setFileSelectionMode(JFileChooser.FILES_ONLY); - // - if (jc.showSaveDialog(this) != JFileChooser.APPROVE_OPTION) - return; - - try - { - BufferedWriter bout = new BufferedWriter (new OutputStreamWriter (new FileOutputStream (jc.getSelectedFile()))); - bout.write(textArea.getText()); - bout.flush(); - bout.close(); - } - catch (Exception e) - { - log.log(Level.WARNING, e.getMessage()); - } - } // exportText - - /** - * ChangeListener for TabbedPane - * @param e event - */ - public void stateChanged(ChangeEvent e) - { - if (tabbedPane.getSelectedIndex() == 1) // switch to HTML - textPane.setText(textArea.getText()); - } // stateChanged - - public void keyTyped (KeyEvent e) - { - } - - public void keyPressed (KeyEvent e) - { - } - - public void keyReleased (KeyEvent e) - { - updateStatusBar(); - } - -} // VPostIt \ No newline at end of file diff --git a/org.adempiere.ui.swing/src/org/compiere/grid/ed/VRowIDEditor.java b/org.adempiere.ui.swing/src/org/compiere/grid/ed/VRowIDEditor.java deleted file mode 100644 index ab294f3f57..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/grid/ed/VRowIDEditor.java +++ /dev/null @@ -1,124 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ -package org.compiere.grid.ed; - -import java.awt.Component; -import java.awt.Insets; -import java.util.EventObject; -import java.util.logging.Level; - -import javax.swing.AbstractCellEditor; -import javax.swing.JCheckBox; -import javax.swing.JLabel; -import javax.swing.JTable; -import javax.swing.table.TableCellEditor; - -import org.compiere.util.CLogger; - -/** - * RowID Cell Editor providing Selection - * - * @author Jorg Janke - * @version $Id: VRowIDEditor.java,v 1.2 2006/07/30 00:51:28 jjanke Exp $ - */ -public class VRowIDEditor extends AbstractCellEditor implements TableCellEditor -{ - /** - * - */ - private static final long serialVersionUID = -787968703981149591L; - - /** - * Constructor - */ - public VRowIDEditor(boolean select) - { - super(); - m_select = select; - m_cb.setMargin(new Insets(0,0,0,0)); - m_cb.setHorizontalAlignment(JLabel.CENTER); - } // VRowIDEditor - - private JCheckBox m_cb = new JCheckBox(); - private Object[] m_rid; - private boolean m_select; - /** Logger */ - private static CLogger log = CLogger.getCLogger(VRowIDEditor.class); - - /** - * Enable Selection to be displayed - */ - public void setEnableSelection(boolean showSelection) - { - m_select = showSelection; - } // setEnableSelection - - /** - * Ask the editor if it can start editing using anEvent. - * This method is intended for the use of client to avoid the cost of - * setting up and installing the editor component if editing is not possible. - * If editing can be started this method returns true - */ - public boolean isCellEditable(EventObject anEvent) - { - return m_select; - } // isCellEditable - - /** - * Sets an initial value for the editor. This will cause the editor to - * stopEditing and lose any partially edited value if the editor is editing - * when this method is called. - * Returns the component that should be added to the client's Component hierarchy. - * Once installed in the client's hierarchy this component - * will then be able to draw and receive user input. - */ - public Component getTableCellEditorComponent(JTable table, - Object value, boolean isSelected, int row, int col) - { - if (log.isLoggable(Level.FINE)) log.fine("Value=" + value + ", row=" + row + ", col=" + col); - m_rid = (Object[])value; - if (m_rid == null || m_rid[1] == null) - m_cb.setSelected(false); - else - { - Boolean sel = (Boolean)m_rid[1]; - m_cb.setSelected(sel.booleanValue()); - } - return m_cb; - } // getTableCellEditorComponent - - /** - * The editing cell should be selected or not - */ - public boolean shouldSelectCell(EventObject anEvent) - { - return m_select; - } // shouldSelectCell - - /** - * Returns the value contained in the editor - */ - public Object getCellEditorValue() - { - if (log.isLoggable(Level.FINE)) log.fine("" + m_cb.isSelected()); - if (m_rid == null) - return null; - m_rid[1] = Boolean.valueOf(m_cb.isSelected()); - return m_rid; - } // getCellEditorValue - -} // VRowIDEditor diff --git a/org.adempiere.ui.swing/src/org/compiere/grid/ed/VRowIDRenderer.java b/org.adempiere.ui.swing/src/org/compiere/grid/ed/VRowIDRenderer.java deleted file mode 100644 index 847275b666..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/grid/ed/VRowIDRenderer.java +++ /dev/null @@ -1,78 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ -package org.compiere.grid.ed; - -import java.awt.Component; - -import javax.swing.JButton; -import javax.swing.JCheckBox; -import javax.swing.JTable; -import javax.swing.table.TableCellRenderer; - -/** - * Renderer for RowID Column - * - * @author Jorg Janke - * @version $Id: VRowIDRenderer.java,v 1.2 2006/07/30 00:51:28 jjanke Exp $ - */ -public final class VRowIDRenderer implements TableCellRenderer -{ - /** - * Constructor - */ - public VRowIDRenderer(boolean enableSelection) - { - m_select = enableSelection; - } // VRowIDRenderer - - private boolean m_select = false; - private JButton m_button = new JButton(); - private JCheckBox m_check = null; - - /** - * Enable Selection to be displayed - */ - public void setEnableSelection(boolean showSelection) - { - m_select = showSelection; - } // setEnableSelection - - /** - * Return TableCell Renderer Component - */ - public Component getTableCellRendererComponent(JTable table, Object value, - boolean isSelected, boolean hasFocus, int row, int column) - { - if (m_select) - { - if (m_check == null) - m_check = new JCheckBox(); - Object[] data = (Object[])value; - if (data == null || data[1] == null) - m_check.setSelected(false); - else - { - Boolean sel = (Boolean)data[1]; - m_check.setSelected(sel.booleanValue()); - } - return m_check; - } - else - return m_button; - } // getTableCellRenderereComponent - -} // VRowIDRenderer diff --git a/org.adempiere.ui.swing/src/org/compiere/grid/ed/VString.java b/org.adempiere.ui.swing/src/org/compiere/grid/ed/VString.java deleted file mode 100644 index 16d1f5a1e8..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/grid/ed/VString.java +++ /dev/null @@ -1,440 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ -package org.compiere.grid.ed; - -import java.awt.Color; -import java.awt.Component; -import java.awt.Font; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.awt.event.FocusEvent; -import java.awt.event.FocusListener; -import java.awt.event.KeyEvent; -import java.awt.event.MouseAdapter; -import java.awt.event.MouseEvent; -import java.beans.PropertyChangeEvent; -import java.beans.PropertyVetoException; -import java.util.logging.Level; - -import javax.swing.JPopupMenu; -import javax.swing.SwingUtilities; -import javax.swing.event.CaretListener; - -import org.adempiere.plaf.AdempierePLAF; -import org.compiere.apps.FieldRecordInfo; -import org.compiere.model.GridField; -import org.compiere.model.MRole; -import org.compiere.model.Obscure; -import org.compiere.swing.CMenuItem; -import org.compiere.swing.CTextField; -import org.compiere.util.CLogger; -import org.compiere.util.Env; -import org.compiere.util.Msg; - -/** - * Data Binding: - * VEditors call fireVetoableChange(m_columnName, null, getText()); - * GridController (for Single-Row) and VCellExitor (for Multi-Row) - * listen to Vetoable Change Listener (vetoableChange) - * then set the value for that column in the current row in the table - * - * @author Jorg Janke - * @version $Id: VString.java,v 1.2 2006/07/30 00:51:27 jjanke Exp $ - */ -public final class VString extends CTextField - implements VEditor, ActionListener, FocusListener -{ - /** - * - */ - private static final long serialVersionUID = 4537820279343591025L; - - /** Max Display Length - 60 */ - public static final int MAXDISPLAY_LENGTH = org.compiere.model.GridField.MAXDISPLAY_LENGTH; - - /****************************************************************************** - * Mouse Listener - */ - final class VString_mouseAdapter extends MouseAdapter - { - /** - * Constructor - * @param adaptee adaptee - */ - VString_mouseAdapter(VString adaptee) - { - m_adaptee = adaptee; - } // VString_mouseAdapter - - private VString m_adaptee; - - /** - * Mouse Listener - * @param e event - */ - public void mouseClicked(MouseEvent e) - { - // popup menu - if (SwingUtilities.isRightMouseButton(e)) - m_adaptee.popupMenu.show((Component)e.getSource(), e.getX(), e.getY()); - } // mouseClicked - - } // VText_mouseAdapter - - /** - * IDE Bean Constructor for 30 character updateable field - */ - public VString() - { - this("String", false, false, true, 30, 30, "", null); - } // VString - - /** - * Detail Constructor - * @param columnName column name - * @param mandatory mandatory - * @param isReadOnly read only - * @param isUpdateable updateable - * @param displayLength display length - * @param fieldLength field length - * @param VFormat format - * @param ObscureType obscure type - */ - public VString (String columnName, boolean mandatory, boolean isReadOnly, boolean isUpdateable, - int displayLength, int fieldLength, String VFormat, String ObscureType) - { - super(displayLength>MAXDISPLAY_LENGTH ? MAXDISPLAY_LENGTH : displayLength); - super.setName(columnName); - m_columnName = columnName; - if (VFormat == null) - VFormat = ""; - m_VFormat = VFormat; - m_fieldLength = fieldLength; - if (m_VFormat.length() != 0 || m_fieldLength != 0) - setDocument(new MDocString(m_VFormat, m_fieldLength, this)); - if (m_VFormat.length() != 0) - setCaret(new VOvrCaret()); - // - setMandatory(mandatory); - if (ObscureType != null && ObscureType.length() > 0) - { - m_obscure = new Obscure ("", ObscureType); - m_stdFont = getFont(); - m_obscureFont = new Font("SansSerif", Font.ITALIC, m_stdFont.getSize()); - } - - // Editable - if (isReadOnly || !isUpdateable) - { - setEditable(false); - setBackground(AdempierePLAF.getFieldBackground_Inactive()); - } - - this.addKeyListener(this); - this.addActionListener(this); - this.addFocusListener(this); - addMouseListener(new VString_mouseAdapter(this)); - // Popup for Editor - if (fieldLength > displayLength) - { - mEditor = new CMenuItem (Msg.getMsg(Env.getCtx(), "Editor"), Env.getImageIcon("Editor16.gif")); - mEditor.addActionListener(this); - popupMenu.add(mEditor); - } - setForeground(AdempierePLAF.getTextColor_Normal()); - setBackground(AdempierePLAF.getFieldBackground_Normal()); - } // VString - - /** - * Dispose - */ - public void dispose() - { - m_mField = null; - } // dispose - - /** Popup Menu */ - JPopupMenu popupMenu = new JPopupMenu(); - /** Editor Menu Item */ - private CMenuItem mEditor; - /** Grid Field */ - private GridField m_mField = null; - /** Column Name */ - private String m_columnName; - private String m_oldText; - private String m_initialText; - private String m_VFormat; - /** Field Length */ - private int m_fieldLength; - /** Obcure Setting */ - private Obscure m_obscure = null; - private Font m_stdFont = null; - private Font m_obscureFont = null; - /** Setting new value */ - private volatile boolean m_setting = false; - /** Field in focus */ - private volatile boolean m_infocus = false; - - /** Logger */ - private static CLogger log = CLogger.getCLogger (VString.class); - - /** - * Set Editor to value - * @param value value - */ - public void setValue(Object value) - { - // log.config( "VString.setValue", value); - if (value == null) - m_oldText = ""; - else - m_oldText = value.toString(); - // only set when not updated here - if (m_setting) - return; - setText (m_oldText); - m_initialText = m_oldText; - // If R/O left justify - if (!isEditable() || !isEnabled()) - setCaretPosition(0); - } // setValue - - /** - * Property Change Listener - * @param evt event - */ - public void propertyChange (PropertyChangeEvent evt) - { - if (evt.getPropertyName().equals(org.compiere.model.GridField.PROPERTY)) - setValue(evt.getNewValue()); - } // propertyChange - - /** - * Return Editor value - * @return value - */ - public Object getValue() - { - return getText(); - } // getValue - - /** - * Return Display Value - * @return value - */ - public String getDisplay() - { - return super.getText(); // optionally obscured - } // getDisplay - - - /** - * Key Released. - * if Escape Restore old Text - * @param e event - */ - public void keyReleased(KeyEvent e) - { - if (log.isLoggable(Level.FINEST)) log.finest("Key=" + e.getKeyCode() + " - " + e.getKeyChar() - + " -> " + getText()); - // ESC - if (e.getKeyCode() == KeyEvent.VK_ESCAPE) - setText(m_initialText); - } // keyReleased - - /** - * Data Binding to MTable (via GridController) - Enter pressed - * @param e event - */ - public void actionPerformed(ActionEvent e) - { - if (e.getActionCommand().equals(ValuePreference.NAME)) - { - if (MRole.getDefault().isShowPreference() && !m_mField.isEncrypted() && !m_mField.isEncryptedColumn()) - ValuePreference.start (m_mField, getValue()); - return; - } - else if(e.getActionCommand().equals(FieldRecordInfo.CHANGE_LOG_COMMAND)) - { - FieldRecordInfo.start(m_mField); - return; - } - - // Invoke Editor - if (e.getSource() == mEditor) - { - String s = Editor.startEditor(this, Msg.translate(Env.getCtx(), m_columnName), - getText(), isEditable(), m_fieldLength); - setText(s); - } - // Data Binding - try - { - fireVetoableChange(m_columnName, m_oldText, getText()); - } - catch (PropertyVetoException pve) - { - } - } // actionPerformed - - /** - * Set Field/WindowNo for ValuePreference - * @param mField field - */ - public void setField (GridField mField) - { - m_mField = mField; - if (m_mField != null - && MRole.getDefault().isShowPreference() - && !mField.isEncrypted() && !mField.isEncryptedColumn()) - ValuePreference.addMenu (this, popupMenu); - if (m_mField != null) - FieldRecordInfo.addMenu(this, popupMenu); - } // setField - - @Override - public GridField getField() { - return m_mField; - } - - /** - * Feature Request [1707462] - * Set VFormat - * @param strMask mask - * @author fer_luck - */ - public void setVFormat (String strMask) - { - m_VFormat = strMask; - //Get the actual caret from the field, if there's no - //caret then just catch the exception and continue - //creating the new caret. - try{ - CaretListener [] cl = this.getCaretListeners(); - this.removeCaretListener(cl[0]); - } catch(ClassCastException ex ){ - log.fine("VString.setVFormat - No caret Listeners"); - } - - //hengsin: [ adempiere-Bugs-1891037 ], preserve current data before change of format - String s = getText(); - setDocument(new MDocString(m_VFormat, m_fieldLength, this)); - setText(s); - } // setVFormat - - /** - * Set Text (optionally obscured) - * @param text text - */ - public void setText (String text) - { - if (m_obscure != null && !m_infocus) - { - super.setFont(m_obscureFont); - super.setText (m_obscure.getObscuredValue(text)); - super.setForeground(Color.gray); - } - else - { - if (m_stdFont != null) - { - super.setFont(m_stdFont); - super.setForeground(AdempierePLAF.getTextColor_Normal()); - } - super.setText (text); - } - } // setText - - - /** - * Get Text (clear) - * @return text - */ - public String getText () - { - String text = super.getText(); - if (m_obscure != null && text != null && text.length() > 0) - { - if (isReadWrite() && text.equals(m_obscure.getObscuredValue())) - text = m_obscure.getClearValue(); - } - return text; - } // getText - - /** - * Feature Request [1707462] - * Get VFormat - * @return strMask mask - * @author fer_luck - */ - public String getVFormat () - { - return this.m_VFormat; - } // getVFormat - - /** - * Focus Gained. - * Enabled with Obscure - * @param e event - */ - public void focusGained (FocusEvent e) - { - m_infocus = true; - setText(getText()); // clear - } // focusGained - - /** - * Focus Lost - * Enabled with Obscure - * @param e event - */ - public void focusLost (FocusEvent e) - { - m_setting = true; - try - { - String clear = getText(); - if (clear.length() > m_fieldLength) - clear = clear.substring(0, m_fieldLength); - fireVetoableChange (m_columnName, m_oldText, clear); - } - catch (PropertyVetoException pve) - { - } - m_setting = false; - - m_infocus = false; - setText(getText()); // obscure - } // focus Lost - - @Override - public void setFont(Font f) { - super.setFont(f); - m_stdFont = f; - m_obscureFont = new Font("SansSerif", Font.ITALIC, m_stdFont.getSize()); - } - - /** - * Get Focus Component - * @return component - */ - public Component getFocusableComponent() - { - return this; - } // getFocusableComponent - -} // VString \ No newline at end of file diff --git a/org.adempiere.ui.swing/src/org/compiere/grid/ed/VStringBeanInfo.java b/org.adempiere.ui.swing/src/org/compiere/grid/ed/VStringBeanInfo.java deleted file mode 100644 index 236a62f2b5..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/grid/ed/VStringBeanInfo.java +++ /dev/null @@ -1,96 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ -package org.compiere.grid.ed; - -import java.beans.BeanInfo; -import java.beans.IntrospectionException; -import java.beans.Introspector; -import java.beans.PropertyDescriptor; -import java.beans.SimpleBeanInfo; - -/** - * Generated - * - * @author Jorg Janke - * @version $Id: VStringBeanInfo.java,v 1.2 2006/07/30 00:51:28 jjanke Exp $ - */ - -public class VStringBeanInfo extends SimpleBeanInfo -{ - private Class beanClass = VString.class; - private String iconColor16x16Filename; - private String iconColor32x32Filename; - private String iconMono16x16Filename; - private String iconMono32x32Filename; - - public VStringBeanInfo() - { - } - public PropertyDescriptor[] getPropertyDescriptors() - { - try - { - PropertyDescriptor _display = new PropertyDescriptor("display", beanClass, "getDisplay", null); - PropertyDescriptor _editable = new PropertyDescriptor("editable", beanClass, null, "setEditable"); - PropertyDescriptor _mandatory = new PropertyDescriptor("mandatory", beanClass, "isMandatory", "setMandatory"); - PropertyDescriptor _value = new PropertyDescriptor("value", beanClass, "getValue", "setValue"); - PropertyDescriptor[] pds = new PropertyDescriptor[] { - _display, - _editable, - _mandatory, - _value}; - return pds; - - - - -} - catch(IntrospectionException ex) - { - ex.printStackTrace(); - return null; - } - } - public java.awt.Image getIcon(int iconKind) - { - switch (iconKind) { - case BeanInfo.ICON_COLOR_16x16: - return iconColor16x16Filename != null ? loadImage(iconColor16x16Filename) : null; - case BeanInfo.ICON_COLOR_32x32: - return iconColor32x32Filename != null ? loadImage(iconColor32x32Filename) : null; - case BeanInfo.ICON_MONO_16x16: - return iconMono16x16Filename != null ? loadImage(iconMono16x16Filename) : null; - case BeanInfo.ICON_MONO_32x32: - return iconMono32x32Filename != null ? loadImage(iconMono32x32Filename) : null; - } - return null; - } - public BeanInfo[] getAdditionalBeanInfo() - { - Class superclass = beanClass.getSuperclass(); - try - { - BeanInfo superBeanInfo = Introspector.getBeanInfo(superclass); - return new BeanInfo[] { superBeanInfo }; - } - catch(IntrospectionException ex) - { - ex.printStackTrace(); - return null; - } - } -} diff --git a/org.adempiere.ui.swing/src/org/compiere/grid/ed/VText.java b/org.adempiere.ui.swing/src/org/compiere/grid/ed/VText.java deleted file mode 100644 index 9f4f568378..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/grid/ed/VText.java +++ /dev/null @@ -1,281 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ -package org.compiere.grid.ed; - -import java.awt.Component; -import java.awt.Container; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.awt.event.FocusEvent; -import java.awt.event.FocusListener; -import java.awt.event.KeyEvent; -import java.awt.event.KeyListener; -import java.awt.event.MouseAdapter; -import java.awt.event.MouseEvent; -import java.beans.PropertyChangeEvent; -import java.beans.PropertyVetoException; - -import javax.swing.JPopupMenu; -import javax.swing.LookAndFeel; -import javax.swing.SwingUtilities; - -import org.adempiere.plaf.AdempierePLAF; -import org.compiere.apps.AEnv; -import org.compiere.apps.FieldRecordInfo; -import org.compiere.apps.ScriptEditor; -import org.compiere.model.GridField; -import org.compiere.swing.CMenuItem; -import org.compiere.swing.CTextArea; -import org.compiere.util.Env; -import org.compiere.util.Msg; - -/** - * Text Control (JTextArea embedded in JScrollPane) - * - * @author Jorg Janke - * @version $Id: VText.java,v 1.2 2006/07/30 00:51:28 jjanke Exp $ - */ -public class VText extends CTextArea - implements VEditor, KeyListener, ActionListener, FocusListener -{ - - /** - * - */ - private static final long serialVersionUID = 189322325798427286L; - - /** - * Mouse Listener - */ - final class VText_mouseAdapter extends MouseAdapter - { - /** - * Constructor - * @param adaptee VText - */ - VText_mouseAdapter(VText adaptee) - { - this.adaptee = adaptee; - } // VText_mouseAdapter - - private VText adaptee; - - /** - * Mouse Listener - * @param e event - */ - public void mouseClicked(MouseEvent e) - { - // popup menu - if (SwingUtilities.isRightMouseButton(e)) - adaptee.popupMenu.show((Component)e.getSource(), e.getX(), e.getY()); - } // mouse Clicked - - } // VText_mouseAdapter - - /** - * Standard Constructor - * @param columnName column name - * @param mandatory mandatory - * @param isReadOnly read only - * @param isUpdateable updateable - * @param displayLength display length - * @param fieldLength field length - */ - public VText (String columnName, boolean mandatory, boolean isReadOnly, boolean isUpdateable, - int displayLength, int fieldLength) - { - super (fieldLength < 300 ? 2 : 3, 50); - super.setName(columnName); - LookAndFeel.installBorder(this, "TextField.border"); - - // Create Editor - setColumns(displayLength>VString.MAXDISPLAY_LENGTH ? VString.MAXDISPLAY_LENGTH : displayLength); // 46 - setForeground(AdempierePLAF.getTextColor_Normal()); - setBackground(AdempierePLAF.getFieldBackground_Normal()); - - setLineWrap(true); - setWrapStyleWord(true); - setMandatory(mandatory); - m_columnName = columnName; - m_fieldLength = fieldLength; - - if (isReadOnly || !isUpdateable) - setReadWrite(false); - addKeyListener(this); - addFocusListener(this); - - // Popup - addMouseListener(new VText_mouseAdapter(this)); - if (columnName.equals("Script")) - menuEditor = new CMenuItem(Msg.getMsg(Env.getCtx(), "Script"), Env.getImageIcon("Script16.gif")); - else - menuEditor = new CMenuItem(Msg.getMsg(Env.getCtx(), "Editor"), Env.getImageIcon("Editor16.gif")); - menuEditor.addActionListener(this); - popupMenu.add(menuEditor); - } // VText - - /** - * Dispose - */ - public void dispose() - { - } // dispose - - JPopupMenu popupMenu = new JPopupMenu(); - private CMenuItem menuEditor; - private int m_fieldLength; - private String m_columnName; - private String m_oldText; - private String m_initialText; - private volatile boolean m_setting = false; - private GridField m_mField; - - /** - * Set Editor to value - * @param value value - */ - public void setValue(Object value) - { - if (value == null) - m_oldText = ""; - else - m_oldText = value.toString(); - if (m_setting) - return; - super.setValue(m_oldText); - m_initialText = m_oldText; - // Always position Top - setCaretPosition(0); - } // setValue - - /** - * Property Change Listener - * @param evt event - */ - public void propertyChange (PropertyChangeEvent evt) - { - if (evt.getPropertyName().equals(org.compiere.model.GridField.PROPERTY)) - setValue(evt.getNewValue()); - } // propertyChange - - /** - * ActionListener - * @param e event - */ - public void actionPerformed(ActionEvent e) - { - if (e.getSource() == menuEditor) - { - menuEditor.setEnabled(false); - String s = null; - if (m_columnName.equals("Script") || m_columnName.endsWith("_Script")) - s = ScriptEditor.start ( - AEnv.getFrame(this.getParent()), - Msg.translate(Env.getCtx(), m_columnName), getText(), isEditable(), - findWindowNo()); - else - s = Editor.startEditor (this, Msg.translate(Env.getCtx(), m_columnName), - getText(), isEditable(), m_fieldLength); - menuEditor.setEnabled(true); - // Data Binding - try - { - fireVetoableChange(m_columnName, m_oldText, s); - } - catch (PropertyVetoException pve) {} - } - else if (e.getActionCommand().equals(FieldRecordInfo.CHANGE_LOG_COMMAND)) - { - FieldRecordInfo.start(m_mField); - return; - } - } // actionPerformed - - private int findWindowNo() { - Container c = this.getParent(); - return c != null ? AEnv.getWindowNo(c) : 0; - } - - /** - * Action Listener Interface - NOP - * @param listener listener - */ - public void addActionListener(ActionListener listener) - { - } // addActionListener - - /************************************************************************** - * Key Listener Interface - * @param e event - */ - public void keyTyped(KeyEvent e) {} - public void keyPressed(KeyEvent e) {} - - /** - * Key Released - * if Escape restore old Text. - * @param e event - */ - public void keyReleased(KeyEvent e) - { - // ESC - if (e.getKeyCode() == KeyEvent.VK_ESCAPE) - setText(m_initialText); - } // keyReleased - - /** - * Set Field/WindowNo for ValuePreference (NOP) - * @param mField field model - */ - public void setField (org.compiere.model.GridField mField) - { - m_mField = mField; - if (m_mField != null) - FieldRecordInfo.addMenu(this, popupMenu); - } // setField - - @Override - public GridField getField() { - return m_mField; - } - - @Override - public void focusGained(FocusEvent e) { - } - - @Override - public void focusLost(FocusEvent e) { - m_setting = true; - try - { - fireVetoableChange(m_columnName, m_oldText, getText()); - } - catch (PropertyVetoException pve) {} - m_setting = false; - } - - /** - * Get Focus Component - * @return component - */ - public Component getFocusableComponent() - { - return this; - } // getFocusableComponent - -} // VText diff --git a/org.adempiere.ui.swing/src/org/compiere/grid/ed/VTextBeanInfo.java b/org.adempiere.ui.swing/src/org/compiere/grid/ed/VTextBeanInfo.java deleted file mode 100644 index ce34170e37..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/grid/ed/VTextBeanInfo.java +++ /dev/null @@ -1,108 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ -package org.compiere.grid.ed; - -import java.beans.BeanInfo; -import java.beans.IntrospectionException; -import java.beans.Introspector; -import java.beans.PropertyDescriptor; -import java.beans.SimpleBeanInfo; - -/** - * Generated - * - * @author Jorg Janke - * @version $Id: VTextBeanInfo.java,v 1.2 2006/07/30 00:51:28 jjanke Exp $ - */ - -public class VTextBeanInfo extends SimpleBeanInfo -{ - private Class beanClass = VText.class; - private String iconColor16x16Filename; - private String iconColor32x32Filename; - private String iconMono16x16Filename; - private String iconMono32x32Filename; - - public VTextBeanInfo() - { - } - public PropertyDescriptor[] getPropertyDescriptors() - { - try - { - PropertyDescriptor _background = new PropertyDescriptor("background", beanClass, null, "setBackground"); - PropertyDescriptor _border = new PropertyDescriptor("border", beanClass, null, "setBorder"); - PropertyDescriptor _display = new PropertyDescriptor("display", beanClass, "getDisplay", null); - PropertyDescriptor _editable = new PropertyDescriptor("editable", beanClass, "isEditable", "setEditable"); - PropertyDescriptor _font = new PropertyDescriptor("font", beanClass, null, "setFont"); - PropertyDescriptor _foreground = new PropertyDescriptor("foreground", beanClass, null, "setForeground"); - PropertyDescriptor _mandatory = new PropertyDescriptor("mandatory", beanClass, "isMandatory", "setMandatory"); - PropertyDescriptor _value = new PropertyDescriptor("value", beanClass, "getValue", "setValue"); - PropertyDescriptor[] pds = new PropertyDescriptor[] { - _background, - _border, - _display, - _editable, - _font, - _foreground, - _mandatory, - _value}; - return pds; - - - - - - - - -} - catch(IntrospectionException ex) - { - ex.printStackTrace(); - return null; - } - } - public java.awt.Image getIcon(int iconKind) - { - switch (iconKind) { - case BeanInfo.ICON_COLOR_16x16: - return iconColor16x16Filename != null ? loadImage(iconColor16x16Filename) : null; - case BeanInfo.ICON_COLOR_32x32: - return iconColor32x32Filename != null ? loadImage(iconColor32x32Filename) : null; - case BeanInfo.ICON_MONO_16x16: - return iconMono16x16Filename != null ? loadImage(iconMono16x16Filename) : null; - case BeanInfo.ICON_MONO_32x32: - return iconMono32x32Filename != null ? loadImage(iconMono32x32Filename) : null; - } - return null; - } - public BeanInfo[] getAdditionalBeanInfo() - { - Class superclass = beanClass.getSuperclass(); - try - { - BeanInfo superBeanInfo = Introspector.getBeanInfo(superclass); - return new BeanInfo[] { superBeanInfo }; - } - catch(IntrospectionException ex) - { - ex.printStackTrace(); - return null; - } - } -} diff --git a/org.adempiere.ui.swing/src/org/compiere/grid/ed/VTextLong.java b/org.adempiere.ui.swing/src/org/compiere/grid/ed/VTextLong.java deleted file mode 100644 index 2c9411006e..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/grid/ed/VTextLong.java +++ /dev/null @@ -1,287 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ -package org.compiere.grid.ed; - -import java.awt.Component; -import java.awt.Container; -import java.awt.Dimension; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.awt.event.FocusEvent; -import java.awt.event.FocusListener; -import java.awt.event.KeyEvent; -import java.awt.event.KeyListener; -import java.awt.event.MouseAdapter; -import java.awt.event.MouseEvent; -import java.beans.PropertyChangeEvent; -import java.beans.PropertyVetoException; -import java.util.logging.Level; - -import javax.swing.JFrame; -import javax.swing.JPopupMenu; -import javax.swing.LookAndFeel; -import javax.swing.SwingUtilities; - -import org.adempiere.plaf.AdempierePLAF; -import org.compiere.apps.AEnv; -import org.compiere.apps.FieldRecordInfo; -import org.compiere.model.GridField; -import org.compiere.swing.CMenuItem; -import org.compiere.swing.CTextPane; -import org.compiere.util.CLogger; -import org.compiere.util.Env; -import org.compiere.util.Msg; - -/** - * Long Text (CBLOB) Editor - * - * @author Jorg Janke - * @version $Id: VTextLong.java,v 1.2 2006/07/30 00:51:28 jjanke Exp $ - */ -public class VTextLong extends CTextPane - implements VEditor, KeyListener, ActionListener, FocusListener -{ - /** - * - */ - private static final long serialVersionUID = 7954461878765188455L; - - /** - * Mouse Listener - */ - final class VTextLong_mouseAdapter extends MouseAdapter - { - /** - * Constructor - * @param adaptee VText - */ - VTextLong_mouseAdapter(VTextLong adaptee) - { - this.adaptee = adaptee; - } // VText_mouseAdapter - - private VTextLong adaptee; - - /** - * Mouse Listener - * @param e event - */ - public void mouseClicked(MouseEvent e) - { - // popup menu - if (SwingUtilities.isRightMouseButton(e)) - adaptee.popupMenu.show((Component)e.getSource(), e.getX(), e.getY()); - } // mouse Clicked - - } // VTextLong_mouseAdapter - - /** - * Factory: Start Editor - * @param jc container to get parent frame - * @param header heading - * @param text initial text - * @param editable if false = r/o - * @return edited string - */ - public static String startEditor(Container jc, String header, String text, boolean editable) - { - // Find frame - JFrame frame = AEnv.getFrame(jc); - // Start it - HTMLEditor ed = new HTMLEditor (frame, header, text, editable); - String s = ed.getHtmlText(); - ed = null; - return s; - } // startEditor - - /** - * Standard Constructor - * @param columnName column name - * @param mandatory mandatory - * @param isReadOnly read only - * @param isUpdateable updateable - * @param displayLength display length - * @param fieldLength field length - */ - public VTextLong (String columnName, boolean mandatory, boolean isReadOnly, boolean isUpdateable, - int displayLength, int fieldLength) - { - super (); - super.setName(columnName); - LookAndFeel.installBorder(this, "TextField.border"); - setPreferredSize(new Dimension (500,80)); - - // Create Editor - setForeground(AdempierePLAF.getTextColor_Normal()); - setBackground(AdempierePLAF.getFieldBackground_Normal()); - - setMandatory(mandatory); - m_columnName = columnName; - - if (isReadOnly || !isUpdateable) - setReadWrite(false); - addKeyListener(this); - addFocusListener(this); - - // Popup - addMouseListener(new VTextLong_mouseAdapter(this)); - menuEditor = new CMenuItem(Msg.getMsg(Env.getCtx(), "Editor"), Env.getImageIcon("Editor16.gif")); - menuEditor.addActionListener(this); - popupMenu.add(menuEditor); - } // VText - - /** - * Dispose - */ - public void dispose() - { - } // dispose - - JPopupMenu popupMenu = new JPopupMenu(); - private CMenuItem menuEditor; - - private String m_columnName; - private String m_oldText; - private String m_initialText; - private volatile boolean m_setting = false; - private GridField m_mField; - /** Logger */ - private static CLogger log = CLogger.getCLogger(VTextLong.class); - - /** - * Set Editor to value - * @param value value - */ - public void setValue(Object value) - { - if (value == null) - m_oldText = ""; - else - m_oldText = value.toString(); - if (m_setting) - return; - super.setValue(m_oldText); - m_initialText = m_oldText; - // Always position Top - setCaretPosition(0); - } // setValue - - /** - * Property Change Listener - * @param evt event - */ - public void propertyChange (PropertyChangeEvent evt) - { - if (evt.getPropertyName().equals(org.compiere.model.GridField.PROPERTY)) - setValue(evt.getNewValue()); - } // propertyChange - - /** - * ActionListener - * @param e event - */ - public void actionPerformed(ActionEvent e) - { - if (log.isLoggable(Level.FINEST)) log.finest( "VTestLong.actionPerformed - " + e.getActionCommand()); - if (e.getSource() == menuEditor) - { - menuEditor.setEnabled(false); - String s = VTextLong.startEditor (this, Msg.translate(Env.getCtx(), m_columnName), getText(), isEditable()); - menuEditor.setEnabled(true); - // - // Data Binding - try - { - fireVetoableChange(m_columnName, m_oldText, s); - } - catch (PropertyVetoException pve) {} - } - else if (e.getActionCommand().equals(FieldRecordInfo.CHANGE_LOG_COMMAND)) - { - FieldRecordInfo.start(m_mField); - return; - } - } // actionPerformed - - /** - * Action Listener Interface - NOP - * @param listener listener - */ - public void addActionListener(ActionListener listener) - { - } // addActionListener - - /************************************************************************** - * Key Listener Interface - * @param e event - */ - public void keyTyped(KeyEvent e) {} - public void keyPressed(KeyEvent e) {} - - /** - * Key Released - * if Escape restore old Text. - * @param e event - */ - public void keyReleased(KeyEvent e) - { - // ESC - if (e.getKeyCode() == KeyEvent.VK_ESCAPE) - setText(m_initialText); - } // keyReleased - - /** - * Set Field/WindowNo for ValuePreference - * @param mField field model - */ - public void setField (org.compiere.model.GridField mField) - { - m_mField = mField; - if (m_mField != null) - FieldRecordInfo.addMenu(this, popupMenu); - } // setField - - @Override - public GridField getField() { - return m_mField; - } - - @Override - public void focusGained(FocusEvent e) { - } - - @Override - public void focusLost(FocusEvent e) { - m_setting = true; - try - { - fireVetoableChange(m_columnName, m_oldText, getText()); - } - catch (PropertyVetoException pve) {} - m_setting = false; - } - - /** - * Get Focus Component - * @return component - */ - public Component getFocusableComponent() - { - return this; - } // getFocusableComponent - -} // VTextLong \ No newline at end of file diff --git a/org.adempiere.ui.swing/src/org/compiere/grid/ed/VURL.java b/org.adempiere.ui.swing/src/org/compiere/grid/ed/VURL.java deleted file mode 100644 index dbf6d1698a..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/grid/ed/VURL.java +++ /dev/null @@ -1,537 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ -package org.compiere.grid.ed; - -import java.awt.BorderLayout; -import java.awt.Color; -import java.awt.Component; -import java.awt.Dimension; -import java.awt.Insets; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.awt.event.FocusEvent; -import java.awt.event.FocusListener; -import java.awt.event.KeyEvent; -import java.awt.event.KeyListener; -import java.awt.event.MouseAdapter; -import java.awt.event.MouseEvent; -import java.beans.PropertyChangeEvent; -import java.beans.PropertyVetoException; -import java.net.URL; -import java.util.logging.Level; - -import javax.swing.JComponent; -import javax.swing.JPopupMenu; -import javax.swing.JTextField; -import javax.swing.LookAndFeel; -import javax.swing.SwingUtilities; - -import org.adempiere.plaf.AdempierePLAF; -import org.compiere.apps.ADialog; -import org.compiere.apps.FieldRecordInfo; -import org.compiere.model.GridField; -import org.compiere.model.MRole; -import org.compiere.swing.CButton; -import org.compiere.swing.CMenuItem; -import org.compiere.swing.CTextField; -import org.compiere.util.CLogger; -import org.compiere.util.Env; -import org.compiere.util.Msg; - -/** - * URL Editor - * - * @author Jorg Janke - * @version $Id: VURL.java,v 1.2 2006/07/30 00:51:28 jjanke Exp $ - */ -public class VURL extends JComponent - implements VEditor, ActionListener, KeyListener, FocusListener -{ - /** - * - */ - private static final long serialVersionUID = 8055870820325408717L; - - /****************************************************************************** - * Mouse Listener - */ - final class VURL_mouseAdapter extends MouseAdapter - { - /** - * Constructor - * @param adaptee adaptee - */ - VURL_mouseAdapter(VURL adaptee) - { - m_adaptee = adaptee; - } // VString_mouseAdapter - - private VURL m_adaptee; - - /** - * Mouse Listener - * @param e event - */ - public void mouseClicked(MouseEvent e) - { - // popup menu - if (SwingUtilities.isRightMouseButton(e)) - m_adaptee.popupMenu.show((Component)e.getSource(), e.getX(), e.getY()); - } // mouseClicked - - } // VURL_mouseAdapter - - /** - * IDE Constructor - */ - public VURL () - { - this ("URL", false, false, true, 20, 60); - } // VURL - - /** - * Detail Constructor - * @param columnName column name - * @param mandatory mandatory - * @param isReadOnly read only - * @param isUpdateable updateable - * @param displayLength display length - * @param fieldLength field length - */ - public VURL (String columnName, boolean mandatory, boolean isReadOnly, boolean isUpdateable, - int displayLength, int fieldLength) - { - super.setName(columnName); - m_columnName = columnName; - m_fieldLength = fieldLength; - m_mandatory = mandatory; - LookAndFeel.installBorder(this, "TextField.border"); - this.setLayout(new BorderLayout()); - // Size - this.setPreferredSize(m_text.getPreferredSize()); - int height = m_text.getPreferredSize().height; - - // *** Text *** - m_text = new CTextField(displayLength>VString.MAXDISPLAY_LENGTH ? VString.MAXDISPLAY_LENGTH : displayLength); - m_text.setEditable(isReadOnly); - m_text.setFocusable(true); - m_text.setBorder(null); - m_text.setHorizontalAlignment(JTextField.LEADING); - - // Background - setMandatory(mandatory); - this.add(m_text, BorderLayout.CENTER); - - // *** Button *** - m_button.setIcon(Env.getImageIcon("Online10.gif")); // should be 10 - m_button.setMargin(new Insets(0, 0, 0, 0)); - m_button.setPreferredSize(new Dimension(height, height)); - m_button.addActionListener(this); - m_button.setFocusable(false); - this.add(m_button, BorderLayout.EAST); - - // Preferred Size - this.setPreferredSize(this.getPreferredSize()); // causes r/o to be the same length - // ReadWrite - if (isReadOnly || !isUpdateable) - setReadWrite(false); - else - setReadWrite(true); - - m_text.addKeyListener(this); - m_text.addFocusListener(this); - m_text.addActionListener(this); - m_text.addMouseListener(new VURL_mouseAdapter(this)); - // Popup for Editor - if (fieldLength > displayLength) - { - mEditor = new CMenuItem (Msg.getMsg(Env.getCtx(), "Editor"), Env.getImageIcon("Editor16.gif")); - mEditor.addActionListener(this); - popupMenu.add(mEditor); - } - setForeground(AdempierePLAF.getTextColor_Normal()); - setBackground(AdempierePLAF.getFieldBackground_Normal()); - } // VURL - - /** Logger */ - private static CLogger log = CLogger.getCLogger (VURL.class); - /** Column Name */ - private String m_columnName; - /** The Text */ - private CTextField m_text = new CTextField(); - private boolean m_readWrite; - private boolean m_mandatory; - /** The Button */ - private CButton m_button = new CButton(); - /** Popup Menu */ - JPopupMenu popupMenu = new JPopupMenu(); - /** Editor Menu Item */ - private CMenuItem mEditor; - /** Grid Field */ - private GridField m_mField = null; - - private String m_oldText; - private String m_initialText; - /** Setting new value */ - private volatile boolean m_setting = false; - /** Field in focus */ - @SuppressWarnings("unused") - private volatile boolean m_infocus = false; - /** Field Length */ - private int m_fieldLength; - - /** - * Dispose resources - */ - public void dispose() - { - m_text = null; - m_button = null; - m_mField = null; - } // dispose - - /** - * Set Mandatory - * @param mandatory mandatory - */ - public void setMandatory (boolean mandatory) - { - m_mandatory = mandatory; - m_text.setMandatory(mandatory); - setBackground (false); - } // setMandatory - - /** - * Get Mandatory - * @return mandatory - */ - public boolean isMandatory() - { - return m_mandatory; - } // isMandatory - - /** - * Set ReadWrite - * @param rw read/write - */ - public void setReadWrite (boolean rw) - { - m_readWrite = rw; - m_text.setReadWrite(rw); - setBackground (false); - } // setReadWrite - - /** - * Is Read Write - * @return read write - */ - public boolean isReadWrite() - { - return m_readWrite; - } // isReadWrite - - /** - * Set Foreground - * @param color color - */ - public void setForeground (Color color) - { - m_text.setForeground(color); - } // SetForeground - - /** - * Set Background - * @param error Error - */ - public void setBackground (boolean error) - { - if (error) - setBackground(AdempierePLAF.getFieldBackground_Error()); - else if (!m_readWrite) - setBackground(AdempierePLAF.getFieldBackground_Inactive()); - else if (m_mandatory) - setBackground(AdempierePLAF.getFieldBackground_Mandatory()); - else - setBackground(AdempierePLAF.getFieldBackground_Normal()); - } // setBackground - - /** - * Set Background - * @param color Color - */ - public void setBackground (Color color) - { - m_text.setBackground(color); - } // setBackground - - /** - * Set Editor to value - * @param value value - */ - public void setValue(Object value) - { - // log.config( "VString.setValue", value); - if (value == null) - m_oldText = ""; - else - m_oldText = value.toString(); - // only set when not updated here - if (m_setting) - return; - setText (m_oldText); - m_initialText = m_oldText; - // If R/O left justify - if (!m_text.isEditable() || !isEnabled()) - m_text.setCaretPosition(0); - } // setValue - - /** - * Property Change Listener - * @param evt event - */ - public void propertyChange (PropertyChangeEvent evt) - { - if (evt.getPropertyName().equals(org.compiere.model.GridField.PROPERTY)) - setValue(evt.getNewValue()); - } // propertyChange - - /** - * Return Editor value - * @return value - */ - public Object getValue() - { - return getText(); - } // getValue - - /** - * Return Display Value - * @return value - */ - public String getDisplay() - { - return m_text.getText(); - } // getDisplay - - - /** - * Key Released. - * if Escape Restore old Text - * @param e event - */ - public void keyReleased(KeyEvent e) - { - if (log.isLoggable(Level.FINEST)) log.finest("Key=" + e.getKeyCode() + " - " + e.getKeyChar() - + " -> " + getText()); - // ESC - if (e.getKeyCode() == KeyEvent.VK_ESCAPE) - setText(m_initialText); - } // keyReleased - - /** - * Key Pressed - * @param e ignored - */ - public void keyPressed (KeyEvent e) - { - } // keyPressed - /** - * Key Typed - * @param e ignored - */ - public void keyTyped (KeyEvent e) - { - } // keyTyped - - /** - * Add Action Listener - * @param listener listener - */ - public void addActionListener (ActionListener listener) - { - m_text.addActionListener(listener); - } // addActionListener - - /** - * Data Binding to MTable (via GridController) - Enter pressed - * @param e event - */ - public void actionPerformed(ActionEvent e) - { - if (e.getActionCommand().equals(ValuePreference.NAME)) - { - if (MRole.getDefault().isShowPreference() && !m_mField.isEncrypted() && !m_mField.isEncryptedColumn()) - ValuePreference.start (m_mField, getValue()); - return; - } - else if (e.getActionCommand().equals(FieldRecordInfo.CHANGE_LOG_COMMAND)) - { - FieldRecordInfo.start(m_mField); - return; - } - - // Invoke Editor - else if (e.getSource() == mEditor) - { - String s = Editor.startEditor(this, Msg.translate(Env.getCtx(), m_columnName), - getText(), m_text.isEditable(), m_fieldLength); - setText(s); - } - // - else if (e.getSource() == m_button) - { - action_button(); - return; - } - // Data Binding - try - { - fireVetoableChange(m_columnName, m_oldText, getText()); - } - catch (PropertyVetoException pve) - { - } - } // actionPerformed - - /** - * Action button pressed - show URL - */ - private void action_button() - { - String urlString = m_text.getText(); - String message = null; - if (urlString != null && urlString.length() > 0) - { - try - { - @SuppressWarnings("unused") - URL url = new URL(urlString); - Env.startBrowser(urlString); - return; - } - catch (Exception e) - { - message = e.getMessage(); - } - } - ADialog.warn(0, this, "URLnotValid", message); - } // action button - - /** - * Set Field/WindowNo for ValuePreference - * @param mField field - */ - public void setField (GridField mField) - { - m_mField = mField; - if (m_mField != null - && MRole.getDefault().isShowPreference() - && !mField.isEncrypted() && !mField.isEncryptedColumn()) - ValuePreference.addMenu (this, popupMenu); - if (m_mField != null) - FieldRecordInfo.addMenu(this, popupMenu); - } // setField - - @Override - public GridField getField() { - return m_mField; - } - - /** - * Set Text - * @param text text - */ - public void setText (String text) - { - m_text.setText (text); - } // setText - - - /** - * Get Text (clear) - * @return text - */ - public String getText () - { - String text = m_text.getText(); - return text; - } // getText - - /** - * Focus Gained. - * Enabled with Obscure - * @param e event - */ - public void focusGained (FocusEvent e) - { - m_infocus = true; - setText(getText()); // clear - } // focusGained - - /** - * Focus Lost - * Enabled with Obscure - * @param e event - */ - public void focusLost (FocusEvent e) - { - m_setting = true; - try - { - String clear = getText(); - if (clear.length() > m_fieldLength) - clear = clear.substring(0, m_fieldLength); - fireVetoableChange (m_columnName, m_oldText, clear); - } - catch (PropertyVetoException pve) - { - } - m_setting = false; - - m_infocus = false; - setText(getText()); // obscure - } // focus Lost - - /** - * Request Focus - */ - @Override - public void requestFocus() - { - m_text.requestFocus(); - } // requestFocus - - /** - * Request Focus In Window - * @return focus request - */ - @Override - public boolean requestFocusInWindow() - { - return m_text.requestFocusInWindow(); - } // requestFocusInWindow - - /** - * Get Focus Component - * @return component - */ - public Component getFocusableComponent() - { - return m_text; - } // getFocusComponent - -} // VURL diff --git a/org.adempiere.ui.swing/src/org/compiere/grid/ed/ValuePreference.java b/org.adempiere.ui.swing/src/org/compiere/grid/ed/ValuePreference.java deleted file mode 100644 index 977582d218..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/grid/ed/ValuePreference.java +++ /dev/null @@ -1,525 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ -package org.compiere.grid.ed; - -import java.awt.BorderLayout; -import java.awt.Color; -import java.awt.Frame; -import java.awt.GridBagConstraints; -import java.awt.GridBagLayout; -import java.awt.Insets; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.util.Properties; -import java.util.UUID; -import java.util.logging.Level; - -import javax.swing.BorderFactory; -import javax.swing.Icon; -import javax.swing.ImageIcon; -import javax.swing.JButton; -import javax.swing.JDialog; -import javax.swing.JPopupMenu; -import javax.swing.JScrollPane; -import javax.swing.JTable; -import javax.swing.border.TitledBorder; - -import org.compiere.apps.ADialog; -import org.compiere.apps.AEnv; -import org.compiere.apps.ConfirmPanel; -import org.compiere.model.GridField; -import org.compiere.model.MRole; -import org.compiere.swing.CDialog; -import org.compiere.swing.CLabel; -import org.compiere.swing.CMenuItem; -import org.compiere.swing.CPanel; -import org.compiere.swing.CTextField; -import org.compiere.util.CLogMgt; -import org.compiere.util.CLogger; -import org.compiere.util.DB; -import org.compiere.util.DisplayType; -import org.compiere.util.Env; -import org.compiere.util.Msg; - -/** - * Maintain Value Preferences. - * To delete a preference, select a null value and save. - * - * @author Jorg Janke - * @version $Id: ValuePreference.java,v 1.2 2006/07/30 00:51:28 jjanke Exp $ - */ -public class ValuePreference extends CDialog - implements ActionListener -{ - /** - * - */ - private static final long serialVersionUID = -6718115525965508049L; - - /** - * Factory - * @param mField field - * @param aValue value - * @return ValuePreference or null - */ - public static ValuePreference start (GridField mField, Object aValue) - { - return start (mField, aValue, null); - } // start - - /** - * Factory - * @param mField field - * @param aValue value - * @param aDisplayValue display value - * @return ValuePreference or null - */ - public static ValuePreference start (GridField mField, Object aValue, String aDisplayValue) - { - if (!mField.isEditable(false)) - { - log.info("Field not editable (R/O)"); - return null; - } - - // Set Value/DisplayValue - String Value = null; - String DisplayValue = null; - if (aValue != null) - { - Value = aValue.toString(); - DisplayValue = (aDisplayValue == null) ? Value : aDisplayValue; - } - - // Get from mField - // AD_Window_ID, DisplayAttribute, Attribute, DisplayType, AD_Referenece_ID - int AD_Window_ID = mField.getAD_Window_ID(); - String Attribute = mField.getColumnName(); - String DisplayAttribute = mField.getHeader(); - int displayType = mField.getDisplayType(); - int AD_Reference_ID = 0; - int WindowNo = mField.getWindowNo(); - - // Get from Environment (WindowNo) - // AD_Client_ID, AD_Org_ID, AD_User_ID, Frame - int AD_Client_ID = Env.getAD_Client_ID(Env.getCtx()); - int AD_Org_ID = Env.getContextAsInt(Env.getCtx(), WindowNo, "AD_Org_ID"); - int AD_User_ID = Env.getAD_User_ID(Env.getCtx()); - Frame frame = AEnv.getWindow(WindowNo); - - // Create Editor - ValuePreference vp = new ValuePreference (frame, WindowNo, - AD_Client_ID, AD_Org_ID, AD_User_ID, AD_Window_ID, - Attribute, DisplayAttribute, Value, DisplayValue, - displayType, AD_Reference_ID); - return vp; - } // create - - /** - * Create the popup menu item to start the ValuePreference editor. - * - * .. add method - * public void setField (MField mField) - * { - * m_mField = mField; - * if (m_mField != null) - * ValuePreference.addMenu (this, m_popupMenu); - * } // setField - * - * .. in actionPerformed add .. - * if (e.getActionCommand().equals(ValuePreference.NAME)) - * { - * ValuePreference.start (m_mField, getValue(), DisplayValue); - * return; - * } - * - * @param l listener - * @param popupMenu menu - * @return JMenuItem - */ - public static CMenuItem addMenu (ActionListener l, JPopupMenu popupMenu) - { - CMenuItem mi = new CMenuItem (Msg.getMsg(Env.getCtx(), NAME), s_icon); - mi.setActionCommand(NAME); - mi.addActionListener(l); - popupMenu.add(mi); - return mi; - } // addMenu - - /** The Name of the Editor */ - public static final String NAME = "ValuePreference"; - /** The Menu Icon */ - private static Icon s_icon = new ImageIcon(org.compiere.AdempiereClient.class.getResource("images/VPreference16.gif")); - /** Logger */ - private static CLogger log = CLogger.getCLogger(ValuePreference.class); - - /** - * Constructor - * - * @param frame parent - * @param WindowNo window no - * @param AD_Client_ID client - * @param AD_Org_ID org - * @param AD_User_ID user - * @param AD_Window_ID window id - * @param Attribute attribute - * @param DisplayAttribute attribute display - * @param Value value - * @param DisplayValue calue display - * @param displayType display type - * @param AD_Reference_ID reference - */ - public ValuePreference (Frame frame, int WindowNo, - int AD_Client_ID, int AD_Org_ID, int AD_User_ID, int AD_Window_ID, - String Attribute, String DisplayAttribute, String Value, String DisplayValue, - int displayType, int AD_Reference_ID) - { - super(frame, Msg.getMsg(Env.getCtx(), NAME) + " " + DisplayAttribute, true); - if (log.isLoggable(Level.CONFIG)) log.config("WindowNo=" + WindowNo - + ", Client_ID=" + AD_Client_ID + ", Org_ID=" + AD_Org_ID + ", User_ID=" + AD_User_ID + ", Window_ID=" + AD_Window_ID - + ", Attribute=" + Attribute + "/" + DisplayAttribute + ", Value=" + Value + "/" + DisplayValue - + ", DisplayType=" + displayType + ", Reference_ID=" + AD_Reference_ID); - m_ctx = Env.getCtx(); - m_WindowNo = WindowNo; - m_AD_Client_ID = AD_Client_ID; - m_AD_Org_ID = AD_Org_ID; - m_AD_User_ID = AD_User_ID; - m_AD_Window_ID = AD_Window_ID; - m_Attribute = Attribute; - m_DisplayAttribute = DisplayAttribute; - m_Value = Value; - m_DisplayValue = DisplayValue; - m_DisplayType = displayType; - // - m_role = MRole.getDefault(); - try - { - jbInit(); - dynInit(); - } - catch(Exception ex) - { - log.log(Level.SEVERE, "", ex); - } - AEnv.showCenterScreen(this); - } // ValuePreference - - private Properties m_ctx; - private int m_WindowNo; - private int m_AD_Client_ID; - private int m_AD_Org_ID; - private int m_AD_User_ID; - private int m_AD_Window_ID; - private String m_Attribute; - private String m_DisplayAttribute; - private String m_Value; - private String m_DisplayValue; - private int m_DisplayType; - private MRole m_role; - - // Display - private CPanel setPanel = new CPanel(); - private GridBagLayout setLayout = new GridBagLayout(); - private CLabel lAttribute = new CLabel(); - private CTextField fAttribute = new CTextField(); - private CLabel lAttributeValue = new CLabel(); - private CLabel lValue = new CLabel(); - private CLabel lValueValue = new CLabel(); - private CTextField fValue = new CTextField(); - private CLabel lSetFor = new CLabel(); - private VCheckBox cbClient = new VCheckBox(); - private VCheckBox cbOrg = new VCheckBox(); - private VCheckBox cbUser = new VCheckBox(); - private VCheckBox cbWindow = new VCheckBox(); - private CLabel lExplanation = new CLabel(); - private CPanel currentPanel = new CPanel(); - private TitledBorder titledBorder; - private JScrollPane scrollPane = new JScrollPane(); - private BorderLayout currentLayout = new BorderLayout(); - private JTable table = new JTable(); - - private ConfirmPanel confirmPanel = new ConfirmPanel(true); - private JButton bDelete; - - /** - * Static Layout - * @throws Exception - */ - void jbInit() throws Exception - { - setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE); - titledBorder = new TitledBorder(BorderFactory.createEtchedBorder(Color.white,new Color(148, 145, 140)), - Msg.getMsg(m_ctx, "CurrentSettings")); - // - lAttribute.setText(Msg.translate(m_ctx, "Attribute")); - lValue.setText(Msg.translate(m_ctx, "Value")); - lSetFor.setText(Msg.getMsg(m_ctx, "ValuePreferenceSetFor")); - cbClient.setText(Msg.translate(m_ctx, "AD_Client_ID")); - cbOrg.setText(Msg.translate(m_ctx, "AD_Org_ID")); - cbUser.setText(Msg.translate(m_ctx, "AD_User_ID")); - cbUser.setSelected(true); - cbWindow.setText(Msg.translate(m_ctx, "AD_Window_ID")); - cbWindow.setSelected(true); - // - setPanel.setLayout(setLayout); - fAttribute.setEditable(false); - fValue.setEditable(false); - this.getContentPane().add(setPanel, BorderLayout.NORTH); - setPanel.add(lAttribute, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); - setPanel.add(fAttribute, new GridBagConstraints(1, 0, 4, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5), 0, 0)); - setPanel.add(lValue, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); - setPanel.add(fValue, new GridBagConstraints(1, 1, 4, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5), 0, 0)); - setPanel.add(lSetFor, new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); - setPanel.add(cbClient, new GridBagConstraints(1, 2, 1, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); - setPanel.add(cbOrg, new GridBagConstraints(2, 2, 1, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); - setPanel.add(cbUser, new GridBagConstraints(3, 2, 1, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); - setPanel.add(cbWindow, new GridBagConstraints(4, 2, 1, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); - setPanel.add(lAttributeValue, new GridBagConstraints(5, 0, 1, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); - setPanel.add(lValueValue, new GridBagConstraints(5, 1, 1, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); - setPanel.add(lExplanation, new GridBagConstraints(1, 3, 4, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); - // - currentPanel.setBorder(titledBorder); - currentPanel.setLayout(currentLayout); - // this.getContentPane().add(currentPanel, BorderLayout.CENTER); - currentPanel.add(scrollPane, BorderLayout.CENTER); - scrollPane.getViewport().add(table, null); - this.getContentPane().add(confirmPanel, BorderLayout.SOUTH); - } // jbInit - - /** - * Dynamic Init - */ - private void dynInit() - { - // Set Attribute/Value - fAttribute.setText(m_DisplayAttribute); - lAttributeValue.setText(m_Attribute); - fValue.setText(m_DisplayValue); - lValueValue.setText(m_Value); - if (CLogMgt.isLevelFine()) - { - lAttributeValue.setVisible(false); - lValueValue.setVisible(false); - } - - // ActionListener - cbClient.setEnabled(false); - cbClient.setSelected(true); - // cbClient.addActionListener(this); - - // Can Change Org - if (MRole.PREFERENCETYPE_Client.equals(m_role.getPreferenceType())) - cbOrg.addActionListener(this); - else - { - cbOrg.setEnabled(false); - cbOrg.setSelected(true); - } - - // Can Change User - if (MRole.PREFERENCETYPE_Client.equals(m_role.getPreferenceType()) - || MRole.PREFERENCETYPE_Organization.equals(m_role.getPreferenceType())) - cbUser.addActionListener(this); - else - { - cbUser.setEnabled(false); - cbUser.setSelected(true); - } - // Can change all/specific - cbWindow.addActionListener(this); - - // Other - confirmPanel.addActionListener(this); - bDelete = confirmPanel.addButton(ConfirmPanel.createDeleteButton(true)); - bDelete.addActionListener(this); - setExplanation(); - } // dynInit - - /** - * Action Listener - * @param e event - */ - public void actionPerformed (ActionEvent e) - { - if (e.getActionCommand().equals(ConfirmPanel.A_CANCEL)) - { - dispose(); - } - else if (e.getActionCommand().equals(ConfirmPanel.A_OK)) - { - insert(); - dispose(); - } - else if (e.getSource() == bDelete) - { - int no = delete(); - if (no == 0) - ADialog.warn(m_WindowNo, this, "ValuePreferenceNotFound"); - else - ADialog.info(m_WindowNo, this, "ValuePreferenceDeleted", String.valueOf(no)); - dispose(); - } - else - setExplanation(); - } // actionPerformed - - /** - * Set Explanation - */ - private void setExplanation() - { - /** @todo translation */ - StringBuilder expl = new StringBuilder("For "); - if (cbClient.isSelected() && cbOrg.isSelected()) - expl.append("this Client and Organization"); - else if (cbClient.isSelected() && !cbOrg.isSelected()) - expl.append("all Organizations of this Client"); - else if (!cbClient.isSelected() && cbOrg.isSelected()) - { - cbOrg.setSelected(false); - expl.append("entire System"); - } - else - expl.append("entire System"); - // - if (cbUser.isSelected()) - expl.append(", this User"); - else - expl.append(", all Users"); - // - if (cbWindow.isSelected()) - expl.append(" and this Window"); - else - expl.append(" and all Windows"); - // - if (Env.getLanguage(Env.getCtx()).isBaseLanguage()) - { - lExplanation.setText (expl.toString ()); - this.pack (); - } - } // setExplanation - - /** - * Delete Preference - * @return number of rows deleted - */ - public int delete() - { - log.info(""); - - StringBuilder sql = new StringBuilder ("DELETE FROM AD_Preference WHERE "); - sql.append("AD_Client_ID=").append(cbClient.isSelected() ? m_AD_Client_ID : 0); - sql.append(" AND AD_Org_ID=").append(cbOrg.isSelected() ? m_AD_Org_ID : 0); - if (cbUser.isSelected()) - sql.append(" AND AD_User_ID=").append(m_AD_User_ID); - else - sql.append(" AND AD_User_ID IS NULL"); - if (cbWindow.isSelected()) - sql.append(" AND AD_Window_ID=").append(m_AD_Window_ID); - else - sql.append(" AND AD_Window_ID IS NULL"); - sql.append(" AND Attribute='").append(m_Attribute).append("'"); - // - if (log.isLoggable(Level.FINE)) log.fine( sql.toString()); - int no = DB.executeUpdate(sql.toString(), null); - if (no > 0) - Env.setContext(m_ctx, getContextKey(), (String)null); - return no; - } // delete - - /** - * Get Context Key - * @return Context Key - */ - private String getContextKey() - { - if (cbWindow.isSelected()) - return "P" + m_AD_Window_ID + "|" + m_Attribute; - else - return "P|" + m_Attribute; - } // getContextKey - - /** - * Save to Disk - */ - public void insert() - { - log.info(""); - - // --- Delete first - int no = delete(); - - // Handle NULL - if (m_Value == null || m_Value.length() == 0) - { - if (DisplayType.isLookup(m_DisplayType)) - m_Value = "-1"; // -1 may cause problems (BPartner - M_DiscountSchema - else if (DisplayType.isDate(m_DisplayType)) - m_Value = " "; - else - { - ADialog.warn(m_WindowNo, this, "ValuePreferenceNotInserted"); - return; - } - } - - // --- Inserting - int Client_ID = cbClient.isSelected() ? m_AD_Client_ID : 0; - int Org_ID = cbOrg.isSelected() ? m_AD_Org_ID : 0; - int AD_Preference_ID = DB.getNextID(m_ctx, "AD_Preference", null); - // - StringBuilder sql = new StringBuilder ("INSERT INTO AD_Preference (" - + "AD_Preference_ID, AD_Preference_UU, AD_Client_ID, AD_Org_ID, IsActive, Created,CreatedBy,Updated,UpdatedBy," - + "AD_Window_ID, AD_User_ID, Attribute, Value) VALUES ("); - sql.append(AD_Preference_ID).append(",").append(DB.TO_STRING(UUID.randomUUID().toString())).append(",").append(Client_ID).append(",").append(Org_ID) - .append(", 'Y',SysDate,").append(m_AD_User_ID).append(",SysDate,").append(m_AD_User_ID).append(", "); - if (cbWindow.isSelected()) - sql.append(m_AD_Window_ID).append(","); - else - sql.append("NULL,") ; - if (cbUser.isSelected()) - sql.append(m_AD_User_ID).append(","); - else - sql.append("NULL,"); - // - sql.append(DB.TO_STRING(m_Attribute)).append(",").append(DB.TO_STRING(m_Value)).append(")"); - // - if (log.isLoggable(Level.FINE)) log.fine( sql.toString()); - no = DB.executeUpdate(sql.toString(), null); - if (no == 1) - { - Env.setContext(m_ctx, getContextKey(), m_Value); - ADialog.info(m_WindowNo, this, "ValuePreferenceInserted"); - } - else - ADialog.warn(m_WindowNo, this, "ValuePreferenceNotInserted"); - - } // insert - -} // ValuePreference diff --git a/org.adempiere.ui.swing/src/org/compiere/grid/ed/package.html b/org.adempiere.ui.swing/src/org/compiere/grid/ed/package.html deleted file mode 100644 index ec4efba3ff..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/grid/ed/package.html +++ /dev/null @@ -1,34 +0,0 @@ - - - - - - - -Provides for.... - -

    Field Editor

    - - - -

    Related Documentation

    - -For overviews, tutorials, examples, guides, and tool documentation, please see: - - - - - - diff --git a/org.adempiere.ui.swing/src/org/compiere/grid/package.html b/org.adempiere.ui.swing/src/org/compiere/grid/package.html deleted file mode 100644 index c77ff2e0af..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/grid/package.html +++ /dev/null @@ -1,30 +0,0 @@ - - - - - - - -

    Package org.compiere.grid

    - -Implement datagrid, custom application dialog and tabpane for application window. - -

    Related Documentation

    - -For overviews, tutorials, examples, guides, and tool documentation, please see: - - - - - - diff --git a/org.adempiere.ui.swing/src/org/compiere/grid/tree/AdempiereTreeModel.java b/org.adempiere.ui.swing/src/org/compiere/grid/tree/AdempiereTreeModel.java deleted file mode 100644 index ce26793f5e..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/grid/tree/AdempiereTreeModel.java +++ /dev/null @@ -1,108 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ -package org.compiere.grid.tree; - -import java.util.logging.Level; - -import javax.swing.tree.DefaultTreeModel; -import javax.swing.tree.TreeNode; - -import org.compiere.model.MTree; -import org.compiere.model.MTreeNode; -import org.compiere.util.CLogger; -import org.compiere.util.DB; -import org.compiere.util.Trx; - -/** - * AdempiereTreeModel provides a persistable tree model based on an MTree. - * - * @author phib 2008/07/30 - * FR [ 2032092 ] Java 6 improvements to tree drag and drop - */ -public class AdempiereTreeModel extends DefaultTreeModel { - - /** - * - */ - private static final long serialVersionUID = 8503954687681402088L; - - /** Logger */ - private static CLogger log = CLogger.getCLogger(AdempiereTreeModel.class); - - private MTree m_MTree; - public AdempiereTreeModel(TreeNode root) { - super(root); - } - - public AdempiereTreeModel(MTreeNode root, boolean b) { - super(root, b); - } - - public void setMTree(MTree tree) { - - m_MTree = tree; - - } - - public void saveChangedNodes(MTreeNode from, MTreeNode to) { - int AD_Tree_ID = m_MTree.getAD_Tree_ID(); - Trx trx = Trx.get (Trx.createTrxName("AdempiereTreeModel"), true); - try - { - @SuppressWarnings("unused") - int no = 0; - for (int i = 0; i < from.getChildCount(); i++) - { - MTreeNode nd = (MTreeNode)from.getChildAt(i); - StringBuilder sql = new StringBuilder("UPDATE "); - sql.append(m_MTree.getNodeTableName()) - .append(" SET Parent_ID=").append(from.getNode_ID()) - .append(", SeqNo=").append(i) - .append(", Updated=SysDate") - .append(" WHERE AD_Tree_ID=").append(AD_Tree_ID) - .append(" AND Node_ID=").append(nd.getNode_ID()); - no = DB.executeUpdate(sql.toString(),trx.getTrxName()); - } - if (from != to) - for (int i = 0; i < to.getChildCount(); i++) - { - MTreeNode nd = (MTreeNode)to.getChildAt(i); - StringBuilder sql = new StringBuilder("UPDATE "); - sql.append(m_MTree.getNodeTableName()) - .append(" SET Parent_ID=").append(to.getNode_ID()) - .append(", SeqNo=").append(i) - .append(", Updated=SysDate") - .append(" WHERE AD_Tree_ID=").append(AD_Tree_ID) - .append(" AND Node_ID=").append(nd.getNode_ID()); - if (log.isLoggable(Level.FINE)) log.fine(sql.toString()); - no = DB.executeUpdate(sql.toString(),trx.getTrxName()); - } - trx.commit(true); - } - catch (Exception e) - { - trx.rollback(); - log.log(Level.SEVERE, "move", e); - } - trx.close(); - trx = null; - log.config("complete"); - - } - - -} diff --git a/org.adempiere.ui.swing/src/org/compiere/grid/tree/TransferableTreeNode.java b/org.adempiere.ui.swing/src/org/compiere/grid/tree/TransferableTreeNode.java deleted file mode 100644 index 5606709f8a..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/grid/tree/TransferableTreeNode.java +++ /dev/null @@ -1,65 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ -package org.compiere.grid.tree; - -import java.awt.datatransfer.DataFlavor; -import java.awt.datatransfer.Transferable; -import java.awt.datatransfer.UnsupportedFlavorException; -import java.io.IOException; - -import org.compiere.model.MTreeNode; - -/** - * TransferableTreeNode wraps an MTreeNode into a Transferable for - * use by drag and drop type actions. - * - * - * @author phib 2008/07/30 - * FR [ 2032092 ] Java 6 improvements to tree drag and drop - */ -class TransferableTreeNode implements Transferable { - - public static DataFlavor TREE_NODE_FLAVOR = new DataFlavor(MTreeNode.class, - "Tree Path"); - - DataFlavor flavors[] = { TREE_NODE_FLAVOR }; - - MTreeNode node; - - public TransferableTreeNode(MTreeNode node) { - this.node = node; - } - - public synchronized DataFlavor[] getTransferDataFlavors() { - return flavors; - } - - public boolean isDataFlavorSupported(DataFlavor flavor) { - return (flavor.getRepresentationClass() == MTreeNode.class); - } - - public synchronized Object getTransferData(DataFlavor flavor) - throws UnsupportedFlavorException, IOException { - if (isDataFlavorSupported(flavor)) { - return (Object) node; - } else { - throw new UnsupportedFlavorException(flavor); - } - } - } - - diff --git a/org.adempiere.ui.swing/src/org/compiere/grid/tree/VTreeCellRenderer.java b/org.adempiere.ui.swing/src/org/compiere/grid/tree/VTreeCellRenderer.java deleted file mode 100644 index 5f322ddcfc..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/grid/tree/VTreeCellRenderer.java +++ /dev/null @@ -1,81 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ -package org.compiere.grid.tree; - -import java.awt.Component; - -import javax.swing.Icon; -import javax.swing.JTree; -import javax.swing.tree.DefaultTreeCellRenderer; - -import org.compiere.model.MTreeNode; - -/** - * Tree Cell Renderer to context sensitive display Icon - * @author Jorg Janke - * @version $Id: VTreeCellRenderer.java,v 1.3 2006/07/30 00:51:28 jjanke Exp $ - */ -public final class VTreeCellRenderer extends DefaultTreeCellRenderer -{ - /** - * - */ - private static final long serialVersionUID = -7611138520740658446L; - - - /** - * Constructor - */ - public VTreeCellRenderer() - { - super(); - } // VTreeCellRenderer - - - /** - * Get Tree Cell Renderer Component. - * Sets Icon, Name, Description for leaves - * @param tree tree - * @param value value - * @param Selected selected - * @param expanded expanded - * @param leaf leaf - * @param row row - * @param HasFocus focus - * @return renderer - */ - public Component getTreeCellRendererComponent(JTree tree, Object value, - boolean Selected, boolean expanded, boolean leaf, int row, boolean HasFocus) - { - VTreeCellRenderer c = (VTreeCellRenderer)super.getTreeCellRendererComponent - (tree, value, Selected, expanded, leaf, row, HasFocus); - if (!leaf) - return c; - - // We have a leaf - MTreeNode nd = (MTreeNode)value; - Icon icon = nd.getIcon(); - if (icon != null) - c.setIcon(icon); - c.setText(nd.getName()); - c.setToolTipText(nd.getDescription()); - if (!Selected) - c.setForeground(nd.getColor()); - return c; - } // getTreeCellRendererComponent - -} // VTreeCellRenderer diff --git a/org.adempiere.ui.swing/src/org/compiere/grid/tree/VTreePanel.java b/org.adempiere.ui.swing/src/org/compiere/grid/tree/VTreePanel.java deleted file mode 100644 index aa174fdce4..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/grid/tree/VTreePanel.java +++ /dev/null @@ -1,1072 +0,0 @@ - /****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ -package org.compiere.grid.tree; - - -import java.awt.BorderLayout; -import java.awt.Container; -import java.awt.Cursor; -import java.awt.Dimension; -import java.awt.Graphics; -import java.awt.Insets; -import java.awt.Rectangle; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.awt.event.KeyEvent; -import java.awt.event.KeyListener; -import java.awt.event.MouseEvent; -import java.awt.event.MouseListener; -import java.beans.PropertyChangeEvent; -import java.beans.PropertyChangeListener; -import java.util.ArrayList; -import java.util.Enumeration; -import java.util.HashMap; -import java.util.Map; -import java.util.logging.Level; - -import javax.swing.Action; -import javax.swing.ActionMap; -import javax.swing.BorderFactory; -import javax.swing.DropMode; -import javax.swing.JButton; -import javax.swing.JCheckBox; -import javax.swing.JComponent; -import javax.swing.JFrame; -import javax.swing.JLabel; -import javax.swing.JMenuItem; -import javax.swing.JPopupMenu; -import javax.swing.JScrollPane; -import javax.swing.JSplitPane; -import javax.swing.JToolBar; -import javax.swing.JTree; -import javax.swing.KeyStroke; -import javax.swing.SwingUtilities; -import javax.swing.TransferHandler; -import javax.swing.UIManager; -import javax.swing.plaf.SplitPaneUI; -import javax.swing.plaf.basic.BasicSplitPaneUI; -import javax.swing.tree.DefaultTreeSelectionModel; -import javax.swing.tree.TreePath; - -import org.adempiere.exceptions.DBException; -import org.adempiere.plaf.AdempierePLAF; -import org.adempiere.plaf.AdempiereTaskPaneUI; -import org.compiere.apps.ADialog; -import org.compiere.apps.AEnv; -import org.compiere.model.MTree; -import org.compiere.model.MTreeNode; -import org.compiere.swing.CButton; -import org.compiere.swing.CCheckBox; -import org.compiere.swing.CLabel; -import org.compiere.swing.CMenuItem; -import org.compiere.swing.CPanel; -import org.compiere.swing.CTextField; -import org.compiere.swing.ShadowBorder; -import org.compiere.util.CLogger; -import org.compiere.util.DB; -import org.compiere.util.Env; -import org.compiere.util.Msg; -import org.jdesktop.swingx.JXTaskPane; -import org.jdesktop.swingx.JXTaskPaneContainer; - -import de.schaeffer.compiere.tools.DocumentSearch; - -/** - * Tree Panel displays trees. - *
    - * When a node is selected by Left Click, a propertyChange (NODE_SELECTION) event is fired - *
    - *		PropertyChangeListener -
    - *			treePanel.addPropertyChangeListener(VTreePanel.NODE_SELECTION, this);
    - *			calls: public void propertyChange(PropertyChangeEvent e)
    - *  
    - * To select a specific node call - * setSelectedNode(NodeID); - * - * @author Jorg Janke - * @version $Id: VTreePanel.java,v 1.3 2006/07/30 00:51:28 jjanke Exp $ - * - * @author kthiemann / Carlos Ruiz - *
  • 2761420 - Advanced Search - * - * @author Teo Sarca - *
  • BF [ 2866493 ] VTreePanel is not saving who did the node move - * https://sourceforge.net/tracker/?func=detail&atid=879332&aid=2866493&group_id=176962 - * - * @author Paul Bowden - *
  • FR [ 2032092 ] Java 6 improvements to tree drag and drop - * https://sourceforge.net/tracker/index.php?func=detail&aid=2032092&group_id=176962&atid=879335 - */ -public final class VTreePanel extends CPanel - implements ActionListener -{ -/****************************************************************************** - * Mouse Clicked - */ - class VTreePanel_mouseAdapter extends java.awt.event.MouseAdapter - { - VTreePanel m_adaptee; - - /** - * VTreePanel_mouseAdapter - * @param adaptee - */ - VTreePanel_mouseAdapter(VTreePanel adaptee) - { - m_adaptee = adaptee; - } - - /** - * Mouse Clicked - * @param e - */ - public void mouseClicked(MouseEvent e) - { - m_adaptee.mouseClicked(e); - } - - - } // VTreePanel_mouseAdapter - - /** - * Key Pressed - */ - class VTreePanel_keyAdapter extends java.awt.event.KeyAdapter - { - VTreePanel m_adaptee; - - /** - * VTreePanel_keyAdapter - * @param adaptee - */ - VTreePanel_keyAdapter(VTreePanel adaptee) - { - m_adaptee = adaptee; - } - - /** - * Key Pressed - * @param e - */ - public void keyPressed(KeyEvent e) - { - if (e.getKeyCode() == KeyEvent.VK_ENTER) - m_adaptee.keyPressed(e); - } - } // VTreePanel_keyAdapter - - - /** - * - */ - private static final long serialVersionUID = 8238886431744822217L; - - private static final String PREFIX_DOCUMENT_SEARCH = "/"; - - protected boolean m_lookAndFeelChanged = false; - - private VTreeTransferHandler handler = new VTreeTransferHandler(); - - /** - * Tree Panel for browsing and editing of a tree. - * Need to call initTree - * @param WindowNo WindowNo - * @param editable if true you can edit it - * @param hasBar has OutlookBar - */ - public VTreePanel(int WindowNo, boolean hasBar, boolean editable) - { - super(); - toolbar = new ArrayList(); - if (log.isLoggable(Level.CONFIG)) log.config("Bar=" + hasBar + ", Editable=" + editable); - m_WindowNo = WindowNo; - m_hasBar = hasBar; - m_editable = editable; - - // static init - jbInit(); - if (!hasBar) - { - barScrollPane.setPreferredSize(new Dimension(0,0)); - barScrollPane.setMaximumSize(new Dimension(0,0)); - barScrollPane.setMinimumSize(new Dimension(0,0)); - //Begin - [FR 1953769] - bar.setBackground(AdempierePLAF.getFormBackground()); - //End - [FR 1953769] - centerSplitPane.setDividerLocation(0); - centerSplitPane.setDividerSize(0); - popMenuTree.remove(mBarAdd); - } - else { - centerSplitPane.setDividerLocation(80); - UIManager.addPropertyChangeListener(new PropertyChangeListener() { - public void propertyChange(PropertyChangeEvent evt) { - if ("lookAndFeel".equals(evt.getPropertyName())) - m_lookAndFeelChanged = true; - } - - }); - } - // base settings - if (editable) { - tree.setDragEnabled(true); - tree.setTransferHandler(handler); - tree.setDropMode(DropMode.INSERT); - setMappings(tree); - } - else - { - popMenuTree.remove(mFrom); - popMenuTree.remove(mTo); - } - } // VTreePanel - - /** - * Tree initialization. - * May be called several times - * @param AD_Tree_ID tree to load - * @return true if loaded ok - */ - public boolean initTree (int AD_Tree_ID) - { - return initTree (AD_Tree_ID, null, 0); - } - - public boolean initTree (int AD_Tree_ID, String linkColName, int linkID) - { - if (log.isLoggable(Level.CONFIG)) log.config("AD_Tree_ID=" + AD_Tree_ID); - // - m_AD_Tree_ID = AD_Tree_ID; - - // Get Tree - MTree vTree = null; - if (linkColName != null) - vTree = new MTree (Env.getCtx(), AD_Tree_ID, m_editable, true, null, linkColName, linkID); - else - vTree = new MTree (Env.getCtx(), AD_Tree_ID, m_editable, true, null); - m_root = vTree.getRoot(); - m_root.setName(Msg.getMsg(Env.getCtx(), vTree.getName() ) ); // translate name of menu. - // m_root.setName(Msg.getMsg(Env.getCtx(), "Menu") ); // @Trifon; this is the hardcoded way. - - if (log.isLoggable(Level.CONFIG)) log.config("root=" + m_root); - m_nodeTableName = vTree.getNodeTableName(); - treeModel = new AdempiereTreeModel(m_root, true); - treeModel.setMTree(vTree); - tree.setModel(treeModel); - - // Shortcut Bar - if (m_hasBar) - { - for (JToolBar jt : toolbar) - jt.removeAll(); - toolbarMap = new HashMap(); - Enumeration enTop = m_root.children(); - JToolBar jt = null; - Map titleMap = new HashMap(); - while (enTop.hasMoreElements()) - { - MTreeNode ndTop = (MTreeNode)enTop.nextElement(); - Enumeration en = ndTop.preorderEnumeration(); - boolean labelDrawn=false; - while (en.hasMoreElements()) - { - MTreeNode nd = (MTreeNode)en.nextElement(); - if (nd.isOnBar()) { - if (!labelDrawn) { - jt = new JToolBar(JToolBar.VERTICAL); - titleMap.put(jt, ndTop.toString().trim()); - labelDrawn=true; - toolbarMap.put(ndTop.getNode_ID(), jt); - } - addToBar(nd, jt, false); - } - } - if (jt!=null) - toolbar.add(jt); - jt=null; - } - //jbInit(); - for (JToolBar jt2 : toolbar) { - jt2.setOpaque(false); - //jt2.setLayout(new GridBagLayout()); - jt2.setFloatable(false); - jt2.setRollover(true); - jt2.setBorder(BorderFactory.createEmptyBorder()); - - JXTaskPane barPart = new JXTaskPane(); - //Begin - [FR 1953769] - barPart.setUI(new AdempiereTaskPaneUI()); - barPart.getContentPane().setBackground(AdempierePLAF.getFormBackground()); - //End - [FR 1953769] - barPart.setAnimated(true); - barPart.setLayout(new BorderLayout()); - barPart.add(jt2, BorderLayout.NORTH); - barPart.setTitle(titleMap.get(jt2)); - - bar.add(barPart); - //Begin - [FR 1953769] - bar.setBackground(AdempierePLAF.getFormBackground()); - //End - [FR 1953769] - } - } - return true; - } // initTree - - /** Logger */ - private static CLogger log = CLogger.getCLogger(VTreePanel.class); - - private BorderLayout mainLayout = new BorderLayout(); - private JTree tree = new JTree(); - private AdempiereTreeModel treeModel; - private DefaultTreeSelectionModel treeSelect = new DefaultTreeSelectionModel(); - private CPanel southPanel = new CPanel(); - private CCheckBox treeExpand = new CCheckBox(); - private CTextField treeSearch = new CTextField(10); - private CLabel treeSearchLabel = new CLabel(); - private JPopupMenu popMenuTree = new JPopupMenu(); - private JPopupMenu popMenuBar = new JPopupMenu(); - private CMenuItem mFrom = new CMenuItem(); - private CMenuItem mTo = new CMenuItem(); - private JXTaskPaneContainer bar = new JXTaskPaneContainer(); - private java.util.List toolbar; - private HashMap toolbarMap; - //private int toolBarCols=3; - private CMenuItem mBarAdd = new CMenuItem(); - private CMenuItem mBarRemove = new CMenuItem(); - private BorderLayout southLayout = new BorderLayout(); - private JSplitPane centerSplitPane = new JSplitPane(); - private JScrollPane treePane = new JScrollPane(); - private MouseListener mouseListener = new VTreePanel_mouseAdapter(this); - private KeyListener keyListener = new VTreePanel_keyAdapter(this); - - // - @SuppressWarnings("unused") - private int m_WindowNo; - /** Tree ID */ - private int m_AD_Tree_ID = 0; - /** Table Name for TreeNode */ - @SuppressWarnings("unused") - private String m_nodeTableName = null; - /** Tree is editable (can move nodes) - also not active shown */ - private boolean m_editable; - /** Tree has a shortcut Bar */ - private boolean m_hasBar; - /** The root node */ - private MTreeNode m_root = null; - - - private String m_search = ""; - private Enumeration m_nodeEn; - private MTreeNode m_selectedNode; // the selected model node - private CButton m_buttonSelected; - - private JScrollPane barScrollPane; - - /** Property Listener NodeSelected by Left Click */ - public static final String NODE_SELECTION = "NodeSelected"; - - /** - * Static Component initialization. - *
    -	 *  - centerSplitPane
    -	 *      - treePane
    -	 *          - tree
    -	 *      - bar
    -	 *  - southPanel
    -	 *  
    - */ - private void jbInit() - { - this.setLayout(mainLayout); - mainLayout.setVgap(5); - // - // only one node to be selected - treeSelect.setSelectionMode(DefaultTreeSelectionModel.SINGLE_TREE_SELECTION); - tree.setSelectionModel(treeSelect); - // - tree.setEditable(false); // allows to change the text - tree.addMouseListener(mouseListener); - tree.addKeyListener(keyListener); - tree.setCellRenderer(new VTreeCellRenderer()); - treePane.getViewport().add(tree, null); - treePane.setBorder(new ShadowBorder()); - tree.setBorder(BorderFactory.createEmptyBorder()); - - CPanel treePart = new CPanel(); - treePart.setLayout(new BorderLayout()); - treePart.add(treePane, BorderLayout.CENTER); - treePart.setBorder(BorderFactory.createEmptyBorder()); - - // - treeExpand.setText(Msg.getMsg(Env.getCtx(), "ExpandTree")); - treeExpand.setActionCommand("Expand"); - treeExpand.addMouseListener(mouseListener); - treeExpand.addActionListener(this); - // - treeSearchLabel.setText(Msg.getMsg(Env.getCtx(), "TreeSearch") + " "); - treeSearchLabel.setLabelFor(treeSearch); - treeSearchLabel.setToolTipText(Msg.getMsg(Env.getCtx(), "TreeSearchText")); - - treeSearch.setBackground(AdempierePLAF.getInfoBackground()); - treeSearch.addKeyListener(keyListener); - southPanel.setLayout(southLayout); - southPanel.add(treeExpand, BorderLayout.WEST); - southPanel.add(treeSearchLabel, BorderLayout.CENTER); - southPanel.add(treeSearch, BorderLayout.EAST); - treePart.add(southPanel, BorderLayout.SOUTH); - // - centerSplitPane.setOpaque(false); - barScrollPane = new JScrollPane(); - barScrollPane.getViewport().add(bar); - centerSplitPane.add(barScrollPane, JSplitPane.LEFT); //hengsin, jxtaskpane - centerSplitPane.add(treePart, JSplitPane.RIGHT); - centerSplitPane.setBorder(BorderFactory.createEmptyBorder()); - removeSplitPaneBorder(); - - this.add(centerSplitPane, BorderLayout.CENTER); - - // - mFrom.setText(Msg.getMsg(Env.getCtx(), "ItemMove")); - mFrom.setActionCommand((String)TransferHandler.getCutAction(). - getValue(Action.NAME)); - mFrom.addActionListener(this); - mFrom.setAccelerator( - KeyStroke.getKeyStroke(KeyEvent.VK_X, ActionEvent.CTRL_MASK)); - mTo.setText(Msg.getMsg(Env.getCtx(), "ItemInsert")); - mTo.setActionCommand((String)TransferHandler.getPasteAction(). - getValue(Action.NAME)); - mTo.setAccelerator( - KeyStroke.getKeyStroke(KeyEvent.VK_V, ActionEvent.CTRL_MASK)); - mTo.setMnemonic(KeyEvent.VK_V); - mTo.addActionListener(this); - - mBarAdd.setText(Msg.getMsg(Env.getCtx(), "BarAdd")); - mBarAdd.setActionCommand("BarAdd"); - mBarAdd.addActionListener(this); - mBarRemove.setText(Msg.getMsg(Env.getCtx(), "BarRemove")); - mBarRemove.setActionCommand("BarRemove"); - mBarRemove.addActionListener(this); - // - popMenuTree.setLightWeightPopupEnabled(false); - popMenuTree.add(mBarAdd); - popMenuTree.add(mFrom); - if(!m_hasBar){ - popMenuTree.addSeparator(); - } - popMenuTree.add(mTo); - popMenuBar.setLightWeightPopupEnabled(false); - popMenuBar.add(mBarRemove); - } // jbInit - - - private void removeSplitPaneBorder() { - if (centerSplitPane != null) { - SplitPaneUI splitPaneUI = centerSplitPane.getUI(); - if (splitPaneUI instanceof BasicSplitPaneUI) { - BasicSplitPaneUI basicUI = (BasicSplitPaneUI) splitPaneUI; - basicUI.getDivider().setBorder(BorderFactory.createEmptyBorder()); - } - } - } - - /** - * Set Divider Location - * @param location location (80 default) - */ - public void setDividerLocation(int location) - { - centerSplitPane.setDividerLocation(location); - } // setDividerLocation - - /** - * Get Divider Location - * @return divider location - */ - public int getDividerLocation() - { - return centerSplitPane.getDividerLocation(); - } // getDividerLocation - - - /** - * Enter Key - * @param e event - */ - protected void keyPressed(KeyEvent e) - { - - //CHANGED - document search - if (e.getSource() == treeSearch && treeSearch.getText() != null - && treeSearch.getText().length() > 0 - && treeSearch.getText().substring(0, 1).equals(PREFIX_DOCUMENT_SEARCH)) { - setBusy(true); - DocumentSearch search = new DocumentSearch(); - if (search.openDocumentsByDocumentNo(treeSearch.getText().substring(1))) - treeSearch.setText(null); - setBusy(false); - return; - } - - // *** Tree *** - if (e.getSource() instanceof JTree - || (e.getSource() == treeSearch && e.getModifiersEx() != 0)) // InputEvent.CTRL_MASK - { - TreePath tp = tree.getSelectionPath(); - if (tp == null) - ADialog.beep(); - else - { - MTreeNode tn = (MTreeNode)tp.getLastPathComponent(); - setSelectedNode(tn); - } - } - - // *** treeSearch *** - else if (e.getSource() == treeSearch) - { - String search = treeSearch.getText(); - boolean found = false; - - // at the end - try from top - if (m_nodeEn != null && !m_nodeEn.hasMoreElements()) - m_search = ""; - - // this is the first time - if (!search.equals(m_search)) - { - // get enumeration of all nodes - m_nodeEn = m_root.preorderEnumeration(); - m_search = search; - } - - // search the nodes - while(!found && m_nodeEn != null && m_nodeEn.hasMoreElements()) - { - MTreeNode nd = (MTreeNode)m_nodeEn.nextElement(); - // compare in upper case - if (nd.toString().toUpperCase().indexOf(search.toUpperCase()) != -1) - { - found = true; - TreePath treePath = new TreePath(nd.getPath()); - tree.setSelectionPath(treePath); - tree.makeVisible(treePath); // expand it - tree.scrollPathToVisible(treePath); - } - } - if (!found) - ADialog.beep(); - } // treeSearch - - } // keyPressed - - - /*************************************************************************/ - - /** - * Mouse clicked - * @param e event - */ - protected void mouseClicked(MouseEvent e) - { - // *** JTree *** - if (e.getSource() instanceof JTree) - { - // Left Double Click - if (SwingUtilities.isLeftMouseButton(e) - && e.getClickCount() > 0) - { - int selRow = tree.getRowForLocation(e.getX(), e.getY()); - if(selRow != -1) - { - MTreeNode tn = (MTreeNode)tree.getPathForLocation - (e.getX(), e.getY()).getLastPathComponent(); - setSelectedNode(tn); - } - } - - // Right Click for PopUp - else if ((m_editable || m_hasBar) - && SwingUtilities.isRightMouseButton(e) ) - { - int selRow = tree.getRowForLocation(e.getX(), e.getY()); - if(selRow != -1) - { - tree.setSelectionRow(selRow); - } - if (tree.getSelectionPath() != null) // need select first - { - MTreeNode nd = (MTreeNode)tree.getSelectionPath().getLastPathComponent(); - if (nd.isLeaf()) // only add leaves to bar - mBarAdd.setEnabled(true); - else - mBarAdd.setEnabled(false); - Rectangle r = tree.getPathBounds(tree.getSelectionPath()); - popMenuTree.show(tree, (int)r.getMaxX(), (int)r.getY()); - } - } - } // JTree - - // *** JButton *** - else if (e.getSource() instanceof JButton) - { - if (SwingUtilities.isRightMouseButton(e)) - { - m_buttonSelected = (CButton)e.getSource(); - popMenuBar.show(m_buttonSelected, e.getX(), e.getY()); - } - } // JButton - - } // mouseClicked - - - /** - * Get currently selected node - * @return MTreeNode - */ - public MTreeNode getSelectedNode() - { - return m_selectedNode; - } // getSelectedNode - - /** - * Search Field - * @return Search Field - */ - public JComponent getSearchField() - { - return treeSearch; - } // getSearchField - - /** - * Set Selection to Node in Event - * @param nodeID Node ID - * @return true if selected - */ - public boolean setSelectedNode (int nodeID) - { - if (log.isLoggable(Level.CONFIG)) log.config("ID=" + nodeID); - if (nodeID != -1) // new is -1 - return selectID(nodeID, true); // show selection - return false; - } // setSelectedNode - - /** - * Select ID in Tree - * @param nodeID Node ID - * @param show scroll to node - * @return true if selected - */ - private boolean selectID (int nodeID, boolean show) - { - if (m_root == null) - return false; - if (log.isLoggable(Level.CONFIG)) log.config("NodeID=" + nodeID - + ", Show=" + show + ", root=" + m_root); - // try to find the node - MTreeNode node = m_root.findNode (nodeID); - if (node != null) - { - TreePath treePath = new TreePath(node.getPath()); - if (log.isLoggable(Level.CONFIG)) log.config("Node=" + node - + ", Path=" + treePath.toString()); - tree.setSelectionPath(treePath); - if (show) - { - tree.makeVisible(treePath); // expand it - tree.scrollPathToVisible(treePath); - } - return true; - } - if (log.isLoggable(Level.INFO)) log.info("Node not found; ID=" + nodeID); - return false; - } // selectID - - - /** - * Set the selected node & initiate all listeners - * @param nd node - */ - private void setSelectedNode (MTreeNode nd) - { - if (log.isLoggable(Level.CONFIG)) log.config("Node = " + nd); - m_selectedNode = nd; - // - firePropertyChange(NODE_SELECTION, null, nd); - } // setSelectedNode - - - /************************************************************************** - * Node Changed - synchronize Node - * - * @param save true the node was saved (changed/added), false if the row was deleted - * @param keyID the ID of the row changed - * @param name name - * @param description description - * @param isSummary summary node - * @param imageIndicator image indicator - */ - public void nodeChanged (boolean save, int keyID, - String name, String description, boolean isSummary, String imageIndicator) - { - if (log.isLoggable(Level.CONFIG)) log.config("Save=" + save + ", KeyID=" + keyID - + ", Name=" + name + ", Description=" + description - + ", IsSummary=" + isSummary + ", ImageInd=" + imageIndicator - + ", root=" + m_root); - // if ID==0=root - don't update it - if (keyID == 0) - return; - - // try to find the node - MTreeNode node = m_root.findNode(keyID); - - // Node not found and saved -> new - if (node == null && save) - { - node = new MTreeNode (keyID, 0, name, description, - m_root.getNode_ID(), isSummary, imageIndicator, false, null); - m_root.add (node); - } - - // Node found and saved -> change - else if (node != null && save) - { - node.setName (name); - node.setAllowsChildren(isSummary); - } - - // Node found and not saved -> delete - else if (node != null && !save) - { - MTreeNode parent = (MTreeNode)node.getParent(); - node.removeFromParent(); - node = parent; // select Parent - } - - // Error - else - { - log.log(Level.SEVERE, "Save=" + save + ", KeyID=" + keyID + ", Node=" + node); - node = null; - } - - // Nothing to display - if (node == null) - return; - - // (Re) Display Node - tree.updateUI(); - TreePath treePath = new TreePath(node.getPath()); - tree.setSelectionPath(treePath); - tree.makeVisible(treePath); // expand it - tree.scrollPathToVisible(treePath); - } // nodeChanged - - - /************************************************************************** - * ActionListener - * @param e event - */ - public void actionPerformed(ActionEvent e) - { - // bar button pressed - if (e.getSource() instanceof JButton) - { - // Find Node - don't show - selectID(Integer.parseInt(e.getActionCommand()), false); - // Select it - MTreeNode tn = (MTreeNode)tree.getSelectionPath().getLastPathComponent(); - setSelectedNode(tn); - } - - // popup menu commands - else if (e.getSource() instanceof JMenuItem) - { - String action = (String)e.getActionCommand(); - Action a = tree.getActionMap().get(action); - if (a != null) { - a.actionPerformed(new ActionEvent(tree, - ActionEvent.ACTION_PERFORMED, - null)); - } - else if (action.equals("BarAdd")) - barAdd(); - else if (action.equals("BarRemove")) - barRemove(); - } - - else if (e.getSource() instanceof JCheckBox) - { - if (e.getActionCommand().equals("Expand")) - expandTree(); - } - } // actionPerformed - - /** - * Add selected TreeNode to Bar - */ - private void barAdd() - { - MTreeNode nd = (MTreeNode)tree.getSelectionPath().getLastPathComponent(); - if (barDBupdate(true, nd.getNode_ID())) - addToBar(nd,getParentToolBar(nd), false); - else if (DBException.isUniqueContraintError(CLogger.retrieveException())) - ADialog.error(0, this, "BookmarkExist", null); - } // barAdd - - /** - * Returns the top level parent JToolBar for the given MTreenode. If the parent is not on - * the CPanel yet a new one is created and added. - * @param nd - * @return top level parent JToolBar for the given MTreenode - */ - private JToolBar getParentToolBar(MTreeNode nd){ - int topParentId = getTopParentId(nd); - JToolBar parent = toolbarMap.get(topParentId); - if(parent==null){ - Enumeration enTop =m_root.children(); - while (enTop.hasMoreElements()) { - MTreeNode ndTop = (MTreeNode)enTop.nextElement(); - if(ndTop.getNode_ID()==topParentId){ - if (log.isLoggable(Level.FINE)) log.fine("add new category: " + ndTop); - parent = new JToolBar(JToolBar.VERTICAL); - - toolbarMap.put(ndTop.getNode_ID(), parent); - toolbar.add(parent); - parent.setOpaque(false); - parent.setFloatable(false); - parent.setRollover(true); - parent.setBorder(BorderFactory.createEmptyBorder()); - - JXTaskPane barPart = new JXTaskPane(); - //Begin - [FR 1953769] - barPart.setUI(new AdempiereTaskPaneUI()); - barPart.getContentPane().setBackground(AdempierePLAF.getFormBackground()); - //End - [FR 1953769] - barPart.setTitle(ndTop.toString().trim()); - barPart.setAnimated(true); - barPart.setLayout(new BorderLayout()); - barPart.add(parent, BorderLayout.NORTH); - - bar.add(barPart); - return parent; - } - } - } else { - if (log.isLoggable(Level.FINE)) log.fine("parent found: " + parent); - } - return parent; - } - - /** - * Returns the id of the top level parent of the given MTreenode - * @param nd - * @return - */ - private int getTopParentId(MTreeNode nd) { - MTreeNode parent = (MTreeNode) nd.getParent(); - if(parent!=null && parent.getNode_ID()!=0){ - return getTopParentId(parent); - } - return nd.getNode_ID(); - } - - /** - * Add TreeNode to Bar - * @param nd node - */ - private void addToBar(MTreeNode nd, JToolBar currentToolBar, boolean isLabel) - { - // Only first word of Label - String label = nd.toString().trim(); - // int space = label.indexOf(' '); - // if (space != -1) - // label = label.substring(0, space); - - if (!isLabel) { - CButton button = new CButton(label); - button.setOpaque(false); - button.setHorizontalAlignment(JButton.LEFT); - button.setMargin(new Insets(0, 0, 0, 0)); - button.setIcon(nd.getIcon()); - button.setRequestFocusEnabled(false); - button.setToolTipText(nd.getDescription()); - button.setActionCommand(String.valueOf(nd.getNode_ID())); - button.addActionListener(this); - button.addMouseListener(mouseListener); - currentToolBar.add(button); - } else { - currentToolBar.add(new JLabel("" +label+"")); - } - bar.validate(); - //if (centerSplitPane.getDividerLocation() == -1) - // centerSplitPane.setDividerLocation(button.getPreferredSize().width); - bar.repaint(); - } // addToBar - - /** - * Remove from Bar - */ - private void barRemove() - { - /* - * Sidebar Hierachie: - * JXTaskPaneContainer (instance variable: bar) - * --JXTaskPane (parentPanel) - * ----JXCollapsiblePane - * ------JXCollapsiblePane$WrapperContainer - * --------JXPanel - * ----------JToolBar (parentBar) - */ - - //The button in on a JToolBar - JToolBar parentBar = (JToolBar) m_buttonSelected.getParent(); - - //Get JXTaskPane for JToolBar (we want to remove this one from the "bar" if there are no more nodes) - Container parentPanel = null; - if(parentBar!=null){ - parentPanel = parentBar.getParent().getParent().getParent().getParent(); - } - - //Remove the entry from the JToolBar - for (JToolBar jt : toolbar) { - jt.remove(m_buttonSelected); - } - - //If we found the JXTaskPane for our toolbar and the toolbar is now empty, we want to remove the whole JXTaskPane - if(parentPanel != null && parentBar.getComponentCount()==0){ - - //Remove JXTaskPane from JXTaskPaneContainer - bar.remove(parentPanel); - - //Remove JToolBar from the toolBarMap.. - toolbarMap.values().remove(parentBar); - - } - - //Recreate the Sidebar - bar.validate(); - bar.repaint(); - - //Persist the changes - barDBupdate(false, Integer.parseInt(m_buttonSelected.getActionCommand())); - } // barRemove - - /** - * Make Bar add/remove persistent - * @param add true if add - otherwise remove - * @param Node_ID Node ID - * @return true if updated - */ - private boolean barDBupdate (boolean add, int Node_ID) - { - int AD_Client_ID = Env.getAD_Client_ID(Env.getCtx()); - int AD_Org_ID = Env.getContextAsInt(Env.getCtx(), "#AD_Org_ID"); - int AD_User_ID = Env.getContextAsInt(Env.getCtx(), "#AD_User_ID"); - StringBuilder sql = new StringBuilder(); - if (add) - sql.append("INSERT INTO AD_TreeBar " - + "(AD_Tree_ID,AD_User_ID,Node_ID, " - + "AD_Client_ID,AD_Org_ID, " - + "IsActive,Created,CreatedBy,Updated,UpdatedBy)VALUES (") - .append(m_AD_Tree_ID).append(",").append(AD_User_ID).append(",").append(Node_ID).append(",") - .append(AD_Client_ID).append(",").append(AD_Org_ID).append(",") - .append("'Y',SysDate,").append(AD_User_ID).append(",SysDate,").append(AD_User_ID).append(")"); - // if already exist, will result in ORA-00001: unique constraint (ADEMPIERE.AD_TREEBAR_KEY) - else - sql.append("DELETE AD_TreeBar WHERE AD_Tree_ID=").append(m_AD_Tree_ID) - .append(" AND AD_User_ID=").append(AD_User_ID) - .append(" AND Node_ID=").append(Node_ID); - int no = DB.executeUpdate(sql.toString(), false, null); - return no == 1; - } // barDBupdate - - // Auto Expand Tree - nmicoud IDEMPIERE 195 - /** - * Expand/Collapse tree - * @param expand true if tree should be expanded - */ - public void expandTree(boolean expand) - { - treeExpand.setSelected(expand); - expandTree(); - } - - /** - * Clicked on Expand All - */ - private void expandTree() - { - if (treeExpand.isSelected()) - { - for (int row = 0; row < tree.getRowCount(); row++) - tree.expandRow(row); - } - else - { -// patch: 1654055 +jgubo Changed direction of collapsing the tree nodes - for (int row = tree.getRowCount(); row > 0; row--) - tree.collapseRow(row); - } - } // expandTree - - @Override - public void paint(Graphics g) { - if (m_lookAndFeelChanged) { - m_lookAndFeelChanged = false; - if (m_hasBar) removeSplitPaneBorder(); - } - super.paint(g); - } - - private void setMappings(JTree tree) { - ActionMap map = tree.getActionMap(); - map.put(TransferHandler.getCutAction().getValue(Action.NAME), - TransferHandler.getCutAction()); - map.put(TransferHandler.getPasteAction().getValue(Action.NAME), - TransferHandler.getPasteAction()); - } - - //CHANGED - SET BUSY ADDED - /** - * Indicate Busy - * @param busy busy - */ - private void setBusy (boolean busy) - { - JFrame frame = AEnv.getFrame(this); - if (log.isLoggable(Level.INFO)) log.info("frame: " + frame); - if (frame == null) // during init - return; - if (busy) - { - this.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); - frame.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); - treeSearch.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); - } - else - { - this.setCursor(Cursor.getDefaultCursor()); - frame.setCursor(Cursor.getDefaultCursor()); - treeSearch.setCursor(Cursor.getDefaultCursor()); - } - } // set Busy - -} // VTreePanel - - - - diff --git a/org.adempiere.ui.swing/src/org/compiere/grid/tree/VTreeTransferHandler.java b/org.adempiere.ui.swing/src/org/compiere/grid/tree/VTreeTransferHandler.java deleted file mode 100644 index 11790db96d..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/grid/tree/VTreeTransferHandler.java +++ /dev/null @@ -1,124 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ -package org.compiere.grid.tree; - -import java.awt.datatransfer.Transferable; - -import javax.swing.JComponent; -import javax.swing.JTree; -import javax.swing.TransferHandler; -import javax.swing.tree.DefaultTreeModel; -import javax.swing.tree.TreePath; - -import org.compiere.model.MTreeNode; - -/** - * VTreeTransferHandler provides the TransferHandler for dragging and dropping - * within a tree. See VTreePanel. - * - * - * @author phib 2008/07/30 - * FR [ 2032092 ] Java 6 improvements to tree drag and drop - */ -public class VTreeTransferHandler extends TransferHandler { - - - /** - * - */ - private static final long serialVersionUID = 2799737958477528717L; - - public int getSourceActions(JComponent c) { - return TransferHandler.MOVE; - } - - protected Transferable createTransferable(JComponent c) { - JTree tree = (JTree) c; - MTreeNode node = (MTreeNode) tree.getSelectionPath().getLastPathComponent(); - return new TransferableTreeNode(node); - } - - protected void exportDone(JComponent c, Transferable t, int action) { - if (action == MOVE) { - JTree tree = (JTree) c; - MTreeNode node = null; - try { - node = (MTreeNode) t.getTransferData(TransferableTreeNode.TREE_NODE_FLAVOR); - } catch (Exception e) { - // ignore - } - - if ( node != null ) - ((DefaultTreeModel) tree.getModel()).removeNodeFromParent(node); - } - } - - public boolean canImport(TransferSupport info) { - // Check for flavor - if (!info.isDataFlavorSupported(TransferableTreeNode.TREE_NODE_FLAVOR)) { - return false; - } - return true; - } - - public boolean importData(TransferHandler.TransferSupport info) { - if (!canImport(info)) - return false; - - JTree tree = (JTree) info.getComponent(); - AdempiereTreeModel model = (AdempiereTreeModel) tree.getModel(); - Transferable t = info.getTransferable(); - MTreeNode to = null; - MTreeNode from = null; - int index; - try { - from = (MTreeNode)t.getTransferData(TransferableTreeNode.TREE_NODE_FLAVOR); - } - catch (Exception e) { return false; } - - if (info.isDrop()) { - JTree.DropLocation dl = (JTree.DropLocation)info.getDropLocation(); - to = (MTreeNode) dl.getPath().getLastPathComponent(); - - if (from == to) - return false; - - index = dl.getChildIndex(); - if ( index == -1 ) - index = 0; // insert as first child - - } - else { // it's a paste - MTreeNode selected = (MTreeNode) tree.getSelectionPath().getLastPathComponent(); - if ( selected.isLeaf() ) { - to = (MTreeNode) selected.getParent(); - index = to.getIndex(selected) + 1; // insert after selected - } - else { - to = selected; - index = 0; - } - } - - model.insertNodeInto(from, to, index); - tree.scrollPathToVisible(new TreePath(from.getPath())); // display from's new location - model.saveChangedNodes(from, to); - - return true; - } - -} diff --git a/org.adempiere.ui.swing/src/org/compiere/images/About16.gif b/org.adempiere.ui.swing/src/org/compiere/images/About16.gif deleted file mode 100644 index 29ccad7ce9..0000000000 Binary files a/org.adempiere.ui.swing/src/org/compiere/images/About16.gif and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/compiere/images/About24.gif b/org.adempiere.ui.swing/src/org/compiere/images/About24.gif deleted file mode 100644 index c7b75a4989..0000000000 Binary files a/org.adempiere.ui.swing/src/org/compiere/images/About24.gif and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/compiere/images/Account10.gif b/org.adempiere.ui.swing/src/org/compiere/images/Account10.gif deleted file mode 100644 index 946e2f76e1..0000000000 Binary files a/org.adempiere.ui.swing/src/org/compiere/images/Account10.gif and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/compiere/images/Account16.gif b/org.adempiere.ui.swing/src/org/compiere/images/Account16.gif deleted file mode 100644 index ce11b27b7e..0000000000 Binary files a/org.adempiere.ui.swing/src/org/compiere/images/Account16.gif and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/compiere/images/Account24.gif b/org.adempiere.ui.swing/src/org/compiere/images/Account24.gif deleted file mode 100644 index d5ae52789d..0000000000 Binary files a/org.adempiere.ui.swing/src/org/compiere/images/Account24.gif and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/compiere/images/Archive16.gif b/org.adempiere.ui.swing/src/org/compiere/images/Archive16.gif deleted file mode 100644 index 60cade46c9..0000000000 Binary files a/org.adempiere.ui.swing/src/org/compiere/images/Archive16.gif and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/compiere/images/Archive24.gif b/org.adempiere.ui.swing/src/org/compiere/images/Archive24.gif deleted file mode 100644 index 7228d4a3a2..0000000000 Binary files a/org.adempiere.ui.swing/src/org/compiere/images/Archive24.gif and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/compiere/images/Assignment10.gif b/org.adempiere.ui.swing/src/org/compiere/images/Assignment10.gif deleted file mode 100644 index 5687a12223..0000000000 Binary files a/org.adempiere.ui.swing/src/org/compiere/images/Assignment10.gif and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/compiere/images/Assignment16.gif b/org.adempiere.ui.swing/src/org/compiere/images/Assignment16.gif deleted file mode 100644 index 1a55d27d5e..0000000000 Binary files a/org.adempiere.ui.swing/src/org/compiere/images/Assignment16.gif and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/compiere/images/Assignment24.gif b/org.adempiere.ui.swing/src/org/compiere/images/Assignment24.gif deleted file mode 100644 index a5df65948e..0000000000 Binary files a/org.adempiere.ui.swing/src/org/compiere/images/Assignment24.gif and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/compiere/images/Attachment16.gif b/org.adempiere.ui.swing/src/org/compiere/images/Attachment16.gif deleted file mode 100644 index 00194ee31e..0000000000 Binary files a/org.adempiere.ui.swing/src/org/compiere/images/Attachment16.gif and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/compiere/images/Attachment24.gif b/org.adempiere.ui.swing/src/org/compiere/images/Attachment24.gif deleted file mode 100644 index 91fe440fe0..0000000000 Binary files a/org.adempiere.ui.swing/src/org/compiere/images/Attachment24.gif and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/compiere/images/Attachment24D.gif b/org.adempiere.ui.swing/src/org/compiere/images/Attachment24D.gif deleted file mode 100755 index 91fe440fe0..0000000000 Binary files a/org.adempiere.ui.swing/src/org/compiere/images/Attachment24D.gif and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/compiere/images/AttachmentX16.gif b/org.adempiere.ui.swing/src/org/compiere/images/AttachmentX16.gif deleted file mode 100644 index 98fc568e95..0000000000 Binary files a/org.adempiere.ui.swing/src/org/compiere/images/AttachmentX16.gif and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/compiere/images/AttachmentX16_grey.gif b/org.adempiere.ui.swing/src/org/compiere/images/AttachmentX16_grey.gif deleted file mode 100644 index 6b710c29e4..0000000000 Binary files a/org.adempiere.ui.swing/src/org/compiere/images/AttachmentX16_grey.gif and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/compiere/images/AttachmentX24.gif b/org.adempiere.ui.swing/src/org/compiere/images/AttachmentX24.gif deleted file mode 100644 index 03907e8afa..0000000000 Binary files a/org.adempiere.ui.swing/src/org/compiere/images/AttachmentX24.gif and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/compiere/images/BPartner10.gif b/org.adempiere.ui.swing/src/org/compiere/images/BPartner10.gif deleted file mode 100644 index c49970aaf4..0000000000 Binary files a/org.adempiere.ui.swing/src/org/compiere/images/BPartner10.gif and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/compiere/images/BPartner16.gif b/org.adempiere.ui.swing/src/org/compiere/images/BPartner16.gif deleted file mode 100644 index 10dfb4c7f3..0000000000 Binary files a/org.adempiere.ui.swing/src/org/compiere/images/BPartner16.gif and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/compiere/images/BPartner24.gif b/org.adempiere.ui.swing/src/org/compiere/images/BPartner24.gif deleted file mode 100644 index 001fb00c67..0000000000 Binary files a/org.adempiere.ui.swing/src/org/compiere/images/BPartner24.gif and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/compiere/images/Bold16.gif b/org.adempiere.ui.swing/src/org/compiere/images/Bold16.gif deleted file mode 100644 index c9cb630343..0000000000 Binary files a/org.adempiere.ui.swing/src/org/compiere/images/Bold16.gif and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/compiere/images/C10030HR.png b/org.adempiere.ui.swing/src/org/compiere/images/C10030HR.png deleted file mode 100644 index e5cd1f7b4f..0000000000 Binary files a/org.adempiere.ui.swing/src/org/compiere/images/C10030HR.png and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/compiere/images/Calculator10.gif b/org.adempiere.ui.swing/src/org/compiere/images/Calculator10.gif deleted file mode 100644 index 2a31f0ab06..0000000000 Binary files a/org.adempiere.ui.swing/src/org/compiere/images/Calculator10.gif and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/compiere/images/Calculator16.gif b/org.adempiere.ui.swing/src/org/compiere/images/Calculator16.gif deleted file mode 100644 index 9248971a91..0000000000 Binary files a/org.adempiere.ui.swing/src/org/compiere/images/Calculator16.gif and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/compiere/images/Calculator24.gif b/org.adempiere.ui.swing/src/org/compiere/images/Calculator24.gif deleted file mode 100644 index 99bfd16c17..0000000000 Binary files a/org.adempiere.ui.swing/src/org/compiere/images/Calculator24.gif and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/compiere/images/Calendar10.gif b/org.adempiere.ui.swing/src/org/compiere/images/Calendar10.gif deleted file mode 100644 index 58dc763f64..0000000000 Binary files a/org.adempiere.ui.swing/src/org/compiere/images/Calendar10.gif and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/compiere/images/Calendar16.gif b/org.adempiere.ui.swing/src/org/compiere/images/Calendar16.gif deleted file mode 100644 index f6978d7d3b..0000000000 Binary files a/org.adempiere.ui.swing/src/org/compiere/images/Calendar16.gif and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/compiere/images/Calendar24.gif b/org.adempiere.ui.swing/src/org/compiere/images/Calendar24.gif deleted file mode 100644 index 0c224e9f01..0000000000 Binary files a/org.adempiere.ui.swing/src/org/compiere/images/Calendar24.gif and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/compiere/images/Cancel10.gif b/org.adempiere.ui.swing/src/org/compiere/images/Cancel10.gif deleted file mode 100644 index 564b151820..0000000000 Binary files a/org.adempiere.ui.swing/src/org/compiere/images/Cancel10.gif and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/compiere/images/Cancel16.gif b/org.adempiere.ui.swing/src/org/compiere/images/Cancel16.gif deleted file mode 100644 index 9beb8fcec1..0000000000 Binary files a/org.adempiere.ui.swing/src/org/compiere/images/Cancel16.gif and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/compiere/images/Cancel24.gif b/org.adempiere.ui.swing/src/org/compiere/images/Cancel24.gif deleted file mode 100644 index d91a52dc0c..0000000000 Binary files a/org.adempiere.ui.swing/src/org/compiere/images/Cancel24.gif and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/compiere/images/ChangeLog16.png b/org.adempiere.ui.swing/src/org/compiere/images/ChangeLog16.png deleted file mode 100644 index 2c367d351a..0000000000 Binary files a/org.adempiere.ui.swing/src/org/compiere/images/ChangeLog16.png and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/compiere/images/Chat16.gif b/org.adempiere.ui.swing/src/org/compiere/images/Chat16.gif deleted file mode 100644 index f6e83254b6..0000000000 Binary files a/org.adempiere.ui.swing/src/org/compiere/images/Chat16.gif and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/compiere/images/Chat24.gif b/org.adempiere.ui.swing/src/org/compiere/images/Chat24.gif deleted file mode 100644 index 3cac5dfcdd..0000000000 Binary files a/org.adempiere.ui.swing/src/org/compiere/images/Chat24.gif and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/compiere/images/ChatX16.gif b/org.adempiere.ui.swing/src/org/compiere/images/ChatX16.gif deleted file mode 100644 index f6e83254b6..0000000000 Binary files a/org.adempiere.ui.swing/src/org/compiere/images/ChatX16.gif and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/compiere/images/ChatX24.gif b/org.adempiere.ui.swing/src/org/compiere/images/ChatX24.gif deleted file mode 100644 index 3cac5dfcdd..0000000000 Binary files a/org.adempiere.ui.swing/src/org/compiere/images/ChatX24.gif and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/compiere/images/Copy16.gif b/org.adempiere.ui.swing/src/org/compiere/images/Copy16.gif deleted file mode 100644 index 8dd48c4949..0000000000 Binary files a/org.adempiere.ui.swing/src/org/compiere/images/Copy16.gif and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/compiere/images/Copy24.gif b/org.adempiere.ui.swing/src/org/compiere/images/Copy24.gif deleted file mode 100644 index 345b2f1d7c..0000000000 Binary files a/org.adempiere.ui.swing/src/org/compiere/images/Copy24.gif and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/compiere/images/Customize16.gif b/org.adempiere.ui.swing/src/org/compiere/images/Customize16.gif deleted file mode 100644 index 68f916c9d3..0000000000 Binary files a/org.adempiere.ui.swing/src/org/compiere/images/Customize16.gif and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/compiere/images/Customize24.gif b/org.adempiere.ui.swing/src/org/compiere/images/Customize24.gif deleted file mode 100644 index c359063ced..0000000000 Binary files a/org.adempiere.ui.swing/src/org/compiere/images/Customize24.gif and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/compiere/images/Delete16.gif b/org.adempiere.ui.swing/src/org/compiere/images/Delete16.gif deleted file mode 100644 index 0e0953c73c..0000000000 Binary files a/org.adempiere.ui.swing/src/org/compiere/images/Delete16.gif and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/compiere/images/Delete24.gif b/org.adempiere.ui.swing/src/org/compiere/images/Delete24.gif deleted file mode 100644 index 86913615bb..0000000000 Binary files a/org.adempiere.ui.swing/src/org/compiere/images/Delete24.gif and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/compiere/images/DeleteSelection16.gif b/org.adempiere.ui.swing/src/org/compiere/images/DeleteSelection16.gif deleted file mode 100644 index e7c11c8336..0000000000 Binary files a/org.adempiere.ui.swing/src/org/compiere/images/DeleteSelection16.gif and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/compiere/images/DeleteSelection24.gif b/org.adempiere.ui.swing/src/org/compiere/images/DeleteSelection24.gif deleted file mode 100644 index 2aee61d8da..0000000000 Binary files a/org.adempiere.ui.swing/src/org/compiere/images/DeleteSelection24.gif and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/compiere/images/Detail16.gif b/org.adempiere.ui.swing/src/org/compiere/images/Detail16.gif deleted file mode 100644 index 6ef8de76e0..0000000000 Binary files a/org.adempiere.ui.swing/src/org/compiere/images/Detail16.gif and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/compiere/images/Detail24.gif b/org.adempiere.ui.swing/src/org/compiere/images/Detail24.gif deleted file mode 100644 index 6f3f65d33d..0000000000 Binary files a/org.adempiere.ui.swing/src/org/compiere/images/Detail24.gif and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/compiere/images/DragCursor32.gif b/org.adempiere.ui.swing/src/org/compiere/images/DragCursor32.gif deleted file mode 100644 index 94a646189d..0000000000 Binary files a/org.adempiere.ui.swing/src/org/compiere/images/DragCursor32.gif and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/compiere/images/EMailSupport16.gif b/org.adempiere.ui.swing/src/org/compiere/images/EMailSupport16.gif deleted file mode 100644 index 7c68cb8d35..0000000000 Binary files a/org.adempiere.ui.swing/src/org/compiere/images/EMailSupport16.gif and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/compiere/images/EMailSupport24.gif b/org.adempiere.ui.swing/src/org/compiere/images/EMailSupport24.gif deleted file mode 100644 index 96ae0e9077..0000000000 Binary files a/org.adempiere.ui.swing/src/org/compiere/images/EMailSupport24.gif and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/compiere/images/Edit16.gif b/org.adempiere.ui.swing/src/org/compiere/images/Edit16.gif deleted file mode 100644 index 188e1c12bd..0000000000 Binary files a/org.adempiere.ui.swing/src/org/compiere/images/Edit16.gif and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/compiere/images/Edit24.gif b/org.adempiere.ui.swing/src/org/compiere/images/Edit24.gif deleted file mode 100644 index c3d245dece..0000000000 Binary files a/org.adempiere.ui.swing/src/org/compiere/images/Edit24.gif and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/compiere/images/Editor16.gif b/org.adempiere.ui.swing/src/org/compiere/images/Editor16.gif deleted file mode 100644 index 188e1c12bd..0000000000 Binary files a/org.adempiere.ui.swing/src/org/compiere/images/Editor16.gif and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/compiere/images/Editor24.gif b/org.adempiere.ui.swing/src/org/compiere/images/Editor24.gif deleted file mode 100644 index c3d245dece..0000000000 Binary files a/org.adempiere.ui.swing/src/org/compiere/images/Editor24.gif and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/compiere/images/End16.gif b/org.adempiere.ui.swing/src/org/compiere/images/End16.gif deleted file mode 100644 index 6a8d206a84..0000000000 Binary files a/org.adempiere.ui.swing/src/org/compiere/images/End16.gif and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/compiere/images/End24.gif b/org.adempiere.ui.swing/src/org/compiere/images/End24.gif deleted file mode 100644 index 2aeb66bce0..0000000000 Binary files a/org.adempiere.ui.swing/src/org/compiere/images/End24.gif and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/compiere/images/Error32.gif b/org.adempiere.ui.swing/src/org/compiere/images/Error32.gif deleted file mode 100644 index cdd95bade1..0000000000 Binary files a/org.adempiere.ui.swing/src/org/compiere/images/Error32.gif and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/compiere/images/Exit16.gif b/org.adempiere.ui.swing/src/org/compiere/images/Exit16.gif deleted file mode 100644 index 1ce05410f5..0000000000 Binary files a/org.adempiere.ui.swing/src/org/compiere/images/Exit16.gif and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/compiere/images/Exit24.gif b/org.adempiere.ui.swing/src/org/compiere/images/Exit24.gif deleted file mode 100644 index 58e9c41863..0000000000 Binary files a/org.adempiere.ui.swing/src/org/compiere/images/Exit24.gif and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/compiere/images/Export16.gif b/org.adempiere.ui.swing/src/org/compiere/images/Export16.gif deleted file mode 100644 index 9bed1436ef..0000000000 Binary files a/org.adempiere.ui.swing/src/org/compiere/images/Export16.gif and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/compiere/images/Export16X.gif b/org.adempiere.ui.swing/src/org/compiere/images/Export16X.gif deleted file mode 100755 index 9bed1436ef..0000000000 Binary files a/org.adempiere.ui.swing/src/org/compiere/images/Export16X.gif and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/compiere/images/Export24.gif b/org.adempiere.ui.swing/src/org/compiere/images/Export24.gif deleted file mode 100644 index 340a87eec0..0000000000 Binary files a/org.adempiere.ui.swing/src/org/compiere/images/Export24.gif and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/compiere/images/Export24X.gif b/org.adempiere.ui.swing/src/org/compiere/images/Export24X.gif deleted file mode 100755 index 340a87eec0..0000000000 Binary files a/org.adempiere.ui.swing/src/org/compiere/images/Export24X.gif and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/compiere/images/ExportX16.gif b/org.adempiere.ui.swing/src/org/compiere/images/ExportX16.gif deleted file mode 100644 index 9bed1436ef..0000000000 Binary files a/org.adempiere.ui.swing/src/org/compiere/images/ExportX16.gif and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/compiere/images/ExportX24.gif b/org.adempiere.ui.swing/src/org/compiere/images/ExportX24.gif deleted file mode 100644 index 340a87eec0..0000000000 Binary files a/org.adempiere.ui.swing/src/org/compiere/images/ExportX24.gif and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/compiere/images/FastBack24.gif b/org.adempiere.ui.swing/src/org/compiere/images/FastBack24.gif deleted file mode 100644 index e094d12282..0000000000 Binary files a/org.adempiere.ui.swing/src/org/compiere/images/FastBack24.gif and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/compiere/images/FastForward24.gif b/org.adempiere.ui.swing/src/org/compiere/images/FastForward24.gif deleted file mode 100644 index b9c2c6c8ed..0000000000 Binary files a/org.adempiere.ui.swing/src/org/compiere/images/FastForward24.gif and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/compiere/images/Find16.gif b/org.adempiere.ui.swing/src/org/compiere/images/Find16.gif deleted file mode 100644 index fd7f0b07a5..0000000000 Binary files a/org.adempiere.ui.swing/src/org/compiere/images/Find16.gif and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/compiere/images/Find24.gif b/org.adempiere.ui.swing/src/org/compiere/images/Find24.gif deleted file mode 100644 index 4e522b23d8..0000000000 Binary files a/org.adempiere.ui.swing/src/org/compiere/images/Find24.gif and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/compiere/images/FindX16.gif b/org.adempiere.ui.swing/src/org/compiere/images/FindX16.gif deleted file mode 100644 index aff8fce620..0000000000 Binary files a/org.adempiere.ui.swing/src/org/compiere/images/FindX16.gif and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/compiere/images/FindX24.gif b/org.adempiere.ui.swing/src/org/compiere/images/FindX24.gif deleted file mode 100644 index 986df47d49..0000000000 Binary files a/org.adempiere.ui.swing/src/org/compiere/images/FindX24.gif and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/compiere/images/First16.gif b/org.adempiere.ui.swing/src/org/compiere/images/First16.gif deleted file mode 100644 index 70f2c996cd..0000000000 Binary files a/org.adempiere.ui.swing/src/org/compiere/images/First16.gif and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/compiere/images/First24.gif b/org.adempiere.ui.swing/src/org/compiere/images/First24.gif deleted file mode 100644 index 96f98dd205..0000000000 Binary files a/org.adempiere.ui.swing/src/org/compiere/images/First24.gif and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/compiere/images/First24D.gif b/org.adempiere.ui.swing/src/org/compiere/images/First24D.gif deleted file mode 100755 index 96f98dd205..0000000000 Binary files a/org.adempiere.ui.swing/src/org/compiere/images/First24D.gif and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/compiere/images/Folder16.gif b/org.adempiere.ui.swing/src/org/compiere/images/Folder16.gif deleted file mode 100755 index 901edc9624..0000000000 Binary files a/org.adempiere.ui.swing/src/org/compiere/images/Folder16.gif and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/compiere/images/Folder24.gif b/org.adempiere.ui.swing/src/org/compiere/images/Folder24.gif deleted file mode 100755 index 54898f33c7..0000000000 Binary files a/org.adempiere.ui.swing/src/org/compiere/images/Folder24.gif and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/compiere/images/GetMail16.gif b/org.adempiere.ui.swing/src/org/compiere/images/GetMail16.gif deleted file mode 100644 index a9c4bd39f8..0000000000 Binary files a/org.adempiere.ui.swing/src/org/compiere/images/GetMail16.gif and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/compiere/images/GetMail24.gif b/org.adempiere.ui.swing/src/org/compiere/images/GetMail24.gif deleted file mode 100644 index 02abb6cbd6..0000000000 Binary files a/org.adempiere.ui.swing/src/org/compiere/images/GetMail24.gif and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/compiere/images/Help16.gif b/org.adempiere.ui.swing/src/org/compiere/images/Help16.gif deleted file mode 100644 index f25fc3fbf1..0000000000 Binary files a/org.adempiere.ui.swing/src/org/compiere/images/Help16.gif and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/compiere/images/Help24.gif b/org.adempiere.ui.swing/src/org/compiere/images/Help24.gif deleted file mode 100644 index c67c7a60ef..0000000000 Binary files a/org.adempiere.ui.swing/src/org/compiere/images/Help24.gif and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/compiere/images/History16.gif b/org.adempiere.ui.swing/src/org/compiere/images/History16.gif deleted file mode 100644 index 39ab127405..0000000000 Binary files a/org.adempiere.ui.swing/src/org/compiere/images/History16.gif and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/compiere/images/History24.gif b/org.adempiere.ui.swing/src/org/compiere/images/History24.gif deleted file mode 100644 index 8bb037b3db..0000000000 Binary files a/org.adempiere.ui.swing/src/org/compiere/images/History24.gif and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/compiere/images/History24D.gif b/org.adempiere.ui.swing/src/org/compiere/images/History24D.gif deleted file mode 100755 index 8bb037b3db..0000000000 Binary files a/org.adempiere.ui.swing/src/org/compiere/images/History24D.gif and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/compiere/images/HistoryX16.gif b/org.adempiere.ui.swing/src/org/compiere/images/HistoryX16.gif deleted file mode 100644 index 39ab127405..0000000000 Binary files a/org.adempiere.ui.swing/src/org/compiere/images/HistoryX16.gif and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/compiere/images/HistoryX24.gif b/org.adempiere.ui.swing/src/org/compiere/images/HistoryX24.gif deleted file mode 100644 index 8bb037b3db..0000000000 Binary files a/org.adempiere.ui.swing/src/org/compiere/images/HistoryX24.gif and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/compiere/images/Home16.gif b/org.adempiere.ui.swing/src/org/compiere/images/Home16.gif deleted file mode 100644 index a46fb22206..0000000000 Binary files a/org.adempiere.ui.swing/src/org/compiere/images/Home16.gif and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/compiere/images/Home24.gif b/org.adempiere.ui.swing/src/org/compiere/images/Home24.gif deleted file mode 100644 index 9d62109aa8..0000000000 Binary files a/org.adempiere.ui.swing/src/org/compiere/images/Home24.gif and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/compiere/images/Ignore16.gif b/org.adempiere.ui.swing/src/org/compiere/images/Ignore16.gif deleted file mode 100644 index 8b0fef9a83..0000000000 Binary files a/org.adempiere.ui.swing/src/org/compiere/images/Ignore16.gif and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/compiere/images/Ignore24.gif b/org.adempiere.ui.swing/src/org/compiere/images/Ignore24.gif deleted file mode 100644 index f37c6963d5..0000000000 Binary files a/org.adempiere.ui.swing/src/org/compiere/images/Ignore24.gif and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/compiere/images/Import16.gif b/org.adempiere.ui.swing/src/org/compiere/images/Import16.gif deleted file mode 100644 index 4ab50de487..0000000000 Binary files a/org.adempiere.ui.swing/src/org/compiere/images/Import16.gif and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/compiere/images/Import24.gif b/org.adempiere.ui.swing/src/org/compiere/images/Import24.gif deleted file mode 100644 index 44641e887b..0000000000 Binary files a/org.adempiere.ui.swing/src/org/compiere/images/Import24.gif and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/compiere/images/Info16.gif b/org.adempiere.ui.swing/src/org/compiere/images/Info16.gif deleted file mode 100644 index 8851b99ba1..0000000000 Binary files a/org.adempiere.ui.swing/src/org/compiere/images/Info16.gif and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/compiere/images/Info24.gif b/org.adempiere.ui.swing/src/org/compiere/images/Info24.gif deleted file mode 100644 index 07cf0102d3..0000000000 Binary files a/org.adempiere.ui.swing/src/org/compiere/images/Info24.gif and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/compiere/images/InfoAccount16.gif b/org.adempiere.ui.swing/src/org/compiere/images/InfoAccount16.gif deleted file mode 100644 index fe87b0fd42..0000000000 Binary files a/org.adempiere.ui.swing/src/org/compiere/images/InfoAccount16.gif and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/compiere/images/InfoAccount24.gif b/org.adempiere.ui.swing/src/org/compiere/images/InfoAccount24.gif deleted file mode 100644 index 9bcd02f6b7..0000000000 Binary files a/org.adempiere.ui.swing/src/org/compiere/images/InfoAccount24.gif and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/compiere/images/InfoBPartner16.gif b/org.adempiere.ui.swing/src/org/compiere/images/InfoBPartner16.gif deleted file mode 100644 index 46573fff69..0000000000 Binary files a/org.adempiere.ui.swing/src/org/compiere/images/InfoBPartner16.gif and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/compiere/images/InfoBPartner24.gif b/org.adempiere.ui.swing/src/org/compiere/images/InfoBPartner24.gif deleted file mode 100644 index c9921be2c7..0000000000 Binary files a/org.adempiere.ui.swing/src/org/compiere/images/InfoBPartner24.gif and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/compiere/images/InfoProduct16.gif b/org.adempiere.ui.swing/src/org/compiere/images/InfoProduct16.gif deleted file mode 100644 index f87c2a9662..0000000000 Binary files a/org.adempiere.ui.swing/src/org/compiere/images/InfoProduct16.gif and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/compiere/images/InfoProduct24.gif b/org.adempiere.ui.swing/src/org/compiere/images/InfoProduct24.gif deleted file mode 100644 index acfdec98eb..0000000000 Binary files a/org.adempiere.ui.swing/src/org/compiere/images/InfoProduct24.gif and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/compiere/images/InfoSchedule16.gif b/org.adempiere.ui.swing/src/org/compiere/images/InfoSchedule16.gif deleted file mode 100644 index 18b7c6781e..0000000000 Binary files a/org.adempiere.ui.swing/src/org/compiere/images/InfoSchedule16.gif and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/compiere/images/InfoSchedule24.gif b/org.adempiere.ui.swing/src/org/compiere/images/InfoSchedule24.gif deleted file mode 100644 index d676ffd463..0000000000 Binary files a/org.adempiere.ui.swing/src/org/compiere/images/InfoSchedule24.gif and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/compiere/images/Inform32.gif b/org.adempiere.ui.swing/src/org/compiere/images/Inform32.gif deleted file mode 100644 index 2ac57475c3..0000000000 Binary files a/org.adempiere.ui.swing/src/org/compiere/images/Inform32.gif and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/compiere/images/Italic16.gif b/org.adempiere.ui.swing/src/org/compiere/images/Italic16.gif deleted file mode 100644 index 977ea82176..0000000000 Binary files a/org.adempiere.ui.swing/src/org/compiere/images/Italic16.gif and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/compiere/images/Java_anim.gif b/org.adempiere.ui.swing/src/org/compiere/images/Java_anim.gif deleted file mode 100644 index 036dd8637b..0000000000 Binary files a/org.adempiere.ui.swing/src/org/compiere/images/Java_anim.gif and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/compiere/images/Java_logo.gif b/org.adempiere.ui.swing/src/org/compiere/images/Java_logo.gif deleted file mode 100644 index 69fce04656..0000000000 Binary files a/org.adempiere.ui.swing/src/org/compiere/images/Java_logo.gif and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/compiere/images/Last16.gif b/org.adempiere.ui.swing/src/org/compiere/images/Last16.gif deleted file mode 100644 index 2c5a80385c..0000000000 Binary files a/org.adempiere.ui.swing/src/org/compiere/images/Last16.gif and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/compiere/images/Last24.gif b/org.adempiere.ui.swing/src/org/compiere/images/Last24.gif deleted file mode 100644 index d81e071402..0000000000 Binary files a/org.adempiere.ui.swing/src/org/compiere/images/Last24.gif and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/compiere/images/Last24D.gif b/org.adempiere.ui.swing/src/org/compiere/images/Last24D.gif deleted file mode 100755 index d81e071402..0000000000 Binary files a/org.adempiere.ui.swing/src/org/compiere/images/Last24D.gif and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/compiere/images/Location10.gif b/org.adempiere.ui.swing/src/org/compiere/images/Location10.gif deleted file mode 100644 index 8e54fbdf0e..0000000000 Binary files a/org.adempiere.ui.swing/src/org/compiere/images/Location10.gif and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/compiere/images/Locator10.gif b/org.adempiere.ui.swing/src/org/compiere/images/Locator10.gif deleted file mode 100644 index 399789b5cd..0000000000 Binary files a/org.adempiere.ui.swing/src/org/compiere/images/Locator10.gif and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/compiere/images/Lock16.gif b/org.adempiere.ui.swing/src/org/compiere/images/Lock16.gif deleted file mode 100644 index dfa89a9e99..0000000000 Binary files a/org.adempiere.ui.swing/src/org/compiere/images/Lock16.gif and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/compiere/images/Lock24.gif b/org.adempiere.ui.swing/src/org/compiere/images/Lock24.gif deleted file mode 100644 index 007af85555..0000000000 Binary files a/org.adempiere.ui.swing/src/org/compiere/images/Lock24.gif and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/compiere/images/LockX16.gif b/org.adempiere.ui.swing/src/org/compiere/images/LockX16.gif deleted file mode 100644 index 7400865f49..0000000000 Binary files a/org.adempiere.ui.swing/src/org/compiere/images/LockX16.gif and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/compiere/images/LockX24.gif b/org.adempiere.ui.swing/src/org/compiere/images/LockX24.gif deleted file mode 100644 index c37bbd3d3e..0000000000 Binary files a/org.adempiere.ui.swing/src/org/compiere/images/LockX24.gif and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/compiere/images/Logo.gif b/org.adempiere.ui.swing/src/org/compiere/images/Logo.gif deleted file mode 100644 index 7e98bb0696..0000000000 Binary files a/org.adempiere.ui.swing/src/org/compiere/images/Logo.gif and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/compiere/images/Logout16.png b/org.adempiere.ui.swing/src/org/compiere/images/Logout16.png deleted file mode 100644 index 60a6e40e6e..0000000000 Binary files a/org.adempiere.ui.swing/src/org/compiere/images/Logout16.png and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/compiere/images/Logout24.png b/org.adempiere.ui.swing/src/org/compiere/images/Logout24.png deleted file mode 100644 index 393598b9f3..0000000000 Binary files a/org.adempiere.ui.swing/src/org/compiere/images/Logout24.png and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/compiere/images/Minus16.gif b/org.adempiere.ui.swing/src/org/compiere/images/Minus16.gif deleted file mode 100644 index 00b654e8ca..0000000000 Binary files a/org.adempiere.ui.swing/src/org/compiere/images/Minus16.gif and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/compiere/images/Minus24.gif b/org.adempiere.ui.swing/src/org/compiere/images/Minus24.gif deleted file mode 100644 index 45e5c2a8e9..0000000000 Binary files a/org.adempiere.ui.swing/src/org/compiere/images/Minus24.gif and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/compiere/images/Multi16.gif b/org.adempiere.ui.swing/src/org/compiere/images/Multi16.gif deleted file mode 100644 index 86de1ff369..0000000000 Binary files a/org.adempiere.ui.swing/src/org/compiere/images/Multi16.gif and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/compiere/images/Multi24.gif b/org.adempiere.ui.swing/src/org/compiere/images/Multi24.gif deleted file mode 100644 index 5d40cb2745..0000000000 Binary files a/org.adempiere.ui.swing/src/org/compiere/images/Multi24.gif and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/compiere/images/MultiX16.gif b/org.adempiere.ui.swing/src/org/compiere/images/MultiX16.gif deleted file mode 100644 index ffdabd4e97..0000000000 Binary files a/org.adempiere.ui.swing/src/org/compiere/images/MultiX16.gif and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/compiere/images/MultiX24.gif b/org.adempiere.ui.swing/src/org/compiere/images/MultiX24.gif deleted file mode 100644 index 6f0f292950..0000000000 Binary files a/org.adempiere.ui.swing/src/org/compiere/images/MultiX24.gif and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/compiere/images/New16.gif b/org.adempiere.ui.swing/src/org/compiere/images/New16.gif deleted file mode 100644 index 4c3efdd6fa..0000000000 Binary files a/org.adempiere.ui.swing/src/org/compiere/images/New16.gif and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/compiere/images/New24.gif b/org.adempiere.ui.swing/src/org/compiere/images/New24.gif deleted file mode 100644 index e3808a108e..0000000000 Binary files a/org.adempiere.ui.swing/src/org/compiere/images/New24.gif and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/compiere/images/Next16.gif b/org.adempiere.ui.swing/src/org/compiere/images/Next16.gif deleted file mode 100644 index 3dd7fccdf0..0000000000 Binary files a/org.adempiere.ui.swing/src/org/compiere/images/Next16.gif and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/compiere/images/Next24.gif b/org.adempiere.ui.swing/src/org/compiere/images/Next24.gif deleted file mode 100644 index af23788173..0000000000 Binary files a/org.adempiere.ui.swing/src/org/compiere/images/Next24.gif and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/compiere/images/Next24D.gif b/org.adempiere.ui.swing/src/org/compiere/images/Next24D.gif deleted file mode 100755 index af23788173..0000000000 Binary files a/org.adempiere.ui.swing/src/org/compiere/images/Next24D.gif and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/compiere/images/Normal16.gif b/org.adempiere.ui.swing/src/org/compiere/images/Normal16.gif deleted file mode 100644 index f79387f0b2..0000000000 Binary files a/org.adempiere.ui.swing/src/org/compiere/images/Normal16.gif and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/compiere/images/Ok16.gif b/org.adempiere.ui.swing/src/org/compiere/images/Ok16.gif deleted file mode 100644 index caa44b5049..0000000000 Binary files a/org.adempiere.ui.swing/src/org/compiere/images/Ok16.gif and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/compiere/images/Ok24.gif b/org.adempiere.ui.swing/src/org/compiere/images/Ok24.gif deleted file mode 100644 index 027d18f531..0000000000 Binary files a/org.adempiere.ui.swing/src/org/compiere/images/Ok24.gif and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/compiere/images/Online10.gif b/org.adempiere.ui.swing/src/org/compiere/images/Online10.gif deleted file mode 100644 index c47e987718..0000000000 Binary files a/org.adempiere.ui.swing/src/org/compiere/images/Online10.gif and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/compiere/images/Online16.gif b/org.adempiere.ui.swing/src/org/compiere/images/Online16.gif deleted file mode 100644 index a5889683a6..0000000000 Binary files a/org.adempiere.ui.swing/src/org/compiere/images/Online16.gif and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/compiere/images/Online24.gif b/org.adempiere.ui.swing/src/org/compiere/images/Online24.gif deleted file mode 100644 index d4bfb82bf5..0000000000 Binary files a/org.adempiere.ui.swing/src/org/compiere/images/Online24.gif and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/compiere/images/Open16.gif b/org.adempiere.ui.swing/src/org/compiere/images/Open16.gif deleted file mode 100644 index 1e074cd024..0000000000 Binary files a/org.adempiere.ui.swing/src/org/compiere/images/Open16.gif and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/compiere/images/Open24.gif b/org.adempiere.ui.swing/src/org/compiere/images/Open24.gif deleted file mode 100644 index eaf4be873c..0000000000 Binary files a/org.adempiere.ui.swing/src/org/compiere/images/Open24.gif and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/compiere/images/PAttribute10.gif b/org.adempiere.ui.swing/src/org/compiere/images/PAttribute10.gif deleted file mode 100644 index 9e916d9625..0000000000 Binary files a/org.adempiere.ui.swing/src/org/compiere/images/PAttribute10.gif and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/compiere/images/PAttribute16.gif b/org.adempiere.ui.swing/src/org/compiere/images/PAttribute16.gif deleted file mode 100644 index 87094f954a..0000000000 Binary files a/org.adempiere.ui.swing/src/org/compiere/images/PAttribute16.gif and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/compiere/images/PAttribute24.gif b/org.adempiere.ui.swing/src/org/compiere/images/PAttribute24.gif deleted file mode 100644 index e018cfb657..0000000000 Binary files a/org.adempiere.ui.swing/src/org/compiere/images/PAttribute24.gif and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/compiere/images/PageSetup16.gif b/org.adempiere.ui.swing/src/org/compiere/images/PageSetup16.gif deleted file mode 100644 index 9aad200e7b..0000000000 Binary files a/org.adempiere.ui.swing/src/org/compiere/images/PageSetup16.gif and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/compiere/images/PageSetup24.gif b/org.adempiere.ui.swing/src/org/compiere/images/PageSetup24.gif deleted file mode 100644 index b8fc10e7ad..0000000000 Binary files a/org.adempiere.ui.swing/src/org/compiere/images/PageSetup24.gif and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/compiere/images/Parent16.gif b/org.adempiere.ui.swing/src/org/compiere/images/Parent16.gif deleted file mode 100644 index 659cd90d7f..0000000000 Binary files a/org.adempiere.ui.swing/src/org/compiere/images/Parent16.gif and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/compiere/images/Parent24.gif b/org.adempiere.ui.swing/src/org/compiere/images/Parent24.gif deleted file mode 100644 index 93be3d1ee6..0000000000 Binary files a/org.adempiere.ui.swing/src/org/compiere/images/Parent24.gif and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/compiere/images/Payment10.gif b/org.adempiere.ui.swing/src/org/compiere/images/Payment10.gif deleted file mode 100644 index 04a3e556f4..0000000000 Binary files a/org.adempiere.ui.swing/src/org/compiere/images/Payment10.gif and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/compiere/images/Payment16.gif b/org.adempiere.ui.swing/src/org/compiere/images/Payment16.gif deleted file mode 100644 index d694f7260c..0000000000 Binary files a/org.adempiere.ui.swing/src/org/compiere/images/Payment16.gif and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/compiere/images/Payment24.gif b/org.adempiere.ui.swing/src/org/compiere/images/Payment24.gif deleted file mode 100644 index ca63ae50d5..0000000000 Binary files a/org.adempiere.ui.swing/src/org/compiere/images/Payment24.gif and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/compiere/images/PickOpen10.gif b/org.adempiere.ui.swing/src/org/compiere/images/PickOpen10.gif deleted file mode 100644 index c3280ede7f..0000000000 Binary files a/org.adempiere.ui.swing/src/org/compiere/images/PickOpen10.gif and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/compiere/images/Plus16.gif b/org.adempiere.ui.swing/src/org/compiere/images/Plus16.gif deleted file mode 100644 index 1aa7f095c6..0000000000 Binary files a/org.adempiere.ui.swing/src/org/compiere/images/Plus16.gif and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/compiere/images/Plus24.gif b/org.adempiere.ui.swing/src/org/compiere/images/Plus24.gif deleted file mode 100644 index 306d3d8929..0000000000 Binary files a/org.adempiere.ui.swing/src/org/compiere/images/Plus24.gif and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/compiere/images/PostIt16.png b/org.adempiere.ui.swing/src/org/compiere/images/PostIt16.png deleted file mode 100644 index c72f5ba466..0000000000 Binary files a/org.adempiere.ui.swing/src/org/compiere/images/PostIt16.png and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/compiere/images/PostIt24.png b/org.adempiere.ui.swing/src/org/compiere/images/PostIt24.png deleted file mode 100644 index 496cd3b218..0000000000 Binary files a/org.adempiere.ui.swing/src/org/compiere/images/PostIt24.png and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/compiere/images/PostItX16.png b/org.adempiere.ui.swing/src/org/compiere/images/PostItX16.png deleted file mode 100644 index 59d340cc71..0000000000 Binary files a/org.adempiere.ui.swing/src/org/compiere/images/PostItX16.png and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/compiere/images/PostItX24.png b/org.adempiere.ui.swing/src/org/compiere/images/PostItX24.png deleted file mode 100644 index 8633a7fa8f..0000000000 Binary files a/org.adempiere.ui.swing/src/org/compiere/images/PostItX24.png and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/compiere/images/Preference16.gif b/org.adempiere.ui.swing/src/org/compiere/images/Preference16.gif deleted file mode 100644 index 9460dfc746..0000000000 Binary files a/org.adempiere.ui.swing/src/org/compiere/images/Preference16.gif and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/compiere/images/Preference24.gif b/org.adempiere.ui.swing/src/org/compiere/images/Preference24.gif deleted file mode 100644 index cc91d65958..0000000000 Binary files a/org.adempiere.ui.swing/src/org/compiere/images/Preference24.gif and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/compiere/images/Previous16.gif b/org.adempiere.ui.swing/src/org/compiere/images/Previous16.gif deleted file mode 100644 index fa9a7d71b5..0000000000 Binary files a/org.adempiere.ui.swing/src/org/compiere/images/Previous16.gif and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/compiere/images/Previous24.gif b/org.adempiere.ui.swing/src/org/compiere/images/Previous24.gif deleted file mode 100644 index b0a0cd721f..0000000000 Binary files a/org.adempiere.ui.swing/src/org/compiere/images/Previous24.gif and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/compiere/images/Previous24D.gif b/org.adempiere.ui.swing/src/org/compiere/images/Previous24D.gif deleted file mode 100755 index b0a0cd721f..0000000000 Binary files a/org.adempiere.ui.swing/src/org/compiere/images/Previous24D.gif and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/compiere/images/Print16.gif b/org.adempiere.ui.swing/src/org/compiere/images/Print16.gif deleted file mode 100644 index 35c37bd73e..0000000000 Binary files a/org.adempiere.ui.swing/src/org/compiere/images/Print16.gif and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/compiere/images/Print24.gif b/org.adempiere.ui.swing/src/org/compiere/images/Print24.gif deleted file mode 100644 index 52dd67e876..0000000000 Binary files a/org.adempiere.ui.swing/src/org/compiere/images/Print24.gif and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/compiere/images/PrintPreview16.gif b/org.adempiere.ui.swing/src/org/compiere/images/PrintPreview16.gif deleted file mode 100644 index ab92a309ce..0000000000 Binary files a/org.adempiere.ui.swing/src/org/compiere/images/PrintPreview16.gif and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/compiere/images/PrintPreview24.gif b/org.adempiere.ui.swing/src/org/compiere/images/PrintPreview24.gif deleted file mode 100644 index 75f43aa64b..0000000000 Binary files a/org.adempiere.ui.swing/src/org/compiere/images/PrintPreview24.gif and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/compiere/images/PrintScreen16.gif b/org.adempiere.ui.swing/src/org/compiere/images/PrintScreen16.gif deleted file mode 100644 index dc297db176..0000000000 Binary files a/org.adempiere.ui.swing/src/org/compiere/images/PrintScreen16.gif and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/compiere/images/PrintScreen24.gif b/org.adempiere.ui.swing/src/org/compiere/images/PrintScreen24.gif deleted file mode 100644 index 619e1969d7..0000000000 Binary files a/org.adempiere.ui.swing/src/org/compiere/images/PrintScreen24.gif and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/compiere/images/Process16.gif b/org.adempiere.ui.swing/src/org/compiere/images/Process16.gif deleted file mode 100644 index d90ab661cb..0000000000 Binary files a/org.adempiere.ui.swing/src/org/compiere/images/Process16.gif and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/compiere/images/Process24.gif b/org.adempiere.ui.swing/src/org/compiere/images/Process24.gif deleted file mode 100644 index 4decc893f8..0000000000 Binary files a/org.adempiere.ui.swing/src/org/compiere/images/Process24.gif and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/compiere/images/Product10.gif b/org.adempiere.ui.swing/src/org/compiere/images/Product10.gif deleted file mode 100644 index 3cbddd231b..0000000000 Binary files a/org.adempiere.ui.swing/src/org/compiere/images/Product10.gif and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/compiere/images/Product16.gif b/org.adempiere.ui.swing/src/org/compiere/images/Product16.gif deleted file mode 100644 index f87c2a9662..0000000000 Binary files a/org.adempiere.ui.swing/src/org/compiere/images/Product16.gif and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/compiere/images/Product24.gif b/org.adempiere.ui.swing/src/org/compiere/images/Product24.gif deleted file mode 100644 index d96276895f..0000000000 Binary files a/org.adempiere.ui.swing/src/org/compiere/images/Product24.gif and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/compiere/images/Question32.gif b/org.adempiere.ui.swing/src/org/compiere/images/Question32.gif deleted file mode 100644 index dc19aa1706..0000000000 Binary files a/org.adempiere.ui.swing/src/org/compiere/images/Question32.gif and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/compiere/images/Redo16.gif b/org.adempiere.ui.swing/src/org/compiere/images/Redo16.gif deleted file mode 100644 index c3b0df0396..0000000000 Binary files a/org.adempiere.ui.swing/src/org/compiere/images/Redo16.gif and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/compiere/images/Redo24.gif b/org.adempiere.ui.swing/src/org/compiere/images/Redo24.gif deleted file mode 100644 index 576cfc76c6..0000000000 Binary files a/org.adempiere.ui.swing/src/org/compiere/images/Redo24.gif and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/compiere/images/Refresh16.gif b/org.adempiere.ui.swing/src/org/compiere/images/Refresh16.gif deleted file mode 100644 index 3fd71d6e59..0000000000 Binary files a/org.adempiere.ui.swing/src/org/compiere/images/Refresh16.gif and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/compiere/images/Refresh24.gif b/org.adempiere.ui.swing/src/org/compiere/images/Refresh24.gif deleted file mode 100644 index cab4d02c75..0000000000 Binary files a/org.adempiere.ui.swing/src/org/compiere/images/Refresh24.gif and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/compiere/images/Register16.gif b/org.adempiere.ui.swing/src/org/compiere/images/Register16.gif deleted file mode 100644 index a9a6432230..0000000000 Binary files a/org.adempiere.ui.swing/src/org/compiere/images/Register16.gif and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/compiere/images/Register24.gif b/org.adempiere.ui.swing/src/org/compiere/images/Register24.gif deleted file mode 100644 index 72dcd36f6c..0000000000 Binary files a/org.adempiere.ui.swing/src/org/compiere/images/Register24.gif and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/compiere/images/Report16.png b/org.adempiere.ui.swing/src/org/compiere/images/Report16.png deleted file mode 100644 index d18082e397..0000000000 Binary files a/org.adempiere.ui.swing/src/org/compiere/images/Report16.png and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/compiere/images/Report24.png b/org.adempiere.ui.swing/src/org/compiere/images/Report24.png deleted file mode 100644 index c9baeda2c4..0000000000 Binary files a/org.adempiere.ui.swing/src/org/compiere/images/Report24.png and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/compiere/images/Request16.gif b/org.adempiere.ui.swing/src/org/compiere/images/Request16.gif deleted file mode 100644 index 2017b0af0b..0000000000 Binary files a/org.adempiere.ui.swing/src/org/compiere/images/Request16.gif and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/compiere/images/Request24.gif b/org.adempiere.ui.swing/src/org/compiere/images/Request24.gif deleted file mode 100644 index c158a72533..0000000000 Binary files a/org.adempiere.ui.swing/src/org/compiere/images/Request24.gif and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/compiere/images/Reset16.gif b/org.adempiere.ui.swing/src/org/compiere/images/Reset16.gif deleted file mode 100644 index 1d218c388b..0000000000 Binary files a/org.adempiere.ui.swing/src/org/compiere/images/Reset16.gif and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/compiere/images/Reset24.gif b/org.adempiere.ui.swing/src/org/compiere/images/Reset24.gif deleted file mode 100644 index 373dce9549..0000000000 Binary files a/org.adempiere.ui.swing/src/org/compiere/images/Reset24.gif and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/compiere/images/Save16.gif b/org.adempiere.ui.swing/src/org/compiere/images/Save16.gif deleted file mode 100644 index f1d7a19859..0000000000 Binary files a/org.adempiere.ui.swing/src/org/compiere/images/Save16.gif and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/compiere/images/Save24.gif b/org.adempiere.ui.swing/src/org/compiere/images/Save24.gif deleted file mode 100644 index af79de8525..0000000000 Binary files a/org.adempiere.ui.swing/src/org/compiere/images/Save24.gif and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/compiere/images/SaveCreate16.gif b/org.adempiere.ui.swing/src/org/compiere/images/SaveCreate16.gif deleted file mode 100644 index 749a2ab3ee..0000000000 Binary files a/org.adempiere.ui.swing/src/org/compiere/images/SaveCreate16.gif and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/compiere/images/SaveCreate24.gif b/org.adempiere.ui.swing/src/org/compiere/images/SaveCreate24.gif deleted file mode 100644 index 16db6a1d4d..0000000000 Binary files a/org.adempiere.ui.swing/src/org/compiere/images/SaveCreate24.gif and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/compiere/images/ScreenShot16.gif b/org.adempiere.ui.swing/src/org/compiere/images/ScreenShot16.gif deleted file mode 100644 index 1de6b72814..0000000000 Binary files a/org.adempiere.ui.swing/src/org/compiere/images/ScreenShot16.gif and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/compiere/images/ScreenShot24.gif b/org.adempiere.ui.swing/src/org/compiere/images/ScreenShot24.gif deleted file mode 100644 index 205a66311f..0000000000 Binary files a/org.adempiere.ui.swing/src/org/compiere/images/ScreenShot24.gif and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/compiere/images/Script16.gif b/org.adempiere.ui.swing/src/org/compiere/images/Script16.gif deleted file mode 100644 index c923098eac..0000000000 Binary files a/org.adempiere.ui.swing/src/org/compiere/images/Script16.gif and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/compiere/images/Script24.gif b/org.adempiere.ui.swing/src/org/compiere/images/Script24.gif deleted file mode 100644 index abf8f616dd..0000000000 Binary files a/org.adempiere.ui.swing/src/org/compiere/images/Script24.gif and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/compiere/images/SelectAll16.png b/org.adempiere.ui.swing/src/org/compiere/images/SelectAll16.png deleted file mode 100644 index f4b0b19e09..0000000000 Binary files a/org.adempiere.ui.swing/src/org/compiere/images/SelectAll16.png and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/compiere/images/SelectAll24.png b/org.adempiere.ui.swing/src/org/compiere/images/SelectAll24.png deleted file mode 100644 index e6331c6e9b..0000000000 Binary files a/org.adempiere.ui.swing/src/org/compiere/images/SelectAll24.png and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/compiere/images/SendMail16.gif b/org.adempiere.ui.swing/src/org/compiere/images/SendMail16.gif deleted file mode 100644 index 66afdb713b..0000000000 Binary files a/org.adempiere.ui.swing/src/org/compiere/images/SendMail16.gif and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/compiere/images/SendMail24.gif b/org.adempiere.ui.swing/src/org/compiere/images/SendMail24.gif deleted file mode 100644 index 37f606e797..0000000000 Binary files a/org.adempiere.ui.swing/src/org/compiere/images/SendMail24.gif and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/compiere/images/Server16.gif b/org.adempiere.ui.swing/src/org/compiere/images/Server16.gif deleted file mode 100644 index 068ffebee2..0000000000 Binary files a/org.adempiere.ui.swing/src/org/compiere/images/Server16.gif and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/compiere/images/Server24.gif b/org.adempiere.ui.swing/src/org/compiere/images/Server24.gif deleted file mode 100644 index a0d7118d2b..0000000000 Binary files a/org.adempiere.ui.swing/src/org/compiere/images/Server24.gif and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/compiere/images/Setup16.gif b/org.adempiere.ui.swing/src/org/compiere/images/Setup16.gif deleted file mode 100644 index 58f19c68b0..0000000000 Binary files a/org.adempiere.ui.swing/src/org/compiere/images/Setup16.gif and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/compiere/images/Setup24.gif b/org.adempiere.ui.swing/src/org/compiere/images/Setup24.gif deleted file mode 100644 index 5f7a362bcd..0000000000 Binary files a/org.adempiere.ui.swing/src/org/compiere/images/Setup24.gif and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/compiere/images/StepBack24.gif b/org.adempiere.ui.swing/src/org/compiere/images/StepBack24.gif deleted file mode 100644 index 2a5e703062..0000000000 Binary files a/org.adempiere.ui.swing/src/org/compiere/images/StepBack24.gif and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/compiere/images/StepForward24.gif b/org.adempiere.ui.swing/src/org/compiere/images/StepForward24.gif deleted file mode 100644 index 28bca3e72e..0000000000 Binary files a/org.adempiere.ui.swing/src/org/compiere/images/StepForward24.gif and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/compiere/images/Summary16.gif b/org.adempiere.ui.swing/src/org/compiere/images/Summary16.gif deleted file mode 100644 index 24588a3a4d..0000000000 Binary files a/org.adempiere.ui.swing/src/org/compiere/images/Summary16.gif and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/compiere/images/Summary24.gif b/org.adempiere.ui.swing/src/org/compiere/images/Summary24.gif deleted file mode 100644 index f6a625ce0c..0000000000 Binary files a/org.adempiere.ui.swing/src/org/compiere/images/Summary24.gif and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/compiere/images/Translate16.gif b/org.adempiere.ui.swing/src/org/compiere/images/Translate16.gif deleted file mode 100644 index 5b9e46112d..0000000000 Binary files a/org.adempiere.ui.swing/src/org/compiere/images/Translate16.gif and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/compiere/images/Translate24.gif b/org.adempiere.ui.swing/src/org/compiere/images/Translate24.gif deleted file mode 100644 index 38b36b48c3..0000000000 Binary files a/org.adempiere.ui.swing/src/org/compiere/images/Translate24.gif and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/compiere/images/Underline16.gif b/org.adempiere.ui.swing/src/org/compiere/images/Underline16.gif deleted file mode 100644 index 0c48721002..0000000000 Binary files a/org.adempiere.ui.swing/src/org/compiere/images/Underline16.gif and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/compiere/images/Undo16.gif b/org.adempiere.ui.swing/src/org/compiere/images/Undo16.gif deleted file mode 100644 index 40b970b265..0000000000 Binary files a/org.adempiere.ui.swing/src/org/compiere/images/Undo16.gif and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/compiere/images/Undo24.gif b/org.adempiere.ui.swing/src/org/compiere/images/Undo24.gif deleted file mode 100644 index 53561163ed..0000000000 Binary files a/org.adempiere.ui.swing/src/org/compiere/images/Undo24.gif and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/compiere/images/VPreference16.gif b/org.adempiere.ui.swing/src/org/compiere/images/VPreference16.gif deleted file mode 100644 index fbea772cae..0000000000 Binary files a/org.adempiere.ui.swing/src/org/compiere/images/VPreference16.gif and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/compiere/images/VPreference24.gif b/org.adempiere.ui.swing/src/org/compiere/images/VPreference24.gif deleted file mode 100644 index 7b5f0ba237..0000000000 Binary files a/org.adempiere.ui.swing/src/org/compiere/images/VPreference24.gif and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/compiere/images/Warn32.gif b/org.adempiere.ui.swing/src/org/compiere/images/Warn32.gif deleted file mode 100644 index a05e160c20..0000000000 Binary files a/org.adempiere.ui.swing/src/org/compiere/images/Warn32.gif and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/compiere/images/WinSize16.gif b/org.adempiere.ui.swing/src/org/compiere/images/WinSize16.gif deleted file mode 100644 index c3a2b8d2e3..0000000000 Binary files a/org.adempiere.ui.swing/src/org/compiere/images/WinSize16.gif and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/compiere/images/WinSize24.gif b/org.adempiere.ui.swing/src/org/compiere/images/WinSize24.gif deleted file mode 100644 index 4d200f26af..0000000000 Binary files a/org.adempiere.ui.swing/src/org/compiere/images/WinSize24.gif and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/compiere/images/WorkFlow16.gif b/org.adempiere.ui.swing/src/org/compiere/images/WorkFlow16.gif deleted file mode 100644 index 92224cea7f..0000000000 Binary files a/org.adempiere.ui.swing/src/org/compiere/images/WorkFlow16.gif and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/compiere/images/WorkFlow24.gif b/org.adempiere.ui.swing/src/org/compiere/images/WorkFlow24.gif deleted file mode 100644 index 7879b2f6f9..0000000000 Binary files a/org.adempiere.ui.swing/src/org/compiere/images/WorkFlow24.gif and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/compiere/images/WorkFlow_16.gif b/org.adempiere.ui.swing/src/org/compiere/images/WorkFlow_16.gif deleted file mode 100644 index 92224cea7f..0000000000 Binary files a/org.adempiere.ui.swing/src/org/compiere/images/WorkFlow_16.gif and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/compiere/images/WorkFlow_24.gif b/org.adempiere.ui.swing/src/org/compiere/images/WorkFlow_24.gif deleted file mode 100644 index 7879b2f6f9..0000000000 Binary files a/org.adempiere.ui.swing/src/org/compiere/images/WorkFlow_24.gif and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/compiere/images/Zoom16.gif b/org.adempiere.ui.swing/src/org/compiere/images/Zoom16.gif deleted file mode 100644 index d072d3cbe2..0000000000 Binary files a/org.adempiere.ui.swing/src/org/compiere/images/Zoom16.gif and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/compiere/images/Zoom24.gif b/org.adempiere.ui.swing/src/org/compiere/images/Zoom24.gif deleted file mode 100644 index 4f078cb6ea..0000000000 Binary files a/org.adempiere.ui.swing/src/org/compiere/images/Zoom24.gif and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/compiere/images/ZoomAcross16.gif b/org.adempiere.ui.swing/src/org/compiere/images/ZoomAcross16.gif deleted file mode 100644 index b02eb9c0da..0000000000 Binary files a/org.adempiere.ui.swing/src/org/compiere/images/ZoomAcross16.gif and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/compiere/images/ZoomAcross24.gif b/org.adempiere.ui.swing/src/org/compiere/images/ZoomAcross24.gif deleted file mode 100644 index 1d34368538..0000000000 Binary files a/org.adempiere.ui.swing/src/org/compiere/images/ZoomAcross24.gif and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/compiere/images/downarrow.gif b/org.adempiere.ui.swing/src/org/compiere/images/downarrow.gif deleted file mode 100644 index 206d7c19dd..0000000000 Binary files a/org.adempiere.ui.swing/src/org/compiere/images/downarrow.gif and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/compiere/images/iD10030.png b/org.adempiere.ui.swing/src/org/compiere/images/iD10030.png deleted file mode 100644 index e5cd1f7b4f..0000000000 Binary files a/org.adempiere.ui.swing/src/org/compiere/images/iD10030.png and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/compiere/images/iD16.gif b/org.adempiere.ui.swing/src/org/compiere/images/iD16.gif deleted file mode 100644 index e626d5704a..0000000000 Binary files a/org.adempiere.ui.swing/src/org/compiere/images/iD16.gif and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/compiere/images/iD32.gif b/org.adempiere.ui.swing/src/org/compiere/images/iD32.gif deleted file mode 100644 index 65c7a571a3..0000000000 Binary files a/org.adempiere.ui.swing/src/org/compiere/images/iD32.gif and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/compiere/images/iDempiere.png b/org.adempiere.ui.swing/src/org/compiere/images/iDempiere.png deleted file mode 100644 index 38cb4be63e..0000000000 Binary files a/org.adempiere.ui.swing/src/org/compiere/images/iDempiere.png and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/compiere/images/iDempiereHR.png b/org.adempiere.ui.swing/src/org/compiere/images/iDempiereHR.png deleted file mode 100644 index 76071a46dd..0000000000 Binary files a/org.adempiere.ui.swing/src/org/compiere/images/iDempiereHR.png and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/compiere/images/logo_ad.png b/org.adempiere.ui.swing/src/org/compiere/images/logo_ad.png deleted file mode 100644 index f7574b2071..0000000000 Binary files a/org.adempiere.ui.swing/src/org/compiere/images/logo_ad.png and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/compiere/images/mClosed.gif b/org.adempiere.ui.swing/src/org/compiere/images/mClosed.gif deleted file mode 100755 index 901edc9624..0000000000 Binary files a/org.adempiere.ui.swing/src/org/compiere/images/mClosed.gif and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/compiere/images/mDocAction.png b/org.adempiere.ui.swing/src/org/compiere/images/mDocAction.png deleted file mode 100644 index 2420d2351e..0000000000 Binary files a/org.adempiere.ui.swing/src/org/compiere/images/mDocAction.png and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/compiere/images/mOpen.gif b/org.adempiere.ui.swing/src/org/compiere/images/mOpen.gif deleted file mode 100755 index 1e074cd024..0000000000 Binary files a/org.adempiere.ui.swing/src/org/compiere/images/mOpen.gif and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/compiere/images/mProcess.png b/org.adempiere.ui.swing/src/org/compiere/images/mProcess.png deleted file mode 100644 index d90ab661cb..0000000000 Binary files a/org.adempiere.ui.swing/src/org/compiere/images/mProcess.png and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/compiere/images/mReport.png b/org.adempiere.ui.swing/src/org/compiere/images/mReport.png deleted file mode 100644 index 2d7f2d6017..0000000000 Binary files a/org.adempiere.ui.swing/src/org/compiere/images/mReport.png and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/compiere/images/mSetVariable.png b/org.adempiere.ui.swing/src/org/compiere/images/mSetVariable.png deleted file mode 100644 index f85b1c78bb..0000000000 Binary files a/org.adempiere.ui.swing/src/org/compiere/images/mSetVariable.png and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/compiere/images/mUserChoice.png b/org.adempiere.ui.swing/src/org/compiere/images/mUserChoice.png deleted file mode 100644 index c890426e05..0000000000 Binary files a/org.adempiere.ui.swing/src/org/compiere/images/mUserChoice.png and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/compiere/images/mWindow.png b/org.adempiere.ui.swing/src/org/compiere/images/mWindow.png deleted file mode 100644 index 596caf9486..0000000000 Binary files a/org.adempiere.ui.swing/src/org/compiere/images/mWindow.png and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/compiere/images/mWorkFlow.png b/org.adempiere.ui.swing/src/org/compiere/images/mWorkFlow.png deleted file mode 100644 index 92224cea7f..0000000000 Binary files a/org.adempiere.ui.swing/src/org/compiere/images/mWorkFlow.png and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/compiere/images/mWorkbench.png b/org.adempiere.ui.swing/src/org/compiere/images/mWorkbench.png deleted file mode 100644 index 437522777b..0000000000 Binary files a/org.adempiere.ui.swing/src/org/compiere/images/mWorkbench.png and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/compiere/images/standard.css b/org.adempiere.ui.swing/src/org/compiere/images/standard.css deleted file mode 100644 index 17b2ae59cb..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/images/standard.css +++ /dev/null @@ -1,165 +0,0 @@ -/* ADempiere HTML UI (c) Jorg Janke */ -/* $Id: standard.css,v 1.1 2009/04/15 11:26:44 vinhpt Exp $ */ - -a { - color: #000066; - text-decoration: none; -} - -a:hover { - text-decoration: underline; -} - -body { - margin-top:0px; - margin-right:0px; - margin-left:0px; - margin-bottom:0px; - padding-top: 0px; - padding-right: 0px; - padding-left: 0px; - padding-bottom: 0px; - font-family: Arial, verdana; - font-size: 8pt; - font-weight: normal; - COLOR: #000000; - background-color : white; -; -} - -h1 { - color: #003FAF; - font-size: 14px !important; - margin-bottom: 10px; - margin-top: 0; -} - -h2 { - color: #000066; - font-size: 14px; - font-style: italic; - font-weight: bold; -} - -h3 { - color: #0000CC; - font-size: 14px; - font-style: normal; - font-weight: bold; -} - -h4 { - color: #6600CC; - font-size: 14px; - font-style: italic; -} - -h5 { - color: #660099; - font-size: 14px; - font-weight: normal; -} - -h6 { - font-size: 12px; - font-weight: bold; -} - -hr { - color: #000099; - padding-bottom: 0; - padding-top: 0; -} - - -th { - font-size: 10px; - background-color: #C9D9F5; - font-weight: bold; - color: black; - border: 0px; -} - -td { - font-size: 10px; - color: black; - border: 0px; -} - -p { - text-align:justify; -} - -.menuDetail{ - color: #660099; - font-family: Arial,Helvetica,sans-serif; - font-size: 12px; - padding-bottom: 0; - padding-left: 20px; - padding-top: 0; - text-decoration: none; -} - -.menuDetail:hover{ - background-color: #99FFFF; - color: #660099; - font-size: 12px; - padding-bottom: 0; - padding-left: 20px; - padding-top: 0; - text-decoration: none; -} - -.menuMain{ - color: #000066; - font-size: 14px; - text-align: left; - text-decoration: none; -} - -.menuMain:hover{ - background-color: #99FFFF; - color: #000066; - font-size: 14px; - text-align: left; - text-decoration: none; -} - -.menuSub{ - color: #000066; - font-size: 12px; - padding-left: 10px; - text-align: left; - text-decoration: none; -} - -.menuSub:hover{ - background-color: #99FFFF; - color: #000066; - font-size: 12px; - padding-left: 10px; - text-align: left; - text-decoration: none; -} - -#menuDetail{ - color: #660099; - display: block; - font-size: 12px; - margin-bottom: 1px; - margin-top: 1px; - padding-right: 20px; - text-align: right; - text-decoration: none; -} - -#menuMain{ - border-top: groove; - color: #000066; - display: block; - font-size: 14px; - margin-bottom: 1px; - margin-top: 5px; - text-align: left; - text-decoration: none; -} diff --git a/org.adempiere.ui.swing/src/org/compiere/images/uparrow.gif b/org.adempiere.ui.swing/src/org/compiere/images/uparrow.gif deleted file mode 100644 index 883a4f95ca..0000000000 Binary files a/org.adempiere.ui.swing/src/org/compiere/images/uparrow.gif and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/compiere/images/wfBack24.gif b/org.adempiere.ui.swing/src/org/compiere/images/wfBack24.gif deleted file mode 100644 index 93be3d1ee6..0000000000 Binary files a/org.adempiere.ui.swing/src/org/compiere/images/wfBack24.gif and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/compiere/images/wfEnd24.gif b/org.adempiere.ui.swing/src/org/compiere/images/wfEnd24.gif deleted file mode 100644 index 32df45d41f..0000000000 Binary files a/org.adempiere.ui.swing/src/org/compiere/images/wfEnd24.gif and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/compiere/images/wfNext24.gif b/org.adempiere.ui.swing/src/org/compiere/images/wfNext24.gif deleted file mode 100644 index 6f3f65d33d..0000000000 Binary files a/org.adempiere.ui.swing/src/org/compiere/images/wfNext24.gif and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/compiere/images/wfStart24.gif b/org.adempiere.ui.swing/src/org/compiere/images/wfStart24.gif deleted file mode 100644 index bf0d8f2c8b..0000000000 Binary files a/org.adempiere.ui.swing/src/org/compiere/images/wfStart24.gif and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/compiere/images/zip.gif b/org.adempiere.ui.swing/src/org/compiere/images/zip.gif deleted file mode 100644 index dc76287383..0000000000 Binary files a/org.adempiere.ui.swing/src/org/compiere/images/zip.gif and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/compiere/install/VTranslationDialog.java b/org.adempiere.ui.swing/src/org/compiere/install/VTranslationDialog.java deleted file mode 100644 index 7ea92cd2a5..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/install/VTranslationDialog.java +++ /dev/null @@ -1,256 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ -package org.compiere.install; - -import java.awt.BorderLayout; -import java.awt.Cursor; -import java.awt.GridBagConstraints; -import java.awt.GridBagLayout; -import java.awt.Insets; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.io.File; -import java.util.ArrayList; -import java.util.logging.Level; - -import javax.swing.JButton; -import javax.swing.JComboBox; -import javax.swing.JFileChooser; -import javax.swing.JLabel; - -import org.compiere.apps.ADialog; -import org.compiere.apps.StatusBar; -import org.compiere.apps.form.FormFrame; -import org.compiere.apps.form.FormPanel; -import org.compiere.grid.ed.VCheckBox; -import org.compiere.swing.CPanel; -import org.compiere.util.CLogger; -import org.compiere.util.Env; -import org.compiere.util.Ini; -import org.compiere.util.KeyNamePair; -import org.compiere.util.Msg; -import org.compiere.util.ValueNamePair; - -/** - * Translation Dialog Import + Export. - * - * @author Jorg Janke - * @version $Id: TranslationDialog.java,v 1.3 2006/07/30 00:51:28 jjanke Exp $ - */ -public class VTranslationDialog extends TranslationController - implements FormPanel, ActionListener -{ - private CPanel panel = new CPanel(); - - - /** - * TranslationDialog Constructor. - * (Initiated via init()) - */ - public VTranslationDialog() - { - } // TranslationDialog - - /** FormFrame */ - private FormFrame m_frame; - /** Logger */ - private static CLogger log = CLogger.getCLogger(VTranslationDialog.class); - // - private GridBagLayout mainLayout = new GridBagLayout(); - private JComboBox cbLanguage = new JComboBox(); - private JLabel lLanguage = new JLabel(); - private JLabel lTable = new JLabel(); - private JComboBox cbTable = new JComboBox(); - private JButton bExport = new JButton(); - private JButton bImport = new JButton(); - // - private StatusBar statusBar = new StatusBar(); - private JLabel lClient = new JLabel(); - private JComboBox cbClient = new JComboBox(); - private VCheckBox isOnlyCentralized = new VCheckBox(); - - - /** - * Static Init - * @throws Exception - */ - private void jbInit() throws Exception - { - panel.setLayout(mainLayout); - lClient.setText(Msg.translate(Env.getCtx(), "AD_Client_ID")); - lLanguage.setText(Msg.translate(Env.getCtx(), "AD_Language")); - lLanguage.setToolTipText(Msg.translate(Env.getCtx(), "IsSystemLanguage")); - lTable.setText(Msg.translate(Env.getCtx(), "AD_Table_ID")); - isOnlyCentralized.setText(Msg.getMsg(Env.getCtx(), "OnlyCentralizedData")); - // - bExport.setText(Msg.getMsg(Env.getCtx(), "Export")); - bExport.addActionListener(this); - bImport.setText(Msg.getMsg(Env.getCtx(), "Import")); - bImport.addActionListener(this); - // - panel.add(cbLanguage, new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5), 0, 0)); - panel.add(lLanguage, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); - panel.add(lTable, new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); - panel.add(cbTable, new GridBagConstraints(1, 2, 1, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5), 0, 0)); - panel.add(isOnlyCentralized, new GridBagConstraints(1, 4, 1, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5), 0, 0)); - panel.add(bExport, new GridBagConstraints(0, 5, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); - panel.add(bImport, new GridBagConstraints(1, 5, 1, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); - panel.add(lClient, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); - panel.add(cbClient, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5), 0, 0)); - } // jbInit - - /** - * Dynamic Init. - * - fill Language & Table - */ - private void dynInit() - { - // Fill Client - ArrayList clients = getClientList(); - for(KeyNamePair client: clients) - cbClient.addItem(client); - - // Fill Language - ArrayList languages = getLanguageList(); - for(ValueNamePair language: languages) - cbLanguage.addItem(language); - - // Fill Table - ArrayList tables = getTableList(); - for(ValueNamePair table: tables) - cbTable.addItem(table); - - // Info - setStatusBar(statusBar); - } // dynInit - - /** - * Initialize Panel - * @param WindowNo window - * @param frame frame - */ - public void init (int WindowNo, FormFrame frame) - { - log.info(""); - m_WindowNo = WindowNo; - m_frame = frame; - Env.setContext(Env.getCtx(), m_WindowNo, "IsSOTrx", "Y"); - try - { - jbInit(); - dynInit(); - frame.getContentPane().add(panel, BorderLayout.CENTER); - frame.getContentPane().add(statusBar, BorderLayout.SOUTH); - } - catch(Exception ex) - { - log.log(Level.SEVERE, "", ex); - } - } // init - - /** - * Dispose - */ - public void dispose() - { - m_frame.dispose(); - } // dispose - - /************************************************************************** - * Action Listener - * @param e event - */ - public void actionPerformed(ActionEvent e) - { - ValueNamePair AD_Language = (ValueNamePair)cbLanguage.getSelectedItem(); - if (AD_Language == null) - { - statusBar.setStatusLine(Msg.getMsg(Env.getCtx(), "LanguageSetupError"), true); - return; - } - ValueNamePair AD_Table = (ValueNamePair)cbTable.getSelectedItem(); - if (AD_Table == null) - return; - boolean imp = (e.getSource() == bImport); - KeyNamePair AD_Client = (KeyNamePair)cbClient.getSelectedItem(); - int AD_Client_ID = -1; - if (AD_Client != null) - AD_Client_ID = AD_Client.getKey(); - - String startDir = Ini.getAdempiereHome() + File.separator + "data"; - JFileChooser chooser = new JFileChooser(startDir); - chooser.setMultiSelectionEnabled(false); - chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); - int returnVal = imp ? chooser.showOpenDialog(panel) : chooser.showSaveDialog(panel); - if (returnVal != JFileChooser.APPROVE_OPTION) - return; - String directory = chooser.getSelectedFile().getAbsolutePath(); - // - statusBar.setStatusLine(directory); - panel.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); - Translation t = new Translation(Env.getCtx()); - String msg = t.validateLanguage(AD_Language.getValue()); - if (msg.length() > 0) - { - ADialog.error(m_WindowNo, panel, "LanguageSetupError", msg); - return; - } - - // All Tables - if (AD_Table.getValue().equals("")) - { - msg = null; - - for (int i = 1; i < cbTable.getItemCount(); i++) - { - AD_Table = (ValueNamePair)cbTable.getItemAt(i); - msg = imp - ? t.importTrl (directory, AD_Client_ID, AD_Language.getValue(), AD_Table.getValue()) - : t.exportTrl (directory, AD_Client_ID, AD_Language.getValue(), AD_Table.getValue(), isOnlyCentralized.isSelected()); - } - - if(msg == null || msg.length() == 0) - msg = (imp ? "Import" : "Export") + " Successful. [" + directory + "]"; - - statusBar.setStatusLine(directory); - } - else // single table - { - msg = null; - msg = imp - ? t.importTrl (directory, AD_Client_ID, AD_Language.getValue(), AD_Table.getValue()) - : t.exportTrl (directory, AD_Client_ID, AD_Language.getValue(), AD_Table.getValue(), isOnlyCentralized.isSelected()); - - if(msg == null || msg.length() == 0) - msg = (imp ? "Import" : "Export") + " Successful. [" + directory + "]"; - - statusBar.setStatusLine(msg); - } - // - panel.setCursor(Cursor.getDefaultCursor()); - } // actionPerformed - -} // Translation diff --git a/org.adempiere.ui.swing/src/org/compiere/install/package.html b/org.adempiere.ui.swing/src/org/compiere/install/package.html deleted file mode 100644 index f3bfb97c47..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/install/package.html +++ /dev/null @@ -1,30 +0,0 @@ - - - - - - - -

    Package org.compiere.install

    - -Language Pack Maintenance - -

    Related Documentation

    - -For overviews, tutorials, examples, guides, and tool documentation, please see: - - - - - - diff --git a/org.adempiere.ui.swing/src/org/compiere/license.html b/org.adempiere.ui.swing/src/org/compiere/license.html deleted file mode 100644 index a4e87c198d..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/license.html +++ /dev/null @@ -1,81 +0,0 @@ - - -Adempiere Public License - - - -
    -

    ADEMPIERE PUBLIC LICENSE

    - Version 1.2 -

    Contact info@adempiere.org for licensing alternatives.

    -

    GNU General Public License

    -

    Version 2, June 1991

    -
    Copyright (C) 1989, 1991 Free Software Foundation, Inc.  
    -59 Temple Place - Suite 330, Boston, MA  02111-1307, USA
    -
    -
    -Everyone is permitted to copy and distribute verbatim copies
    -of this license document, but changing it is not allowed.
    -  
    -
    -

    Preamble

    -

    The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Library General Public License instead.) You can apply it to your programs, too.

    -

    When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things.

    -

    To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it.

    -

    For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights.

    -

    We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software.

    -

    Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations.

    -

    Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all.

    -

    The precise terms and conditions for copying, distribution and modification follow.

    -

    TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION

    -

    0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". -

    Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. -

    1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. -

    You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. -

    2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: -

    -

    -
      -
    • a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. -
    • - b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. -
    • - c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) -
    -
    -
    These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it.
    -

    Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. -

    In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. -

    3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: - - -

    -
      -
    • a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, -
    • b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, -
    • -
      c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.)
      -
    • -
    -
    -
    The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable.
    -

    If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. -

    4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. -

    5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. -

    6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. -

    7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. -

    If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. -

    It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. -

    This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. -

    8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. -

    9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. -

    Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. -

    10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. -

    NO WARRANTY

    -

    11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. -

    12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. -

    -

    END OF TERMS AND CONDITION

    -

    - - diff --git a/org.adempiere.ui.swing/src/org/compiere/minigrid/CheckRenderer.java b/org.adempiere.ui.swing/src/org/compiere/minigrid/CheckRenderer.java deleted file mode 100644 index 0366fab85d..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/minigrid/CheckRenderer.java +++ /dev/null @@ -1,101 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ -package org.compiere.minigrid; - -import java.awt.Color; -import java.awt.Component; -import java.awt.Insets; - -import javax.swing.JCheckBox; -import javax.swing.JLabel; -import javax.swing.JTable; -import javax.swing.table.DefaultTableCellRenderer; - -import org.adempiere.plaf.AdempierePLAF; - -/** - * Check Box Renderer based on Boolean values - * - * @author Jorg Janke - * @version $Id: CheckRenderer.java,v 1.2 2006/07/30 00:51:28 jjanke Exp $ - */ -public final class CheckRenderer extends DefaultTableCellRenderer -{ - /** - * - */ - private static final long serialVersionUID = -7687503957742100068L; - - /** - * Constructor - */ - public CheckRenderer() - { - super(); - m_check.setMargin(new Insets(0,0,0,0)); - m_check.setHorizontalAlignment(JLabel.CENTER); - m_check.setOpaque(true); - } // CheckRenderer - - private JCheckBox m_check = new JCheckBox(); - - /** - * Return centered, white Check Box - * @param table - * @param value - * @param isSelected - * @param hasFocus - * @param row - * @param col - * @return Component - */ - public Component getTableCellRendererComponent(JTable table, Object value, - boolean isSelected, boolean hasFocus, int row, int col) - { - // Background & Foreground - Color bg = AdempierePLAF.getFieldBackground_Normal(); - // Selected is white on blue in Windows - if (isSelected && !hasFocus) - bg = table.getSelectionBackground(); - // row not selected or field has focus - else - { - // Inactive Background - if (!table.isCellEditable(row, col)) - bg = AdempierePLAF.getFieldBackground_Inactive(); - } - // Set Color - m_check.setBackground(bg); - - // Value - setValue(value); - return m_check; - } // getTableCellRendererComponent - - /** - * Set Value - * @param value - */ - public void setValue(Object value) - { - if (value != null && ((Boolean)value).booleanValue()) - m_check.setSelected(true); - else - m_check.setSelected(false); - } // setValue - -} // CheckRenderer diff --git a/org.adempiere.ui.swing/src/org/compiere/minigrid/IDColumnEditor.java b/org.adempiere.ui.swing/src/org/compiere/minigrid/IDColumnEditor.java deleted file mode 100644 index 58090c2927..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/minigrid/IDColumnEditor.java +++ /dev/null @@ -1,137 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ -package org.compiere.minigrid; - -import java.awt.Component; -import java.awt.Insets; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.util.EventObject; - -import javax.swing.AbstractCellEditor; -import javax.swing.JCheckBox; -import javax.swing.JLabel; -import javax.swing.JTable; -import javax.swing.event.ChangeEvent; -import javax.swing.table.TableCellEditor; - -import org.compiere.swing.CCheckBox; - -/** - * ID Column Editor (with Select Box). - * CheckBox change is only detected, if you move out of the cell. - * A ActionListener is added to the check box and the table forced - * to notice the change immediately. - * - * @author Jorg Janke - * @version $Id: IDColumnEditor.java,v 1.2 2006/07/30 00:51:28 jjanke Exp $ - */ -public class IDColumnEditor extends AbstractCellEditor - implements TableCellEditor, ActionListener -{ - /** - * - */ - private static final long serialVersionUID = 7263316764540177503L; - - /** - * Constructor - */ - public IDColumnEditor() - { - m_check.setMargin(new Insets(0,0,0,0)); - m_check.setHorizontalAlignment(JLabel.CENTER); - m_check.addActionListener(this); - } // IDColumnEditor - - /** the selection */ - private JCheckBox m_check = new CCheckBox(); - /** temporary value */ - private IDColumn m_value = null; - - private JTable m_table; - - /** - * Return Selection Status as IDColumn - * @return value - */ - public Object getCellEditorValue() - { - // log.fine( "IDColumnEditor.getCellEditorValue - " + m_check.isSelected()); - if (m_value != null) - m_value.setSelected (m_check.isSelected()); - return m_value; - } // getCellEditorValue - - /** - * Get visual Component - * @param table - * @param value - * @param isSelected - * @param row - * @param column - * @return Component - */ - public Component getTableCellEditorComponent (JTable table, Object value, boolean isSelected, int row, int column) - { - // log.fine( "IDColumnEditor.getTableCellEditorComponent", value); - m_table = table; - // set value - if (value != null && value instanceof IDColumn) - m_value = (IDColumn)value; - else - { - m_value = null; - return null; - //throw new IllegalArgumentException("ICColumnEditor.getTableCellEditorComponent - value=" + value); - } - // set editor value - m_check.setSelected(m_value.isSelected()); - return m_check; - } // getTableCellEditorComponent - - /** - * Can we edit it - * @param anEvent - * @return true (cobstant) - */ - public boolean isCellEditable (EventObject anEvent) - { - return true; - } // isCellEditable - - /** - * Can the cell be selected - * @param anEvent - * @return true (constant) - */ - public boolean shouldSelectCell (EventObject anEvent) - { - return true; - } // shouldSelectCell - - /** - * Action Listener - * @param e - */ - public void actionPerformed (ActionEvent e) - { - if (m_table != null) - m_table.editingStopped(new ChangeEvent(this)); - } // actionPerformed - -} // IDColumnEditor diff --git a/org.adempiere.ui.swing/src/org/compiere/minigrid/IDColumnRenderer.java b/org.adempiere.ui.swing/src/org/compiere/minigrid/IDColumnRenderer.java deleted file mode 100644 index ccc552648c..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/minigrid/IDColumnRenderer.java +++ /dev/null @@ -1,113 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ -package org.compiere.minigrid; - -import java.awt.Component; -import java.awt.Dimension; -import java.awt.Insets; - -import javax.swing.JButton; -import javax.swing.JCheckBox; -import javax.swing.JLabel; -import javax.swing.JTable; -import javax.swing.table.DefaultTableCellRenderer; - -/** - * ID Column Renderer - * - * @author Jorg Janke - * @version $Id: IDColumnRenderer.java,v 1.2 2006/07/30 00:51:28 jjanke Exp $ - */ -public class IDColumnRenderer extends DefaultTableCellRenderer -{ - /** - * - */ - private static final long serialVersionUID = -7513837304119751313L; - - /** - * Constructor - * @param multiSelection determines layout - button for single, check for multi - */ - public IDColumnRenderer(boolean multiSelection) - { - super(); - m_multiSelection = multiSelection; - // Multi => Check - if (m_multiSelection) - { - m_check = new JCheckBox(); - m_check.setMargin(new Insets(0,0,0,0)); - m_check.setHorizontalAlignment(JLabel.CENTER); - } - else // Single => Button - { - m_button = new JButton(); - m_button.setMargin(new Insets(0,0,0,0)); - m_button.setSize(new Dimension(5,5)); - } - } // IDColumnRenderer - - /** Mult-Selection flag */ - private boolean m_multiSelection; - /** The Single-Selection renderer */ - private JButton m_button; - /* The Multi-Selection renderer */ - private JCheckBox m_check; - - /** - * Set Value (for multi-selection) - * @param value - */ - protected void setValue(Object value) - { - if (m_multiSelection) - { - boolean sel = false; - if (value == null) - ; - else if (value instanceof IDColumn) - sel = ((IDColumn)value).isSelected(); - else if (value instanceof Boolean) - sel = ((Boolean)value).booleanValue(); - else - sel = value.toString().equals("Y"); - // - m_check.setSelected(sel); - } - } // setValue - - /** - * Return rendering component - * @param table - * @param value - * @param isSelected - * @param hasFocus - * @param row - * @param column - * @return Component (CheckBox or Button) - */ - public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) - { - setValue(value); - if (m_multiSelection) - return m_check; - else - return m_button; - } // setTableCellRenderereComponent - -} // IDColumnRenderer diff --git a/org.adempiere.ui.swing/src/org/compiere/minigrid/MiniCellEditor.java b/org.adempiere.ui.swing/src/org/compiere/minigrid/MiniCellEditor.java deleted file mode 100644 index 4ea6d81408..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/minigrid/MiniCellEditor.java +++ /dev/null @@ -1,110 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ -package org.compiere.minigrid; - -import java.awt.Component; -import java.math.BigDecimal; -import java.sql.Timestamp; - -import javax.swing.AbstractCellEditor; -import javax.swing.JTable; -import javax.swing.table.TableCellEditor; - -import org.compiere.grid.ed.VDate; -import org.compiere.grid.ed.VEditor; -import org.compiere.grid.ed.VNumber; -import org.compiere.grid.ed.VString; -import org.compiere.util.DisplayType; - -/** - * MiniTable Cell Editor based on class - Timestamp, BigDecimal - * - * @author Jorg Janke - * @version $Id: MiniCellEditor.java,v 1.2 2006/07/30 00:51:28 jjanke Exp $ - */ -public class MiniCellEditor extends AbstractCellEditor implements TableCellEditor -{ - /** - * - */ - private static final long serialVersionUID = 4431508736596874253L; - - /** - * Default Constructor - * @param c Class - */ - public MiniCellEditor(Class c) - { - super(); - // Date - if (c == Timestamp.class) - m_editor = new VDate(); - else if (c == BigDecimal.class) - m_editor = new VNumber("Amount", false, false, true, DisplayType.Amount, "Amount"); - else if (c == Double.class) - m_editor = new VNumber("Number", false, false, true, DisplayType.Number, "Number"); - else if (c == Integer.class) - m_editor = new VNumber("Integer", false, false, true, DisplayType.Integer, "Integer"); - else - m_editor = new VString(); - - } // MiniCellEditor - - private VEditor m_editor = null; - - /** - * Sets an initial value for the editor. This will cause the editor to - * stopEditing and lose any partially edited value if the editor is editing - * when this method is called. - * Returns the component that should be added to the client's Component hierarchy. - * Once installed in the client's hierarchy this component - * will then be able to draw and receive user input. - * @param table - * @param value - * @param isSelected - * @param row - * @param column - * @return Component - */ - public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) - { - // ADebug.trace(ADebug.l5_DData, "VCellEditor.getTableCellEditorComponent - " + value == null ? "null" : value.toString()); - - // Set Value - m_editor.setValue(value); - - // Set UI - m_editor.setBorder(null); - // m_editor.setBorder(UIManager.getBorder("Table.focusCellHighlightBorder")); - m_editor.setFont(table.getFont()); - return (Component)m_editor; - } // getTableCellEditorComponent - - /** - * Returns the value contained in the editor - * @return value - */ - public Object getCellEditorValue() - { - // ADebug.trace(ADebug.l5_DData, "VCellEditor.getCellEditorValue - "); - - if (m_editor != null) - return m_editor.getValue(); - return null; - } // getCellEditorValue - -} // MiniCellEditor diff --git a/org.adempiere.ui.swing/src/org/compiere/minigrid/MiniTable.java b/org.adempiere.ui.swing/src/org/compiere/minigrid/MiniTable.java deleted file mode 100644 index 4334ea0524..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/minigrid/MiniTable.java +++ /dev/null @@ -1,910 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ -package org.compiere.minigrid; - -import java.awt.Component; -import java.awt.Insets; -import java.math.BigDecimal; -import java.sql.ResultSet; -import java.sql.SQLException; -import java.sql.Timestamp; -import java.util.ArrayList; -import java.util.Collection; -import java.util.logging.Level; - -import javax.swing.DefaultCellEditor; -import javax.swing.SwingConstants; -import javax.swing.table.DefaultTableCellRenderer; -import javax.swing.table.DefaultTableModel; -import javax.swing.table.TableCellRenderer; -import javax.swing.table.TableColumn; -import javax.swing.table.TableModel; - -import org.compiere.apps.search.Info_Column; -import org.compiere.grid.ed.VCellRenderer; -import org.compiere.grid.ed.VHeaderRenderer; -import org.compiere.model.MRole; -import org.compiere.model.PO; -import org.compiere.swing.CCheckBox; -import org.compiere.swing.CTable; -import org.compiere.util.CLogger; -import org.compiere.util.DisplayType; -import org.compiere.util.Env; -import org.compiere.util.KeyNamePair; -import org.compiere.util.Util; - -/** - * Mini Table. - * Default Read Only Table for Boolean, String, Number, Timestamp values - *

    - * After initializing the Table Model, you need to call setColumnClass, - * add columns via addColumn or in one go prepare the table. - * - * MiniTable mt = new MiniTable(); - * String sql = mt.prepareTable(..); // table defined - * // add where to the sql statement - * ResultSet rs = .. - * mt.loadTable(rs); - * rs.close(); - * - * @author Jorg Janke - * @version $Id: MiniTable.java,v 1.3 2006/07/30 00:51:28 jjanke Exp $ - * - * @author Teo Sarca, SC ARHIPAC SERVICE SRL - *

  • BF [ 1891082 ] NPE on MiniTable when you hide some columns - *
  • FR [ 1974299 ] Add MiniTable.getSelectedKeys method - *
  • FR [ 2847295 ] MiniTable multiselection checkboxes not working - * https://sourceforge.net/tracker/?func=detail&atid=879335&aid=2847295&group_id=176962 - * @author Teo Sarca, teo.sarca@gmail.com - *
  • BF [ 2876895 ] MiniTable.loadTable: NPE if column is null - * https://sourceforge.net/tracker/?func=detail&aid=2876895&group_id=176962&atid=879332 - */ -public class MiniTable extends CTable implements IMiniTable -{ - /** - * - */ - private static final long serialVersionUID = 281959800766140642L; - - /** - * Default Constructor - */ - public MiniTable() - { - super(); - // log.config( "MiniTable"); - setCellSelectionEnabled(false); - setRowSelectionAllowed(false); - // Default Editor - this.setCellEditor(new ROCellEditor()); - } // MiniTable - - /** List of R/W columns */ - private ArrayList m_readWriteColumn = new ArrayList(); - /** List of Column Width */ - private ArrayList m_minWidth = new ArrayList(); - - /** Color Column Index of Model */ - private int m_colorColumnIndex = -1; - /** Color Column compare data */ - private Object m_colorDataCompare = Env.ZERO; - - /** Multi Selection mode (default false) */ - private boolean m_multiSelection = false; - - /** Lauout set in prepareTable and used in loadTable */ - private ColumnInfo[] m_layout = null; - /** Logger */ - private static CLogger log = CLogger.getCLogger(MiniTable.class); - /** Is Total Show */ - private boolean showTotals = false; - private boolean autoResize = true; - - public boolean isAutoResize() { - return autoResize; - } - - public void setAutoResize(boolean autoResize) { - this.autoResize = autoResize; - } - - /** - * Gets the swing column of given index. No index checking - * is done. - * - * @param col - * @return - */ - public TableColumn getColumn(int col) { - return(getColumnModel().getColumn(col)); - } - - /** - * Return number of columns in the mini table - */ - public int getColumnCount() { - return(getColumnModel().getColumnCount()); - } - - /** - * Size Columns. - * Uses Mimimum Column Size - */ - public void autoSize() - { - if ( !autoResize ) - return; - - long start = System.currentTimeMillis(); - // - final int SLACK = 8; // making sure it fits in a column - final int MAXSIZE = 300; // max size of a column - // - TableModel model = this.getModel(); - int size = model.getColumnCount(); - // for all columns - for (int col = 0; col < size; col++) - { - // Column & minimum width - TableColumn tc = this.getColumnModel().getColumn(col); - int width = 0; - if (m_minWidth.size() > col) - width = ((Integer)m_minWidth.get(col)).intValue(); - // log.config( "Column=" + col + " " + column.getHeaderValue()); - - // Header - TableCellRenderer renderer = tc.getHeaderRenderer(); - if (renderer == null) - renderer = new DefaultTableCellRenderer(); - Component comp = renderer.getTableCellRendererComponent - (this, tc.getHeaderValue(), false, false, 0, 0); - // log.fine( "Hdr - preferred=" + comp.getPreferredSize().width + ", width=" + comp.getWidth()); - width = Math.max(width, comp.getPreferredSize().width + SLACK); - - // Cells - int maxRow = Math.min(30, getRowCount()); // first 30 rows - for (int row = 0; row < maxRow; row++) - { - renderer = getCellRenderer(row, col); - comp = renderer.getTableCellRendererComponent - (this, getValueAt(row, col), false, false, row, col); - if (comp != null) { - int rowWidth = comp.getPreferredSize().width + SLACK; - width = Math.max(width, rowWidth); - } - } - // Width not greater .. - width = Math.min(MAXSIZE, width); - tc.setPreferredWidth(width); - // log.fine( "width=" + width); - } // for all columns - if (log.isLoggable(Level.FINER)) log.finer("Cols=" + size + " - " + (System.currentTimeMillis()-start) + "ms"); - } // autoSize - - - /** - * Is Cell Editable - * @param row row - * @param column column - * @return true if editable - */ - public boolean isCellEditable(int row, int column) - { - // if the first column is a boolean and it is false, it is not editable - if (column != 0 - && getValueAt(row, 0) instanceof Boolean - && !((Boolean)getValueAt(row, 0)).booleanValue()) - return false; - - // is the column RW? - if (m_readWriteColumn.contains(Integer.valueOf(column))) - return true; - return false; - } // isCellEditable - - /** - * Set Column to ReadOnly - * @param column column - * @param readOnly read only - */ - public void setColumnReadOnly (int column, boolean readOnly) - { - // Column is ReadWrite - if (m_readWriteColumn.contains(Integer.valueOf(column))) - { - // Remove from list - if (readOnly) - { - int size = m_readWriteColumn.size(); - for (int i = 0; i < size; i++) - { - if (((Integer)m_readWriteColumn.get(i)).intValue() == column) - { - m_readWriteColumn.remove(i); - break; - } - } - } // ReadOnly - } - // current column is R/O - ReadWrite - add to list - else if (!readOnly) - m_readWriteColumn.add(Integer.valueOf(column)); - } // setColumnReadOnly - - - /************************************************************************** - * Prepare Table and return SQL - * - * @param layout array of column info - * @param from SQL FROM content - * @param where SQL WHERE content - * @param multiSelection multiple selections - * @param tableName table name - * @return SQL - */ - public String prepareTable(ColumnInfo[] layout, - String from, String where, boolean multiSelection, String tableName) - { - m_layout = layout; - m_multiSelection = multiSelection; - // - StringBuilder sql = new StringBuilder ("SELECT "); - // add columns & sql - for (int i = 0; i < layout.length; i++) - { - // create sql - if (i > 0) - sql.append(", "); - sql.append(layout[i].getColSQL()); - // adding ID column - if (layout[i].isKeyPairCol()) - sql.append(",").append(layout[i].getKeyPairColSQL()); - - // add to model - addColumn(layout[i].getColHeader()); - if (layout[i].isColorColumn()) - setColorColumn(i); - if (layout[i].getColClass() == IDColumn.class) - p_keyColumnIndex = i; - } - // set editors (two steps) - for (int i = 0; i < layout.length; i++) - setColumnClass(i, layout[i].getColClass(), layout[i].isReadOnly(), layout[i].getColHeader()); - - sql.append( " FROM ").append(from); - sql.append(" WHERE ").append(where); - - // Table Selection - setRowSelectionAllowed(true); - - // org.compiere.apps.form.VMatch.dynInit calls routine for initial init only - if (from.length() == 0) - return sql.toString(); - // - String finalSQL = MRole.getDefault().addAccessSQL(sql.toString(), - tableName, MRole.SQL_FULLYQUALIFIED, MRole.SQL_RO); - log.finest(finalSQL); - return finalSQL; - } // prepareTable - - /** - * Add Table Column. - * after adding a column, you need to set the column classes again - * (DefaultTableModel fires TableStructureChanged, which calls - * JTable.tableChanged .. createDefaultColumnsFromModel - * @param header header - */ - public void addColumn (String header) - { - if (getModel() instanceof DefaultTableModel) - { - DefaultTableModel model = (DefaultTableModel)getModel(); - model.addColumn(Util.cleanAmp(header)); - } - else - throw new IllegalArgumentException("Model must be instance of DefaultTableModel"); - } // addColumn - - /** - * Set Column Editor & Renderer to Class. - * (after all columns were added) - * @param index column index - * @param c class of column - determines renderere - * @param readOnly read only flag - */ - public void setColumnClass (int index, Class c, boolean readOnly) - { - setColumnClass(index, c, readOnly, null); - } // setColumnClass - - /** - * Set Column Editor & Renderer to Class - * (after all columns were added) - * Lauout of IDColumn depemds on multiSelection - * @param index column index - * @param c class of column - determines renderere/editors supported: - * IDColumn, Boolean, Double (Quantity), BigDecimal (Amount), Integer, Timestamp, String (default) - * @param readOnly read only flag - * @param header optional header value - */ - public void setColumnClass (int index, Class c, boolean readOnly, String header) - { - // log.config( "MiniTable.setColumnClass - " + index, c.getName() + ", r/o=" + readOnly); - TableColumn tc = getColumnModel().getColumn(index); - if (tc == null) - return; - // Set R/O - setColumnReadOnly(index, readOnly); - - // Header - if (header != null && header.length() > 0) - tc.setHeaderValue(Util.cleanAmp(header)); - - // ID Column & Selection - if (c == IDColumn.class) - { - tc.setCellRenderer(new IDColumnRenderer(m_multiSelection)); - if (m_multiSelection) - { - tc.setCellEditor(new IDColumnEditor()); - setColumnReadOnly(index, false); - } - else - { - tc.setCellEditor(new ROCellEditor()); - } - m_minWidth.add(Integer.valueOf(10)); - tc.setMaxWidth(20); - tc.setPreferredWidth(20); - tc.setResizable(false); - - tc.setHeaderRenderer(new VHeaderRenderer(DisplayType.Number)); - } - // Boolean - else if (c == Boolean.class) - { - tc.setCellRenderer(new CheckRenderer()); - if (readOnly) - tc.setCellEditor(new ROCellEditor()); - else - { - CCheckBox check = new CCheckBox(); - check.setMargin(new Insets(0,0,0,0)); - check.setHorizontalAlignment(SwingConstants.CENTER); - tc.setCellEditor(new DefaultCellEditor(check)); - } - m_minWidth.add(Integer.valueOf(30)); - - tc.setHeaderRenderer(new VHeaderRenderer(DisplayType.YesNo)); - } - // Date - else if (c == Timestamp.class) - { - tc.setCellRenderer(new VCellRenderer(DisplayType.Date)); - if (readOnly) - tc.setCellEditor(new ROCellEditor()); - else - tc.setCellEditor(new MiniCellEditor(c)); - m_minWidth.add(Integer.valueOf(30)); - - tc.setHeaderRenderer(new VHeaderRenderer(DisplayType.DateTime)); - } - // Amount - else if (c == BigDecimal.class) - { - tc.setCellRenderer(new VCellRenderer(DisplayType.Amount)); - if (readOnly) - { - tc.setCellEditor(new ROCellEditor()); - m_minWidth.add(Integer.valueOf(70)); - } - else - { - tc.setCellEditor(new MiniCellEditor(c)); - m_minWidth.add(Integer.valueOf(80)); - } - - tc.setHeaderRenderer(new VHeaderRenderer(DisplayType.Number)); - } - // Number - else if (c == Double.class) - { - tc.setCellRenderer(new VCellRenderer(DisplayType.Number)); - if (readOnly) - { - tc.setCellEditor(new ROCellEditor()); - m_minWidth.add(Integer.valueOf(70)); - } - else - { - tc.setCellEditor(new MiniCellEditor(c)); - m_minWidth.add(Integer.valueOf(80)); - } - - tc.setHeaderRenderer(new VHeaderRenderer(DisplayType.Number)); - } - // Integer - else if (c == Integer.class) - { - tc.setCellRenderer(new VCellRenderer(DisplayType.Integer)); - if (readOnly) - tc.setCellEditor(new ROCellEditor()); - else - tc.setCellEditor(new MiniCellEditor(c)); - m_minWidth.add(Integer.valueOf(30)); - - tc.setHeaderRenderer(new VHeaderRenderer(DisplayType.Number)); - } - // String - else - { - tc.setCellRenderer(new VCellRenderer(DisplayType.String)); - if (readOnly) - tc.setCellEditor(new ROCellEditor()); - else - tc.setCellEditor(new MiniCellEditor(String.class)); - m_minWidth.add(Integer.valueOf(30)); - - tc.setHeaderRenderer(new VHeaderRenderer(DisplayType.String)); - } - // log.fine( "Renderer=" + tc.getCellRenderer().toString() + ", Editor=" + tc.getCellEditor().toString()); - } // setColumnClass - - /** - * Clear Table Content - * @param no number of rows - */ - public void setRowCount (int no) - { - if (getModel() instanceof DefaultTableModel) - { - DefaultTableModel model = (DefaultTableModel)getModel(); - model.setRowCount(no); - // log.config( "MiniTable.setRowCount", "rows=" + getRowCount() + ", cols=" + getColumnCount()); - } - else - throw new IllegalArgumentException("Model must be instance of DefaultTableModel"); - } // setRowCount - - - /************************************************************************** - * Load Table from ResultSet - The ResultSet is not closed - * - * @param rs ResultSet with the column layout defined in prepareTable - */ - public void loadTable(ResultSet rs) - { - if (m_layout == null) - throw new UnsupportedOperationException("Layout not defined"); - - // Clear Table - setRowCount(0); - // - try - { - while (rs.next()) - { - int row = getRowCount(); - setRowCount(row+1); - int colOffset = 1; // columns start with 1 - for (int col = 0; col < m_layout.length; col++) - { - Object data = null; - Class c = m_layout[col].getColClass(); - int colIndex = col + colOffset; - if (c == IDColumn.class) - data = new IDColumn(rs.getInt(colIndex)); - else if (c == Boolean.class) - data = Boolean.valueOf("Y".equals(rs.getString(colIndex))); - else if (c == Timestamp.class) - data = rs.getTimestamp(colIndex); - else if (c == BigDecimal.class) - data = rs.getBigDecimal(colIndex); - else if (c == Double.class) - data = rs.getDouble(colIndex); - else if (c == Integer.class) - data = rs.getInt(colIndex); - else if (c == KeyNamePair.class) - { - String display = rs.getString(colIndex); - int key = rs.getInt(colIndex+1); - data = new KeyNamePair(key, display); - colOffset++; - } - else - { - String s = rs.getString(colIndex); - if (s != null) - data = s.trim(); // problems with NCHAR - } - // store - setValueAt(data, row, col); - // log.fine( "r=" + row + ", c=" + col + " " + m_layout[col].getColHeader(), - // "data=" + data.toString() + " " + data.getClass().getName() + " * " + m_table.getCellRenderer(row, col)); - } - - - } - } - catch (SQLException e) - { - log.log(Level.SEVERE, "", e); - } - if(getShowTotals()) - addTotals(m_layout); - autoSize(); - if (log.isLoggable(Level.CONFIG)) log.config("Row(rs)=" + getRowCount()); - - - } // loadTable - - /** - * Load Table from Object Array - * @param pos array of POs - */ - public void loadTable(PO[] pos) - { - if (m_layout == null) - throw new UnsupportedOperationException("Layout not defined"); - - // Clear Table - setRowCount(0); - // - for (int i = 0; i < pos.length; i++) - { - PO myPO = pos[i]; - int row = getRowCount(); - setRowCount(row+1); - - for (int col = 0; col < m_layout.length; col++) - { - String columnName = m_layout[col].getColSQL(); - Object data = myPO.get_Value(columnName); - if (data != null) - { - Class c = m_layout[col].getColClass(); - if (c == IDColumn.class) - data = new IDColumn(((Integer)data).intValue()); - else if (c == Double.class) - data = Double.valueOf(((BigDecimal)data).doubleValue()); - } - // store - setValueAt(data, row, col); - } - } - if(getShowTotals()) - addTotals(m_layout); - autoSize(); - if (log.isLoggable(Level.CONFIG)) log.config("Row(array)=" + getRowCount()); - } // loadTable - - - /** - * Get the key of currently selected row based on layout defined in prepareTable - * @return ID if key - */ - public Integer getSelectedRowKey() - { - if (m_layout == null) - throw new UnsupportedOperationException("Layout not defined"); - - int row = getSelectedRow(); - if (row != -1 && p_keyColumnIndex != -1) - { - Object data = getModel().getValueAt(row, p_keyColumnIndex); - if (data instanceof IDColumn) - data = ((IDColumn)data).getRecord_ID(); - if (data instanceof Integer) - return (Integer)data; - } - return null; - } // getSelectedRowKey - - /** - * @return collection of selected IDs - */ - public Collection getSelectedKeys() - { - if (m_layout == null) - { - throw new UnsupportedOperationException("Layout not defined"); - } - if (p_keyColumnIndex < 0) - { - throw new UnsupportedOperationException("Key Column is not defined"); - } - // - ArrayList list = new ArrayList(); - for (int row = 0; row < getRowCount(); row++) - { - Object data = getModel().getValueAt(row, p_keyColumnIndex); - if (data instanceof IDColumn) - { - IDColumn record = (IDColumn)data; - if (record.isSelected()) - { - list.add(record.getRecord_ID()); - } - } - } - return list; - } - - /************************************************************************** - * Get Layout - * @return Array of ColumnInfo - */ - public ColumnInfo[] getLayoutInfo() - { - return m_layout; - } // getLayout - - /** - * Set Single Selection - * @param multiSelection multiple selections - */ - public void setMultiSelection (boolean multiSelection) - { - m_multiSelection = multiSelection; - } // setMultiSelection - - /** - * Single Selection Table - * @return true if multiple rows can be selected - */ - public boolean isMultiSelection() - { - return m_multiSelection; - } // isMultiSelection - - /** - * Set the Column to determine the color of the row (based on model index) - * @param modelIndex model index - */ - public void setColorColumn (int modelIndex) - { - m_colorColumnIndex = modelIndex; - } // setColorColumn - - /** - * Set ColorColumn comparison criteria - * @param dataCompare data - */ - public void setColorCompare (Object dataCompare) - { - m_colorDataCompare = dataCompare; - } // - - /** - * Get ColorCode for Row. - *
    -	 *	If numerical value in compare column is
    -	 *		negative = -1,
    -	 *      positive = 1,
    -	 *      otherwise = 0
    -	 *  If Timestamp
    -	 *  
    - * @param row row - * @return color code - */ - public int getColorCode (int row) - { - if (m_colorColumnIndex == -1) - return 0; - - Object data = getModel().getValueAt(row, m_colorColumnIndex); - int cmp = 0; - - // We need to have a Number - if (data == null) - return 0; - try - { - if (data instanceof Timestamp) - { - if (m_colorDataCompare == null || !(m_colorDataCompare instanceof Timestamp)) - m_colorDataCompare = new Timestamp(System.currentTimeMillis()); - cmp = ((Timestamp)m_colorDataCompare).compareTo((Timestamp)data); - } - else - { - if (m_colorDataCompare == null || !(m_colorDataCompare instanceof BigDecimal)) - m_colorDataCompare = Env.ZERO; - if (!(data instanceof BigDecimal)) - data = new BigDecimal(data.toString()); - cmp = ((BigDecimal)m_colorDataCompare).compareTo((BigDecimal)data); - } - } - catch (Exception e) - { - return 0; - } - if (cmp > 0) - return -1; - if (cmp < 0) - return 1; - return 0; - } // getColorCode - - - /** - * Set if Totals is Show - * @param boolean Show - */ - public void setShowTotals(boolean show) - { - showTotals= show; - } - /** - * get if Totals is Show - * @param boolean Show - */ - public boolean getShowTotals() - { - return showTotals; - } - - /** - * Adding a new row with the totals - */ - public void addTotals(ColumnInfo[] layout) - { - if (getRowCount() == 0 || layout.length == 0) - return; - - Object[] total = new Object[layout.length]; - - for (int row = 0 ; row < getRowCount(); row ++) - { - - for (int col = 0; col < layout.length; col++) - { - Object data = getModel().getValueAt(row, col); - Class c = layout[col].getColClass(); - if (c == BigDecimal.class) - { - BigDecimal subtotal = Env.ZERO; - if(total[col]!= null) - subtotal = (BigDecimal)(total[col]); - - BigDecimal amt = (BigDecimal) data; - if(subtotal == null) - subtotal = Env.ZERO; - if(amt == null ) - amt = Env.ZERO; - total[col] = subtotal.add(amt); - } - else if (c == Double.class) - { - Double subtotal = Double.valueOf(0); - if(total[col] != null) - subtotal = (Double)(total[col]); - - Double amt = (Double) data; - if(subtotal == null) - subtotal = Double.valueOf(0); - if(amt == null ) - amt = Double.valueOf(0); - total[col] = subtotal + amt; - - } - } - } - - //adding total row - - int row = getRowCount() + 1; - setRowCount(row); - for (int col = 0; col < layout.length; col++) - { - Class c = layout[col].getColClass(); - if (c == BigDecimal.class) - { - setValueAt(total[col] , row - 1, col); - } - else if (c == Double.class) - { - setValueAt(total[col] , row -1 , col); - } - else - { - if(col == 0 ) - { - setValueAt(" ÎŁ " , row -1 , col); - } - else - setValueAt(null , row - 1, col ); - } - - } - } - - /** - * Adding a new row with the totals - */ - public void addTotals(Info_Column[] layout) - { - if (getRowCount() == 0 || layout.length == 0) - return; - - Object[] total = new Object[layout.length]; - - for (int row = 0 ; row < getRowCount(); row ++) - { - - for (int col = 0; col < layout.length; col++) - { - Object data = getModel().getValueAt(row, col); - Class c = layout[col].getColClass(); - if (c == BigDecimal.class) - { - BigDecimal subtotal = Env.ZERO; - if(total[col]!= null) - subtotal = (BigDecimal)(total[col]); - - BigDecimal amt = (BigDecimal) data; - if(subtotal == null) - subtotal = Env.ZERO; - if(amt == null ) - amt = Env.ZERO; - total[col] = subtotal.add(amt); - } - else if (c == Double.class) - { - Double subtotal = Double.valueOf(0); - if(total[col] != null) - subtotal = (Double)(total[col]); - - Double amt = (Double) data; - if(subtotal == null) - subtotal = Double.valueOf(0); - if(amt == null ) - amt = Double.valueOf(0); - total[col] = subtotal + amt; - - } - } - } - - //adding total row - - int row = getRowCount() + 1; - setRowCount(row); - for (int col = 0; col < layout.length; col++) - { - Class c = layout[col].getColClass(); - if (c == BigDecimal.class) - { - setValueAt(total[col] , row - 1, col); - } - else if (c == Double.class) - { - setValueAt(total[col] , row -1 , col); - } - else - { - if(col == 1 ) - { - setValueAt(" ÎŁ " , row -1 , col ); - } - else - setValueAt(null , row - 1, col ); - } - - } - } -} // MiniTable diff --git a/org.adempiere.ui.swing/src/org/compiere/minigrid/ROCellEditor.java b/org.adempiere.ui.swing/src/org/compiere/minigrid/ROCellEditor.java deleted file mode 100644 index e8af206a52..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/minigrid/ROCellEditor.java +++ /dev/null @@ -1,54 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ -package org.compiere.minigrid; - -import java.util.EventObject; - -import javax.swing.DefaultCellEditor; -import javax.swing.JTextField; - -/** - * Read Only Cell Renderer - * - * @author Jorg Janke - * @version $Id: ROCellEditor.java,v 1.2 2006/07/30 00:51:28 jjanke Exp $ - */ -public final class ROCellEditor extends DefaultCellEditor -{ - /** - * - */ - private static final long serialVersionUID = 1957123963696065686L; - - /** - * Constructor - */ - public ROCellEditor() - { - super(new JTextField()); - } // ROCellEditor - - /** - * Indicate RO - * @param anEvent - * @return false - */ - public boolean isCellEditable(EventObject anEvent) - { - return false; - } // isCellEditable -} // ROCellEditor diff --git a/org.adempiere.ui.swing/src/org/compiere/minigrid/package.html b/org.adempiere.ui.swing/src/org/compiere/minigrid/package.html deleted file mode 100644 index 04e562d3e5..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/minigrid/package.html +++ /dev/null @@ -1,30 +0,0 @@ - - - - - - - -

    Package org.compiere.minigrid

    - -Custom JTable for use in custom application form. - -

    Related Documentation

    - -For overviews, tutorials, examples, guides, and tool documentation, please see: - - - - - - diff --git a/org.adempiere.ui.swing/src/org/compiere/plaf/Adempiere200x100.gif b/org.adempiere.ui.swing/src/org/compiere/plaf/Adempiere200x100.gif deleted file mode 100644 index f3e3c93682..0000000000 Binary files a/org.adempiere.ui.swing/src/org/compiere/plaf/Adempiere200x100.gif and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/compiere/plaf/AquaTheme.java b/org.adempiere.ui.swing/src/org/compiere/plaf/AquaTheme.java deleted file mode 100644 index d1735c6797..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/plaf/AquaTheme.java +++ /dev/null @@ -1,44 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ -package org.compiere.plaf; - -/* - * @(#)AquaTheme.java 1.9 04/07/26 - */ -import javax.swing.plaf.ColorUIResource; -import javax.swing.plaf.metal.DefaultMetalTheme; - - -/** - * This class describes a theme using "blue-green" colors. - * - * 1.9 07/26/04 - * @author Steve Wilson - */ -public class AquaTheme extends DefaultMetalTheme { - - public String getName() { return "Aqua"; } - - private final ColorUIResource primary1 = new ColorUIResource(102, 153, 153); - private final ColorUIResource primary2 = new ColorUIResource(128, 192, 192); - private final ColorUIResource primary3 = new ColorUIResource(159, 235, 235); - - protected ColorUIResource getPrimary1() { return primary1; } - protected ColorUIResource getPrimary2() { return primary2; } - protected ColorUIResource getPrimary3() { return primary3; } - -} diff --git a/org.adempiere.ui.swing/src/org/compiere/plaf/CharcoalTheme.java b/org.adempiere.ui.swing/src/org/compiere/plaf/CharcoalTheme.java deleted file mode 100644 index 7fa0ec1bc5..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/plaf/CharcoalTheme.java +++ /dev/null @@ -1,59 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ -package org.compiere.plaf; - -/* - * @(#)CharcoalTheme.java 1.9 04/07/26 - */ - - -import javax.swing.plaf.ColorUIResource; -import javax.swing.plaf.metal.DefaultMetalTheme; - -/** - * This class describes a theme using gray colors. - * - * 1.9 07/26/04 - * @author Steve Wilson - */ -public class CharcoalTheme extends DefaultMetalTheme { - - public String getName() { return "Charcoal"; } - - private final ColorUIResource primary1 = new ColorUIResource(66, 33, 66); - private final ColorUIResource primary2 = new ColorUIResource(90, 86, 99); - private final ColorUIResource primary3 = new ColorUIResource(99, 99, 99); - - private final ColorUIResource secondary1 = new ColorUIResource(0, 0, 0); - private final ColorUIResource secondary2 = new ColorUIResource(51, 51, 51); - private final ColorUIResource secondary3 = new ColorUIResource(102, 102, 102); - - private final ColorUIResource black = new ColorUIResource(222, 222, 222); - private final ColorUIResource white = new ColorUIResource(0, 0, 0); - - protected ColorUIResource getPrimary1() { return primary1; } - protected ColorUIResource getPrimary2() { return primary2; } - protected ColorUIResource getPrimary3() { return primary3; } - - protected ColorUIResource getSecondary1() { return secondary1; } - protected ColorUIResource getSecondary2() { return secondary2; } - protected ColorUIResource getSecondary3() { return secondary3; } - - protected ColorUIResource getBlack() { return black; } - protected ColorUIResource getWhite() { return white; } - -} diff --git a/org.adempiere.ui.swing/src/org/compiere/plaf/CompiereButtonListener.java b/org.adempiere.ui.swing/src/org/compiere/plaf/CompiereButtonListener.java deleted file mode 100644 index 252fa8afc1..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/plaf/CompiereButtonListener.java +++ /dev/null @@ -1,105 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ -package org.compiere.plaf; - -import java.awt.event.ActionEvent; -import java.beans.PropertyChangeEvent; - -import javax.swing.AbstractButton; -import javax.swing.InputMap; -import javax.swing.JCheckBox; -import javax.swing.JComponent; -import javax.swing.KeyStroke; -import javax.swing.SwingUtilities; -import javax.swing.plaf.ComponentInputMapUIResource; -import javax.swing.plaf.basic.BasicButtonListener; - -/** - * Button Listener - * - * @author Jorg Janke - * @version $Id: AdempiereButtonListener.java,v 1.2 2006/07/30 00:52:24 jjanke Exp $ - */ -public class CompiereButtonListener extends BasicButtonListener -{ - /** - * Adempiere Button Listener - * @param b button - */ - public CompiereButtonListener (AbstractButton b) - { - super (b); - } // AdempiereButtonListener - - /** - * Install Keyboard Actions - * @param c component - */ - public void installKeyboardActions (JComponent c) - { - super.installKeyboardActions (c); - updateMnemonicBindingX ((AbstractButton)c); - } // installKeyboardActions - - /** - * Property Change - * @param e event - */ - public void propertyChange (PropertyChangeEvent e) - { - String prop = e.getPropertyName(); - if (prop.equals(AbstractButton.MNEMONIC_CHANGED_PROPERTY)) - updateMnemonicBindingX ((AbstractButton)e.getSource()); - else - super.propertyChange (e); - } // propertyChange - - /** - * Update Mnemonic Binding - * @param b button - */ - void updateMnemonicBindingX (AbstractButton b) - { - int m = b.getMnemonic(); - if (m != 0) - { - InputMap map = SwingUtilities.getUIInputMap(b, JComponent.WHEN_IN_FOCUSED_WINDOW); - - if (map == null) - { - map = new ComponentInputMapUIResource(b); - SwingUtilities.replaceUIInputMap(b, JComponent.WHEN_IN_FOCUSED_WINDOW, map); - } - map.clear(); - String className = b.getClass().getName(); - int mask = ActionEvent.ALT_MASK; // Default Buttons - if (b instanceof JCheckBox // In Tab - || className.indexOf("VButton") != -1) - mask = ActionEvent.SHIFT_MASK + ActionEvent.CTRL_MASK; - map.put(KeyStroke.getKeyStroke(m, mask, false), "pressed"); - map.put(KeyStroke.getKeyStroke(m, mask, true), "released"); - map.put(KeyStroke.getKeyStroke(m, 0, true), "released"); - } - else - { - InputMap map = SwingUtilities.getUIInputMap(b, JComponent.WHEN_IN_FOCUSED_WINDOW); - if (map != null) - map.clear(); - } - } // updateMnemonicBindingX - -} // AdempiereButtonListener diff --git a/org.adempiere.ui.swing/src/org/compiere/plaf/CompiereButtonUI.java b/org.adempiere.ui.swing/src/org/compiere/plaf/CompiereButtonUI.java deleted file mode 100644 index 88f498ee61..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/plaf/CompiereButtonUI.java +++ /dev/null @@ -1,137 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ -package org.compiere.plaf; - -import java.awt.Graphics; -import java.awt.Graphics2D; - -import javax.swing.AbstractButton; -import javax.swing.ButtonModel; -import javax.swing.JComponent; -import javax.swing.JToolBar; -import javax.swing.plaf.ComponentUI; -import javax.swing.plaf.basic.BasicButtonListener; -import javax.swing.plaf.metal.MetalButtonUI; - -/** - * Button UI - * - * @author Jorg Janke - * @version $Id: AdempiereButtonUI.java,v 1.2 2006/07/30 00:52:24 jjanke Exp $ - */ -public class CompiereButtonUI extends MetalButtonUI -{ - /** - * Static Create UI - * @param c - * @return Adempiere Button UI - */ - public static ComponentUI createUI (JComponent c) - { - return s_buttonUI; - } // createUI - - /** UI shared */ - private static CompiereButtonUI s_buttonUI = new CompiereButtonUI(); - - - /************************************************************************** - * Install Defaults - * @param b - */ - public void installDefaults(AbstractButton b) - { - super.installDefaults(b); - b.setOpaque(false); - } // installDefaults - - /** - * Update. - * This method is invoked by JComponent when the specified - * component is being painted. - * - * By default this method will fill the specified component with - * its background color (if its opaque property is - * true) and then immediately call paint. - * - * @param g the Graphics context in which to paint - * @param c the component being painted - * - * @see #paint - * @see javax.swing.JComponent#paintComponent - */ - public void update(Graphics g, JComponent c) - { - // System.out.println(c.getClass() + " ** " + ((JButton)c).getText() + " ** " + c.isOpaque()); - if (c.isOpaque()) - CompiereUtils.fillRectange((Graphics2D)g, c, CompiereLookAndFeel.ROUND); - paint (g, c); - } // update - - /** - * Paint 3D boxes - * @param g - * @param c - */ - public void paint (Graphics g, JComponent c) - { - super.paint( g, c); - AbstractButton b = (AbstractButton) c; - ButtonModel model = b.getModel(); - boolean in = model.isPressed() || model.isSelected(); - // - if (b.isBorderPainted()) - CompiereUtils.paint3Deffect((Graphics2D)g, c, CompiereLookAndFeel.ROUND, !in); - } // paint - - /** - * Don't get selected Color - use default (otherwise the pressed button is gray) - * @param g - * @param b - */ - protected void paintButtonPressed(Graphics g, AbstractButton b) - { - // if (b.isContentAreaFilled()) - // { - // Dimension size = b.getSize(); - // g.setColor(getSelectColor()); - // g.fillRect(0, 0, size.width, size.height); - // } - } // paintButtonPressed - - /** - * Is Tool Bar Button - * @param c - * @return true if toolbar - */ - boolean isToolBarButton(JComponent c) - { - return (c.getParent() instanceof JToolBar); - } // isToolBarButton - - - /** - * Create Button Listener - * @param b button - * @return listener - */ - protected BasicButtonListener createButtonListener (AbstractButton b) - { - return new CompiereButtonListener(b); - } // createButtonListener - -} // AdempiereButtonUI diff --git a/org.adempiere.ui.swing/src/org/compiere/plaf/CompiereCheckBoxMenuItemUI.java b/org.adempiere.ui.swing/src/org/compiere/plaf/CompiereCheckBoxMenuItemUI.java deleted file mode 100644 index 2c2cad52c6..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/plaf/CompiereCheckBoxMenuItemUI.java +++ /dev/null @@ -1,51 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ -package org.compiere.plaf; - -import javax.swing.JComponent; -import javax.swing.plaf.ComponentUI; -import javax.swing.plaf.basic.BasicCheckBoxMenuItemUI; - -/** - * Menu Check Box UI - * - * @author Jorg Janke - * @version $Id: AdempiereCheckBoxMenuItemUI.java,v 1.2 2006/07/30 00:52:24 jjanke Exp $ - */ -public class CompiereCheckBoxMenuItemUI extends BasicCheckBoxMenuItemUI -{ - /** - * Create own instance - * @param c compoment - * @return AdempiereMenuBarUI - */ - public static ComponentUI createUI(JComponent c) - { - return new CompiereMenuItemUI(); - } // createUI - - /** - * Install UI - * @param c - */ - public void installUI (JComponent c) - { - super.installUI(c); - c.setOpaque(false); // use MenuBarUI background - } // installUI - -} // AdempiereCheckBoxMenuItemUI diff --git a/org.adempiere.ui.swing/src/org/compiere/plaf/CompiereCheckBoxUI.java b/org.adempiere.ui.swing/src/org/compiere/plaf/CompiereCheckBoxUI.java deleted file mode 100644 index 6439b7319e..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/plaf/CompiereCheckBoxUI.java +++ /dev/null @@ -1,67 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ -package org.compiere.plaf; - -import javax.swing.AbstractButton; -import javax.swing.JComponent; -import javax.swing.plaf.ComponentUI; -import javax.swing.plaf.basic.BasicButtonListener; -import javax.swing.plaf.metal.MetalCheckBoxUI; - -/** - * Check Box UI - * - * @author Jorg Janke - * @version $Id: AdempiereCheckBoxUI.java,v 1.2 2006/07/30 00:52:24 jjanke Exp $ - */ -public class CompiereCheckBoxUI extends MetalCheckBoxUI -{ - /** - * Create UI - * @param b - * @return ComponentUI - */ - public static ComponentUI createUI (JComponent b) - { - return s_checkBoxUI; - } // createUI - - /** UI shared */ - private static CompiereCheckBoxUI s_checkBoxUI = new CompiereCheckBoxUI(); - - - /************************************************************************** - * Install Defaults - * @param b - */ - public void installDefaults (AbstractButton b) - { - super.installDefaults(b); - b.setOpaque(false); - } // installDefaults - - /** - * Create Button Listener - * @param b button - * @return listener - */ - protected BasicButtonListener createButtonListener (AbstractButton b) - { - return new CompiereButtonListener(b); - } // createButtonListener - -} // AdempiereCheckBoxUI diff --git a/org.adempiere.ui.swing/src/org/compiere/plaf/CompiereColor.java b/org.adempiere.ui.swing/src/org/compiere/plaf/CompiereColor.java deleted file mode 100644 index 2285f07734..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/plaf/CompiereColor.java +++ /dev/null @@ -1,1308 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ -package org.compiere.plaf; - -import java.awt.AlphaComposite; -import java.awt.BasicStroke; -import java.awt.Color; -import java.awt.Container; -import java.awt.GradientPaint; -import java.awt.Graphics; -import java.awt.Graphics2D; -import java.awt.Point; -import java.awt.Rectangle; -import java.awt.TexturePaint; -import java.awt.Window; -import java.awt.image.BufferedImage; -import java.io.Serializable; -import java.math.BigDecimal; -import java.net.URL; -import java.util.ResourceBundle; -import java.util.logging.Level; -import java.util.logging.Logger; - -import javax.swing.JComponent; -import javax.swing.JDialog; -import javax.swing.JFrame; -import javax.swing.JPanel; -import javax.swing.JWindow; -import javax.swing.SwingConstants; -import javax.swing.UIManager; -import javax.swing.plaf.ColorUIResource; - -import org.adempiere.plaf.AdempierePLAF; -import org.compiere.model.MColor; -import org.compiere.swing.ColorBlind; -import org.compiere.swing.ThemeUtils; -import org.compiere.util.KeyNamePair; -import org.compiere.util.ValueNamePair; - -/** - * Adempiere Background Color - * - * @author Jorg Janke - * @version $Id: AdempiereColor.java,v 1.2 2006/07/30 00:52:24 jjanke Exp $ - */ -public class CompiereColor implements Serializable -{ - /** - * - */ - private static final long serialVersionUID = 756220720952973781L; - /** Background type Flat */ - public static final String TYPE_FLAT = "F"; - /** Background type Gradient */ - public static final String TYPE_GRADIENT = "G"; - /** Background type Lines */ - public static final String TYPE_LINES = "L"; - /** Background type Texture */ - public static final String TYPE_TEXTURE = "T"; - - /** Names */ - private static ResourceBundle s_res = ResourceBundle.getBundle("org.compiere.plaf.PlafRes"); - - /** Type Values */ - public static final String[] TYPE_VALUES = new String[] { - TYPE_FLAT, TYPE_GRADIENT, TYPE_LINES, TYPE_TEXTURE - }; - /** Type Names */ - public static final String[] TYPE_NAMES = new String[] { - s_res.getString("BackColType_Flat"), - s_res.getString("BackColType_Gradient"), - s_res.getString("BackColType_Lines"), - s_res.getString("BackColType_Texture") - }; - /** Types */ - public static final ValueNamePair[] TYPES = new ValueNamePair[] { - new ValueNamePair(TYPE_VALUES[0], TYPE_NAMES[0]), - new ValueNamePair(TYPE_VALUES[1], TYPE_NAMES[1]), - new ValueNamePair(TYPE_VALUES[2], TYPE_NAMES[2]), - new ValueNamePair(TYPE_VALUES[3], TYPE_NAMES[3]) - }; - - /** Gradient Starting Values */ - public static final int[] GRADIENT_SP_VALUES = new int[] { - SwingConstants.NORTH, SwingConstants.NORTH_EAST, - SwingConstants.EAST, SwingConstants.SOUTH_EAST, - SwingConstants.SOUTH, SwingConstants.SOUTH_WEST, - SwingConstants.WEST, SwingConstants.NORTH_WEST - }; - /** Gradient Starting Names */ - public static final String[] GRADIENT_SP_NAMES = new String[] { - "North", "North-East", - "East", "South-East", - "South", "South-West", - "West", "North-West" - }; - /** Gradient Starting Point */ - public static final KeyNamePair[] GRADIENT_SP = new KeyNamePair[] { - new KeyNamePair(GRADIENT_SP_VALUES[0], GRADIENT_SP_NAMES[0]), - new KeyNamePair(GRADIENT_SP_VALUES[1], GRADIENT_SP_NAMES[1]), - new KeyNamePair(GRADIENT_SP_VALUES[2], GRADIENT_SP_NAMES[2]), - new KeyNamePair(GRADIENT_SP_VALUES[3], GRADIENT_SP_NAMES[3]), - new KeyNamePair(GRADIENT_SP_VALUES[4], GRADIENT_SP_NAMES[4]), - new KeyNamePair(GRADIENT_SP_VALUES[5], GRADIENT_SP_NAMES[5]), - new KeyNamePair(GRADIENT_SP_VALUES[6], GRADIENT_SP_NAMES[6]), - new KeyNamePair(GRADIENT_SP_VALUES[7], GRADIENT_SP_NAMES[7]) - }; - /** Exception text */ - private static final String EXCEPTION_TEXT = "Arguments cannot be NULL"; - - - /************************************************************************** - * Set Background of Component to default color - * @param c component - */ - public static void setBackground (JComponent c) - { - setBackground (c, new CompiereColor(AdempierePLAF.getFormBackground())); - } // setBackground - - /** - * Set Background of Component - * @param c Component - * @param cc Color - */ - public static void setBackground (JComponent c, CompiereColor cc) - { - c.putClientProperty(CompiereLookAndFeel.BACKGROUND, cc); - } // setBackground - - /** - * Get Background Color of component - * @param c JComponent - * @return Color - */ - public static CompiereColor getBackground (JComponent c) - { - CompiereColor bg = null; - try - { - bg = (CompiereColor)c.getClientProperty(CompiereLookAndFeel.BACKGROUND); - } - catch (Exception e) - { - log.severe("ClientProperty: " + e.getMessage()); - } - return bg; - } // getBackground - - /** - * Set Background of Window Content Pane to default color - * @param win window - */ - public static void setBackground (Window win) - { - setBackground (win, new CompiereColor(AdempierePLAF.getFormBackground())); - } // setBackground - - /** - * Set Background of Window Content Pane - * @param win window - * @param cc adempiere color - */ - public static void setBackground (Window win, CompiereColor cc) - { - if (win instanceof JDialog) - { - ((JPanel)((JDialog)win).getContentPane()).putClientProperty(CompiereLookAndFeel.BACKGROUND, cc); - // ((JPanel)((JDialog)win).getContentPane()).setName("contentPane"); - } - else if (win instanceof JFrame) - { - ((JPanel)((JFrame)win).getContentPane()).putClientProperty(CompiereLookAndFeel.BACKGROUND, cc); - // ((JPanel)((JFrame)win).getContentPane()).setName("contentPane"); - } - else if (win instanceof JWindow) - { - ((JPanel)((JWindow)win).getContentPane()).putClientProperty(CompiereLookAndFeel.BACKGROUND, cc); - // ((JPanel)((JWindow)win).getContentPane()).setName("contentPane"); - } - } // setBackground - - /** - * Get Default Background - * @return Background - * @see CompierePanelUI#getDefaultBackground - */ - public static CompiereColor getDefaultBackground() - { - return new CompiereColor(AdempierePLAF.getFormBackground()); - } // getDefaultBackground - - /** - * Parse attributes and return AdempiereColor - * @param attributes attributes - * @return AdempiereColor - */ - public static CompiereColor parse (String attributes) - { - CompiereColor cc = new CompiereColor (); - try - { - if (attributes != null && attributes.length() > 0) - cc.parseAttributres (attributes); - } - catch (Exception e) - { - log.severe("(" + attributes + ") - " + e.toString()); - } - return cc; - } // parse - - /************************************************************************** - * Get CompiereColor. - * @return CompiereColor - */ - public static CompiereColor getCompiereColor(MColor color) - { - if (color == null || color.get_ID() == 0) - return null; - - // Color Type - String ColorType = (String)color.getColorType(); - if (ColorType == null) - { - log.log(Level.SEVERE, "MColor.getAdempiereColor - No ColorType"); - return null; - } - CompiereColor cc = null; - // - if (ColorType.equals(CompiereColor.TYPE_FLAT)) - { - cc = new CompiereColor(color.getColor(true), true); - } - else if (ColorType.equals(CompiereColor.TYPE_GRADIENT)) - { - int RepeatDistance = color.getRepeatDistance(); - String StartPoint = color.getStartPoint(); - int startPoint = StartPoint == null ? 0 : Integer.parseInt(StartPoint); - cc = new CompiereColor(color.getColor(true), color.getColor(false), startPoint, RepeatDistance); - } - else if (ColorType.equals(CompiereColor.TYPE_LINES)) - { - int LineWidth = color.getLineWidth(); - int LineDistance = color.getLineDistance(); - cc = new CompiereColor(color.getColor(false), color.getColor(true), LineWidth, LineDistance); - } - else if (ColorType.equals(CompiereColor.TYPE_TEXTURE)) - { - int AD_Image_ID = color.getAD_Image_ID(); - String url = color.getURL(AD_Image_ID); - if (url == null) - return null; - BigDecimal ImageAlpha = color.getImageAlpha(); - float compositeAlpha = ImageAlpha == null ? 0.7f : ImageAlpha.floatValue(); - cc = new CompiereColor(url, color.getColor(true), compositeAlpha); - } - return cc; - } // getAdempiereColor - - /************************************************************************* - * Create Gradient Background Color (Window System Color - White) - */ - public CompiereColor() - { - this (TYPE_GRADIENT); - } // AdempiereColor - - /** - * Create Default Background Colors of Type - * @param type Background type (see constants TYPE_*) - */ - public CompiereColor (String type) - { - if (type == null) - throw new java.lang.IllegalArgumentException (EXCEPTION_TEXT); - if (type.equals(TYPE_FLAT) || type.equals(TYPE_GRADIENT) - || type.equals(TYPE_TEXTURE) || type.equals(TYPE_LINES)) - { - m_type = type; - } - else - throw new java.lang.IllegalArgumentException ("Invalid Type"); - } // AdempiereColor - - /** - * Create Flat Background Color - * @param bg background - */ - public CompiereColor (Color bg) - { - this (bg, true); - } // AdempiereColor - - /** - * Create Background Color - * @param bg Color - * @param flat if true create Flat color otherwise Gradient color with white lower color - */ - public CompiereColor (Color bg, boolean flat) - { - if (bg == null) - throw new java.lang.IllegalArgumentException (EXCEPTION_TEXT); - m_type = flat ? TYPE_FLAT : TYPE_GRADIENT; - m_primaryColor = bg; - } // AdempiereColor - - /** - * Set Background to Gradient colors - * @param upperColor upper Color - * @param lowerColor lower Color - * @param startPoint Starting point - e.g. SOUTH_WEST see SwingConstants, default NORTH_WEST - * @param repeatDistance X/Y Distance to repeat gradient in points - 0 no repeats - */ - public CompiereColor (Color upperColor, Color lowerColor, int startPoint, int repeatDistance) - { - if (upperColor == null || lowerColor == null) - throw new java.lang.IllegalArgumentException (EXCEPTION_TEXT); - m_type = TYPE_GRADIENT; - m_primaryColor = upperColor; - m_secondaryColor = lowerColor; - m_startPoint = startPoint; - m_repeatDistance = repeatDistance; - } // AdempiereColor - - /** - * Set Background to Gradient colors. - * Starting in the north, repeat after 100 pt - * @param upperColor upper color - * @param lowerColor lower color - */ - public CompiereColor (Color upperColor, Color lowerColor) - { - this (upperColor, lowerColor, SwingConstants.NORTH_WEST, 100); - } // AdempiereColor - - /** - * Set Background to Texture - * - * @param textureURL URL to a *.gif or *.jpg graphic file - * @param taint Color to taint the texture (use white for not tainting it) - * @param compositeAlpha Value from 0(no) to 1(full) tainting - */ - public CompiereColor (URL textureURL, Color taint, float compositeAlpha) - { - if (textureURL == null || taint == null) - throw new java.lang.IllegalArgumentException (EXCEPTION_TEXT); - m_type = TYPE_TEXTURE; - m_textureURL = textureURL; - m_primaryColor = taint; - m_compositeAlpha = compositeAlpha; - } // AdempiereColor - - /** - * Set Background to Texture - * - * @param textureURL URL to a *.gif or *.jpg graphic file - * @param taint Color to taint the texture (use white for not tainting it) - * @param compositeAlpha Tainting value from 0 (no - FullGraph) to 1 (full - NoGraph) - */ - public CompiereColor (String textureURL, Color taint, float compositeAlpha) - { - if (textureURL == null || taint == null) - throw new java.lang.IllegalArgumentException (EXCEPTION_TEXT); - m_type = TYPE_TEXTURE; - setTextureURL(textureURL); - m_primaryColor = taint; - m_compositeAlpha = compositeAlpha; - } // AdempiereColor - - /** - * Set Background to Lines - * - * @param lineColor line color - * @param backColor background color - * @param lineWidth Stroke width in point - * @param lineDistance Distance between lines in points - */ - public CompiereColor (Color lineColor, Color backColor, float lineWidth, int lineDistance) - { - if (lineColor == null || backColor == null) - throw new java.lang.IllegalArgumentException (EXCEPTION_TEXT); - m_type = TYPE_LINES; - m_primaryColor = backColor; - m_secondaryColor = lineColor; - m_lineWidth = lineWidth; - m_lineDistance = lineDistance; - } // AdempiereColor - - /** - * Copy Color - * @param cc color - */ - public CompiereColor (CompiereColor cc) - { - if (cc == null) - return; - setColor(cc); - } // AdempiereColor - - /*************************************************************************/ - - /** Type - Default: Gradient */ - private String m_type = TYPE_GRADIENT; - - /** Primary Color - Default Panel back */ - private Color m_primaryColor = UIManager.getColor("Panel.background"); - /** Secondary Color - Default: gray-white */ - private Color m_secondaryColor = new Color (245, 245, 245); - - /** Texture Graph URL */ - private URL m_textureURL = null; - /** Texture Graph */ - private BufferedImage m_image = null; - /** Texture Alpha - Default: 0.7 */ - private float m_compositeAlpha = 0.7f; - - /** Line Width - Default: 1 */ - private float m_lineWidth = 1.0f; - /** Line Distance - Default: 5 */ - private int m_lineDistance = 5; - - /** Gradient Starting point - Default: NORTH_WEST */ - private int m_startPoint = SwingConstants.NORTH_WEST; - /** Gradient repeat distance in points - Default: 100 */ - private int m_repeatDistance = 100; - - /** Background */ - private ColorBackground m_back = null; - - /** Diry marker for repaining Background */ - private boolean m_dirty = true; - /** Logger */ - private static Logger log = Logger.getLogger(CompiereColor.class.getName()); - - /************************************************************************** - * Get BackgroundType (Flat, Gradient, Lines, Texture) - * @return Background Type (see TYPE_* constants) - */ - public String getType() - { - return m_type; - } // getType - - /** - * Flat Background Type (default) - * @return true if Flat background - */ - public boolean isFlat() - { - return TYPE_FLAT.equals(getType()); - } // isFlat - - /** - * Gradient Background Type - * @return true if Gradient background - */ - public boolean isGradient() - { - return TYPE_GRADIENT.equals(getType()); - } // isGradient - - /** - * Line Background Type - * @return true if Line background - */ - public boolean isLine() - { - return TYPE_LINES.equals(getType()); - } // isLine - - /** - * Texture Background Type - * @return true if Texture background - */ - public boolean isTexture() - { - return TYPE_TEXTURE.equals(getType()); - } // isTexture - - - /************************ - * Get Flat Color - * @return Primary Color - */ - public Color getFlatColor() - { - return m_primaryColor; - } // getFlatColor - - /** - * Set Flat Color - * @param color flat color - */ - public void setFlatColor(Color color) - { - if (!isFlat() || color == null) - return; - m_primaryColor = color; - m_dirty = true; - } // getFlatColor - - - /************************ - * Gradient Upper Color - * @return Color or null - */ - public Color getGradientUpperColor() - { - if (!isGradient()) - return null; - return m_primaryColor; - } // getGradientUpperColor - - /** - * Gradient Upper Color - * @param color upper color - */ - public void setGradientUpperColor(Color color) - { - if (!isGradient() || color == null) - return; - m_primaryColor = color; - m_dirty = true; - } // getGradientUpperColor - - /** - * Gradient Lower Color - * @return Color or null - */ - public Color getGradientLowerColor() - { - if (!isGradient()) - return null; - return m_secondaryColor; - } // getGradientLowerColor - - /** - * Gradient Lower Color - * @param color lower color - */ - public void setGradientLowerColor(Color color) - { - if (!isGradient() || color == null) - return; - m_secondaryColor = color; - m_dirty = true; - } // setGradientLowerColor - - /** - * Gradient Starting Point - * @return starting point - e.g. NORTH - or 0 - * @see SwingConstants - */ - public int getGradientStartPoint () - { - if (!isGradient()) - return 0; - return m_startPoint; - } // getGradientStartPoint - - /** - * Gradient Starting Point - * @param startPoint starting point - e.g. NORTH - * @see SwingConstants - */ - public void setGradientStartPoint (int startPoint) - { - if (!isGradient()) - return; - m_startPoint = startPoint; - m_dirty = true; - } // setGradientStartPoint - - /** - * Gradient Repeat Distance in point - * @return Repeat Distance - or 0 - */ - public int getGradientRepeatDistance () - { - if (!isGradient()) - return 0; - return m_repeatDistance; - } // getGradientRepeatDistance - - /** - * Gradient Repeat Distance. - * Zero stands for no repeats - * @param repeatDistance repeat gradient after point x+repeat / y+repeat (depending on direction) - */ - public void setGradientRepeatDistance (int repeatDistance) - { - if (!isGradient()) - return; - m_repeatDistance = repeatDistance; - m_dirty = true; - } // setGradientRepeatDistance - - /** - * Gradient Repeat Distance. - * Zero stands for no repeats - * @param repeatDistanceString repeat gradient after point x+repeat / y+repeat (depending on direction) - */ - public void setGradientRepeatDistance (String repeatDistanceString) - { - if (!isGradient()) - return; - try - { - setGradientRepeatDistance(Integer.parseInt(repeatDistanceString)); - } - catch (Exception e) - { - log.severe("Parsing=" - + repeatDistanceString + " - " + e.getMessage()); - } - } // setGradientRepeatDistance - - - /************************ - * Texture Url - * @return URL (if not found, org.compiere.plaf.background.jpg is used) - */ - public URL getTextureURL() - { - if (!isTexture()) - return null; - if (m_textureURL == null) - m_textureURL = CompiereColor.class.getResource("iDempiere00x100.gif"); - return m_textureURL; - } // getTextureURL - - /** - * Get Texture Image based on Texture URL - * @return Image - */ - public BufferedImage getTextureImage() - { - if (m_image == null) - { - URL url = getTextureURL(); - m_image = CompiereUtils.loadBufferedImage(url, BufferedImage.TYPE_INT_ARGB_PRE); - } - return m_image; - } // getTextureImage - - /** - * Texture Url - * @param url URL to graphic file (jpg) - */ - public void setTextureURL(URL url) - { - if (!isTexture() || url == null) - return; - m_textureURL = url; - m_image = null; - m_dirty = true; - } // setTextureURL - - /** - * Texture Url - * @param urlString URL to graphic file (jpg) - */ - public void setTextureURL(String urlString) - { - if (!isTexture() || urlString == null) - return; - try - { - setTextureURL (new URL(urlString)); - } - catch (Exception e) - { - log.severe("Parsing URL=" - + urlString + " - " + e.getMessage()); - } - } // setTextureURL - - /** - * Texture Taint Color - * @return Color or null - */ - public Color getTextureTaintColor() - { - if (!isTexture()) - return null; - return m_primaryColor; - } // getTextureTaintColor - - /** - * Texture Taint Color - * @param color taint color - */ - public void setTextureTaintColor(Color color) - { - if (!isTexture() || color == null) - return; - m_primaryColor = color; - m_dirty = true; - } // setTextureTaintColor - - /** - * Texture Composite Alpha - * @return Composite Ampha or 0f - */ - public float getTextureCompositeAlpha() - { - if (!isTexture()) - return 0f; - return m_compositeAlpha; - } // getTextureCompositeAlpha - - /** - * Texture Composite Alpha - * @param alpha alpha value - */ - public void setTextureCompositeAlpha(float alpha) - { - if (!isTexture()) - return; - m_compositeAlpha = alpha; - m_dirty = true; - } // setTextureCompositeAlpha - - /** - * Texture Composite Alpha - * @param alphaString String to be parsed - */ - public void setTextureCompositeAlpha(String alphaString) - { - if (!isTexture() || alphaString == null) - return; - try - { - setTextureCompositeAlpha(Float.parseFloat(alphaString)); - } - catch (Exception e) - { - log.severe("Parsing=" - + alphaString + " - " + e.getMessage()); - } - } // setTextureCompositeAlpha - - - /************************ - * Line Color - * @return Color or null - */ - public Color getLineColor() - { - if (!isLine()) - return null; - return m_secondaryColor; - } // getLineColor - - /** - * Line Color - * @param color line color - */ - public void setLineColor(Color color) - { - if (!isLine() || color == null) - return; - m_secondaryColor = color; - m_dirty = true; - } // setLineColor - - /** - * Line Background Color - * @return Color or null - */ - public Color getLineBackColor() - { - if (!isLine()) - return null; - return m_primaryColor; - } // getLineBackColor - - /** - * Line Background Color - * @param color background color - */ - public void setLineBackColor(Color color) - { - if (!isLine() || color == null) - return; - m_primaryColor = color; - m_dirty = true; - } // setLineBackColor - - /** - * Background Line Width - * @return width or 0f - */ - public float getLineWidth() - { - if (!isLine()) - return 0f; - return m_lineWidth; - } // getLineWidth - - /** - * Background Line Width - * @param width line width - */ - public void setLineWidth(float width) - { - if (!isLine()) - return; - m_lineWidth = width; - m_dirty = true; - } // setLineWidth - - /** - * Background Line Width - * @param widthString line width - */ - public void setLineWidth(String widthString) - { - if (!isLine() || widthString == null) - return; - try - { - setLineWidth(Float.parseFloat(widthString)); - } - catch (Exception e) - { - log.severe("Parsing=" - + widthString + " - " + e.getMessage()); - } - } // setLineWidth - - /** - * Background Line distance in pt - * @return distance or 0 - */ - public int getLineDistance() - { - if (!isLine()) - return 0; - return m_lineDistance; - } // getLineDistance - - /** - * Background Line distance in pt - * @param distance line distance - */ - public void setLineDistance(int distance) - { - if (!isLine()) - return; - m_lineDistance = distance; - m_dirty = true; - } // setLineDistance - - /** - * Background Line distance in pt - * @param distanceString line distance - */ - public void setLineDistance(String distanceString) - { - if (!isLine()) - return; - try - { - setLineDistance(Integer.parseInt(distanceString)); - } - catch (Exception e) - { - log.severe("Parsing=" - + distanceString + " - " + e.getMessage()); - } - } // setLineDistance - - /** - * Set Prinary Color - * @param color primary color - */ - protected void setPrimaryColor (Color color) - { - if (color != null) - m_primaryColor = color; - } // setPrimaryColor - - /** - * Set AdempiereColor from AdempiereColor - * @param cc AdempiereColor - */ - public void setColor (CompiereColor cc) - { - if (cc == null) - return; - m_type = cc.getType(); - // - if (cc.isFlat()) - m_primaryColor = cc.getFlatColor(); - else if (cc.isGradient()) - { - m_primaryColor = cc.getGradientUpperColor(); - m_secondaryColor = cc.getGradientLowerColor(); - m_startPoint = cc.getGradientStartPoint(); - m_repeatDistance = cc.getGradientRepeatDistance(); - } - else if (cc.isTexture()) - { - setTextureURL(cc.getTextureURL()); - m_primaryColor = cc.getTextureTaintColor(); - m_compositeAlpha = cc.getTextureCompositeAlpha(); - } - else if (cc.isLine()) - { - m_primaryColor = cc.getLineBackColor(); - m_secondaryColor = cc.getLineColor(); - m_lineWidth = cc.getLineWidth(); - m_lineDistance = cc.getLineDistance(); - } - else - log.severe("Invalid Color"); - // - m_dirty = true; - } // setColor - - - /************************************************************************** - * Fill with AdempiereColor Background - * @param g the Graphics context in which to paint - * @param c the component being painted - */ - public void paint (Graphics g, JComponent c) - { - getColorBackground(c).paint (g, c); - } // paint - - /** - * Fill with Adempiere Background - * @param g graphics - * @param c component - * @param x x pos - * @param y y pos - * @param w with - * @param h height - */ - public void paintRect (Graphics g, JComponent c, int x, int y, int w, int h) - { - getColorBackground(c).paintRect (g,c, x,y, w,h); - } // paintRect - - /** - * Get Background - * @param c Componenr - * @return Background - */ - private ColorBackground getColorBackground (JComponent c) - { - if (m_back == null) - { - Rectangle bounds = c.getBounds(); - Container container = c.getParent(); - while (container != null) - { - bounds = container.getBounds(bounds); - container = container.getParent(); - } - m_back = new ColorBackground (bounds); - } - return m_back; - } // getBackground - - - /************************************************************************** - * String representation - * @return string representation - */ - public String toString() - { - StringBuilder sb = new StringBuilder ("AdempiereColor["); - if (isFlat()) - sb.append("Flat") - .append(" ").append(ThemeUtils.getColorAsString(getFlatColor())); - else if (isGradient()) - sb.append("Gradient") - .append(" Upper=").append(ThemeUtils.getColorAsString(getGradientUpperColor())) - .append(",Lower=").append(ThemeUtils.getColorAsString(getGradientLowerColor())) - .append(",Start=").append(getGradientStartPoint()) - .append(",RDistance=").append(getGradientRepeatDistance()); - else if (isLine()) - sb.append("Line") - .append(" Color=").append(ThemeUtils.getColorAsString(getLineColor())) - .append(",BackColor=").append(ThemeUtils.getColorAsString(getLineBackColor())) - .append(",Width=").append(getLineWidth()) - .append(",Distance=").append(getLineDistance()); - else if (isTexture()) - sb.append("Texture") - .append(" GraphURL=").append(getTextureURL()) - .append(",Taint=").append(ThemeUtils.getColorAsString(getTextureTaintColor())) - .append(",Alpha=").append(getTextureCompositeAlpha()); - sb.append("]"); - return sb.toString(); - } // toString - - /** - * Parse String Representation and set Attributes - * @param str parse string - */ - private void parseAttributres (String str) - { - if (str.indexOf("[Flat ") != -1) - { - m_type = TYPE_FLAT; - m_primaryColor = ThemeUtils.parseColor(str, - new ColorUIResource(m_primaryColor)); - } - else if (str.indexOf("[Gradient ") != -1) - { - m_type = TYPE_GRADIENT; - m_primaryColor = ThemeUtils.parseColor(str.substring(str.indexOf(" Upper=")+7, str.indexOf(",Lower=")), - new ColorUIResource(m_primaryColor)); - m_secondaryColor = ThemeUtils.parseColor(str.substring(str.indexOf(",Lower=")+7, str.indexOf(",Start=")), - new ColorUIResource(m_secondaryColor)); - m_startPoint = Integer.parseInt(str.substring(str.indexOf(",Start=")+7, str.indexOf(",RDistance="))); - setGradientRepeatDistance(str.substring(str.indexOf(",RDistance=")+11, str.lastIndexOf(']'))); - } - else if (str.indexOf("[Line ") != -1) - { - m_type = TYPE_LINES; - m_primaryColor = ThemeUtils.parseColor(str.substring(str.indexOf(" Color=")+7, str.indexOf(",BackColor=")), - new ColorUIResource(m_primaryColor)); - m_secondaryColor = ThemeUtils.parseColor(str.substring(str.indexOf(",BackColor=")+11, str.indexOf(",Width=")), - new ColorUIResource(m_secondaryColor)); - setLineWidth(str.substring(str.indexOf(",Width=")+7, str.indexOf(",Distance="))); - setLineDistance(str.substring(str.indexOf(",Distance=")+10, str.lastIndexOf(']'))); - } - else if (str.indexOf("[Texture ") != -1) - { - m_type = TYPE_TEXTURE; - setTextureURL (str.substring(str.indexOf(" GraphURL=")+10, str.indexOf(",Taint="))); - m_primaryColor = ThemeUtils.parseColor(str.substring(str.indexOf(",Taint=")+7, str.indexOf(",Alpha=")), - new ColorUIResource(m_primaryColor)); - setTextureCompositeAlpha (str.substring(str.indexOf(",Alpha=")+7, str.lastIndexOf(']'))); - } - } // parseString - - /** - * Does the background needs to be redone - * @return true if there were changes - */ - boolean isDirty() - { - return m_dirty; - } // isDirty - - /** - * Set Dirty - * @param dirty if true, the background will be re-painted - */ - void setDirty (boolean dirty) - { - m_dirty = dirty; - } // setDirty - - -/****************************************************************************** - * Background contains a Buffered Image with the background. - * The initial size is determined by the constructor. - * It is resized if required when painting. - *
    - * The Buffered image is a 8-bit RGBA color components packed into integer pixels. - * The image has a DirectColorModel with alpha. The color data in this image - * is considered to be premultiplied with alpha - */ -public class ColorBackground -{ - /** - * Create Color Background - * @param bounds Rectangle to fit in - */ - public ColorBackground (Rectangle bounds) - { - createColorBackground (bounds); - fillColorBackground (); - } // Background - - private int m_height = 200; - private int m_width = 200; - private BufferedImage m_backImage; - private int m_colorBlind = ColorBlind.getColorType(); - - /** - * Create Color Background - * @param bounds Rectangle to fit in - */ - private void createColorBackground (Rectangle bounds) - { - m_height = Math.max(bounds.y + bounds.height, m_height); - m_width = Math.max(bounds.x + bounds.width, m_width); - m_backImage = new BufferedImage (m_width, m_height, BufferedImage.TYPE_INT_ARGB_PRE); - } // create Background - - - /** - * Fill Background with Color - */ - public void fillColorBackground () - { - Graphics2D g2D = m_backImage.createGraphics(); - - if (isGradient()) - { - Point start = null; - Point end = null; - int r = 1; // repeats - switch (m_startPoint) - { - case SwingConstants.NORTH_WEST: - start = new Point (0, 0); - if (m_repeatDistance > 0) - end = new Point (m_repeatDistance, m_repeatDistance); - // end = new Point (Math.min(m_repeatDistance, m_width), Math.min(m_repeatDistance, height)); - else - end = new Point (m_width/r, m_height/r); - break; - case SwingConstants.WEST: - start = new Point (0, m_height/2); - if (m_repeatDistance > 0) - end = new Point (m_repeatDistance, m_height/2); - // end = new Point (Math.min(m_repeatDistance, m_width), m_height/2); - else - end = new Point (m_width/r, m_height/2); - break; - case SwingConstants.SOUTH_WEST: - start = new Point (0, m_height); - if (m_repeatDistance > 0) - end = new Point (m_repeatDistance, m_height-m_repeatDistance); - // end = new Point (Math.min(m_width, m_repeatDistance), Math.max(0, m_height-m_repeatDistance)); - else - end = new Point (m_width/r, m_height-(m_height/r)); - break; - case SwingConstants.SOUTH: - start = new Point (0, m_height); - if (m_repeatDistance > 0) - end = new Point (0, m_height-m_repeatDistance); - // end = new Point (0, Math.max(0, m_height-m_repeatDistance)); - else - end = new Point (0, m_height-(m_height/r)); - break; - case SwingConstants.SOUTH_EAST: - start = new Point (m_width, m_height); - if (m_repeatDistance > 0) - end = new Point (m_width-m_repeatDistance, m_height-m_repeatDistance); - // end = new Point (Math.min(0, m_width-m_repeatDistance), Math.max(0, m_height-m_repeatDistance)); - else - end = new Point (m_width-(m_width/r), m_height-(m_height/r)); - break; - case SwingConstants.EAST: - start = new Point (m_width, m_height/2); - if (m_repeatDistance > 0) - end = new Point (m_width-m_repeatDistance, m_height/2); - // end = new Point (Math.min(0, m_width-m_repeatDistance), m_height/2); - else - end = new Point (m_width-(m_width/r), m_height/2); - break; - case SwingConstants.NORTH_EAST: - start = new Point (m_width, 0); - if (m_repeatDistance > 0) - end = new Point (m_width-m_repeatDistance, m_repeatDistance); - // end = new Point (Math.min(0, m_width-m_repeatDistance), Math.min(m_height, m_repeatDistance)); - else - end = new Point (m_width-(m_width/r), m_height/r); - break; - default: - case SwingConstants.NORTH: - start = new Point (0, 0); - if (m_repeatDistance > 0) - end = new Point (0, m_repeatDistance); - // end = new Point (0, Math.min(m_height, m_repeatDistance)); - else - end = new Point (0, m_height/r); - } - GradientPaint paint = new GradientPaint( - start, - ColorBlind.getDichromatColor(getGradientUpperColor()), - end, - ColorBlind.getDichromatColor(getGradientLowerColor()), - true); // cyclic - g2D.setPaint(paint); - g2D.fillRect(0, 0, m_width, m_height); - } - else if (isTexture()) - { - BufferedImage image = getTextureImage(); - if (image == null) - { - g2D.setPaint(ColorBlind.getDichromatColor(getFlatColor())); - g2D.fillRect(0, 0, m_width, m_height); - } - else - { - Rectangle anchor = new Rectangle (0,0, image.getWidth(), image.getHeight()); - TexturePaint texture = new TexturePaint (image, anchor); - g2D.setPaint(texture); - g2D.fillRect(0, 0, m_width, m_height); - g2D.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, getTextureCompositeAlpha())); - g2D.setPaint(ColorBlind.getDichromatColor(getTextureTaintColor())); - g2D.fillRect(0, 0, m_width, m_height); - } - } - else if (isLine()) - { - // Background - g2D.setPaint(ColorBlind.getDichromatColor(getLineBackColor())); - g2D.fillRect(0, 0, m_width, m_height); - // Lines - g2D.setPaint(ColorBlind.getDichromatColor(getLineColor())); - g2D.setStroke(new BasicStroke(getLineWidth())); - for (int y = 0; y < m_height; y += getLineDistance()) - g2D.drawLine(0, y, m_width, y); - } - else // flat - { - g2D.setPaint(ColorBlind.getDichromatColor(getFlatColor())); - g2D.fillRect(0, 0, m_width, m_height); - } - setDirty (false); - } // fillBackground - - /** - * Paint/copy background to component - * @param g graphics - * @param c component - */ - public void paint (Graphics g, JComponent c) - { - Rectangle bounds = c.getBounds(); - check (bounds); - // - int h = c.getHeight(); - int w = c.getWidth(); - // Copy Background - g.drawImage (m_backImage, - 0, 0, // destination start point - w, h, // destination end point - bounds.x, bounds.y, // source start - bounds.x+w, bounds.y+h, // source end - c); - } // paint - - /** - * Paint/copy background to component rectangle - * @param g graphics - * @param c compnent - * @param x x pos - * @param y y pos - * @param w width - * @param h height - */ - public void paintRect (Graphics g, JComponent c, int x, int y, int w, int h) - { - Rectangle bounds = c.getBounds(); - check (bounds); - // Copy Background - g.drawImage (m_backImage, - x, y, // destination start point - x+w, h+y, // destination end point - x, y, // source start - x+w, y+h, // source end - c); - } // paint - - /** - * Check size of background and repaint if required - * @param bounds Bounds of component - */ - private void check (Rectangle bounds) - { - // Re-Create, if Color Type changed - if (ColorBlind.getColorType() != m_colorBlind) - { - m_colorBlind = ColorBlind.getColorType(); - setDirty(true); - } - // we need to create new background - if ((m_height < (bounds.y + bounds.height)) - || (m_width < (bounds.x + bounds.width))) - { - createColorBackground (bounds); - fillColorBackground(); - } - else if (isDirty()) - fillColorBackground(); - } // check - -} // ColorBackground - -} // AdempiereColor diff --git a/org.adempiere.ui.swing/src/org/compiere/plaf/CompiereComboBoxUI.java b/org.adempiere.ui.swing/src/org/compiere/plaf/CompiereComboBoxUI.java deleted file mode 100644 index 21f5c83d38..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/plaf/CompiereComboBoxUI.java +++ /dev/null @@ -1,114 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ -package org.compiere.plaf; - -import java.awt.event.MouseListener; - -import javax.swing.Icon; -import javax.swing.JButton; -import javax.swing.JComponent; -import javax.swing.plaf.ComponentUI; -import javax.swing.plaf.basic.ComboPopup; -import javax.swing.plaf.metal.MetalComboBoxButton; -import javax.swing.plaf.metal.MetalComboBoxUI; - - -/** - * Adempiere ComboBox UI. - * The ComboBox is opaque - with opaque arrow button and textfield background - * - * @author Jorg Janke - * @version $Id: AdempiereComboBoxUI.java,v 1.2 2006/07/30 00:52:24 jjanke Exp $ - */ -public class CompiereComboBoxUI extends MetalComboBoxUI -{ - /** - * Create UI - * @param c - * @return new instance of AdempiereComboBoxUI - */ - public static ComponentUI createUI(JComponent c) - { - return new CompiereComboBoxUI(); - } // CreateUI - - /*************************************************************************/ - - static int s_no = 0; - /** - * Install UI - Set ComboBox opaque. - * Bug in Metal: arrowButton gets Mouse Events, so add the JComboBox - * MouseListeners to the arrowButton - * @see org.compiere.swing.CComboBox#addMouseListener(MouseListener) - * @param c componrnt - */ - public void installUI (JComponent c) - { - MouseListener[] ml = c.getMouseListeners(); - super.installUI(c); - c.setOpaque(false); - // - for (int i = 0; i < ml.length; i++) - { - // System.out.println("adding " + c.getClass().getName()); - arrowButton.addMouseListener(ml[i]); - } - - } // installUI - - /*************************************************************************/ - - /** - * Create opaque button - * @return opaque button - */ - protected JButton createArrowButton() - { - JButton button = super.createArrowButton(); - button.setContentAreaFilled(false); - button.setOpaque(false); - return button; - } // createArrowButton - - public JButton getArrowButton() - { - return arrowButton; - } - - /** - * Set Icon of arrow button - * @param defaultIcon - */ - public void setIcon(Icon defaultIcon) - { - ((MetalComboBoxButton)arrowButton).setComboIcon(defaultIcon); - } // setIcon - - /*************************************************************************/ - - /** - * Create Popup - * @return AdempiereComboPopup - */ - protected ComboPopup createPopup() - { - CompiereComboPopup newPopup = new CompiereComboPopup( comboBox ); - newPopup.getAccessibleContext().setAccessibleParent(comboBox); - return newPopup; - } // createPopup - -} // AdempiereComboBoxUI diff --git a/org.adempiere.ui.swing/src/org/compiere/plaf/CompiereComboPopup.java b/org.adempiere.ui.swing/src/org/compiere/plaf/CompiereComboPopup.java deleted file mode 100644 index e30a6816bd..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/plaf/CompiereComboPopup.java +++ /dev/null @@ -1,81 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ -package org.compiere.plaf; - -import javax.swing.JComboBox; -import javax.swing.plaf.basic.BasicComboPopup; - -import org.compiere.swing.CComboBox; -import org.compiere.swing.CField; - -/** - * Adempiere Combo Popup - allows to prevent the display of the popup - * - * @author Jorg Janke - * @version $Id: AdempiereComboPopup.java,v 1.2 2006/07/30 00:52:24 jjanke Exp $ - */ -public class CompiereComboPopup extends BasicComboPopup -{ - /** - * - */ - private static final long serialVersionUID = 2031710222285745816L; - - /** - * Constructor - * @param combo - */ - public CompiereComboPopup(JComboBox combo) - { - super(combo); - } // AdempiereComboPopup - - /** - * Conditionally show the Popup. - * If the combo is a CComboBox/CField, the return value of the - * method displayPopup determines if the popup is actually displayed - * @see CComboBox#displayPopup() - * @see CField#displayPopup() - */ - public void show() - { - // Check ComboBox if popup should be displayed - if (comboBox instanceof CComboBox && !((CComboBox)comboBox).displayPopup()) - return; - // Check Field if popup should be displayed - if (comboBox instanceof CField && !((CField)comboBox).displayPopup()) - return; - super.show(); - } // show - - - /** - * Inform CComboBox and CField that Popup was hidden - * @see CComboBox.hidingPopup - * @see CField.hidingPopup - * - public void hide() - { - super.hide(); - // Inform ComboBox that popup was hidden - if (comboBox instanceof CComboBox) - (CComboBox)comboBox).hidingPopup(); - else if (comboBox instanceof CComboBox) - (CComboBox)comboBox).hidingPopup(); - } // hided - /**/ -} // AdempiereComboPopup diff --git a/org.adempiere.ui.swing/src/org/compiere/plaf/CompiereLabelUI.java b/org.adempiere.ui.swing/src/org/compiere/plaf/CompiereLabelUI.java deleted file mode 100644 index 64b859b4c3..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/plaf/CompiereLabelUI.java +++ /dev/null @@ -1,164 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ -package org.compiere.plaf; - -import java.awt.Component; -import java.awt.Container; -import java.awt.FocusTraversalPolicy; -import java.awt.event.ActionEvent; - -import javax.swing.ActionMap; -import javax.swing.InputMap; -import javax.swing.JComponent; -import javax.swing.JLabel; -import javax.swing.KeyStroke; -import javax.swing.SwingUtilities; -import javax.swing.plaf.ComponentInputMapUIResource; -import javax.swing.plaf.metal.MetalLabelUI; - -import org.jdesktop.swingx.UIAction; - -/** - * Adempiere Label UI - * - * @author Jorg Janke - * @version $Id: AdempiereLabelUI.java,v 1.2 2006/07/30 00:52:24 jjanke Exp $ - */ -public class CompiereLabelUI extends MetalLabelUI -{ - /** Singleton */ - protected static CompiereLabelUI adempiereLabelUI = new CompiereLabelUI(); - - /** - * Create UI - * @param c component - * @return singleton - */ - public static CompiereLabelUI createUI(JComponent c) - { - return adempiereLabelUI; - } // createUI - - /** - * Install Keyboard Actions - * @param l label - */ - protected void installKeyboardActions (JLabel l) - { - // super.installKeyboardActions(l); - int dka = l.getDisplayedMnemonic(); - if (dka != 0) - { - Component lf = l.getLabelFor(); - if (lf != null) - { - ActionMap actionMap = l.getActionMap(); - actionMap.put(PRESS, ACTION_PRESS); - InputMap inputMap = SwingUtilities.getUIInputMap (l, JComponent.WHEN_IN_FOCUSED_WINDOW); - if (inputMap == null) - { - inputMap = new ComponentInputMapUIResource (l); - SwingUtilities.replaceUIInputMap (l, JComponent.WHEN_IN_FOCUSED_WINDOW, inputMap); - } - inputMap.clear (); - inputMap.put (KeyStroke.getKeyStroke (dka, - ActionEvent.SHIFT_MASK+ActionEvent.CTRL_MASK, false), PRESS); - } - } - } // installKeyboardActions - - - /** Action Name */ - private static final String PRESS = "press"; - /** Press Action */ - private static PressAction ACTION_PRESS = new PressAction(); - - /** - * Adempiere Label UI Actions - */ - private static class PressAction extends UIAction - { - - PressAction () - { - super (PRESS); - } - - public void actionPerformed (ActionEvent e) - { - JLabel label = (JLabel)e.getSource (); - String key = getName (); - if (key.equals(PRESS)) - { - doPress (label); - } - } // actionPerformed - - /** - * Do Press - Focus the Field - * @param label label - */ - private void doPress (JLabel label) - { - Component labelFor = label.getLabelFor (); - if (labelFor != null && labelFor.isEnabled ()) - { - Component owner = label.getLabelFor (); - if (owner instanceof Container - && ((Container)owner).isFocusCycleRoot ()) - { - owner.requestFocus (); - } - else - { - if (owner instanceof Container) - { - Container container = (Container)owner; - if (container.isFocusCycleRoot()) - { - FocusTraversalPolicy policy = container.getFocusTraversalPolicy(); - Component comp = policy.getDefaultComponent(container); - if (comp != null) - { - comp.requestFocus(); - return; - } - } - Container rootAncestor = container.getFocusCycleRootAncestor(); - if (rootAncestor != null) - { - FocusTraversalPolicy policy = rootAncestor.getFocusTraversalPolicy(); - Component comp = policy.getComponentAfter(rootAncestor, container); - if (comp != null && SwingUtilities.isDescendingFrom(comp, container)) - { - comp.requestFocus(); - return; - } - } - } - if (owner.isFocusable()) - { - owner.requestFocus(); - return; - } - // No Forcus - } - } - } // doPress - } // PressAction - -} // AdempiereLabelUI diff --git a/org.adempiere.ui.swing/src/org/compiere/plaf/CompiereLookAndFeel.java b/org.adempiere.ui.swing/src/org/compiere/plaf/CompiereLookAndFeel.java deleted file mode 100644 index fd9a225ac3..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/plaf/CompiereLookAndFeel.java +++ /dev/null @@ -1,252 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ -package org.compiere.plaf; - -import java.awt.Color; -import java.awt.Component; - -import javax.swing.UIDefaults; -import javax.swing.plaf.metal.MetalLookAndFeel; -import javax.swing.plaf.metal.MetalTheme; - -/** - * Compiere Look & Feel. - * We wanted a nice UI not the battleship gray based stuff. - * I guess a matter of taste. - * - * : - * UIManager.setLookAndFeel(new com.adempiere.plaf.AdempiereLookAndFeel()); - * // or UIManager.setLookAndFeel("com.adempiere.plaf.AdempiereLookAndFeel"); - * - * - * @author Jorg Janke - * @version $Id: AdempiereLookAndFeel.java,v 1.2 2006/07/30 00:52:24 jjanke Exp $ - */ -public class CompiereLookAndFeel extends MetalLookAndFeel -{ - /** - * - */ - private static final long serialVersionUID = -5141712405407428104L; - - /** - * Constructor - */ - public CompiereLookAndFeel() - { - super(); - // System.setProperty("awt.visualbell", "true"); - } // AdempiereLookAndFeel - - /** The name */ - public static final String NAME = "Compiere"; - - /** The Theme */ - private static CompiereTheme s_compiereTheme = new CompiereThemeBlueMetal(); - private static MetalTheme s_theme = s_compiereTheme; - - /** Paint Round Corners */ - protected static boolean ROUND = false; - - /** Key of Client Property to paint in CompiereColor */ - public static final String BACKGROUND = "CompiereBackground"; - /** Key of Client Property for Rectangle Items - if exists, the standard background is used */ - public static final String BACKGROUND_FILL = "CompiereBackgroundFill"; - /** Key of Client Property for CPanel */ - public static final String TABLEVEL = "TabLevel"; - - /** Version tag */ - public static final String VERSION = "R1.4.0"; - - /** - * The Name - * @return Name - */ - public String getName() - { - return NAME; - } // getName - - /** - * The ID - * @return Name - */ - public String getID() - { - return NAME; - } // getID - - /** - * The Description - * @return description - */ - public String getDescription() - { - return "Compiere Look & Feel - (c) 2001-2005 Jorg Janke"; - } // getDescription - - - /************************************************************************** - * Get/Create Defaults - * @return UI Defaults - */ - public UIDefaults getDefaults() - { - // Theme already created/set - MetalLookAndFeel.setCurrentTheme(s_theme); - UIDefaults defaults = super.getDefaults(); // calls init..Defaults - return defaults; - } // getDefaults - - /** - * Creates the mapping from UI class IDs to ComponentUI classes, - * putting the ID-ComponentUI pairs in the passed-in defaults table. - * Each JComponent class specifies its own UI class ID string. - * - * @param table UI Defaults - */ - protected void initClassDefaults(UIDefaults table) - { - super.initClassDefaults( table); - // Overwrite - putDefault (table, "PanelUI"); - putDefault (table, "ButtonUI"); - putDefault (table, "ToggleButtonUI"); - putDefault (table, "TabbedPaneUI"); - putDefault (table, "TableHeaderUI"); - putDefault (table, "RadioButtonUI"); - putDefault (table, "CheckBoxUI"); - putDefault (table, "ComboBoxUI"); - putDefault (table, "MenuUI"); - putDefault (table, "MenuBarUI"); - putDefault (table, "MenuItemUI"); - putDefault (table, "CheckBoxMenuItemUI"); - putDefault (table, "ToolBarUI"); - putDefault (table, "RootPaneUI"); - putDefault (table, "ViewportUI"); - putDefault (table, "SplitPaneUI"); - putDefault (table, "ScrollPaneUI"); - putDefault (table, "LabelUI"); - putDefault (table, "ToolTipUI"); - putDefault (table, "TextAreaUI"); - - } // initClassDefaults - - /** - * Put "uiKey - ClassName" pair in UIDefaults - * @param table - * @param uiKey - */ - private void putDefault (UIDefaults table, String uiKey) - { - try - { - String className = "org.compiere.plaf.Compiere" + uiKey; - table.put(uiKey, className); - } - catch (Exception ex) - { - ex.printStackTrace(); - } - } // putDefault - - /** - * For overwriting Component defaults - * @param table - */ - protected void initSystemColorDefaults (UIDefaults table) - { - super.initSystemColorDefaults( table); - } // initSystemColorDefaults - - /** - * For overwriting Component defaults - * @param table - */ - protected void initComponentDefaults (UIDefaults table) - { - super.initComponentDefaults( table); - - // ComboBox defaults - Color c = table.getColor("TextField.background"); - table.put("ComboBox.background", c); - table.put("ComboBox.listBackground", c); - } // initComponentDefaults - - - /************************************************************************** - * Create Default Themes - */ - protected void createDefaultTheme() - { - setCurrentTheme(s_theme); - } // createDefaultTheme - - /** - * Set Current Theme - * @param theme metal theme - */ - public static void setCurrentTheme (MetalTheme theme) - { - if (theme != null) - s_theme = theme; - MetalLookAndFeel.setCurrentTheme(s_theme); - } // setCurrentTheme - - /** - * Get Current Theme - * @return Metal Theme - */ - public static MetalTheme getCurrentTheme() - { - return s_theme; - } // getCurrentTheme - - /** - * Get Compiere Theme - * @return Metal Theme - */ - public static CompiereTheme getCompiereTheme() - { - return s_compiereTheme; - } // getCurrentTheme - - /** - * Error Feedback. - *

    - * Invoked when the user attempts an invalid operation, - * such as pasting into an uneditable JTextField - * that has focus. - *

    - *

    - * If the user has enabled visual error indication on - * the desktop, this method will flash the caption bar - * of the active window. The user can also set the - * property awt.visualbell=true to achieve the same - * results. - *

    - * @param component Component the error occured in, may be - * null indicating the error condition is - * not directly associated with a - * Component. - */ - public void provideErrorFeedback (Component component) - { - super.provideErrorFeedback (component); - } // provideErrorFeedback - -} // AdempiereLookAndFeel diff --git a/org.adempiere.ui.swing/src/org/compiere/plaf/CompiereMenuBarUI.java b/org.adempiere.ui.swing/src/org/compiere/plaf/CompiereMenuBarUI.java deleted file mode 100644 index 7233fb8723..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/plaf/CompiereMenuBarUI.java +++ /dev/null @@ -1,75 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ -package org.compiere.plaf; - -import java.awt.Graphics; - -import javax.swing.JComponent; -import javax.swing.plaf.ComponentUI; -import javax.swing.plaf.metal.MetalMenuBarUI; - -/** - * Adempiere Menu Bar UI. - * Main Menu background - * - * @author Jorg Janke - * @version $Id: AdempiereMenuBarUI.java,v 1.2 2006/07/30 00:52:24 jjanke Exp $ - */ -public class CompiereMenuBarUI extends MetalMenuBarUI -{ - /** - * Create own instance - * @param x - * @return AdempiereMenuBarUI - */ - public static ComponentUI createUI (JComponent x) - { - return new CompiereMenuBarUI(); - } // createUI - - /** - * Install UI - * @param c - */ - public void installUI (JComponent c) - { - super.installUI(c); - c.setOpaque(true); - } // installUI - - /** - * Update UI - * @param g graphics - * @param c component - */ - public void update (Graphics g, JComponent c) - { - if (c.isOpaque()) - { - // Get AdempiereColor - CompiereColor bg = CompiereColor.getDefaultBackground(); - bg.paint (g, c); - } - else - { - g.setColor(c.getBackground()); - g.fillRect(0,0, c.getWidth(), c.getHeight()); - } - paint(g,c); - } // update - -} // AdempiereMenuBarUI diff --git a/org.adempiere.ui.swing/src/org/compiere/plaf/CompiereMenuItemUI.java b/org.adempiere.ui.swing/src/org/compiere/plaf/CompiereMenuItemUI.java deleted file mode 100644 index 5dba81309f..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/plaf/CompiereMenuItemUI.java +++ /dev/null @@ -1,92 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ -package org.compiere.plaf; - -import java.awt.Color; -import java.awt.Graphics; - -import javax.swing.ButtonModel; -import javax.swing.JComponent; -import javax.swing.JMenuItem; -import javax.swing.plaf.ComponentUI; -import javax.swing.plaf.basic.BasicMenuItemUI; - -/** - * Menu Item UI - * - * @author Jorg Janke - * @version $Id: AdempiereMenuItemUI.java,v 1.2 2006/07/30 00:52:24 jjanke Exp $ - */ -public class CompiereMenuItemUI extends BasicMenuItemUI -{ - /** - * Create own instance - * @param c compoment - * @return AdempiereMenuBarUI - */ - public static ComponentUI createUI(JComponent c) - { - return new CompiereMenuItemUI(); - } // createUI - - /** - * Install UI - * @param c - */ - public void installUI (JComponent c) - { - super.installUI(c); - c.setOpaque(false); // use MenuBarUI background - } // installUI - - /** - * Update UI - * @param g graphics - * @param c component - */ - public void update (Graphics g, JComponent c) - { - if (c.isOpaque()) - { - CompiereColor bg = CompiereColor.getDefaultBackground(); - bg.paint (g, c); - // - // g.setColor(c.getBackground()); - // g.fillRect(0,0, c.getWidth(), c.getHeight()); - } - paint(g,c); - } // update - - /** - * Paint Background - * @param g graphics - * @param menuItem menu - * @param bgColor bg color - */ - protected void paintBackground (Graphics g, JMenuItem menuItem, Color bgColor) - { - ButtonModel model = menuItem.getModel(); - if (model.isArmed()) - super.paintBackground (g, menuItem, bgColor); - else - { - CompiereColor bg = CompiereColor.getDefaultBackground(); - bg.paint (g, menuItem); - } - } // paintBackground - -} // AdempiereMenuItemUI diff --git a/org.adempiere.ui.swing/src/org/compiere/plaf/CompiereMenuUI.java b/org.adempiere.ui.swing/src/org/compiere/plaf/CompiereMenuUI.java deleted file mode 100644 index e74d517f80..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/plaf/CompiereMenuUI.java +++ /dev/null @@ -1,52 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ -package org.compiere.plaf; - -import javax.swing.JComponent; -import javax.swing.plaf.ComponentUI; -import javax.swing.plaf.basic.BasicMenuUI; - -/** - * Adempiere Menu UI. - * The main menu. - * - * @author Jorg Janke - * @version $Id: AdempiereMenuUI.java,v 1.2 2006/07/30 00:52:24 jjanke Exp $ - */ -public class CompiereMenuUI extends BasicMenuUI -{ - /** - * Create own instance - * @param x - * @return AdempiereMenuBarUI - */ - public static ComponentUI createUI(JComponent x) - { - return new CompiereMenuUI(); - } // createUI - - /** - * Install UI - * @param c - */ - public void installUI (JComponent c) - { - super.installUI(c); - c.setOpaque(false); // use MenuBarUI background - } // installUI - -} // AdempiereMenuUI diff --git a/org.adempiere.ui.swing/src/org/compiere/plaf/CompierePanelUI.java b/org.adempiere.ui.swing/src/org/compiere/plaf/CompierePanelUI.java deleted file mode 100644 index ae6e3b296a..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/plaf/CompierePanelUI.java +++ /dev/null @@ -1,136 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ -package org.compiere.plaf; - -import java.awt.Graphics; - -import javax.swing.JComponent; -import javax.swing.JPanel; -import javax.swing.plaf.ComponentUI; -import javax.swing.plaf.basic.BasicPanelUI; - -/** - * Panel UI. - * The default properties can be set via - *
    - *  AdempierePanelUI.setDefaultBackground (new AdempiereColor());
    - *  
    - * The individual Panel can set the background type by setting the - * parameter via - *
    - *  putClientProperty(AdempierePanelUI.BACKGROUND, new AdempiereColor());
    - *  
    - * @see org.compiere.swing.CPanel - * - * @author Jorg Janke - * @version $Id: AdempierePanelUI.java,v 1.2 2006/07/30 00:52:24 jjanke Exp $ - */ -public class CompierePanelUI extends BasicPanelUI -{ - /** - * Static Create UI - * @param c JComponent - * @return Adempiere Panel UI - */ - public static ComponentUI createUI (JComponent c) - { - // return new AdempierePanelUI(); - return s_panelUI; - } // createUI - - /** UI */ - private static CompierePanelUI s_panelUI = new CompierePanelUI(); - - - /************************************************************************** - * Install Defaults - * @param p Panel - */ - protected void installDefaults (JPanel p) - { - super.installDefaults(p); - /** If enabled, all windows are with Adempiere Background, - * but Sun dialogs (print ..) are "patchy" as they are opaque ** - // System.out.println ("BG=" + p.getClientProperty(AdempierePLAF.BACKGROUND)); - if (s_setDefault || p.getClientProperty(AdempierePLAF.BACKGROUND) == null) - p.putClientProperty (AdempierePLAF.BACKGROUND, s_default); - /** **/ - } // installDefaults - - - /************************************************************************** - * Update. - * This method is invoked by JComponent when the specified - * component is being painted. - * - * By default this method will fill the specified component with - * its background color (if its opaque property is - * true) and then immediately call paint. - * - * @param g the Graphics context in which to paint - * @param c the component being painted - * - * @see javax.swing.JComponent#paintComponent - */ - public void update (Graphics g, JComponent c) - { - // AdempiereUtils.printParents (c); - if (c.isOpaque()) - updateIt (g, c); - paint (g, c); // does nothing - } // update - - /** - * Print background based on AdempiereColor or flat background if not found - * @param g - * @param c - */ - static void updateIt (Graphics g, JComponent c) - { - // System.out.print("Panel " + c.getName()); - // System.out.print(" Bounds=" + c.getBounds().toString()); - // System.out.print(" - Background: "); - - // Get AdempiereColor - CompiereColor bg = null; - try - { - bg = (CompiereColor)c.getClientProperty(CompiereLookAndFeel.BACKGROUND); - } - catch (Exception e) - { - System.err.println("AdempierePanelUI - ClientProperty: " + e.getMessage()); - } - // paint adempiere background - if (bg != null) - { - // System.out.print(bg); - bg.paint (g, c); - } - else - { - // System.out.print(c.getBackground()); - g.setColor(c.getBackground()); - g.fillRect(0,0, c.getWidth(), c.getHeight()); - } - // System.out.println(); - } // updateIt - - /*************************************************************************/ - - -} // AdempierePanel diff --git a/org.adempiere.ui.swing/src/org/compiere/plaf/CompiereRadioButtonUI.java b/org.adempiere.ui.swing/src/org/compiere/plaf/CompiereRadioButtonUI.java deleted file mode 100644 index 0973feb52f..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/plaf/CompiereRadioButtonUI.java +++ /dev/null @@ -1,56 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ -package org.compiere.plaf; - -import javax.swing.AbstractButton; -import javax.swing.JComponent; -import javax.swing.plaf.ComponentUI; -import javax.swing.plaf.metal.MetalRadioButtonUI; - -/** - * Adempiere Radio Button UI - * - * @author Jorg Janke - * @version $Id: AdempiereRadioButtonUI.java,v 1.2 2006/07/30 00:52:23 jjanke Exp $ - */ -public class CompiereRadioButtonUI extends MetalRadioButtonUI -{ - /** - * Create UI - * @param c component - * @return ComponentUI - */ - public static ComponentUI createUI (JComponent c) - { - return s_radioButtonUI; - } // createUI - - /** UI */ - private static final CompiereRadioButtonUI s_radioButtonUI = new CompiereRadioButtonUI(); - - - /************************************************************************** - * Install Defaults - * @param b Button - */ - public void installDefaults (AbstractButton b) - { - super.installDefaults(b); - b.setOpaque(false); - } // installDefaults - -} // AdempiereRadioButtonUI diff --git a/org.adempiere.ui.swing/src/org/compiere/plaf/CompiereRootPaneUI.java b/org.adempiere.ui.swing/src/org/compiere/plaf/CompiereRootPaneUI.java deleted file mode 100644 index 10b17f07fa..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/plaf/CompiereRootPaneUI.java +++ /dev/null @@ -1,33 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ -package org.compiere.plaf; - -import javax.swing.plaf.metal.MetalRootPaneUI; - -/** - * Root Pane UI - * - * @author Jorg Janke - * @version $Id: AdempiereRootPaneUI.java,v 1.2 2006/07/30 00:52:24 jjanke Exp $ - */ -public class CompiereRootPaneUI extends MetalRootPaneUI -{ -/** - * MetalTitlePane does the Layout & Painting of the Window including System MenuBar - * The titlePane is private in MetalRootPaneUI - */ -} // AdempiereRootPaneUI diff --git a/org.adempiere.ui.swing/src/org/compiere/plaf/CompiereScrollPaneUI.java b/org.adempiere.ui.swing/src/org/compiere/plaf/CompiereScrollPaneUI.java deleted file mode 100644 index d42c505a13..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/plaf/CompiereScrollPaneUI.java +++ /dev/null @@ -1,54 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ -package org.compiere.plaf; - -import javax.swing.JComponent; -import javax.swing.JScrollPane; -import javax.swing.plaf.ComponentUI; -import javax.swing.plaf.metal.MetalScrollPaneUI; - -/** - * Adempiere Scroll Pane UI - * - * @author Jorg Janke - * @version $Id: AdempiereScrollPaneUI.java,v 1.2 2006/07/30 00:52:23 jjanke Exp $ - */ -public class CompiereScrollPaneUI extends MetalScrollPaneUI -{ - /** - * Create UI (not shared) - * @param x - * @return UI - */ - public static ComponentUI createUI(JComponent x) - { - return new CompiereScrollPaneUI(); - } // createUI - - /** - * Install UI - * @param c - */ - public void installUI (JComponent c) - { - super.installUI(c); - c.setOpaque(false); - // was ignored as set in constructor after updateUI - Sun bug: 138828 - ((JScrollPane)c).getViewport().setOpaque(false); - } // installUI - -} // AdempiereScrollPaneUI diff --git a/org.adempiere.ui.swing/src/org/compiere/plaf/CompiereSplitPaneDivider.java b/org.adempiere.ui.swing/src/org/compiere/plaf/CompiereSplitPaneDivider.java deleted file mode 100644 index d451ade5cd..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/plaf/CompiereSplitPaneDivider.java +++ /dev/null @@ -1,61 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ -package org.compiere.plaf; - -import java.awt.Graphics; - -import javax.swing.plaf.basic.BasicSplitPaneDivider; -import javax.swing.plaf.basic.BasicSplitPaneUI; - -/** - * Split Pane Divider - * - * @author Jorg Janke - * @version $Id: AdempiereSplitPaneDivider.java,v 1.2 2006/07/30 00:52:24 jjanke Exp $ - */ -class CompiereSplitPaneDivider extends BasicSplitPaneDivider -{ - /** - * - */ - private static final long serialVersionUID = 8912837390203690804L; - - /** - * Constructor - * @param ui - */ - public CompiereSplitPaneDivider (BasicSplitPaneUI ui) - { - super (ui); - // BasicBorders$SplitPaneDividerBorder - ignored set after constructor - setBorder(null); - } // AdempiereSplitPaneDivider - - /** - * Paints the divider. - * If the border is painted, it creates a light gray bar on top/button. - * Still, a light gray 1 pt shaddow border is painted on top/button - * @param g - */ - public void paint (Graphics g) - { - // BasicBorders$SplitPaneDividerBorder - setBorder(null); - super.paint(g); - } // paint - -} // AdempiereSplitPaneDivider diff --git a/org.adempiere.ui.swing/src/org/compiere/plaf/CompiereSplitPaneUI.java b/org.adempiere.ui.swing/src/org/compiere/plaf/CompiereSplitPaneUI.java deleted file mode 100644 index b4ac64e70e..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/plaf/CompiereSplitPaneUI.java +++ /dev/null @@ -1,69 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ -package org.compiere.plaf; - -import javax.swing.JComponent; -import javax.swing.plaf.ComponentUI; -import javax.swing.plaf.basic.BasicSplitPaneDivider; -import javax.swing.plaf.basic.BasicSplitPaneUI; - -/** - * Adempiere Split Pane UI. - * When moving, the divider is painted in darkGray. - * - * @author Jorg Janke - * @version $Id: AdempiereSplitPaneUI.java,v 1.2 2006/07/30 00:52:24 jjanke Exp $ - */ -public class CompiereSplitPaneUI extends BasicSplitPaneUI -{ - /** - * Creates a new MetalSplitPaneUI instance - * @param x - * @return ComponentUI - */ - public static ComponentUI createUI (JComponent x) - { - return new CompiereSplitPaneUI(); - } // createUI - - /** - * Creates the default divider. - * @return SplitPaneDivider - */ - public BasicSplitPaneDivider createDefaultDivider() - { - return new CompiereSplitPaneDivider (this); - } - - /** - * Installs the UI. - * @param c - */ - public void installUI (JComponent c) - { - super.installUI(c); - c.setOpaque(false); - // BasicBorders$SplitPaneBorder paints gray border - // resulting in a 2pt border for the left/right components - // but results in 1pt gray line on top/button of divider. - // Still, a 1 pt shaddow light gay line is painted - c.setBorder(null); - } // installUI - - - -} // AdempiereSplitPaneUI diff --git a/org.adempiere.ui.swing/src/org/compiere/plaf/CompiereTabbedPaneUI.java b/org.adempiere.ui.swing/src/org/compiere/plaf/CompiereTabbedPaneUI.java deleted file mode 100644 index 09a9f75378..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/plaf/CompiereTabbedPaneUI.java +++ /dev/null @@ -1,1068 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ -package org.compiere.plaf; - -import java.awt.Color; -import java.awt.Component; -import java.awt.Dimension; -import java.awt.Font; -import java.awt.FontMetrics; -import java.awt.GradientPaint; -import java.awt.Graphics; -import java.awt.Graphics2D; -import java.awt.Insets; -import java.awt.LayoutManager; -import java.awt.Polygon; -import java.awt.Rectangle; -import java.awt.Shape; - -import javax.swing.Icon; -import javax.swing.JComponent; -import javax.swing.JPanel; -import javax.swing.SwingUtilities; -import javax.swing.plaf.ComponentUI; -import javax.swing.plaf.basic.BasicGraphicsUtils; -import javax.swing.plaf.metal.MetalTabbedPaneUI; - -/** - * Same implementation detail as in AdempierePanelUI. - * Additional handling of dwawing tabs. - * @see CompierePanelUI - * - * @author Jorg Janke - * @version $Id: AdempiereTabbedPaneUI.java,v 1.3 2006/07/30 00:52:23 jjanke Exp $ - */ -public class CompiereTabbedPaneUI extends MetalTabbedPaneUI -{ - /** - * Static Create UI - * @param c Component - * @return Adempiere TabbedPaneUI - */ - public static ComponentUI createUI(JComponent c) - { - return new CompiereTabbedPaneUI(); - } // createUI - - /** - * Install Defaults - */ - protected void installDefaults() - { - super.installDefaults(); - tabPane.setOpaque(false); - } // installDefaults - - - /************************************************************************* - * Update - - * This method is invoked by JComponent when the specified - * component is being painted. - * - * By default this method will fill the specified component with - * its background color (if its opaque property is - * true) and then immediately call paint. - * - * @param g the Graphics context in which to paint - * @param c the component being painted - * - * @see #paint - * @see javax.swing.JComponent#paintComponent - */ - public void update (Graphics g, JComponent c) - { - /** - System.out.println (c.getClass().getName() + " ** " + c.isOpaque()); - Container container = c.getParent(); - while (container != null) - { - System.out.println (" - " + container.getClass() + " ** " + container.isOpaque() ); - container = container.getParent(); - } - */ - - // System.out.println("Tab: Bounds=" + c.getBounds() + " - " + c.getClass().getName()); - - if (c.isOpaque()) - CompierePanelUI.updateIt (g, c); // tabAreaBackground - paint (g, c); - } // update - - /** - * Paint it - * @param g graphics - * @param c component - */ - public void paint( Graphics g, JComponent c ) - { - int tabPlacement = tabPane.getTabPlacement(); - Insets insets = c.getInsets(); - Dimension size = c.getSize(); - - if ( tabPane.isOpaque() ) - { - g.setColor(c.getBackground()); - /** @todo Printing of area behind Tabs */ - switch (tabPlacement) - { - case LEFT: - g.fillRect( insets.left, insets.top, - calculateTabAreaWidth( tabPlacement, runCount, maxTabWidth ), - size.height - insets.bottom - insets.top ); - break; - case BOTTOM: - int totalTabHeight = calculateTabAreaHeight( tabPlacement, runCount, maxTabHeight ); - g.fillRect( insets.left, size.height - insets.bottom - totalTabHeight, - size.width - insets.left - insets.right, - totalTabHeight ); - break; - case RIGHT: - int totalTabWidth = calculateTabAreaWidth( tabPlacement, runCount, maxTabWidth ); - g.fillRect( size.width - insets.right - totalTabWidth, - insets.top, totalTabWidth, - size.height - insets.top - insets.bottom ); - break; - // - case TOP: - default: - g.fillRect( insets.left, insets.top, - size.width - insets.right - insets.left, - calculateTabAreaHeight(tabPlacement, runCount, maxTabHeight) ); - paintHighlightBelowTab(); - } - } - else - super.paint( g, c ); - } // paint - - - /************************************************************************** - * Paint the actual Tab Background. - * Called from Basic.PaintTab (<- Basic.paintTabArea <- Basic.paint) - *

    - * Based on MetalTabbedPaneUI.paintTabBackground: - * Differences: - * - Color based on primary Background of Tab - * - Selected Tab is painted - *

    -	 *          selected    not sel
    -	 *  top     //////////  //////////  (lighter)
    -	 *                      ++++++++++  (flat/darker)
    -	 *
    -	 *  bottom              //////////  (flat/lighter)
    -	 *          ++++++++++  ++++++++++  (darker)
    -	 *
    -	 *  sides               //////////  (flat/ligher)
    -	 *                      ++++++++++  (flat/darker)
    -	 *  
    - * @param g graphics - * @param tabPlacement tab placement - * @param tabIndex tab index - * @param x x - * @param y y - * @param w width - * @param h height - * @param isSelected selected - */ - protected void paintTabBackground (Graphics g, int tabPlacement, - int tabIndex, int x, int y, int w, int h, boolean isSelected) - { - Graphics2D g2D = (Graphics2D)g; - - - // Get Background color of Tab - Component comp = tabPane.getComponentAt(tabIndex); - // System.out.println("Tab " + tabIndex + " Comp=" + comp.getName() + " " + comp.getClass().getName() + " x=" + x + ", y=" + y + ", w=" +w + ", h=" + h); - g2D.setPaint(comp.getBackground()); - CompiereColor bg = CompiereColor.getDefaultBackground(); - if (comp instanceof JPanel) - { - JPanel jp = (JPanel)comp; - try - { - bg = (CompiereColor)jp.getClientProperty(CompiereLookAndFeel.BACKGROUND); - } - catch (Exception e) - { - System.err.println("AdempiereTabbedPaneUI - ClientProperty: " + e.getMessage()); - } - } - - if (bg == null) // No Background - { - if (CompiereUtils.isLeftToRight(tabPane)) - { - switch (tabPlacement) - { - case LEFT: - g2D.fillRect( x + 5, y + 1, w - 5, h - 1); - g2D.fillRect( x + 2, y + 4, 3, h - 4 ); - break; - case BOTTOM: - g2D.fillRect( x + 2, y, w - 2, h - 4 ); - g2D.fillRect( x + 5, y + (h - 1) - 3, w - 5, 3 ); - break; - case RIGHT: - g2D.fillRect( x + 1, y + 1, w - 5, h - 1); - g2D.fillRect( x + (w - 1) - 3, y + 5, 3, h - 5 ); - break; - case TOP: - default: - g2D.fillRect( x + 4, y + 2, (w - 1) - 3, (h - 1) - 1 ); - g2D.fillRect( x + 2, y + 5, 2, h - 5 ); - } - } - else - { - switch (tabPlacement) - { - case LEFT: - g2D.fillRect( x + 5, y + 1, w - 5, h - 1); - g2D.fillRect( x + 2, y + 4, 3, h - 4 ); - break; - case BOTTOM: - g2D.fillRect( x, y, w - 5, h - 1 ); - g2D.fillRect( x + (w - 1) - 4, y, 4, h - 5); - g2D.fillRect( x + (w - 1) - 4, y + (h - 1) - 4, 2, 2); - break; - case RIGHT: - g2D.fillRect( x + 1, y + 1, w - 5, h - 1); - g2D.fillRect( x + (w - 1) - 3, y + 5, 3, h - 5 ); - break; - case TOP: - default: - g2D.fillRect( x, y + 2, (w - 1) - 3, (h - 1) - 1 ); - g2D.fillRect( x + (w - 1) - 3, y + 4, 3, h - 4 ); - } - } - } - else // we have a background - { - if (CompiereUtils.isLeftToRight(tabPane)) - { - switch (tabPlacement) - { - case LEFT: - bg.paintRect (g2D, tabPane, x + 5, y + 1, w - 5, h - 1); - bg.paintRect (g2D, tabPane, x + 2, y + 4, 3, h - 4 ); - break; - case BOTTOM: - bg.paintRect (g2D, tabPane, x + 2, y, w - 2, h - 4 ); - bg.paintRect (g2D, tabPane, x + 5, y + (h - 1) - 3, w - 5, 3 ); - break; - case RIGHT: - // bg.paintRect (g2D, tabPane, x + 1, y + 1, w - 5, h - 1); - bg.paintRect (g2D, tabPane, x, y + 2, w - 4, h - 2); // changed - bg.paintRect (g2D, tabPane, x + (w - 1) - 3, y + 5, 3, h - 5 ); - break; - case TOP: - default: - bg.paintRect (g2D, tabPane, x + 4, y + 2, (w - 1) - 3, (h - 1) - 1 ); - bg.paintRect (g2D, tabPane, x + 2, y + 5, 2, h - 5 ); - } - } - else - { - switch (tabPlacement) - { - case LEFT: - bg.paintRect (g2D, tabPane, x + 5, y + 1, w - 5, h - 1); - bg.paintRect (g2D, tabPane, x + 2, y + 4, 3, h - 4 ); - break; - case BOTTOM: - bg.paintRect (g2D, tabPane, x, y, w - 5, h - 1 ); - bg.paintRect (g2D, tabPane, x + (w - 1) - 4, y, 4, h - 5); - bg.paintRect (g2D, tabPane, x + (w - 1) - 4, y + (h - 1) - 4, 2, 2); - break; - case RIGHT: - bg.paintRect (g2D, tabPane, x + 1, y + 1, w - 5, h - 1); - bg.paintRect (g2D, tabPane, x + (w - 1) - 3, y + 5, 3, h - 5 ); - break; - case TOP: - default: - bg.paintRect (g2D, tabPane, x, y + 2, (w - 1) - 3, (h - 1) - 1 ); - bg.paintRect (g2D, tabPane, x + (w - 1) - 3, y + 4, 3, h - 4 ); - } - } - } - - // Upper Part - not when selected and R/L/B - if (!(isSelected && (tabPlacement == RIGHT || tabPlacement == LEFT || tabPlacement == BOTTOM))) - { - Shape top = new Rectangle (x, y, w, h/2); // upper half - if (tabPlacement == TOP || tabPlacement == LEFT) - top = new Polygon ( // top left triangle - new int[] {x+6, x+w, x+w, x, x }, - new int[] {y, y, y+(h/2), y+(h/2), y+6 }, 5); - else if (tabPlacement == RIGHT) - top = new Polygon ( // top right triangle - new int[] {x, x+w-6, x+w, x+w, x }, - new int[] {y, y, y+6, y+(h/2), y+(h/2) }, 5); - // lighter - GradientPaint paint = new GradientPaint ( - x, y, CompiereUtils.COL_1TOP, - x, y+(h/2), CompiereUtils.COL_1END); - g2D.setPaint(paint); - g2D.fill(top); - } - - // Lower part - not when selected and T/R/L - if (!(isSelected && (tabPlacement == TOP || tabPlacement == RIGHT || tabPlacement == LEFT))) - { - Shape end = new Rectangle (x, y+(h/2), w, h/2); // lower half - if (tabPlacement == BOTTOM) - end = new Polygon ( // bottom left triangle - new int[] {x, x+w, x+w, x+6, x }, - new int[] {y+(h/2), y+(h/2), y+h, y+h, y+h-6 }, 5); - // darker - GradientPaint paint = new GradientPaint ( - x, y+(h/2), CompiereUtils.COL_2TOP, - x, y+h, CompiereUtils.COL_2END); - g2D.setPaint(paint); - g2D.fill(end); - } - - } // paintTabBackground - - - /************************************************************************** - * Paint Content Border (overwriting BasicTabbedPanelUI) - * Uses Color from actual Tab (not from TabbedPane) - * @param g graphics - * @param tabPlacement tab placement - * @param selectedIndex index - */ - protected void paintContentBorder (Graphics g, int tabPlacement, int selectedIndex) - { - // System.out.println("TabContentBorder " ); - int width = tabPane.getWidth(); - int height = tabPane.getHeight(); - Insets insets = tabPane.getInsets(); - - int x = insets.left; - int y = insets.top; - int w = width - insets.right - insets.left; - int h = height - insets.top - insets.bottom; - - switch (tabPlacement) - { - case LEFT: - x += calculateTabAreaWidth(tabPlacement, runCount, maxTabWidth); - w -= (x - insets.left); - break; - case RIGHT: - w -= calculateTabAreaWidth(tabPlacement, runCount, maxTabWidth); - break; - case BOTTOM: - h -= calculateTabAreaHeight(tabPlacement, runCount, maxTabHeight); - break; - case TOP: - default: - y += calculateTabAreaHeight(tabPlacement, runCount, maxTabHeight); - h -= (y - insets.top); - } - - // Fill region behind content area - basically a border - Component comp = null; - if (selectedIndex != -1) - comp = tabPane.getComponentAt(selectedIndex); - if (comp != null && comp instanceof JComponent) - { - JComponent jc = (JComponent)comp; - CompiereColor bg = null; - try - { - if (jc != null) - bg = (CompiereColor)jc.getClientProperty(CompiereLookAndFeel.BACKGROUND); - } - catch (Exception e) - { - System.err.println("AdempiereTabbedPaneUI - ClientProperty: " + e.getMessage()); - } - if (bg == null) - { - bg = new CompiereColor(jc.getBackground()); - jc.putClientProperty(CompiereLookAndFeel.BACKGROUND, bg); - } - bg.paintRect(g, jc, x,y, w,h); - } - // Not a JComponent - paint flat - else if (comp != null) - { - g.setColor(comp.getBackground()); - g.fillRect(x,y, w,h); - } - - paintContentBorderTopEdge(g, tabPlacement, selectedIndex, x, y, w, h); - paintContentBorderLeftEdge(g, tabPlacement, selectedIndex, x, y, w, h); - paintContentBorderBottomEdge(g, tabPlacement, selectedIndex, x, y, w, h); - paintContentBorderRightEdge(g, tabPlacement, selectedIndex, x, y, w, h); - } // paintContentBorder - - /** - * Paint left content border edge - * @param g graphics - * @param tabPlacement tab placement - * @param selectedIndex index - * @param x x - * @param y y - * @param w width - * @param h height - */ - protected void paintContentBorderLeftEdge (Graphics g, int tabPlacement, - int selectedIndex, int x, int y, int w, int h) - { - Rectangle selRect = selectedIndex < 0 ? null : getTabBounds(selectedIndex, calcRect); - g.setColor(selectHighlight); - - // Draw unbroken line if tabs are not on LEFT, OR - // selected tab is not in run adjacent to content, OR - // selected tab is not visible (SCROLL_TAB_LAYOUT) - if (tabPlacement != LEFT || selectedIndex < 0 - || (selRect.x + selRect.width + 1 < x) - || (selRect.y < y || selRect.y > y + h)) - { - g.drawLine(x, y, x, y+h-2); - } - else - { - // Break line to show visual connection to selected tab - g.drawLine(x, y, x, selRect.y + 1); - if (selRect.y + selRect.height < y + h - 2) - g.drawLine(x, selRect.y + selRect.height + 1, x, y+h-2); // bug - } - } - - /** - * Paint bottom content area edge - * @param g graphics - * @param tabPlacement tab placement - * @param selectedIndex index - * @param x x - * @param y y - * @param w width - * @param h height - */ - protected void paintContentBorderBottomEdge (Graphics g, int tabPlacement, - int selectedIndex, int x, int y, int w, int h) - { - boolean leftToRight = CompiereUtils.isLeftToRight(tabPane); - int bottom = y + h - 1; - int right = x + w - 1; - Rectangle selRect = selectedIndex < 0 ? null : getTabBounds(selectedIndex, calcRect); - g.setColor(shadow); - - // Draw unbroken line if tabs are not on BOTTOM, OR - // selected tab is not in run adjacent to content, OR - // selected tab is not visible (SCROLL_TAB_LAYOUT) - if (tabPlacement != BOTTOM - || selectedIndex < 0 -// || (selRect.y - 1 > h) // bug!! - || (selRect.x < x || selRect.x > x + w)) - { - g.setColor(darkShadow); - g.drawLine(x, y+h-1, x+w-1, y+h-1); - } - else - { - // Break line to show visual connection to selected tab - boolean lastInRun = isLastInRun(selectedIndex); - g.setColor(darkShadow); - if ( leftToRight || lastInRun ) - g.drawLine(x, bottom, selRect.x, bottom); - else - g.drawLine(x, bottom, selRect.x - 1, bottom); - - if (selRect.x + selRect.width < x + w - 2) - { - if ( leftToRight && !lastInRun ) - g.drawLine(selRect.x + selRect.width, bottom, right, bottom); - else - g.drawLine(selRect.x + selRect.width - 1, bottom, right, bottom); - } - } - } // paintContentBorderBottomEdge - - /** - * Paint right Contenr border edge - * @param g graphics - * @param tabPlacement tab placement - * @param selectedIndex index - * @param x x - * @param y y - * @param w width - * @param h height - */ - protected void paintContentBorderRightEdge (Graphics g, int tabPlacement, - int selectedIndex, int x, int y, int w, int h) - { - Rectangle selRect = selectedIndex < 0 ? null : getTabBounds(selectedIndex, calcRect); - g.setColor(shadow); - - // Draw unbroken line if tabs are not on RIGHT, OR - // selected tab is not in run adjacent to content, OR - // selected tab is not visible (SCROLL_TAB_LAYOUT) - if (tabPlacement != RIGHT - || selectedIndex < 0 -// || (selRect.x - 1 > w) // bug !! - || (selRect.y < y || selRect.y > y + h) - ) - { - g.setColor(darkShadow); - g.drawLine(x+w-1, y, x+w-1, y+h-1); - } - else - { - // Break line to show visual connection to selected tab - g.setColor(darkShadow); - g.drawLine(x+w-1, y, x+w-1, selRect.y); - if (selRect.y + selRect.height < y + h - 2) - { - g.setColor(darkShadow); - g.drawLine(x+w-1, selRect.y + selRect.height, x+w-1, y+h-2); - } - } - } // paintContentBorderRightEdge - - /** - * Is Last Run - * @param tabIndex index - * @return true if last tab run - */ - private boolean isLastInRun (int tabIndex) - { - int run = getRunForTab( tabPane.getTabCount(), tabIndex ); - int lastIndex = lastTabInRun( tabPane.getTabCount(), run ); - return tabIndex == lastIndex; - } // isLastRun - - - /************************************************************************** - * Fill Tab gap triangle (no) - * @param currentRun current run - * @param tabIndex tab index - * @param x x - * @param y y - * @return false - */ - protected boolean shouldFillGap (int currentRun, int tabIndex, int x, int y) - { - return false; - } // shouldFillGap - - /** - * Paint Top Tab Border - * @param tabIndex index - * @param g graphics - * @param x x - * @param y y - * @param w width - * @param h height - * @param btm bottom - * @param rght right - * @param isSelected selected - */ - protected void paintTopTabBorder ( int tabIndex, Graphics g, - int x, int y, int w, int h, int btm, int rght, boolean isSelected ) - { - int currentRun = getRunForTab( tabPane.getTabCount(), tabIndex ); - int lastIndex = lastTabInRun( tabPane.getTabCount(), currentRun ); - int firstIndex = tabRuns[ currentRun ]; - boolean leftToRight = CompiereUtils.isLeftToRight(tabPane); - int bottom = h - 1; - int right = w - 1; - - // ** Paint Gap ** - if ( shouldFillGap( currentRun, tabIndex, x, y ) ) - { - g.translate( x, y ); - if ( leftToRight ) - { - g.setColor( getColorForGap( currentRun, x, y + 1 ) ); - g.fillRect( 1, 0, 5, 3 ); - g.fillRect( 1, 3, 2, 2 ); - } - else - { - g.setColor( getColorForGap( currentRun, x + w - 1, y + 1 ) ); - g.fillRect( right - 5, 0, 5, 3 ); - g.fillRect( right - 2, 3, 2, 2 ); - } - g.translate( -x, -y ); - } - - g.translate( x, y ); - // ** Paint Border ** - g.setColor( darkShadow ); - if (leftToRight) - { - // Paint slant - g.drawLine( 1, 5, 6, 0 ); - // Paint top - g.drawLine( 6, 0, right, 0 ); - // Paint right - if ( tabIndex==lastIndex ) // last tab in run - g.drawLine( right, 1, right, bottom ); - // Paint left - if ( tabIndex != tabRuns[ runCount - 1 ] ) // not the first tab in the last run - g.drawLine( 0, 0, 0, bottom ); - else // the first tab in the last run - g.drawLine( 0, 6, 0, bottom ); - } - else - { - // Paint slant - g.drawLine( right - 1, 5, right - 6, 0 ); - // Paint top - g.drawLine( right - 6, 0, 0, 0 ); - // Paint right - if ( tabIndex != tabRuns[ runCount - 1 ] ) // not the first tab in the last run - g.drawLine( right, 0, right, bottom ); - else // the first tab in the last run - g.drawLine( right, 6, right, bottom ); - // Paint left - if ( tabIndex==lastIndex ) // last tab in run - g.drawLine( 0, 1, 0, bottom ); - } - - // Paint button - if (!isSelected) - g.drawLine(0, bottom, right, bottom); // added - - // ** Paint Highlight ** - g.setColor( isSelected ? selectHighlight : highlight ); - if ( leftToRight ) - { - // Paint slant - g.drawLine( 1, 6, 6, 1 ); - // Paint top - if (tabIndex == lastIndex) - g.drawLine( 6, 1, right-1, 1 ); - else - g.drawLine( 6, 1, right, 1 ); // bug !! - // Paint left - g.drawLine( 1, 6, 1, bottom ); - - // paint highlight in the gap on tab behind this one - // on the left end (where they all line up) - if ( tabIndex==firstIndex && tabIndex!=tabRuns[runCount - 1] ) - { - // first tab in run but not first tab in last run - if (tabPane.getSelectedIndex()==tabRuns[currentRun+1]) - { - // tab in front of selected tab - g.setColor( selectHighlight ); - } - else - { - // tab in front of normal tab - g.setColor( highlight ); - } - g.drawLine( 1, 0, 1, 4 ); - } - } - else - { - // Paint slant - g.drawLine( right - 1, 6, right - 6, 1 ); - // Paint top - g.drawLine( right - 6, 1, 1, 1 ); - - // Paint left - if ( tabIndex==lastIndex ) // last tab in run - g.drawLine( 1, 1, 1, bottom ); - else - g.drawLine( 0, 1, 0, bottom ); - } - g.translate( -x, -y ); - } // paintTopTabBorder - - /** - * Paint Border of Left Tab. - * Does not fill triangle - * - * @param tabIndex index - * @param g graphics - * @param x x - * @param y y - * @param w width - * @param h height - * @param btm bottom - * @param rght right - * @param isSelected selected - */ - protected void paintLeftTabBorder (int tabIndex, Graphics g, - int x, int y, int w, int h, int btm, int rght, boolean isSelected) - { - int tabCount = tabPane.getTabCount(); - int currentRun = getRunForTab( tabCount, tabIndex ); - @SuppressWarnings("unused") - int lastIndex = lastTabInRun( tabCount, currentRun ); - @SuppressWarnings("unused") - int firstIndex = tabRuns[ currentRun ]; - - g.translate( x, y ); - - int bottom = h - 1; - int right = w - 1; - - // ** Paint Highlight ** - g.setColor( isSelected ? selectHighlight : highlight ); - // Paint slant - g.drawLine( 1, 6, 6, 1 ); - // Paint top - g.drawLine( 6, 1, right, 1 ); - // Paint left - g.drawLine( 1, 6, 1, bottom ); - // Paint right - if (!isSelected) - g.drawLine(right-1, 0, right-1, bottom ); - - // ** Paint Border ** - g.setColor( darkShadow ); - // Paint slant - g.drawLine( 1, 5, 6, 0 ); - // Paint top - g.drawLine( 6, 0, right, 0 ); - // Paint left - g.drawLine( 0, 6, 0, bottom ); - // Paint bottom - g.drawLine( 0, bottom, right, bottom ); - // Paint right - if (!isSelected) - g.drawLine(right, 0, right, bottom ); - // - g.translate( -x, -y ); - } // paintLeftTabBorder - - - /** - * Paint Border of Right Tab. - * Does not fill triangle - * - * @param tabIndex index - * @param g graphics - * @param x x - * @param y y - * @param w width - * @param h height - * @param btm bottom - * @param rght right - * @param isSelected selected - */ - protected void paintRightTabBorder (int tabIndex, Graphics g, - int x, int y, int w, int h, int btm, int rght, boolean isSelected) - { - int tabCount = tabPane.getTabCount(); - int currentRun = getRunForTab( tabCount, tabIndex ); - @SuppressWarnings("unused") - int lastIndex = lastTabInRun( tabCount, currentRun ); - @SuppressWarnings("unused") - int firstIndex = tabRuns[ currentRun ]; - - g.translate( x, y ); - - int bottom = h - 1; - int right = w - 1; - - // ** Paint Highlight ** - g.setColor( isSelected ? selectHighlight : highlight ); - // Paint slant - g.drawLine (right-6, 1, right-1, 6 ); - // Paint top - g.drawLine (0, 1, right - 6, 1 ); - // Paint right - g.drawLine (right-1, 6, right-1, bottom-1); - // Paint left - if (!isSelected) - g.drawLine (0, 1, 0, bottom-1); - - // ** Paint Border ** - g.setColor( darkShadow ); - // Paint slant - g.drawLine (right - 6, 0, right, 6 ); - // Paint top - g.drawLine (0, 0, right - 6, 0 ); - // Paint right - g.drawLine (right, 6, right, bottom ); - // Paint bottom - g.drawLine( 0, bottom, right, bottom ); - - g.translate( -x, -y ); - } // paintRightTabBorder - - - /************************************************************************** - * Calculate Tab Width. - * We may have to overwrite to adjust width for TabHirarchyLevel - * @param tabPlacement tab placement - * @param tabIndex tab index - * @param metrics metcics - * @return tab width - */ - protected int calculateTabWidth (int tabPlacement, int tabIndex, FontMetrics metrics) - { - boolean calculate = !(tabPlacement == TOP || tabPlacement == BOTTOM); - // HTML - if (getTextViewForTab(tabIndex) != null) - calculate = false; - // No spaces in title - String title = tabPane.getTitleAt(tabIndex); - int pos = title.indexOf(' '); - if (calculate && pos == -1) - calculate = false; - if (!calculate) - return super.calculateTabWidth (tabPlacement, tabIndex, metrics); - // - Icon icon = getIconForTab(tabIndex); - Insets tabInsetsLocal = getTabInsets(tabPlacement, tabIndex); - int width = tabInsetsLocal.left + tabInsetsLocal.right + 3; - - if (icon != null) - width += icon.getIconWidth() + textIconGap; - - String firstLine = title.substring(0, pos); - String secondLine = title.substring(pos+1); - width += Math.max(SwingUtilities.computeStringWidth (metrics, firstLine), - SwingUtilities.computeStringWidth (metrics, secondLine)); - return width; - } // calculateTabWidth - - /** - * Calculate TabHeight - * @param tabPlacement tab placement - * @param tabIndex tab index - * @param fontHeight font height - * @return tab height - */ - protected int calculateTabHeight(int tabPlacement, int tabIndex, int fontHeight) - { - boolean calculate = !(tabPlacement == TOP || tabPlacement == BOTTOM); - // HTML - if (getTextViewForTab(tabIndex) != null) - calculate = false; - // No spaces in title - String title = tabPane.getTitleAt(tabIndex); - int pos = title.indexOf(' '); - if (calculate && pos == -1) - calculate = false; - if (!calculate) - return super.calculateTabHeight (tabPlacement, tabIndex, fontHeight); - // - int height = fontHeight * 2; - Icon icon = getIconForTab(tabIndex); - Insets tabInsetsLocal = getTabInsets(tabPlacement, tabIndex); - if (icon != null) - height = Math.max(height, icon.getIconHeight()); - height += tabInsetsLocal.top + tabInsetsLocal.bottom + 2; - return height; - } - - /** - * Layout Label - * @param tabPlacement tab placement - * @param metrics fint metrics - * @param tabIndex tab index - * @param title title - * @param icon icon - * @param tabRect tab bounds - * @param iconRect icon bounds - * @param textRect text bounds - * @param isSelected selected - */ - protected void layoutLabel(int tabPlacement, - FontMetrics metrics, int tabIndex, String title, Icon icon, - Rectangle tabRect, Rectangle iconRect, Rectangle textRect, boolean isSelected) - { - boolean calculate = !(tabPlacement == TOP || tabPlacement == BOTTOM); - // HTML - if (getTextViewForTab(tabIndex) != null) - calculate = false; - if (!calculate) - { - super.layoutLabel (tabPlacement, metrics, tabIndex, title, icon, - tabRect, iconRect, textRect, isSelected); - // System.out.println("1.tabRect=" + tabRect + " - textRect=" + textRect + " - " + title); - return; - } - // - textRect.x = textRect.y = iconRect.x = iconRect.y = 0; - SwingUtilities.layoutCompoundLabel(tabPane, - metrics, title, icon, - SwingUtilities.TOP, // vert - SwingUtilities.LEFT, // horiz - SwingUtilities.CENTER, // vert Text - SwingUtilities.TRAILING, // horiz Text - tabRect, - iconRect, - textRect, - textIconGap); - tabPane.putClientProperty("html", null); - int xNudge = getTabLabelShiftX(tabPlacement, tabIndex, isSelected); - int yNudge = getTabLabelShiftY(tabPlacement, tabIndex, isSelected); - // positioned top left - add gap - Insets tabInsetsLocal = getTabInsets(tabPlacement, tabIndex); - xNudge += tabInsetsLocal.left; - yNudge += tabInsetsLocal.top + 1; - iconRect.x += xNudge; - iconRect.y += yNudge; - textRect.x += xNudge; - textRect.y += yNudge; - // System.out.println("2.tabRect=" + tabRect + " - textRect=" + textRect + " - " + title); - } - - /** - * Paint Tab - * @param g graphics - * @param tabPlacement tab placement - * @param font font - * @param metrics font metrics - * @param tabIndex tab index - * @param title title - * @param textRect text bounds - * @param isSelected selected - */ - protected void paintText (Graphics g, int tabPlacement, - Font font, FontMetrics metrics, int tabIndex, - String title, Rectangle textRect, boolean isSelected) - { - boolean calculate = !(tabPlacement == TOP || tabPlacement == BOTTOM); - // HTML - if (getTextViewForTab(tabIndex) != null) - calculate = false; - if (!calculate) - { - super.paintText (g, tabPlacement, font, metrics, tabIndex, - title, textRect, isSelected); - return; - } - - // System.out.println("3.textRect " + textRect + " - " + title); - String firstLine = title; - String secondLine = null; - int pos = title.indexOf(' '); - if (pos != -1) - { - firstLine = title.substring(0, pos); - secondLine = title.substring(pos+1); - } - - g.setFont(font); - int mnemIndex = tabPane.getDisplayedMnemonicIndexAt(tabIndex); - if (tabPane.isEnabled() && tabPane.isEnabledAt(tabIndex)) - { - Color c = tabPane.getForegroundAt(tabIndex); - if (!isSelected) - { - if (c.equals(Color.black)) - c = Color.darkGray; - else - c = c.brighter(); - } - g.setColor(c); - // first line - BasicGraphicsUtils.drawStringUnderlineCharAt - (g, firstLine, mnemIndex, textRect.x, textRect.y + metrics.getAscent()); - // secondLine - if (secondLine != null) - BasicGraphicsUtils.drawStringUnderlineCharAt - (g, secondLine, mnemIndex-firstLine.length(), - textRect.x, textRect.y + metrics.getAscent() + metrics.getHeight()); - } - else - { // tab disabled - g.setColor(tabPane.getBackgroundAt(tabIndex).brighter()); - BasicGraphicsUtils.drawStringUnderlineCharAt - (g, firstLine, mnemIndex, textRect.x, textRect.y + metrics.getAscent()); - // secondLine - if (secondLine != null) - BasicGraphicsUtils.drawStringUnderlineCharAt - (g, secondLine, mnemIndex-firstLine.length(), - textRect.x, textRect.y + metrics.getAscent() + metrics.getHeight()); - // - g.setColor(tabPane.getBackgroundAt(tabIndex).darker()); - BasicGraphicsUtils.drawStringUnderlineCharAt - (g, firstLine, mnemIndex, textRect.x -1, textRect.y + metrics.getAscent() -1); - // secondLine - if (secondLine != null) - BasicGraphicsUtils.drawStringUnderlineCharAt - (g, secondLine, mnemIndex-firstLine.length(), - textRect.x -1, textRect.y + metrics.getAscent() + metrics.getHeight() -1); - } - } // paintText - - - /************************************************************************** - * Create Layout Manager to size & position tabs - * @return Layout Manager - */ - protected LayoutManager createLayoutManager() - { - return new TabbedPaneLayout(); - } // createLayoutManager - - /** - * Layout Manager to overwrite TabRect size - */ - public class TabbedPaneLayout extends MetalTabbedPaneUI.TabbedPaneLayout - { - /** - * Calculate Tab Rectangle Size - * @param tabPlacement tab placement - * @param tabCount no of tabs - */ - protected void calculateTabRects(int tabPlacement, int tabCount) - { - super.calculateTabRects(tabPlacement, tabCount); - if (tabPlacement == TOP || tabPlacement == BOTTOM) - return; - // System.out.println("calculateTabRects " + tabCount); - int tabHeight = calculateMaxTabHeight(tabPlacement); - for (int i = 0; i < rects.length; i++) - { - int level = 0; - Component comp = tabPane.getComponentAt(i); - if (comp instanceof JComponent) - { - JComponent jc = (JComponent)comp; - try - { - Integer ll = (Integer)jc.getClientProperty(CompiereLookAndFeel.TABLEVEL); - if (ll != null) - level = ll.intValue(); - } - catch (Exception e) - { - System.err.println("AdempiereTabbedPaneUI - ClientProperty: " + e.getMessage()); - } - } - if (level != 0) - { - if (tabPlacement == LEFT) - rects[i].x += level * 5; - rects[i].width -= level * 5; - } - // Height - rects[i].height = tabHeight; - if (i > 0) - rects[i].y = rects[i-1].y + tabHeight; // rects[i-1].height; - } // for all rects - } // calculate TabRects - - } // TabbedPaneLayout - -} // AdempiereTabbedPaneUI diff --git a/org.adempiere.ui.swing/src/org/compiere/plaf/CompiereTableHeaderUI.java b/org.adempiere.ui.swing/src/org/compiere/plaf/CompiereTableHeaderUI.java deleted file mode 100644 index d6c7097bb9..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/plaf/CompiereTableHeaderUI.java +++ /dev/null @@ -1,95 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ -package org.compiere.plaf; - -import java.awt.Graphics; -import java.awt.Graphics2D; - -import javax.swing.JComponent; -import javax.swing.plaf.ComponentUI; -import javax.swing.plaf.basic.BasicTableHeaderUI; - -/** - * Table Header UI - * 3D effect - * - * @author Jorg Janke - * @version $Id: AdempiereTableHeaderUI.java,v 1.2 2006/07/30 00:52:24 jjanke Exp $ - */ -public class CompiereTableHeaderUI extends BasicTableHeaderUI -{ - /** - * Static Create UI - * @param c Component - * @return Adempiere TableHeader UI - */ - public static ComponentUI createUI(JComponent c) - { - return new CompiereTableHeaderUI(); - } // createUI - - - /** - * Install UI - set not Opaque - * @param c - */ - public void installUI(JComponent c) - { - super.installUI(c); - // TableHeader is in JViewpoiunt, which is Opaque - // When UI created, TableHeader not added to viewpoint - //c.setOpaque(true); - //c.putClientProperty(AdempierePLAF.BACKGROUND_FILL, "Y"); - } // installUI - - - /************************************************************************** - * Update - - * This method is invoked by JComponent when the specified - * component is being painted. - * - * By default this method will fill the specified component with - * its background color (if its opaque property is - * true) and then immediately call paint. - * - * @param g the Graphics context in which to paint - * @param c the component being painted - * - * @see #paint - * @see javax.swing.JComponent#paintComponent - */ - public void update(Graphics g, JComponent c) - { - // AdempiereUtils.printParents (c); // Parent is JViewpoint - if (c.isOpaque()) // flat - CompiereUtils.fillRectange((Graphics2D)g, c, CompiereLookAndFeel.ROUND); - // - paint (g, c); - } // update - - /** - * Paint 3D box - * @param g - * @param c - */ - public void paint(Graphics g, JComponent c) - { - super.paint( g, c); - CompiereUtils.paint3Deffect((Graphics2D)g, c, CompiereLookAndFeel.ROUND, true); - } // paint - -} // AdempiereTableHeader diff --git a/org.adempiere.ui.swing/src/org/compiere/plaf/CompiereTextAreaUI.java b/org.adempiere.ui.swing/src/org/compiere/plaf/CompiereTextAreaUI.java deleted file mode 100644 index e3649cd9d8..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/plaf/CompiereTextAreaUI.java +++ /dev/null @@ -1,119 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ -package org.compiere.plaf; - -import java.awt.AWTKeyStroke; -import java.awt.KeyboardFocusManager; -import java.awt.event.ActionEvent; -import java.awt.event.KeyEvent; -import java.beans.PropertyChangeEvent; -import java.util.HashSet; -import java.util.Set; - -import javax.swing.Action; -import javax.swing.JComponent; -import javax.swing.KeyStroke; -import javax.swing.LookAndFeel; -import javax.swing.plaf.ComponentUI; -import javax.swing.plaf.basic.BasicTextAreaUI; -import javax.swing.text.DefaultEditorKit; -import javax.swing.text.EditorKit; -import javax.swing.text.JTextComponent; -import javax.swing.text.Keymap; - - -public class CompiereTextAreaUI extends BasicTextAreaUI -{ - /** - * Creates a UI for a JTextArea. - * Tab is the normal focus traversal key - to enter Tab enter Ctrl-Tab - * - * @param ta a text area - * @return the UI - */ - public static ComponentUI createUI(JComponent ta) - { - return new CompiereTextAreaUI(ta); - } - - /** - * Constructor - * @param ta text area - */ - public CompiereTextAreaUI (JComponent ta) - { - if (ta instanceof JTextComponent) - m_editor = (JTextComponent)ta; - } // AdempiereTextAreaUI - - /** The Editor */ - private JTextComponent m_editor = null; - /** Tab Stroke */ - private static KeyStroke s_stroke = KeyStroke.getKeyStroke (KeyEvent.VK_TAB, ActionEvent.CTRL_MASK); - /** Tab Action */ - private static Action s_action = new DefaultEditorKit.InsertTabAction(); - - /** - * Create Keymap - * @return key Map - */ - protected Keymap createKeymap () - { - Keymap map = super.createKeymap (); - map.addActionForKeyStroke(s_stroke, s_action); - return map; - } // createKeyMap - - /** - * Property Change - * @param evt event - */ - protected void propertyChange (PropertyChangeEvent evt) - { - String name = evt.getPropertyName(); - if ("editable".equals(name)) - updateFocusTraversalKeysX(); - else - super.propertyChange (evt); - } // propertyChange - - /** - * UpdateFocusTraversalKeysX - */ - void updateFocusTraversalKeysX () - { - if (m_editor == null) - return; - // - EditorKit editorKit = getEditorKit (m_editor); - if (editorKit != null && editorKit instanceof DefaultEditorKit) - { - Set storedForwardTraversalKeys = m_editor.getFocusTraversalKeys (KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS); - Set storedBackwardTraversalKeys = m_editor.getFocusTraversalKeys (KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS); - Set forwardTraversalKeys = new HashSet(storedForwardTraversalKeys); - Set backwardTraversalKeys = new HashSet(storedBackwardTraversalKeys); - // - forwardTraversalKeys.add (KeyStroke.getKeyStroke (KeyEvent.VK_TAB, 0)); - forwardTraversalKeys.remove(s_stroke); - backwardTraversalKeys.add (KeyStroke.getKeyStroke (KeyEvent.VK_TAB, ActionEvent.SHIFT_MASK)); - // - LookAndFeel.installProperty (m_editor, "focusTraversalKeysForward", forwardTraversalKeys); - LookAndFeel.installProperty (m_editor, "focusTraversalKeysBackward", backwardTraversalKeys); - } - } // updateFocusTraversalKeysX - -} // AdempiereTextAreaUI diff --git a/org.adempiere.ui.swing/src/org/compiere/plaf/CompiereTheme.java b/org.adempiere.ui.swing/src/org/compiere/plaf/CompiereTheme.java deleted file mode 100644 index 246d9fe451..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/plaf/CompiereTheme.java +++ /dev/null @@ -1,343 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ -package org.compiere.plaf; - -import java.awt.Font; -import java.util.logging.Logger; - -import javax.swing.UIDefaults; -import javax.swing.plaf.ColorUIResource; -import javax.swing.plaf.FontUIResource; -import javax.swing.plaf.metal.MetalTheme; - -import org.compiere.swing.ColorBlind; -import org.compiere.swing.ExtendedTheme; - -/** - * Compiere User definable Theme (if used in Metal L&F). - * In other Environments, it provides UI extensions (e.g. Error Color) - * - * @author Jorg Janke - * @version $Id: AdempiereTheme.java,v 1.4 2006/07/30 00:52:23 jjanke Exp $ - */ -public class CompiereTheme extends MetalTheme -{ - /** - * Constructor - nop - */ - public CompiereTheme() - { - } // AdempiereTheme - - /** - * Return Theme Name - * @return Theme Name - */ - public String getName() - { - return s_name; - } // getName - - /** - * String Representation - * @return info - */ - public String toString () - { - return s_name; - } // toString - - /** - * Set Default Colors - */ - protected void setDefault() - { - } // setDefault - - /** Static Initializer */ - static - { - s_theme = new CompiereThemeBlueMetal(); - } - - /** Theme Name */ - protected static String s_name = "Compiere Theme"; - /** Logger */ - protected static Logger log = Logger.getLogger(CompiereTheme.class.getName()); - /** Active Theme */ - protected static CompiereTheme s_theme = null; - - /** Blue 51,51,102 */ - protected static ColorUIResource primary0 = new ColorUIResource(51, 51, 102); - /** Blue 102, 102, 153 */ - protected static ColorUIResource primary1; - /** Blue 153, 153, 204 */ - protected static ColorUIResource primary2; - /** Blue 204, 204, 255 */ - protected static ColorUIResource primary3; - - /** Black */ - protected final ColorUIResource secondary0 = new ColorUIResource(0, 0, 0); - /** Gray 102, 102, 102 */ - protected static ColorUIResource secondary1; - /** Gray 153, 153, 153 */ - protected static ColorUIResource secondary2; - /** BlueGray 214, 224, 234 - background */ - protected static ColorUIResource secondary3; - /** White */ - protected final ColorUIResource secondary4 = new ColorUIResource(255, 255, 255); - - /** Black */ - protected static ColorUIResource black; - /** White */ - protected static ColorUIResource white; - - /** Background for mandatory fields */ - protected static ColorUIResource mandatory; - /** Background for fields in error */ - protected static ColorUIResource error; - /** Background for inactive fields */ - protected static ColorUIResource inactive; - /** Background for info fields */ - protected static ColorUIResource info; - - /** Foreground Text OK */ - protected static ColorUIResource txt_ok; - /** Foreground Text Error */ - protected static ColorUIResource txt_error; - - /** Control font */ - protected static FontUIResource controlFont; - /** System font */ - protected static FontUIResource systemFont; - /** User font */ - protected static FontUIResource userFont; - /** Small font */ - protected static FontUIResource smallFont; - /** Window Title font */ - protected static FontUIResource windowFont; - /** Menu font */ - protected static FontUIResource menuFont; - - /** Default Font */ - public static final String FONT_DEFAULT = "Dialog"; - /** Default Font Size */ - public static final int FONT_SIZE = 12; - - - /************************************************************************** - * Get Primary 1 (blue in default Metal Theme) - * @return color - */ - public ColorUIResource getPrimary1() - { - return ColorBlind.getDichromatColorUIResource(primary1); - } - public ColorUIResource getPrimary2() - { - return ColorBlind.getDichromatColorUIResource(primary2); - } - public ColorUIResource getPrimary3() - { - return ColorBlind.getDichromatColorUIResource(primary3); - } - - /** - * Get Seconary 1 (gray in default Metal Theme) - * @return color - */ - public ColorUIResource getSecondary0() - { - return ColorBlind.getDichromatColorUIResource(secondary0); - } - public ColorUIResource getSecondary1() - { - return ColorBlind.getDichromatColorUIResource(secondary1); - } - public ColorUIResource getSecondary2() - { - return ColorBlind.getDichromatColorUIResource(secondary2); - } - public ColorUIResource getSecondary3() - { - return ColorBlind.getDichromatColorUIResource(secondary3); - } - public ColorUIResource getSecondary4() - { - return ColorBlind.getDichromatColorUIResource(secondary4); - } - - public ColorUIResource getBlack() - { - return ColorBlind.getDichromatColorUIResource(black); - } - public ColorUIResource getWhite() - { - return ColorBlind.getDichromatColorUIResource(white); - } - - /** - * Control Font (plain) - * @return font - */ - protected static FontUIResource _getControlTextFont() - { - if (controlFont == null) - { - try - { - controlFont = new FontUIResource(Font.getFont("swing.plaf.metal.controlFont", - new Font(FONT_DEFAULT, Font.PLAIN, FONT_SIZE))); - } - catch (Exception e) - { - controlFont = new FontUIResource(FONT_DEFAULT, Font.PLAIN, FONT_SIZE); - } - } - return controlFont; - } - public FontUIResource getControlTextFont() {return _getControlTextFont();} - - /** - * System Font - * @return font - */ - protected static FontUIResource _getSystemTextFont() - { - if (systemFont == null) - { - try - { - systemFont = new FontUIResource(Font.getFont("swing.plaf.metal.systemFont", - new Font(FONT_DEFAULT, Font.PLAIN, FONT_SIZE))); - } - catch (Exception e) - { - systemFont = new FontUIResource(FONT_DEFAULT, Font.PLAIN, FONT_SIZE); - } - } - return systemFont; - } - public FontUIResource getSystemTextFont() {return _getSystemTextFont();} - - /** - * User Font - * @return font - */ - protected static FontUIResource _getUserTextFont() - { - if (userFont == null) - { - try - { - userFont = new FontUIResource(Font.getFont("swing.plaf.metal.userFont", - new Font(FONT_DEFAULT, Font.PLAIN, FONT_SIZE))); - } - catch (Exception e) - { - userFont = new FontUIResource(FONT_DEFAULT, Font.PLAIN, FONT_SIZE); - } - } - return userFont; - } - public FontUIResource getUserTextFont() {return _getUserTextFont();} - - /** - * Menu - * @return font - */ - protected static FontUIResource _getMenuTextFont() - { - if (menuFont == null) - { - try - { - menuFont = new FontUIResource(Font.getFont("swing.plaf.metal.menuFont", - new Font(FONT_DEFAULT, Font.PLAIN, FONT_SIZE))); - } - catch (Exception e) - { - menuFont = new FontUIResource(FONT_DEFAULT, Font.PLAIN, FONT_SIZE); - } - } - return menuFont; - } - public FontUIResource getMenuTextFont() {return _getMenuTextFont();} - - /** - * Window Title - * @return font - */ - protected static FontUIResource _getWindowTitleFont() - { - if (windowFont == null) - { - try - { - windowFont = new FontUIResource(Font.getFont("swing.plaf.metal.windowFont", - new Font(FONT_DEFAULT, Font.BOLD, FONT_SIZE+2))); - } - catch (Exception e) - { - windowFont = new FontUIResource(FONT_DEFAULT, Font.BOLD, FONT_SIZE+2); - } - } - return windowFont; - } - public FontUIResource getWindowTitleFont() {return _getWindowTitleFont();} - - /** - * Sub Text - * @return font - */ - protected static FontUIResource _getSubTextFont() - { - if (smallFont == null) - { - try - { - smallFont = new FontUIResource(Font.getFont("swing.plaf.metal.smallFont", - new Font(FONT_DEFAULT, Font.PLAIN, FONT_SIZE-2))); - } - catch (Exception e) - { - smallFont = new FontUIResource(FONT_DEFAULT, Font.PLAIN, FONT_SIZE-2); - } - } - return smallFont; - } - public FontUIResource getSubTextFont() {return _getSubTextFont();} - - @Override - public void addCustomEntriesToTable(UIDefaults table) { - super.addCustomEntriesToTable(table); - Object[] defaults = - { - ExtendedTheme.ERROR_BG_KEY, - error, - ExtendedTheme.ERROR_FG_KEY, - txt_error, - ExtendedTheme.INACTIVE_BG_KEY, - inactive, - ExtendedTheme.INFO_BG_KEY, - info, - ExtendedTheme.MANDATORY_BG_KEY, - mandatory - }; - table.putDefaults(defaults); - } -} // AdempiereTheme diff --git a/org.adempiere.ui.swing/src/org/compiere/plaf/CompiereThemeBlueMetal.java b/org.adempiere.ui.swing/src/org/compiere/plaf/CompiereThemeBlueMetal.java deleted file mode 100644 index 5652ba899d..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/plaf/CompiereThemeBlueMetal.java +++ /dev/null @@ -1,101 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ -package org.compiere.plaf; - -import java.awt.Color; - -import javax.swing.plaf.ColorUIResource; - -/** - * Adempiere default Blue Metal Color Theme - * - * @author Jorg Janke, Adam Michau - * @version $Id: AdempiereThemeBlueMetal.java,v 1.2 2006/07/30 00:52:24 jjanke Exp $ - */ -public class CompiereThemeBlueMetal extends CompiereTheme -{ - /** - * Adempiere default Theme Blue Metal - */ - public CompiereThemeBlueMetal() - { - setDefault(); - s_theme = this; - s_name = NAME; - } // AdempiereThemeBlueMetal - - /** Name */ - public static final String NAME = "Compiere Theme"; - - /** - * Set Defaults - */ - protected void setDefault() - { - /** Blue 102, 102, 153 */ - primary1 = new ColorUIResource(102, 102, 153); - /** Blue 153, 153, 204 */ - primary2 = new ColorUIResource(153, 153, 204); - /** Blue 204, 204, 255 */ - primary3 = new ColorUIResource(204, 204, 255); - /** Gray 102, 102, 102 */ - secondary1 = new ColorUIResource(102, 102, 102); - /** Gray 153, 153, 153 */ - secondary2 = new ColorUIResource(153, 153, 153); - /** BlueGray 214, 224, 234 - background */ - secondary3 = new ColorUIResource(205, 215, 231); - - /** Black */ - black = new ColorUIResource(Color.black); - /** White */ - white = new ColorUIResource(Color.white); - - /** Background for mandatory fields */ - mandatory = new ColorUIResource(224, 224, 255); // blue-isch - /** Background for fields in error */ - error = new ColorUIResource(255, 204, 204); // red-isch - /** Background for inactive fields */ - inactive = new ColorUIResource(234, 234, 234); // light gray - /** Background for info fields */ - info = new ColorUIResource(253, 237, 207); // light yellow - - /** Foreground Text OK */ - txt_ok = new ColorUIResource(51, 51, 102); // dark blue - /** Foreground Text Error */ - txt_error = new ColorUIResource(204, 0, 0); // dark red - - /** Control font */ - controlFont = null; - _getControlTextFont(); - /** System font */ - systemFont = null; - _getSystemTextFont(); - /** User font */ - userFont = null; - _getUserTextFont(); - /** Small font */ - smallFont = null; - _getSubTextFont(); - /** Window Title font */ - windowFont = null; - _getWindowTitleFont(); - /** Menu font */ - menuFont = null; - _getMenuTextFont(); - } // setDefault - -} // AdempiereThemeBlueMetal diff --git a/org.adempiere.ui.swing/src/org/compiere/plaf/CompiereThemeEditor.java b/org.adempiere.ui.swing/src/org/compiere/plaf/CompiereThemeEditor.java deleted file mode 100644 index 104ee2440a..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/plaf/CompiereThemeEditor.java +++ /dev/null @@ -1,431 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ -package org.compiere.plaf; - -import java.awt.BorderLayout; -import java.awt.FlowLayout; -import java.awt.GridLayout; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.util.ResourceBundle; - -import javax.swing.JColorChooser; -import javax.swing.JDialog; -import javax.swing.UIManager; -import javax.swing.border.TitledBorder; -import javax.swing.plaf.ColorUIResource; -import javax.swing.plaf.FontUIResource; -import javax.swing.plaf.metal.MetalLookAndFeel; - -import org.adempiere.plaf.AdempierePLAF; -import org.compiere.swing.CButton; -import org.compiere.swing.CDialog; -import org.compiere.swing.CPanel; -import org.compiere.swing.FontChooser; - -/** - * Java Theme Editor. - * Edit the attributes and save them in Ini.properties. - * Does not set background of AdempiereColorUI. - * - * @author Jorg Janke - * @version $Id: AdempiereThemeEditor.java,v 1.3 2006/07/30 00:52:24 jjanke Exp $ - */ -public class CompiereThemeEditor extends CDialog - implements ActionListener -{ - /** - * - */ - private static final long serialVersionUID = 6865599987532875192L; - - /** - * Constructor - * @param owner Frame owner - */ - public CompiereThemeEditor (JDialog owner) - { - super(owner, s_res.getString("AdempiereThemeEditor"), true); - try - { - jbInit(); - loadTheme(); - dynInit(); - AdempierePLAF.showCenterScreen(this); - } - catch(Exception e) - { - System.err.println("AdempiereThemeEditor"); - e.printStackTrace(); - } - } // AdempiereThemeEditor - - static ResourceBundle s_res = ResourceBundle.getBundle("org.compiere.plaf.PlafRes"); - - private CButton primary1 = new CButton(); - private CButton primary2 = new CButton(); - private CButton primary3 = new CButton(); - private CButton secondary1 = new CButton(); - private CButton secondary2 = new CButton(); - private CButton secondary3 = new CButton(); - private CButton controlFont = new CButton(); - private CButton systemFont = new CButton(); - private CButton userFont = new CButton(); - private CButton smallFont = new CButton(); - private CButton mandatory = new CButton(); - private CButton error = new CButton(); - private CButton windowFont = new CButton(); - private CButton menuFont = new CButton(); - private CButton white = new CButton(); - private CButton black = new CButton(); - private CPanel confirmPanel = new CPanel(); - - private CButton inactive = new CButton(); - private CButton txt_ok = new CButton(); - private CButton txt_error = new CButton(); - private CButton bCancel = AdempierePLAF.getCancelButton(); - private CButton bOK = AdempierePLAF.getOKButton(); - private FlowLayout confirmLayout = new FlowLayout(); - private CPanel centerPanel = new CPanel(); - private CPanel metalColorPanel = new CPanel(); - private BorderLayout centerLayout = new BorderLayout(); - private CPanel adempiereColorPanel = new CPanel(); - private TitledBorder metalColorBorder; - private TitledBorder adempiereColorBorder; - private GridLayout metalColorLayout = new GridLayout(); - private GridLayout adempiereColorLayout = new GridLayout(); - private CPanel fontPanel = new CPanel(); - private GridLayout fontLayout = new GridLayout(); - private TitledBorder fontBorder; - private CButton info = new CButton(); - - /** - * Static Init - * @throws Exception - */ - private void jbInit() throws Exception - { - metalColorBorder = new TitledBorder(s_res.getString("MetalColors")); - adempiereColorBorder = new TitledBorder(s_res.getString("AdempiereColors")); - fontBorder = new TitledBorder(s_res.getString("AdempiereFonts")); - fontPanel.setBorder(fontBorder); - fontPanel.setOpaque(false); - - this.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE); - // - primary1.setToolTipText(s_res.getString("Primary1Info")); - primary1.setText(s_res.getString("Primary1")); - primary1.addActionListener(this); - primary2.setToolTipText(s_res.getString("Primary2Info")); - primary2.setText(s_res.getString("Primary2")); - primary2.addActionListener(this); - primary3.setToolTipText(s_res.getString("Primary3Info")); - primary3.setText(s_res.getString("Primary3")); - primary3.addActionListener(this); - secondary1.setToolTipText(s_res.getString("Secondary1Info")); - secondary1.setText(s_res.getString("Secondary1")); - secondary1.addActionListener(this); - secondary2.setToolTipText(s_res.getString("Secondary2Info")); - secondary2.setText(s_res.getString("Secondary2")); - secondary2.addActionListener(this); - secondary3.setToolTipText(s_res.getString("Secondary3Info")); - secondary3.setText(s_res.getString("Secondary3")); - secondary3.addActionListener(this); - controlFont.setToolTipText(s_res.getString("ControlFontInfo")); - controlFont.setText(s_res.getString("ControlFont")); - controlFont.addActionListener(this); - systemFont.setToolTipText(s_res.getString("SystemFontInfo")); - systemFont.setText(s_res.getString("SystemFont")); - systemFont.addActionListener(this); - userFont.setToolTipText(s_res.getString("UserFontInfo")); - userFont.setText(s_res.getString("UserFont")); - userFont.addActionListener(this); - smallFont.setText(s_res.getString("SmallFont")); - smallFont.addActionListener(this); - mandatory.setToolTipText(s_res.getString("MandatoryInfo")); - mandatory.setText(s_res.getString("Mandatory")); - mandatory.addActionListener(this); - error.setToolTipText(s_res.getString("ErrorInfo")); - error.setText(s_res.getString("Error")); - error.addActionListener(this); - info.setToolTipText(s_res.getString("InfoInfo")); - info.setText(s_res.getString("Info")); - info.addActionListener(this); - windowFont.setText(s_res.getString("WindowTitleFont")); - windowFont.addActionListener(this); - menuFont.setText(s_res.getString("MenuFont")); - menuFont.addActionListener(this); - white.setToolTipText(s_res.getString("WhiteInfo")); - white.setText(s_res.getString("White")); - white.addActionListener(this); - black.setToolTipText(s_res.getString("BlackInfo")); - black.setText(s_res.getString("Black")); - black.addActionListener(this); - inactive.setToolTipText(s_res.getString("InactiveInfo")); - inactive.setText(s_res.getString("Inactive")); - inactive.addActionListener(this); - txt_ok.setToolTipText(s_res.getString("TextOKInfo")); - txt_ok.setText(s_res.getString("TextOK")); - txt_ok.addActionListener(this); - txt_error.setToolTipText(s_res.getString("TextIssueInfo")); - txt_error.setText(s_res.getString("TextIssue")); - txt_error.addActionListener(this); - // - confirmPanel.setLayout(confirmLayout); - confirmLayout.setAlignment(FlowLayout.RIGHT); - centerPanel.setLayout(centerLayout); - metalColorPanel.setBorder(metalColorBorder); - metalColorPanel.setOpaque(false); - metalColorPanel.setLayout(metalColorLayout); - adempiereColorPanel.setLayout(adempiereColorLayout); - adempiereColorPanel.setBorder(adempiereColorBorder); - adempiereColorPanel.setOpaque(false); - metalColorLayout.setColumns(3); - metalColorLayout.setHgap(5); - metalColorLayout.setRows(3); - metalColorLayout.setVgap(5); - adempiereColorLayout.setColumns(4); - adempiereColorLayout.setHgap(5); - adempiereColorLayout.setRows(2); - adempiereColorLayout.setVgap(5); - fontPanel.setLayout(fontLayout); - fontLayout.setColumns(3); - fontLayout.setHgap(5); - fontLayout.setRows(2); - fontLayout.setVgap(5); - centerLayout.setVgap(5); - fontBorder.setTitle(s_res.getString("Fonts")); - confirmPanel.setOpaque(false); - this.getContentPane().add(confirmPanel, BorderLayout.SOUTH); - confirmPanel.add(bCancel, null); - confirmPanel.add(bOK, null); - this.getContentPane().add(centerPanel, BorderLayout.CENTER); - centerPanel.add(metalColorPanel, BorderLayout.NORTH); - metalColorPanel.add(primary1, null); - metalColorPanel.add(primary2, null); - metalColorPanel.add(primary3, null); - metalColorPanel.add(secondary1, null); - metalColorPanel.add(secondary2, null); - metalColorPanel.add(secondary3, null); - metalColorPanel.add(white, null); - metalColorPanel.add(black, null); - centerPanel.add(adempiereColorPanel, BorderLayout.CENTER); - adempiereColorPanel.add(txt_error, null); - centerPanel.add(fontPanel, BorderLayout.SOUTH); - fontPanel.add(controlFont, null); - fontPanel.add(systemFont, null); - fontPanel.add(menuFont, null); - fontPanel.add(userFont, null); - fontPanel.add(windowFont, null); - fontPanel.add(smallFont, null); - adempiereColorPanel.add(error, null); - adempiereColorPanel.add(inactive, null); - adempiereColorPanel.add(txt_ok, null); - adempiereColorPanel.add(mandatory, null); - adempiereColorPanel.add(info, null); - bCancel.addActionListener(this); - bOK.addActionListener(this); - } // jbInit - - /** - * Load Theme from current Setting (if MetalLookAndFeel) - */ - private void loadTheme() - { - if (UIManager.getLookAndFeel() instanceof MetalLookAndFeel) - { - // AdempiereTheme.setTheme(); - } - else // Not a Metal Theme - { - primary1.setEnabled(false); - primary2.setEnabled(false); - primary3.setEnabled(false); - secondary1.setEnabled(false); - secondary2.setEnabled(false); - secondary3.setEnabled(false); - } - } // loadTheme - - /** - * Dynamic Init - */ - private void dynInit() - { - // Colors - primary1.setBackground(CompiereTheme.primary1); - primary2.setBackground(CompiereTheme.primary2); - primary3.setBackground(CompiereTheme.primary3); - secondary1.setBackground(CompiereTheme.secondary1); - secondary2.setBackground(CompiereTheme.secondary2); - secondary3.setBackground(CompiereTheme.secondary3); - // - white.setBackground(CompiereTheme.white); - black.setBackground(CompiereTheme.secondary3); - black.setForeground(CompiereTheme.black); - // - error.setBackground(CompiereTheme.error); - mandatory.setBackground(CompiereTheme.mandatory); - inactive.setBackground(CompiereTheme.inactive); - info.setBackground(CompiereTheme.info); - // - txt_ok.setBackground(CompiereTheme.white); - txt_ok.setForeground(CompiereTheme.txt_ok); - txt_error.setBackground(CompiereTheme.white); // AdempierePLAF.getFieldBackground_Normal() - txt_error.setForeground(CompiereTheme.txt_error); - - // Fonts - controlFont.setFont(CompiereTheme.controlFont); - systemFont.setFont(CompiereTheme.systemFont); - userFont.setFont(CompiereTheme.userFont); - smallFont.setFont(CompiereTheme.smallFont); - menuFont.setFont(CompiereTheme.menuFont); - windowFont.setFont(CompiereTheme.windowFont); - } // dynInit - - /** - * Action Listener - * @param e - */ - public void actionPerformed(ActionEvent e) - { - // Confirm - if (e.getSource() == bOK) - { - //CompiereTheme.saveEx(); - dispose(); - return; - } - // Cancel - else if (e.getSource() == bCancel) - { - dispose(); - return; - } - - try { // to capture errors when Cancel in JColorChooser - - if (e.getSource() == primary1) - { - CompiereTheme.primary1 = new ColorUIResource(JColorChooser.showDialog - (this, s_res.getString("Primary1"), CompiereTheme.primary1)); - } - else if (e.getSource() == primary2) - { - CompiereTheme.primary2 = new ColorUIResource(JColorChooser.showDialog - (this, s_res.getString("Primary2"), CompiereTheme.primary2)); - } - else if (e.getSource() == primary3) - { - CompiereTheme.primary3 = new ColorUIResource(JColorChooser.showDialog - (this, s_res.getString("Primary3"), CompiereTheme.primary3)); - } - else if (e.getSource() == secondary1) - { - CompiereTheme.secondary1 = new ColorUIResource(JColorChooser.showDialog - (this, s_res.getString("Secondary1"), CompiereTheme.secondary1)); - } - else if (e.getSource() == secondary2) - { - CompiereTheme.secondary2 = new ColorUIResource(JColorChooser.showDialog - (this, s_res.getString("Secondary2"), CompiereTheme.secondary2)); - } - else if (e.getSource() == secondary3) - { - CompiereTheme.secondary3 = new ColorUIResource(JColorChooser.showDialog - (this, s_res.getString("Secondary3"), CompiereTheme.secondary3)); - } - - else if (e.getSource() == error) - { - CompiereTheme.error = new ColorUIResource(JColorChooser.showDialog - (this, s_res.getString("Error"), CompiereTheme.error)); - } - else if (e.getSource() == mandatory) - { - CompiereTheme.mandatory = new ColorUIResource(JColorChooser.showDialog - (this, s_res.getString("Mandatory"), CompiereTheme.mandatory)); - } - else if (e.getSource() == inactive) - { - CompiereTheme.inactive = new ColorUIResource(JColorChooser.showDialog - (this, s_res.getString("Inactive"), CompiereTheme.inactive)); - } - else if (e.getSource() == info) - { - CompiereTheme.info = new ColorUIResource(JColorChooser.showDialog - (this, s_res.getString("Info"), CompiereTheme.info)); - } - - else if (e.getSource() == black) - { - CompiereTheme.black = new ColorUIResource(JColorChooser.showDialog - (this, s_res.getString("Black"), CompiereTheme.black)); - } - else if (e.getSource() == white) - { - CompiereTheme.white = new ColorUIResource(JColorChooser.showDialog - (this, s_res.getString("White"), CompiereTheme.white)); - } - else if (e.getSource() == txt_ok) - { - CompiereTheme.txt_ok = new ColorUIResource(JColorChooser.showDialog - (this, s_res.getString("TextOK"), CompiereTheme.txt_ok)); - } - else if (e.getSource() == txt_error) - { - CompiereTheme.txt_error = new ColorUIResource(JColorChooser.showDialog - (this, s_res.getString("TextIssue"), CompiereTheme.txt_error)); - } - - else if (e.getSource() == controlFont) - { - CompiereTheme.controlFont = new FontUIResource(FontChooser.showDialog - (this, s_res.getString("ControlFont"), CompiereTheme.controlFont)); - } - else if (e.getSource() == systemFont) - { - CompiereTheme.systemFont = new FontUIResource(FontChooser.showDialog - (this, s_res.getString("SystemFont"), CompiereTheme.systemFont)); - } - else if (e.getSource() == userFont) - { - CompiereTheme.userFont = new FontUIResource(FontChooser.showDialog - (this, s_res.getString("UserFont"), CompiereTheme.userFont)); - } - else if (e.getSource() == smallFont) - { - CompiereTheme.smallFont = new FontUIResource(FontChooser.showDialog - (this, s_res.getString("SmallFont"), CompiereTheme.smallFont)); - } - else if (e.getSource() == menuFont) - { - CompiereTheme.menuFont = new FontUIResource(FontChooser.showDialog - (this, s_res.getString("MenuFont"), CompiereTheme.menuFont)); - } - else if (e.getSource() == windowFont) - { - CompiereTheme.windowFont = new FontUIResource(FontChooser.showDialog - (this, s_res.getString("WindowTitleFont"), CompiereTheme.windowFont)); - } - - } catch (Exception ee) {} // to capture errors when Cancel in JColorChooser - - dynInit(); - } // actionPerformed - -} // AdempiereThemeEditor diff --git a/org.adempiere.ui.swing/src/org/compiere/plaf/CompiereThemeIce.java b/org.adempiere.ui.swing/src/org/compiere/plaf/CompiereThemeIce.java deleted file mode 100644 index 134bab80aa..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/plaf/CompiereThemeIce.java +++ /dev/null @@ -1,101 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ -package org.compiere.plaf; - -import java.awt.Color; - -import javax.swing.plaf.ColorUIResource; - -/** - * Adempiere Theme Ice - * - * @author Jorg Janke, Adam Michau - * @version $Id: AdempiereThemeIce.java,v 1.2 2006/07/30 00:52:24 jjanke Exp $ - */ -public class CompiereThemeIce extends CompiereTheme -{ - /** - * Adempiere Theme: Ice - */ - public CompiereThemeIce () - { - setDefault(); - s_theme = this; - s_name = NAME; - } // AdempiereThemeBlueMetal - - /** Name */ - public static final String NAME = "Compiere Ice"; - - /** - * Set Defaults - */ - protected void setDefault() - { - /** Blue 102, 102, 153 */ - primary1 = new ColorUIResource(210, 226, 239); - /** Blue 153, 153, 204 */ - primary2 = new ColorUIResource(233, 240, 248); - /** Blue 204, 204, 255 */ - primary3 = new ColorUIResource(167, 198, 227); - /** Gray 102, 102, 102 */ - secondary1 = new ColorUIResource(102, 102, 102); - /** Gray 153, 153, 153 */ - secondary2 = new ColorUIResource(153, 153, 153); - /** BlueGray 214, 224, 234 - background */ - secondary3 = new ColorUIResource(210, 226, 239); - - /** Black */ - black = new ColorUIResource(Color.black); - /** White */ - white = new ColorUIResource(Color.white); - - /** Background for mandatory fields */ - mandatory = new ColorUIResource(224, 224, 255); // blue-isch - /** Background for fields in error */ - error = new ColorUIResource(255, 204, 204); // red-isch - /** Background for inactive fields */ - inactive = new ColorUIResource(234, 234, 234); // light gray - /** Background for info fields */ - info = new ColorUIResource(253, 237, 207); // light yellow - - /** Foreground Text OK */ - txt_ok = new ColorUIResource(51, 51, 102); // dark blue - /** Foreground Text Error */ - txt_error = new ColorUIResource(204, 0, 0); // dark red - - /** Control font */ - controlFont = null; - _getControlTextFont(); - /** System font */ - systemFont = null; - _getSystemTextFont(); - /** User font */ - userFont = null; - _getUserTextFont(); - /** Small font */ - smallFont = null; - _getSubTextFont(); - /** Window Title font */ - windowFont = null; - _getWindowTitleFont(); - /** Menu font */ - menuFont = null; - _getMenuTextFont(); - } // setDefault - -} // AdempiereThemeIce diff --git a/org.adempiere.ui.swing/src/org/compiere/plaf/CompiereToggleButtonUI.java b/org.adempiere.ui.swing/src/org/compiere/plaf/CompiereToggleButtonUI.java deleted file mode 100644 index 1a53cac058..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/plaf/CompiereToggleButtonUI.java +++ /dev/null @@ -1,113 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ -package org.compiere.plaf; - -import java.awt.Graphics; -import java.awt.Graphics2D; - -import javax.swing.AbstractButton; -import javax.swing.ButtonModel; -import javax.swing.JComponent; -import javax.swing.plaf.ComponentUI; -import javax.swing.plaf.metal.MetalToggleButtonUI; - -/** - * Adempiere Toggle Button UI - * - * @author Jorg Janke - * @version $Id: AdempiereToggleButtonUI.java,v 1.2 2006/07/30 00:52:24 jjanke Exp $ - */ -public class CompiereToggleButtonUI extends MetalToggleButtonUI -{ - /** - * Static Create UI - * @param c Component - * @return Adempiere ToggleButton UI - */ - public static ComponentUI createUI (JComponent c) - { - return s_toggleButtonUI; - } // createUI - - /** UI shared */ - private static CompiereToggleButtonUI s_toggleButtonUI = new CompiereToggleButtonUI(); - - - /************************************************************************** - * Install Defaults - * @param b - */ - public void installDefaults(AbstractButton b) - { - super.installDefaults(b); - b.setOpaque(false); - } // installDefaults - - /** - * Update - - * This method is invoked by JComponent when the specified - * component is being painted. - * - * By default this method will fill the specified component with - * its background color (if its opaque property is - * true) and then immediately call paint. - * - * @param g the Graphics context in which to paint - * @param c the component being painted - * - * @see #paint - * @see javax.swing.JComponent#paintComponent - */ - public void update(Graphics g, JComponent c) - { - if (c.isOpaque()) // flat background - // AdempiereColor.getDefaultBackground().paint(g, c); - CompiereUtils.fillRectange((Graphics2D)g, c, CompiereLookAndFeel.ROUND); - paint (g, c); - } // update - - /** - * Paint 3D Box - * @param g Graphics - * @param c Component - */ - public void paint(Graphics g, JComponent c) - { - super.paint(g, c); - AbstractButton b = (AbstractButton) c; - ButtonModel model = b.getModel(); - boolean in = model.isPressed() || model.isSelected(); - // - CompiereUtils.paint3Deffect((Graphics2D)g, c, CompiereLookAndFeel.ROUND, !in); - } // paint - - /** - * Don't get selected Color - use default (otherwise the pressed button is gray) - * @param g - * @param b - */ - protected void paintButtonPressed(Graphics g, AbstractButton b) - { - // if (b.isContentAreaFilled()) - // { - // Dimension size = b.getSize(); - // g.setColor(getSelectColor()); - // g.fillRect(0, 0, size.width, size.height); - // } - } // paintButtonPressed - -} // AdempiereToggleButton diff --git a/org.adempiere.ui.swing/src/org/compiere/plaf/CompiereToolBarUI.java b/org.adempiere.ui.swing/src/org/compiere/plaf/CompiereToolBarUI.java deleted file mode 100644 index cfe262aa5c..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/plaf/CompiereToolBarUI.java +++ /dev/null @@ -1,60 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ -package org.compiere.plaf; - -import javax.swing.JComponent; -import javax.swing.plaf.ComponentUI; -import javax.swing.plaf.metal.MetalToolBarUI; - -/** - * Adempiere Tool Bar - * - * @author Jorg Janke - * @version $Id: AdempiereToolBarUI.java,v 1.2 2006/07/30 00:52:24 jjanke Exp $ - */ -public class CompiereToolBarUI extends MetalToolBarUI -{ - /** - * Create UI (own instance) - * @param c - * @return AdempiereToolBarUI - */ - public static ComponentUI createUI (JComponent c) - { - return new CompiereToolBarUI(); - } // createUI - - - /** - * Install UI - not Opaque - * @param c - */ - public void installUI( JComponent c ) - { - super.installUI (c); - c.setOpaque(false); - } // installUI - - /** - * JToolbar error : I just instanciate and display a toolbar - * in the AWT dispatcher thread. When the toolbar is repaint - * with a SwingUtilities.updateTreeView, buttons are larger - * than usual. Note that I have several toolbars - * == paint is done by Metal, so error is there == - */ - -} // AdempiereToolBarUI diff --git a/org.adempiere.ui.swing/src/org/compiere/plaf/CompiereToolTipUI.java b/org.adempiere.ui.swing/src/org/compiere/plaf/CompiereToolTipUI.java deleted file mode 100644 index a8bb4d214a..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/plaf/CompiereToolTipUI.java +++ /dev/null @@ -1,96 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ -package org.compiere.plaf; - -import java.awt.Dimension; -import java.awt.Graphics; -import java.awt.event.KeyEvent; - -import javax.swing.JComponent; -import javax.swing.JMenuItem; -import javax.swing.JTabbedPane; -import javax.swing.JToolTip; -import javax.swing.KeyStroke; -import javax.swing.plaf.ComponentUI; -import javax.swing.plaf.metal.MetalToolTipUI; - -/** - * Tool Tip - * - * @author Jorg Janke - * @version $Id: AdempiereToolTipUI.java,v 1.2 2006/07/30 00:52:24 jjanke Exp $ - */ -public class CompiereToolTipUI extends MetalToolTipUI -{ - - public static ComponentUI createUI(JComponent c) - { - return sharedInstance; - } - - static CompiereToolTipUI sharedInstance = new CompiereToolTipUI(); - - private JToolTip tip; - - public Dimension getPreferredSize(JComponent c) - { - tip = (JToolTip)c; - return super.getPreferredSize(c); - } - public void paint(Graphics g, JComponent c) - { - tip = (JToolTip)c; - super.paint(g, c); - } - - /** - * Get Accelerator String - * @return string - */ - public String getAcceleratorString () - { - String str = super.getAcceleratorString(); - - if (tip == null || isAcceleratorHidden ()) - return str; - JComponent comp = tip.getComponent (); - if (comp == null || comp instanceof JTabbedPane || comp instanceof JMenuItem) - return str; - - KeyStroke[] keys = comp.getRegisteredKeyStrokes (); - StringBuilder controlKeyStr = new StringBuilder(); - for (int i = 0; i < keys.length; i++) - { - int mod = keys[i].getModifiers (); - int condition = comp.getConditionForKeyStroke (keys[i]); - if (condition == JComponent.WHEN_IN_FOCUSED_WINDOW) - { - String prefix = KeyEvent.getModifiersExText (mod); - if (prefix.length() > 1) - { - if (controlKeyStr.length() > 0) - controlKeyStr.append(" "); - controlKeyStr.append(prefix).append("-") - .append(KeyEvent.getKeyText(keys[i].getKeyCode())); - break; // just first - } - } - } - return controlKeyStr.toString(); - } // getAcceleratorString - -} // AdempierelToolTipUI diff --git a/org.adempiere.ui.swing/src/org/compiere/plaf/CompiereUtils.java b/org.adempiere.ui.swing/src/org/compiere/plaf/CompiereUtils.java deleted file mode 100644 index 5390386f97..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/plaf/CompiereUtils.java +++ /dev/null @@ -1,482 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ -package org.compiere.plaf; - -import java.awt.Color; -import java.awt.Component; -import java.awt.Container; -import java.awt.GradientPaint; -import java.awt.Graphics2D; -import java.awt.Image; -import java.awt.MediaTracker; -import java.awt.Paint; -import java.awt.Rectangle; -import java.awt.Toolkit; -import java.awt.geom.RectangularShape; -import java.awt.geom.RoundRectangle2D; -import java.awt.image.BufferedImage; -import java.io.File; -import java.net.MalformedURLException; -import java.net.URL; -import java.util.logging.Level; -import java.util.logging.Logger; - -import javax.imageio.ImageIO; -import javax.swing.JComponent; - - -/** - * UI utilities - * - * @author Jorg Janke - * @version $Id: AdempiereUtils.java,v 1.2 2006/07/30 00:52:23 jjanke Exp $ - */ -public class CompiereUtils -{ - - /** Logger */ - private static Logger log = Logger.getLogger(CompiereUtils.class.getName()); - - /** - * Fill Background with Color. - * (Ususlly called from update methods) - * - * @param g2D Graphics - * @param c Component - * @param round paint round corners - */ - public static void fillRectange(Graphics2D g2D, JComponent c, boolean round) - { - // Paint in AdempiereColor? - CompiereColor cc = null; - boolean stdCC = c.getClientProperty(CompiereLookAndFeel.BACKGROUND_FILL) != null; - try - { - cc = (CompiereColor)c.getClientProperty(CompiereLookAndFeel.BACKGROUND); - } - catch (Exception e) - { - stdCC = true; - } - if (stdCC) - cc = CompiereColor.getDefaultBackground(); - - // Paint AdempiereColor - if (cc != null) - { - // bounds is often not within Panel bouunds - cc.paint(g2D, c); - } - // Paint Flat Color - else - { - Paint paint = c.getBackground(); - g2D.setPaint(paint); - // - RectangularShape rec = null; - if (round) - rec = new RoundRectangle2D.Float(0, 0, c.getWidth(),c.getHeight(), 15,15); - else - rec = new Rectangle(0,0, c.getWidth(),c.getHeight()); - g2D.fill(rec); - } - } // fill Rectangle - - /** Top Top Color - white 128 the higher the ligher */ - static public final Color COL_1TOP = new Color(255, 255, 255, 128); - /** End Top Color - white 0 */ - static public final Color COL_1END = new Color(255, 255, 255, 0); - /** Top End Color - black 0 */ - static public final Color COL_2TOP = new Color(0, 0, 0, 0); - /** End End Color - black 64 the higher the darker */ - static public final Color COL_2END = new Color(0, 0, 0, 64); - - /** - * Paint 3D effect in (lighten in upper half, darken in lowerhalf) - * (called from paint methods) - * - * @param g2D Graphics - * @param r Ractangle - * @param round paint round corners - * @param out paint sticking out (not pressed) - */ - public static void paint3Deffect (Graphics2D g2D, Rectangle r, boolean round, boolean out) - { - // paint upper gradient - GradientPaint topPaint = null; - if (out) - topPaint = new GradientPaint(r.x, r.y, COL_1TOP, r.x, r.y+r.height/2, COL_1END); - else - topPaint = new GradientPaint(r.x, r.y, COL_2END, r.x, r.y+r.height/2, COL_2TOP); - g2D.setPaint(topPaint); - // - RectangularShape topRec = null; - if (round) - topRec = new RoundRectangle2D.Float(r.x,r.y, r.width,r.height/2, 15,15); - else - topRec = new Rectangle(r.x,r.y, r.width,r.height/2); - g2D.fill(topRec); - - // paint lower gradient - GradientPaint endPaint = null; // upper left corner to lower left - if (out) - endPaint = new GradientPaint(r.x, r.y+r.height/2, COL_2TOP, r.x, r.y+r.height, COL_2END); - else - endPaint = new GradientPaint(r.x, r.y+r.height/2, COL_1END, r.x, r.y+r.height, COL_1TOP); - g2D.setPaint(endPaint); - // - RectangularShape endRec = null; - if (round) - endRec = new RoundRectangle2D.Float(r.x, r.y+r.height/2, r.width, r.height/2, 15,15); - else - endRec = new Rectangle(r.x, r.y+r.height/2, r.width, r.height/2); - g2D.fill(endRec); - } // paint3Deffect - - /** - * Paint 3D effect in (lighten in upper half, darken in lowerhalf) - * (called from paint methods) - * - * @param g2D Graphics - * @param c Component - * @param round paint round corners - * @param out paint sticking out (not pressed) - */ - public static void paint3Deffect (Graphics2D g2D, JComponent c, boolean round, boolean out) - { - // paint upper gradient - GradientPaint topPaint = null; - if (out) - topPaint = new GradientPaint(0,0, COL_1TOP, 0,c.getHeight()/2, COL_1END); - else - topPaint = new GradientPaint(0,0, COL_2END, 0,c.getHeight()/2, COL_2TOP); - g2D.setPaint(topPaint); - // - RectangularShape topRec = null; - if (round) - topRec = new RoundRectangle2D.Float(0, 0, c.getWidth(),c.getHeight()/2, 15,15); - else - topRec = new Rectangle(0,0, c.getWidth(),c.getHeight()/2); - g2D.fill(topRec); - - // paint lower gradient - GradientPaint endPaint = null; - if (out) - endPaint = new GradientPaint(0, c.getHeight()/2, COL_2TOP, 0,c.getHeight(), COL_2END); - else - endPaint = new GradientPaint(0, c.getHeight()/2, COL_1END, 0,c.getHeight(), COL_1TOP); - g2D.setPaint(endPaint); - // - RectangularShape endRec = null; - if (round) - endRec = new RoundRectangle2D.Float(0, c.getHeight()/2, c.getWidth(),c.getHeight()/2, 15,15); - else - endRec = new Rectangle(0, c.getHeight()/2, c.getWidth(), c.getHeight()/2); - g2D.fill(endRec); - } // paint3Deffect - - - /************************************************************************* - * Helper to simplify creation of translucent colors - * @param c Color - * @param alpha alpha - * @return Translucent Color - */ - static public Color getTranslucentColor(Color c, int alpha) - { - return new Color(c.getRed(), c.getGreen(), c.getBlue(), alpha); - } // getTranslucentColor - - - /** - * Set Not Buffered. Recursive for all contained components - * @param c - */ - static public void setNotBuffered (Component c) - { - if (c instanceof JComponent) - ((JComponent)c).setDoubleBuffered(false); - if (c instanceof Container) - { - Component[] cc = ((Container)c).getComponents(); - for (int i = 0; i < cc.length; i++) - setNotBuffered(cc[i]); - } - } // setNotBuffered - - - /*************************************************************************/ - - /** Component for media tracker */ - protected final static Component s_component = new Component() { - - /** - * - */ - private static final long serialVersionUID = 2185807624882290223L;}; - /** Media tracker */ - protected final static MediaTracker s_tracker = new MediaTracker(s_component); - - /** - * load the image located at path. - * - * @param path location of image file in local file system - * - otherwise relative to class - * @return loaded image at path or url - * @see java.io.File#toURI() - * @see java.net.URI#toURL() - */ - public static synchronized Image loadImage(String path) - { - Image image = null; - if (path != null) - { - try - { - File file = new File(path); - URL url = file.toURI().toURL(); - image = loadImage(url); - } - catch (MalformedURLException e) - { - log.severe("Path= " + path + " - " + e.getMessage()); - } - } - return image; - } // loadImage - - /** - * Load the image located at URL. - * - * @param url URL where the image file is located. - * @return loaded image at path or url - * @see java.io.File#toURI() - */ - public static synchronized Image loadImage(URL url) - { - Image image = null; - image = Toolkit.getDefaultToolkit().getImage(url); - if (image != null) - { - s_tracker.addImage(image, 0); - try - { - s_tracker.waitForAll(); - } - catch (InterruptedException e) - { - log.severe("Url= " + url + " - " + e.getMessage()); - s_tracker.removeImage(image); - image = null; - } - finally - { - if (image != null) - s_tracker.removeImage(image); - if (s_tracker.isErrorAny()) - { - log.severe("Tracker: " + s_tracker.getErrorsAny()[0]); - image = null; - } - - if (image != null) - { - if (image.getWidth(null) < 0 || image.getHeight(null) < 0) - { - log.severe("Image=0"); - image = null; - } - } - } - } - return image; - } // loadImage - - /** - * Load an image from a given file into a BufferedImage. - * The image is returned in the format defined by the imageType parameter. - * Note that this is special cased for JPEG images where loading is performed - * outside the standard media tracker, for efficiency reasons. - * - * @param file File where the image file is located. - * @param imageType one of the image type defined in the BufferedImage class. - * @return loaded image at path or url - * @see java.awt.image.BufferedImage - */ - public static synchronized BufferedImage loadBufferedImage(File file, int imageType) - { - BufferedImage image = null; - try - { - URL url = file.toURI().toURL(); - image = loadBufferedImage(url, imageType); - } - catch (MalformedURLException e) - { - log.severe("File: " + file + " - " + e.getMessage()); - } - return image; - } // loadBufferedImage - - /** - * Load an image from a given path into a BufferedImage. - * The image is returned in the format defined by the imageType parameter. - * Note that this is special cased for JPEG images where loading is performed - * outside the standard media tracker, for efficiency reasons. - * - * @param path Name of file where the image file is located. - * @param imageType one of the image type defined in the BufferedImage class. - * @return loaded image at path or url - * @see java.awt.image.BufferedImage - * @see java.io.File#toURI() - * @see java.net.URI#toURL() - */ - public static synchronized BufferedImage loadBufferedImage(String path, int imageType) - { - File file = new File(path); - BufferedImage image = null; - try - { - URL url = file.toURI().toURL(); - image = loadBufferedImage(url, imageType); - } - catch (MalformedURLException e) - { - log.severe("Path: " + path + " - " + e.getMessage()); - } - return image; - } // loadBufferedImage - - /** - * Loads an image from a given URL into a BufferedImage. - * The image is returned in the format defined by the imageType parameter. - * Note that this is special cased for JPEG images where loading is performed - * outside the standard media tracker, for efficiency reasons. - * - * @param url URL where the image file is located. - * @param imageType one of the image type defined in the BufferedImage class. - * @return loaded image at path or url - * @see java.awt.image.BufferedImage - */ - public static synchronized BufferedImage loadBufferedImage(URL url, int imageType) - { - BufferedImage image = null; - // Special handling for JPEG images to avoid extra processing if possible. - if (url == null || !url.toString().toLowerCase().endsWith(".jpg")) - { - Image tmpImage = loadImage(url); - if (tmpImage != null) - { - image = new BufferedImage(tmpImage.getWidth(null), tmpImage.getHeight(null), imageType); - Graphics2D g = image.createGraphics(); - g.drawImage(tmpImage, 0, 0, null); - g.dispose(); - } - } - else - { - BufferedImage tmpImage = loadBufferedJPEGImage(url); - if (tmpImage != null) - { - if (tmpImage.getType() != imageType) - { - log.config("Incompatible JPEG image type: creating new buffer image"); - image = new BufferedImage(tmpImage.getWidth(null), tmpImage.getHeight(null), imageType); - Graphics2D g = image.createGraphics(); - g.drawImage(tmpImage, 0, 0, null); - g.dispose(); - } - else - image = tmpImage; - } - } - return image; - } // loadBufferedImage - - /** - * Load a JPEG image from a given location. - * - * @param url URL where the image file is located. - * @return loaded image at path or url - */ - public static synchronized BufferedImage loadBufferedJPEGImage (URL url) - { - BufferedImage image = null; - if (url != null) - { - try - { - image = ImageIO.read(url); - } - catch (Exception e) - { - log.severe("URL: " + url + " - " + e.getMessage()); - image = null; - } - if (image != null) - { - if (log.isLoggable(Level.CONFIG)) log.config("Image type : " + image.getType()); - if (image.getWidth() <= 0 || image.getHeight() <= 0) - { - log.severe("URL: " + url + " =0"); - image = null; - } - } - } - return image; - } - - - /************************************************************************* - * Convenience function for determining ComponentOrientation. - * Copied from MetalUtils - * @param c Component - * @return true, if left to right - */ - public static boolean isLeftToRight (Component c) - { - return c.getComponentOrientation().isLeftToRight(); - } // isLeftToRight - - /** Debug SequenceNo */ - private static int s_no = 0; - - /** - * Print Oarent of Component - * @param c component - */ - static void printParents (JComponent c) - { - if (c.getName() == null) - c.setName("C" + String.valueOf(s_no++)); - System.out.print(c.getName()); - System.out.print(" - " + c.getClass().getName()); - System.out.println (" ** " + c.isOpaque() + " bg=" + (c.getClientProperty(CompiereLookAndFeel.BACKGROUND) != null)); - // - Container container = c.getParent(); - while (container != null) - { - System.out.print (" - " + container.getName() + " " + container.getClass().getName() - + " ** " + container.isOpaque()); - if (container instanceof JComponent) - System.out.print (" bg=" + (((JComponent)container).getClientProperty(CompiereLookAndFeel.BACKGROUND) != null)); - System.out.println (); - container = container.getParent(); - } - } // printParents - -} // AdempiereTuils diff --git a/org.adempiere.ui.swing/src/org/compiere/plaf/CompiereViewportUI.java b/org.adempiere.ui.swing/src/org/compiere/plaf/CompiereViewportUI.java deleted file mode 100644 index 98585084b0..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/plaf/CompiereViewportUI.java +++ /dev/null @@ -1,58 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ -package org.compiere.plaf; - -import javax.swing.JComponent; -import javax.swing.plaf.ComponentUI; -import javax.swing.plaf.ViewportUI; -import javax.swing.plaf.basic.BasicViewportUI; - -/** - * Adempiere View Point - * - * @author Jorg Janke - * @version $Id: AdempiereViewportUI.java,v 1.2 2006/07/30 00:52:23 jjanke Exp $ - */ -public class CompiereViewportUI extends BasicViewportUI -{ - /** Shared UI object */ - private static ViewportUI viewportUI; - - /** - * Create UI - * @param c - * @return AdempiereViewpointUI - */ - public static ComponentUI createUI (JComponent c) - { - if (viewportUI == null) - viewportUI = new CompiereViewportUI(); - return viewportUI; - } // createUI - - /** - * Install UI - * @param c - */ - public void installUI(JComponent c) - { - super.installUI(c); - // will be ignored as set in constructor after updateUI - Sun bug: 4677611 - c.setOpaque(false); - } // installUI - -} // AdempiereViewpointUI diff --git a/org.adempiere.ui.swing/src/org/compiere/plaf/ContrastTheme.java b/org.adempiere.ui.swing/src/org/compiere/plaf/ContrastTheme.java deleted file mode 100644 index 8a95b91166..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/plaf/ContrastTheme.java +++ /dev/null @@ -1,180 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ -package org.compiere.plaf; - -/* - * @(#)ContrastTheme.java 1.10 04/07/26 - */ -import javax.swing.UIDefaults; -import javax.swing.border.Border; -import javax.swing.border.CompoundBorder; -import javax.swing.border.LineBorder; -import javax.swing.plaf.BorderUIResource; -import javax.swing.plaf.ColorUIResource; -import javax.swing.plaf.basic.BasicBorders; -import javax.swing.plaf.metal.DefaultMetalTheme; - -/** - * This class describes a higher-contrast Metal Theme. - * - * @version 1.10 07/26/04 - * @author Michael C. Albers, Jorg Janke - */ -public class ContrastTheme extends DefaultMetalTheme -{ - - public String getName () - { - return "Contrast"; - } - - private final ColorUIResource primary1 - = new ColorUIResource (0, 0, 0); - - private final ColorUIResource primary2 - = new ColorUIResource (204, 204, 204); - - private final ColorUIResource primary3 - = new ColorUIResource (255, 255, 255); - - private final ColorUIResource primaryHighlight - = new ColorUIResource (102, 102, 102); - - private final ColorUIResource secondary2 - = new ColorUIResource (204, 204, 204); - - private final ColorUIResource secondary3 - = new ColorUIResource (255, 255, 255); - - //private final ColorUIResource controlHighlight = new ColorUIResource (102, 102, 102); - - protected ColorUIResource getPrimary1 () - { - return primary1; - } - - protected ColorUIResource getPrimary2 () - { - return primary2; - } - - protected ColorUIResource getPrimary3 () - { - return primary3; - } - - public ColorUIResource getPrimaryControlHighlight () - { - return primaryHighlight; - } - - protected ColorUIResource getSecondary2 () - { - return secondary2; - } - - protected ColorUIResource getSecondary3 () - { - return secondary3; - } - - public ColorUIResource getControlHighlight () - { - return super.getSecondary3 (); - } - - public ColorUIResource getFocusColor () - { - return getBlack (); - } - - public ColorUIResource getTextHighlightColor () - { - return getBlack (); - } - - public ColorUIResource getHighlightedTextColor () - { - return getWhite (); - } - - public ColorUIResource getMenuSelectedBackground () - { - return getBlack (); - } - - public ColorUIResource getMenuSelectedForeground () - { - return getWhite (); - } - - public ColorUIResource getAcceleratorForeground () - { - return getBlack (); - } - - public ColorUIResource getAcceleratorSelectedForeground () - { - return getWhite (); - } - - public void addCustomEntriesToTable (UIDefaults table) - { - Border blackLineBorder = new BorderUIResource - (new LineBorder(getBlack ())); - @SuppressWarnings("unused") - Border whiteLineBorder = new BorderUIResource( - new LineBorder(getWhite())); - // - Object textBorder = new BorderUIResource (new CompoundBorder - (blackLineBorder, new BasicBorders.MarginBorder())); - - // Enhancements - Object[] defaults = new Object[] - { - "ToolTip.border", blackLineBorder, - "TitledBorder.border", blackLineBorder, - "TextField.border", textBorder, - "PasswordField.border", textBorder, - "TextArea.border", textBorder, - "TextPane.border", textBorder, - "EditorPane.border", textBorder, - // - "ComboBox.background", getWindowBackground (), - "ComboBox.foreground", getUserTextColor (), - "ComboBox.selectionBackground", getTextHighlightColor (), - "ComboBox.selectionForeground", getHighlightedTextColor (), - "ProgressBar.foreground", getUserTextColor (), - "ProgressBar.background", getWindowBackground (), - "ProgressBar.selectionForeground", getWindowBackground (), - "ProgressBar.selectionBackground", getUserTextColor (), - "OptionPane.errorDialog.border.background", getPrimary1 (), - "OptionPane.errorDialog.titlePane.foreground", getPrimary3 (), - "OptionPane.errorDialog.titlePane.background", getPrimary1 (), - "OptionPane.errorDialog.titlePane.shadow", getPrimary2 (), - "OptionPane.questionDialog.border.background", getPrimary1 (), - "OptionPane.questionDialog.titlePane.foreground", getPrimary3 (), - "OptionPane.questionDialog.titlePane.background", getPrimary1 (), - "OptionPane.questionDialog.titlePane.shadow", getPrimary2 (), - "OptionPane.warningDialog.border.background", getPrimary1 (), - "OptionPane.warningDialog.titlePane.foreground", getPrimary3 (), - "OptionPane.warningDialog.titlePane.background", getPrimary1 (), - "OptionPane.warningDialog.titlePane.shadow", getPrimary2 (), - }; - table.putDefaults (defaults); - } -} diff --git a/org.adempiere.ui.swing/src/org/compiere/plaf/EmeraldTheme.java b/org.adempiere.ui.swing/src/org/compiere/plaf/EmeraldTheme.java deleted file mode 100644 index c5fdd7ee2c..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/plaf/EmeraldTheme.java +++ /dev/null @@ -1,58 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ -package org.compiere.plaf; - -/* - * @(#)EmeraldTheme.java 1.9 04/07/26 - */ - -import javax.swing.plaf.ColorUIResource; -import javax.swing.plaf.metal.DefaultMetalTheme; - -/** - * This class describes a theme using glowing green colors. - * - * @version 1.9 07/26/04 - * @author Jeff Dinkins - */ -public class EmeraldTheme extends DefaultMetalTheme { - - public String getName() - { - return "Emerald"; - } - - private final ColorUIResource primary1 = new ColorUIResource(51, 142, 71); - private final ColorUIResource primary2 = new ColorUIResource(102, 193, 122); - private final ColorUIResource primary3 = new ColorUIResource(153, 244, 173); - - protected ColorUIResource getPrimary1 () - { - return primary1; - } - - protected ColorUIResource getPrimary2 () - { - return primary2; - } - - protected ColorUIResource getPrimary3 () - { - return primary3; - } - -} diff --git a/org.adempiere.ui.swing/src/org/compiere/plaf/PlafRes.java b/org.adempiere.ui.swing/src/org/compiere/plaf/PlafRes.java deleted file mode 100644 index 3e37a3a5b5..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/plaf/PlafRes.java +++ /dev/null @@ -1,133 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ -package org.compiere.plaf; - -import java.util.ListResourceBundle; - -/** - * Translation Texts for Look & Feel - * - * @author Jorg Janke - * @version $Id: PlafRes.java,v 1.2 2006/07/30 00:52:24 jjanke Exp $ - */ -public class PlafRes extends ListResourceBundle -{ - /** The data */ - static final Object[][] contents = new String[][] - { - { "BackColType", "Background Color Type" }, - { "BackColType_Flat", "Flat" }, - { "BackColType_Gradient", "Gradient" }, - { "BackColType_Lines", "Lines" }, - { "BackColType_Texture", "Texture" }, - // - { "LookAndFeelEditor", "Look & Feel Editor" }, - { "LookAndFeel", "Look & Feel" }, - { "Theme", "Theme" }, - { "EditAdempiereTheme", "Edit Adempiere Theme" }, - { "SetDefault", "Default Background" }, - { "SetDefaultColor", "Background Color" }, - { "ColorBlind", "Color Deficiency" }, - { "Example", "Example" }, - { "Reset", "Reset" }, - { "OK", "OK" }, - { "Cancel", "Cancel" }, - // - { "AdempiereThemeEditor", "Adempiere Theme Editor" }, - { "MetalColors", "Metal Colors" }, - { "AdempiereColors", "Adempiere Colors" }, - { "AdempiereFonts", "Adempiere Fonts" }, - { "Primary1Info", "Shadow, Separator" }, - { "Primary1", "Primary 1" }, - { "Primary2Info", "Focus Line, Selected Menu" }, - { "Primary2", "Primary 2" }, - { "Primary3Info", "Table Selected Row, Selected Text, ToolTip Background" }, - { "Primary3", "Primary 3" }, - { "Secondary1Info", "Border Lines" }, - { "Secondary1", "Secondary 1" }, - { "Secondary2Info", "Inactive Tabs, Pressed Fields, Inactive Border + Text" }, - { "Secondary2", "Secondary 2" }, - { "Secondary3Info", "Background" }, - { "Secondary3", "Secondary 3" }, - // - { "ControlFontInfo", "Control Font" }, - { "ControlFont", "Label Font" }, - { "SystemFontInfo", "Tool Tip, Tree nodes" }, - { "SystemFont", "System Font" }, - { "UserFontInfo", "User Entered Data" }, - { "UserFont", "Field Font" }, -// { "SmallFontInfo", "Reports" }, - { "SmallFont", "Small Font" }, - { "WindowTitleFont", "Title Font" }, - { "MenuFont", "Menu Font" }, - // - { "MandatoryInfo", "Mandatory Field Background" }, - { "Mandatory", "Mandatory" }, - { "ErrorInfo", "Error Field Background" }, - { "Error", "Error" }, - { "InfoInfo", "Info Field Background" }, - { "Info", "Info" }, - { "WhiteInfo", "Lines" }, - { "White", "White" }, - { "BlackInfo", "Lines, Text" }, - { "Black", "Black" }, - { "InactiveInfo", "Inactive Field Background" }, - { "Inactive", "Inactive" }, - { "TextOKInfo", "OK Text Foreground" }, - { "TextOK", "Text - OK" }, - { "TextIssueInfo", "Error Text Foreground" }, - { "TextIssue", "Text - Error" }, - // - { "FontChooser", "Font Chooser" }, - { "Fonts", "Fonts" }, - { "Plain", "Plain" }, - { "Italic", "Italic" }, - { "Bold", "Bold" }, - { "BoldItalic", "Bold & Italic" }, - { "Name", "Name" }, - { "Size", "Size" }, - { "Style", "Style" }, - { "TestString", "This is just a Test! The quick brown Fox is doing something. 12,3456.78 LetterLOne = l1 LetterOZero = O0" }, - { "FontString", "Font" }, - // - { "AdempiereColorEditor", "Adempiere Color Editor" }, - { "AdempiereType", "Color Type" }, - { "GradientUpperColor", "Gradient Upper Color" }, - { "GradientLowerColor", "Gradient Lower Color" }, - { "GradientStart", "Gradient Start" }, - { "GradientDistance", "Gradient Distance" }, - { "TextureURL", "Texture URL" }, - { "TextureAlpha", "Texture Alpha" }, - { "TextureTaintColor", "Texture Taint Color" }, - { "LineColor", "Line Color" }, - { "LineBackColor", "Background Color" }, - { "LineWidth", "Line Width" }, - { "LineDistance", "Line Distance" }, - { "FlatColor", "Flat Color" }, - { "UITheme", "User Interface Theme" }, - { "Preview", "Preview" } - }; - - /** - * Get Contents - * @return contents - */ - public Object[][] getContents() - { - return contents; - } -} // Res diff --git a/org.adempiere.ui.swing/src/org/compiere/plaf/PlafRes_ar.java b/org.adempiere.ui.swing/src/org/compiere/plaf/PlafRes_ar.java deleted file mode 100644 index 4893131d68..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/plaf/PlafRes_ar.java +++ /dev/null @@ -1,132 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ -package org.compiere.plaf; - -import java.util.ListResourceBundle; - -/** - * Translation Texts for Look & Feel - * @author Nizar Khalifa Sallem - OXIA Tunisia - * @version $Id: PlafRes_ar.java,v 1.2 2006/07/30 00:52:24 jjanke Exp $ - */ -public class PlafRes_ar extends ListResourceBundle -{ - /** The data */ - static final Object[][] contents = new String[][] - { - { "BackColType", "\u0646\u0648\u0639 \u0644\u0648\u0646 \u0627\u0644\u062e\u0644\u0641\u064a\u0651\u064e\u0629" }, - { "BackColType_Flat", "\u0645\u0633\u0637\u0651\u064e\u062d" }, - { "BackColType_Gradient", "\u062a\u062f\u0631\u0651\u064f\u062c" }, - { "BackColType_Lines", "\u0623\u0633\u0637\u0631" }, - { "BackColType_Texture", "\u0646\u0633\u064a\u062c" }, - // - { "LookAndFeelEditor", "\u0645\u0639\u0650\u062f \u0623\u0646\u0638\u0631 \u0648 \u0623\u062d\u0633" }, - { "LookAndFeel", "\u0623\u0646\u0638\u0631 \u0648 \u0623\u062d\u0633" }, - { "Theme", "\u0633\u0645\u0629" }, - { "EditAdempiereTheme", "\u0623\u0639\u062f \u0633\u0645\u0629 \u0643\u0645\u0628\u064a\u0631" }, - { "SetDefault", "\u0627\u0644\u062e\u0644\u0641\u064a\u0651\u064e\u0629 \u0627\u0644\u0627\u0650\u0641\u062a\u0631\u0627\u0636\u064a\u0651\u064e\u0629" }, - { "SetDefaultColor", "\u0644\u0648\u0646 \u0627\u0644\u062e\u0644\u0641\u064a\u0651\u064e\u0629" }, - { "ColorBlind", "\u0639\u0645\u0649 \u0627\u0644\u0623\u0644\u0648\u0627\u0646" }, - { "Example", "\u0645\u062b\u0627\u0644" }, - { "Reset", "\u0625\u0639\u0627\u062f\u0629 \u0636\u0628\u0637" }, - { "OK", "\u0646\u0639\u0645" }, - { "Cancel", "\u0625\u0644\u063a\u0627\u0621" }, - // - { "AdempiereThemeEditor", "\u0645\u0639\u062f \u0633\u0645\u0629 \u0643\u0645\u0628\u064a\u0631" }, - { "MetalColors", "\u0623\u0644\u0648\u0627\u0646 \u0645\u0639\u062f\u0646\u064a\u0651\u064e\u0629" }, - { "AdempiereColors", "\u0623\u0644\u0648\u0627\u0646 \u0643\u0645\u0628\u064a\u0631" }, - { "AdempiereFonts", "\u062e\u0637\u0648\u0637 \u0643\u0645\u0628\u064a\u0631" }, - { "Primary1Info", "\u0638\u0644\u060c \u0641\u0627\u0635\u0644" }, - { "Primary1", "\u0623\u0648\u0651\u064e\u0644\u064a 1" }, - { "Primary2Info", "\u0633\u0637\u0631 \u0645\u0631\u0643\u0651\u064e\u0632 \u0639\u0644\u064a\u0647\u060c \u0642\u0627\u0626\u0645\u0629 \u0645\u062e\u062a\u0627\u0631\u0629" }, - { "Primary2", "\u0623\u0648\u0651\u064e\u0644\u064a 2" }, - { "Primary3Info", "\u0633\u0637\u0631 \u0645\u062e\u062a\u0627\u0631 \u0645\u0646 \u062c\u062f\u0648\u0644\u060c \u0646\u0635 \u0645\u062e\u062a\u0627\u0631\u060c \u062e\u0644\u0641\u064a\u0651\u064e\u0629 \u0646\u0635 \u0639\u0631\u0636\u064a" }, - { "Primary3", "\u0623\u0648\u0651\u064e\u0644\u064a 3" }, - { "Secondary1Info", "\u0623\u0633\u0637\u0631 \u062d\u062f" }, - { "Secondary1", "\u062b\u0627\u0646\u0648\u064a 1" }, - { "Secondary2Info", "\u062c\u062f\u0648\u0644\u0627\u062a \u062e\u0627\u0645\u0644\u0629\u060c \u062e\u0627\u0646\u0627\u062a \u0645\u0636\u063a\u0648\u0637\u0629\u060c \u062d\u062f \u062e\u0627\u0645\u0644 +\u0646\u0635" }, - { "Secondary2", "\u062b\u0627\u0646\u0648\u064a 2" }, - { "Secondary3Info", "\u062e\u0644\u0641\u064a\u0651\u064e\u0629" }, - { "Secondary3", "\u062b\u0627\u0646\u0648\u064a 3" }, - // - { "ControlFontInfo", "\u062e\u0637 \u0645\u0631\u0627\u0642\u0628\u0629" }, - { "ControlFont", "\u062e\u0637 \u062c\u0630\u0627\u0630\u0629" }, - { "SystemFontInfo", "\u0646\u0635 \u0639\u0631\u0636\u064a\u060c \u0639\u0642\u062f \u0634\u062c\u0631\u0629" }, - { "SystemFont", "\u062e\u0637 \u0627\u0644\u0646\u0638\u0627\u0645" }, - { "UserFontInfo", "\u0628\u064a\u0627\u0646\u0627\u062a \u0645\u062f\u062e\u0644\u0629 \u0645\u0646 \u0627\u0644\u0645\u0633\u062a\u0639\u0645\u0644" }, - { "UserFont", "\u062e\u0637 \u062d\u0642\u0644" }, -// { "SmallFontInfo", "\u062a\u0642\u0627\u0631\u064a\u0631" }, - { "SmallFont", "\u062e\u0637 \u0635\u063a\u064a\u0631" }, - { "WindowTitleFont", "\u062e\u0637 \u0639\u0646\u0648\u0627\u0646" }, - { "MenuFont", "\u062e\u0637 \u0642\u0627\u0626\u0645\u0629" }, - // - { "MandatoryInfo", "\u062e\u0644\u0641\u064a\u0651\u064e\u0629 \u062d\u0642\u0644 \u0625\u062c\u0628\u0627\u0631\u064a" }, - { "Mandatory", "\u0625\u062c\u0628\u0627\u0631\u064a" }, - { "ErrorInfo", "\u062e\u0644\u0641\u064a\u0651\u064e\u0629 \u062d\u0642\u0644 \u062e\u0627\u0637\u0626"}, - { "Error", "\u062e\u0637\u0623" }, - { "InfoInfo", "\u062e\u0644\u0641\u064a\u0651\u064e\u0629 \u062d\u0642\u0644 \u0628\u064a\u0627\u0646\u0627\u062a" }, - { "Info", "\u0628\u064a\u0627\u0646\u0627\u062a" }, - { "WhiteInfo", "\u0623\u0633\u0637\u0631" }, - { "White", "\u0623\u0628\u064a\u0636" }, - { "BlackInfo", "\u0623\u0633\u0637\u0631\u060c \u0646\u0635" }, - { "Black", "\u0623\u0633\u0648\u062f" }, - { "InactiveInfo", "\u062e\u0644\u0641\u064a\u0651\u064e\u0629 \u062d\u0642\u0644 \u062e\u0627\u0645\u0644" }, - { "Inactive", "\u062e\u0627\u0645\u0644" }, - { "TextOKInfo", "\u0623\u0645\u0627\u0645\u064a\u0651\u064e\u0629 \u0646\u0635 \u0635\u062d\u064a\u062d" }, - { "TextOK", "\u0646\u0635 - \u0635\u062d\u064a\u062d" }, - { "TextIssueInfo", "\u0623\u0645\u0627\u0645\u064a\u0651\u064e\u0629 \u0646\u0635 \u062e\u0627\u0637\u0626" }, - { "TextIssue", "\u0646\u0635 - \u062e\u0637\u0623" }, - // - { "FontChooser", "\u0645\u062e\u062a\u0627\u0631 \u0627\u0644\u062e\u0637" }, - { "Fonts", "\u062e\u0637\u0648\u0637" }, - { "Plain", "\u0645\u0644\u0622\u0646" }, - { "Italic", "\u0645\u0627\u0626\u0644" }, - { "Bold", "\u0633\u0645\u064a\u0643" }, - { "BoldItalic", "\u0633\u0645\u064a\u0643 \u0648 \u0645\u0627\u0626\u0644" }, - { "Name", "\u0627\u0650\u0633\u0645" }, - { "Size", "\u062d\u062c\u0645" }, - { "Style", "\u0645\u0638\u0647\u0631" }, - { "TestString", "\u0647\u0630\u0627 \u0627\u0650\u062e\u062a\u0628\u0627\u0631 \u0641\u0642\u0637\u060c \u0627\u0644\u062b\u0639\u0644\u0628 \u0627\u0644\u0628\u0646\u064a \u0627\u0644\u0633\u0631\u064a\u0639 \u0623\u0643\u0644 \u0634\u064a\u0626\u0627 \u0645\u0627. 12,3456789" }, - { "FontString", "\u062e\u0637" }, - // - { "AdempiereColorEditor", "\u0645\u0639\u062f \u0623\u0644\u0648\u0627\u0646 \u0643\u0645\u0628\u064a\u0631" }, - { "AdempiereType", "\u0646\u0648\u0639 \u0627\u0644\u0644\u0651\u064e\u0648\u0646" }, - { "GradientUpperColor", "\u0644\u0648\u0646 \u0627\u0644\u062a\u062f\u0631\u0651\u064f\u062c \u0627\u0644\u0639\u0644\u0648\u064a" }, - { "GradientLowerColor", "\u0644\u0648\u0646 \u0627\u0644\u062a\u062f\u0631\u0651\u064f\u062c \u0627\u0644\u0633\u0651\u064f\u0641\u0644\u064a" }, - { "GradientStart", "\u0628\u062f\u0627\u064a\u0629 \u0627\u0644\u062a\u062f\u0631\u0651\u064f\u062c" }, - { "GradientDistance", "\u062a\u0628\u0627\u0639\u062f \u0627\u0644\u062a\u062f\u0631\u0651\u064f\u062c" }, - { "TextureURL", "\u0639\u0646\u0648\u0627\u0646 \u0627\u0644\u0646\u0633\u064a\u062c" }, - { "TextureAlpha", "\u0634\u0641\u0627\u0641\u064a\u0651\u064e\u0629 \u0627\u0644\u0646\u0633\u064a\u062c" }, - { "TextureTaintColor", "\u0644\u0648\u0646 \u0635\u0628\u063a\u0629 \u0627\u0644\u0646\u0633\u064a\u062c" }, - { "LineColor", "\u0644\u0648\u0646 \u0627\u0644\u0633\u0651\u064e\u0637\u0631" }, - { "LineBackColor", "\u0644\u0648\u0646 \u0627\u0644\u062e\u0644\u0641\u064a\u0651\u064e\u0629" }, - { "LineWidth", "\u0639\u0631\u0636 \u0627\u0644\u0633\u0637\u0631" }, - { "LineDistance", "\u062a\u0628\u0627\u0639\u062f \u0627\u0644\u0633\u0637\u0631" }, - { "FlatColor", "\u0644\u0648\u0646 \u0645\u0633\u0637\u0651\u064e\u062d" } - }; - - /** - * Get Contents - * @return contents - * @uml.property name="contents" - */ - public Object[][] getContents() - { - return contents; - } -} // Res_ar_TN - diff --git a/org.adempiere.ui.swing/src/org/compiere/plaf/PlafRes_bg.java b/org.adempiere.ui.swing/src/org/compiere/plaf/PlafRes_bg.java deleted file mode 100644 index 016867804b..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/plaf/PlafRes_bg.java +++ /dev/null @@ -1,131 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ -package org.compiere.plaf; - -import java.util.ListResourceBundle; - -/** - * Translation Texts for Look & Feel - * - * @author Plamen Niikolov - * @version $Id: PlafRes_bg.java,v 1.2 2006/07/30 00:52:24 jjanke Exp $ - */ -public class PlafRes_bg extends ListResourceBundle -{ - /** The data */ - static final Object[][] contents = new String[][] - { - { "BackColType", "\u0422\u0438\u043f \u043d\u0430 \u0446\u0432\u0435\u0442\u0430 \u043d\u0430 \u0444\u043e\u043d\u0430" }, - { "BackColType_Flat", "\u0420\u0430\u0432\u0435\u043d(\u041f\u043b\u044a\u0442\u0435\u043d)" }, - { "BackColType_Gradient", "\u041f\u0440\u0435\u043b\u0438\u0432\u0430\u0449" }, - { "BackColType_Lines", "\u041b\u0438\u043d\u0438\u0438" }, - { "BackColType_Texture", "\u041a\u043e\u043d\u0441\u0438\u0441\u0442\u0435\u043d\u0446\u0438\u044f" }, - // - { "LookAndFeelEditor", "\u0420\u0435\u0434\u0430\u043a\u0442\u043e\u0440 \u043d\u0430 \u0432\u0438\u0434 \u043f\u043e\u0442\u0440\u0435\u0431.\u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441" }, - { "LookAndFeel", "\u0412\u0438\u0434 \u043d\u0430 \u043f\u043e\u0442\u0440\u0435\u0431.\u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441" }, - { "Theme", "\u0422\u0435\u043c\u0430" }, - { "EditAdempiereTheme", "\u0420\u0435\u0434\u0430\u043a\u0446\u0438\u044f \u043d\u0430 \u0442\u0435\u043c\u0430" }, - { "SetDefault", "\u041f\u043e\u0434\u0440\u0430\u0437\u0431" }, - { "SetDefaultColor", "\u0426\u0432\u044f\u0442 \u043d\u0430 \u0444\u043e\u043d\u0430" }, - { "ColorBlind", "\u0414\u043e\u043f\u044a\u043b\u0432\u0430\u0449 \u0446\u0432\u044f\u0442" }, - { "Example", "\u041f\u0440\u0438\u043c\u0435\u0440" }, - { "Reset", "\u041d\u0430\u0447\u0430\u043b\u043d\u043e \u0441\u044a\u0441\u0442\u043e\u044f\u043d\u0438\u0435" }, - { "OK", "\u0414\u0430" }, - { "Cancel", "\u041e\u0442\u043a\u0430\u0437" }, - // - { "AdempiereThemeEditor", "\u0420\u0435\u0434\u0430\u043a\u0442\u043e\u0440 \u043d\u0430 \u0442\u0435\u043c\u0438" }, - { "MetalColors", "\u041c\u0435\u0442\u0430\u043b\u043d\u0438 \u0446\u0432\u0435\u0442\u043e\u0432\u0435" }, - { "AdempiereColors", "\u0426\u0432\u0435\u0442\u043e\u0432\u0435" }, - { "AdempiereFonts", "\u0428\u0440\u0438\u0444\u0442\u043e\u0432\u0435" }, - { "Primary1Info", "\u0421\u044f\u043d\u043a\u0430, \u0440\u0430\u0437\u0434\u0435\u043b\u0438\u0442\u0435\u043b" }, - { "Primary1", "\u041e\u0441\u043d\u043e\u0432\u0435\u043d 1" }, - { "Primary2Info", "\u0424\u043e\u043a\u0443\u0441 \u043b\u0438\u043d\u0438\u044f, \u0421\u0435\u043b\u0435\u043a\u0442\u0438\u0440\u0430\u043d\u043e \u043c\u0435\u043d\u044e" }, - { "Primary2", "\u041e\u0441\u043d\u043e\u0432\u0435\u043d 2" }, - { "Primary3Info", "\u0421\u0435\u043b\u0435\u043a\u0442\u0438\u0440\u0430\u043d \u0440\u0435\u0434 \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0430, \u0421\u0435\u043b\u0435\u043a\u0442\u0438\u0440\u0430\u043d \u0442\u0435\u043a\u0441\u0442,\u0424\u043e\u043d \u043d\u0430 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u043d\u0430 \u043f\u043e\u043c\u043e\u0449" }, - { "Primary3", "\u041e\u0441\u043d\u043e\u0432\u0435\u043d 3" }, - { "Secondary1Info", "\u041b\u0438\u043d\u0438\u044f \u043d\u0430 \u0440\u0430\u043c\u043a\u0430\u0442\u0430" }, - { "Secondary1", "\u0421\u043f\u043e\u043c\u0430\u0433\u0430\u0442\u0435\u043b\u0435\u043d 1" }, - { "Secondary2Info", "\u041d\u0435\u0430\u043a\u0442\u0438\u0432\u043d\u0438 \u043f\u0430\u043d\u0435\u043b\u0438, \u041d\u0430\u0442\u0438\u0441\u043d\u0430\u0442\u0438 \u043f\u043e\u043b\u0435\u0442\u0430, \u041d\u0435\u0430\u043a\u0442\u0438\u0432\u043d\u0438 \u0440\u0430\u043c\u043a\u0438 \u0438 \u0442\u0435\u043a\u0441\u0442\u043e\u0432\u0435" }, - { "Secondary2", "\u0421\u043f\u043e\u043c\u0430\u0433\u0430\u0442\u0435\u043b\u0435\u043d 2" }, - { "Secondary3Info", "\u0424\u043e\u043d" }, - { "Secondary3", "\u0421\u043f\u043e\u043c\u0430\u0433\u0430\u0442\u0435\u043b\u0435\u043d 3" }, - // - { "ControlFontInfo", "\u041a\u043e\u043d\u0442\u0440\u043e\u043b \u043d\u0430 \u0448\u0440\u0438\u0444\u0442\u043e\u0432\u0435\u0442\u0435" }, - { "ControlFont", "\u0428\u0440\u0438\u0444\u0442 \u043d\u0430 \u0435\u0442\u0438\u043a\u0435\u0442\u0438\u0442\u0435" }, - { "SystemFontInfo", "\u041a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u043d\u0430 \u043f\u043e\u043c\u043e\u0449, \u0434\u044a\u0440\u0432\u043e\u0432\u0438\u0434\u043d\u0430 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430" }, - { "SystemFont", "\u0421\u0438\u0441\u0442\u0435\u043c\u0435\u043d \u0448\u0440\u0438\u0444\u0442" }, - { "UserFontInfo", "\u0414\u0430\u043d\u043d\u0438 \u0432\u044a\u0432\u0435\u0434\u0435\u043d\u0438 \u043e\u0442 \u043f\u043e\u0442\u0440\u0435\u0431\u0438\u0442\u0435\u043b\u044f" }, - { "UserFont", "\u0428\u0440\u0438\u0444\u0442 \u043d\u0430 \u043f\u043e\u043b\u0435" }, -// { "SmallFontInfo", "Reports" }, - { "SmallFont", "\u041c\u0430\u043b\u044a\u043a \u0448\u0440\u0438\u0444\u0442" }, - { "WindowTitleFont", "\u0428\u0440\u0438\u0444\u0442 \u043d\u0430 \u0437\u0430\u0433\u043b\u0430\u0432\u0438\u0435\u0442\u043e" }, - { "MenuFont", "\u0428\u0440\u0438\u0444\u0442 \u043d\u0430 \u043c\u0435\u043d\u044e\u0442\u043e" }, - // - { "MandatoryInfo", "\u0424\u043e\u043d \u043d\u0430 \u0437\u0430\u0434\u044a\u043b\u0436\u0438\u0442\u0435\u043b\u043d\u043e\u0442\u043e \u043f\u043e\u043b\u0435" }, - { "Mandatory", "\u0417\u0430\u0434\u044a\u043b\u0436\u0438\u0442\u0435\u043b\u0435\u043d" }, - { "ErrorInfo", "\u0424\u043e\u043d \u043d\u0430 \u043f\u043e\u043b\u0435 \u0437\u0430 \u0433\u0440\u0435\u0448\u043a\u0430" }, - { "Error", "\u0413\u0440\u0435\u0448\u043a\u0430" }, - { "InfoInfo", "\u0424\u043e\u043d \u043d\u0430 \u043f\u043e\u043b\u0435\u0442\u043e \u0441 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f" }, - { "Info", "\u0418\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f" }, - { "WhiteInfo", "\u041b\u0438\u043d\u0438\u0438" }, - { "White", "\u0411\u044f\u043b" }, - { "BlackInfo", "\u041b\u0438\u043d\u0438\u0438, \u0442\u0435\u043a\u0441\u0442" }, - { "Black", "\u0427\u0435\u0440\u0435\u043d" }, - { "InactiveInfo", "\u0424\u043e\u043d \u043d\u0430 \u043d\u0435\u0430\u043a\u0442\u0438\u0432\u043d\u043e \u043f\u043e\u043b\u0435" }, - { "Inactive", "\u041d\u0435\u0430\u043a\u0442\u0438\u0432\u0435\u043d" }, - { "TextOKInfo", "\u0426\u0432\u044f\u0442 \u043d\u0430 \u0448\u0440\u0438\u0444\u0442\u0430 \u043f\u0440\u0438 \u041e\u041a" }, - { "TextOK", "\u0412\u0430\u043b\u0438\u0434\u0435\u043d \u0442\u0435\u043a\u0441\u0442" }, - { "TextIssueInfo", "\u0426\u0432\u044f\u0442 \u043d \u0430\u0448\u0440\u0438\u0444\u0442\u0430 \u043f\u0440\u0438 \u0433\u0440\u0435\u0448\u043a\u0430" }, - { "TextIssue", "\u0413\u0440\u0435\u0448\u0435\u043d \u0442\u0435\u043a\u0441\u0442" }, - // - { "FontChooser", "\u0418\u0437\u0431\u043e\u0440 \u043d\u0430 \u0448\u0440\u0438\u0444\u0442" }, - { "Fonts", "\u0428\u0440\u0438\u0444\u0442\u043e\u0432\u0435" }, - { "Plain", "\u041e\u0431\u0438\u043a\u043d\u043e\u0432\u0435\u043d" }, - { "Italic", "\u041d\u0430\u043a\u043b\u043e\u043d\u0435\u043d" }, - { "Bold", "\u0423\u0434\u0435\u0431\u0435\u043b\u0435\u043d" }, - { "BoldItalic", "\u0423\u0434\u0435\u0431\u0435\u043b\u0435\u043d \u0438 \u043d\u0430\u043a\u043b\u043e\u043d\u0435\u043d" }, - { "Name", "\u0418\u043c\u0435" }, - { "Size", "\u0420\u0430\u0437\u043c\u0435\u0440" }, - { "Style", "\u0421\u0442\u0438\u043b" }, - { "TestString", "\u0422\u043e\u0432\u0430 \u0435 \u0441\u0430\u043c\u043e \u0442\u0435\u0441\u0442! \u0411\u044a\u0440\u0437\u0430\u0442\u0430 \u043a\u0430\u0444\u044f\u0432\u0430 \u043b\u0438\u0441\u0438\u0446\u0430 \u043f\u0440\u0430\u0432\u0438 \u043d\u0435\u0449\u043e. 12,3456.78 LetterLOne = l1 LetterOZero = O0" }, - { "FontString", "\u0428\u0440\u0438\u0444\u0442" }, - // - { "AdempiereColorEditor", "\u0420\u0435\u0434\u0430\u043a\u0442\u043e\u0440 \u043d\u0430 \u0446\u0432\u0435\u0442\u043e\u0432\u0435" }, - { "AdempiereType", "\u0422\u0438\u043f \u043d\u0430 \u0446\u0432\u0435\u0442\u043e\u0432\u0435\u0442\u0435" }, - { "GradientUpperColor", "\u041f\u0440\u0435\u043b\u0438\u0432\u0430\u043d\u0435 \u0433\u043e\u0440\u0435\u043d \u0446\u0432\u044f\u0442" }, - { "GradientLowerColor", "\u041f\u0440\u0435\u043b\u0438\u0432\u0430\u043d\u0435 \u0434\u043e\u043b\u0435\u043d \u0446\u0432\u044f\u0442" }, - { "GradientStart", "\u041d\u0430\u0447\u0430\u043b\u043e \u043d\u0430 \u043f\u0440\u0435\u043b\u0438\u0432\u043a\u0430" }, - { "GradientDistance", "\u0414\u044a\u043b\u0436\u0438\u043d\u0430 \u043d\u0430 \u043f\u0440\u0435\u043b\u0438\u0432\u043a\u0430" }, - { "TextureURL", "\u041c\u0435\u0441\u0442\u043e\u043d\u0430\u0445\u043e\u0436\u0434\u0435\u043d\u0438\u0435 \u043d\u0430 \u043a\u043e\u0441\u043d\u0441\u0438\u0441\u0442\u0435\u043d\u0446\u0438\u044f\u0442\u0430" }, - { "TextureAlpha", "\u0422\u0435\u043a\u0441\u0442\u0443\u0440\u0430 \u0410\u043b\u0444\u0430" }, - { "TextureTaintColor", "\u0422\u0435\u043a\u0441\u0442\u0443\u0440\u0430 \u0446\u0432\u044f\u0442 - \u043f\u0435\u0442\u043d\u043e, \u0441\u043b\u0435\u0434\u0430" }, - { "LineColor", "\u0426\u0432\u044f\u0442 \u043d\u0430 \u043b\u0438\u043d\u0438\u044f" }, - { "LineBackColor", "\u0426\u0432\u044f\u0442 \u043d\u0430 \u0444\u043e\u043d\u0430" }, - { "LineWidth", "\u0414\u0435\u0431\u0435\u043b\u0438\u043d\u0430 \u043d\u0430 \u043b\u0438\u043d\u0438\u044f" }, - { "LineDistance", "\u0414\u044a\u043b\u0436\u0438\u043d\u0430 \u043d\u0430 \u043b\u0438\u043d\u0438\u044f" }, - { "FlatColor", "\u0420\u0430\u0432\u0435\u043d(\u041f\u043b\u044a\u0442\u0435\u043d) \u0446\u0432\u044f\u0442" } - }; - - /** - * Get Contents - * @return contents - */ - public Object[][] getContents() - { - return contents; - } -} // Res diff --git a/org.adempiere.ui.swing/src/org/compiere/plaf/PlafRes_ca.java b/org.adempiere.ui.swing/src/org/compiere/plaf/PlafRes_ca.java deleted file mode 100644 index 988c0391ca..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/plaf/PlafRes_ca.java +++ /dev/null @@ -1,134 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ -package org.compiere.plaf; - -import java.util.ListResourceBundle; - -/** - * Translation Texts for Look & Feel - * - * @author Jaume Teixi - * @author Jordi Luna - * @version $Id: PlafRes_ca.java,v 1.2 2006/07/30 00:52:23 jjanke Exp $ - */ -public class PlafRes_ca extends ListResourceBundle -{ - /** The data */ - static final Object[][] contents = new String[][] - { - { "BackColType", "Tipus Color de Fons" }, - { "BackColType_Flat", "Pla" }, - { "BackColType_Gradient", "Pendent" }, - { "BackColType_Lines", "L\u00ednies" }, - { "BackColType_Texture", "Textura" }, - // - { "LookAndFeelEditor", "Editor Look & Feel" }, - { "LookAndFeel", "Look & Feel" }, - { "Theme", "Tema" }, - { "EditAdempiereTheme", "Editar Tema Adempiere" }, - { "SetDefault", "Fons Per Defecte" }, - { "SetDefaultColor", "Color de Fons" }, - { "ColorBlind", "Defici\u00e9ncia de Color" }, - { "Example", "Exemple" }, - { "Reset", "Reiniciar" }, - { "OK", "Acceptar" }, - { "Cancel", "Cancel.lar" }, - // - { "AdempiereThemeEditor", "Editor Tema Adempiere" }, - { "MetalColors", "Colors Met\u00e0l.lics" }, - { "AdempiereColors", "Colors Adempiere" }, - { "AdempiereFonts", "Fonts Adempiere" }, - { "Primary1Info", "Ombra, Separador" }, - { "Primary1", "Primari 1" }, - { "Primary2Info", "L\u00ednia Enfocada, Men\u00fa Seleccionat" }, - { "Primary2", "Primari 2" }, - { "Primary3Info", "Taula Fila Seleccionada, Texte Seleccionat, Indicador de Fons" }, - { "Primary3", "Primari 3" }, - { "Secondary1Info", "L\u00ednies Marc" }, - { "Secondary1", "Secondari 1" }, - { "Secondary2Info", "Pestanyes Inactives, Camps Premuts, Texte + Marc Inactius" }, - { "Secondary2", "Secondari 2" }, - { "Secondary3Info", "Fons" }, - { "Secondary3", "Secondari 3" }, - // - { "ControlFontInfo", "Font de Control" }, - { "ControlFont", "Font d'Etiqueta" }, - { "SystemFontInfo", "Indicador, Arbres Node" }, - { "SystemFont", "Font de Sistema" }, - { "UserFontInfo", "Dades Entrades Per l'Usuari" }, - { "UserFont", "Font de Camp" }, -// { "SmallFontInfo", "Informes" }, - { "SmallFont", "Font Petita" }, - { "WindowTitleFont", "Font de T\u00edtol" }, - { "MenuFont", "Font del Men\u00fa" }, - // - { "MandatoryInfo", "Camp de Fons Obligatori" }, - { "Mandatory", "Obligatori" }, - { "ErrorInfo", "Error al Camp de Fons" }, - { "Error", "Error" }, - { "InfoInfo", "Informaci\u00f3 Camp de Fons" }, - { "Info", "Informaci\u00f3" }, - { "WhiteInfo", "L\u00ednies" }, - { "White", "Blanc" }, - { "BlackInfo", "L\u00ednies, Text" }, - { "Black", "Negre" }, - { "InactiveInfo", "Camp de Fons Inactiu" }, - { "Inactive", "Inactiu" }, - { "TextOKInfo", "Texte Superior OK" }, - { "TextOK", "Texte - OK" }, - { "TextIssueInfo", "Error al Texte Superior" }, - { "TextIssue", "Texte - Error" }, - // - { "FontChooser", "Seleccionador de Font" }, - { "Fonts", "Fonts" }, - { "Plain", "Plana" }, - { "Italic", "It\u00e0lica" }, - { "Bold", "Negreta" }, - { "BoldItalic", "Negreta & It\u00e0lica" }, - { "Name", "Nom" }, - { "Size", "Tamany" }, - { "Style", "Estil" }, - { "TestString", "Aix\u00f2 \u00e9s nom\u00e9s una Prova! La Guineu marr\u00f3 r\u00e0pida est\u00e0 fent quelcom. 12,3456.78 LetterLOne = l1 LetterOZero = O0" }, - { "FontString", "Font" }, - // - { "AdempiereColorEditor", "Editor Color Adempiere" }, - { "AdempiereType", "Tipus Color" }, - { "GradientUpperColor", "Color Superior Degradat" }, - { "GradientLowerColor", "Color Inferior Degradat" }, - { "GradientStart", "Inici Degradat" }, - { "GradientDistance", "Dist\u00e0ncia Degradat" }, - { "TextureURL", "Textura URL" }, - { "TextureAlpha", "Textura Alfa" }, - { "TextureTaintColor", "Textura Color Empanyat" }, - { "LineColor", "Color de L\u00ednia" }, - { "LineBackColor", "Color de Fons" }, - { "LineWidth", "Amplada L\u00ednia" }, - { "LineDistance", "Dist\u00e0ncia L\u00ednia" }, - { "FlatColor", "Color Pl\u00e0" }, - { "UITheme", "Tema Interface d'Usuari" }, - { "Preview", "Pre-visualitzar" } - }; - - /** - * Get Contents - * @return contents - */ - public Object[][] getContents() - { - return contents; - } -} // Res diff --git a/org.adempiere.ui.swing/src/org/compiere/plaf/PlafRes_da.java b/org.adempiere.ui.swing/src/org/compiere/plaf/PlafRes_da.java deleted file mode 100644 index 02248ba3a6..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/plaf/PlafRes_da.java +++ /dev/null @@ -1,131 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ -package org.compiere.plaf; - -import java.util.ListResourceBundle; - -/** - * Translation Texts for Look & Feel - * - * @author Jorg Janke - * @version $Id: PlafRes_da.java,v 1.2 2006/07/30 00:52:23 jjanke Exp $ - */ -public class PlafRes_da extends ListResourceBundle -{ - /** The data */ - static final Object[][] contents = new String[][] - { - { "BackColType", "Baggrund: Farvetype" }, - { "BackColType_Flat", "Fast" }, - { "BackColType_Gradient", "FarveforlĂžb" }, - { "BackColType_Lines", "Linjer" }, - { "BackColType_Texture", "Struktur" }, - // - { "LookAndFeelEditor", "RedigĂ©r & udseende" }, - { "LookAndFeel", "Udseende" }, - { "Theme", "Tema" }, - { "EditAdempiereTheme", "RedigĂ©r Adempiere tema" }, - { "SetDefault", "Baggrund: Standard" }, - { "SetDefaultColor", "Baggrundsfarve" }, - { "ColorBlind", "Farvereduktion" }, - { "Example", "Eksempel" }, - { "Reset", "Gendan" }, - { "OK", "OK" }, - { "Cancel", "AnnullĂ©r" }, - // - { "AdempiereThemeEditor", "Adempiere-tema: RedigĂ©r" }, - { "MetalColors", "Metal-farver" }, - { "AdempiereColors", "Adempiere-farver" }, - { "AdempiereFonts", "Adempiere-skrifttyper" }, - { "Primary1Info", "Skygge, Separator" }, - { "Primary1", "PrimĂŠr 1" }, - { "Primary2Info", "Markeret element, Markeret menu" }, - { "Primary2", "PrimĂŠr 2" }, - { "Primary3Info", "Markeret rĂŠkke i tabel, Markeret tekst, VĂŠrktĂžjstip - baggr." }, - { "Primary3", "Primïżœr 3" }, - { "Secondary1Info", "Rammelinjer" }, - { "Secondary1", "SekundĂŠr 1" }, - { "Secondary2Info", "Ikke-aktive faner, Markerede felter, Ikke-aktiv ramme + tekst" }, - { "Secondary2", "SekundĂŠr 2" }, - { "Secondary3Info", "Baggrund" }, - { "Secondary3", "SekundĂŠr 3" }, - // - { "ControlFontInfo", "Skrifttype: Knapper" }, - { "ControlFont", "Skrifttype: Etiket" }, - { "SystemFontInfo", "VĂŠrktĂžjstip, Strukturknuder" }, - { "SystemFont", "Skrifttype: System" }, - { "UserFontInfo", "Anvend" }, - { "UserFont", "Skrifttype: Felt" }, -// { "SmallFontInfo", "Rapporter" }, - { "SmallFont", "Lille" }, - { "WindowTitleFont", "Skrifttype: Titellinje" }, - { "MenuFont", "Skrifttype: Menu" }, - // - { "MandatoryInfo", "Tvungen feltbaggrund" }, - { "Mandatory", "Tvungen" }, - { "ErrorInfo", "Fejl: Feltbaggrund" }, - { "Error", "Fejl" }, - { "InfoInfo", "Info: Feltbaggrund" }, - { "Info", "Info" }, - { "WhiteInfo", "Linjer" }, - { "White", "Hvid" }, - { "BlackInfo", "Linjer, Tekst" }, - { "Black", "Sort" }, - { "InactiveInfo", "Inaktiv feltbaggrund" }, - { "Inactive", "Inaktiv" }, - { "TextOKInfo", "OK: Tekstforgrund" }, - { "TextOK", "Tekst: OK" }, - { "TextIssueInfo", "Fejl: Tekstforgrund" }, - { "TextIssue", "Tekst: Fejl" }, - // - { "FontChooser", "Skriftype" }, - { "Fonts", "Skrifttyper" }, - { "Plain", "Normal" }, - { "Italic", "Kursiv" }, - { "Bold", "Fed" }, - { "BoldItalic", "Fed & kursiv" }, - { "Name", "Navn" }, - { "Size", "StĂžrrelse" }, - { "Style", "Type" }, - { "TestString", "Dette er en prĂžve! 12.3456,78 BogstavLEn = l1 BogstavONul = O0" }, - { "FontString", "Skrifttype" }, - // - { "AdempiereColorEditor", "Adempiere-farveeditor" }, - { "AdempiereType", "Farvetype" }, - { "GradientUpperColor", "FarveforlĂžb: Farve 1" }, - { "GradientLowerColor", "FarveforlĂžb: Farve 2" }, - { "GradientStart", "FarveforlĂžb: Start" }, - { "GradientDistance", "FarveforlĂžb: Afstand" }, - { "TextureURL", "Struktur: URL" }, - { "TextureAlpha", "Struktur: Alpha" }, - { "TextureTaintColor", "Struktur: Pletvis" }, - { "LineColor", "Linjefarve" }, - { "LineBackColor", "Baggrundsfarve" }, - { "LineWidth", "Linjebredde" }, - { "LineDistance", "Linjeafstand" }, - { "FlatColor", "Fast farve" } - }; - - /** - * Get Contents - * @return contents - */ - public Object[][] getContents() - { - return contents; - } -} // Res diff --git a/org.adempiere.ui.swing/src/org/compiere/plaf/PlafRes_de.java b/org.adempiere.ui.swing/src/org/compiere/plaf/PlafRes_de.java deleted file mode 100644 index 61196f2723..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/plaf/PlafRes_de.java +++ /dev/null @@ -1,130 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ -package org.compiere.plaf; - -import java.util.ListResourceBundle; - -/** - * Translation Texts for Look & Feel (German) - * - * @author Jorg Janke - * @version $Id: PlafRes_de.java,v 1.2 2006/07/30 00:52:23 jjanke Exp $ - */ -public class PlafRes_de extends ListResourceBundle -{ - /** The data */ - static final Object[][] contents = new String[][] - { - { "BackColType", "Hintergrund Farbtyp" }, - { "BackColType_Flat", "Flach" }, - { "BackColType_Gradient", "Gradient" }, - { "BackColType_Lines", "Linie" }, - { "BackColType_Texture", "Textur" }, - // - { "LookAndFeelEditor", "BenutzeroberflĂ€chen Editor" }, - { "LookAndFeel", "OberflĂ€che" }, - { "Theme", "Thema" }, - { "EditAdempiereTheme", "Adempiere Thema bearbeiten" }, - { "SetDefault", "Standard Hintergrund" }, - { "SetDefaultColor", "Hintergrund Farbe" }, - { "ColorBlind", "Farbblindheit" }, - { "Example", "Beispiel" }, - { "Reset", "ZurĂŒcksetzen" }, - { "OK", "Ja" }, - { "Cancel", "Abbruch" }, - // - { "AdempiereThemeEditor", "Adempiere Thema Editor" }, - { "MetalColors", "Metal Farben" }, - { "AdempiereColors", "Adempiere Farben" }, - { "AdempiereFonts", "Adempiere Schriften" }, - { "Primary1Info", "Schatten, Separator" }, - { "Primary1", "PrimĂ€r 1" }, - { "Primary2Info", "Fokuslinien, Aktives Menïżœ" }, - { "Primary2", "PrimĂ€r 2" }, - { "Primary3Info", "Tabelle Selected Row, Selected Text, Tool Tip Hintergrund" }, - { "Primary3", "PrimĂ€r 3" }, - { "Secondary1Info", "Rahmen Lines" }, - { "Secondary1", "SekundĂ€r 1" }, - { "Secondary2Info", "Inaktive Tabs, Pressed Felder, Inaktive Rahmen + Text" }, - { "Secondary2", "SekundĂ€r 2" }, - { "Secondary3Info", "Hintergrund" }, - { "Secundary3", "SekundĂ€r 3" }, - // - { "ControlFontInfo", "Labels" }, - { "ControlFont", "Standard Schrift" }, - { "SystemFontInfo", "Tool Tip" }, - { "SystemFont", "System Schrift" }, - { "UserFontInfo", "Entered Data" }, - { "UserFont", "Nutzer Schrift" }, - { "SmallFont", "Kleine Schrift" }, - { "WindowTitleFont", "Titel Schrift" }, - { "MenuFont", "MenĂŒ Schrift" }, - // - { "MandatoryInfo", "Erforderliches Feld Hintergrund" }, - { "Mandatory", "Erforderlich" }, - { "ErrorInfo", "Fehler Feld Hintergrund" }, - { "Error", "Fehler" }, - { "InfoInfo", "Info Feld Hintergrund" }, - { "Info", "Info" }, - { "WhiteInfo", "Linien" }, - { "White", "Weiß" }, - { "BlackInfo", "Linien, Text" }, - { "Black", "Schwarz" }, - { "InactiveInfo", "Inaktiv Feld Hintergrund" }, - { "Inactive", "Inaktiv" }, - { "TextOKInfo", "OK Text Fordergrund" }, - { "TextOK", "Text - OK" }, - { "TextIssueInfo", "Fehler Text Fordergrund" }, - { "TextIssue", "Text - Fehler" }, - // - { "FontChooser", "Schrift Auswahl" }, - { "Fonts", "Schriften" }, - { "Plain", "Normal" }, - { "Italic", "Italic" }, - { "Bold", "Fett" }, - { "BoldItalic", "Fett & Italic" }, - { "Name", "Name" }, - { "Size", "GrĂ¶ĂŸe" }, - { "Style", "Stil" }, - { "TestString", "Dies ist nur ein Test! The quick brown Fox is doing something. 12,3456.78 BuchstabeLEins = l1 BuchstabeONull = O0" }, - { "FontString", "Schrift" }, - // - { "AdempiereColorEditor", "Adempiere Farben Auswahl" }, - { "AdempiereType", "Farbtyp" }, - { "GradientUpperColor", "Gradient obere Farbe" }, - { "GradientLowerColor", "Gradient untere Farbe" }, - { "GradientStart", "Gradient Start" }, - { "GradientDistance", "Gradient Distanz" }, - { "TextureURL", "Textur URL" }, - { "TextureAlpha", "Textur Alpha" }, - { "TextureTaintColor", "Textur Tönung Farbe" }, - { "LineColor", "Linie Farbe" }, - { "LineBackColor", "Hintergrund Farbe" }, - { "LineWidth", "Linie Breite" }, - { "LineDistance", "Linie Distanz" }, - { "FlatColor", "Flache Farbe" } - }; - - /** - * Get Contents - * @return contents - */ - public Object[][] getContents() - { - return contents; - } -} // Res_de diff --git a/org.adempiere.ui.swing/src/org/compiere/plaf/PlafRes_el.java b/org.adempiere.ui.swing/src/org/compiere/plaf/PlafRes_el.java deleted file mode 100644 index 8b56bcbfdb..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/plaf/PlafRes_el.java +++ /dev/null @@ -1,133 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ -package org.compiere.plaf; - -import java.util.ListResourceBundle; - -/** - * Translation Texts for Look & Feel - * - * @author Kyriakos Ioannidis - kioa@openway.gr - * @version $Id: PlafRes.java,v 1.2 2006/07/30 00:52:24 jjanke Exp $ - */ -public class PlafRes_el extends ListResourceBundle -{ - /** The data */ - static final Object[][] contents = new String[][] - { - { "BackColType", "Background Color Type" }, - { "BackColType_Flat", "Flat" }, - { "BackColType_Gradient", "Gradient" }, - { "BackColType_Lines", "Lines" }, - { "BackColType_Texture", "Texture" }, - // - { "LookAndFeelEditor", "Look & Feel Editor" }, - { "LookAndFeel", "Look & Feel" }, - { "Theme", "Theme" }, - { "EditAdempiereTheme", "Edit Adempiere Theme" }, - { "SetDefault", "Default Background" }, - { "SetDefaultColor", "Background Color" }, - { "ColorBlind", "Color Deficiency" }, - { "Example", "Example" }, - { "Reset", "Reset" }, - { "OK", "OK" }, - { "Cancel", "Cancel" }, - // - { "AdempiereThemeEditor", "Adempiere Theme Editor" }, - { "MetalColors", "Metal Colors" }, - { "AdempiereColors", "Adempiere Colors" }, - { "AdempiereFonts", "Adempiere Fonts" }, - { "Primary1Info", "Shadow, Separator" }, - { "Primary1", "Primary 1" }, - { "Primary2Info", "Focus Line, Selected Menu" }, - { "Primary2", "Primary 2" }, - { "Primary3Info", "Table Selected Row, Selected Text, ToolTip Background" }, - { "Primary3", "Primary 3" }, - { "Secondary1Info", "Border Lines" }, - { "Secondary1", "Secondary 1" }, - { "Secondary2Info", "Inactive Tabs, Pressed Fields, Inactive Border + Text" }, - { "Secondary2", "Secondary 2" }, - { "Secondary3Info", "Background" }, - { "Secondary3", "Secondary 3" }, - // - { "ControlFontInfo", "Control Font" }, - { "ControlFont", "Label Font" }, - { "SystemFontInfo", "Tool Tip, Tree nodes" }, - { "SystemFont", "System Font" }, - { "UserFontInfo", "User Entered Data" }, - { "UserFont", "Field Font" }, -// { "SmallFontInfo", "Reports" }, - { "SmallFont", "Small Font" }, - { "WindowTitleFont", "Title Font" }, - { "MenuFont", "Menu Font" }, - // - { "MandatoryInfo", "Mandatory Field Background" }, - { "Mandatory", "Mandatory" }, - { "ErrorInfo", "Error Field Background" }, - { "Error", "Error" }, - { "InfoInfo", "Info Field Background" }, - { "Info", "Info" }, - { "WhiteInfo", "Lines" }, - { "White", "White" }, - { "BlackInfo", "Lines, Text" }, - { "Black", "Black" }, - { "InactiveInfo", "Inactive Field Background" }, - { "Inactive", "Inactive" }, - { "TextOKInfo", "OK Text Foreground" }, - { "TextOK", "Text - OK" }, - { "TextIssueInfo", "Error Text Foreground" }, - { "TextIssue", "Text - Error" }, - // - { "FontChooser", "Font Chooser" }, - { "Fonts", "Fonts" }, - { "Plain", "Plain" }, - { "Italic", "Italic" }, - { "Bold", "Bold" }, - { "BoldItalic", "Bold & Italic" }, - { "Name", "Name" }, - { "Size", "Size" }, - { "Style", "Style" }, - { "TestString", "This is just a Test! The quick brown Fox is doing something. 12,3456.78 LetterLOne = l1 LetterOZero = O0" }, - { "FontString", "Font" }, - // - { "AdempiereColorEditor", "Adempiere Color Editor" }, - { "AdempiereType", "Color Type" }, - { "GradientUpperColor", "Gradient Upper Color" }, - { "GradientLowerColor", "Gradient Lower Color" }, - { "GradientStart", "Gradient Start" }, - { "GradientDistance", "Gradient Distance" }, - { "TextureURL", "Texture URL" }, - { "TextureAlpha", "Texture Alpha" }, - { "TextureTaintColor", "Texture Taint Color" }, - { "LineColor", "Line Color" }, - { "LineBackColor", "Background Color" }, - { "LineWidth", "Line Width" }, - { "LineDistance", "Line Distance" }, - { "FlatColor", "Flat Color" }, - { "UITheme", "User Interface Theme" }, - { "Preview", "Preview" } - }; - - /** - * Get Contents - * @return contents - */ - public Object[][] getContents() - { - return contents; - } -} // Res diff --git a/org.adempiere.ui.swing/src/org/compiere/plaf/PlafRes_es.java b/org.adempiere.ui.swing/src/org/compiere/plaf/PlafRes_es.java deleted file mode 100644 index 06fb669c1e..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/plaf/PlafRes_es.java +++ /dev/null @@ -1,133 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ -package org.compiere.plaf; - -import java.util.ListResourceBundle; - -/** - * Translation Texts for Look & Feel - * - * @author Jordi Luna - * @version $Id: PlafRes_es.java,v 1.2 2006/07/30 00:52:23 jjanke Exp $ - */ -public class PlafRes_es extends ListResourceBundle -{ - /** The data */ - static final Object[][] contents = new String[][] - { - { "BackColType", "Tipo Color de Fondo" }, - { "BackColType_Flat", "Plano" }, - { "BackColType_Gradient", "Pendiente" }, - { "BackColType_Lines", "L\u00edneas" }, - { "BackColType_Texture", "Textura" }, - // - { "LookAndFeelEditor", "Editor Look & Feel" }, - { "LookAndFeel", "Look & Feel" }, - { "Theme", "Tema" }, - { "EditAdempiereTheme", "Editar Tema Adempiere" }, - { "SetDefault", "Fondo Por Defecto" }, - { "SetDefaultColor", "Color de Fondo" }, - { "ColorBlind", "Defici\u00e9ncia de Color" }, - { "Example", "Ejemplo" }, - { "Reset", "Reiniciar" }, - { "OK", "Aceptar" }, - { "Cancel", "Cancelar" }, - // - { "AdempiereThemeEditor", "Editor Tema Adempiere" }, - { "MetalColors", "Colores Met\u00e1licos" }, - { "AdempiereColors", "Colores Adempiere" }, - { "AdempiereFonts", "Fuentes Adempiere" }, - { "Primary1Info", "Sombra, Separador" }, - { "Primary1", "Primario 1" }, - { "Primary2Info", "L\u00ednea Enfocada, Men\u00fa Seleccionado" }, - { "Primary2", "Primario 2" }, - { "Primary3Info", "Fila de Tabla Seleccionada, Texto Seleccionado, Indicador de Fondo" }, - { "Primary3", "Primario 3" }, - { "Secondary1Info", "L\u00edneas Marco" }, - { "Secondary1", "Secundario 1" }, - { "Secondary2Info", "Pesta\u00f1as Inactivas, Campos Pulsados, Texto + Marco Inactivos" }, - { "Secondary2", "Secundario 2" }, - { "Secondary3Info", "Fondo" }, - { "Secondary3", "Secundario 3" }, - // - { "ControlFontInfo", "Fuente de Control" }, - { "ControlFont", "Fuente de Etiqueta" }, - { "SystemFontInfo", "Indicador, \u00c1rbol Nodo" }, - { "SystemFont", "Fuente del Sistema" }, - { "UserFontInfo", "Datos Entrados Por el Usuario" }, - { "UserFont", "Fuente de Campo" }, -// { "SmallFontInfo", "Informes" }, - { "SmallFont", "Fuente Peque\u00f1a" }, - { "WindowTitleFont", "Fuente de T\u00edtulo" }, - { "MenuFont", "Fuente del Men\u00fa" }, - // - { "MandatoryInfo", "Campo de fondo Obligatorio" }, - { "Mandatory", "Obligatorio" }, - { "ErrorInfo", "Error en el Campo de Fondo" }, - { "Error", "Error" }, - { "InfoInfo", "Informaci\u00f3n Campo de Fondo" }, - { "Info", "Informaci\u00f3n" }, - { "WhiteInfo", "L\u00edneas" }, - { "White", "Blanco" }, - { "BlackInfo", "L\u00edneas, Texto" }, - { "Black", "Negro" }, - { "InactiveInfo", "Campo de Fondo Inactivo" }, - { "Inactive", "Inactivo" }, - { "TextOKInfo", "Texto Superior OK" }, - { "TextOK", "Texto - OK" }, - { "TextIssueInfo", "Error en el Texto Superior" }, - { "TextIssue", "Texto - Error" }, - // - { "FontChooser", "Seleccionador de Fuente" }, - { "Fonts", "Fuentes" }, - { "Plain", "Plana" }, - { "Italic", "It\u00e1lica" }, - { "Bold", "Negrita" }, - { "BoldItalic", "Negrita & It\u00e1lica" }, - { "Name", "Nombre" }, - { "Size", "Tama\u00f1o" }, - { "Style", "Estilo" }, - { "TestString", "Esto es solo una prueba! El r\u00e1pido zorro marr\u00f3n est\u00e1 haciendo alguna cosa. 12,3456.78 LetterLOne = l1 LetterOZero = O0" }, - { "FontString", "Fuente" }, - // - { "AdempiereColorEditor", "Editor Color Adempiere" }, - { "AdempiereType", "Tipo Color" }, - { "GradientUpperColor", "Color Superior Degradado" }, - { "GradientLowerColor", "Color Inferior Degradado" }, - { "GradientStart", "Inicio Degradado" }, - { "GradientDistance", "Distancia Degradado" }, - { "TextureURL", "Textura URL" }, - { "TextureAlpha", "Textura Alfa" }, - { "TextureTaintColor", "Textura Color Empa\u00f1ado" }, - { "LineColor", "Color de L\u00ednea" }, - { "LineBackColor", "Color de Fondo" }, - { "LineWidth", "Anchura L\u00ednea" }, - { "LineDistance", "Distancia L\u00ednea" }, - { "FlatColor", "Color Plano" }, - { "UITheme", "Tema Interface de Usuario" }, - { "Preview", "Pre-visualizar" } - }; - - /** - * Get Contents - * @return contents - */ - public Object[][] getContents() - { - return contents; - } -} // Res diff --git a/org.adempiere.ui.swing/src/org/compiere/plaf/PlafRes_fa.java b/org.adempiere.ui.swing/src/org/compiere/plaf/PlafRes_fa.java deleted file mode 100644 index c0b7183d7c..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/plaf/PlafRes_fa.java +++ /dev/null @@ -1,131 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ -package org.compiere.plaf; - -import java.util.ListResourceBundle; - -/** - * Translation Texts for Look & Feel - * - * @author Jorg Janke - * @version $Id: PlafRes_fa.java,v 1.2 2006/07/30 00:52:24 jjanke Exp $ - */ -public class PlafRes_fa extends ListResourceBundle -{ - /** The data */ - static final Object[][] contents = new String[][] - { - { "BackColType", "\u0646\u0648\u0639 \u0631\u0646\u06af \u0632\u0645\u064a\u0646\u0647" }, - { "BackColType_Flat", "\u0645\u0633\u0637\u062d" }, - { "BackColType_Gradient", "\u0634\u064a\u0628 \u062f\u0627\u0631" }, - { "BackColType_Lines", "\u062e\u0637\u0648\u0637" }, - { "BackColType_Texture", "\u0634\u0627\u0644\u0648\u062f\u0647" }, - // - { "LookAndFeelEditor", "\u0648\u064a\u0631\u0627\u0633\u062a\u0627\u0631 \u0645\u0631\u0628\u0648\u0637 \u0628\u0647 \u0638\u0627\u0647\u0631 \u0648 \u0639\u0645\u0644" }, - { "LookAndFeel", "\u0638\u0627\u0647\u0631 \u0648 \u0639\u0645\u0644" }, - { "Theme", "\u062a\u0645" }, - { "EditAdempiereTheme", "\u0648\u064a\u0631\u0627\u064a\u0634 \u062a\u0645 \u06a9\u0627\u0645\u067e\u064a\u0631\u0647" }, - { "SetDefault", "\u0632\u0645\u064a\u0646\u0647 \u067e\u064a\u0634 \u0641\u0631\u0636" }, - { "SetDefaultColor", "\u0631\u0646\u06af \u0632\u0645\u064a\u0646\u0647" }, - { "ColorBlind", "\u0646\u0642\u0635 \u0631\u0646\u06af" }, - { "Example", "\u0645\u062b\u0627\u0644" }, - { "Reset", "\u0628\u0627\u0632\u0646\u0634\u0627\u0646\u062f\u0646" }, - { "OK", "\u062a\u0635\u0648\u064a\u0628" }, - { "Cancel", "\u0644\u063a\u0648" }, - // - { "AdempiereThemeEditor", "\u0648\u064a\u0631\u0627\u064a\u0633\u062a\u0627\u0631 \u062a\u0645 \u06a9\u0627\u0645\u067e\u064a\u0631\u0647" }, - { "MetalColors", "\u0631\u0646\u06af\u0647\u0627\u06cc \u0645\u062a\u0627\u0644" }, - { "AdempiereColors", "\u0631\u0646\u06af\u0647\u0627\u06cc \u06a9\u0627\u0645\u067e\u064a\u0631\u0647" }, - { "AdempiereFonts", "\u0641\u0648\u0646\u062a \u06a9\u0627\u0645\u067e\u064a\u0631\u0647" }, - { "Primary1Info", "\u0633\u0627\u064a\u0647\u060c \u062c\u062f\u0627\u06a9\u0646\u0646\u062f\u0647" }, - { "Primary1", "\u0627\u0648\u0644\u064a\u0647 1" }, - { "Primary2Info", "\u062e\u0637 \u0645\u0648\u0631\u062f \u062a\u0627\u06a9\u064a\u062f\u060c \u0645\u0646\u0648\u06cc \u0627\u0646\u062a\u062e\u0627\u0628 \u0634\u062f\u0647" }, - { "Primary2", "\u0627\u0648\u0644\u064a\u0647 2" }, - { "Primary3Info", "\u0631\u062f\u064a\u0641 \u062c\u062f\u0648\u0644 \u0627\u0646\u062a\u062e\u0627\u0628 \u0634\u062f\u0647\u060c \u0645\u062a\u0646 \u0627\u0646\u062a\u062e\u0627\u0628 \u0634\u062f\u0647\u060c \u0632\u0645\u064a\u0646\u0647 \u062a\u0648\u0644\u062a\u064a\u067e" }, - { "Primary3", "\u0627\u0648\u0644\u064a\u0647 3" }, - { "Secondary1Info", "\u062e\u0637\u0648\u0637 \u0645\u0631\u0632\u06cc" }, - { "Secondary1", "\u062b\u0627\u0646\u0648\u064a\u0647 1" }, - { "Secondary2Info", "\u062c\u062f\u0627\u0648\u0644 \u0639\u064a\u0631\u0641\u0639\u0627\u0644\u060c \u0641\u064a\u0644\u062f\u0647\u0627\u06cc \u0641\u0634\u0627\u0631 \u062f\u0627\u062f\u0647 \u0634\u062f\u0647\u060c \u0645\u0631\u0632 \u063a\u064a\u0631\u0641\u0639\u0627\u0644 \u0648 \u0645\u062a\u0646" }, - { "Secondary2", "\u062b\u0627\u0646\u0648\u064a\u0647 2" }, - { "Secondary3Info", "\u0632\u0645\u064a\u0646\u0647" }, - { "Secondary3", "\u062b\u0627\u0646\u0648\u064a\u0647 3" }, - // - { "ControlFontInfo", "\u0641\u0648\u0646\u062a \u06a9\u0646\u062a\u0631\u0644" }, - { "ControlFont", "\u0641\u0648\u0646\u062a \u0628\u0631\u0686\u0633\u0628" }, - { "SystemFontInfo", "\u062a\u0648\u0644\u062a\u064a\u067e\u060c \u0646\u062f\u0647\u0627\u06cc \u062f\u0631\u062e\u062a" }, - { "SystemFont", "\u0641\u0648\u0646\u062a \u0633\u064a\u0633\u062a\u0645" }, - { "UserFontInfo", "\u062f\u0627\u062f\u0647 \u0647\u0627\u06cc \u0648\u0627\u0631\u062f \u0634\u062f\u0647 \u0628\u0648\u0633\u064a\u0644\u0647 \u0627\u0633\u062a\u0641\u0627\u062f\u0647 \u06a9\u0646\u0646\u062f\u0647" }, - { "UserFont", "\u0641\u0648\u0646\u062a \u0641\u064a\u0644\u062f" }, -// { "SmallFontInfo", "\u06af\u0632\u0627\u0631\u0634\u0627\u062a" }, - { "SmallFont", "\u0641\u0648\u0646\u062a \u06a9\u0648\u0686\u06a9" }, - { "WindowTitleFont", "\u0641\u0648\u0646\u062a \u0639\u0646\u0648\u0627\u0646" }, - { "MenuFont", "\u0641\u0648\u0646\u062a \u0645\u0646\u0648" }, - // - { "MandatoryInfo", "\u0632\u0645\u064a\u0646\u0647 \u0641\u064a\u0644\u062f \u0627\u0644\u0632\u0627\u0645\u06cc" }, - { "Mandatory", "\u0627\u0644\u0632\u0627\u0645\u06cc" }, - { "ErrorInfo", "\u0632\u0645\u064a\u0646\u0647 \u0641\u064a\u0644\u062f \u062e\u0637\u0627" }, - { "Error", "\u062e\u0637\u0627" }, - { "InfoInfo", "\u0632\u0645\u064a\u0646\u0647 \u0641\u064a\u0644\u062f \u0627\u0637\u0644\u0627\u0639\u0627\u062a\u06cc" }, - { "Info", "\u0627\u0637\u0644\u0627\u0639\u0627\u062a\u06cc" }, - { "WhiteInfo", "\u062e\u0637\u0648\u0637" }, - { "White", "\u0633\u0641\u064a\u062f" }, - { "BlackInfo", "\u062e\u0637\u0648\u0637\u060c \u0645\u062a\u0646" }, - { "Black", "\u0633\u064a\u0627\u0647" }, - { "InactiveInfo", "\u0632\u0645\u064a\u0646\u0647 \u0641\u064a\u0644\u062f \u063a\u064a\u0631\u0641\u0639\u0627\u0644" }, - { "Inactive", "\u063a\u064a\u0631\u0641\u0639\u0627\u0644" }, - { "TextOKInfo", "\u0631\u0646\u06af \u0645\u062a\u0646 \u062a\u0635\u0648\u064a\u0628" }, - { "TextOK", "\u0645\u062a\u0646 - \u062a\u0635\u0648\u064a\u0628" }, - { "TextIssueInfo", "\u0631\u0646\u06af \u0645\u062a\u0646 \u062e\u0637\u0627" }, - { "TextIssue", "\u0645\u062a\u0646 - \u062e\u0637\u0627" }, - // - { "FontChooser", "\u0627\u0646\u062a\u062e\u0627\u0628 \u06a9\u0646\u0646\u062f\u0647 \u0641\u0648\u0646\u062a" }, - { "Fonts", "\u0641\u0648\u0646\u062a\u0647\u0627" }, - { "Plain", "\u0633\u0627\u062f\u0647" }, - { "Italic", "\u062d\u0631\u0648\u0641 \u06a9\u062c" }, - { "Bold", "\u0633\u064a\u0627\u0647" }, - { "BoldItalic", "\u0633\u064a\u0627\u0647 \u0648 \u06a9\u062c" }, - { "Name", "\u0646\u0627\u0645" }, - { "Size", "\u0627\u0646\u062f\u0627\u0632\u0647" }, - { "Style", "\u0633\u0628\u06a9" }, - { "TestString", "\u0627\u064a\u0646 \u064a\u06a9 \u062a\u0633\u062a \u0627\u0633\u062a! \u0631\u0648\u0628\u0627\u0647 \u0642\u0647\u0648\u0647 \u0627\u06cc \u062f\u0631 \u062d\u0627\u0644 \u0627\u0646\u062c\u0627\u0645 \u06a9\u0627\u0631\u06cc \u0627\u0633\u062a." }, - { "FontString", "\u0641\u0648\u0646\u062a" }, - // - { "AdempiereColorEditor", "\u0648\u064a\u0631\u0627\u0633\u062a\u0627\u0631 \u0631\u0646\u06af \u06a9\u0627\u0645\u067e\u064a\u0631\u0647" }, - { "AdempiereType", "\u0646\u0648\u0639 \u0631\u0646\u06af" }, - { "GradientUpperColor", "\u0631\u0646\u06af \u0628\u0627\u0644\u0627\u06cc \u0634\u064a\u0628" }, - { "GradientLowerColor", "\u0631\u0646\u06af \u067e\u0627\u064a\u064a\u0646 \u0634\u064a\u0628" }, - { "GradientStart", "\u0634\u0631\u0648\u0639 \u0634\u064a\u0628" }, - { "GradientDistance", "\u0645\u0633\u0627\u0641\u062a \u0634\u064a\u0628" }, - { "TextureURL", "\u064a\u0648 \u0622\u0631 \u0622\u0644 \u0628\u0627\u0641\u062a" }, - { "TextureAlpha", "\u0628\u0627\u0641\u062a \u0622\u0644\u0641\u0627" }, - { "TextureTaintColor", "\u0631\u0646\u06af \u0628\u0627\u0641\u062a \u0644\u06a9\u0647 \u062f\u0627\u0631" }, - { "LineColor", "\u0631\u0646\u06af \u062e\u0637" }, - { "LineBackColor", "\u0631\u0646\u06af \u0632\u0645\u064a\u0646\u0647" }, - { "LineWidth", "\u067e\u0647\u0646\u0627\u06cc \u062e\u0637" }, - { "LineDistance", "\u0641\u0627\u0635\u0644\u0647 \u062e\u0637" }, - { "FlatColor", "\u0631\u0646\u06af \u0645\u0633\u0637\u062d" } - }; - - /** - * Get Contents - * @return contents - */ - public Object[][] getContents() - { - return contents; - } -} // Res diff --git a/org.adempiere.ui.swing/src/org/compiere/plaf/PlafRes_fr.java b/org.adempiere.ui.swing/src/org/compiere/plaf/PlafRes_fr.java deleted file mode 100644 index 5a48651888..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/plaf/PlafRes_fr.java +++ /dev/null @@ -1,124 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ -package org.compiere.plaf; - -import java.util.ListResourceBundle; - -/** - * Translation Texts for Look & Feel (French) - * - * @author Jean-Luc SCHEIDEGGER - * @version $Id: PlafRes_fr.java,v 1.2 2006/07/30 00:52:23 jjanke Exp $ - */ -public class PlafRes_fr extends ListResourceBundle -{ - /** Translation Content */ - static final Object[][] contents = new String[][] - { - { "BackColType", "Type de Couleur de Fond" }, - { "BackColType_Flat", "Flat" }, - { "BackColType_Gradient", "Gradient" }, - { "BackColType_Lines", "Lignes" }, - { "BackColType_Texture", "Texture" }, - { "LookAndFeelEditor", "Look & Feel Editor" }, - { "LookAndFeel", "Look & Feel" }, - { "Theme", "Th\350me" }, - { "EditAdempiereTheme", "Editer Th\350me Adempiere" }, - { "SetDefault", "Couleur de Fond par D\351faut" }, - { "SetDefaultColor", "Couleur de Fond" }, - { "ColorBlind", "Couleur Deficiency" }, - { "Example", "Exemple" }, - { "Reset", "Remettre" }, - { "OK", "OK" }, - { "Cancel", "Annuler" }, - { "AdempiereThemeEditor", "Editeur de Th\350me Adempiere" }, - { "MetalColors", "Couleurs M\351tal" }, - { "AdempiereColors", "Couleurs Adempiere" }, - { "AdempiereFonts", "Polices Adempiere" }, - { "Primary1Info", "Label Text" }, - { "Primary1", "Primary 1" }, - { "Primary2Info", "Focus Line, Selected CheckBox" }, - { "Primary2", "Primary 2" }, - { "Primary3Info", "Table Selected Row, Selected Text, ToolTip Background" }, - { "Primary3", "Primary 3" }, - { "Secondary1Info", "Border Lines" }, - { "Secondary1", "Secondary 1" }, - { "Secondary2Info", "Inactive Tabs, Pressed Fields, Inactive Border + Text" }, - { "Secondary2", "Secondary 2" }, - { "Secondary3Info", "Background" }, - { "Secondary3", "Secondary 3" }, - { "ControlFontInfo", "Control Font" }, - { "ControlFont", "Label Font" }, - { "SystemFontInfo", "Tool Tip, Tree nodes" }, - { "SystemFont", "System Font" }, - { "UserFontInfo", "User Entered Data" }, - { "UserFont", "Field Font" }, - { "SmallFont", "Small Font" }, - { "WindowTitleFont", "Title Font" }, - { "MenuFont", "Menu Font" }, - { "MandatoryInfo", "Mandatory Field Background" }, - { "Mandatory", "Mandatory" }, - { "ErrorInfo", "Error Field Background" }, - { "Error", "Error" }, - { "InfoInfo", "Info Field Background" }, - { "Info", "Info" }, - { "WhiteInfo", "Lines" }, - { "White", "White" }, - { "BlackInfo", "Lines, Text" }, - { "Black", "Black" }, - { "InactiveInfo", "Inactive Field Background" }, - { "Inactive", "Inactive" }, - { "TextOKInfo", "OK Text Foreground" }, - { "TextOK", "Text - OK" }, - { "TextIssueInfo", "Error Text Foreground" }, - { "TextIssue", "Text - Error" }, - { "FontChooser", "Font Chooser" }, - { "Fonts", "Fonts" }, - { "Plain", "Plain" }, - { "Italic", "Italic" }, - { "Bold", "Bold" }, - { "BoldItalic", "Bold & Italic" }, - { "Name", "Name" }, - { "Size", "Size" }, - { "Style", "Style" }, - { "TestString", "This is just a Test! The quick brown Fox is doing something. 12,3456.78 LetterLOne = l1 LetterOZero = O0" }, - { "FontString", "Font" }, - { "AdempiereColorEditor", "Adempiere Couleur Editor" }, - { "AdempiereType", "Couleur Type" }, - { "GradientUpperColor", "Gradient Upper Couleur" }, - { "GradientLowerColor", "Gradient Lower Couleur" }, - { "GradientStart", "Gradient Start" }, - { "GradientDistance", "Gradient Distance" }, - { "TextureURL", "Texture URL" }, - { "TextureAlpha", "Texture Alpha" }, - { "TextureTaintColor", "Texture Taint Couleur" }, - { "LineColor", "Line Couleur" }, - { "LineBackColor", "Background Couleur" }, - { "LineWidth", "Line Width" }, - { "LineDistance", "Line Distance" }, - { "FlatColor", "Flat Couleur" } - }; - - /** - * Get Contents - * @return contents - */ - public Object[][] getContents() - { - return contents; - } // fetContents -} // PlafRes_fr diff --git a/org.adempiere.ui.swing/src/org/compiere/plaf/PlafRes_hr.java b/org.adempiere.ui.swing/src/org/compiere/plaf/PlafRes_hr.java deleted file mode 100644 index 63744e1124..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/plaf/PlafRes_hr.java +++ /dev/null @@ -1,132 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ -package org.compiere.plaf; - -import java.util.ListResourceBundle; - -/** - * Translation Texts for Look & Feel - * - * @author Marko Bubalo - * @version $Id: PlafRes_hr.java,v 1.2 2006/07/30 00:52:24 jjanke Exp $ - */ -public class PlafRes_hr extends ListResourceBundle -{ - /** The data */ - static final Object[][] contents = new String[][] - { - { "BackColType", "Tip pozadine" }, - { "BackColType_Flat", "Flat" }, - { "BackColType_Gradient", "Gradient" }, - { "BackColType_Lines", "Liije" }, - { "BackColType_Texture", "Teksture" }, - // - { "LookAndFeelEditor", "Uredivaïżœ izgleda" }, - { "LookAndFeel", "Izgled" }, - { "Theme", "Tema" }, - { "EditAdempiereTheme", "Ureïżœivanje Adempiere teme" }, - { "SetDefault", "Uobiïżœajena pozadina" }, - { "SetDefaultColor", "Boja pozadine" }, - { "ColorBlind", "Color Deficiency" }, - { "Example", "Primjer" }, - { "Reset", "Poniïżœtiti" }, - { "OK", "U redu" }, - { "Cancel", "Otkazati" }, - // - { "AdempiereThemeEditor", "Ureïżœivanje Adempiere teme" }, - { "MetalColors", "Metal Colors" }, - { "AdempiereColors", "Adempiere Colors" }, - { "AdempiereFonts", "Adempiere Fonts" }, - { "Primary1Info", "Shadow, Separator" }, - { "Primary1", "Primary 1" }, - { "Primary2Info", "Focus Line, Selected Menu" }, - { "Primary2", "Primary 2" }, - { "Primary3Info", "Table Selected Row, Selected Text, ToolTip Background" }, - { "Primary3", "Primary 3" }, - { "Secondary1Info", "Border Lines" }, - { "Secondary1", "Secondary 1" }, - { "Secondary2Info", "Inactive Tabs, Pressed Fields, Inactive Border + Text" }, - { "Secondary2", "Secondary 2" }, - { "Secondary3Info", "Background" }, - { "Secondary3", "Secondary 3" }, - // - { "ControlFontInfo", "Control Font" }, - { "ControlFont", "Label Font" }, - { "SystemFontInfo", "Tool Tip, Tree nodes" }, - { "SystemFont", "System Font" }, - { "UserFontInfo", "User Entered Data" }, - { "UserFont", "Field Font" }, -// { "SmallFontInfo", "Reports" }, - { "SmallFont", "Small Font" }, - { "WindowTitleFont", "Title Font" }, - { "MenuFont", "Menu Font" }, - // - { "MandatoryInfo", "Mandatory Field Background" }, - { "Mandatory", "Mandatory" }, - { "ErrorInfo", "Error Field Background" }, - { "Error", "Error" }, - { "InfoInfo", "Info Field Background" }, - { "Info", "Info" }, - { "WhiteInfo", "Lines" }, - { "White", "White" }, - { "BlackInfo", "Lines, Text" }, - { "Black", "Black" }, - { "InactiveInfo", "Inactive Field Background" }, - { "Inactive", "Inactive" }, - { "TextOKInfo", "OK Text Foreground" }, - { "TextOK", "Text - OK" }, - { "TextIssueInfo", "Error Text Foreground" }, - { "TextIssue", "Text - Error" }, - // - { "FontChooser", "Font Chooser" }, - { "Fonts", "Fonts" }, - { "Plain", "Plain" }, - { "Italic", "Italic" }, - { "Bold", "Bold" }, - { "BoldItalic", "Bold & Italic" }, - { "Name", "Name" }, - { "Size", "Size" }, - { "Style", "Style" }, - { "TestString", "This is just a Test! The quick brown Fox is doing something. 12,3456.78 LetterLOne = l1 LetterOZero = O0" }, - { "FontString", "Font" }, - // - { "AdempiereColorEditor", "Adempiere Color Editor" }, - { "AdempiereType", "Color Type" }, - { "GradientUpperColor", "Gradient Upper Color" }, - { "GradientLowerColor", "Gradient Lower Color" }, - { "GradientStart", "Gradient Start" }, - { "GradientDistance", "Gradient Distance" }, - { "TextureURL", "Texture URL" }, - { "TextureAlpha", "Texture Alpha" }, - { "TextureTaintColor", "Texture Taint Color" }, - { "LineColor", "Line Color" }, - { "LineBackColor", "Background Color" }, - { "LineWidth", "Line Width" }, - { "LineDistance", "Line Distance" }, - { "FlatColor", "Flat Color" } - }; - - /** - * Get Contents - * @return contents - */ - public Object[][] getContents() - { - return contents; - } -} // Res - diff --git a/org.adempiere.ui.swing/src/org/compiere/plaf/PlafRes_hu.java b/org.adempiere.ui.swing/src/org/compiere/plaf/PlafRes_hu.java deleted file mode 100644 index 66524f6d95..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/plaf/PlafRes_hu.java +++ /dev/null @@ -1,133 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ -package org.compiere.plaf; - -import java.util.ListResourceBundle; - -/** - * Translation Texts for Look & Feel - * - * @author Jorg Janke - * @version $Id: PlafRes.java,v 1.2 2006/07/30 00:52:24 jjanke Exp $ - */ -public class PlafRes_hu extends ListResourceBundle -{ - /** The data */ - static final Object[][] contents = new String[][] - { - { "BackColType", "HĂĄttĂ©rszĂ­n tĂ­pus" }, - { "BackColType_Flat", "Sima" }, - { "BackColType_Gradient", "Gradiens" }, - { "BackColType_Lines", "Vonalas" }, - { "BackColType_Texture", "TextĂșrĂĄzott" }, - // - { "LookAndFeelEditor", "Look & Feel Editor" }, - { "LookAndFeel", "Look & Feel" }, - { "Theme", "Theme" }, - { "EditAdempiereTheme", "Edit Adempiere Theme" }, - { "SetDefault", "Default Background" }, - { "SetDefaultColor", "Background Color" }, - { "ColorBlind", "Color Deficiency" }, - { "Example", "Example" }, - { "Reset", "Reset" }, - { "OK", "OK" }, - { "Cancel", "Cancel" }, - // - { "AdempiereThemeEditor", "Adempiere Theme Editor" }, - { "MetalColors", "Metal Colors" }, - { "AdempiereColors", "Adempiere Colors" }, - { "AdempiereFonts", "Adempiere Fonts" }, - { "Primary1Info", "Shadow, Separator" }, - { "Primary1", "Primary 1" }, - { "Primary2Info", "Focus Line, Selected Menu" }, - { "Primary2", "Primary 2" }, - { "Primary3Info", "Table Selected Row, Selected Text, ToolTip Background" }, - { "Primary3", "Primary 3" }, - { "Secondary1Info", "Border Lines" }, - { "Secondary1", "Secondary 1" }, - { "Secondary2Info", "Inactive Tabs, Pressed Fields, Inactive Border + Text" }, - { "Secondary2", "Secondary 2" }, - { "Secondary3Info", "Background" }, - { "Secondary3", "Secondary 3" }, - // - { "ControlFontInfo", "Control Font" }, - { "ControlFont", "Label Font" }, - { "SystemFontInfo", "Tool Tip, Tree nodes" }, - { "SystemFont", "System Font" }, - { "UserFontInfo", "User Entered Data" }, - { "UserFont", "Field Font" }, -// { "SmallFontInfo", "Reports" }, - { "SmallFont", "Small Font" }, - { "WindowTitleFont", "Title Font" }, - { "MenuFont", "Menu Font" }, - // - { "MandatoryInfo", "Mandatory Field Background" }, - { "Mandatory", "Mandatory" }, - { "ErrorInfo", "Error Field Background" }, - { "Error", "Error" }, - { "InfoInfo", "Info Field Background" }, - { "Info", "Info" }, - { "WhiteInfo", "Lines" }, - { "White", "White" }, - { "BlackInfo", "Lines, Text" }, - { "Black", "Black" }, - { "InactiveInfo", "Inactive Field Background" }, - { "Inactive", "Inactive" }, - { "TextOKInfo", "OK Text Foreground" }, - { "TextOK", "Text - OK" }, - { "TextIssueInfo", "Error Text Foreground" }, - { "TextIssue", "Text - Error" }, - // - { "FontChooser", "Font Chooser" }, - { "Fonts", "Fonts" }, - { "Plain", "Plain" }, - { "Italic", "Italic" }, - { "Bold", "Bold" }, - { "BoldItalic", "Bold & Italic" }, - { "Name", "Name" }, - { "Size", "Size" }, - { "Style", "Style" }, - { "TestString", "This is just a Test! The quick brown Fox is doing something. 12,3456.78 LetterLOne = l1 LetterOZero = O0" }, - { "FontString", "Font" }, - // - { "AdempiereColorEditor", "Adempiere Color Editor" }, - { "AdempiereType", "Color Type" }, - { "GradientUpperColor", "Gradient Upper Color" }, - { "GradientLowerColor", "Gradient Lower Color" }, - { "GradientStart", "Gradient Start" }, - { "GradientDistance", "Gradient Distance" }, - { "TextureURL", "Texture URL" }, - { "TextureAlpha", "Texture Alpha" }, - { "TextureTaintColor", "Texture Taint Color" }, - { "LineColor", "Line Color" }, - { "LineBackColor", "Background Color" }, - { "LineWidth", "Line Width" }, - { "LineDistance", "Line Distance" }, - { "FlatColor", "Flat Color" }, - { "UITheme", "User Interface Theme" }, - { "Preview", "Preview" } - }; - - /** - * Get Contents - * @return contents - */ - public Object[][] getContents() - { - return contents; - } -} // Res diff --git a/org.adempiere.ui.swing/src/org/compiere/plaf/PlafRes_in.java b/org.adempiere.ui.swing/src/org/compiere/plaf/PlafRes_in.java deleted file mode 100644 index 8134c78201..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/plaf/PlafRes_in.java +++ /dev/null @@ -1,131 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ -package org.compiere.plaf; - -import java.util.ListResourceBundle; - -/** - * Translation Texts for Look & Feel - * - * @author Halim Englen - * @version $Id: PlafRes_in.java,v 1.2 2006/07/30 00:52:24 jjanke Exp $ - */ -public class PlafRes_in extends ListResourceBundle -{ - /** The data */ - static final Object[][] contents = new String[][] - { - { "BackColType", "Tipe Warna Latar Belakang" }, - { "BackColType_Flat", "Rata" }, - { "BackColType_Gradient", "Gradien" }, - { "BackColType_Lines", "Garis" }, - { "BackColType_Texture", "Textur" }, - // - { "LookAndFeelEditor", "Editor Look & Feel" }, - { "LookAndFeel", "Look & Feel" }, - { "Theme", "Tema" }, - { "EditAdempiereTheme", "Ubah Tema Adempiere" }, - { "SetDefault", "Latar Belakang Asal" }, - { "SetDefaultColor", "Warna Latar Belakang" }, - { "ColorBlind", "Defisiensi Warna" }, - { "Example", "Contoh" }, - { "Reset", "Reset" }, - { "OK", "OK" }, - { "Cancel", "Batal" }, - // - { "AdempiereThemeEditor", "Adempiere Tema Editor" }, - { "MetalColors", "Warna Metal" }, - { "AdempiereColors", "Warna Adempiere" }, - { "AdempiereFonts", "Adempiere Fonts" }, - { "Primary1Info", "Bayangan, Pemisah" }, - { "Primary1", "Utama 1" }, - { "Primary2Info", "Baris Fokus, Menu yang Dipilih" }, - { "Primary2", "Utama 2" }, - { "Primary3Info", "Table Selected Row, Selected Text, ToolTip Background" }, - { "Primary3", "Utama 3" }, - { "Secondary1Info", "Border Lines" }, - { "Secondary1", "Sekunder 1" }, - { "Secondary2Info", "Inactive Tabs, Pressed Fields, Inactive Border + Text" }, - { "Secondary2", "Sekunder 2" }, - { "Secondary3Info", "Background" }, - { "Secondary3", "Sekunder 3" }, - // - { "ControlFontInfo", "Control Font" }, - { "ControlFont", "Label Font" }, - { "SystemFontInfo", "Tool Tip, Tree nodes" }, - { "SystemFont", "System Font" }, - { "UserFontInfo", "User Entered Data" }, - { "UserFont", "Field Font" }, -// { "SmallFontInfo", "Reports" }, - { "SmallFont", "Small Font" }, - { "WindowTitleFont", "Title Font" }, - { "MenuFont", "Menu Font" }, - // - { "MandatoryInfo", "Mandatory Field Background" }, - { "Mandatory", "Mandatory" }, - { "ErrorInfo", "Error Field Background" }, - { "Error", "Error" }, - { "InfoInfo", "Info Field Background" }, - { "Info", "Info" }, - { "WhiteInfo", "Lines" }, - { "White", "Putih" }, - { "BlackInfo", "Lines, Text" }, - { "Black", "Hitam" }, - { "InactiveInfo", "Inactive Field Background" }, - { "Inactive", "Inactive" }, - { "TextOKInfo", "OK Text Foreground" }, - { "TextOK", "Text - OK" }, - { "TextIssueInfo", "Error Text Foreground" }, - { "TextIssue", "Text - Error" }, - // - { "FontChooser", "Font Chooser" }, - { "Fonts", "Fonts" }, - { "Plain", "Plain" }, - { "Italic", "Italic" }, - { "Bold", "Bold" }, - { "BoldItalic", "Bold & Italic" }, - { "Name", "Nama" }, - { "Size", "Ukuran" }, - { "Style", "Gaya" }, - { "TestString", "This is just a Test! The quick brown Fox is doing something. 12,3456.78 LetterLOne = l1 LetterOZero = O0" }, - { "FontString", "Font" }, - // - { "AdempiereColorEditor", "Editor Warna Adempiere" }, - { "AdempiereType", "Tipe Warna" }, - { "GradientUpperColor", "Warna Atas Gradien" }, - { "GradientLowerColor", "Warna Bawah Gradien" }, - { "GradientStart", "Mulai Gradien" }, - { "GradientDistance", "Jarak Gradien" }, - { "TextureURL", "Textur URL" }, - { "TextureAlpha", "Textur Alpha" }, - { "TextureTaintColor", "Textur Warna Taint" }, - { "LineColor", "Warna Baris" }, - { "LineBackColor", "Warna Latar Belakang" }, - { "LineWidth", "Lebar Baris" }, - { "LineDistance", "Jarak Baris" }, - { "FlatColor", "Warna Flat" } - }; - - /** - * Get Contents - * @return contents - */ - public Object[][] getContents() - { - return contents; - } -} // Res diff --git a/org.adempiere.ui.swing/src/org/compiere/plaf/PlafRes_it.java b/org.adempiere.ui.swing/src/org/compiere/plaf/PlafRes_it.java deleted file mode 100644 index bffb116159..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/plaf/PlafRes_it.java +++ /dev/null @@ -1,213 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ -package org.compiere.plaf; - -import java.util.ListResourceBundle; - -/** - * Translation Texts for Look & Feel - * - * @author Gabriele Vivinetto - gabriele.mailing@rvmgroup.it - * @version $Id: PlafRes_it.java,v 1.2 2006/07/30 00:52:24 jjanke Exp $ - */ -public class PlafRes_it extends ListResourceBundle -{ - /** The data */ - static final Object[][] contents = new String[][] - { - //{ "BackColType", "Background Color Type" }, - { "BackColType", "Tipo Colore di Sfondo" }, - //{ "BackColType_Flat", "Flat" }, - { "BackColType_Flat", "Piatto" }, - //{ "BackColType_Gradient", "Gradient" }, - { "BackColType_Gradient", "Gradiente" }, - //{ "BackColType_Lines", "Lines" }, - { "BackColType_Lines", "Linee" }, - //{ "BackColType_Texture", "Texture" }, //Need to be checked. How to translate "Texture" ? - { "BackColType_Texture", "Texture" }, - // - //{ "LookAndFeelEditor", "Look & Feel Editor" }, //Need to be checked - { "LookAndFeelEditor", "Editor aspetto" }, - //{ "LookAndFeel", "Look & Feel" }, - { "LookAndFeel", "Aspetto" }, - //{ "Theme", "Theme" }, - { "Theme", "Tema" }, - //{ "EditAdempiereTheme", "Edit Adempiere Theme" }, //Need to be checked - { "EditAdempiereTheme", "Modifica Tema di Adempiere" }, - //{ "SetDefault", "Default Background" }, - { "SetDefault", "Sfondo di Default" }, - //{ "SetDefaultColor", "Background Color" }, - { "SetDefaultColor", "Colore di Sfondo" }, - //{ "ColorBlind", "Color Deficiency" }, //Need to be checked - { "ColorBlind", "Mancanza di Colore" }, - //{ "Example", "Example" }, - { "Example", "Esempio" }, - //{ "Reset", "Reset" }, //Need to be checked - { "Reset", "Resetta" }, - //{ "OK", "OK" }, - { "OK", "OK" }, - //{ "Cancel", "Cancel" }, - { "Cancel", "Cancella" }, - // - //{ "AdempiereThemeEditor", "Adempiere Theme Editor" }, //Need to be checked - { "AdempiereThemeEditor", "Editor di Tema Adempiere" }, - //{ "MetalColors", "Metal Colors" }, - { "MetalColors", "Colori Metallici" }, - //{ "AdempiereColors", "Adempiere Colors" }, - { "AdempiereColors", "Colori di Adempiere" }, - //{ "AdempiereFonts", "Adempiere Fonts" }, //Need to be checked. Mantain the word "Font" ? - { "AdempiereFonts", "Caratteri di Adempiere" }, - //{ "Primary1Info", "Shadow, Separator" }, //Need to be checked - { "Primary1Info", "Ombra, Separatore" }, - //{ "Primary1", "Primary 1" }, - { "Primary1", "Primario 1" }, - //{ "Primary2Info", "Focus Line, Selected Menu" }, //Need to be checked - { "Primary2Info", "Linea di Selezione, Menu Selezionato" }, - //{ "Primary2", "Primary 2" }, - { "Primary2", "Primario 2" }, - //{ "Primary3Info", "Table Selected Row, Selected Text, ToolTip Background" }, //Need to be checked - { "Primary3Info", "Riga di Tabella Selezionata, Testo Selezionato, Sfondo ToolTip " }, - //{ "Primary3", "Primary 3" }, - { "Primary3", "Primario 3" }, - //{ "Secondary1Info", "Border Lines" }, - { "Secondary1Info", "Linee di Bordo" }, - //{ "Secondary1", "Secondary 1" }, - { "Secondary1", "Secondario 1" }, - //{ "Secondary2Info", "Inactive Tabs, Pressed Fields, Inactive Border + Text" }, //Need to be checked - { "Secondary2Info", "Tab inattive, Campi selezionati, Bordo + Testo inattivo" }, - //{ "Secondary2", "Secondary 2" }, - { "Secondary2", "Secondario 2" }, - //{ "Secondary3Info", "Background" }, - { "Secondary3Info", "Sfondo" }, - //{ "Secondary3", "Secondary 3" }, - { "Secondary3", "Secondario 3" }, - // - //{ "ControlFontInfo", "Control Font" }, //Need to be checked - { "ControlFontInfo", "Font di Controllo" }, - //{ "ControlFont", "Label Font" }, //Need to be checked - { "ControlFont", "Font di Etichetta" }, - //{ "SystemFontInfo", "Tool Tip, Tree nodes" }, //Need to be checked - { "SystemFontInfo", "Tool Tip, Nodi ad Albero" }, - //{ "SystemFont", "System Font" }, //Need to be checked - { "SystemFont", "Carattere di Sistema" }, - //{ "UserFontInfo", "User Entered Data" }, - { "UserFontInfo", "Dati immessi dall'utente" }, - //{ "UserFont", "Field Font" }, //Need to be checked - { "UserFont", "Carattere del Campo" }, -// { "SmallFontInfo", "Reports" }, - //{ "SmallFont", "Small Font" }, //Need to be checked - { "SmallFont", "Carattere piccolo" }, - //{ "WindowTitleFont", "Title Font" }, //Need to be checked - { "WindowTitleFont", "Carattere Titolo" }, - //{ "MenuFont", "Menu Font" }, //Need to be checked - { "MenuFont", "Carattere Menu" }, - // - //{ "MandatoryInfo", "Mandatory Field Background" }, - { "MandatoryInfo", "Sfondo Campo Obbligatorio" }, - //{ "Mandatory", "Mandatory" }, - { "Mandatory", "Obbligatorio" }, - //{ "ErrorInfo", "Error Field Background" }, - { "ErrorInfo", "Sfondo Campo di Errore" }, - //{ "Error", "Error" }, - { "Error", "Errore" }, - //{ "InfoInfo", "Info Field Background" }, //Need to be checked. Is it better "Informativo" ? What with the following ? - { "InfoInfo", "Sfondo Campo Informazione" }, - //{ "Info", "Info" }, - { "Info", "Informazione" }, - //{ "WhiteInfo", "Lines" }, - { "WhiteInfo", "Linee" }, - //{ "White", "White" }, - { "White", "Bianco" }, - //{ "BlackInfo", "Lines, Text" }, - { "BlackInfo", "Linee, Testo" }, - //{ "Black", "Black" }, - { "Black", "Nero" }, - //{ "InactiveInfo", "Inactive Field Background" }, - { "InactiveInfo", "Sfondo Campo Inattivo" }, - //{ "Inactive", "Inactive" }, - { "Inactive", "Inattivo" }, - //{ "TextOKInfo", "OK Text Foreground" }, //Need to be checked. How to translate Foreground ? - { "TextOKInfo", "Colore Testo OK" }, - //{ "TextOK", "Text - OK" }, //Need to be checked - { "TextOK", "Testo - OK" }, - //{ "TextIssueInfo", "Error Text Foreground" }, //Need to be checked - { "TextIssueInfo", "Colore Testo di Errore" }, - //{ "TextIssue", "Text - Error" }, - { "TextIssue", "Testo - Error" }, - // - //{ "FontChooser", "Font Chooser" }, //Need to be checked - { "FontChooser", "Selezionatore Carattere" }, - //{ "Fonts", "Fonts" }, //Need to be checked - { "Fonts", "Caratteri" }, - //{ "Plain", "Plain" }, //Need to be checked - { "Plain", "Normale" }, - //{ "Italic", "Italic" }, - { "Italic", "Corsivo" }, - //{ "Bold", "Bold" }, - { "Bold", "Grassetto" }, - //{ "BoldItalic", "Bold & Italic" }, - { "BoldItalic", "Grassetto & Corsivo" }, - //{ "Name", "Name" }, - { "Name", "Nome" }, - //{ "Size", "Size" }, - { "Size", "Dimensione" }, - //{ "Style", "Style" }, - { "Style", "Stile" }, - //{ "TestString", "This is just a Test! The quick brown Fox is doing something. 12,3456.78 LetterLOne = l1 LetterOZero = O0" }, - { "TestString", "Questo ïżœ solo un Test! La veloce volpe marrone stïżœ facendo qualcosa. 12,3456.78 LetteraLUno = l1 LetteraOZero = O0" }, - //{ "FontString", "Font" }, - { "FontString", "Carattere" }, //Need to be checked - // - //{ "AdempiereColorEditor", "Adempiere Color Editor" }, //Need to be checked - { "AdempiereColorEditor", "Editor di Colori Adempiere" }, - //{ "AdempiereType", "Color Type" }, - { "AdempiereType", "Tipo Colore" }, - //{ "GradientUpperColor", "Gradient Upper Color" }, - { "GradientUpperColor", "Colore Gradiente Superiore" }, - //{ "GradientLowerColor", "Gradient Lower Color" }, - { "GradientLowerColor", "Colore Gradiente Inferiore" }, - //{ "GradientStart", "Gradient Start" }, - { "GradientStart", "Inizio Gradiente" }, - //{ "GradientDistance", "Gradient Distance" }, - { "GradientDistance", "Distanza Gradiente" }, - //{ "TextureURL", "Texture URL" }, //Need to be checked. How to translate "Texture" ? - { "TextureURL", "URL Texture" }, - //{ "TextureAlpha", "Texture Alpha" }, //Need to be checked. How to translate ? - { "TextureAlpha", "Texture Alpha" }, - //{ "TextureTaintColor", "Texture Taint Color" }, //Need to be checked. How to translate ? - { "TextureTaintColor", "Texture Taint Color" }, - //{ "LineColor", "Line Color" }, - { "LineColor", "Colore Linea" }, - //{ "LineBackColor", "Background Color" }, - { "LineBackColor", "Colore Sfondo" }, - //{ "LineWidth", "Line Width" }, - { "LineWidth", "Spessore Linea" }, - //{ "LineDistance", "Line Distance" }, - { "LineDistance", "Distanza Linea" }, - //{ "FlatColor", "Flat Color" } - { "FlatColor", "Colore Piatto" } - }; - - /** - * Get Contents - * @return contents - */ - public Object[][] getContents() - { - return contents; - } -} // Res diff --git a/org.adempiere.ui.swing/src/org/compiere/plaf/PlafRes_ja.java b/org.adempiere.ui.swing/src/org/compiere/plaf/PlafRes_ja.java deleted file mode 100644 index 47e9ea45f8..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/plaf/PlafRes_ja.java +++ /dev/null @@ -1,131 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ -package org.compiere.plaf; - -import java.util.ListResourceBundle; - -/** - * Translation Texts for Look & Feel - * - * @author Stefan Christians - * @version $Id: PlafRes_ja.java,v 1.2 2006/07/30 00:52:24 jjanke Exp $ - */ -public class PlafRes_ja extends ListResourceBundle -{ - /** The data */ - static final Object[][] contents = new String[][] - { - { "BackColType", "\u80cc\u666f\u306e\u30b9\u30bf\u30a4\u30eb" }, - { "BackColType_Flat", "\u5358\u8272" }, - { "BackColType_Gradient", "\u30b0\u30e9\u30c7\u30fc\u30b7\u30e7\u30f3" }, - { "BackColType_Lines", "\u30e9\u30a4\u30f3" }, - { "BackColType_Texture", "\u30c6\u30ad\u30b9\u30c1\u30e3\u30fc" }, - // - { "LookAndFeelEditor", "\u5916\u89b3\u4fee\u6b63" }, - { "LookAndFeel", "\u5916\u89b3" }, - { "Theme", "\u30c6\u30fc\u30de" }, - { "EditAdempiereTheme", "\u30a2\u30c7\u30f3\u30d4\u30a8\u30fc\u30ec\u306e\u30c6\u30fc\u30de\u4fee\u6b63" }, - { "SetDefault", "\u30c7\u30d5\u30a9\u30eb\u30c8\u3092\u8a2d\u5b9a" }, - { "SetDefaultColor", "\u30c7\u30d5\u30a9\u30eb\u30c8\u8272\u3092\u8a2d\u5b9a" }, - { "ColorBlind", "\u80cc\u666f\u8272" }, - { "Example", "\u4f8b" }, - { "Reset", "\u30ea\u30bb\u30c3\u30c8" }, - { "OK", "OK" }, - { "Cancel", "\u30ad\u30e3\u30f3\u30bb\u30eb" }, - // - { "AdempiereThemeEditor", "\u30a2\u30c7\u30f3\u30d4\u30a8\u30fc\u30ec\u30c6\u30fc\u30de\u4fee\u6b63" }, - { "MetalColors", "\u30e1\u30bf\u30eb\u8abf" }, - { "AdempiereColors", "\u30a2\u30c7\u30f3\u30d4\u30a8\u30fc\u30ec\u306e\u8272" }, - { "AdempiereFonts", "\u30a2\u30c7\u30f3\u30d4\u30a8\u30fc\u30ec\u306e\u30d5\u30a9\u30f3\u30c8" }, - { "Primary1Info", "\u5f71\u3001\u30bb\u30d1\u30ec\u30fc\u30bf" }, - { "Primary1", "\u4e00\u756a\u76ee\u306e1" }, - { "Primary2Info", "\u30d5\u30a9\u30fc\u30ab\u30b9\u304c\u6709\u308b\u30e9\u30a4\u30f3\u3001\u9078\u629e\u3057\u305f\u30e1\u30cb\u30e5\u30fc" }, - { "Primary2", "\u4e00\u756a\u76ee\u306e2" }, - { "Primary3Info", "\u9078\u629e\u3057\u305f\u30c6\u30fc\u30d6\u30eb\u306e\u884c\u3001\u9078\u629e\u3057\u305f\u30c6\u30ad\u30b9\u30c8\u3001\u30c4\u30fc\u30eb\u30fb\u30c1\u30c3\u30d7\u306e\u80cc\u666f" }, - { "Primary3", "\u4e00\u756a\u76ee\u306e3" }, - { "Secondary1Info", "\u5883\u754c\u7dda" }, - { "Secondary1", "\u4e8c\u756a\u76ee\u306e1" }, - { "Secondary2Info", "\u4e0d\u6d3b\u6027\u30bf\u30d6\u3001\u62bc\u4e0b\u3057\u305f\u30d5\u30a3\u30fc\u30eb\u30c9\u3001\u4e0d\u6d3b\u6027\u5883\u754c\u3068\u30c6\u30ad\u30b9\u30c8" }, - { "Secondary2", "\u4e8c\u756a\u76ee\u306e2" }, - { "Secondary3Info", "\u80cc\u666f" }, - { "Secondary3", "\u4e8c\u756a\u76ee\u306e3" }, - // - { "ControlFontInfo", "\u30b3\u30f3\u30c8\u30ed\u30fc\u30eb\u306e\u30d5\u30a9\u30f3\u30c8" }, - { "ControlFont", "\u30e9\u30d9\u30eb\u306e\u30d5\u30a9\u30f3\u30c8" }, - { "SystemFontInfo", "\u30c4\u30fc\u30eb\u30fb\u30c1\u30c3\u30d7\u3001\u30c4\u30ea\u30fc" }, - { "SystemFont", "\u30b7\u30b9\u30c6\u30e0\u30d5\u30a9\u30f3\u30c8" }, - { "UserFontInfo", "\u30e6\u30fc\u30b6\u304c\u5165\u529b\u3057\u305f\u30c7\u30fc\u30bf" }, - { "UserFont", "\u30d5\u30a3\u30fc\u30eb\u30c9\u30d5\u30a9\u30f3\u30c8" }, -// { "SmallFontInfo", "\u30ec\u30dd\u30fc\u30c8" }, - { "SmallFont", "\u5c0f\u30d5\u30a9\u30f3\u30c8" }, - { "WindowTitleFont", "\u30bf\u30a4\u30c8\u30eb\u30d5\u30a9\u30f3\u30c8" }, - { "MenuFont", "\u30e1\u30cb\u30e5\u30fc\u30d5\u30a9\u30f3\u30c8" }, - // - { "MandatoryInfo", "\u5fc5\u9808\u30d5\u30a3\u30fc\u30eb\u30c9\u306e\u80cc\u666f" }, - { "Mandatory", "\u5fc5\u9808" }, - { "ErrorInfo", "\u30a8\u30e9\u30fc\u30fb\u30d5\u30a3\u30fc\u30eb\u30c9\u306e\u80cc\u666f" }, - { "Error", "\u30a8\u30e9\u30fc" }, - { "InfoInfo", "\u60c5\u5831\u30fb\u30d5\u30a3\u30fc\u30eb\u30c9\u306e\u80cc\u666f" }, - { "Info", "\u60c5\u5831" }, - { "WhiteInfo", "\u30e9\u30a4\u30f3" }, - { "White", "\u767d" }, - { "BlackInfo", "\u30e9\u30a4\u30f3\u3068\u30c6\u30ad\u30b9\u30c8" }, - { "Black", "\u9ed2" }, - { "InactiveInfo", "\u4e0d\u6d3b\u6027\u30d5\u30a3\u30fc\u30eb\u30c9\u306e\u80cc\u666f" }, - { "Inactive", "\u4e0d\u6d3b\u6027" }, - { "TextOKInfo", "OK\u30fb\u30c6\u30ad\u30b9\u30c8\u306e\u524d\u666f" }, - { "TextOK", "\u30c6\u30ad\u30b9\u30c8 - OK" }, - { "TextIssueInfo", "\u30a8\u30e9\u30fc\u30fb\u30c6\u30ad\u30b9\u30c8\u306e\u524d\u666f" }, - { "TextIssue", "\u30c6\u30ad\u30b9\u30c8 - \u30a8\u30e9\u30fc" }, - // - { "FontChooser", "\u30d5\u30a9\u30f3\u30c8\u306e\u9078\u629e" }, - { "Fonts", "\u30d5\u30a9\u30f3\u30c8" }, - { "Plain", "\u666e\u901a" }, - { "Italic", "\u659c\u4f53" }, - { "Bold", "\u592a\u5b57" }, - { "BoldItalic", "\u592a\u5b57\u3068\u659c\u4f53" }, - { "Name", "\u30d5\u30a1\u30df\u30ea" }, - { "Size", "\u30b5\u30a4\u30ba" }, - { "Style", "\u30b9\u30bf\u30a4\u30eb" }, - { "TestString", "This is just a Test! The quick brown Fox is doing something. 12,3456.78 LetterLOne = l1 LetterOZero = O0" }, - { "FontString", "\u30d5\u30a9\u30f3\u30c8" }, - // - { "AdempiereColorEditor", "\u30a2\u30c7\u30f3\u30d4\u30a8\u30fc\u30ec\u8272\u4fee\u6b63" }, - { "AdempiereType", "\u8272\u578b" }, - { "GradientUpperColor", "\u30b0\u30e9\u30c7\u30fc\u30b7\u30e7\u30f3\u306e\u4e0a\u306e\u8272" }, - { "GradientLowerColor", "\u30b0\u30e9\u30c7\u30fc\u30b7\u30e7\u30f3\u306e\u4e0b\u306e\u8272" }, - { "GradientStart", "\u30b0\u30e9\u30c7\u30fc\u30b7\u30e7\u30f3\u306e" }, - { "GradientDistance", "\u30b0\u30e9\u30c7\u30fc\u30b7\u30e7\u30f3\u306e\u8ddd\u96e2" }, - { "TextureURL", "\u30c6\u30ad\u30b9\u30c1\u30e3\u30fc\u306eURL" }, - { "TextureAlpha", "\u30c6\u30ad\u30b9\u30c1\u30e3\u30fc\u306e\u03b1\u5024" }, - { "TextureTaintColor", "\u30c6\u30ad\u30b9\u30c1\u30e3\u30fc\u306e\u6c5a\u308c\u8272" }, - { "LineColor", "\u30e9\u30a4\u30f3\u306e\u8272" }, - { "LineBackColor", "\u30e9\u30a4\u30f3\u306e\u80cc\u666f\u8272" }, - { "LineWidth", "\u30e9\u30a4\u30f3\u306e\u5e45" }, - { "LineDistance", "\u30e9\u30a4\u30f3\u306e\u8ddd\u96e2" }, - { "FlatColor", "\u5358\u8272" } - }; - - /** - * Get Contents - * @return contents - */ - public Object[][] getContents() - { - return contents; - } -} // Res diff --git a/org.adempiere.ui.swing/src/org/compiere/plaf/PlafRes_ms.java b/org.adempiere.ui.swing/src/org/compiere/plaf/PlafRes_ms.java deleted file mode 100644 index 846667791e..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/plaf/PlafRes_ms.java +++ /dev/null @@ -1,131 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ -package org.compiere.plaf; - -import java.util.ListResourceBundle; - -/** - * Translation Texts for Look & Feel - * - * @author Robin Hoo, Redhuan D. Oon (OPEN FIX SDN BHD - 2003) - * @version $Id: PlafRes_ms.java,v 1.2 2006/07/30 00:52:23 jjanke Exp $ - */ -public class PlafRes_ms extends ListResourceBundle -{ - /** The data */ - static final Object[][] contents = new String[][] - { - { "BackColType", "Jenis Warna Latar Belakang" }, - { "BackColType_Flat", "Leper" }, - { "BackColType_Gradient", "Gradient" }, - { "BackColType_Lines", "Garisan" }, - { "BackColType_Texture", "Texture" }, - // - { "LookAndFeelEditor", "Bentuk Paparan Editor" }, - { "LookAndFeel", "Bentuk Paparan" }, - { "Theme", "Tema" }, - { "EditAdempiereTheme", "Edit Tema Adempiere" }, - { "SetDefault", "Default LatarBelakang" }, - { "SetDefaultColor", "Warna LatarBelankang" }, - { "ColorBlind", "Kecacatan Warna" }, - { "Example", "Contoh" }, - { "Reset", "Reset" }, - { "OK", "OK" }, - { "Cancel", "Batal" }, - // - { "AdempiereThemeEditor", "Tema Adempiere Editor" }, - { "MetalColors", "Warna Metal" }, - { "AdempiereColors", "Warna Adempiere" }, - { "AdempiereFonts", "Adempiere Fonts" }, - { "Primary1Info", "Bayang, Pemisah" }, - { "Primary1", "Primary 1" }, - { "Primary2Info", "Garisan Fokus, Menu Terpilih" }, - { "Primary2", "Primary 2" }, - { "Primary3Info", "Table Selected Row, Selected Text, ToolTip Background" }, - { "Primary3", "Primary 3" }, - { "Secondary1Info", "Garis Sempadan" }, - { "Secondary1", "Menengah 1" }, - { "Secondary2Info", "Tab Tak Aktif, Medan Tertekan, Sempadan Tak Aktif + Teks" }, - { "Secondary2", "Menengah 2" }, - { "Secondary3Info", "LatarBelakang" }, - { "Secondary3", "Menengah 3" }, - // - { "ControlFontInfo", "Fon Kawalan" }, - { "ControlFont", "Fon Label" }, - { "SystemFontInfo", "Tool Tip, Tree nodes" }, - { "SystemFont", "Fon Sistem" }, - { "UserFontInfo", "User Entered Data" }, - { "UserFont", "Fon Medan" }, -// { "SmallFontInfo", "Reports" }, - { "SmallFont", "Fon Kecil" }, - { "WindowTitleFont", "Fon Tajuk" }, - { "MenuFont", "Fon Menu" }, - // - { "MandatoryInfo", "Medan LatarBelakang Wajib" }, - { "Mandatory", "Wajib" }, - { "ErrorInfo", "Error Field LatarBelakang" }, - { "Error", "Error" }, - { "InfoInfo", "Info Field Background" }, - { "Info", "Info" }, - { "WhiteInfo", "Garisan" }, - { "White", "Putih" }, - { "BlackInfo", "Garisan, Teks" }, - { "Black", "Hitam" }, - { "InactiveInfo", "Inactive Field Background" }, - { "Inactive", "Tak Aktif" }, - { "TextOKInfo", "OK Text Foreground" }, - { "TextOK", "Teks - OK" }, - { "TextIssueInfo", "Error Text Foreground" }, - { "TextIssue", "Teks - Error" }, - // - { "FontChooser", "Pemilih Fon" }, - { "Fonts", "Fon" }, - { "Plain", "Biasa" }, - { "Italic", "Italic" }, - { "Bold", "Bold" }, - { "BoldItalic", "Bold & Italic" }, - { "Name", "Nama" }, - { "Size", "Saiz" }, - { "Style", "Stail" }, - { "TestString", "Ini cuma ujian! The quick brown Fox is doing something. 12,3456.78 LetterLOne = l1 LetterOZero = O0" }, - { "FontString", "Fon" }, - // - { "AdempiereColorEditor", "Adempiere Color Editor" }, - { "AdempiereType", "Jenis Warna" }, - { "GradientUpperColor", "Gradient Upper Color" }, - { "GradientLowerColor", "Gradient Lower Color" }, - { "GradientStart", "Gradient Start" }, - { "GradientDistance", "Gradient Distance" }, - { "TextureURL", "Texture URL" }, - { "TextureAlpha", "Texture Alpha" }, - { "TextureTaintColor", "Texture Taint Color" }, - { "LineColor", "Warna Garisan" }, - { "LineBackColor", "Warna LatarBelakang" }, - { "LineWidth", "Lebar Garisan" }, - { "LineDistance", "Jarak Garisan" }, - { "FlatColor", "Warna Leper" } - }; - - /** - * Get Contents - * @return contents - */ - public Object[][] getContents() - { - return contents; - } -} // Res diff --git a/org.adempiere.ui.swing/src/org/compiere/plaf/PlafRes_nl.java b/org.adempiere.ui.swing/src/org/compiere/plaf/PlafRes_nl.java deleted file mode 100644 index bf70ef7646..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/plaf/PlafRes_nl.java +++ /dev/null @@ -1,132 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ -package org.compiere.plaf; - -import java.util.ListResourceBundle; - -/** - * Translation Texts for Look & Feel - * - * @author Eldir Tomassen - * @version $Id: PlafRes_nl.java,v 1.2 2006/07/30 00:52:23 jjanke Exp $ - */ -public class PlafRes_nl extends ListResourceBundle -{ - /** The data */ - static final Object[][] contents = new String[][] - { - { "BackColType", "Achtergrond Kleur Type" }, - { "BackColType_Flat", "Egaal" }, - { "BackColType_Gradient", "Verloop" }, - { "BackColType_Lines", "Lijnen" }, - { "BackColType_Texture", "Reliïżœf" }, - // - { "LookAndFeelEditor", "Look & Feel Editor" }, - { "LookAndFeel", "Look & Feel" }, - { "Theme", "Thema" }, - { "EditAdempiereTheme", "Adempiere Theme Bewerken" }, - { "SetDefault", "Standaard Achtergrond" }, - { "SetDefaultColor", "Achtergrond Kleur" }, - { "ColorBlind", "Kleur Verloop" }, - { "Example", "Voorbeeld" }, - { "Reset", "Ongedaan maken" }, - { "OK", "OK" }, - { "Cancel", "Annuleren" }, - // - { "AdempiereThemeEditor", "Adempiere Thema Editor" }, - { "MetalColors", "Metaal Kleuren" }, - { "AdempiereColors", "Adempiere Kleuren" }, - { "AdempiereFonts", "Adempiere Lettertypen" }, - { "Primary1Info", "Shaduw, Schijdingsteken" }, - { "Primary1", "Primair 1" }, - { "Primary2Info", "Schijdingslijn, Geselecteerd Menu" }, - { "Primary2", "Primair 2" }, - { "Primary3Info", "Tabel Geselecteerde Rij, Geselecteerde Tekst, ToolTip Achtergrond" }, - { "Primary3", "Primair 3" }, - { "Secondary1Info", "Begrenzing Lijnen" }, - { "Secondary1", "Secundair 2" }, - { "Secondary2Info", "Inactieve Tabs, Geselecteerde Velden, Inactieve Begrenzing + Tekst" }, - { "Secondary2", "Secundait 2" }, - { "Secondary3Info", "Achtergrond" }, - { "Secondary3", "Secondair 3" }, - // - { "ControlFontInfo", "Beheer Lettertype" }, - { "ControlFont", "Label Lettertype" }, - { "SystemFontInfo", "Tool Tip, Boom Iconen" }, - { "SystemFont", "Systeem Letterype" }, - { "UserFontInfo", "Door Gebruiker ingevoerde gegevens" }, - { "UserFont", "Veld Lettertype" }, -// { "SmallFontInfo", "Reports" }, - { "SmallFont", "Klein Lettertype" }, - { "WindowTitleFont", "Titel Lettertype" }, - { "MenuFont", "Menu Lettertype" }, - // - { "MandatoryInfo", "Verplicht Veld Achtergrond" }, - { "Mandatory", "Verplicht" }, - { "ErrorInfo", "Foutief Veld Achtergrond" }, - { "Error", "Foutief" }, - { "InfoInfo", "Informatie Veld Achtergrond" }, - { "Info", "Informatie" }, - { "WhiteInfo", "Lijnen" }, - { "White", "Wit" }, - { "BlackInfo", "Lijnen, Tekst" }, - { "Black", "Zwart" }, - { "InactiveInfo", "Inactief Veld Achtergrond" }, - { "Inactive", "Inactief" }, - { "TextOKInfo", "OK Tekst Voorgrond" }, - { "TextOK", "Tekst - OK" }, - { "TextIssueInfo", "Foutief Tekst Voorgrond" }, - { "TextIssue", "Tekst - Foutief" }, - // - { "FontChooser", "Lettertype Selecteren" }, - { "Fonts", "Lettertypen" }, - { "Plain", "Normaal" }, - { "Italic", "Schuin" }, - { "Bold", "Vet" }, - { "BoldItalic", "Vet & Schuin" }, - { "Name", "Naam" }, - { "Size", "Formaat" }, - { "Style", "Stijl" }, - { "TestString", "Dit is een test! De thema brwoser is bezig. 12,3456.78 LetterLOne = l1 LetterOZero = O0" }, - { "FontString", "Lettertype" }, - // - { "AdempiereColorEditor", "Adempiere Kleur Editor" }, - { "AdempiereType", "Kleur Type" }, - { "GradientUpperColor", "Verloop Bovenste Kleur" }, - { "GradientLowerColor", "Verloop Onderste Kleur" }, - { "GradientStart", "Verloop Start" }, - { "GradientDistance", "Verloop Afstand" }, - { "TextureURL", "Textuur URL" }, - { "TextureAlpha", "Textuur Alpha" }, - { "TextureTaintColor", "Textuur Taint Kleur" }, - { "LineColor", "Lijn Kleur" }, - { "LineBackColor", "Achtergrond Kleur" }, - { "LineWidth", "Lijn Breedte" }, - { "LineDistance", "Lijn Reikwijdte" }, - { "FlatColor", "Egale Kleur" } - }; - - /** - * Get Contents - * @return contents - */ - public Object[][] getContents() - { - return contents; - } -} // Res - diff --git a/org.adempiere.ui.swing/src/org/compiere/plaf/PlafRes_no.java b/org.adempiere.ui.swing/src/org/compiere/plaf/PlafRes_no.java deleted file mode 100644 index 0429c2f04b..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/plaf/PlafRes_no.java +++ /dev/null @@ -1,131 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ -package org.compiere.plaf; - -import java.util.ListResourceBundle; - -/** - * Norwegian Translation Texts for Look & Feel - * - * @author Olaf Slazak Lïżœken - * @version $Id: PlafRes_no.java,v 1.2 2006/07/30 00:52:24 jjanke Exp $ - */ -public class PlafRes_no extends ListResourceBundle -{ - /** The data */ - static final Object[][] contents = new String[][] - { - { "BackColType", "Bakgrunns Farge Type" }, - { "BackColType_Flat", "Flat" }, - { "BackColType_Gradient", "Gradient" }, - { "BackColType_Lines", "Linjer" }, - { "BackColType_Texture", "Texture" }, - // - { "LookAndFeelEditor", "Utseende Egenskaper" }, - { "LookAndFeel", "Utseende" }, - { "Theme", "Sjanger" }, - { "EditAdempiereTheme", "Rediger Adempiere Sjanger" }, - { "SetDefault", "Standard Bakgrunn" }, - { "SetDefaultColor", "Bakgrunn Farge" }, - { "ColorBlind", "Farge Deficiency" }, - { "Example", "Eksempel" }, - { "Reset", "Angre" }, - { "OK", "OK" }, - { "Cancel", "Avbryt" }, - // - { "AdempiereThemeEditor", "Rediger Adempiere Sjanger" }, - { "MetalColors", "Metal Farger" }, - { "AdempiereColors", "Adempiere Farger" }, - { "AdempiereFonts", "Adempiere Fonter" }, - { "Primary1Info", "Sygger, Separator" }, - { "Primary1", "Primary 1" }, - { "Primary2Info", "Fokus Linje, Valgte " }, - { "Primary2", "Primary 2" }, - { "Primary3Info", "Table Selected Row, Selected Text, ToolTip Background" }, - { "Primary3", "Primary 3" }, - { "Secondary1Info", "Border Lines" }, - { "Secondary1", "Secondary 1" }, - { "Secondary2Info", "Inactive Tabs, Pressed Fields, Inactive Border + Text" }, - { "Secondary2", "Secondary 2" }, - { "Secondary3Info", "Background" }, - { "Secondary3", "Secondary 3" }, - // - { "ControlFontInfo", "Kontrol Font" }, - { "ControlFont", "Label Font" }, - { "SystemFontInfo", "Systemets Font Info" }, - { "SystemFont", "Systemets Fonter" }, - { "UserFontInfo", "Bruker Innlagt Data" }, - { "UserFont", "Felt Fonter" }, -// { "SmallFontInfo", "Reports" }, - { "SmallFont", "Smïżœ Fonter" }, - { "WindowTitleFont", "Titell Fonter" }, - { "MenuFont", "Meny Fonter" }, - // - { "MandatoryInfo", "Mandatory Field Background" }, - { "Mandatory", "Mandatory" }, - { "ErrorInfo", "Error Field Background" }, - { "Error", "Error" }, - { "InfoInfo", "Info Field Background" }, - { "Info", "Info" }, - { "WhiteInfo", "Lines" }, - { "White", "White" }, - { "BlackInfo", "Lines, Text" }, - { "Black", "Black" }, - { "InactiveInfo", "Inactive Field Background" }, - { "Inactive", "Inactive" }, - { "TextOKInfo", "OK Text Foreground" }, - { "TextOK", "Text - OK" }, - { "TextIssueInfo", "Error Text Foreground" }, - { "TextIssue", "Text - Error" }, - // - { "FontChooser", "Font Chooser" }, - { "Fonts", "Fonts" }, - { "Plain", "Plain" }, - { "Italic", "Italic" }, - { "Bold", "Bold" }, - { "BoldItalic", "Bold & Italic" }, - { "Name", "Name" }, - { "Size", "Size" }, - { "Style", "Style" }, - { "TestString", "This is just a Test! The quick brown Fox is doing something. 12,3456.78 LetterLOne = l1 LetterOZero = O0" }, - { "FontString", "Font" }, - // - { "AdempiereColorEditor", "Adempiere Color Editor" }, - { "AdempiereType", "Color Type" }, - { "GradientUpperColor", "Gradient Upper Color" }, - { "GradientLowerColor", "Gradient Lower Color" }, - { "GradientStart", "Gradient Start" }, - { "GradientDistance", "Gradient Distance" }, - { "TextureURL", "Texture URL" }, - { "TextureAlpha", "Texture Alpha" }, - { "TextureTaintColor", "Texture Taint Color" }, - { "LineColor", "Line Color" }, - { "LineBackColor", "Background Color" }, - { "LineWidth", "Line Width" }, - { "LineDistance", "Line Distance" }, - { "FlatColor", "Flat Color" } - }; - - /** - * Get Contents - * @return contents - */ - public Object[][] getContents() - { - return contents; - } -} // Res diff --git a/org.adempiere.ui.swing/src/org/compiere/plaf/PlafRes_pl.java b/org.adempiere.ui.swing/src/org/compiere/plaf/PlafRes_pl.java deleted file mode 100644 index c14103b915..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/plaf/PlafRes_pl.java +++ /dev/null @@ -1,130 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ -package org.compiere.plaf; - -import java.util.ListResourceBundle; - -/** - * Translation Texts for Look & Feel - * - * @author Adam Bodurka - * @version $Id: PlafRes_pl.java,v 1.2 2006/07/30 00:52:24 jjanke Exp $ - */ -public class PlafRes_pl extends ListResourceBundle -{ - /** The data */ - static final Object[][] contents = new String[][] - { - { "BackColType", "Typ koloru t\u0142a" }, - { "BackColType_Flat", "P\u0142aski" }, - { "BackColType_Gradient", "Stopniowany" }, - { "BackColType_Lines", "Linie" }, - { "BackColType_Texture", "Tekstura" }, - // - { "LookAndFeelEditor", "Edytor Wygl\u0105du" }, - { "LookAndFeel", "Wygl\u0105d" }, - { "Theme", "Temat" }, - { "EditAdempiereTheme", "Edytuj Temat Compiera" }, - { "SetDefault", "Domy\u015blne T\u0142o" }, - { "SetDefaultColor", "Domy\u015blny Kolor" }, - { "Example", "Przyk\u0142ad" }, - { "Reset", "Resetuj" }, - { "OK", "OK" }, - { "Cancel", "Anuluj" }, - // - { "AdempiereThemeEditor", "Edytor Tematu Compiera" }, - { "MetalColors", "Kolory Metalowe" }, - { "AdempiereColors", "Kolory Compiera" }, - { "AdempiereFonts", "Czcionki Compiera" }, - { "Primary1Info", "Tekst Etykiety" }, - { "Primary1", "Podstawowy 1" }, - { "Primary2Info", "Linia Fokusu, Wybrany CheckBox" }, - { "Primary2", "Podstawowy 2" }, - { "Primary3Info", "Wybrany Wiersz Tabeli, Wybrany Tekst, T\u0142o Podpowiedzi" }, - { "Primary3", "Podstawowy 3" }, - { "Secondary1Info", "Linie Obramowania" }, - { "Secondary1", "Drugorz\u0119dny 1" }, - { "Secondary2Info", "Nieaktywne Zak\u0142adki, Naci\u015bni\u0119te Pola, Nieaktywna Ramka + Tekst" }, - { "Secondary2", "Drugorz\u0119dny 2" }, - { "Secondary3Info", "T\u0142o" }, - { "Secondary3", "Drugorz\u0119dny 3" }, - // - { "ControlFontInfo", "Czcionka Kontrolki" }, - { "ControlFont", "Czcionka Etykiety" }, - { "SystemFontInfo", "Podpowiedzi, Ga\u0142\u0119zie drzewa" }, - { "SystemFont", "Czcionka Systemowa" }, - { "UserFontInfo", "Dane wprowadzone przez U\u017cytkownika" }, - { "UserFont", "Czcionka Pola" }, -// { "SmallFontInfo", "Raporty" }, - { "SmallFont", "Ma\u0142a Czcionka" }, - { "WindowTitleFont", "Czcionka Tytu\u0142u" }, - { "MenuFont", "Czcionka Menu" }, - // - { "MandatoryInfo", "Obowi\u0105zkowe T\u0142o Pola" }, - { "Mandatory", "Obowi\u0105zkowe" }, - { "ErrorInfo", "B\u0142\u0105d T\u0142a Pola" }, - { "Error", "B\u0142\u0105d" }, - { "InfoInfo", "Informacja T\u0142a Pola" }, - { "Info", "Informacja" }, - { "WhiteInfo", "Linie" }, - { "White", "Bia\u0142y" }, - { "BlackInfo", "Linie, Tekst" }, - { "Black", "Czarny" }, - { "InactiveInfo", "Nieaktywne T\u0142o Pola" }, - { "Inactive", "Nieaktywny" }, - { "TextOKInfo", "OK Pierwszoplanowy Tekst" }, - { "TextOK", "Tekst - OK" }, - { "TextIssueInfo", "B\u0142\u0105d Pierwszoplanowego Tekstu" }, - { "TextIssue", "Tekst - B\u0142\u0105d" }, - // - { "FontChooser", "Wyb\u00f3r Czcionki" }, - { "Fonts", "Czcionki" }, - { "Plain", "G\u0142adki" }, - { "Italic", "Kursywa" }, - { "Bold", "Pogrubiony" }, - { "BoldItalic", "Pogrubiony i Kursywa" }, - { "Name", "Nazwa" }, - { "Size", "Rozmiar" }, - { "Style", "Styl" }, - { "TestString", "To jest tylko test!" }, - { "FontString", "Czcionka" }, - // - { "AdempiereColorEditor", "Edytor Koloru Compiera" }, - { "AdempiereType", "Typ Koloru" }, - { "GradientUpperColor", "G\u00f3rny Kolor Stopniowania" }, - { "GradientLowerColor", "Dolny Kolor Stopniowania" }, - { "GradientStart", "Pocz\u0105tek Stopniowania" }, - { "GradientDistance", "Odst\u0119p Stopniowania" }, - { "TextureURL", "Tekstura URL" }, - { "TextureAlpha", "Tekstura Alpha" }, - { "TextureTaintColor", "Kolor t\u0142a Tekstury" }, - { "LineColor", "Kolor Linii" }, - { "LineBackColor", "Kolor T\u0142a" }, - { "LineWidth", "Grubo\u015b\u0107 Linii" }, - { "LineDistance", "Odst\u0119p Linii" }, - { "FlatColor", "Kolor P\u0142aski" } - }; - - /** - * Get Contents - * @return contents - */ - public Object[][] getContents() - { - return contents; - } -} // Res diff --git a/org.adempiere.ui.swing/src/org/compiere/plaf/PlafRes_pt.java b/org.adempiere.ui.swing/src/org/compiere/plaf/PlafRes_pt.java deleted file mode 100644 index 8b421b85f0..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/plaf/PlafRes_pt.java +++ /dev/null @@ -1,133 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ -package org.compiere.plaf; - -import java.util.ListResourceBundle; - -/** - * Translation Texts for Look & Feel - * - * @author Jesse Jr - * @version $Id: PlafRes_pt.java,v 1.2 2006/07/30 00:52:24 jjanke Exp $ - */ -public class PlafRes_pt extends ListResourceBundle -{ - /** The data */ - //Characters encoded to UTF8 Hex, so no more problems with svn commits - //Fernando Lucktemberg - CenturuyOn Consultoria - static final Object[][] contents = new String[][] - { - { "BackColType", "Tipo da Cor de Fundo" }, - { "BackColType_Flat", "Plano" }, - { "BackColType_Gradient", "Degrad\u00ea" }, - { "BackColType_Lines", "Linhas" }, - { "BackColType_Texture", "Textura" }, - // - { "LookAndFeelEditor", "Editor: Look & Feel" }, - { "LookAndFeel", "Look & Feel" }, - { "Theme", "Tema" }, - { "EditAdempiereTheme", "Editar Tema Adempiere" }, - { "SetDefault", "Fundo Padr\u00e3o" }, - { "SetDefaultColor", "Cor de Fundo" }, - { "ColorBlind", "Defici\u00eancia de Cor" }, - { "Example", "Exemplo" }, - { "Reset", "Reinicializar" }, - { "OK", "OK" }, - { "Cancel", "Cancelar" }, - // - { "AdempiereThemeEditor", "Adempiere: Editor de Temas" }, - { "MetalColors", "Cores Metal" }, - { "AdempiereColors", "Cores Adempiere" }, - { "AdempiereFonts", "Fontes Adempiere" }, - { "Primary1Info", "Sombra, Separador" }, - { "Primary1", "Prim\u00e1rio 1" }, - { "Primary2Info", "Linha de Foco, Menu Selecionado" }, - { "Primary2", "Prim\u00e1rio 2" }, - { "Primary3Info", "Linha da Tabele Selecionada, Texto Selecionado, Fundo Dicas" }, - { "Primary3", "Prim\u00e1rio 3" }, - { "Secondary1Info", "Bordas de Linhas" }, - { "Secondary1", "Secund\u00e1rio 1" }, - { "Secondary2Info", "Tabs Inativas, Campos Pressed, Borda Inativa + Texto" }, - { "Secondary2", "Secund\u00e1rio 2" }, - { "Secondary3Info", "ïżœrea de Fundo" }, - { "Secondary3", "Secund\u00e1rio 3" }, - // - { "ControlFontInfo", "Controle de Fonte" }, - { "ControlFont", "R\u00f3tulo da Fonte" }, - { "SystemFontInfo", "Tool Tip, Tree nodes" }, - { "SystemFont", "System Font" }, - { "UserFontInfo", "Entrada de Dados pelo Usu\u00e1rio" }, - { "UserFont", "Fonte dos Campos" }, -// { "SmallFontInfo", "Relat\u00f3rios" }, - { "SmallFont", "Fonte pequena" }, - { "WindowTitleFont", "Fonte do T\u00edtulo" }, - { "MenuFont", "Fonte do Menu" }, - // - { "MandatoryInfo", "Fundo de Campos Obrigatïżœrios" }, - { "Mandatory", "Obrigat\u00f3rio" }, - { "ErrorInfo", "Fundo de Campo de Erro" }, - { "Error", "Erro" }, - { "InfoInfo", "Fundo de Campos Informativos" }, - { "Info", "Info" }, - { "WhiteInfo", "Linhas" }, - { "White", "Branco" }, - { "BlackInfo", "Linhas, Texto" }, - { "Black", "Preto" }, - { "InactiveInfo", "Fundo de Campo Inativo" }, - { "Inactive", "Inativo" }, - { "TextOKInfo", "OK Fundo do Texto" }, - { "TextOK", "Texto - OK" }, - { "TextIssueInfo", "Fundo do Texto de Erro" }, - { "TextIssue", "Texto - Erro" }, - // - { "FontChooser", "Selecionar Fonte" }, - { "Fonts", "Fontes" }, - { "Plain", "Plano" }, - { "Italic", "It\u00e1lico" }, - { "Bold", "Negrito" }, - { "BoldItalic", "Negrito & It\u00e1lico" }, - { "Name", "Nome" }, - { "Size", "Tamanho" }, - { "Style", "Estilo" }, - { "TestString", "Somente teste! The quick brown Fox is doing something. 12,3456.78 LetterLOne = l1 LetterOZero = O0" }, - { "FontString", "Fonte" }, - // - { "AdempiereColorEditor", "Adempiere: Editor de Cores" }, - { "AdempiereType", "Tipo de Cor" }, - { "GradientUpperColor", "Cor Degrad\u00ea Superior" }, - { "GradientLowerColor", "Cor Degrad\u00ea Inferior" }, - { "GradientStart", "In\u00edcio do Degrad\u00ea" }, - { "GradientDistance", "Dist\u00e2ncia do Degrad\u00ea" }, - { "TextureURL", "URL Textura" }, - { "TextureAlpha", "Alfa Textura" }, - { "TextureTaintColor", "Colora\u00e7\u00e3o da Textura" }, - { "LineColor", "Cor da Linha" }, - { "LineBackColor", "Cores de Fundo" }, - { "LineWidth", "Largura da Linha" }, - { "LineDistance", "Dist\u00e2ncia das linhas" }, - { "FlatColor", "Cores Planas" } - }; - - /** - * Get Contents - * @return contents - */ - public Object[][] getContents() - { - return contents; - } -} // Res diff --git a/org.adempiere.ui.swing/src/org/compiere/plaf/PlafRes_ro.java b/org.adempiere.ui.swing/src/org/compiere/plaf/PlafRes_ro.java deleted file mode 100644 index 7a89ab6f76..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/plaf/PlafRes_ro.java +++ /dev/null @@ -1,131 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ -package org.compiere.plaf; - -import java.util.ListResourceBundle; - -/** - * Translation Texts for Look & Feel - * - * @author Jorg Janke - * @version $Id: PlafRes_ro.java,v 1.2 2006/07/30 00:52:24 jjanke Exp $ - */ -public class PlafRes_ro extends ListResourceBundle -{ - /** The data */ - static final Object[][] contents = new String[][] - { - { "BackColType", "Tip al culorii de fundal" }, - { "BackColType_Flat", "Plin" }, - { "BackColType_Gradient", "Gradient" }, - { "BackColType_Lines", "Linii" }, - { "BackColType_Texture", "Ha\u015fur\u0103" }, - // - { "LookAndFeelEditor", "Editor de aspect grafic" }, - { "LookAndFeel", "Aspect grafic" }, - { "Theme", "Tem\u0103" }, - { "EditAdempiereTheme", "Editare a temei Adempiere" }, - { "SetDefault", "Fundal implicit" }, - { "SetDefaultColor", "Culoare de fundal" }, - { "ColorBlind", "Deficien\u0163\u0103 cromatic\u0103" }, - { "Example", "Exemplu" }, - { "Reset", "Reini\u0163ializare" }, - { "OK", "OK" }, - { "Cancel", "Anulare" }, - // - { "AdempiereThemeEditor", "Editor de tem\u0103 grafic\u0103" }, - { "MetalColors", "Culori metalice" }, - { "AdempiereColors", "Culori Adempiere" }, - { "AdempiereFonts", "Font-uri Adempiere" }, - { "Primary1Info", "Umbr\u0103, separator" }, - { "Primary1", "Principal 1" }, - { "Primary2Info", "Linie curent\u0103, meniu selectat" }, - { "Primary2", "Principal 2" }, - { "Primary3Info", "R\u00e2nd de tabel selectat, text selectat, fundal pentru indica\u0163ii" }, - { "Primary3", "Principal 3" }, - { "Secondary1Info", "Margini" }, - { "Secondary1", "Secundar 1" }, - { "Secondary2Info", "File inactive, butoane ap\u0103sate, margini \u015fi text inactive" }, - { "Secondary2", "Secundar 2" }, - { "Secondary3Info", "Fundal" }, - { "Secondary3", "Secundar 3" }, - // - { "ControlFontInfo", "Font pentru obiecte grafice" }, - { "ControlFont", "Font pentru etichete" }, - { "SystemFontInfo", "Indica\u0163ii, noduri \u00een arborescen\u0163e" }, - { "SystemFont", "Font de sistem" }, - { "UserFontInfo", "Date introduse de utilizator" }, - { "UserFont", "Font pentru c\u00e2mpuri" }, -// { "SmallFontInfo", "Font pentru rapoarte" }, - { "SmallFont", "Font de dimensiune mic\u0103" }, - { "WindowTitleFont", "Font pentru titluri" }, - { "MenuFont", "Font de meniuri" }, - // - { "MandatoryInfo", "Fundal pentru c\u00e2mpuri obligatorii" }, - { "Mandatory", "Obligatoriu" }, - { "ErrorInfo", "Fundal pentru c\u00e2mpuri cu valori eronate" }, - { "Error", "Erori" }, - { "InfoInfo", "Fundal pentru c\u00e2mpuri de informare" }, - { "Info", "Informare" }, - { "WhiteInfo", "R\u00e2nduri goale" }, - { "White", "\"Alb\"" }, - { "BlackInfo", "Linii, text" }, - { "Black", "\"Negru\"" }, - { "InactiveInfo", "Fundal pentru c\u00e2mpuri inactive" }, - { "Inactive", "Inactiv" }, - { "TextOKInfo", "Culoare pentru mesaje de confirmare" }, - { "TextOK", "Text de confirmare" }, - { "TextIssueInfo", "Culoare pentru mesaje de eroare" }, - { "TextIssue", "Text de eroare" }, - // - { "FontChooser", "Selector de font-uri" }, - { "Fonts", "Font-uri" }, - { "Plain", "Normal" }, - { "Italic", "Cursiv" }, - { "Bold", "Aldin" }, - { "BoldItalic", "Aldin \u015fi cursiv" }, - { "Name", "Nume" }, - { "Size", "Dimensiune" }, - { "Style", "Stil" }, - { "TestString", "Acesta este un test! Ziua bun\u0103 se cunoa\u015fte de diminea\u0163\u0103. 123.456,78 Lunu = l1 Ozero = O0" }, - { "FontString", "Font" }, - // - { "AdempiereColorEditor", "Editor de culoare " }, - { "AdempiereType", "Tip de culoare" }, - { "GradientUpperColor", "Culoare superioar\u0103 pentru gradient" }, - { "GradientLowerColor", "Culoare inferioar\u0103 pentru gradient" }, - { "GradientStart", "\u00cenceput de gradient" }, - { "GradientDistance", "Distan\u0163\u0103 de gradient" }, - { "TextureURL", "URL pentru ha\u015fur\u0103" }, - { "TextureAlpha", "Masc\u0103 alpha pentru ha\u015fur\u0103" }, - { "TextureTaintColor", "Nuan\u0163\u0103 a ha\u015furii" }, - { "LineColor", "Culoare de desenare" }, - { "LineBackColor", "Culoare de fundal" }, - { "LineWidth", "L\u0103\u0163imea liniei" }, - { "LineDistance", "Distan\u0163a \u00eentre linii" }, - { "FlatColor", "Culoare plin\u0103" } - }; - - /** - * Get Contents - * @return contents - */ - public Object[][] getContents() - { - return contents; - } -} // Res diff --git a/org.adempiere.ui.swing/src/org/compiere/plaf/PlafRes_ru.java b/org.adempiere.ui.swing/src/org/compiere/plaf/PlafRes_ru.java deleted file mode 100644 index 8098fe90a8..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/plaf/PlafRes_ru.java +++ /dev/null @@ -1,131 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ -package org.compiere.plaf; - -import java.util.ListResourceBundle; - -/** - * Translation Texts for Look & Feel - * - * @author Vyacheslav Pedak - * @version $Id: PlafRes_ru.java,v 1.2 2006/07/30 00:52:24 jjanke Exp $ - */ -public class PlafRes_ru extends ListResourceBundle -{ - /** The data */ - static final Object[][] contents = new String[][] - { - { "BackColType", "\u0422\u0438\u043f \u0444\u043e\u043d\u043e\u0432\u043e\u0433\u043e \u0446\u0432\u0435\u0442\u0430" }, - { "BackColType_Flat", "\u0417\u0430\u043b\u0438\u0432\u043a\u0430" }, - { "BackColType_Gradient", "\u0413\u0440\u0430\u0434\u0438\u0435\u043d\u0442" }, - { "BackColType_Lines", "\u041b\u0438\u043d\u0438\u0438" }, - { "BackColType_Texture", "\u0422\u0435\u043a\u0441\u0442\u0443\u0440\u0430" }, - // - { "LookAndFeelEditor", "\u0420\u0435\u0434\u0430\u043a\u0442\u043e\u0440 \u0432\u043d\u0435\u0448\u043d\u0435\u0433\u043e \u0432\u0438\u0434\u0430" }, - { "LookAndFeel", "\u0412\u043d\u0435\u0448\u043d\u0438\u0439 \u0432\u0438\u0434" }, - { "Theme", "\u0422\u0435\u043c\u0430" }, - { "EditAdempiereTheme", "\u0420\u0435\u0434\u0430\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0442\u0435\u043c\u044b Adempiere" }, - { "SetDefault", "\u0424\u043e\u043d \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e" }, - { "SetDefaultColor", "\u0426\u0432\u0435\u0442 \u0444\u043e\u043d\u0430" }, - { "ColorBlind", "\u0420\u0430\u0437\u043c\u044b\u0442\u043e\u0441\u0442\u044c \u0446\u0432\u0435\u0442\u0430" }, - { "Example", "\u041f\u0440\u0438\u043c\u0435\u0440" }, - { "Reset", "\u0421\u0431\u0440\u043e\u0441" }, - { "OK", "\u0414\u0430" }, - { "Cancel", "\u041e\u0442\u043c\u0435\u043d\u0430" }, - // - { "AdempiereThemeEditor", "\u0420\u0435\u0434\u0430\u043a\u0442\u043e\u0440 \u0442\u0435\u043c Adempiere" }, - { "MetalColors", "\u041c\u0435\u0442\u0430\u043b\u043b\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u0446\u0432\u0435\u0442\u0430" }, - { "AdempiereColors", "\u0426\u0432\u0435\u0442\u0430 Adempiere" }, - { "AdempiereFonts", "\u0428\u0440\u0438\u0444\u0442\u044b Adempiere" }, - { "Primary1Info", "\u0422\u0435\u043d\u044c, \u0420\u0430\u0437\u0434\u0435\u043b\u0438\u0442\u0435\u043b\u044c" }, - { "Primary1", "\u041f\u0435\u0440\u0432\u043e\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u044b\u0439 1" }, - { "Primary2Info", "\u0424\u043e\u043a\u0443\u0441\u0438\u0440\u043e\u0432\u043a\u0430, \u0412\u044b\u0431\u0440\u0430\u043d\u043d\u043e\u0435 \u043c\u0435\u043d\u044e" }, - { "Primary2", "\u041f\u0435\u0440\u0432\u043e\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u044b\u0439 2" }, - { "Primary3Info", "\u0412\u044b\u0431\u0440\u0430\u043d\u043d\u0430\u044f \u0441\u0442\u0440\u043e\u043a\u0430 \u0432 \u0442\u0430\u043b\u0438\u0446\u0435, \u0412\u044b\u0431\u0440\u0430\u043d\u043d\u044b\u0439 \u0446\u0432\u0435\u0442, \u0424\u043e\u043d ToolTip" }, - { "Primary3", "\u041f\u0435\u0440\u0432\u043e\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u044b\u0439 3" }, - { "Secondary1Info", "\u041b\u0438\u043d\u0438\u0438 \u0433\u0440\u0430\u043d\u0438\u0446\u044b" }, - { "Secondary1", "\u0412\u0442\u043e\u0440\u0438\u0447\u043d\u044b\u0439 1" }, - { "Secondary2Info", "\u041d\u0435\u0430\u043a\u0442\u0438\u0432\u043d\u044b\u0435 \u0437\u0430\u043a\u043b\u0430\u0434\u043a\u0438, \u041d\u0430\u0436\u0430\u0442\u044b\u0435 \u043f\u043e\u043b\u044f, \u041d\u0435\u0430\u043a\u0442\u0438\u0432\u043d\u044b\u0435 \u0433\u0440\u0430\u043d\u0438\u0446\u044b + \u0442\u0435\u043a\u0441\u0442" }, - { "Secondary2", "\u0412\u0442\u043e\u0440\u0438\u0447\u043d\u044b\u0439 2" }, - { "Secondary3Info", "\u0424\u043e\u043d" }, - { "Secondary3", "\u0412\u0442\u043e\u0440\u0438\u0447\u043d\u044b\u0439 3" }, - // - { "ControlFontInfo", "\u0428\u0440\u0438\u0444\u0442 \u0434\u043b\u044f \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f" }, - { "ControlFont", "\u0428\u0440\u0438\u0444\u0442 \u0434\u043b\u044f \u043c\u0435\u0442\u043e\u043a" }, - { "SystemFontInfo", "Tool Tip, \u042d\u043b\u0435\u043c\u0435\u043d\u0442\u044b \u0434\u0435\u0440\u0435\u0432\u0430" }, - { "SystemFont", "\u0421\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u0439 \u0448\u0440\u0438\u0444\u0442" }, - { "UserFontInfo", "\u0412\u0432\u0435\u0434\u0435\u043d\u043d\u044b\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u043c \u0434\u0430\u043d\u043d\u044b\u0435" }, - { "UserFont", "\u0428\u0440\u0438\u0444\u0442 \u0434\u043b\u044f \u043f\u043e\u043b\u0435\u0439 \u0432\u0432\u043e\u0434\u0430" }, -// { "SmallFontInfo", "\u041e\u0442\u0447\u0435\u0442\u044b" }, - { "SmallFont", "\u041c\u0430\u043b\u0435\u043d\u044c\u043a\u0438\u0439 \u0448\u0440\u0438\u0444\u0442" }, - { "WindowTitleFont", "\u0428\u0440\u0438\u0444\u0442 \u0434\u043b\u044f \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043a\u043e\u043c" }, - { "MenuFont", "\u0428\u0440\u0438\u0444\u0442 \u0434\u043b\u044f \u043c\u0435\u043d\u044e" }, - // - { "MandatoryInfo", "\u0424\u043e\u043d \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u043f\u043e\u043b\u0435\u0439 \u0432\u0432\u043e\u0434\u0430" }, - { "Mandatory", "\u041e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0439" }, - { "ErrorInfo", "\u0424\u043e\u043d \u043e\u0448\u0438\u0431\u043e\u0447\u043d\u044b\u0445 \u043f\u043e\u043b\u0435\u0439" }, - { "Error", "\u041e\u0448\u0438\u0431\u043a\u0430" }, - { "InfoInfo", "\u0424\u043e\u043d \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u043e\u043d\u043d\u044b\u0445 \u043f\u043e\u043b\u0435\u0439" }, - { "Info", "\u0418\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f" }, - { "WhiteInfo", "\u041b\u0438\u043d\u0438\u0438" }, - { "White", "\u0411\u0435\u043b\u044b\u0439" }, - { "BlackInfo", "\u041b\u0438\u043d\u0438\u0438, \u0422\u0435\u043a\u0441\u0442" }, - { "Black", "\u0427\u0435\u0440\u043d\u044b\u0439" }, - { "InactiveInfo", "\u0424\u043e\u043d \u043d\u0435\u0430\u043a\u0442\u0438\u0432\u043d\u044b\u0445 \u043f\u043e\u043b\u0435\u0439" }, - { "Inactive", "\u041d\u0435\u0430\u043a\u0442\u0438\u0432\u043d\u044b\u0439" }, - { "TextOKInfo", "\u0426\u0432\u0435\u0442 \u0442\u0435\u043a\u0441\u0442\u0430 '\u0414\u0430'" }, - { "TextOK", "\u0422\u0435\u043a\u0441\u0442 - '\u0414\u0430'" }, - { "TextIssueInfo", "\u0426\u0432\u0435\u0442 \u0442\u0435\u043a\u0441\u0442\u0430 '\u041e\u0448\u0438\u0431\u043a\u0430'" }, - { "TextIssue", "\u0422\u0435\u043a\u0441\u0442 - '\u041e\u0448\u0438\u0431\u043a\u0430'" }, - // - { "FontChooser", "\u0412\u044b\u0431\u043e\u0440 \u0448\u0440\u0438\u0444\u0442\u043e\u0432" }, - { "Fonts", "\u0428\u0440\u0438\u0444\u0442\u044b" }, - { "Plain", "\u041e\u0431\u044b\u0447\u043d\u044b\u0439" }, - { "Italic", "\u041d\u0430\u043a\u043b\u043e\u043d\u043d\u044b\u0439" }, - { "Bold", "\u0416\u0438\u0440\u043d\u044b\u0439" }, - { "BoldItalic", "\u0416\u0438\u0440\u043d\u044b\u0439 \u0438 \u041d\u0430\u043a\u043b\u043e\u043d\u043d\u044b\u0439" }, - { "Name", "\u0418\u043c\u044f" }, - { "Size", "\u0420\u0430\u0437\u043c\u0435\u0440" }, - { "Style", "\u0421\u0442\u0438\u0442\u044c" }, - { "TestString", "\u042d\u0442\u043e \u0432\u0435\u0433\u043e \u043b\u0438\u0448\u044c \u0442\u0435\u0441\u0442! \u0422\u0430\u043a \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u043d\u0430\u0434\u043f\u0438\u0441\u044c. 12,3456.78 LetterLOne = l1 LetterOZero = O0" }, - { "FontString", "\u0428\u0440\u0438\u0444\u0442" }, - // - { "AdempiereColorEditor", "\u0420\u0435\u0434\u0430\u043a\u0442\u043e\u0440 \u0446\u0432\u0435\u0442\u043e\u0432 Adempiere" }, - { "AdempiereType", "\u0422\u0438\u043f \u0446\u0432\u0435\u0442\u0430" }, - { "GradientUpperColor", "\u0412\u0435\u0440\u0445\u043d\u0438\u0439 \u0433\u0440\u0430\u0434\u0438\u0435\u043d\u0442" }, - { "GradientLowerColor", "\u041d\u0438\u0436\u043d\u0438\u0439 \u0433\u0440\u0430\u0434\u0438\u0435\u043d\u0442" }, - { "GradientStart", "\u041d\u0430\u0447\u0430\u043b\u043e \u0433\u0440\u0430\u0434\u0438\u0435\u043d\u0442\u0430" }, - { "GradientDistance", "\u041f\u0440\u043e\u043c\u0435\u0436\u0443\u0442\u043e\u043a \u0433\u0440\u0430\u0434\u0438\u0435\u043d\u0442\u0430" }, - { "TextureURL", "URL \u0442\u0435\u043a\u0441\u0442\u0443\u0440\u044b" }, - { "TextureAlpha", "Alpha \u0442\u0435\u043a\u0441\u0442\u0443\u0440\u044b" }, - { "TextureTaintColor", "\u0426\u0432\u0435\u0442 \u0442\u0435\u043a\u0441\u0442\u0443\u0440\u044b" }, - { "LineColor", "\u0426\u0432\u0435\u0442 \u043b\u0438\u043d\u0438\u0438" }, - { "LineBackColor", "\u0426\u0432\u0435\u0442 \u0444\u043e\u043d\u0430" }, - { "LineWidth", "\u0428\u0438\u0440\u0438\u043d\u0430 \u043b\u0438\u043d\u0438\u0439" }, - { "LineDistance", "\u041f\u0440\u043e\u043c\u0435\u0436\u0434\u0443\u0442\u043e\u043a \u043c\u0435\u0436\u0434\u0443 \u043b\u0438\u043d\u0438\u044f\u043c\u0438" }, - { "FlatColor", "\u0426\u0432\u0435\u0442 \u0437\u0430\u043b\u0438\u0432\u043a\u0438" } - }; - - /** - * Get Contents - * @return contents - */ - public Object[][] getContents() - { - return contents; - } -} // Res diff --git a/org.adempiere.ui.swing/src/org/compiere/plaf/PlafRes_sl.java b/org.adempiere.ui.swing/src/org/compiere/plaf/PlafRes_sl.java deleted file mode 100644 index c5a3b89b62..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/plaf/PlafRes_sl.java +++ /dev/null @@ -1,132 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ -package org.compiere.plaf; - -import java.util.ListResourceBundle; - -/** - * Translation Texts for Look & Feel - * - * @author Matja\u017e Godec - * @version $Id: PlafRes_sl.java,v 1.2 2006/07/30 00:52:24 jjanke Exp $ - */ -public class PlafRes_sl extends ListResourceBundle -{ - /** The data */ - static final Object[][] contents = new String[][] - { - { "BackColType", "Tip ozadja" }, - { "BackColType_Flat", "Barva" }, - { "BackColType_Gradient", "Preliv" }, - { "BackColType_Lines", "\u010crte" }, - { "BackColType_Texture", "Tekstura" }, - // - { "LookAndFeelEditor", "Urejevalnik izgleda" }, - { "LookAndFeel", "Izgled" }, - { "Theme", "Tema" }, - { "EditAdempiereTheme", "Urejanje Adempiere teme" }, - { "SetDefault", "Privzeto ozadje" }, - { "SetDefaultColor", "Barva ozadja" }, - { "ColorBlind", "Color Deficiency" }, - { "Example", "Primer" }, - { "Reset", "Ponastavi" }, - { "OK", "V redu" }, - { "Cancel", "Prekli\u010di" }, - // - { "AdempiereThemeEditor", "Urejanje Adempiere teme" }, - { "MetalColors", "Barve Metal" }, - { "AdempiereColors", "Barve Adempiere" }, - { "AdempiereFonts", "Adempiere pisave" }, - { "Primary1Info", "Sen\u010denje, Lo\u010dilo" }, - { "Primary1", "Primarna 1" }, - { "Primary2Info", "\u010crta s fokusom, Izbran meni" }, - { "Primary2", "Primarna 2" }, - { "Primary3Info", "Izbrana vrstice tabele, Izbran tekst, Ozadje nasvetov" }, - { "Primary3", "Primarna 3" }, - { "Secondary1Info", "\u010crte okvirja" }, - { "Secondary1", "Sekundarno 1" }, - { "Secondary2Info", "Neaktivni zavihki, Izbrana (pritisnjena) polja, Neaktivne meje + tekst" }, - { "Secondary2", "Sekundarno 2" }, - { "Secondary3Info", "Ozadje" }, - { "Secondary3", "Sekundarno 3" }, - // - { "ControlFontInfo", "Pisava za kontrole" }, - { "ControlFont", "Pisava za oznake" }, - { "SystemFontInfo", "Nasveti, listi drevesa" }, - { "SystemFont", "Sistemska pisava" }, - { "UserFontInfo", "Uporabni\u0161ko vne\u0161eni podatki" }, - { "UserFont", "Pisava za polje" }, -// { "SmallFontInfo", "Reporti" }, - { "SmallFont", "Majhna pisava" }, - { "WindowTitleFont", "Pisava naslovov" }, - { "MenuFont", "Pisava menija" }, - // - { "MandatoryInfo", "Ozadje obveznega polja" }, - { "Mandatory", "Obvezno" }, - { "ErrorInfo", "Ozadje polja z napako" }, - { "Error", "Napaka" }, - { "InfoInfo", "Ozadje informacijskih polj" }, - { "Info", "Informacije" }, - { "WhiteInfo", "\u010crte" }, - { "White", "Belo" }, - { "BlackInfo", "\u010crte, tekst" }, - { "Black", "\u010crno" }, - { "InactiveInfo", "Ozadje neaktivnih polj" }, - { "Inactive", "Neaktivno" }, - { "TextOKInfo", "Barva pisave polja V redu" }, - { "TextOK", "Tekst - V redu" }, - { "TextIssueInfo", "Barva teksta napake" }, - { "TextIssue", "Tekst - Napaka" }, - // - { "FontChooser", "Font Chooser" }, - { "Fonts", "Fonts" }, - { "Plain", "Plain" }, - { "Italic", "Italic" }, - { "Bold", "Bold" }, - { "BoldItalic", "Bold & Italic" }, - { "Name", "Ime" }, - { "Size", "Velikost" }, - { "Style", "Stil" }, - { "TestString", "To je samo test. The quick brown Fox is doing something. 12,3456.78 LetterLOne = l1 LetterOZero = O0" }, - { "FontString", "Font" }, - // - { "AdempiereColorEditor", "Adempiere Color Editor" }, - { "AdempiereType", "Color Type" }, - { "GradientUpperColor", "Gradient Upper Color" }, - { "GradientLowerColor", "Gradient Lower Color" }, - { "GradientStart", "Gradient Start" }, - { "GradientDistance", "Gradient Distance" }, - { "TextureURL", "Texture URL" }, - { "TextureAlpha", "Texture Alpha" }, - { "TextureTaintColor", "Texture Taint Color" }, - { "LineColor", "Line Color" }, - { "LineBackColor", "Background Color" }, - { "LineWidth", "Line Width" }, - { "LineDistance", "Line Distance" }, - { "FlatColor", "Flat Color" } - }; - - /** - * Get Contents - * @return contents - */ - public Object[][] getContents() - { - return contents; - } -} // Res - diff --git a/org.adempiere.ui.swing/src/org/compiere/plaf/PlafRes_sr.java b/org.adempiere.ui.swing/src/org/compiere/plaf/PlafRes_sr.java deleted file mode 100644 index dfa34ec6f4..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/plaf/PlafRes_sr.java +++ /dev/null @@ -1,132 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ -package org.compiere.plaf; - -import java.util.ListResourceBundle; - -/** - * Translation Texts for Look & Feel - * - * @author Nikola Petkov - * @version $Id: patch-java-trl-sr_RS.txt,v 1.1 2008/12/05 11:39:16 mgifos Exp $ - */ -public class PlafRes_sr extends ListResourceBundle -{ - /** The data */ - static final Object[][] contents = new String[][] - { - { "BackColType", "\u0422\u0438\u043F \u043F\u043E\u0437\u0430\u0434\u0438\u043D\u0435" }, - { "BackColType_Flat", "Flat" }, - { "BackColType_Gradient", "\u0413\u0440\u0430\u0434\u0438\u0458\u0435\u043D\u0442" }, - { "BackColType_Lines", "\u041B\u0438\u043D\u0438\u0458\u0435" }, - { "BackColType_Texture", "\u0422\u0435\u043A\u0441\u0442\u0443\u0440\u0435" }, - // - { "LookAndFeelEditor", "\u0415\u0434\u0438\u0442\u043E\u0440 \u0438\u0437\u0433\u043B\u0435\u0434\u0430" }, - { "LookAndFeel", "\u0418\u0437\u0433\u043B\u0435\u0434" }, - { "Theme", "\u0422\u0435\u043C\u0430" }, - { "EditAdempiereTheme", "\u0423\u0440\u0435\u0452\u0438\u0432\u0430\u045A\u0435 Adempiere \u0442\u0435\u043C\u0435" }, - { "SetDefault", "\u0423\u043E\u0431\u0438\u0447\u0430\u0458\u0435\u043D\u0430 \u043F\u043E\u0437\u0430\u0434\u0438\u043D\u0430" }, - { "SetDefaultColor", "\u0411\u043E\u0458\u0430 \u043F\u043E\u0437\u0430\u0434\u0438\u043D\u0435" }, - { "ColorBlind", "Color Deficiency" }, - { "Example", "\u041F\u0440\u0438\u043C\u0435\u0440" }, - { "Reset", "\u041F\u043E\u043D\u0438\u0448\u0442\u0438 \u0438\u0437\u043C\u0435\u043D\u0435" }, - { "OK", "\u0423 \u0440\u0435\u0434\u0443" }, - { "Cancel", "\u041E\u0434\u0443\u0441\u0442\u0430\u043D\u0438" }, - // - { "AdempiereThemeEditor", "\u0423\u0440\u0435\u0452\u0438\u0432\u0430\u045A\u0435 Adempiere \u0442\u0435\u043C\u0435" }, - { "MetalColors", "Metal Colors" }, - { "AdempiereColors", "Adempiere Colors" }, - { "AdempiereFonts", "Adempiere Fonts" }, - { "Primary1Info", "Shadow, Separator" }, - { "Primary1", "Primary 1" }, - { "Primary2Info", "Focus Line, Selected Menu" }, - { "Primary2", "Primary 2" }, - { "Primary3Info", "Table Selected Row, Selected Text, ToolTip Background" }, - { "Primary3", "Primary 3" }, - { "Secondary1Info", "Border Lines" }, - { "Secondary1", "Secondary 1" }, - { "Secondary2Info", "Inactive Tabs, Pressed Fields, Inactive Border + Text" }, - { "Secondary2", "Secondary 2" }, - { "Secondary3Info", "Background" }, - { "Secondary3", "Secondary 3" }, - // - { "ControlFontInfo", "Control Font" }, - { "ControlFont", "Label Font" }, - { "SystemFontInfo", "Tool Tip, Tree nodes" }, - { "SystemFont", "System Font" }, - { "UserFontInfo", "User Entered Data" }, - { "UserFont", "Field Font" }, -// { "SmallFontInfo", "Reports" }, - { "SmallFont", "Small Font" }, - { "WindowTitleFont", "Title Font" }, - { "MenuFont", "Menu Font" }, - // - { "MandatoryInfo", "Mandatory Field Background" }, - { "Mandatory", "Mandatory" }, - { "ErrorInfo", "Error Field Background" }, - { "Error", "Error" }, - { "InfoInfo", "Info Field Background" }, - { "Info", "Info" }, - { "WhiteInfo", "Lines" }, - { "White", "White" }, - { "BlackInfo", "Lines, Text" }, - { "Black", "Black" }, - { "InactiveInfo", "Inactive Field Background" }, - { "Inactive", "Inactive" }, - { "TextOKInfo", "OK Text Foreground" }, - { "TextOK", "Text - OK" }, - { "TextIssueInfo", "Error Text Foreground" }, - { "TextIssue", "Text - Error" }, - // - { "FontChooser", "Font Chooser" }, - { "Fonts", "Fonts" }, - { "Plain", "Plain" }, - { "Italic", "Italic" }, - { "Bold", "Bold" }, - { "BoldItalic", "Bold & Italic" }, - { "Name", "Name" }, - { "Size", "Size" }, - { "Style", "Style" }, - { "TestString", "This is just a Test! The quick brown Fox is doing something. 12,3456.78 LetterLOne = l1 LetterOZero = O0" }, - { "FontString", "Font" }, - // - { "AdempiereColorEditor", "Adempiere Color Editor" }, - { "AdempiereType", "Color Type" }, - { "GradientUpperColor", "Gradient Upper Color" }, - { "GradientLowerColor", "Gradient Lower Color" }, - { "GradientStart", "Gradient Start" }, - { "GradientDistance", "Gradient Distance" }, - { "TextureURL", "Texture URL" }, - { "TextureAlpha", "Texture Alpha" }, - { "TextureTaintColor", "Texture Taint Color" }, - { "LineColor", "Line Color" }, - { "LineBackColor", "Background Color" }, - { "LineWidth", "Line Width" }, - { "LineDistance", "Line Distance" }, - { "FlatColor", "Flat Color" } - }; - - /** - * Get Contents - * @return contents - */ - public Object[][] getContents() - { - return contents; - } -} // Res - diff --git a/org.adempiere.ui.swing/src/org/compiere/plaf/PlafRes_sv.java b/org.adempiere.ui.swing/src/org/compiere/plaf/PlafRes_sv.java deleted file mode 100644 index 5d6423752a..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/plaf/PlafRes_sv.java +++ /dev/null @@ -1,131 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ -package org.compiere.plaf; - -import java.util.ListResourceBundle; - -/** - * Swedish Translation Texts for Look & Feel - * - * @author Thomas Dilts - * @version $Id: PlafRes_sv.java,v 1.2 2006/07/30 00:52:24 jjanke Exp $ - */ -public class PlafRes_sv extends ListResourceBundle -{ - /** The data */ - static final Object[][] contents = new String[][] - { - { "BackColType", "Bakgrundsfïżœrgtyp" }, - { "BackColType_Flat", "Platt" }, - { "BackColType_Gradient", "Toning" }, - { "BackColType_Lines", "Linjer" }, - { "BackColType_Texture", "Struktur" }, - // - { "LookAndFeelEditor", "Utseenderedigeringsprogram" }, - { "LookAndFeel", "Utseendet" }, - { "Theme", "Tema" }, - { "EditAdempiereTheme", "Redigera adempiere tema" }, - { "SetDefault", "Standardbakgrund" }, - { "SetDefaultColor", "Bakgrundsfïżœrg" }, - { "ColorBlind", "Bristfïżœlligfïżœrg" }, - { "Example", "Exempel" }, - { "Reset", "ïżœterstïżœlla" }, - { "OK", "OK" }, - { "Cancel", "Avbryt" }, - // - { "AdempiereThemeEditor", "Adempiere temaredigeringsprogram" }, - { "MetalColors", "Metal fïżœrg" }, - { "AdempiereColors", "Adempiere fïżœrger" }, - { "AdempiereFonts", "Adempiere teckensnitt" }, - { "Primary1Info", "Skugga, avskiljare" }, - { "Primary1", "Primïżœr 1" }, - { "Primary2Info", "Fokus linje, vald meny" }, - { "Primary2", "Primïżœr 2" }, - { "Primary3Info", "Tabel vald rad, vald text, knappbeskrivning bakgrund" }, - { "Primary3", "Primïżœr 3" }, - { "Secondary1Info", "Ram linjer" }, - { "Secondary1", "Sekundïżœr 1" }, - { "Secondary2Info", "Inactiv tabbar, nedtrycktfïżœlt, inactive ram + text" }, - { "Secondary2", "Sekundïżœr 2" }, - { "Secondary3Info", "Bakgrund" }, - { "Secondary3", "Sekundïżœr 3" }, - // - { "ControlFontInfo", "Kontrolteckensnitt" }, - { "ControlFont", "Textetiketter teckensnitt" }, - { "SystemFontInfo", "Knappbeskrivning, Trïżœd gren" }, - { "SystemFont", "System teckensnitt" }, - { "UserFontInfo", "Anvïżœndare angiven data" }, - { "UserFont", "Fïżœlt teckensnitt" }, -// { "SmallFontInfo", "Reports" }, - { "SmallFont", "Liten teckensnitt" }, - { "WindowTitleFont", "Rubrik teckensnitt" }, - { "MenuFont", "Meny teckensnitt" }, - // - { "MandatoryInfo", "Obligatoriskt fïżœlt bakgrund" }, - { "Mandatory", "Obligatorisk" }, - { "ErrorInfo", "Fel fïżœlt bakgrund" }, - { "Error", "Fel" }, - { "InfoInfo", "Information fïżœlt bakgrund" }, - { "Info", "Information" }, - { "WhiteInfo", "Linjer" }, - { "White", "Vit" }, - { "BlackInfo", "Linjer, text" }, - { "Black", "Svart" }, - { "InactiveInfo", "Inactiv fïżœlt bakgrund" }, - { "Inactive", "Inactiv" }, - { "TextOKInfo", "OK text fïżœrgrund" }, - { "TextOK", "Text - OK" }, - { "TextIssueInfo", "Fel text fïżœrgrund" }, - { "TextIssue", "Text - Fel" }, - // - { "FontChooser", "Teckensnittvïżœljare" }, - { "Fonts", "Teckensnitt" }, - { "Plain", "Oformaterad" }, - { "Italic", "Kursiv" }, - { "Bold", "Fet" }, - { "BoldItalic", "Fet & kursiv" }, - { "Name", "Namn" }, - { "Size", "Storlek" }, - { "Style", "Stil" }, - { "TestString", "Denna ïżœr en test! ABCDEFG abcdefg ïżœïżœïżœïżœïżœïżœ. 12,3456.78 LetterLOne = l1 LetterOZero = O0" }, - { "FontString", "Teckensnitt" }, - // - { "AdempiereColorEditor", "Adempiere fïżœrgredigeringsprogram" }, - { "AdempiereType", "Fïżœrgtyp" }, - { "GradientUpperColor", "Toning ïżœverfïżœrg" }, - { "GradientLowerColor", "Toning underfïżœrg" }, - { "GradientStart", "Toning start" }, - { "GradientDistance", "Toning lïżœngd" }, - { "TextureURL", "Struktur URL" }, - { "TextureAlpha", "Struktur Alpha" }, - { "TextureTaintColor", "Struktur flïżœckfïżœrg" }, - { "LineColor", "Linje fïżœrg" }, - { "LineBackColor", "Bakgrundsfïżœrg" }, - { "LineWidth", "Linje bred" }, - { "LineDistance", "Linje lïżœngd" }, - { "FlatColor", "Mattfïżœrg" } - }; - - /** - * Get Contents - * @return contents - */ - public Object[][] getContents() - { - return contents; - } -} // Res diff --git a/org.adempiere.ui.swing/src/org/compiere/plaf/PlafRes_th.java b/org.adempiere.ui.swing/src/org/compiere/plaf/PlafRes_th.java deleted file mode 100644 index 0caad22d96..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/plaf/PlafRes_th.java +++ /dev/null @@ -1,131 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ -package org.compiere.plaf; - -import java.util.ListResourceBundle; - -/** - * Translation Texts for Look & Feel (Thai) - * - * @author Sureeraya Limpaibul - * @version $Id: PlafRes_th.java,v 1.2 2006/07/30 00:52:24 jjanke Exp $ - */ -public class PlafRes_th extends ListResourceBundle -{ - /** The data */ - static final Object[][] contents = new String[][] - { - { "BackColType", "\u0e23\u0e39\u0e1b\u0e41\u0e1a\u0e1a\u0e02\u0e2d\u0e07\u0e1e\u0e37\u0e49\u0e19\u0e2b\u0e25\u0e31\u0e07" }, - { "BackColType_Flat", "Flat" }, - { "BackColType_Gradient", "Gradient" }, - { "BackColType_Lines", "Lines" }, - { "BackColType_Texture", "Texture" }, - // - { "LookAndFeelEditor", "Look & Feel Editor" }, - { "LookAndFeel", "Look & Feel" }, - { "Theme", "Theme" }, - { "EditAdempiereTheme", "Edit Adempiere Theme" }, - { "SetDefault", "Default Background" }, - { "SetDefaultColor", "Background Color" }, - { "ColorBlind", "Color Deficiency" }, - { "Example", "\u0e15\u0e31\u0e27\u0e2d\u0e22\u0e48\u0e32\u0e07" }, - { "Reset", "Reset" }, - { "OK", "\u0e15\u0e01\u0e25\u0e07" }, - { "Cancel", "\u0e22\u0e01\u0e40\u0e25\u0e34\u0e01" }, - // - { "AdempiereThemeEditor", "Adempiere Theme Editor" }, - { "MetalColors", "Metal Colors" }, - { "AdempiereColors", "Adempiere Colors" }, - { "AdempiereFonts", "Adempiere Fonts" }, - { "Primary1Info", "Shadow, Separator" }, - { "Primary1", "Primary 1" }, - { "Primary2Info", "Focus Line, Selected Menu" }, - { "Primary2", "Primary 2" }, - { "Primary3Info", "Table Selected Row, Selected Text, ToolTip Background" }, - { "Primary3", "Primary 3" }, - { "Secondary1Info", "Border Lines" }, - { "Secondary1", "Secondary 1" }, - { "Secondary2Info", "Inactive Tabs, Pressed Fields, Inactive Border + Text" }, - { "Secondary2", "Secondary 2" }, - { "Secondary3Info", "Background" }, - { "Secondary3", "Secondary 3" }, - // - { "ControlFontInfo", "Control Font" }, - { "ControlFont", "Label Font" }, - { "SystemFontInfo", "Tool Tip, Tree nodes" }, - { "SystemFont", "System Font" }, - { "UserFontInfo", "User Entered Data" }, - { "UserFont", "Field Font" }, -// { "SmallFontInfo", "Reports" }, - { "SmallFont", "\u0e2d\u0e31\u0e01\u0e29\u0e23\u0e02\u0e19\u0e32\u0e14\u0e40\u0e25\u0e47\u0e01" }, - { "WindowTitleFont", "Title Font" }, - { "MenuFont", "\u0e40\u0e21\u0e19\u0e39\u0e2d\u0e31\u0e01\u0e29\u0e23" }, - // - { "MandatoryInfo", "Mandatory Field Background" }, - { "Mandatory", "Mandatory" }, - { "ErrorInfo", "Error Field Background" }, - { "Error", "Error" }, - { "InfoInfo", "Info Field Background" }, - { "Info", "Info" }, - { "WhiteInfo", "Lines" }, - { "White", "White" }, - { "BlackInfo", "Lines, Text" }, - { "Black", "Black" }, - { "InactiveInfo", "Inactive Field Background" }, - { "Inactive", "Inactive" }, - { "TextOKInfo", "OK Text Foreground" }, - { "TextOK", "Text - OK" }, - { "TextIssueInfo", "Error Text Foreground" }, - { "TextIssue", "Text - Error" }, - // - { "FontChooser", "\u0e40\u0e25\u0e37\u0e2d\u0e01\u0e41\u0e1a\u0e1a\u0e2d\u0e31\u0e01\u0e29\u0e23" }, - { "Fonts", "\u0e15\u0e31\u0e27\u0e2d\u0e31\u0e01\u0e29\u0e23" }, - { "Plain", "\u0e18\u0e23\u0e23\u0e21\u0e14\u0e32" }, - { "Italic", "\u0e15\u0e31\u0e27\u0e40\u0e2d\u0e35\u0e22\u0e07" }, - { "Bold", "\u0e15\u0e31\u0e27\u0e2b\u0e19\u0e32" }, - { "BoldItalic", "\u0e15\u0e31\u0e27\u0e2b\u0e19\u0e32 \u0e15\u0e31\u0e27\u0e40\u0e2d\u0e35\u0e22\u0e07" }, - { "Name", "\u0e0a\u0e37\u0e48\u0e2d" }, - { "Size", "\u0e02\u0e19\u0e32\u0e14" }, - { "Style", "\u0e25\u0e31\u0e01\u0e29\u0e13\u0e30\u0e41\u0e1a\u0e1a\u0e2d\u0e31\u0e01\u0e29\u0e23" }, - { "TestString", "This is just a Test! The quick brown Fox is doing something. 12,3456.78 LetterLOne = l1 LetterOZero = O0" }, - { "FontString", "\u0e15\u0e31\u0e27\u0e2d\u0e31\u0e01\u0e29\u0e23" }, - // - { "AdempiereColorEditor", "Adempiere Color Editor" }, - { "AdempiereType", "Color Type" }, - { "GradientUpperColor", "Gradient Upper Color" }, - { "GradientLowerColor", "Gradient Lower Color" }, - { "GradientStart", "Gradient Start" }, - { "GradientDistance", "Gradient Distance" }, - { "TextureURL", "Texture URL" }, - { "TextureAlpha", "Texture Alpha" }, - { "TextureTaintColor", "Texture Taint Color" }, - { "LineColor", "Line Color" }, - { "LineBackColor", "Background Color" }, - { "LineWidth", "Line Width" }, - { "LineDistance", "Line Distance" }, - { "FlatColor", "Flat Color" } - }; - - /** - * Get Contents - * @return contents - */ - public Object[][] getContents() - { - return contents; - } -} // Res diff --git a/org.adempiere.ui.swing/src/org/compiere/plaf/PlafRes_vi.java b/org.adempiere.ui.swing/src/org/compiere/plaf/PlafRes_vi.java deleted file mode 100644 index ca279dfea0..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/plaf/PlafRes_vi.java +++ /dev/null @@ -1,131 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ -package org.compiere.plaf; - -import java.util.ListResourceBundle; - -/** - * Translation Texts for Look & Feel - * - * @author Bui Chi Trung - * @version $Id: PlafRes_vi.java,v 1.2 2006/07/30 00:52:23 jjanke Exp $ - */ -public class PlafRes_vi extends ListResourceBundle -{ - /** The data */ - static final Object[][] contents = new String[][] - { - { "BackColType", "Lo\u1EA1i mïżœu n\u1EC1n" }, - { "BackColType_Flat", "Ph\u1EB3ng" }, - { "BackColType_Gradient", "D\u1ED1c" }, - { "BackColType_Lines", "\u0110\u01B0\u1EDDng th\u1EB3ng" }, - { "BackColType_Texture", "\u0110an chïżœo" }, - // - { "LookAndFeelEditor", "Cïżœng c\u1EE5 thay \u0111\u1ED5i V\u1EBB ngoïżœi vïżœ C\u1EA3m nh\u1EADn" }, - { "LookAndFeel", "V\u1EBB ngoïżœi vïżœ C\u1EA3m nh\u1EADn" }, - { "Theme", "Ch\u1EE7 \u0111\u1EC1" }, - { "EditAdempiereTheme", "Hi\u1EC7u ch\u1EC9nh ch\u1EE7 \u0111\u1EC1 C\u0103mpia-\u01A1" }, - { "SetDefault", "N\u1EC1n m\u1EB7c nhiïżœn" }, - { "SetDefaultColor", "Mïżœu n\u1EC1n" }, - { "ColorBlind", "Mïżœ mïżœu" }, - { "Example", "Vïżœ d\u1EE5" }, - { "Reset", "C\u1EA5u hïżœnh l\u1EA1i" }, - { "OK", "\u0110\u1ED3ng ïżœ" }, - { "Cancel", "H\u1EE7y" }, - // - { "AdempiereThemeEditor", "Cïżœng c\u1EE5 thay \u0111\u1ED5i ch\u1EE7 \u0111\u1EC1 C\u0103mpia-\u01A1" }, - { "MetalColors", "B\u1ED9 mïżœu ïżœnh kim" }, - { "AdempiereColors", "B\u1ED9 mïżœu C\u0103mpia-\u01A1" }, - { "AdempiereFonts", "B\u1ED9 Font C\u0103mpia-\u01A1" }, - { "Primary1Info", "Bïżœng, Tïżœch bi\u1EC7t" }, - { "Primary1", "Ch\u1EE7 \u0111\u1EA1o 1" }, - { "Primary2Info", "\u0110\u01B0\u1EDDng tiïżœu \u0111i\u1EC3m, Th\u1EF1c \u0111\u01A1n \u0111\u01B0\u1EE3c ch\u1ECDn" }, - { "Primary2", "Ch\u1EE7 \u0111\u1EA1o 2" }, - { "Primary3Info", "Table Selected Row, Selected Text, ToolTip Background" }, - { "Primary3", "Primary 3" }, - { "Secondary1Info", "\u0110\u01B0\u1EDDng biïżœn" }, - { "Secondary1", "Ph\u1EE5 1" }, - { "Secondary2Info", "Inactive Tabs, Pressed Fields, Inactive Border + Text" }, - { "Secondary2", "Ph\u1EE5 2" }, - { "Secondary3Info", "N\u1EC1n" }, - { "Secondary3", "Ph\u1EE5 3" }, - // - { "ControlFontInfo", "Control Font" }, - { "ControlFont", "Label Font" }, - { "SystemFontInfo", "Tool Tip, Tree nodes" }, - { "SystemFont", "System Font" }, - { "UserFontInfo", "User Entered Data" }, - { "UserFont", "Field Font" }, -// { "SmallFontInfo", "Reports" }, - { "SmallFont", "Small Font" }, - { "WindowTitleFont", "Title Font" }, - { "MenuFont", "Menu Font" }, - // - { "MandatoryInfo", "N\u1EC1n c\u1EE7a tr\u01B0\u1EDDng b\u1EAFt bu\u1ED9c" }, - { "Mandatory", "B\u1EAFt bu\u1ED9c" }, - { "ErrorInfo", "N\u1EC1n c\u1EE7a tr\u01B0\u1EDDng b\u1ECB l\u1ED7i" }, - { "Error", "L\u1ED7i" }, - { "InfoInfo", "N\u1EC1n c\u1EE7a tr\u01B0\u1EDDng thïżœng tin" }, - { "Info", "Thïżœng tin" }, - { "WhiteInfo", "\u0110\u01B0\u1EDDng th\u1EB3ng" }, - { "White", "Tr\u1EAFng" }, - { "BlackInfo", "\u0110\u01B0\u1EDDng th\u1EB3ng, \u0110o\u1EA1n v\u0103n" }, - { "Black", "Black" }, - { "InactiveInfo", "Inactive Field Background" }, - { "Inactive", "Inactive" }, - { "TextOKInfo", "OK Text Foreground" }, - { "TextOK", "Text - OK" }, - { "TextIssueInfo", "Error Text Foreground" }, - { "TextIssue", "Text - Error" }, - // - { "FontChooser", "Ch\u1ECDn Font" }, - { "Fonts", "Fonts" }, - { "Plain", "Plain" }, - { "Italic", "Italic" }, - { "Bold", "Bold" }, - { "BoldItalic", "Bold & Italic" }, - { "Name", "Tïżœn" }, - { "Size", "Kïżœch th\u01B0\u1EDBc" }, - { "Style", "Ki\u1EC3u" }, - { "TestString", "\u0110ïżœy ch\u1EC9 lïżœ ph\u1EA7n th\u1EED nghi\u1EC7m" }, - { "FontString", "Font" }, - // - { "AdempiereColorEditor", "Cïżœng c\u1EE5 thay \u0111\u1ED5i mïżœu C\u0103mpia-\u01A1" }, - { "AdempiereType", "Lo\u1EA1i mïżœu" }, - { "GradientUpperColor", "Gradient Upper Color" }, - { "GradientLowerColor", "Gradient Lower Color" }, - { "GradientStart", "Gradient Start" }, - { "GradientDistance", "Gradient Distance" }, - { "TextureURL", "Texture URL" }, - { "TextureAlpha", "Texture Alpha" }, - { "TextureTaintColor", "Texture Taint Color" }, - { "LineColor", "Line Color" }, - { "LineBackColor", "Background Color" }, - { "LineWidth", "Chi\u1EC1u r\u1ED9ng \u0111\u01B0\u1EDDng" }, - { "LineDistance", "Chi\u1EC1u xa \u0111\u01B0\u1EDDng" }, - { "FlatColor", "Mïżœu ph\u1EB3ng" } - }; - - /** - * Get Contents - * @return contents - */ - public Object[][] getContents() - { - return contents; - } -} // Res diff --git a/org.adempiere.ui.swing/src/org/compiere/plaf/PlafRes_zh.java b/org.adempiere.ui.swing/src/org/compiere/plaf/PlafRes_zh.java deleted file mode 100644 index 310d6a835c..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/plaf/PlafRes_zh.java +++ /dev/null @@ -1,131 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ -package org.compiere.plaf; - -import java.util.ListResourceBundle; - -/** - * Translation Texts for Look & Feel - * - * @author Kirin Lin - * @version $Id: PlafRes_zh.java,v 1.2 2006/07/30 00:52:23 jjanke Exp $ - */ -public class PlafRes_zh extends ListResourceBundle -{ - /** The data */ - static final Object[][] contents = new String[][] - { - { "BackColType", "\u80cc\u666f\u984f\u8272" }, - { "BackColType_Flat", "\u55ae\u8272" }, - { "BackColType_Gradient", "\u6f38\u5c64" }, - { "BackColType_Lines", "\u689d\u7d0b" }, - { "BackColType_Texture", "\u5716\u6848" }, - // - { "LookAndFeelEditor", "\u5916\u89c0\u7de8\u8f2f\u5668" }, - { "LookAndFeel", "\u5916\u89c0" }, - { "Theme", "\u4f48\u666f" }, - { "EditAdempiereTheme", "\u7de8\u8f2f Adempiere \u4f48\u666f" }, - { "SetDefault", "\u8a2d\u6210\u9810\u8a2d\u80cc\u666f" }, - { "SetDefaultColor", "\u80cc\u666f\u984f\u8272" }, - { "ColorBlind", "\u8272\u5dee" }, - { "Example", "\u7bc4\u4f8b" }, - { "Reset", "\u91cd\u7f6e" }, - { "OK", "\u78ba\u5b9a" }, - { "Cancel", "\u53d6\u6d88" }, - // - { "AdempiereThemeEditor", "Adempiere \u4f48\u666f\u7de8\u8f2f\u5668" }, - { "MetalColors", "\u91d1\u5c6c\u8272\u7cfb" }, - { "AdempiereColors", "Adempiere \u984f\u8272" }, - { "AdempiereFonts", "Adempiere \u5b57\u578b" }, - { "Primary1Info", "\u9670\u5f71, \u5206\u9694" }, - { "Primary1", "\u4e3b\u8981\u8272 1" }, - { "Primary2Info", "\u7126\u9ede\u7dda\u6846, \u9078\u55ae\u7126\u9ede" }, - { "Primary2", "\u4e3b\u8981\u8272 2" }, - { "Primary3Info", "\u9078\u53d6\u7684\u884c, \u9078\u53d6\u7684\u5b57, \u5de5\u5177\u63d0\u793a\u80cc\u666f" }, - { "Primary3", "\u4e3b\u8981\u8272 3" }, - { "Secondary1Info", "\u908a\u6846" }, - { "Secondary1", "\u6b21\u8981\u8272 1" }, - { "Secondary2Info", "\u975e\u6d3b\u52d5 Tabs, \u6309\u4e0b\u7684\u6309\u9215\u908a\u7de3, \u975e\u6d3b\u52d5\u5340\u908a\u6846 + \u6587\u5b57" }, - { "Secondary2", "\u6b21\u8981\u8272 2" }, - { "Secondary3Info", "\u80cc\u666f" }, - { "Secondary3", "\u6b21\u8981\u8272 3" }, - // - { "ControlFontInfo", "\u63a7\u5236\u8a0a\u606f\u5b57\u578b" }, - { "ControlFont", "\u6a19\u7c64\u5b57\u578b" }, - { "SystemFontInfo", "\u5de5\u5177\u63d0\u793a, \u6a39\u72c0\u76ee\u9304" }, - { "SystemFont", "\u7cfb\u7d71\u5b57\u578b" }, - { "UserFontInfo", "\u4f7f\u7528\u8005\u8f38\u5165\u8cc7\u6599" }, - { "UserFont", "\u6b04\u4f4d\u5b57\u578b" }, -// { "SmallFontInfo", "\u5831\u8868" }, - { "SmallFont", "\u5c0f\u5b57\u578b" }, - { "WindowTitleFont", "\u6a19\u984c\u5b57\u578b" }, - { "MenuFont", "\u9078\u55ae\u5b57\u578b" }, - // - { "MandatoryInfo", "\u9078\u9805\u6b04\u4f4d\u80cc\u666f" }, - { "Mandatory", "\u9078\u9805" }, - { "ErrorInfo", "\u932f\u8aa4\u8a0a\u606f\u80cc\u666f" }, - { "Error", "\u932f\u8aa4\u8a0a\u606f" }, - { "InfoInfo", "\u4e00\u822c\u8a0a\u606f\u6b04\u4f4d\u80cc\u666f" }, - { "Info", "\u4e00\u822c\u8a0a\u606f" }, - { "WhiteInfo", "\u7dda\u689d" }, - { "White", "\u767d" }, - { "BlackInfo", "\u7dda\u689d, \u6587\u5b57" }, - { "Black", "\u9ed1" }, - { "InactiveInfo", "\u975e\u6d3b\u52d5\u6b04\u4f4d\u80cc\u666f" }, - { "Inactive", "\u975e\u6d3b\u52d5" }, - { "TextOKInfo", "\u78ba\u5b9a\u9805\u524d\u666f\u8272" }, - { "TextOK", "\u6587\u5b57 - \u78ba\u5b9a" }, - { "TextIssueInfo", "\u932f\u8aa4\u9805\u524d\u666f\u8272" }, - { "TextIssue", "\u6587\u5b57 - \u932f\u8aa4" }, - // - { "FontChooser", "\u5b57\u578b\u8a2d\u5b9a" }, - { "Fonts", "\u5b57\u9ad4" }, - { "Plain", "\u4e00\u822c" }, - { "Italic", "\u659c\u9ad4" }, - { "Bold", "\u7c97\u9ad4" }, - { "BoldItalic", "\u7c97\u659c\u9ad4" }, - { "Name", "\u540d\u7a31" }, - { "Size", "\u5927\u5c0f" }, - { "Style", "\u98a8\u683c" }, - { "TestString", "\u9019\u662f\u6e2c\u8a66! The quick brown Fox is doing something. 12,3456.78 LetterLOne = l1 LetterOZero = O0" }, - { "FontString", "\u5b57\u9ad4" }, - // - { "AdempiereColorEditor", "Adempiere \u984f\u8272\u7de8\u8f2f\u5668" }, - { "AdempiereType", "\u984f\u8272\u7a2e\u985e" }, - { "GradientUpperColor", "\u6f38\u5c64\u8272 1" }, - { "GradientLowerColor", "\u6f38\u5c64\u8272 2" }, - { "GradientStart", "\u6f38\u5c64\u65b9\u5411" }, - { "GradientDistance", "\u9593\u8ddd" }, - { "TextureURL", "\u5716\u6848 URL" }, - { "TextureAlpha", "\u5716\u6848\u900f\u660e\u5ea6" }, - { "TextureTaintColor", "\u5716\u6848\u8457\u8272" }, - { "LineColor", "\u7dda\u689d\u984f\u8272" }, - { "LineBackColor", "\u80cc\u666f\u984f\u8272" }, - { "LineWidth", "\u7dda\u689d\u5bec\u5ea6" }, - { "LineDistance", "\u7dda\u689d\u9593\u8ddd" }, - { "FlatColor", "\u55ae\u8272" } - }; - - /** - * Get Contents - * @return contents - */ - public Object[][] getContents() - { - return contents; - } -} // Res diff --git a/org.adempiere.ui.swing/src/org/compiere/plaf/PlafRes_zh_CN.java b/org.adempiere.ui.swing/src/org/compiere/plaf/PlafRes_zh_CN.java deleted file mode 100644 index a8639566b7..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/plaf/PlafRes_zh_CN.java +++ /dev/null @@ -1,131 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ -package org.compiere.plaf; - -import java.util.ListResourceBundle; - -/** - * Translation Texts for Look & Feel - * - * @author ZhaoXing Meng - * @version $Id: PlafRes_zh_CN.java,v 1.2 2006/07/30 00:52:24 jjanke Exp $ - */ -public class PlafRes_zh_CN extends ListResourceBundle -{ - /** The data */ - static final Object[][] contents = new String[][] - { - { "BackColType", "\u80cc\u666f\u989c\u8272" }, - { "BackColType_Flat", "\u5355\u8272" }, - { "BackColType_Gradient", "\u6e10\u53d8" }, - { "BackColType_Lines", "\u6761\u7eb9" }, - { "BackColType_Texture", "\u56fe\u6587" }, - // - { "LookAndFeelEditor", "\u5916\u89c2\u7f16\u8f91\u5668" }, - { "LookAndFeel", "\u5916\u89c2" }, - { "Theme", "\u5e03\u666f" }, - { "EditAdempiereTheme", "\u7f16\u8f91 Adempiere \u5e03\u666f" }, - { "SetDefault", "\u8bbe\u6210\u9884\u5b9a\u80cc\u666f" }, - { "SetDefaultColor", "\u80cc\u666f\u989c\u8272" }, - { "ColorBlind", "\u8272\u5dee" }, - { "Example", "\u8303\u4f8b" }, - { "Reset", "\u91cd\u8bbe" }, - { "OK", "\u786e\u8ba4" }, - { "Cancel", "\u64a4\u6d88" }, - // - { "AdempiereThemeEditor", "Adempiere \u5e03\u666f\u7f16\u8f91\u5668" }, - { "MetalColors", "\u91d1\u5c5e\u8272\u7cfb" }, - { "AdempiereColors", "Adempiere \u989c\u8272" }, - { "AdempiereFonts", "Adempiere \u5b57\u4f53" }, - { "Primary1Info", "\u9634\u5f71, \u5206\u9694" }, - { "Primary1", "\u4e3b\u8981\u8272 1" }, - { "Primary2Info", "\u7126\u70b9\u7ebf\u6846, \u83dc\u5355\u7126\u70b9" }, - { "Primary2", "\u4e3b\u8981\u8272 2" }, - { "Primary3Info", "\u9009\u62e9\u7684\u884c, \u9009\u62e9\u7684\u6587\u5b57, \u5de5\u5177\u63d0\u793a\u80cc\u666f" }, - { "Primary3", "\u4e3b\u8981\u8272 3" }, - { "Secondary1Info", "\u8fb9\u6846" }, - { "Secondary1", "\u6b21\u8981\u8272 1" }, - { "Secondary2Info", "\u975e\u6d3b\u52a8\u6807\u7b7e, \u6309\u4e0b\u7684\u6309\u94ae\u8fb9\u7f18, \u975e\u6d3b\u52a8\u533a\u8fb9\u6846 + \u6587\u5b57" }, - { "Secondary2", "\u6b21\u8981\u8272 2" }, - { "Secondary3Info", "\u80cc\u666f" }, - { "Secondary3", "\u6b21\u8981\u8272 3" }, - // - { "ControlFontInfo", "\u63a7\u5236\u4fe1\u606f\u5b57\u4f53" }, - { "ControlFont", "\u6807\u7b7e\u5b57\u4f53" }, - { "SystemFontInfo", "\u5de5\u5177\u63d0\u793a, \u6811\u72b6\u76ee\u5f55" }, - { "SystemFont", "\u7cfb\u7edf\u5b57\u4f53" }, - { "UserFontInfo", "\u4f7f\u7528\u8005\u8f93\u5165\u6570\u636e" }, - { "UserFont", "\u5b57\u6bb5\u5b57\u4f53" }, -// { "SmallFontInfo", "\u62a5\u8868" }, - { "SmallFont", "\u5c0f\u5b57\u4f53" }, - { "WindowTitleFont", "\u6807\u9898\u5b57\u4f53" }, - { "MenuFont", "\u83dc\u5355\u5b57\u4f53" }, - // - { "MandatoryInfo", "\u9009\u9879\u5b57\u6bb5\u80cc\u666f" }, - { "Mandatory", "\u9009\u9879" }, - { "ErrorInfo", "\u9519\u8bef\u5b57\u6bb5\u80cc\u666f" }, - { "Error", "\u9519\u8bef\u4fe1\u606f" }, - { "InfoInfo", "\u4e00\u822c\u4fe1\u606f\u5b57\u6bb5\u80cc\u666f" }, - { "Info", "\u4e00\u822c\u4fe1\u606f" }, - { "WhiteInfo", "\u7ebf\u6761" }, - { "White", "\u767d" }, - { "BlackInfo", "\u7ebf\u6761, \u6587\u5b57" }, - { "Black", "\u9ed1" }, - { "InactiveInfo", "\u975e\u6d3b\u52a8\u5b57\u6bb5\u80cc\u666f" }, - { "Inactive", "\u975e\u6d3b\u52a8" }, - { "TextOKInfo", "\u786e\u8ba4 - \u524d\u666f\u8272" }, - { "TextOK", "\u6587\u5b57 - \u786e\u8ba4" }, - { "TextIssueInfo", "\u9519\u8bef\u6587\u5b57\u524d\u666f\u8272" }, - { "TextIssue", "\u6587\u5b57 - \u9519\u8bef" }, - // - { "FontChooser", "\u5b57\u4f53\u9009\u62e9" }, - { "Fonts", "\u5b57\u4f53" }, - { "Plain", "\u666e\u901a" }, - { "Italic", "\u659c\u4f53" }, - { "Bold", "\u7c97\u4f53" }, - { "BoldItalic", "\u7c97\u659c\u4f53" }, - { "Name", "\u540d\u79f0" }, - { "Size", "\u5927\u5c0f" }, - { "Style", "\u7c7b\u578b" }, - { "TestString", "\u8fd9\u662f\u6d4b\u8bd5! The quick brown Fox is doing something. 12,3456.78 LetterLOne = l1 LetterOZero = O0" }, - { "FontString", "\u5b57\u4f53" }, - // - { "AdempiereColorEditor", "Adempiere \u989c\u8272\u7f16\u8f91\u5668" }, - { "AdempiereType", "\u989c\u8272\u79cd\u7c7b" }, - { "GradientUpperColor", "\u6e10\u589e\u8272 1" }, - { "GradientLowerColor", "\u6e10\u51cf\u8272 2" }, - { "GradientStart", "\u6e10\u589e\u65b9\u5411" }, - { "GradientDistance", "\u95f4\u8ddd" }, - { "TextureURL", "\u56fe\u6848 URL" }, - { "TextureAlpha", "\u56fe\u6848\u900f\u660e\u5ea6" }, - { "TextureTaintColor", "\u56fe\u6848\u7740\u8272" }, - { "LineColor", "\u7ebf\u6761\u989c\u8272" }, - { "LineBackColor", "\u80cc\u666f\u989c\u8272" }, - { "LineWidth", "\u7ebf\u6761\u5bbd\u5ea6" }, - { "LineDistance", "\u7ebf\u6761\u95f4\u8ddd" }, - { "FlatColor", "\u5355\u8272" } - }; - - /** - * Get Contents - * @return contents - */ - public Object[][] getContents() - { - return contents; - } -} // Res diff --git a/org.adempiere.ui.swing/src/org/compiere/plaf/RubyTheme.java b/org.adempiere.ui.swing/src/org/compiere/plaf/RubyTheme.java deleted file mode 100644 index 332b3adee7..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/plaf/RubyTheme.java +++ /dev/null @@ -1,44 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ -package org.compiere.plaf; - -/* - * @(#)RubyTheme.java 1.9 04/07/26 - */ - -import javax.swing.plaf.ColorUIResource; -import javax.swing.plaf.metal.DefaultMetalTheme; - -/** - * This class describes a theme using red colors. - * - * @version 1.9 07/26/04 - * @author Jeff Dinkins - */ -public class RubyTheme extends DefaultMetalTheme { - - public String getName() { return "Ruby"; } - - private final ColorUIResource primary1 = new ColorUIResource(80, 10, 22); - private final ColorUIResource primary2 = new ColorUIResource(193, 10, 44); - private final ColorUIResource primary3 = new ColorUIResource(244, 10, 66); - - protected ColorUIResource getPrimary1() { return primary1; } - protected ColorUIResource getPrimary2() { return primary2; } - protected ColorUIResource getPrimary3() { return primary3; } - -} diff --git a/org.adempiere.ui.swing/src/org/compiere/plaf/icons/CL16.gif b/org.adempiere.ui.swing/src/org/compiere/plaf/icons/CL16.gif deleted file mode 100644 index 27d903c3e2..0000000000 Binary files a/org.adempiere.ui.swing/src/org/compiere/plaf/icons/CL16.gif and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/compiere/plaf/icons/CL32.gif b/org.adempiere.ui.swing/src/org/compiere/plaf/icons/CL32.gif deleted file mode 100644 index c83d267cbd..0000000000 Binary files a/org.adempiere.ui.swing/src/org/compiere/plaf/icons/CL32.gif and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/compiere/plaf/icons/Cancel24.gif b/org.adempiere.ui.swing/src/org/compiere/plaf/icons/Cancel24.gif deleted file mode 100644 index d91a52dc0c..0000000000 Binary files a/org.adempiere.ui.swing/src/org/compiere/plaf/icons/Cancel24.gif and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/compiere/plaf/icons/Error.gif b/org.adempiere.ui.swing/src/org/compiere/plaf/icons/Error.gif deleted file mode 100644 index b2ac9f57b4..0000000000 Binary files a/org.adempiere.ui.swing/src/org/compiere/plaf/icons/Error.gif and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/compiere/plaf/icons/Inform.gif b/org.adempiere.ui.swing/src/org/compiere/plaf/icons/Inform.gif deleted file mode 100644 index 2ac57475c3..0000000000 Binary files a/org.adempiere.ui.swing/src/org/compiere/plaf/icons/Inform.gif and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/compiere/plaf/icons/Ok24.gif b/org.adempiere.ui.swing/src/org/compiere/plaf/icons/Ok24.gif deleted file mode 100644 index 027d18f531..0000000000 Binary files a/org.adempiere.ui.swing/src/org/compiere/plaf/icons/Ok24.gif and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/compiere/plaf/icons/Question.gif b/org.adempiere.ui.swing/src/org/compiere/plaf/icons/Question.gif deleted file mode 100644 index dc19aa1706..0000000000 Binary files a/org.adempiere.ui.swing/src/org/compiere/plaf/icons/Question.gif and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/compiere/plaf/icons/Warn.gif b/org.adempiere.ui.swing/src/org/compiere/plaf/icons/Warn.gif deleted file mode 100644 index a05e160c20..0000000000 Binary files a/org.adempiere.ui.swing/src/org/compiere/plaf/icons/Warn.gif and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/compiere/plaf/package.html b/org.adempiere.ui.swing/src/org/compiere/plaf/package.html deleted file mode 100644 index bcca4ad220..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/plaf/package.html +++ /dev/null @@ -1,24 +0,0 @@ - - - - - -

    Provides for Pluggabe Look & Feel User Interface. -

    -

    Package Specification

    - -

    The classes extend the Metal Look & Feel.

    -

    Related Documentation

    - -For overviews, tutorials, examples, guides, and tool documentation, please see -http://www.adempiere.org/looks - - diff --git a/org.adempiere.ui.swing/src/org/compiere/plaf/sounds/FrameClose.wav b/org.adempiere.ui.swing/src/org/compiere/plaf/sounds/FrameClose.wav deleted file mode 100644 index 873285b1ef..0000000000 Binary files a/org.adempiere.ui.swing/src/org/compiere/plaf/sounds/FrameClose.wav and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/compiere/plaf/sounds/FrameMaximize.wav b/org.adempiere.ui.swing/src/org/compiere/plaf/sounds/FrameMaximize.wav deleted file mode 100644 index 49905b8367..0000000000 Binary files a/org.adempiere.ui.swing/src/org/compiere/plaf/sounds/FrameMaximize.wav and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/compiere/plaf/sounds/FrameMinimize.wav b/org.adempiere.ui.swing/src/org/compiere/plaf/sounds/FrameMinimize.wav deleted file mode 100644 index 2dab1ce569..0000000000 Binary files a/org.adempiere.ui.swing/src/org/compiere/plaf/sounds/FrameMinimize.wav and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/compiere/plaf/sounds/FrameRestoreDown.wav b/org.adempiere.ui.swing/src/org/compiere/plaf/sounds/FrameRestoreDown.wav deleted file mode 100644 index 4363f479d3..0000000000 Binary files a/org.adempiere.ui.swing/src/org/compiere/plaf/sounds/FrameRestoreDown.wav and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/compiere/plaf/sounds/FrameRestoreUp.wav b/org.adempiere.ui.swing/src/org/compiere/plaf/sounds/FrameRestoreUp.wav deleted file mode 100644 index d82b011188..0000000000 Binary files a/org.adempiere.ui.swing/src/org/compiere/plaf/sounds/FrameRestoreUp.wav and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/compiere/plaf/sounds/MenuItemCommand.wav b/org.adempiere.ui.swing/src/org/compiere/plaf/sounds/MenuItemCommand.wav deleted file mode 100644 index 487746c661..0000000000 Binary files a/org.adempiere.ui.swing/src/org/compiere/plaf/sounds/MenuItemCommand.wav and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/compiere/plaf/sounds/OptionPaneError.wav b/org.adempiere.ui.swing/src/org/compiere/plaf/sounds/OptionPaneError.wav deleted file mode 100644 index 55e39eb499..0000000000 Binary files a/org.adempiere.ui.swing/src/org/compiere/plaf/sounds/OptionPaneError.wav and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/compiere/plaf/sounds/OptionPaneInformation.wav b/org.adempiere.ui.swing/src/org/compiere/plaf/sounds/OptionPaneInformation.wav deleted file mode 100644 index 6dad743f1d..0000000000 Binary files a/org.adempiere.ui.swing/src/org/compiere/plaf/sounds/OptionPaneInformation.wav and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/compiere/plaf/sounds/OptionPaneQuestion.wav b/org.adempiere.ui.swing/src/org/compiere/plaf/sounds/OptionPaneQuestion.wav deleted file mode 100644 index 82eccb4f76..0000000000 Binary files a/org.adempiere.ui.swing/src/org/compiere/plaf/sounds/OptionPaneQuestion.wav and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/compiere/plaf/sounds/OptionPaneWarning.wav b/org.adempiere.ui.swing/src/org/compiere/plaf/sounds/OptionPaneWarning.wav deleted file mode 100644 index 64ddda2aeb..0000000000 Binary files a/org.adempiere.ui.swing/src/org/compiere/plaf/sounds/OptionPaneWarning.wav and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/compiere/plaf/sounds/PopupMenuPopup.wav b/org.adempiere.ui.swing/src/org/compiere/plaf/sounds/PopupMenuPopup.wav deleted file mode 100644 index 1eb388fced..0000000000 Binary files a/org.adempiere.ui.swing/src/org/compiere/plaf/sounds/PopupMenuPopup.wav and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/compiere/plaf/vincent.jpg b/org.adempiere.ui.swing/src/org/compiere/plaf/vincent.jpg deleted file mode 100644 index 0ee8ede107..0000000000 Binary files a/org.adempiere.ui.swing/src/org/compiere/plaf/vincent.jpg and /dev/null differ diff --git a/org.adempiere.ui.swing/src/org/compiere/pos/AdempierePOSException.java b/org.adempiere.ui.swing/src/org/compiere/pos/AdempierePOSException.java deleted file mode 100644 index b6ddd8278e..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/pos/AdempierePOSException.java +++ /dev/null @@ -1,17 +0,0 @@ -package org.compiere.pos; - -import org.adempiere.exceptions.AdempiereException; - -public class AdempierePOSException extends AdempiereException { - - public AdempierePOSException(String message) { - super(message); - } - - /** - * - */ - private static final long serialVersionUID = -9117127988717827183L; - - -} diff --git a/org.adempiere.ui.swing/src/org/compiere/pos/CashSubFunctions.java b/org.adempiere.ui.swing/src/org/compiere/pos/CashSubFunctions.java deleted file mode 100644 index a2f972b09b..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/pos/CashSubFunctions.java +++ /dev/null @@ -1,572 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 Adempiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - *****************************************************************************/ - -package org.compiere.pos; - -import java.awt.BorderLayout; -import java.awt.Dimension; -import java.awt.GridBagConstraints; -import java.awt.GridBagLayout; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.awt.event.InputMethodEvent; -import java.awt.event.InputMethodListener; -import java.math.BigDecimal; -import java.sql.Timestamp; -import java.util.Properties; -import java.util.logging.Level; - -import javax.swing.border.TitledBorder; - -import org.compiere.apps.AEnv; -import org.compiere.apps.ConfirmPanel; -import org.compiere.grid.ed.VNumber; -import org.compiere.model.MCash; -import org.compiere.model.MCashBook; -import org.compiere.model.MCashLine; -import org.compiere.model.MOrder; -import org.compiere.model.MQuery; -import org.compiere.swing.CButton; -import org.compiere.swing.CLabel; -import org.compiere.swing.CPanel; -import org.compiere.swing.CScrollPane; -import org.compiere.util.CLogger; -import org.compiere.util.DisplayType; -import org.compiere.util.Env; -import org.compiere.util.Msg; -import org.compiere.util.TimeUtil; - -/** - * @author Comunidad de Desarrollo OpenXpertya - * *Basado en Codigo Original Modificado, Revisado y Optimizado de: - * *Jose A.Gonzalez, Conserti. - * - * @version $Id: CashSubFunctions.java,v 0.9 $ - * - * @Colaborador $Id: Consultoria y Soporte en Redes y Tecnologias de la Informacion S.L. - * - */ - -public class CashSubFunctions extends PosQuery implements ActionListener, InputMethodListener -{ - /** - * - */ - private static final long serialVersionUID = 4020633764275099369L; - - /** - * Constructor - */ - public CashSubFunctions (PosBasePanel posPanel) - { - super(posPanel); - } // PosQueryProduct - - private CButton f_displayInitialChange = null; - private CButton f_inputsOutputs = null; - private CButton f_tickets = null; - private CButton f_closingCash = null; - private CButton f_displayCashScrutiny = null; - private CButton f_pos = null; - private CPanel c; - - // for initial change - private CPanel cInitial; - private CLabel l_PreviousChange = null; - private VNumber v_PreviousChange; - private CLabel l_change = null; - private VNumber v_change; - private CButton f_change = null; - - // for cash scrutiny - private CPanel cScrutiny; - private CLabel l_previousBalance = null; - private VNumber v_previousBalance; - private CLabel l_ActualBalance = null; - private VNumber v_ActualBalance; - private CLabel l_difference = null; - private VNumber v_difference; - private CButton f_calculateDifference = null; - - private CPanel panel; - @SuppressWarnings("unused") - private CScrollPane centerScroll; - @SuppressWarnings("unused") - private ConfirmPanel confirm; - private Properties p_ctx; - - /** Logger */ - private static CLogger log = CLogger.getCLogger(CashSubFunctions.class); - - /** - * Set up Panel - */ - protected void init() - { - CPanel main = new CPanel(); - main.setLayout(new BorderLayout(2,6)); - main.setPreferredSize(new Dimension(400,600)); - getContentPane().add(main); - // North - panel = new CPanel(new GridBagLayout()); - main.add (panel, BorderLayout.CENTER); - panel.setBorder(new TitledBorder(Msg.getMsg(p_ctx, "Cash Functions"))); - GridBagConstraints gbc = new GridBagConstraints(); - // - gbc.gridx = 0; - gbc.gridy = 0; - gbc.anchor = GridBagConstraints.CENTER; - gbc.weightx = .3; - gbc.weighty = 0.05; - - - //******************** Main buttons ********************************** - - f_displayInitialChange = createButtonAction("InitialChange", null); - f_displayInitialChange.setText("Initial Change"); - f_displayInitialChange.setActionCommand("displayInitialChange"); - f_displayInitialChange.setMaximumSize(new Dimension(160,35)); - f_displayInitialChange.setMinimumSize(new Dimension(160,35)); - f_displayInitialChange.setPreferredSize(new Dimension(160,35)); - panel.add (f_displayInitialChange, gbc); - // - f_closingCash = createButtonAction("InitialChange", null); - f_closingCash.setText("Cash Closing"); - f_closingCash.setActionCommand("CashClosing"); - f_closingCash.setPreferredSize(new Dimension(160,35)); - f_closingCash.setMaximumSize(new Dimension(160,35)); - f_closingCash.setMinimumSize(new Dimension(160,35)); - gbc.gridy = 1; - panel.add (f_closingCash, gbc); - // - f_displayCashScrutiny = createButtonAction("Scrutiny", null); - f_displayCashScrutiny.setText("Cash Scrutiny"); - f_displayCashScrutiny.setActionCommand("displayCashScrutiny"); - f_displayCashScrutiny.setPreferredSize(new Dimension(160,35)); - f_displayCashScrutiny.setMaximumSize(new Dimension(160,35)); - f_displayCashScrutiny.setMinimumSize(new Dimension(160,35)); - gbc.gridy = 2; - panel.add (f_displayCashScrutiny, gbc); - // - f_inputsOutputs = createButtonAction("Inputs", null); - f_inputsOutputs.setText("Inputs and Outputs"); - f_inputsOutputs.setActionCommand("InputsOutputs"); - f_inputsOutputs.setPreferredSize(new Dimension(160,35)); - f_inputsOutputs.setMaximumSize(new Dimension(160,35)); - f_inputsOutputs.setMinimumSize(new Dimension(160,35)); - gbc.gridy = 3; - panel.add (f_inputsOutputs, gbc); - // - f_tickets = createButtonAction("Tickets", null); - f_tickets.setText("Tickets"); - f_tickets.setPreferredSize(new Dimension(160,35)); - f_tickets.setMaximumSize(new Dimension(160,35)); - f_tickets.setMinimumSize(new Dimension(160,35)); - gbc.gridy = 4; - panel.add (f_tickets, gbc); - // - f_pos = createButtonAction("End", null); - f_pos.setText("POS"); - f_pos.setPreferredSize(new Dimension(160,35)); - f_pos.setMaximumSize(new Dimension(160,35)); - f_pos.setMinimumSize(new Dimension(160,35)); - gbc.gridy = 5; - panel.add (f_pos, gbc); - - //*************************** Panel to put buttons ************************* - gbc.gridx = 1; - gbc.anchor = GridBagConstraints.WEST; - gbc.gridy = 0; - gbc.gridheight = 5; - - c = new CPanel(new GridBagLayout()); - c.setBorder(new TitledBorder("")); - c.setMaximumSize(new Dimension(400,400)); - c.setMinimumSize(new Dimension(400,400)); - c.setPreferredSize(new Dimension(400,400)); - panel.add (c, gbc); - - - - //*************************** Panel for initial change ************************* - gbc.gridx = 1; - gbc.anchor = GridBagConstraints.WEST; - gbc.gridy = 0; - gbc.gridheight = 5; - cInitial = new CPanel(new GridBagLayout()); - cInitial.setBorder(new TitledBorder("Initial Change")); - cInitial.setVisible(false); - panel.add (cInitial, gbc); - GridBagConstraints gbc0 = new GridBagConstraints(); - gbc0.anchor = GridBagConstraints.CENTER; - // - gbc0.gridx = 0; - gbc0.gridy = 0; - l_PreviousChange = new CLabel("Previous Change"); - cInitial.add (l_PreviousChange, gbc0); - - gbc0.gridx = 1; - v_PreviousChange = new VNumber("PreviousChange", false, true, false, DisplayType.Amount, "PreviousChange"); - v_PreviousChange.setColumns(10, 25); - cInitial.add(v_PreviousChange, gbc0); - v_PreviousChange.setValue(Env.ZERO); - // - gbc0.gridx = 0; - gbc0.gridy = 1; - l_change = new CLabel("Initial Change"); - cInitial.add (l_change, gbc0); - - gbc0.gridx = 1; - v_change = new VNumber("Change", false, false, true, DisplayType.Amount, "Change"); - v_change.setColumns(10, 25); - cInitial.add(v_change, gbc0); - v_change.setValue(Env.ZERO); - - gbc0.gridy = 2; - gbc0.gridx = 0; - gbc0.gridwidth = 2; - //gbc0.fill = GridBagConstraints.HORIZONTAL; - f_change = createButtonAction("InitialChange", null); - f_change.setText("Save Change"); - f_change.setActionCommand("saveChange"); - cInitial.add (f_change, gbc0); - f_change.setPreferredSize(new Dimension(160,35)); - f_change.setMaximumSize(new Dimension(160,35)); - f_change.setMinimumSize(new Dimension(160,35)); - - cInitial.setMaximumSize(new Dimension(400,400)); - cInitial.setMinimumSize(new Dimension(400,400)); - cInitial.setPreferredSize(new Dimension(400,400)); - - - //****************************** Panel for cash scrutiniy ************************ - gbc.gridx = 1; - gbc.anchor = GridBagConstraints.WEST; - gbc.gridy = 0; - gbc.gridheight = 5; - - // gbc.weightx = .7; - - cScrutiny = new CPanel(new GridBagLayout()); - cScrutiny.setBorder(new TitledBorder("Cash Scrutiny")); - cScrutiny.setVisible(false); - panel.add (cScrutiny, gbc); - GridBagConstraints gbc1 = new GridBagConstraints(); - gbc1.anchor = GridBagConstraints.CENTER; - - // - gbc1.gridx = 0; - gbc1.gridy = 0; - l_previousBalance = new CLabel("Previous Balance"); - cScrutiny.add (l_previousBalance, gbc1); - - gbc1.gridx = 1; - v_previousBalance = new VNumber("PreviousBalance", false, true, false, DisplayType.Amount, "PreviousBalance"); - v_previousBalance.setColumns(10, 25); - cScrutiny.add(v_previousBalance, gbc1); - v_previousBalance.setValue(Env.ZERO); - - // - gbc1.gridx = 0; - gbc1.gridy = 1; - l_ActualBalance = new CLabel("Actual Balance"); - cScrutiny.add (l_ActualBalance, gbc1); - - gbc1.gridx = 1; - v_ActualBalance = new VNumber("ActualBalance", false, false, true, DisplayType.Amount, "ActualBalance"); - v_ActualBalance.setColumns(10, 25); - v_ActualBalance.addActionListener(this); - v_ActualBalance.addInputMethodListener(this); - cScrutiny.add(v_ActualBalance, gbc1); - v_ActualBalance.setValue(Env.ZERO); - - // - gbc1.gridx = 0; - gbc1.gridy = 2; - l_difference = new CLabel("Difference"); - cScrutiny.add (l_difference, gbc1); - - gbc1.gridx = 1; - v_difference = new VNumber("Difference", false, true, false, DisplayType.Amount, "Difference"); - v_difference.setColumns(10, 25); - cScrutiny.add(v_difference, gbc1); - v_difference.setValue(Env.ZERO); - - // - gbc1.gridx = 0; - gbc1.gridy = 4; - gbc1.gridwidth = 2; - gbc1.fill = GridBagConstraints.HORIZONTAL; - f_calculateDifference = createButtonAction("InitialChange", null); - f_calculateDifference.setText("Annotate Difference"); - f_calculateDifference.setActionCommand("AnnotateDiference"); - cScrutiny.add (f_calculateDifference, gbc1); - - cScrutiny.setMaximumSize(new Dimension(400,400)); - cScrutiny.setMinimumSize(new Dimension(400,400)); - cScrutiny.setPreferredSize(new Dimension(400,400)); - } // init - - - /** - * Dispose - */ - public void dispose() - { - removeAll(); - panel = null; - centerScroll = null; - confirm = null; - } // dispose - - - /** - * Action Listener - * @param e event - */ - public void actionPerformed (ActionEvent e) - { - String action = e.getActionCommand(); - if (action == null || action.length() == 0) - return; - if (log.isLoggable(Level.INFO)) log.info("PosCashSubFunctions - actionPerformed: " + action); - - // to display panel with initial change - if (action.equals("displayInitialChange")) - { - cmd_displayInitialChange(); - cInitial.setVisible(false); - } - // to display panel with cash closing - else if (action.equals("CashClosing")) - { - Timestamp today = TimeUtil.getDay(System.currentTimeMillis()); - - MCash cash = MCash.get(p_pos.getCtx(), /*p_pos.getAD_Org_ID(),*/ p_pos.getC_CashBook_ID(), today, null); - - MQuery query = new MQuery(MCash.Table_Name); - query.addRestriction("C_Cash_ID", MQuery.EQUAL, cash.getC_Cash_ID()); - AEnv.zoom(query); - } - // to open window with inputs and outputs of cash - else if (action.equals("InputsOutputs")) - { - Timestamp today = TimeUtil.getDay(System.currentTimeMillis()); - - MCash cash = MCash.get(p_pos.getCtx(), /*p_pos.getAD_Org_ID(),*/ p_pos.getC_CashBook_ID(), today, null); - - AEnv.zoom(MCash.Table_ID, cash.getC_Cash_ID()); - } - else if (action.equals("Tickets")) - { - MQuery query = new MQuery(MOrder.Table_Name); - query.addRestriction("C_DocTypeTarget_ID", MQuery.EQUAL, p_pos.getC_DocType_ID()); - AEnv.zoom(query); - } - // Cash (Payment) - else if (action.equals("displayCashScrutiny")) - { - cmd_displayCashScrutiny(); - } - else if (action.equals("End")) - { - super.dispose(); - } - else if (action.equals("saveChange")) - { - cmd_saveChange(); - } - else if (action.equals("AnnotateDifference")) - { - cmd_calculateDifference(); - cmd_annotateDifference(); - } - else if (e.getSource() == v_ActualBalance) - cmd_calculateDifference(); - - - } // actionPerformed - - /** - * Desplegar panel de Cambio Inicial - * - * @author Comunidad de Desarrollo OpenXpertya - * *Basado en Codigo Original Modificado, Revisado y Optimizado de: - * *Copyright (c) ConSerTi - */ - private void cmd_displayInitialChange() - { - if (cScrutiny.isVisible()) - cScrutiny.setVisible(false); - if (c.isVisible()) - c.setVisible(false); - cInitial.setVisible(true); - - Timestamp today = TimeUtil.getDay(System.currentTimeMillis()); - - MCash cash = MCash.get(p_pos.getCtx(), /*p_pos.getAD_Org_ID(),*/ p_pos.getC_CashBook_ID(), today, null); - - if (cash != null) - { - v_PreviousChange.setValue(cash.getEndingBalance()); - v_change.setValue(cash.getEndingBalance()); - } - else - log.severe("No Cash"); - } - - /** - * Desplegar panel de Scrutiny de caja - * - * @author Comunidad de Desarrollo OpenXpertya - * *Basado en Codigo Original Modificado, Revisado y Optimizado de: - * *Copyright (c) ConSerTi - */ - private void cmd_displayCashScrutiny() - { - if (cInitial.isVisible()) - cInitial.setVisible(false); - if (c.isVisible()) - c.setVisible(false); - cScrutiny.setVisible(true); - - // calculate total until the moment and shows it in scrutiny panel - Timestamp today = TimeUtil.getDay(System.currentTimeMillis()); - - MCash cash = MCash.get(p_pos.getCtx(), /*p_pos.getAD_Org_ID(),*/ p_pos.getC_CashBook_ID(), today, null); - - v_previousBalance.setValue(cash.getEndingBalance()); - } - - /** - * Save the initial change of the cash - * - * @author Comunidad de Desarrollo OpenXpertya - * *Basado en Codigo Original Modificado, Revisado y Optimizado de: - * *Copyright (c) ConSerTi - */ - private void cmd_saveChange() - { - @SuppressWarnings("unused") - MCashBook cashBook = new MCashBook(p_ctx, p_pos.getC_CashBook_ID(), null); - Timestamp today = TimeUtil.getDay(System.currentTimeMillis()); - - MCash cash = MCash.get(p_ctx, /*p_pos.getAD_Org_ID(),*/ p_pos.getC_CashBook_ID(), today, null); - - BigDecimal initialChange = (BigDecimal)v_change.getValue(); - - if (cash != null && cash.get_ID() != 0 && initialChange.compareTo(cash.getEndingBalance()) != 0) - { - MCashLine cl = new MCashLine (cash); - cl.setCashType(MCashLine.CASHTYPE_Difference); - cl.setAmount(initialChange.subtract(cash.getEndingBalance())); - cl.setDescription("Initial Change Before: " + cash.getEndingBalance() + " Now: " + initialChange); - cl.saveEx(); - } - v_PreviousChange.setValue(initialChange); - } - - /** - * Calculate difference between previous balance and actual - * for cash scrutiny - * - * @author Comunidad de Desarrollo OpenXpertya - * *Basado en Codigo Original Modificado, Revisado y Optimizado de: - * *Copyright (c) ConSerTi - */ - private void cmd_calculateDifference() - { - // calculate difference between scrutiny of previous and actual balance - BigDecimal previousValue, actualValue; - - Timestamp today = TimeUtil.getDay(System.currentTimeMillis()); - MCash cash = MCash.get(p_pos.getCtx(), /*p_pos.getAD_Org_ID(),*/ p_pos.getC_CashBook_ID(), today, null); - v_previousBalance.setValue(cash.getEndingBalance()); - previousValue = cash.getEndingBalance(); - - actualValue = (BigDecimal)v_ActualBalance.getValue(); - - v_difference.setValue(actualValue.subtract(previousValue)); - } - - /** - * Annotate the difference between previous balance and actual - * from cash scrutiny in the cash book - * - * @author Comunidad de Desarrollo OpenXpertya - * *Basado en Codigo Original Modificado, Revisado y Optimizado de: - * *Copyright (c) ConSerTi - */ - private void cmd_annotateDifference() - { - // calculate difference from scrutiny between previous and actual balance - BigDecimal previousValue, actualValue, difference; - previousValue = (BigDecimal)v_previousBalance.getValue(); - actualValue = (BigDecimal)v_ActualBalance.getValue(); - - difference = actualValue.subtract(previousValue); - - MCashBook cashBook = new MCashBook(p_ctx, p_pos.getC_CashBook_ID(), null); - Timestamp today = TimeUtil.getDay(System.currentTimeMillis()); - - MCash cash = MCash.get(p_ctx, /*cashBook.getAD_Org_ID(),*/ cashBook.getC_CashBook_ID(), today, null); - - if (cash != null && cash.get_ID() != 0 && difference.compareTo(cash.getStatementDifference()) != 0) - { - MCashLine cl = new MCashLine (cash); - cl.setCashType(MCashLine.CASHTYPE_Difference); - cl.setAmount(difference); - cl.setDescription(Msg.translate(p_pos.getCtx(), "Cash Scrutiny -> Before: ") + previousValue + " Now: " + actualValue); - cl.saveEx(); - } - cash = MCash.get(p_pos.getCtx(), /*p_pos.getAD_Org_ID(),*/ p_pos.getC_CashBook_ID(), today, null); - v_previousBalance.setValue(cash.getEndingBalance()); - v_ActualBalance.setValue(Env.ZERO); - v_difference.setValue(Env.ZERO); - } - - - /** - * calculate difference in cash scrutiny every time the cursor moves - */ - public void caretPositionChanged(InputMethodEvent event) - { - cmd_calculateDifference(); - } - - - /** - * calculate difference between cash scrutiniy each time the actual balance text changes - */ - public void inputMethodTextChanged(InputMethodEvent event) - { - cmd_calculateDifference(); - } - - - @Override - protected void close() { - } - - - @Override - protected void enableButtons() { - } - - - @Override - public void reset() { - } - -} // CashSubFunctions diff --git a/org.adempiere.ui.swing/src/org/compiere/pos/POSKeyboard.java b/org.adempiere.ui.swing/src/org/compiere/pos/POSKeyboard.java deleted file mode 100644 index 3843c700a5..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/pos/POSKeyboard.java +++ /dev/null @@ -1,261 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 Adempiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - *****************************************************************************/ - -package org.compiere.pos; - -import java.awt.Dimension; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.math.BigDecimal; -import java.text.ParseException; -import java.util.HashMap; -import java.util.logging.Level; - -import javax.swing.JFormattedTextField; -import javax.swing.JTextField; - -import net.miginfocom.swing.MigLayout; - -import org.compiere.apps.AEnv; -import org.compiere.apps.ConfirmPanel; -import org.compiere.model.MPOSKey; -import org.compiere.model.MPOSKeyLayout; -import org.compiere.swing.CDialog; -import org.compiere.swing.CPanel; -import org.compiere.util.CLogger; - - -/** - * On Screen Keyboard - * @author Paul Bowden - * Adaxa Pty Ltd - */ -public class POSKeyboard extends CDialog implements ActionListener, PosKeyListener -{ - /** - * - */ - private static final long serialVersionUID = 3296839634889851637L; - - private PosTextField field; - - private MPOSKeyLayout keylayout; - - - /** - * Constructor - * @param posPanel POS Panel - */ - public POSKeyboard (PosBasePanel posPanel, int C_POSKeyLayout_ID, PosTextField field, String title) - { - this(posPanel, C_POSKeyLayout_ID); - setTitle(title); - setPosTextField(field); - } - - public POSKeyboard(PosBasePanel posPanel, int keyLayoutId) { - super(AEnv.getFrame(posPanel), true); - keylayout = MPOSKeyLayout.get(posPanel.getCtx(), keyLayoutId); - init( keyLayoutId ); - } - - private JFormattedTextField text = new JFormattedTextField(); - - private HashMap keys; - - /** Logger */ - private static CLogger log = CLogger.getCLogger(POSKeyboard.class); - - - /** - * Initialize - * @param startText - * @param POSKeyLayout_ID - */ - public void init(int POSKeyLayout_ID ) - { - CPanel panel = new CPanel(); - getContentPane().add(panel); - - // Content - panel.setLayout(new MigLayout("fill")); - - if ( keylayout.getPOSKeyLayoutType().equals(MPOSKeyLayout.POSKEYLAYOUTTYPE_Numberpad)) - text.setHorizontalAlignment(JTextField.TRAILING); - panel.add(text, "north, growx, h 30!, wrap, gap 10 10 10 10"); - - PosKeyPanel keys = new PosKeyPanel(POSKeyLayout_ID, this); - panel.add(keys, "center, growx, growy"); - - ConfirmPanel confirm = new ConfirmPanel(true, false, true, false, false, false, false); - confirm.addActionListener(this); - Dimension buttonDim = new Dimension(50,50); - confirm.getResetButton().setPreferredSize(buttonDim); - confirm.getOKButton().setPreferredSize(buttonDim); - confirm.getCancelButton().setPreferredSize(buttonDim); - panel.add(confirm, "south"); - pack(); - setLocationByPlatform(true); - text.requestFocusInWindow(); - - } // init - - /** - * Dispose - Free Resources - */ - public void dispose() - { - if (keys != null) - { - keys.clear(); - keys = null; - } - super.dispose(); - } // dispose - - /** - * Action Listener - * @param e event - */ - public void actionPerformed (ActionEvent e) - { - String action = e.getActionCommand(); - if (action == null || action.length() == 0) - return; - else if ( action.equals(ConfirmPanel.A_RESET)) - { - if ( keylayout.getPOSKeyLayoutType().equals(MPOSKeyLayout.POSKEYLAYOUTTYPE_Numberpad)) - text.setText("0"); - else - text.setText(""); - try { - text.commitEdit(); - } catch (ParseException e1) { - if (log.isLoggable(Level.FINE))log.log(Level.FINE, "JFormattedTextField commit failed"); - } - } - else if ( action.equals(ConfirmPanel.A_CANCEL)) - { - dispose(); - } - else if (action.equals(ConfirmPanel.A_OK)) - { - field.setText(text.getText()); - try { - field.commitEdit(); - } catch (ParseException e1) { - if (log.isLoggable(Level.FINE))log.log(Level.FINE, "JFormattedTextField commit failed"); - } - dispose(); - } - if (log.isLoggable(Level.INFO)) log.info( "PosSubBasicKeys - actionPerformed: " + action); - - } // actionPerformed - - public void keyReturned(MPOSKey key) { - - String entry = key.getText(); - String old = text.getText(); - int caretPos = text.getCaretPosition(); - if ( text.getSelectedText() != null ) - caretPos = text.getSelectionStart(); - String head = old.substring(0, caretPos); - if ( text.getSelectedText() != null ) - caretPos = text.getSelectionEnd(); - String tail = old.substring(caretPos, old.length()); - - if ( entry != null && !entry.isEmpty() ) - { - if ( keylayout.getPOSKeyLayoutType().equals(MPOSKeyLayout.POSKEYLAYOUTTYPE_Keyboard)) - { - if ( key.getText() != null ) - text.setText( head + entry + tail); - } - else if ( keylayout.getPOSKeyLayoutType().equals(MPOSKeyLayout.POSKEYLAYOUTTYPE_Numberpad)) - { - if ( entry.equals(".") ) - { - text.setText(head + entry + tail); - } - if ( entry.equals(",") ) - { - text.setText(head + entry + tail); - } - else if ( entry.equals("C") ) - { - text.setText("0"); - } - else { - try - { - int number = Integer.parseInt(entry); // test if number - if ( number >= 0 && number <= 9 ) - { - text.setText(head + number + tail); - } - // greater than 9, add to existing - else - { - Object current = text.getValue(); - if ( current == null ) - { - text.setText(Integer.toString(number)); - } - else if ( current instanceof BigDecimal ) - { - text.setText(((BigDecimal) current).add( - new BigDecimal(Integer.toString(number))).toPlainString()); - } - else if ( current instanceof Integer ) - { - text.setText(Integer.toString(((Integer) current) + number)); - } - else if ( current instanceof Long ) - { - text.setText(Long.toString(((Long) current) + number)); - } - else if ( current instanceof Double ) - { - text.setText(Double.toString(((Double) current) + number)); - } - } - - - } - catch (NumberFormatException e) - { - // ignore non-numbers - } - } - - try { - text.commitEdit(); - } catch (ParseException e) { - if (log.isLoggable(Level.FINE))log.log(Level.FINE, "JFormattedTextField commit failed"); - } - } - } - } - - public void setPosTextField(PosTextField posTextField) { - - field = posTextField; - text.setFormatterFactory(field.getFormatterFactory()); - text.setText(field.getText()); - text.setValue(field.getValue()); - getContentPane().invalidate(); - - } - -} // PosSubBasicKeys diff --git a/org.adempiere.ui.swing/src/org/compiere/pos/PosApplication.java b/org.adempiere.ui.swing/src/org/compiere/pos/PosApplication.java deleted file mode 100644 index 8c97cb7a3f..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/pos/PosApplication.java +++ /dev/null @@ -1,94 +0,0 @@ -//red1 -- use for POS GUI Testing in Fitnesse with UISpec4J. -package org.compiere.pos; - -import java.awt.KeyboardFocusManager; -import java.awt.event.WindowEvent; -import java.awt.event.WindowListener; -import java.util.Properties; - -import javax.swing.JFrame; - -import org.compiere.Adempiere; -import org.compiere.apps.ADialog; -import org.compiere.apps.AEnv; -import org.compiere.apps.AKeyboardFocusManager; -import org.compiere.apps.ALogin; -import org.compiere.model.MSession; -import org.compiere.swing.CFrame; -import org.compiere.util.DB; -import org.compiere.util.Env; - -public class PosApplication { - private Properties m_ctx; - - PosApplication() { - Adempiere.startup(true); // needs to be here for UI -// Splash splash = Splash.getSplash(); -- red1 -- not mandatory, so its removed for faster GUI testing - final CFrame frame = new CFrame(); - // Focus Traversal - KeyboardFocusManager.setCurrentKeyboardFocusManager(AKeyboardFocusManager.get()); - - - ALogin login = new ALogin(frame); - if (!login.initLogin()) // no automatic login - { - // Center the window - try - { - AEnv.showCenterScreen(login); // HTML load errors - } - catch (Exception ex) - { - } - if (!login.isConnected()) // '|| !login.isOKpressed()' -- red1 -- can't work during UISpec4J testing - AEnv.exit(1); - } - - // Check Build - if (!DB.isBuildOK(m_ctx)) // red1 - m_ctx seems null - AEnv.exit(1); - Env.setContext( Env.getCtx(), "#M_Warehouse_ID", 104 ); //red1 - presetting to Store Central for GUI Testing - if (!Adempiere.startupEnvironment(true)) // Load Environment - System.exit(1); - MSession.get (Env.getCtx(), true); // Start Session - - @SuppressWarnings("unused") - int m_WindowNo = AEnv.createWindowNo(frame); - - // Default Image - frame.setIconImage(Adempiere.getImage16()); - - // Setting close operation/listener - teo_sarca [ 1684168 ] - frame.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE); - frame.addWindowListener(new WindowListener() { - public void windowClosing(WindowEvent e) { - if (!ADialog.ask(0, null, "ExitApplication?")) - return; - frame.dispose(); - } - public void windowActivated(WindowEvent e) {} - public void windowClosed(WindowEvent e) {} - public void windowDeactivated(WindowEvent e) {} - public void windowDeiconified(WindowEvent e) {} - public void windowIconified(WindowEvent e) {} - public void windowOpened(WindowEvent e) {} - }); - - PosBasePanel pos = new PosBasePanel(); - pos.init(0,frame); - frame.pack(); -// splash.dispose(); -// splash = null; - frame.setVisible(true); - } - - /** - * @param args - */ - public static void main(String[] args) { - - new PosApplication(); - - } - -} diff --git a/org.adempiere.ui.swing/src/org/compiere/pos/PosBasePanel.java b/org.adempiere.ui.swing/src/org/compiere/pos/PosBasePanel.java deleted file mode 100644 index 87e4dc7029..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/pos/PosBasePanel.java +++ /dev/null @@ -1,396 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 Adempiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - *****************************************************************************/ - -package org.compiere.pos; - -import java.awt.BorderLayout; -import java.awt.Dimension; -import java.awt.KeyboardFocusManager; -import java.awt.MouseInfo; -import java.awt.PointerInfo; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.sql.Timestamp; -import java.util.HashMap; -import java.util.Properties; -import java.util.logging.Level; - -import javax.swing.JFrame; -import javax.swing.JOptionPane; - -import net.miginfocom.swing.MigLayout; - -import org.compiere.apps.ADialog; -import org.compiere.model.MPOS; -import org.compiere.swing.CFrame; -import org.compiere.swing.CPanel; -import org.compiere.util.CLogger; -import org.compiere.util.Env; -import org.compiere.util.Msg; - -/** - * Point of Sales Main Window. - * - * @author Comunidad de Desarrollo OpenXpertya - * *Basado en Codigo Original Modificado, Revisado y Optimizado de: - * *Copyright (c) Jorg Janke - * @version $Id: PosPanel.java,v 1.10 2004/07/12 04:10:04 jjanke Exp $ - */ -public class PosBasePanel extends CPanel - //implements FormPanel -{ - /** - * - */ - private static final long serialVersionUID = 7477837683408198860L; - - public static String trxName = null; //Trx.createTrxName("GUIPOSTesting_"); --red1 won't persist trx for recall in display - //trxName for not committing test so tests does not impact DB.. temporary halt due to above issue. - /** - * Constructor - see init - */ - public PosBasePanel() - { - super (new MigLayout(" fill","[500!]10[300:350:, fill]","")); - originalKeyboardFocusManager = KeyboardFocusManager.getCurrentKeyboardFocusManager(); - m_focusMgr = new PosKeyboardFocusManager(); - KeyboardFocusManager.setCurrentKeyboardFocusManager(m_focusMgr); - } // PosPanel - - /** Window No */ - private int m_WindowNo = 0; - /** FormFrame */ - private CFrame m_frame; - /** Logger */ - private CLogger log = CLogger.getCLogger(getClass()); - /** Context */ - private Properties m_ctx = Env.getCtx(); - /** Sales Rep */ - private int m_SalesRep_ID = 0; - /** POS Model */ - protected MPOS p_pos = null; - /** Keyoard Focus Manager */ - private PosKeyboardFocusManager m_focusMgr = null; - - /** Order Panel */ - protected SubOrder f_order; - /** Current Line */ - protected SubCurrentLine f_curLine; - /** Function Keys */ - protected SubFunctionKeys f_functionKeys; - - protected CashSubFunctions f_cashfunctions; - - private javax.swing.Timer logoutTimer; - - - PosOrderModel m_order = null; - - // Today's (login) date */ - private Timestamp m_today = Env.getContextAsDate(m_ctx, "#Date"); - - private KeyboardFocusManager originalKeyboardFocusManager; - private boolean debug = true; - private CFrame frame; - private HashMap keyboards = new HashMap(); - - - public String getTrxName(){ - return trxName; - } - /** - * Initialize Panel - * @param WindowNo window - * @param frame parent frame - */ - public void init (int WindowNo, CFrame frame) - { - this.frame = frame; - if ( debug ) - frame.setPreferredSize(new Dimension(1024,768)); - else - { - frame.setExtendedState(JFrame.MAXIMIZED_BOTH); - frame.setResizable(false); - } - - m_SalesRep_ID = Env.getAD_User_ID(m_ctx); - if (log.isLoggable(Level.INFO)) log.info("init - SalesRep_ID=" + m_SalesRep_ID); - m_WindowNo = WindowNo; - m_frame = frame; - frame.setJMenuBar(null); - // - try - { - if (!dynInit()) - { - dispose(); - frame.dispose(); - return; - } - frame.getContentPane().add(this, BorderLayout.CENTER); - } - catch(Exception e) - { - log.log(Level.SEVERE, "init", e); - } - if (log.isLoggable(Level.CONFIG)) log.config( "PosPanel.init - " + getPreferredSize()); - - if ( p_pos.getAutoLogoutDelay() > 0 && logoutTimer == null ) - { - logoutTimer = new javax.swing.Timer(1000, - new ActionListener() { - - PointerInfo pi = null; - long lastMouseMove = System.currentTimeMillis(); - long lastKeyboardEvent = System.currentTimeMillis(); - public void actionPerformed(ActionEvent e) { - long now = e.getWhen(); - PointerInfo newPi = MouseInfo.getPointerInfo(); - // mouse moved - if ( newPi != null && pi != null - && !pi.getLocation().equals(newPi.getLocation()) ) - { - lastMouseMove = now; - } - pi = newPi; - - lastKeyboardEvent = m_focusMgr.getLastWhen(); - - if ( p_pos.getAutoLogoutDelay()*1000 < now - Math.max(lastKeyboardEvent, lastMouseMove) ) - { - // new PosLogin(this); - } - } - }); - logoutTimer.start(); - } - m_focusMgr.start(); - - } // init - - /** - * Dispose - Free Resources - */ - public void dispose() - { - keyboards.clear(); - keyboards = null; - if ( logoutTimer != null ) - logoutTimer.stop(); - logoutTimer = null; - - if (m_focusMgr != null) - m_focusMgr.stop(); - m_focusMgr = null; - KeyboardFocusManager.setCurrentKeyboardFocusManager(originalKeyboardFocusManager); - // - if (f_order != null) - f_order.dispose(); - f_order = null; - if (f_curLine != null) - { - // if ( m_order != null ) - // m_order.deleteOrder(); - f_curLine.dispose(); - } - f_curLine = null; - if (f_functionKeys != null) - f_functionKeys.dispose(); - f_functionKeys = null; - - if (f_cashfunctions != null) - f_cashfunctions.dispose(); - f_cashfunctions = null; - if (m_frame != null) - m_frame.dispose(); - m_frame = null; - m_ctx = null; - } // dispose - - - /************************************************************************** - * Dynamic Init. - * PosPanel has a GridBagLayout. - * The Sub Panels return their position - */ - private boolean dynInit() - { - if (!setMPOS()) - return false; - frame.setTitle("Adempiere POS: " + p_pos.getName()); - // Create Sub Panels - f_order = new SubOrder (this); - add (f_order, "split 2, flowy, growx, spany"); - // - f_curLine = new SubCurrentLine (this); - add (f_curLine, "h 300, growx, growy, gaptop 10"); - - f_functionKeys = new SubFunctionKeys (this); - add (f_functionKeys, "aligny top, h 500, growx, growy, flowy, split 2"); - - return true; - } // dynInit - - /** - * Set MPOS - * @return true if found/set - */ - private boolean setMPOS() - { - MPOS[] poss = null; - if (m_SalesRep_ID == 100) // superUser - poss = getPOSs (0); - else - poss = getPOSs (m_SalesRep_ID); - // - if (poss.length == 0) - { - ADialog.error(m_WindowNo, m_frame, "NoPOSForUser"); - return false; - } - else if (poss.length == 1) - { - p_pos = poss[0]; - return true; - } - - // Select POS - String msg = Msg.getMsg(m_ctx, "SelectPOS"); - String title = Env.getHeader(m_ctx, m_WindowNo); - Object selection = JOptionPane.showInputDialog(m_frame, msg, title, - JOptionPane.QUESTION_MESSAGE, null, poss, poss[0]); - if (selection != null) - { - p_pos = (MPOS)selection; - return true; - } - return false; - } // setMPOS - - /** - * Get POSs for specific Sales Rep or all - * @param SalesRep_ID - * @return array of POS - */ - private MPOS[] getPOSs (int SalesRep_ID) - { - String pass_field = "SalesRep_ID"; - int pass_ID = SalesRep_ID; - if (SalesRep_ID==0) - { - pass_field = "AD_Client_ID"; - pass_ID = Env.getAD_Client_ID(m_ctx); - } - return MPOS.getAll(m_ctx, pass_field, pass_ID); - } // getPOSs - - /************************************************************************** - * Get Today's date - * @return date - */ - public Timestamp getToday() - { - return m_today; - } // getToday - - /** - * New Order - * - */ - public void newOrder() - { - log.info( "PosPanel.newOrder"); - f_order.setC_BPartner_ID(0); - m_order = null; - m_order = PosOrderModel.createOrder(p_pos, f_order.getBPartner(), trxName); - f_curLine.newLine(); - f_curLine.f_name.requestFocusInWindow(); - updateInfo(); - } // newOrder - - /** - * Get the number of the window for the function calls that it needs - * - * @return the window number - */ - public int getWindowNo() - { - return m_WindowNo; - } - - /** - * Get the properties for the process calls that it needs - * - * @return getProperties m_ctx - */ - public Properties getCtx() - { - return m_ctx; - } - - public void updateInfo() - { - // reload order - if ( m_order != null ) - { - m_order.reload(); - } - if ( f_curLine != null ) - f_curLine.updateTable(m_order); - if (f_order != null) - { - f_order.updateOrder(); - } - } - - /** - * @param m_c_order_id - */ - public void setOldOrder(int m_c_order_id) - { - if ( m_order != null ) - m_order.deleteOrder(); - - if ( m_c_order_id == 0 ) - m_order = null; - else - m_order = new PosOrderModel(m_ctx , m_c_order_id, trxName, p_pos); - updateInfo(); - } - - /** - * @param m_c_order_id - */ - public void setOrder(int m_c_order_id) - { - if ( m_c_order_id == 0 ) - m_order = null; - else - m_order = new PosOrderModel(m_ctx , m_c_order_id, trxName, p_pos); - } - - public POSKeyboard getKeyboard(int keyLayoutId) { - if ( keyboards.containsKey(keyLayoutId) ) - return keyboards.get(keyLayoutId); - else - { - POSKeyboard keyboard = new POSKeyboard(this, keyLayoutId); - keyboards.put(keyLayoutId, keyboard); - return keyboard; - } - } - -} // PosPanel - diff --git a/org.adempiere.ui.swing/src/org/compiere/pos/PosKeyListener.java b/org.adempiere.ui.swing/src/org/compiere/pos/PosKeyListener.java deleted file mode 100644 index db8fd64b38..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/pos/PosKeyListener.java +++ /dev/null @@ -1,30 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 Adempiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - *****************************************************************************/ - - -package org.compiere.pos; - -import org.compiere.model.MPOSKey; - -/** - * Interface for listening to on screen key events - * @author Paul Bowden - * Adaxa Pty Ltd - * - */ -public interface PosKeyListener { - - void keyReturned( MPOSKey key ); - -} diff --git a/org.adempiere.ui.swing/src/org/compiere/pos/PosKeyPanel.java b/org.adempiere.ui.swing/src/org/compiere/pos/PosKeyPanel.java deleted file mode 100644 index 941ee286bd..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/pos/PosKeyPanel.java +++ /dev/null @@ -1,249 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 Adempiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - *****************************************************************************/ - -package org.compiere.pos; - -import java.awt.CardLayout; -import java.awt.Color; -import java.awt.Dimension; -import java.awt.Font; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.util.HashMap; -import java.util.logging.Level; - -import javax.swing.Icon; -import javax.swing.SwingConstants; - -import net.miginfocom.swing.MigLayout; - -import org.adempiere.plaf.AdempierePLAF; -import org.compiere.model.MImage; -import org.compiere.model.MPOSKey; -import org.compiere.model.MPOSKeyLayout; -import org.compiere.print.MPrintColor; -import org.compiere.print.MPrintFont; -import org.compiere.swing.CButton; -import org.compiere.swing.CPanel; -import org.compiere.swing.CScrollPane; -import org.compiere.util.CLogger; -import org.compiere.util.Env; - -/** - * Button panel supporting multiple linked layouts - * @author Paul Bowden - * Adaxa Pty Ltd - * - */ -public class PosKeyPanel extends CPanel implements ActionListener { - /** - * - */ - private static final long serialVersionUID = -1773720355288801510L; - - - /** - * Constructor - */ - public PosKeyPanel (int C_POSKeyLayout_ID, PosKeyListener caller) - { - if (C_POSKeyLayout_ID == 0) - return; - - setLayout(cardLayout); - add(createCard(C_POSKeyLayout_ID), Integer.toString(C_POSKeyLayout_ID)); - currentLayout = C_POSKeyLayout_ID; - cardLayout.show(this, Integer.toString(C_POSKeyLayout_ID)); - this.caller = caller; - } // PosSubFunctionKeys - - /** layout */ - private CardLayout cardLayout = new CardLayout(); - /** Map of map of keys */ - private HashMap> keymap = new HashMap>(); - /** Currently displayed layout */ - int currentLayout; - /** Logger */ - private static CLogger log = CLogger.getCLogger(PosKeyPanel.class); - /** Caller */ - private PosKeyListener caller; - - - /** - * @return - */ - private CPanel createCard(int C_POSKeyLayout_ID) { - - // already added - if ( keymap.containsKey(C_POSKeyLayout_ID) ) - { - return null; - } - - CPanel card = new CPanel(); - card.setLayout(new MigLayout("fill, ins 0")); - MPOSKeyLayout keyLayout = MPOSKeyLayout.get(Env.getCtx(), C_POSKeyLayout_ID); - - Color stdColor = Color.lightGray; - if (keyLayout.getAD_PrintColor_ID() != 0) - { - MPrintColor color = MPrintColor.get(Env.getCtx(), keyLayout.getAD_PrintColor_ID()); - stdColor = color.getColor(); - } - Font stdFont = AdempierePLAF.getFont_Field(); - if (keyLayout.getAD_PrintFont_ID() != 0) - { - MPrintFont font = MPrintFont.get(keyLayout.getAD_PrintFont_ID()); - stdFont = font.getFont(); - } - - if (keyLayout.get_ID() == 0) - return null; - MPOSKey[] keys = keyLayout.getKeys(false); - - HashMap map = new HashMap(keys.length); - - keymap.put(C_POSKeyLayout_ID, map); - - int COLUMNS = 3; // Min Columns - int ROWS = 3; // Min Rows - int noKeys = keys.length; - int cols = keyLayout.getColumns(); - if ( cols == 0 ) - cols = COLUMNS; - - int buttons = 0; - - if (log.isLoggable(Level.FINE)) log.fine( "PosSubFunctionKeys.init - NoKeys=" + noKeys - + ", Cols=" + cols); - // Content - CPanel content = new CPanel (new MigLayout("fill, wrap " + Math.max(cols, 3))); - String buttonSize = "h 50, w 50, growx, growy, sg button,"; - for (MPOSKey key : keys) - { - - if ( key.getSubKeyLayout_ID() > 0 ) - { - CPanel subCard = createCard(key.getSubKeyLayout_ID()); - if ( subCard != null ) - add(subCard, Integer.toString(key.getSubKeyLayout_ID())); - } - - map.put(key.getC_POSKey_ID(), key); - Color keyColor = stdColor; - Font keyFont = stdFont; - StringBuilder buttonHTML = new StringBuilder("

    "); - if (key.getAD_PrintColor_ID() != 0) - { - MPrintColor color = MPrintColor.get(Env.getCtx(), key.getAD_PrintColor_ID()); - keyColor = color.getColor(); - } - - if ( key.getAD_PrintFont_ID() != 0) - { - MPrintFont font = MPrintFont.get(key.getAD_PrintFont_ID()); - keyFont = font.getFont(); - } - - buttonHTML.append(key.getName()); - buttonHTML.append("

    "); - if (log.isLoggable(Level.FINE)) log.fine( "#" + map.size() + " - " + keyColor); - CButton button = new CButton(buttonHTML.toString()); - button.setBackground(keyColor); - button.setFont(keyFont); - - if ( key.getAD_Image_ID() != 0 ) - { - MImage image = MImage.get(Env.getCtx(), key.getAD_Image_ID()); - Icon icon = image.getIcon(); - button.setIcon(icon); - button.setVerticalTextPosition(SwingConstants.BOTTOM); - button.setHorizontalTextPosition(SwingConstants.CENTER); - } - button.setFocusable(false); - if ( !key.isActive() ) - button.setEnabled(false); - button.setActionCommand(String.valueOf(key.getC_POSKey_ID())); - button.addActionListener(this); - String constraints = buttonSize; - int size = 1; - if ( key.getSpanX() > 1 ) - { - constraints += "spanx " + key.getSpanX() + ","; - size = key.getSpanX(); - } - if ( key.getSpanY() > 1 ) - { - constraints += "spany " + key.getSpanY() + ","; - size = size*key.getSpanY(); - } - buttons = buttons + size; - content.add (button, constraints); - } - - int rows = Math.max ((buttons / cols), ROWS); - if ( buttons % cols > 0 ) - rows = rows + 1; - - for (int i = buttons; i < rows*cols; i++) - { - CButton button = new CButton(""); - button.setFocusable(false); - button.setReadWrite(false); - content.add (button, buttonSize); - } - - CScrollPane scroll = new CScrollPane(content); - // scroll.setPreferredSize(new Dimension( 600 - 20, 400-20)); - card.add (scroll, "growx, growy"); - // increase scrollbar width for touchscreen - scroll.getVerticalScrollBar().setPreferredSize(new Dimension(30, 0)); - scroll.getHorizontalScrollBar().setPreferredSize(new Dimension(0,30)); - return card; - } - - /** - * Action Listener - * @param e event - */ - public void actionPerformed (ActionEvent e) - { - String action = e.getActionCommand(); - if (action == null || action.length() == 0 || keymap == null) - return; - if (log.isLoggable(Level.INFO)) log.info( "PosSubFunctionKeys - actionPerformed: " + action); - HashMap currentKeymap = keymap.get(currentLayout); - - try - { - int C_POSKey_ID = Integer.parseInt(action); - MPOSKey key = currentKeymap.get(C_POSKey_ID); - // switch layout - if ( key.getSubKeyLayout_ID() > 0 ) - { - currentLayout = key.getSubKeyLayout_ID(); - cardLayout.show(this, Integer.toString(key.getSubKeyLayout_ID())); - } - else - { - caller.keyReturned(key); - } - } - catch (Exception ex) - { - } - - } // actionPerformed - -} diff --git a/org.adempiere.ui.swing/src/org/compiere/pos/PosKeyboardFocusManager.java b/org.adempiere.ui.swing/src/org/compiere/pos/PosKeyboardFocusManager.java deleted file mode 100644 index 4b47a65d5c..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/pos/PosKeyboardFocusManager.java +++ /dev/null @@ -1,133 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 Adempiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - *****************************************************************************/ - -package org.compiere.pos; - -import java.awt.DefaultKeyboardFocusManager; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.awt.event.KeyEvent; -import java.util.LinkedList; -import java.util.logging.Level; - -import org.compiere.util.CLogger; - -/** - * POS Keyboard Focus Manager - * - * @author Comunidad de Desarrollo OpenXpertya - * *Basado en Codigo Original Modificado, Revisado y Optimizado de: - * *Copyright (c) Jorg Janke - * @version $Id: PosKeyboardFocusManager.java,v 1.2 2004/07/11 19:50:12 jjanke - * Exp $ - */ -public class PosKeyboardFocusManager extends DefaultKeyboardFocusManager - implements ActionListener { - - /** - * PosKeyboardFocusManager - */ - public PosKeyboardFocusManager() { - super(); - } // PosKeyboardFocusManager - - /** FirstIn First Out List */ - private LinkedList m_fifo = new LinkedList(); - - /** Last Key Type */ - private long m_lastWhen = 0; - - public long getLastWhen() { - return m_lastWhen; - } - - /** Timer */ - private javax.swing.Timer m_timer = null; - /** Logger */ - private static CLogger log = CLogger.getCLogger(PosKeyboardFocusManager.class); - - /** - * Dispose - */ - public void dispose() { - if (m_timer != null) - m_timer.stop(); - m_timer = null; - if (m_fifo != null) - m_fifo.clear(); - m_fifo = null; - } // dispose - - /** - * Start Timer - */ - public void start() { - // Unqueue time - 200 ms - int delay = 200; - if (log.isLoggable(Level.FINE)) log.fine("PosKeyboardFocusManager.start - " + delay); - if (m_timer == null) - m_timer = new javax.swing.Timer(delay, this); - if (!m_timer.isRunning()) - m_timer.start(); - } // start - - /** - * Stop Timer - */ - public void stop() { - if (log.isLoggable(Level.FINE)) log.fine("PosKeyboardFocusManager.stop - " + m_timer); - - if (m_timer != null) - m_timer.stop(); - } // stop - - /*************************************************************************** - * Dispatch Key Event - queue - * - * @param eevent - * event - * @return true - */ - public boolean dispatchKeyEvent(KeyEvent event) { - if (event.getID() == KeyEvent.KEY_PRESSED) { - // Keyboard Repeat: 485 - then 31 - // log.fine( "PosKeyboardFocusManager.dispatchKeyEvent - " - // - " - // + event.getWhen() + " - " + (event.getWhen() - m_lastWhen)); - m_lastWhen = event.getWhen(); - } - if (m_timer == null) - super.dispatchKeyEvent(event); - else - m_fifo.add(event); - return true; - } // displatchEvent - - /** - * Action Performed - unqueue - * - * @param e - * event - */ - public void actionPerformed(ActionEvent e) { - if (m_timer == null) - return; - // log.fine( "actionPerformed - " + m_fifo.size()); - while (m_fifo.size() > 0) { - KeyEvent event = (KeyEvent) m_fifo.removeFirst(); - super.dispatchKeyEvent(event); - } - } // actionPerformed - -} // PosKeyboardFocusManager diff --git a/org.adempiere.ui.swing/src/org/compiere/pos/PosLogin.java b/org.adempiere.ui.swing/src/org/compiere/pos/PosLogin.java deleted file mode 100644 index 2d2b980153..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/pos/PosLogin.java +++ /dev/null @@ -1,80 +0,0 @@ -package org.compiere.pos; - -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.awt.event.KeyEvent; - -import javax.swing.KeyStroke; - -import net.miginfocom.swing.MigLayout; - -import org.compiere.apps.AEnv; -import org.compiere.apps.AppsAction; -import org.compiere.model.MUser; -import org.compiere.swing.CButton; -import org.compiere.swing.CDialog; -import org.compiere.swing.CLabel; -import org.compiere.swing.CPanel; -import org.compiere.util.Msg; - -public class PosLogin extends CDialog implements ActionListener { - - /** - * - */ - private static final long serialVersionUID = 8490567722808711399L; - private PosBasePanel posPanel; - private PosTextField username; - private PosTextField pin; - private CButton bProcess; - - /** - * Constructor - * @param posPanel POS Panel - */ - public PosLogin (PosBasePanel posPanel) - { - super (AEnv.getFrame(posPanel),Msg.translate(posPanel.getCtx(), "Login"), true); - init(); - this.posPanel = posPanel; - } - - private void init() { - CPanel panel = new CPanel(); - panel.setLayout(new MigLayout()); - getContentPane().add(panel); - - panel.add(new CLabel(Msg.translate(posPanel.getCtx(),"SalesRep_ID"))); - - username = new PosTextField(Msg.translate(posPanel.getCtx(),"SalesRep_ID"), - posPanel, posPanel.p_pos.getOSK_KeyLayout_ID()); - - panel.add( username, "wrap"); - - panel.add(new CLabel(Msg.translate(posPanel.getCtx(), "UserPIN"))); - - pin = new PosTextField(Msg.translate(posPanel.getCtx(), "UserPIN"), posPanel, posPanel.p_pos.getOSNP_KeyLayout_ID()); - - panel.add(pin, ""); - - AppsAction act = new AppsAction("Ok", KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), false); - act.setDelegate(this); - bProcess = (CButton)act.getButton(); - bProcess.setFocusable(false); - panel.add (bProcess, "h 50!, w 50!"); - - pack(); - - } - - @Override - public void actionPerformed(ActionEvent e) { - if ( e.getSource().equals(bProcess) ) - { - MUser.get(posPanel.getCtx(), username.getText(), pin.getText()); - } - - dispose(); - } - -} diff --git a/org.adempiere.ui.swing/src/org/compiere/pos/PosOrderModel.java b/org.adempiere.ui.swing/src/org/compiere/pos/PosOrderModel.java deleted file mode 100644 index 4c601281da..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/pos/PosOrderModel.java +++ /dev/null @@ -1,473 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 Adempiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - *****************************************************************************/ -package org.compiere.pos; - -import java.math.BigDecimal; -import java.util.HashMap; -import java.util.Properties; -import java.util.logging.Level; - -import org.compiere.model.MBPartner; -import org.compiere.model.MBankAccountProcessor; -import org.compiere.model.MOrder; -import org.compiere.model.MOrderLine; -import org.compiere.model.MOrderTax; -import org.compiere.model.MPOS; -import org.compiere.model.MPayment; -import org.compiere.model.MProduct; -import org.compiere.process.DocAction; -import org.compiere.util.DB; -import org.compiere.util.Env; -import org.compiere.util.ValueNamePair; - -/** - * Wrapper for standard order - * @author Paul Bowden - * Adaxa Pty Ltd - * - */ -public class PosOrderModel extends MOrder { - /** - * - */ - private static final long serialVersionUID = 5253837037827124425L; - - private MPOS m_pos; - - private String trxName; - - public PosOrderModel(Properties ctx, int C_Order_ID, String trxName, MPOS pos) { - super(ctx, C_Order_ID, trxName); - this.trxName = trxName; - m_pos = pos; - } - - /** - * Get/create Order - * - * @return order or null - */ - public static PosOrderModel createOrder(MPOS pos, MBPartner partner, String trxName) { - - PosOrderModel order = new PosOrderModel(Env.getCtx(), 0, trxName, pos); - order.setAD_Org_ID(pos.getAD_Org_ID()); - order.setIsSOTrx(true); - order.setC_POS_ID(pos.getC_POS_ID()); - if (pos.getC_DocType_ID() != 0) - order.setC_DocTypeTarget_ID(pos.getC_DocType_ID()); - else - order.setC_DocTypeTarget_ID(MOrder.DocSubTypeSO_POS); - if (partner == null || partner.get_ID() == 0) - partner = pos.getBPartner(); - if (partner == null || partner.get_ID() == 0) { - throw new AdempierePOSException("No BPartner for order"); - } - order.setBPartner(partner); - // - order.setM_PriceList_ID(pos.getM_PriceList_ID()); - order.setM_Warehouse_ID(pos.getM_Warehouse_ID()); - order.setSalesRep_ID(pos.getSalesRep_ID()); - order.setPaymentRule(MOrder.PAYMENTRULE_Cash); - if (!order.save()) - { - order = null; - throw new AdempierePOSException("Save order failed"); - } - - return order; - } // createOrder - - - /** - * @author Community Development OpenXpertya - * *Based on Modified Original Code, Revised and Optimized: - * *Copyright ConSerTi - */ - public void setBPartner(MBPartner partner) - { - if (getDocStatus().equals("DR")) - { - if (partner == null || partner.get_ID() == 0) { - throw new AdempierePOSException("no BPartner"); - } - else - { - if (log.isLoggable(Level.INFO)) log.info("SubCurrentLine.getOrder -" + partner); - super.setBPartner(partner); - MOrderLine[] lineas = getLines(); - for (int i = 0; i < lineas.length; i++) - { - lineas[i].setC_BPartner_ID(partner.getC_BPartner_ID()); - lineas[i].setTax(); - lineas[i].saveEx(); - } - saveEx(); - } - } - - } - - /** - * Create new Line - * - * @return line or null - */ - public MOrderLine createLine(MProduct product, BigDecimal QtyOrdered, - BigDecimal PriceActual) { - - if (!getDocStatus().equals("DR") ) - return null; - //add new line or increase qty - - // catch Exceptions at order.getLines() - int numLines = 0; - MOrderLine[] lines = null; - try - { - lines = getLines(null,"Line"); - numLines = lines.length; - for (int i = 0; i < numLines; i++) - { - if (lines[i].getM_Product_ID() == product.getM_Product_ID()) - { - //increase qty - BigDecimal current = lines[i].getQtyEntered(); - BigDecimal toadd = QtyOrdered; - BigDecimal total = current.add(toadd); - lines[i].setQty(total); - lines[i].setPrice(); // sets List/limit - if ( PriceActual.compareTo(Env.ZERO) > 0 ) - lines[i].setPrice(PriceActual); - lines[i].saveEx(); - return lines[i]; - } - } - } - catch (Exception e) - { - log.severe("Order lines cannot be created - " + e.getMessage()); - } - - //create new line - MOrderLine line = new MOrderLine(this); - line.setProduct(product); - line.setQty(QtyOrdered); - - line.setPrice(); // sets List/limit - if ( PriceActual.compareTo(Env.ZERO) > 0 ) - line.setPrice(PriceActual); - line.saveEx(); - return line; - - } // createLine - - - /** - * Delete order from database - * - * @author Comunidad de Desarrollo OpenXpertya - * *Basado en Codigo Original Modificado, Revisado y Optimizado de: - * *Copyright ConSerTi - */ - public boolean deleteOrder () { - if (getDocStatus().equals("DR")) - { - MOrderLine[] lines = getLines(); - if (lines != null) - { - int numLines = lines.length; - if (numLines > 0) - for (int i = numLines - 1; i >= 0; i--) - { - if (lines[i] != null) - deleteLine(lines[i].getC_OrderLine_ID()); - } - } - - MOrderTax[] taxs = getTaxes(true); - if (taxs != null) - { - int numTax = taxs.length; - if (numTax > 0) - for (int i = taxs.length - 1; i >= 0; i--) - { - if (taxs[i] != null) - taxs[i].delete(true); - taxs[i].saveEx(); - taxs[i] = null; - } - } - - getLines(true, null); // requery order - setDocStatus("VO");//delete(true); red1 -- should not delete but void the order - setProcessed(true); //red1 -- to avoid been in history during query - saveEx(); - return true; - } - return false; - } // deleteOrder - - /** - * to erase the lines from order - * @return true if deleted - */ - public void deleteLine (int C_OrderLine_ID) { - if ( C_OrderLine_ID != -1 ) - { - for ( MOrderLine line : getLines(true, "M_Product_ID") ) - { - if ( line.getC_OrderLine_ID() == C_OrderLine_ID ) - { - line.delete(true); - line.saveEx(); - } - } - } - } // deleteLine - - /** - * Process Order - * @author Comunidad de Desarrollo OpenXpertya - * *Basado en Codigo Original Modificado, Revisado y Optimizado de: - * *Copyright ïżœ ConSerTi - */ - public boolean processOrder() - { - //Returning orderCompleted to check for order completeness - boolean orderCompleted = false; - // check if order completed OK - if (getDocStatus().equals("DR") || getDocStatus().equals("IP") ) - { - setDocAction(DocAction.ACTION_Complete); - try - { - if (processIt(DocAction.ACTION_Complete) ) - { - saveEx(); - } - else - { - log.info( "Process Order FAILED"); - } - } - catch (Exception e) - { - log.severe("Order can not be completed - " + e.getMessage()); - } - finally - { // When order failed convert it back to draft so it can be processed - if( getDocStatus().equals("IN") ) - { - setDocStatus("DR"); - } - else if( getDocStatus().equals("CO") ) - { - orderCompleted = true; - log.info( "SubCheckout - processOrder OK"); - } - else - { - log.info( "SubCheckout - processOrder - unrecognized DocStatus"); - } - } // try-finally - - } - - return orderCompleted; - } // processOrder - - public BigDecimal getTaxAmt() { - BigDecimal taxAmt = Env.ZERO; - for (MOrderTax tax : getTaxes(true)) - { - taxAmt = taxAmt.add(tax.getTaxAmt()); - } - return taxAmt; - } - - public BigDecimal getSubtotal() { - return getGrandTotal().subtract(getTaxAmt()); - } - - public BigDecimal getPaidAmt() - { - String sql = "SELECT sum(PayAmt) FROM C_Payment WHERE C_Order_ID = ? AND DocStatus IN ('CO','CL')"; - BigDecimal received = DB.getSQLValueBD(null, sql, getC_Order_ID()); - if ( received == null ) - received = Env.ZERO; - - sql = "SELECT sum(Amount) FROM C_CashLine WHERE C_Invoice_ID = ? "; - BigDecimal cashline = DB.getSQLValueBD(null, sql, getC_Invoice_ID()); - if ( cashline != null ) - received = received.add(cashline); - - return received; - } - - public boolean payCash(BigDecimal amt) { - - MPayment payment = createPayment(MPayment.TENDERTYPE_Cash); - payment.setC_CashBook_ID(m_pos.getC_CashBook_ID()); - payment.setAmount(getC_Currency_ID(), amt); - payment.setC_BankAccount_ID(m_pos.getC_BankAccount_ID()); - payment.saveEx(); - payment.setDocAction(MPayment.DOCACTION_Complete); - payment.setDocStatus(MPayment.DOCSTATUS_Drafted); - if ( payment.processIt(MPayment.DOCACTION_Complete) ) - { - payment.saveEx(); - return true; - } - else return false; - } // payCash - - public boolean payCheck(BigDecimal amt, String accountNo, String routingNo, String checkNo) - { - MPayment payment = createPayment(MPayment.TENDERTYPE_Check); - payment.setAmount(getC_Currency_ID(), amt); - payment.setC_BankAccount_ID(m_pos.getC_BankAccount_ID()); - payment.setAccountNo(accountNo); - payment.setRoutingNo(routingNo); - payment.setCheckNo(checkNo); - payment.saveEx(); - payment.setDocAction(MPayment.DOCACTION_Complete); - payment.setDocStatus(MPayment.DOCSTATUS_Drafted); - if ( payment.processIt(MPayment.DOCACTION_Complete) ) - { - payment.saveEx(); - return true; - } - else return false; - } // payCheck - - public boolean payCreditCard(BigDecimal amt, String accountName, int month, int year, - String cardNo, String cvc, String cardtype) - { - - MPayment payment = createPayment(MPayment.TENDERTYPE_CreditCard); - payment.setAmount(getC_Currency_ID(), amt); - payment.setC_BankAccount_ID(m_pos.getC_BankAccount_ID()); - payment.setCreditCard(MPayment.TRXTYPE_Sales, cardtype, - cardNo, cvc, month, year); - payment.saveEx(); - payment.setDocAction(MPayment.DOCACTION_Complete); - payment.setDocStatus(MPayment.DOCSTATUS_Drafted); - if ( payment.processIt(MPayment.DOCACTION_Complete) ) - { - payment.saveEx(); - return true; - } - else return false; - } // payCheck - - private MPayment createPayment(String tenderType) - { - MPayment payment = new MPayment(getCtx(), 0, trxName); - payment.setAD_Org_ID(m_pos.getAD_Org_ID()); - payment.setTenderType(tenderType); - payment.setC_Order_ID(getC_Order_ID()); - payment.setIsReceipt(true); - payment.setC_BPartner_ID(getC_BPartner_ID()); - return payment; - } - - public void reload() { - load( get_TrxName()); - getLines(true, ""); - } - - /** - * Duplicated from MPayment - * Get Accepted Credit Cards for amount - * @param amt trx amount - * @return credit cards - */ - public ValueNamePair[] getCreditCards (BigDecimal amt) - { - try - { - MBankAccountProcessor[] m_mBankAccountProcessors = MBankAccountProcessor.find(getCtx (), null, null, - getAD_Client_ID (), getAD_Org_ID(), getC_Currency_ID (), amt, get_TrxName()); - // - HashMap map = new HashMap(); // to eliminate duplicates - for (int i = 0; i < m_mBankAccountProcessors.length; i++) - { - MBankAccountProcessor bankAccountProcessor = m_mBankAccountProcessors[i]; - if (bankAccountProcessor.isAcceptAMEX()) - map.put (MPayment.CREDITCARDTYPE_Amex, getCreditCardPair (MPayment.CREDITCARDTYPE_Amex)); - if (bankAccountProcessor.isAcceptDiners()) - map.put (MPayment.CREDITCARDTYPE_Diners, getCreditCardPair (MPayment.CREDITCARDTYPE_Diners)); - if (bankAccountProcessor.isAcceptDiscover()) - map.put (MPayment.CREDITCARDTYPE_Discover, getCreditCardPair (MPayment.CREDITCARDTYPE_Discover)); - if (bankAccountProcessor.isAcceptMC()) - map.put (MPayment.CREDITCARDTYPE_MasterCard, getCreditCardPair (MPayment.CREDITCARDTYPE_MasterCard)); - if (bankAccountProcessor.isAcceptCorporate()) - map.put (MPayment.CREDITCARDTYPE_PurchaseCard, getCreditCardPair (MPayment.CREDITCARDTYPE_PurchaseCard)); - if (bankAccountProcessor.isAcceptVisa()) - map.put (MPayment.CREDITCARDTYPE_Visa, getCreditCardPair (MPayment.CREDITCARDTYPE_Visa)); - } // for all payment processors - // - ValueNamePair[] retValue = new ValueNamePair[map.size ()]; - map.values ().toArray (retValue); - if (log.isLoggable(Level.FINE)) log.fine("getCreditCards - #" + retValue.length + " - Processors=" + m_mBankAccountProcessors.length); - return retValue; - } - catch (Exception ex) - { - ex.printStackTrace(); - return null; - } - } // getCreditCards - - /** - * - * Duplicated from MPayment - * Get Type and name pair - * @param CreditCardType credit card Type - * @return pair - */ - private ValueNamePair getCreditCardPair (String CreditCardType) - { - return new ValueNamePair (CreditCardType, getCreditCardName(CreditCardType)); - } // getCreditCardPair - - /** - * - * Duplicated from MPayment - * Get Name of Credit Card - * @param CreditCardType credit card type - * @return Name - */ - public String getCreditCardName(String CreditCardType) - { - if (CreditCardType == null) - return "--"; - else if (MPayment.CREDITCARDTYPE_MasterCard.equals(CreditCardType)) - return "MasterCard"; - else if (MPayment.CREDITCARDTYPE_Visa.equals(CreditCardType)) - return "Visa"; - else if (MPayment.CREDITCARDTYPE_Amex.equals(CreditCardType)) - return "Amex"; - else if (MPayment.CREDITCARDTYPE_ATM.equals(CreditCardType)) - return "ATM"; - else if (MPayment.CREDITCARDTYPE_Diners.equals(CreditCardType)) - return "Diners"; - else if (MPayment.CREDITCARDTYPE_Discover.equals(CreditCardType)) - return "Discover"; - else if (MPayment.CREDITCARDTYPE_PurchaseCard.equals(CreditCardType)) - return "PurchaseCard"; - return "?" + CreditCardType + "?"; - } // getCreditCardName - -} // PosOrderModel.class diff --git a/org.adempiere.ui.swing/src/org/compiere/pos/PosPanel.java b/org.adempiere.ui.swing/src/org/compiere/pos/PosPanel.java deleted file mode 100644 index 02d639c456..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/pos/PosPanel.java +++ /dev/null @@ -1,18 +0,0 @@ -package org.compiere.pos; - -import org.compiere.apps.form.FormFrame; -import org.compiere.apps.form.FormPanel; - -public class PosPanel implements FormPanel { - private PosBasePanel panel; - - public void dispose() { - panel.dispose(); - } - - public void init(int WindowNo, FormFrame frame) { - panel = new PosBasePanel(); - panel.init(0, frame); - } - -} diff --git a/org.adempiere.ui.swing/src/org/compiere/pos/PosPayment.java b/org.adempiere.ui.swing/src/org/compiere/pos/PosPayment.java deleted file mode 100644 index dd6e5cd665..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/pos/PosPayment.java +++ /dev/null @@ -1,529 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 Adempiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - *****************************************************************************/ -package org.compiere.pos; - -import java.awt.Component; -import java.awt.Dimension; -import java.awt.Font; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.awt.event.KeyEvent; -import java.beans.PropertyChangeEvent; -import java.beans.PropertyVetoException; -import java.beans.VetoableChangeListener; -import java.math.BigDecimal; -import java.text.DecimalFormat; -import java.text.NumberFormat; -import java.text.ParseException; -import java.util.ArrayList; -import java.util.Locale; -import java.util.Properties; - -import javax.swing.DefaultComboBoxModel; -import javax.swing.DefaultListCellRenderer; -import javax.swing.JLabel; -import javax.swing.JList; -import javax.swing.JTextField; -import javax.swing.KeyStroke; -import javax.swing.ListCellRenderer; -import javax.swing.SwingUtilities; -import javax.swing.border.TitledBorder; - -import net.miginfocom.swing.MigLayout; - -import org.adempiere.plaf.AdempierePLAF; -import org.compiere.apps.ADialog; -import org.compiere.apps.AEnv; -import org.compiere.apps.AppsAction; -import org.compiere.model.MCurrency; -import org.compiere.model.MLookup; -import org.compiere.model.MLookupFactory; -import org.compiere.model.MPOS; -import org.compiere.model.MPOSKey; -import org.compiere.model.MPayment; -import org.compiere.model.MPaymentValidate; - -import static org.compiere.model.SystemIDs.*; - -import org.compiere.swing.CButton; -import org.compiere.swing.CComboBox; -import org.compiere.swing.CDialog; -import org.compiere.swing.CLabel; -import org.compiere.swing.CPanel; -import org.compiere.swing.CTextField; -import org.compiere.util.DisplayType; -import org.compiere.util.Env; -import org.compiere.util.Msg; -import org.compiere.util.ValueNamePair; - -public class PosPayment extends CDialog implements PosKeyListener, VetoableChangeListener, ActionListener { - /** - * - */ - private static final long serialVersionUID = -1961758117289056671L; - - NumberFormat formatter = new DecimalFormat("#0.00"); //red1 - parser to remove commas or dots separator for above '000s. - NumberFormat nf = NumberFormat.getInstance(Locale.getDefault()); // make locale-specific - - @Override - public void actionPerformed(ActionEvent e) { - - if ( e.getSource().equals(fTenderAmt) || e.getSource().equals(fPayAmt) ) - { - //red1 - remove commas from thousand value - BigDecimal tender = Env.ZERO; - BigDecimal pay = Env.ZERO; - try - { - tender = new BigDecimal(formatter.format((nf.parse(fTenderAmt.getText())).floatValue())); - pay = new BigDecimal(formatter.format((nf.parse(fPayAmt.getText())).floatValue())); - } - catch (ParseException n) - { - n.printStackTrace(); - } - if ( tender.compareTo(Env.ZERO) != 0 ) - { - fReturnAmt.setValue(tender.subtract(pay)); - } - return; - } - - if ( e.getSource().equals(f_bProcess)) - { - processPayment(); - } - if ( e.getSource().equals(f_bCancel)) - { - paid = false; - dispose(); - return; - } - - setTotals(); - - super.actionPerformed(e); - } - - private void processPayment() { - - try { - - String tenderType = ((ValueNamePair) tenderTypePick.getValue()).getID(); - BigDecimal amt = new BigDecimal(formatter.format((nf.parse(fPayAmt.getText())).floatValue()));; - - if ( tenderType.equals(MPayment.TENDERTYPE_Cash) ) - { - p_posPanel.m_order.payCash(amt); - } - else if ( tenderType.equals(MPayment.TENDERTYPE_Check) ) - { - p_posPanel.m_order.payCheck(amt,fCheckAccountNo.getText(), fCheckRouteNo.getText(), fCheckNo.getText()); - p_posPanel.f_order.openCashDrawer(); - } - else if ( tenderType.equals(MPayment.TENDERTYPE_CreditCard) ) - { - String error = null; - error = MPaymentValidate.validateCreditCardExp(fCCardMonth.getText()); - if ( error != null && !error.isEmpty() ) - { - ADialog.warn(0, p_posPanel, error); - return; - } - int month = MPaymentValidate.getCreditCardExpMM(fCCardMonth.getText()); - int year = MPaymentValidate.getCreditCardExpYY(fCCardMonth.getText()); - - String type = ((ValueNamePair) fCCardType.getSelectedItem()).getValue(); - error = MPaymentValidate.validateCreditCardNumber(fCCardNo.getText(), type); - if ( error != null && !error.isEmpty() ) - { - ADialog.warn(0, p_posPanel, error); - return; - } - p_posPanel.m_order.payCreditCard(amt, fCCardName.getText(), - month, year, fCCardNo.getText(), fCCardVC.getText(), type); - p_posPanel.f_order.openCashDrawer(); - } - else if ( tenderType.equals(MPayment.TENDERTYPE_Account) ) - { - p_posPanel.m_order.payCash(amt); - p_posPanel.f_order.openCashDrawer(); - } - else - { - ADialog.warn(0, this, "Unsupported payment type"); - } - - - p_posPanel.f_order.openCashDrawer(); - setTotals(); - } - catch (Exception e ) - { - ADialog.warn(0, this, "Payment processing failed: " + e.getMessage()); - } - } - - private PosBasePanel p_posPanel; - private MPOS p_pos; - private Properties p_ctx; - private PosOrderModel p_order; - private CTextField fTotal = new CTextField(10); - private CTextField fBalance = new CTextField(10); - private CComboBoxtenderTypePick = new CComboBox(); - private PosTextField fPayAmt; - private CButton f_bProcess; - private boolean paid = false; - private BigDecimal balance = Env.ZERO; - private PosTextField fCheckAccountNo; - private PosTextField fCheckNo; - private PosTextField fCheckRouteNo; - private PosTextField fCCardNo; - private PosTextField fCCardName; - private CComboBoxfCCardType; - private PosTextField fCCardMonth; - private PosTextField fCCardVC; - - private CLabel lCheckNo; - private CLabel lCheckAccountNo; - private CLabel lCheckRouteNo; - private CLabel lCCardNo; - private CLabel lCCardName; - private CLabel lCCardType; - private CLabel lCCardMonth; - private CLabel lCCardVC; - private PosTextField fTenderAmt; - private CLabel lTenderAmt; - private PosTextField fReturnAmt; - private CLabel lReturnAmt; - private CButton f_bCancel; - - public PosPayment(PosBasePanel posPanel) { - super(AEnv.getFrame(posPanel),true); - p_posPanel = posPanel; - p_pos = posPanel.p_pos; - p_ctx = p_pos.getCtx(); - p_order = p_posPanel.m_order; - - if ( p_order == null ) - dispose(); - - init(); - pack(); - setLocationByPlatform(true); - } - - private void init() { - - Font font = AdempierePLAF.getFont_Field().deriveFont(18f); - - // North - CPanel mainPanel = new CPanel(new MigLayout("hidemode 3", - "[100:100:300, trailing]20[200:200:300,grow, trailing]")); - getContentPane().add(mainPanel); - - mainPanel.setBorder(new TitledBorder(Msg.translate(p_ctx, "Payment"))); - CLabel gtLabel = new CLabel(Msg.translate(p_ctx, "GrandTotal")); - mainPanel.add(gtLabel, "growx"); - mainPanel.add(fTotal, "wrap, growx"); - fTotal.setEditable(false); - fTotal.setFont(font); - fTotal.setHorizontalAlignment(JTextField.TRAILING); - - mainPanel.add(new CLabel(Msg.translate(p_ctx, "Balance")), "growx"); - mainPanel.add(fBalance, "wrap, growx"); - fBalance.setEditable(false); - fBalance.setFont(font); - fBalance.setHorizontalAlignment(JTextField.TRAILING); - - - mainPanel.add(new CLabel(Msg.translate(p_ctx, "TenderType"), "growx")); - // Payment type selection - int AD_Column_ID = COLUMN_C_PAYMENT_V_TENDERTYPE; //C_Payment_v.TenderType - MLookup lookup = MLookupFactory.get(Env.getCtx(), 0, 0, AD_Column_ID, DisplayType.List); - ArrayList types = lookup.getData(true, false, true, true, false); // IDEMPIERE 90 - - DefaultComboBoxModel typeModel = new DefaultComboBoxModel(types.toArray()); - tenderTypePick.setModel(typeModel); - // default to cash payment - for (Object obj : types) - { - if ( obj instanceof ValueNamePair ) - { - ValueNamePair key = (ValueNamePair) obj; - if ( key.getID().equals("X")) // Cash - tenderTypePick.setSelectedItem(key); - - if ( ! "CKX".contains(key.getID() ) ) - tenderTypePick.removeItem(key); - } - } - - tenderTypePick.setFont(font); - tenderTypePick.addActionListener(this); - tenderTypePick.setName("tenderTypePick"); //red1 for ID purpuse during testing - tenderTypePick.setRenderer(new ListCellRenderer() { - protected DefaultListCellRenderer defaultRenderer = new DefaultListCellRenderer(); - - public Component getListCellRendererComponent(JList list, Object value, - int index, boolean isSelected, boolean cellHasFocus) { - - JLabel renderer = (JLabel) defaultRenderer - .getListCellRendererComponent(list, value, index, isSelected, - cellHasFocus); - - renderer.setPreferredSize(new Dimension(50, 50)); - renderer.setHorizontalAlignment(JLabel.CENTER); - - return renderer; - - } - }); - - mainPanel.add(tenderTypePick, "wrap, h 50!, growx"); - - fPayAmt = new PosTextField(Msg.translate(p_ctx, "PayAmt"), p_posPanel, p_pos.getOSNP_KeyLayout_ID(), DisplayType.getNumberFormat(DisplayType.Amount)); - mainPanel.add(new CLabel(Msg.translate(p_ctx, "PayAmt")), "growx"); - fPayAmt.setFont(font); - fPayAmt.setHorizontalAlignment(JTextField.TRAILING); - fPayAmt.addActionListener(this); - mainPanel.add(fPayAmt, "wrap, growx"); - - fTenderAmt = new PosTextField(Msg.translate(p_ctx, "AmountTendered"), p_posPanel, p_pos.getOSNP_KeyLayout_ID(), DisplayType.getNumberFormat(DisplayType.Amount)); - lTenderAmt = new CLabel(Msg.translate(p_ctx, "AmountTendered")); - mainPanel.add(lTenderAmt, "growx"); - fTenderAmt.addActionListener(this); - fTenderAmt.setFont(font); - fTenderAmt.setHorizontalAlignment(JTextField.TRAILING); - mainPanel.add(fTenderAmt, "wrap, growx"); - - fReturnAmt = new PosTextField(Msg.translate(p_ctx, "AmountReturned"), p_posPanel, p_pos.getOSNP_KeyLayout_ID(), DisplayType.getNumberFormat(DisplayType.Amount)); - lReturnAmt = new CLabel(Msg.translate(p_ctx, "AmountReturned")); - mainPanel.add(lReturnAmt, "growx"); - fReturnAmt.setFont(font); - fReturnAmt.setHorizontalAlignment(JTextField.TRAILING); - mainPanel.add(fReturnAmt, "wrap, growx"); - fReturnAmt.setEditable(false); - - fCheckRouteNo = new PosTextField(Msg.translate(p_ctx, "RoutingNo"), p_posPanel, p_pos.getOSNP_KeyLayout_ID(), new DecimalFormat("#")); - lCheckRouteNo = new CLabel(Msg.translate(p_ctx, "RoutingNo")); - mainPanel.add(lCheckRouteNo, "growx"); - mainPanel.add(fCheckRouteNo, "wrap, growx"); - fCheckRouteNo.setFont(font); - fCheckRouteNo.setHorizontalAlignment(JTextField.TRAILING); - - fCheckAccountNo = new PosTextField(Msg.translate(p_ctx, "AccountNo"), p_posPanel, p_pos.getOSNP_KeyLayout_ID(), new DecimalFormat("#")); - lCheckAccountNo = new CLabel(Msg.translate(p_ctx, "AccountNo")); - mainPanel.add(lCheckAccountNo, "growx"); - mainPanel.add(fCheckAccountNo, "wrap, growx"); - fCheckAccountNo.setFont(font); - fCheckAccountNo.setHorizontalAlignment(JTextField.TRAILING); - - fCheckNo = new PosTextField(Msg.translate(p_ctx, "CheckNo"), p_posPanel, p_pos.getOSNP_KeyLayout_ID(), new DecimalFormat("#")); - lCheckNo = new CLabel(Msg.translate(p_ctx, "CheckNo")); - mainPanel.add(lCheckNo, "growx"); - mainPanel.add(fCheckNo, "wrap, growx"); - fCheckNo.setFont(font); - fCheckNo.setHorizontalAlignment(JTextField.TRAILING); - - /** - * Load Credit Cards - */ - ValueNamePair[] ccs = p_order.getCreditCards((BigDecimal) fPayAmt.getValue()); - // Set Selection - fCCardType = new CComboBox(ccs); - fCCardType.setName("cardType"); //red1 Id for testing - fCCardType.setRenderer(new ListCellRenderer() { - protected DefaultListCellRenderer defaultRenderer = new DefaultListCellRenderer(); - - public Component getListCellRendererComponent(JList list, Object value, - int index, boolean isSelected, boolean cellHasFocus) { - - JLabel renderer = (JLabel) defaultRenderer - .getListCellRendererComponent(list, value, index, isSelected, - cellHasFocus); - - renderer.setPreferredSize(new Dimension(50, 50)); - renderer.setHorizontalAlignment(JLabel.CENTER); - - return renderer; - - } - }); - lCCardType = new CLabel(Msg.translate(p_ctx, "CreditCardType")); - mainPanel.add(lCCardType, "growx"); - mainPanel.add(fCCardType, "h 50, wrap, growx"); - fCCardType.setFont(font); - - fCCardNo = new PosTextField(Msg.translate(p_ctx, "CreditCardNumber"), p_posPanel, p_pos.getOSNP_KeyLayout_ID(), new DecimalFormat("#")); - lCCardNo = new CLabel(Msg.translate(p_ctx, "CreditCardNumber")); - fCCardNo.setName("cardNo"); - mainPanel.add(lCCardNo, "growx"); - mainPanel.add(fCCardNo, "wrap, growx"); - fCCardNo.setFont(font); - fCCardNo.setHorizontalAlignment(JTextField.TRAILING); - - fCCardName = new PosTextField(Msg.translate(p_ctx, "Name"), p_posPanel, p_pos.getOSK_KeyLayout_ID()); - lCCardName = new CLabel(Msg.translate(p_ctx, "Name")); - mainPanel.add(lCCardName, "growx"); - mainPanel.add(fCCardName, "wrap, growx"); - fCCardName.setFont(font); - fCCardName.setHorizontalAlignment(JTextField.TRAILING); - - fCCardMonth = new PosTextField(Msg.translate(p_ctx, "Expires"), p_posPanel, p_pos.getOSNP_KeyLayout_ID(), new DecimalFormat("#")); - lCCardMonth = new CLabel(Msg.translate(p_ctx, "Expires")); - fCCardMonth.setName("expiry"); - mainPanel.add(lCCardMonth, "growx"); - mainPanel.add(fCCardMonth, "wrap, w 75!"); - fCCardMonth.setFont(font); - fCCardMonth.setHorizontalAlignment(JTextField.TRAILING); - - fCCardVC = new PosTextField(Msg.translate(p_ctx, "CVC"), p_posPanel, p_pos.getOSNP_KeyLayout_ID(), new DecimalFormat("#")); - lCCardVC = new CLabel(Msg.translate(p_ctx, "CVC")); - mainPanel.add(lCCardVC, "growx"); - mainPanel.add(fCCardVC, "wrap, w 75!"); - fCCardVC.setFont(font); - fCCardVC.setHorizontalAlignment(JTextField.TRAILING); - - AppsAction actCancel = new AppsAction("Cancel", KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), false); - actCancel.setDelegate(this); - f_bCancel = (CButton)actCancel.getButton(); - f_bCancel.setFocusable(false); - mainPanel.add (f_bCancel, "h 50!, w 50!, skip, split 2, trailing"); - - AppsAction act = new AppsAction("Ok", KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), false); - act.setDelegate(this); - f_bProcess = (CButton)act.getButton(); - f_bProcess.setFocusable(false); - mainPanel.add (f_bProcess, "h 50!, w 50!"); - - pack(); - - setTotals(); - } - - private void setTotals() { - - String tenderType = ((ValueNamePair) tenderTypePick.getValue()).getID(); - boolean cash = MPayment.TENDERTYPE_Cash.equals(tenderType); - boolean check = MPayment.TENDERTYPE_Check.equals(tenderType); - boolean creditcard = MPayment.TENDERTYPE_CreditCard.equals(tenderType); - //boolean account = MPayment.TENDERTYPE_Account.equals(tenderType); - - fTenderAmt.setVisible(cash); - fReturnAmt.setVisible(cash); - lTenderAmt.setVisible(cash); - lReturnAmt.setVisible(cash); - - fCheckAccountNo.setVisible(check); - fCheckNo.setVisible(check); - fCheckRouteNo.setVisible(check); - lCheckAccountNo.setVisible(check); - lCheckNo.setVisible(check); - lCheckRouteNo.setVisible(check); - - fCCardMonth.setVisible(creditcard); - fCCardName.setVisible(creditcard); - fCCardNo.setVisible(creditcard); - fCCardType.setVisible(creditcard); - fCCardVC.setVisible(creditcard); - lCCardMonth.setVisible(creditcard); - lCCardName.setVisible(creditcard); - lCCardNo.setVisible(creditcard); - lCCardType.setVisible(creditcard); - lCCardVC.setVisible(creditcard); - - fTotal.setValue(p_order.getGrandTotal()); - - BigDecimal received = p_order.getPaidAmt(); - balance = p_order.getGrandTotal().subtract(received); - balance = balance.setScale(MCurrency.getStdPrecision(p_ctx, p_order.getC_Currency_ID())); - if ( balance.compareTo(Env.ZERO) <= 0 ) - { - paid = true; - - if ( balance.compareTo(Env.ZERO) < 0 ) - ADialog.warn(0, this, Msg.getMsg(p_ctx, "Change") + ": " + balance); - dispose(); - } - - fBalance.setValue(balance); - fPayAmt.setValue(balance); - if ( !MPayment.TENDERTYPE_Cash.equals(tenderType) ) - { - fPayAmt.requestFocusInWindow(); - SwingUtilities.invokeLater(new Runnable() { - - public void run() { - fPayAmt.selectAll(); - } - }); - } - else - { - fTenderAmt.requestFocusInWindow(); - } - - pack(); - } - - public void keyReturned(MPOSKey key) { - - String text = key.getText(); - String payAmt = fPayAmt.getText(); - String selected = fPayAmt.getSelectedText(); - if ( selected != null && !selected.isEmpty() ) - { - payAmt = payAmt.replaceAll(selected, ""); - } - - if ( text != null && !text.isEmpty() ) - { - if ( text.equals(".") && payAmt.indexOf(".") == -1 ) - { - fPayAmt.setText(payAmt + text); - return; - } - try - { - Integer.parseInt(text); // test if number - fPayAmt.setText(payAmt + text); - } - catch (NumberFormatException e) - { - // ignore non-numbers - } - } - } - - public static boolean pay(PosBasePanel posPanel) { - - PosPayment pay = new PosPayment(posPanel); - pay.setVisible(true); - - return pay.isPaid(); - } - - private boolean isPaid() { - return paid ; - } - - public void vetoableChange(PropertyChangeEvent arg0) - throws PropertyVetoException { - // TODO Auto-generated method stub - - } - - -} diff --git a/org.adempiere.ui.swing/src/org/compiere/pos/PosQuery.java b/org.adempiere.ui.swing/src/org/compiere/pos/PosQuery.java deleted file mode 100644 index 5a23339f37..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/pos/PosQuery.java +++ /dev/null @@ -1,141 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 Adempiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - *****************************************************************************/ -package org.compiere.pos; - -import java.awt.Dimension; -import java.awt.HeadlessException; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.awt.event.MouseEvent; -import java.awt.event.MouseListener; -import java.util.Properties; - -import javax.swing.KeyStroke; -import javax.swing.event.ListSelectionEvent; -import javax.swing.event.ListSelectionListener; - -import org.compiere.apps.AEnv; -import org.compiere.apps.AppsAction; -import org.compiere.apps.ConfirmPanel; -import org.compiere.model.MPOS; -import org.compiere.swing.CButton; -import org.compiere.swing.CDialog; -import org.compiere.swing.CPanel; -import org.compiere.swing.CScrollPane; -import org.compiere.util.CLogger; - -public abstract class PosQuery extends CDialog implements MouseListener, ListSelectionListener, ActionListener { - /** - * - */ - private static final long serialVersionUID = -6227838436743951898L; - - protected Properties p_ctx; - /** POS Panel */ - protected PosBasePanel p_posPanel = null; - /** Underlying POS Model */ - protected MPOS p_pos = null; - /** The Table */ - protected PosTable m_table; - protected CPanel northPanel; - protected CScrollPane centerScroll; - protected ConfirmPanel confirm; - protected CButton f_up; - protected CButton f_down; - /** Logger */ - protected static CLogger log = CLogger.getCLogger(QueryProduct.class); - - public PosQuery() throws HeadlessException { - super(); - } - - protected abstract void close(); - - public abstract void reset(); - - public abstract void actionPerformed(ActionEvent e); - - public void dispose() { - removeAll(); - northPanel = null; - centerScroll = null; - confirm = null; - m_table = null; - super.dispose(); - } - - protected abstract void init(); - protected abstract void enableButtons(); - - /** - * Constructor - */ - public PosQuery (PosBasePanel posPanel) - { - super(AEnv.getFrame(posPanel), true); - p_posPanel = posPanel; - p_pos = posPanel.p_pos; - p_ctx = p_pos.getCtx(); - init(); - pack(); - setLocationByPlatform(true); - } // PosQueryBPartner - - /** - * Mouse Clicked - * @param e event - */ - public void mouseClicked(MouseEvent e) - { - // Single click with selected row => exit - if (e.getClickCount() > 0 && m_table.getSelectedRow() != -1) - { - enableButtons(); - close(); - } - } // mouseClicked - - public void mouseEntered (MouseEvent e) {} - public void mouseExited (MouseEvent e) {} - public void mousePressed (MouseEvent e) {} - public void mouseReleased (MouseEvent e) {} - - /** - * Table selection changed - * @param e event - */ - public void valueChanged (ListSelectionEvent e) - { - if (e.getValueIsAdjusting()) - return; - enableButtons(); - } // valueChanged - - /** - * Create Action Button - * @param action action - * @return button - */ - protected CButton createButtonAction(String action, KeyStroke accelerator) { - AppsAction act = new AppsAction(action, accelerator, false); - act.setDelegate(this); - CButton button = (CButton)act.getButton(); - button.setPreferredSize(new Dimension(WIDTH, HEIGHT)); - button.setMinimumSize(getPreferredSize()); - button.setMaximumSize(getPreferredSize()); - button.setFocusable(false); - return button; - } // getButtonAction - -} \ No newline at end of file diff --git a/org.adempiere.ui.swing/src/org/compiere/pos/PosSubPanel.java b/org.adempiere.ui.swing/src/org/compiere/pos/PosSubPanel.java deleted file mode 100644 index 1a825030fb..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/pos/PosSubPanel.java +++ /dev/null @@ -1,165 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 Adempiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - *****************************************************************************/ - -package org.compiere.pos; - -import java.awt.Dimension; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.util.Properties; - -import javax.swing.KeyStroke; - -import org.compiere.apps.AEnv; -import org.compiere.apps.AppsAction; -import org.compiere.model.MOrder; -import org.compiere.model.MPOS; -import org.compiere.print.ReportCtl; -import org.compiere.print.ReportEngine; -import org.compiere.swing.CButton; -import org.compiere.swing.CPanel; -import org.compiere.util.Env; - -/** - * POS Sub Panel Base Class. - * @author Comunidad de Desarrollo OpenXpertya - * *Basado en Codigo Original Modificado, Revisado y Optimizado de: - * *Copyright (c) Jorg Janke - * - */ -public abstract class PosSubPanel extends CPanel - implements ActionListener -{ - /** - * - */ - private static final long serialVersionUID = -8112502747494990955L; - - /** - * Constructor - * @param posPanel POS Panel - */ - public PosSubPanel (PosBasePanel posPanel) - { - super(); - p_posPanel = posPanel; - p_pos = posPanel.p_pos; - init(); - } // PosSubPanel - - /** POS Panel */ - protected PosBasePanel p_posPanel; - /** Underlying POS Model */ - protected MPOS p_pos; - /** Context */ - protected Properties p_ctx = Env.getCtx(); - - protected static CButton f_cashPayment; - - /** Button Width = 50 */ - private static final int WIDTH = 50; - /** Button Height = 50 */ - private static final int HEIGHT = 50; - - /** - * Initialize - */ - protected abstract void init(); - - /** - * Dispose - Free Resources - */ - public void dispose() - { - p_pos = null; - } // dispose - - - /** - * Create Action Button - * @param action action - * @return button - */ - protected CButton createButtonAction (String action, KeyStroke accelerator) - { - AppsAction act = new AppsAction(action, accelerator, false); - act.setDelegate(this); - CButton button = (CButton)act.getButton(); - button.setPreferredSize(new Dimension(WIDTH, HEIGHT)); - button.setMinimumSize(getPreferredSize()); - button.setMaximumSize(getPreferredSize()); - button.setFocusable(false); - return button; - } // getButtonAction - - /** - * Create Standard Button - * @param text text - * @return button - */ - protected CButton createButton (String text) - { - // if (text.indexOf("") == -1) - // text = "

    " + text + "

    "; - CButton button = new CButton(text); - button.addActionListener(this); - button.setPreferredSize(new Dimension(WIDTH, HEIGHT)); - button.setMinimumSize(getPreferredSize()); - button.setMaximumSize(getPreferredSize()); - button.setFocusable(false); - return button; - } // getButton - - /** - * Action Listener - * @param e event - */ - public void actionPerformed (ActionEvent e) - { - } // actionPerformed - /** - * Print Ticket - * @author Comunidad de Desarrollo OpenXpertya - * *Basado en Codigo Original Modificado, Revisado y Optimizado de: - * *Copyright ConSerTi - */ - public void printTicket() - { - if ( p_posPanel.m_order == null ) - return; - - MOrder order = p_posPanel.m_order; - //int windowNo = p_posPanel.getWindowNo(); - //Properties m_ctx = p_posPanel.getPropiedades(); - - if (order != null) - { - try - { - //TODO: to incorporate work from Posterita - /* - if (p_pos.getAD_PrintLabel_ID() != 0) - PrintLabel.printLabelTicket(order.getC_Order_ID(), p_pos.getAD_PrintLabel_ID()); - */ - //print standard document - ReportCtl.startDocumentPrint(ReportEngine.ORDER, order.getC_Order_ID(), null, AEnv.getWindowNo(this), true); - - } - catch (Exception e) - { - //log.severe("PrintTicket - Error Printing Ticket"); - } - } - } -} // PosSubPanel diff --git a/org.adempiere.ui.swing/src/org/compiere/pos/PosTable.java b/org.adempiere.ui.swing/src/org/compiere/pos/PosTable.java deleted file mode 100644 index 4977afa683..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/pos/PosTable.java +++ /dev/null @@ -1,43 +0,0 @@ -package org.compiere.pos; - -import java.awt.Container; -import java.awt.Dimension; - -import javax.swing.JScrollPane; -import javax.swing.JViewport; -import javax.swing.ListSelectionModel; - -import org.compiere.minigrid.MiniTable; - -public class PosTable extends MiniTable { - - /** - * - */ - private static final long serialVersionUID = 7884238751207398699L; - - public PosTable() { - - super(); - setRowSelectionAllowed(true); - setColumnSelectionAllowed(false); - setMultiSelection(false); - setSelectionMode(ListSelectionModel.SINGLE_SELECTION); - setRowHeight(30); - setAutoResize(false); - } - - public void growScrollbars() { - // fatter scroll bars - Container p = getParent(); - if (p instanceof JViewport) { - Container gp = p.getParent(); - if (gp instanceof JScrollPane) { - JScrollPane scrollPane = (JScrollPane) gp; - scrollPane.getVerticalScrollBar().setPreferredSize(new Dimension(30,0)); - scrollPane.getHorizontalScrollBar().setPreferredSize(new Dimension(0,30)); - } - } - } - -} diff --git a/org.adempiere.ui.swing/src/org/compiere/pos/PosTextField.java b/org.adempiere.ui.swing/src/org/compiere/pos/PosTextField.java deleted file mode 100644 index ffc3871cf0..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/pos/PosTextField.java +++ /dev/null @@ -1,93 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 Adempiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - *****************************************************************************/ -package org.compiere.pos; - -import java.awt.event.MouseEvent; -import java.awt.event.MouseListener; -import java.text.Format; - -import javax.swing.JFormattedTextField; -import javax.swing.text.DefaultFormatterFactory; - -/** - * Formatted Text field with on-screen keyboard support - * @author Paul Bowden - * Adaxa Pty Ltd - * - */ -public class PosTextField extends JFormattedTextField implements MouseListener { - /** - * - */ - private static final long serialVersionUID = -2453719110038264481L; - @SuppressWarnings("unused") - private DefaultFormatterFactory formatFactory = new DefaultFormatterFactory(); - PosBasePanel pos = null; - int keyLayoutId = 0; - private String title; - - public PosTextField(String title, PosBasePanel pos, final int posKeyLayout_ID, Format format ) { - super(format); - - if ( posKeyLayout_ID > 0 ) - addMouseListener(this); - - keyLayoutId = posKeyLayout_ID; - this.pos = pos; - this.title = title; - - } - - public PosTextField(String title, PosBasePanel pos, final int posKeyLayout_ID, AbstractFormatter formatter ) { - super(formatter); - - if ( posKeyLayout_ID > 0 ) - addMouseListener(this); - - keyLayoutId = posKeyLayout_ID; - this.pos = pos; - this.title = title; - - } - - - public PosTextField(String title, PosBasePanel pos, final int posKeyLayout_ID) { - super(); - - if ( posKeyLayout_ID > 0 ) - addMouseListener(this); - - keyLayoutId = posKeyLayout_ID; - this.pos = pos; - this.title = title; - - } - - public void mouseReleased(MouseEvent arg0) {} - public void mousePressed(MouseEvent arg0) {} - public void mouseExited(MouseEvent arg0) {} - public void mouseEntered(MouseEvent arg0) {} - - public void mouseClicked(MouseEvent arg0) { - - if ( isEnabled() && isEditable() ) - { - POSKeyboard keyboard = pos.getKeyboard(keyLayoutId); - keyboard.setTitle(title); - keyboard.setPosTextField(this); - keyboard.setVisible(true); - fireActionPerformed(); - } - } -} diff --git a/org.adempiere.ui.swing/src/org/compiere/pos/QueryBPartner.java b/org.adempiere.ui.swing/src/org/compiere/pos/QueryBPartner.java deleted file mode 100644 index 759e0a20ac..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/pos/QueryBPartner.java +++ /dev/null @@ -1,300 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 Adempiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - *****************************************************************************/ - -package org.compiere.pos; - -import java.awt.Dimension; -import java.awt.event.ActionEvent; -import java.awt.event.KeyEvent; -import java.util.logging.Level; - -import javax.swing.KeyStroke; -import javax.swing.border.TitledBorder; - -import net.miginfocom.swing.MigLayout; - -import org.compiere.minigrid.ColumnInfo; -import org.compiere.minigrid.IDColumn; -import org.compiere.model.MBPartnerInfo; -import org.compiere.swing.CButton; -import org.compiere.swing.CLabel; -import org.compiere.swing.CPanel; -import org.compiere.swing.CScrollPane; -import org.compiere.swing.CTextField; -import org.compiere.util.CLogger; -import org.compiere.util.Env; -import org.compiere.util.Msg; - -/** - * POS Query BPartner - * - * @author Comunidad de Desarrollo OpenXpertya - * *Basado en Codigo Original Modificado, Revisado y Optimizado de: - * *Copyright (c) Jorg Janke - * @version $Id: QueryBPartner.java,v 1.1 2004/07/12 04:10:04 jjanke Exp $ - */ -public class QueryBPartner extends PosQuery -{ - /** - * - */ - private static final long serialVersionUID = -4500636033505855695L; - - /** - * Constructor - */ - public QueryBPartner (PosBasePanel posPanel) - { - super(posPanel); - } // PosQueryBPartner - - private PosTextField f_value; - private PosTextField f_name; - private PosTextField f_contact; - private PosTextField f_email; - private PosTextField f_phone; - private CTextField f_city; - - private int m_C_BPartner_ID; - private CButton f_refresh; - private CButton f_ok; - private CButton f_cancel; - /** Logger */ - private static CLogger log = CLogger.getCLogger(QueryBPartner.class); - - - /** Table Column Layout Info */ - private static ColumnInfo[] s_layout = new ColumnInfo[] - { - new ColumnInfo(" ", "C_BPartner_ID", IDColumn.class), - new ColumnInfo(Msg.translate(Env.getCtx(), "Value"), "Value", String.class), - new ColumnInfo(Msg.translate(Env.getCtx(), "Name"), "Name", String.class), - new ColumnInfo(Msg.translate(Env.getCtx(), "Email"), "Email", String.class), - new ColumnInfo(Msg.translate(Env.getCtx(), "Phone"), "Phone", String.class), - new ColumnInfo(Msg.translate(Env.getCtx(), "Postal"), "Postal", String.class), - new ColumnInfo(Msg.translate(Env.getCtx(), "City"), "City", String.class) - }; - /** From Clause */ - private static String s_sqlFrom = "RV_BPartner"; - /** Where Clause */ - private static String s_sqlWhere = "IsActive='Y'"; - - /** - * Set up Panel - */ - protected void init() - { - CPanel panel = new CPanel(); - - panel.setLayout(new MigLayout("fill")); - getContentPane().add(panel); - // North - northPanel = new CPanel(new MigLayout("fill","", "[50][50][]")); - panel.add (northPanel, "north"); - northPanel.setBorder(new TitledBorder(Msg.getMsg(p_ctx, "Query"))); - - CLabel lvalue = new CLabel(Msg.translate(p_ctx, "Value")); - northPanel.add (lvalue, " growy"); - f_value = new PosTextField("", p_posPanel, p_pos.getOSK_KeyLayout_ID()); - lvalue.setLabelFor(f_value); - northPanel.add(f_value, "h 30, w 200"); - f_value.addActionListener(this); - - // - CLabel lcontact = new CLabel(Msg.translate(p_ctx, "Contact")); - northPanel.add (lcontact, " growy"); - f_contact = new PosTextField("", p_posPanel, p_pos.getOSK_KeyLayout_ID()); - lcontact.setLabelFor(f_contact); - northPanel.add(f_contact, "h 30, w 200"); - f_contact.addActionListener(this); - - // - CLabel lphone = new CLabel(Msg.translate(p_ctx, "Phone")); - northPanel.add (lphone, " growy"); - f_phone = new PosTextField("", p_posPanel, p_pos.getOSK_KeyLayout_ID()); - lphone.setLabelFor(f_phone); - northPanel.add(f_phone, "h 30, w 200, wrap"); - f_phone.addActionListener(this); - - // - CLabel lname = new CLabel(Msg.translate(p_ctx, "Name")); - northPanel.add (lname, " growy"); - f_name = new PosTextField("", p_posPanel, p_pos.getOSK_KeyLayout_ID()); - lname.setLabelFor(f_name); - northPanel.add(f_name, "h 30, w 200"); - f_name.addActionListener(this); - // - CLabel lemail = new CLabel(Msg.translate(p_ctx, "Email")); - northPanel.add (lemail, " growy"); - f_email = new PosTextField("", p_posPanel, p_pos.getOSK_KeyLayout_ID()); - lemail.setLabelFor(f_email); - northPanel.add(f_email, "h 30, w 200"); - f_email.addActionListener(this); - // - CLabel lcity = new CLabel(Msg.translate(p_ctx, "City")); - northPanel.add (lcity, " growy"); - f_city = new CTextField(10); - lcity.setLabelFor(f_city); - northPanel.add(f_city, "h 30, w 200"); - f_city.addActionListener(this); - // - - f_refresh = createButtonAction("Refresh", KeyStroke.getKeyStroke(KeyEvent.VK_F5, 0)); - northPanel.add(f_refresh, "w 50!, h 50!, wrap, alignx trailing"); - - f_up = createButtonAction("Previous", KeyStroke.getKeyStroke(KeyEvent.VK_UP, 0)); - northPanel.add(f_up, "w 50!, h 50!, span, split 4"); - f_down = createButtonAction("Next", KeyStroke.getKeyStroke(KeyEvent.VK_DOWN, 0)); - northPanel.add(f_down, "w 50!, h 50!"); - - f_ok = createButtonAction("Ok", KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0)); - northPanel.add(f_ok, "w 50!, h 50!"); - - f_cancel = createButtonAction("Cancel", KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0)); - northPanel.add(f_cancel, "w 50!, h 50!"); - - // Center - m_table = new PosTable(); - @SuppressWarnings("unused") - String sql = m_table.prepareTable (s_layout, s_sqlFrom, - s_sqlWhere, false, "RV_BPartner") - + " ORDER BY Value"; - m_table.addMouseListener(this); - m_table.getSelectionModel().addListSelectionListener(this); - enableButtons(); - centerScroll = new CScrollPane(m_table); - panel.add (centerScroll, "growx, growy"); - m_table.growScrollbars(); - panel.setPreferredSize(new Dimension(800,600)); - f_value.requestFocus(); - } // init - - /** - * Action Listener - * @param e event - */ - public void actionPerformed (ActionEvent e) - { - if (log.isLoggable(Level.INFO)) log.info(e.getActionCommand()); - if ("Refresh".equals(e.getActionCommand()) - || e.getSource() == f_value // || e.getSource() == f_upc - || e.getSource() == f_name // || e.getSource() == f_sku - ) - { - setResults(MBPartnerInfo.find (p_ctx, - f_value.getText(), f_name.getText(), - null, f_email.getText(), - f_phone.getText(), f_city.getText())); - return; - } - else if ("Reset".equals(e.getActionCommand())) - { - reset(); - return; - } - else if ("Previous".equalsIgnoreCase(e.getActionCommand())) - { - int rows = m_table.getRowCount(); - if (rows == 0) - return; - int row = m_table.getSelectedRow(); - row--; - if (row < 0) - row = 0; - m_table.getSelectionModel().setSelectionInterval(row, row); - return; - } - else if ("Next".equalsIgnoreCase(e.getActionCommand())) - { - int rows = m_table.getRowCount(); - if (rows == 0) - return; - int row = m_table.getSelectedRow(); - row++; - if (row >= rows) - row = rows - 1; - m_table.getSelectionModel().setSelectionInterval(row, row); - return; - } - // Exit - close(); - } // actionPerformed - - - /** - * Set/display Results - * @param results results - */ - public void setResults (MBPartnerInfo[] results) - { - m_table.loadTable(results); - enableButtons(); - } // setResults - - /** - * Enable/Set Buttons and set ID - */ - protected void enableButtons() - { - m_C_BPartner_ID = -1; - int row = m_table.getSelectedRow(); - boolean enabled = row != -1; - if (enabled) - { - Integer ID = m_table.getSelectedRowKey(); - if (ID != null) - { - m_C_BPartner_ID = ID.intValue(); - // m_BPartnerName = (String)m_table.getValueAt(row, 2); - // m_Price = (BigDecimal)m_table.getValueAt(row, 7); - } - } - f_ok.setEnabled(enabled); - if (log.isLoggable(Level.FINE)) log.fine("C_BPartner_ID=" + m_C_BPartner_ID); - } // enableButtons - - /** - * Close. - * Set Values on other panels and close - */ - protected void close() - { - if (log.isLoggable(Level.FINE)) log.fine("C_BPartner_ID=" + m_C_BPartner_ID); - - if (m_C_BPartner_ID > 0) - { - p_posPanel.f_order.setC_BPartner_ID(m_C_BPartner_ID); - // p_posPanel.f_curLine.setCurrency(m_Price); - } - else - { - p_posPanel.f_order.setC_BPartner_ID(0); - // p_posPanel.f_curLine.setPrice(Env.ZERO); - } - dispose(); - } // close - - - @Override - public void reset() { - f_value.setText(null); - f_name.setText(null); - f_contact.setText(null); - f_email.setText(null); - f_phone.setText(null); - f_city.setText(null); - setResults(new MBPartnerInfo[0]); - } - -} // PosQueryBPartner diff --git a/org.adempiere.ui.swing/src/org/compiere/pos/QueryProduct.java b/org.adempiere.ui.swing/src/org/compiere/pos/QueryProduct.java deleted file mode 100644 index 50f2f95520..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/pos/QueryProduct.java +++ /dev/null @@ -1,316 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 Adempiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - *****************************************************************************/ - -package org.compiere.pos; - -import java.awt.Dimension; -import java.awt.event.ActionEvent; -import java.awt.event.KeyEvent; -import java.math.BigDecimal; -import java.util.logging.Level; - -import javax.swing.KeyStroke; -import javax.swing.border.TitledBorder; - -import net.miginfocom.swing.MigLayout; - -import org.compiere.minigrid.ColumnInfo; -import org.compiere.minigrid.IDColumn; -import org.compiere.model.MWarehousePrice; -import org.compiere.swing.CButton; -import org.compiere.swing.CLabel; -import org.compiere.swing.CPanel; -import org.compiere.swing.CScrollPane; -import org.compiere.util.CLogger; -import org.compiere.util.Env; -import org.compiere.util.Msg; - -/** - * POS Query Product - * - * @author Based on Modified Original Code, Revised and Optimized - * *Copyright (c) Jorg Janke - */ -public class QueryProduct extends PosQuery -{ - /** - * - */ - private static final long serialVersionUID = 2618144050021362472L; - - /** - * Constructor - */ - public QueryProduct (PosBasePanel posPanel) - { - super(posPanel); - } // PosQueryProduct - - private PosTextField f_value; - private PosTextField f_name; - private PosTextField f_upc; - private PosTextField f_sku; - - private int m_M_Product_ID; - private String m_ProductName; - private BigDecimal m_Price; - // - private int m_M_PriceList_Version_ID; - private int m_M_Warehouse_ID; - private CButton f_refresh; - private CButton f_ok; - private CButton f_cancel; - /** Logger */ - private static CLogger log = CLogger.getCLogger(QueryProduct.class); - - - /** Table Column Layout Info */ - private static ColumnInfo[] s_layout = new ColumnInfo[] - { - new ColumnInfo(" ", "M_Product_ID", IDColumn.class), - new ColumnInfo(Msg.translate(Env.getCtx(), "Value"), "Value", String.class), - new ColumnInfo(Msg.translate(Env.getCtx(), "Name"), "Name", String.class), - new ColumnInfo(Msg.translate(Env.getCtx(), "UPC"), "UPC", String.class), - new ColumnInfo(Msg.translate(Env.getCtx(), "SKU"), "SKU", String.class), - new ColumnInfo(Msg.translate(Env.getCtx(), "QtyAvailable"), "QtyAvailable", Double.class), - new ColumnInfo(Msg.translate(Env.getCtx(), "QtyOnHand"), "QtyOnHand", Double.class), - new ColumnInfo(Msg.translate(Env.getCtx(), "PriceStd"), "PriceStd", BigDecimal.class) - }; - /** From Clause */ - private static String s_sqlFrom = "RV_WarehousePrice"; - /** Where Clause */ - private static String s_sqlWhere = "IsActive='Y'"; - - /** - * Set up Panel - */ - protected void init() - { - CPanel panel = new CPanel(); - - panel.setLayout(new MigLayout("fill")); - getContentPane().add(panel); - // North - northPanel = new CPanel(new MigLayout("fill", "", "[50][50][]")); - panel.add (northPanel, "north"); - northPanel.setBorder(new TitledBorder(Msg.getMsg(p_ctx, "Query"))); - - // - CLabel lvalue = new CLabel(Msg.translate(p_ctx, "Value")); - northPanel.add (lvalue, "growy"); - f_value = new PosTextField("", p_posPanel, p_pos.getOSK_KeyLayout_ID()); - f_value.setName("ProductKey"); //red1 for UISpec4J testing call - lvalue.setLabelFor(f_value); - northPanel.add(f_value, "h 30, w 200"); - f_value.addActionListener(this); - // - CLabel lupc = new CLabel(Msg.translate(p_ctx, "UPC")); - northPanel.add (lupc, "growy"); - f_upc = new PosTextField("", p_posPanel, p_pos.getOSK_KeyLayout_ID()); - lupc.setLabelFor(f_upc); - northPanel.add(f_upc, "h 30, w 200, wrap"); - f_upc.addActionListener(this); - // - CLabel lname = new CLabel(Msg.translate(p_ctx, "Name")); - northPanel.add (lname, "growy"); - f_name = new PosTextField("", p_posPanel, p_pos.getOSK_KeyLayout_ID()); - f_name.setName("ProductName"); //red1 for UISpec4J testing call - lname.setLabelFor(f_name); - northPanel.add(f_name, "h 30, w 200"); - f_name.addActionListener(this); - // - CLabel lsku = new CLabel(Msg.translate(p_ctx, "SKU")); - northPanel.add (lsku, "growy"); - f_sku = new PosTextField("", p_posPanel, p_pos.getOSK_KeyLayout_ID()); - lsku.setLabelFor(f_sku); - northPanel.add(f_sku, "h 30, w 200"); - f_sku.addActionListener(this); - // - - - f_refresh = createButtonAction("Refresh", KeyStroke.getKeyStroke(KeyEvent.VK_F5, 0)); - northPanel.add(f_refresh, "w 50!, h 50!, wrap, alignx trailing"); - - f_up = createButtonAction("Previous", KeyStroke.getKeyStroke(KeyEvent.VK_UP, 0)); - northPanel.add(f_up, "w 50!, h 50!, span, split 4"); - f_down = createButtonAction("Next", KeyStroke.getKeyStroke(KeyEvent.VK_DOWN, 0)); - northPanel.add(f_down, "w 50!, h 50!"); - - f_ok = createButtonAction("Ok", KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0)); - northPanel.add(f_ok, "w 50!, h 50!"); - - f_cancel = createButtonAction("Cancel", KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0)); - northPanel.add(f_cancel, "w 50!, h 50!"); - - // Center - m_table = new PosTable(); - @SuppressWarnings("unused") - String sql = m_table.prepareTable (s_layout, s_sqlFrom, - s_sqlWhere, false, "RV_WarehousePrice") - + " ORDER BY Margin, QtyAvailable"; - m_table.addMouseListener(this); - m_table.getSelectionModel().addListSelectionListener(this); - m_table.setColumnVisibility(m_table.getColumn(0), false); - m_table.getColumn(1).setPreferredWidth(175); - m_table.getColumn(2).setPreferredWidth(175); - m_table.getColumn(3).setPreferredWidth(100); - m_table.getColumn(4).setPreferredWidth(75); - m_table.getColumn(5).setPreferredWidth(75); - m_table.getColumn(6).setPreferredWidth(75); - m_table.getColumn(7).setPreferredWidth(75); - enableButtons(); - m_table.setFillsViewportHeight( true ); //@Trifon - m_table.growScrollbars(); - centerScroll = new CScrollPane(m_table); - panel.add (centerScroll, "growx, growy,south"); - panel.setPreferredSize(new Dimension(800,600)); - f_value.requestFocus(); - } // init - - /** - * Set Query Data - * @param M_PriceList_Version_ID plv - * @param M_Warehouse_ID wh - */ - public void setQueryData (int M_PriceList_Version_ID, int M_Warehouse_ID) - { - m_M_PriceList_Version_ID = M_PriceList_Version_ID; - m_M_Warehouse_ID = M_Warehouse_ID; - } // setQueryData - - /** - * Action Listener - * @param e event - */ - public void actionPerformed (ActionEvent e) - { - if (log.isLoggable(Level.INFO)) log.info(e.getActionCommand()); - if ("Refresh".equals(e.getActionCommand()) - || e.getSource() == f_value || e.getSource() == f_upc - || e.getSource() == f_name || e.getSource() == f_sku) - { - setResults(MWarehousePrice.find (p_ctx, - m_M_PriceList_Version_ID, m_M_Warehouse_ID, - f_value.getText(), f_name.getText(), f_upc.getText(), f_sku.getText(), null)); - return; - } - else if ("Reset".equals(e.getActionCommand())) - { - reset(); - return; - } - else if ("Previous".equalsIgnoreCase(e.getActionCommand())) - { - int rows = m_table.getRowCount(); - if (rows == 0) - return; - int row = m_table.getSelectedRow(); - row--; - if (row < 0) - row = 0; - m_table.getSelectionModel().setSelectionInterval(row, row); - // https://sourceforge.net/tracker/?func=detail&atid=879332&aid=3121975&group_id=176962 - m_table.scrollRectToVisible(m_table.getCellRect(row, 1, true)); //@Trifon - BF[3121975] - return; - } - else if ("Next".equalsIgnoreCase(e.getActionCommand())) - { - int rows = m_table.getRowCount(); - if (rows == 0) - return; - int row = m_table.getSelectedRow(); - row++; - if (row >= rows) - row = rows - 1; - m_table.getSelectionModel().setSelectionInterval(row, row); - // https://sourceforge.net/tracker/?func=detail&atid=879332&aid=3121975&group_id=176962 - m_table.scrollRectToVisible(m_table.getCellRect(row, 1, true)); //@Trifon - BF[3121975] - return; - } - // Exit - close(); - } // actionPerformed - - - /** - * Set/display Results - * @param results results - */ - public void setResults (MWarehousePrice[] results) - { - m_table.loadTable(results); - if (m_table.getRowCount() >0 ) - m_table.setRowSelectionInterval(0, 0); - enableButtons(); - } // setResults - - /** - * Enable/Set Buttons and set ID - */ - protected void enableButtons() - { - m_M_Product_ID = -1; - m_ProductName = null; - m_Price = null; - int row = m_table.getSelectedRow(); - boolean enabled = row != -1; - if (enabled) - { - Integer ID = m_table.getSelectedRowKey(); - if (ID != null) - { - m_M_Product_ID = ID.intValue(); - m_ProductName = (String)m_table.getValueAt(row, 2); - m_Price = (BigDecimal)m_table.getValueAt(row, 7); - } - } - f_ok.setEnabled(enabled); - if (log.isLoggable(Level.FINE)) log.fine("M_Product_ID=" + m_M_Product_ID + " - " + m_ProductName + " - " + m_Price); - } // enableButtons - - - - /** - * Close. - * Set Values on other panels and close - */ - protected void close() - { - if (log.isLoggable(Level.FINE)) log.fine("M_Product_ID=" + m_M_Product_ID); - - if (m_M_Product_ID > 0) - { - p_posPanel.f_curLine.setM_Product_ID(m_M_Product_ID); - p_posPanel.f_curLine.setPrice(m_Price); - } - else - { - p_posPanel.f_curLine.setM_Product_ID(0); - p_posPanel.f_curLine.setPrice(Env.ZERO); - } - dispose(); - } // close - - - @Override - public void reset() { - - f_value.setText(null); - f_name.setText(null); - f_sku.setText(null); - f_upc.setText(null); - setResults(new MWarehousePrice[0]); - } - -} // PosQueryProduct diff --git a/org.adempiere.ui.swing/src/org/compiere/pos/QueryTicket.java b/org.adempiere.ui.swing/src/org/compiere/pos/QueryTicket.java deleted file mode 100644 index 266698e243..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/pos/QueryTicket.java +++ /dev/null @@ -1,306 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 Adempiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - *****************************************************************************/ - -package org.compiere.pos; - -import java.awt.Dimension; -import java.awt.event.ActionEvent; -import java.awt.event.KeyEvent; -import java.math.BigDecimal; -import java.sql.PreparedStatement; -import java.sql.ResultSet; -import java.sql.Timestamp; -import java.util.Properties; -import java.util.logging.Level; - -import javax.swing.KeyStroke; -import javax.swing.border.TitledBorder; - -import net.miginfocom.swing.MigLayout; - -import org.compiere.grid.ed.VDate; -import org.compiere.minigrid.ColumnInfo; -import org.compiere.minigrid.IDColumn; -import org.compiere.swing.CButton; -import org.compiere.swing.CCheckBox; -import org.compiere.swing.CLabel; -import org.compiere.swing.CPanel; -import org.compiere.swing.CScrollPane; -import org.compiere.util.DB; -import org.compiere.util.Env; -import org.compiere.util.Msg; - -/** - * POS Query Product - * - * @author Comunidad de Desarrollo OpenXpertya - * *Basado en Codigo Original Modificado, Revisado y Optimizado de: - * *Jose A.Gonzalez, Conserti. - * - * @version $Id: QueryTicket.java,v 0.9 $ - * - * @Colaborador $Id: Consultoria y Soporte en Redes y Tecnologias de la Informacion S.L. - * - */ - -public class QueryTicket extends PosQuery -{ - /** - * - */ - private static final long serialVersionUID = 1487067464540688770L; - - /** - * Constructor - */ - public QueryTicket (PosBasePanel posPanel) - { - super(posPanel); - } // PosQueryProduct - - - private PosTextField f_documentno; - private VDate f_date; - - private int m_c_order_id; - private CCheckBox f_processed; - private CButton f_refresh; - private CButton f_ok; - private CButton f_cancel; - - /** Table Column Layout Info */ - private static ColumnInfo[] s_layout = new ColumnInfo[] - { - new ColumnInfo(" ", "C_Order_ID", IDColumn.class), - new ColumnInfo(Msg.translate(Env.getCtx(), "DocumentNo"), "DocumentNo", String.class), - new ColumnInfo(Msg.translate(Env.getCtx(), "TotalLines"), "TotalLines", BigDecimal.class), - new ColumnInfo(Msg.translate(Env.getCtx(), "GrandTotal"), "GrandTotal", BigDecimal.class), - new ColumnInfo(Msg.translate(Env.getCtx(), "C_BPartner_ID"), "Name", String.class), - new ColumnInfo(Msg.translate(Env.getCtx(), "Processed"), "Processed", Boolean.class) - }; - - /** - * Set up Panel - */ - @Override - protected void init() - { - CPanel panel = new CPanel(); - - panel.setLayout(new MigLayout("fill")); - getContentPane().add(panel); - // North - northPanel = new CPanel(new MigLayout("fill","", "[50][50][]")); - panel.add (northPanel, "north"); - northPanel.setBorder(new TitledBorder(Msg.getMsg(p_ctx, "Query"))); - - CLabel ldoc = new CLabel(Msg.translate(p_ctx, "DocumentNo")); - northPanel.add (ldoc, " growy"); - f_documentno = new PosTextField("", p_posPanel, p_pos.getOSK_KeyLayout_ID()); - ldoc.setLabelFor(f_documentno); - northPanel.add(f_documentno, "h 30, w 200"); - f_documentno.addActionListener(this); - // - CLabel ldate = new CLabel(Msg.translate(p_ctx, "DateOrdered")); - northPanel.add (ldate, "growy"); - f_date = new VDate(); - f_date.setValue(Env.getContextAsDate(Env.getCtx(), "#Date")); - ldate.setLabelFor(f_date); - northPanel.add(f_date, "h 30, w 200"); - f_date.addActionListener(this); - - f_processed = new CCheckBox(Msg.translate(p_ctx, "Processed")); - f_processed.setSelected(false); - northPanel.add(f_processed, ""); - - f_refresh = createButtonAction("Refresh", KeyStroke.getKeyStroke(KeyEvent.VK_F5, 0)); - northPanel.add(f_refresh, "w 50!, h 50!, wrap, alignx trailing"); - - f_up = createButtonAction("Previous", KeyStroke.getKeyStroke(KeyEvent.VK_UP, 0)); - northPanel.add(f_up, "w 50!, h 50!, span, split 4"); - f_down = createButtonAction("Next", KeyStroke.getKeyStroke(KeyEvent.VK_DOWN, 0)); - northPanel.add(f_down, "w 50!, h 50!"); - - f_ok = createButtonAction("Ok", KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0)); - northPanel.add(f_ok, "w 50!, h 50!"); - - f_cancel = createButtonAction("Cancel", KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0)); - northPanel.add(f_cancel, "w 50!, h 50!"); - - - // Center - m_table = new PosTable(); - - @SuppressWarnings("unused") - String sql = m_table.prepareTable (s_layout, "C_Order", - "C_POS_ID = " + p_pos.getC_POS_ID() - , false, "C_Order") - + " ORDER BY Margin, QtyAvailable"; - m_table.addMouseListener(this); - m_table.getSelectionModel().addListSelectionListener(this); - enableButtons(); - centerScroll = new CScrollPane(m_table); - panel.add (centerScroll, "growx, growy"); - m_table.growScrollbars(); - panel.setPreferredSize(new Dimension(800,600)); - - f_documentno.requestFocus(); - pack(); - - setResults(p_ctx, f_processed.isSelected(), f_documentno.getText(), f_date.getTimestamp()); - } // init - - - /** - * Action Listener - * @param e event - */ - @Override - public void actionPerformed (ActionEvent e) - { - if (log.isLoggable(Level.INFO)) log.info("PosQueryProduct.actionPerformed - " + e.getActionCommand()); - if ("Refresh".equals(e.getActionCommand()) - || e.getSource() == f_processed || e.getSource() == f_documentno - || e.getSource() == f_date) - { - setResults(p_ctx, f_processed.isSelected(), f_documentno.getText(), f_date.getTimestamp()); - return; - } - else if ("Reset".equals(e.getActionCommand())) - { - reset(); - return; - } - else if ("Previous".equalsIgnoreCase(e.getActionCommand())) - { - int rows = m_table.getRowCount(); - if (rows == 0) - return; - int row = m_table.getSelectedRow(); - row--; - if (row < 0) - row = 0; - m_table.getSelectionModel().setSelectionInterval(row, row); - return; - } - else if ("Next".equalsIgnoreCase(e.getActionCommand())) - { - int rows = m_table.getRowCount(); - if (rows == 0) - return; - int row = m_table.getSelectedRow(); - row++; - if (row >= rows) - row = rows - 1; - m_table.getSelectionModel().setSelectionInterval(row, row); - return; - } - else if ("Cancel".equalsIgnoreCase(e.getActionCommand())) - { - dispose(); - return; - } - // Exit - close(); - } // actionPerformed - - - /** - * - */ - @Override - public void reset() - { - f_processed.setSelected(false); - f_documentno.setText(null); - f_date.setValue(Env.getContextAsDate(Env.getCtx(), "#Date")); - setResults(p_ctx, f_processed.isSelected(), f_documentno.getText(), f_date.getTimestamp()); - } - - - /** - * Set/display Results - * @param results results - */ - public void setResults (Properties ctx, boolean processed, String doc, Timestamp date) - { - String sql = ""; - try - { - sql = "SELECT o.C_Order_ID, o.DocumentNo, o.TotalLines, o.GrandTotal, b.Name, o.Processed" + - " FROM C_Order o INNER JOIN C_BPartner b ON o.C_BPartner_ID=b.C_BPartner_ID" + - " WHERE o.C_POS_ID = " + p_pos.getC_POS_ID(); - sql += " AND o.Processed = " + ( processed ? "'Y' " : "'N' "); - if (doc != null && !doc.equalsIgnoreCase("")) - sql += " AND o.DocumentNo = '" + doc + "'"; - if ( date != null ) - sql += " AND o.DateOrdered = ? Order By o.DocumentNo DESC"; - - PreparedStatement pstm = DB.prepareStatement(sql, null); - if ( date != null ) - pstm.setTimestamp(1, date); - ResultSet rs = pstm.executeQuery(); - m_table.loadTable(rs); - if ( m_table.getRowCount() > 0 ) - m_table.setRowSelectionInterval(0, 0); - enableButtons(); - } - catch(Exception e) - { - log.severe("QueryTicket.setResults: " + e + " -> " + sql); - - } - } // setResults - - /** - * Enable/Set Buttons and set ID - */ - protected void enableButtons() - { - m_c_order_id = -1; - int row = m_table.getSelectedRow(); - boolean enabled = row != -1; - if (enabled) - { - Integer ID = m_table.getSelectedRowKey(); - if (ID != null) - { - m_c_order_id = ID.intValue(); - } - } - - f_ok.setEnabled(enabled); - - if (log.isLoggable(Level.INFO)) log.info("ID=" + m_c_order_id); - } // enableButtons - - /** - * Close. - * Set Values on other panels and close - */ - @Override - protected void close() - { - if (log.isLoggable(Level.INFO)) log.info("C_Order_ID=" + m_c_order_id); - - if (m_c_order_id > 0) - { - p_posPanel.setOrder(m_c_order_id); - p_posPanel.updateInfo(); - - } - dispose(); - } // close - -} // PosQueryProduct diff --git a/org.adempiere.ui.swing/src/org/compiere/pos/SubCheckout.java b/org.adempiere.ui.swing/src/org/compiere/pos/SubCheckout.java deleted file mode 100644 index 137424279c..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/pos/SubCheckout.java +++ /dev/null @@ -1,235 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 Adempiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - *****************************************************************************/ - -package org.compiere.pos; - -import java.awt.Dimension; -import java.awt.GridBagConstraints; -import java.awt.GridBagLayout; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.util.logging.Level; - -import javax.swing.border.TitledBorder; - -import org.compiere.grid.ed.VNumber; -import org.compiere.swing.CButton; -import org.compiere.swing.CLabel; -import org.compiere.swing.CPanel; -import org.compiere.util.CLogger; -import org.compiere.util.DisplayType; -import org.compiere.util.Env; -import org.compiere.util.Msg; - -/** - * Checkout Sub Panel - * - * @author Comunidad de Desarrollo OpenXpertya - * *Basado en Codigo Original Modificado, Revisado y Optimizado de: - * *Copyright ïżœ Jorg Janke - * @version $Id: SubCheckout.java,v 1.1 2004/07/12 04:10:04 jjanke Exp $ - */ -public class SubCheckout extends PosSubPanel implements ActionListener -{ - /** - * - */ - private static final long serialVersionUID = -5088462537034950615L; - - /** - * Constructor - * @param posPanel POS Panel - */ - public SubCheckout (PosBasePanel posPanel) - { - super (posPanel); - } // PosSubCheckout - - private CButton f_summary = null; - - //TODO: credit card -/* private CLabel f_lcreditCardNumber = null; - private CTextField f_creditCardNumber = null; - private CLabel f_lcreditCardExp = null; - private CTextField f_creditCardExp = null; - private CLabel f_lcreditCardVV = null; - private CTextField f_creditCardVV = null; - private CButton f_creditPayment = null; -*/ - private CLabel f_lcashGiven = null; - private VNumber f_cashGiven; - private CLabel f_lcashReturn = null; - private VNumber f_cashReturn; - - private CButton f_cashRegisterFunctions; - /** Logger */ - private static CLogger log = CLogger.getCLogger(SubCheckout.class); - - /** - * Initialize - */ - public void init() - { - // Content - setLayout(new GridBagLayout()); - GridBagConstraints gbc = new GridBagConstraints(); - - // BOX 1 - CASH - gbc.gridx = 0; - gbc.gridheight = 2; - gbc.fill = GridBagConstraints.BOTH; - gbc.weightx = .1; - CPanel cash = new CPanel(new GridBagLayout()); - cash.setBackground(java.awt.Color.lightGray); - cash.setBorder(new TitledBorder(Msg.getMsg(Env.getCtx(), "Checkout"))); - gbc.gridy = 0; - add (cash, gbc); - GridBagConstraints gbc0 = new GridBagConstraints(); -// gbc0.anchor = GridBagConstraints.EAST; - // - f_lcashGiven = new CLabel(Msg.getMsg(Env.getCtx(),"CashGiven")); - cash.add (f_lcashGiven, gbc0); - f_cashGiven = new VNumber("CashGiven", false, false, true, DisplayType.Amount, Msg.translate(Env.getCtx(), "CashGiven")); - f_cashGiven.setColumns(12, 25); - cash.add (f_cashGiven, gbc0); - f_cashGiven.setValue(Env.ZERO); - f_cashGiven.addActionListener(this); //to update the change with the money - // - f_lcashReturn = new CLabel(Msg.getMsg(Env.getCtx(),"CashReturn")); - cash.add (f_lcashReturn, gbc0); - f_cashReturn = new VNumber("CashReturn", false, true, false, DisplayType.Amount, "CashReturn"); - f_cashReturn.setColumns(8, 25); - cash.add (f_cashReturn, gbc0); - f_cashReturn.setValue(Env.ZERO); - - // BOX 2 - UTILS - CPanel utils = new CPanel(new GridBagLayout()); - utils.setBorder(new TitledBorder(Msg.getMsg(Env.getCtx(), "Utils"))); - gbc.gridx = 0; - gbc.gridy = 2; - gbc.weightx = .1; - add (utils, gbc); - GridBagConstraints gbcU = new GridBagConstraints(); - gbcU.anchor = GridBagConstraints.EAST; - //CASH FUNCTIONS - f_cashRegisterFunctions = createButtonAction("CashRegisterFunction", null); - f_cashRegisterFunctions.setText("Cash Functions"); - f_cashRegisterFunctions.setPreferredSize(new Dimension(130,37)); - f_cashRegisterFunctions.setMaximumSize(new Dimension(130,37)); - f_cashRegisterFunctions.setMinimumSize(new Dimension(130,37)); - utils.add(f_cashRegisterFunctions, gbcU); - //SUMMARY - f_summary = createButtonAction("Summary", null); - utils.add (f_summary, gbcU); - - - -//TODO: Credit card -/* Panel para la introducciïżœn de los datos de CreditCard para el pago quitada por ConSerTi al no considerar - * que sea ïżœtil de momento - - // -- 1 -- Creditcard - CPanel creditcard = new CPanel(new GridBagLayout()); - creditcard.setBorder(new TitledBorder(Msg.translate(Env.getCtx(), "CreditCardType"))); - gbc.gridy = 2; - add (creditcard, gbc); - GridBagConstraints gbc1 = new GridBagConstraints(); - gbc1.insets = INSETS2; - gbc1.anchor = GridBagConstraints.WEST; - - gbc1.gridx = 0; - gbc1.gridy = 0; - f_lcreditCardNumber = new CLabel(Msg.translate(Env.getCtx(), "CreditCardNumber")); - creditcard.add (f_lcreditCardNumber, gbc1); - gbc1.gridy = 1; - f_creditCardNumber = new CTextField(18); - creditcard.add (f_creditCardNumber, gbc1); - gbc1.gridx = 1; - gbc1.gridy = 0; - f_lcreditCardExp = new CLabel(Msg.translate(Env.getCtx(),"CreditCardExp")); - creditcard.add (f_lcreditCardExp, gbc1); - gbc1.gridy = 1; - f_creditCardExp = new CTextField(5); - creditcard.add (f_creditCardExp, gbc1); - gbc1.gridx = 2; - gbc1.gridy = 0; - f_lcreditCardVV = new CLabel(Msg.translate(Env.getCtx(), "CreditCardVV")); - creditcard.add (f_lcreditCardVV, gbc1); - gbc1.gridy = 1; - f_creditCardVV = new CTextField(5); - creditcard.add (f_creditCardVV, gbc1); - // - gbc1.gridx = 3; - gbc1.gridy = 0; - gbc1.gridheight = 2; - f_creditPayment = createButtonAction("Payment", null); - f_creditPayment.setActionCommand("CreditCard"); - gbc1.anchor = GridBagConstraints.EAST; - gbc1.weightx = 0.1; - creditcard.add (f_creditPayment, gbc1); - - **/ //fin del comentario para quitar la parte del CreditCard - } // init - - /** - * Dispose - Free Resources - */ - public void dispose() - { - super.dispose(); - } // dispose - - - /** - * Action Listener - * @param e event - */ - public void actionPerformed (ActionEvent e) - { - String action = e.getActionCommand(); - if (action == null || action.length() == 0) - return; - if (log.isLoggable(Level.INFO)) log.info( "PosSubCheckout - actionPerformed: " + action); - - - if (action.equals("Summary")) - { - //displaySummary(); - } - - else if (action.equals("CashRegisterFunction")) - { - CashSubFunctions csf = new CashSubFunctions(p_posPanel); - csf.setVisible(true); - } - else if (e.getSource() == f_cashGiven) - //displayReturn(); - -/* // CreditCard (Payment) - else if (action.equals("CreditCard")) - { - Log.print("CreditCard"); - } fin del comentario para la Credit Card*/ - - p_posPanel.updateInfo(); - } // actionPerformed - - - - - - - - -} // PosSubCheckout diff --git a/org.adempiere.ui.swing/src/org/compiere/pos/SubCurrentLine.java b/org.adempiere.ui.swing/src/org/compiere/pos/SubCurrentLine.java deleted file mode 100644 index 7605ddb62f..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/pos/SubCurrentLine.java +++ /dev/null @@ -1,718 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 Adempiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - *****************************************************************************/ - -package org.compiere.pos; - -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.awt.event.FocusEvent; -import java.awt.event.FocusListener; -import java.awt.event.KeyEvent; -import java.math.BigDecimal; -import java.sql.PreparedStatement; -import java.sql.ResultSet; -import java.util.logging.Level; - -import javax.swing.JTextField; -import javax.swing.KeyStroke; -import javax.swing.event.ListSelectionEvent; -import javax.swing.event.ListSelectionListener; - -import net.miginfocom.swing.MigLayout; - -import org.compiere.apps.ADialog; -import org.compiere.minigrid.ColumnInfo; -import org.compiere.minigrid.IDColumn; -import org.compiere.model.MOrderLine; -import org.compiere.model.MProduct; -import org.compiere.model.MWarehousePrice; -import org.compiere.model.PO; -import org.compiere.swing.CButton; -import org.compiere.swing.CLabel; -import org.compiere.swing.CScrollPane; -import org.compiere.util.CLogger; -import org.compiere.util.DB; -import org.compiere.util.DisplayType; -import org.compiere.util.Env; -import org.compiere.util.Msg; - -/** - * Current Line Sub Panel - * - * @author OpenXpertya - * Based on Modified Original Code, Revised and Optimized - * *Copyright Jorg Janke - * red1 - [2093355 ] Small bugs in OpenXpertya POS - */ -public class SubCurrentLine extends PosSubPanel implements ActionListener, FocusListener, ListSelectionListener { - /** - * - */ - private static final long serialVersionUID = 8348032740580968638L; - - private String trxName; - - /** - * Constructor - * - * @param posPanel POS Panel - */ - public SubCurrentLine(PosBasePanel posPanel) { - super(posPanel); - trxName = posPanel.getTrxName(); - } - - private CButton f_up; - private CButton f_delete; - private CButton f_down; - // - private CButton f_plus; - private CButton f_minus; - private PosTextField f_price; - private PosTextField f_quantity; - protected PosTextField f_name; - private CButton f_bSearch; - private int orderLineId = 0; - - - /** The Product */ - private MProduct m_product = null; - - /** Warehouse */ - private int m_M_Warehouse_ID; - /** PLV */ - private int m_M_PriceList_Version_ID; - - /** Logger */ - private static CLogger log = CLogger.getCLogger(SubCurrentLine.class); - - - /** The Table */ - PosTable m_table; - /** The Query SQL */ - private String m_sql; - /** Logger */ - - /** Table Column Layout Info */ - private static ColumnInfo[] s_layout = new ColumnInfo[] - { - new ColumnInfo(" ", "C_OrderLine_ID", IDColumn.class), - new ColumnInfo(Msg.translate(Env.getCtx(), "Name"), "Name", String.class), - new ColumnInfo(Msg.translate(Env.getCtx(), "Qty"), "QtyOrdered", Double.class), - new ColumnInfo(Msg.translate(Env.getCtx(), "C_UOM_ID"), "UOMSymbol", String.class), - new ColumnInfo(Msg.translate(Env.getCtx(), "PriceActual"), "PriceActual", BigDecimal.class), - new ColumnInfo(Msg.translate(Env.getCtx(), "LineNetAmt"), "LineNetAmt", BigDecimal.class), - new ColumnInfo(Msg.translate(Env.getCtx(), "C_Tax_ID"), "TaxIndicator", String.class), - }; - /** From Clause */ - private static String s_sqlFrom = "C_Order_LineTax_v"; - /** Where Clause */ - private static String s_sqlWhere = "C_Order_ID=? AND LineNetAmt <> 0"; - - /** - * Initialize - */ - public void init() { - - // Content - setLayout(new MigLayout("fill, ins 0 0")); - - String buttonSize = "w 50!, h 50!,"; - // - f_bSearch = createButtonAction ("Product", KeyStroke.getKeyStroke(KeyEvent.VK_I, ActionEvent.CTRL_MASK)); - f_bSearch.setName("ProductSearch"); - add (f_bSearch, buttonSize ); - - CLabel productLabel = new CLabel(Msg.translate(Env.getCtx(), "M_Product_ID")); - add(productLabel, ", flowy, h 15"); - - f_name = new PosTextField(Msg.translate(Env.getCtx(), "M_Product_ID"), p_posPanel, p_pos.getOSK_KeyLayout_ID()); - f_name.setName("ProductInput"); - f_name.addActionListener(this); - f_name.addFocusListener(this); - f_name.requestFocusInWindow(); - - add (f_name, "spanx 3, growx, pushx, h 25!"); - - // PAYMENT - add (new CLabel(),""); - f_cashPayment = createButtonAction("Payment", null); - f_cashPayment.setActionCommand("Payment"); - add (f_cashPayment, "w 75!, h 50!, pushx, wrap"); - f_cashPayment.setEnabled(false); - - m_table = new PosTable(); - CScrollPane scroll = new CScrollPane(m_table); - m_sql = m_table.prepareTable (s_layout, s_sqlFrom, - s_sqlWhere, false, "C_Order_LineTax_v") - + " ORDER BY Line"; - // m_table.addMouseListener(this); - m_table.getSelectionModel().addListSelectionListener(this); - m_table.setColumnVisibility(m_table.getColumn(0), false); - m_table.getColumn(1).setPreferredWidth(175); - m_table.getColumn(2).setPreferredWidth(75); - m_table.getColumn(3).setPreferredWidth(30); - m_table.getColumn(4).setPreferredWidth(75); - m_table.getColumn(5).setPreferredWidth(75); - m_table.getColumn(6).setPreferredWidth(30); - m_table.setFocusable(false); - m_table.setFillsViewportHeight( true ); //@Trifon - m_table.growScrollbars(); - - add (scroll, "growx, spanx, growy, pushy, h 200:300:"); - - f_up = createButtonAction("Previous", KeyStroke.getKeyStroke(KeyEvent.VK_UP, 0)); - add (f_up, buttonSize); - f_down = createButtonAction("Next", KeyStroke.getKeyStroke(KeyEvent.VK_DOWN, 0)); - add (f_down, buttonSize); - - - f_delete = createButtonAction("Cancel", KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, ActionEvent.SHIFT_MASK)); - add (f_delete, buttonSize); - - // - f_minus = createButtonAction("Minus", null); - add(f_minus, buttonSize); - - - - CLabel qtyLabel = new CLabel(Msg.translate(Env.getCtx(), "QtyOrdered")); - add(qtyLabel, "split 2, flowy, h 15"); - - // - f_quantity = new PosTextField(Msg.translate(Env.getCtx(), "QtyOrdered"), - p_posPanel,p_pos.getOSNP_KeyLayout_ID(), DisplayType.getNumberFormat(DisplayType.Quantity)); - f_quantity.setHorizontalAlignment(JTextField.TRAILING); - f_quantity.addActionListener(this); - add(f_quantity, "h 30:30:, w 100"); - setQty(Env.ONE); - // - f_plus = createButtonAction("Plus", null); - add(f_plus, buttonSize); - - - CLabel priceLabel = new CLabel(Msg.translate(Env.getCtx(), "PriceActual")); - add(priceLabel, "split 2, flowy, h 15"); - - // - f_price = new PosTextField(Msg.translate(Env.getCtx(), "PriceActual"), - p_posPanel,p_pos.getOSNP_KeyLayout_ID(), DisplayType.getNumberFormat(DisplayType.Amount)); - f_price.addActionListener(this); - f_price.setHorizontalAlignment(JTextField.TRAILING); - add(f_price, "h 30, w 100, wrap"); - setPrice(Env.ZERO); - - enableButtons(); - } //init - - - /** - * Dispose - Free Resources - */ - public void dispose() { - super.dispose(); - } // dispose - - /** - * Action Listener - * - * @param e event - */ - public void actionPerformed(ActionEvent e) { - String action = e.getActionCommand(); - if (action == null || action.length() == 0) - return; - if (log.isLoggable(Level.INFO)) log.info( "SubCurrentLine - actionPerformed: " + action); - - // Plus - if (action.equals("Plus")) - { - if ( orderLineId > 0 ) - { - MOrderLine line = new MOrderLine(p_ctx, orderLineId, null); - if ( line != null ) - { - line.setQty(line.getQtyOrdered().add(Env.ONE)); - line.saveEx(); - p_posPanel.updateInfo(); - } - } - } - // Minus - else if (action.equals("Minus")) - { - if ( orderLineId > 0 ) - { - MOrderLine line = new MOrderLine(p_ctx, orderLineId, null); - if ( line != null ) - { - line.setQty(line.getQtyOrdered().subtract(Env.ONE)); - line.saveEx(); - p_posPanel.updateInfo(); - } - } - - } - else if (action.equals("Payment")) - payOrder(); - - // VNumber - else if (e.getSource() == f_price) { - MOrderLine line = new MOrderLine(p_ctx, orderLineId, null); - if ( line != null ) - { - line.setQty(new BigDecimal(f_price.getValue().toString())); - line.saveEx(); - p_posPanel.updateInfo(); - } - } - else if (e.getSource() == f_quantity && orderLineId > 0 ) - { - MOrderLine line = new MOrderLine(p_ctx, orderLineId, null); - if ( line != null ) - { - line.setQty(new BigDecimal(f_quantity.getValue().toString())); - line.saveEx(); - p_posPanel.updateInfo(); - } - } - // Product - if (action.equals("Product")) - { - setParameter(); - QueryProduct qt = new QueryProduct(p_posPanel); - qt.setQueryData(m_M_PriceList_Version_ID, m_M_Warehouse_ID); - qt.setVisible(true); - findProduct(); - - int row = m_table.getSelectedRow(); - if (row < 0) row = 0; -// m_table.getSelectionModel().setSelectionInterval(row, row); --red1 - use product window first will gives out of bound error - // https://sourceforge.net/tracker/?func=detail&atid=879332&aid=3121975&group_id=176962 - m_table.scrollRectToVisible(m_table.getCellRect(row, 1, true)); //@Trifon - BF[3121975] - } - // Name - else if (e.getSource() == f_name) - findProduct(); - if ("Previous".equalsIgnoreCase(e.getActionCommand())) - { - int rows = m_table.getRowCount(); - if (rows == 0) - return; - int row = m_table.getSelectedRow(); - row--; - if (row < 0) - row = 0; - m_table.getSelectionModel().setSelectionInterval(row, row); - // https://sourceforge.net/tracker/?func=detail&atid=879332&aid=3121975&group_id=176962 - m_table.scrollRectToVisible(m_table.getCellRect(row, 1, true)); //@Trifon - BF[3121975] - return; - } - else if ("Next".equalsIgnoreCase(e.getActionCommand())) - { - int rows = m_table.getRowCount(); - if (rows == 0) - return; - int row = m_table.getSelectedRow(); - row++; - if (row >= rows) - row = rows - 1; - m_table.getSelectionModel().setSelectionInterval(row, row); - // https://sourceforge.net/tracker/?func=detail&atid=879332&aid=3121975&group_id=176962 - m_table.scrollRectToVisible(m_table.getCellRect(row, 1, true)); //@Trifon - BF[3121975] - return; - } - // Delete - else if (action.equals("Cancel")) - { - int rows = m_table.getRowCount(); - if (rows != 0) - { - int row = m_table.getSelectedRow(); - if (row != -1) - { - if ( p_posPanel.m_order != null ) - p_posPanel.m_order.deleteLine(m_table.getSelectedRowKey()); - setQty(null); - setPrice(null); - - orderLineId = 0; - } - } - } - p_posPanel.updateInfo(); - } // actionPerformed - /** - * - */ - private void payOrder() { - - //Check if order is completed, if so, print and open drawer, create an empty order and set cashGiven to zero - - if( p_posPanel.m_order != null ) //red1 wrong action flow below - { - if (!PosPayment.pay(p_posPanel) ) - return; //red1 not paid (cancelled) cannot continue process the order. - - if (!p_posPanel.m_order.isProcessed() && !p_posPanel.m_order.processOrder() ) - { - ADialog.warn(0, p_posPanel, "PosOrderProcessFailed"); - return; - } - else - { - printTicket(); - p_posPanel.setOrder(0); - } - } - } - - /** - * Update Table - * @param order order - */ - public void updateTable (PosOrderModel order) - { - int C_Order_ID = 0; - if (order != null) - C_Order_ID = order.getC_Order_ID(); - if (C_Order_ID == 0) - { - p_posPanel.f_curLine.m_table.loadTable(new PO[0]); - p_posPanel.f_order.setSums(null); - } - - PreparedStatement pstmt = null; - ResultSet rs = null; - try - { - pstmt = DB.prepareStatement (m_sql, null); - pstmt.setInt (1, C_Order_ID); - rs = pstmt.executeQuery (); - m_table.loadTable(rs); - } - catch (Exception e) - { - log.log(Level.SEVERE, m_sql, e); - } - finally - { - DB.close(rs, pstmt); - rs = null; pstmt = null; - } - - for ( int i = 0; i < m_table.getRowCount(); i ++ ) - { - IDColumn key = (IDColumn) m_table.getModel().getValueAt(i, 0); - if ( key != null && orderLineId > 0 && key.getRecord_ID() == orderLineId ) - { - m_table.getSelectionModel().setSelectionInterval(i, i); - break; - } - } - - enableButtons(); - - p_posPanel.f_order.setSums(order); - - } // updateTable - - private void enableButtons() - { - boolean enabled = true; - if ( m_table == null || m_table.getRowCount() == 0 || m_table.getSelectedRowKey() == null ) - { - enabled = false; - } - f_down.setEnabled(enabled); - f_up.setEnabled(enabled); - f_delete.setEnabled(enabled); - f_minus.setEnabled(enabled); - f_plus.setEnabled(enabled); - f_quantity.setEnabled(enabled); - f_price.setEnabled(enabled); - } - - /** - * Set Query Parameter - */ - private void setParameter() - { - // What PriceList ? - m_M_Warehouse_ID = p_pos.getM_Warehouse_ID(); - m_M_PriceList_Version_ID = p_posPanel.f_order.getM_PriceList_Version_ID(); - } // setParameter - - /** - * Set Price - * - * @param price - */ - public void setPrice(BigDecimal price) { - if (price == null) - price = Env.ZERO; - f_price.setValue(price); - boolean rw = Env.ZERO.compareTo(price) == 0 || p_pos.isModifyPrice(); - f_price.setEditable(rw); - } // setPrice - - /** - * Get Price - * - * @return price - */ - public BigDecimal getPrice() { - return (BigDecimal) f_price.getValue(); - } // getPrice - - /** - * Set Qty - * - * @param qty - */ - public void setQty(BigDecimal qty) { - f_quantity.setValue(qty); - } // setQty - - /** - * Get Qty - * - * @return qty - */ - public BigDecimal getQty() { - return (BigDecimal) f_quantity.getValue(); - } // getQty - - /*************************************************************************** - * New Line - */ - public void newLine() { - setM_Product_ID(0); - setQty(Env.ONE); - setPrice(Env.ZERO); - orderLineId = 0; - f_name.requestFocusInWindow(); - } // newLine - - /** - * Save Line - * - * @return true if saved - */ - public boolean saveLine() { - MProduct product = getProduct(); - if (product == null) - return false; - BigDecimal QtyOrdered = (BigDecimal) f_quantity.getValue(); - BigDecimal PriceActual = (BigDecimal) f_price.getValue(); - - if ( p_posPanel.m_order == null ) - { - p_posPanel.m_order = PosOrderModel.createOrder(p_posPanel.p_pos, p_posPanel.f_order.getBPartner(),trxName); - } - - MOrderLine line = null; - - if ( p_posPanel.m_order != null ) - { - line = p_posPanel.m_order.createLine(product, QtyOrdered, PriceActual); - - if (line == null) - return false; - if (!line.save()) - return false; - } - - orderLineId = line.getC_OrderLine_ID(); - setM_Product_ID(0); - // - return true; - } // saveLine - - - /** - * Get Product - * @return product - */ - public MProduct getProduct() - { - return m_product; - } // getProduct - - /** - * Set Price for defined product - */ - public void setPrice() - { - if (m_product == null) - return; - // - setParameter(); - MWarehousePrice result = MWarehousePrice.get (m_product, - m_M_PriceList_Version_ID, m_M_Warehouse_ID, null); - if (result != null) - p_posPanel.f_curLine.setPrice(result.getPriceStd()); - else - p_posPanel.f_curLine.setPrice(Env.ZERO); - } // setPrice - - - - /************************************************************************** - * Find/Set Product & Price - */ - private void findProduct() - { - String query = f_name.getText(); - if (query == null || query.length() == 0) - return; - query = query.toUpperCase(); - // Test Number - boolean allNumber = true; - try - { - Integer.getInteger(query); - } - catch (Exception e) - { - allNumber = false; - } - String Value = query; - String Name = query; - String UPC = (allNumber ? query : null); - String SKU = (allNumber ? query : null); - - MWarehousePrice[] results = null; - setParameter(); - // - results = MWarehousePrice.find (p_ctx, - m_M_PriceList_Version_ID, m_M_Warehouse_ID, - Value, Name, UPC, SKU, null); - - // Set Result - if (results.length == 0) - { - String message = Msg.translate(p_ctx, "search.product.notfound"); - ADialog.warn(0, p_posPanel, message + query); - setM_Product_ID(0); - p_posPanel.f_curLine.setPrice(Env.ZERO); - } - else if (results.length == 1) - { - setM_Product_ID(results[0].getM_Product_ID()); - setQty(Env.ONE); - f_name.setText(results[0].getName()); - p_posPanel.f_curLine.setPrice(results[0].getPriceStd()); - saveLine(); - } - else // more than one - { - QueryProduct qt = new QueryProduct(p_posPanel); - qt.setResults(results); - qt.setQueryData(m_M_PriceList_Version_ID, m_M_Warehouse_ID); - qt.setVisible(true); - } - } // findProduct - - - /************************************************************************** - * Set Product - * @param M_Product_ID id - */ - public void setM_Product_ID (int M_Product_ID) - { - if (log.isLoggable(Level.FINE)) log.fine( "PosSubProduct.setM_Product_ID=" + M_Product_ID); - if (M_Product_ID <= 0) - m_product = null; - else - { - m_product = MProduct.get(p_ctx, M_Product_ID); - if (m_product.get_ID() == 0) - m_product = null; - } - // Set String Info - if (m_product != null) - { - f_name.setText(m_product.getName()); - f_name.setToolTipText(m_product.getDescription()); - } - else - { - f_name.setText(null); - f_name.setToolTipText(null); - } - } // setM_Product_ID - - /** - * Focus Gained - * @param e - */ - public void focusGained (FocusEvent e) - { - - - } // focusGained - - - /** - * Focus Lost - * @param e - */ - public void focusLost (FocusEvent e) - { - if (e.isTemporary()) - return; - log.info( "PosSubProduct - focusLost"); - findProduct(); - - p_posPanel.updateInfo(); - } // focusLost - - - public void valueChanged(ListSelectionEvent e) { - if ( e.getValueIsAdjusting() ) - return; - - int row = m_table.getSelectedRow(); - if (row != -1 ) - { - Object data = m_table.getModel().getValueAt(row, 0); - if ( data != null ) - { - Integer id = (Integer) ((IDColumn)data).getRecord_ID(); - orderLineId = id; - loadLine(id); - } - } - enableButtons(); - - } - - - private void loadLine(int lineId) { - - if ( lineId <= 0 ) - return; - - if (log.isLoggable(Level.FINE)) log.fine("SubCurrentLine - loading line " + lineId); - MOrderLine ol = new MOrderLine(p_ctx, lineId, null); - if ( ol != null ) - { - setPrice(ol.getPriceActual()); - setQty(ol.getQtyOrdered()); - } - - } - -} // PosSubCurrentLine diff --git a/org.adempiere.ui.swing/src/org/compiere/pos/SubFunctionKeys.java b/org.adempiere.ui.swing/src/org/compiere/pos/SubFunctionKeys.java deleted file mode 100644 index b2f701b7b3..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/pos/SubFunctionKeys.java +++ /dev/null @@ -1,97 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 Adempiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - *****************************************************************************/ - -package org.compiere.pos; - -import net.miginfocom.swing.MigLayout; - -import org.compiere.apps.ADialog; -import org.compiere.model.MPOSKey; -import org.compiere.util.CLogger; - - -/** - * Function Key Sub Panel - * - * @author Comunidad de Desarrollo OpenXpertya - * *Basado en Codigo Original Modificado, Revisado y Optimizado de: - * *Copyright (c) Jorg Janke - * @version $Id: SubFunctionKeys.java,v 1.1 2004/07/12 04:10:04 jjanke Exp $ - */ -public class SubFunctionKeys extends PosSubPanel implements PosKeyListener -{ - /** - * - */ - private static final long serialVersionUID = -1870924843670214389L; - - /** - * Constructor - * @param posPanel POS Panel - */ - public SubFunctionKeys (PosBasePanel posPanel) - { - super (posPanel); - } // PosSubFunctionKeys - - /** Keys */ - //private MPOSKey[] m_keys; - /** Logger */ - @SuppressWarnings("unused") - private static CLogger log = CLogger.getCLogger(SubFunctionKeys.class); - - /** - * Initialize - */ - public void init() - { - int C_POSKeyLayout_ID = p_pos.getC_POSKeyLayout_ID(); - if (C_POSKeyLayout_ID == 0) - return; - - PosKeyPanel panel = new PosKeyPanel(C_POSKeyLayout_ID, this); - this.setLayout(new MigLayout("fill, ins 0")); - add(panel, "growx, growy"); - - } // init - - /** - * Dispose - Free Resources - */ - public void dispose() - { - super.dispose(); - } // dispose - - /** - * Call back from key panel - */ - public void keyReturned(MPOSKey key) { - // processed order - if ( p_posPanel.m_order != null && p_posPanel.m_order.isProcessed() ) - return; - - // new line - p_posPanel.f_curLine.setM_Product_ID(key.getM_Product_ID()); - p_posPanel.f_curLine.setPrice(); - p_posPanel.f_curLine.setQty(key.getQty()); - if ( !p_posPanel.f_curLine.saveLine() ) - { - ADialog.error(0, this, "Could not save order line"); - } - p_posPanel.updateInfo(); - return; - } - -} // PosSubFunctionKeys diff --git a/org.adempiere.ui.swing/src/org/compiere/pos/SubOrder.java b/org.adempiere.ui.swing/src/org/compiere/pos/SubOrder.java deleted file mode 100644 index ea5f194e0a..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/pos/SubOrder.java +++ /dev/null @@ -1,661 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 Adempiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - *****************************************************************************/ - -package org.compiere.pos; - -import java.awt.Color; -import java.awt.Event; -import java.awt.Font; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.awt.event.FocusEvent; -import java.awt.event.FocusListener; -import java.awt.event.KeyEvent; -import java.io.FileOutputStream; -import java.io.IOException; -import java.util.Vector; -import java.util.logging.Level; - -import javax.swing.DefaultComboBoxModel; -import javax.swing.JFormattedTextField; -import javax.swing.JTextField; -import javax.swing.KeyStroke; - -import net.miginfocom.swing.MigLayout; - -import org.adempiere.plaf.AdempierePLAF; -import org.compiere.apps.ADialog; -import org.compiere.model.MBPartner; -import org.compiere.model.MBPartnerInfo; -import org.compiere.model.MBPartnerLocation; -import org.compiere.model.MCurrency; -import org.compiere.model.MOrder; -import org.compiere.model.MPriceList; -import org.compiere.model.MPriceListVersion; -import org.compiere.model.MUser; -import org.compiere.swing.CButton; -import org.compiere.swing.CComboBox; -import org.compiere.swing.CLabel; -import org.compiere.swing.CTextField; -import org.compiere.util.CLogger; -import org.compiere.util.DisplayType; -import org.compiere.util.Env; -import org.compiere.util.KeyNamePair; -import org.compiere.util.Msg; - - -/** - * Customer Sub Panel - * - * @author Comunidad de Desarrollo OpenXpertya - * *Basado en Codigo Original Modificado, Revisado y Optimizado de: - * *Copyright ïżœ Jorg Janke - * @version $Id: SubBPartner.java,v 1.1 2004/07/12 04:10:04 jjanke Exp $ - */ -public class SubOrder extends PosSubPanel - implements ActionListener, FocusListener -{ - /** - * - */ - private static final long serialVersionUID = -2985454173868605178L; - - /** - * Constructor - * @param posPanel POS Panel - */ - public SubOrder (PosBasePanel posPanel) - { - super (posPanel); - } // PosSubCustomer - - private CButton f_history; - private PosTextField f_name; - private CButton f_bNew; - //private CButton f_bSearch; - private CComboBox f_location; - private CComboBox f_user; - private CButton f_process; - private CButton f_print; - private CTextField f_DocumentNo; - private CButton f_logout; - private JFormattedTextField f_net; - private JFormattedTextField f_tax; - private JFormattedTextField f_total; - - /** The Business Partner */ - private MBPartner m_bpartner; - /** Price List Version to use */ - private int m_M_PriceList_Version_ID = 0; - private CTextField f_currency = new CTextField(); - private CButton f_bEdit; - private CButton f_bSettings; - /** Logger */ - private static CLogger log = CLogger.getCLogger(SubOrder.class); - - /** - * Initialize - */ - public void init() - { - // Content - MigLayout layout = new MigLayout("ins 0 0","[fill|fill|fill|fill]","[nogrid]unrel[||]"); - setLayout(layout); - - Font bigFont = AdempierePLAF.getFont_Field().deriveFont(20f); - - String buttonSize = "w 50!, h 50!,"; - // NEW - f_bNew = createButtonAction("New", KeyStroke.getKeyStroke(KeyEvent.VK_F2, Event.F2)); - add (f_bNew, buttonSize); - - // HISTORY - f_history = createButtonAction("History", null); - add (f_history, buttonSize); - - // EDIT - f_bEdit = createButtonAction("Edit", null); - add(f_bEdit, buttonSize); - f_bEdit.setEnabled(false); - - // CANCEL - f_process = createButtonAction("Delete", null); - add (f_process, buttonSize); - f_process.setEnabled(false); - - - //PRINT - f_print = createButtonAction("Print", null); - add (f_print, buttonSize); - f_print.setEnabled(false); - - // Settings - f_bSettings = createButtonAction("Preference", null); - add (f_bSettings, buttonSize); - - // - f_logout = createButtonAction ("Logout", null); - add (f_logout, buttonSize + ", gapx 25, wrap"); - - // SALES REP - add(new CLabel(Msg.translate(Env.getCtx(), "Cashier")), ""); - CLabel cashiername = new CLabel((p_ctx.getProperty("#AD_User_Name")).toUpperCase()); - cashiername.setFont(bigFont); - cashiername.setFontBold(true); - cashiername.setForeground(Color.RED); - add (cashiername, "growx, pushx"); - - CLabel lNet = new CLabel (Msg.translate(Env.getCtx(), "SubTotal")); - add(lNet, ""); - f_net = new JFormattedTextField(DisplayType.getNumberFormat(DisplayType.Amount)); - f_net.setHorizontalAlignment(JTextField.TRAILING); - f_net.setEditable(false); - f_net.setFocusable(false); - lNet.setLabelFor(f_net); - add(f_net, "wrap, growx, pushx"); - f_net.setValue (Env.ZERO); - // - - // BPARTNER -// f_bSearch = createButtonAction ("BPartner", KeyStroke.getKeyStroke(KeyEvent.VK_I, Event.SHIFT_MASK+Event.CTRL_MASK)); -// add (f_bSearch,buttonSize + ", spany 2"); - - // DOC NO - add (new CLabel(Msg.getMsg(Env.getCtx(),"DocumentNo")), ""); - - f_DocumentNo = new CTextField(""); - f_DocumentNo.setName("DocumentNo"); - f_DocumentNo.setEditable(false); - add (f_DocumentNo, "growx, pushx"); - - CLabel lTax = new CLabel (Msg.translate(Env.getCtx(), "TaxAmt")); - add(lTax); - f_tax = new JFormattedTextField(DisplayType.getNumberFormat(DisplayType.Amount)); - f_tax.setHorizontalAlignment(JTextField.TRAILING); - f_tax.setEditable(false); - f_tax.setFocusable(false); - lTax.setLabelFor(f_tax); - add(f_tax, "wrap, growx, pushx"); - f_tax.setValue (Env.ZERO); - // - - /* - f_location = new CComboBox(); - add (f_location, " wrap"); - */ - - // BP - add(new CLabel(Msg.translate(Env.getCtx(), "Customer")), ""); - f_name =new PosTextField(Msg.translate(Env.getCtx(), "C_Partner_ID"), p_posPanel, p_pos.getOSK_KeyLayout_ID()); - f_name.setEditable(true); //red1 - f_name.setName("BPartner"); - f_name.addActionListener(this); - f_name.addFocusListener(this); - add (f_name, " flowy, pushx, h 20!"); - - // - CLabel lTotal = new CLabel (Msg.translate(Env.getCtx(), "TOTAL")); - lTotal.setFont(bigFont); - add(lTotal, ""); - f_total = new JFormattedTextField(DisplayType.getNumberFormat(DisplayType.Amount)); - f_total.setHorizontalAlignment(JTextField.TRAILING);f_total.setFont(bigFont);f_total.setForeground(Color.BLUE); - f_total.setEditable(false); - f_total.setFocusable(false); - f_total.setName("GrandTotal"); - lTotal.setLabelFor(f_total); - add(f_total, "spanx 3, growx, pushx"); - f_total.setValue (Env.ZERO); - /* - // - f_user = new CComboBox(); - add (f_user, "skip 1"); - */ - } // init - - /** - * Dispose - Free Resources - */ - public void dispose() - { - if (f_name != null) - f_name.removeFocusListener(this); - f_name = null; - removeAll(); - super.dispose(); - } // dispose - - - /************************************************************************** - * Action Listener - * @param e event - */ - public void actionPerformed (ActionEvent e) - { - String action = e.getActionCommand(); - if (action == null || action.length() == 0) - return; - if (log.isLoggable(Level.INFO)) log.info( "PosSubCustomer - actionPerformed: " + action); - // New - if (action.equals("New")) - { - p_posPanel.newOrder(); //red1 New POS Order instead - B_Partner already has direct field - return; - } - // Register - if (action.equals("History")) - { - PosQuery qt = new QueryTicket(p_posPanel); - qt.setVisible(true); - return; - } - else if (action.equals("Delete")) //red1 more apt description - { - deleteOrder(); - p_posPanel.m_order = null; - p_posPanel.f_curLine.newLine(); - p_posPanel.f_curLine.f_name.requestFocusInWindow(); - } - else if (action.equals("Preference")) - { - CashSubFunctions csf = new CashSubFunctions(p_posPanel); - csf.setVisible(true); - } - else if (action.equals("Print")) - printOrder(); - else if (action.equals("BPartner")) - { - PosQuery qt = new QueryBPartner(p_posPanel); - qt.setVisible(true); - } - // Logout - else if (action.equals("Logout")) - { - p_posPanel.dispose(); - return; - } - // Name - else if (e.getSource() == f_name) - findBPartner(); - - p_posPanel.updateInfo(); - } // actionPerformed - - /** - * - */ - private void printOrder() { - { - if (isOrderFullyPaid()) - { - updateOrder(); - printTicket(); - openCashDrawer(); - } - } - } - - - - /** - * - */ - private void deleteOrder() { - if ( p_posPanel != null && ADialog.ask(0, this, "Delete order?") ) - p_posPanel.m_order.deleteOrder(); - // p_posPanel.newOrder(); - - } - - /** - * Focus Gained - * @param e - */ - public void focusGained (FocusEvent e) - { - } // focusGained - - /** - * Focus Lost - * @param e - */ - public void focusLost (FocusEvent e) - { - if (e.isTemporary()) - return; - if (log.isLoggable(Level.INFO)) log.info(e.toString()); - findBPartner(); - } // focusLost - - - /** - * Find/Set BPartner - */ - private void findBPartner() - { - - String query = f_name.getText(); - - if (query == null || query.length() == 0) - return; - - // unchanged - if ( m_bpartner != null && m_bpartner.getName().equals(query)) - return; - - query = query.toUpperCase(); - // Test Number - boolean allNumber = true; - boolean noNumber = true; - char[] qq = query.toCharArray(); - for (int i = 0; i < qq.length; i++) - { - if (Character.isDigit(qq[i])) - { - noNumber = false; - break; - } - } - try - { - Integer.parseInt(query); - } - catch (Exception e) - { - allNumber = false; - } - String Value = query; - String Name = (allNumber ? null : query); - String EMail = (query.indexOf('@') != -1 ? query : null); - String Phone = (noNumber ? null : query); - String City = null; - // - //TODO: contact have been remove from rv_bpartner - MBPartnerInfo[] results = MBPartnerInfo.find(p_ctx, Value, Name, - /*Contact, */null, EMail, Phone, City); - - // Set Result - if (results.length == 0) - { - setC_BPartner_ID(0); - } - else if (results.length == 1) - { - setC_BPartner_ID(results[0].getC_BPartner_ID()); - f_name.setText(results[0].getName()); - } - else // more than one - { - QueryBPartner qt = new QueryBPartner(p_posPanel); - qt.setResults (results); - qt.setVisible(true); - } - } // findBPartner - - - /************************************************************************** - * Set BPartner - * @param C_BPartner_ID id - */ - public void setC_BPartner_ID (int C_BPartner_ID) - { - if (log.isLoggable(Level.FINE)) log.fine( "PosSubCustomer.setC_BPartner_ID=" + C_BPartner_ID); - if (C_BPartner_ID == 0) - m_bpartner = null; - else - { - m_bpartner = new MBPartner(p_ctx, C_BPartner_ID, null); - if (m_bpartner.get_ID() == 0) - m_bpartner = null; - } - - // Set Info - if (m_bpartner != null) - { - f_name.setText(m_bpartner.getName()); - } - else - { - f_name.setText(null); - } - // Sets Currency - m_M_PriceList_Version_ID = 0; - getM_PriceList_Version_ID(); - //fillCombos(); - if ( p_posPanel.m_order != null && m_bpartner != null ) - p_posPanel.m_order.setBPartner(m_bpartner); //added by ConSerTi to update the client in the request - } // setC_BPartner_ID - - /** - * Fill Combos (Location, User) - */ - @SuppressWarnings("unused") - private void fillCombos() - { - Vector locationVector = new Vector(); - if (m_bpartner != null) - { - MBPartnerLocation[] locations = m_bpartner.getLocations(false); - for (int i = 0; i < locations.length; i++) - locationVector.add(locations[i].getKeyNamePair()); - } - DefaultComboBoxModel locationModel = new DefaultComboBoxModel(locationVector); - f_location.setModel(locationModel); - // - Vector userVector = new Vector(); - if (m_bpartner != null) - { - MUser[] users = m_bpartner.getContacts(false); - for (int i = 0; i < users.length; i++) - userVector.add(users[i].getKeyNamePair()); - } - DefaultComboBoxModel userModel = new DefaultComboBoxModel(userVector); - f_user.setModel(userModel); - } // fillCombos - - - /** - * Get BPartner - * @return C_BPartner_ID - */ - public int getC_BPartner_ID () - { - if (m_bpartner != null) - return m_bpartner.getC_BPartner_ID(); - return 0; - } // getC_BPartner_ID - - /** - * Get BPartner - * @return BPartner - */ - public MBPartner getBPartner () - { - return m_bpartner; - } // getBPartner - - /** - * Get BPartner Location - * @return C_BPartner_Location_ID - */ - public int getC_BPartner_Location_ID () - { - if (m_bpartner != null) - { - KeyNamePair pp = (KeyNamePair)f_location.getSelectedItem(); - if (pp != null) - return pp.getKey(); - } - return 0; - } // getC_BPartner_Location_ID - - /** - * Get BPartner Contact - * @return AD_User_ID - */ - public int getAD_User_ID () - { - if (m_bpartner != null) - { - KeyNamePair pp = (KeyNamePair)f_user.getSelectedItem(); - if (pp != null) - return pp.getKey(); - } - return 0; - } // getC_BPartner_Location_ID - - /** - * Get M_PriceList_Version_ID. - * Set Currency - * @return plv - */ - public int getM_PriceList_Version_ID() - { - if (m_M_PriceList_Version_ID == 0) - { - int M_PriceList_ID = p_pos.getM_PriceList_ID(); - if (m_bpartner != null && m_bpartner.getM_PriceList_ID() != 0) - M_PriceList_ID = m_bpartner.getM_PriceList_ID(); - // - MPriceList pl = MPriceList.get(p_ctx, M_PriceList_ID, null); - setCurrency(MCurrency.getISO_Code(p_ctx, pl.getC_Currency_ID())); - f_name.setToolTipText(pl.getName()); - // - MPriceListVersion plv = pl.getPriceListVersion (p_posPanel.getToday()); - if (plv != null && plv.getM_PriceList_Version_ID() != 0) - m_M_PriceList_Version_ID = plv.getM_PriceList_Version_ID(); - } - return m_M_PriceList_Version_ID; - } // getM_PriceList_Version_ID - - - /*************************************************************************** - * Set Currency - * - * @param currency - * currency - */ - public void setCurrency(String currency) { - if (currency == null) - f_currency.setText("---"); - else - f_currency.setText(currency); - } // setCurrency - - - /** - * Is order fully pay ? - * Calculates if the given money is sufficient to pay the order - * - * @author Comunidad de Desarrollo OpenXpertya - * *Basado en Codigo Original Modificado, Revisado y Optimizado de: - * *Copyright ïżœ ConSerTi - */ - public boolean isOrderFullyPaid() - { - /*TODO - BigDecimal given = new BigDecimal(f_cashGiven.getValue().toString()); - boolean paid = false; - if (p_posPanel != null && p_posPanel.f_curLine != null) - { - MOrder order = p_posPanel.f_curLine.getOrder(); - BigDecimal total = Env.ZERO; - if (order != null) - total = order.getGrandTotal(); - paid = given.doubleValue() >= total.doubleValue(); - } - return paid; - */ - return true; - } - - /** - * Display cash return - * Display the difference between tender amount and bill amount - * @author Comunidad de Desarrollo OpenXpertya - * *Basado en Codigo Original Modificado, Revisado y Optimizado de: - * *Copyright ïżœ ConSerTi - */ - public void updateOrder() - { - if (p_posPanel != null ) - { - MOrder order = p_posPanel.m_order; - if (order != null) - { - f_DocumentNo.setText(order.getDocumentNo()); - setC_BPartner_ID(order.getC_BPartner_ID()); - f_bNew.setEnabled(order.getLines().length != 0); - f_bEdit.setEnabled(true); - f_process.setEnabled(true); - f_print.setEnabled(order.isProcessed()); - f_cashPayment.setEnabled(order.getLines().length != 0); - } - else - { - f_DocumentNo.setText(null); - setC_BPartner_ID(0); - f_bNew.setEnabled(true); - f_bEdit.setEnabled(false); - f_process.setEnabled(false); - f_print.setEnabled(false); - f_cashPayment.setEnabled(false); - } - - } - } - - /** - * Abrir caja - * Abre la caja registradora - * @author Comunidad de Desarrollo OpenXpertya - * *Basado en Codigo Original Modificado, Revisado y Optimizado de: - * *Copyright ïżœ ConSerTi - */ - public void openCashDrawer() - { - String port = "/dev/lp"; - - byte data[] = new byte[] {0x1B, 0x40, 0x1C}; - try { - FileOutputStream m_out = null; - if (m_out == null) { - m_out = new FileOutputStream(port); // No poner append = true. - } - m_out.write(data); - } catch (IOException e) { - } - } - - /** - * Set Sums from Table - */ - void setSums(PosOrderModel order) - { - int noLines = p_posPanel.f_curLine.m_table.getRowCount(); - if (order == null || noLines == 0) - { - f_net.setValue(Env.ZERO); - f_total.setValue(Env.ZERO); - f_tax.setValue(Env.ZERO); - } - else - { - // order.getMOrder().prepareIt(); - f_net.setValue(order.getSubtotal()); - f_total.setValue(order.getGrandTotal()); - f_tax.setValue(order.getTaxAmt()); - - } - } // setSums -} // PosSubCustomer diff --git a/org.adempiere.ui.swing/src/org/compiere/pos/package.html b/org.adempiere.ui.swing/src/org/compiere/pos/package.html deleted file mode 100644 index b56874f998..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/pos/package.html +++ /dev/null @@ -1,30 +0,0 @@ - - - - - - - -

    Package org.compiere.pos

    - -Point of Sale for PC Terminal - -

    Related Documentation

    - -For overviews, tutorials, examples, guides, and tool documentation, please see: - - - - - - diff --git a/org.adempiere.ui.swing/src/org/compiere/print/AReport.java b/org.adempiere.ui.swing/src/org/compiere/print/AReport.java deleted file mode 100644 index f0b08b58d4..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/print/AReport.java +++ /dev/null @@ -1,241 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ -package org.compiere.print; - -import java.awt.Cursor; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.util.ArrayList; -import java.util.List; -import java.util.logging.Level; -import javax.swing.JComponent; -import javax.swing.JPopupMenu; -import org.adempiere.util.IProcessUI; -import org.compiere.apps.ADialog; -import org.compiere.apps.ClientProcessCtrl; -import org.compiere.apps.ProcessCtl; -import org.compiere.model.MQuery; -import org.compiere.model.MRole; -import org.compiere.model.MTable; -import org.compiere.model.PrintInfo; -import org.compiere.process.ProcessInfo; -import org.compiere.util.CLogger; -import org.compiere.util.Env; -import org.compiere.util.KeyNamePair; - -/** - * Application Report Launcher. - * Called from APanel; Queries available Reports for Table. - * If no report available, a new one is created and launched. - * If there is one report, it is launched. - * If there are more, the available reports are displayed and the selected is launched. - * - * @author Jorg Janke - * @version $Id: AReport.java,v 1.2 2006/07/30 00:51:28 jjanke Exp $ - */ -public class AReport implements ActionListener -{ - /** - * Constructor - * - * @param AD_Table_ID table - * @param invoker component to display popup (optional) - * @param query query - */ - public AReport (int AD_Table_ID, JComponent invoker, MQuery query) - { - this (AD_Table_ID, invoker, query, null, 0); - } - - /** - * Constructor - * - * @param AD_Table_ID table - * @param invoker component to display popup (optional) - * @param query query - * @param parent The invoking parent window - * @param WindowNo The invoking parent window number - */ - public AReport (int AD_Table_ID, JComponent invoker, MQuery query, IProcessUI parent, int WindowNo) - { - if (log.isLoggable(Level.CONFIG)) log.config("AD_Table_ID=" + AD_Table_ID + " " + query); - if (!MRole.getDefault().isCanReport(AD_Table_ID)) - { - ADialog.error(0, invoker, "AccessCannotReport", query.getTableName()); - return; - } - - m_query = query; - this.parent = parent; - this.WindowNo = WindowNo; - - int AD_Window_ID = Env.getContextAsInt(Env.getCtx(), WindowNo, "_WinInfo_AD_Window_ID", true); - if (AD_Window_ID == 0) - AD_Window_ID = Env.getZoomWindowID(query); - - // See What is there - getPrintFormats (AD_Table_ID, AD_Window_ID, invoker); - } // AReport - - /** - * Constructor - * - * @param AD_Table_ID table - * @param invoker component to display popup (optional) - * @param query query - * @param parent The invoking parent window - * @param whereExtended The filtering where clause - * @param WindowNo The invoking parent window number - */ - public AReport (int AD_Table_ID, JComponent invoker, MQuery query, IProcessUI parent, int WindowNo, String whereExtended) - { - if (log.isLoggable(Level.CONFIG)) log.config("AD_Table_ID=" + AD_Table_ID + " " + query); - if (!MRole.getDefault().isCanReport(AD_Table_ID)) - { - ADialog.error(0, invoker, "AccessCannotReport", query.getTableName()); - return; - } - - m_query = query; - if (whereExtended != null && whereExtended.length() > 0 && m_query != null) - m_query.addRestriction(Env.parseContext(Env.getCtx(), WindowNo, whereExtended, false)); - this.parent = parent; - this.WindowNo = WindowNo; - this.m_whereExtended = whereExtended; - - int AD_Window_ID = Env.getContextAsInt(Env.getCtx(), WindowNo, "_WinInfo_AD_Window_ID", true); - if (AD_Window_ID == 0) - AD_Window_ID = Env.getZoomWindowID(query); - - // See What is there - getPrintFormats (AD_Table_ID, AD_Window_ID, invoker); - } // AReport - - /** The Query */ - private MQuery m_query; - /** The Popup */ - private JPopupMenu m_popup = new JPopupMenu("ReportMenu"); - /** The Option List */ - private List m_list = new ArrayList(); - /** Logger */ - private static CLogger log = CLogger.getCLogger(AReport.class); - /** The parent window for locking/unlocking during process execution */ - IProcessUI parent; - /** The filter to apply to this report */ - String m_whereExtended; - /** The parent window number */ - int WindowNo; - - /** - * Get the Print Formats for the table. - * Fill the list and the popup menu - * @param AD_Table_ID table - * @param invoker component to display popup (optional) - */ - private void getPrintFormats (int AD_Table_ID, int AD_Window_ID, JComponent invoker) - { - m_list = MPrintFormat.getAccessiblePrintFormats(AD_Table_ID, AD_Window_ID, null, true); - - if (m_list.size() == 1 || invoker == null) - launchReport ((KeyNamePair)m_list.get(0)); - // Multiple Formats exist - show selection - else if (invoker.isShowing()){ - for (KeyNamePair printFormatInfo : m_list) - m_popup.add(printFormatInfo.toString()).addActionListener(this); - - m_popup.show(invoker, 0, invoker.getHeight()); // below button - } - - } // getPrintFormats - - - /** - * Launch Report - * @param pp Key=AD_PrintFormat_ID - */ - private void launchReport (KeyNamePair pp) - { - MPrintFormat pf = MPrintFormat.get(Env.getCtx(), pp.getKey(), false); - launchReport (pf); - } // launchReport - - /** - * Launch Report - * @param pf print format - */ - private void launchReport (MPrintFormat pf) - { - int Record_ID = 0; - if (m_query.getRestrictionCount()==1 && m_query.getCode(0) instanceof Integer) - Record_ID = ((Integer)m_query.getCode(0)).intValue(); - PrintInfo info = new PrintInfo( - pf.getName(), - pf.getAD_Table_ID(), - Record_ID); - info.setDescription(m_query.getInfo()); - - if(pf != null && pf.getJasperProcess_ID() > 0) - { - // It's a report using the JasperReports engine - ProcessInfo pi = new ProcessInfo ("", pf.getJasperProcess_ID(), pf.getAD_Table_ID(), Record_ID); - - // Execute Process - @SuppressWarnings("unused") - ProcessCtl worker = ClientProcessCtrl.process(parent, WindowNo, pi, null); - } - else - { - // It's a default report using the standard printing engine - ReportEngine re = new ReportEngine (Env.getCtx(), pf, m_query, info); - re.setWhereExtended(m_whereExtended); - re.setWindowNo(WindowNo); - ReportCtl.preview(re); - } - } // launchReport - - /** - * Action Listener - * @param e event - */ - public void actionPerformed(ActionEvent e) - { - m_popup.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); - String cmd = e.getActionCommand(); - for (int i = 0; i < m_list.size(); i++) - { - KeyNamePair pp = (KeyNamePair)m_list.get(i); - if (cmd.equals(pp.getName())) - { - launchReport (pp); - return; - } - } - } // actionPerformed - - - /************************************************************************** - * Get AD_Table_ID for Table Name - * @param tableName table name - * @return AD_Table_ID or 0 - */ - public static int getAD_Table_ID (String tableName) - { - return MTable.getTable_ID(tableName); - } // getAD_Table_ID - -} // AReport - diff --git a/org.adempiere.ui.swing/src/org/compiere/print/CPrinter.java b/org.adempiere.ui.swing/src/org/compiere/print/CPrinter.java deleted file mode 100644 index c1eaf4244d..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/print/CPrinter.java +++ /dev/null @@ -1,118 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ -package org.compiere.print; - -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; - -import javax.print.PrintService; -import javax.print.PrintServiceLookup; -import javax.swing.DefaultComboBoxModel; - -import org.compiere.swing.CComboBox; -import org.compiere.util.CLogger; -import org.compiere.util.Ini; - -/** - * Adempiere Printer Selection - * - * @author Jorg Janke - * @version $Id: CPrinter.java,v 1.3 2006/07/30 00:53:02 jjanke Exp $ - */ -public class CPrinter extends CComboBox implements ActionListener -{ - /** - * - */ - private static final long serialVersionUID = -6366208617152587573L; - - /** Available Printer Services */ - private static PrintService[] s_services = PrintUtil.getAllPrintServices(); - - /** - * Get Print (Services) Names - * @return Printer Name array - */ - public static String[] getPrinterNames() - { - // Refresh print services every time the combobox is constructed - s_services = PrintUtil.getAllPrintServices(); - - String[] retValue = new String[s_services.length]; - for (int i = 0; i < s_services.length; i++) - retValue[i] = s_services[i].getName(); - return retValue; - } // getPrintServiceNames - - - /** Logger */ - @SuppressWarnings("unused") - private static CLogger log = CLogger.getCLogger (CPrinter.class); - - - /************************************************************************** - * Create PrinterJob - */ - public CPrinter() - { - super(getPrinterNames()); - // Set Default - setValue(Ini.getProperty(Ini.P_PRINTER)); - this.addActionListener(this); - } // CPrinter - - /** - * Action Listener - * @param e event - */ - public void actionPerformed (ActionEvent e) - { - - } // actionPerformed - - /** - * Get PrintService - * @return print service - */ - public PrintService getPrintService() - { - String currentService = (String)getSelectedItem(); - for (int i = 0; i < s_services.length; i++) - { - if (s_services[i].getName().equals(currentService)) - return s_services[i]; - } - return PrintServiceLookup.lookupDefaultPrintService(); - } // getPrintService - - /** - * Refresh printer list - */ - public void refresh() { - String current = (String) getSelectedItem(); - removeAllItems(); - setModel(new DefaultComboBoxModel(getPrinterNames())); - if (current != null) { - for (int i = 0; i < getItemCount(); i++) { - String item = (String) getItemAt(i); - if (item.equals(current)) - setSelectedIndex(i); - } - } - } - -} // CPrinter diff --git a/org.adempiere.ui.swing/src/org/compiere/print/SwingViewerProvider.java b/org.adempiere.ui.swing/src/org/compiere/print/SwingViewerProvider.java deleted file mode 100644 index efb50c90b3..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/print/SwingViewerProvider.java +++ /dev/null @@ -1,38 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 2007 Adempiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * - * Copyright (C) 2007 Low Heng Sin hengsin@avantz.com - * _____________________________________________ - *****************************************************************************/ -package org.compiere.print; - -import javax.swing.JFrame; - -import org.compiere.apps.AEnv; -import org.compiere.apps.AMenu; - -/** - * - * @author Low Heng Sin - * - */ -public class SwingViewerProvider implements ReportViewerProvider { - - public void openViewer(ReportEngine re) { - JFrame top = AEnv.getWindow(0); - Viewer viewer = new Viewer(top.getGraphicsConfiguration(), re); - if (top instanceof AMenu) - ((AMenu)top).getWindowManager().add(viewer); - } - -} diff --git a/org.adempiere.ui.swing/src/org/compiere/print/View.java b/org.adempiere.ui.swing/src/org/compiere/print/View.java deleted file mode 100644 index 1650c11a3d..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/print/View.java +++ /dev/null @@ -1,344 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ -package org.compiere.print; - -import java.awt.Color; -import java.awt.Dimension; -import java.awt.Graphics; -import java.awt.Graphics2D; -import java.awt.Point; -import java.awt.Rectangle; -import java.util.HashMap; -import java.util.logging.Level; - -import org.compiere.model.MQuery; -import org.compiere.print.layout.LayoutEngine; -import org.compiere.print.layout.Page; -import org.compiere.swing.CPanel; -import org.compiere.util.CLogger; - -/** - * View Panel - * - * @author Jorg Janke - * @version $Id: View.java,v 1.2 2006/07/30 00:53:02 jjanke Exp $ - * - * @author Teo Sarca, www.arhipac.ro - *
  • FR [ 2539927 ] Display Zoom combobox - * https://sourceforge.net/tracker/?func=detail&atid=879335&aid=2539927&group_id=176962 - */ -public class View extends CPanel -{ - /** - * - */ - private static final long serialVersionUID = 5640892952739279088L; - - /** - * Print Preview - * @param layout Layout - */ - public View (LayoutEngine layout) - { - m_layout = layout; - } // View - - /** Layout to be Printed */ - private LayoutEngine m_layout; - - - /** Zoom Level */ - private int m_zoomLevel = 2; - /** Zoom Options */ - public static final String[] ZOOM_OPTIONS = new String[] {"200%", "150%", "100%", "75%", "50%"}; - private static HashMap ZOOM_ScaleValues = new HashMap(); - static { - ZOOM_ScaleValues.put("200%", 2.00); - ZOOM_ScaleValues.put("150%", 1.50); - ZOOM_ScaleValues.put("100%", 1.00); - ZOOM_ScaleValues.put("75%", 0.75); - ZOOM_ScaleValues.put("50%", 0.50); - } - - /** Margin around paper */ - public static int MARGIN = 5; - /** Margin Background Color */ - private static Color COLOR_BACKGROUND = Color.lightGray; - - /** Logger */ - private static CLogger log = CLogger.getCLogger(View.class); - - /*************************************************************************/ - - public int getMarginSize(boolean doScale) - { - double scale = (doScale ? getScale() : 1.00); - return (int)(MARGIN * scale); - } - - /** - * Minimum Size - * @return Max Page Size - */ - public Dimension getMinimumSize() - { - return getMaximumSize(); - } // getMinimumSize - - /** - * Minimum Size - * @return Max Page Size - */ - public Dimension getMaximumSize() - { - return new Dimension (getPaperWidth()+(2*getMarginSize(true)), - (getPaperHeight()+getMarginSize(true))*getPageCount()+getMarginSize(true)); - } // getMaximumSize - - /** - * Preferred Size - * @return Max Page Size - */ - public Dimension getPreferredSize() - { - return getMaximumSize(); - } // getPreferredSize - - /** - * Is Archivable - * @return true if archivable - */ - public boolean isArchivable() - { - return ArchiveEngine.isValid(m_layout); - } // IsArchivable - - /** - * Paint Component - * @param g Graphics - */ - public void paintComponent (Graphics g) - { - // log.fine( "View.paintComponent", g.getClip()); - Graphics2D g2D = (Graphics2D)g; - g2D.scale(getScale(), getScale()); - Rectangle bounds = g2D.getClipBounds(); - // - g2D.setColor(COLOR_BACKGROUND); - g2D.fillRect(bounds.x, bounds.y, bounds.width, bounds.height); - - // for all pages - for (int page = 0; page < m_layout.getPages().size(); page++) - { - Rectangle pageRectangle = getRectangleOfPage(page+1, false); - if (bounds.intersects(pageRectangle)) - { - Page p = (Page)m_layout.getPages().get(page); - p.paint (g2D, pageRectangle, true, false); // sets context - m_layout.getHeaderFooter().paint(g2D, pageRectangle, true); - } // paint page - } // for all pages - } // paintComponent - - - /************************************************************************** - * Set Zoom Level - * @param level zoom level - */ - public void setZoomLevel(int level) - { - m_zoomLevel = level; - } // setZoomLevel - - /** - * Set Zoom Level - * @param levelString zoom level string - */ - public void setZoomLevel(String levelString) - { - for (int i = 0; i < ZOOM_OPTIONS.length; i++) - { - if (ZOOM_OPTIONS[i].equals(levelString)) - { - setZoomLevel(i); - break; - } - } - } // setZoomLevel - - /** - * Get Zoom Level - * @return zoom level - */ - public int getZoomLevel() - { - return m_zoomLevel; - } // getZoomLevel - - private double getScale() - { - Double scale = ZOOM_ScaleValues.get(ZOOM_OPTIONS[m_zoomLevel]); - if (scale != null) - return scale.doubleValue(); - else - return 1.00; - } - - /** - * Get Rectange of Page - * @param pageNo page no - * @return rectangle - */ - public Rectangle getRectangleOfPage(int pageNo) - { - return getRectangleOfPage(pageNo, true); -// int y = (int)(MARGIN + ((pageNo-1) * (getPaperHeight() + MARGIN))); -// return new Rectangle (MARGIN, y, getPaperWidth(), getPaperHeight()); - } // getRectangleOfPage - - public Rectangle getRectangleOfPage(int pageNo, boolean doScale) - { - int y = (int)(getMarginSize(doScale) + ((pageNo-1) * (getPaperHeight(doScale) + getMarginSize(doScale)))); - return new Rectangle (getMarginSize(doScale), y, getPaperWidth(doScale), getPaperHeight(doScale)); - } // getRectangleOfPage - - /** - * Get Page at Point - * @param p Point - * @return page as float to determine also position on page - */ - public float getPageNoAt (Point p) - { - float y = (float)(p.y / getScale()); - float pageHeight = getPaperHeight(false) + getMarginSize(false); - return 1f + (y/pageHeight); - } // getPageAt - - /** - * Get Page Count - * @return page count - */ - public int getPageCount() - { - return m_layout.getPages().size(); - } // getPageCount - - /** - * Get Page Info for Multi-Page tables - * @param pageNo page - * @return info e.g. (1,1) - */ - public String getPageInfo(int pageNo) - { - return m_layout.getPageInfo(pageNo); - } // getPageInfo - - /** - * Get Max Page Info for Multi-Page tables - * @return info e.g. (3,2) - */ - public String getPageInfoMax() - { - return m_layout.getPageInfoMax(); - } // getPageInfo - - /** - * Get Paper - * @return paper - */ - public CPaper getPaper() - { - return m_layout.getPaper(); - } // getPaper - - /** - * Get Paper Height - * @return paper height - */ - public int getPaperHeight() - { - return getPaperHeight(true); -// return (int)(m_layout.getPaper().getHeight(true) * getScale()); - } // getPaperHeight - - public int getPaperHeight(boolean doScale) - { - double scale = (doScale ? getScale() : 1.0); - return (int)(m_layout.getPaper().getHeight(true) * scale); - } // getPaperHeight - - /** - * Get Paper Height - * @return paper height - */ - public int getPaperWidth() - { - return getPaperWidth(true); -// return (int)(m_layout.getPaper().getWidth(true) * getScale()); - } // getPaperHeight - - public int getPaperWidth(boolean doScale) - { - double scale = (doScale ? getScale() : 1.0); - return (int)(m_layout.getPaper().getWidth(true) * scale); - } // getPaperHeight - - /** - * Get Drill Down - * @param absolutePoint point - * @return Drill Down - */ - public MQuery getDrillDown (Point absolutePoint) - { - int pageNo = (int)getPageNoAt(absolutePoint); - Rectangle pageRectangle = getRectangleOfPage(pageNo, false); - Point relativePoint = new Point ( - (int)(absolutePoint.x/getScale()-pageRectangle.x), - (int)(absolutePoint.y/getScale()-pageRectangle.y) - ); - Page page = (Page)m_layout.getPages().get(pageNo-1); - // - if (log.isLoggable(Level.CONFIG)) log.config("Relative=" + relativePoint + ", " + page); - // log.config("AbsolutePoint=" + absolutePoint + ", PageNo=" + pageNo + ", pageRectangle=" + pageRectangle); - MQuery retValue = page.getDrillDown (relativePoint); - if (retValue == null) - retValue = m_layout.getHeaderFooter().getDrillDown (relativePoint); - return retValue; - } // getDrillDown - - /** - * Get Drill Across - * @param absolutePoint point - * @return Drill Across - */ - public MQuery getDrillAcross (Point absolutePoint) - { - int pageNo = (int)getPageNoAt(absolutePoint); - Rectangle pageRectangle = getRectangleOfPage(pageNo); - Point relativePoint = new Point ( - (int)(absolutePoint.x/getScale()-pageRectangle.x), - (int)(absolutePoint.y/getScale()-pageRectangle.y) - ); - Page page = (Page)m_layout.getPages().get(pageNo-1); - // - if (log.isLoggable(Level.CONFIG)) log.config("Relative=" + relativePoint + ", " + page); - // log.config("AbsolutePoint=" + absolutePoint + ", PageNo=" + pageNo + ", pageRectangle=" + pageRectangle); - return page.getDrillAcross (relativePoint); - } // getDrillAcross - - -} // View diff --git a/org.adempiere.ui.swing/src/org/compiere/print/Viewer.java b/org.adempiere.ui.swing/src/org/compiere/print/Viewer.java deleted file mode 100644 index 75a13a41bb..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/print/Viewer.java +++ /dev/null @@ -1,1393 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - * Contributor: phib [ 1566335 ] Report View scrolling (Bug 1566328) * - * Teo Sarca [ 1619449 ] Minor typo problem * - *****************************************************************************/ -package org.compiere.print; - -import java.awt.BorderLayout; -import java.awt.Component; -import java.awt.Cursor; -import java.awt.Dimension; -import java.awt.GraphicsConfiguration; -import java.awt.Point; -import java.awt.Rectangle; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.awt.event.KeyEvent; -import java.awt.event.MouseAdapter; -import java.awt.event.MouseEvent; -import java.awt.event.WindowEvent; -import java.awt.event.WindowStateListener; -import java.io.File; -import java.io.IOException; -import java.sql.PreparedStatement; -import java.sql.ResultSet; -import java.sql.SQLException; -import java.util.ArrayList; -import java.util.Properties; -import java.util.logging.Level; - -import javax.swing.AbstractAction; -import javax.swing.AbstractButton; -import javax.swing.Icon; -import javax.swing.ImageIcon; -import javax.swing.JComponent; -import javax.swing.JFileChooser; -import javax.swing.JFrame; -import javax.swing.JMenu; -import javax.swing.JMenuBar; -import javax.swing.JOptionPane; -import javax.swing.JPopupMenu; -import javax.swing.JScrollPane; -import javax.swing.JSpinner; -import javax.swing.JToolBar; -import javax.swing.KeyStroke; -import javax.swing.SpinnerNumberModel; -import javax.swing.SwingUtilities; -import javax.swing.event.ChangeEvent; -import javax.swing.event.ChangeListener; - -import org.adempiere.pdf.Document; -import org.compiere.apps.ADialog; -import org.compiere.apps.AEnv; -import org.compiere.apps.AMenu; -import org.compiere.apps.AWindow; -import org.compiere.apps.AWindowListener; -import org.compiere.apps.AppsAction; -import org.compiere.apps.EMailDialog; -import org.compiere.apps.StatusBar; -import org.compiere.apps.WindowMenu; -import org.compiere.apps.search.Find; -import org.compiere.model.GridField; -import org.compiere.model.MArchive; -import org.compiere.model.MClient; -import org.compiere.model.MQuery; -import org.compiere.model.MRole; -import org.compiere.model.MUser; -import org.compiere.model.PrintInfo; -import org.compiere.model.X_C_Invoice; -import org.compiere.swing.CButton; -import org.compiere.swing.CCheckBox; -import org.compiere.swing.CComboBox; -import org.compiere.swing.CFrame; -import org.compiere.swing.CLabel; -import org.compiere.swing.CMenuItem; -import org.compiere.swing.CPanel; -import org.compiere.tools.FileUtil; -import org.compiere.util.CLogMgt; -import org.compiere.util.CLogger; -import org.compiere.util.DB; -import org.compiere.util.Env; -import org.compiere.util.ExtensionFileFilter; -import org.compiere.util.KeyNamePair; -import org.compiere.util.Language; -import org.compiere.util.Login; -import org.compiere.util.Msg; -import org.compiere.util.NamePair; -import org.compiere.util.ValueNamePair; - -/** - * Print View Frame - * - * @author Jorg Janke - * @version $Id: Viewer.java,v 1.2 2006/07/30 00:51:28 jjanke Exp $ - * globalqss: integrate phib contribution from - * http://sourceforge.net/tracker/index.php?func=detail&aid=1566335&group_id=176962&atid=879334 - * globalqss: integrate Teo Sarca bug fixing - * Colin Rooney 2007/03/20 RFE#1670185 & BUG#1684142 - * Extend security to Info queries - * - * @author Teo Sarca, www.arhipac.ro - *
  • FR [ 1762466 ] Add "Window" menu to report viewer. - *
  • FR [ 1779403 ] Report Viewer: add PgUp and PgDown key handlers - *
  • BF [ 1836908 ] Report customize NPE when no window access - *
  • FR [ 1894640 ] Report Engine: Excel Export support - *
  • FR [ 2539927 ] Display Zoom combobox - * https://sourceforge.net/tracker/?func=detail&atid=879335&aid=2539927&group_id=176962 - * @author victor.perez@e-evolution.com - *
  • FR [ 1966328 ] New Window Info to MRP and CRP into View http://sourceforge.net/tracker/index.php?func=detail&aid=1966328&group_id=176962&atid=879335 - *
  • FR [ 2011569 ] Implementing new Summary flag in Report View http://sourceforge.net/tracker/index.php?func=detail&aid=2011569&group_id=176962&atid=879335 - * - */ -public class Viewer extends CFrame - implements ActionListener, ChangeListener, WindowStateListener, IReportEngineEventListener -{ - /** - * - */ - private static final long serialVersionUID = 3766771249690413641L; - - /** - * @deprecated - * Viewer Constructor - * @param re report engine - */ - public Viewer (ReportEngine re) - { - this(null, re); - } - - /** - * Viewer Constructor - * @param gc - * @param re report engine - */ - public Viewer (GraphicsConfiguration gc, ReportEngine re) - { - super(gc); - log.info(""); - m_WindowNo = AEnv.createWindowNo(this); - Env.setContext(re.getCtx(), m_WindowNo, "_WinInfo_IsReportViewer", "Y"); - m_reportEngine = re; - m_AD_Table_ID = re.getPrintFormat().getAD_Table_ID(); - if (!MRole.getDefault().isCanReport(m_AD_Table_ID)) - { - ADialog.error(m_WindowNo, this, "AccessCannotReport", m_reportEngine.getName()); - this.dispose(); - } - m_isCanExport = MRole.getDefault().isCanExport(m_AD_Table_ID); - try - { - m_viewPanel = new View(re.getLayout()); - re.addEventListener(this); - m_ctx = m_reportEngine.getCtx(); - jbInit(); - dynInit(); - if (!m_viewPanel.isArchivable()) - log.warning("Cannot archive Document"); - AEnv.showCenterScreen(this); - } - catch(Exception e) - { - log.log(Level.SEVERE, "", e); - ADialog.error(m_WindowNo, this, "LoadError", e.getLocalizedMessage()); - this.dispose(); - } - } // Viewer - - /** Window No */ - private int m_WindowNo; - /** Print Context */ - private Properties m_ctx; - /** Page No */ - private int m_pageNo = 1; - /** Max Page Number */ - private int m_pageMax = 1; - /** View Pane */ - private View m_viewPanel; - /** Setting Values */ - private boolean m_setting = false; - /** Report Engine */ - private ReportEngine m_reportEngine; - /** Drill Down/Across */ - private boolean m_drillDown = true; - /** Table ID */ - private int m_AD_Table_ID = 0; - private boolean m_isCanExport; - - private MQuery m_ddQ = null; - private MQuery m_daQ = null; - private CMenuItem m_ddM = null; - private CMenuItem m_daM = null; - - /** Logger */ - private static CLogger log = CLogger.getCLogger(Viewer.class); - - // - private CPanel northPanel = new CPanel(); - private JScrollPane centerScrollPane = new JScrollPane(); - private StatusBar statusBar = new StatusBar(false); - private JMenuBar menuBar = new JMenuBar(); - private JToolBar toolBar = new JToolBar(); - private CButton bPrint = new CButton(); - private CButton bSendMail = new CButton(); - private CButton bPageSetup = new CButton(); - private CButton bArchive = new CButton(); - private BorderLayout northLayout = new BorderLayout(); - private CButton bCustomize = new CButton(); - private CButton bEnd = new CButton(); - private CButton bFind = new CButton(); - private CButton bExport = new CButton(); - private CComboBoxcomboReport = new CComboBox(); - private CButton bPrevious = new CButton(); - private CButton bNext = new CButton(); - private SpinnerNumberModel spinnerModel = new SpinnerNumberModel(1,1,100,1); - private JSpinner spinner = new JSpinner(spinnerModel); - private CLabel labelDrill = new CLabel(); - private CComboBoxcomboDrill = new CComboBox(); - //FR 201156 - private CCheckBox summary = new CCheckBox(); - private CComboBoxcomboZoom = new CComboBox(View.ZOOM_OPTIONS); - - - /** - * Static Layout - * @throws Exception - */ - private void jbInit() throws Exception - { - this.setIconImage(Env.getImage("mReport.png")); - this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); - // - northPanel.setLayout(northLayout); - this.getContentPane().add(northPanel, BorderLayout.NORTH); - northPanel.add(toolBar, BorderLayout.EAST); - this.getContentPane().add(centerScrollPane, BorderLayout.CENTER); - centerScrollPane.getViewport().add(m_viewPanel, null); - // pb add: set scrolling with scrollbar buttons to move by 20 pixels - // each press - centerScrollPane.getVerticalScrollBar().setUnitIncrement(20); - centerScrollPane.getHorizontalScrollBar().setUnitIncrement(20); - // end pb - this.getContentPane().add(statusBar, BorderLayout.SOUTH); - - // ToolBar - this.setJMenuBar(menuBar); - // Page Control - toolBar.add(bPrevious); - toolBar.add(spinner); - spinner.setToolTipText(Msg.getMsg(m_ctx, "GoToPage")); - toolBar.add(bNext); - - // Add PgUp and PgDown key handlers - teo_sarca FR [ 1779403 ] - m_viewPanel.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW) - .put(KeyStroke.getKeyStroke(KeyEvent.VK_PAGE_UP, 0), "PAGE_UP"); - m_viewPanel.getActionMap().put("PAGE_UP", new AbstractAction() { - private static final long serialVersionUID = -6439939910196779649L; - public void actionPerformed(ActionEvent e) { - setPage(m_pageNo-1); - } - }); - // - m_viewPanel.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW) - .put(KeyStroke.getKeyStroke(KeyEvent.VK_PAGE_DOWN, 0), "PAGE_DOWN"); - m_viewPanel.getActionMap().put("PAGE_DOWN", new AbstractAction() { - private static final long serialVersionUID = -4468272400181368278L; - public void actionPerformed(ActionEvent e) { - setPage(m_pageNo+1); - } - }); - - // Zoom Level - toolBar.addSeparator(); - toolBar.add(comboZoom, null); - comboZoom.setToolTipText(Msg.getMsg(m_ctx, "Zoom")); - // Drill - toolBar.addSeparator(); - labelDrill.setText(Msg.getMsg(m_ctx, "Drill") + ": "); - toolBar.add(labelDrill); - toolBar.add(comboDrill); - comboDrill.setToolTipText(Msg.getMsg(m_ctx, "Drill")); - // Format, Customize, Find - toolBar.addSeparator(); - toolBar.add(comboReport); - comboReport.setToolTipText(Msg.translate(m_ctx, "AD_PrintFormat_ID")); - //FR 201156 - toolBar.add(summary); - summary.setText(Msg.getMsg(m_ctx, "Summary")); - toolBar.add(bCustomize); - bCustomize.setToolTipText(Msg.getMsg(m_ctx, "PrintCustomize")); - toolBar.add(bFind); - bFind.setToolTipText(Msg.getMsg(m_ctx, "Find")); - toolBar.addSeparator(); - // Print/Export - toolBar.add(bPrint); - toolBar.addSeparator(); - toolBar.add(bPageSetup); - bPageSetup.setToolTipText(Msg.getMsg(m_ctx, "PageSetup")); - toolBar.add(bSendMail); - toolBar.add(bArchive); - if (m_isCanExport) - { - bExport.setToolTipText(Msg.getMsg(m_ctx, "Export")); - toolBar.add(bExport); - } - // End - toolBar.addSeparator(); - toolBar.add(bEnd, null); - bEnd.setToolTipText(Msg.getMsg(m_ctx, "End")); - } // jbInit - - /** - * Dynamic Init - */ - private void dynInit() - { - createMenu(); - comboZoom.setSelectedIndex(m_viewPanel.getZoomLevel()); - comboZoom.addActionListener(this); - // Change Listener to set Page no - //pb comment this out so that scrolling works normally - //centerScrollPane.getViewport().addChangeListener(this); - // end pb - //FR 201156 - summary.addActionListener(this); - // Max Page - m_pageMax = m_viewPanel.getPageCount(); - spinnerModel.setMaximum(Integer.valueOf(m_pageMax)); - spinner.addChangeListener(this); - - fillComboReport(m_reportEngine.getPrintFormat().get_ID()); - - // View Panel Mouse Listener - m_viewPanel.addMouseListener(new MouseAdapter() - { - public void mouseClicked(MouseEvent e) - { - if (SwingUtilities.isRightMouseButton(e)) - mouse_clicked(e,true); - else if (e.getClickCount() > 1) - mouse_clicked(e,false); - } - }); - - // fill Drill Options (Name, TableName) - comboDrill.addItem(new ValueNamePair (null,"")); - String sql = "SELECT t.AD_Table_ID, t.TableName, e.PrintName, NULLIF(e.PO_PrintName,e.PrintName) " - + "FROM AD_Column c " - + " INNER JOIN AD_Column used ON (c.ColumnName=used.ColumnName)" - + " INNER JOIN AD_Table t ON (used.AD_Table_ID=t.AD_Table_ID AND t.IsView='N' AND t.AD_Table_ID <> c.AD_Table_ID)" - + " INNER JOIN AD_Column cKey ON (t.AD_Table_ID=cKey.AD_Table_ID AND cKey.IsKey='Y')" - + " INNER JOIN AD_Element e ON (cKey.ColumnName=e.ColumnName) " - + "WHERE c.AD_Table_ID=? AND c.IsKey='Y' " - + "ORDER BY 3"; - boolean trl = !Env.isBaseLanguage(Env.getCtx(), "AD_Element"); - if (trl) - sql = "SELECT t.AD_Table_ID, t.TableName, et.PrintName, NULLIF(et.PO_PrintName,et.PrintName) " - + "FROM AD_Column c" - + " INNER JOIN AD_Column used ON (c.ColumnName=used.ColumnName)" - + " INNER JOIN AD_Table t ON (used.AD_Table_ID=t.AD_Table_ID AND t.IsView='N' AND t.AD_Table_ID <> c.AD_Table_ID)" - + " INNER JOIN AD_Column cKey ON (t.AD_Table_ID=cKey.AD_Table_ID AND cKey.IsKey='Y')" - + " INNER JOIN AD_Element e ON (cKey.ColumnName=e.ColumnName)" - + " INNER JOIN AD_Element_Trl et ON (e.AD_Element_ID=et.AD_Element_ID) " - + "WHERE c.AD_Table_ID=? AND c.IsKey='Y'" - + " AND et.AD_Language=? " - + "ORDER BY 3"; - PreparedStatement pstmt = null; - ResultSet rs = null; - try - { - pstmt = DB.prepareStatement(sql, null); - pstmt.setInt(1, m_reportEngine.getPrintFormat().getAD_Table_ID()); - if (trl) - pstmt.setString(2, Env.getAD_Language(Env.getCtx())); - rs = pstmt.executeQuery(); - while (rs.next()) - { - String tableName = rs.getString(2); - String name = rs.getString(3); - String poName = rs.getString(4); - if (poName != null) - name += "/" + poName; - comboDrill.addItem(new ValueNamePair (tableName, name)); - } - } - catch (SQLException e) - { - log.log(Level.SEVERE, sql, e); - } - finally - { - DB.close(rs, pstmt); - rs = null; - pstmt = null; - } - if (comboDrill.getItemCount() == 1) - { - labelDrill.setVisible(false); - comboDrill.setVisible(false); - } - else - comboDrill.addActionListener(this); - - revalidate(); - } // dynInit - - /** - * Fill ComboBox comboReport (report options) - * @param AD_PrintFormat_ID item to be selected - */ - private void fillComboReport(int AD_PrintFormat_ID) - { - comboReport.removeActionListener(this); - comboReport.removeAllItems(); - KeyNamePair selectValue = null; - - int AD_Window_ID = Env.getContextAsInt(Env.getCtx(), m_reportEngine.getWindowNo(), "_WinInfo_AD_Window_ID", true); - if (AD_Window_ID == 0) - AD_Window_ID = Env.getZoomWindowID(m_reportEngine.getQuery()); - // fill Report Options - String sql = MRole.getDefault().addAccessSQL( - "SELECT AD_PrintFormat_ID, Name, Description " - + "FROM AD_PrintFormat " - + "WHERE AD_Table_ID=? " - //Added Lines by Armen - + "AND IsActive='Y' " - //End of Added Lines - + (AD_Window_ID > 0 ? "AND (AD_Window_ID=? OR AD_Window_ID IS NULL) " : "") - + "ORDER BY Name", - "AD_PrintFormat", MRole.SQL_NOTQUALIFIED, MRole.SQL_RO); - int AD_Table_ID = m_reportEngine.getPrintFormat().getAD_Table_ID(); - PreparedStatement pstmt = null; - ResultSet rs = null; - try - { - pstmt = DB.prepareStatement(sql, null); - pstmt.setInt(1, AD_Table_ID); - if (AD_Window_ID > 0) - pstmt.setInt(2, AD_Window_ID); - rs = pstmt.executeQuery(); - while (rs.next()) - { - KeyNamePair pp = new KeyNamePair(rs.getInt(1), rs.getString(2)); - comboReport.addItem(pp); - if (rs.getInt(1) == AD_PrintFormat_ID) - selectValue = pp; - } - } - catch (SQLException e) - { - log.log(Level.SEVERE, sql, e); - } - finally - { - DB.close(rs, pstmt); - rs = null; - pstmt = null; - } - // IDEMPIERE-297 - Check for Table Access and Window Access for New Report - int pfAD_Window_ID = MPrintFormat.getZoomWindowID(AD_PrintFormat_ID); - if ( MRole.getDefault().isTableAccess(MPrintFormat.Table_ID, false) - && (Boolean.TRUE.equals(MRole.getDefault().getWindowAccess(pfAD_Window_ID)))) - { - StringBuffer sb = new StringBuffer("** ").append(Msg.getMsg(m_ctx, "NewReport")).append(" **"); - KeyNamePair pp = new KeyNamePair(-1, sb.toString()); - comboReport.addItem(pp); - } - if (selectValue != null) - comboReport.setSelectedItem(selectValue); - comboReport.addActionListener(this); - } // fillComboReport - - /** - * Revalidate settings after change of environment - */ - public void revalidate() - { - m_pageMax = m_viewPanel.getPageCount(); - spinnerModel.setMaximum(Integer.valueOf(m_pageMax)); - - // scroll area (page size dependent) - centerScrollPane.setPreferredSize(new Dimension - (m_viewPanel.getPaperWidth()+30, m_viewPanel.getPaperHeight()+15)); - centerScrollPane.getViewport().setViewSize(new Dimension - (m_viewPanel.getPaperWidth()+2*m_viewPanel.getMarginSize(true), - m_viewPanel.getPaperHeight()+2*m_viewPanel.getMarginSize(true))); - - // Report Info - setTitle(Msg.getMsg(m_ctx, "Report") + ": " + m_reportEngine.getName() + " " + Env.getHeader(m_ctx, 0)); - StringBuilder sb = new StringBuilder (); - sb.append(m_viewPanel.getPaper().toString(m_ctx)) - .append(" - ").append(Msg.getMsg(m_ctx, "DataCols")).append("=") - .append(m_reportEngine.getColumnCount()) - .append(", ").append(Msg.getMsg(m_ctx, "DataRows")).append("=") - .append(m_reportEngine.getRowCount()); - statusBar.setStatusLine(sb.toString()); - // - setPage(m_pageNo); - } // revalidate - - - /** - * Create Menu - */ - private void createMenu() - { - // File - JMenu mFile = AEnv.getMenu("File"); - menuBar.add(mFile); - AEnv.addMenuItem("PrintScreen", null, KeyStroke.getKeyStroke(KeyEvent.VK_PRINTSCREEN, 0), mFile, this); - AEnv.addMenuItem("ScreenShot", null, KeyStroke.getKeyStroke(KeyEvent.VK_PRINTSCREEN, ActionEvent.SHIFT_MASK), mFile, this); - AEnv.addMenuItem("Report", null, KeyStroke.getKeyStroke(KeyEvent.VK_P, ActionEvent.ALT_MASK), mFile, this); - mFile.addSeparator(); - AEnv.addMenuItem("PrintCustomize", "Preference", null, mFile, this); - AEnv.addMenuItem("Translate", null, null, mFile, this); - AEnv.addMenuItem("Find", null, KeyStroke.getKeyStroke(KeyEvent.VK_F, ActionEvent.CTRL_MASK), mFile, this); - mFile.addSeparator(); - AEnv.addMenuItem("PageSetup", null, null, mFile, this); - AEnv.addMenuItem("Print", null, KeyStroke.getKeyStroke(KeyEvent.VK_P, ActionEvent.CTRL_MASK), mFile, this); - if (m_isCanExport) - AEnv.addMenuItem("Export", null, null, mFile, this); - mFile.addSeparator(); - AEnv.addMenuItem("End", null, KeyStroke.getKeyStroke(KeyEvent.VK_X, ActionEvent.ALT_MASK), mFile, this); - AEnv.addMenuItem("Logout", null, KeyStroke.getKeyStroke(KeyEvent.VK_L, ActionEvent.SHIFT_MASK+ActionEvent.ALT_MASK), mFile, this); - AEnv.addMenuItem("Exit", null, KeyStroke.getKeyStroke(KeyEvent.VK_X, ActionEvent.SHIFT_MASK+ActionEvent.ALT_MASK), mFile, this); - - // View - JMenu mView = AEnv.getMenu("View"); - menuBar.add(mView); - - if (MRole.getDefault().isAllow_Info_Product()) - { - AEnv.addMenuItem("InfoProduct", null, KeyStroke.getKeyStroke(KeyEvent.VK_I, ActionEvent.ALT_MASK), mView, this); - } - if (MRole.getDefault().isAllow_Info_BPartner()) - { - AEnv.addMenuItem("InfoBPartner", null, KeyStroke.getKeyStroke(KeyEvent.VK_I, ActionEvent.ALT_MASK+ActionEvent.CTRL_MASK), mView, this); - } - if (MRole.getDefault().isShowAcct() && MRole.getDefault().isAllow_Info_Account()) - { - AEnv.addMenuItem("InfoAccount", null, KeyStroke.getKeyStroke(KeyEvent.VK_I, ActionEvent.ALT_MASK+ActionEvent.CTRL_MASK), mView, this); - } - if (MRole.getDefault().isAllow_Info_Schedule()) - { - AEnv.addMenuItem("InfoSchedule", null, null, mView, this); - } - //FR [ 1966328 ] -// if (MRole.getDefault().isAllow_Info_MRP()) -// { -// AEnv.addMenuItem("InfoMRP", "Info", null, mView, this); -// } -// if (MRole.getDefault().isAllow_Info_CRP()) -// { -// AEnv.addMenuItem("InfoCRP", "Info", null, mView, this); -// } - mView.addSeparator(); - if (MRole.getDefault().isAllow_Info_Order()) - { - AEnv.addMenuItem("InfoOrder", "Info", null, mView, this); - } - if (MRole.getDefault().isAllow_Info_Invoice()) - { - AEnv.addMenuItem("InfoInvoice", "Info", null, mView, this); - } - if (MRole.getDefault().isAllow_Info_InOut()) - { - AEnv.addMenuItem("InfoInOut", "Info", null, mView, this); - } - if (MRole.getDefault().isAllow_Info_Payment()) - { - AEnv.addMenuItem("InfoPayment", "Info", null, mView, this); - } -// if (MRole.getDefault().isAllow_Info_CashJournal()) -// { -// AEnv.addMenuItem("InfoCashLine", "Info", null, mView, this); -// } - if (MRole.getDefault().isAllow_Info_Resource()) - { - AEnv.addMenuItem("InfoAssignment", "Info", null, mView, this); - } - if (MRole.getDefault().isAllow_Info_Asset()) - { - AEnv.addMenuItem("InfoAsset", "Info", null, mView, this); - } - - - // Go - JMenu mGo = AEnv.getMenu("Go"); - menuBar.add(mGo); - AEnv.addMenuItem("First", "First", KeyStroke.getKeyStroke(KeyEvent.VK_PAGE_UP, ActionEvent.ALT_MASK), mGo, this); - AEnv.addMenuItem("PreviousPage", "Previous", KeyStroke.getKeyStroke(KeyEvent.VK_UP, ActionEvent.ALT_MASK), mGo, this); - AEnv.addMenuItem("NextPage", "Next", KeyStroke.getKeyStroke(KeyEvent.VK_DOWN, ActionEvent.ALT_MASK), mGo, this); - AEnv.addMenuItem("Last", "Last", KeyStroke.getKeyStroke(KeyEvent.VK_PAGE_DOWN, ActionEvent.ALT_MASK), mGo, this); - - // Tools - JMenu mTools = AEnv.getMenu("Tools"); - menuBar.add(mTools); - AEnv.addMenuItem("Calculator", null, null, mTools, this); - AEnv.addMenuItem("Calendar", null, null, mTools, this); - MUser user = MUser.get(Env.getCtx()); - if (user.isAdministrator()) - AEnv.addMenuItem("Editor", null, null, mTools, this); - AEnv.addMenuItem("Script", null, null, mTools, this); - mTools.addSeparator(); - AEnv.addMenuItem("Preference", null, null, mTools, this); - - // Window - AMenu aMenu = (AMenu)AEnv.getWindow(0); - JMenu mWindow = new WindowMenu(aMenu.getWindowManager(), this); - menuBar.add(mWindow); - - // Help - JMenu mHelp = AEnv.getMenu("Help"); - menuBar.add(mHelp); - AEnv.addMenuItem("Online", null, null, mHelp, this); - AEnv.addMenuItem("SendMail", null, null, mHelp, this); - AEnv.addMenuItem("About", null, null, mHelp, this); - - // ---- ToolBar ---- - // - setButton(bPrint, "Print", "Print"); - setButton(bSendMail, "SendMail", "SendMail"); - setButton(bPageSetup, "PageSetup", "PageSetup"); - setButton(bArchive, "Archive", "Archive"); - if (m_isCanExport) - setButton(bExport, "Export", "Export"); - // - setButton(bNext, "NextPage", "Next"); - setButton(bPrevious, "PreviousPage", "Previous"); - // - setButton(bFind, "Find", "Find"); - setButton(bCustomize, "PrintCustomize", "Preference"); - // - setButton(bEnd, "End", "End"); - } // createMenu - - /** - * Set Button - * @param button button - * @param cmd command - * @param file fine mame - */ - private void setButton (AbstractButton button, String cmd, String file) - { - String text = Msg.getMsg(m_ctx, cmd); - button.setToolTipText(text); - button.setActionCommand(cmd); - // - ImageIcon ii24 = Env.getImageIcon(file+"24.gif"); - if (ii24 != null) - button.setIcon(ii24); - button.setMargin(AppsAction.BUTTON_INSETS); - button.setPreferredSize(AppsAction.BUTTON_SIZE); - button.addActionListener(this); - } // setButton - - /** - * Dispose - */ - public void dispose() - { - Env.clearWinContext(m_WindowNo); - m_reportEngine = null; - m_viewPanel = null; - m_ctx = null; - super.dispose(); - } // dispose - - - /************************************************************************** - * Action Listener - * @param e event - */ - public void actionPerformed (ActionEvent e) - { - if (m_setting) - return; - String cmd = e.getActionCommand(); - log.config(cmd); - this.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); - // - if (e.getSource() == comboZoom) - cmd_zoom(); - else if (e.getSource() == comboReport) - cmd_report(); - else if (e.getSource() == comboDrill) - cmd_drill(); - else if (e.getSource() == summary) //FR 201156 - { - m_reportEngine.setSummary(summary.isSelected()); - cmd_report(); - } - else if (cmd.equals("First")) - setPage(1); - else if (cmd.equals("PreviousPage") || cmd.equals("Previous")) - setPage(m_pageNo-1); - else if (cmd.equals("NextPage") || cmd.equals("Next")) - setPage(m_pageNo+1); - else if (cmd.equals("Last")) - setPage(m_pageMax); - else if (cmd.equals("Find")) - cmd_find(); - else if (cmd.equals("Export")) - cmd_export(); - else if (cmd.equals("Print")) - cmd_print(); - else if (cmd.equals("SendMail")) - cmd_sendMail(); - else if (cmd.equals("Archive")) - cmd_archive(); - else if (cmd.equals("PrintCustomize")) - cmd_customize(); - else if (cmd.equals("PageSetup")) - cmd_pageSetup(); - else if (cmd.equals("Translate")) - cmd_translate(); - else if (cmd.equals("End")) - dispose(); - // - else if (e.getSource() == m_ddM) - cmd_window(m_ddQ); - else if (e.getSource() == m_daM) - cmd_window(m_daQ); - // - else if (!AEnv.actionPerformed(e.getActionCommand(), m_WindowNo, this)) - log.log(Level.SEVERE, "unknown action=" + e.getActionCommand()); - // - this.setCursor(Cursor.getDefaultCursor()); - } // actionPerformed - - /** - * Change Listener (spinner, viewpoint) - * @param e event - */ - public void stateChanged (ChangeEvent e) - { - if (m_setting) - return; - // log.config( "Viewer.stateChanged", e); - m_setting = true; - int newPage = 0; - if (e.getSource() == spinner) - { - newPage = ((Integer)spinnerModel.getValue()).intValue(); - } - // pb with the viewport change listener disabled the following is - // superfluous and should be removed - else // Viewpoint - { - Point p = centerScrollPane.getViewport().getViewPosition(); - newPage = Math.round(m_viewPanel.getPageNoAt(p)); - } - setPage(newPage); - m_setting = false; - } // stateChanged - - - /** - * Set Page No - * @param page page no - */ - private void setPage (int page) - { - m_setting = true; - m_pageNo = page; - if (m_pageNo < 1) - m_pageNo = 1; - if (page > m_pageMax) - m_pageNo = m_pageMax; - bPrevious.setEnabled (m_pageNo != 1); - bNext.setEnabled (m_pageNo != m_pageMax); - // - Rectangle pageRectangle = m_viewPanel.getRectangleOfPage(m_pageNo); - pageRectangle.x -= m_viewPanel.getMarginSize(true); - pageRectangle.y -= m_viewPanel.getMarginSize(true); - centerScrollPane.getViewport().setViewPosition(pageRectangle.getLocation()); - // System.out.println("scrollTo " + pageRectangle); - - // Set Page - spinnerModel.setValue(Integer.valueOf(m_pageNo)); - StringBuffer sb = new StringBuffer (Msg.getMsg(m_ctx, "Page")) - .append(" ").append(m_pageNo) - .append(m_viewPanel.getPageInfo(m_pageNo)) - .append(" ").append(Msg.getMsg(m_ctx, "of")).append(" ") - .append(m_pageMax) - .append(m_viewPanel.getPageInfoMax()); - statusBar.setStatusDB(sb.toString()); - m_setting = false; - } // setPage - - - /************************************************************************** - * (Re)Set Drill Accross Cursor - */ - private void cmd_drill() - { - m_drillDown = comboDrill.getSelectedIndex() < 1; // -1 or 0 - if (m_drillDown) - setCursor(Cursor.getDefaultCursor()); - else - setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); - } // cmd_drill - - /** - * Mouse clicked - * @param e event - * @param rightClick true if right click - */ - private void mouse_clicked (MouseEvent e, boolean rightClick) - { - Point point = e.getPoint(); - if (log.isLoggable(Level.INFO)) log.info("Right=" + rightClick + " - " + point.toString()); - if (rightClick) - { - m_ddQ = m_viewPanel.getDrillDown(point); - m_daQ = m_viewPanel.getDrillAcross(point); - m_ddM = null; - m_daM = null; - if (m_ddQ == null && m_daQ == null) - return; - // Create Menu - JPopupMenu pop = new JPopupMenu(); - Icon wi = Env.getImageIcon("mWindow.png"); - if (m_ddQ != null) - { - m_ddM = new CMenuItem(m_ddQ.getDisplayName(Env.getCtx()), wi); - m_ddM.setToolTipText(m_ddQ.toString()); - m_ddM.addActionListener(this); - pop.add(m_ddM); - } - if (m_daQ != null) - { - m_daM = new CMenuItem(m_daQ.getDisplayName(Env.getCtx()), wi); - m_daM.setToolTipText(m_daQ.toString()); - m_daM.addActionListener(this); - pop.add(m_daM); - } - Point pp = e.getPoint(); - pop.show((Component)e.getSource(), pp.x, pp.y); - return; - } - - setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); - if (m_drillDown) - { - MQuery query = m_viewPanel.getDrillDown(point); - if (query != null) - { - if (log.isLoggable(Level.INFO)) log.info("Drill Down: " + query.getWhereClause(true)); - executeDrill(query); - } - } - else if (comboDrill.getSelectedItem() != null && comboDrill.getSelectedIndex() > 0) - { - MQuery query = m_viewPanel.getDrillAcross(point); - if (query != null) - { - NamePair pp = (NamePair)comboDrill.getSelectedItem(); - query.setTableName(pp.getID()); - if (log.isLoggable(Level.INFO)) log.info("Drill Accross: " + query.getWhereClause(true)); - executeDrill(query); - } - } - cmd_drill(); // setCursor - } // mouse_clicked - - /** - * Execute Drill to Query - * @param query query - */ - private void executeDrill (MQuery query) - { - int AD_Table_ID = AReport.getAD_Table_ID(query.getTableName()); - if (!MRole.getDefault().isCanReport(AD_Table_ID)) - { - ADialog.error(m_WindowNo, this, "AccessCannotReport", query.getTableName()); - return; - } - if (AD_Table_ID != 0) - new AReport (AD_Table_ID, null, query); - else - log.warning("No Table found for " + query.getWhereClause(true)); - } // executeDrill - - /** - * Open Window - * @param query query - */ - private void cmd_window (MQuery query) - { - if (query == null) - return; - AEnv.zoom(query); - } // cmd_window - - /************************************************************************** - * Print Report - */ - private void cmd_print() - { - setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); - m_reportEngine.getPrintInfo().setWithDialog(true); - m_reportEngine.print(); - cmd_drill(); // setCursor - } // cmd_print - - /** - * Send Mail - */ - private void cmd_sendMail() - { - String to = ""; - MUser from = MUser.get(Env.getCtx(), Env.getAD_User_ID(Env.getCtx())); - String subject = m_reportEngine.getName(); - String message = ""; - File attachment = null; - - try - { - attachment = new File(FileUtil.getTempMailName(subject, ".pdf")); - m_reportEngine.getPDF(attachment); - } - catch (Exception e) - { - log.log(Level.SEVERE, "", e); - } - - new EMailDialog (this, - Msg.getMsg(Env.getCtx(), "SendMail"), - from, to, subject, message, attachment); - } // cmd_sendMail - - /** - * Archive Report directly - */ - private void cmd_archive () - { - boolean success = false; - byte[] data = Document.getPDFAsArray(m_reportEngine.getLayout().getPageable(false)); // No Copy - if (data != null) - { - MArchive archive = new MArchive (Env.getCtx(), m_reportEngine.getPrintInfo(), null); - archive.setBinaryData(data); - success = archive.save(); - } - if (success) - ADialog.info(m_WindowNo, this, "Archived"); - else - ADialog.error(m_WindowNo, this, "ArchiveError"); - } // cmd_archive - - /** - * Print Setup Dialog - */ - private void cmd_pageSetup() - { - setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); - m_reportEngine.pageSetupDialog(); - revalidate(); - cmd_drill(); // setCursor - } // cmd_pageSetup - - /** - * Export - */ - private void cmd_export() - { - log.config(""); - if (!m_isCanExport) - { - ADialog.error(m_WindowNo, this, "AccessCannotExport", getTitle()); - return; - } - - // - JFileChooser chooser = new JFileChooser(); - chooser.setDialogType(JFileChooser.SAVE_DIALOG); - chooser.setFileSelectionMode(JFileChooser.FILES_ONLY); - chooser.setDialogTitle(Msg.getMsg(m_ctx, "Export") + ": " + getTitle()); - // - chooser.addChoosableFileFilter(new ExtensionFileFilter("ps", Msg.getMsg(m_ctx, "FilePS"))); - chooser.addChoosableFileFilter(new ExtensionFileFilter("xml", Msg.getMsg(m_ctx, "FileXML"))); - chooser.addChoosableFileFilter(new ExtensionFileFilter("pdf", Msg.getMsg(m_ctx, "FilePDF"))); - chooser.addChoosableFileFilter(new ExtensionFileFilter("html", Msg.getMsg(m_ctx, "FileHTML"))); - chooser.addChoosableFileFilter(new ExtensionFileFilter("txt", Msg.getMsg(m_ctx, "FileTXT"))); - chooser.addChoosableFileFilter(new ExtensionFileFilter("ssv", Msg.getMsg(m_ctx, "FileSSV"))); - chooser.addChoosableFileFilter(new ExtensionFileFilter("csv", Msg.getMsg(m_ctx, "FileCSV"))); - chooser.addChoosableFileFilter(new ExtensionFileFilter("xls", Msg.getMsg(m_ctx, "FileXLS"))); - // - if (chooser.showSaveDialog(this) != JFileChooser.APPROVE_OPTION) - return; - - // Create File - File outFile = ExtensionFileFilter.getFile(chooser.getSelectedFile(), chooser.getFileFilter()); - try - { - outFile.createNewFile(); - } - catch (IOException e) - { - log.log(Level.SEVERE, "", e); - ADialog.error(m_WindowNo, this, "FileCannotCreate", e.getLocalizedMessage()); - return; - } - - String ext = outFile.getPath(); - // no extension - if (ext.lastIndexOf('.') == -1) - { - ADialog.error(m_WindowNo, this, "FileInvalidExtension"); - return; - } - ext = ext.substring(ext.lastIndexOf('.')+1).toLowerCase(); - if (log.isLoggable(Level.CONFIG)) log.config( "File=" + outFile.getPath() + "; Type=" + ext); - - setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); - try { - if (ext.equals("pdf")) - m_reportEngine.createPDF(outFile); - else if (ext.equals("ps")) - m_reportEngine.createPS(outFile); - else if (ext.equals("xml")) - m_reportEngine.createXML(outFile); - else if (ext.equals("csv")) - m_reportEngine.createCSV(outFile, ',', m_reportEngine.getPrintFormat().getLanguage()); - else if (ext.equals("ssv")) - m_reportEngine.createCSV(outFile, ';', m_reportEngine.getPrintFormat().getLanguage()); - else if (ext.equals("txt")) - m_reportEngine.createCSV(outFile, '\t', m_reportEngine.getPrintFormat().getLanguage()); - else if (ext.equals("html") || ext.equals("htm")) - m_reportEngine.createHTML(outFile, false, m_reportEngine.getPrintFormat().getLanguage()); - else if (ext.equals("xls")) - m_reportEngine.createXLS(outFile, m_reportEngine.getPrintFormat().getLanguage()); - else - ADialog.error(m_WindowNo, this, "FileInvalidExtension"); - } - catch (Exception e) { - ADialog.error(m_WindowNo, this, "Error", e.getLocalizedMessage()); - if (CLogMgt.isLevelFinest()) - e.printStackTrace(); - } - cmd_drill(); // setCursor - } // cmd_export - - - /** - * Report Combo - Start other Report or create new one - */ - private void cmd_report() - { - KeyNamePair pp = (KeyNamePair)comboReport.getSelectedItem(); - if (pp == null) - return; - // - setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); - MPrintFormat pf = null; - int AD_PrintFormat_ID = pp.getKey(); - - // create new - if (AD_PrintFormat_ID == -1) - { - int AD_ReportView_ID = m_reportEngine.getPrintFormat().getAD_ReportView_ID(); - if (AD_ReportView_ID != 0) - { - String name = m_reportEngine.getName(); - int index = name.lastIndexOf('_'); - if (index != -1) - name = name.substring(0,index); - pf = MPrintFormat.createFromReportView(m_ctx, AD_ReportView_ID, name); - } - else - { - int AD_Table_ID = m_reportEngine.getPrintFormat().getAD_Table_ID(); - pf = MPrintFormat.createFromTable(m_ctx, AD_Table_ID); - } - if (pf != null) - fillComboReport(pf.get_ID()); - else - return; - } - else - pf = MPrintFormat.get (Env.getCtx(), AD_PrintFormat_ID, true); - - // Get Language from previous - thanks Gunther Hoppe - if (m_reportEngine.getPrintFormat() != null) - { - pf.setLanguage(m_reportEngine.getPrintFormat().getLanguage()); // needs to be re-set - otherwise viewer will be blank - pf.setTranslationLanguage(m_reportEngine.getPrintFormat().getLanguage()); - } - m_reportEngine.setPrintFormat(pf); - revalidate(); - - cmd_drill(); // setCursor - } // cmd_report - - /** - * Query Report - */ - private void cmd_find() - { - setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); - int AD_Table_ID = m_reportEngine.getPrintFormat().getAD_Table_ID(); - - String title = null; - String tableName = null; - - // Get Find Tab Info - String sql = "SELECT t.AD_Tab_ID " - // ,w.Name, t.Name, w.IsDefault, t.SeqNo, ABS (tt.AD_Window_ID-t.AD_Window_ID) - + "FROM AD_Tab t" - + " INNER JOIN AD_Window w ON (t.AD_Window_ID=w.AD_Window_ID)" - + " INNER JOIN AD_Table tt ON (t.AD_Table_ID=tt.AD_Table_ID) " - + "WHERE tt.AD_Table_ID=? " - + "ORDER BY w.IsDefault DESC, t.SeqNo, ABS (tt.AD_Window_ID-t.AD_Window_ID)"; - int AD_Tab_ID = DB.getSQLValue(null, sql, AD_Table_ID); - // ASP - MClient client = MClient.get(Env.getCtx()); - String ASPFilter = ""; - if (client.isUseASP()) - ASPFilter = - " AND ( AD_Tab_ID IN ( " - // Just ASP subscribed tabs for client " - + " SELECT t.AD_Tab_ID " - + " FROM ASP_Tab t, ASP_Window w, ASP_Level l, ASP_ClientLevel cl " - + " WHERE w.ASP_Level_ID = l.ASP_Level_ID " - + " AND cl.AD_Client_ID = " + client.getAD_Client_ID() - + " AND cl.ASP_Level_ID = l.ASP_Level_ID " - + " AND t.ASP_Window_ID = w.ASP_Window_ID " - + " AND t.IsActive = 'Y' " - + " AND w.IsActive = 'Y' " - + " AND l.IsActive = 'Y' " - + " AND cl.IsActive = 'Y' " - + " AND t.ASP_Status = 'S') " // Show - + " OR AD_Tab_ID IN ( " - // + show ASP exceptions for client - + " SELECT AD_Tab_ID " - + " FROM ASP_ClientException ce " - + " WHERE ce.AD_Client_ID = " + client.getAD_Client_ID() - + " AND ce.IsActive = 'Y' " - + " AND ce.AD_Tab_ID IS NOT NULL " - + " AND ce.AD_Field_ID IS NULL " - + " AND ce.ASP_Status = 'S') " // Show - + " ) " - + " AND AD_Tab_ID NOT IN ( " - // minus hide ASP exceptions for client - + " SELECT AD_Tab_ID " - + " FROM ASP_ClientException ce " - + " WHERE ce.AD_Client_ID = " + client.getAD_Client_ID() - + " AND ce.IsActive = 'Y' " - + " AND ce.AD_Tab_ID IS NOT NULL " - + " AND ce.AD_Field_ID IS NULL " - + " AND ce.ASP_Status = 'H')"; // Hide - // - sql = "SELECT Name, TableName FROM AD_Tab_v WHERE AD_Tab_ID=? " + ASPFilter; - if (!Env.isBaseLanguage(Env.getCtx(), "AD_Tab")) - sql = "SELECT Name, TableName FROM AD_Tab_vt WHERE AD_Tab_ID=?" - + " AND AD_Language='" + Env.getAD_Language(Env.getCtx()) + "' " + ASPFilter; - PreparedStatement pstmt = null; - ResultSet rs = null; - try - { - pstmt = DB.prepareStatement(sql, null); - pstmt.setInt(1, AD_Tab_ID); - rs = pstmt.executeQuery(); - // - if (rs.next()) - { - title = rs.getString(1); - tableName = rs.getString(2); - } - // - } - catch (SQLException e) - { - log.log(Level.SEVERE, sql, e); - } - finally - { - DB.close(rs, pstmt); - rs = null; - pstmt = null; - } - - GridField[] findFields = null; - if (tableName != null) - findFields = GridField.createFields(m_ctx, m_WindowNo, 0, AD_Tab_ID); - - if (findFields == null) // No Tab for Table exists - bFind.setEnabled(false); - else - { - Find find = new Find (this, m_reportEngine.getWindowNo(), title, - AD_Tab_ID, AD_Table_ID, tableName, m_reportEngine.getWhereExtended(), findFields, 1); - m_reportEngine.setQuery(find.getQuery()); - find.dispose(); - find = null; - revalidate(); - } - cmd_drill(); // setCursor - } // cmd_find - - /** - * Call Customize - */ - private void cmd_customize() - { - AWindow win = new AWindow (getGraphicsConfiguration()); - new AWindowListener (win, this); // forwards Window Events - int AD_PrintFormat_ID = m_reportEngine.getPrintFormat().get_ID(); - int AD_Window_ID = MPrintFormat.getZoomWindowID(AD_PrintFormat_ID); - boolean loadedOK = win.initWindow(AD_Window_ID, MQuery.getEqualQuery("AD_PrintFormat_ID", AD_PrintFormat_ID)); - if (loadedOK) - { - AEnv.addToWindowManager(win); - AEnv.showCenterScreen(win); - } - // see windowStateChanged for applying change - } // cmd_customize - - /** - * Window State Listener for Customize Window - * @param e event - */ - public void windowStateChanged (WindowEvent e) - { - // The Customize Window was closed - if (e.getID() == WindowEvent.WINDOW_CLOSED && m_reportEngine != null) - { - setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); - log.info("Re-read PrintFormat"); - int AD_PrintFormat_ID = m_reportEngine.getPrintFormat().get_ID(); - Language language = m_reportEngine.getPrintFormat().getLanguage(); - MPrintFormat pf = MPrintFormat.get (Env.getCtx(), AD_PrintFormat_ID, true); - pf.setLanguage (language); // needs to be re-set - otherwise viewer will be blank - pf.setTranslationLanguage (language); - m_reportEngine.setPrintFormat(pf); - revalidate(); - cmd_drill(); // setCursor - } - } // windowStateChanged - - /** - * Set Zoom Level - */ - private void cmd_zoom() - { - setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); - m_viewPanel.setZoomLevel(comboZoom.getSelectedIndex()); - revalidate(); - cmd_drill(); // setCursor - } // cmd_zoom - - - /** - * Show Translation Dialog. - * Translate base table entry, will be copied to trl tables if not multi-lingual - */ - private void cmd_translate() - { - ArrayList list = new ArrayList(); - ValueNamePair pp = null; - String sql = "SELECT Name, AD_Language FROM AD_Language WHERE IsSystemLanguage='Y' ORDER BY 1"; - PreparedStatement pstmt = null; - ResultSet rs = null; - try - { - pstmt = DB.prepareStatement(sql, null); - rs = pstmt.executeQuery(); - while (rs.next()) - list.add(new ValueNamePair (rs.getString(2), rs.getString(1))); - } - catch (SQLException e) - { - log.log(Level.SEVERE, sql, e); - } - finally - { - DB.close(rs, pstmt); - rs = null; - pstmt = null; - } - if (list.size() == 0) - { - ADialog.warn(m_WindowNo, this, "NoTranslation"); - return; - } - - // Dialog - String title = Msg.getMsg(Env.getCtx(), "PrintFormatTrl", true); - String message = Msg.getMsg(Env.getCtx(), "PrintFormatTrl", false); - int choice = JOptionPane.showOptionDialog - (this, message, title, - JOptionPane.OK_OPTION, JOptionPane.QUESTION_MESSAGE, null, - list.toArray(), null); - if (choice == JOptionPane.CLOSED_OPTION) - return; - // - pp = (ValueNamePair)list.get(choice); - String AD_Language = pp.getValue(); - int AD_PrintFormat_ID = m_reportEngine.getPrintFormat().get_ID(); - if (log.isLoggable(Level.CONFIG)) log.config(AD_Language + " - AD_PrintFormat_ID=" + AD_PrintFormat_ID); - StringBuilder sb = new StringBuilder(); - // English - if (Language.isBaseLanguage (AD_Language)) - { - sb.append("UPDATE AD_PrintFormatItem pfi " - + "SET Name = (SELECT e.Name FROM AD_Element e, AD_Column c" - + " WHERE e.AD_Element_ID=c.AD_Element_ID AND c.AD_Column_ID=pfi.AD_Column_ID)," - + "PrintName = (SELECT e.PrintName FROM AD_Element e, AD_Column c" - + " WHERE e.AD_Element_ID=c.AD_Element_ID AND c.AD_Column_ID=pfi.AD_Column_ID) " - + "WHERE AD_PrintFormat_ID=").append(AD_PrintFormat_ID).append( - " AND EXISTS (SELECT * FROM AD_Element e, AD_Column c" - + " WHERE e.AD_Element_ID=c.AD_Element_ID AND c.AD_Column_ID=pfi.AD_Column_ID)"); - } - else - { - AD_Language = "'" + AD_Language + "'"; - sb.append("UPDATE AD_PrintFormatItem pfi " - + "SET Name = (SELECT e.Name FROM AD_Element_Trl e, AD_Column c" - + " WHERE e.AD_Language=").append(AD_Language).append( - " AND e.AD_Element_ID=c.AD_Element_ID AND c.AD_Column_ID=pfi.AD_Column_ID), " - + "PrintName = (SELECT e.PrintName FROM AD_Element_Trl e, AD_Column c" - + " WHERE e.AD_Language=").append(AD_Language).append( - " AND e.AD_Element_ID=c.AD_Element_ID AND c.AD_Column_ID=pfi.AD_Column_ID) " - + "WHERE AD_PrintFormat_ID=").append(AD_PrintFormat_ID).append( - " AND EXISTS (SELECT * FROM AD_Element_Trl e, AD_Column c" - + " WHERE e.AD_Language=").append(AD_Language).append( - " AND e.AD_Element_ID=c.AD_Element_ID AND c.AD_Column_ID=pfi.AD_Column_ID)"); - } - int count = DB.executeUpdate(sb.toString(), null); - if (log.isLoggable(Level.CONFIG)) log.config("Count=" + count); - // - m_reportEngine.setPrintFormat(MPrintFormat.get (Env.getCtx(), AD_PrintFormat_ID, true)); - revalidate(); - } // cmd_translate - - /*************************************************************************/ - - /** - * Test - * @param args args - */ - static public void main (String[] args) - { - Login.initTest(true); - - MQuery q = new MQuery("C_Invoice"); - q.addRestriction("C_Invoice_ID", MQuery.EQUAL, Integer.valueOf(103)); - - // 102 = Invoice - 100 = Order - PrintInfo i = new PrintInfo("test", X_C_Invoice.Table_ID, 102, 0); - MPrintFormat f = MPrintFormat.get (Env.getCtx(), 102, false); - ReportEngine re = new ReportEngine(Env.getCtx(), f, q, i); - - // MPrintFormat f = new MPrintFormat(Env.getCtx(), 101); - // ReportEngine re = new ReportEngine(f, null); - - new Viewer(null, re); - } // main - - @Override - public void onPrintFormatChanged(ReportEngineEvent event) { - if (m_viewPanel != null) - m_viewPanel.revalidate(); - } - - @Override - public void onQueryChanged(ReportEngineEvent event) { - if (m_viewPanel != null) - m_viewPanel.revalidate(); - } - - @Override - public void onPageSetupChanged(ReportEngineEvent event) { - if (m_viewPanel != null) - m_viewPanel.revalidate(); - } - -} // Viewer - diff --git a/org.adempiere.ui.swing/src/org/compiere/print/package.html b/org.adempiere.ui.swing/src/org/compiere/print/package.html deleted file mode 100644 index edd76e6f46..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/print/package.html +++ /dev/null @@ -1,36 +0,0 @@ - - - - - - - -Provides for.... - -

    Package org.compiere.print

    - -Report viewer and controller. - - - -

    Related Documentation

    - -For overviews, tutorials, examples, guides, and tool documentation, please see: - - - - - - diff --git a/org.adempiere.ui.swing/src/org/compiere/report/core/ResultTable.java b/org.adempiere.ui.swing/src/org/compiere/report/core/ResultTable.java deleted file mode 100644 index 88948d77a2..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/report/core/ResultTable.java +++ /dev/null @@ -1,264 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ -package org.compiere.report.core; - -import java.awt.Component; -import java.awt.event.MouseEvent; -import java.awt.event.MouseListener; -import java.util.ArrayList; -import java.util.Collections; -import java.util.Comparator; -import java.util.logging.Level; - -import javax.swing.JTable; -import javax.swing.ListSelectionModel; -import javax.swing.event.TableModelEvent; -import javax.swing.table.DefaultTableCellRenderer; -import javax.swing.table.TableCellRenderer; -import javax.swing.table.TableColumn; -import javax.swing.table.TableColumnModel; -import javax.swing.table.TableModel; - -import org.compiere.util.CLogger; -import org.compiere.util.MSort; - -/** - * The Table to present RModel information - * - * @author Jorg Janke - * @version $Id: ResultTable.java,v 1.2 2006/07/30 00:51:06 jjanke Exp $ - */ -public class ResultTable extends JTable implements MouseListener -{ - /** - * - */ - private static final long serialVersionUID = -2633317327407673345L; - - /** - * Constructor - */ - public ResultTable() - { - super(); - setCellSelectionEnabled(false); - setColumnSelectionAllowed(false); - setRowSelectionAllowed(false); - setSelectionMode(ListSelectionModel.SINGLE_SELECTION); - setAutoResizeMode(JTable.AUTO_RESIZE_OFF); - - // Default Editor - ResultTableCellEditor rtce = new ResultTableCellEditor(); - setCellEditor(rtce); - - // Mouse Listener - addMouseListener(this); - getTableHeader().addMouseListener(this); - } // ResultTable - - /** Last model index sorted */ - private int m_lastSortIndex = -1; - /** Sort direction */ - private boolean m_asc = true; - /** RModel */ - private RModel m_model = null; - - /** Logger */ - private static CLogger log = CLogger.getCLogger(ResultTable.class); - - /** - * Create a JTable Model from ReportModel - * @param reportModel - */ - public ResultTable (RModel reportModel) - { - this(); - setModel(reportModel); - } // ResultTable - - /** - * Set Model - * @param reportModel - */ - public void setModel (RModel reportModel) - { - if (log.isLoggable(Level.CONFIG)) log.config(reportModel.toString()); - m_model = reportModel; - super.setModel(new ResultTableModel(reportModel)); - // - TableColumnModel tcm = getColumnModel(); - // Set Editor/Renderer - for (int i = 0; i < tcm.getColumnCount(); i++) - { - TableColumn tc = tcm.getColumn(i); - RColumn rc = reportModel.getRColumn(i); - if (rc.getColHeader().equals(tc.getHeaderValue())) - { - ResultTableCellRenderer rtcr = new ResultTableCellRenderer(reportModel, rc); - tc.setCellRenderer(rtcr); - // - } - else - log.log(Level.SEVERE, "RColumn=" + rc.getColHeader() + " <> TableColumn=" + tc.getHeaderValue()); - } - autoSize(); - } // setModel - - /** - * @return RModel - */ - public RModel getRModel() { - return m_model; - } - - /** - * Set Model - * @param ignored - */ - public void setModel (TableModel ignored) - { - // throw new IllegalArgumentException("Requires RModel"); // default construvtor calls this - super.setModel(ignored); - } // setModel - - /** - * Table Model Listener - * @param e - */ - public void tableChanged(TableModelEvent e) - { - super.tableChanged(e); - if (log.isLoggable(Level.FINE)) log.fine("Type=" + e.getType()); - } // tableChanged - - /*************************************************************************/ - - /** - * Mouse Clicked - * @param e - */ - public void mouseClicked(MouseEvent e) - { - int col = getColumnModel().getColumnIndexAtX(e.getX()); - if (log.isLoggable(Level.FINE)) log.fine("Column " + col + " = " + getColumnModel().getColumn(col).getHeaderValue() - + ", Table r=" + this.getSelectedRow() + " c=" + this.getSelectedColumn()); - - // clicked Cell - if (e.getSource() == this) - { - } - // clicked Header - else - { - int mc = convertColumnIndexToModel(col); - sort(mc); - } - } // mouseClicked - - public void mousePressed(MouseEvent e) - { - } - public void mouseReleased(MouseEvent e) - { - } - public void mouseEntered(MouseEvent e) - { - } - public void mouseExited(MouseEvent e) - { - } - - - /************************************************************************** - * Size Columns - */ - private void autoSize() - { - log.config(""); - // - final int SLACK = 8; // making sure it fits in a column - final int MAXSIZE = 300; // max size of a column - // - TableColumnModel tcm = getColumnModel(); - // For all columns - for (int col = 0; col < tcm.getColumnCount(); col++) - { - TableColumn tc = tcm.getColumn(col); - // log.config( "Column=" + col, tc.getHeaderValue()); - int width = 0; - - // Header - TableCellRenderer renderer = tc.getHeaderRenderer(); - if (renderer == null) - renderer = new DefaultTableCellRenderer(); - Component comp = renderer.getTableCellRendererComponent - (this, tc.getHeaderValue(), false, false, 0, 0); - // log.fine( "Hdr - preferred=" + comp.getPreferredSize().width + ", width=" + comp.getWidth()); - width = comp.getPreferredSize().width + SLACK; - - // Cells - int maxRow = Math.min(30, getRowCount()); // first 30 rows - for (int row = 0; row < maxRow; row++) - { - renderer = getCellRenderer(row, col); - comp = renderer.getTableCellRendererComponent - (this, getValueAt(row, col), false, false, row, col); - int rowWidth = comp.getPreferredSize().width + SLACK; - width = Math.max(width, rowWidth); - } - // Width not greater .. - width = Math.min(MAXSIZE, width); - tc.setPreferredWidth(width); - // log.fine( "width=" + width); - } // for all columns - } // autoSize - - /** - * Sort Table - * @param modelColumnIndex - */ - private void sort (final int modelColumnIndex) - { - int rows = getRowCount(); - if (rows == 0) - return; - // other column - if (modelColumnIndex != m_lastSortIndex) - m_asc = true; - else - m_asc = !m_asc; - - m_lastSortIndex = modelColumnIndex; - // - if (log.isLoggable(Level.CONFIG)) log.config("#" + modelColumnIndex - + " - rows=" + rows + ", asc=" + m_asc); - ResultTableModel model = (ResultTableModel)getModel(); - - // Prepare sorting - final MSort sort = new MSort(0, null); - sort.setSortAsc(m_asc); - // Sort the data list - teo_sarca [ 1734327 ] - Collections.sort(model.getDataList(), new Comparator() { - public int compare(Object o1, Object o2) { - Object item1 = ((ArrayList)o1).get(modelColumnIndex); - Object item2 = ((ArrayList)o2).get(modelColumnIndex); - return sort.compare(item1, item2); - } - }); - } // sort - -} // ResultTable diff --git a/org.adempiere.ui.swing/src/org/compiere/report/core/ResultTableCellEditor.java b/org.adempiere.ui.swing/src/org/compiere/report/core/ResultTableCellEditor.java deleted file mode 100644 index 2bb66f260b..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/report/core/ResultTableCellEditor.java +++ /dev/null @@ -1,98 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ -package org.compiere.report.core; - -import java.awt.Component; -import java.util.EventObject; - -import javax.swing.AbstractCellEditor; -import javax.swing.JTable; -import javax.swing.table.TableCellEditor; - -/** - * Cell Editor for Report Result Table - * - * @author Jorg Janke - * @version $Id: ResultTableCellEditor.java,v 1.2 2006/07/30 00:51:06 jjanke Exp $ - */ -public class ResultTableCellEditor extends AbstractCellEditor implements TableCellEditor -{ - /** - * - */ - private static final long serialVersionUID = -5173884011593230904L; - - /** - * Constructor (read only) - */ - public ResultTableCellEditor() - { - } // ResultTableCellEditor - - /** - * Constructor - */ - public ResultTableCellEditor(RColumn rc) - { - m_rc = rc; - } // ResultTableCellEditor - - /** Report Column */ - private RColumn m_rc = null; - - /** - * Return Editor - */ - public Component getTableCellEditorComponent (JTable table, Object value, - boolean isSelected, int row, int col) - { - if (m_rc == null) - return null; - return null; - } // getTableCellEditorComponent - - /** - * Get Value - */ - public Object getCellEditorValue() - { - if (m_rc == null) - return null; - return null; - } // getCellEditorValue - - /** - * Is Cell editable - */ - public boolean isCellEditable(EventObject anEvent) - { - if (m_rc == null) - return false; - return !m_rc.isReadOnly(); - } // isCellEditable - - /** - * Should Cell be selected - */ - public boolean shouldSelectCell(EventObject anEvent) - { - if (m_rc == null) - return false; - return !m_rc.isReadOnly(); - } // shouldSelectCell - -} // ResultTableCellEditor diff --git a/org.adempiere.ui.swing/src/org/compiere/report/core/ResultTableCellRenderer.java b/org.adempiere.ui.swing/src/org/compiere/report/core/ResultTableCellRenderer.java deleted file mode 100644 index 80539dbbbd..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/report/core/ResultTableCellRenderer.java +++ /dev/null @@ -1,162 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ -package org.compiere.report.core; - -import java.awt.Component; -import java.awt.Font; -import java.awt.Insets; -import java.text.DecimalFormat; -import java.text.SimpleDateFormat; - -import javax.swing.JCheckBox; -import javax.swing.JLabel; -import javax.swing.JTable; -import javax.swing.table.DefaultTableCellRenderer; -import javax.swing.table.TableCellRenderer; - -import org.adempiere.plaf.AdempierePLAF; -import org.compiere.util.DisplayType; - -/** - * Cell Renderer for Report Result Table - * - * @author Jorg Janke - * @version $Id: ResultTableCellRenderer.java,v 1.2 2006/07/30 00:51:06 jjanke Exp $ - */ -class ResultTableCellRenderer extends DefaultTableCellRenderer implements TableCellRenderer -{ - /** - * - */ - private static final long serialVersionUID = -1491594061244117003L; - - - /** - * Constructor (extends Label) - * @param rm - * @param rc - */ - public ResultTableCellRenderer(RModel rm, RColumn rc) - { - m_rm = rm; - m_rc = rc; - int dt = m_rc.getDisplayType(); - // Numbers - if (DisplayType.isNumeric(dt)) - { - super.setHorizontalAlignment(JLabel.TRAILING); - m_nFormat = DisplayType.getNumberFormat(dt); - } - // Dates - else if (DisplayType.isDate(m_rc.getDisplayType())) - { - super.setHorizontalAlignment(JLabel.TRAILING); - m_dFormat = DisplayType.getDateFormat(dt); - } - // - else if (dt == DisplayType.YesNo) - { - m_check = new JCheckBox(); - m_check.setMargin(new Insets(0,0,0,0)); - m_check.setHorizontalAlignment(JLabel.CENTER); - } - } // ResultTableCellRenderer - - /** Report Column */ - private RModel m_rm = null; - /** Report Column */ - private RColumn m_rc = null; - /** Number Format */ - private DecimalFormat m_nFormat = null; - /** Date Format */ - private SimpleDateFormat m_dFormat = null; - /** Boolean renderer */ - private JCheckBox m_check; - - - /** - * Return Renderer Component - * @param table - * @param value - * @param isSelected - * @param hasFocus - * @param row - * @param col - * @return renderer component - */ - public Component getTableCellRendererComponent(JTable table, Object value, - boolean isSelected, boolean hasFocus, int row, int col) - { - // Get Component - Component c = m_check; - if (c == null) // default JLabel - c = super.getTableCellRendererComponent(table,value, isSelected,hasFocus, row,col); - // Background - if (m_rm.isCellEditable(row, col)) - c.setBackground(AdempierePLAF.getFieldBackground_Normal()); - else - c.setBackground(AdempierePLAF.getFieldBackground_Inactive()); - // - if (m_rm.isGroupRow(row)) - c.setFont(c.getFont().deriveFont(Font.BOLD)); - // Value - setValue (value); - return c; - } // getTableCellRendererComponent - - /** - * Set Value - * @param value - */ - protected void setValue (Object value) - { - // Boolean - if (m_check != null) - { - boolean sel = false; - if (value != null && ((Boolean)value).booleanValue()) - sel = true; - m_check.setSelected(sel); - return; - } - - // JLabel - if (value == null) - setText(""); - else if (m_nFormat != null) - try - { - setText(m_nFormat.format(value)); - } - catch (Exception e) - { - setText(value.toString()); - } - else if (m_dFormat != null) - try - { - setText(m_dFormat.format(value)); - } - catch (Exception e) - { - setText(value.toString()); - } - else - setText(value.toString()); - } // setValue - -} // ResultTableCellRenderer diff --git a/org.adempiere.ui.swing/src/org/compiere/swing/CButton.java b/org.adempiere.ui.swing/src/org/compiere/swing/CButton.java deleted file mode 100644 index 9b15112726..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/swing/CButton.java +++ /dev/null @@ -1,341 +0,0 @@ -/********************************************************************* -* This file is part of Adempiere ERP Bazaar * -* http://www.adempiere.org * -* * -* Copyright (C) 1999 - 2006 Compiere Inc. * -* Copyright (C) Contributors * -* * -* This program is free software; you can redistribute it and/or * -* modify it under the terms of the GNU General Public License * -* as published by the Free Software Foundation; either version 2 * -* of the License, or (at your option) any later version. * -* * -* This program is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU General Public License for more details. * -* * -* You should have received a copy of the GNU General Public License * -* along with this program; if not, write to the Free Software * -* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, * -* MA 02110-1301, USA. * -* * -* Contributors: * -* - Bahman Movaqar (bmovaqar@users.sf.net) * -**********************************************************************/ -package org.compiere.swing; - -import java.awt.Color; -import java.awt.event.ActionEvent; -import java.awt.event.KeyEvent; - -import javax.swing.Action; -import javax.swing.Icon; -import javax.swing.InputMap; -import javax.swing.JButton; -import javax.swing.JComponent; -import javax.swing.KeyStroke; -import javax.swing.SwingUtilities; -import javax.swing.plaf.ComponentInputMapUIResource; - -import org.adempiere.plaf.AdempierePLAF; -import org.compiere.plaf.CompiereColor; -import org.compiere.plaf.CompiereLookAndFeel; - -/** - * Adempiere Button supporting colored Background - * - * @author Jorg Janke - * @version $Id: CButton.java,v 1.2 2006/07/30 00:52:24 jjanke Exp $ - */ -public class CButton extends JButton implements CEditor { - /** - * - */ - private static final long serialVersionUID = 70278798402299341L; - - /** - * Creates a button with no set text or icon. - */ - public CButton() { - this(null, null); - } // CButton - - /** - * Creates a button with an icon. - * - * @param icon - * the Icon image to display on the button - */ - public CButton(Icon icon) { - this(null, icon); - } // CButton - - /** - * Creates a button with text. - * - * @param text - * the text of the button - */ - public CButton(String text) { - this(text, null); - } // CButton - - /** - * Creates a button where properties are taken from the Action - * supplied. - * - * @param a - * the Action used to specify the new button - * - * @since 1.3 - */ - public CButton(Action a) { - super(a); - } // CButton - - /** - * Creates a button with initial text and an icon. - * - * @param text - * the text of the button - * @param icon - * the Icon image to display on the button - */ - public CButton(String text, Icon icon) { - super(text, icon); - } // CButton - - /*************************************************************************** - * Set Background - Differentiates between system & user call. If User Call, - * sets Opaque & ContextAreaFilled to true - * - * @param bg - * background color - */ - public void setBackground(Color bg) { - if (bg.equals(getBackground())) - return; - super.setBackground(bg); - setBackgroundColor(new CompiereColor(bg)); - this.repaint(); - } // setBackground - - /** - * Set Background - NOP - * - * @param error - * error - */ - public void setBackground(boolean error) { - } // setBackground - - /** - * Set Standard Background - */ - public void setBackgroundColor() { - setBackgroundColor(null); - } // setBackground - - /** - * Set Background - * - * @param bg - * AdempiereColor for Background, if null set standard background - */ - public void setBackgroundColor(CompiereColor bg) { - if (bg == null) - bg = new CompiereColor(AdempierePLAF.getFormBackground()); - putClientProperty(CompiereLookAndFeel.BACKGROUND, bg); - super.setBackground(bg.getFlatColor()); - this.repaint(); - } // setBackground - - /** - * Get Background - * - * @return Color for Background - */ - public CompiereColor getBackgroundColor() { - try { - return (CompiereColor) getClientProperty(CompiereLookAndFeel.BACKGROUND); - } catch (Exception e) { - System.err.println("CButton - ClientProperty: " + e.getMessage()); - } - return null; - } // getBackgroundColor - - /** Mandatory (default false) */ - private boolean m_mandatory = false; - - /** Read-Write */ - private boolean m_readWrite = true; - - /** - * Set Editor Mandatory - * - * @param mandatory - * true, if you have to enter data - */ - public void setMandatory(boolean mandatory) { - m_mandatory = mandatory; - setBackground(false); - } // setMandatory - - /** - * Is Field mandatory - * - * @return true, if mandatory - */ - public boolean isMandatory() { - return m_mandatory; - } // isMandatory - - /** - * Enable Editor - * - * @param rw - * true, if you can enter/select data - */ - public void setReadWrite(boolean rw) { - if (isEnabled() != rw) - setEnabled(rw); - m_readWrite = rw; - } // setReadWrite - - /** - * Is it possible to edit - * - * @return true, if editable - */ - public boolean isReadWrite() { - return m_readWrite; - } // isReadWrite - - /** - * Set Editor to value - * - * @param value - * value of the editor - */ - public void setValue(Object value) { - if (value == null) - setText(""); - else - setText(value.toString()); - } // setValue - - /** - * Return Editor value - * - * @return current value - */ - public Object getValue() { - return getText(); - } // getValue - - /** - * Return Display Value - * - * @return displayed String value - */ - public String getDisplay() { - return getText(); - } // getDisplay - - /** - * Set Text & Mnemonic - * - * @param text - * text - */ - public void setText(String text) { - if (text == null) { - super.setText(text); - return; - } - int pos = text.indexOf('&'); - if (pos != -1) // We have a nemonic - creates ALT-_ - { - int mnemonic = text.toUpperCase().charAt(pos + 1); - if (mnemonic != ' ') { - setMnemonic(mnemonic); - text = text.substring(0, pos) + text.substring(pos + 1); - } - } - super.setText(text); - if (getName() == null) - setName(text); - } // setText - - /** - * Set Tool Tip Text & Mnemonic - * - * @param text - * text - */ - public void setToolTipText(String text) { - if (text == null) { - //super.setText(text); Angelo Dabala' (genied) fixed, was calling the wrong method - super.setToolTipText(text); - return; - } - int pos = text.indexOf('&'); - if (pos != -1) // We have a nemonic - creates ALT-_ - { - int mnemonic = text.toUpperCase().charAt(pos + 1); - if (mnemonic != ' ') { - setMnemonic(mnemonic); - text = text.substring(0, pos) + text.substring(pos + 1); - } - } - super.setToolTipText(text); - if (getName() == null) - setName(text); - } // setToolTipText - - /** - * Set Action Command - * - * @param actionCommand - * command - */ - public void setActionCommand(String actionCommand) { - super.setActionCommand(actionCommand); - if (getName() == null && actionCommand != null - && actionCommand.length() > 0) - setName(actionCommand); - } // setActionCommand - - /** - * Overrides the JButton.setMnemonic() method, setting modifier keys to - * CTRL+ALT. - * - * @param mnemonic - * The mnemonic character code. - */ - public void setMnemonic(int mnemonic) { - super.setMnemonic(mnemonic); - - // Angelo Dabala' (genied) avoid to register Ctrl+Alt modifier mask without mnemonic - if (mnemonic==KeyEvent.VK_UNDEFINED) { - return; - } - - InputMap map = SwingUtilities.getUIInputMap(this, - JComponent.WHEN_IN_FOCUSED_WINDOW); - - if (map == null) { - map = new ComponentInputMapUIResource(this); - SwingUtilities.replaceUIInputMap(this, - JComponent.WHEN_IN_FOCUSED_WINDOW, map); - } - map.clear(); - int mask = ActionEvent.ALT_MASK + ActionEvent.CTRL_MASK; // Default - // Buttons - map.put(KeyStroke.getKeyStroke(mnemonic, mask, false), "pressed"); - map.put(KeyStroke.getKeyStroke(mnemonic, mask, true), "released"); - map.put(KeyStroke.getKeyStroke(mnemonic, 0, true), "released"); - setInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW, map); - } // setMnemonic -} // CButton diff --git a/org.adempiere.ui.swing/src/org/compiere/swing/CCheckBox.java b/org.adempiere.ui.swing/src/org/compiere/swing/CCheckBox.java deleted file mode 100644 index 5a385503c1..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/swing/CCheckBox.java +++ /dev/null @@ -1,347 +0,0 @@ -/********************************************************************* -* This file is part of Adempiere ERP Bazaar * -* http://www.adempiere.org * -* * -* Copyright (C) 1999 - 2006 Compiere Inc. * -* Copyright (C) Contributors * -* * -* This program is free software; you can redistribute it and/or * -* modify it under the terms of the GNU General Public License * -* as published by the Free Software Foundation; either version 2 * -* of the License, or (at your option) any later version. * -* * -* This program is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU General Public License for more details. * -* * -* You should have received a copy of the GNU General Public License * -* along with this program; if not, write to the Free Software * -* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, * -* MA 02110-1301, USA. * -* * -* Contributors: * -* - Bahman Movaqar (bmovaqar@users.sf.net) * -**********************************************************************/ -package org.compiere.swing; - -import java.awt.Color; -import java.awt.event.ActionEvent; - -import javax.swing.Action; -import javax.swing.Icon; -import javax.swing.InputMap; -import javax.swing.JCheckBox; -import javax.swing.JComponent; -import javax.swing.KeyStroke; -import javax.swing.SwingUtilities; -import javax.swing.plaf.ComponentInputMapUIResource; - -/** - * Adempiere CheckBox - * - * @author Jorg Janke - * @version $Id: CCheckBox.java,v 1.2 2006/07/30 00:52:24 jjanke Exp $ - */ -public class CCheckBox extends JCheckBox implements CEditor { - /** - * - */ - private static final long serialVersionUID = 6115543971487470944L; - - /** - * Creates an initially unselected check box button with no text, no icon. - */ - public CCheckBox() { - super(); - init(); - } - - /** - * Creates an initially unselected check box with an icon. - * - * @param icon - * the Icon image to display - */ - public CCheckBox(Icon icon) { - super(icon); - init(); - } - - /** - * Creates a check box with an icon and specifies whether or not it is - * initially selected. - * - * @param icon - * the Icon image to display - * @param selected - * a boolean value indicating the initial selection state. If - * true the check box is selected - */ - public CCheckBox(Icon icon, boolean selected) { - super(icon, selected); - init(); - } - - /** - * Creates an initially unselected check box with text. - * - * @param text - * the text of the check box. - */ - public CCheckBox(String text) { - super(text); - init(); - } - - /** - * Creates a check box where properties are taken from the Action supplied. - * - * @param a - */ - public CCheckBox(Action a) { - super(a); - init(); - } - - /** - * Creates a check box with text and specifies whether or not it is - * initially selected. - * - * @param text - * the text of the check box. - * @param selected - * a boolean value indicating the initial selection state. If - * true the check box is selected - */ - public CCheckBox(String text, boolean selected) { - super(text, selected); - init(); - } - - /** - * Creates an initially unselected check box with the specified text and - * icon. - * - * @param text - * the text of the check box. - * @param icon - * the Icon image to display - */ - public CCheckBox(String text, Icon icon) { - super(text, icon, false); - init(); - } - - /** - * Creates a check box with text and icon, and specifies whether or not it - * is initially selected. - * - * @param text - * the text of the check box. - * @param icon - * the Icon image to display - * @param selected - * a boolean value indicating the initial selection state. If - * true the check box is selected - */ - public CCheckBox(String text, Icon icon, boolean selected) { - super(text, icon, selected); - init(); - } - - /** - * Common Init - */ - private void init() { - // Default to transparent, works better under windows look and feel - setOpaque(false); - } // init - - /** ********************************************************************** */ - - /** Mandatory (default false) */ - private boolean m_mandatory = false; - - /** Read-Write */ - private boolean m_readWrite = true; - - /** - * Set Editor Mandatory - * - * @param mandatory - * true, if you have to enter data - */ - public void setMandatory(boolean mandatory) { - m_mandatory = mandatory; - setBackground(false); - } // setMandatory - - /** - * Is Field mandatory - * - * @return true, if mandatory - */ - public boolean isMandatory() { - return m_mandatory; - } // isMandatory - - /** - * Enable Editor - * - * @param rw - * true, if you can enter/select data - */ - public void setReadWrite(boolean rw) { - if (super.isEnabled() != rw) - super.setEnabled(rw); - setBackground(false); - m_readWrite = rw; - } // setEditable - - /** - * Is it possible to edit - * - * @return true, if editable - */ - public boolean isReadWrite() { - return m_readWrite; - } // isEditable - - /** - * Set Background based on editable/mandatory/error - ignored - - * - * @param error - * if true, set background to error color, otherwise - * mandatory/editable - */ - public void setBackground(boolean error) { - } // setBackground - - /** - * Set Background - * - * @param bg - */ - public void setBackground(Color bg) { - if (bg.equals(getBackground())) - return; - super.setBackground(bg); - } // setBackground - - /** Retain value */ - private Object m_value = null; - - /** - * Set Editor to value. Interpret Y/N and Boolean - * - * @param value - * value of the editor - */ - public void setValue(Object value) { - m_value = value; - boolean sel = false; - if (value == null) - sel = false; - else if (value.toString().equals("Y")) - sel = true; - else if (value.toString().equals("N")) - sel = false; - else if (value instanceof Boolean) - sel = ((Boolean) value).booleanValue(); - else { - try { - sel = Boolean.getBoolean(value.toString()); - } catch (Exception e) { - } - } - this.setSelected(sel); - } // setValue - - /** - * Return Editor value - * - * @return current value as String or Boolean - */ - public Object getValue() { - if (m_value instanceof String) - return super.isSelected() ? "Y" : "N"; - return Boolean.valueOf(isSelected()); - } // getValue - - /** - * Return Display Value - * - * @return displayed String value - */ - public String getDisplay() { - if (m_value instanceof String) - return super.isSelected() ? "Y" : "N"; - return Boolean.toString(super.isSelected()); - } // getDisplay - - /** - * Set Text - * - * @param mnemonicLabel - * text - */ - public void setText(String mnemonicLabel) { - super.setText(createMnemonic(mnemonicLabel)); - } // setText - - /** - * Create Mnemonics of text containing "&". Based on MS notation of &Help => - * H is Mnemonics Creates ALT_ - * - * @param text - * test with Mnemonics - * @return text w/o & - */ - private String createMnemonic(String text) { - if (text == null) - return text; - int pos = text.indexOf('&'); - if (pos != -1) // We have a nemonic - { - char ch = text.charAt(pos + 1); - if (ch != ' ') // &_ - is the & character - { - setMnemonic(ch); - return text.substring(0, pos) + text.substring(pos + 1); - } - } - return text; - } // createMnemonic - - /** - * Overrides the JCheckBox.setMnemonic() method, setting modifier keys to - * CTRL+SHIFT. - * - * @param mnemonic - * The mnemonic character code. - */ - public void setMnemonic(int mnemonic) { - super.setMnemonic(mnemonic); - - InputMap map = SwingUtilities.getUIInputMap(this, - JComponent.WHEN_IN_FOCUSED_WINDOW); - - if (map == null) { - map = new ComponentInputMapUIResource(this); - SwingUtilities.replaceUIInputMap(this, - JComponent.WHEN_IN_FOCUSED_WINDOW, map); - } - map.clear(); - String className = this.getClass().getName(); - int mask = ActionEvent.ALT_MASK; // Default Buttons - if (this instanceof JCheckBox // In Tab - || className.indexOf("VButton") != -1) - mask = ActionEvent.SHIFT_MASK + ActionEvent.CTRL_MASK; - map.put(KeyStroke.getKeyStroke(mnemonic, mask, false), "pressed"); - map.put(KeyStroke.getKeyStroke(mnemonic, mask, true), "released"); - map.put(KeyStroke.getKeyStroke(mnemonic, 0, true), "released"); - setInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW, map); - } // setMnemonic - -} // CCheckBox diff --git a/org.adempiere.ui.swing/src/org/compiere/swing/CCheckBoxMenuItem.java b/org.adempiere.ui.swing/src/org/compiere/swing/CCheckBoxMenuItem.java deleted file mode 100644 index 1d707e10f6..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/swing/CCheckBoxMenuItem.java +++ /dev/null @@ -1,98 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ -package org.compiere.swing; - -import javax.swing.Action; -import javax.swing.Icon; -import javax.swing.JCheckBoxMenuItem; - -/** - * Adempiere Check Box Menu Item - * - * @author Jorg Janke - * @version $Id: CCheckBoxMenuItem.java,v 1.2 2006/07/30 00:52:24 jjanke Exp $ - */ -public class CCheckBoxMenuItem extends JCheckBoxMenuItem -{ - - /** - * - */ - private static final long serialVersionUID = 6701152155152356260L; - - public CCheckBoxMenuItem () - { - super (); - } // CCheckBoxMenuItem - - public CCheckBoxMenuItem (Icon icon) - { - super (icon); - } // CCheckBoxMenuItem - - public CCheckBoxMenuItem (String text) - { - super (text); - } // CCheckBoxMenuItem - - public CCheckBoxMenuItem (Action a) - { - super (a); - } // CCheckBoxMenuItem - - public CCheckBoxMenuItem (String text, Icon icon) - { - super (text, icon); - } // CCheckBoxMenuItem - - public CCheckBoxMenuItem (String text, boolean b) - { - super (text, b); - } // CCheckBoxMenuItem - - public CCheckBoxMenuItem (String text, Icon icon, boolean b) - { - super (text, icon, b); - } // CCheckBoxMenuItem - - /** - * Set Text - * @param text text - */ - public void setText (String text) - { - if (text == null) - { - super.setText(text); - return; - } - int pos = text.indexOf('&'); - if (pos != -1 && text.length() > pos) // We have a nemonic - creates ALT-_ - { - int mnemonic = text.toUpperCase().charAt(pos+1); - if (mnemonic != ' ') - { - setMnemonic(mnemonic); - text = text.substring(0, pos) + text.substring(pos+1); - } - } - super.setText (text); - if (getName() == null) - setName (text); - } // setText - -} // CCheckBoxMenuItem diff --git a/org.adempiere.ui.swing/src/org/compiere/swing/CColumnControlButton.java b/org.adempiere.ui.swing/src/org/compiere/swing/CColumnControlButton.java deleted file mode 100644 index 01c05009a7..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/swing/CColumnControlButton.java +++ /dev/null @@ -1,890 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 2007 Adempiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - *****************************************************************************/ -package org.compiere.swing; - -import java.awt.BorderLayout; -import java.awt.ComponentOrientation; -import java.awt.Dimension; -import java.awt.Insets; -import java.awt.event.ActionEvent; -import java.awt.event.ItemEvent; -import java.beans.PropertyChangeEvent; -import java.beans.PropertyChangeListener; -import java.util.ArrayList; -import java.util.Collections; -import java.util.Enumeration; -import java.util.List; - -import javax.swing.AbstractAction; -import javax.swing.AbstractButton; -import javax.swing.Action; -import javax.swing.BorderFactory; -import javax.swing.Box; -import javax.swing.Icon; -import javax.swing.JButton; -import javax.swing.JCheckBox; -import javax.swing.JComboBox; -import javax.swing.JComponent; -import javax.swing.JPanel; -import javax.swing.JPopupMenu; -import javax.swing.JScrollPane; -import javax.swing.JSeparator; -import javax.swing.ScrollPaneConstants; -import javax.swing.SwingUtilities; -import javax.swing.UIManager; -import javax.swing.event.ChangeEvent; -import javax.swing.event.ListSelectionEvent; -import javax.swing.event.TableColumnModelEvent; -import javax.swing.event.TableColumnModelListener; -import javax.swing.table.TableColumn; -import javax.swing.table.TableColumnModel; - -import org.jdesktop.swingx.VerticalLayout; -import org.jdesktop.swingx.action.AbstractActionExt; -import org.jdesktop.swingx.action.ActionContainerFactory; -import org.jdesktop.swingx.table.ColumnControlPopup; - -/** - * Code and description adapted from SwingX ColumnControlButton class. - * - * A component to allow interactive customization of CTable's - * columns. - * It's main purpose is to allow toggling of table columns' visibility. - * Additionally, arbitrary configuration actions can be exposed. - *

    - * - * This component is installed in the CTable's - * trailing corner, if enabled: - * - *

    
    - * table.setColumnControlVisible(true);
    - * 
    - * - * From the perspective of a CTable, the component's behaviour is - * opaque. Typically, the button's action is to popup a component for user - * interaction.

    - * - * This class is responsible for handling/providing/updating the lists of - * actions and to keep all action's state in synch with Table-/Column state. - * The visible behaviour of the popup is delegated to a - * ColumnControlPopup.

    - * - * @see CTable#setColumnControl - * - */ -public class CColumnControlButton extends JButton { - /** - * - */ - private static final long serialVersionUID = 3052540263336100861L; - /** Marker to auto-recognize actions which should be added to the popup. */ - public static final String COLUMN_CONTROL_MARKER = "column."; - /** exposed for testing. */ - protected ColumnControlPopup popup; - // TODO: the table reference is a potential leak? - /** The table which is controlled by this. */ - private CTable table; - /** Listener for table property changes. */ - private PropertyChangeListener tablePropertyChangeListener; - /** Listener for table's columnModel. */ - TableColumnModelListener columnModelListener; - /** the list of actions for column menuitems.*/ - private List columnVisibilityActions; - - /** - * Creates a column control button for the table. The button - * uses the given icon and has no text. - * @param table the JTable controlled by this component - * @param icon the Icon to show - */ - public CColumnControlButton(CTable table, Icon icon) { - super(); - init(); - // JW: icon LF dependent? - setAction(createControlAction(icon)); - installTable(table); - } - - - @Override - public void updateUI() { - super.updateUI(); - // JW: icon LF dependent? - setMargin(new Insets(1, 2, 2, 1)); // Make this LAF-independent - getColumnControlPopup().updateUI(); - } - - /** - * Toggles the popup component's visibility. This method is - * called by this control's default action.

    - * - * Here: delegates to getControlPopup(). - */ - public void togglePopup() { - getColumnControlPopup().toggleVisibility(this); - } - - @Override - public void applyComponentOrientation(ComponentOrientation o) { - super.applyComponentOrientation(o); - getColumnControlPopup().applyComponentOrientation(o); - } - - -//-------------------------- Action in synch with column properties - /** - * A specialized Action which takes care of keeping in synch with - * TableColumn state. - * - * NOTE: client must call releaseColumn if this action is no longer needed! - * - */ - public class ColumnVisibilityAction extends AbstractActionExt { - - /** - * - */ - private static final long serialVersionUID = -5843080042335689992L; - - private TableColumn column; - - private PropertyChangeListener columnListener; - - /** flag to distinguish selection changes triggered by - * column's property change from those triggered by - * user interaction. Hack around #212-swingx. - */ - private boolean fromColumn; - - /** - * Creates a action synched to the table column. - * - * @param column the TableColumn to keep synched to. - */ - public ColumnVisibilityAction(TableColumn column) { - super((String) null); - setStateAction(); - installColumn(column); - } - - /** - * Releases all references to the synched TableColumn. - * Client code must call this method if the - * action is no longer needed. After calling this action must not be - * used any longer. - */ - public void releaseColumn() { - column.removePropertyChangeListener(columnListener); - column = null; - } - - @Override - public void itemStateChanged(final ItemEvent e) { - if ((e.getStateChange() == ItemEvent.DESELECTED) - //JW: guarding against 1 leads to #212-swingx: setting - // column visibility programatically fails if - // the current column is the second last visible - // guarding against 0 leads to hiding all columns - // by deselecting the menu item. - && (table.getColumnCount() <= 1) - // JW Fixed #212: basically implemented Rob's idea to distinguish - // event sources instead of unconditionally reselect - // not entirely sure if the state transitions are completely - // defined but all related tests are passing now. - && !fromColumn) { - reselect(); - } else { - setSelected(e.getStateChange() == ItemEvent.SELECTED); - } - } - - - @Override - public synchronized void setSelected(boolean newValue) { - super.setSelected(newValue); - if (!newValue) { - if (table.isColumnVisible(column)) { - table.setColumnVisibility(column, newValue); - } - } else { - if (!table.isColumnVisible(column)) { - table.setColumnVisibility(column, newValue); - } - } - } - - /** - * Does nothing. Synch from action state to TableColumn state - * is done in itemStateChanged. - */ - public void actionPerformed(ActionEvent e) { - - } - - /** - * Synchs selected property to visible. This - * is called on change of tablecolumn's visible property. - * - * @param visible column visible state to synch to. - */ - private void updateFromColumnVisible(boolean visible) { - fromColumn = true; - setSelected(visible); - fromColumn = false; - } - - /** - * Synchs name property to value. This is called on change of - * tableColumn's headerValue property. - * - * @param value - */ - private void updateFromColumnHeader(Object value) { - if (value == null) { - this.setEnabled(false); - } else { - setName(String.valueOf(value)); - this.setEnabled(true); - } - } - - /** - * Enforces selected to true. Called if user interaction - * tried to de-select the last single visible column. - * - */ - private void reselect() { - firePropertyChange("selected", null, Boolean.TRUE); - } - - // -------------- init - private void installColumn(TableColumn column) { - this.column = column; - column.addPropertyChangeListener(getColumnListener()); - updateFromColumnHeader(column.getHeaderValue()); - // #429-swing: actionCommand must be string - if (column.getIdentifier() != null) { - setActionCommand(column.getIdentifier().toString()); - } - boolean visible = table.isColumnVisible(column); - updateFromColumnVisible(visible); - } - - /** - * Returns the listener to column's property changes. The listener - * is created lazily if necessary. - * - * @return the PropertyChangeListener listening to - * TableColumn's property changes, guaranteed to be - * not null. - */ - protected PropertyChangeListener getColumnListener() { - if (columnListener == null) { - columnListener = createPropertyChangeListener(); - } - return columnListener; - } - - /** - * Creates and returns the listener to column's property changes. - * Subclasses are free to roll their own. - *

    - * Implementation note: this listener reacts to column's - * visible and headerValue properties and - * calls the respective updateFromXX methodes. - * - * @return the PropertyChangeListener to use with the - * column - */ - protected PropertyChangeListener createPropertyChangeListener() { - return new PropertyChangeListener() { - public void propertyChange(PropertyChangeEvent evt) { - if ("visible".equals(evt.getPropertyName())) { - updateFromColumnVisible((Boolean) evt.getNewValue()); - } else if ("headerValue".equals(evt.getPropertyName())) { - updateFromColumnHeader(evt.getNewValue()); - if (evt.getNewValue() == null) - populatePopup(); - } - } - }; - } - } - - // ---------------------- the popup - - /** - * A default implementation of ColumnControlPopup. - * It uses a JPopupMenu with - * MenuItems corresponding to the Actions as - * provided by the ColumnControlButton. - * - * - */ - public class DefaultColumnControlPopup implements ColumnControlPopup { - private JPopupMenu popupMenu; - private JScrollPane scroller; - private JPanel panelMenus; - - //------------------ public methods to control visibility status - - /** - * @inheritDoc - * - */ - public void updateUI() { - SwingUtilities.updateComponentTreeUI(getPopupMenu()); - } - - private JPanel getPanelMenu() { - if (panelMenus == null) { - panelMenus = new JPanel(); - panelMenus.setLayout(new VerticalLayout()); - panelMenus.setBackground(UIManager.getColor("MenuItem.background")); - panelMenus.setBorder(BorderFactory.createEmptyBorder()); - } - return panelMenus; - } - - private JScrollPane getScroller() { - if (scroller == null) { - scroller = createScroller(); - scroller.getVerticalScrollBar().setFocusable( false ); - scroller.setViewportView(getPanelMenu()); - } - return scroller; - } - - /** - * @inheritDoc - * - */ - public void toggleVisibility(JComponent owner) { - JPopupMenu popupMenu = getPopupMenu(); - JPanel panel = getPanelMenu(); - if (popupMenu.isVisible()) { - popupMenu.setVisible(false); - } else if (panel.getComponentCount() > 0) { - JScrollPane scroller = getScroller(); - panel.validate(); - - Dimension pSize = table.getParent().getSize(); - Dimension size = panel.getPreferredSize(); - if (size.height >= pSize.height) { - scroller.setPreferredSize(new Dimension(size.width, pSize.height - 30)); - } else { - scroller.setPreferredSize(size); - } - popupMenu.setPopupSize(new Dimension(scroller.getPreferredSize().width + 20, - scroller.getPreferredSize().height - 20)); - - Dimension buttonSize = owner.getSize(); - int xPos = owner.getComponentOrientation().isLeftToRight() ? buttonSize.width - - popupMenu.getPreferredSize().width - : 0; - - popupMenu.show(owner, - xPos, buttonSize.height); - } - - } - - /** - * @inheritDoc - * - */ - public void applyComponentOrientation(ComponentOrientation o) { - getPopupMenu().applyComponentOrientation(o); - - } - - //-------------------- public methods to manipulate popup contents. - - /** - * @inheritDoc - * - */ - public void removeAll() { - getPanelMenu().removeAll(); - } - - - /** - * @inheritDoc - * - */ - public void addVisibilityActionItems( - List actions) { - addItems(new ArrayList(actions)); - - } - - - /** - * @inheritDoc - * - */ - public void addAdditionalActionItems(List actions) { - if (actions.size() == 0) - return; - addSeparator(); - addItems(actions); - } - - //--------------------------- internal helpers to manipulate popups content - - /** - * Here: creates and adds a menuItem to the popup for every - * Action in the list. Does nothing if - * if the list is empty. - * - * PRE: actions != null. - * - * @param actions a list containing the actions to add to the popup. - * Must not be null. - * - */ - protected void addItems(List actions) { - ActionContainerFactory factory = new ActionContainerFactory(null); - for (Action action : actions) { - AbstractActionExt a = (AbstractActionExt)action; - if (action.isEnabled()) { - if (a.isStateAction()) - addItem(createCheckBox((AbstractActionExt)action)); - else { - addItem(factory.createButton(action)); - } - } - } - } - - private JCheckBox createCheckBox(AbstractActionExt action) { - JCheckBox c = new JCheckBox(action); - c.setSelected(action.isSelected()); - c.addItemListener(action); - return c; - } - - /** - * adds a separator to the popup. - * - */ - protected void addSeparator() { - getPanelMenu().add(Box.createVerticalStrut(2)); - getPanelMenu().add(new JSeparator()); - getPanelMenu().add(Box.createVerticalStrut(2)); - } - - /** - * - * @param item the menuItem to add to the popup. - */ - protected void addItem(AbstractButton item) { - getPanelMenu().add(item); - } - - /** - * - * @return the popup to add menuitems. Guaranteed to be != null. - */ - protected JPopupMenu getPopupMenu() { - if (popupMenu == null) { - popupMenu = new JPopupMenu(); - popupMenu.removeAll(); - popupMenu.setLayout(new BorderLayout()); - popupMenu.add(getScroller(), BorderLayout.CENTER); - } - return popupMenu; - } - - /** - * Creates the scroll pane which houses the scrollable list. - */ - protected JScrollPane createScroller() { - JScrollPane sp = new JScrollPane( null, - ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, - ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER ); - sp.setHorizontalScrollBar(null); - sp.setBorder(BorderFactory.createEmptyBorder()); - return sp; - } - - } - - - /** - * Returns to popup component for user interaction. Lazily - * creates the component if necessary. - * - * @return the ColumnControlPopup for showing the items, guaranteed - * to be not null. - * @see #createColumnControlPopup() - */ - protected ColumnControlPopup getColumnControlPopup() { - if (popup == null) { - popup = createColumnControlPopup(); - } - return popup; - } - - /** - * Factory method to return a ColumnControlPopup. - * Subclasses can override to hook custom implementations. - * - * @return the ColumnControlPopup used. - */ - protected ColumnControlPopup createColumnControlPopup() { - return new DefaultColumnControlPopup(); - } - - -//-------------------------- updates from table propertyChangelistnere - - /** - * Adjusts internal state after table's column model property has changed. - * Handles cleanup of listeners to the old/new columnModel (Note, that - * it listens to the column model only if it can control column visibility). - * Updates content of popup. - * - * @param oldModel the old TableColumnModel we had been listening to. - */ - protected void updateFromColumnModelChange(TableColumnModel oldModel) { - if (oldModel != null && columnModelListener != null) { - oldModel.removeColumnModelListener(columnModelListener); - } - populatePopup(); - table.getColumnModel().addColumnModelListener(getColumnModelListener()); - } - - /** - * Synchs this button's enabled with table's enabled. - * - */ - protected void updateFromTableEnabledChanged() { - getAction().setEnabled(table.isEnabled()); - - } - -// ------------------------ updating the popup - /** - * Populates the popup from scratch. - * - * If applicable, creates and adds column visibility actions. Always adds - * additional actions. - */ - protected void populatePopup() { - clearAll(); - createVisibilityActions(); - addVisibilityActionItems(); - addAdditionalActionItems(); - } - - /** - * - * removes all components from the popup, making sure to release all - * columnVisibility actions. - * - */ - protected void clearAll() { - clearColumnVisibilityActions(); - getColumnControlPopup().removeAll(); - } - - - /** - * Releases actions and clears list of actions. - * - */ - protected void clearColumnVisibilityActions() { - if (columnVisibilityActions == null) - return; - for (ColumnVisibilityAction action : columnVisibilityActions) { - action.releaseColumn(); - } - columnVisibilityActions.clear(); - } - - - /** - * Adds visibility actions into the popup view. - * - * Here: delegates the list of actions to the DefaultColumnControlPopup. - *

    - * PRE: columnVisibilityActions populated before calling this. - * - */ - protected void addVisibilityActionItems() { - getColumnControlPopup().addVisibilityActionItems( - Collections.unmodifiableList(getColumnVisibilityActions())); - } - - /** - * Adds additional actions to the popup. - * Here: delegates the list of actions as returned by #getAdditionalActions() - * to the DefaultColumnControlPopup. - * Does nothing if #getColumnActions() is empty. - * - */ - protected void addAdditionalActionItems() { - getColumnControlPopup().addAdditionalActionItems( - Collections.unmodifiableList(getAdditionalActions())); - } - - - /** - * Creates and adds a ColumnVisiblityAction for every column that should be - * togglable via the column control.

    - * - * Here: all table columns contained in the TableColumnModel - - * visible and invisible columns - to createColumnVisibilityAction and - * adds all not null return values. - * - *

    - * PRE: canControl() - * - * @see #createColumnVisibilityAction - */ - protected void createVisibilityActions() { - Enumeration columns = table.getColumnModel().getColumns(); - while(columns.hasMoreElements()) { - TableColumn column = columns.nextElement(); - if (column.getHeaderValue() != null) { - ColumnVisibilityAction action = createColumnVisibilityAction(column); - if (action != null) { - getColumnVisibilityActions().add(action); - } - } - } - - } - - /** - * Creates and returns a ColumnVisibilityAction for the given - * TableColumn. The return value might be null, f.i. if the - * column should not be allowed to be toggled. - * - * @param column the TableColumn to use for the action - * @return a ColumnVisibilityAction to use for the given column, - * may be null. - */ - protected ColumnVisibilityAction createColumnVisibilityAction(TableColumn column) { - return new ColumnVisibilityAction(column); - } - - /** - * Lazyly creates and returns the List of visibility actions. - * - * @return the list of visibility actions, guaranteed to be != null. - */ - protected List getColumnVisibilityActions() { - if (columnVisibilityActions == null) { - columnVisibilityActions = new ArrayList(); - } - return columnVisibilityActions; - } - - - /** - * creates and returns a list of additional Actions to add to the popup. - * Here: the actions are looked up in the table's actionMap according - * to the keys as returned from #getColumnControlActionKeys(); - * - * @return a list containing all additional actions to include into the popup. - */ - protected List getAdditionalActions() { - List actionKeys = getColumnControlActionKeys(); - List actions = new ArrayList(); - for (Object key : actionKeys) { - actions.add(table.getActionMap().get(key)); - } - return actions; - } - - /** - * Looks up and returns action keys to access actions in the - * table's actionMap which should be included into the popup. - * - * Here: all keys with isColumnControlActionKey(key). The list - * is sorted by those keys. - * - * @return the action keys of table's actionMap entries whose - * action should be included into the popup. - */ - protected List getColumnControlActionKeys() { - Object[] allKeys = table.getActionMap().allKeys(); - List columnKeys = new ArrayList(); - for (int i = 0; i < allKeys.length; i++) { - if (isColumnControlActionKey(allKeys[i])) { - columnKeys.add((String)allKeys[i]); - } - } - // JW: this will blow for non-String keys! - // so this method is less decoupled from the - // decision method isControl than expected. - Collections.sort(columnKeys); - return columnKeys; - } - - /** - * Here: true if a String key starts with #COLUMN_CONTROL_MARKER. - * - * @param actionKey a key in the table's actionMap. - * @return a boolean to indicate whether the given actionKey maps to - * an action which should be included into the popup. - * - */ - protected boolean isColumnControlActionKey(Object actionKey) { - return (actionKey instanceof String) && - ((String) actionKey).startsWith(COLUMN_CONTROL_MARKER); - } - - - //--------------------------- init - - private void installTable(CTable table) { - this.table = table; - table.addPropertyChangeListener(getTablePropertyChangeListener()); - updateFromColumnModelChange(null); - updateFromTableEnabledChanged(); - } - - - /** - * Initialize the column control button's gui - */ - private void init() { - setFocusPainted(false); - setFocusable(false); - // this is a trick to get hold of the client prop which - // prevents closing of the popup - JComboBox box = new JComboBox(); - Object preventHide = box.getClientProperty("doNotCancelPopup"); - putClientProperty("doNotCancelPopup", preventHide); - } - - - /** - * Creates and returns the default action for this button. - * - * @param icon the Icon to use in the action. - * @return the default action. - */ - private Action createControlAction(Icon icon) { - Action control = new AbstractAction() { - - /** - * - */ - private static final long serialVersionUID = -6683797828219296451L; - - public void actionPerformed(ActionEvent e) { - togglePopup(); - } - - }; - control.putValue(Action.SMALL_ICON, icon); - return control; - } - - // -------------------------------- listeners - - /** - * Returns the listener to table's property changes. The listener is - * lazily created if necessary. - * @return the PropertyChangeListener for use with the - * table, guaranteed to be not null. - */ - protected PropertyChangeListener getTablePropertyChangeListener() { - if (tablePropertyChangeListener == null) { - tablePropertyChangeListener = createTablePropertyChangeListener(); - } - return tablePropertyChangeListener; - } - - /** - * Creates the listener to table's property changes. Subclasses are free - * to roll their own.

    - * Implementation note: this listener reacts to table's enabled and - * columnModel properties and calls the respective - * updateFromXX methodes. - * - * @return the PropertyChangeListener for use with the table. - */ - protected PropertyChangeListener createTablePropertyChangeListener() { - return new PropertyChangeListener() { - public void propertyChange(PropertyChangeEvent evt) { - if ("columnModel".equals(evt.getPropertyName())) { - updateFromColumnModelChange((TableColumnModel) evt - .getOldValue()); - } else if ("enabled".equals(evt.getPropertyName())) { - updateFromTableEnabledChanged(); - } - } - }; - } - - /** - * Returns the listener to table's column model. The listener is - * lazily created if necessary. - * @return the TableColumnModelListener for use with the - * table's column model, guaranteed to be not null. - */ - protected TableColumnModelListener getColumnModelListener() { - if (columnModelListener == null) { - columnModelListener = createColumnModelListener(); - } - return columnModelListener; - } - - /** - * Creates the listener to columnModel. Subclasses are free to roll their - * own. - *

    - * Implementation note: this listener reacts to "real" columnRemoved/-Added by - * populating the popups content from scratch. - * - * @return the TableColumnModelListener for use with the - * table's columnModel. - */ - protected TableColumnModelListener createColumnModelListener() { - return new TableColumnModelListener() { - /** Tells listeners that a column was added to the model. */ - public void columnAdded(TableColumnModelEvent e) { - populatePopup(); - } - - /** Tells listeners that a column was removed from the model. */ - public void columnRemoved(TableColumnModelEvent e) { - populatePopup(); - } - - - /** Tells listeners that a column was repositioned. */ - public void columnMoved(TableColumnModelEvent e) { - } - - /** Tells listeners that a column was moved due to a margin change. */ - public void columnMarginChanged(ChangeEvent e) { - } - - /** - * Tells listeners that the selection model of the TableColumnModel - * changed. - */ - public void columnSelectionChanged(ListSelectionEvent e) { - } - }; - } - -} // end class ColumnControlButton diff --git a/org.adempiere.ui.swing/src/org/compiere/swing/CComboBox.java b/org.adempiere.ui.swing/src/org/compiere/swing/CComboBox.java deleted file mode 100644 index 80632ed156..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/swing/CComboBox.java +++ /dev/null @@ -1,1006 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ -package org.compiere.swing; - -import java.awt.Color; -import java.awt.event.FocusEvent; -import java.awt.event.FocusListener; -import java.awt.event.InputEvent; -import java.awt.event.KeyAdapter; -import java.awt.event.KeyEvent; -import java.awt.event.MouseAdapter; -import java.awt.event.MouseEvent; -import java.awt.event.MouseListener; -import java.util.ArrayList; -import java.util.Vector; - -import javax.swing.ComboBoxModel; -import javax.swing.DefaultComboBoxModel; -import javax.swing.FocusManager; -import javax.swing.Icon; -import javax.swing.JButton; -import javax.swing.JComboBox; -import javax.swing.JComponent; -import javax.swing.MutableComboBoxModel; -import javax.swing.SwingUtilities; -import javax.swing.event.EventListenerList; -import javax.swing.event.ListDataEvent; -import javax.swing.event.ListDataListener; -import javax.swing.plaf.ComboBoxUI; -import javax.swing.text.JTextComponent; - -import org.adempiere.plaf.AdempierePLAF; -import org.compiere.plaf.CompiereComboBoxUI; -import org.compiere.util.NamePair; -import org.compiere.util.Trace; - -/** - * Adempiere Colored Combo Box. - * - * @author Jorg Janke - * @version $Id: CComboBox.java,v 1.2 2006/07/30 00:52:24 jjanke Exp $ - */ -public class CComboBox extends JComboBox - implements CEditor -{ - /** - * - */ - private static final long serialVersionUID = 5918151626085721856L; - - /** - * Creates a JComboBox that takes it's items from an - * existing ComboBoxModel. Since the - * ComboBoxModel is provided, a combo box created using - * this constructor does not create a default combo box model and - * may impact how the insert, remove and add methods behave. - * - * @param aModel the ComboBoxModel that provides the - * displayed list of items - * @see DefaultComboBoxModel - */ - public CComboBox(ComboBoxModel aModel) - { - super(aModel); - init(); - } // CComboBox - - /** - * Creates a JComboBox that contains the elements - * in the specified array. By default the first item in the array - * (and therefore the data model) becomes selected. - * - * @param items an array of objects to insert into the combo box - * @see DefaultComboBoxModel - */ - public CComboBox(final E items[]) - { - super(items); - init(); - } // CComboBox - - /** - * Creates a JComboBox that contains the elements - * in the specified array. By default the first item in the array - * (and therefore the data model) becomes selected. - * - * @param items an array of objects to insert into the combo box - * @param key set selected if exists - * @see DefaultComboBoxModel - */ - public CComboBox(final E items[], String key) - { - this(items); - if (key == null) - return; - for (int i = 0; i < 0; i++) - { - Object item = items[i]; - if (item == null) - continue; - boolean found = false; - if (item instanceof NamePair) - found = ((NamePair)item).getID().equals(key); - else - found = item.toString().equals(key); - if (found) - { - setSelectedIndex(i); - break; - } - } - } // CComboBox - - /** - * Creates a JComboBox that contains the elements - * in the specified Vector. By default the first item in the vector - * and therefore the data model) becomes selected. - * - * @param items an array of vectors to insert into the combo box - * @see DefaultComboBoxModel - */ - public CComboBox(Vector items) - { - super(items); - init(); - } // CComboBox - - /** - * Creates a JComboBox with a default data model. - * The default data model is an empty list of objects. - * Use addItem to add items. By default the first item - * in the data model becomes selected. - * - * @see DefaultComboBoxModel - */ - public CComboBox() - { - super(); - init(); - } // CComboBox - - /** Field Height */ - public static int FIELD_HIGHT = 0; - - /** Property key for auto-reduction. */ - public static final String AUTO_REDUCIBLE_PROPERTY = "autoReducible"; - - /** Property key for case sensitive auto-reduction. */ - public static final String CASE_SENSITIVE_PROPERTY = "caseSensitive"; - - /** View model for hiding showing only filtered data */ - ReducibleModel m_reducibleModel; - - /** Key listener for triggering an update the filtering model . */ - private ReducibleKeyListener reducibleKeyListener = new ReducibleKeyListener(); - - /** - * Common Init - */ - private void init() - { - FIELD_HIGHT = getPreferredSize().height; - - setEditable(true); - setAutoReducible(true); - - addMouseListener(new MouseAdapter() - { - public void mousePressed(MouseEvent me) { - if (SwingUtilities.isLeftMouseButton(me) && isAutoReducible()) - updateReducibleModel(false); - } - }); - - // when auto-reducing, the focus listener will ensure all data choices - // are shown on initial focus, and that a valid selection is in place - // when focus is lost - final JTextComponent textComponent = - (JTextComponent)getEditor().getEditorComponent(); - textComponent.addFocusListener(new FocusListener() - { - public void focusGained(FocusEvent fe) - { - if (isEditable()) - textComponent.selectAll(); - textComponent.repaint(); - } - - public void focusLost(FocusEvent fe) - { - if (isAutoReducible()) - { - Object item = m_reducibleModel.getSelectedItem(); - item = (item == null && m_reducibleModel.getSize() != 0) ? - m_reducibleModel.getElementAt(0) : item; - if (item == null) - { - updateReducibleModel(false); - if (m_reducibleModel.getSize() != 0) - item = m_reducibleModel.getElementAt(0); - else - return; - } - m_reducibleModel.setSelectedItem(item); - } - textComponent.setCaretPosition(0); - hidePopup(); - textComponent.repaint(); - } - }); - - textComponent.addMouseListener(new MouseAdapter() - { - public void mouseClicked(MouseEvent me) { - if (SwingUtilities.isLeftMouseButton(me) && - isAutoReducible() && - !isPopupVisible()) - { - updateReducibleModel(false); - showPopup(); - } - } - }); - } // init - - - /*************************************************************************/ - - /** Icon */ - private Icon m_icon = null; - - /** - * Set Icon of arrow button to icon - * @param defaultIcon Icon to be displayed - */ - public void setIcon (Icon defaultIcon) - { - if (getUI() instanceof CompiereComboBoxUI) - ((CompiereComboBoxUI)getUI()).setIcon(defaultIcon); - m_icon = defaultIcon; - } // setIcon - - - public ComboBoxModel getCompleteComboBoxModel() - { - return m_reducibleModel.getModel(); - } // getCompleteComboBoxModel - - /** - * @see javax.swing.JComboBox#setModel(javax.swing.ComboBoxModel) - */ - public void setModel(ComboBoxModel aModel) - { - m_reducibleModel = (m_reducibleModel == null) ? new ReducibleModel() : m_reducibleModel; - m_reducibleModel.setModel(aModel); - - super.setModel(m_reducibleModel); - } // setModel - - /** - * Set UI and re-set Icon for arrow button - * @param ui - */ - public void setUI (ComboBoxUI ui) - { - super.setUI(ui); - if (m_icon != null && ui instanceof CompiereComboBoxUI) - ((CompiereComboBoxUI)getUI()).setIcon(m_icon); - } // setUI - - /** - * Display Popup. - * Called from AdempiereComboPopup and allows to implement - * alternative actions than showing the popup - * @return if true, the popup should be displayed - */ - public boolean displayPopup() - { - return true; - } // displayPopup - - /*************************************************************************/ - - /** Mandatory (default false) */ - private boolean m_mandatory = false; - - /** - * Set Editor Mandatory - * @param mandatory true, if you have to enter data - */ - public void setMandatory (boolean mandatory) - { - m_mandatory = mandatory; - setBackground(false); - } // setMandatory - - /** - * Is Field mandatory - * @return true, if mandatory - */ - public boolean isMandatory() - { - return m_mandatory; - } // isMandatory - - /** - * Enable Editor - * @param rw true, if you can enter/select data - */ - public void setReadWrite (boolean rw) - { - if (super.isEnabled() != rw) - super.setEnabled (rw); - setBackground(false); - } // setReadWrite - - /** - * Is it possible to edit - * @return true, if editable - */ - public boolean isReadWrite() - { - return super.isEnabled(); - } // isReadWrite - - /** - * Set Background based on editable / mandatory / error - * @param error if true, set background to error color, otherwise mandatory/editable - */ - public void setBackground (boolean error) - { - if (error) - setBackground(AdempierePLAF.getFieldBackground_Error()); - else if (!isReadWrite()) - setBackground(AdempierePLAF.getFieldBackground_Inactive()); - else if (m_mandatory) - setBackground(AdempierePLAF.getFieldBackground_Mandatory()); - else - setBackground(AdempierePLAF.getFieldBackground_Normal()); - } // setBackground - - /** - * Set Background - * @param bg - */ - public void setBackground (Color bg) - { - if (bg.equals(getBackground())) - return; - // Set same color for editor component - teo_sarca [ 1735122 ] - if (getEditor() != null && getEditor().getEditorComponent() != null) - getEditor().getEditorComponent().setBackground(bg); - super.setBackground(bg); - } // setBackground - - /** - * Set Editor to value - * @param value value of the editor - */ - public void setValue (Object value) - { - super.setSelectedItem(value); - } // setValue - - /** - * Return Editor value - * @return current value - */ - public Object getValue() - { - return super.getSelectedItem(); - } // getValue - - /** - * Return Display Value - * @return displayed String value - */ - public String getDisplay() - { - Object o = super.getSelectedItem(); - if (o == null) - return ""; - return o.toString(); - } // getDisplay - - /** - * Add Mouse Listener - 1-4-0 Bug. - * Bug in 1.4.0 Metal: arrowButton gets Mouse Events, so add the JComboBox - * MouseListeners to the arrowButton - No context menu if right-click - * @see CompiereComboBoxUI#installUI(JComponent) - * @param ml - */ - public void addMouseListener (MouseListener ml) - { - super.addMouseListener(ml); - // ignore calls from javax.swing.plaf.basic.BasicComboBoxUI.installListeners(BasicComboBoxUI.java:271) - if (getUI() instanceof CompiereComboBoxUI && !Trace.getCallerClass(1).startsWith("javax")) - { - JButton b = ((CompiereComboBoxUI)getUI()).getArrowButton(); - if (b != null) - b.addMouseListener(ml); - } - //begin vpj-cd e-evolution - if (getUI() instanceof org.adempiere.plaf.AdempiereComboBoxUI && !Trace.getCallerClass(1).startsWith("javax")) - { - JButton b = ((org.adempiere.plaf.AdempiereComboBoxUI)getUI()).getArrowButton(); - if (b != null) - b.addMouseListener(ml); - } - //end vpj-cd e-evolution - } // addMouseListener - - /** - * Remove Mouse Listener. - * @param ml - */ - public void removeMouseListener (MouseListener ml) - { - super.removeMouseListener(ml); - if (getUI() instanceof CompiereComboBoxUI) - { - JButton b = ((CompiereComboBoxUI)getUI()).getArrowButton(); - if (b != null) - b.removeMouseListener(ml); - } - } // removeMouseListener - - /** - * Set Action Command - * @param actionCommand command - */ - public void setActionCommand (String actionCommand) - { - super.setActionCommand (actionCommand); - if (getName() == null && actionCommand != null && actionCommand.length() > 0) - setName(actionCommand); - } // setActionCommand - - /** - * Called only when auto-reducing. By default, does a case insensitive - * string search for a match in the string representation of the given - * element. - * - * @param element an element in the combo box model - * - * @return true if the choice is to be displayed in the popup menu - */ - protected boolean isMatchingFilter(Object element) - { - String str = (element != null) ? element.toString().trim() : ""; - str = isCaseSensitive() ? str : str.toLowerCase(); - - return str.indexOf(m_reducibleModel.getMatchingFilter()) > -1; - } - - /** - * Is the combo box auto-reducible? - * - * @return true if isAutoReducible() - */ - public boolean isAutoReducible() - { - Boolean b = (Boolean)getClientProperty(AUTO_REDUCIBLE_PROPERTY); - return (b != null) && b.booleanValue(); - } - - /** - * Set whether the combo box is auto-reducible. The combo box must also be editable - * for auto-reduction to fully functional. Auto-reduction of data will preclude - * the ability for users to enter in their own choices. - * - * @param autoreducible true will activate auto-reduction of choices when user enters text - */ - public void setAutoReducible(boolean autoreducible) - { - if (isAutoReducible() != autoreducible) - { - putClientProperty(AUTO_REDUCIBLE_PROPERTY, Boolean.valueOf(autoreducible)); - updateReducibleModel(false); - - JTextComponent textComponent = - (JTextComponent)getEditor().getEditorComponent(); - if (autoreducible) - textComponent.addKeyListener(reducibleKeyListener); - else - textComponent.removeKeyListener(reducibleKeyListener); - } - } - - /** - * Is the auto-reduction case sensitive? - * - * @return true if case sensitive - */ - public boolean isCaseSensitive() - { - Boolean b = (Boolean)getClientProperty(CASE_SENSITIVE_PROPERTY); - return (b != null) && b.booleanValue(); - } - - /* (non-Javadoc) - * @see javax.swing.JComboBox#removeAllItems() - */ - public void removeAllItems() - { - m_reducibleModel.removeAllElements(); - } - - /** - * Set whether auto-reduction is case sensitive. - * - * @param caseSensitive true will make auto-reduction is case sensitive - */ - public void setCaseSensitive(boolean caseSensitive) - { - putClientProperty(CASE_SENSITIVE_PROPERTY, Boolean.valueOf(caseSensitive)); - } - - /** - * Updates the auto-reduction model. - * - * @param filtering true if the underlying data model should be filtered - */ - void updateReducibleModel(boolean filtering) - { - if (filtering || - m_reducibleModel.getSize() != m_reducibleModel.getModel().getSize()) - { - if (getParent() != null) - hidePopup(); - - // remember to caret position - JTextComponent textComponent = - (JTextComponent)getEditor().getEditorComponent(); - int pos = textComponent.getCaretPosition(); - m_reducibleModel.setFilter(textComponent.getText()); - - // update the model - m_reducibleModel.updateModel(filtering); - - // reset the caret - textComponent.setText(m_reducibleModel.getFilter()); - textComponent.setCaretPosition(pos); - - // ensure the combo box is resized to match the popup, if necessary - if (getParent() != null) - { - getParent().validate(); - getParent().repaint(); - - if (isShowing() && m_reducibleModel.getSize() > 0) { - // only show the popup if there is something to show - showPopup(); - } - } - } - } - - /** - * A view adapter model to hide filtered choices in the underlying combo box model. - */ - private class ReducibleModel implements MutableComboBoxModel, ListDataListener - { - /** - * Default constructor. Creates a ReducibleModel. - */ - public ReducibleModel() - { - } - - /** The wrapped data model. */ - private ComboBoxModel m_model; - - /** The wrapped data model. */ - private EventListenerList m_listenerList = new EventListenerList(); - - /** The filtered data. */ - private ArrayList m_visibleData = new ArrayList(); - - /** The filtered data. */ - private ArrayList m_modelData = new ArrayList(); - - /** The current filter. */ - private String m_filter = ""; - - /** The cached filter for case insensitive filtering. */ - private String m_lcFilter = ""; - - /** - * Pass through to the wrapped model if underlying model is MutableComboBoxModel. - * - * @see javax.swing.DefaultComboBoxModel#addElement(java.lang.Object) - */ - public void addElement(T anObject) - { - checkMutableComboBoxModel(); - m_modelData.add(anObject); - ((MutableComboBoxModel)m_model).addElement(anObject); - } - - /* (non-Javadoc) - * @see javax.swing.ListModel#addListDataListener(javax.swing.event.ListDataListener) - */ - public void addListDataListener(ListDataListener ldl) - { - m_listenerList.remove(ListDataListener.class, ldl); - m_listenerList.add(ListDataListener.class, ldl); - } - - /** - * Checks that the dataModel is an instance of - * MutableComboBoxModel. If not, it throws an exception. - * - * @exception RuntimeException if dataModel is not an - * instance of MutableComboBoxModel. - */ - void checkMutableComboBoxModel() - { - if ( !(m_model instanceof MutableComboBoxModel) ) - throw new RuntimeException("Cannot use this method with a non-Mutable data model."); - } - - /* (non-Javadoc) - * @see javax.swing.event.ListDataListener#contentsChanged(javax.swing.event.ListDataEvent) - */ - public void contentsChanged(ListDataEvent lde) - { - updateDataModel(); - // IDEMPIERE-574 - Swing AutoReducible ComboBox not reduced when used with cursor keys - // tbayen 2013-01-20 - updateModel(isAutoReducible()); - - if (isPopupVisible()) - { - hidePopup(); - showPopup(); - } - } - - /** - * - */ - private void fireContentsChanged() - { - ListDataEvent lde = null; - for (ListDataListener ldl : getListDataListeners()) - { - lde = (lde == null) ? - new ListDataEvent(this, ListDataEvent.CONTENTS_CHANGED, 0, getSize()) : lde; - ldl.contentsChanged(lde); - } - } - - /* (non-Javadoc) - * @see javax.swing.ListModel#getElementAt(int) - */ - public T getElementAt(int index) - { - return m_visibleData.get(index); - } - - /** - * Return the current filter. - * - * @return the filter - */ - public String getFilter() - { - return m_filter; - } - - /** - * - */ - public ListDataListener[] getListDataListeners() - { - return (ListDataListener[])m_listenerList.getListeners(ListDataListener.class); - } - - /** - * @return the filter to use for matching; hecks case sensistivity - */ - protected String getMatchingFilter() - { - return isCaseSensitive() ? m_filter : m_lcFilter; - } - - /** - * @return the wrapped model - */ - public ComboBoxModel getModel() - { - return m_model; - } - - /** - * @return the selected item in the wrapped model - * - * @see javax.swing.DefaultComboBoxModel#getSelectedItem() - */ - public Object getSelectedItem() - { - return m_model.getSelectedItem(); - } - - /* (non-Javadoc) - * @see javax.swing.ListModel#getSize() - */ - public int getSize() - { - return m_visibleData.size(); - } - - /** - * Pass through to the wrapped model if underlying model is MutableComboBoxModel. - * - * @see javax.swing.DefaultComboBoxModel#insertElementAt(java.lang.Object, int) - */ - public void insertElementAt(T anObject, int index) - { - checkMutableComboBoxModel(); - m_modelData.add(index, anObject); - ((MutableComboBoxModel)m_model).insertElementAt(anObject, index); - } - - /** - * Pass through to the wrapped model if underlying model is MutableComboBoxModel. - * - * @see javax.swing.event.ListDataListener#intervalAdded(javax.swing.event.ListDataEvent) - */ - public void intervalAdded(ListDataEvent lde) - { - updateDataModel(); - updateModel(false); - } - - /** - * Pass through to the wrapped model if underlying model is MutableComboBoxModel. - * - * @see javax.swing.event.ListDataListener#intervalRemoved(javax.swing.event.ListDataEvent) - */ - public void intervalRemoved(ListDataEvent lde) - { - updateDataModel(); - updateModel(false); - } - - /** - * - */ - public void removeAllElements() - { - checkMutableComboBoxModel(); - - ListDataListener[] listeners = getListDataListeners(); - for (int i = 0; i < listeners.length; i++) - removeListDataListener(listeners[i]); - m_model.removeListDataListener(this); - - m_modelData.clear(); - m_visibleData.clear(); - while (m_model.getSize() > 0) - ((MutableComboBoxModel)m_model).removeElementAt(0); - - for (ListDataListener ldl : listeners) - addListDataListener(ldl); - m_model.addListDataListener(this); - - updateModel(false); - } - - /** - * Pass through to the wrapped model if underlying model is MutableComboBoxModel. - * - * @see javax.swing.DefaultComboBoxModel#removeElement(java.lang.Object) - */ - public void removeElement(Object anObject) - { - checkMutableComboBoxModel(); - m_modelData.remove(anObject); - m_visibleData.clear(); - ((MutableComboBoxModel)m_model).removeElement(anObject); - } - - /** - * Pass through to the wrapped model if underlying model is MutableComboBoxModel. - * - * @see javax.swing.DefaultComboBoxModel#removeElementAt(int) - */ - public void removeElementAt(int index) - { - checkMutableComboBoxModel(); - m_modelData.remove(index); - m_visibleData.clear(); - ((MutableComboBoxModel)m_model).removeElementAt(index); - } - - /* (non-Javadoc) - * @see javax.swing.ListModel#removeListDataListener(javax.swing.event.ListDataListener) - */ - public void removeListDataListener(ListDataListener ldl) - { - m_listenerList.remove(ListDataListener.class, ldl); - } - - /** - * @param filter the filter to set - */ - public void setFilter(String filter) - { - this.m_filter = (filter != null) ? filter : ""; - m_lcFilter = filter.trim().toLowerCase(); - } - - /** - * Set the wrapped combo box model. - * - * @param model the model to set - */ - public void setModel(ComboBoxModel model) - { - if (this.m_model != null) - this.m_model.removeListDataListener(this); - - this.m_model = model; - updateDataModel(); - m_filter = ""; - - model.addListDataListener(this); - updateModel(false); - } - - /** - * Set the selected item in the wrapped model. - * - * @see javax.swing.DefaultComboBoxModel#setSelectedItem(java.lang.Object) - */ - public void setSelectedItem(Object anObject) - { - if (anObject == null || m_modelData.contains(anObject)) - m_model.setSelectedItem(anObject); - } - - /** - * Updates the view model based on whether filtering or not. - * - * @param filtering true if the underlying model is to be filtered - */ - public void updateDataModel() - { - m_modelData.clear(); - int size = m_model.getSize(); - for (int i = 0; i < size; i++) - m_modelData.add(m_model.getElementAt(i)); - } - - /** - * Updates the view model based on whether filtering or not. - * - * @param filtering true if the underlying model is to be filtered - */ - public void updateModel(boolean filtering) - { - boolean includeAll = !filtering || !isAutoReducible() || "".equals(m_lcFilter); - if (includeAll) - { - m_visibleData.clear(); - m_visibleData.addAll(m_modelData); - } - else - { - m_visibleData.clear(); - Object selected = getSelectedItem(); - ListDataListener[] listeners = getListDataListeners(); - for (int i = 0; i < listeners.length; i++) - removeListDataListener(listeners[i]); - m_model.removeListDataListener(this); - - - int size = m_model.getSize(); - - for (int i = 0; i < size; i++) - { - T element = m_model.getElementAt(i); - if (element == null || isMatchingFilter(element)) - { - m_visibleData.add(element); - } - } - - if (m_visibleData.contains(selected) || selected == null) - setSelectedItem(selected); - - for (ListDataListener ldl : listeners) - addListDataListener(ldl); - m_model.addListDataListener(this); - } - - fireContentsChanged(); - } - } // ReducibleModel - - /** - * Key listener for editor's text compontent to trigger auto-reduction. Only - * used when auto-reduction is enabled. - */ - class ReducibleKeyListener extends KeyAdapter - { - /** Invokes autoreduction. */ - private Runnable m_invoker = new Runnable() - { - public void run() - { - updateReducibleModel(true); - } - }; - - /** Visibly updates the popup menu. */ - private Runnable m_updateMenu = new Runnable() - { - public void run() - { - hidePopup(); - getParent().validate(); - getParent().repaint(); - showPopup(); - } - }; - - /* (non-Javadoc) - * @see java.awt.event.KeyAdapter#keyPressed(java.awt.event.KeyEvent) - */ - public void keyPressed(KeyEvent ke) - { - if (ke.getKeyCode() != KeyEvent.VK_CONTROL && - ke.getKeyCode() != KeyEvent.VK_ALT && - ke.getKeyCode() != KeyEvent.VK_SHIFT && - ( ke.getModifiersEx() & InputEvent.ALT_DOWN_MASK ) == 0 ) - { - if (ke.getKeyCode() == KeyEvent.VK_ENTER || - ke.getKeyCode() == KeyEvent.VK_TAB) - { - // enter key pressed, so complete editing and select item - Object selObject = getSelectedItem(); - selObject = (selObject == null && getItemCount() > 0) ? getItemAt(0) : selObject; - setSelectedItem(selObject); - getEditor().setItem(getSelectedItem()); - } - else if (ke.getKeyCode() == KeyEvent.VK_ESCAPE) - { - // escape key ends editing and rejects focus of text editor - FocusManager.getCurrentManager().upFocusCycle(); - } - else if (ke.getKeyCode() == KeyEvent.VK_UP || - ke.getKeyCode() == KeyEvent.VK_KP_UP || - ke.getKeyCode() == KeyEvent.VK_DOWN || - ke.getKeyCode() == KeyEvent.VK_KP_DOWN) - { - // up or down selects new value - SwingUtilities.invokeLater(m_updateMenu); - } - else if (ke.getKeyChar() == KeyEvent.CHAR_UNDEFINED) { - ; // ignore keys not modifying text - } - else - { - // key typed, so filter - SwingUtilities.invokeLater(m_invoker); - setSelectedItem(null); - } - } - } - } // ReducibleKeyListener - - // IDEMPIERE 90 - /** show only short list items or all ? */ - private boolean m_ShortListSearch = false; - - /** set the editor to return only short list items */ - public void setShortListSearch (boolean shortList) - { - m_ShortListSearch = shortList; - } // setShortListSearch - - /** does the search should return only short list items ? */ - public boolean isShortListSearch() - { - return m_ShortListSearch; - } // isShortListSearch - - // IDEMPIERE 90 -} // CComboBox diff --git a/org.adempiere.ui.swing/src/org/compiere/swing/CComboBoxEditable.java b/org.adempiere.ui.swing/src/org/compiere/swing/CComboBoxEditable.java deleted file mode 100644 index 2ac9e3b366..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/swing/CComboBoxEditable.java +++ /dev/null @@ -1,348 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ -package org.compiere.swing; - -import java.awt.Color; -import java.awt.event.MouseListener; -import java.util.Vector; - -import javax.swing.ComboBoxModel; -import javax.swing.DefaultComboBoxModel; -import javax.swing.Icon; -import javax.swing.JButton; -import javax.swing.JComboBox; -import javax.swing.JComponent; -import javax.swing.plaf.ComboBoxUI; - -import org.adempiere.plaf.AdempierePLAF; -import org.compiere.plaf.CompiereComboBoxUI; -import org.compiere.util.NamePair; -import org.compiere.util.Trace; - -/** - * Adempiere Colored Combo Box. - * - * @author Jorg Janke - * @version $Id: CComboBoxEditable.java,v 1.2 2006/07/30 00:52:24 jjanke Exp $ - */ -public class CComboBoxEditable extends JComboBox - implements CEditor -{ - /** - * - */ - private static final long serialVersionUID = -3036970630981224309L; - - /** - * Creates a JComboBox that takes it's items from an - * existing ComboBoxModel. Since the - * ComboBoxModel is provided, a combo box created using - * this constructor does not create a default combo box model and - * may impact how the insert, remove and add methods behave. - * - * @param aModel the ComboBoxModel that provides the - * displayed list of items - * @see DefaultComboBoxModel - */ - public CComboBoxEditable(ComboBoxModel aModel) - { - super(aModel); - init(); - } // CComboBoxEditable - - /** - * Creates a JComboBox that contains the elements - * in the specified array. By default the first item in the array - * (and therefore the data model) becomes selected. - * - * @param items an array of objects to insert into the combo box - * @see DefaultComboBoxModel - */ - public CComboBoxEditable(final E items[]) - { - super(items); - init(); - } // CComboBoxEditable - - /** - * Creates a JComboBox that contains the elements - * in the specified array. By default the first item in the array - * (and therefore the data model) becomes selected. - * - * @param items an array of objects to insert into the combo box - * @param key set selected if exists - * @see DefaultComboBoxModel - */ - public CComboBoxEditable(final E items[], String key) - { - this(items); - if (key == null) - return; - for (int i = 0; i < 0; i++) - { - Object item = items[i]; - if (item == null) - continue; - boolean found = false; - if (item instanceof NamePair) - found = ((NamePair)item).getID().equals(key); - else - found = item.toString().equals(key); - if (found) - { - setSelectedIndex(i); - break; - } - } - } // CComboBoxEditable - - /** - * Creates a JComboBox that contains the elements - * in the specified Vector. By default the first item in the vector - * and therefore the data model) becomes selected. - * - * @param items an array of vectors to insert into the combo box - * @see DefaultComboBoxModel - */ - public CComboBoxEditable(Vector items) - { - super(items); - init(); - } // CComboBoxEditable - - /** - * Creates a JComboBox with a default data model. - * The default data model is an empty list of objects. - * Use addItem to add items. By default the first item - * in the data model becomes selected. - * - * @see DefaultComboBoxModel - */ - public CComboBoxEditable() - { - super(); - init(); - } // CComboBoxEditable - - /** Field Height */ - public static int FIELD_HIGHT = 0; - - /** - * Common Init - */ - private void init() - { - FIELD_HIGHT = getPreferredSize().height; - } // init - - - /*************************************************************************/ - - /** Icon */ - private Icon m_icon = null; - - /** - * Set Icon of arrow button to icon - * @param defaultIcon Icon to be displayed - */ - public void setIcon (Icon defaultIcon) - { - if (getUI() instanceof CompiereComboBoxUI) - ((CompiereComboBoxUI)getUI()).setIcon(defaultIcon); - m_icon = defaultIcon; - } // setIcon - - /** - * Set UI and re-set Icon for arrow button - * @param ui - */ - public void setUI (ComboBoxUI ui) - { - super.setUI(ui); - if (m_icon != null && ui instanceof CompiereComboBoxUI) - ((CompiereComboBoxUI)getUI()).setIcon(m_icon); - } // setUI - - /** - * Display Popup. - * Called from AdempiereComboPopup and allows to implement - * alternative actions than showing the popup - * @return if true, the popup should be displayed - */ - public boolean displayPopup() - { - return true; - } // displayPopup - - /*************************************************************************/ - - /** Mandatory (default false) */ - private boolean m_mandatory = false; - - /** - * Set Editor Mandatory - * @param mandatory true, if you have to enter data - */ - public void setMandatory (boolean mandatory) - { - m_mandatory = mandatory; - setBackground(false); - } // setMandatory - - /** - * Is Field mandatory - * @return true, if mandatory - */ - public boolean isMandatory() - { - return m_mandatory; - } // isMandatory - - /** - * Enable Editor - * @param rw true, if you can enter/select data - */ - public void setReadWrite (boolean rw) - { - if (super.isEnabled() != rw) - super.setEnabled (rw); - setBackground(false); - } // setReadWrite - - /** - * Is it possible to edit - * @return true, if editable - */ - public boolean isReadWrite() - { - return super.isEnabled(); - } // isReadWrite - - /** - * Set Background based on editable / mandatory / error - * @param error if true, set background to error color, otherwise mandatory/editable - */ - public void setBackground (boolean error) - { - if (error) - setBackground(AdempierePLAF.getFieldBackground_Error()); - else if (!isReadWrite()) - setBackground(AdempierePLAF.getFieldBackground_Inactive()); - else if (m_mandatory) - setBackground(AdempierePLAF.getFieldBackground_Mandatory()); - else - setBackground(AdempierePLAF.getFieldBackground_Normal()); - } // setBackground - - /** - * Set Background - * @param bg - */ - public void setBackground (Color bg) - { - if (bg.equals(getBackground())) - return; - // Set same color for editor component - teo_sarca [ 1735122 ] - if (getEditor() != null && getEditor().getEditorComponent() != null) - getEditor().getEditorComponent().setBackground(bg); - super.setBackground(bg); - } // setBackground - - /** - * Set Editor to value - * @param value value of the editor - */ - public void setValue (Object value) - { - super.setSelectedItem(value); - } // setValue - - /** - * Return Editor value - * @return current value - */ - public Object getValue() - { - return super.getSelectedItem(); - } // getValue - - /** - * Return Display Value - * @return displayed String value - */ - public String getDisplay() - { - Object o = super.getSelectedItem(); - if (o == null) - return ""; - return o.toString(); - } // getDisplay - - /** - * Add Mouse Listener - 1-4-0 Bug. - * Bug in 1.4.0 Metal: arrowButton gets Mouse Events, so add the JComboBox - * MouseListeners to the arrowButton - No context menu if right-click - * @see CompiereComboBoxUI#installUI(JComponent) - * @param ml - */ - public void addMouseListener (MouseListener ml) - { - super.addMouseListener(ml); - // ignore calls from javax.swing.plaf.basic.BasicComboBoxUI.installListeners(BasicComboBoxUI.java:271) - if (getUI() instanceof CompiereComboBoxUI && !Trace.getCallerClass(1).startsWith("javax")) - { - JButton b = ((CompiereComboBoxUI)getUI()).getArrowButton(); - if (b != null) - b.addMouseListener(ml); - } - //begin vpj-cd e-evolution - if (getUI() instanceof org.adempiere.plaf.AdempiereComboBoxUI && !Trace.getCallerClass(1).startsWith("javax")) - { - JButton b = ((org.adempiere.plaf.AdempiereComboBoxUI)getUI()).getArrowButton(); - if (b != null) - b.addMouseListener(ml); - } - //end vpj-cd e-evolution - } // addMouseListener - - /** - * Remove Mouse Listener. - * @param ml - */ - public void removeMouseListener (MouseListener ml) - { - super.removeMouseListener(ml); - if (getUI() instanceof CompiereComboBoxUI) - { - JButton b = ((CompiereComboBoxUI)getUI()).getArrowButton(); - if (b != null) - b.removeMouseListener(ml); - } - } // removeMouseListener - - /** - * Set Action Command - * @param actionCommand command - */ - public void setActionCommand (String actionCommand) - { - super.setActionCommand (actionCommand); - if (getName() == null && actionCommand != null && actionCommand.length() > 0) - setName(actionCommand); - } // setActionCommand - -} // CComboBoxEditable diff --git a/org.adempiere.ui.swing/src/org/compiere/swing/CDialog.java b/org.adempiere.ui.swing/src/org/compiere/swing/CDialog.java deleted file mode 100644 index 9dec64fdd4..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/swing/CDialog.java +++ /dev/null @@ -1,305 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ -package org.compiere.swing; - -import java.awt.Container; -import java.awt.Dialog; -import java.awt.Frame; -import java.awt.GraphicsConfiguration; -import java.awt.HeadlessException; -import java.awt.Window; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.awt.event.KeyEvent; -import java.awt.event.MouseEvent; -import java.awt.event.MouseListener; - -import javax.swing.AbstractAction; -import javax.swing.JDialog; -import javax.swing.JPanel; -import javax.swing.KeyStroke; - -/** - * Conveniance Dialog Class. - * Adempiere Background + Dispose on Close - * Implementing empty Action and Mouse Listener - * - * @author Jorg Janke - * @version $Id: CDialog.java,v 1.3 2006/07/30 00:52:24 jjanke Exp $ - */ -public class CDialog extends JDialog - implements ActionListener, MouseListener -{ - /** - * - */ - private static final long serialVersionUID = -1698027199524570661L; - - /** - * CDialog - * @throws HeadlessException - */ - public CDialog() throws HeadlessException - { - this((Frame)null, false); - } - /** - * CDialog - * @param owner - * @throws HeadlessException - */ - public CDialog(Frame owner) throws HeadlessException - { - this (owner, false); - } - /** - * CDialog - * @param owner - * @param modal - * @throws HeadlessException - */ - public CDialog(Frame owner, boolean modal) throws HeadlessException - { - this (owner, null, modal); - } - /** - * CDialog - * @param owner - * @param title - * @throws HeadlessException - */ - public CDialog(Frame owner, String title) throws HeadlessException - { - this (owner, title, false); - } - /** - * CDialog - * @param owner - * @param title - * @param modal - * @throws HeadlessException - */ - public CDialog(Frame owner, String title, boolean modal) throws HeadlessException - { - super(owner, title, modal); - } - /** - * CDialog - * @param owner - * @param title - * @param modal - * @param gc - */ - public CDialog(Frame owner, String title, boolean modal, GraphicsConfiguration gc) - { - super(owner, title, modal, gc); - } - /** - * CDialog - * @param owner - * @throws HeadlessException - */ - public CDialog(Dialog owner) throws HeadlessException - { - this (owner, false); - } - /** - * CDialog - * @param owner - * @param modal - * @throws HeadlessException - */ - public CDialog(Dialog owner, boolean modal) throws HeadlessException - { - this(owner, null, modal); - } - /** - * CDialog - * @param owner - * @param title - * @throws HeadlessException - */ - public CDialog(Dialog owner, String title) throws HeadlessException - { - this(owner, title, false); - } - /** - * CDialog - * @param owner - * @param title - * @param modal - * @throws HeadlessException - */ - public CDialog(Dialog owner, String title, boolean modal) throws HeadlessException - { - super(owner, title, modal); - } - /** - * CDialog - * @param owner - * @param title - * @param modal - * @param gc - * @throws HeadlessException - */ - public CDialog(Dialog owner, String title, boolean modal, GraphicsConfiguration gc) throws HeadlessException - { - super(owner, title, modal, gc); - } - - /** - * Initialize. - * Install ALT-Pause - */ - protected void dialogInit() - { - super.dialogInit(); - setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE); - setTitle(getTitle()); // remove Mn - // - Container c = getContentPane(); - if (c instanceof JPanel) - { - JPanel panel = (JPanel)c; - panel.getActionMap().put(ACTION_DISPOSE, s_dialogAction); - panel.getInputMap(JPanel.WHEN_IN_FOCUSED_WINDOW).put(s_disposeKeyStroke, ACTION_DISPOSE); - } - } // init - - - /************************************************************************** - * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent) - * @param e - */ - public void actionPerformed(ActionEvent e) - { - } - - /** - * @see java.awt.event.MouseListener#mouseClicked(java.awt.event.MouseEvent) - * @param e - */ - public void mouseClicked(MouseEvent e) - { - } - - /** - * @see java.awt.event.MouseListener#mouseEntered(java.awt.event.MouseEvent) - * @param e - */ - public void mouseEntered(MouseEvent e) - { - } - - /** - * @see java.awt.event.MouseListener#mouseExited(java.awt.event.MouseEvent) - * @param e - */ - public void mouseExited(MouseEvent e) - { - } - - /** - * @see java.awt.event.MouseListener#mousePressed(java.awt.event.MouseEvent) - * @param e - */ - public void mousePressed(MouseEvent e) - { - } - - /** - * @see java.awt.event.MouseListener#mouseReleased(java.awt.event.MouseEvent) - * @param e - */ - public void mouseReleased(MouseEvent e) - { - } - - /** - * Set Title - * @param title title - */ - public void setTitle(String title) - { - if (title != null) - { - int pos = title.indexOf('&'); - if (pos != -1 && title.length() > pos) // We have a nemonic - { - int mnemonic = title.toUpperCase().charAt(pos+1); - if (mnemonic != ' ') - title = title.substring(0, pos) + title.substring(pos+1); - } - } - super.setTitle(title); - } // setTitle - - /** Dispose Action Name */ - protected static String ACTION_DISPOSE = "CDialogDispose"; - /** Action */ - protected static DialogAction s_dialogAction = new DialogAction(ACTION_DISPOSE); - /** ALT-EXCAPE */ - protected static KeyStroke s_disposeKeyStroke = - KeyStroke.getKeyStroke(KeyEvent.VK_PAUSE, ActionEvent.ALT_MASK); - - /** - * Adempiere Dialog Action - * - * @author Jorg Janke - * @version $Id: CDialog.java,v 1.3 2006/07/30 00:52:24 jjanke Exp $ - */ - static class DialogAction extends AbstractAction - { - /** - * - */ - private static final long serialVersionUID = -1502992970807699945L; - - DialogAction (String actionName) - { - super(actionName); - putValue(AbstractAction.ACTION_COMMAND_KEY, actionName); - } // DialogAction - - /** - * Action Listener - * @param e event - */ - public void actionPerformed (ActionEvent e) - { - if (ACTION_DISPOSE.equals(e.getActionCommand())) - { - Object source = e.getSource(); - while (source != null) - { - if (source instanceof Window) - { - ((Window)source).dispose(); - return; - } - if (source instanceof Container) - source = ((Container)source).getParent(); - else - source = null; - } - } - else - System.out.println("Action: " + e); - } // actionPerformed - } // DialogAction - -} // CDialog diff --git a/org.adempiere.ui.swing/src/org/compiere/swing/CEditor.java b/org.adempiere.ui.swing/src/org/compiere/swing/CEditor.java deleted file mode 100644 index 514bed7534..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/swing/CEditor.java +++ /dev/null @@ -1,81 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ -package org.compiere.swing; - -/** - * Adempiere Editor interface - * - * @author Jorg Janke - * @version $Id: CEditor.java,v 1.2 2006/07/30 00:52:24 jjanke Exp $ - */ -public interface CEditor -{ - /** - * Enable Editor - * @param rw true, if you can enter/select data - */ - public void setReadWrite (boolean rw); - - /** - * Is it possible to edit - * @return true, if editable - */ - public boolean isReadWrite(); - - /** - * Set Editor Mandatory - * @param mandatory true, if you have to enter data - */ - public void setMandatory (boolean mandatory); - - /** - * Is Field mandatory - * @return true, if mandatory - */ - public boolean isMandatory(); - - /** - * Set Background based on editable / mandatory / error - * @param error if true, set background to error color, otherwise mandatory/editable - */ - public void setBackground (boolean error); - - /** - * Set Visible - * @param visible true if field is to be shown - */ - public void setVisible (boolean visible); - - /** - * Set Editor to value - * @param value value of the editor - */ - public void setValue (Object value); - - /** - * Return Editor value - * @return current value - */ - public Object getValue(); - - /** - * Return Display Value - * @return displayed String value - */ - public String getDisplay(); - -} // CEditor diff --git a/org.adempiere.ui.swing/src/org/compiere/swing/CField.java b/org.adempiere.ui.swing/src/org/compiere/swing/CField.java deleted file mode 100644 index 249c9551da..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/swing/CField.java +++ /dev/null @@ -1,334 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ -package org.compiere.swing; - -import java.awt.Color; -import java.awt.Dialog; -import java.awt.Frame; -import java.awt.Window; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.lang.reflect.Constructor; -import java.text.DateFormat; -import java.text.DecimalFormat; -import java.text.NumberFormat; -import java.text.SimpleDateFormat; -import java.util.regex.Pattern; - -import javax.swing.Icon; -import javax.swing.JComboBox; -import javax.swing.JOptionPane; -import javax.swing.SwingUtilities; -import javax.swing.plaf.TextUI; - -import org.adempiere.plaf.AdempierePLAF; - -/** - * Adempiere Colored Field with external popup editor. - * It extends ComboBox for UI consistency purposes - * - * @author Jorg Janke - * @version $Id: CField.java,v 1.2 2006/07/30 00:52:24 jjanke Exp $ - */ -public class CField extends JComboBox - implements CEditor, ActionListener -{ - - /** - * - */ - private static final long serialVersionUID = -2570380982649145678L; - - public static CField createNumeric(NumberFormat format) - { - return null; - } - public static CField createNumeric() - { - return createNumeric(new DecimalFormat()); - } - public static CField createDate(DateFormat format) - { - return null; - } - public static CField createDate() - { - return createDate(new SimpleDateFormat()); - } - public static CField createText(Pattern p) - { - return null; - } - public static CField createText(int length) - { - return null; - } - - /*************************************************************************/ - - public CField () - { - this (null, null, ""); - } - - /** - * Construct Adempiere Field with external popup editor - * - * @param editor the (validating) editor - * @param cFieldPopup the popup dialog - * @param title title for popup - */ - public CField (CFieldEditor editor, Class cFieldPopup, String title) - { - super(new Object[] {"1", "2"}); - if (editor != null) -// setEditor (editor); - setEditable(true); - m_title = title; - - // Check popup - if (cFieldPopup != null) - { - Class[] interfaces = cFieldPopup.getInterfaces(); - boolean found = false; - for (int i = 0; i < interfaces.length; i++) - { - if (interfaces[i].equals(CFieldPopup.class)) - { - found = true; - break; - } - } - if (!found) - throw new IllegalArgumentException ("Popup class must be CFieldPopup"); - } - super.addActionListener(this); - } // CField - - private CFieldEditor m_editor = null; - private Class m_popupClass = null; - private String m_title = null; - private Object m_oldValue = null; - - /*************************************************************************/ - - /** Icon */ - private Icon m_icon = null; - - /** - * Set Icon of arrow button to icon - * @param defaultIcon Icon to be displayed - */ - public void setIcon (Icon defaultIcon) - { - m_icon = defaultIcon; - } // setIcon - - /** - * Get Icon of arrow button to icon - * @return defaultIcon Icon to be displayed - */ - public Icon getIcon () - { - return m_icon; - } // getIcon - - - /** - * Set UI and re-set Icon for arrow button - * @param ui - */ - public void setUI (TextUI ui) - { - super.setUI(ui); - } // setUI - - /** - * Display Popup. - * Called from AdempiereComboPopup and allows to implement - * alternative actions than showing the popup - * @return if true, the popup should be displayed - */ - public boolean displayPopup() - { - if (m_popupClass == null) - return false; - // - try - { - // Get Owner & Create Popup Instance - Window win = SwingUtilities.getWindowAncestor(this); - CFieldPopup popup = null; - if (win instanceof Dialog) - { - Constructor constructor = m_popupClass.getConstructor - (new Class[] {Dialog.class, String.class, Boolean.class}); - popup = (CFieldPopup)constructor.newInstance(new Object[] - {(Dialog)win, m_title, Boolean.TRUE}); - } - else if (win instanceof Frame) - { - Constructor constructor = m_popupClass.getConstructor - (new Class[] {Frame.class, String.class, Boolean.class}); - popup = (CFieldPopup)constructor.newInstance(new Object[] - {(Frame)win, m_title, Boolean.TRUE}); - } - if (popup == null) - return false; - // Start Popup - popup.setValue (m_editor.getItem()); - popup.setFormat (m_editor.getFormat()); - popup.show(); - m_editor.setItem (popup.getValue()); - popup = null; - } - catch (Exception e) - { - notifyUser (e); - } - // - return false; - } // displayPopup - - /** - * Notify User of a Ptoblem with starting popup - * @param e Exception - */ - public void notifyUser (Exception e) - { - JOptionPane.showMessageDialog(this, e.toString(), "Field Error", JOptionPane.ERROR_MESSAGE); - } // notify User - - /*************************************************************************/ - - /** Mandatory (default false) */ - private boolean m_mandatory = false; - - /** - * Set Editor Mandatory - * @param mandatory true, if you have to enter data - */ - public void setMandatory (boolean mandatory) - { - m_mandatory = mandatory; - setBackground(false); - } // setMandatory - - /** - * Is Field mandatory - * @return true, if mandatory - */ - public boolean isMandatory() - { - return m_mandatory; - } // isMandatory - - /** - * Enable Editor - * @param rw true, if you can enter/select data - */ - public void setReadWrite (boolean rw) - { - if (super.isEnabled() != rw) - super.setEnabled (rw); - setBackground(false); - } // setReadWrite - - /** - * Is it possible to edit - * @return true, if editable - */ - public boolean isReadWrite() - { - return super.isEnabled(); - } // isReadWrite - - - /** - * Set Background based on editable / mandatory / error - * @param error if true, set background to error color, otherwise mandatory/editable - */ - public void setBackground (boolean error) - { - Color bg = null; - if (error) - bg = AdempierePLAF.getFieldBackground_Error(); - else if (!isReadWrite()) - bg = AdempierePLAF.getFieldBackground_Inactive(); - else if (m_mandatory) - bg = AdempierePLAF.getFieldBackground_Mandatory(); - else - bg = AdempierePLAF.getFieldBackground_Normal(); - if (bg.equals(m_editor.getBackground())) - return; - m_editor.setBackground(bg); - } // setBackground - - /** - * Set Editor to value - * @param value value of the editor - */ - public void setValue (Object value) - { - m_oldValue = value; - // super.setSelectedItem(value); - } // setValue - - /** - * Return Editor value - * @return current value - */ - public Object getValue() - { - return null;//super.getSelectedItem(); - } // getValue - - /** - * Return Display Value - * @return displayed String value - */ - public String getDisplay() - { - // if (super.getSelectedItem() == null) - return ""; - // return super.getSelectedItem().toString(); - } // getDisplay - - /*************************************************************************/ - - /** - * Action Listener - * @param e ActionEvent - */ - public void actionPerformed(ActionEvent e) - { - // Do er have a change? - Object newValue = getValue(); - if ((newValue != null && newValue.equals(m_oldValue)) - || (newValue == null && m_oldValue == null) ) - return; - super.firePropertyChange("DataChanged", m_oldValue, newValue); - m_oldValue = newValue; - } // // actionPerformed - - @Override - public void setBackground(Color bg) - { - m_editor.setBackground(bg); - } - -} // CField diff --git a/org.adempiere.ui.swing/src/org/compiere/swing/CFieldEditor.java b/org.adempiere.ui.swing/src/org/compiere/swing/CFieldEditor.java deleted file mode 100644 index bb89b9c6a3..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/swing/CFieldEditor.java +++ /dev/null @@ -1,84 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ -package org.compiere.swing; - -import java.awt.Component; - -import javax.swing.ComboBoxEditor; -import javax.swing.JTextField; - -/** - * Adempiere Field Editor. - * - * - * @author Jorg Janke - * @version $Id: CFieldEditor.java,v 1.2 2006/07/30 00:52:24 jjanke Exp $ - */ -public class CFieldEditor extends JTextField implements ComboBoxEditor -{ - /** - * - */ - private static final long serialVersionUID = -1048599104686258148L; - - /** - * - */ - public CFieldEditor() - { - } - - /** - * Return the component that should be added to the tree hierarchy - * for this editor - */ - public Component getEditorComponent() - { - return this; - } // getEditorCimponent - - /** - * Set Editor - * @param anObject - */ - public void setItem (Object anObject) - { - if (anObject == null) - setText(""); - else - setText(anObject.toString()); - } // setItem - - /** - * Get edited item - * @return edited text - */ - public Object getItem() - { - return getText(); - } // getItem - - /** - * Returns format Info (for Popup) - * @return format - */ - public Object getFormat() - { - return null; - } // getFormat - -} // CFieldEditor diff --git a/org.adempiere.ui.swing/src/org/compiere/swing/CFieldPopup.java b/org.adempiere.ui.swing/src/org/compiere/swing/CFieldPopup.java deleted file mode 100644 index 45420e67d4..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/swing/CFieldPopup.java +++ /dev/null @@ -1,57 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ -package org.compiere.swing; - -/** - * Adempiere Field external popup Interface. - * The actual class must be a JDialog - * - * @author Jorg Janke - * @version $Id: CFieldPopup.java,v 1.2 2006/07/30 00:52:24 jjanke Exp $ - */ -public interface CFieldPopup -{ - /** - * Show Popup - */ - public void show(); - - /** - * Set Value - * @param value - */ - public void setValue (Object value); - - /** - * Get Value - * @return value - */ - public Object getValue(); - - /** - * Set Format - * @param format - */ - public void setFormat (Object format); - - /** - * Get Format - * @return format - */ - public Object getFormat(); - -} // CFieldPopup diff --git a/org.adempiere.ui.swing/src/org/compiere/swing/CFrame.java b/org.adempiere.ui.swing/src/org/compiere/swing/CFrame.java deleted file mode 100644 index 27f291b84e..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/swing/CFrame.java +++ /dev/null @@ -1,143 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ -package org.compiere.swing; - -import java.awt.Container; -import java.awt.GraphicsConfiguration; -import java.awt.HeadlessException; - -import javax.swing.JFrame; -import javax.swing.JPanel; - -/** - * Adempiere Frame - * - * @author Jorg Janke - * @version $Id: CFrame.java,v 1.2 2006/07/30 00:52:24 jjanke Exp $ - */ -public class CFrame extends JFrame -{ - /** - * - */ - private static final long serialVersionUID = 6282268921005682543L; - - /** - * CFrame - * @throws HeadlessException - */ - public CFrame () throws HeadlessException - { - super (); - } // CFrame - - /** - * CFrame - * @param gc - */ - public CFrame (GraphicsConfiguration gc) - { - super (gc); - } // CFrame - - /** - * CFrame - * @param title - * @throws HeadlessException - */ - public CFrame (String title) throws HeadlessException - { - super (cleanup(title)); - } // CFrame - - /** - * CFrame - * @param title - * @param gc - */ - public CFrame (String title, GraphicsConfiguration gc) - { - super (cleanup(title), gc); - } // CFrame - - /** Window ID */ - private int p_AD_Window_ID = 0; - - /** - * Frame Init. - * Install ALT-Pause - */ - protected void frameInit () - { - super.frameInit (); - setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); - // - Container c = getContentPane(); - if (c instanceof JPanel) - { - JPanel panel = (JPanel)c; - panel.getActionMap().put(CDialog.ACTION_DISPOSE, CDialog.s_dialogAction); - panel.getInputMap(JPanel.WHEN_IN_FOCUSED_WINDOW).put(CDialog.s_disposeKeyStroke, CDialog.ACTION_DISPOSE); - } - } // frameInit - - /** - * Cleanedup Title - * @param title title - * @return title w/o mn - */ - private static String cleanup (String title) - { - if (title != null) - { - int pos = title.indexOf('&'); - if (pos != -1 && title.length() > pos) // We have a mnemonic - { - int mnemonic = title.toUpperCase().charAt(pos+1); - if (mnemonic != ' ') - title = title.substring(0, pos) + title.substring(pos+1); - } - } - return title; - } // getTitle - - /** - * Set Title - * @param title title - */ - public void setTitle(String title) - { - super.setTitle(cleanup(title)); - } // setTitle - - /** - * @return Returns the AD_Window_ID. - */ - public int getAD_Window_ID () - { - return p_AD_Window_ID; - } // getAD_Window_ID - - /** - * @param window_ID The AD_Window_ID to set. - */ - public void setAD_Window_ID (int window_ID) - { - p_AD_Window_ID = window_ID; - } // getAD_Window_ID - -} // CFrame diff --git a/org.adempiere.ui.swing/src/org/compiere/swing/CLabel.java b/org.adempiere.ui.swing/src/org/compiere/swing/CLabel.java deleted file mode 100644 index e01b017c99..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/swing/CLabel.java +++ /dev/null @@ -1,309 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ -package org.compiere.swing; - -import java.awt.Color; -import java.awt.Component; -import java.awt.Font; - -import javax.swing.Icon; -import javax.swing.JLabel; -import javax.swing.text.JTextComponent; - -/** - * Label with Mnemonics interpretation - * - * @author Jorg Janke - * @version $Id: CLabel.java,v 1.2 2006/07/30 00:52:24 jjanke Exp $ - */ -public class CLabel extends JLabel -{ - /** - * - */ - private static final long serialVersionUID = 3836688834452881595L; - public static int DEFAULT_ALIGNMENT = JLabel.TRAILING; - - /** - * Creates a Label instance with the specified - * text, image, and horizontal alignment. - * The label is centered vertically in its display area. - * The text is on the trailing edge of the image. - * - * @param text The text to be displayed by the label. - * @param icon The image to be displayed by the label. - * @param horizontalAlignment One of the following constants - * defined in SwingConstants: - * LEFT, - * CENTER, - * RIGHT, - * LEADING or - * TRAILING. - */ - public CLabel (String text, Icon icon, int horizontalAlignment) - { - super (text, icon, horizontalAlignment); - init(); - } - - /** - * Creates a Label instance with the specified - * text and horizontal alignment. - * The label is centered vertically in its display area. - * - * @param text The text to be displayed by the label. - * @param horizontalAlignment One of the following constants - * defined in SwingConstants: - * LEFT, - * CENTER, - * RIGHT, - * LEADING or - * TRAILING. - */ - public CLabel (String text, int horizontalAlignment) - { - super(text, horizontalAlignment); - init(); - } - - /** - * Creates a Label instance with the specified text. - * The label is aligned against the leading edge of its display area, - * and centered vertically. - * - * @param text The text to be displayed by the label. - */ - public CLabel (String text) - { - super(text, DEFAULT_ALIGNMENT); - init(); - } - - /** - * Creates a Label instance with the specified - * image and horizontal alignment. - * The label is centered vertically in its display area. - * - * @param image The image to be displayed by the label. - * @param horizontalAlignment One of the following constants - * defined in SwingConstants: - * LEFT, - * CENTER, - * RIGHT, - * LEADING or - * TRAILING. - */ - public CLabel (Icon image, int horizontalAlignment) - { - super (image, horizontalAlignment); - init(); - } - - /** - * Creates a Label instance with the specified image. - * The label is centered vertically and horizontally - * in its display area. - * - * @param image The image to be displayed by the label. - */ - public CLabel (Icon image) - { - super (image, DEFAULT_ALIGNMENT); - init(); - } - - /** - * Creates a JLabel instance with - * no image and with an empty string for the title. - * The label is centered vertically - * in its display area. - * The label's contents, once set, will be displayed on the leading edge - * of the label's display area. - */ - public CLabel () - { - super("", DEFAULT_ALIGNMENT); - init(); - } - - /** - * Creates a Label instance with the specified text. - * The label is aligned against the leading edge of its display area, - * and centered vertically. - * - * @param label The text to be displayed by the label. - * @param toolTip The optional Tooltip text - */ - public CLabel (String label, String toolTip) - { - super (label, DEFAULT_ALIGNMENT); - if (toolTip != null && toolTip.length() > 0) - super.setToolTipText(toolTip); - init(); - } // CLabel - - /** - * Trailing Label for Field - * @param label label - * @param field field - */ - public CLabel (String label, Component field) - { - this (label, TRAILING); - setLabelFor(field); - } // CLabel - - - /** Mnemonic saved */ - private char m_savedMnemonic = 0; - - /** - * Common init - */ - private void init() - { - setFocusable (false); - setOpaque(false); - if (getToolTipText() == null) // force Tool Tip - setToolTipText(getText()); - } // init - - - /** - * Set Background - * @param bg background - */ - public void setBackground (Color bg) - { - if (bg.equals(getBackground())) - return; - super.setBackground(bg); - } // setBackground - - /** - * Set Font to Bold - * @param bold true bold false normal - */ - public void setFontBold (boolean bold) - { - Font font = getFont(); - if (bold != font.isBold()) - { - font = new Font (font.getName(), bold ? - Font.BOLD : Font.PLAIN, - font.getSize()); - setFont (font); - } - } // setFontBold - - /************************************************************************** - * Set label text - if it includes &, the next character is the Mnemonic - * @param mnemonicLabel Label containing Mnemonic - */ - public void setText (String mnemonicLabel) - { - String text = createMnemonic (mnemonicLabel); - super.setText (text); - if (text != null && getName() == null) - setName(text); - //workaround for focus accelerator issue - if (getLabelFor() != null && getLabelFor() instanceof JTextComponent) - { - if ( m_savedMnemonic > 0) - ((JTextComponent)getLabelFor()).setFocusAccelerator(m_savedMnemonic); - else - ((JTextComponent)getLabelFor()).setFocusAccelerator('\0'); - } - } // setText - - /** - * Create Mnemonics of text containing "&". - * Based on MS notation of &Help => H is Mnemonics - * @param text test with Mnemonics - * @return text w/o & - * @see JLabel#setLabelFor(java.awt.Component) - */ - private String createMnemonic(String text) - { - m_savedMnemonic = 0; - if (text == null) - return text; - int pos = text.indexOf('&'); - if (pos != -1) // We have a nemonic - { - char ch = text.charAt(pos+1); - if (ch != ' ') // &_ - is the & character - { - setDisplayedMnemonic(ch); - setSavedMnemonic(ch); - return text.substring(0, pos) + text.substring(pos+1); - } - } - return text; - } // createMnemonic - - /** - * Set ReadWrite - * @param rw enabled - */ - public void setReadWrite (boolean rw) - { - this.setEnabled(rw); - } // setReadWrite - - /** - * Set Label For - * @param c component - */ - public void setLabelFor (Component c) - { - //reset old if any - if (getLabelFor() != null && getLabelFor() instanceof JTextComponent) - { - ((JTextComponent)getLabelFor()).setFocusAccelerator('\0'); - } - super.setLabelFor (c); - if (c.getName() == null) - c.setName(getName()); - //workaround for focus accelerator issue - if (c instanceof JTextComponent) - { - if (m_savedMnemonic > 0) - { - ((JTextComponent)c).setFocusAccelerator(m_savedMnemonic); - } - } - } // setLabelFor - - - /** - * @return Returns the savedMnemonic. - */ - public char getSavedMnemonic () - { - return m_savedMnemonic; - } // getSavedMnemonic - - /** - * @param savedMnemonic The savedMnemonic to set. - */ - public void setSavedMnemonic (char savedMnemonic) - { - m_savedMnemonic = savedMnemonic; - } // getSavedMnemonic - -} // CLabel diff --git a/org.adempiere.ui.swing/src/org/compiere/swing/CMenuItem.java b/org.adempiere.ui.swing/src/org/compiere/swing/CMenuItem.java deleted file mode 100644 index 8d9af64037..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/swing/CMenuItem.java +++ /dev/null @@ -1,93 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ -package org.compiere.swing; - -import javax.swing.Action; -import javax.swing.Icon; -import javax.swing.JMenuItem; - -/** - * Adempiere Menu Item - * - * @author Jorg Janke - * @version $Id: CMenuItem.java,v 1.2 2006/07/30 00:52:24 jjanke Exp $ - */ -public class CMenuItem extends JMenuItem -{ - - /** - * - */ - private static final long serialVersionUID = 5241542923170919340L; - - public CMenuItem () - { - super (); - } // CMenuItem - - public CMenuItem (Icon icon) - { - super (icon); - } // CMenuItem - - public CMenuItem (String text) - { - super (text); - } // CMenuItem - - public CMenuItem (Action a) - { - super (a); - } // CMenuItem - - public CMenuItem (String text, Icon icon) - { - super (text, icon); - } // CMenuItem - - public CMenuItem (String text, int mnemonic) - { - super (text, mnemonic); - } // CMenuItem - - /** - * Set Text - * @param text text - */ - public void setText (String text) - { - if (text == null) - { - super.setText(text); - return; - } - int pos = text.indexOf('&'); - if (pos != -1 && text.length() > pos) // We have a nemonic - creates ALT-_ - { - int mnemonic = text.toUpperCase().charAt(pos+1); - if (mnemonic != ' ') - { - setMnemonic(mnemonic); - text = text.substring(0, pos) + text.substring(pos+1); - } - } - super.setText (text); - if (getName() == null) - setName (text); - } // setText - -} // CMenuItem diff --git a/org.adempiere.ui.swing/src/org/compiere/swing/CPanel.java b/org.adempiere.ui.swing/src/org/compiere/swing/CPanel.java deleted file mode 100644 index e72be47ad2..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/swing/CPanel.java +++ /dev/null @@ -1,206 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ -package org.compiere.swing; - -import java.awt.Color; -import java.awt.LayoutManager; - -import javax.swing.JPanel; - -import org.adempiere.plaf.AdempiereLookAndFeel; -import org.adempiere.plaf.AdempierePLAF; -import org.compiere.plaf.CompiereColor; -import org.compiere.plaf.CompiereLookAndFeel; - -/** - * Adempiere Panel supporting colored Backgrounds - * - * @author Jorg Janke - * @version $Id: CPanel.java,v 1.2 2006/07/30 00:52:24 jjanke Exp $ - */ -public class CPanel extends JPanel -{ - /** - * - */ - private static final long serialVersionUID = 4153588317643163582L; - - - /** - * Creates a new AdempierePanel with the specified layout manager - * and buffering strategy. - * @param layout the LayoutManager to use - * @param isDoubleBuffered a boolean, true for double-buffering, which - * uses additional memory space to achieve fast, flicker-free updates - */ - public CPanel (LayoutManager layout, boolean isDoubleBuffered) - { - super (layout, isDoubleBuffered); - init(); - } // CPanel - - /** - * Create a new buffered CPanel with the specified layout manager - * @param layout the LayoutManager to use - */ - public CPanel (LayoutManager layout) - { - super (layout); - init(); - } // CPanel - - /** - * Creates a new CPanel with FlowLayout - * and the specified buffering strategy. - * If isDoubleBuffered is true, the CPanel - * will use a double buffer. - * @param isDoubleBuffered a boolean, true for double-buffering, which - * uses additional memory space to achieve fast, flicker-free updates - */ - public CPanel (boolean isDoubleBuffered) - { - super (isDoubleBuffered); - init(); - } // CPanel - - /** - * Creates a new CPanel with a double buffer and a flow layout. - */ - public CPanel() - { - super (); - init(); - } // CPanel - - /** - * Creates a new CPanel with a double buffer and a flow layout. - * @param bc Initial Background Color - */ - public CPanel(CompiereColor bc) - { - this (); - init(); - setBackgroundColor (bc); - } // CPanel - - /** - * Common init. - * Adempiere backround requires that for the base, background is set explictily. - * The additional panels should be transparent. - */ - private void init() - { - setOpaque(false); // transparent - } // init - - - /************************************************************************** - * Set Background - ignored by UI - - * @param bg ignored - */ - public void setBackground (Color bg) - { - if (bg.equals(getBackground())) - return; - super.setBackground (bg); - // ignore calls from javax.swing.LookAndFeel.installColors(LookAndFeel.java:61) - //if (!Trace.getCallerClass(1).startsWith("javax")) - setBackgroundColor (new CompiereColor(bg)); - } // setBackground - - /** - * Set Background - * @param bg AdempiereColor for Background, if null set standard background - */ - public void setBackgroundColor (CompiereColor bg) - { - if (bg == null) - bg = new CompiereColor(AdempierePLAF.getFormBackground()); - setOpaque(true); // not transparent - putClientProperty(CompiereLookAndFeel.BACKGROUND, bg); - super.setBackground (bg.getFlatColor()); - } // setBackground - - /** - * Get Background - * @return Color for Background - */ - public CompiereColor getBackgroundColor () - { - try - { - return (CompiereColor)getClientProperty(CompiereLookAndFeel.BACKGROUND); - } - catch (Exception e) - { - System.err.println("CPanel - ClientProperty: " + e.getMessage()); - } - return null; - } // getBackgroundColor - - /*************************************************************************/ - - /** - * Set Tab Hierarchy Level. - * Has only effect, if tabs are on left or right side - * - * @param level - */ - public void setTabLevel (int level) - { - if (level == 0) - putClientProperty(AdempiereLookAndFeel.TABLEVEL, null); - else - putClientProperty(AdempiereLookAndFeel.TABLEVEL, Integer.valueOf(level)); - } // setTabLevel - - /** - * Get Tab Hierarchy Level - * @return Tab Level - */ - public int getTabLevel() - { - try - { - Integer ll = (Integer)getClientProperty(CompiereLookAndFeel.TABLEVEL); - if (ll != null) - return ll.intValue(); - } - catch (Exception e) - { - System.err.println("ClientProperty: " + e.getMessage()); - } - return 0; - } // getTabLevel - - - /************************************************************************** - * String representation - * @return String representation - */ - public String toString() - { - StringBuilder sb = new StringBuilder ("CPanel ["); - sb.append(super.toString()); - CompiereColor bg = getBackgroundColor(); - if (bg != null) - sb.append(bg.toString()); - sb.append("]"); - return sb.toString(); - } // toString - -} // CPanel diff --git a/org.adempiere.ui.swing/src/org/compiere/swing/CPassword.java b/org.adempiere.ui.swing/src/org/compiere/swing/CPassword.java deleted file mode 100644 index d6d7536ee9..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/swing/CPassword.java +++ /dev/null @@ -1,219 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ -package org.compiere.swing; - -import java.awt.Color; - -import javax.swing.JPasswordField; -import javax.swing.text.Document; - -import org.adempiere.plaf.AdempierePLAF; - -/** - * Password Field - * - * @author Jorg Janke - * @version $Id: CPassword.java,v 1.2 2006/07/30 00:52:24 jjanke Exp $ - */ -public class CPassword extends JPasswordField implements CEditor -{ - /** - * - */ - private static final long serialVersionUID = 6516269177469866775L; - - /** - * Constructs a new JPasswordField, - * with a default document, null starting - * text string, and 0 column width. - */ - public CPassword() - { - super(); - init(); - } - - /** - * Constructs a new JPasswordField initialized - * with the specified text. The document model is set to the - * default, and the number of columns to 0. - * - * @param text the text to be displayed, null if none - */ - public CPassword (String text) - { - super (text); - init(); - } - - /** - * Constructs a new empty JPasswordField with the specified - * number of columns. A default model is created, and the initial string - * is set to null. - * - * @param columns the number of columns >= 0 - */ - public CPassword (int columns) - { - super (columns); - init(); - } - - /** - * Constructs a new JPasswordField initialized with - * the specified text and columns. The document model is set to - * the default. - * - * @param text the text to be displayed, null if none - * @param columns the number of columns >= 0 - */ - public CPassword (String text, int columns) - { - super (text,columns); - init(); - } - - /** - * Constructs a new JPasswordField that uses the - * given text storage model and the given number of columns. - * This is the constructor through which the other constructors feed. - * The echo character is set to '*'. If the document model is - * null, a default one will be created. - * - * @param doc the text storage to use - * @param txt the text to be displayed, null if none - * @param columns the number of columns to use to calculate - * the preferred width >= 0; if columns is set to zero, the - * preferred width will be whatever naturally results from - * the component implementation - */ - public CPassword (Document doc, String txt, int columns) - { - super (doc, txt, columns); - init(); - } - - /** - * Common Init - */ - private void init() - { - } // init - - /*************************************************************************/ - - /** Mandatory (default false) */ - private boolean m_mandatory = false; - - /** - * Set Editor Mandatory - * @param mandatory true, if you have to enter data - */ - public void setMandatory (boolean mandatory) - { - m_mandatory = mandatory; - setBackground(false); - } // setMandatory - - /** - * Is Field mandatory - * @return true, if mandatory - */ - public boolean isMandatory() - { - return m_mandatory; - } // isMandatory - - /** - * Enable Editor - * @param rw true, if you can enter/select data - */ - public void setReadWrite (boolean rw) - { - if (super.isEditable() != rw) - super.setEditable (rw); - setBackground(false); - } // setEditable - - /** - * Is it possible to edit - * @return true, if editable - */ - public boolean isReadWrite() - { - return super.isEditable(); - } // isReadWrite - - /** - * Set Background based on editable / mandatory / error - * @param error if true, set background to error color, otherwise mandatory/editable - */ - public void setBackground (boolean error) - { - if (error) - setBackground(AdempierePLAF.getFieldBackground_Error()); - else if (!isReadWrite()) - setBackground(AdempierePLAF.getFieldBackground_Inactive()); - else if (m_mandatory) - setBackground(AdempierePLAF.getFieldBackground_Mandatory()); - else - setBackground(AdempierePLAF.getFieldBackground_Normal()); - } // setBackground - - /** - * Set Background - * @param bg - */ - public void setBackground (Color bg) - { - if (bg.equals(getBackground())) - return; - super.setBackground(bg); - } // setBackground - - /** - * Set Editor to value - * @param value value of the editor - */ - public void setValue (Object value) - { - if (value == null) - setText(""); - else - setText(value.toString()); - } // setValue - - /** - * Return Editor value - * @return current value - */ - public Object getValue() - { - return new String(super.getPassword()); - } // getValue - - /** - * Return Display Value - * @return displayed String value - */ - public String getDisplay() - { - return new String(super.getPassword()); - } // getDisplay - - -} diff --git a/org.adempiere.ui.swing/src/org/compiere/swing/CScrollPane.java b/org.adempiere.ui.swing/src/org/compiere/swing/CScrollPane.java deleted file mode 100644 index 8fecda7dd3..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/swing/CScrollPane.java +++ /dev/null @@ -1,94 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ -package org.compiere.swing; - -import java.awt.Component; - -import javax.swing.JScrollPane; - -import org.adempiere.plaf.AdempierePLAF; -import org.compiere.plaf.CompiereColor; -import org.compiere.plaf.CompiereLookAndFeel; - -/** - * Adempiere Srcoll Pane. - * - * @author Jorg Janke - * @version $Id: CScrollPane.java,v 1.2 2006/07/30 00:52:24 jjanke Exp $ - */ -public class CScrollPane extends JScrollPane -{ - - /** - * - */ - private static final long serialVersionUID = -2941967111871448295L; - - - /** - * Adempiere ScollPane - */ - public CScrollPane () - { - this (null, VERTICAL_SCROLLBAR_AS_NEEDED, HORIZONTAL_SCROLLBAR_AS_NEEDED); - } // CScollPane - - /** - * Adempiere ScollPane - * @param vsbPolicy vertical policy - * @param hsbPolicy horizontal policy - */ - public CScrollPane (int vsbPolicy, int hsbPolicy) - { - this (null, vsbPolicy, hsbPolicy); - } // CScollPane - - /** - * Adempiere ScollPane - * @param view view - */ - public CScrollPane (Component view) - { - this (view, VERTICAL_SCROLLBAR_AS_NEEDED, HORIZONTAL_SCROLLBAR_AS_NEEDED); - } // CScollPane - - /** - * Adempiere ScollPane - * @param view view - * @param vsbPolicy vertical policy - * @param hsbPolicy horizontal policy - */ - public CScrollPane (Component view, int vsbPolicy, int hsbPolicy) - { - super (view, vsbPolicy, hsbPolicy); - setOpaque(false); - getViewport().setOpaque(false); - } // CScollPane - - - /** - * Set Background - * @param bg AdempiereColor for Background, if null set standard background - */ - public void setBackgroundColor (CompiereColor bg) - { - if (bg == null) - bg = new CompiereColor(AdempierePLAF.getFormBackground()); - putClientProperty(CompiereLookAndFeel.BACKGROUND, bg); - } // setBackground - -} // CScollPane diff --git a/org.adempiere.ui.swing/src/org/compiere/swing/CTabbedPane.java b/org.adempiere.ui.swing/src/org/compiere/swing/CTabbedPane.java deleted file mode 100644 index 661c9f5240..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/swing/CTabbedPane.java +++ /dev/null @@ -1,382 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ -package org.compiere.swing; - -import java.awt.Color; -import java.awt.Component; -import java.awt.event.ActionEvent; -import java.awt.event.KeyEvent; -import java.util.ArrayList; - -import javax.swing.Icon; -import javax.swing.JPanel; -import javax.swing.JTabbedPane; -import javax.swing.KeyStroke; - -import org.adempiere.plaf.AdempierePLAF; -import org.compiere.plaf.CompiereColor; -import org.compiere.plaf.CompiereLookAndFeel; -import org.jdesktop.swingx.UIAction; - -/** - * Adempiere Color Tabbed Pane - * - * @author Jorg Janke - * @version $Id: CTabbedPane.java,v 1.2 2006/07/30 00:52:24 jjanke Exp $ - */ -public class CTabbedPane extends JTabbedPane -{ - /** - * - */ - private static final long serialVersionUID = 5845265820245543812L; - - - /** - * Creates an empty TabbedPane with a default - * tab placement of JTabbedPane.TOP and default - * tab layout policy of JTabbedPane.WRAP_TAB_LAYOUT. - */ - public CTabbedPane() - { - super(); - init(); - } // CTabbedPane - - /** - * Creates an empty TabbedPane with the specified tab placement - * of either: JTabbedPane.TOP, JTabbedPane.BOTTOM, - * JTabbedPane.LEFT, or JTabbedPane.RIGHT, and a - * default tab layout policy of JTabbedPane.WRAP_TAB_LAYOUT. - * - * @param tabPlacement the placement for the tabs relative to the content - */ - public CTabbedPane(int tabPlacement) - { - super(tabPlacement); - init(); - } // CTabbedPane - - /** - * Creates an empty TabbedPane with the specified tab placement - * and tab layout policy. Tab placement may be either: - * JTabbedPane.TOP, JTabbedPane.BOTTOM, - * JTabbedPane.LEFT, or JTabbedPane.RIGHT. - * Tab layout policy may be either: JTabbedPane.WRAP_TAB_LAYOUT - * or JTabbedPane.SCROLL_TAB_LAYOUT. - * - * @param tabPlacement the placement for the tabs relative to the content - * @param tabLayoutPolicy the policy for laying out tabs when all tabs will not fit on one run - * @exception IllegalArgumentException if tab placement or tab layout policy are not - * one of the above supported values - */ - public CTabbedPane(int tabPlacement, int tabLayoutPolicy) - { - super (tabPlacement, tabLayoutPolicy); - init(); - } // CTabbedPane - - /** - * Creates an empty TabbedPane with a defaults and Color - * @param bg Color - */ - public CTabbedPane (CompiereColor bg) - { - super(); - init(); - setBackgroundColor (bg); - } // CTabbedPane - - /** - * Common Init - */ - private void init() - { - } // init - - - /************************************************************************** - * Set Background - ignored by UI - - * @param bg ignored - */ - public void setBackground (Color bg) - { - if (bg.equals(getBackground())) - return; - super.setBackground (bg); - setBackgroundColor (new CompiereColor(bg)); - } // setBackground - - /** - * Set Standard Background - */ - public void setBackgroundColor () - { - setBackgroundColor (null); - } // setBackground - - /** - * Set Background - * @param bg AdempiereColor for Background, if null set standard background - */ - public void setBackgroundColor (CompiereColor bg) - { - if (bg == null) - bg = new CompiereColor(AdempierePLAF.getFormBackground()); - putClientProperty(CompiereLookAndFeel.BACKGROUND, bg); - super.setBackground (bg.getFlatColor()); - // - repaint(); - } // setBackground - - /** - * Get Background - * @return Color for Background - */ - public CompiereColor getBackgroundColor () - { - try - { - return (CompiereColor)getClientProperty(CompiereLookAndFeel.BACKGROUND); - } - catch (Exception e) - { - System.err.println("ClientProperty: " + e.getMessage()); - } - return null; - } // getBackgroundColor - - - /************************************************************************** - * Insert tab. - * If the component is a JPanel, the backround is set to the default - * AdempiereColor (and Opaque) if nothing was defined. - * Redquired as otherwise a gray background would be pained. - *

    - * Inserts a component, at index, - * represented by a title and/or icon, - * either of which may be null. If icon - * is non-null and it implements - * ImageIcon a corresponding disabled icon will automatically - * be created and set on the tabbedpane. - * Uses java.util.Vector internally, see insertElementAt - * for details of insertion conventions. - * - * @param text the title with Mnemonic to be displayed in this tab - * @param icon the icon to be displayed in this tab - * @param component The component to be displayed when this tab is clicked. - * @param tip the tooltip to be displayed for this tab - * @param index the position to insert this new tab - */ - public void insertTab (String text, Icon icon, Component component, String tip, int index) - { - String title = text; - if (!title.startsWith("")) - { - int pos = title.indexOf('&'); - if (pos != -1) - title = title.substring(0, pos) + title.substring(pos+1); - } - // Enforce Tool Tip - if (tip == null || tip.length() == 0) - tip = title; - super.insertTab (title, icon, component, tip, index); - // Set component background - if (component instanceof JPanel) - { - JPanel p = (JPanel)component; - if (p.getClientProperty(CompiereLookAndFeel.BACKGROUND) == null) - { - //AdempiereColor.setBackground(p); - //p.setOpaque(true); - } - } - // Set first - if (index == 0) - getActionMap().put(ACTION_SELECT, s_action); - // - if (!setMnemonicAt(index, text)) - { // Only one - set direct - if (index < 9) - setMnemonicAt(index, '1'+index); - else if (index == 9) - setMnemonicAt(index, '0'); - } - else // additional ALT-1..0 - { - if (index < 9) - getInputMap(WHEN_IN_FOCUSED_WINDOW) - .put(KeyStroke.getKeyStroke(KeyEvent.VK_1+index, ActionEvent.ALT_MASK), ACTION_SELECT); - else if (index == 9) - getInputMap(WHEN_IN_FOCUSED_WINDOW) - .put(KeyStroke.getKeyStroke(KeyEvent.VK_0, ActionEvent.ALT_MASK), ACTION_SELECT); - } - // - } // insertTab - - /** - * Set Title At - * @param index index - * @param text title with opt Mnemonic - */ - public void setTitleAt (int index, String text) - { - String title = text; - if (!title.startsWith("")) - { - int pos = title.indexOf('&'); - if (pos != -1) // We have a nemonic - creates ALT-_ - title = title.substring(0, pos) + title.substring(pos+1); - } - super.setTitleAt (index, title); - // setMnemonicAt(index, text); - } // setTitleAt - - - /** - * Set Mnemonic for Index based on text - * @param index for index - * @param text text - */ - public boolean setMnemonicAt (int index, String text) - { - // logistics - remove old - while (m_mnemonic.size() < index+1) - m_mnemonic.add((char)0); - char keyCode = m_mnemonic.get(index); - if (keyCode != 0) - getInputMap(WHEN_IN_FOCUSED_WINDOW) - .remove(KeyStroke.getKeyStroke(keyCode, ActionEvent.ALT_MASK)); - m_mnemonic.set(index, (char)0); - // - if (!text.startsWith("")) - { - int pos = text.indexOf('&'); - if (pos != -1 && text.length() > pos) // We have a nemonic - creates ALT-_ - { - keyCode = text.toUpperCase().charAt(pos+1); - if (keyCode != ' ') - { - setMnemonicAt(index, keyCode); - m_mnemonic.set(index, keyCode); - return true; - } - } - } - /** - keyCode = text.toUpperCase().charAt(0); - if (m_mnemonic.contains(keyCode)) - { - keyCode = 0; - // Beginning new word - int pos = text.indexOf(' '); - while (pos != -1 && text.length() > pos) - { - char c = text.toUpperCase().charAt(pos+1); - if (Character.isLetterOrDigit(c) && !m_mnemonic.contains(c)) - { - keyCode = c; - break; - } - pos = text.indexOf(' ', pos+1); - } - // Any character - if (keyCode == 0) - { - for (int i = 1; i < text.length(); i++) - { - char c = text.toUpperCase().charAt(i); - if (Character.isLetterOrDigit(c) && !m_mnemonic.contains(c)) - { - keyCode = c; - break; - } - } - } - // First character fallback - // if (mnemonic == 0) - // mnemonic = text.toUpperCase().charAt(0); - } - if (keyCode != 0) - { - setMnemonicAt(index, keyCode); - m_mnemonic.set(index, keyCode); - } - **/ - return false; - } // setMnemonicAt - - /** Used Mnemonics */ - private ArrayList m_mnemonic = new ArrayList(10); - - - /** - * String representation - * @return String representation - */ - public String toString() - { - StringBuilder sb = new StringBuilder ("CTabbedPane ["); - sb.append(super.toString()); - CompiereColor bg = getBackgroundColor(); - if (bg != null) - sb.append(bg.toString()); - sb.append("]"); - return sb.toString(); - } // toString - - /** Select Action Text */ - private static final String ACTION_SELECT = "CAS"; - /** Select Action */ - private static CTAction s_action = new CTAction(ACTION_SELECT); - - /** - * Select Action - * - * @author Jorg Janke - * @version $Id: CTabbedPane.java,v 1.2 2006/07/30 00:52:24 jjanke Exp $ - */ - private static class CTAction extends UIAction - { - /** - * Constructor - */ - public CTAction (String actionName) - { - super (actionName); - } // Action - - public void actionPerformed (ActionEvent e) - { - String key = getName(); - if (!key.equals(ACTION_SELECT) - || !(e.getSource() instanceof CTabbedPane)) - return; - CTabbedPane pane = (CTabbedPane)e.getSource(); - String command = e.getActionCommand(); - if (command == null || command.length() != 1) - return; - int index = command.charAt(0)-'1'; - if (index > -1 && index < pane.getTabCount()) - pane.setSelectedIndex(index); - else - System.out.println("Action: " + e); - } // actionPerformed - - } // Action - -} // CTabbedPane diff --git a/org.adempiere.ui.swing/src/org/compiere/swing/CTable.java b/org.adempiere.ui.swing/src/org/compiere/swing/CTable.java deleted file mode 100644 index 1d8103e56d..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/swing/CTable.java +++ /dev/null @@ -1,740 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ -package org.compiere.swing; - -import java.awt.Component; -import java.awt.Container; -import java.awt.Font; -import java.awt.event.HierarchyEvent; -import java.awt.event.HierarchyListener; -import java.awt.event.MouseAdapter; -import java.awt.event.MouseEvent; -import java.util.ArrayList; -import java.util.Collections; -import java.util.Comparator; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Vector; -import java.util.logging.Level; -import java.util.logging.Logger; - -import javax.swing.JComponent; -import javax.swing.JScrollPane; -import javax.swing.JTable; -import javax.swing.JViewport; -import javax.swing.ListSelectionModel; -import javax.swing.ScrollPaneConstants; -import javax.swing.event.ChangeEvent; -import javax.swing.event.TableModelEvent; -import javax.swing.table.DefaultTableCellRenderer; -import javax.swing.table.DefaultTableModel; -import javax.swing.table.TableCellEditor; -import javax.swing.table.TableCellRenderer; -import javax.swing.table.TableColumn; -import javax.swing.table.TableModel; - -import org.adempiere.plaf.AdempierePLAF; -import org.compiere.util.MSort; -import org.jdesktop.swingx.icon.ColumnControlIcon; - -/** - * Model Independent enhanced JTable. - * Provides sizing and sorting. - * - * @author Jorg Janke - * @version $Id: CTable.java,v 1.2 2006/07/30 00:52:24 jjanke Exp $ - * - * @author Teo Sarca, SC ARHIPAC SERVICE SRL - BF [ 1585369 ], FR [ 1753943 ] - */ -public class CTable extends JTable -{ - /** - * - */ - private static final long serialVersionUID = 975975420639030844L; - - /** - * Default Constructor - */ - public CTable() - { - super(new DefaultTableModel()); - setColumnSelectionAllowed(false); - setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); // teo_sarca - FR [ 1753943 ] - setAutoResizeMode(JTable.AUTO_RESIZE_OFF); - getTableHeader().addMouseListener(new CTableMouseListener()); - setSurrendersFocusOnKeystroke(true); - //Default row height too narrow - setRowHeight(getFont().getSize() + 8); - - setColumnControlVisible(true); - addHierarchyListener(createHierarchyListener()); - } // CTable - - private HierarchyListener createHierarchyListener() { - return new HierarchyListener() { - - public void hierarchyChanged(HierarchyEvent e) { - if (e.getChangeFlags() == HierarchyEvent.PARENT_CHANGED) - configureColumnControl(); - } - - }; - } - - /** Last model index sorted */ - protected int p_lastSortIndex = -1; - /** Sort direction */ - protected boolean p_asc = true; - - /** Sizing: making sure it fits in a column */ - private final int SLACK = 15; - /** Sizing: max size in pt */ - private final int MAXSIZE = 250; - /** Model Index of Key Column */ - protected int p_keyColumnIndex = -1; - /** state variable to indicate sorting in progress **/ - protected boolean sorting; - - /** Logger */ - private static Logger log = Logger.getLogger(CTable.class.getName()); - - /** - * ScrollPane's original vertical scroll policy. If the column control is - * visible the policy is set to ALWAYS. - */ - private int verticalScrollPolicy; - - /** - * Flag to indicate if the column control is visible. - */ - private boolean columnControlVisible = false; - - /** - * The component used a column control in the upper trailing corner of - * an enclosing JScrollPane. - */ - private JComponent columnControlButton; - - private List hiddenColumns = new ArrayList(); - - private Map columnAttributesMap - = new HashMap(); - - /** - * Set Model index of Key Column. - * Used for identifying previous selected row after fort complete to set as selected row. - * If not set, column 0 is used. - * @param keyColumnIndex model index - */ - public void setKeyColumnIndex (int keyColumnIndex) - { - p_keyColumnIndex = keyColumnIndex; - } // setKeyColumnIndex - - /** - * Get Model index of Key Column - * @return model index - */ - public int getKeyColumnIndex() - { - return p_keyColumnIndex; - } // getKeyColumnIndex - - /** - * Get Current Row Key Column Value - * @return value or null - */ - public Object getSelectedKeyColumnValue() - { - int row = getSelectedRow(); - if (row != -1 && p_keyColumnIndex != -1) - return getModel().getValueAt(row, p_keyColumnIndex); - return null; - } // getKeyColumnValue - - /** - * Get Selected Value or null - * @return value - */ - public Object getSelectedValue() - { - int row = getSelectedRow(); - int col = getSelectedColumn(); - if (row == -1 || col == -1) - return null; - return getValueAt(row, col); - } // getSelectedValue - - /** - * Stop Table Editors and remove focus - * @param saveValue save value - */ - public void stopEditor (boolean saveValue) - { - // MultiRow - remove editors - ChangeEvent ce = new ChangeEvent(this); - if (saveValue) - editingStopped(ce); - else - editingCanceled(ce); - // - if (getInputContext() != null) - getInputContext().endComposition(); - // change focus to next - transferFocus(); - } // stopEditor - - - /************************************************************************** - * Size Columns. - * @param useColumnIdentifier if false uses plain content - - * otherwise uses Column Identifier to indicate displayed columns - */ - public void autoSize (boolean useColumnIdentifier) - { - TableModel model = this.getModel(); - int size = model.getColumnCount(); - // for all columns - for (int c = 0; c < size; c++) - { - TableColumn column = getColumnModel().getColumn(c); - // Not displayed columns - if (useColumnIdentifier - && (column.getIdentifier() == null - || column.getMaxWidth() == 0 - || column.getIdentifier().toString().length() == 0)) - continue; - - int width = 0; - // Header - TableCellRenderer renderer = column.getHeaderRenderer(); - if (renderer == null) - renderer = new DefaultTableCellRenderer(); - Component comp = null; - if (renderer != null) - comp = renderer.getTableCellRendererComponent - (this, column.getHeaderValue(), false, false, 0, 0); - // - if (comp != null) - { - width = comp.getPreferredSize().width; - width = Math.max(width, comp.getWidth()); - - // Cells - int col = column.getModelIndex(); - int maxRow = Math.min(20, getRowCount()); - try - { - for (int row = 0; row < maxRow; row++) - { - renderer = getCellRenderer(row, col); - comp = renderer.getTableCellRendererComponent - (this, getValueAt(row, col), false, false, row, col); - if (comp != null) - { - int rowWidth = comp.getPreferredSize().width; - width = Math.max(width, rowWidth); - } - } - } - catch (Exception e) - { - log.log(Level.SEVERE, column.getIdentifier().toString(), e); - } - // Width not greater than 250 - width = Math.min(MAXSIZE, width + SLACK); - } - // - column.setPreferredWidth(width); - } // for all columns - } // autoSize - - public void packColumn(TableColumn column) - { - int width = 0; - // Header - TableCellRenderer renderer = column.getHeaderRenderer(); - if (renderer == null) - renderer = new DefaultTableCellRenderer(); - Component comp = null; - if (renderer != null) - comp = renderer.getTableCellRendererComponent - (this, column.getHeaderValue(), false, false, 0, 0); - // - if (comp != null) - { - width = comp.getPreferredSize().width; - width = Math.max(width, comp.getWidth()); - - // Cells - int col = column.getModelIndex(); - int maxRow = Math.min(20, getRowCount()); - try - { - for (int row = 0; row < maxRow; row++) - { - renderer = getCellRenderer(row, col); - comp = renderer.getTableCellRendererComponent - (this, getValueAt(row, col), false, false, row, col); - if (comp != null) - { - int rowWidth = comp.getPreferredSize().width; - width = Math.max(width, rowWidth); - } - } - } - catch (Exception e) - { - log.log(Level.SEVERE, column.getIdentifier().toString(), e); - } - // Width not greater than 250 - width = Math.min(MAXSIZE, width + SLACK); - } - // - column.setPreferredWidth(width); - } - - - /** - * Sort Table - * @param modelColumnIndex model column sort index - */ - @SuppressWarnings("unchecked") - protected void sort (final int modelColumnIndex) - { - int rows = getRowCount(); - if (rows == 0) - return; - - sorting = true; - - // other column - if (modelColumnIndex != p_lastSortIndex) - p_asc = true; - else - p_asc = !p_asc; - p_lastSortIndex = modelColumnIndex; - // - if (log.isLoggable(Level.CONFIG)) log.config("#" + modelColumnIndex + " - rows=" + rows + ", asc=" + p_asc); - - // Selection - Object selected = null; - int selRow = getSelectedRow(); - int selCol = p_keyColumnIndex == -1 ? 0 : p_keyColumnIndex; // used to identify current row - if (getSelectedRow() >= 0) - selected = getValueAt(selRow, selCol); - - // Prepare sorting - DefaultTableModel model = (DefaultTableModel)getModel(); - final MSort sort = new MSort(0, null); - sort.setSortAsc(p_asc); - /* teo_sarca: commented: [ 1585369 ] CTable sorting is TOO LAZY * - // while something to sort - sorting: - while (true) - { - // Create sortList - ArrayList sortList = new ArrayList(rows); - // fill with data entity - for (int i = 0; i < rows; i++) - { - Object value = model.getValueAt(i, modelColumnIndex); - sortList.add(new MSort(i, value)); - } - // sort list it - Collections.sort(sortList, sort); - // move out of sequence row - for (int i = 0; i < rows; i++) - { - int index = ((MSort)sortList.get(i)).index; - if (i != index) - { - // log.config( "move " + i + " to " + index); - model.moveRow(i,i, index); - continue sorting; - } - } - // we are done - // log.config("done"); - break; - } // while something to sort - */ - // teo_sarca: [ 1585369 ] CTable sorting is TOO LAZY - Collections.sort(model.getDataVector(), new Comparator() { - public int compare(Object o1, Object o2) { - Object item1 = ((Vector)o1).get(modelColumnIndex); - Object item2 = ((Vector)o2).get(modelColumnIndex); - return sort.compare(item1, item2); - } - }); - - // selection - clearSelection(); - if (selected != null) - { - for (int r = 0; r < rows; r++) - { - if (selected.equals(getValueAt(r, selCol))) - { - setRowSelectionInterval(r,r); - scrollRectToVisible(getCellRect(r, modelColumnIndex, true)); // teo_sarca: bug fix [ 1585369 ] - break; - } - } - } // selected != null - - sorting = false; - } // sort - - - @Override - public void tableChanged(TableModelEvent e) { - if (e != null && e.getFirstRow() == 0 && e.getLastRow() == Integer.MAX_VALUE && - e.getColumn() == TableModelEvent.ALL_COLUMNS && e.getType() == TableModelEvent.UPDATE) - { - if (!sorting) - { - //reset sort state after refresh - p_asc = true; - p_lastSortIndex = -1; - } - } - else - { - if (getRowCount() == 0) - { - //reset sort state after clear - p_asc = true; - p_lastSortIndex = -1; - } - } - - super.tableChanged(e); - } - - /** - * String Representation - * @return info - */ - public String toString() - { - return new StringBuffer("CTable[").append(getModel()).append("]").toString(); - } // toString - - - /************************************************************************** - * MouseListener - */ - class CTableMouseListener extends MouseAdapter - { - private TableColumn cachedResizingColumn = null; - - /** - * Constructor - */ - public CTableMouseListener() - { - super(); - } // CTableMouseListener - - /** - * Mouse clicked - * @param e event - */ - public void mouseClicked (MouseEvent e) - { - if (isInResizeRegion(e)) - { - if (e.getClickCount() == 2) - packColumn(cachedResizingColumn); - uncacheResizingColumn(); - } - else - { - int vc = getColumnModel().getColumnIndexAtX(e.getX()); - // log.info( "Sort " + vc + "=" + getColumnModel().getColumn(vc).getHeaderValue()); - int mc = convertColumnIndexToModel(vc); - TableColumn column = getTableHeader().getResizingColumn(); - if (column != null) return; - sort(mc); - } - } - - public void mouseReleased(MouseEvent e) { - cacheResizingColumn(e); - } - - public void mousePressed(MouseEvent e) { - cacheResizingColumn(e); - } - - private void cacheResizingColumn(MouseEvent e) { - TableColumn column = getTableHeader().getResizingColumn(); - if (column != null) { - cachedResizingColumn = column; - } - } - - private void uncacheResizingColumn() { - cachedResizingColumn = null; - } - - private boolean isInResizeRegion(MouseEvent e) { - return cachedResizingColumn != null; // inResize; - } - - public void mouseEntered(MouseEvent e) { - } - - public void mouseExited(MouseEvent e) { - uncacheResizingColumn(); - } - - public void mouseDragged(MouseEvent e) { - uncacheResizingColumn(); - } - - } // CTableMouseListener - - - @Override - public void setFont(Font font) { - super.setFont(font); - //Update row height - setRowHeight(getFont().getSize() + 8); - } - - /** - * @return column index - */ - public int getSortColumn() { - return p_lastSortIndex; - } - - /** - * @return boolean - */ - public boolean isSortAscending() { - return p_asc; - } - - /** - * Returns the column control visible property. - *

    - * - * @return boolean to indicate whether the column control is visible. - * @see #setColumnControlVisible(boolean) - * @see #setColumnControl(JComponent) - */ - public boolean isColumnControlVisible() { - return columnControlVisible; - } - - /** - * Sets the column control visible property. If true and - * JXTable is contained in a JScrollPane, the - * table adds the column control to the trailing corner of the scroll pane. - *

    - * - * Note: if the table is not inside a JScrollPane the column - * control is not shown even if this returns true. In this case it's the - * responsibility of the client code to actually show it. - *

    - * - * The default value is false. - * - * @param visible boolean to indicate if the column control should be shown - * @see #isColumnControlVisible() - * @see #setColumnControl(JComponent) - * - */ - public void setColumnControlVisible(boolean visible) { - boolean old = isColumnControlVisible(); - this.columnControlVisible = visible; - if (old != isColumnControlVisible()) { - configureColumnControl(); - firePropertyChange("columnControlVisible", old, !old); - } - } - - /** - * Returns the component used as column control. Lazily creates the - * control to the default if it is null. - * - * @return component for column control, guaranteed to be != null. - * @see #setColumnControl(JComponent) - * @see #createDefaultColumnControl() - */ - public JComponent getColumnControl() { - if (columnControlButton == null) { - columnControlButton = createDefaultColumnControl(); - } - return columnControlButton; - } - - /** - * Creates the default column control used by this table. - * This implementation returns a ColumnControlButton configured - * with default ColumnControlIcon. - * - * @return the default component used as column control. - * @see #setColumnControl(JComponent) - * @see org.jdesktop.swingx.table.ColumnControlButton - * @see org.jdesktop.swingx.icon.ColumnControlIcon - */ - protected JComponent createDefaultColumnControl() { - return new CColumnControlButton(this, new ColumnControlIcon()); - } - - /** - * Configures the upper trailing corner of an enclosing - * JScrollPane. - * - * Adds/removes the ColumnControl depending on the - * columnControlVisible property.

    - * - * @see #setColumnControlVisible(boolean) - * @see #setColumnControl(JComponent) - */ - protected void configureColumnControl() { - Container p = getParent(); - if (p instanceof JViewport) { - Container gp = p.getParent(); - if (gp instanceof JScrollPane) { - JScrollPane scrollPane = (JScrollPane) gp; - // Make certain we are the viewPort's view and not, for - // example, the rowHeaderView of the scrollPane - - // an implementor of fixed columns might do this. - JViewport viewport = scrollPane.getViewport(); - if (viewport == null || viewport.getView() != this) { - return; - } - if (isColumnControlVisible()) { - verticalScrollPolicy = scrollPane - .getVerticalScrollBarPolicy(); - scrollPane.setCorner(JScrollPane.UPPER_TRAILING_CORNER, - getColumnControl()); - - scrollPane - .setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS); - } else { - if (verticalScrollPolicy != 0) { - // Fix #155-swingx: reset only if we had force always before - // PENDING: JW - doesn't cope with dynamically changing the policy - // shouldn't be much of a problem because doesn't happen too often?? - scrollPane.setVerticalScrollBarPolicy(verticalScrollPolicy); - } - try { - scrollPane.setCorner(JScrollPane.UPPER_TRAILING_CORNER, - null); - } catch (Exception ex) { - // Ignore spurious exception thrown by JScrollPane. This - // is a Swing bug! - } - - } - } - } - } - - /** - * - * @param column - * @return boolean - */ - public boolean isColumnVisible(TableColumn column) - { - return !hiddenColumns.contains(column); - } - - /** - * Hide or show column - * @param column - * @param visible - */ - public void setColumnVisibility(TableColumn column, boolean visible) - { - if (visible) - { - if (isColumnVisible(column)) return; - ColumnAttributes attributes = columnAttributesMap.get(column); - if (attributes == null) return; - - column.setCellEditor(attributes.cellEditor); - column.setCellRenderer(attributes.cellRenderer); - column.setMinWidth(attributes.minWidth); - column.setMaxWidth(attributes.maxWidth); - column.setPreferredWidth(attributes.preferredWidth); - columnAttributesMap.remove(column); - hiddenColumns.remove(column); - } - else - { - if (!isColumnVisible(column)) return; - - ColumnAttributes attributes = new ColumnAttributes(); - attributes.cellEditor = column.getCellEditor(); - attributes.cellRenderer = column.getCellRenderer(); - attributes.minWidth = column.getMinWidth(); - attributes.maxWidth = column.getMaxWidth(); - attributes.preferredWidth = column.getPreferredWidth(); - columnAttributesMap.put(column, attributes); - - TableCellNone h = new TableCellNone(column.getIdentifier() != null ? - column.getIdentifier().toString() : column.getHeaderValue().toString()); - column.setCellEditor(h); - column.setCellRenderer(h); - column.setMinWidth(0); - column.setMaxWidth(0); - column.setPreferredWidth(0); - - hiddenColumns.add(column); - } - } - - public Component prepareRenderer(TableCellRenderer renderer, int rowIndex, - int vColIndex) { - Component c = super.prepareRenderer(renderer, rowIndex, vColIndex); - if (c==null) return c; - if (!this.isCellEditable(rowIndex, vColIndex) || isCellSelected(rowIndex, vColIndex)) - return c; - if (rowIndex % 2 == 0) { - c.setBackground(AdempierePLAF.getFieldBackground_Selected()); - } else { - // If not shaded, match the table's background - c.setBackground(getBackground()); - } - return c; - } - - class ColumnAttributes { - protected TableCellEditor cellEditor; - - protected TableCellRenderer cellRenderer; - - protected Object headerValue; - - protected int minWidth; - - protected int maxWidth; - - protected int preferredWidth; - } - -} // CTable diff --git a/org.adempiere.ui.swing/src/org/compiere/swing/CTextArea.java b/org.adempiere.ui.swing/src/org/compiere/swing/CTextArea.java deleted file mode 100644 index c63d703333..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/swing/CTextArea.java +++ /dev/null @@ -1,528 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ -package org.compiere.swing; - -import java.awt.Color; -import java.awt.Insets; -import java.awt.KeyboardFocusManager; -import java.awt.event.ActionEvent; -import java.awt.event.FocusEvent; -import java.awt.event.FocusListener; -import java.awt.event.InputEvent; -import java.awt.event.InputMethodListener; -import java.awt.event.KeyEvent; -import java.awt.event.KeyListener; -import java.awt.event.MouseListener; -import java.awt.im.InputMethodRequests; - -import javax.swing.AbstractAction; -import javax.swing.ActionMap; -import javax.swing.InputMap; -import javax.swing.InputVerifier; -import javax.swing.JScrollPane; -import javax.swing.JTextArea; -import javax.swing.KeyStroke; -import javax.swing.text.DefaultEditorKit; -import javax.swing.text.Document; - -import org.adempiere.plaf.AdempierePLAF; -import org.compiere.model.MSysConfig; -import org.compiere.util.Env; - -/** - * Adempiere TextArea - A ScrollPane with a JTextArea. - * Manages visibility, opaque and color consistently - * - * @author Jorg Janke - * @version $Id: CTextArea.java,v 1.3 2006/07/30 00:52:24 jjanke Exp $ - */ -public class CTextArea extends JScrollPane - implements CEditor -{ - /** - * - */ - private static final long serialVersionUID = 6208738910767859872L; - - // IDEMPIERE-320 - private static final String FIRE_CHANGE = "fire-change"; - - /** - * Constructs a new TextArea. A default model is set, the initial string - * is null, and rows/columns are set to 0. - */ - public CTextArea() - { - this (new JTextArea()); - } // CText - - /** - * Constructs a new TextArea with the specified text displayed. - * A default model is created and rows/columns are set to 0. - * - * @param text the text to be displayed, or null - */ - public CTextArea (String text) - { - this (new JTextArea (text)); - } // CText - - /** - * Constructs a new empty TextArea with the specified number of - * rows and columns. A default model is created, and the initial - * string is null. - * - * @param rows the number of rows >= 0 - * @param columns the number of columns >= 0 - * @exception IllegalArgumentException if the rows or columns - * arguments are negative. - */ - public CTextArea (int rows, int columns) - { - this (new JTextArea (rows, columns)); - } // CText - - /** - * Constructs a new TextArea with the specified text and number - * of rows and columns. A default model is created. - * - * @param text the text to be displayed, or null - * @param rows the number of rows >= 0 - * @param columns the number of columns >= 0 - * @exception IllegalArgumentException if the rows or columns - * arguments are negative. - */ - public CTextArea (String text, int rows, int columns) - { - this (new JTextArea(text, rows, columns)); - } // CText - - /** - * Constructs a new JTextArea with the given document model, and defaults - * for all of the other arguments (null, 0, 0). - * - * @param doc the model to use - */ - public CTextArea (Document doc) - { - this (new JTextArea (doc)); - } // CText - - /** - * Constructs a new JTextArea with the specified number of rows - * and columns, and the given model. All of the constructors - * feed through this constructor. - * - * @param doc the model to use, or create a default one if null - * @param text the text to be displayed, null if none - * @param rows the number of rows >= 0 - * @param columns the number of columns >= 0 - * @exception IllegalArgumentException if the rows or columns - * arguments are negative. - */ - public CTextArea (Document doc, String text, int rows, int columns) - { - this (new JTextArea (doc, text, rows, columns)); - } // CTextArea - - - /** - * Create a JScrollArea with a JTextArea. - * (use Cpmpiere Colors, Line wrap) - * @param textArea - */ - public CTextArea (JTextArea textArea) - { - super (textArea); - m_textArea = textArea; - super.setOpaque(false); - super.getViewport().setOpaque(false); - m_textArea.setLineWrap(true); - m_textArea.setWrapStyleWord(true); - // Overwrite default Tab - m_textArea.firePropertyChange("editable", !isEditable(), isEditable()); - - // IDEMPIERE-573 - Swing text areas break user flow when cycling focus with tab key - // tbayen - 2013-01-20 - // remove special treatment of TAB and Ctrl-TAB in JTextArea - m_textArea.setFocusTraversalKeys(KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS, null); - m_textArea.setFocusTraversalKeys(KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS, null); - // Use Ctrl-TAB to insert tab character into text area. - KeyStroke keyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_TAB, InputEvent.CTRL_DOWN_MASK); - m_textArea.getInputMap().put(keyStroke, DefaultEditorKit.insertTabAction); - - // IDEMPIERE-320 (see also comment at IDEMPIERE-573) - // Use Ctrl-ENTER oder Shift-ENTER to insert newline in text area. - // (independent from SWING_OVERRIDE_TEXT_AREA_BEHAVIOUR on or off - // as a convenience for switching users) - keyStroke =KeyStroke.getKeyStroke(KeyEvent.VK_ENTER,InputEvent.SHIFT_DOWN_MASK); - m_textArea.getInputMap().put(keyStroke, DefaultEditorKit.insertBreakAction); - keyStroke =KeyStroke.getKeyStroke(KeyEvent.VK_ENTER,InputEvent.CTRL_DOWN_MASK); - m_textArea.getInputMap().put(keyStroke, DefaultEditorKit.insertBreakAction); - - // IDEMPIERE-320 - boolean taBehaviour = MSysConfig.getBooleanValue(MSysConfig.SWING_OVERRIDE_TEXT_AREA_BEHAVIOUR, false, Env.getAD_Client_ID(Env.getCtx())); - if (taBehaviour) - { - InputMap im = m_textArea.getInputMap(); - im.put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), FIRE_CHANGE); - - ActionMap am = m_textArea.getActionMap(); - am.put(FIRE_CHANGE, new AbstractAction() { - - /** - * - */ - private static final long serialVersionUID = -4599908611347627047L; - - @Override - public void actionPerformed(ActionEvent arg0) { - m_textArea.dispatchEvent(new FocusEvent(m_textArea, FocusEvent.FOCUS_LOST)); - m_textArea.requestFocus(); - } - }); - } - } // CTextArea - - /** Text Area */ - private JTextArea m_textArea = null; - - /*************************************************************************/ - - /** Mandatory (default false) */ - private boolean m_mandatory = false; - - /** - * Set Editor Mandatory - * @param mandatory true, if you have to enter data - */ - public void setMandatory (boolean mandatory) - { - m_mandatory = mandatory; - setBackground(false); - } // setMandatory - - /** - * Is Field mandatory - * @return true, if mandatory - */ - public boolean isMandatory() - { - return m_mandatory; - } // isMandatory - - /** - * Enable Editor - * @param rw true, if you can enter/select data - */ - public void setReadWrite (boolean rw) - { - if (m_textArea.isEditable() != rw) - m_textArea.setEditable (rw); - setBackground(false); - } // setReadWrite - - /** - * Is it possible to edit - * @return true, if editable - */ - public boolean isReadWrite() - { - return m_textArea.isEditable(); - } // isReadWrite - - /** - * Set Background based on editable / mandatory / error - * @param error if true, set background to error color, otherwise mandatory/editable - */ - public void setBackground (boolean error) - { - if (error) - setBackground(AdempierePLAF.getFieldBackground_Error()); - else if (!isReadWrite()) - setBackground(AdempierePLAF.getFieldBackground_Inactive()); - else if (m_mandatory) - setBackground(AdempierePLAF.getFieldBackground_Mandatory()); - else - setBackground(AdempierePLAF.getFieldBackground_Normal()); - } // setBackground - - /** - * Set Background color - * @param color color - */ - public void setBackground (Color color) - { - if (color.equals(getBackground())) - return; - if (m_textArea == null) // during init - super.setBackground(color); - else - m_textArea.setBackground(color); - } - /** - * Get Background color - * @return background - */ - public Color getBackground () - { - if (m_textArea == null) // during init - return super.getBackground(); - else - return m_textArea.getBackground(); - } - /** - * Set Foreground color - * @param color - */ - public void setForeground (Color color) - { - if (m_textArea == null) // during init - super.setForeground(color); - else - m_textArea.setForeground(color); - } - /** - * Get Foreground color - * @return color - */ - public Color getForeground () - { - if (m_textArea == null) // during init - return super.getForeground(); - else - return m_textArea.getForeground(); - } - - /** - * Set Editor to value - * @param value value of the editor - */ - public void setValue (Object value) - { - if (value == null) - m_textArea.setText(""); - else - m_textArea.setText(value.toString()); - } // setValue - - /** - * Return Editor value - * @return current value - */ - public Object getValue() - { - return m_textArea.getText(); - } // getValue - - /** - * Return Display Value - * @return displayed String value - */ - public String getDisplay() - { - return m_textArea.getText(); - } // getDisplay - - /************************************************************************* - * Set Text and position top - * @param text - */ - public void setText (String text) - { - m_textArea.setText(text); - m_textArea.setCaretPosition(0); - } - /** - * Get Text - * @return text - */ - public String getText() - { - return m_textArea.getText(); - } - /** - * Append text - * @param text - */ - public void append (String text) - { - m_textArea.append (text); - } - - /** - * Set Columns - * @param cols - */ - public void setColumns (int cols) - { - m_textArea.setColumns (cols); - } - /** - * Get Columns - * @return columns - */ - public int getColumns() - { - return m_textArea.getColumns(); - } - - /** - * Set Rows - * @param rows - */ - public void setRows (int rows) - { - m_textArea.setRows(rows); - } - /** - * Get Rows - * @return rows - */ - public int getRows() - { - return m_textArea.getRows(); - } - - /** - * Set Text Caret Position - * @param pos - */ - public void setCaretPosition (int pos) - { - m_textArea.setCaretPosition (pos); - } - /** - * Get Text Caret Position - * @return position - */ - public int getCaretPosition() - { - return m_textArea.getCaretPosition(); - } - - /** - * Set Text Editable - * @param edit - */ - public void setEditable (boolean edit) - { - m_textArea.setEditable(edit); - } - /** - * Is Text Editable - * @return true if editable - */ - public boolean isEditable() - { - return m_textArea.isEditable(); - } - - /** - * Set Text Line Wrap - * @param wrap - */ - public void setLineWrap (boolean wrap) - { - m_textArea.setLineWrap (wrap); - } - /** - * Set Text Wrap Style Word - * @param word - */ - public void setWrapStyleWord (boolean word) - { - m_textArea.setWrapStyleWord (word); - } - - /** - * Set Opaque - * @param isOpaque - */ - public void setOpaque (boolean isOpaque) - { - // JScrollPane & Viewport is always not Opaque - if (m_textArea == null) // during init of JScrollPane - super.setOpaque(isOpaque); - else - m_textArea.setOpaque(isOpaque); - } // setOpaque - - /** - * Set Text Margin - * @param m insets - */ - public void setMargin (Insets m) - { - if (m_textArea != null) - m_textArea.setMargin(m); - } // setMargin - - - /** - * AddFocusListener - * @param l - */ - public void addFocusListener (FocusListener l) - { - if (m_textArea == null) // during init - super.addFocusListener(l); - else - m_textArea.addFocusListener(l); - } - /** - * Add Text Mouse Listener - * @param l - */ - public void addMouseListener (MouseListener l) - { - m_textArea.addMouseListener(l); - } - /** - * Add Text Key Listener - * @param l - */ - public void addKeyListener (KeyListener l) - { - m_textArea.addKeyListener(l); - } - /** - * Add Text Input Method Listener - * @param l - */ - public void addInputMethodListener (InputMethodListener l) - { - m_textArea.addInputMethodListener(l); - } - /** - * Get text Input Method Requests - * @return requests - */ - public InputMethodRequests getInputMethodRequests() - { - return m_textArea.getInputMethodRequests(); - } - /** - * Set Text Input Verifier - * @param l - */ - public void setInputVerifier (InputVerifier l) - { - m_textArea.setInputVerifier(l); - } - -} // CTextArea diff --git a/org.adempiere.ui.swing/src/org/compiere/swing/CTextField.java b/org.adempiere.ui.swing/src/org/compiere/swing/CTextField.java deleted file mode 100644 index 0830442ddb..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/swing/CTextField.java +++ /dev/null @@ -1,259 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ -package org.compiere.swing; - -import java.awt.Color; -import java.awt.event.KeyEvent; -import java.awt.event.KeyListener; - -import javax.swing.JTextField; -import javax.swing.text.Document; - -import org.adempiere.plaf.AdempierePLAF; - -/** - * Adempiere Text Field - * - * @author Jorg Janke - * @version $Id: CTextField.java,v 1.2 2006/07/30 00:52:24 jjanke Exp $ - */ -public class CTextField extends JTextField - implements CEditor, KeyListener -{ - /** - * - */ - private static final long serialVersionUID = 460529728891168659L; - - /** - * Constructs a new TextField. A default model is created, - * the initial string is null, - * and the number of columns is set to 0. - */ - public CTextField() - { - super(); - init(); - } // CTextField - - /** - * Constructs a new TextField initialized with the - * specified text. A default model is created and the number of - * columns is 0. - * - * @param text the text to be displayed, or null - */ - public CTextField (String text) - { - super (text); - init(); - } // CTextField - - /** - * Constructs a new empty TextField with the specified - * number of columns. - * A default model is created and the initial string is set to - * null. - * - * @param columns the number of columns to use to calculate - * the preferred width; if columns is set to zero, the - * preferred width will be whatever naturally results from - * the component implementation - */ - public CTextField (int columns) - { - super (columns); - init(); - } // CTextField - - /** - * Constructs a new TextField initialized with the - * specified text and columns. A default model is created. - * - * @param text the text to be displayed, or null - * @param columns the number of columns to use to calculate - * the preferred width; if columns is set to zero, the - * preferred width will be whatever naturally results from - * the component implementation - */ - public CTextField (String text, int columns) - { - super (text, columns); - init(); - } // CTextField - - /** - * Constructs a new JTextField that uses the given text - * storage model and the given number of columns. - * This is the constructor through which the other constructors feed. - * If the document is null, a default model is created. - * - * @param doc the text storage to use; if this is null, - * a default will be provided by calling the - * createDefaultModel method - * @param text the initial string to display, or null - * @param columns the number of columns to use to calculate - * the preferred width >= 0; if columns - * is set to zero, the preferred width will be whatever - * naturally results from the component implementation - * @exception IllegalArgumentException if columns < 0 - */ - public CTextField (Document doc, String text, int columns) - { - super (doc, text, columns); - init(); - } // CTextField - - /** - * Initialization - */ - private void init() - { - setBackground (false); - } // init - - /*************************************************************************/ - - /** Mandatory (default false) */ - private boolean m_mandatory = false; - - /** - * Set Editor Mandatory - * @param mandatory true, if you have to enter data - */ - public void setMandatory (boolean mandatory) - { - m_mandatory = mandatory; - setBackground(false); - } // setMandatory - - /** - * Is Field mandatory - * @return true, if mandatory - */ - public boolean isMandatory() - { - return m_mandatory; - } // isMandatory - - /** - * Enable Editor - * @param rw true, if you can enter/select data - */ - public void setReadWrite (boolean rw) - { - if (super.isEditable() != rw) - super.setEditable (rw); - setBackground(false); - } // setEditable - - /** - * Is it possible to edit - * @return true, if editable - */ - public boolean isReadWrite() - { - return super.isEditable(); - } // isReadWrite - - - /** - * Set Background based on editable / mandatory / error - * @param error if true, set background to error color, otherwise mandatory/editable - */ - public void setBackground (boolean error) - { - if (error) - setBackground(AdempierePLAF.getFieldBackground_Error()); - else if (!isReadWrite()) - setBackground(AdempierePLAF.getFieldBackground_Inactive()); - else if (m_mandatory) - setBackground(AdempierePLAF.getFieldBackground_Mandatory()); - else - setBackground(AdempierePLAF.getFieldBackground_Normal()); - } // setBackground - - /** - * Set Background - * @param bg background - */ - public void setBackground (Color bg) - { - if (bg.equals(getBackground())) - return; - super.setBackground(bg); - } // setBackground - - /** - * Set Editor to value - * @param value value of the editor - */ - public void setValue (Object value) - { - if (value == null) - setText(""); - else - setText(value.toString()); - } // setValue - - /** - * Return Editor value - * @return current value - */ - public Object getValue() - { - return getText(); - } // getValue - - /** - * Return Display Value - * @return displayed String value - */ - public String getDisplay() - { - return getText(); - } // getDisplay - - - /** - * key Pressed - * @see java.awt.event.KeyListener#keyPressed(java.awt.event.KeyEvent) - * @param e - */ - public void keyPressed(KeyEvent e) - { - } // keyPressed - - /** - * key Released - * @see java.awt.event.KeyListener#keyReleased(java.awt.event.KeyEvent) - * @param e - */ - public void keyReleased(KeyEvent e) - { - } // keyReleased - - /** - * key Typed - * @see java.awt.event.KeyListener#keyTyped(java.awt.event.KeyEvent) - * @param e - */ - public void keyTyped(KeyEvent e) - { - } // keyTyped - -} // CTextField diff --git a/org.adempiere.ui.swing/src/org/compiere/swing/CTextPane.java b/org.adempiere.ui.swing/src/org/compiere/swing/CTextPane.java deleted file mode 100644 index 347acc54fb..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/swing/CTextPane.java +++ /dev/null @@ -1,360 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ -package org.compiere.swing; - -import java.awt.Color; -import java.awt.Insets; -import java.awt.event.FocusListener; -import java.awt.event.InputMethodListener; -import java.awt.event.KeyListener; -import java.awt.event.MouseListener; -import java.awt.im.InputMethodRequests; - -import javax.swing.InputVerifier; -import javax.swing.JScrollPane; -import javax.swing.JTextPane; -import javax.swing.text.StyledDocument; - -import org.adempiere.plaf.AdempierePLAF; - -/** - * Adempiere TextPane - A ScrollPane with a JTextPane. - * Manages visibility, opaque and color consistently * - * @author Jorg Janke - * @version $Id: CTextPane.java,v 1.3 2006/07/30 00:52:24 jjanke Exp $ - */ -public class CTextPane extends JScrollPane - implements CEditor - -{ - /** - * - */ - private static final long serialVersionUID = -6702310899755509377L; - - /** - * Constructs a new TextPane (HTML) - */ - public CTextPane() - { - this (new JTextPane()); - } // CTextPane - - /** - * Constructs a new JTextPane with the given document - * @param doc the model to use - */ - public CTextPane (StyledDocument doc) - { - this (new JTextPane (doc)); - } // CTextPane - - /** - * Create a JScrollArea with a JTextEditor - * @param textPane - */ - public CTextPane (JTextPane textPane) - { - super (textPane); - m_textPane = textPane; - super.setOpaque(false); - super.getViewport().setOpaque(false); - m_textPane.setContentType("text/html"); - } // CTextPane - - private JTextPane m_textPane = null; - - /*************************************************************************/ - - /** Mandatory (default false) */ - private boolean m_mandatory = false; - - /** - * Set Editor Mandatory - * @param mandatory true, if you have to enter data - */ - public void setMandatory (boolean mandatory) - { - m_mandatory = mandatory; - setBackground(false); - } // setMandatory - - /** - * Is Field mandatory - * @return true, if mandatory - */ - public boolean isMandatory() - { - return m_mandatory; - } // isMandatory - - /** - * Enable Editor - * @param rw true, if you can enter/select data - */ - public void setReadWrite (boolean rw) - { - if (m_textPane.isEditable() != rw) - m_textPane.setEditable (rw); - setBackground(false); - } // setReadWrite - - /** - * Is it possible to edit - * @return true, if editable - */ - public boolean isReadWrite() - { - return m_textPane.isEditable(); - } // isReadWrite - - /** - * Set Background based on editable / mandatory / error - * @param error if true, set background to error color, otherwise mandatory/editable - */ - public void setBackground (boolean error) - { - if (error) - setBackground(AdempierePLAF.getFieldBackground_Error()); - else if (!isReadWrite()) - setBackground(AdempierePLAF.getFieldBackground_Inactive()); - else if (m_mandatory) - setBackground(AdempierePLAF.getFieldBackground_Mandatory()); - else - setBackground(AdempierePLAF.getFieldBackground_Normal()); - } // setBackground - - /** - * Set Background - * @param color color - */ - public void setBackground (Color color) - { - if (color.equals(getBackground())) - return; - if (m_textPane == null) // during init - super.setBackground(color); - else - m_textPane.setBackground(color); - } // setBackground - - /** - * Get Background - * @return color - */ - public Color getBackground () - { - if (m_textPane == null) // during init - return super.getBackground(); - else - return m_textPane.getBackground(); - } // getBackground - - /** - * Set Foreground - * @param color color - */ - public void setForeground (Color color) - { - if (m_textPane == null) // during init - super.setForeground(color); - else - m_textPane.setForeground(color); - } // setForeground - - /** - * Get Foreground - * @return color - */ - public Color getForeground () - { - if (m_textPane == null) // during init - return super.getForeground(); - else - return m_textPane.getForeground(); - } // getForeground - - /** - * Set Content Type - * @param type e.g. text/html - */ - public void setContentType (String type) - { - if (m_textPane != null) // during init - m_textPane.setContentType(type); - } // setContentType - - - /** - * Set Editor to value - * @param value value of the editor - */ - public void setValue (Object value) - { - if (value == null) - m_textPane.setText(""); - else - m_textPane.setText(value.toString()); - } // setValue - - /** - * Return Editor value - * @return current value - */ - public Object getValue() - { - return m_textPane.getText(); - } // getValue - - /** - * Return Display Value - * @return displayed String value - */ - public String getDisplay() - { - return m_textPane.getText(); - } // getDisplay - - - /************************************************************************** - * Set Text and position top - * @param text - */ - public void setText (String text) - { - m_textPane.setText(text); - m_textPane.setCaretPosition(0); - } - /** - * Get Text - * @return text - */ - public String getText() - { - return m_textPane.getText(); - } - - /** - * Set Caret Position - * @param pos pos - */ - public void setCaretPosition (int pos) - { - m_textPane.setCaretPosition (pos); - } - /** - * Get Caret Position - * @return position - */ - public int getCaretPosition() - { - return m_textPane.getCaretPosition(); - } - - /** - * Set Editable - * @param edit editable - */ - public void setEditable (boolean edit) - { - m_textPane.setEditable(edit); - } - /** - * Editable - * @return true if editable - */ - public boolean isEditable() - { - return m_textPane.isEditable(); - } - - /** - * Set Text Margin - * @param m insets - */ - public void setMargin (Insets m) - { - if (m_textPane != null) - m_textPane.setMargin(m); - } // setMargin - - /** - * Set Opaque - * @param isOpaque opaque - */ - public void setOpaque (boolean isOpaque) - { - // JScrollPane & Viewport is always not Opaque - if (m_textPane == null) // during init of JScrollPane - super.setOpaque(isOpaque); - else - m_textPane.setOpaque(isOpaque); - } // setOpaque - - /** - * Add Focus Listener - * @param l listener - */ - public void addFocusListener (FocusListener l) - { - if (m_textPane == null) // during init - super.addFocusListener(l); - else - m_textPane.addFocusListener(l); - } - /** - * Add Mouse Listener - * @param l listner - */ - public void addMouseListener (MouseListener l) - { - m_textPane.addMouseListener(l); - } - /** - * Add Key Listener - * @param l listner - */ - public void addKeyListener (KeyListener l) - { - m_textPane.addKeyListener(l); - } - /** - * Add Input Method Listener - * @param l listener - */ - public void addInputMethodListener (InputMethodListener l) - { - m_textPane.addInputMethodListener(l); - } - /** - * Get Input Method Requests - * @return requests - */ - public InputMethodRequests getInputMethodRequests() - { - return m_textPane.getInputMethodRequests(); - } - /** - * Set Input Verifier - * @param l verifyer - */ - public void setInputVerifier (InputVerifier l) - { - m_textPane.setInputVerifier(l); - } - -} // CTextPane diff --git a/org.adempiere.ui.swing/src/org/compiere/swing/CToggleButton.java b/org.adempiere.ui.swing/src/org/compiere/swing/CToggleButton.java deleted file mode 100644 index c788993c53..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/swing/CToggleButton.java +++ /dev/null @@ -1,266 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ -package org.compiere.swing; - -import java.awt.Color; - -import javax.swing.Action; -import javax.swing.Icon; -import javax.swing.JToggleButton; - -import org.adempiere.plaf.AdempierePLAF; -import org.compiere.plaf.CompiereColor; -import org.compiere.plaf.CompiereLookAndFeel; - -/** - * Adempiere Color Taggle Button - * - * @author Jorg Janke - * @version $Id: CToggleButton.java,v 1.2 2006/07/30 00:52:24 jjanke Exp $ - */ -public class CToggleButton extends JToggleButton implements CEditor -{ - /** - * - */ - private static final long serialVersionUID = -3527812520795669992L; - - /** - * Creates an initially unselected toggle button - * without setting the text or image. - */ - public CToggleButton () - { - this(null, null, false); - } - - /** - * Creates an initially unselected toggle button - * with the specified image but no text. - * - * @param icon the image that the button should display - */ - public CToggleButton(Icon icon) - { - this(null, icon, false); - } - - /** - * Creates a toggle button with the specified image - * and selection state, but no text. - * - * @param icon the image that the button should display - * @param selected if true, the button is initially selected; - * otherwise, the button is initially unselected - */ - public CToggleButton(Icon icon, boolean selected) - { - this(null, icon, selected); - } - - /** - * Creates an unselected toggle button with the specified text. - * - * @param text the string displayed on the toggle button - */ - public CToggleButton (String text) - { - this(text, null, false); - } - - /** - * Creates a toggle button with the specified text - * and selection state. - * - * @param text the string displayed on the toggle button - * @param selected if true, the button is initially selected; - * otherwise, the button is initially unselected - */ - public CToggleButton (String text, boolean selected) - { - this(text, null, selected); - } - - /** - * Creates a toggle button where properties are taken from the - * Action supplied. - * @param a - */ - public CToggleButton(Action a) - { - this(null, null, false); - setAction(a); - } - - /** - * Creates a toggle button that has the specified text and image, - * and that is initially unselected. - * - * @param text the string displayed on the button - * @param icon the image that the button should display - */ - public CToggleButton(String text, Icon icon) - { - this(text, icon, false); - } - - /** - * Creates a toggle button with the specified text, image, and - * selection state. - * - * @param text the text of the toggle button - * @param icon the image that the button should display - * @param selected if true, the button is initially selected; - * otherwise, the button is initially unselected - */ - public CToggleButton (String text, Icon icon, boolean selected) - { - super(text, icon, selected); - } - - /*************************************************************************/ - - /** - * Set Background - Differentiates between system & user call. - * If User Call, sets Opaque & ContextAreaFilled to true - * @param bg - */ - public void setBackground(Color bg) - { - if (bg.equals(getBackground())) - return; - super.setBackground( bg); - } // setBackground - - /** - * Set Background - NOP - * @param error - */ - public void setBackground (boolean error) - { - } // setBackground - - /** - * Set Standard Background - */ - public void setBackgroundColor () - { - setBackgroundColor (null); - } // setBackground - - /** - * Set Background - * @param bg AdempiereColor for Background, if null set standard background - */ - public void setBackgroundColor (CompiereColor bg) - { - if (bg == null) - bg = new CompiereColor(AdempierePLAF.getFormBackground()); - setOpaque(true); - putClientProperty(CompiereLookAndFeel.BACKGROUND, bg); - super.setBackground (bg.getFlatColor()); - } // setBackground - - /** - * Get Background - * @return Color for Background - */ - public CompiereColor getBackgroundColor () - { - try - { - return (CompiereColor)getClientProperty(CompiereLookAndFeel.BACKGROUND); - } - catch (Exception e) - { - System.err.println("CButton - ClientProperty: " + e.getMessage()); - } - return null; - } // getBackgroundColor - - /** Mandatory (default false) */ - private boolean m_mandatory = false; - - /** - * Set Editor Mandatory - * @param mandatory true, if you have to enter data - */ - public void setMandatory (boolean mandatory) - { - m_mandatory = mandatory; - setBackground(false); - } // setMandatory - - /** - * Is Field mandatory - * @return true, if mandatory - */ - public boolean isMandatory() - { - return m_mandatory; - } // isMandatory - - /** - * Enable Editor - * @param rw true, if you can enter/select data - */ - public void setReadWrite (boolean rw) - { - if (super.isEnabled() != rw) - super.setEnabled(rw); - } // setReadWrite - - /** - * Is it possible to edit - * @return true, if editable - */ - public boolean isReadWrite() - { - return super.isEnabled(); - } // isReadWrite - - /** - * Set Editor to value - * @param value value of the editor - */ - public void setValue (Object value) - { - if (value == null) - setText(""); - else - setText(value.toString()); - } // setValue - - /** - * Return Editor value - * @return current value - */ - public Object getValue() - { - return getText(); - } // getValue - - /** - * Return Display Value - * @return displayed String value - */ - public String getDisplay() - { - return getText(); - } // getDisplay - -} // CToggleButton diff --git a/org.adempiere.ui.swing/src/org/compiere/swing/CollapsiblePanel.java b/org.adempiere.ui.swing/src/org/compiere/swing/CollapsiblePanel.java deleted file mode 100644 index e700b2e5ad..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/swing/CollapsiblePanel.java +++ /dev/null @@ -1,219 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 2007 Adempiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - *****************************************************************************/ -package org.compiere.swing; - -import java.awt.Color; -import java.awt.Component; -import java.awt.Graphics; -import java.awt.Insets; - -import javax.swing.Action; -import javax.swing.BorderFactory; -import javax.swing.JPanel; -import javax.swing.UIManager; -import javax.swing.border.Border; -import javax.swing.border.CompoundBorder; - -import org.adempiere.plaf.AdempierePLAF; -import org.jdesktop.swingx.JXCollapsiblePane; -import org.jdesktop.swingx.JXHyperlink; -import org.jdesktop.swingx.VerticalLayout; - -/** - * Collapsible panel with a title and contents.
    - * - * Based on the StackedBox component develop by - * Frederic Lavigne - * - * @author hengsin - */ -public class CollapsiblePanel extends JPanel { - - /** - * - */ - private static final long serialVersionUID = -7372966868790589720L; - private Color titleBackgroundColor; - private Color titleForegroundColor; - private Color separatorColor; - private Border separatorBorder; - private JXHyperlink link; - private JXCollapsiblePane collapsible; - - /** - * - * @param title - */ - public CollapsiblePanel(String title) { - setLayout(new VerticalLayout()); - setOpaque(true); - setBackground(Color.WHITE); - - separatorBorder = new SeparatorBorder(); - setTitleForegroundColor(Color.BLACK); - setTitleBackgroundColor(new Color(248, 248, 248)); - setSeparatorColor(new Color(214, 223, 247)); - - collapsible = new JXCollapsiblePane(); - collapsible.getContentPane().setBackground( - AdempierePLAF.getFormBackground()); - collapsible.setBorder(new CompoundBorder(separatorBorder, collapsible - .getBorder())); - - Action toggleAction = collapsible.getActionMap().get( - JXCollapsiblePane.TOGGLE_ACTION); - // use the collapse/expand icons from the JTree UI - toggleAction.putValue(JXCollapsiblePane.COLLAPSE_ICON, UIManager - .getIcon("Tree.expandedIcon")); - toggleAction.putValue(JXCollapsiblePane.EXPAND_ICON, UIManager - .getIcon("Tree.collapsedIcon")); - - link = new JXHyperlink(toggleAction); - link.setText(title); - link.setOpaque(true); - link.setBackground(getTitleBackgroundColor()); - link.setFocusPainted(false); - - link.setUnclickedColor(getTitleForegroundColor()); - link.setClickedColor(getTitleForegroundColor()); - - link.setBorder(new CompoundBorder(separatorBorder, BorderFactory - .createEmptyBorder(2, 4, 2, 4))); - link.setBorderPainted(true); - - super.add(link); - super.add(collapsible); - - } - - /** - * - * @return color - */ - public Color getSeparatorColor() { - return separatorColor; - } - - /** - * - * @param separatorColor - */ - public void setSeparatorColor(Color separatorColor) { - this.separatorColor = separatorColor; - } - - /** - * get title foreground color - * - * @return color - */ - public Color getTitleForegroundColor() { - return titleForegroundColor; - } - - /** - * Set title foreground color - * - * @param titleForegroundColor - */ - public void setTitleForegroundColor(Color titleForegroundColor) { - this.titleForegroundColor = titleForegroundColor; - } - - /** - * - * @return title background color - */ - public Color getTitleBackgroundColor() { - return titleBackgroundColor; - } - - /** - * Set background color of title - * - * @param titleBackgroundColor - */ - public void setTitleBackgroundColor(Color titleBackgroundColor) { - this.titleBackgroundColor = titleBackgroundColor; - } - - /** - * Set title of the section - * - * @param title - */ - public void setTitle(String title) { - if (link != null) - link.setText(title); - } - - /** - * - * @return collapsible pane - */ - public JXCollapsiblePane getCollapsiblePane() { - return collapsible; - } - - /** - * The border between the stack components. It separates each component with - * a fine line border. - */ - class SeparatorBorder implements Border { - - boolean isFirst(Component c) { - return c.getParent() == null || c.getParent().getComponent(0) == c; - } - - public Insets getBorderInsets(Component c) { - // if the collapsible is collapsed, we do not want its border to be - // painted. - if (c instanceof JXCollapsiblePane) { - if (((JXCollapsiblePane) c).isCollapsed()) { - return new Insets(0, 0, 0, 0); - } - } - return new Insets(4, 0, 1, 0); - } - - public boolean isBorderOpaque() { - return true; - } - - public void paintBorder(Component c, Graphics g, int x, int y, - int width, int height) { - // if the collapsible is collapsed, we do not want its border to be - // painted. - if (c instanceof JXCollapsiblePane) { - if (((JXCollapsiblePane) c).isCollapsed()) { - return; - } - } - g.setColor(getSeparatorColor()); - if (isFirst(c)) { - g.drawLine(x, y + 2, x + width, y + 2); - } - g.drawLine(x, y + height - 1, x + width, y + height - 1); - } - } - - @Override - public Component add(Component comp) { - if (collapsible != null) - return collapsible.add(comp); - - return null; - } - -} diff --git a/org.adempiere.ui.swing/src/org/compiere/swing/ColorBlind.java b/org.adempiere.ui.swing/src/org/compiere/swing/ColorBlind.java deleted file mode 100644 index 10a46e4260..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/swing/ColorBlind.java +++ /dev/null @@ -1,290 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ -package org.compiere.swing; - -import java.awt.Color; -import java.util.logging.Level; -import java.util.logging.Logger; - -import javax.swing.plaf.ColorUIResource; - -/** - * Color Blind Utilities. - * These utilities help to show how color blind/challenged see colors. - * - * Created by Thomas Wolfmaier. - * Copyright (C) 1999-2005 HCIRN. - * All rights reserved. - * @see HCIRN - * - * @author Thomas Wolfmaier - * @version $Id: ColorBlind.java,v 1.2 2006/07/30 00:52:23 jjanke Exp $ - */ -public class ColorBlind -{ - /** Color Blindness Type - 0=none */ - public static final String[] COLORBLIND_TYPE = - {"", "Protanopia", "Deuteranopia", "Tritanopia"}; - - public static final int NORMAL = 0; - public static final int PROTANOPIA = 1; - public static final int DEUTERANOPIA = 2; - public static final int TRITANOPIA = 3; - - /*************************************************************************/ - - private static final double[][] confusionPoints = - { {0.735, 0.265}, - {1.140, -0.140}, - {0.171, -0.003} - }; - private static final double[][][] colorAxes = - { {{0.115807, 0.073581}, {0.471899, 0.527051}}, - {{0.102776, 0.102864}, {0.505845, 0.493211}}, - {{0.045391, 0.294976}, {0.665764, 0.334011}} - }; - private static final double[][] RGBtoXYZMatrix = - { {0.430574, 0.341550, 0.178325}, - {0.222015, 0.706655, 0.071330}, - {0.020183, 0.129553, 0.939180} - }; - private static final double[][] XYZtoRGBMatrix = - { { 3.063218, -1.393325, -0.475802}, - {-0.969243, 1.875966, 0.041555}, - { 0.067871, -0.228834, 1.069251} - }; - private static final double[] whitePoint = - { 0.312713, 0.329016, 0.358271 - }; - private static final double gamma = 2.2; - - /** Color Blind Type */ - private static int s_colorType = NORMAL; - - /** Logger */ - private static Logger log = Logger.getLogger(ColorBlind.class.getName()); - - - /** - * Set Color Type for Color Blind view - * @param colorType (0 = none) - */ - public static void setColorType (int colorType) - { - if (colorType > 0 && colorType < 4) - s_colorType = colorType; - else - s_colorType = 0; - if (s_colorType != 0) - if (log.isLoggable(Level.CONFIG)) log.config(COLORBLIND_TYPE[colorType]); - } // setColorType - - /** - * Get Color Type for Color Blind view - * @return colorType (0 = none) - */ - public static int getColorType () - { - return s_colorType; - } // getColorType - - - /************************************************************************** - * Convert "normal" color to Dichromat Color based on set color type - * @param color Java Color object containing values for RGB - * @return Dichromat Color - */ - public static ColorUIResource getDichromatColorUIResource (ColorUIResource color) - { - if (s_colorType == NORMAL) - return color; - return new ColorUIResource(getDichromatColorUIResource (color, s_colorType)); - } // convertToDichromatColorUIResource - - /** - * Convert "normal" color to Dichromat Color - * @param color Java Color object containing values for RGB - * @param colorType PROTANOPIA = 1, DEUTERANOPIA = 2 or TRITANOPIA = 3 as declared above - * @return Dichromat Color - */ - public static Color getDichromatColorUIResource (ColorUIResource color, int colorType) - { - if (s_colorType == NORMAL) - return color; - return new ColorUIResource(getDichromatColor (color, s_colorType)); - } // convertToDichromatColorUIResource - - /** - * Convert "normal" color to Dichromat Color based on set color type - * @param color Java Color object containing values for RGB - * @return Dichromat Color - */ - public static Color getDichromatColor (Color color) - { - if (s_colorType == NORMAL) - return color; - return getDichromatColor (color, s_colorType); - } // convertToDichromatColor - - /** - * Convert "normal" color to Dichromat Color - * @param color Java Color object containing values for RGB - * @param colorType PROTANOPIA = 1, DEUTERANOPIA = 2 or TRITANOPIA = 3 as declared above - * @return Dichromat Color - */ - public static Color getDichromatColor (Color color, int colorType) - { - // check type & return if not valid - int type = 0; - if (colorType > 0 && colorType < 4) - type = colorType; - // No conversion or no color - if (type == 0 || color == null) - return color; - type--; // correct to zero based - - // Return white & black - not converted - if (color.equals(Color.black) || color.equals(Color.white)) - return color; - - double red = color.getRed(); - double green = color.getGreen(); - double blue = color.getBlue(); - - // System.out.println("Red: " + red + " Green: " + green + " Blue: " + blue); - - double X = RGBtoXYZMatrix[0][0] * Math.pow(red / 255.0, gamma) + - RGBtoXYZMatrix[0][1] * Math.pow(green / 255.0, gamma) + - RGBtoXYZMatrix[0][2] * Math.pow(blue / 255.0, gamma); - double Y = RGBtoXYZMatrix[1][0] * Math.pow(red / 255.0, gamma) + - RGBtoXYZMatrix[1][1] * Math.pow(green / 255.0, gamma) + - RGBtoXYZMatrix[1][2] * Math.pow(blue / 255.0, gamma); - double Z = RGBtoXYZMatrix[2][0] * Math.pow(red / 255.0, gamma) + - RGBtoXYZMatrix[2][1] * Math.pow(green / 255.0, gamma) + - RGBtoXYZMatrix[2][2] * Math.pow(blue / 255.0, gamma); - - // System.out.println("X: " + X + " Y: " + Y + " Z: " + Z); - - double x = 0.0; - double y = 0.0; - - if ((X + Y + Z) != 0.0) - { - x = X / (X + Y + Z); - y = Y / (X + Y + Z); - } - - // System.out.println("x: " + x + " y: " + y + " Y: " + Y); - - double Yn = Y; - double Xn = (whitePoint[0] * Yn) / whitePoint[1]; - double Zn = (whitePoint[2] * Yn) / whitePoint[1]; - - double xc = confusionPoints[type][0]; - double yc = confusionPoints[type][1]; - - double x1 = colorAxes[type][0][0]; - double y1 = colorAxes[type][0][1]; - double x2 = colorAxes[type][1][0]; - double y2 = colorAxes[type][1][1]; - - double ap = (y2 - y1) / (x2 - x1); - double bp = y1 - (x1 * ap); - - // System.out.println("ap: " + ap + " bp: " + bp); - - double a; - if (x < xc) - a = (yc - y) / (xc - x); - else - a = (y - yc) / (x - xc); - - double b = y - (x * a); - - // System.out.println("a: " + a + " b: " + b); - - x = (bp - b) / (a - ap); - y = a * x + b; - - // System.out.println("x: " + x + " y: " + y); - - X = 0.0; - Z = 0.0; - if (y != 0) - { - X = x * (Y / y); - Z = (1 - x - y) * (Y / y); - } - - // System.out.println("X: " + X + " Y: " + Y + " Z: " + Z); - - red = XYZtoRGBMatrix[0][0] * X + - XYZtoRGBMatrix[0][1] * Y + - XYZtoRGBMatrix[0][2] * Z; - green = XYZtoRGBMatrix[1][0] * X + - XYZtoRGBMatrix[1][1] * Y + - XYZtoRGBMatrix[1][2] * Z; - blue = XYZtoRGBMatrix[2][0] * X + - XYZtoRGBMatrix[2][1] * Y + - XYZtoRGBMatrix[2][2] * Z; - - // System.out.println("Red: " + red + " Green: " + green + " Blue: " + blue); - - double reddiff = XYZtoRGBMatrix[0][0] * (Xn - X) + - XYZtoRGBMatrix[0][1] * (Yn - Y) + - XYZtoRGBMatrix[0][2] * (Zn - Z); - double greendiff = XYZtoRGBMatrix[1][0] * (Xn - X) + - XYZtoRGBMatrix[1][1] * (Yn - Y) + - XYZtoRGBMatrix[1][2] * (Zn - Z); - double bluediff = XYZtoRGBMatrix[2][0] * (Xn - X) + - XYZtoRGBMatrix[2][1] * (Yn - Y) + - XYZtoRGBMatrix[2][2] * (Zn - Z); - - double cr = ((red < 0.0 ? 0.0 : 1.0) - red) / reddiff; - double cg = ((green < 0.0 ? 0.0 : 1.0) - green) / greendiff; - double cb = ((blue < 0.0 ? 0.0 : 1.0) - blue) / bluediff; - - // System.out.println("cr: " + cr + " cg: " + cg + " cb: " + cb); - - double c1 = (cr < 0 || cr > 1) ? 0 : cr; - double c2 = (cg < 0 || cg > 1) ? 0 : cg; - double c3 = (cb < 0 || cb > 1) ? 0 : cb; - double c = Math.max(c1, Math.max(c2, c3)); - - // System.out.println("c: " + c); - - red = red + c * reddiff; - green = green + c * greendiff; - blue = blue + c * bluediff; - - // System.out.println("Red: " + red + " Green: " + green + " Blue: " + blue); - - red = Math.pow(red, 1.0 / gamma); - green = Math.pow(green, 1.0 / gamma); - blue = Math.pow(blue, 1.0 / gamma); - - // System.out.println("Red: " + red + " Green: " + green + " Blue: " + blue); - // System.out.println("Red: " + red * 255.0 + " Green: " + green * 255.0 + " Blue: " + blue * 255.0); - - Color retValue = new Color((float)red, (float)green, (float)blue); - if (log.isLoggable(Level.FINE)) log.fine("Color " + color.getRed() + "-" + color.getGreen() + "-" + color.getBlue() - + " -> " + retValue.getRed() + "-" + retValue.getGreen() + "-" + retValue.getBlue() + " <- " + COLORBLIND_TYPE[colorType]); - - return retValue; - } // convertToDichromatColor - -} // ColorBlind diff --git a/org.adempiere.ui.swing/src/org/compiere/swing/ColorEditor.java b/org.adempiere.ui.swing/src/org/compiere/swing/ColorEditor.java deleted file mode 100644 index 5612d6e698..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/swing/ColorEditor.java +++ /dev/null @@ -1,682 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ -package org.compiere.swing; - -import java.awt.BorderLayout; -import java.awt.Component; -import java.awt.Dialog; -import java.awt.Dimension; -import java.awt.FlowLayout; -import java.awt.Frame; -import java.awt.Graphics; -import java.awt.GridBagConstraints; -import java.awt.GridBagLayout; -import java.awt.Insets; -import java.awt.Rectangle; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.beans.PropertyChangeListener; -import java.beans.PropertyEditor; -import java.util.ResourceBundle; - -import javax.swing.BorderFactory; -import javax.swing.JColorChooser; - -import org.adempiere.plaf.AdempierePLAF; -import org.compiere.plaf.CompiereColor; -import org.compiere.util.KeyNamePair; -import org.compiere.util.ValueNamePair; - -/** - * Adempiere Color Editor - * - * @author Jorg Janke - * @version $Id: AdempiereColorEditor.java,v 1.2 2006/07/30 00:52:24 jjanke Exp $ - */ -public class ColorEditor extends CDialog - implements ActionListener, PropertyEditor -{ - /** - * - */ - private static final long serialVersionUID = -484760951046013782L; - - /** - * Get Background AdempiereColor - * @param owner owner - * @param color optional initial color - * @return AdempiereColor - */ - public static CompiereColor showDialog (Frame owner, CompiereColor color) - { - ColorEditor cce = new ColorEditor (owner, color); - if (cce.isSaved()) - return cce.getColor(); - return color; - } // showDialog - - /** - * Get Background AdempiereColor - * @param owner owner - * @param color optional initial color - * @return AdempiereColor - */ - public static CompiereColor showDialog (Dialog owner, CompiereColor color) - { - ColorEditor cce = new ColorEditor (owner, color); - if (cce.isSaved()) - return cce.getColor(); - return color; - } // showIt - - /*************************************************************************/ - - /** - * Create AdempiereColor Dialog with color - * @param owner owner - * @param color Start Color - */ - public ColorEditor (Frame owner, CompiereColor color) - { - super(owner, "", true); - init (color); - } // AdempiereColorEditor - - /** - * Create AdempiereColor Dialog with color - * @param owner owner - * @param color Start Color - */ - public ColorEditor (Dialog owner, CompiereColor color) - { - super(owner, "", true); - init (color); - } // AdempiereColorEditor - - /** - * Init Dialog - * @param color Start Color - */ - private void init (CompiereColor color) - { - try - { - jbInit(); - } - catch(Exception e) - { - e.printStackTrace(); - } - - bOK.addActionListener(this); - bCancel.addActionListener(this); - typeField.addActionListener(this); - flatField.addActionListener(this); - gradientUpper.addActionListener(this); - gradientLower.addActionListener(this); - urlField.addActionListener(this); - alphaField.addActionListener(this); - taintColor.addActionListener(this); - lineColor.addActionListener(this); - backColor.addActionListener(this); - widthField.addActionListener(this); - distanceField.addActionListener(this); - gradientStartField.addActionListener(this); - gradientDistanceField.addActionListener(this); - - if (color == null) - setColor (m_cc); - else - setColor (new CompiereColor(color)); - AdempierePLAF.showCenterScreen(this); - } // init - - - private static ResourceBundle res = ResourceBundle.getBundle("org.compiere.plaf.PlafRes"); - private CompiereColor m_cc = null; - private boolean m_saved = false; - private boolean m_setting = false; - - // - private CPanel northPanel = new CPanel(); - private CPanel southPanel = new CPanel(); - private CButton bOK = AdempierePLAF.getOKButton(); - private CButton bCancel = AdempierePLAF.getCancelButton(); - private FlowLayout southLayout = new FlowLayout(); - private GridBagLayout northLayout = new GridBagLayout(); - private CLabel typeLabel = new CLabel(); - private CComboBox typeField = new CComboBox(CompiereColor.TYPES); - private CButton gradientUpper = new CButton(); - private CButton gradientLower = new CButton(); - private CLabel urlLabel = new CLabel(); - private CTextField urlField = new CTextField(30); - private CLabel alphaLabel = new CLabel(); - private CTextField alphaField = new CTextField(10); - private CButton taintColor = new CButton(); - private CButton lineColor = new CButton(); - private CButton backColor = new CButton(); - private CLabel widthLabel = new CLabel(); - private CTextField widthField = new CTextField(10); - private CLabel distanceLabel = new CLabel(); - private CTextField distanceField = new CTextField(10); - private CPanel centerPanel = new CPanel(); - private CButton flatField = new CButton(); - private CComboBox gradientStartField = new CComboBox(CompiereColor.GRADIENT_SP); - private CTextField gradientDistanceField = new CTextField(10); - private CLabel gradientStartLabel = new CLabel(); - private CLabel gradientDistanceLabel = new CLabel(); - - /** - * Static Layout. - *
    -	 *      - northPanel
    -	 *          - labels & fields
    -	 *      - centerPanel
    -	 *      - southPanel
    -	 *  
    - * @throws Exception - */ - private void jbInit() throws Exception - { - this.setTitle(res.getString("AdempiereColorEditor")); - southPanel.setLayout(southLayout); - southLayout.setAlignment(FlowLayout.RIGHT); - northPanel.setLayout(northLayout); - typeLabel.setText(res.getString("AdempiereType")); - gradientUpper.setText(res.getString("GradientUpperColor")); - gradientLower.setText(res.getString("GradientLowerColor")); - gradientStartLabel.setText(res.getString("GradientStart")); - gradientDistanceLabel.setText(res.getString("GradientDistance")); - urlLabel.setText(res.getString("TextureURL")); - alphaLabel.setText(res.getString("TextureAlpha")); - taintColor.setText(res.getString("TextureTaintColor")); - lineColor.setText(res.getString("LineColor")); - backColor.setText(res.getString("LineBackColor")); - widthLabel.setText(res.getString("LineWidth")); - distanceLabel.setText(res.getString("LineDistance")); - flatField.setText(res.getString("FlatColor")); - centerPanel.setBorder(BorderFactory.createRaisedBevelBorder()); - centerPanel.setPreferredSize(new Dimension(400, 200)); - centerPanel.setOpaque(true); - northPanel.setPreferredSize(new Dimension(400, 150)); - southPanel.add(bCancel, null); - this.getContentPane().add(northPanel, BorderLayout.NORTH); - southPanel.add(bOK, null); - this.getContentPane().add(southPanel, BorderLayout.SOUTH); - this.getContentPane().add(centerPanel, BorderLayout.CENTER); - northPanel.add(typeLabel, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); - northPanel.add(typeField, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 0, 5), 0, 0)); - northPanel.add(gradientLower, new GridBagConstraints(1, 2, 1, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5), 0, 0)); - northPanel.add(urlField, new GridBagConstraints(1, 5, 2, 1, 1.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5), 0, 0)); - northPanel.add(alphaLabel, new GridBagConstraints(0, 6, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); - northPanel.add(alphaField, new GridBagConstraints(1, 6, 1, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5), 0, 0)); - northPanel.add(taintColor, new GridBagConstraints(1, 7, 1, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5), 0, 0)); - northPanel.add(backColor, new GridBagConstraints(1, 8, 1, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5), 0, 0)); - northPanel.add(widthLabel, new GridBagConstraints(0, 9, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); - northPanel.add(widthField, new GridBagConstraints(1, 9, 1, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); - northPanel.add(distanceLabel, new GridBagConstraints(0, 10, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); - northPanel.add(distanceField, new GridBagConstraints(1, 10, 1, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); - northPanel.add(flatField, new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5), 0, 0)); - northPanel.add(gradientStartField, new GridBagConstraints(1, 3, 1, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); - northPanel.add(gradientDistanceField, new GridBagConstraints(1, 4, 1, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); - northPanel.add(urlLabel, new GridBagConstraints(0, 5, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); - northPanel.add(gradientStartLabel, new GridBagConstraints(0, 3, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); - northPanel.add(gradientDistanceLabel, new GridBagConstraints(0, 4, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); - northPanel.add(gradientUpper, new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5), 0, 0)); - northPanel.add(lineColor, new GridBagConstraints(0, 8, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5), 0, 0)); - } // jbInit - - /** - * Action Listener - * @param e event - */ - public void actionPerformed(ActionEvent e) - { - if (m_setting) - return; - if (e.getSource() == bOK) - { - m_saved = true; - dispose(); - return; - } - else if (e.getSource() == bCancel) - { - dispose(); - return; - } - - /**** Field Changes ****/ - try - { - // Type - if (e.getSource() == typeField) - cmd_type(); - // Flat - else if (e.getSource() == flatField) - m_cc.setFlatColor(JColorChooser.showDialog - (this, flatField.getText(), m_cc.getFlatColor())); - // Gradient - else if (e.getSource() == gradientUpper) - m_cc.setGradientUpperColor(JColorChooser.showDialog - (this, gradientUpper.getText(), m_cc.getGradientUpperColor())); - else if (e.getSource() == gradientLower) - m_cc.setGradientLowerColor(JColorChooser.showDialog - (this, gradientLower.getText(), m_cc.getGradientLowerColor())); - else if (e.getSource() == gradientStartField) - m_cc.setGradientStartPoint - (((KeyNamePair)gradientStartField.getSelectedItem()).getKey()); - else if (e.getSource() == gradientDistanceField) - m_cc.setGradientRepeatDistance(gradientDistanceField.getText()); - // Texture - else if (e.getSource() == urlField) - m_cc.setTextureURL(urlField.getText()); - else if (e.getSource() == alphaField) - m_cc.setTextureCompositeAlpha(alphaField.getText()); - else if (e.getSource() == taintColor) - m_cc.setTextureTaintColor(JColorChooser.showDialog - (this, taintColor.getText(), m_cc.getTextureTaintColor())); - // Lines - else if (e.getSource() == lineColor) - m_cc.setLineColor(JColorChooser.showDialog - (this, lineColor.getText(), m_cc.getLineColor())); - else if (e.getSource() == backColor) - m_cc.setLineBackColor(JColorChooser.showDialog - (this, backColor.getText(), m_cc.getLineBackColor())); - else if (e.getSource() == widthField) - m_cc.setLineWidth(widthField.getText()); - else if (e.getSource() == distanceField) - m_cc.setLineDistance(distanceField.getText()); - } - catch (Exception ee) - { - } - setColor (m_cc); - } // actionPerformed - - /** - * Set Type with default values - */ - private void cmd_type() - { - ValueNamePair vp = (ValueNamePair)typeField.getSelectedItem(); - if (vp.getValue().equals(CompiereColor.TYPE_FLAT)) - m_cc = new CompiereColor(CompiereColor.TYPE_FLAT); - else if (vp.getValue().equals(CompiereColor.TYPE_GRADIENT)) - m_cc = new CompiereColor(CompiereColor.TYPE_GRADIENT); - else if (vp.getValue().equals(CompiereColor.TYPE_TEXTURE)) - m_cc = new CompiereColor(CompiereColor.TYPE_TEXTURE); - else if (vp.getValue().equals(CompiereColor.TYPE_LINES)) - m_cc = new CompiereColor(CompiereColor.TYPE_LINES); - setColor (m_cc); - } // cmd_type - - /** - * Set Color and update UI - * @param color color - */ - public void setColor (CompiereColor color) - { - if (color == null && m_cc != null) - return; - // - // System.out.println("AdempiereColorEditor.setColor " + color); - m_cc = color; - if (m_cc == null) - m_cc = CompiereColor.getDefaultBackground(); - - // update display - updateFields(); - centerPanel.setBackgroundColor(m_cc); - centerPanel.repaint(); - } // setColor - - /** - * UpdateField from AdempiereColor - */ - private void updateFields() - { - m_setting = true; - // Type - for (int i = 0; i < CompiereColor.TYPES.length; i++) - { - if (m_cc.getType().equals(CompiereColor.TYPE_VALUES[i])) - { - typeField.setSelectedItem(CompiereColor.TYPES[i]); - break; - } - } - // - if (m_cc.isFlat()) - { - flatField.setVisible(true); - gradientUpper.setVisible(false); - gradientLower.setVisible(false); - gradientStartLabel.setVisible(false); - gradientDistanceLabel.setVisible(false); - gradientStartField.setVisible(false); - gradientDistanceField.setVisible(false); - urlLabel.setVisible(false); - urlField.setVisible(false); - alphaLabel.setVisible(false); - alphaField.setVisible(false); - taintColor.setVisible(false); - lineColor.setVisible(false); - backColor.setVisible(false); - widthLabel.setVisible(false); - widthField.setVisible(false); - distanceLabel.setVisible(false); - distanceField.setVisible(false); - // - flatField.setBackground(m_cc.getFlatColor()); - } - else if (m_cc.isGradient()) - { - flatField.setVisible(false); - gradientUpper.setVisible(true); - gradientLower.setVisible(true); - gradientStartLabel.setVisible(true); - gradientDistanceLabel.setVisible(true); - gradientStartField.setVisible(true); - gradientDistanceField.setVisible(true); - urlLabel.setVisible(false); - urlField.setVisible(false); - alphaLabel.setVisible(false); - alphaField.setVisible(false); - taintColor.setVisible(false); - lineColor.setVisible(false); - backColor.setVisible(false); - widthLabel.setVisible(false); - widthField.setVisible(false); - distanceLabel.setVisible(false); - distanceField.setVisible(false); - // - gradientUpper.setBackground(m_cc.getGradientUpperColor()); - gradientLower.setBackground(m_cc.getGradientLowerColor()); - gradientDistanceField.setText(String.valueOf(m_cc.getGradientRepeatDistance())); - for (int i = 0; i < CompiereColor.GRADIENT_SP.length; i++) - { - if (m_cc.getGradientStartPoint() == CompiereColor.GRADIENT_SP_VALUES[i]) - { - gradientStartField.setSelectedItem(CompiereColor.GRADIENT_SP[i]); - break; - } - } - } - else if (m_cc.isTexture()) - { - flatField.setVisible(false); - gradientUpper.setVisible(false); - gradientLower.setVisible(false); - gradientStartLabel.setVisible(false); - gradientDistanceLabel.setVisible(false); - gradientStartField.setVisible(false); - gradientDistanceField.setVisible(false); - urlLabel.setVisible(true); - urlField.setVisible(true); - alphaLabel.setVisible(true); - alphaField.setVisible(true); - taintColor.setVisible(true); - lineColor.setVisible(false); - backColor.setVisible(false); - widthLabel.setVisible(false); - widthField.setVisible(false); - distanceLabel.setVisible(false); - distanceField.setVisible(false); - // - urlField.setText(m_cc.getTextureURL().toString()); - alphaField.setText(String.valueOf(m_cc.getTextureCompositeAlpha())); - taintColor.setBackground(m_cc.getTextureTaintColor()); - } - else if (m_cc.isLine()) - { - flatField.setVisible(false); - gradientUpper.setVisible(false); - gradientLower.setVisible(false); - gradientStartLabel.setVisible(false); - gradientDistanceLabel.setVisible(false); - gradientStartField.setVisible(false); - gradientDistanceField.setVisible(false); - urlLabel.setVisible(false); - urlField.setVisible(false); - alphaLabel.setVisible(false); - alphaField.setVisible(false); - taintColor.setVisible(false); - lineColor.setVisible(true); - backColor.setVisible(true); - widthLabel.setVisible(true); - widthField.setVisible(true); - distanceLabel.setVisible(true); - distanceField.setVisible(true); - // - lineColor.setBackground(m_cc.getLineColor()); - backColor.setBackground(m_cc.getLineBackColor()); - widthField.setText(String.valueOf(m_cc.getLineWidth())); - distanceField.setText(String.valueOf(m_cc.getLineDistance())); - } - m_setting = false; - } // updateFields - - /** - * Get Color - * @return Color, when saved - else null - */ - public CompiereColor getColor() - { - return m_cc; - } // getColor - - /** - * Was the selection saved - * @return true if saved - */ - public boolean isSaved() - { - return m_saved; - } // m_saved - - /*************************************************************************/ - - /** - * Set (or change) the object that is to be edited. Primitive types such - * as "int" must be wrapped as the corresponding object type such as - * "java.lang.Integer". - * - * @param value The new target object to be edited. Note that this - * object should not be modified by the PropertyEditor, rather - * the PropertyEditor should create a new object to hold any - * modified value. - */ - public void setValue(Object value) - { - if (value != null && value instanceof CompiereColor) - setColor (new CompiereColor((CompiereColor)value)); - else - throw new IllegalArgumentException("AdempiereColorEditor.setValue requires AdempiereColor"); - } // setValue - - /** - * Gets the property value. - * - * @return The value of the property. Primitive types such as "int" will - * be wrapped as the corresponding object type such as "java.lang.Integer". - */ - public Object getValue() - { - return getColor(); - } // getColor - - /** - * Determines whether this property editor is paintable. - * @return True if the class will honor the paintValue method. - */ - public boolean isPaintable() - { - return false; - } - - /** - * Paint a representation of the value into a given area of screen - * real estate. Note that the propertyEditor is responsible for doing - * its own clipping so that it fits into the given rectangle. - *

    - * If the PropertyEditor doesn't honor paint requests (see isPaintable) - * this method should be a silent noop. - *

    - * The given Graphics object will have the default font, color, etc of - * the parent container. The PropertyEditor may change graphics attributes - * such as font and color and doesn't need to restore the old values. - * - * @param gfx Graphics object to paint into. - * @param box Rectangle within graphics object into which we should paint. - */ - public void paintValue(Graphics gfx, Rectangle box) - { - /**@todo: Implement this java.beans.PropertyEditor method*/ - throw new java.lang.UnsupportedOperationException("Method paintValue() not yet implemented."); - } // paintValue - - /** - * This method is intended for use when generating Java code to set - * the value of the property. It should return a fragment of Java code - * that can be used to initialize a variable with the current property - * value. - *

    - * Example results are "2", "new Color(127,127,34)", "Color.orange", etc. - * - * @return A fragment of Java code representing an initializer for the - * current value. - */ - public String getJavaInitializationString() - { - return "new AdempiereColor()"; - } // String getJavaInitializationString - - /** - * Gets the property value as text. - * - * @return The property value as a human editable string. - *

    Returns null if the value can't be expressed as an editable string. - *

    If a non-null value is returned, then the PropertyEditor should - * be prepared to parse that string back in setAsText(). - */ - public String getAsText() - { - return m_cc.toString(); - } // getAsText - - /** - * Set the property value by parsing a given String. May raise - * java.lang.IllegalArgumentException if either the String is - * badly formatted or if this kind of property can't be expressed - * as text. - * @param text The string to be parsed. - * @throws IllegalArgumentException - */ - public void setAsText(String text) throws java.lang.IllegalArgumentException - { - throw new java.lang.IllegalArgumentException("AdempiereColorEditor.setAsText not supported"); - } // setAsText - - /** - * If the property value must be one of a set of known tagged values, - * then this method should return an array of the tags. This can - * be used to represent (for example) enum values. If a PropertyEditor - * supports tags, then it should support the use of setAsText with - * a tag value as a way of setting the value and the use of getAsText - * to identify the current value. - * - * @return The tag values for this property. May be null if this - * property cannot be represented as a tagged value. - */ - public String[] getTags() - { - return null; - } // getTags - - /** - * A PropertyEditor may choose to make available a full custom Component - * that edits its property value. It is the responsibility of the - * PropertyEditor to hook itself up to its editor Component itself and - * to report property value changes by firing a PropertyChange event. - *

    - * The higher-level code that calls getCustomEditor may either embed - * the Component in some larger property sheet, or it may put it in - * its own individual dialog, or ... - * - * @return A java.awt.Component that will allow a human to directly - * edit the current property value. May be null if this is - * not supported. - */ - public Component getCustomEditor() - { - return this; - } // getCustomEditor - - /** - * Determines whether this property editor supports a custom editor. - * @return True if the propertyEditor can provide a custom editor. - */ - public boolean supportsCustomEditor() - { - return true; - } // supportsCustomEditor - - /** - * Register a listener for the PropertyChange event. When a - * PropertyEditor changes its value it should fire a PropertyChange - * event on all registered PropertyChangeListeners, specifying the - * null value for the property name and itself as the source. - * - * @param listener An object to be invoked when a PropertyChange - * event is fired. - */ - public void addPropertyChangeListener(PropertyChangeListener listener) - { - super.addPropertyChangeListener(listener); - } // addPropertyChangeListener - - /** - * Remove a listener for the PropertyChange event. - * @param listener The PropertyChange listener to be removed. - */ - public void removePropertyChangeListener(PropertyChangeListener listener) - { - super.removePropertyChangeListener(listener); - } // removePropertyChangeListener - -} // AdempiereColorEditor diff --git a/org.adempiere.ui.swing/src/org/compiere/swing/ExtendedTheme.java b/org.adempiere.ui.swing/src/org/compiere/swing/ExtendedTheme.java deleted file mode 100644 index f77b18b7ff..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/swing/ExtendedTheme.java +++ /dev/null @@ -1,34 +0,0 @@ -package org.compiere.swing; - -import java.util.Map; - -import javax.swing.plaf.ColorUIResource; - -public interface ExtendedTheme { - - public ColorUIResource getWhite(); - public ColorUIResource getBlack(); - public ColorUIResource getErrorForeground(); - public ColorUIResource getErrorBackground(); - public ColorUIResource getInactiveBackground(); - public ColorUIResource getMandatoryBackground(); - public ColorUIResource getInfoBackground(); - - public final static ColorUIResource DEFAULT_MANDATORY_BG = new ColorUIResource(224, 224, 255); // blue-isch - public final static ColorUIResource DEFAULT_ERROR_BG = new ColorUIResource(255, 204, 204); // red-isch - public final static ColorUIResource DEFAULT_ERROR_FG = new ColorUIResource(204, 0, 0); // dark red - public final static ColorUIResource DEFAULT_INACTIVE_BG = new ColorUIResource(234, 234, 234); // light gray - public final static ColorUIResource DEFAULT_INFO_BG = new ColorUIResource(253, 237, 207); // light yellow - public final static ColorUIResource DEFAULT_SELECTED_BG = new ColorUIResource(240, 248, 255); // light gray - public final static ColorUIResource DEFAULT_READONLY_BG = new ColorUIResource(255, 245, 238); // light yellow - - public void setUIProperties(Map propertyMap); - - public final static String ERROR_BG_KEY = "TextField.errorBackground"; - public final static String ERROR_FG_KEY = "TextField.errorForeground"; - public final static String MANDATORY_BG_KEY = "TextField.mandatoryBackground"; - public final static String INACTIVE_BG_KEY = "TextField.inactiveBackground"; - public final static String INFO_BG_KEY = "Info.background"; - public final static String SELECTED_BG_KEY = "TextField.selectedBackground"; - public final static String READONLY_BG_KEY = "TextField.readonlyBackground"; -} diff --git a/org.adempiere.ui.swing/src/org/compiere/swing/FontChooser.java b/org.adempiere.ui.swing/src/org/compiere/swing/FontChooser.java deleted file mode 100644 index c553c9cef5..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/swing/FontChooser.java +++ /dev/null @@ -1,324 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ -package org.compiere.swing; - -import java.awt.BorderLayout; -import java.awt.Dialog; -import java.awt.Dimension; -import java.awt.FlowLayout; -import java.awt.Font; -import java.awt.GraphicsEnvironment; -import java.awt.GridBagConstraints; -import java.awt.GridBagLayout; -import java.awt.Insets; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.util.Arrays; -import java.util.ResourceBundle; - -import javax.swing.BorderFactory; -import javax.swing.JTextArea; - -import org.adempiere.plaf.AdempierePLAF; - -/** - * Font Chooser Dialog - * - * @author Jorg Janke - * @version $Id: FontChooser.java,v 1.2 2006/07/30 00:52:24 jjanke Exp $ - */ -public class FontChooser extends CDialog - implements ActionListener -{ - /** - * - */ - private static final long serialVersionUID = -755094979517882166L; - - /** - * Show Dialog with initial font and return selected font - * @param owner Base window - * @param title Chooser Title - * @param initFont initial font - * @return selected font - */ - public static Font showDialog (Dialog owner, String title, Font initFont) - { - Font retValue = initFont; - FontChooser fc = new FontChooser(owner, title, initFont); - retValue = fc.getFont(); - fc = null; - return retValue; - } // showDialog - - - /************************************************************************** - * Constructor - * - * @param owner Base window - * @param title Chooser Title - * @param initFont Initial Font - */ - public FontChooser(Dialog owner, String title, Font initFont) - { - super(owner, title, true); - try - { - jbInit(); - dynInit(); - setFont(initFont); - AdempierePLAF.showCenterScreen(this); - } - catch(Exception ex) - { - System.err.println ("FontChooser"); - ex.printStackTrace(); - } - } // FontChooser - - /** - * IDE Constructor - */ - public FontChooser() - { - this (null, s_res.getString("FontChooser"), null); - } // FontChooser - - static ResourceBundle s_res = ResourceBundle.getBundle("org.compiere.plaf.PlafRes"); - - /** Static list of Styles */ - public static FontStyle[] s_list = { - new FontStyle(s_res.getString("Plain"), Font.PLAIN), - new FontStyle(s_res.getString("Italic"), Font.ITALIC), - new FontStyle(s_res.getString("Bold"), Font.BOLD), - new FontStyle(s_res.getString("BoldItalic"), Font.BOLD|Font.ITALIC)}; - - private Font m_font = super.getFont(); - private Font m_retFont = null; - - private boolean m_setting = false; - - private CPanel mainPanel = new CPanel(); - private BorderLayout mainLayout = new BorderLayout(); - private CPanel selectPanel = new CPanel(); - private CLabel nameLabel = new CLabel(); - private CComboBoxfontName = new CComboBox(); - private CLabel sizeLabel = new CLabel(); - private CLabel styleLabel = new CLabel(); - private CComboBoxfontStyle = new CComboBox(); - private CComboBoxfontSize = new CComboBox(); - private JTextArea fontTest = new JTextArea(); - private JTextArea fontInfo = new JTextArea(); - private GridBagLayout selectLayout = new GridBagLayout(); - private CPanel confirmPanel = new CPanel(); - private CButton bCancel = AdempierePLAF.getCancelButton(); - private CButton bOK = AdempierePLAF.getOKButton(); - private FlowLayout confirmLayout = new FlowLayout(); - - /** - * Static Layout - * @throws Exception - */ - private void jbInit() throws Exception - { - mainPanel.setLayout(mainLayout); - nameLabel.setText(s_res.getString("Name")); - selectPanel.setLayout(selectLayout); - sizeLabel.setText(s_res.getString("Size")); - styleLabel.setText(s_res.getString("Style")); - fontTest.setText(s_res.getString("TestString")); - fontTest.setLineWrap(true); - fontTest.setWrapStyleWord(true); - fontTest.setBackground(AdempierePLAF.getFieldBackground_Inactive()); - fontTest.setBorder(BorderFactory.createLoweredBevelBorder()); - fontTest.setPreferredSize(new Dimension(220, 100)); - fontInfo.setText(s_res.getString("FontString")); - fontInfo.setLineWrap(true); - fontInfo.setWrapStyleWord(true); - fontInfo.setBackground(AdempierePLAF.getFieldBackground_Inactive()); - fontInfo.setOpaque(false); - fontInfo.setEditable(false); - confirmPanel.setLayout(confirmLayout); - confirmLayout.setAlignment(FlowLayout.RIGHT); - confirmPanel.setOpaque(false); - selectPanel.setOpaque(false); - getContentPane().add(mainPanel); - mainPanel.add(selectPanel, BorderLayout.CENTER); - selectPanel.add(nameLabel, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); - selectPanel.add(fontName, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); - selectPanel.add(sizeLabel, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); - selectPanel.add(styleLabel, new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); - selectPanel.add(fontStyle, new GridBagConstraints(1, 2, 2, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); - selectPanel.add(fontSize, new GridBagConstraints(1, 1, 2, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); - selectPanel.add(fontTest, new GridBagConstraints(0, 3, 2, 1, 0.0, 0.0 - ,GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(20, 5, 5, 5), 0, 0)); - selectPanel.add(fontInfo, new GridBagConstraints(0, 4, 2, 1, 0.0, 0.0 - ,GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(10, 5, 10, 5), 0, 0)); - // - mainPanel.add(confirmPanel, BorderLayout.SOUTH); - confirmPanel.add(bCancel, null); - confirmPanel.add(bOK, null); - bCancel.addActionListener(this); - bOK.addActionListener(this); - } // jbInit - - /** - * Dynamic Init - */ - private void dynInit() - { - String[] names = GraphicsEnvironment.getLocalGraphicsEnvironment().getAvailableFontFamilyNames(); - Arrays.sort(names); - for (int i = 0; i < names.length; i++) - fontName.addItem(names[i]); - fontName.addActionListener(this); - // - for (int i = 6; i < 32; i++) - fontSize.addItem(String.valueOf(i)); - fontSize.addActionListener(this); - // - for (int i = 0; i < s_list.length; i++) - fontStyle.addItem(s_list[i]); - fontStyle.addActionListener(this); - } // dynInit - - /** - * Set Font - sets font for chooser - not the component font - * @param font - */ - public void setFont(Font font) - { - if (font == null) - return; - // Log.trace("FontChooser.setFont - " + font.toString()); - if (m_retFont == null) - m_retFont = font; - // - fontTest.setFont(font); - fontInfo.setFont(font); - fontInfo.setText(font.toString()); - // - m_setting = true; - fontName.setSelectedItem(font.getName()); - if (!fontName.getSelectedItem().equals(font.getName())) - System.err.println("FontChooser.setFont" + fontName.getSelectedItem().toString() + " <> " + font.getName()); - // - fontSize.setSelectedItem(String.valueOf(font.getSize())); - if (!fontSize.getSelectedItem().equals(String.valueOf(font.getSize()))) - System.err.println("FontChooser.setFont" + fontSize.getSelectedItem() + " <> " + font.getSize()); - // find style - for (int i = 0; i < s_list.length; i++) - if (s_list[i].getID() == font.getStyle()) - fontStyle.setSelectedItem(s_list[i]); - if (((FontStyle)fontStyle.getSelectedItem()).getID() != font.getStyle()) - System.err.println("FontChooser.setFont" + ((FontStyle)fontStyle.getSelectedItem()).getID() + " <> " + font.getStyle()); - // - m_font = font; - this.pack(); - m_setting = false; - } // setFont - - /** - * Return selected font - * @return font - */ - public Font getFont() - { - return m_retFont; - } // getFont - - /** - * ActionListener - * @param e - */ - public void actionPerformed(ActionEvent e) - { - if (m_setting) - return; - - if (e.getSource() == bOK) - { - m_retFont = m_font; - dispose(); - } - - else if (e.getSource() == bCancel) - dispose(); - - else if (e.getSource() == fontName) - { - String s = fontName.getSelectedItem().toString(); - m_font = new Font(s, m_font.getStyle(), m_font.getSize()); - } - else if (e.getSource() == fontSize) - { - String s = fontSize.getSelectedItem().toString(); - m_font = new Font(m_font.getName(), m_font.getStyle(), Integer.parseInt(s)); - } - else if (e.getSource() == fontStyle) - { - FontStyle fs = (FontStyle)fontStyle.getSelectedItem(); - m_font = new Font(m_font.getName(), fs.getID(), m_font.getSize()); - } - // System.out.println("NewFont - " + m_font.toString()); - setFont(m_font); - } // actionPerformed -} // FontChooser - -/** - * Font Style Value Object - */ -class FontStyle -{ - /** - * Create FontStyle - * @param name - * @param id - */ - public FontStyle(String name, int id) - { - m_name = name; - m_id = id; - } // FontStyle - - private String m_name; - private int m_id; - - /** - * Get Name - * @return name - */ - public String toString() - { - return m_name; - } // getName - - /** - * Get int value of Font Style - * @return id - */ - public int getID() - { - return m_id; - } // getID -} // FontStyle diff --git a/org.adempiere.ui.swing/src/org/compiere/swing/ShadowBorder.java b/org.adempiere.ui.swing/src/org/compiere/swing/ShadowBorder.java deleted file mode 100644 index 17444ae62e..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/swing/ShadowBorder.java +++ /dev/null @@ -1,77 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 Adempiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - *****************************************************************************/ -package org.compiere.swing; - -import java.awt.Color; -import java.awt.Component; -import java.awt.Graphics; -import java.awt.Insets; - -import javax.swing.UIManager; -import javax.swing.border.AbstractBorder; - -/** - * A border with a drop shadow. - * Extracted from JGoodies look demo. - * @author Low Heng Sin - * @version 2006-11-24 - */ -public class ShadowBorder extends AbstractBorder { - - /** - * - */ - private static final long serialVersionUID = 4027643023639628783L; - private static final Insets INSETS = new Insets(1, 1, 3, 3); - - public Insets getBorderInsets(Component c) { return INSETS; } - - public void paintBorder(Component c, Graphics g, - int x, int y, int w, int h) { - - Color shadow = UIManager.getColor("controlShadow"); - if (shadow == null) { - shadow = Color.GRAY; - } - Color lightShadow = new Color(shadow.getRed(), - shadow.getGreen(), - shadow.getBlue(), - 170); - Color lighterShadow = new Color(shadow.getRed(), - shadow.getGreen(), - shadow.getBlue(), - 70); - g.translate(x, y); - - g.setColor(shadow); - g.fillRect(0, 0, w - 3, 1); - g.fillRect(0, 0, 1, h - 3); - g.fillRect(w - 3, 1, 1, h - 3); - g.fillRect(1, h - 3, w - 3, 1); - // Shadow line 1 - g.setColor(lightShadow); - g.fillRect(w - 3, 0, 1, 1); - g.fillRect(0, h - 3, 1, 1); - g.fillRect(w - 2, 1, 1, h - 3); - g.fillRect(1, h - 2, w - 3, 1); - // Shadow line2 - g.setColor(lighterShadow); - g.fillRect(w - 2, 0, 1, 1); - g.fillRect(0, h - 2, 1, 1); - g.fillRect(w-2, h-2, 1, 1); - g.fillRect(w - 1, 1, 1, h - 2); - g.fillRect(1, h - 1, w - 2, 1); - g.translate(-x, -y); - } -} diff --git a/org.adempiere.ui.swing/src/org/compiere/swing/StackedBox.java b/org.adempiere.ui.swing/src/org/compiere/swing/StackedBox.java deleted file mode 100644 index 9dfc051ce1..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/swing/StackedBox.java +++ /dev/null @@ -1,216 +0,0 @@ -/* - * $Id: StackedBox.java.txt,v 1.1 2006/03/09 20:48:47 rbair Exp $ - * - * Copyright 2004 Sun Microsystems, Inc., 4150 Network Circle, - * Santa Clara, California 95054, U.S.A. All rights reserved. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ -package org.compiere.swing; - -import java.awt.Color; -import java.awt.Component; -import java.awt.Dimension; -import java.awt.Font; -import java.awt.Graphics; -import java.awt.Insets; -import java.awt.Rectangle; - -import javax.swing.Action; -import javax.swing.BorderFactory; -import javax.swing.JPanel; -import javax.swing.JViewport; -import javax.swing.Scrollable; -import javax.swing.UIManager; -import javax.swing.border.Border; -import javax.swing.border.CompoundBorder; - -import org.jdesktop.swingx.JXCollapsiblePane; -import org.jdesktop.swingx.JXHyperlink; -import org.jdesktop.swingx.VerticalLayout; - -/** - * Stacks components vertically in boxes. Each box is created with a title and a - * component.
    - * - *

    - * The StackedBox can be added to a - * {@link javax.swing.JScrollPane}. - * - *

    - * - * @author Frederic Lavigne - */ -public class StackedBox extends JPanel implements Scrollable { - - /** - * - */ - private static final long serialVersionUID = -8233461475245242991L; -private Color titleBackgroundColor; - private Color titleForegroundColor; - private Color separatorColor; - private Border separatorBorder; - - public StackedBox() { - setLayout(new VerticalLayout()); - setOpaque(true); - setBackground(Color.WHITE); - - separatorBorder = new SeparatorBorder(); - setTitleForegroundColor(Color.BLACK); - setTitleBackgroundColor(new Color(248, 248, 248)); - setSeparatorColor(new Color(214, 223, 247)); - } - - public Color getSeparatorColor() { - return separatorColor; - } - - public void setSeparatorColor(Color separatorColor) { - this.separatorColor = separatorColor; - } - - public Color getTitleForegroundColor() { - return titleForegroundColor; - } - - public void setTitleForegroundColor(Color titleForegroundColor) { - this.titleForegroundColor = titleForegroundColor; - } - - public Color getTitleBackgroundColor() { - return titleBackgroundColor; - } - - public void setTitleBackgroundColor(Color titleBackgroundColor) { - this.titleBackgroundColor = titleBackgroundColor; - } - - /** - * Adds a new component to this StackedBox - * - * @param title - * @param component - */ - public void addBox(String title, Component component) { - final JXCollapsiblePane collapsible = new JXCollapsiblePane(); - collapsible.getContentPane().setBackground(Color.WHITE); - collapsible.add(component); - collapsible.setBorder(new CompoundBorder(separatorBorder, collapsible - .getBorder())); - - Action toggleAction = collapsible.getActionMap().get( - JXCollapsiblePane.TOGGLE_ACTION); - // use the collapse/expand icons from the JTree UI - toggleAction.putValue(JXCollapsiblePane.COLLAPSE_ICON, UIManager - .getIcon("Tree.expandedIcon")); - toggleAction.putValue(JXCollapsiblePane.EXPAND_ICON, UIManager - .getIcon("Tree.collapsedIcon")); - - JXHyperlink link = new JXHyperlink(toggleAction); - link.setText(title); - link.setFont(link.getFont().deriveFont(Font.BOLD)); - link.setOpaque(true); - link.setBackground(getTitleBackgroundColor()); - link.setFocusPainted(false); - - link.setUnclickedColor(getTitleForegroundColor()); - link.setClickedColor(getTitleForegroundColor()); - - link.setBorder(new CompoundBorder(separatorBorder, BorderFactory - .createEmptyBorder(2, 4, 2, 4))); - link.setBorderPainted(true); - - add(link); - add(collapsible); - } - - /** - * @see Scrollable#getPreferredScrollableViewportSize() - */ - public Dimension getPreferredScrollableViewportSize() { - return getPreferredSize(); - } - - /** - * @see Scrollable#getScrollableBlockIncrement(java.awt.Rectangle, int, int) - */ - public int getScrollableBlockIncrement(Rectangle visibleRect, - int orientation, int direction) { - return 10; - } - - /** - * @see Scrollable#getScrollableTracksViewportHeight() - */ - public boolean getScrollableTracksViewportHeight() { - if (getParent() instanceof JViewport) { - return (((JViewport)getParent()).getHeight() > getPreferredSize().height); - } else { - return false; - } - } - - /** - * @see Scrollable#getScrollableTracksViewportWidth() - */ - public boolean getScrollableTracksViewportWidth() { - return true; - } - - /** - * @see Scrollable#getScrollableUnitIncrement(java.awt.Rectangle, int, int) - */ - public int getScrollableUnitIncrement(Rectangle visibleRect, int orientation, - int direction) { - return 10; - } - - /** - * The border between the stack components. It separates each component with a - * fine line border. - */ - class SeparatorBorder implements Border { - - boolean isFirst(Component c) { - return c.getParent() == null || c.getParent().getComponent(0) == c; - } - - public Insets getBorderInsets(Component c) { - // if the collapsible is collapsed, we do not want its border to be - // painted. - if (c instanceof JXCollapsiblePane) { - if (((JXCollapsiblePane)c).isCollapsed()) { return new Insets(0, 0, 0, - 0); } - } - return new Insets(isFirst(c)?4:1, 0, 1, 0); - } - - public boolean isBorderOpaque() { - return true; - } - - public void paintBorder(Component c, Graphics g, int x, int y, int width, - int height) { - g.setColor(getSeparatorColor()); - if (isFirst(c)) { - g.drawLine(x, y + 2, x + width, y + 2); - } - g.drawLine(x, y + height - 1, x + width, y + height - 1); - } - } - -} diff --git a/org.adempiere.ui.swing/src/org/compiere/swing/TableCellNone.java b/org.adempiere.ui.swing/src/org/compiere/swing/TableCellNone.java deleted file mode 100644 index 76dbf00034..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/swing/TableCellNone.java +++ /dev/null @@ -1,76 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 2007 Adempiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - *****************************************************************************/ -package org.compiere.swing; - -import java.awt.Component; -import java.util.EventObject; - -import javax.swing.JTable; -import javax.swing.event.CellEditorListener; -import javax.swing.table.TableCellEditor; -import javax.swing.table.TableCellRenderer; - -/** - * Dummy editor and renderer use for invisible column - * @author Low Heng Sin - * - */ -public class TableCellNone implements TableCellEditor, TableCellRenderer { - - private Object m_value; - @SuppressWarnings("unused") - private String m_columnName; - - public TableCellNone(String columnName) { - m_columnName = columnName; - } - - public Component getTableCellEditorComponent(JTable table, Object value, - boolean isSelected, int row, int column) { - m_value = value; - return null; - } - - public void addCellEditorListener(CellEditorListener l) { - } - - public void cancelCellEditing() { - } - - public Object getCellEditorValue() { - return m_value; - } - - public boolean isCellEditable(EventObject anEvent) { - return false; - } - - public void removeCellEditorListener(CellEditorListener l) { - } - - public boolean shouldSelectCell(EventObject anEvent) { - return false; - } - - public boolean stopCellEditing() { - return true; - } - - public Component getTableCellRendererComponent(JTable table, Object value, - boolean isSelected, boolean hasFocus, int row, int column) { - m_value = value; - return null; - } - -} diff --git a/org.adempiere.ui.swing/src/org/compiere/swing/ThemeUtils.java b/org.adempiere.ui.swing/src/org/compiere/swing/ThemeUtils.java deleted file mode 100644 index fac8b60144..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/swing/ThemeUtils.java +++ /dev/null @@ -1,221 +0,0 @@ -package org.compiere.swing; - -import java.awt.Color; -import java.awt.Font; -import java.awt.SystemColor; -import java.util.HashMap; -import java.util.Map; -import java.util.Properties; -import java.util.logging.Level; -import java.util.logging.Logger; - -import javax.swing.plaf.ColorUIResource; -import javax.swing.plaf.FontUIResource; -import javax.swing.plaf.metal.MetalTheme; - -import org.compiere.plaf.CompiereColor; - -public final class ThemeUtils { - - /** Logger */ - private static Logger log = Logger.getLogger(ThemeUtils.class.getName()); - - /** - * Parses Color into String representation. - * Required as SystemColors and Alpha Colors have different formats - * @param c Color - * @return [r=102,g=102,b=153,a=255] - * @see #parseColor - */ - public static String getColorAsString (Color c) - { - if (c == null) - c = SystemColor.control; - StringBuffer sb = new StringBuffer("[r=").append(c.getRed()) - .append(",g=").append(c.getGreen()) - .append(",b=").append(c.getBlue()) - .append(",a=").append(c.getAlpha()) - .append("]"); - // System.out.println(sb.toString()); - return sb.toString(); - } // getColorAsString - - /** - * Parse Color. - *

    - * Color - [r=102,g=102,b=153,a=0] - * - * @param information string information to be parsed - * @param stdColor color used if info cannot parsed - * @return color - * @see #getColorAsString - */ - public static ColorUIResource parseColor (String information, ColorUIResource stdColor) - { - if (information == null - || information.length() == 0 - || information.trim().length() == 0) - return stdColor; - // System.out.print("ParseColor=" + info); - try - { - int r = Integer.parseInt(information.substring(information.indexOf("r=")+2, information.indexOf(",g="))); - int g = Integer.parseInt(information.substring(information.indexOf("g=")+2, information.indexOf(",b="))); - int b = 0; - int a = 255; - if (information.indexOf("a=") == -1) - b = Integer.parseInt(information.substring(information.indexOf("b=")+2, information.indexOf(']'))); - else - { - b = Integer.parseInt(information.substring(information.indexOf("b=")+2, information.indexOf(",a="))); - a = Integer.parseInt(information.substring(information.indexOf("a=")+2, information.indexOf(']'))); - } - ColorUIResource retValue = new ColorUIResource(new Color(r, g, b, a)); - // System.out.println(" - " + retValue.toString()); - return retValue; - } - catch (Exception e) - { - if (log.isLoggable(Level.CONFIG)) log.config(information + " - cannot parse: " + e.toString()); - } - return stdColor; - } // parseColor - - /** - * Parse Font - *

    - * javax.swing.plaf.FontUIResource[family=dialog.bold,name=Dialog,style=bold,size=12] - * - * @param information string information to be parsed - * @param stdFont font used if info cannot be parsed - * @return font - */ - public static FontUIResource parseFont(String information, FontUIResource stdFont) - { - if (information == null - || information.length() == 0 - || information.trim().length() == 0) - return stdFont; - // System.out.print("ParseFont=" + info); - try - { - String name = information.substring(information.indexOf("name=")+5, information.indexOf(",style=")); - String s = information.substring(information.indexOf("style=")+6, information.indexOf(",size=")); - int style = Font.PLAIN; - if (s.equals("bold")) - style = Font.BOLD; - else if (s.equals("italic")) - style = Font.ITALIC; - else if (s.equals("bolditalic")) - style = Font.BOLD | Font.ITALIC; - int size = Integer.parseInt(information.substring(information.indexOf(",size=")+6, information.lastIndexOf(']'))); - FontUIResource retValue = new FontUIResource(name,style,size); - // System.out.println(" - " + retValue.toString()); - return retValue; - } - catch (Exception e) - { - if (log.isLoggable(Level.CONFIG)) log.config(information + " - cannot parse: " + e.toString()); - } - return stdFont; - } // parseFont - - // Static property info - public static final String P_Primary1 = "#ColorPrimary1"; - public static final String P_Primary2 = "#ColorPrimary2"; - public static final String P_Primary3 = "#ColorPrimary3"; - public static final String P_Secondary1 = "#ColorSecondary1"; - public static final String P_Secondary2 = "#ColorSecondary2"; - public static final String P_Secondary3 = "#ColorSecondary3"; - public static final String P_Black = "#ColorBlack"; - public static final String P_White = "#ColorWhite"; - public static final String P_Error = "#ColorError"; - public static final String P_Info = "#ColorInfo"; - public static final String P_Mandatory = "#ColorMandatory"; - public static final String P_Inactive = "#ColorInactive"; - public static final String P_Txt_OK = "#ColorTextOK"; - public static final String P_Txt_Error = "#ColorTextError"; - // - public static final String P_Control = "#FontControl"; - public static final String P_System = "#FontSystem"; - public static final String P_User = "#FontUser"; - public static final String P_Small = "#FontSmall"; - public static final String P_Window = "#FontWindow"; - public static final String P_Menu = "#FontMenu"; - - /** - * Save information in Properties - */ - public static void save (Properties properties, MetalTheme theme) - { - if (log.isLoggable(Level.CONFIG)) log.config(CompiereColor.getDefaultBackground().toString()); - // - properties.setProperty(P_Primary1, getColorAsString(theme.getPrimaryControlDarkShadow())); - properties.setProperty(P_Primary2, getColorAsString(theme.getPrimaryControlShadow())); - properties.setProperty(P_Primary3, getColorAsString(theme.getPrimaryControl())); - properties.setProperty(P_Secondary1, getColorAsString(theme.getControlDarkShadow())); - properties.setProperty(P_Secondary2, getColorAsString(theme.getControlShadow())); - properties.setProperty(P_Secondary3, getColorAsString(theme.getControl())); - properties.setProperty(P_Txt_OK, getColorAsString(theme.getUserTextColor())); - - if ( theme instanceof ExtendedTheme ) { - ExtendedTheme e = (ExtendedTheme)theme; - properties.setProperty(P_Error, getColorAsString(e.getErrorBackground())); - properties.setProperty(P_Txt_Error, getColorAsString(e.getErrorForeground())); - properties.setProperty(P_Mandatory, getColorAsString(e.getMandatoryBackground())); - properties.setProperty(P_Inactive, getColorAsString(e.getInactiveBackground())); - properties.setProperty(P_White, getColorAsString(e.getWhite())); - properties.setProperty(P_Black, getColorAsString(e.getBlack())); - properties.setProperty(P_Info, getColorAsString(e.getInfoBackground())); - } else { - properties.setProperty(P_White, getColorAsString(Color.white)); - properties.setProperty(P_Black, getColorAsString(Color.black)); - properties.setProperty(P_Error, getColorAsString(ExtendedTheme.DEFAULT_ERROR_BG)); - properties.setProperty(P_Txt_Error, getColorAsString(ExtendedTheme.DEFAULT_ERROR_FG)); - properties.setProperty(P_Mandatory, getColorAsString(ExtendedTheme.DEFAULT_MANDATORY_BG)); - properties.setProperty(P_Inactive, getColorAsString(ExtendedTheme.DEFAULT_INACTIVE_BG)); - properties.setProperty(P_Info, getColorAsString(theme.getPrimaryControl())); - } - - // - properties.setProperty(P_Control, (theme.getControlTextFont()).toString()); - properties.setProperty(P_System, (theme.getSystemTextFont()).toString()); - properties.setProperty(P_User, (theme.getUserTextFont()).toString()); - properties.setProperty(P_Small, (theme.getSubTextFont()).toString()); - properties.setProperty(P_Window, (theme.getWindowTitleFont()).toString()); - properties.setProperty(P_Menu, (theme.getMenuTextFont()).toString()); - - } // save - - - /** - * Load Properties from properties - */ - public static void load (Properties properties, ExtendedTheme theme) - { - Map p = new HashMap(); - p.put(P_Primary1, parseColor (properties.getProperty(P_Primary1),null)); - p.put(P_Primary2, parseColor (properties.getProperty(P_Primary2),null)); - p.put(P_Primary3, parseColor (properties.getProperty(P_Primary3), null)); - p.put(P_Secondary1, parseColor (properties.getProperty(P_Secondary1), null)); - p.put(P_Secondary2, parseColor (properties.getProperty(P_Secondary2), null)); - p.put(P_Secondary3, parseColor (properties.getProperty(P_Secondary3), null)); - p.put(P_Error, parseColor(properties.getProperty(P_Error), null)); - p.put(P_Info, parseColor(properties.getProperty(P_Info), null)); - p.put(P_Mandatory, parseColor(properties.getProperty(P_Mandatory), null)); - p.put(P_Inactive, parseColor(properties.getProperty(P_Inactive), null)); - p.put(P_White,parseColor(properties.getProperty(P_White), null)); - p.put(P_Black, parseColor(properties.getProperty(P_Black), null)); - p.put(P_Txt_OK, parseColor(properties.getProperty(P_Txt_OK), null)); - p.put(P_Txt_Error,parseColor(properties.getProperty(P_Txt_Error), null)); - // - p.put(P_Control, parseFont(properties.getProperty(P_Control), null)); - p.put(P_System, parseFont(properties.getProperty(P_System), null)); - p.put(P_User, parseFont(properties.getProperty(P_User), null)); - p.put(P_Small, parseFont(properties.getProperty(P_Small), null)); - p.put(P_Window, parseFont(properties.getProperty(P_Window), null)); - p.put(P_Menu, parseFont(properties.getProperty(P_Menu), null)); - // - theme.setUIProperties(p); - } // load -} diff --git a/org.adempiere.ui.swing/src/org/compiere/swing/package.html b/org.adempiere.ui.swing/src/org/compiere/swing/package.html deleted file mode 100644 index 46380c5000..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/swing/package.html +++ /dev/null @@ -1,32 +0,0 @@ - - - - - -

    -Provides Swing components to utilize the Adempiere Looks. -

    -

    Package Specification

    -

    -In the standard implementation, panels and panes are opaque. -Adempiere Looks sets opaque to false for JViewport, JScrollPane, JSplitPane and JTabbedPane -but not for JPanel and JButton. -

    -The Adempiere Swing extensions like CPanel, CButton are not opaque. -

    -

    Related Documentation

    -

    For overviews, tutorials, examples, guides, and tool documentation, please - see: http://www.adempiere.org/looks

    -

    - -

    - - diff --git a/org.adempiere.ui.swing/src/org/compiere/util/IniDialog.java b/org.adempiere.ui.swing/src/org/compiere/util/IniDialog.java deleted file mode 100644 index 81ae3d535c..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/util/IniDialog.java +++ /dev/null @@ -1,196 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ -package org.compiere.util; - -import java.awt.BorderLayout; -import java.awt.Color; -import java.awt.Dimension; -import java.awt.FlowLayout; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.net.URL; -import java.util.ResourceBundle; -import java.util.logging.Level; -import java.util.logging.Logger; - -import javax.swing.JButton; -import javax.swing.JDialog; -import javax.swing.JEditorPane; -import javax.swing.JLabel; -import javax.swing.JScrollPane; - -import org.adempiere.plaf.AdempierePLAF; -import org.compiere.swing.CPanel; - -/** - * Init Dialog - * - * @author Jorg Janke - * @version $Id: IniDialog.java,v 1.3 2006/10/12 00:58:32 jjanke Exp $ - */ -public final class IniDialog extends JDialog implements ActionListener -{ - /** - * - */ - private static final long serialVersionUID = -1469122685638342569L; - - /** - * Constructor - */ - public IniDialog() - { - super(); - try - { - jbInit(); - String where = "org/compiere/license.html"; - URL url = null; - ClassLoader cl = getClass().getClassLoader(); - if (cl != null) // Bootstrap - url = cl.getResource(where); - if (url == null) - { - log.warning("No license in resource "); - url = new URL("http://www.adempiere.org/license.htm"); - } - //if (url == null) - //cmd_reject(); - // - licensePane.setPage(url); - AdempierePLAF.showCenterScreen(this); - } - catch (Exception ex) - { - log.log(Level.SEVERE, "init", ex); - cmd_reject(); - } - } // IniDialog - - /** Translation */ - static ResourceBundle s_res = ResourceBundle.getBundle("org.compiere.util.IniRes"); - private boolean m_accept = false; - /** Logger */ - private static Logger log = Logger.getLogger (IniDialog.class.getName()); - - - private CPanel mainPanel = new CPanel(); - private BorderLayout mainLayout = new BorderLayout(); - private JScrollPane scrollPane = new JScrollPane(); - private CPanel southPanel = new CPanel(); - private JButton bReject = AdempierePLAF.getCancelButton(); - private JButton bAccept = AdempierePLAF.getOKButton(); - private FlowLayout southLayout = new FlowLayout(); - private JLabel southLabel = new JLabel(); - private JEditorPane licensePane = new JEditorPane(); - - /** - * Static Layout - * @throws Exception - */ - private void jbInit() throws Exception - { - setTitle("Adempiere - " + s_res.getString("Adempiere_License")); - southLabel.setText(s_res.getString("Do_you_accept")); - bReject.setText(s_res.getString("No")); - bAccept.setText(s_res.getString("Yes_I_Understand")); - // - setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE); - setModal(true); - // - mainPanel.setLayout(mainLayout); - bReject.setForeground(Color.red); - bReject.addActionListener(this); - bAccept.addActionListener(this); - southPanel.setLayout(southLayout); - southLayout.setAlignment(FlowLayout.RIGHT); - licensePane.setEditable(false); - licensePane.setContentType("text/html"); - scrollPane.setPreferredSize(new Dimension(700, 400)); - southPanel.add(southLabel, null); - getContentPane().add(mainPanel); - mainPanel.add(scrollPane, BorderLayout.CENTER); - scrollPane.getViewport().add(licensePane, null); - mainPanel.add(southPanel, BorderLayout.SOUTH); - southPanel.add(bReject, null); - southPanel.add(bAccept, null); - } // jbInit - - /** - * ActionListener - * @param e event - */ - public final void actionPerformed(ActionEvent e) - { - if (e.getSource() == bAccept) - m_accept = true; - dispose(); - } // actionPerformed - - /** - * Dispose - */ - public final void dispose() - { - super.dispose(); - if (!m_accept) - cmd_reject(); - } // dispose - - /** - * Is Accepted - * @return true if accepted - */ - public final boolean isAccepted() - { - return m_accept; - } // isAccepted - - /** - * Reject License - */ - public final void cmd_reject() - { - String info = "License rejected or expired"; - try - { - info = s_res.getString("License_rejected"); - } - catch (Exception e) - { - } - log.severe(info); - System.exit(10); - } // cmd_reject - - /** - * Display License and exit if rejected - * @return true if acceptes - */ - public static final boolean accept() - { - IniDialog id = new IniDialog(); - if (id.isAccepted()) - { - log.info("License Accepted"); - return true; - } - System.exit(10); - return false; // never executed. - } // accpept - -} // IniDialog diff --git a/org.adempiere.ui.swing/src/org/compiere/util/MiniBrowser.java b/org.adempiere.ui.swing/src/org/compiere/util/MiniBrowser.java deleted file mode 100644 index 7cf4e8dd72..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/util/MiniBrowser.java +++ /dev/null @@ -1,118 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ -package org.compiere.util; - -import java.awt.BorderLayout; -import java.awt.Dimension; -import java.net.URL; - -import javax.swing.JDialog; -import javax.swing.JEditorPane; -import javax.swing.JScrollPane; - -import org.adempiere.plaf.AdempierePLAF; - - -/** - * Mini Browser - * - * @author Jorg Janke - * @version $Id: MiniBrowser.java,v 1.2 2006/07/30 00:52:23 jjanke Exp $ - */ -public class MiniBrowser extends JDialog -{ - /** - * - */ - private static final long serialVersionUID = 9084820549169098075L; - - /** - * Default Constructor - */ - public MiniBrowser() - { - this (null); - } // MiniBrowser - - /** - * Create MiniBrowser with URL - * @param url - */ - public MiniBrowser(String url) - { - this.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE); - try - { - jbInit(); - } - catch(Exception e) - { - e.printStackTrace(); - } - setURL (url); - AdempierePLAF.showCenterScreen(this); - } // MiniBrowser - - private JScrollPane scrollPane = new JScrollPane(); - private JEditorPane editorPane = new JEditorPane(); - - /** - * Static Init - * @throws Exception - */ - private void jbInit() throws Exception - { - scrollPane.setPreferredSize(new Dimension(500, 500)); - this.getContentPane().add(scrollPane, BorderLayout.CENTER); - scrollPane.getViewport().add(editorPane, null); - } // jbInit - - /** - * Set URL - * @param url - */ - private void setURL (String url) - { - String myURL = url; - if (url == null) - myURL = "http://www.adempiere.org"; - this.setTitle(myURL); - - // Set URL - URL realURL = null; - try - { - realURL = new URL(myURL); - } - catch (Exception e) - { - System.err.println("MiniBrowser.setURL (set) - " + e.toString()); - } - if (realURL == null) - return; - - // Open - try - { - editorPane.setPage(realURL); - } - catch (Exception e) - { - System.err.println("MiniBrowser.setURL (open) - " + e.toString()); - } - } // setURL -} // MiniBrowser diff --git a/org.adempiere.ui.swing/src/org/compiere/util/ResourceFinder.java b/org.adempiere.ui.swing/src/org/compiere/util/ResourceFinder.java deleted file mode 100644 index 2a613bf290..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/util/ResourceFinder.java +++ /dev/null @@ -1,18 +0,0 @@ -package org.compiere.util; - -import java.net.URL; - -import org.adempiere.base.IResourceFinder; -import org.compiere.AdempiereClient; - -public class ResourceFinder implements IResourceFinder { - - public ResourceFinder() { - } - - public URL getResource(String name) { - URL resource = AdempiereClient.class.getResource(name); - return resource; - } - -} diff --git a/org.adempiere.ui.swing/src/org/compiere/util/Splash.java b/org.adempiere.ui.swing/src/org/compiere/util/Splash.java deleted file mode 100644 index 022a6a0356..0000000000 --- a/org.adempiere.ui.swing/src/org/compiere/util/Splash.java +++ /dev/null @@ -1,327 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ -package org.compiere.util; - -import java.awt.BorderLayout; -import java.awt.Color; -import java.awt.Component; -import java.awt.Dimension; -import java.awt.Frame; -import java.awt.Graphics; -import java.awt.GridBagConstraints; -import java.awt.GridBagLayout; -import java.awt.Image; -import java.awt.Insets; -import java.awt.Label; -import java.awt.MediaTracker; -import java.awt.Panel; -import java.awt.Rectangle; -import java.awt.SystemColor; -import java.awt.Toolkit; -import java.net.URL; -import java.util.Locale; - -import org.compiere.Adempiere; - -/** - * Splash Screen. - * - don't use environment as not set up yet - - * - * Splash splash = new Splash("Processing"); - * .. do something here - * splash.dispose(); - * splash = null; - * - * @author Jorg Janke - * @version $Id: Splash.java,v 1.3 2006/07/30 00:54:36 jjanke Exp $ - */ -public class Splash extends Frame -{ - /** - * - */ - private static final long serialVersionUID = 7671371032359729541L; - - /** - * Get Splash Screen - * @return Splash Screen - */ - public static Splash getSplash () - { - String msg; - if (Locale.getDefault().getLanguage().equals("es")) // espaƄol - globalqss - msg = new String("Cargando..."); - else - // Default english - msg = new String("Loading..."); - return getSplash (msg); - } // getSplash - - /** - * Get Splash Screen - * @param text splash text - * @return Splash Screen - */ - public static Splash getSplash (String text) - { - if (s_splash == null) - s_splash = new Splash (text); - else - s_splash.setText(text); - return s_splash; - } // getSplash - - private static Splash s_splash = null; - - /************************************************************************** - * Standard constructor - * @param text clear text - */ - public Splash (String text) - { - super("iDempiere"); - System.out.println(text); - message.setText(text); - try - { - jbInit(); - } - catch(Exception e) - { - System.out.println("Splash"); - e.printStackTrace(); - } - display(); - } // Splash - - /** Tracker */ - private MediaTracker tracker = new MediaTracker(this); - // - private CImage cImage = new CImage(); - private AImage aImage = new AImage(); - // - private Label productLabel = new Label(); - private Panel contentPanel = new Panel(); - private GridBagLayout contentLayout = new GridBagLayout(); - private Label message = new Label(); - - /** - * Static Init - * @throws Exception - */ - private void jbInit() throws Exception - { - this.setBackground(Color.white); - this.setName("splash"); - this.setUndecorated(true); - // - productLabel.setAlignment(Label.CENTER); - message.setFont(new java.awt.Font("Serif", 3, 20)); // italic bold 20 pt - message.setForeground(SystemColor.activeCaption); - message.setAlignment(Label.CENTER); - contentPanel.setLayout(contentLayout); - contentPanel.setName("splashContent"); - contentPanel.setBackground(Color.white); - // - productLabel.setFont(new java.awt.Font("Serif", 2, 10)); - productLabel.setForeground(Color.blue); - productLabel.setText(Adempiere.getSubtitle()); - // productLabel.setToolTipText(Adempiere.getURL()); - // - contentPanel.add(cImage, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0 - ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(10, 5, 0, 10), 0, 0)); - contentPanel.add(productLabel, new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0 - ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 5, 0, 10), 0, 0)); - contentPanel.add(message, new GridBagConstraints(1, 2, 1, 1, 0.0, 0.0 - ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(5, 5, 10, 10), 0, 0)); - // - this.add(aImage, BorderLayout.WEST); - this.add(contentPanel, BorderLayout.EAST); - } // jbInit - - /** - * Set Text (20 pt) - * @param text translated text to display - */ - public void setText (String text) - { - message.setText(text); - display(); - } // setText - - /** - * Show Window - * @param visible true if visible - */ - public void setVisible (boolean visible) - { - super.setVisible(visible); - if (visible) - toFront(); - } // setVisible - - /** - * Calculate size and display - */ - private void display() - { - pack(); - Dimension ss = Toolkit.getDefaultToolkit().getScreenSize(); - Rectangle bounds = getBounds(); - setBounds((ss.width - bounds.width) / 2, (ss.height - bounds.height) / 2, - bounds.width, bounds.height); - setVisible(true); - } // display - - /** - * Dispose Splash - */ - public void dispose() - { - super.dispose(); - s_splash = null; - } // dispose - - - /************************************************************************** - * Adempiere Image - */ - private class CImage extends Component - { - /** - * - */ - private static final long serialVersionUID = -4980770762959724071L; - - /** - * Adempiere Image - */ - public CImage () - { - m_image = Adempiere.getImageLogo(); - tracker.addImage(m_image, 0); - } - /** The Image */ - private Image m_image = null; - /* The Dimension */ - private Dimension m_dim = null; - - /** - * Calculate Size - * @return size - */ - public Dimension getPreferredSize() - { - try - { - tracker.waitForID(0); - } - catch (Exception e) - { - System.err.println("Splash.CImage"); - e.printStackTrace(); - } - m_dim = new Dimension (m_image.getWidth(this), m_image.getHeight(this)); - return m_dim; - } // getPreferredSize - - /** - * Paint - * @param g Graphics - */ - public void paint(Graphics g) - { - if (tracker.checkID(0)) - g.drawImage(m_image, 0, 0, this); - } // paint - - } // CImage - - /** - * Animation Image - * @author jjanke - * @version $Id: Splash.java,v 1.3 2006/07/30 00:54:36 jjanke Exp $ - */ - private class AImage extends Component - { - /** - * - */ - private static final long serialVersionUID = -3003967119777877704L; - - /** - * Animation Image - */ - public AImage() - { - super(); - URL url = org.compiere.AdempiereClient.class.getResource("images/Java_anim.gif"); - if (url == null) - url = org.compiere.AdempiereClient.class.getResource("images/Java_logo.gif"); - if (url != null) - { - m_image = Toolkit.getDefaultToolkit().getImage(url); - tracker.addImage(m_image, 1); - } - } // AImage - - /** The image */ - private Image m_image = null; - /** The dimension */ - private Dimension m_dim = null; - - /** - * Calculate Size - * @return size - */ - public Dimension getPreferredSize() - { - try - { - tracker.waitForID(1); - } - catch (Exception e) - { - System.err.println("Splash.AImage"); - e.printStackTrace(); - } - m_dim = new Dimension (m_image.getWidth(this)+15, m_image.getHeight(this)+15); - return m_dim; - } // getPreferredSize - - /** - * Paint - * @param g Graphics - */ - public void paint (Graphics g) - { - if (tracker.checkID(1)) - g.drawImage(m_image, 10, 10, this); - } // paint - - /** - * Update - * @param g Graphics - */ - public void update (Graphics g) - { - paint(g); - } // update - - } // AImage - -} // Splash diff --git a/org.adempiere.ui.swing/src/org/eevolution/form/VInOutInvoiceGen.java b/org.adempiere.ui.swing/src/org/eevolution/form/VInOutInvoiceGen.java deleted file mode 100755 index a652320835..0000000000 --- a/org.adempiere.ui.swing/src/org/eevolution/form/VInOutInvoiceGen.java +++ /dev/null @@ -1,933 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * Contributor(s): Victor Perez www.e-evolution.com * - * Copyright (C) 2003-2007 e-Evolution,SC. All Rights Reserved. * - *****************************************************************************/ -package org.eevolution.form; - -import java.awt.BorderLayout; -import java.awt.Cursor; -import java.awt.FlowLayout; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.beans.PropertyChangeEvent; -import java.beans.VetoableChangeListener; -import java.io.File; -import java.math.BigDecimal; -import java.sql.PreparedStatement; -import java.sql.ResultSet; -import java.sql.SQLException; -import java.sql.Timestamp; -import java.util.ArrayList; -import java.util.logging.Level; - -import javax.swing.JOptionPane; -import javax.swing.JScrollPane; -import javax.swing.event.ChangeEvent; -import javax.swing.event.ChangeListener; -import javax.swing.event.TableModelEvent; -import javax.swing.event.TableModelListener; - -import org.adempiere.plaf.AdempierePLAF; -import org.adempiere.util.Callback; -import org.adempiere.util.IProcessUI; -import org.compiere.apps.ADialog; -import org.compiere.apps.ADialogDialog; -import org.compiere.apps.AEnv; -import org.compiere.apps.ConfirmPanel; -import org.compiere.apps.ProcessCtl; -import org.compiere.apps.StatusBar; -import org.compiere.apps.form.FormFrame; -import org.compiere.apps.form.FormPanel; -import org.compiere.grid.ed.VComboBox; -import org.compiere.grid.ed.VLookup; -import org.compiere.minigrid.IDColumn; -import org.compiere.minigrid.MiniTable; -import org.compiere.model.MLookup; -import org.compiere.model.MLookupFactory; -import org.compiere.model.MOrder; -import org.compiere.model.MPInstance; -import org.compiere.model.MPInstancePara; -import org.compiere.model.MPrivateAccess; -import org.compiere.model.MRMA; -import static org.compiere.model.SystemIDs.*; -import org.compiere.plaf.CompiereColor; -import org.compiere.print.ReportCtl; -import org.compiere.print.ReportEngine; -import org.compiere.process.ProcessInfo; -import org.compiere.process.ProcessInfoUtil; -import org.compiere.swing.CLabel; -import org.compiere.swing.CPanel; -import org.compiere.swing.CTabbedPane; -import org.compiere.swing.CTextPane; -import org.compiere.util.CLogger; -import org.compiere.util.DB; -import org.compiere.util.DisplayType; -import org.compiere.util.Env; -import org.compiere.util.KeyNamePair; -import org.compiere.util.Msg; -import org.compiere.util.Trx; - -/** - * Manual Shipment Selection - * - * @author victor.perez@e-evolution.com - * @version $Id: VInOutInvoiceGen.java - */ -public class VInOutInvoiceGen extends CPanel - implements FormPanel, ActionListener, VetoableChangeListener, - ChangeListener, TableModelListener, IProcessUI -{ - /** - * - */ - private static final long serialVersionUID = -2327667535691916715L; - - /** - * Initialize Panel - * @param WindowNo window - * @param frame frame - */ - public void init (int WindowNo, FormFrame frame) - { - log.info(""); - m_WindowNo = WindowNo; - m_frame = frame; - Env.setContext(Env.getCtx(), m_WindowNo, "IsSOTrx", "Y"); - try - { - fillPicks(); - jbInit(); - dynInit(); - frame.getContentPane().add(tabbedPane, BorderLayout.CENTER); - frame.getContentPane().add(statusBar, BorderLayout.SOUTH); - } - catch(Exception ex) - { - log.log(Level.SEVERE, "init", ex); - } - } // init - - /** Window No */ - private int m_WindowNo = 0; - /** FormFrame */ - private FormFrame m_frame; - - private boolean m_selectionActive = true; - private Object m_M_Warehouse_ID = null; - private Object m_C_BPartner_ID = null; - /** Logger */ - private static CLogger log = CLogger.getCLogger(VInOutInvoiceGen.class); - // - private CTabbedPane tabbedPane = new CTabbedPane(); - private CPanel selPanel = new CPanel(); - private CPanel selNorthPanel = new CPanel(); - private BorderLayout selPanelLayout = new BorderLayout(); - private CLabel lWarehouse = new CLabel(); - private VLookup fWarehouse; - private CLabel lBPartner = new CLabel(); - private VLookup fBPartner; - private FlowLayout northPanelLayout = new FlowLayout(); - private ConfirmPanel confirmPanelSel = new ConfirmPanel(true); - private ConfirmPanel confirmPanelGen = new ConfirmPanel(false, true, false, false, false, false, true); - private StatusBar statusBar = new StatusBar(); - private CPanel genPanel = new CPanel(); - private BorderLayout genLayout = new BorderLayout(); - private CTextPane info = new CTextPane(); - private JScrollPane scrollPane = new JScrollPane(); - private MiniTable miniTable = new MiniTable(); - - private CLabel lDocType = new CLabel(); - private VComboBox cmbDocType = new VComboBox(); - - /** User selection */ - private ArrayList selection = null; - private StringBuffer iText = new StringBuffer(); - - - /** - * Static Init. - *
    -	 *  selPanel (tabbed)
    -	 *      fOrg, fBPartner
    -	 *      scrollPane & miniTable
    -	 *  genPanel
    -	 *      info
    -	 *  
    - * @throws Exception - */ - void jbInit() throws Exception - { - CompiereColor.setBackground(this); - // - selPanel.setLayout(selPanelLayout); - lWarehouse.setLabelFor(fWarehouse); - lBPartner.setLabelFor(fBPartner); - lBPartner.setText("BPartner"); - selNorthPanel.setLayout(northPanelLayout); - northPanelLayout.setAlignment(FlowLayout.LEFT); - tabbedPane.add(selPanel, Msg.getMsg(Env.getCtx(), "Select")); - selPanel.add(selNorthPanel, BorderLayout.NORTH); - selNorthPanel.add(lWarehouse, null); - selNorthPanel.add(fWarehouse, null); - selNorthPanel.add(lBPartner, null); - selNorthPanel.add(fBPartner, null); - selPanel.setName("selPanel"); - selPanel.add(confirmPanelSel, BorderLayout.SOUTH); - selPanel.add(scrollPane, BorderLayout.CENTER); - scrollPane.getViewport().add(miniTable, null); - confirmPanelSel.addActionListener(this); - // - tabbedPane.add(genPanel, Msg.getMsg(Env.getCtx(), "Generate")); - genPanel.setLayout(genLayout); - genPanel.add(info, BorderLayout.CENTER); - genPanel.setEnabled(false); - info.setBackground(AdempierePLAF.getFieldBackground_Inactive()); - info.setEditable(false); - genPanel.add(confirmPanelGen, BorderLayout.SOUTH); - confirmPanelGen.addActionListener(this); - - lDocType.setLabelFor(cmbDocType); - selNorthPanel.add(lDocType, null); - selNorthPanel.add(cmbDocType, null); - } // jbInit - - /** - * Fill Picks. - * Column_ID from C_Order - * @throws Exception if Lookups cannot be initialized - */ - private void fillPicks() throws Exception - { - // C_OrderLine.M_Warehouse_ID - MLookup orgL = MLookupFactory.get (Env.getCtx(), m_WindowNo, 0, 2223, DisplayType.TableDir); - fWarehouse = new VLookup ("M_Warehouse_ID", true, false, true, orgL); - lWarehouse.setText(Msg.translate(Env.getCtx(), "M_Warehouse_ID")); - fWarehouse.addVetoableChangeListener(this); - m_M_Warehouse_ID = fWarehouse.getValue(); - // C_Order.C_BPartner_ID - MLookup bpL = MLookupFactory.get (Env.getCtx(), m_WindowNo, 0, 2762, DisplayType.Search); - fBPartner = new VLookup ("C_BPartner_ID", false, false, true, bpL); - lBPartner.setText(Msg.translate(Env.getCtx(), "C_BPartner_ID")); - fBPartner.addVetoableChangeListener(this); - //Document Type Sales Order/Vendor RMA - lDocType.setText(Msg.translate(Env.getCtx(), "C_DocType_ID")); - cmbDocType.addItem(new KeyNamePair(MOrder.Table_ID, Msg.translate(Env.getCtx(), "Order"))); - cmbDocType.addItem(new KeyNamePair(MRMA.Table_ID, Msg.translate(Env.getCtx(), "VendorRMA"))); - cmbDocType.addActionListener(this); - } // fillPicks - - /** - * Dynamic Init. - * - Create GridController & Panel - * - AD_Column_ID from C_Order - */ - private void dynInit() - { - // create Columns - miniTable.addColumn("C_Order_ID"); - miniTable.addColumn("AD_Org_ID"); - miniTable.addColumn("C_DocType_ID"); - miniTable.addColumn("DocumentNo"); - miniTable.addColumn("C_BPartner_ID"); - miniTable.addColumn("DateOrdered"); - miniTable.addColumn("TotalLines"); - // - miniTable.setMultiSelection(true); - miniTable.setRowSelectionAllowed(true); - // set details - miniTable.setColumnClass(0, IDColumn.class, false, " "); - miniTable.setColumnClass(1, String.class, true, Msg.translate(Env.getCtx(), "AD_Org_ID")); - miniTable.setColumnClass(2, String.class, true, Msg.translate(Env.getCtx(), "C_DocType_ID")); - miniTable.setColumnClass(3, String.class, true, Msg.translate(Env.getCtx(), "DocumentNo")); - miniTable.setColumnClass(4, String.class, true, Msg.translate(Env.getCtx(), "C_BPartner_ID")); - miniTable.setColumnClass(5, Timestamp.class, true, Msg.translate(Env.getCtx(), "DateOrdered")); - miniTable.setColumnClass(6, BigDecimal.class, true, Msg.translate(Env.getCtx(), "TotalLines")); - // - miniTable.autoSize(); - miniTable.getModel().addTableModelListener(this); - // Info - statusBar.setStatusLine(Msg.getMsg(Env.getCtx(), "InOutGenerateSel"));//@@ - statusBar.setStatusDB(" "); - // Tabbed Pane Listener - tabbedPane.addChangeListener(this); - } // dynInit - - /** - * Get SQL for Orders that needs to be shipped - * @return sql - */ - private String getOrderSQL() - { - // Create SQL - StringBuilder sql = new StringBuilder( - "SELECT C_Order_ID, o.Name, dt.Name, DocumentNo, bp.Name, DateOrdered, TotalLines " - + "FROM M_InOut_Candidate_v ic, AD_Org o, C_BPartner bp, C_DocType dt " - + "WHERE ic.AD_Org_ID=o.AD_Org_ID" - + " AND ic.C_BPartner_ID=bp.C_BPartner_ID" - + " AND ic.C_DocType_ID=dt.C_DocType_ID" - + " AND ic.AD_Client_ID=?"); - - if (m_M_Warehouse_ID != null) - sql.append(" AND ic.M_Warehouse_ID=").append(m_M_Warehouse_ID); - if (m_C_BPartner_ID != null) - sql.append(" AND ic.C_BPartner_ID=").append(m_C_BPartner_ID); - - // bug - [ 1713317 ] Generate Shipments (manual) show locked records - /* begin - Exclude locked records; @Trifon */ - int AD_User_ID = Env.getContextAsInt(Env.getCtx(), "#AD_User_ID"); - String lockedIDs = MPrivateAccess.getLockedRecordWhere(MOrder.Table_ID, AD_User_ID); - if (lockedIDs != null) - { - if (sql.length() > 0) - sql.append(" AND "); - sql.append("C_Order_ID").append(lockedIDs); - } - /* eng - Exclude locked records; @Trifon */ - - // - sql.append(" ORDER BY o.Name,bp.Name,DateOrdered"); - - return sql.toString(); - } - - /** - * Get SQL for Vendor RMA that need to be shipped - * @return sql - */ - private String getRMASql() - { - StringBuilder sql = new StringBuilder(); - - sql.append("SELECT rma.M_RMA_ID, org.Name, dt.Name, rma.DocumentNo, bp.Name, rma.Created, rma.Amt "); - sql.append("FROM M_RMA rma INNER JOIN AD_Org org ON rma.AD_Org_ID=org.AD_Org_ID "); - sql.append("INNER JOIN C_DocType dt ON rma.C_DocType_ID=dt.C_DocType_ID "); - sql.append("INNER JOIN C_BPartner bp ON rma.C_BPartner_ID=bp.C_BPartner_ID "); - sql.append("INNER JOIN M_InOut io ON rma.InOut_ID=io.M_InOut_ID "); - sql.append("WHERE rma.DocStatus='CO' "); - sql.append("AND dt.DocBaseType = 'POO' "); - sql.append("AND EXISTS (SELECT * FROM M_RMA r INNER JOIN M_RMALine rl "); - sql.append("ON r.M_RMA_ID=rl.M_RMA_ID WHERE r.M_RMA_ID=rma.M_RMA_ID "); - sql.append("AND rl.IsActive='Y' AND rl.M_InOutLine_ID > 0 AND rl.QtyDelivered < rl.Qty) "); - sql.append("AND NOT EXISTS (SELECT * FROM M_InOut oio WHERE oio.M_RMA_ID=rma.M_RMA_ID "); - sql.append("AND oio.DocStatus IN ('IP', 'CO', 'CL')) " ); - sql.append("AND rma.AD_Client_ID=?"); - - if (m_M_Warehouse_ID != null) - sql.append(" AND io.M_Warehouse_ID=").append(m_M_Warehouse_ID); - if (m_C_BPartner_ID != null) - sql.append(" AND bp.C_BPartner_ID=").append(m_C_BPartner_ID); - - int AD_User_ID = Env.getContextAsInt(Env.getCtx(), "#AD_User_ID"); - String lockedIDs = MPrivateAccess.getLockedRecordWhere(MRMA.Table_ID, AD_User_ID); - if (lockedIDs != null) - { - sql.append(" AND rma.M_RMA_ID").append(lockedIDs); - } - - sql.append(" ORDER BY org.Name, bp.Name, rma.Created "); - - return sql.toString(); - } - - /** - * Query Info - */ - private void executeQuery() - { - log.info(""); - int AD_Client_ID = Env.getAD_Client_ID(Env.getCtx()); - - String sql = ""; - - KeyNamePair docTypeKNPair = (KeyNamePair)cmbDocType.getSelectedItem(); - - if (docTypeKNPair.getKey() == MRMA.Table_ID) - { - sql = getRMASql(); - } - else - { - sql = getOrderSQL(); - } - - log.fine(sql); - // reset table - int row = 0; - miniTable.setRowCount(row); - // Execute - PreparedStatement pstmt = null; - ResultSet rs = null; - try - { - pstmt = DB.prepareStatement(sql.toString(), null); - pstmt.setInt(1, AD_Client_ID); - rs = pstmt.executeQuery(); - // - while (rs.next()) - { - // extend table - miniTable.setRowCount(row+1); - // set values - miniTable.setValueAt(new IDColumn(rs.getInt(1)), row, 0); // C_Order_ID - miniTable.setValueAt(rs.getString(2), row, 1); // Org - miniTable.setValueAt(rs.getString(3), row, 2); // DocType - miniTable.setValueAt(rs.getString(4), row, 3); // Doc No - miniTable.setValueAt(rs.getString(5), row, 4); // BPartner - miniTable.setValueAt(rs.getTimestamp(6), row, 5); // DateOrdered - miniTable.setValueAt(rs.getBigDecimal(7), row, 6); // TotalLines - // prepare next - row++; - } - } - catch (SQLException e) - { - log.log(Level.SEVERE, sql.toString(), e); - } - finally - { - DB.close(rs, pstmt); - rs = null; - pstmt = null; - } - // - miniTable.autoSize(); - // statusBar.setStatusDB(String.valueOf(miniTable.getRowCount())); - } // executeQuery - - /** - * Dispose - */ - public void dispose() - { - if (m_frame != null) - m_frame.dispose(); - m_frame = null; - } // dispose - - /** - * Action Listener - * @param e event - */ - public void actionPerformed (ActionEvent e) - { - if (log.isLoggable(Level.INFO)) log.info("Cmd=" + e.getActionCommand()); - // - if (e.getActionCommand().equals(ConfirmPanel.A_CANCEL)) - { - dispose(); - return; - } - if (cmbDocType.equals(e.getSource())) - { - executeQuery(); - return; - } - // - saveSelection(); - if (selection != null - && selection.size() > 0 - && m_selectionActive // on selection tab - && m_M_Warehouse_ID != null) - { - generateShipments (); - - } - else - dispose(); - } // actionPerformed - - /** - * Vetoable Change Listener - requery - * @param e event - */ - public void vetoableChange(PropertyChangeEvent e) - { - if (log.isLoggable(Level.INFO)) log.info(e.getPropertyName() + "=" + e.getNewValue()); - if (e.getPropertyName().equals("M_Warehouse_ID")) - m_M_Warehouse_ID = e.getNewValue(); - if (e.getPropertyName().equals("C_BPartner_ID")) - { - m_C_BPartner_ID = e.getNewValue(); - fBPartner.setValue(m_C_BPartner_ID); // display value - } - executeQuery(); - } // vetoableChange - - /** - * Change Listener (Tab changed) - * @param e event - */ - public void stateChanged (ChangeEvent e) - { - int index = tabbedPane.getSelectedIndex(); - m_selectionActive = (index == 0); - } // stateChanged - - /** - * Table Model Listener - * @param e event - */ - public void tableChanged(TableModelEvent e) - { - int rowsSelected = 0; - int rows = miniTable.getRowCount(); - for (int i = 0; i < rows; i++) - { - IDColumn id = (IDColumn)miniTable.getValueAt(i, 0); // ID in column 0 - if (id != null && id.isSelected()) - rowsSelected++; - } - statusBar.setStatusDB(" " + rowsSelected + " "); - } // tableChanged - - /** - * Save Selection & return selecion Query or "" - * @return where clause like C_Order_ID IN (...) - */ - private void saveSelection() - { - log.info(""); - // ID selection may be pending - miniTable.editingStopped(new ChangeEvent(this)); - // Array of Integers - ArrayList results = new ArrayList(); - selection = null; - - // Get selected entries - int rows = miniTable.getRowCount(); - for (int i = 0; i < rows; i++) - { - IDColumn id = (IDColumn)miniTable.getValueAt(i, 0); // ID in column 0 - // log.fine( "Row=" + i + " - " + id); - if (id != null && id.isSelected()) - results.add(id.getRecord_ID()); - } - - if (results.size() == 0) - return; - if (log.isLoggable(Level.CONFIG)) log.config("Selected #" + results.size()); - selection = results; - - } // saveSelection - - - /************************************************************************** - * Generate Shipments - */ - private void generateShipments () - { - if (log.isLoggable(Level.INFO)) log.info("M_Warehouse_ID=" + m_M_Warehouse_ID); - String trxName = Trx.createTrxName("IOG"); - Trx trx = Trx.get(trxName, true); //trx needs to be committed too - //String trxName = null; - //Trx trx = null; - - m_selectionActive = false; // prevents from being called twice - statusBar.setStatusLine(Msg.getMsg(Env.getCtx(), "InOutGenerateGen")); - statusBar.setStatusDB(String.valueOf(selection.size())); - - // Prepare Process - int AD_Process_ID = 0; - KeyNamePair docTypeKNPair = (KeyNamePair)cmbDocType.getSelectedItem(); - - if (docTypeKNPair.getKey() == MRMA.Table_ID) - { - AD_Process_ID = PROCESS_M_INOUT_GENERATERMA_MANUAL; // M_InOut_GenerateRMA - org.adempiere.process.InOutGenerateRMA - } - else - { - AD_Process_ID = PROCESS_M_INOUT_GENERATE_MANUAL; // M_InOut_Generate - org.compiere.process.InOutGenerate - } - - MPInstance instance = new MPInstance(Env.getCtx(), AD_Process_ID, 0); - if (!instance.save()) - { - info.setText(Msg.getMsg(Env.getCtx(), "ProcessNoInstance")); - return; - } - - //insert selection - StringBuilder insert = new StringBuilder(); - insert.append("INSERT INTO T_SELECTION(AD_PINSTANCE_ID, T_SELECTION_ID) "); - int counter = 0; - for(Integer selectedId : selection) - { - counter++; - if (counter > 1) - insert.append(" UNION "); - insert.append("SELECT "); - insert.append(instance.getAD_PInstance_ID()); - insert.append(", "); - insert.append(selectedId); - insert.append(" FROM DUAL "); - - if (counter == 1000) - { - if ( DB.executeUpdate(insert.toString(), trxName) < 0 ) - { - String msg = "No Shipments"; // not translated! - log.config(msg); - info.setText(msg); - trx.rollback(); - return; - } - insert = new StringBuilder(); - insert.append("INSERT INTO T_SELECTION(AD_PINSTANCE_ID, T_SELECTION_ID) "); - counter = 0; - } - } - if (counter > 0) - { - if ( DB.executeUpdate(insert.toString(), trxName) < 0 ) - { - String msg = "No Shipments"; // not translated! - log.config(msg); - info.setText(msg); - trx.rollback(); - return; - } - } - - //call process - ProcessInfo pi = new ProcessInfo ("VInOutGen", AD_Process_ID); - pi.setAD_PInstance_ID (instance.getAD_PInstance_ID()); - - // Add Parameter - Selection=Y - MPInstancePara ip = new MPInstancePara(instance, 10); - ip.setParameter("Selection","Y"); - if (!ip.save()) - { - String msg = "No Parameter added"; // not translated - info.setText(msg); - log.log(Level.SEVERE, msg); - return; - } - // Add Parameter - M_Warehouse_ID=x - ip = new MPInstancePara(instance, 20); - ip.setParameter("M_Warehouse_ID", Integer.parseInt(m_M_Warehouse_ID.toString())); - if (!ip.save()) - { - String msg = "No Parameter added"; // not translated - info.setText(msg); - log.log(Level.SEVERE, msg); - return; - } - - // Execute Process - ProcessCtl worker = new ProcessCtl(this, AEnv.getWindowNo(this), pi, trx); - worker.start(); // complete tasks in unlockUI / generateShipments_complete - // - } // generateShipments - - /** - * Complete generating shipments. - * Called from Unlock UI - * @param pi process info - */ - private void generateShipments_complete (ProcessInfo pi) - { - // Switch Tabs - tabbedPane.setSelectedIndex(1); - // - ProcessInfoUtil.setLogFromDB(pi); - //StringBuffer iText = new StringBuffer(); - iText.append("").append(pi.getSummary()) - .append("
    (") - .append(Msg.getMsg(Env.getCtx(), "InOutGenerateInfo")) - // Shipments are generated depending on the Delivery Rule selection in the Order - .append(")
    ") - .append(pi.getLogInfo(true)); - info.setText(iText.toString()); - - // Reset Selection - /* - String sql = "UPDATE C_Order SET IsSelected='N' WHERE " + m_whereClause; - int no = DB.executeUpdate(sql, null); - log.config("Reset=" + no);*/ - - // Get results - int[] ids = pi.getIDs(); - if (ids == null || ids.length == 0) - return; - if (log.isLoggable(Level.CONFIG)) log.config("PrintItems=" + ids.length); - - confirmPanelGen.getOKButton().setEnabled(false); - // OK to print shipments - if (ADialog.ask(m_WindowNo, this, "PrintShipments")) - { - // info.append("\n\n" + Msg.getMsg(Env.getCtx(), "PrintShipments")); - setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); - int retValue = ADialogDialog.A_CANCEL; // see also ProcessDialog.printShipments/Invoices - do - { - // Loop through all items - for (int i = 0; i < ids.length; i++) - { - int M_InOut_ID = ids[i]; - ReportCtl.startDocumentPrint(ReportEngine.SHIPMENT, M_InOut_ID, this, AEnv.getWindowNo(this), true); - } - ADialogDialog d = new ADialogDialog (m_frame, - Env.getHeader(Env.getCtx(), m_WindowNo), - Msg.getMsg(Env.getCtx(), "PrintoutOK?"), - JOptionPane.QUESTION_MESSAGE); - retValue = d.getReturnCode(); - } - while (retValue == ADialogDialog.A_CANCEL); - setCursor(Cursor.getDefaultCursor()); - } // OK to print shipments - - // - confirmPanelGen.getOKButton().setEnabled(true); - } // generateShipments_complete - - /************************************************************************** - * Generate Invoices - */ - private void generateInvoices () - { - String trxName = Trx.createTrxName("IVG"); - Trx trx = Trx.get(trxName, true); //trx needs to be committed too - //String trxName = null; - //Trx trx = null; - - m_selectionActive = false; // prevents from being called twice - statusBar.setStatusLine(Msg.getMsg(Env.getCtx(), "InvGenerateGen")); - statusBar.setStatusDB(String.valueOf(selection.size())); - - // Prepare Process - int AD_Process_ID = 0; - KeyNamePair docTypeKNPair = (KeyNamePair)cmbDocType.getSelectedItem(); - - if (docTypeKNPair.getKey() == MRMA.Table_ID) - { - AD_Process_ID = PROCESS_C_INVOICE_GENERATERMA_MANUAL; // C_Invoice_GenerateRMA - org.adempiere.process.InvoiceGenerateRMA - } - else - { - AD_Process_ID = PROCESS_C_INVOICE_GENERATE_MANUAL; // HARDCODED C_InvoiceCreate - } - MPInstance instance = new MPInstance(Env.getCtx(), AD_Process_ID, 0); - if (!instance.save()) - { - info.setText(Msg.getMsg(Env.getCtx(), "ProcessNoInstance")); - return; - } - - //insert selection - /*Selection exist from shipment*/ - StringBuilder insert = new StringBuilder(); - insert.append("INSERT INTO T_SELECTION(AD_PINSTANCE_ID, T_SELECTION_ID) "); - int counter = 0; - for(Integer selectedId : selection) - { - counter++; - if (counter > 1) - insert.append(" UNION "); - insert.append("SELECT "); - insert.append(instance.getAD_PInstance_ID()); - insert.append(", "); - insert.append(selectedId); - insert.append(" FROM DUAL "); - - if (counter == 1000) - { - if ( DB.executeUpdate(insert.toString(), trxName) < 0 ) - { - String msg = "No Shipments"; // not translated! - log.config(msg); - info.setText(msg); - trx.rollback(); - return; - } - insert = new StringBuilder(); - insert.append("INSERT INTO T_SELECTION(AD_PINSTANCE_ID, T_SELECTION_ID) "); - counter = 0; - } - } - if (counter > 0) - { - if ( DB.executeUpdate(insert.toString(), trxName) < 0 ) - { - String msg = "No Shipments"; // not translated! - log.config(msg); - info.setText(msg); - trx.rollback(); - return; - } - } - - ProcessInfo pi = new ProcessInfo ("", AD_Process_ID); - pi.setAD_PInstance_ID (instance.getAD_PInstance_ID()); - - // Add Parameters - MPInstancePara para = new MPInstancePara(instance, 10); - para.setParameter("Selection", "Y"); - if (!para.save()) - { - String msg = "No Selection Parameter added"; // not translated - info.setText(msg); - log.log(Level.SEVERE, msg); - return; - } - para = new MPInstancePara(instance, 20); - para.setParameter("DocAction", "CO"); - if (!para.save()) - { - String msg = "No DocAction Parameter added"; // not translated - info.setText(msg); - log.log(Level.SEVERE, msg); - return; - } - - // Execute Process - ProcessCtl worker = new ProcessCtl(this, AEnv.getWindowNo(this), pi, trx); - worker.start(); // complete tasks in unlockUI / generateInvoice_complete - } // generateInvoices - - /** - * Complete generating invoices. - * Called from Unlock UI - * @param pi process info - */ - private void generateInvoice_complete (ProcessInfo pi) - { - // Switch Tabs - tabbedPane.setSelectedIndex(1); - // - ProcessInfoUtil.setLogFromDB(pi); - //StringBuffer iText = new StringBuffer(); - iText.append("").append(pi.getSummary()) - .append("
    (") - .append(Msg.getMsg(Env.getCtx(), "InvGenerateInfo")) - //Invoices are generated depending on the Invoicing Rule selection in the Order - .append(")
    ") - .append(pi.getLogInfo(true)); - info.setText(iText.toString()); - - // Reset Selection - /* - String sql = "UPDATE C_Order SET IsSelected = 'N' WHERE " + m_whereClause; - int no = DB.executeUpdate(sql, null); - log.config("Reset=" + no);*/ - - // Get results - int[] ids = pi.getIDs(); - if (ids == null || ids.length == 0) - return; - - confirmPanelGen.getOKButton().setEnabled(false); - // OK to print invoices - if (ADialog.ask(m_WindowNo, this, "PrintInvoices")) - { - // info.append("\n\n" + Msg.getMsg(Env.getCtx(), "PrintInvoices")); - setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); - int retValue = ADialogDialog.A_CANCEL; - do - { - // Loop through all items - for (int i = 0; i < ids.length; i++) - { - int C_Invoice_ID = ids[i]; - ReportCtl.startDocumentPrint(ReportEngine.INVOICE, C_Invoice_ID, this, AEnv.getWindowNo(this), true); - } - ADialogDialog d = new ADialogDialog (m_frame, - Env.getHeader(Env.getCtx(), m_WindowNo), - Msg.getMsg(Env.getCtx(), "PrintoutOK?"), - JOptionPane.QUESTION_MESSAGE); - retValue = d.getReturnCode(); - } - while (retValue == ADialogDialog.A_CANCEL); - setCursor(Cursor.getDefaultCursor()); - } // OK to print invoices - - // - confirmPanelGen.getOKButton().setEnabled(true); - } // generateInvoices_complete - /************************************************************************** - * Lock User Interface. - * Called from the Worker before processing - * @param pi process info - */ - public void lockUI (ProcessInfo pi) - { - this.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); - this.setEnabled(false); - } // lockUI - - /** - * Unlock User Interface. - * Called from the Worker when processing is done - * @param pi result of execute ASync call - */ - public void unlockUI (ProcessInfo pi) - { - // - if(pi.getAD_Process_ID() == PROCESS_M_INOUT_GENERATE_MANUAL) - { - generateShipments_complete(pi); - generateInvoices (); - } - if(pi.getAD_Process_ID() == PROCESS_C_INVOICE_GENERATE_MANUAL) - { - generateInvoice_complete(pi); - this.setEnabled(true); - this.setCursor(Cursor.getDefaultCursor()); - } - - } // unlockUI - - /** - * Is the UI locked (Internal method) - * @return true, if UI is locked - */ - public boolean isUILocked() - { - return this.isEnabled(); - } // isUILocked - - /** - * Method to be executed async. - * Called from the Worker - * @param pi ProcessInfo - */ - public void executeASync (ProcessInfo pi) - { - } // executeASync - - @Override - public void statusUpdate(String message) { - statusBar.setStatusLine(message); - } - - @Override - public void ask(String message, Callback callback) { - boolean b = ADialog.ask(m_WindowNo, this, message); - if (callback != null) { - callback.onCallback(b); - } - } - - @Override - public void download(File file) { - // TODO Auto-generated method stub - - } - - @Override - public void askForInput(String message, Callback callback) { - String s = ADialog.askForInput(m_WindowNo, this, message); - if(callback != null) - callback.onCallback(s); - } -} // VInOutGen diff --git a/org.adempiere.ui.swing/swing.properties b/org.adempiere.ui.swing/swing.properties deleted file mode 100644 index a3738c106e..0000000000 --- a/org.adempiere.ui.swing/swing.properties +++ /dev/null @@ -1,10 +0,0 @@ -swing.defaultlaf=org.adempiere.plaf.AdempiereLookAndFeel -swing.installedlafs=Metal,Motif,Windows,Adempiere -swing.installedlaf.Metal.class=javax.swing.plaf.metal.MetalLookAndFeel -swing.installedlaf.Metal.name=Metal -swing.installedlaf.Motif.class=com.sun.java.swing.plaf.motif.MotifLookAndFeel -swing.installedlaf.Motif.name=CDE/Motif -swing.installedlaf.Windows.class=com.sun.java.swing.plaf.windows.WindowsLookAndFeel -swing.installedlaf.Windows.name=MS Windows -swing.installedlaf.Adempiere.class=org.compiere.plaf.AdempiereLookAndFeel -swing.installedlaf.Adempiere.name=Adempiere diff --git a/org.idempiere.javadoc/build.properties b/org.idempiere.javadoc/build.properties index 7da1847b76..57b476f569 100644 --- a/org.idempiere.javadoc/build.properties +++ b/org.idempiere.javadoc/build.properties @@ -18,7 +18,6 @@ jars.extra.classpath = platform:/plugin/org.adempiere.base/,\ platform:/plugin/org.adempiere.server/src/main/servlet/,\ platform:/plugin/org.adempiere.server/src/main/home/,\ platform:/plugin/org.adempiere.ui/,\ - platform:/plugin/org.adempiere.ui.swing/,\ platform:/plugin/org.adempiere.ui.zk/,\ platform:/plugin/org.adempiere.webstore/,\ platform:/plugin/org.adempiere.webstore.resource/,\ diff --git a/pom.xml b/pom.xml index 9624c2af21..b7da28d8dd 100644 --- a/pom.xml +++ b/pom.xml @@ -26,10 +26,8 @@ org.adempiere.replication.server org.adempiere.report.jasper.library org.adempiere.report.jasper - org.adempiere.report.jasper.swing org.adempiere.report.jasper.webapp - org.adempiere.server - org.adempiere.ui.swing + org.adempiere.server org.adempiere.ui org.adempiere.ui.zk org.adempiere.webstore @@ -49,8 +47,7 @@ org.adempiere.pipo-feature org.adempiere.replication.server-feature org.adempiere.server-feature - org.adempiere.target.platform-feature - org.adempiere.ui.swing-feature + org.adempiere.target.platform-feature org.adempiere.ui.zk-feature org.adempiere.webstore-feature org.compiere.db.provider-feature