Example usage for com.google.gwt.user.cellview.client Column Column

List of usage examples for com.google.gwt.user.cellview.client Column Column

Introduction

In this page you can find the example usage for com.google.gwt.user.cellview.client Column Column.

Prototype

public Column(Cell<C> cell) 

Source Link

Document

Construct a new Column with a given Cell .

Usage

From source file:n3phele.client.view.CommandDetailView.java

License:Open Source License

public CommandDetailView(ImageResource icon, String heading, String runButtonText, String cancelButtonText) {
    super(new MenuItem(icon, heading, null));
    title = new FlexTable();
    title.setCellSpacing(8);/*from  w  w  w. j a  va 2s .co m*/
    title.setWidth("100%");
    commandName = new InlineHTML(commandDescriptionText);
    title.setWidget(0, 0, commandName);
    commandName.addStyleName(N3phele.n3pheleResource.css().commandDetailHeader());
    commandDescription = new InlineHTML(commandDescriptionText);
    commandDescription.addStyleName(N3phele.n3pheleResource.css().commandDetailText());
    title.setWidget(0, 1, commandDescription);
    commandVersion = new InlineHTML(commandVersionText);
    title.setWidget(1, 0, commandVersion);
    title.getCellFormatter().setStylePrimaryName(1, 0, N3phele.n3pheleResource.css().commandDetailText());
    title.getFlexCellFormatter().setRowSpan(0, 1, 2);

    this.add(title);

    /*
     * Setup parameters section of the view
     */

    parameters = new SectionPanel("Parameters");
    this.paramTable = createParameterTable();
    parameters.add(paramTable);
    this.add(parameters);

    /*
     * Setup input and output files sections of the view
     */

    nullRepoColumnIn = new Column<FileSpecification, FileSpecification>(createRepoRefCompositeCell(true)) {
        @Override
        public FileSpecification getValue(FileSpecification fs) {
            return fs;
        }
    };

    nullRepoColumnOut = new Column<FileSpecification, FileSpecification>(createRepoRefCompositeCell(false)) {
        @Override
        public FileSpecification getValue(FileSpecification fs) {
            return fs;
        }
    };

    inputs = new SectionPanel("Input Files");
    inputTable = createFileTable(inputRepoColumn = nullRepoColumnIn);
    inputs.add(inputTable);
    this.add(inputs);
    outputs = new SectionPanel("Output Files");
    outputTable = createFileTable(outputRepoColumn = nullRepoColumnOut);
    outputs.add(outputTable);
    this.add(outputs);

    clouds = new SectionPanel("Execute On");
    HorizontalPanel divider = new HorizontalPanel();
    divider.setWidth("100%");
    clouds.add(divider);
    gotExecutionSelection = new CellWidget<String>(
            new ValidInputIndicatorCell(N3phele.n3pheleResource.inputErrorIcon()),
            "+Execution target selection required");
    divider.add(gotExecutionSelection);
    divider.setCellVerticalAlignment(gotExecutionSelection, HorizontalPanel.ALIGN_MIDDLE);
    divider.setCellWidth(gotExecutionSelection, "20px");
    accountTable = createAccountTable();
    divider.add(accountTable);
    this.sendEmail = new CheckBox("Send you an email on completion");
    sendEmail.setWordWrap(true);
    divider.add(sendEmail);
    divider.setCellVerticalAlignment(sendEmail, HorizontalPanel.ALIGN_MIDDLE);
    divider.setCellHorizontalAlignment(sendEmail, HorizontalPanel.ALIGN_CENTER);
    divider.setCellWidth(sendEmail, "20%");
    this.add(clouds);

    buttons = new HorizontalPanel();
    buttons.setWidth("90%");
    buttons.setHorizontalAlignment(HorizontalPanel.ALIGN_RIGHT);
    Label jobLabel = new Label("with job name ");
    buttons.add(jobLabel);
    jobName = new TextBox();
    buttons.add(jobName);
    Label fill = new Label("");
    buttons.add(fill);
    buttons.setCellWidth(fill, "10%");

    run = new Button(runButtonText);
    run.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            doRun();
        }
    });
    run.setEnabled(false);
    buttons.add(run);
    errorsOnPage = new CellWidget<String>(new ValidInputIndicatorCell(N3phele.n3pheleResource.inputErrorIcon()),
            "+check for missing or invalid parameters marked with this icon");
    buttons.add(errorsOnPage);
    buttons.setCellWidth(errorsOnPage, "20px");

    cancel = new Button(cancelButtonText);
    cancel.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            doCancel();
        }
    });
    buttons.add(cancel);

    this.add(buttons);

}

From source file:n3phele.client.view.CommandDetailView.java

