-
Notifications
You must be signed in to change notification settings - Fork 54
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
Showing
3 changed files
with
94 additions
and
10 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
46 changes: 46 additions & 0 deletions
46
src/com/yii2framework/completion/views/DirectoryLookupElement.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,46 @@ | ||
package com.yii2framework.completion.views; | ||
|
||
import com.intellij.codeInsight.lookup.LookupElement; | ||
import com.intellij.codeInsight.lookup.LookupElementPresentation; | ||
import com.intellij.psi.PsiDirectory; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
import javax.swing.*; | ||
|
||
/** | ||
* Created by NVlad on 28.12.2016. | ||
*/ | ||
public class DirectoryLookupElement extends LookupElement { | ||
private Icon icon; | ||
private String name; | ||
private String prefix; | ||
private String lookup; | ||
|
||
DirectoryLookupElement(PsiDirectory directory, String searchPrefix) { | ||
icon = directory.getIcon(0); | ||
name = directory.getName(); | ||
prefix = searchPrefix; | ||
if (searchPrefix.startsWith("/")) { | ||
prefix = prefix.substring(1); | ||
} | ||
if (prefix.length() > 0 && !prefix.endsWith("/")) { | ||
prefix = prefix.concat("/"); | ||
} | ||
lookup = directory.getName().concat("/"); | ||
} | ||
|
||
@NotNull | ||
@Override | ||
public String getLookupString() { | ||
return prefix.concat(lookup); | ||
} | ||
|
||
@Override | ||
public void renderElement(LookupElementPresentation presentation) { | ||
super.renderElement(presentation); | ||
|
||
presentation.setItemText(name); | ||
presentation.setTailText("/", true); | ||
presentation.setIcon(icon); | ||
} | ||
} |
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