Permalink
Browse files

Johnathan Giles patch to remove commands from the ribbon

  • Loading branch information...
1 parent 692166d commit 9c8b82768af29e6dde6a277104933149c6a71288 @shemnon shemnon committed Mar 26, 2011
Showing with 61 additions and 0 deletions.
  1. +61 −0 src/main/java/org/pushingpixels/flamingo/api/ribbon/JRibbon.java
@@ -269,6 +269,11 @@ public synchronized void addTaskbarComponent(Component comp) {
this.fireStateChanged();
}
+ /*
+ * Added Remove Tasks from patch provided by Jonathan Giles Jan 2009
+ * http://markmail.org/message/vzw3hrntr6qsdlu3
+ */
+
/**
* Removes the specified taskbar component from this ribbon.
*
@@ -283,6 +288,14 @@ public synchronized void removeTaskbarComponent(Component comp) {
}
/**
+ * Removes all components added to the taskbar of the ribbon.
+ */
+ public void removeAllTaskbarComponents() {
+ this.taskbarComponents.clear();
+ this.fireStateChanged();
+ }
+
+ /**
* Adds the specified task to this ribbon.
*
* @param task
@@ -304,6 +317,54 @@ public synchronized void addTask(RibbonTask task) {
}
/**
+ * Removes the task at the specified position, if it represents a valid task.
+ * Throws an {@link IndexOutOfBoundsException} if not.
+ *
+ * @param pos
+ * The position of the task to remove.
+ */
+ public void removeTask(int pos) {
+ if (pos >= getTaskCount()) {
+ throw new IndexOutOfBoundsException("task position '"+pos+"' exceeds number of tasks in ribbon ('"+getTaskCount()+"')");
+ }
+
+ removeTask(getTask(pos));
+ }
+
+ /**
+ * Removes the given task from the ribbon. If this is the currently visible task, the
+ * ribbon will move to the task to its left, unless the removed task is the left-most,
+ * in which case it will move to the next task to the right.
+ *
+ * @param task The ribbon task to be removed from the panel.
+ */
+ public void removeTask(RibbonTask task) {
+ if (task == null) {
+ throw new IllegalArgumentException("RibbonTask can not be null");
+ }
+
+ int posOfTask = this.tasks.indexOf(task);
+ this.tasks.remove(task);
+
+ if (getSelectedTask().equals(task) && tasks.size() > 0) {
+ RibbonTask newTask = getTask(posOfTask == 0 ? 1 : posOfTask
+- 1);
+ setSelectedTask(newTask);
+ }
+
+ this.fireStateChanged();
+ }
+
+ /**
+ * Removes all tasks from the ribbon.
+ */
+ public void removeAllTasks() {
+ this.tasks.clear();
+ this.contextualTaskGroups.clear();
+ this.fireStateChanged();
+ }
+
+ /**
* Configures the help button of this ribbon.
*
* @param helpIcon

0 comments on commit 9c8b827

Please sign in to comment.