Example usage for com.google.gwt.safehtml.shared SafeHtmlUtils fromString

List of usage examples for com.google.gwt.safehtml.shared SafeHtmlUtils fromString

Introduction

In this page you can find the example usage for com.google.gwt.safehtml.shared SafeHtmlUtils fromString.

Prototype

public static SafeHtml fromString(String s) 

Source Link

Document

Returns a SafeHtml containing the escaped string.

Usage

From source file:org.jboss.hal.client.runtime.managementoperations.ManagementOperationsPresenter.java

License:Apache License

void cancelNonProgressingOperation() {
    if (environment.isStandalone()) {
        ResourceAddress address = MANAGEMENT_OPERATIONS_TEMPLATE.resolve(statementContext);
        Operation operation = new Operation.Builder(address, CANCEL_NON_PROGRESSING_OPERATION).build();
        dispatcher.execute(operation, result -> {
            MessageEvent.fire(eventBus,//w ww .  jav a  2 s  .  c  o  m
                    Message.info(resources.messages().cancelledOperation(result.asString())));
            reload();
        }, (operation1, failure) -> {
            // the cancel-non-progressing-operation returns an exception message if there are no
            // operation to cancel, handle this a non error in HAL
            if (failure.contains(WFLYDM_0089)) {
                MessageEvent.fire(eventBus, Message.success(SafeHtmlUtils.fromString(failure)));
            } else {
                MessageEvent.fire(eventBus, Message.error(SafeHtmlUtils.fromString(failure)));
            }
            reload();
        }, (operation1, ex) -> {
            // the cancel-non-progressing-operation returns an exception message if there are no
            // operation to cancel, handle this a non error in HAL
            if (ex.getMessage().contains(WFLYDM_0089)) {
                MessageEvent.fire(eventBus, Message.success(SafeHtmlUtils.fromString(ex.getMessage())));
            } else {
                MessageEvent.fire(eventBus, Message.error(SafeHtmlUtils.fromString(ex.getMessage())));
            }
            reload();
        });
    } else {
        Composite composite = new Composite();
        // return running hosts, to later call a cancel-non-progressing-operation on each host
        ResourceAddress rootAddress = new ResourceAddress();
        Operation opHosts = new Operation.Builder(rootAddress, READ_CHILDREN_NAMES_OPERATION)
                .param(CHILD_TYPE, HOST).build();
        composite.add(opHosts);

        ResourceAddress address = new ResourceAddress().add(HOST, WILDCARD).add(SERVER, WILDCARD);
        Operation opRunningServers = new Operation.Builder(address, QUERY)
                .param(SELECT, new ModelNode().add(HOST).add(NAME))
                .param(WHERE, new ModelNode().set(SERVER_STATE, "running")).build();
        composite.add(opRunningServers);

        dispatcher.execute(composite, (CompositeResult compositeResult) -> {

            // available hosts
            List<String> hosts = compositeResult.step(0).get(RESULT).asList().stream().map(ModelNode::asString)
                    .collect(toList());

            // runing servers
            List<String> servers = Collections.emptyList();
            ModelNode result = compositeResult.step(1);
            if (result != null && result.isDefined()) {
                servers = result.get(RESULT).asList().stream().map(r -> hostServerAddress(r.get(RESULT)))
                        .collect(toList());
            }

            // run each :cancel-non-progressing-operation on a specific task
            // because the :cancel-non-progressing-operation returns as a failure
            // for this case, continue to run the next task
            List<Task<FlowContext>> tasks = new ArrayList<>(hosts.size());
            for (String host : hosts) {
                // call cancel-non-progressing-operation on each host
                Task<FlowContext> task = context -> {
                    ResourceAddress hostAddress = new ResourceAddress().add(HOST, host)
                            .add(CORE_SERVICE, MANAGEMENT).add(SERVICE, MANAGEMENT_OPERATIONS);
                    return buildCancelOperation(hostAddress, context);
                };
                tasks.add(task);
            }

            for (String server : servers) {
                // call cancel-non-progressing-operation on each server
                Task<FlowContext> task = context -> {
                    ResourceAddress serverAddress = AddressTemplate.of(server)
                            .append(MANAGEMENT_OPERATIONS_TEMPLATE).resolve(statementContext);
                    return buildCancelOperation(serverAddress, context);
                };
                tasks.add(task);
            }

            series(new FlowContext(progress.get()), tasks).subscribe(new Outcome<FlowContext>() {
                @Override
                public void onError(FlowContext context, Throwable error) {
                    MessageEvent.fire(getEventBus(), Message.error(SafeHtmlUtils
                            .fromString("Error loading management operations: " + error.getMessage())));
                }

                @Override
                public void onSuccess(FlowContext context) {
                    if (context.emptyStack()) {
                        // display the standard message if there is no cancelled operation
                        MessageEvent.fire(eventBus,
                                Message.success(SafeHtmlUtils.fromString(context.get(WFLYDM_0089))));
                    } else {
                        // display the cancelled non progressing operation ids
                        List<String> canceledOps = new ArrayList<>();
                        while (!context.emptyStack()) {
                            canceledOps.add(context.pop());
                        }
                        String ids = Joiner.on(", ").join(canceledOps);
                        MessageEvent.fire(eventBus,
                                Message.success(resources.messages().cancelledOperation(ids)));
                    }
                    reload();
                }
            });
        });
    }
}