License:Open Source License

public CellTable<TypedParameter> createParameterTable() {
    final ProvidesKey<TypedParameter> KEY_PROVIDER = new ProvidesKey<TypedParameter>() {
        public Object getKey(TypedParameter item) {
            return item.getName();
        }//from  w  w  w . j ava  2s.  co m
    };
    final CellTable<TypedParameter> table;
    table = new CellTable<TypedParameter>(KEY_PROVIDER);
    table.setWidth("100%");
    table.setKeyboardSelectionPolicy(KeyboardSelectionPolicy.DISABLED);
    TextColumn<TypedParameter> descriptionColumn = new TextColumn<TypedParameter>() {
        @Override
        public String getValue(TypedParameter command) {
            String result = "";
            if (command != null)
                return command.getDescription();
            return result;
        }
    };
    table.addColumn(descriptionColumn);

    this.parameterTextInputCell = new DisappearingTextInputCell();
    this.parameterCheckboxCell = new DisappearingCheckBoxCell();
    final ValidInputIndicatorCell valid = new ValidInputIndicatorCell(N3phele.n3pheleResource.inputErrorIcon());

    HasCell<TypedParameter, ?> valueHasCell = new HasCell<TypedParameter, String>() {

        @Override
        public Cell<String> getCell() {
            return CommandDetailView.this.parameterTextInputCell;
        }

        @Override
        public FieldUpdater<TypedParameter, String> getFieldUpdater() {
            return new FieldUpdater<TypedParameter, String>() { // Needs to exist so that the cell level updater is invoked
                @Override
                public void update(int index, TypedParameter object, String value) {
                }

            };
        }

        @Override
        public String getValue(TypedParameter object) {
            if (object != null) {
                if (!object.getType().equalsIgnoreCase("boolean")) {
                    String result = object.getValue();
                    if (isNullOrBlank(result))
                        result = object.getDefaultValue();
                    if (result == null)
                        result = "";
                    return result;
                }
            }
            return null;
        }

    };
    HasCell<TypedParameter, ?> validHasCell = new HasCell<TypedParameter, String>() {

        @Override
        public Cell<String> getCell() {
            return valid;
        }

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

        @Override
        public String getValue(TypedParameter object) {
            String errTooltip;
            errTooltip = errorMessageMap().get(object.getType());
            if (checkParameterValue(object)) {
                return "-" + errTooltip;
            } else {
                return "+" + errTooltip;
            }
        }

    };

    HasCell<TypedParameter, ?> booleanHasCell = new HasCell<TypedParameter, Boolean>() {

        @Override
        public Cell<Boolean> getCell() {
            return parameterCheckboxCell;
        }

        @Override
        public FieldUpdater<TypedParameter, Boolean> getFieldUpdater() {
            return new FieldUpdater<TypedParameter, Boolean>() { // Needs to exist so that the cell level updater is invoked
                @Override
                public void update(int index, TypedParameter object, Boolean value) {
                }

            };
        }

        @Override
        public Boolean getValue(TypedParameter object) {
            if (object != null) {
                if (object.getType().equalsIgnoreCase("boolean")) {
                    String result = object.getValue();
                    if (isNullOrBlank(result))
                        result = object.getDefaultValue();
                    return Boolean.valueOf(result);
                }
            }
            return null;
        }

    };
    List<HasCell<TypedParameter, ?>> arg = new ArrayList<HasCell<TypedParameter, ?>>(2);
    arg.add(validHasCell);
    arg.add(valueHasCell);
    arg.add(booleanHasCell);

    Column<TypedParameter, TypedParameter> valueColumn = new Column<TypedParameter, TypedParameter>(
            new TypedPropertyComposite(arg)) {
        @Override
        public TypedParameter getValue(TypedParameter parameter) {
            return parameter;
        }
    };
    valueColumn.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_RIGHT);
    table.addColumn(valueColumn);
    table.setWidth("100%", true);
    table.setColumnWidth(valueColumn, "210px");
    valueColumn.setFieldUpdater(new FieldUpdater<TypedParameter, TypedParameter>() {
        public void update(int index, final TypedParameter object, final TypedParameter value) {
            GWT.runAsync(new RunAsyncCallback() {

                @Override
                public void onSuccess() {
                    updateRunButton(true);
                }

                @Override
                public void onFailure(Throwable reason) {
                    //
                }
            });

        }
    });
    return table;
}

From source file:n3phele.client.view.CommandDetailView.java

License:Open Source License

