Skip to content

Commit

Permalink
BZ-1129694: validations and refactoring in forms
Browse files Browse the repository at this point in the history
Conflicts:
	jbpm-console-ng-executor-service/jbpm-console-ng-executor-service-client/src/main/java/org/jbpm/console/ng/es/client/editors/quicknewjob/QuickNewJobViewImpl.ui.xml
	jbpm-console-ng-executor-service/jbpm-console-ng-executor-service-client/src/main/java/org/jbpm/console/ng/es/client/editors/requestlist/RequestListViewImpl.java
  • Loading branch information
salaboy committed Dec 5, 2014
1 parent c1784e2 commit 5113be0
Show file tree
Hide file tree
Showing 9 changed files with 316 additions and 120 deletions.
@@ -0,0 +1,92 @@
<?xml version="1.0" encoding="utf-8"?>

<!--
~ Copyright 2012 JBoss Inc
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->
<!DOCTYPE ui:UiBinder SYSTEM "http://dl.google.com/gwt/DTD/xhtml.ent">
<ui:UiBinder xmlns:ui='urn:ui:com.google.gwt.uibinder'
xmlns:gwt='urn:import:com.google.gwt.user.client.ui'
xmlns:bootstrap='urn:import:com.github.gwtbootstrap.client.ui'>

<ui:with field="i18n"
type="org.jbpm.console.ng.es.client.i18n.Constants"/>


<ui:style>
.mandatory-field {
color: red;
}
</ui:style>

<gwt:HTMLPanel>
<bootstrap:Well>
<bootstrap:Fieldset>
<bootstrap:ControlGroup ui:field="jobNameControlGroup">
<bootstrap:ControlLabel for="jobNameText">
<span class="{style.mandatory-field}">*</span>
<ui:text from="{i18n.Name}"/>
</bootstrap:ControlLabel>
<bootstrap:Controls>
<bootstrap:TextBox bootstrap:id="jobNameText" ui:field="jobNameText" placeholder="{i18n.Name}"/>
<bootstrap:HelpInline ui:field="jobNameHelpInline"/>
</bootstrap:Controls>
</bootstrap:ControlGroup>

<bootstrap:ControlGroup ui:field="jobDueDateControlGroup">
<bootstrap:ControlLabel for="jobDueDate">
<ui:text from="{i18n.Due_On}"/>
</bootstrap:ControlLabel>
<bootstrap:Controls>
<gwt:HorizontalPanel ui:field="jobDueSimplePanel"/>
<bootstrap:HelpInline ui:field="jobDueDateHelpInline"/>
</bootstrap:Controls>
</bootstrap:ControlGroup>

<bootstrap:ControlGroup ui:field="jobTypeControlGroup">
<bootstrap:ControlLabel for="jobTypeText">
<span class="{style.mandatory-field}">*</span>
<ui:text from="{i18n.Type}"/>
</bootstrap:ControlLabel>
<bootstrap:Controls>
<bootstrap:TextBox bootstrap:id="jobTypeText" ui:field="jobTypeText" placeholder="{i18n.Type}"/>
<bootstrap:HelpInline ui:field="jobTypeHelpInline"/>
</bootstrap:Controls>
</bootstrap:ControlGroup>

<bootstrap:ControlGroup ui:field="jobRetriesControlGroup">
<bootstrap:ControlLabel for="jobRetriesNumber">
<span class="{style.mandatory-field}">*</span>
<ui:text from="{i18n.Retries}"/>
</bootstrap:ControlLabel>
<bootstrap:Controls>
<bootstrap:IntegerBox bootstrap:id="jobRetriesNumber" ui:field="jobRetriesNumber" placeholder="{i18n.Retries}"/>
<bootstrap:HelpInline ui:field="jobRetriesHelpInline"/>
</bootstrap:Controls>
</bootstrap:ControlGroup>

<bootstrap:DataGrid ui:field="myParametersGrid">

</bootstrap:DataGrid>
<bootstrap:Button ui:field="newParametersButton"></bootstrap:Button>
</bootstrap:Fieldset>


</bootstrap:Well>
<bootstrap:ModalFooter>
<bootstrap:Button type="PRIMARY" ui:field="createButton"></bootstrap:Button>
</bootstrap:ModalFooter>
</gwt:HTMLPanel>

</ui:UiBinder>
Expand Up @@ -64,8 +64,6 @@ public interface RequestListView extends ListView<RequestSummary, RequestListPre
@Inject
private RequestListView view;

private Menus menus;

@Inject
private Caller<ExecutorServiceEntryPoint> executorServices;
@Inject
Expand All @@ -76,7 +74,6 @@ public interface RequestListView extends ListView<RequestSummary, RequestListPre

public RequestListPresenter() {
onRangeChanged();
makeMenuBar();
}

private void onRangeChanged(){
Expand Down Expand Up @@ -198,41 +195,4 @@ public void callback(Void nothing) {
}).requeueRequest(requestId);
}

@WorkbenchMenu
public Menus getMenus() {
return menus;
}

private void makeMenuBar() {
menus = MenuFactory
.newTopLevelMenu(constants.Settings())
.respondsWith(new Command() {
@Override
public void execute() {
placeManager.goTo( new DefaultPlaceRequest( "Job Service Settings" ) );

}
})
.endMenu()
.newTopLevelMenu(constants.New_Job())
.respondsWith(new Command() {
@Override
public void execute() {
placeManager.goTo( new DefaultPlaceRequest( "Quick New Job" ) );

}
})
.endMenu()
.newTopLevelMenu(constants.Refresh())
.respondsWith(new Command() {
public void execute() {
refreshRequests(null);
// clearSearchEvent.fire(new ClearSearchEvent());
// view.setCurrentFilter("");
// view.displayNotification(constants.Process_Instances_Refreshed());
}
})
.endMenu().build();

}
}
Expand Up @@ -34,6 +34,9 @@
import org.uberfire.workbench.events.NotificationEvent;