From source file:org.jboss.hal.client.runtime.subsystem.elytron.StoresPresenter.java

License:Apache License

void setSecret(Metadata metadata, String name, String alias) {
    AddressTemplate template = metadata.getTemplate();
    String resource = Names.CREDENTIAL_STORE + SPACE + name;
    Metadata opMetadata = metadata.forOperation(SET_SECRET);
    SafeHtml question = SafeHtmlUtils.fromString(opMetadata.getDescription().getDescription());
    Form<ModelNode> form = new ModelNodeForm.Builder<>(Ids.build(template.lastName(), SET_SECRET), opMetadata)
            .build();/*from  w  w w .  jav  a  2 s  . c o  m*/
    form.attach();
    HTMLElement formElement = form.element();
    ModelNode model = new ModelNode();
    model.get(ALIAS).set(alias);
    form.getFormItem(ALIAS).setEnabled(false);
    form.edit(model);
    DialogFactory.buildConfirmation(resources.constants().setSecret(), question, formElement,
            Dialog.Size.MEDIUM, () -> {
                ResourceAddress address = template.resolve(statementContext, name);
                Operation addOp = new Operation.Builder(address, REMOVE_ALIAS).param(ALIAS, alias).build();
                dispatcher.execute(addOp,
                        result -> MessageEvent.fire(getEventBus(),
                                Message.success(
                                        resources.messages().setSecretPasswordSuccess(alias, resource))),
                        (operation, failure) -> MessageEvent.fire(getEventBus(),
                                Message.error(
                                        resources.messages().setSecretPasswordError(alias, resource, failure))),
                        (operation, ex) -> MessageEvent.fire(getEventBus(), Message.error(resources.messages()
                                .setSecretPasswordError(alias, resource, ex.getMessage()))));

            }).show();
}

From source file:org.jboss.hal.client.skeleton.ToastNotificationDialog.java

License:Apache License

ToastNotificationDialog(Message message) {
    String[] cssIcon = ToastNotificationElement.cssIcon(message.getLevel());
    ElementsBuilder builder = collect();

    // header/*  w  w w.  ja va2s .c  o m*/
    builder.add(div().css(alert, cssIcon[0]).add(span().css(pfIcon(cssIcon[1])))
            .add(span().innerHtml(message.getMessage())));

    // details
    String header = message.getDetails() != null ? CONSTANTS.details() : CONSTANTS.noDetails();
    builder.add(p().css(messageDetails).add(span().textContent(header))
            .add(span().css(pullRight, timestamp).textContent(message.getTimestamp())));
    if (message.getDetails() != null) {
        builder.add(pre().css(messageDetailsPre).innerHtml(SafeHtmlUtils.fromString(message.getDetails())));
    }

    dialog = new Dialog.Builder(CONSTANTS.message()).closeOnly().add(builder.get()).build();
}

