use of org.eclipse.linuxtools.oprofile.ui.model.UiModelSession in project linuxtools by eclipse.
the class OprofileView method selectionChanged.
@Override
public void selectionChanged(SelectionChangedEvent event) {
TreeSelection tsl = (TreeSelection) viewer.getSelection();
if (tsl.getFirstElement() instanceof UiModelSession) {
if (!deleteSessionAction.isEnabled()) {
deleteSessionAction.setEnabled(true);
}
if (((UiModelSession) tsl.getFirstElement()).isDefaultSession()) {
if (!saveDefaultSessionAction.isEnabled()) {
saveDefaultSessionAction.setEnabled(true);
}
}
} else {
deleteSessionAction.setEnabled(false);
saveDefaultSessionAction.setEnabled(false);
}
}
use of org.eclipse.linuxtools.oprofile.ui.model.UiModelSession in project linuxtools by eclipse.
the class OprofileViewDeleteSessionAction method run.
@Override
public void run() {
TreeSelection tsl = (TreeSelection) treeViewer.getSelection();
if (tsl.getFirstElement() instanceof UiModelSession) {
UiModelSession sess = (UiModelSession) tsl.getFirstElement();
deleteSession(sess);
}
OprofileUiPlugin.getDefault().getOprofileView().refreshView();
}
use of org.eclipse.linuxtools.oprofile.ui.model.UiModelSession in project linuxtools by eclipse.
the class OprofileViewDoubleClickListener method doubleClick.
@Override
public void doubleClick(DoubleClickEvent event) {
TreeViewer tv = (TreeViewer) event.getSource();
TreeSelection tsl = (TreeSelection) tv.getSelection();
IUiModelElement element = (IUiModelElement) tsl.getFirstElement();
try {
if (element instanceof UiModelEvent) {
// UiModelEvent event = (UiModelEvent)element;
} else if (element instanceof UiModelSession) {
/* moved into an action menu */
} else if (element instanceof UiModelImage) {
// UiModelImage image = (UiModelImage)element;
} else if (element instanceof UiModelSymbol) {
final UiModelSymbol symbol = (UiModelSymbol) element;
final String fileName = symbol.getFileName();
int line = symbol.getLineNumber();
ProfileUIUtils.openEditorAndSelect(fileName, line);
} else if (element instanceof UiModelSample) {
// jump to line number in the appropriate file
UiModelSample sample = (UiModelSample) element;
int line = sample.getLine();
// get file name from the parent sample
final String fileName = sample.getFile();
ProfileUIUtils.openEditorAndSelect(fileName, line, getProject());
}
} catch (BadLocationException e1) {
e1.printStackTrace();
} catch (PartInitException e2) {
e2.printStackTrace();
} catch (CoreException e) {
e.printStackTrace();
}
}
use of org.eclipse.linuxtools.oprofile.ui.model.UiModelSession in project linuxtools by eclipse.
the class OprofileViewSaveDefaultSessionAction method run.
@Override
public void run() {
boolean defaultSessionExists = false;
UiModelRoot modelRoot = UiModelRoot.getDefault();
String defaultSessionName = null;
IUiModelElement[] modelEvents = null;
if (modelRoot.hasChildren()) {
IUiModelElement[] sessions = modelRoot.getChildren();
for (IUiModelElement e : sessions) {
if (e instanceof UiModelError)
break;
if (e instanceof UiModelSession) {
if (((UiModelSession) e).isDefaultSession()) {
defaultSessionExists = true;
defaultSessionName = e.getLabelText();
modelEvents = ((UiModelSession) e).getChildren();
break;
}
if (defaultSessionExists)
break;
}
}
if (defaultSessionExists) {
// the following code was originially written by Keith Seitz
InputDialog dialog = new InputDialog(OprofileUiPlugin.getActiveWorkbenchShell(), // $NON-NLS-1$
OprofileUiMessages.getString("savedialog.title"), // $NON-NLS-1$
OprofileUiMessages.getString("savedialog.message"), // $NON-NLS-1$
OprofileUiMessages.getString("savedialog.initial"), new SaveSessionValidator());
int result = dialog.open();
if (result == Window.OK) {
SessionManager.saveSession(dialog.getValue());
// remove the default session
for (int i = 0; i < modelEvents.length; i++) {
SessionManager.deleteSession(defaultSessionName, modelEvents[i].getLabelText());
}
if (Oprofile.OprofileProject.OPERF_BINARY.equals(Oprofile.OprofileProject.getProfilingBinary())) {
// remove oprofile_data so current event no longer
// be there
OprofileViewDeleteSessionAction.deleteOperfDataFolder(Oprofile.OprofileProject.getProject().getFolder(Oprofile.OprofileProject.OPERF_DATA));
}
OprofileUiPlugin.getDefault().getOprofileView().refreshView();
}
} else {
MessageDialog.openError(OprofileUiPlugin.getActiveWorkbenchShell(), OprofileUiMessages.getString(// $NON-NLS-1$
"defaultsessiondialog.nodefaultsession.title"), OprofileUiMessages.getString(// $NON-NLS-1$
"defaultsessiondialog.nodefaultsession.message"));
}
}
}
Aggregations