public CellTable<CloudProfile> createAccountTable(/*final SingleSelectionModel<ExtendedCloudProfile> selectionModel*/) {
    final SensitiveCheckBoxCell checkbox = new SensitiveCheckBoxCell(true, true);
    final ProvidesKey<CloudProfile> KEY_PROVIDER = new ProvidesKey<CloudProfile>() {

        public Object getKey(CloudProfile item) {
            return item.id();
        }//  w  ww  .j ava 2s .  c  om
    };
    final CellTable<CloudProfile> table = new CellTable<CloudProfile>(KEY_PROVIDER);
    table.setKeyboardSelectionPolicy(KeyboardSelectionPolicy.DISABLED);
    Column<CloudProfile, Boolean> checkColumn = new Column<CloudProfile, Boolean>(checkbox) {
        @Override
        public Boolean getValue(CloudProfile profile) {
            return (profile.getId().equals(CommandDetailView.this.selectedProfile))
                    && (profile.getAccountUri().equals(CommandDetailView.this.selectedAccountURI));
        }

    };
    checkColumn.setFieldUpdater(new FieldUpdater<CloudProfile, Boolean>() {

        @Override
        public void update(int index, CloudProfile profile, Boolean value) {
            if (profile != null) {
                if (value) {
                    CommandDetailView.this.selectedProfile = profile.getId();
                    CommandDetailView.this.selectedAccountURI = profile.getAccountUri();
                } else {
                    if (profile.getId().equals(CommandDetailView.this.selectedProfile)) {
                        CommandDetailView.this.selectedProfile = null;
                        CommandDetailView.this.selectedAccountURI = null;
                    }
                }
                table.redraw();
                String visible = value ? "-" : "+";
                CommandDetailView.this.gotExecutionSelection.setValue(
                        visible + CommandDetailView.this.gotExecutionSelection.getValue().substring(1));
                updateRunButton(true);
            } else {
                checkbox.clearViewData(KEY_PROVIDER.getKey(profile));
                table.redraw();
                updateRunButton(false);
                CommandDetailView.this.gotExecutionSelection
                        .setValue("+" + CommandDetailView.this.gotExecutionSelection.getValue().substring(1));
            }

        }

    });
    table.addColumn(checkColumn);
    TextColumn<CloudProfile> accountColumn = new TextColumn<CloudProfile>() {
        @Override
        public String getValue(CloudProfile profile) {
            String result = "";
            if (profile != null)
                return profile.getAccountName();
            return result;
        }
    };
    table.addColumn(accountColumn);
    TextColumn<CloudProfile> nameColumn = new TextColumn<CloudProfile>() {
        @Override
        public String getValue(CloudProfile profile) {
            String result = "";
            if (profile != null) {
                return profile.getCloudName();
            }
            return result;
        }
    };
    table.addColumn(nameColumn);
    TextColumn<CloudProfile> descriptionColumn = new TextColumn<CloudProfile>() {
        @Override
        public String getValue(CloudProfile profile) {
            if (profile != null)
                return profile.getDescription();
            else
                return null;
        }
    };
    table.addColumn(descriptionColumn);
    return table;
}

From source file:n3phele.client.view.CommandDetailView.java

License:Open Source License

protected Column<FileSpecification, FileSpecification> replaceSelectionRepoColumn(
        CellTable<FileSpecification> table, Column<FileSpecification, FileSpecification> repoColumn,
        boolean isInput) {
    Column<FileSpecification, FileSpecification> newColumn = new Column<FileSpecification, FileSpecification>(
            createRepoRefCompositeCell(isInput)) {
        @Override//w ww.j ava  2s .  c o m
        public FileSpecification getValue(FileSpecification fs) {
            return fs;
        }
    };
    return replaceSelectionRepoColumn(table, newColumn, repoColumn);
}

From source file:n3phele.client.view.CommandListGridView.java

License:Open Source License