From source file:org.jboss.hal.core.modelbrowser.ReadChildren.java

License:Apache License

@Override
@SuppressWarnings("unchecked")
public void load(final Node<Context> node, final ResultCallback<Context> callback) {
    if (node.data.isFullyQualified()) {
        Operation operation = new Operation.Builder(node.data.getAddress(), READ_CHILDREN_TYPES_OPERATION)
                .param(INCLUDE_SINGLETONS, true).build();
        dispatcher.execute(operation, result -> {
            List<ModelNode> modelNodes = result.asList();
            Multimap<String, String> resources = HashMultimap.create();
            for (ModelNode modelNode : modelNodes) {
                String name = modelNode.asString();
                if (name.contains("=")) {
                    List<String> parts = Splitter.on('=').limit(2).splitToList(name);
                    resources.put(parts.get(0), parts.get(1));
                } else {
                    resources.put(name, NO_SINGLETON);
                }//ww w. ja  v  a  2  s  .  c o  m
            }

            List<Node<Context>> children = new ArrayList<>();
            for (Map.Entry<String, Collection<String>> entry : resources.asMap().entrySet()) {
                String name = entry.getKey();
                Set<String> singletons = new HashSet<>(entry.getValue());
                if (singletons.size() == 1 && singletons.contains(NO_SINGLETON)) {
                    singletons = Collections.emptySet();
                }
                ResourceAddress address = new ResourceAddress(node.data.getAddress()).add(name, "*");
                Context context = new Context(address, singletons);
                // ids need to be unique!
                Node.Builder<Context> builder = new Node.Builder<>(uniqueId(node, name), name, context)
                        .asyncFolder();
                if (!singletons.isEmpty()) {
                    builder.icon(fontAwesome("list-ul"));
                }
                children.add(builder.build());
            }
            callback.result(children.toArray(new Node[children.size()]));
        });

    } else {
        ResourceAddress parentAddress = node.data.getAddress().getParent();
        Operation operation = new Operation.Builder(parentAddress, READ_CHILDREN_NAMES_OPERATION)
                .param(CHILD_TYPE, node.text).build();
        dispatcher.execute(operation, result -> {
            List<ModelNode> modelNodes = result.asList();
            List<Node<Context>> children = new ArrayList<>();
            SortedSet<String> singletons = new TreeSet<>(node.data.getSingletons());

            // Add existing children
            for (ModelNode modelNode : modelNodes) {
                String name = SafeHtmlUtils.fromString(modelNode.asString()).asString();
                singletons.remove(name);
                ResourceAddress address = new ResourceAddress(parentAddress).add(node.text, name);
                Context context = new Context(address, Collections.emptySet());
                Node<Context> child = new Node.Builder<>(uniqueId(node, name), name, context).asyncFolder()
                        .icon(fontAwesome("file-text-o")).build();
                children.add(child);
            }

            // Add non-existing singletons
            for (String singleton : singletons) {
                ResourceAddress address = new ResourceAddress(parentAddress).add(node.text, singleton);
                Context context = new Context(address, Collections.emptySet());
                Node<Context> child = new Node.Builder<>(uniqueId(node, singleton), singleton, context)
                        .icon(fontAwesome("file-o")).disabled().build();
                children.add(child);
            }

            callback.result(children.toArray(new Node[children.size()]));
        });
    }
}

From source file:org.jboss.hal.core.mvp.HalViewImpl.java

License:Apache License

protected HalViewImpl() {
    attachables = new ArrayList<>();
    attached = false;/*from   w  w w.  j  a va 2s  .  c o m*/

    // noinspection HardCodedStringLiteral
    element = div().css(marginTopLarge)
            .add(new Alert(Icons.ERROR, SafeHtmlUtils.fromString("View not initialized")).element())
            .add(p().add(span().textContent("The view is not initialized. Did you forget to call "))
                    .add(code().textContent("initElement(Element)")).add(span().textContent(" / "))
                    .add(code().textContent("initElements(Iterable<Element>)")).add(span().textContent("?")))
            .get();
}

From source file:org.jboss.wise.gwt.client.view.EndpointsView.java

