-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 961365d
Showing
18 changed files
with
814 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<projectDescription> | ||
<name>hu.donat.quicksearch.feature</name> | ||
<comment></comment> | ||
<projects> | ||
</projects> | ||
<buildSpec> | ||
<buildCommand> | ||
<name>org.eclipse.pde.FeatureBuilder</name> | ||
<arguments> | ||
</arguments> | ||
</buildCommand> | ||
</buildSpec> | ||
<natures> | ||
<nature>org.eclipse.pde.FeatureNature</nature> | ||
</natures> | ||
</projectDescription> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
bin.includes = feature.xml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<feature | ||
id="hu.donat.quicksearch" | ||
label="Quick search" | ||
version="0.0.1"> | ||
|
||
<description url="http://www.example.com/description"> | ||
[Enter Feature Description here.] | ||
</description> | ||
|
||
<copyright url="http://www.example.com/copyright"> | ||
[Enter Copyright Description here.] | ||
</copyright> | ||
|
||
<license url="http://www.example.com/license"> | ||
[Enter License Description here.] | ||
</license> | ||
|
||
<plugin | ||
id="hu.donat.quicksearch" | ||
download-size="0" | ||
install-size="0" | ||
version="0.0.0" | ||
unpack="false"/> | ||
|
||
</feature> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<projectDescription> | ||
<name>hu.donat.quicksearch.site</name> | ||
<comment></comment> | ||
<projects> | ||
</projects> | ||
<buildSpec> | ||
<buildCommand> | ||
<name>org.eclipse.pde.UpdateSiteBuilder</name> | ||
<arguments> | ||
</arguments> | ||
</buildCommand> | ||
</buildSpec> | ||
<natures> | ||
<nature>org.eclipse.pde.UpdateSiteNature</nature> | ||
</natures> | ||
</projectDescription> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<site> | ||
<feature url="features/hu.donat.quicksearch_0.0.1.jar" id="hu.donat.quicksearch" version="0.0.1"/> | ||
</site> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<classpath> | ||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"/> | ||
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/> | ||
<classpathentry kind="src" path="src/main/java"/> | ||
<classpathentry kind="output" path="bin"/> | ||
</classpath> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<projectDescription> | ||
<name>hu.donat.quicksearch</name> | ||
<comment></comment> | ||
<projects> | ||
</projects> | ||
<buildSpec> | ||
<buildCommand> | ||
<name>org.eclipse.jdt.core.javabuilder</name> | ||
<arguments> | ||
</arguments> | ||
</buildCommand> | ||
<buildCommand> | ||
<name>org.eclipse.pde.ManifestBuilder</name> | ||
<arguments> | ||
</arguments> | ||
</buildCommand> | ||
<buildCommand> | ||
<name>org.eclipse.pde.SchemaBuilder</name> | ||
<arguments> | ||
</arguments> | ||
</buildCommand> | ||
</buildSpec> | ||
<natures> | ||
<nature>org.eclipse.pde.PluginNature</nature> | ||
<nature>org.eclipse.jdt.core.javanature</nature> | ||
</natures> | ||
</projectDescription> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
eclipse.preferences.version=1 | ||
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled | ||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7 | ||
org.eclipse.jdt.core.compiler.compliance=1.7 | ||
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error | ||
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error | ||
org.eclipse.jdt.core.compiler.source=1.7 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
Manifest-Version: 1.0 | ||
Bundle-ManifestVersion: 2 | ||
Bundle-Name: Quicksearch | ||
Bundle-SymbolicName: hu.donat.quicksearch;singleton:=true | ||
Bundle-Version: 1.0.0.qualifier | ||
Bundle-Activator: hu.donat.quicksearch.internal.QuicksearchPlugin | ||
Require-Bundle: org.eclipse.ui, | ||
org.eclipse.core.runtime, | ||
com.google.guava | ||
Bundle-RequiredExecutionEnvironment: JavaSE-1.7 | ||
Bundle-ActivationPolicy: lazy |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/hu/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
source.. = src/main/java/ | ||
output.. = bin/ | ||
bin.includes = META-INF/,\ | ||
.,\ | ||
plugin.xml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<?eclipse version="3.4"?> | ||
<plugin> | ||
<extension | ||
point="org.eclipse.ui.startup"> | ||
<startup | ||
class="hu.donat.quicksearch.internal.Startup"> | ||
</startup> | ||
</extension> | ||
|
||
</plugin> |
128 changes: 128 additions & 0 deletions
128
hu.donat.quicksearch/src/main/java/hu/donat/quicksearch/internal/Listeners.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,128 @@ | ||
/* | ||
* Copyright (c) 2016 the original author or authors. | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License v1.0 | ||
* which accompanies this distribution, and is available at | ||
* http://www.eclipse.org/legal/epl-v10.html | ||
*/ | ||
|
||
package hu.donat.quicksearch.internal; | ||
|
||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
import org.eclipse.ui.IPageListener; | ||
import org.eclipse.ui.IPartListener; | ||
import org.eclipse.ui.IWindowListener; | ||
import org.eclipse.ui.IWorkbenchPage; | ||
import org.eclipse.ui.IWorkbenchPart; | ||
import org.eclipse.ui.IWorkbenchWindow; | ||
import org.eclipse.ui.PlatformUI; | ||
|
||
/** | ||
* @author Donát Csikós | ||
*/ | ||
public final class Listeners { | ||
|
||
private Listeners() { | ||
} | ||
|
||
public static void addListeners() { | ||
PlatformUI.getWorkbench().addWindowListener(new WindowListener()); | ||
for (IWorkbenchWindow window : PlatformUI.getWorkbench().getWorkbenchWindows()) { | ||
Map<IWorkbenchPage, IPartListener> partListeners = new HashMap<>(); | ||
for (IWorkbenchPage page : window.getPages()) { | ||
PartListener partListener = new PartListener(); | ||
partListeners.put(page, partListener); | ||
page.addPartListener(partListener); | ||
} | ||
window.addPageListener(new PageListener(partListeners)); | ||
} | ||
} | ||
|
||
public static class WindowListener implements IWindowListener { | ||
|
||
private final Map<IWorkbenchWindow, IPageListener> listeners = new HashMap<>(); | ||
|
||
@Override | ||
public void windowActivated(IWorkbenchWindow window) { | ||
} | ||
|
||
@Override | ||
public void windowDeactivated(IWorkbenchWindow window) { | ||
} | ||
|
||
@Override | ||
public void windowClosed(IWorkbenchWindow window) { | ||
IPageListener listener = this.listeners.remove(window); | ||
if (listener != null) { | ||
window.removePageListener(listener); | ||
} | ||
} | ||
|
||
@Override | ||
public void windowOpened(IWorkbenchWindow window) { | ||
PageListener listener = new PageListener(); | ||
this.listeners.put(window, listener); | ||
window.addPageListener(listener); | ||
} | ||
} | ||
|
||
public static class PageListener implements IPageListener { | ||
|
||
private final Map<IWorkbenchPage, IPartListener> listeners; | ||
|
||
public PageListener() { | ||
this.listeners = new HashMap<>(); | ||
} | ||
|
||
public PageListener(Map<IWorkbenchPage, IPartListener> partListeners) { | ||
this.listeners = new HashMap<>(partListeners); | ||
} | ||
|
||
@Override | ||
public void pageActivated(IWorkbenchPage page) { | ||
} | ||
|
||
@Override | ||
public void pageClosed(IWorkbenchPage page) { | ||
IPartListener listener = this.listeners.remove(page); | ||
if (listener != null) { | ||
page.removePartListener(listener); | ||
} | ||
} | ||
|
||
@Override | ||
public void pageOpened(IWorkbenchPage page) { | ||
PartListener listener = new PartListener(); | ||
this.listeners.put(page, listener); | ||
page.addPartListener(listener); | ||
} | ||
|
||
} | ||
|
||
public static class PartListener implements IPartListener { | ||
|
||
@Override | ||
public void partActivated(IWorkbenchPart part) { | ||
} | ||
|
||
@Override | ||
public void partBroughtToTop(IWorkbenchPart part) { | ||
} | ||
|
||
@Override | ||
public void partClosed(IWorkbenchPart part) { | ||
} | ||
|
||
@Override | ||
public void partDeactivated(IWorkbenchPart part) { | ||
} | ||
|
||
@Override | ||
public void partOpened(IWorkbenchPart part) { | ||
QuickSearchManager.addQuickSearchToAllTrees(part.getSite().getShell().getDisplay()); | ||
} | ||
|
||
} | ||
} |
112 changes: 112 additions & 0 deletions
112
hu.donat.quicksearch/src/main/java/hu/donat/quicksearch/internal/OverlayLabel.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
/* | ||
* Copyright (c) 2016 the original author or authors. | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License v1.0 | ||
* which accompanies this distribution, and is available at | ||
* http://www.eclipse.org/legal/epl-v10.html | ||
*/ | ||
|
||
package hu.donat.quicksearch.internal; | ||
|
||
import com.google.common.base.Preconditions; | ||
|
||
import org.eclipse.jface.layout.GridLayoutFactory; | ||
import org.eclipse.swt.SWT; | ||
import org.eclipse.swt.events.ControlEvent; | ||
import org.eclipse.swt.events.ControlListener; | ||
import org.eclipse.swt.events.DisposeEvent; | ||
import org.eclipse.swt.events.DisposeListener; | ||
import org.eclipse.swt.events.FocusAdapter; | ||
import org.eclipse.swt.events.FocusEvent; | ||
import org.eclipse.swt.graphics.Point; | ||
import org.eclipse.swt.layout.GridData; | ||
import org.eclipse.swt.widgets.Control; | ||
import org.eclipse.swt.widgets.Label; | ||
import org.eclipse.swt.widgets.Shell; | ||
|
||
/** | ||
* @author Donát Csikós | ||
*/ | ||
public final class OverlayLabel { | ||
|
||
private final Control target; | ||
private final Shell shell; | ||
private final Label label; | ||
|
||
private OverlayLabel(Control control) { | ||
this.target = Preconditions.checkNotNull(control); | ||
this.shell = new Shell(control.getShell(), SWT.MODELESS); | ||
this.shell.setLayout(GridLayoutFactory.fillDefaults().create()); | ||
this.label = new Label(this.shell, SWT.NONE); | ||
this.label.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); | ||
} | ||
|
||
public void updateText(String text) { | ||
if (text == null) { | ||
this.shell.setVisible(false); | ||
this.label.setText(""); | ||
} else { | ||
this.label.setText(text); | ||
reposition(); | ||
this.shell.setVisible(true); | ||
} | ||
} | ||
|
||
private void reposition() { | ||
this.shell.pack(); | ||
this.shell.setLocation(calculateLocation()); | ||
} | ||
|
||
private Point calculateLocation() { | ||
// display the label on the right side of the tree if it can fit on the screen | ||
// otherwise display the label inside the tree's bounds on the right side | ||
int displayWidth = this.shell.getDisplay().getClientArea().width; | ||
int shellWidth = this.shell.getBounds().width; | ||
int targetWidth = this.target.getBounds().width; | ||
int targetRightCorner = this.target.toDisplay(this.target.getBounds().width, 0).x; | ||
if(targetRightCorner + shellWidth < displayWidth) { | ||
return this.target.toDisplay(targetWidth, 0); | ||
} else { | ||
return this.target.toDisplay(targetWidth - shellWidth, 0); | ||
} | ||
} | ||
|
||
public static OverlayLabel attach(Control control) { | ||
OverlayLabel overlayTextShell = new OverlayLabel(control); | ||
control.addFocusListener(overlayTextShell.new WidgetFocusListener()); | ||
control.addDisposeListener(overlayTextShell.new WidgetDisposedListener()); | ||
control.addControlListener(overlayTextShell.new WidgetControlListener()); | ||
return overlayTextShell; | ||
} | ||
|
||
private final class WidgetFocusListener extends FocusAdapter { | ||
|
||
@Override | ||
public void focusLost(FocusEvent e) { | ||
if (!OverlayLabel.this.shell.isDisposed()) { | ||
OverlayLabel.this.shell.setVisible(false); | ||
} | ||
} | ||
} | ||
|
||
private final class WidgetDisposedListener implements DisposeListener { | ||
|
||
@Override | ||
public void widgetDisposed(DisposeEvent e) { | ||
OverlayLabel.this.shell.dispose(); | ||
} | ||
} | ||
private final class WidgetControlListener implements ControlListener { | ||
|
||
@Override | ||
public void controlMoved(ControlEvent e) { | ||
reposition(); | ||
} | ||
|
||
@Override | ||
public void controlResized(ControlEvent e) { | ||
reposition(); | ||
} | ||
} | ||
|
||
} |
Oops, something went wrong.