public void handleEvent(Event event) {
Point point = new Point(event.x, event.y);
final TreeItem item = checkboxTreeViewer.getTree()
.getItem(point);
if (item != null) {
Script s = (Script) item.getData();
if(!createNewTab(s)) {
return;
}
showTab(s);
}
}
private void showTab(final Script s) {
curEditor.setText(s.getScript());
buildTextModifyListener(s);
}
private void buildTextModifyListener(final Script s) {
//TODO modified listener for rsyntaxtextarea
/*curTextBox.addExtendedModifyListener(new ExtendedModifyListener(){
@Override
public void modifyText(ExtendedModifyEvent event) {
CTabItem currentTab = tabs.getSelection();
if(!currentTab.getText().startsWith("*")){
currentTab.setText("*"+currentTab.getText());
}
}});*/
}
private boolean createNewTab(Script s) {
for(CTabItem c : tabs.getItems()){
if(c.getData().equals(s)){
//changeTab(c);
return false;
}
}
CTabItem newItem = new CTabItem(tabs, SWT.CLOSE);
newItem.setData(s);
newItem.setText(s.getReference().getName());
newItem.addDisposeListener(new DisposeListener(){
@Override
public void widgetDisposed(DisposeEvent e) {
if(tabs.getItemCount() == 0){
disableTopBar();
}
}
private void disableTopBar() {
combo.setEnabled(false);
tltmSave.setEnabled(false);
tltmCut.setEnabled(false);
tltmCopy.setEnabled(false);
tltmPaste.setEnabled(false);
}});
Composite comp = new Composite(tabs, SWT.EMBEDDED | SWT.NO_BACKGROUND);
ScriptEditor se = new ScriptEditor(comp, s);
curEditor = se;
newItem.setControl(comp);
changeTab(newItem);
//st.setFont(SWTResourceManager.getFont("Courier New", 9, SWT.NORMAL));
//buildTabStyler(s, st);
enableTopBar(tltmSave, tltmCut, tltmCopy, tltmPaste);
return true;
}
/*
private void buildTabStyler(Script s, final StyledText st) {
final LineStyler styler = stylers.get(s.getScriptType());
st.addLineStyleListener(styler);
st.addKeyListener(new KeyListener() {
@Override
public void keyPressed(KeyEvent e) {
styler.parseBlockComments(st.getText());
if ((e.stateMask & SWT.CTRL) != 0) {
switch (e.keyCode) {
case 'a':
curTextBox.selectAll();
break;
case 's':
save();
break;
case 'z':
//undo();
break;
case 'y':
//redo();
break;
}
}
}
@Override
public void keyReleased(KeyEvent e) {
}
});
}*/
});
checkboxTreeViewer.addCheckStateListener(new ICheckStateListener() {
@Override
public void checkStateChanged(CheckStateChangedEvent event) {
Script s = (Script) event.getElement();
s.setInUse(event.getChecked());
}
});
}