com.jidesoft.swing.SearchableUtils Java Examples

The following examples show how to use com.jidesoft.swing.SearchableUtils. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TabPanelGoods.java    From mars-sim with GNU General Public License v3.0 4 votes vote down vote up
public void initializeUI() {
		uiDone = true;
		
		// Prepare goods label panel.
		WebPanel goodsLabelPanel = new WebPanel(new FlowLayout(FlowLayout.CENTER));
		topContentPanel.add(goodsLabelPanel);

		// Prepare goods label.
		WebLabel titleLabel = new WebLabel(Msg.getString("TabPanelGoods.label"), WebLabel.CENTER); //$NON-NLS-1$
		titleLabel.setFont(new Font("Serif", Font.BOLD, 16));
		//titleLabel.setForeground(new Color(102, 51, 0)); // dark brown
		goodsLabelPanel.add(titleLabel);

		// Create scroll panel for the outer table panel.
		WebScrollPane goodsScrollPane = new WebScrollPane();
		goodsScrollPane.setPreferredSize(new Dimension(250, 300));
		// increase vertical mousewheel scrolling speed for this one
		goodsScrollPane.getVerticalScrollBar().setUnitIncrement(16);
		centerContentPanel.add(goodsScrollPane);

		// Prepare goods table model.
		goodsTableModel = new GoodsTableModel(((Settlement) unit).getGoodsManager());

		// Prepare goods table.
		goodsTable = new ZebraJTable(goodsTableModel);
		goodsScrollPane.setViewportView(goodsTable);
		goodsTable.setRowSelectionAllowed(true);
		
		// Override default cell renderer for formatting double values.
		goodsTable.setDefaultRenderer(Double.class, new NumberCellRenderer(2, true));
		
		goodsTable.getColumnModel().getColumn(0).setPreferredWidth(140);
		goodsTable.getColumnModel().getColumn(1).setPreferredWidth(80);
		
		// Added the two methods below to make all heatTable columns
		// Resizable automatically when its Panel resizes
		goodsTable.setPreferredScrollableViewportSize(new Dimension(225, -1));
		//goodsTable.setAutoResizeMode(WebTable.AUTO_RESIZE_ALL_COLUMNS);

		// Align the preference score to the center of the cell
		DefaultTableCellRenderer renderer = new DefaultTableCellRenderer();
		renderer.setHorizontalAlignment(SwingConstants.RIGHT);
		goodsTable.getColumnModel().getColumn(0).setCellRenderer(renderer);
//		goodsTable.getColumnModel().getColumn(1).setCellRenderer(renderer);

		// Added sorting
		goodsTable.setAutoCreateRowSorter(true);

		TableStyle.setTableStyle(goodsTable);

     	// Added goodsSearchable
     	TableSearchable searchable = SearchableUtils.installSearchable(goodsTable);
        searchable.setPopupTimeout(5000);
     	searchable.setCaseSensitive(false);
        searchable.setMainIndex(0); // -1 = search for all columns

	}
 
Example #2
Source File: TabPanelOrganization.java    From mars-sim with GNU General Public License v3.0 4 votes vote down vote up
public void initializeUI() {
		uiDone = true;		

		UnitManager unitManager = Simulation.instance().getUnitManager();
		LocalUnitManagerListener unitManagerListener = new LocalUnitManagerListener();
		unitManager.addUnitManagerListener(unitManagerListener);

		// Create label panel.
		JPanel titlePanel = new JPanel(new FlowLayout(FlowLayout.CENTER));
		topContentPanel.add(titlePanel);

		// Prepare label
		JLabel tlabel = new JLabel(Msg.getString("TabPanelStructure.title"), JLabel.CENTER); //$NON-NLS-1$
		tlabel.setFont(new Font("Serif", Font.BOLD, 16));
		// tlabel.setForeground(new Color(102, 51, 0)); // dark brown
		titlePanel.add(tlabel);

		// Prepare info panel.
		infoPanel = new JPanel(new GridLayout(1, 2, 0, 0));
//		infoPanel.setBorder(new MarsPanelBorder());
		centerContentPanel.add(infoPanel, BorderLayout.NORTH);

		// Create label panel.
		JPanel labelPanel = new JPanel(new FlowLayout(FlowLayout.CENTER));
		infoPanel.add(labelPanel);

		// Prepare label
		JLabel label = new JLabel(Msg.getString("TabPanelStructure.label"), JLabel.CENTER); //$NON-NLS-1$
		labelPanel.add(label);

		root = new DefaultMutableTreeNode(settlement.getName());

		tree = new JTree(root);
		tree.setVisibleRowCount(8);
		tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
		//Listen for when the selection changes.
//	    tree.addTreeSelectionListener(new MyTreeModelListener());
	    
		// Use treeSearchable
		TreeSearchable searchable = SearchableUtils.installSearchable(tree);
		searchable.setPopupTimeout(5000);
		searchable.setCaseSensitive(false);
		
		defaultTreeModel = new DefaultTreeModel(root);
		tree.setModel(defaultTreeModel);

		centerContentPanel.add(new JScrollPane(tree, ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS,
				ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER), BorderLayout.CENTER);
	
		buildTreeNodes();
		
		initNodes();
	}
 
