Skip to content

Commit

Permalink
- reverting fix path commit
Browse files Browse the repository at this point in the history
- BZ-1009915: improving comments screen
- BZ-1009911: checking for empty comments
  • Loading branch information
salaboy committed Sep 20, 2013
1 parent c414f22 commit e2a076f
Show file tree
Hide file tree
Showing 9 changed files with 109 additions and 9 deletions.
Expand Up @@ -68,9 +68,7 @@ public class TaskAssignmentsViewImpl extends Composite implements TaskAssignment
@Inject
@DataField
public Label usersGroupsControlsPanel;





@Inject
private Event<NotificationEvent> notification;
Expand Down
Expand Up @@ -61,6 +61,8 @@ public interface TaskCommentsView extends UberView<TaskCommentsPresenter> {
DataGrid<CommentSummary> getDataGrid();

SimplePager getPager();

void displayNotification( String text );
}

@Inject
Expand Down Expand Up @@ -141,6 +143,17 @@ public void callback( Long response ) {
}
} ).addComment( currentTaskId, text, identity.getName(), addedOn );
}

public void removeTaskComment( long commentId ) {
taskServices.call( new RemoteCallback<Long>() {
@Override
public void callback( Long response ) {
refreshComments( );
view.getNewTaskCommentTextArea().setText("");
view.displayNotification("Comment Deleted!");
}
} ).deleteComment( currentTaskId, commentId );
}

