Lines 1-5
Link Here
|
1 |
/******************************************************************************* |
1 |
/******************************************************************************* |
2 |
* Copyright (c) 2000, 2011 IBM Corporation and others. |
2 |
* Copyright (c) 2000, 2012 IBM Corporation and others. |
3 |
* All rights reserved. This program and the accompanying materials |
3 |
* All rights reserved. This program and the accompanying materials |
4 |
* are made available under the terms of the Eclipse Public License v1.0 |
4 |
* are made available under the terms of the Eclipse Public License v1.0 |
5 |
* which accompanies this distribution, and is available at |
5 |
* which accompanies this distribution, and is available at |
Lines 8-19
Link Here
|
8 |
* Contributors: |
8 |
* Contributors: |
9 |
* IBM Corporation - initial API and implementation |
9 |
* IBM Corporation - initial API and implementation |
10 |
* Peter Friese <peter.friese@gentleware.com> - bug 194529, bug 196867 |
10 |
* Peter Friese <peter.friese@gentleware.com> - bug 194529, bug 196867 |
|
|
11 |
* Sascha Becher <s.becher@qualitype.com> - bug 360894 |
11 |
*******************************************************************************/ |
12 |
*******************************************************************************/ |
12 |
package org.eclipse.pde.internal.ui.editor.plugin; |
13 |
package org.eclipse.pde.internal.ui.editor.plugin; |
13 |
|
14 |
|
14 |
import java.util.*; |
15 |
import java.util.*; |
15 |
import org.eclipse.core.resources.IProject; |
16 |
import org.eclipse.core.resources.IProject; |
16 |
import org.eclipse.core.runtime.*; |
17 |
import org.eclipse.core.runtime.*; |
|
|
18 |
import org.eclipse.core.runtime.jobs.*; |
17 |
import org.eclipse.jface.action.*; |
19 |
import org.eclipse.jface.action.*; |
18 |
import org.eclipse.jface.dialogs.IMessageProvider; |
20 |
import org.eclipse.jface.dialogs.IMessageProvider; |
19 |
import org.eclipse.jface.util.IPropertyChangeListener; |
21 |
import org.eclipse.jface.util.IPropertyChangeListener; |
Lines 32-42
Link Here
|
32 |
import org.eclipse.pde.internal.core.text.plugin.PluginBaseNode; |
34 |
import org.eclipse.pde.internal.core.text.plugin.PluginBaseNode; |
33 |
import org.eclipse.pde.internal.ui.*; |
35 |
import org.eclipse.pde.internal.ui.*; |
34 |
import org.eclipse.pde.internal.ui.editor.*; |
36 |
import org.eclipse.pde.internal.ui.editor.*; |
35 |
import org.eclipse.pde.internal.ui.editor.actions.CollapseAction; |
37 |
import org.eclipse.pde.internal.ui.editor.actions.*; |
36 |
import org.eclipse.pde.internal.ui.editor.actions.SortAction; |
|
|
37 |
import org.eclipse.pde.internal.ui.editor.contentassist.XMLElementProposalComputer; |
38 |
import org.eclipse.pde.internal.ui.editor.contentassist.XMLElementProposalComputer; |
38 |
import org.eclipse.pde.internal.ui.elements.DefaultContentProvider; |
39 |
import org.eclipse.pde.internal.ui.elements.DefaultContentProvider; |
39 |
import org.eclipse.pde.internal.ui.parts.TreePart; |
40 |
import org.eclipse.pde.internal.ui.parts.TreePart; |
|
|
41 |
import org.eclipse.pde.internal.ui.search.ExtensionsPatternFilter; |
40 |
import org.eclipse.pde.internal.ui.search.PluginSearchActionGroup; |
42 |
import org.eclipse.pde.internal.ui.search.PluginSearchActionGroup; |
41 |
import org.eclipse.pde.internal.ui.util.SWTUtil; |
43 |
import org.eclipse.pde.internal.ui.util.SWTUtil; |
42 |
import org.eclipse.pde.internal.ui.wizards.extension.ExtensionEditorWizard; |
44 |
import org.eclipse.pde.internal.ui.wizards.extension.ExtensionEditorWizard; |
Lines 51-59
Link Here
|
51 |
import org.eclipse.swt.widgets.*; |
53 |
import org.eclipse.swt.widgets.*; |
52 |
import org.eclipse.ui.actions.ActionContext; |
54 |
import org.eclipse.ui.actions.ActionContext; |
53 |
import org.eclipse.ui.actions.ActionFactory; |
55 |
import org.eclipse.ui.actions.ActionFactory; |
54 |
import org.eclipse.ui.dialogs.PatternFilter; |
|
|
55 |
import org.eclipse.ui.forms.widgets.FormToolkit; |
56 |
import org.eclipse.ui.forms.widgets.FormToolkit; |
56 |
import org.eclipse.ui.forms.widgets.Section; |
57 |
import org.eclipse.ui.forms.widgets.Section; |
|
|
58 |
import org.eclipse.ui.progress.WorkbenchJob; |
57 |
|
59 |
|
58 |
public class ExtensionsSection extends TreeSection implements IModelChangedListener, IPropertyChangeListener { |
60 |
public class ExtensionsSection extends TreeSection implements IModelChangedListener, IPropertyChangeListener { |
59 |
private static final int BUTTON_MOVE_DOWN = 4; |
61 |
private static final int BUTTON_MOVE_DOWN = 4; |
Lines 68-81
Link Here
|
68 |
private Hashtable fEditorWizards; |
70 |
private Hashtable fEditorWizards; |
69 |
private SortAction fSortAction; |
71 |
private SortAction fSortAction; |
70 |
private CollapseAction fCollapseAction; |
72 |
private CollapseAction fCollapseAction; |
|
|
73 |
private ToggleExpandStateAction fExpandAction; |
74 |
private FilterRelatedExtensionsAction fFilterRelatedAction; |
75 |
private SearchExtensionsAction fSearchAction; |
71 |
|
76 |
|
72 |
private static final int BUTTON_ADD = 0; |
77 |
private static final int BUTTON_ADD = 0; |
73 |
|
78 |
|
74 |
private static final String[] COMMON_LABEL_PROPERTIES = {"label", //$NON-NLS-1$ |
79 |
// TODO common label properties should be configured in preferences |
75 |
"name", //$NON-NLS-1$ |
80 |
public static final String[] COMMON_LABEL_ATTRIBUTES = {"label", //$NON-NLS-1$ |
76 |
"id", //$NON-NLS-1$ |
81 |
"name", "class", "id", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ |
77 |
"commandId", //$NON-NLS-1$ |
82 |
"commandId", "property", "activityId", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ |
78 |
"activityId"}; //$NON-NLS-1$ |
83 |
"attribute", "value"}; //$NON-NLS-1$ //$NON-NLS-2$ |
79 |
|
84 |
|
80 |
private static final String[] VALID_IMAGE_TYPES = {"png", "bmp", "ico", "gif", "jpg", "tiff"}; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ |
85 |
private static final String[] VALID_IMAGE_TYPES = {"png", "bmp", "ico", "gif", "jpg", "tiff"}; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ |
81 |
|
86 |
|
Lines 232-237
Link Here
|
232 |
updateButtons(ssel.size() != 1 ? null : ssel); |
237 |
updateButtons(ssel.size() != 1 ? null : ssel); |
233 |
} |
238 |
} |
234 |
}); |
239 |
}); |
|
|
240 |
|
241 |
// required for enabling constant typing in the filter control |
242 |
filterText.addKeyListener(new KeyAdapter() { |
243 |
public void keyPressed(KeyEvent e) { |
244 |
if (fFilteredTree.getFilterControl().getText().length() > 0) { |
245 |
Job jobs[] = Job.getJobManager().find(null); |
246 |
try { |
247 |
Job.getJobManager().suspend(); |
248 |
for (int i = 0; i < jobs.length; i++) { |
249 |
Job job = jobs[i]; |
250 |
if (job != null && "Refresh Filter".equals(job.getName())) { //$NON-NLS-1$ |
251 |
// remove prior filtering refresh jobs in order to avoid blocked filter control |
252 |
job.cancel(); |
253 |
} |
254 |
} |
255 |
} finally { |
256 |
Job.getJobManager().resume(); |
257 |
} |
258 |
} |
259 |
} |
260 |
}); |
235 |
} |
261 |
} |
236 |
} |
262 |
} |
237 |
|
263 |
|
Lines 252-260
Link Here
|
252 |
} |
278 |
} |
253 |
} |
279 |
} |
254 |
}); |
280 |
}); |
|
|
281 |
// Add action to filter tree with some of the selection's attributes |
282 |
fFilterRelatedAction = new FilterRelatedExtensionsAction(fExtensionTree, fFilteredTree); |
283 |
toolBarManager.add(fFilterRelatedAction); |
284 |
// Add action to search all workspace plugins with current filtering applied to the tree viewer |
285 |
fSearchAction = new SearchExtensionsAction(fFilteredTree, PDEUIMessages.ExtensionsPage_searchWithExtensionsFilter); |
286 |
toolBarManager.add(fSearchAction); |
287 |
// Add separator |
288 |
Separator separator = new Separator(); |
289 |
toolBarManager.add(separator); |
255 |
// Add sort action to the tool bar |
290 |
// Add sort action to the tool bar |
256 |
fSortAction = new SortAction(fExtensionTree, PDEUIMessages.ExtensionsPage_sortAlpha, null, null, this); |
291 |
fSortAction = new SortAction(fExtensionTree, PDEUIMessages.ExtensionsPage_sortAlpha, null, null, this); |
257 |
toolBarManager.add(fSortAction); |
292 |
toolBarManager.add(fSortAction); |
|
|
293 |
// Add expand selected leafs action to the toolbar |
294 |
fExpandAction = new ToggleExpandStateAction(fFilteredTree, fExtensionTree); |
295 |
toolBarManager.add(fExpandAction); |
258 |
// Add collapse action to the tool bar |
296 |
// Add collapse action to the tool bar |
259 |
fCollapseAction = new CollapseAction(fExtensionTree, PDEUIMessages.ExtensionsPage_collapseAll); |
297 |
fCollapseAction = new CollapseAction(fExtensionTree, PDEUIMessages.ExtensionsPage_collapseAll); |
260 |
toolBarManager.add(fCollapseAction); |
298 |
toolBarManager.add(fCollapseAction); |
Lines 309-319
Link Here
|
309 |
* @see org.eclipse.pde.internal.ui.editor.PDESection#doGlobalAction(java.lang.String) |
347 |
* @see org.eclipse.pde.internal.ui.editor.PDESection#doGlobalAction(java.lang.String) |
310 |
*/ |
348 |
*/ |
311 |
public boolean doGlobalAction(String actionId) { |
349 |
public boolean doGlobalAction(String actionId) { |
312 |
|
350 |
if (actionId.equals(ActionFactory.FIND.getId()) && fFilterRelatedAction != null) { |
|
|
351 |
fFilterRelatedAction.run(); |
352 |
return true; |
353 |
} |
313 |
if (!isEditable()) { |
354 |
if (!isEditable()) { |
314 |
return false; |
355 |
return false; |
315 |
} |
356 |
} |
316 |
|
|
|
317 |
if (actionId.equals(ActionFactory.DELETE.getId())) { |
357 |
if (actionId.equals(ActionFactory.DELETE.getId())) { |
318 |
handleDelete(); |
358 |
handleDelete(); |
319 |
return true; |
359 |
return true; |
Lines 348-354
Link Here
|
348 |
|
388 |
|
349 |
protected void fillContextMenu(IMenuManager manager) { |
389 |
protected void fillContextMenu(IMenuManager manager) { |
350 |
ISelection selection = fExtensionTree.getSelection(); |
390 |
ISelection selection = fExtensionTree.getSelection(); |
351 |
IStructuredSelection ssel = (IStructuredSelection) selection; |
391 |
final IStructuredSelection ssel = (IStructuredSelection) selection; |
352 |
if (ssel.size() == 1) { |
392 |
if (ssel.size() == 1) { |
353 |
Object object = ssel.getFirstElement(); |
393 |
Object object = ssel.getFirstElement(); |
354 |
if (object instanceof IPluginParent) { |
394 |
if (object instanceof IPluginParent) { |
Lines 377-388
Link Here
|
377 |
manager.add(new Separator()); |
417 |
manager.add(new Separator()); |
378 |
delAction.setEnabled(isEditable()); |
418 |
delAction.setEnabled(isEditable()); |
379 |
} |
419 |
} |
|
|
420 |
if (ssel.size() > 0) { |
421 |
if (FilterRelatedExtensionsAction.isFilterRelatedEnabled(ssel)) { |
422 |
FilterRelatedExtensionsAction filterRelatedAction = new FilterRelatedExtensionsAction(fExtensionTree, fFilteredTree); |
423 |
manager.add(filterRelatedAction); |
424 |
SearchExtensionsAction searchRelatedAction = new SearchExtensionsAction(ssel, FilterRelatedExtensionsAction.getFilterRelatedPattern(ssel), PDEUIMessages.Actions_search_relatedPluginElements); |
425 |
manager.add(searchRelatedAction); |
426 |
manager.add(new Separator()); |
427 |
} |
428 |
} |
380 |
manager.add(new Separator()); |
429 |
manager.add(new Separator()); |
381 |
if (ssel.size() < 2) { // only cut things when the selection is one |
430 |
if (ssel.size() < 2) { // only cut things when the selection is one |
382 |
getPage().getPDEEditor().getContributor().addClipboardActions(manager); |
431 |
getPage().getPDEEditor().getContributor().addClipboardActions(manager); |
383 |
} |
432 |
} |
384 |
getPage().getPDEEditor().getContributor().contextMenuAboutToShow(manager, false); |
433 |
getPage().getPDEEditor().getContributor().contextMenuAboutToShow(manager, false); |
385 |
|
434 |
this.fFilteredTree.update(); |
386 |
} |
435 |
} |
387 |
|
436 |
|
388 |
static IMenuManager fillContextMenu(PDEFormPage page, final IPluginParent parent, IMenuManager manager) { |
437 |
static IMenuManager fillContextMenu(PDEFormPage page, final IPluginParent parent, IMenuManager manager) { |
Lines 491-496
Link Here
|
491 |
PDEPlugin.logException(e); |
540 |
PDEPlugin.logException(e); |
492 |
} |
541 |
} |
493 |
} |
542 |
} |
|
|
543 |
} |
544 |
|
545 |
public FormFilteredTree getFormFilteredTree() { |
546 |
return fFilteredTree; |
494 |
} |
547 |
} |
495 |
|
548 |
|
496 |
private void handleNew() { |
549 |
private void handleNew() { |
Lines 643-652
Link Here
|
643 |
// The model changed but the editor is still open, we should try to retain expansion, selection will be retained on its own |
696 |
// The model changed but the editor is still open, we should try to retain expansion, selection will be retained on its own |
644 |
Object[] expanded = fExtensionTree.getExpandedElements(); |
697 |
Object[] expanded = fExtensionTree.getExpandedElements(); |
645 |
IPluginModelBase model = (IPluginModelBase) getPage().getModel(); |
698 |
IPluginModelBase model = (IPluginModelBase) getPage().getModel(); |
646 |
fExtensionTree.getControl().setRedraw(false); |
699 |
try { |
647 |
fExtensionTree.setInput(model.getPluginBase()); |
700 |
fExtensionTree.getControl().setRedraw(false); |
648 |
fExtensionTree.setExpandedElements(expanded); |
701 |
fExtensionTree.setInput(model.getPluginBase()); |
649 |
fExtensionTree.getControl().setRedraw(true); |
702 |
fExtensionTree.setExpandedElements(expanded); |
|
|
703 |
} finally { |
704 |
fExtensionTree.getControl().setRedraw(true); |
705 |
} |
650 |
reportMissingExtensionPointSchemas(model.getPluginBase()); |
706 |
reportMissingExtensionPointSchemas(model.getPluginBase()); |
651 |
getManagedForm().fireSelectionChanged(ExtensionsSection.this, fExtensionTree.getSelection()); |
707 |
getManagedForm().fireSelectionChanged(ExtensionsSection.this, fExtensionTree.getSelection()); |
652 |
super.refresh(); |
708 |
super.refresh(); |
Lines 809-816
Link Here
|
809 |
if (labelAtt == null) { |
865 |
if (labelAtt == null) { |
810 |
// try some hard-coded attributes that |
866 |
// try some hard-coded attributes that |
811 |
// are used frequently |
867 |
// are used frequently |
812 |
for (int i = 0; i < COMMON_LABEL_PROPERTIES.length; i++) { |
868 |
for (int i = 0; i < COMMON_LABEL_ATTRIBUTES.length; i++) { |
813 |
labelAtt = element.getAttribute(COMMON_LABEL_PROPERTIES[i]); |
869 |
labelAtt = element.getAttribute(COMMON_LABEL_ATTRIBUTES[i]); |
814 |
if (labelAtt != null) |
870 |
if (labelAtt != null) |
815 |
break; |
871 |
break; |
816 |
} |
872 |
} |
Lines 821-829
Link Here
|
821 |
labelAtt = element.getAttributes()[0]; |
877 |
labelAtt = element.getAttributes()[0]; |
822 |
} |
878 |
} |
823 |
} |
879 |
} |
824 |
if (labelAtt != null && labelAtt.getValue() != null) |
880 |
if (labelAtt != null && labelAtt.getValue() != null) { |
825 |
fullName = stripShortcuts(labelAtt.getValue()); |
881 |
fullName = stripShortcuts(labelAtt.getValue()); |
|
|
882 |
if (labelAtt.getName().equals(COMMON_LABEL_ATTRIBUTES[2])) { // remove package from handler class |
883 |
fullName = fullName.substring(fullName.lastIndexOf('.') + 1, fullName.length()); |
884 |
} |
885 |
} |
826 |
fullName = element.getResourceString(fullName); |
886 |
fullName = element.getResourceString(fullName); |
|
|
887 |
|
827 |
if (fullNames) |
888 |
if (fullNames) |
828 |
return fullName != null ? fullName : baseName; |
889 |
return fullName != null ? fullName : baseName; |
829 |
if (fullName == null) |
890 |
if (fullName == null) |
Lines 1081-1086
Link Here
|
1081 |
} |
1142 |
} |
1082 |
|
1143 |
|
1083 |
private void updateButtons(Object item) { |
1144 |
private void updateButtons(Object item) { |
|
|
1145 |
if (fExpandAction != null) { |
1146 |
fExpandAction.setEnabled(ToggleExpandStateAction.isExpandable((IStructuredSelection) fExtensionTree.getSelection())); |
1147 |
} |
1148 |
if (fFilterRelatedAction != null) { |
1149 |
fFilterRelatedAction.setEnabled(FilterRelatedExtensionsAction.isFilterRelatedEnabled((IStructuredSelection) fExtensionTree.getSelection())); |
1150 |
} |
1151 |
if (fSearchAction != null) { |
1152 |
Text filterControl = fFilteredTree.getFilterControl(); |
1153 |
// enable action only when filtering occurs |
1154 |
fSearchAction.setEnabled(filterControl != null && filterControl.getText().length() > 0); |
1155 |
} |
1156 |
|
1084 |
if (getPage().getModel().isEditable() == false) |
1157 |
if (getPage().getModel().isEditable() == false) |
1085 |
return; |
1158 |
return; |
1086 |
boolean sorted = fSortAction != null && fSortAction.isChecked(); |
1159 |
boolean sorted = fSortAction != null && fSortAction.isChecked(); |
Lines 1140-1147
Link Here
|
1140 |
* @see org.eclipse.pde.internal.ui.editor.TreeSection#createTreeViewer(org.eclipse.swt.widgets.Composite, int) |
1213 |
* @see org.eclipse.pde.internal.ui.editor.TreeSection#createTreeViewer(org.eclipse.swt.widgets.Composite, int) |
1141 |
*/ |
1214 |
*/ |
1142 |
protected TreeViewer createTreeViewer(Composite parent, int style) { |
1215 |
protected TreeViewer createTreeViewer(Composite parent, int style) { |
1143 |
fFilteredTree = new FormFilteredTree(parent, style, new PatternFilter()); |
1216 |
fFilteredTree = new FormFilteredTree(parent, style, new ExtensionsPatternFilter()) { |
|
|
1217 |
protected WorkbenchJob doCreateRefreshJob() { |
1218 |
final WorkbenchJob job = super.doCreateRefreshJob(); |
1219 |
job.addJobChangeListener(new JobChangeAdapter() { |
1220 |
private ISelection selection; |
1221 |
|
1222 |
public void scheduled(IJobChangeEvent event) { |
1223 |
((ExtensionsPatternFilter) fFilteredTree.getPatternFilter()).clearMatchingLeafs(); |
1224 |
selection = fExtensionTree.getSelection(); |
1225 |
fFilteredTree.setRedraw(false); |
1226 |
} |
1227 |
|
1228 |
public void done(IJobChangeEvent event) { |
1229 |
ExtensionsPatternFilter extensionsPatternFilter = ((ExtensionsPatternFilter) fFilteredTree.getPatternFilter()); |
1230 |
fExtensionTree.collapseAll(); |
1231 |
Object[] leafs = extensionsPatternFilter.getMatchingLeafsAsArray(); |
1232 |
for (int i = 0; i < leafs.length; i++) { |
1233 |
fExtensionTree.expandToLevel(leafs[i], 0); |
1234 |
} |
1235 |
if (selection != null && !(selection.isEmpty())) { |
1236 |
fExtensionTree.setSelection(selection, false); |
1237 |
} |
1238 |
fFilteredTree.setRedraw(true); |
1239 |
} |
1240 |
|
1241 |
}); |
1242 |
return job; |
1243 |
} |
1244 |
|
1245 |
protected long getRefreshJobDelay() { |
1246 |
return 500; // required for continuous typing while performing extensive search operation |
1247 |
} |
1248 |
}; |
1144 |
parent.setData("filtered", Boolean.TRUE); //$NON-NLS-1$ |
1249 |
parent.setData("filtered", Boolean.TRUE); //$NON-NLS-1$ |
|
|
1250 |
fFilteredTree.addMouseWheelListener(new MouseWheelListener() { |
1251 |
|
1252 |
public void mouseScrolled(MouseEvent e) { |
1253 |
if ((e.stateMask & SWT.MOD1) == SWT.MOD1) { |
1254 |
//System.out.println("e.stateMask == SWT.MOD1"); |
1255 |
//fExtensionTree.scrollDown(0, 80); |
1256 |
//fFilteredTree.redraw(); |
1257 |
} |
1258 |
//} |
1259 |
|
1260 |
} |
1261 |
}); |
1145 |
return fFilteredTree.getViewer(); |
1262 |
return fFilteredTree.getViewer(); |
1146 |
} |
1263 |
} |
1147 |
|
1264 |
|