1 D table boolean (true false) & amp; Boolean (true-false)

Could solve this problem? and please explain to me why this happened? Thank you very much...

Hi Kelvin,

This occurs when you try to connect an array to a scalar indicator

You see a table range - for each element of the array. So you get a table of Boolean, one bit per element!

If you want to know if all the elements of the array are in range, use the function of "of elements of array.

If you need to know if one of the elements of the array is in range, use the function of "Elements of array of GOLD"...

Published:

-You probably want to set scalar limits instead of paintings of the limits.

-To reduce to zero the numbers, you can use the function "Cancel". Or did you put that '-1' constant to have the exact number of elements of array?

Tags: NI Software

Similar Questions

  • Update of an item of table boolean conditionally

    Hi, I have a table of 16-bit Boolean values, and I want to be able to change a bit and only, when appropriate for the VI has changed.

    As background, I have a 16-bit port Expander (I2C) and I need to change a little, IE, define an output on or off, without affecting the others. To do this, I re-read the 16 bits so I know what are the current States of the outputs, then I need to change a bit and write that the 16-bit of return.

    I looked at the block replace table subset, which seems to be related, but since I only need to change one bit at a time, I don't see how I can connect the control to all 16 bits and change only the need for change.

    Is there an elegant way to do it? For instance I have a list box with the names of the ports, so that the user can select the port they need to change, and then they set the State of a toggle switch or a Boolean value to set the bit and only this small? Thanks for any advice.

    What is the kind of thing you had in mind?

  • unique table boolean Boolean

    Hello world
    I'm working on a project concerning the Modbus using the "Modbus on desktop.vi. In Vi, the "values of coil to write" type is an array of Boolean. I want to change it to a single Boolean value. is this possible? I get a screenshot of the Panel front and block diagram.

    Thank you.

    You can simply use the array to build with a "single Boolean value.

    This will give you an array containing a single element.

    Steve

  • Values in the array of Booleans to dictate the output to be Boolean False or Boolean True

    I have a pretty simple question that I have a problem to solve.

    I'm looking to enter a Boolean array for a sub - vi that will take this table and dictate a single boolean output Boolean false or Boolean True.

    For example, the table will be table boolean 1 d, with a depth of 2 index values.

    -If the two index values are wrong then the sub - vi will kick for a False value.

    -If the two index values are true then the sub - vi will kick on a True value.

    -If an index value is True then the sub - vi will kick a True value.

    Any ideas?

    Thank you.

    jonathanupr wrote:

    -If the two index values are wrong then the sub - vi will kick for a False value.

    -If the two index values are true then the sub - vi will kick on a True value.

    -If an index value is True then the sub - vi will kick a True value.

    It sounds like an RC for me

    jonathanupr wrote:

    For example, the table will be table boolean 1 d, with a depth of 2 index values.

    I don't know what you mean by that.  How you choose to use indexes?

    EDIT: Perhaps you need some Elements of array or

  • A special selection of the table of Boolean

    I use Labview to prepare to use with AB CompactLogix PLC HMI. The problem for me is that I cannot select a bit special (for example to connect with a button, TRUE/FALSE) in an array of Boolean. What I can do is get a particular tag data (integer type Double) plc using OPC and convert these data into array of Boolean. The table can be represented by a series of 32 buttons (I use a card of entry type 32 PLC input fields). But I want to access only the bit 4 of table boolean and toggle an LED based on its output. How to do this? Help, please!

    Leave the data type as a U32 and use the following code:

    1 must be of type U32.

    That should do it.

    Play with this idea, also explore GOLD and XOR actions on U32.

    Tone

  • Bug of output conditional Boolean autoindexing

    It's a little subtle, so I apologize in advance for the possible confusion.

    Start with a While loop and conditionally autoindex a scalar:

    Example 1

    As noted, the Boolean result is a scalar.

    Now try the same thing with a loop (DO NOT REPLACE THE WHILE LOOP above by a For CREATING a BRAND NEW LOOP FOR loop):

    Example 2

    OK, so now the Boolean result is a table. Cool, that's what I wanted with the While loop above, but could not achieve.

    Now you can play with replacements:

    In example 1 above, replace the While loop with a loop For. Here's what you get:

    If you CAN produce a Boolean scalar value in a loop For, but you have to go through a While loop to get it.

    Now replace the loop in example 2 by a while loop:

    All right, here's my table Boolean output. But I had to go through a While loop to do.

    I'd say it's a bug, and the Boolean result of conditional indexation should be a table (not sure if there would be any how to have it be a scalar; last exit value?).

    Tested by LavBIEW 2013 SP1 64 bit

    Sam is correct: the conditional Terminal is not out of the loop for. When you "dragged through" the sequence you actually create an output of indexation of array of Booleans (unconditionally). Click on "cleaning chart" and you will see this. (I guess it might be a bug that LabView allows two nodes to overlay on the same place in the loop).

    Moreover, you can always get a scalar to a loop for. right click on the tunnel, set it to "last".

  • How to create a table in if/else or structure without 0-case?

    Hello

    I tried to do for a while now.

    I only managed to think about this in three ways:

    1. (what I'm doing right now create the table through a loop for, fills the table in automatic indexing.) Filled it with many of if true and with a '0' if the value false. The idea was to remove the 0 later in the code. However, this seems very inefficient.

    2 make use of a registry change, which automatically adds the correct number of a table. The problem is that the table will keep growing and growing and at the very least would enormously slow down my program. At worst, it would break.

    So my question is: how to create a table that if a comparison is true, it puts the item in and if not, it does nothing?

    I have attached a PNG of my code snippet.

    Kind regards

    David.

    If you want to only affect exactly as much memory as you need for the table, you can count the number of true elements in the table of Boolean everything first and then assign one of exactly this size. In this way, you are more memory and time-efficient whether overuse (such as allocation of an array of I32 as big as the whole table boolean) or underallocating (from zero element and let it grow automatically whenever you add on).

    Count the true values, allocate an array only the great and then replace each value in this new table with indexes / "I ' value where the real exists." An excerpt from VI:

  • Why not adding css class for table poster red border cell error?

    JavaFX 2.2.21 Java 7.21

    I'm trying to display a red border and a picture on a cell text when an error occurs.

    I took the address book example (example 12-11 http://docs.oracle.com/javafx/2/ui_controls/table-view.htm#CJAGAAEE).

    and also James D solution to my previous question.

    I find that adding a class of css error does not display the red border and the image.

    However, using setStyle this - but it is not preferable, because I want to put the border value by default once the error is corrected.

    In the example below, red border does NOT appear. The 'name' field was changed to salary and must display one error (red border and image) if other thing that an integer is entered.

    If you uncomment the setStyle lines, then it is displayed.

    Note: I use empty.png to erase the image of 'failure' because using - fx-background-image: none; somehow, did not.

    import javafx.application.Application;
    import javafx.beans.property.SimpleStringProperty;
    import javafx.collections.FXCollections;
    import javafx.collections.ObservableList;
    import javafx.geometry.Insets;
    import javafx.scene.Group;
    import javafx.scene.Scene;
    import javafx.scene.control.Label;
    import javafx.scene.control.TableColumn.CellEditEvent;
    import javafx.scene.layout.HBox;
    import javafx.scene.layout.VBox;
    import javafx.scene.text.Font;
    import javafx.stage.Stage;
    import javafx.beans.value.ChangeListener;
    import javafx.beans.value.ObservableValue;
    import javafx.event.ActionEvent;
    import javafx.event.EventHandler;
    import javafx.scene.control.Button;
    import javafx.scene.control.TableCell;
    import javafx.scene.control.TableColumn;
    import javafx.scene.control.TableView;
    import javafx.scene.control.TextField;
    import javafx.scene.control.cell.PropertyValueFactory;
    import javafx.scene.input.KeyCode;
    import javafx.scene.input.KeyEvent;
    import javafx.util.Callback;
    public class TableViewSample extends Application {
    
    
        private TableView<Person> table = new TableView<Person>();
        private final ObservableList<Person> data =
                FXCollections.observableArrayList(
                new Person("Gates", "46", "[email protected]"),
                new Person("Ellison", "25", "[email protected]"),
                new Person("McNealy", "1", "[email protected]"),
                new Person("Jobs", "0", "[email protected]"),
                new Person("Me", "0", "[email protected]"));
        final HBox hb = new HBox();
    
    
        public static void main(String[] args) {
            launch(args);
        }
    
    
        @Override
        public void start(Stage stage) {
            Scene scene = new Scene(new Group());
            stage.setTitle("Table View Sample");
            stage.setWidth(450);
            stage.setHeight(550);
    
    
            final Label label = new Label("Address Book");
            label.setFont(new Font("Arial", 20));
    
    
            table.setEditable(true);
            Callback<TableColumn, TableCell> cellFactory =
                    new Callback<TableColumn, TableCell>() {
                public TableCell call(TableColumn p) {
                    return new EditingCell();
                }
            };
    
    
            TableColumn firstNameCol = new TableColumn("First Name");
            firstNameCol.setMinWidth(100);
            firstNameCol.setCellValueFactory(
                    new PropertyValueFactory<Person, String>("firstName"));
            firstNameCol.setCellFactory(cellFactory);
            firstNameCol.setOnEditCommit(
                    new EventHandler<CellEditEvent<Person, String>>() {
                @Override
                public void handle(CellEditEvent<Person, String> t) {
                    ((Person) t.getTableView().getItems().get(
                            t.getTablePosition().getRow())).setFirstName(t.getNewValue());
                }
            });
    
    
    
    
            TableColumn salaryCol = new TableColumn("Salary");
            salaryCol.setMinWidth(100);
            salaryCol.setCellValueFactory(
                    new PropertyValueFactory<Person, String>("salary"));
            salaryCol.setCellFactory(cellFactory);
            salaryCol.setOnEditCommit(
                    new EventHandler<CellEditEvent<Person, String>>() {
                @Override
                public void handle(CellEditEvent<Person, String> t) {
                    ((Person) t.getTableView().getItems().get(
                            t.getTablePosition().getRow())).setSalary(t.getNewValue());
                }
            });
    
    
            TableColumn emailCol = new TableColumn("Email");
            emailCol.setMinWidth(200);
            emailCol.setCellValueFactory(
                    new PropertyValueFactory<Person, String>("email"));
            emailCol.setCellFactory(cellFactory);
            emailCol.setOnEditCommit(
                    new EventHandler<CellEditEvent<Person, String>>() {
                @Override
                public void handle(CellEditEvent<Person, String> t) {
                    ((Person) t.getTableView().getItems().get(
                            t.getTablePosition().getRow())).setEmail(t.getNewValue());
                }
            });
    
    
            table.setItems(data);
            table.getColumns().addAll(firstNameCol, salaryCol, emailCol);
    
    
            final TextField addFirstName = new TextField();
            addFirstName.setPromptText("First Name");
            addFirstName.setMaxWidth(firstNameCol.getPrefWidth());
            final TextField addSalary = new TextField();
            addSalary.setMaxWidth(salaryCol.getPrefWidth());
            addSalary.setPromptText("Last Name");
            final TextField addEmail = new TextField();
            addEmail.setMaxWidth(emailCol.getPrefWidth());
            addEmail.setPromptText("Email");
    
    
            final Button addButton = new Button("Add");
            addButton.setOnAction(new EventHandler<ActionEvent>() {
                @Override
                public void handle(ActionEvent e) {
                    data.add(new Person(
                            addFirstName.getText(),
                            addSalary.getText(),
                            addEmail.getText()));
                    addFirstName.clear();
                    addSalary.clear();
                    addEmail.clear();
                }
            });
    
    
            hb.getChildren().addAll(addFirstName, addSalary, addEmail, addButton);
            hb.setSpacing(3);
    
    
            final VBox vbox = new VBox();
            vbox.setSpacing(5);
            vbox.setPadding(new Insets(10, 0, 0, 10));
            vbox.getChildren().addAll(label, table, hb);
    
    
            ((Group) scene.getRoot()).getChildren().addAll(vbox);
            scene.getStylesheets().add(getClass().getResource("errorTextField.css").toExternalForm());
    
    
            stage.setScene(scene);
            stage.show();
        }
    
    
        public static class Person {
    
    
            private final SimpleStringProperty firstName;
            private final SimpleStringProperty salary;
            private final SimpleStringProperty email;
    
    
            private Person(String fName, String pay, String email) {
                this.firstName = new SimpleStringProperty(fName);
                this.salary = new SimpleStringProperty(pay);
                this.email = new SimpleStringProperty(email);
            }
    
    
            public String getFirstName() {
                return firstName.get();
            }
    
    
            public void setFirstName(String fName) {
                firstName.set(fName);
            }
    
    
            public String getSalary() {
                return salary.get();
            }
    
    
            public void setSalary(String fName) {
                salary.set(fName);
            }
    
    
            public String getEmail() {
                return email.get();
            }
    
    
            public void setEmail(String fName) {
                email.set(fName);
            }
        }
    
    
        class EditingCell extends TableCell<Person, String> {
    
    
            final String errorCSSClass = "error";
            private TextField textField;
    
    
            public EditingCell() {
            }
    
    
            @Override
            public void startEdit() {
                if (!isEmpty()) {
                    super.startEdit();
                    createTextField();
                    setText(null);
                    setGraphic(textField);
                    textField.selectAll();
                }
            }
    
    
            @Override
            public void cancelEdit() {
                super.cancelEdit();
    
    
                setText((String) getItem());
                setGraphic(null);
            }
    
    
            @Override
            public void updateItem(String item, boolean empty) {
                super.updateItem(item, empty);
    
    
                if (empty) {
                    setText(null);
                    setGraphic(null);
                } else {
                    if (isEditing()) {
                        if (textField != null) {
                            textField.setText(getString());
                        }
                        setText(null);
                        setGraphic(textField);
                    } else {
                        setText(getString());
                        setGraphic(null);
                    }
                }
            }
    
    
            private boolean validate(String text) {
                try {
                    Integer.parseInt(text);
                } catch (NumberFormatException ne) {
                    return false;
                }
                return true;
            }
    
    
            private void createTextField() {
                textField = new TextField(getString());
                textField.setMinWidth(this.getWidth() - this.getGraphicTextGap() * 2);
                textField.focusedProperty().addListener(new ChangeListener<Boolean>() {
                    @Override
                    public void changed(ObservableValue<? extends Boolean> arg0,
                            Boolean arg1, Boolean arg2) {
                        if (!arg2) {
                            commitEdit(textField.getText());
                            boolean valid = validate(textField.getText());
                            if (!valid) {
                                if (!getStyleClass().contains(errorCSSClass)) {
                                    getStyleClass().add(errorCSSClass);
                                }
    //                            setStyle("-fx-border-color: red; -fx-background-image:url('fail.png'); -fx-background-repeat: no-repeat; -fx-background-position: right center;");
                            } else {
                                getStyleClass().remove(errorCSSClass);
    //                            setStyle("-fx-border-color: gray;  -fx-background-image:url('empty.png');");
                            }
                        }
                    }
                });
                textField.setOnKeyReleased(new EventHandler<KeyEvent>() {
                    @Override
                    public void handle(KeyEvent event) {
                        if ((event.getCode() == KeyCode.ENTER)) {
                            commitEdit(textField.getText());
                            boolean valid = validate(textField.getText());
                            if (!valid) {
                                if (!getStyleClass().contains(errorCSSClass)) {
                                    getStyleClass().add(errorCSSClass);
                                }
    //                            setStyle("-fx-border-color: red; -fx-background-image:url('fail.png'); -fx-background-repeat: no-repeat; -fx-background-position: right center;");
                            } else {
                                getStyleClass().remove(errorCSSClass);
    //                            setStyle("-fx-border-color: gray;  -fx-background-image:url('empty.png');");
                            }
                        } else if (event.getCode() == KeyCode.ESCAPE) {
                            cancelEdit();
                        }
                    }
                });
            }
    
    
            private String getString() {
                return getItem() == null ? "" : getItem().toString();
            }
        }
    }
    
    
    

    errorTextField.css

    root {
        display: block;
    }
    
    
    .text-field.error {
    -fx-border-color: red ;
      -fx-border-width: 2px ;
      -fx-background-image:url('fail.png');
      -fx-background-repeat: no-repeat;
      -fx-background-position: right center;
    }
    .text-field {
    -fx-border-width: 0px ;
    -fx-background-image:url('empty.png') ;
       -fx-background-repeat: no-repeat;
      -fx-background-position: right center;
    }
    
    
    

    The css Setup is fine. The selector

    .a.b
    

    Selects elements that have the two class a and class b. Note that in this example, you set the style on the table cell class, not on the text field. So you have the selector

    .table-cell.error
    

    You can select the cells of a table with text fields that also have the style class 'mistake' set with

    .text-field.error, .table-cell.error
    
  • Play a sound from an above a certain threshold. Data table 1 d type

    I am facing a problem with the beep.vi.  I have a DAQ program, which acquired the signal and compare it to a threshold value. When a signal is out of range, a Visual and sound alarm has occurred. I use the VI beep.vi to generate the sound. Everything works fine except the sound alarm. It gives the table 1 d of type mismatch. I tried to fix this by placing it in a box structure. But it still does not work. If someone could help? Please find attached my VI. Best wishes to all visitors to the Forums of Discussion OR.

    Ihab El-Sayed

    Why did you create a new thread? All you need to do is add a response to the previous, attaching the VI you have forgotten to attach.

    Please keep any further discussion in this thread.

    As to your question: I have no idea why you use a Type Cast on a table 1 d of Boolean. Did you randomly choose a function off the pallet until you found one that does not give you a cut wire? It seems to me that since you compare an array of values to a certain threshold, then you probably want to beep if one of them is out of range. In this case, you would like to if none of the elements of the array, Boolean is set to True. This implies an OR condition. And that means that you must use the function to the array element or. This will return a value of True if any value in a table Boolean is set to True.

  • Replace the subset of table operation

    I have a code to a key VI event down that toggles the visibility of some indicators in response to press the function keys. Records using Boolean shift, the code worked with a few indicators.

    To scale to a large number of indicators, I decided that I would need convert a registry to offset single Boolean array.

    With the shift table Boolean register, for a given function key, the code reverse the Boolean value of the table for the property node Visible, then replaces the same item in the table of Boolean with the inverted Boolean value. The code does not work. Once the indicator is visible, he won't go invisible on the next push of button.

    I watched the execution, display values. Looks like that replace it table subset VI is not replace the Boolean value with the updated value. In the attached screenshot, you can see where I got the element of the array once it has been "updated" to replace table VI of subset. Impossible to find all the bugs in the list of bug LV2013.

    See the attached screenshot. What's wrong with this code? My apologies for the resolution of the screen capture. If necessary, I'll go back to the lab and try to capture a screenshot of higher resolution.

    On-screen turned your empty Boolean arrayis, in other words, it has no elements. Subset of the table Replace does not work with an empty array.

    See you soon,.

    McDuff

  • Comparison table

    Hi all

    I have 2 tables... I just need to check if the two are same... If even give me a real and not a fake...

    by using the function "=", I get a table of true/false... what I need is simple just one true if they are equal and not a fake

    any suggestions

    concerning

    Right-click on equal to, go to the comparison Mode, then select compare aggregates.

  • FilterVisible does not work for an af:table component.

    In jdev 12.1.3

    I have a component af:table surrounded by a panelCollection in a jsf page, and I have set the attribute FilterVisible of the element af:table as 'true '. The page associated with source codes are as follows:

    < af:table id = "md1" lines = ' #{bindings. " TodoListVO11.rangeSize}.
    fetchSize = "#{bindings." TodoListVO11.rangeSize}.
    emptyText = "#{bindings." TodoListVO11.viewable? "{'No data to display.': 'Access Denied.'}".
    var = "row" value = "#{bindings." TodoListVO11.collectionModel}.
    rowBandingInterval = '0 '.
    selectedRowKeys = ' #{bindings. " TodoListVO11.collectionModel.selectedRow}.
    selectionListener = "#{bindings." TodoListVO11.collectionModel.makeCurrent}.
    "rowSelection ="single"partialTriggers =": b2: b2 "displayRow ="selected ".
    filterVisible = "true" >
    < af:column headerText = "#{bindings." TodoListVO11.hints.Id.label}.
    sortProperty = "#{bindings." TodoListVO11.hints.Id.name}"sortable ="false ".
    ID = "c46" width = "30" >
    < af:outputText value = "#{rank." ID} ".
    shortDesc = "#{bindings." TodoListVO11.hints.Id.tooltip}"id ="ot46 ".
    inlineStyle = "make-weight: #{rank." Tree lt 4? {'medium': 'normal'}; ">"


    < af:convertNumber groupingUsed = "false".
    model = ' #{bindings. " TodoListVO11.hints.Id.format}"/ >
    < / af:outputText >
    < / af:column >

    < af:column... >

    < / af:column >
    < / af:table >

    But, when the page runs, the buttun toggles filter for the table does not appear in the upper area of the panelColletion.

    Is there something that I missed?

    How to fix?

    Thank you.

    The not Blas: how to add screening lines to an af:table which has not been originally configured for this

    When you add an ADF table read-only on a JSF page you can add "the lines matching" to the table. Here's how to put it on a table that was not setup with the 'filtering of lines"and now you want to enable it now.

    1. right click on the JSF page that contains the 'af:table' and select 'go to definition Page.

    2. in the window structure, right-click on 'executable' and select 'insert inside executables-> Search box.

    3. Enter an ID like this--> SrListQuery

    4. change the XML binding file so it adds these 3 attributes, as shown.

    <searchRegionBinds="SrlistView1Iterator"Criteria=""Customizer="oracle.jbo.uicli.binding.JUSearchBindingCustomizer"id="SrListQuery"/>
    

    5. return to the JSF page and go into the source editor and add these 3 attributes in bold to your "af:table". You should use "SrListQuery" which is the Id of the executable search box.

    <af:tablevalue="#{bindings.SrlistView1.collectionModel}"var="row" rows="#{bindings.SrlistView1.rangeSize}"emptyText="#{bindings.SrlistView1.viewable ? 'No rows yet.' : 'Access Denied.'}"fetchSize="#{bindings.SrlistView1.rangeSize}"  filterModel="#{bindings.SrListQuery.queryDescriptor}"  queryListener="#{bindings.SrListQuery.processQuery}" selectedRowKeys="#{bindings.SrlistView1.collectionModel.selectedRow}"selectionListener="#{bindings.SrlistView1.collectionModel.makeCurrent}"rowSelection="single" id="table"filterVisible="true">
    

    Finally we must determine which columns we want to allow filtering occurs for which we do as follows

    6. Select the "af:column" tag in the structure window.

    7. click on the symbol to expand the 'behavior' options in the property inspector.

    8. set "Filterable" to "true".

    9. Repeat steps 6 through 8 for each column that you want to be blockable.

    Now, when you switch to design view of your JSF page you should see your table that has one row on top of the table which allows line of filtering for columns that you have enabled this for.

  • TableView containing the format of table TextFieldTableCells

    Hello

    I have a TableView consisting of columns of TextFieldTableCells and I would format a cell based on another cell in the same row value. As the CellFactory is fixed for each of the TableColumns use a TextFieldTableCell.forColumn (), how can I optimize both the cell formatting and access to the row in the same call updateItem object?

    IM really stuck thereby and would appreciate pointers.

    See you soon

    Andy

    It has much in common with the cell TableView coloring updates - realizing if sort arrived: you might want to take a look at the response to this first.

    How can I get both the cell formatting

    TextFieldTableCell subclass and override the updateItem() method to do the formatting. If you format conditionally other properties (for example other columns) which can change, you will need to listen to these properties for changes. You must handle the listener carefully that the cell can be reused for different elements in the table. This part is similar to the above thread.

    and access to the line in the same call updateItem object

    Use getTableRow () .getItem () to access the value of the row in the table. You can also use table.getItems () .get (getIndex). Both methods require audits: getTableRow() does not return null, which the getIndex() return a value in the range.

    My Canon, revised example for this question:

    import java.util.Arrays;
    import java.util.List;
    
    import javafx.application.Application;
    import javafx.beans.property.BooleanProperty;
    import javafx.beans.property.SimpleBooleanProperty;
    import javafx.beans.property.SimpleStringProperty;
    import javafx.beans.property.StringProperty;
    import javafx.beans.value.ChangeListener;
    import javafx.beans.value.ObservableValue;
    import javafx.collections.FXCollections;
    import javafx.collections.ObservableList;
    import javafx.event.ActionEvent;
    import javafx.event.EventHandler;
    import javafx.scene.Scene;
    import javafx.scene.control.Button;
    import javafx.scene.control.TableCell;
    import javafx.scene.control.TableColumn;
    import javafx.scene.control.TableRow;
    import javafx.scene.control.TableView;
    import javafx.scene.control.cell.CheckBoxTableCell;
    import javafx.scene.control.cell.PropertyValueFactory;
    import javafx.scene.control.cell.TextFieldTableCell;
    import javafx.scene.layout.BorderPane;
    import javafx.stage.Stage;
    import javafx.util.Callback;
    import javafx.util.StringConverter;
    
    public class FormattedTableWithTextFields extends Application {
    
      @Override
      public void start(Stage primaryStage) {
        final BorderPane root = new BorderPane();
        final TableView table = new TableView();
        table.setItems(createData());
        final TableColumn firstNameColumn = new TableColumn<>("First Name");
        final TableColumn lastNameColumn = new TableColumn<>("Last Name");
        final TableColumn injuredColumn = new TableColumn<>("Injured");
        firstNameColumn.setCellValueFactory(new PropertyValueFactory("firstName"));
        lastNameColumn.setCellValueFactory(new PropertyValueFactory("lastName"));
        injuredColumn.setCellValueFactory(new PropertyValueFactory("injured"));
        injuredColumn.setCellFactory(CheckBoxTableCell.forTableColumn(injuredColumn));
        injuredColumn.setEditable(true);
    
        installCustomTextFieldCellFactory(firstNameColumn);
        installCustomTextFieldCellFactory(lastNameColumn);
    
        table.setEditable(true);
        table.getColumns().addAll(firstNameColumn, lastNameColumn, injuredColumn);
    
        root.setCenter(table);
    
        Button button = new Button("Dump info");
        button.setOnAction(new EventHandler() {
          @Override
          public void handle(ActionEvent event) {
            for (Player p : table.getItems()) {
              System.out.println(p);
            }
            System.out.println();
          }
        });
        root.setBottom(button);
        final Scene scene = new Scene(root, 400, 600);
        scene.getStylesheets().add(getClass().getResource("formattedTableWithTextFields.css").toExternalForm());
        primaryStage.setScene(scene);
        primaryStage.show();
      }
    
      private void installCustomTextFieldCellFactory(TableColumn column) {
        column.setCellFactory(new Callback, TableCell>() {
    
          @Override
          public TableCell call(TableColumn column) {
            return new StyledTextFieldTableCell();
          }
    
        });
      }
    
      public static void main(String[] args) {
        launch(args);
      }
    
      private ObservableList createData() {
        List players = Arrays.asList(
            new Player("Hugo" ,"Lloris", false),
            new Player("Brad", "Friedel", false),
            new Player("Kyle", "Naughton", false),
            new Player("Younes", "Kaboul", true),
            new Player("Benoit", "Assou-Ekotto", false),
            new Player("Jan", "Vertonghen", false),
            new Player("Michael", "Dawson", false),
            new Player("William", "Gallas", true),
            new Player("Kyle", "Walker", false),
            new Player("Scott", "Parker", false),
            new Player("Mousa", "Dembele", false),
            new Player("Sandro", "Cordeiro", true),
            new Player("Tom", "Huddlestone", false),
            new Player("Gylfi","Sigurdsson", false),
            new Player("Gareth", "Bale", false),
            new Player("Aaron", "Lennon", false),
            new Player("Paulinho", "Maciel", false),
            new Player("Jermane", "Defoe", false),
            new Player("Emmanuel", "Adebayor", true)
        );
    
        return FXCollections.observableArrayList(players);
      }
    
      private static class StyledTextFieldTableCell extends TextFieldTableCell {
    
        private final ChangeListener injuredListener ;
        private Player previousPlayer ;
    
        StyledTextFieldTableCell() {
          // Seems we have to set a trivial string converter:
          super(new StringConverter() {
            @Override
            public String fromString(String string) {
              return string;
            }
            @Override
            public String toString(String object) {
              return object;
            }
          });
    
          injuredListener = new ChangeListener() {
            @Override
            public void changed(ObservableValue observable,
                Boolean oldValue, Boolean newValue) {
              if (newValue) {
                ensureInjuredStyleClass();
              } else {
                ensureNoInjuredStyleClass();
              }
            }
          };
        }
    
        @Override
        public void updateItem(String item, boolean empty) {
          super.updateItem(item, empty);
          Player currentPlayer = null ;
          TableRow tableRow = getTableRow();
          if (tableRow != null) {
            currentPlayer = tableRow.getItem();
          }
          if (previousPlayer != currentPlayer) {
            if (previousPlayer != null) {
              previousPlayer.injuredProperty().removeListener(injuredListener);
            }
            if (currentPlayer != null) {
              currentPlayer.injuredProperty().addListener(injuredListener);
              if (currentPlayer.isInjured() ) {
                ensureInjuredStyleClass();
              } else if (! currentPlayer.isInjured()) {
                ensureNoInjuredStyleClass();
              }
            }
            previousPlayer = currentPlayer ;
          }
        }
    
        private void ensureNoInjuredStyleClass() {
          while (getStyleClass().contains("injured")) {
            getStyleClass().remove("injured");
          }
        }
        private void ensureInjuredStyleClass() {
          if (! getStyleClass().contains("injured")) {
            getStyleClass().add("injured");
          }
        }
      }
    
      public static class Player {
        private final StringProperty firstName ;
        private final StringProperty lastName ;
        private final BooleanProperty injured ;
        Player(String firstName, String lastName, boolean international) {
          this.firstName = new SimpleStringProperty(this, "firstName", firstName);
          this.lastName = new SimpleStringProperty(this, "lastName", lastName);
          this.injured = new SimpleBooleanProperty(this, "injured", international);
        }
        public String getFirstName() { return firstName.get(); }
        public void setFirstName(String firstName) { this.firstName.set(firstName);}
        public StringProperty firstNameProperty() { return firstName ; }
        public String getLastName() { return lastName.get(); }
        public void setLastName(String lastName) { this.lastName.set(lastName); }
        public StringProperty lastNameProperty() { return lastName ; }
        public boolean isInjured() { return injured.get(); }
        public void setInjured(boolean international) { this.injured.set(international); }
        public BooleanProperty injuredProperty() { return injured ; }
        @Override
        public String toString() {
          return firstName.get() + " " + lastName.get() + (injured.get()?" (injured)":"");
        }
      }
    }
    

    And the css (formattedTableWithTextFields.css):

    @CHARSET "US-ASCII";
    .table-cell.injured .text-field, .table-cell.injured .label {
     -fx-text-fill: red ;
    }
    .table-cell.injured .text {
      -fx-fill: red ;
    }
    

    Post edited by: James_D (slight refactor code, added css)

  • Linux - Nimbus LookAndFeel: Table grid lines do not come

    I use in my java application NimBusLookAndFeel. I tried to show grid lines in the table.

    Following the code works perfectly fine on windows but not on Linux (table grid lines don't appear under linux)

    UIManager.setLookAndFeel ("com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel");
    UIManager.put ("Table.showGrid", true);
    UIManager.put ("Table.intercellSpacing", New Dimension (1,1));

    Following are details of java version on linux

    Java version "1.6.0_12" Java (TM) SE Runtime Environment (build 1.6.0_12 - b04) Java hotspot Server VM (build 11.2 - b01, mixed mode)

    I also tried on JDK 1.6 update 30, but in vain

    It takes overrive after Nimbus UIDefaults http://docs.oracle.com/javase/tutorial/uiswing/lookandfeel/_nimbusDefaults.html

    try {// UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
                for (LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) {
                    if (info.getName().equals("Nimbus")) {
                        UIManager.setLookAndFeel(info.getClassName());
                        UIDefaults defaults = UIManager.getLookAndFeelDefaults();
                        defaults.put("Table.gridColor", new Color (214,217,223));
                        defaults.put("Table.disabled", false);
                        defaults.put("Table.showGrid", true);
                        defaults.put("Table.intercellSpacing", new Dimension(1, 1));
                        break;
                    }
                }
            } catch (Exception e) {
                //e.printStackTrace();
            }
    
  • Alignment of columns of a table using the control variable

    Hi I'm new to Javascript, using only Applescript before.

    I use Indesign 5.5 on Mac and I learn Javascript by adapting old Applescripts I have used for years.

    So, with an existing table, one of the things I want to do is to put alignments in the columns by using a variable. Here's what I've tried so far:

    function setColumnWidthsAndAlignments()
    {
        var myWidths=[29, 23, 13, 13, 13, 13];
        var myAlignments=["leftAlign","leftAlign","centerAlign","centerAlign","rightAlign","rightAlign"];
        var numberOfColumns=myTable.columns.count();
        for (c=0;c<numberOfColumns;c++)
        {
            myTable.columns[c].width=myWidths[c];
            myTable.columns[c].cells.everyItem().texts.everyItem().justification=Justification.myAlignments[c];
        }
    }
    
    

    but I get an error

    -Object does not support the property or method 'myAlignments '.

    If I throw the myAlignments variable and just put for example leftAlign, it works, then maybe I'm not declares the variable correctly?

    I know that I could add a few extra paragraph styles and cell styles and style of the table like that, but I it would be a good learning exercise (more of which I want to limit the number of paragraph in document styles - there enough already!)

    If anyone is really interested, I would like to place the script here and would like to really comment on how the structure could be improved or optimized or simply to tell me if I'm heading in the right direction.

    Thank you and best regards,

    Malcolm

    //Simple table script 1
    
    
    app.scriptPreferences.userInteractionLevel = UserInteractionLevels.interactWithAll; //make sure that user interactivity is switched on ????  why????
    
    
    if(checkForOpenDocs()) //checks to see if there are any open Indesign documents
        {
            if(targetMyTable()) //checks to see if the selection is inside a table - if not, gives an error dialog - if it is, returns variable myTable which can be used to target different parts of the table
                {
                   // selectLastRow();
                    //resetTable();
                    //applyTableTextParaStyle();
                    //removeRules();
                    //applyAlternatingFills();
                    setColumnWidthsAndAlignments();
                    //setRowHeightsAndInsets();
                    
                    
        }
    }
    
    
    function checkForOpenDocs()
    {
        if (app.documents.length!=0)   //there is at least one document open
        {
            myDocument = app.documents.item(0);    //get the id of the frontmost document - might be useful?
            return true;
        }   
        else
        {
            alert("There are no documents open");
            return false;
         }
     }
    
    
    function targetMyTable() //no matter what is selected in the table, change selection to be whole table
    {
        if(app.selection[0]==null) //if there is nothing selected
        {
            alert("There is nothing selected.");
            return false
        }
        var mySelection = app.selection[0];
        
        switch(mySelection.constructor.name)
        {
                                            //When a row, a column, or a range of cells is 
                                            //selected, the type returned is always "Cell"
            case "Cell":
            myTable=mySelection.parent;
            return true
            break;
    
            case "Table":
            myTable=mySelection;
            return true
            break;
    
    
            case "InsertionPoint":
            case "Character":
            case "Word":
            case "TextStyleRange":
            case "Line":
            case "Paragraph":
            case "TextColumn":
            case "Text":
            if(app.selection[0].parent.constructor.name == "Cell")
            {
                myTable=mySelection.parent.parent;
                return true
            }
            else
            {
                alert("The selection is not inside a table."); 
                return false
            }
            break;
    
    
            case "Rectangle":
            case "Oval":
            case "Polygon":
            case "GraphicLine":
            case "TextFrame":
            if(app.selection[0].parent.parent.constructor.name == "Cell")
            {
                myTable=mySelection.parent.parent.parent;
                return true
            }
            else
            {
                alert("The selection is not inside a table."); 
                return false
            }
            break;
    
    
            case "Image":
            case "PDF":
            case "EPS":
            if(app.selection[0].parent.parent.parent.constructor.name == "Cell")
            {
                myTable=mySelection.parent.parent.parent.parent;
                return true
            }
            else
            {
                alert("The selection is not inside a table."); 
                return false
            }
            break;
            
            default:
            break;
        }
    }
    
    
    
    function resetTable()
    {
        myTable.cells.everyItem().clearCellStyleOverrides (true);   
    }
    
    
    function selectLastRow()
        {
        //myTable.cells.itemByRange(0,-1).select();
        myTable.rows.itemByRange(-1,-1).select();
        }
    
    
    function applyTableTextParaStyle()
    {
        myParagraphStyle=myDocument.paragraphStyles.item("•table text");
        myTable.cells.everyItem().texts.everyItem().appliedParagraphStyle = myParagraphStyle;
    }
    
    
    function removeRules()
    {
        myTable.cells.everyItem().topEdgeStrokeWeight=0;
        myTable.cells.everyItem().bottomEdgeStrokeWeight=0;
        myTable.cells.everyItem().leftEdgeStrokeWeight=0;
        myTable.cells.everyItem().rightEdgeStrokeWeight=0;
    }
    
    
    function applyAlternatingFills()
    {
        myColor=myDocument.swatches.item("Black");
        myTable.alternatingFills=AlternatingFillsTypes.alternatingRows;
        myTable.startRowFillColor=myColor;
        myTable.startRowFillTint=20;
        myTable.endRowFillColor=myColor;
        myTable.endRowFillTint = 0;
    }
    
    
    function setColumnWidthsAndAlignments()
    {
        var myWidths=[29, 23, 13, 13, 13, 13];
        var myAlignments=["leftAlign","leftAlign","centerAlign","centerAlign","rightAlign","rightAlign"];
        var numberOfColumns=myTable.columns.count();
        for (c=0;c<numberOfColumns;c++)
        {
            myTable.columns[c].width=myWidths[c];
            myTable.columns[c].cells.everyItem().texts.everyItem().justification=Justification.myAlignments[c];
        }
    }
    
    
    function setRowHeightsAndInsets()
    {
        myTable.rows.everyItem().minimumHeight=1.058;
        myInset=0.5;
        myTable.rows.everyItem().topInset=myInset;
        myTable.rows.everyItem().bottomInset=myInset;
    }
    
    

    Hello

    Welcome

    myAlignments should be properties, not strings. have not read the second part of your post...

    myTable = app.activeDocument.stories[0].tables[0];
    setColumnWidthsAndAlignments(myTable)
    
    function setColumnWidthsAndAlignments(tableObj)
    {
        var myWidths=[29, 23, 13, 13, 13, 13];
        var myAlignments=[Justification.LEFT_ALIGN,Justification.LEFT_ALIGN,Justification.CENTER_ALIGN,Justification.CENTER_ALIGN,Justification.RIGHT_ALIGN,Justification.RIGHT_ALIGN];
        var numberOfColumns=tableObj.columns.count();
        for (c=0;c		   

Maybe you are looking for

  • HP t610 more

    Hello We bought a few thin client (t610 more) the original of the BONE is W2009 shipped, I want to know if it is possible to upgrade to W2007? Thanks in advance

  • Qosmio G20-139: failure of the DVD - D: is not accessible

    Hi I have a six month old Qosmio G20-139without warning I can't access my DVD player now. No disk will not work and the message: -."D:\ is not accessible. The request could not be performed because of an i/o device error" I ran that the pre installed

  • Load balancing

    Bought this router, just waiting to delivery I was wondering the NLB feature, if I have 2 x 10 MB connections, can I download 20 MB or max speed still 10 MB, but 20 MB is balanced on network, IE 2 people can download 10 MB?

  • Can a run of DDR2 PCI E 2.1 graphics ASUS AMD Radeon HD 5450 1 GB Arma 2?

    I want to know if aASUS can of DDR2 PCI E 2.1 AMD Radeon HD 5450 1 GB graphics card run Arma 2 and most of the games on the pc because I have an ATI 1250 x Radeon and it does not work anything good.

  • Failed to load the message when the wifi or data are disabled...

    I get the message "could not load. Please check your internet connection and try again ' when I unlock the screen or disconnect the wifi connection or data.  I am not in a position to say what app it is, how can he know whether the app is the cause?