public CommandListGridView() {
    super(new MenuItem(N3phele.n3pheleResource.commandIcon(), "Commands", null));
    String html = "<img style='border:none; vertical-align:bottom; margin:-2px; padding-right:2px;' width=20 height=20 src='"
            + N3phele.n3pheleResource.commandIcon().getURL() + "'/>create a new command";
    Button addDataSet = new Button(html, new ClickHandler() {

        @Override/*from  w ww .  j ava2 s.  co m*/
        public void onClick(ClickEvent event) {
            createUploadPopup();
        }
    });
    addDataSet.setStyleName(N3phele.n3pheleResource.css().newCommandButton());
    this.strip.add(addDataSet);
    HorizontalPanel heading = new HorizontalPanel();
    heading.setWidth("500px");
    heading.setStyleName(N3phele.n3pheleResource.css().sectionPanelHeader());
    add(heading);
    SimplePager.Resources pagerResources = GWT.create(SimplePager.Resources.class);
    simplePager = new SimplePager(TextLocation.CENTER, pagerResources, false, 0, true);
    heading.add(simplePager);

    textBox = new TextBox();
    textBox.setTitle("search for a command");
    heading.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
    heading.add(textBox);
    heading.setCellHorizontalAlignment(textBox, HorizontalPanel.ALIGN_RIGHT);
    textBox.addKeyPressHandler(new KeyPressHandler() {
        public void onKeyPress(KeyPressEvent event) {
            if (KeyCodes.KEY_ENTER == event.getNativeEvent().getKeyCode()) {
                commandActivity.fetch(0, searchText = textBox.getText(), !allVersions.getValue());
            }
        }
    });

    Image searchIcon = new Image(N3phele.n3pheleResource.searchIcon().getURL());
    searchIcon.setPixelSize(20, 20);
    PushButton search = new PushButton(searchIcon);
    search.setTitle("search for a command");
    search.setStyleName(N3phele.n3pheleResource.css().commandSearchButton());
    heading.add(search);
    search.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
            commandActivity.fetch(0, searchText = textBox.getText(), !allVersions.getValue());

        }
    });

    heading.setCellHorizontalAlignment(simplePager, HorizontalPanel.ALIGN_CENTER);
    DisclosurePanel more = new DisclosurePanel("advanced");
    more.setStyleName(N3phele.n3pheleResource.css().sectionPanelHeader());
    heading.add(more);
    heading.setCellHorizontalAlignment(more, HorizontalPanel.ALIGN_LEFT);
    HorizontalPanel disclosed = new HorizontalPanel();
    more.add(disclosed);
    disclosed.add(new InlineLabel("Search all versions"));

    allVersions = new SimpleCheckBox();
    allVersions.setName("allVersions");
    allVersions.setFormValue("Search all versions");
    disclosed.add(allVersions);

    grid = new CellTable<List<Command>>();
    grid.setWidth("100%", true);
    HasCell<Command, ?> nameHasCell = new HasCell<Command, Command>() {

        @Override
        public Cell<Command> getCell() {
            return new CommandTextCell(CommandNameRenderer.getInstance());
        }

        @Override
        public FieldUpdater<Command, Command> getFieldUpdater() {
            return new FieldUpdater<Command, Command>() {

                @Override
                public void update(int index, Command object, Command value) {
                    //                  if(value != null) {
                    //                     GWT.log("got-139 "+index+" "+value.getName());
                    //                     commandActivity.goTo(new CommandPlace(value.getUri()));
                    //                  }

                }
            };
        }

        @Override
        public Command getValue(Command object) {
            return object;
        }

    };
    HasCell<Command, ?> versionHasCell = new HasCell<Command, Command>() {

        @Override
        public Cell<Command> getCell() {
            return new CommandTextCell(CommandVersionRenderer.getInstance());
        }

        @Override
        public FieldUpdater<Command, Command> getFieldUpdater() {
            return new FieldUpdater<Command, Command>() {

                @Override
                public void update(int index, Command object, Command value) {
                    //                  if(value != null) {
                    //                     GWT.log("got-166 "+index+" "+value.getName());
                    //                     commandActivity.goTo(new CommandPlace(value.getUri()));
                    //                  }

                }
            };
        }

        @Override
        public Command getValue(Command object) {
            return object;
        }

    };

    List<HasCell<Command, ?>> hasCells = new ArrayList<HasCell<Command, ?>>(2);
    hasCells.add(nameHasCell);
    hasCells.add(versionHasCell);
    for (int i = 0; i < ROWLENGTH; i++) {
        Column<List<Command>, Command> c = new Column<List<Command>, Command>(new CommandIconTextCell(
                N3phele.n3pheleResource.scriptIcon(), new CompositeCell<Command>(hasCells), i)) {

            @Override
            public Command getValue(List<Command> object) {
                int index = ((CommandIconTextCell) this.getCell()).getIndex();
                if (index < object.size()) {
                    return object.get(index);
                } else {
                    return null;
                }
            }
        };
        c.setFieldUpdater(new FieldUpdater<List<Command>, Command>() {

            @Override
            public void update(int index, List<Command> object, Command value) {
                if (value != null) {
                    GWT.log("got-201 " + index + " " + value.getName());
                    commandActivity.goTo(new CommandPlace(value.getUri()));
                }

            }
        });
        grid.addColumn(c);
        grid.setColumnWidth(c, 100.0 / ROWLENGTH, Unit.PCT);
    }

    grid.setKeyboardSelectionPolicy(KeyboardSelectionPolicy.DISABLED);
    simplePager.setDisplay(grid);
    simplePager.setPageSize(PAGESIZE);
    grid.addRangeChangeHandler(new RangeChangeEvent.Handler() {

        /* (non-Javadoc)
         * @see com.google.gwt.view.client.RangeChangeEvent.Handler#onRangeChange(com.google.gwt.view.client.RangeChangeEvent)
         */
        @Override
        public void onRangeChange(RangeChangeEvent event) {
            if (suppressEvent)
                return;
            Range range = grid.getVisibleRange();
            GWT.log("Table range is " + range.getStart() + " length " + range.getLength());
            int start = range.getStart();
            if (start > total)
                start = total;
            //            if(data == null || (data.size() < start) ){

            commandActivity.fetch(start, searchText, !allVersions.getValue());
            //            } else {
            //               if(length+start > data.size())
            //                  length = data.size()-start;
            //               GWT.log("data available start="+start);
            //               grid.setRowData(start, chunk(data.subList(start, start+length)));
            //            }
        }

    });
    this.add(grid);
}

