-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
1. create action and enums and util package. 2. create IconLoadUtil.java process icon file. 3. create BrowserEngineType.java control engine type.
- Loading branch information
Showing
12 changed files
with
327 additions
and
227 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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,51 @@ | ||
package com.raindrop.action; | ||
|
||
import com.intellij.ide.BrowserUtil; | ||
import com.intellij.openapi.actionSystem.AnAction; | ||
import com.intellij.openapi.actionSystem.AnActionEvent; | ||
import com.intellij.openapi.actionSystem.PlatformDataKeys; | ||
import com.intellij.openapi.editor.Editor; | ||
import com.intellij.openapi.editor.SelectionModel; | ||
import com.intellij.openapi.util.text.StringUtil; | ||
import com.raindrop.enums.BrowserEngineType; | ||
import com.raindrop.util.IconLoadUtil; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
import java.io.UnsupportedEncodingException; | ||
import java.net.URLEncoder; | ||
|
||
/** | ||
* @name: com.raindrop.action.SearchBaiDu.java | ||
* @description: BaiDu search action | ||
* @author: Raindrop | ||
* @create Time: 2018/5/16 20:47 | ||
*/ | ||
public class SearchBaiDu extends AnAction { | ||
|
||
private static final Logger logger = LoggerFactory.getLogger(SearchBaiDu.class); | ||
|
||
public SearchBaiDu() { | ||
super(null, null, IconLoadUtil.loadByPath("icon/baidu.png")); | ||
} | ||
|
||
@Override | ||
public void actionPerformed(AnActionEvent e) { | ||
// get editor | ||
final Editor editor = e.getData(PlatformDataKeys.EDITOR); | ||
// get select model | ||
SelectionModel selectionModel = editor.getSelectionModel(); | ||
// get user selected text | ||
String text = selectionModel.getSelectedText(); | ||
if (!StringUtil.isEmpty(text)) { | ||
try { | ||
text = URLEncoder.encode(text, "utf-8"); | ||
} catch (UnsupportedEncodingException ex) { | ||
logger.error("BaiDu search url encode error: {}", ex.getMessage()); | ||
} | ||
logger.info("BaiDu search text : {}", text); | ||
BrowserUtil.browse(BrowserEngineType.BAIDU_ENGINE.getEnginePath() + text); | ||
} | ||
} | ||
|
||
} |
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,51 @@ | ||
package com.raindrop.action; | ||
|
||
import com.intellij.ide.BrowserUtil; | ||
import com.intellij.openapi.actionSystem.AnAction; | ||
import com.intellij.openapi.actionSystem.AnActionEvent; | ||
import com.intellij.openapi.actionSystem.PlatformDataKeys; | ||
import com.intellij.openapi.editor.Editor; | ||
import com.intellij.openapi.editor.SelectionModel; | ||
import com.intellij.openapi.util.text.StringUtil; | ||
import com.raindrop.enums.BrowserEngineType; | ||
import com.raindrop.util.IconLoadUtil; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
import java.io.UnsupportedEncodingException; | ||
import java.net.URLEncoder; | ||
|
||
/** | ||
* @name: com.raindrop.action.SearchDuckDuckGo.java | ||
* @description: DuckDuckGo search action | ||
* @author: Raindrop | ||
* @create Time: 2018/5/16 20:47 | ||
*/ | ||
public class SearchDuckDuckGo extends AnAction { | ||
|
||
private static final Logger logger = LoggerFactory.getLogger(SearchDuckDuckGo.class); | ||
|
||
public SearchDuckDuckGo() { | ||
super(null, null, IconLoadUtil.loadByPath("icon/duckduckgo.png")); | ||
} | ||
|
||
@Override | ||
public void actionPerformed(AnActionEvent e) { | ||
// get editor | ||
final Editor editor = e.getData(PlatformDataKeys.EDITOR); | ||
// get select model | ||
SelectionModel selectionModel = editor.getSelectionModel(); | ||
// get user selected text | ||
String text = selectionModel.getSelectedText(); | ||
if (!StringUtil.isEmpty(text)) { | ||
try { | ||
text = URLEncoder.encode(text, "utf-8"); | ||
} catch (UnsupportedEncodingException ex) { | ||
logger.error("DuckDuckGo search url encode error: {}", ex.getMessage()); | ||
} | ||
logger.info("DuckDuckGo search text : {}", text); | ||
BrowserUtil.browse(BrowserEngineType.DUCK_ENGINE.getEnginePath() + text); | ||
} | ||
} | ||
|
||
} |
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,51 @@ | ||
package com.raindrop.action; | ||
|
||
import com.intellij.ide.BrowserUtil; | ||
import com.intellij.openapi.actionSystem.AnAction; | ||
import com.intellij.openapi.actionSystem.AnActionEvent; | ||
import com.intellij.openapi.actionSystem.PlatformDataKeys; | ||
import com.intellij.openapi.editor.Editor; | ||
import com.intellij.openapi.editor.SelectionModel; | ||
import com.intellij.openapi.util.text.StringUtil; | ||
import com.raindrop.enums.BrowserEngineType; | ||
import com.raindrop.util.IconLoadUtil; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
import java.io.UnsupportedEncodingException; | ||
import java.net.URLEncoder; | ||
|
||
/** | ||
* @name: com.raindrop.action.SearchGoogle.java | ||
* @description: Google search action | ||
* @author: Raindrop | ||
* @create Time: 2018/5/16 20:47 | ||
*/ | ||
public class SearchGoogle extends AnAction { | ||
|
||
private static final Logger logger = LoggerFactory.getLogger(SearchGoogle.class); | ||
|
||
public SearchGoogle() { | ||
super(null, null, IconLoadUtil.loadByPath("icon/chrome.png")); | ||
} | ||
|
||
@Override | ||
public void actionPerformed(AnActionEvent e) { | ||
// get editor | ||
final Editor editor = e.getData(PlatformDataKeys.EDITOR); | ||
// get select model | ||
SelectionModel selectionModel = editor.getSelectionModel(); | ||
// get user selected text | ||
String text = selectionModel.getSelectedText(); | ||
if (!StringUtil.isEmpty(text)) { | ||
try { | ||
text = URLEncoder.encode(text, "utf-8"); | ||
} catch (UnsupportedEncodingException ex) { | ||
logger.error("Google search url encode error: {}", ex.getMessage()); | ||
} | ||
logger.info("Google search text : {}", text); | ||
BrowserUtil.browse(BrowserEngineType.GOOGLE_ENGINE.getEnginePath() + text); | ||
} | ||
} | ||
|
||
} |
Oops, something went wrong.