Cleanup
This commit is contained in:
parent
d88cdc599b
commit
7cf1419cc4
@ -70,11 +70,6 @@
|
||||
</extension>
|
||||
|
||||
<!-- ExtensionPoint für die QuickFixes der ReplaceMarker Quelle: http://wiki.eclipse.org/FAQ_How_do_I_implement_Quick_Fixes_for_my_own_language%3F -->
|
||||
<extension point="org.eclipse.ui.ide.markerResolution">
|
||||
<markerResolutionGenerator
|
||||
markerType="typinferenzplugin.replacemarker"
|
||||
class="typinferenzplugin.marker.QuickFixer"/>
|
||||
</extension>
|
||||
<extension
|
||||
point="org.eclipse.ui.menus">
|
||||
<menuContribution
|
||||
|
@ -7,6 +7,8 @@ import org.eclipse.swt.events.SelectionListener;
|
||||
import org.eclipse.swt.widgets.Menu;
|
||||
import org.eclipse.swt.widgets.MenuItem;
|
||||
|
||||
import typinferenzplugin.TypeReplaceMarker;
|
||||
|
||||
public class InsertTypeContribution extends ContributionItem {
|
||||
JavEditor editorContext;
|
||||
|
||||
@ -15,17 +17,13 @@ public class InsertTypeContribution extends ContributionItem {
|
||||
this.editorContext = editorContext;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fill(Menu menu, int index) {
|
||||
new MenuItem(menu, SWT.SEPARATOR, 0);
|
||||
var parent = new MenuItem(menu, SWT.CASCADE, 0);
|
||||
parent.setText("Typ einsetzen");
|
||||
var subMenu = new Menu(parent);
|
||||
parent.setMenu(subMenu);
|
||||
for (var marker : editorContext.currentMarkers) {
|
||||
var item = new MenuItem(subMenu, SWT.PUSH);
|
||||
item.setText(marker.getInsertPoint().getInsertString());
|
||||
item.addSelectionListener(new SelectionListener() {
|
||||
private final class SelectionHandler implements SelectionListener {
|
||||
final TypeReplaceMarker marker;
|
||||
|
||||
SelectionHandler(TypeReplaceMarker marker) {
|
||||
this.marker = marker;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void widgetSelected(SelectionEvent e) {
|
||||
editorContext.runReplaceMarker(marker);
|
||||
@ -36,8 +34,28 @@ public class InsertTypeContribution extends ContributionItem {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fill(Menu menu, int index) {
|
||||
new MenuItem(menu, SWT.SEPARATOR, 0);
|
||||
if (editorContext.currentMarkers.size() > 1) {
|
||||
var parent = new MenuItem(menu, SWT.CASCADE, 0);
|
||||
parent.setText("Typ einsetzen");
|
||||
var subMenu = new Menu(parent);
|
||||
parent.setMenu(subMenu);
|
||||
for (var marker : editorContext.currentMarkers) {
|
||||
var item = new MenuItem(subMenu, SWT.PUSH);
|
||||
item.setText(marker.getInsertPoint().getInsertString());
|
||||
item.addSelectionListener(new SelectionHandler(marker));
|
||||
}
|
||||
} else {
|
||||
var marker = editorContext.currentMarkers.get(0);
|
||||
var item = new MenuItem(menu, SWT.PUSH, 0);
|
||||
item.setText(marker.getInsertPoint().getInsertString() + " einsetzen");
|
||||
item.addSelectionListener(new SelectionHandler(marker));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1,19 +0,0 @@
|
||||
package typinferenzplugin.marker;
|
||||
|
||||
import org.eclipse.core.resources.IMarker;
|
||||
import org.eclipse.jface.dialogs.MessageDialog;
|
||||
import org.eclipse.ui.IMarkerResolution;
|
||||
|
||||
public class QuickFix implements IMarkerResolution {
|
||||
String label;
|
||||
QuickFix(String label) {
|
||||
this.label = label;
|
||||
}
|
||||
public String getLabel() {
|
||||
return label;
|
||||
}
|
||||
public void run(IMarker marker) {
|
||||
MessageDialog.openInformation(null, "QuickFix Demo",
|
||||
"This quick-fix is not yet implemented");
|
||||
}
|
||||
}
|
@ -1,17 +0,0 @@
|
||||
package typinferenzplugin.marker;
|
||||
|
||||
import org.eclipse.core.resources.IMarker;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.ui.IMarkerResolution;
|
||||
import org.eclipse.ui.IMarkerResolutionGenerator;
|
||||
|
||||
public class QuickFixer implements IMarkerResolutionGenerator {
|
||||
|
||||
public IMarkerResolution[] getResolutions(IMarker mk) {
|
||||
return new IMarkerResolution[] {
|
||||
new QuickFix("Fix #1 for ")
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user