From source file:n3phele.client.view.CommandListView.java

License:Open Source License

public CommandListView() {
    super(new MenuItem(N3phele.n3pheleResource.commandIcon(), "Commands", null));
    cellTable = new CellTable<Command>();
    cellTable.setSize("455px", "");

    //      TextColumn<Command> nameColumn = new TextColumn<Command>() {
    //         @Override
    //         public String getValue(Command command) {
    //            String result = "";
    //            if(command != null)
    //               return command.getName();
    //            return result;
    //         }/*from w  w  w . ja va  2s  .c  o  m*/
    //      };
    //      cellTable.addColumn(nameColumn, "Name");

    Column<Command, Hyperlink> nameColumn = new Column<Command, Hyperlink>(new HyperlinkCell()) {

        @Override
        public Hyperlink getValue(Command command) {
            if (command == null)
                return null;
            String name = command.getName();
            String historyToken = commandActivity.getToken(command);
            return new Hyperlink(name, historyToken);
        }

    };

    nameColumn.setFieldUpdater(new FieldUpdater<Command, Hyperlink>() {
        @Override
        public void update(int index, Command object, Hyperlink value) {
            CommandListView.this.commandActivity.goTo(new CommandPlace(object.getUri()));
        }
    });
    cellTable.addColumn(nameColumn, "Name");

    TextColumn<Command> descriptionColumn = new TextColumn<Command>() {
        @Override
        public String getValue(Command command) {
            String result = "";
            if (command != null)
                return command.getDescription();
            return result;
        }
    };
    cellTable.addColumn(descriptionColumn, "Description");
    //       // Add a selection model to handle user selection.
    //       final SingleSelectionModel<Command> selectionModel = new SingleSelectionModel<Command>();
    //       cellTable.setSelectionModel(selectionModel);
    //       selectionModel.addSelectionChangeHandler(new SelectionChangeEvent.Handler() {
    //         public void onSelectionChange(SelectionChangeEvent event) {
    //           Command selected = selectionModel.getSelectedObject();
    //           if (selected != null) {
    //             if(commandActivity != null) {
    //               commandActivity.onSelect(selected);
    //             }
    //           }
    //         }
    //       });

    cellTable.setKeyboardSelectionPolicy(KeyboardSelectionPolicy.DISABLED);
    this.add(cellTable);

}

From source file:n3phele.client.view.CreateServiceView.java

License:Open Source License