License:Open Source License

public EndpointsView() {

    SimplePanel contentDetailsDecorator = new SimplePanel();
    contentDetailsDecorator.setWidth("100%");
    contentDetailsDecorator.setWidth("640px");
    initWidget(contentDetailsDecorator);

    VerticalPanel contentDetailsPanel = new VerticalPanel();
    contentDetailsPanel.setWidth("100%");

    StepLabel stepTitle = new StepLabel("Step 1 of 3: Select an Endpoint");
    contentDetailsPanel.add(stepTitle);//ww  w . j  ava2 s.c om

    Tree.Resources resources = new TreeImageResource();
    rootNode = new Tree(resources);
    rootNode.addItem(new TreeItem(SafeHtmlUtils.fromString("")));
    contentDetailsPanel.add(rootNode);

    menuPanel.getNextButton().setEnabled(false); // wait for user to select endpoint treeItem
    contentDetailsPanel.add(menuPanel);
    contentDetailsDecorator.add(contentDetailsPanel);
}

From source file:org.jboss.wise.gwt.client.view.EndpointsView.java

License:Open Source License

public void setData(List<Service> data) {

    endpointsMap.clear();/*ww w.  ja  v  a2s.  co m*/
    rootNode.removeItems();
    if (data != null) {
        for (Service s : data) {
            TreeItem serviceItem = new TreeItem(SafeHtmlUtils.fromString(s.getName()));
            rootNode.addItem(serviceItem);

            for (Port p : s.getPorts()) {
                TreeItem portItem = new TreeItem(SafeHtmlUtils.fromString(p.getName()));
                serviceItem.addItem(portItem);
                serviceItem.setState(true);

                for (Operation o : p.getOperations()) {
                    TreeItem tItem = new TreeItem(SafeHtmlUtils.fromString(o.getFullName()));
                    portItem.addItem(tItem);
                    portItem.setState(true);
                    tItem.addStyleName("endpoint");
                    endpointsMap.put(tItem, o);
                }
            }
        }
    }
}

From source file:org.jboss.wise.gwt.client.view.InvocationView.java

License:Open Source License

public InvocationView() {

    SimplePanel contentDetailsDecorator = new SimplePanel();
    contentDetailsDecorator.setWidth("100%");
    contentDetailsDecorator.setWidth("640px");
    initWidget(contentDetailsDecorator);

    VerticalPanel contentDetailsPanel = new VerticalPanel();
    contentDetailsPanel.setWidth("100%");

    StepLabel stepTitle = new StepLabel("Step 3 of 3: Result Data");
    contentDetailsPanel.add(stepTitle);/*from  ww  w .ja  v  a  2  s  .co  m*/

    Tree.Resources resources = new TreeImageResource();
    rootNode = new Tree(resources);
    rootNode.addItem(new TreeItem(SafeHtmlUtils.fromString("")));
    contentDetailsPanel.add(rootNode);

    // result msg display area
    previewMessageDisplayPanel.setDisplayRefreshButton(false);
    contentDetailsPanel.add(previewMessageDisplayPanel);

    menuPanel.getNextButton().setHTML("Cancel");

    contentDetailsPanel.add(menuPanel);
    contentDetailsDecorator.add(contentDetailsPanel);
}

From source file:org.kie.guvnor.guided.dtable.client.widget.GuidedDecisionTableWidget.java

License:Apache License

