IDEMPIERE-4581 Model generator should isn't dialog it should be window (#463)
* IDEMPIERE-4581 Model generator should isn't dialog it should be window use shutdown asyn to shutdown framework when close Model generator window one unhappy thing remain: when use -console then framework is shutdown but jdk still hang because "pipe-gosh --login --noshutdown" still live (for https://bugs.eclipse.org/bugs/show_bug.cgi?id=362412) work-around: use -console 1234 by that way we can't access osgi command from console but can use "telnet localhost 1234" to use osgi command * IDEMPIERE-4581 Model generator should isn't dialog it should be window Fix problem about program not closing Improve layout Co-authored-by: hieplq <hieplq@hasuvimex.vn>
This commit is contained in:
parent
5da1785572
commit
fd947f4fef
|
@ -21,30 +21,20 @@
|
|||
<listEntry value="org.eclipse.debug.ui.launchGroup.debug"/>
|
||||
</listAttribute>
|
||||
<stringAttribute key="org.eclipse.jdt.launching.JRE_CONTAINER" value="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-11"/>
|
||||
<stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS" value="-os ${target.os} -ws ${target.ws} -arch ${target.arch} -nl ${target.nl} -consoleLog -console"/>
|
||||
<stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS" value="-os ${target.os} -ws ${target.ws} -arch ${target.arch} -nl ${target.nl} -consoleLog"/>
|
||||
<stringAttribute key="org.eclipse.jdt.launching.SOURCE_PATH_PROVIDER" value="org.eclipse.pde.ui.workbenchClasspathProvider"/>
|
||||
<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="--add-modules java.se --add-opens java.base/java.lang=ALL-UNNAMED --add-opens java.base/java.nio=ALL-UNNAMED --add-opens java.base/sun.nio.ch=ALL-UNNAMED --add-opens java.management/sun.management=ALL-UNNAMED --add-opens jdk.management/com.sun.management.internal=ALL-UNNAMED --add-exports java.base/jdk.internal.ref=ALL-UNNAMED --add-exports java.desktop/sun.awt=ALL-UNNAMED --add-exports java.sql.rowset/com.sun.rowset=ALL-UNNAMED --add-exports java.naming/com.sun.jndi.ldap=ALL-UNNAMED"/>
|
||||
<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="--add-modules java.se --add-opens java.base/java.lang=ALL-UNNAMED --add-opens java.base/java.nio=ALL-UNNAMED --add-opens java.base/sun.nio.ch=ALL-UNNAMED --add-opens java.management/sun.management=ALL-UNNAMED --add-opens jdk.management/com.sun.management.internal=ALL-UNNAMED --add-exports java.base/jdk.internal.ref=ALL-UNNAMED --add-exports java.desktop/sun.awt=ALL-UNNAMED --add-exports java.sql.rowset/com.sun.rowset=ALL-UNNAMED --add-exports java.naming/com.sun.jndi.ldap=ALL-UNNAMED -Dosgi.noShutdown=true"/>
|
||||
<stringAttribute key="org.eclipse.jdt.launching.WORKING_DIRECTORY" value="${workspace_loc}"/>
|
||||
<stringAttribute key="pde.version" value="3.3"/>
|
||||
<stringAttribute key="product" value="org.adempiere.server.server_product"/>
|
||||
<stringAttribute key="productFile" value="/org.adempiere.server-feature/server.product"/>
|
||||
<setAttribute key="selected_target_bundles">
|
||||
<setEntry value="bcprov@default:default"/>
|
||||
<setEntry value="com.diffplug.osgi.extension.sun.misc@default:false"/>
|
||||
<setEntry value="com.google.zxing.core@default:default"/>
|
||||
<setEntry value="com.itextpdf@default:default"/>
|
||||
<setEntry value="com.jaspersoft.studio.bundles.barbecue@default:default"/>
|
||||
<setEntry value="com.sun.activation.jakarta.activation@default:default"/>
|
||||
<setEntry value="com.sun.mail.imap@default:default"/>
|
||||
<setEntry value="com.sun.mail.jakarta.mail@default:default"/>
|
||||
<setEntry value="com.sun.mail.smtp@default:default"/>
|
||||
<setEntry value="groovy-console@default:false"/>
|
||||
<setEntry value="groovy-datetime@default:false"/>
|
||||
<setEntry value="groovy-json@default:false"/>
|
||||
<setEntry value="groovy-jsr223@default:false"/>
|
||||
<setEntry value="groovy-nio@default:false"/>
|
||||
<setEntry value="groovy-sql@default:false"/>
|
||||
<setEntry value="groovy-xml@default:false"/>
|
||||
<setEntry value="groovy@default:default"/>
|
||||
<setEntry value="jakarta.xml.bind-api@default:default"/>
|
||||
<setEntry value="javax.jms@default:default"/>
|
||||
|
@ -52,7 +42,6 @@
|
|||
<setEntry value="org.apache.activemq.activemq-core@default:default"/>
|
||||
<setEntry value="org.apache.activemq.kahadb@default:default"/>
|
||||
<setEntry value="org.apache.ant@default:default"/>
|
||||
<setEntry value="org.apache.commons.codec@default:default"/>
|
||||
<setEntry value="org.apache.commons.collections@default:default"/>
|
||||
<setEntry value="org.apache.commons.commons-collections4@default:default"/>
|
||||
<setEntry value="org.apache.commons.compress@default:default"/>
|
||||
|
@ -66,10 +55,6 @@
|
|||
<setEntry value="org.apache.poi.poi-ooxml@default:default"/>
|
||||
<setEntry value="org.apache.poi.poi@default:default"/>
|
||||
<setEntry value="org.apache.servicemix.bundles.cglib.source"/>
|
||||
<setEntry value="org.apache.servicemix.bundles.cglib@default:default"/>
|
||||
<setEntry value="org.apache.servicemix.bundles.xerces@default:default"/>
|
||||
<setEntry value="org.apache.xml.resolver@default:default"/>
|
||||
<setEntry value="org.apache.xml.serializer@default:default"/>
|
||||
<setEntry value="org.apache.xmlbeans@default:default"/>
|
||||
<setEntry value="org.cryptacular@default:default"/>
|
||||
<setEntry value="org.eclipse.ant.core@default:default"/>
|
||||
|
@ -93,18 +78,11 @@
|
|||
<setEntry value="org.krysalis.barcode4j@default:default"/>
|
||||
<setEntry value="org.passay@default:default"/>
|
||||
<setEntry value="slf4j.api@default:default"/>
|
||||
<setEntry value="slf4j.jcl@default:default"/>
|
||||
<setEntry value="slf4j.jcl@default:false"/>
|
||||
</setAttribute>
|
||||
<setAttribute key="selected_workspace_bundles">
|
||||
<setEntry value="org.adempiere.base.callout@default:default"/>
|
||||
<setEntry value="org.adempiere.base.process@default:default"/>
|
||||
<setEntry value="org.adempiere.base@default:default"/>
|
||||
<setEntry value="org.adempiere.install@default:default"/>
|
||||
<setEntry value="org.adempiere.payment.processor@default:default"/>
|
||||
<setEntry value="org.adempiere.pipo.handlers@default:default"/>
|
||||
<setEntry value="org.adempiere.pipo@default:true"/>
|
||||
<setEntry value="org.adempiere.plugin.utils@default:default"/>
|
||||
<setEntry value="org.adempiere.replication@default:default"/>
|
||||
<setEntry value="org.apache.ecs@default:default"/>
|
||||
<setEntry value="org.compiere.db.oracle.provider@default:default"/>
|
||||
<setEntry value="org.compiere.db.postgresql.provider@default:default"/>
|
||||
|
|
|
@ -13,14 +13,20 @@
|
|||
*****************************************************************************/
|
||||
package org.adempiere.base;
|
||||
|
||||
import java.awt.event.WindowAdapter;
|
||||
import java.awt.event.WindowEvent;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.swing.JFrame;
|
||||
|
||||
import org.adempiere.util.ModelClassGenerator;
|
||||
import org.adempiere.util.ModelGeneratorDialog;
|
||||
import org.adempiere.util.ModelInterfaceGenerator;
|
||||
import org.compiere.Adempiere;
|
||||
import org.eclipse.equinox.app.IApplication;
|
||||
import org.eclipse.equinox.app.IApplicationContext;
|
||||
import org.osgi.framework.BundleException;
|
||||
import org.osgi.framework.FrameworkUtil;
|
||||
|
||||
/**
|
||||
* @author hengsin
|
||||
|
@ -52,12 +58,30 @@ public class ModelGeneratorApplication implements IApplication {
|
|||
System.out.println("usage: ModelGenerator folder packageName tableEntityType tableName columnEntityType");
|
||||
} else {
|
||||
ModelGeneratorDialog dialog = new ModelGeneratorDialog();
|
||||
dialog.setModal(true);
|
||||
dialog.addWindowListener(new WindowAdapter() {
|
||||
@Override
|
||||
public void windowClosed(WindowEvent e) {
|
||||
context.setResult(IApplication.EXIT_OK, ModelGeneratorApplication.this);
|
||||
try {
|
||||
// async stop https://www.eclipse.org/forums/index.php?t=msg&th=31999&goto=103832&#msg_103832
|
||||
// can cast getBundle(0) to org.osgi.framework.launch.Framework in case want more
|
||||
FrameworkUtil.getBundle(ModelGeneratorApplication.class).getBundleContext().getBundle(0).stop();
|
||||
} catch (BundleException be) {
|
||||
System.exit(0);
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
//dialog.setModal(true);
|
||||
dialog.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
|
||||
dialog.pack();
|
||||
dialog.setLocationRelativeTo(null);
|
||||
dialog.setVisible(true);
|
||||
|
||||
}
|
||||
return IApplication.EXIT_OK;
|
||||
|
||||
// async stop on close window
|
||||
return IApplicationContext.EXIT_ASYNC_RESULT;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
|
|
|
@ -15,6 +15,8 @@ package org.adempiere.util;
|
|||
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Cursor;
|
||||
import java.awt.GridBagConstraints;
|
||||
import java.awt.GridBagLayout;
|
||||
import java.awt.GridLayout;
|
||||
import java.awt.Insets;
|
||||
import java.awt.Panel;
|
||||
|
@ -24,8 +26,8 @@ import java.io.File;
|
|||
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JCheckBox;
|
||||
import javax.swing.JDialog;
|
||||
import javax.swing.JFileChooser;
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JOptionPane;
|
||||
import javax.swing.JTextField;
|
||||
|
@ -37,7 +39,7 @@ import org.compiere.Adempiere;
|
|||
* @author hengsin
|
||||
*
|
||||
*/
|
||||
public class ModelGeneratorDialog extends JDialog implements ActionListener {
|
||||
public class ModelGeneratorDialog extends JFrame implements ActionListener {
|
||||
|
||||
/**
|
||||
* default generated serial version Id
|
||||
|
@ -63,7 +65,7 @@ public class ModelGeneratorDialog extends JDialog implements ActionListener {
|
|||
this.getContentPane().add(confirmPanel, BorderLayout.SOUTH);
|
||||
Panel mainPanel = new Panel();
|
||||
this.getContentPane().add(mainPanel, BorderLayout.CENTER);
|
||||
mainPanel.setLayout(new GridLayout(6, 2));
|
||||
mainPanel.setLayout(new GridBagLayout());
|
||||
|
||||
Panel filePanel = new Panel();
|
||||
filePanel.setLayout(new BorderLayout());
|
||||
|
@ -73,30 +75,30 @@ public class ModelGeneratorDialog extends JDialog implements ActionListener {
|
|||
bFolder = new JButton("...");
|
||||
bFolder.setMargin(new Insets(0, 0, 0, 0));
|
||||
filePanel.add(bFolder, BorderLayout.EAST);
|
||||
mainPanel.add(new JLabel("Source Folder"));
|
||||
mainPanel.add(filePanel);
|
||||
mainPanel.add(new JLabel("Source Folder"), makeGbc(0, 0));
|
||||
mainPanel.add(filePanel, makeGbc(1, 0));
|
||||
bFolder.addActionListener(this);
|
||||
|
||||
mainPanel.add(new JLabel("Package Name"));
|
||||
mainPanel.add(new JLabel("Package Name"), makeGbc(0, 1));
|
||||
fPackageName = new JTextField("org.compiere.model");
|
||||
mainPanel.add(fPackageName);
|
||||
mainPanel.add(fPackageName, makeGbc(1, 1));
|
||||
|
||||
mainPanel.add(new JLabel("Table Name"));
|
||||
mainPanel.add(new JLabel("Table Name"), makeGbc(0, 2));
|
||||
fTableName = new JTextField("AD_ReplaceThis%");
|
||||
mainPanel.add(fTableName);
|
||||
mainPanel.add(fTableName, makeGbc(1, 2));
|
||||
|
||||
mainPanel.add(new JLabel("Table Entity Type"));
|
||||
mainPanel.add(new JLabel("Table Entity Type"), makeGbc(0, 3));
|
||||
fEntityType = new JTextField("D");
|
||||
mainPanel.add(fEntityType);
|
||||
mainPanel.add(fEntityType, makeGbc(1, 3));
|
||||
|
||||
mainPanel.add(new JLabel("Column Entity Type"));
|
||||
mainPanel.add(new JLabel("Column Entity Type"), makeGbc(0, 4));
|
||||
fColumnEntityType = new JTextField("");
|
||||
mainPanel.add(fColumnEntityType);
|
||||
mainPanel.add(fColumnEntityType, makeGbc(1, 4));
|
||||
|
||||
Panel chkPanel = new Panel();
|
||||
chkPanel.setLayout(new GridLayout(1, 2));
|
||||
mainPanel.add(new JLabel(""));
|
||||
mainPanel.add(chkPanel);
|
||||
mainPanel.add(new JLabel(""), makeGbc(0, 5));
|
||||
mainPanel.add(chkPanel, makeGbc(1, 5));
|
||||
fGenerateInterface = new JCheckBox("Generate Interface");
|
||||
fGenerateInterface.setSelected(true);
|
||||
chkPanel.add(fGenerateInterface);
|
||||
|
@ -112,6 +114,20 @@ public class ModelGeneratorDialog extends JDialog implements ActionListener {
|
|||
bCancel.addActionListener(this);
|
||||
}
|
||||
|
||||
private GridBagConstraints makeGbc(int x, int y) {
|
||||
GridBagConstraints gbc = new GridBagConstraints();
|
||||
gbc.gridwidth = 1;
|
||||
gbc.gridheight = 1;
|
||||
gbc.gridx = x;
|
||||
gbc.gridy = y;
|
||||
gbc.weightx = x;
|
||||
gbc.weighty = 1.0;
|
||||
gbc.insets = new Insets(2, 2, 2, 2);
|
||||
gbc.anchor = (x == 0) ? GridBagConstraints.LINE_START : GridBagConstraints.LINE_END;
|
||||
gbc.fill = GridBagConstraints.HORIZONTAL;
|
||||
return gbc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
if (e.getSource() == bGenerate) {
|
||||
|
|
Loading…
Reference in New Issue