public CellTable<CommandCloudAccount> createAccountTable() {
    final SensitiveCheckBoxCell checkbox = new SensitiveCheckBoxCell(true, true);
    final ProvidesKey<CommandCloudAccount> KEY_PROVIDER = new ProvidesKey<CommandCloudAccount>() {

        public Object getKey(CommandCloudAccount item) {
            return item.getAccountUri();
        }/*from  ww  w  .j av  a 2s .c  o m*/
    };
    final CellTable<CommandCloudAccount> table = new CellTable<CommandCloudAccount>(KEY_PROVIDER);
    table.setKeyboardSelectionPolicy(KeyboardSelectionPolicy.DISABLED);
    Column<CommandCloudAccount, Boolean> checkColumn = new Column<CommandCloudAccount, Boolean>(checkbox) {
        @Override
        public Boolean getValue(CommandCloudAccount profile) {
            return (profile.getAccountUri().equals(CreateServiceView.this.selectedAccountURI));
        }

    };
    checkColumn.setFieldUpdater(new FieldUpdater<CommandCloudAccount, Boolean>() {

        @Override
        public void update(int index, CommandCloudAccount profile, Boolean value) {
            if (profile != null) {
                if (value) {
                    CreateServiceView.this.selectedImplementation = profile.getImplementation();
                    CreateServiceView.this.selectedAccountURI = profile.getAccountUri().toString();
                } else {
                    if (profile.getImplementation().equals(CreateServiceView.this.selectedImplementation)) {

                        CreateServiceView.this.selectedImplementation = null;
                        CreateServiceView.this.selectedAccountURI = null;
                    }
                }
                table.redraw();
                String visible = value ? "-" : "+";
                CreateServiceView.this.gotExecutionSelection.setValue(
                        visible + CreateServiceView.this.gotExecutionSelection.getValue().substring(1));
                updateRunButton(true);
                validateAccount(true);
            } else {
                checkbox.clearViewData(KEY_PROVIDER.getKey(profile));
                table.redraw();
                updateRunButton(false);
                validateAccount(false);
                GWT.log("update account");
                CreateServiceView.this.gotExecutionSelection
                        .setValue("+" + CreateServiceView.this.gotExecutionSelection.getValue().substring(1));
            }

        }

    });
    table.addColumn(checkColumn);
    table.setColumnWidth(checkColumn, "40px");
    TextColumn<CommandCloudAccount> accountColumn = new TextColumn<CommandCloudAccount>() {
        @Override
        public String getValue(CommandCloudAccount profile) {
            String result = "";
            if (profile != null)
                return profile.getAccountName();
            return result;
        }
    };
    table.addColumn(accountColumn);
    TextColumn<CommandCloudAccount> nameColumn = new TextColumn<CommandCloudAccount>() {
        @Override
        public String getValue(CommandCloudAccount profile) {
            String result = "";
            if (profile != null) {
                return profile.getImplementation();
            }
            return result;
        }
    };
    table.addColumn(nameColumn);
    table.setWidth("400px");
    table.addStyleName(N3phele.n3pheleResource.css().lineBreakStyle());
    table.setTableLayoutFixed(true);
    return table;
}

From source file:n3phele.client.view.ProcessView.java

License:Open Source License

public ProcessView() {
    super(new MenuItem(N3phele.n3pheleResource.activityIcon(), "Activity", null));
    table = new FlexTable();
    table.setCellPadding(2);/*from   w w w .j ava2 s  . c  o m*/

    this.add(table);
    table.setWidth("100%");

    Label lblNewLabel_4 = new Label("name");
    table.setWidget(0, 0, lblNewLabel_4);

    name = new Label("");
    table.setWidget(0, 1, name);

    iconStatus = new CellWidget<IconText>(new IconTextCell<IconText>(32, 32, 15));
    table.setWidget(0, 2, iconStatus);
    table.getColumnFormatter().setWidth(0, "60px");
    table.getColumnFormatter().setWidth(2, "170px");

    Label lblNewLabel = new Label("running");
    table.setWidget(1, 0, lblNewLabel);

    command = new Hyperlink("", "");
    table.setWidget(1, 1, command);
    table.getFlexCellFormatter().setColSpan(1, 1, 2);

    //      description = new Label("-description-");
    //      table.setWidget(1, 2, description);

    Label lblNewLabel_3 = new Label("started");
    table.setWidget(2, 0, lblNewLabel_3);

    startdate = new CellWidget<Date>(
            new DateCell(DateTimeFormat.getFormat(DateTimeFormat.PredefinedFormat.DATE_TIME_SHORT)));

    table.setWidget(2, 1, startdate);
    //table.getFlexCellFormatter().setColSpan(2, 1, 2);

    Label lblNewLabel_6 = new Label("completed");
    table.setWidget(3, 0, lblNewLabel_6);

    completedate = new CellWidget<Date>(
            new DateCell(DateTimeFormat.getFormat(DateTimeFormat.PredefinedFormat.DATE_TIME_SHORT)));
    table.setWidget(3, 1, completedate);
    //table.getFlexCellFormatter().setColSpan(3, 1, 2);

    duration = new Label(".duration");
    table.setWidget(3, 2, duration);

    if (resource == null)
        resource = GWT.create(NarrativeListCellTableResource.class);
    narrativeTable = new CellTable<Narrative>(15, resource);
    this.add(narrativeTable);
    narrativeTable.setWidth("100%", true);

    final Map<String, ImageResource> mapper = new HashMap<String, ImageResource>();
    mapper.put("info", N3phele.n3pheleResource.narrativeInfo());
    mapper.put("warning", N3phele.n3pheleResource.narrativeWarning());
    mapper.put("error", N3phele.n3pheleResource.narrativeError());
    state = new Column<Narrative, ImageResource>(new ImageResourceCell()) {
        @Override
        public ImageResource getValue(Narrative object) {
            return mapper.get(object.getState());
        }
    };
    state.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
    state.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
    narrativeTable.addColumn(state);
    narrativeTable.setColumnWidth(state, "8%");

    Column<Narrative, Date> date = new Column<Narrative, Date>(
            new DateCell(DateTimeFormat.getFormat(DateTimeFormat.PredefinedFormat.DATE_TIME_SHORT))) {
        @Override
        public Date getValue(Narrative object) {
            return object.getStamp();
        }
    };
    narrativeTable.addColumn(date);
    narrativeTable.setColumnWidth(date, "15%");

    Column<Narrative, Hyperlink> id = new Column<Narrative, Hyperlink>(new HyperlinkCell()) {

        @Override
        public Hyperlink getValue(Narrative object) {
            if (object == null)
                return null;
            String name = object.getTag();
            String historyToken = presenter.getToken(object.getProcessUri());
            return new Hyperlink(name, historyToken);
        }

    };
    id.setFieldUpdater(new FieldUpdater<Narrative, Hyperlink>() {
        @Override
        public void update(int index, Narrative object, Hyperlink value) {
            ProcessView.this.narrativeTable.setFocus(false);
        }
    });
    id.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
    id.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_LEFT);

    narrativeTable.addColumn(id);
    narrativeTable.setColumnWidth(id, "20%");

    TextColumn<Narrative> msg = new TextColumn<Narrative>() {
        @Override
        public String getValue(Narrative object) {
            return object.getText();
        }
    };
    msg.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
    msg.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_LEFT);

    narrativeTable.addColumn(msg);
    narrativeTable.setColumnWidth(msg, "60%");
}