Example #3
Source File: MonitorWindow.java    From mars-sim with GNU General Public License v3.0 4 votes vote down vote up
public void createSearchableBar(JTable table) {
	// Searchable searchable = null;
	// SearchableBar _tableSearchableBar = null;

	if (searchable != null)
		SearchableUtils.uninstallSearchable(searchable);

	if (table != null) {
		// SearchableUtils.uninstallSearchable(searchable);
		searchable = SearchableUtils.installSearchable(table);
		// searchable.setRepeats(true);
		searchable.setPopupTimeout(5000);
		searchable.setCaseSensitive(false);
		searchable.setHideSearchPopupOnEvent(false);
		searchable.setWildcardEnabled(true);
		searchable.setHeavyweightComponentEnabled(true);
		// searchable.setSearchableProvider(searchableProvider)
		searchable.setMismatchForeground(Color.PINK);
		// WildcardSupport WildcardSupport = new WildcardSupport();
		// searchable.setWildcardSupport(new WildcardSupport());

		if (searchBar != null) {
			searchBar.setSearchingText("");
			statusPanel.remove(searchBar);
			searchBar = null;
		}

		searchBar = new SearchableBar(searchable);
		searchBar.setSearchingText("");
		searchBar.setCompact(true);
		// _tableSearchableBar.setSearchingText("*" +
		// _tableSearchableBar.getSearchingText());

		// _tableSearchableBar.setVisibleButtons(1);
		TooltipManager.setTooltip(searchBar, "Use wildcards (*, +, ?) for searching. e.g. '*DaVinci' ");
		
		((TableSearchable) searchable).setMainIndex(-1); // -1 = search for all columns
		searchBar.setVisibleButtons(SearchableBar.SHOW_NAVIGATION | SearchableBar.SHOW_MATCHCASE
				| SearchableBar.SHOW_WHOLE_WORDS | SearchableBar.SHOW_STATUS);
		searchBar.setName(table.getName());
		searchBar.setShowMatchCount(true);
		searchBar.setVisible(true);

		statusPanel.add(searchBar); // , BorderLayout.AFTER_LAST_LINE);

		// pack();

		// statusPanel.add(_tableSearchableBar); // , BorderLayout.AFTER_LAST_LINE);
		statusPanel.invalidate();
		statusPanel.revalidate();
	}
}
 
Example #4
Source File: CustomCrsPanel.java    From snap-desktop with GNU General Public License v3.0 4 votes vote down vote up
private void createUI() {
    final TableLayout tableLayout = new TableLayout(2);
    setLayout(tableLayout);
    tableLayout.setTableFill(TableLayout.Fill.HORIZONTAL);
    tableLayout.setTablePadding(4, 4);
    tableLayout.setTableAnchor(TableLayout.Anchor.WEST);

    tableLayout.setColumnWeightX(0, 0.0);
    tableLayout.setColumnWeightX(1, 1.0);
    tableLayout.setCellColspan(2, 0, 2);
    tableLayout.setCellAnchor(2, 0, TableLayout.Anchor.EAST);
    tableLayout.setCellFill(2, 0, TableLayout.Fill.NONE);

    final JLabel datumLabel = new JLabel("Geodetic datum:");
    final JLabel projectionLabel = new JLabel("Projection:");

    projectionComboBox = new JComboBox<>(crsProviderSet.toArray(new AbstractCrsProvider[crsProviderSet.size()]));
    projectionComboBox.setEditable(false); // combobox searchable only works when combobox is not editable.
    final ComboBoxSearchable methodSearchable = new CrsProviderSearchable(projectionComboBox);
    methodSearchable.installListeners();
    projectionComboBox.setRenderer(new CrsProviderCellRenderer());

    datumComboBox = new JComboBox<>(datumSet.toArray(new GeodeticDatum[datumSet.size()]));
    datumComboBox.setEditable(false); // combobox searchable only works when combobox is not editable.
    SearchableUtils.installSearchable(datumComboBox);
    datumComboBox.setRenderer(new IdentifiedObjectCellRenderer());
    final ComboBoxSearchable datumSearchable = new IdentifiedObjectSearchable(datumComboBox);
    datumSearchable.installListeners();

    paramButton = new JButton("Projection Parameters...");
    paramButton.addActionListener(new ParameterButtonListener());
    add(datumLabel);
    add(datumComboBox);
    add(projectionLabel);
    add(projectionComboBox);
    add(paramButton);
    addPropertyChangeListener("enabled", evt -> updateEnableState((Boolean) evt.getNewValue()));
    final BindingContext context = new BindingContext(vc);
    context.bind(OPERATION_WRAPPER, projectionComboBox);
    context.bind(DATUM, datumComboBox);
}