So I've got most of the errors resolved (at least in Eclipse), except the documentService.getProperties... and table.setHTML(row, col...
Errors are:
1. getProperties for documentService (which is true based on documentation)
2. row Cannot refer to a non-final variable row inside an inner class defined in a different method
Everything else has been more or less resolved by importing the various classes.
Here is what I have:
Code: Select allOpenKM, Open Document Management System (http://www.openkm.com)
* Copyright (c) 2006-2015 Paco Avila & Josep Llort
*
* No bytes were intentionally harmed during the development of this application.
*
* 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 com.openkm.frontend.client.widget.dashboard.workflow;
import java.util.List;
import java.util.ListIterator;
import org.apache.chemistry.opencmis.server.impl.browser.RepositoryService;
import com.google.gwt.core.client.GWT;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.event.dom.client.HasClickHandlers;
import com.google.gwt.event.shared.HandlerRegistration;
import com.google.gwt.i18n.client.DateTimeFormat;
import com.google.gwt.user.client.Event;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.ui.Anchor;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.FlexTable;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.HasAlignment;
import com.google.gwt.user.client.ui.HorizontalPanel;
import com.google.gwt.user.client.ui.Image;
import com.google.gwt.user.client.ui.SimplePanel;
import com.google.gwt.user.client.ui.VerticalPanel;
import com.openkm.frontend.client.Main;
import com.openkm.frontend.client.bean.GWTDocument;
import com.openkm.frontend.client.bean.GWTTaskInstance;
import com.openkm.frontend.client.widget.ConfirmPopup;
import com.openkm.frontend.client.widget.dashboard.Status;
import com.openkm.frontend.client.service.OKMDocumentService;
import com.openkm.frontend.client.service.OKMDocumentServiceAsync;
import com.openkm.frontend.client.service.OKMRepositoryService;
//Alex
import com.openkm.frontend.client.util.Util;
import com.openkm.frontend.client.service.OKMRepositoryServiceAsync;
import com.openkm.rest.endpoint.DocumentService;
/**
* WorkflowWidget
*
* @author jllort
*
*/
public class WorkflowWidget extends Composite {
private static final int TYPE_PENDING_TASK = 1;
private static final int TYPE_POOLED_TASK = 2;
private static int HEADER_SQUARE = 24;
private static int SEPARATOR_HEIGHT = 20;
private static int SEPARATOR_WIDTH = 20;
private VerticalPanel vPanel;
private SimplePanel spTop;
private HorizontalPanel hPanel;
private SimplePanel spLeft;
private VerticalPanel vCenterPanel;
private SimplePanel spRight;
private Header header;
private SimplePanel panelData;
private FlexTable table;
private Image zoomImage;
private boolean zoom = false;
private boolean flagZoom = true;
public Status status;
private String headerTextKey;
private int widgetType = TYPE_PENDING_TASK;
private GWTTaskInstance taskInstancePooled = null;
private double processToExecuteNextTask = -1;
private final OKMDocumentServiceAsync documentService = (OKMDocumentServiceAsync) GWT.create(OKMDocumentService.class);
private final OKMRepositoryServiceAsync repositoryService = (OKMRepositoryServiceAsync) GWT.create(OKMRepositoryService.class);
/**
* WorkflowWidget
*/
public WorkflowWidget(String headerTextKey, String iconUrl, boolean zoom) {
status = new Status();
status.setStyleName("okm-StatusPopup");
spTop = new SimplePanel();
spLeft = new SimplePanel();
spRight = new SimplePanel();
panelData = new SimplePanel();
table = new FlexTable();
vCenterPanel = new VerticalPanel();
hPanel = new HorizontalPanel();
header = new Header(iconUrl, zoom);
vPanel = new VerticalPanel();
this.headerTextKey = headerTextKey;
// Sets or unsets visible table
table.setVisible(zoom);
header.setHeaderText(Main.i18n(headerTextKey));
panelData.add(table);
vCenterPanel.add(header);
vCenterPanel.add(panelData);
hPanel.add(spLeft);
hPanel.add(vCenterPanel);
hPanel.add(spRight);
vPanel.add(spTop);
vPanel.add(hPanel);
spTop.setHeight(""+SEPARATOR_HEIGHT);
spLeft.setWidth(""+SEPARATOR_WIDTH);
spRight.setWidth(""+SEPARATOR_WIDTH);
vPanel.setStyleName("okm-DashboardWidget ");
panelData.setStyleName("data");
table.setStyleName("okm-NoWrap");
panelData.setWidth("99.6%");
header.setWidth("100%");
table.setCellPadding(0);
table.setCellSpacing(0);
vPanel.addStyleName("okm-DisableSelect");
initWidget(vPanel);
}
/**
* setHeaderText
*
* @param text
*/
public void setHeaderText(String text) {
header.setHeaderText(text);
}
/**
* setHeaderResults
*
* @param value
*/
public void setHeaderResults(int value) {
header.setHeaderResults(value);
}
/**
* setWidth
*
* @param width
*/
public void setWidth(int width) {
vCenterPanel.setWidth(""+(width-2*SEPARATOR_WIDTH));
}
/**
* removeAllRows
*/
private void removeAllRows() {
while (table.getRowCount()>0) {
table.removeRow(0);
}
}
/**
* Setting documents
*
* @param docList document list
*/
public void setTasks(List<GWTTaskInstance> taskIntanceList) {
int tasksNotViewed = 0;
removeAllRows();
for (ListIterator<GWTTaskInstance> it = taskIntanceList.listIterator(); it.hasNext();) {
int row = table.getRowCount();
final GWTTaskInstance taskInstanceResult = it.next();
if (taskInstanceResult.getProcessInstance().getId() == processToExecuteNextTask) {
processToExecuteNextTask = -1;
Main.get().mainPanel.dashboard.workflowDashboard.workflowFormPanel.setTaskInstance(taskInstanceResult);
}
Anchor taskName = new Anchor();
taskName.setText(taskInstanceResult.getName());
taskName.setTitle(taskInstanceResult.getProcessInstance().getProcessDefinition().getName());
switch (widgetType) {
case TYPE_PENDING_TASK:
final String uuid = (String) taskInstanceResult.getProcessInstance().getVariables().get("uuid");
taskName.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
Main.get().mainPanel.dashboard.workflowDashboard.workflowFormPanel.setTaskInstance(taskInstanceResult);
// convert uuid to path
repositoryService.getPathByUUID(uuid, new AsyncCallback<String>() {
@Override
public void onSuccess(final String path) {
// Getting the document properties
documentService.getProperties(path, new AsyncCallback<GWTDocument>() {
@Override
public void onSuccess(GWTDocument doc) {
hPanel.add(new HTML(Util.mimeImageHTML(doc.getMimeType())));
// Here write the table
// To the document icon:
table.setHTML(row, col, Util.mimeImageHTML(doc.getMimeType()));
}
@Override
public void onFailure(Throwable caught) {
Main.get().showError("getProperties", caught);
}
});
};
@Override
public void onFailure(Throwable caught) {
Main.get().showError("getPathByUUID", caught);
}
});
}
});
break;
case TYPE_POOLED_TASK:
taskName.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
Main.get().confirmPopup.setConfirm(ConfirmPopup.CONFIRM_GET_POOLED_WORKFLOW_TASK);
Main.get().confirmPopup.show();
taskInstancePooled = taskInstanceResult;
}
});
break;
}
taskName.setStyleName("okm-Hyperlink");
table.setHTML(row, 0, "");
table.setWidget(row, 1, taskName);
DateTimeFormat dtf = DateTimeFormat.getFormat(Main.i18n("general.date.pattern"));
table.setHTML(row, 2, dtf.format(taskInstanceResult.getCreate()));
table.getCellFormatter().setWidth(row, 0, "20");
table.getCellFormatter().setWidth(row, 1, "100%"); // Table sets de 100% of space
table.getCellFormatter().setHorizontalAlignment(row, 2, HasAlignment.ALIGN_RIGHT);
tasksNotViewed++;
table.getRowFormatter().setStyleName(row, "okm-NotViewed");
}
header.setHeaderNotViewedResults(tasksNotViewed);
}
Any ideas on how to finish this up? I would love to get this completed!