Skip to content

Commit 78bca44

Browse files
gian-benitoBAlgarraKN0987
committed
Added Filter Textfield support
Co-authored-by: Brandon Algarra <[email protected]> Co-authored-by: Khang Nguyen <[email protected]>
1 parent d9ad053 commit 78bca44

File tree

8 files changed

+99
-3
lines changed

8 files changed

+99
-3
lines changed

apitools/org.eclipse.pde.api.tools/.classpath

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@
66
<classpathentry kind="src" output="bin_ant" path="src_ant"/>
77
<classpathentry kind="src" path="xslt"/>
88
<classpathentry kind="output" path="bin"/>
9-
</classpath>
9+
</classpath>

ui/org.eclipse.pde.core/src/org/eclipse/pde/core/plugin/IPluginImport.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,11 @@ public interface IPluginImport extends IPluginObject, IPluginReference {
3434
*/
3535
String P_OPTIONAL = "optional"; //$NON-NLS-1$
3636

37+
/**
38+
* @since 3.21
39+
*/
40+
String P_FILTER = "filter"; //$NON-NLS-1$
41+
3742
/**
3843
* Tests whether the imported plug-in is reexported for
3944
* plug-ins that will use this plug-in.
@@ -70,4 +75,17 @@ public interface IPluginImport extends IPluginObject, IPluginReference {
7075
*/
7176
void setOptional(boolean value) throws CoreException;
7277

78+
/**
79+
* @since 3.21
80+
*/
81+
void setFilter(String filter) throws CoreException;
82+
83+
/**
84+
* Returns the filter string for this plugin reference.
85+
*
86+
* @return the filter string, or null if not set
87+
* @since 3.21
88+
*/
89+
String getFilter();
90+
7391
}

ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/plugin/PluginImport.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ public class PluginImport extends IdentifiablePluginObject implements IPluginImp
4646
private boolean reexported = false;
4747
private boolean optional = false;
4848
private String version;
49+
private String filter;
4950

5051
public PluginImport() {
5152
}
@@ -74,6 +75,12 @@ public String getVersion() {
7475
return version;
7576
}
7677

