inputElementDialog.open();
}
});
menuManager.update(true);
IToolBarManager toolBarManager = getViewSite().getActionBars()
.getToolBarManager();
toolBarManager.add(new Action("Export Log") {
{
setImageDescriptor(Activator.imageDescriptorFromPlugin(
Activator.PLUGIN_ID, "/icons/export_log.gif"));
}
public void run() {
FileDialog dlg = new FileDialog(Display.getCurrent()
.getActiveShell(), SWT.SAVE);
dlg.setText("Export log to:");
String open = dlg.open();
if (open != null) {
try {
FileOutputStream s = new FileOutputStream(open);
BufferedWriter bf = new BufferedWriter(
new OutputStreamWriter(s));
try {
bf.append(currentLogs);
bf.close();
} catch (Exception e) {
MessageDialog.openError(Display.getCurrent()
.getActiveShell(), "Error", e.getMessage());
}
} catch (FileNotFoundException e) {
MessageDialog.openError(Display.getCurrent()
.getActiveShell(), "Error", e.getMessage());
}
}
}
});
toolBarManager.add(new Action("Import Log") {
{
setImageDescriptor(Activator.imageDescriptorFromPlugin(
Activator.PLUGIN_ID, "/icons/import_log.gif"));
}
public void run() {
FileDialog dlg = new FileDialog(Display.getCurrent()
.getActiveShell(), SWT.OPEN);
dlg.setText("Open log from");
String open = dlg.open();
if (open != null) {
try {
FileInputStream s = new FileInputStream(open);
BufferedReader bf = new BufferedReader(
new InputStreamReader(s));
StringBuilder bld = new StringBuilder();
;
ArrayList<LogItem> result = new ArrayList<LogItem>();
try {
while (true) {
try {
String str = bf.readLine();
if (str == null) {
break;
}
try {
result.add(new LogItem(str));
} catch (Exception e) {
e.printStackTrace();
}
bld.append(str);
bld.append('\n');
} catch (IOException e) {
MessageDialog.openError(Display
.getCurrent().getActiveShell(),
"Error", e.getMessage());
}
}
logViewer.setInput(result
.toArray(new LogItem[result.size()]));
currentLogs = bld.toString();
} catch (Exception e) {
MessageDialog.openError(Display.getCurrent()
.getActiveShell(), "Error", e.getMessage());
}
} catch (FileNotFoundException e) {
MessageDialog.openError(Display.getCurrent()
.getActiveShell(), "Error", e.getMessage());
}
}
}
});
sync = new Action("Sync with Server") {
{
setImageDescriptor(Activator.imageDescriptorFromPlugin(
Activator.PLUGIN_ID, "/icons/refresh.gif"));
}
public void run() {
refreshLog(currentProject);
}
};
menuManager.add(new Separator());
Action action = new Action("Split horizontally",
IAction.AS_RADIO_BUTTON) {
{
setImageDescriptor(Activator.imageDescriptorFromPlugin(
Activator.PLUGIN_ID, "icons/horizontalOrientation.gif"));
}
public void run() {
owner.setOrientation(SWT.HORIZONTAL);
logViewer.getTreeViewer().getTree().layout(true, true);
}
};
action.setChecked(owner.getOrientation() == SWT.HORIZONTAL);
menuManager.add(action);
menuManager
.add(new Action("Split vertically", IAction.AS_RADIO_BUTTON) {
{
setImageDescriptor(Activator.imageDescriptorFromPlugin(
Activator.PLUGIN_ID,
"icons/verticalOrientation.gif"));
setChecked(owner.getOrientation() == SWT.VERTICAL);
}
public void run() {
owner.setOrientation(SWT.VERTICAL);
logViewer.getTreeViewer().getTree().layout(true, true);
}
});
sync.setEnabled(false);
toolBarManager.add(sync);
toolBarManager.update(true);
}