IDEMPIERE-1555:code make link to document is duplicate

This commit is contained in:
hieplq 2014-07-30 16:28:02 +07:00
parent 57163af0bf
commit 18bbd814c1
6 changed files with 110 additions and 104 deletions

View File

@ -19,6 +19,7 @@ package org.adempiere.webui.adwindow;
import org.adempiere.webui.LayoutUtils;
import org.adempiere.webui.apps.AEnv;
import org.adempiere.webui.component.DocumentLink;
import org.adempiere.webui.component.Label;
import org.adempiere.webui.component.Panel;
import org.adempiere.webui.component.Tabpanel;
@ -172,9 +173,7 @@ public class StatusBar extends Panel implements EventListener<Event>
if (m_logs[i].getP_Msg() != null) {
if (m_logs[i].getAD_Table_ID() > 0
&& m_logs[i].getRecord_ID() > 0) {
RecordLink recordLink = new RecordLink(m_logs[i].getAD_Table_ID(), m_logs[i].getRecord_ID());
recordLink.setLabel(m_logs[i].getP_Msg());
recordLink.addEventListener(Events.ON_CLICK, this);
DocumentLink recordLink = new DocumentLink(m_logs[i].getP_Msg(), m_logs[i].getAD_Table_ID(), m_logs[i].getRecord_ID());
if (!div.getChildren().isEmpty())
div.appendChild(new Separator("horizontal"));
div.appendChild(recordLink);
@ -245,9 +244,7 @@ public class StatusBar extends Panel implements EventListener<Event>
@Override
public void onEvent(Event event) throws Exception {
if(event.getTarget() instanceof RecordLink){
doZoom((RecordLink)event.getTarget());
} else if (event.getTarget() instanceof Label) {
if (event.getTarget() instanceof Label) {
showPopup();
}
}
@ -257,16 +254,6 @@ public class StatusBar extends Panel implements EventListener<Event>
LayoutUtils.openOverlappedWindow(messageContainer, msgPopup, "overlap_end");
}
private void doZoom(RecordLink link) {
int Record_ID = 0;
int AD_Table_ID = 0;
Record_ID = link.recordId;
AD_Table_ID = link.tableId;
if (Record_ID > 0 && AD_Table_ID > 0) {
AEnv.zoom(AD_Table_ID, Record_ID);
}
}
/**
*
* @return process logs
@ -304,16 +291,4 @@ public class StatusBar extends Panel implements EventListener<Event>
msgPopup.appendChild(msgPopupCaption);
}
class RecordLink extends A {
private static final long serialVersionUID = 3793489614175751401L;
protected int recordId;
protected int tableId;
protected RecordLink(int AD_Table_ID, int Record_ID) {
super();
tableId = AD_Table_ID;
recordId = Record_ID;
}
}
}

View File

@ -30,6 +30,7 @@ import org.adempiere.webui.LayoutUtils;
import org.adempiere.webui.component.Button;
import org.adempiere.webui.component.Combobox;
import org.adempiere.webui.component.ConfirmPanel;
import org.adempiere.webui.component.DocumentLink;
import org.adempiere.webui.component.Grid;
import org.adempiere.webui.component.GridFactory;
import org.adempiere.webui.component.Mask;
@ -545,13 +546,7 @@ public class ProcessDialog extends AbstractProcessDialog implements EventListene
Td td = new Td();
if (log.getP_Msg() != null) {
if (log.getAD_Table_ID() > 0 && log.getRecord_ID() > 0) {
A recordLink = new A();
recordLink.setLabel(log.getP_Msg());
recordLink.setAttribute("Record_ID",
String.valueOf(log.getRecord_ID()));
recordLink.setAttribute("AD_Table_ID",
String.valueOf(log.getAD_Table_ID()));
recordLink.addEventListener(Events.ON_CLICK, this);
DocumentLink recordLink = new DocumentLink(log.getP_Msg(), log.getAD_Table_ID(), log.getRecord_ID());
td.appendChild(recordLink);
} else {
Text t = new Text();

View File

@ -28,6 +28,7 @@ import java.util.logging.Level;
import org.adempiere.webui.apps.AEnv;
import org.adempiere.webui.component.Button;
import org.adempiere.webui.component.Checkbox;
import org.adempiere.webui.component.DocumentLink;
import org.adempiere.webui.component.Grid;
import org.adempiere.webui.component.GridFactory;
import org.adempiere.webui.component.Label;
@ -376,23 +377,7 @@ public class WAllocation extends Allocation
allocateButton.setEnabled(true);
if (allocation != null)
{
A link = new A(allocation.getDocumentNo());
link.setAttribute("Record_ID", allocation.get_ID());
link.setAttribute("AD_Table_ID", allocation.get_Table_ID());
link.addEventListener(Events.ON_CLICK, new EventListener<Event>()
{
@Override
public void onEvent(Event event) throws Exception
{
Component comp = event.getTarget();
Integer Record_ID = (Integer) comp.getAttribute("Record_ID");
Integer AD_Table_ID = (Integer) comp.getAttribute("AD_Table_ID");
if (Record_ID != null && Record_ID > 0 && AD_Table_ID != null && AD_Table_ID > 0)
{
AEnv.zoom(AD_Table_ID, Record_ID);
}
}
});
DocumentLink link = new DocumentLink(allocation.getDocumentNo(), allocation.get_Table_ID(), allocation.get_ID());
statusBar.appendChild(link);
}
}

View File

@ -28,6 +28,7 @@ import org.adempiere.webui.apps.WProcessCtl;
import org.adempiere.webui.component.Button;
import org.adempiere.webui.component.ConfirmPanel;
import org.adempiere.webui.component.DesktopTabpanel;
import org.adempiere.webui.component.DocumentLink;
import org.adempiere.webui.component.Grid;
import org.adempiere.webui.component.GridFactory;
import org.adempiere.webui.component.ListboxFactory;
@ -252,11 +253,7 @@ public class WGenForm extends ADForm implements EventListener<Event>, WTableMode
{
log.info("Cmd=" + e.getTarget().getId());
//
if(e.getTarget() instanceof A && e.getName().equals(Events.ON_CLICK)){
doOnClick((A)e.getTarget());
return;
}
else if (e.getTarget().getId().equals(ConfirmPanel.A_CANCEL))
if (e.getTarget().getId().equals(ConfirmPanel.A_CANCEL))
{
dispose();
return;
@ -564,13 +561,8 @@ public class WGenForm extends ADForm implements EventListener<Event>, WTableMode
Td td = new Td();
if (log.getP_Msg() != null) {
if (log.getAD_Table_ID() > 0 && log.getRecord_ID() > 0) {
A recordLink = new A();
recordLink.setLabel(log.getP_Msg());
recordLink.setAttribute("Record_ID",
String.valueOf(log.getRecord_ID()));
recordLink.setAttribute("AD_Table_ID",
String.valueOf(log.getAD_Table_ID()));
recordLink.addEventListener(Events.ON_CLICK, this);
DocumentLink recordLink = new DocumentLink(log.getP_Msg(), log.getAD_Table_ID(), log.getRecord_ID());
td.appendChild(recordLink);
} else {
Text t = new Text();
@ -584,25 +576,4 @@ public class WGenForm extends ADForm implements EventListener<Event>, WTableMode
}
messageDiv.appendChild(logMessageTable);
}
/**
* Handling Anchor link on end of process
* Open document window
* @param btn
*/
private void doOnClick(A btn) {
int Record_ID = 0;
int AD_Table_ID =0;
try
{
Record_ID = Integer.valueOf((String)btn.getAttribute("Record_ID"));
AD_Table_ID= Integer.valueOf((String)btn.getAttribute("AD_Table_ID"));
}
catch (Exception e) {
}
if (Record_ID > 0 && AD_Table_ID > 0) {
AEnv.zoom(AD_Table_ID, Record_ID);
}
}
}

View File

@ -0,0 +1,96 @@
/**********************************************************************
* This file is part of Idempiere ERP Bazaar *
* http://www.idempiere.org *
* *
* Copyright (C) Idempiere *
* *
* 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. *
* *
**********************************************************************/
package org.adempiere.webui.component;
import org.adempiere.webui.apps.AEnv;
import org.zkoss.zk.ui.event.Event;
import org.zkoss.zk.ui.event.EventListener;
import org.zkoss.zk.ui.event.Events;
import org.zkoss.zul.A;
/**
* Make link to document window
* @author hieplq
*
*/
public class DocumentLink extends A implements EventListener<Event> {
private static final long serialVersionUID = -2950001959302619043L;
public static final String ATT_RECORD_ID = "Record_ID";
public static final String ATT_AD_TABLE_ID = "AD_Table_ID";
protected int recordId;
public int getRecordId() {
return recordId;
}
public void setRecordId(int recordId) {
this.recordId = recordId;
}
protected int adTableId;
public int getAdTableId() {
return adTableId;
}
public void setAdTableId(int adTableId) {
this.adTableId = adTableId;
}
public DocumentLink(String label, int adTableId, int recordId){
this(label, adTableId, recordId, null);
}
public DocumentLink(String label, int adTableId, int recordId, EventListener<Event> clickHandle){
super();
if (label == null || label.trim().length() == 0)
label = String.valueOf(recordId);
super.setLabel(label);
setAdTableId(adTableId);
setRecordId(recordId);
if (clickHandle == null)
this.addEventListener (Events.ON_CLICK, this);
else
this.addEventListener (Events.ON_CLICK, clickHandle);
}
/**
* Go to document window
*/
@Override
public void onEvent(Event event) throws Exception {
if(event.getTarget() instanceof DocumentLink){
DocumentLink documentLink = (DocumentLink)event.getTarget();
if (documentLink.getAdTableId() > 0 && documentLink.getAdTableId() > 0)
AEnv.zoom(documentLink.getAdTableId(), documentLink.getRecordId());
}
}
}

View File

@ -98,13 +98,8 @@ public class ProcessInfoDialog extends Window implements EventListener<Event> {
if (log.getAD_Table_ID() > 0
&& log.getRecord_ID() > 0) {
A recordLink = new A();
recordLink.setLabel(sb.toString());
recordLink.setAttribute("Record_ID",
String.valueOf(log.getRecord_ID()));
recordLink.setAttribute("AD_Table_ID",
String.valueOf(log.getAD_Table_ID()));
recordLink.addEventListener(Events.ON_CLICK, this);
DocumentLink recordLink = new DocumentLink(sb.toString(), log.getAD_Table_ID(), log.getRecord_ID());
pnlMessage.appendChild(recordLink);
} else {
Text recordText = new Text(sb.toString());
@ -153,18 +148,7 @@ public class ProcessInfoDialog extends Window implements EventListener<Event> {
public void onEvent(Event event) throws Exception {
if (event == null)
return;
if (event.getTarget() instanceof A) {
int Record_ID = 0;
int AD_Table_ID = 0;
Record_ID = Integer.valueOf((String) event.getTarget()
.getAttribute("Record_ID"));
AD_Table_ID = Integer.valueOf((String) event.getTarget()
.getAttribute("AD_Table_ID"));
if (Record_ID > 0 && AD_Table_ID > 0) {
AEnv.zoom(AD_Table_ID, Record_ID);
}
} else if (event.getTarget() == btnOk) {
if (event.getTarget() == btnOk) {
this.detach();
}
}