import com.github.gwtbootstrap.client.ui.Label;
import com.github.gwtbootstrap.client.ui.NavLink;
import com.github.gwtbootstrap.client.ui.SimplePager;
import com.github.gwtbootstrap.client.ui.SplitDropdownButton;
import com.github.gwtbootstrap.client.ui.constants.IconType;
import com.github.gwtbootstrap.client.ui.resources.ButtonSize;
import com.google.gwt.cell.client.ActionCell;
Expand Down Expand Up @@ -104,7 +107,7 @@ public void init(final RequestListPresenter presenter ) {
super.init(presenter, new GridGlobalPreferences("RequestListGrid", initColumns, bannedColumns));

initFiltersBar();

this.initActionsDropDown();
listGrid.setEmptyTableCaption(constants.No_Jobs_Found());
initSelectionModel();
initNoActionColumnManager();
Expand Down Expand Up @@ -353,6 +356,31 @@ public DefaultSelectionEventManager.SelectAction translateSelectionEvent(CellPre

}

private void initActionsDropDown() {
SplitDropdownButton actions = new SplitDropdownButton();
actions.setText(constants.Actions());
NavLink newJobNavLink = new NavLink(constants.New_Job());
newJobNavLink.setIcon(IconType.PLUS_SIGN);
newJobNavLink.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
placeManager.goTo( new DefaultPlaceRequest( "Quick New Job" ) );
}
});

NavLink settingsNavLink = new NavLink(constants.Settings());
settingsNavLink.setIcon(IconType.COG);
settingsNavLink.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
placeManager.goTo( new DefaultPlaceRequest( "Job Service Settings" ) );
}
});

actions.add(newJobNavLink);
actions.add(settingsNavLink);
listGrid.getLeftToolbar().add(actions);
}

private void initChecksColumn() {
// Checkbox column. This table will uses a checkbox column for selection.
Expand Down
Expand Up @@ -16,13 +16,16 @@

package org.jbpm.console.ng.es.client.editors.servicesettings;

import com.github.gwtbootstrap.client.ui.Button;
import com.google.gwt.core.shared.GWT;
import javax.annotation.PostConstruct;
import javax.enterprise.context.Dependent;
import javax.inject.Inject;

import com.google.gwt.user.client.ui.Focusable;
import org.jboss.errai.common.client.api.Caller;
import org.jboss.errai.common.client.api.RemoteCallback;
import org.jbpm.console.ng.es.client.i18n.Constants;
import org.jbpm.console.ng.es.service.ExecutorServiceEntryPoint;
import org.uberfire.client.annotations.WorkbenchPartTitle;
import org.uberfire.client.annotations.WorkbenchPartView;
Expand Down Expand Up @@ -50,6 +53,8 @@ public interface JobServiceSettingsView extends UberView<JobServiceSettingsPrese
void setStartedLabel( Boolean started );

void alert( String message );

Button getStartStopButton();
}

@Inject
Expand All @@ -59,6 +64,8 @@ public interface JobServiceSettingsView extends UberView<JobServiceSettingsPrese
@Inject
private Caller<ExecutorServiceEntryPoint> executorServices;
private PlaceRequest place;

private Constants constants = GWT.create( Constants.class );

public JobServiceSettingsPresenter() {
}
Expand Down Expand Up @@ -91,24 +98,32 @@ public void callback( Integer threadPoolSize ) {
@Override
public void callback( Boolean started ) {
view.setStartedLabel( started );
if(started){
view.getStartStopButton().setText(constants.Stop());
}else{
view.getStartStopButton().setText(constants.Start());
}
}
} ).isActive();
}

public void initService( final Integer numberOfExecutors,
String frequency ) {
try {
Integer interval = fromFrequencyToInterval( frequency );
Integer frequency ) {


executorServices.call( new RemoteCallback<Boolean>() {
@Override
public void callback( Boolean serviceStatus ) {
view.displayNotification( serviceStatus ? "Service started" : "Service stopped" );
if(serviceStatus){
view.getStartStopButton().setText(constants.Stop());
}else{
view.getStartStopButton().setText(constants.Start());
}
placeManager.closePlace( place );
}
} ).startStopService( interval, numberOfExecutors );
} catch ( NumberFormatException e ) {
view.alert( "Invalid frequency expression: " + frequency );
}
} ).startStopService( frequency, numberOfExecutors );

}

@OnOpen
Expand All @@ -121,7 +136,7 @@ public void onStartup( final PlaceRequest place ) {
this.place = place;
}

private String fromIntervalToFrequency( Integer interval ) {
public String fromIntervalToFrequency( Integer interval ) {
int seconds = interval % 60;
int minutes = ( interval / 60 ) % 60;
int hours = ( interval / 3600 ) % 24;
Expand All @@ -142,7 +157,7 @@ private String fromIntervalToFrequency( Integer interval ) {
return frequencyText.toString();
}

private Integer fromFrequencyToInterval( String frequency ) throws NumberFormatException {
public Integer fromFrequencyToInterval( String frequency ) throws NumberFormatException {
String[] sections = frequency.split( " " );
int interval = 0;
for ( String section : sections ) {
Expand Down

This file was deleted.

0 comments on commit 5113be0

Please sign in to comment.