use of net.sourceforge.usbdm.deviceEditor.Activator in project usbdm-eclipse-plugins by podonoghue.
the class DeviceEditor method doSave.
@Override
public void doSave(IProgressMonitor monitor) {
SubMonitor.convert(monitor, 100);
if (fFactory == null) {
return;
}
DeviceInfo deviceInfo = fFactory.getDeviceInfo();
if (deviceInfo == null) {
return;
}
deviceInfo.saveSettings(fProject);
Activator activator = Activator.getDefault();
if (activator != null) {
IDialogSettings dialogSettings = activator.getDialogSettings();
if (dialogSettings != null) {
dialogSettings.put("ActiveTab", fTabFolder.getSelectionIndex());
}
}
}
use of net.sourceforge.usbdm.deviceEditor.Activator in project usbdm-eclipse-plugins by podonoghue.
the class DeviceEditor method createPartControl.
/**
* Creates the editor pages.
*/
@Override
public void createPartControl(Composite parent) {
fFactory = null;
String failureReason = "Unknown";
try {
fFactory = ModelFactory.createModels(fPath, true);
} catch (Exception e) {
failureReason = "Failed to create editor content for '" + fPath + "'.\nReason: " + e.getMessage();
System.err.println(failureReason);
e.printStackTrace();
}
if (fFactory == null) {
Label label = new Label(parent, SWT.NONE);
label.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, false, false));
label.setText(failureReason);
return;
}
Display display = Display.getCurrent();
// Create the containing tab folder
fTabFolder = new CTabFolder(parent, SWT.NONE);
fTabFolder.setSimple(false);
fTabFolder.setBackground(new Color[] { display.getSystemColor(SWT.COLOR_WHITE), display.getSystemColor(SWT.COLOR_TITLE_BACKGROUND_GRADIENT) }, new int[] { 100 }, true);
fTabFolder.setSelectionBackground(new Color[] { display.getSystemColor(SWT.COLOR_WHITE), display.getSystemColor(SWT.COLOR_WHITE) }, new int[] { 100 }, true);
ArrayList<IEditorPage> editors = new ArrayList<IEditorPage>();
for (IPage page : fFactory.getModels()) {
// Pin view
CTabItem tabItem;
tabItem = new CTabItem(fTabFolder, SWT.NONE);
tabItem.setText(page.getName());
IEditorPage editorPage = page.createEditorPage();
editors.add(editorPage);
tabItem.setControl(editorPage.createComposite(fTabFolder));
if ((page.getToolTip() == null) || page.getToolTip().isEmpty()) {
System.err.println("No tooltip");
}
tabItem.setToolTipText(page.getToolTip());
}
fEditors = editors.toArray(new IEditorPage[editors.size()]);
refreshModels();
fFactory.addListener(this);
// Create the actions
makeActions();
// Add selected actions to context menu
hookContextMenu();
try {
Activator activator = Activator.getDefault();
if (activator != null) {
IDialogSettings dialogSettings = activator.getDialogSettings();
if (dialogSettings != null) {
fTabFolder.setSelection(dialogSettings.getInt("ActiveTab"));
}
}
} catch (NumberFormatException e) {
}
}
Aggregations