View | Details | Raw Unified | Return to bug 194529 | Differences between
and this patch

Collapse All | Expand All

(-)src/org/eclipse/pde/internal/ui/editor/plugin/ExtensionsSection.java (-22 / +42 lines)
Lines 74-79 Link Here
74
import org.eclipse.swt.custom.BusyIndicator;
74
import org.eclipse.swt.custom.BusyIndicator;
75
import org.eclipse.swt.events.DisposeEvent;
75
import org.eclipse.swt.events.DisposeEvent;
76
import org.eclipse.swt.events.DisposeListener;
76
import org.eclipse.swt.events.DisposeListener;
77
import org.eclipse.swt.events.ModifyEvent;
78
import org.eclipse.swt.events.ModifyListener;
77
import org.eclipse.swt.graphics.Cursor;
79
import org.eclipse.swt.graphics.Cursor;
78
import org.eclipse.swt.graphics.Image;
80
import org.eclipse.swt.graphics.Image;
79
import org.eclipse.swt.widgets.Composite;
81
import org.eclipse.swt.widgets.Composite;
Lines 239-244 Link Here
239
		createSectionToolbar(section, toolkit);
241
		createSectionToolbar(section, toolkit);
240
		// Create the adapted listener for the filter entry field
242
		// Create the adapted listener for the filter entry field
241
		fFilteredTree.createUIListenerEntryFilter(this);
243
		fFilteredTree.createUIListenerEntryFilter(this);
244
		fFilteredTree.getFilterControl().addModifyListener(new ModifyListener() {
245
			public void modifyText(ModifyEvent e) {
246
				StructuredViewer viewer = getStructuredViewerPart().getViewer();
247
				IStructuredSelection ssel = (IStructuredSelection)viewer.getSelection();
248
				updateButtons(ssel.size() != 1 ? null : ssel.getFirstElement());
249
			}
250
		});
242
	}
251
	}
243
	
252
	
244
	/**
253
	/**
Lines 275-281 Link Here
275
	
284
	
276
	protected void selectionChanged(IStructuredSelection selection) {
285
	protected void selectionChanged(IStructuredSelection selection) {
277
		getPage().getPDEEditor().setSelection(selection);
286
		getPage().getPDEEditor().setSelection(selection);
278
		updateUpDownButtons(selection.getFirstElement());
287
		updateButtons(selection.getFirstElement());
279
		getTreePart().setButtonEnabled(1, isSelectionEditable(selection));
288
		getTreePart().setButtonEnabled(1, isSelectionEditable(selection));
280
	}
289
	}
281
	protected void handleDoubleClick(IStructuredSelection selection) {
290
	protected void handleDoubleClick(IStructuredSelection selection) {
Lines 1046-1052 Link Here
1046
			}
1055
			}
1047
		}
1056
		}
1048
	}
1057
	}
1049
	private void updateUpDownButtons(Object item) {
1058
	
1059
	private void updateButtons(Object item) {
1050
		if (getPage().getModel().isEditable() == false)
1060
		if (getPage().getModel().isEditable() == false)
1051
			return;
1061
			return;
1052
		boolean sorted = fSortAction != null && fSortAction.isChecked();
1062
		boolean sorted = fSortAction != null && fSortAction.isChecked();
Lines 1056-1083 Link Here
1056
			return;
1066
			return;
1057
		}
1067
		}
1058
		
1068
		
1069
		boolean filtered = fFilteredTree.isFiltered();
1070
		boolean addEnabled = true;
1059
		boolean upEnabled = false;
1071
		boolean upEnabled = false;
1060
		boolean downEnabled = false;
1072
		boolean downEnabled = false;
1061
		if (item instanceof IPluginElement) {
1073
		if (filtered) {
1062
			IPluginElement element = (IPluginElement) item;
1074
			// Fix for bug 194529 and bug 194828
1063
			IPluginParent parent = (IPluginParent) element.getParent();
1075
			addEnabled = false;
1064
			// check up
1076
			upEnabled = false;
1065
			int index = parent.getIndexOf(element);
1077
			downEnabled = false;
1066
			if (index > 0)
1067
				upEnabled = true;
1068
			if (index < parent.getChildCount() - 1)
1069
				downEnabled = true;
1070
		} else if (item instanceof IPluginExtension) {
1071
			IPluginExtension extension = (IPluginExtension) item;
1072
			IExtensions extensions = (IExtensions) extension.getParent();
1073
			int index = extensions.getIndexOf(extension);
1074
			int size = extensions.getExtensions().length;
1075
			if (index > 0)
1076
				upEnabled = true;
1077
			if (index < size - 1)
1078
				downEnabled = true;
1079
		}
1078
		}
1080
		
1079
		else {
1080
			if (item instanceof IPluginElement) {
1081
				IPluginElement element = (IPluginElement) item;
1082
				IPluginParent parent = (IPluginParent) element.getParent();
1083
				// check up
1084
				int index = parent.getIndexOf(element);
1085
				if (index > 0)
1086
					upEnabled = true;
1087
				if (index < parent.getChildCount() - 1)
1088
					downEnabled = true;
1089
			} else if (item instanceof IPluginExtension) {
1090
				IPluginExtension extension = (IPluginExtension) item;
1091
				IExtensions extensions = (IExtensions) extension.getParent();
1092
				int index = extensions.getIndexOf(extension);
1093
				int size = extensions.getExtensions().length;
1094
				if (index > 0)
1095
					upEnabled = true;
1096
				if (index < size - 1)
1097
					downEnabled = true;
1098
			}
1099
		}
1100
		getTreePart().setButtonEnabled(0, addEnabled);
1081
		getTreePart().setButtonEnabled(3, upEnabled);
1101
		getTreePart().setButtonEnabled(3, upEnabled);
1082
		getTreePart().setButtonEnabled(4, downEnabled);
1102
		getTreePart().setButtonEnabled(4, downEnabled);
1083
	}
1103
	}
Lines 1095-1101 Link Here
1095
		if (fSortAction.equals(event.getSource()) && IAction.RESULT.equals(event.getProperty())) {
1115
		if (fSortAction.equals(event.getSource()) && IAction.RESULT.equals(event.getProperty())) {
1096
			StructuredViewer viewer = getStructuredViewerPart().getViewer();
1116
			StructuredViewer viewer = getStructuredViewerPart().getViewer();
1097
			IStructuredSelection ssel = (IStructuredSelection)viewer.getSelection();
1117
			IStructuredSelection ssel = (IStructuredSelection)viewer.getSelection();
1098
			updateUpDownButtons(ssel.size() != 1 ? null : ssel.getFirstElement());
1118
			updateButtons(ssel.size() != 1 ? null : ssel.getFirstElement());
1099
		}
1119
		}
1100
	}
1120
	}
1101
1121
(-)src/org/eclipse/pde/internal/ui/editor/plugin/FormFilteredTree.java (+8 lines)
Lines 121-124 Link Here
121
		});
121
		});
122
	}
122
	}
123
	
123
	
124
	/**
125
	 * @return a boolean indicating whether the tree is filtered or not.
126
	 */
127
	public boolean isFiltered() {
128
		String filterText = getFilterControl().getText();
129
		boolean filtered = (filterText != null && filterText.length() > 0 && !filterText.equals(getInitialText()));
130
		return filtered;
131
	}
124
}
132
}

Return to bug 194529