Java Code Examples for org.jdesktop.swingx.JXTaskPane#setCollapsed()

The following examples show how to use org.jdesktop.swingx.JXTaskPane#setCollapsed() . 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: StyleDefinitionEditorDialog.java    From pentaho-reporting with GNU Lesser General Public License v2.1 5 votes vote down vote up
protected Component createContentPane() {
  taskPane = new JXTaskPane();
  taskPane.setSpecial( true );
  taskPane.setCollapsed( false );
  taskPane.setTitle( Messages.getString( "StyleDefinitionEditorDialog.TaskTitle" ) );
  taskPane.add( new AddStyleRuleAction( editorContext ) );

  taskPaneContainer = new JXTaskPaneContainer();
  taskPaneContainer.add( taskPane );
  return new JScrollPane( taskPaneContainer );
}
 
Example 2
Source File: ExpressionPropertyDialog.java    From rapidminer-studio with GNU Affero General Public License v3.0 4 votes vote down vote up
/**
 * Updates the function panel
 */
private void updateFunctions() {

	// remove all content
	functionsPanel.removeAll();
	functionsPanel.setLayout(functionButtonsLayout);
	functionCategoryTaskPanes = new HashMap<>();
	GridBagConstraints gbc = new GridBagConstraints();
	gbc.fill = GridBagConstraints.HORIZONTAL;
	gbc.weightx = 1;
	gbc.gridx = 0;
	gbc.gridy = 0;
	int totalFunctionCount = 0;

	// get the filtered model (the FunctionDescriptions we want to display)
	Map<String, List<FunctionDescription>> filteredModel = functionModel.getFilteredModel();
	String filterName = functionModel.getFilterNameString();
	boolean searchStringGiven = !filterName.isEmpty();

	for (String functionGroup : filteredModel.keySet()) {

		boolean perfectMatch = false;
		JXTaskPane functionCategoryTaskPane = new JXTaskPane();
		functionCategoryTaskPane.setName(functionGroup);
		List<FunctionDescription> list = functionModel.getFilteredModel(functionGroup);
		totalFunctionCount += list.size();

		for (FunctionDescription function : list) {
			// create the panels for the functions, register the observer and add them to the
			// related category
			final FunctionDescriptionPanel funcDescPanel = new FunctionDescriptionPanel(function);
			funcDescPanel.registerObserver(functionObserver);
			functionCategoryTaskPane.add(funcDescPanel);
			if (!perfectMatch && searchStringGiven) {
				// check for function name equality without brackets and with brackets
				String functionName = function.getDisplayName().split("\\(")[0];
				if (filterName.toLowerCase(Locale.ENGLISH).equals(functionName.toLowerCase(Locale.ENGLISH)) || filterName
						.toLowerCase(Locale.ENGLISH).equals(function.getDisplayName().toLowerCase(Locale.ENGLISH))) {
					perfectMatch = true;
				}
			}
		}

		functionCategoryTaskPane.setTitle(functionGroup);
		functionCategoryTaskPane.setAnimated(false);

		// if there is only one category in the filtered model, open the task pane
		if (filteredModel.keySet().size() == 1) {
			functionCategoryTaskPane.setCollapsed(false);
		} else {
			functionCategoryTaskPane.setCollapsed(true);
		}

		if (perfectMatch) {
			functionCategoryTaskPane.setCollapsed(false);
		}

		functionCategoryTaskPanes.put(functionGroup, functionCategoryTaskPane);

		gbc.ipady = 10;
		functionsPanel.add(functionCategoryTaskPane, gbc);
		gbc.gridy += 1;
	}

	// if the number of result functions is clear, open the task panes
	// (if you can see all categories even if they are opened)
	if (totalFunctionCount <= MAX_NMBR_FUNCTIONS_SHOWN) {
		for (JXTaskPane taskPane : functionCategoryTaskPanes.values()) {
			taskPane.setCollapsed(false);
		}
	}

	// if there are no results, show a simple message
	if (filteredModel.isEmpty()) {
		gbc.ipady = 10;
		functionsPanel.add(new JLabel(MESSAGE_NO_RESULTS), gbc);
	}

	functionsPanel.revalidate();
}