Search in sources :

Example 1 with Activator

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());
        }
    }
}
Also used : Activator(net.sourceforge.usbdm.deviceEditor.Activator) IDialogSettings(org.eclipse.jface.dialogs.IDialogSettings) DeviceInfo(net.sourceforge.usbdm.deviceEditor.information.DeviceInfo)

Example 2 with Activator

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) {
    }
}
Also used : CTabFolder(org.eclipse.swt.custom.CTabFolder) IEditorPage(net.sourceforge.usbdm.deviceEditor.model.IEditorPage) Label(org.eclipse.swt.widgets.Label) ArrayList(java.util.ArrayList) CTabItem(org.eclipse.swt.custom.CTabItem) PartInitException(org.eclipse.ui.PartInitException) IPage(net.sourceforge.usbdm.deviceEditor.model.IPage) Activator(net.sourceforge.usbdm.deviceEditor.Activator) IDialogSettings(org.eclipse.jface.dialogs.IDialogSettings) GridData(org.eclipse.swt.layout.GridData) Display(org.eclipse.swt.widgets.Display)

Aggregations

Activator (net.sourceforge.usbdm.deviceEditor.Activator)2 IDialogSettings (org.eclipse.jface.dialogs.IDialogSettings)2 ArrayList (java.util.ArrayList)1 DeviceInfo (net.sourceforge.usbdm.deviceEditor.information.DeviceInfo)1 IEditorPage (net.sourceforge.usbdm.deviceEditor.model.IEditorPage)1 IPage (net.sourceforge.usbdm.deviceEditor.model.IPage)1 CTabFolder (org.eclipse.swt.custom.CTabFolder)1 CTabItem (org.eclipse.swt.custom.CTabItem)1 GridData (org.eclipse.swt.layout.GridData)1 Display (org.eclipse.swt.widgets.Display)1 Label (org.eclipse.swt.widgets.Label)1 PartInitException (org.eclipse.ui.PartInitException)1