Search in sources :

Example 1 with IEditorPage

use of net.sourceforge.usbdm.deviceEditor.model.IEditorPage in project usbdm-eclipse-plugins by podonoghue.

the class DeviceEditor method refreshModels.

/**
 * Set the models for page 1..N<br>
 * Page 0 is assumed unchanged
 */
private void refreshModels() {
    ArrayList<IPage> models = fFactory.getModels();
    int index = 0;
    for (IEditorPage page : fEditors) {
        page.update(models.get(index++));
    }
}
Also used : IPage(net.sourceforge.usbdm.deviceEditor.model.IPage) IEditorPage(net.sourceforge.usbdm.deviceEditor.model.IEditorPage)

Example 2 with IEditorPage

use of net.sourceforge.usbdm.deviceEditor.model.IEditorPage 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

IEditorPage (net.sourceforge.usbdm.deviceEditor.model.IEditorPage)2 IPage (net.sourceforge.usbdm.deviceEditor.model.IPage)2 ArrayList (java.util.ArrayList)1 Activator (net.sourceforge.usbdm.deviceEditor.Activator)1 IDialogSettings (org.eclipse.jface.dialogs.IDialogSettings)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