IDEMPIERE-1386 - email from attachments dialog (#909)
* IDEMPIERE-1386 - email from attachments dialog * IDEMPIERE-1386 - fix mobile suggested by CarlosRuiz-globalqss
This commit is contained in:
parent
631e25b599
commit
c24270615e
|
@ -26,6 +26,8 @@ import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
|
||||||
|
import javax.activation.FileDataSource;
|
||||||
|
|
||||||
import org.adempiere.exceptions.AdempiereException;
|
import org.adempiere.exceptions.AdempiereException;
|
||||||
import org.adempiere.util.Callback;
|
import org.adempiere.util.Callback;
|
||||||
import org.adempiere.webui.AdempiereWebUI;
|
import org.adempiere.webui.AdempiereWebUI;
|
||||||
|
@ -39,17 +41,20 @@ import org.adempiere.webui.component.ListItem;
|
||||||
import org.adempiere.webui.component.Listbox;
|
import org.adempiere.webui.component.Listbox;
|
||||||
import org.adempiere.webui.component.Panel;
|
import org.adempiere.webui.component.Panel;
|
||||||
import org.adempiere.webui.component.Textbox;
|
import org.adempiere.webui.component.Textbox;
|
||||||
|
import org.adempiere.webui.component.ToolBar;
|
||||||
import org.adempiere.webui.component.Window;
|
import org.adempiere.webui.component.Window;
|
||||||
import org.adempiere.webui.event.DialogEvents;
|
import org.adempiere.webui.event.DialogEvents;
|
||||||
import org.adempiere.webui.factory.ButtonFactory;
|
import org.adempiere.webui.factory.ButtonFactory;
|
||||||
import org.adempiere.webui.theme.ThemeManager;
|
import org.adempiere.webui.theme.ThemeManager;
|
||||||
import org.adempiere.webui.util.ZKUpdateUtil;
|
import org.adempiere.webui.util.ZKUpdateUtil;
|
||||||
import org.adempiere.webui.window.FDialog;
|
import org.adempiere.webui.window.FDialog;
|
||||||
|
import org.adempiere.webui.window.WEMailDialog;
|
||||||
import org.adempiere.webui.window.WTextEditorDialog;
|
import org.adempiere.webui.window.WTextEditorDialog;
|
||||||
import org.compiere.model.MAttachment;
|
import org.compiere.model.MAttachment;
|
||||||
import org.compiere.model.MAttachmentEntry;
|
import org.compiere.model.MAttachmentEntry;
|
||||||
import org.compiere.model.MSysConfig;
|
import org.compiere.model.MSysConfig;
|
||||||
import org.compiere.model.MTable;
|
import org.compiere.model.MTable;
|
||||||
|
import org.compiere.model.MUser;
|
||||||
import org.compiere.util.CLogger;
|
import org.compiere.util.CLogger;
|
||||||
import org.compiere.util.Env;
|
import org.compiere.util.Env;
|
||||||
import org.compiere.util.Msg;
|
import org.compiere.util.Msg;
|
||||||
|
@ -113,12 +118,13 @@ public class WAttachment extends Window implements EventListener<Event>
|
||||||
private Button bCancel = ButtonFactory.createNamedButton(ConfirmPanel.A_CANCEL, false, true);
|
private Button bCancel = ButtonFactory.createNamedButton(ConfirmPanel.A_CANCEL, false, true);
|
||||||
private Button bOk = ButtonFactory.createNamedButton(ConfirmPanel.A_OK, false, true);
|
private Button bOk = ButtonFactory.createNamedButton(ConfirmPanel.A_OK, false, true);
|
||||||
private Button bPreview = new Button();
|
private Button bPreview = new Button();
|
||||||
|
private Button bEmail = new Button();
|
||||||
|
|
||||||
private Panel previewPanel = new Panel();
|
private Panel previewPanel = new Panel();
|
||||||
|
|
||||||
private Borderlayout mainPanel = new Borderlayout();
|
private Borderlayout mainPanel = new Borderlayout();
|
||||||
|
|
||||||
private Hbox toolBar = new Hbox();
|
private ToolBar toolBar = new ToolBar();
|
||||||
|
|
||||||
private Hlayout confirmPanel = new Hlayout();
|
private Hlayout confirmPanel = new Hlayout();
|
||||||
|
|
||||||
|
@ -269,11 +275,12 @@ public class WAttachment extends Window implements EventListener<Event>
|
||||||
cbContent.addEventListener(Events.ON_SELECT, this);
|
cbContent.addEventListener(Events.ON_SELECT, this);
|
||||||
|
|
||||||
toolBar.setAlign("center");
|
toolBar.setAlign("center");
|
||||||
toolBar.setPack("start");
|
toolBar.setOverflowPopup(true);
|
||||||
toolBar.appendChild(bLoad);
|
toolBar.appendChild(bLoad);
|
||||||
toolBar.appendChild(bDelete);
|
toolBar.appendChild(bDelete);
|
||||||
toolBar.appendChild(bSave);
|
toolBar.appendChild(bSave);
|
||||||
toolBar.appendChild(bSaveAllAsZip);
|
toolBar.appendChild(bSaveAllAsZip);
|
||||||
|
toolBar.appendChild(bEmail);
|
||||||
toolBar.appendChild(cbContent);
|
toolBar.appendChild(cbContent);
|
||||||
toolBar.appendChild(sizeLabel);
|
toolBar.appendChild(sizeLabel);
|
||||||
|
|
||||||
|
@ -317,6 +324,15 @@ public class WAttachment extends Window implements EventListener<Event>
|
||||||
|
|
||||||
bDelete.addEventListener(Events.ON_CLICK, this);
|
bDelete.addEventListener(Events.ON_CLICK, this);
|
||||||
|
|
||||||
|
bEmail.setEnabled(false);
|
||||||
|
if (ThemeManager.isUseFontIconForImage())
|
||||||
|
bEmail.setIconSclass("z-icon-SendMail");
|
||||||
|
else
|
||||||
|
bEmail.setImage(ThemeManager.getThemeResource("images/SendMail24.png"));
|
||||||
|
bLoad.setSclass("img-btn");
|
||||||
|
bEmail.setTooltiptext(Msg.getMsg(Env.getCtx(), "EMail"));
|
||||||
|
bEmail.addEventListener(Events.ON_CLICK, this);
|
||||||
|
|
||||||
previewPanel.appendChild(preview);
|
previewPanel.appendChild(preview);
|
||||||
ZKUpdateUtil.setVflex(preview, "1");
|
ZKUpdateUtil.setVflex(preview, "1");
|
||||||
ZKUpdateUtil.setHflex(preview, "1");
|
ZKUpdateUtil.setHflex(preview, "1");
|
||||||
|
@ -452,6 +468,7 @@ public class WAttachment extends Window implements EventListener<Event>
|
||||||
bSave.setEnabled(true);
|
bSave.setEnabled(true);
|
||||||
bSaveAllAsZip.setEnabled(true);
|
bSaveAllAsZip.setEnabled(true);
|
||||||
bDelete.setEnabled(true);
|
bDelete.setEnabled(true);
|
||||||
|
bEmail.setEnabled(true);
|
||||||
|
|
||||||
if (autoPreviewList.contains(mimeType))
|
if (autoPreviewList.contains(mimeType))
|
||||||
{
|
{
|
||||||
|
@ -492,6 +509,7 @@ public class WAttachment extends Window implements EventListener<Event>
|
||||||
bSaveAllAsZip.setEnabled(false);
|
bSaveAllAsZip.setEnabled(false);
|
||||||
bDelete.setEnabled(false);
|
bDelete.setEnabled(false);
|
||||||
sizeLabel.setText("");
|
sizeLabel.setText("");
|
||||||
|
bEmail.setEnabled(false);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -640,6 +658,8 @@ public class WAttachment extends Window implements EventListener<Event>
|
||||||
displayData(cbContent.getSelectedIndex(), true);
|
displayData(cbContent.getSelectedIndex(), true);
|
||||||
} else if (e.getTarget() == bSaveAllAsZip) {
|
} else if (e.getTarget() == bSaveAllAsZip) {
|
||||||
saveAllAsZip();
|
saveAllAsZip();
|
||||||
|
} else if(e.getTarget()==bEmail){
|
||||||
|
sendMail();
|
||||||
}
|
}
|
||||||
|
|
||||||
} // onEvent
|
} // onEvent
|
||||||
|
@ -823,4 +843,19 @@ public class WAttachment extends Window implements EventListener<Event>
|
||||||
Filedownload.save(media);
|
Filedownload.save(media);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void sendMail()
|
||||||
|
{
|
||||||
|
int index = cbContent.getSelectedIndex();
|
||||||
|
|
||||||
|
MUser from = MUser.get(Env.getCtx(), Env.getAD_User_ID(Env.getCtx()));
|
||||||
|
String fileName = System.getProperty("java.io.tmpdir") +
|
||||||
|
System.getProperty("file.separator") + m_attachment.getEntryName(index);
|
||||||
|
File attachment = new File(fileName);
|
||||||
|
m_attachment.getEntryFile(index, attachment);
|
||||||
|
|
||||||
|
WEMailDialog dialog = new WEMailDialog (Msg.getMsg(Env.getCtx(), "SendMail"),
|
||||||
|
from, "", "", "", new FileDataSource(attachment));
|
||||||
|
AEnv.showWindow(dialog);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue