Skip to content

Commit

Permalink
fix code review issue
Browse files Browse the repository at this point in the history
  • Loading branch information
Jamling committed Aug 23, 2017
1 parent 7cd567b commit 16877b6
Show file tree
Hide file tree
Showing 13 changed files with 64 additions and 40 deletions.
2 changes: 1 addition & 1 deletion cn.ieclipse.smartqq.feature/feature.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<feature
id="cn.ieclipse.smartqq.feature"
label="SmartQQ Feature"
version="1.0.7"
version="1.0.8"
provider-name="ieclipse.cn"
plugin="cn.ieclipse.smartqq">

Expand Down
2 changes: 1 addition & 1 deletion cn.ieclipse.smartqq/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: SmartQQ
Bundle-SymbolicName: cn.ieclipse.smartqq;singleton:=true
Bundle-Version: 1.0.7
Bundle-Version: 1.0.8
Bundle-Activator: cn.ieclipse.smartqq.QQPlugin
Bundle-Vendor: ieclipse.cn
Require-Bundle: org.eclipse.ui,
Expand Down
Binary file removed cn.ieclipse.smartqq/icons/sample.gif
Binary file not shown.
Binary file added cn.ieclipse.smartqq/icons/type.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion cn.ieclipse.smartqq/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
allowMultiple="false"
category="cn.ieclipse.smartqq"
class="cn.ieclipse.smartqq.views.ContactView"
icon="icons/editor_area.png"
icon="icons/review.png"
id="cn.ieclipse.smartqq.views.ContactView"
name="Smart">
</view>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import org.eclipse.ui.PlatformUI;

import cn.ieclipse.smartqq.QQPlugin;
import cn.ieclipse.smartqq.views.ContactView;