From source file:n3phele.client.view.ProgressView.java

License:Open Source License

public ProgressView() {
    super(new MenuItem(N3phele.n3pheleResource.activityIcon(), "Activity", null));
    table = new FlexTable();
    table.setCellPadding(2);//from www  .j a  v  a2s .c  om

    this.add(table);
    //table.setSize("478px", "260px");

    Label lblNewLabel_4 = new Label("name");
    table.setWidget(0, 0, lblNewLabel_4);

    name = new Label("");
    table.setWidget(0, 1, name);

    iconStatus = new CellWidget<IconText>(new IconTextCell<IconText>(32, 32, 15));
    //      {
    //         @Override
    //         public IconText getValue(Progress progress) {
    //            String status = progress.getStatus();
    //            ImageResource icon = statusVizualization.get(status);
    //            if(icon != null) return new IconText(icon, progress.getName());
    //            return new IconText(getTemplate().statusBar(getPercentComplete(progress), barUrl ), progress.getName()); // make progress bar
    //         }
    //      };

    table.setWidget(0, 2, iconStatus);

    Label lblNewLabel = new Label("running");
    table.setWidget(1, 0, lblNewLabel);

    command = new Hyperlink("", "");
    table.setWidget(1, 1, command);

    description = new Label("-description-");
    table.setWidget(1, 2, description);

    Label lblNewLabel_3 = new Label("started");
    table.setWidget(2, 0, lblNewLabel_3);

    startdate = new CellWidget<Date>(
            new DateCell(DateTimeFormat.getFormat(DateTimeFormat.PredefinedFormat.DATE_TIME_SHORT)));

    table.setWidget(2, 1, startdate);
    table.getFlexCellFormatter().setColSpan(2, 1, 2);

    Label lblNewLabel_6 = new Label("completed");
    table.setWidget(3, 0, lblNewLabel_6);

    completedate = new CellWidget<Date>(
            new DateCell(DateTimeFormat.getFormat(DateTimeFormat.PredefinedFormat.DATE_TIME_SHORT)));
    table.setWidget(3, 1, completedate);
    table.getFlexCellFormatter().setColSpan(3, 1, 2);

    Label lblNewLabel_7 = new Label("estimated duration", true);
    table.setWidget(4, 0, lblNewLabel_7);

    duration = new Label(".duration");
    table.setWidget(4, 1, duration);
    table.getFlexCellFormatter().setColSpan(4, 1, 2);
    if (resource == null)
        resource = GWT.create(NarrativeListCellTableResource.class);
    narrativeTable = new CellTable<Narrative>(15, resource);
    this.add(narrativeTable);
    narrativeTable.setWidth("100%", true);

    final Map<String, ImageResource> mapper = new HashMap<String, ImageResource>();
    mapper.put("info", N3phele.n3pheleResource.narrativeInfo());
    mapper.put("warning", N3phele.n3pheleResource.narrativeWarning());
    mapper.put("error", N3phele.n3pheleResource.narrativeError());
    state = new Column<Narrative, ImageResource>(new ImageResourceCell()) {
        @Override
        public ImageResource getValue(Narrative object) {
            return mapper.get(object.getState());
        }
    };
    state.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
    state.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
    narrativeTable.addColumn(state);
    narrativeTable.setColumnWidth(state, "8%");

    Column<Narrative, Date> date = new Column<Narrative, Date>(
            new DateCell(DateTimeFormat.getFormat(DateTimeFormat.PredefinedFormat.DATE_TIME_SHORT))) {
        @Override
        public Date getValue(Narrative object) {
            return object.getStamp();
        }
    };
    narrativeTable.addColumn(date);
    narrativeTable.setColumnWidth(date, "15%");

    TextColumn<Narrative> id = new TextColumn<Narrative>() {
        @Override
        public String getValue(Narrative object) {
            return object.getId();
        }
    };
    id.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
    id.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_LEFT);

    narrativeTable.addColumn(id);
    narrativeTable.setColumnWidth(id, "20%");

    TextColumn<Narrative> msg = new TextColumn<Narrative>() {
        @Override
        public String getValue(Narrative object) {
            return object.getText();
        }
    };
    msg.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
    msg.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_LEFT);

    narrativeTable.addColumn(msg);
    narrativeTable.setColumnWidth(msg, "60%");
}

