Search Results

Search found 4 results on 1 pages for 'selectionmodel'.

Page 1/1 | 1 

  • In GWT-EXT checkboxtree how to handle single selection of tree nodes?

    - by RAS
    hi, I'm working on checkBoxTree in GWT-EXT 2.0.3 with Java. My aim is to get a selectionModel which allows me to select(check) only one TreeNode at a time. If I select another TreeNode after selecting one then, the previous one should be unchecked. I've tried using DefaultSelectionModel with TreePanel, but either I've not used it properly or it's working only for selection of TreeNode not for checking a TreeNode. Can anyone help me in this? Thanks in advance.

    Read the article

  • Problem in setting backgound color to my TreeCellRenderer

    - by Sunil Kumar Sahoo
    Hi I have cretaed my own renderer. I want the back ground should be blue. I have set background color as blue also. But I donot know what is tha problem that the background color of my renderer always seems to be white. I have post the code. please help where I am wrong so that the background color becomes white. class CheckTreeCellRenderer extends JPanel implements TreeCellRenderer { private CheckTreeSelectionModel selectionModel; private MyRenderer delegate; private TristateCheckBox checkBox = new TristateCheckBox("", null, true); public static final State NOT_SELECTED = new State(); public static final State SELECTED = new State(); public static final State DONT_CARE = new State(); public CheckTreeCellRenderer(MyRenderer delegate, CheckTreeSelectionModel selectionModel) { this.delegate = delegate; this.selectionModel = selectionModel; setLayout(new BorderLayout()); setOpaque(true); setBackground(new Color(207, 219, 234)); checkBox.setState(Boolean.TRUE); checkBox.setOpaque(true); checkBox.setBackground(new Color(207, 219, 234)); } public Component getTreeCellRendererComponent(JTree tree, Object value, boolean selected, boolean expanded, boolean leaf, int row, boolean hasFocus) { Component renderer = delegate.getTreeCellRendererComponent(tree, value, selected, expanded, leaf, row, hasFocus); TreePath path = tree.getPathForRow(row); if (path != null) { if (selectionModel.isPathSelected(path, true)) { checkBox.setState(Boolean.TRUE); } else { checkBox.setState(selectionModel.isPartiallySelected(path) ? null : Boolean.FALSE); } } renderer.setBackground(new Color(207, 219, 234)); tree.setOpaque(true); tree.setBackground(new Color(207, 219, 234)); this.setOpaque(true); this.setBackground(new Color(207, 219, 234)); add(checkBox, BorderLayout.WEST); add(renderer, BorderLayout.CENTER); return this; } }

    Read the article

  • javafx tableview get selected data from ObservableList

    - by user3717821
    i am working on a javafx project and i need your help . while i am trying to get selected data from table i can get selected data from normal cell but can't get data from ObservableList inside tableview. code for my database: -- phpMyAdmin SQL Dump -- version 4.0.4 -- http://www.phpmyadmin.net -- -- Host: localhost -- Generation Time: Jun 10, 2014 at 06:20 AM -- Server version: 5.1.33-community -- PHP Version: 5.4.12 SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO"; SET time_zone = "+00:00"; /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; /*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; /*!40101 SET NAMES utf8 */; -- -- Database: `test` -- -- -------------------------------------------------------- -- -- Table structure for table `customer` -- CREATE TABLE IF NOT EXISTS `customer` ( `col0` int(11) NOT NULL, `col1` varchar(255) DEFAULT NULL, `col2` int(11) DEFAULT NULL, PRIMARY KEY (`col0`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- -- Dumping data for table `customer` -- INSERT INTO `customer` (`col0`, `col1`, `col2`) VALUES (12, 'adasdasd', 231), (22, 'adasdasd', 231), (212, 'adasdasd', 231); /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; /*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; my javafx codes: import java.sql.Connection; import java.sql.DriverManager; import java.sql.ResultSet; import java.sql.SQLException; import java.util.Map; import javafx.application.Application; import javafx.beans.property.SimpleStringProperty; 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.TableColumn.CellDataFeatures; import javafx.scene.control.TablePosition; import javafx.scene.control.TableView; import javafx.scene.control.TableView.TableViewSelectionModel; import javafx.scene.control.cell.ChoiceBoxTableCell; import javafx.scene.control.cell.TextFieldTableCell; import javafx.scene.layout.BorderPane; import javafx.stage.Stage; import javafx.util.Callback; import javafx.util.StringConverter; class DBConnector { private static Connection conn; private static String url = "jdbc:mysql://localhost/test"; private static String user = "root"; private static String pass = "root"; public static Connection connect() throws SQLException{ try{ Class.forName("com.mysql.jdbc.Driver").newInstance(); }catch(ClassNotFoundException cnfe){ System.err.println("Error: "+cnfe.getMessage()); }catch(InstantiationException ie){ System.err.println("Error: "+ie.getMessage()); }catch(IllegalAccessException iae){ System.err.println("Error: "+iae.getMessage()); } conn = DriverManager.getConnection(url,user,pass); return conn; } public static Connection getConnection() throws SQLException, ClassNotFoundException{ if(conn !=null && !conn.isClosed()) return conn; connect(); return conn; } } public class DynamicTable extends Application{ Object newValue; //TABLE VIEW AND DATA private ObservableList<ObservableList> data; private TableView<ObservableList> tableview; //MAIN EXECUTOR public static void main(String[] args) { launch(args); } //CONNECTION DATABASE public void buildData(){ tableview.setEditable(true); Callback<TableColumn<Map, String>, TableCell<Map, String>> cellFactoryForMap = new Callback<TableColumn<Map, String>, TableCell<Map, String>>() { @Override public TableCell call(TableColumn p) { return new TextFieldTableCell(new StringConverter() { @Override public String toString(Object t) { return t.toString(); } @Override public Object fromString(String string) { return string; } }); } }; Connection c ; data = FXCollections.observableArrayList(); try{ c = DBConnector.connect(); //SQL FOR SELECTING ALL OF CUSTOMER String SQL = "SELECT * from CUSTOMer"; //ResultSet ResultSet rs = c.createStatement().executeQuery(SQL); /********************************** * TABLE COLUMN ADDED DYNAMICALLY * **********************************/ for(int i=0 ; i<rs.getMetaData().getColumnCount(); i++){ //We are using non property style for making dynamic table final int j = i; TableColumn col = new TableColumn(rs.getMetaData().getColumnName(i+1)); if(j==1){ final ObservableList<String> logLevelList = FXCollections.observableArrayList("FATAL", "ERROR", "WARN", "INFO", "INOUT", "DEBUG"); col.setCellFactory(ChoiceBoxTableCell.forTableColumn(logLevelList)); tableview.getColumns().addAll(col); } else{ col.setCellValueFactory(new Callback<CellDataFeatures<ObservableList,String>,ObservableValue<String>>(){ public ObservableValue<String> call(CellDataFeatures<ObservableList, String> param) { return new SimpleStringProperty(param.getValue().get(j).toString()); } }); tableview.getColumns().addAll(col); } if(j!=1) col.setCellFactory(cellFactoryForMap); System.out.println("Column ["+i+"] "); } /******************************** * Data added to ObservableList * ********************************/ while(rs.next()){ //Iterate Row ObservableList<String> row = FXCollections.observableArrayList(); for(int i=1 ; i<=rs.getMetaData().getColumnCount(); i++){ //Iterate Column row.add(rs.getString(i)); } System.out.println("Row [1] added "+row ); data.add(row); } //FINALLY ADDED TO TableView tableview.setItems(data); }catch(Exception e){ e.printStackTrace(); System.out.println("Error on Building Data"); } } @Override public void start(Stage stage) throws Exception { //TableView Button showDataButton = new Button("Add"); showDataButton.setOnAction(new EventHandler<ActionEvent>() { public void handle(ActionEvent event) { ObservableList<String> row = FXCollections.observableArrayList(); for(int i=1 ; i<=3; i++){ //Iterate Column row.add("asdasd"); } data.add(row); //FINALLY ADDED TO TableView tableview.setItems(data); } }); tableview = new TableView(); buildData(); //Main Scene BorderPane root = new BorderPane(); root.setCenter(tableview); root.setBottom(showDataButton); Scene scene = new Scene(root,500,500); stage.setScene(scene); stage.show(); tableview.getSelectionModel().selectedItemProperty().addListener(new ChangeListener() { @Override public void changed(ObservableValue observableValue, Object oldValue, Object newValue) { //Check whether item is selected and set value of selected item to Label if (tableview.getSelectionModel().getSelectedItem() != null) { TableViewSelectionModel selectionModel = tableview.getSelectionModel(); ObservableList selectedCells = selectionModel.getSelectedCells(); TablePosition tablePosition = (TablePosition) selectedCells.get(0); Object val = tablePosition.getTableColumn().getCellData(newValue); System.out.println("Selected Value " + val); System.out.println("Selected row " + newValue); } } }); } } please help me..

    Read the article

  • Written a resharper plugin that modifies the TextControl?

    - by Ajaxx
    Resharper claims to eat it's own dogfood, specifically, they claim that many of the features of Resharper are written ontop of R# (OpenAPI). I'm writing a simple plugin to fix up comments of the current document of a selection. When this plugin is run, it throws an exception as follows: Document can be modified inside a command scope only I've researched the error and can't find anything to help with this, so I'm hoping that possibly, you've written a plugin to accomplish this. If not, I hope the snippet is enough to help others get their own plugins underway. using System; using System.IO; using System.Windows.Forms; using JetBrains.ActionManagement; using JetBrains.DocumentModel; using JetBrains.IDE; using JetBrains.TextControl; using JetBrains.Util; namespace TinkerToys.Actions { [ActionHandler("TinkerToys.RewriteComment")] public class RewriteCommentAction : IActionHandler { #region Implementation of IActionHandler /// <summary> /// Updates action visual presentation. If presentation.Enabled is set to false, Execute /// will not be called. /// </summary> /// <param name="context">DataContext</param> /// <param name="presentation">presentation to update</param> /// <param name="nextUpdate">delegate to call</param> public bool Update(IDataContext context, ActionPresentation presentation, DelegateUpdate nextUpdate) { ITextControl textControl = context.GetData(DataConstants.TEXT_CONTROL); return textControl != null; } /// <summary> /// Executes action. Called after Update, that set ActionPresentation.Enabled to true. /// </summary> /// <param name="context">DataContext</param> /// <param name="nextExecute">delegate to call</param> public void Execute(IDataContext context, DelegateExecute nextExecute) { ITextControl textControl = context.GetData(DataConstants.TEXT_CONTROL); if (textControl != null) { TextRange textSelectRange; ISelectionModel textSelectionModel = textControl.SelectionModel; if ((textSelectionModel != null) && textSelectionModel.HasSelection()) { textSelectRange = textSelectionModel.Range; } else { textSelectRange = new TextRange(0, textControl.Document.GetTextLength()); } IDocument textDocument = textControl.Document; String textSelection = textDocument.GetText(textSelectRange); if (textSelection != null) { StringReader sReader = new StringReader(textSelection); StringWriter sWriter = new StringWriter(); Converter.Convert(sReader, sWriter); textSelection = sWriter.ToString(); textDocument.ReplaceText(textSelectRange, textSelection); } } } #endregion } } So what is this command scope it wants so badly? I had some additional logging in this prior to posting it so I'm absolutely certain that both the range and text are valid. In addition, the error seems to indicate that I'm missing some scope that I've been, as yet, unable to find.

    Read the article

1