/**
* 类/接口描述
Expand All @@ -29,7 +30,9 @@
*
*/
public class DisconnectAction extends Action {
public DisconnectAction() {
ContactView contactView;
public DisconnectAction(ContactView contactView) {
this.contactView = contactView;
setText("Close");
setToolTipText("Disconnect from server");
setImageDescriptor(PlatformUI.getWorkbench().getSharedImages()
Expand All @@ -41,6 +44,8 @@ public void run() {
QQPlugin.getDefault().getClient().close();
QQPlugin.getDefault().closeAllChat();
QQPlugin.getDefault().enable = true;

if (contactView != null) {
contactView.initFriends();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,10 @@

import org.eclipse.jface.action.Action;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.swt.SWT;
import org.eclipse.wb.swt.ResourceManager;

import cn.ieclipse.smartqq.QQPlugin;
import cn.ieclipse.smartqq.console.ChatConsole;
import cn.ieclipse.smartqq.views.LetterImageFactory;

/**
* 类/接口描述
Expand All @@ -37,9 +36,10 @@ public SendAction(ChatConsole console) {
this.fConsole = console;
setText("Input");
setToolTipText("Input message");
ImageDescriptor image = ResourceManager
.getImageDescriptor("icons/editor_area.png");
image = LetterImageFactory.createDescriptor('I', SWT.COLOR_DARK_GRAY);
ImageDescriptor image = QQPlugin.getImageDescriptor("icons/type.png");
// image = LetterImageFactory.createDescriptor('I',
// SWT.COLOR_DARK_GRAY);

setImageDescriptor(image);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ protected void init() {

@Override
public void doubleClick(DoubleClickEvent event) {
if (!QQPlugin.getDefault().getClient().isLogin()) {
return;
}
IStructuredSelection isel = (IStructuredSelection) event
.getSelection();
Object obj = isel.getFirstElement();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,13 @@ else if ("discuss".equals(inputElement)) {
}
return groups == null ? null : groups.toArray();
}
List<Category> categories = QQPlugin.getDefault().getClient()
.getFriendListWithCategory();
return categories == null ? null : categories.toArray();
else if ("friend".equals(inputElement)) {
List<Category> categories = QQPlugin.getDefault().getClient()
.getFriendListWithCategory();
return categories == null ? null : categories.toArray();
}
else {
return null;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,15 @@ else if (this.d != null && id.startsWith("D_")) {
}
}

public void sendMsg(final String msg) {
writeMine(msg);
new Thread() {
public void run() {
post(msg);
};
}.start();
}

public void sendFile(final String file) {
final File f = new File(file);
new Thread() {
Expand Down Expand Up @@ -230,7 +239,7 @@ protected void init() {
mineStream = newOutputStream();

outputStream.setColor(SWTResourceManager.getColor(SWT.COLOR_BLACK));
inputStream.setColor(SWTResourceManager.getColor(SWT.COLOR_BLUE));
inputStream.setColor(SWTResourceManager.getColor(SWT.COLOR_BLACK));
promptStream.setColor(
SWTResourceManager.getColor(SWT.COLOR_WIDGET_DARK_SHADOW));
mineStream.setColor(SWTResourceManager.getColor(SWT.COLOR_DARK_BLUE));
Expand Down Expand Up @@ -341,7 +350,6 @@ private void toggleContactView(boolean show) {
}
}


public void activeInput() {
final StyledText text = getPage().getViewer().getTextWidget();
Shell pshell = text.getShell();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,12 +112,7 @@ public void keyPressed(KeyEvent e) {
e.doit = false;
input = text.getText();
if (console != null && !input.isEmpty()) {
console.writeMine(input);
new Thread() {
public void run() {
console.post(input);
};
}.start();
console.sendMsg(input);
}
text.setText("");
setVisible(false);
Expand Down
37 changes: 23 additions & 14 deletions cn.ieclipse.smartqq/src/cn/ieclipse/smartqq/views/ContactView.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ public class ContactView extends ViewPart implements IShowInTarget {
*/
public static final String ID = "cn.ieclipse.smartqq.views.ContactView";
private DrillDownAdapter drillDownAdapter;
private Action action1;
private Action action2;
private Action login;
private Action settings;
private Action exit;
private Action broadcast;
private Action doubleClickAction;
Expand Down Expand Up @@ -122,6 +122,12 @@ public void initFriends() {
QQPlugin.getDefault().getLog().log(info);
}
}
else {
ftvFriend.setInput(null);
ftvGroup.setInput(null);
ftvDiscuss.setInput(null);
ftvRecent.setInput(null);
}
}

private void hookContextMenu() {
Expand All @@ -141,44 +147,47 @@ private void contributeToActionBars() {
}

private void fillLocalPullDown(IMenuManager manager) {
manager.add(action1);
manager.add(login);
manager.add(new Separator());
manager.add(action2);
manager.add(settings);
}

private void fillContextMenu(IMenuManager manager) {
manager.add(action1);
manager.add(login);
manager.add(exit);
manager.add(new Separator());
manager.add(broadcast);
manager.add(action2);
manager.add(settings);
// drillDownAdapter.addNavigationActions(manager);
// Other plug-ins can contribute there actions here
manager.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));
}

private void fillLocalToolBar(IToolBarManager manager) {
manager.add(action1);
manager.add(login);
manager.add(exit);
manager.add(new Separator());
manager.add(broadcast);
manager.add(action2);
manager.add(settings);
// manager.add(doubleClickAction);
// drillDownAdapter.addNavigationActions(manager);
}

private void makeActions() {
action1 = new LoginAction(this);
action2 = new SettingAction();
exit = new DisconnectAction();
login = new LoginAction(this);
settings = new SettingAction();
exit = new DisconnectAction(this);

broadcast = new BroadcastAction();
doubleClickAction = new Action() {
public void run() {
Friend f = new Friend();
f.setUserId(System.currentTimeMillis());
f.setMarkname("Test" + System.currentTimeMillis());
ChatConsole console = QQPlugin.getDefault().findConsole(f, true);
console.write(Utils.formatMsg(System.currentTimeMillis(), "明月", "我的未来不是梦http://www.baidu.com咕咕"));
ChatConsole console = QQPlugin.getDefault().findConsole(f,
true);
console.write(Utils.formatMsg(System.currentTimeMillis(), "明月",
"我的未来不是梦http://www.baidu.com咕咕"));
}
};
doubleClickAction.setText("Test");
Expand All @@ -197,7 +206,7 @@ private void showMessage(String message) {
public void setFocus() {

}

@Override
public boolean show(ShowInContext context) {
ISelection sel = context.getSelection();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,8 @@ public void widgetSelected(SelectionEvent e) {
else {
consoles.remove(console);
}
getButton(IDialogConstants.OK_ID).setEnabled(!consoles.isEmpty());
getButton(IDialogConstants.OK_ID)
.setEnabled(!consoles.isEmpty());
}
});

Expand All @@ -156,7 +157,7 @@ protected void createButtonsForButtonBar(Composite parent) {
true);
createButton(parent, IDialogConstants.CANCEL_ID,
IDialogConstants.CANCEL_LABEL, false);

getButton(IDialogConstants.OK_ID).setEnabled(!consoles.isEmpty());
}

Expand All @@ -165,9 +166,7 @@ protected void okPressed() {
String msg = String.format("%s(Reviews: %s)", text.getText(),
styledText.getText());
for (ChatConsole console : consoles) {
console.write(
Utils.formatMsg(System.currentTimeMillis(), "明月", msg));
System.out.println("send");
console.sendMsg(msg);
}
super.okPressed();
}
Expand Down

0 comments on commit 16877b6

Please sign in to comment.