public void addDataDisplay( HasData<CommentSummary> display ) {
dataProvider.addDataDisplay( display );
Expand Down
Expand Up @@ -33,22 +33,37 @@
import com.github.gwtbootstrap.client.ui.Label;
import com.github.gwtbootstrap.client.ui.SimplePager;
import com.github.gwtbootstrap.client.ui.TextArea;
import com.github.gwtbootstrap.client.ui.base.UnorderedList;
import com.google.gwt.cell.client.ActionCell;
import com.google.gwt.cell.client.ActionCell.Delegate;
import com.google.gwt.cell.client.Cell;
import com.google.gwt.cell.client.CompositeCell;
import com.google.gwt.cell.client.FieldUpdater;
import com.google.gwt.cell.client.HasCell;
import com.google.gwt.cell.client.TextCell;
import com.google.gwt.core.client.GWT;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.i18n.client.DateTimeFormat;
import com.google.gwt.safehtml.shared.SafeHtmlBuilder;
import com.google.gwt.user.cellview.client.Column;
import com.google.gwt.user.cellview.client.ColumnSortEvent.ListHandler;
import com.google.gwt.user.client.ui.AbstractImagePrototype;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.FlowPanel;
import com.google.gwt.user.client.ui.HTMLPanel;
import java.util.LinkedList;
import java.util.List;
import javax.enterprise.event.Event;
import org.jbpm.console.ng.ht.client.i18n.Constants;
import org.jbpm.console.ng.ht.client.resources.HumanTasksImages;
import org.jbpm.console.ng.ht.client.util.ResizableHeader;
import org.jbpm.console.ng.pr.model.ProcessInstanceSummary;
import org.uberfire.workbench.events.NotificationEvent;

@Dependent
@Templated(value = "TaskCommentsViewImpl.html")
public class TaskCommentsViewImpl extends Composite implements TaskCommentsPresenter.TaskCommentsView {
private Constants constants = GWT.create(Constants.class);
private HumanTasksImages images = GWT.create( HumanTasksImages.class );

private TaskCommentsPresenter presenter;

Expand Down Expand Up @@ -84,6 +99,8 @@ public class TaskCommentsViewImpl extends Composite implements TaskCommentsPrese

private ListHandler<CommentSummary> sortHandler;

@Inject
private Event<NotificationEvent> notification;

@Override
public TextArea getNewTaskCommentTextArea() {
Expand Down Expand Up @@ -131,7 +148,16 @@ public void init(TaskCommentsPresenter presenter) {

@EventHandler("addCommentButton")
public void addCommentButton(ClickEvent e) {
presenter.addTaskComment(newTaskCommentTextArea.getText(), new Date());
if(!newTaskCommentTextArea.getText().equals("")){
presenter.addTaskComment(newTaskCommentTextArea.getText(), new Date());
}else{
displayNotification("The Comment cannot be empty!");
}
}

@Override
public void displayNotification( String text ) {
notification.fire( new NotificationEvent( text ) );
}

private void initTableColumns() {
Expand Down Expand Up @@ -176,5 +202,65 @@ public String getValue(CommentSummary object) {
};
addedByColumn.setSortable(false);
commentsListGrid.addColumn(commentTextColumn, constants.Comment());

List<HasCell<CommentSummary, ?>> cells = new LinkedList<HasCell<CommentSummary, ?>>();

cells.add( new DeleteCommentActionHasCell( "Delete", new Delegate<CommentSummary>() {
@Override
public void execute( CommentSummary comment ) {

presenter.removeTaskComment(comment.getId());
}
} ) );

CompositeCell<CommentSummary> cell = new CompositeCell<CommentSummary>( cells );
Column<CommentSummary, CommentSummary> actionsColumn = new Column<CommentSummary, CommentSummary>(
cell ) {
@Override
public CommentSummary getValue( CommentSummary object ) {
return object;
}
};
commentsListGrid.addColumn( actionsColumn, new ResizableHeader( "", commentsListGrid,
actionsColumn ) );
}

private class DeleteCommentActionHasCell implements HasCell<CommentSummary, CommentSummary> {

private ActionCell<CommentSummary> cell;

public DeleteCommentActionHasCell( String text,
Delegate<CommentSummary> delegate ) {
cell = new ActionCell<CommentSummary>( text, delegate ) {
@Override
public void render( Cell.Context context,
CommentSummary value,
SafeHtmlBuilder sb ) {

AbstractImagePrototype imageProto = AbstractImagePrototype.create( images.abortGridIcon() );
SafeHtmlBuilder mysb = new SafeHtmlBuilder();
mysb.appendHtmlConstant( "<span title='" + constants.Delete() + "' style='margin-right:5px;'>");
mysb.append( imageProto.getSafeHtml() );
mysb.appendHtmlConstant( "</span>" );
sb.append( mysb.toSafeHtml() );

}
};
}

@Override
public Cell<CommentSummary> getCell() {
return cell;
}

@Override
public FieldUpdater<CommentSummary, CommentSummary> getFieldUpdater() {
return null;
}

@Override
public CommentSummary getValue( CommentSummary object ) {
return object;
}
}
}
Expand Up @@ -160,4 +160,6 @@ public interface Constants extends Messages {
String Parent_Group();

String Save();

String Delete();
}
Expand Up @@ -24,6 +24,9 @@ public interface HumanTasksImages extends ClientBundle {

HumanTasksImages INSTANCE = GWT.create(HumanTasksImages.class);

@Source("org/jbpm/console/ng/ht/public/images/icons/abort-grid-icon.png")
public ImageResource abortGridIcon();

@Source("org/jbpm/console/ng/ht/public/images/icons/complete-grid-icon.png")
public ImageResource completeGridIcon();

Expand Down
Expand Up @@ -63,3 +63,4 @@ Add_TypeRole=Add Type Role
Type_Role=Type Role
Parent_Group=Parent Group
Save=Save
Delete=Delete
Expand Up @@ -63,3 +63,4 @@ Add_TypeRole=Agregar tipo de rol
Type_Role=Tipo de rol
Parent_Group=Grupo Padre
Save=Guardar
Delete=Borrar
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Expand Up @@ -43,10 +43,6 @@ public String getFileName() {
return fileName + ".bpmn2";
}

@Override
public String getFileNameWithoutExtension() {
return fileName;
}

@Override
public String toURI() {
Expand Down

0 comments on commit e2a076f

Please sign in to comment.