use of java.awt.Container in project adempiere by adempiere.
the class ProcessCtl method lock.
// run
/**
* Lock UI & show Waiting
*/
private void lock() {
//m_parent is null for synchrous execution
if (m_parent != null) {
if (m_parent instanceof Container) {
//swing client
JFrame frame = Env.getFrame((Container) m_parent);
if (frame instanceof AWindow)
((AWindow) frame).setBusyTimer(processInstance.getEstSeconds());
else
waiting = new Waiting(frame, Msg.getMsg(Env.getCtx(), "Processing"), false, processInstance.getEstSeconds());
SwingUtilities.invokeLater(new Runnable() {
public void run() {
log.finer("lock");
m_parent.lockUI(processInstance);
}
});
if (waiting != null) {
waiting.toFront();
waiting.setVisible(true);
}
} else {
//other client
log.finer("lock");
m_parent.lockUI(processInstance);
}
}
}
use of java.awt.Container in project adempiere by adempiere.
the class ProcessCtl method process.
/**
* Process Control
* <code>
* - Get Instance ID
* - Get Parameters
* - execute (lock - start process - unlock)
* </code>
* Creates a ProcessCtl instance, which calls
* lockUI and unlockUI if parent is a ASyncProcess
* <br>
* 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(ASyncProcess parent, int WindowNo, ProcessInfo pi, Trx trx) {
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)
// FR [ 265 ]
// Change to Standard Process Modal Dialog
ProcessModalDialog para = new ProcessModalDialog(Env.getFrame((Container) parent), WindowNo, pi);
if (para.isValidDialog()) {
para.validate();
para.pack();
AEnv.showCenterWindow(Env.getWindow(WindowNo), para);
if (!para.isOK()) {
return null;
}
}
// execute
ProcessCtl worker = new ProcessCtl(parent, WindowNo, pi, trx);
if (parent != null) {
//asynchrous
worker.start();
} else {
//synchrous
worker.run();
}
return worker;
}
use of java.awt.Container in project adempiere by adempiere.
the class VPAttribute method actionPerformed.
// addActionListener
/**
* Action Listener - start dialog
* @param e Event
*/
public void actionPerformed(ActionEvent e) {
if (e.getActionCommand().equals(RecordInfo.CHANGE_LOG_COMMAND)) {
RecordInfo.start(m_GridField);
return;
}
if (!m_button.isEnabled())
return;
m_button.setEnabled(false);
//
Integer oldValue = 0;
try {
oldValue = (Integer) getValue();
} catch (ClassCastException cce) {
// Possible Invalid Cast exception if getValue() return new instance of Object.
}
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;
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
// HARDCODED
boolean productWindow = m_AD_Column_ID == 8418;
// Exclude ability to enter ASI
boolean exclude = false;
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 (// Use BOM Component
M_ProductBOM_ID != 0)
M_Product_ID = M_ProductBOM_ID;
// If the VPAttribute component is in a dialog, use the search
if (m_searchOnly) {
// The component is an element in a CPanel, which is part of a JPanel
// which is in a JLayeredPane which is in ... the InfoProduct window
Container me = ((Container) this).getParent();
while (me != null) {
if (me instanceof InfoProduct)
break;
me = me.getParent();
}
InfoPAttribute ia = new InfoPAttribute((CDialog) me);
m_pAttributeWhere = ia.getWhereClause();
String oldText = m_text.getText();
m_text.setText(ia.getDisplay());
// The text can be long. Use the tooltip to help display the info.
m_text.setToolTipText(m_text.getText());
ActionEvent ae = new ActionEvent(m_text, 1001, "updated");
// TODO not the generally correct way to fire an event
((InfoProduct) me).actionPerformed(ae);
} else if (!productWindow && (M_Product_ID == 0 || exclude)) {
changed = true;
m_text.setText(null);
M_AttributeSetInstance_ID = 0;
} else {
VPAttributeDialog vad = new VPAttributeDialog(Env.getFrame(this), M_AttributeSetInstance_ID, M_Product_ID, m_C_BPartner_ID, productWindow, m_AD_Column_ID, m_WindowNo, isReadWrite());
if (vad.isChanged()) {
m_text.setText(vad.getM_AttributeSetInstanceName());
// The text can be long. Use the tooltip to help display the info.
m_text.setToolTipText(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) {
log.finest("Changed M_AttributeSetInstance_ID=" + M_AttributeSetInstance_ID);
// force re-query display
m_value = new Object();
if (M_AttributeSetInstance_ID == 0)
setValue(null);
else
setValue(new Integer(M_AttributeSetInstance_ID));
// Change Locator
if (m_GridTab != null && M_Locator_ID > 0) {
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();
}
use of java.awt.Container in project jmeter by apache.
the class TextBoxDialoger method createDialogBox.
private void createDialogBox() {
JFrame mainFrame = GuiPackage.getInstance().getMainFrame();
String title = //$NON-NLS-1$
editable ? //$NON-NLS-1$
JMeterUtils.getResString("textbox_title_edit") : //$NON-NLS-1$
JMeterUtils.getResString("textbox_title_view");
// modal dialog box
dialog = new JDialog(mainFrame, title, true);
// Close action dialog box when tapping Escape key
JPanel content = (JPanel) dialog.getContentPane();
content.registerKeyboardAction(this, KeyStrokes.ESC, JComponent.WHEN_IN_FOCUSED_WINDOW);
textBox = new JEditorPane();
textBox.setEditable(editable);
JScrollPane textBoxScrollPane = GuiUtils.makeScrollPane(textBox);
JPanel btnBar = new JPanel();
btnBar.setLayout(new FlowLayout(FlowLayout.RIGHT));
if (editable) {
//$NON-NLS-1$
JButton cancelBtn = new JButton(JMeterUtils.getResString("textbox_cancel"));
cancelBtn.setActionCommand(CANCEL_COMMAND);
cancelBtn.addActionListener(this);
//$NON-NLS-1$
JButton saveBtn = new JButton(JMeterUtils.getResString("textbox_save_close"));
saveBtn.setActionCommand(SAVE_CLOSE_COMMAND);
saveBtn.addActionListener(this);
btnBar.add(cancelBtn);
btnBar.add(saveBtn);
} else {
//$NON-NLS-1$
JButton closeBtn = new JButton(JMeterUtils.getResString("textbox_close"));
closeBtn.setActionCommand(CLOSE_COMMAND);
closeBtn.addActionListener(this);
btnBar.add(closeBtn);
}
// Prepare dialog box
Container panel = dialog.getContentPane();
dialog.setMinimumSize(new Dimension(400, 250));
panel.add(textBoxScrollPane, BorderLayout.CENTER);
panel.add(btnBar, BorderLayout.SOUTH);
// determine location on screen
Point p = mainFrame.getLocationOnScreen();
Dimension d1 = mainFrame.getSize();
Dimension d2 = dialog.getSize();
dialog.setLocation(p.x + (d1.width - d2.width) / 2, p.y + (d1.height - d2.height) / 2);
dialog.pack();
}
use of java.awt.Container in project lombok by rzwitserloot.
the class InstallerGUI method doUninstall.
private void doUninstall() {
JPanel spinner = new JPanel();
spinner.setOpaque(true);
spinner.setLayout(new FlowLayout());
spinner.add(new JLabel(new ImageIcon(Installer.class.getResource("/lombok/installer/loading.gif"))));
final Container originalContentPane = appWindow.getContentPane();
appWindow.setContentPane(spinner);
final AtomicInteger successes = new AtomicInteger();
new Thread(new Runnable() {
@Override
public void run() {
for (IdeLocation loc : toUninstall) {
try {
loc.uninstall();
successes.incrementAndGet();
} catch (final UninstallException e) {
if (e.isWarning()) {
try {
SwingUtilities.invokeAndWait(new Runnable() {
@Override
public void run() {
JOptionPane.showMessageDialog(appWindow, e.getMessage(), "Uninstall Problem", JOptionPane.WARNING_MESSAGE);
}
});
} catch (Exception e2) {
e2.printStackTrace();
//Shouldn't happen.
throw new RuntimeException(e2);
}
} else {
try {
SwingUtilities.invokeAndWait(new Runnable() {
@Override
public void run() {
JOptionPane.showMessageDialog(appWindow, e.getMessage(), "Uninstall Problem", JOptionPane.ERROR_MESSAGE);
}
});
} catch (Exception e2) {
e2.printStackTrace();
//Shouldn't happen.
throw new RuntimeException(e2);
}
}
}
}
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
if (successes.get() > 0) {
JOptionPane.showMessageDialog(appWindow, "Lombok has been removed from the selected IDE installations.", "Uninstall successful", JOptionPane.INFORMATION_MESSAGE);
appWindow.setVisible(false);
System.exit(0);
return;
}
appWindow.setContentPane(originalContentPane);
}
});
}
}).start();
}
Aggregations