From source file:n3phele.client.view.RepoContentView.java

License:Open Source License

protected Widget createDatasetTable() {
    grid = new CellTable<List<FileNode>>();
    grid.setWidth("100%");
    grid.setTableLayoutFixed(true);//from  ww w  . j  a va2s. c o m

    for (int i = 0; i < ROWLENGTH; i++) {

        Column<List<FileNode>, FileNode> icon = new Column<List<FileNode>, FileNode>(new FileNodeIconCell(i)) {
            @Override
            public FileNode getValue(List<FileNode> object) {
                int index = ((FileNodeIconCell) this.getCell()).getIndex();
                if (index < object.size()) {
                    FileNode value = object.get(index);
                    return value;
                } else {
                    return null;
                }
            }
        };
        icon.setFieldUpdater(new FieldUpdater<List<FileNode>, FileNode>() {

            @Override
            public void update(int index, List<FileNode> object, FileNode value) {
                if (value != null) {
                    String type = value.getMime();
                    PopupPanel popup;
                    if (!type.endsWith("Folder") && !type.endsWith("Placeholder")) {
                        GWT.log("got filename on row " + index + " " + value.toFormattedString());
                        popup = createFileDetailsPopup(value);
                    } else {
                        GWT.log("got folder on row " + index + " " + value.toFormattedString());
                        popup = createFileDetailsPopup(value);
                    }
                    if (popup != null) {
                        int column = 0;
                        for (int i = 0; i < ROWLENGTH && i < object.size(); i++) {
                            FileNode n = object.get(i);
                            if (n.getName() != null && n.getName().equals(value.getName())) {
                                column = i;
                                GWT.log("Found at " + column);
                                break;
                            }
                        }

                        popup.showRelativeTo(new ElementWrapper(grid.getRowElement(index).getChild(column * 2)
                                .getFirstChild().getParentElement().getFirstChildElement()));
                        popup.addAutoHidePartner(grid.getRowElement(index).getChild(column * 2).getFirstChild()
                                .getParentElement());
                    }
                }
            }
        });

        Column<List<FileNode>, FileNode> text = new Column<List<FileNode>, FileNode>(new FileNodeTextCell(i)) {
            @Override
            public FileNode getValue(List<FileNode> object) {
                int index = ((FileNodeTextCell) this.getCell()).getIndex();
                if (index < object.size()) {
                    FileNode value = object.get(index);
                    return value;
                } else {
                    return null;
                }
            }
        };
        text.setFieldUpdater(new FieldUpdater<List<FileNode>, FileNode>() {

            @Override
            public void update(int index, List<FileNode> object, FileNode value) {
                if (value != null) {
                    if (isFile(value)) {
                        GWT.log("got filename on row " + index + " " + value.toFormattedString());
                    } else {
                        GWT.log("got folder on row " + index + " " + value.toFormattedString());
                        RepoContentView.this.presenter.selectFolder(value);
                    }
                }
            }
        });

        grid.addColumn(icon);
        grid.setColumnWidth(icon, 50, Unit.PX);
        grid.addColumn(text);
        text.setCellStyleNames(N3phele.n3pheleResource.css().repoTextCell());
        grid.setColumnWidth(text, (100.0 / ROWLENGTH), Unit.PCT);

    }
    grid.setKeyboardSelectionPolicy(KeyboardSelectionPolicy.DISABLED);
    emptyTable = grid.getEmptyTableWidget();
    return grid;
}