private Widget newColumn() {
    AddButton addButton = new AddButton();
    addButton.setText(Constants.INSTANCE.NewColumn());
    addButton.setTitle(Constants.INSTANCE.AddNewColumn());

    addButton.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent w) {
            final FormStylePopup pop = new FormStylePopup();
            pop.setModal(false);//from   w w  w.  ja  v  a  2s. co m

            //List of basic column types
            final ListBox choice = new ListBox();
            choice.setVisibleItemCount(NewColumnTypes.values().length);

            choice.addItem(Constants.INSTANCE.AddNewMetadataOrAttributeColumn(),
                    NewColumnTypes.METADATA_ATTRIBUTE.name());
            choice.addItem(SECTION_SEPARATOR);
            choice.addItem(Constants.INSTANCE.AddNewConditionSimpleColumn(),
                    NewColumnTypes.CONDITION_SIMPLE.name());
            choice.addItem(SECTION_SEPARATOR);
            choice.addItem(Constants.INSTANCE.SetTheValueOfAField(),
                    NewColumnTypes.ACTION_UPDATE_FACT_FIELD.name());
            choice.addItem(Constants.INSTANCE.SetTheValueOfAFieldOnANewFact(),
                    NewColumnTypes.ACTION_INSERT_FACT_FIELD.name());
            choice.addItem(Constants.INSTANCE.RetractAnExistingFact(),
                    NewColumnTypes.ACTION_RETRACT_FACT.name());

            //Checkbox to include Advanced Action types
            final CheckBox chkIncludeAdvancedOptions = new CheckBox(
                    SafeHtmlUtils.fromString(Constants.INSTANCE.IncludeAdvancedOptions()));
            chkIncludeAdvancedOptions.setValue(false);
            chkIncludeAdvancedOptions.addClickHandler(new ClickHandler() {

                public void onClick(ClickEvent event) {
                    if (chkIncludeAdvancedOptions.getValue()) {
                        addItem(3, Constants.INSTANCE.AddNewConditionBRLFragment(),
                                NewColumnTypes.CONDITION_BRL_FRAGMENT.name());
                        addItem(Constants.INSTANCE.WorkItemAction(), NewColumnTypes.ACTION_WORKITEM.name());
                        addItem(Constants.INSTANCE.WorkItemActionSetField(),
                                NewColumnTypes.ACTION_WORKITEM_UPDATE_FACT_FIELD.name());
                        addItem(Constants.INSTANCE.WorkItemActionInsertFact(),
                                NewColumnTypes.ACTION_WORKITEM_INSERT_FACT_FIELD.name());
                        addItem(Constants.INSTANCE.AddNewActionBRLFragment(),
                                NewColumnTypes.ACTION_BRL_FRAGMENT.name());
                    } else {
                        removeItem(NewColumnTypes.CONDITION_BRL_FRAGMENT.name());
                        removeItem(NewColumnTypes.ACTION_WORKITEM.name());
                        removeItem(NewColumnTypes.ACTION_WORKITEM_UPDATE_FACT_FIELD.name());
                        removeItem(NewColumnTypes.ACTION_WORKITEM_INSERT_FACT_FIELD.name());
                        removeItem(NewColumnTypes.ACTION_BRL_FRAGMENT.name());
                    }
                    pop.center();
                }

                private void addItem(int index, String item, String value) {
                    for (int itemIndex = 0; itemIndex < choice.getItemCount(); itemIndex++) {
                        if (choice.getValue(itemIndex).equals(value)) {
                            return;
                        }
                    }
                    choice.insertItem(item, value, index);
                }

                private void addItem(String item, String value) {
                    for (int itemIndex = 0; itemIndex < choice.getItemCount(); itemIndex++) {
                        if (choice.getValue(itemIndex).equals(value)) {
                            return;
                        }
                    }
                    choice.addItem(item, value);
                }

                private void removeItem(String value) {
                    for (int itemIndex = 0; itemIndex < choice.getItemCount(); itemIndex++) {
                        if (choice.getValue(itemIndex).equals(value)) {
                            choice.removeItem(itemIndex);
                            break;
                        }
                    }
                }

            });

            //OK button to create column
            final Button ok = new Button(Constants.INSTANCE.OK());
            ok.addClickHandler(new ClickHandler() {
                public void onClick(ClickEvent w) {
                    String s = choice.getValue(choice.getSelectedIndex());
                    if (s.equals(NewColumnTypes.METADATA_ATTRIBUTE.name())) {
                        showMetaDataAndAttribute();
                    } else if (s.equals(NewColumnTypes.CONDITION_SIMPLE.name())) {
                        showConditionSimple();
                    } else if (s.equals(NewColumnTypes.CONDITION_BRL_FRAGMENT.name())) {
                        showConditionBRLFragment();
                    } else if (s.equals(NewColumnTypes.ACTION_UPDATE_FACT_FIELD.name())) {
                        showActionSet();
                    } else if (s.equals(NewColumnTypes.ACTION_INSERT_FACT_FIELD.name())) {
                        showActionInsert();
                    } else if (s.equals(NewColumnTypes.ACTION_RETRACT_FACT.name())) {
                        showActionRetract();
                    } else if (s.equals(NewColumnTypes.ACTION_WORKITEM.name())) {
                        showActionWorkItemAction();
                    } else if (s.equals(NewColumnTypes.ACTION_WORKITEM_UPDATE_FACT_FIELD.name())) {
                        showActionWorkItemActionSet();
                    } else if (s.equals(NewColumnTypes.ACTION_WORKITEM_INSERT_FACT_FIELD.name())) {
                        showActionWorkItemActionInsert();
                    } else if (s.equals(NewColumnTypes.ACTION_BRL_FRAGMENT.name())) {
                        showActionBRLFragment();
                    }
                    pop.hide();
                }

                private void showMetaDataAndAttribute() {
                    // show choice of attributes
                    final Image image = ImageResources508.INSTANCE.Config();
                    final FormStylePopup pop = new FormStylePopup(image,
                            Constants.INSTANCE.AddAnOptionToTheRule());
                    final ListBox list = RuleAttributeWidget.getAttributeList();

                    //This attribute is only used for Decision Tables
                    list.addItem(GuidedDecisionTable52.NEGATE_RULE_ATTR);

                    // Remove any attributes already added
                    for (AttributeCol52 col : model.getAttributeCols()) {
                        for (int iItem = 0; iItem < list.getItemCount(); iItem++) {
                            if (list.getItemText(iItem).equals(col.getAttribute())) {
                                list.removeItem(iItem);
                                break;
                            }
                        }
                    }

                    final Image addbutton = ImageResources508.INSTANCE.NewItem();
                    final TextBox box = new TextBox();
                    box.setVisibleLength(15);

                    list.setSelectedIndex(0);

                    list.addChangeHandler(new ChangeHandler() {
                        public void onChange(ChangeEvent event) {
                            AttributeCol52 attr = new AttributeCol52();
                            attr.setAttribute(list.getItemText(list.getSelectedIndex()));
                            dtable.addColumn(attr);
                            refreshAttributeWidget();
                            pop.hide();
                        }
                    });

                    addbutton.setTitle(Constants.INSTANCE.AddMetadataToTheRule());

                    addbutton.addClickHandler(new ClickHandler() {
                        public void onClick(ClickEvent w) {

                            String metadata = box.getText();
                            if (!isUnique(metadata)) {
                                Window.alert(
                                        Constants.INSTANCE.ThatColumnNameIsAlreadyInUsePleasePickAnother());
                                return;
                            }
                            MetadataCol52 met = new MetadataCol52();
                            met.setHideColumn(true);
                            met.setMetadata(metadata);
                            dtable.addColumn(met);
                            refreshAttributeWidget();
                            pop.hide();
                        }

                        private boolean isUnique(String metadata) {
                            for (MetadataCol52 mc : model.getMetadataCols()) {
                                if (metadata.equals(mc.getMetadata())) {
                                    return false;
                                }
                            }
                            return true;
                        }

                    });
                    DirtyableHorizontalPane horiz = new DirtyableHorizontalPane();
                    horiz.add(box);
                    horiz.add(addbutton);

                    pop.addAttribute(Constants.INSTANCE.Metadata1(), horiz);
                    pop.addAttribute(Constants.INSTANCE.Attribute(), list);
                    pop.show();
                }

                private void showConditionSimple() {
                    final ConditionCol52 column = makeNewConditionColumn();
                    ConditionPopup dialog = new ConditionPopup(oracle, model, new ConditionColumnCommand() {
                        public void execute(Pattern52 pattern, ConditionCol52 column) {

                            //Update UI
                            dtable.addColumn(pattern, column);
                            refreshConditionsWidget();
                        }
                    }, column, true, isReadOnly);
                    dialog.show();
                }

                private void showConditionBRLFragment() {
                    final BRLConditionColumn column = makeNewConditionBRLFragment();
                    switch (model.getTableFormat()) {
                    case EXTENDED_ENTRY:
                        BRLConditionColumnViewImpl popup = new BRLConditionColumnViewImpl(path, oracle, model,
                                column, eventBus, true, isReadOnly);
                        popup.setPresenter(BRL_CONDITION_PRESENTER);
                        popup.show();
                        break;
                    case LIMITED_ENTRY:
                        LimitedEntryBRLConditionColumnViewImpl limtedEntryPopup = new LimitedEntryBRLConditionColumnViewImpl(
                                path, oracle, model, (LimitedEntryBRLConditionColumn) column, eventBus, true,
                                isReadOnly);
                        limtedEntryPopup.setPresenter(LIMITED_ENTRY_BRL_CONDITION_PRESENTER);
                        limtedEntryPopup.show();
                        break;
                    }
                }

                private void showActionInsert() {
                    final ActionInsertFactCol52 afc = makeNewActionInsertColumn();
                    ActionInsertFactPopup ins = new ActionInsertFactPopup(oracle, model,
                            new GenericColumnCommand() {
                                public void execute(DTColumnConfig52 column) {
                                    newActionAdded((ActionCol52) column);
                                }
                            }, afc, true, isReadOnly);
                    ins.show();
                }

                private void showActionSet() {
                    final ActionSetFieldCol52 afc = makeNewActionSetColumn();
                    ActionSetFieldPopup set = new ActionSetFieldPopup(oracle, model,
                            new GenericColumnCommand() {
                                public void execute(DTColumnConfig52 column) {
                                    newActionAdded((ActionCol52) column);
                                }
                            }, afc, true, isReadOnly);
                    set.show();
                }

                private void showActionRetract() {
                    final ActionRetractFactCol52 arf = makeNewActionRetractFact();
                    ActionRetractFactPopup popup = new ActionRetractFactPopup(model,
                            new GenericColumnCommand() {
                                public void execute(DTColumnConfig52 column) {
                                    newActionAdded((ActionCol52) column);
                                }
                            }, arf, true, isReadOnly);
                    popup.show();
                }

                private void showActionWorkItemAction() {
                    final ActionWorkItemCol52 awi = makeNewActionWorkItem();
                    ActionWorkItemPopup popup = new ActionWorkItemPopup(path, model,
                            GuidedDecisionTableWidget.this, new GenericColumnCommand() {
                                public void execute(DTColumnConfig52 column) {
                                    newActionAdded((ActionCol52) column);
                                }
                            }, awi, true, isReadOnly);
                    popup.show();
                }

                private void showActionWorkItemActionSet() {
                    final ActionWorkItemSetFieldCol52 awisf = makeNewActionWorkItemSetField();
                    ActionWorkItemSetFieldPopup popup = new ActionWorkItemSetFieldPopup(oracle, model,
                            new GenericColumnCommand() {
                                public void execute(DTColumnConfig52 column) {
                                    newActionAdded((ActionCol52) column);
                                }
                            }, awisf, true, isReadOnly);
                    popup.show();
                }

                private void showActionWorkItemActionInsert() {
                    final ActionWorkItemInsertFactCol52 awiif = makeNewActionWorkItemInsertFact();
                    ActionWorkItemInsertFactPopup popup = new ActionWorkItemInsertFactPopup(oracle, model,
                            new GenericColumnCommand() {
                                public void execute(DTColumnConfig52 column) {
                                    newActionAdded((ActionCol52) column);
                                }
                            }, awiif, true, isReadOnly);
                    popup.show();
                }

                private void showActionBRLFragment() {
                    final BRLActionColumn column = makeNewActionBRLFragment();
                    switch (model.getTableFormat()) {
                    case EXTENDED_ENTRY:
                        BRLActionColumnViewImpl popup = new BRLActionColumnViewImpl(path, oracle, model, column,
                                eventBus, true, isReadOnly);
                        popup.setPresenter(BRL_ACTION_PRESENTER);
                        popup.show();
                        break;
                    case LIMITED_ENTRY:
                        LimitedEntryBRLActionColumnViewImpl limtedEntryPopup = new LimitedEntryBRLActionColumnViewImpl(
                                path, oracle, model, (LimitedEntryBRLActionColumn) column, eventBus, true,
                                isReadOnly);
                        limtedEntryPopup.setPresenter(LIMITED_ENTRY_BRL_ACTION_PRESENTER);
                        limtedEntryPopup.show();
                        break;
                    }

                }

                private void newActionAdded(ActionCol52 column) {
                    dtable.addColumn(column);
                    refreshActionsWidget();
                }
            });

            //If a separator is clicked disable OK button
            choice.addClickHandler(new ClickHandler() {

                public void onClick(ClickEvent event) {
                    int itemIndex = choice.getSelectedIndex();
                    if (itemIndex < 0) {
                        return;
                    }
                    ok.setEnabled(!choice.getValue(itemIndex).equals(SECTION_SEPARATOR));
                }

            });

            pop.setTitle(Constants.INSTANCE.AddNewColumn());
            pop.addAttribute(Constants.INSTANCE.TypeOfColumn(), choice);
            pop.addAttribute("", chkIncludeAdvancedOptions);
            pop.addAttribute("", ok);
            pop.show();
        }

        private ConditionCol52 makeNewConditionColumn() {
            switch (model.getTableFormat()) {
            case LIMITED_ENTRY:
                return new LimitedEntryConditionCol52();
            default:
                return new ConditionCol52();
            }
        }

        private ActionInsertFactCol52 makeNewActionInsertColumn() {
            switch (model.getTableFormat()) {
            case LIMITED_ENTRY:
                return new LimitedEntryActionInsertFactCol52();
            default:
                return new ActionInsertFactCol52();
            }
        }

        private ActionSetFieldCol52 makeNewActionSetColumn() {
            switch (model.getTableFormat()) {
            case LIMITED_ENTRY:
                return new LimitedEntryActionSetFieldCol52();
            default:
                return new ActionSetFieldCol52();
            }
        }

        private ActionRetractFactCol52 makeNewActionRetractFact() {
            switch (model.getTableFormat()) {
            case LIMITED_ENTRY:
                LimitedEntryActionRetractFactCol52 ler = new LimitedEntryActionRetractFactCol52();
                ler.setValue(new DTCellValue52(""));
                return ler;
            default:
                return new ActionRetractFactCol52();
            }
        }

        private ActionWorkItemCol52 makeNewActionWorkItem() {
            //WorkItems are defined within the column and always boolean (i.e. Limited Entry) in the table
            return new ActionWorkItemCol52();
        }

        private ActionWorkItemSetFieldCol52 makeNewActionWorkItemSetField() {
            //Actions setting Field Values from Work Item Result Parameters are always boolean (i.e. Limited Entry) in the table
            return new ActionWorkItemSetFieldCol52();
        }

        private ActionWorkItemInsertFactCol52 makeNewActionWorkItemInsertFact() {
            //Actions setting Field Values from Work Item Result Parameters are always boolean (i.e. Limited Entry) in the table
            return new ActionWorkItemInsertFactCol52();
        }

        private BRLActionColumn makeNewActionBRLFragment() {
            switch (model.getTableFormat()) {
            case LIMITED_ENTRY:
                return new LimitedEntryBRLActionColumn();
            default:
                return new BRLActionColumn();
            }
        }

        private BRLConditionColumn makeNewConditionBRLFragment() {
            switch (model.getTableFormat()) {
            case LIMITED_ENTRY:
                return new LimitedEntryBRLConditionColumn();
            default:
                return new BRLConditionColumn();
            }
        }

    });

    return addButton;
}

From source file:org.kie.workbench.common.forms.dynamic.client.rendering.renderers.selectors.radioGroup.RadioGroupFieldRendererBase.java

License:Apache License

protected SafeHtml getOptionLabel(String text) {
    if (text == null || text.isEmpty()) {
        return SafeHtmlUtils.fromTrustedString("&nbsp;");
    }/*from  ww w .  j a v a  2 s  . co m*/
    return SafeHtmlUtils.fromString(text);
}