78+
@Override
79+
public String getFilter() {
80+
// TODO Auto-generated method stub
81+
return version;
82+
}
83+
7784
@Override
7885
public boolean isReexported() {
7986
return reexported;
@@ -203,6 +210,15 @@ public void setVersion(String version) throws CoreException {
203210
firePropertyChanged(P_VERSION, oldValue, version);
204211
}
205212

213+
@Override
214+
public void setFilter(String filter) throws CoreException {
215+
ensureModelEditable();
216+
String oldValue = this.filter;
217+
this.filter = filter;
218+
firePropertyChanged(P_FILTER, oldValue, filter);
219+
220+
}
221+
206222
@Override
207223
public void restoreProperty(String name, Object oldValue, Object newValue) throws CoreException {
208224
if (name.equals(P_MATCH)) {
@@ -312,4 +328,6 @@ public void writeDelimeter(PrintWriter writer) {
312328
writer.print(' ');
313329
}
314330

331+
332+
315333
}

ui/org.eclipse.pde.core/text/org/eclipse/pde/internal/core/text/plugin/PluginImportNode.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,17 @@ public class PluginImportNode extends PluginObjectNode implements IPluginImport
2121

2222
private static final long serialVersionUID = 1L;
2323

24+
@Override
25+
public void setFilter(String filter) {
26+
setXMLAttribute(P_FILTER, filter);
27+
28+
}
29+
30+
@Override
31+
public String getFilter() {
32+
return getXMLAttributeValue(P_FILTER);
33+
}
34+
2435
public PluginImportNode(String id) {
2536
super();
2637
String name = "plugin"; //$NON-NLS-1$

ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/PDEUIMessages.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -977,6 +977,7 @@ public class PDEUIMessages extends NLS {
977977
public static String ManifestEditor_MatchSection_equivalent;
978978
public static String ManifestEditor_MatchSection_compatible;
979979
public static String ManifestEditor_MatchSection_greater;
980+
public static String ManifestEditor_MatchSection_filter;
980981

981982
public static String ManifestEditor_PluginSpecSection_title;
982983
public static String ManifestEditor_PluginSpecSection_desc;

ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/editor/plugin/MatchSection.java

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import org.eclipse.pde.core.plugin.IMatchRules;
2626
import org.eclipse.pde.core.plugin.IPluginImport;
2727
import org.eclipse.pde.core.plugin.IPluginReference;
28+
import org.eclipse.pde.internal.core.ifeature.IFeatureImport;
2829
import org.eclipse.pde.internal.core.plugin.ImportObject;
2930
import org.eclipse.pde.internal.ui.PDEPlugin;
3031
import org.eclipse.pde.internal.ui.PDEUIMessages;
@@ -44,13 +45,17 @@
4445
import org.eclipse.ui.forms.IPartSelectionListener;
4546
import org.eclipse.ui.forms.widgets.FormToolkit;
4647
import org.eclipse.ui.forms.widgets.Section;
48+
import org.osgi.framework.FrameworkUtil;
49+
import org.osgi.framework.InvalidSyntaxException;
4750

4851
public class MatchSection extends PDESection implements IPartSelectionListener {
4952

53+
5054
private Button fReexportButton;
5155
private Button fOptionalButton;
5256

5357
private FormEntry fVersionText;
58+
private FormEntry fFilterText;
5459

5560
private ComboPart fMatchCombo;
5661
protected IPluginReference fCurrentImport;
@@ -134,6 +139,26 @@ public void textDirty(FormEntry text) {
134139
}));
135140
toolkit.paintBordersFor(container);
136141
initialize();
142+
143+
fFilterText = new FormEntry(container, toolkit, PDEUIMessages.ManifestEditor_MatchSection_filter, null, false);
144+
fFilterText.setFormEntryListener(
145+
new FormEntryAdapter(this, getPage().getEditor().getEditorSite().getActionBars()) {
146+
@Override
147+
public void textValueChanged(FormEntry text) {
148+
applyFilter(text.getValue());
149+
}
150+
151+
@Override
152+
public void textDirty(FormEntry text) {
153+
if (fBlockChanges) {
154+
return;
155+
}
156+
markDirty();
157+
fBlockChanges = true;
158+
resetMatchCombo(fCurrentImport);
159+
fBlockChanges = false;
160+
}
161+
});
137162
update((IPluginReference) null);
138163

139164
section.setClient(container);
@@ -200,6 +225,23 @@ private void applyMatch(int match) {
200225
}
201226
}
202227

228+
private void applyFilter(String filter) {
229+
try {
230+
if (fCurrentImport == null)
231+
return;
232+
if (filter == null || filter.isEmpty())
233+
((IFeatureImport) fCurrentImport).setFilter(null);
234+
else {
235+
FrameworkUtil.createFilter(filter);
236+
((IFeatureImport) fCurrentImport).setFilter(filter);
237+
}
238+
} catch (InvalidSyntaxException e) {
239+
PDEPlugin.logException(e);
240+
} catch (CoreException e) {
241+
PDEPlugin.logException(e);
242+
}
243+
}
244+
203245
private int getMatch() {
204246
return fMatchCombo.getSelectionIndex();
205247
}
@@ -272,8 +314,11 @@ protected void update(IPluginReference iimport) {
272314
}
273315
fVersionText.setValue(null, true);
274316
fVersionText.setEditable(false);
317+
275318
fMatchCombo.getControl().setEnabled(false);
276319
fMatchCombo.setText(""); //$NON-NLS-1$
320+
fFilterText.setValue(null, false);
321+
fFilterText.setEditable(false);
277322
fCurrentImport = null;
278323
fBlockChanges = false;
279324
return;
@@ -292,7 +337,10 @@ protected void update(IPluginReference iimport) {
292337
}
293338
fVersionText.setEditable(isEditable());
294339
fVersionText.setValue(fCurrentImport.getVersion());
340+
295341
resetMatchCombo(fCurrentImport);
342+
fFilterText.setEditable(isEditable());
343+
fFilterText.setValue(((IFeatureImport) fCurrentImport).getFilter());
296344
fBlockChanges = false;
297345
}
298346
}

ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/pderesources.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -388,6 +388,7 @@ ManifestEditor_MatchSection_perfect = Perfect
388388
ManifestEditor_MatchSection_equivalent = Equivalent
389389
ManifestEditor_MatchSection_compatible = Compatible
390390
ManifestEditor_MatchSection_greater = Greater or Equal
391+
ManifestEditor_MatchSection_filter = Filter:
391392

392393
ManifestEditor_PluginSpecSection_title = General Information
393394
ManifestEditor_PluginSpecSection_desc = This section describes general information about this plug-in.

ui/org.eclipse.pde.ui/src/org/eclipse/pde/ui/templates/PluginReference.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,5 +113,4 @@ public String getId() {
113113
public void setId(String id) throws CoreException {
114114
this.id = id;
115115
}
116-
117-
}
116+
}

0 commit comments

Comments
 (0)